@equinor/fusion-framework-module-context 7.0.4-next.0 → 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 +22 -16
- 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/esm/version.js.map +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
|
@@ -3,6 +3,14 @@ import type { QueryCtorOptions, QueryFn } from '@equinor/fusion-query';
|
|
|
3
3
|
import type { GetContextParameters } from './client/ContextClient';
|
|
4
4
|
import type { ContextModuleConfig, ContextModuleConfigurator, IContextModuleConfigurator } from './configurator';
|
|
5
5
|
import type { ContextItem, QueryContextParameters, RelatedContextParameters } from './types';
|
|
6
|
+
/**
|
|
7
|
+
* Callback passed to {@link IContextModuleConfigurator.addConfigBuilder}.
|
|
8
|
+
*
|
|
9
|
+
* Receives a {@link ContextConfigBuilder} and may use its setter methods
|
|
10
|
+
* to populate the context module configuration. The callback may be async.
|
|
11
|
+
*
|
|
12
|
+
* @typeParam TDeps - Module dependency array inferred from the configurator.
|
|
13
|
+
*/
|
|
6
14
|
export type ContextConfigBuilderCallback = <TDeps extends Array<AnyModule> = []>(builder: ContextConfigBuilder<TDeps, ModuleInitializerArgs<IContextModuleConfigurator, TDeps>>) => void | Promise<void>;
|
|
7
15
|
/**
|
|
8
16
|
* A builder class for configuring and customizing context module behavior within the Fusion Framework.
|
|
@@ -87,6 +95,13 @@ export declare class ContextConfigBuilder<TModules extends Array<AnyModule> = []
|
|
|
87
95
|
* @param fn - A function that takes a context and generates a corresponding path.
|
|
88
96
|
*/
|
|
89
97
|
setContextPathGenerator(fn: ContextModuleConfig['generatePathFromContext']): void;
|
|
98
|
+
/**
|
|
99
|
+
* Sets the function used to resolve the initial context during module post-initialization.
|
|
100
|
+
*
|
|
101
|
+
* @param fn - A function that returns an observable input emitting the initial context item.
|
|
102
|
+
* The default resolver extracts a context ID from the navigation path, falling
|
|
103
|
+
* back to the parent provider's current context.
|
|
104
|
+
*/
|
|
90
105
|
setResolveInitialContext(fn: ContextModuleConfig['resolveInitialContext']): void;
|
|
91
106
|
/**
|
|
92
107
|
* Sets the context client configuration for fetching context items.
|
|
@@ -514,26 +514,63 @@ export declare class ContextProvider extends BaseModuleProvider<ContextModuleCon
|
|
|
514
514
|
export default ContextProvider;
|
|
515
515
|
declare module '@equinor/fusion-framework-module-event' {
|
|
516
516
|
interface FrameworkEventMap {
|
|
517
|
+
/**
|
|
518
|
+
* Dispatched **before** the current context is changed.
|
|
519
|
+
*
|
|
520
|
+
* The event is cancelable — calling `event.preventDefault()` in a
|
|
521
|
+
* listener will abort the context change.
|
|
522
|
+
*/
|
|
517
523
|
onCurrentContextChange: FrameworkEvent<FrameworkEventInit<{
|
|
518
524
|
context: ContextItem | null;
|
|
519
525
|
}, IContextProvider>>;
|
|
526
|
+
/**
|
|
527
|
+
* Dispatched **after** the current context has changed.
|
|
528
|
+
*
|
|
529
|
+
* Contains both the previous and next context items, enabling
|
|
530
|
+
* listeners to react to transitions.
|
|
531
|
+
*/
|
|
520
532
|
onCurrentContextChanged: FrameworkEvent<FrameworkEventInit<{
|
|
521
533
|
next: ContextItem | null;
|
|
522
534
|
previous?: ContextItem | null;
|
|
523
535
|
}, IContextProvider>>;
|
|
536
|
+
/**
|
|
537
|
+
* Dispatched **before** a parent context change is applied locally.
|
|
538
|
+
*
|
|
539
|
+
* Cancelable — prevents the parent context from being mirrored into
|
|
540
|
+
* this provider.
|
|
541
|
+
*/
|
|
524
542
|
onParentContextChanged: FrameworkEvent<FrameworkEventInit<{
|
|
525
543
|
context: ContextItem | null;
|
|
526
544
|
}, IContextProvider>>;
|
|
545
|
+
/**
|
|
546
|
+
* Dispatched **before** context resolution begins (when validation
|
|
547
|
+
* fails and the caller requested resolution).
|
|
548
|
+
*
|
|
549
|
+
* Cancelable — aborting prevents the resolution attempt.
|
|
550
|
+
*/
|
|
527
551
|
onSetContextResolve: FrameworkEvent<FrameworkEventInit<{
|
|
528
552
|
context: ContextItem;
|
|
529
553
|
}, IContextProvider>>;
|
|
554
|
+
/**
|
|
555
|
+
* Dispatched **after** the context has been resolved to a new item.
|
|
556
|
+
*
|
|
557
|
+
* Cancelable — aborting prevents the resolved item from being
|
|
558
|
+
* set as the current context.
|
|
559
|
+
*/
|
|
530
560
|
onSetContextResolved: FrameworkEvent<FrameworkEventInit<{
|
|
531
561
|
context: ContextItem;
|
|
532
562
|
resolved?: ContextItem | null;
|
|
533
563
|
}, IContextProvider>>;
|
|
564
|
+
/**
|
|
565
|
+
* Dispatched when context validation fails and resolution is not
|
|
566
|
+
* enabled.
|
|
567
|
+
*/
|
|
534
568
|
onSetContextValidationFailed: FrameworkEvent<FrameworkEventInit<{
|
|
535
569
|
context: ContextItem;
|
|
536
570
|
}, IContextProvider>>;
|
|
571
|
+
/**
|
|
572
|
+
* Dispatched when context resolution fails with an error.
|
|
573
|
+
*/
|
|
537
574
|
onSetContextResolveFailed: FrameworkEvent<FrameworkEventInit<{
|
|
538
575
|
context: ContextItem;
|
|
539
576
|
error: unknown;
|
|
@@ -7,46 +7,176 @@ import type { ContextFilterFn, ContextItem, QueryContextParameters, RelatedConte
|
|
|
7
7
|
import type { GetContextParameters } from './client/ContextClient';
|
|
8
8
|
import { type ContextConfigBuilderCallback } from './ContextConfigBuilder';
|
|
9
9
|
import type { IContextProvider } from './ContextProvider';
|
|
10
|
+
/**
|
|
11
|
+
* Resolved configuration for the context module.
|
|
12
|
+
*
|
|
13
|
+
* Holds query clients, type filters, parent-connection settings, and
|
|
14
|
+
* optional callbacks for validation, resolution, and path integration.
|
|
15
|
+
* Produced by {@link ContextModuleConfigurator.createConfig} after all
|
|
16
|
+
* {@link ContextConfigBuilder} callbacks have run.
|
|
17
|
+
*
|
|
18
|
+
* @see ContextConfigBuilder — fluent API for populating this config.
|
|
19
|
+
* @see ContextProvider — runtime consumer of this config.
|
|
20
|
+
*/
|
|
10
21
|
export interface ContextModuleConfig {
|
|
22
|
+
/**
|
|
23
|
+
* Query client options used to fetch, search, and resolve related context items.
|
|
24
|
+
*
|
|
25
|
+
* - `get` — retrieves a single context item by ID.
|
|
26
|
+
* - `query` — searches context items by text and optional type filter.
|
|
27
|
+
* - `related` — fetches context items related to a given item (used during resolution).
|
|
28
|
+
*/
|
|
11
29
|
client: {
|
|
12
30
|
get: QueryCtorOptions<ContextItem, GetContextParameters>;
|
|
13
31
|
query: QueryCtorOptions<ContextItem[], QueryContextParameters>;
|
|
14
32
|
related?: QueryCtorOptions<ContextItem[], RelatedContextParameters>;
|
|
15
33
|
};
|
|
34
|
+
/**
|
|
35
|
+
* Allowed context type IDs (e.g. `['ProjectMaster', 'Facility']`).
|
|
36
|
+
*
|
|
37
|
+
* When set, {@link ContextProvider.validateContext} only accepts items
|
|
38
|
+
* whose `type.id` matches one of these values (case-insensitive).
|
|
39
|
+
*/
|
|
16
40
|
contextType?: string[];
|
|
41
|
+
/**
|
|
42
|
+
* Optional post-query filter applied to the result set returned by
|
|
43
|
+
* {@link ContextProvider.queryContext}.
|
|
44
|
+
*/
|
|
17
45
|
contextFilter?: ContextFilterFn;
|
|
18
46
|
/**
|
|
19
|
-
* connect context module to
|
|
47
|
+
* Whether to connect the context module to a parent context module.
|
|
48
|
+
*
|
|
49
|
+
* When `true` (the default), the provider subscribes to the parent's
|
|
50
|
+
* `currentContext$` and mirrors changes into its own state.
|
|
20
51
|
*
|
|
21
|
-
*
|
|
52
|
+
* @defaultValue `true`
|
|
22
53
|
*/
|
|
23
54
|
connectParentContext?: boolean;
|
|
24
|
-
/**
|
|
55
|
+
/**
|
|
56
|
+
* When `true`, skips resolving an initial context from the path or parent
|
|
57
|
+
* during module post-initialization.
|
|
58
|
+
*/
|
|
25
59
|
skipInitialContext?: boolean;
|
|
60
|
+
/**
|
|
61
|
+
* Extracts a context ID from a URL path segment.
|
|
62
|
+
*
|
|
63
|
+
* Used during initial context resolution and deep-link support.
|
|
64
|
+
* If not provided, the default GUID-based extractor is used.
|
|
65
|
+
*
|
|
66
|
+
* @param path - The URL path to inspect.
|
|
67
|
+
* @returns The extracted context ID, or `undefined` if none is found.
|
|
68
|
+
*/
|
|
26
69
|
extractContextIdFromPath?: (path: string) => string | undefined;
|
|
70
|
+
/**
|
|
71
|
+
* Generates a URL path that embeds the given context item's ID.
|
|
72
|
+
*
|
|
73
|
+
* Used by navigation integrations to update the browser URL when
|
|
74
|
+
* the context changes.
|
|
75
|
+
*
|
|
76
|
+
* @param context - The active context item.
|
|
77
|
+
* @param path - The current URL path.
|
|
78
|
+
* @returns The updated path, or `undefined` to leave it unchanged.
|
|
79
|
+
*/
|
|
27
80
|
generatePathFromContext?: (context: ContextItem, path: string) => string | undefined;
|
|
28
81
|
/**
|
|
29
|
-
*
|
|
82
|
+
* Transforms a user search string and the configured context type into
|
|
83
|
+
* the query parameters sent to the context API.
|
|
84
|
+
*
|
|
85
|
+
* Override this to customise how free-text searches are mapped to the
|
|
86
|
+
* backend query contract.
|
|
30
87
|
*/
|
|
31
88
|
contextParameterFn?: (args: {
|
|
32
89
|
search: string;
|
|
33
90
|
type: ContextModuleConfig['contextType'];
|
|
34
91
|
}) => string | QueryContextParameters;
|
|
92
|
+
/**
|
|
93
|
+
* Custom context resolution strategy.
|
|
94
|
+
*
|
|
95
|
+
* Called with `this` bound to the {@link IContextProvider} when a context
|
|
96
|
+
* item fails validation and the caller requests resolution.
|
|
97
|
+
*
|
|
98
|
+
* @param item - The context item to resolve, or `null`.
|
|
99
|
+
* @returns An observable emitting the resolved context item.
|
|
100
|
+
*/
|
|
35
101
|
resolveContext?: (this: IContextProvider, item: ContextItem | null) => ReturnType<IContextProvider['resolveContext']>;
|
|
102
|
+
/**
|
|
103
|
+
* Custom context validation strategy.
|
|
104
|
+
*
|
|
105
|
+
* Called with `this` bound to the {@link IContextProvider} to decide
|
|
106
|
+
* whether a candidate context item is acceptable.
|
|
107
|
+
*
|
|
108
|
+
* @param item - The context item to validate, or `null`.
|
|
109
|
+
* @returns `true` if the item is valid.
|
|
110
|
+
*/
|
|
36
111
|
validateContext?: (this: IContextProvider, item: ContextItem | null) => ReturnType<IContextProvider['validateContext']>;
|
|
112
|
+
/**
|
|
113
|
+
* Resolves the initial context during module post-initialization.
|
|
114
|
+
*
|
|
115
|
+
* The default implementation tries to extract a context ID from the
|
|
116
|
+
* current navigation path, falling back to the parent provider's context.
|
|
117
|
+
*
|
|
118
|
+
* @param args - Module reference and instance map.
|
|
119
|
+
* @returns An observable input emitting the initial context item, or void.
|
|
120
|
+
*/
|
|
37
121
|
resolveInitialContext?: (args: {
|
|
38
122
|
ref?: AnyModuleInstance | any;
|
|
39
123
|
modules: ModuleInstance;
|
|
40
124
|
}) => ObservableInput<ContextItem | void>;
|
|
41
125
|
}
|
|
126
|
+
/**
|
|
127
|
+
* Public configurator contract for the context module.
|
|
128
|
+
*
|
|
129
|
+
* Consumers call {@link addConfigBuilder} to register one or more
|
|
130
|
+
* {@link ContextConfigBuilderCallback} functions that will run during
|
|
131
|
+
* module initialization to populate the {@link ContextModuleConfig}.
|
|
132
|
+
*/
|
|
42
133
|
export interface IContextModuleConfigurator {
|
|
134
|
+
/**
|
|
135
|
+
* Registers a configuration callback that receives a {@link ContextConfigBuilder}.
|
|
136
|
+
*
|
|
137
|
+
* Multiple builders can be added; they execute sequentially and merge
|
|
138
|
+
* their results into a single {@link ContextModuleConfig}.
|
|
139
|
+
*
|
|
140
|
+
* @param init - Builder callback invoked during module initialization.
|
|
141
|
+
*/
|
|
43
142
|
addConfigBuilder: (init: ContextConfigBuilderCallback) => void;
|
|
44
143
|
}
|
|
144
|
+
/**
|
|
145
|
+
* Default implementation of {@link IContextModuleConfigurator}.
|
|
146
|
+
*
|
|
147
|
+
* Collects {@link ContextConfigBuilderCallback} registrations and, when
|
|
148
|
+
* {@link createConfig} is called, runs them in order against a
|
|
149
|
+
* {@link ContextConfigBuilder} to produce the final {@link ContextModuleConfig}.
|
|
150
|
+
*
|
|
151
|
+
* If no custom client is configured, the configurator falls back to
|
|
152
|
+
* creating one from the {@link ServicesModule} API provider.
|
|
153
|
+
*/
|
|
45
154
|
export declare class ContextModuleConfigurator implements IContextModuleConfigurator {
|
|
46
155
|
#private;
|
|
156
|
+
/** Default cache TTL (in ms) for context query results. */
|
|
47
157
|
defaultExpireTime: number;
|
|
158
|
+
/** @inheritdoc */
|
|
48
159
|
addConfigBuilder(init: ContextConfigBuilderCallback): void;
|
|
160
|
+
/**
|
|
161
|
+
* Resolves the services API provider, preferring the local module
|
|
162
|
+
* instance and falling back to the parent module.
|
|
163
|
+
*
|
|
164
|
+
* @param init - Module initializer arguments.
|
|
165
|
+
* @returns The resolved API provider.
|
|
166
|
+
* @throws Error if no services module is available.
|
|
167
|
+
*/
|
|
49
168
|
protected _getServiceProvider(init: ModuleInitializerArgs<IContextModuleConfigurator, [ServicesModule]>): Promise<IApiProvider>;
|
|
169
|
+
/**
|
|
170
|
+
* Runs all registered config builders and produces the final
|
|
171
|
+
* {@link ContextModuleConfig}.
|
|
172
|
+
*
|
|
173
|
+
* If no `resolveInitialContext` was set, the default path + parent
|
|
174
|
+
* resolver is used. If no `client` was set, one is created from the
|
|
175
|
+
* {@link ServicesModule} API provider.
|
|
176
|
+
*
|
|
177
|
+
* @param init - Module initializer arguments including dependency instances.
|
|
178
|
+
* @returns The fully resolved context module configuration.
|
|
179
|
+
*/
|
|
50
180
|
createConfig(init: ModuleInitializerArgs<IContextModuleConfigurator, [ServicesModule, NavigationModule]>): Promise<ContextModuleConfig>;
|
|
51
181
|
}
|
|
52
182
|
export default ContextModuleConfigurator;
|
package/dist/types/index.d.ts
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, IContextModuleConfigurator, ContextModuleConfig, } from './configurator';
|
|
2
14
|
export { IContextProvider, ContextProvider } from './ContextProvider';
|
|
3
15
|
export { default, ContextModule, module as contextModule, moduleKey as contextModuleKey, } from './module';
|
package/dist/types/module.d.ts
CHANGED
|
@@ -4,7 +4,18 @@ import type { ServicesModule } from '@equinor/fusion-framework-module-services';
|
|
|
4
4
|
import type { NavigationModule } from '@equinor/fusion-framework-module-navigation';
|
|
5
5
|
import { type IContextModuleConfigurator } from './configurator';
|
|
6
6
|
import { type IContextProvider } from './ContextProvider';
|
|
7
|
+
/**
|
|
8
|
+
* Literal type identifying the context module within the Fusion Framework module system.
|
|
9
|
+
*
|
|
10
|
+
* Used as the key when registering or looking up the module in a `Modules` map.
|
|
11
|
+
*/
|
|
7
12
|
export type ContextModuleKey = 'context';
|
|
13
|
+
/**
|
|
14
|
+
* Module registration key for the context module.
|
|
15
|
+
*
|
|
16
|
+
* Pass this value—or reference it as `contextModuleKey`—when you need to
|
|
17
|
+
* identify the context module by name at runtime (e.g., `hasModule(contextModuleKey)`).
|
|
18
|
+
*/
|
|
8
19
|
export declare const moduleKey: ContextModuleKey;
|
|
9
20
|
/**
|
|
10
21
|
* Represents a module for managing context within the framework.
|
package/dist/types/types.d.ts
CHANGED
|
@@ -39,11 +39,33 @@ export type ContextItem<TType extends Record<string, unknown> = Record<string, u
|
|
|
39
39
|
content: string;
|
|
40
40
|
};
|
|
41
41
|
};
|
|
42
|
+
/**
|
|
43
|
+
* Describes the type classification of a {@link ContextItem}.
|
|
44
|
+
*
|
|
45
|
+
* Every context item carries a `type` that identifies what kind of
|
|
46
|
+
* entity it represents (e.g. `ProjectMaster`, `Facility`, `Contract`).
|
|
47
|
+
* The optional hierarchy fields indicate parent–child relationships
|
|
48
|
+
* between context types.
|
|
49
|
+
*/
|
|
42
50
|
export interface ContextItemType {
|
|
51
|
+
/** Unique identifier for the context type (e.g. `'ProjectMaster'`). */
|
|
43
52
|
id: string;
|
|
53
|
+
/** Whether this type is a child of another context type. */
|
|
44
54
|
isChildType?: boolean;
|
|
55
|
+
/** IDs of parent context types, when `isChildType` is `true`. */
|
|
45
56
|
parentTypeIds?: string[];
|
|
46
57
|
}
|
|
58
|
+
/**
|
|
59
|
+
* Parameters for querying context items from the context API.
|
|
60
|
+
*
|
|
61
|
+
* Used by {@link ContextProvider.queryContext} and the underlying
|
|
62
|
+
* query client to search and filter context results.
|
|
63
|
+
*
|
|
64
|
+
* @property search - Free-text search term.
|
|
65
|
+
* @property filter - Optional structured filters.
|
|
66
|
+
* @property filter.type - Restrict results to specific context type IDs.
|
|
67
|
+
* @property filter.externalId - Filter by an external system identifier.
|
|
68
|
+
*/
|
|
47
69
|
export type QueryContextParameters = {
|
|
48
70
|
search?: string;
|
|
49
71
|
filter?: {
|
|
@@ -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';
|
package/dist/types/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const version = "
|
|
1
|
+
export declare const version = "8.0.0";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@equinor/fusion-framework-module-context",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "8.0.0",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "./dist/esm/index.js",
|
|
6
6
|
"exports": {
|
|
@@ -45,19 +45,19 @@
|
|
|
45
45
|
},
|
|
46
46
|
"dependencies": {
|
|
47
47
|
"fast-deep-equal": "^3.1.3",
|
|
48
|
-
"@equinor/fusion-query": "^
|
|
48
|
+
"@equinor/fusion-query": "^7.0.0"
|
|
49
49
|
},
|
|
50
50
|
"devDependencies": {
|
|
51
51
|
"rxjs": "^7.8.1",
|
|
52
|
-
"typescript": "^5.
|
|
53
|
-
"@equinor/fusion-framework-module": "^
|
|
54
|
-
"@equinor/fusion-framework-module
|
|
55
|
-
"@equinor/fusion-framework-module-
|
|
56
|
-
"@equinor/fusion-framework-module-
|
|
52
|
+
"typescript": "^5.9.3",
|
|
53
|
+
"@equinor/fusion-framework-module-event": "^6.0.0",
|
|
54
|
+
"@equinor/fusion-framework-module": "^6.0.0",
|
|
55
|
+
"@equinor/fusion-framework-module-services": "^8.0.0",
|
|
56
|
+
"@equinor/fusion-framework-module-navigation": "^7.0.0"
|
|
57
57
|
},
|
|
58
58
|
"peerDependencies": {
|
|
59
|
-
"rxjs": "^7.
|
|
60
|
-
"@equinor/fusion-framework-module": "^
|
|
59
|
+
"rxjs": "^7.0.0",
|
|
60
|
+
"@equinor/fusion-framework-module": "^6.0.0"
|
|
61
61
|
},
|
|
62
62
|
"scripts": {
|
|
63
63
|
"build": "tsc -b"
|
|
@@ -17,6 +17,14 @@ import type {
|
|
|
17
17
|
|
|
18
18
|
import type { ContextItem, QueryContextParameters, RelatedContextParameters } from './types';
|
|
19
19
|
|
|
20
|
+
/**
|
|
21
|
+
* Callback passed to {@link IContextModuleConfigurator.addConfigBuilder}.
|
|
22
|
+
*
|
|
23
|
+
* Receives a {@link ContextConfigBuilder} and may use its setter methods
|
|
24
|
+
* to populate the context module configuration. The callback may be async.
|
|
25
|
+
*
|
|
26
|
+
* @typeParam TDeps - Module dependency array inferred from the configurator.
|
|
27
|
+
*/
|
|
20
28
|
export type ContextConfigBuilderCallback = <TDeps extends Array<AnyModule> = []>(
|
|
21
29
|
builder: ContextConfigBuilder<TDeps, ModuleInitializerArgs<IContextModuleConfigurator, TDeps>>,
|
|
22
30
|
) => void | Promise<void>;
|
|
@@ -147,6 +155,13 @@ export class ContextConfigBuilder<
|
|
|
147
155
|
this.config.generatePathFromContext = fn;
|
|
148
156
|
}
|
|
149
157
|
|
|
158
|
+
/**
|
|
159
|
+
* Sets the function used to resolve the initial context during module post-initialization.
|
|
160
|
+
*
|
|
161
|
+
* @param fn - A function that returns an observable input emitting the initial context item.
|
|
162
|
+
* The default resolver extracts a context ID from the navigation path, falling
|
|
163
|
+
* back to the parent provider's current context.
|
|
164
|
+
*/
|
|
150
165
|
setResolveInitialContext(fn: ContextModuleConfig['resolveInitialContext']) {
|
|
151
166
|
this.config.resolveInitialContext = fn;
|
|
152
167
|
}
|
package/src/ContextProvider.ts
CHANGED
|
@@ -989,7 +989,12 @@ export default ContextProvider;
|
|
|
989
989
|
|
|
990
990
|
declare module '@equinor/fusion-framework-module-event' {
|
|
991
991
|
interface FrameworkEventMap {
|
|
992
|
-
|
|
992
|
+
/**
|
|
993
|
+
* Dispatched **before** the current context is changed.
|
|
994
|
+
*
|
|
995
|
+
* The event is cancelable — calling `event.preventDefault()` in a
|
|
996
|
+
* listener will abort the context change.
|
|
997
|
+
*/
|
|
993
998
|
onCurrentContextChange: FrameworkEvent<
|
|
994
999
|
FrameworkEventInit<
|
|
995
1000
|
{
|
|
@@ -998,7 +1003,12 @@ declare module '@equinor/fusion-framework-module-event' {
|
|
|
998
1003
|
IContextProvider
|
|
999
1004
|
>
|
|
1000
1005
|
>;
|
|
1001
|
-
|
|
1006
|
+
/**
|
|
1007
|
+
* Dispatched **after** the current context has changed.
|
|
1008
|
+
*
|
|
1009
|
+
* Contains both the previous and next context items, enabling
|
|
1010
|
+
* listeners to react to transitions.
|
|
1011
|
+
*/
|
|
1002
1012
|
onCurrentContextChanged: FrameworkEvent<
|
|
1003
1013
|
FrameworkEventInit<
|
|
1004
1014
|
{
|
|
@@ -1009,7 +1019,12 @@ declare module '@equinor/fusion-framework-module-event' {
|
|
|
1009
1019
|
>
|
|
1010
1020
|
>;
|
|
1011
1021
|
|
|
1012
|
-
|
|
1022
|
+
/**
|
|
1023
|
+
* Dispatched **before** a parent context change is applied locally.
|
|
1024
|
+
*
|
|
1025
|
+
* Cancelable — prevents the parent context from being mirrored into
|
|
1026
|
+
* this provider.
|
|
1027
|
+
*/
|
|
1013
1028
|
onParentContextChanged: FrameworkEvent<
|
|
1014
1029
|
FrameworkEventInit<
|
|
1015
1030
|
{
|
|
@@ -1019,7 +1034,12 @@ declare module '@equinor/fusion-framework-module-event' {
|
|
|
1019
1034
|
>
|
|
1020
1035
|
>;
|
|
1021
1036
|
|
|
1022
|
-
|
|
1037
|
+
/**
|
|
1038
|
+
* Dispatched **before** context resolution begins (when validation
|
|
1039
|
+
* fails and the caller requested resolution).
|
|
1040
|
+
*
|
|
1041
|
+
* Cancelable — aborting prevents the resolution attempt.
|
|
1042
|
+
*/
|
|
1023
1043
|
onSetContextResolve: FrameworkEvent<
|
|
1024
1044
|
FrameworkEventInit<
|
|
1025
1045
|
{
|
|
@@ -1029,7 +1049,12 @@ declare module '@equinor/fusion-framework-module-event' {
|
|
|
1029
1049
|
>
|
|
1030
1050
|
>;
|
|
1031
1051
|
|
|
1032
|
-
|
|
1052
|
+
/**
|
|
1053
|
+
* Dispatched **after** the context has been resolved to a new item.
|
|
1054
|
+
*
|
|
1055
|
+
* Cancelable — aborting prevents the resolved item from being
|
|
1056
|
+
* set as the current context.
|
|
1057
|
+
*/
|
|
1033
1058
|
onSetContextResolved: FrameworkEvent<
|
|
1034
1059
|
FrameworkEventInit<
|
|
1035
1060
|
{
|
|
@@ -1040,7 +1065,10 @@ declare module '@equinor/fusion-framework-module-event' {
|
|
|
1040
1065
|
>
|
|
1041
1066
|
>;
|
|
1042
1067
|
|
|
1043
|
-
|
|
1068
|
+
/**
|
|
1069
|
+
* Dispatched when context validation fails and resolution is not
|
|
1070
|
+
* enabled.
|
|
1071
|
+
*/
|
|
1044
1072
|
onSetContextValidationFailed: FrameworkEvent<
|
|
1045
1073
|
FrameworkEventInit<
|
|
1046
1074
|
{
|
|
@@ -1050,7 +1078,9 @@ declare module '@equinor/fusion-framework-module-event' {
|
|
|
1050
1078
|
>
|
|
1051
1079
|
>;
|
|
1052
1080
|
|
|
1053
|
-
|
|
1081
|
+
/**
|
|
1082
|
+
* Dispatched when context resolution fails with an error.
|
|
1083
|
+
*/
|
|
1054
1084
|
onSetContextResolveFailed: FrameworkEvent<
|
|
1055
1085
|
FrameworkEventInit<
|
|
1056
1086
|
{
|