@based/schema 2.2.10 → 2.2.12

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 (95) hide show
  1. package/dist/{display → src/display}/index.d.ts +1 -1
  2. package/dist/src/display/index.js +16 -0
  3. package/dist/{display → src/display}/number.js +1 -3
  4. package/dist/{display → src/display}/string.js +1 -3
  5. package/dist/{display → src/display}/timestamp.js +1 -3
  6. package/dist/{error.js → src/error.js} +2 -5
  7. package/dist/src/index.d.ts +5 -0
  8. package/dist/src/index.js +6 -0
  9. package/dist/{languages.js → src/languages.js} +1 -4
  10. package/dist/src/set/fields/array.d.ts +2 -0
  11. package/dist/{set → src/set}/fields/array.js +10 -14
  12. package/dist/src/set/fields/index.d.ts +3 -0
  13. package/dist/src/set/fields/index.js +71 -0
  14. package/dist/{set → src/set}/fields/number.d.ts +1 -1
  15. package/dist/{set → src/set}/fields/number.js +15 -21
  16. package/dist/{set → src/set}/fields/object.d.ts +1 -1
  17. package/dist/src/set/fields/object.js +28 -0
  18. package/dist/{set → src/set}/fields/references.d.ts +1 -1
  19. package/dist/{set → src/set}/fields/references.js +13 -18
  20. package/dist/src/set/fields/set.d.ts +2 -0
  21. package/dist/{set → src/set}/fields/set.js +4 -8
  22. package/dist/{set → src/set}/fields/string.d.ts +1 -1
  23. package/dist/{set → src/set}/fields/string.js +87 -95
  24. package/dist/{set → src/set}/index.d.ts +2 -2
  25. package/dist/{set → src/set}/index.js +21 -25
  26. package/dist/{set → src/set}/isValidId.d.ts +1 -1
  27. package/dist/{set → src/set}/isValidId.js +1 -5
  28. package/dist/{types.d.ts → src/types.d.ts} +7 -6
  29. package/dist/src/types.js +23 -0
  30. package/dist/src/updateSchema.d.ts +2 -0
  31. package/dist/src/updateSchema.js +12 -0
  32. package/dist/src/validateSchema.d.ts +4 -0
  33. package/dist/{validateSchema.js → src/validateSchema.js} +5 -11
  34. package/dist/{walker → src/walker}/args.d.ts +4 -4
  35. package/dist/{walker → src/walker}/args.js +8 -12
  36. package/dist/src/walker/index.d.ts +6 -0
  37. package/dist/src/walker/index.js +31 -0
  38. package/dist/{walker → src/walker}/parse.d.ts +1 -1
  39. package/dist/{walker → src/walker}/parse.js +7 -11
  40. package/dist/{walker → src/walker}/types.d.ts +3 -3
  41. package/dist/{walker → src/walker}/types.js +2 -5
  42. package/dist/test/array.d.ts +1 -0
  43. package/dist/test/array.js +342 -0
  44. package/dist/test/display.d.ts +1 -0
  45. package/dist/test/display.js +103 -0
  46. package/dist/test/number.d.ts +1 -0
  47. package/dist/test/number.js +374 -0
  48. package/dist/test/reference.d.ts +1 -0
  49. package/dist/test/reference.js +186 -0
  50. package/dist/test/rest.d.ts +1 -0
  51. package/dist/test/rest.js +168 -0
  52. package/dist/test/set.d.ts +1 -0
  53. package/dist/test/set.js +95 -0
  54. package/dist/test/string.d.ts +1 -0
  55. package/dist/test/string.js +120 -0
  56. package/dist/test/text.d.ts +1 -0
  57. package/dist/test/text.js +324 -0
  58. package/dist/test/utils/index.d.ts +11 -0
  59. package/dist/test/utils/index.js +17 -0
  60. package/dist/test/validateSchema.d.ts +1 -0
  61. package/dist/test/validateSchema.js +38 -0
  62. package/dist/test/walker.d.ts +1 -0
  63. package/dist/test/walker.js +289 -0
  64. package/package.json +8 -13
  65. package/dist/display/dateString copy.d.ts +0 -3
  66. package/dist/display/dateString copy.js +0 -127
  67. package/dist/display/dateString.d.ts +0 -3
  68. package/dist/display/dateString.js +0 -127
  69. package/dist/display/display.d.ts +0 -1
  70. package/dist/display/display.js +0 -8
  71. package/dist/display/index.js +0 -26
  72. package/dist/display/number copy.d.ts +0 -3
  73. package/dist/display/number copy.js +0 -81
  74. package/dist/display.d.ts +0 -2
  75. package/dist/display.js +0 -8
  76. package/dist/index.d.ts +0 -5
  77. package/dist/index.js +0 -22
  78. package/dist/set/fields/array.d.ts +0 -2
  79. package/dist/set/fields/index.d.ts +0 -3
  80. package/dist/set/fields/index.js +0 -74
  81. package/dist/set/fields/object.js +0 -33
  82. package/dist/set/fields/set.d.ts +0 -2
  83. package/dist/set/types.d.ts +0 -0
  84. package/dist/set/types.js +0 -1
  85. package/dist/types.js +0 -27
  86. package/dist/updateSchema.d.ts +0 -2
  87. package/dist/updateSchema.js +0 -16
  88. package/dist/validateSchema.d.ts +0 -4
  89. package/dist/walker/index.d.ts +0 -6
  90. package/dist/walker/index.js +0 -49
  91. /package/dist/{display → src/display}/number.d.ts +0 -0
  92. /package/dist/{display → src/display}/string.d.ts +0 -0
  93. /package/dist/{display → src/display}/timestamp.d.ts +0 -0
  94. /package/dist/{error.d.ts → src/error.d.ts} +0 -0
  95. /package/dist/{languages.d.ts → src/languages.d.ts} +0 -0
@@ -1,73 +1,67 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.text = exports.string = void 0;
7
- const error_1 = require("../../error");
8
- const validator_1 = __importDefault(require("validator"));
1
+ import { ParseError } from '../../error.js';
2
+ import validators from 'validator';
9
3
  const formatPatterns = {
10
- email: validator_1.default.isEmail,
11
- URL: validator_1.default.isURL,
12
- MACAddress: validator_1.default.isMACAddress,
13
- IP: validator_1.default.isIP,
14
- IPRange: validator_1.default.isIPRange,
15
- FQDN: validator_1.default.isFQDN,
16
- IBAN: validator_1.default.isIBAN,
17
- BIC: validator_1.default.isBIC,
18
- alpha: validator_1.default.isAlpha,
19
- alphaLocales: validator_1.default.isAlphaLocales,
20
- alphanumeric: validator_1.default.isAlphanumeric,
21
- alphanumericLocales: validator_1.default.isAlphanumericLocales,
22
- passportNumber: validator_1.default.isPassportNumber,
23
- port: validator_1.default.isPort,
24
- lowercase: validator_1.default.isLowercase,
25
- uppercase: validator_1.default.isUppercase,
26
- ascii: validator_1.default.isAscii,
27
- semVer: validator_1.default.isSemVer,
28
- surrogatePair: validator_1.default.isSurrogatePair,
29
- IMEI: validator_1.default.isIMEI,
30
- hexadecimal: validator_1.default.isHexadecimal,
31
- octal: validator_1.default.isOctal,
32
- hexColor: validator_1.default.isHexColor,
33
- rgbColor: validator_1.default.isRgbColor,
34
- HSL: validator_1.default.isHSL,
35
- ISRC: validator_1.default.isISRC,
36
- MD5: validator_1.default.isMD5,
37
- JWT: validator_1.default.isJWT,
38
- UUID: validator_1.default.isUUID,
39
- luhnNumber: validator_1.default.isLuhnNumber,
40
- creditCard: validator_1.default.isCreditCard,
41
- identityCard: validator_1.default.isIdentityCard,
42
- EAN: validator_1.default.isEAN,
43
- ISIN: validator_1.default.isISIN,
44
- ISBN: validator_1.default.isISBN,
45
- ISSN: validator_1.default.isISSN,
46
- mobilePhone: validator_1.default.isMobilePhone,
47
- mobilePhoneLocales: validator_1.default.isMobilePhoneLocales,
48
- postalCode: validator_1.default.isPostalCode,
49
- postalCodeLocales: validator_1.default.isPostalCodeLocales,
50
- ethereumAddress: validator_1.default.isEthereumAddress,
51
- currency: validator_1.default.isCurrency,
52
- btcAddress: validator_1.default.isBtcAddress,
53
- ISO6391: validator_1.default.isISO6391,
54
- ISO8601: validator_1.default.isISO8601,
55
- RFC3339: validator_1.default.isRFC3339,
56
- ISO31661Alpha2: validator_1.default.isISO31661Alpha2,
57
- ISO31661Alpha3: validator_1.default.isISO31661Alpha3,
58
- ISO4217: validator_1.default.isISO4217,
59
- base32: validator_1.default.isBase32,
60
- base58: validator_1.default.isBase58,
61
- base64: validator_1.default.isBase64,
62
- dataURI: validator_1.default.isDataURI,
63
- magnetURI: validator_1.default.isMagnetURI,
64
- mimeType: validator_1.default.isMimeType,
65
- latLong: validator_1.default.isLatLong,
66
- slug: validator_1.default.isSlug,
67
- strongPassword: validator_1.default.isStrongPassword,
68
- taxID: validator_1.default.isTaxID,
69
- licensePlate: validator_1.default.isLicensePlate,
70
- VAT: validator_1.default.isVAT,
4
+ email: validators.isEmail,
5
+ URL: validators.isURL,
6
+ MACAddress: validators.isMACAddress,
7
+ IP: validators.isIP,
8
+ IPRange: validators.isIPRange,
9
+ FQDN: validators.isFQDN,
10
+ IBAN: validators.isIBAN,
11
+ BIC: validators.isBIC,
12
+ alpha: validators.isAlpha,
13
+ alphaLocales: validators.isAlphaLocales,
14
+ alphanumeric: validators.isAlphanumeric,
15
+ alphanumericLocales: validators.isAlphanumericLocales,
16
+ passportNumber: validators.isPassportNumber,
17
+ port: validators.isPort,
18
+ lowercase: validators.isLowercase,
19
+ uppercase: validators.isUppercase,
20
+ ascii: validators.isAscii,
21
+ semVer: validators.isSemVer,
22
+ surrogatePair: validators.isSurrogatePair,
23
+ IMEI: validators.isIMEI,
24
+ hexadecimal: validators.isHexadecimal,
25
+ octal: validators.isOctal,
26
+ hexColor: validators.isHexColor,
27
+ rgbColor: validators.isRgbColor,
28
+ HSL: validators.isHSL,
29
+ ISRC: validators.isISRC,
30
+ MD5: validators.isMD5,
31
+ JWT: validators.isJWT,
32
+ UUID: validators.isUUID,
33
+ luhnNumber: validators.isLuhnNumber,
34
+ creditCard: validators.isCreditCard,
35
+ identityCard: validators.isIdentityCard,
36
+ EAN: validators.isEAN,
37
+ ISIN: validators.isISIN,
38
+ ISBN: validators.isISBN,
39
+ ISSN: validators.isISSN,
40
+ mobilePhone: validators.isMobilePhone,
41
+ mobilePhoneLocales: validators.isMobilePhoneLocales,
42
+ postalCode: validators.isPostalCode,
43
+ postalCodeLocales: validators.isPostalCodeLocales,
44
+ ethereumAddress: validators.isEthereumAddress,
45
+ currency: validators.isCurrency,
46
+ btcAddress: validators.isBtcAddress,
47
+ ISO6391: validators.isISO6391,
48
+ ISO8601: validators.isISO8601,
49
+ RFC3339: validators.isRFC3339,
50
+ ISO31661Alpha2: validators.isISO31661Alpha2,
51
+ ISO31661Alpha3: validators.isISO31661Alpha3,
52
+ ISO4217: validators.isISO4217,
53
+ base32: validators.isBase32,
54
+ base58: validators.isBase58,
55
+ base64: validators.isBase64,
56
+ dataURI: validators.isDataURI,
57
+ magnetURI: validators.isMagnetURI,
58
+ mimeType: validators.isMimeType,
59
+ latLong: validators.isLatLong,
60
+ slug: validators.isSlug,
61
+ strongPassword: validators.isStrongPassword,
62
+ taxID: validators.isTaxID,
63
+ licensePlate: validators.isLicensePlate,
64
+ VAT: validators.isVAT,
71
65
  code: () => true,
72
66
  javascript: () => true,
73
67
  typescript: () => true,
@@ -81,58 +75,57 @@ const formatPatterns = {
81
75
  };
82
76
  const validateString = (args, value) => {
83
77
  if (typeof value !== 'string') {
84
- args.error(error_1.ParseError.incorrectFormat);
78
+ args.error(ParseError.incorrectFormat);
85
79
  return false;
86
80
  }
87
81
  if (args.fieldSchema.minLength && value.length < args.fieldSchema.minLength) {
88
- args.error(error_1.ParseError.subceedsMinimum);
82
+ args.error(ParseError.subceedsMinimum);
89
83
  return false;
90
84
  }
91
85
  if (args.fieldSchema.maxLength && value.length > args.fieldSchema.maxLength) {
92
- args.error(error_1.ParseError.exceedsMaximum);
86
+ args.error(ParseError.exceedsMaximum);
93
87
  return false;
94
88
  }
95
89
  if (args.fieldSchema.pattern) {
96
90
  const re = new RegExp(args.fieldSchema.pattern);
97
91
  if (!re.test(value)) {
98
- args.error(error_1.ParseError.incorrectFormat);
92
+ args.error(ParseError.incorrectFormat);
99
93
  return false;
100
94
  }
101
95
  }
102
96
  if (args.fieldSchema.format &&
103
97
  !formatPatterns[args.fieldSchema.format](value)) {
104
- args.error(error_1.ParseError.incorrectFormat);
98
+ args.error(ParseError.incorrectFormat);
105
99
  return false;
106
100
  }
107
101
  return true;
108
102
  };
109
- const string = async (args) => {
103
+ export const string = async (args) => {
110
104
  if (!validateString(args, args.value)) {
111
105
  return;
112
106
  }
113
107
  args.collect();
114
108
  };
115
- exports.string = string;
116
109
  // --- bla
117
110
  // if typeof === string
118
- const text = async (args) => {
111
+ export const text = async (args) => {
119
112
  const value = args.value;
120
113
  args.stop();
121
114
  if (value === null) {
122
- args.error(error_1.ParseError.incorrectFormat);
115
+ args.error(ParseError.incorrectFormat);
123
116
  return;
124
117
  }
125
118
  if (typeof value === 'object') {
126
119
  for (const key in value) {
127
120
  if (key === '$merge') {
128
121
  if (typeof value.$merge !== 'boolean') {
129
- args.error(error_1.ParseError.incorrectFormat);
122
+ args.error(ParseError.incorrectFormat);
130
123
  return;
131
124
  }
132
125
  }
133
126
  else if (key === '$delete') {
134
127
  if (value[key] !== true) {
135
- args.error(error_1.ParseError.incorrectFormat);
128
+ args.error(ParseError.incorrectFormat);
136
129
  return;
137
130
  }
138
131
  args.collect({ $delete: true });
@@ -148,13 +141,13 @@ const text = async (args) => {
148
141
  }
149
142
  else if (key === '$default') {
150
143
  if (value[key] === null) {
151
- args.error(error_1.ParseError.incorrectFormat);
144
+ args.error(ParseError.incorrectFormat);
152
145
  return;
153
146
  }
154
147
  if (typeof value[key] === 'object') {
155
148
  for (const k in value[key]) {
156
149
  if (!validateString(args, args.value[key][k])) {
157
- args.error(error_1.ParseError.incorrectFormat);
150
+ args.error(ParseError.incorrectFormat);
158
151
  return;
159
152
  }
160
153
  args
@@ -167,15 +160,15 @@ const text = async (args) => {
167
160
  }
168
161
  }
169
162
  else if (typeof value[key] !== 'string') {
170
- args.error(error_1.ParseError.incorrectFormat);
163
+ args.error(ParseError.incorrectFormat);
171
164
  return;
172
165
  }
173
166
  else if (!args.target.$language) {
174
- args.error(error_1.ParseError.noLanguageFound);
167
+ args.error(ParseError.noLanguageFound);
175
168
  return;
176
169
  }
177
170
  else if (!validateString(args, value[key])) {
178
- args.error(error_1.ParseError.incorrectFormat);
171
+ args.error(ParseError.incorrectFormat);
179
172
  return;
180
173
  }
181
174
  else {
@@ -195,7 +188,7 @@ const text = async (args) => {
195
188
  for (const k in value[key]) {
196
189
  if (k === '$delete') {
197
190
  if (value[key].$delete !== true) {
198
- args.error(error_1.ParseError.incorrectFormat);
191
+ args.error(ParseError.incorrectFormat);
199
192
  return;
200
193
  }
201
194
  args
@@ -208,7 +201,7 @@ const text = async (args) => {
208
201
  }
209
202
  else if (k === '$value') {
210
203
  if (!validateString(args, value[key].$value)) {
211
- args.create({ key }).error(error_1.ParseError.incorrectFormat);
204
+ args.create({ key }).error(ParseError.incorrectFormat);
212
205
  }
213
206
  else {
214
207
  args
@@ -222,7 +215,7 @@ const text = async (args) => {
222
215
  }
223
216
  else if (k === '$default') {
224
217
  if (!validateString(args, value[key].$default)) {
225
- args.create({ key }).error(error_1.ParseError.incorrectFormat);
218
+ args.create({ key }).error(ParseError.incorrectFormat);
226
219
  }
227
220
  else {
228
221
  args
@@ -237,14 +230,14 @@ const text = async (args) => {
237
230
  else {
238
231
  args
239
232
  .create({ path: [...args.path, key, k] })
240
- .error(error_1.ParseError.fieldDoesNotExist);
233
+ .error(ParseError.fieldDoesNotExist);
241
234
  return;
242
235
  }
243
236
  }
244
237
  }
245
238
  else {
246
239
  if (!validateString(args, args.value[key])) {
247
- args.error(error_1.ParseError.incorrectFormat);
240
+ args.error(ParseError.incorrectFormat);
248
241
  return;
249
242
  }
250
243
  args
@@ -257,7 +250,7 @@ const text = async (args) => {
257
250
  }
258
251
  }
259
252
  else {
260
- args.create({ key }).error(error_1.ParseError.languageNotSupported);
253
+ args.create({ key }).error(ParseError.languageNotSupported);
261
254
  }
262
255
  }
263
256
  if (!args._stopObject) {
@@ -266,15 +259,15 @@ const text = async (args) => {
266
259
  return;
267
260
  }
268
261
  if (typeof value !== 'string') {
269
- args.error(error_1.ParseError.incorrectFormat);
262
+ args.error(ParseError.incorrectFormat);
270
263
  return;
271
264
  }
272
265
  if (!args.target.$language) {
273
- args.error(error_1.ParseError.noLanguageFound);
266
+ args.error(ParseError.noLanguageFound);
274
267
  return;
275
268
  }
276
269
  if (!validateString(args, args.value)) {
277
- args.error(error_1.ParseError.incorrectFormat);
270
+ args.error(ParseError.incorrectFormat);
278
271
  return;
279
272
  }
280
273
  args
@@ -290,5 +283,4 @@ const text = async (args) => {
290
283
  });
291
284
  }
292
285
  };
293
- exports.text = text;
294
286
  //# sourceMappingURL=string.js.map
@@ -1,3 +1,3 @@
1
- import { BasedSchema, BasedSetTarget } from '../types';
2
- import { AsyncOperation } from '../walker';
1
+ import { BasedSchema, BasedSetTarget } from '../types.js';
2
+ import { AsyncOperation } from '../walker/index.js';
3
3
  export declare const setWalker: (schema: BasedSchema, value: any, asyncOperationHandler?: AsyncOperation<BasedSetTarget>) => Promise<BasedSetTarget>;
@@ -1,16 +1,13 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.setWalker = void 0;
4
- const error_1 = require("../error");
5
- const walker_1 = require("../walker");
6
- const fields_1 = require("./fields");
7
- const isValidId_1 = require("./isValidId");
1
+ import { ParseError } from '../error.js';
2
+ import { walk } from '../walker/index.js';
3
+ import { fields } from './fields/index.js';
4
+ import { isValidId } from './isValidId.js';
8
5
  const opts = {
9
6
  parsers: {
10
7
  keys: {
11
8
  $delete: async (args) => {
12
9
  if (args.prev === args.root) {
13
- args.error(error_1.ParseError.cannotDeleteNodeFromModify);
10
+ args.error(ParseError.cannotDeleteNodeFromModify);
14
11
  return;
15
12
  }
16
13
  if (args.value === true) {
@@ -24,19 +21,19 @@ const opts = {
24
21
  if (Array.isArray(args.value)) {
25
22
  for (const field of args.value) {
26
23
  if (typeof field !== 'string') {
27
- args.error(error_1.ParseError.incorrectFormat);
24
+ args.error(ParseError.incorrectFormat);
28
25
  return;
29
26
  }
30
27
  }
31
28
  return;
32
29
  }
33
30
  if (typeof args.value !== 'string') {
34
- args.error(error_1.ParseError.incorrectFormat);
31
+ args.error(ParseError.incorrectFormat);
35
32
  }
36
33
  },
37
34
  $merge: async (args) => {
38
35
  if (typeof args.value !== 'boolean') {
39
- args.error(error_1.ParseError.incorrectFormat);
36
+ args.error(ParseError.incorrectFormat);
40
37
  return;
41
38
  }
42
39
  if (args.prev !== args.root) {
@@ -45,8 +42,8 @@ const opts = {
45
42
  return;
46
43
  },
47
44
  $id: async (args) => {
48
- if (!(0, isValidId_1.isValidId)(args.schema, args.value)) {
49
- args.error(error_1.ParseError.incorrectFormat);
45
+ if (!isValidId(args.schema, args.value)) {
46
+ args.error(ParseError.incorrectFormat);
50
47
  return;
51
48
  }
52
49
  },
@@ -54,7 +51,7 @@ const opts = {
54
51
  if (!(args.schema.translations || [])
55
52
  .concat(args.schema.language)
56
53
  .includes(args.value)) {
57
- args.error(error_1.ParseError.languageNotSupported);
54
+ args.error(ParseError.languageNotSupported);
58
55
  return;
59
56
  }
60
57
  },
@@ -66,7 +63,7 @@ const opts = {
66
63
  args.prev.stop();
67
64
  args.stop();
68
65
  if (args.prev.value.$default) {
69
- args.error(error_1.ParseError.valueAndDefault);
66
+ args.error(ParseError.valueAndDefault);
70
67
  return;
71
68
  }
72
69
  return {
@@ -109,14 +106,14 @@ const opts = {
109
106
  }
110
107
  for (const key in args.prev.value) {
111
108
  if (key !== '$default') {
112
- args.prev.create({ key }).error(error_1.ParseError.fieldDoesNotExist);
109
+ args.prev.create({ key }).error(ParseError.fieldDoesNotExist);
113
110
  }
114
111
  }
115
112
  },
116
113
  },
117
- fields: fields_1.fields,
114
+ fields,
118
115
  catch: async (args) => {
119
- args.error(error_1.ParseError.fieldDoesNotExist);
116
+ args.error(ParseError.fieldDoesNotExist);
120
117
  },
121
118
  },
122
119
  init: async (value, schema, error) => {
@@ -136,7 +133,7 @@ const opts = {
136
133
  type = schema.prefixToTypeMapping[value.$id.slice(0, 2)];
137
134
  }
138
135
  if (!type) {
139
- error(error_1.ParseError.incorrectFieldType, { target });
136
+ error(ParseError.incorrectFieldType, { target });
140
137
  return { target };
141
138
  }
142
139
  }
@@ -145,14 +142,14 @@ const opts = {
145
142
  }
146
143
  if (value.type) {
147
144
  if (type && value.type !== type) {
148
- error(error_1.ParseError.incorrectNodeType, { target });
145
+ error(ParseError.incorrectNodeType, { target });
149
146
  return { target };
150
147
  }
151
148
  type = value.type;
152
149
  }
153
150
  const typeSchema = type === 'root' ? schema.root : schema.types[type];
154
151
  if (!typeSchema) {
155
- error(error_1.ParseError.incorrectNodeType, { target });
152
+ error(ParseError.incorrectNodeType, { target });
156
153
  return { target };
157
154
  }
158
155
  target.type = type;
@@ -160,7 +157,7 @@ const opts = {
160
157
  target.$id = value.$id;
161
158
  if ('$merge' in value) {
162
159
  if (typeof value.$merge !== 'boolean') {
163
- error(error_1.ParseError.incorrectFormat, { target });
160
+ error(ParseError.incorrectFormat, { target });
164
161
  }
165
162
  target.$merge = value.$merge;
166
163
  }
@@ -176,8 +173,7 @@ const opts = {
176
173
  args.root.target.collected.push(args);
177
174
  },
178
175
  };
179
- const setWalker = (schema, value, asyncOperationHandler) => {
180
- return (0, walker_1.walk)(schema, opts, value, asyncOperationHandler);
176
+ export const setWalker = (schema, value, asyncOperationHandler) => {
177
+ return walk(schema, opts, value, asyncOperationHandler);
181
178
  };
182
- exports.setWalker = setWalker;
183
179
  //# sourceMappingURL=index.js.map
@@ -1,2 +1,2 @@
1
- import { BasedSchema } from '../types';
1
+ import { BasedSchema } from '../types.js';
2
2
  export declare const isValidId: (schema: BasedSchema, id: any) => boolean;
@@ -1,7 +1,4 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.isValidId = void 0;
4
- const isValidId = (schema, id) => {
1
+ export const isValidId = (schema, id) => {
5
2
  if (typeof id !== 'string') {
6
3
  return false;
7
4
  }
@@ -17,5 +14,4 @@ const isValidId = (schema, id) => {
17
14
  }
18
15
  return true;
19
16
  };
20
- exports.isValidId = isValidId;
21
17
  //# sourceMappingURL=isValidId.js.map
@@ -1,10 +1,10 @@
1
- import type { Language } from './languages';
1
+ import type { Language } from './languages.js';
2
2
  import type { PartialDeep } from 'type-fest';
3
- import { ParseError } from './error';
4
- import { ArgsClass, Path } from './walker';
5
- import { StringFormat } from './display/string';
6
- import { NumberFormat } from './display/number';
7
- import { DateFormat } from './display/timestamp';
3
+ import { ParseError } from './error.js';
4
+ import { ArgsClass, Path } from './walker/index.js';
5
+ import { StringFormat } from './display/string.js';
6
+ import { NumberFormat } from './display/number.js';
7
+ import { DateFormat } from './display/timestamp.js';
8
8
  export type AllowedTypes = (string | {
9
9
  type?: string;
10
10
  $filter: any | any[];
@@ -121,6 +121,7 @@ export type BasedSchemaFieldReference = {
121
121
  bidirectional?: {
122
122
  fromField: string;
123
123
  };
124
+ sortable?: boolean;
124
125
  allowedTypes?: AllowedTypes;
125
126
  } & BasedSchemaFieldShared;
126
127
  export type BasedSchemaFieldReferences = {
@@ -0,0 +1,23 @@
1
+ import { languages as allLanguages } from './languages.js';
2
+ export const basedSchemaFieldTypes = [
3
+ 'array',
4
+ 'object',
5
+ 'record',
6
+ 'set',
7
+ 'string',
8
+ 'boolean',
9
+ 'number',
10
+ 'json',
11
+ 'integer',
12
+ 'timestamp',
13
+ 'reference',
14
+ 'references',
15
+ 'text',
16
+ 'enum',
17
+ 'cardinality',
18
+ ];
19
+ export const isCollection = (type) => {
20
+ return type === 'array' || type === 'object' || type === 'record';
21
+ };
22
+ export const languages = Object.keys(allLanguages);
23
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1,2 @@
1
+ import { BasedSchema, BasedSchemaPartial } from './types.js';
2
+ export declare const updateSchema: (_newSchema: BasedSchemaPartial, oldSchema?: BasedSchema) => Promise<BasedSchema>;
@@ -0,0 +1,12 @@
1
+ export const updateSchema = async (_newSchema, oldSchema = {
2
+ $defs: {},
3
+ types: {},
4
+ language: 'en',
5
+ root: { fields: {} },
6
+ prefixToTypeMapping: {},
7
+ }) => {
8
+ // add sha
9
+ // put isRequired on the new schema in REQUIRED arrays
10
+ return oldSchema;
11
+ };
12
+ //# sourceMappingURL=updateSchema.js.map
@@ -0,0 +1,4 @@
1
+ import { BasedSchemaPartial, BasedSchemaFieldPartial, BasedSchemaTypePartial } from './types.js';
2
+ export declare const validateType: (_fromSchema: BasedSchemaPartial, typeName: string, type: BasedSchemaTypePartial) => void;
3
+ export declare const validateField: (_fromSchema: BasedSchemaPartial, _path: string[], _field: BasedSchemaFieldPartial) => void;
4
+ export declare const validateSchema: (schema: BasedSchemaPartial) => BasedSchemaPartial;
@@ -1,19 +1,14 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.validateSchema = exports.validateField = exports.validateType = void 0;
4
1
  // gaurd in the schema for refs in arrays
5
- const validateType = (fromSchema, typeName, type) => {
2
+ export const validateType = (_fromSchema, typeName, type) => {
6
3
  if (type.prefix &&
7
4
  (typeof type.prefix !== 'string' || type.prefix.length !== 2)) {
8
5
  throw new Error(`Incorrect prefix "${type.prefix}" for type "${typeName}" has to be a string of 2 alphanumerical characters e.g. "Az", "ab", "cc", "10"`);
9
6
  }
10
7
  };
11
- exports.validateType = validateType;
12
- const validateField = (fromSchema, path, field) => {
8
+ export const validateField = (_fromSchema, _path, _field) => {
13
9
  //
14
10
  };
15
- exports.validateField = validateField;
16
- const validateSchema = (schema) => {
11
+ export const validateSchema = (schema) => {
17
12
  // rewrite schema things like required / required: []
18
13
  if (typeof schema !== 'object') {
19
14
  throw new Error('Schema is not an object');
@@ -28,14 +23,13 @@ const validateSchema = (schema) => {
28
23
  // first defs ofc
29
24
  }
30
25
  if (schema.root) {
31
- (0, exports.validateType)(schema, 'root', schema.root);
26
+ validateType(schema, 'root', schema.root);
32
27
  }
33
28
  if (schema.types) {
34
29
  for (const type in schema.types) {
35
- (0, exports.validateType)(schema, type, schema.types[type]);
30
+ validateType(schema, type, schema.types[type]);
36
31
  }
37
32
  }
38
33
  return schema;
39
34
  };
40
- exports.validateSchema = validateSchema;
41
35
  //# sourceMappingURL=validateSchema.js.map
@@ -1,7 +1,7 @@
1
- import { BasedSchema } from '../types';
2
- import { BasedSchemaType, BasedSchemaFields } from '../types';
3
- import { ArgsOpts, Path, Opts, Stopped, Collect } from './types';
4
- import { ParseError } from '../error';
1
+ import { BasedSchema } from '../types.js';
2
+ import { BasedSchemaType, BasedSchemaFields } from '../types.js';
3
+ import { ArgsOpts, Path, Opts, Stopped, Collect } from './types.js';
4
+ import { ParseError } from '../error.js';
5
5
  export declare class ArgsClass<T, K extends keyof BasedSchemaFields = keyof BasedSchemaFields> {
6
6
  errors: any[];
7
7
  id: number;
@@ -1,11 +1,8 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ArgsClass = void 0;
4
- const types_1 = require("./types");
5
- const parse_1 = require("./parse");
6
- const utils_1 = require("@saulx/utils");
1
+ import { Stopped } from './types.js';
2
+ import { parse } from './parse.js';
3
+ import { deepEqual } from '@saulx/utils';
7
4
  let id = 0;
8
- class ArgsClass {
5
+ export class ArgsClass {
9
6
  constructor(opts, prev) {
10
7
  this.id = ++id;
11
8
  this.fromBackTrack = [];
@@ -81,10 +78,10 @@ class ArgsClass {
81
78
  stop(onllyStopFieldSchemaParser) {
82
79
  const target = this;
83
80
  if (onllyStopFieldSchemaParser) {
84
- target.stopped = types_1.Stopped.onlyStopFieldParser;
81
+ target.stopped = Stopped.onlyStopFieldParser;
85
82
  }
86
83
  else {
87
- target.stopped = types_1.Stopped.stopAll;
84
+ target.stopped = Stopped.stopAll;
88
85
  }
89
86
  }
90
87
  create(opts) {
@@ -102,7 +99,7 @@ class ArgsClass {
102
99
  }
103
100
  async parse(opts) {
104
101
  if (!opts) {
105
- return (0, parse_1.parse)(this);
102
+ return parse(this);
106
103
  }
107
104
  else {
108
105
  const newArgs = new ArgsClass(opts, this);
@@ -126,7 +123,7 @@ class ArgsClass {
126
123
  let p = this;
127
124
  while (p) {
128
125
  if (p.prev) {
129
- if ((0, utils_1.deepEqual)(p.prev.path, p.path)) {
126
+ if (deepEqual(p.prev.path, p.path)) {
130
127
  p = p.prev;
131
128
  }
132
129
  else {
@@ -158,5 +155,4 @@ class ArgsClass {
158
155
  this.root._opts.error(code, this);
159
156
  }
160
157
  }
161
- exports.ArgsClass = ArgsClass;
162
158
  //# sourceMappingURL=args.js.map