@dereekb/util 13.11.14 → 13.11.15
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/eslint/index.cjs.js +10008 -394
- package/eslint/index.esm.js +9982 -392
- package/eslint/package.json +4 -4
- package/eslint/src/lib/comments.d.ts +14 -3
- package/eslint/src/lib/dbx-tag-families.d.ts +280 -0
- package/eslint/src/lib/index.d.ts +26 -3
- package/eslint/src/lib/jsdoc-parser.d.ts +116 -0
- package/eslint/src/lib/no-inline-string-empty-object-intersection.rule.d.ts +44 -0
- package/eslint/src/lib/no-inline-type-import.rule.d.ts +38 -0
- package/eslint/src/lib/no-sister-re-export.rule.d.ts +69 -0
- package/eslint/src/lib/plugin.d.ts +52 -1
- package/eslint/src/lib/prefer-canonical-jsdoc.rule.d.ts +68 -0
- package/eslint/src/lib/prefer-config-object.rule.d.ts +61 -0
- package/eslint/src/lib/prefer-maybe-type.rule.d.ts +72 -0
- package/eslint/src/lib/prefer-no-side-effects-in-jsdoc.rule.d.ts +1 -1
- package/eslint/src/lib/prefer-suggested-string.rule.d.ts +51 -0
- package/eslint/src/lib/require-constant-naming.rule.d.ts +63 -0
- package/eslint/src/lib/require-dbx-action-companion-tags.rule.d.ts +46 -0
- package/eslint/src/lib/require-dbx-auth-companion-tags.rule.d.ts +45 -0
- package/eslint/src/lib/require-dbx-docs-ui-example-companion-tags.rule.d.ts +42 -0
- package/eslint/src/lib/require-dbx-filter-companion-tags.rule.d.ts +43 -0
- package/eslint/src/lib/require-dbx-form-field-companion-tags.rule.d.ts +46 -0
- package/eslint/src/lib/require-dbx-model-companion-tags.rule.d.ts +46 -0
- package/eslint/src/lib/require-dbx-model-firebase-index-companion-tags.rule.d.ts +44 -0
- package/eslint/src/lib/require-dbx-model-snapshot-field-companion-tags.rule.d.ts +44 -0
- package/eslint/src/lib/require-dbx-pipe-companion-tags.rule.d.ts +43 -0
- package/eslint/src/lib/require-dbx-rule-companion-tags.rule.d.ts +44 -0
- package/eslint/src/lib/require-dbx-util-companion-tags.rule.d.ts +74 -0
- package/eslint/src/lib/require-dbx-web-companion-tags.rule.d.ts +43 -0
- package/eslint/src/lib/require-default-prefix-naming.rule.d.ts +60 -0
- package/eslint/src/lib/require-deprecated-alias-placement.rule.d.ts +75 -0
- package/eslint/src/lib/require-exported-jsdoc-example.rule.d.ts +61 -0
- package/eslint/src/lib/require-no-side-effects.rule.d.ts +1 -1
- package/eslint/src/lib/require-readonly-config-params.rule.d.ts +57 -0
- package/eslint/src/lib/require-single-return.rule.d.ts +42 -0
- package/fetch/index.cjs.js +95 -80
- package/fetch/index.esm.js +95 -80
- package/fetch/package.json +2 -2
- package/fetch/src/lib/error.d.ts +2 -2
- package/fetch/src/lib/fetch.d.ts +15 -15
- package/fetch/src/lib/fetch.file.d.ts +5 -5
- package/fetch/src/lib/fetch.limit.d.ts +2 -2
- package/fetch/src/lib/fetch.page.d.ts +1 -1
- package/fetch/src/lib/fetch.page.iterate.d.ts +4 -4
- package/fetch/src/lib/fetch.type.d.ts +3 -2
- package/fetch/src/lib/fetch.url.d.ts +13 -13
- package/fetch/src/lib/json.d.ts +12 -12
- package/fetch/src/lib/timeout.d.ts +2 -2
- package/fetch/src/lib/url.d.ts +11 -11
- package/index.cjs.js +2592 -2329
- package/index.esm.js +2590 -2327
- package/package.json +1 -1
- package/src/lib/array/array.boolean.d.ts +20 -20
- package/src/lib/array/array.d.ts +73 -72
- package/src/lib/array/array.factory.d.ts +8 -5
- package/src/lib/array/array.filter.d.ts +23 -20
- package/src/lib/array/array.find.d.ts +9 -8
- package/src/lib/array/array.index.d.ts +15 -14
- package/src/lib/array/array.indexed.d.ts +22 -19
- package/src/lib/array/array.make.d.ts +3 -2
- package/src/lib/array/array.map.d.ts +5 -5
- package/src/lib/array/array.number.d.ts +27 -27
- package/src/lib/array/array.random.d.ts +11 -10
- package/src/lib/array/array.set.d.ts +14 -14
- package/src/lib/array/array.string.d.ts +31 -31
- package/src/lib/array/array.unique.d.ts +22 -20
- package/src/lib/array/array.value.d.ts +3 -2
- package/src/lib/assertion/assert.error.d.ts +8 -8
- package/src/lib/assertion/assertion.d.ts +5 -5
- package/src/lib/assertion/assertion.generic.d.ts +3 -3
- package/src/lib/assertion/assertion.number.d.ts +6 -6
- package/src/lib/auth/auth.role.claims.d.ts +12 -11
- package/src/lib/auth/auth.role.d.ts +3 -3
- package/src/lib/auth/pkce.d.ts +2 -2
- package/src/lib/boolean.d.ts +11 -11
- package/src/lib/cache/cache.memoize.d.ts +6 -6
- package/src/lib/contact/domain.d.ts +9 -9
- package/src/lib/contact/email.d.ts +11 -11
- package/src/lib/contact/phone.d.ts +12 -12
- package/src/lib/contact/random.d.ts +11 -9
- package/src/lib/date/date.d.ts +60 -59
- package/src/lib/date/date.time.d.ts +2 -2
- package/src/lib/date/date.unix.d.ts +8 -8
- package/src/lib/date/duration.d.ts +17 -17
- package/src/lib/date/expires.d.ts +29 -27
- package/src/lib/date/hour.d.ts +23 -23
- package/src/lib/date/minute.d.ts +6 -6
- package/src/lib/date/time.d.ts +10 -9
- package/src/lib/date/week.d.ts +32 -31
- package/src/lib/encryption/encryption.object.d.ts +3 -3
- package/src/lib/error/error.d.ts +13 -12
- package/src/lib/error/error.server.d.ts +4 -4
- package/src/lib/file/pdf.d.ts +4 -4
- package/src/lib/filter/filter.d.ts +3 -2
- package/src/lib/function/function.boolean.d.ts +4 -3
- package/src/lib/function/function.forward.d.ts +6 -4
- package/src/lib/getter/getter.d.ts +24 -19
- package/src/lib/getter/getter.map.d.ts +6 -5
- package/src/lib/getter/getter.util.d.ts +3 -2
- package/src/lib/grouping.d.ts +25 -24
- package/src/lib/hash.d.ts +11 -10
- package/src/lib/iterable/iterable.d.ts +39 -39
- package/src/lib/iterable/iterable.map.d.ts +3 -3
- package/src/lib/key.d.ts +16 -16
- package/src/lib/map/map.d.ts +12 -12
- package/src/lib/map/map.intersection.d.ts +3 -3
- package/src/lib/map/map.key.d.ts +16 -14
- package/src/lib/misc/host.d.ts +2 -2
- package/src/lib/model/id.batch.d.ts +4 -3
- package/src/lib/model/id.factory.d.ts +4 -3
- package/src/lib/model/model.conversion.d.ts +19 -14
- package/src/lib/model/model.conversion.field.d.ts +2 -2
- package/src/lib/model/model.copy.d.ts +5 -4
- package/src/lib/model/model.d.ts +48 -46
- package/src/lib/model/model.modify.d.ts +10 -8
- package/src/lib/nodejs/stream.d.ts +6 -5
- package/src/lib/number/bitwise.dencoder.d.ts +12 -12
- package/src/lib/number/bound.d.ts +16 -13
- package/src/lib/number/dollar.d.ts +6 -5
- package/src/lib/number/encoded.d.ts +7 -7
- package/src/lib/number/factory.d.ts +4 -3
- package/src/lib/number/number.d.ts +37 -37
- package/src/lib/number/random.d.ts +11 -10
- package/src/lib/number/round.d.ts +34 -30
- package/src/lib/number/sort.d.ts +3 -2
- package/src/lib/number/transform.d.ts +5 -4
- package/src/lib/object/object.array.d.ts +6 -6
- package/src/lib/object/object.array.delta.d.ts +3 -2
- package/src/lib/object/object.d.ts +12 -12
- package/src/lib/object/object.empty.d.ts +3 -3
- package/src/lib/object/object.equal.d.ts +11 -10
- package/src/lib/object/object.filter.pojo.d.ts +74 -74
- package/src/lib/object/object.filter.tuple.d.ts +26 -26
- package/src/lib/object/object.flatten.d.ts +4 -4
- package/src/lib/object/object.key.d.ts +6 -4
- package/src/lib/object/object.map.d.ts +15 -13
- package/src/lib/page/page.d.ts +5 -5
- package/src/lib/page/page.filter.d.ts +8 -8
- package/src/lib/path/path.d.ts +98 -88
- package/src/lib/promise/callback.d.ts +2 -2
- package/src/lib/promise/is.d.ts +6 -6
- package/src/lib/promise/poll.d.ts +9 -9
- package/src/lib/promise/promise.d.ts +33 -30
- package/src/lib/promise/promise.factory.d.ts +4 -3
- package/src/lib/promise/promise.loop.d.ts +11 -11
- package/src/lib/promise/promise.task.d.ts +6 -5
- package/src/lib/promise/promise.type.d.ts +3 -3
- package/src/lib/promise/use.d.ts +3 -3
- package/src/lib/relation/relation.d.ts +15 -15
- package/src/lib/service/handler.config.d.ts +20 -16
- package/src/lib/service/handler.d.ts +3 -2
- package/src/lib/service/typed.service.d.ts +2 -2
- package/src/lib/set/set.d.ts +62 -59
- package/src/lib/set/set.delta.d.ts +5 -4
- package/src/lib/set/set.hashset.d.ts +5 -5
- package/src/lib/set/set.selection.d.ts +5 -4
- package/src/lib/sort.d.ts +11 -11
- package/src/lib/storage/storage.d.ts +2 -1
- package/src/lib/storage/storage.error.d.ts +4 -4
- package/src/lib/storage/storage.memory.d.ts +7 -7
- package/src/lib/storage/storage.object.d.ts +5 -5
- package/src/lib/string/case.d.ts +6 -6
- package/src/lib/string/char.d.ts +30 -29
- package/src/lib/string/dencoder.d.ts +25 -20
- package/src/lib/string/factory.d.ts +11 -8
- package/src/lib/string/html.d.ts +19 -19
- package/src/lib/string/mimetype.d.ts +9 -8
- package/src/lib/string/prefix.d.ts +8 -8
- package/src/lib/string/replace.d.ts +45 -39
- package/src/lib/string/search.d.ts +5 -4
- package/src/lib/string/sort.d.ts +13 -4
- package/src/lib/string/string.d.ts +44 -43
- package/src/lib/string/transform.d.ts +32 -23
- package/src/lib/string/tree.d.ts +5 -4
- package/src/lib/string/url.d.ts +5 -4
- package/src/lib/tree/tree.array.d.ts +5 -4
- package/src/lib/tree/tree.expand.d.ts +6 -6
- package/src/lib/tree/tree.explore.d.ts +13 -10
- package/src/lib/tree/tree.flatten.d.ts +10 -10
- package/src/lib/type.d.ts +42 -12
- package/src/lib/value/address.d.ts +7 -7
- package/src/lib/value/bound.d.ts +70 -66
- package/src/lib/value/build.d.ts +6 -6
- package/src/lib/value/comparator.d.ts +19 -17
- package/src/lib/value/cron.d.ts +2 -2
- package/src/lib/value/decision.d.ts +6 -5
- package/src/lib/value/equal.d.ts +11 -9
- package/src/lib/value/indexed.d.ts +101 -85
- package/src/lib/value/label.d.ts +2 -2
- package/src/lib/value/map.d.ts +20 -16
- package/src/lib/value/maybe.d.ts +36 -36
- package/src/lib/value/modifier.d.ts +24 -23
- package/src/lib/value/point.d.ts +85 -77
- package/src/lib/value/url.d.ts +2 -2
- package/src/lib/value/use.d.ts +36 -33
- package/src/lib/value/vector.d.ts +15 -14
- package/test/index.cjs.js +41 -36
- package/test/index.esm.js +41 -36
- package/test/package.json +2 -2
- package/test/src/lib/jest/jest.fail.d.ts +2 -2
- package/test/src/lib/shared/shared.d.ts +20 -20
- package/test/src/lib/shared/shared.fail.d.ts +21 -16
- package/test/src/lib/shared/shared.function.d.ts +4 -4
- package/test/src/lib/shared/shared.wrap.d.ts +10 -10
package/src/lib/map/map.d.ts
CHANGED
|
@@ -3,37 +3,37 @@ import { type Maybe } from '../value/maybe.type';
|
|
|
3
3
|
/**
|
|
4
4
|
* Combines multiple Maps into a single Map. Later maps override earlier values for the same key.
|
|
5
5
|
*
|
|
6
|
-
* @param maps -
|
|
7
|
-
* @returns
|
|
6
|
+
* @param maps - Lookups to merge; nullish entries are skipped.
|
|
7
|
+
* @returns Combined lookup with later entries overriding earlier ones per key.
|
|
8
8
|
*/
|
|
9
9
|
export declare function combineMaps<K, T>(...maps: Maybe<Map<K, T>>[]): Map<K, T>;
|
|
10
10
|
/**
|
|
11
11
|
* Sets the same value for one or more keys in a Map.
|
|
12
12
|
*
|
|
13
|
-
* @param map -
|
|
14
|
-
* @param key -
|
|
15
|
-
* @param value -
|
|
16
|
-
* @returns
|
|
13
|
+
* @param map - Lookup that receives the writes in place.
|
|
14
|
+
* @param key - One or more keys to associate with `value`.
|
|
15
|
+
* @param value - Payload assigned to every supplied key.
|
|
16
|
+
* @returns Same `map` reference after the assignments.
|
|
17
17
|
*/
|
|
18
18
|
export declare function setKeysOnMap<K, T>(map: Map<K, T>, key: ArrayOrValue<K>, value: T): Map<K, T>;
|
|
19
19
|
/**
|
|
20
20
|
* Converts a Map to an array of key-value tuples.
|
|
21
21
|
*
|
|
22
|
-
* @param map -
|
|
23
|
-
* @returns
|
|
22
|
+
* @param map - Lookup whose entries should be flattened.
|
|
23
|
+
* @returns Tuple list mirroring the lookup's entry iteration order.
|
|
24
24
|
*/
|
|
25
25
|
export declare function mapToTuples<K, T>(map: Map<K, T>): [K, T][];
|
|
26
26
|
/**
|
|
27
27
|
* Expands a Map with array values into individual key/value tuples.
|
|
28
28
|
*
|
|
29
|
-
* @param map -
|
|
30
|
-
* @returns
|
|
29
|
+
* @param map - Lookup whose values are arrays to expand.
|
|
30
|
+
* @returns Flattened tuples — one per element across every keyed array.
|
|
31
31
|
*/
|
|
32
32
|
export declare function expandArrayMapTuples<K, T>(map: Map<K, T[]>): [K, T][];
|
|
33
33
|
/**
|
|
34
34
|
* Expands tuples where values may be arrays into individual key/value tuples.
|
|
35
35
|
*
|
|
36
|
-
* @param values -
|
|
37
|
-
* @returns
|
|
36
|
+
* @param values - Tuples whose right-hand side may be a single value or an array.
|
|
37
|
+
* @returns Flattened tuples emitting one entry per element on each input tuple.
|
|
38
38
|
*/
|
|
39
39
|
export declare function expandArrayValueTuples<K, T>(values: [K, ArrayOrValue<T>][]): [K, T][];
|
|
@@ -9,8 +9,8 @@ export interface MapKeysIntersectionObject<T> {
|
|
|
9
9
|
* Builds an array from the intersection of an object's keys with the provided keys.
|
|
10
10
|
* For each matching key, the associated value (or values) are added to the result array.
|
|
11
11
|
*
|
|
12
|
-
* @param object -
|
|
13
|
-
* @param keys -
|
|
14
|
-
* @returns
|
|
12
|
+
* @param object - Lookup whose entries should be activated when their keys are requested.
|
|
13
|
+
* @param keys - Requested key set restricting which entries contribute values.
|
|
14
|
+
* @returns Flattened values drawn from entries whose key was requested.
|
|
15
15
|
*/
|
|
16
16
|
export declare function mapKeysIntersectionObjectToArray<T>(object: MapKeysIntersectionObject<T>, keys: Iterable<string>): T[];
|
package/src/lib/map/map.key.d.ts
CHANGED
|
@@ -10,46 +10,48 @@ export type KeyValueMapFactory<T, K extends PrimativeKey = PrimativeKey> = (valu
|
|
|
10
10
|
/**
|
|
11
11
|
* Creates a KeyValueMapFactory that maps values by their key using a ReadKeyFunction.
|
|
12
12
|
*
|
|
13
|
+
* @param read - Function that extracts a key from each value.
|
|
14
|
+
* @returns A factory that creates Maps from arrays of values.
|
|
15
|
+
*
|
|
13
16
|
* @dbxUtil
|
|
14
17
|
* @dbxUtilCategory value
|
|
15
18
|
* @dbxUtilKind factory
|
|
16
19
|
* @dbxUtilTags map, key, factory, lookup, index
|
|
17
20
|
* @dbxUtilRelated multi-key-value-map-factory, read-keys-to-map
|
|
18
21
|
*
|
|
19
|
-
* @param read - Function that extracts a key from each value
|
|
20
|
-
* @returns A factory that creates Maps from arrays of values
|
|
21
22
|
* @__NO_SIDE_EFFECTS__
|
|
22
23
|
*/
|
|
23
24
|
export declare function keyValueMapFactory<T, K extends PrimativeKey = PrimativeKey>(read: ReadKeyFunction<T, K>): KeyValueMapFactory<T, K>;
|
|
24
25
|
/**
|
|
25
26
|
* Reads keys off the input values and places them in a Map using a ReadKeyFunction.
|
|
26
27
|
*
|
|
27
|
-
* @param values -
|
|
28
|
-
* @param read -
|
|
29
|
-
* @returns
|
|
28
|
+
* @param values - Source items whose keys are derived during indexing.
|
|
29
|
+
* @param read - Resolver that extracts the comparison key from each value.
|
|
30
|
+
* @returns Lookup keyed by derived key; the last entry per key wins.
|
|
30
31
|
*/
|
|
31
32
|
export declare function readKeysToMap<T, K extends PrimativeKey = PrimativeKey>(values: T[], read: ReadKeyFunction<T, K>): Map<K, T>;
|
|
32
33
|
/**
|
|
33
34
|
* Creates a KeyValueMapFactory that maps values by multiple keys using a ReadMultipleKeysFunction.
|
|
34
35
|
* Each value can appear under multiple keys.
|
|
35
36
|
*
|
|
37
|
+
* @param read - Function that extracts multiple keys from each value.
|
|
38
|
+
* @returns A factory that creates Maps from arrays of values.
|
|
39
|
+
*
|
|
36
40
|
* @dbxUtil
|
|
37
41
|
* @dbxUtilCategory value
|
|
38
42
|
* @dbxUtilKind factory
|
|
39
43
|
* @dbxUtilTags map, key, multi, factory, lookup, index
|
|
40
44
|
* @dbxUtilRelated key-value-map-factory, read-multiple-keys-to-map
|
|
41
45
|
*
|
|
42
|
-
* @param read - Function that extracts multiple keys from each value
|
|
43
|
-
* @returns A factory that creates Maps from arrays of values
|
|
44
46
|
* @__NO_SIDE_EFFECTS__
|
|
45
47
|
*/
|
|
46
48
|
export declare function multiKeyValueMapFactory<T, K extends PrimativeKey = PrimativeKey>(read: ReadMultipleKeysFunction<T, K>): KeyValueMapFactory<T, K>;
|
|
47
49
|
/**
|
|
48
50
|
* Reads multiple keys off the input values and places them in a Map using a ReadMultipleKeysFunction.
|
|
49
51
|
*
|
|
50
|
-
* @param values -
|
|
51
|
-
* @param read -
|
|
52
|
-
* @returns
|
|
52
|
+
* @param values - Source items whose keys are derived during indexing.
|
|
53
|
+
* @param read - Resolver that extracts every comparison key from each value.
|
|
54
|
+
* @returns Lookup keyed by every derived key; the last entry per key wins.
|
|
53
55
|
*/
|
|
54
56
|
export declare function readMultipleKeysToMap<T, K extends PrimativeKey = PrimativeKey>(values: T[], read: ReadMultipleKeysFunction<T, K>): Map<K, T>;
|
|
55
57
|
/**
|
|
@@ -119,14 +121,14 @@ export interface MultiValueMapBuilder<T, K extends PrimativeKey = PrimativeKey>
|
|
|
119
121
|
/**
|
|
120
122
|
* Creates a new MultiValueMapBuilder for building Maps where each key maps to an array of values.
|
|
121
123
|
*
|
|
122
|
-
* @returns A new MultiValueMapBuilder instance
|
|
124
|
+
* @returns A new MultiValueMapBuilder instance.
|
|
123
125
|
*/
|
|
124
126
|
export declare function multiValueMapBuilder<T, K extends PrimativeKey = PrimativeKey>(): MultiValueMapBuilder<T, K>;
|
|
125
127
|
/**
|
|
126
128
|
* Determines if two maps have the same keys.
|
|
127
129
|
*
|
|
128
|
-
* @param a - The first map
|
|
129
|
-
* @param b - The second map
|
|
130
|
-
* @returns
|
|
130
|
+
* @param a - The first map.
|
|
131
|
+
* @param b - The second map.
|
|
132
|
+
* @returns True if the maps have the same keys, false otherwise.
|
|
131
133
|
*/
|
|
132
134
|
export declare function mapsHaveSameKeys<K>(a: Map<K, unknown>, b: Map<K, unknown>): boolean;
|
package/src/lib/misc/host.d.ts
CHANGED
|
@@ -9,7 +9,7 @@ export interface JoinHostAndPortConfig {
|
|
|
9
9
|
/**
|
|
10
10
|
* Joins the host and port into a "host:port" string.
|
|
11
11
|
*
|
|
12
|
-
* @param config - The host and port configuration, or null/undefined
|
|
13
|
-
* @returns The joined string, or null/undefined if config is null/undefined
|
|
12
|
+
* @param config - The host and port configuration, or null/undefined.
|
|
13
|
+
* @returns The joined string, or null/undefined if config is null/undefined.
|
|
14
14
|
*/
|
|
15
15
|
export declare function joinHostAndPort(config: Maybe<JoinHostAndPortConfig>): Maybe<string>;
|
|
@@ -34,15 +34,16 @@ export type IdBatchFactory<T> = AsyncArrayFactory<T>;
|
|
|
34
34
|
* The factory generates identifiers in batches, filters them for uniqueness, and verifies each batch
|
|
35
35
|
* using the configured verifier. Throws if uniqueness generation fails repeatedly (after 20 attempts).
|
|
36
36
|
*
|
|
37
|
+
* @param config - Configuration with the base factory for generating candidates and the verifier for validating them.
|
|
38
|
+
* @returns An async factory function that produces the requested number of valid identifiers.
|
|
39
|
+
* @throws {Error} If the factory cannot produce enough unique values after repeated attempts.
|
|
40
|
+
*
|
|
37
41
|
* @dbxUtil
|
|
38
42
|
* @dbxUtilCategory model
|
|
39
43
|
* @dbxUtilKind factory
|
|
40
44
|
* @dbxUtilTags model, id, batch, factory, async, unique, identifier
|
|
41
45
|
* @dbxUtilRelated sequential-incrementing-number-string-model-id-factory
|
|
42
46
|
*
|
|
43
|
-
* @param config - Configuration with the base factory for generating candidates and the verifier for validating them
|
|
44
|
-
* @returns An async factory function that produces the requested number of valid identifiers
|
|
45
|
-
* @throws Error if the factory cannot produce enough unique values after repeated attempts
|
|
46
47
|
* @__NO_SIDE_EFFECTS__
|
|
47
48
|
*/
|
|
48
49
|
export declare function idBatchFactory<T, K extends PrimativeKey = PrimativeKey>(config: IdBatchFactoryConfig<T, K>): IdBatchFactory<T>;
|
|
@@ -41,9 +41,9 @@ export interface SequentialIncrementingNumberStringModelIdFactoryConfig {
|
|
|
41
41
|
* {@link NumberStringDencoder} (defaults to base-64). Supports starting from a specific index or continuing
|
|
42
42
|
* from a current index, and an optional transform for post-processing (e.g., padding).
|
|
43
43
|
*
|
|
44
|
-
* @param config - Configuration for the starting index, increment step, dencoder, and transform
|
|
45
|
-
* @returns A factory function that returns the next encoded string identifier on each call
|
|
46
|
-
* @throws Error
|
|
44
|
+
* @param config - Configuration for the starting index, increment step, dencoder, and transform.
|
|
45
|
+
* @returns A factory function that returns the next encoded string identifier on each call.
|
|
46
|
+
* @throws {Error} If `increaseBy` is 0.
|
|
47
47
|
*
|
|
48
48
|
* @dbxUtil
|
|
49
49
|
* @dbxUtilCategory model
|
|
@@ -57,6 +57,7 @@ export interface SequentialIncrementingNumberStringModelIdFactoryConfig {
|
|
|
57
57
|
* const first = factory(); // encoded representation of 0
|
|
58
58
|
* const second = factory(); // encoded representation of 1
|
|
59
59
|
* ```
|
|
60
|
+
*
|
|
60
61
|
* @__NO_SIDE_EFFECTS__
|
|
61
62
|
*/
|
|
62
63
|
export declare function sequentialIncrementingNumberStringModelIdFactory(config?: SequentialIncrementingNumberStringModelIdFactoryConfig): ModelIdFactory;
|
|
@@ -20,14 +20,15 @@ export interface ModelMapFunctions<V extends object, D extends object> {
|
|
|
20
20
|
*
|
|
21
21
|
* The `to` function converts from the model (V) to data (D), while `from` converts back from data (D) to model (V).
|
|
22
22
|
*
|
|
23
|
+
* @param fields - Field conversion definitions for each key in the model.
|
|
24
|
+
* @returns Object with `from` and `to` mapping functions.
|
|
25
|
+
*
|
|
23
26
|
* @dbxUtil
|
|
24
27
|
* @dbxUtilCategory model
|
|
25
28
|
* @dbxUtilKind factory
|
|
26
29
|
* @dbxUtilTags model, conversion, map, factory, bidirectional, fields
|
|
27
30
|
* @dbxUtilRelated to-model-map-functions, modify-model-map-functions, model-field-conversions
|
|
28
31
|
*
|
|
29
|
-
* @param fields - Field conversion definitions for each key in the model
|
|
30
|
-
* @returns Object with `from` and `to` mapping functions
|
|
31
32
|
* @__NO_SIDE_EFFECTS__
|
|
32
33
|
*/
|
|
33
34
|
export declare function makeModelMapFunctions<V extends object, D extends object>(fields: ModelFieldConversions<V, D>): ModelMapFunctions<V, D>;
|
|
@@ -52,14 +53,15 @@ export type ModelConversionFieldValuesFunction<I extends object, O extends objec
|
|
|
52
53
|
*
|
|
53
54
|
* Supports optional filtering by field names and skipping undefined values via {@link ModelConversionOptions}.
|
|
54
55
|
*
|
|
56
|
+
* @param fields - Array of `[key, convertFn]` tuples defining how each field is converted.
|
|
57
|
+
* @returns Reusable converter that applies the per-field transforms to any input record.
|
|
58
|
+
*
|
|
55
59
|
* @dbxUtil
|
|
56
60
|
* @dbxUtilCategory model
|
|
57
61
|
* @dbxUtilKind factory
|
|
58
62
|
* @dbxUtilTags model, conversion, factory, fields, map, transform
|
|
59
63
|
* @dbxUtilRelated make-model-map-functions, model-field-map-functions
|
|
60
64
|
*
|
|
61
|
-
* @param fields - Array of `[key, convertFn]` tuples defining how each field is converted
|
|
62
|
-
* @returns A function that converts an input object to an output object
|
|
63
65
|
* @__NO_SIDE_EFFECTS__
|
|
64
66
|
*/
|
|
65
67
|
export declare function makeModelConversionFieldValuesFunction<I extends object, O extends object>(fields: ModelConversionFieldValuesConfig<I>): ModelConversionFieldValuesFunction<I, O>;
|
|
@@ -78,8 +80,8 @@ export type ModelFieldConversionsConfig<V extends object, D extends object> = Re
|
|
|
78
80
|
/**
|
|
79
81
|
* Converts a {@link ModelFieldConversionsConfig} (with raw config per field) into resolved {@link ModelFieldConversions} (with compiled map functions per field).
|
|
80
82
|
*
|
|
81
|
-
* @param config - Configuration object with a conversion config for each model field
|
|
82
|
-
* @returns Resolved field conversions with compiled `from` and `to` functions
|
|
83
|
+
* @param config - Configuration object with a conversion config for each model field.
|
|
84
|
+
* @returns Resolved field conversions with compiled `from` and `to` functions.
|
|
83
85
|
*/
|
|
84
86
|
export declare function modelFieldConversions<V extends object, D extends object>(config: ModelFieldConversionsConfig<V, D>): ModelFieldConversions<V, D>;
|
|
85
87
|
export type ModelFieldMapFunctions<I = unknown, O = unknown> = {
|
|
@@ -97,14 +99,15 @@ export type ModelFieldMapFunctionsWithDefaultsConfig<I = unknown, O = unknown> =
|
|
|
97
99
|
/**
|
|
98
100
|
* Compiles a {@link ModelFieldMapFunctionsConfig} into resolved {@link ModelFieldMapFunctions} with `from` and `to` mapping functions.
|
|
99
101
|
*
|
|
102
|
+
* @param config - Configuration with `from` and `to` field map configs.
|
|
103
|
+
* @returns Compiled field map functions.
|
|
104
|
+
*
|
|
100
105
|
* @dbxUtil
|
|
101
106
|
* @dbxUtilCategory model
|
|
102
107
|
* @dbxUtilKind factory
|
|
103
108
|
* @dbxUtilTags model, field, map, factory, conversion, bidirectional
|
|
104
109
|
* @dbxUtilRelated model-field-map-function, make-model-map-functions
|
|
105
110
|
*
|
|
106
|
-
* @param config - Configuration with `from` and `to` field map configs
|
|
107
|
-
* @returns Compiled field map functions
|
|
108
111
|
* @__NO_SIDE_EFFECTS__
|
|
109
112
|
*/
|
|
110
113
|
export declare function modelFieldMapFunctions<I = unknown, O = unknown>(config: ModelFieldMapFunctionsConfig<I, O>): ModelFieldMapFunctions<I, O>;
|
|
@@ -147,14 +150,15 @@ export type ModelFieldMapToFunction<I, O> = ModelFieldMapFunction<I, O>;
|
|
|
147
150
|
* - Null/undefined input with `convertMaybe`: delegates to that function
|
|
148
151
|
* - Null/undefined input with `default` or `defaultInput`: uses the appropriate fallback
|
|
149
152
|
*
|
|
153
|
+
* @param config - Configuration specifying how to convert values and handle null/undefined.
|
|
154
|
+
* @returns Reusable mapper that handles concrete and nullish inputs via the configured fallbacks.
|
|
155
|
+
*
|
|
150
156
|
* @dbxUtil
|
|
151
157
|
* @dbxUtilCategory model
|
|
152
158
|
* @dbxUtilKind factory
|
|
153
159
|
* @dbxUtilTags model, field, map, factory, maybe, default, convert
|
|
154
160
|
* @dbxUtilRelated model-field-map-functions, make-model-map-functions
|
|
155
161
|
*
|
|
156
|
-
* @param config - Configuration specifying how to convert values and handle null/undefined
|
|
157
|
-
* @returns A function that maps Maybe input values to output values
|
|
158
162
|
* @__NO_SIDE_EFFECTS__
|
|
159
163
|
*/
|
|
160
164
|
export declare function modelFieldMapFunction<I, O>(config: ModelFieldMapConfig<I, O>): ModelFieldMapFunction<I, O>;
|
|
@@ -170,8 +174,8 @@ export type ToModelFieldConversionsInput<T extends object, O extends object> = M
|
|
|
170
174
|
*
|
|
171
175
|
* Accepts either a pre-built `fieldConversions` reference or a `fields` config that will be compiled.
|
|
172
176
|
*
|
|
173
|
-
* @param input - Either a config ref or a pre-built conversions ref
|
|
174
|
-
* @returns Resolved field conversions
|
|
177
|
+
* @param input - Either a config ref or a pre-built conversions ref.
|
|
178
|
+
* @returns Resolved field conversions.
|
|
175
179
|
*/
|
|
176
180
|
export declare function toModelFieldConversions<T extends object, O extends object>(input: ToModelFieldConversionsInput<T, O>): Required<{ [K in keyof T]: ModelFieldMapFunctions<T[K], ReplaceType<T, O, any>[K]>; }>;
|
|
177
181
|
export type ModelMapFunctionsRef<T extends object, O extends object> = {
|
|
@@ -183,14 +187,15 @@ export type ToModelMapFunctionsInput<T extends object, O extends object> = ToMod
|
|
|
183
187
|
*
|
|
184
188
|
* Accepts a pre-built `mapFunctions` reference, a `fieldConversions` ref, or a `fields` config.
|
|
185
189
|
*
|
|
190
|
+
* @param input - Input that can be resolved to model map functions.
|
|
191
|
+
* @returns Bidirectional model map functions.
|
|
192
|
+
*
|
|
186
193
|
* @dbxUtil
|
|
187
194
|
* @dbxUtilCategory model
|
|
188
195
|
* @dbxUtilKind factory
|
|
189
196
|
* @dbxUtilTags model, conversion, map, factory, normalize, resolve
|
|
190
197
|
* @dbxUtilRelated make-model-map-functions, to-model-field-conversions
|
|
191
198
|
*
|
|
192
|
-
* @param input - Input that can be resolved to model map functions
|
|
193
|
-
* @returns Bidirectional model map functions
|
|
194
199
|
* @__NO_SIDE_EFFECTS__
|
|
195
200
|
*/
|
|
196
201
|
export declare function toModelMapFunctions<T extends object, O extends object>(input: ToModelMapFunctionsInput<T, O>): ModelMapFunctions<T, O>;
|
|
@@ -4,8 +4,8 @@ import { type ModelFieldMapFunctionsConfig } from './model.conversion';
|
|
|
4
4
|
*
|
|
5
5
|
* When the input is null/undefined, the provided default value is used instead.
|
|
6
6
|
*
|
|
7
|
-
* @param defaultOutput - Default value to use when the source value is null/undefined
|
|
8
|
-
* @returns A {@link ModelFieldMapFunctionsConfig} with identity `from` and `to` conversions
|
|
7
|
+
* @param defaultOutput - Default value to use when the source value is null/undefined.
|
|
8
|
+
* @returns A {@link ModelFieldMapFunctionsConfig} with identity `from` and `to` conversions.
|
|
9
9
|
*
|
|
10
10
|
* @example
|
|
11
11
|
* ```ts
|
|
@@ -7,7 +7,7 @@ export interface CopyModelFieldConfig<V = unknown> {
|
|
|
7
7
|
/**
|
|
8
8
|
* Default value if not presented. If default is not defined and there is no value, the key will be ignored entirely.
|
|
9
9
|
*/
|
|
10
|
-
default?: V;
|
|
10
|
+
readonly default?: V;
|
|
11
11
|
}
|
|
12
12
|
/**
|
|
13
13
|
* Used for copying one field from one partial object to a target object.
|
|
@@ -20,15 +20,16 @@ export type CopyModelFieldFunction<T> = (from: Partial<T>, target: Partial<T>) =
|
|
|
20
20
|
* If the field does not exist on the source but a default is configured, the default is used.
|
|
21
21
|
* Otherwise, the target is left unchanged.
|
|
22
22
|
*
|
|
23
|
+
* @param key - The property key to copy.
|
|
24
|
+
* @param inputConfig - Optional config with a default value for the field.
|
|
25
|
+
* @returns Reusable mapper that copies the configured field (or fills in the default) per pair.
|
|
26
|
+
*
|
|
23
27
|
* @dbxUtil
|
|
24
28
|
* @dbxUtilCategory model
|
|
25
29
|
* @dbxUtilKind factory
|
|
26
30
|
* @dbxUtilTags model, copy, field, factory, default
|
|
27
31
|
* @dbxUtilRelated make-model-map-functions, modify-model-map-functions
|
|
28
32
|
*
|
|
29
|
-
* @param key - The property key to copy
|
|
30
|
-
* @param inputConfig - Optional config with a default value for the field
|
|
31
|
-
* @returns A function that copies the field from source to target
|
|
32
33
|
* @__NO_SIDE_EFFECTS__
|
|
33
34
|
*/
|
|
34
35
|
export declare function makeCopyModelFieldFunction<T extends object>(key: keyof T, inputConfig?: Maybe<CopyModelFieldConfig>): CopyModelFieldFunction<T>;
|
package/src/lib/model/model.d.ts
CHANGED
|
@@ -74,8 +74,8 @@ export interface ModelKeyNamePair extends Pick<ModelKeyTypePair, 'key'> {
|
|
|
74
74
|
export interface ModelKeyTypeNamePair<M extends ModelTypeString = ModelTypeString> extends ModelKeyNamePair, ModelKeyTypePair<M> {
|
|
75
75
|
}
|
|
76
76
|
export interface ReadModelKeyParams<T> {
|
|
77
|
-
required?: boolean;
|
|
78
|
-
read: ReadModelKeyFunction<T>;
|
|
77
|
+
readonly required?: boolean;
|
|
78
|
+
readonly read: ReadModelKeyFunction<T>;
|
|
79
79
|
}
|
|
80
80
|
export type ReadModelKeyFunction<T> = ReadKeyFunction<T, ModelKey>;
|
|
81
81
|
export type ReadModelTypeFunction<T, M extends ModelTypeString = ModelTypeString> = ReadKeyFunction<T, M>;
|
|
@@ -84,15 +84,15 @@ export type MultiModelKeyMap<T> = Map<string, T>;
|
|
|
84
84
|
/**
|
|
85
85
|
* Reads the `id` property from a {@link UniqueModel}.
|
|
86
86
|
*
|
|
87
|
-
* @param model - Model to read the key from
|
|
88
|
-
* @returns The model's `id` value
|
|
87
|
+
* @param model - Model to read the key from.
|
|
88
|
+
* @returns The model's `id` value.
|
|
89
89
|
*/
|
|
90
90
|
export declare const readUniqueModelKey: (model: UniqueModel) => string | undefined;
|
|
91
91
|
/**
|
|
92
92
|
* Deduplicates an array of model keys using a Set.
|
|
93
93
|
*
|
|
94
|
-
* @param keys - Array of model keys that may contain duplicates
|
|
95
|
-
* @returns Array containing only unique keys
|
|
94
|
+
* @param keys - Array of model keys that may contain duplicates.
|
|
95
|
+
* @returns Array containing only unique keys.
|
|
96
96
|
*
|
|
97
97
|
* @example
|
|
98
98
|
* ```ts
|
|
@@ -124,11 +124,11 @@ export declare function readModelKeysFromObjects<T extends UniqueModel>(input: T
|
|
|
124
124
|
/**
|
|
125
125
|
* Computes the symmetric difference (elements in either array but not both) between two arrays of models or keys.
|
|
126
126
|
*
|
|
127
|
-
* @param a - First array of models or keys
|
|
128
|
-
* @param b - Second array of models or keys
|
|
129
|
-
* @param required - Whether keys are required
|
|
130
|
-
* @param read - Function to extract keys from models
|
|
131
|
-
* @returns Keys that appear in one array but not the other
|
|
127
|
+
* @param a - First array of models or keys.
|
|
128
|
+
* @param b - Second array of models or keys.
|
|
129
|
+
* @param required - Whether keys are required.
|
|
130
|
+
* @param read - Function to extract keys from models.
|
|
131
|
+
* @returns Keys that appear in one array but not the other.
|
|
132
132
|
*/
|
|
133
133
|
export declare function symmetricDifferenceWithModels<T extends UniqueModel>(a: ModelOrKey<T>[], b: ModelOrKey<T>[], required?: boolean, read?: ReadModelKeyFunction<T>): Maybe<ModelKey>[];
|
|
134
134
|
/**
|
|
@@ -172,14 +172,15 @@ export declare function makeModelMap<T>(input: T[], read: ReadModelKeyFunction<T
|
|
|
172
172
|
*
|
|
173
173
|
* If multiple models share the same relation key, the last one wins for that key.
|
|
174
174
|
*
|
|
175
|
+
* @param input - Array of models to index.
|
|
176
|
+
* @param read - Function that returns an array of relation keys for each model.
|
|
177
|
+
* @returns Map from relation key to model.
|
|
178
|
+
*
|
|
175
179
|
* @dbxUtil
|
|
176
180
|
* @dbxUtilCategory model
|
|
177
181
|
* @dbxUtilTags model, map, key, multi, relation, index, lookup
|
|
178
182
|
* @dbxUtilRelated make-model-map, read-model-key
|
|
179
183
|
*
|
|
180
|
-
* @param input - Array of models to index
|
|
181
|
-
* @param read - Function that returns an array of relation keys for each model
|
|
182
|
-
* @returns Map from relation key to model
|
|
183
184
|
* @__NO_SIDE_EFFECTS__
|
|
184
185
|
*/
|
|
185
186
|
export declare function makeMultiModelKeyMap<T>(input: T[], read: ReadRelationKeysFunction<T>): MultiModelKeyMap<T>;
|
|
@@ -188,13 +189,13 @@ export declare function makeMultiModelKeyMap<T>(input: T[], read: ReadRelationKe
|
|
|
188
189
|
*
|
|
189
190
|
* If the input is null/undefined and `required` is true, throws an error.
|
|
190
191
|
*
|
|
191
|
-
* @param input - A model object or a model key string
|
|
192
|
-
* @param config - Handlers for model and key cases, plus whether input is required
|
|
193
|
-
* @param config.useModel -
|
|
194
|
-
* @param config.useKey -
|
|
195
|
-
* @param config.required -
|
|
196
|
-
* @returns The result of the matched handler, or undefined if input is nullish and not required
|
|
197
|
-
* @throws Error
|
|
192
|
+
* @param input - A model object or a model key string.
|
|
193
|
+
* @param config - Handlers for model and key cases, plus whether input is required.
|
|
194
|
+
* @param config.useModel - Handler invoked when the input is a model object; if omitted, the model's key is passed to `useKey` instead.
|
|
195
|
+
* @param config.useKey - Handler invoked when the input is a model key string.
|
|
196
|
+
* @param config.required - When true, throws an error if the input is nullish; defaults to false.
|
|
197
|
+
* @returns The result of the matched handler, or undefined if input is nullish and not required.
|
|
198
|
+
* @throws {Error} If `required` is true and input is nullish.
|
|
198
199
|
*/
|
|
199
200
|
export declare function useModelOrKey<O, T extends UniqueModel>(input: ModelOrKey<T>, { useModel, useKey, required }: {
|
|
200
201
|
useModel?: (model: T) => O;
|
|
@@ -204,19 +205,19 @@ export declare function useModelOrKey<O, T extends UniqueModel>(input: ModelOrKe
|
|
|
204
205
|
/**
|
|
205
206
|
* Extracts model keys from an array of models or key strings.
|
|
206
207
|
*
|
|
207
|
-
* @param input - Array of models, key strings, or undefined values
|
|
208
|
-
* @param required - Whether keys are required
|
|
209
|
-
* @param read - Function to extract the key from model objects
|
|
210
|
-
* @returns Array of model keys
|
|
208
|
+
* @param input - Array of models, key strings, or undefined values.
|
|
209
|
+
* @param required - Whether keys are required.
|
|
210
|
+
* @param read - Function to extract the key from model objects.
|
|
211
|
+
* @returns Array of model keys.
|
|
211
212
|
*/
|
|
212
|
-
export declare function readModelKeys<T extends UniqueModel>(input:
|
|
213
|
+
export declare function readModelKeys<T extends UniqueModel>(input: Maybe<ModelOrKey<T>>[], required?: boolean, read?: ReadModelKeyFunction<T>): Maybe<ModelKey>[];
|
|
213
214
|
/**
|
|
214
215
|
* Reads a model key from a model or key string. Convenience wrapper around {@link readModelKey} with default params.
|
|
215
216
|
*
|
|
216
|
-
* @param input - A model object or a key string
|
|
217
|
-
* @returns The extracted model key, or undefined if input is undefined
|
|
217
|
+
* @param input - A model object or a key string.
|
|
218
|
+
* @returns The extracted model key, or undefined if input is undefined.
|
|
218
219
|
*/
|
|
219
|
-
export declare function requireModelKey<T extends UniqueModel>(input: ModelOrKey<T
|
|
220
|
+
export declare function requireModelKey<T extends UniqueModel>(input: Maybe<ModelOrKey<T>>): Maybe<ModelKey>;
|
|
220
221
|
/**
|
|
221
222
|
* Reads a model key from a value that may be a model object, a key string, or undefined.
|
|
222
223
|
*
|
|
@@ -227,36 +228,36 @@ export declare function requireModelKey<T extends UniqueModel>(input: ModelOrKey
|
|
|
227
228
|
* @returns The extracted model key, or undefined
|
|
228
229
|
* @throws Error if `required` is true and no key can be extracted
|
|
229
230
|
*/
|
|
230
|
-
export declare function readModelKey<T>(input: ModelOrKey<T
|
|
231
|
-
export declare function readModelKey<T extends UniqueModel>(input: ModelOrKey<T
|
|
231
|
+
export declare function readModelKey<T>(input: Maybe<ModelOrKey<T>>, params: ReadModelKeyParams<T>): Maybe<ModelKey>;
|
|
232
|
+
export declare function readModelKey<T extends UniqueModel>(input: Maybe<ModelOrKey<T>>, params?: Partial<ReadModelKeyParams<T>>): Maybe<ModelKey>;
|
|
232
233
|
/**
|
|
233
234
|
* Reads a model key directly from a model object using the provided read function.
|
|
234
235
|
*
|
|
235
|
-
* @param input - Model object to read the key from
|
|
236
|
-
* @param required - Whether the key is required; throws if missing when true
|
|
237
|
-
* @param read - Function to extract the key; defaults to reading the `id` property
|
|
238
|
-
* @returns The extracted model key, or undefined
|
|
239
|
-
* @throws Error
|
|
236
|
+
* @param input - Model object to read the key from.
|
|
237
|
+
* @param required - Whether the key is required; throws if missing when true.
|
|
238
|
+
* @param read - Function to extract the key; defaults to reading the `id` property.
|
|
239
|
+
* @returns The extracted model key, or undefined.
|
|
240
|
+
* @throws {Error} If `required` is true and the key is missing.
|
|
240
241
|
*/
|
|
241
242
|
export declare function readModelKeyFromObject<T extends UniqueModel>(input: T, required?: boolean, read?: ReadModelKeyFunction<T>): Maybe<ModelKey>;
|
|
242
243
|
/**
|
|
243
244
|
* Type guard that checks whether the input is a string model key rather than a model object.
|
|
244
245
|
*
|
|
245
|
-
* @param input - A model object or a key string
|
|
246
|
-
* @returns `true` if the input is a string key
|
|
246
|
+
* @param input - A model object or a key string.
|
|
247
|
+
* @returns `true` if the input is a string key.
|
|
247
248
|
*/
|
|
248
249
|
export declare function isModelKey<T extends UniqueModel>(input: ModelOrKey<T>): input is ModelKey;
|
|
249
250
|
/**
|
|
250
251
|
* Throws an error indicating a model key was required but not provided.
|
|
251
252
|
*
|
|
252
|
-
* @throws Error
|
|
253
|
+
* @throws {Error} Always — this function never returns normally.
|
|
253
254
|
*/
|
|
254
255
|
export declare function throwKeyIsRequired(): void;
|
|
255
256
|
/**
|
|
256
257
|
* Encodes a {@link ModelKeyTypePair} into a single string in the format `type_key`.
|
|
257
258
|
*
|
|
258
|
-
* @param pair - The type/key pair to encode
|
|
259
|
-
* @returns Encoded string representation
|
|
259
|
+
* @param pair - The type/key pair to encode.
|
|
260
|
+
* @returns Encoded string representation.
|
|
260
261
|
*
|
|
261
262
|
* @example
|
|
262
263
|
* ```ts
|
|
@@ -268,8 +269,8 @@ export declare function encodeModelKeyTypePair(pair: ModelKeyTypePair): ModelKey
|
|
|
268
269
|
/**
|
|
269
270
|
* Decodes a string in the format `type_key` back into a {@link ModelKeyTypePair}.
|
|
270
271
|
*
|
|
271
|
-
* @param linkKey - Encoded string to decode
|
|
272
|
-
* @returns The decoded type/key pair
|
|
272
|
+
* @param linkKey - Encoded string to decode.
|
|
273
|
+
* @returns The decoded type/key pair.
|
|
273
274
|
*
|
|
274
275
|
* @example
|
|
275
276
|
* ```ts
|
|
@@ -293,15 +294,16 @@ export type ModelTypeDataPairFactory<T, M extends ModelTypeString = ModelTypeStr
|
|
|
293
294
|
*
|
|
294
295
|
* Falls back to the provided default type if the type reader returns a nullish value.
|
|
295
296
|
*
|
|
297
|
+
* @param typeReader - Function to extract the model type from input data.
|
|
298
|
+
* @param defaultType - Fallback type string when the reader returns nullish.
|
|
299
|
+
* @returns Factory function that produces ModelTypeDataPair values.
|
|
300
|
+
*
|
|
296
301
|
* @dbxUtil
|
|
297
302
|
* @dbxUtilCategory model
|
|
298
303
|
* @dbxUtilKind factory
|
|
299
304
|
* @dbxUtilTags model, type, pair, factory, wrap
|
|
300
305
|
* @dbxUtilRelated read-model-key, encode-model-key-type-pair
|
|
301
306
|
*
|
|
302
|
-
* @param typeReader - Function to extract the model type from input data
|
|
303
|
-
* @param defaultType - Fallback type string when the reader returns nullish
|
|
304
|
-
* @returns Factory function that produces ModelTypeDataPair values
|
|
305
307
|
* @__NO_SIDE_EFFECTS__
|
|
306
308
|
*/
|
|
307
309
|
export declare function modelTypeDataPairFactory<T, M extends ModelTypeString = ModelTypeString>(typeReader: ReadModelTypeFunction<T, M>, defaultType?: string): ModelTypeDataPairFactory<T, M>;
|
|
@@ -15,8 +15,8 @@ export type PartialModelModifier<V extends object, D extends object> = Partial<M
|
|
|
15
15
|
*
|
|
16
16
|
* Combines all `modifyData` and `modifyModel` functions from the input modifiers into unified modifier functions.
|
|
17
17
|
*
|
|
18
|
-
* @param input - One or more partial model modifiers to merge
|
|
19
|
-
* @returns A single merged modifier with combined `modifyData` and `modifyModel` functions
|
|
18
|
+
* @param input - One or more partial model modifiers to merge.
|
|
19
|
+
* @returns A single merged modifier with combined `modifyData` and `modifyModel` functions.
|
|
20
20
|
*/
|
|
21
21
|
export declare function maybeMergeModelModifiers<V extends object, D extends object>(input: ArrayOrValue<PartialModelModifier<V, D>>): PartialModelModifier<V, D>;
|
|
22
22
|
export interface ModifyModelMapFunctionsConfig<V extends object, D extends object> {
|
|
@@ -47,14 +47,15 @@ export interface ModifyModelMapFunctionsConfig<V extends object, D extends objec
|
|
|
47
47
|
*
|
|
48
48
|
* Optionally copies the input object before modification to avoid mutating the original.
|
|
49
49
|
*
|
|
50
|
+
* @param config - Configuration with the base map functions, modifiers, and copy options.
|
|
51
|
+
* @returns New model map functions with modifiers applied before each conversion.
|
|
52
|
+
*
|
|
50
53
|
* @dbxUtil
|
|
51
54
|
* @dbxUtilCategory model
|
|
52
55
|
* @dbxUtilKind factory
|
|
53
56
|
* @dbxUtilTags model, map, modify, factory, modifier, copy
|
|
54
57
|
* @dbxUtilRelated make-model-map-functions, modify-model-map-function
|
|
55
58
|
*
|
|
56
|
-
* @param config - Configuration with the base map functions, modifiers, and copy options
|
|
57
|
-
* @returns New model map functions with modifiers applied before each conversion
|
|
58
59
|
* @__NO_SIDE_EFFECTS__
|
|
59
60
|
*/
|
|
60
61
|
export declare function modifyModelMapFunctions<V extends object, D extends object>(config: ModifyModelMapFunctionsConfig<V, D>): ModelMapFunctions<V, D>;
|
|
@@ -64,16 +65,17 @@ export declare function modifyModelMapFunctions<V extends object, D extends obje
|
|
|
64
65
|
* When `copy` is true (default), the input is shallow-copied before modification to avoid mutating the original.
|
|
65
66
|
* If no modifier is provided, the original map function is returned unchanged.
|
|
66
67
|
*
|
|
68
|
+
* @param mapFn - The base map function to wrap.
|
|
69
|
+
* @param modifyModel - Optional modifier to apply before mapping.
|
|
70
|
+
* @param copy - Whether to shallow-copy the input before modifying; defaults to true.
|
|
71
|
+
* @returns The wrapped map function, or the original if no modifier is provided.
|
|
72
|
+
*
|
|
67
73
|
* @dbxUtil
|
|
68
74
|
* @dbxUtilCategory model
|
|
69
75
|
* @dbxUtilKind factory
|
|
70
76
|
* @dbxUtilTags model, map, modify, factory, modifier, wrap
|
|
71
77
|
* @dbxUtilRelated modify-model-map-functions, model-field-map-function
|
|
72
78
|
*
|
|
73
|
-
* @param mapFn - The base map function to wrap
|
|
74
|
-
* @param modifyModel - Optional modifier to apply before mapping
|
|
75
|
-
* @param copy - Whether to shallow-copy the input before modifying; defaults to true
|
|
76
|
-
* @returns The wrapped map function, or the original if no modifier is provided
|
|
77
79
|
* @__NO_SIDE_EFFECTS__
|
|
78
80
|
*/
|
|
79
81
|
export declare function modifyModelMapFunction<I extends object, O extends object>(mapFn: ModelMapFunction<I, O>, modifyModel: Maybe<ModifierFunction<I>>, copy?: boolean): ModelMapFunction<I, O>;
|
|
@@ -5,14 +5,15 @@ export type ReadableStreamToStringFunction = (stream: NodeJS.ReadableStream) =>
|
|
|
5
5
|
/**
|
|
6
6
|
* Creates a function that reads a Node.js ReadableStream and converts its contents to a string using the specified encoding.
|
|
7
7
|
*
|
|
8
|
+
* @param encoding - The buffer encoding to use (e.g., 'utf-8', 'base64')
|
|
9
|
+
* @returns Reusable consumer that drains a stream and resolves with its decoded contents.
|
|
10
|
+
*
|
|
8
11
|
* @dbxUtil
|
|
9
12
|
* @dbxUtilCategory nodejs
|
|
10
13
|
* @dbxUtilKind factory
|
|
11
14
|
* @dbxUtilTags nodejs, stream, readable, string, factory, encoding
|
|
12
15
|
* @dbxUtilRelated readable-stream-to-buffer, readable-stream-to-base64
|
|
13
16
|
*
|
|
14
|
-
* @param encoding - The buffer encoding to use (e.g., 'utf-8', 'base64')
|
|
15
|
-
* @returns A function that consumes a ReadableStream and resolves to its string content
|
|
16
17
|
* @__NO_SIDE_EFFECTS__
|
|
17
18
|
*/
|
|
18
19
|
export declare function readableStreamToStringFunction(encoding: BufferEncoding): ReadableStreamToStringFunction;
|
|
@@ -23,8 +24,8 @@ export declare const readableStreamToBase64: ReadableStreamToStringFunction;
|
|
|
23
24
|
/**
|
|
24
25
|
* Reads all data from a Node.js ReadableStream and concatenates it into a single Buffer.
|
|
25
26
|
*
|
|
26
|
-
* @param stream - The readable stream to consume
|
|
27
|
-
* @returns Promise resolving to a Buffer containing all stream data
|
|
28
|
-
* @throws
|
|
27
|
+
* @param stream - The readable stream to consume.
|
|
28
|
+
* @returns Promise resolving to a Buffer containing all stream data.
|
|
29
|
+
* @throws {Error} If the stream emits an error event; the returned promise rejects with that error.
|
|
29
30
|
*/
|
|
30
31
|
export declare function readableStreamToBuffer(stream: NodeJS.ReadableStream): Promise<Buffer>;
|