shinkansen-transmission 2.2.235 → 2.3.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 (38) hide show
  1. package/babel.config.cjs +1 -0
  2. package/eslint.config.mjs +28 -30
  3. package/index.d.mts +321 -16
  4. package/package.json +6 -6
  5. package/src/index.cjs +2 -0
  6. package/src/index.d.mts +10 -9
  7. package/src/transmission/common/index.d.mts +152 -87
  8. package/src/transmission/common/index.mjs +627 -193
  9. package/src/transmission/from-document-to-hash/array/index.mjs +20 -4
  10. package/src/transmission/from-document-to-hash/boolean/index.mjs +25 -9
  11. package/src/transmission/from-document-to-hash/index.d.mts +8 -19
  12. package/src/transmission/from-document-to-hash/index.mjs +102 -16
  13. package/src/transmission/from-document-to-hash/null/index.mjs +25 -9
  14. package/src/transmission/from-document-to-hash/number/index.mjs +25 -9
  15. package/src/transmission/from-document-to-hash/object/index.mjs +22 -6
  16. package/src/transmission/from-document-to-hash/string/index.mjs +25 -9
  17. package/src/transmission/from-hash-to-document/array/index.mjs +22 -5
  18. package/src/transmission/from-hash-to-document/boolean/index.mjs +21 -4
  19. package/src/transmission/from-hash-to-document/index.d.mts +24 -26
  20. package/src/transmission/from-hash-to-document/index.mjs +264 -142
  21. package/src/transmission/from-hash-to-document/null/index.mjs +21 -4
  22. package/src/transmission/from-hash-to-document/number/index.mjs +21 -4
  23. package/src/transmission/from-hash-to-document/object/index.mjs +22 -5
  24. package/src/transmission/from-hash-to-document/string/index.mjs +26 -4
  25. package/src/transmission/index.d.mts +4 -10
  26. package/src/transmission/to-zashiki/index.d.mts +5 -13
  27. package/src/transmission/to-zashiki/params/index.mjs +430 -0
  28. package/src/transmission/to-zashiki/render/array/index.mjs +737 -0
  29. package/src/transmission/to-zashiki/render/boolean/index.mjs +794 -0
  30. package/src/transmission/to-zashiki/render/index.mjs +157 -0
  31. package/src/transmission/to-zashiki/render/null/index.mjs +796 -0
  32. package/src/transmission/to-zashiki/render/number/index.mjs +940 -0
  33. package/src/transmission/to-zashiki/render/object/index.mjs +653 -0
  34. package/src/transmission/to-zashiki/render/string/index.mjs +910 -0
  35. package/src/transmission/to-zashiki/render-params/root-schema/index.mjs +212 -0
  36. package/src/transmission/to-zashiki/render-params/schema/index.mjs +731 -0
  37. package/src/transmission/to-zashiki/transform-root-schema.mjs +485 -421
  38. package/src/transmission/to-zashiki/transform-schema.mjs +1988 -4663
@@ -1,3 +1,41 @@
1
+ /**
2
+ * @typedef {TransmissionTypes.ObjectLiteralType} ObjectLiteralType
3
+ * @typedef {TransmissionTypes.ObjectType} ObjectType
4
+ *
5
+ * @typedef {TransmissionTypes.ItemsType} ItemsType
6
+ *
7
+ * @typedef {TransmissionTypes.Transmission.StringMetaType} TransmissionStringMetaType
8
+ * @typedef {TransmissionTypes.Transmission.NumberMetaType} TransmissionNumberMetaType
9
+ * @typedef {TransmissionTypes.Transmission.ArrayMetaType} TransmissionArrayMetaType
10
+ * @typedef {TransmissionTypes.Transmission.ObjectMetaType} TransmissionObjectMetaType
11
+ * @typedef {TransmissionTypes.Transmission.BooleanMetaType} TransmissionBooleanMetaType
12
+ * @typedef {TransmissionTypes.Transmission.NullMetaType} TransmissionNullMetaType
13
+ *
14
+ * @typedef {TransmissionTypes.Transmission.StringElementsType} TransmissionStringElementsType
15
+ * @typedef {TransmissionTypes.Transmission.NumberElementsType} TransmissionNumberElementsType
16
+ * @typedef {TransmissionTypes.Transmission.ArrayElementsType} TransmissionArrayElementsType
17
+ * @typedef {TransmissionTypes.Transmission.ObjectElementsType} TransmissionObjectElementsType
18
+ * @typedef {TransmissionTypes.Transmission.BooleanElementsType} TransmissionBooleanElementsType
19
+ * @typedef {TransmissionTypes.Transmission.NullElementsType} TransmissionNullElementsType
20
+ *
21
+ * @typedef {TransmissionTypes.EnumType} EnumType
22
+ * @typedef {TransmissionTypes.AnyOfType} AnyOfType
23
+ * @typedef {TransmissionTypes.OneOfType} OneOfType
24
+ * @typedef {TransmissionTypes.FieldType} FieldType
25
+ *
26
+ * @typedef {TransmissionTypes.SchemaType} SchemaType
27
+ *
28
+ * @typedef {TransmissionTypes.StringSchemaType} StringSchemaType
29
+ * @typedef {TransmissionTypes.NumberSchemaType} NumberSchemaType
30
+ * @typedef {TransmissionTypes.ArraySchemaType} ArraySchemaType
31
+ * @typedef {TransmissionTypes.ObjectSchemaType} ObjectSchemaType
32
+ * @typedef {TransmissionTypes.BooleanSchemaType} BooleanSchemaType
33
+ * @typedef {TransmissionTypes.NullSchemaType} NullSchemaType
34
+ *
35
+ * @typedef {TransmissionTypes.ValuesType} ValuesType
36
+ * @typedef {TransmissionTypes.ParamsType} ParamsType
37
+ */
38
+
1
39
  import debug from 'debug'
2
40
 
3
41
  import equal from 'fast-deep-equal'
@@ -6,41 +44,111 @@ const log = debug('shinkansen-transmission/transmission/common')
6
44
 
7
45
  log('`shinkansen` is awake')
8
46
 
47
+ /**
48
+ * @param {unknown} [v]
49
+ * @returns {v is (Record<PropertyKey, string | number | object | boolean | null | string[] | number[] | object[] | boolean[] | null[]> | Record<PropertyKey, never>)}
50
+ */
9
51
  export const isObject = (v) => (v || false) instanceof Object && !isArray(v)
10
52
 
53
+ /**
54
+ * @param {unknown} [v]
55
+ * @returns {v is (string[] | number[] | object[] | boolean[] | null[])} // | SchemaType)[]}
56
+ */
11
57
  export const isArray = (v) => Array.isArray(v)
12
58
 
59
+ /**
60
+ * @param {unknown} [v]
61
+ * @returns {v is (string | number | boolean | null)}
62
+ */
13
63
  export const isPrimitive = (v) => !isObject(v) && !isArray(v)
14
64
 
15
- export const isSchema = (v = {}) => Reflect.has(v, 'type')
65
+ /**
66
+ * @param {SchemaType | object} [v]
67
+ * @returns {v is SchemaType}
68
+ */
69
+ export const isSchema = (v = {}) => 'type' in v // Reflect.has(v, 'type')
16
70
 
71
+ /**
72
+ * @param {SchemaType} schema
73
+ * @returns {schema is StringSchemaType}
74
+ */
17
75
  export const isStringSchema = ({ type } = {}) => type === 'string'
18
76
 
77
+ /**
78
+ * @param {SchemaType} schema
79
+ * @returns {schema is NumberSchemaType}
80
+ */
19
81
  export const isNumberSchema = ({ type } = {}) => type === 'number'
20
82
 
83
+ /**
84
+ * @param {SchemaType} schema
85
+ * @returns {schema is ArraySchemaType}
86
+ */
21
87
  export const isArraySchema = ({ type } = {}) => type === 'array'
22
88
 
89
+ /**
90
+ * @param {SchemaType} schema
91
+ * @returns {schema is ObjectSchemaType}
92
+ */
23
93
  export const isObjectSchema = ({ type } = {}) => type === 'object'
24
94
 
95
+ /**
96
+ * @param {SchemaType} schema
97
+ * @returns {schema is BooleanSchemaType}
98
+ */
25
99
  export const isBooleanSchema = ({ type } = {}) => type === 'boolean'
26
100
 
101
+ /**
102
+ * @param {SchemaType} schema
103
+ * @returns {schema is NullSchemaType}
104
+ */
27
105
  export const isNullSchema = ({ type } = {}) => type === 'null'
28
106
 
107
+ /**
108
+ * @param {SchemaType} schema
109
+ * @returns {{ title: string} | {}}
110
+ */
29
111
  export const getTitle = ({ title } = {}) => (title ? { title } : {})
30
112
 
113
+ /**
114
+ * @param {SchemaType} schema
115
+ * @returns {{ description: string} | {}}
116
+ */
31
117
  export const getDescription = ({ description } = {}) => (description ? { description } : {})
32
118
 
119
+ /**
120
+ * @param {SchemaType} schema
121
+ * @returns {{ readOnly: boolean } | {}}
122
+ */
33
123
  export const getIsReadOnly = ({ readOnly = false } = {}) => (readOnly ? { readOnly } : {})
34
124
 
125
+ /**
126
+ * @param {SchemaType} schema
127
+ * @returns {{ writeOnly: boolean } | {}}
128
+ */
35
129
  export const getIsWriteOnly = ({ writeOnly = false } = {}) => (writeOnly ? { writeOnly } : {})
36
130
 
37
- const getUriForRegExp = (uri) => uri.endsWith('/') ? uri : uri.concat('/')
38
-
131
+ /**
132
+ * @param {string} uri
133
+ * @returns {string}
134
+ */
135
+ const getUriForRegExp = (uri) => uri.endsWith('/') ? uri : uri + '/'
136
+
137
+ /**
138
+ * @param {Record<string, string | number | boolean | null | string[] | number[] | boolean[] | null[]>} [values]
139
+ * @param {string} [uri]
140
+ * @returns {(
141
+ * string |
142
+ * number |
143
+ * boolean |
144
+ * null
145
+ * )[]}
146
+ */
39
147
  export function getSelectedItems (values = {}, uri = '#') {
40
148
  const u = normaliseUri(uri)
41
149
 
42
- if (Reflect.has(values, u)) {
43
- const v = Reflect.get(values, u)
150
+ if (u in values) { // if (Reflect.has(values, u)) {
151
+ const v = values[u] // Reflect.get(values, u)
44
152
 
45
153
  // transformByKeyForEnum
46
154
  // transformByKeyForAnyOf
@@ -83,12 +191,18 @@ export function getSelectedItems (values = {}, uri = '#') {
83
191
  const v = isArray(value) ? value[i] : value
84
192
  const n = Number(v)
85
193
 
86
- if (!isNaN(n)) return n
87
- return v
194
+ return isNaN(n)
195
+ ? v
196
+ : n
88
197
  })
89
198
  )
90
199
  }
91
200
 
201
+ /**
202
+ * @param {string} [parentUri]
203
+ * @param {string} [uri]
204
+ * @returns {boolean}
205
+ */
92
206
  export function isParentUri (parentUri = '#', uri = '#') {
93
207
  return (
94
208
  parentUri !== '#' &&
@@ -96,20 +210,44 @@ export function isParentUri (parentUri = '#', uri = '#') {
96
210
  )
97
211
  }
98
212
 
213
+ /**
214
+ * @param {ParamsType} [params]
215
+ * @param {string} [uri]
216
+ * @returns {TransmissionStringMetaType | TransmissionNumberMetaType | TransmissionArrayMetaType | TransmissionObjectMetaType | TransmissionBooleanMetaType | TransmissionNullMetaType | Record<string, never>}
217
+ */
99
218
  export function getMetaProps (params = {}, uri = '#') {
100
- let meta
101
- if (Reflect.has(params, uri)) {
102
- ({
103
- meta
104
- } = Reflect.get(params, uri))
219
+ if (uri in params) { // if (Reflect.has(params, uri)) {
220
+ const {
221
+ meta = {}
222
+ } = params[uri] // Reflect.get(params, uri))
223
+
224
+ return meta
225
+ }
226
+
227
+ return {}
228
+ }
229
+
230
+ /**
231
+ * @param {SchemaType} [schema]
232
+ * @returns {boolean}
233
+ */
234
+ export function hasMetaDefaultValue (schema = {}) {
235
+ if ('default' in schema) { // if (Reflect.has(schema, 'default') {
236
+ const defaultValue = schema.default // Reflect.get(schema, 'default')
237
+
238
+ return isPrimitive(defaultValue)
105
239
  }
106
240
 
107
- return meta || {}
241
+ return false
108
242
  }
109
243
 
244
+ /**
245
+ * @param {SchemaType} [schema]
246
+ * @returns {{ defaultValue: string } | {}}
247
+ */
110
248
  export function getMetaDefaultValue (schema = {}) {
111
- if (Reflect.has(schema, 'default')) {
112
- const defaultValue = Reflect.get(schema, 'default')
249
+ if ('default' in schema) { // if (Reflect.has(schema, 'default') {
250
+ const defaultValue = schema.default // Reflect.get(schema, 'default')
113
251
 
114
252
  return { defaultValue: String(defaultValue) }
115
253
  }
@@ -117,15 +255,21 @@ export function getMetaDefaultValue (schema = {}) {
117
255
  return {}
118
256
  }
119
257
 
258
+ /**
259
+ * @param {ValuesType} [values]
260
+ * @param {string} [uri]
261
+ * @param {SchemaType} [schema]
262
+ * @returns {boolean}
263
+ */
120
264
  export function hasMetaValue (values = {}, uri = '#', schema = {}) {
121
- if (Reflect.has(values, uri)) {
122
- const value = Reflect.get(values, uri)
265
+ if (uri in values) { // Reflect.has(values, uri)) {
266
+ const value = values[uri] // Reflect.get(values, uri)
123
267
 
124
268
  return isPrimitive(value)
125
269
  }
126
270
 
127
- if (Reflect.has(schema, 'const')) {
128
- const constValue = Reflect.get(schema, 'const')
271
+ if ('const' in schema) { // Reflect.has(schema, 'const')) {
272
+ const constValue = schema.const // Reflect.get(schema, 'const')
129
273
 
130
274
  return isPrimitive(constValue)
131
275
  }
@@ -133,17 +277,23 @@ export function hasMetaValue (values = {}, uri = '#', schema = {}) {
133
277
  return false
134
278
  }
135
279
 
280
+ /**
281
+ * @param {ValuesType} [values]
282
+ * @param {string} [uri]
283
+ * @param {SchemaType} [schema]
284
+ * @returns {{ value: string } | {}}
285
+ */
136
286
  export function getMetaValue (values = {}, uri = '#', schema = {}) {
137
- if (Reflect.has(values, uri)) {
138
- const value = Reflect.get(values, uri)
287
+ if (uri in values) { // if (Reflect.has(values, uri)) {
288
+ const value = values[uri] // Reflect.get(values, uri)
139
289
 
140
290
  if (isPrimitive(value)) {
141
291
  return { value: String(value) }
142
292
  }
143
293
  }
144
294
 
145
- if (Reflect.has(schema, 'const')) {
146
- const constValue = Reflect.get(schema, 'const')
295
+ if ('const' in schema) { // if (Reflect.has(schema, 'const')) {
296
+ const constValue = schema.const // Reflect.get(schema, 'const')
147
297
 
148
298
  if (isPrimitive(constValue)) {
149
299
  return { value: String(constValue) }
@@ -153,82 +303,85 @@ export function getMetaValue (values = {}, uri = '#', schema = {}) {
153
303
  return {}
154
304
  }
155
305
 
156
- export function transformValue (schema) {
157
- return (
158
- isObject(schema)
159
- ? hasConst(schema)
160
- ? getConst(schema)
161
- : hasDefault(schema)
162
- ? getDefault(schema)
163
- : schema
164
- : schema
165
- )
166
- }
167
-
168
- export function findByKey (parentUri, uri) {
169
- /*
170
- * log('findByKey')
171
- */
172
- return function find (key) {
173
- /*
174
- * log('find')
175
- */
176
- return getUri(parentUri, key) === uri
306
+ /**
307
+ * @param {string | number | object | boolean | null} [item]
308
+ * @returns {string | number | object | boolean | null | undefined}
309
+ */
310
+ export function transformToValue (item) {
311
+ if (isPrimitive(item)) return item
312
+
313
+ if (isObject(item)) {
314
+ if (hasConst(item)) {
315
+ return getConst(item)
316
+ } else {
317
+ if (hasDefault(item)) {
318
+ return getDefault(item)
319
+ }
320
+ }
177
321
  }
322
+
323
+ return item
178
324
  }
179
325
 
180
- export function findByIndex (parentUri, uri) {
326
+ /**
327
+ * @param {string} parentUri
328
+ * @param {string} uri
329
+ * @returns {(key: string | number) => boolean}
330
+ */
331
+ export function findByUri (parentUri, uri) {
181
332
  /*
182
- * log('findByIndex')
333
+ * log('findByUri')
183
334
  */
184
- return function find (schema, index) {
335
+ return function find (key) {
185
336
  /*
186
337
  * log('find')
187
338
  */
188
- if (hasEnum(schema)) {
189
- return getUri(parentUri, index) === uri
190
- }
191
-
192
- if (hasAnyOf(schema)) {
193
- const array = getAnyOf(schema)
194
339
 
195
- return array.find(findByIndex(parentUri, uri))
196
- }
197
-
198
- if (hasOneOf(schema)) {
199
- const array = getOneOf(schema)
200
-
201
- return array.find(findByIndex(parentUri, uri))
202
- }
203
-
204
- return getUri(parentUri, index) === uri
340
+ return (
341
+ getUri(parentUri, key) === uri
342
+ )
205
343
  }
206
344
  }
207
345
 
346
+ /**
347
+ * @param {string | number | object | boolean | null} [value]
348
+ * @returns {(item?: string | number | object | boolean | null | string[] | number[] | object[] | boolean[] | null[]) => boolean}
349
+ */
208
350
  export function findByValue (value) {
209
351
  /*
210
352
  * log('findByValue')
211
353
  */
212
- return function find (schema) {
354
+ return function find (item) {
213
355
  /*
214
356
  * log('find')
215
357
  */
216
- return value === transformValue(schema)
358
+
359
+ return (
360
+ value === transformToValue(item)
361
+ )
217
362
  }
218
363
  }
219
364
 
365
+ /**
366
+ * @param {string | number | object | boolean | null} [value]
367
+ * @returns {(item?: string | number | object | boolean | null | string[] | number[] | object[] | boolean[] | null[]) => boolean}
368
+ */
220
369
  export function findByEqual (value) {
221
370
  /*
222
371
  * log('findByEqual')
223
372
  */
224
- return function find (schema) {
373
+ return function find (item) {
225
374
  /*
226
375
  * log('find')
227
376
  */
228
- return equal(value, transformValue(schema))
377
+ return equal(value, transformToValue(item))
229
378
  }
230
379
  }
231
380
 
381
+ /**
382
+ * @param {string | number | object | boolean | null} [value]
383
+ * @returns {string}
384
+ */
232
385
  export function toString (value) {
233
386
  /*
234
387
  * log('toString')
@@ -236,57 +389,107 @@ export function toString (value) {
236
389
  return (value !== undefined) ? String(value) : ''
237
390
  }
238
391
 
239
- export function getObject ({ properties = {} /* object */ } = {}, parentUri = '', uri = '') {
240
- /*
241
- * log('getObject')
242
- */
243
- return (
244
- Reflect.get(properties, (
245
- Object.keys(properties)
246
- .find(findByKey(parentUri, uri))
247
- ))
248
- )
392
+ /**
393
+ * @param {{ items?: SchemaType | SchemaType[] }} [schema]
394
+ * @param {string} parentUri
395
+ * @param {string} uri
396
+ * @returns {SchemaType | undefined}
397
+ */
398
+ function getArray ({ items /* array or object */ } = {}, parentUri = '', uri = '') {
399
+ if (isArray(items)) {
400
+ const keys = Object.keys(items).map(Number)
401
+ const find = findByUri(parentUri, uri)
402
+
403
+ const key = keys.find(find)
404
+ if (typeof key === 'number') return items[key]
405
+ return undefined
406
+ }
407
+
408
+ if (isObject(items)) return items
409
+
410
+ return undefined
249
411
  }
250
412
 
251
- export function getArray ({ items = {} /* array or object */ } = {}, parentUri = '', uri = '') {
413
+ /**
414
+ * @param {{ properties?: Record<string, SchemaType> }} [schema]
415
+ * @param {string} [parentUri]
416
+ * @param {string} [uri]
417
+ * @returns {SchemaType | undefined}
418
+ */
419
+ export function getObject ({ properties /* object */ } = {}, parentUri = '', uri = '') {
252
420
  /*
253
- * log('getArray')
421
+ * log('getObject')
254
422
  */
255
- return (isArray(items))
256
- ? items.find(findByIndex(parentUri, uri))
257
- : items
423
+
424
+ if (isObject(properties)) {
425
+ const keys = Object.keys(properties).map(String)
426
+ const find = findByUri(parentUri, uri)
427
+
428
+ const key = keys.find(find)
429
+ if (typeof key === 'string') return properties[key]
430
+ }
431
+
432
+ return undefined
258
433
  }
259
434
 
435
+ /**
436
+ * @overload
437
+ * @param {(
438
+ * StringSchemaType |
439
+ * NumberSchemaType |
440
+ * ArraySchemaType |
441
+ * ObjectSchemaType |
442
+ * BooleanSchemaType |
443
+ * NullSchemaType
444
+ * )} schema
445
+ * @param {string} [parentUri]
446
+ * @param {string} [uri]
447
+ * @returns {SchemaType | undefined}
448
+ *
449
+ *
450
+ * @param {*} [schema]
451
+ * @param {string} [parentUri]
452
+ * @param {string} [uri]
453
+ * @returns {* | undefined}
454
+ */
260
455
  export function getSchema (schema = {}, parentUri = '', uri = '') {
261
456
  /*
262
457
  * log('getSchema')
263
458
  */
264
- const { type } = schema
459
+ const {
460
+ type
461
+ } = schema
265
462
 
266
463
  switch (type) {
267
- case 'object':
268
- return getObject(schema, parentUri, uri)
269
-
270
464
  case 'array':
271
465
  return getArray(schema, parentUri, uri)
272
466
 
467
+ case 'object':
468
+ return getObject(schema, parentUri, uri)
469
+
273
470
  default:
274
471
  return schema
275
472
  }
276
473
  }
277
474
 
475
+ /**
476
+ * @param {string[] | number[] | object[] | boolean[] | null[]} array
477
+ * @param {string | number | object | boolean | null} [value]
478
+ * @returns {string}
479
+ */
278
480
  export function transformValueIndexFor (array, value) {
279
481
  /*
280
- * log('transformValueIndexFor')
482
+ * log('transformEqualIndexFor')
281
483
  */
484
+
282
485
  const find = findByValue(value)
283
486
 
284
487
  if (array.some(find)) {
285
488
  const index = array.findIndex(find)
286
489
 
287
490
  /*
288
- * Transform a number to a string
289
- */
491
+ * Transform a number to a string
492
+ */
290
493
  return String(index)
291
494
  }
292
495
 
@@ -296,10 +499,16 @@ export function transformValueIndexFor (array, value) {
296
499
  return toString(value)
297
500
  }
298
501
 
502
+ /**
503
+ * @param {string[] | number[] | object[] | boolean[] | null[]} array
504
+ * @param {string | number | object | boolean | null} [value]
505
+ * @returns {string}
506
+ */
299
507
  export function transformEqualIndexFor (array, value) {
300
508
  /*
301
509
  * log('transformEqualIndexFor')
302
510
  */
511
+
303
512
  const find = findByEqual(value)
304
513
 
305
514
  if (array.some(find)) {
@@ -317,15 +526,21 @@ export function transformEqualIndexFor (array, value) {
317
526
  return toString(value)
318
527
  }
319
528
 
529
+ /**
530
+ * @param {ValuesType} [values]
531
+ * @param {string} [uri]
532
+ * @param {SchemaType} [schema]
533
+ * @returns {boolean}
534
+ */
320
535
  export function hasValue (values = {}, uri = '#', schema = {}) {
321
- if (Reflect.has(values, uri)) {
322
- const value = Reflect.get(values, uri)
536
+ if (uri in values) { // if (Reflect.has(values, uri)) {
537
+ const value = values[uri] // Reflect.get(values, uri)
323
538
 
324
539
  return isPrimitive(value)
325
540
  }
326
541
 
327
- if (Reflect.has(schema, 'const')) {
328
- const constValue = Reflect.get(schema, 'const')
542
+ if ('const' in schema) { // if (Reflect.has(schema, 'const')) {
543
+ const constValue = schema.const // Reflect.get(schema, 'const')
329
544
 
330
545
  return isPrimitive(constValue)
331
546
  }
@@ -333,34 +548,53 @@ export function hasValue (values = {}, uri = '#', schema = {}) {
333
548
  return false
334
549
  }
335
550
 
551
+ /**
552
+ * @param {ValuesType} [values]
553
+ * @param {string} [uri]
554
+ * @param {SchemaType} [schema]
555
+ * @returns {string}
556
+ */
336
557
  export function getValue (values = {}, uri = '#', schema = {}) {
337
- if (Reflect.has(values, uri)) {
338
- const value = Reflect.get(values, uri)
558
+ if (uri in values) { // if (Reflect.has(values, uri)) {
559
+ const value = values[uri] // Reflect.get(values, uri)
339
560
 
340
561
  if (isPrimitive(value)) {
341
562
  return String(value)
342
563
  }
343
564
  }
344
565
 
345
- if (Reflect.has(schema, 'const')) {
346
- const constValue = Reflect.get(schema, 'const')
566
+ if ('const' in schema) { // if (Reflect.has(schema, 'const')) {
567
+ const constValue = schema.const // Reflect.get(schema, 'const')
347
568
 
348
569
  if (isPrimitive(constValue)) {
349
570
  return String(constValue)
350
571
  }
351
572
  }
573
+
574
+ return ''
352
575
  }
353
576
 
577
+ /**
578
+ * @deprecated
579
+ *
580
+ * @param {string | number} v
581
+ * @param {{ enum?: ItemsType }} [schema]
582
+ * @returns {string}
583
+ */
354
584
  export function getValueForEnum (v, { enum: items = [] } = {}) {
355
- if (Reflect.has(items, v)) {
356
- const enumValue = Reflect.get(items, v)
585
+ if (v in items) { // @ts-ignore // if (Reflect.has(items, v)) {
586
+ const enumValue = items[v] // Reflect.get(items, v)
357
587
 
358
588
  return String(enumValue)
359
589
  }
590
+
591
+ return ''
360
592
  }
361
593
 
362
- /*
594
+ /**
363
595
  * Use `index` `item` `arrayIndex`
596
+ *
597
+ * @deprecated
364
598
  */
365
599
  export function getIndexForEnum (values = {}, parentUri = '#', uri = '#', schema = {}) {
366
600
  if (/\/\d+$/.test(uri)) {
@@ -373,20 +607,31 @@ export function getIndexForEnum (values = {}, parentUri = '#', uri = '#', schema
373
607
  return NaN
374
608
  }
375
609
 
610
+ /**
611
+ * @deprecated
612
+ *
613
+ * @param {string | number} v
614
+ * @param {{ anyOf?: ItemsType }} [schema]
615
+ * @returns {string}
616
+ */
376
617
  export function getValueForAnyOf (v, { anyOf: items = [] } = {}) {
377
- if (Reflect.has(items, v)) {
378
- const anyOf = Reflect.get(items, v)
618
+ if (v in items) { // @ts-ignore // if (Reflect.has(items, v)) {
619
+ const anyOf = items[v] // Reflect.get(items, v)
379
620
 
380
- const anyOfValue = transformValue(anyOf)
621
+ const anyOfValue = transformToValue(anyOf)
381
622
 
382
623
  if (isPrimitive(anyOfValue)) {
383
624
  return String(anyOfValue)
384
625
  }
385
626
  }
627
+
628
+ return ''
386
629
  }
387
630
 
388
- /*
631
+ /**
389
632
  * Use `index` `item` `arrayIndex`
633
+ *
634
+ * @deprecated
390
635
  */
391
636
  export function getIndexForAnyOf (values = {}, parentUri = '#', uri = '#', schema = {}) {
392
637
  if (/\/\d+$/.test(uri)) {
@@ -399,20 +644,31 @@ export function getIndexForAnyOf (values = {}, parentUri = '#', uri = '#', schem
399
644
  return NaN
400
645
  }
401
646
 
647
+ /**
648
+ * @deprecated
649
+ *
650
+ * @param {string | number} v
651
+ * @param {{ oneOf?: ItemsType }} [schema]
652
+ * @returns {string}
653
+ */
402
654
  export function getValueForOneOf (v, { oneOf: items = [] } = {}) {
403
- if (Reflect.has(items, v)) {
404
- const oneOf = Reflect.get(items, v)
655
+ if (v in items) { // @ts-ignore // if (Reflect.has(items, v)) {
656
+ const oneOf = items[v] // Reflect.get(items, v)
405
657
 
406
- const oneOfValue = transformValue(oneOf)
658
+ const oneOfValue = transformToValue(oneOf)
407
659
 
408
660
  if (isPrimitive(oneOfValue)) {
409
661
  return String(oneOfValue)
410
662
  }
411
663
  }
664
+
665
+ return ''
412
666
  }
413
667
 
414
- /*
668
+ /**
415
669
  * Use `index` `item` `arrayIndex`
670
+ *
671
+ * @deprecated
416
672
  */
417
673
  export function getIndexForOneOf (values = {}, parentUri = '#', uri = '#', schema = {}) {
418
674
  if (/\/\d+$/.test(uri)) {
@@ -425,127 +681,158 @@ export function getIndexForOneOf (values = {}, parentUri = '#', uri = '#', schem
425
681
  return NaN
426
682
  }
427
683
 
684
+ /**
685
+ * @param {ParamsType} [params]
686
+ * @param {string} [uri]
687
+ * @returns {TransmissionStringElementsType | TransmissionNumberElementsType | TransmissionArrayElementsType | TransmissionObjectElementsType | TransmissionBooleanElementsType | TransmissionNullElementsType | Record<string, never>}
688
+ */
428
689
  export function getElementsProps (params = {}, uri = '#') {
429
- let elements
430
- if (Reflect.has(params, uri)) {
431
- ({
690
+ if (uri in params) { // if (Reflect.has(values, uri)) {
691
+ const {
432
692
  elements = {}
433
- } = Reflect.get(params, uri))
434
- }
435
-
436
- return elements || {}
437
- }
438
-
439
- export function getElementsTitleProps (params = {}, uri = '#') {
440
- let title
441
- if (Reflect.has(params, uri)) {
442
- ({
443
- elements: {
444
- title
445
- } = {}
446
- } = Reflect.get(params, uri))
447
- }
693
+ } = params[uri] // Reflect.get(values, uri)
448
694
 
449
- return title || {}
450
- }
451
-
452
- export function getElementsDescriptionProps (params = {}, uri = '#') {
453
- let description
454
- if (Reflect.has(params, uri)) {
455
- ({
456
- elements: {
457
- description
458
- } = {}
459
- } = Reflect.get(params, uri))
695
+ return elements
460
696
  }
461
697
 
462
- return description || {}
698
+ return {}
463
699
  }
464
700
 
701
+ /**
702
+ * @param {ParamsType} [params]
703
+ * @param {string} [uri]
704
+ * @returns {EnumType | ObjectLiteralType}
705
+ */
465
706
  export function getElementsFieldPropsForEnum (params = {}, uri = '#') {
466
- let field
467
- if (Reflect.has(params, uri)) {
468
- ({
707
+ if (uri in params) { // if (Reflect.has(values, uri)) {
708
+ /**
709
+ * @type {{ elements?: { enum?: EnumType | ObjectLiteralType } }}
710
+ */
711
+ const {
469
712
  elements: {
470
- enum: field
713
+ enum: value = {}
471
714
  } = {}
472
- } = Reflect.get(params, uri))
715
+ } = params[uri] // Reflect.get(values, uri)
716
+
717
+ return value
473
718
  }
474
719
 
475
- return field || {}
720
+ return {}
476
721
  }
477
722
 
723
+ /**
724
+ * @param {ParamsType} [params]
725
+ * @param {string} [uri]
726
+ * @returns {OneOfType | ObjectLiteralType}
727
+ */
478
728
  export function getElementsFieldPropsForOneOf (params = {}, uri = '#') {
479
- let field
480
- if (Reflect.has(params, uri)) {
481
- ({
729
+ if (uri in params) { // if (Reflect.has(values, uri)) {
730
+ /**
731
+ * @type {{ elements?: { oneOf?: OneOfType | ObjectLiteralType } }}
732
+ */
733
+ const {
482
734
  elements: {
483
- oneOf: field
735
+ oneOf: value = {}
484
736
  } = {}
485
- } = Reflect.get(params, uri))
737
+ } = params[uri] // Reflect.get(values, uri)
738
+
739
+ return value
486
740
  }
487
741
 
488
- return field || {}
742
+ return {}
489
743
  }
490
744
 
745
+ /**
746
+ * @param {ParamsType} [params]
747
+ * @param {string} [uri]
748
+ * @returns {AnyOfType | ObjectLiteralType}
749
+ */
491
750
  export function getElementsFieldPropsForAnyOf (params = {}, uri = '#') {
492
- let field
493
- if (Reflect.has(params, uri)) {
494
- ({
751
+ if (uri in params) { // if (Reflect.has(values, uri)) {
752
+ /**
753
+ * @type {{ elements?: { anyOf?: AnyOfType | ObjectLiteralType } }}
754
+ */
755
+ const {
495
756
  elements: {
496
- anyOf: field
757
+ anyOf: value = {}
497
758
  } = {}
498
- } = Reflect.get(params, uri))
759
+ } = params[uri] // Reflect.get(values, uri)
760
+
761
+ return value
499
762
  }
500
763
 
501
- return field || {}
764
+ return {}
502
765
  }
503
766
 
767
+ /**
768
+ * @param {ParamsType} [params]
769
+ * @param {string} [uri]
770
+ * @returns {FieldType | ObjectLiteralType}
771
+ */
504
772
  export function getElementsFieldPropsForAllOf (params = {}, uri = '#') {
505
- let field
506
- if (Reflect.has(params, uri)) {
507
- ({
773
+ if (uri in params) { // if (Reflect.has(values, uri)) {
774
+ /**
775
+ * @type {{ elements?: { field?: FieldType | ObjectLiteralType } }}
776
+ */
777
+ const {
508
778
  elements: {
509
- field
779
+ field: value = {}
510
780
  } = {}
511
- } = Reflect.get(params, uri))
781
+ } = params[uri] // Reflect.get(values, uri)
782
+
783
+ return value
512
784
  }
513
785
 
514
- return field || {}
786
+ return {}
515
787
  }
516
788
 
789
+ /**
790
+ * @param {ParamsType} [params]
791
+ * @param {string} [uri]
792
+ * @returns {FieldType | ObjectLiteralType}
793
+ */
517
794
  export function getElementsFieldProps (params = {}, uri = '#') {
518
- let field
519
- if (Reflect.has(params, uri)) {
520
- ({
795
+ if (uri in params) { // if (Reflect.has(values, uri)) {
796
+ /**
797
+ * @type {{ elements?: { field?: FieldType | ObjectLiteralType } }}
798
+ */
799
+ const {
521
800
  elements: {
522
- field
801
+ field: value = {}
523
802
  } = {}
524
- } = Reflect.get(params, uri))
803
+ } = params[uri] // Reflect.get(values, uri)
804
+
805
+ return value
525
806
  }
526
807
 
527
- return field || {}
808
+ return {}
528
809
  }
529
810
 
811
+ /**
812
+ * @param {ValuesType} [values]
813
+ * @param {string} [uri]
814
+ * @param {SchemaType} [schema]
815
+ * @returns {{ value: string } | {}}
816
+ */
530
817
  export function getElementsFieldValue (values = {}, uri = '#', schema = {}) {
531
- if (Reflect.has(values, uri)) {
532
- const value = Reflect.get(values, uri)
818
+ if (uri in values) { // (Reflect.has(values, uri)) {
819
+ const value = values[uri] // Reflect.get(values, uri)
533
820
 
534
821
  if (isPrimitive(value)) {
535
822
  return { value: String(value) }
536
823
  }
537
824
  }
538
825
 
539
- if (Reflect.has(schema, 'const')) {
540
- const constValue = Reflect.get(schema, 'const')
826
+ if ('const' in schema) { // Reflect.has(schema, 'const')) {
827
+ const constValue = schema.const // Reflect.get(schema, 'const')
541
828
 
542
829
  if (isPrimitive(constValue)) {
543
830
  return { value: String(constValue) }
544
831
  }
545
832
  }
546
833
 
547
- if (Reflect.has(schema, 'default')) {
548
- const defaultValue = Reflect.get(schema, 'default')
834
+ if ('default' in schema) { // Reflect.has(schema, 'default')) {
835
+ const defaultValue = schema.default // Reflect.get(schema, 'default')
549
836
 
550
837
  if (isPrimitive(defaultValue)) {
551
838
  return { value: String(defaultValue) }
@@ -555,67 +842,182 @@ export function getElementsFieldValue (values = {}, uri = '#', schema = {}) {
555
842
  return {}
556
843
  }
557
844
 
558
- export const hasEnum = (schema = {}) => Reflect.has(schema, 'enum')
559
- export const getEnum = (schema = {}) => Reflect.get(schema, 'enum')
845
+ /**
846
+ * @param {{ 'enum'?: ItemsType }} [schema]
847
+ * @returns {schema is { 'enum': ItemsType }}
848
+ */
849
+ export const hasEnum = (schema = {}) => 'enum' in schema // Reflect.has(schema, 'enum')
850
+
851
+ /**
852
+ * @overload
853
+ * @param {{ 'enum': ItemsType }} schema
854
+ * @returns {ItemsType}
855
+ *
856
+ * @param {{ 'enum'?: ItemsType }} [schema]
857
+ * @returns {ItemsType | undefined}
858
+ */
859
+ export const getEnum = (schema = {}) => schema.enum // Reflect.get(schema, 'enum')
560
860
 
561
- export const hasConst = (schema = {}) => Reflect.has(schema, 'const')
562
- export const getConst = (schema = {}) => Reflect.get(schema, 'const')
861
+ /**
862
+ * @param {{ 'const'?: string | number | object | boolean | null }} [schema]
863
+ * @returns {schema is { 'const': string | number | object | boolean | null }}
864
+ */
865
+ export const hasConst = (schema = {}) => 'const' in schema // Reflect.has(schema, 'const')
866
+
867
+ /**
868
+ * @overload
869
+ * @param {{ 'const': string | number | object | boolean | null }} schema
870
+ * @returns {string | number | object | boolean | null}
871
+ *
872
+ * @param {{ 'const'?: string | number | object | boolean | null }} [schema]
873
+ * @returns {string | number | object | boolean | null | undefined}
874
+ */
875
+ export const getConst = (schema = {}) => schema.const // Reflect.get(schema, 'const')
563
876
 
564
- export const hasDefault = (schema = {}) => Reflect.has(schema, 'default')
565
- export const getDefault = (schema = {}) => Reflect.get(schema, 'default')
877
+ /**
878
+ * @param {{ 'default'?: string | number | object | boolean | null }} [schema]
879
+ * @returns {schema is { 'default': string | number | object | boolean | null }}
880
+ */
881
+ export const hasDefault = (schema = {}) => 'default' in schema // Reflect.has(schema, 'default')
882
+
883
+ /**
884
+ * @overload
885
+ * @param {{ 'default': string | number | object | boolean | null }} schema
886
+ * @returns {string | number | object | boolean | null}
887
+ *
888
+ * @param {{ 'default'?: string | number | object | boolean | null }} [schema]
889
+ * @returns {string | number | object | boolean | null | undefined}
890
+ */
891
+ export const getDefault = (schema = {}) => schema.default // Reflect.get(schema, 'default')
566
892
 
567
- export const hasAnyOf = (schema = {}) => Reflect.has(schema, 'anyOf')
568
- export const getAnyOf = (schema = {}) => Reflect.get(schema, 'anyOf')
893
+ /**
894
+ * @param {{ 'anyOf'?: ItemsType }} [schema]
895
+ * @returns {schema is { 'anyOf': ItemsType }}
896
+ */
897
+ export const hasAnyOf = (schema = {}) => 'anyOf' in schema // Reflect.has(schema, 'anyOf')
898
+
899
+ /**
900
+ * @overload
901
+ * @param {{ 'anyOf': ItemsType }} schema
902
+ * @returns {ItemsType}
903
+ *
904
+ * @param {{ 'anyOf'?: ItemsType }} [schema]
905
+ * @returns {ItemsType | undefined}
906
+ */
907
+ export const getAnyOf = (schema = {}) => schema.anyOf // Reflect.get(schema, 'anyOf')
569
908
 
570
- export const hasOneOf = (schema = {}) => Reflect.has(schema, 'oneOf')
571
- export const getOneOf = (schema = {}) => Reflect.get(schema, 'oneOf')
909
+ /**
910
+ * @param {{ 'oneOf'?: ItemsType }} [schema]
911
+ * @returns {schema is { 'oneOf': ItemsType }}
912
+ */
913
+ export const hasOneOf = (schema = {}) => 'oneOf' in schema // Reflect.has(schema, 'oneOf')
914
+
915
+ /**
916
+ * @overload
917
+ * @param {{ 'oneOf': ItemsType }} schema
918
+ * @returns {ItemsType}
919
+ *
920
+ * @param {{ 'oneOf'?: ItemsType }} schema
921
+ * @returns {ItemsType | undefined}
922
+ */
923
+ export const getOneOf = (schema = {}) => schema.oneOf // Reflect.get(schema, 'oneOf')
572
924
 
573
- export const hasAllOf = (schema = {}) => Reflect.has(schema, 'allOf')
574
- export const getAllOf = (schema = {}) => Reflect.get(schema, 'allOf')
925
+ /**
926
+ * @param {{ 'allOf'?: ItemsType }} [schema]
927
+ * @returns {schema is { 'allOf': ItemsType }}
928
+ */
929
+ export const hasAllOf = (schema = {}) => 'allOf' in schema // Reflect.has(schema, 'allOf')
930
+
931
+ /**
932
+ * @overload
933
+ * @param {{ 'allOf': ItemsType }} schema
934
+ * @returns {ItemsType}
935
+ *
936
+ * @param {{ 'allOf'?: ItemsType }} [schema]
937
+ * @returns {ItemsType | undefined}
938
+ */
939
+ export const getAllOf = (schema = {}) => schema.allOf // Reflect.get(schema, 'allOf')
575
940
 
576
- export const getUri = (uri = '#', resource = '') => (uri.endsWith('/') ? uri : uri.concat('/')).concat(resource)
941
+ /**
942
+ * @param {string} [uri]
943
+ * @param {string | number} [resource]
944
+ * @returns {string}
945
+ */
946
+ export const getUri = (uri = '#', resource = '') => (uri.endsWith('/') ? uri : uri + '/') + String(resource)
577
947
 
948
+ /**
949
+ * @param {string} [uri]
950
+ * @returns {string}
951
+ */
578
952
  export const normaliseUri = (uri = '#') => uri === '#' ? '#/' : uri
579
953
 
954
+ /**
955
+ * @param {{ minimum?: number }} schema
956
+ * @returns {{ min: number } | {}}
957
+ */
580
958
  export function getMin ({ minimum } = {}) {
581
959
  const value = Number(minimum)
582
960
 
583
961
  return isNaN(value) ? {} : { min: value }
584
962
  }
585
963
 
964
+ /**
965
+ * @param {{ maximum?: number }} schema
966
+ * @returns {{ max: number } | {}}
967
+ */
586
968
  export function getMax ({ maximum } = {}) {
587
969
  const value = Number(maximum)
588
970
 
589
971
  return isNaN(value) ? {} : { max: value }
590
972
  }
591
973
 
974
+ /**
975
+ * @param {{ minLength?: number }} schema
976
+ * @returns {{ minLength: number } | {}}
977
+ */
592
978
  export function getMinLength ({ minLength } = {}) {
593
979
  const value = Number(minLength)
594
980
 
595
981
  return isNaN(value) ? {} : { minLength: value }
596
982
  }
597
983
 
984
+ /**
985
+ * @param {{ maxLength?: number }} schema
986
+ * @returns {{ maxLength: number } | {}}
987
+ */
598
988
  export function getMaxLength ({ maxLength } = {}) {
599
989
  const value = Number(maxLength)
600
990
 
601
991
  return isNaN(value) ? {} : { maxLength: value }
602
992
  }
603
993
 
994
+ /**
995
+ * @param {{ minItems?: number }} schema
996
+ * @returns {{ minItems: number } | {}}
997
+ */
604
998
  export function getMinItems ({ minItems } = {}) {
605
999
  const value = Number(minItems)
606
1000
 
607
1001
  return isNaN(value) ? {} : { minItems: value }
608
1002
  }
609
1003
 
1004
+ /**
1005
+ * @param {{ maxItems?: number }} schema
1006
+ * @returns {{ maxItems: number } | {}}
1007
+ */
610
1008
  export function getMaxItems ({ maxItems } = {}) {
611
1009
  const value = Number(maxItems)
612
1010
 
613
1011
  return isNaN(value) ? {} : { maxItems: value }
614
1012
  }
615
1013
 
1014
+ /**
1015
+ * @param {{ uniqueItems?: boolean }} schema
1016
+ * @returns {{ hasUniqueItems: boolean } | {}}
1017
+ */
616
1018
  export function getHasUniqueItems (schema = {}) {
617
- if (Reflect.has(schema, 'uniqueItems')) {
618
- const value = Reflect.get(schema, 'uniqueItems')
1019
+ if ('uniqueItems' in schema) { // if (Reflect.has(schema, 'uniqueItems') {
1020
+ const value = schema.uniqueItems // Reflect.get(schema, 'uniqueItems')
619
1021
 
620
1022
  return (typeof value === 'boolean') ? { hasUniqueItems: value } : {}
621
1023
  }
@@ -623,33 +1025,53 @@ export function getHasUniqueItems (schema = {}) {
623
1025
  return {}
624
1026
  }
625
1027
 
1028
+ /**
1029
+ * @param {{ minContains?: number }} schema
1030
+ * @returns {{ minContains: number } | {}}
1031
+ */
626
1032
  export function getMinContains ({ minContains } = {}) {
627
1033
  const value = Number(minContains)
628
1034
 
629
1035
  return isNaN(value) ? {} : { minContains: value }
630
1036
  }
631
1037
 
1038
+ /**
1039
+ * @param {{ maxContains?: number }} schema
1040
+ * @returns {{ maxContains: number } | {}}
1041
+ */
632
1042
  export function getMaxContains ({ maxContains } = {}) {
633
1043
  const value = Number(maxContains)
634
1044
 
635
1045
  return isNaN(value) ? {} : { maxContains: value }
636
1046
  }
637
1047
 
1048
+ /**
1049
+ * @param {{ minProperties?: number }} schema
1050
+ * @returns {{ minProperties: number } | {}}
1051
+ */
638
1052
  export function getMinProperties ({ minProperties } = {}) {
639
1053
  const value = Number(minProperties)
640
1054
 
641
1055
  return isNaN(value) ? {} : { minProperties: value }
642
1056
  }
643
1057
 
1058
+ /**
1059
+ * @param {{ maxProperties?: number }} schema
1060
+ * @returns {{ maxProperties: number } | {}}
1061
+ */
644
1062
  export function getMaxProperties ({ maxProperties } = {}) {
645
1063
  const value = Number(maxProperties)
646
1064
 
647
1065
  return isNaN(value) ? {} : { maxProperties: value }
648
1066
  }
649
1067
 
1068
+ /**
1069
+ * @param {{ exclusiveMinimum?: boolean }} schema
1070
+ * @returns {{ isExclusiveMin: boolean } | {}}
1071
+ */
650
1072
  export function getIsExclusiveMin (schema = {}) {
651
- if (Reflect.has(schema, 'exclusiveMinimum')) {
652
- const value = Reflect.get(schema, 'exclusiveMinimum')
1073
+ if ('exclusiveMinimum' in schema) { // if (Reflect.has(schema, 'exclusiveMinimum') {
1074
+ const value = schema.exclusiveMinimum // Reflect.get(schema, 'exclusiveMinimum')
653
1075
 
654
1076
  return (typeof value === 'boolean') ? { isExclusiveMin: value } : {}
655
1077
  }
@@ -657,9 +1079,13 @@ export function getIsExclusiveMin (schema = {}) {
657
1079
  return {}
658
1080
  }
659
1081
 
1082
+ /**
1083
+ * @param {{ exclusiveMaximum?: boolean }} schema
1084
+ * @returns {{ isExclusiveMax: boolean } | {}}
1085
+ */
660
1086
  export function getIsExclusiveMax (schema = {}) {
661
- if (Reflect.has(schema, 'exclusiveMaximum')) {
662
- const value = Reflect.get(schema, 'exclusiveMaximum')
1087
+ if ('exclusiveMaximum' in schema) { // if (Reflect.has(schema, 'exclusiveMaximum') {
1088
+ const value = schema.exclusiveMaximum // Reflect.get(schema, 'exclusiveMaximum')
663
1089
 
664
1090
  return (typeof value === 'boolean') ? { isExclusiveMax: value } : {}
665
1091
  }
@@ -667,8 +1093,16 @@ export function getIsExclusiveMax (schema = {}) {
667
1093
  return {}
668
1094
  }
669
1095
 
1096
+ /**
1097
+ * @param {{ pattern?: RegExp }} schema
1098
+ * @returns {{ pattern: RegExp } | {}}
1099
+ */
670
1100
  export const getPattern = ({ pattern } = {}) => (pattern ? { pattern } : {})
671
1101
 
1102
+ /**
1103
+ * @param {{ multipleOf?: number }} schema
1104
+ * @returns {{ step: number } | {}}
1105
+ */
672
1106
  export function getStep ({ multipleOf } = {}) {
673
1107
  const value = Number(multipleOf)
674
1108