surreal-zod 0.0.0-alpha.13 → 0.0.0-alpha.15
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/schema.d.ts +147 -148
- package/lib/zod/schema.js +116 -9
- package/package.json +1 -1
- package/src/zod/schema.ts +598 -996
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>;
|
|
@@ -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 */
|
|
@@ -1795,7 +1794,7 @@ export type ZodSurrealTable<Name extends string = string, Fields extends Surreal
|
|
|
1795
1794
|
drop(): ZodSurrealTable<Name, Fields, Config, Kind>;
|
|
1796
1795
|
nodrop(): ZodSurrealTable<Name, Fields, Config, Kind>;
|
|
1797
1796
|
comment(comment: string): ZodSurrealTable<Name, Fields, Config, Kind>;
|
|
1798
|
-
record():
|
|
1797
|
+
record(): NormalizedIdField<Name, Fields, "id">["id"];
|
|
1799
1798
|
dto(): ZodSurrealObject<Omit<NormalizedFields<Name, Fields>, "id"> & {
|
|
1800
1799
|
id: ZodSurrealOptional<NormalizedFields<Name, Fields>["id"]>;
|
|
1801
1800
|
}, {
|
package/lib/zod/schema.js
CHANGED
|
@@ -2030,16 +2030,123 @@ export const ZodSurrealdRecordId = core.$constructor("ZodSurrealRecordId", (inst
|
|
|
2030
2030
|
inst.id = inst.type;
|
|
2031
2031
|
inst.value = inst.type;
|
|
2032
2032
|
// ------- Parsing/Encoding/Decoding -------
|
|
2033
|
-
|
|
2034
|
-
|
|
2035
|
-
|
|
2036
|
-
|
|
2037
|
-
|
|
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
|
+
};
|
|
2038
2092
|
if (normalized.table?.length === 1) {
|
|
2039
|
-
_inst
|
|
2040
|
-
_inst.
|
|
2041
|
-
|
|
2042
|
-
|
|
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
|
+
};
|
|
2043
2150
|
}
|
|
2044
2151
|
inst._zod.parse = (payload, ctx) => {
|
|
2045
2152
|
if (payload.value instanceof RecordId) {
|