@o3r/core 15.3.0-prerelease.9 → 15.3.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.
- package/core/application/build-properties.d.ts +50 -0
- package/core/application/build-properties.d.ts.map +1 -0
- package/core/application/build-properties.js +17 -0
- package/core/application/build-properties.js.map +1 -0
- package/core/application/dgp-interfaces.d.ts +35 -0
- package/core/application/dgp-interfaces.d.ts.map +1 -0
- package/core/application/dgp-interfaces.js +2 -0
- package/core/application/dgp-interfaces.js.map +1 -0
- package/core/application/index.d.ts +4 -0
- package/core/application/index.d.ts.map +1 -0
- package/core/application/index.js +4 -0
- package/core/application/index.js.map +1 -0
- package/core/application/runtime.d.ts +14 -0
- package/core/application/runtime.d.ts.map +1 -0
- package/core/application/runtime.js +2 -0
- package/core/application/runtime.js.map +1 -0
- package/core/common/index.d.ts +3 -0
- package/core/common/index.d.ts.map +1 -0
- package/core/common/index.js +3 -0
- package/core/common/index.js.map +1 -0
- package/core/common/interface-utils.d.ts +7 -0
- package/core/common/interface-utils.d.ts.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.d.ts +8 -0
- package/core/common/label-value.d.ts.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.d.ts +34 -0
- package/core/devkit/devtools-interface.d.ts.map +1 -0
- package/core/devkit/devtools-interface.js +2 -0
- package/core/devkit/devtools-interface.js.map +1 -0
- package/core/devkit/index.d.ts +2 -0
- package/core/devkit/index.d.ts.map +1 -0
- package/core/devkit/index.js +2 -0
- package/core/devkit/index.js.map +1 -0
- package/core/index.d.ts +7 -0
- package/core/index.d.ts.map +1 -0
- package/core/index.js +7 -0
- package/core/index.js.map +1 -0
- package/core/interfaces/configuration.d.ts +90 -0
- package/core/interfaces/configuration.d.ts.map +1 -0
- package/core/interfaces/configuration.js +2 -0
- package/core/interfaces/configuration.js.map +1 -0
- package/core/interfaces/context.d.ts +57 -0
- package/core/interfaces/context.d.ts.map +1 -0
- package/core/interfaces/context.js +2 -0
- package/core/interfaces/context.js.map +1 -0
- package/core/interfaces/index.d.ts +5 -0
- package/core/interfaces/index.d.ts.map +1 -0
- package/core/interfaces/index.js +5 -0
- package/core/interfaces/index.js.map +1 -0
- package/core/interfaces/item-identifier.d.ts +14 -0
- package/core/interfaces/item-identifier.d.ts.map +1 -0
- package/core/interfaces/item-identifier.js +2 -0
- package/core/interfaces/item-identifier.js.map +1 -0
- package/core/interfaces/translation.d.ts +7 -0
- package/core/interfaces/translation.d.ts.map +1 -0
- package/core/interfaces/translation.js +2 -0
- package/core/interfaces/translation.js.map +1 -0
- package/core/metadata/component-decorator.d.ts +32 -0
- package/core/metadata/component-decorator.d.ts.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.d.ts +7 -0
- package/core/metadata/component-identifier.d.ts.map +1 -0
- package/core/metadata/component-identifier.js +9 -0
- package/core/metadata/component-identifier.js.map +1 -0
- package/core/metadata/index.d.ts +4 -0
- package/core/metadata/index.d.ts.map +1 -0
- package/core/metadata/index.js +4 -0
- package/core/metadata/index.js.map +1 -0
- package/core/metadata/metadata-interface.d.ts +10 -0
- package/core/metadata/metadata-interface.d.ts.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.d.ts +2 -0
- package/core/rules-engine/index.d.ts.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.d.ts +24 -0
- package/core/rules-engine/rules-engine-interfaces.d.ts.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/fesm2022/o3r-core.mjs +300 -470
- package/fesm2022/o3r-core.mjs.map +1 -1
- package/log/index.d.ts +2 -0
- package/log/index.d.ts.map +1 -0
- package/log/index.js +2 -0
- package/log/index.js.map +1 -0
- package/log/logger.d.ts +36 -0
- package/log/logger.d.ts.map +1 -0
- package/log/logger.js +2 -0
- package/log/logger.js.map +1 -0
- package/messages/common-message-interface.d.ts +17 -0
- package/messages/common-message-interface.d.ts.map +1 -0
- package/messages/common-message-interface.js +2 -0
- package/messages/common-message-interface.js.map +1 -0
- package/messages/index.d.ts +4 -0
- package/messages/index.d.ts.map +1 -0
- package/messages/index.js +4 -0
- package/messages/index.js.map +1 -0
- package/messages/message-helpers.d.ts +24 -0
- package/messages/message-helpers.d.ts.map +1 -0
- package/messages/message-helpers.js +54 -0
- package/messages/message-helpers.js.map +1 -0
- package/messages/message-interfaces.d.ts +26 -0
- package/messages/message-interfaces.d.ts.map +1 -0
- package/messages/message-interfaces.js +5 -0
- package/messages/message-interfaces.js.map +1 -0
- package/package.json +13 -13
- package/public_api.d.ts +6 -0
- package/public_api.d.ts.map +1 -0
- package/public_api.js +6 -0
- package/public_api.js.map +1 -0
- package/schematics/add-modules/schema.json +0 -3
- package/schematics/component/container/schema.json +0 -3
- package/schematics/component/presenter/schema.json +0 -3
- package/schematics/component/schema.json +0 -3
- package/schematics/ng-add/schema.json +0 -3
- package/schematics/ng-add-create/schema.json +0 -3
- package/schematics/page/schema.json +0 -3
- package/schematics/schematics-update/schema.json +0 -3
- package/schematics/service/schema.json +0 -3
- package/schematics/store/entity-async/schema.json +0 -3
- package/schematics/store/entity-sync/schema.json +0 -3
- package/schematics/store/schema.json +0 -3
- package/schematics/store/simple-async/schema.json +0 -3
- package/schematics/store/simple-sync/schema.json +0 -3
- package/schematics/store-action/schema.json +0 -3
- package/store/async/async-entity.adapter.d.ts +62 -0
- package/store/async/async-entity.adapter.d.ts.map +1 -0
- package/store/async/async-entity.adapter.js +49 -0
- package/store/async/async-entity.adapter.js.map +1 -0
- package/store/async/async.adapter.d.ts +91 -0
- package/store/async/async.adapter.d.ts.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.d.ts +17 -0
- package/store/async/async.helpers.d.ts.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.d.ts +91 -0
- package/store/async/async.interfaces.d.ts.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.d.ts +22 -0
- package/store/async/async.operators.d.ts.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.d.ts +7 -0
- package/store/async/async.props.d.ts.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.d.ts +29 -0
- package/store/async/async.serializer.d.ts.map +1 -0
- package/store/async/async.serializer.js +34 -0
- package/store/async/async.serializer.js.map +1 -0
- package/store/async/index.d.ts +8 -0
- package/store/async/index.d.ts.map +1 -0
- package/store/async/index.js +8 -0
- package/store/async/index.js.map +1 -0
- package/store/index.d.ts +3 -0
- package/store/index.d.ts.map +1 -0
- package/store/index.js +3 -0
- package/store/index.js.map +1 -0
- package/store/types.d.ts +95 -0
- package/store/types.d.ts.map +1 -0
- package/store/types.js +11 -0
- package/store/types.js.map +1 -0
- package/types/o3r-core.d.ts +553 -610
- package/types/o3r-core.d.ts.map +1 -1
- package/utils/debug/debug-helper.d.ts +14 -0
- package/utils/debug/debug-helper.d.ts.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.d.ts +37 -0
- package/utils/deep-fill/deep-fill.d.ts.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.d.ts +4 -0
- package/utils/index.d.ts.map +1 -0
- package/utils/index.js +4 -0
- package/utils/index.js.map +1 -0
- package/utils/rendering/rendering-helpers.d.ts +10 -0
- package/utils/rendering/rendering-helpers.d.ts.map +1 -0
- package/utils/rendering/rendering-helpers.js +31 -0
- package/utils/rendering/rendering-helpers.js.map +1 -0
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import type { EntityAdapter, EntityState } from '@ngrx/entity';
|
|
2
|
+
import { AsyncStoreItem, EntityWithoutAsyncStoreItem } from './async.interfaces';
|
|
3
|
+
/** Adapter for Asynchronous Entity Store */
|
|
4
|
+
export interface EntityAsyncRequestAdapter<T extends AsyncStoreItem> extends EntityAdapter<T> {
|
|
5
|
+
/**
|
|
6
|
+
* Updates the AsyncStoreItem properties of each entity matching an id from the list of given ids, when a request has failed.
|
|
7
|
+
* @param state Actual state
|
|
8
|
+
* @param ids Ids of the entity to be updated with AsyncStoreItem properties
|
|
9
|
+
* @param requestId Id of request which has failed
|
|
10
|
+
*/
|
|
11
|
+
failRequestMany<V extends EntityState<T> & AsyncStoreItem>(state: V, ids?: (string | number)[], requestId?: string): V;
|
|
12
|
+
/**
|
|
13
|
+
* Adds AsyncStoreItem property to the global store, or the entity if it already exists, when a request is triggered.
|
|
14
|
+
* @param state Actual state
|
|
15
|
+
* @param id Id of the entity to update
|
|
16
|
+
* @param requestId Id of the request which is triggered
|
|
17
|
+
*/
|
|
18
|
+
addRequestOne<V extends EntityState<T> & AsyncStoreItem>(state: V, id: string | number | null | undefined, requestId: string): V;
|
|
19
|
+
/**
|
|
20
|
+
* Adds AsyncStoreItem properties for each entity matching the given ids, when a request is triggered
|
|
21
|
+
* @param state Actual state
|
|
22
|
+
* @param ids Ids of the entity to be updated with AsyncStoreItem properties
|
|
23
|
+
* @param requestId Id of request which is triggered
|
|
24
|
+
*/
|
|
25
|
+
addRequestMany<V extends EntityState<T>>(state: V, ids: (string | number)[], requestId: string): V;
|
|
26
|
+
/**
|
|
27
|
+
* Updates the state with the given entity. Update the global or the current entity's status if it exists.
|
|
28
|
+
* @param state Actual state
|
|
29
|
+
* @param entity Payload item;
|
|
30
|
+
* @param requestId Id of request which has resolved if any
|
|
31
|
+
*/
|
|
32
|
+
resolveRequestOne<V extends EntityState<T> & AsyncStoreItem>(state: V, entity: EntityWithoutAsyncStoreItem<T> & Record<'id', string | number>, requestId?: string): V;
|
|
33
|
+
/**
|
|
34
|
+
* Updates the state with the given entity. Update the global or the current entity's status if it exists.
|
|
35
|
+
* @param state Actual state
|
|
36
|
+
* @param entity Payload item;
|
|
37
|
+
* @param requestId Id of request which has resolved if any
|
|
38
|
+
* @param idProperty Property of the entity containing its unique identifier
|
|
39
|
+
*/
|
|
40
|
+
resolveRequestOne<V extends EntityState<T> & AsyncStoreItem, W extends keyof T>(state: V, entity: EntityWithoutAsyncStoreItem<T> & Record<W, string | number>, requestId?: string, idProperty?: W): V;
|
|
41
|
+
/**
|
|
42
|
+
* Updates the state with the given entities. Updates also AsyncStoreItem properties of each entity, when a request is resolved.
|
|
43
|
+
* @param state Actual state
|
|
44
|
+
* @param entities Payload items;
|
|
45
|
+
* @param requestId Id of request which has resolved if any
|
|
46
|
+
*/
|
|
47
|
+
resolveRequestMany<V extends EntityState<T>>(state: V, entities: (Partial<T> & Record<'id', string | number>)[], requestId?: string): V;
|
|
48
|
+
/**
|
|
49
|
+
* Updates the state with the given entities. Updates also AsyncStoreItem properties of each entity, when a request is resolved.
|
|
50
|
+
* @param state Actual state
|
|
51
|
+
* @param entities Payload items;
|
|
52
|
+
* @param requestId Id of request which has resolved if any
|
|
53
|
+
* @param idProperty Property of the entity containing its unique identifier
|
|
54
|
+
*/
|
|
55
|
+
resolveRequestMany<V extends EntityState<T>, W extends keyof T>(state: V, entities: (Partial<T> & Record<W, string | number>)[], requestId?: string, idProperty?: W): V;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Create an Asynchronous Request Entity Adapter
|
|
59
|
+
* @param adapter Entity Adapter
|
|
60
|
+
*/
|
|
61
|
+
export declare function createEntityAsyncRequestAdapter<T extends AsyncStoreItem>(adapter: EntityAdapter<T>): EntityAsyncRequestAdapter<T>;
|
|
62
|
+
//# sourceMappingURL=async-entity.adapter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"async-entity.adapter.d.ts","sourceRoot":"","sources":["../../../src/store/async/async-entity.adapter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,aAAa,EACb,WAAW,EAEZ,MAAM,cAAc,CAAC;AAItB,OAAO,EACL,cAAc,EACd,2BAA2B,EAC5B,MAAM,oBAAoB,CAAC;AAE5B,4CAA4C;AAC5C,MAAM,WAAW,yBAAyB,CAAC,CAAC,SAAS,cAAc,CAAE,SAAQ,aAAa,CAAC,CAAC,CAAC;IAE3F;;;;;OAKG;IACH,eAAe,CAAC,CAAC,SAAS,WAAW,CAAC,CAAC,CAAC,GAAG,cAAc,EAAE,KAAK,EAAE,CAAC,EAAE,GAAG,CAAC,EAAE,CAAC,MAAM,GAAG,MAAM,CAAC,EAAE,EAAE,SAAS,CAAC,EAAE,MAAM,GAAG,CAAC,CAAC;IAEvH;;;;;OAKG;IACH,aAAa,CAAC,CAAC,SAAS,WAAW,CAAC,CAAC,CAAC,GAAG,cAAc,EAAE,KAAK,EAAE,CAAC,EAAE,EAAE,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,GAAG,SAAS,EAAE,SAAS,EAAE,MAAM,GAAG,CAAC,CAAC;IAEjI;;;;;OAKG;IACH,cAAc,CAAC,CAAC,SAAS,WAAW,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,GAAG,EAAE,CAAC,MAAM,GAAG,MAAM,CAAC,EAAE,EAAE,SAAS,EAAE,MAAM,GAAG,CAAC,CAAC;IAEnG;;;;;OAKG;IACH,iBAAiB,CAAC,CAAC,SAAS,WAAW,CAAC,CAAC,CAAC,GAAG,cAAc,EAAE,KAAK,EAAE,CAAC,EAAE,MAAM,EAAE,2BAA2B,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,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
|
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
|
+
const currentEntity = state.entities[entity[idProperty]];
|
|
21
|
+
const newEntity = currentEntity
|
|
22
|
+
? asyncStoreItemAdapter.resolveRequest({ ...entity, ...asyncStoreItemAdapter.extractAsyncStoreItem(currentEntity) }, requestId)
|
|
23
|
+
: asyncStoreItemAdapter.initialize(entity);
|
|
24
|
+
state = asyncStoreItemAdapter.resolveRequest(state, requestId);
|
|
25
|
+
return adapter.upsertOne(newEntity, state);
|
|
26
|
+
};
|
|
27
|
+
const resolveRequestMany = (state, entities, requestId, idProperty = 'id') => adapter.updateMany(entities.filter((entity) => !!state.entities[entity[idProperty]]).map((entity) => {
|
|
28
|
+
const model = { ...entity, ...asyncStoreItemAdapter.extractAsyncStoreItem(state.entities[entity[idProperty]]) };
|
|
29
|
+
return { id: entity[idProperty], changes: asyncStoreItemAdapter.resolveRequest(model, requestId) };
|
|
30
|
+
}), state);
|
|
31
|
+
const failRequestMany = (state, ids = [], requestId) => {
|
|
32
|
+
if (ids.length > 0 && !ids.some((id) => state.entities[id] === undefined)) {
|
|
33
|
+
return adapter.updateMany(ids.map((id) => ({
|
|
34
|
+
id,
|
|
35
|
+
changes: asyncStoreItemAdapter.failRequest(asyncStoreItemAdapter.extractAsyncStoreItem(state.entities[id]), requestId)
|
|
36
|
+
})), state);
|
|
37
|
+
}
|
|
38
|
+
return asyncStoreItemAdapter.failRequest(state, requestId);
|
|
39
|
+
};
|
|
40
|
+
return {
|
|
41
|
+
...adapter,
|
|
42
|
+
failRequestMany,
|
|
43
|
+
addRequestOne,
|
|
44
|
+
addRequestMany,
|
|
45
|
+
resolveRequestOne,
|
|
46
|
+
resolveRequestMany
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
//# 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;AACH,MAAM,UAAU,+BAA+B,CAA2B,OAAyB;IACjG,MAAM,aAAa,GAA0H,CAAC,KAAK,EAAE,EAAE,EAAE,SAAS,EAAE,EAAE;QACpK,MAAM,aAAa,GAAG,OAAO,EAAE,KAAK,WAAW,IAAI,EAAE,KAAK,IAAI,IAAI,KAAK,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC;QACrF,IAAI,aAAa,EAAE,CAAC;YAClB,MAAM,OAAO,GAAG,qBAAqB,CAAC,UAAU,CAAC,qBAAqB,CAAC,qBAAqB,CAAC,aAAa,CAAC,EAAE,SAAS,CAAC,CAAC;YACxH,OAAO,OAAO,CAAC,SAAS,CAAC,EAAE,EAAE,EAAE,OAAO,EAAe,EAAE,KAAK,CAAC,CAAC;QAChE,CAAC;QACD,OAAO,qBAAqB,CAAC,UAAU,CAAC,KAAK,EAAE,SAAS,CAAC,CAAC;IAC5D,CA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@
|
|
|
1
|
+
import { AsyncStoreItem, EntityStatus } from './async.interfaces';
|
|
2
|
+
/**
|
|
3
|
+
* Adapter to help manipulate AsyncStoreItems to register new request and update the status when they fail or resolve.
|
|
4
|
+
*/
|
|
5
|
+
export interface AsyncStoreItemAdapter {
|
|
6
|
+
/**
|
|
7
|
+
* Adds a request to an AsyncStoreItem.
|
|
8
|
+
* If the item had a failure and no ongoing requests, sets it's failure status back to false
|
|
9
|
+
* @param item
|
|
10
|
+
* @param requestId
|
|
11
|
+
*/
|
|
12
|
+
addRequest<T extends AsyncStoreItem>(item: T, requestId: string): T;
|
|
13
|
+
/**
|
|
14
|
+
* Updates an AsyncStoreItem when a request has resolved.
|
|
15
|
+
* Removes it from its requestIds array.
|
|
16
|
+
* If no requestId provided, the method returns the current status of the AsyncStoreItem
|
|
17
|
+
* @param item
|
|
18
|
+
* @param requestId
|
|
19
|
+
*/
|
|
20
|
+
resolveRequest<T extends AsyncStoreItem>(item: T, requestId?: string): T;
|
|
21
|
+
/**
|
|
22
|
+
* Updates an AsyncStoreItem when a request has failed.
|
|
23
|
+
* Removes it from its requestIds array and set its failure status.
|
|
24
|
+
* @param item
|
|
25
|
+
* @param requestId
|
|
26
|
+
*/
|
|
27
|
+
failRequest<T extends AsyncStoreItem>(item: T, requestId?: string): T;
|
|
28
|
+
/**
|
|
29
|
+
* Add AsyncStoreItem properties (with initial values) to the given entity
|
|
30
|
+
* @param entityItem
|
|
31
|
+
* @returns Given item improved with AsyncStoreItem properties
|
|
32
|
+
*/
|
|
33
|
+
initialize<T extends object>(entityItem: T): T & AsyncStoreItem;
|
|
34
|
+
/**
|
|
35
|
+
* Extract only AsyncStoreItem properties from the given entity
|
|
36
|
+
* @param entityItem A model containing AsyncStoreItem properties
|
|
37
|
+
* @returns Object containing only AsyncStoreItem properties
|
|
38
|
+
*/
|
|
39
|
+
extractAsyncStoreItem<T extends AsyncStoreItem>(entityItem: T): AsyncStoreItem;
|
|
40
|
+
/**
|
|
41
|
+
* Clear AsyncStoreItem properties from the given entity
|
|
42
|
+
* @param entityItem A model containing AsyncStoreItem properties
|
|
43
|
+
*/
|
|
44
|
+
clearAsyncStoreItem<T extends AsyncStoreItem>(entityItem: T): T;
|
|
45
|
+
/**
|
|
46
|
+
* Merges an AsyncStoreItem collection into one item that gives an overall status.
|
|
47
|
+
* @param items
|
|
48
|
+
*/
|
|
49
|
+
merge(...items: (AsyncStoreItem | undefined)[]): AsyncStoreItem;
|
|
50
|
+
/**
|
|
51
|
+
* Add a request to the given subResource of an EntityStatus object
|
|
52
|
+
* @param status
|
|
53
|
+
* @param subResource
|
|
54
|
+
* @param requestId
|
|
55
|
+
*/
|
|
56
|
+
entityStatusAddRequest<T extends EntityStatus<T>>(status: T, subResource: keyof T, requestId: string): T;
|
|
57
|
+
/**
|
|
58
|
+
* Resolve a request on the given subResource of an EntityStatus object
|
|
59
|
+
* @param status
|
|
60
|
+
* @param subResource
|
|
61
|
+
* @param requestId
|
|
62
|
+
*/
|
|
63
|
+
entityStatusResolveRequest<T extends EntityStatus<T>>(status: T, subResource: keyof T, requestId?: string): T;
|
|
64
|
+
/**
|
|
65
|
+
* Fail a request to the given subResource of an EntityStatus object
|
|
66
|
+
* @param status
|
|
67
|
+
* @param subResource
|
|
68
|
+
* @param requestId
|
|
69
|
+
*/
|
|
70
|
+
entityStatusFailRequest<T extends EntityStatus<T>>(status: T, subResource: keyof T, requestId?: string): T;
|
|
71
|
+
/**
|
|
72
|
+
* Reset the failure status of the given subResource of an EntityStatus object
|
|
73
|
+
* @param status
|
|
74
|
+
* @param subResource
|
|
75
|
+
*/
|
|
76
|
+
entityStatusResetFailure<T extends EntityStatus<T>>(status: T, subResource: keyof T): T;
|
|
77
|
+
/**
|
|
78
|
+
* Reset the failure status of the given AsyncStoreItem to false
|
|
79
|
+
* @param entityItem
|
|
80
|
+
* @returns AsyncStoreItem with the updated failure status
|
|
81
|
+
*/
|
|
82
|
+
resetFailureStatus<T extends AsyncStoreItem>(entityItem: T): T;
|
|
83
|
+
/**
|
|
84
|
+
* Set the pending status of the given AsyncStoreItem to true
|
|
85
|
+
* @param entityItem
|
|
86
|
+
* @returns AsyncStoreItem with the updated pending status
|
|
87
|
+
*/
|
|
88
|
+
setLoadingStatus<T extends AsyncStoreItem>(entityItem: T): T;
|
|
89
|
+
}
|
|
90
|
+
export declare const asyncStoreItemAdapter: AsyncStoreItemAdapter;
|
|
91
|
+
//# sourceMappingURL=async.adapter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"async.adapter.d.ts","sourceRoot":"","sources":["../../../src/store/async/async.adapter.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,cAAc,EACd,YAAY,EAEb,MAAM,oBAAoB,CAAC;AAE5B;;GAEG;AACH,MAAM,WAAW,qBAAqB;IACpC;;;;;OAKG;IACH,UAAU,CAAC,CAAC,SAAS,cAAc,EAAE,IAAI,EAAE,CAAC,EAAE,SAAS,EAAE,MAAM,GAAG,CAAC,CAAC;IAEpE;;;;;;OAMG;IACH,cAAc,CAAC,CAAC,SAAS,cAAc,EAAE,IAAI,EAAE,CAAC,EAAE,SAAS,CAAC,EAAE,MAAM,GAAG,CAAC,CAAC;IAEzE;;;;;OAKG;IACH,WAAW,CAAC,CAAC,SAAS,cAAc,EAAE,IAAI,EAAE,CAAC,EAAE,SAAS,CAAC,EAAE,MAAM,GAAG,CAAC,CAAC;IAEtE;;;;OAIG;IACH,UAAU,CAAC,CAAC,SAAS,MAAM,EAAE,UAAU,EAAE,CAAC,GAAG,CAAC,GAAG,cAAc,CAAC;IAEhE;;;;OAIG;IACH,qBAAqB,CAAC,CAAC,SAAS,cAAc,EAAE,UAAU,EAAE,CAAC,GAAG,cAAc,CAAC;IAE/E;;;OAGG;IACH,mBAAmB,CAAC,CAAC,SAAS,cAAc,EAAE,UAAU,EAAE,CAAC,GAAG,CAAC,CAAC;IAEhE;;;OAGG;IACH,KAAK,CAAC,GAAG,KAAK,EAAE,CAAC,cAAc,GAAG,SAAS,CAAC,EAAE,GAAG,cAAc,CAAC;IAEhE;;;;;OAKG;IACH,sBAAsB,CAAC,CAAC,SAAS,YAAY,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,WAAW,EAAE,MAAM,CAAC,EAAE,SAAS,EAAE,MAAM,GAAG,CAAC,CAAC;IAEzG;;;;;OAKG;IACH,0BAA0B,CAAC,CAAC,SAAS,YAAY,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,WAAW,EAAE,MAAM,CAAC,EAAE,SAAS,CAAC,EAAE,MAAM,GAAG,CAAC,CAAC;IAE9G;;;;;OAKG;IACH,uBAAuB,CAAC,CAAC,SAAS,YAAY,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,WAAW,EAAE,MAAM,CAAC,EAAE,SAAS,CAAC,EAAE,MAAM,GAAG,CAAC,CAAC;IAE3G;;;;OAIG;IACH,wBAAwB,CAAC,CAAC,SAAS,YAAY,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,WAAW,EAAE,MAAM,CAAC,GAAG,CAAC,CAAC;IAExF;;;;OAIG;IACH,kBAAkB,CAAC,CAAC,SAAS,cAAc,EAAE,UAAU,EAAE,CAAC,GAAG,CAAC,CAAC;IAE/D;;;;OAIG;IACH,gBAAgB,CAAC,CAAC,SAAS,cAAc,EAAE,UAAU,EAAE,CAAC,GAAG,CAAC,CAAC;CAC9D;AAED,eAAO,MAAM,qBAAqB,EAAE,qBAwGnC,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":"AA2GA,MAAM,CAAC,MAAM,qBAAqB,GAA0B;IAC1D,UAAU,EAAE,CAAC,IAAI,EAAE,SAAS,EAAE,EAAE;QAC9B,OAAO;YACL,GAAG,I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AAC,cAAc,CAAC,gBAAgB,EAAE,SAAS,CAAC,CAAC,CAAC,CAAC,EAAE,UAAU,EAAE,EAAiB,EAAE;SACxI,CAAC;IACJ,CAAC;IAED,uBAAuB,EAAE,CAAC,MAAM,EAAE,WAAW,EAAE,SAAS,EAAE,EAAE;QAC1D,MAAM,gBAAgB,GAAG,MAAM,CAAC,WAAW,CAAC,CAAC;QAC7C,OAAO;YACL,GAAG,MAAM;YACT,CAAC,WAAW,CAAC,EAAE,gBAAgB,CAAC,CAAC,CAAC,qBAAqB,CAAC,WAAW,CAAC,gBAAgB,EAAE,SAAS,CAAC,CAAC,CAAC,CAAC,EAAE,UAAU,EAAE,EAAiB,EAAE,SAAS,EAAE,IAAI,EAAE;SACtJ,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,EAAiB,EAAE;SACjI,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,17 @@
|
|
|
1
|
+
import { AsyncRequest, FromApiActionPayload } from './async.interfaces';
|
|
2
|
+
/**
|
|
3
|
+
* Determine if the action is an AsyncRequest action
|
|
4
|
+
* @param action Redux Action
|
|
5
|
+
*/
|
|
6
|
+
export declare function isCallAction<T = any>(action?: any): action is FromApiActionPayload<T>;
|
|
7
|
+
/**
|
|
8
|
+
* Determine if the action is an AsyncRequest action with a Request ID
|
|
9
|
+
* @param action Redux Action
|
|
10
|
+
*/
|
|
11
|
+
export declare function isIdentifiedCallAction<T = any>(action?: any): action is FromApiActionPayload<T> & AsyncRequest;
|
|
12
|
+
/**
|
|
13
|
+
* Determine if the given item implements the AsyncRequest interface
|
|
14
|
+
* @param item
|
|
15
|
+
*/
|
|
16
|
+
export declare function isAsyncRequest<T>(item: any): item is T & AsyncRequest;
|
|
17
|
+
//# sourceMappingURL=async.helpers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"async.helpers.d.ts","sourceRoot":"","sources":["../../../src/store/async/async.helpers.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,YAAY,EACZ,oBAAoB,EACrB,MAAM,oBAAoB,CAAC;AAE5B;;;GAGG;AACH,wBAAgB,YAAY,CAAC,CAAC,GAAG,GAAG,EAAE,MAAM,CAAC,EAAE,GAAG,GAAG,MAAM,IAAI,oBAAoB,CAAC,CAAC,CAAC,CAMrF;AAED;;;GAGG;AACH,wBAAgB,sBAAsB,CAAC,CAAC,GAAG,GAAG,EAAE,MAAM,CAAC,EAAE,GAAG,GAAG,MAAM,IAAI,oBAAoB,CAAC,CAAC,CAAC,GAAG,YAAY,CAE9G;AAED;;;GAGG;AACH,wBAAgB,cAAc,CAAC,CAAC,EAAE,IAAI,EAAE,GAAG,GAAG,IAAI,IAAI,CAAC,GAAG,YAAY,CAErE"}
|
|
@@ -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,91 @@
|
|
|
1
|
+
import { FailActionPayload, FailEntitiesActionPayload, SetActionPayload, SetEntitiesActionPayload, SetEntityActionPayload, UpdateEntitiesActionPayload, UpdateEntitiesActionPayloadWithId, UpdateEntityActionPayload, UpdateEntityActionPayloadWithId } from '../types';
|
|
2
|
+
export type RequestId = string;
|
|
3
|
+
/**
|
|
4
|
+
* Interface representing an asynchronous request
|
|
5
|
+
*/
|
|
6
|
+
export interface AsyncRequest {
|
|
7
|
+
/** ID of the request */
|
|
8
|
+
requestId: RequestId;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Represents a store item that can be manipulated via asynchronous calls
|
|
12
|
+
*/
|
|
13
|
+
export interface AsyncStoreItem {
|
|
14
|
+
/**
|
|
15
|
+
* IDs of the active asynchronous requests for this item.
|
|
16
|
+
*/
|
|
17
|
+
requestIds: RequestId[];
|
|
18
|
+
/**
|
|
19
|
+
* Has a recent call failed.
|
|
20
|
+
* This is reset back to false the next time a new async process is started and there are no active requests.
|
|
21
|
+
*/
|
|
22
|
+
isFailure?: boolean;
|
|
23
|
+
/**
|
|
24
|
+
* Is an asynchronous process ongoing on that item
|
|
25
|
+
*/
|
|
26
|
+
isPending?: boolean;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Payload for actions relying on asynchronous requests
|
|
30
|
+
*/
|
|
31
|
+
export interface FromApiActionPayload<T> extends Partial<AsyncRequest> {
|
|
32
|
+
/** Promise call from API */
|
|
33
|
+
call: Promise<T>;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Unwraps the type of a FromApiActionPayload
|
|
37
|
+
*/
|
|
38
|
+
export type ExtractFromApiActionPayloadType<T extends FromApiActionPayload<any>> = T['call'] extends Promise<infer U> ? U : never;
|
|
39
|
+
/**
|
|
40
|
+
* Payload for actions relying on asynchronous requests
|
|
41
|
+
*/
|
|
42
|
+
export interface FromApiActionPayloadWithEntityId<T> extends FromApiActionPayload<T> {
|
|
43
|
+
/** ID of the entity affected by the call */
|
|
44
|
+
id?: string;
|
|
45
|
+
}
|
|
46
|
+
/** Add an optional request ID to the given object */
|
|
47
|
+
export type WithRequestId<T> = T & Partial<AsyncRequest>;
|
|
48
|
+
/** Payload to set entities actions from async */
|
|
49
|
+
export interface SetAsyncStoreItemActionPayload<T> extends SetActionPayload<T>, Partial<AsyncRequest> {
|
|
50
|
+
}
|
|
51
|
+
/** Payload to update entities actions from async */
|
|
52
|
+
export interface UpdateAsyncStoreItemEntitiesActionPayload<T extends object, K extends keyof T> extends UpdateEntitiesActionPayload<T, K>, Partial<AsyncRequest> {
|
|
53
|
+
}
|
|
54
|
+
/** Payload to update entities actions from async with a field ID */
|
|
55
|
+
export interface UpdateAsyncStoreItemEntitiesActionPayloadWithId<T extends {
|
|
56
|
+
id: string | number;
|
|
57
|
+
}> extends UpdateEntitiesActionPayloadWithId<T>, Partial<AsyncRequest> {
|
|
58
|
+
}
|
|
59
|
+
/** Payload to update entity actions from async */
|
|
60
|
+
export interface UpdateAsyncStoreItemEntityActionPayload<T extends object, K extends keyof T> extends UpdateEntityActionPayload<T, K>, Partial<AsyncRequest> {
|
|
61
|
+
}
|
|
62
|
+
/** Payload to update entity actions from async with a field ID */
|
|
63
|
+
export interface UpdateAsyncStoreItemEntityActionPayloadWithId<T extends {
|
|
64
|
+
id: string | number;
|
|
65
|
+
}> extends UpdateEntityActionPayloadWithId<T>, Partial<AsyncRequest> {
|
|
66
|
+
}
|
|
67
|
+
/** Payload to set/upsert entities actions from async */
|
|
68
|
+
export interface SetAsyncStoreItemEntitiesActionPayload<T extends object> extends SetEntitiesActionPayload<T>, Partial<AsyncRequest> {
|
|
69
|
+
}
|
|
70
|
+
/** Payload to set/upsert entity actions from async */
|
|
71
|
+
export interface SetAsyncStoreItemEntityActionPayload<T extends object> extends SetEntityActionPayload<T>, Partial<AsyncRequest> {
|
|
72
|
+
}
|
|
73
|
+
/** Payload to fail entity actions from async */
|
|
74
|
+
export interface FailAsyncStoreItemEntityActionPayload<T extends object> extends FailActionPayload<T>, Partial<AsyncRequest> {
|
|
75
|
+
}
|
|
76
|
+
/** Payload to fail entities actions from async */
|
|
77
|
+
export interface FailAsyncStoreItemEntitiesActionPayload<T extends object> extends FailEntitiesActionPayload<T>, Partial<AsyncRequest> {
|
|
78
|
+
}
|
|
79
|
+
/** Status for all the elements inside a cart */
|
|
80
|
+
export type EntityStatus<T, U extends keyof T = never> = {
|
|
81
|
+
[P in keyof Omit<T, 'id' | U>]?: AsyncStoreItem;
|
|
82
|
+
};
|
|
83
|
+
/**
|
|
84
|
+
* Extends an Entity model with a status property that holds async information for each of its sub-resources
|
|
85
|
+
*/
|
|
86
|
+
export type EntityWithStatus<T> = T & {
|
|
87
|
+
status: EntityStatus<T>;
|
|
88
|
+
};
|
|
89
|
+
/** Modifies the given type that extends AsyncStoreItem to remove those properties */
|
|
90
|
+
export type EntityWithoutAsyncStoreItem<T extends AsyncStoreItem> = Omit<T, keyof AsyncStoreItem>;
|
|
91
|
+
//# sourceMappingURL=async.interfaces.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"async.interfaces.d.ts","sourceRoot":"","sources":["../../../src/store/async/async.interfaces.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,iBAAiB,EACjB,yBAAyB,EACzB,gBAAgB,EAChB,wBAAwB,EACxB,sBAAsB,EACtB,2BAA2B,EAC3B,iCAAiC,EACjC,yBAAyB,EACzB,+BAA+B,EAChC,MAAM,UAAU,CAAC;AAElB,MAAM,MAAM,SAAS,GAAG,MAAM,CAAC;AAE/B;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B,wBAAwB;IACxB,SAAS,EAAE,SAAS,CAAC;CACtB;AAED;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B;;OAEG;IACH,UAAU,EAAE,SAAS,EAAE,CAAC;IAExB;;;OAGG;IACH,SAAS,CAAC,EAAE,OAAO,CAAC;IAEpB;;OAEG;IACH,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB;AAED;;GAEG;AACH,MAAM,WAAW,oBAAoB,CAAC,CAAC,CAAE,SAAQ,OAAO,CAAC,YAAY,CAAC;IACpE,4BAA4B;IAC5B,IAAI,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC;CAClB;AAED;;GAEG;AACH,MAAM,MAAM,+BAA+B,CAAC,CAAC,SAAS,oBAAoB,CAAC,GAAG,CAAC,IAAI,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