@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
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"daffodil-core-state.mjs","sources":["../../../libs/core/state/src/operators/substream.pipe.ts","../../../libs/core/state/src/errors/transform-error-to-state-error.ts","../../../libs/core/state/src/collection/sortable.ts","../../../libs/core/state/src/reducers/create-meta.ts","../../../libs/core/state/src/daffodil-core-state.ts"],"sourcesContent":["import { Action } from '@ngrx/store';\nimport { pipe } from 'rxjs';\nimport {\n scan,\n filter,\n} from 'rxjs/operators';\n\nexport type ActionType = Action['type'];\nexport type ActionSequenceStep = ActionType | ActionType[];\nexport type ActionSequence = ActionSequenceStep[];\n\nconst compareActionSequenceStep = (step: ActionSequenceStep, action: Action): boolean => Array.isArray(step)\n ? step.reduce((acc, type) => acc || action.type === type, false)\n : action.type === step;\n\n/**\n * Watches for a particular stream of actions in the specified order and\n * emits a list of those actions once all sequence steps have been matched.\n *\n * This will find the first occurence of the substream and not necessarily the most concise or recent substream.\n * For example, substream([A, B]) encountering an action stream of [A1, A2, B1, B2] will emit [A1, B1].\n * When a substream is found and emitted, the list is reset and it will continue to listen to the action stream.\n *\n * You can indicate that a particular step in the sequence can be matched by mutiple actions by passing an array for that step.\n * For example, if the first step of the sequence could be action A or action B: substream([[A, B], C]).\n * An action stream of [A1, C1] would cause substream to emit [A1, C1].\n * An action stream of [B1, C1] would cause substream to emit [B1, C1].\n * An action stream of [A1, B1, C1] would cause substream to emit [A1, C1].\n *\n * You can optionally pass a list of terminators.\n * If a terminator is encountered in the action stream, any partially matched substream is reset.\n * For example, substream([A, B], C) would not emit anything for an action stream of [A1, C1, B1].\n *\n * @param sequence The sequence of action types that define the substream to listen for.\n * @param terminators A list of terminators, any of which interrupt and reset a partially matched substream.\n */\nexport const substream = (sequence: ActionSequence, ...terminators: ActionType[]) => {\n const isFullMatch = matchedSubstream => matchedSubstream.length === sequence.length;\n const accumulateMatchedSubstream = (matchedSubstream, action) =>\n compareActionSequenceStep(sequence[matchedSubstream.length], action)\n ? [\n ...matchedSubstream,\n action,\n ]\n : matchedSubstream;\n\n return pipe(\n scan<Action, Action[]>((matchedSubstream, action) =>\n terminators.indexOf(action.type) > -1\n // terminator found, reset the list\n ? []\n : accumulateMatchedSubstream(\n // reset the list if fully matched\n isFullMatch(matchedSubstream) ? [] : matchedSubstream,\n action,\n ),\n []),\n filter(isFullMatch),\n );\n};\n","import { DaffError } from '@daffodil/core';\n\nimport { DaffStateError } from './state-error.interface';\n\nexport type ErrorTransformer = (DaffError) => DaffStateError;\n\n/**\n * Transforms an error instance to a state error object.\n */\nexport function daffTransformErrorToStateError({ code, message, recoverable }: DaffError): DaffStateError {\n return { code, message, recoverable };\n}\n","/**\n * The metadata that describes the sorting behavior of a collection of elements.\n */\nexport interface DaffSortOptions {\n default: DaffSortOption['value'];\n options: DaffSortOption[];\n}\n\n\n/**\n * One particular option used to sort a collection of elements;\n */\nexport interface DaffSortOption {\n label: string;\n value: any;\n}\n\n/**\n * The direction in which to sort a list of elements, e.g. if the list was\n * sorted alphabetically, \"Ascending\" would be from \"A-Z\",\n * and \"Descending\" would be from \"Z-A\".\n */\nexport enum DaffSortDirectionEnum {\n Ascending = 'ASC',\n Descending = 'DSC'\n}\n\n/**\n * Describes the properties of a collection that make the collection able to be\n * sorted by Daffodil.\n */\nexport interface DaffSortable {\n\n /**\n * The available options by which to sort the collection.\n */\n sort_options: DaffSortOptions;\n\n /**\n * The currently applied sorting option.\n */\n applied_sort_option: DaffSortOption['value'];\n\n /**\n * The currently applied sort direction.\n */\n applied_sort_direction: DaffSortDirectionEnum;\n}\n","import {\n Action,\n ActionReducer,\n} from '@ngrx/store';\n\n/**\n * Creates and returns a composite reducer that invokes each of the passed reducers in turn.\n */\nexport function daffComposeReducers<\n T,\n V extends Action = Action\n>(reducers: ActionReducer<T, V>[]): ActionReducer<T, V> {\n return (state: T, action: V): T =>\n reducers.reduce((nextState, reducer) => reducer(nextState, action), state);\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;AAWA,MAAM,yBAAyB,GAAG,CAAC,IAAwB,EAAE,MAAc,KAAc,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC;MACxG,IAAI,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,IAAI,KAAK,GAAG,IAAI,MAAM,CAAC,IAAI,KAAK,IAAI,EAAE,KAAK,CAAC;AAChE,MAAE,MAAM,CAAC,IAAI,KAAK,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Q,EAAE,MAAS,KACzB,QAAQ,CAAC,MAAM,CAAC,CAAC,SAAS,EAAE,OAAO,KAAK,OAAO,CAAC,SAAS,EAAE,MAAM,CAAC,EAAE,KAAK,CAAC,CAAC;AAC/E;;ACdA;;AAEG;;;;"}
|
|
1
|
+
{"version":3,"file":"daffodil-core-state.mjs","sources":["../../../libs/core/state/src/operators/substream.pipe.ts","../../../libs/core/state/src/errors/transform-error-to-state-error.ts","../../../libs/core/state/src/reducers/create-meta.ts","../../../libs/core/state/src/reducers/identity.ts","../../../libs/core/state/src/collection/adapter.class.ts","../../../libs/core/state/src/collection/initial-state.ts","../../../libs/core/state/src/collection/selector-factory.ts","../../../libs/core/state/src/collection/facade.ts","../../../libs/core/state/src/daffodil-core-state.ts"],"sourcesContent":["import { Action } from '@ngrx/store';\nimport { pipe } from 'rxjs';\nimport {\n scan,\n filter,\n} from 'rxjs/operators';\n\nexport type ActionType = Action['type'];\nexport type ActionSequenceStep = ActionType | ActionType[];\nexport type ActionSequence = ActionSequenceStep[];\n\nconst compareActionSequenceStep = (step: ActionSequenceStep, action: Action): boolean => Array.isArray(step)\n ? step.reduce((acc, type) => acc || action.type === type, false)\n : action.type === step;\n\n/**\n * Watches for a particular stream of actions in the specified order and\n * emits a list of those actions once all sequence steps have been matched.\n *\n * This will find the first occurence of the substream and not necessarily the most concise or recent substream.\n * For example, substream([A, B]) encountering an action stream of [A1, A2, B1, B2] will emit [A1, B1].\n * When a substream is found and emitted, the list is reset and it will continue to listen to the action stream.\n *\n * You can indicate that a particular step in the sequence can be matched by mutiple actions by passing an array for that step.\n * For example, if the first step of the sequence could be action A or action B: substream([[A, B], C]).\n * An action stream of [A1, C1] would cause substream to emit [A1, C1].\n * An action stream of [B1, C1] would cause substream to emit [B1, C1].\n * An action stream of [A1, B1, C1] would cause substream to emit [A1, C1].\n *\n * You can optionally pass a list of terminators.\n * If a terminator is encountered in the action stream, any partially matched substream is reset.\n * For example, substream([A, B], C) would not emit anything for an action stream of [A1, C1, B1].\n *\n * @param sequence The sequence of action types that define the substream to listen for.\n * @param terminators A list of terminators, any of which interrupt and reset a partially matched substream.\n */\nexport const substream = (sequence: ActionSequence, ...terminators: ActionType[]) => {\n const isFullMatch = matchedSubstream => matchedSubstream.length === sequence.length;\n const accumulateMatchedSubstream = (matchedSubstream, action) =>\n compareActionSequenceStep(sequence[matchedSubstream.length], action)\n ? [\n ...matchedSubstream,\n action,\n ]\n : matchedSubstream;\n\n return pipe(\n scan<Action, Action[]>((matchedSubstream, action) =>\n terminators.indexOf(action.type) > -1\n // terminator found, reset the list\n ? []\n : accumulateMatchedSubstream(\n // reset the list if fully matched\n isFullMatch(matchedSubstream) ? [] : matchedSubstream,\n action,\n ),\n []),\n filter(isFullMatch),\n );\n};\n","import { DaffError } from '@daffodil/core';\n\nimport { DaffStateError } from './state-error.interface';\n\nexport type ErrorTransformer = (DaffError) => DaffStateError;\n\n/**\n * Transforms an error instance to a state error object.\n */\nexport function daffTransformErrorToStateError({ code, message, recoverable }: DaffError): DaffStateError {\n return { code, message, recoverable };\n}\n","import {\n Action,\n ActionReducer,\n} from '@ngrx/store';\n\n/**\n * Creates and returns a composite reducer that invokes each of the passed reducers in turn.\n */\nexport function daffComposeReducers<\n T,\n V extends Action = Action\n>(reducers: ActionReducer<T, V>[]): ActionReducer<T, V> {\n return (state: T, action: V): T =>\n reducers.reduce((nextState, reducer) => reducer(nextState, action), state);\n}\n","import { Action } from '@ngrx/store';\n\n/**\n * A simple reducer that simply returns the passed state.\n * This is useful for stubbing out parts of state that are not covered in an injected extra reducer map.\n */\nexport const daffIdentityReducer = <T = unknown>(state: T, action: Action): T => state;\n","import { defaultMemoize } from '@ngrx/store';\n\nimport {\n daffCollectionBuildMetadataFromRequest,\n DaffCollectionMetadata,\n DaffCollectionRequest,\n} from '@daffodil/core';\n\n/**\n * Provides an abstracted way to manage a collection state.\n */\nexport class DaffCollectionStateAdapter<T extends DaffCollectionMetadata = DaffCollectionMetadata> {\n /**\n * Stores a collection request in state.\n * This is useful when you want to preemptively reduce a request before waiting for a response.\n */\n storeRequest(request: DaffCollectionRequest, state: T): T {\n return {\n ...state,\n ...daffCollectionBuildMetadataFromRequest(request),\n };\n }\n\n /**\n * Sets the page size.\n */\n setPageSize(size: number, state: T): T {\n return {\n ...state,\n pageSize: size,\n currentPage: 1,\n };\n }\n\n /**\n * Sets the current page.\n */\n setCurrentPage(page: number, state: T): T {\n return {\n ...state,\n currentPage: page,\n };\n }\n\n /**\n * Sets the sorting option and direction.\n */\n setSort(option: string, direction: string, state: T): T {\n return {\n ...state,\n appliedSortOption: option,\n appliedSortDirection: direction,\n };\n }\n\n /**\n * Set the entire collection metadata at once.\n */\n setMetadata(metadata: DaffCollectionMetadata, state: T): T {\n return {\n ...state,\n ids: metadata.ids,\n count: metadata.count,\n currentPage: metadata.currentPage,\n pageSize: metadata.pageSize,\n sortOptions: metadata.sortOptions,\n totalPages: metadata.totalPages,\n appliedSortOption: metadata.appliedSortOption || state.appliedSortOption,\n appliedSortDirection: metadata.appliedSortDirection || state.appliedSortDirection,\n };\n }\n}\n\n/**\n * Create the adapter for the collection state.\n */\nexport const getCollectionStateAdapter: <T extends DaffCollectionMetadata = DaffCollectionMetadata>() => DaffCollectionStateAdapter<T>\n = defaultMemoize(() => new DaffCollectionStateAdapter()).memoized;\n","import { DaffCollectionMetadata } from '@daffodil/core';\n\nexport const daffCollectionReducerInitialState: DaffCollectionMetadata = {\n count: 0,\n appliedSortOption: null,\n appliedSortDirection: null,\n currentPage: null,\n pageSize: null,\n totalPages: null,\n sortOptions: {\n default: null,\n options: [],\n },\n ids: [],\n};\n","import {\n createSelector,\n MemoizedSelector,\n} from '@ngrx/store';\n\nimport {\n DaffCollectionMetadata,\n DaffCollectionRequest,\n} from '@daffodil/core';\n\n/**\n * An interface to describe all selectors related to the collection metadata.\n */\nexport interface DaffCollectionMemoizedSelectors<\n TState,\n TMetadata extends DaffCollectionMetadata = DaffCollectionMetadata\n> {\n /**\n * Selects the metadata for the collection.\n */\n selectCollectionMetadata: MemoizedSelector<TState, TMetadata>;\n /**\n * Builds a request that matches the current collection.\n */\n selectCollectionRequest: MemoizedSelector<TState, DaffCollectionRequest>;\n /**\n * Selects the total number of items of the collection.\n */\n selectCollectionCount: MemoizedSelector<TState, TMetadata['count']>;\n /**\n * Selects the current page of items of the collection.\n */\n selectCollectionCurrentPage: MemoizedSelector<TState, TMetadata['currentPage']>;\n /**\n * Selects the total number of pages of items that exist in the collection.\n */\n selectCollectionTotalPages: MemoizedSelector<TState, TMetadata['totalPages']>;\n /**\n * Selects the number of items on each collection.\n */\n selectCollectionPageSize: MemoizedSelector<TState, TMetadata['pageSize']>;\n /**\n * Selects the sort options that may be applied to the collection.\n */\n selectCollectionSortOptions: MemoizedSelector<TState, TMetadata['sortOptions']['options']>;\n /**\n * Selects the applied sorting option if one is applied.\n */\n selectCollectionAppliedSortOption: MemoizedSelector<TState, TMetadata['appliedSortOption']>;\n /**\n * Selects the applied sorting direction if a sorting option is applied.\n */\n selectCollectionAppliedSortDirection: MemoizedSelector<TState, TMetadata['appliedSortDirection']>;\n /**\n * Selects the applied sorting direction if a sorting option is applied.\n */\n selectCollectionIds: MemoizedSelector<TState, TMetadata['ids']>;\n}\n\n/**\n * Creates collection selectors.\n *\n * @param selectCollectionState A selector for the particular collection state upon which the returned selectors should operate.\n */\nexport const daffCollectionSelectorFactory = <\n TState,\n TMetadata extends DaffCollectionMetadata = DaffCollectionMetadata\n>(\n selectCollectionState: MemoizedSelector<TState, TMetadata>,\n): DaffCollectionMemoizedSelectors<TState, TMetadata> => {\n\n const selectCollectionMetadata = createSelector(\n selectCollectionState,\n state => state,\n );\n\n const selectCollectionRequest = createSelector(\n selectCollectionMetadata,\n metadata => ({\n appliedSortOption: metadata.appliedSortOption,\n appliedSortDirection: metadata.appliedSortDirection,\n currentPage: metadata.currentPage,\n pageSize: metadata.pageSize,\n }),\n );\n\n const selectCollectionCount = createSelector(\n selectCollectionMetadata,\n state => state.count,\n );\n\n const selectCollectionCurrentPage = createSelector(\n selectCollectionMetadata,\n state => state.currentPage,\n );\n\n const selectCollectionTotalPages = createSelector(\n selectCollectionMetadata,\n state => state.totalPages,\n );\n\n const selectCollectionPageSize = createSelector(\n selectCollectionMetadata,\n state => state.pageSize,\n );\n\n const selectCollectionSortOptions = createSelector(\n selectCollectionMetadata,\n state => state.sortOptions.options,\n );\n\n const selectCollectionAppliedSortOption = createSelector(\n selectCollectionMetadata,\n state => state.appliedSortOption,\n );\n\n const selectCollectionAppliedSortDirection = createSelector(\n selectCollectionMetadata,\n state => state.appliedSortDirection,\n );\n\n const selectCollectionIds = createSelector(\n selectCollectionMetadata,\n state => state.ids,\n );\n\n return {\n selectCollectionMetadata,\n selectCollectionRequest,\n selectCollectionCount,\n selectCollectionCurrentPage,\n selectCollectionTotalPages,\n selectCollectionPageSize,\n selectCollectionSortOptions,\n selectCollectionAppliedSortOption,\n selectCollectionAppliedSortDirection,\n selectCollectionIds,\n };\n};\n","import {\n Store,\n select,\n Action,\n} from '@ngrx/store';\nimport { Observable } from 'rxjs';\n\nimport {\n DaffCollectionMetadata,\n DaffCollectionRequest,\n DaffSortDirectionEnum,\n DaffSortOption,\n} from '@daffodil/core';\n\nimport { DaffCollectionFacadeInterface } from './facade.interface';\nimport { DaffCollectionMemoizedSelectors } from './selector-factory';\n\n/**\n * An abstract class for a collection facade.\n * It is configurable via its constructor parameters.\n * The particular collection state from which\n * this facade will read is determined by the selectors passed.\n *\n * @inheritdoc\n */\nexport abstract class DaffCollectionFacade<\n TState,\n TMetadata extends DaffCollectionMetadata = DaffCollectionMetadata\n> implements DaffCollectionFacadeInterface<TMetadata> {\n metadata$: Observable<TMetadata>;\n request$: Observable<DaffCollectionRequest>;\n count$: Observable<number>;\n currentPage$: Observable<number>;\n totalPages$: Observable<number>;\n pageSize$: Observable<number>;\n sortOptions$: Observable<DaffSortOption[]>;\n appliedSortOption$: Observable<string>;\n appliedSortDirection$: Observable<DaffSortDirectionEnum>;\n\n constructor(\n protected store: Store<TState>,\n selectors: DaffCollectionMemoizedSelectors<TState, TMetadata>,\n ) {\n\t this.metadata$ = this.store.pipe(select(selectors.selectCollectionMetadata));\n\t this.request$ = this.store.pipe(select(selectors.selectCollectionRequest));\n\t this.count$ = this.store.pipe(select(selectors.selectCollectionCount));\n\t this.currentPage$ = this.store.pipe(select(selectors.selectCollectionCurrentPage));\n\t this.totalPages$ = this.store.pipe(select(selectors.selectCollectionTotalPages));\n\t this.pageSize$ = this.store.pipe(select(selectors.selectCollectionPageSize));\n\t this.sortOptions$ = this.store.pipe(select(selectors.selectCollectionSortOptions));\n\t this.appliedSortOption$ = this.store.pipe(select(selectors.selectCollectionAppliedSortOption));\n\t this.appliedSortDirection$ = this.store.pipe(select(selectors.selectCollectionAppliedSortDirection));\n }\n\n /**\n * Dispatches the given action.\n *\n * @param action action to dispatch.\n */\n dispatch(action: Action) {\n\t this.store.dispatch(action);\n }\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;AAWA,MAAM,yBAAyB,GAAG,CAAC,IAAwB,EAAE,MAAc,KAAc,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC;MACxG,IAAI,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,IAAI,KAAK,GAAG,IAAI,MAAM,CAAC,IAAI,KAAK,IAAI,EAAE,KAAK,CAAC;AAChE,MAAE,MAAM,CAAC,IAAI,KAAK,IAAI,CAAC;AAEzB;;;;;;;;;;;;;;;;;;;;AAoBG;AACU,MAAA,SAAS,GAAG,CAAC,QAAwB,EAAE,GAAG,WAAyB,KAAI;AAClF,IAAA,MAAM,WAAW,GAAG,gBAAgB,IAAI,gBAAgB,CAAC,MAAM,KAAK,QAAQ,CAAC,MAAM,CAAC;AACpF,IAAA,MAAM,0BAA0B,GAAG,CAAC,gBAAgB,EAAE,MAAM,KAC1D,yBAAyB,CAAC,QAAQ,CAAC,gBAAgB,CAAC,MAAM,CAAC,EAAE,MAAM,C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AC,MAAM,CAAC,SAAS,CAAC,wBAAwB,CAAC,CAAC,CAAC;AAC7E,QAAA,IAAI,CAAC,YAAY,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,2BAA2B,CAAC,CAAC,CAAC;AACnF,QAAA,IAAI,CAAC,kBAAkB,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,iCAAiC,CAAC,CAAC,CAAC;AAC/F,QAAA,IAAI,CAAC,qBAAqB,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,oCAAoC,CAAC,CAAC,CAAC;KACrG;AAED;;;;AAIG;AACH,IAAA,QAAQ,CAAC,MAAc,EAAA;AACtB,QAAA,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;KAC5B;AACF;;AC9DD;;AAEG;;;;"}
|
|
@@ -1,7 +1,38 @@
|
|
|
1
1
|
import * as i0 from '@angular/core';
|
|
2
|
-
import {
|
|
2
|
+
import { Pipe, NgModule, Injectable } from '@angular/core';
|
|
3
|
+
import { range, DaffSortDirectionEnum, daffIdentifiableArrayToDict } from '@daffodil/core';
|
|
3
4
|
import * as faker from '@faker-js/faker/locale/en_US';
|
|
4
|
-
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* @docs
|
|
8
|
+
* A mock CurrencyPipe that does nothing to a given input.
|
|
9
|
+
* This pipe is useful for asserting that a CurrencyPipe is in use via a spy,
|
|
10
|
+
* but ignoring the actual underlying implementation
|
|
11
|
+
*/
|
|
12
|
+
class DaffMockCurrencyPipe {
|
|
13
|
+
transform(value) { }
|
|
14
|
+
;
|
|
15
|
+
}
|
|
16
|
+
/** @nocollapse */ /** @nocollapse */ DaffMockCurrencyPipe.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.0", ngImport: i0, type: DaffMockCurrencyPipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe });
|
|
17
|
+
/** @nocollapse */ /** @nocollapse */ DaffMockCurrencyPipe.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "12.0.0", version: "13.3.0", ngImport: i0, type: DaffMockCurrencyPipe, name: "currency" });
|
|
18
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.0", ngImport: i0, type: DaffMockCurrencyPipe, decorators: [{
|
|
19
|
+
type: Pipe,
|
|
20
|
+
args: [{ name: 'currency' }]
|
|
21
|
+
}] });
|
|
22
|
+
|
|
23
|
+
class DaffCoreTestingModule {
|
|
24
|
+
}
|
|
25
|
+
/** @nocollapse */ /** @nocollapse */ DaffCoreTestingModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.0", ngImport: i0, type: DaffCoreTestingModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
|
26
|
+
/** @nocollapse */ /** @nocollapse */ DaffCoreTestingModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "13.3.0", ngImport: i0, type: DaffCoreTestingModule, declarations: [DaffMockCurrencyPipe] });
|
|
27
|
+
/** @nocollapse */ /** @nocollapse */ DaffCoreTestingModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "13.3.0", ngImport: i0, type: DaffCoreTestingModule });
|
|
28
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.0", ngImport: i0, type: DaffCoreTestingModule, decorators: [{
|
|
29
|
+
type: NgModule,
|
|
30
|
+
args: [{
|
|
31
|
+
declarations: [
|
|
32
|
+
DaffMockCurrencyPipe,
|
|
33
|
+
],
|
|
34
|
+
}]
|
|
35
|
+
}] });
|
|
5
36
|
|
|
6
37
|
/**
|
|
7
38
|
* The base class for model factories.
|
|
@@ -87,42 +118,187 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.0", ngImpor
|
|
|
87
118
|
}]
|
|
88
119
|
}], ctorParameters: function () { return []; } });
|
|
89
120
|
|
|
121
|
+
class MockDaffNumericallyPaginable {
|
|
122
|
+
constructor() {
|
|
123
|
+
this.totalPages = faker.datatype.number({ min: 1, max: 100 });
|
|
124
|
+
this.currentPage = faker.datatype.number(this.totalPages);
|
|
125
|
+
this.pageSize = faker.datatype.number({ min: 1, max: 100 });
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
class DaffNumericallyPaginableFactory extends DaffModelFactory {
|
|
129
|
+
constructor() {
|
|
130
|
+
super(MockDaffNumericallyPaginable);
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
/** @nocollapse */ /** @nocollapse */ DaffNumericallyPaginableFactory.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.0", ngImport: i0, type: DaffNumericallyPaginableFactory, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
134
|
+
/** @nocollapse */ /** @nocollapse */ DaffNumericallyPaginableFactory.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.3.0", ngImport: i0, type: DaffNumericallyPaginableFactory, providedIn: 'root' });
|
|
135
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.0", ngImport: i0, type: DaffNumericallyPaginableFactory, decorators: [{
|
|
136
|
+
type: Injectable,
|
|
137
|
+
args: [{
|
|
138
|
+
providedIn: 'root',
|
|
139
|
+
}]
|
|
140
|
+
}], ctorParameters: function () { return []; } });
|
|
141
|
+
|
|
142
|
+
class MockDaffSortOption {
|
|
143
|
+
constructor() {
|
|
144
|
+
this.label = faker.random.word();
|
|
145
|
+
this.value = faker.random.word();
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
class DaffSortOptionFactory extends DaffModelFactory {
|
|
149
|
+
constructor() {
|
|
150
|
+
super(MockDaffSortOption);
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
/** @nocollapse */ /** @nocollapse */ DaffSortOptionFactory.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.0", ngImport: i0, type: DaffSortOptionFactory, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
154
|
+
/** @nocollapse */ /** @nocollapse */ DaffSortOptionFactory.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.3.0", ngImport: i0, type: DaffSortOptionFactory, providedIn: 'root' });
|
|
155
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.0", ngImport: i0, type: DaffSortOptionFactory, decorators: [{
|
|
156
|
+
type: Injectable,
|
|
157
|
+
args: [{
|
|
158
|
+
providedIn: 'root',
|
|
159
|
+
}]
|
|
160
|
+
}], ctorParameters: function () { return []; } });
|
|
161
|
+
|
|
162
|
+
class MockDaffSortOptions {
|
|
163
|
+
constructor(optionFactory) {
|
|
164
|
+
this.optionFactory = optionFactory;
|
|
165
|
+
this.options = this.createOptions();
|
|
166
|
+
this.default = faker.random.arrayElement(this.options).value;
|
|
167
|
+
}
|
|
168
|
+
createOptions() {
|
|
169
|
+
return this.optionFactory.createMany(faker.random.number({ min: 1, max: 5 }));
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
class DaffSortOptionsFactory extends DaffModelFactory {
|
|
173
|
+
constructor(optionFactory) {
|
|
174
|
+
super(MockDaffSortOptions, optionFactory);
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
/** @nocollapse */ /** @nocollapse */ DaffSortOptionsFactory.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.0", ngImport: i0, type: DaffSortOptionsFactory, deps: [{ token: DaffSortOptionFactory }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
178
|
+
/** @nocollapse */ /** @nocollapse */ DaffSortOptionsFactory.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.3.0", ngImport: i0, type: DaffSortOptionsFactory, providedIn: 'root' });
|
|
179
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.0", ngImport: i0, type: DaffSortOptionsFactory, decorators: [{
|
|
180
|
+
type: Injectable,
|
|
181
|
+
args: [{
|
|
182
|
+
providedIn: 'root',
|
|
183
|
+
}]
|
|
184
|
+
}], ctorParameters: function () { return [{ type: DaffSortOptionFactory }]; } });
|
|
185
|
+
|
|
186
|
+
class MockDaffSortable {
|
|
187
|
+
constructor(optionFactory) {
|
|
188
|
+
this.optionFactory = optionFactory;
|
|
189
|
+
this.sortOptions = this.createOptions();
|
|
190
|
+
this.appliedSortOption = faker.random.arrayElement(this.sortOptions.options).value;
|
|
191
|
+
this.appliedSortDirection = faker.random.arrayElement([DaffSortDirectionEnum.Ascending, DaffSortDirectionEnum.Descending]);
|
|
192
|
+
}
|
|
193
|
+
createOptions() {
|
|
194
|
+
return this.optionFactory.create();
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
class DaffSortableFactory extends DaffModelFactory {
|
|
198
|
+
constructor(optionFactory) {
|
|
199
|
+
super(MockDaffSortable, optionFactory);
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
/** @nocollapse */ /** @nocollapse */ DaffSortableFactory.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.0", ngImport: i0, type: DaffSortableFactory, deps: [{ token: DaffSortOptionsFactory }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
203
|
+
/** @nocollapse */ /** @nocollapse */ DaffSortableFactory.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.3.0", ngImport: i0, type: DaffSortableFactory, providedIn: 'root' });
|
|
204
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.0", ngImport: i0, type: DaffSortableFactory, decorators: [{
|
|
205
|
+
type: Injectable,
|
|
206
|
+
args: [{
|
|
207
|
+
providedIn: 'root',
|
|
208
|
+
}]
|
|
209
|
+
}], ctorParameters: function () { return [{ type: DaffSortOptionsFactory }]; } });
|
|
210
|
+
|
|
90
211
|
/**
|
|
91
|
-
* @
|
|
92
|
-
* A mock CurrencyPipe that does nothing to a given input.
|
|
93
|
-
* This pipe is useful for asserting that a CurrencyPipe is in use via a spy,
|
|
94
|
-
* but ignoring the actual underlying implementation
|
|
212
|
+
* Mocked {@link DaffCollectionMetadata} object.
|
|
95
213
|
*/
|
|
96
|
-
class
|
|
97
|
-
|
|
98
|
-
|
|
214
|
+
class MockCollectionMetadata {
|
|
215
|
+
constructor(pageInfoFactory, sortFieldsFactory) {
|
|
216
|
+
const _pageInfo = pageInfoFactory.create();
|
|
217
|
+
const _sortFields = sortFieldsFactory.create();
|
|
218
|
+
this.count = faker.datatype.number({ min: 1, max: 1000 });
|
|
219
|
+
this.ids = new Array(this.count).fill(null).map(() => faker.datatype.uuid());
|
|
220
|
+
this.currentPage = _pageInfo.currentPage;
|
|
221
|
+
this.totalPages = _pageInfo.totalPages;
|
|
222
|
+
this.pageSize = _pageInfo.pageSize;
|
|
223
|
+
this.appliedSortDirection = _sortFields.appliedSortDirection;
|
|
224
|
+
this.appliedSortOption = _sortFields.appliedSortOption;
|
|
225
|
+
this.sortOptions = _sortFields.sortOptions;
|
|
226
|
+
}
|
|
99
227
|
}
|
|
100
|
-
/**
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
228
|
+
/**
|
|
229
|
+
* Factory for creating {@link DaffCollectionMetadata}s.
|
|
230
|
+
*/
|
|
231
|
+
class DaffCollectionMetadataFactory extends DaffModelFactory {
|
|
232
|
+
constructor(pageInfoFactory, sortFieldsFactory) {
|
|
233
|
+
super(MockCollectionMetadata, pageInfoFactory, sortFieldsFactory);
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
/** @nocollapse */ /** @nocollapse */ DaffCollectionMetadataFactory.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.0", ngImport: i0, type: DaffCollectionMetadataFactory, deps: [{ token: DaffNumericallyPaginableFactory }, { token: DaffSortableFactory }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
237
|
+
/** @nocollapse */ /** @nocollapse */ DaffCollectionMetadataFactory.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.3.0", ngImport: i0, type: DaffCollectionMetadataFactory, providedIn: 'root' });
|
|
238
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.0", ngImport: i0, type: DaffCollectionMetadataFactory, decorators: [{
|
|
239
|
+
type: Injectable,
|
|
240
|
+
args: [{
|
|
241
|
+
providedIn: 'root',
|
|
242
|
+
}]
|
|
243
|
+
}], ctorParameters: function () { return [{ type: DaffNumericallyPaginableFactory }, { type: DaffSortableFactory }]; } });
|
|
106
244
|
|
|
107
|
-
|
|
245
|
+
/**
|
|
246
|
+
* Mocked {@link DaffCollectionRequest} object.
|
|
247
|
+
*/
|
|
248
|
+
class MockCollectionRequest {
|
|
249
|
+
constructor() {
|
|
250
|
+
this.currentPage = faker.datatype.number({ min: 1, max: 100 });
|
|
251
|
+
this.appliedSortDirection = faker.random.arrayElement([DaffSortDirectionEnum.Ascending, DaffSortDirectionEnum.Descending]);
|
|
252
|
+
this.pageSize = faker.datatype.number({ min: 1, max: 100 });
|
|
253
|
+
this.appliedSortOption = faker.random.word();
|
|
254
|
+
}
|
|
108
255
|
}
|
|
109
|
-
/**
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
256
|
+
/**
|
|
257
|
+
* Factory for creating {@link DaffCollectionRequest}s.
|
|
258
|
+
*/
|
|
259
|
+
class DaffCollectionRequestFactory extends DaffModelFactory {
|
|
260
|
+
constructor() {
|
|
261
|
+
super(MockCollectionRequest);
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
/** @nocollapse */ /** @nocollapse */ DaffCollectionRequestFactory.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.0", ngImport: i0, type: DaffCollectionRequestFactory, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
265
|
+
/** @nocollapse */ /** @nocollapse */ DaffCollectionRequestFactory.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.3.0", ngImport: i0, type: DaffCollectionRequestFactory, providedIn: 'root' });
|
|
266
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.0", ngImport: i0, type: DaffCollectionRequestFactory, decorators: [{
|
|
267
|
+
type: Injectable,
|
|
114
268
|
args: [{
|
|
115
|
-
|
|
116
|
-
DaffMockCurrencyPipe,
|
|
117
|
-
],
|
|
269
|
+
providedIn: 'root',
|
|
118
270
|
}]
|
|
119
|
-
}] });
|
|
271
|
+
}], ctorParameters: function () { return []; } });
|
|
272
|
+
|
|
273
|
+
/**
|
|
274
|
+
* Mocked {@link DaffCollection} object.
|
|
275
|
+
*
|
|
276
|
+
* It should be customized by passing the factory for the contained entity as the first constructor argument.
|
|
277
|
+
*/
|
|
278
|
+
class MockCollection {
|
|
279
|
+
constructor(itemFactory, metadataFactory) {
|
|
280
|
+
this.itemFactory = itemFactory;
|
|
281
|
+
this.metadataFactory = metadataFactory;
|
|
282
|
+
this._items = this.createItems();
|
|
283
|
+
this.metadata = this.createMetadata();
|
|
284
|
+
this.data = daffIdentifiableArrayToDict(this._items);
|
|
285
|
+
}
|
|
286
|
+
createItems() {
|
|
287
|
+
return this.itemFactory.createMany();
|
|
288
|
+
}
|
|
289
|
+
createMetadata() {
|
|
290
|
+
return this.metadataFactory.create({
|
|
291
|
+
ids: this._items.map(({ id }) => id),
|
|
292
|
+
count: this._items.length,
|
|
293
|
+
});
|
|
294
|
+
}
|
|
295
|
+
}
|
|
120
296
|
|
|
121
|
-
|
|
297
|
+
//@angular/core
|
|
122
298
|
|
|
123
299
|
/**
|
|
124
300
|
* Generated bundle index. Do not edit.
|
|
125
301
|
*/
|
|
126
302
|
|
|
127
|
-
export { DaffAddressFactory, DaffCoreTestingModule, DaffMockCurrencyPipe, DaffModelFactory };
|
|
303
|
+
export { DaffAddressFactory, DaffCollectionMetadataFactory, DaffCollectionRequestFactory, DaffCoreTestingModule, DaffMockCurrencyPipe, DaffModelFactory, DaffNumericallyPaginableFactory, DaffSortOptionFactory, DaffSortOptionsFactory, DaffSortableFactory, MockCollection, MockCollectionMetadata, MockCollectionRequest, MockDaffAddress };
|
|
128
304
|
//# sourceMappingURL=daffodil-core-testing.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"daffodil-core-testing.mjs","sources":["../../../libs/core/testing/src/factories/factory.ts","../../../libs/core/testing/src/address/factories/address.factory.ts","../../../libs/core/testing/src/angular/mocks/pipes/currency.ts","../../../libs/core/testing/src/testing.module.ts","../../../libs/core/testing/src/index.ts","../../../libs/core/testing/src/daffodil-core-testing.ts"],"sourcesContent":["import {\n range,\n Constructable,\n} from '@daffodil/core';\n\nimport { IDaffModelFactory } from './factory.interface';\n\n/**\n * The base class for model factories.\n *\n * The mock class is passed as the first constructor arg\n * and any additional args are passed to the mock class constructor.\n *\n * The constructor args can be omitted if the `create` method is overridden.\n *\n * The following example demonstrates using this feature to inject\n * a different factory into a mock class.\n *\n * ```ts\n * class MyMockModel {\n * constructor(\n * private otherFactory: MyOtherFactory\n * ) {}\n *\n * private createOtherModel() {\n * return this.otherFactory.create()\n * }\n *\n * otherModel = this.createOtherModel()\n * }\n *\n * @Injectable()\n * class TestFactory extends DaffModelFactory<MyMockModel> {\n * constructor(\n * otherFactory: MyOtherFactory\n * ) {\n * super(MyMockModel, otherFactory)\n * }\n * }\n * ```\n */\nexport abstract class DaffModelFactory<T extends Record<string, any>> implements IDaffModelFactory<T> {\n _instantiationArgs: ConstructorParameters<Constructable<T>>;\n\n constructor(\n public type?: Constructable<T>,\n ...args: ConstructorParameters<Constructable<T>>\n ) {\n this._instantiationArgs = args;\n }\n\n create(partial = {}): T {\n if (!this.type) {\n throw new Error('`type` is required if `create` is not overriden.');\n }\n return {\n ...new this.type(...this._instantiationArgs),\n ...partial,\n };\n }\n\n createMany(qty = 1, partial = {}): T[] {\n return range(0, qty - 1).map(() => this.create(partial));\n }\n}\n","import { Injectable } from '@angular/core';\nimport * as faker from '@faker-js/faker/locale/en_US';\n\nimport { DaffAddress } from '@daffodil/core';\n\nimport { DaffModelFactory } from '../../factories/factory';\n\n/**\n * @deprecated\n * Prefer the `MockDaffAddress` of daffodil/geography/testing`\n */\nexport class MockDaffAddress implements DaffAddress {\n firstname = faker.name.firstName();\n lastname = faker.name.lastName();\n street = faker.address.streetName();\n city = faker.address.city();\n state = faker.address.stateAbbr();\n email = faker.internet.email();\n postcode = faker.address.zipCode();\n telephone = faker.phone.phoneNumber();\n}\n\n/**\n * @deprecated\n * Prefer the `DaffAddressFactory` of `daffodil/geography/testing`\n */\n@Injectable({\n providedIn: 'root',\n})\nexport class DaffAddressFactory extends DaffModelFactory<DaffAddress>{\n constructor(){\n super(MockDaffAddress);\n }\n}\n","import {\n Pipe,\n PipeTransform,\n} from '@angular/core';\n\n/**\n * @docs\n * A mock CurrencyPipe that does nothing to a given input.\n * This pipe is useful for asserting that a CurrencyPipe is in use via a spy,\n * but ignoring the actual underlying implementation\n */\n@Pipe({ name: 'currency' })\nexport class DaffMockCurrencyPipe implements PipeTransform {\n transform(value: number) {};\n}\n","import { NgModule } from '@angular/core';\n\nimport { DaffMockCurrencyPipe } from './angular/mocks/pipes/currency';\n\n@NgModule({\n declarations: [\n DaffMockCurrencyPipe,\n ],\n})\nexport class DaffCoreTestingModule {}\n","// Address\nexport { DaffAddressFactory } from './address/factories/address.factory';\n\n//@angular/core\nexport { DaffMockCurrencyPipe } from './angular/mocks/pipes/currency';\nexport { DaffInMemoryDataServiceInterface } from './angular/interfaces/in-memory-data-service.interface';\n\n//Core\nexport { DaffCoreTestingModule } from './testing.module';\nexport { DaffModelFactory } from './factories/factory';\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],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CAAA,CAAA;AAArB,sCAAA,qBAAA,CAAA,IAAA,GAAA,EAAA,CAAA,mBAAA,CAAA,EAAA,UAAA,EAAA,QAAA,EAAA,OAAA,EAAA,QAAA,EAAA,QAAA,EAAA,EAAA,EAAA,IAAA,EAAA,qBAAqB,iBAH9B,oBAAoB,CAAA,EAAA,CAAA,CAAA;yJAGX,qBAAqB,EAAA,CAAA,CAAA;2FAArB,qBAAqB,EAAA,UAAA,EAAA,CAAA;kBALjC,QAAQ;AAAC,YAAA,IAAA,EAAA,CAAA;AACR,oBAAA,YAAY,EAAE;wBACZ,oBAAoB;AACrB,qBAAA;iBACF,CAAA;;;ACRD;;ACAA;;AAEG;;;;"}
|
|
1
|
+
{"version":3,"file":"daffodil-core-testing.mjs","sources":["../../../libs/core/testing/src/angular/mocks/pipes/currency.ts","../../../libs/core/testing/src/testing.module.ts","../../../libs/core/testing/src/factories/factory.ts","../../../libs/core/testing/src/factories/address.factory.ts","../../../libs/core/testing/src/factories/collection/numerically-paginable.factory.ts","../../../libs/core/testing/src/factories/collection/sort-option.factory.ts","../../../libs/core/testing/src/factories/collection/sort-options.factory.ts","../../../libs/core/testing/src/factories/collection/sortable.factory.ts","../../../libs/core/testing/src/factories/collection/metadata.factory.ts","../../../libs/core/testing/src/factories/collection/request.factory.ts","../../../libs/core/testing/src/factories/collection/mock-collection.class.ts","../../../libs/core/testing/src/public_api.ts","../../../libs/core/testing/src/daffodil-core-testing.ts"],"sourcesContent":["import {\n Pipe,\n PipeTransform,\n} from '@angular/core';\n\n/**\n * @docs\n * A mock CurrencyPipe that does nothing to a given input.\n * This pipe is useful for asserting that a CurrencyPipe is in use via a spy,\n * but ignoring the actual underlying implementation\n */\n@Pipe({ name: 'currency' })\nexport class DaffMockCurrencyPipe implements PipeTransform {\n transform(value: number) {};\n}\n","import { NgModule } from '@angular/core';\n\nimport { DaffMockCurrencyPipe } from './angular/mocks/pipes/currency';\n\n@NgModule({\n declarations: [\n DaffMockCurrencyPipe,\n ],\n})\nexport class DaffCoreTestingModule {}\n","import {\n range,\n Constructable,\n} from '@daffodil/core';\n\nimport { IDaffModelFactory } from './factory.interface';\n\n/**\n * The base class for model factories.\n *\n * The mock class is passed as the first constructor arg\n * and any additional args are passed to the mock class constructor.\n *\n * The constructor args can be omitted if the `create` method is overridden.\n *\n * The following example demonstrates using this feature to inject\n * a different factory into a mock class.\n *\n * ```ts\n * class MyMockModel {\n * constructor(\n * private otherFactory: MyOtherFactory\n * ) {}\n *\n * private createOtherModel() {\n * return this.otherFactory.create()\n * }\n *\n * otherModel = this.createOtherModel()\n * }\n *\n * @Injectable()\n * class TestFactory extends DaffModelFactory<MyMockModel> {\n * constructor(\n * otherFactory: MyOtherFactory\n * ) {\n * super(MyMockModel, otherFactory)\n * }\n * }\n * ```\n */\nexport abstract class DaffModelFactory<T extends Record<string, any>> implements IDaffModelFactory<T> {\n _instantiationArgs: ConstructorParameters<Constructable<T>>;\n\n constructor(\n public type?: Constructable<T>,\n ...args: ConstructorParameters<Constructable<T>>\n ) {\n this._instantiationArgs = args;\n }\n\n create(partial = {}): T {\n if (!this.type) {\n throw new Error('`type` is required if `create` is not overriden.');\n }\n return {\n ...new this.type(...this._instantiationArgs),\n ...partial,\n };\n }\n\n createMany(qty = 1, partial = {}): T[] {\n return range(0, qty - 1).map(() => this.create(partial));\n }\n}\n","import { Injectable } from '@angular/core';\nimport * as faker from '@faker-js/faker/locale/en_US';\n\nimport { DaffAddress } from '@daffodil/core';\n\nimport { DaffModelFactory } from './factory';\n\n/**\n * @deprecated\n * Prefer the `MockDaffAddress` of daffodil/geography/testing`\n */\nexport class MockDaffAddress implements DaffAddress {\n firstname = faker.name.firstName();\n lastname = faker.name.lastName();\n street = faker.address.streetName();\n city = faker.address.city();\n state = faker.address.stateAbbr();\n email = faker.internet.email();\n postcode = faker.address.zipCode();\n telephone = faker.phone.phoneNumber();\n}\n\n/**\n * @deprecated\n * Prefer the `DaffAddressFactory` of `daffodil/geography/testing`\n */\n@Injectable({\n providedIn: 'root',\n})\nexport class DaffAddressFactory extends DaffModelFactory<DaffAddress>{\n constructor(){\n super(MockDaffAddress);\n }\n}\n","import { Injectable } from '@angular/core';\nimport * as faker from '@faker-js/faker/locale/en_US';\n\nimport { DaffNumericallyPaginable } from '@daffodil/core';\n\nimport { DaffModelFactory } from '../factory';\n\nclass MockDaffNumericallyPaginable implements DaffNumericallyPaginable {\n totalPages = faker.datatype.number({ min: 1, max: 100 });\n currentPage = faker.datatype.number(this.totalPages);\n pageSize = faker.datatype.number({ min: 1, max: 100 });\n}\n\n@Injectable({\n providedIn: 'root',\n})\nexport class DaffNumericallyPaginableFactory extends DaffModelFactory<DaffNumericallyPaginable> {\n constructor(){\n super(MockDaffNumericallyPaginable);\n }\n}\n","import { Injectable } from '@angular/core';\nimport * as faker from '@faker-js/faker/locale/en_US';\n\nimport { DaffSortOption } from '@daffodil/core';\n\nimport { DaffModelFactory } from '../factory';\n\nclass MockDaffSortOption implements DaffSortOption {\n label = faker.random.word();\n value = faker.random.word();\n}\n\n@Injectable({\n providedIn: 'root',\n})\nexport class DaffSortOptionFactory extends DaffModelFactory<DaffSortOption> {\n constructor() {\n super(MockDaffSortOption);\n }\n}\n","import { Injectable } from '@angular/core';\nimport * as faker from '@faker-js/faker/locale/en_US';\n\nimport {\n DaffSortOption,\n DaffSortOptions,\n} from '@daffodil/core';\n\nimport { DaffModelFactory } from '../factory';\nimport { DaffSortOptionFactory } from './sort-option.factory';\n\nclass MockDaffSortOptions implements DaffSortOptions {\n options = this.createOptions();\n default = faker.random.arrayElement(this.options).value;\n\n constructor(\n private optionFactory: DaffSortOptionFactory,\n ) {}\n\n private createOptions(): DaffSortOption[] {\n return this.optionFactory.createMany(faker.random.number({ min: 1, max: 5 }));\n }\n}\n\n@Injectable({\n providedIn: 'root',\n})\nexport class DaffSortOptionsFactory extends DaffModelFactory<DaffSortOptions> {\n constructor(\n optionFactory: DaffSortOptionFactory,\n ) {\n super(MockDaffSortOptions, optionFactory);\n }\n}\n","import { Injectable } from '@angular/core';\nimport * as faker from '@faker-js/faker/locale/en_US';\n\nimport {\n DaffSortable,\n DaffSortDirectionEnum,\n DaffSortOptions,\n} from '@daffodil/core';\n\nimport { DaffModelFactory } from '../factory';\nimport { DaffSortOptionsFactory } from './sort-options.factory';\n\nclass MockDaffSortable implements DaffSortable {\n sortOptions = this.createOptions();\n appliedSortOption = faker.random.arrayElement(this.sortOptions.options).value;\n appliedSortDirection = faker.random.arrayElement([DaffSortDirectionEnum.Ascending, DaffSortDirectionEnum.Descending]);\n\n constructor(\n private optionFactory: DaffSortOptionsFactory,\n ) {}\n\n private createOptions(): DaffSortOptions {\n return this.optionFactory.create();\n }\n}\n\n@Injectable({\n providedIn: 'root',\n})\nexport class DaffSortableFactory extends DaffModelFactory<DaffSortable> {\n constructor(\n optionFactory: DaffSortOptionsFactory,\n ) {\n super(MockDaffSortable, optionFactory);\n }\n}\n","import { Injectable } from '@angular/core';\nimport * as faker from '@faker-js/faker/locale/en_US';\n\nimport {\n DaffCollectionMetadata,\n DaffIdentifiable,\n DaffNumericallyPaginable,\n DaffSortable,\n DaffSortDirectionEnum,\n DaffSortOption,\n DaffSortOptions,\n} from '@daffodil/core';\n\nimport { DaffModelFactory } from '../factory';\nimport { DaffNumericallyPaginableFactory } from './numerically-paginable.factory';\nimport { DaffSortableFactory } from './sortable.factory';\n\n/**\n * Mocked {@link DaffCollectionMetadata} object.\n */\nexport class MockCollectionMetadata implements DaffCollectionMetadata {\n currentPage: number;\n totalPages: number;\n pageSize: number;\n sortOptions: DaffSortOptions;\n appliedSortOption: DaffSortOption['value'];\n appliedSortDirection: DaffSortDirectionEnum;\n count: number;\n ids: DaffIdentifiable['id'][];\n\n constructor(\n pageInfoFactory: DaffNumericallyPaginableFactory,\n sortFieldsFactory: DaffSortableFactory,\n ) {\n const _pageInfo = pageInfoFactory.create();\n const _sortFields = sortFieldsFactory.create();\n\n this.count = faker.datatype.number({ min: 1, max: 1000 });\n this.ids = new Array(this.count).fill(null).map<string>(() => faker.datatype.uuid());\n\n this.currentPage = _pageInfo.currentPage;\n this.totalPages = _pageInfo.totalPages;\n this.pageSize = _pageInfo.pageSize;\n\n this.appliedSortDirection = _sortFields.appliedSortDirection;\n this.appliedSortOption = _sortFields.appliedSortOption;\n this.sortOptions = _sortFields.sortOptions;\n }\n}\n\n/**\n * Factory for creating {@link DaffCollectionMetadata}s.\n */\n@Injectable({\n providedIn: 'root',\n})\nexport class DaffCollectionMetadataFactory extends DaffModelFactory<DaffCollectionMetadata> {\n constructor(\n pageInfoFactory: DaffNumericallyPaginableFactory,\n sortFieldsFactory: DaffSortableFactory,\n ) {\n super(MockCollectionMetadata, pageInfoFactory, sortFieldsFactory);\n }\n}\n","import { Injectable } from '@angular/core';\nimport * as faker from '@faker-js/faker/locale/en_US';\n\nimport {\n DaffCollectionRequest,\n DaffSortDirectionEnum,\n} from '@daffodil/core';\n\nimport { DaffModelFactory } from '../factory';\n\n/**\n * Mocked {@link DaffCollectionRequest} object.\n */\nexport class MockCollectionRequest implements DaffCollectionRequest {\n currentPage = faker.datatype.number({ min: 1, max: 100 });\n appliedSortDirection = faker.random.arrayElement([DaffSortDirectionEnum.Ascending, DaffSortDirectionEnum.Descending]);\n pageSize = faker.datatype.number({ min: 1, max: 100 });\n appliedSortOption = faker.random.word();\n}\n\n/**\n * Factory for creating {@link DaffCollectionRequest}s.\n */\n@Injectable({\n providedIn: 'root',\n})\nexport class DaffCollectionRequestFactory extends DaffModelFactory<DaffCollectionRequest> {\n constructor() {\n super(MockCollectionRequest);\n }\n}\n","import {\n daffIdentifiableArrayToDict,\n DaffCollection,\n DaffCollectionMetadata,\n DaffIdentifiable,\n} from '@daffodil/core';\n\nimport { DaffModelFactory } from '../factory';\nimport { DaffCollectionMetadataFactory } from './metadata.factory';\n\n/**\n * Mocked {@link DaffCollection} object.\n *\n * It should be customized by passing the factory for the contained entity as the first constructor argument.\n */\nexport class MockCollection<T extends DaffIdentifiable = DaffIdentifiable> implements DaffCollection<T> {\n private _items = this.createItems();\n metadata = this.createMetadata();\n data = daffIdentifiableArrayToDict(this._items);\n\n constructor(\n private itemFactory: DaffModelFactory<T>,\n private metadataFactory: DaffCollectionMetadataFactory,\n ) {}\n\n private createItems(): T[] {\n return this.itemFactory.createMany();\n }\n\n private createMetadata(): DaffCollectionMetadata {\n return this.metadataFactory.create({\n ids: this._items.map(({ id }) => id),\n count: this._items.length,\n });\n }\n}\n","//@angular/core\nexport { DaffMockCurrencyPipe } from './angular/mocks/pipes/currency';\nexport { DaffInMemoryDataServiceInterface } from './angular/interfaces/in-memory-data-service.interface';\n\n//Core\nexport { DaffCoreTestingModule } from './testing.module';\n\nexport * from './factories/public_api';\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":["i1.DaffSortOptionFactory","i1.DaffSortOptionsFactory","i1.DaffNumericallyPaginableFactory","i2.DaffSortableFactory"],"mappings":";;;;;AAKA;;;;;AAKG;MAEU,oBAAoB,CAAA;IAC/B,SAAS,CAAC,KAAa,EAAA,GAAI;;;uJADhB,oBAAoB,EAAA,IAAA,EAAA,EAAA,EAAA,MAAA,EAAA,EAAA,CAAA,eAAA,CAAA,IAAA,EAAA,CAAA,CAAA;qJAApB,oBAAoB,EAAA,IAAA,EAAA,UAAA,EAAA,CAAA,CAAA;2FAApB,oBAAoB,EAAA,UAAA,EAAA,CAAA;kBADhC,IAAI;mBAAC,EAAE,IAAI,EAAE,UAAU,EAAE,CAAA;;;MCFb,qBAAqB,CAAA;;wJAArB,qBAAqB,EAAA,IAAA,EAAA,EAAA,EAAA,MAAA,EAAA,EAAA,CAAA,eAAA,CAAA,QAAA,EAAA,CAAA,CAAA;AAArB,sCAAA,qBAAA,CAAA,IAAA,GAAA,EAAA,CAAA,mBAAA,CAAA,EAAA,UAAA,EAAA,QAAA,EAAA,OAAA,EAAA,QAAA,EAAA,QAAA,EAAA,EAAA,EAAA,IAAA,EAAA,qBAAqB,iBAH9B,oBAAoB,CAAA,EAAA,CAAA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A;AAA5B,sCAAA,4BAAA,CAAA,KAAA,GAAA,EAAA,CAAA,qBAAA,CAAA,EAAA,UAAA,EAAA,QAAA,EAAA,OAAA,EAAA,QAAA,EAAA,QAAA,EAAA,EAAA,EAAA,IAAA,EAAA,4BAA4B,cAF3B,MAAM,EAAA,CAAA,CAAA;2FAEP,4BAA4B,EAAA,UAAA,EAAA,CAAA;kBAHxC,UAAU;AAAC,YAAA,IAAA,EAAA,CAAA;AACV,oBAAA,UAAU,EAAE,MAAM;iBACnB,CAAA;;;ACfD;;;;AAIG;MACU,cAAc,CAAA;IAKzB,WACU,CAAA,WAAgC,EAChC,eAA8C,EAAA;AAD9C,QAAA,IAAW,CAAA,WAAA,GAAX,WAAW,CAAqB;AAChC,QAAA,IAAe,CAAA,eAAA,GAAf,eAAe,CAA+B;AANhD,QAAA,IAAA,CAAA,MAAM,GAAG,IAAI,CAAC,WAAW,EAAE,CAAC;AACpC,QAAA,IAAA,CAAA,QAAQ,GAAG,IAAI,CAAC,cAAc,EAAE,CAAC;QACjC,IAAA,CAAA,IAAI,GAAG,2BAA2B,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;KAK5C;IAEI,WAAW,GAAA;AACjB,QAAA,OAAO,IAAI,CAAC,WAAW,CAAC,UAAU,EAAE,CAAC;KACtC;IAEO,cAAc,GAAA;AACpB,QAAA,OAAO,IAAI,CAAC,eAAe,CAAC,MAAM,CAAC;AACjC,YAAA,GAAG,EAAE,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,EAAE,EAAE,EAAE,KAAK,EAAE,CAAC;AACpC,YAAA,KAAK,EAAE,IAAI,CAAC,MAAM,CAAC,MAAM;AAC1B,SAAA,CAAC,CAAC;KACJ;AACF;;ACnCD;;ACAA;;AAEG;;;;"}
|
|
@@ -152,9 +152,9 @@ const randomSlice = (array, length) => {
|
|
|
152
152
|
|
|
153
153
|
/**
|
|
154
154
|
* Converts an array into a dictionary.
|
|
155
|
-
* Dictionary values are keyed by the return of the specified getKey
|
|
155
|
+
* Dictionary values are keyed by the return of the specified `getKey`.
|
|
156
156
|
*/
|
|
157
|
-
const daffArrayToDict = (array, getKey
|
|
157
|
+
const daffArrayToDict = (array, getKey) => array.reduce((dict, val) => {
|
|
158
158
|
dict[getKey(val)] = val;
|
|
159
159
|
return dict;
|
|
160
160
|
}, {});
|
|
@@ -457,9 +457,66 @@ const DaffBase64ServiceToken = new InjectionToken('DaffBase64Service', {
|
|
|
457
457
|
: new DaffServerBase64Service(inject(PLATFORM_ID)),
|
|
458
458
|
});
|
|
459
459
|
|
|
460
|
+
/**
|
|
461
|
+
* The direction in which to sort a list of elements, e.g. if the list was
|
|
462
|
+
* sorted alphabetically, "Ascending" would be from "A-Z",
|
|
463
|
+
* and "Descending" would be from "Z-A".
|
|
464
|
+
*/
|
|
465
|
+
var DaffSortDirectionEnum;
|
|
466
|
+
(function (DaffSortDirectionEnum) {
|
|
467
|
+
DaffSortDirectionEnum["Ascending"] = "ASC";
|
|
468
|
+
DaffSortDirectionEnum["Descending"] = "DSC";
|
|
469
|
+
})(DaffSortDirectionEnum || (DaffSortDirectionEnum = {}));
|
|
470
|
+
|
|
471
|
+
const DAFF_COLLECTION_PAGE_OUT_OF_BOUNDS_ERROR_CODE = 'DAFF_COLLECTION_PAGE_OUT_OF_BOUNDS';
|
|
472
|
+
/**
|
|
473
|
+
* An error thrown when the requested page is greater than the number of available pages.
|
|
474
|
+
*/
|
|
475
|
+
class DaffCollectionPageOutOfBoundsError extends DaffInheritableError {
|
|
476
|
+
constructor(message) {
|
|
477
|
+
super(message);
|
|
478
|
+
this.code = DAFF_COLLECTION_PAGE_OUT_OF_BOUNDS_ERROR_CODE;
|
|
479
|
+
}
|
|
480
|
+
}
|
|
481
|
+
|
|
482
|
+
const daffCollectionErrorMap = {
|
|
483
|
+
[DAFF_COLLECTION_PAGE_OUT_OF_BOUNDS_ERROR_CODE]: DaffCollectionPageOutOfBoundsError,
|
|
484
|
+
};
|
|
485
|
+
|
|
486
|
+
const allowedMetadataKeys = [
|
|
487
|
+
'appliedSortOption',
|
|
488
|
+
'appliedSortDirection',
|
|
489
|
+
'currentPage',
|
|
490
|
+
'pageSize',
|
|
491
|
+
];
|
|
492
|
+
/**
|
|
493
|
+
* Extracts the part of the {@link DaffCollectionRequest} that can be directly set in {@link DaffCollectionMetadata}.
|
|
494
|
+
*/
|
|
495
|
+
const daffCollectionBuildMetadataFromRequest = (request) => allowedMetadataKeys.reduce((acc, key) => {
|
|
496
|
+
if (request[key]) {
|
|
497
|
+
acc[key] = request[key];
|
|
498
|
+
}
|
|
499
|
+
return acc;
|
|
500
|
+
}, {});
|
|
501
|
+
|
|
502
|
+
/**
|
|
503
|
+
* Builds a {@link DaffCollectionRequest} from {@link DaffCollectionMetadata}.
|
|
504
|
+
*/
|
|
505
|
+
const daffCollectionBuildRequestFromMetadata = (metadata) => ({
|
|
506
|
+
appliedSortOption: metadata.appliedSortOption,
|
|
507
|
+
appliedSortDirection: metadata.appliedSortDirection,
|
|
508
|
+
currentPage: metadata.currentPage,
|
|
509
|
+
pageSize: metadata.pageSize,
|
|
510
|
+
});
|
|
511
|
+
|
|
512
|
+
/**
|
|
513
|
+
* Transforms an array of {@link DaffIdentifiable} objects to a dictionary of those objects keyed by ID.
|
|
514
|
+
*/
|
|
515
|
+
const daffIdentifiableArrayToDict = (ary) => daffArrayToDict(ary, ({ id }) => id);
|
|
516
|
+
|
|
460
517
|
/**
|
|
461
518
|
* Generated bundle index. Do not edit.
|
|
462
519
|
*/
|
|
463
520
|
|
|
464
|
-
export { DaffBase64ServiceToken, DaffBrowserBase64Service, DaffErrorStorageService, DaffInheritableError, DaffLocalStorageService, DaffNoopStorageService, DaffPersistenceServiceToken, DaffServerBase64Service, DaffServerErrorStorageService, DaffServerSafePersistenceServiceToken, DaffServerSideStorageError, DaffStorageServiceError, backoff, daffAdd, daffArrayToDict, daffDivide, daffIsError, daffMultiply, daffSubtract, randomSlice, randomSubset, range, sample, shuffle, unique };
|
|
521
|
+
export { DAFF_COLLECTION_PAGE_OUT_OF_BOUNDS_ERROR_CODE, DaffBase64ServiceToken, DaffBrowserBase64Service, DaffCollectionPageOutOfBoundsError, DaffErrorStorageService, DaffInheritableError, DaffLocalStorageService, DaffNoopStorageService, DaffPersistenceServiceToken, DaffServerBase64Service, DaffServerErrorStorageService, DaffServerSafePersistenceServiceToken, DaffServerSideStorageError, DaffSortDirectionEnum, DaffStorageServiceError, backoff, daffAdd, daffArrayToDict, daffCollectionBuildMetadataFromRequest, daffCollectionBuildRequestFromMetadata, daffCollectionErrorMap, daffDivide, daffIdentifiableArrayToDict, daffIsError, daffMultiply, daffSubtract, randomSlice, randomSubset, range, sample, shuffle, unique };
|
|
465
522
|
//# sourceMappingURL=daffodil-core.mjs.map
|