zodvex 0.7.7-beta.1 → 0.7.7
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/cli/index.js +296 -81
- package/dist/cli/index.js.map +1 -1
- package/dist/client/index.js +2 -2
- package/dist/client/index.js.map +1 -1
- package/dist/codegen/index.js +211 -28
- package/dist/codegen/index.js.map +1 -1
- package/dist/core/index.js +33 -16
- package/dist/core/index.js.map +1 -1
- package/dist/index.js +33 -16
- package/dist/index.js.map +1 -1
- package/dist/internal/boundaryHelpers.d.ts +2 -15
- package/dist/internal/boundaryHelpers.d.ts.map +1 -1
- package/dist/internal/registry.d.ts.map +1 -1
- package/dist/internal/zx.d.ts.map +1 -1
- package/dist/internal/zxDateBrand.d.ts +5 -0
- package/dist/internal/zxDateBrand.d.ts.map +1 -0
- package/dist/legacy/index.js +21 -10
- package/dist/legacy/index.js.map +1 -1
- package/dist/mini/client/index.js +2 -2
- package/dist/mini/client/index.js.map +1 -1
- package/dist/mini/index.js +33 -16
- package/dist/mini/index.js.map +1 -1
- package/dist/mini/react/index.js +2 -2
- package/dist/mini/react/index.js.map +1 -1
- package/dist/mini/server/index.js +23 -12
- package/dist/mini/server/index.js.map +1 -1
- package/dist/public/cli/commands.d.ts.map +1 -1
- package/dist/public/codegen/discover.d.ts.map +1 -1
- package/dist/public/codegen/discovery-hooks.d.ts +2 -1
- package/dist/public/codegen/discovery-hooks.d.ts.map +1 -1
- package/dist/public/codegen/extractCodec.d.ts.map +1 -1
- package/dist/public/codegen/tsconfigPaths.d.ts +41 -0
- package/dist/public/codegen/tsconfigPaths.d.ts.map +1 -0
- package/dist/public/codegen/zodToSource.d.ts.map +1 -1
- package/dist/react/index.js +2 -2
- package/dist/react/index.js.map +1 -1
- package/dist/server/index.js +23 -12
- package/dist/server/index.js.map +1 -1
- package/package.json +1 -1
- package/src/internal/boundaryHelpers.ts +15 -3
- package/src/internal/registry.ts +12 -9
- package/src/internal/zx.ts +12 -9
- package/src/internal/zxDateBrand.ts +34 -0
- package/src/public/cli/commands.ts +59 -17
- package/src/public/codegen/discover.ts +27 -15
- package/src/public/codegen/discovery-hooks.ts +42 -3
- package/src/public/codegen/extractCodec.ts +5 -11
- package/src/public/codegen/tsconfigPaths.ts +224 -0
- package/src/public/codegen/zodToSource.ts +5 -6
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { $ZodError, encode, $ZodObject, $ZodType, globalRegistry, $ZodDate, $ZodCodec, $
|
|
1
|
+
import { $ZodError, encode, $ZodObject, $ZodType, globalRegistry, $ZodDate, $ZodCodec, $ZodOptional, $ZodNullable, $ZodDefault, parse, clone, safeParse, $ZodArray, $ZodLazy, $ZodTuple, $ZodRecord, $ZodEnum, $ZodLiteral, $ZodUnion, $ZodDiscriminatedUnion } from 'zod/v4/core';
|
|
2
2
|
import { z } from 'zod';
|
|
3
3
|
import { v } from 'convex/values';
|
|
4
4
|
|
|
@@ -101,9 +101,9 @@ var ZodvexDecodeError = class extends $ZodError {
|
|
|
101
101
|
this.name = "ZodvexDecodeError";
|
|
102
102
|
}
|
|
103
103
|
};
|
|
104
|
+
var warnedPaths = /* @__PURE__ */ new Set();
|
|
104
105
|
function createBoundaryHelpers(registry, options) {
|
|
105
106
|
const onDecodeError = options?.onDecodeError ?? "warn";
|
|
106
|
-
const warnedPaths = /* @__PURE__ */ new Set();
|
|
107
107
|
function encodeArgs(ref, args) {
|
|
108
108
|
if (args == null) return args;
|
|
109
109
|
const path = resolveFunctionPath(ref);
|
|
@@ -113,7 +113,7 @@ function createBoundaryHelpers(registry, options) {
|
|
|
113
113
|
if (entry === void 0 && !warnedPaths.has(path)) {
|
|
114
114
|
warnedPaths.add(path);
|
|
115
115
|
console.debug(
|
|
116
|
-
`[zodvex] No registry entry for "${path}" \u2014 args
|
|
116
|
+
`[zodvex] No registry entry for "${path}" \u2014 args/returns pass through unencoded. This is expected when the target is a raw (non-zodvex) function; if it should be codec-aware, run \`zodvex generate\` to update the registry.`
|
|
117
117
|
);
|
|
118
118
|
}
|
|
119
119
|
return args;
|
|
@@ -581,6 +581,22 @@ function zodToConvexFields(zod) {
|
|
|
581
581
|
}
|
|
582
582
|
return result;
|
|
583
583
|
}
|
|
584
|
+
|
|
585
|
+
// src/internal/zxDateBrand.ts
|
|
586
|
+
var ZX_DATE_BRAND = /* @__PURE__ */ Symbol.for("zodvex.zxDate");
|
|
587
|
+
function brandZxDate(codec2) {
|
|
588
|
+
codec2[ZX_DATE_BRAND] = true;
|
|
589
|
+
const def = codec2._zod?.def;
|
|
590
|
+
if (def) def[ZX_DATE_BRAND] = true;
|
|
591
|
+
return codec2;
|
|
592
|
+
}
|
|
593
|
+
function isZxDateCodec(schema) {
|
|
594
|
+
if (!schema || typeof schema !== "object") return false;
|
|
595
|
+
const s = schema;
|
|
596
|
+
return s[ZX_DATE_BRAND] === true || s._zod?.def?.[ZX_DATE_BRAND] === true;
|
|
597
|
+
}
|
|
598
|
+
|
|
599
|
+
// src/internal/registry.ts
|
|
584
600
|
function isZidSchema(schema) {
|
|
585
601
|
const description = globalRegistry.get(schema)?.description;
|
|
586
602
|
return typeof description === "string" && description.startsWith("convexId:");
|
|
@@ -611,7 +627,7 @@ function zodvexJSONSchemaOverride(ctx) {
|
|
|
611
627
|
jsonSchema.format = "date-time";
|
|
612
628
|
return;
|
|
613
629
|
}
|
|
614
|
-
if (zodSchema
|
|
630
|
+
if (isZxDateCodec(zodSchema)) {
|
|
615
631
|
jsonSchema.type = "string";
|
|
616
632
|
jsonSchema.format = "date-time";
|
|
617
633
|
const description = globalRegistry.get(zodSchema)?.description;
|
|
@@ -863,8 +879,7 @@ function findCodec(schema) {
|
|
|
863
879
|
let current = schema;
|
|
864
880
|
for (let i = 0; i < 10; i++) {
|
|
865
881
|
if (current instanceof $ZodCodec) {
|
|
866
|
-
|
|
867
|
-
if (isZxDate) return void 0;
|
|
882
|
+
if (isZxDateCodec(current)) return void 0;
|
|
868
883
|
return current;
|
|
869
884
|
}
|
|
870
885
|
if (current instanceof $ZodOptional || current instanceof $ZodNullable) {
|
|
@@ -897,16 +912,18 @@ function readFnReturns(fn) {
|
|
|
897
912
|
return meta.zodReturns;
|
|
898
913
|
}
|
|
899
914
|
function date() {
|
|
900
|
-
return
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
915
|
+
return brandZxDate(
|
|
916
|
+
zodvexCodec(
|
|
917
|
+
z.number(),
|
|
918
|
+
// Wire: timestamp
|
|
919
|
+
z.custom((val) => val instanceof Date, {
|
|
920
|
+
message: "Expected Date instance"
|
|
921
|
+
}),
|
|
922
|
+
{
|
|
923
|
+
decode: (timestamp) => new Date(timestamp),
|
|
924
|
+
encode: (date2) => date2.getTime()
|
|
925
|
+
}
|
|
926
|
+
)
|
|
910
927
|
);
|
|
911
928
|
}
|
|
912
929
|
function id(tableName) {
|