@zuplo/cli 6.71.23 → 6.71.26

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (128) hide show
  1. package/node_modules/@fastify/fast-json-stringify-compiler/.github/dependabot.yml +42 -2
  2. package/node_modules/@fastify/fast-json-stringify-compiler/.github/workflows/ci.yml +6 -1
  3. package/node_modules/@fastify/fast-json-stringify-compiler/.github/workflows/lock-threads.yml +19 -0
  4. package/node_modules/@fastify/fast-json-stringify-compiler/LICENSE +1 -1
  5. package/node_modules/@fastify/fast-json-stringify-compiler/README.md +1 -1
  6. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/.gitattributes +2 -0
  7. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/.github/dependabot.yml +13 -0
  8. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/.github/workflows/ci.yml +33 -0
  9. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/.github/workflows/lock-threads.yml +19 -0
  10. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/LICENSE +22 -0
  11. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/README.md +742 -0
  12. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/benchmark/bench-cmp-branch.js +116 -0
  13. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/benchmark/bench-cmp-lib.js +339 -0
  14. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/benchmark/bench-thread.js +33 -0
  15. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/benchmark/bench.js +391 -0
  16. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/build/build-schema-validator.js +26 -0
  17. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/eslint.config.js +9 -0
  18. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/examples/example.js +81 -0
  19. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/examples/server.js +42 -0
  20. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/index.js +1308 -0
  21. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/lib/location.js +24 -0
  22. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/lib/merge-schemas.js +9 -0
  23. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/lib/schema-validator.js +1134 -0
  24. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/lib/serializer.js +141 -0
  25. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/lib/standalone.js +34 -0
  26. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/lib/validator.js +96 -0
  27. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/package.json +89 -0
  28. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/additionalProperties.test.js +332 -0
  29. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/allof.test.js +751 -0
  30. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/any.test.js +231 -0
  31. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/anyof.test.js +812 -0
  32. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/array.test.js +688 -0
  33. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/asNumber.test.js +13 -0
  34. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/basic.test.js +400 -0
  35. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/bigint.test.js +76 -0
  36. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/clean-cache.test.js +47 -0
  37. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/const.test.js +314 -0
  38. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/date.test.js +639 -0
  39. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/debug-mode.test.js +130 -0
  40. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/defaults.test.js +376 -0
  41. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/enum.test.js +37 -0
  42. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/fix-604.test.js +25 -0
  43. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/fixtures/.keep +0 -0
  44. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/if-then-else.test.js +540 -0
  45. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/inferType.test.js +92 -0
  46. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/infinity.test.js +55 -0
  47. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/integer.test.js +194 -0
  48. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/invalidSchema.test.js +38 -0
  49. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/issue-479.test.js +57 -0
  50. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/issue-793.test.js +107 -0
  51. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/issue-794.test.js +177 -0
  52. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/issue-836.test.js +183 -0
  53. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/json-add-comma.test.js +57 -0
  54. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/json-schema-test-suite/README.md +10 -0
  55. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/json-schema-test-suite/draft4/required.json +54 -0
  56. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/json-schema-test-suite/draft4.test.js +12 -0
  57. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/json-schema-test-suite/draft6/required.json +70 -0
  58. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/json-schema-test-suite/draft6.test.js +12 -0
  59. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/json-schema-test-suite/draft7/required.json +70 -0
  60. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/json-schema-test-suite/draft7.test.js +12 -0
  61. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/json-schema-test-suite/util.js +31 -0
  62. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/missing-values.test.js +88 -0
  63. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/multi-type-serializer.test.js +19 -0
  64. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/nestedObjects.test.js +63 -0
  65. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/nullable.test.js +543 -0
  66. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/oneof.test.js +510 -0
  67. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/patternProperties.test.js +168 -0
  68. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/recursion.test.js +245 -0
  69. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/ref.json +12 -0
  70. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/ref.test.js +2077 -0
  71. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/regex.test.js +32 -0
  72. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/required.test.js +204 -0
  73. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/requiresAjv.test.js +50 -0
  74. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/sanitize.test.js +141 -0
  75. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/sanitize2.test.js +18 -0
  76. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/sanitize3.test.js +17 -0
  77. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/sanitize4.test.js +16 -0
  78. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/sanitize5.test.js +16 -0
  79. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/sanitize6.test.js +22 -0
  80. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/sanitize7.test.js +68 -0
  81. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/side-effect.test.js +196 -0
  82. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/standalone-mode.test.js +219 -0
  83. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/string.test.js +84 -0
  84. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/surrogate.test.js +67 -0
  85. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/toJSON.test.js +203 -0
  86. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/typebox.test.js +36 -0
  87. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/typesArray.test.js +550 -0
  88. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/unknownFormats.test.js +27 -0
  89. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/webpack.test.js +50 -0
  90. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/types/index.d.ts +219 -0
  91. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/types/index.tst.ts +259 -0
  92. package/node_modules/@fastify/fast-json-stringify-compiler/package.json +6 -11
  93. package/node_modules/@fastify/fast-json-stringify-compiler/types/{index.test-d.ts → index.tst.ts} +34 -32
  94. package/node_modules/@protobufjs/utf8/CHANGELOG.md +8 -0
  95. package/node_modules/@protobufjs/utf8/index.js +29 -18
  96. package/node_modules/@protobufjs/utf8/package.json +2 -2
  97. package/node_modules/@protobufjs/utf8/tests/index.js +5 -0
  98. package/node_modules/@zuplo/core/package.json +1 -1
  99. package/node_modules/@zuplo/graphql/package.json +1 -1
  100. package/node_modules/@zuplo/openapi-tools/package.json +1 -1
  101. package/node_modules/@zuplo/otel/package.json +1 -1
  102. package/node_modules/@zuplo/runtime/out/esm/{chunk-5CYWMN74.js → chunk-D3O7C43P.js} +98 -97
  103. package/node_modules/@zuplo/runtime/out/esm/chunk-D3O7C43P.js.map +1 -0
  104. package/node_modules/@zuplo/runtime/out/esm/index.js +1 -1
  105. package/node_modules/@zuplo/runtime/out/esm/index.js.map +1 -1
  106. package/node_modules/@zuplo/runtime/out/esm/mcp-gateway/index.js +1 -1
  107. package/node_modules/@zuplo/runtime/out/types/index.d.ts +172 -0
  108. package/node_modules/@zuplo/runtime/package.json +1 -1
  109. package/node_modules/hono/dist/adapter/aws-lambda/handler.js +1 -1
  110. package/node_modules/hono/dist/adapter/bun/websocket.js +3 -1
  111. package/node_modules/hono/dist/cjs/adapter/aws-lambda/handler.js +1 -1
  112. package/node_modules/hono/dist/cjs/adapter/bun/websocket.js +3 -1
  113. package/node_modules/hono/dist/cjs/middleware/serve-static/index.js +1 -1
  114. package/node_modules/hono/dist/cjs/utils/body.js +12 -4
  115. package/node_modules/hono/dist/cjs/utils/buffer.js +2 -1
  116. package/node_modules/hono/dist/cjs/validator/validator.js +3 -3
  117. package/node_modules/hono/dist/middleware/serve-static/index.js +1 -1
  118. package/node_modules/hono/dist/types/middleware/context-storage/index.d.ts +2 -2
  119. package/node_modules/hono/dist/types/utils/body.d.ts +1 -1
  120. package/node_modules/hono/dist/utils/body.js +12 -4
  121. package/node_modules/hono/dist/utils/buffer.js +2 -1
  122. package/node_modules/hono/dist/validator/validator.js +3 -3
  123. package/node_modules/hono/package.json +8 -7
  124. package/package.json +6 -6
  125. package/node_modules/@fastify/fast-json-stringify-compiler/.eslintrc +0 -1
  126. package/node_modules/@zuplo/runtime/out/esm/chunk-5CYWMN74.js.map +0 -1
  127. package/node_modules/hono/dist/tsconfig.build.tsbuildinfo +0 -1
  128. /package/node_modules/@zuplo/runtime/out/esm/{chunk-5CYWMN74.js.LEGAL.txt → chunk-D3O7C43P.js.LEGAL.txt} +0 -0
@@ -0,0 +1,194 @@
1
+ 'use strict'
2
+
3
+ const { test } = require('node:test')
4
+
5
+ const validator = require('is-my-json-valid')
6
+ const build = require('..')
7
+ const ROUNDING_TYPES = ['ceil', 'floor', 'round']
8
+
9
+ test('render an integer as JSON', (t) => {
10
+ t.plan(2)
11
+
12
+ const schema = {
13
+ title: 'integer',
14
+ type: 'integer'
15
+ }
16
+
17
+ const validate = validator(schema)
18
+ const stringify = build(schema)
19
+ const output = stringify(1615)
20
+
21
+ t.assert.equal(output, '1615')
22
+ t.assert.ok(validate(JSON.parse(output)), 'valid schema')
23
+ })
24
+
25
+ test('render a float as an integer', (t) => {
26
+ t.plan(2)
27
+ try {
28
+ build({
29
+ title: 'float as integer',
30
+ type: 'integer'
31
+ }, { rounding: 'foobar' })
32
+ } catch (error) {
33
+ t.assert.ok(error)
34
+ t.assert.equal(error.message, 'Unsupported integer rounding method foobar')
35
+ }
36
+ })
37
+
38
+ test('throws on NaN', (t) => {
39
+ t.plan(1)
40
+
41
+ const schema = {
42
+ title: 'integer',
43
+ type: 'integer'
44
+ }
45
+
46
+ const stringify = build(schema)
47
+ t.assert.throws(() => stringify(NaN), new Error('The value "NaN" cannot be converted to an integer.'))
48
+ })
49
+
50
+ test('render a float as an integer', (t) => {
51
+ const cases = [
52
+ { input: Math.PI, output: '3' },
53
+ { input: 5.0, output: '5' },
54
+ { input: null, output: '0' },
55
+ { input: 0, output: '0' },
56
+ { input: 0.0, output: '0' },
57
+ { input: 42, output: '42' },
58
+ { input: 1.99999, output: '1' },
59
+ { input: -45.05, output: '-45' },
60
+ { input: 3333333333333333, output: '3333333333333333' },
61
+ { input: Math.PI, output: '3', rounding: 'trunc' },
62
+ { input: 5.0, output: '5', rounding: 'trunc' },
63
+ { input: null, output: '0', rounding: 'trunc' },
64
+ { input: 0, output: '0', rounding: 'trunc' },
65
+ { input: 0.0, output: '0', rounding: 'trunc' },
66
+ { input: 42, output: '42', rounding: 'trunc' },
67
+ { input: 1.99999, output: '1', rounding: 'trunc' },
68
+ { input: -45.05, output: '-45', rounding: 'trunc' },
69
+ { input: 0.95, output: '1', rounding: 'ceil' },
70
+ { input: 0.2, output: '1', rounding: 'ceil' },
71
+ { input: 45.95, output: '45', rounding: 'floor' },
72
+ { input: -45.05, output: '-46', rounding: 'floor' },
73
+ { input: 45.44, output: '45', rounding: 'round' },
74
+ { input: 45.95, output: '46', rounding: 'round' }
75
+ ]
76
+
77
+ t.plan(cases.length * 2)
78
+ cases.forEach(checkInteger)
79
+
80
+ function checkInteger ({ input, output, rounding }) {
81
+ const schema = {
82
+ title: 'float as integer',
83
+ type: 'integer'
84
+ }
85
+
86
+ const validate = validator(schema)
87
+ const stringify = build(schema, { rounding })
88
+ const str = stringify(input)
89
+
90
+ t.assert.equal(str, output)
91
+ t.assert.ok(validate(JSON.parse(str)), 'valid schema')
92
+ }
93
+ })
94
+
95
+ test('render an object with an integer as JSON', (t) => {
96
+ t.plan(2)
97
+
98
+ const schema = {
99
+ title: 'object with integer',
100
+ type: 'object',
101
+ properties: {
102
+ id: {
103
+ type: 'integer'
104
+ }
105
+ }
106
+ }
107
+
108
+ const validate = validator(schema)
109
+ const stringify = build(schema)
110
+ const output = stringify({
111
+ id: 1615
112
+ })
113
+
114
+ t.assert.equal(output, '{"id":1615}')
115
+ t.assert.ok(validate(JSON.parse(output)), 'valid schema')
116
+ })
117
+
118
+ test('render an array with an integer as JSON', (t) => {
119
+ t.plan(2)
120
+
121
+ const schema = {
122
+ title: 'array with integer',
123
+ type: 'array',
124
+ items: {
125
+ type: 'integer'
126
+ }
127
+ }
128
+
129
+ const validate = validator(schema)
130
+ const stringify = build(schema)
131
+ const output = stringify([1615])
132
+
133
+ t.assert.equal(output, '[1615]')
134
+ t.assert.ok(validate(JSON.parse(output)), 'valid schema')
135
+ })
136
+
137
+ test('render an object with an additionalProperty of type integer as JSON', (t) => {
138
+ t.plan(2)
139
+
140
+ const schema = {
141
+ title: 'object with integer',
142
+ type: 'object',
143
+ additionalProperties: {
144
+ type: 'integer'
145
+ }
146
+ }
147
+
148
+ const validate = validator(schema)
149
+ const stringify = build(schema)
150
+ const output = stringify({
151
+ num: 1615
152
+ })
153
+
154
+ t.assert.equal(output, '{"num":1615}')
155
+ t.assert.ok(validate(JSON.parse(output)), 'valid schema')
156
+ })
157
+
158
+ test('should round integer object parameter', t => {
159
+ t.plan(2)
160
+
161
+ const schema = { type: 'object', properties: { magic: { type: 'integer' } } }
162
+ const validate = validator(schema)
163
+ const stringify = build(schema, { rounding: 'ceil' })
164
+ const output = stringify({ magic: 4.2 })
165
+
166
+ t.assert.equal(output, '{"magic":5}')
167
+ t.assert.ok(validate(JSON.parse(output)), 'valid schema')
168
+ })
169
+
170
+ test('should not stringify a property if it does not exist', t => {
171
+ t.plan(2)
172
+
173
+ const schema = { title: 'Example Schema', type: 'object', properties: { age: { type: 'integer' } } }
174
+ const validate = validator(schema)
175
+ const stringify = build(schema)
176
+ const output = stringify({})
177
+
178
+ t.assert.equal(output, '{}')
179
+ t.assert.ok(validate(JSON.parse(output)), 'valid schema')
180
+ })
181
+
182
+ ROUNDING_TYPES.forEach((rounding) => {
183
+ test(`should not stringify a property if it does not exist (rounding: ${rounding})`, t => {
184
+ t.plan(2)
185
+
186
+ const schema = { type: 'object', properties: { magic: { type: 'integer' } } }
187
+ const validate = validator(schema)
188
+ const stringify = build(schema, { rounding })
189
+ const output = stringify({})
190
+
191
+ t.assert.equal(output, '{}')
192
+ t.assert.ok(validate(JSON.parse(output)), 'valid schema')
193
+ })
194
+ })
@@ -0,0 +1,38 @@
1
+ 'use strict'
2
+
3
+ const { test } = require('node:test')
4
+ const build = require('..')
5
+
6
+ // Covers issue #139
7
+ test('Should throw on invalid schema', t => {
8
+ t.plan(1)
9
+ t.assert.throws(() => {
10
+ build({}, {
11
+ schema: {
12
+ invalid: {
13
+ type: 'Dinosaur'
14
+ }
15
+ }
16
+ })
17
+ }, { message: /^"invalid" schema is invalid:.*/ })
18
+ })
19
+
20
+ test('invalid not schema', (t) => {
21
+ t.plan(1)
22
+
23
+ const schema = {
24
+ type: 'object',
25
+ properties: {
26
+ prop: {
27
+ not: 'not object' // invalid, not must be object
28
+ }
29
+ }
30
+ }
31
+
32
+ try {
33
+ build(schema)
34
+ t.assert.fail('Should throw')
35
+ } catch (err) {
36
+ t.assert.ok(err.message.includes('schema is invalid'))
37
+ }
38
+ })
@@ -0,0 +1,57 @@
1
+ 'use strict'
2
+
3
+ const { test } = require('node:test')
4
+ const build = require('..')
5
+
6
+ test('should validate anyOf after allOf merge', (t) => {
7
+ t.plan(1)
8
+
9
+ const schema = {
10
+ $id: 'schema',
11
+ type: 'object',
12
+ allOf: [
13
+ {
14
+ $id: 'base',
15
+ type: 'object',
16
+ properties: {
17
+ name: {
18
+ type: 'string'
19
+ }
20
+ },
21
+ required: [
22
+ 'name'
23
+ ]
24
+ },
25
+ {
26
+ $id: 'inner_schema',
27
+ type: 'object',
28
+ properties: {
29
+ union: {
30
+ $id: '#id',
31
+ anyOf: [
32
+ {
33
+
34
+ $id: 'guid',
35
+ type: 'string'
36
+ },
37
+ {
38
+
39
+ $id: 'email',
40
+ type: 'string'
41
+ }
42
+ ]
43
+ }
44
+ },
45
+ required: [
46
+ 'union'
47
+ ]
48
+ }
49
+ ]
50
+ }
51
+
52
+ const stringify = build(schema)
53
+
54
+ t.assert.equal(
55
+ stringify({ name: 'foo', union: 'a8f1cc50-5530-5c62-9109-5ba9589a6ae1' }),
56
+ '{"name":"foo","union":"a8f1cc50-5530-5c62-9109-5ba9589a6ae1"}')
57
+ })
@@ -0,0 +1,107 @@
1
+ 'use strict'
2
+
3
+ const { test } = require('node:test')
4
+
5
+ const build = require('..')
6
+
7
+ test('serialize string with newlines - issue #793', (t) => {
8
+ t.plan(2)
9
+
10
+ const schema = {
11
+ type: 'object',
12
+ properties: {
13
+ message: {
14
+ type: 'string'
15
+ }
16
+ }
17
+ }
18
+
19
+ const input = {
20
+ message: `This is a string
21
+ with multiple
22
+ newlines in it
23
+ Foo`
24
+ }
25
+
26
+ const stringify = build(schema)
27
+ const output = stringify(input)
28
+
29
+ // The output should be valid JSON
30
+ t.assert.doesNotThrow(() => {
31
+ JSON.parse(output)
32
+ }, 'JSON output should be parseable')
33
+
34
+ // The parsed output should match the input
35
+ const parsed = JSON.parse(output)
36
+ t.assert.equal(parsed.message, input.message)
37
+ })
38
+
39
+ test('serialize string with various newline characters - issue #793', (t) => {
40
+ t.plan(4)
41
+
42
+ const schema = {
43
+ type: 'string'
44
+ }
45
+
46
+ const stringify = build(schema)
47
+
48
+ // Test \n (line feed)
49
+ const inputLF = 'line1\nline2'
50
+ const outputLF = stringify(inputLF)
51
+ t.assert.equal(JSON.parse(outputLF), inputLF)
52
+
53
+ // Test \r (carriage return)
54
+ const inputCR = 'line1\rline2'
55
+ const outputCR = stringify(inputCR)
56
+ t.assert.equal(JSON.parse(outputCR), inputCR)
57
+
58
+ // Test \r\n (CRLF)
59
+ const inputCRLF = 'line1\r\nline2'
60
+ const outputCRLF = stringify(inputCRLF)
61
+ t.assert.equal(JSON.parse(outputCRLF), inputCRLF)
62
+
63
+ // Test mixed newlines
64
+ const inputMixed = 'line1\nline2\rline3\r\nline4'
65
+ const outputMixed = stringify(inputMixed)
66
+ t.assert.equal(JSON.parse(outputMixed), inputMixed)
67
+ })
68
+
69
+ test('serialize object with newlines in multiple properties - issue #793', (t) => {
70
+ t.plan(2)
71
+
72
+ const schema = {
73
+ type: 'object',
74
+ properties: {
75
+ message: {
76
+ type: 'string'
77
+ },
78
+ description: {
79
+ type: 'string'
80
+ },
81
+ timestamp: {
82
+ type: 'string'
83
+ }
84
+ }
85
+ }
86
+
87
+ const input = {
88
+ message: `This is a string
89
+ with multiple
90
+ newlines in it
91
+ Foo`,
92
+ description: 'This JSON response contains a field with newline characters',
93
+ timestamp: new Date().toISOString()
94
+ }
95
+
96
+ const stringify = build(schema)
97
+ const output = stringify(input)
98
+
99
+ // The output should be valid JSON
100
+ t.assert.doesNotThrow(() => {
101
+ JSON.parse(output)
102
+ }, 'JSON output should be parseable')
103
+
104
+ // The parsed output should match the input
105
+ const parsed = JSON.parse(output)
106
+ t.assert.deepEqual(parsed, input)
107
+ })
@@ -0,0 +1,177 @@
1
+ 'use strict'
2
+
3
+ const { test } = require('node:test')
4
+
5
+ const build = require('..')
6
+
7
+ test('serialize string with quotes - issue #794', (t) => {
8
+ t.plan(2)
9
+
10
+ const schema = {
11
+ type: 'object',
12
+ properties: {
13
+ message: {
14
+ type: 'string'
15
+ }
16
+ }
17
+ }
18
+
19
+ const input = {
20
+ message: 'Error: Property "name" is required'
21
+ }
22
+
23
+ const stringify = build(schema)
24
+ const output = stringify(input)
25
+
26
+ // The output should be valid JSON
27
+ t.assert.doesNotThrow(() => {
28
+ JSON.parse(output)
29
+ }, 'JSON output should be parseable')
30
+
31
+ // The parsed output should match the input
32
+ const parsed = JSON.parse(output)
33
+ t.assert.equal(parsed.message, input.message)
34
+ })
35
+
36
+ test('serialize string with various quote types - issue #794', (t) => {
37
+ t.plan(6)
38
+
39
+ const schema = {
40
+ type: 'string'
41
+ }
42
+
43
+ const stringify = build(schema)
44
+
45
+ // Test double quotes
46
+ const inputDoubleQuotes = 'Property "name" is required'
47
+ const outputDoubleQuotes = stringify(inputDoubleQuotes)
48
+ t.assert.doesNotThrow(() => JSON.parse(outputDoubleQuotes))
49
+ t.assert.equal(JSON.parse(outputDoubleQuotes), inputDoubleQuotes)
50
+
51
+ // Test single quotes (should be fine but test for completeness)
52
+ const inputSingleQuotes = "Property 'name' is required"
53
+ const outputSingleQuotes = stringify(inputSingleQuotes)
54
+ t.assert.doesNotThrow(() => JSON.parse(outputSingleQuotes))
55
+ t.assert.equal(JSON.parse(outputSingleQuotes), inputSingleQuotes)
56
+
57
+ // Test mixed quotes
58
+ const inputMixedQuotes = 'Error: "Property \'name\' is required"'
59
+ const outputMixedQuotes = stringify(inputMixedQuotes)
60
+ t.assert.doesNotThrow(() => JSON.parse(outputMixedQuotes))
61
+ t.assert.equal(JSON.parse(outputMixedQuotes), inputMixedQuotes)
62
+ })
63
+
64
+ test('serialize error-like object with quotes in message - issue #794', (t) => {
65
+ t.plan(2)
66
+
67
+ const schema = {
68
+ type: 'object',
69
+ properties: {
70
+ error: {
71
+ type: 'object',
72
+ properties: {
73
+ message: {
74
+ type: 'string'
75
+ },
76
+ code: {
77
+ type: 'string'
78
+ }
79
+ }
80
+ }
81
+ }
82
+ }
83
+
84
+ const input = {
85
+ error: {
86
+ message: 'Validation failed: Property "email" must be a valid email address',
87
+ code: 'VALIDATION_ERROR'
88
+ }
89
+ }
90
+
91
+ const stringify = build(schema)
92
+ const output = stringify(input)
93
+
94
+ // The output should be valid JSON
95
+ t.assert.doesNotThrow(() => {
96
+ JSON.parse(output)
97
+ }, 'JSON output should be parseable')
98
+
99
+ // The parsed output should match the input
100
+ const parsed = JSON.parse(output)
101
+ t.assert.deepEqual(parsed, input)
102
+ })
103
+
104
+ test('serialize validation errors array with quotes - issue #794', (t) => {
105
+ t.plan(2)
106
+
107
+ const schema = {
108
+ type: 'object',
109
+ properties: {
110
+ errors: {
111
+ type: 'array',
112
+ items: {
113
+ type: 'object',
114
+ properties: {
115
+ message: {
116
+ type: 'string'
117
+ },
118
+ field: {
119
+ type: 'string'
120
+ }
121
+ }
122
+ }
123
+ }
124
+ }
125
+ }
126
+
127
+ const input = {
128
+ errors: [
129
+ {
130
+ message: 'Property "name" is required',
131
+ field: 'name'
132
+ },
133
+ {
134
+ message: 'Property "email" must be a valid email address',
135
+ field: 'email'
136
+ },
137
+ {
138
+ message: 'Value must be between "1" and "100"',
139
+ field: 'age'
140
+ }
141
+ ]
142
+ }
143
+
144
+ const stringify = build(schema)
145
+ const output = stringify(input)
146
+
147
+ // The output should be valid JSON
148
+ t.assert.doesNotThrow(() => {
149
+ JSON.parse(output)
150
+ }, 'JSON output should be parseable')
151
+
152
+ // The parsed output should match the input
153
+ const parsed = JSON.parse(output)
154
+ t.assert.deepEqual(parsed, input)
155
+ })
156
+
157
+ test('serialize string with backslashes and quotes - issue #794', (t) => {
158
+ t.plan(4)
159
+
160
+ const schema = {
161
+ type: 'string'
162
+ }
163
+
164
+ const stringify = build(schema)
165
+
166
+ // Test backslashes
167
+ const inputBackslash = 'Path: C:\\Users\\test\\file.json'
168
+ const outputBackslash = stringify(inputBackslash)
169
+ t.assert.doesNotThrow(() => JSON.parse(outputBackslash))
170
+ t.assert.equal(JSON.parse(outputBackslash), inputBackslash)
171
+
172
+ // Test combination of backslashes and quotes
173
+ const inputMixed = 'Error: Could not find file "C:\\Users\\test\\config.json"'
174
+ const outputMixed = stringify(inputMixed)
175
+ t.assert.doesNotThrow(() => JSON.parse(outputMixed))
176
+ t.assert.equal(JSON.parse(outputMixed), inputMixed)
177
+ })