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

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 CHANGED
@@ -1,3 +1,4 @@
1
- import * as sz from "./zod/schema";
2
- export { sz };
3
- export default sz;
1
+ import * as z from "./zod";
2
+ export { z };
3
+ export * from "./zod";
4
+ export default z;
package/lib/index.js CHANGED
@@ -1,3 +1,4 @@
1
- import * as sz from "./zod/schema";
2
- export { sz };
3
- export default sz;
1
+ import * as z from "./zod";
2
+ export { z };
3
+ export * from "./zod";
4
+ export default z;
@@ -0,0 +1,7 @@
1
+ import z from "zod/v4";
2
+ export type SurrealZodCacheMeta = {
3
+ type: string;
4
+ };
5
+ export declare const registries: Readonly<{
6
+ tables: z.core.$ZodRegistry<object | undefined, z.core.$ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>>;
7
+ }>;
@@ -0,0 +1,5 @@
1
+ import z from "zod/v4";
2
+ const tables = z.registry();
3
+ export const registries = Object.freeze({
4
+ tables,
5
+ });
package/lib/surql.d.ts CHANGED
@@ -1,12 +1,11 @@
1
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]>;
2
+ import * as core from "zod/v4/core";
3
+ import * as _schema_ from "./zod/schema";
4
+ import * as _core_ from "./zod/core";
5
+ export declare function tableToSurql(table: _schema_.ZodSurrealTable, statement: "define", defineOptions?: DefineTableOptions): BoundQuery<[undefined]>;
6
+ export declare function tableToSurql(table: _schema_.ZodSurrealTable, statement: "remove", removeOptions?: RemoveTableOptions): BoundQuery<[undefined]>;
7
+ export declare function tableToSurql(table: _schema_.ZodSurrealTable, statement: "info"): BoundQuery<[TableInfo]>;
8
+ export declare function tableToSurql(table: _schema_.ZodSurrealTable, statement: "structure"): BoundQuery<[TableStructure]>;
10
9
  export type RemoveTableOptions = {
11
10
  /**
12
11
  * What to do if the table is missing.
@@ -16,7 +15,7 @@ export type RemoveTableOptions = {
16
15
  */
17
16
  missing?: "ignore" | "error";
18
17
  };
19
- export declare function removeTable(table: SurrealZodTable, options?: RemoveTableOptions): BoundQuery<[undefined]>;
18
+ export declare function removeTable(table: _schema_.ZodSurrealTable, options?: RemoveTableOptions): BoundQuery<[undefined]>;
20
19
  export interface TableInfo {
21
20
  events: Record<string, string>;
22
21
  fields: Record<string, string>;
@@ -24,7 +23,7 @@ export interface TableInfo {
24
23
  lives: Record<string, string>;
25
24
  tables: Record<string, string>;
26
25
  }
27
- export declare function infoTable(table: SurrealZodTable): BoundQuery<[TableInfo]>;
26
+ export declare function infoTable(table: _schema_.ZodSurrealTable): BoundQuery<[TableInfo]>;
28
27
  export interface TableStructure {
29
28
  events: unknown[];
30
29
  fields: FieldStructure[];
@@ -43,15 +42,16 @@ export interface FieldStructure {
43
42
  readonly: boolean;
44
43
  what: string;
45
44
  }
46
- export declare function structureTable(table: SurrealZodTable): BoundQuery<[TableStructure]>;
45
+ export declare function structureTable(table: _schema_.ZodSurrealTable): BoundQuery<[TableStructure]>;
47
46
  export type DefineTableOptions = {
48
47
  exists?: "ignore" | "error" | "overwrite";
49
48
  fields?: boolean;
50
49
  };
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> {
50
+ export declare function defineTable(schema: _schema_.ZodSurrealTable, options?: DefineTableOptions): BoundQuery<[undefined, ...undefined[]]>;
51
+ export declare function isRelationTable(table: unknown): table is _schema_.ZodSurrealTable<string, {
52
+ [K in "in" | "out" | "id"]: _schema_.ZodSurrealdRecordId;
53
+ }, _schema_.SurrealZodTableConfig, "relation">;
54
+ export interface ZodToSurqlOptions<S extends _schema_.ZodSurrealObject> {
55
55
  table: string | Table;
56
56
  schemafull?: boolean;
57
57
  exists?: "ignore" | "error" | "overwrite";
@@ -62,16 +62,33 @@ export interface ZodToSurqlOptions<S extends z4.$ZodObject> {
62
62
  export type DefineFieldOptions = {
63
63
  exists?: "ignore" | "error" | "overwrite";
64
64
  schemafull?: boolean;
65
+ default?: {
66
+ value: BoundQuery;
67
+ always?: boolean;
68
+ prase?: boolean;
69
+ };
70
+ comment?: string;
71
+ readonly?: boolean;
72
+ assert?: BoundQuery;
73
+ value?: BoundQuery;
65
74
  };
75
+ export declare function defineField(name: string, table: string, schema: _core_.$ZodSurrealType, options?: DefineFieldOptions): BoundQuery<unknown[]>;
66
76
  type ZodSurrealTypeContext = {
67
77
  type: Set<string>;
78
+ parents: Set<_core_.$ZodSurrealType>;
79
+ fullParents: Set<_core_.$ZodSurrealType>;
68
80
  depth: number;
69
81
  children: ZodSurrealChildType[];
70
82
  flexible: boolean;
71
83
  };
72
84
  type ZodSurrealChildType = {
73
85
  name: string;
74
- type: z4.$ZodType;
86
+ type: core.$ZodType;
87
+ };
88
+ export declare function inferSurrealType(type: _core_.$ZodSurrealType, context?: ZodSurrealTypeContext): {
89
+ type: string;
90
+ context: ZodSurrealTypeContext;
75
91
  };
76
- export declare function inferSurrealType(type: SurrealZodType, context: ZodSurrealTypeContext): string;
92
+ export declare function formatQuery(query: string): string;
93
+ export declare function inlineQueryParameters(query: BoundQuery): string;
77
94
  export {};