@zuplo/cli 6.71.23 → 6.71.25

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (128) hide show
  1. package/node_modules/@fastify/fast-json-stringify-compiler/.github/dependabot.yml +42 -2
  2. package/node_modules/@fastify/fast-json-stringify-compiler/.github/workflows/ci.yml +6 -1
  3. package/node_modules/@fastify/fast-json-stringify-compiler/.github/workflows/lock-threads.yml +19 -0
  4. package/node_modules/@fastify/fast-json-stringify-compiler/LICENSE +1 -1
  5. package/node_modules/@fastify/fast-json-stringify-compiler/README.md +1 -1
  6. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/.gitattributes +2 -0
  7. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/.github/dependabot.yml +13 -0
  8. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/.github/workflows/ci.yml +33 -0
  9. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/.github/workflows/lock-threads.yml +19 -0
  10. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/LICENSE +22 -0
  11. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/README.md +742 -0
  12. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/benchmark/bench-cmp-branch.js +116 -0
  13. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/benchmark/bench-cmp-lib.js +339 -0
  14. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/benchmark/bench-thread.js +33 -0
  15. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/benchmark/bench.js +391 -0
  16. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/build/build-schema-validator.js +26 -0
  17. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/eslint.config.js +9 -0
  18. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/examples/example.js +81 -0
  19. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/examples/server.js +42 -0
  20. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/index.js +1308 -0
  21. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/lib/location.js +24 -0
  22. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/lib/merge-schemas.js +9 -0
  23. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/lib/schema-validator.js +1134 -0
  24. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/lib/serializer.js +141 -0
  25. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/lib/standalone.js +34 -0
  26. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/lib/validator.js +96 -0
  27. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/package.json +89 -0
  28. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/additionalProperties.test.js +332 -0
  29. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/allof.test.js +751 -0
  30. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/any.test.js +231 -0
  31. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/anyof.test.js +812 -0
  32. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/array.test.js +688 -0
  33. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/asNumber.test.js +13 -0
  34. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/basic.test.js +400 -0
  35. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/bigint.test.js +76 -0
  36. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/clean-cache.test.js +47 -0
  37. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/const.test.js +314 -0
  38. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/date.test.js +639 -0
  39. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/debug-mode.test.js +130 -0
  40. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/defaults.test.js +376 -0
  41. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/enum.test.js +37 -0
  42. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/fix-604.test.js +25 -0
  43. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/fixtures/.keep +0 -0
  44. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/if-then-else.test.js +540 -0
  45. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/inferType.test.js +92 -0
  46. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/infinity.test.js +55 -0
  47. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/integer.test.js +194 -0
  48. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/invalidSchema.test.js +38 -0
  49. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/issue-479.test.js +57 -0
  50. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/issue-793.test.js +107 -0
  51. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/issue-794.test.js +177 -0
  52. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/issue-836.test.js +183 -0
  53. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/json-add-comma.test.js +57 -0
  54. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/json-schema-test-suite/README.md +10 -0
  55. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/json-schema-test-suite/draft4/required.json +54 -0
  56. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/json-schema-test-suite/draft4.test.js +12 -0
  57. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/json-schema-test-suite/draft6/required.json +70 -0
  58. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/json-schema-test-suite/draft6.test.js +12 -0
  59. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/json-schema-test-suite/draft7/required.json +70 -0
  60. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/json-schema-test-suite/draft7.test.js +12 -0
  61. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/json-schema-test-suite/util.js +31 -0
  62. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/missing-values.test.js +88 -0
  63. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/multi-type-serializer.test.js +19 -0
  64. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/nestedObjects.test.js +63 -0
  65. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/nullable.test.js +543 -0
  66. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/oneof.test.js +510 -0
  67. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/patternProperties.test.js +168 -0
  68. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/recursion.test.js +245 -0
  69. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/ref.json +12 -0
  70. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/ref.test.js +2077 -0
  71. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/regex.test.js +32 -0
  72. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/required.test.js +204 -0
  73. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/requiresAjv.test.js +50 -0
  74. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/sanitize.test.js +141 -0
  75. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/sanitize2.test.js +18 -0
  76. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/sanitize3.test.js +17 -0
  77. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/sanitize4.test.js +16 -0
  78. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/sanitize5.test.js +16 -0
  79. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/sanitize6.test.js +22 -0
  80. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/sanitize7.test.js +68 -0
  81. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/side-effect.test.js +196 -0
  82. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/standalone-mode.test.js +219 -0
  83. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/string.test.js +84 -0
  84. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/surrogate.test.js +67 -0
  85. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/toJSON.test.js +203 -0
  86. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/typebox.test.js +36 -0
  87. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/typesArray.test.js +550 -0
  88. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/unknownFormats.test.js +27 -0
  89. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/webpack.test.js +50 -0
  90. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/types/index.d.ts +219 -0
  91. package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/types/index.tst.ts +259 -0
  92. package/node_modules/@fastify/fast-json-stringify-compiler/package.json +6 -11
  93. package/node_modules/@fastify/fast-json-stringify-compiler/types/{index.test-d.ts → index.tst.ts} +34 -32
  94. package/node_modules/@protobufjs/utf8/CHANGELOG.md +8 -0
  95. package/node_modules/@protobufjs/utf8/index.js +29 -18
  96. package/node_modules/@protobufjs/utf8/package.json +2 -2
  97. package/node_modules/@protobufjs/utf8/tests/index.js +5 -0
  98. package/node_modules/@zuplo/core/package.json +1 -1
  99. package/node_modules/@zuplo/graphql/package.json +1 -1
  100. package/node_modules/@zuplo/openapi-tools/package.json +1 -1
  101. package/node_modules/@zuplo/otel/package.json +1 -1
  102. package/node_modules/@zuplo/runtime/out/esm/{chunk-5CYWMN74.js → chunk-MJWTZPC2.js} +90 -90
  103. package/node_modules/@zuplo/runtime/out/esm/chunk-MJWTZPC2.js.map +1 -0
  104. package/node_modules/@zuplo/runtime/out/esm/index.js +1 -1
  105. package/node_modules/@zuplo/runtime/out/esm/index.js.map +1 -1
  106. package/node_modules/@zuplo/runtime/out/esm/mcp-gateway/index.js +1 -1
  107. package/node_modules/@zuplo/runtime/out/types/index.d.ts +154 -0
  108. package/node_modules/@zuplo/runtime/package.json +1 -1
  109. package/node_modules/hono/dist/adapter/aws-lambda/handler.js +1 -1
  110. package/node_modules/hono/dist/adapter/bun/websocket.js +3 -1
  111. package/node_modules/hono/dist/cjs/adapter/aws-lambda/handler.js +1 -1
  112. package/node_modules/hono/dist/cjs/adapter/bun/websocket.js +3 -1
  113. package/node_modules/hono/dist/cjs/middleware/serve-static/index.js +1 -1
  114. package/node_modules/hono/dist/cjs/utils/body.js +12 -4
  115. package/node_modules/hono/dist/cjs/utils/buffer.js +2 -1
  116. package/node_modules/hono/dist/cjs/validator/validator.js +3 -3
  117. package/node_modules/hono/dist/middleware/serve-static/index.js +1 -1
  118. package/node_modules/hono/dist/types/middleware/context-storage/index.d.ts +2 -2
  119. package/node_modules/hono/dist/types/utils/body.d.ts +1 -1
  120. package/node_modules/hono/dist/utils/body.js +12 -4
  121. package/node_modules/hono/dist/utils/buffer.js +2 -1
  122. package/node_modules/hono/dist/validator/validator.js +3 -3
  123. package/node_modules/hono/package.json +8 -7
  124. package/package.json +6 -6
  125. package/node_modules/@fastify/fast-json-stringify-compiler/.eslintrc +0 -1
  126. package/node_modules/@zuplo/runtime/out/esm/chunk-5CYWMN74.js.map +0 -1
  127. package/node_modules/hono/dist/tsconfig.build.tsbuildinfo +0 -1
  128. /package/node_modules/@zuplo/runtime/out/esm/{chunk-5CYWMN74.js.LEGAL.txt → chunk-MJWTZPC2.js.LEGAL.txt} +0 -0
@@ -0,0 +1,130 @@
1
+ 'use strict'
2
+
3
+ const { test } = require('node:test')
4
+ const fjs = require('..')
5
+
6
+ const Ajv = require('ajv').default
7
+ const Validator = require('../lib/validator')
8
+ const Serializer = require('../lib/serializer')
9
+
10
+ function build (opts) {
11
+ return fjs({
12
+ title: 'default string',
13
+ type: 'object',
14
+ properties: {
15
+ firstName: {
16
+ type: 'string'
17
+ }
18
+ },
19
+ required: ['firstName']
20
+ }, opts)
21
+ }
22
+
23
+ test('activate debug mode', t => {
24
+ t.plan(5)
25
+ const debugMode = build({ mode: 'debug' })
26
+
27
+ t.assert.ok(typeof debugMode === 'object')
28
+ t.assert.ok(debugMode.ajv instanceof Ajv)
29
+ t.assert.ok(debugMode.validator instanceof Validator)
30
+ t.assert.ok(debugMode.serializer instanceof Serializer)
31
+ t.assert.ok(typeof debugMode.code === 'string')
32
+ })
33
+
34
+ test('to string auto-consistent', t => {
35
+ t.plan(6)
36
+ const debugMode = build({ mode: 'debug' })
37
+
38
+ t.assert.ok(typeof debugMode === 'object')
39
+ t.assert.ok(typeof debugMode.code === 'string')
40
+ t.assert.ok(debugMode.ajv instanceof Ajv)
41
+ t.assert.ok(debugMode.serializer instanceof Serializer)
42
+ t.assert.ok(debugMode.validator instanceof Validator)
43
+
44
+ const compiled = fjs.restore(debugMode)
45
+ const tobe = JSON.stringify({ firstName: 'Foo' })
46
+ t.assert.equal(compiled({ firstName: 'Foo', surname: 'bar' }), tobe, 'surname evicted')
47
+ })
48
+
49
+ test('to string auto-consistent with ajv', t => {
50
+ t.plan(6)
51
+
52
+ const debugMode = fjs({
53
+ title: 'object with multiple types field',
54
+ type: 'object',
55
+ properties: {
56
+ str: {
57
+ anyOf: [{
58
+ type: 'string'
59
+ }, {
60
+ type: 'boolean'
61
+ }]
62
+ }
63
+ }
64
+ }, { mode: 'debug' })
65
+
66
+ t.assert.ok(typeof debugMode === 'object')
67
+ t.assert.ok(typeof debugMode.code === 'string')
68
+ t.assert.ok(debugMode.ajv instanceof Ajv)
69
+ t.assert.ok(debugMode.validator instanceof Validator)
70
+ t.assert.ok(debugMode.serializer instanceof Serializer)
71
+
72
+ const compiled = fjs.restore(debugMode)
73
+ const tobe = JSON.stringify({ str: 'Foo' })
74
+ t.assert.equal(compiled({ str: 'Foo', void: 'me' }), tobe)
75
+ })
76
+
77
+ test('to string auto-consistent with ajv-formats', t => {
78
+ t.plan(3)
79
+
80
+ const debugMode = fjs({
81
+ title: 'object with multiple types field and format keyword',
82
+ type: 'object',
83
+ properties: {
84
+ str: {
85
+ anyOf: [{
86
+ type: 'string',
87
+ format: 'email'
88
+ }, {
89
+ type: 'boolean'
90
+ }]
91
+ }
92
+ }
93
+ }, { mode: 'debug' })
94
+
95
+ t.assert.ok(typeof debugMode === 'object')
96
+
97
+ const compiled = fjs.restore(debugMode)
98
+ const tobe = JSON.stringify({ str: 'foo@bar.com' })
99
+ t.assert.equal(compiled({ str: 'foo@bar.com' }), tobe)
100
+ t.assert.throws(() => compiled({ str: 'foo' }))
101
+ })
102
+
103
+ test('debug should restore the same serializer instance', t => {
104
+ t.plan(1)
105
+
106
+ const debugMode = fjs({ type: 'integer' }, { mode: 'debug', rounding: 'ceil' })
107
+ const compiled = fjs.restore(debugMode)
108
+ t.assert.equal(compiled(3.95), 4)
109
+ })
110
+
111
+ test('Serializer restoreFromState', t => {
112
+ t.plan(1)
113
+
114
+ const Serializer = require('../lib/serializer')
115
+ const serializer = new Serializer()
116
+ const state = serializer.getState()
117
+ const restored = Serializer.restoreFromState(state)
118
+ t.assert.ok(restored instanceof Serializer)
119
+ })
120
+
121
+ test('Validator restoreFromState', t => {
122
+ t.plan(1)
123
+
124
+ const Validator = require('../lib/validator')
125
+ const validator = new Validator()
126
+ validator.addSchema({ type: 'string' }, 'test')
127
+ const state = validator.getState()
128
+ const restored = Validator.restoreFromState(state)
129
+ t.assert.ok(restored instanceof Validator)
130
+ })
@@ -0,0 +1,376 @@
1
+ 'use strict'
2
+
3
+ const { test } = require('node:test')
4
+ const build = require('..')
5
+
6
+ function buildTest (schema, toStringify, expected) {
7
+ test(`render a ${schema.title} with default as JSON`, (t) => {
8
+ t.plan(1)
9
+
10
+ const stringify = build(schema)
11
+
12
+ const output = stringify(toStringify)
13
+
14
+ t.assert.equal(output, JSON.stringify(expected))
15
+ })
16
+ }
17
+
18
+ buildTest({
19
+ title: 'default string',
20
+ type: 'object',
21
+ properties: {
22
+ firstName: {
23
+ type: 'string'
24
+ },
25
+ lastName: {
26
+ type: 'string',
27
+ default: 'Collina'
28
+ },
29
+ age: {
30
+ description: 'Age in years',
31
+ type: 'integer',
32
+ minimum: 0
33
+ },
34
+ magic: {
35
+ type: 'number'
36
+ }
37
+ },
38
+ required: ['firstName', 'lastName']
39
+ }, {
40
+ firstName: 'Matteo',
41
+ magic: 42,
42
+ age: 32
43
+ }, {
44
+ firstName: 'Matteo',
45
+ lastName: 'Collina',
46
+ age: 32,
47
+ magic: 42
48
+ })
49
+
50
+ buildTest({
51
+ title: 'default string with value',
52
+ type: 'object',
53
+ properties: {
54
+ firstName: {
55
+ type: 'string'
56
+ },
57
+ lastName: {
58
+ type: 'string',
59
+ default: 'Collina'
60
+ },
61
+ age: {
62
+ description: 'Age in years',
63
+ type: 'integer',
64
+ minimum: 0
65
+ },
66
+ magic: {
67
+ type: 'number'
68
+ }
69
+ },
70
+ required: ['firstName', 'lastName']
71
+ }, {
72
+ firstName: 'Matteo',
73
+ lastName: 'collina',
74
+ magic: 42,
75
+ age: 32
76
+ }, {
77
+ firstName: 'Matteo',
78
+ lastName: 'collina',
79
+ age: 32,
80
+ magic: 42
81
+ })
82
+
83
+ buildTest({
84
+ title: 'default number',
85
+ type: 'object',
86
+ properties: {
87
+ firstName: {
88
+ type: 'string'
89
+ },
90
+ lastName: {
91
+ type: 'string'
92
+ },
93
+ age: {
94
+ description: 'Age in years',
95
+ type: 'integer',
96
+ minimum: 0
97
+ },
98
+ magic: {
99
+ type: 'number',
100
+ default: 42
101
+ }
102
+ },
103
+ required: ['firstName', 'lastName']
104
+ }, {
105
+ firstName: 'Matteo',
106
+ lastName: 'Collina',
107
+ age: 32
108
+ }, {
109
+ firstName: 'Matteo',
110
+ lastName: 'Collina',
111
+ age: 32,
112
+ magic: 42
113
+ })
114
+
115
+ buildTest({
116
+ title: 'default number with value',
117
+ type: 'object',
118
+ properties: {
119
+ firstName: {
120
+ type: 'string'
121
+ },
122
+ lastName: {
123
+ type: 'string'
124
+ },
125
+ age: {
126
+ description: 'Age in years',
127
+ type: 'integer',
128
+ minimum: 0
129
+ },
130
+ magic: {
131
+ type: 'number',
132
+ default: 42
133
+ }
134
+ },
135
+ required: ['firstName', 'lastName']
136
+ }, {
137
+ firstName: 'Matteo',
138
+ lastName: 'Collina',
139
+ age: 32,
140
+ magic: 66
141
+ }, {
142
+ firstName: 'Matteo',
143
+ lastName: 'Collina',
144
+ age: 32,
145
+ magic: 66
146
+ })
147
+
148
+ buildTest({
149
+ title: 'default object',
150
+ type: 'object',
151
+ properties: {
152
+ firstName: {
153
+ type: 'string'
154
+ },
155
+ lastName: {
156
+ type: 'string'
157
+ },
158
+ age: {
159
+ description: 'Age in years',
160
+ type: 'integer',
161
+ minimum: 0
162
+ },
163
+ otherProps: {
164
+ type: 'object',
165
+ default: { foo: 'bar' }
166
+ }
167
+ },
168
+ required: ['firstName', 'lastName']
169
+ }, {
170
+ firstName: 'Matteo',
171
+ lastName: 'Collina',
172
+ age: 32
173
+ }, {
174
+ firstName: 'Matteo',
175
+ lastName: 'Collina',
176
+ age: 32,
177
+ otherProps: { foo: 'bar' }
178
+ })
179
+
180
+ buildTest({
181
+ title: 'default object with value',
182
+ type: 'object',
183
+ properties: {
184
+ firstName: {
185
+ type: 'string'
186
+ },
187
+ lastName: {
188
+ type: 'string'
189
+ },
190
+ age: {
191
+ description: 'Age in years',
192
+ type: 'integer',
193
+ minimum: 0
194
+ },
195
+ otherProps: {
196
+ type: 'object',
197
+ additionalProperties: true,
198
+ default: { foo: 'bar' }
199
+ }
200
+ },
201
+ required: ['firstName', 'lastName']
202
+ }, {
203
+ firstName: 'Matteo',
204
+ lastName: 'Collina',
205
+ age: 32,
206
+ otherProps: { hello: 'world' }
207
+ }, {
208
+ firstName: 'Matteo',
209
+ lastName: 'Collina',
210
+ age: 32,
211
+ otherProps: { hello: 'world' }
212
+ })
213
+
214
+ buildTest({
215
+ title: 'default array',
216
+ type: 'object',
217
+ properties: {
218
+ firstName: {
219
+ type: 'string'
220
+ },
221
+ lastName: {
222
+ type: 'string'
223
+ },
224
+ age: {
225
+ description: 'Age in years',
226
+ type: 'integer',
227
+ minimum: 0
228
+ },
229
+ otherProps: {
230
+ type: 'array',
231
+ items: { type: 'string' },
232
+ default: ['FOO']
233
+ }
234
+ },
235
+ required: ['firstName', 'lastName']
236
+ }, {
237
+ firstName: 'Matteo',
238
+ lastName: 'Collina',
239
+ age: 32
240
+ }, {
241
+ firstName: 'Matteo',
242
+ lastName: 'Collina',
243
+ age: 32,
244
+ otherProps: ['FOO']
245
+ })
246
+
247
+ buildTest({
248
+ title: 'default array with value',
249
+ type: 'object',
250
+ properties: {
251
+ firstName: {
252
+ type: 'string'
253
+ },
254
+ lastName: {
255
+ type: 'string'
256
+ },
257
+ age: {
258
+ description: 'Age in years',
259
+ type: 'integer',
260
+ minimum: 0
261
+ },
262
+ otherProps: {
263
+ type: 'array',
264
+ items: { type: 'string' },
265
+ default: ['FOO']
266
+ }
267
+ },
268
+ required: ['firstName', 'lastName']
269
+ }, {
270
+ firstName: 'Matteo',
271
+ lastName: 'Collina',
272
+ age: 32,
273
+ otherProps: ['BAR']
274
+ }, {
275
+ firstName: 'Matteo',
276
+ lastName: 'Collina',
277
+ age: 32,
278
+ otherProps: ['BAR']
279
+ })
280
+
281
+ buildTest({
282
+ title: 'default deeper value',
283
+ type: 'object',
284
+ properties: {
285
+ level1: {
286
+ type: 'object',
287
+ properties: {
288
+ level2: {
289
+ type: 'object',
290
+ properties: {
291
+ level3: {
292
+ type: 'object',
293
+ properties: {
294
+ level4: {
295
+ type: 'object',
296
+ default: { foo: 'bar' }
297
+ }
298
+ }
299
+ }
300
+ }
301
+ }
302
+ }
303
+ }
304
+ }
305
+ }, {
306
+ level1: { level2: { level3: { } } }
307
+ }, {
308
+ level1: { level2: { level3: { level4: { foo: 'bar' } } } }
309
+ })
310
+
311
+ buildTest({
312
+ title: 'default deeper value with value',
313
+ type: 'object',
314
+ properties: {
315
+ level1: {
316
+ type: 'object',
317
+ properties: {
318
+ level2: {
319
+ type: 'object',
320
+ properties: {
321
+ level3: {
322
+ type: 'object',
323
+ properties: {
324
+ level4: {
325
+ type: 'object',
326
+ default: { foo: 'bar' }
327
+ }
328
+ }
329
+ }
330
+ }
331
+ }
332
+ }
333
+ }
334
+ }
335
+ }, {
336
+ level1: { level2: { level3: { level4: { } } } }
337
+ }, {
338
+ level1: { level2: { level3: { level4: { } } } }
339
+ })
340
+
341
+ buildTest({
342
+ type: 'object',
343
+ properties: {
344
+ name: {
345
+ type: 'string',
346
+ default: 'foo'
347
+ },
348
+ dev: {
349
+ type: 'boolean',
350
+ default: false
351
+ }
352
+ },
353
+ required: [
354
+ 'name', 'dev'
355
+ ]
356
+ }, {}, { name: 'foo', dev: false })
357
+
358
+ buildTest({
359
+ type: 'object',
360
+ properties: {
361
+ name: {
362
+ type: 'string',
363
+ default: 'foo'
364
+ },
365
+ dev: {
366
+ type: 'boolean'
367
+ },
368
+ job: {
369
+ type: 'string',
370
+ default: 'awesome'
371
+ }
372
+ },
373
+ required: [
374
+ 'name', 'dev'
375
+ ]
376
+ }, { dev: true }, { name: 'foo', dev: true, job: 'awesome' })
@@ -0,0 +1,37 @@
1
+ 'use strict'
2
+
3
+ const { test } = require('node:test')
4
+ const build = require('..')
5
+
6
+ test('use enum without type', (t) => {
7
+ t.plan(1)
8
+ const stringify = build({
9
+ title: 'Example Schema',
10
+ type: 'object',
11
+ properties: {
12
+ order: {
13
+ type: 'string',
14
+ enum: ['asc', 'desc']
15
+ }
16
+ }
17
+ })
18
+
19
+ const obj = { order: 'asc' }
20
+ t.assert.equal('{"order":"asc"}', stringify(obj))
21
+ })
22
+
23
+ test('use enum without type', (t) => {
24
+ t.plan(1)
25
+ const stringify = build({
26
+ title: 'Example Schema',
27
+ type: 'object',
28
+ properties: {
29
+ order: {
30
+ enum: ['asc', 'desc']
31
+ }
32
+ }
33
+ })
34
+
35
+ const obj = { order: 'asc' }
36
+ t.assert.equal('{"order":"asc"}', stringify(obj))
37
+ })
@@ -0,0 +1,25 @@
1
+ 'use strict'
2
+
3
+ const { test } = require('node:test')
4
+ const fjs = require('..')
5
+
6
+ test('fix-604', t => {
7
+ const schema = {
8
+ type: 'object',
9
+ properties: {
10
+ fullName: { type: 'string' },
11
+ phone: { type: 'number' }
12
+ }
13
+ }
14
+
15
+ const input = {
16
+ fullName: 'Jone',
17
+ phone: 'phone'
18
+ }
19
+
20
+ const render = fjs(schema)
21
+
22
+ t.assert.throws(() => {
23
+ render(input)
24
+ }, { message: 'The value "phone" cannot be converted to a number.' })
25
+ })