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.
@@ -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
- // create()/update() take the collection's *CreateData \u2014 the read model
1649
- // omits password/hidden fields, but the write model carries them.
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<LazypockCollections[K], LazypockCreateData[K]>
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<LazypockCollections[K], LazypockCreateData[K]>
1683
+ ? CollectionService<
1684
+ LazypockCollections[K],
1685
+ LazypockCreateData[K],
1686
+ LazypockQueryFields[K]
1687
+ >
1657
1688
  : CollectionService<unknown>;
1658
1689
  }
1659
1690
  }