@zuplo/cli 6.71.23 → 6.71.25

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-MJWTZPC2.js} +90 -90
  103. package/node_modules/@zuplo/runtime/out/esm/chunk-MJWTZPC2.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 +154 -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-MJWTZPC2.js.LEGAL.txt} +0 -0
@@ -0,0 +1,391 @@
1
+ 'use strict'
2
+
3
+ const path = require('path')
4
+ const { Worker } = require('worker_threads')
5
+
6
+ const BENCH_THREAD_PATH = path.join(__dirname, 'bench-thread.js')
7
+
8
+ const LONG_STRING_LENGTH = 1e4
9
+ const SHORT_ARRAY_SIZE = 1e3
10
+
11
+ const shortArrayOfNumbers = new Array(SHORT_ARRAY_SIZE)
12
+ const shortArrayOfIntegers = new Array(SHORT_ARRAY_SIZE)
13
+ const shortArrayOfShortStrings = new Array(SHORT_ARRAY_SIZE)
14
+ const shortArrayOfLongStrings = new Array(SHORT_ARRAY_SIZE)
15
+ const shortArrayOfMultiObject = new Array(SHORT_ARRAY_SIZE)
16
+
17
+ function getRandomInt (max) {
18
+ return Math.floor(Math.random() * max)
19
+ }
20
+
21
+ let longSimpleString = ''
22
+ for (let i = 0; i < LONG_STRING_LENGTH; i++) {
23
+ longSimpleString += i
24
+ }
25
+
26
+ let longString = ''
27
+ for (let i = 0; i < LONG_STRING_LENGTH; i++) {
28
+ longString += i
29
+ if (i % 100 === 0) {
30
+ longString += '"'
31
+ }
32
+ }
33
+
34
+ for (let i = 0; i < SHORT_ARRAY_SIZE; i++) {
35
+ shortArrayOfNumbers[i] = getRandomInt(1000)
36
+ shortArrayOfIntegers[i] = getRandomInt(1000)
37
+ shortArrayOfShortStrings[i] = 'hello world'
38
+ shortArrayOfLongStrings[i] = longString
39
+ shortArrayOfMultiObject[i] = { s: 'hello world', n: 42, b: true }
40
+ }
41
+
42
+ const benchmarks = [
43
+ {
44
+ name: 'short string',
45
+ schema: {
46
+ type: 'string'
47
+ },
48
+ input: 'hello world'
49
+ },
50
+ {
51
+ name: 'unsafe short string',
52
+ schema: {
53
+ type: 'string',
54
+ format: 'unsafe'
55
+ },
56
+ input: 'hello world'
57
+ },
58
+ {
59
+ name: 'short string with double quote',
60
+ schema: {
61
+ type: 'string'
62
+ },
63
+ input: 'hello " world'
64
+ },
65
+ {
66
+ name: 'long string without double quotes',
67
+ schema: {
68
+ type: 'string'
69
+ },
70
+ input: longSimpleString
71
+ },
72
+ {
73
+ name: 'unsafe long string without double quotes',
74
+ schema: {
75
+ type: 'string',
76
+ format: 'unsafe'
77
+ },
78
+ input: longSimpleString
79
+ },
80
+ {
81
+ name: 'long string',
82
+ schema: {
83
+ type: 'string'
84
+ },
85
+ input: longString
86
+ },
87
+ {
88
+ name: 'unsafe long string',
89
+ schema: {
90
+ type: 'string',
91
+ format: 'unsafe'
92
+ },
93
+ input: longString
94
+ },
95
+ {
96
+ name: 'number',
97
+ schema: {
98
+ type: 'number'
99
+ },
100
+ input: 42
101
+ },
102
+ {
103
+ name: 'integer',
104
+ schema: {
105
+ type: 'integer'
106
+ },
107
+ input: 42
108
+ },
109
+ {
110
+ name: 'formatted date-time',
111
+ schema: {
112
+ type: 'string',
113
+ format: 'date-time'
114
+ },
115
+ input: new Date()
116
+ },
117
+ {
118
+ name: 'formatted date',
119
+ schema: {
120
+ type: 'string',
121
+ format: 'date'
122
+ },
123
+ input: new Date()
124
+ },
125
+ {
126
+ name: 'formatted time',
127
+ schema: {
128
+ type: 'string',
129
+ format: 'time'
130
+ },
131
+ input: new Date()
132
+ },
133
+ {
134
+ name: 'short array of numbers',
135
+ schema: {
136
+ type: 'array',
137
+ items: { type: 'number' }
138
+ },
139
+ input: shortArrayOfNumbers
140
+ },
141
+ {
142
+ name: 'short array of integers',
143
+ schema: {
144
+ type: 'array',
145
+ items: { type: 'integer' }
146
+ },
147
+ input: shortArrayOfIntegers
148
+ },
149
+ {
150
+ name: 'short array of short strings',
151
+ schema: {
152
+ type: 'array',
153
+ items: { type: 'string' }
154
+ },
155
+ input: shortArrayOfShortStrings
156
+ },
157
+ {
158
+ name: 'short array of long strings',
159
+ schema: {
160
+ type: 'array',
161
+ items: { type: 'string' }
162
+ },
163
+ input: shortArrayOfShortStrings
164
+ },
165
+ {
166
+ name: 'short array of objects with properties of different types',
167
+ schema: {
168
+ type: 'array',
169
+ items: {
170
+ type: 'object',
171
+ properties: {
172
+ s: { type: 'string' },
173
+ n: { type: 'number' },
174
+ b: { type: 'boolean' }
175
+ }
176
+ }
177
+ },
178
+ input: shortArrayOfMultiObject
179
+ },
180
+ {
181
+ name: 'object with number property',
182
+ schema: {
183
+ type: 'object',
184
+ properties: {
185
+ a: { type: 'number' }
186
+ }
187
+ },
188
+ input: { a: 42 }
189
+ },
190
+ {
191
+ name: 'object with integer property',
192
+ schema: {
193
+ type: 'object',
194
+ properties: {
195
+ a: { type: 'integer' }
196
+ }
197
+ },
198
+ input: { a: 42 }
199
+ },
200
+ {
201
+ name: 'object with short string property',
202
+ schema: {
203
+ type: 'object',
204
+ properties: {
205
+ a: { type: 'string' }
206
+ }
207
+ },
208
+ input: { a: 'hello world' }
209
+ },
210
+ {
211
+ name: 'object with long string property',
212
+ schema: {
213
+ type: 'object',
214
+ properties: {
215
+ a: { type: 'string' }
216
+ }
217
+ },
218
+ input: { a: longString }
219
+ },
220
+ {
221
+ name: 'object with properties of different types',
222
+ schema: {
223
+ type: 'object',
224
+ properties: {
225
+ s1: { type: 'string' },
226
+ n1: { type: 'number' },
227
+ b1: { type: 'boolean' },
228
+ s2: { type: 'string' },
229
+ n2: { type: 'number' },
230
+ b2: { type: 'boolean' },
231
+ s3: { type: 'string' },
232
+ n3: { type: 'number' },
233
+ b3: { type: 'boolean' },
234
+ s4: { type: 'string' },
235
+ n4: { type: 'number' },
236
+ b4: { type: 'boolean' },
237
+ s5: { type: 'string' },
238
+ n5: { type: 'number' },
239
+ b5: { type: 'boolean' }
240
+ }
241
+ },
242
+ input: {
243
+ s1: 'hello world',
244
+ n1: 42,
245
+ b1: true,
246
+ s2: 'hello world',
247
+ n2: 42,
248
+ b2: true,
249
+ s3: 'hello world',
250
+ n3: 42,
251
+ b3: true,
252
+ s4: 'hello world',
253
+ n4: 42,
254
+ b4: true,
255
+ s5: 'hello world',
256
+ n5: 42,
257
+ b5: true
258
+ }
259
+ },
260
+ {
261
+ name: 'simple object',
262
+ schema: {
263
+ title: 'Example Schema',
264
+ type: 'object',
265
+ properties: {
266
+ firstName: {
267
+ type: 'string'
268
+ },
269
+ lastName: {
270
+ type: ['string', 'null']
271
+ },
272
+ age: {
273
+ description: 'Age in years',
274
+ type: 'integer',
275
+ minimum: 0
276
+ }
277
+ }
278
+ },
279
+ input: { firstName: 'Max', lastName: 'Power', age: 22 }
280
+ },
281
+ {
282
+ name: 'simple object with required fields',
283
+ schema: {
284
+ title: 'Example Schema',
285
+ type: 'object',
286
+ properties: {
287
+ firstName: {
288
+ type: 'string'
289
+ },
290
+ lastName: {
291
+ type: ['string', 'null']
292
+ },
293
+ age: {
294
+ description: 'Age in years',
295
+ type: 'integer',
296
+ minimum: 0
297
+ }
298
+ },
299
+ required: ['firstName', 'lastName', 'age']
300
+ },
301
+ input: { firstName: 'Max', lastName: 'Power', age: 22 }
302
+ },
303
+ {
304
+ name: 'object with const string property',
305
+ schema: {
306
+ type: 'object',
307
+ properties: {
308
+ a: { const: 'const string' }
309
+ }
310
+ },
311
+ input: { a: 'const string' }
312
+ },
313
+ {
314
+ name: 'object with const number property',
315
+ schema: {
316
+ type: 'object',
317
+ properties: {
318
+ a: { const: 1 }
319
+ }
320
+ },
321
+ input: { a: 1 }
322
+ },
323
+ {
324
+ name: 'object with const bool property',
325
+ schema: {
326
+ type: 'object',
327
+ properties: {
328
+ a: { const: true }
329
+ }
330
+ },
331
+ input: { a: true }
332
+ },
333
+ {
334
+ name: 'object with const object property',
335
+ schema: {
336
+ type: 'object',
337
+ properties: {
338
+ foo: { const: { bar: 'baz' } }
339
+ }
340
+ },
341
+ input: {
342
+ foo: { bar: 'baz' }
343
+ }
344
+ },
345
+ {
346
+ name: 'object with const null property',
347
+ schema: {
348
+ type: 'object',
349
+ properties: {
350
+ foo: { const: null }
351
+ }
352
+ },
353
+ input: {
354
+ foo: null
355
+ }
356
+ }
357
+ ]
358
+
359
+ async function runBenchmark (benchmark) {
360
+ const worker = new Worker(BENCH_THREAD_PATH, { workerData: benchmark })
361
+
362
+ return new Promise((resolve, reject) => {
363
+ let result = null
364
+ worker.on('error', reject)
365
+ worker.on('message', (benchResult) => {
366
+ result = benchResult
367
+ })
368
+ worker.on('exit', (code) => {
369
+ if (code === 0) {
370
+ resolve(result)
371
+ } else {
372
+ reject(new Error(`Worker stopped with exit code ${code}`))
373
+ }
374
+ })
375
+ })
376
+ }
377
+
378
+ async function runBenchmarks () {
379
+ let maxNameLength = 0
380
+ for (const benchmark of benchmarks) {
381
+ maxNameLength = Math.max(benchmark.name.length, maxNameLength)
382
+ }
383
+
384
+ for (const benchmark of benchmarks) {
385
+ benchmark.name = benchmark.name.padEnd(maxNameLength, '.')
386
+ const resultMessage = await runBenchmark(benchmark)
387
+ console.log(resultMessage)
388
+ }
389
+ }
390
+
391
+ runBenchmarks()
@@ -0,0 +1,26 @@
1
+ 'use strict'
2
+
3
+ const Ajv = require('ajv')
4
+ const standaloneCode = require('ajv/dist/standalone').default
5
+ const ajvFormats = require('ajv-formats')
6
+ const fs = require('fs')
7
+ const path = require('path')
8
+
9
+ const ajv = new Ajv({
10
+ addUsedSchema: false,
11
+ allowUnionTypes: true,
12
+ code: {
13
+ source: true,
14
+ lines: true,
15
+ optimize: 3
16
+ }
17
+ })
18
+ ajvFormats(ajv)
19
+
20
+ const schema = require('ajv/lib/refs/json-schema-draft-07.json')
21
+ const validate = ajv.compile(schema)
22
+ const validationCode = standaloneCode(ajv, validate)
23
+
24
+ const moduleCode = `/* CODE GENERATED BY '${path.basename(__filename)}' DO NOT EDIT! */\n${validationCode}`
25
+
26
+ fs.writeFileSync(path.join(__dirname, '../lib/schema-validator.js'), moduleCode)
@@ -0,0 +1,9 @@
1
+ 'use strict'
2
+
3
+ module.exports = require('neostandard')({
4
+ ignores: [
5
+ ...require('neostandard').resolveIgnoresFromGitignore(),
6
+ 'lib/schema-validator.js'
7
+ ],
8
+ ts: true
9
+ })
@@ -0,0 +1,81 @@
1
+ 'use strict'
2
+
3
+ const fastJson = require('..')
4
+ const stringify = fastJson({
5
+ title: 'Example Schema',
6
+ type: 'object',
7
+ properties: {
8
+ firstName: {
9
+ type: 'string'
10
+ },
11
+ lastName: {
12
+ type: 'string'
13
+ },
14
+ age: {
15
+ description: 'Age in years',
16
+ type: 'integer'
17
+ },
18
+ now: {
19
+ type: 'string'
20
+ },
21
+ birthdate: {
22
+ type: ['string'],
23
+ format: 'date-time'
24
+ },
25
+ reg: {
26
+ type: 'string'
27
+ },
28
+ obj: {
29
+ type: 'object',
30
+ properties: {
31
+ bool: {
32
+ type: 'boolean'
33
+ }
34
+ }
35
+ },
36
+ arr: {
37
+ type: 'array',
38
+ items: {
39
+ type: 'object',
40
+ properties: {
41
+ str: {
42
+ type: 'string'
43
+ }
44
+ }
45
+ }
46
+ }
47
+ },
48
+ required: ['now'],
49
+ patternProperties: {
50
+ '.*foo$': {
51
+ type: 'string'
52
+ },
53
+ test: {
54
+ type: 'number'
55
+ },
56
+ date: {
57
+ type: 'string',
58
+ format: 'date-time'
59
+ }
60
+ },
61
+ additionalProperties: {
62
+ type: 'string'
63
+ }
64
+ })
65
+
66
+ console.log(stringify({
67
+ firstName: 'Matteo',
68
+ lastName: 'Collina',
69
+ age: 32,
70
+ now: new Date(),
71
+ reg: /"([^"]|\\")*"/,
72
+ foo: 'hello',
73
+ numfoo: 42,
74
+ test: 42,
75
+ strtest: '23',
76
+ arr: [{ str: 'stark' }, { str: 'lannister' }],
77
+ obj: { bool: true },
78
+ notmatch: 'valar morghulis',
79
+ notmatchobj: { a: true },
80
+ notmatchnum: 42
81
+ }))
@@ -0,0 +1,42 @@
1
+ 'use strict'
2
+
3
+ const http = require('http')
4
+
5
+ const stringify = require('fast-json-stringify')({
6
+ type: 'object',
7
+ properties: {
8
+ hello: {
9
+ type: 'string'
10
+ },
11
+ data: {
12
+ type: 'number'
13
+ },
14
+ nested: {
15
+ type: 'object',
16
+ properties: {
17
+ more: {
18
+ type: 'string'
19
+ }
20
+ }
21
+ }
22
+ }
23
+ })
24
+
25
+ const server = http.createServer(handle)
26
+
27
+ function handle (req, res) {
28
+ const data = {
29
+ hello: 'world',
30
+ data: 42,
31
+ nested: {
32
+ more: 'data'
33
+ }
34
+ }
35
+ if (req.url === '/JSON') {
36
+ res.end(JSON.stringify(data))
37
+ } else {
38
+ res.end(stringify(data))
39
+ }
40
+ }
41
+
42
+ server.listen(3000)