shinkansen-transmission 2.3.6 → 2.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.d.mts +22 -22
- package/package.json +1 -1
- package/src/transmission/common/index.d.mts +30 -38
- package/src/transmission/common/index.mjs +76 -196
- package/src/transmission/common/transform/index.d.mts +18 -0
- package/src/transmission/common/transform/index.mjs +128 -0
- package/src/transmission/from-document-to-hash/array/index.d.mts +1 -0
- package/src/transmission/from-document-to-hash/array/index.mjs +1 -46
- package/src/transmission/from-document-to-hash/boolean/index.d.mts +5 -0
- package/src/transmission/from-document-to-hash/boolean/index.mjs +7 -7
- package/src/transmission/from-document-to-hash/index.d.mts +10 -3
- package/src/transmission/from-document-to-hash/index.mjs +121 -60
- package/src/transmission/from-document-to-hash/null/index.d.mts +5 -0
- package/src/transmission/from-document-to-hash/null/index.mjs +7 -7
- package/src/transmission/from-document-to-hash/number/index.d.mts +5 -0
- package/src/transmission/from-document-to-hash/number/index.mjs +7 -7
- package/src/transmission/from-document-to-hash/object/index.d.mts +1 -0
- package/src/transmission/from-document-to-hash/object/index.mjs +1 -46
- package/src/transmission/from-document-to-hash/string/index.d.mts +5 -0
- package/src/transmission/from-document-to-hash/string/index.mjs +8 -8
- package/src/transmission/from-hash-to-document/array/index.d.mts +4 -0
- package/src/transmission/from-hash-to-document/array/index.mjs +4 -42
- package/src/transmission/from-hash-to-document/boolean/index.d.mts +8 -0
- package/src/transmission/from-hash-to-document/boolean/index.mjs +84 -3
- package/src/transmission/from-hash-to-document/index.d.mts +28 -21
- package/src/transmission/from-hash-to-document/index.mjs +184 -352
- package/src/transmission/from-hash-to-document/null/index.d.mts +8 -0
- package/src/transmission/from-hash-to-document/null/index.mjs +84 -3
- package/src/transmission/from-hash-to-document/number/index.d.mts +8 -0
- package/src/transmission/from-hash-to-document/number/index.mjs +84 -3
- package/src/transmission/from-hash-to-document/object/index.d.mts +4 -0
- package/src/transmission/from-hash-to-document/object/index.mjs +4 -42
- package/src/transmission/from-hash-to-document/string/index.d.mts +8 -0
- package/src/transmission/from-hash-to-document/string/index.mjs +85 -4
package/index.d.mts
CHANGED
@@ -5,38 +5,38 @@ declare global {
|
|
5
5
|
export type ArrayLiteralType = never[]
|
6
6
|
export type ArrayType = unknown[]
|
7
7
|
|
8
|
-
export type
|
9
|
-
|
10
|
-
export type
|
8
|
+
export type MemberArrayType = string[] | number[] | object[] | boolean[] | null[]
|
9
|
+
export type MemberType = string | number | object | boolean | null
|
10
|
+
export type SelectedMemberArrayType = MemberType[]
|
11
11
|
|
12
12
|
export interface EnumType {
|
13
13
|
id: string
|
14
14
|
name?: string
|
15
|
-
items?:
|
16
|
-
selectedItems?:
|
15
|
+
items?: MemberArrayType
|
16
|
+
selectedItems?: SelectedMemberArrayType
|
17
17
|
}
|
18
18
|
|
19
19
|
export interface AnyOfType {
|
20
20
|
id: string
|
21
21
|
name?: string
|
22
|
-
items?:
|
23
|
-
selectedItems?:
|
22
|
+
items?: MemberArrayType
|
23
|
+
selectedItems?: SelectedMemberArrayType
|
24
24
|
}
|
25
25
|
|
26
26
|
export interface OneOfType {
|
27
27
|
id: string
|
28
28
|
name?: string
|
29
|
-
items?:
|
30
|
-
selectedItems?:
|
29
|
+
items?: MemberArrayType
|
30
|
+
selectedItems?: SelectedMemberArrayType
|
31
31
|
}
|
32
32
|
|
33
33
|
export interface FieldType {
|
34
34
|
id: string
|
35
35
|
name?: string
|
36
|
-
items?:
|
37
|
-
selectedItems?:
|
38
|
-
value?:
|
39
|
-
defaultValue?:
|
36
|
+
items?: MemberArrayType
|
37
|
+
selectedItems?: SelectedMemberArrayType
|
38
|
+
value?: MemberType | MemberArrayType
|
39
|
+
defaultValue?: MemberType | MemberArrayType
|
40
40
|
}
|
41
41
|
|
42
42
|
export interface SchemaType {
|
@@ -48,12 +48,12 @@ declare global {
|
|
48
48
|
required?: string[]
|
49
49
|
readOnly?: boolean
|
50
50
|
writeOnly?: boolean
|
51
|
-
const?:
|
52
|
-
default?:
|
53
|
-
enum?:
|
54
|
-
anyOf?:
|
55
|
-
oneOf?:
|
56
|
-
allOf?:
|
51
|
+
const?: MemberType
|
52
|
+
default?: MemberType
|
53
|
+
enum?: MemberArrayType
|
54
|
+
anyOf?: MemberArrayType
|
55
|
+
oneOf?: MemberArrayType
|
56
|
+
allOf?: MemberArrayType
|
57
57
|
minimum?: number
|
58
58
|
maximum?: number
|
59
59
|
minLength?: number
|
@@ -111,8 +111,8 @@ declare global {
|
|
111
111
|
defaultValue?: string
|
112
112
|
item?: number
|
113
113
|
name?: string
|
114
|
-
selectedItems?:
|
115
|
-
items?:
|
114
|
+
selectedItems?: SelectedMemberArrayType
|
115
|
+
items?: MemberArrayType
|
116
116
|
isRequired?: boolean
|
117
117
|
component?: string
|
118
118
|
}
|
@@ -319,7 +319,7 @@ declare global {
|
|
319
319
|
/**
|
320
320
|
* A JSON Schema document
|
321
321
|
*/
|
322
|
-
export type DocumentType =
|
322
|
+
export type DocumentType = MemberType | MemberArrayType
|
323
323
|
|
324
324
|
/**
|
325
325
|
* String keys with string or string array values
|
package/package.json
CHANGED
@@ -1,7 +1,8 @@
|
|
1
1
|
export type ObjectLiteralType = TransmissionTypes.ObjectLiteralType
|
2
2
|
export type ObjectType = TransmissionTypes.ObjectType
|
3
3
|
|
4
|
-
export type
|
4
|
+
export type MemberArrayType = TransmissionTypes.MemberArrayType
|
5
|
+
export type MemberType = TransmissionTypes.MemberType
|
5
6
|
|
6
7
|
export type StringMetaType = TransmissionTypes.Transmission.StringMetaType
|
7
8
|
export type NumberMetaType = TransmissionTypes.Transmission.NumberMetaType
|
@@ -34,8 +35,8 @@ export type NullSchemaType = TransmissionTypes.NullSchemaType
|
|
34
35
|
export type ValuesType = TransmissionTypes.ValuesType
|
35
36
|
export type ParamsType = TransmissionTypes.ParamsType
|
36
37
|
|
37
|
-
export function isObject (v?: unknown): v is (Record<PropertyKey,
|
38
|
-
export function isArray (v?: unknown): v is (
|
38
|
+
export function isObject (v?: unknown): v is (Record<PropertyKey, MemberType | MemberArrayType> | Record<PropertyKey, never>)
|
39
|
+
export function isArray (v?: unknown): v is (MemberArrayType)
|
39
40
|
export function isPrimitive (v?: unknown): v is string | number | boolean | null
|
40
41
|
|
41
42
|
export function isSchema (v?: SchemaType | object): v is SchemaType
|
@@ -61,14 +62,14 @@ export function getMetaDefaultValue (schema?: SchemaType): { defaultValue: strin
|
|
61
62
|
export function hasMetaValue (values?: ValuesType, uri?: string, schema?: SchemaType): boolean
|
62
63
|
export function getMetaValue (values?: ValuesType, uri?: string, schema?: SchemaType): { value: string } | ObjectLiteralType
|
63
64
|
|
64
|
-
export function transformToValue (schema?:
|
65
|
+
export function transformToValue (schema?: MemberType): MemberType | undefined
|
65
66
|
|
66
67
|
export function getFindByKey (parentUri: string, uri: string): (key: string | number) => boolean
|
67
68
|
export function getFindByIndex (parentUri: string, uri: string): (item: SchemaType, index: number) => boolean
|
68
|
-
export function getFindByValue (value?:
|
69
|
-
export function getFindByEqual (value?:
|
69
|
+
export function getFindByValue (value?: MemberType): (item?: MemberType | MemberArrayType) => boolean
|
70
|
+
export function getFindByEqual (value?: MemberType): (item?: MemberType | MemberArrayType) => boolean
|
70
71
|
|
71
|
-
export function toString (value?:
|
72
|
+
export function toString (value?: MemberType): string
|
72
73
|
|
73
74
|
export function getArray (schema?: { items?: SchemaType | SchemaType[] }, parentUri?: string, uri?: string): SchemaType | undefined
|
74
75
|
export function getObject (schema?: { properties?: Record<string, SchemaType> }, parentUri?: string, uri?: string): SchemaType | undefined
|
@@ -94,24 +95,15 @@ declare function getSchema (
|
|
94
95
|
|
95
96
|
export { getSchema }
|
96
97
|
|
97
|
-
export function
|
98
|
-
export function
|
98
|
+
export function transformIndexToValueByFindValue (array: MemberArrayType, value?: MemberType): string
|
99
|
+
export function transformIndexToValueByFindEqual (array: MemberArrayType, value?: MemberType): string
|
99
100
|
|
100
|
-
export function
|
101
|
-
export function
|
101
|
+
export function findIndexByValue (array: MemberArrayType, value?: MemberType): number
|
102
|
+
export function findIndexByEqual (array: MemberArrayType, value?: MemberType): number
|
102
103
|
|
103
104
|
export function hasValue (values?: ValuesType, uri?: string, schema?: SchemaType): boolean
|
104
105
|
export function getValue (values?: ValuesType, uri?: string, schema?: SchemaType): string
|
105
106
|
|
106
|
-
export function getValueForEnum (v: string | number, schema?: { enum?: ItemsType }): string
|
107
|
-
export function getIndexForEnum (values?: ValuesType, parentUri?: string, uri?: string, schema?: SchemaType): number
|
108
|
-
|
109
|
-
export function getValueForAnyOf (v: string | number, schema?: { anyOf?: ItemsType }): string
|
110
|
-
export function getIndexForAnyOf (values?: ValuesType, parentUri?: string, uri?: string, schema?: SchemaType): number
|
111
|
-
|
112
|
-
export function getValueForOneOf (v: string | number, schema?: { oneOf?: ItemsType }): string
|
113
|
-
export function getIndexForOneOf (values: ValuesType, parentUri?: string, uri?: string, schema?: SchemaType): number
|
114
|
-
|
115
107
|
export function getElementsProps (params?: ParamsType, uri?: string): StringElementsType | NumberElementsType | ArrayElementsType | ObjectElementsType | BooleanElementsType | NullElementsType | Record<string, never>
|
116
108
|
|
117
109
|
export function getElementsFieldPropsForEnum (params?: ParamsType, uri?: string): EnumType | ObjectLiteralType
|
@@ -121,45 +113,45 @@ export function getElementsFieldPropsForAllOf (params?: ParamsType, uri?: string
|
|
121
113
|
export function getElementsFieldProps (params?: ParamsType, uri?: string): FieldType | ObjectLiteralType
|
122
114
|
export function getElementsFieldValue (values?: ValuesType, uri?: string, schema?: SchemaType): { value: string } | ObjectLiteralType
|
123
115
|
|
124
|
-
export function hasEnum (schema?: { enum?:
|
116
|
+
export function hasEnum (schema?: { enum?: MemberArrayType }): schema is { enum: MemberArrayType }
|
125
117
|
|
126
|
-
declare function getEnum (schema: { enum:
|
127
|
-
declare function getEnum (schema?: { enum?:
|
118
|
+
declare function getEnum (schema: { enum: MemberArrayType }): MemberArrayType
|
119
|
+
declare function getEnum (schema?: { enum?: MemberArrayType }): MemberArrayType | undefined
|
128
120
|
|
129
121
|
export { getEnum }
|
130
122
|
|
131
|
-
export function hasConst (schema?: { const?:
|
123
|
+
export function hasConst (schema?: { const?: MemberType }): schema is { const: MemberType }
|
132
124
|
|
133
|
-
declare function getConst (schema: { const:
|
134
|
-
declare function getConst (schema?: { const?:
|
125
|
+
declare function getConst (schema: { const: MemberType }): MemberType
|
126
|
+
declare function getConst (schema?: { const?: MemberType }): MemberType | undefined
|
135
127
|
|
136
128
|
export { getConst }
|
137
129
|
|
138
|
-
export function hasDefault (schema?: { default?:
|
130
|
+
export function hasDefault (schema?: { default?: MemberType }): schema is { default: MemberType }
|
139
131
|
|
140
|
-
declare function getDefault (schema: { default:
|
141
|
-
declare function getDefault (schema?: { default?:
|
132
|
+
declare function getDefault (schema: { default: MemberType }): MemberType
|
133
|
+
declare function getDefault (schema?: { default?: MemberType }): MemberType | undefined
|
142
134
|
|
143
135
|
export { getDefault }
|
144
136
|
|
145
|
-
export function hasAnyOf (schema?: { anyOf?:
|
137
|
+
export function hasAnyOf (schema?: { anyOf?: MemberArrayType }): schema is { anyOf: MemberArrayType }
|
146
138
|
|
147
|
-
declare function getAnyOf (schema: { anyOf:
|
148
|
-
declare function getAnyOf (schema?: { anyOf?:
|
139
|
+
declare function getAnyOf (schema: { anyOf: MemberArrayType }): MemberArrayType
|
140
|
+
declare function getAnyOf (schema?: { anyOf?: MemberArrayType }): MemberArrayType | undefined
|
149
141
|
|
150
142
|
export { getAnyOf }
|
151
143
|
|
152
|
-
export function hasOneOf (schema?: { oneOf?:
|
144
|
+
export function hasOneOf (schema?: { oneOf?: MemberArrayType }): schema is { oneOf: MemberArrayType }
|
153
145
|
|
154
|
-
declare function getOneOf (schema: { oneOf:
|
155
|
-
declare function getOneOf (schema?: { oneOf?:
|
146
|
+
declare function getOneOf (schema: { oneOf: MemberArrayType }): MemberArrayType
|
147
|
+
declare function getOneOf (schema?: { oneOf?: MemberArrayType }): MemberArrayType | undefined
|
156
148
|
|
157
149
|
export { getOneOf }
|
158
150
|
|
159
|
-
export function hasAllOf (schema?: { allOf?:
|
151
|
+
export function hasAllOf (schema?: { allOf?: MemberArrayType }): schema is { allOf: MemberArrayType }
|
160
152
|
|
161
|
-
declare function getAllOf (schema: { allOf:
|
162
|
-
declare function getAllOf (schema?: { allOf?:
|
153
|
+
declare function getAllOf (schema: { allOf: MemberArrayType }): MemberArrayType
|
154
|
+
declare function getAllOf (schema?: { allOf?: MemberArrayType }): MemberArrayType | undefined
|
163
155
|
|
164
156
|
export { getAllOf }
|
165
157
|
|
@@ -2,7 +2,8 @@
|
|
2
2
|
* @typedef {TransmissionTypes.ObjectLiteralType} ObjectLiteralType
|
3
3
|
* @typedef {TransmissionTypes.ObjectType} ObjectType
|
4
4
|
*
|
5
|
-
* @typedef {TransmissionTypes.
|
5
|
+
* @typedef {TransmissionTypes.MemberArrayType} MemberArrayType
|
6
|
+
* @typedef {TransmissionTypes.MemberType} MemberType
|
6
7
|
*
|
7
8
|
* @typedef {TransmissionTypes.Transmission.StringMetaType} TransmissionStringMetaType
|
8
9
|
* @typedef {TransmissionTypes.Transmission.NumberMetaType} TransmissionNumberMetaType
|
@@ -46,13 +47,13 @@ log('`shinkansen` is awake')
|
|
46
47
|
|
47
48
|
/**
|
48
49
|
* @param {unknown} [v]
|
49
|
-
* @returns {v is (Record<PropertyKey,
|
50
|
+
* @returns {v is (Record<PropertyKey, MemberType | MemberArrayType> | Record<PropertyKey, never>)}
|
50
51
|
*/
|
51
52
|
export const isObject = (v) => (v || false) instanceof Object && !isArray(v)
|
52
53
|
|
53
54
|
/**
|
54
55
|
* @param {unknown} [v]
|
55
|
-
* @returns {v is (
|
56
|
+
* @returns {v is (MemberArrayType)} // | SchemaType)[]}
|
56
57
|
*/
|
57
58
|
export const isArray = (v) => Array.isArray(v)
|
58
59
|
|
@@ -304,8 +305,8 @@ export function getMetaValue (values = {}, uri = '#', schema = {}) {
|
|
304
305
|
}
|
305
306
|
|
306
307
|
/**
|
307
|
-
* @param {
|
308
|
-
* @returns {
|
308
|
+
* @param {MemberType} [item]
|
309
|
+
* @returns {MemberType | undefined}
|
309
310
|
*/
|
310
311
|
export function transformToValue (item) {
|
311
312
|
if (item === undefined) return item
|
@@ -366,8 +367,8 @@ export function getFindByIndex (parentUri, uri) {
|
|
366
367
|
}
|
367
368
|
|
368
369
|
/**
|
369
|
-
* @param {
|
370
|
-
* @returns {(item?:
|
370
|
+
* @param {MemberType} [value]
|
371
|
+
* @returns {(item?: MemberType | MemberArrayType) => boolean}
|
371
372
|
*/
|
372
373
|
export function getFindByValue (value) {
|
373
374
|
/*
|
@@ -384,8 +385,8 @@ export function getFindByValue (value) {
|
|
384
385
|
}
|
385
386
|
|
386
387
|
/**
|
387
|
-
* @param {
|
388
|
-
* @returns {(item?:
|
388
|
+
* @param {MemberType} [value]
|
389
|
+
* @returns {(item?: MemberType | MemberArrayType) => boolean}
|
389
390
|
*/
|
390
391
|
export function getFindByEqual (value) {
|
391
392
|
/*
|
@@ -400,7 +401,7 @@ export function getFindByEqual (value) {
|
|
400
401
|
}
|
401
402
|
|
402
403
|
/**
|
403
|
-
* @param {
|
404
|
+
* @param {MemberType} [value]
|
404
405
|
* @returns {string}
|
405
406
|
*/
|
406
407
|
export function toString (value) {
|
@@ -502,86 +503,72 @@ export function getSchema (schema = {}, parentUri = '', uri = '') {
|
|
502
503
|
}
|
503
504
|
|
504
505
|
/**
|
505
|
-
* @param {
|
506
|
-
* @param {
|
506
|
+
* @param {MemberArrayType} array
|
507
|
+
* @param {MemberType} [value]
|
507
508
|
* @returns {string}
|
508
509
|
*/
|
509
|
-
export function
|
510
|
+
export function transformIndexToValueByFindValue (array, value) {
|
510
511
|
/*
|
511
|
-
* log('
|
512
|
+
* log('transformIndexToValueByFindValue')
|
512
513
|
*/
|
513
514
|
|
514
|
-
const
|
515
|
-
|
516
|
-
if (array.some(find)) {
|
517
|
-
const index = array.findIndex(find)
|
518
|
-
|
519
|
-
/*
|
520
|
-
* Transform a number to a string
|
521
|
-
*/
|
522
|
-
return String(index)
|
523
|
-
}
|
515
|
+
const index = findIndexByValue(array, value)
|
524
516
|
|
525
517
|
/*
|
526
|
-
*
|
518
|
+
* Transform a number to a string
|
527
519
|
*/
|
528
|
-
return
|
520
|
+
return String(index)
|
529
521
|
}
|
530
522
|
|
531
523
|
/**
|
532
|
-
* @param {
|
533
|
-
* @param {
|
524
|
+
* @param {MemberArrayType} array
|
525
|
+
* @param {MemberType} [value]
|
534
526
|
* @returns {number}
|
535
527
|
*/
|
536
|
-
export function
|
528
|
+
export function findIndexByValue (array, value) {
|
537
529
|
/*
|
538
|
-
* log('
|
530
|
+
* log('findIndexByValue')
|
539
531
|
*/
|
540
532
|
|
533
|
+
const find = getFindByValue(value)
|
534
|
+
|
541
535
|
return (
|
542
|
-
array.findIndex(
|
536
|
+
array.findIndex(find)
|
543
537
|
)
|
544
538
|
}
|
545
539
|
|
546
540
|
/**
|
547
|
-
* @param {
|
548
|
-
* @param {
|
541
|
+
* @param {MemberArrayType} array
|
542
|
+
* @param {MemberType} [value]
|
549
543
|
* @returns {string}
|
550
544
|
*/
|
551
|
-
export function
|
545
|
+
export function transformIndexToValueByFindEqual (array, value) {
|
552
546
|
/*
|
553
|
-
* log('
|
547
|
+
* log('transformIndexToValueByFindEqual')
|
554
548
|
*/
|
555
549
|
|
556
|
-
const
|
557
|
-
|
558
|
-
if (array.some(find)) {
|
559
|
-
const index = array.findIndex(find)
|
560
|
-
|
561
|
-
/*
|
562
|
-
* Transform a number to a string
|
563
|
-
*/
|
564
|
-
return String(index)
|
565
|
-
}
|
550
|
+
const index = findIndexByEqual(array, value)
|
566
551
|
|
567
552
|
/*
|
568
|
-
|
569
|
-
|
570
|
-
return
|
553
|
+
* Transform a number to a string
|
554
|
+
*/
|
555
|
+
return String(index)
|
571
556
|
}
|
572
557
|
|
573
558
|
/**
|
574
|
-
* @param {
|
575
|
-
* @param {
|
559
|
+
* @param {MemberArrayType} array
|
560
|
+
* @param {MemberType} [value]
|
576
561
|
* @returns {string}
|
577
562
|
*/
|
578
|
-
export function
|
563
|
+
export function findIndexByEqual (array, value) {
|
579
564
|
/*
|
580
|
-
* log('
|
565
|
+
* log('findIndexByEqual')
|
581
566
|
*/
|
582
567
|
|
568
|
+
const find = getFindByEqual(value)
|
569
|
+
|
583
570
|
return (
|
584
|
-
array.findIndex(
|
571
|
+
array.findIndex(find)
|
585
572
|
)
|
586
573
|
}
|
587
574
|
|
@@ -633,113 +620,6 @@ export function getValue (values = {}, uri = '#', schema = {}) {
|
|
633
620
|
return ''
|
634
621
|
}
|
635
622
|
|
636
|
-
/**
|
637
|
-
* @deprecated
|
638
|
-
*
|
639
|
-
* @param {string | number} v
|
640
|
-
* @param {{ enum?: ItemsType }} [schema]
|
641
|
-
* @returns {string}
|
642
|
-
*/
|
643
|
-
export function getValueForEnum (v, { enum: items = [] } = {}) {
|
644
|
-
if (v in items) { // @ts-ignore // if (Reflect.has(items, v)) {
|
645
|
-
const enumValue = items[v] // Reflect.get(items, v)
|
646
|
-
|
647
|
-
return String(enumValue)
|
648
|
-
}
|
649
|
-
|
650
|
-
return ''
|
651
|
-
}
|
652
|
-
|
653
|
-
/**
|
654
|
-
* Use `index` `item` `arrayIndex`
|
655
|
-
*
|
656
|
-
* @deprecated
|
657
|
-
*/
|
658
|
-
export function getIndexForEnum (values = {}, parentUri = '#', uri = '#', schema = {}) {
|
659
|
-
if (/\/\d+$/.test(uri)) {
|
660
|
-
/*
|
661
|
-
* Get the index
|
662
|
-
*/
|
663
|
-
return Number(uri.slice(uri.lastIndexOf('/') + 1))
|
664
|
-
}
|
665
|
-
|
666
|
-
return NaN
|
667
|
-
}
|
668
|
-
|
669
|
-
/**
|
670
|
-
* @deprecated
|
671
|
-
*
|
672
|
-
* @param {string | number} v
|
673
|
-
* @param {{ anyOf?: ItemsType }} [schema]
|
674
|
-
* @returns {string}
|
675
|
-
*/
|
676
|
-
export function getValueForAnyOf (v, { anyOf: items = [] } = {}) {
|
677
|
-
if (v in items) { // @ts-ignore // if (Reflect.has(items, v)) {
|
678
|
-
const anyOf = items[v] // Reflect.get(items, v)
|
679
|
-
|
680
|
-
const anyOfValue = transformToValue(anyOf)
|
681
|
-
|
682
|
-
if (isPrimitive(anyOfValue)) {
|
683
|
-
return String(anyOfValue)
|
684
|
-
}
|
685
|
-
}
|
686
|
-
|
687
|
-
return ''
|
688
|
-
}
|
689
|
-
|
690
|
-
/**
|
691
|
-
* Use `index` `item` `arrayIndex`
|
692
|
-
*
|
693
|
-
* @deprecated
|
694
|
-
*/
|
695
|
-
export function getIndexForAnyOf (values = {}, parentUri = '#', uri = '#', schema = {}) {
|
696
|
-
if (/\/\d+$/.test(uri)) {
|
697
|
-
/*
|
698
|
-
* Get the index
|
699
|
-
*/
|
700
|
-
return Number(uri.slice(uri.lastIndexOf('/') + 1))
|
701
|
-
}
|
702
|
-
|
703
|
-
return NaN
|
704
|
-
}
|
705
|
-
|
706
|
-
/**
|
707
|
-
* @deprecated
|
708
|
-
*
|
709
|
-
* @param {string | number} v
|
710
|
-
* @param {{ oneOf?: ItemsType }} [schema]
|
711
|
-
* @returns {string}
|
712
|
-
*/
|
713
|
-
export function getValueForOneOf (v, { oneOf: items = [] } = {}) {
|
714
|
-
if (v in items) { // @ts-ignore // if (Reflect.has(items, v)) {
|
715
|
-
const oneOf = items[v] // Reflect.get(items, v)
|
716
|
-
|
717
|
-
const oneOfValue = transformToValue(oneOf)
|
718
|
-
|
719
|
-
if (isPrimitive(oneOfValue)) {
|
720
|
-
return String(oneOfValue)
|
721
|
-
}
|
722
|
-
}
|
723
|
-
|
724
|
-
return ''
|
725
|
-
}
|
726
|
-
|
727
|
-
/**
|
728
|
-
* Use `index` `item` `arrayIndex`
|
729
|
-
*
|
730
|
-
* @deprecated
|
731
|
-
*/
|
732
|
-
export function getIndexForOneOf (values = {}, parentUri = '#', uri = '#', schema = {}) {
|
733
|
-
if (/\/\d+$/.test(uri)) {
|
734
|
-
/*
|
735
|
-
* Get the index
|
736
|
-
*/
|
737
|
-
return Number(uri.slice(uri.lastIndexOf('/') + 1))
|
738
|
-
}
|
739
|
-
|
740
|
-
return NaN
|
741
|
-
}
|
742
|
-
|
743
623
|
/**
|
744
624
|
* @param {ParamsType} [params]
|
745
625
|
* @param {string} [uri]
|
@@ -902,98 +782,98 @@ export function getElementsFieldValue (values = {}, uri = '#', schema = {}) {
|
|
902
782
|
}
|
903
783
|
|
904
784
|
/**
|
905
|
-
* @param {{ 'enum'?:
|
906
|
-
* @returns {schema is { 'enum':
|
785
|
+
* @param {{ 'enum'?: MemberArrayType }} [schema]
|
786
|
+
* @returns {schema is { 'enum': MemberArrayType }}
|
907
787
|
*/
|
908
788
|
export const hasEnum = (schema = {}) => 'enum' in schema // Reflect.has(schema, 'enum')
|
909
789
|
|
910
790
|
/**
|
911
791
|
* @overload
|
912
|
-
* @param {{ 'enum':
|
913
|
-
* @returns {
|
792
|
+
* @param {{ 'enum': MemberArrayType }} schema
|
793
|
+
* @returns {MemberArrayType}
|
914
794
|
*
|
915
|
-
* @param {{ 'enum'?:
|
916
|
-
* @returns {
|
795
|
+
* @param {{ 'enum'?: MemberArrayType }} [schema]
|
796
|
+
* @returns {MemberArrayType | undefined}
|
917
797
|
*/
|
918
798
|
export const getEnum = (schema = {}) => schema.enum // Reflect.get(schema, 'enum')
|
919
799
|
|
920
800
|
/**
|
921
|
-
* @param {{ 'const'?:
|
922
|
-
* @returns {schema is { 'const':
|
801
|
+
* @param {{ 'const'?: MemberType }} [schema]
|
802
|
+
* @returns {schema is { 'const': MemberType }}
|
923
803
|
*/
|
924
804
|
export const hasConst = (schema = {}) => 'const' in schema // Reflect.has(schema, 'const')
|
925
805
|
|
926
806
|
/**
|
927
807
|
* @overload
|
928
|
-
* @param {{ 'const':
|
929
|
-
* @returns {
|
808
|
+
* @param {{ 'const': MemberType }} schema
|
809
|
+
* @returns {MemberType}
|
930
810
|
*
|
931
|
-
* @param {{ 'const'?:
|
932
|
-
* @returns {
|
811
|
+
* @param {{ 'const'?: MemberType }} [schema]
|
812
|
+
* @returns {MemberType | undefined}
|
933
813
|
*/
|
934
814
|
export const getConst = (schema = {}) => schema.const // Reflect.get(schema, 'const')
|
935
815
|
|
936
816
|
/**
|
937
|
-
* @param {{ 'default'?:
|
938
|
-
* @returns {schema is { 'default':
|
817
|
+
* @param {{ 'default'?: MemberType }} [schema]
|
818
|
+
* @returns {schema is { 'default': MemberType }}
|
939
819
|
*/
|
940
820
|
export const hasDefault = (schema = {}) => 'default' in schema // Reflect.has(schema, 'default')
|
941
821
|
|
942
822
|
/**
|
943
823
|
* @overload
|
944
|
-
* @param {{ 'default':
|
945
|
-
* @returns {
|
824
|
+
* @param {{ 'default': MemberType }} schema
|
825
|
+
* @returns {MemberType}
|
946
826
|
*
|
947
|
-
* @param {{ 'default'?:
|
948
|
-
* @returns {
|
827
|
+
* @param {{ 'default'?: MemberType }} [schema]
|
828
|
+
* @returns {MemberType | undefined}
|
949
829
|
*/
|
950
830
|
export const getDefault = (schema = {}) => schema.default // Reflect.get(schema, 'default')
|
951
831
|
|
952
832
|
/**
|
953
|
-
* @param {{ 'anyOf'?:
|
954
|
-
* @returns {schema is { 'anyOf':
|
833
|
+
* @param {{ 'anyOf'?: MemberArrayType }} [schema]
|
834
|
+
* @returns {schema is { 'anyOf': MemberArrayType }}
|
955
835
|
*/
|
956
836
|
export const hasAnyOf = (schema = {}) => 'anyOf' in schema // Reflect.has(schema, 'anyOf')
|
957
837
|
|
958
838
|
/**
|
959
839
|
* @overload
|
960
|
-
* @param {{ 'anyOf':
|
961
|
-
* @returns {
|
840
|
+
* @param {{ 'anyOf': MemberArrayType }} schema
|
841
|
+
* @returns {MemberArrayType}
|
962
842
|
*
|
963
|
-
* @param {{ 'anyOf'?:
|
964
|
-
* @returns {
|
843
|
+
* @param {{ 'anyOf'?: MemberArrayType }} [schema]
|
844
|
+
* @returns {MemberArrayType | undefined}
|
965
845
|
*/
|
966
846
|
export const getAnyOf = (schema = {}) => schema.anyOf // Reflect.get(schema, 'anyOf')
|
967
847
|
|
968
848
|
/**
|
969
|
-
* @param {{ 'oneOf'?:
|
970
|
-
* @returns {schema is { 'oneOf':
|
849
|
+
* @param {{ 'oneOf'?: MemberArrayType }} [schema]
|
850
|
+
* @returns {schema is { 'oneOf': MemberArrayType }}
|
971
851
|
*/
|
972
852
|
export const hasOneOf = (schema = {}) => 'oneOf' in schema // Reflect.has(schema, 'oneOf')
|
973
853
|
|
974
854
|
/**
|
975
855
|
* @overload
|
976
|
-
* @param {{ 'oneOf':
|
977
|
-
* @returns {
|
856
|
+
* @param {{ 'oneOf': MemberArrayType }} schema
|
857
|
+
* @returns {MemberArrayType}
|
978
858
|
*
|
979
|
-
* @param {{ 'oneOf'?:
|
980
|
-
* @returns {
|
859
|
+
* @param {{ 'oneOf'?: MemberArrayType }} schema
|
860
|
+
* @returns {MemberArrayType | undefined}
|
981
861
|
*/
|
982
862
|
export const getOneOf = (schema = {}) => schema.oneOf // Reflect.get(schema, 'oneOf')
|
983
863
|
|
984
864
|
/**
|
985
|
-
* @param {{ 'allOf'?:
|
986
|
-
* @returns {schema is { 'allOf':
|
865
|
+
* @param {{ 'allOf'?: MemberArrayType }} [schema]
|
866
|
+
* @returns {schema is { 'allOf': MemberArrayType }}
|
987
867
|
*/
|
988
868
|
export const hasAllOf = (schema = {}) => 'allOf' in schema // Reflect.has(schema, 'allOf')
|
989
869
|
|
990
870
|
/**
|
991
871
|
* @overload
|
992
|
-
* @param {{ 'allOf':
|
993
|
-
* @returns {
|
872
|
+
* @param {{ 'allOf': MemberArrayType }} schema
|
873
|
+
* @returns {MemberArrayType}
|
994
874
|
*
|
995
|
-
* @param {{ 'allOf'?:
|
996
|
-
* @returns {
|
875
|
+
* @param {{ 'allOf'?: MemberArrayType }} [schema]
|
876
|
+
* @returns {MemberArrayType | undefined}
|
997
877
|
*/
|
998
878
|
export const getAllOf = (schema = {}) => schema.allOf // Reflect.get(schema, 'allOf')
|
999
879
|
|