@equinor/fusion-framework-module-app 7.4.1 → 8.0.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.
- package/CHANGELOG.md +57 -33
- package/README.md +118 -11
- package/dist/esm/AppClient.js +16 -3
- package/dist/esm/AppClient.js.map +1 -1
- package/dist/esm/AppConfig.js +7 -1
- package/dist/esm/AppConfig.js.map +1 -1
- package/dist/esm/AppConfigurator.js +7 -0
- package/dist/esm/AppConfigurator.js.map +1 -1
- package/dist/esm/AppModuleProvider.js +80 -17
- package/dist/esm/AppModuleProvider.js.map +1 -1
- package/dist/esm/app/App.js +17 -1
- package/dist/esm/app/App.js.map +1 -1
- package/dist/esm/app/actions.js +13 -0
- package/dist/esm/app/actions.js.map +1 -1
- package/dist/esm/app/create-reducer.js +9 -0
- package/dist/esm/app/create-reducer.js.map +1 -1
- package/dist/esm/app/create-state.js +11 -0
- package/dist/esm/app/create-state.js.map +1 -1
- package/dist/esm/app/flows.js +3 -2
- package/dist/esm/app/flows.js.map +1 -1
- package/dist/esm/app/index.js +7 -0
- package/dist/esm/app/index.js.map +1 -1
- package/dist/esm/enable-app-module.js +19 -2
- package/dist/esm/enable-app-module.js.map +1 -1
- package/dist/esm/errors.js.map +1 -1
- package/dist/esm/index.js +18 -0
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/module.js +1 -0
- package/dist/esm/module.js.map +1 -1
- package/dist/esm/version.js +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/types/AppClient.d.ts +52 -10
- package/dist/types/AppConfig.d.ts +8 -0
- package/dist/types/AppConfigurator.d.ts +32 -0
- package/dist/types/AppModuleProvider.d.ts +80 -17
- package/dist/types/app/App.d.ts +28 -3
- package/dist/types/app/actions.d.ts +16 -0
- package/dist/types/app/create-reducer.d.ts +9 -0
- package/dist/types/app/create-state.d.ts +11 -0
- package/dist/types/app/events.d.ts +17 -1
- package/dist/types/app/index.d.ts +7 -0
- package/dist/types/enable-app-module.d.ts +19 -2
- package/dist/types/errors.d.ts +8 -0
- package/dist/types/index.d.ts +18 -0
- package/dist/types/module.d.ts +6 -0
- package/dist/types/types.d.ts +92 -3
- package/dist/types/version.d.ts +1 -1
- package/package.json +10 -10
- package/src/AppClient.ts +54 -11
- package/src/AppConfig.ts +15 -1
- package/src/AppConfigurator.ts +33 -1
- package/src/AppModuleProvider.ts +80 -17
- package/src/app/App.ts +29 -4
- package/src/app/actions.ts +16 -0
- package/src/app/create-reducer.ts +9 -0
- package/src/app/create-state.ts +11 -0
- package/src/app/events.ts +17 -1
- package/src/app/flows.ts +6 -2
- package/src/app/index.ts +7 -0
- package/src/enable-app-module.ts +19 -2
- package/src/errors.ts +8 -0
- package/src/index.ts +19 -0
- package/src/module.ts +6 -0
- package/src/types.ts +94 -7
- package/src/version.ts +1 -1
|
@@ -13,6 +13,15 @@ import { type Actions, actions } from './actions';
|
|
|
13
13
|
|
|
14
14
|
import type { AppBundleState, AppBundleStateInitial } from './types';
|
|
15
15
|
|
|
16
|
+
/**
|
|
17
|
+
* Creates the Immer-powered reducer for the {@link App} state machine.
|
|
18
|
+
*
|
|
19
|
+
* Handles synchronous state updates (set manifest, config, settings, module, instance)
|
|
20
|
+
* and tracks in-progress async operations via a `status` set.
|
|
21
|
+
*
|
|
22
|
+
* @param value - Initial state values (appKey, tag, and any pre-loaded data).
|
|
23
|
+
* @returns A reducer function compatible with {@link FlowSubject}.
|
|
24
|
+
*/
|
|
16
25
|
export const createReducer = (value: AppBundleStateInitial) =>
|
|
17
26
|
makeReducer<AppBundleState, Actions>(
|
|
18
27
|
{ ...value, status: new Set() } as AppBundleState,
|
package/src/app/create-state.ts
CHANGED
|
@@ -14,6 +14,17 @@ import type { Actions } from './actions';
|
|
|
14
14
|
import type { AppBundleState, AppBundleStateInitial } from './types';
|
|
15
15
|
import type { AppModuleProvider } from '../AppModuleProvider';
|
|
16
16
|
|
|
17
|
+
/**
|
|
18
|
+
* Creates and configures the reactive state machine ({@link FlowSubject}) for
|
|
19
|
+
* an {@link App} instance.
|
|
20
|
+
*
|
|
21
|
+
* Registers flows for fetching manifests, configs, settings, and importing
|
|
22
|
+
* the application script module.
|
|
23
|
+
*
|
|
24
|
+
* @param value - Initial state values (appKey, tag, and any pre-loaded data).
|
|
25
|
+
* @param provider - The {@link AppModuleProvider} used by flows to fetch data.
|
|
26
|
+
* @returns A configured `FlowSubject` ready for use by the App class.
|
|
27
|
+
*/
|
|
17
28
|
export const createState = (
|
|
18
29
|
value: AppBundleStateInitial,
|
|
19
30
|
provider: AppModuleProvider,
|
package/src/app/events.ts
CHANGED
|
@@ -10,7 +10,14 @@ import type {
|
|
|
10
10
|
AppSettings,
|
|
11
11
|
} from '../types';
|
|
12
12
|
|
|
13
|
-
/**
|
|
13
|
+
/**
|
|
14
|
+
* Base event initialization type for application lifecycle events.
|
|
15
|
+
*
|
|
16
|
+
* Extends {@link FrameworkEventInit} with a mandatory `appKey` field and
|
|
17
|
+
* the {@link App} as the event source.
|
|
18
|
+
*
|
|
19
|
+
* @template TDetail - Additional detail properties carried by the event.
|
|
20
|
+
*/
|
|
14
21
|
export type AppEventEventInit<TDetail extends Record<string, unknown> | unknown = unknown> =
|
|
15
22
|
FrameworkEventInit<
|
|
16
23
|
/** additional event details and key of target event */
|
|
@@ -19,10 +26,19 @@ export type AppEventEventInit<TDetail extends Record<string, unknown> | unknown
|
|
|
19
26
|
App
|
|
20
27
|
>;
|
|
21
28
|
|
|
29
|
+
/**
|
|
30
|
+
* Framework event carrying application-scoped detail and an {@link App} source.
|
|
31
|
+
*
|
|
32
|
+
* @template TDetail - Additional detail properties carried by the event.
|
|
33
|
+
*/
|
|
22
34
|
export type AppEvent<TDetail extends Record<string, unknown> | unknown = unknown> = FrameworkEvent<
|
|
23
35
|
AppEventEventInit<TDetail>
|
|
24
36
|
>;
|
|
25
37
|
|
|
38
|
+
/**
|
|
39
|
+
* Framework event emitted when an application lifecycle operation fails.
|
|
40
|
+
* The `error` detail carries the underlying failure.
|
|
41
|
+
*/
|
|
26
42
|
export type AppEventFailure = FrameworkEvent<
|
|
27
43
|
AppEventEventInit<{
|
|
28
44
|
error: AppConfig;
|
package/src/app/flows.ts
CHANGED
|
@@ -173,9 +173,13 @@ export const handleImportApplication =
|
|
|
173
173
|
filter(actions.importApp.match),
|
|
174
174
|
// when request is received, abort any ongoing request and start new
|
|
175
175
|
switchMap(({ payload }) => {
|
|
176
|
-
const endpoint = [provider.assetUri, payload].join('/').replace(/\/{2,}/g, '/');
|
|
177
176
|
// dynamically import the application script
|
|
178
|
-
return from(
|
|
177
|
+
return from(
|
|
178
|
+
import(
|
|
179
|
+
/* @vite-ignore */ /* webpackIgnore: true */
|
|
180
|
+
[provider.assetUri, payload].join('/').replace(/\/{2,}/g, '/')
|
|
181
|
+
),
|
|
182
|
+
).pipe(
|
|
179
183
|
// dispatch success action
|
|
180
184
|
map(actions.importApp.success),
|
|
181
185
|
// catch any error and dispatch failure action
|
package/src/app/index.ts
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Re-exports for the app sub-module.
|
|
3
|
+
*
|
|
4
|
+
* - {@link App} – Concrete application class managing reactive state.
|
|
5
|
+
* - {@link IApp} – Public interface for an application instance.
|
|
6
|
+
* - {@link AppInitializeResult} – Shape emitted by `App.initialize()`.
|
|
7
|
+
*/
|
|
1
8
|
export { App, IApp, type AppInitializeResult } from './App';
|
|
2
9
|
|
|
3
10
|
export { default } from './App';
|
package/src/enable-app-module.ts
CHANGED
|
@@ -3,8 +3,25 @@ import { module } from './module';
|
|
|
3
3
|
import type { AppConfigurator } from './AppConfigurator';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
|
-
*
|
|
7
|
-
*
|
|
6
|
+
* Registers the app module with a framework configurator.
|
|
7
|
+
*
|
|
8
|
+
* Call this during framework setup to enable application loading, manifest fetching,
|
|
9
|
+
* configuration resolution, and per-user settings management.
|
|
10
|
+
*
|
|
11
|
+
* @param configurator - The framework modules configurator to register the app module with.
|
|
12
|
+
* @param callback - Optional callback to customize the {@link AppConfigurator} before initialization
|
|
13
|
+
* (e.g., override the HTTP client or set a custom asset URI).
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* ```ts
|
|
17
|
+
* import { enableAppModule } from '@equinor/fusion-framework-module-app';
|
|
18
|
+
*
|
|
19
|
+
* export const configure = async (configurator: FrameworkConfigurator) => {
|
|
20
|
+
* enableAppModule(configurator, (builder) => {
|
|
21
|
+
* builder.setAssetUri('/custom-proxy');
|
|
22
|
+
* });
|
|
23
|
+
* };
|
|
24
|
+
* ```
|
|
8
25
|
*/
|
|
9
26
|
export const enableAppModule = (
|
|
10
27
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
package/src/errors.ts
CHANGED
|
@@ -1,3 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Discriminant for application-related errors.
|
|
3
|
+
*
|
|
4
|
+
* - `'not_found'` – The requested resource does not exist (HTTP 404).
|
|
5
|
+
* - `'unauthorized'` – The request lacks valid credentials (HTTP 401).
|
|
6
|
+
* - `'deleted'` – The resource has been removed (HTTP 410).
|
|
7
|
+
* - `'unknown'` – An unexpected failure occurred.
|
|
8
|
+
*/
|
|
1
9
|
type AppErrorType = 'not_found' | 'unauthorized' | 'unknown' | 'deleted';
|
|
2
10
|
|
|
3
11
|
/**
|
package/src/index.ts
CHANGED
|
@@ -1,3 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @packageDocumentation
|
|
3
|
+
*
|
|
4
|
+
* Framework module for loading, configuring, and managing Fusion applications at runtime.
|
|
5
|
+
*
|
|
6
|
+
* Use {@link enableAppModule} to register the module with a framework configurator.
|
|
7
|
+
* Once initialized, {@link AppModuleProvider} exposes methods for fetching app manifests,
|
|
8
|
+
* configurations, user settings, and for setting the current active application.
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```ts
|
|
12
|
+
* import { enableAppModule } from '@equinor/fusion-framework-module-app';
|
|
13
|
+
*
|
|
14
|
+
* export const configure = async (configurator: FrameworkConfigurator) => {
|
|
15
|
+
* enableAppModule(configurator);
|
|
16
|
+
* };
|
|
17
|
+
* ```
|
|
18
|
+
*/
|
|
19
|
+
|
|
1
20
|
export {
|
|
2
21
|
AppModuleConfig,
|
|
3
22
|
AppConfigurator,
|
package/src/module.ts
CHANGED
|
@@ -4,8 +4,14 @@ import type { ModuleDeps } from './types';
|
|
|
4
4
|
import { AppConfigurator } from './AppConfigurator';
|
|
5
5
|
import { AppModuleProvider } from './AppModuleProvider';
|
|
6
6
|
|
|
7
|
+
/** Module key used to register and look up the app module in the framework. */
|
|
7
8
|
export const moduleKey = 'app';
|
|
8
9
|
|
|
10
|
+
/**
|
|
11
|
+
* Type alias for the app module definition, binding the module key,
|
|
12
|
+
* provider type ({@link AppModuleProvider}), configurator type
|
|
13
|
+
* ({@link AppConfigurator}), and required module dependencies.
|
|
14
|
+
*/
|
|
9
15
|
export type AppModule = Module<typeof moduleKey, AppModuleProvider, AppConfigurator, ModuleDeps>;
|
|
10
16
|
|
|
11
17
|
/**
|
package/src/types.ts
CHANGED
|
@@ -6,13 +6,22 @@ import type { ServiceDiscoveryModule } from '@equinor/fusion-framework-module-se
|
|
|
6
6
|
import type { AppConfig } from './AppConfig';
|
|
7
7
|
import type IApp from './app';
|
|
8
8
|
|
|
9
|
+
/**
|
|
10
|
+
* Re-export of {@link ConfigEnvironment} from AppConfig.
|
|
11
|
+
*/
|
|
9
12
|
export type ConfigEnvironment = Record<string, unknown>;
|
|
10
13
|
export type { AppConfig } from './AppConfig';
|
|
11
14
|
|
|
12
|
-
// TODO
|
|
13
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
15
|
+
// biome-ignore lint/suspicious/noExplicitAny: TODO - needs proper type definition
|
|
14
16
|
type Fusion = any;
|
|
15
17
|
|
|
18
|
+
/**
|
|
19
|
+
* Environment bindings passed to an application at render time,
|
|
20
|
+
* including its manifest, configuration, base path, and custom props.
|
|
21
|
+
*
|
|
22
|
+
* @template TEnv - Shape of the environment configuration record.
|
|
23
|
+
* @template TProps - Shape of custom properties passed to the app.
|
|
24
|
+
*/
|
|
16
25
|
export type AppEnv<TEnv extends ConfigEnvironment = ConfigEnvironment, TProps = unknown> = {
|
|
17
26
|
basename?: string;
|
|
18
27
|
manifest?: AppManifest;
|
|
@@ -21,21 +30,38 @@ export type AppEnv<TEnv extends ConfigEnvironment = ConfigEnvironment, TProps =
|
|
|
21
30
|
};
|
|
22
31
|
|
|
23
32
|
/**
|
|
24
|
-
* Reference to an
|
|
33
|
+
* Reference to an application, used to fetch the app manifest from the app service.
|
|
34
|
+
* The `tag` defaults to `'latest'` when omitted.
|
|
25
35
|
*/
|
|
26
36
|
export type AppReference = {
|
|
27
37
|
appKey: string;
|
|
28
38
|
tag?: string; // defaults to 'latest'
|
|
29
39
|
};
|
|
30
40
|
|
|
31
|
-
|
|
41
|
+
/**
|
|
42
|
+
* Required module dependencies for the app module.
|
|
43
|
+
*
|
|
44
|
+
* The app module depends on HTTP (for API calls), service discovery
|
|
45
|
+
* (for resolving the apps service URL), and events (for lifecycle notifications).
|
|
46
|
+
*/
|
|
32
47
|
export type ModuleDeps = [HttpModule, ServiceDiscoveryModule, EventModule];
|
|
33
48
|
|
|
49
|
+
/**
|
|
50
|
+
* Per-user application settings, stored as an arbitrary key-value record.
|
|
51
|
+
* Read via `getAppSettings` and written via `updateAppSettings` on the provider.
|
|
52
|
+
*/
|
|
34
53
|
export interface AppSettings {
|
|
35
54
|
[key: string]: unknown;
|
|
36
55
|
}
|
|
37
56
|
|
|
38
|
-
|
|
57
|
+
/**
|
|
58
|
+
* Discriminant union of supported application types.
|
|
59
|
+
*
|
|
60
|
+
* - `'standalone'` – A full standalone application.
|
|
61
|
+
* - `'template'` / `'template-app'` – Template-based apps.
|
|
62
|
+
* - `'landing-page'` – Portal landing pages.
|
|
63
|
+
* - `'report'` / `'launcher'` – Legacy types (will be removed).
|
|
64
|
+
*/
|
|
39
65
|
export type AppType =
|
|
40
66
|
| 'standalone'
|
|
41
67
|
| 'report'
|
|
@@ -44,6 +70,13 @@ export type AppType =
|
|
|
44
70
|
| 'template-app'
|
|
45
71
|
| 'landing-page';
|
|
46
72
|
|
|
73
|
+
/**
|
|
74
|
+
* The currently active application, or `null` when cleared, or `undefined`
|
|
75
|
+
* when no application has been set yet.
|
|
76
|
+
*
|
|
77
|
+
* @template TModules - Additional framework modules the app depends on.
|
|
78
|
+
* @template TEnv - Shape of the environment configuration record.
|
|
79
|
+
*/
|
|
47
80
|
export type CurrentApp<
|
|
48
81
|
TModules extends Array<AnyModule> = [],
|
|
49
82
|
TEnv extends ConfigEnvironment = ConfigEnvironment,
|
|
@@ -51,6 +84,9 @@ export type CurrentApp<
|
|
|
51
84
|
|
|
52
85
|
type Nullable<T> = T | null | undefined;
|
|
53
86
|
|
|
87
|
+
/**
|
|
88
|
+
* Represents a person associated with an application (admin or owner).
|
|
89
|
+
*/
|
|
54
90
|
type AppPerson = {
|
|
55
91
|
id: string;
|
|
56
92
|
azureUniqueId: string;
|
|
@@ -62,10 +98,29 @@ type AppPerson = {
|
|
|
62
98
|
isExpired?: Nullable<boolean>;
|
|
63
99
|
};
|
|
64
100
|
|
|
101
|
+
/** An application administrator. */
|
|
65
102
|
export type AppAdmin = AppPerson;
|
|
66
103
|
|
|
104
|
+
/** An application owner. */
|
|
67
105
|
export type AppOwner = AppPerson;
|
|
68
106
|
|
|
107
|
+
/**
|
|
108
|
+
* Schema entry format for route documentation in app manifests.
|
|
109
|
+
* Each entry represents a route with its path, description, and optional parameter/search schemas.
|
|
110
|
+
*/
|
|
111
|
+
export type RouteSchemaEntry = [
|
|
112
|
+
path: string,
|
|
113
|
+
description: string,
|
|
114
|
+
options?: {
|
|
115
|
+
params?: Record<string, string>;
|
|
116
|
+
search?: Record<string, string>;
|
|
117
|
+
},
|
|
118
|
+
];
|
|
119
|
+
|
|
120
|
+
/**
|
|
121
|
+
* Build metadata returned by the app service for a specific application version.
|
|
122
|
+
* Contains the script entry point, asset path, tags, and optional CI metadata.
|
|
123
|
+
*/
|
|
69
124
|
export type AppBuildManifest = {
|
|
70
125
|
version: string;
|
|
71
126
|
entryPoint: string;
|
|
@@ -82,6 +137,10 @@ export type AppBuildManifest = {
|
|
|
82
137
|
uploadedBy?: Nullable<AppOwner>;
|
|
83
138
|
};
|
|
84
139
|
|
|
140
|
+
/**
|
|
141
|
+
* Full manifest describing a registered Fusion application, including
|
|
142
|
+
* display metadata, category, admins/owners, build info, and optional route schemas.
|
|
143
|
+
*/
|
|
85
144
|
export interface AppManifest {
|
|
86
145
|
/** @deprecated will be removed, use appKey */
|
|
87
146
|
key?: string;
|
|
@@ -110,11 +169,15 @@ export interface AppManifest {
|
|
|
110
169
|
admins?: Nullable<AppAdmin[]>;
|
|
111
170
|
owners?: Nullable<AppOwner[]>;
|
|
112
171
|
build?: Nullable<AppBuildManifest>;
|
|
172
|
+
/** Route schema entries for documentation and API schema generation */
|
|
173
|
+
routes?: Nullable<RouteSchemaEntry[]>;
|
|
113
174
|
}
|
|
114
175
|
|
|
115
176
|
/**
|
|
116
|
-
*
|
|
117
|
-
*
|
|
177
|
+
* A loaded application bundle containing its manifest, config, and imported script module.
|
|
178
|
+
*
|
|
179
|
+
* @template TEnvironment - Shape of the environment config record.
|
|
180
|
+
* @template TModule - Type of the dynamically imported ES module.
|
|
118
181
|
*/
|
|
119
182
|
export type AppBundle<
|
|
120
183
|
TEnvironment extends ConfigEnvironment = ConfigEnvironment,
|
|
@@ -125,20 +188,44 @@ export type AppBundle<
|
|
|
125
188
|
module: TModule;
|
|
126
189
|
};
|
|
127
190
|
|
|
191
|
+
/**
|
|
192
|
+
* Combined module type merging the app's own modules with base framework modules
|
|
193
|
+
* (Event, HTTP, MSAL).
|
|
194
|
+
*
|
|
195
|
+
* @template TModules - Additional modules contributed by the application.
|
|
196
|
+
*/
|
|
128
197
|
export type AppModules<TModules extends Array<AnyModule> | unknown = unknown> = CombinedModules<
|
|
129
198
|
TModules,
|
|
130
199
|
[EventModule, HttpModule, MsalModule]
|
|
131
200
|
>;
|
|
132
201
|
|
|
202
|
+
/**
|
|
203
|
+
* Arguments passed to an application's `renderApp` or default export function
|
|
204
|
+
* when mounting the application into a DOM element.
|
|
205
|
+
*
|
|
206
|
+
* @template TFusion - Type of the Fusion framework instance.
|
|
207
|
+
* @template TEnv - Type of the environment bindings.
|
|
208
|
+
*/
|
|
133
209
|
export type ComponentRenderArgs<TFusion extends Fusion = Fusion, TEnv = AppEnv> = {
|
|
134
210
|
fusion: TFusion;
|
|
135
211
|
env: TEnv;
|
|
136
212
|
};
|
|
137
213
|
|
|
214
|
+
/**
|
|
215
|
+
* Shape of the ES module exported by an application's script bundle.
|
|
216
|
+
*
|
|
217
|
+
* Must expose either a `default` export or a `renderApp` function (or both)
|
|
218
|
+
* that mounts the application into a host DOM element.
|
|
219
|
+
*/
|
|
138
220
|
export type AppScriptModule = {
|
|
139
221
|
default: (el: HTMLElement, args: ComponentRenderArgs) => VoidFunction;
|
|
140
222
|
renderApp: (el: HTMLElement, args: ComponentRenderArgs) => VoidFunction;
|
|
141
223
|
};
|
|
142
224
|
|
|
225
|
+
/**
|
|
226
|
+
* Instantiated module collection for a running application.
|
|
227
|
+
*
|
|
228
|
+
* @template TModules - Additional modules contributed by the application.
|
|
229
|
+
*/
|
|
143
230
|
export type AppModulesInstance<TModules extends Array<AnyModule> | unknown = unknown> =
|
|
144
231
|
ModulesInstance<AppModules<TModules>>;
|
package/src/version.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// Generated by genversion.
|
|
2
|
-
export const version = '
|
|
2
|
+
export const version = '8.0.0';
|