@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,639 @@
1
+ 'use strict'
2
+
3
+ const { test } = require('node:test')
4
+ const validator = require('is-my-json-valid')
5
+ const build = require('..')
6
+
7
+ process.env.TZ = 'UTC'
8
+
9
+ test('render a date in a string as JSON', (t) => {
10
+ t.plan(2)
11
+
12
+ const schema = {
13
+ title: 'a date in a string',
14
+ type: 'string'
15
+ }
16
+ const toStringify = new Date(1674263005800)
17
+
18
+ const validate = validator(schema)
19
+ const stringify = build(schema)
20
+ const output = stringify(toStringify)
21
+
22
+ t.assert.equal(output, JSON.stringify(toStringify))
23
+ t.assert.ok(validate(JSON.parse(output)), 'valid schema')
24
+ })
25
+
26
+ test('render a date in a string when format is date-format as ISOString', (t) => {
27
+ t.plan(2)
28
+
29
+ const schema = {
30
+ title: 'a date in a string',
31
+ type: 'string',
32
+ format: 'date-time'
33
+ }
34
+ const toStringify = new Date(1674263005800)
35
+
36
+ const validate = validator(schema)
37
+ const stringify = build(schema)
38
+ const output = stringify(toStringify)
39
+
40
+ t.assert.equal(output, JSON.stringify(toStringify))
41
+ t.assert.ok(validate(JSON.parse(output)), 'valid schema')
42
+ })
43
+
44
+ test('render a nullable date in a string when format is date-format as ISOString', (t) => {
45
+ t.plan(2)
46
+
47
+ const schema = {
48
+ title: 'a date in a string',
49
+ type: 'string',
50
+ format: 'date-time',
51
+ nullable: true
52
+ }
53
+ const toStringify = new Date(1674263005800)
54
+
55
+ const validate = validator(schema)
56
+ const stringify = build(schema)
57
+ const output = stringify(toStringify)
58
+
59
+ t.assert.equal(output, JSON.stringify(toStringify))
60
+ t.assert.ok(validate(JSON.parse(output)), 'valid schema')
61
+ })
62
+
63
+ test('render a date in a string when format is date as YYYY-MM-DD', (t) => {
64
+ t.plan(2)
65
+
66
+ const schema = {
67
+ title: 'a date in a string',
68
+ type: 'string',
69
+ format: 'date'
70
+ }
71
+ const toStringify = new Date(1674263005800)
72
+
73
+ const validate = validator(schema)
74
+ const stringify = build(schema)
75
+ const output = stringify(toStringify)
76
+
77
+ t.assert.equal(output, '"2023-01-21"')
78
+ t.assert.ok(validate(JSON.parse(output)), 'valid schema')
79
+ })
80
+
81
+ test('render a nullable date in a string when format is date as YYYY-MM-DD', (t) => {
82
+ t.plan(2)
83
+
84
+ const schema = {
85
+ title: 'a date in a string',
86
+ type: 'string',
87
+ format: 'date',
88
+ nullable: true
89
+ }
90
+ const toStringify = new Date(1674263005800)
91
+
92
+ const validate = validator(schema)
93
+ const stringify = build(schema)
94
+ const output = stringify(toStringify)
95
+
96
+ t.assert.equal(output, '"2023-01-21"')
97
+ t.assert.ok(validate(JSON.parse(output)), 'valid schema')
98
+ })
99
+
100
+ test('verify padding for rendered date in a string when format is date', (t) => {
101
+ t.plan(2)
102
+
103
+ const schema = {
104
+ title: 'a date in a string',
105
+ type: 'string',
106
+ format: 'date'
107
+ }
108
+ const toStringify = new Date(2020, 0, 1, 0, 0, 0, 0)
109
+
110
+ const validate = validator(schema)
111
+ const stringify = build(schema)
112
+ const output = stringify(toStringify)
113
+
114
+ t.assert.equal(output, '"2020-01-01"')
115
+ t.assert.ok(validate(JSON.parse(output)), 'valid schema')
116
+ })
117
+
118
+ test('render a date in a string when format is time as kk:mm:ss', (t) => {
119
+ t.plan(3)
120
+
121
+ const schema = {
122
+ title: 'a date in a string',
123
+ type: 'string',
124
+ format: 'time'
125
+ }
126
+ const toStringify = new Date(1674263005800)
127
+
128
+ const validate = validator(schema)
129
+ const stringify = build(schema)
130
+ const output = stringify(toStringify)
131
+
132
+ validate(JSON.parse(output))
133
+ t.assert.equal(validate.errors, null)
134
+
135
+ t.assert.equal(output, '"01:03:25"')
136
+ t.assert.ok(validate(JSON.parse(output)), 'valid schema')
137
+ })
138
+
139
+ test('render a nullable date in a string when format is time as kk:mm:ss', (t) => {
140
+ t.plan(3)
141
+
142
+ const schema = {
143
+ title: 'a date in a string',
144
+ type: 'string',
145
+ format: 'time',
146
+ nullable: true
147
+ }
148
+ const toStringify = new Date(1674263005800)
149
+
150
+ const validate = validator(schema)
151
+ const stringify = build(schema)
152
+ const output = stringify(toStringify)
153
+
154
+ validate(JSON.parse(output))
155
+ t.assert.equal(validate.errors, null)
156
+
157
+ t.assert.equal(output, '"01:03:25"')
158
+ t.assert.ok(validate(JSON.parse(output)), 'valid schema')
159
+ })
160
+
161
+ test('render a midnight time', (t) => {
162
+ t.plan(3)
163
+
164
+ const schema = {
165
+ title: 'a date in a string',
166
+ type: 'string',
167
+ format: 'time'
168
+ }
169
+ const midnight = new Date(new Date(1674263005800).setHours(24))
170
+
171
+ const validate = validator(schema)
172
+ const stringify = build(schema)
173
+ const output = stringify(midnight)
174
+
175
+ validate(JSON.parse(output))
176
+ t.assert.equal(validate.errors, null)
177
+
178
+ t.assert.equal(output, '"00:03:25"')
179
+ t.assert.ok(validate(JSON.parse(output)), 'valid schema')
180
+ })
181
+
182
+ test('verify padding for rendered date in a string when format is time', (t) => {
183
+ t.plan(3)
184
+
185
+ const schema = {
186
+ title: 'a date in a string',
187
+ type: 'string',
188
+ format: 'time'
189
+ }
190
+ const toStringify = new Date(2020, 0, 1, 1, 1, 1, 1)
191
+
192
+ const validate = validator(schema)
193
+ const stringify = build(schema)
194
+ const output = stringify(toStringify)
195
+
196
+ validate(JSON.parse(output))
197
+ t.assert.equal(validate.errors, null)
198
+
199
+ t.assert.equal(output, '"01:01:01"')
200
+ t.assert.ok(validate(JSON.parse(output)), 'valid schema')
201
+ })
202
+
203
+ test('render a nested object in a string when type is date-format as ISOString', (t) => {
204
+ t.plan(2)
205
+
206
+ const schema = {
207
+ title: 'an object in a string',
208
+ type: 'object',
209
+ properties: {
210
+ date: {
211
+ type: 'string',
212
+ format: 'date-time'
213
+ }
214
+ }
215
+ }
216
+ const toStringify = { date: new Date(1674263005800) }
217
+
218
+ const validate = validator(schema)
219
+ const stringify = build(schema)
220
+ const output = stringify(toStringify)
221
+
222
+ t.assert.equal(output, JSON.stringify(toStringify))
223
+ t.assert.ok(validate(JSON.parse(output)), 'valid schema')
224
+ })
225
+
226
+ test('serializing null value', async t => {
227
+ const input = { updatedAt: null }
228
+
229
+ function createSchema (properties) {
230
+ return {
231
+ title: 'an object in a string',
232
+ type: 'object',
233
+ properties
234
+ }
235
+ }
236
+
237
+ function serialize (schema, input) {
238
+ const validate = validator(schema)
239
+ const stringify = build(schema)
240
+ const output = stringify(input)
241
+
242
+ return {
243
+ validate,
244
+ output
245
+ }
246
+ }
247
+
248
+ t.plan(3)
249
+
250
+ await t.test('type::string', async t => {
251
+ t.plan(3)
252
+
253
+ await t.test('format::date-time', t => {
254
+ t.plan(2)
255
+
256
+ const prop = {
257
+ updatedAt: {
258
+ type: 'string',
259
+ format: 'date-time'
260
+ }
261
+ }
262
+
263
+ const {
264
+ output,
265
+ validate
266
+ } = serialize(createSchema(prop), input)
267
+
268
+ t.assert.equal(output, '{"updatedAt":""}')
269
+ t.assert.equal(validate(JSON.parse(output)), false, 'an empty string is not a date-time format')
270
+ })
271
+
272
+ await t.test('format::date', t => {
273
+ t.plan(2)
274
+
275
+ const prop = {
276
+ updatedAt: {
277
+ type: 'string',
278
+ format: 'date'
279
+ }
280
+ }
281
+
282
+ const {
283
+ output,
284
+ validate
285
+ } = serialize(createSchema(prop), input)
286
+
287
+ t.assert.equal(output, '{"updatedAt":""}')
288
+ t.assert.equal(validate(JSON.parse(output)), false, 'an empty string is not a date format')
289
+ })
290
+
291
+ await t.test('format::time', t => {
292
+ t.plan(2)
293
+
294
+ const prop = {
295
+ updatedAt: {
296
+ type: 'string',
297
+ format: 'time'
298
+ }
299
+ }
300
+
301
+ const {
302
+ output,
303
+ validate
304
+ } = serialize(createSchema(prop), input)
305
+
306
+ t.assert.equal(output, '{"updatedAt":""}')
307
+ t.assert.equal(validate(JSON.parse(output)), false, 'an empty string is not a time format')
308
+ })
309
+ })
310
+
311
+ await t.test('type::array', async t => {
312
+ t.plan(6)
313
+
314
+ await t.test('format::date-time', t => {
315
+ t.plan(2)
316
+
317
+ const prop = {
318
+ updatedAt: {
319
+ type: ['string'],
320
+ format: 'date-time'
321
+ }
322
+ }
323
+
324
+ const {
325
+ output,
326
+ validate
327
+ } = serialize(createSchema(prop), input)
328
+
329
+ t.assert.equal(output, '{"updatedAt":""}')
330
+ t.assert.equal(validate(JSON.parse(output)), false, 'an empty string is not a date-time format')
331
+ })
332
+
333
+ await t.test('format::date', t => {
334
+ t.plan(2)
335
+
336
+ const prop = {
337
+ updatedAt: {
338
+ type: ['string'],
339
+ format: 'date'
340
+ }
341
+ }
342
+
343
+ const {
344
+ output,
345
+ validate
346
+ } = serialize(createSchema(prop), input)
347
+
348
+ t.assert.equal(output, '{"updatedAt":""}')
349
+ t.assert.equal(validate(JSON.parse(output)), false, 'an empty string is not a date format')
350
+ })
351
+
352
+ await t.test('format::date', t => {
353
+ t.plan(2)
354
+
355
+ const prop = {
356
+ updatedAt: {
357
+ type: ['string'],
358
+ format: 'date'
359
+ }
360
+ }
361
+
362
+ const {
363
+ output,
364
+ validate
365
+ } = serialize(createSchema(prop), input)
366
+
367
+ t.assert.equal(output, '{"updatedAt":""}')
368
+ t.assert.equal(validate(JSON.parse(output)), false, 'an empty string is not a date format')
369
+ })
370
+
371
+ await t.test('format::time, Date object', t => {
372
+ t.plan(1)
373
+
374
+ const schema = {
375
+ oneOf: [
376
+ {
377
+ type: 'object',
378
+ properties: {
379
+ updatedAt: {
380
+ type: ['string', 'number'],
381
+ format: 'time'
382
+ }
383
+ }
384
+ }
385
+ ]
386
+ }
387
+
388
+ const date = new Date(1674263005800)
389
+ const input = { updatedAt: date }
390
+ const { output } = serialize(schema, input)
391
+
392
+ t.assert.equal(output, JSON.stringify({ updatedAt: '01:03:25' }))
393
+ })
394
+
395
+ await t.test('format::time, Date object', t => {
396
+ t.plan(1)
397
+
398
+ const schema = {
399
+ oneOf: [
400
+ {
401
+ type: ['string', 'number'],
402
+ format: 'time'
403
+ }
404
+ ]
405
+ }
406
+
407
+ const date = new Date(1674263005800)
408
+ const { output } = serialize(schema, date)
409
+
410
+ t.assert.equal(output, '"01:03:25"')
411
+ })
412
+
413
+ await t.test('format::time, Date object', t => {
414
+ t.plan(1)
415
+
416
+ const schema = {
417
+ oneOf: [
418
+ {
419
+ type: ['string', 'number'],
420
+ format: 'time'
421
+ }
422
+ ]
423
+ }
424
+
425
+ const { output } = serialize(schema, 42)
426
+
427
+ t.assert.equal(output, JSON.stringify(42))
428
+ })
429
+ })
430
+
431
+ await t.test('type::array::nullable', async t => {
432
+ t.plan(3)
433
+
434
+ await t.test('format::date-time', t => {
435
+ t.plan(2)
436
+
437
+ const prop = {
438
+ updatedAt: {
439
+ type: ['string', 'null'],
440
+ format: 'date-time'
441
+ }
442
+ }
443
+
444
+ const {
445
+ output,
446
+ validate
447
+ } = serialize(createSchema(prop), input)
448
+
449
+ t.assert.equal(output, '{"updatedAt":null}')
450
+ t.assert.ok(validate(JSON.parse(output)), 'valid schema')
451
+ })
452
+
453
+ await t.test('format::date', t => {
454
+ t.plan(2)
455
+
456
+ const prop = {
457
+ updatedAt: {
458
+ type: ['string', 'null'],
459
+ format: 'date'
460
+ }
461
+ }
462
+
463
+ const {
464
+ output,
465
+ validate
466
+ } = serialize(createSchema(prop), input)
467
+
468
+ t.assert.equal(output, '{"updatedAt":null}')
469
+ t.assert.ok(validate(JSON.parse(output)), 'valid schema')
470
+ })
471
+
472
+ await t.test('format::time', t => {
473
+ t.plan(2)
474
+
475
+ const prop = {
476
+ updatedAt: {
477
+ type: ['string', 'null'],
478
+ format: 'time'
479
+ }
480
+ }
481
+
482
+ const {
483
+ output,
484
+ validate
485
+ } = serialize(createSchema(prop), input)
486
+
487
+ t.assert.equal(output, '{"updatedAt":null}')
488
+ t.assert.ok(validate(JSON.parse(output)), 'valid schema')
489
+ })
490
+ })
491
+ })
492
+
493
+ test('Validate Date object as string type', (t) => {
494
+ t.plan(1)
495
+
496
+ const schema = {
497
+ oneOf: [
498
+ { type: 'string' }
499
+ ]
500
+ }
501
+ const toStringify = new Date(1674263005800)
502
+
503
+ const stringify = build(schema)
504
+ const output = stringify(toStringify)
505
+
506
+ t.assert.equal(output, JSON.stringify(toStringify))
507
+ })
508
+
509
+ test('nullable date', (t) => {
510
+ t.plan(1)
511
+
512
+ const schema = {
513
+ anyOf: [
514
+ {
515
+ format: 'date',
516
+ type: 'string',
517
+ nullable: true
518
+ }
519
+ ]
520
+ }
521
+
522
+ const stringify = build(schema)
523
+
524
+ const data = new Date(1674263005800)
525
+ const result = stringify(data)
526
+
527
+ t.assert.equal(result, '"2023-01-21"')
528
+ })
529
+
530
+ test('non-date format should not affect data serialization (issue #491)', (t) => {
531
+ t.plan(1)
532
+
533
+ const schema = {
534
+ type: 'object',
535
+ properties: {
536
+ hello: {
537
+ type: 'string',
538
+ format: 'int64',
539
+ pattern: '^[0-9]*$'
540
+ }
541
+ }
542
+ }
543
+
544
+ const stringify = build(schema)
545
+ const data = { hello: 123n }
546
+ t.assert.equal(stringify(data), '{"hello":"123"}')
547
+ })
548
+
549
+ test('should serialize also an invalid string value, even if it is not a valid date', (t) => {
550
+ t.plan(2)
551
+
552
+ const schema = {
553
+ title: 'a date in a string',
554
+ type: 'string',
555
+ format: 'date-time',
556
+ nullable: true
557
+ }
558
+ const toStringify = 'invalid'
559
+
560
+ const validate = validator(schema)
561
+ const stringify = build(schema)
562
+ const output = stringify(toStringify)
563
+
564
+ t.assert.equal(output, JSON.stringify(toStringify))
565
+ t.assert.equal(validate(JSON.parse(output)), false, 'valid schema')
566
+ })
567
+
568
+ test('should throw an error if value can not be transformed to date-time', (t) => {
569
+ t.plan(2)
570
+
571
+ const schema = {
572
+ title: 'a date in a string',
573
+ type: 'string',
574
+ format: 'date-time',
575
+ nullable: true
576
+ }
577
+ const toStringify = true
578
+
579
+ const validate = validator(schema)
580
+ const stringify = build(schema)
581
+
582
+ t.assert.throws(() => stringify(toStringify), new Error('The value "true" cannot be converted to a date-time.'))
583
+ t.assert.equal(validate(toStringify), false)
584
+ })
585
+
586
+ test('should throw an error if value can not be transformed to date', (t) => {
587
+ t.plan(2)
588
+
589
+ const schema = {
590
+ title: 'a date in a string',
591
+ type: 'string',
592
+ format: 'date',
593
+ nullable: true
594
+ }
595
+ const toStringify = true
596
+
597
+ const validate = validator(schema)
598
+ const stringify = build(schema)
599
+
600
+ t.assert.throws(() => stringify(toStringify), new Error('The value "true" cannot be converted to a date.'))
601
+ t.assert.equal(validate(toStringify), false)
602
+ })
603
+
604
+ test('should throw an error if value can not be transformed to time', (t) => {
605
+ t.plan(2)
606
+
607
+ const schema = {
608
+ title: 'a time in a string',
609
+ type: 'string',
610
+ format: 'time',
611
+ nullable: true
612
+ }
613
+ const toStringify = true
614
+
615
+ const validate = validator(schema)
616
+ const stringify = build(schema)
617
+
618
+ t.assert.throws(() => stringify(toStringify), new Error('The value "true" cannot be converted to a time.'))
619
+ t.assert.equal(validate(toStringify), false)
620
+ })
621
+
622
+ test('should serialize also an invalid string value, even if it is not a valid time', (t) => {
623
+ t.plan(2)
624
+
625
+ const schema = {
626
+ title: 'a time in a string',
627
+ type: 'string',
628
+ format: 'time',
629
+ nullable: true
630
+ }
631
+ const toStringify = 'invalid'
632
+
633
+ const validate = validator(schema)
634
+ const stringify = build(schema)
635
+ const output = stringify(toStringify)
636
+
637
+ t.assert.equal(output, JSON.stringify(toStringify))
638
+ t.assert.equal(validate(JSON.parse(output)), false, 'valid schema')
639
+ })