lazypock 0.10.0 → 0.10.2
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/README.md +32 -9
- package/dist/{chunk-JYKRCEC3.js → chunk-LVEOMG6A.js} +36 -5
- package/dist/chunk-LVEOMG6A.js.map +1 -0
- package/dist/cli.cjs +35 -4
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.global.js +35 -4
- package/dist/cli.global.js.map +1 -1
- package/dist/cli.js +1 -1
- package/dist/index.cjs +35 -4
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +154 -40
- package/dist/index.d.ts +154 -40
- package/dist/index.global.js +35 -4
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/codegen.ts +50 -4
- package/src/collection.ts +73 -25
- package/src/types.ts +261 -38
- package/dist/chunk-JYKRCEC3.js.map +0 -1
package/dist/index.global.js
CHANGED
|
@@ -1578,6 +1578,20 @@ var Lazypock = (() => {
|
|
|
1578
1578
|
body: createLines.join("\n")
|
|
1579
1579
|
})}`
|
|
1580
1580
|
);
|
|
1581
|
+
const queryLines = [];
|
|
1582
|
+
for (const f of fields) {
|
|
1583
|
+
if (f.type === "password") continue;
|
|
1584
|
+
const key = fieldKey(f.name);
|
|
1585
|
+
const type = fieldTypeScriptType(f);
|
|
1586
|
+
if (type === "never") continue;
|
|
1587
|
+
queryLines.push(` ${JSON.stringify(key)}?: ${type};`);
|
|
1588
|
+
}
|
|
1589
|
+
sections.push(
|
|
1590
|
+
`export interface ${typeName}QueryFields${renderInterface({
|
|
1591
|
+
extends: includeBaseFields ? "BaseRecord" : void 0,
|
|
1592
|
+
body: queryLines.join("\n")
|
|
1593
|
+
})}`
|
|
1594
|
+
);
|
|
1581
1595
|
}
|
|
1582
1596
|
sections.push(`export interface AuthRecord extends BaseRecord {
|
|
1583
1597
|
email: string;
|
|
@@ -1592,6 +1606,12 @@ ${mapEntries}
|
|
|
1592
1606
|
const createMapEntries = filtered.map((c) => ` "${c.name}": ${collectionTypeName(c.name)}CreateData;`).join("\n");
|
|
1593
1607
|
sections.push(`export interface LazypockCreateData {
|
|
1594
1608
|
${createMapEntries}
|
|
1609
|
+
}`);
|
|
1610
|
+
const queryMapEntries = filtered.map(
|
|
1611
|
+
(c) => ` "${c.name}": ${collectionTypeName(c.name)}QueryFields${c.type === "auth" ? " & AuthRecord" : ""};`
|
|
1612
|
+
).join("\n");
|
|
1613
|
+
sections.push(`export interface LazypockQueryFields {
|
|
1614
|
+
${queryMapEntries}
|
|
1595
1615
|
}`);
|
|
1596
1616
|
const schemaEntries = collections.map(
|
|
1597
1617
|
(c) => ` {
|
|
@@ -1645,15 +1665,26 @@ export class TypedClient extends LazypockClient {
|
|
|
1645
1665
|
// The (string & {}) intersection keeps the union from collapsing to plain
|
|
1646
1666
|
// string (which would silently kill the suggestions).
|
|
1647
1667
|
//
|
|
1648
|
-
//
|
|
1649
|
-
//
|
|
1668
|
+
// The service binds three types: the read model, the write-only *CreateData,
|
|
1669
|
+
// and the *QueryFields (filter/sort/expand/select keys). QueryFields is what
|
|
1670
|
+
// lets hidden relation fields \u2014 excluded from the read model but still
|
|
1671
|
+
// expandable/filterable at runtime \u2014 typecheck:
|
|
1672
|
+
// client.collection("project_members").getFullList({ expand: "user" }) // \u2713
|
|
1650
1673
|
override collection<K extends keyof LazypockCollections | (string & {})>(
|
|
1651
1674
|
name: K,
|
|
1652
1675
|
): K extends keyof LazypockCollections
|
|
1653
|
-
? CollectionService<
|
|
1676
|
+
? CollectionService<
|
|
1677
|
+
LazypockCollections[K],
|
|
1678
|
+
LazypockCreateData[K],
|
|
1679
|
+
LazypockQueryFields[K]
|
|
1680
|
+
>
|
|
1654
1681
|
: CollectionService<unknown> {
|
|
1655
1682
|
return super.collection(name) as K extends keyof LazypockCollections
|
|
1656
|
-
? CollectionService<
|
|
1683
|
+
? CollectionService<
|
|
1684
|
+
LazypockCollections[K],
|
|
1685
|
+
LazypockCreateData[K],
|
|
1686
|
+
LazypockQueryFields[K]
|
|
1687
|
+
>
|
|
1657
1688
|
: CollectionService<unknown>;
|
|
1658
1689
|
}
|
|
1659
1690
|
}
|