@lucern/contracts 0.1.2-alpha.5 → 0.3.0-alpha.1
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/dist/defineFunction-DO97DKs4.d.ts +14 -0
- package/dist/defineTable-CBQ03FXl.d.ts +36 -0
- package/dist/dsl-BgpoVOVQ.d.ts +110 -0
- package/dist/dsl.d.ts +5 -0
- package/dist/dsl.js +678 -0
- package/dist/dsl.js.map +1 -0
- package/dist/function-registry/beliefs.d.ts +479 -0
- package/dist/function-registry/beliefs.js +4677 -0
- package/dist/function-registry/beliefs.js.map +1 -0
- package/dist/function-registry/coding.d.ts +323 -0
- package/dist/function-registry/coding.js +4451 -0
- package/dist/function-registry/coding.js.map +1 -0
- package/dist/function-registry/context.d.ts +206 -0
- package/dist/function-registry/context.js +4336 -0
- package/dist/function-registry/context.js.map +1 -0
- package/dist/function-registry/contracts.d.ts +206 -0
- package/dist/function-registry/contracts.js +4284 -0
- package/dist/function-registry/contracts.js.map +1 -0
- package/dist/function-registry/coordination.d.ts +440 -0
- package/dist/function-registry/coordination.js +4405 -0
- package/dist/function-registry/coordination.js.map +1 -0
- package/dist/function-registry/edges.d.ts +167 -0
- package/dist/function-registry/edges.js +4425 -0
- package/dist/function-registry/edges.js.map +1 -0
- package/dist/function-registry/evidence.d.ts +401 -0
- package/dist/function-registry/evidence.js +4598 -0
- package/dist/function-registry/evidence.js.map +1 -0
- package/dist/function-registry/graph.d.ts +596 -0
- package/dist/function-registry/graph.js +4489 -0
- package/dist/function-registry/graph.js.map +1 -0
- package/dist/function-registry/helpers.d.ts +84 -0
- package/dist/function-registry/helpers.js +4280 -0
- package/dist/function-registry/helpers.js.map +1 -0
- package/dist/function-registry/identity.d.ts +206 -0
- package/dist/function-registry/identity.js +4295 -0
- package/dist/function-registry/identity.js.map +1 -0
- package/dist/function-registry/index.d.ts +32 -0
- package/dist/function-registry/index.js +4384 -0
- package/dist/function-registry/index.js.map +1 -0
- package/dist/function-registry/judgments.d.ts +167 -0
- package/dist/function-registry/judgments.js +4308 -0
- package/dist/function-registry/judgments.js.map +1 -0
- package/dist/function-registry/legacy.d.ts +128 -0
- package/dist/function-registry/legacy.js +4259 -0
- package/dist/function-registry/legacy.js.map +1 -0
- package/dist/function-registry/lenses.d.ts +245 -0
- package/dist/function-registry/lenses.js +4343 -0
- package/dist/function-registry/lenses.js.map +1 -0
- package/dist/function-registry/manifest.d.ts +36 -0
- package/dist/function-registry/manifest.js +367 -0
- package/dist/function-registry/manifest.js.map +1 -0
- package/dist/function-registry/ontologies.d.ts +518 -0
- package/dist/function-registry/ontologies.js +4442 -0
- package/dist/function-registry/ontologies.js.map +1 -0
- package/dist/function-registry/pipeline.d.ts +206 -0
- package/dist/function-registry/pipeline.js +4295 -0
- package/dist/function-registry/pipeline.js.map +1 -0
- package/dist/function-registry/questions.d.ts +557 -0
- package/dist/function-registry/questions.js +4528 -0
- package/dist/function-registry/questions.js.map +1 -0
- package/dist/function-registry/tasks.d.ts +245 -0
- package/dist/function-registry/tasks.js +4373 -0
- package/dist/function-registry/tasks.js.map +1 -0
- package/dist/function-registry/topics.d.ts +284 -0
- package/dist/function-registry/topics.js +4350 -0
- package/dist/function-registry/topics.js.map +1 -0
- package/dist/function-registry/types.d.ts +84 -0
- package/dist/function-registry/types.js +3 -0
- package/dist/function-registry/types.js.map +1 -0
- package/dist/function-registry/worktrees.d.ts +479 -0
- package/dist/function-registry/worktrees.js +4522 -0
- package/dist/function-registry/worktrees.js.map +1 -0
- package/dist/generated/convexSchemas.d.ts +20 -0
- package/dist/generated/convexSchemas.js +161 -0
- package/dist/generated/convexSchemas.js.map +1 -0
- package/dist/generated/schema-manifest.json +5231 -0
- package/dist/generated/tableOwnership.d.ts +128 -0
- package/dist/generated/tableOwnership.js +278 -0
- package/dist/generated/tableOwnership.js.map +1 -0
- package/dist/generated/tier-expectations.json +363 -0
- package/dist/idOf-DR8tkhQS.d.ts +10 -0
- package/dist/index-CV-0_VWJ.d.ts +25 -0
- package/dist/index.d.ts +421 -2
- package/dist/index.js +7634 -1607
- package/dist/index.js.map +1 -1
- package/dist/schema-helpers/enumValidation.d.ts +17 -0
- package/dist/schema-helpers/enumValidation.js +143 -0
- package/dist/schema-helpers/enumValidation.js.map +1 -0
- package/dist/schema-helpers/spine/nodes/decision.d.ts +19 -0
- package/dist/schema-helpers/spine/nodes/decision.js +81 -0
- package/dist/schema-helpers/spine/nodes/decision.js.map +1 -0
- package/dist/schema-helpers/spine/tables/epistemicNodes.d.ts +9 -0
- package/dist/schema-helpers/spine/tables/epistemicNodes.js +62 -0
- package/dist/schema-helpers/spine/tables/epistemicNodes.js.map +1 -0
- package/dist/schema-helpers/topicIds.d.ts +17 -0
- package/dist/schema-helpers/topicIds.js +21 -0
- package/dist/schema-helpers/topicIds.js.map +1 -0
- package/dist/schema-helpers/topicLegacyScope.d.ts +19 -0
- package/dist/schema-helpers/topicLegacyScope.js +44 -0
- package/dist/schema-helpers/topicLegacyScope.js.map +1 -0
- package/dist/schema-helpers/validators.d.ts +8 -0
- package/dist/schema-helpers/validators.js +18 -0
- package/dist/schema-helpers/validators.js.map +1 -0
- package/dist/schemas/component-table-manifest.d.ts +74 -0
- package/dist/schemas/component-table-manifest.js +26 -0
- package/dist/schemas/component-table-manifest.js.map +1 -0
- package/dist/schemas/enums.d.ts +12 -0
- package/dist/schemas/enums.js +11 -0
- package/dist/schemas/enums.js.map +1 -0
- package/dist/schemas/index.d.ts +7 -0
- package/dist/schemas/index.js +4298 -0
- package/dist/schemas/index.js.map +1 -0
- package/dist/schemas/manifest.d.ts +24586 -0
- package/dist/schemas/manifest.js +4269 -0
- package/dist/schemas/manifest.js.map +1 -0
- package/dist/schemas/sl-opinion.d.ts +31 -0
- package/dist/schemas/sl-opinion.js +19 -0
- package/dist/schemas/sl-opinion.js.map +1 -0
- package/dist/schemas/tables/identity/agent.d.ts +21 -0
- package/dist/schemas/tables/identity/agent.js +41 -0
- package/dist/schemas/tables/identity/agent.js.map +1 -0
- package/dist/schemas/tables/identity/epistemic.d.ts +18 -0
- package/dist/schemas/tables/identity/epistemic.js +38 -0
- package/dist/schemas/tables/identity/epistemic.js.map +1 -0
- package/dist/schemas/tables/identity/model.d.ts +62 -0
- package/dist/schemas/tables/identity/model.js +110 -0
- package/dist/schemas/tables/identity/model.js.map +1 -0
- package/dist/schemas/tables/identity/platform.d.ts +392 -0
- package/dist/schemas/tables/identity/platform.js +475 -0
- package/dist/schemas/tables/identity/platform.js.map +1 -0
- package/dist/schemas/tables/identity/project.d.ts +22 -0
- package/dist/schemas/tables/identity/project.js +48 -0
- package/dist/schemas/tables/identity/project.js.map +1 -0
- package/dist/schemas/tables/identity/user.d.ts +26 -0
- package/dist/schemas/tables/identity/user.js +47 -0
- package/dist/schemas/tables/identity/user.js.map +1 -0
- package/dist/schemas/tables/kernel/config.d.ts +20 -0
- package/dist/schemas/tables/kernel/config.js +39 -0
- package/dist/schemas/tables/kernel/config.js.map +1 -0
- package/dist/schemas/tables/kernel/coordination.d.ts +30 -0
- package/dist/schemas/tables/kernel/coordination.js +57 -0
- package/dist/schemas/tables/kernel/coordination.js.map +1 -0
- package/dist/schemas/tables/kernel/decision.d.ts +246 -0
- package/dist/schemas/tables/kernel/decision.js +371 -0
- package/dist/schemas/tables/kernel/decision.js.map +1 -0
- package/dist/schemas/tables/kernel/embedding.d.ts +18 -0
- package/dist/schemas/tables/kernel/embedding.js +48 -0
- package/dist/schemas/tables/kernel/embedding.js.map +1 -0
- package/dist/schemas/tables/kernel/epistemic.d.ts +317 -0
- package/dist/schemas/tables/kernel/epistemic.js +329 -0
- package/dist/schemas/tables/kernel/epistemic.js.map +1 -0
- package/dist/schemas/tables/kernel/idempotency.d.ts +13 -0
- package/dist/schemas/tables/kernel/idempotency.js +31 -0
- package/dist/schemas/tables/kernel/idempotency.js.map +1 -0
- package/dist/schemas/tables/kernel/infra.d.ts +183 -0
- package/dist/schemas/tables/kernel/infra.js +182 -0
- package/dist/schemas/tables/kernel/infra.js.map +1 -0
- package/dist/schemas/tables/kernel/intelligence.d.ts +293 -0
- package/dist/schemas/tables/kernel/intelligence.js +207 -0
- package/dist/schemas/tables/kernel/intelligence.js.map +1 -0
- package/dist/schemas/tables/kernel/lens.d.ts +192 -0
- package/dist/schemas/tables/kernel/lens.js +122 -0
- package/dist/schemas/tables/kernel/lens.js.map +1 -0
- package/dist/schemas/tables/kernel/ontology.d.ts +89 -0
- package/dist/schemas/tables/kernel/ontology.js +91 -0
- package/dist/schemas/tables/kernel/ontology.js.map +1 -0
- package/dist/schemas/tables/kernel/platform.d.ts +353 -0
- package/dist/schemas/tables/kernel/platform.js +349 -0
- package/dist/schemas/tables/kernel/platform.js.map +1 -0
- package/dist/schemas/tables/kernel/spine.d.ts +206 -0
- package/dist/schemas/tables/kernel/spine.js +243 -0
- package/dist/schemas/tables/kernel/spine.js.map +1 -0
- package/dist/schemas/tables/kernel/task.d.ts +614 -0
- package/dist/schemas/tables/kernel/task.js +189 -0
- package/dist/schemas/tables/kernel/task.js.map +1 -0
- package/dist/schemas/tables/kernel/topic.d.ts +25 -0
- package/dist/schemas/tables/kernel/topic.js +62 -0
- package/dist/schemas/tables/kernel/topic.js.map +1 -0
- package/dist/schemas/tables/kernel/workflow.d.ts +45 -0
- package/dist/schemas/tables/kernel/workflow.js +94 -0
- package/dist/schemas/tables/kernel/workflow.js.map +1 -0
- package/dist/schemas/tables/kernel/worktree.d.ts +823 -0
- package/dist/schemas/tables/kernel/worktree.js +330 -0
- package/dist/schemas/tables/kernel/worktree.js.map +1 -0
- package/dist/schemas/tables/mc/identity.d.ts +134 -0
- package/dist/schemas/tables/mc/identity.js +221 -0
- package/dist/schemas/tables/mc/identity.js.map +1 -0
- package/dist/schemas/tables/mc/methodology.d.ts +46 -0
- package/dist/schemas/tables/mc/methodology.js +69 -0
- package/dist/schemas/tables/mc/methodology.js.map +1 -0
- package/dist/schemas/tables/mc/pack.d.ts +540 -0
- package/dist/schemas/tables/mc/pack.js +294 -0
- package/dist/schemas/tables/mc/pack.js.map +1 -0
- package/dist/schemas/tables/mc/policy.d.ts +57 -0
- package/dist/schemas/tables/mc/policy.js +121 -0
- package/dist/schemas/tables/mc/policy.js.map +1 -0
- package/dist/schemas/tables/mc/registry.d.ts +155 -0
- package/dist/schemas/tables/mc/registry.js +164 -0
- package/dist/schemas/tables/mc/registry.js.map +1 -0
- package/dist/schemas/tables/mc/runtime.d.ts +119 -0
- package/dist/schemas/tables/mc/runtime.js +199 -0
- package/dist/schemas/tables/mc/runtime.js.map +1 -0
- package/dist/schemas/tables/mc/tenant.d.ts +106 -0
- package/dist/schemas/tables/mc/tenant.js +114 -0
- package/dist/schemas/tables/mc/tenant.js.map +1 -0
- package/dist/schemas/tables/mc/workspace.d.ts +28 -0
- package/dist/schemas/tables/mc/workspace.js +52 -0
- package/dist/schemas/tables/mc/workspace.js.map +1 -0
- package/dist/sdk-methods.contract.d.ts +5 -2
- package/dist/{sdk-tools.contract-BnV0hKLp.d.ts → sdk-tools.contract-S4ia0TTo.d.ts} +3 -7
- package/dist/sdk-tools.contract.d.ts +2 -2
- package/dist/sdk-tools.contract.js +810 -218
- package/dist/sdk-tools.contract.js.map +1 -1
- package/dist/tool-contracts-C92-9ueT.d.ts +290 -0
- package/dist/tool-contracts.d.ts +1 -0
- package/dist/{mcp-tools.contract.js → tool-contracts.js} +812 -159
- package/dist/tool-contracts.js.map +1 -0
- package/dist/workflow-runtime.contract.js +1 -1
- package/dist/workflow-runtime.contract.js.map +1 -1
- package/package.json +137 -2
- package/dist/mcp-tools.contract-D8kXcP6d.d.ts +0 -254
- package/dist/mcp-tools.contract.d.ts +0 -1
- package/dist/mcp-tools.contract.js.map +0 -1
package/dist/dsl.js
ADDED
|
@@ -0,0 +1,678 @@
|
|
|
1
|
+
import { z, ZodFirstPartyTypeKind } from 'zod';
|
|
2
|
+
|
|
3
|
+
// src/dsl/defineFunction.ts
|
|
4
|
+
function defineFunction(spec) {
|
|
5
|
+
return spec;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
// src/dsl/defineTable.ts
|
|
9
|
+
function defineTable(spec) {
|
|
10
|
+
return spec;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
// src/dsl/errors.ts
|
|
14
|
+
function formatPath(path) {
|
|
15
|
+
if (!path || path.length === 0) {
|
|
16
|
+
return "";
|
|
17
|
+
}
|
|
18
|
+
return path.join(".");
|
|
19
|
+
}
|
|
20
|
+
function formatLocation(context) {
|
|
21
|
+
const segments = [context.adapter];
|
|
22
|
+
if (context.purpose) {
|
|
23
|
+
segments.push(context.purpose);
|
|
24
|
+
}
|
|
25
|
+
if (context.location) {
|
|
26
|
+
segments.push(context.location);
|
|
27
|
+
}
|
|
28
|
+
const formattedPath = formatPath(context.path);
|
|
29
|
+
if (formattedPath) {
|
|
30
|
+
segments.push(formattedPath);
|
|
31
|
+
}
|
|
32
|
+
return segments.join(" :: ");
|
|
33
|
+
}
|
|
34
|
+
var SchemaAdapterError = class extends Error {
|
|
35
|
+
context;
|
|
36
|
+
constructor(message, context) {
|
|
37
|
+
super(`${message} [${formatLocation(context)}]`);
|
|
38
|
+
this.name = "SchemaAdapterError";
|
|
39
|
+
this.context = context;
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
function schemaAdapterError(message, context) {
|
|
43
|
+
return new SchemaAdapterError(message, context);
|
|
44
|
+
}
|
|
45
|
+
var CONVEX_ID_TABLE = /* @__PURE__ */ Symbol.for("lucern.contracts.convexIdTable");
|
|
46
|
+
function idOf(table) {
|
|
47
|
+
const schema = z.string().brand();
|
|
48
|
+
Object.defineProperty(schema, CONVEX_ID_TABLE, {
|
|
49
|
+
configurable: false,
|
|
50
|
+
enumerable: false,
|
|
51
|
+
value: table,
|
|
52
|
+
writable: false
|
|
53
|
+
});
|
|
54
|
+
return schema;
|
|
55
|
+
}
|
|
56
|
+
function getConvexIdTable(schema) {
|
|
57
|
+
return schema[CONVEX_ID_TABLE];
|
|
58
|
+
}
|
|
59
|
+
function unsupported(message, state, path) {
|
|
60
|
+
throw schemaAdapterError(message, {
|
|
61
|
+
adapter: "cli",
|
|
62
|
+
location: state.location,
|
|
63
|
+
path
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
function getObjectShape(schema) {
|
|
67
|
+
const shape = typeof schema._def.shape === "function" ? schema._def.shape() : schema._def.shape;
|
|
68
|
+
return shape;
|
|
69
|
+
}
|
|
70
|
+
function unwrapField(schema, path) {
|
|
71
|
+
let current = schema;
|
|
72
|
+
let required = true;
|
|
73
|
+
let nullable = false;
|
|
74
|
+
let defaultValue;
|
|
75
|
+
while (true) {
|
|
76
|
+
switch (current._def.typeName) {
|
|
77
|
+
case ZodFirstPartyTypeKind.ZodOptional:
|
|
78
|
+
required = false;
|
|
79
|
+
current = current._def.innerType;
|
|
80
|
+
continue;
|
|
81
|
+
case ZodFirstPartyTypeKind.ZodDefault:
|
|
82
|
+
required = false;
|
|
83
|
+
defaultValue = current._def.defaultValue();
|
|
84
|
+
current = current._def.innerType;
|
|
85
|
+
continue;
|
|
86
|
+
case ZodFirstPartyTypeKind.ZodNullable:
|
|
87
|
+
nullable = true;
|
|
88
|
+
current = current._def.innerType;
|
|
89
|
+
continue;
|
|
90
|
+
default:
|
|
91
|
+
return {
|
|
92
|
+
schema: current,
|
|
93
|
+
required,
|
|
94
|
+
nullable,
|
|
95
|
+
defaultValue
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
function primitiveOption(name, kind, field, choices) {
|
|
101
|
+
return {
|
|
102
|
+
name,
|
|
103
|
+
kind,
|
|
104
|
+
required: field.required,
|
|
105
|
+
nullable: field.nullable || void 0,
|
|
106
|
+
defaultValue: field.defaultValue,
|
|
107
|
+
choices,
|
|
108
|
+
description: field.schema.description
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
function optionFromSchema(name, schema, state, path) {
|
|
112
|
+
const field = unwrapField(schema);
|
|
113
|
+
switch (field.schema._def.typeName) {
|
|
114
|
+
case ZodFirstPartyTypeKind.ZodString:
|
|
115
|
+
return primitiveOption(name, "string", field);
|
|
116
|
+
case ZodFirstPartyTypeKind.ZodNumber:
|
|
117
|
+
return primitiveOption(name, "number", field);
|
|
118
|
+
case ZodFirstPartyTypeKind.ZodBigInt:
|
|
119
|
+
return primitiveOption(name, "bigint", field);
|
|
120
|
+
case ZodFirstPartyTypeKind.ZodBoolean:
|
|
121
|
+
return primitiveOption(name, "boolean", field);
|
|
122
|
+
case ZodFirstPartyTypeKind.ZodEnum:
|
|
123
|
+
return primitiveOption(name, "string", field, field.schema._def.values);
|
|
124
|
+
case ZodFirstPartyTypeKind.ZodNativeEnum: {
|
|
125
|
+
const values = [...new Set(Object.values(field.schema._def.values))].filter(
|
|
126
|
+
(value) => typeof value === "string" || typeof value === "number" || typeof value === "boolean"
|
|
127
|
+
);
|
|
128
|
+
return primitiveOption(
|
|
129
|
+
name,
|
|
130
|
+
values.every((value) => typeof value === "number") ? "number" : "string",
|
|
131
|
+
field,
|
|
132
|
+
values
|
|
133
|
+
);
|
|
134
|
+
}
|
|
135
|
+
case ZodFirstPartyTypeKind.ZodLiteral:
|
|
136
|
+
return primitiveOption(name, "string", field, [field.schema._def.value]);
|
|
137
|
+
case ZodFirstPartyTypeKind.ZodArray: {
|
|
138
|
+
const item = unwrapField(field.schema._def.type, [...path, "[]"]);
|
|
139
|
+
switch (item.schema._def.typeName) {
|
|
140
|
+
case ZodFirstPartyTypeKind.ZodString:
|
|
141
|
+
return { ...primitiveOption(name, "string", field), variadic: true };
|
|
142
|
+
case ZodFirstPartyTypeKind.ZodNumber:
|
|
143
|
+
return { ...primitiveOption(name, "number", field), variadic: true };
|
|
144
|
+
case ZodFirstPartyTypeKind.ZodBigInt:
|
|
145
|
+
return { ...primitiveOption(name, "bigint", field), variadic: true };
|
|
146
|
+
case ZodFirstPartyTypeKind.ZodBoolean:
|
|
147
|
+
return { ...primitiveOption(name, "boolean", field), variadic: true };
|
|
148
|
+
default:
|
|
149
|
+
return {
|
|
150
|
+
...primitiveOption(name, "json", field),
|
|
151
|
+
variadic: false
|
|
152
|
+
};
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
case ZodFirstPartyTypeKind.ZodLazy: {
|
|
156
|
+
const lazySchema = field.schema;
|
|
157
|
+
if (state.seenLazySchemas.has(lazySchema)) {
|
|
158
|
+
unsupported(
|
|
159
|
+
"Recursive z.lazy schemas are not supported by the CLI adapter",
|
|
160
|
+
state,
|
|
161
|
+
path
|
|
162
|
+
);
|
|
163
|
+
}
|
|
164
|
+
state.seenLazySchemas.add(lazySchema);
|
|
165
|
+
try {
|
|
166
|
+
return optionFromSchema(name, lazySchema._def.getter(), state, path);
|
|
167
|
+
} finally {
|
|
168
|
+
state.seenLazySchemas.delete(lazySchema);
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
case ZodFirstPartyTypeKind.ZodBranded:
|
|
172
|
+
return primitiveOption(name, "string", field);
|
|
173
|
+
case ZodFirstPartyTypeKind.ZodObject:
|
|
174
|
+
case ZodFirstPartyTypeKind.ZodUnion:
|
|
175
|
+
case ZodFirstPartyTypeKind.ZodDiscriminatedUnion:
|
|
176
|
+
case ZodFirstPartyTypeKind.ZodRecord:
|
|
177
|
+
case ZodFirstPartyTypeKind.ZodAny:
|
|
178
|
+
case ZodFirstPartyTypeKind.ZodUnknown:
|
|
179
|
+
return primitiveOption(name, "json", field);
|
|
180
|
+
default:
|
|
181
|
+
unsupported(
|
|
182
|
+
`Unsupported Zod schema kind ${field.schema._def.typeName}`,
|
|
183
|
+
state,
|
|
184
|
+
path
|
|
185
|
+
);
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
function zodToCli(schema, options = {}) {
|
|
189
|
+
if (schema._def.typeName !== ZodFirstPartyTypeKind.ZodObject) {
|
|
190
|
+
throw schemaAdapterError("CLI generation requires a Zod object schema", {
|
|
191
|
+
adapter: "cli",
|
|
192
|
+
location: options.location,
|
|
193
|
+
path: []
|
|
194
|
+
});
|
|
195
|
+
}
|
|
196
|
+
const state = {
|
|
197
|
+
location: options.location,
|
|
198
|
+
seenLazySchemas: /* @__PURE__ */ new WeakSet()
|
|
199
|
+
};
|
|
200
|
+
const optionsList = Object.entries(getObjectShape(schema)).sort(([left], [right]) => left.localeCompare(right)).map(([name, value]) => optionFromSchema(name, value, state, [name]));
|
|
201
|
+
return {
|
|
202
|
+
options: optionsList
|
|
203
|
+
};
|
|
204
|
+
}
|
|
205
|
+
function encodeLiteral(value) {
|
|
206
|
+
if (typeof value === "bigint") {
|
|
207
|
+
return `${value}n`;
|
|
208
|
+
}
|
|
209
|
+
return JSON.stringify(value);
|
|
210
|
+
}
|
|
211
|
+
function quoteKey(value) {
|
|
212
|
+
return JSON.stringify(value);
|
|
213
|
+
}
|
|
214
|
+
function sortEntries(entries) {
|
|
215
|
+
return [...entries].sort(([left], [right]) => left.localeCompare(right));
|
|
216
|
+
}
|
|
217
|
+
function getObjectShape2(schema) {
|
|
218
|
+
const shape = typeof schema._def.shape === "function" ? schema._def.shape() : schema._def.shape;
|
|
219
|
+
return shape;
|
|
220
|
+
}
|
|
221
|
+
function unwrapOptionalLike(schema, state, path) {
|
|
222
|
+
const defaults = [];
|
|
223
|
+
let current = schema;
|
|
224
|
+
let isOptional = false;
|
|
225
|
+
while (true) {
|
|
226
|
+
switch (current._def.typeName) {
|
|
227
|
+
case ZodFirstPartyTypeKind.ZodOptional:
|
|
228
|
+
isOptional = true;
|
|
229
|
+
current = current._def.innerType;
|
|
230
|
+
continue;
|
|
231
|
+
case ZodFirstPartyTypeKind.ZodDefault: {
|
|
232
|
+
if (state.purpose === "table") {
|
|
233
|
+
throw schemaAdapterError(
|
|
234
|
+
"Zod defaults are not allowed in table contracts",
|
|
235
|
+
{
|
|
236
|
+
adapter: "convex",
|
|
237
|
+
purpose: state.purpose,
|
|
238
|
+
location: state.location,
|
|
239
|
+
path
|
|
240
|
+
}
|
|
241
|
+
);
|
|
242
|
+
}
|
|
243
|
+
isOptional = true;
|
|
244
|
+
defaults.push({
|
|
245
|
+
path,
|
|
246
|
+
value: current._def.defaultValue()
|
|
247
|
+
});
|
|
248
|
+
current = current._def.innerType;
|
|
249
|
+
continue;
|
|
250
|
+
}
|
|
251
|
+
default:
|
|
252
|
+
return {
|
|
253
|
+
schema: current,
|
|
254
|
+
isOptional,
|
|
255
|
+
defaults
|
|
256
|
+
};
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
function convertSchema(schema, state, path) {
|
|
261
|
+
const { schema: unwrapped, isOptional, defaults } = unwrapOptionalLike(
|
|
262
|
+
schema,
|
|
263
|
+
state,
|
|
264
|
+
path
|
|
265
|
+
);
|
|
266
|
+
const converted = convertSchemaInner(unwrapped, state, path);
|
|
267
|
+
return {
|
|
268
|
+
source: isOptional ? `v.optional(${converted.source})` : converted.source,
|
|
269
|
+
defaults: [...defaults, ...converted.defaults]
|
|
270
|
+
};
|
|
271
|
+
}
|
|
272
|
+
function enumToUnion(values) {
|
|
273
|
+
if (values.length === 0) {
|
|
274
|
+
return "v.never()";
|
|
275
|
+
}
|
|
276
|
+
if (values.length === 1) {
|
|
277
|
+
return `v.literal(${encodeLiteral(values[0])})`;
|
|
278
|
+
}
|
|
279
|
+
return `v.union(${values.map((value) => `v.literal(${encodeLiteral(value)})`).join(", ")})`;
|
|
280
|
+
}
|
|
281
|
+
function unsupported2(message, state, path) {
|
|
282
|
+
throw schemaAdapterError(message, {
|
|
283
|
+
adapter: "convex",
|
|
284
|
+
purpose: state.purpose,
|
|
285
|
+
location: state.location,
|
|
286
|
+
path
|
|
287
|
+
});
|
|
288
|
+
}
|
|
289
|
+
function convertLazy(schema, state, path) {
|
|
290
|
+
const lazySchema = schema;
|
|
291
|
+
if (state.seenLazySchemas.has(lazySchema)) {
|
|
292
|
+
unsupported2(
|
|
293
|
+
"Recursive z.lazy schemas are not supported by the Convex adapter",
|
|
294
|
+
state,
|
|
295
|
+
path
|
|
296
|
+
);
|
|
297
|
+
}
|
|
298
|
+
state.seenLazySchemas.add(lazySchema);
|
|
299
|
+
try {
|
|
300
|
+
return convertSchema(lazySchema._def.getter(), state, path);
|
|
301
|
+
} finally {
|
|
302
|
+
state.seenLazySchemas.delete(lazySchema);
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
function convertSchemaInner(schema, state, path) {
|
|
306
|
+
const idTable = getConvexIdTable(schema);
|
|
307
|
+
if (idTable) {
|
|
308
|
+
return {
|
|
309
|
+
source: `v.id(${JSON.stringify(idTable)})`,
|
|
310
|
+
defaults: []
|
|
311
|
+
};
|
|
312
|
+
}
|
|
313
|
+
switch (schema._def.typeName) {
|
|
314
|
+
case ZodFirstPartyTypeKind.ZodString:
|
|
315
|
+
return { source: "v.string()", defaults: [] };
|
|
316
|
+
case ZodFirstPartyTypeKind.ZodNumber:
|
|
317
|
+
return { source: "v.number()", defaults: [] };
|
|
318
|
+
case ZodFirstPartyTypeKind.ZodBigInt:
|
|
319
|
+
return { source: "v.int64()", defaults: [] };
|
|
320
|
+
case ZodFirstPartyTypeKind.ZodBoolean:
|
|
321
|
+
return { source: "v.boolean()", defaults: [] };
|
|
322
|
+
case ZodFirstPartyTypeKind.ZodNull:
|
|
323
|
+
return { source: "v.null()", defaults: [] };
|
|
324
|
+
case ZodFirstPartyTypeKind.ZodAny:
|
|
325
|
+
case ZodFirstPartyTypeKind.ZodUnknown:
|
|
326
|
+
return { source: "v.any()", defaults: [] };
|
|
327
|
+
case ZodFirstPartyTypeKind.ZodLiteral: {
|
|
328
|
+
return {
|
|
329
|
+
source: `v.literal(${encodeLiteral(schema._def.value)})`,
|
|
330
|
+
defaults: []
|
|
331
|
+
};
|
|
332
|
+
}
|
|
333
|
+
case ZodFirstPartyTypeKind.ZodEnum:
|
|
334
|
+
return {
|
|
335
|
+
source: enumToUnion(schema._def.values),
|
|
336
|
+
defaults: []
|
|
337
|
+
};
|
|
338
|
+
case ZodFirstPartyTypeKind.ZodNativeEnum: {
|
|
339
|
+
const values = Object.values(schema._def.values).filter(
|
|
340
|
+
(value) => typeof value === "string" || typeof value === "number"
|
|
341
|
+
);
|
|
342
|
+
return {
|
|
343
|
+
source: enumToUnion([...new Set(values)]),
|
|
344
|
+
defaults: []
|
|
345
|
+
};
|
|
346
|
+
}
|
|
347
|
+
case ZodFirstPartyTypeKind.ZodNullable: {
|
|
348
|
+
const inner = convertSchema(schema._def.innerType, state, path);
|
|
349
|
+
return {
|
|
350
|
+
source: `v.nullable(${inner.source})`,
|
|
351
|
+
defaults: inner.defaults
|
|
352
|
+
};
|
|
353
|
+
}
|
|
354
|
+
case ZodFirstPartyTypeKind.ZodArray: {
|
|
355
|
+
const inner = convertSchema(schema._def.type, state, [...path, "[]"]);
|
|
356
|
+
return {
|
|
357
|
+
source: `v.array(${inner.source})`,
|
|
358
|
+
defaults: inner.defaults
|
|
359
|
+
};
|
|
360
|
+
}
|
|
361
|
+
case ZodFirstPartyTypeKind.ZodObject: {
|
|
362
|
+
const objectSchema = schema;
|
|
363
|
+
if (objectSchema._def.catchall && objectSchema._def.catchall._def.typeName !== ZodFirstPartyTypeKind.ZodNever) {
|
|
364
|
+
unsupported2(
|
|
365
|
+
"Zod objects with catchall/passthrough fields cannot be lowered to Convex validators",
|
|
366
|
+
state,
|
|
367
|
+
path
|
|
368
|
+
);
|
|
369
|
+
}
|
|
370
|
+
const fields = sortEntries(Object.entries(getObjectShape2(objectSchema)));
|
|
371
|
+
const convertedFields = fields.map(([key, value]) => [
|
|
372
|
+
key,
|
|
373
|
+
convertSchema(value, state, [...path, key])
|
|
374
|
+
]);
|
|
375
|
+
return {
|
|
376
|
+
source: `v.object({ ${convertedFields.map(([key, converted]) => `${quoteKey(key)}: ${converted.source}`).join(", ")} })`,
|
|
377
|
+
defaults: convertedFields.flatMap(([, converted]) => converted.defaults)
|
|
378
|
+
};
|
|
379
|
+
}
|
|
380
|
+
case ZodFirstPartyTypeKind.ZodUnion: {
|
|
381
|
+
const members = schema._def.options.map(
|
|
382
|
+
(option, index) => convertSchema(option, state, [...path, String(index)])
|
|
383
|
+
);
|
|
384
|
+
return {
|
|
385
|
+
source: `v.union(${members.map((member) => member.source).join(", ")})`,
|
|
386
|
+
defaults: members.flatMap((member) => member.defaults)
|
|
387
|
+
};
|
|
388
|
+
}
|
|
389
|
+
case ZodFirstPartyTypeKind.ZodDiscriminatedUnion: {
|
|
390
|
+
const discriminatedUnion = schema;
|
|
391
|
+
const options = discriminatedUnion.options instanceof Map ? [...discriminatedUnion.options.values()] : [...discriminatedUnion.options];
|
|
392
|
+
const members = options.map(
|
|
393
|
+
(option, index) => convertSchema(option, state, [...path, String(index)])
|
|
394
|
+
);
|
|
395
|
+
return {
|
|
396
|
+
source: `v.union(${members.map((member) => member.source).join(", ")})`,
|
|
397
|
+
defaults: members.flatMap((member) => member.defaults)
|
|
398
|
+
};
|
|
399
|
+
}
|
|
400
|
+
case ZodFirstPartyTypeKind.ZodRecord: {
|
|
401
|
+
const keyType = schema._def.keyType;
|
|
402
|
+
if (keyType && keyType._def.typeName !== ZodFirstPartyTypeKind.ZodString) {
|
|
403
|
+
unsupported2(
|
|
404
|
+
"Only string-keyed z.record schemas can be lowered to Convex validators",
|
|
405
|
+
state,
|
|
406
|
+
path
|
|
407
|
+
);
|
|
408
|
+
}
|
|
409
|
+
const value = convertSchema(schema._def.valueType, state, [...path, "{}"]);
|
|
410
|
+
return {
|
|
411
|
+
source: `v.record(v.string(), ${value.source})`,
|
|
412
|
+
defaults: value.defaults
|
|
413
|
+
};
|
|
414
|
+
}
|
|
415
|
+
case ZodFirstPartyTypeKind.ZodLazy:
|
|
416
|
+
return convertLazy(schema, state, path);
|
|
417
|
+
case ZodFirstPartyTypeKind.ZodBranded: {
|
|
418
|
+
return convertSchema(schema._def.type, state, path);
|
|
419
|
+
}
|
|
420
|
+
case ZodFirstPartyTypeKind.ZodEffects: {
|
|
421
|
+
return convertSchema(schema._def.schema, state, path);
|
|
422
|
+
}
|
|
423
|
+
default:
|
|
424
|
+
unsupported2(`Unsupported Zod schema kind ${schema._def.typeName}`, state, path);
|
|
425
|
+
}
|
|
426
|
+
}
|
|
427
|
+
function zodToConvex(schema, options = {}) {
|
|
428
|
+
const state = {
|
|
429
|
+
location: options.location,
|
|
430
|
+
purpose: options.purpose ?? "function_returns",
|
|
431
|
+
seenLazySchemas: /* @__PURE__ */ new WeakSet()
|
|
432
|
+
};
|
|
433
|
+
const converted = convertSchema(schema, state, []);
|
|
434
|
+
return {
|
|
435
|
+
source: converted.source,
|
|
436
|
+
defaults: converted.defaults
|
|
437
|
+
};
|
|
438
|
+
}
|
|
439
|
+
function tableIndexToConvexSource(index) {
|
|
440
|
+
switch (index.kind) {
|
|
441
|
+
case "index":
|
|
442
|
+
return `.index(${JSON.stringify(index.name)}, [${index.columns.map((column) => JSON.stringify(column)).join(", ")}])`;
|
|
443
|
+
case "search":
|
|
444
|
+
return `.searchIndex(${JSON.stringify(index.name)}, { searchField: ${JSON.stringify(
|
|
445
|
+
index.searchField
|
|
446
|
+
)}${index.filterFields?.length ? `, filterFields: [${index.filterFields.map((field) => JSON.stringify(field)).join(", ")}]` : ""} })`;
|
|
447
|
+
case "vector":
|
|
448
|
+
return `.vectorIndex(${JSON.stringify(index.name)}, { vectorField: ${JSON.stringify(
|
|
449
|
+
index.vectorField
|
|
450
|
+
)}, dimensions: ${index.dimensions}${index.filterFields?.length ? `, filterFields: [${index.filterFields.map((field) => JSON.stringify(field)).join(", ")}]` : ""} })`;
|
|
451
|
+
default: {
|
|
452
|
+
const exhaustive = index;
|
|
453
|
+
throw new SchemaAdapterError(
|
|
454
|
+
`Unsupported table index kind ${exhaustive.kind ?? "unknown"}`,
|
|
455
|
+
{ adapter: "convex" }
|
|
456
|
+
);
|
|
457
|
+
}
|
|
458
|
+
}
|
|
459
|
+
}
|
|
460
|
+
function unsupported3(message, state, path) {
|
|
461
|
+
throw schemaAdapterError(message, {
|
|
462
|
+
adapter: "jsonschema",
|
|
463
|
+
location: state.location,
|
|
464
|
+
path
|
|
465
|
+
});
|
|
466
|
+
}
|
|
467
|
+
function getObjectShape3(schema) {
|
|
468
|
+
const shape = typeof schema._def.shape === "function" ? schema._def.shape() : schema._def.shape;
|
|
469
|
+
return shape;
|
|
470
|
+
}
|
|
471
|
+
function unwrapOptionalLike2(schema, state, path) {
|
|
472
|
+
let current = schema;
|
|
473
|
+
let required = true;
|
|
474
|
+
let defaultValue;
|
|
475
|
+
while (true) {
|
|
476
|
+
switch (current._def.typeName) {
|
|
477
|
+
case ZodFirstPartyTypeKind.ZodOptional:
|
|
478
|
+
required = false;
|
|
479
|
+
current = current._def.innerType;
|
|
480
|
+
continue;
|
|
481
|
+
case ZodFirstPartyTypeKind.ZodDefault:
|
|
482
|
+
required = false;
|
|
483
|
+
defaultValue = current._def.defaultValue();
|
|
484
|
+
current = current._def.innerType;
|
|
485
|
+
continue;
|
|
486
|
+
default:
|
|
487
|
+
return {
|
|
488
|
+
schema: current,
|
|
489
|
+
required,
|
|
490
|
+
defaultValue
|
|
491
|
+
};
|
|
492
|
+
}
|
|
493
|
+
}
|
|
494
|
+
}
|
|
495
|
+
function convertLazy2(schema, state, path) {
|
|
496
|
+
if (state.seenLazySchemas.has(schema)) {
|
|
497
|
+
unsupported3(
|
|
498
|
+
"Recursive z.lazy schemas are not supported by the JSON Schema adapter",
|
|
499
|
+
state,
|
|
500
|
+
path
|
|
501
|
+
);
|
|
502
|
+
}
|
|
503
|
+
state.seenLazySchemas.add(schema);
|
|
504
|
+
try {
|
|
505
|
+
return convertSchema2(schema._def.getter(), state, path);
|
|
506
|
+
} finally {
|
|
507
|
+
state.seenLazySchemas.delete(schema);
|
|
508
|
+
}
|
|
509
|
+
}
|
|
510
|
+
function literalType(value) {
|
|
511
|
+
switch (typeof value) {
|
|
512
|
+
case "string":
|
|
513
|
+
return "string";
|
|
514
|
+
case "number":
|
|
515
|
+
return Number.isInteger(value) ? "integer" : "number";
|
|
516
|
+
case "boolean":
|
|
517
|
+
return "boolean";
|
|
518
|
+
case "bigint":
|
|
519
|
+
return "integer";
|
|
520
|
+
default:
|
|
521
|
+
return value === null ? "null" : void 0;
|
|
522
|
+
}
|
|
523
|
+
}
|
|
524
|
+
function convertField(schema, state, path) {
|
|
525
|
+
const { schema: unwrapped, required, defaultValue } = unwrapOptionalLike2(
|
|
526
|
+
schema);
|
|
527
|
+
const field = convertSchema2(unwrapped, state, path);
|
|
528
|
+
if (typeof field === "boolean") {
|
|
529
|
+
return {
|
|
530
|
+
schema: field,
|
|
531
|
+
required
|
|
532
|
+
};
|
|
533
|
+
}
|
|
534
|
+
return {
|
|
535
|
+
schema: defaultValue === void 0 ? field : { ...field, default: defaultValue },
|
|
536
|
+
required
|
|
537
|
+
};
|
|
538
|
+
}
|
|
539
|
+
function convertSchema2(schema, state, path) {
|
|
540
|
+
const idTable = getConvexIdTable(schema);
|
|
541
|
+
if (idTable) {
|
|
542
|
+
return {
|
|
543
|
+
type: "string",
|
|
544
|
+
"x-convex-id-table": idTable
|
|
545
|
+
};
|
|
546
|
+
}
|
|
547
|
+
switch (schema._def.typeName) {
|
|
548
|
+
case ZodFirstPartyTypeKind.ZodString:
|
|
549
|
+
return { type: "string" };
|
|
550
|
+
case ZodFirstPartyTypeKind.ZodNumber:
|
|
551
|
+
return { type: "number" };
|
|
552
|
+
case ZodFirstPartyTypeKind.ZodBigInt:
|
|
553
|
+
return { type: "integer", format: "int64" };
|
|
554
|
+
case ZodFirstPartyTypeKind.ZodBoolean:
|
|
555
|
+
return { type: "boolean" };
|
|
556
|
+
case ZodFirstPartyTypeKind.ZodNull:
|
|
557
|
+
return { type: "null" };
|
|
558
|
+
case ZodFirstPartyTypeKind.ZodAny:
|
|
559
|
+
case ZodFirstPartyTypeKind.ZodUnknown:
|
|
560
|
+
return {};
|
|
561
|
+
case ZodFirstPartyTypeKind.ZodLiteral:
|
|
562
|
+
return {
|
|
563
|
+
const: schema._def.value,
|
|
564
|
+
type: literalType(schema._def.value)
|
|
565
|
+
};
|
|
566
|
+
case ZodFirstPartyTypeKind.ZodEnum:
|
|
567
|
+
return {
|
|
568
|
+
type: "string",
|
|
569
|
+
enum: schema._def.values
|
|
570
|
+
};
|
|
571
|
+
case ZodFirstPartyTypeKind.ZodNativeEnum: {
|
|
572
|
+
const values = [...new Set(Object.values(schema._def.values))].filter(
|
|
573
|
+
(value) => typeof value === "string" || typeof value === "number" || typeof value === "boolean"
|
|
574
|
+
);
|
|
575
|
+
return {
|
|
576
|
+
type: values.every((value) => typeof value === "number") ? "number" : "string",
|
|
577
|
+
enum: values
|
|
578
|
+
};
|
|
579
|
+
}
|
|
580
|
+
case ZodFirstPartyTypeKind.ZodNullable: {
|
|
581
|
+
const inner = convertSchema2(schema._def.innerType, state, path);
|
|
582
|
+
return {
|
|
583
|
+
anyOf: [inner, { type: "null" }]
|
|
584
|
+
};
|
|
585
|
+
}
|
|
586
|
+
case ZodFirstPartyTypeKind.ZodArray:
|
|
587
|
+
return {
|
|
588
|
+
type: "array",
|
|
589
|
+
items: convertSchema2(schema._def.type, state, [...path, "[]"])
|
|
590
|
+
};
|
|
591
|
+
case ZodFirstPartyTypeKind.ZodObject: {
|
|
592
|
+
const objectSchema = schema;
|
|
593
|
+
if (objectSchema._def.catchall && objectSchema._def.catchall._def.typeName !== ZodFirstPartyTypeKind.ZodNever) {
|
|
594
|
+
unsupported3(
|
|
595
|
+
"Zod objects with catchall/passthrough fields cannot be lowered to JSON Schema",
|
|
596
|
+
state,
|
|
597
|
+
path
|
|
598
|
+
);
|
|
599
|
+
}
|
|
600
|
+
const entries = Object.entries(getObjectShape3(objectSchema)).sort(
|
|
601
|
+
([a], [b]) => a.localeCompare(b)
|
|
602
|
+
);
|
|
603
|
+
const converted = entries.map(([key, value]) => [
|
|
604
|
+
key,
|
|
605
|
+
convertField(value, state, [...path, key])
|
|
606
|
+
]);
|
|
607
|
+
const required = converted.filter(([, field]) => field.required).map(([key]) => key);
|
|
608
|
+
return {
|
|
609
|
+
type: "object",
|
|
610
|
+
properties: Object.fromEntries(
|
|
611
|
+
converted.map(([key, field]) => [key, field.schema])
|
|
612
|
+
),
|
|
613
|
+
additionalProperties: false,
|
|
614
|
+
...required.length > 0 ? { required } : {}
|
|
615
|
+
};
|
|
616
|
+
}
|
|
617
|
+
case ZodFirstPartyTypeKind.ZodUnion:
|
|
618
|
+
return {
|
|
619
|
+
anyOf: schema._def.options.map(
|
|
620
|
+
(option, index) => convertSchema2(option, state, [...path, String(index)])
|
|
621
|
+
)
|
|
622
|
+
};
|
|
623
|
+
case ZodFirstPartyTypeKind.ZodDiscriminatedUnion: {
|
|
624
|
+
const discriminatedUnion = schema;
|
|
625
|
+
const options = discriminatedUnion.options instanceof Map ? [...discriminatedUnion.options.values()] : [...discriminatedUnion.options];
|
|
626
|
+
return {
|
|
627
|
+
oneOf: options.map(
|
|
628
|
+
(option, index) => convertSchema2(option, state, [...path, String(index)])
|
|
629
|
+
)
|
|
630
|
+
};
|
|
631
|
+
}
|
|
632
|
+
case ZodFirstPartyTypeKind.ZodRecord: {
|
|
633
|
+
const keyType = schema._def.keyType;
|
|
634
|
+
if (keyType && keyType._def.typeName !== ZodFirstPartyTypeKind.ZodString) {
|
|
635
|
+
unsupported3(
|
|
636
|
+
"Only string-keyed z.record schemas can be lowered to JSON Schema",
|
|
637
|
+
state,
|
|
638
|
+
path
|
|
639
|
+
);
|
|
640
|
+
}
|
|
641
|
+
return {
|
|
642
|
+
type: "object",
|
|
643
|
+
additionalProperties: convertSchema2(
|
|
644
|
+
schema._def.valueType,
|
|
645
|
+
state,
|
|
646
|
+
[...path, "{}"]
|
|
647
|
+
)
|
|
648
|
+
};
|
|
649
|
+
}
|
|
650
|
+
case ZodFirstPartyTypeKind.ZodLazy:
|
|
651
|
+
return convertLazy2(schema, state, path);
|
|
652
|
+
case ZodFirstPartyTypeKind.ZodBranded:
|
|
653
|
+
return convertSchema2(schema._def.type, state, path);
|
|
654
|
+
default:
|
|
655
|
+
unsupported3(
|
|
656
|
+
`Unsupported Zod schema kind ${schema._def.typeName}`,
|
|
657
|
+
state,
|
|
658
|
+
path
|
|
659
|
+
);
|
|
660
|
+
}
|
|
661
|
+
}
|
|
662
|
+
function zodToJsonSchema(schema, options = {}) {
|
|
663
|
+
const converted = convertSchema2(schema, {
|
|
664
|
+
location: options.location,
|
|
665
|
+
seenLazySchemas: /* @__PURE__ */ new WeakSet()
|
|
666
|
+
}, []);
|
|
667
|
+
if (typeof converted === "boolean") {
|
|
668
|
+
return converted;
|
|
669
|
+
}
|
|
670
|
+
return {
|
|
671
|
+
$schema: "http://json-schema.org/draft-07/schema#",
|
|
672
|
+
...converted
|
|
673
|
+
};
|
|
674
|
+
}
|
|
675
|
+
|
|
676
|
+
export { CONVEX_ID_TABLE, SchemaAdapterError, defineFunction, defineTable, getConvexIdTable, idOf, schemaAdapterError, tableIndexToConvexSource, zodToCli, zodToConvex, zodToJsonSchema };
|
|
677
|
+
//# sourceMappingURL=dsl.js.map
|
|
678
|
+
//# sourceMappingURL=dsl.js.map
|