@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
|
@@ -1,44 +1,74 @@
|
|
|
1
1
|
import { type Observable, type ObservableInput } from 'rxjs';
|
|
2
2
|
import { type IHttpClient } from '@equinor/fusion-framework-module-http';
|
|
3
3
|
import type { AppBuildManifest, AppConfig, AppManifest, AppSettings, ConfigEnvironment } from './types';
|
|
4
|
+
/**
|
|
5
|
+
* Contract for an app service client that fetches application manifests,
|
|
6
|
+
* build metadata, configurations, and per-user settings from the Fusion apps API.
|
|
7
|
+
*
|
|
8
|
+
* All methods return `ObservableInput` so consumers can use either `Observable`
|
|
9
|
+
* or `Promise`-based consumption patterns.
|
|
10
|
+
*/
|
|
4
11
|
export interface IAppClient extends Disposable {
|
|
5
12
|
/**
|
|
6
|
-
*
|
|
13
|
+
* Fetches the manifest for a single application.
|
|
14
|
+
*
|
|
15
|
+
* @param args - Object containing the `appKey` and an optional version `tag`.
|
|
16
|
+
* @returns An observable that emits the resolved {@link AppManifest}.
|
|
17
|
+
* @throws {AppManifestError} When the manifest cannot be loaded (404, 401, 410, or unknown).
|
|
7
18
|
*/
|
|
8
19
|
getAppManifest: (args: {
|
|
9
20
|
appKey: string;
|
|
10
21
|
tag?: string;
|
|
11
22
|
}) => ObservableInput<AppManifest>;
|
|
12
23
|
/**
|
|
13
|
-
*
|
|
24
|
+
* Fetches the build metadata (entry point, version, asset path) for an application.
|
|
25
|
+
*
|
|
26
|
+
* @param args - Object containing the `appKey` and an optional version `tag`.
|
|
27
|
+
* @returns An observable that emits the resolved {@link AppBuildManifest}.
|
|
28
|
+
* @throws {AppBuildError} When the build metadata cannot be loaded.
|
|
14
29
|
*/
|
|
15
30
|
getAppBuild: (args: {
|
|
16
31
|
appKey: string;
|
|
17
32
|
tag?: string;
|
|
18
33
|
}) => ObservableInput<AppBuildManifest>;
|
|
19
34
|
/**
|
|
20
|
-
*
|
|
35
|
+
* Fetches manifests for all registered applications.
|
|
36
|
+
*
|
|
37
|
+
* @param args - Optional filter; set `filterByCurrentUser` to `true` to return
|
|
38
|
+
* only apps the authenticated user has access to.
|
|
39
|
+
* @returns An observable that emits an array of {@link AppManifest} objects.
|
|
21
40
|
*/
|
|
22
41
|
getAppManifests: (args?: {
|
|
23
42
|
filterByCurrentUser?: boolean;
|
|
24
43
|
}) => ObservableInput<AppManifest[]>;
|
|
25
44
|
/**
|
|
26
|
-
*
|
|
45
|
+
* Fetches the runtime configuration (environment variables and endpoints) for an application.
|
|
46
|
+
*
|
|
47
|
+
* @template TType - Shape of the `environment` record in the returned config.
|
|
48
|
+
* @param args - Object containing the `appKey` and an optional version `tag`.
|
|
49
|
+
* @returns An observable that emits the resolved {@link AppConfig}.
|
|
50
|
+
* @throws {AppConfigError} When the configuration cannot be loaded.
|
|
27
51
|
*/
|
|
28
52
|
getAppConfig: <TType extends ConfigEnvironment = ConfigEnvironment>(args: {
|
|
29
53
|
appKey: string;
|
|
30
54
|
tag?: string;
|
|
31
55
|
}) => ObservableInput<AppConfig<TType>>;
|
|
32
56
|
/**
|
|
33
|
-
*
|
|
57
|
+
* Fetches per-user settings for an application.
|
|
58
|
+
*
|
|
59
|
+
* @param args - Object containing the `appKey`.
|
|
60
|
+
* @returns An observable that emits the {@link AppSettings} record.
|
|
61
|
+
* @throws {AppSettingsError} When settings cannot be loaded.
|
|
34
62
|
*/
|
|
35
63
|
getAppSettings: (args: {
|
|
36
64
|
appKey: string;
|
|
37
65
|
}) => ObservableInput<AppSettings>;
|
|
38
66
|
/**
|
|
39
|
-
*
|
|
40
|
-
*
|
|
41
|
-
* @
|
|
67
|
+
* Persists updated per-user settings for an application via PUT.
|
|
68
|
+
*
|
|
69
|
+
* @param args - Object containing the `appKey` and the `settings` payload to save.
|
|
70
|
+
* @returns An observable that emits the persisted {@link AppSettings}.
|
|
71
|
+
* @throws {AppSettingsError} When the update request fails.
|
|
42
72
|
*/
|
|
43
73
|
updateAppSettings: (args: {
|
|
44
74
|
appKey: string;
|
|
@@ -46,8 +76,20 @@ export interface IAppClient extends Disposable {
|
|
|
46
76
|
}) => ObservableInput<AppSettings>;
|
|
47
77
|
}
|
|
48
78
|
/**
|
|
49
|
-
*
|
|
50
|
-
*
|
|
79
|
+
* Default implementation of {@link IAppClient} that communicates with the
|
|
80
|
+
* Fusion app service API over HTTP.
|
|
81
|
+
*
|
|
82
|
+
* Uses {@link Query} internally for request deduplication and caching
|
|
83
|
+
* (1-minute expiry by default). Responses are validated against Zod schemas
|
|
84
|
+
* ({@link ApiApplicationSchema}, {@link ApiApplicationBuildSchema}) and
|
|
85
|
+
* HTTP errors are mapped to typed error classes.
|
|
86
|
+
*
|
|
87
|
+
* @example
|
|
88
|
+
* ```ts
|
|
89
|
+
* const httpClient = await http.createClient('apps');
|
|
90
|
+
* const appClient = new AppClient(httpClient);
|
|
91
|
+
* appClient.getAppManifest({ appKey: 'my-app' }).subscribe(console.log);
|
|
92
|
+
* ```
|
|
51
93
|
*/
|
|
52
94
|
export declare class AppClient implements IAppClient {
|
|
53
95
|
#private;
|
|
@@ -1,4 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Arbitrary key-value record representing environment-specific variables
|
|
3
|
+
* injected into an application's runtime configuration.
|
|
4
|
+
*/
|
|
1
5
|
export type ConfigEnvironment = Record<string, unknown>;
|
|
6
|
+
/**
|
|
7
|
+
* A named endpoint from the application configuration, containing a URL
|
|
8
|
+
* and the OAuth scopes required to call it.
|
|
9
|
+
*/
|
|
2
10
|
export type ConfigEndPoint = {
|
|
3
11
|
url: string;
|
|
4
12
|
scopes: string[];
|
|
@@ -2,14 +2,46 @@ import { BaseConfigBuilder, type ConfigBuilderCallback, type ModuleInitializerAr
|
|
|
2
2
|
import type { HttpModule, IHttpClient } from '@equinor/fusion-framework-module-http';
|
|
3
3
|
import type { ServiceDiscoveryModule } from '@equinor/fusion-framework-module-service-discovery';
|
|
4
4
|
import { type IAppClient } from './AppClient';
|
|
5
|
+
/**
|
|
6
|
+
* Resolved configuration for the app module.
|
|
7
|
+
*
|
|
8
|
+
* Produced by {@link AppConfigurator} during module initialization and consumed
|
|
9
|
+
* by {@link AppModuleProvider} at runtime.
|
|
10
|
+
*/
|
|
5
11
|
export interface AppModuleConfig {
|
|
12
|
+
/** HTTP client used to communicate with the Fusion app service API. */
|
|
6
13
|
client: IAppClient;
|
|
14
|
+
/** Base URI for fetching application script bundles (e.g., `'/apps-proxy'`). */
|
|
7
15
|
assetUri?: string;
|
|
8
16
|
}
|
|
17
|
+
/**
|
|
18
|
+
* Public interface for configuring the app module before initialization.
|
|
19
|
+
*
|
|
20
|
+
* Consumers use this interface (via the callback in {@link enableAppModule}) to
|
|
21
|
+
* override the default HTTP client or asset URI.
|
|
22
|
+
*/
|
|
9
23
|
export interface IAppConfigurator {
|
|
24
|
+
/**
|
|
25
|
+
* Sets the app service client used to fetch manifests, configs, and settings.
|
|
26
|
+
*
|
|
27
|
+
* @param client_or_cb - A promise resolving to an {@link IAppClient}, or a callback
|
|
28
|
+
* that receives module initializer args and returns one.
|
|
29
|
+
*/
|
|
10
30
|
setClient: (client_or_cb: Promise<AppModuleConfig['client']> | ConfigBuilderCallback<AppModuleConfig['client']>) => void;
|
|
31
|
+
/**
|
|
32
|
+
* Sets the base URI used to proxy-load application script bundles.
|
|
33
|
+
*
|
|
34
|
+
* @param base_or_cb - A static URI string or a callback returning one.
|
|
35
|
+
*/
|
|
11
36
|
setAssetUri: (base_or_cb: string | ConfigBuilderCallback<string>) => void;
|
|
12
37
|
}
|
|
38
|
+
/**
|
|
39
|
+
* Configuration builder for the app module.
|
|
40
|
+
*
|
|
41
|
+
* Extends {@link BaseConfigBuilder} to assemble an {@link AppModuleConfig} during
|
|
42
|
+
* framework initialization. If no explicit client is set, a default one is created
|
|
43
|
+
* via service discovery. The default `assetUri` is `'/apps-proxy'`.
|
|
44
|
+
*/
|
|
13
45
|
export declare class AppConfigurator extends BaseConfigBuilder<AppModuleConfig> implements IAppConfigurator {
|
|
14
46
|
defaultExpireTime: number;
|
|
15
47
|
/**
|
|
@@ -6,32 +6,73 @@ import { App, type IApp } from './app/App';
|
|
|
6
6
|
import type { AppModuleConfig } from './AppConfigurator';
|
|
7
7
|
import type { AppBundleStateInitial } from './app/types';
|
|
8
8
|
import { SemanticVersion } from '@equinor/fusion-framework-module';
|
|
9
|
+
/**
|
|
10
|
+
* Runtime provider for the app module.
|
|
11
|
+
*
|
|
12
|
+
* Exposes methods for fetching application manifests, configurations, and user
|
|
13
|
+
* settings, and for setting or clearing the current active application. When an
|
|
14
|
+
* {@link EventModule} is available, lifecycle events are dispatched as the
|
|
15
|
+
* current app changes.
|
|
16
|
+
*
|
|
17
|
+
* @remarks
|
|
18
|
+
* Only one application can be active (`current`) at a time. Setting a new current
|
|
19
|
+
* app automatically disposes the previous one. Subscribe to {@link current$} for
|
|
20
|
+
* reactive updates.
|
|
21
|
+
*/
|
|
9
22
|
export declare class AppModuleProvider {
|
|
10
23
|
#private;
|
|
24
|
+
/**
|
|
25
|
+
* Shallow-compares two app manifests by JSON serialization.
|
|
26
|
+
*
|
|
27
|
+
* @param a - First manifest to compare.
|
|
28
|
+
* @param b - Second manifest to compare.
|
|
29
|
+
* @returns `true` if the serialized manifests are identical.
|
|
30
|
+
*/
|
|
11
31
|
static compareAppManifest<T extends AppManifest>(a?: T, b?: T): boolean;
|
|
12
32
|
/**
|
|
13
33
|
* Get module version
|
|
14
34
|
*/
|
|
15
35
|
get version(): SemanticVersion;
|
|
16
36
|
/**
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
* - null
|
|
21
|
-
* -
|
|
37
|
+
* The current active application instance.
|
|
38
|
+
*
|
|
39
|
+
* - `undefined` – no application has been set yet.
|
|
40
|
+
* - `null` – the current application was explicitly cleared.
|
|
41
|
+
* - `App` – an active application instance.
|
|
22
42
|
*/
|
|
23
43
|
get current(): CurrentApp | null | undefined;
|
|
44
|
+
/**
|
|
45
|
+
* Observable that emits when the current application changes.
|
|
46
|
+
*
|
|
47
|
+
* Emits are deduplicated by `appKey`; re-setting the same app does not trigger
|
|
48
|
+
* a new emission.
|
|
49
|
+
*/
|
|
24
50
|
get current$(): Observable<CurrentApp | null>;
|
|
51
|
+
/**
|
|
52
|
+
* Creates the app module provider.
|
|
53
|
+
*
|
|
54
|
+
* @param args - Object containing the resolved {@link AppModuleConfig} and an
|
|
55
|
+
* optional {@link EventModule} instance for dispatching lifecycle events.
|
|
56
|
+
*/
|
|
25
57
|
constructor(args: {
|
|
26
58
|
config: AppModuleConfig;
|
|
27
59
|
event?: ModuleType<EventModule>;
|
|
28
60
|
});
|
|
29
61
|
/**
|
|
30
|
-
*
|
|
31
|
-
*
|
|
32
|
-
* @param
|
|
62
|
+
* Fetches the manifest for a single application by key.
|
|
63
|
+
*
|
|
64
|
+
* @param appKey - Unique application identifier.
|
|
65
|
+
* @param tag - Optional version tag (defaults to latest).
|
|
66
|
+
* @returns An observable that emits the resolved {@link AppManifest}.
|
|
33
67
|
*/
|
|
34
68
|
getAppManifest(appKey: string, tag?: string): Observable<AppManifest>;
|
|
69
|
+
/**
|
|
70
|
+
* Fetches manifests for all registered applications.
|
|
71
|
+
*
|
|
72
|
+
* @param filter - Optional filter; set `filterByCurrentUser` to `true` to scope
|
|
73
|
+
* results to apps accessible by the authenticated user.
|
|
74
|
+
* @returns An observable that emits an array of {@link AppManifest} objects.
|
|
75
|
+
*/
|
|
35
76
|
getAppManifests(filter?: {
|
|
36
77
|
filterByCurrentUser: boolean;
|
|
37
78
|
}): Observable<AppManifest[]>;
|
|
@@ -41,33 +82,55 @@ export declare class AppModuleProvider {
|
|
|
41
82
|
*/
|
|
42
83
|
getAllAppManifests(): Observable<AppManifest[]>;
|
|
43
84
|
/**
|
|
44
|
-
*
|
|
45
|
-
*
|
|
85
|
+
* Fetches the runtime configuration for an application.
|
|
86
|
+
*
|
|
87
|
+
* @template TType - Shape of the `environment` record in the returned config.
|
|
88
|
+
* @param appKey - Unique application identifier.
|
|
89
|
+
* @param tag - Optional version tag.
|
|
90
|
+
* @returns An observable that emits the resolved {@link AppConfig}.
|
|
46
91
|
*/
|
|
47
92
|
getAppConfig<TType extends ConfigEnvironment = ConfigEnvironment>(appKey: string, tag?: string): Observable<AppConfig<TType>>;
|
|
48
93
|
/**
|
|
49
|
-
*
|
|
50
|
-
*
|
|
94
|
+
* Fetches per-user settings for an application.
|
|
95
|
+
*
|
|
96
|
+
* @param appKey - Unique application identifier.
|
|
97
|
+
* @returns An observable that emits the {@link AppSettings} record.
|
|
51
98
|
*/
|
|
52
99
|
getAppSettings(appKey: string): Observable<AppSettings>;
|
|
53
100
|
/**
|
|
54
|
-
*
|
|
55
|
-
*
|
|
56
|
-
* @param
|
|
101
|
+
* Persists updated per-user settings for an application.
|
|
102
|
+
*
|
|
103
|
+
* @param appKey - Unique application identifier.
|
|
104
|
+
* @param settings - The settings record to save.
|
|
105
|
+
* @returns An observable that emits the persisted {@link AppSettings}.
|
|
57
106
|
*/
|
|
58
107
|
updateAppSettings(appKey: string, settings: AppSettings): Observable<AppSettings>;
|
|
59
108
|
/**
|
|
60
|
-
*
|
|
61
|
-
*
|
|
109
|
+
* Sets the current active application.
|
|
110
|
+
*
|
|
111
|
+
* Accepts an app key string, an {@link IApp} instance, or an {@link AppReference}
|
|
112
|
+
* with both `appKey` and `tag`. Setting a new app disposes the previous one.
|
|
113
|
+
*
|
|
114
|
+
* @param appKeyOrApp - Application key, app reference, or an existing `IApp` instance.
|
|
62
115
|
*/
|
|
63
116
|
setCurrentApp(appKeyOrApp: string | IApp | AppReference): void;
|
|
117
|
+
/**
|
|
118
|
+
* Clears the current application, disposing its resources and emitting `null`
|
|
119
|
+
* on {@link current$}.
|
|
120
|
+
*/
|
|
64
121
|
clearCurrentApp(): void;
|
|
122
|
+
/**
|
|
123
|
+
* Base URI used for proxying application script imports.
|
|
124
|
+
*/
|
|
65
125
|
get assetUri(): string;
|
|
66
126
|
/**
|
|
67
127
|
* This should not be used, only for legacy creation backdoor
|
|
68
128
|
* @deprecated
|
|
69
129
|
*/
|
|
70
130
|
createApp(value: AppBundleStateInitial): App;
|
|
131
|
+
/**
|
|
132
|
+
* Tears down the provider, unsubscribing from all internal observables.
|
|
133
|
+
*/
|
|
71
134
|
dispose(): void;
|
|
72
135
|
}
|
|
73
136
|
export default AppModuleProvider;
|
package/dist/types/app/App.d.ts
CHANGED
|
@@ -6,11 +6,22 @@ import type { EventModule } from '@equinor/fusion-framework-module-event';
|
|
|
6
6
|
import type { AnyModule, ModuleType } from '@equinor/fusion-framework-module';
|
|
7
7
|
import type { AppBundleState, AppBundleStateInitial } from './types';
|
|
8
8
|
import './events';
|
|
9
|
+
/**
|
|
10
|
+
* RxJS operator that filters out `null` and `undefined` emissions.
|
|
11
|
+
*
|
|
12
|
+
* @template T - The non-nullable value type.
|
|
13
|
+
* @returns An operator that only passes through non-nullable values.
|
|
14
|
+
*/
|
|
9
15
|
export declare function filterEmpty<T>(): OperatorFunction<T | null | undefined, T>;
|
|
10
16
|
/**
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
17
|
+
* Public interface for a single loaded Fusion application.
|
|
18
|
+
*
|
|
19
|
+
* Provides reactive observables and imperative methods for accessing the
|
|
20
|
+
* application's manifest, configuration, per-user settings, script module,
|
|
21
|
+
* and initialized module instance.
|
|
22
|
+
*
|
|
23
|
+
* @template TEnv - Shape of the environment configuration record.
|
|
24
|
+
* @template TModules - Additional framework modules the app depends on.
|
|
14
25
|
*/
|
|
15
26
|
export interface IApp<TEnv extends ConfigEnvironment = ConfigEnvironment, TModules extends Array<AnyModule> | unknown = unknown> {
|
|
16
27
|
/**
|
|
@@ -181,11 +192,25 @@ export interface IApp<TEnv extends ConfigEnvironment = ConfigEnvironment, TModul
|
|
|
181
192
|
*/
|
|
182
193
|
getAppModuleAsync(allow_cache?: boolean): Promise<AppScriptModule>;
|
|
183
194
|
}
|
|
195
|
+
/**
|
|
196
|
+
* Result emitted by {@link IApp.initialize}, containing the resolved manifest,
|
|
197
|
+
* imported script module, and runtime configuration.
|
|
198
|
+
*/
|
|
184
199
|
export type AppInitializeResult = {
|
|
185
200
|
manifest: AppManifest;
|
|
186
201
|
script: AppScriptModule;
|
|
187
202
|
config: AppConfig;
|
|
188
203
|
};
|
|
204
|
+
/**
|
|
205
|
+
* Concrete implementation of {@link IApp}.
|
|
206
|
+
*
|
|
207
|
+
* Manages an internal reactive state machine ({@link FlowSubject}) that orchestrates
|
|
208
|
+
* manifest fetching, config loading, settings management, and script import. Dispatches
|
|
209
|
+
* lifecycle events through the {@link EventModule} when available.
|
|
210
|
+
*
|
|
211
|
+
* @template TEnv - Shape of the environment configuration record.
|
|
212
|
+
* @template TModules - Additional framework modules the app depends on.
|
|
213
|
+
*/
|
|
189
214
|
export declare class App<TEnv extends ConfigEnvironment = ConfigEnvironment, TModules extends Array<AnyModule> | unknown = unknown> implements IApp<TEnv, TModules> {
|
|
190
215
|
#private;
|
|
191
216
|
get manifest$(): Observable<AppManifest>;
|
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
import { type ActionInstanceMap, type ActionTypes } from '@equinor/fusion-observable';
|
|
2
2
|
import type { AppConfig, AppManifest, AppModulesInstance, AppScriptModule, AppSettings } from '../types';
|
|
3
|
+
/**
|
|
4
|
+
* Factory function that creates all action creators used by the {@link App}
|
|
5
|
+
* state machine.
|
|
6
|
+
*
|
|
7
|
+
* Actions are grouped by domain:
|
|
8
|
+
* - **Manifest** – `setManifest`, `fetchManifest` (async)
|
|
9
|
+
* - **Config** – `setConfig`, `fetchConfig` (async)
|
|
10
|
+
* - **Settings** – `setSettings`, `fetchSettings` (async), `updateSettings` (async)
|
|
11
|
+
* - **Script module** – `setModule`, `importApp` (async)
|
|
12
|
+
* - **Instance** – `setInstance`
|
|
13
|
+
* - **Lifecycle** – `initialize` (async)
|
|
14
|
+
*/
|
|
3
15
|
declare const createActions: () => {
|
|
4
16
|
/** Manifest loading */
|
|
5
17
|
setManifest: import("@equinor/fusion-observable").ActionCreatorWithPreparedPayload<[manifest: AppManifest, update?: boolean | undefined], AppManifest, "set_manifest", never, {
|
|
@@ -51,6 +63,7 @@ declare const createActions: () => {
|
|
|
51
63
|
failure: import("@equinor/fusion-observable").ActionCreatorWithPreparedPayload<[error: unknown], unknown, "initialize_app::failure", never, never>;
|
|
52
64
|
};
|
|
53
65
|
};
|
|
66
|
+
/** Singleton action creator map used by the app state machine. */
|
|
54
67
|
export declare const actions: {
|
|
55
68
|
/** Manifest loading */
|
|
56
69
|
setManifest: import("@equinor/fusion-observable").ActionCreatorWithPreparedPayload<[manifest: AppManifest, update?: boolean | undefined], AppManifest, "set_manifest", never, {
|
|
@@ -102,7 +115,10 @@ export declare const actions: {
|
|
|
102
115
|
failure: import("@equinor/fusion-observable").ActionCreatorWithPreparedPayload<[error: unknown], unknown, "initialize_app::failure", never, never>;
|
|
103
116
|
};
|
|
104
117
|
};
|
|
118
|
+
/** Record mapping action names to their creator functions. */
|
|
105
119
|
export type ActionBuilder = ReturnType<typeof createActions>;
|
|
120
|
+
/** Map of action names to their instantiated action shapes. */
|
|
106
121
|
export type ActionMap = ActionInstanceMap<ActionBuilder>;
|
|
122
|
+
/** Union of all action types dispatched by the app state machine. */
|
|
107
123
|
export type Actions = ActionTypes<typeof actions>;
|
|
108
124
|
export {};
|
|
@@ -1,4 +1,13 @@
|
|
|
1
1
|
import type { AppBundleState, AppBundleStateInitial } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* Creates the Immer-powered reducer for the {@link App} state machine.
|
|
4
|
+
*
|
|
5
|
+
* Handles synchronous state updates (set manifest, config, settings, module, instance)
|
|
6
|
+
* and tracks in-progress async operations via a `status` set.
|
|
7
|
+
*
|
|
8
|
+
* @param value - Initial state values (appKey, tag, and any pre-loaded data).
|
|
9
|
+
* @returns A reducer function compatible with {@link FlowSubject}.
|
|
10
|
+
*/
|
|
2
11
|
export declare const createReducer: (value: AppBundleStateInitial) => import("@equinor/fusion-observable").ReducerWithInitialState<AppBundleState, import("@equinor/fusion-observable").PayloadAction<import("..").AppManifest, "set_manifest", {
|
|
3
12
|
created: number;
|
|
4
13
|
update: boolean | undefined;
|
|
@@ -2,4 +2,15 @@ import { FlowSubject } from '@equinor/fusion-observable';
|
|
|
2
2
|
import type { Actions } from './actions';
|
|
3
3
|
import type { AppBundleState, AppBundleStateInitial } from './types';
|
|
4
4
|
import type { AppModuleProvider } from '../AppModuleProvider';
|
|
5
|
+
/**
|
|
6
|
+
* Creates and configures the reactive state machine ({@link FlowSubject}) for
|
|
7
|
+
* an {@link App} instance.
|
|
8
|
+
*
|
|
9
|
+
* Registers flows for fetching manifests, configs, settings, and importing
|
|
10
|
+
* the application script module.
|
|
11
|
+
*
|
|
12
|
+
* @param value - Initial state values (appKey, tag, and any pre-loaded data).
|
|
13
|
+
* @param provider - The {@link AppModuleProvider} used by flows to fetch data.
|
|
14
|
+
* @returns A configured `FlowSubject` ready for use by the App class.
|
|
15
|
+
*/
|
|
5
16
|
export declare const createState: (value: AppBundleStateInitial, provider: AppModuleProvider) => FlowSubject<AppBundleState, Actions>;
|
|
@@ -1,7 +1,14 @@
|
|
|
1
1
|
import type { FrameworkEvent, FrameworkEventInit } from '@equinor/fusion-framework-module-event';
|
|
2
2
|
import type { App } from './App';
|
|
3
3
|
import type { AppConfig, AppManifest, AppModulesInstance, AppScriptModule, AppSettings } from '../types';
|
|
4
|
-
/**
|
|
4
|
+
/**
|
|
5
|
+
* Base event initialization type for application lifecycle events.
|
|
6
|
+
*
|
|
7
|
+
* Extends {@link FrameworkEventInit} with a mandatory `appKey` field and
|
|
8
|
+
* the {@link App} as the event source.
|
|
9
|
+
*
|
|
10
|
+
* @template TDetail - Additional detail properties carried by the event.
|
|
11
|
+
*/
|
|
5
12
|
export type AppEventEventInit<TDetail extends Record<string, unknown> | unknown = unknown> = FrameworkEventInit<
|
|
6
13
|
/** additional event details and key of target event */
|
|
7
14
|
TDetail & {
|
|
@@ -9,7 +16,16 @@ TDetail & {
|
|
|
9
16
|
},
|
|
10
17
|
/** source of the event */
|
|
11
18
|
App>;
|
|
19
|
+
/**
|
|
20
|
+
* Framework event carrying application-scoped detail and an {@link App} source.
|
|
21
|
+
*
|
|
22
|
+
* @template TDetail - Additional detail properties carried by the event.
|
|
23
|
+
*/
|
|
12
24
|
export type AppEvent<TDetail extends Record<string, unknown> | unknown = unknown> = FrameworkEvent<AppEventEventInit<TDetail>>;
|
|
25
|
+
/**
|
|
26
|
+
* Framework event emitted when an application lifecycle operation fails.
|
|
27
|
+
* The `error` detail carries the underlying failure.
|
|
28
|
+
*/
|
|
13
29
|
export type AppEventFailure = FrameworkEvent<AppEventEventInit<{
|
|
14
30
|
error: AppConfig;
|
|
15
31
|
}>>;
|
|
@@ -1,2 +1,9 @@
|
|
|
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
|
export { default } from './App';
|
|
@@ -1,7 +1,24 @@
|
|
|
1
1
|
import type { IModulesConfigurator } from '@equinor/fusion-framework-module';
|
|
2
2
|
import type { AppConfigurator } from './AppConfigurator';
|
|
3
3
|
/**
|
|
4
|
-
*
|
|
5
|
-
*
|
|
4
|
+
* Registers the app module with a framework configurator.
|
|
5
|
+
*
|
|
6
|
+
* Call this during framework setup to enable application loading, manifest fetching,
|
|
7
|
+
* configuration resolution, and per-user settings management.
|
|
8
|
+
*
|
|
9
|
+
* @param configurator - The framework modules configurator to register the app module with.
|
|
10
|
+
* @param callback - Optional callback to customize the {@link AppConfigurator} before initialization
|
|
11
|
+
* (e.g., override the HTTP client or set a custom asset URI).
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* ```ts
|
|
15
|
+
* import { enableAppModule } from '@equinor/fusion-framework-module-app';
|
|
16
|
+
*
|
|
17
|
+
* export const configure = async (configurator: FrameworkConfigurator) => {
|
|
18
|
+
* enableAppModule(configurator, (builder) => {
|
|
19
|
+
* builder.setAssetUri('/custom-proxy');
|
|
20
|
+
* });
|
|
21
|
+
* };
|
|
22
|
+
* ```
|
|
6
23
|
*/
|
|
7
24
|
export declare const enableAppModule: (configurator: IModulesConfigurator<any, any>, callback?: (builder: AppConfigurator) => void | Promise<void>) => void;
|
package/dist/types/errors.d.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
|
* Represents an error that occurs when loading an application manifest.
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,3 +1,21 @@
|
|
|
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
|
+
*/
|
|
1
19
|
export { AppModuleConfig, AppConfigurator, IAppConfigurator, type AppModuleConfig as IAppModuleConfig, } from './AppConfigurator';
|
|
2
20
|
export { AppClient, type IAppClient } from './AppClient';
|
|
3
21
|
export { AppModuleProvider } from './AppModuleProvider';
|
package/dist/types/module.d.ts
CHANGED
|
@@ -2,7 +2,13 @@ import type { Module } from '@equinor/fusion-framework-module';
|
|
|
2
2
|
import type { ModuleDeps } from './types';
|
|
3
3
|
import { AppConfigurator } from './AppConfigurator';
|
|
4
4
|
import { AppModuleProvider } from './AppModuleProvider';
|
|
5
|
+
/** Module key used to register and look up the app module in the framework. */
|
|
5
6
|
export declare const moduleKey = "app";
|
|
7
|
+
/**
|
|
8
|
+
* Type alias for the app module definition, binding the module key,
|
|
9
|
+
* provider type ({@link AppModuleProvider}), configurator type
|
|
10
|
+
* ({@link AppConfigurator}), and required module dependencies.
|
|
11
|
+
*/
|
|
6
12
|
export type AppModule = Module<typeof moduleKey, AppModuleProvider, AppConfigurator, ModuleDeps>;
|
|
7
13
|
/**
|
|
8
14
|
* Represents a module for handling applications.
|