Skip to content

Commit bafc49f

Browse files
authored
chore: de-namespace types (#1741)
1 parent 7f8af58 commit bafc49f

File tree

3 files changed

+46
-21
lines changed

3 files changed

+46
-21
lines changed

.changeset/eight-ducks-rush.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
---
2+
---

packages/core/src/submodules/schema/schemas/NormalizedSchema.ts

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,12 @@ import type {
1818
StaticMapSchema,
1919
StaticOperationSchema,
2020
StaticSchema,
21-
StaticSchemaId,
21+
StaticSchemaIdError,
22+
StaticSchemaIdList,
23+
StaticSchemaIdMap,
24+
StaticSchemaIdOperation,
25+
StaticSchemaIdSimple,
26+
StaticSchemaIdStruct,
2227
StaticSimpleSchema,
2328
StaticStructureSchema,
2429
StreamingBlobSchema,
@@ -445,12 +450,12 @@ export function hydrate(
445450
const [id, ...rest] = ss;
446451
return (
447452
{
448-
[0 satisfies StaticSchemaId.Simple]: sim,
449-
[1 satisfies StaticSchemaId.List]: list,
450-
[2 satisfies StaticSchemaId.Map]: map,
451-
[3 satisfies StaticSchemaId.Struct]: struct,
452-
[-3 satisfies StaticSchemaId.Error]: error,
453-
[9 satisfies StaticSchemaId.Operation]: op,
453+
[0 satisfies StaticSchemaIdSimple]: sim,
454+
[1 satisfies StaticSchemaIdList]: list,
455+
[2 satisfies StaticSchemaIdMap]: map,
456+
[3 satisfies StaticSchemaIdStruct]: struct,
457+
[-3 satisfies StaticSchemaIdError]: error,
458+
[9 satisfies StaticSchemaIdOperation]: op,
454459
}[id] as Function
455460
).call(null, ...rest);
456461
}

packages/types/src/schema/static-schemas.ts

Lines changed: 32 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,32 @@ import type { SchemaRef, SchemaTraits } from "../schema/schema";
88
/**
99
* @alpha
1010
*/
11-
export namespace StaticSchemaId {
12-
export type Simple = 0;
13-
export type List = 1;
14-
export type Map = 2;
15-
export type Struct = 3;
16-
export type Error = -3;
17-
export type Operation = 9;
18-
}
11+
export type StaticSchemaIdSimple = 0;
12+
13+
/**
14+
* @alpha
15+
*/
16+
export type StaticSchemaIdList = 1;
17+
18+
/**
19+
* @alpha
20+
*/
21+
export type StaticSchemaIdMap = 2;
22+
23+
/**
24+
* @alpha
25+
*/
26+
export type StaticSchemaIdStruct = 3;
27+
28+
/**
29+
* @alpha
30+
*/
31+
export type StaticSchemaIdError = -3;
32+
33+
/**
34+
* @alpha
35+
*/
36+
export type StaticSchemaIdOperation = 9;
1937

2038
/**
2139
* @alpha
@@ -41,23 +59,23 @@ export type ShapeNamespace = string;
4159
/**
4260
* @alpha
4361
*/
44-
export type StaticSimpleSchema = [StaticSchemaId.Simple, ShapeNamespace, ShapeName, SchemaRef, SchemaTraits];
62+
export type StaticSimpleSchema = [StaticSchemaIdSimple, ShapeNamespace, ShapeName, SchemaRef, SchemaTraits];
4563

4664
/**
4765
* @alpha
4866
*/
49-
export type StaticListSchema = [StaticSchemaId.List, ShapeNamespace, ShapeName, SchemaTraits, SchemaRef];
67+
export type StaticListSchema = [StaticSchemaIdList, ShapeNamespace, ShapeName, SchemaTraits, SchemaRef];
5068

5169
/**
5270
* @alpha
5371
*/
54-
export type StaticMapSchema = [StaticSchemaId.Map, ShapeNamespace, ShapeName, SchemaTraits, SchemaRef, SchemaRef];
72+
export type StaticMapSchema = [StaticSchemaIdMap, ShapeNamespace, ShapeName, SchemaTraits, SchemaRef, SchemaRef];
5573

5674
/**
5775
* @alpha
5876
*/
5977
export type StaticStructureSchema = [
60-
StaticSchemaId.Struct,
78+
StaticSchemaIdStruct,
6179
ShapeNamespace,
6280
ShapeName,
6381
SchemaTraits,
@@ -69,7 +87,7 @@ export type StaticStructureSchema = [
6987
* @alpha
7088
*/
7189
export type StaticErrorSchema = [
72-
StaticSchemaId.Error,
90+
StaticSchemaIdError,
7391
ShapeNamespace,
7492
ShapeName,
7593
SchemaTraits,
@@ -81,7 +99,7 @@ export type StaticErrorSchema = [
8199
* @alpha
82100
*/
83101
export type StaticOperationSchema = [
84-
StaticSchemaId.Operation,
102+
StaticSchemaIdOperation,
85103
ShapeNamespace,
86104
ShapeName,
87105
SchemaTraits,

0 commit comments

Comments
 (0)