@netsapiens/horizon-sdk 0.1.5 → 0.1.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.cts CHANGED
@@ -592,7 +592,12 @@ declare class RemoteAppSDK {
592
592
  private dynamicColumns;
593
593
  private callEventsSubscribed;
594
594
  private sidePanelOpen;
595
- constructor(eventBus: HorizonEventBus, appId: string);
595
+ /**
596
+ * @param webpackModule Your Module Federation container name (the `name` in
597
+ * ModuleFederationPlugin, camelCase). The app's `appId` is derived from it
598
+ * via {@link deriveAppId} so it matches the host/API registry `id`.
599
+ */
600
+ constructor(eventBus: HorizonEventBus, webpackModule: string);
596
601
  registerRoute(config: Omit<RouteConfig, "appId">): Promise<void>;
597
602
  unregisterRoute(routeId: string): void;
598
603
  /**
@@ -639,8 +644,30 @@ declare class RemoteAppSDK {
639
644
  getRegisteredDynamicExtensions(): string[];
640
645
  getRegisteredDynamicColumns(): string[];
641
646
  }
642
- /** Factory: equivalent to `new RemoteAppSDK(...)`. */
643
- declare function createRemoteAppSDK(eventBus: HorizonEventBus, appId: string): RemoteAppSDK;
647
+ /**
648
+ * Factory: equivalent to `new RemoteAppSDK(...)`. Pass your Module Federation
649
+ * container name (`webpack_module`, camelCase); the appId is derived from it.
650
+ */
651
+ declare function createRemoteAppSDK(eventBus: HorizonEventBus, webpackModule: string): RemoteAppSDK;
652
+
653
+ /**
654
+ * Derive a remote app's stable `appId` (the kebab-case registry `id`) from its
655
+ * Module Federation container name (`webpack_module`, camelCase).
656
+ *
657
+ * This mirrors the derivation the Horizon host and the `/ui-extensions` API use
658
+ * (`id = kebab(webpack_module)`), so a remote app specifies ONE identifier — the
659
+ * `name` in its `ModuleFederationPlugin` config — and the SDK, host, and API all
660
+ * agree on the resulting app id (used for registration attribution, audit, and
661
+ * the `/ui-extensions/{id}` route).
662
+ *
663
+ * Idempotent: an already-kebab value is returned unchanged, so passing either
664
+ * form works.
665
+ *
666
+ * @example
667
+ * deriveAppId("ucaasExtensionDemo"); // "ucaas-extension-demo"
668
+ * deriveAppId("ucaas-extension-demo"); // "ucaas-extension-demo" (unchanged)
669
+ */
670
+ declare function deriveAppId(webpackModule: string): string;
644
671
 
645
672
  /**
646
673
  * Wrap your registered page components with this provider so they receive a
@@ -818,9 +845,15 @@ declare function useSidePanel(eventBus?: HorizonContext["eventBus"], appId?: str
818
845
  * Get an SDK instance bound to your app, plus a flat view of the Horizon
819
846
  * context. Returned `sdk.cleanup()` is called automatically on unmount.
820
847
  *
848
+ * Pass your **Module Federation container name** — the `name` in your
849
+ * `ModuleFederationPlugin` config (a.k.a. `webpack_module`, camelCase). That's
850
+ * the single identifier you maintain; the SDK derives the kebab-case app id
851
+ * (matching the host/API registry `id`) for you via {@link deriveAppId}.
852
+ *
821
853
  * @example
822
854
  * export default function MyApp(horizonContext: HorizonContext) {
823
- * const { sdk, user } = useRemoteApp(horizonContext, 'my-app');
855
+ * // 'myApp' === the name in your ModuleFederationPlugin config
856
+ * const { sdk, user } = useRemoteApp(horizonContext, 'myApp');
824
857
  *
825
858
  * useEffect(() => {
826
859
  * sdk.registerDynamicExtension({
@@ -834,7 +867,7 @@ declare function useSidePanel(eventBus?: HorizonContext["eventBus"], appId?: str
834
867
  * return <div>Hello {user.displayName}</div>;
835
868
  * }
836
869
  */
837
- declare function useRemoteApp(horizonContext: HorizonContext, appId: string): {
870
+ declare function useRemoteApp(horizonContext: HorizonContext, webpackModule: string): {
838
871
  user: HorizonUser;
839
872
  auth: HorizonAuth;
840
873
  api: HorizonApiClient;
@@ -850,12 +883,12 @@ declare function useRemoteApp(horizonContext: HorizonContext, appId: string): {
850
883
  /**
851
884
  * Register a route for the lifetime of the calling component.
852
885
  */
853
- declare function useRoute(eventBus: HorizonContext["eventBus"], appId: string, config: Omit<RouteConfig, "appId">): RemoteAppSDK;
886
+ declare function useRoute(eventBus: HorizonContext["eventBus"], webpackModule: string, config: Omit<RouteConfig, "appId">): RemoteAppSDK;
854
887
  /**
855
888
  * Register a route by pulling its component out of a federated module's
856
889
  * webpack container.
857
890
  */
858
- declare function useRouteFromModule(eventBus: HorizonContext["eventBus"], appId: string, routeConfig: Omit<RouteConfig, "appId" | "component">, moduleConfig: RemoteModuleConfig): {
891
+ declare function useRouteFromModule(eventBus: HorizonContext["eventBus"], webpackModule: string, routeConfig: Omit<RouteConfig, "appId" | "component">, moduleConfig: RemoteModuleConfig): {
859
892
  loading: boolean;
860
893
  error: Error | null;
861
894
  sdk: RemoteAppSDK;
@@ -864,7 +897,7 @@ declare function useRouteFromModule(eventBus: HorizonContext["eventBus"], appId:
864
897
  * Register a dynamic extension (pattern-based UI injection) for the lifetime
865
898
  * of the calling component.
866
899
  */
867
- declare function useDynamicExtension(eventBus: HorizonContext["eventBus"], appId: string, config: Omit<DynamicExtensionConfig, "appId">): RemoteAppSDK;
900
+ declare function useDynamicExtension(eventBus: HorizonContext["eventBus"], webpackModule: string, config: Omit<DynamicExtensionConfig, "appId">): RemoteAppSDK;
868
901
  /**
869
902
  * Returns the current page context as a typed value.
870
903
  *
@@ -892,7 +925,7 @@ declare function usePageContext<T = unknown>(context: ExtensionContext): T | und
892
925
  /**
893
926
  * Register a dynamic table column for the lifetime of the calling component.
894
927
  */
895
- declare function useDynamicColumn(eventBus: HorizonContext["eventBus"], appId: string, config: Omit<DynamicColumnConfig, "appId">): RemoteAppSDK;
928
+ declare function useDynamicColumn(eventBus: HorizonContext["eventBus"], webpackModule: string, config: Omit<DynamicColumnConfig, "appId">): RemoteAppSDK;
896
929
 
897
930
  /**
898
931
  * Federation Error
@@ -1011,107 +1044,6 @@ declare global {
1011
1044
  }
1012
1045
  }
1013
1046
 
1014
- /**
1015
- * Stable Anchor IDs for Extension Placement
1016
- *
1017
- * These anchor IDs are guaranteed to be stable and can be used by extensions
1018
- * to specify their menu placement using semantic anchors.
1019
- *
1020
- * @example
1021
- * ```typescript
1022
- * import { MANAGE_ANCHORS } from '@netsapiens/horizon-sdk';
1023
- *
1024
- * sdk.registerRoute({
1025
- * id: 'my-crm',
1026
- * parentPath: '/apps',
1027
- * path: 'crm',
1028
- * label: 'CRM',
1029
- * placement: { after: MANAGE_ANCHORS.contacts }
1030
- * });
1031
- * ```
1032
- */
1033
- /**
1034
- * Manage Menu Anchors
1035
- * Available in both domain and no-domain contexts
1036
- */
1037
- declare const MANAGE_ANCHORS: {
1038
- readonly dashboard: "manage-dashboard";
1039
- readonly users: "manage-users";
1040
- readonly contacts: "manage-contacts";
1041
- readonly devices: "manage-devices";
1042
- readonly phoneNumbers: "manage-phone-numbers";
1043
- readonly callLogs: "manage-call-logs";
1044
- readonly voicemail: "manage-voicemail";
1045
- readonly fax: "manage-fax";
1046
- readonly settings: "manage-settings";
1047
- };
1048
- /**
1049
- * Platform Menu Anchors
1050
- * Available to Admin, Super User, and Reseller scopes
1051
- */
1052
- declare const PLATFORM_ANCHORS: {
1053
- readonly dashboard: "platform-dashboard";
1054
- readonly codeManagement: "platform-code-management";
1055
- readonly configManagement: "platform-config-management";
1056
- readonly sdkManagement: "platform-ui-sdk";
1057
- readonly branding: "platform-branding";
1058
- readonly recording: "platform-recording";
1059
- readonly logsAndDiagnostics: "platform-logs-and-diagnostics";
1060
- };
1061
- /**
1062
- * Apps Menu Anchors
1063
- * Extension apps typically register here
1064
- */
1065
- declare const APPS_ANCHORS: {
1066
- readonly home: "apps-home";
1067
- };
1068
- /**
1069
- * My Account Menu Anchors
1070
- * User-specific settings and preferences
1071
- */
1072
- declare const MY_ACCOUNT_ANCHORS: {
1073
- readonly profile: "my-account-profile";
1074
- readonly preferences: "my-account-preferences";
1075
- readonly security: "my-account-security";
1076
- };
1077
- /**
1078
- * All anchor constants in one object for convenience
1079
- */
1080
- declare const ANCHORS: {
1081
- readonly manage: {
1082
- readonly dashboard: "manage-dashboard";
1083
- readonly users: "manage-users";
1084
- readonly contacts: "manage-contacts";
1085
- readonly devices: "manage-devices";
1086
- readonly phoneNumbers: "manage-phone-numbers";
1087
- readonly callLogs: "manage-call-logs";
1088
- readonly voicemail: "manage-voicemail";
1089
- readonly fax: "manage-fax";
1090
- readonly settings: "manage-settings";
1091
- };
1092
- readonly platform: {
1093
- readonly dashboard: "platform-dashboard";
1094
- readonly codeManagement: "platform-code-management";
1095
- readonly configManagement: "platform-config-management";
1096
- readonly sdkManagement: "platform-ui-sdk";
1097
- readonly branding: "platform-branding";
1098
- readonly recording: "platform-recording";
1099
- readonly logsAndDiagnostics: "platform-logs-and-diagnostics";
1100
- };
1101
- readonly apps: {
1102
- readonly home: "apps-home";
1103
- };
1104
- readonly myAccount: {
1105
- readonly profile: "my-account-profile";
1106
- readonly preferences: "my-account-preferences";
1107
- readonly security: "my-account-security";
1108
- };
1109
- };
1110
- /**
1111
- * Type-safe anchor ID union
1112
- */
1113
- type AnchorId = (typeof MANAGE_ANCHORS)[keyof typeof MANAGE_ANCHORS] | (typeof PLATFORM_ANCHORS)[keyof typeof PLATFORM_ANCHORS] | (typeof APPS_ANCHORS)[keyof typeof APPS_ANCHORS] | (typeof MY_ACCOUNT_ANCHORS)[keyof typeof MY_ACCOUNT_ANCHORS];
1114
-
1115
1047
  declare const VERSION: string;
1116
1048
 
1117
- export { ANCHORS, APPS_ANCHORS, type AnchorId, type BreadcrumbItem, type CallEvent, type CallEventType, type DynamicColumnConfig, type DynamicColumnDefinition, type DynamicExtensionConfig, type ExtensionComponentProps, type ExtensionContext, type ExtensionZone, type ExtensionZoneId, type FormPanelStep, type HorizonApiClient, type HorizonAuth, type HorizonContext, HorizonContextProvider, type HorizonEventBus, HorizonSDKError, type HorizonSDKErrorCode, type HorizonSDKErrorOptions, type HorizonUI, type HorizonUITemplates, type HorizonUser, MANAGE_ANCHORS, MY_ACCOUNT_ANCHORS, PLATFORM_ANCHORS, RemoteAppSDK, type RemoteAuthError, type RemoteAuthOptions, type RemoteAuthRequest, type RemoteAuthResponse, type RemoteModuleConfig, type RouteConfig, type RoutePattern, type SemanticPlacement, type SidePanelConfig, type SidePanelContentProps, type TableFilterBarContext, type ThemeTokens, VERSION, apiError, createHorizonSDKError, createLogger, createRemoteAppSDK, getLogLevel, invalidExtensionPointError, moduleLoadError, permissionDeniedError, rateLimitError, setLogLevel, signatureVerificationError, useDynamicColumn, useDynamicExtension, useHorizonContext, useLocale, usePageContext, useRemoteApp, useRoute, useRouteFromModule, useSidePanel, useTheme };
1049
+ export { type BreadcrumbItem, type CallEvent, type CallEventType, type DynamicColumnConfig, type DynamicColumnDefinition, type DynamicExtensionConfig, type ExtensionComponentProps, type ExtensionContext, type ExtensionZone, type ExtensionZoneId, type FormPanelStep, type HorizonApiClient, type HorizonAuth, type HorizonContext, HorizonContextProvider, type HorizonEventBus, HorizonSDKError, type HorizonSDKErrorCode, type HorizonSDKErrorOptions, type HorizonUI, type HorizonUITemplates, type HorizonUser, RemoteAppSDK, type RemoteAuthError, type RemoteAuthOptions, type RemoteAuthRequest, type RemoteAuthResponse, type RemoteModuleConfig, type RouteConfig, type RoutePattern, type SemanticPlacement, type SidePanelConfig, type SidePanelContentProps, type TableFilterBarContext, type ThemeTokens, VERSION, apiError, createHorizonSDKError, createLogger, createRemoteAppSDK, deriveAppId, getLogLevel, invalidExtensionPointError, moduleLoadError, permissionDeniedError, rateLimitError, setLogLevel, signatureVerificationError, useDynamicColumn, useDynamicExtension, useHorizonContext, useLocale, usePageContext, useRemoteApp, useRoute, useRouteFromModule, useSidePanel, useTheme };
package/dist/index.d.ts CHANGED
@@ -592,7 +592,12 @@ declare class RemoteAppSDK {
592
592
  private dynamicColumns;
593
593
  private callEventsSubscribed;
594
594
  private sidePanelOpen;
595
- constructor(eventBus: HorizonEventBus, appId: string);
595
+ /**
596
+ * @param webpackModule Your Module Federation container name (the `name` in
597
+ * ModuleFederationPlugin, camelCase). The app's `appId` is derived from it
598
+ * via {@link deriveAppId} so it matches the host/API registry `id`.
599
+ */
600
+ constructor(eventBus: HorizonEventBus, webpackModule: string);
596
601
  registerRoute(config: Omit<RouteConfig, "appId">): Promise<void>;
597
602
  unregisterRoute(routeId: string): void;
598
603
  /**
@@ -639,8 +644,30 @@ declare class RemoteAppSDK {
639
644
  getRegisteredDynamicExtensions(): string[];
640
645
  getRegisteredDynamicColumns(): string[];
641
646
  }
642
- /** Factory: equivalent to `new RemoteAppSDK(...)`. */
643
- declare function createRemoteAppSDK(eventBus: HorizonEventBus, appId: string): RemoteAppSDK;
647
+ /**
648
+ * Factory: equivalent to `new RemoteAppSDK(...)`. Pass your Module Federation
649
+ * container name (`webpack_module`, camelCase); the appId is derived from it.
650
+ */
651
+ declare function createRemoteAppSDK(eventBus: HorizonEventBus, webpackModule: string): RemoteAppSDK;
652
+
653
+ /**
654
+ * Derive a remote app's stable `appId` (the kebab-case registry `id`) from its
655
+ * Module Federation container name (`webpack_module`, camelCase).
656
+ *
657
+ * This mirrors the derivation the Horizon host and the `/ui-extensions` API use
658
+ * (`id = kebab(webpack_module)`), so a remote app specifies ONE identifier — the
659
+ * `name` in its `ModuleFederationPlugin` config — and the SDK, host, and API all
660
+ * agree on the resulting app id (used for registration attribution, audit, and
661
+ * the `/ui-extensions/{id}` route).
662
+ *
663
+ * Idempotent: an already-kebab value is returned unchanged, so passing either
664
+ * form works.
665
+ *
666
+ * @example
667
+ * deriveAppId("ucaasExtensionDemo"); // "ucaas-extension-demo"
668
+ * deriveAppId("ucaas-extension-demo"); // "ucaas-extension-demo" (unchanged)
669
+ */
670
+ declare function deriveAppId(webpackModule: string): string;
644
671
 
645
672
  /**
646
673
  * Wrap your registered page components with this provider so they receive a
@@ -818,9 +845,15 @@ declare function useSidePanel(eventBus?: HorizonContext["eventBus"], appId?: str
818
845
  * Get an SDK instance bound to your app, plus a flat view of the Horizon
819
846
  * context. Returned `sdk.cleanup()` is called automatically on unmount.
820
847
  *
848
+ * Pass your **Module Federation container name** — the `name` in your
849
+ * `ModuleFederationPlugin` config (a.k.a. `webpack_module`, camelCase). That's
850
+ * the single identifier you maintain; the SDK derives the kebab-case app id
851
+ * (matching the host/API registry `id`) for you via {@link deriveAppId}.
852
+ *
821
853
  * @example
822
854
  * export default function MyApp(horizonContext: HorizonContext) {
823
- * const { sdk, user } = useRemoteApp(horizonContext, 'my-app');
855
+ * // 'myApp' === the name in your ModuleFederationPlugin config
856
+ * const { sdk, user } = useRemoteApp(horizonContext, 'myApp');
824
857
  *
825
858
  * useEffect(() => {
826
859
  * sdk.registerDynamicExtension({
@@ -834,7 +867,7 @@ declare function useSidePanel(eventBus?: HorizonContext["eventBus"], appId?: str
834
867
  * return <div>Hello {user.displayName}</div>;
835
868
  * }
836
869
  */
837
- declare function useRemoteApp(horizonContext: HorizonContext, appId: string): {
870
+ declare function useRemoteApp(horizonContext: HorizonContext, webpackModule: string): {
838
871
  user: HorizonUser;
839
872
  auth: HorizonAuth;
840
873
  api: HorizonApiClient;
@@ -850,12 +883,12 @@ declare function useRemoteApp(horizonContext: HorizonContext, appId: string): {
850
883
  /**
851
884
  * Register a route for the lifetime of the calling component.
852
885
  */
853
- declare function useRoute(eventBus: HorizonContext["eventBus"], appId: string, config: Omit<RouteConfig, "appId">): RemoteAppSDK;
886
+ declare function useRoute(eventBus: HorizonContext["eventBus"], webpackModule: string, config: Omit<RouteConfig, "appId">): RemoteAppSDK;
854
887
  /**
855
888
  * Register a route by pulling its component out of a federated module's
856
889
  * webpack container.
857
890
  */
858
- declare function useRouteFromModule(eventBus: HorizonContext["eventBus"], appId: string, routeConfig: Omit<RouteConfig, "appId" | "component">, moduleConfig: RemoteModuleConfig): {
891
+ declare function useRouteFromModule(eventBus: HorizonContext["eventBus"], webpackModule: string, routeConfig: Omit<RouteConfig, "appId" | "component">, moduleConfig: RemoteModuleConfig): {
859
892
  loading: boolean;
860
893
  error: Error | null;
861
894
  sdk: RemoteAppSDK;
@@ -864,7 +897,7 @@ declare function useRouteFromModule(eventBus: HorizonContext["eventBus"], appId:
864
897
  * Register a dynamic extension (pattern-based UI injection) for the lifetime
865
898
  * of the calling component.
866
899
  */
867
- declare function useDynamicExtension(eventBus: HorizonContext["eventBus"], appId: string, config: Omit<DynamicExtensionConfig, "appId">): RemoteAppSDK;
900
+ declare function useDynamicExtension(eventBus: HorizonContext["eventBus"], webpackModule: string, config: Omit<DynamicExtensionConfig, "appId">): RemoteAppSDK;
868
901
  /**
869
902
  * Returns the current page context as a typed value.
870
903
  *
@@ -892,7 +925,7 @@ declare function usePageContext<T = unknown>(context: ExtensionContext): T | und
892
925
  /**
893
926
  * Register a dynamic table column for the lifetime of the calling component.
894
927
  */
895
- declare function useDynamicColumn(eventBus: HorizonContext["eventBus"], appId: string, config: Omit<DynamicColumnConfig, "appId">): RemoteAppSDK;
928
+ declare function useDynamicColumn(eventBus: HorizonContext["eventBus"], webpackModule: string, config: Omit<DynamicColumnConfig, "appId">): RemoteAppSDK;
896
929
 
897
930
  /**
898
931
  * Federation Error
@@ -1011,107 +1044,6 @@ declare global {
1011
1044
  }
1012
1045
  }
1013
1046
 
1014
- /**
1015
- * Stable Anchor IDs for Extension Placement
1016
- *
1017
- * These anchor IDs are guaranteed to be stable and can be used by extensions
1018
- * to specify their menu placement using semantic anchors.
1019
- *
1020
- * @example
1021
- * ```typescript
1022
- * import { MANAGE_ANCHORS } from '@netsapiens/horizon-sdk';
1023
- *
1024
- * sdk.registerRoute({
1025
- * id: 'my-crm',
1026
- * parentPath: '/apps',
1027
- * path: 'crm',
1028
- * label: 'CRM',
1029
- * placement: { after: MANAGE_ANCHORS.contacts }
1030
- * });
1031
- * ```
1032
- */
1033
- /**
1034
- * Manage Menu Anchors
1035
- * Available in both domain and no-domain contexts
1036
- */
1037
- declare const MANAGE_ANCHORS: {
1038
- readonly dashboard: "manage-dashboard";
1039
- readonly users: "manage-users";
1040
- readonly contacts: "manage-contacts";
1041
- readonly devices: "manage-devices";
1042
- readonly phoneNumbers: "manage-phone-numbers";
1043
- readonly callLogs: "manage-call-logs";
1044
- readonly voicemail: "manage-voicemail";
1045
- readonly fax: "manage-fax";
1046
- readonly settings: "manage-settings";
1047
- };
1048
- /**
1049
- * Platform Menu Anchors
1050
- * Available to Admin, Super User, and Reseller scopes
1051
- */
1052
- declare const PLATFORM_ANCHORS: {
1053
- readonly dashboard: "platform-dashboard";
1054
- readonly codeManagement: "platform-code-management";
1055
- readonly configManagement: "platform-config-management";
1056
- readonly sdkManagement: "platform-ui-sdk";
1057
- readonly branding: "platform-branding";
1058
- readonly recording: "platform-recording";
1059
- readonly logsAndDiagnostics: "platform-logs-and-diagnostics";
1060
- };
1061
- /**
1062
- * Apps Menu Anchors
1063
- * Extension apps typically register here
1064
- */
1065
- declare const APPS_ANCHORS: {
1066
- readonly home: "apps-home";
1067
- };
1068
- /**
1069
- * My Account Menu Anchors
1070
- * User-specific settings and preferences
1071
- */
1072
- declare const MY_ACCOUNT_ANCHORS: {
1073
- readonly profile: "my-account-profile";
1074
- readonly preferences: "my-account-preferences";
1075
- readonly security: "my-account-security";
1076
- };
1077
- /**
1078
- * All anchor constants in one object for convenience
1079
- */
1080
- declare const ANCHORS: {
1081
- readonly manage: {
1082
- readonly dashboard: "manage-dashboard";
1083
- readonly users: "manage-users";
1084
- readonly contacts: "manage-contacts";
1085
- readonly devices: "manage-devices";
1086
- readonly phoneNumbers: "manage-phone-numbers";
1087
- readonly callLogs: "manage-call-logs";
1088
- readonly voicemail: "manage-voicemail";
1089
- readonly fax: "manage-fax";
1090
- readonly settings: "manage-settings";
1091
- };
1092
- readonly platform: {
1093
- readonly dashboard: "platform-dashboard";
1094
- readonly codeManagement: "platform-code-management";
1095
- readonly configManagement: "platform-config-management";
1096
- readonly sdkManagement: "platform-ui-sdk";
1097
- readonly branding: "platform-branding";
1098
- readonly recording: "platform-recording";
1099
- readonly logsAndDiagnostics: "platform-logs-and-diagnostics";
1100
- };
1101
- readonly apps: {
1102
- readonly home: "apps-home";
1103
- };
1104
- readonly myAccount: {
1105
- readonly profile: "my-account-profile";
1106
- readonly preferences: "my-account-preferences";
1107
- readonly security: "my-account-security";
1108
- };
1109
- };
1110
- /**
1111
- * Type-safe anchor ID union
1112
- */
1113
- type AnchorId = (typeof MANAGE_ANCHORS)[keyof typeof MANAGE_ANCHORS] | (typeof PLATFORM_ANCHORS)[keyof typeof PLATFORM_ANCHORS] | (typeof APPS_ANCHORS)[keyof typeof APPS_ANCHORS] | (typeof MY_ACCOUNT_ANCHORS)[keyof typeof MY_ACCOUNT_ANCHORS];
1114
-
1115
1047
  declare const VERSION: string;
1116
1048
 
1117
- export { ANCHORS, APPS_ANCHORS, type AnchorId, type BreadcrumbItem, type CallEvent, type CallEventType, type DynamicColumnConfig, type DynamicColumnDefinition, type DynamicExtensionConfig, type ExtensionComponentProps, type ExtensionContext, type ExtensionZone, type ExtensionZoneId, type FormPanelStep, type HorizonApiClient, type HorizonAuth, type HorizonContext, HorizonContextProvider, type HorizonEventBus, HorizonSDKError, type HorizonSDKErrorCode, type HorizonSDKErrorOptions, type HorizonUI, type HorizonUITemplates, type HorizonUser, MANAGE_ANCHORS, MY_ACCOUNT_ANCHORS, PLATFORM_ANCHORS, RemoteAppSDK, type RemoteAuthError, type RemoteAuthOptions, type RemoteAuthRequest, type RemoteAuthResponse, type RemoteModuleConfig, type RouteConfig, type RoutePattern, type SemanticPlacement, type SidePanelConfig, type SidePanelContentProps, type TableFilterBarContext, type ThemeTokens, VERSION, apiError, createHorizonSDKError, createLogger, createRemoteAppSDK, getLogLevel, invalidExtensionPointError, moduleLoadError, permissionDeniedError, rateLimitError, setLogLevel, signatureVerificationError, useDynamicColumn, useDynamicExtension, useHorizonContext, useLocale, usePageContext, useRemoteApp, useRoute, useRouteFromModule, useSidePanel, useTheme };
1049
+ export { type BreadcrumbItem, type CallEvent, type CallEventType, type DynamicColumnConfig, type DynamicColumnDefinition, type DynamicExtensionConfig, type ExtensionComponentProps, type ExtensionContext, type ExtensionZone, type ExtensionZoneId, type FormPanelStep, type HorizonApiClient, type HorizonAuth, type HorizonContext, HorizonContextProvider, type HorizonEventBus, HorizonSDKError, type HorizonSDKErrorCode, type HorizonSDKErrorOptions, type HorizonUI, type HorizonUITemplates, type HorizonUser, RemoteAppSDK, type RemoteAuthError, type RemoteAuthOptions, type RemoteAuthRequest, type RemoteAuthResponse, type RemoteModuleConfig, type RouteConfig, type RoutePattern, type SemanticPlacement, type SidePanelConfig, type SidePanelContentProps, type TableFilterBarContext, type ThemeTokens, VERSION, apiError, createHorizonSDKError, createLogger, createRemoteAppSDK, deriveAppId, getLogLevel, invalidExtensionPointError, moduleLoadError, permissionDeniedError, rateLimitError, setLogLevel, signatureVerificationError, useDynamicColumn, useDynamicExtension, useHorizonContext, useLocale, usePageContext, useRemoteApp, useRoute, useRouteFromModule, useSidePanel, useTheme };
package/dist/index.js CHANGED
@@ -32,6 +32,11 @@ if (typeof window !== "undefined") {
32
32
  }
33
33
  }
34
34
 
35
+ // src/appId.ts
36
+ function deriveAppId(webpackModule) {
37
+ return webpackModule.replace(/([a-z0-9])([A-Z])/g, "$1-$2").toLowerCase();
38
+ }
39
+
35
40
  // src/RemoteAppSDK.ts
36
41
  var log = createLogger("RemoteAppSDK");
37
42
  var RemoteAppSDK = class {
@@ -45,10 +50,15 @@ var RemoteAppSDK = class {
45
50
  dynamicColumns = /* @__PURE__ */ new Set();
46
51
  callEventsSubscribed = false;
47
52
  sidePanelOpen = false;
48
- constructor(eventBus, appId) {
53
+ /**
54
+ * @param webpackModule Your Module Federation container name (the `name` in
55
+ * ModuleFederationPlugin, camelCase). The app's `appId` is derived from it
56
+ * via {@link deriveAppId} so it matches the host/API registry `id`.
57
+ */
58
+ constructor(eventBus, webpackModule) {
49
59
  this.eventBus = eventBus;
50
- this.appId = appId;
51
- log.debug(`Initialized for app: ${appId}`);
60
+ this.appId = deriveAppId(webpackModule);
61
+ log.debug(`Initialized for app: ${this.appId}`);
52
62
  }
53
63
  // -------------------------------------------------------------------------
54
64
  // Routes
@@ -207,8 +217,8 @@ var RemoteAppSDK = class {
207
217
  return Array.from(this.dynamicColumns);
208
218
  }
209
219
  };
210
- function createRemoteAppSDK(eventBus, appId) {
211
- return new RemoteAppSDK(eventBus, appId);
220
+ function createRemoteAppSDK(eventBus, webpackModule) {
221
+ return new RemoteAppSDK(eventBus, webpackModule);
212
222
  }
213
223
  var HorizonContextReact = createContext(null);
214
224
  function HorizonContextProvider({
@@ -297,18 +307,18 @@ function useSidePanel(eventBus, appId) {
297
307
  [bus, appId]
298
308
  );
299
309
  }
300
- function useRemoteApp(horizonContext, appId) {
310
+ function useRemoteApp(horizonContext, webpackModule) {
301
311
  const sdkRef = useRef(null);
302
312
  if (!sdkRef.current) {
303
- sdkRef.current = createRemoteAppSDK(horizonContext.eventBus, appId);
313
+ sdkRef.current = createRemoteAppSDK(horizonContext.eventBus, webpackModule);
304
314
  }
305
315
  const sdk = sdkRef.current;
306
316
  return { sdk, ...horizonContext };
307
317
  }
308
- function useRoute(eventBus, appId, config) {
318
+ function useRoute(eventBus, webpackModule, config) {
309
319
  const sdk = useMemo(
310
- () => createRemoteAppSDK(eventBus, appId),
311
- [eventBus, appId]
320
+ () => createRemoteAppSDK(eventBus, webpackModule),
321
+ [eventBus, webpackModule]
312
322
  );
313
323
  useEffect(() => {
314
324
  void sdk.registerRoute(config);
@@ -316,10 +326,10 @@ function useRoute(eventBus, appId, config) {
316
326
  }, [sdk, config]);
317
327
  return sdk;
318
328
  }
319
- function useRouteFromModule(eventBus, appId, routeConfig, moduleConfig) {
329
+ function useRouteFromModule(eventBus, webpackModule, routeConfig, moduleConfig) {
320
330
  const sdk = useMemo(
321
- () => createRemoteAppSDK(eventBus, appId),
322
- [eventBus, appId]
331
+ () => createRemoteAppSDK(eventBus, webpackModule),
332
+ [eventBus, webpackModule]
323
333
  );
324
334
  const [loading, setLoading] = useState(true);
325
335
  const [error, setError] = useState(null);
@@ -340,10 +350,10 @@ function useRouteFromModule(eventBus, appId, routeConfig, moduleConfig) {
340
350
  }, [sdk, moduleConfig, routeConfig]);
341
351
  return { loading, error, sdk };
342
352
  }
343
- function useDynamicExtension(eventBus, appId, config) {
353
+ function useDynamicExtension(eventBus, webpackModule, config) {
344
354
  const sdk = useMemo(
345
- () => createRemoteAppSDK(eventBus, appId),
346
- [eventBus, appId]
355
+ () => createRemoteAppSDK(eventBus, webpackModule),
356
+ [eventBus, webpackModule]
347
357
  );
348
358
  useEffect(() => {
349
359
  sdk.registerDynamicExtension(config);
@@ -354,10 +364,10 @@ function useDynamicExtension(eventBus, appId, config) {
354
364
  function usePageContext(context) {
355
365
  return context.pageContext;
356
366
  }
357
- function useDynamicColumn(eventBus, appId, config) {
367
+ function useDynamicColumn(eventBus, webpackModule, config) {
358
368
  const sdk = useMemo(
359
- () => createRemoteAppSDK(eventBus, appId),
360
- [eventBus, appId]
369
+ () => createRemoteAppSDK(eventBus, webpackModule),
370
+ [eventBus, webpackModule]
361
371
  );
362
372
  useEffect(() => {
363
373
  sdk.registerDynamicColumn(config);
@@ -506,51 +516,15 @@ function moduleLoadError(appId, url, cause) {
506
516
  });
507
517
  }
508
518
 
509
- // src/anchors.ts
510
- var MANAGE_ANCHORS = {
511
- dashboard: "manage-dashboard",
512
- users: "manage-users",
513
- contacts: "manage-contacts",
514
- devices: "manage-devices",
515
- phoneNumbers: "manage-phone-numbers",
516
- callLogs: "manage-call-logs",
517
- voicemail: "manage-voicemail",
518
- fax: "manage-fax",
519
- settings: "manage-settings"
520
- };
521
- var PLATFORM_ANCHORS = {
522
- dashboard: "platform-dashboard",
523
- codeManagement: "platform-code-management",
524
- configManagement: "platform-config-management",
525
- sdkManagement: "platform-ui-sdk",
526
- branding: "platform-branding",
527
- recording: "platform-recording",
528
- logsAndDiagnostics: "platform-logs-and-diagnostics"
529
- };
530
- var APPS_ANCHORS = {
531
- home: "apps-home"
532
- };
533
- var MY_ACCOUNT_ANCHORS = {
534
- profile: "my-account-profile",
535
- preferences: "my-account-preferences",
536
- security: "my-account-security"
537
- };
538
- var ANCHORS = {
539
- manage: MANAGE_ANCHORS,
540
- platform: PLATFORM_ANCHORS,
541
- apps: APPS_ANCHORS,
542
- myAccount: MY_ACCOUNT_ANCHORS
543
- };
544
-
545
519
  // package.json
546
520
  var package_default = {
547
- version: "0.1.5"};
521
+ version: "0.1.7"};
548
522
 
549
523
  // src/index.ts
550
524
  var VERSION = package_default.version;
551
525
  var log2 = createLogger("FederationSDK");
552
526
  log2.info(`SDK v${VERSION} loaded`);
553
527
 
554
- export { ANCHORS, APPS_ANCHORS, HorizonContextProvider, HorizonSDKError, MANAGE_ANCHORS, MY_ACCOUNT_ANCHORS, PLATFORM_ANCHORS, RemoteAppSDK, VERSION, apiError, createHorizonSDKError, createLogger, createRemoteAppSDK, getLogLevel, invalidExtensionPointError, moduleLoadError, permissionDeniedError, rateLimitError, setLogLevel, signatureVerificationError, useDynamicColumn, useDynamicExtension, useHorizonContext, useLocale, usePageContext, useRemoteApp, useRoute, useRouteFromModule, useSidePanel, useTheme };
528
+ export { HorizonContextProvider, HorizonSDKError, RemoteAppSDK, VERSION, apiError, createHorizonSDKError, createLogger, createRemoteAppSDK, deriveAppId, getLogLevel, invalidExtensionPointError, moduleLoadError, permissionDeniedError, rateLimitError, setLogLevel, signatureVerificationError, useDynamicColumn, useDynamicExtension, useHorizonContext, useLocale, usePageContext, useRemoteApp, useRoute, useRouteFromModule, useSidePanel, useTheme };
555
529
  //# sourceMappingURL=index.js.map
556
530
  //# sourceMappingURL=index.js.map