@daffodil/core 0.42.2 → 0.43.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/collection/build-metadata.d.ts +6 -0
- package/collection/build-request.d.ts +6 -0
- package/collection/collection.interface.d.ts +16 -0
- package/collection/countable.interface.d.ts +9 -0
- package/collection/error-map.d.ts +4 -0
- package/collection/metadata.interface.d.ts +11 -0
- package/collection/page-out-of-bounds.error.d.ts +9 -0
- package/{state/collection → collection}/paginable.d.ts +3 -3
- package/collection/public_api.d.ts +10 -0
- package/collection/request.interface.d.ts +22 -0
- package/{state/collection → collection}/sortable.d.ts +3 -3
- package/esm2020/collection/build-metadata.mjs +16 -0
- package/esm2020/collection/build-request.mjs +10 -0
- package/esm2020/collection/collection.interface.mjs +2 -0
- package/esm2020/collection/countable.interface.mjs +2 -0
- package/esm2020/collection/error-map.mjs +5 -0
- package/esm2020/collection/metadata.interface.mjs +2 -0
- package/esm2020/collection/page-out-of-bounds.error.mjs +12 -0
- package/esm2020/collection/paginable.mjs +2 -0
- package/esm2020/collection/public_api.mjs +11 -0
- package/esm2020/collection/request.interface.mjs +2 -0
- package/esm2020/collection/sortable.mjs +11 -0
- package/esm2020/identifiable/array-to-dict.mjs +6 -0
- package/esm2020/identifiable/public_api.mjs +2 -0
- package/esm2020/public_api.mjs +3 -1
- package/esm2020/state/collection/actions.mjs +2 -0
- package/esm2020/state/collection/adapter.class.mjs +67 -0
- package/esm2020/state/collection/facade.interface.mjs +2 -0
- package/esm2020/state/collection/facade.mjs +32 -0
- package/esm2020/state/collection/initial-state.mjs +14 -0
- package/esm2020/state/collection/public_api.mjs +7 -3
- package/esm2020/state/collection/selector-factory.mjs +36 -0
- package/esm2020/state/public_api.mjs +2 -2
- package/esm2020/state/reducers/identity.mjs +6 -0
- package/esm2020/state/reducers/public_api.mjs +2 -1
- package/esm2020/state/testing/daffodil-core-state-testing.mjs +5 -0
- package/esm2020/state/testing/index.mjs +2 -0
- package/esm2020/state/testing/mock-collection-facade.mjs +30 -0
- package/esm2020/state/testing/public_api.mjs +2 -0
- package/esm2020/testing/factories/address.factory.mjs +38 -0
- package/esm2020/testing/factories/collection/metadata.factory.mjs +42 -0
- package/esm2020/testing/factories/collection/mock-collection.class.mjs +25 -0
- package/esm2020/testing/factories/collection/numerically-paginable.factory.mjs +25 -0
- package/esm2020/testing/factories/collection/public_api.mjs +8 -0
- package/esm2020/testing/factories/collection/request.factory.mjs +33 -0
- package/esm2020/testing/factories/collection/sort-option.factory.mjs +24 -0
- package/esm2020/testing/factories/collection/sort-options.factory.mjs +30 -0
- package/esm2020/testing/factories/collection/sortable.factory.mjs +32 -0
- package/esm2020/testing/factories/public_api.mjs +4 -0
- package/esm2020/testing/index.mjs +2 -8
- package/esm2020/testing/public_api.mjs +6 -0
- package/esm2020/types/public_api.mjs +1 -1
- package/esm2020/utils/array-to-dict.mjs +3 -3
- package/fesm2015/daffodil-core-state-testing.mjs +37 -0
- package/fesm2015/daffodil-core-state-testing.mjs.map +1 -0
- package/fesm2015/daffodil-core-state.mjs +130 -12
- package/fesm2015/daffodil-core-state.mjs.map +1 -1
- package/fesm2015/daffodil-core-testing.mjs +203 -27
- package/fesm2015/daffodil-core-testing.mjs.map +1 -1
- package/fesm2015/daffodil-core.mjs +60 -3
- package/fesm2015/daffodil-core.mjs.map +1 -1
- package/fesm2020/daffodil-core-state-testing.mjs +37 -0
- package/fesm2020/daffodil-core-state-testing.mjs.map +1 -0
- package/fesm2020/daffodil-core-state.mjs +154 -12
- package/fesm2020/daffodil-core-state.mjs.map +1 -1
- package/fesm2020/daffodil-core-testing.mjs +203 -27
- package/fesm2020/daffodil-core-testing.mjs.map +1 -1
- package/fesm2020/daffodil-core.mjs +60 -3
- package/fesm2020/daffodil-core.mjs.map +1 -1
- package/identifiable/array-to-dict.d.ts +5 -0
- package/identifiable/public_api.d.ts +2 -0
- package/package.json +9 -1
- package/public_api.d.ts +2 -1
- package/state/collection/actions.d.ts +32 -0
- package/state/collection/adapter.class.d.ts +31 -0
- package/state/collection/facade.d.ts +32 -0
- package/state/collection/facade.interface.d.ts +46 -0
- package/state/collection/initial-state.d.ts +2 -0
- package/state/collection/public_api.d.ts +6 -2
- package/state/collection/selector-factory.d.ts +53 -0
- package/state/public_api.d.ts +1 -1
- package/state/reducers/identity.d.ts +6 -0
- package/state/reducers/public_api.d.ts +1 -0
- package/state/testing/daffodil-core-state-testing.d.ts +5 -0
- package/state/testing/index.d.ts +1 -0
- package/state/testing/mock-collection-facade.d.ts +24 -0
- package/state/testing/package.json +10 -0
- package/state/testing/public_api.d.ts +1 -0
- package/testing/{address/factories → factories}/address.factory.d.ts +1 -1
- package/testing/factories/collection/metadata.factory.d.ts +27 -0
- package/testing/factories/collection/mock-collection.class.d.ts +18 -0
- package/testing/factories/collection/numerically-paginable.factory.d.ts +8 -0
- package/testing/factories/collection/public_api.d.ts +7 -0
- package/testing/factories/collection/request.factory.d.ts +20 -0
- package/testing/factories/collection/sort-option.factory.d.ts +8 -0
- package/testing/factories/collection/sort-options.factory.d.ts +9 -0
- package/testing/factories/collection/sortable.factory.d.ts +9 -0
- package/testing/factories/public_api.d.ts +4 -0
- package/testing/index.d.ts +1 -5
- package/testing/public_api.d.ts +4 -0
- package/types/public_api.d.ts +0 -1
- package/utils/array-to-dict.d.ts +4 -3
- package/esm2020/state/collection/paginable.mjs +0 -2
- package/esm2020/state/collection/sortable.mjs +0 -11
- package/esm2020/testing/address/factories/address.factory.mjs +0 -38
- package/esm2020/types/dict.type.mjs +0 -2
- package/types/dict.type.d.ts +0 -5
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { Action } from '@ngrx/store';
|
|
2
|
+
import { DaffCollectionMetadata } from '@daffodil/core';
|
|
3
|
+
/**
|
|
4
|
+
* An action for changing the number of items shown on each page for this collection.
|
|
5
|
+
*/
|
|
6
|
+
export interface DaffCollectionChangePageSize extends Action {
|
|
7
|
+
/**
|
|
8
|
+
* The number of items per page.
|
|
9
|
+
*/
|
|
10
|
+
readonly pageSize: DaffCollectionMetadata['pageSize'];
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* An action for changing the current page of items for this collection.
|
|
14
|
+
*/
|
|
15
|
+
export interface DaffCollectionChangeCurrentPage extends Action {
|
|
16
|
+
/**
|
|
17
|
+
* The current page of items for this collection.
|
|
18
|
+
*/
|
|
19
|
+
readonly currentPage: DaffCollectionMetadata['currentPage'];
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* An action for changing the sorting option for this collection.
|
|
23
|
+
*/
|
|
24
|
+
export interface DaffCollectionChangeSortingOption extends Action {
|
|
25
|
+
/**
|
|
26
|
+
* The sort option to be applied.
|
|
27
|
+
*/
|
|
28
|
+
readonly sort: {
|
|
29
|
+
option: DaffCollectionMetadata['appliedSortOption'];
|
|
30
|
+
direction: DaffCollectionMetadata['appliedSortDirection'];
|
|
31
|
+
};
|
|
32
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { DaffCollectionMetadata, DaffCollectionRequest } from '@daffodil/core';
|
|
2
|
+
/**
|
|
3
|
+
* Provides an abstracted way to manage a collection state.
|
|
4
|
+
*/
|
|
5
|
+
export declare class DaffCollectionStateAdapter<T extends DaffCollectionMetadata = DaffCollectionMetadata> {
|
|
6
|
+
/**
|
|
7
|
+
* Stores a collection request in state.
|
|
8
|
+
* This is useful when you want to preemptively reduce a request before waiting for a response.
|
|
9
|
+
*/
|
|
10
|
+
storeRequest(request: DaffCollectionRequest, state: T): T;
|
|
11
|
+
/**
|
|
12
|
+
* Sets the page size.
|
|
13
|
+
*/
|
|
14
|
+
setPageSize(size: number, state: T): T;
|
|
15
|
+
/**
|
|
16
|
+
* Sets the current page.
|
|
17
|
+
*/
|
|
18
|
+
setCurrentPage(page: number, state: T): T;
|
|
19
|
+
/**
|
|
20
|
+
* Sets the sorting option and direction.
|
|
21
|
+
*/
|
|
22
|
+
setSort(option: string, direction: string, state: T): T;
|
|
23
|
+
/**
|
|
24
|
+
* Set the entire collection metadata at once.
|
|
25
|
+
*/
|
|
26
|
+
setMetadata(metadata: DaffCollectionMetadata, state: T): T;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Create the adapter for the collection state.
|
|
30
|
+
*/
|
|
31
|
+
export declare const getCollectionStateAdapter: <T extends DaffCollectionMetadata = DaffCollectionMetadata>() => DaffCollectionStateAdapter<T>;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { Store, Action } from '@ngrx/store';
|
|
2
|
+
import { Observable } from 'rxjs';
|
|
3
|
+
import { DaffCollectionMetadata, DaffCollectionRequest, DaffSortDirectionEnum, DaffSortOption } from '@daffodil/core';
|
|
4
|
+
import { DaffCollectionFacadeInterface } from './facade.interface';
|
|
5
|
+
import { DaffCollectionMemoizedSelectors } from './selector-factory';
|
|
6
|
+
/**
|
|
7
|
+
* An abstract class for a collection facade.
|
|
8
|
+
* It is configurable via its constructor parameters.
|
|
9
|
+
* The particular collection state from which
|
|
10
|
+
* this facade will read is determined by the selectors passed.
|
|
11
|
+
*
|
|
12
|
+
* @inheritdoc
|
|
13
|
+
*/
|
|
14
|
+
export declare abstract class DaffCollectionFacade<TState, TMetadata extends DaffCollectionMetadata = DaffCollectionMetadata> implements DaffCollectionFacadeInterface<TMetadata> {
|
|
15
|
+
protected store: Store<TState>;
|
|
16
|
+
metadata$: Observable<TMetadata>;
|
|
17
|
+
request$: Observable<DaffCollectionRequest>;
|
|
18
|
+
count$: Observable<number>;
|
|
19
|
+
currentPage$: Observable<number>;
|
|
20
|
+
totalPages$: Observable<number>;
|
|
21
|
+
pageSize$: Observable<number>;
|
|
22
|
+
sortOptions$: Observable<DaffSortOption[]>;
|
|
23
|
+
appliedSortOption$: Observable<string>;
|
|
24
|
+
appliedSortDirection$: Observable<DaffSortDirectionEnum>;
|
|
25
|
+
constructor(store: Store<TState>, selectors: DaffCollectionMemoizedSelectors<TState, TMetadata>);
|
|
26
|
+
/**
|
|
27
|
+
* Dispatches the given action.
|
|
28
|
+
*
|
|
29
|
+
* @param action action to dispatch.
|
|
30
|
+
*/
|
|
31
|
+
dispatch(action: Action): void;
|
|
32
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { Action } from '@ngrx/store';
|
|
2
|
+
import { Observable } from 'rxjs';
|
|
3
|
+
import { DaffSortDirectionEnum, DaffSortOption } from '@daffodil/core';
|
|
4
|
+
import { DaffCollectionMetadata, DaffCollectionRequest } from '@daffodil/core';
|
|
5
|
+
import { DaffStoreFacade } from '../store/facade';
|
|
6
|
+
/**
|
|
7
|
+
* A facade for interacting with a collection state.
|
|
8
|
+
*/
|
|
9
|
+
export interface DaffCollectionFacadeInterface<TMetadata extends DaffCollectionMetadata = DaffCollectionMetadata> extends DaffStoreFacade<Action> {
|
|
10
|
+
/**
|
|
11
|
+
* The page metadata for the collection.
|
|
12
|
+
*/
|
|
13
|
+
metadata$: Observable<TMetadata>;
|
|
14
|
+
/**
|
|
15
|
+
* Builds a request that matches the current collection.
|
|
16
|
+
*/
|
|
17
|
+
request$: Observable<DaffCollectionRequest>;
|
|
18
|
+
/**
|
|
19
|
+
* The number of items in the collection.
|
|
20
|
+
*/
|
|
21
|
+
count$: Observable<number>;
|
|
22
|
+
/**
|
|
23
|
+
* The current page of items for the collection.
|
|
24
|
+
*/
|
|
25
|
+
currentPage$: Observable<number>;
|
|
26
|
+
/**
|
|
27
|
+
* The number of pages of items available in the collection.
|
|
28
|
+
*/
|
|
29
|
+
totalPages$: Observable<number>;
|
|
30
|
+
/**
|
|
31
|
+
* The number of items per page for the collection.
|
|
32
|
+
*/
|
|
33
|
+
pageSize$: Observable<number>;
|
|
34
|
+
/**
|
|
35
|
+
* The sort options available for the items of the collection.
|
|
36
|
+
*/
|
|
37
|
+
sortOptions$: Observable<DaffSortOption[]>;
|
|
38
|
+
/**
|
|
39
|
+
* The sort options available for the items of the collection.
|
|
40
|
+
*/
|
|
41
|
+
appliedSortOption$: Observable<string>;
|
|
42
|
+
/**
|
|
43
|
+
* The sort options available for the items of the collection.
|
|
44
|
+
*/
|
|
45
|
+
appliedSortDirection$: Observable<DaffSortDirectionEnum>;
|
|
46
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { MemoizedSelector } from '@ngrx/store';
|
|
2
|
+
import { DaffCollectionMetadata, DaffCollectionRequest } from '@daffodil/core';
|
|
3
|
+
/**
|
|
4
|
+
* An interface to describe all selectors related to the collection metadata.
|
|
5
|
+
*/
|
|
6
|
+
export interface DaffCollectionMemoizedSelectors<TState, TMetadata extends DaffCollectionMetadata = DaffCollectionMetadata> {
|
|
7
|
+
/**
|
|
8
|
+
* Selects the metadata for the collection.
|
|
9
|
+
*/
|
|
10
|
+
selectCollectionMetadata: MemoizedSelector<TState, TMetadata>;
|
|
11
|
+
/**
|
|
12
|
+
* Builds a request that matches the current collection.
|
|
13
|
+
*/
|
|
14
|
+
selectCollectionRequest: MemoizedSelector<TState, DaffCollectionRequest>;
|
|
15
|
+
/**
|
|
16
|
+
* Selects the total number of items of the collection.
|
|
17
|
+
*/
|
|
18
|
+
selectCollectionCount: MemoizedSelector<TState, TMetadata['count']>;
|
|
19
|
+
/**
|
|
20
|
+
* Selects the current page of items of the collection.
|
|
21
|
+
*/
|
|
22
|
+
selectCollectionCurrentPage: MemoizedSelector<TState, TMetadata['currentPage']>;
|
|
23
|
+
/**
|
|
24
|
+
* Selects the total number of pages of items that exist in the collection.
|
|
25
|
+
*/
|
|
26
|
+
selectCollectionTotalPages: MemoizedSelector<TState, TMetadata['totalPages']>;
|
|
27
|
+
/**
|
|
28
|
+
* Selects the number of items on each collection.
|
|
29
|
+
*/
|
|
30
|
+
selectCollectionPageSize: MemoizedSelector<TState, TMetadata['pageSize']>;
|
|
31
|
+
/**
|
|
32
|
+
* Selects the sort options that may be applied to the collection.
|
|
33
|
+
*/
|
|
34
|
+
selectCollectionSortOptions: MemoizedSelector<TState, TMetadata['sortOptions']['options']>;
|
|
35
|
+
/**
|
|
36
|
+
* Selects the applied sorting option if one is applied.
|
|
37
|
+
*/
|
|
38
|
+
selectCollectionAppliedSortOption: MemoizedSelector<TState, TMetadata['appliedSortOption']>;
|
|
39
|
+
/**
|
|
40
|
+
* Selects the applied sorting direction if a sorting option is applied.
|
|
41
|
+
*/
|
|
42
|
+
selectCollectionAppliedSortDirection: MemoizedSelector<TState, TMetadata['appliedSortDirection']>;
|
|
43
|
+
/**
|
|
44
|
+
* Selects the applied sorting direction if a sorting option is applied.
|
|
45
|
+
*/
|
|
46
|
+
selectCollectionIds: MemoizedSelector<TState, TMetadata['ids']>;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Creates collection selectors.
|
|
50
|
+
*
|
|
51
|
+
* @param selectCollectionState A selector for the particular collection state upon which the returned selectors should operate.
|
|
52
|
+
*/
|
|
53
|
+
export declare const daffCollectionSelectorFactory: <TState, TMetadata extends DaffCollectionMetadata = DaffCollectionMetadata>(selectCollectionState: MemoizedSelector<TState, TMetadata, import("@ngrx/store").DefaultProjectorFn<TMetadata>>) => DaffCollectionMemoizedSelectors<TState, TMetadata>;
|
package/state/public_api.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export * from './operators/public_api';
|
|
2
2
|
export * from './states/public_api';
|
|
3
3
|
export * from './errors/public_api';
|
|
4
|
-
export * from './collection/public_api';
|
|
5
4
|
export * from './reducers/public_api';
|
|
5
|
+
export * from './collection/public_api';
|
|
6
6
|
export { DaffStoreFacade } from './store/facade';
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { Action } from '@ngrx/store';
|
|
2
|
+
/**
|
|
3
|
+
* A simple reducer that simply returns the passed state.
|
|
4
|
+
* This is useful for stubbing out parts of state that are not covered in an injected extra reducer map.
|
|
5
|
+
*/
|
|
6
|
+
export declare const daffIdentityReducer: <T = unknown>(state: T, action: Action) => T;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './public_api';
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { Action } from '@ngrx/store';
|
|
2
|
+
import { BehaviorSubject } from 'rxjs';
|
|
3
|
+
import { DaffCollectionMetadata, DaffCollectionRequest, DaffSortDirectionEnum, DaffSortOption } from '@daffodil/core';
|
|
4
|
+
import { DaffCollectionFacadeInterface } from '@daffodil/core/state';
|
|
5
|
+
import * as i0 from "@angular/core";
|
|
6
|
+
/**
|
|
7
|
+
* Can be used to mock out the {@link DaffCollectionFacade} in testing environments.
|
|
8
|
+
*
|
|
9
|
+
* @inheritdoc
|
|
10
|
+
*/
|
|
11
|
+
export declare class MockDaffCollectionFacade implements DaffCollectionFacadeInterface {
|
|
12
|
+
metadata$: BehaviorSubject<DaffCollectionMetadata>;
|
|
13
|
+
request$: BehaviorSubject<DaffCollectionRequest>;
|
|
14
|
+
count$: BehaviorSubject<number>;
|
|
15
|
+
currentPage$: BehaviorSubject<number>;
|
|
16
|
+
totalPages$: BehaviorSubject<number>;
|
|
17
|
+
pageSize$: BehaviorSubject<number>;
|
|
18
|
+
sortOptions$: BehaviorSubject<DaffSortOption[]>;
|
|
19
|
+
appliedSortOption$: BehaviorSubject<string>;
|
|
20
|
+
appliedSortDirection$: BehaviorSubject<DaffSortDirectionEnum>;
|
|
21
|
+
dispatch(action: Action): void;
|
|
22
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<MockDaffCollectionFacade, never>;
|
|
23
|
+
static ɵprov: i0.ɵɵInjectableDeclaration<MockDaffCollectionFacade>;
|
|
24
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@daffodil/core/state/testing",
|
|
3
|
+
"module": "../../fesm2015/daffodil-core-state-testing.mjs",
|
|
4
|
+
"es2020": "../../fesm2020/daffodil-core-state-testing.mjs",
|
|
5
|
+
"esm2020": "../../esm2020/state/testing/daffodil-core-state-testing.mjs",
|
|
6
|
+
"fesm2020": "../../fesm2020/daffodil-core-state-testing.mjs",
|
|
7
|
+
"fesm2015": "../../fesm2015/daffodil-core-state-testing.mjs",
|
|
8
|
+
"typings": "daffodil-core-state-testing.d.ts",
|
|
9
|
+
"sideEffects": false
|
|
10
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { MockDaffCollectionFacade } from './mock-collection-facade';
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { DaffCollectionMetadata, DaffIdentifiable, DaffSortDirectionEnum, DaffSortOption, DaffSortOptions } from '@daffodil/core';
|
|
2
|
+
import { DaffModelFactory } from '../factory';
|
|
3
|
+
import { DaffNumericallyPaginableFactory } from './numerically-paginable.factory';
|
|
4
|
+
import { DaffSortableFactory } from './sortable.factory';
|
|
5
|
+
import * as i0 from "@angular/core";
|
|
6
|
+
/**
|
|
7
|
+
* Mocked {@link DaffCollectionMetadata} object.
|
|
8
|
+
*/
|
|
9
|
+
export declare class MockCollectionMetadata implements DaffCollectionMetadata {
|
|
10
|
+
currentPage: number;
|
|
11
|
+
totalPages: number;
|
|
12
|
+
pageSize: number;
|
|
13
|
+
sortOptions: DaffSortOptions;
|
|
14
|
+
appliedSortOption: DaffSortOption['value'];
|
|
15
|
+
appliedSortDirection: DaffSortDirectionEnum;
|
|
16
|
+
count: number;
|
|
17
|
+
ids: DaffIdentifiable['id'][];
|
|
18
|
+
constructor(pageInfoFactory: DaffNumericallyPaginableFactory, sortFieldsFactory: DaffSortableFactory);
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Factory for creating {@link DaffCollectionMetadata}s.
|
|
22
|
+
*/
|
|
23
|
+
export declare class DaffCollectionMetadataFactory extends DaffModelFactory<DaffCollectionMetadata> {
|
|
24
|
+
constructor(pageInfoFactory: DaffNumericallyPaginableFactory, sortFieldsFactory: DaffSortableFactory);
|
|
25
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<DaffCollectionMetadataFactory, never>;
|
|
26
|
+
static ɵprov: i0.ɵɵInjectableDeclaration<DaffCollectionMetadataFactory>;
|
|
27
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { DaffCollection, DaffCollectionMetadata, DaffIdentifiable } from '@daffodil/core';
|
|
2
|
+
import { DaffModelFactory } from '../factory';
|
|
3
|
+
import { DaffCollectionMetadataFactory } from './metadata.factory';
|
|
4
|
+
/**
|
|
5
|
+
* Mocked {@link DaffCollection} object.
|
|
6
|
+
*
|
|
7
|
+
* It should be customized by passing the factory for the contained entity as the first constructor argument.
|
|
8
|
+
*/
|
|
9
|
+
export declare class MockCollection<T extends DaffIdentifiable = DaffIdentifiable> implements DaffCollection<T> {
|
|
10
|
+
private itemFactory;
|
|
11
|
+
private metadataFactory;
|
|
12
|
+
private _items;
|
|
13
|
+
metadata: DaffCollectionMetadata;
|
|
14
|
+
data: Record<T["id"], T>;
|
|
15
|
+
constructor(itemFactory: DaffModelFactory<T>, metadataFactory: DaffCollectionMetadataFactory);
|
|
16
|
+
private createItems;
|
|
17
|
+
private createMetadata;
|
|
18
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { DaffNumericallyPaginable } from '@daffodil/core';
|
|
2
|
+
import { DaffModelFactory } from '../factory';
|
|
3
|
+
import * as i0 from "@angular/core";
|
|
4
|
+
export declare class DaffNumericallyPaginableFactory extends DaffModelFactory<DaffNumericallyPaginable> {
|
|
5
|
+
constructor();
|
|
6
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<DaffNumericallyPaginableFactory, never>;
|
|
7
|
+
static ɵprov: i0.ɵɵInjectableDeclaration<DaffNumericallyPaginableFactory>;
|
|
8
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export { DaffNumericallyPaginableFactory } from './numerically-paginable.factory';
|
|
2
|
+
export { DaffSortableFactory } from './sortable.factory';
|
|
3
|
+
export { DaffSortOptionFactory } from './sort-option.factory';
|
|
4
|
+
export { DaffSortOptionsFactory } from './sort-options.factory';
|
|
5
|
+
export * from './metadata.factory';
|
|
6
|
+
export * from './request.factory';
|
|
7
|
+
export * from './mock-collection.class';
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { DaffCollectionRequest } from '@daffodil/core';
|
|
2
|
+
import { DaffModelFactory } from '../factory';
|
|
3
|
+
import * as i0 from "@angular/core";
|
|
4
|
+
/**
|
|
5
|
+
* Mocked {@link DaffCollectionRequest} object.
|
|
6
|
+
*/
|
|
7
|
+
export declare class MockCollectionRequest implements DaffCollectionRequest {
|
|
8
|
+
currentPage: any;
|
|
9
|
+
appliedSortDirection: any;
|
|
10
|
+
pageSize: any;
|
|
11
|
+
appliedSortOption: any;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Factory for creating {@link DaffCollectionRequest}s.
|
|
15
|
+
*/
|
|
16
|
+
export declare class DaffCollectionRequestFactory extends DaffModelFactory<DaffCollectionRequest> {
|
|
17
|
+
constructor();
|
|
18
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<DaffCollectionRequestFactory, never>;
|
|
19
|
+
static ɵprov: i0.ɵɵInjectableDeclaration<DaffCollectionRequestFactory>;
|
|
20
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { DaffSortOption } from '@daffodil/core';
|
|
2
|
+
import { DaffModelFactory } from '../factory';
|
|
3
|
+
import * as i0 from "@angular/core";
|
|
4
|
+
export declare class DaffSortOptionFactory extends DaffModelFactory<DaffSortOption> {
|
|
5
|
+
constructor();
|
|
6
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<DaffSortOptionFactory, never>;
|
|
7
|
+
static ɵprov: i0.ɵɵInjectableDeclaration<DaffSortOptionFactory>;
|
|
8
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { DaffSortOptions } from '@daffodil/core';
|
|
2
|
+
import { DaffModelFactory } from '../factory';
|
|
3
|
+
import { DaffSortOptionFactory } from './sort-option.factory';
|
|
4
|
+
import * as i0 from "@angular/core";
|
|
5
|
+
export declare class DaffSortOptionsFactory extends DaffModelFactory<DaffSortOptions> {
|
|
6
|
+
constructor(optionFactory: DaffSortOptionFactory);
|
|
7
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<DaffSortOptionsFactory, never>;
|
|
8
|
+
static ɵprov: i0.ɵɵInjectableDeclaration<DaffSortOptionsFactory>;
|
|
9
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { DaffSortable } from '@daffodil/core';
|
|
2
|
+
import { DaffModelFactory } from '../factory';
|
|
3
|
+
import { DaffSortOptionsFactory } from './sort-options.factory';
|
|
4
|
+
import * as i0 from "@angular/core";
|
|
5
|
+
export declare class DaffSortableFactory extends DaffModelFactory<DaffSortable> {
|
|
6
|
+
constructor(optionFactory: DaffSortOptionsFactory);
|
|
7
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<DaffSortableFactory, never>;
|
|
8
|
+
static ɵprov: i0.ɵɵInjectableDeclaration<DaffSortableFactory>;
|
|
9
|
+
}
|
package/testing/index.d.ts
CHANGED
|
@@ -1,5 +1 @@
|
|
|
1
|
-
export
|
|
2
|
-
export { DaffMockCurrencyPipe } from './angular/mocks/pipes/currency';
|
|
3
|
-
export { DaffInMemoryDataServiceInterface } from './angular/interfaces/in-memory-data-service.interface';
|
|
4
|
-
export { DaffCoreTestingModule } from './testing.module';
|
|
5
|
-
export { DaffModelFactory } from './factories/factory';
|
|
1
|
+
export * from './public_api';
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export { DaffMockCurrencyPipe } from './angular/mocks/pipes/currency';
|
|
2
|
+
export { DaffInMemoryDataServiceInterface } from './angular/interfaces/in-memory-data-service.interface';
|
|
3
|
+
export { DaffCoreTestingModule } from './testing.module';
|
|
4
|
+
export * from './factories/public_api';
|
package/types/public_api.d.ts
CHANGED
package/utils/array-to-dict.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
|
|
1
|
+
declare type Dictionary = Record<string | number | symbol, any>;
|
|
2
2
|
/**
|
|
3
3
|
* Converts an array into a dictionary.
|
|
4
|
-
* Dictionary values are keyed by the return of the specified getKey
|
|
4
|
+
* Dictionary values are keyed by the return of the specified `getKey`.
|
|
5
5
|
*/
|
|
6
|
-
export declare const daffArrayToDict: <T>(array: T[], getKey
|
|
6
|
+
export declare const daffArrayToDict: <T extends Dictionary>(array: T[], getKey: (val: T) => keyof Dictionary) => Record<string | number | symbol, T>;
|
|
7
|
+
export {};
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
export {};
|
|
2
|
-
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicGFnaW5hYmxlLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vLi4vLi4vbGlicy9jb3JlL3N0YXRlL3NyYy9jb2xsZWN0aW9uL3BhZ2luYWJsZS50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiIiwic291cmNlc0NvbnRlbnQiOlsiLyoqXG4gKiBUaGUgaW50ZXJmYWNlIHRoYXQgZGVzY3JpYmVzIGEgY29sbGVjdGlvbiBvZiBlbGVtZW50cyB0aGF0IGNhbiBiZSBuYXZpZ2F0ZWQgaW5cbiAqIGEgcGFnZWQgd2F5LiBFLmcuIFwiUGFnZXMgMSwyLDMsNCw1XCIuXG4gKlxuICovXG5leHBvcnQgaW50ZXJmYWNlIERhZmZOdW1lcmljYWxseVBhZ2luYWJsZSB7XG4gIGN1cnJlbnRfcGFnZTogbnVtYmVyO1xuICB0b3RhbF9wYWdlczogbnVtYmVyO1xuICBwYWdlX3NpemU6IG51bWJlcjtcbn1cbiJdfQ==
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The direction in which to sort a list of elements, e.g. if the list was
|
|
3
|
-
* sorted alphabetically, "Ascending" would be from "A-Z",
|
|
4
|
-
* and "Descending" would be from "Z-A".
|
|
5
|
-
*/
|
|
6
|
-
export var DaffSortDirectionEnum;
|
|
7
|
-
(function (DaffSortDirectionEnum) {
|
|
8
|
-
DaffSortDirectionEnum["Ascending"] = "ASC";
|
|
9
|
-
DaffSortDirectionEnum["Descending"] = "DSC";
|
|
10
|
-
})(DaffSortDirectionEnum || (DaffSortDirectionEnum = {}));
|
|
11
|
-
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic29ydGFibGUuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi8uLi8uLi9saWJzL2NvcmUvc3RhdGUvc3JjL2NvbGxlY3Rpb24vc29ydGFibGUudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBaUJBOzs7O0dBSUc7QUFDSCxNQUFNLENBQU4sSUFBWSxxQkFHWDtBQUhELFdBQVkscUJBQXFCO0lBQy9CLDBDQUFpQixDQUFBO0lBQ2pCLDJDQUFrQixDQUFBO0FBQ3BCLENBQUMsRUFIVyxxQkFBcUIsS0FBckIscUJBQXFCLFFBR2hDIiwic291cmNlc0NvbnRlbnQiOlsiLyoqXG4gKiBUaGUgbWV0YWRhdGEgdGhhdCBkZXNjcmliZXMgdGhlIHNvcnRpbmcgYmVoYXZpb3Igb2YgYSBjb2xsZWN0aW9uIG9mIGVsZW1lbnRzLlxuICovXG5leHBvcnQgaW50ZXJmYWNlIERhZmZTb3J0T3B0aW9ucyB7XG4gIGRlZmF1bHQ6IERhZmZTb3J0T3B0aW9uWyd2YWx1ZSddO1xuICBvcHRpb25zOiBEYWZmU29ydE9wdGlvbltdO1xufVxuXG5cbi8qKlxuICogT25lIHBhcnRpY3VsYXIgb3B0aW9uIHVzZWQgdG8gc29ydCBhIGNvbGxlY3Rpb24gb2YgZWxlbWVudHM7XG4gKi9cbmV4cG9ydCBpbnRlcmZhY2UgRGFmZlNvcnRPcHRpb24ge1xuICBsYWJlbDogc3RyaW5nO1xuICB2YWx1ZTogYW55O1xufVxuXG4vKipcbiAqIFRoZSBkaXJlY3Rpb24gaW4gd2hpY2ggdG8gc29ydCBhIGxpc3Qgb2YgZWxlbWVudHMsIGUuZy4gaWYgdGhlIGxpc3Qgd2FzXG4gKiBzb3J0ZWQgYWxwaGFiZXRpY2FsbHksIFwiQXNjZW5kaW5nXCIgd291bGQgYmUgZnJvbSBcIkEtWlwiLFxuICogYW5kIFwiRGVzY2VuZGluZ1wiIHdvdWxkIGJlIGZyb20gXCJaLUFcIi5cbiAqL1xuZXhwb3J0IGVudW0gRGFmZlNvcnREaXJlY3Rpb25FbnVtIHtcbiAgQXNjZW5kaW5nID0gJ0FTQycsXG4gIERlc2NlbmRpbmcgPSAnRFNDJ1xufVxuXG4vKipcbiAqIERlc2NyaWJlcyB0aGUgcHJvcGVydGllcyBvZiBhIGNvbGxlY3Rpb24gdGhhdCBtYWtlIHRoZSBjb2xsZWN0aW9uIGFibGUgdG8gYmVcbiAqIHNvcnRlZCBieSBEYWZmb2RpbC5cbiAqL1xuZXhwb3J0IGludGVyZmFjZSBEYWZmU29ydGFibGUge1xuXG4gIC8qKlxuICAgKiBUaGUgYXZhaWxhYmxlIG9wdGlvbnMgYnkgd2hpY2ggdG8gc29ydCB0aGUgY29sbGVjdGlvbi5cbiAgICovXG4gIHNvcnRfb3B0aW9uczogRGFmZlNvcnRPcHRpb25zO1xuXG4gIC8qKlxuICAgKiBUaGUgY3VycmVudGx5IGFwcGxpZWQgc29ydGluZyBvcHRpb24uXG4gICAqL1xuICBhcHBsaWVkX3NvcnRfb3B0aW9uOiBEYWZmU29ydE9wdGlvblsndmFsdWUnXTtcblxuICAvKipcbiAgICogVGhlIGN1cnJlbnRseSBhcHBsaWVkIHNvcnQgZGlyZWN0aW9uLlxuICAgKi9cbiAgYXBwbGllZF9zb3J0X2RpcmVjdGlvbjogRGFmZlNvcnREaXJlY3Rpb25FbnVtO1xufVxuIl19
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import { Injectable } from '@angular/core';
|
|
2
|
-
import * as faker from '@faker-js/faker/locale/en_US';
|
|
3
|
-
import { DaffModelFactory } from '../../factories/factory';
|
|
4
|
-
import * as i0 from "@angular/core";
|
|
5
|
-
/**
|
|
6
|
-
* @deprecated
|
|
7
|
-
* Prefer the `MockDaffAddress` of daffodil/geography/testing`
|
|
8
|
-
*/
|
|
9
|
-
export class MockDaffAddress {
|
|
10
|
-
constructor() {
|
|
11
|
-
this.firstname = faker.name.firstName();
|
|
12
|
-
this.lastname = faker.name.lastName();
|
|
13
|
-
this.street = faker.address.streetName();
|
|
14
|
-
this.city = faker.address.city();
|
|
15
|
-
this.state = faker.address.stateAbbr();
|
|
16
|
-
this.email = faker.internet.email();
|
|
17
|
-
this.postcode = faker.address.zipCode();
|
|
18
|
-
this.telephone = faker.phone.phoneNumber();
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
/**
|
|
22
|
-
* @deprecated
|
|
23
|
-
* Prefer the `DaffAddressFactory` of `daffodil/geography/testing`
|
|
24
|
-
*/
|
|
25
|
-
export class DaffAddressFactory extends DaffModelFactory {
|
|
26
|
-
constructor() {
|
|
27
|
-
super(MockDaffAddress);
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
/** @nocollapse */ /** @nocollapse */ DaffAddressFactory.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.0", ngImport: i0, type: DaffAddressFactory, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
31
|
-
/** @nocollapse */ /** @nocollapse */ DaffAddressFactory.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.3.0", ngImport: i0, type: DaffAddressFactory, providedIn: 'root' });
|
|
32
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.0", ngImport: i0, type: DaffAddressFactory, decorators: [{
|
|
33
|
-
type: Injectable,
|
|
34
|
-
args: [{
|
|
35
|
-
providedIn: 'root',
|
|
36
|
-
}]
|
|
37
|
-
}], ctorParameters: function () { return []; } });
|
|
38
|
-
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYWRkcmVzcy5mYWN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