shinkansen-transmission 2.1.15 → 2.2.2

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 (82) hide show
  1. package/.husky/pre-commit +4 -0
  2. package/babel.config.js +1 -1
  3. package/index.js +6 -1
  4. package/lib/index.js +1 -1
  5. package/lib/transmission/common/index.js +1 -1
  6. package/lib/transmission/from-document-to-hash/index.js +1 -1
  7. package/lib/transmission/from-hash-to-document/index.js +1 -1
  8. package/lib/transmission/index.js +1 -1
  9. package/lib/transmission/to-zashiki/index.js +1 -1
  10. package/lib/transmission/to-zashiki/transform-root-schema.js +1 -1
  11. package/lib/transmission/to-zashiki/transform-schema.js +1 -1
  12. package/package.json +23 -30
  13. package/src/transmission/from-document-to-hash/index.js +75 -29
  14. package/src/transmission/from-hash-to-document/index.js +13 -10
  15. package/src/transmission/to-zashiki/transform-root-schema.js +143 -136
  16. package/src/transmission/to-zashiki/transform-schema.js +3256 -1952
  17. package/.github/dependabot.yml +0 -9
  18. package/test/transmission/common/index.spec.js +0 -1348
  19. package/test/transmission/from-document-to-hash/index.spec.js +0 -1866
  20. package/test/transmission/from-hash-to-document/index.spec.js +0 -1523
  21. package/test/transmission/to-zashiki/transform-root-schema/transforming-array-type-schemas.spec.js +0 -1784
  22. package/test/transmission/to-zashiki/transform-root-schema/transforming-boolean-type-schemas.spec.js +0 -334
  23. package/test/transmission/to-zashiki/transform-root-schema/transforming-null-type-schemas.spec.js +0 -253
  24. package/test/transmission/to-zashiki/transform-root-schema/transforming-number-type-schemas.spec.js +0 -565
  25. package/test/transmission/to-zashiki/transform-root-schema/transforming-object-type-schemas.spec.js +0 -1715
  26. package/test/transmission/to-zashiki/transform-root-schema/transforming-string-type-schemas.spec.js +0 -496
  27. package/test/transmission/to-zashiki/transform-root-schema/with-values/with-params/transforming-array-type-schemas.spec.js +0 -31633
  28. package/test/transmission/to-zashiki/transform-root-schema/with-values/with-params/transforming-boolean-type-schemas.spec.js +0 -359
  29. package/test/transmission/to-zashiki/transform-root-schema/with-values/with-params/transforming-null-type-schemas.spec.js +0 -359
  30. package/test/transmission/to-zashiki/transform-root-schema/with-values/with-params/transforming-number-type-schemas.spec.js +0 -446
  31. package/test/transmission/to-zashiki/transform-root-schema/with-values/with-params/transforming-object-type-schemas.spec.js +0 -8348
  32. package/test/transmission/to-zashiki/transform-root-schema/with-values/with-params/transforming-string-type-schemas.spec.js +0 -446
  33. package/test/transmission/to-zashiki/transform-root-schema/with-values/without-params/transforming-array-type-schemas.spec.js +0 -30373
  34. package/test/transmission/to-zashiki/transform-root-schema/with-values/without-params/transforming-boolean-type-schemas.spec.js +0 -334
  35. package/test/transmission/to-zashiki/transform-root-schema/with-values/without-params/transforming-null-type-schemas.spec.js +0 -253
  36. package/test/transmission/to-zashiki/transform-root-schema/with-values/without-params/transforming-number-type-schemas.spec.js +0 -421
  37. package/test/transmission/to-zashiki/transform-root-schema/with-values/without-params/transforming-object-type-schemas.spec.js +0 -7826
  38. package/test/transmission/to-zashiki/transform-root-schema/with-values/without-params/transforming-string-type-schemas.spec.js +0 -421
  39. package/test/transmission/to-zashiki/transform-root-schema/without-values/with-params/transforming-array-type-schemas.spec.js +0 -31111
  40. package/test/transmission/to-zashiki/transform-root-schema/without-values/with-params/transforming-boolean-type-schemas.spec.js +0 -347
  41. package/test/transmission/to-zashiki/transform-root-schema/without-values/with-params/transforming-null-type-schemas.spec.js +0 -344
  42. package/test/transmission/to-zashiki/transform-root-schema/without-values/with-params/transforming-number-type-schemas.spec.js +0 -434
  43. package/test/transmission/to-zashiki/transform-root-schema/without-values/with-params/transforming-object-type-schemas.spec.js +0 -8222
  44. package/test/transmission/to-zashiki/transform-root-schema/without-values/with-params/transforming-string-type-schemas.spec.js +0 -434
  45. package/test/transmission/to-zashiki/transform-root-schema/without-values/without-params/transforming-array-type-schemas.spec.js +0 -29494
  46. package/test/transmission/to-zashiki/transform-root-schema/without-values/without-params/transforming-boolean-type-schemas.spec.js +0 -312
  47. package/test/transmission/to-zashiki/transform-root-schema/without-values/without-params/transforming-null-type-schemas.spec.js +0 -309
  48. package/test/transmission/to-zashiki/transform-root-schema/without-values/without-params/transforming-number-type-schemas.spec.js +0 -399
  49. package/test/transmission/to-zashiki/transform-root-schema/without-values/without-params/transforming-object-type-schemas.spec.js +0 -7584
  50. package/test/transmission/to-zashiki/transform-root-schema/without-values/without-params/transforming-string-type-schemas.spec.js +0 -398
  51. package/test/transmission/to-zashiki/transform-root-schema.spec.js +0 -22
  52. package/test/transmission/to-zashiki/transform-schema/transforming-array-type-schemas.spec.js +0 -1806
  53. package/test/transmission/to-zashiki/transform-schema/transforming-boolean-type-schemas.spec.js +0 -340
  54. package/test/transmission/to-zashiki/transform-schema/transforming-null-type-schemas.spec.js +0 -259
  55. package/test/transmission/to-zashiki/transform-schema/transforming-number-type-schemas.spec.js +0 -571
  56. package/test/transmission/to-zashiki/transform-schema/transforming-object-type-schemas.spec.js +0 -1737
  57. package/test/transmission/to-zashiki/transform-schema/transforming-string-type-schemas.spec.js +0 -502
  58. package/test/transmission/to-zashiki/transform-schema/with-values/with-params/transforming-array-type-schemas.spec.js +0 -32173
  59. package/test/transmission/to-zashiki/transform-schema/with-values/with-params/transforming-boolean-type-schemas.spec.js +0 -377
  60. package/test/transmission/to-zashiki/transform-schema/with-values/with-params/transforming-null-type-schemas.spec.js +0 -377
  61. package/test/transmission/to-zashiki/transform-schema/with-values/with-params/transforming-number-type-schemas.spec.js +0 -464
  62. package/test/transmission/to-zashiki/transform-schema/with-values/with-params/transforming-object-type-schemas.spec.js +0 -8525
  63. package/test/transmission/to-zashiki/transform-schema/with-values/with-params/transforming-string-type-schemas.spec.js +0 -464
  64. package/test/transmission/to-zashiki/transform-schema/with-values/without-params/transforming-array-type-schemas.spec.js +0 -30910
  65. package/test/transmission/to-zashiki/transform-schema/with-values/without-params/transforming-boolean-type-schemas.spec.js +0 -352
  66. package/test/transmission/to-zashiki/transform-schema/with-values/without-params/transforming-null-type-schemas.spec.js +0 -271
  67. package/test/transmission/to-zashiki/transform-schema/with-values/without-params/transforming-number-type-schemas.spec.js +0 -439
  68. package/test/transmission/to-zashiki/transform-schema/with-values/without-params/transforming-object-type-schemas.spec.js +0 -8003
  69. package/test/transmission/to-zashiki/transform-schema/with-values/without-params/transforming-string-type-schemas.spec.js +0 -439
  70. package/test/transmission/to-zashiki/transform-schema/without-values/with-params/transforming-array-type-schemas.spec.js +0 -31654
  71. package/test/transmission/to-zashiki/transform-schema/without-values/with-params/transforming-boolean-type-schemas.spec.js +0 -365
  72. package/test/transmission/to-zashiki/transform-schema/without-values/with-params/transforming-null-type-schemas.spec.js +0 -362
  73. package/test/transmission/to-zashiki/transform-schema/without-values/with-params/transforming-number-type-schemas.spec.js +0 -452
  74. package/test/transmission/to-zashiki/transform-schema/without-values/with-params/transforming-object-type-schemas.spec.js +0 -8399
  75. package/test/transmission/to-zashiki/transform-schema/without-values/with-params/transforming-string-type-schemas.spec.js +0 -452
  76. package/test/transmission/to-zashiki/transform-schema/without-values/without-params/transforming-array-type-schemas.spec.js +0 -29671
  77. package/test/transmission/to-zashiki/transform-schema/without-values/without-params/transforming-boolean-type-schemas.spec.js +0 -320
  78. package/test/transmission/to-zashiki/transform-schema/without-values/without-params/transforming-null-type-schemas.spec.js +0 -317
  79. package/test/transmission/to-zashiki/transform-schema/without-values/without-params/transforming-number-type-schemas.spec.js +0 -407
  80. package/test/transmission/to-zashiki/transform-schema/without-values/without-params/transforming-object-type-schemas.spec.js +0 -7645
  81. package/test/transmission/to-zashiki/transform-schema/without-values/without-params/transforming-string-type-schemas.spec.js +0 -406
  82. package/test/transmission/to-zashiki/transform-schema.spec.js +0 -777
@@ -1,464 +0,0 @@
1
- import debug from 'debug'
2
-
3
- import { expect } from 'chai'
4
-
5
- import transform from 'shinkansen-transmission/transmission/to-zashiki/transform-schema'
6
-
7
- describe('shinkansen-transmission/transmission/to-zashiki/transform-schema', () => {
8
- before(() => {
9
- const {
10
- env: {
11
- DEBUG
12
- }
13
- } = process
14
-
15
- if (DEBUG) debug.enable(DEBUG)
16
- })
17
-
18
- describe('With values', () => {
19
- describe('With params', () => {
20
- /*
21
- * Number
22
- */
23
- describe('Transforming `number` type schemas', () => {
24
- it('transforms with `enum`', () => {
25
- const schema = {
26
- type: 'number',
27
- enum: [
28
- 1,
29
- 2,
30
- 3
31
- ]
32
- }
33
-
34
- const rootSchema = undefined
35
-
36
- const values = {
37
- '#/': '2'
38
- }
39
-
40
- const params = {
41
- '#/': { meta: { component: 'component' } }
42
- }
43
-
44
- return expect(transform(schema, rootSchema, values, params))
45
- .to.eql({
46
- meta: {
47
- component: 'component',
48
- type: 'number',
49
- rootSchema: {},
50
- schema,
51
- uri: '#/',
52
- items: [
53
- 1,
54
- 2,
55
- 3
56
- ],
57
- selectedItems: [2]
58
- },
59
- elements: {
60
- enum: {
61
- id: '#/',
62
- items: [
63
- 1,
64
- 2,
65
- 3
66
- ],
67
- selectedItems: [2]
68
- }
69
- }
70
- })
71
- })
72
-
73
- it('transforms with `anyOf`', () => {
74
- const schema = {
75
- type: 'number',
76
- anyOf: [
77
- { const: 1 },
78
- { const: 2 },
79
- { const: 3 }
80
- ]
81
- }
82
-
83
- const rootSchema = undefined
84
-
85
- const values = {
86
- '#/': '2'
87
- }
88
-
89
- const params = {
90
- '#/': { meta: { component: 'component' } }
91
- }
92
-
93
- return expect(transform(schema, rootSchema, values, params))
94
- .to.eql({
95
- meta: {
96
- component: 'component',
97
- type: 'number',
98
- rootSchema: {},
99
- schema,
100
- uri: '#/',
101
- items: [
102
- {
103
- meta: {
104
- type: 'number',
105
- item: 0,
106
- rootSchema: {},
107
- schema: {
108
- const: 1
109
- },
110
- parentUri: '#/',
111
- uri: '#/0',
112
- value: '1'
113
- },
114
- elements: {
115
- field: {
116
- id: '#/0',
117
- value: '1'
118
- }
119
- }
120
- },
121
- {
122
- meta: {
123
- type: 'number',
124
- item: 1,
125
- rootSchema: {},
126
- schema: {
127
- const: 2
128
- },
129
- parentUri: '#/',
130
- uri: '#/1',
131
- value: '2'
132
- },
133
- elements: {
134
- field: {
135
- id: '#/1',
136
- value: '2'
137
- }
138
- }
139
- },
140
- {
141
- meta: {
142
- type: 'number',
143
- item: 2,
144
- rootSchema: {},
145
- schema: {
146
- const: 3
147
- },
148
- parentUri: '#/',
149
- uri: '#/2',
150
- value: '3'
151
- },
152
- elements: {
153
- field: {
154
- id: '#/2',
155
- value: '3'
156
- }
157
- }
158
- }
159
- ],
160
- selectedItems: [2]
161
- },
162
- elements: {
163
- anyOf: {
164
- id: '#/',
165
- items: [
166
- {
167
- meta: {
168
- type: 'number',
169
- item: 0,
170
- rootSchema: {},
171
- schema: {
172
- const: 1
173
- },
174
- parentUri: '#/',
175
- uri: '#/0',
176
- value: '1'
177
- },
178
- elements: {
179
- field: {
180
- id: '#/0',
181
- value: '1'
182
- }
183
- }
184
- },
185
- {
186
- meta: {
187
- type: 'number',
188
- item: 1,
189
- rootSchema: {},
190
- schema: {
191
- const: 2
192
- },
193
- parentUri: '#/',
194
- uri: '#/1',
195
- value: '2'
196
- },
197
- elements: {
198
- field: {
199
- id: '#/1',
200
- value: '2'
201
- }
202
- }
203
- },
204
- {
205
- meta: {
206
- type: 'number',
207
- item: 2,
208
- rootSchema: {},
209
- schema: {
210
- const: 3
211
- },
212
- parentUri: '#/',
213
- uri: '#/2',
214
- value: '3'
215
- },
216
- elements: {
217
- field: {
218
- id: '#/2',
219
- value: '3'
220
- }
221
- }
222
- }
223
- ],
224
- selectedItems: [2]
225
- }
226
- }
227
- })
228
- })
229
-
230
- it('transforms with `oneOf`', () => {
231
- const schema = {
232
- type: 'number',
233
- oneOf: [
234
- { const: 1 },
235
- { const: 2 },
236
- { const: 3 }
237
- ]
238
- }
239
-
240
- const rootSchema = undefined
241
-
242
- const values = {
243
- '#/': '2'
244
- }
245
-
246
- const params = {
247
- '#/': { meta: { component: 'component' } }
248
- }
249
-
250
- return expect(transform(schema, rootSchema, values, params))
251
- .to.eql({
252
- meta: {
253
- component: 'component',
254
- type: 'number',
255
- rootSchema: {},
256
- schema,
257
- uri: '#/',
258
- items: [
259
- {
260
- meta: {
261
- type: 'number',
262
- item: 0,
263
- rootSchema: {},
264
- schema: {
265
- const: 1
266
- },
267
- parentUri: '#/',
268
- uri: '#/0',
269
- value: '1'
270
- },
271
- elements: {
272
- field: {
273
- id: '#/0',
274
- value: '1'
275
- }
276
- }
277
- },
278
- {
279
- meta: {
280
- type: 'number',
281
- item: 1,
282
- rootSchema: {},
283
- schema: {
284
- const: 2
285
- },
286
- parentUri: '#/',
287
- uri: '#/1',
288
- value: '2'
289
- },
290
- elements: {
291
- field: {
292
- id: '#/1',
293
- value: '2'
294
- }
295
- }
296
- },
297
- {
298
- meta: {
299
- type: 'number',
300
- item: 2,
301
- rootSchema: {},
302
- schema: {
303
- const: 3
304
- },
305
- parentUri: '#/',
306
- uri: '#/2',
307
- value: '3'
308
- },
309
- elements: {
310
- field: {
311
- id: '#/2',
312
- value: '3'
313
- }
314
- }
315
- }
316
- ],
317
- selectedItems: [2]
318
- },
319
- elements: {
320
- oneOf: {
321
- id: '#/',
322
- items: [
323
- {
324
- meta: {
325
- type: 'number',
326
- item: 0,
327
- rootSchema: {},
328
- schema: {
329
- const: 1
330
- },
331
- parentUri: '#/',
332
- uri: '#/0',
333
- value: '1'
334
- },
335
- elements: {
336
- field: {
337
- id: '#/0',
338
- value: '1'
339
- }
340
- }
341
- },
342
- {
343
- meta: {
344
- type: 'number',
345
- item: 1,
346
- rootSchema: {},
347
- schema: {
348
- const: 2
349
- },
350
- parentUri: '#/',
351
- uri: '#/1',
352
- value: '2'
353
- },
354
- elements: {
355
- field: {
356
- id: '#/1',
357
- value: '2'
358
- }
359
- }
360
- },
361
- {
362
- meta: {
363
- type: 'number',
364
- item: 2,
365
- rootSchema: {},
366
- schema: {
367
- const: 3
368
- },
369
- parentUri: '#/',
370
- uri: '#/2',
371
- value: '3'
372
- },
373
- elements: {
374
- field: {
375
- id: '#/2',
376
- value: '3'
377
- }
378
- }
379
- }
380
- ],
381
- selectedItems: [2]
382
- }
383
- }
384
- })
385
- })
386
-
387
- it('transforms with `allOf`', () => {
388
- const schema = {
389
- type: 'number',
390
- allOf: [
391
- { minimum: 1 },
392
- { const: 2 },
393
- { maximum: 3 }
394
- ]
395
- }
396
-
397
- const rootSchema = undefined
398
-
399
- const values = {
400
- '#/': '1'
401
- }
402
-
403
- const params = {
404
- '#/': { meta: { component: 'component' } }
405
- }
406
-
407
- return expect(transform(schema, rootSchema, values, params))
408
- .to.eql({
409
- meta: {
410
- component: 'component',
411
- type: 'number',
412
- rootSchema: {},
413
- schema,
414
- min: 1,
415
- max: 3,
416
- uri: '#/',
417
- value: '1'
418
- },
419
- elements: {
420
- field: {
421
- id: '#/',
422
- min: 1,
423
- max: 3,
424
- value: '1'
425
- }
426
- }
427
- })
428
- })
429
-
430
- it('transforms without `enum` or `anyOf` or `oneOf` or `allOf`', () => {
431
- const schema = { type: 'number' }
432
-
433
- const rootSchema = undefined
434
-
435
- const values = {
436
- '#/': '1'
437
- }
438
-
439
- const params = {
440
- '#/': { meta: { component: 'component' } }
441
- }
442
-
443
- return expect(transform(schema, rootSchema, values, params))
444
- .to.eql({
445
- meta: {
446
- component: 'component',
447
- type: 'number',
448
- rootSchema: {},
449
- schema,
450
- uri: '#/',
451
- value: '1'
452
- },
453
- elements: {
454
- field: {
455
- id: '#/',
456
- value: '1'
457
- }
458
- }
459
- })
460
- })
461
- })
462
- })
463
- })
464
- })