zcb 0.3.5 → 0.3.7
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/cjs/cli.cjs.map +1 -1
- package/dist/cjs/index.cjs +1 -1
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/esm/cli.mjs.map +1 -1
- package/dist/esm/index.mjs +1 -1
- package/dist/esm/index.mjs.map +1 -1
- package/dist/production.analysis.txt +15 -15
- package/dist/types/cjs/createConfigBuilder.d.cts +1 -1
- package/dist/types/cjs/createConfigBuilder.d.cts.map +1 -1
- package/dist/types/cjs/utils/hasArrayInvalidDefaults.d.cts +3 -0
- package/dist/types/cjs/utils/hasArrayInvalidDefaults.d.cts.map +1 -0
- package/dist/types/cjs/utils/hasObjectPropertyDefaults.d.cts +3 -0
- package/dist/types/cjs/utils/hasObjectPropertyDefaults.d.cts.map +1 -0
- package/dist/types/cjs/utils/hasRecordInvalidDefaults.d.cts +3 -0
- package/dist/types/cjs/utils/hasRecordInvalidDefaults.d.cts.map +1 -0
- package/dist/types/cjs/utils/isInvalidPropertyOverride.d.cts +1 -1
- package/dist/types/cjs/utils/isInvalidPropertyOverride.d.cts.map +1 -1
- package/dist/types/cjs/utils/isValidValue.d.cts.map +1 -1
- package/dist/types/cjs/utils/transformConfig.d.cts.map +1 -1
- package/dist/types/esm/createConfigBuilder.d.ts +1 -1
- package/dist/types/esm/createConfigBuilder.d.ts.map +1 -1
- package/dist/types/esm/utils/hasArrayInvalidDefaults.d.ts +3 -0
- package/dist/types/esm/utils/hasArrayInvalidDefaults.d.ts.map +1 -0
- package/dist/types/esm/utils/hasObjectPropertyDefaults.d.ts +3 -0
- package/dist/types/esm/utils/hasObjectPropertyDefaults.d.ts.map +1 -0
- package/dist/types/esm/utils/hasRecordInvalidDefaults.d.ts +3 -0
- package/dist/types/esm/utils/hasRecordInvalidDefaults.d.ts.map +1 -0
- package/dist/types/esm/utils/isInvalidPropertyOverride.d.ts +1 -1
- package/dist/types/esm/utils/isInvalidPropertyOverride.d.ts.map +1 -1
- package/dist/types/esm/utils/isValidValue.d.ts.map +1 -1
- package/dist/types/esm/utils/transformConfig.d.ts.map +1 -1
- package/dist/types/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +18 -16
- package/pnpm-workspace.yaml +23 -0
- package/src/__testUtils__/configBuilder.ts +1 -1
- package/src/createConfigBuilder.test.ts +4 -4
- package/src/createConfigBuilder.ts +16 -20
- package/src/createConfigReader.test.ts +2 -2
- package/src/utils/collateDefaultValues.ts +10 -10
- package/src/utils/collateObjectPropertyDefaults.ts +2 -2
- package/src/utils/{arrayHasInvalidDefaults.ts → hasArrayInvalidDefaults.ts} +1 -1
- package/src/utils/{objectPropertyHasDefaults.ts → hasObjectPropertyDefaults.ts} +1 -1
- package/src/utils/{recordHasInvalidDefaults.ts → hasRecordInvalidDefaults.ts} +1 -1
- package/src/utils/isInvalidPropertyOverride.ts +2 -2
- package/src/utils/isValidValue.ts +1 -5
- package/src/utils/transformConfig.ts +5 -11
- package/dist/types/cjs/utils/arrayHasInvalidDefaults.d.cts +0 -3
- package/dist/types/cjs/utils/arrayHasInvalidDefaults.d.cts.map +0 -1
- package/dist/types/cjs/utils/objectPropertyHasDefaults.d.cts +0 -3
- package/dist/types/cjs/utils/objectPropertyHasDefaults.d.cts.map +0 -1
- package/dist/types/cjs/utils/recordHasInvalidDefaults.d.cts +0 -3
- package/dist/types/cjs/utils/recordHasInvalidDefaults.d.cts.map +0 -1
- package/dist/types/esm/utils/arrayHasInvalidDefaults.d.ts +0 -3
- package/dist/types/esm/utils/arrayHasInvalidDefaults.d.ts.map +0 -1
- package/dist/types/esm/utils/objectPropertyHasDefaults.d.ts +0 -3
- package/dist/types/esm/utils/objectPropertyHasDefaults.d.ts.map +0 -1
- package/dist/types/esm/utils/recordHasInvalidDefaults.d.ts +0 -3
- package/dist/types/esm/utils/recordHasInvalidDefaults.d.ts.map +0 -1
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "zcb",
|
|
3
3
|
"description": "Build configs with type safety from zod schema.",
|
|
4
|
-
"version": "0.3.
|
|
4
|
+
"version": "0.3.7",
|
|
5
5
|
"author": "miami-man",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"homepage": "https://github.com/badbatch/zod-config-builder",
|
|
@@ -22,6 +22,7 @@
|
|
|
22
22
|
},
|
|
23
23
|
"exports": {
|
|
24
24
|
".": {
|
|
25
|
+
"source": "./src/index.ts",
|
|
25
26
|
"types": {
|
|
26
27
|
"import": "./dist/types/esm/index.d.ts",
|
|
27
28
|
"require": "./dist/types/cjs/index.d.cts"
|
|
@@ -30,6 +31,7 @@
|
|
|
30
31
|
"require": "./dist/cjs/index.cjs"
|
|
31
32
|
},
|
|
32
33
|
"./cli": {
|
|
34
|
+
"source": "./src/cli.ts",
|
|
33
35
|
"types": {
|
|
34
36
|
"import": "./dist/types/esm/cli.d.ts",
|
|
35
37
|
"require": "./dist/types/cjs/cli.d.cts"
|
|
@@ -49,7 +51,7 @@
|
|
|
49
51
|
"@types/uuid": "^11.0.0",
|
|
50
52
|
"@types/yargs": "^17.0.35",
|
|
51
53
|
"core-js": "^3.49.0",
|
|
52
|
-
"fs-extra": "^11.
|
|
54
|
+
"fs-extra": "^11.4.0",
|
|
53
55
|
"handlebars": "^4.7.9",
|
|
54
56
|
"json-schema": "^0.4.0",
|
|
55
57
|
"lodash-es": "^4.18.1",
|
|
@@ -58,39 +60,39 @@
|
|
|
58
60
|
"ts-toolbelt": "^9.6.0",
|
|
59
61
|
"type-fest": "^5.8.0",
|
|
60
62
|
"uuid": "^14.0.1",
|
|
61
|
-
"yargs": "^18.
|
|
63
|
+
"yargs": "^18.1.0",
|
|
62
64
|
"zod": "^4.4.3",
|
|
63
65
|
"zod-to-json-schema": "^3.25.2"
|
|
64
66
|
},
|
|
65
67
|
"devDependencies": {
|
|
66
68
|
"@commitlint/cli": "^21.2.1",
|
|
67
69
|
"@jest/globals": "^30.4.1",
|
|
68
|
-
"@repodog/cli": "^1.
|
|
69
|
-
"@repodog/commitlint-config": "^21.0.
|
|
70
|
-
"@repodog/eslint-config": "^9.0.
|
|
71
|
-
"@repodog/eslint-config-jest": "^9.0.
|
|
70
|
+
"@repodog/cli": "^1.7.0",
|
|
71
|
+
"@repodog/commitlint-config": "^21.0.3",
|
|
72
|
+
"@repodog/eslint-config": "^9.0.30",
|
|
73
|
+
"@repodog/eslint-config-jest": "^9.0.10",
|
|
72
74
|
"@repodog/jest-config": "^30.0.4",
|
|
73
75
|
"@repodog/markdownlint-config": "^1.2.7",
|
|
74
76
|
"@repodog/prettier-config": "^3.0.5",
|
|
75
|
-
"@repodog/rollup-config": "^4.0.
|
|
76
|
-
"@repodog/swc-config": "^1.0.
|
|
77
|
-
"@repodog/syncpack-config": "^15.0.
|
|
77
|
+
"@repodog/rollup-config": "^4.0.18",
|
|
78
|
+
"@repodog/swc-config": "^1.0.16",
|
|
79
|
+
"@repodog/syncpack-config": "^15.0.4",
|
|
78
80
|
"@repodog/ts-config": "^6.0.3",
|
|
79
81
|
"@rollup/plugin-swc": "^0.4.1",
|
|
80
|
-
"@swc/core": "^1.15.
|
|
82
|
+
"@swc/core": "^1.15.47",
|
|
81
83
|
"@swc/jest": "^0.2.39",
|
|
82
84
|
"@types/jest": "^30.0.0",
|
|
83
|
-
"@types/node": "^
|
|
85
|
+
"@types/node": "^26.1.2",
|
|
84
86
|
"cts-types": "^0.0.11",
|
|
85
87
|
"del-cli": "^7.0.0",
|
|
86
|
-
"eslint": "^
|
|
88
|
+
"eslint": "^10.8.0",
|
|
87
89
|
"generate-changelog": "^1.8.0",
|
|
88
90
|
"husky": "^9.1.7",
|
|
89
91
|
"jest": "^30.4.2",
|
|
90
92
|
"jest-environment-node": "^30.4.1",
|
|
91
|
-
"markdownlint-cli2": "^0.23.
|
|
92
|
-
"prettier": "^3.9.
|
|
93
|
-
"rollup": "^4.62.
|
|
93
|
+
"markdownlint-cli2": "^0.23.2",
|
|
94
|
+
"prettier": "^3.9.6",
|
|
95
|
+
"rollup": "^4.62.3",
|
|
94
96
|
"suppress-experimental-warnings": "^2.0.0",
|
|
95
97
|
"syncpack": "^15.3.2",
|
|
96
98
|
"typescript": "^6.0.3"
|
package/pnpm-workspace.yaml
CHANGED
|
@@ -2,3 +2,26 @@ allowBuilds:
|
|
|
2
2
|
'@swc/core': false
|
|
3
3
|
core-js: false
|
|
4
4
|
unrs-resolver: false
|
|
5
|
+
|
|
6
|
+
minimumReleaseAgeExclude:
|
|
7
|
+
- '@repodog/cli-cut@1.4.30'
|
|
8
|
+
- '@repodog/cli-new@1.6.0'
|
|
9
|
+
- '@repodog/cli-postinstall@0.4.26'
|
|
10
|
+
- '@repodog/cli-publish@1.4.30'
|
|
11
|
+
- '@repodog/cli-setup@1.4.27'
|
|
12
|
+
- '@repodog/cli-utils@1.4.25'
|
|
13
|
+
- '@repodog/cli@1.7.0'
|
|
14
|
+
- '@repodog/commitlint-config@21.0.3'
|
|
15
|
+
- '@repodog/eslint-config-jest@9.0.10'
|
|
16
|
+
- '@repodog/eslint-config@9.0.30'
|
|
17
|
+
- '@repodog/rollup-config@4.0.18'
|
|
18
|
+
- '@repodog/swc-config@1.0.16'
|
|
19
|
+
- '@repodog/syncpack-config@15.0.4'
|
|
20
|
+
|
|
21
|
+
overrides:
|
|
22
|
+
'body-parser@<1.20.6': '>=1.20.6'
|
|
23
|
+
'fast-uri@>=3.0.0 <=3.1.3': '>=3.1.4'
|
|
24
|
+
'js-yaml@^4.0.0': '^4.3.0'
|
|
25
|
+
'js-yaml@>=5.0.0 <=5.2.1': '>=5.2.2'
|
|
26
|
+
'markdown-it@<=14.1.1': '>=14.2.0'
|
|
27
|
+
'postcss@<=8.5.17': '>=8.5.18'
|
|
@@ -52,7 +52,7 @@ configBuilder
|
|
|
52
52
|
.enabled(true)
|
|
53
53
|
.languageCodes(['en'])
|
|
54
54
|
.locales(({ countryCode, languageCodes }) =>
|
|
55
|
-
languageCodes?.length
|
|
55
|
+
countryCode && languageCodes?.length ? languageCodes.map(code => `${code}_${countryCode}`) : [],
|
|
56
56
|
)
|
|
57
57
|
.pages({
|
|
58
58
|
contactDetails: contactDetailsPage,
|
|
@@ -589,7 +589,7 @@ describe('createConfigBuilder', () => {
|
|
|
589
589
|
.languageCodes(['en'])
|
|
590
590
|
.locales(({ countryCode, languageCodes }) =>
|
|
591
591
|
// eslint-disable-next-line jest/no-conditional-in-test
|
|
592
|
-
languageCodes?.length
|
|
592
|
+
countryCode && languageCodes?.length ? languageCodes.map(code => `${code}_${countryCode}` as const) : [],
|
|
593
593
|
);
|
|
594
594
|
|
|
595
595
|
expect(config.$values()).toEqual({
|
|
@@ -608,7 +608,7 @@ describe('createConfigBuilder', () => {
|
|
|
608
608
|
.languageCodes(['en'])
|
|
609
609
|
.locales(({ countryCode, languageCodes }) =>
|
|
610
610
|
// eslint-disable-next-line jest/no-conditional-in-test
|
|
611
|
-
languageCodes?.length
|
|
611
|
+
countryCode && languageCodes?.length ? languageCodes.map(code => `${code}_${countryCode}` as const) : [],
|
|
612
612
|
)
|
|
613
613
|
.languageCodes(['fr'], true);
|
|
614
614
|
|
|
@@ -628,7 +628,7 @@ describe('createConfigBuilder', () => {
|
|
|
628
628
|
.languageCodes(['en'])
|
|
629
629
|
.locales(({ countryCode, languageCodes }) =>
|
|
630
630
|
// eslint-disable-next-line jest/no-conditional-in-test
|
|
631
|
-
languageCodes?.length
|
|
631
|
+
countryCode && languageCodes?.length ? languageCodes.map(code => `${code}_${countryCode}`) : [],
|
|
632
632
|
);
|
|
633
633
|
|
|
634
634
|
expect(config.$validate()).toBe(true);
|
|
@@ -646,7 +646,7 @@ describe('createConfigBuilder', () => {
|
|
|
646
646
|
.languageCodes(['en'])
|
|
647
647
|
.locales(({ countryCode, languageCodes }) =>
|
|
648
648
|
// eslint-disable-next-line jest/no-conditional-in-test
|
|
649
|
-
languageCodes?.length
|
|
649
|
+
countryCode && languageCodes?.length ? languageCodes.map(code => `${code}_${countryCode}`) : [],
|
|
650
650
|
);
|
|
651
651
|
|
|
652
652
|
expect(config.$toJson()).toMatchInlineSnapshot(`
|
|
@@ -13,7 +13,7 @@ import { transformConfigSync } from './utils/transformConfig.ts';
|
|
|
13
13
|
export type ConfigBuilder<ZodTypes> = {
|
|
14
14
|
[Key in keyof Required<ZodTypes>]: (
|
|
15
15
|
value: ZodTypes[Key] | ((c: ZodTypes) => ZodTypes[Key]),
|
|
16
|
-
|
|
16
|
+
isOverride?: boolean,
|
|
17
17
|
) => ConfigBuilder<ZodTypes>;
|
|
18
18
|
} & {
|
|
19
19
|
$disable: () => ConfigBuilder<ZodTypes>;
|
|
@@ -75,15 +75,13 @@ export const createConfigBuilder = <ZodTypes>(
|
|
|
75
75
|
enumerable: false,
|
|
76
76
|
value: true,
|
|
77
77
|
},
|
|
78
|
-
...(options.type
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
}
|
|
86
|
-
: undefined),
|
|
78
|
+
...(options.type && {
|
|
79
|
+
__type: {
|
|
80
|
+
configurable: false,
|
|
81
|
+
enumerable: false,
|
|
82
|
+
value: options.type,
|
|
83
|
+
},
|
|
84
|
+
}),
|
|
87
85
|
});
|
|
88
86
|
};
|
|
89
87
|
|
|
@@ -155,11 +153,9 @@ export const createConfigBuilder = <ZodTypes>(
|
|
|
155
153
|
for (const propertyName in callbacks) {
|
|
156
154
|
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions
|
|
157
155
|
const castPropertyName = propertyName as keyof Config;
|
|
158
|
-
// eslint-disable-next-line unicorn/no-unsafe-property-key
|
|
159
156
|
const callback = callbacks[castPropertyName];
|
|
160
157
|
|
|
161
158
|
if (callback) {
|
|
162
|
-
// eslint-disable-next-line unicorn/no-unsafe-property-key
|
|
163
159
|
config[castPropertyName] = callback(config);
|
|
164
160
|
}
|
|
165
161
|
}
|
|
@@ -194,12 +190,12 @@ export const createConfigBuilder = <ZodTypes>(
|
|
|
194
190
|
|
|
195
191
|
// Aimed at making it easier for TypeScript to derive type.
|
|
196
192
|
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions
|
|
197
|
-
configBuilder[castPropertyName] = ((value: Config[keyof Config] | DerivedValueCallback,
|
|
198
|
-
if (isInvalidPropertyOverride(config[castPropertyName],
|
|
193
|
+
configBuilder[castPropertyName] = ((value: Config[keyof Config] | DerivedValueCallback, toOverride?: boolean) => {
|
|
194
|
+
if (isInvalidPropertyOverride(config[castPropertyName], toOverride)) {
|
|
199
195
|
throw new Error(
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
)}". You may be trying to add a new values before flushing the old one. If you intended to override the existing value, pass in true as the second argument.`,
|
|
196
|
+
// ESLint unable to derive value can also be symbol or number
|
|
197
|
+
// eslint-disable-next-line unicorn/no-useless-coercion
|
|
198
|
+
`A value already exists for "${String(castPropertyName)}". You may be trying to add a new values before flushing the old one. If you intended to override the existing value, pass in true as the second argument.`,
|
|
203
199
|
);
|
|
204
200
|
}
|
|
205
201
|
|
|
@@ -207,9 +203,9 @@ export const createConfigBuilder = <ZodTypes>(
|
|
|
207
203
|
|
|
208
204
|
if (!isValidValue(value)) {
|
|
209
205
|
throw new Error(
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
)}" value has a depth greater than ${String(MAX_DEPTH)}. To pass in objects with a depth greater than ${String(MAX_DEPTH)}, create a builder for that config slice.`,
|
|
206
|
+
// ESLint unable to derive value can also be symbol or number
|
|
207
|
+
// eslint-disable-next-line unicorn/no-useless-coercion
|
|
208
|
+
`"${String(castPropertyName)}" value has a depth greater than ${String(MAX_DEPTH)}. To pass in objects with a depth greater than ${String(MAX_DEPTH)}, create a builder for that config slice.`,
|
|
213
209
|
);
|
|
214
210
|
}
|
|
215
211
|
|
|
@@ -20,8 +20,8 @@ describe('createConfigReader', () => {
|
|
|
20
20
|
describe('when that value is a boolean', () => {
|
|
21
21
|
it('should return the correct value', () => {
|
|
22
22
|
const reader = createReader();
|
|
23
|
-
const
|
|
24
|
-
expect(
|
|
23
|
+
const isEnabled = reader.read('enabled');
|
|
24
|
+
expect(isEnabled).toBe(true);
|
|
25
25
|
});
|
|
26
26
|
});
|
|
27
27
|
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { type JSONSchema } from 'zod/v4/core';
|
|
2
|
-
import { arrayHasInvalidDefaults } from './arrayHasInvalidDefaults.ts';
|
|
3
2
|
import { collateObjectPropertyDefaults } from './collateObjectPropertyDefaults.ts';
|
|
3
|
+
import { hasArrayInvalidDefaults } from './hasArrayInvalidDefaults.ts';
|
|
4
|
+
import { hasRecordInvalidDefaults } from './hasRecordInvalidDefaults.ts';
|
|
4
5
|
import { RESERVED_KEYWORDS, isPropertyReservedWord } from './isPropertyReservedWord.ts';
|
|
5
6
|
import { isValidPropertyDefinition } from './isValidPropertyDefinition.ts';
|
|
6
|
-
import { recordHasInvalidDefaults } from './recordHasInvalidDefaults.ts';
|
|
7
7
|
|
|
8
8
|
export const collateDefaultValues = <Config>(jsonSchema: JSONSchema.JSONSchema): Partial<Config> => {
|
|
9
9
|
const defaultValues: Partial<Config> = {};
|
|
@@ -29,20 +29,20 @@ export const collateDefaultValues = <Config>(jsonSchema: JSONSchema.JSONSchema):
|
|
|
29
29
|
defaultValues[castPropertyName] = propertyDefinition.default as Config[keyof Config];
|
|
30
30
|
}
|
|
31
31
|
|
|
32
|
-
if (propertyDefinition.type === 'array' &&
|
|
32
|
+
if (propertyDefinition.type === 'array' && hasArrayInvalidDefaults(propertyDefinition)) {
|
|
33
33
|
throw new Error(
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
)}", set them on the array and not the item.`,
|
|
34
|
+
// ESLint unable to derive value can also be symbol or number
|
|
35
|
+
// eslint-disable-next-line unicorn/no-useless-coercion
|
|
36
|
+
`When setting schema array defaults for the array assigned to "${String(castPropertyName)}", set them on the array and not the item.`,
|
|
37
37
|
);
|
|
38
38
|
}
|
|
39
39
|
|
|
40
40
|
if (propertyDefinition.type === 'object') {
|
|
41
|
-
if (
|
|
41
|
+
if (hasRecordInvalidDefaults(propertyDefinition)) {
|
|
42
42
|
throw new Error(
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
)}", set them on the record and not the value.`,
|
|
43
|
+
// ESLint unable to derive value can also be symbol or number
|
|
44
|
+
// eslint-disable-next-line unicorn/no-useless-coercion
|
|
45
|
+
`When setting schema property defaults for the value of the record assigned to "${String(castPropertyName)}", set them on the record and not the value.`,
|
|
46
46
|
);
|
|
47
47
|
}
|
|
48
48
|
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { isBoolean, isUndefined } from 'lodash-es';
|
|
2
2
|
import { type Jsonifiable } from 'type-fest';
|
|
3
3
|
import { type JSONSchema } from 'zod/v4/core';
|
|
4
|
-
import {
|
|
4
|
+
import { hasObjectPropertyDefaults } from './hasObjectPropertyDefaults.ts';
|
|
5
5
|
|
|
6
6
|
export const collateObjectPropertyDefaults = (
|
|
7
7
|
propertyDefinition: JSONSchema.JSONSchema,
|
|
8
8
|
): Record<string, Jsonifiable> | undefined => {
|
|
9
9
|
const { properties } = propertyDefinition;
|
|
10
10
|
|
|
11
|
-
if (!properties || !
|
|
11
|
+
if (!properties || !hasObjectPropertyDefaults(propertyDefinition)) {
|
|
12
12
|
return;
|
|
13
13
|
}
|
|
14
14
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type JSONSchema } from 'zod/v4/core';
|
|
2
2
|
|
|
3
|
-
export const
|
|
3
|
+
export const hasArrayInvalidDefaults = (propertyDefinition: JSONSchema.JSONSchema): boolean => {
|
|
4
4
|
const { items } = propertyDefinition;
|
|
5
5
|
return !!items && typeof items === 'object' && 'default' in items;
|
|
6
6
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type JSONSchema } from 'zod/v4/core';
|
|
2
2
|
|
|
3
|
-
export const
|
|
3
|
+
export const hasObjectPropertyDefaults = (propertyDefinition: JSONSchema.JSONSchema): boolean =>
|
|
4
4
|
!!propertyDefinition.properties &&
|
|
5
5
|
Object.values(propertyDefinition.properties).some(value => typeof value === 'object' && 'default' in value);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type JSONSchema } from 'zod/v4/core';
|
|
2
2
|
|
|
3
|
-
export const
|
|
3
|
+
export const hasRecordInvalidDefaults = (propertyDefinition: JSONSchema.JSONSchema): boolean =>
|
|
4
4
|
!!propertyDefinition.additionalProperties &&
|
|
5
5
|
typeof propertyDefinition.additionalProperties === 'object' &&
|
|
6
6
|
'default' in propertyDefinition.additionalProperties;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
2
|
-
export const isInvalidPropertyOverride = (propertyValue: any,
|
|
3
|
-
!
|
|
2
|
+
export const isInvalidPropertyOverride = (propertyValue: any, isOverride = false): boolean =>
|
|
3
|
+
!isOverride && propertyValue !== undefined;
|
|
@@ -18,11 +18,7 @@ export const isValidValue = (value: unknown, depth = 0): boolean => {
|
|
|
18
18
|
}
|
|
19
19
|
|
|
20
20
|
if (Array.isArray(value)) {
|
|
21
|
-
|
|
22
|
-
return true;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
return false;
|
|
21
|
+
return value.every(v => isValidValue(v, depth + 1));
|
|
26
22
|
}
|
|
27
23
|
|
|
28
24
|
return true;
|
|
@@ -46,21 +46,15 @@ export const transformConfig = async <Config extends AnyRecord>(
|
|
|
46
46
|
}
|
|
47
47
|
|
|
48
48
|
for (const key in config) {
|
|
49
|
-
// TODO: Need to look at this
|
|
50
|
-
// eslint-disable-next-line unicorn/no-unsafe-property-key
|
|
51
49
|
const value = config[key];
|
|
52
50
|
|
|
53
51
|
if (isPlainObject(value)) {
|
|
54
|
-
// TODO: Need to look at this
|
|
55
|
-
// eslint-disable-next-line unicorn/no-unsafe-property-key
|
|
56
52
|
transform[key] = await transformConfig(value, handler);
|
|
57
53
|
} else if (Array.isArray(value)) {
|
|
58
54
|
// TODO: Need to look at this
|
|
59
|
-
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions
|
|
55
|
+
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions
|
|
60
56
|
transform[key] = (await transformArray(value, handler)) as Config[Extract<keyof Config, string>];
|
|
61
57
|
} else {
|
|
62
|
-
// TODO: Need to look at this
|
|
63
|
-
// eslint-disable-next-line unicorn/no-unsafe-property-key
|
|
64
58
|
transform[key] = value;
|
|
65
59
|
}
|
|
66
60
|
}
|
|
@@ -114,20 +108,20 @@ export const transformConfigSync = <Config extends AnyRecord>(
|
|
|
114
108
|
|
|
115
109
|
for (const key in config) {
|
|
116
110
|
// TODO: Need to look at this
|
|
117
|
-
|
|
111
|
+
|
|
118
112
|
const value = config[key];
|
|
119
113
|
|
|
120
114
|
if (isPlainObject(value)) {
|
|
121
115
|
// TODO: Need to look at this
|
|
122
|
-
|
|
116
|
+
|
|
123
117
|
transform[key] = transformConfigSync(value, handler);
|
|
124
118
|
} else if (Array.isArray(value)) {
|
|
125
119
|
// TODO: Need to look at this
|
|
126
|
-
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions
|
|
120
|
+
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions
|
|
127
121
|
transform[key] = transformArraySync(value, handler) as Config[Extract<keyof Config, string>];
|
|
128
122
|
} else {
|
|
129
123
|
// TODO: Need to look at this
|
|
130
|
-
|
|
124
|
+
|
|
131
125
|
transform[key] = value;
|
|
132
126
|
}
|
|
133
127
|
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"arrayHasInvalidDefaults.d.cts","sourceRoot":"","sources":["../../../../src/utils/arrayHasInvalidDefaults.cts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,UAAU,EAAE,MAAM,aAAa,CAAC;AAE9C,eAAO,MAAM,uBAAuB,GAAI,oBAAoB,UAAU,CAAC,UAAU,KAAG,OAGnF,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"objectPropertyHasDefaults.d.cts","sourceRoot":"","sources":["../../../../src/utils/objectPropertyHasDefaults.cts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,UAAU,EAAE,MAAM,aAAa,CAAC;AAE9C,eAAO,MAAM,yBAAyB,GAAI,oBAAoB,UAAU,CAAC,UAAU,KAAG,OAEuB,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"recordHasInvalidDefaults.d.cts","sourceRoot":"","sources":["../../../../src/utils/recordHasInvalidDefaults.cts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,UAAU,EAAE,MAAM,aAAa,CAAC;AAE9C,eAAO,MAAM,wBAAwB,GAAI,oBAAoB,UAAU,CAAC,UAAU,KAAG,OAG/B,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"arrayHasInvalidDefaults.d.ts","sourceRoot":"","sources":["../../../../src/utils/arrayHasInvalidDefaults.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,UAAU,EAAE,MAAM,aAAa,CAAC;AAE9C,eAAO,MAAM,uBAAuB,GAAI,oBAAoB,UAAU,CAAC,UAAU,KAAG,OAGnF,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"objectPropertyHasDefaults.d.ts","sourceRoot":"","sources":["../../../../src/utils/objectPropertyHasDefaults.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,UAAU,EAAE,MAAM,aAAa,CAAC;AAE9C,eAAO,MAAM,yBAAyB,GAAI,oBAAoB,UAAU,CAAC,UAAU,KAAG,OAEuB,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"recordHasInvalidDefaults.d.ts","sourceRoot":"","sources":["../../../../src/utils/recordHasInvalidDefaults.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,UAAU,EAAE,MAAM,aAAa,CAAC;AAE9C,eAAO,MAAM,wBAAwB,GAAI,oBAAoB,UAAU,CAAC,UAAU,KAAG,OAG/B,CAAC"}
|