zcb 0.2.2 → 0.2.4
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/README.md +4 -2
- package/dist/cjs/index.cjs +2 -1
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/esm/index.mjs +2 -1
- package/dist/esm/index.mjs.map +1 -1
- package/dist/types/cjs/createConfigBuilder.d.cts +3 -0
- package/dist/types/cjs/createConfigBuilder.d.cts.map +1 -1
- package/dist/types/cjs/transformers/cloneNonEnumerableValues.d.cts.map +1 -1
- package/dist/types/esm/createConfigBuilder.d.ts +3 -0
- package/dist/types/esm/createConfigBuilder.d.ts.map +1 -1
- package/dist/types/esm/transformers/cloneNonEnumerableValues.d.ts.map +1 -1
- package/dist/types/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/createConfigBuilder.ts +6 -1
- package/src/transformers/cloneNonEnumerableValues.ts +6 -3
package/package.json
CHANGED
|
@@ -32,6 +32,9 @@ export type ConfigBuilder<ZodTypes> = {
|
|
|
32
32
|
};
|
|
33
33
|
|
|
34
34
|
export type CreateConfigBuilderOptions = {
|
|
35
|
+
overrides?: {
|
|
36
|
+
uuid?: () => string;
|
|
37
|
+
};
|
|
35
38
|
type?: string;
|
|
36
39
|
};
|
|
37
40
|
|
|
@@ -62,6 +65,8 @@ export const createConfigBuilder = <ZodTypes>(
|
|
|
62
65
|
throw new Error(`The root type of a config schema must be "object", but received "${String(jsonSchema.type)}"`);
|
|
63
66
|
}
|
|
64
67
|
|
|
68
|
+
const uuid = options.overrides?.uuid ?? uuidV4;
|
|
69
|
+
|
|
65
70
|
const addNonEnumeralBaseProperties = (conf: Config) => {
|
|
66
71
|
Object.defineProperty(conf, NonEmumeralProperties.ZCB, {
|
|
67
72
|
configurable: false,
|
|
@@ -72,7 +77,7 @@ export const createConfigBuilder = <ZodTypes>(
|
|
|
72
77
|
Object.defineProperty(conf, NonEmumeralProperties.ID, {
|
|
73
78
|
configurable: false,
|
|
74
79
|
enumerable: false,
|
|
75
|
-
value:
|
|
80
|
+
value: uuid(),
|
|
76
81
|
});
|
|
77
82
|
|
|
78
83
|
if (options.type) {
|
|
@@ -3,9 +3,12 @@ import { type AnyRecord, NonEmumeralProperties, type TransformConfigHandlerSync
|
|
|
3
3
|
const NON_ENUMERABLE_KEYS = new Set(Object.values(NonEmumeralProperties));
|
|
4
4
|
|
|
5
5
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
6
|
-
export const cloneNonEnumerableValues: TransformConfigHandlerSync = <
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
export const cloneNonEnumerableValues: TransformConfigHandlerSync = <
|
|
7
|
+
Config1 extends AnyRecord,
|
|
8
|
+
Config2 extends AnyRecord
|
|
9
|
+
>(
|
|
10
|
+
clone: Config1,
|
|
11
|
+
config: Config2
|
|
9
12
|
) => {
|
|
10
13
|
for (const nonEnumerableKey of NON_ENUMERABLE_KEYS) {
|
|
11
14
|
if (nonEnumerableKey in config) {
|