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

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/schema";
2
+ export { sz };
3
+ export default sz;
package/lib/index.js CHANGED
@@ -1,3 +1,3 @@
1
- import * as sz from "./zod";
1
+ import * as sz from "./zod/schema";
2
2
  export { sz };
3
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,77 @@
1
+ import { BoundQuery, Table } from "surrealdb";
2
+ import * as z4 from "zod/v4/core";
3
+ import type { SurrealZodTable, SurrealZodTableNormal, SurrealZodTableRelation, SurrealZodType } from "./zod/schema";
4
+ export type ZodTypeName = z4.$ZodType["_zod"]["def"]["type"];
5
+ export type SurrealZodTypeName = SurrealZodType["_zod"]["def"]["type"];
6
+ export declare function tableToSurql(table: SurrealZodTable, statement: "define", defineOptions?: DefineTableOptions): BoundQuery<[undefined]>;
7
+ export declare function tableToSurql(table: SurrealZodTable, statement: "remove", removeOptions?: RemoveTableOptions): BoundQuery<[undefined]>;
8
+ export declare function tableToSurql(table: SurrealZodTable, statement: "info"): BoundQuery<[TableInfo]>;
9
+ export declare function tableToSurql(table: SurrealZodTable, statement: "structure"): BoundQuery<[TableStructure]>;
10
+ export type RemoveTableOptions = {
11
+ /**
12
+ * What to do if the table is missing.
13
+ * - "ignore": Ignore the error and continue.
14
+ * - "error": Throw an error if the table is missing.
15
+ * @default "error"
16
+ */
17
+ missing?: "ignore" | "error";
18
+ };
19
+ export declare function removeTable(table: SurrealZodTable, options?: RemoveTableOptions): BoundQuery<[undefined]>;
20
+ export interface TableInfo {
21
+ events: Record<string, string>;
22
+ fields: Record<string, string>;
23
+ indexes: Record<string, string>;
24
+ lives: Record<string, string>;
25
+ tables: Record<string, string>;
26
+ }
27
+ export declare function infoTable(table: SurrealZodTable): BoundQuery<[TableInfo]>;
28
+ export interface TableStructure {
29
+ events: unknown[];
30
+ fields: FieldStructure[];
31
+ indexes: unknown[];
32
+ lives: unknown[];
33
+ tables: unknown[];
34
+ }
35
+ export interface FieldStructure {
36
+ name: string;
37
+ kind: string;
38
+ permissions: {
39
+ create: boolean;
40
+ select: boolean;
41
+ update: boolean;
42
+ };
43
+ readonly: boolean;
44
+ what: string;
45
+ }
46
+ export declare function structureTable(table: SurrealZodTable): BoundQuery<[TableStructure]>;
47
+ export type DefineTableOptions = {
48
+ exists?: "ignore" | "error" | "overwrite";
49
+ fields?: boolean;
50
+ };
51
+ export declare function defineTable(schema: SurrealZodTable, options?: DefineTableOptions): BoundQuery<[undefined, ...undefined[]]>;
52
+ export declare function isNormalTable(table: SurrealZodTable): table is SurrealZodTableNormal;
53
+ export declare function isRelationTable(table: SurrealZodTable): table is SurrealZodTableRelation;
54
+ export interface ZodToSurqlOptions<S extends z4.$ZodObject> {
55
+ table: string | Table;
56
+ schemafull?: boolean;
57
+ exists?: "ignore" | "error" | "overwrite";
58
+ drop?: boolean;
59
+ comment?: string;
60
+ schema: S;
61
+ }
62
+ export type DefineFieldOptions = {
63
+ exists?: "ignore" | "error" | "overwrite";
64
+ schemafull?: boolean;
65
+ };
66
+ type ZodSurrealTypeContext = {
67
+ type: Set<string>;
68
+ depth: number;
69
+ children: ZodSurrealChildType[];
70
+ flexible: boolean;
71
+ };
72
+ type ZodSurrealChildType = {
73
+ name: string;
74
+ type: z4.$ZodType;
75
+ };
76
+ export declare function inferSurrealType(type: SurrealZodType, context: ZodSurrealTypeContext): string;
77
+ export {};