@equinor/fusion-framework-module-app 8.0.2 → 8.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.
- package/CHANGELOG.md +13 -0
- package/dist/esm/AppClient.js +75 -8
- package/dist/esm/AppClient.js.map +1 -1
- package/dist/esm/AppConfig.js +9 -1
- package/dist/esm/AppConfig.js.map +1 -1
- package/dist/esm/{AppClient.Selectors.js → AppConfigSelector.js} +1 -1
- package/dist/esm/AppConfigSelector.js.map +1 -0
- package/dist/esm/AppConfigurator.js +28 -2
- package/dist/esm/AppConfigurator.js.map +1 -1
- package/dist/esm/AppModuleProvider.js +16 -0
- package/dist/esm/AppModuleProvider.js.map +1 -1
- package/dist/esm/app/App.js +82 -24
- package/dist/esm/app/App.js.map +1 -1
- package/dist/esm/app/actions.js +2 -2
- package/dist/esm/app/actions.js.map +1 -1
- package/dist/esm/app/create-reducer.js +2 -1
- package/dist/esm/app/create-reducer.js.map +1 -1
- package/dist/esm/app/filter-empty.js +11 -0
- package/dist/esm/app/filter-empty.js.map +1 -0
- package/dist/esm/app/flows/handle-fetch-config.js +30 -0
- package/dist/esm/app/flows/handle-fetch-config.js.map +1 -0
- package/dist/esm/app/flows/handle-fetch-manifest.js +30 -0
- package/dist/esm/app/flows/handle-fetch-manifest.js.map +1 -0
- package/dist/esm/app/flows/handle-fetch-settings.js +30 -0
- package/dist/esm/app/flows/handle-fetch-settings.js.map +1 -0
- package/dist/esm/app/flows/handle-import-application.js +23 -0
- package/dist/esm/app/flows/handle-import-application.js.map +1 -0
- package/dist/esm/app/flows/handle-update-settings.js +22 -0
- package/dist/esm/app/flows/handle-update-settings.js.map +1 -0
- package/dist/esm/app/flows/index.js +6 -0
- package/dist/esm/app/flows/index.js.map +1 -0
- package/dist/esm/enable-app-module.js +2 -1
- package/dist/esm/enable-app-module.js.map +1 -1
- package/dist/esm/errors/AppBuildError.js +35 -0
- package/dist/esm/errors/AppBuildError.js.map +1 -0
- package/dist/esm/errors/AppConfigError.js +35 -0
- package/dist/esm/errors/AppConfigError.js.map +1 -0
- package/dist/esm/errors/AppManifestError.js +35 -0
- package/dist/esm/errors/AppManifestError.js.map +1 -0
- package/dist/esm/errors/AppScriptModuleError.js +17 -0
- package/dist/esm/errors/AppScriptModuleError.js.map +1 -0
- package/dist/esm/errors/AppSettingsError.js +35 -0
- package/dist/esm/errors/AppSettingsError.js.map +1 -0
- package/dist/esm/errors/app-error-type.js +2 -0
- package/dist/esm/errors/app-error-type.js.map +1 -0
- package/dist/esm/errors.js +5 -148
- package/dist/esm/errors.js.map +1 -1
- package/dist/esm/module.js +2 -0
- package/dist/esm/module.js.map +1 -1
- package/dist/esm/schemas.js +4 -0
- package/dist/esm/schemas.js.map +1 -1
- package/dist/esm/version.js +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/types/AppClient.d.ts +42 -0
- package/dist/types/AppConfig.d.ts +7 -1
- package/dist/types/AppConfigurator.d.ts +25 -0
- package/dist/types/AppModuleProvider.d.ts +10 -0
- package/dist/types/app/App.d.ts +49 -8
- package/dist/types/app/create-reducer.d.ts +55 -55
- package/dist/types/app/filter-empty.d.ts +8 -0
- package/dist/types/app/flows/handle-fetch-config.d.ts +12 -0
- package/dist/types/app/flows/handle-fetch-manifest.d.ts +12 -0
- package/dist/types/app/flows/handle-fetch-settings.d.ts +12 -0
- package/dist/types/app/flows/handle-import-application.d.ts +10 -0
- package/dist/types/app/flows/handle-update-settings.d.ts +12 -0
- package/dist/types/app/flows/index.d.ts +5 -0
- package/dist/types/errors/AppBuildError.d.ts +21 -0
- package/dist/types/errors/AppConfigError.d.ts +21 -0
- package/dist/types/errors/AppManifestError.d.ts +21 -0
- package/dist/types/errors/AppScriptModuleError.d.ts +14 -0
- package/dist/types/errors/AppSettingsError.d.ts +21 -0
- package/dist/types/errors/app-error-type.d.ts +9 -0
- package/dist/types/errors.d.ts +6 -103
- package/dist/types/version.d.ts +1 -1
- package/package.json +9 -9
- package/src/AppClient.ts +65 -4
- package/src/AppConfig.ts +9 -1
- package/src/AppConfigurator.ts +28 -4
- package/src/AppModuleProvider.ts +16 -0
- package/src/app/App.ts +88 -31
- package/src/app/actions.ts +2 -2
- package/src/app/create-reducer.ts +2 -1
- package/src/app/filter-empty.ts +11 -0
- package/src/app/flows/handle-fetch-config.ts +48 -0
- package/src/app/flows/handle-fetch-manifest.ts +53 -0
- package/src/app/flows/handle-fetch-settings.ts +50 -0
- package/src/app/flows/handle-import-application.ts +37 -0
- package/src/app/flows/handle-update-settings.ts +39 -0
- package/src/app/flows/index.ts +5 -0
- package/src/app/types.ts +2 -2
- package/src/enable-app-module.ts +2 -1
- package/src/errors/AppBuildError.ts +47 -0
- package/src/errors/AppConfigError.ts +47 -0
- package/src/errors/AppManifestError.ts +47 -0
- package/src/errors/AppScriptModuleError.ts +20 -0
- package/src/errors/AppSettingsError.ts +47 -0
- package/src/errors/app-error-type.ts +9 -0
- package/src/errors.ts +6 -208
- package/src/module.ts +2 -0
- package/src/schemas.ts +4 -0
- package/src/types.ts +1 -1
- package/src/version.ts +1 -1
- package/dist/esm/AppClient.Selectors.js.map +0 -1
- package/dist/esm/app/flows.js +0 -120
- package/dist/esm/app/flows.js.map +0 -1
- package/dist/types/app/flows.d.ts +0 -41
- package/src/app/flows.ts +0 -189
- /package/dist/types/{AppClient.Selectors.d.ts → AppConfigSelector.d.ts} +0 -0
- /package/src/{AppClient.Selectors.ts → AppConfigSelector.ts} +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,18 @@
|
|
|
1
1
|
# Change Log
|
|
2
2
|
|
|
3
|
+
## 8.0.3
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 80c3e4a: Internal: resolve `noExplicitAny` Biome warnings in `enableAppModule`'s configurator widening, `AppBundleState`/`AppBundleStateInitial`'s `TModules` generic default, and the `setModule` action creator, using explanatory `biome-ignore` comments. No public API or behavior change.
|
|
8
|
+
- 80c3e4a: Internal: add a required fusion-lint intent comment explaining an `as unknown as AppModuleProvider` cast in the module's `dispose` hook. No behavior change.
|
|
9
|
+
- 80c3e4a: Internal: Resolve fusion-lint warnings across the module — added missing TSDoc comments (including `@inheritdoc` for `IApp` interface implementations), added intent comments for control-flow and RxJS `.pipe()` chains, and referenced tracking issues for existing TODOs (#5123-#5133).
|
|
10
|
+
|
|
11
|
+
Split multi-export files into one-symbol-per-file modules for maintainability: `errors.ts` into `errors/*.ts`, `app/flows.ts` into `app/flows/*.ts`, and extracted the `filterEmpty` operator from `app/App.ts` into `app/filter-empty.ts` (re-exported from `App.ts` for backwards compatibility).
|
|
12
|
+
|
|
13
|
+
- 80c3e4a: Internal: renamed 45 source files across these packages to comply with the `filename-convention` lint rule (e.g. `AIConfigurator.ts` → `AiConfigurator.ts`, `BookmarkProvider.actions.ts` → `bookmark-actions.ts`, `errors/app-build-error.ts` → `errors/AppBuildError.ts`, `plugins/api/plugin.ts` → `plugins/api/ApiPlugin.ts`, `errors.ts` → `UnsupportedApiVersion.ts`, etc.). Also added `enable-signalr.ts` to the `filename-convention` exclude list since the suggested rename would incorrectly split the "SignalR" brand name. No public API changes.
|
|
14
|
+
- 80c3e4a: Internal: added missing intent comments ahead of non-obvious control flow, RxJS `.pipe()` chains, iterator calls, and multi-source object merges to comply with the `require-intent-comment` and `require-tsdoc` lint rules. Also removed dead duplicate files left over from an earlier refactor in `navigation` (`events.ts`, `navigated-event.ts`, `history.flows.ts` — all fully superseded by their split replacements) and renamed `bookmarks/schemas.ts` to `bookmarks/bookmark.schemas.ts` in `services` to match the `*.schemas.ts` filename convention. No public API changes.
|
|
15
|
+
|
|
3
16
|
## 8.0.2
|
|
4
17
|
|
|
5
18
|
### Patch Changes
|
package/dist/esm/AppClient.js
CHANGED
|
@@ -5,7 +5,7 @@ import { HttpJsonResponseError, HttpResponseError, } from '@equinor/fusion-frame
|
|
|
5
5
|
import { jsonSelector } from '@equinor/fusion-framework-module-http/selectors';
|
|
6
6
|
import { ApiApplicationBuildSchema, ApiApplicationSchema } from './schemas';
|
|
7
7
|
import { AppBuildError, AppConfigError, AppManifestError, AppSettingsError } from './errors';
|
|
8
|
-
import { AppConfigSelector } from './
|
|
8
|
+
import { AppConfigSelector } from './AppConfigSelector';
|
|
9
9
|
/**
|
|
10
10
|
* Transforms a raw API application response into an {@link AppManifest},
|
|
11
11
|
* adding backwards-compatible `key` and `name` getters.
|
|
@@ -16,11 +16,11 @@ const ApplicationSchema = ApiApplicationSchema.transform((x) => {
|
|
|
16
16
|
const { category, ...props } = x;
|
|
17
17
|
return {
|
|
18
18
|
...props,
|
|
19
|
-
// TODO: remove deprecated appKey
|
|
19
|
+
// TODO(#5124): remove deprecated appKey
|
|
20
20
|
get key() {
|
|
21
21
|
return props.appKey;
|
|
22
22
|
},
|
|
23
|
-
// TODO: remove deprecated name
|
|
23
|
+
// TODO(#5124): remove deprecated name
|
|
24
24
|
get name() {
|
|
25
25
|
return props.displayName;
|
|
26
26
|
},
|
|
@@ -51,6 +51,10 @@ export class AppClient {
|
|
|
51
51
|
#build;
|
|
52
52
|
#settings;
|
|
53
53
|
#client;
|
|
54
|
+
/**
|
|
55
|
+
* Creates a new {@link AppClient} backed by the given HTTP client.
|
|
56
|
+
* @param client - The HTTP client used to communicate with the Fusion app service API.
|
|
57
|
+
*/
|
|
54
58
|
constructor(client) {
|
|
55
59
|
this.#client = client;
|
|
56
60
|
const expire = 1 * 60 * 1000;
|
|
@@ -133,63 +137,122 @@ export class AppClient {
|
|
|
133
137
|
expire,
|
|
134
138
|
});
|
|
135
139
|
}
|
|
140
|
+
/**
|
|
141
|
+
* Fetches the build metadata for an application.
|
|
142
|
+
* @param args - Object containing the `appKey` and an optional version `tag`.
|
|
143
|
+
* @returns An observable that emits the resolved {@link AppBuildManifest}.
|
|
144
|
+
* @throws {AppBuildError} When the build metadata cannot be loaded.
|
|
145
|
+
*/
|
|
136
146
|
getAppBuild(args) {
|
|
137
|
-
|
|
147
|
+
// unwrap the build manifest and map errors to a typed AppBuildError
|
|
148
|
+
return this.#build.query(args).pipe(
|
|
149
|
+
// unwrap the query result into the build manifest
|
|
150
|
+
map((res) => res.value),
|
|
151
|
+
// map http/unknown errors into a typed AppBuildError
|
|
152
|
+
catchError((err) => {
|
|
138
153
|
const cause = err?.cause || err;
|
|
154
|
+
// rethrow already-typed errors as-is
|
|
139
155
|
if (cause instanceof AppBuildError) {
|
|
140
156
|
throw cause;
|
|
141
157
|
}
|
|
158
|
+
// map http errors to a typed AppBuildError
|
|
142
159
|
if (cause instanceof HttpJsonResponseError || cause instanceof HttpResponseError) {
|
|
143
160
|
throw AppBuildError.fromHttpResponse(cause.response, { cause });
|
|
144
161
|
}
|
|
145
162
|
throw new AppBuildError('unknown', 'failed to load build', { cause });
|
|
146
163
|
}));
|
|
147
164
|
}
|
|
165
|
+
/**
|
|
166
|
+
* Fetches the manifest for a single application.
|
|
167
|
+
* @param args - Object containing the `appKey` and an optional version `tag`.
|
|
168
|
+
* @returns An observable that emits the resolved {@link AppManifest}.
|
|
169
|
+
* @throws {AppManifestError} When the manifest cannot be loaded.
|
|
170
|
+
*/
|
|
148
171
|
getAppManifest(args) {
|
|
149
|
-
|
|
172
|
+
// unwrap the manifest and map errors to a typed AppManifestError
|
|
173
|
+
return this.#manifest.query(args).pipe(queryValue,
|
|
174
|
+
// map http/unknown errors into a typed AppManifestError
|
|
175
|
+
catchError((err) => {
|
|
150
176
|
const cause = err?.cause || err;
|
|
177
|
+
// rethrow already-typed errors as-is
|
|
151
178
|
if (cause instanceof AppManifestError) {
|
|
152
179
|
throw cause;
|
|
153
180
|
}
|
|
181
|
+
// map http errors to a typed AppManifestError
|
|
154
182
|
if (cause instanceof HttpJsonResponseError || cause instanceof HttpResponseError) {
|
|
155
183
|
throw AppManifestError.fromHttpResponse(cause.response, { cause });
|
|
156
184
|
}
|
|
157
185
|
throw new AppManifestError('unknown', 'failed to load manifest', { cause });
|
|
158
186
|
}));
|
|
159
187
|
}
|
|
188
|
+
/**
|
|
189
|
+
* Fetches manifests for all registered applications.
|
|
190
|
+
* @param args - Optional filter; set `filterByCurrentUser` to `true` to return only apps the authenticated user has access to.
|
|
191
|
+
* @returns An observable that emits an array of {@link AppManifest} objects.
|
|
192
|
+
*/
|
|
160
193
|
getAppManifests(args) {
|
|
194
|
+
// unwrap the query result into the manifest array
|
|
161
195
|
return this.#manifests.query(args).pipe(queryValue);
|
|
162
196
|
}
|
|
197
|
+
/**
|
|
198
|
+
* Fetches the runtime configuration for an application.
|
|
199
|
+
* @template TType - Shape of the `environment` record in the returned config.
|
|
200
|
+
* @param args - Object containing the `appKey` and an optional version `tag`.
|
|
201
|
+
* @returns An observable that emits the resolved {@link AppConfig}.
|
|
202
|
+
* @throws {AppConfigError} When the configuration cannot be loaded.
|
|
203
|
+
*/
|
|
163
204
|
getAppConfig(args) {
|
|
164
|
-
|
|
205
|
+
// unwrap the config and map errors to a typed AppConfigError
|
|
206
|
+
return this.#config.query(args).pipe(
|
|
207
|
+
// unwrap the query result into the config
|
|
208
|
+
map((res) => res.value),
|
|
209
|
+
// map http/unknown errors into a typed AppConfigError
|
|
210
|
+
catchError((err) => {
|
|
165
211
|
/** handle both direct errors and errors wrapped in a `cause` property */
|
|
166
212
|
const cause = err?.cause || err;
|
|
213
|
+
// rethrow already-typed errors as-is
|
|
167
214
|
if (cause instanceof AppConfigError) {
|
|
168
215
|
throw cause;
|
|
169
216
|
}
|
|
217
|
+
// map http errors to a typed AppConfigError
|
|
170
218
|
if (cause instanceof HttpJsonResponseError || cause instanceof HttpResponseError) {
|
|
171
219
|
throw AppConfigError.fromHttpResponse(cause.response, { cause });
|
|
172
220
|
}
|
|
173
221
|
throw new AppConfigError('unknown', 'failed to load config', { cause });
|
|
174
222
|
}));
|
|
175
223
|
}
|
|
224
|
+
/**
|
|
225
|
+
* Fetches per-user settings for an application.
|
|
226
|
+
* @param args - Object containing the `appKey`.
|
|
227
|
+
* @returns An observable that emits the {@link AppSettings} record.
|
|
228
|
+
* @throws {AppSettingsError} When settings cannot be loaded.
|
|
229
|
+
*/
|
|
176
230
|
getAppSettings(args) {
|
|
177
|
-
|
|
231
|
+
// unwrap the settings and map errors to a typed AppSettingsError
|
|
232
|
+
return this.#settings.query(args).pipe(queryValue,
|
|
233
|
+
// map http/unknown errors into a typed AppSettingsError
|
|
234
|
+
catchError((err) => {
|
|
178
235
|
/** handle both direct errors and errors wrapped in a `cause` property */
|
|
179
236
|
const cause = err?.cause || err;
|
|
237
|
+
// rethrow already-typed errors as-is
|
|
180
238
|
if (cause instanceof AppSettingsError) {
|
|
181
239
|
throw cause;
|
|
182
240
|
}
|
|
241
|
+
// map http errors to a typed AppSettingsError
|
|
183
242
|
if (cause instanceof HttpJsonResponseError || cause instanceof HttpResponseError) {
|
|
184
243
|
throw AppSettingsError.fromHttpResponse(cause.response, { cause });
|
|
185
244
|
}
|
|
186
245
|
throw new AppSettingsError('unknown', 'failed to load settings', { cause });
|
|
187
246
|
}));
|
|
188
247
|
}
|
|
248
|
+
/**
|
|
249
|
+
* Persists updated per-user settings for an application via PUT.
|
|
250
|
+
* @param args - Object containing the `appKey` and the `settings` payload to save.
|
|
251
|
+
* @returns An observable that emits the persisted {@link AppSettings}.
|
|
252
|
+
*/
|
|
189
253
|
updateAppSettings(args) {
|
|
190
254
|
const { appKey, settings } = args;
|
|
191
255
|
return (this.#client
|
|
192
|
-
// execute PUT request to update settings
|
|
193
256
|
.json$(`/persons/me/apps/${appKey}/settings`, {
|
|
194
257
|
method: 'PUT',
|
|
195
258
|
body: settings,
|
|
@@ -197,6 +260,7 @@ export class AppClient {
|
|
|
197
260
|
'Api-Version': '1.0',
|
|
198
261
|
},
|
|
199
262
|
})
|
|
263
|
+
// update the settings cache with the persisted value
|
|
200
264
|
.pipe(tap((value) => {
|
|
201
265
|
// update cache with new settings
|
|
202
266
|
this.#settings.mutate({ appKey }, {
|
|
@@ -205,6 +269,9 @@ export class AppClient {
|
|
|
205
269
|
});
|
|
206
270
|
})));
|
|
207
271
|
}
|
|
272
|
+
/**
|
|
273
|
+
* Disposes of the client, completing all internal query streams.
|
|
274
|
+
*/
|
|
208
275
|
[Symbol.dispose]() {
|
|
209
276
|
console.warn('AppClient disposed');
|
|
210
277
|
this.#manifest.complete();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AppClient.js","sourceRoot":"","sources":["../../src/AppClient.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,GAAG,EAAyC,GAAG,EAAE,MAAM,MAAM,CAAC;AAEnF,OAAO,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AAC9C,OAAO,EAAE,UAAU,EAAE,MAAM,iCAAiC,CAAC;AAE7D,OAAO,EACL,qBAAqB,EACrB,iBAAiB,GAElB,MAAM,uCAAuC,CAAC;AAC/C,OAAO,EAAE,YAAY,EAAE,MAAM,iDAAiD,CAAC;AAE/E,OAAO,EAAE,yBAAyB,EAAE,oBAAoB,EAAE,MAAM,WAAW,CAAC;AAS5E,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAC7F,OAAO,EAAE,iBAAiB,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"AppClient.js","sourceRoot":"","sources":["../../src/AppClient.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,GAAG,EAAyC,GAAG,EAAE,MAAM,MAAM,CAAC;AAEnF,OAAO,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AAC9C,OAAO,EAAE,UAAU,EAAE,MAAM,iCAAiC,CAAC;AAE7D,OAAO,EACL,qBAAqB,EACrB,iBAAiB,GAElB,MAAM,uCAAuC,CAAC;AAC/C,OAAO,EAAE,YAAY,EAAE,MAAM,iDAAiD,CAAC;AAE/E,OAAO,EAAE,yBAAyB,EAAE,oBAAoB,EAAE,MAAM,WAAW,CAAC;AAS5E,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,gBAAg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C,QAAQ,EAAE,CAAC;QACxB,IAAI,CAAC,SAAS,CAAC,QAAQ,EAAE,CAAC;QAC1B,IAAI,CAAC,MAAM,CAAC,QAAQ,EAAE,CAAC;IACzB,CAAC;CACF;AAED,eAAe,SAAS,CAAC"}
|
package/dist/esm/AppConfig.js
CHANGED
|
@@ -6,7 +6,9 @@
|
|
|
6
6
|
* @returns The same object, deeply frozen.
|
|
7
7
|
*/
|
|
8
8
|
const deepFreeze = (obj) => {
|
|
9
|
+
// recursively freeze any nested, unfrozen object properties
|
|
9
10
|
for (const property of Object.keys(obj)) {
|
|
11
|
+
// only descend into unfrozen object properties
|
|
10
12
|
if (typeof obj[property] === 'object' &&
|
|
11
13
|
obj[property] !== null &&
|
|
12
14
|
!Object.isFrozen(obj[property])) {
|
|
@@ -40,16 +42,22 @@ export class AppConfig {
|
|
|
40
42
|
#environment;
|
|
41
43
|
/**
|
|
42
44
|
* The environment configuration for the application.
|
|
45
|
+
* @returns The frozen environment configuration.
|
|
43
46
|
*/
|
|
44
47
|
get environment() {
|
|
45
48
|
return this.#environment;
|
|
46
49
|
}
|
|
47
50
|
/**
|
|
48
|
-
* The configuration endpoints for the application
|
|
51
|
+
* The configuration endpoints for the application.
|
|
52
|
+
* @returns The frozen map of configuration endpoints.
|
|
49
53
|
*/
|
|
50
54
|
get endpoints() {
|
|
51
55
|
return this.#endpoints;
|
|
52
56
|
}
|
|
57
|
+
/**
|
|
58
|
+
* Creates a new {@link AppConfig}, deep-freezing the provided environment and endpoints.
|
|
59
|
+
* @param config - The environment and endpoints to initialize the configuration with.
|
|
60
|
+
*/
|
|
53
61
|
constructor(config) {
|
|
54
62
|
this.#environment = deepFreeze(config.environment ?? {});
|
|
55
63
|
this.#endpoints = deepFreeze(config.endpoints ?? {});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AppConfig.js","sourceRoot":"","sources":["../../src/AppConfig.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,MAAM,UAAU,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AE3B;;;OAGG;IACH,IAAI,WAAW;QACb,OAAO,IAAI,CAAC,YAAY,CAAC;IAC3B,CAAC;IAED;;;OAGG;IACH,IAAI,SAAS;QACX,OAAO,IAAI,CAAC,UAAU,CAAC;IACzB,CAAC;IAED;;;OAGG;IACH,YAAY,MAGX;QACC,IAAI,CAAC,YAAY,GAAG,UAAU,CAAC,MAAM,CAAC,WAAW,IAAI,EAAE,CAAiB,CAAC;QACzE,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC,MAAM,CAAC,SAAS,IAAI,EAAE,CAAC,CAAC;IACvD,CAAC;IAED;;;;;OAKG;IACH,WAAW,CAAC,GAAW;QACrB,OAAO,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC;IAC9B,CAAC;CACF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AppConfigSelector.js","sourceRoot":"","sources":["../../src/AppConfigSelector.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,YAAY,GAEb,MAAM,iDAAiD,CAAC;AAEzD,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,kBAAkB,EAAE,MAAM,WAAW,CAAC;AAE/C;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAgC,KAAK,EAAE,QAAQ,EAAE,EAAE;IAC/E,yCAAyC;IACzC,MAAM,GAAG,GAAG,MAAM,YAAY,CAAC,QAAQ,CAAC,CAAC;IAEzC,qEAAqE;IACrE,MAAM,IAAI,GAAG,kBAAkB,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IAE3C,OAAO,IAAI,SAAS,CAAC,IAAI,CAAC,CAAC;AAC7B,CAAC,CAAC"}
|
|
@@ -10,7 +10,13 @@ import AppClient from './AppClient';
|
|
|
10
10
|
export class AppConfigurator extends BaseConfigBuilder {
|
|
11
11
|
defaultExpireTime = 1 * 60 * 1000;
|
|
12
12
|
/**
|
|
13
|
+
* Creates the default HTTP client for the app service, preferring a pre-configured
|
|
14
|
+
* client from the http module and falling back to service discovery.
|
|
15
|
+
*
|
|
13
16
|
* WARNING: this function will be remove in future
|
|
17
|
+
*
|
|
18
|
+
* @param init - Module initializer args providing access to the http and service discovery modules.
|
|
19
|
+
* @returns A promise resolving to the {@link IHttpClient} used to communicate with the app service.
|
|
14
20
|
*/
|
|
15
21
|
async _createHttpClient(init) {
|
|
16
22
|
const http = await init.requireInstance('http');
|
|
@@ -21,20 +27,39 @@ export class AppConfigurator extends BaseConfigBuilder {
|
|
|
21
27
|
}
|
|
22
28
|
/** load service discovery module */
|
|
23
29
|
const serviceDiscovery = await init.requireInstance('serviceDiscovery');
|
|
24
|
-
// TODO - remove when refactor portal service!
|
|
30
|
+
// TODO(#5125) - remove when refactor portal service!
|
|
25
31
|
/** resolve and create a client from discovery */
|
|
26
32
|
return await serviceDiscovery.createClient(serviceName);
|
|
27
33
|
}
|
|
34
|
+
/**
|
|
35
|
+
* Sets the app service client used to fetch manifests, configs, and settings.
|
|
36
|
+
* @param client_or_cb - A promise resolving to an {@link IAppClient}, or a callback
|
|
37
|
+
* that receives module initializer args and returns one.
|
|
38
|
+
*/
|
|
28
39
|
setClient(client_or_cb) {
|
|
29
40
|
const cb = typeof client_or_cb === 'object' ? () => client_or_cb : client_or_cb;
|
|
30
41
|
this._set('client', cb);
|
|
31
42
|
}
|
|
32
|
-
|
|
43
|
+
/**
|
|
44
|
+
* Sets the base URI used to proxy-load application script bundles.
|
|
45
|
+
*
|
|
46
|
+
* TODO(#5132) - explain why, used in import of resources aka proxy url
|
|
47
|
+
*
|
|
48
|
+
* @param base_or_cb - A static URI string or a callback returning one.
|
|
49
|
+
*/
|
|
33
50
|
setAssetUri(base_or_cb) {
|
|
34
51
|
const cb = typeof base_or_cb === 'string' ? async () => base_or_cb : base_or_cb;
|
|
35
52
|
this._set('assetUri', cb);
|
|
36
53
|
}
|
|
54
|
+
/**
|
|
55
|
+
* Builds the resolved {@link AppModuleConfig}, applying default client and asset URI
|
|
56
|
+
* when they haven't been explicitly configured.
|
|
57
|
+
* @param init - Module initializer args used to build the default client.
|
|
58
|
+
* @param initial - Optional initial partial configuration.
|
|
59
|
+
* @returns The resolved module config.
|
|
60
|
+
*/
|
|
37
61
|
_createConfig(init, initial) {
|
|
62
|
+
// fall back to a default client created via the http/service discovery modules
|
|
38
63
|
if (!this._has('client')) {
|
|
39
64
|
this.setClient(async () => {
|
|
40
65
|
const httpClient = await this._createHttpClient(init);
|
|
@@ -42,6 +67,7 @@ export class AppConfigurator extends BaseConfigBuilder {
|
|
|
42
67
|
return appClient;
|
|
43
68
|
});
|
|
44
69
|
}
|
|
70
|
+
// fall back to the default proxy asset uri
|
|
45
71
|
if (!this._has('assetUri')) {
|
|
46
72
|
this.setAssetUri('/apps-proxy');
|
|
47
73
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AppConfigurator.js","sourceRoot":"","sources":["../../src/AppConfigurator.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,iBAAiB,GAGlB,MAAM,kCAAkC,CAAC;
|
|
1
|
+
{"version":3,"file":"AppConfigurator.js","sourceRoot":"","sources":["../../src/AppConfigurator.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,iBAAiB,GAGlB,MAAM,kCAAkC,CAAC;AAI1C,OAAO,SAA8B,MAAM,aAAa,CAAC;AA0CzD;;;;;;GAMG;AACH,MAAM,OAAO,eACX,SAAQ,iBAAkC;IAG1C,iBAAiB,GAAG,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC;IAElC;;;;;;;;OAQG;IACO,KAAK,CAAC,iBAAiB,CAC/B,IAAmF;QAEnF,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,eAAe,CAAC,MAAM,CAAC,CAAC;QAChD,MAAM,WAAW,GAAG,MAAM,CAAC;QAC3B,wDAAwD;QACxD,IAAI,IAAI,CAAC,SAAS,CAAC,WAAW,CAAC,EAAE,CAAC;YAChC,OAAO,IAAI,CAAC,YAAY,CAAC,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OAAO,KAAK,CAAC,aAAa,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;IAC5C,CAAC;CACF"}
|
|
@@ -19,6 +19,7 @@ export class AppModuleProvider {
|
|
|
19
19
|
/**
|
|
20
20
|
* Shallow-compares two app manifests by JSON serialization.
|
|
21
21
|
*
|
|
22
|
+
* @template T - The manifest type being compared.
|
|
22
23
|
* @param a - First manifest to compare.
|
|
23
24
|
* @param b - Second manifest to compare.
|
|
24
25
|
* @returns `true` if the serialized manifests are identical.
|
|
@@ -33,6 +34,7 @@ export class AppModuleProvider {
|
|
|
33
34
|
#event;
|
|
34
35
|
/**
|
|
35
36
|
* Get module version
|
|
37
|
+
* @returns The module's semantic version.
|
|
36
38
|
*/
|
|
37
39
|
get version() {
|
|
38
40
|
return new SemanticVersion(version);
|
|
@@ -43,6 +45,8 @@ export class AppModuleProvider {
|
|
|
43
45
|
* - `undefined` – no application has been set yet.
|
|
44
46
|
* - `null` – the current application was explicitly cleared.
|
|
45
47
|
* - `App` – an active application instance.
|
|
48
|
+
*
|
|
49
|
+
* @returns The current active application, `null` if cleared, or `undefined` if never set.
|
|
46
50
|
*/
|
|
47
51
|
get current() {
|
|
48
52
|
return this.#current$.value;
|
|
@@ -52,9 +56,13 @@ export class AppModuleProvider {
|
|
|
52
56
|
*
|
|
53
57
|
* Emits are deduplicated by `appKey`; re-setting the same app does not trigger
|
|
54
58
|
* a new emission.
|
|
59
|
+
*
|
|
60
|
+
* @returns An observable of the current active application.
|
|
55
61
|
*/
|
|
56
62
|
get current$() {
|
|
63
|
+
// dedupe emissions when the current app's key is unchanged
|
|
57
64
|
return this.#current$.pipe(distinctUntilChanged((prev, next) => {
|
|
65
|
+
// compare by appKey when both are set, otherwise fall back to reference equality
|
|
58
66
|
if (prev && next) {
|
|
59
67
|
return prev.appKey === next.appKey;
|
|
60
68
|
}
|
|
@@ -74,6 +82,7 @@ export class AppModuleProvider {
|
|
|
74
82
|
this.#current$ = new BehaviorSubject(undefined);
|
|
75
83
|
this.#appBaseUri = config.assetUri ?? '';
|
|
76
84
|
this.#subscription.add(this.current$
|
|
85
|
+
// dispatch a lifecycle event whenever the current app changes
|
|
77
86
|
.pipe(pairwise(), takeWhile(() => !!event))
|
|
78
87
|
.subscribe(([previous, next]) => {
|
|
79
88
|
event?.dispatchEvent('onCurrentAppChanged', {
|
|
@@ -82,6 +91,7 @@ export class AppModuleProvider {
|
|
|
82
91
|
});
|
|
83
92
|
}));
|
|
84
93
|
this.#subscription.add(this.#current$
|
|
94
|
+
// dispose the previous app once it has been replaced
|
|
85
95
|
.pipe(pairwise(), map(([previous]) => previous), filterEmpty())
|
|
86
96
|
.subscribe((app) => app.dispose()));
|
|
87
97
|
}
|
|
@@ -108,6 +118,7 @@ export class AppModuleProvider {
|
|
|
108
118
|
/**
|
|
109
119
|
* fetch all applications
|
|
110
120
|
* @deprecated use `getAppManifests` instead
|
|
121
|
+
* @returns An observable that emits an array of {@link AppManifest} objects.
|
|
111
122
|
*/
|
|
112
123
|
getAllAppManifests() {
|
|
113
124
|
return this.getAppManifests();
|
|
@@ -151,11 +162,13 @@ export class AppModuleProvider {
|
|
|
151
162
|
* @param appKeyOrApp - Application key, app reference, or an existing `IApp` instance.
|
|
152
163
|
*/
|
|
153
164
|
setCurrentApp(appKeyOrApp) {
|
|
165
|
+
// a plain string is treated as an appKey to create a new App from
|
|
154
166
|
if (typeof appKeyOrApp === 'string') {
|
|
155
167
|
const newApp = new App({ appKey: appKeyOrApp }, { provider: this, event: this.#event });
|
|
156
168
|
this.#current$.next(newApp);
|
|
157
169
|
return;
|
|
158
170
|
}
|
|
171
|
+
// an object with appKey and tag is treated as an AppReference to create a new App from
|
|
159
172
|
if (appKeyOrApp.appKey && 'tag' in appKeyOrApp) {
|
|
160
173
|
const newApp = new App({ appKey: appKeyOrApp.appKey, tag: appKeyOrApp.tag }, { provider: this, event: this.#event });
|
|
161
174
|
this.#current$.next(newApp);
|
|
@@ -172,6 +185,7 @@ export class AppModuleProvider {
|
|
|
172
185
|
}
|
|
173
186
|
/**
|
|
174
187
|
* Base URI used for proxying application script imports.
|
|
188
|
+
* @returns The configured asset base URI.
|
|
175
189
|
*/
|
|
176
190
|
get assetUri() {
|
|
177
191
|
return this.#appBaseUri;
|
|
@@ -179,6 +193,8 @@ export class AppModuleProvider {
|
|
|
179
193
|
/**
|
|
180
194
|
* This should not be used, only for legacy creation backdoor
|
|
181
195
|
* @deprecated
|
|
196
|
+
* @param value - The initial app bundle state to construct the app from.
|
|
197
|
+
* @returns The newly created {@link App} instance.
|
|
182
198
|
*/
|
|
183
199
|
createApp(value) {
|
|
184
200
|
console.warn('AppModuleProvider.createApp is deprecated and should not be used.');
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AppModuleProvider.js","sourceRoot":"","sources":["../../src/AppModuleProvider.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,eAAe,EACf,oBAAoB,EACpB,IAAI,EACJ,GAAG,EAEH,QAAQ,EACR,YAAY,EACZ,SAAS,GACV,MAAM,MAAM,CAAC;AAcd,OAAO,EAAE,GAAG,EAAE,WAAW,EAAa,MAAM,WAAW,CAAC;AAIxD,OAAO,EAAE,eAAe,EAAE,MAAM,kCAAkC,CAAC;AACnE,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEpC;;;;;;;;;;;;GAYG;AACH,MAAM,OAAO,iBAAiB;IAC5B
|
|
1
|
+
{"version":3,"file":"AppModuleProvider.js","sourceRoot":"","sources":["../../src/AppModuleProvider.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,eAAe,EACf,oBAAoB,EACpB,IAAI,EACJ,GAAG,EAEH,QAAQ,EACR,YAAY,EACZ,SAAS,GACV,MAAM,MAAM,CAAC;AAcd,OAAO,EAAE,GAAG,EAAE,WAAW,EAAa,MAAM,WAAW,CAAC;AAIxD,OAAO,EAAE,eAAe,EAAE,MAAM,kCAAkC,CAAC;AACnE,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;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