@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.
- package/node_modules/@fastify/fast-json-stringify-compiler/.github/dependabot.yml +42 -2
- package/node_modules/@fastify/fast-json-stringify-compiler/.github/workflows/ci.yml +6 -1
- package/node_modules/@fastify/fast-json-stringify-compiler/.github/workflows/lock-threads.yml +19 -0
- package/node_modules/@fastify/fast-json-stringify-compiler/LICENSE +1 -1
- package/node_modules/@fastify/fast-json-stringify-compiler/README.md +1 -1
- package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/.gitattributes +2 -0
- package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/.github/dependabot.yml +13 -0
- package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/.github/workflows/ci.yml +33 -0
- package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/.github/workflows/lock-threads.yml +19 -0
- package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/LICENSE +22 -0
- package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/README.md +742 -0
- package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/benchmark/bench-cmp-branch.js +116 -0
- package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/benchmark/bench-cmp-lib.js +339 -0
- package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/benchmark/bench-thread.js +33 -0
- package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/benchmark/bench.js +391 -0
- package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/build/build-schema-validator.js +26 -0
- package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/eslint.config.js +9 -0
- package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/examples/example.js +81 -0
- package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/examples/server.js +42 -0
- package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/index.js +1308 -0
- package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/lib/location.js +24 -0
- package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/lib/merge-schemas.js +9 -0
- package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/lib/schema-validator.js +1134 -0
- package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/lib/serializer.js +141 -0
- package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/lib/standalone.js +34 -0
- package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/lib/validator.js +96 -0
- package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/package.json +89 -0
- package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/additionalProperties.test.js +332 -0
- package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/allof.test.js +751 -0
- package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/any.test.js +231 -0
- package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/anyof.test.js +812 -0
- package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/array.test.js +688 -0
- package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/asNumber.test.js +13 -0
- package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/basic.test.js +400 -0
- package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/bigint.test.js +76 -0
- package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/clean-cache.test.js +47 -0
- package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/const.test.js +314 -0
- package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/date.test.js +639 -0
- package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/debug-mode.test.js +130 -0
- package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/defaults.test.js +376 -0
- package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/enum.test.js +37 -0
- package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/fix-604.test.js +25 -0
- package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/fixtures/.keep +0 -0
- package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/if-then-else.test.js +540 -0
- package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/inferType.test.js +92 -0
- package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/infinity.test.js +55 -0
- package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/integer.test.js +194 -0
- package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/invalidSchema.test.js +38 -0
- package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/issue-479.test.js +57 -0
- package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/issue-793.test.js +107 -0
- package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/issue-794.test.js +177 -0
- package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/issue-836.test.js +183 -0
- package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/json-add-comma.test.js +57 -0
- package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/json-schema-test-suite/README.md +10 -0
- package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/json-schema-test-suite/draft4/required.json +54 -0
- package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/json-schema-test-suite/draft4.test.js +12 -0
- package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/json-schema-test-suite/draft6/required.json +70 -0
- package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/json-schema-test-suite/draft6.test.js +12 -0
- package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/json-schema-test-suite/draft7/required.json +70 -0
- package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/json-schema-test-suite/draft7.test.js +12 -0
- package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/json-schema-test-suite/util.js +31 -0
- package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/missing-values.test.js +88 -0
- package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/multi-type-serializer.test.js +19 -0
- package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/nestedObjects.test.js +63 -0
- package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/nullable.test.js +543 -0
- package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/oneof.test.js +510 -0
- package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/patternProperties.test.js +168 -0
- package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/recursion.test.js +245 -0
- package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/ref.json +12 -0
- package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/ref.test.js +2077 -0
- package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/regex.test.js +32 -0
- package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/required.test.js +204 -0
- package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/requiresAjv.test.js +50 -0
- package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/sanitize.test.js +141 -0
- package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/sanitize2.test.js +18 -0
- package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/sanitize3.test.js +17 -0
- package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/sanitize4.test.js +16 -0
- package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/sanitize5.test.js +16 -0
- package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/sanitize6.test.js +22 -0
- package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/sanitize7.test.js +68 -0
- package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/side-effect.test.js +196 -0
- package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/standalone-mode.test.js +219 -0
- package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/string.test.js +84 -0
- package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/surrogate.test.js +67 -0
- package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/toJSON.test.js +203 -0
- package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/typebox.test.js +36 -0
- package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/typesArray.test.js +550 -0
- package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/unknownFormats.test.js +27 -0
- package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/test/webpack.test.js +50 -0
- package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/types/index.d.ts +219 -0
- package/node_modules/@fastify/fast-json-stringify-compiler/node_modules/fast-json-stringify/types/index.tst.ts +259 -0
- package/node_modules/@fastify/fast-json-stringify-compiler/package.json +6 -11
- package/node_modules/@fastify/fast-json-stringify-compiler/types/{index.test-d.ts → index.tst.ts} +34 -32
- package/node_modules/@posthog/core/dist/posthog-core-stateless.d.ts +5 -0
- package/node_modules/@posthog/core/dist/posthog-core-stateless.d.ts.map +1 -1
- package/node_modules/@posthog/core/dist/posthog-core-stateless.js +50 -10
- package/node_modules/@posthog/core/dist/posthog-core-stateless.mjs +47 -10
- package/node_modules/@posthog/core/dist/posthog-core.d.ts +2 -2
- package/node_modules/@posthog/core/dist/posthog-core.d.ts.map +1 -1
- package/node_modules/@posthog/core/dist/posthog-core.js +10 -6
- package/node_modules/@posthog/core/dist/posthog-core.mjs +11 -7
- package/node_modules/@posthog/core/dist/testing/PostHogCoreTestClient.d.ts +1 -0
- package/node_modules/@posthog/core/dist/testing/PostHogCoreTestClient.d.ts.map +1 -1
- package/node_modules/@posthog/core/dist/testing/PostHogCoreTestClient.js +3 -0
- package/node_modules/@posthog/core/dist/testing/PostHogCoreTestClient.mjs +3 -0
- package/node_modules/@posthog/core/dist/utils/promise-queue.d.ts +3 -0
- package/node_modules/@posthog/core/dist/utils/promise-queue.d.ts.map +1 -1
- package/node_modules/@posthog/core/dist/utils/promise-queue.js +15 -3
- package/node_modules/@posthog/core/dist/utils/promise-queue.mjs +15 -3
- package/node_modules/@posthog/core/package.json +1 -1
- package/node_modules/@posthog/core/src/posthog-core-stateless.ts +80 -14
- package/node_modules/@posthog/core/src/posthog-core.ts +18 -7
- package/node_modules/@posthog/core/src/testing/PostHogCoreTestClient.ts +4 -0
- package/node_modules/@posthog/core/src/utils/promise-queue.ts +17 -4
- package/node_modules/@posthog/types/dist/posthog.d.ts +12 -0
- package/node_modules/@posthog/types/dist/posthog.d.ts.map +1 -1
- package/node_modules/@posthog/types/package.json +1 -1
- package/node_modules/@posthog/types/src/posthog.ts +13 -0
- package/node_modules/@protobufjs/utf8/CHANGELOG.md +8 -0
- package/node_modules/@protobufjs/utf8/index.js +29 -18
- package/node_modules/@protobufjs/utf8/package.json +2 -2
- package/node_modules/@protobufjs/utf8/tests/index.js +5 -0
- package/node_modules/@types/node/README.md +1 -1
- package/node_modules/@types/node/buffer.d.ts +64 -25
- package/node_modules/@types/node/crypto.d.ts +18 -5
- package/node_modules/@types/node/diagnostics_channel.d.ts +237 -3
- package/node_modules/@types/node/dns.d.ts +1 -1
- package/node_modules/@types/node/ffi.d.ts +486 -0
- package/node_modules/@types/node/fs/promises.d.ts +3 -0
- package/node_modules/@types/node/fs.d.ts +21 -6
- package/node_modules/@types/node/http.d.ts +25 -0
- package/node_modules/@types/node/index.d.ts +1 -0
- package/node_modules/@types/node/package.json +2 -2
- package/node_modules/@types/node/process.d.ts +14 -1
- package/node_modules/@types/node/quic.d.ts +92 -11
- package/node_modules/@types/node/sqlite.d.ts +55 -0
- package/node_modules/@types/node/stream/iter.d.ts +150 -0
- package/node_modules/@types/node/stream.d.ts +32 -0
- package/node_modules/@types/node/test.d.ts +112 -2
- package/node_modules/@types/node/ts5.6/index.d.ts +1 -0
- package/node_modules/@types/node/ts5.7/index.d.ts +1 -0
- package/node_modules/@types/node/util.d.ts +19 -2
- package/node_modules/@types/node/v8.d.ts +84 -2
- package/node_modules/@types/node/worker_threads.d.ts +8 -7
- package/node_modules/@zuplo/core/package.json +1 -1
- package/node_modules/@zuplo/graphql/out/esm/index.js +11 -11
- package/node_modules/@zuplo/graphql/out/esm/index.js.map +1 -1
- package/node_modules/@zuplo/graphql/package.json +1 -1
- package/node_modules/@zuplo/openapi-tools/package.json +1 -1
- package/node_modules/@zuplo/otel/package.json +1 -1
- package/node_modules/@zuplo/runtime/out/esm/{chunk-54PA7VDV.js → chunk-4QJJMELB.js} +1 -1
- package/node_modules/@zuplo/runtime/out/esm/{chunk-54PA7VDV.js.map → chunk-4QJJMELB.js.map} +1 -1
- package/node_modules/@zuplo/runtime/out/esm/chunk-MJWTZPC2.js +402 -0
- package/node_modules/@zuplo/runtime/out/esm/chunk-MJWTZPC2.js.map +1 -0
- package/node_modules/@zuplo/runtime/out/esm/index.js +1 -1
- package/node_modules/@zuplo/runtime/out/esm/index.js.map +1 -1
- package/node_modules/@zuplo/runtime/out/esm/mcp-gateway/index.js +7 -7
- package/node_modules/@zuplo/runtime/out/esm/mcp-gateway/index.js.map +1 -1
- package/node_modules/@zuplo/runtime/out/esm/mocks/index.js +1 -1
- package/node_modules/@zuplo/runtime/out/types/index.d.ts +263 -19
- package/node_modules/@zuplo/runtime/out/types/mcp-gateway/index.d.ts +33 -7
- package/node_modules/@zuplo/runtime/package.json +1 -1
- package/node_modules/hono/dist/adapter/aws-lambda/handler.js +1 -1
- package/node_modules/hono/dist/adapter/bun/websocket.js +3 -1
- package/node_modules/hono/dist/cjs/adapter/aws-lambda/handler.js +1 -1
- package/node_modules/hono/dist/cjs/adapter/bun/websocket.js +3 -1
- package/node_modules/hono/dist/cjs/middleware/serve-static/index.js +1 -1
- package/node_modules/hono/dist/cjs/utils/body.js +12 -4
- package/node_modules/hono/dist/cjs/utils/buffer.js +2 -1
- package/node_modules/hono/dist/cjs/validator/validator.js +3 -3
- package/node_modules/hono/dist/middleware/serve-static/index.js +1 -1
- package/node_modules/hono/dist/types/middleware/context-storage/index.d.ts +2 -2
- package/node_modules/hono/dist/types/utils/body.d.ts +1 -1
- package/node_modules/hono/dist/utils/body.js +12 -4
- package/node_modules/hono/dist/utils/buffer.js +2 -1
- package/node_modules/hono/dist/validator/validator.js +3 -3
- package/node_modules/hono/package.json +8 -7
- package/node_modules/iconv-lite/encodings/sbcs-data.js +2 -0
- package/node_modules/iconv-lite/encodings/utf32.js +10 -3
- package/node_modules/iconv-lite/package.json +2 -2
- package/node_modules/iconv-lite/types/encodings.d.ts +2 -0
- package/node_modules/protobufjs/dist/light/protobuf.js +2 -2
- package/node_modules/protobufjs/dist/light/protobuf.min.js +2 -2
- package/node_modules/protobufjs/dist/minimal/protobuf.js +2 -2
- package/node_modules/protobufjs/dist/minimal/protobuf.min.js +2 -2
- package/node_modules/protobufjs/dist/protobuf.js +5 -2
- package/node_modules/protobufjs/dist/protobuf.js.map +1 -1
- package/node_modules/protobufjs/dist/protobuf.min.js +3 -3
- package/node_modules/protobufjs/dist/protobuf.min.js.map +1 -1
- package/node_modules/protobufjs/package.json +1 -1
- package/node_modules/protobufjs/src/parse.js +3 -0
- package/node_modules/toad-cache/README.md +10 -9
- package/node_modules/toad-cache/dist/toad-cache.cjs +139 -139
- package/node_modules/toad-cache/dist/toad-cache.mjs +136 -140
- package/node_modules/toad-cache/package.json +8 -8
- package/node_modules/toad-cache/toad-cache.d.cts +20 -14
- package/node_modules/toad-cache/toad-cache.d.ts +18 -14
- package/package.json +6 -6
- package/node_modules/@fastify/fast-json-stringify-compiler/.eslintrc +0 -1
- package/node_modules/@zuplo/runtime/out/esm/chunk-36XLJ4X6.js +0 -389
- package/node_modules/@zuplo/runtime/out/esm/chunk-36XLJ4X6.js.map +0 -1
- package/node_modules/hono/dist/tsconfig.build.tsbuildinfo +0 -1
- /package/node_modules/@zuplo/runtime/out/esm/{chunk-36XLJ4X6.js.LEGAL.txt → chunk-MJWTZPC2.js.LEGAL.txt} +0 -0
|
@@ -0,0 +1,314 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
const { test } = require('node:test')
|
|
4
|
+
const validator = require('is-my-json-valid')
|
|
5
|
+
const build = require('..')
|
|
6
|
+
|
|
7
|
+
test('schema with const string', (t) => {
|
|
8
|
+
t.plan(2)
|
|
9
|
+
|
|
10
|
+
const schema = {
|
|
11
|
+
type: 'object',
|
|
12
|
+
properties: {
|
|
13
|
+
foo: { const: 'bar' }
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
const validate = validator(schema)
|
|
18
|
+
const stringify = build(schema)
|
|
19
|
+
const output = stringify({
|
|
20
|
+
foo: 'bar'
|
|
21
|
+
})
|
|
22
|
+
|
|
23
|
+
t.assert.equal(output, '{"foo":"bar"}')
|
|
24
|
+
t.assert.ok(validate(JSON.parse(output)), 'valid schema')
|
|
25
|
+
})
|
|
26
|
+
|
|
27
|
+
test('schema with const string and different input', (t) => {
|
|
28
|
+
t.plan(2)
|
|
29
|
+
|
|
30
|
+
const schema = {
|
|
31
|
+
type: 'object',
|
|
32
|
+
properties: {
|
|
33
|
+
foo: { const: 'bar' }
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
const validate = validator(schema)
|
|
38
|
+
const stringify = build(schema)
|
|
39
|
+
const output = stringify({
|
|
40
|
+
foo: 'baz'
|
|
41
|
+
})
|
|
42
|
+
|
|
43
|
+
t.assert.equal(output, '{"foo":"bar"}')
|
|
44
|
+
t.assert.ok(validate(JSON.parse(output)), 'valid schema')
|
|
45
|
+
})
|
|
46
|
+
|
|
47
|
+
test('schema with const string and different type input', (t) => {
|
|
48
|
+
t.plan(2)
|
|
49
|
+
|
|
50
|
+
const schema = {
|
|
51
|
+
type: 'object',
|
|
52
|
+
properties: {
|
|
53
|
+
foo: { const: 'bar' }
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
const validate = validator(schema)
|
|
58
|
+
const stringify = build(schema)
|
|
59
|
+
const output = stringify({
|
|
60
|
+
foo: 1
|
|
61
|
+
})
|
|
62
|
+
|
|
63
|
+
t.assert.equal(output, '{"foo":"bar"}')
|
|
64
|
+
t.assert.ok(validate(JSON.parse(output)), 'valid schema')
|
|
65
|
+
})
|
|
66
|
+
|
|
67
|
+
test('schema with const string and no input', (t) => {
|
|
68
|
+
t.plan(2)
|
|
69
|
+
|
|
70
|
+
const schema = {
|
|
71
|
+
type: 'object',
|
|
72
|
+
properties: {
|
|
73
|
+
foo: { const: 'bar' }
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
const validate = validator(schema)
|
|
78
|
+
const stringify = build(schema)
|
|
79
|
+
const output = stringify({})
|
|
80
|
+
|
|
81
|
+
t.assert.equal(output, '{}')
|
|
82
|
+
t.assert.ok(validate(JSON.parse(output)), 'valid schema')
|
|
83
|
+
})
|
|
84
|
+
|
|
85
|
+
test('schema with const string that contains \'', (t) => {
|
|
86
|
+
t.plan(2)
|
|
87
|
+
|
|
88
|
+
const schema = {
|
|
89
|
+
type: 'object',
|
|
90
|
+
properties: {
|
|
91
|
+
foo: { const: "'bar'" }
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
const validate = validator(schema)
|
|
96
|
+
const stringify = build(schema)
|
|
97
|
+
const output = stringify({
|
|
98
|
+
foo: "'bar'"
|
|
99
|
+
})
|
|
100
|
+
|
|
101
|
+
t.assert.equal(output, '{"foo":"\'bar\'"}')
|
|
102
|
+
t.assert.ok(validate(JSON.parse(output)), 'valid schema')
|
|
103
|
+
})
|
|
104
|
+
|
|
105
|
+
test('schema with const number', (t) => {
|
|
106
|
+
t.plan(2)
|
|
107
|
+
|
|
108
|
+
const schema = {
|
|
109
|
+
type: 'object',
|
|
110
|
+
properties: {
|
|
111
|
+
foo: { const: 1 }
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
const validate = validator(schema)
|
|
116
|
+
const stringify = build(schema)
|
|
117
|
+
const output = stringify({
|
|
118
|
+
foo: 1
|
|
119
|
+
})
|
|
120
|
+
|
|
121
|
+
t.assert.equal(output, '{"foo":1}')
|
|
122
|
+
t.assert.ok(validate(JSON.parse(output)), 'valid schema')
|
|
123
|
+
})
|
|
124
|
+
|
|
125
|
+
test('schema with const number and different input', (t) => {
|
|
126
|
+
t.plan(2)
|
|
127
|
+
|
|
128
|
+
const schema = {
|
|
129
|
+
type: 'object',
|
|
130
|
+
properties: {
|
|
131
|
+
foo: { const: 1 }
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
const validate = validator(schema)
|
|
136
|
+
const stringify = build(schema)
|
|
137
|
+
const output = stringify({
|
|
138
|
+
foo: 2
|
|
139
|
+
})
|
|
140
|
+
|
|
141
|
+
t.assert.equal(output, '{"foo":1}')
|
|
142
|
+
t.assert.ok(validate(JSON.parse(output)), 'valid schema')
|
|
143
|
+
})
|
|
144
|
+
|
|
145
|
+
test('schema with const bool', (t) => {
|
|
146
|
+
t.plan(2)
|
|
147
|
+
|
|
148
|
+
const schema = {
|
|
149
|
+
type: 'object',
|
|
150
|
+
properties: {
|
|
151
|
+
foo: { const: true }
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
const validate = validator(schema)
|
|
156
|
+
const stringify = build(schema)
|
|
157
|
+
const output = stringify({
|
|
158
|
+
foo: true
|
|
159
|
+
})
|
|
160
|
+
|
|
161
|
+
t.assert.equal(output, '{"foo":true}')
|
|
162
|
+
t.assert.ok(validate(JSON.parse(output)), 'valid schema')
|
|
163
|
+
})
|
|
164
|
+
|
|
165
|
+
test('schema with const number', (t) => {
|
|
166
|
+
t.plan(2)
|
|
167
|
+
|
|
168
|
+
const schema = {
|
|
169
|
+
type: 'object',
|
|
170
|
+
properties: {
|
|
171
|
+
foo: { const: 1 }
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
const validate = validator(schema)
|
|
176
|
+
const stringify = build(schema)
|
|
177
|
+
const output = stringify({
|
|
178
|
+
foo: 1
|
|
179
|
+
})
|
|
180
|
+
|
|
181
|
+
t.assert.equal(output, '{"foo":1}')
|
|
182
|
+
t.assert.ok(validate(JSON.parse(output)), 'valid schema')
|
|
183
|
+
})
|
|
184
|
+
|
|
185
|
+
test('schema with const null', (t) => {
|
|
186
|
+
t.plan(2)
|
|
187
|
+
|
|
188
|
+
const schema = {
|
|
189
|
+
type: 'object',
|
|
190
|
+
properties: {
|
|
191
|
+
foo: { const: null }
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
const validate = validator(schema)
|
|
196
|
+
const stringify = build(schema)
|
|
197
|
+
const output = stringify({
|
|
198
|
+
foo: null
|
|
199
|
+
})
|
|
200
|
+
|
|
201
|
+
t.assert.equal(output, '{"foo":null}')
|
|
202
|
+
t.assert.ok(validate(JSON.parse(output)), 'valid schema')
|
|
203
|
+
})
|
|
204
|
+
|
|
205
|
+
test('schema with const array', (t) => {
|
|
206
|
+
t.plan(2)
|
|
207
|
+
|
|
208
|
+
const schema = {
|
|
209
|
+
type: 'object',
|
|
210
|
+
properties: {
|
|
211
|
+
foo: { const: [1, 2, 3] }
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
const validate = validator(schema)
|
|
216
|
+
const stringify = build(schema)
|
|
217
|
+
const output = stringify({
|
|
218
|
+
foo: [1, 2, 3]
|
|
219
|
+
})
|
|
220
|
+
|
|
221
|
+
t.assert.equal(output, '{"foo":[1,2,3]}')
|
|
222
|
+
t.assert.ok(validate(JSON.parse(output)), 'valid schema')
|
|
223
|
+
})
|
|
224
|
+
|
|
225
|
+
test('schema with const object', (t) => {
|
|
226
|
+
t.plan(2)
|
|
227
|
+
|
|
228
|
+
const schema = {
|
|
229
|
+
type: 'object',
|
|
230
|
+
properties: {
|
|
231
|
+
foo: { const: { bar: 'baz' } }
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
const validate = validator(schema)
|
|
236
|
+
const stringify = build(schema)
|
|
237
|
+
const output = stringify({
|
|
238
|
+
foo: { bar: 'baz' }
|
|
239
|
+
})
|
|
240
|
+
|
|
241
|
+
t.assert.equal(output, '{"foo":{"bar":"baz"}}')
|
|
242
|
+
t.assert.ok(validate(JSON.parse(output)), 'valid schema')
|
|
243
|
+
})
|
|
244
|
+
|
|
245
|
+
test('schema with const and null as type', (t) => {
|
|
246
|
+
t.plan(4)
|
|
247
|
+
|
|
248
|
+
const schema = {
|
|
249
|
+
type: 'object',
|
|
250
|
+
properties: {
|
|
251
|
+
foo: { type: ['string', 'null'], const: 'baz' }
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
const validate = validator(schema)
|
|
256
|
+
const stringify = build(schema)
|
|
257
|
+
const output = stringify({
|
|
258
|
+
foo: null
|
|
259
|
+
})
|
|
260
|
+
|
|
261
|
+
t.assert.equal(output, '{"foo":null}')
|
|
262
|
+
t.assert.ok(validate(JSON.parse(output)), 'valid schema')
|
|
263
|
+
|
|
264
|
+
const output2 = stringify({ foo: 'baz' })
|
|
265
|
+
t.assert.equal(output2, '{"foo":"baz"}')
|
|
266
|
+
t.assert.ok(validate(JSON.parse(output2)), 'valid schema')
|
|
267
|
+
})
|
|
268
|
+
|
|
269
|
+
test('schema with const as nullable', (t) => {
|
|
270
|
+
t.plan(4)
|
|
271
|
+
|
|
272
|
+
const schema = {
|
|
273
|
+
type: 'object',
|
|
274
|
+
properties: {
|
|
275
|
+
foo: { nullable: true, const: 'baz' }
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
const validate = validator(schema)
|
|
280
|
+
const stringify = build(schema)
|
|
281
|
+
const output = stringify({
|
|
282
|
+
foo: null
|
|
283
|
+
})
|
|
284
|
+
|
|
285
|
+
t.assert.equal(output, '{"foo":null}')
|
|
286
|
+
t.assert.ok(validate(JSON.parse(output)), 'valid schema')
|
|
287
|
+
|
|
288
|
+
const output2 = stringify({
|
|
289
|
+
foo: 'baz'
|
|
290
|
+
})
|
|
291
|
+
t.assert.equal(output2, '{"foo":"baz"}')
|
|
292
|
+
t.assert.ok(validate(JSON.parse(output2)), 'valid schema')
|
|
293
|
+
})
|
|
294
|
+
|
|
295
|
+
test('schema with const and invalid object', (t) => {
|
|
296
|
+
t.plan(2)
|
|
297
|
+
|
|
298
|
+
const schema = {
|
|
299
|
+
type: 'object',
|
|
300
|
+
properties: {
|
|
301
|
+
foo: { const: { foo: 'bar' } }
|
|
302
|
+
},
|
|
303
|
+
required: ['foo']
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
const validate = validator(schema)
|
|
307
|
+
const stringify = build(schema)
|
|
308
|
+
const result = stringify({
|
|
309
|
+
foo: { foo: 'baz' }
|
|
310
|
+
})
|
|
311
|
+
|
|
312
|
+
t.assert.equal(result, '{"foo":{"foo":"bar"}}')
|
|
313
|
+
t.assert.ok(validate(JSON.parse(result)), 'valid schema')
|
|
314
|
+
})
|