@equinor/fusion-framework-module-app 2.3.0 → 2.5.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 (39) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/dist/esm/AppConfigurator.js +1 -1
  3. package/dist/esm/AppConfigurator.js.map +1 -1
  4. package/dist/esm/AppModuleProvider.js +7 -3
  5. package/dist/esm/AppModuleProvider.js.map +1 -1
  6. package/dist/esm/app/App.js +4 -2
  7. package/dist/esm/app/App.js.map +1 -1
  8. package/dist/esm/app/create-reducer.js +1 -1
  9. package/dist/esm/app/create-reducer.js.map +1 -1
  10. package/dist/esm/app/create-state.js +2 -2
  11. package/dist/esm/app/create-state.js.map +1 -1
  12. package/dist/esm/app/index.js +3 -0
  13. package/dist/esm/app/index.js.map +1 -0
  14. package/dist/esm/index.js +1 -1
  15. package/dist/esm/index.js.map +1 -1
  16. package/dist/esm/module.js.map +1 -1
  17. package/dist/tsconfig.tsbuildinfo +1 -1
  18. package/dist/types/AppModuleProvider.d.ts +4 -2
  19. package/dist/types/app/App.d.ts +3 -1
  20. package/dist/types/app/create-reducer.d.ts +2 -2
  21. package/dist/types/app/create-state.d.ts +2 -2
  22. package/dist/types/app/index.d.ts +2 -0
  23. package/dist/types/app/types.d.ts +1 -0
  24. package/dist/types/events.d.ts +2 -2
  25. package/dist/types/index.d.ts +1 -1
  26. package/dist/types/module.d.ts +1 -1
  27. package/dist/types/types.d.ts +10 -10
  28. package/package.json +9 -5
  29. package/src/AppConfigurator.ts +1 -1
  30. package/src/AppModuleProvider.ts +13 -5
  31. package/src/app/App.ts +11 -4
  32. package/src/app/create-reducer.ts +3 -3
  33. package/src/app/create-state.ts +3 -3
  34. package/src/app/index.ts +3 -0
  35. package/src/app/types.ts +6 -0
  36. package/src/events.ts +2 -2
  37. package/src/index.ts +1 -1
  38. package/src/module.ts +2 -1
  39. package/src/types.ts +10 -10
@@ -1,10 +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
9
  export declare class AppModuleProvider {
9
10
  #private;
10
11
  static compareAppManifest<T extends AppManifest>(a?: T, b?: T): boolean;
@@ -20,7 +21,8 @@ export declare class AppModuleProvider {
20
21
  getAppManifest(appKey: string): Observable<AppManifest>;
21
22
  getAllAppManifests(): Observable<AppManifest[]>;
22
23
  getAppConfig<TType = unknown>(appKey: string, tag?: string): Observable<AppConfig<TType>>;
23
- setCurrentApp(appKey: string): void;
24
+ setCurrentApp(appKeyOrApp: string | App): void;
25
+ createApp(value: AppBundleStateInitial): App;
24
26
  dispose(): void;
25
27
  }
26
28
  export default AppModuleProvider;
@@ -4,6 +4,7 @@ import type { AppModuleProvider } from '../AppModuleProvider';
4
4
  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
+ import { AppBundleStateInitial } from './types';
7
8
  import '../events';
8
9
  export declare function filterEmpty<T>(): OperatorFunction<T | null | undefined, T>;
9
10
  export declare class App<TEnv = any, TModules extends Array<AnyModule> | unknown = unknown> {
@@ -16,7 +17,7 @@ export declare class App<TEnv = any, TModules extends Array<AnyModule> | unknown
16
17
  get manifest(): Promise<AppManifest>;
17
18
  get config(): Promise<AppConfig<TEnv>>;
18
19
  get instance(): AppModulesInstance<TModules> | undefined;
19
- constructor(appKey: string, args: {
20
+ constructor(value: AppBundleStateInitial, args: {
20
21
  provider: AppModuleProvider;
21
22
  event?: ModuleType<EventModule>;
22
23
  });
@@ -32,3 +33,4 @@ export declare class App<TEnv = any, TModules extends Array<AnyModule> | unknown
32
33
  getAppModuleAsync(allow_cache?: boolean): Promise<AppScriptModule>;
33
34
  dispose: VoidFunction;
34
35
  }
36
+ export default App;
@@ -1,3 +1,3 @@
1
- import { AppBundleState } from './types';
2
- export declare const createReducer: (appKey: string) => import("@equinor/fusion-observable").ReducerWithInitialState<AppBundleState<any, any>, import("@equinor/fusion-observable").AnyAction>;
1
+ import { AppBundleState, AppBundleStateInitial } from './types';
2
+ export declare const createReducer: (value: AppBundleStateInitial) => import("@equinor/fusion-observable").ReducerWithInitialState<AppBundleState<any, any>, import("@equinor/fusion-observable").AnyAction>;
3
3
  export default createReducer;
@@ -1,5 +1,5 @@
1
1
  import { FlowSubject } from '@equinor/fusion-observable';
2
2
  import type { Actions } from './actions';
3
- import type { AppBundleState } from './types';
3
+ import type { AppBundleState, AppBundleStateInitial } from './types';
4
4
  import type { AppModuleProvider } from '../AppModuleProvider';
5
- export declare const createState: (appKey: string, provider: AppModuleProvider) => FlowSubject<AppBundleState, Actions>;
5
+ export declare const createState: (value: AppBundleStateInitial, provider: AppModuleProvider) => FlowSubject<AppBundleState, Actions>;
@@ -0,0 +1,2 @@
1
+ export { App } from './App';
2
+ export { default } from './App';
@@ -7,3 +7,4 @@ export type AppBundleState<TConfig = any, TModules = any> = {
7
7
  modules?: AppScriptModule;
8
8
  instance?: AppModulesInstance<TModules>;
9
9
  };
10
+ export type AppBundleStateInitial<TConfig = any, TModules = any> = Omit<AppBundleState<TConfig, TModules>, 'status'>;
@@ -1,7 +1,7 @@
1
1
  import { AnyModule } from '@equinor/fusion-framework-module';
2
2
  import { FrameworkEvent, FrameworkEventInit } from '@equinor/fusion-framework-module-event';
3
- import { App } from 'app/App';
4
- import AppModuleProvider from 'AppModuleProvider';
3
+ import { App } from './app/App';
4
+ import AppModuleProvider from './AppModuleProvider';
5
5
  import { AppModulesInstance } from './types';
6
6
  type AppModulesLoadedEventInit<TModules extends Array<AnyModule> | unknown = unknown> = FrameworkEventInit<{
7
7
  appKey: string;
@@ -3,4 +3,4 @@ export { AppModuleProvider } from './AppModuleProvider';
3
3
  export { App } from './app/App';
4
4
  export * from './events';
5
5
  export * from './types';
6
- export { default, AppModule, module, moduleKey } from './module';
6
+ export { default, AppModule, module, moduleKey, enableAppModule } from './module';
@@ -5,7 +5,7 @@ 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;
8
+ export declare const enableAppModule: (configurator: IModulesConfigurator<any, any>) => void;
9
9
  export default module;
10
10
  declare module '@equinor/fusion-framework-module' {
11
11
  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.3.0",
3
+ "version": "2.5.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": "4bc7a862d19921fc8801e5238d7013b8ece12917"
48
+ "gitHead": "e5668331df89b0ef6ef6175ea1908d4aeb772544"
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,17 +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';
23
+ import { AppBundleStateInitial } from './app/types';
24
24
 
25
25
  export class AppModuleProvider {
26
26
  static compareAppManifest<T extends AppManifest>(a?: T, b?: T): boolean {
@@ -147,8 +147,16 @@ export class AppModuleProvider {
147
147
  * set the current application, will internally resolve manifest
148
148
  * @param appKey - application key
149
149
  */
150
- public setCurrentApp(appKey: string): void {
151
- this.#current$.next(new App(appKey, { provider: this, event: this.#event }));
150
+ public setCurrentApp(appKeyOrApp: string | App): void {
151
+ const app = typeof appKeyOrApp === 'string' ? this.createApp({ appKey: appKeyOrApp }) : App;
152
+ this.#current$.next(app as App);
153
+ }
154
+
155
+ /**
156
+ * This should not be used, only for legacy creation backdoor
157
+ */
158
+ public createApp(value: AppBundleStateInitial): App {
159
+ return new App(value, { provider: this, event: this.#event });
152
160
  }
153
161
 
154
162
  public dispose() {
package/src/app/App.ts CHANGED
@@ -16,7 +16,7 @@ import { EventModule } from '@equinor/fusion-framework-module-event';
16
16
  import { AnyModule, ModuleType } from '@equinor/fusion-framework-module';
17
17
  import { createState } from './create-state';
18
18
  import { actions, Actions } from './actions';
19
- import { AppBundleState } from './types';
19
+ import { AppBundleState, AppBundleStateInitial } from './types';
20
20
 
21
21
  import '../events';
22
22
 
@@ -78,10 +78,15 @@ export class App<TEnv = any, TModules extends Array<AnyModule> | unknown = unkno
78
78
  }
79
79
 
80
80
  constructor(
81
- appKey: string,
82
- args: { provider: AppModuleProvider; event?: ModuleType<EventModule> }
81
+ value: AppBundleStateInitial,
82
+ args: {
83
+ provider: AppModuleProvider;
84
+ event?: ModuleType<EventModule>;
85
+ }
83
86
  ) {
84
- this.#state = createState(appKey, args.provider);
87
+ this.#state = createState(value, args.provider);
88
+
89
+ const { appKey } = value;
85
90
 
86
91
  const subscriptions = new Subscription();
87
92
 
@@ -241,3 +246,5 @@ export class App<TEnv = any, TModules extends Array<AnyModule> | unknown = unkno
241
246
 
242
247
  public dispose: VoidFunction;
243
248
  }
249
+
250
+ export default App;
@@ -11,10 +11,10 @@ enableMapSet();
11
11
 
12
12
  import { actions } from './actions';
13
13
 
14
- import { AppBundleState } from './types';
14
+ import { AppBundleState, AppBundleStateInitial } from './types';
15
15
 
16
- export const createReducer = (appKey: string) =>
17
- makeReducer({ appKey, status: new Set() } as AppBundleState, (builder) =>
16
+ export const createReducer = (value: AppBundleStateInitial) =>
17
+ makeReducer({ ...value, status: new Set() } as AppBundleState, (builder) =>
18
18
  builder
19
19
  .addCase(actions.setManifest, (state, action) => {
20
20
  state.manifest = action.payload;
@@ -5,14 +5,14 @@ import { createReducer } from './create-reducer';
5
5
  import { handleFetchManifest, handleFetchConfig, handleImportApplication } from './flows';
6
6
 
7
7
  import type { Actions } from './actions';
8
- import type { AppBundleState } from './types';
8
+ import type { AppBundleState, AppBundleStateInitial } from './types';
9
9
  import type { AppModuleProvider } from '../AppModuleProvider';
10
10
 
11
11
  export const createState = (
12
- appKey: string,
12
+ value: AppBundleStateInitial,
13
13
  provider: AppModuleProvider
14
14
  ): FlowSubject<AppBundleState, Actions> => {
15
- const reducer = createReducer(appKey);
15
+ const reducer = createReducer(value);
16
16
  const state = new FlowSubject<AppBundleState, Actions>(reducer);
17
17
  state.addFlow(handleFetchManifest(provider));
18
18
  state.addFlow(handleFetchConfig(provider));
@@ -0,0 +1,3 @@
1
+ export { App } from './App';
2
+
3
+ export { default } from './App';
package/src/app/types.ts CHANGED
@@ -9,3 +9,9 @@ export type AppBundleState<TConfig = any, TModules = any> = {
9
9
  modules?: AppScriptModule;
10
10
  instance?: AppModulesInstance<TModules>;
11
11
  };
12
+
13
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
14
+ export type AppBundleStateInitial<TConfig = any, TModules = any> = Omit<
15
+ AppBundleState<TConfig, TModules>,
16
+ 'status'
17
+ >;
package/src/events.ts CHANGED
@@ -1,8 +1,8 @@
1
1
  import { AnyModule } from '@equinor/fusion-framework-module';
2
2
 
3
3
  import { FrameworkEvent, FrameworkEventInit } from '@equinor/fusion-framework-module-event';
4
- import { App } from 'app/App';
5
- import AppModuleProvider from 'AppModuleProvider';
4
+ import { App } from './app/App';
5
+ import AppModuleProvider from './AppModuleProvider';
6
6
 
7
7
  import { AppModulesInstance } from './types';
8
8
 
package/src/index.ts CHANGED
@@ -11,4 +11,4 @@ export { App } from './app/App';
11
11
  export * from './events';
12
12
  export * from './types';
13
13
 
14
- export { default, AppModule, module, moduleKey } from './module';
14
+ export { default, AppModule, module, moduleKey, enableAppModule } from './module';
package/src/module.ts CHANGED
@@ -21,7 +21,8 @@ export const module: AppModule = {
21
21
  },
22
22
  };
23
23
 
24
- export const enableAppModule = (configurator: IModulesConfigurator) => {
24
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
25
+ export const enableAppModule = (configurator: IModulesConfigurator<any, any>) => {
25
26
  configurator.addConfig({ module });
26
27
  };
27
28
 
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[] };