@daffodil/core 0.69.0 → 0.71.0
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/constructable/constructable.d.ts +1 -1
- package/esm2022/base64/browser/browser.service.mjs +4 -4
- package/esm2022/base64/server/server.service.mjs +4 -4
- package/esm2022/constructable/constructable.mjs +1 -1
- package/esm2022/external-script/external-script.service.mjs +4 -4
- package/esm2022/external-script/testing/external-script.service.mjs +4 -4
- package/esm2022/graphql/apollo/queued-apollo/queued-apollo.service.mjs +4 -4
- package/esm2022/routing/uri/normalizer.service.mjs +4 -4
- package/esm2022/state/actions/failure.type.mjs +1 -1
- package/esm2022/state/actions/public_api.mjs +1 -1
- package/esm2022/state/operation/adapter.mjs +3 -3
- package/esm2022/state/operation/entity/adapter.mjs +69 -36
- package/esm2022/state/operation/entity/helpers/create-fake-id.mjs +10 -0
- package/esm2022/state/operation/entity/public_api.mjs +2 -2
- package/esm2022/state/operation/entity/selectors.mjs +2 -1
- package/esm2022/state/operation/selectors.mjs +4 -3
- package/esm2022/state/states/helpers.mjs +15 -0
- package/esm2022/state/states/public_api.mjs +2 -2
- package/esm2022/state/states/state.enum.mjs +1 -1
- package/esm2022/state/testing/mock-collection-facade.mjs +4 -4
- package/esm2022/state/testing/mock-operation-facade.mjs +4 -4
- package/esm2022/storage/error/error.service.mjs +4 -4
- package/esm2022/storage/localstorage/localstorage.service.mjs +4 -4
- package/esm2022/storage/noopstorage/noopstorage.service.mjs +4 -4
- package/esm2022/storage/server-error/server-error.service.mjs +4 -4
- package/esm2022/testing/angular/mocks/pipes/currency.mjs +4 -4
- package/esm2022/testing/factories/address.factory.mjs +6 -6
- package/esm2022/testing/factories/collection/metadata.factory.mjs +4 -4
- package/esm2022/testing/factories/collection/numerically-paginable.factory.mjs +4 -4
- package/esm2022/testing/factories/collection/request.factory.mjs +4 -4
- package/esm2022/testing/factories/collection/sort-option.factory.mjs +4 -4
- package/esm2022/testing/factories/collection/sort-options.factory.mjs +4 -4
- package/esm2022/testing/factories/collection/sortable.factory.mjs +4 -4
- package/esm2022/testing/factories/filters/filter.factory.mjs +4 -4
- package/esm2022/testing/factories/filters/request.factory.mjs +4 -4
- package/esm2022/testing/factories/filters/toggle-request.mjs +4 -4
- package/esm2022/testing/factories/filters/type/equal/option.mjs +4 -4
- package/esm2022/testing/factories/filters/type/equal/request.mjs +4 -4
- package/esm2022/testing/factories/filters/type/equal/toggle-request.mjs +4 -4
- package/esm2022/testing/factories/filters/type/equal.mjs +4 -4
- package/esm2022/testing/factories/filters/type/range-numeric/option.mjs +4 -4
- package/esm2022/testing/factories/filters/type/range-numeric/pair.mjs +4 -4
- package/esm2022/testing/factories/filters/type/range-numeric/request-option.mjs +4 -4
- package/esm2022/testing/factories/filters/type/range-numeric/request.mjs +4 -4
- package/esm2022/testing/factories/filters/type/range-numeric/toggle-request.mjs +4 -4
- package/esm2022/testing/factories/filters/type/range-numeric.mjs +4 -4
- package/esm2022/testing/factories/identifiable.factory.mjs +4 -4
- package/esm2022/testing/testing.module.mjs +5 -5
- package/esm2022/utils/identity.mjs +8 -0
- package/esm2022/utils/observe.mjs +11 -0
- package/esm2022/utils/public_api.mjs +3 -1
- package/fesm2022/daffodil-core-external-script-testing.mjs +3 -3
- package/fesm2022/daffodil-core-external-script-testing.mjs.map +1 -1
- package/fesm2022/daffodil-core-external-script.mjs +3 -3
- package/fesm2022/daffodil-core-external-script.mjs.map +1 -1
- package/fesm2022/daffodil-core-graphql.mjs +3 -3
- package/fesm2022/daffodil-core-graphql.mjs.map +1 -1
- package/fesm2022/daffodil-core-routing.mjs +3 -3
- package/fesm2022/daffodil-core-routing.mjs.map +1 -1
- package/fesm2022/daffodil-core-state-testing.mjs +6 -6
- package/fesm2022/daffodil-core-state-testing.mjs.map +1 -1
- package/fesm2022/daffodil-core-state.mjs +89 -49
- package/fesm2022/daffodil-core-state.mjs.map +1 -1
- package/fesm2022/daffodil-core-testing.mjs +72 -72
- package/fesm2022/daffodil-core-testing.mjs.map +1 -1
- package/fesm2022/daffodil-core.mjs +38 -20
- package/fesm2022/daffodil-core.mjs.map +1 -1
- package/package.json +1 -1
- package/state/actions/failure.type.d.ts +6 -4
- package/state/operation/entity/adapter.d.ts +21 -1
- package/state/operation/entity/{helpers.d.ts → helpers/create-fake-id.d.ts} +0 -5
- package/state/operation/entity/public_api.d.ts +1 -1
- package/state/operation/entity/selectors.d.ts +1 -1
- package/state/states/helpers.d.ts +9 -0
- package/state/states/public_api.d.ts +1 -0
- package/state/states/state.enum.d.ts +16 -4
- package/utils/identity.d.ts +5 -0
- package/utils/observe.d.ts +8 -0
- package/utils/public_api.d.ts +2 -0
- package/esm2022/state/operation/entity/helpers.mjs +0 -19
package/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"name":"@daffodil/core","nx":{"targets":{"build":{"outputs":["{workspaceRoot}/dist/core"]}}},"version":"0.
|
|
1
|
+
{"name":"@daffodil/core","nx":{"targets":{"build":{"outputs":["{workspaceRoot}/dist/core"]}}},"version":"0.71.0","description":"Interfaces built for daffodil/state","repository":{"type":"git","url":"https://github.com/graycoreio/daffodil"},"author":"Graycore LLC","license":"MIT","bugs":{"url":"https://github.com/graycoreio/daffodil/issues"},"homepage":"https://github.com/graycoreio/daffodil","peerDependencies":{"@angular/core":"^17.0.0","@angular/common":"^17.0.0","rxjs":"7.8.1"},"optionalDependencies":{"graphql":"^15.8.0","@angular/router":"^17.0.0","@apollo/client":"^3.0.0","@ngrx/store":"^17.0.0","angular-in-memory-web-api":"^0.17.0","apollo-angular":"^6.0.0","@faker-js/faker":"^7.6.0"},"module":"fesm2022/daffodil-core.mjs","typings":"index.d.ts","exports":{"./package.json":{"default":"./package.json"},".":{"types":"./index.d.ts","esm2022":"./esm2022/daffodil-core.mjs","esm":"./esm2022/daffodil-core.mjs","default":"./fesm2022/daffodil-core.mjs"},"./external-script":{"types":"./external-script/index.d.ts","esm2022":"./esm2022/external-script/daffodil-core-external-script.mjs","esm":"./esm2022/external-script/daffodil-core-external-script.mjs","default":"./fesm2022/daffodil-core-external-script.mjs"},"./graphql":{"types":"./graphql/index.d.ts","esm2022":"./esm2022/graphql/daffodil-core-graphql.mjs","esm":"./esm2022/graphql/daffodil-core-graphql.mjs","default":"./fesm2022/daffodil-core-graphql.mjs"},"./routing":{"types":"./routing/index.d.ts","esm2022":"./esm2022/routing/daffodil-core-routing.mjs","esm":"./esm2022/routing/daffodil-core-routing.mjs","default":"./fesm2022/daffodil-core-routing.mjs"},"./state":{"types":"./state/index.d.ts","esm2022":"./esm2022/state/daffodil-core-state.mjs","esm":"./esm2022/state/daffodil-core-state.mjs","default":"./fesm2022/daffodil-core-state.mjs"},"./testing":{"types":"./testing/index.d.ts","esm2022":"./esm2022/testing/daffodil-core-testing.mjs","esm":"./esm2022/testing/daffodil-core-testing.mjs","default":"./fesm2022/daffodil-core-testing.mjs"},"./external-script/testing":{"types":"./external-script/testing/index.d.ts","esm2022":"./esm2022/external-script/testing/daffodil-core-external-script-testing.mjs","esm":"./esm2022/external-script/testing/daffodil-core-external-script-testing.mjs","default":"./fesm2022/daffodil-core-external-script-testing.mjs"},"./state/testing":{"types":"./state/testing/index.d.ts","esm2022":"./esm2022/state/testing/daffodil-core-state-testing.mjs","esm":"./esm2022/state/testing/daffodil-core-state-testing.mjs","default":"./fesm2022/daffodil-core-state-testing.mjs"}},"sideEffects":false,"dependencies":{"tslib":"^2.3.0"}}
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import { Action } from '@ngrx/store';
|
|
2
2
|
import { DaffStateError } from '../errors/state-error.interface';
|
|
3
|
-
|
|
4
|
-
* An action that represents a failure of an operation.
|
|
5
|
-
*/
|
|
6
|
-
export interface DaffFailureAction extends Action {
|
|
3
|
+
export interface DaffFailable {
|
|
7
4
|
/**
|
|
8
5
|
* A list of errors that occured during the operation.
|
|
9
6
|
*/
|
|
10
7
|
readonly payload: DaffStateError[];
|
|
11
8
|
}
|
|
9
|
+
/**
|
|
10
|
+
* An action that represents a failure of an operation.
|
|
11
|
+
*/
|
|
12
|
+
export interface DaffFailureAction extends DaffFailable, Action {
|
|
13
|
+
}
|
|
@@ -7,7 +7,7 @@ import { DaffStateError } from '../../errors/public_api';
|
|
|
7
7
|
/**
|
|
8
8
|
* An entity state adapter that takes care of managing contextual operation and error state for entities.
|
|
9
9
|
*/
|
|
10
|
-
export interface
|
|
10
|
+
export interface DaffOperationEntityStateAdapterInterface<T extends DaffIdentifiable = DaffIdentifiable> {
|
|
11
11
|
/**
|
|
12
12
|
* Stores a list of entities in state and resets them all to stable.
|
|
13
13
|
*/
|
|
@@ -61,4 +61,24 @@ export interface DaffOperationEntityStateAdapter<T extends DaffIdentifiable = Da
|
|
|
61
61
|
*/
|
|
62
62
|
getSelectors<TRootState>(selectState: (state: TRootState) => DaffOperationEntityState<T>): DaffOperationEntityStateSelectors<TRootState, T>;
|
|
63
63
|
}
|
|
64
|
+
/**
|
|
65
|
+
* @inheritdoc
|
|
66
|
+
*/
|
|
67
|
+
export declare class DaffOperationEntityStateAdapter<T extends DaffIdentifiable = DaffIdentifiable> implements DaffOperationEntityStateAdapterInterface<T> {
|
|
68
|
+
protected adapter: EntityAdapter<DaffOperationEntity<T>>;
|
|
69
|
+
constructor(adapter?: EntityAdapter<DaffOperationEntity<T>>);
|
|
70
|
+
list<S extends DaffOperationEntityState<T> = DaffOperationEntityState<T>>(entities: T[], state: S): S;
|
|
71
|
+
preload<S extends DaffOperationEntityState<T> = DaffOperationEntityState<T>>(id: string, state: S): S;
|
|
72
|
+
load<S extends DaffOperationEntityState<T> = DaffOperationEntityState<T>>(entity: T, state: S): S;
|
|
73
|
+
preadd<S extends DaffOperationEntityState<T> = DaffOperationEntityState<T>>(entity: T, state: S, placeholderId?: string): S;
|
|
74
|
+
add<S extends DaffOperationEntityState<T> = DaffOperationEntityState<T>>(entity: T, state: S, placeholderId?: string): S;
|
|
75
|
+
preupdate<S extends DaffOperationEntityState<T> = DaffOperationEntityState<T>>(entity: Partial<T> & DaffIdentifiable, state: S): S;
|
|
76
|
+
update<S extends DaffOperationEntityState<T> = DaffOperationEntityState<T>>(entity: Partial<T> & DaffIdentifiable, state: S): S;
|
|
77
|
+
preremove<S extends DaffOperationEntityState<T> = DaffOperationEntityState<T>>(key: string, state: S): S;
|
|
78
|
+
remove<S extends DaffOperationEntityState<T> = DaffOperationEntityState<T>>(key: string, state: S): S;
|
|
79
|
+
operationFailed<S extends DaffOperationEntityState<T> = DaffOperationEntityState<T>>(key: string, errors: DaffStateError[], state: S): S;
|
|
80
|
+
resetState<S extends DaffOperationEntityState<T> = DaffOperationEntityState<T>>(key: string, state: S): S;
|
|
81
|
+
getInitialState<S extends DaffOperationEntityState<T> = DaffOperationEntityState<T>>(state?: S): S;
|
|
82
|
+
getSelectors<TRootState>(selectState: (state: TRootState) => DaffOperationEntityState<T>): DaffOperationEntityStateSelectors<TRootState, T>;
|
|
83
|
+
}
|
|
64
84
|
export declare function daffCreateOperationEntityStateAdapter<T extends DaffIdentifiable = DaffIdentifiable>(adapter?: EntityAdapter<DaffOperationEntity<T>>): DaffOperationEntityStateAdapter<T>;
|
|
@@ -1,8 +1,3 @@
|
|
|
1
|
-
import { DaffState } from '../../states/public_api';
|
|
2
|
-
/**
|
|
3
|
-
* Returns whether the state is one that represents an operation in progress.
|
|
4
|
-
*/
|
|
5
|
-
export declare function daffStateIsLoading(daffState: DaffState): boolean;
|
|
6
1
|
/**
|
|
7
2
|
* Generate a fake ID for use with placeholder entities.
|
|
8
3
|
*
|
|
@@ -5,7 +5,7 @@ import { DaffOperationEntity } from './type';
|
|
|
5
5
|
/**
|
|
6
6
|
* Selectors for an operation state.
|
|
7
7
|
*/
|
|
8
|
-
export interface DaffOperationEntityStateSelectors<TRootState, T extends DaffIdentifiable = DaffIdentifiable> {
|
|
8
|
+
export interface DaffOperationEntityStateSelectors<TRootState, T extends DaffIdentifiable = DaffIdentifiable> extends EntitySelectors<DaffOperationEntity<T>, TRootState> {
|
|
9
9
|
/**
|
|
10
10
|
* Selects an entity by ID.
|
|
11
11
|
*/
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { DaffState } from './state.enum';
|
|
2
|
+
/**
|
|
3
|
+
* Returns whether the state is one that represents an operation in progress.
|
|
4
|
+
*/
|
|
5
|
+
export declare function daffStateIsLoading(daffState: DaffState): boolean;
|
|
6
|
+
/**
|
|
7
|
+
* Returns whether the state is one that represents a mutable operation in progress.
|
|
8
|
+
*/
|
|
9
|
+
export declare function daffStateIsMutating(daffState: DaffState): boolean;
|
|
@@ -24,18 +24,26 @@ export declare const enum DaffState {
|
|
|
24
24
|
*/
|
|
25
25
|
Added = "Added",
|
|
26
26
|
/**
|
|
27
|
-
* The '
|
|
27
|
+
* The 'Updating' state describes when an object that currently exists in state
|
|
28
28
|
* is being changed in some way.
|
|
29
29
|
*
|
|
30
30
|
* Disambiguation: This has nothing to do with immutability.
|
|
31
31
|
*/
|
|
32
|
-
|
|
32
|
+
Updating = "Updating",
|
|
33
33
|
/**
|
|
34
34
|
* The 'Mutated' state describes when an object has recently been modified in
|
|
35
35
|
* state. This state is typically associated with a subsequent decay into a
|
|
36
36
|
* 'Stable' state.
|
|
37
37
|
*/
|
|
38
|
-
|
|
38
|
+
Updated = "Updated",
|
|
39
|
+
/**
|
|
40
|
+
* @deprecated in favor of {@link DaffState.Updating}
|
|
41
|
+
*/
|
|
42
|
+
Mutating = "Updating",
|
|
43
|
+
/**
|
|
44
|
+
* @deprecated in favor of {@link DaffState.Updated}
|
|
45
|
+
*/
|
|
46
|
+
Mutated = "Updated",
|
|
39
47
|
/**
|
|
40
48
|
* The "Deleting" state occurs when an object is in the process of being
|
|
41
49
|
* removed from state.
|
|
@@ -47,5 +55,9 @@ export declare const enum DaffState {
|
|
|
47
55
|
* @deprecated
|
|
48
56
|
* Use DaffState.Stable instead.
|
|
49
57
|
*/
|
|
50
|
-
Complete = "Stable"
|
|
58
|
+
Complete = "Stable",
|
|
59
|
+
/**
|
|
60
|
+
* Indicates that the most recent operation specififc to this entity has failed.
|
|
61
|
+
*/
|
|
62
|
+
Error = "Error"
|
|
51
63
|
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Observable } from 'rxjs';
|
|
2
|
+
/**
|
|
3
|
+
* Converts a value to an observable.
|
|
4
|
+
* If the value is an observable, just returns that observable.
|
|
5
|
+
* If the value is a promise, converts it to an observable (see rxjs `from`).
|
|
6
|
+
* If the value is neither, just returns an observable that immediately emits the value.
|
|
7
|
+
*/
|
|
8
|
+
export declare function observe<T>(val: T | Promise<T> | Observable<T>): Observable<T>;
|
package/utils/public_api.d.ts
CHANGED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Returns whether the state is one that represents an operation in progress.
|
|
3
|
-
*/
|
|
4
|
-
export function daffStateIsLoading(daffState) {
|
|
5
|
-
return daffState === "Adding" /* DaffState.Adding */
|
|
6
|
-
|| daffState === "Mutating" /* DaffState.Mutating */
|
|
7
|
-
|| daffState === "Resolving" /* DaffState.Resolving */
|
|
8
|
-
|| daffState === "Deleting" /* DaffState.Deleting */;
|
|
9
|
-
}
|
|
10
|
-
/**
|
|
11
|
-
* Generate a fake ID for use with placeholder entities.
|
|
12
|
-
*
|
|
13
|
-
* @param key An optional key that can augment the randomly generated ID.
|
|
14
|
-
* @returns A string cont
|
|
15
|
-
*/
|
|
16
|
-
export function daffOperationEntityCreateFakeId(key = '') {
|
|
17
|
-
return `ε-${Date.now()}-${key}`;
|
|
18
|
-
}
|
|
19
|
-
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaGVscGVycy5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uLy4uLy4uLy4uL2xpYnMvY29yZS9zdGF0ZS9zcmMvb3BlcmF0aW9uL2VudGl0eS9oZWxwZXJzLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUVBOztHQUVHO0FBQ0gsT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