@equinor/fusion-framework-module-context 5.1.0 → 5.1.1
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 +7 -0
- package/dist/esm/ContextConfigBuilder.js +4 -16
- package/dist/esm/ContextConfigBuilder.js.map +1 -1
- package/dist/esm/ContextProvider.js +74 -105
- package/dist/esm/ContextProvider.js.map +1 -1
- package/dist/esm/client/ContextClient.js +14 -27
- package/dist/esm/client/ContextClient.js.map +1 -1
- package/dist/esm/configurator.js +55 -79
- package/dist/esm/configurator.js.map +1 -1
- package/dist/esm/errors.js +5 -19
- package/dist/esm/errors.js.map +1 -1
- package/dist/esm/module.js +48 -60
- package/dist/esm/module.js.map +1 -1
- package/dist/esm/selectors.js +18 -31
- package/dist/esm/selectors.js.map +1 -1
- package/dist/esm/utils/resolve-context-from-path.js +1 -1
- package/dist/esm/utils/resolve-context-from-path.js.map +1 -1
- package/dist/esm/utils/resolve-initial-context.js +4 -4
- package/dist/esm/utils/resolve-initial-context.js.map +1 -1
- package/dist/esm/version.js +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/types/version.d.ts +1 -1
- package/package.json +7 -20
- package/src/version.ts +1 -1
- package/tsconfig.json +5 -11
package/dist/esm/configurator.js
CHANGED
|
@@ -1,95 +1,71 @@
|
|
|
1
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
-
});
|
|
9
|
-
};
|
|
10
|
-
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
11
|
-
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
12
|
-
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
13
|
-
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
14
|
-
};
|
|
15
|
-
var _ContextModuleConfigurator_configBuilders;
|
|
16
1
|
import { getContextSelector, queryContextSelector, relatedContextSelector } from './selectors';
|
|
17
2
|
import { ContextConfigBuilder } from './ContextConfigBuilder';
|
|
18
3
|
import resolveInitialContext from './utils/resolve-initial-context';
|
|
19
4
|
export class ContextModuleConfigurator {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
_ContextModuleConfigurator_configBuilders.set(this, []);
|
|
23
|
-
}
|
|
5
|
+
defaultExpireTime = 1 * 60 * 1000;
|
|
6
|
+
#configBuilders = [];
|
|
24
7
|
addConfigBuilder(init) {
|
|
25
|
-
|
|
8
|
+
this.#configBuilders.push(init);
|
|
26
9
|
}
|
|
27
|
-
_getServiceProvider(init) {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
if (parentServiceModule) {
|
|
36
|
-
return parentServiceModule;
|
|
37
|
-
}
|
|
38
|
-
throw Error('no service services provider configures [ServicesModule]');
|
|
10
|
+
async _getServiceProvider(init) {
|
|
11
|
+
if (init.hasModule('services')) {
|
|
12
|
+
return init.requireInstance('services');
|
|
13
|
+
}
|
|
14
|
+
else {
|
|
15
|
+
const parentServiceModule = init.ref?.services;
|
|
16
|
+
if (parentServiceModule) {
|
|
17
|
+
return parentServiceModule;
|
|
39
18
|
}
|
|
40
|
-
|
|
19
|
+
throw Error('no service services provider configures [ServicesModule]');
|
|
20
|
+
}
|
|
41
21
|
}
|
|
42
|
-
createConfig(init) {
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
const
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
client: {
|
|
64
|
-
fn: (args) => contextClient.get('v1', args, { selector: getContextSelector }),
|
|
65
|
-
},
|
|
66
|
-
key: ({ id }) => id,
|
|
67
|
-
expire: this.defaultExpireTime,
|
|
22
|
+
async createConfig(init) {
|
|
23
|
+
const config = await this.#configBuilders.reduce(async (cur, cb) => {
|
|
24
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
25
|
+
const builder = new ContextConfigBuilder(init, await cur);
|
|
26
|
+
await Promise.resolve(cb(builder));
|
|
27
|
+
return Object.assign(cur, builder.config);
|
|
28
|
+
}, Promise.resolve({}));
|
|
29
|
+
config.resolveInitialContext ??= resolveInitialContext({
|
|
30
|
+
path: {
|
|
31
|
+
extract: config.extractContextIdFromPath,
|
|
32
|
+
validate: config.extractContextIdFromPath ? () => true : undefined,
|
|
33
|
+
},
|
|
34
|
+
});
|
|
35
|
+
// TODO - make less lazy
|
|
36
|
+
config.client ??= await (async () => {
|
|
37
|
+
const apiProvider = await this._getServiceProvider(init);
|
|
38
|
+
const contextClient = await apiProvider.createContextClient('json$');
|
|
39
|
+
return {
|
|
40
|
+
get: {
|
|
41
|
+
client: {
|
|
42
|
+
fn: (args) => contextClient.get('v1', args, { selector: getContextSelector }),
|
|
68
43
|
},
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
expire: this.defaultExpireTime,
|
|
44
|
+
key: ({ id }) => id,
|
|
45
|
+
expire: this.defaultExpireTime,
|
|
46
|
+
},
|
|
47
|
+
query: {
|
|
48
|
+
client: {
|
|
49
|
+
fn: (query) => contextClient.query('v1', { query }, { selector: queryContextSelector }),
|
|
76
50
|
},
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
51
|
+
// TODO - might cast to checksum
|
|
52
|
+
key: (args) => JSON.stringify(args),
|
|
53
|
+
expire: this.defaultExpireTime,
|
|
54
|
+
},
|
|
55
|
+
related: {
|
|
56
|
+
client: {
|
|
57
|
+
fn: (args) => {
|
|
58
|
+
return contextClient.related('v1', { id: args.item.id, query: { filter: args.filter } }, { selector: relatedContextSelector });
|
|
82
59
|
},
|
|
83
|
-
// TODO - might cast to checksum
|
|
84
|
-
key: (args) => JSON.stringify(args),
|
|
85
|
-
expire: this.defaultExpireTime,
|
|
86
60
|
},
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
61
|
+
// TODO - might cast to checksum
|
|
62
|
+
key: (args) => JSON.stringify(args),
|
|
63
|
+
expire: this.defaultExpireTime,
|
|
64
|
+
},
|
|
65
|
+
};
|
|
66
|
+
})();
|
|
67
|
+
return config;
|
|
91
68
|
}
|
|
92
69
|
}
|
|
93
|
-
_ContextModuleConfigurator_configBuilders = new WeakMap();
|
|
94
70
|
export default ContextModuleConfigurator;
|
|
95
71
|
//# sourceMappingURL=configurator.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"configurator.js","sourceRoot":"","sources":["../../src/configurator.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"configurator.js","sourceRoot":"","sources":["../../src/configurator.ts"],"names":[],"mappings":"AAUA,OAAO,EAAE,kBAAkB,EAAE,oBAAoB,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAC;AAS/F,OAAO,EAAE,oBAAoB,EAAqC,MAAM,wBAAwB,CAAC;AAEjG,OAAO,qBAAqB,MAAM,iCAAiC,CAAC;AAqDpE,MAAM,OAAO,yBAAyB;IAC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AgC;oBAChC,GAAG,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC;oBACnC,MAAM,EAAE,IAAI,CAAC,iBAAiB;iBAC/B;aACF,CAAC;QACJ,CAAC,CAAC,EAAE,CAAC;QAEL,OAAO,MAA6B,CAAC;IACvC,CAAC;CACF;AAED,eAAe,yBAAyB,CAAC"}
|
package/dist/esm/errors.js
CHANGED
|
@@ -1,30 +1,19 @@
|
|
|
1
|
-
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
2
|
-
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
3
|
-
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
4
|
-
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
5
|
-
};
|
|
6
|
-
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
7
|
-
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
8
|
-
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
9
|
-
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
10
|
-
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
11
|
-
};
|
|
12
|
-
var _FusionContextSearchError_details;
|
|
13
1
|
/**
|
|
14
2
|
* Represents an error that occurs during a search in the Fusion Context.
|
|
15
3
|
*/
|
|
16
4
|
export class FusionContextSearchError extends Error {
|
|
5
|
+
#details;
|
|
17
6
|
/**
|
|
18
7
|
* The title of the error.
|
|
19
8
|
*/
|
|
20
9
|
get title() {
|
|
21
|
-
return
|
|
10
|
+
return this.#details.title;
|
|
22
11
|
}
|
|
23
12
|
/**
|
|
24
13
|
* The description of the error, if available.
|
|
25
14
|
*/
|
|
26
15
|
get description() {
|
|
27
|
-
return
|
|
16
|
+
return this.#details.description;
|
|
28
17
|
}
|
|
29
18
|
/**
|
|
30
19
|
* Creates a new instance of FusionContextSearchError.
|
|
@@ -32,12 +21,9 @@ export class FusionContextSearchError extends Error {
|
|
|
32
21
|
* @param options - Optional parameters for the error.
|
|
33
22
|
*/
|
|
34
23
|
constructor(details, options) {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
_FusionContextSearchError_details.set(this, void 0);
|
|
38
|
-
__classPrivateFieldSet(this, _FusionContextSearchError_details, details, "f");
|
|
24
|
+
super(details.description ?? details.title, options);
|
|
25
|
+
this.#details = details;
|
|
39
26
|
this.name = 'FusionContextSearchError';
|
|
40
27
|
}
|
|
41
28
|
}
|
|
42
|
-
_FusionContextSearchError_details = new WeakMap();
|
|
43
29
|
//# sourceMappingURL=errors.js.map
|
package/dist/esm/errors.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../../src/errors.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../../src/errors.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,OAAO,wBAAyB,SAAQ,KAAK;IACjD,QAAQ,CAAC;IAET;;OAEG;IACH,IAAI,KAAK;QACP,OAAO,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC;IAC7B,CAAC;IAED;;OAEG;IACH,IAAI,WAAW;QACb,OAAO,IAAI,CAAC,QAAQ,CAAC,WAAW,CAAC;IACnC,CAAC;IAED;;;;OAIG;IACH,YACE,OASC,EACD,OAAsB;QAEtB,KAAK,CAAC,OAAO,CAAC,WAAW,IAAI,OAAO,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;QACrD,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC;QACxB,IAAI,CAAC,IAAI,GAAG,0BAA0B,CAAC;IACzC,CAAC;CACF"}
|
package/dist/esm/module.js
CHANGED
|
@@ -1,12 +1,3 @@
|
|
|
1
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
-
});
|
|
9
|
-
};
|
|
10
1
|
import { catchError, EMPTY, from, Observable, switchMap, filter, Subscription } from 'rxjs';
|
|
11
2
|
import { ContextModuleConfigurator } from './configurator';
|
|
12
3
|
import { ContextProvider } from './ContextProvider';
|
|
@@ -14,58 +5,55 @@ export const moduleKey = 'context';
|
|
|
14
5
|
export const module = {
|
|
15
6
|
name: moduleKey,
|
|
16
7
|
configure: () => new ContextModuleConfigurator(),
|
|
17
|
-
initialize: function (args) {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
//
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
.
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
},
|
|
63
|
-
}));
|
|
64
|
-
});
|
|
65
|
-
// add teardown to module
|
|
66
|
-
this.dispose = () => subscription.unsubscribe();
|
|
67
|
-
return provider;
|
|
8
|
+
initialize: async function (args) {
|
|
9
|
+
// create config from configurator
|
|
10
|
+
const config = await args.config.createConfig(args);
|
|
11
|
+
// get event module if available
|
|
12
|
+
const event = args.hasModule('event') ? await args.requireInstance('event') : undefined;
|
|
13
|
+
// get parent context provider if available
|
|
14
|
+
const parentProvider = args.ref?.context;
|
|
15
|
+
// create context provider
|
|
16
|
+
const provider = new ContextProvider({ config, event, parentContext: parentProvider });
|
|
17
|
+
// create subscription for disposing the provider
|
|
18
|
+
const subscription = new Subscription(() => provider.dispose());
|
|
19
|
+
// setup post initialize to module
|
|
20
|
+
this.postInitialize = (args) =>
|
|
21
|
+
// create observable for resolving initial context
|
|
22
|
+
new Observable((subscriber) => {
|
|
23
|
+
// resolve initial context if available from config if available
|
|
24
|
+
const resolveInitialContext$ = config.resolveInitialContext
|
|
25
|
+
? from(config.resolveInitialContext(args)).pipe(
|
|
26
|
+
// filter out invalid context items
|
|
27
|
+
filter((item) => !!item), switchMap((item) =>
|
|
28
|
+
// set current context with validation and resolution
|
|
29
|
+
args.modules.context.setCurrentContext(item, {
|
|
30
|
+
validate: true,
|
|
31
|
+
resolve: true,
|
|
32
|
+
})))
|
|
33
|
+
: EMPTY; // if no initial context is available, complete immediately
|
|
34
|
+
// add teardown to resolve initial context
|
|
35
|
+
subscriber.add(resolveInitialContext$
|
|
36
|
+
.pipe(catchError((err) => {
|
|
37
|
+
console.warn('ContextModule.postInitialize', 'failed to resolve initial context', err);
|
|
38
|
+
// failed to resolve initial context, complete immediately
|
|
39
|
+
return EMPTY;
|
|
40
|
+
}))
|
|
41
|
+
.subscribe({
|
|
42
|
+
next: (item) => {
|
|
43
|
+
console.debug('ContextModule.postInitialize', `initial context was resolved to [${item ? item.id : 'none'}]`, item);
|
|
44
|
+
},
|
|
45
|
+
complete: () => {
|
|
46
|
+
// connect parent context if available when stream completes
|
|
47
|
+
if (config.connectParentContext !== false && parentProvider) {
|
|
48
|
+
provider.connectParentContext(parentProvider);
|
|
49
|
+
}
|
|
50
|
+
subscriber.complete();
|
|
51
|
+
},
|
|
52
|
+
}));
|
|
68
53
|
});
|
|
54
|
+
// add teardown to module
|
|
55
|
+
this.dispose = () => subscription.unsubscribe();
|
|
56
|
+
return provider;
|
|
69
57
|
},
|
|
70
58
|
};
|
|
71
59
|
export default module;
|
package/dist/esm/module.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"module.js","sourceRoot":"","sources":["../../src/module.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"module.js","sourceRoot":"","sources":["../../src/module.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,KAAK,EAAE,IAAI,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,MAAM,CAAC;AAQ5F,OAAO,EAAmC,yBAAyB,EAAE,MAAM,gBAAgB,CAAC;AAC5F,OAAO,EAAyB,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAK3E,MAAM,CAAC,MAAM,SAAS,GAAqB,SAAS,CAAC;AASrD,MAAM,CAAC,MAAM,MAAM,GAAkB;IACnC,IAAI,EAAE,SAAS;IACf,SAAS,EAAE,GAAG,EAAE,CAAC,IAAI,yBAAyB,EAAE;IAChD,UAAU,EAAE,KAAK,WAAW,IAAI;QAC9B,kCAAkC;QAClC,MAAM,MAAM,GAAG,MAAO,IAAI,CAAC,MAAoC,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC;QAEnF,gCAAgC;QAChC,MAAM,KAAK,GAAG,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,MAAM,IAAI,CAAC,eAAe,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;QAExF,2CAA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EAAE;oBACb,OAAO,CAAC,KAAK,CACX,8BAA8B,EAC9B,oCAAoC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC,MAAM,GAAG,EAC9D,IAAI,CACL,CAAC;gBACJ,CAAC;gBACD,QAAQ,EAAE,GAAG,EAAE;oBACb,4DAA4D;oBAC5D,IAAI,MAAM,CAAC,oBAAoB,KAAK,KAAK,IAAI,cAAc,EAAE,CAAC;wBAC5D,QAAQ,CAAC,oBAAoB,CAAC,cAAc,CAAC,CAAC;oBAChD,CAAC;oBACD,UAAU,CAAC,QAAQ,EAAE,CAAC;gBACxB,CAAC;aACF,CAAC,CACL,CAAC;QACJ,CAAC,CAAC,CAAC;QAEL,yBAAyB;QACzB,IAAI,CAAC,OAAO,GAAG,GAAG,EAAE,CAAC,YAAY,CAAC,WAAW,EAAE,CAAC;QAEhD,OAAO,QAAQ,CAAC;IAClB,CAAC;CACF,CAAC;AAQF,eAAe,MAAM,CAAC"}
|
package/dist/esm/selectors.js
CHANGED
|
@@ -1,44 +1,31 @@
|
|
|
1
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
-
});
|
|
9
|
-
};
|
|
10
1
|
/**
|
|
11
2
|
* Parses the context type from the response of the GetContext API.
|
|
12
3
|
*
|
|
13
4
|
* @param type The type property from the GetContext response.
|
|
14
5
|
* @returns The parsed context item type.
|
|
15
6
|
*/
|
|
16
|
-
const parseContextType = (type) => {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
parentTypeIds: (_a = type.parentTypeIds) !== null && _a !== void 0 ? _a : [],
|
|
22
|
-
});
|
|
23
|
-
};
|
|
7
|
+
const parseContextType = (type) => ({
|
|
8
|
+
id: type.id,
|
|
9
|
+
isChildType: type.isChildType,
|
|
10
|
+
parentTypeIds: type.parentTypeIds ?? [],
|
|
11
|
+
});
|
|
24
12
|
/**
|
|
25
13
|
* Parses an ApiContextEntity object into a ContextItem object.
|
|
26
14
|
* @param item The ApiContextEntity object to parse.
|
|
27
15
|
* @returns The parsed ContextItem object.
|
|
28
16
|
*/
|
|
29
17
|
const parseContextItem = (item) => {
|
|
30
|
-
var _a, _b, _c, _d;
|
|
31
18
|
return {
|
|
32
19
|
id: item.id,
|
|
33
|
-
externalId:
|
|
20
|
+
externalId: item.externalId ?? undefined,
|
|
34
21
|
isActive: item.isActive,
|
|
35
22
|
isDeleted: item.isDeleted,
|
|
36
23
|
created: new Date(item.created),
|
|
37
|
-
source:
|
|
38
|
-
title:
|
|
24
|
+
source: item.source ?? undefined,
|
|
25
|
+
title: item.title ?? undefined,
|
|
39
26
|
type: parseContextType(item.type),
|
|
40
27
|
// TODO
|
|
41
|
-
value:
|
|
28
|
+
value: item.value ?? {},
|
|
42
29
|
};
|
|
43
30
|
};
|
|
44
31
|
/**
|
|
@@ -46,26 +33,26 @@ const parseContextItem = (item) => {
|
|
|
46
33
|
* @param response The response object containing the context item.
|
|
47
34
|
* @returns A promise that resolves to the context item.
|
|
48
35
|
*/
|
|
49
|
-
export const getContextSelector = (response) =>
|
|
50
|
-
const result = (
|
|
36
|
+
export const getContextSelector = async (response) => {
|
|
37
|
+
const result = (await response.json());
|
|
51
38
|
return parseContextItem(result);
|
|
52
|
-
}
|
|
39
|
+
};
|
|
53
40
|
/**
|
|
54
41
|
* Parse the response from the QueryContext API into an array of context items.
|
|
55
42
|
* @param response The response object.
|
|
56
43
|
* @returns A promise that resolves to an array of context items.
|
|
57
44
|
*/
|
|
58
|
-
export const queryContextSelector = (response) =>
|
|
59
|
-
const result = (
|
|
45
|
+
export const queryContextSelector = async (response) => {
|
|
46
|
+
const result = (await response.json());
|
|
60
47
|
return result.map(parseContextItem);
|
|
61
|
-
}
|
|
48
|
+
};
|
|
62
49
|
/**
|
|
63
50
|
* Parse the response from the RelatedContext API into an array of context items.
|
|
64
51
|
* @param response The response object containing the related context items.
|
|
65
52
|
* @returns A promise that resolves to an array of ContextItem objects.
|
|
66
53
|
*/
|
|
67
|
-
export const relatedContextSelector = (response) =>
|
|
68
|
-
const result = (
|
|
54
|
+
export const relatedContextSelector = async (response) => {
|
|
55
|
+
const result = (await response.json());
|
|
69
56
|
return result.map(parseContextItem);
|
|
70
|
-
}
|
|
57
|
+
};
|
|
71
58
|
//# sourceMappingURL=selectors.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"selectors.js","sourceRoot":"","sources":["../../src/selectors.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"selectors.js","sourceRoot":"","sources":["../../src/selectors.ts"],"names":[],"mappings":"AASA;;;;;GAKG;AACH,MAAM,gBAAgB,GAAG,CAAC,IAAsC,EAAmB,EAAE,CAAC,CAAC;IACrF,EAAE,EAAE,IAAI,CAAC,EAAE;IACX,WAAW,EAAE,IAAI,CAAC,WAAW;IAC7B,aAAa,EAAE,IAAI,CAAC,aAAa,IAAI,EAAE;CACxC,CAAC,CAAC;AAEH;;;;GAIG;AACH,MAAM,gBAAgB,GAAG,CAAC,IAAqC,EAAe,EAAE;IAC9E,OAAO;QACL,EAAE,EAAE,IAAI,CAAC,EAAE;QACX,UAAU,EAAE,IAAI,CAAC,UAAU,IAAI,SAAS;QACxC,QAAQ,EAAE,IAAI,CAAC,QAAQ;QACvB,SAAS,EAAE,IAAI,CAAC,SAAS;QACzB,OAAO,EAAE,IAAI,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC;QAC/B,MAAM,EAAE,IAAI,CAAC,MAAM,IAAI,SAAS;QAChC,KAAK,EAAE,IAAI,CAAC,KAAK,IAAI,SAAS;QAC9B,IAAI,EAAE,gBAAgB,CAAC,IAAI,CAAC,IAAI,CAAC;QACjC,OAAO;QACP,KAAK,EAAE,IAAI,CAAC,KAAK,IAAI,EAAE;KACxB,CAAC;AACJ,CAAC,CAAC;AAEF;;;;GAIG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG,KAAK,EAAE,QAAkB,EAAwB,EAAE;IACnF,MAAM,MAAM,GAAG,CAAC,MAAM,QAAQ,CAAC,IAAI,EAAE,CAA6B,CAAC;IACnE,OAAO,gBAAgB,CAAC,MAAM,CAAC,CAAC;AAClC,CAAC,CAAC;AAEF;;;;GAIG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAG,KAAK,EAAE,QAAkB,EAA0B,EAAE;IACvF,MAAM,MAAM,GAAG,CAAC,MAAM,QAAQ,CAAC,IAAI,EAAE,CAA+B,CAAC;IACrE,OAAO,MAAM,CAAC,GAAG,CAAC,gBAAgB,CAAC,CAAC;AACtC,CAAC,CAAC;AAEF;;;;GAIG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAG,KAAK,EAAE,QAAkB,EAA0B,EAAE;IACzF,MAAM,MAAM,GAAG,CAAC,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAiC,CAAC;IACvE,OAAO,MAAM,CAAC,GAAG,CAAC,gBAAgB,CAAC,CAAC;AACtC,CAAC,CAAC"}
|
|
@@ -26,7 +26,7 @@ export const extractContextIdFromPath = (path, matcher = matchGUID) => path
|
|
|
26
26
|
const validateContextId = (contextId) => !!contextId.match(matchGUID);
|
|
27
27
|
export function resolveContextFromPath(context, args) {
|
|
28
28
|
return (path) => {
|
|
29
|
-
const { extract = extractContextIdFromPath, validate = validateContextId } = args
|
|
29
|
+
const { extract = extractContextIdFromPath, validate = validateContextId } = args ?? {};
|
|
30
30
|
const contextId = extract(path);
|
|
31
31
|
if (!contextId) {
|
|
32
32
|
return EMPTY;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resolve-context-from-path.js","sourceRoot":"","sources":["../../../src/utils/resolve-context-from-path.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAmB,MAAM,MAAM,CAAC;AAyB9C,eAAe;AACf,MAAM,SAAS,GACb,uGAAuG,CAAC;AAE1G;;;;;;;;;;;;;;GAcG;AACH,MAAM,CAAC,MAAM,wBAAwB,GAAG,CACtC,IAAY,EACZ,UAAkB,SAAS,EACP,EAAE,CACtB,IAAI;IACF,yBAAyB;KACxB,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC;IACpB,wBAAwB;KACvB,KAAK,CAAC,GAAG,CAAC;IACX,wDAAwD;KACvD,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC;AAEnC,MAAM,iBAAiB,GAAG,CAAC,SAAiB,EAAW,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC;AAkDvF,MAAM,UAAU,sBAAsB,CACpC,OAAkC,EAClC,IAA6B;IAE7B,OAAO,CAAC,IAAY,EAAE,EAAE;QACtB,MAAM,EAAE,OAAO,GAAG,wBAAwB,EAAE,QAAQ,GAAG,iBAAiB,EAAE,GAAG,IAAI,
|
|
1
|
+
{"version":3,"file":"resolve-context-from-path.js","sourceRoot":"","sources":["../../../src/utils/resolve-context-from-path.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAmB,MAAM,MAAM,CAAC;AAyB9C,eAAe;AACf,MAAM,SAAS,GACb,uGAAuG,CAAC;AAE1G;;;;;;;;;;;;;;GAcG;AACH,MAAM,CAAC,MAAM,wBAAwB,GAAG,CACtC,IAAY,EACZ,UAAkB,SAAS,EACP,EAAE,CACtB,IAAI;IACF,yBAAyB;KACxB,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC;IACpB,wBAAwB;KACvB,KAAK,CAAC,GAAG,CAAC;IACX,wDAAwD;KACvD,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC;AAEnC,MAAM,iBAAiB,GAAG,CAAC,SAAiB,EAAW,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC;AAkDvF,MAAM,UAAU,sBAAsB,CACpC,OAAkC,EAClC,IAA6B;IAE7B,OAAO,CAAC,IAAY,EAAE,EAAE;QACtB,MAAM,EAAE,OAAO,GAAG,wBAAwB,EAAE,QAAQ,GAAG,iBAAiB,EAAE,GAAG,IAAI,IAAI,EAAE,CAAC;QACxF,MAAM,SAAS,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;QAChC,IAAI,CAAC,SAAS,EAAE,CAAC;YACf,OAAO,KAAK,CAAC;QACf,CAAC;QACD,IAAI,QAAQ,CAAC,SAAS,CAAC,EAAE,CAAC;YACxB,OAAO,OAAO,CAAC,aAAa,CAAC,cAAc,CAAC,SAAS,CAAC,CAAC;QACzD,CAAC;QAED,MAAM,KAAK,CAAC,+BAA+B,SAAS,gBAAgB,IAAI,GAAG,CAAC,CAAC;IAC/E,CAAC,CAAC;AACJ,CAAC;AAED,eAAe,sBAAsB,CAAC"}
|
|
@@ -7,7 +7,7 @@ import { resolveContextFromPath } from './resolve-context-from-path';
|
|
|
7
7
|
* @returns An Observable of the resolved initial context.
|
|
8
8
|
*/
|
|
9
9
|
export const resolveContextFromParent = ({ ref }) => {
|
|
10
|
-
const parentContext = ref
|
|
10
|
+
const parentContext = ref?.context;
|
|
11
11
|
// check if the parent has context module
|
|
12
12
|
if (!parentContext) {
|
|
13
13
|
throw Error(['resolveContextFromNavigation', 'ref does not support context!'].join('\n'));
|
|
@@ -24,12 +24,12 @@ export const resolveContextFromParent = ({ ref }) => {
|
|
|
24
24
|
* @returns A function that accepts the module's reference and modules, and returns an Observable of the resolved initial context.
|
|
25
25
|
*/
|
|
26
26
|
export const resolveInitialContext = (options) => ({ ref, modules }) => {
|
|
27
|
-
var _a, _b;
|
|
28
27
|
const { context, navigation } = modules;
|
|
29
28
|
// create a path resolver from the context module
|
|
30
|
-
const pathResolver = resolveContextFromPath(context, options
|
|
29
|
+
const pathResolver = resolveContextFromPath(context, options?.path);
|
|
31
30
|
// use the path from the navigation module, or the path from the parent navigation module
|
|
32
|
-
const pathname =
|
|
31
|
+
const pathname = navigation?.path.pathname ??
|
|
32
|
+
ref.navigation?.path.pathname;
|
|
33
33
|
// try to resolve the context from the path, and if that fails, try to resolve the context from the parent
|
|
34
34
|
return concat(pathname ? pathResolver(pathname) : EMPTY, resolveContextFromParent({ ref, modules })).pipe(first());
|
|
35
35
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resolve-initial-context.js","sourceRoot":"","sources":["../../../src/utils/resolve-initial-context.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,EAAE,EAAE,MAAM,MAAM,CAAC;AAEhD,OAAO,EAA+B,sBAAsB,EAAE,MAAM,6BAA6B,CAAC;AAGlG;;;;;GAKG;AACH,MAAM,CAAC,MAAM,wBAAwB,GAAiD,CAAC,EAAE,GAAG,EAAE,EAAE,EAAE;IAChG,MAAM,aAAa,GAAI,GAAwC,
|
|
1
|
+
{"version":3,"file":"resolve-initial-context.js","sourceRoot":"","sources":["../../../src/utils/resolve-initial-context.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,EAAE,EAAE,MAAM,MAAM,CAAC;AAEhD,OAAO,EAA+B,sBAAsB,EAAE,MAAM,6BAA6B,CAAC;AAGlG;;;;;GAKG;AACH,MAAM,CAAC,MAAM,wBAAwB,GAAiD,CAAC,EAAE,GAAG,EAAE,EAAE,EAAE;IAChG,MAAM,aAAa,GAAI,GAAwC,EAAE,O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