Skip to content

Commit d18f6e8

Browse files
Copilotstreamich
andcommitted
Fix remaining references to use new schema field names
Co-authored-by: streamich <[email protected]>
1 parent 73e7acc commit d18f6e8

File tree

6 files changed

+23
-20
lines changed

6 files changed

+23
-20
lines changed

src/codegen/capacity/estimators.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ export const map = (ctx: CapacityEstimatorCodegenContext, value: JsExpression, t
142142
const rLen = codegen.var(`${rKeys}.length`);
143143
codegen.js(`size += ${MaxEncodingOverhead.ObjectElement} * ${rLen}`);
144144
const mapType = type as any; // MapType
145-
const valueType = mapType.type;
145+
const valueType = mapType.valueType;
146146
const fn = valueType.compileCapacityEstimator({
147147
system: ctx.options.system,
148148
name: ctx.options.name,

src/json-schema/converter.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ function mapToJsonSchema(type: MapType<any>, ctx?: TypeExportContext): JsonSchem
204204
const result: JsonSchemaObject = {
205205
type: 'object',
206206
patternProperties: {
207-
'.*': typeToJsonSchema((type as any).type, ctx),
207+
'.*': typeToJsonSchema((type as any).valueType, ctx),
208208
},
209209
};
210210

src/random/generators.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ export const map = (type: MapType<any>): Record<string, unknown> => {
5454
const length = Math.round(Math.random() * 10);
5555
const res: Record<string, unknown> = {};
5656
for (let i = 0; i < length; i++) {
57-
res[RandomJson.genString(length)] = (type as any).type.random();
57+
res[RandomJson.genString(length)] = (type as any).valueType.random();
5858
}
5959
return res;
6060
};

src/schema/validate.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -162,12 +162,15 @@ const validateFieldSchema = (schema: any, validateChildSchema: (schema: Schema)
162162
const {key, optional} = schema;
163163
if (typeof key !== 'string') throw new Error('KEY_TYPE');
164164
if (optional !== undefined && typeof optional !== 'boolean') throw new Error('OPTIONAL_TYPE');
165-
validateChildSchema(schema.type);
165+
validateChildSchema(schema.value);
166166
};
167167

168168
const validateMapSchema = (schema: any, validateChildSchema: (schema: Schema) => void): void => {
169169
validateTType(schema, 'map');
170-
validateChildSchema(schema.type);
170+
validateChildSchema(schema.value);
171+
if (schema.key) {
172+
validateChildSchema(schema.key);
173+
}
171174
};
172175

173176
const validateRefSchema = (schema: any): void => {

src/type/__tests__/TypeBuilder.spec.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -155,10 +155,10 @@ describe('import()', () => {
155155
expect(type.getSchema()).toStrictEqual({
156156
kind: 'obj',
157157
fields: [
158-
{kind: 'field', key: 'id', type: {kind: 'str'}},
159-
{kind: 'field', key: 'name', type: {kind: 'str'}, optional: true},
160-
{kind: 'field', key: 'age', type: {kind: 'num'}, optional: true},
161-
{kind: 'field', key: 'verified', type: {kind: 'bool'}},
158+
{kind: 'field', key: 'id', value: {kind: 'str'}},
159+
{kind: 'field', key: 'name', value: {kind: 'str'}, optional: true},
160+
{kind: 'field', key: 'age', value: {kind: 'num'}, optional: true},
161+
{kind: 'field', key: 'verified', value: {kind: 'bool'}},
162162
],
163163
});
164164
});
@@ -253,7 +253,7 @@ describe('validateSchema()', () => {
253253
{
254254
kind: 'field',
255255
key: 'id',
256-
type: {kind: 'str', ascii: 'bytes'} as any,
256+
value: {kind: 'str', ascii: 'bytes'} as any,
257257
},
258258
],
259259
});
@@ -269,7 +269,7 @@ describe('validateSchema()', () => {
269269
kind: 'field',
270270
key: 'id',
271271
optional: 123,
272-
type: {kind: 'str'},
272+
value: {kind: 'str'},
273273
} as any,
274274
],
275275
});

src/type/classes/__tests__/BinType.spec.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,28 +2,28 @@ import {t} from '../../..';
22

33
test('can use convenience methods to define type schema fields', () => {
44
const binary = t.bin;
5-
expect(binary.getSchema()).toEqual({kind: 'bin', value: {kind: 'any'}});
5+
expect(binary.getSchema()).toEqual({kind: 'bin', type: {kind: 'any'}});
66
binary.title('My Binary');
7-
expect(binary.getSchema()).toEqual({kind: 'bin', value: {kind: 'any'}, title: 'My Binary'});
7+
expect(binary.getSchema()).toEqual({kind: 'bin', type: {kind: 'any'}, title: 'My Binary'});
88
binary.intro('This is a binary type');
99
expect(binary.getSchema()).toEqual({
1010
kind: 'bin',
11-
value: {kind: 'any'},
11+
type: {kind: 'any'},
1212
title: 'My Binary',
1313
intro: 'This is a binary type',
1414
});
1515
binary.description('A detailed description of the binary type');
1616
expect(binary.getSchema()).toEqual({
1717
kind: 'bin',
18-
value: {kind: 'any'},
18+
type: {kind: 'any'},
1919
title: 'My Binary',
2020
intro: 'This is a binary type',
2121
description: 'A detailed description of the binary type',
2222
});
2323
binary.format('json');
2424
expect(binary.getSchema()).toEqual({
2525
kind: 'bin',
26-
value: {kind: 'any'},
26+
type: {kind: 'any'},
2727
title: 'My Binary',
2828
intro: 'This is a binary type',
2929
description: 'A detailed description of the binary type',
@@ -32,7 +32,7 @@ test('can use convenience methods to define type schema fields', () => {
3232
binary.min(5);
3333
expect(binary.getSchema()).toEqual({
3434
kind: 'bin',
35-
value: {kind: 'any'},
35+
type: {kind: 'any'},
3636
title: 'My Binary',
3737
intro: 'This is a binary type',
3838
description: 'A detailed description of the binary type',
@@ -42,7 +42,7 @@ test('can use convenience methods to define type schema fields', () => {
4242
binary.max(10);
4343
expect(binary.getSchema()).toEqual({
4444
kind: 'bin',
45-
value: {kind: 'any'},
45+
type: {kind: 'any'},
4646
title: 'My Binary',
4747
intro: 'This is a binary type',
4848
description: 'A detailed description of the binary type',
@@ -53,7 +53,7 @@ test('can use convenience methods to define type schema fields', () => {
5353
binary.default(new Uint8Array([1, 2, 3]));
5454
expect(binary.getSchema()).toEqual({
5555
kind: 'bin',
56-
value: {kind: 'any'},
56+
type: {kind: 'any'},
5757
title: 'My Binary',
5858
intro: 'This is a binary type',
5959
description: 'A detailed description of the binary type',
@@ -65,7 +65,7 @@ test('can use convenience methods to define type schema fields', () => {
6565
binary.example(new Uint8Array([4, 5, 6]), 'Example Binary', {description: 'An example binary value'});
6666
expect(binary.getSchema()).toEqual({
6767
kind: 'bin',
68-
value: {kind: 'any'},
68+
type: {kind: 'any'},
6969
title: 'My Binary',
7070
intro: 'This is a binary type',
7171
description: 'A detailed description of the binary type',

0 commit comments

Comments
 (0)