@esposter/shared 2.4.0 → 2.5.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/dist/index.d.ts +6 -42
- package/package.json +6 -4
package/dist/index.d.ts
CHANGED
|
@@ -5,56 +5,46 @@ declare enum Operation {
|
|
|
5
5
|
Push = "Push",
|
|
6
6
|
Read = "Read",
|
|
7
7
|
Update = "Update",
|
|
8
|
-
}
|
|
8
|
+
}
|
|
9
|
+
//#endregion
|
|
9
10
|
//#region src/models/error/InvalidOperationError.d.ts
|
|
10
11
|
declare class InvalidOperationError extends Error {
|
|
11
12
|
constructor(operation: Operation, name: string, message: string);
|
|
12
13
|
}
|
|
13
|
-
|
|
14
14
|
//#endregion
|
|
15
15
|
//#region src/models/error/NotFoundError.d.ts
|
|
16
16
|
declare class NotFoundError<T extends string = string> extends Error {
|
|
17
17
|
constructor(name: T, id: string);
|
|
18
18
|
}
|
|
19
|
-
|
|
20
19
|
//#endregion
|
|
21
20
|
//#region src/models/error/NotInitializedError.d.ts
|
|
22
21
|
declare class NotInitializedError<T extends string = string> extends Error {
|
|
23
22
|
constructor(name: T);
|
|
24
23
|
}
|
|
25
|
-
|
|
26
24
|
//#endregion
|
|
27
25
|
//#region src/util/id/constants.d.ts
|
|
28
26
|
declare const ID_SEPARATOR = "|";
|
|
29
|
-
|
|
30
27
|
//#endregion
|
|
31
28
|
//#region src/util/object/isPlainObject.d.ts
|
|
32
29
|
declare const isPlainObject: (data: unknown) => data is object;
|
|
33
|
-
|
|
34
30
|
//#endregion
|
|
35
31
|
//#region src/util/types/MergeObjectsStrict.d.ts
|
|
36
32
|
type MergeObjectsStrict<T extends object[]> = T extends [infer TFirst, infer TSecond, ...infer TRemaining] ? TSecond extends { [K in keyof TSecond]: K extends keyof TFirst ? never : TSecond[K] } ? TRemaining extends object[] ? MergeObjectsStrict<[TSecond, ...TRemaining]> & TFirst : TFirst & TSecond : never : T extends [infer TFirst] ? TFirst : never;
|
|
37
|
-
|
|
38
33
|
//#endregion
|
|
39
34
|
//#region src/util/object/mergeObjectsStrict.d.ts
|
|
40
35
|
declare const mergeObjectsStrict: <T extends object[]>(...objects: T) => MergeObjectsStrict<T>;
|
|
41
|
-
|
|
42
36
|
//#endregion
|
|
43
37
|
//#region src/util/text/capitalize.d.ts
|
|
44
38
|
declare const capitalize: (string: string) => string;
|
|
45
|
-
|
|
46
39
|
//#endregion
|
|
47
40
|
//#region src/util/types/CamelToKebab.d.ts
|
|
48
41
|
type CamelToKebab<S extends string> = S extends `${infer T}${infer U}` ? U extends Uncapitalize<U> ? `${Uncapitalize<T>}${CamelToKebab<U>}` : `${Uncapitalize<T>}-${CamelToKebab<U>}` : S;
|
|
49
|
-
|
|
50
42
|
//#endregion
|
|
51
43
|
//#region src/util/text/toKebabCase.d.ts
|
|
52
44
|
declare const toKebabCase: <T extends string>(string: T) => CamelToKebab<T>;
|
|
53
|
-
|
|
54
45
|
//#endregion
|
|
55
46
|
//#region src/util/types/FunctionProperties.d.ts
|
|
56
47
|
type FunctionProperties<T> = { [K in keyof T]: T[K] extends Function ? K : never };
|
|
57
|
-
|
|
58
48
|
//#endregion
|
|
59
49
|
//#region ../../node_modules/.pnpm/type-fest@4.41.0/node_modules/type-fest/source/observable-like.d.ts
|
|
60
50
|
declare global {
|
|
@@ -64,8 +54,6 @@ declare global {
|
|
|
64
54
|
}
|
|
65
55
|
}
|
|
66
56
|
|
|
67
|
-
//#endregion
|
|
68
|
-
//#region ../../node_modules/.pnpm/type-fest@4.41.0/node_modules/type-fest/source/optional-keys-of.d.ts
|
|
69
57
|
/**
|
|
70
58
|
@remarks
|
|
71
59
|
The TC39 observable proposal defines a `closed` property, but some implementations (such as xstream) do not as of 10/08/2021.
|
|
@@ -77,6 +65,8 @@ As well, some guidance on making an `Observable` to not include `closed` propert
|
|
|
77
65
|
@category Observable
|
|
78
66
|
*/
|
|
79
67
|
|
|
68
|
+
//#endregion
|
|
69
|
+
//#region ../../node_modules/.pnpm/type-fest@4.41.0/node_modules/type-fest/source/optional-keys-of.d.ts
|
|
80
70
|
/**
|
|
81
71
|
Extract all optional keys from the given type.
|
|
82
72
|
|
|
@@ -112,11 +102,9 @@ const update2: UpdateOperation<User> = {
|
|
|
112
102
|
*/
|
|
113
103
|
type OptionalKeysOf<BaseType extends object> = BaseType extends unknown // For distributing `BaseType`
|
|
114
104
|
? (keyof { [Key in keyof BaseType as BaseType extends Record<Key, BaseType[Key]> ? never : Key]: never }) & (keyof BaseType) // Intersect with `keyof BaseType` to ensure result of `OptionalKeysOf<BaseType>` is always assignable to `keyof BaseType`
|
|
115
|
-
: never;
|
|
116
|
-
|
|
105
|
+
: never; // Should never happen
|
|
117
106
|
//#endregion
|
|
118
107
|
//#region ../../node_modules/.pnpm/type-fest@4.41.0/node_modules/type-fest/source/required-keys-of.d.ts
|
|
119
|
-
// Should never happen
|
|
120
108
|
/**
|
|
121
109
|
Extract all required keys from the given type.
|
|
122
110
|
|
|
@@ -142,12 +130,10 @@ const validator2 = createValidation<User>('surname', value => value.length < 25)
|
|
|
142
130
|
@category Utilities
|
|
143
131
|
*/
|
|
144
132
|
type RequiredKeysOf<BaseType extends object> = BaseType extends unknown // For distributing `BaseType`
|
|
145
|
-
? Exclude<keyof BaseType, OptionalKeysOf<BaseType>> : never;
|
|
133
|
+
? Exclude<keyof BaseType, OptionalKeysOf<BaseType>> : never; // Should never happen
|
|
146
134
|
|
|
147
135
|
//#endregion
|
|
148
136
|
//#region ../../node_modules/.pnpm/type-fest@4.41.0/node_modules/type-fest/source/is-never.d.ts
|
|
149
|
-
// Should never happen
|
|
150
|
-
|
|
151
137
|
/**
|
|
152
138
|
Returns a boolean for whether the given type is `never`.
|
|
153
139
|
|
|
@@ -190,7 +176,6 @@ endIfEqual('abc', '123');
|
|
|
190
176
|
@category Utilities
|
|
191
177
|
*/
|
|
192
178
|
type IsNever<T> = [T] extends [never] ? true : false;
|
|
193
|
-
|
|
194
179
|
//#endregion
|
|
195
180
|
//#region ../../node_modules/.pnpm/type-fest@4.41.0/node_modules/type-fest/source/if-never.d.ts
|
|
196
181
|
/**
|
|
@@ -213,7 +198,6 @@ type ShouldBeBar = IfNever<'not never', 'foo', 'bar'>;
|
|
|
213
198
|
@category Utilities
|
|
214
199
|
*/
|
|
215
200
|
type IfNever<T, TypeIfNever = true, TypeIfNotNever = false> = (IsNever<T> extends true ? TypeIfNever : TypeIfNotNever);
|
|
216
|
-
|
|
217
201
|
//#endregion
|
|
218
202
|
//#region ../../node_modules/.pnpm/type-fest@4.41.0/node_modules/type-fest/source/is-any.d.ts
|
|
219
203
|
// Can eventually be replaced with the built-in once this library supports
|
|
@@ -249,7 +233,6 @@ const anyA = get(anyObject, 'a');
|
|
|
249
233
|
@category Utilities
|
|
250
234
|
*/
|
|
251
235
|
type IsAny<T> = 0 extends 1 & NoInfer<T> ? true : false;
|
|
252
|
-
|
|
253
236
|
//#endregion
|
|
254
237
|
//#region ../../node_modules/.pnpm/type-fest@4.41.0/node_modules/type-fest/source/is-equal.d.ts
|
|
255
238
|
/**
|
|
@@ -279,7 +262,6 @@ type Includes<Value extends readonly any[], Item> =
|
|
|
279
262
|
@category Utilities
|
|
280
263
|
*/
|
|
281
264
|
type IsEqual<A, B> = (<G>() => G extends A & G | G ? 1 : 2) extends (<G>() => G extends B & G | G ? 1 : 2) ? true : false;
|
|
282
|
-
|
|
283
265
|
//#endregion
|
|
284
266
|
//#region ../../node_modules/.pnpm/type-fest@4.41.0/node_modules/type-fest/source/simplify.d.ts
|
|
285
267
|
/**
|
|
@@ -340,7 +322,6 @@ fn(someInterface as Simplify<SomeInterface>); // Good: transform an `interface`
|
|
|
340
322
|
@category Object
|
|
341
323
|
*/
|
|
342
324
|
type Simplify<T> = { [KeyType in keyof T]: T[KeyType] } & {};
|
|
343
|
-
|
|
344
325
|
//#endregion
|
|
345
326
|
//#region ../../node_modules/.pnpm/type-fest@4.41.0/node_modules/type-fest/source/omit-index-signature.d.ts
|
|
346
327
|
/**
|
|
@@ -434,7 +415,6 @@ type ExampleWithoutIndexSignatures = OmitIndexSignature<Example>;
|
|
|
434
415
|
@category Object
|
|
435
416
|
*/
|
|
436
417
|
type OmitIndexSignature<ObjectType> = { [KeyType in keyof ObjectType as {} extends Record<KeyType, unknown> ? never : KeyType]: ObjectType[KeyType] };
|
|
437
|
-
|
|
438
418
|
//#endregion
|
|
439
419
|
//#region ../../node_modules/.pnpm/type-fest@4.41.0/node_modules/type-fest/source/pick-index-signature.d.ts
|
|
440
420
|
/**
|
|
@@ -483,7 +463,6 @@ type ExampleIndexSignature = PickIndexSignature<Example>;
|
|
|
483
463
|
@category Object
|
|
484
464
|
*/
|
|
485
465
|
type PickIndexSignature<ObjectType> = { [KeyType in keyof ObjectType as {} extends Record<KeyType, unknown> ? KeyType : never]: ObjectType[KeyType] };
|
|
486
|
-
|
|
487
466
|
//#endregion
|
|
488
467
|
//#region ../../node_modules/.pnpm/type-fest@4.41.0/node_modules/type-fest/source/merge.d.ts
|
|
489
468
|
// Merges two objects without worrying about index signatures.
|
|
@@ -524,7 +503,6 @@ export type FooBar = Merge<Foo, Bar>;
|
|
|
524
503
|
@category Object
|
|
525
504
|
*/
|
|
526
505
|
type Merge<Destination, Source> = Simplify<SimpleMerge<PickIndexSignature<Destination>, PickIndexSignature<Source>> & SimpleMerge<OmitIndexSignature<Destination>, OmitIndexSignature<Source>>>;
|
|
527
|
-
|
|
528
506
|
//#endregion
|
|
529
507
|
//#region ../../node_modules/.pnpm/type-fest@4.41.0/node_modules/type-fest/source/if-any.d.ts
|
|
530
508
|
/**
|
|
@@ -547,7 +525,6 @@ type ShouldBeBar = IfAny<'not any', 'foo', 'bar'>;
|
|
|
547
525
|
@category Utilities
|
|
548
526
|
*/
|
|
549
527
|
type IfAny<T, TypeIfAny = true, TypeIfNotAny = false> = (IsAny<T> extends true ? TypeIfAny : TypeIfNotAny);
|
|
550
|
-
|
|
551
528
|
//#endregion
|
|
552
529
|
//#region ../../node_modules/.pnpm/type-fest@4.41.0/node_modules/type-fest/source/internal/object.d.ts
|
|
553
530
|
/**
|
|
@@ -604,7 +581,6 @@ type Result = ApplyDefaultOptions<PathsOptions, DefaultPathsOptions, SpecifiedOp
|
|
|
604
581
|
*/
|
|
605
582
|
type ApplyDefaultOptions<Options extends object, Defaults extends Simplify<Omit<Required<Options>, RequiredKeysOf<Options>> & Partial<Record<RequiredKeysOf<Options>, never>>>, SpecifiedOptions extends Options> = IfAny<SpecifiedOptions, Defaults, IfNever<SpecifiedOptions, Defaults, Simplify<Merge<Defaults, { [Key in keyof SpecifiedOptions as Key extends OptionalKeysOf<Options> ? Extract<SpecifiedOptions[Key], undefined> extends never ? Key : never : Key]: SpecifiedOptions[Key] }> & Required<Options>> // `& Required<Options>` ensures that `ApplyDefaultOptions<SomeOption, ...>` is always assignable to `Required<SomeOption>`
|
|
606
583
|
>>;
|
|
607
|
-
|
|
608
584
|
//#endregion
|
|
609
585
|
//#region ../../node_modules/.pnpm/type-fest@4.41.0/node_modules/type-fest/source/except.d.ts
|
|
610
586
|
/**
|
|
@@ -702,54 +678,42 @@ type PostPayload = Except<UserData, 'email'>;
|
|
|
702
678
|
*/
|
|
703
679
|
type Except<ObjectType, KeysType extends keyof ObjectType, Options extends ExceptOptions = {}> = _Except<ObjectType, KeysType, ApplyDefaultOptions<ExceptOptions, DefaultExceptOptions, Options>>;
|
|
704
680
|
type _Except<ObjectType, KeysType extends keyof ObjectType, Options extends Required<ExceptOptions>> = { [KeyType in keyof ObjectType as Filter<KeyType, KeysType>]: ObjectType[KeyType] } & (Options['requireExactProps'] extends true ? Partial<Record<KeysType, never>> : {});
|
|
705
|
-
|
|
706
681
|
//#endregion
|
|
707
682
|
//#region src/util/types/ExcludeFunctionProperties.d.ts
|
|
708
683
|
type ExcludeFunctionProperties<T> = Except<T, FunctionProperties<T>[keyof T]>;
|
|
709
|
-
|
|
710
684
|
//#endregion
|
|
711
685
|
//#region src/util/types/KebabToCamel.d.ts
|
|
712
686
|
type KebabToCamel<S extends string> = S extends `${infer T}-${infer U}` ? `${T}${Capitalize<KebabToCamel<U>>}` : S;
|
|
713
|
-
|
|
714
687
|
//#endregion
|
|
715
688
|
//#region src/util/types/TupleSplitHead.d.ts
|
|
716
689
|
type TupleSplitHead<T extends unknown[], N extends number> = T["length"] extends N ? T : T extends [...infer R, unknown] ? TupleSplitHead<R, N> : never;
|
|
717
|
-
|
|
718
690
|
//#endregion
|
|
719
691
|
//#region src/util/types/TupleSplitTail.d.ts
|
|
720
692
|
type TupleSplitTail<T, N extends number, O extends unknown[] = []> = O["length"] extends N ? T : T extends [infer F, ...infer R] ? TupleSplitTail<[...R], N, [...O, F]> : never;
|
|
721
|
-
|
|
722
693
|
//#endregion
|
|
723
694
|
//#region src/util/types/TupleSplit.d.ts
|
|
724
695
|
// https://stackoverflow.com/questions/67605122/obtain-a-slice-of-a-typescript-parameters-tuple
|
|
725
696
|
type TupleSplit<T extends unknown[], N extends number> = [TupleSplitHead<T, N>, TupleSplitTail<T, N>];
|
|
726
|
-
|
|
727
697
|
//#endregion
|
|
728
698
|
//#region src/util/types/SkipFirst.d.ts
|
|
729
699
|
type SkipFirst<T extends unknown[], N extends number> = TupleSplit<T, N>[1];
|
|
730
|
-
|
|
731
700
|
//#endregion
|
|
732
701
|
//#region src/util/types/TakeFirst.d.ts
|
|
733
702
|
type TakeFirst<T extends unknown[], N extends number> = TupleSplit<T, N>[0];
|
|
734
|
-
|
|
735
703
|
//#endregion
|
|
736
704
|
//#region src/util/types/TupleSlice.d.ts
|
|
737
705
|
type TupleSlice<T extends unknown[], S extends number, E extends number = T["length"]> = SkipFirst<TakeFirst<T, E>, S>;
|
|
738
|
-
|
|
739
706
|
//#endregion
|
|
740
707
|
//#region src/util/validation/exhaustiveGuard.d.ts
|
|
741
708
|
declare const exhaustiveGuard: (value: never) => never;
|
|
742
|
-
|
|
743
709
|
//#endregion
|
|
744
710
|
//#region src/util/id/uuid/constants.d.ts
|
|
745
711
|
/* eslint-disable @typescript-eslint/no-inferrable-types */
|
|
746
712
|
declare const NIL = "00000000-0000-0000-0000-000000000000";
|
|
747
713
|
declare const UUIDV4_REGEX: RegExp;
|
|
748
714
|
declare const UUIDV4_SEARCH_REGEX: RegExp;
|
|
749
|
-
|
|
750
715
|
//#endregion
|
|
751
716
|
//#region src/util/id/uuid/uuidValidateV4.d.ts
|
|
752
717
|
declare const uuidValidateV4: (uuid: string) => boolean;
|
|
753
|
-
|
|
754
718
|
//#endregion
|
|
755
719
|
export { CamelToKebab, ExcludeFunctionProperties, FunctionProperties, ID_SEPARATOR, InvalidOperationError, KebabToCamel, MergeObjectsStrict, NIL, NotFoundError, NotInitializedError, Operation, SkipFirst, TakeFirst, TupleSlice, TupleSplit, TupleSplitHead, TupleSplitTail, UUIDV4_REGEX, UUIDV4_SEARCH_REGEX, capitalize, exhaustiveGuard, isPlainObject, mergeObjectsStrict, toKebabCase, uuidValidateV4 };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@esposter/shared",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.5.0",
|
|
4
4
|
"description": "A library that contains shared typescript code.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"homepage": "https://github.com/Esposter/Esposter#readme",
|
|
@@ -23,10 +23,12 @@
|
|
|
23
23
|
},
|
|
24
24
|
"scripts": {
|
|
25
25
|
"build": "pnpm export:gen && rolldown --config rolldown.config.ts",
|
|
26
|
-
"
|
|
27
|
-
"
|
|
26
|
+
"test": "NODE_OPTIONS=--max-old-space-size=8192 vitest",
|
|
27
|
+
"coverage": "vitest run --coverage",
|
|
28
|
+
"lint": "oxlint && eslint .",
|
|
29
|
+
"lint:fix": "oxlint --fix && eslint --fix .",
|
|
28
30
|
"typecheck": "tsc",
|
|
29
31
|
"export:gen": "ctix build --config ../configuration/.ctirc-ts"
|
|
30
32
|
},
|
|
31
|
-
"gitHead": "
|
|
33
|
+
"gitHead": "8faf7789eed01e2fcff4d2206137058e3c3ee681"
|
|
32
34
|
}
|