@basictech/schema 0.6.0 → 0.7.0-beta.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/dist/index.js CHANGED
@@ -1,9 +1,7 @@
1
1
  "use strict";
2
- var __create = Object.create;
3
2
  var __defProp = Object.defineProperty;
4
3
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
4
  var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
7
5
  var __hasOwnProp = Object.prototype.hasOwnProperty;
8
6
  var __export = (target, all) => {
9
7
  for (var name in all)
@@ -17,14 +15,6 @@ var __copyProps = (to, from, except, desc) => {
17
15
  }
18
16
  return to;
19
17
  };
20
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
- // If the importer is in node compatibility mode or this is not an ESM
22
- // file that has been converted to a CommonJS file using a Babel-
23
- // compatible transform (i.e. "__esModule" has not been set), then set
24
- // "default" to the CommonJS "module.exports" for node compatibility.
25
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
- mod
27
- ));
28
18
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
19
 
30
20
  // index.ts
@@ -38,7 +28,608 @@ __export(schema_exports, {
38
28
  validateUpdateSchema: () => validateUpdateSchema
39
29
  });
40
30
  module.exports = __toCommonJS(schema_exports);
41
- var import_ajv = __toESM(require("ajv"));
31
+
32
+ // generated-validator.js
33
+ var validate = validate10;
34
+ var schema11 = { "$schema": "http://json-schema.org/draft-07/schema#", "type": "object", "properties": { "project_id": { "type": "string" }, "namespace": { "type": "string" }, "version": { "type": "integer", "minimum": 0 }, "tables": { "type": "object", "propertyNames": { "pattern": "^(?!id$|ID$|Id$|iD$)[a-zA-Z0-9][a-zA-Z0-9_]*$", "minLength": 1, "maxLength": 50, "type": "string" }, "patternProperties": { "^(?!id$|ID$|Id$|iD$)[a-zA-Z0-9][a-zA-Z0-9_]*$": { "type": "object", "propertyNames": { "pattern": "^(?!id$|ID$|Id$|iD$)[a-zA-Z0-9][a-zA-Z0-9_]*$", "minLength": 1, "maxLength": 50, "type": "string" }, "properties": { "name": { "type": "string" }, "type": { "type": "string", "enum": ["collection"] }, "origin": { "type": "object", "properties": { "type": { "type": "string", "enum": ["reference"] }, "project_id": { "type": "string" }, "table": { "type": "string" }, "version": { "type": "integer" } }, "if": { "properties": { "type": { "const": "reference" } } }, "then": { "required": ["project_id", "table"] } }, "fields": { "type": "object", "propertyNames": { "pattern": "^(?!id$|ID$|Id$|iD$)[a-zA-Z0-9][a-zA-Z0-9_]*$", "minLength": 1, "maxLength": 50, "type": "string" }, "patternProperties": { "^(?!id$|ID$|Id$|iD$)[a-zA-Z0-9][a-zA-Z0-9_]*$": { "type": "object", "properties": { "type": { "type": "string", "enum": ["string", "boolean", "number", "json"] }, "indexed": { "type": "boolean" }, "required": { "type": "boolean" } }, "required": ["type"] } }, "additionalProperties": true } }, "required": ["fields"] } }, "additionalProperties": true } }, "required": ["project_id", "version", "tables"] };
35
+ var ucs2length = (str) => [...str].length;
36
+ var func2 = ucs2length;
37
+ var pattern0 = new RegExp("^(?!id$|ID$|Id$|iD$)[a-zA-Z0-9][a-zA-Z0-9_]*$", "u");
38
+ function validate10(data, { instancePath = "", parentData, parentDataProperty, rootData = data } = {}) {
39
+ let vErrors = null;
40
+ let errors = 0;
41
+ const _errs0 = errors;
42
+ if (data && typeof data == "object" && !Array.isArray(data)) {
43
+ if (data.project_id === void 0) {
44
+ const err0 = { instancePath, schemaPath: "#/required", keyword: "required", params: { missingProperty: "project_id" }, message: "must have required property 'project_id'" };
45
+ if (vErrors === null) {
46
+ vErrors = [err0];
47
+ } else {
48
+ vErrors.push(err0);
49
+ }
50
+ errors++;
51
+ }
52
+ if (data.version === void 0) {
53
+ const err1 = { instancePath, schemaPath: "#/required", keyword: "required", params: { missingProperty: "version" }, message: "must have required property 'version'" };
54
+ if (vErrors === null) {
55
+ vErrors = [err1];
56
+ } else {
57
+ vErrors.push(err1);
58
+ }
59
+ errors++;
60
+ }
61
+ if (data.tables === void 0) {
62
+ const err2 = { instancePath, schemaPath: "#/required", keyword: "required", params: { missingProperty: "tables" }, message: "must have required property 'tables'" };
63
+ if (vErrors === null) {
64
+ vErrors = [err2];
65
+ } else {
66
+ vErrors.push(err2);
67
+ }
68
+ errors++;
69
+ }
70
+ if (data.project_id !== void 0) {
71
+ let data0 = data.project_id;
72
+ const _errs1 = errors;
73
+ if (typeof data0 !== "string") {
74
+ const err3 = { instancePath: instancePath + "/project_id", schemaPath: "#/properties/project_id/type", keyword: "type", params: { type: "string" }, message: "must be string" };
75
+ if (vErrors === null) {
76
+ vErrors = [err3];
77
+ } else {
78
+ vErrors.push(err3);
79
+ }
80
+ errors++;
81
+ }
82
+ const _errs2 = errors;
83
+ var valid0 = _errs1 === errors;
84
+ }
85
+ if (data.namespace !== void 0) {
86
+ let data1 = data.namespace;
87
+ const _errs3 = errors;
88
+ if (typeof data1 !== "string") {
89
+ const err4 = { instancePath: instancePath + "/namespace", schemaPath: "#/properties/namespace/type", keyword: "type", params: { type: "string" }, message: "must be string" };
90
+ if (vErrors === null) {
91
+ vErrors = [err4];
92
+ } else {
93
+ vErrors.push(err4);
94
+ }
95
+ errors++;
96
+ }
97
+ const _errs4 = errors;
98
+ var valid0 = _errs3 === errors;
99
+ }
100
+ if (data.version !== void 0) {
101
+ let data2 = data.version;
102
+ const _errs5 = errors;
103
+ if (!(typeof data2 == "number" && (!(data2 % 1) && !isNaN(data2)))) {
104
+ const err5 = { instancePath: instancePath + "/version", schemaPath: "#/properties/version/type", keyword: "type", params: { type: "integer" }, message: "must be integer" };
105
+ if (vErrors === null) {
106
+ vErrors = [err5];
107
+ } else {
108
+ vErrors.push(err5);
109
+ }
110
+ errors++;
111
+ }
112
+ const _errs6 = errors;
113
+ if (typeof data2 == "number") {
114
+ if (data2 < 0 || isNaN(data2)) {
115
+ const err6 = { instancePath: instancePath + "/version", schemaPath: "#/properties/version/minimum", keyword: "minimum", params: { comparison: ">=", limit: 0 }, message: "must be >= 0" };
116
+ if (vErrors === null) {
117
+ vErrors = [err6];
118
+ } else {
119
+ vErrors.push(err6);
120
+ }
121
+ errors++;
122
+ }
123
+ }
124
+ var valid0 = _errs5 === errors;
125
+ }
126
+ if (data.tables !== void 0) {
127
+ let data3 = data.tables;
128
+ const _errs7 = errors;
129
+ const _errs8 = errors;
130
+ if (data3 && typeof data3 == "object" && !Array.isArray(data3)) {
131
+ for (const key0 in data3) {
132
+ const _errs9 = errors;
133
+ const _errs10 = errors;
134
+ if (typeof key0 === "string") {
135
+ if (func2(key0) > 50) {
136
+ const err7 = { instancePath: instancePath + "/tables", schemaPath: "#/properties/tables/propertyNames/maxLength", keyword: "maxLength", params: { limit: 50 }, message: "must NOT have more than 50 characters", propertyName: key0 };
137
+ if (vErrors === null) {
138
+ vErrors = [err7];
139
+ } else {
140
+ vErrors.push(err7);
141
+ }
142
+ errors++;
143
+ }
144
+ if (func2(key0) < 1) {
145
+ const err8 = { instancePath: instancePath + "/tables", schemaPath: "#/properties/tables/propertyNames/minLength", keyword: "minLength", params: { limit: 1 }, message: "must NOT have fewer than 1 characters", propertyName: key0 };
146
+ if (vErrors === null) {
147
+ vErrors = [err8];
148
+ } else {
149
+ vErrors.push(err8);
150
+ }
151
+ errors++;
152
+ }
153
+ if (!pattern0.test(key0)) {
154
+ const err9 = { instancePath: instancePath + "/tables", schemaPath: "#/properties/tables/propertyNames/pattern", keyword: "pattern", params: { pattern: "^(?!id$|ID$|Id$|iD$)[a-zA-Z0-9][a-zA-Z0-9_]*$" }, message: 'must match pattern "^(?!id$|ID$|Id$|iD$)[a-zA-Z0-9][a-zA-Z0-9_]*$"', propertyName: key0 };
155
+ if (vErrors === null) {
156
+ vErrors = [err9];
157
+ } else {
158
+ vErrors.push(err9);
159
+ }
160
+ errors++;
161
+ }
162
+ } else {
163
+ const err10 = { instancePath: instancePath + "/tables", schemaPath: "#/properties/tables/propertyNames/type", keyword: "type", params: { type: "string" }, message: "must be string", propertyName: key0 };
164
+ if (vErrors === null) {
165
+ vErrors = [err10];
166
+ } else {
167
+ vErrors.push(err10);
168
+ }
169
+ errors++;
170
+ }
171
+ var valid1 = _errs9 === errors;
172
+ if (!valid1) {
173
+ const err11 = { instancePath: instancePath + "/tables", schemaPath: "#/properties/tables/propertyNames", keyword: "propertyNames", params: { propertyName: key0 }, message: "property name must be valid" };
174
+ if (vErrors === null) {
175
+ vErrors = [err11];
176
+ } else {
177
+ vErrors.push(err11);
178
+ }
179
+ errors++;
180
+ }
181
+ }
182
+ const _errs11 = errors;
183
+ for (const key1 in data3) {
184
+ if (pattern0.test(key1)) {
185
+ let data4 = data3[key1];
186
+ const _errs12 = errors;
187
+ const _errs13 = errors;
188
+ if (data4 && typeof data4 == "object" && !Array.isArray(data4)) {
189
+ if (data4.fields === void 0) {
190
+ const err12 = { instancePath: instancePath + "/tables/" + key1.replace(/~/g, "~0").replace(/\//g, "~1"), schemaPath: "#/properties/tables/patternProperties/%5E(%3F!id%24%7CID%24%7CId%24%7CiD%24)%5Ba-zA-Z0-9%5D%5Ba-zA-Z0-9_%5D*%24/required", keyword: "required", params: { missingProperty: "fields" }, message: "must have required property 'fields'" };
191
+ if (vErrors === null) {
192
+ vErrors = [err12];
193
+ } else {
194
+ vErrors.push(err12);
195
+ }
196
+ errors++;
197
+ }
198
+ for (const key2 in data4) {
199
+ const _errs14 = errors;
200
+ const _errs15 = errors;
201
+ if (typeof key2 === "string") {
202
+ if (func2(key2) > 50) {
203
+ const err13 = { instancePath: instancePath + "/tables/" + key1.replace(/~/g, "~0").replace(/\//g, "~1"), schemaPath: "#/properties/tables/patternProperties/%5E(%3F!id%24%7CID%24%7CId%24%7CiD%24)%5Ba-zA-Z0-9%5D%5Ba-zA-Z0-9_%5D*%24/propertyNames/maxLength", keyword: "maxLength", params: { limit: 50 }, message: "must NOT have more than 50 characters", propertyName: key2 };
204
+ if (vErrors === null) {
205
+ vErrors = [err13];
206
+ } else {
207
+ vErrors.push(err13);
208
+ }
209
+ errors++;
210
+ }
211
+ if (func2(key2) < 1) {
212
+ const err14 = { instancePath: instancePath + "/tables/" + key1.replace(/~/g, "~0").replace(/\//g, "~1"), schemaPath: "#/properties/tables/patternProperties/%5E(%3F!id%24%7CID%24%7CId%24%7CiD%24)%5Ba-zA-Z0-9%5D%5Ba-zA-Z0-9_%5D*%24/propertyNames/minLength", keyword: "minLength", params: { limit: 1 }, message: "must NOT have fewer than 1 characters", propertyName: key2 };
213
+ if (vErrors === null) {
214
+ vErrors = [err14];
215
+ } else {
216
+ vErrors.push(err14);
217
+ }
218
+ errors++;
219
+ }
220
+ if (!pattern0.test(key2)) {
221
+ const err15 = { instancePath: instancePath + "/tables/" + key1.replace(/~/g, "~0").replace(/\//g, "~1"), schemaPath: "#/properties/tables/patternProperties/%5E(%3F!id%24%7CID%24%7CId%24%7CiD%24)%5Ba-zA-Z0-9%5D%5Ba-zA-Z0-9_%5D*%24/propertyNames/pattern", keyword: "pattern", params: { pattern: "^(?!id$|ID$|Id$|iD$)[a-zA-Z0-9][a-zA-Z0-9_]*$" }, message: 'must match pattern "^(?!id$|ID$|Id$|iD$)[a-zA-Z0-9][a-zA-Z0-9_]*$"', propertyName: key2 };
222
+ if (vErrors === null) {
223
+ vErrors = [err15];
224
+ } else {
225
+ vErrors.push(err15);
226
+ }
227
+ errors++;
228
+ }
229
+ } else {
230
+ const err16 = { instancePath: instancePath + "/tables/" + key1.replace(/~/g, "~0").replace(/\//g, "~1"), schemaPath: "#/properties/tables/patternProperties/%5E(%3F!id%24%7CID%24%7CId%24%7CiD%24)%5Ba-zA-Z0-9%5D%5Ba-zA-Z0-9_%5D*%24/propertyNames/type", keyword: "type", params: { type: "string" }, message: "must be string", propertyName: key2 };
231
+ if (vErrors === null) {
232
+ vErrors = [err16];
233
+ } else {
234
+ vErrors.push(err16);
235
+ }
236
+ errors++;
237
+ }
238
+ var valid3 = _errs14 === errors;
239
+ if (!valid3) {
240
+ const err17 = { instancePath: instancePath + "/tables/" + key1.replace(/~/g, "~0").replace(/\//g, "~1"), schemaPath: "#/properties/tables/patternProperties/%5E(%3F!id%24%7CID%24%7CId%24%7CiD%24)%5Ba-zA-Z0-9%5D%5Ba-zA-Z0-9_%5D*%24/propertyNames", keyword: "propertyNames", params: { propertyName: key2 }, message: "property name must be valid" };
241
+ if (vErrors === null) {
242
+ vErrors = [err17];
243
+ } else {
244
+ vErrors.push(err17);
245
+ }
246
+ errors++;
247
+ }
248
+ }
249
+ if (data4.name !== void 0) {
250
+ let data5 = data4.name;
251
+ const _errs16 = errors;
252
+ if (typeof data5 !== "string") {
253
+ const err18 = { instancePath: instancePath + "/tables/" + key1.replace(/~/g, "~0").replace(/\//g, "~1") + "/name", schemaPath: "#/properties/tables/patternProperties/%5E(%3F!id%24%7CID%24%7CId%24%7CiD%24)%5Ba-zA-Z0-9%5D%5Ba-zA-Z0-9_%5D*%24/properties/name/type", keyword: "type", params: { type: "string" }, message: "must be string" };
254
+ if (vErrors === null) {
255
+ vErrors = [err18];
256
+ } else {
257
+ vErrors.push(err18);
258
+ }
259
+ errors++;
260
+ }
261
+ const _errs17 = errors;
262
+ var valid4 = _errs16 === errors;
263
+ }
264
+ if (data4.type !== void 0) {
265
+ let data6 = data4.type;
266
+ const _errs18 = errors;
267
+ if (typeof data6 !== "string") {
268
+ const err19 = { instancePath: instancePath + "/tables/" + key1.replace(/~/g, "~0").replace(/\//g, "~1") + "/type", schemaPath: "#/properties/tables/patternProperties/%5E(%3F!id%24%7CID%24%7CId%24%7CiD%24)%5Ba-zA-Z0-9%5D%5Ba-zA-Z0-9_%5D*%24/properties/type/type", keyword: "type", params: { type: "string" }, message: "must be string" };
269
+ if (vErrors === null) {
270
+ vErrors = [err19];
271
+ } else {
272
+ vErrors.push(err19);
273
+ }
274
+ errors++;
275
+ }
276
+ const _errs19 = errors;
277
+ const vSchema0 = schema11.properties.tables.patternProperties["^(?!id$|ID$|Id$|iD$)[a-zA-Z0-9][a-zA-Z0-9_]*$"].properties.type.enum;
278
+ if (!(data6 === "collection")) {
279
+ const err20 = { instancePath: instancePath + "/tables/" + key1.replace(/~/g, "~0").replace(/\//g, "~1") + "/type", schemaPath: "#/properties/tables/patternProperties/%5E(%3F!id%24%7CID%24%7CId%24%7CiD%24)%5Ba-zA-Z0-9%5D%5Ba-zA-Z0-9_%5D*%24/properties/type/enum", keyword: "enum", params: { allowedValues: schema11.properties.tables.patternProperties["^(?!id$|ID$|Id$|iD$)[a-zA-Z0-9][a-zA-Z0-9_]*$"].properties.type.enum }, message: "must be equal to one of the allowed values" };
280
+ if (vErrors === null) {
281
+ vErrors = [err20];
282
+ } else {
283
+ vErrors.push(err20);
284
+ }
285
+ errors++;
286
+ }
287
+ var valid4 = _errs18 === errors;
288
+ }
289
+ if (data4.origin !== void 0) {
290
+ let data7 = data4.origin;
291
+ const _errs20 = errors;
292
+ const _errs21 = errors;
293
+ const _errs22 = errors;
294
+ let valid5 = true;
295
+ const _errs23 = errors;
296
+ if (data7 && typeof data7 == "object" && !Array.isArray(data7)) {
297
+ if (data7.type !== void 0) {
298
+ let data8 = data7.type;
299
+ const _errs24 = errors;
300
+ if ("reference" !== data8) {
301
+ const err21 = {};
302
+ if (vErrors === null) {
303
+ vErrors = [err21];
304
+ } else {
305
+ vErrors.push(err21);
306
+ }
307
+ errors++;
308
+ } else {
309
+ }
310
+ if (errors === _errs24) {
311
+ }
312
+ var valid6 = _errs24 === errors;
313
+ } else {
314
+ var valid6 = true;
315
+ }
316
+ if (valid6) {
317
+ }
318
+ }
319
+ if (errors === _errs23) {
320
+ }
321
+ var _valid0 = _errs23 === errors;
322
+ errors = _errs22;
323
+ if (vErrors !== null) {
324
+ if (_errs22) {
325
+ vErrors.length = _errs22;
326
+ } else {
327
+ vErrors = null;
328
+ }
329
+ }
330
+ if (_valid0) {
331
+ const _errs25 = errors;
332
+ if (data7 && typeof data7 == "object" && !Array.isArray(data7)) {
333
+ if (data7.project_id === void 0) {
334
+ const err22 = { instancePath: instancePath + "/tables/" + key1.replace(/~/g, "~0").replace(/\//g, "~1") + "/origin", schemaPath: "#/properties/tables/patternProperties/%5E(%3F!id%24%7CID%24%7CId%24%7CiD%24)%5Ba-zA-Z0-9%5D%5Ba-zA-Z0-9_%5D*%24/properties/origin/then/required", keyword: "required", params: { missingProperty: "project_id" }, message: "must have required property 'project_id'" };
335
+ if (vErrors === null) {
336
+ vErrors = [err22];
337
+ } else {
338
+ vErrors.push(err22);
339
+ }
340
+ errors++;
341
+ }
342
+ if (data7.table === void 0) {
343
+ const err23 = { instancePath: instancePath + "/tables/" + key1.replace(/~/g, "~0").replace(/\//g, "~1") + "/origin", schemaPath: "#/properties/tables/patternProperties/%5E(%3F!id%24%7CID%24%7CId%24%7CiD%24)%5Ba-zA-Z0-9%5D%5Ba-zA-Z0-9_%5D*%24/properties/origin/then/required", keyword: "required", params: { missingProperty: "table" }, message: "must have required property 'table'" };
344
+ if (vErrors === null) {
345
+ vErrors = [err23];
346
+ } else {
347
+ vErrors.push(err23);
348
+ }
349
+ errors++;
350
+ }
351
+ }
352
+ var _valid0 = _errs25 === errors;
353
+ valid5 = _valid0;
354
+ }
355
+ if (!valid5) {
356
+ const err24 = { instancePath: instancePath + "/tables/" + key1.replace(/~/g, "~0").replace(/\//g, "~1") + "/origin", schemaPath: "#/properties/tables/patternProperties/%5E(%3F!id%24%7CID%24%7CId%24%7CiD%24)%5Ba-zA-Z0-9%5D%5Ba-zA-Z0-9_%5D*%24/properties/origin/if", keyword: "if", params: { failingKeyword: "then" }, message: 'must match "then" schema' };
357
+ if (vErrors === null) {
358
+ vErrors = [err24];
359
+ } else {
360
+ vErrors.push(err24);
361
+ }
362
+ errors++;
363
+ }
364
+ if (data7 && typeof data7 == "object" && !Array.isArray(data7)) {
365
+ if (data7.type !== void 0) {
366
+ let data9 = data7.type;
367
+ const _errs26 = errors;
368
+ if (typeof data9 !== "string") {
369
+ const err25 = { instancePath: instancePath + "/tables/" + key1.replace(/~/g, "~0").replace(/\//g, "~1") + "/origin/type", schemaPath: "#/properties/tables/patternProperties/%5E(%3F!id%24%7CID%24%7CId%24%7CiD%24)%5Ba-zA-Z0-9%5D%5Ba-zA-Z0-9_%5D*%24/properties/origin/properties/type/type", keyword: "type", params: { type: "string" }, message: "must be string" };
370
+ if (vErrors === null) {
371
+ vErrors = [err25];
372
+ } else {
373
+ vErrors.push(err25);
374
+ }
375
+ errors++;
376
+ }
377
+ const _errs27 = errors;
378
+ const vSchema1 = schema11.properties.tables.patternProperties["^(?!id$|ID$|Id$|iD$)[a-zA-Z0-9][a-zA-Z0-9_]*$"].properties.origin.properties.type.enum;
379
+ if (!(data9 === "reference")) {
380
+ const err26 = { instancePath: instancePath + "/tables/" + key1.replace(/~/g, "~0").replace(/\//g, "~1") + "/origin/type", schemaPath: "#/properties/tables/patternProperties/%5E(%3F!id%24%7CID%24%7CId%24%7CiD%24)%5Ba-zA-Z0-9%5D%5Ba-zA-Z0-9_%5D*%24/properties/origin/properties/type/enum", keyword: "enum", params: { allowedValues: schema11.properties.tables.patternProperties["^(?!id$|ID$|Id$|iD$)[a-zA-Z0-9][a-zA-Z0-9_]*$"].properties.origin.properties.type.enum }, message: "must be equal to one of the allowed values" };
381
+ if (vErrors === null) {
382
+ vErrors = [err26];
383
+ } else {
384
+ vErrors.push(err26);
385
+ }
386
+ errors++;
387
+ }
388
+ var valid7 = _errs26 === errors;
389
+ }
390
+ if (data7.project_id !== void 0) {
391
+ let data10 = data7.project_id;
392
+ const _errs28 = errors;
393
+ if (typeof data10 !== "string") {
394
+ const err27 = { instancePath: instancePath + "/tables/" + key1.replace(/~/g, "~0").replace(/\//g, "~1") + "/origin/project_id", schemaPath: "#/properties/tables/patternProperties/%5E(%3F!id%24%7CID%24%7CId%24%7CiD%24)%5Ba-zA-Z0-9%5D%5Ba-zA-Z0-9_%5D*%24/properties/origin/properties/project_id/type", keyword: "type", params: { type: "string" }, message: "must be string" };
395
+ if (vErrors === null) {
396
+ vErrors = [err27];
397
+ } else {
398
+ vErrors.push(err27);
399
+ }
400
+ errors++;
401
+ }
402
+ const _errs29 = errors;
403
+ var valid7 = _errs28 === errors;
404
+ }
405
+ if (data7.table !== void 0) {
406
+ let data11 = data7.table;
407
+ const _errs30 = errors;
408
+ if (typeof data11 !== "string") {
409
+ const err28 = { instancePath: instancePath + "/tables/" + key1.replace(/~/g, "~0").replace(/\//g, "~1") + "/origin/table", schemaPath: "#/properties/tables/patternProperties/%5E(%3F!id%24%7CID%24%7CId%24%7CiD%24)%5Ba-zA-Z0-9%5D%5Ba-zA-Z0-9_%5D*%24/properties/origin/properties/table/type", keyword: "type", params: { type: "string" }, message: "must be string" };
410
+ if (vErrors === null) {
411
+ vErrors = [err28];
412
+ } else {
413
+ vErrors.push(err28);
414
+ }
415
+ errors++;
416
+ }
417
+ const _errs31 = errors;
418
+ var valid7 = _errs30 === errors;
419
+ }
420
+ if (data7.version !== void 0) {
421
+ let data12 = data7.version;
422
+ const _errs32 = errors;
423
+ if (!(typeof data12 == "number" && (!(data12 % 1) && !isNaN(data12)))) {
424
+ const err29 = { instancePath: instancePath + "/tables/" + key1.replace(/~/g, "~0").replace(/\//g, "~1") + "/origin/version", schemaPath: "#/properties/tables/patternProperties/%5E(%3F!id%24%7CID%24%7CId%24%7CiD%24)%5Ba-zA-Z0-9%5D%5Ba-zA-Z0-9_%5D*%24/properties/origin/properties/version/type", keyword: "type", params: { type: "integer" }, message: "must be integer" };
425
+ if (vErrors === null) {
426
+ vErrors = [err29];
427
+ } else {
428
+ vErrors.push(err29);
429
+ }
430
+ errors++;
431
+ }
432
+ const _errs33 = errors;
433
+ var valid7 = _errs32 === errors;
434
+ }
435
+ } else {
436
+ const err30 = { instancePath: instancePath + "/tables/" + key1.replace(/~/g, "~0").replace(/\//g, "~1") + "/origin", schemaPath: "#/properties/tables/patternProperties/%5E(%3F!id%24%7CID%24%7CId%24%7CiD%24)%5Ba-zA-Z0-9%5D%5Ba-zA-Z0-9_%5D*%24/properties/origin/type", keyword: "type", params: { type: "object" }, message: "must be object" };
437
+ if (vErrors === null) {
438
+ vErrors = [err30];
439
+ } else {
440
+ vErrors.push(err30);
441
+ }
442
+ errors++;
443
+ }
444
+ var valid4 = _errs20 === errors;
445
+ }
446
+ if (data4.fields !== void 0) {
447
+ let data13 = data4.fields;
448
+ const _errs34 = errors;
449
+ const _errs35 = errors;
450
+ if (data13 && typeof data13 == "object" && !Array.isArray(data13)) {
451
+ for (const key3 in data13) {
452
+ const _errs36 = errors;
453
+ const _errs37 = errors;
454
+ if (typeof key3 === "string") {
455
+ if (func2(key3) > 50) {
456
+ const err31 = { instancePath: instancePath + "/tables/" + key1.replace(/~/g, "~0").replace(/\//g, "~1") + "/fields", schemaPath: "#/properties/tables/patternProperties/%5E(%3F!id%24%7CID%24%7CId%24%7CiD%24)%5Ba-zA-Z0-9%5D%5Ba-zA-Z0-9_%5D*%24/properties/fields/propertyNames/maxLength", keyword: "maxLength", params: { limit: 50 }, message: "must NOT have more than 50 characters", propertyName: key3 };
457
+ if (vErrors === null) {
458
+ vErrors = [err31];
459
+ } else {
460
+ vErrors.push(err31);
461
+ }
462
+ errors++;
463
+ }
464
+ if (func2(key3) < 1) {
465
+ const err32 = { instancePath: instancePath + "/tables/" + key1.replace(/~/g, "~0").replace(/\//g, "~1") + "/fields", schemaPath: "#/properties/tables/patternProperties/%5E(%3F!id%24%7CID%24%7CId%24%7CiD%24)%5Ba-zA-Z0-9%5D%5Ba-zA-Z0-9_%5D*%24/properties/fields/propertyNames/minLength", keyword: "minLength", params: { limit: 1 }, message: "must NOT have fewer than 1 characters", propertyName: key3 };
466
+ if (vErrors === null) {
467
+ vErrors = [err32];
468
+ } else {
469
+ vErrors.push(err32);
470
+ }
471
+ errors++;
472
+ }
473
+ if (!pattern0.test(key3)) {
474
+ const err33 = { instancePath: instancePath + "/tables/" + key1.replace(/~/g, "~0").replace(/\//g, "~1") + "/fields", schemaPath: "#/properties/tables/patternProperties/%5E(%3F!id%24%7CID%24%7CId%24%7CiD%24)%5Ba-zA-Z0-9%5D%5Ba-zA-Z0-9_%5D*%24/properties/fields/propertyNames/pattern", keyword: "pattern", params: { pattern: "^(?!id$|ID$|Id$|iD$)[a-zA-Z0-9][a-zA-Z0-9_]*$" }, message: 'must match pattern "^(?!id$|ID$|Id$|iD$)[a-zA-Z0-9][a-zA-Z0-9_]*$"', propertyName: key3 };
475
+ if (vErrors === null) {
476
+ vErrors = [err33];
477
+ } else {
478
+ vErrors.push(err33);
479
+ }
480
+ errors++;
481
+ }
482
+ } else {
483
+ const err34 = { instancePath: instancePath + "/tables/" + key1.replace(/~/g, "~0").replace(/\//g, "~1") + "/fields", schemaPath: "#/properties/tables/patternProperties/%5E(%3F!id%24%7CID%24%7CId%24%7CiD%24)%5Ba-zA-Z0-9%5D%5Ba-zA-Z0-9_%5D*%24/properties/fields/propertyNames/type", keyword: "type", params: { type: "string" }, message: "must be string", propertyName: key3 };
484
+ if (vErrors === null) {
485
+ vErrors = [err34];
486
+ } else {
487
+ vErrors.push(err34);
488
+ }
489
+ errors++;
490
+ }
491
+ var valid8 = _errs36 === errors;
492
+ if (!valid8) {
493
+ const err35 = { instancePath: instancePath + "/tables/" + key1.replace(/~/g, "~0").replace(/\//g, "~1") + "/fields", schemaPath: "#/properties/tables/patternProperties/%5E(%3F!id%24%7CID%24%7CId%24%7CiD%24)%5Ba-zA-Z0-9%5D%5Ba-zA-Z0-9_%5D*%24/properties/fields/propertyNames", keyword: "propertyNames", params: { propertyName: key3 }, message: "property name must be valid" };
494
+ if (vErrors === null) {
495
+ vErrors = [err35];
496
+ } else {
497
+ vErrors.push(err35);
498
+ }
499
+ errors++;
500
+ }
501
+ }
502
+ const _errs38 = errors;
503
+ for (const key4 in data13) {
504
+ if (pattern0.test(key4)) {
505
+ let data14 = data13[key4];
506
+ const _errs39 = errors;
507
+ const _errs40 = errors;
508
+ if (data14 && typeof data14 == "object" && !Array.isArray(data14)) {
509
+ if (data14.type === void 0) {
510
+ const err36 = { instancePath: instancePath + "/tables/" + key1.replace(/~/g, "~0").replace(/\//g, "~1") + "/fields/" + key4.replace(/~/g, "~0").replace(/\//g, "~1"), schemaPath: "#/properties/tables/patternProperties/%5E(%3F!id%24%7CID%24%7CId%24%7CiD%24)%5Ba-zA-Z0-9%5D%5Ba-zA-Z0-9_%5D*%24/properties/fields/patternProperties/%5E(%3F!id%24%7CID%24%7CId%24%7CiD%24)%5Ba-zA-Z0-9%5D%5Ba-zA-Z0-9_%5D*%24/required", keyword: "required", params: { missingProperty: "type" }, message: "must have required property 'type'" };
511
+ if (vErrors === null) {
512
+ vErrors = [err36];
513
+ } else {
514
+ vErrors.push(err36);
515
+ }
516
+ errors++;
517
+ }
518
+ if (data14.type !== void 0) {
519
+ let data15 = data14.type;
520
+ const _errs41 = errors;
521
+ if (typeof data15 !== "string") {
522
+ const err37 = { instancePath: instancePath + "/tables/" + key1.replace(/~/g, "~0").replace(/\//g, "~1") + "/fields/" + key4.replace(/~/g, "~0").replace(/\//g, "~1") + "/type", schemaPath: "#/properties/tables/patternProperties/%5E(%3F!id%24%7CID%24%7CId%24%7CiD%24)%5Ba-zA-Z0-9%5D%5Ba-zA-Z0-9_%5D*%24/properties/fields/patternProperties/%5E(%3F!id%24%7CID%24%7CId%24%7CiD%24)%5Ba-zA-Z0-9%5D%5Ba-zA-Z0-9_%5D*%24/properties/type/type", keyword: "type", params: { type: "string" }, message: "must be string" };
523
+ if (vErrors === null) {
524
+ vErrors = [err37];
525
+ } else {
526
+ vErrors.push(err37);
527
+ }
528
+ errors++;
529
+ }
530
+ const _errs42 = errors;
531
+ const vSchema2 = schema11.properties.tables.patternProperties["^(?!id$|ID$|Id$|iD$)[a-zA-Z0-9][a-zA-Z0-9_]*$"].properties.fields.patternProperties["^(?!id$|ID$|Id$|iD$)[a-zA-Z0-9][a-zA-Z0-9_]*$"].properties.type.enum;
532
+ if (!(data15 === "string" || data15 === "boolean" || data15 === "number" || data15 === "json")) {
533
+ const err38 = { instancePath: instancePath + "/tables/" + key1.replace(/~/g, "~0").replace(/\//g, "~1") + "/fields/" + key4.replace(/~/g, "~0").replace(/\//g, "~1") + "/type", schemaPath: "#/properties/tables/patternProperties/%5E(%3F!id%24%7CID%24%7CId%24%7CiD%24)%5Ba-zA-Z0-9%5D%5Ba-zA-Z0-9_%5D*%24/properties/fields/patternProperties/%5E(%3F!id%24%7CID%24%7CId%24%7CiD%24)%5Ba-zA-Z0-9%5D%5Ba-zA-Z0-9_%5D*%24/properties/type/enum", keyword: "enum", params: { allowedValues: schema11.properties.tables.patternProperties["^(?!id$|ID$|Id$|iD$)[a-zA-Z0-9][a-zA-Z0-9_]*$"].properties.fields.patternProperties["^(?!id$|ID$|Id$|iD$)[a-zA-Z0-9][a-zA-Z0-9_]*$"].properties.type.enum }, message: "must be equal to one of the allowed values" };
534
+ if (vErrors === null) {
535
+ vErrors = [err38];
536
+ } else {
537
+ vErrors.push(err38);
538
+ }
539
+ errors++;
540
+ }
541
+ var valid10 = _errs41 === errors;
542
+ }
543
+ if (data14.indexed !== void 0) {
544
+ let data16 = data14.indexed;
545
+ const _errs43 = errors;
546
+ if (typeof data16 !== "boolean") {
547
+ const err39 = { instancePath: instancePath + "/tables/" + key1.replace(/~/g, "~0").replace(/\//g, "~1") + "/fields/" + key4.replace(/~/g, "~0").replace(/\//g, "~1") + "/indexed", schemaPath: "#/properties/tables/patternProperties/%5E(%3F!id%24%7CID%24%7CId%24%7CiD%24)%5Ba-zA-Z0-9%5D%5Ba-zA-Z0-9_%5D*%24/properties/fields/patternProperties/%5E(%3F!id%24%7CID%24%7CId%24%7CiD%24)%5Ba-zA-Z0-9%5D%5Ba-zA-Z0-9_%5D*%24/properties/indexed/type", keyword: "type", params: { type: "boolean" }, message: "must be boolean" };
548
+ if (vErrors === null) {
549
+ vErrors = [err39];
550
+ } else {
551
+ vErrors.push(err39);
552
+ }
553
+ errors++;
554
+ }
555
+ const _errs44 = errors;
556
+ var valid10 = _errs43 === errors;
557
+ }
558
+ if (data14.required !== void 0) {
559
+ let data17 = data14.required;
560
+ const _errs45 = errors;
561
+ if (typeof data17 !== "boolean") {
562
+ const err40 = { instancePath: instancePath + "/tables/" + key1.replace(/~/g, "~0").replace(/\//g, "~1") + "/fields/" + key4.replace(/~/g, "~0").replace(/\//g, "~1") + "/required", schemaPath: "#/properties/tables/patternProperties/%5E(%3F!id%24%7CID%24%7CId%24%7CiD%24)%5Ba-zA-Z0-9%5D%5Ba-zA-Z0-9_%5D*%24/properties/fields/patternProperties/%5E(%3F!id%24%7CID%24%7CId%24%7CiD%24)%5Ba-zA-Z0-9%5D%5Ba-zA-Z0-9_%5D*%24/properties/required/type", keyword: "type", params: { type: "boolean" }, message: "must be boolean" };
563
+ if (vErrors === null) {
564
+ vErrors = [err40];
565
+ } else {
566
+ vErrors.push(err40);
567
+ }
568
+ errors++;
569
+ }
570
+ const _errs46 = errors;
571
+ var valid10 = _errs45 === errors;
572
+ }
573
+ } else {
574
+ const err41 = { instancePath: instancePath + "/tables/" + key1.replace(/~/g, "~0").replace(/\//g, "~1") + "/fields/" + key4.replace(/~/g, "~0").replace(/\//g, "~1"), schemaPath: "#/properties/tables/patternProperties/%5E(%3F!id%24%7CID%24%7CId%24%7CiD%24)%5Ba-zA-Z0-9%5D%5Ba-zA-Z0-9_%5D*%24/properties/fields/patternProperties/%5E(%3F!id%24%7CID%24%7CId%24%7CiD%24)%5Ba-zA-Z0-9%5D%5Ba-zA-Z0-9_%5D*%24/type", keyword: "type", params: { type: "object" }, message: "must be object" };
575
+ if (vErrors === null) {
576
+ vErrors = [err41];
577
+ } else {
578
+ vErrors.push(err41);
579
+ }
580
+ errors++;
581
+ }
582
+ var valid9 = _errs39 === errors;
583
+ }
584
+ }
585
+ } else {
586
+ const err42 = { instancePath: instancePath + "/tables/" + key1.replace(/~/g, "~0").replace(/\//g, "~1") + "/fields", schemaPath: "#/properties/tables/patternProperties/%5E(%3F!id%24%7CID%24%7CId%24%7CiD%24)%5Ba-zA-Z0-9%5D%5Ba-zA-Z0-9_%5D*%24/properties/fields/type", keyword: "type", params: { type: "object" }, message: "must be object" };
587
+ if (vErrors === null) {
588
+ vErrors = [err42];
589
+ } else {
590
+ vErrors.push(err42);
591
+ }
592
+ errors++;
593
+ }
594
+ var valid4 = _errs34 === errors;
595
+ }
596
+ } else {
597
+ const err43 = { instancePath: instancePath + "/tables/" + key1.replace(/~/g, "~0").replace(/\//g, "~1"), schemaPath: "#/properties/tables/patternProperties/%5E(%3F!id%24%7CID%24%7CId%24%7CiD%24)%5Ba-zA-Z0-9%5D%5Ba-zA-Z0-9_%5D*%24/type", keyword: "type", params: { type: "object" }, message: "must be object" };
598
+ if (vErrors === null) {
599
+ vErrors = [err43];
600
+ } else {
601
+ vErrors.push(err43);
602
+ }
603
+ errors++;
604
+ }
605
+ var valid2 = _errs12 === errors;
606
+ }
607
+ }
608
+ } else {
609
+ const err44 = { instancePath: instancePath + "/tables", schemaPath: "#/properties/tables/type", keyword: "type", params: { type: "object" }, message: "must be object" };
610
+ if (vErrors === null) {
611
+ vErrors = [err44];
612
+ } else {
613
+ vErrors.push(err44);
614
+ }
615
+ errors++;
616
+ }
617
+ var valid0 = _errs7 === errors;
618
+ }
619
+ } else {
620
+ const err45 = { instancePath, schemaPath: "#/type", keyword: "type", params: { type: "object" }, message: "must be object" };
621
+ if (vErrors === null) {
622
+ vErrors = [err45];
623
+ } else {
624
+ vErrors.push(err45);
625
+ }
626
+ errors++;
627
+ }
628
+ validate10.errors = vErrors;
629
+ return errors === 0;
630
+ }
631
+
632
+ // index.ts
42
633
  var basicJsonSchema = {
43
634
  "$schema": "http://json-schema.org/draft-07/schema#",
44
635
  "type": "object",
@@ -139,8 +730,7 @@ var basicJsonSchema = {
139
730
  },
140
731
  "required": ["project_id", "version", "tables"]
141
732
  };
142
- var ajv = new import_ajv.default({ allErrors: true });
143
- var validator = ajv.compile(basicJsonSchema);
733
+ var validator = validate;
144
734
  function generateEmptySchema(project_id = "", version = 0) {
145
735
  return {
146
736
  project_id,