@o3r/core 11.5.0-prerelease.9 → 11.5.0-rc.1

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 (178) hide show
  1. package/README.md +7 -4
  2. package/builders/app-version/index.js.map +1 -0
  3. package/builders/app-version/schema.js.map +1 -0
  4. package/builders/lib-build/index.js.map +1 -0
  5. package/builders/lib-build/schema.js.map +1 -0
  6. package/builders/multi-watcher/index.js.map +1 -0
  7. package/builders/multi-watcher/schema.js.map +1 -0
  8. package/builders/ngc/index.js.map +1 -0
  9. package/builders/ngc/schema.js.map +1 -0
  10. package/builders/pattern-replacement/index.js.map +1 -0
  11. package/builders/pattern-replacement/schema.js.map +1 -0
  12. package/builders/run-script/index.js.map +1 -0
  13. package/builders/run-script/schema.js.map +1 -0
  14. package/builders/utils.js.map +1 -0
  15. package/core/application/build-properties.js +17 -0
  16. package/core/application/build-properties.js.map +1 -0
  17. package/core/application/dgp.interfaces.js +2 -0
  18. package/core/application/dgp.interfaces.js.map +1 -0
  19. package/core/application/index.js +4 -0
  20. package/core/application/index.js.map +1 -0
  21. package/core/application/runtime.js +2 -0
  22. package/core/application/runtime.js.map +1 -0
  23. package/core/common/index.js +3 -0
  24. package/core/common/index.js.map +1 -0
  25. package/core/common/interface-utils.js +2 -0
  26. package/core/common/interface-utils.js.map +1 -0
  27. package/core/common/label-value.js +2 -0
  28. package/core/common/label-value.js.map +1 -0
  29. package/core/devkit/devtools.interface.js +2 -0
  30. package/core/devkit/devtools.interface.js.map +1 -0
  31. package/core/devkit/index.js +2 -0
  32. package/core/devkit/index.js.map +1 -0
  33. package/core/index.js +7 -0
  34. package/core/index.js.map +1 -0
  35. package/core/interfaces/configuration.js +2 -0
  36. package/core/interfaces/configuration.js.map +1 -0
  37. package/core/interfaces/context.js +3 -0
  38. package/core/interfaces/context.js.map +1 -0
  39. package/core/interfaces/index.js +5 -0
  40. package/core/interfaces/index.js.map +1 -0
  41. package/core/interfaces/item-identifier.js +2 -0
  42. package/core/interfaces/item-identifier.js.map +1 -0
  43. package/core/interfaces/translation.js +2 -0
  44. package/core/interfaces/translation.js.map +1 -0
  45. package/core/metadata/component.decorator.js +18 -0
  46. package/core/metadata/component.decorator.js.map +1 -0
  47. package/core/metadata/component.identifier.js +9 -0
  48. package/core/metadata/component.identifier.js.map +1 -0
  49. package/core/metadata/index.js +4 -0
  50. package/core/metadata/index.js.map +1 -0
  51. package/core/metadata/metadata.interface.js +2 -0
  52. package/core/metadata/metadata.interface.js.map +1 -0
  53. package/core/rules-engine/index.js +2 -0
  54. package/core/rules-engine/index.js.map +1 -0
  55. package/core/rules-engine/rules-engine.interfaces.js +2 -0
  56. package/core/rules-engine/rules-engine.interfaces.js.map +1 -0
  57. package/log/index.js +2 -0
  58. package/log/index.js.map +1 -0
  59. package/log/logger.js +2 -0
  60. package/log/logger.js.map +1 -0
  61. package/messages/common-message.interface.js +2 -0
  62. package/messages/common-message.interface.js.map +1 -0
  63. package/messages/index.js +4 -0
  64. package/messages/index.js.map +1 -0
  65. package/messages/message.helpers.js +52 -0
  66. package/messages/message.helpers.js.map +1 -0
  67. package/messages/message.interfaces.js +5 -0
  68. package/messages/message.interfaces.js.map +1 -0
  69. package/package.json +8 -4
  70. package/public_api.js +6 -0
  71. package/public_api.js.map +1 -0
  72. package/schematics/add-modules/index.js.map +1 -0
  73. package/schematics/add-modules/schema.js.map +1 -0
  74. package/schematics/component/container/index.js.map +1 -0
  75. package/schematics/component/container/schema.js.map +1 -0
  76. package/schematics/component/index.js.map +1 -0
  77. package/schematics/component/presenter/index.js.map +1 -0
  78. package/schematics/component/presenter/schema.js.map +1 -0
  79. package/schematics/component/schema.js.map +1 -0
  80. package/schematics/component/structures.types.js.map +1 -0
  81. package/schematics/context-to-component/index.js.map +1 -0
  82. package/schematics/context-to-component/schema.js.map +1 -0
  83. package/schematics/convert-component/index.js.map +1 -0
  84. package/schematics/convert-component/schema.js.map +1 -0
  85. package/schematics/ng-add/component-decorator/index.js.map +1 -0
  86. package/schematics/ng-add/index.js.map +1 -0
  87. package/schematics/ng-add/project-setup/index.js.map +1 -0
  88. package/schematics/ng-add/schema.js.map +1 -0
  89. package/schematics/ng-add/updates-for-v8/cms-adapters/update-builders-names.js.map +1 -0
  90. package/schematics/ng-add/updates-for-v8/generators/update-generators-names.js.map +1 -0
  91. package/schematics/ng-add/updates-for-v8/replaced-packages.js.map +1 -0
  92. package/schematics/ng-add/utils/index.js.map +1 -0
  93. package/schematics/ng-add/utils/linter/index.js.map +1 -0
  94. package/schematics/ng-add-create/index.js.map +1 -0
  95. package/schematics/ng-add-create/schema.js.map +1 -0
  96. package/schematics/ng-update/index.js.map +1 -0
  97. package/schematics/ng-update/v10.0/configuration.js.map +1 -0
  98. package/schematics/ng-update/v8.2/import-map.js.map +1 -0
  99. package/schematics/page/index.js.map +1 -0
  100. package/schematics/page/schema.js.map +1 -0
  101. package/schematics/renovate/index.js.map +1 -0
  102. package/schematics/renovate/schema.js.map +1 -0
  103. package/schematics/rule-factories/additional-modules/index.js.map +1 -0
  104. package/schematics/rule-factories/component/analytics.js.map +1 -0
  105. package/schematics/rule-factories/component/common.js.map +1 -0
  106. package/schematics/rule-factories/component/configuration.js.map +1 -0
  107. package/schematics/rule-factories/component/context.js.map +1 -0
  108. package/schematics/rule-factories/component/design-token.js.map +1 -0
  109. package/schematics/rule-factories/component/fixture.js.map +1 -0
  110. package/schematics/rule-factories/component/localization.js.map +1 -0
  111. package/schematics/rule-factories/component/rules-engine.js.map +1 -0
  112. package/schematics/rule-factories/component/theming.js.map +1 -0
  113. package/schematics/rule-factories/customization-environment/index.js.map +1 -0
  114. package/schematics/rule-factories/index.js.map +1 -0
  115. package/schematics/rule-factories/o3r-basic-updates/index.js.map +1 -0
  116. package/schematics/rule-factories/otter-environment/index.js.map +1 -0
  117. package/schematics/rule-factories/store/index.js.map +1 -0
  118. package/schematics/schematics-update/index.js.map +1 -0
  119. package/schematics/schematics-update/schema.js.map +1 -0
  120. package/schematics/service/index.js.map +1 -0
  121. package/schematics/service/schema.js.map +1 -0
  122. package/schematics/shared/presets/all.preset.js.map +1 -0
  123. package/schematics/shared/presets/basic.preset.js.map +1 -0
  124. package/schematics/shared/presets/cms.preset.js.map +1 -0
  125. package/schematics/shared/presets/external.preset.js.map +1 -0
  126. package/schematics/shared/presets/helpers.js.map +1 -0
  127. package/schematics/shared/presets/index.js.map +1 -0
  128. package/schematics/shared/presets/preset.interface.js.map +1 -0
  129. package/schematics/show-modules/index.js.map +1 -0
  130. package/schematics/show-modules/schema.js.map +1 -0
  131. package/schematics/store/common/helpers.js.map +1 -0
  132. package/schematics/store/common/schema.js.map +1 -0
  133. package/schematics/store/entity-async/index.js.map +1 -0
  134. package/schematics/store/entity-async/schema.js.map +1 -0
  135. package/schematics/store/entity-sync/index.js.map +1 -0
  136. package/schematics/store/entity-sync/schema.js.map +1 -0
  137. package/schematics/store/index.js.map +1 -0
  138. package/schematics/store/schema.js.map +1 -0
  139. package/schematics/store/simple-async/index.js.map +1 -0
  140. package/schematics/store/simple-async/schema.js.map +1 -0
  141. package/schematics/store/simple-sync/index.js.map +1 -0
  142. package/schematics/store/simple-sync/schema.js.map +1 -0
  143. package/schematics/store-action/index.js.map +1 -0
  144. package/schematics/store-action/schema.js.map +1 -0
  145. package/store/async/async-entity.adapter.js +53 -0
  146. package/store/async/async-entity.adapter.js.map +1 -0
  147. package/store/async/async.adapter.js +93 -0
  148. package/store/async/async.adapter.js.map +1 -0
  149. package/store/async/async.helpers.js +25 -0
  150. package/store/async/async.helpers.js.map +1 -0
  151. package/store/async/async.interfaces.js +2 -0
  152. package/store/async/async.interfaces.js.map +1 -0
  153. package/store/async/async.operators.js +75 -0
  154. package/store/async/async.operators.js.map +1 -0
  155. package/store/async/async.props.js +11 -0
  156. package/store/async/async.props.js.map +1 -0
  157. package/store/async/async.serializer.js +34 -0
  158. package/store/async/async.serializer.js.map +1 -0
  159. package/store/async/index.js +8 -0
  160. package/store/async/index.js.map +1 -0
  161. package/store/index.js +3 -0
  162. package/store/index.js.map +1 -0
  163. package/store/types.js +11 -0
  164. package/store/types.js.map +1 -0
  165. package/utils/debug/debug.helper.js +20 -0
  166. package/utils/debug/debug.helper.js.map +1 -0
  167. package/utils/deep-fill/deep-fill.js +69 -0
  168. package/utils/deep-fill/deep-fill.js.map +1 -0
  169. package/utils/index.js +4 -0
  170. package/utils/index.js.map +1 -0
  171. package/utils/rendering/rendering.helpers.js +32 -0
  172. package/utils/rendering/rendering.helpers.js.map +1 -0
  173. package/schematics/scripts/exported-actions.d.ts +0 -2
  174. package/schematics/scripts/exported-actions.d.ts.map +0 -1
  175. package/schematics/scripts/exported-actions.js +0 -25
  176. package/schematics/scripts/sub-entry-imports.d.ts +0 -2
  177. package/schematics/scripts/sub-entry-imports.d.ts.map +0 -1
  178. package/schematics/scripts/sub-entry-imports.js +0 -55
@@ -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
+ // eslint-disable-next-line @typescript-eslint/ban-types
17
+ export function fromApiEffectSwitchMap(successHandler, errorHandler, cancelRequestActionFactory) {
18
+ const pendingRequestIdsContext = {};
19
+ return (source$) => source$.pipe(tap((action) => {
20
+ if (isIdentifiedCallAction(action)) {
21
+ pendingRequestIdsContext[action.requestId] = true;
22
+ }
23
+ }), startWith(undefined), pairwise(), switchMap(([previousAction, action]) => {
24
+ if (!action) {
25
+ return EMPTY;
26
+ }
27
+ const isPreviousActionStillRunning = isIdentifiedCallAction(previousAction) && pendingRequestIdsContext[previousAction.requestId];
28
+ const cleanStack = () => {
29
+ if (isIdentifiedCallAction(action)) {
30
+ delete pendingRequestIdsContext[action.requestId];
31
+ }
32
+ };
33
+ return from(action.call).pipe(tap(cleanStack), switchMap((result) => {
34
+ const success = successHandler(result, action);
35
+ return isObservable(success) ? success : (isPromise(success) ? success : of(success));
36
+ }), catchError((error) => {
37
+ cleanStack();
38
+ return errorHandler?.(error, action) || EMPTY;
39
+ }), isPreviousActionStillRunning && cancelRequestActionFactory ? startWith(cancelRequestActionFactory({ requestId: previousAction.requestId }, action)) : identity);
40
+ }));
41
+ }
42
+ /**
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":"AACA,OAAO,EAAE,eAAe,EAAE,KAAK,EAAE,IAAI,EAAE,QAAQ,EAAE,YAAY,EAAE,KAAK,EAAc,EAAE,EAA6B,MAAM,MAAM,CAAC;AAC9H,OAAO,EAAE,UAAU,EAAE,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,QAAQ,EAAE,SAAS,EAAE,SAAS,EAAE,GAAG,EAAE,MAAM,gBAAgB,CAAC;AAC1G,OAAO,EAAE,sBAAsB,EAAE,MAAM,iBAAiB,CAAC;AAGzD;;;GAGG;AACH,MAAM,SAAS,GAAG,CAAI,MAAsB,EAAwB,EAAE,CAAC,MAAM,IAAI,OAAO,MAAM,KAAK,QAAQ,IAAI,OAAQ,MAAc,CAAC,IAAI,KAAK,WAAW,CAAC;AAE3J;;;;;;GAMG;AACH,wDAAwD;AACxD,MAAM,UAAU,sBAAsB,CAClC,cAAwE,EACxE,YAAuD,EACvD,0BAAkE;IAEpE,MAAM,wBAAwB,GAA4B,EAAE,CAAC;IAE7D,OAAO,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,IAAI,CAC9B,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE;QACb,IAAI,sBAAsB,CAAC,MAAM,CAAC,EAAE,CAAC;YACnC,wBAAwB,CAAC,MAAM,CAAC,SAAS,CAAC,GAAG,IAAI,CAAC;QACpD,CAAC;IACH,CAAC,CAAC,EACF,SAAS,CAAC,SAAS,CAAC,EACpB,QAAQ,EAAE,EACV,SAAS,CAAC,CAAC,CAAC,cAAc,EAAE,MAAM,CAAC,EAAE,EAAE;QACrC,IAAI,CAAC,MAAM,EAAE,CAAC;YACZ,OAAO,KAAK,CAAC;QACf,CAAC;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AC,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,11 @@
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
+ // eslint-disable-next-line @typescript-eslint/ban-types
8
+ export const asyncProps = () => {
9
+ return (props) => isAsyncRequest(props) ? props : { ...props, requestId: v4() };
10
+ };
11
+ //# 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":"AACA,OAAO,EAAC,EAAE,EAAC,MAAM,MAAM,CAAC;AACxB,OAAO,EAAC,cAAc,EAAC,MAAM,iBAAiB,CAAC;AAE/C;;;GAGG;AACH,wDAAwD;AACxD,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,EAAC,GAAG,KAAK,EAAE,SAAS,EAAE,EAAE,EAAE,EAAC,CAAC;AACnF,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":"AACA,OAAO,EAAE,qBAAqB,EAAE,MAAM,iBAAiB,CAAC;AAGxD;;;;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.helpers';
2
+ export * from './async.interfaces';
3
+ export * from './async.adapter';
4
+ export * from './async-entity.adapter';
5
+ export * from './async.props';
6
+ export * from './async.operators';
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,iBAAiB,CAAC;AAChC,cAAc,oBAAoB,CAAC;AACnC,cAAc,iBAAiB,CAAC;AAChC,cAAc,wBAAwB,CAAC;AACvC,cAAc,eAAe,CAAC;AAC9B,cAAc,mBAAmB,CAAC;AAClC,cAAc,oBAAoB,CAAC"}
package/store/index.js ADDED
@@ -0,0 +1,3 @@
1
+ export * from './async/index';
2
+ export * from './types';
3
+ //# sourceMappingURL=index.js.map
@@ -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,20 @@
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
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
17
+ const bootstrapConfig = dataset.bootstrapconfig && JSON.parse(dataset.bootstrapconfig);
18
+ return bootstrapConfig?.environment === 'prod';
19
+ }
20
+ //# 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":"AAEA;;;;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;AAGD;;;;GAIG;AACH,MAAM,UAAU,uBAAuB,CAAC,OAAgB;IACtD,mEAAmE;IACnE,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,69 @@
1
+ const defaultConstruct = (data) => data;
2
+ const isDate = (data) => data instanceof Date && !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
+ // eslint-disable-next-line no-use-before-define
30
+ return deepFill(obj, obj, additionalMappers);
31
+ }
32
+ else {
33
+ return obj;
34
+ }
35
+ }
36
+ /**
37
+ * Deep fill of base object using source
38
+ * It will do a deep merge of the objects, overriding arrays
39
+ * All properties not present in source, but present in base, will remain
40
+ * @param base
41
+ * @param source
42
+ * @param additionalMappers Map of conditions of type mapper
43
+ */
44
+ export function deepFill(base, source, additionalMappers) {
45
+ if (typeof source === 'undefined') {
46
+ return deepFill(base, base, additionalMappers);
47
+ }
48
+ if (!isObject(base, additionalMappers)) {
49
+ return immutablePrimitive(typeof source !== 'undefined' ? source : base, additionalMappers);
50
+ }
51
+ const newObj = { ...base };
52
+ for (const key in base) {
53
+ if (key in source && typeof base[key] === typeof source[key]) {
54
+ const keyOfSource = source[key];
55
+ newObj[key] = typeof keyOfSource === 'undefined' ? immutablePrimitive(base[key], additionalMappers) : deepFill(base[key], source[key], additionalMappers);
56
+ }
57
+ else {
58
+ newObj[key] = immutablePrimitive(base[key], additionalMappers);
59
+ }
60
+ }
61
+ // getting keys present in source and not present in base
62
+ for (const key in source) {
63
+ if (!(key in newObj)) {
64
+ newObj[key] = immutablePrimitive(source[key], additionalMappers);
65
+ }
66
+ }
67
+ return newObj;
68
+ }
69
+ //# 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,KAAK,CAAC,IAAW,CAAC,CAAC;AAE1E;;;;GAIG;AACH,MAAM,UAAU,QAAQ,CAAC,GAAQ,EAAE,iBAA4C;IAC7E,OA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* from './debug/debug.helper';
2
+ export * from './deep-fill/deep-fill';
3
+ export * from './rendering/rendering.helpers';
4
+ //# sourceMappingURL=index.js.map
@@ -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,32 @@
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
+ * @returns
10
+ */
11
+ export function lazyArray(delayMs = 0, concurrency = 2) {
12
+ let isFirstEmission = true;
13
+ return (source$) => {
14
+ return source$.pipe(mergeMap((items) => {
15
+ if (!isFirstEmission) {
16
+ return of(items);
17
+ }
18
+ const items$ = from(items);
19
+ return items$.pipe(bufferCount(concurrency), concatMap((value, index) => {
20
+ return of(value).pipe(observeOn(animationFrameScheduler), delay(index * delayMs));
21
+ }), scan((acc, steps) => {
22
+ return [...acc, ...steps];
23
+ }, []), tap((scannedItems) => {
24
+ const scanDidComplete = scannedItems.length === items.length;
25
+ if (scanDidComplete) {
26
+ isFirstEmission = false;
27
+ }
28
+ }));
29
+ }));
30
+ };
31
+ }
32
+ //# 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,EAAE,uBAAuB,EAAE,IAAI,EAAc,SAAS,EAAE,EAAE,EAAE,MAAM,MAAM,CAAC;AAChF,OAAO,EACL,WAAW,EACX,SAAS,EACT,KAAK,EACL,QAAQ,EACR,IAA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ceRoot":"","sources":["../../../schematics/scripts/exported-actions.ts"],"names":[],"mappings":""}
@@ -1,25 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const schematics_1 = require("@o3r/schematics");
4
- const ts = require("typescript");
5
- const fs = require("node:fs");
6
- const globby_1 = require("globby");
7
- const path = require("node:path");
8
- const moduleName = 'store';
9
- const moduleFolderPath = path.resolve(__dirname, '..', '..', '..', '..', '..', 'packages', '@o3r', moduleName, 'src');
10
- const outputJsonPath = path.resolve(__dirname, 'exported-actions-v3.json');
11
- const actionFiles = (0, globby_1.sync)(path.posix.join(moduleFolderPath, '**', '*.actions.ts').replace(/\\/g, '/'));
12
- const actionsProgram = ts.createProgram(actionFiles, {});
13
- const exportedActions = actionFiles.reduce((acc, actionFile) => {
14
- // Because v3 actions were classes, we retrieve all the classes exported by the Actions files
15
- (0, schematics_1.getExportedSymbolsFromFile)(actionsProgram, actionFile)
16
- // eslint-disable-next-line no-bitwise
17
- .filter((symbol) => symbol.flags & ts.SymbolFlags.Class)
18
- .forEach((symbol) => {
19
- // And pre-populate the migrated name which in 80% of the case will be a lowerCamelCase version of the classname
20
- acc[symbol.name] = symbol.name.charAt(0).toLowerCase() + symbol.name.slice(1);
21
- });
22
- return acc;
23
- }, {});
24
- fs.writeFileSync(outputJsonPath, JSON.stringify(exportedActions, null, 2));
25
- //# sourceMappingURL=exported-actions.js.map
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=sub-entry-imports.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"sub-entry-imports.d.ts","sourceRoot":"","sources":["../../../schematics/scripts/sub-entry-imports.ts"],"names":[],"mappings":""}
@@ -1,55 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const schematics_1 = require("@o3r/schematics");
4
- const ts = require("typescript");
5
- const fs = require("node:fs");
6
- const minimist = require("minimist");
7
- const path = require("node:path");
8
- const argv = minimist(process.argv.slice(2));
9
- const moduleName = argv._[0];
10
- const moduleFolderPath = path.resolve(__dirname, '..', '..', '..', '..', '..', 'packages', '@o3r', moduleName, 'src');
11
- const outputJsonPath = path.resolve(__dirname, `${moduleName}-mapping.json`);
12
- // Build a list of the index files of every sub-entry
13
- const subEntries = fs.readdirSync(moduleFolderPath, { withFileTypes: true })
14
- .filter(dirent => dirent.isDirectory())
15
- .map(dirent => ({
16
- indexFile: path.join(moduleFolderPath, dirent.name, 'index.ts').replace(/\\/g, '/'),
17
- name: dirent.name
18
- }));
19
- // Build a list of the fixture.ts file of every sub-entry (today only applicable to services)
20
- const fixtureFiles = fs.readdirSync(moduleFolderPath, { withFileTypes: true })
21
- .filter(dirent => dirent.isDirectory())
22
- .map(dirent => ({
23
- indexFile: path.join(moduleFolderPath, dirent.name, 'fixtures.ts').replace(/\\/g, '/'),
24
- name: dirent.name
25
- }))
26
- .filter((fixture) => fs.existsSync(fixture.indexFile));
27
- const subEntriesProgram = ts.createProgram(subEntries.map((subEntry) => subEntry.indexFile), {});
28
- // Build an association between a sub-entry name and all the symbols exported by its index file
29
- const mapping = subEntries.reduce((acc, subEntry) => {
30
- const exports = (0, schematics_1.getExportedSymbolsFromFile)(subEntriesProgram, subEntry.indexFile)
31
- .map((symbol) => symbol.name);
32
- exports.forEach((exportedMember) => {
33
- if (!acc[subEntry.name]) {
34
- acc[subEntry.name] = [];
35
- }
36
- acc[subEntry.name].push(exportedMember);
37
- });
38
- return acc;
39
- }, {});
40
- // If working with fixtures, build a separate list of all the symbols exported by fixtures files
41
- if (fixtureFiles.length > 0) {
42
- const fixturesProgram = ts.createProgram(fixtureFiles.map((fixture) => fixture.indexFile), {});
43
- const availableFixtures = [];
44
- fixtureFiles.forEach((fixture) => {
45
- const exports = (0, schematics_1.getExportedSymbolsFromFile)(fixturesProgram, fixture.indexFile)
46
- .map((symbol) => symbol.name);
47
- availableFixtures.push(...exports);
48
- });
49
- if (availableFixtures.length > 0) {
50
- mapping['fixtures/fixtures'] = availableFixtures;
51
- }
52
- }
53
- const content = { [moduleName]: mapping };
54
- fs.writeFileSync(outputJsonPath, JSON.stringify(content, null, 2));
55
- //# sourceMappingURL=sub-entry-imports.js.map