schemair 0.1.0 → 0.2.0
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/README.md +420 -11
- package/dist/authoring/index.cjs +13 -350
- package/dist/authoring/index.d.cts +2 -90
- package/dist/authoring/index.d.ts +2 -90
- package/dist/authoring/index.js +2 -304
- package/dist/authoring-D3V0iyTe.js +362 -0
- package/dist/authoring-Dnrg5TXm.cjs +389 -0
- package/dist/chunk-BgLxgFZR.js +18 -0
- package/dist/definition/index.cjs +10 -2
- package/dist/definition/index.d.cts +3 -21
- package/dist/definition/index.d.ts +3 -21
- package/dist/definition/index.js +2 -2
- package/dist/definition-BLLBpLKv.cjs +1187 -0
- package/dist/definition-DmYnDmQO.js +1115 -0
- package/dist/index-4aMF0cTE.d.ts +368 -0
- package/dist/index-BqfGAU1K.d.ts +56 -0
- package/dist/{index-eK2Xgrwp.d.ts → index-CBbd4hXJ.d.ts} +13 -2
- package/dist/index-CIim1dG7.d.cts +92 -0
- package/dist/{index-TACcK_mi.d.cts → index-CNjYUKvu.d.cts} +13 -2
- package/dist/index-CQynt7ft.d.cts +420 -0
- package/dist/index-D3mfwaSO.d.cts +56 -0
- package/dist/index-DDMwVy2I.d.cts +368 -0
- package/dist/index-DM5DSLLL.d.ts +99 -0
- package/dist/index-DXWoNYFB.d.ts +92 -0
- package/dist/index-DhmHCGpT.d.cts +99 -0
- package/dist/index-bQy-C-1l.d.ts +418 -0
- package/dist/index.cjs +64 -52
- package/dist/index.d.cts +7 -7
- package/dist/index.d.ts +7 -7
- package/dist/index.js +7 -5
- package/dist/integrations/json-schema/index.cjs +328 -0
- package/dist/integrations/json-schema/index.d.cts +53 -0
- package/dist/integrations/json-schema/index.d.ts +53 -0
- package/dist/integrations/json-schema/index.js +324 -0
- package/dist/integrations/standard-schema/index.cjs +32 -0
- package/dist/integrations/standard-schema/index.d.cts +22 -0
- package/dist/integrations/standard-schema/index.d.ts +22 -0
- package/dist/integrations/standard-schema/index.js +32 -0
- package/dist/payload/index.cjs +1 -1
- package/dist/payload/index.d.cts +1 -55
- package/dist/payload/index.d.ts +1 -55
- package/dist/payload/index.js +1 -1
- package/dist/relations/index.cjs +3 -1
- package/dist/relations/index.d.cts +2 -2
- package/dist/relations/index.d.ts +2 -2
- package/dist/relations/index.js +2 -2
- package/dist/{relations-CMz_0nf4.cjs → relations-Cymx4iTc.cjs} +158 -5
- package/dist/{relations-By0bK3UK.js → relations-ysXDmi-Z.js} +147 -6
- package/dist/spec/index.cjs +9 -0
- package/dist/spec/index.d.cts +2 -2
- package/dist/spec/index.d.ts +2 -2
- package/dist/spec/index.js +3 -1
- package/dist/standard/index.cjs +810 -0
- package/dist/standard/index.d.cts +3 -0
- package/dist/standard/index.d.ts +3 -0
- package/dist/standard/index.js +777 -0
- package/dist/standard-DhKsxu9U.js +471 -0
- package/dist/standard-etPFZDJI.cjs +513 -0
- package/dist/type-interpreter/index.cjs +3 -3
- package/dist/type-interpreter/index.d.cts +2 -99
- package/dist/type-interpreter/index.d.ts +2 -99
- package/dist/type-interpreter/index.js +2 -2
- package/dist/{type-interpreter-Ck0VDhzn.js → type-interpreter-DnrId8aM.js} +5 -284
- package/dist/{type-interpreter-DAIBUqKf.cjs → type-interpreter-OLt2W2yd.cjs} +15 -294
- package/package.json +38 -3
- package/dist/definition-BXj3T94L.js +0 -467
- package/dist/definition-DSZZTz4e.cjs +0 -473
- package/dist/index-CEzHfht2.d.ts +0 -269
- package/dist/index-rzkFjgrt.d.cts +0 -269
|
@@ -1,99 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
//#region src/type-interpreter/interpreter.d.ts
|
|
5
|
-
type TypeInterpreterPath = readonly (string | number)[];
|
|
6
|
-
interface TypeInterpreterDiagnostic {
|
|
7
|
-
readonly code: string;
|
|
8
|
-
readonly path: TypeInterpreterPath;
|
|
9
|
-
readonly message: string;
|
|
10
|
-
}
|
|
11
|
-
type TypeInterpreterStatus = 'evaluated' | 'incomplete' | 'rejected';
|
|
12
|
-
type EvaluatedTypeTerm = SchemaNode | SchemaValueTypeExpr;
|
|
13
|
-
type TypeInterpreterResult = {
|
|
14
|
-
readonly status: 'evaluated';
|
|
15
|
-
readonly term: EvaluatedTypeTerm;
|
|
16
|
-
readonly schema?: SchemaNode;
|
|
17
|
-
readonly unresolvedTypeVars?: readonly string[];
|
|
18
|
-
readonly issues: readonly TypeInterpreterDiagnostic[];
|
|
19
|
-
} | {
|
|
20
|
-
readonly status: 'incomplete';
|
|
21
|
-
readonly issues: readonly TypeInterpreterDiagnostic[];
|
|
22
|
-
} | {
|
|
23
|
-
readonly status: 'rejected';
|
|
24
|
-
readonly issues: readonly TypeInterpreterDiagnostic[];
|
|
25
|
-
};
|
|
26
|
-
type TypeInterpreterRefResolution = SchemaNode | {
|
|
27
|
-
readonly status: 'resolved';
|
|
28
|
-
readonly schema: SchemaNode;
|
|
29
|
-
} | {
|
|
30
|
-
readonly status: 'unknown' | 'unsupported';
|
|
31
|
-
readonly message?: string;
|
|
32
|
-
} | undefined;
|
|
33
|
-
type AsyncTypeInterpreterRefResolution = TypeInterpreterRefResolution | PromiseLike<TypeInterpreterRefResolution>;
|
|
34
|
-
interface TypeInterpreterContext {
|
|
35
|
-
readonly typeVars?: Readonly<Record<string, SchemaValueTypeTerm>>;
|
|
36
|
-
readonly resolveRef?: (refPath: readonly string[]) => TypeInterpreterRefResolution;
|
|
37
|
-
readonly maxDepth?: number;
|
|
38
|
-
readonly maxSteps?: number;
|
|
39
|
-
}
|
|
40
|
-
interface AsyncTypeInterpreterContext {
|
|
41
|
-
readonly typeVars?: Readonly<Record<string, SchemaValueTypeTerm>>;
|
|
42
|
-
readonly resolveRef?: (refPath: readonly string[]) => AsyncTypeInterpreterRefResolution;
|
|
43
|
-
readonly maxDepth?: number;
|
|
44
|
-
readonly maxSteps?: number;
|
|
45
|
-
}
|
|
46
|
-
declare function evaluateExpression(term: unknown, context?: TypeInterpreterContext): TypeInterpreterResult;
|
|
47
|
-
declare function evaluateExpressionAsync(term: unknown, context?: AsyncTypeInterpreterContext): Promise<TypeInterpreterResult>;
|
|
48
|
-
declare const evaluateSchemaValueTypeTerm: typeof evaluateExpression;
|
|
49
|
-
declare const evaluateSchemaValueTypeTermAsync: typeof evaluateExpressionAsync;
|
|
50
|
-
//#endregion
|
|
51
|
-
//#region src/type-interpreter/term-relation.d.ts
|
|
52
|
-
interface TypeTermRelationContext {
|
|
53
|
-
readonly interpreter?: TypeInterpreterContext;
|
|
54
|
-
readonly relation?: RelationContext;
|
|
55
|
-
readonly hostTypeRelation?: (sourcePath: readonly string[], targetPath: readonly string[]) => HostTypeRelationDecision;
|
|
56
|
-
}
|
|
57
|
-
interface AsyncTypeTermRelationContext {
|
|
58
|
-
readonly interpreter?: AsyncTypeInterpreterContext;
|
|
59
|
-
readonly relation?: AsyncRelationContext;
|
|
60
|
-
readonly hostTypeRelation?: (sourcePath: readonly string[], targetPath: readonly string[]) => HostTypeRelationDecision | PromiseLike<HostTypeRelationDecision>;
|
|
61
|
-
}
|
|
62
|
-
type HostTypeRelationDecision = boolean | {
|
|
63
|
-
readonly status: 'assignable' | 'incompatible' | 'unknown' | 'unsupported';
|
|
64
|
-
readonly message?: string;
|
|
65
|
-
};
|
|
66
|
-
declare function checkTypeTermRelation(source: SchemaValueTypeTerm, target: SchemaValueTypeTerm, context?: TypeTermRelationContext): RelationResult;
|
|
67
|
-
declare function checkTypeTermRelationAsync(source: SchemaValueTypeTerm, target: SchemaValueTypeTerm, context?: AsyncTypeTermRelationContext): Promise<RelationResult>;
|
|
68
|
-
//#endregion
|
|
69
|
-
//#region src/type-interpreter/type-variable-solver.d.ts
|
|
70
|
-
interface TypeVariableConstraint {
|
|
71
|
-
readonly source: SchemaValueTypeTerm;
|
|
72
|
-
readonly target: SchemaValueTypeTerm;
|
|
73
|
-
}
|
|
74
|
-
interface TypeVariableSolverInput {
|
|
75
|
-
readonly variables: readonly string[];
|
|
76
|
-
readonly constraints: readonly TypeVariableConstraint[];
|
|
77
|
-
}
|
|
78
|
-
interface TypeVariableSolverIssue {
|
|
79
|
-
readonly code: string;
|
|
80
|
-
readonly constraint?: number;
|
|
81
|
-
readonly variable?: string;
|
|
82
|
-
readonly message: string;
|
|
83
|
-
}
|
|
84
|
-
interface TypeVariableSolverResult {
|
|
85
|
-
readonly status: 'solved' | 'unknown' | 'incompatible' | 'rejected';
|
|
86
|
-
readonly bindings: Readonly<Record<string, EvaluatedTypeTerm>>;
|
|
87
|
-
readonly unresolved: readonly string[];
|
|
88
|
-
readonly issues: readonly TypeVariableSolverIssue[];
|
|
89
|
-
}
|
|
90
|
-
interface TypeVariableSolverContext extends TypeTermRelationContext {
|
|
91
|
-
readonly interpreter?: TypeInterpreterContext;
|
|
92
|
-
}
|
|
93
|
-
interface AsyncTypeVariableSolverContext extends AsyncTypeTermRelationContext {
|
|
94
|
-
readonly interpreter?: AsyncTypeInterpreterContext;
|
|
95
|
-
}
|
|
96
|
-
declare function solveTypeVariables(input: TypeVariableSolverInput, context?: TypeVariableSolverContext): TypeVariableSolverResult;
|
|
97
|
-
declare function solveTypeVariablesAsync(input: TypeVariableSolverInput, context?: AsyncTypeVariableSolverContext): Promise<TypeVariableSolverResult>;
|
|
98
|
-
//#endregion
|
|
99
|
-
export { AsyncTypeInterpreterContext, AsyncTypeInterpreterRefResolution, AsyncTypeTermRelationContext, AsyncTypeVariableSolverContext, EvaluatedTypeTerm, HostTypeRelationDecision, TypeInterpreterContext, TypeInterpreterDiagnostic, TypeInterpreterPath, TypeInterpreterRefResolution, TypeInterpreterResult, TypeInterpreterStatus, TypeTermRelationContext, TypeVariableConstraint, TypeVariableSolverContext, TypeVariableSolverInput, TypeVariableSolverIssue, TypeVariableSolverResult, checkTypeTermRelation, checkTypeTermRelationAsync, evaluateExpression, evaluateExpressionAsync, evaluateSchemaValueTypeTerm, evaluateSchemaValueTypeTermAsync, solveTypeVariables, solveTypeVariablesAsync };
|
|
1
|
+
import { C as evaluateExpression, E as evaluateSchemaTypeTermAsync, S as TypeInterpreterStatus, T as evaluateSchemaTypeTerm, _ as TypeInterpreterContext, a as TypeVariableSolverIssue, b as TypeInterpreterRefResolution, c as solveTypeVariablesAsync, d as TypeTermRelationContext, f as checkTypeTermRelation, g as EvaluatedTypeTerm, h as AsyncTypeInterpreterRefResolution, i as TypeVariableSolverInput, l as AsyncTypeTermRelationContext, m as AsyncTypeInterpreterContext, n as TypeVariableConstraint, o as TypeVariableSolverResult, p as checkTypeTermRelationAsync, r as TypeVariableSolverContext, s as solveTypeVariables, t as AsyncTypeVariableSolverContext, u as HostTypeRelationDecision, v as TypeInterpreterDiagnostic, w as evaluateExpressionAsync, x as TypeInterpreterResult, y as TypeInterpreterPath } from "../index-DM5DSLLL.js";
|
|
2
|
+
export { AsyncTypeInterpreterContext, AsyncTypeInterpreterRefResolution, AsyncTypeTermRelationContext, AsyncTypeVariableSolverContext, EvaluatedTypeTerm, HostTypeRelationDecision, TypeInterpreterContext, TypeInterpreterDiagnostic, TypeInterpreterPath, TypeInterpreterRefResolution, TypeInterpreterResult, TypeInterpreterStatus, TypeTermRelationContext, TypeVariableConstraint, TypeVariableSolverContext, TypeVariableSolverInput, TypeVariableSolverIssue, TypeVariableSolverResult, checkTypeTermRelation, checkTypeTermRelationAsync, evaluateExpression, evaluateExpressionAsync, evaluateSchemaTypeTerm, evaluateSchemaTypeTermAsync, solveTypeVariables, solveTypeVariablesAsync };
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { a as
|
|
1
|
+
import { a as evaluateSchemaTypeTerm, c as checkTypeTermRelationAsync, i as evaluateExpressionAsync, n as solveTypeVariablesAsync, o as evaluateSchemaTypeTermAsync, r as evaluateExpression, s as checkTypeTermRelation, t as solveTypeVariables } from "../type-interpreter-DnrId8aM.js";
|
|
2
2
|
|
|
3
|
-
export { checkTypeTermRelation, checkTypeTermRelationAsync, evaluateExpression, evaluateExpressionAsync,
|
|
3
|
+
export { checkTypeTermRelation, checkTypeTermRelationAsync, evaluateExpression, evaluateExpressionAsync, evaluateSchemaTypeTerm, evaluateSchemaTypeTermAsync, solveTypeVariables, solveTypeVariablesAsync };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { a as expressionShapeIssue, f as validateSchemaNodeDefinition, i as expressionKinds, r as expressionFields } from "./definition-DmYnDmQO.js";
|
|
2
|
+
import { a as checkSchemaRelation, o as checkSchemaRelationAsync } from "./relations-ysXDmi-Z.js";
|
|
3
3
|
|
|
4
4
|
//#region src/type-interpreter/materializer.ts
|
|
5
5
|
function isRecord(value) {
|
|
@@ -1087,201 +1087,6 @@ async function checkTypeTermRelationAsync(source, target, context = {}) {
|
|
|
1087
1087
|
|
|
1088
1088
|
//#endregion
|
|
1089
1089
|
//#region src/type-interpreter/interpreter.ts
|
|
1090
|
-
const expressionKinds = new Set([
|
|
1091
|
-
"typeVar",
|
|
1092
|
-
"opaqueHostType",
|
|
1093
|
-
"absent",
|
|
1094
|
-
"never",
|
|
1095
|
-
"unknown",
|
|
1096
|
-
"maybeAbsent",
|
|
1097
|
-
"arrayOf",
|
|
1098
|
-
"tupleOf",
|
|
1099
|
-
"recordOf",
|
|
1100
|
-
"elementOf",
|
|
1101
|
-
"valueOf",
|
|
1102
|
-
"elementAt",
|
|
1103
|
-
"fieldOf",
|
|
1104
|
-
"keyOf",
|
|
1105
|
-
"fieldsOf",
|
|
1106
|
-
"pickFields",
|
|
1107
|
-
"omitFields",
|
|
1108
|
-
"partialFields",
|
|
1109
|
-
"requiredFields",
|
|
1110
|
-
"mergeRecords",
|
|
1111
|
-
"nullableOf",
|
|
1112
|
-
"taggedUnionOf",
|
|
1113
|
-
"intersect",
|
|
1114
|
-
"refine",
|
|
1115
|
-
"excludeVariants",
|
|
1116
|
-
"extractVariants"
|
|
1117
|
-
]);
|
|
1118
|
-
const expressionFields = {
|
|
1119
|
-
typeVar: {
|
|
1120
|
-
required: ["name"],
|
|
1121
|
-
allowed: [
|
|
1122
|
-
"kind",
|
|
1123
|
-
"name",
|
|
1124
|
-
"extends"
|
|
1125
|
-
]
|
|
1126
|
-
},
|
|
1127
|
-
opaqueHostType: {
|
|
1128
|
-
required: ["hostPath"],
|
|
1129
|
-
allowed: ["kind", "hostPath"]
|
|
1130
|
-
},
|
|
1131
|
-
absent: {
|
|
1132
|
-
required: [],
|
|
1133
|
-
allowed: ["kind"]
|
|
1134
|
-
},
|
|
1135
|
-
never: {
|
|
1136
|
-
required: [],
|
|
1137
|
-
allowed: ["kind"]
|
|
1138
|
-
},
|
|
1139
|
-
unknown: {
|
|
1140
|
-
required: [],
|
|
1141
|
-
allowed: ["kind"]
|
|
1142
|
-
},
|
|
1143
|
-
maybeAbsent: {
|
|
1144
|
-
required: ["value"],
|
|
1145
|
-
allowed: ["kind", "value"]
|
|
1146
|
-
},
|
|
1147
|
-
arrayOf: {
|
|
1148
|
-
required: ["element"],
|
|
1149
|
-
allowed: [
|
|
1150
|
-
"kind",
|
|
1151
|
-
"element",
|
|
1152
|
-
"constraints"
|
|
1153
|
-
]
|
|
1154
|
-
},
|
|
1155
|
-
tupleOf: {
|
|
1156
|
-
required: ["elements"],
|
|
1157
|
-
allowed: ["kind", "elements"]
|
|
1158
|
-
},
|
|
1159
|
-
recordOf: {
|
|
1160
|
-
required: ["fields"],
|
|
1161
|
-
allowed: [
|
|
1162
|
-
"kind",
|
|
1163
|
-
"fields",
|
|
1164
|
-
"additionalFields",
|
|
1165
|
-
"constraints"
|
|
1166
|
-
]
|
|
1167
|
-
},
|
|
1168
|
-
nullableOf: {
|
|
1169
|
-
required: ["value"],
|
|
1170
|
-
allowed: ["kind", "value"]
|
|
1171
|
-
},
|
|
1172
|
-
taggedUnionOf: {
|
|
1173
|
-
required: ["discriminator", "variants"],
|
|
1174
|
-
allowed: [
|
|
1175
|
-
"kind",
|
|
1176
|
-
"discriminator",
|
|
1177
|
-
"variants"
|
|
1178
|
-
]
|
|
1179
|
-
},
|
|
1180
|
-
elementOf: {
|
|
1181
|
-
required: ["source"],
|
|
1182
|
-
allowed: ["kind", "source"]
|
|
1183
|
-
},
|
|
1184
|
-
valueOf: {
|
|
1185
|
-
required: ["source"],
|
|
1186
|
-
allowed: ["kind", "source"]
|
|
1187
|
-
},
|
|
1188
|
-
elementAt: {
|
|
1189
|
-
required: ["source", "index"],
|
|
1190
|
-
allowed: [
|
|
1191
|
-
"kind",
|
|
1192
|
-
"source",
|
|
1193
|
-
"index"
|
|
1194
|
-
]
|
|
1195
|
-
},
|
|
1196
|
-
fieldOf: {
|
|
1197
|
-
required: ["source", "key"],
|
|
1198
|
-
allowed: [
|
|
1199
|
-
"kind",
|
|
1200
|
-
"source",
|
|
1201
|
-
"key"
|
|
1202
|
-
]
|
|
1203
|
-
},
|
|
1204
|
-
keyOf: {
|
|
1205
|
-
required: ["source"],
|
|
1206
|
-
allowed: ["kind", "source"]
|
|
1207
|
-
},
|
|
1208
|
-
fieldsOf: {
|
|
1209
|
-
required: ["source", "fields"],
|
|
1210
|
-
allowed: [
|
|
1211
|
-
"kind",
|
|
1212
|
-
"source",
|
|
1213
|
-
"fields"
|
|
1214
|
-
]
|
|
1215
|
-
},
|
|
1216
|
-
pickFields: {
|
|
1217
|
-
required: ["source", "fields"],
|
|
1218
|
-
allowed: [
|
|
1219
|
-
"kind",
|
|
1220
|
-
"source",
|
|
1221
|
-
"fields"
|
|
1222
|
-
]
|
|
1223
|
-
},
|
|
1224
|
-
omitFields: {
|
|
1225
|
-
required: ["source", "fields"],
|
|
1226
|
-
allowed: [
|
|
1227
|
-
"kind",
|
|
1228
|
-
"source",
|
|
1229
|
-
"fields"
|
|
1230
|
-
]
|
|
1231
|
-
},
|
|
1232
|
-
partialFields: {
|
|
1233
|
-
required: ["source", "fields"],
|
|
1234
|
-
allowed: [
|
|
1235
|
-
"kind",
|
|
1236
|
-
"source",
|
|
1237
|
-
"fields"
|
|
1238
|
-
]
|
|
1239
|
-
},
|
|
1240
|
-
requiredFields: {
|
|
1241
|
-
required: ["source", "fields"],
|
|
1242
|
-
allowed: [
|
|
1243
|
-
"kind",
|
|
1244
|
-
"source",
|
|
1245
|
-
"fields"
|
|
1246
|
-
]
|
|
1247
|
-
},
|
|
1248
|
-
mergeRecords: {
|
|
1249
|
-
required: ["sources", "conflict"],
|
|
1250
|
-
allowed: [
|
|
1251
|
-
"kind",
|
|
1252
|
-
"sources",
|
|
1253
|
-
"conflict"
|
|
1254
|
-
]
|
|
1255
|
-
},
|
|
1256
|
-
intersect: {
|
|
1257
|
-
required: ["sources"],
|
|
1258
|
-
allowed: ["kind", "sources"]
|
|
1259
|
-
},
|
|
1260
|
-
refine: {
|
|
1261
|
-
required: ["source", "fields"],
|
|
1262
|
-
allowed: [
|
|
1263
|
-
"kind",
|
|
1264
|
-
"source",
|
|
1265
|
-
"fields"
|
|
1266
|
-
]
|
|
1267
|
-
},
|
|
1268
|
-
excludeVariants: {
|
|
1269
|
-
required: ["source", "variants"],
|
|
1270
|
-
allowed: [
|
|
1271
|
-
"kind",
|
|
1272
|
-
"source",
|
|
1273
|
-
"variants"
|
|
1274
|
-
]
|
|
1275
|
-
},
|
|
1276
|
-
extractVariants: {
|
|
1277
|
-
required: ["source", "variants"],
|
|
1278
|
-
allowed: [
|
|
1279
|
-
"kind",
|
|
1280
|
-
"source",
|
|
1281
|
-
"variants"
|
|
1282
|
-
]
|
|
1283
|
-
}
|
|
1284
|
-
};
|
|
1285
1090
|
function isObject(value) {
|
|
1286
1091
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
1287
1092
|
}
|
|
@@ -1341,90 +1146,6 @@ function childTerms(expression) {
|
|
|
1341
1146
|
});
|
|
1342
1147
|
return children;
|
|
1343
1148
|
}
|
|
1344
|
-
function hasOnlyKeys(value, keys) {
|
|
1345
|
-
return Object.keys(value).every((key) => keys.includes(key));
|
|
1346
|
-
}
|
|
1347
|
-
function isSelector(value) {
|
|
1348
|
-
if (!isObject(value)) return false;
|
|
1349
|
-
if (value.kind === "all") return hasOnlyKeys(value, ["kind"]);
|
|
1350
|
-
return value.kind === "keys" && hasOnlyKeys(value, [
|
|
1351
|
-
"kind",
|
|
1352
|
-
"keys",
|
|
1353
|
-
"onMissing"
|
|
1354
|
-
]) && Array.isArray(value.keys) && value.keys.every((key) => typeof key === "string") && new Set(value.keys).size === value.keys.length && (value.onMissing === "error" || value.onMissing === "ignore");
|
|
1355
|
-
}
|
|
1356
|
-
function expressionShapeIssue(expression) {
|
|
1357
|
-
const kind = expression.kind;
|
|
1358
|
-
if (kind === "typeVar" && (typeof expression.name !== "string" || !expression.name.trim())) return "typeVar name must be non-blank";
|
|
1359
|
-
if (kind === "opaqueHostType" && (!Array.isArray(expression.hostPath) || expression.hostPath.length === 0 || expression.hostPath.some((part) => typeof part !== "string" || !part.trim()))) return "hostPath must be a non-empty path";
|
|
1360
|
-
if (kind === "tupleOf" && (!Array.isArray(expression.elements) || !isDense(expression.elements))) return "elements must be a dense array";
|
|
1361
|
-
if (kind === "recordOf") {
|
|
1362
|
-
if (!Array.isArray(expression.fields) || !isDense(expression.fields)) return "fields must be a dense array";
|
|
1363
|
-
const keys = /* @__PURE__ */ new Set();
|
|
1364
|
-
for (const field of expression.fields) {
|
|
1365
|
-
if (!isObject(field) || !hasOnlyKeys(field, [
|
|
1366
|
-
"key",
|
|
1367
|
-
"value",
|
|
1368
|
-
"required",
|
|
1369
|
-
"description"
|
|
1370
|
-
]) || typeof field.key !== "string" || keys.has(field.key)) return "record fields must have unique keys and a valid shape";
|
|
1371
|
-
if (field.required !== void 0 && typeof field.required !== "boolean") return "record field required must be a boolean";
|
|
1372
|
-
if (field.description !== void 0 && typeof field.description !== "string") return "record field description must be a string";
|
|
1373
|
-
keys.add(field.key);
|
|
1374
|
-
}
|
|
1375
|
-
if (expression.additionalFields !== void 0 && expression.additionalFields !== true && !isObject(expression.additionalFields)) return "additionalFields must be a type term or true";
|
|
1376
|
-
if (expression.constraints !== void 0 && (!Array.isArray(expression.constraints) || !isDense(expression.constraints))) return "constraints must be a dense array";
|
|
1377
|
-
}
|
|
1378
|
-
if (kind === "arrayOf" && expression.constraints !== void 0 && (!Array.isArray(expression.constraints) || !isDense(expression.constraints))) return "constraints must be a dense array";
|
|
1379
|
-
if (kind === "taggedUnionOf") {
|
|
1380
|
-
if (typeof expression.discriminator !== "string" || !expression.discriminator.trim() || !Array.isArray(expression.variants) || !isDense(expression.variants) || expression.variants.length < 2) return "taggedUnionOf requires a discriminator and at least two dense variants";
|
|
1381
|
-
const keys = /* @__PURE__ */ new Set();
|
|
1382
|
-
for (const variant of expression.variants) {
|
|
1383
|
-
if (!isObject(variant) || !hasOnlyKeys(variant, [
|
|
1384
|
-
"key",
|
|
1385
|
-
"value",
|
|
1386
|
-
"description"
|
|
1387
|
-
]) || typeof variant.key !== "string" || !variant.key.trim() || keys.has(variant.key)) return "taggedUnionOf variants must have unique non-blank keys and a valid shape";
|
|
1388
|
-
if (variant.description !== void 0 && typeof variant.description !== "string") return "variant description must be a string";
|
|
1389
|
-
keys.add(variant.key);
|
|
1390
|
-
}
|
|
1391
|
-
}
|
|
1392
|
-
if ([
|
|
1393
|
-
"fieldsOf",
|
|
1394
|
-
"pickFields",
|
|
1395
|
-
"omitFields",
|
|
1396
|
-
"partialFields",
|
|
1397
|
-
"requiredFields"
|
|
1398
|
-
].includes(String(kind)) && !isSelector(expression.fields)) return "fields must be a valid field selector";
|
|
1399
|
-
if ((kind === "excludeVariants" || kind === "extractVariants") && !isSelector(expression.variants)) return "variants must be a valid variant selector";
|
|
1400
|
-
if (kind === "elementAt" && (!Number.isSafeInteger(expression.index) || expression.index < 0)) return "index must be a non-negative safe integer";
|
|
1401
|
-
if (kind === "fieldOf" && typeof expression.key !== "string") return "key must be a string";
|
|
1402
|
-
if (kind === "mergeRecords" && (!Array.isArray(expression.sources) || !isDense(expression.sources) || expression.sources.length < 2 || ![
|
|
1403
|
-
"leftWins",
|
|
1404
|
-
"rightWins",
|
|
1405
|
-
"error"
|
|
1406
|
-
].includes(String(expression.conflict)))) return "mergeRecords requires at least two dense sources and a valid conflict policy";
|
|
1407
|
-
if (kind === "intersect" && (!Array.isArray(expression.sources) || !isDense(expression.sources) || expression.sources.length < 2)) return "intersect requires at least two dense sources";
|
|
1408
|
-
if (kind === "refine") {
|
|
1409
|
-
if (!Array.isArray(expression.fields) || !isDense(expression.fields) || expression.fields.length === 0) return "refine requires non-empty dense field actions";
|
|
1410
|
-
const keys = /* @__PURE__ */ new Set();
|
|
1411
|
-
for (const action of expression.fields) {
|
|
1412
|
-
if (!isObject(action) || !hasOnlyKeys(action, [
|
|
1413
|
-
"key",
|
|
1414
|
-
"require",
|
|
1415
|
-
"intersectWith",
|
|
1416
|
-
"addConstraints"
|
|
1417
|
-
]) || typeof action.key !== "string" || keys.has(action.key)) return "refine actions must have unique keys and a valid shape";
|
|
1418
|
-
if (action.require !== void 0 && action.require !== true) return "refine require must be true when specified";
|
|
1419
|
-
if (action.addConstraints !== void 0 && (!Array.isArray(action.addConstraints) || !isDense(action.addConstraints))) return "addConstraints must be a dense array";
|
|
1420
|
-
keys.add(action.key);
|
|
1421
|
-
}
|
|
1422
|
-
}
|
|
1423
|
-
}
|
|
1424
|
-
function isDense(value) {
|
|
1425
|
-
for (let index = 0; index < value.length; index += 1) if (!Object.prototype.hasOwnProperty.call(value, index)) return false;
|
|
1426
|
-
return true;
|
|
1427
|
-
}
|
|
1428
1149
|
function replaceChild(expression, path, value) {
|
|
1429
1150
|
const [key, indexText, subkey] = path.split(".");
|
|
1430
1151
|
if (indexText === void 0) {
|
|
@@ -1760,8 +1481,8 @@ async function evaluateExpressionAsync(term, context = {}) {
|
|
|
1760
1481
|
maxSteps: Number.MAX_SAFE_INTEGER
|
|
1761
1482
|
});
|
|
1762
1483
|
}
|
|
1763
|
-
const
|
|
1764
|
-
const
|
|
1484
|
+
const evaluateSchemaTypeTerm = evaluateExpression;
|
|
1485
|
+
const evaluateSchemaTypeTermAsync = evaluateExpressionAsync;
|
|
1765
1486
|
|
|
1766
1487
|
//#endregion
|
|
1767
1488
|
//#region src/type-interpreter/type-variable-solver.ts
|
|
@@ -1932,4 +1653,4 @@ async function solveTypeVariablesAsync(input, context = {}) {
|
|
|
1932
1653
|
}
|
|
1933
1654
|
|
|
1934
1655
|
//#endregion
|
|
1935
|
-
export {
|
|
1656
|
+
export { evaluateSchemaTypeTerm as a, checkTypeTermRelationAsync as c, evaluateExpressionAsync as i, solveTypeVariablesAsync as n, evaluateSchemaTypeTermAsync as o, evaluateExpression as r, checkTypeTermRelation as s, solveTypeVariables as t };
|