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,439 +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('Without params', () => {
20
- /*
21
- * Number
22
- */
23
- describe('Transforming `number` type schemas', () => {
24
- it('transforms `number` type schemas 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
- return expect(transform(schema, rootSchema, values))
41
- .to.eql({
42
- meta: {
43
- type: 'number',
44
- rootSchema: {},
45
- schema,
46
- uri: '#/',
47
- items: [
48
- 1,
49
- 2,
50
- 3
51
- ],
52
- selectedItems: [2]
53
- },
54
- elements: {
55
- enum: {
56
- id: '#/',
57
- items: [
58
- 1,
59
- 2,
60
- 3
61
- ],
62
- selectedItems: [2]
63
- }
64
- }
65
- })
66
- })
67
-
68
- it('transforms `number` type schemas with `anyOf`', () => {
69
- const schema = {
70
- type: 'number',
71
- anyOf: [
72
- { const: 1 },
73
- { const: 2 },
74
- { const: 3 }
75
- ]
76
- }
77
-
78
- const rootSchema = undefined
79
-
80
- const values = {
81
- '#/': '2'
82
- }
83
-
84
- return expect(transform(schema, rootSchema, values))
85
- .to.eql({
86
- meta: {
87
- type: 'number',
88
- rootSchema: {},
89
- schema,
90
- uri: '#/',
91
- items: [
92
- {
93
- meta: {
94
- type: 'number',
95
- item: 0,
96
- rootSchema: {},
97
- schema: {
98
- const: 1
99
- },
100
- parentUri: '#/',
101
- uri: '#/0',
102
- value: '1'
103
- },
104
- elements: {
105
- field: {
106
- id: '#/0',
107
- value: '1'
108
- }
109
- }
110
- },
111
- {
112
- meta: {
113
- type: 'number',
114
- item: 1,
115
- rootSchema: {},
116
- schema: {
117
- const: 2
118
- },
119
- parentUri: '#/',
120
- uri: '#/1',
121
- value: '2'
122
- },
123
- elements: {
124
- field: {
125
- id: '#/1',
126
- value: '2'
127
- }
128
- }
129
- },
130
- {
131
- meta: {
132
- type: 'number',
133
- item: 2,
134
- rootSchema: {},
135
- schema: {
136
- const: 3
137
- },
138
- parentUri: '#/',
139
- uri: '#/2',
140
- value: '3'
141
- },
142
- elements: {
143
- field: {
144
- id: '#/2',
145
- value: '3'
146
- }
147
- }
148
- }
149
- ],
150
- selectedItems: [2]
151
- },
152
- elements: {
153
- anyOf: {
154
- id: '#/',
155
- items: [
156
- {
157
- meta: {
158
- type: 'number',
159
- item: 0,
160
- rootSchema: {},
161
- schema: {
162
- const: 1
163
- },
164
- parentUri: '#/',
165
- uri: '#/0',
166
- value: '1'
167
- },
168
- elements: {
169
- field: {
170
- id: '#/0',
171
- value: '1'
172
- }
173
- }
174
- },
175
- {
176
- meta: {
177
- type: 'number',
178
- item: 1,
179
- rootSchema: {},
180
- schema: {
181
- const: 2
182
- },
183
- parentUri: '#/',
184
- uri: '#/1',
185
- value: '2'
186
- },
187
- elements: {
188
- field: {
189
- id: '#/1',
190
- value: '2'
191
- }
192
- }
193
- },
194
- {
195
- meta: {
196
- type: 'number',
197
- item: 2,
198
- rootSchema: {},
199
- schema: {
200
- const: 3
201
- },
202
- parentUri: '#/',
203
- uri: '#/2',
204
- value: '3'
205
- },
206
- elements: {
207
- field: {
208
- id: '#/2',
209
- value: '3'
210
- }
211
- }
212
- }
213
- ],
214
- selectedItems: [2]
215
- }
216
- }
217
- })
218
- })
219
-
220
- it('transforms `number` type schemas with `oneOf`', () => {
221
- const schema = {
222
- type: 'number',
223
- oneOf: [
224
- { const: 1 },
225
- { const: 2 },
226
- { const: 3 }
227
- ]
228
- }
229
-
230
- const rootSchema = undefined
231
-
232
- const values = {
233
- '#/': '2'
234
- }
235
-
236
- return expect(transform(schema, rootSchema, values))
237
- .to.eql({
238
- meta: {
239
- type: 'number',
240
- rootSchema: {},
241
- schema,
242
- uri: '#/',
243
- items: [
244
- {
245
- meta: {
246
- type: 'number',
247
- item: 0,
248
- rootSchema: {},
249
- schema: {
250
- const: 1
251
- },
252
- parentUri: '#/',
253
- uri: '#/0',
254
- value: '1'
255
- },
256
- elements: {
257
- field: {
258
- id: '#/0',
259
- value: '1'
260
- }
261
- }
262
- },
263
- {
264
- meta: {
265
- type: 'number',
266
- item: 1,
267
- rootSchema: {},
268
- schema: {
269
- const: 2
270
- },
271
- parentUri: '#/',
272
- uri: '#/1',
273
- value: '2'
274
- },
275
- elements: {
276
- field: {
277
- id: '#/1',
278
- value: '2'
279
- }
280
- }
281
- },
282
- {
283
- meta: {
284
- type: 'number',
285
- item: 2,
286
- rootSchema: {},
287
- schema: {
288
- const: 3
289
- },
290
- parentUri: '#/',
291
- uri: '#/2',
292
- value: '3'
293
- },
294
- elements: {
295
- field: {
296
- id: '#/2',
297
- value: '3'
298
- }
299
- }
300
- }
301
- ],
302
- selectedItems: [2]
303
- },
304
- elements: {
305
- oneOf: {
306
- id: '#/',
307
- items: [
308
- {
309
- meta: {
310
- type: 'number',
311
- item: 0,
312
- rootSchema: {},
313
- schema: {
314
- const: 1
315
- },
316
- parentUri: '#/',
317
- uri: '#/0',
318
- value: '1'
319
- },
320
- elements: {
321
- field: {
322
- id: '#/0',
323
- value: '1'
324
- }
325
- }
326
- },
327
- {
328
- meta: {
329
- type: 'number',
330
- item: 1,
331
- rootSchema: {},
332
- schema: {
333
- const: 2
334
- },
335
- parentUri: '#/',
336
- uri: '#/1',
337
- value: '2'
338
- },
339
- elements: {
340
- field: {
341
- id: '#/1',
342
- value: '2'
343
- }
344
- }
345
- },
346
- {
347
- meta: {
348
- type: 'number',
349
- item: 2,
350
- rootSchema: {},
351
- schema: {
352
- const: 3
353
- },
354
- parentUri: '#/',
355
- uri: '#/2',
356
- value: '3'
357
- },
358
- elements: {
359
- field: {
360
- id: '#/2',
361
- value: '3'
362
- }
363
- }
364
- }
365
- ],
366
- selectedItems: [2]
367
- }
368
- }
369
- })
370
- })
371
-
372
- it('transforms `number` type schemas with `allOf`', () => {
373
- const schema = {
374
- type: 'number',
375
- allOf: [
376
- { minimum: 1 },
377
- { const: 2 },
378
- { maximum: 3 }
379
- ]
380
- }
381
-
382
- const rootSchema = undefined
383
-
384
- const values = {
385
- '#/': '2'
386
- }
387
-
388
- return expect(transform(schema, rootSchema, values))
389
- .to.eql({
390
- meta: {
391
- type: 'number',
392
- rootSchema: {},
393
- schema,
394
- min: 1,
395
- max: 3,
396
- uri: '#/',
397
- value: '2'
398
- },
399
- elements: {
400
- field: {
401
- id: '#/',
402
- min: 1,
403
- max: 3,
404
- value: '2'
405
- }
406
- }
407
- })
408
- })
409
-
410
- it('transforms `number` type schemas without `enum` or `anyOf` or `oneOf` or `allOf`', () => {
411
- const schema = { type: 'number' }
412
-
413
- const rootSchema = undefined
414
-
415
- const values = {
416
- '#/': '1'
417
- }
418
-
419
- return expect(transform(schema, rootSchema, values))
420
- .to.eql({
421
- meta: {
422
- type: 'number',
423
- rootSchema: {},
424
- schema,
425
- uri: '#/',
426
- value: '1'
427
- },
428
- elements: {
429
- field: {
430
- id: '#/',
431
- value: '1'
432
- }
433
- }
434
- })
435
- })
436
- })
437
- })
438
- })
439
- })