@zuplo/cli 6.71.22 → 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 (203) 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/@posthog/core/dist/posthog-core-stateless.d.ts +5 -0
  95. package/node_modules/@posthog/core/dist/posthog-core-stateless.d.ts.map +1 -1
  96. package/node_modules/@posthog/core/dist/posthog-core-stateless.js +50 -10
  97. package/node_modules/@posthog/core/dist/posthog-core-stateless.mjs +47 -10
  98. package/node_modules/@posthog/core/dist/posthog-core.d.ts +2 -2
  99. package/node_modules/@posthog/core/dist/posthog-core.d.ts.map +1 -1
  100. package/node_modules/@posthog/core/dist/posthog-core.js +10 -6
  101. package/node_modules/@posthog/core/dist/posthog-core.mjs +11 -7
  102. package/node_modules/@posthog/core/dist/testing/PostHogCoreTestClient.d.ts +1 -0
  103. package/node_modules/@posthog/core/dist/testing/PostHogCoreTestClient.d.ts.map +1 -1
  104. package/node_modules/@posthog/core/dist/testing/PostHogCoreTestClient.js +3 -0
  105. package/node_modules/@posthog/core/dist/testing/PostHogCoreTestClient.mjs +3 -0
  106. package/node_modules/@posthog/core/dist/utils/promise-queue.d.ts +3 -0
  107. package/node_modules/@posthog/core/dist/utils/promise-queue.d.ts.map +1 -1
  108. package/node_modules/@posthog/core/dist/utils/promise-queue.js +15 -3
  109. package/node_modules/@posthog/core/dist/utils/promise-queue.mjs +15 -3
  110. package/node_modules/@posthog/core/package.json +1 -1
  111. package/node_modules/@posthog/core/src/posthog-core-stateless.ts +80 -14
  112. package/node_modules/@posthog/core/src/posthog-core.ts +18 -7
  113. package/node_modules/@posthog/core/src/testing/PostHogCoreTestClient.ts +4 -0
  114. package/node_modules/@posthog/core/src/utils/promise-queue.ts +17 -4
  115. package/node_modules/@posthog/types/dist/posthog.d.ts +12 -0
  116. package/node_modules/@posthog/types/dist/posthog.d.ts.map +1 -1
  117. package/node_modules/@posthog/types/package.json +1 -1
  118. package/node_modules/@posthog/types/src/posthog.ts +13 -0
  119. package/node_modules/@protobufjs/utf8/CHANGELOG.md +8 -0
  120. package/node_modules/@protobufjs/utf8/index.js +29 -18
  121. package/node_modules/@protobufjs/utf8/package.json +2 -2
  122. package/node_modules/@protobufjs/utf8/tests/index.js +5 -0
  123. package/node_modules/@types/node/README.md +1 -1
  124. package/node_modules/@types/node/buffer.d.ts +64 -25
  125. package/node_modules/@types/node/crypto.d.ts +18 -5
  126. package/node_modules/@types/node/diagnostics_channel.d.ts +237 -3
  127. package/node_modules/@types/node/dns.d.ts +1 -1
  128. package/node_modules/@types/node/ffi.d.ts +486 -0
  129. package/node_modules/@types/node/fs/promises.d.ts +3 -0
  130. package/node_modules/@types/node/fs.d.ts +21 -6
  131. package/node_modules/@types/node/http.d.ts +25 -0
  132. package/node_modules/@types/node/index.d.ts +1 -0
  133. package/node_modules/@types/node/package.json +2 -2
  134. package/node_modules/@types/node/process.d.ts +14 -1
  135. package/node_modules/@types/node/quic.d.ts +92 -11
  136. package/node_modules/@types/node/sqlite.d.ts +55 -0
  137. package/node_modules/@types/node/stream/iter.d.ts +150 -0
  138. package/node_modules/@types/node/stream.d.ts +32 -0
  139. package/node_modules/@types/node/test.d.ts +112 -2
  140. package/node_modules/@types/node/ts5.6/index.d.ts +1 -0
  141. package/node_modules/@types/node/ts5.7/index.d.ts +1 -0
  142. package/node_modules/@types/node/util.d.ts +19 -2
  143. package/node_modules/@types/node/v8.d.ts +84 -2
  144. package/node_modules/@types/node/worker_threads.d.ts +8 -7
  145. package/node_modules/@zuplo/core/package.json +1 -1
  146. package/node_modules/@zuplo/graphql/out/esm/index.js +11 -11
  147. package/node_modules/@zuplo/graphql/out/esm/index.js.map +1 -1
  148. package/node_modules/@zuplo/graphql/package.json +1 -1
  149. package/node_modules/@zuplo/openapi-tools/package.json +1 -1
  150. package/node_modules/@zuplo/otel/package.json +1 -1
  151. package/node_modules/@zuplo/runtime/out/esm/{chunk-54PA7VDV.js → chunk-4QJJMELB.js} +1 -1
  152. package/node_modules/@zuplo/runtime/out/esm/{chunk-54PA7VDV.js.map → chunk-4QJJMELB.js.map} +1 -1
  153. package/node_modules/@zuplo/runtime/out/esm/chunk-MJWTZPC2.js +402 -0
  154. package/node_modules/@zuplo/runtime/out/esm/chunk-MJWTZPC2.js.map +1 -0
  155. package/node_modules/@zuplo/runtime/out/esm/index.js +1 -1
  156. package/node_modules/@zuplo/runtime/out/esm/index.js.map +1 -1
  157. package/node_modules/@zuplo/runtime/out/esm/mcp-gateway/index.js +7 -7
  158. package/node_modules/@zuplo/runtime/out/esm/mcp-gateway/index.js.map +1 -1
  159. package/node_modules/@zuplo/runtime/out/esm/mocks/index.js +1 -1
  160. package/node_modules/@zuplo/runtime/out/types/index.d.ts +263 -19
  161. package/node_modules/@zuplo/runtime/out/types/mcp-gateway/index.d.ts +33 -7
  162. package/node_modules/@zuplo/runtime/package.json +1 -1
  163. package/node_modules/hono/dist/adapter/aws-lambda/handler.js +1 -1
  164. package/node_modules/hono/dist/adapter/bun/websocket.js +3 -1
  165. package/node_modules/hono/dist/cjs/adapter/aws-lambda/handler.js +1 -1
  166. package/node_modules/hono/dist/cjs/adapter/bun/websocket.js +3 -1
  167. package/node_modules/hono/dist/cjs/middleware/serve-static/index.js +1 -1
  168. package/node_modules/hono/dist/cjs/utils/body.js +12 -4
  169. package/node_modules/hono/dist/cjs/utils/buffer.js +2 -1
  170. package/node_modules/hono/dist/cjs/validator/validator.js +3 -3
  171. package/node_modules/hono/dist/middleware/serve-static/index.js +1 -1
  172. package/node_modules/hono/dist/types/middleware/context-storage/index.d.ts +2 -2
  173. package/node_modules/hono/dist/types/utils/body.d.ts +1 -1
  174. package/node_modules/hono/dist/utils/body.js +12 -4
  175. package/node_modules/hono/dist/utils/buffer.js +2 -1
  176. package/node_modules/hono/dist/validator/validator.js +3 -3
  177. package/node_modules/hono/package.json +8 -7
  178. package/node_modules/iconv-lite/encodings/sbcs-data.js +2 -0
  179. package/node_modules/iconv-lite/encodings/utf32.js +10 -3
  180. package/node_modules/iconv-lite/package.json +2 -2
  181. package/node_modules/iconv-lite/types/encodings.d.ts +2 -0
  182. package/node_modules/protobufjs/dist/light/protobuf.js +2 -2
  183. package/node_modules/protobufjs/dist/light/protobuf.min.js +2 -2
  184. package/node_modules/protobufjs/dist/minimal/protobuf.js +2 -2
  185. package/node_modules/protobufjs/dist/minimal/protobuf.min.js +2 -2
  186. package/node_modules/protobufjs/dist/protobuf.js +5 -2
  187. package/node_modules/protobufjs/dist/protobuf.js.map +1 -1
  188. package/node_modules/protobufjs/dist/protobuf.min.js +3 -3
  189. package/node_modules/protobufjs/dist/protobuf.min.js.map +1 -1
  190. package/node_modules/protobufjs/package.json +1 -1
  191. package/node_modules/protobufjs/src/parse.js +3 -0
  192. package/node_modules/toad-cache/README.md +10 -9
  193. package/node_modules/toad-cache/dist/toad-cache.cjs +139 -139
  194. package/node_modules/toad-cache/dist/toad-cache.mjs +136 -140
  195. package/node_modules/toad-cache/package.json +8 -8
  196. package/node_modules/toad-cache/toad-cache.d.cts +20 -14
  197. package/node_modules/toad-cache/toad-cache.d.ts +18 -14
  198. package/package.json +6 -6
  199. package/node_modules/@fastify/fast-json-stringify-compiler/.eslintrc +0 -1
  200. package/node_modules/@zuplo/runtime/out/esm/chunk-36XLJ4X6.js +0 -389
  201. package/node_modules/@zuplo/runtime/out/esm/chunk-36XLJ4X6.js.map +0 -1
  202. package/node_modules/hono/dist/tsconfig.build.tsbuildinfo +0 -1
  203. /package/node_modules/@zuplo/runtime/out/esm/{chunk-36XLJ4X6.js.LEGAL.txt → chunk-MJWTZPC2.js.LEGAL.txt} +0 -0
@@ -0,0 +1,688 @@
1
+ 'use strict'
2
+
3
+ const { test } = require('node:test')
4
+ const validator = require('is-my-json-valid')
5
+ const build = require('..')
6
+ const Ajv = require('ajv')
7
+
8
+ test('error on invalid largeArrayMechanism', (t) => {
9
+ t.plan(1)
10
+
11
+ t.assert.throws(() => build({
12
+ title: 'large array of null values with default mechanism',
13
+ type: 'object',
14
+ properties: {
15
+ ids: {
16
+ type: 'array',
17
+ items: { type: 'null' }
18
+ }
19
+ }
20
+ }, {
21
+ largeArraySize: 2e4,
22
+ largeArrayMechanism: 'invalid'
23
+ }), Error('Unsupported large array mechanism invalid'))
24
+ })
25
+
26
+ function buildTest (schema, toStringify, options) {
27
+ test(`render a ${schema.title} as JSON`, (t) => {
28
+ t.plan(3)
29
+
30
+ const validate = validator(schema)
31
+ const stringify = build(schema, options)
32
+ const output = stringify(toStringify)
33
+
34
+ t.assert.deepStrictEqual(JSON.parse(output), JSON.parse(JSON.stringify(toStringify)))
35
+ t.assert.equal(output, JSON.stringify(toStringify))
36
+ t.assert.ok(validate(JSON.parse(output)), 'valid schema')
37
+ })
38
+ }
39
+
40
+ buildTest({
41
+ title: 'dates tuple',
42
+ type: 'object',
43
+ properties: {
44
+ dates: {
45
+ type: 'array',
46
+ minItems: 2,
47
+ maxItems: 2,
48
+ items: [
49
+ {
50
+ type: 'string',
51
+ format: 'date-time'
52
+ },
53
+ {
54
+ type: 'string',
55
+ format: 'date-time'
56
+ }
57
+ ]
58
+ }
59
+ }
60
+ }, {
61
+ dates: [new Date(1), new Date(2)]
62
+ })
63
+
64
+ buildTest({
65
+ title: 'dates tuple $ref',
66
+ definitions: {
67
+ dateTime: {
68
+ type: 'string',
69
+ format: 'date-time'
70
+ }
71
+ },
72
+ type: 'object',
73
+ properties: {
74
+ dates: {
75
+ type: 'array',
76
+ minItems: 2,
77
+ maxItems: 2,
78
+ items: [
79
+ {
80
+ $ref: '#/definitions/dateTime'
81
+ },
82
+ {
83
+ $ref: '#/definitions/dateTime'
84
+ }
85
+ ]
86
+ }
87
+ }
88
+ }, {
89
+ dates: [new Date(1), new Date(2)]
90
+ })
91
+
92
+ buildTest({
93
+ title: 'string array',
94
+ type: 'object',
95
+ properties: {
96
+ ids: {
97
+ type: 'array',
98
+ items: {
99
+ type: 'string'
100
+ }
101
+ }
102
+ }
103
+ }, {
104
+ ids: ['test']
105
+ })
106
+
107
+ buildTest({
108
+ title: 'number array',
109
+ type: 'object',
110
+ properties: {
111
+ ids: {
112
+ type: 'array',
113
+ items: {
114
+ type: 'number'
115
+ }
116
+ }
117
+ }
118
+ }, {
119
+ ids: [1]
120
+ })
121
+
122
+ buildTest({
123
+ title: 'mixed array',
124
+ type: 'object',
125
+ properties: {
126
+ ids: {
127
+ type: 'array',
128
+ items: [
129
+ {
130
+ type: 'null'
131
+ },
132
+ {
133
+ type: 'string'
134
+ },
135
+ {
136
+ type: 'integer'
137
+ },
138
+ {
139
+ type: 'number'
140
+ },
141
+ {
142
+ type: 'boolean'
143
+ },
144
+ {
145
+ type: 'object',
146
+ properties: {
147
+ a: {
148
+ type: 'string'
149
+ }
150
+ }
151
+ },
152
+ {
153
+ type: 'array',
154
+ items: {
155
+ type: 'string'
156
+ }
157
+ }
158
+ ]
159
+ }
160
+ }
161
+ }, {
162
+ ids: [null, 'test', 1, 1.1, true, { a: 'test' }, ['test']]
163
+ })
164
+
165
+ buildTest({
166
+ title: 'repeated types',
167
+ type: 'object',
168
+ properties: {
169
+ ids: {
170
+ type: 'array',
171
+ items: [
172
+ {
173
+ type: 'number'
174
+ },
175
+ {
176
+ type: 'number'
177
+ }
178
+ ]
179
+ }
180
+ }
181
+ }, { ids: [1, 2] })
182
+
183
+ buildTest({
184
+ title: 'pattern properties array',
185
+ type: 'object',
186
+ properties: {
187
+ args: {
188
+ type: 'array',
189
+ items: [
190
+ {
191
+ type: 'object',
192
+ patternProperties: {
193
+ '.*': {
194
+ type: 'string'
195
+ }
196
+ }
197
+ },
198
+ {
199
+ type: 'object',
200
+ patternProperties: {
201
+ '.*': {
202
+ type: 'number'
203
+ }
204
+ }
205
+ }
206
+ ]
207
+ }
208
+ }
209
+ }, { args: [{ a: 'test' }, { b: 1 }] })
210
+
211
+ buildTest({
212
+ title: 'array with weird key',
213
+ type: 'object',
214
+ properties: {
215
+ '@data': {
216
+ type: 'array',
217
+ items: {
218
+ type: 'string'
219
+ }
220
+ }
221
+ }
222
+ }, {
223
+ '@data': ['test']
224
+ })
225
+
226
+ test('invalid items throw', (t) => {
227
+ t.plan(1)
228
+ const schema = {
229
+ type: 'object',
230
+ properties: {
231
+ args: {
232
+ type: 'array',
233
+ items: [
234
+ {
235
+ type: 'object',
236
+ patternProperties: {
237
+ '.*': {
238
+ type: 'string'
239
+ }
240
+ }
241
+ }
242
+ ]
243
+ }
244
+ }
245
+ }
246
+ const stringify = build(schema)
247
+ t.assert.throws(() => stringify({ args: ['invalid'] }))
248
+ })
249
+
250
+ buildTest({
251
+ title: 'item types in array default to any',
252
+ type: 'object',
253
+ properties: {
254
+ foo: {
255
+ type: 'array'
256
+ }
257
+ }
258
+ }, {
259
+ foo: [1, 'string', {}, null]
260
+ })
261
+
262
+ test('array items is a list of schema and additionalItems is true, just the described item is validated', (t) => {
263
+ t.plan(1)
264
+
265
+ const schema = {
266
+ type: 'object',
267
+ properties: {
268
+ foo: {
269
+ type: 'array',
270
+ items: [
271
+ {
272
+ type: 'string'
273
+ }
274
+ ],
275
+ additionalItems: true
276
+ }
277
+ }
278
+ }
279
+
280
+ const stringify = build(schema)
281
+ const result = stringify({
282
+ foo: [
283
+ 'foo',
284
+ 'bar',
285
+ 1
286
+ ]
287
+ })
288
+
289
+ t.assert.equal(result, '{"foo":["foo","bar",1]}')
290
+ })
291
+
292
+ test('array items is a list of schema and additionalItems is true, just the described item is validated', (t) => {
293
+ t.plan(1)
294
+
295
+ const schema = {
296
+ type: 'object',
297
+ properties: {
298
+ foo: {
299
+ type: 'array',
300
+ items: [
301
+ {
302
+ type: 'string'
303
+ },
304
+ {
305
+ type: 'number'
306
+ }
307
+ ],
308
+ additionalItems: true
309
+ }
310
+ }
311
+ }
312
+
313
+ const stringify = build(schema)
314
+ const result = stringify({
315
+ foo: ['foo']
316
+ })
317
+
318
+ t.assert.equal(result, '{"foo":["foo"]}')
319
+ })
320
+
321
+ test('array items is a list of schema and additionalItems is false /1', (t) => {
322
+ t.plan(1)
323
+
324
+ const schema = {
325
+ type: 'object',
326
+ properties: {
327
+ foo: {
328
+ type: 'array',
329
+ items: [
330
+ { type: 'string' }
331
+ ],
332
+ additionalItems: false
333
+ }
334
+ }
335
+ }
336
+
337
+ const stringify = build(schema)
338
+ t.assert.throws(() => stringify({ foo: ['foo', 'bar'] }), new Error('Item at 1 does not match schema definition.'))
339
+ })
340
+
341
+ test('array items is a list of schema and additionalItems is false /2', (t) => {
342
+ t.plan(3)
343
+
344
+ const schema = {
345
+ type: 'object',
346
+ properties: {
347
+ foo: {
348
+ type: 'array',
349
+ items: [
350
+ { type: 'string' },
351
+ { type: 'string' }
352
+ ],
353
+ additionalItems: false
354
+ }
355
+ }
356
+ }
357
+
358
+ const stringify = build(schema)
359
+
360
+ t.assert.throws(() => stringify({ foo: [1, 'bar'] }), new Error('Item at 0 does not match schema definition.'))
361
+ t.assert.throws(() => stringify({ foo: ['foo', 1] }), new Error('Item at 1 does not match schema definition.'))
362
+ t.assert.throws(() => stringify({ foo: ['foo', 'bar', 'baz'] }), new Error('Item at 2 does not match schema definition.'))
363
+ })
364
+
365
+ test('array items is a schema and additionalItems is false', (t) => {
366
+ t.plan(2)
367
+
368
+ const schema = {
369
+ type: 'object',
370
+ properties: {
371
+ foo: {
372
+ type: 'array',
373
+ items: { type: 'string' },
374
+ additionalItems: false
375
+ }
376
+ }
377
+ }
378
+
379
+ const stringify = build(schema)
380
+
381
+ // ajv ignores additionalItems if items is not an Array
382
+ const ajv = new Ajv({ allErrors: true, strict: false })
383
+
384
+ const validate = ajv.compile(schema)
385
+ t.assert.equal(stringify({ foo: ['foo', 'bar'] }), '{"foo":["foo","bar"]}')
386
+ t.assert.equal(validate({ foo: ['foo', 'bar'] }), true)
387
+ })
388
+
389
+ test('array items is a list of schema and additionalItems is a schema', (t) => {
390
+ t.plan(1)
391
+
392
+ const schema = {
393
+ type: 'object',
394
+ properties: {
395
+ foo: {
396
+ type: 'array',
397
+ items: [
398
+ { type: 'string' }
399
+ ],
400
+ additionalItems: { type: 'number' }
401
+ }
402
+ }
403
+ }
404
+
405
+ const stringify = build(schema)
406
+ const result = stringify({ foo: ['foo', 42] })
407
+
408
+ t.assert.equal(result, '{"foo":["foo",42]}')
409
+ })
410
+
411
+ // https://github.com/fastify/fast-json-stringify/issues/279
412
+ test('object array with anyOf and symbol', (t) => {
413
+ t.plan(1)
414
+ const ArrayKind = Symbol('ArrayKind')
415
+ const ObjectKind = Symbol('LiteralKind')
416
+ const UnionKind = Symbol('UnionKind')
417
+ const LiteralKind = Symbol('LiteralKind')
418
+ const StringKind = Symbol('StringKind')
419
+
420
+ const schema = {
421
+ kind: ArrayKind,
422
+ type: 'array',
423
+ items: {
424
+ kind: ObjectKind,
425
+ type: 'object',
426
+ properties: {
427
+ name: {
428
+ kind: StringKind,
429
+ type: 'string'
430
+ },
431
+ option: {
432
+ kind: UnionKind,
433
+ anyOf: [
434
+ {
435
+ kind: LiteralKind,
436
+ type: 'string',
437
+ enum: ['Foo']
438
+ },
439
+ {
440
+ kind: LiteralKind,
441
+ type: 'string',
442
+ enum: ['Bar']
443
+ }
444
+ ]
445
+ }
446
+ },
447
+ required: ['name', 'option']
448
+ }
449
+ }
450
+ const stringify = build(schema)
451
+ const value = stringify([
452
+ { name: 'name-0', option: 'Foo' },
453
+ { name: 'name-1', option: 'Bar' }
454
+ ])
455
+ t.assert.equal(value, '[{"name":"name-0","option":"Foo"},{"name":"name-1","option":"Bar"}]')
456
+ })
457
+
458
+ test('different arrays with same item schemas', (t) => {
459
+ t.plan(1)
460
+
461
+ const schema = {
462
+ type: 'object',
463
+ properties: {
464
+ array1: {
465
+ type: 'array',
466
+ items: [{ type: 'string' }],
467
+ additionalItems: false
468
+ },
469
+ array2: {
470
+ type: 'array',
471
+ items: { $ref: '#/properties/array1/items' },
472
+ additionalItems: true
473
+ }
474
+ }
475
+ }
476
+
477
+ const stringify = build(schema)
478
+ const data = { array1: ['bar'], array2: ['foo', 'bar'] }
479
+
480
+ t.assert.equal(stringify(data), '{"array1":["bar"],"array2":["foo","bar"]}')
481
+ })
482
+
483
+ const largeArray = new Array(2e4).fill({ a: 'test', b: 1 })
484
+ buildTest({
485
+ title: 'large array with default mechanism',
486
+ type: 'object',
487
+ properties: {
488
+ ids: {
489
+ type: 'array',
490
+ items: {
491
+ type: 'object',
492
+ properties: {
493
+ a: { type: 'string' },
494
+ b: { type: 'number' }
495
+ }
496
+ }
497
+ }
498
+ }
499
+ }, {
500
+ ids: largeArray
501
+ }, {
502
+ largeArraySize: 2e4,
503
+ largeArrayMechanism: 'default'
504
+ })
505
+
506
+ buildTest({
507
+ title: 'large array of objects with json-stringify mechanism',
508
+ type: 'object',
509
+ properties: {
510
+ ids: {
511
+ type: 'array',
512
+ items: {
513
+ type: 'object',
514
+ properties: {
515
+ a: { type: 'string' },
516
+ b: { type: 'number' }
517
+ }
518
+ }
519
+ }
520
+ }
521
+ }, {
522
+ ids: largeArray
523
+ }, {
524
+ largeArrayMechanism: 'json-stringify'
525
+ })
526
+
527
+ buildTest({
528
+ title: 'large array of strings with default mechanism',
529
+ type: 'object',
530
+ properties: {
531
+ ids: {
532
+ type: 'array',
533
+ items: { type: 'string' }
534
+ }
535
+ }
536
+ }, {
537
+ ids: new Array(2e4).fill('string')
538
+ }, {
539
+ largeArraySize: 2e4,
540
+ largeArrayMechanism: 'default'
541
+ })
542
+
543
+ buildTest({
544
+ title: 'large array of numbers with default mechanism',
545
+ type: 'object',
546
+ properties: {
547
+ ids: {
548
+ type: 'array',
549
+ items: { type: 'number' }
550
+ }
551
+ }
552
+ }, {
553
+ ids: new Array(2e4).fill(42)
554
+ }, {
555
+ largeArraySize: 2e4,
556
+ largeArrayMechanism: 'default'
557
+ })
558
+
559
+ buildTest({
560
+ title: 'large array of integers with default mechanism',
561
+ type: 'object',
562
+ properties: {
563
+ ids: {
564
+ type: 'array',
565
+ items: { type: 'integer' }
566
+ }
567
+ }
568
+ }, {
569
+ ids: new Array(2e4).fill(42)
570
+ }, {
571
+ largeArraySize: 2e4,
572
+ largeArrayMechanism: 'default'
573
+ })
574
+
575
+ buildTest({
576
+ title: 'large array of booleans with default mechanism',
577
+ type: 'object',
578
+ properties: {
579
+ ids: {
580
+ type: 'array',
581
+ items: { type: 'boolean' }
582
+ }
583
+ }
584
+ }, {
585
+ ids: new Array(2e4).fill(true)
586
+ }, {
587
+ largeArraySize: 2e4,
588
+ largeArrayMechanism: 'default'
589
+ })
590
+
591
+ buildTest({
592
+ title: 'large array of null values with default mechanism',
593
+ type: 'object',
594
+ properties: {
595
+ ids: {
596
+ type: 'array',
597
+ items: { type: 'null' }
598
+ }
599
+ }
600
+ }, {
601
+ ids: new Array(2e4).fill(null)
602
+ }, {
603
+ largeArraySize: 2e4,
604
+ largeArrayMechanism: 'default'
605
+ })
606
+
607
+ test('error on invalid value for largeArraySize /1', (t) => {
608
+ t.plan(1)
609
+
610
+ t.assert.throws(() => build({
611
+ title: 'large array of null values with default mechanism',
612
+ type: 'object',
613
+ properties: {
614
+ ids: {
615
+ type: 'array',
616
+ items: { type: 'null' }
617
+ }
618
+ }
619
+ }, {
620
+ largeArraySize: 'invalid'
621
+ }), Error('Unsupported large array size. Expected integer-like, got string with value invalid'))
622
+ })
623
+
624
+ test('error on invalid value for largeArraySize /2', (t) => {
625
+ t.plan(1)
626
+
627
+ t.assert.throws(() => build({
628
+ title: 'large array of null values with default mechanism',
629
+ type: 'object',
630
+ properties: {
631
+ ids: {
632
+ type: 'array',
633
+ items: { type: 'null' }
634
+ }
635
+ }
636
+ }, {
637
+ largeArraySize: Infinity
638
+ }), Error('Unsupported large array size. Expected integer-like, got number with value Infinity'))
639
+ })
640
+
641
+ test('error on invalid value for largeArraySize /3', (t) => {
642
+ t.plan(1)
643
+
644
+ t.assert.throws(() => build({
645
+ title: 'large array of null values with default mechanism',
646
+ type: 'object',
647
+ properties: {
648
+ ids: {
649
+ type: 'array',
650
+ items: { type: 'null' }
651
+ }
652
+ }
653
+ }, {
654
+ largeArraySize: [200]
655
+ }), Error('Unsupported large array size. Expected integer-like, got object with value 200'))
656
+ })
657
+
658
+ buildTest({
659
+ title: 'large array of integers with largeArraySize is bigint',
660
+ type: 'object',
661
+ properties: {
662
+ ids: {
663
+ type: 'array',
664
+ items: { type: 'integer' }
665
+ }
666
+ }
667
+ }, {
668
+ ids: new Array(2e4).fill(42)
669
+ }, {
670
+ largeArraySize: 20000n,
671
+ largeArrayMechanism: 'default'
672
+ })
673
+
674
+ buildTest({
675
+ title: 'large array of integers with largeArraySize is valid string',
676
+ type: 'object',
677
+ properties: {
678
+ ids: {
679
+ type: 'array',
680
+ items: { type: 'integer' }
681
+ }
682
+ }
683
+ }, {
684
+ ids: new Array(1e4).fill(42)
685
+ }, {
686
+ largeArraySize: '10000',
687
+ largeArrayMechanism: 'default'
688
+ })
@@ -0,0 +1,13 @@
1
+ 'use strict'
2
+
3
+ const { test } = require('node:test')
4
+
5
+ test('asNumber should convert BigInt', (t) => {
6
+ t.plan(1)
7
+ const Serializer = require('../lib/serializer')
8
+ const serializer = new Serializer()
9
+
10
+ const number = serializer.asNumber(11753021440n)
11
+
12
+ t.assert.equal(number, '11753021440')
13
+ })