@o3r/core 12.1.0-prerelease.10 → 12.1.0-prerelease.12
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/core/application/build-properties.js +17 -0
- package/core/application/build-properties.js.map +1 -0
- package/core/application/dgp.interfaces.js +2 -0
- package/core/application/dgp.interfaces.js.map +1 -0
- package/core/application/index.js +4 -0
- package/core/application/index.js.map +1 -0
- package/core/application/runtime.js +2 -0
- package/core/application/runtime.js.map +1 -0
- package/core/common/index.js +3 -0
- package/core/common/index.js.map +1 -0
- package/core/common/interface-utils.js +2 -0
- package/core/common/interface-utils.js.map +1 -0
- package/core/common/label-value.js +2 -0
- package/core/common/label-value.js.map +1 -0
- package/core/devkit/devtools.interface.js +2 -0
- package/core/devkit/devtools.interface.js.map +1 -0
- package/core/devkit/index.js +2 -0
- package/core/devkit/index.js.map +1 -0
- package/core/index.js +7 -0
- package/core/index.js.map +1 -0
- package/core/interfaces/configuration.js +2 -0
- package/core/interfaces/configuration.js.map +1 -0
- package/core/interfaces/context.js +2 -0
- package/core/interfaces/context.js.map +1 -0
- package/core/interfaces/index.js +5 -0
- package/core/interfaces/index.js.map +1 -0
- package/core/interfaces/item-identifier.js +2 -0
- package/core/interfaces/item-identifier.js.map +1 -0
- package/core/interfaces/translation.js +2 -0
- package/core/interfaces/translation.js.map +1 -0
- package/core/metadata/component.decorator.js +18 -0
- package/core/metadata/component.decorator.js.map +1 -0
- package/core/metadata/component.identifier.js +9 -0
- package/core/metadata/component.identifier.js.map +1 -0
- package/core/metadata/index.js +4 -0
- package/core/metadata/index.js.map +1 -0
- package/core/metadata/metadata.interface.js +2 -0
- package/core/metadata/metadata.interface.js.map +1 -0
- package/core/rules-engine/index.js +2 -0
- package/core/rules-engine/index.js.map +1 -0
- package/core/rules-engine/rules-engine.interfaces.js +2 -0
- package/core/rules-engine/rules-engine.interfaces.js.map +1 -0
- package/log/index.js +2 -0
- package/log/index.js.map +1 -0
- package/log/logger.js +2 -0
- package/log/logger.js.map +1 -0
- package/messages/common-message.interface.js +2 -0
- package/messages/common-message.interface.js.map +1 -0
- package/messages/index.js +4 -0
- package/messages/index.js.map +1 -0
- package/messages/message.helpers.js +54 -0
- package/messages/message.helpers.js.map +1 -0
- package/messages/message.interfaces.js +5 -0
- package/messages/message.interfaces.js.map +1 -0
- package/package.json +4 -4
- package/public_api.js +6 -0
- package/public_api.js.map +1 -0
- package/store/async/async-entity.adapter.js +53 -0
- package/store/async/async-entity.adapter.js.map +1 -0
- package/store/async/async.adapter.js +94 -0
- package/store/async/async.adapter.js.map +1 -0
- package/store/async/async.helpers.js +25 -0
- package/store/async/async.helpers.js.map +1 -0
- package/store/async/async.interfaces.js +2 -0
- package/store/async/async.interfaces.js.map +1 -0
- package/store/async/async.operators.js +75 -0
- package/store/async/async.operators.js.map +1 -0
- package/store/async/async.props.js +10 -0
- package/store/async/async.props.js.map +1 -0
- package/store/async/async.serializer.js +34 -0
- package/store/async/async.serializer.js.map +1 -0
- package/store/async/index.js +8 -0
- package/store/async/index.js.map +1 -0
- package/store/index.js +3 -0
- package/store/index.js.map +1 -0
- package/store/types.js +11 -0
- package/store/types.js.map +1 -0
- package/utils/debug/debug.helper.js +19 -0
- package/utils/debug/debug.helper.js.map +1 -0
- package/utils/deep-fill/deep-fill.js +71 -0
- package/utils/deep-fill/deep-fill.js.map +1 -0
- package/utils/index.js +4 -0
- package/utils/index.js.map +1 -0
- package/utils/rendering/rendering.helpers.js +31 -0
- package/utils/rendering/rendering.helpers.js.map +1 -0
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/* eslint-disable @typescript-eslint/naming-convention -- exception for `BuildTimeProperties` */
|
|
2
|
+
/**
|
|
3
|
+
* Library build time default properties
|
|
4
|
+
*/
|
|
5
|
+
export const DEFAULT_BUILD_PROPERTIES = {
|
|
6
|
+
DEBUG_MODE: true,
|
|
7
|
+
APP_BASE_HREF: '.',
|
|
8
|
+
APP_VERSION: '0.0.0',
|
|
9
|
+
DEFAULT_LOC_BUNDLE_NAME: '',
|
|
10
|
+
DEVTOOL_HISTORY_SIZE: 20,
|
|
11
|
+
ENABLE_GHOSTING: false,
|
|
12
|
+
ENABLE_WEBSTORAGE: true,
|
|
13
|
+
ENVIRONMENT: 'dev',
|
|
14
|
+
LOCALIZATION_BUNDLES_OUTPUT: 'localizations/',
|
|
15
|
+
USE_MOCKS: false
|
|
16
|
+
};
|
|
17
|
+
//# sourceMappingURL=build-properties.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"build-properties.js","sourceRoot":"","sources":["../../../src/core/application/build-properties.ts"],"names":[],"mappings":"AAAA,gGAAgG;AAyDhG;;GAEG;AACH,MAAM,CAAC,MAAM,wBAAwB,GAAkC;IACrE,UAAU,EAAE,IAAI;IAChB,aAAa,EAAE,GAAG;IAClB,WAAW,EAAE,OAAO;IACpB,uBAAuB,EAAE,EAAE;IAC3B,oBAAoB,EAAE,EAAE;IACxB,eAAe,EAAE,KAAK;IACtB,iBAAiB,EAAE,IAAI;IACvB,WAAW,EAAE,KAAK;IAClB,2BAA2B,EAAE,gBAAgB;IAC7C,SAAS,EAAE,KAAK;CACR,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dgp.interfaces.js","sourceRoot":"","sources":["../../../src/core/application/dgp.interfaces.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/core/application/index.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAC;AACnC,cAAc,kBAAkB,CAAC;AACjC,cAAc,WAAW,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runtime.js","sourceRoot":"","sources":["../../../src/core/application/runtime.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/core/common/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC;AAClC,cAAc,eAAe,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"interface-utils.js","sourceRoot":"","sources":["../../../src/core/common/interface-utils.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"label-value.js","sourceRoot":"","sources":["../../../src/core/common/label-value.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"devtools.interface.js","sourceRoot":"","sources":["../../../src/core/devkit/devtools.interface.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/core/devkit/index.ts"],"names":[],"mappings":"AAAA,cAAc,sBAAsB,CAAC"}
|
package/core/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/core/index.ts"],"names":[],"mappings":"AAAA,cAAc,qBAAqB,CAAC;AACpC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,oBAAoB,CAAC;AACnC,cAAc,kBAAkB,CAAC;AACjC,cAAc,sBAAsB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"configuration.js","sourceRoot":"","sources":["../../../src/core/interfaces/configuration.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"context.js","sourceRoot":"","sources":["../../../src/core/interfaces/context.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/core/interfaces/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAC;AAChC,cAAc,WAAW,CAAC;AAC1B,cAAc,mBAAmB,CAAC;AAClC,cAAc,eAAe,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"item-identifier.js","sourceRoot":"","sources":["../../../src/core/interfaces/item-identifier.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"translation.js","sourceRoot":"","sources":["../../../src/core/interfaces/translation.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Private field where Otter component information are stored
|
|
3
|
+
*/
|
|
4
|
+
export const otterComponentInfoPropertyName = '__otter-info__';
|
|
5
|
+
/**
|
|
6
|
+
* Decorates an Angular component to provide Otter information
|
|
7
|
+
* @param info Information to define the Otter component
|
|
8
|
+
* @returns the component with the information
|
|
9
|
+
*/
|
|
10
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention -- decorator should be PascalCase
|
|
11
|
+
export function O3rComponent(info) {
|
|
12
|
+
return (constructor) => {
|
|
13
|
+
const componentName = constructor.name;
|
|
14
|
+
constructor.prototype[otterComponentInfoPropertyName] = { ...info, componentName };
|
|
15
|
+
return constructor;
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=component.decorator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"component.decorator.js","sourceRoot":"","sources":["../../../src/core/metadata/component.decorator.ts"],"names":[],"mappings":"AA2BA;;GAEG;AACH,MAAM,CAAC,MAAM,8BAA8B,GAAG,gBAAgB,CAAC;AAE/D;;;;GAIG;AACH,kGAAkG;AAClG,MAAM,UAAU,YAAY,CAAC,IAAiC;IAC5D,OAAO,CAA2C,WAAc,EAAE,EAAE;QAClE,MAAM,aAAa,GAAG,WAAW,CAAC,IAAI,CAAC;QACvC,WAAW,CAAC,SAAS,CAAC,8BAA8B,CAAC,GAAG,EAAE,GAAG,IAAI,EAAE,aAAa,EAAE,CAAC;QACnF,OAAO,WAAW,CAAC;IACrB,CAAC,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Compute the name of the component with the library's name to generate unique component identifier used in metadata and different modules
|
|
3
|
+
* @param componentName Name of the component to get the configuration
|
|
4
|
+
* @param libraryName Name of the library the component is coming from
|
|
5
|
+
*/
|
|
6
|
+
export function computeItemIdentifier(componentName, libraryName) {
|
|
7
|
+
return (libraryName ? libraryName + '#' : '') + componentName;
|
|
8
|
+
}
|
|
9
|
+
//# sourceMappingURL=component.identifier.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"component.identifier.js","sourceRoot":"","sources":["../../../src/core/metadata/component.identifier.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,MAAM,UAAU,qBAAqB,CAAC,aAAqB,EAAE,WAAoB;IAC/E,OAAO,CAAC,WAAW,CAAC,CAAC,CAAC,WAAW,GAAG,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,GAAG,aAAa,CAAC;AAChE,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/core/metadata/index.ts"],"names":[],"mappings":"AAAA,cAAc,uBAAuB,CAAC;AACtC,cAAc,wBAAwB,CAAC;AACvC,cAAc,sBAAsB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"metadata.interface.js","sourceRoot":"","sources":["../../../src/core/metadata/metadata.interface.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/core/rules-engine/index.ts"],"names":[],"mappings":"AAAA,cAAc,2BAA2B,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rules-engine.interfaces.js","sourceRoot":"","sources":["../../../src/core/rules-engine/rules-engine.interfaces.ts"],"names":[],"mappings":""}
|
package/log/index.js
ADDED
package/log/index.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/log/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC"}
|
package/log/logger.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logger.js","sourceRoot":"","sources":["../../src/log/logger.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"common-message.interface.js","sourceRoot":"","sources":["../../src/messages/common-message.interface.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/messages/index.ts"],"names":[],"mappings":"AAAA,cAAc,4BAA4B,CAAC;AAC3C,cAAc,mBAAmB,CAAC;AAClC,cAAc,sBAAsB,CAAC"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { filter, map, } from 'rxjs';
|
|
2
|
+
import { applicationMessageTarget, otterMessageType, } from './message.interfaces';
|
|
3
|
+
/**
|
|
4
|
+
* Determine if a message should be handle by the application
|
|
5
|
+
* @param message Message to analyze
|
|
6
|
+
*/
|
|
7
|
+
export const isToAppOtterMessage = (message) => {
|
|
8
|
+
return message?.to === applicationMessageTarget;
|
|
9
|
+
};
|
|
10
|
+
/**
|
|
11
|
+
* Determine if a message is emitted by an Otter tool
|
|
12
|
+
* @param message Message to analyze
|
|
13
|
+
*/
|
|
14
|
+
export const isOtterMessage = (message) => {
|
|
15
|
+
return message?.type === otterMessageType;
|
|
16
|
+
};
|
|
17
|
+
/**
|
|
18
|
+
* Send an Otter Message
|
|
19
|
+
* @param dataType Type of the message
|
|
20
|
+
* @param content content of the message
|
|
21
|
+
* @param preStringify determine if the message should JSON.stringify before being send (will use the default mechanism otherwise)
|
|
22
|
+
*/
|
|
23
|
+
export const sendOtterMessage = (dataType, content, preStringify = true) => {
|
|
24
|
+
const message = {
|
|
25
|
+
type: otterMessageType,
|
|
26
|
+
content: {
|
|
27
|
+
...content,
|
|
28
|
+
dataType
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
return window.postMessage(preStringify ? JSON.stringify(message) : message, '*');
|
|
32
|
+
};
|
|
33
|
+
/**
|
|
34
|
+
* Filter the Otter message that should be handle by the application and returns it content
|
|
35
|
+
* @param predicate condition to filter the message
|
|
36
|
+
* @returns content of the message
|
|
37
|
+
*/
|
|
38
|
+
/**
|
|
39
|
+
* Operator to get only Otter messages that match the predicate
|
|
40
|
+
* @param predicate
|
|
41
|
+
*/
|
|
42
|
+
export function filterMessageContent(predicate) {
|
|
43
|
+
return (source$) => {
|
|
44
|
+
const obs = source$.pipe(map((event) => {
|
|
45
|
+
const data = event.data;
|
|
46
|
+
return typeof data === 'string' ? JSON.parse(data) : data;
|
|
47
|
+
}), filter(isOtterMessage), filter(isToAppOtterMessage), map((message) => message.content));
|
|
48
|
+
if (predicate) {
|
|
49
|
+
return obs.pipe(filter(predicate));
|
|
50
|
+
}
|
|
51
|
+
return obs;
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
//# sourceMappingURL=message.helpers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"message.helpers.js","sourceRoot":"","sources":["../../src/messages/message.helpers.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,MAAM,EACN,GAAG,GAEJ,MAAM,MAAM,CAAC;AACd,OAAO,EACL,wBAAwB,EAKxB,gBAAgB,GACjB,MAAM,sBAAsB,CAAC;AAE9B;;;GAGG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAyB,OAAW,EAA4D,EAAE;IACnI,OAAO,OAAO,EAAE,EAAE,KAAK,wBAAwB,CAAC;AAClD,CAAC,CAAC;AAEF;;;GAGG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,CAAgC,OAAY,EAA8B,EAAE;IACxG,OAAO,OAAO,EAAE,IAAI,KAAK,gBAAgB,CAAC;AAC5C,CAAC,CAAC;AAEF;;;;;GAKG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAgC,QAAuB,EAAE,OAA8B,EAAE,YAAY,GAAG,IAAI,EAAE,EAAE;IAC9I,MAAM,OAAO,GAAG;QACd,IAAI,EAAE,gBAAgB;QACtB,OAAO,EAAE;YACP,GAAG,OAAO;YACV,QAAQ;SACT;KACF,CAAC;IACF,OAAO,MAAM,CAAC,WAAW,CAAC,YAAY,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC;AACnF,CAAC,CAAC;AAIF;;;;GAIG;AAEH;;;GAGG;AACH,MAAM,UAAU,oBAAoB,CAAgE,SAA0C;IAE5I,OAAO,CAAC,OAAsB,EAAE,EAAE;QAChC,MAAM,GAAG,GAAG,OAAO,CAAC,IAAI,CACtB,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE;YACZ,MAAM,IAAI,GAAI,KAAsB,CAAC,IAAI,CAAC;YAC1C,OAAO,OAAO,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;QAC5D,CAAC,CAAC,EACF,MAAM,CAAC,cAAc,CAAC,EACtB,MAAM,CAAC,mBAAmB,CAAC,EAC3B,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,OAAO,CAAC,CAClC,CAAC;QACF,IAAI,SAAS,EAAE,CAAC;YACd,OAAO,GAAG,CAAC,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,CAAC;QACrC,CAAC;QACD,OAAO,GAAG,CAAC;IACb,CAAC,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/** Type of a message exchanged within the Otter Framework */
|
|
2
|
+
export const otterMessageType = 'otter';
|
|
3
|
+
/** Target of a message that should be handled by the application */
|
|
4
|
+
export const applicationMessageTarget = 'app';
|
|
5
|
+
//# sourceMappingURL=message.interfaces.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"message.interfaces.js","sourceRoot":"","sources":["../../src/messages/message.interfaces.ts"],"names":[],"mappings":"AAAA,6DAA6D;AAC7D,MAAM,CAAC,MAAM,gBAAgB,GAAG,OAAO,CAAC;AAExC,oEAAoE;AACpE,MAAM,CAAC,MAAM,wBAAwB,GAAG,KAAK,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@o3r/core",
|
|
3
|
-
"version": "12.1.0-prerelease.
|
|
3
|
+
"version": "12.1.0-prerelease.12",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
"@ngrx/entity": "^19.0.0",
|
|
26
26
|
"@ngrx/store": "^19.0.0",
|
|
27
27
|
"@nx/angular": "~20.2.0",
|
|
28
|
-
"@o3r/telemetry": "^12.1.0-prerelease.
|
|
28
|
+
"@o3r/telemetry": "^12.1.0-prerelease.12",
|
|
29
29
|
"@schematics/angular": "^19.0.0",
|
|
30
30
|
"chokidar": "^4.0.3",
|
|
31
31
|
"globby": "^11.1.0",
|
|
@@ -64,7 +64,7 @@
|
|
|
64
64
|
}
|
|
65
65
|
},
|
|
66
66
|
"dependencies": {
|
|
67
|
-
"@o3r/schematics": "^12.1.0-prerelease.
|
|
67
|
+
"@o3r/schematics": "^12.1.0-prerelease.12",
|
|
68
68
|
"tslib": "^2.6.2",
|
|
69
69
|
"uuid": "^11.0.5"
|
|
70
70
|
},
|
|
@@ -77,7 +77,7 @@
|
|
|
77
77
|
"@ngrx/store": "~19.0.0",
|
|
78
78
|
"@ngrx/store-devtools": "~19.0.0",
|
|
79
79
|
"@nx/eslint-plugin": "~20.2.0",
|
|
80
|
-
"@o3r/store-sync": "^12.1.0-prerelease.
|
|
80
|
+
"@o3r/store-sync": "^12.1.0-prerelease.12",
|
|
81
81
|
"@stylistic/eslint-plugin": "~3.0.0",
|
|
82
82
|
"@types/jest": "~29.5.2",
|
|
83
83
|
"@typescript-eslint/eslint-plugin": "~8.22.0",
|
package/public_api.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"public_api.js","sourceRoot":"","sources":["../src/public_api.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,cAAc,aAAa,CAAC;AAC5B,cAAc,kBAAkB,CAAC;AACjC,cAAc,eAAe,CAAC;AAC9B,cAAc,eAAe,CAAC"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { asyncStoreItemAdapter, } from './async.adapter';
|
|
2
|
+
/**
|
|
3
|
+
* Create an Asynchronous Request Entity Adapter
|
|
4
|
+
* @param adapter Entity Adapter
|
|
5
|
+
*/
|
|
6
|
+
export function createEntityAsyncRequestAdapter(adapter) {
|
|
7
|
+
const addRequestOne = (state, id, requestId) => {
|
|
8
|
+
const currentEntity = typeof id !== 'undefined' && id !== null && state.entities[id];
|
|
9
|
+
if (currentEntity) {
|
|
10
|
+
const changes = asyncStoreItemAdapter.addRequest(asyncStoreItemAdapter.extractAsyncStoreItem(currentEntity), requestId);
|
|
11
|
+
return adapter.updateOne({ id, changes }, state);
|
|
12
|
+
}
|
|
13
|
+
return asyncStoreItemAdapter.addRequest(state, requestId);
|
|
14
|
+
};
|
|
15
|
+
const addRequestMany = (state, ids, requestId) => adapter.updateMany(ids.filter((id) => !!state.entities[id]).map((id) => ({
|
|
16
|
+
id,
|
|
17
|
+
changes: asyncStoreItemAdapter.addRequest(asyncStoreItemAdapter.extractAsyncStoreItem(state.entities[id]), requestId)
|
|
18
|
+
})), state);
|
|
19
|
+
const resolveRequestOne = (state, entity, requestId, idProperty = 'id') => {
|
|
20
|
+
let newEntity;
|
|
21
|
+
const currentEntity = state.entities[entity[idProperty]];
|
|
22
|
+
if (currentEntity) {
|
|
23
|
+
newEntity = asyncStoreItemAdapter.resolveRequest({ ...entity, ...asyncStoreItemAdapter.extractAsyncStoreItem(currentEntity) }, requestId);
|
|
24
|
+
}
|
|
25
|
+
else {
|
|
26
|
+
newEntity = asyncStoreItemAdapter.initialize(entity);
|
|
27
|
+
state = asyncStoreItemAdapter.resolveRequest(state, requestId);
|
|
28
|
+
}
|
|
29
|
+
return adapter.upsertOne(newEntity, state);
|
|
30
|
+
};
|
|
31
|
+
const resolveRequestMany = (state, entities, requestId, idProperty = 'id') => adapter.updateMany(entities.filter((entity) => !!state.entities[entity[idProperty]]).map((entity) => {
|
|
32
|
+
const model = { ...entity, ...asyncStoreItemAdapter.extractAsyncStoreItem(state.entities[entity[idProperty]]) };
|
|
33
|
+
return { id: entity[idProperty], changes: asyncStoreItemAdapter.resolveRequest(model, requestId) };
|
|
34
|
+
}), state);
|
|
35
|
+
const failRequestMany = (state, ids = [], requestId) => {
|
|
36
|
+
if (ids.length > 0 && !ids.some((id) => state.entities[id] === undefined)) {
|
|
37
|
+
return adapter.updateMany(ids.map((id) => ({
|
|
38
|
+
id,
|
|
39
|
+
changes: asyncStoreItemAdapter.failRequest(asyncStoreItemAdapter.extractAsyncStoreItem(state.entities[id]), requestId)
|
|
40
|
+
})), state);
|
|
41
|
+
}
|
|
42
|
+
return asyncStoreItemAdapter.failRequest(state, requestId);
|
|
43
|
+
};
|
|
44
|
+
return {
|
|
45
|
+
...adapter,
|
|
46
|
+
failRequestMany,
|
|
47
|
+
addRequestOne,
|
|
48
|
+
addRequestMany,
|
|
49
|
+
resolveRequestOne,
|
|
50
|
+
resolveRequestMany
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
//# sourceMappingURL=async-entity.adapter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"async-entity.adapter.js","sourceRoot":"","sources":["../../../src/store/async/async-entity.adapter.ts"],"names":[],"mappings":"AAKA,OAAO,EACL,qBAAqB,GACtB,MAAM,iBAAiB,CAAC;AAoEzB;;;GAGG;AAC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,EAAE,EAAE,EAAE,CAAC,KAAK,CAAC,QAAQ,CAAC,EAAE,CAAC,KAAK,SAAS,CAAC,EAAE,CAAC;YAC1E,OAAO,OAAO,CAAC,UAAU,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC;gBACzC,EAAE;gBACF,OAAO,EAAE,qBAAqB,CAAC,WAAW,CAAC,qBAAqB,CAAC,qBAAqB,CAAC,KAAK,CAAC,QAAQ,CAAC,EAAE,CAAE,CAAC,EAAE,SAAS,CAAC;aAC1G,CAAA,CACd,EAAE,KAAK,CAAC,CAAC;QACZ,CAAC;QACD,OAAO,qBAAqB,CAAC,WAAW,CAAC,KAAK,EAAE,SAAS,CAAC,CAAC;IAC7D,CAAC,CAAC;IAEF,OAAO;QACL,GAAG,OAAO;QACV,eAAe;QACf,aAAa;QACb,cAAc;QACd,iBAAiB;QACjB,kBAAkB;KACnB,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
export const asyncStoreItemAdapter = {
|
|
2
|
+
addRequest: (item, requestId) => {
|
|
3
|
+
return {
|
|
4
|
+
...item,
|
|
5
|
+
requestIds: [...item.requestIds, requestId],
|
|
6
|
+
isFailure: item.requestIds.length === 0 ? false : item.isFailure,
|
|
7
|
+
isPending: true
|
|
8
|
+
};
|
|
9
|
+
},
|
|
10
|
+
failRequest: (item, requestId) => {
|
|
11
|
+
const requestIds = requestId ? item.requestIds.filter((id) => id !== requestId) : item.requestIds;
|
|
12
|
+
return {
|
|
13
|
+
...item,
|
|
14
|
+
isFailure: true,
|
|
15
|
+
isPending: requestIds.length > 0,
|
|
16
|
+
requestIds
|
|
17
|
+
};
|
|
18
|
+
},
|
|
19
|
+
resolveRequest: (item, requestId) => {
|
|
20
|
+
const requestIds = requestId ? item.requestIds.filter((id) => id !== requestId) : item.requestIds;
|
|
21
|
+
return {
|
|
22
|
+
...item,
|
|
23
|
+
requestIds,
|
|
24
|
+
isPending: requestIds.length > 0
|
|
25
|
+
};
|
|
26
|
+
},
|
|
27
|
+
initialize: (entityItem) => {
|
|
28
|
+
return {
|
|
29
|
+
...entityItem,
|
|
30
|
+
requestIds: []
|
|
31
|
+
};
|
|
32
|
+
},
|
|
33
|
+
extractAsyncStoreItem: (entityItem) => {
|
|
34
|
+
return {
|
|
35
|
+
requestIds: [...entityItem.requestIds],
|
|
36
|
+
isFailure: entityItem.isFailure,
|
|
37
|
+
isPending: entityItem.isPending
|
|
38
|
+
};
|
|
39
|
+
},
|
|
40
|
+
clearAsyncStoreItem: (entityItem) => {
|
|
41
|
+
const { isPending, isFailure, ...newResponse } = { ...entityItem, requestIds: [] };
|
|
42
|
+
return newResponse;
|
|
43
|
+
},
|
|
44
|
+
merge: (...items) => {
|
|
45
|
+
return items.reduce((mergedItem, item) => item
|
|
46
|
+
? {
|
|
47
|
+
requestIds: [...mergedItem.requestIds, ...item.requestIds],
|
|
48
|
+
isFailure: mergedItem.isFailure || item.isFailure,
|
|
49
|
+
isPending: mergedItem.isPending || item.isPending
|
|
50
|
+
}
|
|
51
|
+
: mergedItem, asyncStoreItemAdapter.initialize({}));
|
|
52
|
+
},
|
|
53
|
+
entityStatusAddRequest: (status, subResource, requestId) => {
|
|
54
|
+
const currentSubStatus = status[subResource] || asyncStoreItemAdapter.initialize({});
|
|
55
|
+
return {
|
|
56
|
+
...status,
|
|
57
|
+
[subResource]: asyncStoreItemAdapter.addRequest(currentSubStatus, requestId)
|
|
58
|
+
};
|
|
59
|
+
},
|
|
60
|
+
entityStatusResolveRequest: (status, subResource, requestId) => {
|
|
61
|
+
const currentSubStatus = status[subResource];
|
|
62
|
+
return {
|
|
63
|
+
...status,
|
|
64
|
+
[subResource]: currentSubStatus ? asyncStoreItemAdapter.resolveRequest(currentSubStatus, requestId) : { requestIds: [] }
|
|
65
|
+
};
|
|
66
|
+
},
|
|
67
|
+
entityStatusFailRequest: (status, subResource, requestId) => {
|
|
68
|
+
const currentSubStatus = status[subResource];
|
|
69
|
+
return {
|
|
70
|
+
...status,
|
|
71
|
+
[subResource]: currentSubStatus ? asyncStoreItemAdapter.failRequest(currentSubStatus, requestId) : { requestIds: [], isFailure: true }
|
|
72
|
+
};
|
|
73
|
+
},
|
|
74
|
+
entityStatusResetFailure: (status, subResource) => {
|
|
75
|
+
const currentSubStatus = status[subResource];
|
|
76
|
+
return {
|
|
77
|
+
...status,
|
|
78
|
+
[subResource]: currentSubStatus ? asyncStoreItemAdapter.resetFailureStatus(currentSubStatus) : { requestIds: [] }
|
|
79
|
+
};
|
|
80
|
+
},
|
|
81
|
+
resetFailureStatus: (entityItem) => {
|
|
82
|
+
return {
|
|
83
|
+
...entityItem,
|
|
84
|
+
isFailure: false
|
|
85
|
+
};
|
|
86
|
+
},
|
|
87
|
+
setLoadingStatus: (entityItem) => {
|
|
88
|
+
return {
|
|
89
|
+
...entityItem,
|
|
90
|
+
isPending: true
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
};
|
|
94
|
+
//# sourceMappingURL=async.adapter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"async.adapter.js","sourceRoot":"","sources":["../../../src/store/async/async.adapter.ts"],"names":[],"mappings":"AA0GA,MAAM,CAAC,MAAM,qBAAqB,GAA0B;IAC1D,UAAU,EAAE,CAAC,IAAI,EAAE,SAAS,EAAE,EAAE;QAC9B,OAAO;YACL,GAAG,IAAI;YACP,UAAU,EAAE,CAAC,GAAG,IAAI,CAAC,UAAU,EAAE,SAAS,CAAC;YAC3C,SAAS,EAAE,IAAI,CAAC,UAAU,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS;YAChE,SAAS,EAAE,IAAI;SAChB,CAAC;IACJ,CAAC;IAED,WAAW,EAAE,CAAC,IAAI,EAAE,SAAS,EAAE,EAAE;QAC/B,MAAM,UAAU,GAAG,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,UAAU,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AE,SAAS,CAAC,CAAC,CAAC,CAAC,EAAE,UAAU,EAAE,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE;SACvI,CAAC;IACJ,CAAC;IAED,wBAAwB,EAAE,CAAC,MAAM,EAAE,WAAW,EAAE,EAAE;QAChD,MAAM,gBAAgB,GAAG,MAAM,CAAC,WAAW,CAAC,CAAC;QAC7C,OAAO;YACL,GAAG,MAAM;YACT,CAAC,WAAW,CAAC,EAAE,gBAAgB,CAAC,CAAC,CAAC,qBAAqB,CAAC,kBAAkB,CAAC,gBAAgB,CAAC,CAAC,CAAC,CAAC,EAAE,UAAU,EAAE,EAAE,EAAE;SAClH,CAAC;IACJ,CAAC;IAED,kBAAkB,EAAE,CAAC,UAAU,EAAE,EAAE;QACjC,OAAO;YACL,GAAG,UAAU;YACb,SAAS,EAAE,KAAK;SACjB,CAAC;IACJ,CAAC;IAED,gBAAgB,EAAE,CAAC,UAAU,EAAE,EAAE;QAC/B,OAAO;YACL,GAAG,UAAU;YACb,SAAS,EAAE,IAAI;SAChB,CAAC;IACJ,CAAC;CACF,CAAC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Determine if the action is an AsyncRequest action
|
|
3
|
+
* @param action Redux Action
|
|
4
|
+
*/
|
|
5
|
+
export function isCallAction(action) {
|
|
6
|
+
if (!action) {
|
|
7
|
+
return false;
|
|
8
|
+
}
|
|
9
|
+
return !!action.call && action.call instanceof Promise;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Determine if the action is an AsyncRequest action with a Request ID
|
|
13
|
+
* @param action Redux Action
|
|
14
|
+
*/
|
|
15
|
+
export function isIdentifiedCallAction(action) {
|
|
16
|
+
return isCallAction(action) && typeof action.requestId !== 'undefined';
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Determine if the given item implements the AsyncRequest interface
|
|
20
|
+
* @param item
|
|
21
|
+
*/
|
|
22
|
+
export function isAsyncRequest(item) {
|
|
23
|
+
return typeof item.requestId !== 'undefined';
|
|
24
|
+
}
|
|
25
|
+
//# sourceMappingURL=async.helpers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"async.helpers.js","sourceRoot":"","sources":["../../../src/store/async/async.helpers.ts"],"names":[],"mappings":"AAKA;;;GAGG;AACH,MAAM,UAAU,YAAY,CAAU,MAAY;IAChD,IAAI,CAAC,MAAM,EAAE,CAAC;QACZ,OAAO,KAAK,CAAC;IACf,CAAC;IAED,OAAO,CAAC,CAAC,MAAM,CAAC,IAAI,IAAI,MAAM,CAAC,IAAI,YAAY,OAAO,CAAC;AACzD,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,sBAAsB,CAAU,MAAY;IAC1D,OAAO,YAAY,CAAC,MAAM,CAAC,IAAI,OAAO,MAAM,CAAC,SAAS,KAAK,WAAW,CAAC;AACzE,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,cAAc,CAAI,IAAS;IACzC,OAAO,OAAO,IAAI,CAAC,SAAS,KAAK,WAAW,CAAC;AAC/C,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"async.interfaces.js","sourceRoot":"","sources":["../../../src/store/async/async.interfaces.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { BehaviorSubject, EMPTY, from, identity, isObservable, merge, of, } from 'rxjs';
|
|
2
|
+
import { catchError, delay, filter, finalize, pairwise, startWith, switchMap, tap, } from 'rxjs/operators';
|
|
3
|
+
import { isIdentifiedCallAction, } from './async.helpers';
|
|
4
|
+
/**
|
|
5
|
+
* Determine if the given parameter is a Promise
|
|
6
|
+
* @param object
|
|
7
|
+
*/
|
|
8
|
+
const isPromise = (object) => object && typeof object === 'object' && typeof object.then !== 'undefined';
|
|
9
|
+
/**
|
|
10
|
+
* Custom operator to use instead of SwitchMap with effects based on FromApi actions.
|
|
11
|
+
* It makes sure to emit an action when the inner subscription is unsubscribed in order to keep the store up-to-date with pending information.
|
|
12
|
+
* @param successHandler function that returns the action to emit in case the FromApi call is a success
|
|
13
|
+
* @param errorHandler function that returns the action to emit in case the FromApi call fails
|
|
14
|
+
* @param cancelRequestActionFactory function that returns the action to emit in case the FromApi action is 'cancelled' because a new action was received by the switchMap
|
|
15
|
+
*/
|
|
16
|
+
export function fromApiEffectSwitchMap(successHandler, errorHandler, cancelRequestActionFactory) {
|
|
17
|
+
const pendingRequestIdsContext = {};
|
|
18
|
+
return (source$) => source$.pipe(tap((action) => {
|
|
19
|
+
if (isIdentifiedCallAction(action)) {
|
|
20
|
+
pendingRequestIdsContext[action.requestId] = true;
|
|
21
|
+
}
|
|
22
|
+
}), startWith(undefined), pairwise(), switchMap(([previousAction, action]) => {
|
|
23
|
+
if (!action) {
|
|
24
|
+
return EMPTY;
|
|
25
|
+
}
|
|
26
|
+
const isPreviousActionStillRunning = isIdentifiedCallAction(previousAction) && pendingRequestIdsContext[previousAction.requestId];
|
|
27
|
+
const cleanStack = () => {
|
|
28
|
+
if (isIdentifiedCallAction(action)) {
|
|
29
|
+
delete pendingRequestIdsContext[action.requestId];
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
return from(action.call).pipe(tap(cleanStack), switchMap((result) => {
|
|
33
|
+
const success = successHandler(result, action);
|
|
34
|
+
return isObservable(success) ? success : (isPromise(success) ? success : of(success));
|
|
35
|
+
}), catchError((error) => {
|
|
36
|
+
cleanStack();
|
|
37
|
+
return errorHandler?.(error, action) || EMPTY;
|
|
38
|
+
}), isPreviousActionStillRunning && cancelRequestActionFactory ? startWith(cancelRequestActionFactory({ requestId: previousAction.requestId }, action)) : identity);
|
|
39
|
+
}));
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Same as {@link fromApiEffectSwitchMap}, instead one inner subscription is kept by id.
|
|
43
|
+
* @param successHandler
|
|
44
|
+
* @param errorHandler
|
|
45
|
+
* @param cancelRequestActionFactory
|
|
46
|
+
* @param cleanUpTimer
|
|
47
|
+
*/
|
|
48
|
+
export function fromApiEffectSwitchMapById(successHandler, errorHandler, cancelRequestActionFactory, cleanUpTimer) {
|
|
49
|
+
const innerSourcesById = {};
|
|
50
|
+
return (source$) => {
|
|
51
|
+
return source$.pipe(filter((action) => {
|
|
52
|
+
if (!isIdentifiedCallAction(action) || !action.id) {
|
|
53
|
+
return false;
|
|
54
|
+
}
|
|
55
|
+
if (isIdentifiedCallAction(action) && innerSourcesById[action.id]) {
|
|
56
|
+
innerSourcesById[action.id][0].next(action);
|
|
57
|
+
return false;
|
|
58
|
+
}
|
|
59
|
+
return true;
|
|
60
|
+
}), switchMap((action) => {
|
|
61
|
+
const newIdSubject = new BehaviorSubject(action);
|
|
62
|
+
const newId$ = newIdSubject.pipe(fromApiEffectSwitchMap(successHandler, errorHandler, cancelRequestActionFactory));
|
|
63
|
+
innerSourcesById[action.id] = [newIdSubject, newId$];
|
|
64
|
+
if (cleanUpTimer !== undefined) {
|
|
65
|
+
newIdSubject.pipe(switchMap((myAction) => from(myAction.call).pipe(delay(cleanUpTimer), finalize(() => {
|
|
66
|
+
delete innerSourcesById[myAction.id];
|
|
67
|
+
newIdSubject.complete();
|
|
68
|
+
})))).subscribe();
|
|
69
|
+
}
|
|
70
|
+
const streams = Object.values(innerSourcesById).map(([_, obs]) => obs);
|
|
71
|
+
return merge(...streams);
|
|
72
|
+
}));
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
//# sourceMappingURL=async.operators.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"async.operators.js","sourceRoot":"","sources":["../../../src/store/async/async.operators.ts"],"names":[],"mappings":"AAGA,OAAO,EACL,eAAe,EACf,KAAK,EACL,IAAI,EACJ,QAAQ,EACR,YAAY,EACZ,KAAK,EAEL,EAAE,GAGH,MAAM,MAAM,CAAC;AACd,OAAO,EACL,UAAU,EACV,KAAK,EACL,MAAM,EACN,QAAQ,EACR,QAAQ,EACR,SAAS,EACT,SAAS,EACT,G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CAAC;QACd,CAAC,CAAC,EACF,SAAS,CAAC,CAAC,MAAS,EAAE,EAAE;YACtB,MAAM,YAAY,GAAG,IAAI,eAAe,CAAC,MAAM,CAAC,CAAC;YACjD,MAAM,MAAM,GAAG,YAAY,CAAC,IAAI,CAC9B,sBAAsB,CACpB,cAAc,EACd,YAAY,EACZ,0BAA0B,CAC3B,CACF,CAAC;YACF,gBAAgB,CAAC,MAAM,CAAC,EAAE,CAAC,GAAG,CAAC,YAAY,EAAE,MAAM,CAAC,CAAC;YACrD,IAAI,YAAY,KAAK,SAAS,EAAE,CAAC;gBAC/B,YAAY,CAAC,IAAI,CACf,SAAS,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,IAAI,CAC9C,KAAK,CAAC,YAAY,CAAC,EACnB,QAAQ,CAAC,GAAG,EAAE;oBACZ,OAAO,gBAAgB,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC;oBACrC,YAAY,CAAC,QAAQ,EAAE,CAAC;gBAC1B,CAAC,CAAC,CACH,CAAC,CACH,CAAC,SAAS,EAAE,CAAC;YAChB,CAAC;YACD,MAAM,OAAO,GAAG,MAAM,CAAC,MAAM,CAAC,gBAAgB,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,GAAG,CAAC,EAAE,EAAE,CAAC,GAAG,CAAC,CAAC;YACvE,OAAO,KAAK,CAAC,GAAG,OAAO,CAAC,CAAC;QAC3B,CAAC,CAAC,CACH,CAAC;IACJ,CAAC,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { v4, } from 'uuid';
|
|
2
|
+
import { isAsyncRequest, } from './async.helpers';
|
|
3
|
+
/**
|
|
4
|
+
* Returns a creator that makes sure that requestId is defined in the action's properties by generating one
|
|
5
|
+
* if needed.
|
|
6
|
+
*/
|
|
7
|
+
export const asyncProps = () => {
|
|
8
|
+
return (props) => isAsyncRequest(props) ? props : { ...props, requestId: v4() };
|
|
9
|
+
};
|
|
10
|
+
//# sourceMappingURL=async.props.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"async.props.js","sourceRoot":"","sources":["../../../src/store/async/async.props.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,EAAE,GACH,MAAM,MAAM,CAAC;AACd,OAAO,EACL,cAAc,GACf,MAAM,iBAAiB,CAAC;AAKzB;;;GAGG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG,GAAqD,EAAE;IAC/E,OAAO,CAAC,KAAQ,EAAE,EAAE,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,GAAG,KAAK,EAAE,SAAS,EAAE,EAAE,EAAE,EAAE,CAAC;AACrF,CAAC,CAAC"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { asyncStoreItemAdapter, } from './async.adapter';
|
|
2
|
+
/**
|
|
3
|
+
* Serializer for asynchronous store.
|
|
4
|
+
* @param state State of an asynchronous store to serialize
|
|
5
|
+
* @returns a plain json object to pass to json.stringify
|
|
6
|
+
*/
|
|
7
|
+
export function asyncSerializer(state) {
|
|
8
|
+
return asyncStoreItemAdapter.clearAsyncStoreItem(state);
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Serializer for asynchronous entity store.
|
|
12
|
+
* @param state State of an asynchronous entity store to serialize
|
|
13
|
+
* @returns a plain json object to pass to json.stringify
|
|
14
|
+
*/
|
|
15
|
+
export function asyncEntitySerializer(state) {
|
|
16
|
+
const entities = state.ids.reduce((entitiesAcc, entityId) => {
|
|
17
|
+
entitiesAcc[entityId] = asyncStoreItemAdapter.clearAsyncStoreItem(state.entities[entityId]);
|
|
18
|
+
return entitiesAcc;
|
|
19
|
+
}, {});
|
|
20
|
+
return { ...asyncStoreItemAdapter.clearAsyncStoreItem(state), entities };
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Serializer for asynchronous entity store with status.
|
|
24
|
+
* @param state State of an asynchronous entity store with status to serialize
|
|
25
|
+
* @returns a plain json object to pass to json.stringify
|
|
26
|
+
*/
|
|
27
|
+
export function asyncEntityWithStatusSerializer(state) {
|
|
28
|
+
const entities = state.ids.reduce((entitiesAcc, entityId) => {
|
|
29
|
+
entitiesAcc[entityId] = { ...asyncStoreItemAdapter.clearAsyncStoreItem(state.entities[entityId]), status: {} };
|
|
30
|
+
return entitiesAcc;
|
|
31
|
+
}, {});
|
|
32
|
+
return { ...asyncStoreItemAdapter.clearAsyncStoreItem(state), entities };
|
|
33
|
+
}
|
|
34
|
+
//# sourceMappingURL=async.serializer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"async.serializer.js","sourceRoot":"","sources":["../../../src/store/async/async.serializer.ts"],"names":[],"mappings":"AAGA,OAAO,EACL,qBAAqB,GACtB,MAAM,iBAAiB,CAAC;AAMzB;;;;GAIG;AACH,MAAM,UAAU,eAAe,CAA2B,KAAQ;IAChE,OAAO,qBAAqB,CAAC,mBAAmB,CAAC,KAAK,CAAC,CAAC;AAC1D,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,qBAAqB,CAAyD,KAAQ;IACpG,MAAM,QAAQ,GAAI,KAAK,CAAC,GAAgB,CAAC,MAAM,CAAC,CAAC,WAAW,EAAE,QAAQ,EAAE,EAAE;QACxE,WAAW,CAAC,QAAQ,CAAC,GAAG,qBAAqB,CAAC,mBAAmB,CAAC,KAAK,CAAC,QAAQ,CAAC,QAAQ,CAAE,CAAC,CAAC;QAC7F,OAAO,WAAW,CAAC;IACrB,CAAC,EAAE,EAA2B,CAAC,CAAC;IAEhC,OAAO,EAAE,GAAG,qBAAqB,CAAC,mBAAmB,CAAC,KAAK,CAAC,EAAE,QAAQ,EAAE,CAAC;AAC3E,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,+BAA+B,CAA6G,KAAQ;IAClK,MAAM,QAAQ,GAAI,KAAK,CAAC,GAAgB,CAAC,MAAM,CAAC,CAAC,WAAW,EAAE,QAAQ,EAAE,EAAE;QACxE,WAAW,CAAC,QAAQ,CAAC,GAAG,EAAE,GAAG,qBAAqB,CAAC,mBAAmB,CAAC,KAAK,CAAC,QAAQ,CAAC,QAAQ,CAAE,CAAC,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC;QAChH,OAAO,WAAW,CAAC;IACrB,CAAC,EAAE,EAA2B,CAAC,CAAC;IAEhC,OAAO,EAAE,GAAG,qBAAqB,CAAC,mBAAmB,CAAC,KAAK,CAAC,EAAE,QAAQ,EAAE,CAAC;AAC3E,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export * from './async-entity.adapter';
|
|
2
|
+
export * from './async.adapter';
|
|
3
|
+
export * from './async.helpers';
|
|
4
|
+
export * from './async.interfaces';
|
|
5
|
+
export * from './async.operators';
|
|
6
|
+
export * from './async.props';
|
|
7
|
+
export * from './async.serializer';
|
|
8
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/store/async/index.ts"],"names":[],"mappings":"AAAA,cAAc,wBAAwB,CAAC;AACvC,cAAc,iBAAiB,CAAC;AAChC,cAAc,iBAAiB,CAAC;AAChC,cAAc,oBAAoB,CAAC;AACnC,cAAc,mBAAmB,CAAC;AAClC,cAAc,eAAe,CAAC;AAC9B,cAAc,oBAAoB,CAAC"}
|
package/store/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/store/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAC;AAC9B,cAAc,SAAS,CAAC"}
|
package/store/types.js
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export class StateSerializer {
|
|
2
|
+
constructor(serializer) {
|
|
3
|
+
this.reviver = (_, value) => value;
|
|
4
|
+
this.serialize = serializer.serialize || this.serialize;
|
|
5
|
+
this.deserialize = serializer.deserialize || this.deserialize;
|
|
6
|
+
this.reviver = serializer.reviver || this.reviver;
|
|
7
|
+
this.replacer = serializer.replacer || this.replacer;
|
|
8
|
+
this.initialState = serializer.initialState || this.initialState;
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/store/types.ts"],"names":[],"mappings":"AAWA,MAAM,OAAO,eAAe;IAM1B,YAAY,UAAyB;QAQ9B,YAAO,GAAG,CAAC,CAAS,EAAE,KAAU,EAAO,EAAE,CAAC,KAAK,CAAC;QAPrD,IAAI,CAAC,SAAS,GAAG,UAAU,CAAC,SAAS,IAAI,IAAI,CAAC,SAAS,CAAC;QACxD,IAAI,CAAC,WAAW,GAAG,UAAU,CAAC,WAAW,IAAI,IAAI,CAAC,WAAW,CAAC;QAC9D,IAAI,CAAC,OAAO,GAAG,UAAU,CAAC,OAAO,IAAI,IAAI,CAAC,OAAO,CAAC;QAClD,IAAI,CAAC,QAAQ,GAAG,UAAU,CAAC,QAAQ,IAAI,IAAI,CAAC,QAAQ,CAAC;QACrD,IAAI,CAAC,YAAY,GAAG,UAAU,CAAC,YAAY,IAAI,IAAI,CAAC,YAAY,CAAC;IACnE,CAAC;CAGF"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pad number
|
|
3
|
+
* @param val
|
|
4
|
+
* @param digits
|
|
5
|
+
*/
|
|
6
|
+
export function padNumber(val, digits = 2) {
|
|
7
|
+
const str = `${val}`;
|
|
8
|
+
return '0'.repeat(Math.max(0, digits - str.length)) + str;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Returns TRUE if bootstrap config environment is production FALSE otherwise
|
|
12
|
+
* @param dataset
|
|
13
|
+
* @returns TRUE if bootstrap config environment is production FALSE otherwise
|
|
14
|
+
*/
|
|
15
|
+
export function isProductionEnvironment(dataset) {
|
|
16
|
+
const bootstrapConfig = dataset.bootstrapconfig && JSON.parse(dataset.bootstrapconfig);
|
|
17
|
+
return bootstrapConfig?.environment === 'prod';
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=debug.helper.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"debug.helper.js","sourceRoot":"","sources":["../../../src/utils/debug/debug.helper.ts"],"names":[],"mappings":"AAKA;;;;GAIG;AACH,MAAM,UAAU,SAAS,CAAC,GAAW,EAAE,MAAM,GAAG,CAAC;IAC/C,MAAM,GAAG,GAAG,GAAG,GAAG,EAAE,CAAC;IACrB,OAAO,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,MAAM,GAAG,GAAG,CAAC,MAAM,CAAC,CAAC,GAAG,GAAG,CAAC;AAC5D,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,uBAAuB,CAAC,OAAgB;IACtD,MAAM,eAAe,GAAoB,OAAO,CAAC,eAAe,IAAI,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,eAAe,CAAC,CAAC;IACxG,OAAO,eAAe,EAAE,WAAW,KAAK,MAAM,CAAC;AACjD,CAAC"}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
const defaultConstruct = (data) => data;
|
|
2
|
+
const isDate = (data) => data instanceof Date && !Number.isNaN(data);
|
|
3
|
+
/**
|
|
4
|
+
* Check if an object is not an array or a date
|
|
5
|
+
* @param obj
|
|
6
|
+
* @param additionalMappers
|
|
7
|
+
*/
|
|
8
|
+
export function isObject(obj, additionalMappers) {
|
|
9
|
+
return obj instanceof Object && !Array.isArray(obj) && !additionalMappers?.some((mapper) => mapper.condition(obj)) && !isDate(obj);
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Return a new reference of the given object
|
|
13
|
+
* @param obj
|
|
14
|
+
* @param additionalMappers
|
|
15
|
+
*/
|
|
16
|
+
export function immutablePrimitive(obj, additionalMappers) {
|
|
17
|
+
if (Array.isArray(obj)) {
|
|
18
|
+
return obj.slice();
|
|
19
|
+
}
|
|
20
|
+
const matchingPrimitive = additionalMappers?.find((mapper) => mapper.condition(obj));
|
|
21
|
+
const resolvedType = matchingPrimitive && ((matchingPrimitive.construct || defaultConstruct)(obj));
|
|
22
|
+
if (resolvedType !== undefined) {
|
|
23
|
+
return resolvedType;
|
|
24
|
+
}
|
|
25
|
+
if (isDate(obj)) {
|
|
26
|
+
return new Date(obj);
|
|
27
|
+
}
|
|
28
|
+
else if (obj instanceof Object) {
|
|
29
|
+
return deepFill(obj, obj, additionalMappers);
|
|
30
|
+
}
|
|
31
|
+
else {
|
|
32
|
+
return obj;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Deep fill of base object using source
|
|
37
|
+
* It will do a deep merge of the objects, overriding arrays
|
|
38
|
+
* All properties not present in source, but present in base, will remain
|
|
39
|
+
* @param base
|
|
40
|
+
* @param source
|
|
41
|
+
* @param additionalMappers Map of conditions of type mapper
|
|
42
|
+
*/
|
|
43
|
+
export function deepFill(base, source, additionalMappers) {
|
|
44
|
+
if (typeof source === 'undefined') {
|
|
45
|
+
return deepFill(base, base, additionalMappers);
|
|
46
|
+
}
|
|
47
|
+
if (!isObject(base, additionalMappers)) {
|
|
48
|
+
return immutablePrimitive(typeof source === 'undefined' ? base : source, additionalMappers);
|
|
49
|
+
}
|
|
50
|
+
const newObj = { ...base };
|
|
51
|
+
for (const key in base) {
|
|
52
|
+
if (source[key] === null) {
|
|
53
|
+
newObj[key] = immutablePrimitive(null, additionalMappers);
|
|
54
|
+
}
|
|
55
|
+
else if (key in source && typeof base[key] === typeof source[key]) {
|
|
56
|
+
const keyOfSource = source[key];
|
|
57
|
+
newObj[key] = typeof keyOfSource === 'undefined' ? immutablePrimitive(base[key], additionalMappers) : deepFill(base[key], keyOfSource, additionalMappers);
|
|
58
|
+
}
|
|
59
|
+
else {
|
|
60
|
+
newObj[key] = immutablePrimitive(base[key], additionalMappers);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
// getting keys present in source and not present in base
|
|
64
|
+
for (const key in source) {
|
|
65
|
+
if (!(key in newObj)) {
|
|
66
|
+
newObj[key] = immutablePrimitive(source[key], additionalMappers);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
return newObj;
|
|
70
|
+
}
|
|
71
|
+
//# sourceMappingURL=deep-fill.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"deep-fill.js","sourceRoot":"","sources":["../../../src/utils/deep-fill/deep-fill.ts"],"names":[],"mappings":"AAaA,MAAM,gBAAgB,GAAG,CAAC,IAAS,EAAE,EAAE,CAAC,IAAI,CAAC;AAE7C,MAAM,MAAM,GAAG,CAAC,IAAS,EAAE,EAAE,CAAC,IAAI,YAAY,IAAI,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,IAAW,CAAC,CAAC;AAEjF;;;;GAIG;AACH,MAAM,UAAU,QAAQ,CAAC,GAAQ,EAAE,iBAA4C;IAC7E,OAAO,GAAG,YAAY,MAAM,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,iBAAiB,EAAE,IAAI,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;AACrI,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,kBAAkB,CAAC,GAAQ,EAAE,iBAA4C;IACvF,IAAI,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC;QACvB,OAAO,GAAG,CAAC,KAAK,EAAE,CAAC;IACrB,CAAC;IAED,MAAM,iBAAiB,GAAG,iBAAiB,EAAE,IAAI,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,SAAS,CAAC,GAAG,CAAC,C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C,GAAG,CAAC,KAAK,OAAO,MAAM,CAAC,GAAG,CAAC,EAAE,CAAC;YACpE,MAAM,WAAW,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC;YAChC,MAAM,CAAC,GAAG,CAAC,GAAG,OAAO,WAAW,KAAK,WAAW,CAAC,CAAC,CAAC,kBAAkB,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,iBAAiB,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,WAAW,EAAE,iBAAiB,CAAC,CAAC;QAC5J,CAAC;aAAM,CAAC;YACN,MAAM,CAAC,GAAG,CAAC,GAAG,kBAAkB,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,iBAAiB,CAAC,CAAC;QACjE,CAAC;IACH,CAAC;IAED,yDAAyD;IACzD,KAAK,MAAM,GAAG,IAAI,MAAM,EAAE,CAAC;QACzB,IAAI,CAAC,CAAC,GAAG,IAAI,MAAM,CAAC,EAAE,CAAC;YACrB,MAAM,CAAC,GAAc,CAAC,GAAG,kBAAkB,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE,iBAAiB,CAAC,CAAC;QAC9E,CAAC;IACH,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
package/utils/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,sBAAsB,CAAC;AACrC,cAAc,uBAAuB,CAAC;AACtC,cAAc,+BAA+B,CAAC"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { animationFrameScheduler, from, observeOn, of, } from 'rxjs';
|
|
2
|
+
import { bufferCount, concatMap, delay, mergeMap, scan, tap, } from 'rxjs/operators';
|
|
3
|
+
/**
|
|
4
|
+
* Buffers and emits data for lazy/progressive rendering of big lists
|
|
5
|
+
* That could solve issues with long-running tasks when trying to render an array
|
|
6
|
+
* of similar components.
|
|
7
|
+
* @param delayMs Delay between data emits
|
|
8
|
+
* @param concurrency Amount of elements that should be emitted at once
|
|
9
|
+
*/
|
|
10
|
+
export function lazyArray(delayMs = 0, concurrency = 2) {
|
|
11
|
+
let isFirstEmission = true;
|
|
12
|
+
return (source$) => {
|
|
13
|
+
return source$.pipe(mergeMap((items) => {
|
|
14
|
+
if (!isFirstEmission) {
|
|
15
|
+
return of(items);
|
|
16
|
+
}
|
|
17
|
+
const items$ = from(items);
|
|
18
|
+
return items$.pipe(bufferCount(concurrency), concatMap((value, index) => {
|
|
19
|
+
return of(value).pipe(observeOn(animationFrameScheduler), delay(index * delayMs));
|
|
20
|
+
}), scan((acc, steps) => {
|
|
21
|
+
return [...acc, ...steps];
|
|
22
|
+
}, []), tap((scannedItems) => {
|
|
23
|
+
const scanDidComplete = scannedItems.length === items.length;
|
|
24
|
+
if (scanDidComplete) {
|
|
25
|
+
isFirstEmission = false;
|
|
26
|
+
}
|
|
27
|
+
}));
|
|
28
|
+
}));
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
//# sourceMappingURL=rendering.helpers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rendering.helpers.js","sourceRoot":"","sources":["../../../src/utils/rendering/rendering.helpers.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,uBAAuB,EACvB,IAAI,EAEJ,SAAS,EACT,EAAE,GACH,MAAM,MAAM,CAAC;AACd,OAAO,EACL,WAAW,EACX,SAAS,EACT,KAAK,EACL,QAAQ,EACR,IAAI,EACJ,GAAG,GACJ,MAAM,gBAAgB,CAAC;AAExB;;;;;;GAMG;AACH,MAAM,UAAU,SAAS,CAAI,OAAO,GAAG,CAAC,EAAE,WAAW,GAAG,CAAC;IACvD,IAAI,eAAe,GAAG,IAAI,CAAC;IAC3B,OAAO,CAAC,OAAwB,EAAE,EAAE;QAClC,OAAO,OAAO,CAAC,IAAI,CACjB,QAAQ,CAAC,CAAC,KAAK,EAAE,EAAE;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