lazypock 0.8.2 → 0.8.4

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/dist/index.cjs CHANGED
@@ -1490,7 +1490,15 @@ function generateTypes(collections, options = {}) {
1490
1490
  body
1491
1491
  })}`
1492
1492
  );
1493
- const createLines = fields.map((f) => createDataMemberLine(f)).filter((l) => l !== "");
1493
+ const createLines = [];
1494
+ const seenKeys = /* @__PURE__ */ new Set();
1495
+ for (const f of fields) {
1496
+ for (const { key, line } of createDataMemberLines(f)) {
1497
+ if (seenKeys.has(key)) continue;
1498
+ seenKeys.add(key);
1499
+ createLines.push(line);
1500
+ }
1501
+ }
1494
1502
  sections.push(
1495
1503
  `export interface ${typeName}CreateData${renderInterface({
1496
1504
  body: createLines.join("\n")
@@ -1592,14 +1600,23 @@ function memberLine(f) {
1592
1600
  if (type === "never") return "";
1593
1601
  return ` ${JSON.stringify(key)}${req}: ${type};`;
1594
1602
  }
1595
- function createDataMemberLine(f) {
1596
- if (f.type === "autodate") return "";
1597
- const key = fieldKey(f.name);
1603
+ function createDataMemberLines(f) {
1604
+ if (f.type === "autodate") return [];
1605
+ const rawName = fieldKey(f.name);
1598
1606
  const serverDefaulted = f.options?.defaultValue !== void 0 || f.system && (f.name === "verified" || f.name === "emailVisibility");
1599
1607
  const req = f.required && !serverDefaulted ? "" : "?";
1600
1608
  const type = f.type === "password" ? "string" : fieldTypeScriptType(f);
1601
- if (type === "never") return "";
1602
- return ` ${JSON.stringify(key)}${req}: ${type};`;
1609
+ if (type === "never") return [];
1610
+ const members = [
1611
+ { key: rawName, line: ` ${JSON.stringify(rawName)}${req}: ${type};` }
1612
+ ];
1613
+ if (f.type === "password" && rawName !== "password") {
1614
+ members.unshift({
1615
+ key: "password",
1616
+ line: ` ${JSON.stringify("password")}${req}: ${type};`
1617
+ });
1618
+ }
1619
+ return members;
1603
1620
  }
1604
1621
 
1605
1622
  // src/lazypock.ts