@veryfront/ext-schema-zod 0.1.985
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/LICENSE +202 -0
- package/NOTICE +2 -0
- package/README.md +85 -0
- package/esm/adapter.d.ts +22 -0
- package/esm/adapter.d.ts.map +1 -0
- package/esm/adapter.js +159 -0
- package/esm/index.d.ts +19 -0
- package/esm/index.d.ts.map +1 -0
- package/esm/index.js +35 -0
- package/esm/json-schema.d.ts +15 -0
- package/esm/json-schema.d.ts.map +1 -0
- package/esm/json-schema.js +247 -0
- package/esm/package.json +3 -0
- package/package.json +58 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright [yyyy] [name of copyright owner]
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
package/NOTICE
ADDED
package/README.md
ADDED
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
# @veryfront/ext-schema-zod
|
|
2
|
+
|
|
3
|
+
> **Category:** Schema | **Contract:** `SchemaValidator` | **Built-in**
|
|
4
|
+
|
|
5
|
+
Provides schema validation for Veryfront, backed by [Zod](https://zod.dev/). Once loaded, any module that calls `defineSchema((v) => v.object({...}))` resolves through this extension's Zod-powered adapter.
|
|
6
|
+
|
|
7
|
+
## How It Works
|
|
8
|
+
|
|
9
|
+
Core modules never import zod directly. Instead they declare schemas via `defineSchema`:
|
|
10
|
+
|
|
11
|
+
```ts
|
|
12
|
+
import { defineSchema } from "veryfront/schemas";
|
|
13
|
+
import type { InferSchema } from "veryfront/extensions/schema";
|
|
14
|
+
|
|
15
|
+
const getUserSchema = defineSchema((v) =>
|
|
16
|
+
v.object({
|
|
17
|
+
id: v.string().uuid(),
|
|
18
|
+
name: v.string().min(1),
|
|
19
|
+
email: v.string().email().optional(),
|
|
20
|
+
})
|
|
21
|
+
);
|
|
22
|
+
|
|
23
|
+
type User = InferSchema<ReturnType<typeof getUserSchema>>;
|
|
24
|
+
|
|
25
|
+
const user = getUserSchema().parse(input);
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
The `v` parameter is a `SchemaValidator` instance provided by this extension. It exposes a zod-inspired DSL covering primitives, composites, chainables, and validation methods.
|
|
29
|
+
|
|
30
|
+
## Registration
|
|
31
|
+
|
|
32
|
+
ext-schema-zod is registered automatically by `createBuiltinExtensions()` at app bootstrap. It is placed **first** in the builtin chain so that other extensions can use `defineSchema` in their own `setup()` hooks.
|
|
33
|
+
|
|
34
|
+
### Test Setup
|
|
35
|
+
|
|
36
|
+
Tests that use `defineSchema` without full app bootstrap need to register the adapter explicitly:
|
|
37
|
+
|
|
38
|
+
```ts
|
|
39
|
+
import "#veryfront/schemas/_test-setup.ts";
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
Or manually:
|
|
43
|
+
|
|
44
|
+
```ts
|
|
45
|
+
import { register } from "veryfront/extensions/contracts";
|
|
46
|
+
import { createZodAdapter } from "@veryfront/ext-schema-zod";
|
|
47
|
+
|
|
48
|
+
register("SchemaValidator", createZodAdapter());
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
## Supported DSL
|
|
52
|
+
|
|
53
|
+
### Primitives
|
|
54
|
+
|
|
55
|
+
`string()`, `number()`, `boolean()`, `date()`, `null()`, `unknown()`, `any()`, `bigint()`
|
|
56
|
+
|
|
57
|
+
### Composites
|
|
58
|
+
|
|
59
|
+
`object(shape)`, `array(schema)`, `record(keys, values)`, `union(schemas)`, `discriminatedUnion(key, schemas)`, `literal(value)`, `enum(values)`, `tuple(items)`, `lazy(factory)`, `instanceof(ctor)`
|
|
60
|
+
|
|
61
|
+
### Chainables
|
|
62
|
+
|
|
63
|
+
`.optional()`, `.nullable()`, `.nullish()`, `.default(value)`, `.describe(text)`, `.refine(fn)`, `.superRefine(fn)`, `.transform(fn)`, `.strict()`, `.passthrough()`, `.strip()`, `.partial()`, `.extend(shape)`, `.merge(schema)`, `.omit(keys)`, `.pick(keys)`
|
|
64
|
+
|
|
65
|
+
### String/Number Refinements
|
|
66
|
+
|
|
67
|
+
`.min(n)`, `.max(n)`, `.int()`, `.positive()`, `.nonnegative()`, `.regex(pattern)`, `.email()`, `.url()`, `.uuid()`, `.datetime()`
|
|
68
|
+
|
|
69
|
+
### Coercion
|
|
70
|
+
|
|
71
|
+
`v.coerce.string()`, `v.coerce.number()`, `v.coerce.boolean()`, `v.coerce.date()`
|
|
72
|
+
|
|
73
|
+
### Validation
|
|
74
|
+
|
|
75
|
+
`.parse(data)` throws on failure; `.safeParse(data)` returns `{ success, data }` or `{ success, issues }`.
|
|
76
|
+
|
|
77
|
+
### JSON Schema
|
|
78
|
+
|
|
79
|
+
`toJsonSchema(schema)` converts any `Schema<T>` to a JSON Schema object for OpenAPI or tool-call definitions.
|
|
80
|
+
|
|
81
|
+
## Running Tests
|
|
82
|
+
|
|
83
|
+
```sh
|
|
84
|
+
deno task test
|
|
85
|
+
```
|
package/esm/adapter.d.ts
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Zod-backed `SchemaValidator` adapter.
|
|
3
|
+
*
|
|
4
|
+
* The default implementation of the `SchemaValidator` contract. It thinly
|
|
5
|
+
* wraps zod so that core modules can declare schemas through the
|
|
6
|
+
* extension-neutral DSL while still getting zod's runtime behavior.
|
|
7
|
+
*
|
|
8
|
+
* The entire zod surface used by the contract is confined to this file.
|
|
9
|
+
*
|
|
10
|
+
* @module extensions/ext-schema-zod/adapter
|
|
11
|
+
*/
|
|
12
|
+
import type { SchemaValidator } from "veryfront/extensions/schema";
|
|
13
|
+
/**
|
|
14
|
+
* Build a zod-backed `SchemaValidator` instance.
|
|
15
|
+
*
|
|
16
|
+
* Stateless — safe to call once at extension setup and pass the returned
|
|
17
|
+
* value to `ctx.provide("SchemaValidator", …)`. Tests that need to register
|
|
18
|
+
* the validator without going through full extension bootstrap can call this
|
|
19
|
+
* factory directly.
|
|
20
|
+
*/
|
|
21
|
+
export declare function createZodAdapter(): SchemaValidator;
|
|
22
|
+
//# sourceMappingURL=adapter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"adapter.d.ts","sourceRoot":"","sources":["../src/adapter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAGH,OAAO,KAAK,EAKV,eAAe,EAIhB,MAAM,6BAA6B,CAAC;AAiHrC;;;;;;;GAOG;AACH,wBAAgB,gBAAgB,IAAI,eAAe,CA8FlD"}
|
package/esm/adapter.js
ADDED
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Zod-backed `SchemaValidator` adapter.
|
|
3
|
+
*
|
|
4
|
+
* The default implementation of the `SchemaValidator` contract. It thinly
|
|
5
|
+
* wraps zod so that core modules can declare schemas through the
|
|
6
|
+
* extension-neutral DSL while still getting zod's runtime behavior.
|
|
7
|
+
*
|
|
8
|
+
* The entire zod surface used by the contract is confined to this file.
|
|
9
|
+
*
|
|
10
|
+
* @module extensions/ext-schema-zod/adapter
|
|
11
|
+
*/
|
|
12
|
+
import { z } from "zod";
|
|
13
|
+
import { isOptionalSchema, zodToJsonSchema } from "./json-schema.js";
|
|
14
|
+
/** Unwrap our opaque Schema<T> back to the underlying zod schema. */
|
|
15
|
+
function toZod(schema) {
|
|
16
|
+
return schema.__zod;
|
|
17
|
+
}
|
|
18
|
+
/** Wrap a zod schema as an opaque Schema<T> with chainables routed through zod. */
|
|
19
|
+
function wrap(zs) {
|
|
20
|
+
// The wrapper fakes the full Schema<T> surface; unsupported chainables on
|
|
21
|
+
// unsuitable kinds (e.g. calling `.email()` on a number) throw at runtime
|
|
22
|
+
// just like zod would.
|
|
23
|
+
// deno-lint-ignore no-explicit-any -- safe within this adapter
|
|
24
|
+
const anyZs = zs;
|
|
25
|
+
const s = {
|
|
26
|
+
_output: undefined,
|
|
27
|
+
optional: () => wrap(zs.optional()),
|
|
28
|
+
nullable: () => wrap(zs.nullable()),
|
|
29
|
+
nullish: () => wrap(zs.nullish()),
|
|
30
|
+
default: (value) => wrap(anyZs.default(value)),
|
|
31
|
+
describe: (description) => wrap(zs.describe(description)),
|
|
32
|
+
refine: (check, message) => wrap(zs.refine(check, message)),
|
|
33
|
+
superRefine: (check) => wrap(
|
|
34
|
+
// zod v4's `RefinementCtx` extends `ParsePayload` (`{ value, issues }`)
|
|
35
|
+
// and exposes `addIssue(string | $ZodSuperRefineIssue)`. We bridge to
|
|
36
|
+
// our path-aware `RefinementCtx` shape: we don't have a stable `path`
|
|
37
|
+
// from the zod side here (path tracking is per-issue, not per-ctx),
|
|
38
|
+
// so we emit `[]` and let callers pass their own `path` through
|
|
39
|
+
// `addIssue({ path })`.
|
|
40
|
+
anyZs.superRefine((value, zodCtx) => {
|
|
41
|
+
const ctx = {
|
|
42
|
+
path: [],
|
|
43
|
+
addIssue: (issue) => zodCtx.addIssue({
|
|
44
|
+
// String literal "custom" replaces the deprecated
|
|
45
|
+
// z.ZodIssueCode.custom enum (zod v4 prefers raw codes).
|
|
46
|
+
code: issue.code ?? "custom",
|
|
47
|
+
message: issue.message,
|
|
48
|
+
path: issue.path,
|
|
49
|
+
}),
|
|
50
|
+
};
|
|
51
|
+
check(value, ctx);
|
|
52
|
+
})),
|
|
53
|
+
transform: (fn) => wrap(zs.transform(fn)),
|
|
54
|
+
strict: () => wrap(anyZs.strict()),
|
|
55
|
+
strip: () => wrap(anyZs.strip()),
|
|
56
|
+
passthrough: () => wrap(anyZs.passthrough()),
|
|
57
|
+
partial: () => wrap(anyZs.partial()),
|
|
58
|
+
extend: (shape) => {
|
|
59
|
+
const zodShape = toZodShape(shape);
|
|
60
|
+
return wrap(anyZs.extend(zodShape));
|
|
61
|
+
},
|
|
62
|
+
merge: (other) => wrap(anyZs.merge(toZod(other))),
|
|
63
|
+
omit: (keys) => wrap(anyZs.omit(keys)),
|
|
64
|
+
pick: (keys) => wrap(anyZs.pick(keys)),
|
|
65
|
+
min: (value, message) => wrap(anyZs.min(value, message)),
|
|
66
|
+
max: (value, message) => wrap(anyZs.max(value, message)),
|
|
67
|
+
int: (message) => wrap(anyZs.int(message)),
|
|
68
|
+
positive: (message) => wrap(anyZs.positive(message)),
|
|
69
|
+
nonnegative: (message) => wrap(anyZs.nonnegative(message)),
|
|
70
|
+
regex: (pattern, message) => wrap(anyZs.regex(pattern, message)),
|
|
71
|
+
email: (message) => wrap(anyZs.email(message)),
|
|
72
|
+
url: (message) => wrap(anyZs.url(message)),
|
|
73
|
+
uuid: (message) => wrap(anyZs.uuid(message)),
|
|
74
|
+
datetime: (message) => wrap(anyZs.datetime(message)),
|
|
75
|
+
pipe: (next) => wrap(zs.pipe(toZod(next))),
|
|
76
|
+
parse: (data) => zs.parse(data),
|
|
77
|
+
safeParse: (data) => {
|
|
78
|
+
const res = zs.safeParse(data);
|
|
79
|
+
if (res.success)
|
|
80
|
+
return { success: true, data: res.data };
|
|
81
|
+
const issues = res.error.issues.map((issue) => ({
|
|
82
|
+
path: issue.path,
|
|
83
|
+
message: issue.message,
|
|
84
|
+
code: issue.code,
|
|
85
|
+
}));
|
|
86
|
+
return { success: false, issues, error: res.error };
|
|
87
|
+
},
|
|
88
|
+
};
|
|
89
|
+
// Attach the underlying zod schema for adapter round-trips without
|
|
90
|
+
// widening the public Schema<T> surface.
|
|
91
|
+
s.__zod = zs;
|
|
92
|
+
return s;
|
|
93
|
+
}
|
|
94
|
+
function toZodShape(shape) {
|
|
95
|
+
const out = {};
|
|
96
|
+
for (const [key, value] of Object.entries(shape)) {
|
|
97
|
+
out[key] = toZod(value);
|
|
98
|
+
}
|
|
99
|
+
return out;
|
|
100
|
+
}
|
|
101
|
+
const coerce = {
|
|
102
|
+
string: () => wrap(z.coerce.string()),
|
|
103
|
+
number: () => wrap(z.coerce.number()),
|
|
104
|
+
boolean: () => wrap(z.coerce.boolean()),
|
|
105
|
+
date: () => wrap(z.coerce.date()),
|
|
106
|
+
};
|
|
107
|
+
/**
|
|
108
|
+
* Build a zod-backed `SchemaValidator` instance.
|
|
109
|
+
*
|
|
110
|
+
* Stateless — safe to call once at extension setup and pass the returned
|
|
111
|
+
* value to `ctx.provide("SchemaValidator", …)`. Tests that need to register
|
|
112
|
+
* the validator without going through full extension bootstrap can call this
|
|
113
|
+
* factory directly.
|
|
114
|
+
*/
|
|
115
|
+
export function createZodAdapter() {
|
|
116
|
+
return {
|
|
117
|
+
string: () => wrap(z.string()),
|
|
118
|
+
number: () => wrap(z.number()),
|
|
119
|
+
boolean: () => wrap(z.boolean()),
|
|
120
|
+
date: () => wrap(z.date()),
|
|
121
|
+
null: () => wrap(z.null()),
|
|
122
|
+
unknown: () => wrap(z.unknown()),
|
|
123
|
+
bigint: () => wrap(z.bigint()),
|
|
124
|
+
// deno-lint-ignore no-explicit-any -- contract mirrors zod's `any` constructor
|
|
125
|
+
any: () => wrap(z.any()),
|
|
126
|
+
function: () =>
|
|
127
|
+
// zod 4's z.function() is callable without args/returns and produces a
|
|
128
|
+
// schema accepting any function. We wrap it as Schema<AnyFunction>.
|
|
129
|
+
wrap(z.function()),
|
|
130
|
+
object: (shape) => wrap(z.object(toZodShape(shape))),
|
|
131
|
+
array: (element) => wrap(z.array(toZod(element))),
|
|
132
|
+
tuple: (items) => {
|
|
133
|
+
const zodItems = items.map((s) => toZod(s));
|
|
134
|
+
return wrap(z.tuple(zodItems));
|
|
135
|
+
},
|
|
136
|
+
record: (keys, values) => wrap(z.record(toZod(keys), toZod(values))),
|
|
137
|
+
union: (schemas) => {
|
|
138
|
+
const zodSchemas = schemas.map((s) => toZod(s));
|
|
139
|
+
return wrap(z.union(zodSchemas));
|
|
140
|
+
},
|
|
141
|
+
discriminatedUnion: (discriminator, schemas) => {
|
|
142
|
+
const zodSchemas = schemas.map((s) => toZod(s));
|
|
143
|
+
return wrap(z.discriminatedUnion(discriminator, zodSchemas));
|
|
144
|
+
},
|
|
145
|
+
literal: (value) => wrap(z.literal(value)),
|
|
146
|
+
enum: (values) => wrap(z.enum(values)),
|
|
147
|
+
lazy: (factory) => wrap(z.lazy(() => toZod(factory()))),
|
|
148
|
+
instanceof: (ctor) =>
|
|
149
|
+
// zod 4's z.instanceof expects `typeof Class` (z.core.util.Class). Our
|
|
150
|
+
// contract uses a slimmer `new`-able shape; bridge with a single cast
|
|
151
|
+
// through unknown.
|
|
152
|
+
wrap(z.instanceof(ctor)),
|
|
153
|
+
custom: (check, message) => wrap(z.custom(check, message)),
|
|
154
|
+
coerce,
|
|
155
|
+
validate: (schema, data) => schema.safeParse(data),
|
|
156
|
+
toJsonSchema: (schema) => zodToJsonSchema(toZod(schema)),
|
|
157
|
+
isOptional: (schema) => isOptionalSchema(toZod(schema)),
|
|
158
|
+
};
|
|
159
|
+
}
|
package/esm/index.d.ts
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ext-schema-zod — SchemaValidator implementation backed by zod.
|
|
3
|
+
*
|
|
4
|
+
* Provides the `SchemaValidator` contract via a zod-backed adapter. Core
|
|
5
|
+
* modules declare schemas through `defineSchema((v) => …)` (in
|
|
6
|
+
* `src/schemas/define.ts`); the lazy factory resolves this contract on first
|
|
7
|
+
* use and the adapter routes calls into zod.
|
|
8
|
+
*
|
|
9
|
+
* Registered automatically by `createBuiltinExtensions()`. Tests that need
|
|
10
|
+
* the adapter without going through full extension bootstrap can import
|
|
11
|
+
* `createZodAdapter` directly from this module's `./adapter.ts`.
|
|
12
|
+
*
|
|
13
|
+
* @module extensions/ext-schema-zod
|
|
14
|
+
*/
|
|
15
|
+
import type { ExtensionFactory } from "veryfront/extensions";
|
|
16
|
+
declare const extZod: ExtensionFactory;
|
|
17
|
+
export default extZod;
|
|
18
|
+
export { createZodAdapter } from "./adapter.js";
|
|
19
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAG7D,QAAA,MAAM,MAAM,EAAE,gBAiBb,CAAC;AAEF,eAAe,MAAM,CAAC;AACtB,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC"}
|
package/esm/index.js
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ext-schema-zod — SchemaValidator implementation backed by zod.
|
|
3
|
+
*
|
|
4
|
+
* Provides the `SchemaValidator` contract via a zod-backed adapter. Core
|
|
5
|
+
* modules declare schemas through `defineSchema((v) => …)` (in
|
|
6
|
+
* `src/schemas/define.ts`); the lazy factory resolves this contract on first
|
|
7
|
+
* use and the adapter routes calls into zod.
|
|
8
|
+
*
|
|
9
|
+
* Registered automatically by `createBuiltinExtensions()`. Tests that need
|
|
10
|
+
* the adapter without going through full extension bootstrap can import
|
|
11
|
+
* `createZodAdapter` directly from this module's `./adapter.ts`.
|
|
12
|
+
*
|
|
13
|
+
* @module extensions/ext-schema-zod
|
|
14
|
+
*/
|
|
15
|
+
import { createZodAdapter } from "./adapter.js";
|
|
16
|
+
const extZod = () => {
|
|
17
|
+
const impl = createZodAdapter();
|
|
18
|
+
return {
|
|
19
|
+
name: "ext-schema-zod",
|
|
20
|
+
version: "0.1.0",
|
|
21
|
+
contracts: {
|
|
22
|
+
provides: ["SchemaValidator"],
|
|
23
|
+
},
|
|
24
|
+
capabilities: [],
|
|
25
|
+
setup(ctx) {
|
|
26
|
+
ctx.provide("SchemaValidator", impl);
|
|
27
|
+
ctx.logger.info("[ext-schema-zod] SchemaValidator registered");
|
|
28
|
+
},
|
|
29
|
+
teardown() {
|
|
30
|
+
// No resources to release.
|
|
31
|
+
},
|
|
32
|
+
};
|
|
33
|
+
};
|
|
34
|
+
export default extZod;
|
|
35
|
+
export { createZodAdapter } from "./adapter.js";
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Zod-to-JSON-Schema converter used by the `SchemaValidator` adapter.
|
|
3
|
+
*
|
|
4
|
+
* Operates directly on zod's internal `_def` shape (covers both v3 and v4)
|
|
5
|
+
* because zod ships no first-class JSON-Schema export. Confined to
|
|
6
|
+
* `extensions/ext-schema-zod/` so the rest of the codebase never has to import zod
|
|
7
|
+
* to learn what a tool's input schema looks like.
|
|
8
|
+
*
|
|
9
|
+
* @module extensions/ext-schema-zod/json-schema
|
|
10
|
+
*/
|
|
11
|
+
import type { z } from "zod";
|
|
12
|
+
import type { JsonSchema } from "veryfront/extensions/schema";
|
|
13
|
+
export declare function zodToJsonSchema(schema: z.ZodTypeAny): JsonSchema;
|
|
14
|
+
export declare function isOptionalSchema(schema: z.ZodTypeAny): boolean;
|
|
15
|
+
//# sourceMappingURL=json-schema.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"json-schema.d.ts","sourceRoot":"","sources":["../src/json-schema.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAC7B,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAC;AAgD9D,wBAAgB,eAAe,CAAC,MAAM,EAAE,CAAC,CAAC,UAAU,GAAG,UAAU,CAEhE;AAgBD,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,CAAC,CAAC,UAAU,GAAG,OAAO,CAE9D"}
|
|
@@ -0,0 +1,247 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Zod-to-JSON-Schema converter used by the `SchemaValidator` adapter.
|
|
3
|
+
*
|
|
4
|
+
* Operates directly on zod's internal `_def` shape (covers both v3 and v4)
|
|
5
|
+
* because zod ships no first-class JSON-Schema export. Confined to
|
|
6
|
+
* `extensions/ext-schema-zod/` so the rest of the codebase never has to import zod
|
|
7
|
+
* to learn what a tool's input schema looks like.
|
|
8
|
+
*
|
|
9
|
+
* @module extensions/ext-schema-zod/json-schema
|
|
10
|
+
*/
|
|
11
|
+
const LITERAL_TYPE_MAP = {
|
|
12
|
+
string: "string",
|
|
13
|
+
number: "number",
|
|
14
|
+
boolean: "boolean",
|
|
15
|
+
};
|
|
16
|
+
function getLiteralType(value) {
|
|
17
|
+
return LITERAL_TYPE_MAP[typeof value];
|
|
18
|
+
}
|
|
19
|
+
function getDef(schema) {
|
|
20
|
+
return schema._def;
|
|
21
|
+
}
|
|
22
|
+
/** Get the internal type tag from a zod schema (_def.typeName in v3, _def.type in v4). */
|
|
23
|
+
function getTypeTag(schema) {
|
|
24
|
+
const def = getDef(schema);
|
|
25
|
+
return def.typeName ?? def.type;
|
|
26
|
+
}
|
|
27
|
+
export function zodToJsonSchema(schema) {
|
|
28
|
+
return convertSchema(schema, { seen: new WeakSet() });
|
|
29
|
+
}
|
|
30
|
+
function convertSchema(schema, context) {
|
|
31
|
+
// Guard against invalid schemas (can happen with different zod instances in npm bundle)
|
|
32
|
+
if (!schema || typeof schema !== "object" || !("_def" in schema)) {
|
|
33
|
+
throw new Error("Invalid Zod schema: missing _def property");
|
|
34
|
+
}
|
|
35
|
+
const { schema: unwrapped, nullable } = unwrapSchema(schema);
|
|
36
|
+
const json = convert(unwrapped, context);
|
|
37
|
+
const description = getDescription(schema) ?? getDescription(unwrapped);
|
|
38
|
+
if (description && json.description === undefined)
|
|
39
|
+
json.description = description;
|
|
40
|
+
return nullable ? { anyOf: [json, { type: "null" }] } : json;
|
|
41
|
+
}
|
|
42
|
+
export function isOptionalSchema(schema) {
|
|
43
|
+
return unwrapSchema(schema).optional || hasDefaultSchema(schema);
|
|
44
|
+
}
|
|
45
|
+
function convert(schema, context) {
|
|
46
|
+
if (context.seen.has(schema))
|
|
47
|
+
return {};
|
|
48
|
+
context.seen.add(schema);
|
|
49
|
+
try {
|
|
50
|
+
return convertInner(schema, context);
|
|
51
|
+
}
|
|
52
|
+
finally {
|
|
53
|
+
context.seen.delete(schema);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
function convertInner(schema, context) {
|
|
57
|
+
const tag = getTypeTag(schema);
|
|
58
|
+
const def = getDef(schema);
|
|
59
|
+
switch (tag) {
|
|
60
|
+
case "ZodString":
|
|
61
|
+
case "string":
|
|
62
|
+
return { type: "string" };
|
|
63
|
+
case "ZodNumber":
|
|
64
|
+
case "number":
|
|
65
|
+
return { type: "number" };
|
|
66
|
+
case "ZodBoolean":
|
|
67
|
+
case "boolean":
|
|
68
|
+
return { type: "boolean" };
|
|
69
|
+
case "ZodBigInt":
|
|
70
|
+
case "bigint":
|
|
71
|
+
return { type: "integer" };
|
|
72
|
+
case "ZodLiteral":
|
|
73
|
+
case "literal": {
|
|
74
|
+
// v3: _def.value, v4: _def.values (array of accepted values)
|
|
75
|
+
const literal = def.value ?? (Array.isArray(def.values) ? def.values[0] : def.values);
|
|
76
|
+
return { const: literal, type: getLiteralType(literal) };
|
|
77
|
+
}
|
|
78
|
+
case "ZodEnum":
|
|
79
|
+
case "ZodNativeEnum":
|
|
80
|
+
case "enum": {
|
|
81
|
+
// v3: _def.values (array), v4: _def.entries (object {key: value})
|
|
82
|
+
const values = def.values ?? (def.entries ? Object.values(def.entries) : []);
|
|
83
|
+
if (Array.isArray(values)) {
|
|
84
|
+
return { type: "string", enum: values };
|
|
85
|
+
}
|
|
86
|
+
// Native enum: filter out reverse-mapped numeric keys
|
|
87
|
+
return {
|
|
88
|
+
enum: Object.values(values).filter((value) => typeof value !== "number"),
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
case "ZodObject":
|
|
92
|
+
case "object": {
|
|
93
|
+
const shape = typeof def.shape === "function" ? def.shape() : def.shape;
|
|
94
|
+
const properties = {};
|
|
95
|
+
const required = [];
|
|
96
|
+
for (const [key, value] of Object.entries(shape ?? {})) {
|
|
97
|
+
const zodSchema = value;
|
|
98
|
+
properties[key] = convertSchema(zodSchema, context);
|
|
99
|
+
if (!isOptionalSchema(zodSchema))
|
|
100
|
+
required.push(key);
|
|
101
|
+
}
|
|
102
|
+
const json = { type: "object", properties };
|
|
103
|
+
if (required.length)
|
|
104
|
+
json.required = required;
|
|
105
|
+
const additionalProperties = getObjectAdditionalProperties(def, context);
|
|
106
|
+
if (additionalProperties !== undefined)
|
|
107
|
+
json.additionalProperties = additionalProperties;
|
|
108
|
+
return json;
|
|
109
|
+
}
|
|
110
|
+
case "ZodArray":
|
|
111
|
+
case "array": {
|
|
112
|
+
// v3: _def.type (item schema), v4: _def.element (item schema)
|
|
113
|
+
const itemType = def.element ?? def.type;
|
|
114
|
+
if (!itemType || typeof itemType === "string")
|
|
115
|
+
return { type: "array" };
|
|
116
|
+
return { type: "array", items: convertSchema(itemType, context) };
|
|
117
|
+
}
|
|
118
|
+
case "ZodTuple":
|
|
119
|
+
case "tuple": {
|
|
120
|
+
const items = def.items ?? [];
|
|
121
|
+
return {
|
|
122
|
+
type: "array",
|
|
123
|
+
prefixItems: items.map((item) => convertSchema(item, context)),
|
|
124
|
+
minItems: items.length,
|
|
125
|
+
maxItems: items.length,
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
case "ZodUnion":
|
|
129
|
+
case "ZodDiscriminatedUnion":
|
|
130
|
+
case "union": {
|
|
131
|
+
const options = def.options ?? [];
|
|
132
|
+
const optionArray = options instanceof Map ? Array.from(options.values()) : options;
|
|
133
|
+
return { anyOf: optionArray.map((option) => convertSchema(option, context)) };
|
|
134
|
+
}
|
|
135
|
+
case "ZodRecord":
|
|
136
|
+
case "record": {
|
|
137
|
+
const valueSchema = def.valueType ?? def.element;
|
|
138
|
+
if (!valueSchema)
|
|
139
|
+
return { type: "object" };
|
|
140
|
+
return { type: "object", additionalProperties: convertSchema(valueSchema, context) };
|
|
141
|
+
}
|
|
142
|
+
case "ZodDefault":
|
|
143
|
+
case "default": {
|
|
144
|
+
const innerType = def.innerType ?? def.schema;
|
|
145
|
+
if (!innerType)
|
|
146
|
+
return { type: "object" };
|
|
147
|
+
const inner = convertSchema(innerType, context);
|
|
148
|
+
const defaultValue = typeof def.defaultValue === "function"
|
|
149
|
+
? def.defaultValue()
|
|
150
|
+
: def.defaultValue;
|
|
151
|
+
if (typeof inner === "object" && !("anyOf" in inner) && defaultValue !== undefined) {
|
|
152
|
+
inner.default = defaultValue;
|
|
153
|
+
}
|
|
154
|
+
return inner;
|
|
155
|
+
}
|
|
156
|
+
case "ZodLazy":
|
|
157
|
+
case "lazy":
|
|
158
|
+
return def.getter ? convert(def.getter(), context) : { type: "object" };
|
|
159
|
+
case "ZodEffects":
|
|
160
|
+
case "pipe": {
|
|
161
|
+
// v3: ZodEffects wraps schema in _def.schema
|
|
162
|
+
// v4: pipe wraps in _def.in (input schema)
|
|
163
|
+
const innerSchema = def.schema ?? def.in;
|
|
164
|
+
return innerSchema ? convert(innerSchema, context) : { type: "object" };
|
|
165
|
+
}
|
|
166
|
+
default:
|
|
167
|
+
return { type: "object" };
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
function getObjectAdditionalProperties(def, context) {
|
|
171
|
+
if (def.unknownKeys === "passthrough")
|
|
172
|
+
return true;
|
|
173
|
+
if (def.unknownKeys === "strict")
|
|
174
|
+
return false;
|
|
175
|
+
if (def.unknownKeys === "strip")
|
|
176
|
+
return undefined;
|
|
177
|
+
if (!def.catchall)
|
|
178
|
+
return undefined;
|
|
179
|
+
const catchallTag = getTypeTag(def.catchall);
|
|
180
|
+
if (catchallTag === "unknown" || catchallTag === "ZodUnknown")
|
|
181
|
+
return true;
|
|
182
|
+
if (catchallTag === "never" || catchallTag === "ZodNever")
|
|
183
|
+
return false;
|
|
184
|
+
return convertSchema(def.catchall, context);
|
|
185
|
+
}
|
|
186
|
+
function unwrapSchema(schema) {
|
|
187
|
+
let current = schema;
|
|
188
|
+
let nullable = false;
|
|
189
|
+
let optional = false;
|
|
190
|
+
while (true) {
|
|
191
|
+
const tag = getTypeTag(current);
|
|
192
|
+
const def = getDef(current);
|
|
193
|
+
switch (tag) {
|
|
194
|
+
case "ZodNullable":
|
|
195
|
+
case "nullable":
|
|
196
|
+
nullable = true;
|
|
197
|
+
current = (def.innerType ?? def.schema);
|
|
198
|
+
break;
|
|
199
|
+
case "ZodOptional":
|
|
200
|
+
case "optional":
|
|
201
|
+
optional = true;
|
|
202
|
+
current = (def.innerType ?? def.schema);
|
|
203
|
+
break;
|
|
204
|
+
case "ZodEffects":
|
|
205
|
+
case "pipe":
|
|
206
|
+
current = def.schema ?? def.in ?? current;
|
|
207
|
+
if (current === schema)
|
|
208
|
+
return { schema: current, nullable, optional };
|
|
209
|
+
break;
|
|
210
|
+
default:
|
|
211
|
+
return { schema: current, nullable, optional };
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
function hasDefaultSchema(schema) {
|
|
216
|
+
let current = schema;
|
|
217
|
+
while (true) {
|
|
218
|
+
const tag = getTypeTag(current);
|
|
219
|
+
const def = getDef(current);
|
|
220
|
+
switch (tag) {
|
|
221
|
+
case "ZodDefault":
|
|
222
|
+
case "default":
|
|
223
|
+
return true;
|
|
224
|
+
case "ZodNullable":
|
|
225
|
+
case "nullable":
|
|
226
|
+
case "ZodOptional":
|
|
227
|
+
case "optional":
|
|
228
|
+
case "ZodEffects":
|
|
229
|
+
case "pipe": {
|
|
230
|
+
const inner = def.innerType ?? def.schema ?? def.in;
|
|
231
|
+
if (!inner || inner === current)
|
|
232
|
+
return false;
|
|
233
|
+
current = inner;
|
|
234
|
+
break;
|
|
235
|
+
}
|
|
236
|
+
default:
|
|
237
|
+
return false;
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
function getDescription(schema) {
|
|
242
|
+
const direct = schema.description;
|
|
243
|
+
if (typeof direct === "string")
|
|
244
|
+
return direct;
|
|
245
|
+
const defDescription = getDef(schema).description;
|
|
246
|
+
return typeof defDescription === "string" ? defDescription : undefined;
|
|
247
|
+
}
|
package/esm/package.json
ADDED
package/package.json
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@veryfront/ext-schema-zod",
|
|
3
|
+
"version": "0.1.985",
|
|
4
|
+
"description": "Veryfront first-party extension package for ext-schema-zod",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"veryfront",
|
|
7
|
+
"extension",
|
|
8
|
+
"ext-schema-zod"
|
|
9
|
+
],
|
|
10
|
+
"author": "Veryfront",
|
|
11
|
+
"homepage": "https://github.com/veryfront/veryfront-code/tree/main/extensions/ext-schema-zod",
|
|
12
|
+
"repository": {
|
|
13
|
+
"type": "git",
|
|
14
|
+
"url": "git+https://github.com/veryfront/veryfront-code.git",
|
|
15
|
+
"directory": "extensions/ext-schema-zod"
|
|
16
|
+
},
|
|
17
|
+
"license": "Apache-2.0",
|
|
18
|
+
"bugs": {
|
|
19
|
+
"url": "https://github.com/veryfront/veryfront-code/issues"
|
|
20
|
+
},
|
|
21
|
+
"module": "./esm/index.js",
|
|
22
|
+
"exports": {
|
|
23
|
+
".": {
|
|
24
|
+
"import": "./esm/index.js",
|
|
25
|
+
"types": "./esm/index.d.ts"
|
|
26
|
+
}
|
|
27
|
+
},
|
|
28
|
+
"scripts": {},
|
|
29
|
+
"engines": {
|
|
30
|
+
"node": ">=18.0.0"
|
|
31
|
+
},
|
|
32
|
+
"publishConfig": {
|
|
33
|
+
"access": "public"
|
|
34
|
+
},
|
|
35
|
+
"veryfront": {
|
|
36
|
+
"extension": true,
|
|
37
|
+
"contracts": {
|
|
38
|
+
"provides": [
|
|
39
|
+
"SchemaValidator"
|
|
40
|
+
]
|
|
41
|
+
},
|
|
42
|
+
"capabilities": []
|
|
43
|
+
},
|
|
44
|
+
"dependencies": {
|
|
45
|
+
"zod": "4.3.6"
|
|
46
|
+
},
|
|
47
|
+
"peerDependencies": {
|
|
48
|
+
"veryfront": "^0.1.985"
|
|
49
|
+
},
|
|
50
|
+
"type": "module",
|
|
51
|
+
"types": "./esm/index.d.ts",
|
|
52
|
+
"files": [
|
|
53
|
+
"esm",
|
|
54
|
+
"LICENSE",
|
|
55
|
+
"NOTICE",
|
|
56
|
+
"README.md"
|
|
57
|
+
]
|
|
58
|
+
}
|