@equinor/fusion-framework-module-app 2.4.0 → 2.7.0

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.
Files changed (46) hide show
  1. package/CHANGELOG.md +28 -0
  2. package/dist/esm/AppConfigurator.js +1 -1
  3. package/dist/esm/AppConfigurator.js.map +1 -1
  4. package/dist/esm/AppModuleProvider.js +1 -1
  5. package/dist/esm/AppModuleProvider.js.map +1 -1
  6. package/dist/esm/app/App.js +72 -7
  7. package/dist/esm/app/App.js.map +1 -1
  8. package/dist/esm/app/actions.js +1 -0
  9. package/dist/esm/app/actions.js.map +1 -1
  10. package/dist/esm/app/events.js +2 -0
  11. package/dist/esm/app/events.js.map +1 -0
  12. package/dist/esm/app/index.js +3 -0
  13. package/dist/esm/app/index.js.map +1 -0
  14. package/dist/esm/enable-app-module.js +10 -0
  15. package/dist/esm/enable-app-module.js.map +1 -0
  16. package/dist/esm/events.js +1 -6
  17. package/dist/esm/events.js.map +1 -1
  18. package/dist/esm/index.js +1 -0
  19. package/dist/esm/index.js.map +1 -1
  20. package/dist/esm/module.js +0 -3
  21. package/dist/esm/module.js.map +1 -1
  22. package/dist/tsconfig.tsbuildinfo +1 -1
  23. package/dist/types/AppModuleProvider.d.ts +2 -2
  24. package/dist/types/app/App.d.ts +7 -2
  25. package/dist/types/app/actions.d.ts +8 -0
  26. package/dist/types/app/events.d.ts +29 -0
  27. package/dist/types/app/index.d.ts +2 -0
  28. package/dist/types/enable-app-module.d.ts +3 -0
  29. package/dist/types/events.d.ts +3 -14
  30. package/dist/types/index.d.ts +1 -0
  31. package/dist/types/module.d.ts +1 -2
  32. package/dist/types/types.d.ts +10 -10
  33. package/package.json +9 -5
  34. package/src/AppConfigurator.ts +1 -1
  35. package/src/AppModuleProvider.ts +3 -4
  36. package/src/app/App.ts +102 -7
  37. package/src/app/actions.ts +7 -0
  38. package/src/app/create-state.ts +1 -1
  39. package/src/app/events.ts +48 -0
  40. package/src/app/index.ts +3 -0
  41. package/src/app/types.ts +1 -0
  42. package/src/enable-app-module.ts +21 -0
  43. package/src/events.ts +3 -27
  44. package/src/index.ts +2 -0
  45. package/src/module.ts +1 -5
  46. package/src/types.ts +10 -10
@@ -1,11 +1,11 @@
1
1
  import { Observable } from 'rxjs';
2
2
  import { ModuleType } from '@equinor/fusion-framework-module';
3
- import { Query } from '@equinor/fusion-query';
4
3
  import { EventModule } from '@equinor/fusion-framework-module-event';
4
+ import { Query } from '@equinor/fusion-query';
5
5
  import type { AppConfig, AppManifest } from './types';
6
6
  import { App } from './app/App';
7
7
  import { AppModuleConfig } from './AppConfigurator';
8
- import { AppBundleStateInitial } from 'app/types';
8
+ import { AppBundleStateInitial } from './app/types';
9
9
  export declare class AppModuleProvider {
10
10
  #private;
11
11
  static compareAppManifest<T extends AppManifest>(a?: T, b?: T): boolean;
@@ -5,7 +5,7 @@ import { OperatorFunction } from 'rxjs';
5
5
  import { EventModule } from '@equinor/fusion-framework-module-event';
6
6
  import { AnyModule, ModuleType } from '@equinor/fusion-framework-module';
7
7
  import { AppBundleStateInitial } from './types';
8
- import '../events';
8
+ import './events';
9
9
  export declare function filterEmpty<T>(): OperatorFunction<T | null | undefined, T>;
10
10
  export declare class App<TEnv = any, TModules extends Array<AnyModule> | unknown = unknown> {
11
11
  #private;
@@ -21,7 +21,11 @@ export declare class App<TEnv = any, TModules extends Array<AnyModule> | unknown
21
21
  provider: AppModuleProvider;
22
22
  event?: ModuleType<EventModule>;
23
23
  });
24
- initialize(): Observable<[AppManifest, AppScriptModule, AppConfig]>;
24
+ initialize(): Observable<{
25
+ manifest: AppManifest;
26
+ script: AppScriptModule;
27
+ config: AppConfig;
28
+ }>;
25
29
  loadConfig(): void;
26
30
  loadManifest(): void;
27
31
  loadAppModule(allow_cache?: boolean): Promise<void>;
@@ -33,3 +37,4 @@ export declare class App<TEnv = any, TModules extends Array<AnyModule> | unknown
33
37
  getAppModuleAsync(allow_cache?: boolean): Promise<AppScriptModule>;
34
38
  dispose: VoidFunction;
35
39
  }
40
+ export default App;
@@ -19,6 +19,10 @@ declare const createActions: () => {
19
19
  failure: import("@equinor/fusion-observable/dist/types/create-action").ActionCreatorWithPreparedPayload<[error: unknown], unknown, "import_app::failure", never, never>;
20
20
  };
21
21
  setInstance: import("@equinor/fusion-observable/dist/types/create-action").ActionCreatorWithPreparedPayload<[instance: AppModulesInstance<unknown>], AppModulesInstance<unknown>, "set_instance", never, never>;
22
+ initialize: import("@equinor/fusion-observable/dist/types/create-action").ActionCreatorWithPreparedPayload<[], null, "initialize_app::request", never, never> & {
23
+ success: import("@equinor/fusion-observable/dist/types/create-action").ActionCreatorWithPreparedPayload<[], null, "initialize_app::success", never, never>;
24
+ failure: import("@equinor/fusion-observable/dist/types/create-action").ActionCreatorWithPreparedPayload<[error: unknown], unknown, "initialize_app::failure", never, never>;
25
+ };
22
26
  };
23
27
  export declare const actions: {
24
28
  setManifest: import("@equinor/fusion-observable/dist/types/create-action").ActionCreatorWithPreparedPayload<[manifest: AppManifest], AppManifest, "set_manifest", never, {
@@ -39,6 +43,10 @@ export declare const actions: {
39
43
  failure: import("@equinor/fusion-observable/dist/types/create-action").ActionCreatorWithPreparedPayload<[error: unknown], unknown, "import_app::failure", never, never>;
40
44
  };
41
45
  setInstance: import("@equinor/fusion-observable/dist/types/create-action").ActionCreatorWithPreparedPayload<[instance: AppModulesInstance<unknown>], AppModulesInstance<unknown>, "set_instance", never, never>;
46
+ initialize: import("@equinor/fusion-observable/dist/types/create-action").ActionCreatorWithPreparedPayload<[], null, "initialize_app::request", never, never> & {
47
+ success: import("@equinor/fusion-observable/dist/types/create-action").ActionCreatorWithPreparedPayload<[], null, "initialize_app::success", never, never>;
48
+ failure: import("@equinor/fusion-observable/dist/types/create-action").ActionCreatorWithPreparedPayload<[error: unknown], unknown, "initialize_app::failure", never, never>;
49
+ };
42
50
  };
43
51
  export type ActionBuilder = ReturnType<typeof createActions>;
44
52
  export type ActionMap = ActionInstanceMap<ActionBuilder>;
@@ -0,0 +1,29 @@
1
+ import type { FrameworkEvent, FrameworkEventInit } from '@equinor/fusion-framework-module-event';
2
+ import type { App } from './App';
3
+ import type { AppConfig, AppManifest, AppModulesInstance } from '../types';
4
+ export interface AppEventEventInit<TDetail extends Record<string, unknown> | unknown = unknown> extends FrameworkEventInit<TDetail & {
5
+ appKey: string;
6
+ }, App> {
7
+ }
8
+ declare module '@equinor/fusion-framework-module-event' {
9
+ interface FrameworkEventMap {
10
+ onAppModulesLoaded: FrameworkEvent<AppEventEventInit<{
11
+ modules: AppModulesInstance;
12
+ }>>;
13
+ onAppManifestLoaded: FrameworkEvent<AppEventEventInit<{
14
+ manifest: AppManifest;
15
+ }>>;
16
+ onAppConfigLoaded: FrameworkEvent<AppEventEventInit<{
17
+ config: AppConfig;
18
+ }>>;
19
+ onAppScriptLoaded: FrameworkEvent<AppEventEventInit<{
20
+ manifest: AppManifest;
21
+ }>>;
22
+ onAppDispose: FrameworkEvent<AppEventEventInit>;
23
+ onAppInitialize: FrameworkEvent<AppEventEventInit>;
24
+ onAppInitialized: FrameworkEvent<AppEventEventInit>;
25
+ onAppInitializeFailed: FrameworkEvent<AppEventEventInit<{
26
+ error: unknown;
27
+ }>>;
28
+ }
29
+ }
@@ -0,0 +1,2 @@
1
+ export { App } from './App';
2
+ export { default } from './App';
@@ -0,0 +1,3 @@
1
+ import type { IModulesConfigurator } from '@equinor/fusion-framework-module';
2
+ import type { AppConfigBuilderCallback } from './AppConfigBuilder';
3
+ export declare const enableAppModule: (configurator: IModulesConfigurator<any, any>, builder?: AppConfigBuilderCallback) => void;
@@ -1,22 +1,11 @@
1
- import { AnyModule } from '@equinor/fusion-framework-module';
2
1
  import { FrameworkEvent, FrameworkEventInit } from '@equinor/fusion-framework-module-event';
3
- import { App } from 'app/App';
4
- import AppModuleProvider from 'AppModuleProvider';
5
- import { AppModulesInstance } from './types';
6
- type AppModulesLoadedEventInit<TModules extends Array<AnyModule> | unknown = unknown> = FrameworkEventInit<{
7
- appKey: string;
8
- modules: AppModulesInstance<TModules>;
9
- }>;
10
- export declare class AppModulesLoadedEvent<TModules extends Array<AnyModule> | unknown = unknown> extends FrameworkEvent<AppModulesLoadedEventInit<TModules>> {
11
- constructor(appKey: string, modules: AppModulesInstance<TModules>, init?: Omit<AppModulesLoadedEventInit<TModules>, 'detail'>);
12
- }
2
+ import { App } from './app/App';
3
+ import './app/events';
13
4
  declare module '@equinor/fusion-framework-module-event' {
14
5
  interface FrameworkEventMap {
15
- onAppModulesLoaded: AppModulesLoadedEvent;
16
6
  onCurrentAppChanged: FrameworkEvent<FrameworkEventInit<{
17
7
  next?: App;
18
8
  previous?: App;
19
- }, AppModuleProvider>>;
9
+ }>>;
20
10
  }
21
11
  }
22
- export {};
@@ -3,4 +3,5 @@ export { AppModuleProvider } from './AppModuleProvider';
3
3
  export { App } from './app/App';
4
4
  export * from './events';
5
5
  export * from './types';
6
+ export { enableAppModule } from './enable-app-module';
6
7
  export { default, AppModule, module, moduleKey } from './module';
@@ -1,11 +1,10 @@
1
- import { IModulesConfigurator, Module } from '@equinor/fusion-framework-module';
1
+ import { Module } from '@equinor/fusion-framework-module';
2
2
  import { ModuleDeps } from './types';
3
3
  import { IAppConfigurator } from './AppConfigurator';
4
4
  import { AppModuleProvider } from './AppModuleProvider';
5
5
  export declare const moduleKey = "app";
6
6
  export type AppModule = Module<typeof moduleKey, AppModuleProvider, IAppConfigurator, ModuleDeps>;
7
7
  export declare const module: AppModule;
8
- export declare const enableAppModule: (configurator: IModulesConfigurator) => void;
9
8
  export default module;
10
9
  declare module '@equinor/fusion-framework-module' {
11
10
  interface Modules {
@@ -25,20 +25,20 @@ type AppCategory = {
25
25
  export type AppManifest = {
26
26
  appKey: string;
27
27
  name: string;
28
- shortName: string;
28
+ entry: string;
29
29
  version: string;
30
- description: string;
31
- type: AppType;
32
- tags: string[];
30
+ shortName?: string;
31
+ description?: string;
32
+ type?: AppType;
33
+ tags?: string[];
33
34
  auth?: AppAuth[];
34
35
  icon?: string;
35
- order: number | null;
36
- publishedDate: Date | null;
37
- accentColor: string | null;
38
- categoryId: string | null;
39
- category: AppCategory | null;
36
+ order?: number;
37
+ publishedDate?: Date;
38
+ accentColor?: string;
39
+ categoryId?: string;
40
+ category?: AppCategory;
40
41
  hide?: boolean;
41
- entry: string;
42
42
  };
43
43
  export type Endpoint = {
44
44
  name: string;
package/package.json CHANGED
@@ -1,17 +1,21 @@
1
1
  {
2
2
  "name": "@equinor/fusion-framework-module-app",
3
- "version": "2.4.0",
3
+ "version": "2.7.0",
4
4
  "description": "",
5
5
  "main": "dist/esm/index.js",
6
6
  "exports": {
7
7
  ".": "./dist/esm/index.js",
8
- "./errors.js": "./dist/esm/errors.js"
8
+ "./errors.js": "./dist/esm/errors.js",
9
+ "./app": "./dist/esm/app/index.js"
9
10
  },
10
11
  "types": "dist/types/index.d.ts",
11
12
  "typesVersions": {
12
13
  "*": {
13
14
  "errors.js": [
14
15
  "dist/types/errors.d.ts"
16
+ ],
17
+ "app": [
18
+ "dist/types/app/index.d.ts"
15
19
  ]
16
20
  }
17
21
  },
@@ -31,15 +35,15 @@
31
35
  "directory": "packages/module-app"
32
36
  },
33
37
  "dependencies": {
34
- "@equinor/fusion-query": "^1.1.2",
38
+ "@equinor/fusion-query": "^1.1.3",
35
39
  "rxjs": "^7.5.7"
36
40
  },
37
41
  "devDependencies": {
38
42
  "@equinor/fusion-framework-module": "^1.2.10",
39
43
  "@equinor/fusion-framework-module-event": "^1.2.0",
40
44
  "@equinor/fusion-framework-module-http": "^2.2.1",
41
- "@equinor/fusion-framework-module-service-discovery": "^4.0.7",
45
+ "@equinor/fusion-framework-module-service-discovery": "^4.0.8",
42
46
  "typescript": "^4.9.3"
43
47
  },
44
- "gitHead": "a37a5380c885ba37e6462429f4ebc501aee64bb9"
48
+ "gitHead": "02656c04230873efa4aaa758d9b3a974148915f7"
45
49
  }
@@ -80,7 +80,7 @@ export class AppConfigurator implements IAppConfigurator {
80
80
  fn: () => httpClient.json$(`/api/apps`),
81
81
  },
82
82
  // TODO - might cast to checksum
83
- key: (args) => JSON.stringify(args),
83
+ key: () => 'manifests',
84
84
  expire: this.defaultExpireTime,
85
85
  },
86
86
  getAppConfig: {
@@ -10,18 +10,17 @@ import {
10
10
  } from 'rxjs';
11
11
 
12
12
  import { ModuleType } from '@equinor/fusion-framework-module';
13
+ import { HttpResponseError } from '@equinor/fusion-framework-module-http';
14
+ import { EventModule } from '@equinor/fusion-framework-module-event';
13
15
 
14
16
  import { Query } from '@equinor/fusion-query';
15
17
 
16
- import { EventModule } from '@equinor/fusion-framework-module-event';
17
-
18
18
  import type { AppConfig, AppManifest } from './types';
19
19
 
20
20
  import { App, filterEmpty } from './app/App';
21
21
  import { AppModuleConfig } from './AppConfigurator';
22
- import { HttpResponseError } from '@equinor/fusion-framework-module-http';
23
22
  import { AppConfigError, AppManifestError } from './errors';
24
- import { AppBundleStateInitial } from 'app/types';
23
+ import { AppBundleStateInitial } from './app/types';
25
24
 
26
25
  export class AppModuleProvider {
27
26
  static compareAppManifest<T extends AppManifest>(a?: T, b?: T): boolean {
package/src/app/App.ts CHANGED
@@ -18,7 +18,7 @@ import { createState } from './create-state';
18
18
  import { actions, Actions } from './actions';
19
19
  import { AppBundleState, AppBundleStateInitial } from './types';
20
20
 
21
- import '../events';
21
+ import './events';
22
22
 
23
23
  // TODO - move globally
24
24
  export function filterEmpty<T>(): OperatorFunction<T | null | undefined, T> {
@@ -87,12 +87,17 @@ export class App<TEnv = any, TModules extends Array<AnyModule> | unknown = unkno
87
87
  this.#state = createState(value, args.provider);
88
88
 
89
89
  const { appKey } = value;
90
+ const { event } = args;
90
91
 
91
- const subscriptions = new Subscription();
92
+ event && this.#registerEvents(event);
92
93
 
93
- if (args.event) {
94
+ const subscriptions = new Subscription();
95
+ if (event) {
96
+ subscriptions.add(() => {
97
+ event.dispatchEvent('onAppDispose', { detail: { appKey } });
98
+ });
94
99
  subscriptions.add(
95
- args.event.addEventListener('onAppModulesLoaded', (e) => {
100
+ event.addEventListener('onAppModulesLoaded', (e) => {
96
101
  if (e.detail.appKey === appKey) {
97
102
  this.#state.next(actions.setInstance(e.detail.modules));
98
103
  }
@@ -101,16 +106,104 @@ export class App<TEnv = any, TModules extends Array<AnyModule> | unknown = unkno
101
106
  }
102
107
 
103
108
  this.dispose = () => {
109
+ subscriptions?.unsubscribe();
104
110
  if (this.#state.value.instance) {
111
+ /** tear down modules of application */
105
112
  this.#state.value.instance.dispose();
106
113
  }
107
- subscriptions.unsubscribe();
108
114
  this.#state.complete();
109
115
  };
110
116
  }
111
117
 
112
- public initialize(): Observable<[AppManifest, AppScriptModule, AppConfig]> {
113
- return combineLatest([this.getManifest(), this.getAppModule(), this.getConfig()]);
118
+ #registerEvents(event: ModuleType<EventModule>): void {
119
+ const { appKey } = this;
120
+
121
+ this.#state.addEffect(actions.fetchManifest.success.type, (action) => {
122
+ event.dispatchEvent('onAppManifestLoaded', {
123
+ detail: { appKey, manifest: action.payload },
124
+ source: this,
125
+ });
126
+ });
127
+
128
+ this.#state.addEffect(actions.fetchConfig.success.type, (action) => {
129
+ event.dispatchEvent('onAppConfigLoaded', {
130
+ detail: { appKey, manifest: action.payload },
131
+ source: this,
132
+ });
133
+ });
134
+
135
+ this.#state.addEffect(actions.importApp.success.type, (action) => {
136
+ event.dispatchEvent('onAppScriptLoaded', {
137
+ detail: { appKey, manifest: action.payload },
138
+ source: this,
139
+ });
140
+ });
141
+
142
+ this.#state.addEffect(actions.initialize.type, () => {
143
+ event.dispatchEvent('onAppInitialize', {
144
+ detail: { appKey },
145
+ source: this,
146
+ });
147
+ });
148
+
149
+ this.#state.addEffect(actions.initialize.success.type, () => {
150
+ event.dispatchEvent('onAppInitialized', {
151
+ detail: { appKey },
152
+ source: this,
153
+ });
154
+ });
155
+
156
+ this.#state.addEffect(actions.initialize.failure.type, ({ payload }) => {
157
+ event.dispatchEvent('onAppInitializeFailed', {
158
+ detail: { appKey, error: payload },
159
+ source: this,
160
+ });
161
+ });
162
+ }
163
+
164
+ /**
165
+ * The initializing request won`t trigger until subscribing to the returned observable
166
+ *
167
+ * @example
168
+ * ```ts
169
+ * app.initialize().subscribe({
170
+ * next: (value) => {
171
+ * value.script.render(el, ...);
172
+ * },
173
+ * error: (err) => console.error('failed to load application', err),
174
+ * complete: () => setInitializingApp(false)
175
+ * })
176
+ * ```
177
+ */
178
+ public initialize(): Observable<{
179
+ manifest: AppManifest;
180
+ script: AppScriptModule;
181
+ config: AppConfig;
182
+ }> {
183
+ return new Observable((observer) => {
184
+ this.#state.next(actions.initialize());
185
+ observer.add(
186
+ combineLatest([
187
+ this.getManifest(),
188
+ this.getAppModule(),
189
+ this.getConfig(),
190
+ ]).subscribe({
191
+ next: ([manifest, script, config]) =>
192
+ observer.next({
193
+ manifest,
194
+ script,
195
+ config,
196
+ }),
197
+ error: (err) => {
198
+ observer.error(err), this.#state.next(actions.initialize.failure(err));
199
+ },
200
+ complete: () => {
201
+ this.#state.next(actions.initialize.success());
202
+ observer.complete();
203
+ },
204
+ })
205
+ );
206
+ });
114
207
  }
115
208
 
116
209
  public loadConfig() {
@@ -246,3 +339,5 @@ export class App<TEnv = any, TModules extends Array<AnyModule> | unknown = unkno
246
339
 
247
340
  public dispose: VoidFunction;
248
341
  }
342
+
343
+ export default App;
@@ -40,6 +40,13 @@ const createActions = () => ({
40
40
  setInstance: createAction('set_instance', (instance: AppModulesInstance) => ({
41
41
  payload: instance,
42
42
  })),
43
+
44
+ initialize: createAsyncAction(
45
+ 'initialize_app',
46
+ () => ({ payload: null }),
47
+ () => ({ payload: null }),
48
+ (error: unknown) => ({ payload: error })
49
+ ),
43
50
  });
44
51
 
45
52
  export const actions = createActions();
@@ -10,7 +10,7 @@ import type { AppModuleProvider } from '../AppModuleProvider';
10
10
 
11
11
  export const createState = (
12
12
  value: AppBundleStateInitial,
13
- provider: AppModuleProvider,
13
+ provider: AppModuleProvider
14
14
  ): FlowSubject<AppBundleState, Actions> => {
15
15
  const reducer = createReducer(value);
16
16
  const state = new FlowSubject<AppBundleState, Actions>(reducer);
@@ -0,0 +1,48 @@
1
+ import type { FrameworkEvent, FrameworkEventInit } from '@equinor/fusion-framework-module-event';
2
+
3
+ import type { App } from './App';
4
+
5
+ import type { AppConfig, AppManifest, AppModulesInstance } from '../types';
6
+
7
+ export interface AppEventEventInit<TDetail extends Record<string, unknown> | unknown = unknown>
8
+ extends FrameworkEventInit<TDetail & { appKey: string }, App> {}
9
+
10
+ declare module '@equinor/fusion-framework-module-event' {
11
+ interface FrameworkEventMap {
12
+ onAppModulesLoaded: FrameworkEvent<
13
+ AppEventEventInit<{
14
+ modules: AppModulesInstance;
15
+ }>
16
+ >;
17
+
18
+ onAppManifestLoaded: FrameworkEvent<
19
+ AppEventEventInit<{
20
+ manifest: AppManifest;
21
+ }>
22
+ >;
23
+
24
+ onAppConfigLoaded: FrameworkEvent<
25
+ AppEventEventInit<{
26
+ config: AppConfig;
27
+ }>
28
+ >;
29
+
30
+ onAppScriptLoaded: FrameworkEvent<
31
+ AppEventEventInit<{
32
+ manifest: AppManifest;
33
+ }>
34
+ >;
35
+
36
+ onAppDispose: FrameworkEvent<AppEventEventInit>;
37
+
38
+ onAppInitialize: FrameworkEvent<AppEventEventInit>;
39
+
40
+ onAppInitialized: FrameworkEvent<AppEventEventInit>;
41
+
42
+ onAppInitializeFailed: FrameworkEvent<
43
+ AppEventEventInit<{
44
+ error: unknown;
45
+ }>
46
+ >;
47
+ }
48
+ }
@@ -0,0 +1,3 @@
1
+ export { App } from './App';
2
+
3
+ export { default } from './App';
package/src/app/types.ts CHANGED
@@ -10,6 +10,7 @@ export type AppBundleState<TConfig = any, TModules = any> = {
10
10
  instance?: AppModulesInstance<TModules>;
11
11
  };
12
12
 
13
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
13
14
  export type AppBundleStateInitial<TConfig = any, TModules = any> = Omit<
14
15
  AppBundleState<TConfig, TModules>,
15
16
  'status'
@@ -0,0 +1,21 @@
1
+ import type { IModulesConfigurator } from '@equinor/fusion-framework-module';
2
+ import type { AppConfigBuilderCallback } from './AppConfigBuilder';
3
+
4
+ import { module } from './module';
5
+
6
+ /**
7
+ * Method for enabling the Service module
8
+ * @param configurator - configuration object
9
+ */
10
+ export const enableAppModule = (
11
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
12
+ configurator: IModulesConfigurator<any, any>,
13
+ builder?: AppConfigBuilderCallback
14
+ ): void => {
15
+ configurator.addConfig({
16
+ module,
17
+ configure: (appConfigurator) => {
18
+ builder && appConfigurator.addConfigBuilder(builder);
19
+ },
20
+ });
21
+ };
package/src/events.ts CHANGED
@@ -1,34 +1,10 @@
1
- import { AnyModule } from '@equinor/fusion-framework-module';
2
-
3
1
  import { FrameworkEvent, FrameworkEventInit } from '@equinor/fusion-framework-module-event';
4
- import { App } from 'app/App';
5
- import AppModuleProvider from 'AppModuleProvider';
6
-
7
- import { AppModulesInstance } from './types';
8
-
9
- type AppModulesLoadedEventInit<TModules extends Array<AnyModule> | unknown = unknown> =
10
- FrameworkEventInit<{
11
- appKey: string;
12
- modules: AppModulesInstance<TModules>;
13
- }>;
2
+ import { App } from './app/App';
14
3
 
15
- export class AppModulesLoadedEvent<
16
- TModules extends Array<AnyModule> | unknown = unknown
17
- > extends FrameworkEvent<AppModulesLoadedEventInit<TModules>> {
18
- constructor(
19
- appKey: string,
20
- modules: AppModulesInstance<TModules>,
21
- init?: Omit<AppModulesLoadedEventInit<TModules>, 'detail'>
22
- ) {
23
- super('onAppModulesLoaded', { ...init, detail: { appKey, modules } });
24
- }
25
- }
4
+ import './app/events';
26
5
 
27
6
  declare module '@equinor/fusion-framework-module-event' {
28
7
  interface FrameworkEventMap {
29
- onAppModulesLoaded: AppModulesLoadedEvent;
30
- onCurrentAppChanged: FrameworkEvent<
31
- FrameworkEventInit<{ next?: App; previous?: App }, AppModuleProvider>
32
- >;
8
+ onCurrentAppChanged: FrameworkEvent<FrameworkEventInit<{ next?: App; previous?: App }>>;
33
9
  }
34
10
  }
package/src/index.ts CHANGED
@@ -11,4 +11,6 @@ export { App } from './app/App';
11
11
  export * from './events';
12
12
  export * from './types';
13
13
 
14
+ export { enableAppModule } from './enable-app-module';
15
+
14
16
  export { default, AppModule, module, moduleKey } from './module';
package/src/module.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { IModulesConfigurator, Module } from '@equinor/fusion-framework-module';
1
+ import { Module } from '@equinor/fusion-framework-module';
2
2
  import { ModuleDeps } from './types';
3
3
 
4
4
  import { IAppConfigurator, AppConfigurator } from './AppConfigurator';
@@ -21,10 +21,6 @@ export const module: AppModule = {
21
21
  },
22
22
  };
23
23
 
24
- export const enableAppModule = (configurator: IModulesConfigurator) => {
25
- configurator.addConfig({ module });
26
- };
27
-
28
24
  export default module;
29
25
 
30
26
  declare module '@equinor/fusion-framework-module' {
package/src/types.ts CHANGED
@@ -35,21 +35,21 @@ type AppCategory = {
35
35
  export type AppManifest = {
36
36
  appKey: string;
37
37
  name: string;
38
- shortName: string;
38
+ entry: string;
39
39
  version: string;
40
- description: string;
41
- type: AppType;
42
- tags: string[];
40
+ shortName?: string;
41
+ description?: string;
42
+ type?: AppType;
43
+ tags?: string[];
43
44
  // context?: ContextManifest;
44
45
  auth?: AppAuth[];
45
46
  icon?: string;
46
- order: number | null;
47
- publishedDate: Date | null;
48
- accentColor: string | null;
49
- categoryId: string | null;
50
- category: AppCategory | null;
47
+ order?: number;
48
+ publishedDate?: Date;
49
+ accentColor?: string;
50
+ categoryId?: string;
51
+ category?: AppCategory;
51
52
  hide?: boolean;
52
- entry: string;
53
53
  };
54
54
 
55
55
  export type Endpoint = { name: string; uri: string; scopes?: string[] };