@based/schema 1.3.2 → 2.1.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 (71) hide show
  1. package/dist/set/fields/string.d.ts.map +1 -1
  2. package/dist/set/fields/string.js +3 -1
  3. package/dist/set/fields/string.js.map +1 -1
  4. package/dist/set/index.d.ts.map +1 -1
  5. package/dist/set/index.js +3 -1
  6. package/dist/set/index.js.map +1 -1
  7. package/dist/types.d.ts +5 -2
  8. package/dist/types.d.ts.map +1 -1
  9. package/dist/types.js +17 -1
  10. package/dist/types.js.map +1 -1
  11. package/dist/updateSchema.js +1 -1
  12. package/dist/updateSchema.js.map +1 -1
  13. package/dist/validateSchema.d.ts.map +1 -1
  14. package/dist/validateSchema.js +5 -2
  15. package/dist/validateSchema.js.map +1 -1
  16. package/package.json +1 -1
  17. package/dist/set/collections.d.ts +0 -5
  18. package/dist/set/collections.js +0 -211
  19. package/dist/set/collections.js.map +0 -1
  20. package/dist/set/error.d.ts +0 -15
  21. package/dist/set/error.js +0 -24
  22. package/dist/set/error.js.map +0 -1
  23. package/dist/set/number.d.ts +0 -4
  24. package/dist/set/number.js +0 -111
  25. package/dist/set/number.js.map +0 -1
  26. package/dist/set/parseDefaultAndValue.d.ts +0 -3
  27. package/dist/set/parseDefaultAndValue.js +0 -33
  28. package/dist/set/parseDefaultAndValue.js.map +0 -1
  29. package/dist/set/parsers.d.ts +0 -3
  30. package/dist/set/parsers.js +0 -42
  31. package/dist/set/parsers.js.map +0 -1
  32. package/dist/set/references.d.ts +0 -3
  33. package/dist/set/references.js +0 -77
  34. package/dist/set/references.js.map +0 -1
  35. package/dist/set/rest.d.ts +0 -5
  36. package/dist/set/rest.js +0 -76
  37. package/dist/set/rest.js.map +0 -1
  38. package/dist/set/string.d.ts +0 -3
  39. package/dist/set/string.js +0 -173
  40. package/dist/set/string.js.map +0 -1
  41. package/src/error.ts +0 -19
  42. package/src/index.ts +0 -7
  43. package/src/languages.ts +0 -188
  44. package/src/set/fields/array.ts +0 -155
  45. package/src/set/fields/index.ts +0 -70
  46. package/src/set/fields/number.ts +0 -144
  47. package/src/set/fields/object.ts +0 -31
  48. package/src/set/fields/references.ts +0 -140
  49. package/src/set/fields/set.ts +0 -63
  50. package/src/set/fields/string.ts +0 -287
  51. package/src/set/index.ts +0 -182
  52. package/src/set/isValidId.ts +0 -23
  53. package/src/set/types.ts +0 -0
  54. package/src/types.ts +0 -361
  55. package/src/updateSchema.ts +0 -18
  56. package/src/validateSchema.ts +0 -61
  57. package/src/walker/args.ts +0 -209
  58. package/src/walker/index.ts +0 -48
  59. package/src/walker/parse.ts +0 -233
  60. package/src/walker/types.ts +0 -81
  61. package/test/array.ts +0 -388
  62. package/test/number.ts +0 -435
  63. package/test/reference.ts +0 -218
  64. package/test/rest.ts +0 -184
  65. package/test/set.ts +0 -103
  66. package/test/string.ts +0 -118
  67. package/test/text.ts +0 -342
  68. package/test/utils/index.ts +0 -23
  69. package/test/validateSchema.ts +0 -41
  70. package/test/walker.ts +0 -318
  71. package/tsconfig.json +0 -9
@@ -1,140 +0,0 @@
1
- import { ParseError } from '../../error'
2
- import { AllowedTypes, BasedSetTarget } from '../../types'
3
- import { ArgsClass, FieldParser } from '../../walker'
4
- import { isValidId } from '../isValidId'
5
-
6
- async function parseOperator<T>(
7
- args: ArgsClass<T, 'references'>,
8
- key: string
9
- ): Promise<any[]> {
10
- if (Array.isArray(args.value[key])) {
11
- const n = args.create({
12
- key,
13
- skipCollection: true,
14
- value: args.value[key],
15
- })
16
- await n.parse()
17
-
18
- if (n.value?.$value) {
19
- return n.value.$value
20
- }
21
- return []
22
- }
23
- const n = <ArgsClass<BasedSetTarget, 'reference'>>args.create({
24
- value: args.value[key],
25
- key,
26
- skipCollection: true,
27
- })
28
- await reference(n)
29
- return [n.value]
30
- }
31
-
32
- const typeIsAllowed = (
33
- args: ArgsClass<BasedSetTarget, 'reference'>,
34
- type: string
35
- ): boolean => {
36
- if ('allowedTypes' in args.fieldSchema) {
37
- let typeMatches = false
38
- for (const t of args.fieldSchema.allowedTypes) {
39
- if (typeof t === 'string') {
40
- if (t === type) {
41
- return true
42
- }
43
- } else {
44
- if (t.type && t.type === type) {
45
- typeMatches = true
46
- if (t.$filter) {
47
- // stage on requires validation in target
48
- // TODO: ASYNC REQUIRED HOOK
49
- // if(!(await args.target.referenceFilterCondition(value, t.$filter))){
50
- // error(args, ParseError.referenceIsIncorrectType)
51
- // return
52
- // }
53
- }
54
- } else if (!t.type && t.$filter) {
55
- // if(!(await args.target.referenceFilterCondition))
56
- // error(args, ParseError.referenceIsIncorrectType, )
57
- // return
58
- }
59
- }
60
- }
61
- if (typeMatches === false) {
62
- return false
63
- }
64
- }
65
- return true
66
- }
67
-
68
- export const reference: FieldParser<'reference'> = async (args) => {
69
- // TODO: setting an object here , handling $alias (both async hooks)
70
- // Block if path contains $remove (maybe not for $alias)
71
- if (typeof args.value === 'object') {
72
- if (args.root._opts.asyncOperationHandler) {
73
- if (args.value.type && !typeIsAllowed(args, args.value.type)) {
74
- args.error(ParseError.referenceIsIncorrectType)
75
- return
76
- }
77
- if (!args.target.errors.length) {
78
- args.value = await args.root._opts.asyncOperationHandler(
79
- args,
80
- 'modifyObject'
81
- )
82
- }
83
- } else {
84
- args.error(ParseError.nestedModifyObjectNotAllowed)
85
- return
86
- }
87
- }
88
-
89
- if (!isValidId(args.schema, args.value)) {
90
- args.error(ParseError.incorrectFormat)
91
- return
92
- }
93
-
94
- const prefix = args.value.slice(0, 2)
95
- const targetType = args.schema.prefixToTypeMapping[prefix]
96
-
97
- if (typeIsAllowed(args, targetType)) {
98
- args.collect()
99
- } else {
100
- args.error(ParseError.referenceIsIncorrectType)
101
- }
102
- }
103
-
104
- export const references: FieldParser<'references'> = async (args) => {
105
- const { value } = args
106
-
107
- if (typeof value !== 'object' || value === null) {
108
- args.error(ParseError.incorrectFormat)
109
- return
110
- }
111
-
112
- args.stop()
113
-
114
- if (Array.isArray(value)) {
115
- const parseValues = await Promise.all(
116
- value.map(async (id, key) => {
117
- const n = <ArgsClass<BasedSetTarget, 'reference'>>args.create({
118
- value: id,
119
- key,
120
- skipCollection: true,
121
- })
122
- await reference(n)
123
- return n.value
124
- })
125
- )
126
- args.value = { $value: parseValues }
127
- } else {
128
- for (const key in args.value) {
129
- if (key === '$add') {
130
- args.value.$add = await parseOperator(args, key)
131
- } else if (key === '$remove') {
132
- args.value.$remove = await parseOperator(args, key)
133
- } else {
134
- args.create({ key }).error(ParseError.fieldDoesNotExist)
135
- }
136
- }
137
- }
138
-
139
- args.collect()
140
- }
@@ -1,63 +0,0 @@
1
- import { ParseError } from '../../error'
2
- import { ArgsClass, FieldParser } from '../../walker'
3
-
4
- async function parseOperator<T>(
5
- args: ArgsClass<T, 'set'>,
6
- key: string
7
- ): Promise<any[]> {
8
- if (Array.isArray(args.value[key])) {
9
- const n = args.create({
10
- key,
11
- skipCollection: true,
12
- value: args.value[key],
13
- })
14
- await n.parse()
15
- if (n.value?.$value) {
16
- return n.value.$value
17
- }
18
- return []
19
- }
20
- const n = args.create({
21
- key,
22
- skipCollection: true,
23
- value: args.value[key],
24
- fieldSchema: args.fieldSchema.items,
25
- })
26
- await n.parse()
27
- return [n.value]
28
- }
29
-
30
- export const set: FieldParser<'set'> = async (args) => {
31
- if (typeof args.value !== 'object' || args.value === null) {
32
- args.error(ParseError.incorrectFormat)
33
- return
34
- }
35
- args.stop()
36
- const isArray = Array.isArray(args.value)
37
- if (isArray) {
38
- const newArgs: ArgsClass<typeof args.target>[] = []
39
- for (let i = 0; i < args.value.length; i++) {
40
- newArgs.push(
41
- args.create({
42
- key: i,
43
- value: args.value[i],
44
- fieldSchema: args.fieldSchema.items,
45
- skipCollection: true,
46
- })
47
- )
48
- }
49
- await Promise.all(newArgs.map((args) => args.parse()))
50
- args.value = { $value: newArgs.map((args) => args.value) }
51
- } else {
52
- for (const key in args.value) {
53
- if (key === '$add') {
54
- args.value.$add = await parseOperator(args, key)
55
- } else if (key === '$remove') {
56
- args.value.$remove = await parseOperator(args, key)
57
- } else {
58
- args.create({ key }).error(ParseError.fieldDoesNotExist)
59
- }
60
- }
61
- }
62
- args.collect()
63
- }
@@ -1,287 +0,0 @@
1
- import {
2
- BasedSchemaFieldString,
3
- BasedSchemaLanguage,
4
- BasedSetTarget,
5
- } from '../../types'
6
- import { ParseError } from '../../error'
7
- import { FieldParser, ArgsClass } from '../../walker'
8
- import validators from 'validator'
9
- import { deepMerge, setByPath } from '@saulx/utils'
10
-
11
- type StringTypes = 'string' | 'text'
12
-
13
- const formatPatterns: Record<
14
- BasedSchemaFieldString['format'],
15
- (str: string) => boolean
16
- > = {
17
- email: validators.isEmail,
18
- URL: validators.isURL,
19
- MACAddress: validators.isMACAddress,
20
- IP: validators.isIP,
21
- IPRange: validators.isIPRange,
22
- FQDN: validators.isFQDN,
23
- IBAN: validators.isIBAN,
24
- BIC: validators.isBIC,
25
- alpha: validators.isAlpha,
26
- alphaLocales: validators.isAlphaLocales,
27
- alphanumeric: validators.isAlphanumeric,
28
- alphanumericLocales: validators.isAlphanumericLocales,
29
- passportNumber: validators.isPassportNumber,
30
- port: validators.isPort,
31
- lowercase: validators.isLowercase,
32
- uppercase: validators.isUppercase,
33
- ascii: validators.isAscii,
34
- semVer: validators.isSemVer,
35
- surrogatePair: validators.isSurrogatePair,
36
- IMEI: validators.isIMEI,
37
- hexadecimal: validators.isHexadecimal,
38
- octal: validators.isOctal,
39
- hexColor: validators.isHexColor,
40
- rgbColor: validators.isRgbColor,
41
- HSL: validators.isHSL,
42
- ISRC: validators.isISRC,
43
- MD5: validators.isMD5,
44
- JWT: validators.isJWT,
45
- UUID: validators.isUUID,
46
- luhnNumber: validators.isLuhnNumber,
47
- creditCard: validators.isCreditCard,
48
- identityCard: validators.isIdentityCard,
49
- EAN: validators.isEAN,
50
- ISIN: validators.isISIN,
51
- ISBN: validators.isISBN,
52
- ISSN: validators.isISSN,
53
- mobilePhone: validators.isMobilePhone,
54
- mobilePhoneLocales: validators.isMobilePhoneLocales,
55
- postalCode: validators.isPostalCode,
56
- postalCodeLocales: validators.isPostalCodeLocales,
57
- ethereumAddress: validators.isEthereumAddress,
58
- currency: validators.isCurrency,
59
- btcAddress: validators.isBtcAddress,
60
- ISO6391: validators.isISO6391,
61
- ISO8601: validators.isISO8601,
62
- RFC3339: validators.isRFC3339,
63
- ISO31661Alpha2: validators.isISO31661Alpha2,
64
- ISO31661Alpha3: validators.isISO31661Alpha3,
65
- ISO4217: validators.isISO4217,
66
- base32: validators.isBase32,
67
- base58: validators.isBase58,
68
- base64: validators.isBase64,
69
- dataURI: validators.isDataURI,
70
- magnetURI: validators.isMagnetURI,
71
- mimeType: validators.isMimeType,
72
- latLong: validators.isLatLong,
73
- slug: validators.isSlug,
74
- strongPassword: validators.isStrongPassword,
75
- taxID: validators.isTaxID,
76
- licensePlate: validators.isLicensePlate,
77
- VAT: validators.isVAT,
78
- }
79
-
80
- const validateString = (
81
- args: ArgsClass<BasedSetTarget, StringTypes>,
82
- value: string
83
- ): boolean => {
84
- if (typeof value !== 'string') {
85
- args.error(ParseError.incorrectFormat)
86
- return false
87
- }
88
- if (args.fieldSchema.minLength && value.length < args.fieldSchema.minLength) {
89
- args.error(ParseError.subceedsMinimum)
90
- return false
91
- }
92
- if (args.fieldSchema.maxLength && value.length > args.fieldSchema.maxLength) {
93
- args.error(ParseError.exceedsMaximum)
94
- return false
95
- }
96
- if (args.fieldSchema.pattern) {
97
- const re = new RegExp(args.fieldSchema.pattern)
98
- if (!re.test(value)) {
99
- args.error(ParseError.incorrectFormat)
100
- return false
101
- }
102
- }
103
- if (
104
- args.fieldSchema.format &&
105
- !formatPatterns[args.fieldSchema.format](value)
106
- ) {
107
- args.error(ParseError.incorrectFormat)
108
- return false
109
- }
110
- return true
111
- }
112
-
113
- export const string: FieldParser<'string'> = async (args) => {
114
- if (!validateString(args, args.value)) {
115
- return
116
- }
117
- args.collect()
118
- }
119
-
120
- // --- bla
121
- // if typeof === string
122
- export const text: FieldParser<'text'> = async (args) => {
123
- const value = args.value
124
-
125
- args.stop()
126
-
127
- if (value === null) {
128
- args.error(ParseError.incorrectFormat)
129
- return
130
- }
131
-
132
- if (typeof value === 'object') {
133
- for (const key in value) {
134
- if (key === '$merge') {
135
- if (typeof value.$merge !== 'boolean') {
136
- args.error(ParseError.incorrectFormat)
137
- return
138
- }
139
- } else if (key === '$delete') {
140
- if (value[key] !== true) {
141
- args.error(ParseError.incorrectFormat)
142
- return
143
- }
144
- args.collect({ $delete: true })
145
- return
146
- } else if (key === '$value') {
147
- const valueArgs = args.create({
148
- path: args.path,
149
- value: args.value[key],
150
- })
151
- valueArgs._stopObject = true
152
- await valueArgs.parse()
153
- } else if (key === '$default') {
154
- if (value[key] === null) {
155
- args.error(ParseError.incorrectFormat)
156
- return
157
- }
158
- if (typeof value[key] === 'object') {
159
- for (const k in value[key]) {
160
- if (!validateString(args, args.value[key][k])) {
161
- args.error(ParseError.incorrectFormat)
162
- return
163
- }
164
- args
165
- .create({
166
- key: k,
167
- fieldSchema: { type: 'string' },
168
- value: { $default: args.value[key][k] },
169
- })
170
- .collect()
171
- }
172
- } else if (typeof value[key] !== 'string') {
173
- args.error(ParseError.incorrectFormat)
174
- return
175
- } else if (!args.target.$language) {
176
- args.error(ParseError.noLanguageFound)
177
- return
178
- } else if (!validateString(args, value[key])) {
179
- args.error(ParseError.incorrectFormat)
180
- return
181
- } else {
182
- args
183
- .create({
184
- fieldSchema: { type: 'string' },
185
- key: args.target.$language,
186
- value: { $default: args.value[key] },
187
- })
188
- .collect()
189
- }
190
- } else if (args.schema.languages.includes(<BasedSchemaLanguage>key)) {
191
- if (value[key] && typeof value[key] === 'object') {
192
- for (const k in value[key]) {
193
- if (k === '$delete') {
194
- if (value[key].$delete !== true) {
195
- args.error(ParseError.incorrectFormat)
196
- return
197
- }
198
- args
199
- .create({
200
- key,
201
- fieldSchema: { type: 'string' },
202
- value: args.value[key],
203
- })
204
- .collect()
205
- } else if (k === '$value') {
206
- if (!validateString(args, value[key].$value)) {
207
- args.create({ key }).error(ParseError.incorrectFormat)
208
- } else {
209
- args
210
- .create({
211
- key,
212
- fieldSchema: { type: 'string' },
213
- value: args.value[key].$value,
214
- })
215
- .collect()
216
- }
217
- } else if (k === '$default') {
218
- if (!validateString(args, value[key].$default)) {
219
- args.create({ key }).error(ParseError.incorrectFormat)
220
- } else {
221
- args
222
- .create({
223
- key,
224
- fieldSchema: { type: 'string' },
225
- value: { $default: args.value[key].$default },
226
- })
227
- .collect()
228
- }
229
- } else {
230
- args
231
- .create({ path: [...args.path, key, k] })
232
- .error(ParseError.fieldDoesNotExist)
233
- return
234
- }
235
- }
236
- } else {
237
- if (!validateString(args, args.value[key])) {
238
- args.error(ParseError.incorrectFormat)
239
- return
240
- }
241
- args
242
- .create({
243
- key,
244
- fieldSchema: { type: 'string' },
245
- value: args.value[key],
246
- })
247
- .collect()
248
- }
249
- } else {
250
- args.create({ key }).error(ParseError.languageNotSupported)
251
- }
252
- }
253
- if (!args._stopObject) {
254
- args.collect()
255
- }
256
- return
257
- }
258
-
259
- if (typeof value !== 'string') {
260
- args.error(ParseError.incorrectFormat)
261
- return
262
- }
263
-
264
- if (!args.target.$language) {
265
- args.error(ParseError.noLanguageFound)
266
- return
267
- }
268
-
269
- if (!validateString(args, args.value)) {
270
- args.error(ParseError.incorrectFormat)
271
- return
272
- }
273
-
274
- args
275
- .create({
276
- value,
277
- key: args.target.$language,
278
- fieldSchema: { type: 'string' },
279
- })
280
- .collect()
281
-
282
- if (!args._stopObject) {
283
- args.collect({
284
- [args.target.$language]: value,
285
- })
286
- }
287
- }
package/src/set/index.ts DELETED
@@ -1,182 +0,0 @@
1
- import { ParseError } from '../error'
2
- import { BasedSchema, BasedSchemaCollectProps, BasedSetTarget } from '../types'
3
- import { walk, Opts, AsyncOperation } from '../walker'
4
- import { fields } from './fields'
5
- import { isValidId } from './isValidId'
6
-
7
- const opts: Opts<BasedSetTarget> = {
8
- parsers: {
9
- keys: {
10
- $delete: async (args) => {
11
- if (args.prev === args.root) {
12
- args.error(ParseError.cannotDeleteNodeFromModify)
13
- return
14
- }
15
- if (args.value === true) {
16
- args.stop()
17
- args.prev.collect()
18
- args.prev.stop()
19
- return
20
- }
21
- },
22
- $alias: async (args) => {
23
- if (Array.isArray(args.value)) {
24
- for (const field of args.value) {
25
- if (typeof field !== 'string') {
26
- args.error(ParseError.incorrectFormat)
27
- return
28
- }
29
- }
30
- return
31
- }
32
- if (typeof args.value !== 'string') {
33
- args.error(ParseError.incorrectFormat)
34
- }
35
- },
36
- $merge: async (args) => {
37
- if (typeof args.value !== 'boolean') {
38
- args.error(ParseError.incorrectFormat)
39
- return
40
- }
41
-
42
- if (args.prev !== args.root) {
43
- args.prev.collect({ $delete: true })
44
- }
45
-
46
- return
47
- },
48
- $id: async (args) => {
49
- if (!isValidId(args.schema, args.value)) {
50
- args.error(ParseError.incorrectFormat)
51
- return
52
- }
53
- },
54
- $language: async (args) => {
55
- if (!args.schema.languages.includes(args.value)) {
56
- args.error(ParseError.languageNotSupported)
57
- return
58
- }
59
- },
60
- $value: async (args) => {
61
- const type = args.fieldSchema?.type
62
- if (type === 'text' || type === 'set' || type == 'references') {
63
- return
64
- }
65
- args.prev.stop()
66
- args.stop()
67
- if (args.prev.value.$default) {
68
- args.error(ParseError.valueAndDefault)
69
- return
70
- }
71
- return {
72
- path: args.path.slice(0, -1),
73
- value: args.value,
74
- }
75
- },
76
- $default: async (args) => {
77
- const type = args.fieldSchema?.type
78
- if (type === 'number' || type === 'integer' || type === 'text') {
79
- // default can exist with $incr and $decr
80
- return
81
- }
82
- args.prev.stop()
83
- args.stop()
84
-
85
- if (type === 'references' || type === 'set' || type === 'array') {
86
- const newArgs = args.create({
87
- path: args.path.slice(0, -1),
88
- skipCollection: true,
89
- })
90
- await newArgs.parse()
91
- newArgs.skipCollection = false
92
- newArgs.value = { $default: newArgs.value }
93
- newArgs.collect()
94
- } else {
95
- const collect = args._collectOverride ?? args.root._opts.collect
96
- const newArgs = args.create({
97
- path: args.path.slice(0, -1),
98
- collect: (a) => {
99
- if (a.path.length === args.path.length - 1) {
100
- collect(a.create({ value: { $default: a.value } }))
101
- } else {
102
- // console.info('hello', a.path) can handle this later
103
- }
104
- },
105
- })
106
- await newArgs.parse()
107
- }
108
- for (const key in args.prev.value) {
109
- if (key !== '$default') {
110
- args.prev.create({ key }).error(ParseError.fieldDoesNotExist)
111
- }
112
- }
113
- },
114
- },
115
- fields,
116
- catch: async (args) => {
117
- args.error(ParseError.fieldDoesNotExist)
118
- },
119
- },
120
- init: async (value, schema, error) => {
121
- let type: string
122
- const target: BasedSetTarget = {
123
- type,
124
- schema,
125
- required: [],
126
- collected: [],
127
- errors: [],
128
- }
129
- if (value.$id) {
130
- if (value.$id === 'root') {
131
- type = 'root'
132
- } else {
133
- type = schema.prefixToTypeMapping[value.$id.slice(0, 2)]
134
- }
135
- if (!type) {
136
- error(ParseError.incorrectFieldType, { target })
137
- return { target }
138
- }
139
- } else if (value.$alias) {
140
- target.$alias = value.$alias
141
- }
142
- if (value.type) {
143
- if (type && value.type !== type) {
144
- error(ParseError.incorrectNodeType, { target })
145
- return { target }
146
- }
147
- type = value.type
148
- }
149
- const typeSchema = type === 'root' ? schema.root : schema.types[type]
150
- if (!typeSchema) {
151
- error(ParseError.incorrectNodeType, { target })
152
- return { target }
153
- }
154
- target.type = type
155
- target.$language = value.$language
156
- target.$id = value.$id
157
- if ('$merge' in value) {
158
- if (typeof value.$merge !== 'boolean') {
159
- error(ParseError.incorrectFormat, { target })
160
- }
161
- target.$merge = value.$merge
162
- }
163
- return { target, typeSchema }
164
- },
165
- error: (code, args) => {
166
- args.target.errors.push({
167
- code,
168
- path: args.path ?? [],
169
- })
170
- },
171
- collect: (args) => {
172
- args.root.target.collected.push(<BasedSchemaCollectProps>args)
173
- },
174
- }
175
-
176
- export const setWalker = (
177
- schema: BasedSchema,
178
- value: any,
179
- asyncOperationHandler?: AsyncOperation<BasedSetTarget>
180
- ): Promise<BasedSetTarget> => {
181
- return walk<BasedSetTarget>(schema, opts, value, asyncOperationHandler)
182
- }
@@ -1,23 +0,0 @@
1
- import { BasedSchema } from '../types'
2
-
3
- export const isValidId = (schema: BasedSchema, id: any): boolean => {
4
- if (typeof id !== 'string') {
5
- return false
6
- }
7
-
8
- if (id === 'root') {
9
- return true
10
- }
11
-
12
- if (id.length > 16) {
13
- return false
14
- }
15
-
16
- const prefix = id.slice(0, 2)
17
-
18
- if (!schema.prefixToTypeMapping[prefix]) {
19
- return false
20
- }
21
-
22
- return true
23
- }
package/src/set/types.ts DELETED
File without changes