@zuplo/cli 6.71.23 → 6.71.26

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 (128) hide show
  1. package/node_modules/@fastify/fast-json-stringify-compiler/.github/dependabot.yml +42 -2
  2. package/node_modules/@fastify/fast-json-stringify-compiler/.github/workflows/ci.yml +6 -1
  3. package/node_modules/@fastify/fast-json-stringify-compiler/.github/workflows/lock-threads.yml +19 -0
  4. package/node_modules/@fastify/fast-json-stringify-compiler/LICENSE +1 -1
  5. package/node_modules/@fastify/fast-json-stringify-compiler/README.md +1 -1
  6. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/.gitattributes +2 -0
  7. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/.github/dependabot.yml +13 -0
  8. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/.github/workflows/ci.yml +33 -0
  9. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/.github/workflows/lock-threads.yml +19 -0
  10. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/LICENSE +22 -0
  11. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/README.md +742 -0
  12. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/benchmark/bench-cmp-branch.js +116 -0
  13. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/benchmark/bench-cmp-lib.js +339 -0
  14. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/benchmark/bench-thread.js +33 -0
  15. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/benchmark/bench.js +391 -0
  16. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/build/build-schema-validator.js +26 -0
  17. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/eslint.config.js +9 -0
  18. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/examples/example.js +81 -0
  19. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/examples/server.js +42 -0
  20. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/index.js +1308 -0
  21. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/lib/location.js +24 -0
  22. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/lib/merge-schemas.js +9 -0
  23. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/lib/schema-validator.js +1134 -0
  24. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/lib/serializer.js +141 -0
  25. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/lib/standalone.js +34 -0
  26. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/lib/validator.js +96 -0
  27. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/package.json +89 -0
  28. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/additionalProperties.test.js +332 -0
  29. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/allof.test.js +751 -0
  30. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/any.test.js +231 -0
  31. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/anyof.test.js +812 -0
  32. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/array.test.js +688 -0
  33. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/asNumber.test.js +13 -0
  34. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/basic.test.js +400 -0
  35. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/bigint.test.js +76 -0
  36. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/clean-cache.test.js +47 -0
  37. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/const.test.js +314 -0
  38. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/date.test.js +639 -0
  39. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/debug-mode.test.js +130 -0
  40. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/defaults.test.js +376 -0
  41. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/enum.test.js +37 -0
  42. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/fix-604.test.js +25 -0
  43. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/fixtures/.keep +0 -0
  44. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/if-then-else.test.js +540 -0
  45. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/inferType.test.js +92 -0
  46. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/infinity.test.js +55 -0
  47. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/integer.test.js +194 -0
  48. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/invalidSchema.test.js +38 -0
  49. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/issue-479.test.js +57 -0
  50. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/issue-793.test.js +107 -0
  51. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/issue-794.test.js +177 -0
  52. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/issue-836.test.js +183 -0
  53. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/json-add-comma.test.js +57 -0
  54. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/json-schema-test-suite/README.md +10 -0
  55. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/json-schema-test-suite/draft4/required.json +54 -0
  56. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/json-schema-test-suite/draft4.test.js +12 -0
  57. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/json-schema-test-suite/draft6/required.json +70 -0
  58. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/json-schema-test-suite/draft6.test.js +12 -0
  59. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/json-schema-test-suite/draft7/required.json +70 -0
  60. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/json-schema-test-suite/draft7.test.js +12 -0
  61. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/json-schema-test-suite/util.js +31 -0
  62. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/missing-values.test.js +88 -0
  63. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/multi-type-serializer.test.js +19 -0
  64. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/nestedObjects.test.js +63 -0
  65. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/nullable.test.js +543 -0
  66. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/oneof.test.js +510 -0
  67. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/patternProperties.test.js +168 -0
  68. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/recursion.test.js +245 -0
  69. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/ref.json +12 -0
  70. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/ref.test.js +2077 -0
  71. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/regex.test.js +32 -0
  72. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/required.test.js +204 -0
  73. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/requiresAjv.test.js +50 -0
  74. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/sanitize.test.js +141 -0
  75. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/sanitize2.test.js +18 -0
  76. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/sanitize3.test.js +17 -0
  77. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/sanitize4.test.js +16 -0
  78. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/sanitize5.test.js +16 -0
  79. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/sanitize6.test.js +22 -0
  80. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/sanitize7.test.js +68 -0
  81. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/side-effect.test.js +196 -0
  82. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/standalone-mode.test.js +219 -0
  83. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/string.test.js +84 -0
  84. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/surrogate.test.js +67 -0
  85. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/toJSON.test.js +203 -0
  86. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/typebox.test.js +36 -0
  87. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/typesArray.test.js +550 -0
  88. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/unknownFormats.test.js +27 -0
  89. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/webpack.test.js +50 -0
  90. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/types/index.d.ts +219 -0
  91. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/types/index.tst.ts +259 -0
  92. package/node_modules/@fastify/fast-json-stringify-compiler/package.json +6 -11
  93. package/node_modules/@fastify/fast-json-stringify-compiler/types/{index.test-d.ts → index.tst.ts} +34 -32
  94. package/node_modules/@protobufjs/utf8/CHANGELOG.md +8 -0
  95. package/node_modules/@protobufjs/utf8/index.js +29 -18
  96. package/node_modules/@protobufjs/utf8/package.json +2 -2
  97. package/node_modules/@protobufjs/utf8/tests/index.js +5 -0
  98. package/node_modules/@zuplo/core/package.json +1 -1
  99. package/node_modules/@zuplo/graphql/package.json +1 -1
  100. package/node_modules/@zuplo/openapi-tools/package.json +1 -1
  101. package/node_modules/@zuplo/otel/package.json +1 -1
  102. package/node_modules/@zuplo/runtime/out/esm/{chunk-5CYWMN74.js → chunk-D3O7C43P.js} +98 -97
  103. package/node_modules/@zuplo/runtime/out/esm/chunk-D3O7C43P.js.map +1 -0
  104. package/node_modules/@zuplo/runtime/out/esm/index.js +1 -1
  105. package/node_modules/@zuplo/runtime/out/esm/index.js.map +1 -1
  106. package/node_modules/@zuplo/runtime/out/esm/mcp-gateway/index.js +1 -1
  107. package/node_modules/@zuplo/runtime/out/types/index.d.ts +172 -0
  108. package/node_modules/@zuplo/runtime/package.json +1 -1
  109. package/node_modules/hono/dist/adapter/aws-lambda/handler.js +1 -1
  110. package/node_modules/hono/dist/adapter/bun/websocket.js +3 -1
  111. package/node_modules/hono/dist/cjs/adapter/aws-lambda/handler.js +1 -1
  112. package/node_modules/hono/dist/cjs/adapter/bun/websocket.js +3 -1
  113. package/node_modules/hono/dist/cjs/middleware/serve-static/index.js +1 -1
  114. package/node_modules/hono/dist/cjs/utils/body.js +12 -4
  115. package/node_modules/hono/dist/cjs/utils/buffer.js +2 -1
  116. package/node_modules/hono/dist/cjs/validator/validator.js +3 -3
  117. package/node_modules/hono/dist/middleware/serve-static/index.js +1 -1
  118. package/node_modules/hono/dist/types/middleware/context-storage/index.d.ts +2 -2
  119. package/node_modules/hono/dist/types/utils/body.d.ts +1 -1
  120. package/node_modules/hono/dist/utils/body.js +12 -4
  121. package/node_modules/hono/dist/utils/buffer.js +2 -1
  122. package/node_modules/hono/dist/validator/validator.js +3 -3
  123. package/node_modules/hono/package.json +8 -7
  124. package/package.json +6 -6
  125. package/node_modules/@fastify/fast-json-stringify-compiler/.eslintrc +0 -1
  126. package/node_modules/@zuplo/runtime/out/esm/chunk-5CYWMN74.js.map +0 -1
  127. package/node_modules/hono/dist/tsconfig.build.tsbuildinfo +0 -1
  128. /package/node_modules/@zuplo/runtime/out/esm/{chunk-5CYWMN74.js.LEGAL.txt → chunk-D3O7C43P.js.LEGAL.txt} +0 -0
@@ -0,0 +1,543 @@
1
+ 'use strict'
2
+
3
+ const { test } = require('node:test')
4
+
5
+ const build = require('..')
6
+
7
+ const nullable = true
8
+
9
+ const complexObject = {
10
+ type: 'object',
11
+ properties: {
12
+ nullableString: { type: 'string', nullable },
13
+ nullableNumber: { type: 'number', nullable },
14
+ nullableInteger: { type: 'integer', nullable },
15
+ nullableBoolean: { type: 'boolean', nullable },
16
+ nullableNull: { type: 'null', nullable },
17
+ nullableArray: {
18
+ type: 'array',
19
+ nullable: true,
20
+ items: {}
21
+ },
22
+ nullableObject: { type: 'object', nullable: true },
23
+ objectWithNullableProps: {
24
+ type: 'object',
25
+ nullable: false,
26
+ additionalProperties: true,
27
+ properties: {
28
+ nullableString: { type: 'string', nullable },
29
+ nullableNumber: { type: 'number', nullable },
30
+ nullableInteger: { type: 'integer', nullable },
31
+ nullableBoolean: { type: 'boolean', nullable },
32
+ nullableNull: { type: 'null', nullable },
33
+ nullableArray: {
34
+ type: 'array',
35
+ nullable: true,
36
+ items: {}
37
+ }
38
+ }
39
+ },
40
+ arrayWithNullableItems: {
41
+ type: 'array',
42
+ nullable: true,
43
+ items: { type: ['integer', 'string'], nullable: true }
44
+ }
45
+ }
46
+ }
47
+
48
+ const complexData = {
49
+ nullableString: null,
50
+ nullableNumber: null,
51
+ nullableInteger: null,
52
+ nullableBoolean: null,
53
+ nullableNull: null,
54
+ nullableArray: null,
55
+ nullableObject: null,
56
+ objectWithNullableProps: {
57
+ additionalProp: null,
58
+ nullableString: null,
59
+ nullableNumber: null,
60
+ nullableInteger: null,
61
+ nullableBoolean: null,
62
+ nullableNull: null,
63
+ nullableArray: null
64
+ },
65
+ arrayWithNullableItems: [1, 2, null]
66
+ }
67
+
68
+ const complexExpectedResult = {
69
+ nullableString: null,
70
+ nullableNumber: null,
71
+ nullableInteger: null,
72
+ nullableBoolean: null,
73
+ nullableNull: null,
74
+ nullableArray: null,
75
+ nullableObject: null,
76
+ objectWithNullableProps: {
77
+ additionalProp: null,
78
+ nullableString: null,
79
+ nullableNumber: null,
80
+ nullableInteger: null,
81
+ nullableBoolean: null,
82
+ nullableNull: null,
83
+ nullableArray: null
84
+ },
85
+ arrayWithNullableItems: [1, 2, null]
86
+ }
87
+
88
+ const testSet = {
89
+ nullableString: [{ type: 'string', nullable }, null, null],
90
+ nullableNumber: [{ type: 'number', nullable }, null, null],
91
+ nullableInteger: [{ type: 'integer', nullable }, null, null],
92
+ nullableBoolean: [{ type: 'boolean', nullable }, null, null],
93
+ nullableNull: [{ type: 'null', nullable }, null, null],
94
+ nullableArray: [{
95
+ type: 'array',
96
+ nullable: true,
97
+ items: {}
98
+ }, null, null],
99
+ nullableObject: [{ type: 'object', nullable: true }, null, null],
100
+ complexObject: [complexObject, complexData, complexExpectedResult, { ajv: { allowUnionTypes: true } }]
101
+ }
102
+
103
+ Object.keys(testSet).forEach(key => {
104
+ test(`handle nullable:true in ${key} correctly`, (t) => {
105
+ t.plan(1)
106
+
107
+ const [
108
+ schema,
109
+ data,
110
+ expected,
111
+ extraOptions
112
+ ] = testSet[key]
113
+
114
+ const stringifier = build(schema, extraOptions)
115
+ const result = stringifier(data)
116
+ t.assert.deepStrictEqual(JSON.parse(result), expected)
117
+ })
118
+ })
119
+
120
+ test('handle nullable number correctly', (t) => {
121
+ t.plan(2)
122
+
123
+ const schema = {
124
+ type: 'number',
125
+ nullable: true
126
+ }
127
+ const stringify = build(schema)
128
+
129
+ const data = null
130
+ const result = stringify(data)
131
+
132
+ t.assert.equal(result, JSON.stringify(data))
133
+ t.assert.equal(JSON.parse(result), data)
134
+ })
135
+
136
+ test('handle nullable integer correctly', (t) => {
137
+ t.plan(2)
138
+
139
+ const schema = {
140
+ type: 'integer',
141
+ nullable: true
142
+ }
143
+ const stringify = build(schema)
144
+
145
+ const data = null
146
+ const result = stringify(data)
147
+
148
+ t.assert.equal(result, JSON.stringify(data))
149
+ t.assert.equal(JSON.parse(result), data)
150
+ })
151
+
152
+ test('handle nullable boolean correctly', (t) => {
153
+ t.plan(2)
154
+
155
+ const schema = {
156
+ type: 'boolean',
157
+ nullable: true
158
+ }
159
+ const stringify = build(schema)
160
+
161
+ const data = null
162
+ const result = stringify(data)
163
+
164
+ t.assert.equal(result, JSON.stringify(data))
165
+ t.assert.equal(JSON.parse(result), data)
166
+ })
167
+
168
+ test('handle nullable string correctly', (t) => {
169
+ t.plan(2)
170
+
171
+ const schema = {
172
+ type: 'string',
173
+ nullable: true
174
+ }
175
+ const stringify = build(schema)
176
+
177
+ const data = null
178
+ const result = stringify(data)
179
+
180
+ t.assert.equal(result, JSON.stringify(data))
181
+ t.assert.equal(JSON.parse(result), data)
182
+ })
183
+
184
+ test('handle nullable date-time correctly', (t) => {
185
+ t.plan(2)
186
+
187
+ const schema = {
188
+ type: 'string',
189
+ format: 'date-time',
190
+ nullable: true
191
+ }
192
+ const stringify = build(schema)
193
+
194
+ const data = null
195
+ const result = stringify(data)
196
+
197
+ t.assert.equal(result, JSON.stringify(data))
198
+ t.assert.equal(JSON.parse(result), data)
199
+ })
200
+
201
+ test('handle nullable date correctly', (t) => {
202
+ t.plan(2)
203
+
204
+ const schema = {
205
+ type: 'string',
206
+ format: 'date',
207
+ nullable: true
208
+ }
209
+ const stringify = build(schema)
210
+
211
+ const data = null
212
+ const result = stringify(data)
213
+
214
+ t.assert.equal(result, JSON.stringify(data))
215
+ t.assert.equal(JSON.parse(result), data)
216
+ })
217
+
218
+ test('handle nullable time correctly', (t) => {
219
+ t.plan(2)
220
+
221
+ const schema = {
222
+ type: 'string',
223
+ format: 'time',
224
+ nullable: true
225
+ }
226
+ const stringify = build(schema)
227
+
228
+ const data = null
229
+ const result = stringify(data)
230
+
231
+ t.assert.equal(result, JSON.stringify(data))
232
+ t.assert.equal(JSON.parse(result), data)
233
+ })
234
+
235
+ test('large array of nullable strings with default mechanism', (t) => {
236
+ t.plan(2)
237
+
238
+ const schema = {
239
+ type: 'object',
240
+ properties: {
241
+ ids: {
242
+ type: 'array',
243
+ items: {
244
+ type: 'string',
245
+ nullable: true
246
+ }
247
+ }
248
+ }
249
+ }
250
+
251
+ const options = {
252
+ largeArraySize: 2e4,
253
+ largeArrayMechanism: 'default'
254
+ }
255
+
256
+ const stringify = build(schema, options)
257
+
258
+ const data = { ids: new Array(2e4).fill(null) }
259
+ const result = stringify(data)
260
+
261
+ t.assert.equal(result, JSON.stringify(data))
262
+ t.assert.deepStrictEqual(JSON.parse(result), data)
263
+ })
264
+
265
+ test('large array of nullable date-time strings with default mechanism', (t) => {
266
+ t.plan(2)
267
+
268
+ const schema = {
269
+ type: 'object',
270
+ properties: {
271
+ ids: {
272
+ type: 'array',
273
+ items: {
274
+ type: 'string',
275
+ format: 'date-time',
276
+ nullable: true
277
+ }
278
+ }
279
+ }
280
+ }
281
+
282
+ const options = {
283
+ largeArraySize: 2e4,
284
+ largeArrayMechanism: 'default'
285
+ }
286
+
287
+ const stringify = build(schema, options)
288
+
289
+ const data = { ids: new Array(2e4).fill(null) }
290
+ const result = stringify(data)
291
+
292
+ t.assert.equal(result, JSON.stringify(data))
293
+ t.assert.deepStrictEqual(JSON.parse(result), data)
294
+ })
295
+
296
+ test('large array of nullable date-time strings with default mechanism', (t) => {
297
+ t.plan(2)
298
+
299
+ const schema = {
300
+ type: 'object',
301
+ properties: {
302
+ ids: {
303
+ type: 'array',
304
+ items: {
305
+ type: 'string',
306
+ format: 'date',
307
+ nullable: true
308
+ }
309
+ }
310
+ }
311
+ }
312
+
313
+ const options = {
314
+ largeArraySize: 2e4,
315
+ largeArrayMechanism: 'default'
316
+ }
317
+
318
+ const stringify = build(schema, options)
319
+
320
+ const data = { ids: new Array(2e4).fill(null) }
321
+ const result = stringify(data)
322
+
323
+ t.assert.equal(result, JSON.stringify(data))
324
+ t.assert.deepStrictEqual(JSON.parse(result), data)
325
+ })
326
+
327
+ test('large array of nullable date-time strings with default mechanism', (t) => {
328
+ t.plan(2)
329
+
330
+ const schema = {
331
+ type: 'object',
332
+ properties: {
333
+ ids: {
334
+ type: 'array',
335
+ items: {
336
+ type: 'string',
337
+ format: 'time',
338
+ nullable: true
339
+ }
340
+ }
341
+ }
342
+ }
343
+
344
+ const options = {
345
+ largeArraySize: 2e4,
346
+ largeArrayMechanism: 'default'
347
+ }
348
+
349
+ const stringify = build(schema, options)
350
+
351
+ const data = { ids: new Array(2e4).fill(null) }
352
+ const result = stringify(data)
353
+
354
+ t.assert.equal(result, JSON.stringify(data))
355
+ t.assert.deepStrictEqual(JSON.parse(result), data)
356
+ })
357
+
358
+ test('large array of nullable numbers with default mechanism', (t) => {
359
+ t.plan(2)
360
+
361
+ const schema = {
362
+ type: 'object',
363
+ properties: {
364
+ ids: {
365
+ type: 'array',
366
+ items: {
367
+ type: 'number',
368
+ nullable: true
369
+ }
370
+ }
371
+ }
372
+ }
373
+
374
+ const options = {
375
+ largeArraySize: 2e4,
376
+ largeArrayMechanism: 'default'
377
+ }
378
+
379
+ const stringify = build(schema, options)
380
+
381
+ const data = { ids: new Array(2e4).fill(null) }
382
+ const result = stringify(data)
383
+
384
+ t.assert.equal(result, JSON.stringify(data))
385
+ t.assert.deepStrictEqual(JSON.parse(result), data)
386
+ })
387
+
388
+ test('large array of nullable integers with default mechanism', (t) => {
389
+ t.plan(2)
390
+
391
+ const schema = {
392
+ type: 'object',
393
+ properties: {
394
+ ids: {
395
+ type: 'array',
396
+ items: {
397
+ type: 'integer',
398
+ nullable: true
399
+ }
400
+ }
401
+ }
402
+ }
403
+
404
+ const options = {
405
+ largeArraySize: 2e4,
406
+ largeArrayMechanism: 'default'
407
+ }
408
+
409
+ const stringify = build(schema, options)
410
+
411
+ const data = { ids: new Array(2e4).fill(null) }
412
+ const result = stringify(data)
413
+
414
+ t.assert.equal(result, JSON.stringify(data))
415
+ t.assert.deepStrictEqual(JSON.parse(result), data)
416
+ })
417
+
418
+ test('large array of nullable booleans with default mechanism', (t) => {
419
+ t.plan(2)
420
+
421
+ const schema = {
422
+ type: 'object',
423
+ properties: {
424
+ ids: {
425
+ type: 'array',
426
+ items: {
427
+ type: 'boolean',
428
+ nullable: true
429
+ }
430
+ }
431
+ }
432
+ }
433
+
434
+ const options = {
435
+ largeArraySize: 2e4,
436
+ largeArrayMechanism: 'default'
437
+ }
438
+
439
+ const stringify = build(schema, options)
440
+
441
+ const data = { ids: new Array(2e4).fill(null) }
442
+ const result = stringify(data)
443
+
444
+ t.assert.equal(result, JSON.stringify(data))
445
+ t.assert.deepStrictEqual(JSON.parse(result), data)
446
+ })
447
+
448
+ test('nullable type in the schema', (t) => {
449
+ t.plan(2)
450
+
451
+ const schema = {
452
+ type: ['object', 'null'],
453
+ properties: {
454
+ foo: {
455
+ type: 'string'
456
+ }
457
+ }
458
+ }
459
+
460
+ const stringify = build(schema)
461
+
462
+ const data = { foo: 'bar' }
463
+
464
+ t.assert.equal(stringify(data), JSON.stringify(data))
465
+ t.assert.equal(stringify(null), JSON.stringify(null))
466
+ })
467
+
468
+ test('throw an error if the value doesn\'t match the type', (t) => {
469
+ t.plan(2)
470
+
471
+ const schema = {
472
+ type: 'object',
473
+ additionalProperties: false,
474
+ required: ['data'],
475
+ properties: {
476
+ data: {
477
+ type: 'array',
478
+ minItems: 1,
479
+ items: {
480
+ oneOf: [
481
+ {
482
+ type: 'string'
483
+ },
484
+ {
485
+ type: 'number'
486
+ }
487
+ ]
488
+ }
489
+ }
490
+ }
491
+ }
492
+
493
+ const stringify = build(schema)
494
+
495
+ const validData = { data: [1, 'testing'] }
496
+ t.assert.equal(stringify(validData), JSON.stringify(validData))
497
+
498
+ const invalidData = { data: [false, 'testing'] }
499
+ t.assert.throws(() => stringify(invalidData))
500
+ })
501
+
502
+ test('nullable value in oneOf', (t) => {
503
+ t.plan(1)
504
+
505
+ const schema = {
506
+ type: 'object',
507
+ properties: {
508
+ data: {
509
+ oneOf: [
510
+ {
511
+ type: 'array',
512
+ items: {
513
+ type: 'object',
514
+ properties: {
515
+ id: { type: 'integer', minimum: 1 }
516
+ },
517
+ additionalProperties: false,
518
+ required: ['id']
519
+ }
520
+ },
521
+ {
522
+ type: 'array',
523
+ items: {
524
+ type: 'object',
525
+ properties: {
526
+ job: { type: 'string', nullable: true }
527
+ },
528
+ additionalProperties: false,
529
+ required: ['job']
530
+ }
531
+ }
532
+ ]
533
+ }
534
+ },
535
+ required: ['data'],
536
+ additionalProperties: false
537
+ }
538
+
539
+ const stringify = build(schema)
540
+
541
+ const data = { data: [{ job: null }] }
542
+ t.assert.equal(stringify(data), JSON.stringify(data))
543
+ })