@equinor/fusion-framework-module-app 5.2.1 → 5.2.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.
- package/CHANGELOG.md +23 -0
- package/LICENSE +21 -0
- package/dist/esm/AppConfigBuilder.js.map +1 -1
- package/dist/esm/AppConfigurator.js.map +1 -1
- package/dist/esm/errors.js.map +1 -1
- package/dist/esm/version.js +2 -0
- package/dist/esm/version.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/types/AppConfigurator.d.ts +4 -4
- package/dist/types/app/flows.d.ts +1 -1
- package/dist/types/types.d.ts +1 -1
- package/dist/types/version.d.ts +1 -0
- package/package.json +48 -46
- package/src/AppConfigBuilder.ts +8 -5
- package/src/AppConfigurator.ts +16 -13
- package/src/AppModuleProvider.ts +10 -10
- package/src/app/App.ts +21 -21
- package/src/app/actions.ts +4 -4
- package/src/app/create-reducer.ts +1 -1
- package/src/app/create-state.ts +1 -1
- package/src/app/flows.ts +11 -11
- package/src/enable-app-module.ts +1 -1
- package/src/errors.ts +19 -7
- package/src/types.ts +1 -1
- package/src/version.ts +2 -0
- package/tsconfig.json +1 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { ModuleInitializerArgs } from '@equinor/fusion-framework-module';
|
|
2
|
-
import { HttpModule, IHttpClient } from '@equinor/fusion-framework-module-http';
|
|
3
|
-
import { ServiceDiscoveryModule } from '@equinor/fusion-framework-module-service-discovery';
|
|
4
|
-
import { QueryCtorOptions } from '@equinor/fusion-query';
|
|
1
|
+
import type { ModuleInitializerArgs } from '@equinor/fusion-framework-module';
|
|
2
|
+
import type { HttpModule, IHttpClient } from '@equinor/fusion-framework-module-http';
|
|
3
|
+
import type { ServiceDiscoveryModule } from '@equinor/fusion-framework-module-service-discovery';
|
|
4
|
+
import type { QueryCtorOptions } from '@equinor/fusion-query';
|
|
5
5
|
import { AppConfigBuilderCallback } from './AppConfigBuilder';
|
|
6
6
|
import type { AppConfig, AppManifest } from './types';
|
|
7
7
|
export interface AppModuleConfig {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { Flow } from '@equinor/fusion-observable';
|
|
2
2
|
import type { AppModuleProvider } from '../AppModuleProvider';
|
|
3
3
|
import type { Actions } from './actions';
|
|
4
|
-
import { AppBundleState } from './types';
|
|
4
|
+
import type { AppBundleState } from './types';
|
|
5
5
|
export declare const handleFetchManifest: (provider: AppModuleProvider) => Flow<Actions, AppBundleState>;
|
|
6
6
|
export declare const handleFetchConfig: (provider: AppModuleProvider) => Flow<Actions, AppBundleState>;
|
|
7
7
|
export declare const handleImportApplication: () => Flow<Actions, AppBundleState>;
|
package/dist/types/types.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { AnyModule, CombinedModules, ModulesInstance } from '@equinor/fusion-framework-module';
|
|
2
2
|
import type { EventModule } from '@equinor/fusion-framework-module-event';
|
|
3
3
|
import type { HttpModule } from '@equinor/fusion-framework-module-http';
|
|
4
|
-
import { MsalModule } from '@equinor/fusion-framework-module-msal';
|
|
4
|
+
import type { MsalModule } from '@equinor/fusion-framework-module-msal';
|
|
5
5
|
import type { ServiceDiscoveryModule } from '@equinor/fusion-framework-module-service-discovery';
|
|
6
6
|
import IApp from './app';
|
|
7
7
|
type Fusion = any;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const version = "5.2.3";
|
package/package.json
CHANGED
|
@@ -1,48 +1,50 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
}
|
|
21
|
-
},
|
|
22
|
-
"scripts": {
|
|
23
|
-
"build": "tsc -b",
|
|
24
|
-
"prepack": "yarn build"
|
|
25
|
-
},
|
|
26
|
-
"keywords": [],
|
|
27
|
-
"author": "",
|
|
28
|
-
"license": "ISC",
|
|
29
|
-
"publishConfig": {
|
|
30
|
-
"access": "public"
|
|
31
|
-
},
|
|
32
|
-
"repository": {
|
|
33
|
-
"type": "git",
|
|
34
|
-
"url": "git+https://github.com/equinor/fusion-framework.git",
|
|
35
|
-
"directory": "packages/modules/app"
|
|
36
|
-
},
|
|
37
|
-
"dependencies": {
|
|
38
|
-
"@equinor/fusion-query": "^3.0.2",
|
|
39
|
-
"rxjs": "^7.5.7"
|
|
40
|
-
},
|
|
41
|
-
"devDependencies": {
|
|
42
|
-
"@equinor/fusion-framework-module": "^4.2.1",
|
|
43
|
-
"@equinor/fusion-framework-module-event": "^4.0.2",
|
|
44
|
-
"@equinor/fusion-framework-module-http": "^5.0.4",
|
|
45
|
-
"@equinor/fusion-framework-module-service-discovery": "^7.0.5",
|
|
46
|
-
"typescript": "^5.1.3"
|
|
2
|
+
"name": "@equinor/fusion-framework-module-app",
|
|
3
|
+
"version": "5.2.3",
|
|
4
|
+
"description": "",
|
|
5
|
+
"main": "dist/esm/index.js",
|
|
6
|
+
"exports": {
|
|
7
|
+
".": "./dist/esm/index.js",
|
|
8
|
+
"./errors.js": "./dist/esm/errors.js",
|
|
9
|
+
"./app": "./dist/esm/app/index.js"
|
|
10
|
+
},
|
|
11
|
+
"types": "dist/types/index.d.ts",
|
|
12
|
+
"typesVersions": {
|
|
13
|
+
"*": {
|
|
14
|
+
"errors.js": [
|
|
15
|
+
"dist/types/errors.d.ts"
|
|
16
|
+
],
|
|
17
|
+
"app": [
|
|
18
|
+
"dist/types/app/index.d.ts"
|
|
19
|
+
]
|
|
47
20
|
}
|
|
48
|
-
}
|
|
21
|
+
},
|
|
22
|
+
"keywords": [],
|
|
23
|
+
"author": "",
|
|
24
|
+
"license": "ISC",
|
|
25
|
+
"publishConfig": {
|
|
26
|
+
"access": "public"
|
|
27
|
+
},
|
|
28
|
+
"repository": {
|
|
29
|
+
"type": "git",
|
|
30
|
+
"url": "git+https://github.com/equinor/fusion-framework.git",
|
|
31
|
+
"directory": "packages/modules/app"
|
|
32
|
+
},
|
|
33
|
+
"dependencies": {
|
|
34
|
+
"immer": "^9.0.16",
|
|
35
|
+
"rxjs": "^7.8.1",
|
|
36
|
+
"@equinor/fusion-observable": "^8.1.0",
|
|
37
|
+
"@equinor/fusion-query": "^3.0.6"
|
|
38
|
+
},
|
|
39
|
+
"devDependencies": {
|
|
40
|
+
"typescript": "^5.1.3",
|
|
41
|
+
"@equinor/fusion-framework-module": "^4.2.3",
|
|
42
|
+
"@equinor/fusion-framework-module-event": "^4.0.4",
|
|
43
|
+
"@equinor/fusion-framework-module-http": "^5.0.5",
|
|
44
|
+
"@equinor/fusion-framework-module-msal": "^3.0.5",
|
|
45
|
+
"@equinor/fusion-framework-module-service-discovery": "^7.0.7"
|
|
46
|
+
},
|
|
47
|
+
"scripts": {
|
|
48
|
+
"build": "tsc -b"
|
|
49
|
+
}
|
|
50
|
+
}
|
package/src/AppConfigBuilder.ts
CHANGED
|
@@ -7,7 +7,7 @@ import type { AppConfig, AppManifest, ModuleDeps } from './types';
|
|
|
7
7
|
|
|
8
8
|
export type AppConfigBuilderCallback = (
|
|
9
9
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
10
|
-
builder: AppConfigBuilder<ModuleInitializerArgs<IAppConfigurator, any
|
|
10
|
+
builder: AppConfigBuilder<ModuleInitializerArgs<IAppConfigurator, any>>,
|
|
11
11
|
) => void | Promise<void>;
|
|
12
12
|
|
|
13
13
|
export class AppConfigBuilder<
|
|
@@ -15,15 +15,18 @@ export class AppConfigBuilder<
|
|
|
15
15
|
TInit extends ModuleInitializerArgs<IAppConfigurator, any> = ModuleInitializerArgs<
|
|
16
16
|
IAppConfigurator,
|
|
17
17
|
ModuleDeps
|
|
18
|
-
|
|
18
|
+
>,
|
|
19
19
|
> {
|
|
20
20
|
#init: TInit;
|
|
21
|
-
constructor(
|
|
21
|
+
constructor(
|
|
22
|
+
init: TInit,
|
|
23
|
+
public config: Partial<AppModuleConfig> = {},
|
|
24
|
+
) {
|
|
22
25
|
this.#init = init;
|
|
23
26
|
}
|
|
24
27
|
|
|
25
28
|
requireInstance<TKey extends string = Extract<keyof Modules, string>>(
|
|
26
|
-
module: TKey
|
|
29
|
+
module: TKey,
|
|
27
30
|
): Promise<ModuleType<Modules[TKey]>>;
|
|
28
31
|
|
|
29
32
|
requireInstance<T>(module: string): Promise<T>;
|
|
@@ -43,7 +46,7 @@ export class AppConfigBuilder<
|
|
|
43
46
|
| QueryFn<AppConfig, { appKey: string }>
|
|
44
47
|
| QueryCtorOptions<AppConfig, { appKey: string; tag?: string }>;
|
|
45
48
|
},
|
|
46
|
-
expire = 1 * 60 * 1000
|
|
49
|
+
expire = 1 * 60 * 1000,
|
|
47
50
|
) {
|
|
48
51
|
client;
|
|
49
52
|
expire;
|
package/src/AppConfigurator.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { ModuleInitializerArgs } from '@equinor/fusion-framework-module';
|
|
2
|
-
import { HttpModule, IHttpClient } from '@equinor/fusion-framework-module-http';
|
|
3
|
-
import { ServiceDiscoveryModule } from '@equinor/fusion-framework-module-service-discovery';
|
|
4
|
-
import { QueryCtorOptions } from '@equinor/fusion-query';
|
|
1
|
+
import type { ModuleInitializerArgs } from '@equinor/fusion-framework-module';
|
|
2
|
+
import type { HttpModule, IHttpClient } from '@equinor/fusion-framework-module-http';
|
|
3
|
+
import type { ServiceDiscoveryModule } from '@equinor/fusion-framework-module-service-discovery';
|
|
4
|
+
import type { QueryCtorOptions } from '@equinor/fusion-query';
|
|
5
5
|
|
|
6
6
|
import { AppConfigBuilder, AppConfigBuilderCallback } from './AppConfigBuilder';
|
|
7
7
|
|
|
@@ -34,7 +34,7 @@ export class AppConfigurator implements IAppConfigurator {
|
|
|
34
34
|
* WARNING: this function will be remove in future
|
|
35
35
|
*/
|
|
36
36
|
protected async _createHttpClient(
|
|
37
|
-
init: ModuleInitializerArgs<IAppConfigurator, [HttpModule, ServiceDiscoveryModule]
|
|
37
|
+
init: ModuleInitializerArgs<IAppConfigurator, [HttpModule, ServiceDiscoveryModule]>,
|
|
38
38
|
): Promise<IHttpClient> {
|
|
39
39
|
const http = await init.requireInstance('http');
|
|
40
40
|
/** check if the http provider has configure a client */
|
|
@@ -55,14 +55,17 @@ export class AppConfigurator implements IAppConfigurator {
|
|
|
55
55
|
}
|
|
56
56
|
|
|
57
57
|
public async createConfig(
|
|
58
|
-
init: ModuleInitializerArgs<IAppConfigurator, [HttpModule, ServiceDiscoveryModule]
|
|
58
|
+
init: ModuleInitializerArgs<IAppConfigurator, [HttpModule, ServiceDiscoveryModule]>,
|
|
59
59
|
): Promise<AppModuleConfig> {
|
|
60
|
-
const config = await this.#configBuilders.reduce(
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
60
|
+
const config = await this.#configBuilders.reduce(
|
|
61
|
+
async (cur, cb) => {
|
|
62
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
63
|
+
const builder = new AppConfigBuilder(init, await cur);
|
|
64
|
+
await Promise.resolve(cb(builder));
|
|
65
|
+
return Object.assign(cur, builder.config);
|
|
66
|
+
},
|
|
67
|
+
Promise.resolve({} as Partial<AppModuleConfig>),
|
|
68
|
+
);
|
|
66
69
|
|
|
67
70
|
// TODO - make less lazy
|
|
68
71
|
config.client ??= await (async (): Promise<AppModuleConfig['client']> => {
|
|
@@ -87,7 +90,7 @@ export class AppConfigurator implements IAppConfigurator {
|
|
|
87
90
|
client: {
|
|
88
91
|
fn: ({ appKey, tag }) =>
|
|
89
92
|
httpClient.json$(
|
|
90
|
-
`/api/apps/${appKey}/config${tag ? `?tag=${tag}` : ''}
|
|
93
|
+
`/api/apps/${appKey}/config${tag ? `?tag=${tag}` : ''}`,
|
|
91
94
|
),
|
|
92
95
|
},
|
|
93
96
|
key: (args) => JSON.stringify(args),
|
package/src/AppModuleProvider.ts
CHANGED
|
@@ -53,7 +53,7 @@ export class AppModuleProvider {
|
|
|
53
53
|
return prev.appKey === next.appKey;
|
|
54
54
|
}
|
|
55
55
|
return prev === next;
|
|
56
|
-
})
|
|
56
|
+
}),
|
|
57
57
|
);
|
|
58
58
|
}
|
|
59
59
|
|
|
@@ -75,14 +75,14 @@ export class AppModuleProvider {
|
|
|
75
75
|
this.current$
|
|
76
76
|
.pipe(
|
|
77
77
|
pairwise(),
|
|
78
|
-
takeWhile(() => !!event)
|
|
78
|
+
takeWhile(() => !!event),
|
|
79
79
|
)
|
|
80
80
|
.subscribe(([previous, next]) => {
|
|
81
81
|
event?.dispatchEvent('onCurrentAppChanged', {
|
|
82
82
|
source: this,
|
|
83
83
|
detail: { previous, next },
|
|
84
84
|
});
|
|
85
|
-
})
|
|
85
|
+
}),
|
|
86
86
|
);
|
|
87
87
|
|
|
88
88
|
this.#subscription.add(
|
|
@@ -90,9 +90,9 @@ export class AppModuleProvider {
|
|
|
90
90
|
.pipe(
|
|
91
91
|
pairwise(),
|
|
92
92
|
map(([previous]) => previous),
|
|
93
|
-
filterEmpty()
|
|
93
|
+
filterEmpty(),
|
|
94
94
|
)
|
|
95
|
-
.subscribe((app) => app.dispose())
|
|
95
|
+
.subscribe((app) => app.dispose()),
|
|
96
96
|
);
|
|
97
97
|
}
|
|
98
98
|
|
|
@@ -113,8 +113,8 @@ export class AppModuleProvider {
|
|
|
113
113
|
throw AppManifestError.fromHttpResponse(cause.response, { cause });
|
|
114
114
|
}
|
|
115
115
|
throw new AppManifestError('unknown', 'failed to load manifest', { cause });
|
|
116
|
-
})
|
|
117
|
-
)
|
|
116
|
+
}),
|
|
117
|
+
),
|
|
118
118
|
);
|
|
119
119
|
}
|
|
120
120
|
|
|
@@ -131,7 +131,7 @@ export class AppModuleProvider {
|
|
|
131
131
|
*/
|
|
132
132
|
public getAppConfig<TType = unknown>(
|
|
133
133
|
appKey: string,
|
|
134
|
-
tag?: string
|
|
134
|
+
tag?: string,
|
|
135
135
|
): Observable<AppConfig<TType>> {
|
|
136
136
|
return Query.extractQueryValue(
|
|
137
137
|
this.#configClient.query({ appKey, tag }).pipe(
|
|
@@ -145,8 +145,8 @@ export class AppModuleProvider {
|
|
|
145
145
|
throw AppConfigError.fromHttpResponse(cause.response, { cause });
|
|
146
146
|
}
|
|
147
147
|
throw new AppConfigError('unknown', 'failed to load config', { cause });
|
|
148
|
-
})
|
|
149
|
-
)
|
|
148
|
+
}),
|
|
149
|
+
),
|
|
150
150
|
);
|
|
151
151
|
}
|
|
152
152
|
|
package/src/app/App.ts
CHANGED
|
@@ -73,28 +73,28 @@ export class App<TEnv = any, TModules extends Array<AnyModule> | unknown = unkno
|
|
|
73
73
|
get manifest$(): Observable<AppManifest> {
|
|
74
74
|
return this.#state.pipe(
|
|
75
75
|
map(({ manifest }) => manifest),
|
|
76
|
-
filterEmpty()
|
|
76
|
+
filterEmpty(),
|
|
77
77
|
);
|
|
78
78
|
}
|
|
79
79
|
|
|
80
80
|
get config$(): Observable<AppConfig<TEnv>> {
|
|
81
81
|
return this.#state.pipe(
|
|
82
82
|
map(({ config }) => config),
|
|
83
|
-
filterEmpty()
|
|
83
|
+
filterEmpty(),
|
|
84
84
|
);
|
|
85
85
|
}
|
|
86
86
|
|
|
87
87
|
get modules$(): Observable<AppScriptModule> {
|
|
88
88
|
return this.#state.pipe(
|
|
89
89
|
map(({ modules }) => modules),
|
|
90
|
-
filterEmpty()
|
|
90
|
+
filterEmpty(),
|
|
91
91
|
);
|
|
92
92
|
}
|
|
93
93
|
|
|
94
94
|
get instance$(): Observable<AppModulesInstance<TModules>> {
|
|
95
95
|
return this.#state.pipe(
|
|
96
96
|
map(({ instance }) => instance as AppModulesInstance<TModules>),
|
|
97
|
-
filterEmpty()
|
|
97
|
+
filterEmpty(),
|
|
98
98
|
);
|
|
99
99
|
}
|
|
100
100
|
|
|
@@ -134,7 +134,7 @@ export class App<TEnv = any, TModules extends Array<AnyModule> | unknown = unkno
|
|
|
134
134
|
args: {
|
|
135
135
|
provider: AppModuleProvider;
|
|
136
136
|
event?: ModuleType<EventModule>;
|
|
137
|
-
}
|
|
137
|
+
},
|
|
138
138
|
) {
|
|
139
139
|
this.#state = createState(value, args.provider);
|
|
140
140
|
|
|
@@ -153,7 +153,7 @@ export class App<TEnv = any, TModules extends Array<AnyModule> | unknown = unkno
|
|
|
153
153
|
if (e.detail.appKey === appKey) {
|
|
154
154
|
this.#state.next(actions.setInstance(e.detail.modules));
|
|
155
155
|
}
|
|
156
|
-
})
|
|
156
|
+
}),
|
|
157
157
|
);
|
|
158
158
|
}
|
|
159
159
|
|
|
@@ -253,7 +253,7 @@ export class App<TEnv = any, TModules extends Array<AnyModule> | unknown = unkno
|
|
|
253
253
|
this.#state.next(actions.initialize.success());
|
|
254
254
|
observer.complete();
|
|
255
255
|
},
|
|
256
|
-
})
|
|
256
|
+
}),
|
|
257
257
|
);
|
|
258
258
|
});
|
|
259
259
|
}
|
|
@@ -286,22 +286,22 @@ export class App<TEnv = any, TModules extends Array<AnyModule> | unknown = unkno
|
|
|
286
286
|
subscriber.add(
|
|
287
287
|
this.#state.addEffect('set_config', ({ payload }) => {
|
|
288
288
|
subscriber.next(payload);
|
|
289
|
-
})
|
|
289
|
+
}),
|
|
290
290
|
);
|
|
291
291
|
subscriber.add(
|
|
292
292
|
this.#state.addEffect('fetch_config::success', ({ payload }) => {
|
|
293
293
|
subscriber.next(payload);
|
|
294
294
|
subscriber.complete();
|
|
295
|
-
})
|
|
295
|
+
}),
|
|
296
296
|
);
|
|
297
297
|
subscriber.add(
|
|
298
298
|
this.#state.addEffect('fetch_config::failure', ({ payload }) => {
|
|
299
299
|
subscriber.error(
|
|
300
300
|
Error('failed to load application config', {
|
|
301
301
|
cause: payload,
|
|
302
|
-
})
|
|
302
|
+
}),
|
|
303
303
|
);
|
|
304
|
-
})
|
|
304
|
+
}),
|
|
305
305
|
);
|
|
306
306
|
|
|
307
307
|
this.loadConfig();
|
|
@@ -324,22 +324,22 @@ export class App<TEnv = any, TModules extends Array<AnyModule> | unknown = unkno
|
|
|
324
324
|
subscriber.add(
|
|
325
325
|
this.#state.addEffect('set_manifest', ({ payload }) => {
|
|
326
326
|
subscriber.next(payload);
|
|
327
|
-
})
|
|
327
|
+
}),
|
|
328
328
|
);
|
|
329
329
|
subscriber.add(
|
|
330
330
|
this.#state.addEffect('fetch_manifest::success', ({ payload }) => {
|
|
331
331
|
subscriber.next(payload);
|
|
332
332
|
subscriber.complete();
|
|
333
|
-
})
|
|
333
|
+
}),
|
|
334
334
|
);
|
|
335
335
|
subscriber.add(
|
|
336
336
|
this.#state.addEffect('fetch_manifest::failure', ({ payload }) => {
|
|
337
337
|
subscriber.error(
|
|
338
338
|
Error('failed to load application manifest', {
|
|
339
339
|
cause: payload,
|
|
340
|
-
})
|
|
340
|
+
}),
|
|
341
341
|
);
|
|
342
|
-
})
|
|
342
|
+
}),
|
|
343
343
|
);
|
|
344
344
|
|
|
345
345
|
this.loadManifest();
|
|
@@ -362,28 +362,28 @@ export class App<TEnv = any, TModules extends Array<AnyModule> | unknown = unkno
|
|
|
362
362
|
subscriber.add(
|
|
363
363
|
this.#state.addEffect('set_module', ({ payload }) => {
|
|
364
364
|
subscriber.next(payload);
|
|
365
|
-
})
|
|
365
|
+
}),
|
|
366
366
|
);
|
|
367
367
|
subscriber.add(
|
|
368
368
|
this.#state.addEffect('import_app::success', ({ payload }) => {
|
|
369
369
|
subscriber.next(payload);
|
|
370
370
|
subscriber.complete();
|
|
371
|
-
})
|
|
371
|
+
}),
|
|
372
372
|
);
|
|
373
373
|
subscriber.add(
|
|
374
374
|
this.#state.addEffect('import_app::failure', ({ payload }) => {
|
|
375
375
|
subscriber.error(
|
|
376
376
|
Error('failed to load application modules from script', {
|
|
377
377
|
cause: payload,
|
|
378
|
-
})
|
|
378
|
+
}),
|
|
379
379
|
);
|
|
380
|
-
})
|
|
380
|
+
}),
|
|
381
381
|
);
|
|
382
382
|
|
|
383
383
|
subscriber.add(
|
|
384
384
|
this.getManifest().subscribe((manifest) =>
|
|
385
|
-
of(this.#state.next(actions.importApp(manifest.entry)))
|
|
386
|
-
)
|
|
385
|
+
of(this.#state.next(actions.importApp(manifest.entry))),
|
|
386
|
+
),
|
|
387
387
|
);
|
|
388
388
|
});
|
|
389
389
|
}
|
package/src/app/actions.ts
CHANGED
|
@@ -21,7 +21,7 @@ const createActions = () => ({
|
|
|
21
21
|
'fetch_manifest',
|
|
22
22
|
(key: string, update?: boolean) => ({ payload: key, meta: { update } }),
|
|
23
23
|
(manifest: AppManifest) => ({ payload: manifest }),
|
|
24
|
-
(error: unknown) => ({ payload: error })
|
|
24
|
+
(error: unknown) => ({ payload: error }),
|
|
25
25
|
),
|
|
26
26
|
/** Config loading */
|
|
27
27
|
setConfig: createAction('set_config', (config: AppConfig) => ({ payload: config })),
|
|
@@ -29,7 +29,7 @@ const createActions = () => ({
|
|
|
29
29
|
'fetch_config',
|
|
30
30
|
(key: string) => ({ payload: key }),
|
|
31
31
|
(config: AppConfig) => ({ payload: config }),
|
|
32
|
-
(error: unknown) => ({ payload: error })
|
|
32
|
+
(error: unknown) => ({ payload: error }),
|
|
33
33
|
),
|
|
34
34
|
/** App loading */
|
|
35
35
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
@@ -38,7 +38,7 @@ const createActions = () => ({
|
|
|
38
38
|
'import_app',
|
|
39
39
|
(entrypoint: string) => ({ payload: entrypoint }),
|
|
40
40
|
(module: AppScriptModule) => ({ payload: module }),
|
|
41
|
-
(error: unknown) => ({ payload: error })
|
|
41
|
+
(error: unknown) => ({ payload: error }),
|
|
42
42
|
),
|
|
43
43
|
|
|
44
44
|
// App Instance
|
|
@@ -50,7 +50,7 @@ const createActions = () => ({
|
|
|
50
50
|
'initialize_app',
|
|
51
51
|
() => ({ payload: null }),
|
|
52
52
|
() => ({ payload: null }),
|
|
53
|
-
(error: unknown) => ({ payload: error })
|
|
53
|
+
(error: unknown) => ({ payload: error }),
|
|
54
54
|
),
|
|
55
55
|
});
|
|
56
56
|
|
package/src/app/create-state.ts
CHANGED
|
@@ -10,7 +10,7 @@ import type { AppModuleProvider } from '../AppModuleProvider';
|
|
|
10
10
|
|
|
11
11
|
export const createState = (
|
|
12
12
|
value: AppBundleStateInitial,
|
|
13
|
-
provider: AppModuleProvider
|
|
13
|
+
provider: AppModuleProvider,
|
|
14
14
|
): FlowSubject<AppBundleState, Actions> => {
|
|
15
15
|
const reducer = createReducer(value);
|
|
16
16
|
const state = new FlowSubject<AppBundleState, Actions>(reducer);
|
package/src/app/flows.ts
CHANGED
|
@@ -6,7 +6,7 @@ import { actions } from './actions';
|
|
|
6
6
|
import type { Flow } from '@equinor/fusion-observable';
|
|
7
7
|
import type { AppModuleProvider } from '../AppModuleProvider';
|
|
8
8
|
import type { Actions } from './actions';
|
|
9
|
-
import { AppBundleState } from './types';
|
|
9
|
+
import type { AppBundleState } from './types';
|
|
10
10
|
|
|
11
11
|
export const handleFetchManifest =
|
|
12
12
|
(provider: AppModuleProvider): Flow<Actions, AppBundleState> =>
|
|
@@ -16,20 +16,20 @@ export const handleFetchManifest =
|
|
|
16
16
|
switchMap(({ payload: appKey, meta: { update } }) => {
|
|
17
17
|
const fetch$ = from(provider.getAppManifest(appKey)).pipe(
|
|
18
18
|
filter((x) => !!x),
|
|
19
|
-
map((manifest) => actions.setManifest(manifest, update))
|
|
19
|
+
map((manifest) => actions.setManifest(manifest, update)),
|
|
20
20
|
);
|
|
21
21
|
return merge(
|
|
22
22
|
fetch$,
|
|
23
23
|
fetch$.pipe(
|
|
24
24
|
last(),
|
|
25
|
-
map(({ payload }) => actions.fetchManifest.success(payload))
|
|
26
|
-
)
|
|
25
|
+
map(({ payload }) => actions.fetchManifest.success(payload)),
|
|
26
|
+
),
|
|
27
27
|
).pipe(
|
|
28
28
|
catchError((err) => {
|
|
29
29
|
return of(actions.fetchManifest.failure(err));
|
|
30
|
-
})
|
|
30
|
+
}),
|
|
31
31
|
);
|
|
32
|
-
})
|
|
32
|
+
}),
|
|
33
33
|
);
|
|
34
34
|
|
|
35
35
|
export const handleFetchConfig =
|
|
@@ -43,10 +43,10 @@ export const handleFetchConfig =
|
|
|
43
43
|
fetch$,
|
|
44
44
|
fetch$.pipe(
|
|
45
45
|
last(),
|
|
46
|
-
map(({ payload }) => actions.fetchConfig.success(payload))
|
|
47
|
-
)
|
|
46
|
+
map(({ payload }) => actions.fetchConfig.success(payload)),
|
|
47
|
+
),
|
|
48
48
|
).pipe(catchError((err) => of(actions.fetchConfig.failure(err))));
|
|
49
|
-
})
|
|
49
|
+
}),
|
|
50
50
|
);
|
|
51
51
|
|
|
52
52
|
export const handleImportApplication = (): Flow<Actions, AppBundleState> => (action$) =>
|
|
@@ -55,7 +55,7 @@ export const handleImportApplication = (): Flow<Actions, AppBundleState> => (act
|
|
|
55
55
|
switchMap(({ payload }) => {
|
|
56
56
|
return from(import(payload)).pipe(
|
|
57
57
|
map(actions.importApp.success),
|
|
58
|
-
catchError((err) => of(actions.importApp.failure(err)))
|
|
58
|
+
catchError((err) => of(actions.importApp.failure(err))),
|
|
59
59
|
);
|
|
60
|
-
})
|
|
60
|
+
}),
|
|
61
61
|
);
|
package/src/enable-app-module.ts
CHANGED
|
@@ -10,7 +10,7 @@ import { module } from './module';
|
|
|
10
10
|
export const enableAppModule = (
|
|
11
11
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
12
12
|
configurator: IModulesConfigurator<any, any>,
|
|
13
|
-
builder?: AppConfigBuilderCallback
|
|
13
|
+
builder?: AppConfigBuilderCallback,
|
|
14
14
|
): void => {
|
|
15
15
|
configurator.addConfig({
|
|
16
16
|
module,
|
package/src/errors.ts
CHANGED
|
@@ -7,7 +7,7 @@ export class AppManifestError extends Error {
|
|
|
7
7
|
return new AppManifestError(
|
|
8
8
|
'unauthorized',
|
|
9
9
|
'failed to load application manifest, request not authorized',
|
|
10
|
-
options
|
|
10
|
+
options,
|
|
11
11
|
);
|
|
12
12
|
case 404:
|
|
13
13
|
return new AppManifestError('not_found', 'application manifest not found', options);
|
|
@@ -15,10 +15,14 @@ export class AppManifestError extends Error {
|
|
|
15
15
|
return new AppManifestError(
|
|
16
16
|
'unknown',
|
|
17
17
|
`failed to load application manifest, status code ${response.status}`,
|
|
18
|
-
options
|
|
18
|
+
options,
|
|
19
19
|
);
|
|
20
20
|
}
|
|
21
|
-
constructor(
|
|
21
|
+
constructor(
|
|
22
|
+
public readonly type: AppErrorType,
|
|
23
|
+
message?: string,
|
|
24
|
+
options?: ErrorOptions,
|
|
25
|
+
) {
|
|
22
26
|
super(message, options);
|
|
23
27
|
}
|
|
24
28
|
}
|
|
@@ -30,7 +34,7 @@ export class AppConfigError extends Error {
|
|
|
30
34
|
return new AppConfigError(
|
|
31
35
|
'unauthorized',
|
|
32
36
|
'failed to load application config, request not authorized',
|
|
33
|
-
options
|
|
37
|
+
options,
|
|
34
38
|
);
|
|
35
39
|
case 404:
|
|
36
40
|
return new AppConfigError('not_found', 'application config not found', options);
|
|
@@ -38,16 +42,24 @@ export class AppConfigError extends Error {
|
|
|
38
42
|
return new AppConfigError(
|
|
39
43
|
'unknown',
|
|
40
44
|
`failed to load application config, status code ${response.status}`,
|
|
41
|
-
options
|
|
45
|
+
options,
|
|
42
46
|
);
|
|
43
47
|
}
|
|
44
|
-
constructor(
|
|
48
|
+
constructor(
|
|
49
|
+
public readonly type: AppErrorType,
|
|
50
|
+
message?: string,
|
|
51
|
+
options?: ErrorOptions,
|
|
52
|
+
) {
|
|
45
53
|
super(message, options);
|
|
46
54
|
}
|
|
47
55
|
}
|
|
48
56
|
|
|
49
57
|
export class AppScriptModuleError extends Error {
|
|
50
|
-
constructor(
|
|
58
|
+
constructor(
|
|
59
|
+
public readonly type: AppErrorType,
|
|
60
|
+
message?: string,
|
|
61
|
+
options?: ErrorOptions,
|
|
62
|
+
) {
|
|
51
63
|
super(message, options);
|
|
52
64
|
}
|
|
53
65
|
}
|
package/src/types.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { AnyModule, CombinedModules, ModulesInstance } from '@equinor/fusion-framework-module';
|
|
2
2
|
import type { EventModule } from '@equinor/fusion-framework-module-event';
|
|
3
3
|
import type { HttpModule } from '@equinor/fusion-framework-module-http';
|
|
4
|
-
import { MsalModule } from '@equinor/fusion-framework-module-msal';
|
|
4
|
+
import type { MsalModule } from '@equinor/fusion-framework-module-msal';
|
|
5
5
|
import type { ServiceDiscoveryModule } from '@equinor/fusion-framework-module-service-discovery';
|
|
6
6
|
import IApp from './app';
|
|
7
7
|
|
package/src/version.ts
ADDED