Spaces:
Running
Running
File size: 2,882 Bytes
1df763a |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 |
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const shared = (root) => {
const sch = {
nullable: { type: "boolean" },
metadata: {
optionalProperties: {
union: { elements: { ref: "schema" } },
},
additionalProperties: true,
},
};
if (root)
sch.definitions = { values: { ref: "schema" } };
return sch;
};
const emptyForm = (root) => ({
optionalProperties: shared(root),
});
const refForm = (root) => ({
properties: {
ref: { type: "string" },
},
optionalProperties: shared(root),
});
const typeForm = (root) => ({
properties: {
type: {
enum: [
"boolean",
"timestamp",
"string",
"float32",
"float64",
"int8",
"uint8",
"int16",
"uint16",
"int32",
"uint32",
],
},
},
optionalProperties: shared(root),
});
const enumForm = (root) => ({
properties: {
enum: { elements: { type: "string" } },
},
optionalProperties: shared(root),
});
const elementsForm = (root) => ({
properties: {
elements: { ref: "schema" },
},
optionalProperties: shared(root),
});
const propertiesForm = (root) => ({
properties: {
properties: { values: { ref: "schema" } },
},
optionalProperties: {
optionalProperties: { values: { ref: "schema" } },
additionalProperties: { type: "boolean" },
...shared(root),
},
});
const optionalPropertiesForm = (root) => ({
properties: {
optionalProperties: { values: { ref: "schema" } },
},
optionalProperties: {
additionalProperties: { type: "boolean" },
...shared(root),
},
});
const discriminatorForm = (root) => ({
properties: {
discriminator: { type: "string" },
mapping: {
values: {
metadata: {
union: [propertiesForm(false), optionalPropertiesForm(false)],
},
},
},
},
optionalProperties: shared(root),
});
const valuesForm = (root) => ({
properties: {
values: { ref: "schema" },
},
optionalProperties: shared(root),
});
const schema = (root) => ({
metadata: {
union: [
emptyForm,
refForm,
typeForm,
enumForm,
elementsForm,
propertiesForm,
optionalPropertiesForm,
discriminatorForm,
valuesForm,
].map((s) => s(root)),
},
});
const jtdMetaSchema = {
definitions: {
schema: schema(false),
},
...schema(true),
};
exports.default = jtdMetaSchema;
//# sourceMappingURL=jtd-schema.js.map |