@dereekb/util 5.2.0 → 6.0.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/CHANGELOG.md +39 -0
- package/package.json +1 -1
- package/src/lib/auth/auth.role.claims.js +2 -2
- package/src/lib/auth/auth.role.claims.js.map +1 -1
- package/src/lib/error/error.server.d.ts +4 -1
- package/src/lib/error/error.server.js +5 -1
- package/src/lib/error/error.server.js.map +1 -1
- package/src/lib/getter/getter.d.ts +1 -1
- package/src/lib/getter/index.d.ts +1 -0
- package/src/lib/getter/index.js +1 -0
- package/src/lib/getter/index.js.map +1 -1
- package/src/lib/getter/type.d.ts +5 -0
- package/src/lib/getter/type.js +3 -0
- package/src/lib/getter/type.js.map +1 -0
- package/src/lib/iterable/iterable.d.ts +11 -2
- package/src/lib/iterable/iterable.js +19 -5
- package/src/lib/iterable/iterable.js.map +1 -1
- package/src/lib/service/index.d.ts +1 -0
- package/src/lib/service/index.js +1 -0
- package/src/lib/service/index.js.map +1 -1
- package/src/lib/service/typed.service.d.ts +30 -0
- package/src/lib/service/typed.service.js +41 -0
- package/src/lib/service/typed.service.js.map +1 -0
- package/src/lib/set/set.d.ts +15 -2
- package/src/lib/set/set.js +30 -4
- package/src/lib/set/set.js.map +1 -1
- package/src/lib/type.d.ts +11 -1
- package/src/lib/value/maybe.d.ts +21 -0
- package/src/lib/value/maybe.js +9 -1
- package/src/lib/value/maybe.js.map +1 -1
- package/test/CHANGELOG.md +12 -0
- package/test/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,45 @@
|
|
|
2
2
|
|
|
3
3
|
This file was generated using [@jscutlery/semver](https://github.com/jscutlery/semver).
|
|
4
4
|
|
|
5
|
+
# [6.0.0](https://github.com/dereekb/dbx-components/compare/v5.3.0-dev...v6.0.0) (2022-06-03)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
### Bug Fixes
|
|
9
|
+
|
|
10
|
+
* added asIterable to handle strings ([9d5b785](https://github.com/dereekb/dbx-components/commit/9d5b7854b6ce4f3c08b4b36fa75419fb97e8d548))
|
|
11
|
+
* hasAuthRoleHook fix ([e4749ba](https://github.com/dereekb/dbx-components/commit/e4749bae9a657d7cdc82974d129211392261aa3c))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
### Features
|
|
15
|
+
|
|
16
|
+
* added ContextGrantedModelRolesReader ([6fba1cc](https://github.com/dereekb/dbx-components/commit/6fba1cc637beeff55523df599eb88391352f9f58))
|
|
17
|
+
* added FirebaseModelService ([3876575](https://github.com/dereekb/dbx-components/commit/387657559a86908eee57326b655c63a0a836c239))
|
|
18
|
+
* added firebaseModelsService ([7432e55](https://github.com/dereekb/dbx-components/commit/7432e55111cec66a239856ecb2db6adfc9e9780d))
|
|
19
|
+
* added grantedRoleMapReader ([11d2f17](https://github.com/dereekb/dbx-components/commit/11d2f1786f06024dfbbbfd9ac00e48791cbc0521))
|
|
20
|
+
* added OnCallDeleteModel ([358189d](https://github.com/dereekb/dbx-components/commit/358189d6db6ef7d8db93d6dd881d29cc724dd083))
|
|
21
|
+
* added orderByDocumentId, startAtValue, endAtValue constraints ([c846fee](https://github.com/dereekb/dbx-components/commit/c846feef6c26a3818bb006a807b6e931b7b14eaf))
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
# [5.3.0](https://github.com/dereekb/dbx-components/compare/v5.2.1-dev...v5.3.0) (2022-05-30)
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
### Bug Fixes
|
|
29
|
+
|
|
30
|
+
* fixed dbxActionEnforceModifiedDirective ([f889b87](https://github.com/dereekb/dbx-components/commit/f889b87463443024c718786e866ad9c9414a3662))
|
|
31
|
+
* isIterable and useIterableOrValue treat string as a value ([388d6f0](https://github.com/dereekb/dbx-components/commit/388d6f022cf2937a9883df6a549167340243ac0e))
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
### Features
|
|
35
|
+
|
|
36
|
+
* added authRolesObsWithClaimsService ([10055ae](https://github.com/dereekb/dbx-components/commit/10055ae9f4260211b291419134ba637e9f902893))
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
## [5.2.1](https://github.com/dereekb/dbx-components/compare/v5.2.0-dev...v5.2.1) (2022-05-29)
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
|
|
5
44
|
# [5.2.0](https://github.com/dereekb/dbx-components/compare/v5.1.0-dev...v5.2.0) (2022-05-29)
|
|
6
45
|
|
|
7
46
|
|
package/package.json
CHANGED
|
@@ -59,7 +59,7 @@ function authRoleClaimsService(config, defaults = {}) {
|
|
|
59
59
|
entry.claimKey = x[0];
|
|
60
60
|
return [x[0], entry];
|
|
61
61
|
});
|
|
62
|
-
const
|
|
62
|
+
const authRoleMap = new Map(tuples.map((x) => [x[0].toLowerCase(), x[1]]));
|
|
63
63
|
const toClaims = (roles) => {
|
|
64
64
|
const claims = {};
|
|
65
65
|
// iterate by each claim value to build the claims.
|
|
@@ -74,7 +74,7 @@ function authRoleClaimsService(config, defaults = {}) {
|
|
|
74
74
|
const roles = new Set();
|
|
75
75
|
(0, object_1.forEachKeyValue)(claims, {
|
|
76
76
|
forEach: ([claimsKey, value]) => {
|
|
77
|
-
const entry =
|
|
77
|
+
const entry = authRoleMap.get(claimsKey);
|
|
78
78
|
if (entry != null) {
|
|
79
79
|
const decodedRoles = entry.decodeRolesFromValue(value);
|
|
80
80
|
(0, set_1.addToSet)(roles, decodedRoles);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auth.role.claims.js","sourceRoot":"","sources":["../../../../../../packages/util/src/lib/auth/auth.role.claims.ts"],"names":[],"mappings":";;;AACA,6CAA2G;AAC3G,qDAAsD;AACtD,0CAAuD;AACvD,gCAAwD;AAsH3C,QAAA,oCAAoC,GAAG,CAAC,CAAC;AACzC,QAAA,oCAAoC,GAAG,IAAI,CAAC;AAMzD;;;;;;GAMG;AACH,SAAgB,qBAAqB,CAA6B,MAAsC,EAAE,WA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C7G,OAAO,IAAA,uBAAc,EAAC,gBAAgB,EAAE,EAAE,MAAM,EAAE,EAAE,WAAW,EAAE,iCAAwB,CAAC,IAAI,EAAE,EAAE,CAAkB,CAAC;AACvH,CAAC;AAFD,gCAEC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Maybe } from '../value/maybe';
|
|
2
|
-
import { ReadableError, ReadableDataError, StringErrorCode } from './error';
|
|
2
|
+
import { ReadableError, ReadableDataError, StringErrorCode, CodedError } from './error';
|
|
3
3
|
/**
|
|
4
4
|
* The expected error object returned from the server.
|
|
5
5
|
*/
|
|
@@ -15,6 +15,9 @@ export interface ServerErrorResponseData extends ReadableError {
|
|
|
15
15
|
export interface ServerError<T = ServerErrorResponseData> extends ReadableDataError<T> {
|
|
16
16
|
status: number;
|
|
17
17
|
}
|
|
18
|
+
export interface ServerErrorMakeConfig<T> extends ServerError<T>, Partial<CodedError> {
|
|
19
|
+
}
|
|
20
|
+
export declare function serverError<T>(config: ServerErrorMakeConfig<T>): ServerError<T>;
|
|
18
21
|
/**
|
|
19
22
|
* Base server-error class.
|
|
20
23
|
*/
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.UnauthorizedServerErrorResponse = exports.ServerErrorResponse = void 0;
|
|
3
|
+
exports.UnauthorizedServerErrorResponse = exports.ServerErrorResponse = exports.serverError = void 0;
|
|
4
|
+
function serverError(config) {
|
|
5
|
+
return Object.assign(Object.assign({}, config), { data: config.data });
|
|
6
|
+
}
|
|
7
|
+
exports.serverError = serverError;
|
|
4
8
|
/**
|
|
5
9
|
* Base server-error class.
|
|
6
10
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"error.server.js","sourceRoot":"","sources":["../../../../../../packages/util/src/lib/error/error.server.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"error.server.js","sourceRoot":"","sources":["../../../../../../packages/util/src/lib/error/error.server.ts"],"names":[],"mappings":";;;AAsBA,SAAgB,WAAW,CAAI,MAAgC;IAC7D,uCACK,MAAM,KACT,IAAI,EAAE,MAAM,CAAC,IAAI,IACjB;AACJ,CAAC;AALD,kCAKC;AAED;;GAEG;AACH,MAAa,mBAAmB;IAM9B,YAAY,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,EAAkB;QACzD,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IACnB,CAAC;CACF;AAZD,kDAYC;AAED,MAAa,+BAAgC,SAAQ,mBAAmB;IACtE,YAAY,EAAE,IAAI,EAAE,IAAI,EAAE,OAAO,EAAwB;QACvD,KAAK,CAAC,EAAE,MAAM,EAAE,GAAG,EAAE,OAAO,EAAE,OAAO,aAAP,OAAO,cAAP,OAAO,GAAI,cAAc,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC;IACzE,CAAC;CACF;AAJD,0EAIC"}
|
|
@@ -9,7 +9,7 @@ export declare type Factory<T> = Getter<T>;
|
|
|
9
9
|
/**
|
|
10
10
|
* Function that returns a value with an optional single argument.
|
|
11
11
|
*/
|
|
12
|
-
export declare type FactoryWithInput<
|
|
12
|
+
export declare type FactoryWithInput<O, I> = (args?: I) => O;
|
|
13
13
|
/**
|
|
14
14
|
* Function that returns a value with a single argument.
|
|
15
15
|
*/
|
package/src/lib/getter/index.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const tslib_1 = require("tslib");
|
|
4
|
+
tslib_1.__exportStar(require("./type"), exports);
|
|
4
5
|
tslib_1.__exportStar(require("./getter"), exports);
|
|
5
6
|
tslib_1.__exportStar(require("./getter.cache"), exports);
|
|
6
7
|
tslib_1.__exportStar(require("./getter.map"), exports);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../packages/util/src/lib/getter/index.ts"],"names":[],"mappings":";;;AAAA,mDAAyB;AACzB,yDAA+B;AAC/B,uDAA6B"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../packages/util/src/lib/getter/index.ts"],"names":[],"mappings":";;;AAAA,iDAAuB;AACvB,mDAAyB;AACzB,yDAA+B;AAC/B,uDAA6B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"type.js","sourceRoot":"","sources":["../../../../../../packages/util/src/lib/getter/type.ts"],"names":[],"mappings":""}
|
|
@@ -1,12 +1,21 @@
|
|
|
1
1
|
import { Maybe } from '../value/maybe';
|
|
2
|
+
/**
|
|
3
|
+
* An Iterable or a value.
|
|
4
|
+
*
|
|
5
|
+
* Note that strings are a valid Iterable, allowing iteration over characters.
|
|
6
|
+
*/
|
|
2
7
|
export declare type IterableOrValue<T> = T | Iterable<T>;
|
|
8
|
+
export declare function asIterable<T = unknown>(values: IterableOrValue<T>, treatStringAsIterable?: boolean): Iterable<T>;
|
|
3
9
|
/**
|
|
4
10
|
* Returns true if the input is an Iterable.
|
|
5
11
|
*
|
|
12
|
+
* Can specify whether or not to treat string values as iterable values. Is false by default.
|
|
13
|
+
*
|
|
6
14
|
* @param values
|
|
15
|
+
* @param treatStringAsIterable
|
|
7
16
|
* @returns
|
|
8
17
|
*/
|
|
9
|
-
export declare function isIterable<T = unknown>(values: unknown): values is Iterable<T>;
|
|
18
|
+
export declare function isIterable<T = unknown>(values: unknown, treatStringAsIterable?: boolean): values is Iterable<T>;
|
|
10
19
|
/**
|
|
11
20
|
* Returns the first value from the Iterable. If there are no values, returns undefined. Order is not guranteed.
|
|
12
21
|
*
|
|
@@ -35,7 +44,7 @@ export declare function forEachInIterable<T>(values: Iterable<T>, fn: (value: T)
|
|
|
35
44
|
* @param values
|
|
36
45
|
* @param fn
|
|
37
46
|
*/
|
|
38
|
-
export declare function useIterableOrValue<T>(values: Maybe<IterableOrValue<T>>, fn: (value: T) => void): void;
|
|
47
|
+
export declare function useIterableOrValue<T>(values: Maybe<IterableOrValue<T>>, fn: (value: T) => void, treatStringAsIterable?: boolean): void;
|
|
39
48
|
/**
|
|
40
49
|
* Find the first matching value in the Iterable.
|
|
41
50
|
*
|
|
@@ -1,15 +1,29 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.existsInIterable = exports.findInIterable = exports.useIterableOrValue = exports.forEachInIterable = exports.takeValuesFromIterable = exports.firstValueFromIterable = exports.isIterable = void 0;
|
|
3
|
+
exports.existsInIterable = exports.findInIterable = exports.useIterableOrValue = exports.forEachInIterable = exports.takeValuesFromIterable = exports.firstValueFromIterable = exports.isIterable = exports.asIterable = void 0;
|
|
4
4
|
// MARK: Functions
|
|
5
|
+
function asIterable(values, treatStringAsIterable) {
|
|
6
|
+
let iterable;
|
|
7
|
+
if (isIterable(values, treatStringAsIterable)) {
|
|
8
|
+
iterable = values;
|
|
9
|
+
}
|
|
10
|
+
else {
|
|
11
|
+
iterable = [values];
|
|
12
|
+
}
|
|
13
|
+
return iterable;
|
|
14
|
+
}
|
|
15
|
+
exports.asIterable = asIterable;
|
|
5
16
|
/**
|
|
6
17
|
* Returns true if the input is an Iterable.
|
|
7
18
|
*
|
|
19
|
+
* Can specify whether or not to treat string values as iterable values. Is false by default.
|
|
20
|
+
*
|
|
8
21
|
* @param values
|
|
22
|
+
* @param treatStringAsIterable
|
|
9
23
|
* @returns
|
|
10
24
|
*/
|
|
11
|
-
function isIterable(values) {
|
|
12
|
-
if (values && values[Symbol.iterator]) {
|
|
25
|
+
function isIterable(values, treatStringAsIterable = false) {
|
|
26
|
+
if (values && values[Symbol.iterator] && (treatStringAsIterable || typeof values !== 'string')) {
|
|
13
27
|
return true;
|
|
14
28
|
}
|
|
15
29
|
else {
|
|
@@ -68,9 +82,9 @@ exports.forEachInIterable = forEachInIterable;
|
|
|
68
82
|
* @param values
|
|
69
83
|
* @param fn
|
|
70
84
|
*/
|
|
71
|
-
function useIterableOrValue(values, fn) {
|
|
85
|
+
function useIterableOrValue(values, fn, treatStringAsIterable = false) {
|
|
72
86
|
if (values != null) {
|
|
73
|
-
if (isIterable(values)) {
|
|
87
|
+
if (isIterable(values, treatStringAsIterable)) {
|
|
74
88
|
forEachInIterable(values, fn);
|
|
75
89
|
}
|
|
76
90
|
else {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"iterable.js","sourceRoot":"","sources":["../../../../../../packages/util/src/lib/iterable/iterable.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"iterable.js","sourceRoot":"","sources":["../../../../../../packages/util/src/lib/iterable/iterable.ts"],"names":[],"mappings":";;;AAUA,kBAAkB;AAClB,SAAgB,UAAU,CAAc,MAA0B,EAAE,qBAA+B;IACjG,IAAI,QAAqB,CAAC;IAE1B,IAAI,UAAU,CAAC,MAAM,EAAE,qBAAqB,CAAC,EAAE;QAC7C,QAAQ,GAAG,MAAM,CAAC;KACnB;SAAM;QACL,QAAQ,GAAG,CAAC,MAAM,CAAC,CAAC;KACrB;IAED,OAAO,QAAQ,CAAC;AAClB,CAAC;AAVD,gCAUC;AAED;;;;;;;;GAQG;AACH,SAAgB,UAAU,CAAc,MAAe,EAAE,qBAAqB,GAAG,KAAK;IACpF,IAAI,MAAM,IAAK,MAAsB,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,qBAAqB,IAAI,OAAO,MAAM,KAAK,QAAQ,CAAC,EAAE;QAC/G,OAAO,IAAI,CAAC;KACb;SAAM;QACL,OAAO,KAAK,CAAC;KACd;AACH,CAAC;AAND,gCAMC;AAED;;;;;GAKG;AACH,SAAgB,sBAAsB,CAAI,MAAmB;IAC3D,KAAK,MAAM,KAAK,IA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AE;QAC1B,IAAI,EAAE,CAAC,KAAK,CAAC,EAAE;YACb,OAAO,IAAI,CAAC;SACb;KACF;IAED,OAAO,KAAK,CAAC;AACf,CAAC;AARD,4CAQC"}
|
package/src/lib/service/index.js
CHANGED
|
@@ -3,4 +3,5 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
const tslib_1 = require("tslib");
|
|
4
4
|
tslib_1.__exportStar(require("./handler"), exports);
|
|
5
5
|
tslib_1.__exportStar(require("./handler.config"), exports);
|
|
6
|
+
tslib_1.__exportStar(require("./typed.service"), exports);
|
|
6
7
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../packages/util/src/lib/service/index.ts"],"names":[],"mappings":";;;AAAA,oDAA0B;AAC1B,2DAAiC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../packages/util/src/lib/service/index.ts"],"names":[],"mappings":";;;AAAA,oDAA0B;AAC1B,2DAAiC;AACjC,0DAAgC"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { GetterOrValue } from '../getter/getter';
|
|
2
|
+
/**
|
|
3
|
+
* Registry used to load model services when requested.
|
|
4
|
+
*/
|
|
5
|
+
export interface TypedServiceRegistry<S, T extends string = string> {
|
|
6
|
+
/**
|
|
7
|
+
* Returns the service for the type. If a service is not registered, will throw an exception.
|
|
8
|
+
*
|
|
9
|
+
* @param type
|
|
10
|
+
*/
|
|
11
|
+
serviceForType(type: T): S;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* TypedServiceRegistry implementation.
|
|
15
|
+
*/
|
|
16
|
+
export declare class TypedServiceRegistryInstance<S, T extends string = string> implements TypedServiceRegistry<S, T> {
|
|
17
|
+
private _map;
|
|
18
|
+
registerServiceForType(type: T, service: GetterOrValue<S>): void;
|
|
19
|
+
serviceForType(type: T): S;
|
|
20
|
+
}
|
|
21
|
+
export interface TypedServiceRegistrySetupConfig<S, T extends string = string> {
|
|
22
|
+
services: {
|
|
23
|
+
[K in T]: S;
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Creates a new TypedServiceRegistryInstance and registers the input types.
|
|
28
|
+
* @returns
|
|
29
|
+
*/
|
|
30
|
+
export declare function typedServiceRegistry<S, T extends string = string>(config: TypedServiceRegistrySetupConfig<S, T>): TypedServiceRegistryInstance<S, T>;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.typedServiceRegistry = exports.TypedServiceRegistryInstance = void 0;
|
|
4
|
+
const getter_1 = require("../getter/getter");
|
|
5
|
+
const object_1 = require("../object/object");
|
|
6
|
+
/**
|
|
7
|
+
* TypedServiceRegistry implementation.
|
|
8
|
+
*/
|
|
9
|
+
class TypedServiceRegistryInstance {
|
|
10
|
+
constructor() {
|
|
11
|
+
this._map = new Map();
|
|
12
|
+
}
|
|
13
|
+
registerServiceForType(type, service) {
|
|
14
|
+
const getter = (0, getter_1.asGetter)(service);
|
|
15
|
+
this._map.set(type, getter);
|
|
16
|
+
}
|
|
17
|
+
serviceForType(type) {
|
|
18
|
+
const getter = this._map.get(type);
|
|
19
|
+
const service = getter === null || getter === void 0 ? void 0 : getter();
|
|
20
|
+
if (service == null) {
|
|
21
|
+
throw new Error(`no service registered for type "${type}"`);
|
|
22
|
+
}
|
|
23
|
+
return service;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
exports.TypedServiceRegistryInstance = TypedServiceRegistryInstance;
|
|
27
|
+
/**
|
|
28
|
+
* Creates a new TypedServiceRegistryInstance and registers the input types.
|
|
29
|
+
* @returns
|
|
30
|
+
*/
|
|
31
|
+
function typedServiceRegistry(config) {
|
|
32
|
+
const instance = new TypedServiceRegistryInstance();
|
|
33
|
+
(0, object_1.forEachKeyValue)(config.services, {
|
|
34
|
+
forEach: ([key, service]) => {
|
|
35
|
+
instance.registerServiceForType(key, service);
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
return instance;
|
|
39
|
+
}
|
|
40
|
+
exports.typedServiceRegistry = typedServiceRegistry;
|
|
41
|
+
//# sourceMappingURL=typed.service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"typed.service.js","sourceRoot":"","sources":["../../../../../../packages/util/src/lib/service/typed.service.ts"],"names":[],"mappings":";;;AAAA,6CAAmE;AACnE,6CAAmD;AAcnD;;GAEG;AACH,MAAa,4BAA4B;IAAzC;QACU,SAAI,GAAG,IAAI,GAAG,EAAgB,CAAC;IAiBzC,CAAC;IAfC,sBAAsB,CAAC,IAAO,EAAE,OAAyB;QACvD,MAAM,MAAM,GAAG,IAAA,iBAAQ,EAAC,OAAO,CAAC,CAAC;QACjC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;IAC9B,CAAC;IAED,cAAc,CAAC,IAAO;QACpB,MAAM,MAAM,GAAG,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;QACnC,MAAM,OAAO,GAAG,MAAM,aAAN,MAAM,uBAAN,MAAM,EAAI,CAAC;QAE3B,IAAI,OAAO,IAAI,IAAI,EAAE;YACnB,MAAM,IAAI,KAAK,CAAC,mCAAmC,IAAI,GAAG,CAAC,CAAC;SAC7D;QAED,OAAO,OAAO,CAAC;IACjB,CAAC;CACF;AAlBD,oEAkBC;AAQD;;;GAGG;AACH,SAAgB,oBAAoB,CAA+B,MAA6C;IAC9G,MAAM,QAAQ,GAAG,IAAI,4BAA4B,EAAQ,CAAC;IAE1D,IAAA,wBAAe,EAAC,MAAM,CAAC,QAAQ,EAAE;QAC/B,OAAO,EAAE,CAAC,CAAC,GAAG,EAAE,OAAO,CAAC,EAAE,EAAE;YAC1B,QAAQ,CAAC,sBAAsB,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;QAChD,CAAC;KACF,CAAC,CAAC;IAEH,OAAO,QAAQ,CAAC;AAClB,CAAC;AAVD,oDAUC"}
|
package/src/lib/set/set.d.ts
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
import { Maybe } from '../value/maybe';
|
|
2
2
|
import { IterableOrValue } from '../iterable/iterable';
|
|
3
3
|
export declare function asSet<T>(values: IterableOrValue<T>): Set<T>;
|
|
4
|
+
export declare function copySetAndDo<T>(set: Set<T>, fn: (set: Set<T>) => void): Set<T>;
|
|
5
|
+
export declare function addToSetCopy<T>(set: Set<T>, values: Maybe<IterableOrValue<T>>): Set<T>;
|
|
4
6
|
export declare function addToSet<T>(set: Set<T>, values: Maybe<IterableOrValue<T>>): void;
|
|
7
|
+
export declare function removeFromSetCopy<T>(set: Set<T>, values: Maybe<IterableOrValue<T>>): Set<T>;
|
|
5
8
|
export declare function removeFromSet<T>(set: Set<T>, values: Maybe<IterableOrValue<T>>): void;
|
|
6
9
|
export declare function hasDifferentValues<T>(a: Maybe<Iterable<T>>, b: Maybe<Iterable<T>>): boolean;
|
|
7
10
|
export declare function symmetricDifferenceKeys<T>(a: Maybe<Iterable<T>>, b: Maybe<Iterable<T>>): Maybe<T>[];
|
|
@@ -12,8 +15,9 @@ export declare function excludeValuesFromSet<T>(values: T[], set: Set<T>): T[];
|
|
|
12
15
|
export declare function filterValuesFromSet<T>(values: T[], set: Set<T>, exclude?: boolean): T[];
|
|
13
16
|
/**
|
|
14
17
|
* Set inclusion comparison type.
|
|
15
|
-
* - all:
|
|
16
|
-
* -
|
|
18
|
+
* - all: The set must include all values from values (set is a subset of values)
|
|
19
|
+
* - all_reverse: All values must be included in the set (values is a subset of set)
|
|
20
|
+
* - any: Any value from values is in the set
|
|
17
21
|
*/
|
|
18
22
|
export declare type SetIncludesMode = 'all' | 'any';
|
|
19
23
|
/**
|
|
@@ -28,6 +32,15 @@ export declare type SetIncludesFunction<T> = (valuesToFind: Iterable<T>) => bool
|
|
|
28
32
|
* @param mode
|
|
29
33
|
*/
|
|
30
34
|
export declare function setIncludesFunction<T>(valuesSet: Set<T>, mode?: SetIncludesMode): SetIncludesFunction<T>;
|
|
35
|
+
/**
|
|
36
|
+
* Convenience function for calling setIncludesFunction() and passing the result a value, checking for includion.
|
|
37
|
+
*
|
|
38
|
+
* @param valuesSet
|
|
39
|
+
* @param valuesToFind
|
|
40
|
+
* @param mode
|
|
41
|
+
* @returns
|
|
42
|
+
*/
|
|
43
|
+
export declare function setIncludes<T>(valuesSet: Set<T>, valuesToFind: Iterable<T>, mode?: SetIncludesMode): boolean;
|
|
31
44
|
/**
|
|
32
45
|
* Returns true if the input array contains any value from the second array.
|
|
33
46
|
*/
|
package/src/lib/set/set.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.setContainsAllValues = exports.containsAllValues = exports.setContainsAnyValue = exports.containsAnyValueFromSet = exports.containsAnyValue = exports.setIncludesFunction = exports.filterValuesFromSet = exports.excludeValuesFromSet = exports.keepValuesFromSet = exports.flattenArrayToSet = exports.symmetricDifferenceKeysSet = exports.symmetricDifferenceKeys = exports.hasDifferentValues = exports.removeFromSet = exports.addToSet = exports.asSet = void 0;
|
|
3
|
+
exports.setContainsAllValues = exports.containsAllValues = exports.setContainsAnyValue = exports.containsAnyValueFromSet = exports.containsAnyValue = exports.setIncludes = exports.setIncludesFunction = exports.filterValuesFromSet = exports.excludeValuesFromSet = exports.keepValuesFromSet = exports.flattenArrayToSet = exports.symmetricDifferenceKeysSet = exports.symmetricDifferenceKeys = exports.hasDifferentValues = exports.removeFromSet = exports.removeFromSetCopy = exports.addToSet = exports.addToSetCopy = exports.copySetAndDo = exports.asSet = void 0;
|
|
4
4
|
const array_1 = require("../array/array");
|
|
5
5
|
const iterable_1 = require("../iterable/iterable");
|
|
6
6
|
const extra_set_1 = require("extra-set");
|
|
@@ -16,10 +16,24 @@ function asSet(values) {
|
|
|
16
16
|
return set;
|
|
17
17
|
}
|
|
18
18
|
exports.asSet = asSet;
|
|
19
|
+
function copySetAndDo(set, fn) {
|
|
20
|
+
const newSet = new Set(set);
|
|
21
|
+
fn(newSet);
|
|
22
|
+
return newSet;
|
|
23
|
+
}
|
|
24
|
+
exports.copySetAndDo = copySetAndDo;
|
|
25
|
+
function addToSetCopy(set, values) {
|
|
26
|
+
return copySetAndDo(set, (x) => addToSet(x, values));
|
|
27
|
+
}
|
|
28
|
+
exports.addToSetCopy = addToSetCopy;
|
|
19
29
|
function addToSet(set, values) {
|
|
20
30
|
(0, iterable_1.useIterableOrValue)(values, (x) => set.add(x));
|
|
21
31
|
}
|
|
22
32
|
exports.addToSet = addToSet;
|
|
33
|
+
function removeFromSetCopy(set, values) {
|
|
34
|
+
return copySetAndDo(set, (x) => removeFromSet(x, values));
|
|
35
|
+
}
|
|
36
|
+
exports.removeFromSetCopy = removeFromSetCopy;
|
|
23
37
|
function removeFromSet(set, values) {
|
|
24
38
|
(0, iterable_1.useIterableOrValue)(values, (x) => set.delete(x));
|
|
25
39
|
}
|
|
@@ -71,11 +85,23 @@ function setIncludesFunction(valuesSet, mode = 'all') {
|
|
|
71
85
|
return (valuesToFind) => fn(valuesSet, valuesToFind);
|
|
72
86
|
}
|
|
73
87
|
exports.setIncludesFunction = setIncludesFunction;
|
|
88
|
+
/**
|
|
89
|
+
* Convenience function for calling setIncludesFunction() and passing the result a value, checking for includion.
|
|
90
|
+
*
|
|
91
|
+
* @param valuesSet
|
|
92
|
+
* @param valuesToFind
|
|
93
|
+
* @param mode
|
|
94
|
+
* @returns
|
|
95
|
+
*/
|
|
96
|
+
function setIncludes(valuesSet, valuesToFind, mode) {
|
|
97
|
+
return setIncludesFunction(valuesSet, mode)(valuesToFind);
|
|
98
|
+
}
|
|
99
|
+
exports.setIncludes = setIncludes;
|
|
74
100
|
/**
|
|
75
101
|
* Returns true if the input array contains any value from the second array.
|
|
76
102
|
*/
|
|
77
103
|
function containsAnyValue(values, valuesToFind) {
|
|
78
|
-
const set = new Set(valuesToFind);
|
|
104
|
+
const set = new Set((0, iterable_1.asIterable)(valuesToFind, false));
|
|
79
105
|
return containsAnyValueFromSet(values, set);
|
|
80
106
|
}
|
|
81
107
|
exports.containsAnyValue = containsAnyValue;
|
|
@@ -84,7 +110,7 @@ function containsAnyValueFromSet(values, valuesToFind) {
|
|
|
84
110
|
}
|
|
85
111
|
exports.containsAnyValueFromSet = containsAnyValueFromSet;
|
|
86
112
|
function setContainsAnyValue(valuesSet, valuesToFind) {
|
|
87
|
-
return valuesSet ? Array.from(valuesToFind).findIndex((x) => valuesSet.has(x)) !== -1 : false;
|
|
113
|
+
return valuesSet ? Array.from((0, iterable_1.asIterable)(valuesToFind)).findIndex((x) => valuesSet.has(x)) !== -1 : false;
|
|
88
114
|
}
|
|
89
115
|
exports.setContainsAnyValue = setContainsAnyValue;
|
|
90
116
|
/**
|
|
@@ -108,7 +134,7 @@ exports.containsAllValues = containsAllValues;
|
|
|
108
134
|
* @returns
|
|
109
135
|
*/
|
|
110
136
|
function setContainsAllValues(valuesSet, valuesToFind) {
|
|
111
|
-
return valuesSet ? Array.from(valuesToFind).findIndex((x) => !valuesSet.has(x)) == -1 : false;
|
|
137
|
+
return valuesSet ? Array.from((0, iterable_1.asIterable)(valuesToFind)).findIndex((x) => !valuesSet.has(x)) == -1 : false;
|
|
112
138
|
}
|
|
113
139
|
exports.setContainsAllValues = setContainsAllValues;
|
|
114
140
|
//# sourceMappingURL=set.js.map
|
package/src/lib/set/set.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"set.js","sourceRoot":"","sources":["../../../../../../packages/util/src/lib/set/set.ts"],"names":[],"mappings":";;;AACA,0CAA8C;AAC9C,
|
|
1
|
+
{"version":3,"file":"set.js","sourceRoot":"","sources":["../../../../../../packages/util/src/lib/set/set.ts"],"names":[],"mappings":";;;AACA,0CAA8C;AAC9C,mDAAuF;AACvF,yCAAg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AK,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC;AAC5G,CAAC;AAFD,kDAEC;AAED;;;;;;GAMG;AACH,SAAgB,iBAAiB,CAAI,MAAmB,EAAE,YAAyB;IACjF,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,MAAM,CAAC,CAAC;IAC5B,OAAO,oBAAoB,CAAC,GAAG,EAAE,YAAY,CAAC,CAAC;AACjD,CAAC;AAHD,8CAGC;AAED;;;;;;;GAOG;AACH,SAAgB,oBAAoB,CAAI,SAAiB,EAAE,YAAyB;IAClF,OAAO,SAAS,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,IAAA,qBAAU,EAAC,YAAY,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC;AAC5G,CAAC;AAFD,oDAEC"}
|
package/src/lib/type.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Merge, PickProperties, StrictOmit, Writable } from 'ts-essentials';
|
|
1
|
+
import { Merge, NonNever, PickProperties, StrictOmit, Writable } from 'ts-essentials';
|
|
2
2
|
/**
|
|
3
3
|
* Class typing, restricted to types that have a constructor via the new keyword.
|
|
4
4
|
*/
|
|
@@ -46,6 +46,16 @@ export declare type RemoveIndex<T> = {
|
|
|
46
46
|
* https://stackoverflow.com/questions/51954558/how-can-i-remove-a-wider-type-from-a-union-type-without-removing-its-subtypes-in/51955852#51955852
|
|
47
47
|
*/
|
|
48
48
|
export declare type KnownKeys<T> = keyof RemoveIndex<T>;
|
|
49
|
+
/**
|
|
50
|
+
* Returns only properties that have string keys.
|
|
51
|
+
*/
|
|
52
|
+
export declare type StringKeyProperties<T> = NonNever<{
|
|
53
|
+
[K in keyof T]: K extends string ? T[K] : never;
|
|
54
|
+
}>;
|
|
55
|
+
/**
|
|
56
|
+
* Returns the name of all keys that are strings.
|
|
57
|
+
*/
|
|
58
|
+
export declare type StringKeyPropertyKeys<T> = keyof StringKeyProperties<T>;
|
|
49
59
|
/**
|
|
50
60
|
* Makes a readonly type able to be configured. Useful for configurating readonly types before they are used.
|
|
51
61
|
*/
|
package/src/lib/value/maybe.d.ts
CHANGED
|
@@ -47,6 +47,27 @@ export declare function hasValueOrNotEmpty(value: number): true;
|
|
|
47
47
|
export declare function hasValueOrNotEmpty(value: ''): false;
|
|
48
48
|
export declare function hasValueOrNotEmpty(value: null): false;
|
|
49
49
|
export declare function hasValueOrNotEmpty(value: undefined): false;
|
|
50
|
+
/**
|
|
51
|
+
* Returns true if the input value is a non-empty string or is true.
|
|
52
|
+
*
|
|
53
|
+
* @param value
|
|
54
|
+
* @returns
|
|
55
|
+
*/
|
|
56
|
+
export declare function isStringOrTrue(value: ''): false;
|
|
57
|
+
export declare function isStringOrTrue(value: false): false;
|
|
58
|
+
export declare function isStringOrTrue(value: null): false;
|
|
59
|
+
export declare function isStringOrTrue(value: undefined): false;
|
|
60
|
+
export declare function isStringOrTrue(value: Maybe<string | boolean>): boolean;
|
|
61
|
+
/**
|
|
62
|
+
* Returns true if the input is not MaybeNot and not an empty string.
|
|
63
|
+
*
|
|
64
|
+
* @param value
|
|
65
|
+
* @returns
|
|
66
|
+
*/
|
|
67
|
+
export declare function isNotNullOrEmptyString<T>(value: ''): false;
|
|
68
|
+
export declare function isNotNullOrEmptyString<T>(value: null): false;
|
|
69
|
+
export declare function isNotNullOrEmptyString<T>(value: undefined): false;
|
|
70
|
+
export declare function isNotNullOrEmptyString<T>(value: Maybe<MaybeNot | '' | T>): value is MaybeSo<T>;
|
|
50
71
|
/**
|
|
51
72
|
* True if the input is MaybeNot.
|
|
52
73
|
*
|
package/src/lib/value/maybe.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.isSameNonNullValue = exports.isDefinedAndNotFalse = exports.isMaybeNotOrTrue = exports.isMaybeSo = exports.isMaybeNot = exports.hasValueOrNotEmpty = exports.hasNonNullValue = void 0;
|
|
3
|
+
exports.isSameNonNullValue = exports.isDefinedAndNotFalse = exports.isMaybeNotOrTrue = exports.isMaybeSo = exports.isMaybeNot = exports.isNotNullOrEmptyString = exports.isStringOrTrue = exports.hasValueOrNotEmpty = exports.hasNonNullValue = void 0;
|
|
4
4
|
function hasNonNullValue(value) {
|
|
5
5
|
return value != null;
|
|
6
6
|
}
|
|
@@ -14,6 +14,14 @@ function hasValueOrNotEmpty(value) {
|
|
|
14
14
|
}
|
|
15
15
|
}
|
|
16
16
|
exports.hasValueOrNotEmpty = hasValueOrNotEmpty;
|
|
17
|
+
function isStringOrTrue(value) {
|
|
18
|
+
return Boolean(value || value !== '');
|
|
19
|
+
}
|
|
20
|
+
exports.isStringOrTrue = isStringOrTrue;
|
|
21
|
+
function isNotNullOrEmptyString(value) {
|
|
22
|
+
return value != null && value !== '';
|
|
23
|
+
}
|
|
24
|
+
exports.isNotNullOrEmptyString = isNotNullOrEmptyString;
|
|
17
25
|
/**
|
|
18
26
|
* True if the input is MaybeNot.
|
|
19
27
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"maybe.js","sourceRoot":"","sources":["../../../../../../packages/util/src/lib/value/maybe.ts"],"names":[],"mappings":";;;AAqCA,SAAgB,eAAe,CAAI,KAAe;IAChD,OAAO,KAAK,IAAI,IAAI,CAAC;AACvB,CAAC;AAFD,0CAEC;AAmBD,SAAgB,kBAAkB,CAAC,KAAc;IAC/C,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE;QACxB,OAAO,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC;KACzB;SAAM;QACL,OAAO,KAAK,IAAI,IAAI,IAAI,KAAK,KAAK,EAAE,CAAC;KACtC;AACH,CAAC;AAND,gDAMC;AAED;;;;;GAKG;AACH,SAAgB,UA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K,KAAK,EAAE,CAAC;AACvC,CAAC;AAFD,wDAEC;AAED;;;;;GAKG;AACH,SAAgB,UAAU,CAAC,KAAc;IACvC,OAAO,KAAK,IAAI,IAAI,CAAC;AACvB,CAAC;AAFD,gCAEC;AAED;;;;;GAKG;AACH,SAAgB,SAAS,CAAI,KAAe;IAC1C,OAAO,KAAK,IAAI,IAAI,CAAC;AACvB,CAAC;AAFD,8BAEC;AAED;;;;;GAKG;AACH,SAAgB,gBAAgB,CAAC,KAAc;IAC7C,OAAO,KAAK,IAAI,IAAI,IAAI,KAAK,KAAK,IAAI,CAAC;AACzC,CAAC;AAFD,4CAEC;AAED;;;;;GAKG;AACH,SAAgB,oBAAoB,CAAC,KAAc;IACjD,OAAO,KAAK,IAAI,IAAI,IAAI,KAAK,KAAK,KAAK,CAAC;AAC1C,CAAC;AAFD,oDAEC;AAED;;;;;;GAMG;AACH,SAAgB,kBAAkB,CAAI,CAAW,EAAE,CAAW;IAC5D,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC;AAC9B,CAAC;AAFD,gDAEC"}
|
package/test/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,18 @@
|
|
|
2
2
|
|
|
3
3
|
This file was generated using [@jscutlery/semver](https://github.com/jscutlery/semver).
|
|
4
4
|
|
|
5
|
+
# [6.0.0](https://github.com/dereekb/dbx-components/compare/v5.3.0-dev...v6.0.0) (2022-06-03)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
# [5.3.0](https://github.com/dereekb/dbx-components/compare/v5.2.1-dev...v5.3.0) (2022-05-30)
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
## [5.2.1](https://github.com/dereekb/dbx-components/compare/v5.2.0-dev...v5.2.1) (2022-05-29)
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
5
17
|
# [5.2.0](https://github.com/dereekb/dbx-components/compare/v5.1.0-dev...v5.2.0) (2022-05-29)
|
|
6
18
|
|
|
7
19
|
|
package/test/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dereekb/util/test",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "6.0.0",
|
|
4
4
|
"main": "./src/index.js",
|
|
5
5
|
"typings": "./src/index.d.ts",
|
|
6
6
|
"dependencies": {},
|
|
7
7
|
"peerDependencies": {
|
|
8
|
-
"@dereekb/util": "
|
|
8
|
+
"@dereekb/util": "6.0.0",
|
|
9
9
|
"make-error": "^1.3.0",
|
|
10
10
|
"extra-set": "^2.2.11",
|
|
11
11
|
"tslib": "^2.0.0"
|