Lime Web Components API Documentation - v6.24.0
    Preparing search index...

    Interface LimeWebComponentPlatform

    Service container for the Lime CRM platform that provides access to all platform services.

    The platform acts as a service locator for accessing repositories, the command bus, HTTP client, and other services throughout the application. It is used by web components (injected via Stencil's @Prop decorator), command handlers, and other parts of the system.

    The platform type indicates which Lime CRM client is hosting the component:

    • LimeCRMWebClient: Standard web client
    • LimeCRMDesktopClient: Desktop application client
    • LimeCRMWebAdminClient: Administrative web interface
    // Get core services
    const http = platform.get(PlatformServiceName.Http);
    const commandBus = platform.get(PlatformServiceName.CommandBus);
    const limetypes = platform.get(PlatformServiceName.LimeTypeRepository);

    // Check platform type for conditional logic
    if (platform.type === 'LimeCRMDesktopClient') {
    // Desktop-specific functionality
    }

    // Check feature switches
    if (platform.isFeatureEnabled('newFeature')) {
    // Use new feature
    }
    // Register a custom service (third-party plugins)
    platform.register('myPlugin.analytics', new AnalyticsService());

    // Later retrieve it
    const analytics = platform.get('myPlugin.analytics');
    interface LimeWebComponentPlatform {
        type:
            | "LimeCRMWebClient"
            | "LimeCRMDesktopClient"
            | "LimeCRMWebAdminClient";
        get(name: string): any;
        get(name: "state.limetypes"): LimeTypeRepository;
        get(name: "state.configs"): ConfigRepository;
        get(name: "query"): QueryService;
        get(name: "state.limeobjects"): LimeObjectRepository;
        get(name: "state.filters"): FilterRepository;
        get(name: "state.application"): ApplicationRepository;
        get(name: "contextRegistry"): ContextRegistry;
        get(name: "ruleRegistry"): RuleRegistry;
        get(name: "webComponentRegistry"): WebComponentRegistry;
        get(name: "eventDispatcher"): EventDispatcher;
        get(name: "commandBus"): CommandBus;
        get(name: "conditionRegistry"): ConditionRegistry;
        get(name: "translate"): Translator;
        get(name: "http"): HttpClient;
        get(name: "dialog"): DialogRenderer;
        get(name: "keybindingRegistry"): KeybindingRegistry;
        get(name: "routeRegistry"): RouteRegistry;
        get(name: "navigator"): Navigator;
        get(name: "notifications"): Notifications;
        get(name: "state.tasks"): TaskRepository;
        get(name: "state.device"): Device;
        get(name: "state.user-data"): UserDataRepository;
        get(name: "userPreferences"): UserPreferencesRepository;
        get(name: "datetimeformatter"): DateTimeFormatter;
        get(name: "viewFactoryRegistry"): ViewFactoryRegistry;
        get(name: "state.notifications"): NotificationRepository;
        get(name: "pollerFactory"): PollerFactory;
        get(name: "logger"): LoggerFactory;
        get(name: "problemRepository"): ProblemRepository;
        get(name: "aiContextRegistry"): AIContextRegistry;
        has(name: string): boolean;
        isFeatureEnabled(name: never): boolean;
        register(name: string, service: any): void;
    }
    Index

    Properties

    type: "LimeCRMWebClient" | "LimeCRMDesktopClient" | "LimeCRMWebAdminClient"

    The type of Lime CRM client currently running. Use this to conditionally enable features based on the client environment.

    Methods

    • Check if a service is currently registered on the platform.

      Useful for optional dependencies or checking service availability.

      Parameters

      • name: string

        The name of the service to check

      Returns boolean

      true if the service is registered, false otherwise

      if (platform.has(PlatformServiceName.Analytics)) {
      const tracker = platform.get(PlatformServiceName.Analytics);
      tracker.track('event');
      }
    • Check if a feature is enabled in the current environment.

      Feature switches allow gradual rollout of new functionality and environment-specific behavior. Features can be enabled/disabled at the application, user, or system level.

      Parameters

      • name: never

        Name of the feature switch to check

      Returns boolean

      true if the feature is enabled, false otherwise

      // Use feature switches for gradual rollout
      if (platform.isFeatureEnabled('advancedSearch')) {
      return new AdvancedSearchComponent();
      } else {
      return new BasicSearchComponent();
      }
    • Register a service on the platform for use throughout the application.

      Service names are typically defined in the PlatformServiceName enum through module augmentation. This ensures type safety and prevents naming conflicts.

      Parameters

      • name: string

        The name to register the service under

      • service: any

        The service instance to register

      Returns void

      const SERVICE_NAME = 'myPlugin.cache';
      PlatformServiceName.MyCache = SERVICE_NAME;

      declare module '@limetech/lime-web-components' {
      interface PlatformServiceNameType {
      MyCache: typeof SERVICE_NAME;
      }

      interface LimeWebComponentPlatform {
      get(name: PlatformServiceNameType['MyCache']): CacheService;
      }
      }

      // Register the service
      platform.register(PlatformServiceName.MyCache, new CacheService());