@equinor/fusion-framework-app 13.0.3-next.0 → 13.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.
Files changed (47) hide show
  1. package/CHANGELOG.md +3 -5
  2. package/README.md +65 -35
  3. package/dist/esm/configure-modules.js +42 -2
  4. package/dist/esm/configure-modules.js.map +1 -1
  5. package/dist/esm/version.js +1 -1
  6. package/dist/esm/version.js.map +1 -1
  7. package/dist/tsconfig.tsbuildinfo +1 -1
  8. package/dist/types/version.d.ts +1 -1
  9. package/package.json +13 -22
  10. package/src/configure-modules.ts +52 -2
  11. package/src/version.ts +1 -1
  12. package/vitest.config.ts +1 -1
  13. package/dist/esm/__tests__/mock/AppMockConfigurator.test.js +0 -70
  14. package/dist/esm/__tests__/mock/AppMockConfigurator.test.js.map +0 -1
  15. package/dist/esm/__tests__/mock/mock-app.test.js +0 -86
  16. package/dist/esm/__tests__/mock/mock-app.test.js.map +0 -1
  17. package/dist/esm/__tests__/mock/msal-hoisting.test.js +0 -36
  18. package/dist/esm/__tests__/mock/msal-hoisting.test.js.map +0 -1
  19. package/dist/esm/initialize-app-modules.js +0 -65
  20. package/dist/esm/initialize-app-modules.js.map +0 -1
  21. package/dist/esm/mock/AppMockConfigurator.js +0 -183
  22. package/dist/esm/mock/AppMockConfigurator.js.map +0 -1
  23. package/dist/esm/mock/enable-app-manifest-mock.js +0 -49
  24. package/dist/esm/mock/enable-app-manifest-mock.js.map +0 -1
  25. package/dist/esm/mock/index.js +0 -21
  26. package/dist/esm/mock/index.js.map +0 -1
  27. package/dist/esm/mock/mock-app-modules.js +0 -82
  28. package/dist/esm/mock/mock-app-modules.js.map +0 -1
  29. package/dist/types/__tests__/mock/AppMockConfigurator.test.d.ts +0 -1
  30. package/dist/types/__tests__/mock/mock-app.test.d.ts +0 -1
  31. package/dist/types/__tests__/mock/msal-hoisting.test.d.ts +0 -1
  32. package/dist/types/initialize-app-modules.d.ts +0 -31
  33. package/dist/types/mock/AppMockConfigurator.d.ts +0 -142
  34. package/dist/types/mock/enable-app-manifest-mock.d.ts +0 -33
  35. package/dist/types/mock/index.d.ts +0 -20
  36. package/dist/types/mock/mock-app-modules.d.ts +0 -72
  37. package/docs/bookmarks.md +0 -18
  38. package/docs/http-clients.md +0 -71
  39. package/docs/testing.md +0 -105
  40. package/src/__tests__/mock/AppMockConfigurator.test.ts +0 -96
  41. package/src/__tests__/mock/mock-app.test.ts +0 -112
  42. package/src/__tests__/mock/msal-hoisting.test.ts +0 -54
  43. package/src/initialize-app-modules.ts +0 -98
  44. package/src/mock/AppMockConfigurator.ts +0 -218
  45. package/src/mock/enable-app-manifest-mock.ts +0 -62
  46. package/src/mock/index.ts +0 -21
  47. package/src/mock/mock-app-modules.ts +0 -109
package/CHANGELOG.md CHANGED
@@ -1,13 +1,11 @@
1
1
  # Change Log
2
2
 
3
- ## 13.0.3-next.0
3
+ ## 13.0.3
4
4
 
5
5
  ### Patch Changes
6
6
 
7
- - c8008e3: Internal: rebase `next` onto `main`, syncing in already-published stable releases so they carry a `next` pre-release tag.
8
- - Updated dependencies [c8008e3]
9
- - @equinor/fusion-framework-module-app@8.0.6-next.0
10
- - @equinor/fusion-framework-module-state@2.0.2-next.0
7
+ - @equinor/fusion-framework-module-telemetry@7.0.3
8
+ - @equinor/fusion-framework@8.0.16
11
9
 
12
10
  ## 13.0.2
13
11
 
package/README.md CHANGED
@@ -20,14 +20,6 @@ single `configureModules` call.
20
20
  > **Most Fusion apps should use `@equinor/fusion-framework-react-app` instead.**
21
21
  > This lower-level package is for framework-agnostic or advanced scenarios.
22
22
 
23
- ## Documentation
24
-
25
- | Topic | Description |
26
- |---|---|
27
- | [Configure HTTP Clients](docs/http-clients.md) | Named clients from app config, service discovery, and explicit registration, plus resolution priority |
28
- | [Enable Bookmarks](docs/bookmarks.md) | Registering the bookmark module via `enableBookmark` |
29
- | [Testing](docs/testing.md) | The `/mock` entry point: `mockAppModules`, `AppMockConfigurator`, and `enableAppManifestMock` |
30
-
31
23
  ## Installation
32
24
 
33
25
  ```sh
@@ -88,7 +80,6 @@ const modules = await initialize({ fusion, env });
88
80
  | `AppModuleInitiator` | Callback signature accepted by `configureModules` for user-supplied setup. |
89
81
  | `AppEnv` | Environment descriptor containing the app manifest, config, and optional basename. |
90
82
  | `enableBookmark` | Helper to enable the bookmark module (import from `@equinor/fusion-framework-app/enable-bookmark`). |
91
- | `mockAppModules` | Runs the real module pipeline against deterministic fakes for tests (import from `@equinor/fusion-framework-app/mock`). |
92
83
 
93
84
  ## API Surface
94
85
 
@@ -109,13 +100,40 @@ giving you access to:
109
100
  |---|---|
110
101
  | `@equinor/fusion-framework-app` | `configureModules`, `AppConfigurator`, `IAppConfigurator`, all type aliases |
111
102
  | `@equinor/fusion-framework-app/enable-bookmark` | `enableBookmark` function |
112
- | `@equinor/fusion-framework-app/mock` | `mockAppModules`, `AppMockConfigurator`, `enableAppManifestMock` |
113
103
 
114
104
  ## Configure HTTP Clients
115
105
 
116
- The `AppConfigurator` can register named HTTP clients from several sources —
117
- application config endpoints, service discovery, or explicit registration —
118
- and you retrieve one at runtime with `framework.modules.http.createClient(name)`.
106
+ The `AppConfigurator` can register named HTTP clients from several sources.
107
+ You retrieve a client at runtime with `framework.modules.http.createClient(name)`.
108
+
109
+ ### From Application Config (auto-registration)
110
+
111
+ Endpoints defined in `app.config.<env>.ts` are **automatically registered as
112
+ named HTTP clients** when the `AppConfigurator` is created — no extra code
113
+ needed in `config.ts`.
114
+
115
+ ```ts
116
+ // app.config.ts
117
+ import { defineAppConfig } from '@equinor/fusion-framework-cli/app';
118
+
119
+ export default defineAppConfig(() => ({
120
+ endpoints: {
121
+ schedule: {
122
+ url: 'https://schedule-api.example.com',
123
+ scopes: ['api://schedule-id/.default'],
124
+ },
125
+ },
126
+ }));
127
+ ```
128
+
129
+ After initialization, use the client directly:
130
+
131
+ ```ts
132
+ const client = framework.modules.http.createClient('schedule');
133
+ const data = await client.json('/items');
134
+ ```
135
+
136
+ ### Via Service Discovery
119
137
 
120
138
  ```ts
121
139
  const initialize = configureModules((configurator) => {
@@ -123,9 +141,37 @@ const initialize = configureModules((configurator) => {
123
141
  });
124
142
  ```
125
143
 
126
- See [Configure HTTP Clients](docs/http-clients.md) for auto-registration from
127
- `app.config.ts`, explicit registration, and resolution priority when a client
128
- is configured in more than one place.
144
+ ### Explicit Registration
145
+
146
+ Use `configureHttpClient` in `config.ts` when the endpoint is **not** in
147
+ `app.config.ts`, or when you need custom transport behavior such as headers,
148
+ response guards, or a custom client class.
149
+
150
+ ```ts
151
+ configurator.configureHttpClient('custom-api', {
152
+ baseUri: 'https://custom.api.example.com',
153
+ defaultScopes: ['api://custom-id/.default'],
154
+ onCreate: (client) => {
155
+ client.requestHandler.setHeader('X-Source', 'portal');
156
+ },
157
+ });
158
+ ```
159
+
160
+ ### Resolution Priority
161
+
162
+ When the same client name is configured in more than one place, the
163
+ highest-priority source wins:
164
+
165
+ | Priority | Source | Example |
166
+ |----------|--------|---------|
167
+ | 1 (highest) | **Session overrides** | User-specific URL / scopes set at runtime via `sessionStorage` |
168
+ | 2 | **Application config endpoints** | `endpoints` in `app.config.ts` |
169
+ | 3 | **Service-discovery registry** | Resolved via `useFrameworkServiceClient` |
170
+ | 4 (lowest) | **Explicit registration** | `configureHttpClient(name, options)` in `config.ts` |
171
+
172
+ This means an endpoint defined in `app.config.ts` will override a
173
+ `configureHttpClient` call for the same name, and a session override will
174
+ override both.
129
175
 
130
176
  ## Enable Bookmarks
131
177
 
@@ -135,6 +181,7 @@ The bookmark module allows applications to save and restore application state.
135
181
  > `@equinor/fusion-framework-module-bookmark` directly.
136
182
 
137
183
  ```ts
184
+ import { configureModules } from '@equinor/fusion-framework-app';
138
185
  import { enableBookmark } from '@equinor/fusion-framework-app/enable-bookmark';
139
186
 
140
187
  const initialize = configureModules((configurator) => {
@@ -142,25 +189,8 @@ const initialize = configureModules((configurator) => {
142
189
  });
143
190
  ```
144
191
 
145
- See [Enable Bookmarks](docs/bookmarks.md) for payload generator cleanup behavior.
146
-
147
- ## Testing
148
-
149
- Import from `@equinor/fusion-framework-app/mock` to run an application's real
150
- module pipeline in tests — the real `event`/`http`/`msal` modules, the real
151
- `AppConfigurator` configuration pipeline, and real lifecycle — while only the
152
- boundaries that reach outside the process are substituted with deterministic
153
- fakes. This entry point has no dependency on Vitest or any other test runner.
154
-
155
- ```ts
156
- import { mockAppModules } from '@equinor/fusion-framework-app/mock';
157
-
158
- const manifest = { appKey: 'my-app', displayName: 'My App', description: 'My app', type: 'standalone' } as const;
159
- const modules = await mockAppModules(undefined, { manifest });
160
- ```
161
-
162
- See [Testing](docs/testing.md) for `AppMockConfigurator`, `enableAppManifestMock`,
163
- and customizing the mocked parent's service discovery.
192
+ Payload generators registered through the bookmark module are automatically
193
+ cleaned up when the module is disposed.
164
194
 
165
195
  ## Types
166
196
 
@@ -4,8 +4,8 @@
4
4
  * Provides the core factory function for configuring and initializing
5
5
  * application-specific modules in the Fusion framework.
6
6
  */
7
+ import { enableTelemetry, } from '@equinor/fusion-framework-module-telemetry';
7
8
  import { AppConfigurator } from './AppConfigurator';
8
- import { initializeAppModules } from './initialize-app-modules';
9
9
  /**
10
10
  * Create an application module initializer for a Fusion application.
11
11
  *
@@ -49,9 +49,49 @@ export const configureModules = (cb) =>
49
49
  * @returns The fully initialized application module instance.
50
50
  */
51
51
  async (args) => {
52
+ const { fusion } = args;
52
53
  // Create app configurator
53
54
  const configurator = new AppConfigurator(args.env);
54
- return initializeAppModules(configurator, cb, args);
55
+ // Extract telemetry metadata from app manifest for tracking and debugging
56
+ const metadataExtractor = () => {
57
+ return {
58
+ fusion: {
59
+ type: 'app-telemetry',
60
+ app: {
61
+ key: args.env.manifest?.appKey || 'unknown-app',
62
+ version: args.env.manifest?.build?.version || 'unknown-version',
63
+ },
64
+ },
65
+ };
66
+ };
67
+ // Enable telemetry collection for module configuration events
68
+ // attachConfiguratorEvents automatically prefixes events with configurator class name
69
+ enableTelemetry(configurator, {
70
+ attachConfiguratorEvents: true,
71
+ configure: (builder) => {
72
+ builder.setMetadata(metadataExtractor);
73
+ builder.setParent(fusion.modules.telemetry);
74
+ // Scope telemetry to 'app' level for app-specific event filtering
75
+ builder.setDefaultScope(['app']);
76
+ },
77
+ });
78
+ // Allow user configuration callback to run before module initialization
79
+ if (cb) {
80
+ await Promise.resolve(cb(configurator, args));
81
+ }
82
+ // Type cast is safe because AppConfigurator.initialize() returns the exact module
83
+ // instance that was registered and configured above. The intermediate 'unknown'
84
+ // cast is necessary due to TypeScript's generic inference limitations with the
85
+ // configurator's initialization chain, but the runtime value is guaranteed to match.
86
+ const modules = (await configurator.initialize(args.fusion.modules));
87
+ // Dispatch app modules loaded event for app lifecycle tracking
88
+ // TODO(#5061): remove check after fusion-cli is updated (app module is not enabled in fusion-cli)
89
+ if (args.env.manifest?.appKey) {
90
+ modules.event.dispatchEvent('onAppModulesLoaded', {
91
+ detail: { appKey: args.env.manifest.appKey, manifest: args.env.manifest, modules },
92
+ });
93
+ }
94
+ return modules;
55
95
  };
56
96
  export default configureModules;
57
97
  //# sourceMappingURL=configure-modules.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"configure-modules.js","sourceRoot":"","sources":["../../src/configure-modules.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAKH,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAGpD,OAAO,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AAEhE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAC3B,CAKE,EAA6C,EACmC,EAAE;AACpF;;;;;;;GAOG;AACH,KAAK,EAAE,IAAiC,EAAyC,EAAE;IACjF,0BAA0B;IAC1B,MAAM,YAAY,GAAG,IAAI,eAAe,CAAkC,IAAI,CAAC,GAAG,CAAC,CAAC;IACpF,OAAO,oBAAoB,CAAC,YAAY,EAAE,EAAE,EAAE,IAAI,CAAC,CAAC;AACtD,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C;IAEH,wEAAwE;IACxE,IAAI,EAAE,EAAE,CAAC;QACP,MAAM,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC,YAAY,EAAE,IAAI,CAAC,CAAC,CAAC;IAChD,CAAC;IACD,kFAAkF;IAClF,gFAAgF;IAChF,+EAA+E;IAC/E,qFAAqF;IACrF,MAAM,OAAO,GAAiC,CAAC,MAAM,YAAY,CAAC,UAAU,CAC1E,IAAI,CAAC,MAAM,CAAC,OAAO,CACpB,CAA4C,CAAC;IAE9C,+DAA+D;IAC/D,kGAAkG;IAClG,IAAI,IAAI,CAAC,GAAG,CAAC,QAAQ,EAAE,MAAM,EAAE,CAAC;QAC9B,OAAO,CAAC,KAAK,CAAC,aAAa,CAAC,oBAAoB,EAAE;YAChD,MAAM,EAAE,EAAE,MAAM,EAAE,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,MAAM,EAAE,QAAQ,EAAE,IAAI,CAAC,GAAG,CAAC,QAAQ,EAAE,OAAO,EAAE;SACnF,CAAC,CAAC;IACL,CAAC;IACD,OAAO,OAAO,CAAC;AACjB,CAAC,CAAC;AAEJ,eAAe,gBAAgB,CAAC"}
@@ -1,3 +1,3 @@
1
1
  // Generated by genversion.
2
- export const version = '13.0.3-next.0';
2
+ export const version = '13.0.3';
3
3
  //# sourceMappingURL=version.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"version.js","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":"AAAA,2BAA2B;AAC3B,MAAM,CAAC,MAAM,OAAO,GAAG,eAAe,CAAC"}
1
+ {"version":3,"file":"version.js","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":"AAAA,2BAA2B;AAC3B,MAAM,CAAC,MAAM,OAAO,GAAG,QAAQ,CAAC"}