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
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { $ as
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import { a as
|
|
6
|
-
import {
|
|
7
|
-
export {
|
|
1
|
+
import { $ as StructuredOperationPayloadDefinition, A as SchemaTypeOpaqueHostExpr, B as SchemaTypeValueOfExpr, C as SchemaTypeIntersectExpr, D as SchemaTypeNeverExpr, E as SchemaTypeMergeRecordsExpr, F as SchemaTypeRequiredFieldsExpr, G as OperationChannelDefinition, H as SchemaVariantSelector, I as SchemaTypeTaggedUnionExpr, J as OperationErrorDefinition, K as OperationContainerDefinition, L as SchemaTypeTerm, M as SchemaTypePickFieldsExpr, N as SchemaTypeRecordExpr, O as SchemaTypeNullableExpr, P as SchemaTypeRefineExpr, Q as StructuredOperationDefinition, R as SchemaTypeTupleExpr, S as SchemaTypeFieldsOfExpr, T as SchemaTypeMaybeAbsentExpr, U as Operation, V as SchemaTypeVariableExpr, W as OperationBinaryMetadata, X as StructuredOperationChannelDefinition, Y as OperationPayloadDefinition, Z as StructuredOperationContainerDefinition, _ as SchemaTypeElementOfExpr, _t as SchemaStringNode, a as StandardSemanticDefinition, at as SchemaConstraint, b as SchemaTypeExtractVariantsExpr, bt as SchemaTupleNode, c as STANDARD_CONSTRAINT_PATH_LIST, ct as SchemaNode, d as Expression, dt as SchemaNumberNode, et as JsonValue, f as ExpressionArgument, ft as SchemaPrimitiveNode, g as SchemaTypeElementAtExpr, gt as SchemaSelfRefNode, h as SchemaTypeArrayExpr, ht as SchemaRefNode, i as StandardConstraintDefinition, it as SchemaBooleanNode, j as SchemaTypePartialFieldsExpr, k as SchemaTypeOmitFieldsExpr, l as STANDARD_SEMANTIC_PATHS, lt as SchemaNullNode, m as SchemaTypeAbsentExpr, mt as SchemaRecordNode, n as STANDARD_SEMANTIC_DEFINITIONS, nt as PrimitiveName, o as StandardSemanticRelation, ot as SchemaLiteralNode, p as SchemaFieldSelector, pt as SchemaRecordField, q as OperationDefinition, r as STANDARD_SEMANTIC_RELATIONS, rt as SchemaArrayNode, s as STANDARD_CONSTRAINT_PATHS, st as SchemaLiteralUnionNode, t as STANDARD_CONSTRAINT_DEFINITIONS, tt as LiteralValue, u as STANDARD_SEMANTIC_PATH_LIST, ut as SchemaNullableNode, v as SchemaTypeExcludeVariantsExpr, vt as SchemaTaggedUnionNode, w as SchemaTypeKeyOfExpr, x as SchemaTypeFieldOfExpr, y as SchemaTypeExpr, yt as SchemaTaggedUnionVariant, z as SchemaTypeUnknownExpr } from "./index-4aMF0cTE.js";
|
|
2
|
+
import { _ as validateStructuredOperationDefinition, a as validateSchemaTypeTermDefinition, b as SchemaNodeDefinitionValidationResult, c as OperationDefinitionPath, d as StructuredOperationDefinitionValidationResult, f as isStructuredOperationContainerDefinition, g as validateStructuredOperationContainerDefinition, h as validateOperationDefinition, i as validateSchemaTypeExprDefinition, l as OperationDefinitionValidationResult, m as validateOperationContainerDefinition, n as SchemaTypeExprDefinitionValidationResult, o as OperationContainerDefinitionValidationResult, p as isStructuredOperationDefinition, r as SchemaTypeTermDefinitionValidationResult, s as OperationDefinitionDiagnostic, t as SchemaTypeDefinitionDiagnostic, u as StructuredOperationContainerDefinitionValidationResult, v as SchemaNodeDefinitionDiagnostic, x as validateSchemaNodeDefinition, y as SchemaNodeDefinitionPath } from "./index-DXWoNYFB.js";
|
|
3
|
+
import { _ as validatePayloadAsync, a as PayloadProviderDecision, c as PayloadValidationContext, d as SemanticProvider, f as SyncConstraintProvider, g as validatePayload, h as SyncSemanticProvider, i as PayloadProviderContext, l as PayloadValidationDiagnostic, m as SyncPayloadValidationContext, n as ConstraintProvider, o as PayloadResolution, p as SyncPayloadResolution, r as PayloadPath, s as PayloadResolutionContext, t as AsyncPayloadValidationContext, u as PayloadValidationResult } from "./index-BqfGAU1K.js";
|
|
4
|
+
import { _ as checkSchemaAssignabilityAsync, a as AsyncRelationContext, c as RelationPath, d as RelationResolution, f as RelationResolutionContext, g as checkSchemaAssignability, h as RelationStatus, i as checkOperationRelationAsync, l as RelationProviderContext, m as RelationSide, n as OperationRelationDirection, o as RelationContext, p as RelationResult, r as checkOperationRelation, s as RelationDiagnostic, t as OperationRelationComponent, u as RelationProviderDecision, v as checkSchemaRelation, y as checkSchemaRelationAsync } from "./index-CBbd4hXJ.js";
|
|
5
|
+
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";
|
|
6
|
+
import { $ as isExtensionSemanticPath, A as BuildStandardConstraintProfileOptions, B as ExactRationalFailureReason, C as standardSchemaSatisfiability, D as standardPayloadContext, E as standardConstraintTarget, F as StandardConstraintSatisfiability, G as greatestCommonDivisorRationals, H as exactRationalFromFiniteNumber, I as buildStandardConstraintProfile, J as STANDARD_CONSTRAINT_DEFINITION_MAP, K as leastCommonMultipleRationals, L as isStandardConstraintOwner, M as StandardConstraintInterval, N as StandardConstraintOwner, O as standardSemanticProvider, P as StandardConstraintProfile, Q as classifySemanticPath, R as DEFAULT_EXACT_RATIONAL_MAX_BITS, S as refineStandardSchema, T as standardConstraintRegistry, U as exactRationalIsIntegerMultiple, V as ExactRationalResult, W as formatExactRational, X as StandardSemanticResolution, Y as STANDARD_SEMANTIC_DEFINITION_MAP, Z as StandardVocabularyRegistry, _ as createStandardRelationContext, a as InferOperationOutput, b as StandardSchemaOperationResult, c as expression_d_exports, d as InferFailureReason, et as isStandardSemanticNamespace, f as InferRef, g as StandardProviderContext, h as StaticSchemaRegistryEntry, i as InferOperationInput, j as StandardConstraintBound, k as standardSemanticRegistry, l as schema_d_exports, m as StaticSchemaRegistry, n as InferOperationEmits, nt as standardVocabularyRegistry, o as InferOperationPayload, p as InferResult, q as ClassifiedSemanticPath, r as InferOperationErrors, s as OperationRegistry, t as InferOperation, tt as pathKey, u as Infer, v as standardRelationContext, w as standardConstraintProvider, x as intersectStandardSchemas, y as standardVocabularyProvider, z as ExactRational } from "./index-bQy-C-1l.js";
|
|
7
|
+
export { AsyncPayloadValidationContext, AsyncRelationContext, AsyncTypeInterpreterContext, AsyncTypeInterpreterRefResolution, AsyncTypeTermRelationContext, AsyncTypeVariableSolverContext, BuildStandardConstraintProfileOptions, ClassifiedSemanticPath, ConstraintProvider, DEFAULT_EXACT_RATIONAL_MAX_BITS, EvaluatedTypeTerm, ExactRational, ExactRationalFailureReason, ExactRationalResult, Expression, ExpressionArgument, HostTypeRelationDecision, Infer, InferFailureReason, InferOperation, InferOperationEmits, InferOperationErrors, InferOperationInput, InferOperationOutput, InferOperationPayload, InferRef, InferResult, JsonValue, LiteralValue, Operation, OperationBinaryMetadata, OperationChannelDefinition, OperationContainerDefinition, OperationContainerDefinitionValidationResult, OperationDefinition, OperationDefinitionDiagnostic, OperationDefinitionPath, OperationDefinitionValidationResult, OperationErrorDefinition, OperationPayloadDefinition, OperationRegistry, OperationRelationComponent, OperationRelationDirection, PayloadPath, PayloadProviderContext, PayloadProviderDecision, PayloadResolution, PayloadResolutionContext, PayloadValidationContext, PayloadValidationDiagnostic, PayloadValidationResult, PrimitiveName, RelationContext, RelationDiagnostic, RelationPath, RelationProviderContext, RelationProviderDecision, RelationResolution, RelationResolutionContext, RelationResult, RelationSide, RelationStatus, STANDARD_CONSTRAINT_DEFINITIONS, STANDARD_CONSTRAINT_DEFINITION_MAP, STANDARD_CONSTRAINT_PATHS, STANDARD_CONSTRAINT_PATH_LIST, STANDARD_SEMANTIC_DEFINITIONS, STANDARD_SEMANTIC_DEFINITION_MAP, STANDARD_SEMANTIC_PATHS, STANDARD_SEMANTIC_PATH_LIST, STANDARD_SEMANTIC_RELATIONS, SchemaArrayNode, SchemaBooleanNode, SchemaConstraint, SchemaFieldSelector, SchemaLiteralNode, SchemaLiteralUnionNode, SchemaNode, SchemaNodeDefinitionDiagnostic, SchemaNodeDefinitionPath, SchemaNodeDefinitionValidationResult, SchemaNullNode, SchemaNullableNode, SchemaNumberNode, SchemaPrimitiveNode, SchemaRecordField, SchemaRecordNode, SchemaRefNode, SchemaSelfRefNode, SchemaStringNode, SchemaTaggedUnionNode, SchemaTaggedUnionVariant, SchemaTupleNode, SchemaTypeAbsentExpr, SchemaTypeArrayExpr, SchemaTypeDefinitionDiagnostic, SchemaTypeElementAtExpr, SchemaTypeElementOfExpr, SchemaTypeExcludeVariantsExpr, SchemaTypeExpr, SchemaTypeExprDefinitionValidationResult, SchemaTypeExtractVariantsExpr, SchemaTypeFieldOfExpr, SchemaTypeFieldsOfExpr, SchemaTypeIntersectExpr, SchemaTypeKeyOfExpr, SchemaTypeMaybeAbsentExpr, SchemaTypeMergeRecordsExpr, SchemaTypeNeverExpr, SchemaTypeNullableExpr, SchemaTypeOmitFieldsExpr, SchemaTypeOpaqueHostExpr, SchemaTypePartialFieldsExpr, SchemaTypePickFieldsExpr, SchemaTypeRecordExpr, SchemaTypeRefineExpr, SchemaTypeRequiredFieldsExpr, SchemaTypeTaggedUnionExpr, SchemaTypeTerm, SchemaTypeTermDefinitionValidationResult, SchemaTypeTupleExpr, SchemaTypeUnknownExpr, SchemaTypeValueOfExpr, SchemaTypeVariableExpr, SchemaVariantSelector, SemanticProvider, StandardConstraintBound, StandardConstraintDefinition, StandardConstraintInterval, StandardConstraintOwner, StandardConstraintProfile, StandardConstraintSatisfiability, StandardProviderContext, StandardSchemaOperationResult, StandardSemanticDefinition, StandardSemanticRelation, StandardSemanticResolution, StandardVocabularyRegistry, StaticSchemaRegistry, StaticSchemaRegistryEntry, StructuredOperationChannelDefinition, StructuredOperationContainerDefinition, StructuredOperationContainerDefinitionValidationResult, StructuredOperationDefinition, StructuredOperationDefinitionValidationResult, StructuredOperationPayloadDefinition, SyncConstraintProvider, SyncPayloadResolution, SyncPayloadValidationContext, SyncSemanticProvider, TypeInterpreterContext, TypeInterpreterDiagnostic, TypeInterpreterPath, TypeInterpreterRefResolution, TypeInterpreterResult, TypeInterpreterStatus, TypeTermRelationContext, TypeVariableConstraint, TypeVariableSolverContext, TypeVariableSolverInput, TypeVariableSolverIssue, TypeVariableSolverResult, buildStandardConstraintProfile, checkOperationRelation, checkOperationRelationAsync, checkSchemaAssignability, checkSchemaAssignabilityAsync, checkSchemaRelation, checkSchemaRelationAsync, checkTypeTermRelation, checkTypeTermRelationAsync, classifySemanticPath, createStandardRelationContext, evaluateExpression, evaluateExpressionAsync, evaluateSchemaTypeTerm, evaluateSchemaTypeTermAsync, exactRationalFromFiniteNumber, exactRationalIsIntegerMultiple, expression_d_exports as expression, formatExactRational, greatestCommonDivisorRationals, intersectStandardSchemas, isExtensionSemanticPath, isStandardConstraintOwner, isStandardSemanticNamespace, isStructuredOperationContainerDefinition, isStructuredOperationDefinition, leastCommonMultipleRationals, pathKey, refineStandardSchema, schema_d_exports as schema, solveTypeVariables, solveTypeVariablesAsync, standardConstraintProvider, standardConstraintRegistry, standardConstraintTarget, standardPayloadContext, standardRelationContext, standardSchemaSatisfiability, standardSemanticProvider, standardSemanticRegistry, standardVocabularyProvider, standardVocabularyRegistry, validateOperationContainerDefinition, validateOperationDefinition, validatePayload, validatePayloadAsync, validateSchemaNodeDefinition, validateSchemaTypeExprDefinition, validateSchemaTypeTermDefinition, validateStructuredOperationContainerDefinition, validateStructuredOperationDefinition };
|
package/dist/index.js
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
|
+
import { a as STANDARD_CONSTRAINT_PATH_LIST, i as STANDARD_CONSTRAINT_PATHS, n as STANDARD_SEMANTIC_DEFINITIONS, o as STANDARD_SEMANTIC_PATHS, r as STANDARD_SEMANTIC_RELATIONS, s as STANDARD_SEMANTIC_PATH_LIST, t as STANDARD_CONSTRAINT_DEFINITIONS } from "./standard-DhKsxu9U.js";
|
|
1
2
|
import "./spec/index.js";
|
|
2
|
-
import {
|
|
3
|
+
import { c as validateOperationContainerDefinition, d as validateStructuredOperationDefinition, f as validateSchemaNodeDefinition, l as validateOperationDefinition, n as validateSchemaTypeTermDefinition, o as isStructuredOperationContainerDefinition, s as isStructuredOperationDefinition, t as validateSchemaTypeExprDefinition, u as validateStructuredOperationContainerDefinition } from "./definition-DmYnDmQO.js";
|
|
3
4
|
import { validatePayload, validatePayloadAsync } from "./payload/index.js";
|
|
4
|
-
import { i as
|
|
5
|
-
import { a as
|
|
6
|
-
import {
|
|
5
|
+
import { a as checkSchemaRelation, i as checkSchemaAssignabilityAsync, n as checkOperationRelationAsync, o as checkSchemaRelationAsync, r as checkSchemaAssignability, t as checkOperationRelation } from "./relations-ysXDmi-Z.js";
|
|
6
|
+
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";
|
|
7
|
+
import { n as schema_exports, t as expression_exports } from "./authoring-D3V0iyTe.js";
|
|
8
|
+
import { DEFAULT_EXACT_RATIONAL_MAX_BITS, STANDARD_CONSTRAINT_DEFINITION_MAP, STANDARD_SEMANTIC_DEFINITION_MAP, buildStandardConstraintProfile, classifySemanticPath, createStandardRelationContext, exactRationalFromFiniteNumber, exactRationalIsIntegerMultiple, formatExactRational, greatestCommonDivisorRationals, intersectStandardSchemas, isExtensionSemanticPath, isStandardConstraintOwner, isStandardSemanticNamespace, leastCommonMultipleRationals, pathKey, refineStandardSchema, standardConstraintProvider, standardConstraintRegistry, standardConstraintTarget, standardPayloadContext, standardRelationContext, standardSchemaSatisfiability, standardSemanticProvider, standardSemanticRegistry, standardVocabularyProvider, standardVocabularyRegistry } from "./standard/index.js";
|
|
7
9
|
|
|
8
|
-
export {
|
|
10
|
+
export { DEFAULT_EXACT_RATIONAL_MAX_BITS, STANDARD_CONSTRAINT_DEFINITIONS, STANDARD_CONSTRAINT_DEFINITION_MAP, STANDARD_CONSTRAINT_PATHS, STANDARD_CONSTRAINT_PATH_LIST, STANDARD_SEMANTIC_DEFINITIONS, STANDARD_SEMANTIC_DEFINITION_MAP, STANDARD_SEMANTIC_PATHS, STANDARD_SEMANTIC_PATH_LIST, STANDARD_SEMANTIC_RELATIONS, buildStandardConstraintProfile, checkOperationRelation, checkOperationRelationAsync, checkSchemaAssignability, checkSchemaAssignabilityAsync, checkSchemaRelation, checkSchemaRelationAsync, checkTypeTermRelation, checkTypeTermRelationAsync, classifySemanticPath, createStandardRelationContext, evaluateExpression, evaluateExpressionAsync, evaluateSchemaTypeTerm, evaluateSchemaTypeTermAsync, exactRationalFromFiniteNumber, exactRationalIsIntegerMultiple, expression_exports as expression, formatExactRational, greatestCommonDivisorRationals, intersectStandardSchemas, isExtensionSemanticPath, isStandardConstraintOwner, isStandardSemanticNamespace, isStructuredOperationContainerDefinition, isStructuredOperationDefinition, leastCommonMultipleRationals, pathKey, refineStandardSchema, schema_exports as schema, solveTypeVariables, solveTypeVariablesAsync, standardConstraintProvider, standardConstraintRegistry, standardConstraintTarget, standardPayloadContext, standardRelationContext, standardSchemaSatisfiability, standardSemanticProvider, standardSemanticRegistry, standardVocabularyProvider, standardVocabularyRegistry, validateOperationContainerDefinition, validateOperationDefinition, validatePayload, validatePayloadAsync, validateSchemaNodeDefinition, validateSchemaTypeExprDefinition, validateSchemaTypeTermDefinition, validateStructuredOperationContainerDefinition, validateStructuredOperationDefinition };
|
|
@@ -0,0 +1,328 @@
|
|
|
1
|
+
const require_standard = require('../../standard-etPFZDJI.cjs');
|
|
2
|
+
const require_standard_index = require('../../standard/index.cjs');
|
|
3
|
+
|
|
4
|
+
//#region src/integrations/json-schema/index.ts
|
|
5
|
+
function diagnostic(context, code, message, path, severity = "warning") {
|
|
6
|
+
context.diagnostics.push({
|
|
7
|
+
code,
|
|
8
|
+
message,
|
|
9
|
+
path,
|
|
10
|
+
severity
|
|
11
|
+
});
|
|
12
|
+
}
|
|
13
|
+
function mergeKeyword(target, source) {
|
|
14
|
+
if (source) Object.assign(target, source);
|
|
15
|
+
}
|
|
16
|
+
function extension(target, value) {
|
|
17
|
+
const existing = target["x-schemair"];
|
|
18
|
+
target["x-schemair"] = {
|
|
19
|
+
...existing && typeof existing === "object" && !Array.isArray(existing) ? existing : {},
|
|
20
|
+
...value,
|
|
21
|
+
version: 1
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
function standardSemantic(path, node) {
|
|
25
|
+
const key = require_standard_index.pathKey(path);
|
|
26
|
+
const stringFormats = {
|
|
27
|
+
[require_standard_index.pathKey(require_standard.STANDARD_SEMANTIC_PATHS.string.date)]: "date",
|
|
28
|
+
[require_standard_index.pathKey(require_standard.STANDARD_SEMANTIC_PATHS.string.datetime)]: "date-time",
|
|
29
|
+
[require_standard_index.pathKey(require_standard.STANDARD_SEMANTIC_PATHS.string.datetimeIso)]: "date-time",
|
|
30
|
+
[require_standard_index.pathKey(require_standard.STANDARD_SEMANTIC_PATHS.string.email)]: "email",
|
|
31
|
+
[require_standard_index.pathKey(require_standard.STANDARD_SEMANTIC_PATHS.string.url)]: "uri",
|
|
32
|
+
[require_standard_index.pathKey(require_standard.STANDARD_SEMANTIC_PATHS.string.ipV4)]: "ipv4",
|
|
33
|
+
[require_standard_index.pathKey(require_standard.STANDARD_SEMANTIC_PATHS.string.ipV6)]: "ipv6",
|
|
34
|
+
[require_standard_index.pathKey(require_standard.STANDARD_SEMANTIC_PATHS.string.uuid)]: "uuid",
|
|
35
|
+
[require_standard_index.pathKey(require_standard.STANDARD_SEMANTIC_PATHS.string.uuidV4)]: "uuid"
|
|
36
|
+
};
|
|
37
|
+
if (node.name === "string" && stringFormats[key]) return { format: stringFormats[key] };
|
|
38
|
+
if (node.name === "number" && key === require_standard_index.pathKey(require_standard.STANDARD_SEMANTIC_PATHS.number.integer)) return { type: "integer" };
|
|
39
|
+
if (node.name === "number" && key === require_standard_index.pathKey(require_standard.STANDARD_SEMANTIC_PATHS.number.safeInteger)) return {
|
|
40
|
+
type: "integer",
|
|
41
|
+
minimum: -9007199254740991,
|
|
42
|
+
maximum: 9007199254740991
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
function standardConstraint(constraint, target) {
|
|
46
|
+
const key = require_standard_index.pathKey(constraint.constraintPath);
|
|
47
|
+
const value = constraint.args;
|
|
48
|
+
switch (key) {
|
|
49
|
+
case require_standard_index.pathKey(require_standard.STANDARD_CONSTRAINT_PATHS.string.minLength): return typeof value === "number" ? { minLength: value } : void 0;
|
|
50
|
+
case require_standard_index.pathKey(require_standard.STANDARD_CONSTRAINT_PATHS.string.maxLength): return typeof value === "number" ? { maxLength: value } : void 0;
|
|
51
|
+
case require_standard_index.pathKey(require_standard.STANDARD_CONSTRAINT_PATHS.string.pattern): return typeof value === "string" ? { pattern: value } : void 0;
|
|
52
|
+
case require_standard_index.pathKey(require_standard.STANDARD_CONSTRAINT_PATHS.number.minimum): return typeof value === "number" ? { minimum: value } : void 0;
|
|
53
|
+
case require_standard_index.pathKey(require_standard.STANDARD_CONSTRAINT_PATHS.number.maximum): return typeof value === "number" ? { maximum: value } : void 0;
|
|
54
|
+
case require_standard_index.pathKey(require_standard.STANDARD_CONSTRAINT_PATHS.number.exclusiveMinimum): return typeof value === "number" ? target === "draft-2020-12" ? { exclusiveMinimum: value } : {
|
|
55
|
+
minimum: value,
|
|
56
|
+
exclusiveMinimum: true
|
|
57
|
+
} : void 0;
|
|
58
|
+
case require_standard_index.pathKey(require_standard.STANDARD_CONSTRAINT_PATHS.number.exclusiveMaximum): return typeof value === "number" ? target === "draft-2020-12" ? { exclusiveMaximum: value } : {
|
|
59
|
+
maximum: value,
|
|
60
|
+
exclusiveMaximum: true
|
|
61
|
+
} : void 0;
|
|
62
|
+
case require_standard_index.pathKey(require_standard.STANDARD_CONSTRAINT_PATHS.number.multipleOf): return typeof value === "number" ? { multipleOf: value } : void 0;
|
|
63
|
+
case require_standard_index.pathKey(require_standard.STANDARD_CONSTRAINT_PATHS.array.minItems): return typeof value === "number" ? { minItems: value } : void 0;
|
|
64
|
+
case require_standard_index.pathKey(require_standard.STANDARD_CONSTRAINT_PATHS.array.maxItems): return typeof value === "number" ? { maxItems: value } : void 0;
|
|
65
|
+
case require_standard_index.pathKey(require_standard.STANDARD_CONSTRAINT_PATHS.array.uniqueItems): return typeof value === "boolean" ? { uniqueItems: value } : void 0;
|
|
66
|
+
case require_standard_index.pathKey(require_standard.STANDARD_CONSTRAINT_PATHS.record.minProperties): return typeof value === "number" ? { minProperties: value } : void 0;
|
|
67
|
+
case require_standard_index.pathKey(require_standard.STANDARD_CONSTRAINT_PATHS.record.maxProperties): return typeof value === "number" ? { maxProperties: value } : void 0;
|
|
68
|
+
default: return;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
function applyMetadata(target, node, context, path) {
|
|
72
|
+
if ("semanticPath" in node && node.semanticPath) {
|
|
73
|
+
const custom = context.options.semanticMapper?.(node.semanticPath, node);
|
|
74
|
+
const mapped = custom ?? standardSemantic(node.semanticPath, node);
|
|
75
|
+
if (mapped) {
|
|
76
|
+
mergeKeyword(target, mapped);
|
|
77
|
+
extension(target, { semanticPath: node.semanticPath });
|
|
78
|
+
if (custom === void 0) diagnostic(context, "semantic.lossy", `Semantic path ${node.semanticPath.join("/")} is approximated by JSON Schema keywords`, path);
|
|
79
|
+
} else {
|
|
80
|
+
extension(target, { semanticPath: node.semanticPath });
|
|
81
|
+
diagnostic(context, "semantic.unmapped", `Semantic path ${node.semanticPath.join("/")} has no lossless JSON Schema mapping`, path);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
if ("constraints" in node && node.constraints) for (const constraint of node.constraints) {
|
|
85
|
+
const mapped = context.options.constraintMapper?.(constraint, node) ?? standardConstraint(constraint, context.target);
|
|
86
|
+
if (mapped) mergeKeyword(target, mapped);
|
|
87
|
+
else {
|
|
88
|
+
const prior = target["x-schemair"];
|
|
89
|
+
const meta = prior && typeof prior === "object" && !Array.isArray(prior) ? prior : {};
|
|
90
|
+
extension(target, { constraints: [...Array.isArray(meta.constraints) ? meta.constraints : [], {
|
|
91
|
+
constraintPath: [...constraint.constraintPath],
|
|
92
|
+
...constraint.args === void 0 ? {} : { args: constraint.args }
|
|
93
|
+
}] });
|
|
94
|
+
diagnostic(context, "constraint.unmapped", `Constraint ${constraint.constraintPath.join("/")} has no lossless JSON Schema mapping`, path);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
function project(node, context, path) {
|
|
99
|
+
if (context.stack.includes(node)) {
|
|
100
|
+
diagnostic(context, "schema.cycle", "Cyclic schema graph requires an explicit ref strategy", path, "error");
|
|
101
|
+
const cycle = {};
|
|
102
|
+
extension(cycle, { selfRef: true });
|
|
103
|
+
return cycle;
|
|
104
|
+
}
|
|
105
|
+
context.stack.push(node);
|
|
106
|
+
let result;
|
|
107
|
+
switch (node.kind) {
|
|
108
|
+
case "primitive":
|
|
109
|
+
if (context.target === "openapi-3.0" && node.name === "null") {
|
|
110
|
+
result = {};
|
|
111
|
+
extension(result, { original: {
|
|
112
|
+
kind: "primitive",
|
|
113
|
+
name: "null"
|
|
114
|
+
} });
|
|
115
|
+
diagnostic(context, "openapi.null.unsupported", "OpenAPI 3.0 Schema Objects cannot represent a standalone null type", path, "error");
|
|
116
|
+
} else result = { type: node.name === "null" ? "null" : node.name };
|
|
117
|
+
applyMetadata(result, node, context, path);
|
|
118
|
+
break;
|
|
119
|
+
case "literal":
|
|
120
|
+
if (context.target === "openapi-3.0") {
|
|
121
|
+
result = { enum: [node.literal] };
|
|
122
|
+
extension(result, { literal: node.literal });
|
|
123
|
+
diagnostic(context, "openapi.literal.lossy", "OpenAPI 3.0 has no const keyword; the literal is projected as a single-value enum", path);
|
|
124
|
+
} else result = { const: node.literal };
|
|
125
|
+
break;
|
|
126
|
+
case "literalUnion":
|
|
127
|
+
result = { enum: [...node.values] };
|
|
128
|
+
extension(result, { union: {
|
|
129
|
+
kind: "literalUnion",
|
|
130
|
+
values: [...node.values]
|
|
131
|
+
} });
|
|
132
|
+
break;
|
|
133
|
+
case "nullable": {
|
|
134
|
+
const inner = project(node.value, context, [...path, "value"]);
|
|
135
|
+
if (context.target === "openapi-3.0") {
|
|
136
|
+
result = {
|
|
137
|
+
...inner,
|
|
138
|
+
nullable: true
|
|
139
|
+
};
|
|
140
|
+
extension(result, { union: {
|
|
141
|
+
kind: "nullable",
|
|
142
|
+
value: true
|
|
143
|
+
} });
|
|
144
|
+
diagnostic(context, "openapi.nullable.lossy", "OpenAPI 3.0 nullable is preserved as an extension because it is not equivalent to JSON Schema null union semantics", path);
|
|
145
|
+
} else result = { anyOf: [inner, { type: "null" }] };
|
|
146
|
+
break;
|
|
147
|
+
}
|
|
148
|
+
case "array":
|
|
149
|
+
result = {
|
|
150
|
+
type: "array",
|
|
151
|
+
items: project(node.elementSchema, context, [...path, "elementSchema"])
|
|
152
|
+
};
|
|
153
|
+
applyMetadata(result, node, context, path);
|
|
154
|
+
break;
|
|
155
|
+
case "tuple":
|
|
156
|
+
if (context.target === "draft-07") result = {
|
|
157
|
+
type: "array",
|
|
158
|
+
items: node.elementSchemas.map((item, index) => project(item, context, [
|
|
159
|
+
...path,
|
|
160
|
+
"elementSchemas",
|
|
161
|
+
index
|
|
162
|
+
])),
|
|
163
|
+
additionalItems: false,
|
|
164
|
+
minItems: node.elementSchemas.length,
|
|
165
|
+
maxItems: node.elementSchemas.length
|
|
166
|
+
};
|
|
167
|
+
else if (context.target === "openapi-3.0") {
|
|
168
|
+
const elements = node.elementSchemas.map((item, index) => project(item, context, [
|
|
169
|
+
...path,
|
|
170
|
+
"elementSchemas",
|
|
171
|
+
index
|
|
172
|
+
]));
|
|
173
|
+
result = {
|
|
174
|
+
type: "array",
|
|
175
|
+
items: {}
|
|
176
|
+
};
|
|
177
|
+
extension(result, { union: {
|
|
178
|
+
kind: "tuple",
|
|
179
|
+
length: node.elementSchemas.length,
|
|
180
|
+
elementSchemas: elements
|
|
181
|
+
} });
|
|
182
|
+
diagnostic(context, "openapi.tuple.lossy", "OpenAPI 3.0 has no tuple form; tuple position schemas are retained only in x-schemair", path);
|
|
183
|
+
} else result = {
|
|
184
|
+
type: "array",
|
|
185
|
+
prefixItems: node.elementSchemas.map((item, index) => project(item, context, [
|
|
186
|
+
...path,
|
|
187
|
+
"elementSchemas",
|
|
188
|
+
index
|
|
189
|
+
])),
|
|
190
|
+
items: false,
|
|
191
|
+
minItems: node.elementSchemas.length,
|
|
192
|
+
maxItems: node.elementSchemas.length
|
|
193
|
+
};
|
|
194
|
+
break;
|
|
195
|
+
case "record": {
|
|
196
|
+
const properties = {};
|
|
197
|
+
const required = [];
|
|
198
|
+
for (const field of node.fields) {
|
|
199
|
+
properties[field.key] = project(field.schema, context, [
|
|
200
|
+
...path,
|
|
201
|
+
"fields",
|
|
202
|
+
field.key
|
|
203
|
+
]);
|
|
204
|
+
if (field.required) required.push(field.key);
|
|
205
|
+
}
|
|
206
|
+
result = {
|
|
207
|
+
type: "object",
|
|
208
|
+
properties
|
|
209
|
+
};
|
|
210
|
+
if (required.length) result.required = required;
|
|
211
|
+
if (node.additionalFields === void 0) result.additionalProperties = false;
|
|
212
|
+
else if (node.additionalFields === true) result.additionalProperties = true;
|
|
213
|
+
else result.additionalProperties = project(node.additionalFields, context, [...path, "additionalFields"]);
|
|
214
|
+
applyMetadata(result, node, context, path);
|
|
215
|
+
break;
|
|
216
|
+
}
|
|
217
|
+
case "taggedUnion":
|
|
218
|
+
result = { oneOf: node.variants.map((variant, index) => project(variant.schema, context, [
|
|
219
|
+
...path,
|
|
220
|
+
"variants",
|
|
221
|
+
index
|
|
222
|
+
])) };
|
|
223
|
+
extension(result, { union: {
|
|
224
|
+
kind: "taggedUnion",
|
|
225
|
+
discriminator: node.discriminator,
|
|
226
|
+
variants: node.variants.map((variant) => ({
|
|
227
|
+
key: variant.key,
|
|
228
|
+
description: variant.description ?? null
|
|
229
|
+
}))
|
|
230
|
+
} });
|
|
231
|
+
diagnostic(context, "union.tagged.lossy", "SchemaIR tagged-union keys are not JSON Schema validation semantics", path);
|
|
232
|
+
break;
|
|
233
|
+
case "ref": {
|
|
234
|
+
const reference = context.options.refStrategy?.(node.refPath);
|
|
235
|
+
result = reference ? { $ref: reference } : {};
|
|
236
|
+
if (!reference) {
|
|
237
|
+
extension(result, { refPath: node.refPath });
|
|
238
|
+
diagnostic(context, "ref.unresolved", `No JSON Schema ref strategy resolved ${node.refPath.join("/")}`, path, "error");
|
|
239
|
+
}
|
|
240
|
+
break;
|
|
241
|
+
}
|
|
242
|
+
case "selfRef":
|
|
243
|
+
result = {};
|
|
244
|
+
extension(result, { selfRef: true });
|
|
245
|
+
diagnostic(context, "ref.self", "selfRef needs a caller-owned JSON Schema anchor strategy", path, "error");
|
|
246
|
+
break;
|
|
247
|
+
}
|
|
248
|
+
context.stack.pop();
|
|
249
|
+
return result;
|
|
250
|
+
}
|
|
251
|
+
function fidelity(diagnostics) {
|
|
252
|
+
if (diagnostics.some((item) => item.severity === "error")) return "unsupported";
|
|
253
|
+
if (diagnostics.length) return "lossy";
|
|
254
|
+
return "exact";
|
|
255
|
+
}
|
|
256
|
+
/** Project a SchemaNode into JSON Schema Draft 2020-12 without hiding loss. */
|
|
257
|
+
function schemaNodeToJsonSchema(node, options = {}) {
|
|
258
|
+
const target = options.target ?? "draft-2020-12";
|
|
259
|
+
if (target === "openapi-3.0") return schemaNodeToOpenApiSchema(node, options);
|
|
260
|
+
const context = {
|
|
261
|
+
options,
|
|
262
|
+
target,
|
|
263
|
+
diagnostics: [],
|
|
264
|
+
stack: []
|
|
265
|
+
};
|
|
266
|
+
return {
|
|
267
|
+
schema: project(node, context, []),
|
|
268
|
+
fidelity: fidelity(context.diagnostics),
|
|
269
|
+
diagnostics: context.diagnostics
|
|
270
|
+
};
|
|
271
|
+
}
|
|
272
|
+
/** Project a SchemaNode to an OpenAPI 3.0 Schema Object. */
|
|
273
|
+
function schemaNodeToOpenApiSchema(node, options = {}) {
|
|
274
|
+
const context = {
|
|
275
|
+
options,
|
|
276
|
+
target: "openapi-3.0",
|
|
277
|
+
diagnostics: [],
|
|
278
|
+
stack: []
|
|
279
|
+
};
|
|
280
|
+
return {
|
|
281
|
+
schema: project(node, context, []),
|
|
282
|
+
fidelity: fidelity(context.diagnostics),
|
|
283
|
+
diagnostics: context.diagnostics
|
|
284
|
+
};
|
|
285
|
+
}
|
|
286
|
+
/** Alias emphasizing that this is a diagnostic-bearing projection operation. */
|
|
287
|
+
const schemaNodeToJsonSchemaWithDiagnostics = schemaNodeToJsonSchema;
|
|
288
|
+
/**
|
|
289
|
+
* Expose a runtime SchemaIR declaration through Standard JSON Schema V1.
|
|
290
|
+
*
|
|
291
|
+
* SchemaIR declarations do not perform input/output transformations, so both
|
|
292
|
+
* converter methods project the same contract. Lossy projections are allowed
|
|
293
|
+
* because their preserved metadata remains in `x-schemair`; unsupported
|
|
294
|
+
* projections throw as required by the Standard JSON Schema protocol.
|
|
295
|
+
*/
|
|
296
|
+
function schemaIRToStandardJsonSchema(node, options = {}) {
|
|
297
|
+
const convert = (target) => {
|
|
298
|
+
const { target: _ignoredTarget, ...projectionOptions } = options;
|
|
299
|
+
const projectionTarget = target === "openapi-3.0" || target === "draft-2020-12" || target === "draft-07" ? target : void 0;
|
|
300
|
+
const result = projectionTarget === "openapi-3.0" ? schemaNodeToOpenApiSchema(node, projectionOptions) : projectionTarget ? schemaNodeToJsonSchema(node, {
|
|
301
|
+
...projectionOptions,
|
|
302
|
+
target: projectionTarget
|
|
303
|
+
}) : void 0;
|
|
304
|
+
if (!result) throw new Error(`SchemaIR Standard JSON Schema adapter does not support target ${target}`);
|
|
305
|
+
if (result.fidelity === "unsupported") {
|
|
306
|
+
const details = result.diagnostics.map((item) => item.message).join("; ");
|
|
307
|
+
throw new Error(`SchemaIR cannot be represented as JSON Schema: ${details}`);
|
|
308
|
+
}
|
|
309
|
+
return result.schema;
|
|
310
|
+
};
|
|
311
|
+
return { "~standard": {
|
|
312
|
+
version: 1,
|
|
313
|
+
vendor: "schemair",
|
|
314
|
+
jsonSchema: {
|
|
315
|
+
input: ({ target }) => convert(target),
|
|
316
|
+
output: ({ target }) => convert(target)
|
|
317
|
+
}
|
|
318
|
+
} };
|
|
319
|
+
}
|
|
320
|
+
/** Uppercase acronym alias matching the protocol name. */
|
|
321
|
+
const schemaIRToStandardJSONSchema = schemaIRToStandardJsonSchema;
|
|
322
|
+
|
|
323
|
+
//#endregion
|
|
324
|
+
exports.schemaIRToStandardJSONSchema = schemaIRToStandardJSONSchema;
|
|
325
|
+
exports.schemaIRToStandardJsonSchema = schemaIRToStandardJsonSchema;
|
|
326
|
+
exports.schemaNodeToJsonSchema = schemaNodeToJsonSchema;
|
|
327
|
+
exports.schemaNodeToJsonSchemaWithDiagnostics = schemaNodeToJsonSchemaWithDiagnostics;
|
|
328
|
+
exports.schemaNodeToOpenApiSchema = schemaNodeToOpenApiSchema;
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { _t as SchemaStringNode, at as SchemaConstraint, ct as SchemaNode, dt as SchemaNumberNode, et as JsonValue } from "../../index-DDMwVy2I.cjs";
|
|
2
|
+
import { StandardJSONSchemaV1, StandardJSONSchemaV1 as StandardJSONSchemaV1$1 } from "@standard-schema/spec";
|
|
3
|
+
|
|
4
|
+
//#region src/integrations/json-schema/index.d.ts
|
|
5
|
+
/** Supported projection dialects. OpenAPI is a Schema Object, not a full JSON Schema dialect. */
|
|
6
|
+
type JsonSchemaTarget = 'draft-2020-12' | 'draft-07' | 'openapi-3.0';
|
|
7
|
+
/** JSON-compatible values accepted by the exporter. */
|
|
8
|
+
type JsonSchema = {
|
|
9
|
+
[key: string]: JsonSchema | JsonSchema[] | JsonValue | undefined;
|
|
10
|
+
};
|
|
11
|
+
type JsonSchemaProjectionFidelity = 'exact' | 'lossy' | 'unsupported' | 'incomplete';
|
|
12
|
+
interface JsonSchemaProjectionDiagnostic {
|
|
13
|
+
code: string;
|
|
14
|
+
message: string;
|
|
15
|
+
path: readonly (string | number)[];
|
|
16
|
+
severity: 'warning' | 'error';
|
|
17
|
+
}
|
|
18
|
+
interface JsonSchemaProjectionResult {
|
|
19
|
+
schema: JsonSchema;
|
|
20
|
+
fidelity: JsonSchemaProjectionFidelity;
|
|
21
|
+
diagnostics: readonly JsonSchemaProjectionDiagnostic[];
|
|
22
|
+
}
|
|
23
|
+
interface JsonSchemaProjectionOptions {
|
|
24
|
+
/** Projection target. Defaults to JSON Schema Draft 2020-12. */
|
|
25
|
+
target?: JsonSchemaTarget;
|
|
26
|
+
/** Resolve SchemaIR refs to JSON Schema $ref values. Unhandled refs are diagnosed. */
|
|
27
|
+
refStrategy?: (path: readonly string[]) => string | undefined;
|
|
28
|
+
/** Map a semantic path to native JSON Schema keywords when equivalence is known. */
|
|
29
|
+
semanticMapper?: (path: readonly string[], node: SchemaStringNode | SchemaNumberNode) => JsonSchema | undefined;
|
|
30
|
+
/** Map a constraint to native JSON Schema keywords when equivalence is known. */
|
|
31
|
+
constraintMapper?: (constraint: SchemaConstraint, target: SchemaNode) => JsonSchema | undefined;
|
|
32
|
+
}
|
|
33
|
+
/** Options accepted by the Standard JSON Schema adapter. */
|
|
34
|
+
type StandardJsonSchemaAdapterOptions = JsonSchemaProjectionOptions;
|
|
35
|
+
/** Project a SchemaNode into JSON Schema Draft 2020-12 without hiding loss. */
|
|
36
|
+
declare function schemaNodeToJsonSchema(node: SchemaNode, options?: JsonSchemaProjectionOptions): JsonSchemaProjectionResult;
|
|
37
|
+
/** Project a SchemaNode to an OpenAPI 3.0 Schema Object. */
|
|
38
|
+
declare function schemaNodeToOpenApiSchema(node: SchemaNode, options?: Omit<JsonSchemaProjectionOptions, 'target'>): JsonSchemaProjectionResult;
|
|
39
|
+
/** Alias emphasizing that this is a diagnostic-bearing projection operation. */
|
|
40
|
+
declare const schemaNodeToJsonSchemaWithDiagnostics: typeof schemaNodeToJsonSchema;
|
|
41
|
+
/**
|
|
42
|
+
* Expose a runtime SchemaIR declaration through Standard JSON Schema V1.
|
|
43
|
+
*
|
|
44
|
+
* SchemaIR declarations do not perform input/output transformations, so both
|
|
45
|
+
* converter methods project the same contract. Lossy projections are allowed
|
|
46
|
+
* because their preserved metadata remains in `x-schemair`; unsupported
|
|
47
|
+
* projections throw as required by the Standard JSON Schema protocol.
|
|
48
|
+
*/
|
|
49
|
+
declare function schemaIRToStandardJsonSchema(node: SchemaNode, options?: StandardJsonSchemaAdapterOptions): StandardJSONSchemaV1$1;
|
|
50
|
+
/** Uppercase acronym alias matching the protocol name. */
|
|
51
|
+
declare const schemaIRToStandardJSONSchema: typeof schemaIRToStandardJsonSchema;
|
|
52
|
+
//#endregion
|
|
53
|
+
export { JsonSchema, JsonSchemaProjectionDiagnostic, JsonSchemaProjectionFidelity, JsonSchemaProjectionOptions, JsonSchemaProjectionResult, JsonSchemaTarget, type JsonValue, type SchemaConstraint, type SchemaNode, type StandardJSONSchemaV1, StandardJsonSchemaAdapterOptions, schemaIRToStandardJSONSchema, schemaIRToStandardJsonSchema, schemaNodeToJsonSchema, schemaNodeToJsonSchemaWithDiagnostics, schemaNodeToOpenApiSchema };
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { _t as SchemaStringNode, at as SchemaConstraint, ct as SchemaNode, dt as SchemaNumberNode, et as JsonValue } from "../../index-4aMF0cTE.js";
|
|
2
|
+
import { StandardJSONSchemaV1, StandardJSONSchemaV1 as StandardJSONSchemaV1$1 } from "@standard-schema/spec";
|
|
3
|
+
|
|
4
|
+
//#region src/integrations/json-schema/index.d.ts
|
|
5
|
+
/** Supported projection dialects. OpenAPI is a Schema Object, not a full JSON Schema dialect. */
|
|
6
|
+
type JsonSchemaTarget = 'draft-2020-12' | 'draft-07' | 'openapi-3.0';
|
|
7
|
+
/** JSON-compatible values accepted by the exporter. */
|
|
8
|
+
type JsonSchema = {
|
|
9
|
+
[key: string]: JsonSchema | JsonSchema[] | JsonValue | undefined;
|
|
10
|
+
};
|
|
11
|
+
type JsonSchemaProjectionFidelity = 'exact' | 'lossy' | 'unsupported' | 'incomplete';
|
|
12
|
+
interface JsonSchemaProjectionDiagnostic {
|
|
13
|
+
code: string;
|
|
14
|
+
message: string;
|
|
15
|
+
path: readonly (string | number)[];
|
|
16
|
+
severity: 'warning' | 'error';
|
|
17
|
+
}
|
|
18
|
+
interface JsonSchemaProjectionResult {
|
|
19
|
+
schema: JsonSchema;
|
|
20
|
+
fidelity: JsonSchemaProjectionFidelity;
|
|
21
|
+
diagnostics: readonly JsonSchemaProjectionDiagnostic[];
|
|
22
|
+
}
|
|
23
|
+
interface JsonSchemaProjectionOptions {
|
|
24
|
+
/** Projection target. Defaults to JSON Schema Draft 2020-12. */
|
|
25
|
+
target?: JsonSchemaTarget;
|
|
26
|
+
/** Resolve SchemaIR refs to JSON Schema $ref values. Unhandled refs are diagnosed. */
|
|
27
|
+
refStrategy?: (path: readonly string[]) => string | undefined;
|
|
28
|
+
/** Map a semantic path to native JSON Schema keywords when equivalence is known. */
|
|
29
|
+
semanticMapper?: (path: readonly string[], node: SchemaStringNode | SchemaNumberNode) => JsonSchema | undefined;
|
|
30
|
+
/** Map a constraint to native JSON Schema keywords when equivalence is known. */
|
|
31
|
+
constraintMapper?: (constraint: SchemaConstraint, target: SchemaNode) => JsonSchema | undefined;
|
|
32
|
+
}
|
|
33
|
+
/** Options accepted by the Standard JSON Schema adapter. */
|
|
34
|
+
type StandardJsonSchemaAdapterOptions = JsonSchemaProjectionOptions;
|
|
35
|
+
/** Project a SchemaNode into JSON Schema Draft 2020-12 without hiding loss. */
|
|
36
|
+
declare function schemaNodeToJsonSchema(node: SchemaNode, options?: JsonSchemaProjectionOptions): JsonSchemaProjectionResult;
|
|
37
|
+
/** Project a SchemaNode to an OpenAPI 3.0 Schema Object. */
|
|
38
|
+
declare function schemaNodeToOpenApiSchema(node: SchemaNode, options?: Omit<JsonSchemaProjectionOptions, 'target'>): JsonSchemaProjectionResult;
|
|
39
|
+
/** Alias emphasizing that this is a diagnostic-bearing projection operation. */
|
|
40
|
+
declare const schemaNodeToJsonSchemaWithDiagnostics: typeof schemaNodeToJsonSchema;
|
|
41
|
+
/**
|
|
42
|
+
* Expose a runtime SchemaIR declaration through Standard JSON Schema V1.
|
|
43
|
+
*
|
|
44
|
+
* SchemaIR declarations do not perform input/output transformations, so both
|
|
45
|
+
* converter methods project the same contract. Lossy projections are allowed
|
|
46
|
+
* because their preserved metadata remains in `x-schemair`; unsupported
|
|
47
|
+
* projections throw as required by the Standard JSON Schema protocol.
|
|
48
|
+
*/
|
|
49
|
+
declare function schemaIRToStandardJsonSchema(node: SchemaNode, options?: StandardJsonSchemaAdapterOptions): StandardJSONSchemaV1$1;
|
|
50
|
+
/** Uppercase acronym alias matching the protocol name. */
|
|
51
|
+
declare const schemaIRToStandardJSONSchema: typeof schemaIRToStandardJsonSchema;
|
|
52
|
+
//#endregion
|
|
53
|
+
export { JsonSchema, JsonSchemaProjectionDiagnostic, JsonSchemaProjectionFidelity, JsonSchemaProjectionOptions, JsonSchemaProjectionResult, JsonSchemaTarget, type JsonValue, type SchemaConstraint, type SchemaNode, type StandardJSONSchemaV1, StandardJsonSchemaAdapterOptions, schemaIRToStandardJSONSchema, schemaIRToStandardJsonSchema, schemaNodeToJsonSchema, schemaNodeToJsonSchemaWithDiagnostics, schemaNodeToOpenApiSchema };
|