Skip to content

Commit 52fdd9f

Browse files
committed
chore: 🤖 remove type router class
1 parent 28e2f81 commit 52fdd9f

File tree

7 files changed

+17
-195
lines changed

7 files changed

+17
-195
lines changed

src/random/generators.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import {RandomJson} from '@jsonjoy.com/util/lib/json-random';
22
import {cloneBinary} from '@jsonjoy.com/util/lib/json-clone';
3-
import type {AbstractType} from '../type/classes/AbstractType';
43
import type {AnyType} from '../type/classes/AnyType';
54
import type {ArrayType} from '../type/classes/ArrayType';
65
import type {BinaryType} from '../type/classes/BinaryType';

src/system/Method.ts

Lines changed: 0 additions & 21 deletions
This file was deleted.

src/system/TypeRouter.ts

Lines changed: 0 additions & 111 deletions
This file was deleted.

src/system/__tests__/TypeSystem.spec.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,23 @@ describe('.toString()', () => {
4242
4343
└─ validators
4444
└─ "empty-string""
45+
`);
46+
});
47+
48+
test('prints type with nested self reference', () => {
49+
const system = new TypeSystem();
50+
const {t} = system;
51+
system.alias('User', t.obj.prop('id', t.str).opt('friend', t.Ref('User')));
52+
expect(system.toString()).toMatchInlineSnapshot(`
53+
"TypeSystem
54+
├─ aliases
55+
│ └─ User
56+
│ └─ obj
57+
│ ├─ "id":
58+
│ │ └─ str
59+
│ └─ "friend"?:
60+
│ └─ ref → [User]
61+
└─ validators"
4562
`);
4663
});
4764
});

src/system/__tests__/toTypeScript.spec.ts

Lines changed: 0 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import {TypeSystem} from '..';
2-
import {TypeRouter} from '../TypeRouter';
32

43
test('generates TypeScript source for simple string type', () => {
54
const system = new TypeSystem();
@@ -92,49 +91,3 @@ test('type interface inside a tuple', () => {
9291
"
9392
`);
9493
});
95-
96-
test('can export whole router', () => {
97-
const system = new TypeSystem();
98-
const {t} = system;
99-
const router = new TypeRouter({system, routes: {}}).extend(() => ({
100-
callMe: t.Function(t.str, t.num),
101-
'block.subscribe': t.Function$(t.Object(t.prop('id', t.str)), t.obj),
102-
}));
103-
expect(router.toTypeScript()).toMatchInlineSnapshot(`
104-
"export namespace Router {
105-
export type Routes = {
106-
callMe: (request: string) => Promise<number>;
107-
"block.subscribe": (request$: Observable<{
108-
id: string;
109-
}>) => Observable<{}>;
110-
};
111-
}
112-
"
113-
`);
114-
});
115-
116-
test('can export whole router and aliases', () => {
117-
const system = new TypeSystem();
118-
const {t} = system;
119-
system.alias('Document', t.Object(t.prop('id', t.str), t.prop('title', t.str)).options({title: 'The document'}));
120-
const router = new TypeRouter({system, routes: {}}).extend(() => ({
121-
callMe: t.Function(t.str, t.num),
122-
'block.subscribe': t.Function$(t.Object(t.prop('id', t.str)), t.Ref('Document')),
123-
}));
124-
expect(router.toTypeScript()).toMatchInlineSnapshot(`
125-
"export namespace Router {
126-
export type Routes = {
127-
callMe: (request: string) => Promise<number>;
128-
"block.subscribe": (request$: Observable<{
129-
id: string;
130-
}>) => Observable<Document>;
131-
};
132-
133-
export interface Document {
134-
id: string;
135-
title: string;
136-
}
137-
}
138-
"
139-
`);
140-
});

src/type/classes/ArrayType.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ import type {BinaryEncoderCodegenContext} from '../../codegen/binary/BinaryEncod
1414
import type {SchemaOf, Type} from '../types';
1515
import type {TypeSystem} from '../../system/TypeSystem';
1616
import type {json_string} from '@jsonjoy.com/util/lib/json-brand';
17-
import type * as ts from '../../typescript/types';
1817
import type {TypeExportContext} from '../../system/TypeExportContext';
1918

2019
export class ArrayType<T extends Type> extends AbstractType<schema.ArraySchema<SchemaOf<T>>> {

src/value/ObjectValue.ts

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -18,20 +18,6 @@ export type ObjectValueToTypeMap<F> = ToObject<{
1818
}>;
1919
export type TuplesToFields<T> = T extends PropDefinition<infer K, infer V>[] ? classes.ObjectFieldType<K, V>[] : never;
2020

21-
// export type MergeObjectsTypes<A, B> =
22-
// A extends classes.ObjectType<infer A2>
23-
// ? B extends classes.ObjectType<infer B2>
24-
// ? classes.ObjectType<[...A2, ...B2]> :
25-
// never :
26-
// never;
27-
28-
// export type MergeObjectValues<A, B> =
29-
// A extends ObjectValue<infer A2>
30-
// ? B extends ObjectValue<infer B2>
31-
// ? ObjectValue<MergeObjectsTypes<A2, B2>> :
32-
// never :
33-
// never;
34-
3521
type PropDefinition<K extends string, V extends classes.Type> = [key: K, val: V, data: ResolveType<V>];
3622
type PropDef = <K extends string, V extends classes.Type>(key: K, val: V, data: ResolveType<V>) => PropDefinition<K, V>;
3723

0 commit comments

Comments
 (0)