@equinor/fusion-framework-module-app 8.0.2 → 8.0.4
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 +19 -0
- package/dist/esm/AppClient.js +75 -8
- package/dist/esm/AppClient.js.map +1 -1
- package/dist/esm/AppConfig.js +9 -1
- package/dist/esm/AppConfig.js.map +1 -1
- package/dist/esm/{AppClient.Selectors.js → AppConfigSelector.js} +1 -1
- package/dist/esm/AppConfigSelector.js.map +1 -0
- package/dist/esm/AppConfigurator.js +29 -2
- package/dist/esm/AppConfigurator.js.map +1 -1
- package/dist/esm/AppModuleProvider.js +16 -0
- package/dist/esm/AppModuleProvider.js.map +1 -1
- package/dist/esm/app/App.js +83 -24
- package/dist/esm/app/App.js.map +1 -1
- package/dist/esm/app/actions.js +2 -2
- package/dist/esm/app/actions.js.map +1 -1
- package/dist/esm/app/create-reducer.js +2 -1
- package/dist/esm/app/create-reducer.js.map +1 -1
- package/dist/esm/app/filter-empty.js +11 -0
- package/dist/esm/app/filter-empty.js.map +1 -0
- package/dist/esm/app/flows/handle-fetch-config.js +30 -0
- package/dist/esm/app/flows/handle-fetch-config.js.map +1 -0
- package/dist/esm/app/flows/handle-fetch-manifest.js +30 -0
- package/dist/esm/app/flows/handle-fetch-manifest.js.map +1 -0
- package/dist/esm/app/flows/handle-fetch-settings.js +30 -0
- package/dist/esm/app/flows/handle-fetch-settings.js.map +1 -0
- package/dist/esm/app/flows/handle-import-application.js +23 -0
- package/dist/esm/app/flows/handle-import-application.js.map +1 -0
- package/dist/esm/app/flows/handle-update-settings.js +22 -0
- package/dist/esm/app/flows/handle-update-settings.js.map +1 -0
- package/dist/esm/app/flows/index.js +6 -0
- package/dist/esm/app/flows/index.js.map +1 -0
- package/dist/esm/enable-app-module.js +2 -1
- package/dist/esm/enable-app-module.js.map +1 -1
- package/dist/esm/errors/AppBuildError.js +35 -0
- package/dist/esm/errors/AppBuildError.js.map +1 -0
- package/dist/esm/errors/AppConfigError.js +35 -0
- package/dist/esm/errors/AppConfigError.js.map +1 -0
- package/dist/esm/errors/AppManifestError.js +35 -0
- package/dist/esm/errors/AppManifestError.js.map +1 -0
- package/dist/esm/errors/AppScriptModuleError.js +17 -0
- package/dist/esm/errors/AppScriptModuleError.js.map +1 -0
- package/dist/esm/errors/AppSettingsError.js +35 -0
- package/dist/esm/errors/AppSettingsError.js.map +1 -0
- package/dist/esm/errors/app-error-type.js +2 -0
- package/dist/esm/errors/app-error-type.js.map +1 -0
- package/dist/esm/errors.js +5 -148
- package/dist/esm/errors.js.map +1 -1
- package/dist/esm/module.js +2 -0
- package/dist/esm/module.js.map +1 -1
- package/dist/esm/schemas.js +4 -0
- package/dist/esm/schemas.js.map +1 -1
- package/dist/esm/version.js +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/types/AppClient.d.ts +42 -0
- package/dist/types/AppConfig.d.ts +7 -1
- package/dist/types/AppConfigurator.d.ts +26 -0
- package/dist/types/AppModuleProvider.d.ts +10 -0
- package/dist/types/app/App.d.ts +50 -8
- package/dist/types/app/create-reducer.d.ts +55 -55
- package/dist/types/app/filter-empty.d.ts +8 -0
- package/dist/types/app/flows/handle-fetch-config.d.ts +12 -0
- package/dist/types/app/flows/handle-fetch-manifest.d.ts +12 -0
- package/dist/types/app/flows/handle-fetch-settings.d.ts +12 -0
- package/dist/types/app/flows/handle-import-application.d.ts +10 -0
- package/dist/types/app/flows/handle-update-settings.d.ts +12 -0
- package/dist/types/app/flows/index.d.ts +5 -0
- package/dist/types/errors/AppBuildError.d.ts +21 -0
- package/dist/types/errors/AppConfigError.d.ts +21 -0
- package/dist/types/errors/AppManifestError.d.ts +21 -0
- package/dist/types/errors/AppScriptModuleError.d.ts +14 -0
- package/dist/types/errors/AppSettingsError.d.ts +21 -0
- package/dist/types/errors/app-error-type.d.ts +9 -0
- package/dist/types/errors.d.ts +6 -103
- package/dist/types/version.d.ts +1 -1
- package/package.json +9 -9
- package/src/AppClient.ts +65 -4
- package/src/AppConfig.ts +9 -1
- package/src/AppConfigurator.ts +29 -4
- package/src/AppModuleProvider.ts +16 -0
- package/src/app/App.ts +89 -31
- package/src/app/actions.ts +2 -2
- package/src/app/create-reducer.ts +2 -1
- package/src/app/filter-empty.ts +11 -0
- package/src/app/flows/handle-fetch-config.ts +48 -0
- package/src/app/flows/handle-fetch-manifest.ts +53 -0
- package/src/app/flows/handle-fetch-settings.ts +50 -0
- package/src/app/flows/handle-import-application.ts +37 -0
- package/src/app/flows/handle-update-settings.ts +39 -0
- package/src/app/flows/index.ts +5 -0
- package/src/app/types.ts +2 -2
- package/src/enable-app-module.ts +2 -1
- package/src/errors/AppBuildError.ts +47 -0
- package/src/errors/AppConfigError.ts +47 -0
- package/src/errors/AppManifestError.ts +47 -0
- package/src/errors/AppScriptModuleError.ts +20 -0
- package/src/errors/AppSettingsError.ts +47 -0
- package/src/errors/app-error-type.ts +9 -0
- package/src/errors.ts +6 -208
- package/src/module.ts +2 -0
- package/src/schemas.ts +4 -0
- package/src/types.ts +1 -1
- package/src/version.ts +1 -1
- package/dist/esm/AppClient.Selectors.js.map +0 -1
- package/dist/esm/app/flows.js +0 -120
- package/dist/esm/app/flows.js.map +0 -1
- package/dist/types/app/flows.d.ts +0 -41
- package/src/app/flows.ts +0 -189
- /package/dist/types/{AppClient.Selectors.d.ts → AppConfigSelector.d.ts} +0 -0
- /package/src/{AppClient.Selectors.ts → AppConfigSelector.ts} +0 -0
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import type { Flow } from '@equinor/fusion-observable';
|
|
2
|
-
import type { AppModuleProvider } from '../AppModuleProvider';
|
|
3
|
-
import type { Actions } from './actions';
|
|
4
|
-
import type { AppBundleState } from './types';
|
|
5
|
-
/**
|
|
6
|
-
* Handles the fetch manifest action by fetching the app manifest from the provider,
|
|
7
|
-
* dispatching success or failure actions based on the result.
|
|
8
|
-
*
|
|
9
|
-
* @param provider The AppModuleProvider used to fetch the app manifest.
|
|
10
|
-
* @returns A Flow function that takes an Observable of actions and returns an Observable of actions.
|
|
11
|
-
*/
|
|
12
|
-
export declare const handleFetchManifest: (provider: AppModuleProvider) => Flow<Actions, AppBundleState>;
|
|
13
|
-
/**
|
|
14
|
-
* Handles the fetch config action by fetching the app configuration from the provider,
|
|
15
|
-
* filtering out null values, and dispatching success or failure actions accordingly.
|
|
16
|
-
*
|
|
17
|
-
* @param provider The AppModuleProvider used to fetch the app configuration.
|
|
18
|
-
* @returns A Flow function that takes an Observable of actions and returns an Observable of actions.
|
|
19
|
-
*/
|
|
20
|
-
export declare const handleFetchConfig: (provider: AppModuleProvider) => Flow<Actions, AppBundleState>;
|
|
21
|
-
/**
|
|
22
|
-
* Handles the fetch settings action by fetching the app settings from the provider,
|
|
23
|
-
* filtering out null values, and dispatching success or failure actions accordingly.
|
|
24
|
-
*
|
|
25
|
-
* @param provider The AppModuleProvider used to fetch the app settings.
|
|
26
|
-
* @returns A Flow function that takes an Observable of actions and returns an Observable of actions.
|
|
27
|
-
*/
|
|
28
|
-
export declare const handleFetchSettings: (provider: AppModuleProvider) => Flow<Actions, AppBundleState>;
|
|
29
|
-
/**
|
|
30
|
-
* Handles the set settings action by setting the app settings from the provider,
|
|
31
|
-
* filtering out null values, and dispatching success or failure actions accordingly.
|
|
32
|
-
*
|
|
33
|
-
* @param provider The AppModuleProvider used to fetch the app settings.
|
|
34
|
-
* @returns A Flow function that takes an Observable of actions and returns an Observable of actions.
|
|
35
|
-
*/
|
|
36
|
-
export declare const handleUpdateSettings: (provider: AppModuleProvider) => Flow<Actions, AppBundleState>;
|
|
37
|
-
/**
|
|
38
|
-
* Handles the import application flow.
|
|
39
|
-
* @returns A flow that takes in actions and returns an observable of AppBundleState.
|
|
40
|
-
*/
|
|
41
|
-
export declare const handleImportApplication: (provider: AppModuleProvider) => Flow<Actions, AppBundleState>;
|
package/src/app/flows.ts
DELETED
|
@@ -1,189 +0,0 @@
|
|
|
1
|
-
import { from, of, concat } from 'rxjs';
|
|
2
|
-
import { catchError, concatMap, filter, last, map, share, switchMap } from 'rxjs/operators';
|
|
3
|
-
|
|
4
|
-
import { actions } from './actions';
|
|
5
|
-
|
|
6
|
-
import type { Flow } from '@equinor/fusion-observable';
|
|
7
|
-
import type { AppModuleProvider } from '../AppModuleProvider';
|
|
8
|
-
import type { Actions } from './actions';
|
|
9
|
-
import type { AppBundleState } from './types';
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* Handles the fetch manifest action by fetching the app manifest from the provider,
|
|
13
|
-
* dispatching success or failure actions based on the result.
|
|
14
|
-
*
|
|
15
|
-
* @param provider The AppModuleProvider used to fetch the app manifest.
|
|
16
|
-
* @returns A Flow function that takes an Observable of actions and returns an Observable of actions.
|
|
17
|
-
*/
|
|
18
|
-
export const handleFetchManifest =
|
|
19
|
-
(provider: AppModuleProvider): Flow<Actions, AppBundleState> =>
|
|
20
|
-
(action$) =>
|
|
21
|
-
action$.pipe(
|
|
22
|
-
// only handle fetch manifest request actions
|
|
23
|
-
filter(actions.fetchManifest.match),
|
|
24
|
-
// when request is received, abort any ongoing request and start new
|
|
25
|
-
switchMap((action) => {
|
|
26
|
-
const {
|
|
27
|
-
payload: { key, tag },
|
|
28
|
-
meta: { update },
|
|
29
|
-
} = action;
|
|
30
|
-
|
|
31
|
-
// fetch manifest from provider
|
|
32
|
-
const subject = from(provider.getAppManifest(key, tag)).pipe(
|
|
33
|
-
// filter out null values
|
|
34
|
-
filter((x) => !!x),
|
|
35
|
-
// allow multiple subscriptions
|
|
36
|
-
share(),
|
|
37
|
-
);
|
|
38
|
-
|
|
39
|
-
// first load manifest and then dispatch success action
|
|
40
|
-
return concat(
|
|
41
|
-
subject.pipe(map((manifest) => actions.setManifest(manifest, update))),
|
|
42
|
-
subject.pipe(
|
|
43
|
-
last(),
|
|
44
|
-
map((manifest) => actions.fetchManifest.success(manifest)),
|
|
45
|
-
),
|
|
46
|
-
).pipe(
|
|
47
|
-
// catch any error and dispatch failure action
|
|
48
|
-
catchError((err) => {
|
|
49
|
-
return of(actions.fetchManifest.failure(err));
|
|
50
|
-
}),
|
|
51
|
-
);
|
|
52
|
-
}),
|
|
53
|
-
);
|
|
54
|
-
|
|
55
|
-
/**
|
|
56
|
-
* Handles the fetch config action by fetching the app configuration from the provider,
|
|
57
|
-
* filtering out null values, and dispatching success or failure actions accordingly.
|
|
58
|
-
*
|
|
59
|
-
* @param provider The AppModuleProvider used to fetch the app configuration.
|
|
60
|
-
* @returns A Flow function that takes an Observable of actions and returns an Observable of actions.
|
|
61
|
-
*/
|
|
62
|
-
export const handleFetchConfig =
|
|
63
|
-
(provider: AppModuleProvider): Flow<Actions, AppBundleState> =>
|
|
64
|
-
(action$) =>
|
|
65
|
-
action$.pipe(
|
|
66
|
-
// only handle fetch config request actions
|
|
67
|
-
filter(actions.fetchConfig.match),
|
|
68
|
-
// when request is received, abort any ongoing request and start new
|
|
69
|
-
switchMap(({ payload }) => {
|
|
70
|
-
// TODO - use the configUrl directly from the manifest
|
|
71
|
-
// fetch config from provider
|
|
72
|
-
const subject = from(provider.getAppConfig(payload.appKey, payload.build?.version)).pipe(
|
|
73
|
-
// filter out null values
|
|
74
|
-
filter((x) => !!x),
|
|
75
|
-
// allow multiple subscriptions
|
|
76
|
-
share(),
|
|
77
|
-
);
|
|
78
|
-
// first load config and then dispatch success action
|
|
79
|
-
return concat(
|
|
80
|
-
subject.pipe(map((config) => actions.setConfig(config))),
|
|
81
|
-
subject.pipe(
|
|
82
|
-
last(),
|
|
83
|
-
map((config) => actions.fetchConfig.success(config)),
|
|
84
|
-
),
|
|
85
|
-
).pipe(
|
|
86
|
-
// catch any error and dispatch failure action
|
|
87
|
-
catchError((err) => {
|
|
88
|
-
return of(actions.fetchConfig.failure(err));
|
|
89
|
-
}),
|
|
90
|
-
);
|
|
91
|
-
}),
|
|
92
|
-
);
|
|
93
|
-
|
|
94
|
-
/**
|
|
95
|
-
* Handles the fetch settings action by fetching the app settings from the provider,
|
|
96
|
-
* filtering out null values, and dispatching success or failure actions accordingly.
|
|
97
|
-
*
|
|
98
|
-
* @param provider The AppModuleProvider used to fetch the app settings.
|
|
99
|
-
* @returns A Flow function that takes an Observable of actions and returns an Observable of actions.
|
|
100
|
-
*/
|
|
101
|
-
export const handleFetchSettings =
|
|
102
|
-
(provider: AppModuleProvider): Flow<Actions, AppBundleState> =>
|
|
103
|
-
(action$) =>
|
|
104
|
-
action$.pipe(
|
|
105
|
-
// only handle fetch settings request actions
|
|
106
|
-
filter(actions.fetchSettings.match),
|
|
107
|
-
// when request is received, abort any ongoing request and start new
|
|
108
|
-
switchMap(({ payload }) => {
|
|
109
|
-
const { appKey } = payload;
|
|
110
|
-
|
|
111
|
-
// fetch settings from provider
|
|
112
|
-
const subject = from(provider.getAppSettings(appKey)).pipe(
|
|
113
|
-
// filter out null values
|
|
114
|
-
filter((x) => !!x),
|
|
115
|
-
// allow multiple subscriptions
|
|
116
|
-
share(),
|
|
117
|
-
);
|
|
118
|
-
|
|
119
|
-
// first load settings and then dispatch success action
|
|
120
|
-
return concat(
|
|
121
|
-
subject.pipe(map((settings) => actions.setSettings(settings))),
|
|
122
|
-
subject.pipe(
|
|
123
|
-
last(),
|
|
124
|
-
map((settings) => actions.fetchSettings.success(settings)),
|
|
125
|
-
),
|
|
126
|
-
).pipe(
|
|
127
|
-
// catch any error and dispatch failure action
|
|
128
|
-
catchError((err) => {
|
|
129
|
-
return of(actions.fetchSettings.failure(err));
|
|
130
|
-
}),
|
|
131
|
-
);
|
|
132
|
-
}),
|
|
133
|
-
);
|
|
134
|
-
|
|
135
|
-
/**
|
|
136
|
-
* Handles the set settings action by setting the app settings from the provider,
|
|
137
|
-
* filtering out null values, and dispatching success or failure actions accordingly.
|
|
138
|
-
*
|
|
139
|
-
* @param provider The AppModuleProvider used to fetch the app settings.
|
|
140
|
-
* @returns A Flow function that takes an Observable of actions and returns an Observable of actions.
|
|
141
|
-
*/
|
|
142
|
-
export const handleUpdateSettings =
|
|
143
|
-
(provider: AppModuleProvider): Flow<Actions, AppBundleState> =>
|
|
144
|
-
(action$) => {
|
|
145
|
-
return action$.pipe(filter(actions.updateSettings.match)).pipe(
|
|
146
|
-
switchMap(({ payload }) => {
|
|
147
|
-
const { appKey, settings } = payload;
|
|
148
|
-
return provider.updateAppSettings(appKey, settings).pipe(
|
|
149
|
-
// take the last value
|
|
150
|
-
last(),
|
|
151
|
-
// request updating of settings and dispatch success action
|
|
152
|
-
concatMap((updatedSettings) =>
|
|
153
|
-
from([
|
|
154
|
-
actions.setSettings(updatedSettings),
|
|
155
|
-
actions.updateSettings.success(updatedSettings),
|
|
156
|
-
]),
|
|
157
|
-
),
|
|
158
|
-
catchError((err) => of(actions.updateSettings.failure(err))),
|
|
159
|
-
);
|
|
160
|
-
}),
|
|
161
|
-
);
|
|
162
|
-
};
|
|
163
|
-
|
|
164
|
-
/**
|
|
165
|
-
* Handles the import application flow.
|
|
166
|
-
* @returns A flow that takes in actions and returns an observable of AppBundleState.
|
|
167
|
-
*/
|
|
168
|
-
export const handleImportApplication =
|
|
169
|
-
(provider: AppModuleProvider): Flow<Actions, AppBundleState> =>
|
|
170
|
-
(action$) =>
|
|
171
|
-
action$.pipe(
|
|
172
|
-
// only handle import script request actions
|
|
173
|
-
filter(actions.importApp.match),
|
|
174
|
-
// when request is received, abort any ongoing request and start new
|
|
175
|
-
switchMap(({ payload }) => {
|
|
176
|
-
// dynamically import the application script
|
|
177
|
-
return from(
|
|
178
|
-
import(
|
|
179
|
-
/* @vite-ignore */ /* webpackIgnore: true */
|
|
180
|
-
[provider.assetUri, payload].join('/').replace(/\/{2,}/g, '/')
|
|
181
|
-
),
|
|
182
|
-
).pipe(
|
|
183
|
-
// dispatch success action
|
|
184
|
-
map(actions.importApp.success),
|
|
185
|
-
// catch any error and dispatch failure action
|
|
186
|
-
catchError((err) => of(actions.importApp.failure(err))),
|
|
187
|
-
);
|
|
188
|
-
}),
|
|
189
|
-
);
|
|
File without changes
|
|
File without changes
|