@lumerahq/cli 0.22.5 → 0.23.0-dev.0

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.js CHANGED
@@ -226,25 +226,25 @@ async function main() {
226
226
  switch (command) {
227
227
  // Resource commands
228
228
  case "plan":
229
- await import("./resources-62N77NOM.js").then((m) => m.plan(args.slice(1)));
229
+ await import("./resources-DWTWFCSA.js").then((m) => m.plan(args.slice(1)));
230
230
  break;
231
231
  case "apply":
232
- await import("./resources-62N77NOM.js").then((m) => m.apply(args.slice(1)));
232
+ await import("./resources-DWTWFCSA.js").then((m) => m.apply(args.slice(1)));
233
233
  break;
234
234
  case "pull":
235
- await import("./resources-62N77NOM.js").then((m) => m.pull(args.slice(1)));
235
+ await import("./resources-DWTWFCSA.js").then((m) => m.pull(args.slice(1)));
236
236
  break;
237
237
  case "destroy":
238
- await import("./resources-62N77NOM.js").then((m) => m.destroy(args.slice(1)));
238
+ await import("./resources-DWTWFCSA.js").then((m) => m.destroy(args.slice(1)));
239
239
  break;
240
240
  case "list":
241
- await import("./resources-62N77NOM.js").then((m) => m.list(args.slice(1)));
241
+ await import("./resources-DWTWFCSA.js").then((m) => m.list(args.slice(1)));
242
242
  break;
243
243
  case "show":
244
- await import("./resources-62N77NOM.js").then((m) => m.show(args.slice(1)));
244
+ await import("./resources-DWTWFCSA.js").then((m) => m.show(args.slice(1)));
245
245
  break;
246
246
  case "diff":
247
- await import("./resources-62N77NOM.js").then((m) => m.diff(args.slice(1)));
247
+ await import("./resources-DWTWFCSA.js").then((m) => m.diff(args.slice(1)));
248
248
  break;
249
249
  // Development
250
250
  case "dev":
@@ -124,6 +124,7 @@ var collectionSchemaRule = {
124
124
  const id = parsed.id;
125
125
  const name = parsed.name;
126
126
  const fields = parsed.fields;
127
+ const audit = parsed.audit;
127
128
  const indexes = parsed.indexes;
128
129
  const search = parsed.search;
129
130
  const localFieldTypes = /* @__PURE__ */ new Map();
@@ -165,6 +166,9 @@ var collectionSchemaRule = {
165
166
  }
166
167
  }
167
168
  }
169
+ if (audit !== void 0 && typeof audit !== "boolean") {
170
+ issues.push(error(target, 'Optional field "audit" must be a boolean when present.'));
171
+ }
168
172
  if (indexes !== void 0) {
169
173
  if (!Array.isArray(indexes)) {
170
174
  issues.push(error(target, 'Optional field "indexes" must be an array when present.'));
@@ -1366,6 +1370,10 @@ function loadLocalCollections(platformDir, filterName) {
1366
1370
  errors.push(`${file}: missing fields array`);
1367
1371
  continue;
1368
1372
  }
1373
+ if (collection.audit !== void 0 && typeof collection.audit !== "boolean") {
1374
+ errors.push(`${file}: audit must be a boolean when present`);
1375
+ continue;
1376
+ }
1369
1377
  for (let i = 0; i < collection.fields.length; i++) {
1370
1378
  const field = collection.fields[i];
1371
1379
  if (!field || typeof field !== "object") {
@@ -1542,7 +1550,14 @@ function convertCollectionToApiFormat(local) {
1542
1550
  const indexName = `idx_${local.id}_${idx.fields.join("_")}`;
1543
1551
  return `CREATE ${unique}INDEX ${indexName} ON ${local.name} (${fields})`;
1544
1552
  });
1545
- return { id: local.id, name: local.name, schema, indexes, search: local.search ?? null };
1553
+ return {
1554
+ id: local.id,
1555
+ name: local.name,
1556
+ schema,
1557
+ indexes,
1558
+ ...local.audit !== void 0 ? { audit: local.audit } : {},
1559
+ search: local.search ?? null
1560
+ };
1546
1561
  }
1547
1562
  function mapFieldType(type) {
1548
1563
  const typeMap = {
@@ -1659,12 +1674,14 @@ async function planCollections(api, localCollections) {
1659
1674
  for (const local of localCollections) {
1660
1675
  const remote = remoteById.get(local.id);
1661
1676
  if (!remote) {
1677
+ const details = [`${local.fields.length} fields`];
1678
+ if (local.audit) details.push("record audit enabled");
1662
1679
  changes.push({
1663
1680
  type: "create",
1664
1681
  resource: "collection",
1665
1682
  id: local.id,
1666
1683
  name: local.name,
1667
- details: `${local.fields.length} fields`,
1684
+ details: details.join(", "),
1668
1685
  fieldDetails: local.fields.map((f) => ({
1669
1686
  action: "+",
1670
1687
  name: f.name,
@@ -1690,13 +1707,15 @@ async function planCollections(api, localCollections) {
1690
1707
  }
1691
1708
  const indexesChanged = indexesDiffer(local, remote.indexes || []);
1692
1709
  const searchChanged = normalizeCollectionSearch(local.search) !== normalizeCollectionSearch(remote.search);
1693
- if (added.length > 0 || removed.length > 0 || modified.length > 0 || indexesChanged || searchChanged) {
1710
+ const auditChanged = local.audit !== void 0 && local.audit !== remote.audit;
1711
+ if (added.length > 0 || removed.length > 0 || modified.length > 0 || indexesChanged || searchChanged || auditChanged) {
1694
1712
  const details = [];
1695
1713
  if (added.length > 0) details.push(`+${added.length} field${added.length > 1 ? "s" : ""}`);
1696
1714
  if (removed.length > 0) details.push(`-${removed.length} field${removed.length > 1 ? "s" : ""}`);
1697
1715
  if (modified.length > 0) details.push(`~${modified.length} field${modified.length > 1 ? "s" : ""} (${modified.join(", ")})`);
1698
1716
  if (indexesChanged) details.push("indexes changed");
1699
1717
  if (searchChanged) details.push("search changed");
1718
+ if (auditChanged) details.push(local.audit ? "record audit enabled" : "record audit disabled");
1700
1719
  const fieldDetails = [];
1701
1720
  for (const name of added) {
1702
1721
  const f = localFieldMap.get(name);
@@ -2183,6 +2202,7 @@ async function pullCollections(api, platformDir, filterName, appName) {
2183
2202
  const localFormat = {
2184
2203
  id: collection.id,
2185
2204
  name: localName,
2205
+ audit: collection.audit,
2186
2206
  fields: collection.schema.map((field) => {
2187
2207
  const localField = {
2188
2208
  name: field.name,
@@ -2799,9 +2819,10 @@ async function destroyResources(api, platformDir, resourceType, resourceName, sk
2799
2819
  if (!resourceType || resourceType === "collections") {
2800
2820
  const localCollections = loadLocalCollections(platformDir, resourceName || void 0);
2801
2821
  const remoteCollections = await api.listCollections();
2822
+ const remoteById = new Map(remoteCollections.map((c) => [c.id, c]));
2802
2823
  const remoteByName = new Map(remoteCollections.map((c) => [c.name, c]));
2803
2824
  for (const local of localCollections) {
2804
- const remote = remoteByName.get(local.name);
2825
+ const remote = remoteById.get(local.id) || remoteByName.get(local.name);
2805
2826
  if (remote) {
2806
2827
  toDelete.push({ type: "collection", id: local.id, name: local.name, remoteId: remote.id });
2807
2828
  }
@@ -3904,10 +3925,15 @@ async function diff(args) {
3904
3925
  }
3905
3926
  export {
3906
3927
  apply,
3928
+ applyCollections,
3929
+ convertCollectionToApiFormat,
3907
3930
  destroy,
3931
+ destroyResources,
3908
3932
  diff,
3909
3933
  list,
3910
3934
  plan,
3935
+ planCollections,
3911
3936
  pull,
3937
+ pullCollections,
3912
3938
  show
3913
3939
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lumerahq/cli",
3
- "version": "0.22.5",
3
+ "version": "0.23.0-dev.0",
4
4
  "description": "CLI for building and deploying Lumera apps",
5
5
  "type": "module",
6
6
  "engines": {