@transcend-io/type-utils 2.0.1 → 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +201 -21
- package/dist/index.d.mts +591 -0
- package/dist/index.d.mts.map +1 -0
- package/dist/index.mjs +529 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +33 -43
- package/.yarn/sdks/eslint/package.json +0 -14
- package/.yarn/sdks/prettier/package.json +0 -7
- package/.yarn/sdks/typescript/package.json +0 -10
- package/README.md +0 -37
- package/build/aggregateObjects.d.ts +0 -27
- package/build/aggregateObjects.d.ts.map +0 -1
- package/build/aggregateObjects.js +0 -34
- package/build/aggregateObjects.js.map +0 -1
- package/build/apply.d.ts +0 -35
- package/build/apply.d.ts.map +0 -1
- package/build/apply.js +0 -47
- package/build/apply.js.map +0 -1
- package/build/codecTools/FixedLengthArray.d.ts +0 -20
- package/build/codecTools/FixedLengthArray.d.ts.map +0 -1
- package/build/codecTools/FixedLengthArray.js +0 -11
- package/build/codecTools/FixedLengthArray.js.map +0 -1
- package/build/codecTools/FixedLengthString.d.ts +0 -17
- package/build/codecTools/FixedLengthString.d.ts.map +0 -1
- package/build/codecTools/FixedLengthString.js +0 -10
- package/build/codecTools/FixedLengthString.js.map +0 -1
- package/build/codecTools/NonEmptyString.d.ts +0 -12
- package/build/codecTools/NonEmptyString.d.ts.map +0 -1
- package/build/codecTools/NonEmptyString.js +0 -6
- package/build/codecTools/NonEmptyString.js.map +0 -1
- package/build/codecTools/createDefaultCodec.d.ts +0 -39
- package/build/codecTools/createDefaultCodec.d.ts.map +0 -1
- package/build/codecTools/createDefaultCodec.js +0 -114
- package/build/codecTools/createDefaultCodec.js.map +0 -1
- package/build/codecTools/decodeCodec.d.ts +0 -12
- package/build/codecTools/decodeCodec.d.ts.map +0 -1
- package/build/codecTools/decodeCodec.js +0 -47
- package/build/codecTools/decodeCodec.js.map +0 -1
- package/build/codecTools/dictionary.d.ts +0 -18
- package/build/codecTools/dictionary.d.ts.map +0 -1
- package/build/codecTools/dictionary.js +0 -13
- package/build/codecTools/dictionary.js.map +0 -1
- package/build/codecTools/index.d.ts +0 -10
- package/build/codecTools/index.d.ts.map +0 -1
- package/build/codecTools/index.js +0 -10
- package/build/codecTools/index.js.map +0 -1
- package/build/codecTools/isCodecError.d.ts +0 -7
- package/build/codecTools/isCodecError.d.ts.map +0 -1
- package/build/codecTools/isCodecError.js +0 -9
- package/build/codecTools/isCodecError.js.map +0 -1
- package/build/codecTools/partialRecord.d.ts +0 -16
- package/build/codecTools/partialRecord.d.ts.map +0 -1
- package/build/codecTools/partialRecord.js +0 -11
- package/build/codecTools/partialRecord.js.map +0 -1
- package/build/codecTools/toJsonSchema.d.ts +0 -11
- package/build/codecTools/toJsonSchema.d.ts.map +0 -1
- package/build/codecTools/toJsonSchema.js +0 -115
- package/build/codecTools/toJsonSchema.js.map +0 -1
- package/build/enum.d.ts +0 -47
- package/build/enum.d.ts.map +0 -1
- package/build/enum.js +0 -44
- package/build/enum.js.map +0 -1
- package/build/enums.d.ts +0 -20
- package/build/enums.d.ts.map +0 -1
- package/build/enums.js +0 -18
- package/build/enums.js.map +0 -1
- package/build/findAllWithRegex.d.ts +0 -41
- package/build/findAllWithRegex.d.ts.map +0 -1
- package/build/findAllWithRegex.js +0 -41
- package/build/findAllWithRegex.js.map +0 -1
- package/build/flattenObject.d.ts +0 -33
- package/build/flattenObject.d.ts.map +0 -1
- package/build/flattenObject.js +0 -72
- package/build/flattenObject.js.map +0 -1
- package/build/fromEntries.d.ts +0 -9
- package/build/fromEntries.d.ts.map +0 -1
- package/build/fromEntries.js +0 -9
- package/build/fromEntries.js.map +0 -1
- package/build/getEntries.d.ts +0 -8
- package/build/getEntries.d.ts.map +0 -1
- package/build/getEntries.js +0 -10
- package/build/getEntries.js.map +0 -1
- package/build/getKeys.d.ts +0 -14
- package/build/getKeys.d.ts.map +0 -1
- package/build/getKeys.js +0 -19
- package/build/getKeys.js.map +0 -1
- package/build/getValues.d.ts +0 -9
- package/build/getValues.d.ts.map +0 -1
- package/build/getValues.js +0 -9
- package/build/getValues.js.map +0 -1
- package/build/gql.d.ts +0 -22
- package/build/gql.d.ts.map +0 -1
- package/build/gql.js +0 -32
- package/build/gql.js.map +0 -1
- package/build/groupBy.d.ts +0 -11
- package/build/groupBy.d.ts.map +0 -1
- package/build/groupBy.js +0 -20
- package/build/groupBy.js.map +0 -1
- package/build/index.d.ts +0 -19
- package/build/index.d.ts.map +0 -1
- package/build/index.js +0 -19
- package/build/index.js.map +0 -1
- package/build/invert.d.ts +0 -23
- package/build/invert.d.ts.map +0 -1
- package/build/invert.js +0 -79
- package/build/invert.js.map +0 -1
- package/build/noExcess.d.ts +0 -33
- package/build/noExcess.d.ts.map +0 -1
- package/build/noExcess.js +0 -153
- package/build/noExcess.js.map +0 -1
- package/build/tests/FixedLengthArray.test.d.ts +0 -2
- package/build/tests/FixedLengthArray.test.d.ts.map +0 -1
- package/build/tests/FixedLengthArray.test.js +0 -15
- package/build/tests/FixedLengthArray.test.js.map +0 -1
- package/build/tests/aggregateObjects.test.d.ts +0 -2
- package/build/tests/aggregateObjects.test.d.ts.map +0 -1
- package/build/tests/aggregateObjects.test.js +0 -98
- package/build/tests/aggregateObjects.test.js.map +0 -1
- package/build/tests/createDefaultCodec.test.d.ts +0 -2
- package/build/tests/createDefaultCodec.test.d.ts.map +0 -1
- package/build/tests/createDefaultCodec.test.js +0 -104
- package/build/tests/createDefaultCodec.test.js.map +0 -1
- package/build/tests/decodeCodec.test.d.ts +0 -2
- package/build/tests/decodeCodec.test.d.ts.map +0 -1
- package/build/tests/decodeCodec.test.js +0 -43
- package/build/tests/decodeCodec.test.js.map +0 -1
- package/build/tests/enum.test.d.ts +0 -2
- package/build/tests/enum.test.d.ts.map +0 -1
- package/build/tests/enum.test.js +0 -21
- package/build/tests/enum.test.js.map +0 -1
- package/build/tests/flattenObject.test.d.ts +0 -2
- package/build/tests/flattenObject.test.d.ts.map +0 -1
- package/build/tests/flattenObject.test.js +0 -115
- package/build/tests/flattenObject.test.js.map +0 -1
- package/build/tests/gql.test.d.ts +0 -2
- package/build/tests/gql.test.d.ts.map +0 -1
- package/build/tests/gql.test.js +0 -44
- package/build/tests/gql.test.js.map +0 -1
- package/build/tests/groupBy.test.d.ts +0 -2
- package/build/tests/groupBy.test.d.ts.map +0 -1
- package/build/tests/groupBy.test.js +0 -13
- package/build/tests/groupBy.test.js.map +0 -1
- package/build/tests/invert.test.d.ts +0 -2
- package/build/tests/invert.test.d.ts.map +0 -1
- package/build/tests/invert.test.js +0 -50
- package/build/tests/invert.test.js.map +0 -1
- package/build/tests/noExcess.test.d.ts +0 -2
- package/build/tests/noExcess.test.d.ts.map +0 -1
- package/build/tests/noExcess.test.js +0 -65
- package/build/tests/noExcess.test.js.map +0 -1
- package/build/tests/transposeObjectArray.test.d.ts +0 -2
- package/build/tests/transposeObjectArray.test.d.ts.map +0 -1
- package/build/tests/transposeObjectArray.test.js +0 -155
- package/build/tests/transposeObjectArray.test.js.map +0 -1
- package/build/transposeObjectArray.d.ts +0 -67
- package/build/transposeObjectArray.d.ts.map +0 -1
- package/build/transposeObjectArray.js +0 -39
- package/build/transposeObjectArray.js.map +0 -1
- package/build/tsbuildinfo +0 -1
- package/build/types.d.ts +0 -150
- package/build/types.d.ts.map +0 -1
- package/build/types.js +0 -2
- package/build/types.js.map +0 -1
- package/build/valuesOf.d.ts +0 -12
- package/build/valuesOf.d.ts.map +0 -1
- package/build/valuesOf.js +0 -14
- package/build/valuesOf.js.map +0 -1
package/build/flattenObject.js
DELETED
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
// eslint-disable-next-line eslint-comments/disable-enable-pair
|
|
2
|
-
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
3
|
-
import { aggregateObjects } from './aggregateObjects.js';
|
|
4
|
-
/**
|
|
5
|
-
*
|
|
6
|
-
* Flattens a nested object into a single-level object with concatenated key names. Useful
|
|
7
|
-
* for converting objects to CSV.
|
|
8
|
-
* @param param - The information about the object to flatten
|
|
9
|
-
* @returns A flattened object where nested keys are joined with underscores
|
|
10
|
-
* @example
|
|
11
|
-
* const nested = {
|
|
12
|
-
* user: {
|
|
13
|
-
* name: 'John',
|
|
14
|
-
* address: {
|
|
15
|
-
* city: 'NY',
|
|
16
|
-
* zip: 10001
|
|
17
|
-
* },
|
|
18
|
-
* hobbies: ['reading', 'gaming']
|
|
19
|
-
* }
|
|
20
|
-
* };
|
|
21
|
-
*
|
|
22
|
-
* flattenObject(nested)
|
|
23
|
-
* // Returns: {
|
|
24
|
-
* // user_name: 'John',
|
|
25
|
-
* // user_address_city: 'NY',
|
|
26
|
-
* // user_address_zip: 10001,
|
|
27
|
-
* // user_hobbies: 'reading,gaming'
|
|
28
|
-
* // }
|
|
29
|
-
*/
|
|
30
|
-
export const flattenObject = ({ obj, prefix = '', }) => !obj
|
|
31
|
-
? {}
|
|
32
|
-
: Object.keys(obj !== null && obj !== void 0 ? obj : []).reduce((acc, key) => {
|
|
33
|
-
const newKey = prefix ? `${prefix}_${key}` : key;
|
|
34
|
-
const entry = obj[key];
|
|
35
|
-
// Handle arrays of objects
|
|
36
|
-
if (Array.isArray(entry) &&
|
|
37
|
-
entry.length > 0 &&
|
|
38
|
-
entry.some((item) => typeof item === 'object' && item !== null)) {
|
|
39
|
-
// Flatten each object in the array
|
|
40
|
-
const objEntries = entry.filter((item) => typeof item === 'object' && item !== null);
|
|
41
|
-
const flattenedObjects = objEntries.map((item) => flattenObject({ obj: item }));
|
|
42
|
-
// Aggregate the flattened objects
|
|
43
|
-
const aggregated = aggregateObjects({ objs: flattenedObjects });
|
|
44
|
-
// Add prefix to all keys
|
|
45
|
-
Object.entries(aggregated).forEach(([k, v]) => {
|
|
46
|
-
acc[`${newKey}_${k}`] = v;
|
|
47
|
-
});
|
|
48
|
-
}
|
|
49
|
-
// Handle regular objects
|
|
50
|
-
else if (typeof entry === 'object' &&
|
|
51
|
-
entry !== null &&
|
|
52
|
-
!Array.isArray(entry)) {
|
|
53
|
-
Object.assign(acc, flattenObject({ obj: entry, prefix: newKey }));
|
|
54
|
-
}
|
|
55
|
-
// Handle primitive arrays and other values
|
|
56
|
-
else {
|
|
57
|
-
acc[newKey] = Array.isArray(entry)
|
|
58
|
-
? entry
|
|
59
|
-
.map((e) => {
|
|
60
|
-
if (typeof e === 'string') {
|
|
61
|
-
return e.replaceAll(',', '');
|
|
62
|
-
}
|
|
63
|
-
return e !== null && e !== void 0 ? e : '';
|
|
64
|
-
})
|
|
65
|
-
.join(',')
|
|
66
|
-
: typeof entry === 'string'
|
|
67
|
-
? entry.replaceAll(',', '')
|
|
68
|
-
: entry !== null && entry !== void 0 ? entry : '';
|
|
69
|
-
}
|
|
70
|
-
return acc;
|
|
71
|
-
}, {});
|
|
72
|
-
//# sourceMappingURL=flattenObject.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"flattenObject.js","sourceRoot":"","sources":["../src/flattenObject.ts"],"names":[],"mappings":"AAAA,+DAA+D;AAC/D,uDAAuD;AAEvD,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAEzD;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,EAC5B,GAAG,EACH,MAAM,GAAG,EAAE,GAMZ,EAAO,EAAE,CACR,CAAC,GAAG;IACF,CAAC,CAAC,EAAE;IACJ,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,aAAH,GAAG,cAAH,GAAG,GAAI,EAAE,CAAC,CAAC,MAAM,CAC3B,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE;QACX,MAAM,MAAM,GAAG,MAAM,CAAC,CAAC,CAAC,GAAG,MAAM,IAAI,GAAG,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC;QACjD,MAAM,KAAK,GAAG,GAAG,CAAC,GAAG,CAAC,CAAC;QAEvB,2BAA2B;QAC3B,IACE,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC;YACpB,KAAK,CAAC,MAAM,GAAG,CAAC;YAChB,KAAK,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,OAAO,IAAI,KAAK,QAAQ,IAAI,IAAI,KAAK,IAAI,CAAC,EAC/D,CAAC;YACD,mCAAmC;YACnC,MAAM,UAAU,GAAG,KAAK,CAAC,MAAM,CAC7B,CAAC,IAAI,EAAE,EAAE,CAAC,OAAO,IAAI,KAAK,QAAQ,IAAI,IAAI,KAAK,IAAI,CACpD,CAAC;YACF,MAAM,gBAAgB,GAAG,UAAU,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAC/C,aAAa,CAAC,EAAE,GAAG,EAAE,IAAI,EAAE,CAAC,CAC7B,CAAC;YACF,kCAAkC;YAClC,MAAM,UAAU,GAAG,gBAAgB,CAAC,EAAE,IAAI,EAAE,gBAAgB,EAAE,CAAC,CAAC;YAChE,yBAAyB;YACzB,MAAM,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE;gBAC5C,GAAG,CAAC,GAAG,MAAM,IAAI,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC;YAC5B,CAAC,CAAC,CAAC;QACL,CAAC;QACD,yBAAyB;aACpB,IACH,OAAO,KAAK,KAAK,QAAQ;YACzB,KAAK,KAAK,IAAI;YACd,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EACrB,CAAC;YACD,MAAM,CAAC,MAAM,CAAC,GAAG,EAAE,aAAa,CAAC,EAAE,GAAG,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC;QACpE,CAAC;QACD,2CAA2C;aACtC,CAAC;YACJ,GAAG,CAAC,MAAM,CAAC,GAAG,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC;gBAChC,CAAC,CAAC,KAAK;qBACF,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE;oBACT,IAAI,OAAO,CAAC,KAAK,QAAQ,EAAE,CAAC;wBAC1B,OAAO,CAAC,CAAC,UAAU,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC;oBAC/B,CAAC;oBACD,OAAO,CAAC,aAAD,CAAC,cAAD,CAAC,GAAI,EAAE,CAAC;gBACjB,CAAC,CAAC;qBACD,IAAI,CAAC,GAAG,CAAC;gBACd,CAAC,CAAC,OAAO,KAAK,KAAK,QAAQ;oBAC3B,CAAC,CAAC,KAAK,CAAC,UAAU,CAAC,GAAG,EAAE,EAAE,CAAC;oBAC3B,CAAC,CAAC,KAAK,aAAL,KAAK,cAAL,KAAK,GAAI,EAAE,CAAC;QAClB,CAAC;QACD,OAAO,GAAG,CAAC;IACb,CAAC,EACD,EAAyB,CAC1B,CAAC"}
|
package/build/fromEntries.d.ts
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Object.fromEntries that actually preserves entries as types.
|
|
3
|
-
* @param entries - The entries to build the object from
|
|
4
|
-
* @returns The object as built from the entries
|
|
5
|
-
*/
|
|
6
|
-
export declare function fromEntries<const T extends ReadonlyArray<readonly [PropertyKey, unknown]>>(entries: T): {
|
|
7
|
-
[K in T[number] as K[0]]: K[1];
|
|
8
|
-
};
|
|
9
|
-
//# sourceMappingURL=fromEntries.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"fromEntries.d.ts","sourceRoot":"","sources":["../src/fromEntries.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,wBAAgB,WAAW,CACzB,KAAK,CAAC,CAAC,SAAS,aAAa,CAAC,SAAS,CAAC,WAAW,EAAE,OAAO,CAAC,CAAC,EAC9D,OAAO,EAAE,CAAC,GAAG;KAAG,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;CAAE,CAEhD"}
|
package/build/fromEntries.js
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Object.fromEntries that actually preserves entries as types.
|
|
3
|
-
* @param entries - The entries to build the object from
|
|
4
|
-
* @returns The object as built from the entries
|
|
5
|
-
*/
|
|
6
|
-
export function fromEntries(entries) {
|
|
7
|
-
return Object.fromEntries(entries);
|
|
8
|
-
}
|
|
9
|
-
//# sourceMappingURL=fromEntries.js.map
|
package/build/fromEntries.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"fromEntries.js","sourceRoot":"","sources":["../src/fromEntries.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,MAAM,UAAU,WAAW,CAEzB,OAAU;IACV,OAAO,MAAM,CAAC,WAAW,CAAC,OAAO,CAAuC,CAAC;AAC3E,CAAC"}
|
package/build/getEntries.d.ts
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import type { ObjByString } from './types.js';
|
|
2
|
-
/**
|
|
3
|
-
* Object.entries that actually preserves entries as types.
|
|
4
|
-
* @param o - The object to get the entries from
|
|
5
|
-
* @returns The entries of the object preserving type
|
|
6
|
-
*/
|
|
7
|
-
export declare function getEntries<TKey extends keyof TObj, TObj extends ObjByString>(o: TObj): [TKey, TObj[TKey]][];
|
|
8
|
-
//# sourceMappingURL=getEntries.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"getEntries.d.ts","sourceRoot":"","sources":["../src/getEntries.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAE9C;;;;GAIG;AACH,wBAAgB,UAAU,CAAC,IAAI,SAAS,MAAM,IAAI,EAAE,IAAI,SAAS,WAAW,EAC1E,CAAC,EAAE,IAAI,GACN,CAAC,IAAI,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC,EAAE,CAGtB"}
|
package/build/getEntries.js
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Object.entries that actually preserves entries as types.
|
|
3
|
-
* @param o - The object to get the entries from
|
|
4
|
-
* @returns The entries of the object preserving type
|
|
5
|
-
*/
|
|
6
|
-
export function getEntries(o) {
|
|
7
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
8
|
-
return Object.entries(o);
|
|
9
|
-
}
|
|
10
|
-
//# sourceMappingURL=getEntries.js.map
|
package/build/getEntries.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"getEntries.js","sourceRoot":"","sources":["../src/getEntries.ts"],"names":[],"mappings":"AAGA;;;;GAIG;AACH,MAAM,UAAU,UAAU,CACxB,CAAO;IAEP,8DAA8D;IAC9D,OAAO,MAAM,CAAC,OAAO,CAAC,CAAC,CAAQ,CAAC;AAClC,CAAC"}
|
package/build/getKeys.d.ts
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import type { StringKeys } from './types.js';
|
|
2
|
-
/**
|
|
3
|
-
* Object.keys for string keys only
|
|
4
|
-
* @param o - The object to get the keys from
|
|
5
|
-
* @returns The string keys of the object preserving type
|
|
6
|
-
*/
|
|
7
|
-
export declare function getStringKeys<T extends {}>(o: T): StringKeys<T>[];
|
|
8
|
-
/**
|
|
9
|
-
* Object.keys that actually preserves keys as types.
|
|
10
|
-
* @param o - The object to get the keys from
|
|
11
|
-
* @returns The keys of the object preserving type
|
|
12
|
-
*/
|
|
13
|
-
export declare function getKeys<T extends {}>(o: T): (keyof T)[];
|
|
14
|
-
//# sourceMappingURL=getKeys.d.ts.map
|
package/build/getKeys.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"getKeys.d.ts","sourceRoot":"","sources":["../src/getKeys.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAG7C;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,CAAC,SAAS,EAAE,EAAE,CAAC,EAAE,CAAC,GAAG,UAAU,CAAC,CAAC,CAAC,EAAE,CAEjE;AAED;;;;GAIG;AACH,wBAAgB,OAAO,CAAC,CAAC,SAAS,EAAE,EAAE,CAAC,EAAE,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,EAAE,CAEvD"}
|
package/build/getKeys.js
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
/* eslint-disable @typescript-eslint/ban-types */
|
|
2
|
-
/**
|
|
3
|
-
* Object.keys for string keys only
|
|
4
|
-
* @param o - The object to get the keys from
|
|
5
|
-
* @returns The string keys of the object preserving type
|
|
6
|
-
*/
|
|
7
|
-
export function getStringKeys(o) {
|
|
8
|
-
return Object.keys(o).filter((k) => typeof k === 'string');
|
|
9
|
-
}
|
|
10
|
-
/**
|
|
11
|
-
* Object.keys that actually preserves keys as types.
|
|
12
|
-
* @param o - The object to get the keys from
|
|
13
|
-
* @returns The keys of the object preserving type
|
|
14
|
-
*/
|
|
15
|
-
export function getKeys(o) {
|
|
16
|
-
return Object.keys(o);
|
|
17
|
-
}
|
|
18
|
-
/* eslint-enable @typescript-eslint/ban-types */
|
|
19
|
-
//# sourceMappingURL=getKeys.js.map
|
package/build/getKeys.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"getKeys.js","sourceRoot":"","sources":["../src/getKeys.ts"],"names":[],"mappings":"AAGA,iDAAiD;AACjD;;;;GAIG;AACH,MAAM,UAAU,aAAa,CAAe,CAAI;IAC9C,OAAO,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,OAAO,CAAC,KAAK,QAAQ,CAAoB,CAAC;AAChF,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,OAAO,CAAe,CAAI;IACxC,OAAO,MAAM,CAAC,IAAI,CAAC,CAAC,CAAgB,CAAC;AACvC,CAAC;AACD,gDAAgD"}
|
package/build/getValues.d.ts
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Object.values that actually preserves values as types.
|
|
3
|
-
* @param o - The object to get the values from
|
|
4
|
-
* @returns The values of the object preserving type
|
|
5
|
-
*/
|
|
6
|
-
export declare function getValues<TVal>(o: {
|
|
7
|
-
[k in string | number | symbol]: TVal;
|
|
8
|
-
}): TVal[];
|
|
9
|
-
//# sourceMappingURL=getValues.d.ts.map
|
package/build/getValues.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"getValues.d.ts","sourceRoot":"","sources":["../src/getValues.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,wBAAgB,SAAS,CAAC,IAAI,EAAE,CAAC,EAAE;KAChC,CAAC,IAAI,MAAM,GAAG,MAAM,GAAG,MAAM,GAAG,IAAI;CACtC,GAAG,IAAI,EAAE,CAET"}
|
package/build/getValues.js
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Object.values that actually preserves values as types.
|
|
3
|
-
* @param o - The object to get the values from
|
|
4
|
-
* @returns The values of the object preserving type
|
|
5
|
-
*/
|
|
6
|
-
export function getValues(o) {
|
|
7
|
-
return Object.values(o);
|
|
8
|
-
}
|
|
9
|
-
//# sourceMappingURL=getValues.js.map
|
package/build/getValues.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"getValues.js","sourceRoot":"","sources":["../src/getValues.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,MAAM,UAAU,SAAS,CAAO,CAE/B;IACC,OAAO,MAAM,CAAC,MAAM,CAAC,CAAC,CAAW,CAAC;AACpC,CAAC"}
|
package/build/gql.d.ts
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Identify if a string is an interface
|
|
3
|
-
*/
|
|
4
|
-
export declare const INTERFACE_REGEX: RegExp;
|
|
5
|
-
/**
|
|
6
|
-
* A gql is simply a string but enforced to be some underlying type
|
|
7
|
-
*/
|
|
8
|
-
export type Gql<TGraphQLType extends object> = string & {
|
|
9
|
-
/** The typescript type definition that relates to the gql */
|
|
10
|
-
graphQLType: TGraphQLType;
|
|
11
|
-
};
|
|
12
|
-
/**
|
|
13
|
-
* Create a gql tag. This may one day be replaced by apollo graphql-tag.
|
|
14
|
-
* I like being able to create un-named fragments that can be constructed into a graphql statement.
|
|
15
|
-
* It is nice to wrap the fragment in a gql tag to get editor highlighting, however the need to co-localize each fragment definition with the
|
|
16
|
-
* resulting graphql statement is a pain, and thus why graphql-tag is not used.
|
|
17
|
-
* @param strings - The template string
|
|
18
|
-
* @param expressions - The expressions injected into the template
|
|
19
|
-
* @returns The gql string that was the inputs
|
|
20
|
-
*/
|
|
21
|
-
export declare function gql<TGraphQLType extends object>(strings: TemplateStringsArray, ...expressions: (string | number)[]): Gql<TGraphQLType>;
|
|
22
|
-
//# sourceMappingURL=gql.d.ts.map
|
package/build/gql.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"gql.d.ts","sourceRoot":"","sources":["../src/gql.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,eAAO,MAAM,eAAe,QACyC,CAAC;AAEtE;;GAEG;AACH,MAAM,MAAM,GAAG,CAAC,YAAY,SAAS,MAAM,IAAI,MAAM,GAAG;IACtD,6DAA6D;IAC7D,WAAW,EAAE,YAAY,CAAC;CAC3B,CAAC;AAEF;;;;;;;;GAQG;AACH,wBAAgB,GAAG,CAAC,YAAY,SAAS,MAAM,EAC7C,OAAO,EAAE,oBAAoB,EAC7B,GAAG,WAAW,EAAE,CAAC,MAAM,GAAG,MAAM,CAAC,EAAE,GAClC,GAAG,CAAC,YAAY,CAAC,CAqBnB"}
|
package/build/gql.js
DELETED
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Identify if a string is an interface
|
|
3
|
-
*/
|
|
4
|
-
export const INTERFACE_REGEX = /(interface|type|input) [a-zA-Z0-9]* (implements .+?|){([\s\S]+?)}/;
|
|
5
|
-
/**
|
|
6
|
-
* Create a gql tag. This may one day be replaced by apollo graphql-tag.
|
|
7
|
-
* I like being able to create un-named fragments that can be constructed into a graphql statement.
|
|
8
|
-
* It is nice to wrap the fragment in a gql tag to get editor highlighting, however the need to co-localize each fragment definition with the
|
|
9
|
-
* resulting graphql statement is a pain, and thus why graphql-tag is not used.
|
|
10
|
-
* @param strings - The template string
|
|
11
|
-
* @param expressions - The expressions injected into the template
|
|
12
|
-
* @returns The gql string that was the inputs
|
|
13
|
-
*/
|
|
14
|
-
export function gql(strings, ...expressions) {
|
|
15
|
-
// If there are no expressions included in the literal
|
|
16
|
-
if (expressions.length === 0) {
|
|
17
|
-
return strings[0];
|
|
18
|
-
}
|
|
19
|
-
const n = strings.length - 1;
|
|
20
|
-
let result = '';
|
|
21
|
-
for (let i = 0; i < n; i += 1) {
|
|
22
|
-
const expression = expressions[i];
|
|
23
|
-
// Get properties from an interface
|
|
24
|
-
const useExpression = INTERFACE_REGEX.test(typeof expression === 'string' ? expression : expression.toString())
|
|
25
|
-
? (INTERFACE_REGEX.exec(typeof expression === 'string' ? expression : expression.toString()) || [])[3]
|
|
26
|
-
: expression;
|
|
27
|
-
result += strings[i] + useExpression;
|
|
28
|
-
}
|
|
29
|
-
result += strings[n];
|
|
30
|
-
return result;
|
|
31
|
-
}
|
|
32
|
-
//# sourceMappingURL=gql.js.map
|
package/build/gql.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"gql.js","sourceRoot":"","sources":["../src/gql.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,CAAC,MAAM,eAAe,GAC1B,mEAAmE,CAAC;AAUtE;;;;;;;;GAQG;AACH,MAAM,UAAU,GAAG,CACjB,OAA6B,EAC7B,GAAG,WAAgC;IAEnC,sDAAsD;IACtD,IAAI,WAAW,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAC7B,OAAO,OAAO,CAAC,CAAC,CAAsB,CAAC;IACzC,CAAC;IACD,MAAM,CAAC,GAAG,OAAO,CAAC,MAAM,GAAG,CAAC,CAAC;IAC7B,IAAI,MAAM,GAAG,EAAE,CAAC;IAChB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC;QAC9B,MAAM,UAAU,GAAG,WAAW,CAAC,CAAC,CAAC,CAAC;QAClC,mCAAmC;QACnC,MAAM,aAAa,GAAG,eAAe,CAAC,IAAI,CACxC,OAAO,UAAU,KAAK,QAAQ,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,UAAU,CAAC,QAAQ,EAAE,CACpE;YACC,CAAC,CAAC,CAAC,eAAe,CAAC,IAAI,CACnB,OAAO,UAAU,KAAK,QAAQ,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,UAAU,CAAC,QAAQ,EAAE,CACpE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC;YACb,CAAC,CAAC,UAAU,CAAC;QACf,MAAM,IAAI,OAAO,CAAC,CAAC,CAAC,GAAG,aAAa,CAAC;IACvC,CAAC;IACD,MAAM,IAAI,OAAO,CAAC,CAAC,CAAC,CAAC;IACrB,OAAO,MAA2B,CAAC;AACrC,CAAC"}
|
package/build/groupBy.d.ts
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* A typed version of lodash's _.groupBy.
|
|
3
|
-
*
|
|
4
|
-
* Returns a map of identifiers to elements from a given
|
|
5
|
-
* list that return that identifier.
|
|
6
|
-
* @param iterable - the list to group by keys
|
|
7
|
-
* @param getKey - the function to apply to an element of the list to get the key it should belong in
|
|
8
|
-
* @returns a map of identifiers to values that mapped to that identifier
|
|
9
|
-
*/
|
|
10
|
-
export declare function groupBy<T, K>(iterable: T[], getKey: (item: T) => K): Map<K, T[]>;
|
|
11
|
-
//# sourceMappingURL=groupBy.d.ts.map
|
package/build/groupBy.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"groupBy.d.ts","sourceRoot":"","sources":["../src/groupBy.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,wBAAgB,OAAO,CAAC,CAAC,EAAE,CAAC,EAC1B,QAAQ,EAAE,CAAC,EAAE,EACb,MAAM,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC,GACrB,GAAG,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAQb"}
|
package/build/groupBy.js
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* A typed version of lodash's _.groupBy.
|
|
3
|
-
*
|
|
4
|
-
* Returns a map of identifiers to elements from a given
|
|
5
|
-
* list that return that identifier.
|
|
6
|
-
* @param iterable - the list to group by keys
|
|
7
|
-
* @param getKey - the function to apply to an element of the list to get the key it should belong in
|
|
8
|
-
* @returns a map of identifiers to values that mapped to that identifier
|
|
9
|
-
*/
|
|
10
|
-
export function groupBy(iterable, getKey) {
|
|
11
|
-
return iterable.reduce((groupedItems, item) => {
|
|
12
|
-
var _a;
|
|
13
|
-
const groupedKey = getKey(item);
|
|
14
|
-
return groupedItems.set(groupedKey, [
|
|
15
|
-
...((_a = groupedItems.get(groupedKey)) !== null && _a !== void 0 ? _a : []),
|
|
16
|
-
item,
|
|
17
|
-
]);
|
|
18
|
-
}, new Map());
|
|
19
|
-
}
|
|
20
|
-
//# sourceMappingURL=groupBy.js.map
|
package/build/groupBy.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"groupBy.js","sourceRoot":"","sources":["../src/groupBy.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,MAAM,UAAU,OAAO,CACrB,QAAa,EACb,MAAsB;IAEtB,OAAO,QAAQ,CAAC,MAAM,CAAC,CAAC,YAAY,EAAE,IAAI,EAAE,EAAE;;QAC5C,MAAM,UAAU,GAAG,MAAM,CAAC,IAAI,CAAC,CAAC;QAChC,OAAO,YAAY,CAAC,GAAG,CAAC,UAAU,EAAE;YAClC,GAAG,CAAC,MAAA,YAAY,CAAC,GAAG,CAAC,UAAU,CAAC,mCAAI,EAAE,CAAC;YACvC,IAAI;SACL,CAAC,CAAC;IACL,CAAC,EAAE,IAAI,GAAG,EAAU,CAAC,CAAC;AACxB,CAAC"}
|
package/build/index.d.ts
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
export * from './apply.js';
|
|
2
|
-
export * from './codecTools/index.js';
|
|
3
|
-
export * from './enum.js';
|
|
4
|
-
export * from './enums.js';
|
|
5
|
-
export * from './getEntries.js';
|
|
6
|
-
export * from './getKeys.js';
|
|
7
|
-
export * from './getValues.js';
|
|
8
|
-
export * from './groupBy.js';
|
|
9
|
-
export * from './gql.js';
|
|
10
|
-
export * from './invert.js';
|
|
11
|
-
export * from './types.js';
|
|
12
|
-
export * from './valuesOf.js';
|
|
13
|
-
export * from './findAllWithRegex.js';
|
|
14
|
-
export * from './flattenObject.js';
|
|
15
|
-
export * from './aggregateObjects.js';
|
|
16
|
-
export * from './transposeObjectArray.js';
|
|
17
|
-
export * from './fromEntries.js';
|
|
18
|
-
export * from './noExcess.js';
|
|
19
|
-
//# sourceMappingURL=index.d.ts.map
|
package/build/index.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,uBAAuB,CAAC;AACtC,cAAc,WAAW,CAAC;AAC1B,cAAc,YAAY,CAAC;AAC3B,cAAc,iBAAiB,CAAC;AAChC,cAAc,cAAc,CAAC;AAC7B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,cAAc,CAAC;AAC7B,cAAc,UAAU,CAAC;AACzB,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC;AAC3B,cAAc,eAAe,CAAC;AAC9B,cAAc,uBAAuB,CAAC;AACtC,cAAc,oBAAoB,CAAC;AACnC,cAAc,uBAAuB,CAAC;AACtC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,kBAAkB,CAAC;AACjC,cAAc,eAAe,CAAC"}
|
package/build/index.js
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
export * from './apply.js';
|
|
2
|
-
export * from './codecTools/index.js';
|
|
3
|
-
export * from './enum.js';
|
|
4
|
-
export * from './enums.js';
|
|
5
|
-
export * from './getEntries.js';
|
|
6
|
-
export * from './getKeys.js';
|
|
7
|
-
export * from './getValues.js';
|
|
8
|
-
export * from './groupBy.js';
|
|
9
|
-
export * from './gql.js';
|
|
10
|
-
export * from './invert.js';
|
|
11
|
-
export * from './types.js';
|
|
12
|
-
export * from './valuesOf.js';
|
|
13
|
-
export * from './findAllWithRegex.js';
|
|
14
|
-
export * from './flattenObject.js';
|
|
15
|
-
export * from './aggregateObjects.js';
|
|
16
|
-
export * from './transposeObjectArray.js';
|
|
17
|
-
export * from './fromEntries.js';
|
|
18
|
-
export * from './noExcess.js';
|
|
19
|
-
//# sourceMappingURL=index.js.map
|
package/build/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,uBAAuB,CAAC;AACtC,cAAc,WAAW,CAAC;AAC1B,cAAc,YAAY,CAAC;AAC3B,cAAc,iBAAiB,CAAC;AAChC,cAAc,cAAc,CAAC;AAC7B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,cAAc,CAAC;AAC7B,cAAc,UAAU,CAAC;AACzB,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC;AAC3B,cAAc,eAAe,CAAC;AAC9B,cAAc,uBAAuB,CAAC;AACtC,cAAc,oBAAoB,CAAC;AACnC,cAAc,uBAAuB,CAAC;AACtC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,kBAAkB,CAAC;AACjC,cAAc,eAAe,CAAC"}
|
package/build/invert.d.ts
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Invert an object so that the values look up the keys.
|
|
3
|
-
* If the object has an array as the value, each item in the array will be inverted.
|
|
4
|
-
* @param obj - The object to invert
|
|
5
|
-
* @param throwOnDuplicate - When true, throw error if duplicate key detected
|
|
6
|
-
* @returns The inverted object
|
|
7
|
-
*/
|
|
8
|
-
export declare function invert<TKey extends string, TValue extends string | string[]>(obj: {
|
|
9
|
-
[key in TKey]?: TValue;
|
|
10
|
-
}, throwOnDuplicate?: boolean): {
|
|
11
|
-
[key in TValue extends (infer TK)[] ? TK : TValue]: TValue extends any[] ? TKey[] : TKey;
|
|
12
|
-
};
|
|
13
|
-
/**
|
|
14
|
-
* Safely invert an object to be { [key in TValue]: TKey[] }
|
|
15
|
-
* @param obj - The object to invert
|
|
16
|
-
* @returns The inverted object
|
|
17
|
-
*/
|
|
18
|
-
export declare function invertSafe<TKey extends string, TValue extends string>(obj: {
|
|
19
|
-
[key in TKey]: TValue | TValue[];
|
|
20
|
-
}): {
|
|
21
|
-
[key in TValue]: TKey[];
|
|
22
|
-
};
|
|
23
|
-
//# sourceMappingURL=invert.d.ts.map
|
package/build/invert.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"invert.d.ts","sourceRoot":"","sources":["../src/invert.ts"],"names":[],"mappings":"AAGA;;;;;;GAMG;AACH,wBAAgB,MAAM,CAAC,IAAI,SAAS,MAAM,EAAE,MAAM,SAAS,MAAM,GAAG,MAAM,EAAE,EAC1E,GAAG,EAAE;KAAG,GAAG,IAAI,IAAI,CAAC,CAAC,EAAE,MAAM;CAAE,EAC/B,gBAAgB,UAAO,GACtB;KAEA,GAAG,IAAI,MAAM,SAAS,CAAC,MAAM,EAAE,CAAC,EAAE,GAAG,EAAE,GAAG,MAAM,GAAG,MAAM,SAAS,GAAG,EAAE,GACpE,IAAI,EAAE,GACN,IAAI;CACT,CAiCA;AAED;;;;GAIG;AACH,wBAAgB,UAAU,CAAC,IAAI,SAAS,MAAM,EAAE,MAAM,SAAS,MAAM,EAAE,GAAG,EAAE;KACzE,GAAG,IAAI,IAAI,GAAG,MAAM,GAAG,MAAM,EAAE;CACjC,GAAG;KACD,GAAG,IAAI,MAAM,GAAG,IAAI,EAAE;CACxB,CA8BA"}
|
package/build/invert.js
DELETED
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
// local
|
|
2
|
-
import { getEntries } from './getEntries.js';
|
|
3
|
-
/**
|
|
4
|
-
* Invert an object so that the values look up the keys.
|
|
5
|
-
* If the object has an array as the value, each item in the array will be inverted.
|
|
6
|
-
* @param obj - The object to invert
|
|
7
|
-
* @param throwOnDuplicate - When true, throw error if duplicate key detected
|
|
8
|
-
* @returns The inverted object
|
|
9
|
-
*/
|
|
10
|
-
export function invert(obj, throwOnDuplicate = true) {
|
|
11
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
12
|
-
const result = {};
|
|
13
|
-
// Invert
|
|
14
|
-
getEntries(obj).forEach(([key, instance]) => {
|
|
15
|
-
// Ensure no undefined values
|
|
16
|
-
if (instance === undefined) {
|
|
17
|
-
throw new Error('inverse found undefined value, this is not supported');
|
|
18
|
-
}
|
|
19
|
-
// Handle array case
|
|
20
|
-
if (Array.isArray(instance)) {
|
|
21
|
-
instance.forEach((listKey) => {
|
|
22
|
-
// Create a new entry
|
|
23
|
-
if (!result[listKey]) {
|
|
24
|
-
result[listKey] = [key];
|
|
25
|
-
}
|
|
26
|
-
else {
|
|
27
|
-
// Add to existing
|
|
28
|
-
result[listKey].push(key);
|
|
29
|
-
}
|
|
30
|
-
});
|
|
31
|
-
}
|
|
32
|
-
else {
|
|
33
|
-
// Ensure we do not overwrite duplicates
|
|
34
|
-
if (result[instance] && throwOnDuplicate) {
|
|
35
|
-
throw new Error(`Encountered duplicate value inverting object: "${instance}: ${key} and ${result[instance]}"`);
|
|
36
|
-
}
|
|
37
|
-
result[instance] = key;
|
|
38
|
-
}
|
|
39
|
-
});
|
|
40
|
-
return result;
|
|
41
|
-
}
|
|
42
|
-
/**
|
|
43
|
-
* Safely invert an object to be { [key in TValue]: TKey[] }
|
|
44
|
-
* @param obj - The object to invert
|
|
45
|
-
* @returns The inverted object
|
|
46
|
-
*/
|
|
47
|
-
export function invertSafe(obj) {
|
|
48
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
49
|
-
const result = {};
|
|
50
|
-
// Invert
|
|
51
|
-
getEntries(obj).forEach(([key, instance]) => {
|
|
52
|
-
// Ensure no undefined values
|
|
53
|
-
if (instance === undefined) {
|
|
54
|
-
throw new Error('inverse found undefined value, this is not supported');
|
|
55
|
-
}
|
|
56
|
-
// Handle array case
|
|
57
|
-
if (Array.isArray(instance)) {
|
|
58
|
-
instance.forEach((listKey) => {
|
|
59
|
-
// Create a new entry
|
|
60
|
-
if (!result[listKey]) {
|
|
61
|
-
result[listKey] = [key];
|
|
62
|
-
}
|
|
63
|
-
else {
|
|
64
|
-
// Add to existing
|
|
65
|
-
result[listKey].push(key);
|
|
66
|
-
}
|
|
67
|
-
});
|
|
68
|
-
}
|
|
69
|
-
else if (!result[instance]) {
|
|
70
|
-
result[instance] = [key];
|
|
71
|
-
}
|
|
72
|
-
else {
|
|
73
|
-
// Add to existing
|
|
74
|
-
result[instance].push(key);
|
|
75
|
-
}
|
|
76
|
-
});
|
|
77
|
-
return result;
|
|
78
|
-
}
|
|
79
|
-
//# sourceMappingURL=invert.js.map
|
package/build/invert.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"invert.js","sourceRoot":"","sources":["../src/invert.ts"],"names":[],"mappings":"AAAA,QAAQ;AACR,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAE7C;;;;;;GAMG;AACH,MAAM,UAAU,MAAM,CACpB,GAA+B,EAC/B,gBAAgB,GAAG,IAAI;IAOvB,8DAA8D;IAC9D,MAAM,MAAM,GAAQ,EAAS,CAAC;IAE9B,SAAS;IACT,UAAU,CAAC,GAAG,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,EAAE,QAAQ,CAA6B,EAAE,EAAE;QACtE,6BAA6B;QAC7B,IAAI,QAAQ,KAAK,SAAS,EAAE,CAAC;YAC3B,MAAM,IAAI,KAAK,CAAC,sDAAsD,CAAC,CAAC;QAC1E,CAAC;QAED,oBAAoB;QACpB,IAAI,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE,CAAC;YAC5B,QAAQ,CAAC,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE;gBAC3B,qBAAqB;gBACrB,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,EAAE,CAAC;oBACrB,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;gBAC1B,CAAC;qBAAM,CAAC;oBACN,kBAAkB;oBAClB,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;gBAC5B,CAAC;YACH,CAAC,CAAC,CAAC;QACL,CAAC;aAAM,CAAC;YACN,wCAAwC;YACxC,IAAI,MAAM,CAAC,QAAQ,CAAC,IAAI,gBAAgB,EAAE,CAAC;gBACzC,MAAM,IAAI,KAAK,CACb,kDAAkD,QAAQ,KAAK,GAAG,QAAQ,MAAM,CAAC,QAAQ,CAAC,GAAG,CAC9F,CAAC;YACJ,CAAC;YACD,MAAM,CAAC,QAAQ,CAAC,GAAG,GAAG,CAAC;QACzB,CAAC;IACH,CAAC,CAAC,CAAC;IACH,OAAO,MAAM,CAAC;AAChB,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,UAAU,CAA6C,GAEtE;IAGC,8DAA8D;IAC9D,MAAM,MAAM,GAAQ,EAAE,CAAC;IAEvB,SAAS;IACT,UAAU,CAAC,GAAG,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,EAAE,QAAQ,CAAC,EAAE,EAAE;QAC1C,6BAA6B;QAC7B,IAAI,QAAQ,KAAK,SAAS,EAAE,CAAC;YAC3B,MAAM,IAAI,KAAK,CAAC,sDAAsD,CAAC,CAAC;QAC1E,CAAC;QAED,oBAAoB;QACpB,IAAI,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE,CAAC;YAC5B,QAAQ,CAAC,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE;gBAC3B,qBAAqB;gBACrB,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,EAAE,CAAC;oBACrB,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;gBAC1B,CAAC;qBAAM,CAAC;oBACN,kBAAkB;oBAClB,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;gBAC5B,CAAC;YACH,CAAC,CAAC,CAAC;QACL,CAAC;aAAM,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAE,CAAC;YAC7B,MAAM,CAAC,QAAQ,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;QAC3B,CAAC;aAAM,CAAC;YACN,kBAAkB;YAClB,MAAM,CAAC,QAAQ,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QAC7B,CAAC;IACH,CAAC,CAAC,CAAC;IACH,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
package/build/noExcess.d.ts
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import * as t from 'io-ts';
|
|
2
|
-
/**
|
|
3
|
-
* Creates an enhanced codec that validates objects with strict property checking.
|
|
4
|
-
*
|
|
5
|
-
* The enhanced codec performs validation in three steps:
|
|
6
|
-
* 1. Validates structure using the original codec
|
|
7
|
-
* 2. Checks for excess properties using stripKeys
|
|
8
|
-
* 3. Returns validation errors for any unexpected keys with the message "excess key "{key}" found"
|
|
9
|
-
*
|
|
10
|
-
* @template C - The codec type that extends HasProps
|
|
11
|
-
* @param codec - The base codec to enhance with excess property checking
|
|
12
|
-
* @param name - Optional custom name for the enhanced type (auto-generated if not provided)
|
|
13
|
-
* @returns A new NoExcessType that wraps the original codec with strict validation
|
|
14
|
-
*/
|
|
15
|
-
export declare const noExcess: <C extends t.HasProps>(codec: C, name?: string) => NoExcessType<C, C["_A"], C["_A"], unknown>;
|
|
16
|
-
/**
|
|
17
|
-
* The NoExcess Type - a wrapper type to be used with io-ts to ensure there aren't any excess keys
|
|
18
|
-
*/
|
|
19
|
-
export declare class NoExcessType<C extends t.Any, A = C['_A'], O = A, I = unknown> extends t.Type<A, O, I> {
|
|
20
|
-
readonly type: C;
|
|
21
|
-
readonly _tag: "NoExcessType";
|
|
22
|
-
/**
|
|
23
|
-
* Creates a new NoExcessType instance that wraps another codec with excess property validation.
|
|
24
|
-
*
|
|
25
|
-
* @param name - The name of this type for debugging and error messages
|
|
26
|
-
* @param is - Type guard function that checks if a value is of this type
|
|
27
|
-
* @param validate - Validation function that decodes input and validates structure
|
|
28
|
-
* @param encode - Encoding function that converts the type back to its output representation
|
|
29
|
-
* @param type - The original wrapped codec that this NoExcessType enhances
|
|
30
|
-
*/
|
|
31
|
-
constructor(name: string, is: NoExcessType<C, A, O, I>['is'], validate: NoExcessType<C, A, O, I>['validate'], encode: NoExcessType<C, A, O, I>['encode'], type: C);
|
|
32
|
-
}
|
|
33
|
-
//# sourceMappingURL=noExcess.d.ts.map
|
package/build/noExcess.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"noExcess.d.ts","sourceRoot":"","sources":["../src/noExcess.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,CAAC,MAAM,OAAO,CAAC;AA6H3B;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,QAAQ,0CAEb,MAAM,+CAsBb,CAAC;AAEF;;GAEG;AACH,qBAAa,YAAY,CACvB,CAAC,SAAS,CAAC,CAAC,GAAG,EACf,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,EACX,CAAC,GAAG,CAAC,EACL,CAAC,GAAG,OAAO,CACX,SAAQ,CAAC,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;aAiBL,IAAI,EAAE,CAAC;IAhBzB,SAAgB,IAAI,iBAA2B;IAE/C;;;;;;;;OAQG;gBAED,IAAI,EAAE,MAAM,EACZ,EAAE,EAAE,YAAY,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,EAClC,QAAQ,EAAE,YAAY,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,UAAU,CAAC,EAC9C,MAAM,EAAE,YAAY,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC,EAC1B,IAAI,EAAE,CAAC;CAI1B"}
|