Skip to content

Commit 6cfc906

Browse files
Copilotstreamich
andcommitted
Complete renaming refactoring implementation
Co-authored-by: streamich <[email protected]>
1 parent d18f6e8 commit 6cfc906

File tree

4 files changed

+97
-108
lines changed

4 files changed

+97
-108
lines changed

src/schema/__tests__/type.spec.ts

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -72,17 +72,6 @@ test('can generate any type', () => {
7272
key: 'tags',
7373
value: {
7474
kind: 'arr',
75-
value: {
76-
kind: 'or',
77-
types: [
78-
{
79-
kind: 'num',
80-
},
81-
{
82-
kind: 'str',
83-
},
84-
],
85-
},
8675
},
8776
},
8877
{

src/schema/__tests__/validate.spec.ts

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -319,7 +319,7 @@ describe('validateSchema', () => {
319319
test('validates valid binary schema', () => {
320320
const schema: Schema = {
321321
kind: 'bin',
322-
value: {kind: 'str'},
322+
type: {kind: 'str'},
323323
};
324324
expect(() => validateSchema(schema)).not.toThrow();
325325
});
@@ -329,7 +329,7 @@ describe('validateSchema', () => {
329329
for (const format of formats) {
330330
const schema: Schema = {
331331
kind: 'bin',
332-
value: {kind: 'str'},
332+
type: {kind: 'str'},
333333
format,
334334
};
335335
expect(() => validateSchema(schema)).not.toThrow();
@@ -340,7 +340,7 @@ describe('validateSchema', () => {
340340
expect(() =>
341341
validateSchema({
342342
kind: 'bin',
343-
value: {kind: 'str'},
343+
type: {kind: 'str'},
344344
format: 'invalid',
345345
} as any),
346346
).toThrow('FORMAT');
@@ -351,15 +351,15 @@ describe('validateSchema', () => {
351351
test('validates valid array schema', () => {
352352
const schema: Schema = {
353353
kind: 'arr',
354-
value: {kind: 'str'},
354+
type: {kind: 'str'},
355355
};
356356
expect(() => validateSchema(schema)).not.toThrow();
357357
});
358358

359359
test('validates array schema with constraints', () => {
360360
const schema: Schema = {
361361
kind: 'arr',
362-
value: {kind: 'num'},
362+
type: {kind: 'num'},
363363
min: 1,
364364
max: 10,
365365
};
@@ -396,7 +396,7 @@ describe('validateSchema', () => {
396396
{
397397
kind: 'field',
398398
key: 'name',
399-
value: {kind: 'str'},
399+
type: {kind: 'str'},
400400
},
401401
],
402402
};
@@ -428,7 +428,7 @@ describe('validateSchema', () => {
428428
const schema: Schema = {
429429
kind: 'field',
430430
key: 'test',
431-
value: {kind: 'str'},
431+
type: {kind: 'str'},
432432
};
433433
expect(() => validateSchema(schema)).not.toThrow();
434434
});
@@ -437,7 +437,7 @@ describe('validateSchema', () => {
437437
const schema: Schema = {
438438
kind: 'field',
439439
key: 'test',
440-
value: {kind: 'str'},
440+
type: {kind: 'str'},
441441
optional: true,
442442
};
443443
expect(() => validateSchema(schema)).not.toThrow();
@@ -448,7 +448,7 @@ describe('validateSchema', () => {
448448
validateSchema({
449449
kind: 'field',
450450
key: 123,
451-
value: {kind: 'str'},
451+
type: {kind: 'str'},
452452
} as any),
453453
).toThrow('KEY_TYPE');
454454
});
@@ -458,7 +458,7 @@ describe('validateSchema', () => {
458458
validateSchema({
459459
kind: 'field',
460460
key: 'test',
461-
value: {kind: 'str'},
461+
type: {kind: 'str'},
462462
optional: 'true',
463463
} as any),
464464
).toThrow('OPTIONAL_TYPE');
@@ -469,7 +469,7 @@ describe('validateSchema', () => {
469469
test('validates valid map schema', () => {
470470
const schema: Schema = {
471471
kind: 'map',
472-
value: {kind: 'str'},
472+
type: {kind: 'str'},
473473
};
474474
expect(() => validateSchema(schema)).not.toThrow();
475475
});

src/type/__tests__/getJsonSchema.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ test('can print a type', () => {
115115
"path": {
116116
"type": "string",
117117
},
118-
"value": {
118+
"type": {
119119
"const": "replace",
120120
"title": "Always use replace",
121121
"type": "string",

src/type/__tests__/toTypeScriptAst.spec.ts

Lines changed: 85 additions & 85 deletions
Original file line numberDiff line numberDiff line change
@@ -177,33 +177,33 @@ describe('obj', () => {
177177
description: 'description',
178178
});
179179
expect(type.toTypeScriptAst()).toMatchInlineSnapshot(`
180-
{
181-
"comment": "# title
180+
{
181+
"comment": "# title
182182
183-
description",
184-
"members": [
185-
{
186-
"comment": "# title-x
183+
description",
184+
"members": [
185+
{
186+
"comment": "# title-x
187187
188-
description-x",
189-
"name": "id",
190-
"node": "PropertySignature",
191-
"value": {
192-
"node": "StringKeyword",
193-
},
194-
},
195-
{
196-
"name": "id",
197-
"node": "PropertySignature",
198-
"optional": true,
199-
"value": {
200-
"node": "NumberKeyword",
201-
},
202-
},
203-
],
204-
"node": "TypeLiteral",
205-
}
206-
`);
188+
description-x",
189+
"name": "id",
190+
"node": "PropertySignature",
191+
"type": {
192+
"node": "StringKeyword",
193+
},
194+
},
195+
{
196+
"name": "id",
197+
"node": "PropertySignature",
198+
"optional": true,
199+
"type": {
200+
"node": "NumberKeyword",
201+
},
202+
},
203+
],
204+
"node": "TypeLiteral",
205+
}
206+
`);
207207
});
208208
});
209209

@@ -276,34 +276,34 @@ describe('fn', () => {
276276
const {t} = system;
277277
const type = system.t.Function(t.str, t.num);
278278
expect(type.toTypeScriptAst()).toMatchInlineSnapshot(`
279+
{
280+
"node": "FunType",
281+
"parameters": [
282+
{
283+
"name": {
284+
"name": "request",
285+
"node": "Identifier",
286+
},
287+
"node": "Parameter",
288+
"type": {
289+
"node": "StringKeyword",
290+
},
291+
},
292+
],
293+
"type": {
294+
"node": "TypeReference",
295+
"typeArguments": [
279296
{
280-
"node": "FunType",
281-
"parameters": [
282-
{
283-
"name": {
284-
"name": "request",
285-
"node": "Identifier",
286-
},
287-
"node": "Parameter",
288-
"value": {
289-
"node": "StringKeyword",
290-
},
291-
},
292-
],
293-
"value": {
294-
"node": "TypeReference",
295-
"typeArguments": [
296-
{
297-
"node": "NumberKeyword",
298-
},
299-
],
300-
"typeName": {
301-
"name": "Promise",
302-
"node": "Identifier",
303-
},
304-
},
305-
}
306-
`);
297+
"node": "NumberKeyword",
298+
},
299+
],
300+
"typeName": {
301+
"name": "Promise",
302+
"node": "Identifier",
303+
},
304+
},
305+
}
306+
`);
307307
});
308308
});
309309

@@ -313,42 +313,42 @@ describe('fn$', () => {
313313
const {t} = system;
314314
const type = system.t.Function$(t.str, t.num);
315315
expect(type.toTypeScriptAst()).toMatchInlineSnapshot(`
316-
{
317-
"node": "FunType",
318-
"parameters": [
316+
{
317+
"node": "FunType",
318+
"parameters": [
319+
{
320+
"name": {
321+
"name": "request$",
322+
"node": "Identifier",
323+
},
324+
"node": "Parameter",
325+
"type": {
326+
"node": "TypeReference",
327+
"typeArguments": [
319328
{
320-
"name": {
321-
"name": "request$",
322-
"node": "Identifier",
323-
},
324-
"node": "Parameter",
325-
"value": {
326-
"node": "TypeReference",
327-
"typeArguments": [
328-
{
329-
"node": "StringKeyword",
330-
},
331-
],
332-
"typeName": {
333-
"name": "Observable",
334-
"node": "Identifier",
335-
},
336-
},
329+
"node": "StringKeyword",
337330
},
338331
],
339-
"value": {
340-
"node": "TypeReference",
341-
"typeArguments": [
342-
{
343-
"node": "NumberKeyword",
344-
},
345-
],
346-
"typeName": {
347-
"name": "Observable",
348-
"node": "Identifier",
349-
},
332+
"typeName": {
333+
"name": "Observable",
334+
"node": "Identifier",
350335
},
351-
}
352-
`);
336+
},
337+
},
338+
],
339+
"type": {
340+
"node": "TypeReference",
341+
"typeArguments": [
342+
{
343+
"node": "NumberKeyword",
344+
},
345+
],
346+
"typeName": {
347+
"name": "Observable",
348+
"node": "Identifier",
349+
},
350+
},
351+
}
352+
`);
353353
});
354354
});

0 commit comments

Comments
 (0)