surreal-zod 0.0.0-alpha.12 → 0.0.0-alpha.14
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/data-types.d.ts +4 -0
- package/lib/data-types.js +6 -0
- package/lib/zod/core.d.ts +0 -5
- package/lib/zod/external.d.ts +2 -0
- package/lib/zod/external.js +2 -0
- package/lib/zod/index.d.ts +1 -0
- package/lib/zod/index.js +1 -0
- package/lib/zod/json-schema.js +1 -2
- package/lib/zod/schema.d.ts +147 -148
- package/lib/zod/schema.js +116 -10
- package/package.json +1 -1
- package/src/zod/core.ts +0 -9
- package/src/zod/external.ts +8 -0
- package/src/zod/index.ts +1 -0
- package/src/zod/json-schema.ts +1 -2
- package/src/zod/schema.ts +598 -992
package/lib/zod/core.d.ts
CHANGED
|
@@ -234,11 +234,6 @@ export type $InferOuterFunctionType<Args extends ZodSurrealFunctionIn, Returns e
|
|
|
234
234
|
export type $InferOuterFunctionDbType<Args extends ZodSurrealFunctionIn, Returns extends ZodSurrealFunctionOut> = (...args: ZodSurrealFunctionIn extends Args ? never[] : dbinput<Args>) => dboutput<Returns>;
|
|
235
235
|
export type $InferOuterFunctionTypeAsync<Args extends ZodSurrealFunctionIn, Returns extends ZodSurrealFunctionOut> = (...args: ZodSurrealFunctionIn extends Args ? never[] : core.input<Args>) => Promise<core.output<Returns>>;
|
|
236
236
|
export type $InferOuterFunctionDbTypeAsync<Args extends ZodSurrealFunctionIn, Returns extends ZodSurrealFunctionOut> = (...args: ZodSurrealFunctionIn extends Args ? never[] : dbinput<Args>) => Promise<dboutput<Returns>>;
|
|
237
|
-
export interface ZodSurrealFunctionDef<In extends ZodSurrealFunctionIn = ZodSurrealFunctionIn, Out extends ZodSurrealFunctionOut = ZodSurrealFunctionOut> extends $ZodSurrealTypeDef {
|
|
238
|
-
type: "function";
|
|
239
|
-
input: In;
|
|
240
|
-
output: Out;
|
|
241
|
-
}
|
|
242
237
|
type LiteralPart = Exclude<core.util.Literal, symbol>;
|
|
243
238
|
interface SchemaPartInternals extends $ZodSurrealTypeInternals<LiteralPart, LiteralPart> {
|
|
244
239
|
pattern: RegExp;
|
package/lib/zod/index.d.ts
CHANGED
package/lib/zod/index.js
CHANGED
package/lib/zod/json-schema.js
CHANGED
|
@@ -611,8 +611,7 @@ export function toJSONSchema(input, params) {
|
|
|
611
611
|
}
|
|
612
612
|
if (Object.keys(defs).length > 0) {
|
|
613
613
|
const defsSegment = ctx.target === "draft-2020-12" ? "$defs" : "definitions";
|
|
614
|
-
|
|
615
|
-
core.__shared = {
|
|
614
|
+
schemas.__shared = {
|
|
616
615
|
[defsSegment]: defs,
|
|
617
616
|
};
|
|
618
617
|
}
|
package/lib/zod/schema.d.ts
CHANGED
|
@@ -120,7 +120,7 @@ export interface ZodSurrealFieldInternals<out O = unknown, out I = unknown, out
|
|
|
120
120
|
def: ZodSurrealFieldDef<O, I>;
|
|
121
121
|
}
|
|
122
122
|
type UnwrapField<T> = T extends ZodSurrealField<infer I, any, any, any, any, any> ? UnwrapField<I> : T;
|
|
123
|
-
export interface ZodSurrealField<T extends ZodSurrealType = ZodSurrealType, O = core.output<T>, I = core.input<T>, DBO = _core_.dboutput<T>, DBI = _core_.dbinput<T>, Options extends string = ""> extends _core_.$ZodSurrealType<O, I, DBO, DBI, "$default" | "$prefault" | "$defaultAlways" | "$prefaultAlways" extends Options ? Omit<ZodSurrealFieldInternals<O, I, DBO, DBI>, "optin" | "outout"> & {
|
|
123
|
+
export interface ZodSurrealField<T extends _core_.$ZodSurrealType = _core_.$ZodSurrealType, O = core.output<T>, I = core.input<T>, DBO = _core_.dboutput<T>, DBI = _core_.dbinput<T>, Options extends string = ""> extends _core_.$ZodSurrealType<O, I, DBO, DBI, "" | "$default" | "$prefault" | "$defaultAlways" | "$prefaultAlways" extends Options ? Omit<ZodSurrealFieldInternals<O, I, DBO, DBI>, "optin" | "outout"> & {
|
|
124
124
|
optin: "optional";
|
|
125
125
|
optout: "optional";
|
|
126
126
|
dboptin: "optional";
|
|
@@ -128,10 +128,19 @@ export interface ZodSurrealField<T extends ZodSurrealType = ZodSurrealType, O =
|
|
|
128
128
|
dboptout: "optional";
|
|
129
129
|
} : {
|
|
130
130
|
dboptout?: "optional" | undefined;
|
|
131
|
-
}) : ZodSurrealFieldInternals<O, I, DBO, DBI> & {
|
|
131
|
+
}) : ZodSurrealFieldInternals<O, I, DBO, DBI> & (T["_zod"] extends {
|
|
132
|
+
optin?: any;
|
|
133
|
+
} ? {
|
|
134
|
+
dboptin?: T["_zod"]["optin"];
|
|
135
|
+
} : {
|
|
132
136
|
dboptin: T["_zod"]["optin"];
|
|
137
|
+
}) & (T["_zod"] extends {
|
|
138
|
+
optout?: any;
|
|
139
|
+
} ? {
|
|
140
|
+
dboptout?: T["_zod"]["optout"];
|
|
141
|
+
} : {
|
|
133
142
|
dboptout: T["_zod"]["optout"];
|
|
134
|
-
}>, ZodSurrealFieldMethods<Options> {
|
|
143
|
+
})>, ZodSurrealFieldMethods<Options> {
|
|
135
144
|
parse<Ctx extends ParseDbContext>(data: unknown, params?: Ctx): Ctx extends {
|
|
136
145
|
db: any;
|
|
137
146
|
} ? _core_.dboutput<this> : core.output<this>;
|
|
@@ -1408,7 +1417,7 @@ export interface ZodSurrealFunctionInternals<Args extends _core_.ZodSurrealFunct
|
|
|
1408
1417
|
}
|
|
1409
1418
|
export interface ZodSurrealFunction<Args extends _core_.ZodSurrealFunctionIn = _core_.ZodSurrealFunctionIn, Returns extends _core_.ZodSurrealFunctionOut = _core_.ZodSurrealFunctionOut> extends _ZodSurrealType<ZodSurrealFunctionInternals<Args, Returns>>, ZodSurrealFieldMethods {
|
|
1410
1419
|
"~standard": core.ZodStandardSchemaWithJSON<this>;
|
|
1411
|
-
_def:
|
|
1420
|
+
_def: ZodSurrealFunctionDef<Args, Returns>;
|
|
1412
1421
|
_input: _core_.$InferInnerFunctionType<Args, Returns>;
|
|
1413
1422
|
_output: _core_.$InferOuterFunctionType<Args, Returns>;
|
|
1414
1423
|
_dbinput: _core_.$InferInnerFunctionDbType<Args, Returns>;
|
|
@@ -1491,7 +1500,7 @@ export interface ZodSurrealJSONSchema extends _ZodSurrealJSONSchema {
|
|
|
1491
1500
|
}
|
|
1492
1501
|
export declare function json(params?: string | core.$ZodCustomParams): ZodSurrealJSONSchema;
|
|
1493
1502
|
export declare function preprocess<A, U extends _core_.$SomeSurrealType, B = unknown>(fn: (arg: B, ctx: core.$RefinementCtx) => A, schema: U): ZodSurrealPipe<ZodSurrealTransform<A, B>, U>;
|
|
1494
|
-
export type ZodSurrealRecordIdValue = ZodSurrealType<RecordIdValue, unknown>;
|
|
1503
|
+
export type ZodSurrealRecordIdValue = _core_.$ZodSurrealType<RecordIdValue | undefined, unknown, RecordIdValue, unknown>;
|
|
1495
1504
|
export type inferRecordIdValue<Id extends ZodSurrealRecordIdValue> = Id extends {
|
|
1496
1505
|
_zod: {
|
|
1497
1506
|
output: any;
|
|
@@ -1511,9 +1520,9 @@ interface ZodSurrealRecordIdExtras {
|
|
|
1511
1520
|
dboutput?: null | undefined;
|
|
1512
1521
|
dbinput?: null | undefined;
|
|
1513
1522
|
}
|
|
1514
|
-
export interface ZodSurrealRecordIdInternals<Table extends string = string, Id extends ZodSurrealRecordIdValue = ZodSurrealRecordIdValue, Extras extends ZodSurrealRecordIdExtras = {}> extends ZodSurrealTypeInternals<RecordId<Table, core.output<Id>> | (Extras extends {
|
|
1523
|
+
export interface ZodSurrealRecordIdInternals<Table extends string = string, Id extends ZodSurrealRecordIdValue = ZodSurrealRecordIdValue, Extras extends ZodSurrealRecordIdExtras = {}> extends ZodSurrealTypeInternals<RecordId<Table, Exclude<core.output<Id>, undefined>> | (Extras extends {
|
|
1515
1524
|
output: infer Output;
|
|
1516
|
-
} ? Output : never), RecordId<Table, core.output<Id>> | StringRecordId | (Extras extends {
|
|
1525
|
+
} ? Output : never), RecordId<Table, Exclude<core.output<Id>, undefined>> | StringRecordId | (Extras extends {
|
|
1517
1526
|
input: infer Input;
|
|
1518
1527
|
} ? Input : never), RecordId<Table, _core_.dboutput<Id>> | (Extras extends {
|
|
1519
1528
|
dboutput: infer DBOutput;
|
|
@@ -1522,148 +1531,138 @@ export interface ZodSurrealRecordIdInternals<Table extends string = string, Id e
|
|
|
1522
1531
|
} ? DBInput : never)> {
|
|
1523
1532
|
def: ZodSurrealRecordIdDef<Table, Id>;
|
|
1524
1533
|
}
|
|
1525
|
-
type
|
|
1526
|
-
parse<
|
|
1527
|
-
|
|
1528
|
-
|
|
1529
|
-
|
|
1530
|
-
|
|
1531
|
-
|
|
1532
|
-
|
|
1533
|
-
|
|
1534
|
-
|
|
1535
|
-
|
|
1536
|
-
|
|
1537
|
-
|
|
1538
|
-
|
|
1539
|
-
|
|
1540
|
-
|
|
1541
|
-
|
|
1542
|
-
|
|
1543
|
-
|
|
1544
|
-
safeDecode<
|
|
1545
|
-
|
|
1546
|
-
|
|
1547
|
-
|
|
1548
|
-
|
|
1549
|
-
|
|
1550
|
-
|
|
1551
|
-
|
|
1552
|
-
|
|
1553
|
-
|
|
1554
|
-
|
|
1555
|
-
|
|
1556
|
-
|
|
1557
|
-
|
|
1558
|
-
|
|
1559
|
-
|
|
1560
|
-
|
|
1561
|
-
|
|
1562
|
-
|
|
1563
|
-
|
|
1564
|
-
|
|
1565
|
-
|
|
1566
|
-
|
|
1567
|
-
|
|
1568
|
-
|
|
1569
|
-
|
|
1570
|
-
|
|
1571
|
-
|
|
1572
|
-
|
|
1573
|
-
|
|
1574
|
-
|
|
1575
|
-
} :
|
|
1576
|
-
|
|
1577
|
-
} ?
|
|
1578
|
-
|
|
1579
|
-
|
|
1580
|
-
|
|
1581
|
-
|
|
1582
|
-
|
|
1583
|
-
|
|
1584
|
-
|
|
1585
|
-
|
|
1586
|
-
|
|
1587
|
-
|
|
1588
|
-
|
|
1589
|
-
|
|
1590
|
-
|
|
1591
|
-
|
|
1592
|
-
|
|
1593
|
-
|
|
1594
|
-
|
|
1595
|
-
|
|
1596
|
-
|
|
1597
|
-
|
|
1598
|
-
|
|
1599
|
-
|
|
1600
|
-
|
|
1601
|
-
safeDecodeAsync<
|
|
1602
|
-
|
|
1603
|
-
|
|
1604
|
-
|
|
1605
|
-
|
|
1606
|
-
|
|
1607
|
-
|
|
1608
|
-
|
|
1609
|
-
|
|
1610
|
-
} :
|
|
1611
|
-
|
|
1612
|
-
|
|
1613
|
-
|
|
1614
|
-
|
|
1615
|
-
|
|
1616
|
-
|
|
1617
|
-
|
|
1618
|
-
|
|
1619
|
-
|
|
1620
|
-
|
|
1621
|
-
|
|
1622
|
-
|
|
1623
|
-
|
|
1624
|
-
|
|
1625
|
-
|
|
1626
|
-
|
|
1627
|
-
} :
|
|
1628
|
-
|
|
1629
|
-
|
|
1630
|
-
|
|
1631
|
-
|
|
1632
|
-
|
|
1633
|
-
|
|
1634
|
-
|
|
1635
|
-
|
|
1636
|
-
|
|
1637
|
-
|
|
1638
|
-
|
|
1639
|
-
|
|
1640
|
-
|
|
1641
|
-
|
|
1642
|
-
|
|
1643
|
-
|
|
1644
|
-
|
|
1645
|
-
|
|
1646
|
-
|
|
1647
|
-
|
|
1648
|
-
|
|
1649
|
-
|
|
1650
|
-
|
|
1651
|
-
|
|
1652
|
-
} : {
|
|
1653
|
-
parse(data: unknown, params?: ParseDbContext): RecordId<Tb, core.output<Id>>;
|
|
1654
|
-
parseAsync(data: unknown, params?: ParseDbContext): Promise<RecordId<Tb, core.output<Id>>>;
|
|
1655
|
-
safeParse(data: unknown, params?: ParseDbContext): classic.ZodSafeParseResult<RecordId<Tb, core.output<Id>>>;
|
|
1656
|
-
safeParseAsync(data: unknown, params?: ParseDbContext): Promise<classic.ZodSafeParseResult<RecordId<Tb, core.output<Id>>>>;
|
|
1657
|
-
decode(data: RecordId<Tb, core.output<Id>> | StringRecordId, params?: ParseDbContext): RecordId<Tb, core.output<Id>>;
|
|
1658
|
-
decodeAsync(data: RecordId<Tb, core.output<Id>> | StringRecordId, params?: ParseDbContext): Promise<RecordId<Tb, core.output<Id>>>;
|
|
1659
|
-
safeDecode(data: RecordId<Tb, core.output<Id>> | StringRecordId, params?: ParseDbContext): classic.ZodSafeParseResult<RecordId<Tb, core.output<Id>>>;
|
|
1660
|
-
safeDecodeAsync(data: RecordId<Tb, core.output<Id>> | StringRecordId, params?: ParseDbContext): Promise<classic.ZodSafeParseResult<RecordId<Tb, core.output<Id>>>>;
|
|
1661
|
-
fromParts(table: NoInfer<Tb>, id: NoInfer<core.output<Id>>, params?: ParseDbContext): RecordId<Tb, core.output<Id>>;
|
|
1662
|
-
fromPartsAsync(table: NoInfer<Tb>, id: NoInfer<core.output<Id>>, params?: ParseDbContext): Promise<RecordId<Tb, core.output<Id>>>;
|
|
1663
|
-
safeFromParts(table: NoInfer<Tb>, id: NoInfer<core.output<Id>>, params?: ParseDbContext): classic.ZodSafeParseResult<RecordId<Tb, core.output<Id>>>;
|
|
1664
|
-
safeFromPartsAsync(table: NoInfer<Tb>, id: NoInfer<core.output<Id>>, params?: ParseDbContext): Promise<classic.ZodSafeParseResult<RecordId<Tb, core.output<Id>>>>;
|
|
1534
|
+
type AnyTableRecordIdTrait<Tb extends string, Id extends ZodSurrealRecordIdValue> = {
|
|
1535
|
+
parse<Ctx extends ParseDbContext>(data: unknown, params?: Ctx): RecordId<Tb, Ctx extends {
|
|
1536
|
+
db: any;
|
|
1537
|
+
} ? _core_.dboutput<Id> : Exclude<core.output<Id>, undefined>>;
|
|
1538
|
+
parseAsync<Ctx extends ParseDbContext>(data: unknown, params?: Ctx): Promise<RecordId<Tb, Ctx extends {
|
|
1539
|
+
db: any;
|
|
1540
|
+
} ? _core_.dboutput<Id> : Exclude<core.output<Id>, undefined>>>;
|
|
1541
|
+
safeParse<Ctx extends ParseDbContext>(data: unknown, params?: Ctx): classic.ZodSafeParseResult<RecordId<Tb, Ctx extends {
|
|
1542
|
+
db: any;
|
|
1543
|
+
} ? _core_.dboutput<Id> : Exclude<core.output<Id>, undefined>>>;
|
|
1544
|
+
safeParseAsync<Ctx extends ParseDbContext>(data: unknown, params?: Ctx): Promise<classic.ZodSafeParseResult<RecordId<Tb, Ctx extends {
|
|
1545
|
+
db: any;
|
|
1546
|
+
} ? _core_.dboutput<Id> : Exclude<core.output<Id>, undefined>>>>;
|
|
1547
|
+
decode<Ctx extends ParseDbContext>(id: RecordId<Tb, Exclude<core.output<Id>, undefined>> | StringRecordId, params?: Ctx): RecordId<Tb, Ctx extends {
|
|
1548
|
+
db: any;
|
|
1549
|
+
} ? _core_.dboutput<Id> : Exclude<core.output<Id>, undefined>>;
|
|
1550
|
+
decodeAsync<Ctx extends ParseDbContext>(id: RecordId<Tb, Exclude<core.output<Id>, undefined>> | StringRecordId, params?: Ctx): Promise<RecordId<Tb, Ctx extends {
|
|
1551
|
+
db: any;
|
|
1552
|
+
} ? _core_.dboutput<Id> : Exclude<core.output<Id>, undefined>>>;
|
|
1553
|
+
safeDecode<Ctx extends ParseDbContext>(id: RecordId<Tb, Exclude<core.output<Id>, undefined>> | StringRecordId, params?: Ctx): classic.ZodSafeParseResult<RecordId<Tb, Ctx extends {
|
|
1554
|
+
db: any;
|
|
1555
|
+
} ? _core_.dboutput<Id> : Exclude<core.output<Id>, undefined>>>;
|
|
1556
|
+
safeDecodeAsync<Ctx extends ParseDbContext>(id: RecordId<Tb, Exclude<core.output<Id>, undefined>> | StringRecordId, params?: Ctx): Promise<classic.ZodSafeParseResult<RecordId<Tb, Ctx extends {
|
|
1557
|
+
db: any;
|
|
1558
|
+
} ? _core_.dboutput<Id> : Exclude<core.output<Id>, undefined>>>>;
|
|
1559
|
+
fromParts<Ctx extends ParseDbContext>(table: Tb, id: Ctx extends {
|
|
1560
|
+
db: any;
|
|
1561
|
+
} ? core.output<Id> : Exclude<core.output<Id>, undefined>, params?: Ctx): undefined extends core.output<Id> ? RecordId<Tb, Ctx extends {
|
|
1562
|
+
db: any;
|
|
1563
|
+
} ? _core_.dboutput<Id> : Exclude<core.output<Id>, undefined>> | undefined : RecordId<Tb, Ctx extends {
|
|
1564
|
+
db: any;
|
|
1565
|
+
} ? _core_.dboutput<Id> : Exclude<core.output<Id>, undefined>>;
|
|
1566
|
+
fromPartsAsync<Ctx extends ParseDbContext>(table: Tb, id: Ctx extends {
|
|
1567
|
+
db: any;
|
|
1568
|
+
} ? core.output<Id> : Exclude<core.output<Id>, undefined>, params?: Ctx): undefined extends core.output<Id> ? Promise<RecordId<Tb, Ctx extends {
|
|
1569
|
+
db: any;
|
|
1570
|
+
} ? _core_.dboutput<Id> : Exclude<core.output<Id>, undefined>> | undefined> : Promise<RecordId<Tb, Ctx extends {
|
|
1571
|
+
db: any;
|
|
1572
|
+
} ? _core_.dboutput<Id> : Exclude<core.output<Id>, undefined>>>;
|
|
1573
|
+
safeFromParts<Ctx extends ParseDbContext>(table: Tb, id: Ctx extends {
|
|
1574
|
+
db: any;
|
|
1575
|
+
} ? core.output<Id> : Exclude<core.output<Id>, undefined>, params?: Ctx): undefined extends core.output<Id> ? classic.ZodSafeParseResult<RecordId<Tb, Ctx extends {
|
|
1576
|
+
db: any;
|
|
1577
|
+
} ? _core_.dboutput<Id> : Exclude<core.output<Id>, undefined>> | undefined> : classic.ZodSafeParseResult<RecordId<Tb, Ctx extends {
|
|
1578
|
+
db: any;
|
|
1579
|
+
} ? _core_.dboutput<Id> : Exclude<core.output<Id>, undefined>>>;
|
|
1580
|
+
safeFromPartsAsync<Ctx extends ParseDbContext>(table: Tb, id: Ctx extends {
|
|
1581
|
+
db: any;
|
|
1582
|
+
} ? core.output<Id> : Exclude<core.output<Id>, undefined>, params?: Ctx): undefined extends core.output<Id> ? Promise<classic.ZodSafeParseResult<RecordId<Tb, Ctx extends {
|
|
1583
|
+
db: any;
|
|
1584
|
+
} ? _core_.dboutput<Id> : Exclude<core.output<Id>, undefined>> | undefined>> : Promise<classic.ZodSafeParseResult<RecordId<Tb, Ctx extends {
|
|
1585
|
+
db: any;
|
|
1586
|
+
} ? _core_.dboutput<Id> : Exclude<core.output<Id>, undefined>>>>;
|
|
1587
|
+
};
|
|
1588
|
+
type SpecificTableRecordIdTrait<Tb extends string, Id extends ZodSurrealRecordIdValue> = {
|
|
1589
|
+
parse<Ctx extends ParseDbContext>(data: unknown, params?: Ctx): RecordId<Tb, Ctx extends {
|
|
1590
|
+
db: any;
|
|
1591
|
+
} ? _core_.dboutput<Id> : Exclude<core.output<Id>, undefined>>;
|
|
1592
|
+
parseAsync<Ctx extends ParseDbContext>(data: unknown, params?: Ctx): Promise<RecordId<Tb, Ctx extends {
|
|
1593
|
+
db: any;
|
|
1594
|
+
} ? _core_.dboutput<Id> : Exclude<core.output<Id>, undefined>>>;
|
|
1595
|
+
safeParse<Ctx extends ParseDbContext>(data: unknown, params?: Ctx): classic.ZodSafeParseResult<RecordId<Tb, Ctx extends {
|
|
1596
|
+
db: any;
|
|
1597
|
+
} ? _core_.dboutput<Id> : Exclude<core.output<Id>, undefined>>>;
|
|
1598
|
+
safeParseAsync<Ctx extends ParseDbContext>(data: unknown, params?: Ctx): Promise<classic.ZodSafeParseResult<RecordId<Tb, Ctx extends {
|
|
1599
|
+
db: any;
|
|
1600
|
+
} ? _core_.dboutput<Id> : Exclude<core.output<Id>, undefined>>>>;
|
|
1601
|
+
decode<Ctx extends ParseDbContext>(data: core.output<Id> | StringRecordId, params?: Ctx): RecordId<Tb, Ctx extends {
|
|
1602
|
+
db: any;
|
|
1603
|
+
} ? _core_.dboutput<Id> : Exclude<core.output<Id>, undefined>>;
|
|
1604
|
+
decodeAsync<Ctx extends ParseDbContext>(data: core.output<Id> | StringRecordId, params?: Ctx): Promise<RecordId<Tb, Ctx extends {
|
|
1605
|
+
db: any;
|
|
1606
|
+
} ? _core_.dboutput<Id> : Exclude<core.output<Id>, undefined>>>;
|
|
1607
|
+
safeDecode<Ctx extends ParseDbContext>(data: core.output<Id> | StringRecordId, params?: Ctx): classic.ZodSafeParseResult<RecordId<Tb, Ctx extends {
|
|
1608
|
+
db: any;
|
|
1609
|
+
} ? _core_.dboutput<Id> : Exclude<core.output<Id>, undefined>>>;
|
|
1610
|
+
safeDecodeAsync<Ctx extends ParseDbContext>(data: core.output<Id> | StringRecordId, params?: Ctx): Promise<classic.ZodSafeParseResult<RecordId<Tb, Ctx extends {
|
|
1611
|
+
db: any;
|
|
1612
|
+
} ? _core_.dboutput<Id> : Exclude<core.output<Id>, undefined>>>>;
|
|
1613
|
+
fromParts<Ctx extends ParseDbContext>(table: Tb, id: Ctx extends {
|
|
1614
|
+
db: any;
|
|
1615
|
+
} ? core.output<Id> : Exclude<core.output<Id>, undefined>, params?: Ctx): undefined extends core.output<Id> ? RecordId<Tb, Ctx extends {
|
|
1616
|
+
db: any;
|
|
1617
|
+
} ? _core_.dboutput<Id> : Exclude<core.output<Id>, undefined>> | undefined : RecordId<Tb, Ctx extends {
|
|
1618
|
+
db: any;
|
|
1619
|
+
} ? _core_.dboutput<Id> : Exclude<core.output<Id>, undefined>>;
|
|
1620
|
+
fromPartsAsync<Ctx extends ParseDbContext>(table: Tb, id: Ctx extends {
|
|
1621
|
+
db: any;
|
|
1622
|
+
} ? core.output<Id> : Exclude<core.output<Id>, undefined>, params?: Ctx): undefined extends core.output<Id> ? Promise<RecordId<Tb, Ctx extends {
|
|
1623
|
+
db: any;
|
|
1624
|
+
} ? _core_.dboutput<Id> : Exclude<core.output<Id>, undefined>> | undefined> : Promise<RecordId<Tb, Ctx extends {
|
|
1625
|
+
db: any;
|
|
1626
|
+
} ? _core_.dboutput<Id> : Exclude<core.output<Id>, undefined>>>;
|
|
1627
|
+
safeFromParts<Ctx extends ParseDbContext>(table: Tb, id: Ctx extends {
|
|
1628
|
+
db: any;
|
|
1629
|
+
} ? core.output<Id> : Exclude<core.output<Id>, undefined>, params?: Ctx): undefined extends core.output<Id> ? classic.ZodSafeParseResult<RecordId<Tb, Ctx extends {
|
|
1630
|
+
db: any;
|
|
1631
|
+
} ? _core_.dboutput<Id> : Exclude<core.output<Id>, undefined>> | undefined> : classic.ZodSafeParseResult<RecordId<Tb, Ctx extends {
|
|
1632
|
+
db: any;
|
|
1633
|
+
} ? _core_.dboutput<Id> : Exclude<core.output<Id>, undefined>>>;
|
|
1634
|
+
safeFromPartsAsync<Ctx extends ParseDbContext>(table: Tb, id: Ctx extends {
|
|
1635
|
+
db: any;
|
|
1636
|
+
} ? core.output<Id> : Exclude<core.output<Id>, undefined>, params?: Ctx): undefined extends core.output<Id> ? Promise<classic.ZodSafeParseResult<RecordId<Tb, Ctx extends {
|
|
1637
|
+
db: any;
|
|
1638
|
+
} ? _core_.dboutput<Id> : Exclude<core.output<Id>, undefined>> | undefined>> : Promise<classic.ZodSafeParseResult<RecordId<Tb, Ctx extends {
|
|
1639
|
+
db: any;
|
|
1640
|
+
} ? _core_.dboutput<Id> : Exclude<core.output<Id>, undefined>>>>;
|
|
1641
|
+
fromId<Ctx extends ParseDbContext>(id: Ctx extends {
|
|
1642
|
+
db: any;
|
|
1643
|
+
} ? core.output<Id> : Exclude<core.output<Id>, undefined>, params?: Ctx): RecordId<Tb, Ctx extends {
|
|
1644
|
+
db: any;
|
|
1645
|
+
} ? _core_.dboutput<Id> : Exclude<core.output<Id>, undefined>>;
|
|
1646
|
+
fromIdAsync<Ctx extends ParseDbContext>(id: Ctx extends {
|
|
1647
|
+
db: any;
|
|
1648
|
+
} ? core.output<Id> : Exclude<core.output<Id>, undefined>, params?: Ctx): Promise<RecordId<Tb, Ctx extends {
|
|
1649
|
+
db: any;
|
|
1650
|
+
} ? _core_.dboutput<Id> : Exclude<core.output<Id>, undefined>>>;
|
|
1651
|
+
safeFromId<Ctx extends ParseDbContext>(id: Ctx extends {
|
|
1652
|
+
db: any;
|
|
1653
|
+
} ? core.output<Id> : Exclude<core.output<Id>, undefined>, params?: Ctx): classic.ZodSafeParseResult<RecordId<Tb, Ctx extends {
|
|
1654
|
+
db: any;
|
|
1655
|
+
} ? _core_.dboutput<Id> : Exclude<core.output<Id>, undefined>>>;
|
|
1656
|
+
safeFromIdAsync<Ctx extends ParseDbContext>(id: Ctx extends {
|
|
1657
|
+
db: any;
|
|
1658
|
+
} ? core.output<Id> : Exclude<core.output<Id>, undefined>, params?: Ctx): Promise<classic.ZodSafeParseResult<RecordId<Tb, Ctx extends {
|
|
1659
|
+
db: any;
|
|
1660
|
+
} ? _core_.dboutput<Id> : Exclude<core.output<Id>, undefined>>>>;
|
|
1665
1661
|
};
|
|
1666
|
-
|
|
1662
|
+
type ZodSurrealRecordIdTrait<Tb extends string, Id extends ZodSurrealRecordIdValue, Extras extends ZodSurrealRecordIdExtras = {}> = string extends Tb ? AnyTableRecordIdTrait<Tb, Id> : UnionToTuple<Tb> extends {
|
|
1663
|
+
length: 1;
|
|
1664
|
+
} ? SpecificTableRecordIdTrait<Tb, Id> : AnyTableRecordIdTrait<Tb, Id>;
|
|
1665
|
+
export type ZodSurrealdRecordId<Table extends string = string, Id extends ZodSurrealRecordIdValue = ZodSurrealRecordIdValue, Extras extends ZodSurrealRecordIdExtras = {}> = Omit<_ZodSurrealType<ZodSurrealRecordIdInternals<Table, Id, Extras>>, ParsingEncodingDecodingMethodNames | "optional" | "nullable" | "nullish" | "nonoptional"> & ZodSurrealRecordIdTrait<Table, Id, Extras> & ZodSurrealFieldMethods & {
|
|
1667
1666
|
anytable(): ZodSurrealdRecordId<string, Id, Extras>;
|
|
1668
1667
|
table<const NewTable extends string | string[]>(table: NewTable): ZodSurrealdRecordId<NewTable extends string ? NewTable : NewTable[number], Id, Extras>;
|
|
1669
1668
|
/** @alias id */
|
package/lib/zod/schema.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { BoundQuery, DateTime, Duration, escapeIdent, RecordId, StringRecordId, surql, Uuid, Table, } from "surrealdb";
|
|
2
2
|
import * as core from "zod/v4/core";
|
|
3
3
|
import * as classic from "zod/v4";
|
|
4
|
-
import {} from "zod/v4/core";
|
|
5
4
|
import { inferSurrealType, inlineQueryParameters, tableToSurql, } from "../surql";
|
|
6
5
|
import * as _core_ from "./core";
|
|
7
6
|
import { assignParsingMethods, } from "./parse";
|
|
@@ -2031,16 +2030,123 @@ export const ZodSurrealdRecordId = core.$constructor("ZodSurrealRecordId", (inst
|
|
|
2031
2030
|
inst.id = inst.type;
|
|
2032
2031
|
inst.value = inst.type;
|
|
2033
2032
|
// ------- Parsing/Encoding/Decoding -------
|
|
2034
|
-
|
|
2035
|
-
|
|
2036
|
-
|
|
2037
|
-
|
|
2038
|
-
|
|
2033
|
+
inst.fromParts = (table, id, params) => {
|
|
2034
|
+
const inner = def.innerType;
|
|
2035
|
+
if (id === undefined) {
|
|
2036
|
+
const res = core.safeDecode(inner, id, params);
|
|
2037
|
+
if (res.error) {
|
|
2038
|
+
for (const issue of res.error.issues) {
|
|
2039
|
+
issue.path.unshift("id");
|
|
2040
|
+
}
|
|
2041
|
+
throw res.error;
|
|
2042
|
+
}
|
|
2043
|
+
id = res.data;
|
|
2044
|
+
if (id === undefined) {
|
|
2045
|
+
return undefined;
|
|
2046
|
+
}
|
|
2047
|
+
}
|
|
2048
|
+
return inst.decode(new RecordId(table, id), params);
|
|
2049
|
+
};
|
|
2050
|
+
inst.fromPartsAsync = async (table, id, params) => {
|
|
2051
|
+
const inner = def.innerType;
|
|
2052
|
+
if (id === undefined) {
|
|
2053
|
+
const res = await core.safeDecodeAsync(inner, id, params);
|
|
2054
|
+
if (res.error) {
|
|
2055
|
+
for (const issue of res.error.issues) {
|
|
2056
|
+
issue.path.unshift("id");
|
|
2057
|
+
}
|
|
2058
|
+
throw res.error;
|
|
2059
|
+
}
|
|
2060
|
+
id = res.data;
|
|
2061
|
+
}
|
|
2062
|
+
return inst.decodeAsync(new RecordId(table, id), params);
|
|
2063
|
+
};
|
|
2064
|
+
inst.safeFromParts = (table, id, params) => {
|
|
2065
|
+
const inner = def.innerType;
|
|
2066
|
+
if (id === undefined) {
|
|
2067
|
+
const res = core.safeDecode(inner, id, params);
|
|
2068
|
+
if (res.error) {
|
|
2069
|
+
for (const issue of res.error.issues) {
|
|
2070
|
+
issue.path.unshift("id");
|
|
2071
|
+
}
|
|
2072
|
+
throw res.error;
|
|
2073
|
+
}
|
|
2074
|
+
id = res.data;
|
|
2075
|
+
}
|
|
2076
|
+
return inst.safeDecode(new RecordId(table, id), params);
|
|
2077
|
+
};
|
|
2078
|
+
inst.safeFromPartsAsync = async (table, id, params) => {
|
|
2079
|
+
const inner = def.innerType;
|
|
2080
|
+
if (id === undefined) {
|
|
2081
|
+
const res = await core.safeDecodeAsync(inner, id, params);
|
|
2082
|
+
if (res.error) {
|
|
2083
|
+
for (const issue of res.error.issues) {
|
|
2084
|
+
issue.path.unshift("id");
|
|
2085
|
+
}
|
|
2086
|
+
throw res.error;
|
|
2087
|
+
}
|
|
2088
|
+
id = res.data;
|
|
2089
|
+
}
|
|
2090
|
+
return inst.safeDecodeAsync(new RecordId(table, id), params);
|
|
2091
|
+
};
|
|
2039
2092
|
if (normalized.table?.length === 1) {
|
|
2040
|
-
_inst
|
|
2041
|
-
_inst.
|
|
2042
|
-
|
|
2043
|
-
|
|
2093
|
+
const _inst = inst;
|
|
2094
|
+
_inst.fromId = (id, params) => {
|
|
2095
|
+
const inner = def.innerType;
|
|
2096
|
+
if (id === undefined) {
|
|
2097
|
+
const res = core.safeDecode(inner, id, params);
|
|
2098
|
+
if (res.error) {
|
|
2099
|
+
for (const issue of res.error.issues) {
|
|
2100
|
+
issue.path.unshift("id");
|
|
2101
|
+
}
|
|
2102
|
+
throw res.error;
|
|
2103
|
+
}
|
|
2104
|
+
id = res.data;
|
|
2105
|
+
}
|
|
2106
|
+
return _inst.decode(new RecordId(normalized.table?.[0] ?? "", id), params);
|
|
2107
|
+
};
|
|
2108
|
+
_inst.fromIdAsync = async (id, params) => {
|
|
2109
|
+
const inner = def.innerType;
|
|
2110
|
+
if (id === undefined) {
|
|
2111
|
+
const res = await core.safeDecodeAsync(inner, id, params);
|
|
2112
|
+
if (res.error) {
|
|
2113
|
+
for (const issue of res.error.issues) {
|
|
2114
|
+
issue.path.unshift("id");
|
|
2115
|
+
}
|
|
2116
|
+
throw res.error;
|
|
2117
|
+
}
|
|
2118
|
+
id = res.data;
|
|
2119
|
+
}
|
|
2120
|
+
return _inst.decodeAsync(new RecordId(normalized.table?.[0] ?? "", id), params);
|
|
2121
|
+
};
|
|
2122
|
+
_inst.safeFromId = (id, params) => {
|
|
2123
|
+
const inner = def.innerType;
|
|
2124
|
+
if (id === undefined) {
|
|
2125
|
+
const res = core.safeDecode(inner, id, params);
|
|
2126
|
+
if (res.error) {
|
|
2127
|
+
for (const issue of res.error.issues) {
|
|
2128
|
+
issue.path.unshift("id");
|
|
2129
|
+
}
|
|
2130
|
+
throw res.error;
|
|
2131
|
+
}
|
|
2132
|
+
id = res.data;
|
|
2133
|
+
}
|
|
2134
|
+
return _inst.safeDecode(new RecordId(normalized.table?.[0] ?? "", id), params);
|
|
2135
|
+
};
|
|
2136
|
+
_inst.safeFromIdAsync = async (id, params) => {
|
|
2137
|
+
const inner = def.innerType;
|
|
2138
|
+
if (id === undefined) {
|
|
2139
|
+
const res = await core.safeDecodeAsync(inner, id, params);
|
|
2140
|
+
if (res.error) {
|
|
2141
|
+
for (const issue of res.error.issues) {
|
|
2142
|
+
issue.path.unshift("id");
|
|
2143
|
+
}
|
|
2144
|
+
throw res.error;
|
|
2145
|
+
}
|
|
2146
|
+
id = res.data;
|
|
2147
|
+
}
|
|
2148
|
+
return _inst.safeDecodeAsync(new RecordId(normalized.table?.[0] ?? "", id), params);
|
|
2149
|
+
};
|
|
2044
2150
|
}
|
|
2045
2151
|
inst._zod.parse = (payload, ctx) => {
|
|
2046
2152
|
if (payload.value instanceof RecordId) {
|