@daffodil/core 0.39.12 → 0.41.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/base64/base64.interface.d.ts +18 -0
- package/base64/browser/browser.service.d.ts +12 -0
- package/base64/public_api.d.ts +3 -0
- package/base64/server/public_api.d.ts +1 -0
- package/base64/server/server.service.d.ts +14 -0
- package/daffodil-core.d.ts +1 -0
- package/{esm2015/address/address.js → esm2020/address/address.mjs} +0 -0
- package/esm2020/base64/base64.interface.mjs +14 -0
- package/esm2020/base64/browser/browser.service.mjs +31 -0
- package/esm2020/base64/public_api.mjs +4 -0
- package/esm2020/base64/server/public_api.mjs +2 -0
- package/esm2020/base64/server/server.service.mjs +33 -0
- package/{esm2015/canonically-locateable/canonically-locateable.interface.js → esm2020/canonically-locateable/canonically-locateable.interface.mjs} +0 -0
- package/{esm2015/constructable/constructable.js → esm2020/constructable/constructable.mjs} +0 -0
- package/{esm2015/daffodil-core.js → esm2020/daffodil-core.mjs} +0 -0
- package/{esm2015/errors/error-map.js → esm2020/errors/error-map.mjs} +0 -0
- package/{esm2015/errors/error.interface.js → esm2020/errors/error.interface.mjs} +0 -0
- package/{esm2015/errors/inheritable-error.js → esm2020/errors/inheritable-error.mjs} +0 -0
- package/{esm2015/errors/is-error.js → esm2020/errors/is-error.mjs} +0 -0
- package/{esm2015/errors/public_api.js → esm2020/errors/public_api.mjs} +0 -0
- package/{esm2015/graphql/apollo/cacheable-operations/cacheable-operations-link.interface.js → esm2020/graphql/apollo/cacheable-operations/cacheable-operations-link.interface.mjs} +0 -0
- package/{esm2015/graphql/apollo/public_api.js → esm2020/graphql/apollo/public_api.mjs} +0 -0
- package/esm2020/graphql/apollo/queued-apollo/queued-apollo.service.mjs +64 -0
- package/{esm2015/graphql/daffodil-core-graphql.js → esm2020/graphql/daffodil-core-graphql.mjs} +0 -0
- package/{esm2015/graphql/fragments/build-fragment-definition.js → esm2020/graphql/fragments/build-fragment-definition.mjs} +0 -0
- package/esm2020/graphql/fragments/build-fragment-name-spread.mjs +18 -0
- package/{esm2015/graphql/fragments/public_api.js → esm2020/graphql/fragments/public_api.mjs} +0 -0
- package/{esm2015/graphql/index.js → esm2020/graphql/index.mjs} +0 -0
- package/{esm2015/graphql/public_api.js → esm2020/graphql/public_api.mjs} +0 -0
- package/{esm2015/identifiable/identifiable.interface.js → esm2020/identifiable/identifiable.interface.mjs} +0 -0
- package/{esm2015/index.js → esm2020/index.mjs} +0 -0
- package/{esm2015/kindable/kindable.interface.js → esm2020/kindable/kindable.interface.mjs} +0 -0
- package/{esm2015/kindable/public_api.js → esm2020/kindable/public_api.mjs} +0 -0
- package/{esm2015/locateable/locateable.interface.js → esm2020/locateable/locateable.interface.mjs} +0 -0
- package/{esm2015/operators/backoff.pipe.js → esm2020/operators/backoff.pipe.mjs} +0 -0
- package/{esm2015/operators/public_api.js → esm2020/operators/public_api.mjs} +0 -0
- package/{esm2015/orderable/orderable.js → esm2020/orderable/orderable.mjs} +0 -0
- package/esm2020/public_api.mjs +8 -0
- package/{esm2015/routing/daffodil-core-routing.js → esm2020/routing/daffodil-core-routing.mjs} +0 -0
- package/{esm2015/routing/index.js → esm2020/routing/index.mjs} +0 -0
- package/{esm2015/routing/public_api.js → esm2020/routing/public_api.mjs} +0 -0
- package/esm2020/routing/uri/normalizer.service.mjs +38 -0
- package/{esm2015/routing/uri/public_api.js → esm2020/routing/uri/public_api.mjs} +0 -0
- package/esm2020/routing/uri/truncation/file-extension.mjs +10 -0
- package/{esm2015/routing/uri/truncation/leading-path-segments.js → esm2020/routing/uri/truncation/leading-path-segments.mjs} +0 -0
- package/esm2020/routing/uri/truncation/leading-slash.mjs +12 -0
- package/{esm2015/routing/uri/truncation/public_api.js → esm2020/routing/uri/truncation/public_api.mjs} +0 -0
- package/{esm2015/routing/uri/truncation/query-fragment.js → esm2020/routing/uri/truncation/query-fragment.mjs} +0 -0
- package/{esm2015/state/collection/paginable.js → esm2020/state/collection/paginable.mjs} +0 -0
- package/{esm2015/state/collection/public_api.js → esm2020/state/collection/public_api.mjs} +0 -0
- package/{esm2015/state/collection/sortable.js → esm2020/state/collection/sortable.mjs} +0 -0
- package/{esm2015/state/daffodil-core-state.js → esm2020/state/daffodil-core-state.mjs} +0 -0
- package/{esm2015/state/errors/public_api.js → esm2020/state/errors/public_api.mjs} +0 -0
- package/{esm2015/state/errors/state-error.interface.js → esm2020/state/errors/state-error.interface.mjs} +0 -0
- package/{esm2015/state/errors/transform-error-to-state-error.js → esm2020/state/errors/transform-error-to-state-error.mjs} +0 -0
- package/{esm2015/state/index.js → esm2020/state/index.mjs} +0 -0
- package/{esm2015/state/operators/public_api.js → esm2020/state/operators/public_api.mjs} +0 -0
- package/esm2020/state/operators/substream.pipe.mjs +42 -0
- package/{esm2015/state/public_api.js → esm2020/state/public_api.mjs} +0 -0
- package/{esm2015/state/reducers/create-meta.js → esm2020/state/reducers/create-meta.mjs} +0 -0
- package/{esm2015/state/reducers/public_api.js → esm2020/state/reducers/public_api.mjs} +0 -0
- package/{esm2015/state/states/loading.js → esm2020/state/states/loading.mjs} +0 -0
- package/{esm2015/state/states/mutable-loading.js → esm2020/state/states/mutable-loading.mjs} +0 -0
- package/{esm2015/state/states/public_api.js → esm2020/state/states/public_api.mjs} +0 -0
- package/{esm2015/state/states/state.enum.js → esm2020/state/states/state.enum.mjs} +0 -0
- package/{esm2015/state/states/stateable.interface.js → esm2020/state/states/stateable.interface.mjs} +0 -0
- package/{esm2015/state/store/facade.js → esm2020/state/store/facade.mjs} +0 -0
- package/{esm2015/storage/error/error.js → esm2020/storage/error/error.mjs} +0 -0
- package/esm2020/storage/error/error.service.mjs +33 -0
- package/{esm2015/storage/error/public_api.js → esm2020/storage/error/public_api.mjs} +0 -0
- package/esm2020/storage/localstorage/localstorage.service.mjs +46 -0
- package/esm2020/storage/noopstorage/noopstorage.service.mjs +24 -0
- package/esm2020/storage/persistence-server-safe.token.mjs +14 -0
- package/{esm2015/storage/persistence.interface.js → esm2020/storage/persistence.interface.mjs} +0 -0
- package/esm2020/storage/public_api.mjs +7 -0
- package/{esm2015/storage/server-error/public_api.js → esm2020/storage/server-error/public_api.mjs} +0 -0
- package/{esm2015/storage/server-error/server-error.js → esm2020/storage/server-error/server-error.mjs} +0 -0
- package/esm2020/storage/server-error/server-error.service.mjs +36 -0
- package/esm2020/testing/address/factories/address.factory.mjs +38 -0
- package/{esm2015/testing/angular/interfaces/in-memory-data-service.interface.js → esm2020/testing/angular/interfaces/in-memory-data-service.interface.mjs} +0 -0
- package/esm2020/testing/angular/mocks/pipes/currency.mjs +19 -0
- package/{esm2015/testing/daffodil-core-testing.js → esm2020/testing/daffodil-core-testing.mjs} +0 -0
- package/{esm2015/testing/factories/factory.interface.js → esm2020/testing/factories/factory.interface.mjs} +0 -0
- package/esm2020/testing/factories/factory.mjs +54 -0
- package/{esm2015/testing/index.js → esm2020/testing/index.mjs} +0 -0
- package/esm2020/testing/testing.module.mjs +17 -0
- package/{esm2015/types/dict.type.js → esm2020/types/dict.type.mjs} +0 -0
- package/{esm2015/types/id.type.js → esm2020/types/id.type.mjs} +0 -0
- package/{esm2015/types/public_api.js → esm2020/types/public_api.mjs} +0 -0
- package/{esm2015/utils/array-to-dict.js → esm2020/utils/array-to-dict.mjs} +0 -0
- package/{esm2015/utils/long-arithmetic.js → esm2020/utils/long-arithmetic.mjs} +0 -0
- package/{esm2015/utils/public_api.js → esm2020/utils/public_api.mjs} +0 -0
- package/{esm2015/utils/random-slice.js → esm2020/utils/random-slice.mjs} +0 -0
- package/{esm2015/utils/random-subset.js → esm2020/utils/random-subset.mjs} +0 -0
- package/{esm2015/utils/range.js → esm2020/utils/range.mjs} +0 -0
- package/{esm2015/utils/sample.js → esm2020/utils/sample.mjs} +0 -0
- package/{esm2015/utils/shuffle.js → esm2020/utils/shuffle.mjs} +0 -0
- package/{esm2015/utils/unique.js → esm2020/utils/unique.mjs} +0 -0
- package/fesm2015/{daffodil-core-graphql.js → daffodil-core-graphql.mjs} +12 -14
- package/fesm2015/daffodil-core-graphql.mjs.map +1 -0
- package/fesm2015/{daffodil-core-routing.js → daffodil-core-routing.mjs} +13 -13
- package/fesm2015/daffodil-core-routing.mjs.map +1 -0
- package/fesm2015/{daffodil-core-state.js → daffodil-core-state.mjs} +2 -3
- package/fesm2015/daffodil-core-state.mjs.map +1 -0
- package/fesm2015/daffodil-core-testing.mjs +128 -0
- package/fesm2015/daffodil-core-testing.mjs.map +1 -0
- package/fesm2015/daffodil-core.mjs +465 -0
- package/fesm2015/daffodil-core.mjs.map +1 -0
- package/fesm2020/daffodil-core-graphql.mjs +96 -0
- package/fesm2020/daffodil-core-graphql.mjs.map +1 -0
- package/fesm2020/daffodil-core-routing.mjs +84 -0
- package/fesm2020/daffodil-core-routing.mjs.map +1 -0
- package/fesm2020/daffodil-core-state.mjs +74 -0
- package/fesm2020/daffodil-core-state.mjs.map +1 -0
- package/fesm2020/daffodil-core-testing.mjs +131 -0
- package/fesm2020/daffodil-core-testing.mjs.map +1 -0
- package/{fesm2015/daffodil-core.js → fesm2020/daffodil-core.mjs} +117 -31
- package/fesm2020/daffodil-core.mjs.map +1 -0
- package/graphql/apollo/queued-apollo/queued-apollo.service.d.ts +4 -2
- package/graphql/daffodil-core-graphql.d.ts +1 -0
- package/graphql/package.json +5 -6
- package/package.json +59 -15
- package/public_api.d.ts +1 -0
- package/routing/daffodil-core-routing.d.ts +1 -0
- package/routing/package.json +5 -6
- package/routing/uri/normalizer.service.d.ts +3 -0
- package/state/daffodil-core-state.d.ts +1 -0
- package/state/package.json +5 -6
- package/storage/error/error.service.d.ts +3 -0
- package/storage/localstorage/localstorage.service.d.ts +3 -0
- package/storage/noopstorage/noopstorage.service.d.ts +3 -0
- package/storage/persistence-server-safe.token.d.ts +6 -0
- package/storage/public_api.d.ts +1 -0
- package/storage/server-error/server-error.service.d.ts +3 -0
- package/testing/address/factories/address.factory.d.ts +3 -0
- package/testing/angular/mocks/pipes/currency.d.ts +3 -0
- package/testing/daffodil-core-testing.d.ts +1 -0
- package/testing/package.json +5 -6
- package/testing/testing.module.d.ts +5 -0
- package/utils/array-to-dict.d.ts +1 -1
- package/bundles/daffodil-core-graphql.umd.js +0 -445
- package/bundles/daffodil-core-graphql.umd.js.map +0 -1
- package/bundles/daffodil-core-graphql.umd.min.js +0 -16
- package/bundles/daffodil-core-graphql.umd.min.js.map +0 -1
- package/bundles/daffodil-core-routing.umd.js +0 -100
- package/bundles/daffodil-core-routing.umd.js.map +0 -1
- package/bundles/daffodil-core-routing.umd.min.js +0 -2
- package/bundles/daffodil-core-routing.umd.min.js.map +0 -1
- package/bundles/daffodil-core-state.umd.js +0 -405
- package/bundles/daffodil-core-state.umd.js.map +0 -1
- package/bundles/daffodil-core-state.umd.min.js +0 -16
- package/bundles/daffodil-core-state.umd.min.js.map +0 -1
- package/bundles/daffodil-core-testing.umd.js +0 -466
- package/bundles/daffodil-core-testing.umd.js.map +0 -1
- package/bundles/daffodil-core-testing.umd.min.js +0 -16
- package/bundles/daffodil-core-testing.umd.min.js.map +0 -1
- package/bundles/daffodil-core.umd.js +0 -758
- package/bundles/daffodil-core.umd.js.map +0 -1
- package/bundles/daffodil-core.umd.min.js +0 -16
- package/bundles/daffodil-core.umd.min.js.map +0 -1
- package/daffodil-core.metadata.json +0 -1
- package/esm2015/graphql/apollo/queued-apollo/queued-apollo.service.js +0 -67
- package/esm2015/graphql/fragments/build-fragment-name-spread.js +0 -20
- package/esm2015/public_api.js +0 -7
- package/esm2015/routing/uri/normalizer.service.js +0 -40
- package/esm2015/routing/uri/truncation/file-extension.js +0 -10
- package/esm2015/routing/uri/truncation/leading-slash.js +0 -12
- package/esm2015/state/operators/substream.pipe.js +0 -44
- package/esm2015/storage/error/error.service.js +0 -31
- package/esm2015/storage/localstorage/localstorage.service.js +0 -45
- package/esm2015/storage/noopstorage/noopstorage.service.js +0 -22
- package/esm2015/storage/public_api.js +0 -6
- package/esm2015/storage/server-error/server-error.service.js +0 -34
- package/esm2015/testing/address/factories/address.factory.js +0 -38
- package/esm2015/testing/angular/mocks/pipes/currency.js +0 -15
- package/esm2015/testing/factories/factory.js +0 -51
- package/esm2015/testing/testing.module.js +0 -12
- package/fesm2015/daffodil-core-graphql.js.map +0 -1
- package/fesm2015/daffodil-core-routing.js.map +0 -1
- package/fesm2015/daffodil-core-state.js.map +0 -1
- package/fesm2015/daffodil-core-testing.js +0 -120
- package/fesm2015/daffodil-core-testing.js.map +0 -1
- package/fesm2015/daffodil-core.js.map +0 -1
- package/graphql/daffodil-core-graphql.metadata.json +0 -1
- package/routing/daffodil-core-routing.metadata.json +0 -1
- package/state/daffodil-core-state.metadata.json +0 -1
- package/testing/daffodil-core-testing.metadata.json +0 -1
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
import * as i0 from '@angular/core';
|
|
2
|
+
import { Injectable, Pipe, NgModule } from '@angular/core';
|
|
3
|
+
import * as faker from '@faker-js/faker/locale/en_US';
|
|
4
|
+
import { range } from '@daffodil/core';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* The base class for model factories.
|
|
8
|
+
*
|
|
9
|
+
* The mock class is passed as the first constructor arg
|
|
10
|
+
* and any additional args are passed to the mock class constructor.
|
|
11
|
+
*
|
|
12
|
+
* The constructor args can be omitted if the `create` method is overridden.
|
|
13
|
+
*
|
|
14
|
+
* The following example demonstrates using this feature to inject
|
|
15
|
+
* a different factory into a mock class.
|
|
16
|
+
*
|
|
17
|
+
* ```ts
|
|
18
|
+
* class MyMockModel {
|
|
19
|
+
* constructor(
|
|
20
|
+
* private otherFactory: MyOtherFactory
|
|
21
|
+
* ) {}
|
|
22
|
+
*
|
|
23
|
+
* private createOtherModel() {
|
|
24
|
+
* return this.otherFactory.create()
|
|
25
|
+
* }
|
|
26
|
+
*
|
|
27
|
+
* otherModel = this.createOtherModel()
|
|
28
|
+
* }
|
|
29
|
+
*
|
|
30
|
+
* @Injectable()
|
|
31
|
+
* class TestFactory extends DaffModelFactory<MyMockModel> {
|
|
32
|
+
* constructor(
|
|
33
|
+
* otherFactory: MyOtherFactory
|
|
34
|
+
* ) {
|
|
35
|
+
* super(MyMockModel, otherFactory)
|
|
36
|
+
* }
|
|
37
|
+
* }
|
|
38
|
+
* ```
|
|
39
|
+
*/
|
|
40
|
+
class DaffModelFactory {
|
|
41
|
+
constructor(type, ...args) {
|
|
42
|
+
this.type = type;
|
|
43
|
+
this._instantiationArgs = args;
|
|
44
|
+
}
|
|
45
|
+
create(partial = {}) {
|
|
46
|
+
if (!this.type) {
|
|
47
|
+
throw new Error('`type` is required if `create` is not overriden.');
|
|
48
|
+
}
|
|
49
|
+
return Object.assign(Object.assign({}, new this.type(...this._instantiationArgs)), partial);
|
|
50
|
+
}
|
|
51
|
+
createMany(qty = 1, partial = {}) {
|
|
52
|
+
return range(0, qty - 1).map(() => this.create(partial));
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* @deprecated
|
|
58
|
+
* Prefer the `MockDaffAddress` of daffodil/geography/testing`
|
|
59
|
+
*/
|
|
60
|
+
class MockDaffAddress {
|
|
61
|
+
constructor() {
|
|
62
|
+
this.firstname = faker.name.firstName();
|
|
63
|
+
this.lastname = faker.name.lastName();
|
|
64
|
+
this.street = faker.address.streetName();
|
|
65
|
+
this.city = faker.address.city();
|
|
66
|
+
this.state = faker.address.stateAbbr();
|
|
67
|
+
this.email = faker.internet.email();
|
|
68
|
+
this.postcode = faker.address.zipCode();
|
|
69
|
+
this.telephone = faker.phone.phoneNumber();
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* @deprecated
|
|
74
|
+
* Prefer the `DaffAddressFactory` of `daffodil/geography/testing`
|
|
75
|
+
*/
|
|
76
|
+
class DaffAddressFactory extends DaffModelFactory {
|
|
77
|
+
constructor() {
|
|
78
|
+
super(MockDaffAddress);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
/** @nocollapse */ /** @nocollapse */ DaffAddressFactory.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.0", ngImport: i0, type: DaffAddressFactory, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
82
|
+
/** @nocollapse */ /** @nocollapse */ DaffAddressFactory.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.3.0", ngImport: i0, type: DaffAddressFactory, providedIn: 'root' });
|
|
83
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.0", ngImport: i0, type: DaffAddressFactory, decorators: [{
|
|
84
|
+
type: Injectable,
|
|
85
|
+
args: [{
|
|
86
|
+
providedIn: 'root',
|
|
87
|
+
}]
|
|
88
|
+
}], ctorParameters: function () { return []; } });
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* @docs
|
|
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
|
|
95
|
+
*/
|
|
96
|
+
class DaffMockCurrencyPipe {
|
|
97
|
+
transform(value) { }
|
|
98
|
+
;
|
|
99
|
+
}
|
|
100
|
+
/** @nocollapse */ /** @nocollapse */ DaffMockCurrencyPipe.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.0", ngImport: i0, type: DaffMockCurrencyPipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe });
|
|
101
|
+
/** @nocollapse */ /** @nocollapse */ DaffMockCurrencyPipe.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "12.0.0", version: "13.3.0", ngImport: i0, type: DaffMockCurrencyPipe, name: "currency" });
|
|
102
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.0", ngImport: i0, type: DaffMockCurrencyPipe, decorators: [{
|
|
103
|
+
type: Pipe,
|
|
104
|
+
args: [{ name: 'currency' }]
|
|
105
|
+
}] });
|
|
106
|
+
|
|
107
|
+
class DaffCoreTestingModule {
|
|
108
|
+
}
|
|
109
|
+
/** @nocollapse */ /** @nocollapse */ DaffCoreTestingModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.0", ngImport: i0, type: DaffCoreTestingModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
|
110
|
+
/** @nocollapse */ /** @nocollapse */ DaffCoreTestingModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "13.3.0", ngImport: i0, type: DaffCoreTestingModule, declarations: [DaffMockCurrencyPipe] });
|
|
111
|
+
/** @nocollapse */ /** @nocollapse */ DaffCoreTestingModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "13.3.0", ngImport: i0, type: DaffCoreTestingModule });
|
|
112
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.0", ngImport: i0, type: DaffCoreTestingModule, decorators: [{
|
|
113
|
+
type: NgModule,
|
|
114
|
+
args: [{
|
|
115
|
+
declarations: [
|
|
116
|
+
DaffMockCurrencyPipe,
|
|
117
|
+
],
|
|
118
|
+
}]
|
|
119
|
+
}] });
|
|
120
|
+
|
|
121
|
+
// Address
|
|
122
|
+
|
|
123
|
+
/**
|
|
124
|
+
* Generated bundle index. Do not edit.
|
|
125
|
+
*/
|
|
126
|
+
|
|
127
|
+
export { DaffAddressFactory, DaffCoreTestingModule, DaffMockCurrencyPipe, DaffModelFactory };
|
|
128
|
+
//# sourceMappingURL=daffodil-core-testing.mjs.map
|
|
@@ -0,0 +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"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1,465 @@
|
|
|
1
|
+
import * as i0 from '@angular/core';
|
|
2
|
+
import { Injectable, PLATFORM_ID, Inject, InjectionToken, inject } from '@angular/core';
|
|
3
|
+
import { isPlatformBrowser } from '@angular/common';
|
|
4
|
+
import { pipe, throwError, timer } from 'rxjs';
|
|
5
|
+
import { retryWhen, mergeMap } from 'rxjs/operators';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* A helper function to get the number of decimal significant figures of a number.
|
|
9
|
+
* This function will fail if the given number has more than 16 significant figures or
|
|
10
|
+
* the value of the number is greater than 10^11
|
|
11
|
+
*
|
|
12
|
+
* @param number
|
|
13
|
+
*/
|
|
14
|
+
function daffPrecision(number) {
|
|
15
|
+
let p = 10000;
|
|
16
|
+
if (number === undefined || number === null) {
|
|
17
|
+
return p;
|
|
18
|
+
}
|
|
19
|
+
while (Math.round(number * p) / p !== number) {
|
|
20
|
+
p *= 10;
|
|
21
|
+
}
|
|
22
|
+
return p;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* A function to add long numbers accurately with conversions and integer math.
|
|
26
|
+
* This function only guarantees correct answers when the numbers given and the result are less than
|
|
27
|
+
* 16 significant figures and less than 10^11
|
|
28
|
+
*
|
|
29
|
+
* @param numbers
|
|
30
|
+
*/
|
|
31
|
+
function daffAdd(...numbers) {
|
|
32
|
+
if (numbers.length < 2) {
|
|
33
|
+
throw new Error('Provide at least 2 numbers for daffAdd.');
|
|
34
|
+
}
|
|
35
|
+
const precision = Math.max(...numbers.map(daffPrecision));
|
|
36
|
+
return numbers.reduce((acc, number) => acc + Math.round(number * precision), 0) / precision;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* A function to subtract long numbers accurately with conversions and integer math.
|
|
40
|
+
* This function only guarantees correct answers when the numbers given and the result are each less than
|
|
41
|
+
* 16 significant figures and less than 10^11
|
|
42
|
+
*
|
|
43
|
+
* @param numbers
|
|
44
|
+
*/
|
|
45
|
+
function daffSubtract(...numbers) {
|
|
46
|
+
if (numbers.length < 2) {
|
|
47
|
+
throw new Error('Provide at least 2 numbers for daffSubtract.');
|
|
48
|
+
}
|
|
49
|
+
const precision = Math.max(...numbers.map(daffPrecision));
|
|
50
|
+
return numbers.slice(1).reduce((acc, number) => acc - Math.round(number * precision), Math.round(numbers[0] * precision)) / precision;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* A function to multiply long numbers accurately with conversions and integer math.
|
|
54
|
+
* This function only guarantees correct answers when the numbers given and the result are each less than 16 significant figures
|
|
55
|
+
* and less than 10^11
|
|
56
|
+
*
|
|
57
|
+
* @param numbers
|
|
58
|
+
*/
|
|
59
|
+
function daffMultiply(...numbers) {
|
|
60
|
+
if (numbers.length < 2) {
|
|
61
|
+
throw new Error('Provide at least 2 numbers for daffMultiply.');
|
|
62
|
+
}
|
|
63
|
+
const precision = Math.max(...numbers.map(daffPrecision));
|
|
64
|
+
return numbers.reduce((acc, number) => acc * Math.round(number * precision), 1) / Math.pow(precision, numbers.length);
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* A function to divide long numbers accurately with conversions and integer math.
|
|
68
|
+
* This function only guarantees correct answers when the numbers given and the result are each less than 16 significant figures
|
|
69
|
+
* and less than 10^11
|
|
70
|
+
*
|
|
71
|
+
* Returns NaN when attempting to use NaN as an input.
|
|
72
|
+
* Returns NaN when attempting to divide by 0 or null.
|
|
73
|
+
*
|
|
74
|
+
* @param numbers
|
|
75
|
+
*/
|
|
76
|
+
function daffDivide(...numbers) {
|
|
77
|
+
if (numbers.length < 2) {
|
|
78
|
+
throw new Error('Provide at least 2 numbers for daffDivide.');
|
|
79
|
+
}
|
|
80
|
+
// TODO(griest024): use better condition after IE support is dropped
|
|
81
|
+
const illegalOperation = numbers.filter(isNaN).length > 0
|
|
82
|
+
|| numbers.slice(1).filter(n => n === 0 || n === null).length > 0;
|
|
83
|
+
if (illegalOperation) {
|
|
84
|
+
return NaN;
|
|
85
|
+
}
|
|
86
|
+
const precision = Math.max(...numbers.map(daffPrecision));
|
|
87
|
+
return numbers.slice(1).reduce((acc, number) => acc / Math.round(number * precision), Math.round(numbers[0] * precision)) * Math.pow(precision, numbers.length - 2);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* Range
|
|
92
|
+
*
|
|
93
|
+
* Range accepts two inputs, a `start` and an `end`
|
|
94
|
+
* and returns an array filled with numbers from
|
|
95
|
+
* `start` to `end`.
|
|
96
|
+
*
|
|
97
|
+
* @param start
|
|
98
|
+
* @param end
|
|
99
|
+
* @returns number
|
|
100
|
+
*/
|
|
101
|
+
const range = (start, end) => Array.apply(null, Array(end - start + 1)).map((val, index) => index + start);
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* Immutable Fisher-Yates Shuffle
|
|
105
|
+
* https://en.wikipedia.org/wiki/Fisher%E2%80%93Yates_shuffle
|
|
106
|
+
*/
|
|
107
|
+
const shuffle = (array) => {
|
|
108
|
+
const result = [];
|
|
109
|
+
array.forEach((el, i) => {
|
|
110
|
+
const s = Math.floor(Math.random() * i);
|
|
111
|
+
if (s !== i) {
|
|
112
|
+
result[i] = result[s];
|
|
113
|
+
}
|
|
114
|
+
result[s] = el;
|
|
115
|
+
});
|
|
116
|
+
return result;
|
|
117
|
+
};
|
|
118
|
+
|
|
119
|
+
/**
|
|
120
|
+
* Returns a random subset of an array in a random order.
|
|
121
|
+
*
|
|
122
|
+
* @param array
|
|
123
|
+
* @param length
|
|
124
|
+
*/
|
|
125
|
+
const randomSubset = (array, length) => {
|
|
126
|
+
if (length > array.length) {
|
|
127
|
+
throw new Error('Requested length is longer than array length.');
|
|
128
|
+
}
|
|
129
|
+
length = length ? length : Math.floor(Math.random() * array.length);
|
|
130
|
+
return shuffle(array).slice(0, length);
|
|
131
|
+
};
|
|
132
|
+
|
|
133
|
+
/**
|
|
134
|
+
* Returns a random slice of an array.
|
|
135
|
+
* An optional length may be specified.
|
|
136
|
+
*
|
|
137
|
+
* @param array
|
|
138
|
+
*/
|
|
139
|
+
const randomSlice = (array, length) => {
|
|
140
|
+
if (array.length === 0) {
|
|
141
|
+
return [];
|
|
142
|
+
}
|
|
143
|
+
;
|
|
144
|
+
if (length > array.length) {
|
|
145
|
+
throw new Error('Requested length is longer than array length.');
|
|
146
|
+
}
|
|
147
|
+
const arrayLength = length || Math.floor(Math.random() * array.length);
|
|
148
|
+
const start = Math.floor(Math.random() * (array.length - arrayLength + 1));
|
|
149
|
+
const end = start + arrayLength;
|
|
150
|
+
return array.slice(start, end);
|
|
151
|
+
};
|
|
152
|
+
|
|
153
|
+
/**
|
|
154
|
+
* Converts an array into a dictionary.
|
|
155
|
+
* Dictionary values are keyed by the return of the specified getKey, or `'key'` by default.
|
|
156
|
+
*/
|
|
157
|
+
const daffArrayToDict = (array, getKey = (val) => val.key) => array.reduce((dict, val) => {
|
|
158
|
+
dict[getKey(val)] = val;
|
|
159
|
+
return dict;
|
|
160
|
+
}, {});
|
|
161
|
+
|
|
162
|
+
/**
|
|
163
|
+
* Returns a random element of an array.
|
|
164
|
+
*/
|
|
165
|
+
const sample = (array) => randomSlice(array, 1)[0];
|
|
166
|
+
|
|
167
|
+
/**
|
|
168
|
+
* Filters an array of elements, removing duplicates.
|
|
169
|
+
* Does not guarantee order of filtered elements.
|
|
170
|
+
*
|
|
171
|
+
* An optional comparator function may be passed for arbitrary comparison behavior.
|
|
172
|
+
* The default is a strict equality comparison: `a === b`.
|
|
173
|
+
*/
|
|
174
|
+
const unique = (array, comparator = (a, b) => a === b) => array.filter((a, index) => array.slice(index + 1).filter(b => comparator(a, b)).length === 0);
|
|
175
|
+
|
|
176
|
+
/**
|
|
177
|
+
* A class which allows you to appropriately check the inheritance of an error.
|
|
178
|
+
*
|
|
179
|
+
* In typescript, when you try to extend an error with a specialized error class,
|
|
180
|
+
* if you try to call something like:
|
|
181
|
+
*
|
|
182
|
+
* ```ts
|
|
183
|
+
* class MyError extends Error {}
|
|
184
|
+
*
|
|
185
|
+
* let myError = new MyError();
|
|
186
|
+
*
|
|
187
|
+
* myError instanceof MyError; // returns false
|
|
188
|
+
* ```
|
|
189
|
+
*
|
|
190
|
+
* You will see unexpected things. This class fixes that issue as described here
|
|
191
|
+
* https://github.com/microsoft/TypeScript/issues/13965
|
|
192
|
+
*/
|
|
193
|
+
class DaffInheritableError extends Error {
|
|
194
|
+
constructor(message) {
|
|
195
|
+
super(message);
|
|
196
|
+
this.recoverable = false;
|
|
197
|
+
const trueProto = new.target.prototype;
|
|
198
|
+
Object.setPrototypeOf(this, trueProto);
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
/**
|
|
203
|
+
* Checks if the passed object is a {@link DaffError}
|
|
204
|
+
*/
|
|
205
|
+
const daffIsError = (error) => error instanceof DaffInheritableError || !!error.code;
|
|
206
|
+
|
|
207
|
+
class DaffStorageServiceError extends DaffInheritableError {
|
|
208
|
+
constructor(message) {
|
|
209
|
+
super(message);
|
|
210
|
+
this.message = message;
|
|
211
|
+
this.code = 'DAFF_STORAGE_FAILURE';
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
/**
|
|
216
|
+
* @inheritdoc
|
|
217
|
+
*/
|
|
218
|
+
class DaffErrorStorageService {
|
|
219
|
+
setItem(key, value) {
|
|
220
|
+
this.throwError();
|
|
221
|
+
}
|
|
222
|
+
getItem(key) {
|
|
223
|
+
this.throwError();
|
|
224
|
+
}
|
|
225
|
+
removeItem(key) {
|
|
226
|
+
this.throwError();
|
|
227
|
+
}
|
|
228
|
+
clear() {
|
|
229
|
+
this.throwError();
|
|
230
|
+
}
|
|
231
|
+
throwError() {
|
|
232
|
+
throw new DaffStorageServiceError(DaffErrorStorageService.ERROR_MESSAGE);
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
DaffErrorStorageService.ERROR_MESSAGE = 'The DaffErrorStorageService always throws an error.';
|
|
236
|
+
/** @nocollapse */ /** @nocollapse */ DaffErrorStorageService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.0", ngImport: i0, type: DaffErrorStorageService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
237
|
+
/** @nocollapse */ /** @nocollapse */ DaffErrorStorageService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.3.0", ngImport: i0, type: DaffErrorStorageService, providedIn: 'root' });
|
|
238
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.0", ngImport: i0, type: DaffErrorStorageService, decorators: [{
|
|
239
|
+
type: Injectable,
|
|
240
|
+
args: [{
|
|
241
|
+
providedIn: 'root',
|
|
242
|
+
}]
|
|
243
|
+
}] });
|
|
244
|
+
|
|
245
|
+
/**
|
|
246
|
+
* An error thrown when there is an attempt to access storage on the server and none is available.
|
|
247
|
+
*/
|
|
248
|
+
class DaffServerSideStorageError extends DaffStorageServiceError {
|
|
249
|
+
constructor(message) {
|
|
250
|
+
super(message);
|
|
251
|
+
this.message = message;
|
|
252
|
+
this.code = 'DAFF_SERVER_STORAGE_FAILURE';
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
/**
|
|
257
|
+
* A storage service meant to be loaded into SSR contexts.
|
|
258
|
+
* It will always throw the {@link DaffServerSideStorageError}.
|
|
259
|
+
*
|
|
260
|
+
* @inheritdoc
|
|
261
|
+
*/
|
|
262
|
+
class DaffServerErrorStorageService {
|
|
263
|
+
setItem(key, value) {
|
|
264
|
+
this.throwError();
|
|
265
|
+
}
|
|
266
|
+
getItem(key) {
|
|
267
|
+
this.throwError();
|
|
268
|
+
}
|
|
269
|
+
removeItem(key) {
|
|
270
|
+
this.throwError();
|
|
271
|
+
}
|
|
272
|
+
clear() {
|
|
273
|
+
this.throwError();
|
|
274
|
+
}
|
|
275
|
+
throwError() {
|
|
276
|
+
throw new DaffServerSideStorageError(DaffServerErrorStorageService.ERROR_MESSAGE);
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
DaffServerErrorStorageService.ERROR_MESSAGE = 'The DaffServerErrorStorageService always throws an error.';
|
|
280
|
+
/** @nocollapse */ /** @nocollapse */ DaffServerErrorStorageService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.0", ngImport: i0, type: DaffServerErrorStorageService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
281
|
+
/** @nocollapse */ /** @nocollapse */ DaffServerErrorStorageService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.3.0", ngImport: i0, type: DaffServerErrorStorageService, providedIn: 'root' });
|
|
282
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.0", ngImport: i0, type: DaffServerErrorStorageService, decorators: [{
|
|
283
|
+
type: Injectable,
|
|
284
|
+
args: [{
|
|
285
|
+
providedIn: 'root',
|
|
286
|
+
}]
|
|
287
|
+
}] });
|
|
288
|
+
|
|
289
|
+
/**
|
|
290
|
+
* @inheritdoc
|
|
291
|
+
*/
|
|
292
|
+
class DaffLocalStorageService {
|
|
293
|
+
constructor(platformId) {
|
|
294
|
+
if (!isPlatformBrowser(platformId)) {
|
|
295
|
+
throw new Error('The DaffLocalStorageService can only be instantiated in the browser.');
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
/**
|
|
299
|
+
* Persist the given item into local storage.
|
|
300
|
+
*/
|
|
301
|
+
setItem(key, value) {
|
|
302
|
+
localStorage.setItem(key, value);
|
|
303
|
+
}
|
|
304
|
+
/**
|
|
305
|
+
* Retrieve the given item from localstorage.
|
|
306
|
+
*/
|
|
307
|
+
getItem(key) {
|
|
308
|
+
return localStorage.getItem(key);
|
|
309
|
+
}
|
|
310
|
+
/**
|
|
311
|
+
* Remove a given item from localstorage
|
|
312
|
+
*/
|
|
313
|
+
removeItem(key) {
|
|
314
|
+
localStorage.removeItem(key);
|
|
315
|
+
}
|
|
316
|
+
clear() {
|
|
317
|
+
localStorage.clear();
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
/** @nocollapse */ /** @nocollapse */ DaffLocalStorageService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.0", ngImport: i0, type: DaffLocalStorageService, deps: [{ token: PLATFORM_ID }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
321
|
+
/** @nocollapse */ /** @nocollapse */ DaffLocalStorageService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.3.0", ngImport: i0, type: DaffLocalStorageService, providedIn: 'root' });
|
|
322
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.0", ngImport: i0, type: DaffLocalStorageService, decorators: [{
|
|
323
|
+
type: Injectable,
|
|
324
|
+
args: [{
|
|
325
|
+
providedIn: 'root',
|
|
326
|
+
}]
|
|
327
|
+
}], ctorParameters: function () {
|
|
328
|
+
return [{ type: undefined, decorators: [{
|
|
329
|
+
type: Inject,
|
|
330
|
+
args: [PLATFORM_ID]
|
|
331
|
+
}] }];
|
|
332
|
+
} });
|
|
333
|
+
|
|
334
|
+
/**
|
|
335
|
+
* @inheritdoc
|
|
336
|
+
*/
|
|
337
|
+
class DaffNoopStorageService {
|
|
338
|
+
setItem(key, value) { }
|
|
339
|
+
;
|
|
340
|
+
getItem(key) { }
|
|
341
|
+
;
|
|
342
|
+
clear() { }
|
|
343
|
+
;
|
|
344
|
+
removeItem(key) { }
|
|
345
|
+
;
|
|
346
|
+
}
|
|
347
|
+
/** @nocollapse */ /** @nocollapse */ DaffNoopStorageService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.0", ngImport: i0, type: DaffNoopStorageService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
348
|
+
/** @nocollapse */ /** @nocollapse */ DaffNoopStorageService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.3.0", ngImport: i0, type: DaffNoopStorageService, providedIn: 'root' });
|
|
349
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.0", ngImport: i0, type: DaffNoopStorageService, decorators: [{
|
|
350
|
+
type: Injectable,
|
|
351
|
+
args: [{
|
|
352
|
+
providedIn: 'root',
|
|
353
|
+
}]
|
|
354
|
+
}] });
|
|
355
|
+
|
|
356
|
+
const DaffPersistenceServiceToken = new InjectionToken('DaffPersistenceService', {
|
|
357
|
+
providedIn: 'root',
|
|
358
|
+
factory: () => isPlatformBrowser(inject(PLATFORM_ID))
|
|
359
|
+
? new DaffLocalStorageService(inject(PLATFORM_ID))
|
|
360
|
+
: new DaffServerErrorStorageService(),
|
|
361
|
+
});
|
|
362
|
+
|
|
363
|
+
/**
|
|
364
|
+
* Provides noop for the persistence service on the server.
|
|
365
|
+
*/
|
|
366
|
+
const DaffServerSafePersistenceServiceToken = new InjectionToken('DaffServerSafePersistenceService', {
|
|
367
|
+
providedIn: 'root',
|
|
368
|
+
factory: () => isPlatformBrowser(inject(PLATFORM_ID))
|
|
369
|
+
? inject(DaffPersistenceServiceToken)
|
|
370
|
+
: inject(DaffNoopStorageService),
|
|
371
|
+
});
|
|
372
|
+
|
|
373
|
+
/**
|
|
374
|
+
* Retries failed Observables
|
|
375
|
+
*
|
|
376
|
+
* @param maxTries The maximum number of tries the observable will be tried
|
|
377
|
+
* @param ms The initial amount of time
|
|
378
|
+
*/
|
|
379
|
+
function backoff(maxTries, ms) {
|
|
380
|
+
return pipe(retryWhen(attempt => attempt.pipe(mergeMap((shadowedAttempt, i) => {
|
|
381
|
+
if (i >= maxTries) {
|
|
382
|
+
return throwError(shadowedAttempt);
|
|
383
|
+
}
|
|
384
|
+
return timer(ms * Math.pow(2, i));
|
|
385
|
+
}))));
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
/**
|
|
389
|
+
* A base64 service meant to be loaded into SSR contexts.
|
|
390
|
+
*
|
|
391
|
+
* @inheritdoc
|
|
392
|
+
*/
|
|
393
|
+
class DaffServerBase64Service {
|
|
394
|
+
constructor(platformId) {
|
|
395
|
+
if (isPlatformBrowser(platformId)) {
|
|
396
|
+
throw new Error('The DaffBrowserBase64Service can only be instantiated on the server.');
|
|
397
|
+
}
|
|
398
|
+
}
|
|
399
|
+
encode(str) {
|
|
400
|
+
return Buffer.from(str).toString('base64');
|
|
401
|
+
}
|
|
402
|
+
decode(str) {
|
|
403
|
+
return Buffer.from(str, 'base64').toString('ascii');
|
|
404
|
+
}
|
|
405
|
+
}
|
|
406
|
+
/** @nocollapse */ /** @nocollapse */ DaffServerBase64Service.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.0", ngImport: i0, type: DaffServerBase64Service, deps: [{ token: PLATFORM_ID }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
407
|
+
/** @nocollapse */ /** @nocollapse */ DaffServerBase64Service.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.3.0", ngImport: i0, type: DaffServerBase64Service, providedIn: 'root' });
|
|
408
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.0", ngImport: i0, type: DaffServerBase64Service, decorators: [{
|
|
409
|
+
type: Injectable,
|
|
410
|
+
args: [{
|
|
411
|
+
providedIn: 'root',
|
|
412
|
+
}]
|
|
413
|
+
}], ctorParameters: function () {
|
|
414
|
+
return [{ type: undefined, decorators: [{
|
|
415
|
+
type: Inject,
|
|
416
|
+
args: [PLATFORM_ID]
|
|
417
|
+
}] }];
|
|
418
|
+
} });
|
|
419
|
+
|
|
420
|
+
/**
|
|
421
|
+
* @inheritdoc
|
|
422
|
+
*/
|
|
423
|
+
class DaffBrowserBase64Service {
|
|
424
|
+
constructor(platformId) {
|
|
425
|
+
if (!isPlatformBrowser(platformId)) {
|
|
426
|
+
throw new Error('The DaffBrowserBase64Service can only be instantiated in the browser.');
|
|
427
|
+
}
|
|
428
|
+
}
|
|
429
|
+
encode(str) {
|
|
430
|
+
return btoa(str);
|
|
431
|
+
}
|
|
432
|
+
decode(str) {
|
|
433
|
+
return atob(str);
|
|
434
|
+
}
|
|
435
|
+
}
|
|
436
|
+
/** @nocollapse */ /** @nocollapse */ DaffBrowserBase64Service.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.0", ngImport: i0, type: DaffBrowserBase64Service, deps: [{ token: PLATFORM_ID }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
437
|
+
/** @nocollapse */ /** @nocollapse */ DaffBrowserBase64Service.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.3.0", ngImport: i0, type: DaffBrowserBase64Service, providedIn: 'root' });
|
|
438
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.0", ngImport: i0, type: DaffBrowserBase64Service, decorators: [{
|
|
439
|
+
type: Injectable,
|
|
440
|
+
args: [{
|
|
441
|
+
providedIn: 'root',
|
|
442
|
+
}]
|
|
443
|
+
}], ctorParameters: function () {
|
|
444
|
+
return [{ type: undefined, decorators: [{
|
|
445
|
+
type: Inject,
|
|
446
|
+
args: [PLATFORM_ID]
|
|
447
|
+
}] }];
|
|
448
|
+
} });
|
|
449
|
+
|
|
450
|
+
/**
|
|
451
|
+
* A token which creates a base64 service appropriate for the current environment, i.e., browser vs. server.
|
|
452
|
+
*/
|
|
453
|
+
const DaffBase64ServiceToken = new InjectionToken('DaffBase64Service', {
|
|
454
|
+
providedIn: 'root',
|
|
455
|
+
factory: () => isPlatformBrowser(inject(PLATFORM_ID))
|
|
456
|
+
? new DaffBrowserBase64Service(inject(PLATFORM_ID))
|
|
457
|
+
: new DaffServerBase64Service(inject(PLATFORM_ID)),
|
|
458
|
+
});
|
|
459
|
+
|
|
460
|
+
/**
|
|
461
|
+
* Generated bundle index. Do not edit.
|
|
462
|
+
*/
|
|
463
|
+
|
|
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 };
|
|
465
|
+
//# sourceMappingURL=daffodil-core.mjs.map
|