@equinor/fusion-framework-module-context 7.0.3 → 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 +28 -11
- package/README.md +168 -16
- package/dist/esm/ContextConfigBuilder.js +7 -0
- package/dist/esm/ContextConfigBuilder.js.map +1 -1
- package/dist/esm/configurator.js +31 -0
- package/dist/esm/configurator.js.map +1 -1
- package/dist/esm/index.js +12 -0
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/module.js +6 -0
- package/dist/esm/module.js.map +1 -1
- package/dist/esm/utils/index.js +10 -0
- package/dist/esm/utils/index.js.map +1 -1
- package/dist/esm/version.js +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/types/ContextConfigBuilder.d.ts +15 -0
- package/dist/types/ContextProvider.d.ts +37 -0
- package/dist/types/configurator.d.ts +134 -4
- package/dist/types/index.d.ts +12 -0
- package/dist/types/module.d.ts +11 -0
- package/dist/types/types.d.ts +22 -0
- package/dist/types/utils/index.d.ts +10 -0
- package/dist/types/version.d.ts +1 -1
- package/package.json +9 -9
- package/src/ContextConfigBuilder.ts +15 -0
- package/src/ContextProvider.ts +37 -7
- package/src/configurator.ts +137 -4
- package/src/index.ts +13 -0
- package/src/module.ts +11 -0
- package/src/types.ts +22 -0
- package/src/utils/index.ts +10 -0
- package/src/version.ts +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,31 @@
|
|
|
1
1
|
# Change Log
|
|
2
2
|
|
|
3
|
+
## 8.0.0
|
|
4
|
+
|
|
5
|
+
### Major Changes
|
|
6
|
+
|
|
7
|
+
- abffa53: Major version bump for Fusion Framework React 19 release.
|
|
8
|
+
|
|
9
|
+
All packages are bumped to the next major version as part of the React 19 upgrade. This release drops support for React versions below 18 and includes breaking changes across the framework.
|
|
10
|
+
|
|
11
|
+
**Breaking changes:**
|
|
12
|
+
- Peer dependencies now require React 18 or 19 (`^18.0.0 || ^19.0.0`)
|
|
13
|
+
- React Router upgraded from v6 to v7
|
|
14
|
+
- Navigation module refactored with new history API
|
|
15
|
+
- `renderComponent` and `renderApp` now use `createRoot` API
|
|
16
|
+
|
|
17
|
+
**Migration:**
|
|
18
|
+
- Update your React version to 18.0.0 or higher before upgrading
|
|
19
|
+
- Replace `NavigationProvider.createRouter()` with `@equinor/fusion-framework-react-router`
|
|
20
|
+
- See individual package changelogs for package-specific migration steps
|
|
21
|
+
|
|
22
|
+
### Patch Changes
|
|
23
|
+
|
|
24
|
+
- Updated dependencies [abffa53]
|
|
25
|
+
- Updated dependencies [abffa53]
|
|
26
|
+
- @equinor/fusion-framework-module@6.0.0
|
|
27
|
+
- @equinor/fusion-query@7.0.0
|
|
28
|
+
|
|
3
29
|
## 7.0.3
|
|
4
30
|
|
|
5
31
|
### Patch Changes
|
|
@@ -28,14 +54,12 @@
|
|
|
28
54
|
- [#3515](https://github.com/equinor/fusion-framework/pull/3515) [`6cb288b`](https://github.com/equinor/fusion-framework/commit/6cb288b9e1ec4fae68ae6899735c176837bb4275) Thanks [@odinr](https://github.com/odinr)! - ## Global Biome Configuration Modernization
|
|
29
55
|
|
|
30
56
|
**Workspace-wide changes:**
|
|
31
|
-
|
|
32
57
|
- Remove 19 rule overrides from `biome.json` to use Biome's strict "error" defaults
|
|
33
58
|
- Enable `correctness/useUniqueElementIds` accessibility rule globally
|
|
34
59
|
- Reduce configuration size by 40% (60+ → ~35 lines)
|
|
35
60
|
- Eliminate all custom linting rule customizations
|
|
36
61
|
|
|
37
62
|
**Package-specific changes:**
|
|
38
|
-
|
|
39
63
|
- Replace static IDs with React `useId()` hooks in bookmark and dev-portal components
|
|
40
64
|
- Fix `suspicious/noAssignInExpressions` violations in context, legacy-interopt, and observable packages
|
|
41
65
|
- Update 11 React components for accessibility compliance
|
|
@@ -135,18 +159,15 @@
|
|
|
135
159
|
### Minor Changes
|
|
136
160
|
|
|
137
161
|
- [#2930](https://github.com/equinor/fusion-framework/pull/2930) [`5da6b2d`](https://github.com/equinor/fusion-framework/commit/5da6b2d4cb7fb93ff3784753a0052d3362ab828d) Thanks [@odinr](https://github.com/odinr)! - **@equinor/fusion-framework-react:**
|
|
138
|
-
|
|
139
162
|
- Enhanced `useAppContextNavigation` to support custom context path extraction and generation. This allows for more flexible navigation handling based on application-specific requirements.
|
|
140
163
|
|
|
141
164
|
**@equinor/fusion-framework-module-context:**
|
|
142
|
-
|
|
143
165
|
- Added support for custom context path extraction and generation in `ContextConfigBuilder`, `ContextProvider`, and `ContextModuleConfigurator`.
|
|
144
166
|
- Introduced `setContextPathExtractor` and `setContextPathGenerator` methods in `ContextConfigBuilder` to allow developers to define custom logic for extracting and generating context paths.
|
|
145
167
|
- Updated `ContextProvider` to utilize `extractContextIdFromPath` and `generatePathFromContext` from the configuration, enabling dynamic path handling.
|
|
146
168
|
- Enhanced `ContextModuleConfigurator` to include `extractContextIdFromPath` and `generatePathFromContext` in the module configuration.
|
|
147
169
|
|
|
148
170
|
If you are using `@equinor/fusion-framework-module-context` and need custom logic for context path handling:
|
|
149
|
-
|
|
150
171
|
1. Use `setContextPathExtractor` to define how to extract context IDs from paths.
|
|
151
172
|
2. Use `setContextPathGenerator` to define how to generate paths based on context items.
|
|
152
173
|
|
|
@@ -173,11 +194,11 @@
|
|
|
173
194
|
// Custom logic to generate path from context
|
|
174
195
|
const path = contextProvider.generatePathFromContext?.(
|
|
175
196
|
context,
|
|
176
|
-
location.pathname
|
|
197
|
+
location.pathname,
|
|
177
198
|
);
|
|
178
199
|
return path ?? fallbackPathGenerator(context, location.pathname);
|
|
179
200
|
}),
|
|
180
|
-
filter(Boolean)
|
|
201
|
+
filter(Boolean),
|
|
181
202
|
)
|
|
182
203
|
.subscribe((path) => history.push(path));
|
|
183
204
|
```
|
|
@@ -277,7 +298,6 @@
|
|
|
277
298
|
- [#2320](https://github.com/equinor/fusion-framework/pull/2320) [`1dd85f3`](https://github.com/equinor/fusion-framework/commit/1dd85f3a408a73df556d1812a5f280945cc100ee) Thanks [@odinr](https://github.com/odinr)! - Removed the `removeComments` option from the `tsconfig.base.json` file.
|
|
278
299
|
|
|
279
300
|
Removing the `removeComments` option allows TypeScript to preserve comments in the compiled JavaScript output. This can be beneficial for several reasons:
|
|
280
|
-
|
|
281
301
|
1. Improved debugging: Preserved comments can help developers understand the code better during debugging sessions.
|
|
282
302
|
2. Documentation: JSDoc comments and other important code documentation will be retained in the compiled output.
|
|
283
303
|
3. Source map accuracy: Keeping comments can lead to more accurate source maps, which is crucial for debugging and error tracking.
|
|
@@ -406,7 +426,6 @@
|
|
|
406
426
|
### Minor Changes
|
|
407
427
|
|
|
408
428
|
- [#1760](https://github.com/equinor/fusion-framework/pull/1760) [`6e6ee6b`](https://github.com/equinor/fusion-framework/commit/6e6ee6b7ce280820111e8b98ac8377efb15808ef) Thanks [@asbjornhaland](https://github.com/asbjornhaland)! - - Add FusionContextSearchError.
|
|
409
|
-
|
|
410
429
|
- Potential _BREAKING_:
|
|
411
430
|
- Error in `ContextProvider.ts` are now unwrapped if the thrown error is
|
|
412
431
|
`QueryClientError`.
|
|
@@ -540,7 +559,6 @@
|
|
|
540
559
|
### Patch Changes
|
|
541
560
|
|
|
542
561
|
- [#905](https://github.com/equinor/fusion-framework/pull/905) [`a7858a1c`](https://github.com/equinor/fusion-framework/commit/a7858a1c01542e2dc94370709f122b4b99c3219c) Thanks [@odinr](https://github.com/odinr)! - **🚧 Chore: dedupe packages**
|
|
543
|
-
|
|
544
562
|
- align all versions of typescript
|
|
545
563
|
- update types to build
|
|
546
564
|
- a couple of typecasts did not [satisfies](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-5-0.html#satisfies-support-in-jsdoc) and was recasted as `unknwon`, marked with `TODO`, should be fixed in future
|
|
@@ -550,7 +568,6 @@
|
|
|
550
568
|
### Patch Changes
|
|
551
569
|
|
|
552
570
|
- [#898](https://github.com/equinor/fusion-framework/pull/898) [`4551142e`](https://github.com/equinor/fusion-framework/commit/4551142ededdb2f1bf74eae552da26d28cd23057) Thanks [@odinr](https://github.com/odinr)! - feat(module-context): add config option for connection to parent context
|
|
553
|
-
|
|
554
571
|
- add attribute to config interface
|
|
555
572
|
- add setter on config builder
|
|
556
573
|
- add check for connecting to parent when creating provider
|
package/README.md
CHANGED
|
@@ -1,33 +1,185 @@
|
|
|
1
|
-
|
|
1
|
+
# @equinor/fusion-framework-module-context
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
It provides a structured way to handle context information to enrich user experiences and facilitate data sharing across different components of the application.
|
|
3
|
+
Context module for the Fusion Framework. Manages the active context (project, facility, contract, etc.) within Fusion-based applications and portals, providing query, validation, resolution, and parent–child synchronization out of the box.
|
|
5
4
|
|
|
6
|
-
##
|
|
5
|
+
## When to use
|
|
6
|
+
|
|
7
|
+
Use this module when your application or portal needs to:
|
|
8
|
+
|
|
9
|
+
- set, read, or clear the active context (e.g. selecting a project)
|
|
10
|
+
- search and filter available context items from the Fusion context API
|
|
11
|
+
- validate whether a given context item matches the allowed context types
|
|
12
|
+
- resolve context across parent–child provider boundaries (portal → app)
|
|
13
|
+
- deep-link by extracting a context ID from the URL path
|
|
14
|
+
|
|
15
|
+
> **Application developers** will typically use the higher-level
|
|
16
|
+
> `@equinor/fusion-framework-react-app/context` package, which wraps this
|
|
17
|
+
> module with React hooks and providers.
|
|
18
|
+
>
|
|
19
|
+
> **Portal developers** will use `@equinor/fusion-framework-react/context`
|
|
20
|
+
> for the same purpose at the portal level.
|
|
21
|
+
|
|
22
|
+
## Key concepts
|
|
23
|
+
|
|
24
|
+
| Concept | Description |
|
|
25
|
+
|---|---|
|
|
26
|
+
| **ContextItem** | A typed record representing a single context entity (project, facility, etc.). |
|
|
27
|
+
| **ContextProvider** | Runtime service exposing query, set, validate, resolve, and event APIs. |
|
|
28
|
+
| **ContextConfigBuilder** | Fluent builder for configuring context types, filters, clients, and hooks. |
|
|
29
|
+
| **enableContext** | Helper that registers the module on a modules configurator. |
|
|
30
|
+
| **Context resolution** | Automatic lookup of related context items when a context type does not match the configured types. |
|
|
31
|
+
| **Parent connection** | Bi-directional sync between a parent portal context and a child app context. |
|
|
32
|
+
|
|
33
|
+
## Quick start
|
|
7
34
|
|
|
8
35
|
```ts
|
|
9
36
|
import { enableContext } from '@equinor/fusion-framework-module-context';
|
|
10
37
|
|
|
11
|
-
const configure = (configurator
|
|
38
|
+
export const configure = (configurator) => {
|
|
12
39
|
enableContext(configurator, (builder) => {
|
|
13
|
-
//
|
|
40
|
+
// only accept ProjectMaster context items
|
|
41
|
+
builder.setContextType(['ProjectMaster']);
|
|
14
42
|
});
|
|
15
43
|
};
|
|
16
44
|
```
|
|
17
45
|
|
|
18
|
-
|
|
46
|
+
Once initialized, access the provider from the module instance:
|
|
47
|
+
|
|
48
|
+
```ts
|
|
49
|
+
// observe context changes
|
|
50
|
+
modules.context.currentContext$.subscribe((ctx) => {
|
|
51
|
+
console.log('context changed', ctx);
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
// search for context items
|
|
55
|
+
const items = await modules.context.queryContextAsync('Johan');
|
|
56
|
+
|
|
57
|
+
// set context by item
|
|
58
|
+
await modules.context.setCurrentContextAsync(items[0]);
|
|
59
|
+
|
|
60
|
+
// set context by ID
|
|
61
|
+
await modules.context.setCurrentContextByIdAsync('7fd97952-...');
|
|
62
|
+
|
|
63
|
+
// clear the active context
|
|
64
|
+
modules.context.clearCurrentContext();
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
## Configuration
|
|
68
|
+
|
|
69
|
+
All configuration flows through `enableContext` → `ContextConfigBuilder`:
|
|
70
|
+
|
|
71
|
+
```ts
|
|
72
|
+
enableContext(configurator, (builder) => {
|
|
73
|
+
// restrict accepted context types
|
|
74
|
+
builder.setContextType(['ProjectMaster', 'Facility']);
|
|
75
|
+
|
|
76
|
+
// post-query filter
|
|
77
|
+
builder.setContextFilter((items) => items.filter((i) => i.isActive));
|
|
78
|
+
|
|
79
|
+
// custom parameter mapping for the search API
|
|
80
|
+
builder.setContextParameterFn(({ search, type }) => ({
|
|
81
|
+
search,
|
|
82
|
+
filter: { type },
|
|
83
|
+
}));
|
|
84
|
+
|
|
85
|
+
// custom validation logic
|
|
86
|
+
builder.setValidateContext(function (item) {
|
|
87
|
+
return item !== null && this.validateContext(item);
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
// custom context resolution
|
|
91
|
+
builder.setResolveContext(function (item) {
|
|
92
|
+
return this.relatedContexts({ item, filter: { type: ['ProjectMaster'] } });
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
// connect (or disconnect) from parent context
|
|
96
|
+
// when enabled (default), onParentContextChanged fires before mirroring the parent's context locally
|
|
97
|
+
builder.connectParentContext(false);
|
|
98
|
+
|
|
99
|
+
// path ↔ context integration
|
|
100
|
+
// the default resolver uses extractContextIdFromPath to pull a GUID from the URL,
|
|
101
|
+
// then fetches the matching context item — see resolveInitialContext in utils
|
|
102
|
+
builder.setContextPathExtractor((path) => path.split('/')[2]);
|
|
103
|
+
builder.setContextPathGenerator((ctx, path) =>
|
|
104
|
+
path.replace(/\/context\/[^/]+/, `/context/${ctx.id}`),
|
|
105
|
+
);
|
|
106
|
+
|
|
107
|
+
// provide a fully custom context client
|
|
108
|
+
builder.setContextClient({
|
|
109
|
+
get: (args) => fetch(`/api/context/${args.id}`).then((r) => r.json()),
|
|
110
|
+
query: (args) => fetch(`/api/context?q=${args.search}`).then((r) => r.json()),
|
|
111
|
+
});
|
|
112
|
+
});
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
### Configuration reference
|
|
116
|
+
|
|
117
|
+
| Builder method | Purpose |
|
|
118
|
+
|---|---|
|
|
119
|
+
| `setContextType(types)` | Allowed context type IDs for validation |
|
|
120
|
+
| `setContextFilter(fn)` | Post-query result filter |
|
|
121
|
+
| `setContextParameterFn(fn)` | Maps search + type to API query params |
|
|
122
|
+
| `setValidateContext(fn)` | Custom validation (`this` = provider) |
|
|
123
|
+
| `setResolveContext(fn)` | Custom resolution (`this` = provider) |
|
|
124
|
+
| `connectParentContext(bool)` | Enable/disable parent context sync (fires `onParentContextChanged` on change) |
|
|
125
|
+
| `setContextPathExtractor(fn)` | Extract context ID from URL path |
|
|
126
|
+
| `setContextPathGenerator(fn)` | Generate URL path from context item |
|
|
127
|
+
| `setResolveInitialContext(fn)` | Override initial context resolution (default uses `extractContextIdFromPath` → `resolveContextFromPath`) |
|
|
128
|
+
| `setContextClient(client)` | Custom get/query/related clients |
|
|
129
|
+
|
|
130
|
+
## Events
|
|
131
|
+
|
|
132
|
+
The context module dispatches events via the `@equinor/fusion-framework-module-event` system. All events are scoped to the `ContextProvider` source.
|
|
133
|
+
|
|
134
|
+
| Event | When | Cancelable |
|
|
135
|
+
|---|---|---|
|
|
136
|
+
| `onCurrentContextChange` | Before the current context is updated | Yes |
|
|
137
|
+
| `onCurrentContextChanged` | After the current context has changed | No |
|
|
138
|
+
| `onParentContextChanged` | Before a parent context change is mirrored locally | Yes |
|
|
139
|
+
| `onSetContextResolve` | Before context resolution begins | Yes |
|
|
140
|
+
| `onSetContextResolved` | After context resolution completes | Yes |
|
|
141
|
+
| `onSetContextValidationFailed` | When validation fails (no resolution) | No |
|
|
142
|
+
| `onSetContextResolveFailed` | When resolution fails with an error | No |
|
|
143
|
+
|
|
144
|
+
```ts
|
|
145
|
+
modules.event.addEventListener('onCurrentContextChanged', (e) => {
|
|
146
|
+
console.log('previous:', e.detail.previous);
|
|
147
|
+
console.log('next:', e.detail.next);
|
|
148
|
+
});
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
## Errors
|
|
152
|
+
|
|
153
|
+
The module exports `FusionContextSearchError` (from `@equinor/fusion-framework-module-context/errors.js`) for search-related failures:
|
|
154
|
+
|
|
155
|
+
```ts
|
|
156
|
+
import { FusionContextSearchError } from '@equinor/fusion-framework-module-context/errors.js';
|
|
157
|
+
|
|
158
|
+
try {
|
|
159
|
+
await modules.context.queryContextAsync('...');
|
|
160
|
+
} catch (err) {
|
|
161
|
+
if (err instanceof FusionContextSearchError) {
|
|
162
|
+
console.error(err.title, err.description);
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
```
|
|
19
166
|
|
|
20
|
-
|
|
21
|
-
- query context items based on search strings
|
|
22
|
-
- filter context items based on type
|
|
23
|
-
- validate context items against allowed types
|
|
24
|
-
- resolving related context items
|
|
167
|
+
## Utilities
|
|
25
168
|
|
|
26
|
-
|
|
169
|
+
Additional helpers are available from `@equinor/fusion-framework-module-context/utils`:
|
|
27
170
|
|
|
28
|
-
|
|
171
|
+
| Export | Purpose |
|
|
172
|
+
|---|---|
|
|
173
|
+
| `enableContext` | Register the context module on a configurator |
|
|
174
|
+
| `resolveInitialContext` | Default initial-context resolver (path → parent fallback) |
|
|
175
|
+
| `extractContextIdFromPath` | Extract a GUID-format context ID from a URL path |
|
|
176
|
+
| `resolveContextFromPath` | Create a resolver function that fetches a context item from a URL path |
|
|
29
177
|
|
|
30
|
-
|
|
178
|
+
## Package exports
|
|
31
179
|
|
|
32
|
-
|
|
180
|
+
| Specifier | Description |
|
|
181
|
+
|---|---|
|
|
182
|
+
| `@equinor/fusion-framework-module-context` | Main entry — module, provider, configurator, types |
|
|
183
|
+
| `@equinor/fusion-framework-module-context/errors.js` | `FusionContextSearchError` |
|
|
184
|
+
| `@equinor/fusion-framework-module-context/utils` | Utility functions for path resolution and enablement |
|
|
33
185
|
|
|
@@ -101,6 +101,13 @@ export class ContextConfigBuilder {
|
|
|
101
101
|
setContextPathGenerator(fn) {
|
|
102
102
|
this.config.generatePathFromContext = fn;
|
|
103
103
|
}
|
|
104
|
+
/**
|
|
105
|
+
* Sets the function used to resolve the initial context during module post-initialization.
|
|
106
|
+
*
|
|
107
|
+
* @param fn - A function that returns an observable input emitting the initial context item.
|
|
108
|
+
* The default resolver extracts a context ID from the navigation path, falling
|
|
109
|
+
* back to the parent provider's current context.
|
|
110
|
+
*/
|
|
104
111
|
setResolveInitialContext(fn) {
|
|
105
112
|
this.config.resolveInitialContext = fn;
|
|
106
113
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ContextConfigBuilder.js","sourceRoot":"","sources":["../../src/ContextConfigBuilder.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"ContextConfigBuilder.js","sourceRoot":"","sources":["../../src/ContextConfigBuilder.ts"],"names":[],"mappings":"AA+BA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,MAAM,OAAO,oBAAoB;IAUtB;IAHT,KAAK,CAAQ;IACb,YACE,IAAW,EACJ,SAAuC,EAAE;QAAzC,WAAM,GAAN,MAAM,CAAmC;QAEhD,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC;IACpB,CAAC;IAQD,eAAe,CAAC,MAAc;QAC5B,OAAO,IAAI,CAAC,KAAK,CAAC,eAAe,CAAC,MAAM,CAAC,CAAC;IAC5C,CAAC;IAED;;;;OAIG;IACH,cAAc,CAAC,IAAwC;QACrD,IAAI,CAAC,MAAM,CAAC,WAAW,GAAG,IAAI,CAAC;IACjC,CAAC;IAED;;;;OAIG;IACH,gBAAgB,CAAC,MAA4C;QAC3D,IAAI,CAAC,MAAM,CAAC,aAAa,GAAG,MAAM,CAAC;IACrC,CAAC;IAED;;;;OAIG;IACH,oBAAoB,CAAC,OAAoD;QACvE,IAAI,CAAC,MAAM,CAAC,oBAAoB,GAAG,OAAO,CAAC;IAC7C,CAAC;IAED;;;;OAIG;IACH,qBAAqB,CAAC,EAA6C;QACjE,IAAI,CAAC,MAAM,CAAC,kBAAkB,GAAG,EAAE,CAAC;IACtC,CAAC;IAED;;;;OAIG;IACH,kBAAkB,CAAC,EAA0C;QAC3D,IAAI,CAAC,MAAM,CAAC,eAAe,GAAG,EAAE,CAAC;IACnC,CAAC;IAED;;;;OAIG;IACH,iBAAiB,CAAC,EAAyC;QACzD,IAAI,CAAC,MAAM,CAAC,cAAc,GAAG,EAAE,CAAC;IAClC,CAAC;IAED;;;;;OAKG;IACH,uBAAuB,CAAC,EAAmD;QACzE,IAAI,CAAC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C;wBACnC,MAAM,EAAE;4BACN,EAAE,EAAE,MAAM,CAAC,OAAO;yBACnB;wBACD,MAAM;qBACP;oBACH,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC;QACvB,CAAC;IACH,CAAC;CACF"}
|
package/dist/esm/configurator.js
CHANGED
|
@@ -1,12 +1,32 @@
|
|
|
1
1
|
import { getContextSelector, queryContextSelector, relatedContextSelector } from './selectors';
|
|
2
2
|
import { ContextConfigBuilder } from './ContextConfigBuilder';
|
|
3
3
|
import resolveInitialContext from './utils/resolve-initial-context';
|
|
4
|
+
/**
|
|
5
|
+
* Default implementation of {@link IContextModuleConfigurator}.
|
|
6
|
+
*
|
|
7
|
+
* Collects {@link ContextConfigBuilderCallback} registrations and, when
|
|
8
|
+
* {@link createConfig} is called, runs them in order against a
|
|
9
|
+
* {@link ContextConfigBuilder} to produce the final {@link ContextModuleConfig}.
|
|
10
|
+
*
|
|
11
|
+
* If no custom client is configured, the configurator falls back to
|
|
12
|
+
* creating one from the {@link ServicesModule} API provider.
|
|
13
|
+
*/
|
|
4
14
|
export class ContextModuleConfigurator {
|
|
15
|
+
/** Default cache TTL (in ms) for context query results. */
|
|
5
16
|
defaultExpireTime = 1 * 60 * 1000;
|
|
6
17
|
#configBuilders = [];
|
|
18
|
+
/** @inheritdoc */
|
|
7
19
|
addConfigBuilder(init) {
|
|
8
20
|
this.#configBuilders.push(init);
|
|
9
21
|
}
|
|
22
|
+
/**
|
|
23
|
+
* Resolves the services API provider, preferring the local module
|
|
24
|
+
* instance and falling back to the parent module.
|
|
25
|
+
*
|
|
26
|
+
* @param init - Module initializer arguments.
|
|
27
|
+
* @returns The resolved API provider.
|
|
28
|
+
* @throws Error if no services module is available.
|
|
29
|
+
*/
|
|
10
30
|
async _getServiceProvider(init) {
|
|
11
31
|
if (init.hasModule('services')) {
|
|
12
32
|
return init.requireInstance('services');
|
|
@@ -17,6 +37,17 @@ export class ContextModuleConfigurator {
|
|
|
17
37
|
}
|
|
18
38
|
return parentServiceModule;
|
|
19
39
|
}
|
|
40
|
+
/**
|
|
41
|
+
* Runs all registered config builders and produces the final
|
|
42
|
+
* {@link ContextModuleConfig}.
|
|
43
|
+
*
|
|
44
|
+
* If no `resolveInitialContext` was set, the default path + parent
|
|
45
|
+
* resolver is used. If no `client` was set, one is created from the
|
|
46
|
+
* {@link ServicesModule} API provider.
|
|
47
|
+
*
|
|
48
|
+
* @param init - Module initializer arguments including dependency instances.
|
|
49
|
+
* @returns The fully resolved context module configuration.
|
|
50
|
+
*/
|
|
20
51
|
async createConfig(init) {
|
|
21
52
|
const config = await this.#configBuilders.reduce(async (cur, cb) => {
|
|
22
53
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
@@ -1 +1 @@
|
|
|
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;
|
|
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;AA2JpE;;;;;;;;;GASG;AACH,MAAM,OAAO,yBAAyB;IACpC,2DAA2D;IAC3D,iBAAiB,GAAG,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC;IAElC,eAAe,GAAwC,EAAE,CAAC;IAE1D,kBAAkB;IAClB,gBAAgB,CAAC,IAAkC;QACjD,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAClC,CAAC;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,EAAE,CAAC;QAEL,OAAO,MAA6B,CAAC;IACvC,CAAC;CACF;AAED,eAAe,yBAAyB,CAAC"}
|
package/dist/esm/index.js
CHANGED
|
@@ -1,3 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Context module for the Fusion Framework.
|
|
3
|
+
*
|
|
4
|
+
* Provides context management for Fusion-based applications and portals,
|
|
5
|
+
* including setting, querying, validating, and resolving context items.
|
|
6
|
+
*
|
|
7
|
+
* Use {@link enableContext} to register the module in a configurator,
|
|
8
|
+
* then access the {@link IContextProvider} from the module instance
|
|
9
|
+
* to interact with context state.
|
|
10
|
+
*
|
|
11
|
+
* @packageDocumentation
|
|
12
|
+
*/
|
|
1
13
|
export { ContextModuleConfigurator, } from './configurator';
|
|
2
14
|
export { ContextProvider } from './ContextProvider';
|
|
3
15
|
export { default, module as contextModule, moduleKey as contextModuleKey, } from './module';
|
package/dist/esm/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,yBAAyB,GAG1B,MAAM,gBAAgB,CAAC;AAExB,OAAO,EAAoB,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAEtE,OAAO,EACL,OAAO,EAEP,MAAM,IAAI,aAAa,EACvB,SAAS,IAAI,gBAAgB,GAC9B,MAAM,UAAU,CAAC;AAElB,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAEvD,cAAc,SAAS,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EACL,yBAAyB,GAG1B,MAAM,gBAAgB,CAAC;AAExB,OAAO,EAAoB,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAEtE,OAAO,EACL,OAAO,EAEP,MAAM,IAAI,aAAa,EACvB,SAAS,IAAI,gBAAgB,GAC9B,MAAM,UAAU,CAAC;AAElB,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAEvD,cAAc,SAAS,CAAC"}
|
package/dist/esm/module.js
CHANGED
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
import { catchError, EMPTY, from, Observable, switchMap, filter, Subscription } from 'rxjs';
|
|
2
2
|
import { ContextModuleConfigurator } from './configurator';
|
|
3
3
|
import { ContextProvider } from './ContextProvider';
|
|
4
|
+
/**
|
|
5
|
+
* Module registration key for the context module.
|
|
6
|
+
*
|
|
7
|
+
* Pass this value—or reference it as `contextModuleKey`—when you need to
|
|
8
|
+
* identify the context module by name at runtime (e.g., `hasModule(contextModuleKey)`).
|
|
9
|
+
*/
|
|
4
10
|
export const moduleKey = 'context';
|
|
5
11
|
/**
|
|
6
12
|
* The `module` object implements the `ContextModule` interface and provides the configuration,
|
package/dist/esm/module.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
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;
|
|
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;AAU3E;;;;;GAKG;AACH,MAAM,CAAC,MAAM,SAAS,GAAqB,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,CAAC,OAAO,CAAC,OAAO,CAAC,iBAAiB,CAAC,IAAI,EAAE;oBAC3C,QAAQ,EAAE,IAAI;oBACd,OAAO,EAAE,IAAI;iBACd,CAAC,CACH,CACF;gBACH,CAAC,CAAC,KAAK,CAAC,CAAC,2DAA2D;YAEtE,0CAA0C;YAC1C,UAAU,CAAC,GAAG,CACZ,sBAAsB;iBACnB,IAAI,CACH,UAAU,CAAC,CAAC,GAAG,EAAE,EAAE;gBACjB,OAAO,CAAC,IAAI,CACV,8BAA8B,EAC9B,mCAAmC,EACnC,GAAG,CACJ,CAAC;gBACF,0DAA0D;gBAC1D,OAAO,KAAK,CAAC;YACf,CAAC,CAAC,CACH;iBACA,SAAS,CAAC;gBACT,IAAI,EAAE,CAAC,IAAI,EAAE,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/utils/index.js
CHANGED
|
@@ -1,3 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Utility functions for context module configuration and initialization.
|
|
3
|
+
*
|
|
4
|
+
* - {@link enableContext} — register the context module on a configurator.
|
|
5
|
+
* - {@link resolveInitialContext} — default initial-context resolver (path → parent fallback).
|
|
6
|
+
* - {@link extractContextIdFromPath} — extract a GUID context ID from a URL path.
|
|
7
|
+
* - {@link resolveContextFromPath} — resolve a context item from a URL path.
|
|
8
|
+
*
|
|
9
|
+
* @packageDocumentation
|
|
10
|
+
*/
|
|
1
11
|
export { enableContext } from './enable-context';
|
|
2
12
|
export { resolveInitialContext } from './resolve-initial-context';
|
|
3
13
|
export { extractContextIdFromPath, resolveContextFromPath } from './resolve-context-from-path';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/utils/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,EAAE,qBAAqB,EAAE,MAAM,2BAA2B,CAAC;AAClE,OAAO,EAAE,wBAAwB,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/utils/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,EAAE,qBAAqB,EAAE,MAAM,2BAA2B,CAAC;AAClE,OAAO,EAAE,wBAAwB,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAC"}
|
package/dist/esm/version.js
CHANGED