@hkdigital/lib-core 0.4.30 → 0.4.32
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/dist/auth/jwt/constants.d.ts +1 -1
- package/dist/auth/jwt/errors.d.ts +5 -5
- package/dist/auth/jwt/typedef.d.ts +30 -30
- package/dist/config/generators/imagetools.d.ts +3 -3
- package/dist/config/generators/vite.d.ts +11 -11
- package/dist/config/generators/vite.js +1 -1
- package/dist/design/generators/index.d.ts +9 -9
- package/dist/design/utils/clamp.d.ts +1 -1
- package/dist/design/utils/root-vars.d.ts +1 -1
- package/dist/design/utils/scaling.d.ts +2 -2
- package/dist/generic/data/classes/IterableTree.d.ts +2 -2
- package/dist/generic/data/classes/IterableTree.js +1 -0
- package/dist/generic/data/classes/Selector.d.ts +5 -5
- package/dist/generic/data/classes/Selector.js +53 -60
- package/dist/generic/data/classes/typedef.d.ts +5 -5
- package/dist/generic/errors/generic.d.ts +3 -1
- package/dist/generic/errors/promise.d.ts +2 -2
- package/dist/generic/events/classes/EventEmitter.js +1 -0
- package/dist/generic/promises/classes/HkPromise.js +9 -15
- package/dist/logging/internal/adapters/console.d.ts +5 -5
- package/dist/logging/internal/adapters/pino.d.ts +3 -3
- package/dist/logging/internal/adapters/typedef.d.ts +7 -7
- package/dist/logging/internal/factories/client.d.ts +1 -1
- package/dist/logging/internal/factories/server.d.ts +1 -1
- package/dist/logging/internal/logger/Logger.d.ts +3 -3
- package/dist/logging/internal/transports/pretty-transport.d.ts +3 -3
- package/dist/logging/internal/transports/test-transport.d.ts +5 -5
- package/dist/logging/typedef.d.ts +1 -1
- package/dist/network/cache/IndexedDbCache.d.ts +10 -10
- package/dist/network/cache/MemoryResponseCache.d.ts +3 -3
- package/dist/network/cache/typedef.d.ts +3 -3
- package/dist/network/errors/http.d.ts +2 -2
- package/dist/network/http/caching.d.ts +2 -2
- package/dist/network/http/http-request.d.ts +1 -1
- package/dist/network/http/typedef.d.ts +31 -31
- package/dist/network/loaders/audio/AudioScene.svelte.d.ts +2 -2
- package/dist/network/loaders/base/SceneBase.svelte.d.ts +4 -4
- package/dist/network/loaders/base/SceneBase.svelte.js +1 -1
- package/dist/network/loaders/image/ImageLoader.svelte.d.ts +1 -1
- package/dist/network/loaders/image/ImageVariantsLoader.svelte.d.ts +5 -5
- package/dist/network/loaders/image/utils/index.d.ts +3 -3
- package/dist/services/manager-plugins/ConfigPlugin.d.ts +1 -1
- package/dist/services/service-base/ServiceBase.d.ts +13 -3
- package/dist/services/service-base/ServiceBase.js +27 -9
- package/dist/services/service-base/typedef.d.ts +8 -8
- package/dist/services/service-manager/ServiceManager.d.ts +10 -2
- package/dist/services/service-manager/ServiceManager.js +55 -27
- package/dist/services/service-manager/typedef.d.ts +12 -11
- package/dist/services/service-manager/typedef.js +2 -1
- package/dist/state/machines/finite-state-machine/FiniteStateMachine.svelte.d.ts +1 -1
- package/dist/state/machines/loading-state-machine/LoadingStateMachine.svelte.d.ts +1 -1
- package/dist/state/stores/theme.d.ts +1 -1
- package/dist/ui/components/button-group/ButtonGroup.svelte.d.ts +7 -7
- package/dist/ui/components/button-group/typedef.d.ts +1 -1
- package/dist/ui/components/compare-left-right/CompareLeftRight.svelte.d.ts +5 -5
- package/dist/ui/components/drag-drop/DragController.d.ts +1 -1
- package/dist/ui/components/drag-drop/DragDropContext.svelte.d.ts +3 -3
- package/dist/ui/components/drag-drop/Draggable.svelte.d.ts +20 -20
- package/dist/ui/components/drag-drop/DropZone.svelte.d.ts +27 -27
- package/dist/ui/components/drag-drop/DropZoneArea.svelte.d.ts +26 -26
- package/dist/ui/components/drag-drop/DropZoneList.svelte.d.ts +27 -27
- package/dist/ui/components/drag-drop/drag-state.svelte.d.ts +4 -4
- package/dist/ui/components/drag-drop/typedef/drag.d.ts +1 -1
- package/dist/ui/components/game-box/GameBox.svelte.d.ts +19 -19
- package/dist/ui/components/game-box/gamebox.util.d.ts +2 -2
- package/dist/ui/components/grid-layers/GridLayers.svelte.d.ts +7 -7
- package/dist/ui/components/image-box/ImageBox.svelte.d.ts +14 -14
- package/dist/ui/components/presenter/ImageSlide.svelte.d.ts +8 -8
- package/dist/ui/components/presenter/Presenter.state.svelte.d.ts +1 -1
- package/dist/ui/components/presenter/Presenter.svelte.d.ts +5 -5
- package/dist/ui/components/presenter/typedef.d.ts +13 -13
- package/dist/ui/components/rows/panel-grid-row/PanelGridRow.svelte.d.ts +7 -7
- package/dist/ui/components/rows/panel-row-2/PanelRow2.svelte.d.ts +7 -7
- package/dist/ui/components/tab-bar/HkTabBar.svelte.d.ts +10 -10
- package/dist/ui/components/tab-bar/HkTabBarSelector.state.svelte.d.ts +1 -1
- package/dist/ui/components/tab-bar/HkTabBarSelector.svelte.d.ts +10 -10
- package/dist/ui/components/tab-bar/typedef.d.ts +3 -3
- package/dist/ui/components/virtual-viewport/VirtualViewport.svelte.d.ts +17 -17
- package/dist/ui/dev/blocks/TextBlock.svelte.d.ts +6 -6
- package/dist/ui/dev/buttons/CheckButton.svelte.d.ts +11 -11
- package/dist/ui/primitives/area/HkArea.svelte.d.ts +6 -6
- package/dist/ui/primitives/area/HkGridArea.svelte.d.ts +12 -12
- package/dist/ui/primitives/buttons/button/Button.svelte.d.ts +16 -16
- package/dist/ui/primitives/buttons/button-icon-steeze/SteezeIconButton.svelte.d.ts +2 -2
- package/dist/ui/primitives/buttons/button-submit/SubmitButton.svelte +21 -0
- package/dist/ui/primitives/buttons/button-submit/SubmitButton.svelte.d.ts +12 -0
- package/dist/ui/primitives/buttons/index.d.ts +2 -1
- package/dist/ui/primitives/buttons/index.js +2 -1
- package/dist/ui/primitives/icons/HkIcon.svelte.d.ts +4 -4
- package/dist/ui/primitives/icons/HkTabIcon.svelte.d.ts +13 -13
- package/dist/ui/primitives/icons/SteezeIcon.svelte.d.ts +4 -4
- package/dist/ui/primitives/inputs/text-input/TextInput.svelte.d.ts +22 -22
- package/dist/ui/primitives/inputs/text-input/assets/IconInvalid.svelte.d.ts +1 -1
- package/dist/ui/primitives/inputs/text-input/assets/IconValid.svelte.d.ts +1 -1
- package/dist/ui/primitives/panels/panel/Panel.svelte.d.ts +6 -6
- package/dist/util/array/index.d.ts +17 -17
- package/dist/util/array/index.js +5 -5
- package/dist/util/compare/index.d.ts +2 -1
- package/dist/util/compare/index.js +1 -0
- package/dist/util/exceptions/index.d.ts +3 -2
- package/dist/util/exceptions/index.js +13 -9
- package/dist/util/expect/arrays.d.ts +1 -0
- package/dist/util/expect/arrays.js +1 -0
- package/dist/util/expect/primitives.d.ts +18 -0
- package/dist/util/expect/primitives.js +18 -0
- package/dist/util/function/index.d.ts +14 -1
- package/dist/util/geometry/index.d.ts +2 -2
- package/dist/util/geometry/index.js +1 -1
- package/dist/util/iterate/index.d.ts +7 -7
- package/dist/util/object/index.d.ts +13 -13
- package/dist/util/singleton/index.d.ts +3 -3
- package/dist/util/svelte/loading/loading-tracker.svelte.d.ts +1 -1
- package/dist/util/sveltekit/env/all.d.ts +7 -18
- package/dist/util/sveltekit/env/all.js +4 -22
- package/dist/util/sveltekit/env/parsers.d.ts +23 -37
- package/dist/util/sveltekit/env/parsers.js +15 -15
- package/dist/util/sveltekit/env/private.d.ts +9 -11
- package/dist/util/sveltekit/env/private.js +4 -4
- package/dist/util/sveltekit/env/public.d.ts +9 -11
- package/dist/util/sveltekit/env/public.js +3 -3
- package/dist/util/sveltekit/env-all.d.ts +1 -1
- package/dist/util/sveltekit/env-all.js +2 -4
- package/dist/util/sveltekit/route-folders/index.d.ts +2 -2
- package/dist/util/sveltekit/route-folders.d.ts +1 -0
- package/dist/util/{sveltekit.js → sveltekit/route-folders.js} +1 -1
- package/dist/util/time/index.d.ts +4 -4
- package/dist/valibot/parsers/url.d.ts +3 -3
- package/dist/valibot/parsers/url.js +6 -2
- package/package.json +1 -1
- package/dist/util/sveltekit.d.ts +0 -1
|
@@ -18,6 +18,7 @@ export function expect_stringArray(value: any): void;
|
|
|
18
18
|
export function expect_objectArray(value: any): void;
|
|
19
19
|
/**
|
|
20
20
|
* Throws an exception if the value is not an Array or the array is empty
|
|
21
|
+
* @param {any} value - Value to check
|
|
21
22
|
*/
|
|
22
23
|
export function expect_notEmptyArray(value: any): void;
|
|
23
24
|
/**
|
|
@@ -35,6 +35,7 @@ export { expect_objectArray as objectArray };
|
|
|
35
35
|
|
|
36
36
|
/**
|
|
37
37
|
* Throws an exception if the value is not an Array or the array is empty
|
|
38
|
+
* @param {any} value - Value to check
|
|
38
39
|
*/
|
|
39
40
|
export function expect_notEmptyArray(value) {
|
|
40
41
|
v.parse(v.pipe(v.instance(Array), v.nonEmpty()), value);
|
|
@@ -2,24 +2,32 @@
|
|
|
2
2
|
* Throws a validation error if value is not a string
|
|
3
3
|
*
|
|
4
4
|
* @param {any} value
|
|
5
|
+
*
|
|
6
|
+
* @asserts value is string
|
|
5
7
|
*/
|
|
6
8
|
export function expect_string(value: any): void;
|
|
7
9
|
/**
|
|
8
10
|
* Throws a validation error if value is not a boolean
|
|
9
11
|
*
|
|
10
12
|
* @param {any} value
|
|
13
|
+
*
|
|
14
|
+
* @asserts value is boolean
|
|
11
15
|
*/
|
|
12
16
|
export function expect_boolean(value: any): void;
|
|
13
17
|
/**
|
|
14
18
|
* Throws a validation error if value is not a number
|
|
15
19
|
*
|
|
16
20
|
* @param {any} value
|
|
21
|
+
*
|
|
22
|
+
* @asserts value is number
|
|
17
23
|
*/
|
|
18
24
|
export function expect_number(value: any): void;
|
|
19
25
|
/**
|
|
20
26
|
* Throws a validation error if value is not a Symbol
|
|
21
27
|
*
|
|
22
28
|
* @param {any} value
|
|
29
|
+
*
|
|
30
|
+
* @asserts value is Symbol
|
|
23
31
|
*/
|
|
24
32
|
export function expect_symbol(value: any): void;
|
|
25
33
|
/**
|
|
@@ -32,30 +40,40 @@ export function expect_defined(value: any): void;
|
|
|
32
40
|
* Throws a validation error if value is not a function
|
|
33
41
|
*
|
|
34
42
|
* @param {any} value
|
|
43
|
+
*
|
|
44
|
+
* @asserts value is function
|
|
35
45
|
*/
|
|
36
46
|
export function expect_function(value: any): void;
|
|
37
47
|
/**
|
|
38
48
|
* Throws a validation error if value is not a Promise
|
|
39
49
|
*
|
|
40
50
|
* @param {any} value
|
|
51
|
+
*
|
|
52
|
+
* @asserts value is Promise
|
|
41
53
|
*/
|
|
42
54
|
export function expect_promise(value: any): void;
|
|
43
55
|
/**
|
|
44
56
|
* Throws a validation error if value is not a Map
|
|
45
57
|
*
|
|
46
58
|
* @param {any} value
|
|
59
|
+
*
|
|
60
|
+
* @asserts value is Map
|
|
47
61
|
*/
|
|
48
62
|
export function expect_map(value: any): void;
|
|
49
63
|
/**
|
|
50
64
|
* Throws a validation error if value is not a Set
|
|
51
65
|
*
|
|
52
66
|
* @param {any} value
|
|
67
|
+
*
|
|
68
|
+
* @asserts value is Set
|
|
53
69
|
*/
|
|
54
70
|
export function expect_set(value: any): void;
|
|
55
71
|
/**
|
|
56
72
|
* Throws a validation error if value is not an Error instance
|
|
57
73
|
*
|
|
58
74
|
* @param {any} value
|
|
75
|
+
*
|
|
76
|
+
* @asserts value is Error
|
|
59
77
|
*/
|
|
60
78
|
export function expect_error(value: any): void;
|
|
61
79
|
export { expect_string as string, expect_boolean as boolean, expect_number as number, expect_symbol as symbol, expect_defined as defined, expect_function as function, _function as function, expect_function as class, _class as class, expect_promise as promise, expect_map as map, expect_set as set, expect_error as error };
|
|
@@ -4,6 +4,8 @@ import * as v from 'valibot';
|
|
|
4
4
|
* Throws a validation error if value is not a string
|
|
5
5
|
*
|
|
6
6
|
* @param {any} value
|
|
7
|
+
*
|
|
8
|
+
* @asserts value is string
|
|
7
9
|
*/
|
|
8
10
|
export function expect_string(value) {
|
|
9
11
|
v.parse(v.string(), value);
|
|
@@ -15,6 +17,8 @@ export { expect_string as string };
|
|
|
15
17
|
* Throws a validation error if value is not a boolean
|
|
16
18
|
*
|
|
17
19
|
* @param {any} value
|
|
20
|
+
*
|
|
21
|
+
* @asserts value is boolean
|
|
18
22
|
*/
|
|
19
23
|
export function expect_boolean(value) {
|
|
20
24
|
v.parse(v.boolean(), value);
|
|
@@ -26,6 +30,8 @@ export { expect_boolean as boolean };
|
|
|
26
30
|
* Throws a validation error if value is not a number
|
|
27
31
|
*
|
|
28
32
|
* @param {any} value
|
|
33
|
+
*
|
|
34
|
+
* @asserts value is number
|
|
29
35
|
*/
|
|
30
36
|
export function expect_number(value) {
|
|
31
37
|
v.parse(v.number(), value);
|
|
@@ -37,6 +43,8 @@ export { expect_number as number };
|
|
|
37
43
|
* Throws a validation error if value is not a Symbol
|
|
38
44
|
*
|
|
39
45
|
* @param {any} value
|
|
46
|
+
*
|
|
47
|
+
* @asserts value is Symbol
|
|
40
48
|
*/
|
|
41
49
|
export function expect_symbol(value) {
|
|
42
50
|
v.parse(v.symbol(), value);
|
|
@@ -68,6 +76,8 @@ export { expect_defined as defined };
|
|
|
68
76
|
* Throws a validation error if value is not a function
|
|
69
77
|
*
|
|
70
78
|
* @param {any} value
|
|
79
|
+
*
|
|
80
|
+
* @asserts value is function
|
|
71
81
|
*/
|
|
72
82
|
export function expect_function(value) {
|
|
73
83
|
v.parse(v.function(), value);
|
|
@@ -80,6 +90,8 @@ export { expect_function as class };
|
|
|
80
90
|
* Throws a validation error if value is not a Promise
|
|
81
91
|
*
|
|
82
92
|
* @param {any} value
|
|
93
|
+
*
|
|
94
|
+
* @asserts value is Promise
|
|
83
95
|
*/
|
|
84
96
|
export function expect_promise(value) {
|
|
85
97
|
v.parse(v.instance(Promise), value);
|
|
@@ -91,6 +103,8 @@ export { expect_promise as promise };
|
|
|
91
103
|
* Throws a validation error if value is not a Map
|
|
92
104
|
*
|
|
93
105
|
* @param {any} value
|
|
106
|
+
*
|
|
107
|
+
* @asserts value is Map
|
|
94
108
|
*/
|
|
95
109
|
export function expect_map(value) {
|
|
96
110
|
v.parse(v.instance(Map), value);
|
|
@@ -102,6 +116,8 @@ export { expect_map as map };
|
|
|
102
116
|
* Throws a validation error if value is not a Set
|
|
103
117
|
*
|
|
104
118
|
* @param {any} value
|
|
119
|
+
*
|
|
120
|
+
* @asserts value is Set
|
|
105
121
|
*/
|
|
106
122
|
export function expect_set(value) {
|
|
107
123
|
v.parse(v.instance(Set), value);
|
|
@@ -113,6 +129,8 @@ export { expect_set as set };
|
|
|
113
129
|
* Throws a validation error if value is not an Error instance
|
|
114
130
|
*
|
|
115
131
|
* @param {any} value
|
|
132
|
+
*
|
|
133
|
+
* @asserts value is Error
|
|
116
134
|
*/
|
|
117
135
|
export function expect_error(value) {
|
|
118
136
|
v.parse(v.instance(Error), value);
|
|
@@ -18,4 +18,17 @@ export function once(callback: Function): Function;
|
|
|
18
18
|
*/
|
|
19
19
|
export function debounce(fn: Function, intervalMs?: number): Function;
|
|
20
20
|
export function noop(): void;
|
|
21
|
-
|
|
21
|
+
/**
|
|
22
|
+
* Defer the execution of a function
|
|
23
|
+
* - Uses the best 'setImmediate' implementation supported by the current
|
|
24
|
+
* runtime environment
|
|
25
|
+
*
|
|
26
|
+
* @param {function} fn - Function to execute
|
|
27
|
+
*
|
|
28
|
+
* --
|
|
29
|
+
*
|
|
30
|
+
* @note setImmediate is preferred over nextTick
|
|
31
|
+
*
|
|
32
|
+
* @see https://nodejs.org/en/docs/guides/event-loop-timers-and-nexttick/
|
|
33
|
+
*/
|
|
34
|
+
export const defer: typeof setImmediate | ((fn: any) => void);
|
|
@@ -3,8 +3,8 @@
|
|
|
3
3
|
*
|
|
4
4
|
* @param {number} xPct - X-coordinate as percentage
|
|
5
5
|
* @param {number} yPct - Y-coordinate as percentage
|
|
6
|
-
* @param {Array} polygon - Array of [x, y] points
|
|
6
|
+
* @param {Array<number[]>} polygon - Array of [x, y] points
|
|
7
7
|
*
|
|
8
8
|
* @returns {boolean} True if the point lies within the polygon
|
|
9
9
|
*/
|
|
10
|
-
export function isPointInPolygon(xPct: number, yPct: number, polygon:
|
|
10
|
+
export function isPointInPolygon(xPct: number, yPct: number, polygon: Array<number[]>): boolean;
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*
|
|
4
4
|
* @param {number} xPct - X-coordinate as percentage
|
|
5
5
|
* @param {number} yPct - Y-coordinate as percentage
|
|
6
|
-
* @param {Array} polygon - Array of [x, y] points
|
|
6
|
+
* @param {Array<number[]>} polygon - Array of [x, y] points
|
|
7
7
|
*
|
|
8
8
|
* @returns {boolean} True if the point lies within the polygon
|
|
9
9
|
*/
|
|
@@ -48,11 +48,11 @@ export function map(iterable: Iterable<any>, transformFn: Function): Generator;
|
|
|
48
48
|
* @return {Iterable<[string[], any]>} iterable that yields [path, value] pairs
|
|
49
49
|
*/
|
|
50
50
|
export function iterateObjectEntries(obj: object, options?: {
|
|
51
|
-
walkArrays?: boolean;
|
|
52
|
-
expandPathKeys?: boolean;
|
|
53
|
-
outputIntermediateNodes?: boolean;
|
|
54
|
-
ignoreEmptyObjectLeaves?: boolean;
|
|
55
|
-
depthFirst?: boolean;
|
|
51
|
+
walkArrays?: boolean | undefined;
|
|
52
|
+
expandPathKeys?: boolean | undefined;
|
|
53
|
+
outputIntermediateNodes?: boolean | undefined;
|
|
54
|
+
ignoreEmptyObjectLeaves?: boolean | undefined;
|
|
55
|
+
depthFirst?: boolean | undefined;
|
|
56
56
|
}): Iterable<[string[], any]>;
|
|
57
57
|
/**
|
|
58
58
|
* Get an Iterator object that can be used to iterate over all paths in
|
|
@@ -92,6 +92,6 @@ export function iterateObjectValues(obj: object, options?: IterableTreeOptions):
|
|
|
92
92
|
export function sortObjects({ it, getValueFn, reversed }: {
|
|
93
93
|
it: Iterable<any>;
|
|
94
94
|
getValueFn: Function;
|
|
95
|
-
reversed?: boolean;
|
|
96
|
-
}): Promise<
|
|
95
|
+
reversed?: boolean | undefined;
|
|
96
|
+
}): Promise<array>;
|
|
97
97
|
export type IterableTreeOptions = import("../../generic/typedef.js").IterableTreeOptions;
|
|
@@ -54,7 +54,7 @@ export function exportPublic(obj: object, keepKeys?: string[]): object;
|
|
|
54
54
|
*
|
|
55
55
|
* @returns {object|array} new object or array with only primitive values
|
|
56
56
|
*/
|
|
57
|
-
export function exportNotNested(objectOrArray: object |
|
|
57
|
+
export function exportNotNested(objectOrArray: object | array): object | array;
|
|
58
58
|
/**
|
|
59
59
|
* Keep only the specified keys in the object
|
|
60
60
|
* - deletes all other key-value pairs in the object
|
|
@@ -166,12 +166,12 @@ export function objectGetWithThrow(obj: object, path: string | any[], parseFn?:
|
|
|
166
166
|
* List of changes between the object before and object after
|
|
167
167
|
*/
|
|
168
168
|
export function objectDiff(objBefore: object, objAfter: object, options: {
|
|
169
|
-
ignoreAdd?: boolean;
|
|
170
|
-
ignoreUpdate?: boolean;
|
|
171
|
-
ignoreDelete?: boolean;
|
|
172
|
-
ignorePrivate?: boolean;
|
|
173
|
-
deleteValue?: boolean;
|
|
174
|
-
}, _recursion: any):
|
|
169
|
+
ignoreAdd?: boolean | undefined;
|
|
170
|
+
ignoreUpdate?: boolean | undefined;
|
|
171
|
+
ignoreDelete?: boolean | undefined;
|
|
172
|
+
ignorePrivate?: boolean | undefined;
|
|
173
|
+
deleteValue?: boolean | undefined;
|
|
174
|
+
} | undefined, _recursion: any): array;
|
|
175
175
|
/**
|
|
176
176
|
* Applies a list of differences to the input object
|
|
177
177
|
* - A list of changes can be generated by e.g. objectDiff
|
|
@@ -188,10 +188,10 @@ export function objectDiff(objBefore: object, objAfter: object, options: {
|
|
|
188
188
|
* Ignore properties that start with an underscore e.g. _id or _updatedAt
|
|
189
189
|
*/
|
|
190
190
|
export function patchObject(obj: object, changes: object[], options?: {
|
|
191
|
-
ignoreAdd?: boolean;
|
|
192
|
-
ignoreUpdate?: boolean;
|
|
193
|
-
ignoreDelete?: boolean;
|
|
194
|
-
ignorePrivate?: boolean;
|
|
191
|
+
ignoreAdd?: boolean | undefined;
|
|
192
|
+
ignoreUpdate?: boolean | undefined;
|
|
193
|
+
ignoreDelete?: boolean | undefined;
|
|
194
|
+
ignorePrivate?: boolean | undefined;
|
|
195
195
|
}): void;
|
|
196
196
|
/**
|
|
197
197
|
* Extend the target object with methods and properties from the source
|
|
@@ -242,7 +242,7 @@ export function getPrototypeNames(obj: object): string[];
|
|
|
242
242
|
* nested object with the values that were found or defaultValues
|
|
243
243
|
*/
|
|
244
244
|
export function getTree(obj: object, tree: object, options?: {
|
|
245
|
-
shallowLeaves?: boolean;
|
|
245
|
+
shallowLeaves?: boolean | undefined;
|
|
246
246
|
}): object;
|
|
247
247
|
/**
|
|
248
248
|
* Deep clone an object or any kind of other variable
|
|
@@ -284,7 +284,7 @@ export function setReadOnlyProperty(obj: object, propertyName: string, value: an
|
|
|
284
284
|
* @returns {object} updated object
|
|
285
285
|
*/
|
|
286
286
|
export function updateObject(obj?: object, updateData?: object | Iterable<any>, options?: {
|
|
287
|
-
replaceArrays?: boolean;
|
|
287
|
+
replaceArrays?: boolean | undefined;
|
|
288
288
|
}): object;
|
|
289
289
|
/**
|
|
290
290
|
* Copy own properties from an object to another object if they do not
|
|
@@ -12,8 +12,8 @@
|
|
|
12
12
|
*/
|
|
13
13
|
export function getInstance({ needle, class: Class, args }: {
|
|
14
14
|
class: any;
|
|
15
|
-
args?: any[];
|
|
16
|
-
needle?: string;
|
|
15
|
+
args?: any[] | undefined;
|
|
16
|
+
needle?: string | undefined;
|
|
17
17
|
}): any;
|
|
18
18
|
/**
|
|
19
19
|
* Creates a proxy that instantiates the singleton class upon it's first usage
|
|
@@ -28,7 +28,7 @@ export function getInstance({ needle, class: Class, args }: {
|
|
|
28
28
|
*/
|
|
29
29
|
export function lazySingleton<T>({ class: Class, args }: {
|
|
30
30
|
class: new () => T;
|
|
31
|
-
args?: any[];
|
|
31
|
+
args?: any[] | undefined;
|
|
32
32
|
}): T & {
|
|
33
33
|
init: () => null;
|
|
34
34
|
};
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
* @param {boolean} [options.autoGroup=true]
|
|
14
14
|
* Enable automatic prefix grouping
|
|
15
15
|
*
|
|
16
|
-
* @returns {
|
|
16
|
+
* @returns {Record<string, any>} Grouped and parsed combined environment variables
|
|
17
17
|
*
|
|
18
18
|
* @example
|
|
19
19
|
* // Environment variables:
|
|
@@ -31,24 +31,13 @@
|
|
|
31
31
|
* // }
|
|
32
32
|
*/
|
|
33
33
|
export function getAllEnv(options?: {
|
|
34
|
-
camelCase?: boolean;
|
|
35
|
-
parseValues?: boolean;
|
|
36
|
-
autoGroup?: boolean;
|
|
37
|
-
}): any
|
|
38
|
-
/**
|
|
39
|
-
* Get combined environment variables by prefix
|
|
40
|
-
*
|
|
41
|
-
* @param {string} prefix - Environment variable prefix (e.g., 'DATABASE')
|
|
42
|
-
* @param {Object} [options={}] - Parsing options
|
|
43
|
-
*
|
|
44
|
-
* @returns {Object} Parsed configuration object
|
|
45
|
-
*/
|
|
46
|
-
export function getAllEnvByPrefix(prefix: string, options?: any): any;
|
|
34
|
+
camelCase?: boolean | undefined;
|
|
35
|
+
parseValues?: boolean | undefined;
|
|
36
|
+
autoGroup?: boolean | undefined;
|
|
37
|
+
}): Record<string, any>;
|
|
47
38
|
/**
|
|
48
39
|
* Get raw combined environment variables (no parsing)
|
|
49
40
|
*
|
|
50
|
-
* @returns {
|
|
41
|
+
* @returns {Record<string, string|undefined>} Raw combined environment variables
|
|
51
42
|
*/
|
|
52
|
-
export function getRawAllEnv():
|
|
53
|
-
[x: string]: string;
|
|
54
|
-
};
|
|
43
|
+
export function getRawAllEnv(): Record<string, string | undefined>;
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
|
|
15
15
|
import { getPublicEnv, getRawPublicEnv } from './public.js';
|
|
16
16
|
import { getPrivateEnv, getRawPrivateEnv } from './private.js';
|
|
17
|
-
import { autoGroupEnvByPrefix
|
|
17
|
+
import { autoGroupEnvByPrefix } from './parsers.js';
|
|
18
18
|
|
|
19
19
|
/**
|
|
20
20
|
* Get all environment variables (public + private) with automatic grouping
|
|
@@ -31,7 +31,7 @@ import { autoGroupEnvByPrefix, parseEnv } from './parsers.js';
|
|
|
31
31
|
* @param {boolean} [options.autoGroup=true]
|
|
32
32
|
* Enable automatic prefix grouping
|
|
33
33
|
*
|
|
34
|
-
* @returns {
|
|
34
|
+
* @returns {Record<string, any>} Grouped and parsed combined environment variables
|
|
35
35
|
*
|
|
36
36
|
* @example
|
|
37
37
|
* // Environment variables:
|
|
@@ -65,28 +65,10 @@ export function getAllEnv(options = {}) {
|
|
|
65
65
|
return { ...publicVars, ...privateVars };
|
|
66
66
|
}
|
|
67
67
|
|
|
68
|
-
/**
|
|
69
|
-
* Get combined environment variables by prefix
|
|
70
|
-
*
|
|
71
|
-
* @param {string} prefix - Environment variable prefix (e.g., 'DATABASE')
|
|
72
|
-
* @param {Object} [options={}] - Parsing options
|
|
73
|
-
*
|
|
74
|
-
* @returns {Object} Parsed configuration object
|
|
75
|
-
*/
|
|
76
|
-
export function getAllEnvByPrefix(prefix, options = {}) {
|
|
77
|
-
const prefixWithUnderscore = prefix.endsWith('_') ? prefix : `${prefix}_`;
|
|
78
|
-
|
|
79
|
-
return getAllEnv({
|
|
80
|
-
...options,
|
|
81
|
-
prefix: prefixWithUnderscore,
|
|
82
|
-
removePrefix: true
|
|
83
|
-
});
|
|
84
|
-
}
|
|
85
|
-
|
|
86
68
|
/**
|
|
87
69
|
* Get raw combined environment variables (no parsing)
|
|
88
70
|
*
|
|
89
|
-
* @returns {
|
|
71
|
+
* @returns {Record<string, string|undefined>} Raw combined environment variables
|
|
90
72
|
*/
|
|
91
73
|
export function getRawAllEnv() {
|
|
92
74
|
const publicVars = getRawPublicEnv();
|
|
@@ -94,4 +76,4 @@ export function getRawAllEnv() {
|
|
|
94
76
|
|
|
95
77
|
// Private variables take precedence over public ones
|
|
96
78
|
return { ...publicVars, ...privateVars };
|
|
97
|
-
}
|
|
79
|
+
}
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
/**
|
|
18
18
|
* Parse environment object with type conversion and key transformation
|
|
19
19
|
*
|
|
20
|
-
* @param {
|
|
20
|
+
* @param {Record<string, string | undefined>} env - Raw environment variables
|
|
21
21
|
* @param {Object} [options={}] - Parsing options
|
|
22
22
|
* @param {boolean} [options.camelCase=true]
|
|
23
23
|
* Convert env var names to camelCase object keys
|
|
@@ -27,28 +27,24 @@
|
|
|
27
27
|
* @param {boolean} [options.removePrefix=true]
|
|
28
28
|
* Remove prefix from resulting keys
|
|
29
29
|
*
|
|
30
|
-
* @returns {
|
|
30
|
+
* @returns {Record<string, any>} Parsed environment object
|
|
31
31
|
*/
|
|
32
|
-
export function parseEnv(env: {
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
removePrefix?: boolean;
|
|
39
|
-
}): any;
|
|
32
|
+
export function parseEnv(env: Record<string, string | undefined>, options?: {
|
|
33
|
+
camelCase?: boolean | undefined;
|
|
34
|
+
parseValues?: boolean | undefined;
|
|
35
|
+
prefix?: string | undefined;
|
|
36
|
+
removePrefix?: boolean | undefined;
|
|
37
|
+
}): Record<string, any>;
|
|
40
38
|
/**
|
|
41
39
|
* Parse environment variables by prefix
|
|
42
40
|
*
|
|
43
|
-
* @param {
|
|
41
|
+
* @param {Record<string, string | undefined>} env - Raw environment variables
|
|
44
42
|
* @param {string} prefix - Environment variable prefix (e.g., 'DATABASE')
|
|
45
43
|
* @param {Object} [options={}] - Parsing options
|
|
46
44
|
*
|
|
47
|
-
* @returns {
|
|
45
|
+
* @returns {Record<string, any>} Parsed configuration object
|
|
48
46
|
*/
|
|
49
|
-
export function parseEnvByPrefix(env:
|
|
50
|
-
[x: string]: string;
|
|
51
|
-
}, prefix: string, options?: any): any;
|
|
47
|
+
export function parseEnvByPrefix(env: Record<string, string | undefined>, prefix: string, options?: Object): Record<string, any>;
|
|
52
48
|
/**
|
|
53
49
|
* Convert SCREAMING_SNAKE_CASE to camelCase
|
|
54
50
|
*
|
|
@@ -72,14 +68,14 @@ export function parseValue(value: string): any;
|
|
|
72
68
|
* them into configuration objects. All variables with underscores are
|
|
73
69
|
* grouped by their prefix (the part before the first underscore).
|
|
74
70
|
*
|
|
75
|
-
* @param {
|
|
71
|
+
* @param {Record<string, string | undefined>} env - Raw environment variables
|
|
76
72
|
* @param {Object} [options={}] - Parsing options
|
|
77
73
|
* @param {boolean} [options.camelCase=true]
|
|
78
74
|
* Convert env var names to camelCase object keys
|
|
79
75
|
* @param {boolean} [options.parseValues=true]
|
|
80
76
|
* Parse string values to numbers/booleans when possible
|
|
81
77
|
*
|
|
82
|
-
* @returns {
|
|
78
|
+
* @returns {Record<string, Record<string, any> | any>} Grouped environment variables
|
|
83
79
|
*
|
|
84
80
|
* @example
|
|
85
81
|
* // Input env vars:
|
|
@@ -95,41 +91,31 @@ export function parseValue(value: string): any;
|
|
|
95
91
|
* // single: 'value' // No underscore, stays top-level
|
|
96
92
|
* // }
|
|
97
93
|
*/
|
|
98
|
-
export function autoGroupEnvByPrefix(env: {
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
parseValues?: boolean;
|
|
103
|
-
}): {
|
|
104
|
-
[x: string]: any;
|
|
105
|
-
};
|
|
94
|
+
export function autoGroupEnvByPrefix(env: Record<string, string | undefined>, options?: {
|
|
95
|
+
camelCase?: boolean | undefined;
|
|
96
|
+
parseValues?: boolean | undefined;
|
|
97
|
+
}): Record<string, Record<string, any> | any>;
|
|
106
98
|
/**
|
|
107
99
|
* Group environment variables by specific prefixes
|
|
108
100
|
*
|
|
109
|
-
* @param {
|
|
101
|
+
* @param {Record<string, string | undefined>} env - Raw environment variables
|
|
110
102
|
* @param {string[]} prefixes - Array of prefixes to group by
|
|
111
103
|
* @param {Object} [options={}] - Parsing options
|
|
112
104
|
*
|
|
113
|
-
* @returns {
|
|
105
|
+
* @returns {Record<string, Record<string, any>>} Grouped environment variables
|
|
114
106
|
*
|
|
115
107
|
* @example
|
|
116
108
|
* const grouped = groupEnvByPrefixes(env, ['DATABASE', 'REDIS', 'JWT']);
|
|
117
109
|
* // Returns: { database: {...}, redis: {...}, jwt: {...} }
|
|
118
110
|
*/
|
|
119
|
-
export function groupEnvByPrefixes(env:
|
|
120
|
-
[x: string]: string;
|
|
121
|
-
}, prefixes: string[], options?: any): {
|
|
122
|
-
[x: string]: any;
|
|
123
|
-
};
|
|
111
|
+
export function groupEnvByPrefixes(env: Record<string, string | undefined>, prefixes: string[], options?: Object): Record<string, Record<string, any>>;
|
|
124
112
|
/**
|
|
125
113
|
* Filter environment variables by pattern
|
|
126
114
|
*
|
|
127
|
-
* @param {
|
|
115
|
+
* @param {Record<string, string | undefined>} env - Raw environment variables
|
|
128
116
|
* @param {RegExp|string} pattern - Pattern to match against keys
|
|
129
117
|
* @param {Object} [options={}] - Parsing options
|
|
130
118
|
*
|
|
131
|
-
* @returns {
|
|
119
|
+
* @returns {Record<string, any>} Filtered and parsed environment variables
|
|
132
120
|
*/
|
|
133
|
-
export function filterEnvByPattern(env:
|
|
134
|
-
[x: string]: string;
|
|
135
|
-
}, pattern: RegExp | string, options?: any): any;
|
|
121
|
+
export function filterEnvByPattern(env: Record<string, string | undefined>, pattern: RegExp | string, options?: Object): Record<string, any>;
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
/**
|
|
19
19
|
* Parse environment object with type conversion and key transformation
|
|
20
20
|
*
|
|
21
|
-
* @param {
|
|
21
|
+
* @param {Record<string, string | undefined>} env - Raw environment variables
|
|
22
22
|
* @param {Object} [options={}] - Parsing options
|
|
23
23
|
* @param {boolean} [options.camelCase=true]
|
|
24
24
|
* Convert env var names to camelCase object keys
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
* @param {boolean} [options.removePrefix=true]
|
|
29
29
|
* Remove prefix from resulting keys
|
|
30
30
|
*
|
|
31
|
-
* @returns {
|
|
31
|
+
* @returns {Record<string, any>} Parsed environment object
|
|
32
32
|
*/
|
|
33
33
|
export function parseEnv(env, options = {}) {
|
|
34
34
|
const {
|
|
@@ -41,8 +41,8 @@ export function parseEnv(env, options = {}) {
|
|
|
41
41
|
const result = {};
|
|
42
42
|
|
|
43
43
|
for (const [key, value] of Object.entries(env || {})) {
|
|
44
|
-
// Skip if prefix specified and key doesn't match
|
|
45
|
-
if (prefix && !key.startsWith(prefix)) {
|
|
44
|
+
// Skip if value is undefined or if prefix specified and key doesn't match
|
|
45
|
+
if (value === undefined || (prefix && !key.startsWith(prefix))) {
|
|
46
46
|
continue;
|
|
47
47
|
}
|
|
48
48
|
|
|
@@ -73,11 +73,11 @@ export function parseEnv(env, options = {}) {
|
|
|
73
73
|
/**
|
|
74
74
|
* Parse environment variables by prefix
|
|
75
75
|
*
|
|
76
|
-
* @param {
|
|
76
|
+
* @param {Record<string, string | undefined>} env - Raw environment variables
|
|
77
77
|
* @param {string} prefix - Environment variable prefix (e.g., 'DATABASE')
|
|
78
78
|
* @param {Object} [options={}] - Parsing options
|
|
79
79
|
*
|
|
80
|
-
* @returns {
|
|
80
|
+
* @returns {Record<string, any>} Parsed configuration object
|
|
81
81
|
*/
|
|
82
82
|
export function parseEnvByPrefix(env, prefix, options = {}) {
|
|
83
83
|
const prefixWithUnderscore = prefix.endsWith('_') ? prefix : `${prefix}_`;
|
|
@@ -135,14 +135,14 @@ export function parseValue(value) {
|
|
|
135
135
|
* them into configuration objects. All variables with underscores are
|
|
136
136
|
* grouped by their prefix (the part before the first underscore).
|
|
137
137
|
*
|
|
138
|
-
* @param {
|
|
138
|
+
* @param {Record<string, string | undefined>} env - Raw environment variables
|
|
139
139
|
* @param {Object} [options={}] - Parsing options
|
|
140
140
|
* @param {boolean} [options.camelCase=true]
|
|
141
141
|
* Convert env var names to camelCase object keys
|
|
142
142
|
* @param {boolean} [options.parseValues=true]
|
|
143
143
|
* Parse string values to numbers/booleans when possible
|
|
144
144
|
*
|
|
145
|
-
* @returns {
|
|
145
|
+
* @returns {Record<string, Record<string, any> | any>} Grouped environment variables
|
|
146
146
|
*
|
|
147
147
|
* @example
|
|
148
148
|
* // Input env vars:
|
|
@@ -197,7 +197,7 @@ export function autoGroupEnvByPrefix(env, options = {}) {
|
|
|
197
197
|
|
|
198
198
|
// Add remaining variables (no underscore) as top-level properties
|
|
199
199
|
for (const [key, value] of Object.entries(env)) {
|
|
200
|
-
if (!usedKeys.has(key)) {
|
|
200
|
+
if (!usedKeys.has(key) && value !== undefined) {
|
|
201
201
|
const finalKey = camelCase ? toCamelCase(key) : key.toLowerCase();
|
|
202
202
|
result[finalKey] = parseValues ? parseValue(value) : value;
|
|
203
203
|
}
|
|
@@ -209,11 +209,11 @@ export function autoGroupEnvByPrefix(env, options = {}) {
|
|
|
209
209
|
/**
|
|
210
210
|
* Group environment variables by specific prefixes
|
|
211
211
|
*
|
|
212
|
-
* @param {
|
|
212
|
+
* @param {Record<string, string | undefined>} env - Raw environment variables
|
|
213
213
|
* @param {string[]} prefixes - Array of prefixes to group by
|
|
214
214
|
* @param {Object} [options={}] - Parsing options
|
|
215
215
|
*
|
|
216
|
-
* @returns {
|
|
216
|
+
* @returns {Record<string, Record<string, any>>} Grouped environment variables
|
|
217
217
|
*
|
|
218
218
|
* @example
|
|
219
219
|
* const grouped = groupEnvByPrefixes(env, ['DATABASE', 'REDIS', 'JWT']);
|
|
@@ -236,19 +236,19 @@ export function groupEnvByPrefixes(env, prefixes, options = {}) {
|
|
|
236
236
|
/**
|
|
237
237
|
* Filter environment variables by pattern
|
|
238
238
|
*
|
|
239
|
-
* @param {
|
|
239
|
+
* @param {Record<string, string | undefined>} env - Raw environment variables
|
|
240
240
|
* @param {RegExp|string} pattern - Pattern to match against keys
|
|
241
241
|
* @param {Object} [options={}] - Parsing options
|
|
242
242
|
*
|
|
243
|
-
* @returns {
|
|
243
|
+
* @returns {Record<string, any>} Filtered and parsed environment variables
|
|
244
244
|
*/
|
|
245
245
|
export function filterEnvByPattern(env, pattern, options = {}) {
|
|
246
246
|
const regex = typeof pattern === 'string' ? new RegExp(pattern) : pattern;
|
|
247
|
-
/** @type {
|
|
247
|
+
/** @type {Record<string, string>} */
|
|
248
248
|
const filtered = {};
|
|
249
249
|
|
|
250
250
|
for (const [key, value] of Object.entries(env || {})) {
|
|
251
|
-
if (regex.test(key)) {
|
|
251
|
+
if (regex.test(key) && value !== undefined) {
|
|
252
252
|
filtered[key] = value;
|
|
253
253
|
}
|
|
254
254
|
}
|