shinkansen-transmission 2.2.234 → 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.
- package/babel.config.cjs +1 -0
- package/eslint.config.mjs +28 -30
- package/index.d.mts +321 -16
- package/package.json +8 -8
- package/src/index.cjs +2 -0
- package/src/index.d.mts +10 -9
- package/src/transmission/common/index.d.mts +152 -87
- package/src/transmission/common/index.mjs +627 -193
- package/src/transmission/from-document-to-hash/array/index.mjs +20 -4
- package/src/transmission/from-document-to-hash/boolean/index.mjs +25 -9
- package/src/transmission/from-document-to-hash/index.d.mts +8 -19
- package/src/transmission/from-document-to-hash/index.mjs +102 -16
- package/src/transmission/from-document-to-hash/null/index.mjs +25 -9
- package/src/transmission/from-document-to-hash/number/index.mjs +25 -9
- package/src/transmission/from-document-to-hash/object/index.mjs +22 -6
- package/src/transmission/from-document-to-hash/string/index.mjs +25 -9
- package/src/transmission/from-hash-to-document/array/index.mjs +22 -5
- package/src/transmission/from-hash-to-document/boolean/index.mjs +21 -4
- package/src/transmission/from-hash-to-document/index.d.mts +24 -26
- package/src/transmission/from-hash-to-document/index.mjs +264 -142
- package/src/transmission/from-hash-to-document/null/index.mjs +21 -4
- package/src/transmission/from-hash-to-document/number/index.mjs +21 -4
- package/src/transmission/from-hash-to-document/object/index.mjs +22 -5
- package/src/transmission/from-hash-to-document/string/index.mjs +26 -4
- package/src/transmission/index.d.mts +4 -10
- package/src/transmission/to-zashiki/index.d.mts +5 -13
- package/src/transmission/to-zashiki/params/index.mjs +430 -0
- package/src/transmission/to-zashiki/render/array/index.mjs +737 -0
- package/src/transmission/to-zashiki/render/boolean/index.mjs +794 -0
- package/src/transmission/to-zashiki/render/index.mjs +157 -0
- package/src/transmission/to-zashiki/render/null/index.mjs +796 -0
- package/src/transmission/to-zashiki/render/number/index.mjs +940 -0
- package/src/transmission/to-zashiki/render/object/index.mjs +653 -0
- package/src/transmission/to-zashiki/render/string/index.mjs +910 -0
- package/src/transmission/to-zashiki/render-params/root-schema/index.mjs +212 -0
- package/src/transmission/to-zashiki/render-params/schema/index.mjs +731 -0
- package/src/transmission/to-zashiki/transform-root-schema.mjs +485 -421
- package/src/transmission/to-zashiki/transform-schema.mjs +1988 -4663
@@ -1,3 +1,10 @@
|
|
1
|
+
/**
|
2
|
+
* @typedef {TransmissionTypes.HashType} HashType
|
3
|
+
* @typedef {TransmissionTypes.SchemaType} SchemaType
|
4
|
+
* @typedef {TransmissionTypes.ParamsType} ParamsType
|
5
|
+
* @typedef {TransmissionTypes.DocumentType} DocumentType
|
6
|
+
*/
|
7
|
+
|
1
8
|
import debug from 'debug'
|
2
9
|
|
3
10
|
import {
|
@@ -12,18 +19,28 @@ const log = debug('shinkansen-transmission/from-hash-to-document/number')
|
|
12
19
|
|
13
20
|
log('`shinkansen` is awake')
|
14
21
|
|
15
|
-
|
22
|
+
/**
|
23
|
+
* Hash can be `undefined`
|
24
|
+
*
|
25
|
+
* @param {HashType} [hash]
|
26
|
+
* @param {SchemaType} [schema]
|
27
|
+
* @param {ParamsType} [params]
|
28
|
+
* @returns {DocumentType | undefined}
|
29
|
+
*/
|
30
|
+
export default function transformNumberSchema (hash = {}, schema = {}, params = {}) {
|
16
31
|
log('transformNumberSchema')
|
17
32
|
|
18
|
-
const {
|
33
|
+
const {
|
34
|
+
type
|
35
|
+
} = schema
|
19
36
|
|
20
37
|
// https://json-schema.org/draft/2019-09/json-schema-core.html#rfc.section.4.2.1
|
21
38
|
if (type === 'number') {
|
22
39
|
const {
|
23
|
-
uri: parentUri
|
40
|
+
uri: parentUri = '#'
|
24
41
|
} = params
|
25
42
|
|
26
|
-
return transformNumber(
|
43
|
+
return transformNumber(hash, schema, parentUri, getUri(parentUri))
|
27
44
|
}
|
28
45
|
|
29
46
|
throw new Error('Schema does not conform to Instance Data Model, https://json-schema.org/draft/2019-09/json-schema-core.html#rfc.section.4.2.1')
|
@@ -1,3 +1,10 @@
|
|
1
|
+
/**
|
2
|
+
* @typedef {TransmissionTypes.HashType} HashType
|
3
|
+
* @typedef {TransmissionTypes.SchemaType} SchemaType
|
4
|
+
* @typedef {TransmissionTypes.ParamsType} ParamsType
|
5
|
+
* @typedef {TransmissionTypes.DocumentType} DocumentType
|
6
|
+
*/
|
7
|
+
|
1
8
|
import debug from 'debug'
|
2
9
|
|
3
10
|
import {
|
@@ -12,19 +19,29 @@ const log = debug('shinkansen-transmission/from-hash-to-document/object')
|
|
12
19
|
|
13
20
|
log('`shinkansen` is awake')
|
14
21
|
|
15
|
-
|
22
|
+
/**
|
23
|
+
* Hash can be `undefined`
|
24
|
+
*
|
25
|
+
* @param {HashType} [hash]
|
26
|
+
* @param {SchemaType} [schema]
|
27
|
+
* @param {ParamsType} [params]
|
28
|
+
* @returns {DocumentType | undefined}
|
29
|
+
*/
|
30
|
+
export default function transformObjectSchema (hash = {}, schema = {}, params = {}) {
|
16
31
|
log('transformObjectSchema')
|
17
32
|
|
18
|
-
const {
|
33
|
+
const {
|
34
|
+
type
|
35
|
+
} = schema
|
19
36
|
|
20
37
|
// https://json-schema.org/draft/2019-09/json-schema-core.html#rfc.section.4.2.1
|
21
38
|
if (type === 'object') {
|
22
39
|
const {
|
23
|
-
uri: parentUri,
|
24
|
-
key: fieldKey
|
40
|
+
uri: parentUri = '#',
|
41
|
+
key: fieldKey // string | undefined
|
25
42
|
} = params
|
26
43
|
|
27
|
-
return transformObject(
|
44
|
+
return transformObject(hash, schema, parentUri, getUri(parentUri, fieldKey))
|
28
45
|
}
|
29
46
|
|
30
47
|
throw new Error('Schema does not conform to Instance Data Model, https://json-schema.org/draft/2019-09/json-schema-core.html#rfc.section.4.2.1')
|
@@ -1,3 +1,15 @@
|
|
1
|
+
/**
|
2
|
+
* @typedef {TransmissionTypes.ObjectType} ObjectType
|
3
|
+
* @typedef {TransmissionTypes.ArrayType} ArrayType
|
4
|
+
*
|
5
|
+
* @typedef {TransmissionTypes.ItemsType} ItemsType
|
6
|
+
*
|
7
|
+
* @typedef {TransmissionTypes.HashType} HashType
|
8
|
+
* @typedef {TransmissionTypes.SchemaType} SchemaType
|
9
|
+
* @typedef {TransmissionTypes.ParamsType} ParamsType
|
10
|
+
* @typedef {TransmissionTypes.DocumentType} DocumentType
|
11
|
+
*/
|
12
|
+
|
1
13
|
import debug from 'debug'
|
2
14
|
|
3
15
|
import {
|
@@ -12,18 +24,28 @@ const log = debug('shinkansen-transmission/from-hash-to-document/string')
|
|
12
24
|
|
13
25
|
log('`shinkansen` is awake')
|
14
26
|
|
15
|
-
|
27
|
+
/**
|
28
|
+
* Hash can be `undefined`
|
29
|
+
*
|
30
|
+
* @param {HashType} [hash]
|
31
|
+
* @param {SchemaType} [schema]
|
32
|
+
* @param {ParamsType} [params]
|
33
|
+
* @returns {DocumentType | undefined}
|
34
|
+
*/
|
35
|
+
export default function transformStringSchema (hash = {}, schema = {}, params = {}) {
|
16
36
|
log('transformStringSchema')
|
17
37
|
|
18
|
-
const {
|
38
|
+
const {
|
39
|
+
type
|
40
|
+
} = schema
|
19
41
|
|
20
42
|
// https://json-schema.org/draft/2019-09/json-schema-core.html#rfc.section.4.2.1
|
21
43
|
if (type === 'string') {
|
22
44
|
const {
|
23
|
-
uri: parentUri
|
45
|
+
uri: parentUri = '#'
|
24
46
|
} = params
|
25
47
|
|
26
|
-
return transformString(
|
48
|
+
return transformString(hash, schema, parentUri, getUri(parentUri))
|
27
49
|
}
|
28
50
|
|
29
51
|
throw new Error('Schema does not conform to Instance Data Model, https://json-schema.org/draft/2019-09/json-schema-core.html#rfc.section.4.2.1')
|
@@ -1,10 +1,4 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
export { default as toZashiki } from '#transmission/transmission/to-zashiki'
|
6
|
-
}
|
7
|
-
|
8
|
-
declare module 'shinkansen-transmission/transmission' {
|
9
|
-
export * from '#transmission/transmission'
|
10
|
-
}
|
1
|
+
export * as common from '#transmission/transmission/common'
|
2
|
+
export { default as fromDocumentToHash } from '#transmission/transmission/from-document-to-hash'
|
3
|
+
export { default as fromHashToDocument } from '#transmission/transmission/from-hash-to-document'
|
4
|
+
export { default as toZashiki } from '#transmission/transmission/to-zashiki'
|
@@ -1,15 +1,7 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
export type SchemaType = TransmissionTypes.SchemaType
|
2
|
+
export type ValuesType = TransmissionTypes.ValuesType
|
3
|
+
export type ParamsType = TransmissionTypes.ParamsType
|
3
4
|
|
4
|
-
|
5
|
-
type ObjectType = ZashikiTypes.ObjectType
|
5
|
+
export type ZashikiType = TransmissionTypes.Zashiki.ZashikiType
|
6
6
|
|
7
|
-
|
8
|
-
|
9
|
-
export default function toZashiki (rootSchema: SchemaType | undefined, values: ObjectType | ObjectLiteralType | undefined, params: ObjectType | ObjectLiteralType | undefined): ZashikiType | undefined
|
10
|
-
}
|
11
|
-
|
12
|
-
declare module 'shinkansen-transmission/transmission/to-zashiki' {
|
13
|
-
export { default } from '#transmission/transmission/to-zashiki'
|
14
|
-
export * from '#transmission/transmission/to-zashiki'
|
15
|
-
}
|
7
|
+
export default function toZashiki (rootSchema?: SchemaType, values?: ValuesType, params?: ParamsType): ZashikiType
|
@@ -0,0 +1,430 @@
|
|
1
|
+
/**
|
2
|
+
* @typedef {TransmissionTypes.ObjectLiteralType} ObjectLiteralType
|
3
|
+
* @typedef {TransmissionTypes.ObjectType} ObjectType
|
4
|
+
*
|
5
|
+
* @typedef {TransmissionTypes.EnumType} EnumType
|
6
|
+
* @typedef {TransmissionTypes.AnyOfType} AnyOfType
|
7
|
+
* @typedef {TransmissionTypes.OneOfType} OneOfType
|
8
|
+
* @typedef {TransmissionTypes.FieldType} FieldType
|
9
|
+
*
|
10
|
+
* @typedef {TransmissionTypes.SchemaType} SchemaType
|
11
|
+
* @typedef {TransmissionTypes.ValuesType} ValuesType
|
12
|
+
* @typedef {TransmissionTypes.ParamsType} ParamsType
|
13
|
+
*
|
14
|
+
* @typedef {TransmissionTypes.Zashiki.ZashikiType} ZashikiType
|
15
|
+
*
|
16
|
+
* @typedef {TransmissionTypes.Zashiki.StringMetaType} ZashikiStringMetaType
|
17
|
+
* @typedef {TransmissionTypes.Zashiki.NumberMetaType} ZashikiNumberMetaType
|
18
|
+
* @typedef {TransmissionTypes.Zashiki.ArrayMetaType} ZashikiArrayMetaType
|
19
|
+
* @typedef {TransmissionTypes.Zashiki.ObjectMetaType} ZashikiObjectMetaType
|
20
|
+
* @typedef {TransmissionTypes.Zashiki.BooleanMetaType} ZashikiBooleanMetaType
|
21
|
+
* @typedef {TransmissionTypes.Zashiki.NullMetaType} ZashikiNullMetaType
|
22
|
+
*
|
23
|
+
* @typedef {TransmissionTypes.Zashiki.StringElementsType} ZashikiStringElementsType
|
24
|
+
* @typedef {TransmissionTypes.Zashiki.NumberElementsType} ZashikiNumberElementsType
|
25
|
+
* @typedef {TransmissionTypes.Zashiki.ArrayElementsType} ZashikiArrayElementsType
|
26
|
+
* @typedef {TransmissionTypes.Zashiki.ObjectElementsType} ZashikiObjectElementsType
|
27
|
+
* @typedef {TransmissionTypes.Zashiki.BooleanElementsType} ZashikiBooleanElementsType
|
28
|
+
* @typedef {TransmissionTypes.Zashiki.NullElementsType} ZashikiNullElementsType
|
29
|
+
*/
|
30
|
+
|
31
|
+
import debug from 'debug'
|
32
|
+
|
33
|
+
import {
|
34
|
+
getSelectedItems,
|
35
|
+
normaliseUri,
|
36
|
+
getUri,
|
37
|
+
getMetaProps,
|
38
|
+
getElementsFieldPropsForEnum,
|
39
|
+
getElementsFieldPropsForAnyOf,
|
40
|
+
getElementsFieldPropsForOneOf,
|
41
|
+
getElementsFieldPropsForAllOf,
|
42
|
+
getElementsProps
|
43
|
+
} from '#transmission/transmission/common'
|
44
|
+
|
45
|
+
const log = debug('shinkansen-transmission/to-zashiki/params')
|
46
|
+
|
47
|
+
log('`shinkansen` is awake')
|
48
|
+
|
49
|
+
/**
|
50
|
+
* @param {SchemaType} schema
|
51
|
+
* @param {SchemaType} rootSchema
|
52
|
+
* @param {ValuesType} values
|
53
|
+
* @param {ParamsType} params
|
54
|
+
* @returns {ParamsType}
|
55
|
+
*/
|
56
|
+
export function getParamsByKeyForEnum (schema, rootSchema, values, params) {
|
57
|
+
/**
|
58
|
+
* log('getParamsByKeyForAnyOf')
|
59
|
+
*/
|
60
|
+
|
61
|
+
const {
|
62
|
+
parentUri = '#',
|
63
|
+
key = '',
|
64
|
+
required = []
|
65
|
+
} = params
|
66
|
+
|
67
|
+
const isRequired = key ? required.includes(key) : false
|
68
|
+
|
69
|
+
const uri = getUri(parentUri, key)
|
70
|
+
|
71
|
+
const {
|
72
|
+
selectedItems = getSelectedItems(values, uri) // uri
|
73
|
+
} = getMetaProps(params, uri)
|
74
|
+
|
75
|
+
const meta = Object.assign(getMetaProps(params, uri), {
|
76
|
+
schema,
|
77
|
+
rootSchema,
|
78
|
+
parentUri: normaliseUri(parentUri),
|
79
|
+
uri,
|
80
|
+
selectedItems,
|
81
|
+
isRequired
|
82
|
+
})
|
83
|
+
const elements = {
|
84
|
+
enum: Object.assign(getElementsFieldPropsForEnum(params, uri), {
|
85
|
+
selectedItems,
|
86
|
+
isRequired
|
87
|
+
})
|
88
|
+
}
|
89
|
+
|
90
|
+
return Object.assign(params, {
|
91
|
+
parentUri,
|
92
|
+
uri,
|
93
|
+
key,
|
94
|
+
[uri]: {
|
95
|
+
meta,
|
96
|
+
elements
|
97
|
+
}
|
98
|
+
})
|
99
|
+
}
|
100
|
+
|
101
|
+
/**
|
102
|
+
* @param {SchemaType} schema
|
103
|
+
* @param {SchemaType} rootSchema
|
104
|
+
* @param {ValuesType} values
|
105
|
+
* @param {ParamsType} params
|
106
|
+
* @returns {ParamsType}
|
107
|
+
*/
|
108
|
+
export function getParamsByKeyForAnyOf (schema, rootSchema, values, params) {
|
109
|
+
/**
|
110
|
+
* log('getParamsByKeyForAnyOf')
|
111
|
+
*/
|
112
|
+
|
113
|
+
const {
|
114
|
+
parentUri = '#',
|
115
|
+
key = '',
|
116
|
+
required = []
|
117
|
+
} = params
|
118
|
+
|
119
|
+
const isRequired = key ? required.includes(key) : false
|
120
|
+
|
121
|
+
const uri = getUri(parentUri, key)
|
122
|
+
|
123
|
+
const {
|
124
|
+
selectedItems = getSelectedItems(values, uri) // uri
|
125
|
+
} = getMetaProps(params, uri)
|
126
|
+
|
127
|
+
const meta = Object.assign(getMetaProps(params, uri), {
|
128
|
+
schema,
|
129
|
+
rootSchema,
|
130
|
+
parentUri: normaliseUri(parentUri),
|
131
|
+
uri,
|
132
|
+
selectedItems,
|
133
|
+
isRequired
|
134
|
+
})
|
135
|
+
const elements = {
|
136
|
+
anyOf: Object.assign(getElementsFieldPropsForAnyOf(params, uri), {
|
137
|
+
selectedItems,
|
138
|
+
isRequired
|
139
|
+
})
|
140
|
+
}
|
141
|
+
|
142
|
+
return Object.assign(params, {
|
143
|
+
parentUri,
|
144
|
+
uri,
|
145
|
+
key,
|
146
|
+
[uri]: {
|
147
|
+
meta,
|
148
|
+
elements
|
149
|
+
}
|
150
|
+
})
|
151
|
+
}
|
152
|
+
|
153
|
+
/**
|
154
|
+
* @param {SchemaType} schema
|
155
|
+
* @param {SchemaType} rootSchema
|
156
|
+
* @param {ValuesType} values
|
157
|
+
* @param {ParamsType} params
|
158
|
+
* @returns {ParamsType}
|
159
|
+
*/
|
160
|
+
export function getParamsByKeyForOneOf (schema, rootSchema, values, params) {
|
161
|
+
/**
|
162
|
+
* log('getParamsByKeyForOneOf')
|
163
|
+
*/
|
164
|
+
|
165
|
+
const {
|
166
|
+
parentUri = '#',
|
167
|
+
key = '',
|
168
|
+
required = []
|
169
|
+
} = params
|
170
|
+
|
171
|
+
const isRequired = key ? required.includes(key) : false
|
172
|
+
|
173
|
+
const uri = getUri(parentUri, key)
|
174
|
+
|
175
|
+
const {
|
176
|
+
selectedItems = getSelectedItems(values, uri) // uri
|
177
|
+
} = getMetaProps(params, uri)
|
178
|
+
|
179
|
+
const meta = Object.assign(getMetaProps(params, uri), {
|
180
|
+
schema,
|
181
|
+
rootSchema,
|
182
|
+
parentUri: normaliseUri(parentUri),
|
183
|
+
uri,
|
184
|
+
selectedItems,
|
185
|
+
isRequired
|
186
|
+
})
|
187
|
+
const elements = {
|
188
|
+
oneOf: Object.assign(getElementsFieldPropsForOneOf(params, uri), {
|
189
|
+
selectedItems,
|
190
|
+
isRequired
|
191
|
+
})
|
192
|
+
}
|
193
|
+
|
194
|
+
return Object.assign(params, {
|
195
|
+
parentUri,
|
196
|
+
uri,
|
197
|
+
key,
|
198
|
+
[uri]: {
|
199
|
+
meta,
|
200
|
+
elements
|
201
|
+
}
|
202
|
+
})
|
203
|
+
}
|
204
|
+
|
205
|
+
/**
|
206
|
+
* @param {SchemaType} schema
|
207
|
+
* @param {SchemaType} rootSchema
|
208
|
+
* @param {ValuesType} values
|
209
|
+
* @param {ParamsType} params
|
210
|
+
* @returns {ParamsType}
|
211
|
+
*/
|
212
|
+
export function getParamsByKey (schema, rootSchema, values, params) {
|
213
|
+
/**
|
214
|
+
* log('getParamsByKey')
|
215
|
+
*/
|
216
|
+
|
217
|
+
const {
|
218
|
+
parentUri = '#',
|
219
|
+
key = '',
|
220
|
+
required = []
|
221
|
+
} = params
|
222
|
+
|
223
|
+
const isRequired = key ? required.includes(key) : false
|
224
|
+
|
225
|
+
const uri = getUri(parentUri, key)
|
226
|
+
|
227
|
+
const meta = Object.assign(getMetaProps(params, uri), {
|
228
|
+
schema,
|
229
|
+
rootSchema,
|
230
|
+
parentUri: normaliseUri(parentUri),
|
231
|
+
uri,
|
232
|
+
isRequired
|
233
|
+
})
|
234
|
+
const elements = {
|
235
|
+
field: Object.assign(getElementsFieldPropsForAllOf(params, uri), {
|
236
|
+
isRequired
|
237
|
+
})
|
238
|
+
}
|
239
|
+
|
240
|
+
return Object.assign(params, {
|
241
|
+
parentUri,
|
242
|
+
uri,
|
243
|
+
key,
|
244
|
+
[uri]: {
|
245
|
+
meta,
|
246
|
+
elements
|
247
|
+
}
|
248
|
+
})
|
249
|
+
}
|
250
|
+
|
251
|
+
/**
|
252
|
+
* @param {SchemaType} schema
|
253
|
+
* @param {SchemaType} rootSchema
|
254
|
+
* @param {ValuesType} values
|
255
|
+
* @param {ParamsType} params
|
256
|
+
* @returns {ParamsType}
|
257
|
+
*/
|
258
|
+
export function getParamsByIndexForEnum (schema, rootSchema, values, params) {
|
259
|
+
/**
|
260
|
+
* log('getParamsByIndexForEnum')
|
261
|
+
*/
|
262
|
+
|
263
|
+
const {
|
264
|
+
parentUri = '#',
|
265
|
+
index = 0
|
266
|
+
} = params
|
267
|
+
|
268
|
+
const uri = getUri(parentUri, index)
|
269
|
+
|
270
|
+
const {
|
271
|
+
selectedItems = getSelectedItems(values, parentUri), // parent uri,
|
272
|
+
...metaProps
|
273
|
+
} = getMetaProps(params, uri)
|
274
|
+
|
275
|
+
const meta = Object.assign(metaProps, {
|
276
|
+
schema,
|
277
|
+
rootSchema,
|
278
|
+
parentUri: normaliseUri(parentUri),
|
279
|
+
uri,
|
280
|
+
selectedItems
|
281
|
+
})
|
282
|
+
const elements = {
|
283
|
+
enum: Object.assign(getElementsFieldPropsForEnum(params, uri), {
|
284
|
+
selectedItems
|
285
|
+
})
|
286
|
+
}
|
287
|
+
|
288
|
+
return Object.assign(params, {
|
289
|
+
parentUri,
|
290
|
+
uri,
|
291
|
+
index,
|
292
|
+
[uri]: {
|
293
|
+
meta,
|
294
|
+
elements
|
295
|
+
}
|
296
|
+
})
|
297
|
+
}
|
298
|
+
|
299
|
+
/**
|
300
|
+
* @param {SchemaType} schema
|
301
|
+
* @param {SchemaType} rootSchema
|
302
|
+
* @param {ValuesType} values
|
303
|
+
* @param {ParamsType} params
|
304
|
+
* @returns {ParamsType}
|
305
|
+
*/
|
306
|
+
export function getParamsByIndexForAnyOf (schema, rootSchema, values, params) {
|
307
|
+
/**
|
308
|
+
* log('getParamsByIndexForAnyOf')
|
309
|
+
*/
|
310
|
+
|
311
|
+
const {
|
312
|
+
parentUri = '#',
|
313
|
+
index = 0
|
314
|
+
} = params
|
315
|
+
|
316
|
+
const uri = getUri(parentUri, index)
|
317
|
+
|
318
|
+
const {
|
319
|
+
selectedItems = getSelectedItems(values, parentUri), // parent uri,
|
320
|
+
...metaProps
|
321
|
+
} = getMetaProps(params, uri)
|
322
|
+
|
323
|
+
const meta = Object.assign(metaProps, {
|
324
|
+
schema,
|
325
|
+
rootSchema,
|
326
|
+
parentUri: normaliseUri(parentUri),
|
327
|
+
uri,
|
328
|
+
selectedItems
|
329
|
+
})
|
330
|
+
const elements = {
|
331
|
+
anyOf: Object.assign(getElementsFieldPropsForAnyOf(params, uri), {
|
332
|
+
selectedItems
|
333
|
+
})
|
334
|
+
}
|
335
|
+
|
336
|
+
return Object.assign(params, {
|
337
|
+
parentUri,
|
338
|
+
uri,
|
339
|
+
index,
|
340
|
+
[uri]: {
|
341
|
+
meta,
|
342
|
+
elements
|
343
|
+
}
|
344
|
+
})
|
345
|
+
}
|
346
|
+
|
347
|
+
/**
|
348
|
+
* @param {SchemaType} schema
|
349
|
+
* @param {SchemaType} rootSchema
|
350
|
+
* @param {ValuesType} values
|
351
|
+
* @param {ParamsType} params
|
352
|
+
* @returns {ParamsType}
|
353
|
+
*/
|
354
|
+
export function getParamsByIndexForOneOf (schema, rootSchema, values, params) {
|
355
|
+
/**
|
356
|
+
* log('getParamsByIndexForOneOf')
|
357
|
+
*/
|
358
|
+
|
359
|
+
const {
|
360
|
+
parentUri = '#',
|
361
|
+
index = 0
|
362
|
+
} = params
|
363
|
+
|
364
|
+
const uri = getUri(parentUri, index)
|
365
|
+
|
366
|
+
const {
|
367
|
+
selectedItems = getSelectedItems(values, parentUri), // parent uri,
|
368
|
+
...metaProps
|
369
|
+
} = getMetaProps(params, uri)
|
370
|
+
|
371
|
+
const meta = Object.assign(metaProps, {
|
372
|
+
schema,
|
373
|
+
rootSchema,
|
374
|
+
parentUri: normaliseUri(parentUri),
|
375
|
+
uri,
|
376
|
+
selectedItems
|
377
|
+
})
|
378
|
+
const elements = {
|
379
|
+
oneOf: Object.assign(getElementsFieldPropsForOneOf(params, uri), {
|
380
|
+
selectedItems
|
381
|
+
})
|
382
|
+
}
|
383
|
+
|
384
|
+
return Object.assign(params, {
|
385
|
+
parentUri,
|
386
|
+
uri,
|
387
|
+
index,
|
388
|
+
[uri]: {
|
389
|
+
meta,
|
390
|
+
elements
|
391
|
+
}
|
392
|
+
})
|
393
|
+
}
|
394
|
+
|
395
|
+
/**
|
396
|
+
* @param {SchemaType} schema
|
397
|
+
* @param {SchemaType} rootSchema
|
398
|
+
* @param {ValuesType} values
|
399
|
+
* @param {ParamsType} params
|
400
|
+
* @returns {ParamsType}
|
401
|
+
*/
|
402
|
+
export function getParamsByIndex (schema, rootSchema, values, params) {
|
403
|
+
/**
|
404
|
+
* log('getParamsByIndex')
|
405
|
+
*/
|
406
|
+
|
407
|
+
const {
|
408
|
+
parentUri = '#',
|
409
|
+
index = 0
|
410
|
+
} = params
|
411
|
+
|
412
|
+
const uri = getUri(parentUri, index)
|
413
|
+
|
414
|
+
const meta = Object.assign(getMetaProps(params, uri), {
|
415
|
+
schema,
|
416
|
+
rootSchema,
|
417
|
+
parentUri: normaliseUri(parentUri),
|
418
|
+
uri
|
419
|
+
})
|
420
|
+
|
421
|
+
return Object.assign(params, {
|
422
|
+
parentUri,
|
423
|
+
uri,
|
424
|
+
index,
|
425
|
+
[uri]: {
|
426
|
+
meta,
|
427
|
+
elements: getElementsProps(params, uri)
|
428
|
+
}
|
429
|
+
})
|
430
|
+
}
|