surreal-zod 0.0.0-alpha.1 → 0.0.0-alpha.3

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/lib/index.d.ts ADDED
@@ -0,0 +1,3 @@
1
+ import * as sz from "./zod";
2
+ export { sz };
3
+ export default sz;
package/lib/print.d.ts ADDED
@@ -0,0 +1,2 @@
1
+ import type * as z4 from "zod/v4/core";
2
+ export declare function zodToSexpr(schema: z4.$ZodType): string;
package/lib/surql.d.ts ADDED
@@ -0,0 +1,48 @@
1
+ import { BoundQuery, RecordId, Table } from "surrealdb";
2
+ import * as z4 from "zod/v4/core";
3
+ import type { SurrealZodType } from "./zod";
4
+ export type ZodTypeName = z4.$ZodType["_zod"]["def"]["type"];
5
+ export type SurrealZodTypeName = SurrealZodType["_zod"]["def"]["type"];
6
+ export interface ZodToSurqlOptions<S extends z4.$ZodObject> {
7
+ table: string | Table;
8
+ schemafull?: boolean;
9
+ exists?: "ignore" | "error" | "overwrite";
10
+ drop?: boolean;
11
+ comment?: string;
12
+ schema: S;
13
+ }
14
+ export declare function zodToSurql<S extends z4.$ZodObject>(options: ZodToSurqlOptions<S>): [
15
+ S extends z4.$ZodObject<infer Shape> ? z4.$ZodObject<Shape & {
16
+ id: z4.$ZodCustom<RecordId>;
17
+ }> : never,
18
+ BoundQuery
19
+ ];
20
+ type ZodSurrealTypeContext = {
21
+ name: string;
22
+ table: Table;
23
+ rootSchema: z4.$ZodType;
24
+ children: ZodSurrealChildType[];
25
+ asserts: string[];
26
+ transforms: string[];
27
+ default?: {
28
+ value: any;
29
+ always: boolean;
30
+ };
31
+ };
32
+ type ZodSurrealChildType = {
33
+ name: string;
34
+ type: z4.$ZodType;
35
+ };
36
+ export declare function zodTypeToSurrealType(type: z4.$ZodType | SurrealZodType, parents: string[] | undefined, context: ZodSurrealTypeContext): string;
37
+ export declare const checkMap: {
38
+ min_length(name: string, value: number, type: ZodTypeName): string;
39
+ max_length(name: string, value: number, type: ZodTypeName): string;
40
+ greater_than(name: string, value: z4.util.Numeric, inclusive: boolean): string;
41
+ less_than(name: string, value: z4.util.Numeric, inclusive: boolean): string;
42
+ length_equals(name: string, value: number, type?: ZodTypeName): string;
43
+ string_format: {
44
+ email: (name: string) => string;
45
+ url: (name: string, def?: Pick<z4.$ZodCheckURLParams, "hostname" | "protocol" | "normalize">) => string;
46
+ };
47
+ };
48
+ export {};
package/lib/zod.d.ts ADDED
@@ -0,0 +1,55 @@
1
+ import { RecordId, type RecordIdValue } from "surrealdb";
2
+ import * as core from "zod/v4/core";
3
+ export interface SurrealZodTypeDef extends core.$ZodTypeDef {
4
+ surrealType?: "any" | "boolean" | "string" | "object" | "record_id";
5
+ }
6
+ export interface SurrealZodTypeInternals<out O = unknown, out I = unknown> extends core.$ZodTypeInternals<O, I> {
7
+ def: SurrealZodTypeDef;
8
+ }
9
+ export interface SurrealZodType<out O = unknown, out I = unknown, out Internals extends SurrealZodTypeInternals<O, I> = SurrealZodTypeInternals<O, I>> extends core.$ZodType<O, I, Internals> {
10
+ _surreal: true;
11
+ }
12
+ export interface _SurrealZodType<out Internals extends core.$ZodTypeInternals = core.$ZodTypeInternals> extends SurrealZodType<any, any, Internals> {
13
+ }
14
+ export declare const SurrealZodType: core.$constructor<SurrealZodType>;
15
+ export interface SurrealZodAny extends _SurrealZodType<core.$ZodAnyInternals> {
16
+ }
17
+ export declare const SurrealZodAny: core.$constructor<SurrealZodAny>;
18
+ export declare function any(): SurrealZodAny;
19
+ export interface SurrealZodBoolean extends _SurrealZodType<core.$ZodBooleanInternals> {
20
+ }
21
+ export declare const SurrealZodBoolean: core.$constructor<SurrealZodBoolean>;
22
+ export declare function boolean(params?: string | core.$ZodBooleanParams): SurrealZodBoolean;
23
+ export interface SurrealZodString extends _SurrealZodType<core.$ZodStringInternals<string>> {
24
+ }
25
+ export declare const SurrealZodString: core.$constructor<SurrealZodString>;
26
+ export declare function string(params?: string | core.$ZodStringParams): SurrealZodString;
27
+ export interface SurrealZodObject<out Shape extends core.$ZodShape = core.$ZodLooseShape, out Config extends core.$ZodObjectConfig = core.$strip> extends _SurrealZodType<core.$ZodObjectInternals<Shape, Config>>, core.$ZodObject<Shape, Config> {
28
+ }
29
+ export declare const SurrealZodObject: core.$constructor<SurrealZodObject>;
30
+ export declare function object<T extends core.$ZodLooseShape = Partial<Record<never, core.SomeType>>>(shape?: T, params?: string | core.$ZodObjectParams): SurrealZodObject<core.util.Writeable<T>, core.$strip>;
31
+ export interface SurrealZodRecordIdDef<out W extends {
32
+ [key: string]: string;
33
+ } = {
34
+ [key: string]: string;
35
+ }, T extends core.SomeType = core.SomeType> extends SurrealZodTypeDef {
36
+ surrealType: "record_id";
37
+ innerType: T;
38
+ what?: W;
39
+ }
40
+ export interface SurrealZodRecordIdInternals<W extends {
41
+ [key: string]: string;
42
+ } = {
43
+ [key: string]: string;
44
+ }, T extends core.SomeType = core.SomeType> extends SurrealZodTypeInternals<RecordId<W[keyof W]>, RecordIdValue> {
45
+ def: SurrealZodRecordIdDef<W, T>;
46
+ }
47
+ export interface SurrealZodRecordId<W extends {
48
+ [key: string]: string;
49
+ } = {
50
+ [key: string]: string;
51
+ }, T extends core.SomeType = core.SomeType> extends _SurrealZodType<SurrealZodRecordIdInternals<W, T>> {
52
+ }
53
+ export declare const SurrealZodRecordId: core.$constructor<SurrealZodRecordId>;
54
+ export declare function recordId<const W extends readonly string[]>(what?: W, innerType?: core.$ZodType | SurrealZodType): SurrealZodRecordId<core.util.ToEnum<W[number]>>;
55
+ export type SurrealZodTypes = SurrealZodAny | SurrealZodBoolean | SurrealZodString | SurrealZodObject | SurrealZodRecordId;
package/package.json CHANGED
@@ -1,7 +1,6 @@
1
1
  {
2
2
  "name": "surreal-zod",
3
- "version": "0.0.0-alpha.1",
4
- "module": "index.ts",
3
+ "version": "0.0.0-alpha.3",
5
4
  "scripts": {
6
5
  "build": "tsc"
7
6
  },
@@ -9,6 +8,8 @@
9
8
  "lib",
10
9
  "src"
11
10
  ],
11
+ "module": "lib/index.js",
12
+ "types": "lib/index.d.ts",
12
13
  "exports": {
13
14
  ".": {
14
15
  "bun": "./src/index.ts",
package/src/index.ts CHANGED
@@ -1,3 +1,4 @@
1
1
  import * as sz from "./zod";
2
+ export { zodToSurql } from "./surql";
2
3
  export { sz };
3
4
  export default sz;