@equinor/fusion-framework-app 9.3.0 → 9.3.2

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.
@@ -1,7 +1,7 @@
1
- import { type FusionModulesInstance } from '@equinor/fusion-framework';
1
+ import type { FusionModulesInstance } from '@equinor/fusion-framework';
2
2
  import { type AnyModule, type IModulesConfigurator, ModulesConfigurator } from '@equinor/fusion-framework-module';
3
3
  import { configureHttpClient, configureHttp, type HttpClientOptions } from '@equinor/fusion-framework-module-http';
4
- import { AppEnv, AppModules } from './types';
4
+ import type { AppEnv, AppModules } from './types';
5
5
  /**
6
6
  * Configurator for configuring application modules
7
7
  *
@@ -15,19 +15,19 @@ export interface IAppConfigurator<TModules extends Array<AnyModule> | unknown =
15
15
  */
16
16
  configureHttp(...args: Parameters<typeof configureHttp>): void;
17
17
  /**
18
- * [optional]
19
- * Configure a named http client.
20
- * @example
21
- * ```ts
22
- configurator.configureHttpClient(
23
- 'myClient',
24
- {
25
- baseUri: 'https://foo.bar',
26
- defaultScopes: ['client-id/.default']
27
- }
28
- );
29
- * ```
30
- */
18
+ * [optional]
19
+ * Configure a named http client.
20
+ * @example
21
+ * ```ts
22
+ configurator.configureHttpClient(
23
+ 'myClient',
24
+ {
25
+ baseUri: 'https://foo.bar',
26
+ defaultScopes: ['client-id/.default']
27
+ }
28
+ );
29
+ * ```
30
+ */
31
31
  configureHttpClient(...args: Parameters<typeof configureHttpClient>): void;
32
32
  /**
33
33
  * [optional]
@@ -1,4 +1,4 @@
1
- import { Fusion } from '@equinor/fusion-framework';
1
+ import type { Fusion } from '@equinor/fusion-framework';
2
2
  import type { AnyModule } from '@equinor/fusion-framework-module';
3
3
  import type { AppModulesInstance, AppModuleInitiator, AppEnv } from './types';
4
4
  /**
@@ -2,7 +2,7 @@ import type { Fusion } from '@equinor/fusion-framework';
2
2
  import type { AnyModule } from '@equinor/fusion-framework-module';
3
3
  import type { AppConfig, AppManifest, AppModulesInstance, ComponentRenderArgs } from '@equinor/fusion-framework-module-app';
4
4
  import type { IAppConfigurator } from './AppConfigurator';
5
- import { ConfigEnvironment } from '@equinor/fusion-framework-module-app';
5
+ import type { ConfigEnvironment } from '@equinor/fusion-framework-module-app';
6
6
  export type { AppModules, AppManifest, AppConfig, AppModulesInstance, } from '@equinor/fusion-framework-module-app';
7
7
  /**
8
8
  * Application environment args
@@ -1 +1 @@
1
- export declare const version = "9.3.0";
1
+ export declare const version = "9.3.2";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@equinor/fusion-framework-app",
3
- "version": "9.3.0",
3
+ "version": "9.3.2",
4
4
  "description": "",
5
5
  "main": "dist/esm/index.js",
6
6
  "types": "./dist/types/index.d.ts",
@@ -42,19 +42,19 @@
42
42
  "directory": "packages/app"
43
43
  },
44
44
  "dependencies": {
45
- "@equinor/fusion-framework": "^7.3.0",
46
- "@equinor/fusion-framework-module": "^4.3.5",
47
- "@equinor/fusion-framework-module-app": "^6.1.4",
48
- "@equinor/fusion-framework-module-event": "^4.3.0",
49
- "@equinor/fusion-framework-module-http": "^6.2.1",
50
- "@equinor/fusion-framework-module-msal": "^4.0.0"
45
+ "@equinor/fusion-framework": "^7.3.2",
46
+ "@equinor/fusion-framework-module": "^4.3.6",
47
+ "@equinor/fusion-framework-module-app": "^6.1.5",
48
+ "@equinor/fusion-framework-module-event": "^4.3.1",
49
+ "@equinor/fusion-framework-module-http": "^6.2.2",
50
+ "@equinor/fusion-framework-module-msal": "^4.0.1"
51
51
  },
52
52
  "devDependencies": {
53
- "typescript": "^5.5.4",
54
- "@equinor/fusion-framework-module-bookmark": "^2.1.1"
53
+ "typescript": "^5.7.3",
54
+ "@equinor/fusion-framework-module-bookmark": "^2.1.2"
55
55
  },
56
56
  "peerDependencies": {
57
- "@equinor/fusion-framework-module-bookmark": "^2.1.1"
57
+ "@equinor/fusion-framework-module-bookmark": "^2.1.2"
58
58
  },
59
59
  "peerDependenciesMeta": {
60
60
  "@equinor/fusion-framework-module-bookmark": {
@@ -1,23 +1,23 @@
1
- import { type FusionModulesInstance } from '@equinor/fusion-framework';
1
+ import type { FusionModulesInstance } from '@equinor/fusion-framework';
2
2
 
3
3
  import {
4
- type AnyModule,
5
- type IModulesConfigurator,
6
- ModuleConsoleLogger,
7
- ModulesConfigurator,
4
+ type AnyModule,
5
+ type IModulesConfigurator,
6
+ ModuleConsoleLogger,
7
+ ModulesConfigurator,
8
8
  } from '@equinor/fusion-framework-module';
9
9
 
10
10
  import event from '@equinor/fusion-framework-module-event';
11
11
 
12
12
  import http, {
13
- configureHttpClient,
14
- configureHttp,
15
- type HttpClientOptions,
13
+ configureHttpClient,
14
+ configureHttp,
15
+ type HttpClientOptions,
16
16
  } from '@equinor/fusion-framework-module-http';
17
17
 
18
18
  import auth from '@equinor/fusion-framework-module-msal';
19
19
 
20
- import { AppEnv, AppModules } from './types';
20
+ import type { AppEnv, AppModules } from './types';
21
21
 
22
22
  /**
23
23
  * Configurator for configuring application modules
@@ -26,16 +26,16 @@ import { AppEnv, AppModules } from './types';
26
26
  * @template TRef usually undefined, optional references
27
27
  */
28
28
  export interface IAppConfigurator<
29
- TModules extends Array<AnyModule> | unknown = unknown,
30
- TRef extends FusionModulesInstance = FusionModulesInstance,
29
+ TModules extends Array<AnyModule> | unknown = unknown,
30
+ TRef extends FusionModulesInstance = FusionModulesInstance,
31
31
  > extends IModulesConfigurator<AppModules<TModules>, TRef> {
32
- /**
33
- * [optional]
34
- * enable/configure the http module
35
- */
36
- configureHttp(...args: Parameters<typeof configureHttp>): void;
32
+ /**
33
+ * [optional]
34
+ * enable/configure the http module
35
+ */
36
+ configureHttp(...args: Parameters<typeof configureHttp>): void;
37
37
 
38
- /**
38
+ /**
39
39
  * [optional]
40
40
  * Configure a named http client.
41
41
  * @example
@@ -49,64 +49,64 @@ export interface IAppConfigurator<
49
49
  );
50
50
  * ```
51
51
  */
52
- configureHttpClient(...args: Parameters<typeof configureHttpClient>): void;
52
+ configureHttpClient(...args: Parameters<typeof configureHttpClient>): void;
53
53
 
54
- /**
55
- * [optional]
56
- *
57
- * configure a http client which is resolved by service discovery
58
- *
59
- * @param serviceName - name of the service to use
60
- */
61
- // TODO - rename
62
- useFrameworkServiceClient(
63
- serviceName: string,
64
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
65
- options?: Omit<HttpClientOptions<any>, 'baseUri' | 'defaultScopes'>,
66
- ): void;
54
+ /**
55
+ * [optional]
56
+ *
57
+ * configure a http client which is resolved by service discovery
58
+ *
59
+ * @param serviceName - name of the service to use
60
+ */
61
+ // TODO - rename
62
+ useFrameworkServiceClient(
63
+ serviceName: string,
64
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
65
+ options?: Omit<HttpClientOptions<any>, 'baseUri' | 'defaultScopes'>,
66
+ ): void;
67
67
  }
68
68
 
69
69
  export class AppConfigurator<
70
- TModules extends Array<AnyModule> | unknown = unknown,
71
- TRef extends FusionModulesInstance = FusionModulesInstance,
72
- TEnv extends AppEnv = AppEnv,
73
- >
74
- extends ModulesConfigurator<AppModules<TModules>, TRef>
75
- implements IAppConfigurator<TModules, TRef>
70
+ TModules extends Array<AnyModule> | unknown = unknown,
71
+ TRef extends FusionModulesInstance = FusionModulesInstance,
72
+ TEnv extends AppEnv = AppEnv,
73
+ >
74
+ extends ModulesConfigurator<AppModules<TModules>, TRef>
75
+ implements IAppConfigurator<TModules, TRef>
76
76
  {
77
- constructor(public readonly env: TEnv) {
78
- super([event, http, auth]);
79
- this.logger = new ModuleConsoleLogger('AppConfigurator');
80
- }
77
+ constructor(public readonly env: TEnv) {
78
+ super([event, http, auth]);
79
+ this.logger = new ModuleConsoleLogger('AppConfigurator');
80
+ }
81
81
 
82
- public configureHttp(...args: Parameters<typeof configureHttp>) {
83
- this.addConfig(configureHttp(...args));
84
- }
82
+ public configureHttp(...args: Parameters<typeof configureHttp>) {
83
+ this.addConfig(configureHttp(...args));
84
+ }
85
85
 
86
- public configureHttpClient(...args: Parameters<typeof configureHttpClient>) {
87
- this.addConfig(configureHttpClient(...args));
88
- }
86
+ public configureHttpClient(...args: Parameters<typeof configureHttpClient>) {
87
+ this.addConfig(configureHttpClient(...args));
88
+ }
89
89
 
90
- public useFrameworkServiceClient(
91
- serviceName: string,
92
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
93
- options?: Omit<HttpClientOptions<any>, 'baseUri' | 'defaultScopes'>,
94
- ): void {
95
- this.addConfig({
96
- module: http,
97
- configure: async (config, ref) => {
98
- const service = await ref?.serviceDiscovery.resolveService(serviceName);
99
- if (!service) {
100
- throw Error(`failed to configure service [${serviceName}]`);
101
- }
102
- config.configureClient(serviceName, {
103
- ...options,
104
- baseUri: service.uri,
105
- defaultScopes: service.defaultScopes,
106
- });
107
- },
90
+ public useFrameworkServiceClient(
91
+ serviceName: string,
92
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
93
+ options?: Omit<HttpClientOptions<any>, 'baseUri' | 'defaultScopes'>,
94
+ ): void {
95
+ this.addConfig({
96
+ module: http,
97
+ configure: async (config, ref) => {
98
+ const service = await ref?.serviceDiscovery.resolveService(serviceName);
99
+ if (!service) {
100
+ throw Error(`failed to configure service [${serviceName}]`);
101
+ }
102
+ config.configureClient(serviceName, {
103
+ ...options,
104
+ baseUri: service.uri,
105
+ defaultScopes: service.defaultScopes,
108
106
  });
109
- }
107
+ },
108
+ });
109
+ }
110
110
  }
111
111
 
112
112
  export default AppConfigurator;
@@ -1,4 +1,4 @@
1
- import { Fusion } from '@equinor/fusion-framework';
1
+ import type { Fusion } from '@equinor/fusion-framework';
2
2
  import type { AnyModule } from '@equinor/fusion-framework-module';
3
3
 
4
4
  import { AppConfigurator } from './AppConfigurator';
@@ -24,38 +24,38 @@ import type { AppModulesInstance, AppModuleInitiator, AppEnv } from './types';
24
24
  * @returns initialize function, executes configurator
25
25
  */
26
26
  export const configureModules =
27
- <
28
- TModules extends Array<AnyModule> | never,
29
- TRef extends Fusion = Fusion,
30
- TEnv extends AppEnv = AppEnv,
31
- >(
32
- cb?: AppModuleInitiator<TModules, TRef, TEnv>,
33
- ): ((args: { fusion: TRef; env: TEnv }) => Promise<AppModulesInstance<TModules>>) =>
34
- /**
35
- *
36
- * Callback for initializing application modules
37
- *
38
- * @param args - Fusion and application environments (manifest, config ...)
39
- * @returns initialized app modules
40
- */
41
- async (args: { fusion: TRef; env: TEnv }): Promise<AppModulesInstance<TModules>> => {
42
- const configurator = new AppConfigurator<TModules, TRef['modules'], TEnv>(args.env);
43
- if (cb) {
44
- await Promise.resolve(cb(configurator, args));
45
- }
46
- const modules = (await configurator.initialize(
47
- args.fusion.modules,
48
- // TODO
49
- )) as unknown as AppModulesInstance<TModules>;
27
+ <
28
+ TModules extends Array<AnyModule> | never,
29
+ TRef extends Fusion = Fusion,
30
+ TEnv extends AppEnv = AppEnv,
31
+ >(
32
+ cb?: AppModuleInitiator<TModules, TRef, TEnv>,
33
+ ): ((args: { fusion: TRef; env: TEnv }) => Promise<AppModulesInstance<TModules>>) =>
34
+ /**
35
+ *
36
+ * Callback for initializing application modules
37
+ *
38
+ * @param args - Fusion and application environments (manifest, config ...)
39
+ * @returns initialized app modules
40
+ */
41
+ async (args: { fusion: TRef; env: TEnv }): Promise<AppModulesInstance<TModules>> => {
42
+ const configurator = new AppConfigurator<TModules, TRef['modules'], TEnv>(args.env);
43
+ if (cb) {
44
+ await Promise.resolve(cb(configurator, args));
45
+ }
46
+ const modules = (await configurator.initialize(
47
+ args.fusion.modules,
48
+ // TODO
49
+ )) as unknown as AppModulesInstance<TModules>;
50
50
 
51
- // @eikeland
52
- // TODO - remove check after fusion-cli is updated (app module is not enabled in fusion-cli)
53
- if (args.env.manifest?.appKey) {
54
- modules.event.dispatchEvent('onAppModulesLoaded', {
55
- detail: { appKey: args.env.manifest.appKey, modules },
56
- });
57
- }
58
- return modules;
59
- };
51
+ // @eikeland
52
+ // TODO - remove check after fusion-cli is updated (app module is not enabled in fusion-cli)
53
+ if (args.env.manifest?.appKey) {
54
+ modules.event.dispatchEvent('onAppModulesLoaded', {
55
+ detail: { appKey: args.env.manifest.appKey, modules },
56
+ });
57
+ }
58
+ return modules;
59
+ };
60
60
 
61
61
  export default configureModules;
@@ -1,6 +1,6 @@
1
1
  import type {
2
- BookmarkModule,
3
- BookmarkPayloadGenerator,
2
+ BookmarkModule,
3
+ BookmarkPayloadGenerator,
4
4
  } from '@equinor/fusion-framework-module-bookmark';
5
5
  import type { IAppConfigurator } from './AppConfigurator';
6
6
 
@@ -16,57 +16,57 @@ import type { IAppConfigurator } from './AppConfigurator';
16
16
  */
17
17
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
18
18
  export const enableBookmark = (config: IAppConfigurator): void => {
19
- // collection of cleanup functions
20
- const cleanupFunctions = new Set<VoidFunction>();
21
- config.addConfig({
22
- module: {
23
- name: 'bookmark',
24
- initialize(args) {
25
- // get the bookmark provider from the ref (portal)
26
- const provider = args.ref?.bookmark;
27
- if (!provider) {
28
- console.error('Bookmark provider not found');
29
- return {};
30
- }
31
- // create a proxy to intercept the addPayloadGenerator method
32
- return new Proxy(provider, {
33
- get(target, prop) {
34
- switch (prop) {
35
- case 'addPayloadGenerator':
36
- return (generator: BookmarkPayloadGenerator) => {
37
- // catch the teardown function and add it to the cleanup functions
38
- const cleanupHandler = target.addPayloadGenerator(generator);
39
- cleanupFunctions.add(cleanupHandler);
40
- // wrap the teardown function to remove it from the cleanup functions
41
- return () => {
42
- cleanupFunctions.delete(cleanupHandler);
43
- cleanupHandler();
44
- };
45
- };
46
- }
47
- /**
48
- * If the property is not addPayloadGenerator, we want to access the property on the provider
49
- *
50
- * @note we can not use the Reflect API to access the property, as the provider is a proxy
51
- * and the Reflect API will not work as expected (can not access private properties)
52
- */
53
- if (prop in target) {
54
- // if the property is a function, bind it to the provider
55
- if (typeof target[prop] === 'function') {
56
- return target[prop].bind(target);
57
- }
58
- // access the property
59
- return target[prop];
60
- }
61
- },
62
- });
63
- },
64
- dispose() {
65
- for (const teardown of cleanupFunctions) {
66
- teardown();
67
- }
68
- cleanupFunctions.clear();
69
- },
70
- } satisfies BookmarkModule,
71
- });
19
+ // collection of cleanup functions
20
+ const cleanupFunctions = new Set<VoidFunction>();
21
+ config.addConfig({
22
+ module: {
23
+ name: 'bookmark',
24
+ initialize(args) {
25
+ // get the bookmark provider from the ref (portal)
26
+ const provider = args.ref?.bookmark;
27
+ if (!provider) {
28
+ console.error('Bookmark provider not found');
29
+ return {};
30
+ }
31
+ // create a proxy to intercept the addPayloadGenerator method
32
+ return new Proxy(provider, {
33
+ get(target, prop) {
34
+ switch (prop) {
35
+ case 'addPayloadGenerator':
36
+ return (generator: BookmarkPayloadGenerator) => {
37
+ // catch the teardown function and add it to the cleanup functions
38
+ const cleanupHandler = target.addPayloadGenerator(generator);
39
+ cleanupFunctions.add(cleanupHandler);
40
+ // wrap the teardown function to remove it from the cleanup functions
41
+ return () => {
42
+ cleanupFunctions.delete(cleanupHandler);
43
+ cleanupHandler();
44
+ };
45
+ };
46
+ }
47
+ /**
48
+ * If the property is not addPayloadGenerator, we want to access the property on the provider
49
+ *
50
+ * @note we can not use the Reflect API to access the property, as the provider is a proxy
51
+ * and the Reflect API will not work as expected (can not access private properties)
52
+ */
53
+ if (prop in target) {
54
+ // if the property is a function, bind it to the provider
55
+ if (typeof target[prop] === 'function') {
56
+ return target[prop].bind(target);
57
+ }
58
+ // access the property
59
+ return target[prop];
60
+ }
61
+ },
62
+ });
63
+ },
64
+ dispose() {
65
+ for (const teardown of cleanupFunctions) {
66
+ teardown();
67
+ }
68
+ cleanupFunctions.clear();
69
+ },
70
+ } satisfies BookmarkModule,
71
+ });
72
72
  };
package/src/types.ts CHANGED
@@ -3,20 +3,20 @@ import type { Fusion } from '@equinor/fusion-framework';
3
3
  import type { AnyModule } from '@equinor/fusion-framework-module';
4
4
 
5
5
  import type {
6
- AppConfig,
7
- AppManifest,
8
- AppModulesInstance,
9
- ComponentRenderArgs,
6
+ AppConfig,
7
+ AppManifest,
8
+ AppModulesInstance,
9
+ ComponentRenderArgs,
10
10
  } from '@equinor/fusion-framework-module-app';
11
11
 
12
12
  import type { IAppConfigurator } from './AppConfigurator';
13
- import { ConfigEnvironment } from '@equinor/fusion-framework-module-app';
13
+ import type { ConfigEnvironment } from '@equinor/fusion-framework-module-app';
14
14
 
15
15
  export type {
16
- AppModules,
17
- AppManifest,
18
- AppConfig,
19
- AppModulesInstance,
16
+ AppModules,
17
+ AppManifest,
18
+ AppConfig,
19
+ AppModulesInstance,
20
20
  } from '@equinor/fusion-framework-module-app';
21
21
 
22
22
  /**
@@ -27,11 +27,11 @@ export type {
27
27
  * @template TProps [__not in use__] properties for application component
28
28
  */
29
29
  export type AppEnv<TConfig extends ConfigEnvironment = ConfigEnvironment, TProps = unknown> = {
30
- /** base routing path of the application */
31
- basename?: string;
32
- manifest: AppManifest;
33
- config?: AppConfig<TConfig>;
34
- props?: TProps;
30
+ /** base routing path of the application */
31
+ basename?: string;
32
+ manifest: AppManifest;
33
+ config?: AppConfig<TConfig>;
34
+ props?: TProps;
35
35
  };
36
36
 
37
37
  /**
@@ -42,12 +42,12 @@ export type AppEnv<TConfig extends ConfigEnvironment = ConfigEnvironment, TProps
42
42
  * @template TEnv environment object for configuring modules
43
43
  */
44
44
  export type AppModuleInitiator<
45
- TModules extends Array<AnyModule> | unknown = unknown,
46
- TRef extends Fusion = Fusion,
47
- TEnv = AppEnv,
45
+ TModules extends Array<AnyModule> | unknown = unknown,
46
+ TRef extends Fusion = Fusion,
47
+ TEnv = AppEnv,
48
48
  > = (
49
- configurator: IAppConfigurator<TModules, TRef['modules']>,
50
- args: { fusion: TRef; env: TEnv },
49
+ configurator: IAppConfigurator<TModules, TRef['modules']>,
50
+ args: { fusion: TRef; env: TEnv },
51
51
  ) => void | Promise<void>;
52
52
 
53
53
  /**
@@ -58,16 +58,16 @@ export type AppModuleInitiator<
58
58
  * @template TEnv environment object for configuring modules
59
59
  */
60
60
  export type AppModuleInit<
61
- TModules extends Array<AnyModule> | unknown = [],
62
- TRef extends Fusion = Fusion,
63
- TEnv = AppEnv,
61
+ TModules extends Array<AnyModule> | unknown = [],
62
+ TRef extends Fusion = Fusion,
63
+ TEnv = AppEnv,
64
64
  > = (
65
- cb: AppModuleInitiator<TModules, TRef, TEnv>,
65
+ cb: AppModuleInitiator<TModules, TRef, TEnv>,
66
66
  ) => (args: AppModuleInitArgs<TRef, TEnv>) => Promise<AppModulesInstance<TModules>>;
67
67
 
68
68
  export type AppModuleInitArgs<TRef extends Fusion = Fusion, TEnv = AppEnv> = {
69
- fusion: TRef;
70
- env: TEnv;
69
+ fusion: TRef;
70
+ env: TEnv;
71
71
  };
72
72
 
73
73
  /**
@@ -87,6 +87,6 @@ export type AppModuleInitArgs<TRef extends Fusion = Fusion, TEnv = AppEnv> = {
87
87
  * };
88
88
  */
89
89
  export type AppRenderFn<TFusion extends Fusion = Fusion, TEnv = AppEnv> = (
90
- el: HTMLHtmlElement,
91
- args: ComponentRenderArgs<TFusion, TEnv>,
90
+ el: HTMLHtmlElement,
91
+ args: ComponentRenderArgs<TFusion, TEnv>,
92
92
  ) => VoidFunction | void;
package/src/version.ts CHANGED
@@ -1,2 +1,2 @@
1
1
  // Generated by genversion.
2
- export const version = '9.3.0';
2
+ export const version = '9.3.2';