@revisium/schema-toolkit 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.
Files changed (59) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +184 -0
  3. package/dist/consts/index.cjs +26 -0
  4. package/dist/consts/index.cjs.map +1 -0
  5. package/dist/consts/index.d.cts +17 -0
  6. package/dist/consts/index.d.ts +17 -0
  7. package/dist/consts/index.js +23 -0
  8. package/dist/consts/index.js.map +1 -0
  9. package/dist/index.cjs +1874 -0
  10. package/dist/index.cjs.map +1 -0
  11. package/dist/index.d.cts +13 -0
  12. package/dist/index.d.ts +13 -0
  13. package/dist/index.js +1787 -0
  14. package/dist/index.js.map +1 -0
  15. package/dist/json-patch.types-DiJBqfxV.d.ts +28 -0
  16. package/dist/json-patch.types-lByaF-OL.d.cts +28 -0
  17. package/dist/json-string.store-O1J0j-a1.d.cts +228 -0
  18. package/dist/json-string.store-S9FXT39Q.d.ts +228 -0
  19. package/dist/json.types-46Cq-WxU.d.cts +8 -0
  20. package/dist/json.types-46Cq-WxU.d.ts +8 -0
  21. package/dist/lib/index.cjs +1346 -0
  22. package/dist/lib/index.cjs.map +1 -0
  23. package/dist/lib/index.d.cts +91 -0
  24. package/dist/lib/index.d.ts +91 -0
  25. package/dist/lib/index.js +1315 -0
  26. package/dist/lib/index.js.map +1 -0
  27. package/dist/mocks/index.cjs +92 -0
  28. package/dist/mocks/index.cjs.map +1 -0
  29. package/dist/mocks/index.d.cts +26 -0
  30. package/dist/mocks/index.d.ts +26 -0
  31. package/dist/mocks/index.js +81 -0
  32. package/dist/mocks/index.js.map +1 -0
  33. package/dist/model/index.cjs +718 -0
  34. package/dist/model/index.cjs.map +1 -0
  35. package/dist/model/index.d.cts +19 -0
  36. package/dist/model/index.d.ts +19 -0
  37. package/dist/model/index.js +697 -0
  38. package/dist/model/index.js.map +1 -0
  39. package/dist/plugins/index.cjs +122 -0
  40. package/dist/plugins/index.cjs.map +1 -0
  41. package/dist/plugins/index.d.cts +21 -0
  42. package/dist/plugins/index.d.ts +21 -0
  43. package/dist/plugins/index.js +112 -0
  44. package/dist/plugins/index.js.map +1 -0
  45. package/dist/schema.types-Q3MYTp8z.d.cts +68 -0
  46. package/dist/schema.types-Q3MYTp8z.d.ts +68 -0
  47. package/dist/types/index.cjs +15 -0
  48. package/dist/types/index.cjs.map +1 -0
  49. package/dist/types/index.d.cts +56 -0
  50. package/dist/types/index.d.ts +56 -0
  51. package/dist/types/index.js +13 -0
  52. package/dist/types/index.js.map +1 -0
  53. package/dist/validation-schemas/index.cjs +380 -0
  54. package/dist/validation-schemas/index.cjs.map +1 -0
  55. package/dist/validation-schemas/index.d.cts +32 -0
  56. package/dist/validation-schemas/index.d.ts +32 -0
  57. package/dist/validation-schemas/index.js +365 -0
  58. package/dist/validation-schemas/index.js.map +1 -0
  59. package/package.json +169 -0
@@ -0,0 +1,365 @@
1
+ // src/validation-schemas/shared-fields.ts
2
+ var sharedFields = {
3
+ deprecated: {
4
+ type: "boolean"
5
+ },
6
+ title: {
7
+ type: "string"
8
+ },
9
+ description: {
10
+ type: "string"
11
+ }
12
+ };
13
+
14
+ // src/validation-schemas/meta-schema.ts
15
+ var refMetaSchema = {
16
+ type: "object",
17
+ properties: {
18
+ ...sharedFields,
19
+ $ref: {
20
+ type: "string"
21
+ }
22
+ },
23
+ additionalProperties: false,
24
+ required: ["$ref"]
25
+ };
26
+ var baseStringFields = {
27
+ type: {
28
+ const: "string"
29
+ },
30
+ default: {
31
+ type: "string"
32
+ },
33
+ readOnly: {
34
+ type: "boolean"
35
+ },
36
+ pattern: {
37
+ type: "string",
38
+ format: "regex"
39
+ },
40
+ enum: {
41
+ type: "array",
42
+ items: { type: "string" },
43
+ minItems: 1,
44
+ uniqueItems: true
45
+ },
46
+ format: {
47
+ type: "string",
48
+ enum: ["date-time", "date", "time", "email", "regex"]
49
+ },
50
+ contentMediaType: {
51
+ type: "string",
52
+ enum: [
53
+ "text/plain",
54
+ "text/markdown",
55
+ "text/html",
56
+ "application/json",
57
+ "application/schema+json",
58
+ "application/yaml"
59
+ ]
60
+ },
61
+ ...sharedFields
62
+ };
63
+ var stringMetaSchema = {
64
+ type: "object",
65
+ properties: {
66
+ ...baseStringFields,
67
+ foreignKey: {
68
+ type: "string"
69
+ }
70
+ },
71
+ additionalProperties: false,
72
+ required: ["type", "default"]
73
+ };
74
+ var noForeignKeyStringMetaSchema = {
75
+ type: "object",
76
+ properties: {
77
+ ...baseStringFields
78
+ },
79
+ additionalProperties: false,
80
+ required: ["type", "default"]
81
+ };
82
+ var numberMetaSchema = {
83
+ type: "object",
84
+ properties: {
85
+ type: {
86
+ const: "number"
87
+ },
88
+ default: {
89
+ type: "number"
90
+ },
91
+ readOnly: {
92
+ type: "boolean"
93
+ },
94
+ ...sharedFields
95
+ },
96
+ additionalProperties: false,
97
+ required: ["type", "default"]
98
+ };
99
+ var booleanMetaSchema = {
100
+ type: "object",
101
+ properties: {
102
+ type: {
103
+ const: "boolean"
104
+ },
105
+ default: {
106
+ type: "boolean"
107
+ },
108
+ readOnly: {
109
+ type: "boolean"
110
+ },
111
+ ...sharedFields
112
+ },
113
+ additionalProperties: false,
114
+ required: ["type", "default"]
115
+ };
116
+ var objectMetaSchema = {
117
+ type: "object",
118
+ properties: {
119
+ type: {
120
+ const: "object"
121
+ },
122
+ ...sharedFields,
123
+ properties: {
124
+ type: "object",
125
+ additionalProperties: { $dynamicRef: "#meta" },
126
+ default: {}
127
+ },
128
+ additionalProperties: { const: false },
129
+ required: { $ref: "#/$defs/stringArray" }
130
+ },
131
+ additionalProperties: false,
132
+ required: ["type", "properties", "additionalProperties", "required"]
133
+ };
134
+ var arrayMetaSchema = {
135
+ type: "object",
136
+ properties: {
137
+ type: {
138
+ const: "array"
139
+ },
140
+ ...sharedFields,
141
+ items: {
142
+ oneOf: [
143
+ { $ref: "#/$defs/refSchema" },
144
+ { $ref: "#/$defs/objectSchema" },
145
+ { $ref: "#/$defs/arraySchema" },
146
+ { $ref: "#/$defs/stringSchema" },
147
+ { $ref: "#/$defs/numberSchema" },
148
+ { $ref: "#/$defs/booleanSchema" }
149
+ ]
150
+ }
151
+ },
152
+ additionalProperties: false,
153
+ required: ["type", "items"]
154
+ };
155
+ var metaSchema = {
156
+ $id: "meta-schema.json",
157
+ type: "object",
158
+ $dynamicAnchor: "meta",
159
+ oneOf: [
160
+ { $ref: "#/$defs/refSchema" },
161
+ { $ref: "#/$defs/objectSchema" },
162
+ { $ref: "#/$defs/arraySchema" },
163
+ { $ref: "#/$defs/stringSchema" },
164
+ { $ref: "#/$defs/numberSchema" },
165
+ { $ref: "#/$defs/booleanSchema" }
166
+ ],
167
+ $defs: {
168
+ stringArray: {
169
+ type: "array",
170
+ items: { type: "string" },
171
+ uniqueItems: true,
172
+ default: []
173
+ },
174
+ refSchema: refMetaSchema,
175
+ objectSchema: objectMetaSchema,
176
+ stringSchema: stringMetaSchema,
177
+ numberSchema: numberMetaSchema,
178
+ booleanSchema: booleanMetaSchema,
179
+ arraySchema: arrayMetaSchema
180
+ }
181
+ };
182
+ var notForeignKeyMetaSchema = {
183
+ type: "object",
184
+ $dynamicAnchor: "meta",
185
+ oneOf: [
186
+ { $ref: "#/$defs/refSchema" },
187
+ { $ref: "#/$defs/objectSchema" },
188
+ { $ref: "#/$defs/arraySchema" },
189
+ { $ref: "#/$defs/stringSchema" },
190
+ { $ref: "#/$defs/numberSchema" },
191
+ { $ref: "#/$defs/booleanSchema" }
192
+ ],
193
+ $defs: {
194
+ stringArray: {
195
+ type: "array",
196
+ items: { type: "string" },
197
+ uniqueItems: true,
198
+ default: []
199
+ },
200
+ refSchema: refMetaSchema,
201
+ objectSchema: objectMetaSchema,
202
+ stringSchema: noForeignKeyStringMetaSchema,
203
+ numberSchema: numberMetaSchema,
204
+ booleanSchema: booleanMetaSchema,
205
+ arraySchema: arrayMetaSchema
206
+ }
207
+ };
208
+
209
+ // src/validation-schemas/json-patch-schema.ts
210
+ var jsonPatchSchema = {
211
+ $id: "json-patch-schema.json",
212
+ definitions: {
213
+ path: {
214
+ description: "A JSON Pointer path.",
215
+ type: "string"
216
+ },
217
+ objectSchema: objectMetaSchema,
218
+ stringSchema: stringMetaSchema,
219
+ numberSchema: numberMetaSchema,
220
+ booleanSchema: booleanMetaSchema,
221
+ arraySchema: arrayMetaSchema
222
+ },
223
+ minItems: 1,
224
+ items: {
225
+ oneOf: [
226
+ {
227
+ type: "object",
228
+ additionalProperties: false,
229
+ required: ["value", "op", "path"],
230
+ properties: {
231
+ path: {
232
+ $ref: "#/definitions/path"
233
+ },
234
+ op: {
235
+ description: "The operation to perform.",
236
+ type: "string",
237
+ enum: ["add", "replace"]
238
+ },
239
+ value: {
240
+ $ref: "meta-schema.json",
241
+ description: "The value to add, replace or test."
242
+ }
243
+ }
244
+ },
245
+ {
246
+ type: "object",
247
+ additionalProperties: false,
248
+ required: ["op", "path"],
249
+ properties: {
250
+ path: {
251
+ $ref: "#/definitions/path"
252
+ },
253
+ op: {
254
+ description: "The operation to perform.",
255
+ type: "string",
256
+ enum: ["remove"]
257
+ }
258
+ }
259
+ },
260
+ {
261
+ type: "object",
262
+ additionalProperties: false,
263
+ required: ["from", "op", "path"],
264
+ properties: {
265
+ path: {
266
+ $ref: "#/definitions/path"
267
+ },
268
+ op: {
269
+ description: "The operation to perform.",
270
+ type: "string",
271
+ enum: ["move", "copy"]
272
+ },
273
+ from: {
274
+ $ref: "#/definitions/path",
275
+ description: "A JSON Pointer path pointing to the location to move/copy from."
276
+ }
277
+ }
278
+ }
279
+ ]
280
+ },
281
+ title: "JSON schema for JSONPatch files",
282
+ type: "array"
283
+ };
284
+
285
+ // src/validation-schemas/history-patches-schema.ts
286
+ var historyPatchesSchema = {
287
+ $id: "history-patches-schema.json",
288
+ type: "array",
289
+ minItems: 1,
290
+ items: {
291
+ type: "object",
292
+ properties: {
293
+ patches: {
294
+ $ref: "json-patch-schema.json"
295
+ },
296
+ hash: {
297
+ type: "string"
298
+ }
299
+ },
300
+ required: ["patches", "hash"]
301
+ }
302
+ };
303
+
304
+ // src/validation-schemas/table-migrations-schema.ts
305
+ var tableMigrationsSchema = {
306
+ $id: "table-migrations-schema.json",
307
+ oneOf: [
308
+ { $ref: "#/definitions/InitMigration" },
309
+ { $ref: "#/definitions/UpdateMigration" },
310
+ { $ref: "#/definitions/RenameMigration" },
311
+ { $ref: "#/definitions/RemoveMigration" }
312
+ ],
313
+ definitions: {
314
+ InitMigration: {
315
+ type: "object",
316
+ additionalProperties: false,
317
+ required: ["changeType", "tableId", "hash", "id", "schema"],
318
+ properties: {
319
+ changeType: { type: "string", const: "init" },
320
+ tableId: { type: "string" },
321
+ hash: { type: "string" },
322
+ id: { type: "string" },
323
+ schema: { $ref: "meta-schema.json" }
324
+ }
325
+ },
326
+ UpdateMigration: {
327
+ type: "object",
328
+ additionalProperties: false,
329
+ required: ["changeType", "tableId", "hash", "id", "patches"],
330
+ properties: {
331
+ changeType: { type: "string", const: "update" },
332
+ tableId: { type: "string" },
333
+ hash: { type: "string" },
334
+ id: { type: "string" },
335
+ patches: { $ref: "json-patch-schema.json" }
336
+ }
337
+ },
338
+ RenameMigration: {
339
+ type: "object",
340
+ additionalProperties: false,
341
+ required: ["changeType", "id", "tableId", "nextTableId"],
342
+ properties: {
343
+ changeType: { type: "string", const: "rename" },
344
+ id: { type: "string" },
345
+ tableId: { type: "string" },
346
+ nextTableId: { type: "string" }
347
+ }
348
+ },
349
+ RemoveMigration: {
350
+ type: "object",
351
+ additionalProperties: false,
352
+ required: ["changeType", "id", "tableId"],
353
+ properties: {
354
+ changeType: { type: "string", const: "remove" },
355
+ id: { type: "string" },
356
+ tableId: { type: "string" }
357
+ }
358
+ }
359
+ },
360
+ title: "JSON Schema for a Single Migration"
361
+ };
362
+
363
+ export { arrayMetaSchema, baseStringFields, booleanMetaSchema, historyPatchesSchema, jsonPatchSchema, metaSchema, noForeignKeyStringMetaSchema, notForeignKeyMetaSchema, numberMetaSchema, objectMetaSchema, refMetaSchema, sharedFields, stringMetaSchema, tableMigrationsSchema };
364
+ //# sourceMappingURL=index.js.map
365
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/validation-schemas/shared-fields.ts","../../src/validation-schemas/meta-schema.ts","../../src/validation-schemas/json-patch-schema.ts","../../src/validation-schemas/history-patches-schema.ts","../../src/validation-schemas/table-migrations-schema.ts"],"names":[],"mappings":";AAAO,IAAM,YAAA,GAAe;AAAA,EAC1B,UAAA,EAAY;AAAA,IACV,IAAA,EAAM;AAAA,GACR;AAAA,EACA,KAAA,EAAO;AAAA,IACL,IAAA,EAAM;AAAA,GACR;AAAA,EACA,WAAA,EAAa;AAAA,IACX,IAAA,EAAM;AAAA;AAEV;;;ACLO,IAAM,aAAA,GAAwB;AAAA,EACnC,IAAA,EAAM,QAAA;AAAA,EACN,UAAA,EAAY;AAAA,IACV,GAAG,YAAA;AAAA,IACH,IAAA,EAAM;AAAA,MACJ,IAAA,EAAM;AAAA;AACR,GACF;AAAA,EACA,oBAAA,EAAsB,KAAA;AAAA,EACtB,QAAA,EAAU,CAAC,MAAM;AACnB;AAEO,IAAM,gBAAA,GAA2B;AAAA,EACtC,IAAA,EAAM;AAAA,IACJ,KAAA,EAAO;AAAA,GACT;AAAA,EACA,OAAA,EAAS;AAAA,IACP,IAAA,EAAM;AAAA,GACR;AAAA,EACA,QAAA,EAAU;AAAA,IACR,IAAA,EAAM;AAAA,GACR;AAAA,EACA,OAAA,EAAS;AAAA,IACP,IAAA,EAAM,QAAA;AAAA,IACN,MAAA,EAAQ;AAAA,GACV;AAAA,EACA,IAAA,EAAM;AAAA,IACJ,IAAA,EAAM,OAAA;AAAA,IACN,KAAA,EAAO,EAAE,IAAA,EAAM,QAAA,EAAS;AAAA,IACxB,QAAA,EAAU,CAAA;AAAA,IACV,WAAA,EAAa;AAAA,GACf;AAAA,EACA,MAAA,EAAQ;AAAA,IACN,IAAA,EAAM,QAAA;AAAA,IACN,MAAM,CAAC,W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ACf,IAAA,EAAM,QAAA;AAAA,MACN,oBAAA,EAAsB,KAAA;AAAA,MACtB,QAAA,EAAU,CAAC,YAAA,EAAc,IAAA,EAAM,WAAW,aAAa,CAAA;AAAA,MACvD,UAAA,EAAY;AAAA,QACV,UAAA,EAAY,EAAE,IAAA,EAAM,QAAA,EAAU,OAAO,QAAA,EAAS;AAAA,QAC9C,EAAA,EAAI,EAAE,IAAA,EAAM,QAAA,EAAS;AAAA,QACrB,OAAA,EAAS,EAAE,IAAA,EAAM,QAAA,EAAS;AAAA,QAC1B,WAAA,EAAa,EAAE,IAAA,EAAM,QAAA;AAAS;AAChC,KACF;AAAA,IACA,eAAA,EAAiB;AAAA,MACf,IAAA,EAAM,QAAA;AAAA,MACN,oBAAA,EAAsB,KAAA;AAAA,MACtB,QAAA,EAAU,CAAC,YAAA,EAAc,IAAA,EAAM,SAAS,CAAA;AAAA,MACxC,UAAA,EAAY;AAAA,QACV,UAAA,EAAY,EAAE,IAAA,EAAM,QAAA,EAAU,OAAO,QAAA,EAAS;AAAA,QAC9C,EAAA,EAAI,EAAE,IAAA,EAAM,QAAA,EAAS;AAAA,QACrB,OAAA,EAAS,EAAE,IAAA,EAAM,QAAA;AAAS;AAC5B;AACF,GACF;AAAA,EACA,KAAA,EAAO;AACT","file":"index.js","sourcesContent":["export const sharedFields = {\n deprecated: {\n type: 'boolean',\n },\n title: {\n type: 'string',\n },\n description: {\n type: 'string',\n },\n};\n","import { Schema } from 'ajv/dist/2020';\nimport { sharedFields } from './shared-fields.js';\n\n// https://json-schema.org/specification#single-vocabulary-meta-schemas\n\nexport const refMetaSchema: Schema = {\n type: 'object',\n properties: {\n ...sharedFields,\n $ref: {\n type: 'string',\n },\n },\n additionalProperties: false,\n required: ['$ref'],\n};\n\nexport const baseStringFields: Schema = {\n type: {\n const: 'string',\n },\n default: {\n type: 'string',\n },\n readOnly: {\n type: 'boolean',\n },\n pattern: {\n type: 'string',\n format: 'regex',\n },\n enum: {\n type: 'array',\n items: { type: 'string' },\n minItems: 1,\n uniqueItems: true,\n },\n format: {\n type: 'string',\n enum: ['date-time', 'date', 'time', 'email', 'regex'],\n },\n contentMediaType: {\n type: 'string',\n enum: [\n 'text/plain',\n 'text/markdown',\n 'text/html',\n 'application/json',\n 'application/schema+json',\n 'application/yaml',\n ],\n },\n ...sharedFields,\n};\n\nexport const stringMetaSchema: Schema = {\n type: 'object',\n properties: {\n ...baseStringFields,\n foreignKey: {\n type: 'string',\n },\n },\n additionalProperties: false,\n required: ['type', 'default'],\n};\n\nexport const noForeignKeyStringMetaSchema: Schema = {\n type: 'object',\n properties: {\n ...baseStringFields,\n },\n additionalProperties: false,\n required: ['type', 'default'],\n};\n\nexport const numberMetaSchema: Schema = {\n type: 'object',\n properties: {\n type: {\n const: 'number',\n },\n default: {\n type: 'number',\n },\n readOnly: {\n type: 'boolean',\n },\n ...sharedFields,\n },\n additionalProperties: false,\n required: ['type', 'default'],\n};\n\nexport const booleanMetaSchema: Schema = {\n type: 'object',\n properties: {\n type: {\n const: 'boolean',\n },\n default: {\n type: 'boolean',\n },\n readOnly: {\n type: 'boolean',\n },\n ...sharedFields,\n },\n additionalProperties: false,\n required: ['type', 'default'],\n};\n\nexport const objectMetaSchema: Schema = {\n type: 'object',\n properties: {\n type: {\n const: 'object',\n },\n ...sharedFields,\n properties: {\n type: 'object',\n additionalProperties: { $dynamicRef: '#meta' },\n default: {},\n },\n additionalProperties: { const: false },\n required: { $ref: '#/$defs/stringArray' },\n },\n additionalProperties: false,\n required: ['type', 'properties', 'additionalProperties', 'required'],\n};\n\nexport const arrayMetaSchema: Schema = {\n type: 'object',\n properties: {\n type: {\n const: 'array',\n },\n ...sharedFields,\n items: {\n oneOf: [\n { $ref: '#/$defs/refSchema' },\n { $ref: '#/$defs/objectSchema' },\n { $ref: '#/$defs/arraySchema' },\n { $ref: '#/$defs/stringSchema' },\n { $ref: '#/$defs/numberSchema' },\n { $ref: '#/$defs/booleanSchema' },\n ],\n },\n },\n additionalProperties: false,\n required: ['type', 'items'],\n};\n\nexport const metaSchema: Schema = {\n $id: 'meta-schema.json',\n type: 'object',\n $dynamicAnchor: 'meta',\n oneOf: [\n { $ref: '#/$defs/refSchema' },\n { $ref: '#/$defs/objectSchema' },\n { $ref: '#/$defs/arraySchema' },\n { $ref: '#/$defs/stringSchema' },\n { $ref: '#/$defs/numberSchema' },\n { $ref: '#/$defs/booleanSchema' },\n ],\n $defs: {\n stringArray: {\n type: 'array',\n items: { type: 'string' },\n uniqueItems: true,\n default: [],\n },\n refSchema: refMetaSchema,\n objectSchema: objectMetaSchema,\n stringSchema: stringMetaSchema,\n numberSchema: numberMetaSchema,\n booleanSchema: booleanMetaSchema,\n arraySchema: arrayMetaSchema,\n },\n};\n\nexport const notForeignKeyMetaSchema: Schema = {\n type: 'object',\n $dynamicAnchor: 'meta',\n oneOf: [\n { $ref: '#/$defs/refSchema' },\n { $ref: '#/$defs/objectSchema' },\n { $ref: '#/$defs/arraySchema' },\n { $ref: '#/$defs/stringSchema' },\n { $ref: '#/$defs/numberSchema' },\n { $ref: '#/$defs/booleanSchema' },\n ],\n $defs: {\n stringArray: {\n type: 'array',\n items: { type: 'string' },\n uniqueItems: true,\n default: [],\n },\n refSchema: refMetaSchema,\n objectSchema: objectMetaSchema,\n stringSchema: noForeignKeyStringMetaSchema,\n numberSchema: numberMetaSchema,\n booleanSchema: booleanMetaSchema,\n arraySchema: arrayMetaSchema,\n },\n};\n","import { Schema } from 'ajv/dist/2020';\nimport {\n arrayMetaSchema,\n booleanMetaSchema,\n numberMetaSchema,\n objectMetaSchema,\n stringMetaSchema,\n} from './meta-schema.js';\n\n// copied and modified from https://json.schemastore.org/json-patch\n\nexport const jsonPatchSchema: Schema = {\n $id: 'json-patch-schema.json',\n definitions: {\n path: {\n description: 'A JSON Pointer path.',\n type: 'string',\n },\n objectSchema: objectMetaSchema,\n stringSchema: stringMetaSchema,\n numberSchema: numberMetaSchema,\n booleanSchema: booleanMetaSchema,\n arraySchema: arrayMetaSchema,\n },\n minItems: 1,\n items: {\n oneOf: [\n {\n type: 'object',\n additionalProperties: false,\n required: ['value', 'op', 'path'],\n properties: {\n path: {\n $ref: '#/definitions/path',\n },\n op: {\n description: 'The operation to perform.',\n type: 'string',\n enum: ['add', 'replace'],\n },\n value: {\n $ref: 'meta-schema.json',\n description: 'The value to add, replace or test.',\n },\n },\n },\n {\n type: 'object',\n additionalProperties: false,\n required: ['op', 'path'],\n properties: {\n path: {\n $ref: '#/definitions/path',\n },\n op: {\n description: 'The operation to perform.',\n type: 'string',\n enum: ['remove'],\n },\n },\n },\n {\n type: 'object',\n additionalProperties: false,\n required: ['from', 'op', 'path'],\n properties: {\n path: {\n $ref: '#/definitions/path',\n },\n op: {\n description: 'The operation to perform.',\n type: 'string',\n enum: ['move', 'copy'],\n },\n from: {\n $ref: '#/definitions/path',\n description:\n 'A JSON Pointer path pointing to the location to move/copy from.',\n },\n },\n },\n ],\n },\n title: 'JSON schema for JSONPatch files',\n type: 'array',\n};\n","import { Schema } from 'ajv/dist/2020';\n\nexport const historyPatchesSchema: Schema = {\n $id: 'history-patches-schema.json',\n type: 'array',\n minItems: 1,\n items: {\n type: 'object',\n properties: {\n patches: {\n $ref: 'json-patch-schema.json',\n },\n hash: {\n type: 'string',\n },\n },\n required: ['patches', 'hash'],\n },\n};\n","import { Schema } from 'ajv/dist/2020';\n\nexport const tableMigrationsSchema: Schema = {\n $id: 'table-migrations-schema.json',\n oneOf: [\n { $ref: '#/definitions/InitMigration' },\n { $ref: '#/definitions/UpdateMigration' },\n { $ref: '#/definitions/RenameMigration' },\n { $ref: '#/definitions/RemoveMigration' },\n ],\n definitions: {\n InitMigration: {\n type: 'object',\n additionalProperties: false,\n required: ['changeType', 'tableId', 'hash', 'id', 'schema'],\n properties: {\n changeType: { type: 'string', const: 'init' },\n tableId: { type: 'string' },\n hash: { type: 'string' },\n id: { type: 'string' },\n schema: { $ref: 'meta-schema.json' },\n },\n },\n UpdateMigration: {\n type: 'object',\n additionalProperties: false,\n required: ['changeType', 'tableId', 'hash', 'id', 'patches'],\n properties: {\n changeType: { type: 'string', const: 'update' },\n tableId: { type: 'string' },\n hash: { type: 'string' },\n id: { type: 'string' },\n patches: { $ref: 'json-patch-schema.json' },\n },\n },\n RenameMigration: {\n type: 'object',\n additionalProperties: false,\n required: ['changeType', 'id', 'tableId', 'nextTableId'],\n properties: {\n changeType: { type: 'string', const: 'rename' },\n id: { type: 'string' },\n tableId: { type: 'string' },\n nextTableId: { type: 'string' },\n },\n },\n RemoveMigration: {\n type: 'object',\n additionalProperties: false,\n required: ['changeType', 'id', 'tableId'],\n properties: {\n changeType: { type: 'string', const: 'remove' },\n id: { type: 'string' },\n tableId: { type: 'string' },\n },\n },\n },\n title: 'JSON Schema for a Single Migration',\n};\n"]}
package/package.json ADDED
@@ -0,0 +1,169 @@
1
+ {
2
+ "name": "@revisium/schema-toolkit",
3
+ "version": "0.2.0",
4
+ "description": "Universal schema toolkit with TypeScript types and utilities for JSON Schema manipulation",
5
+ "keywords": [
6
+ "json-schema",
7
+ "schema",
8
+ "revisium",
9
+ "typescript"
10
+ ],
11
+ "repository": {
12
+ "type": "git",
13
+ "url": "https://github.com/revisium/schema-toolkit.git"
14
+ },
15
+ "license": "MIT",
16
+ "author": "Anton Kashirov",
17
+ "type": "module",
18
+ "exports": {
19
+ ".": {
20
+ "import": {
21
+ "types": "./dist/index.d.ts",
22
+ "default": "./dist/index.js"
23
+ },
24
+ "require": {
25
+ "types": "./dist/index.d.cts",
26
+ "default": "./dist/index.cjs"
27
+ }
28
+ },
29
+ "./types": {
30
+ "import": {
31
+ "types": "./dist/types/index.d.ts",
32
+ "default": "./dist/types/index.js"
33
+ },
34
+ "require": {
35
+ "types": "./dist/types/index.d.cts",
36
+ "default": "./dist/types/index.cjs"
37
+ }
38
+ },
39
+ "./plugins": {
40
+ "import": {
41
+ "types": "./dist/plugins/index.d.ts",
42
+ "default": "./dist/plugins/index.js"
43
+ },
44
+ "require": {
45
+ "types": "./dist/plugins/index.d.cts",
46
+ "default": "./dist/plugins/index.cjs"
47
+ }
48
+ },
49
+ "./mocks": {
50
+ "import": {
51
+ "types": "./dist/mocks/index.d.ts",
52
+ "default": "./dist/mocks/index.js"
53
+ },
54
+ "require": {
55
+ "types": "./dist/mocks/index.d.cts",
56
+ "default": "./dist/mocks/index.cjs"
57
+ }
58
+ },
59
+ "./consts": {
60
+ "import": {
61
+ "types": "./dist/consts/index.d.ts",
62
+ "default": "./dist/consts/index.js"
63
+ },
64
+ "require": {
65
+ "types": "./dist/consts/index.d.cts",
66
+ "default": "./dist/consts/index.cjs"
67
+ }
68
+ },
69
+ "./model": {
70
+ "import": {
71
+ "types": "./dist/model/index.d.ts",
72
+ "default": "./dist/model/index.js"
73
+ },
74
+ "require": {
75
+ "types": "./dist/model/index.d.cts",
76
+ "default": "./dist/model/index.cjs"
77
+ }
78
+ },
79
+ "./lib": {
80
+ "import": {
81
+ "types": "./dist/lib/index.d.ts",
82
+ "default": "./dist/lib/index.js"
83
+ },
84
+ "require": {
85
+ "types": "./dist/lib/index.d.cts",
86
+ "default": "./dist/lib/index.cjs"
87
+ }
88
+ },
89
+ "./validation-schemas": {
90
+ "import": {
91
+ "types": "./dist/validation-schemas/index.d.ts",
92
+ "default": "./dist/validation-schemas/index.js"
93
+ },
94
+ "require": {
95
+ "types": "./dist/validation-schemas/index.d.cts",
96
+ "default": "./dist/validation-schemas/index.cjs"
97
+ }
98
+ }
99
+ },
100
+ "main": "./dist/index.cjs",
101
+ "module": "./dist/index.js",
102
+ "types": "./dist/index.d.ts",
103
+ "typesVersions": {
104
+ "*": {
105
+ "types": [
106
+ "./dist/types/index.d.ts"
107
+ ],
108
+ "plugins": [
109
+ "./dist/plugins/index.d.ts"
110
+ ],
111
+ "mocks": [
112
+ "./dist/mocks/index.d.ts"
113
+ ],
114
+ "consts": [
115
+ "./dist/consts/index.d.ts"
116
+ ],
117
+ "model": [
118
+ "./dist/model/index.d.ts"
119
+ ],
120
+ "lib": [
121
+ "./dist/lib/index.d.ts"
122
+ ],
123
+ "validation-schemas": [
124
+ "./dist/validation-schemas/index.d.ts"
125
+ ]
126
+ }
127
+ },
128
+ "files": [
129
+ "dist"
130
+ ],
131
+ "scripts": {
132
+ "build": "tsup",
133
+ "dev": "tsup --watch",
134
+ "test": "NODE_OPTIONS=--experimental-vm-modules jest",
135
+ "test:watch": "NODE_OPTIONS=--experimental-vm-modules jest --watch",
136
+ "test:cov": "NODE_OPTIONS=--experimental-vm-modules jest --coverage --silent",
137
+ "lint:ci": "eslint . --max-warnings 0",
138
+ "lint:fix": "eslint . --fix",
139
+ "format": "prettier --write \"src/**/*.ts\"",
140
+ "format:check": "prettier --check \"src/**/*.ts\"",
141
+ "tsc": "tsc --noEmit",
142
+ "prepublishOnly": "npm run build && npm run tsc"
143
+ },
144
+ "devDependencies": {
145
+ "@eslint/js": "^9.15.0",
146
+ "@jest/globals": "^29.7.0",
147
+ "@types/jest": "^29.5.14",
148
+ "@types/node": "^22.10.1",
149
+ "ajv": "^8.17.1",
150
+ "ajv-formats": "^3.0.1",
151
+ "eslint": "^9.15.0",
152
+ "globals": "^15.12.0",
153
+ "jest": "^29.7.0",
154
+ "prettier": "^3.4.2",
155
+ "ts-jest": "^29.2.5",
156
+ "tsup": "^8.3.5",
157
+ "typescript": "^5.7.2",
158
+ "typescript-eslint": "^8.15.0"
159
+ },
160
+ "dependencies": {
161
+ "nanoid": "^3.3.7"
162
+ },
163
+ "engines": {
164
+ "node": ">=18.0.0"
165
+ },
166
+ "publishConfig": {
167
+ "access": "public"
168
+ }
169
+ }