@equinor/fusion-framework-module-widget 9.0.2 → 9.0.3

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 (41) hide show
  1. package/CHANGELOG.md +176 -162
  2. package/dist/esm/Widget.js.map +1 -1
  3. package/dist/esm/WidgetModuleConfigurator.js.map +1 -1
  4. package/dist/esm/WidgetModuleProvider.js.map +1 -1
  5. package/dist/esm/enable-widget-module.js.map +1 -1
  6. package/dist/esm/errors.js.map +1 -1
  7. package/dist/esm/module.js.map +1 -1
  8. package/dist/esm/state/actions.js.map +1 -1
  9. package/dist/esm/state/create-reducer.js.map +1 -1
  10. package/dist/esm/state/create-state.js.map +1 -1
  11. package/dist/esm/state/flows.js.map +1 -1
  12. package/dist/esm/utils.js.map +1 -1
  13. package/dist/esm/version.js +1 -1
  14. package/dist/tsconfig.tsbuildinfo +1 -1
  15. package/dist/types/Widget.d.ts +5 -5
  16. package/dist/types/WidgetModuleConfigurator.d.ts +1 -1
  17. package/dist/types/WidgetModuleProvider.d.ts +4 -4
  18. package/dist/types/enable-widget-module.d.ts +1 -1
  19. package/dist/types/module.d.ts +3 -3
  20. package/dist/types/state/actions.d.ts +2 -2
  21. package/dist/types/state/create-reducer.d.ts +1 -1
  22. package/dist/types/state/create-state.d.ts +2 -2
  23. package/dist/types/state/flows.d.ts +1 -1
  24. package/dist/types/types.d.ts +1 -1
  25. package/dist/types/utils.d.ts +2 -2
  26. package/dist/types/version.d.ts +1 -1
  27. package/package.json +12 -12
  28. package/src/Widget.ts +294 -294
  29. package/src/WidgetModuleConfigurator.ts +45 -45
  30. package/src/WidgetModuleProvider.ts +144 -144
  31. package/src/enable-widget-module.ts +10 -10
  32. package/src/errors.ts +52 -56
  33. package/src/events.ts +51 -51
  34. package/src/module.ts +23 -23
  35. package/src/state/actions.ts +56 -56
  36. package/src/state/create-reducer.ts +33 -33
  37. package/src/state/create-state.ts +10 -10
  38. package/src/state/flows.ts +57 -57
  39. package/src/types.ts +38 -38
  40. package/src/utils.ts +44 -44
  41. package/src/version.ts +1 -1
package/src/types.ts CHANGED
@@ -2,7 +2,7 @@ import type { AnyModule, CombinedModules, ModulesInstance } from '@equinor/fusio
2
2
  import type { EventModule } from '@equinor/fusion-framework-module-event';
3
3
  import type { HttpModule } from '@equinor/fusion-framework-module-http';
4
4
  import type { ServiceDiscoveryModule } from '@equinor/fusion-framework-module-service-discovery';
5
- import { QueryCtorOptions } from '@equinor/fusion-query';
5
+ import type { QueryCtorOptions } from '@equinor/fusion-query';
6
6
 
7
7
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
8
8
  type Fusion = any;
@@ -11,19 +11,19 @@ type Fusion = any;
11
11
  * WidgetEnv type represents the environment configuration for a widget.
12
12
  */
13
13
  export type WidgetEnv<TProps = unknown> = {
14
- basename?: string;
15
- manifest?: WidgetManifest;
16
- props?: TProps;
14
+ basename?: string;
15
+ manifest?: WidgetManifest;
16
+ props?: TProps;
17
17
  };
18
18
 
19
19
  /**
20
20
  * IClient interface represents a client with properties and methods for widget-related operations.
21
21
  */
22
22
  export type IClient = {
23
- apiVersion: string;
24
- baseImportUrl: string;
25
- getWidgetManifest: QueryCtorOptions<WidgetManifest, GetWidgetParameters>;
26
- getWidgetConfig: QueryCtorOptions<WidgetConfig, GetWidgetParameters>;
23
+ apiVersion: string;
24
+ baseImportUrl: string;
25
+ getWidgetManifest: QueryCtorOptions<WidgetManifest, GetWidgetParameters>;
26
+ getWidgetConfig: QueryCtorOptions<WidgetConfig, GetWidgetParameters>;
27
27
  };
28
28
 
29
29
  /**
@@ -35,8 +35,8 @@ export type ModuleDeps = [HttpModule, ServiceDiscoveryModule, EventModule];
35
35
  * GetWidgetParameters type represents parameters for retrieving widget information.
36
36
  */
37
37
  export type GetWidgetParameters = {
38
- widgetKey: string;
39
- args?: { type: 'version' | 'tag'; value: string };
38
+ widgetKey: string;
39
+ args?: { type: 'version' | 'tag'; value: string };
40
40
  };
41
41
 
42
42
  /**
@@ -48,13 +48,13 @@ export type WidgetEndpointBuilder = (args: GetWidgetParameters) => string;
48
48
  * WidgetManifest type represents the manifest information of a widget.
49
49
  */
50
50
  export type WidgetManifest = {
51
- id: string;
52
- name: string;
53
- version: string;
54
- description: string;
55
- maintainers?: string[];
56
- entryPoint: string;
57
- assetPath: string;
51
+ id: string;
52
+ name: string;
53
+ version: string;
54
+ description: string;
55
+ maintainers?: string[];
56
+ entryPoint: string;
57
+ assetPath: string;
58
58
  };
59
59
 
60
60
  /**
@@ -66,16 +66,16 @@ export type Endpoint = { name: string; uri: string; scopes?: string[] };
66
66
  * WidgetConfig type represents the configuration for a widget, including environment and endpoints.
67
67
  */
68
68
  export type WidgetConfig<TEnvironment = unknown> = {
69
- environment: TEnvironment;
70
- endpoints: Record<string, string | Endpoint>;
69
+ environment: TEnvironment;
70
+ endpoints: Record<string, string | Endpoint>;
71
71
  };
72
72
 
73
73
  /**
74
74
  * WidgetModules type represents a combination of modules related to events and service discovery.
75
75
  */
76
76
  export type WidgetModules<TModules extends Array<AnyModule> | unknown = unknown> = CombinedModules<
77
- TModules,
78
- [EventModule, ServiceDiscoveryModule]
77
+ TModules,
78
+ [EventModule, ServiceDiscoveryModule]
79
79
  >;
80
80
 
81
81
  /**
@@ -88,42 +88,42 @@ export type WidgetProps = Record<PropertyKey, unknown>;
88
88
  */
89
89
 
90
90
  export type WidgetRenderArgs<
91
- TFusion extends Fusion = Fusion,
92
- TEnv = WidgetEnv,
93
- TProps extends WidgetProps = WidgetProps,
91
+ TFusion extends Fusion = Fusion,
92
+ TEnv = WidgetEnv,
93
+ TProps extends WidgetProps = WidgetProps,
94
94
  > = {
95
- fusion: TFusion;
96
- env: TEnv;
97
- props?: TProps;
95
+ fusion: TFusion;
96
+ env: TEnv;
97
+ props?: TProps;
98
98
  };
99
99
 
100
100
  /**
101
101
  * WidgetScriptModule type represents a script module for a widget with functions for rendering, rendering icons, etc.
102
102
  */
103
103
  export type WidgetScriptModule<TProps extends WidgetProps = WidgetProps> = {
104
- default: (el: HTMLElement, args: WidgetRenderArgs, props?: TProps) => VoidFunction;
105
- renderWidget: (el: HTMLElement, args: WidgetRenderArgs, props?: TProps) => VoidFunction;
106
- renderIcon: (el: HTMLElement, args: WidgetRenderArgs, props?: TProps) => VoidFunction;
107
- render: (el: HTMLElement, args: WidgetRenderArgs, props?: TProps) => VoidFunction;
104
+ default: (el: HTMLElement, args: WidgetRenderArgs, props?: TProps) => VoidFunction;
105
+ renderWidget: (el: HTMLElement, args: WidgetRenderArgs, props?: TProps) => VoidFunction;
106
+ renderIcon: (el: HTMLElement, args: WidgetRenderArgs, props?: TProps) => VoidFunction;
107
+ render: (el: HTMLElement, args: WidgetRenderArgs, props?: TProps) => VoidFunction;
108
108
  };
109
109
 
110
110
  /**
111
111
  * WidgetModulesInstance type represents an instance of widget modules.
112
112
  */
113
113
  export type WidgetModulesInstance<TModules extends Array<AnyModule> | unknown = unknown> =
114
- ModulesInstance<WidgetModules<TModules>>;
114
+ ModulesInstance<WidgetModules<TModules>>;
115
115
 
116
116
  /**
117
117
  * WidgetState type represents the state of a widget, including properties like name, status, config, manifest, modules, and instance.
118
118
  */
119
119
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
120
120
  export type WidgetState<TModules = any> = {
121
- name: string;
122
- status: Set<string>;
123
- config?: WidgetConfig;
124
- manifest?: WidgetManifest;
125
- modules?: WidgetScriptModule;
126
- instance?: WidgetModulesInstance<TModules>;
121
+ name: string;
122
+ status: Set<string>;
123
+ config?: WidgetConfig;
124
+ manifest?: WidgetManifest;
125
+ modules?: WidgetScriptModule;
126
+ instance?: WidgetModulesInstance<TModules>;
127
127
  };
128
128
  /**
129
129
  * WidgetStateInitial type represents an initial state of a widget, omitting the status property.
package/src/utils.ts CHANGED
@@ -1,51 +1,51 @@
1
- import { GetWidgetParameters, IClient, WidgetEndpointBuilder } from './types';
2
- import { IHttpClient } from '@equinor/fusion-framework-module-http';
1
+ import type { GetWidgetParameters, IClient, WidgetEndpointBuilder } from './types';
2
+ import type { IHttpClient } from '@equinor/fusion-framework-module-http';
3
3
 
4
4
  export const defaultManifestEndpointBuilder =
5
- (apiVersion: string): WidgetEndpointBuilder =>
6
- (params: GetWidgetParameters) => {
7
- const { widgetKey, args } = params;
8
- const { type, value } = args ?? {};
9
- switch (type) {
10
- case 'tag':
11
- case 'version':
12
- return `/widgets/${widgetKey}/versions/${value}?api-version=${apiVersion}`;
13
- default:
14
- return `/widgets/${widgetKey}?api-version=${apiVersion}`;
15
- }
16
- };
5
+ (apiVersion: string): WidgetEndpointBuilder =>
6
+ (params: GetWidgetParameters) => {
7
+ const { widgetKey, args } = params;
8
+ const { type, value } = args ?? {};
9
+ switch (type) {
10
+ case 'tag':
11
+ case 'version':
12
+ return `/widgets/${widgetKey}/versions/${value}?api-version=${apiVersion}`;
13
+ default:
14
+ return `/widgets/${widgetKey}?api-version=${apiVersion}`;
15
+ }
16
+ };
17
17
 
18
18
  export const defaultConfigEndpointBuilder =
19
- (apiVersion: string): WidgetEndpointBuilder =>
20
- (params: GetWidgetParameters) => {
21
- const { widgetKey, args } = params;
22
- const { type, value } = args ?? {};
23
- // Todo Align endpoints with backend when its done!
24
- switch (type) {
25
- case 'tag':
26
- case 'version':
27
- return `/widgets/${widgetKey}/versions/${value}/config?api-version=${apiVersion}`;
28
- default:
29
- return `/widgets/${widgetKey}/config?api-version=${apiVersion}`;
30
- }
31
- };
19
+ (apiVersion: string): WidgetEndpointBuilder =>
20
+ (params: GetWidgetParameters) => {
21
+ const { widgetKey, args } = params;
22
+ const { type, value } = args ?? {};
23
+ // Todo Align endpoints with backend when its done!
24
+ switch (type) {
25
+ case 'tag':
26
+ case 'version':
27
+ return `/widgets/${widgetKey}/versions/${value}/config?api-version=${apiVersion}`;
28
+ default:
29
+ return `/widgets/${widgetKey}/config?api-version=${apiVersion}`;
30
+ }
31
+ };
32
32
 
33
33
  export const createDefaultClient = (httpClient: IHttpClient): IClient => {
34
- const apiVersion = '1.0-preview';
35
- return {
36
- apiVersion,
37
- baseImportUrl: httpClient.uri,
38
- getWidgetManifest: {
39
- client: {
40
- fn: (args) => httpClient.json$(defaultManifestEndpointBuilder(apiVersion)(args)),
41
- },
42
- key: (args) => JSON.stringify(args),
43
- },
44
- getWidgetConfig: {
45
- client: {
46
- fn: (args) => httpClient.json$(defaultConfigEndpointBuilder(apiVersion)(args)),
47
- },
48
- key: (args) => JSON.stringify(args),
49
- },
50
- };
34
+ const apiVersion = '1.0-preview';
35
+ return {
36
+ apiVersion,
37
+ baseImportUrl: httpClient.uri,
38
+ getWidgetManifest: {
39
+ client: {
40
+ fn: (args) => httpClient.json$(defaultManifestEndpointBuilder(apiVersion)(args)),
41
+ },
42
+ key: (args) => JSON.stringify(args),
43
+ },
44
+ getWidgetConfig: {
45
+ client: {
46
+ fn: (args) => httpClient.json$(defaultConfigEndpointBuilder(apiVersion)(args)),
47
+ },
48
+ key: (args) => JSON.stringify(args),
49
+ },
50
+ };
51
51
  };
package/src/version.ts CHANGED
@@ -1,2 +1,2 @@
1
1
  // Generated by genversion.
2
- export const version = '9.0.2';
2
+ export const version = '9.0.3';