@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,400 @@
1
+ 'use strict'
2
+
3
+ const { test } = require('node:test')
4
+ const validator = require('is-my-json-valid')
5
+ const build = require('..')
6
+
7
+ function buildTest (schema, toStringify) {
8
+ test(`render a ${schema.title} as JSON`, (t) => {
9
+ t.plan(3)
10
+
11
+ const validate = validator(schema)
12
+ const stringify = build(schema)
13
+ const output = stringify(toStringify)
14
+
15
+ t.assert.deepStrictEqual(JSON.parse(output), toStringify)
16
+ t.assert.equal(output, JSON.stringify(toStringify))
17
+ t.assert.ok(validate(JSON.parse(output)), 'valid schema')
18
+ })
19
+ }
20
+
21
+ buildTest({
22
+ title: 'string',
23
+ type: 'string',
24
+ format: 'unsafe'
25
+ }, 'hello world')
26
+
27
+ buildTest({
28
+ title: 'basic',
29
+ type: 'object',
30
+ properties: {
31
+ firstName: {
32
+ type: 'string'
33
+ },
34
+ lastName: {
35
+ type: 'string'
36
+ },
37
+ age: {
38
+ description: 'Age in years',
39
+ type: 'integer',
40
+ minimum: 0
41
+ },
42
+ magic: {
43
+ type: 'number'
44
+ }
45
+ },
46
+ required: ['firstName', 'lastName']
47
+ }, {
48
+ firstName: 'Matteo',
49
+ lastName: 'Collina',
50
+ age: 32,
51
+ magic: 42.42
52
+ })
53
+
54
+ buildTest({
55
+ title: 'string',
56
+ type: 'string'
57
+ }, 'hello world')
58
+
59
+ buildTest({
60
+ title: 'string',
61
+ type: 'string'
62
+ }, 'hello\nworld')
63
+
64
+ buildTest({
65
+ title: 'string with quotes',
66
+ type: 'string'
67
+ }, 'hello """" world')
68
+
69
+ buildTest({
70
+ title: 'boolean true',
71
+ type: 'boolean'
72
+ }, true)
73
+
74
+ buildTest({
75
+ title: 'boolean false',
76
+ type: 'boolean'
77
+ }, false)
78
+
79
+ buildTest({
80
+ title: 'an integer',
81
+ type: 'integer'
82
+ }, 42)
83
+
84
+ buildTest({
85
+ title: 'a number',
86
+ type: 'number'
87
+ }, 42.42)
88
+
89
+ buildTest({
90
+ title: 'deep',
91
+ type: 'object',
92
+ properties: {
93
+ firstName: {
94
+ type: 'string'
95
+ },
96
+ lastName: {
97
+ type: 'string'
98
+ },
99
+ more: {
100
+ description: 'more properties',
101
+ type: 'object',
102
+ properties: {
103
+ something: {
104
+ type: 'string'
105
+ }
106
+ }
107
+ }
108
+ }
109
+ }, {
110
+ firstName: 'Matteo',
111
+ lastName: 'Collina',
112
+ more: {
113
+ something: 'else'
114
+ }
115
+ })
116
+
117
+ buildTest({
118
+ title: 'null',
119
+ type: 'null'
120
+ }, null)
121
+
122
+ buildTest({
123
+ title: 'deep object with weird keys',
124
+ type: 'object',
125
+ properties: {
126
+ '@version': {
127
+ type: 'integer'
128
+ }
129
+ }
130
+ }, {
131
+ '@version': 1
132
+ })
133
+
134
+ buildTest({
135
+ title: 'deep object with weird keys of type object',
136
+ type: 'object',
137
+ properties: {
138
+ '@data': {
139
+ type: 'object',
140
+ properties: {
141
+ id: {
142
+ type: 'string'
143
+ }
144
+ }
145
+ }
146
+ }
147
+ }, {
148
+ '@data': {
149
+ id: 'string'
150
+ }
151
+ })
152
+
153
+ buildTest({
154
+ title: 'deep object with spaces in key',
155
+ type: 'object',
156
+ properties: {
157
+ 'spaces in key': {
158
+ type: 'object',
159
+ properties: {
160
+ something: {
161
+ type: 'integer'
162
+ }
163
+ }
164
+ }
165
+ }
166
+ }, {
167
+ 'spaces in key': {
168
+ something: 1
169
+ }
170
+ })
171
+
172
+ buildTest({
173
+ title: 'with null',
174
+ type: 'object',
175
+ properties: {
176
+ firstName: {
177
+ type: 'null'
178
+ }
179
+ }
180
+ }, {
181
+ firstName: null
182
+ })
183
+
184
+ buildTest({
185
+ title: 'array with objects',
186
+ type: 'array',
187
+ items: {
188
+ type: 'object',
189
+ properties: {
190
+ name: {
191
+ type: 'string'
192
+ }
193
+ }
194
+ }
195
+ }, [{
196
+ name: 'Matteo'
197
+ }, {
198
+ name: 'Dave'
199
+ }])
200
+
201
+ buildTest({
202
+ title: 'array with strings',
203
+ type: 'array',
204
+ items: {
205
+ type: 'string'
206
+ }
207
+ }, [
208
+ 'Matteo',
209
+ 'Dave'
210
+ ])
211
+
212
+ buildTest({
213
+ title: 'array with numbers',
214
+ type: 'array',
215
+ items: {
216
+ type: 'number'
217
+ }
218
+ }, [
219
+ 42.42,
220
+ 24
221
+ ])
222
+
223
+ buildTest({
224
+ title: 'array with integers',
225
+ type: 'array',
226
+ items: {
227
+ type: 'number'
228
+ }
229
+ }, [
230
+ 42,
231
+ 24
232
+ ])
233
+
234
+ buildTest({
235
+ title: 'nested array with objects',
236
+ type: 'object',
237
+ properties: {
238
+ data: {
239
+ type: 'array',
240
+ items: {
241
+ type: 'object',
242
+ properties: {
243
+ name: {
244
+ type: 'string'
245
+ }
246
+ }
247
+ }
248
+ }
249
+ }
250
+ }, {
251
+ data: [{
252
+ name: 'Matteo'
253
+ }, {
254
+ name: 'Dave'
255
+ }]
256
+ })
257
+
258
+ buildTest({
259
+ title: 'object with boolean',
260
+ type: 'object',
261
+ properties: {
262
+ readonly: {
263
+ type: 'boolean'
264
+ }
265
+ }
266
+ }, {
267
+ readonly: true
268
+ })
269
+
270
+ test('throw an error or coerce numbers and integers that are not numbers', (t) => {
271
+ const stringify = build({
272
+ title: 'basic',
273
+ type: 'object',
274
+ properties: {
275
+ age: {
276
+ type: 'number'
277
+ },
278
+ distance: {
279
+ type: 'integer'
280
+ }
281
+ }
282
+ })
283
+
284
+ t.assert.throws(() => {
285
+ stringify({ age: 'hello ', distance: 'long' })
286
+ }, { message: 'The value "hello " cannot be converted to a number.' })
287
+
288
+ const result = stringify({
289
+ age: '42',
290
+ distance: true
291
+ })
292
+
293
+ t.assert.deepStrictEqual(JSON.parse(result), { age: 42, distance: 1 })
294
+ })
295
+
296
+ test('Should throw on invalid schema', t => {
297
+ t.plan(1)
298
+ t.assert.throws(() => {
299
+ build({
300
+ type: 'Dinosaur',
301
+ properties: {
302
+ claws: { type: 'sharp' }
303
+ }
304
+ })
305
+ }, { message: 'schema is invalid: data/properties/claws/type must be equal to one of the allowed values' })
306
+ })
307
+
308
+ test('additionalProperties - throw on unknown type', (t) => {
309
+ t.plan(1)
310
+
311
+ t.assert.throws(() => {
312
+ build({
313
+ title: 'check array coerce',
314
+ type: 'object',
315
+ properties: {},
316
+ additionalProperties: {
317
+ type: 'strangetype'
318
+ }
319
+ })
320
+ t.fail('should be an invalid schema')
321
+ }, { message: 'schema is invalid: data/additionalProperties/type must be equal to one of the allowed values' })
322
+ })
323
+
324
+ test('patternProperties - throw on unknown type', (t) => {
325
+ t.plan(1)
326
+
327
+ t.assert.throws(() => {
328
+ build({
329
+ title: 'check array coerce',
330
+ type: 'object',
331
+ properties: {},
332
+ patternProperties: {
333
+ foo: {
334
+ type: 'strangetype'
335
+ }
336
+ }
337
+ })
338
+ }, { message: 'schema is invalid: data/patternProperties/foo/type must be equal to one of the allowed values' })
339
+ })
340
+
341
+ test('render a double quote as JSON /1', (t) => {
342
+ t.plan(2)
343
+
344
+ const schema = {
345
+ type: 'string'
346
+ }
347
+ const toStringify = '" double quote'
348
+
349
+ const validate = validator(schema)
350
+ const stringify = build(schema)
351
+ const output = stringify(toStringify)
352
+
353
+ t.assert.equal(output, JSON.stringify(toStringify))
354
+ t.assert.ok(validate(JSON.parse(output)), 'valid schema')
355
+ })
356
+
357
+ test('render a double quote as JSON /2', (t) => {
358
+ t.plan(2)
359
+
360
+ const schema = {
361
+ type: 'string'
362
+ }
363
+ const toStringify = 'double quote " 2'
364
+
365
+ const validate = validator(schema)
366
+ const stringify = build(schema)
367
+ const output = stringify(toStringify)
368
+
369
+ t.assert.equal(output, JSON.stringify(toStringify))
370
+ t.assert.ok(validate(JSON.parse(output)), 'valid schema')
371
+ })
372
+
373
+ test('render a long string', (t) => {
374
+ t.plan(2)
375
+
376
+ const schema = {
377
+ type: 'string'
378
+ }
379
+ const toStringify = 'the Ultimate Question of Life, the Universe, and Everything.'
380
+
381
+ const validate = validator(schema)
382
+ const stringify = build(schema)
383
+ const output = stringify(toStringify)
384
+
385
+ t.assert.equal(output, JSON.stringify(toStringify))
386
+ t.assert.ok(validate(JSON.parse(output)), 'valid schema')
387
+ })
388
+
389
+ test('returns JSON.stringify if schema type is boolean', t => {
390
+ t.plan(1)
391
+
392
+ const schema = {
393
+ type: 'array',
394
+ items: true
395
+ }
396
+
397
+ const array = [1, true, 'test']
398
+ const stringify = build(schema)
399
+ t.assert.equal(stringify(array), JSON.stringify(array))
400
+ })
@@ -0,0 +1,76 @@
1
+ 'use strict'
2
+
3
+ const { test } = require('node:test')
4
+
5
+ const build = require('..')
6
+
7
+ test('render a bigint as JSON', (t) => {
8
+ t.plan(1)
9
+
10
+ const schema = {
11
+ title: 'bigint',
12
+ type: 'integer'
13
+ }
14
+
15
+ const stringify = build(schema)
16
+ const output = stringify(1615n)
17
+
18
+ t.assert.equal(output, '1615')
19
+ })
20
+
21
+ test('render an object with a bigint as JSON', (t) => {
22
+ t.plan(1)
23
+
24
+ const schema = {
25
+ title: 'object with bigint',
26
+ type: 'object',
27
+ properties: {
28
+ id: {
29
+ type: 'integer'
30
+ }
31
+ }
32
+ }
33
+
34
+ const stringify = build(schema)
35
+ const output = stringify({
36
+ id: 1615n
37
+ })
38
+
39
+ t.assert.equal(output, '{"id":1615}')
40
+ })
41
+
42
+ test('render an array with a bigint as JSON', (t) => {
43
+ t.plan(1)
44
+
45
+ const schema = {
46
+ title: 'array with bigint',
47
+ type: 'array',
48
+ items: {
49
+ type: 'integer'
50
+ }
51
+ }
52
+
53
+ const stringify = build(schema)
54
+ const output = stringify([1615n])
55
+
56
+ t.assert.equal(output, '[1615]')
57
+ })
58
+
59
+ test('render an object with an additionalProperty of type bigint as JSON', (t) => {
60
+ t.plan(1)
61
+
62
+ const schema = {
63
+ title: 'object with bigint',
64
+ type: 'object',
65
+ additionalProperties: {
66
+ type: 'integer'
67
+ }
68
+ }
69
+
70
+ const stringify = build(schema)
71
+ const output = stringify({
72
+ num: 1615n
73
+ })
74
+
75
+ t.assert.equal(output, '{"num":1615}')
76
+ })
@@ -0,0 +1,47 @@
1
+ 'use strict'
2
+
3
+ const { test } = require('node:test')
4
+ const build = require('..')
5
+
6
+ test('Should clean the cache', (t) => {
7
+ t.plan(1)
8
+
9
+ const schema = {
10
+ $id: 'test',
11
+ type: 'string'
12
+ }
13
+
14
+ t.assert.doesNotThrow(() => {
15
+ build(schema)
16
+ build(schema)
17
+ })
18
+ })
19
+
20
+ test('Should clean the cache with external schemas', (t) => {
21
+ t.plan(1)
22
+
23
+ const schema = {
24
+ $id: 'test',
25
+ definitions: {
26
+ def: {
27
+ type: 'object',
28
+ properties: {
29
+ str: {
30
+ type: 'string'
31
+ }
32
+ }
33
+ }
34
+ },
35
+ type: 'object',
36
+ properties: {
37
+ obj: {
38
+ $ref: '#/definitions/def'
39
+ }
40
+ }
41
+ }
42
+
43
+ t.assert.doesNotThrow(() => {
44
+ build(schema)
45
+ build(schema)
46
+ })
47
+ })