@ai-matrx/records 0.96.1 → 0.96.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/CHANGELOG.md CHANGED
@@ -1,9 +1,9 @@
1
1
  # Changelog — @ai-matrx/records
2
2
 
3
- ## 0.96.1
3
+ ## 0.96.2
4
4
 
5
5
  Automatic changed-only republish (docs/metadata drift since the last tag — see
6
- `git diff npm/records/v0.96.0..npm/records/v0.96.1 -- apps/shared/records`).
6
+ `git diff npm/records/v0.96.1..npm/records/v0.96.2 -- apps/shared/records`).
7
7
  No source changes intended and no consumer action required.
8
8
 
9
9
  ## 0.96.0 — the organization's calendar can be asked (lane NOTION-SMALL-4)
@@ -620,7 +620,20 @@ function checklistSpec(checklist, tables, forms, documents) {
620
620
  };
621
621
  }
622
622
  function automationHeld(a) {
623
- return `The automation "${a.name}" is held for lane 11: no store door runs automations yet, so a template carrying one is held, never installed without it.`;
623
+ return `The automation "${a.name}" has a trigger the install cannot set up (${a.when.event}); a template automation runs on created, due or overdue.`;
624
+ }
625
+ function automationSpec(a, fieldIds) {
626
+ const text = (a.message?.trim() || a.then.trim()).slice(0, 600);
627
+ const actions = [{ do: "notify", to: { author: true }, text }];
628
+ const at = a.at && /^([01][0-9]|2[0-3]):[0-5][0-9]$/.test(a.at) ? a.at : "09:00";
629
+ if (a.when.event === "created") return { name: a.name, trigger: { on: "row_added" }, actions };
630
+ if (a.when.event === "due" || a.when.event === "overdue") {
631
+ const field = a.when.field ? fieldIds[a.when.field] : void 0;
632
+ if (!field) throw new Error(`The automation "${a.name}" waits for "${a.when.field ?? "?"}", which "${a.when.table}" does not declare.`);
633
+ const offset = a.when.event === "due" ? -Math.max(0, Math.round(a.when.daysBefore ?? 0)) : 1;
634
+ return { name: a.name, trigger: { on: "date_arrives", field, offset_days: offset, at }, actions };
635
+ }
636
+ throw new Error(automationHeld(a));
624
637
  }
625
638
  function bookingColumnsProblem(tables, booking) {
626
639
  const t = tables.find((x) => x.token === booking.table);
@@ -1992,6 +2005,8 @@ function compileInstallPlan(written) {
1992
2005
  }
1993
2006
  const needIds = /* @__PURE__ */ new Set([
1994
2007
  ...spec.extras.filter((e) => e.kind === "document" || e.kind === "row_action").map((e) => e.table),
2008
+ // A date reminder names its date Field by id.
2009
+ ...spec.extras.filter((e) => e.kind === "automation" && e.when.field).map((e) => e.when.table),
1995
2010
  ...spec.views.filter((v) => v.anyOf && Object.keys(v.anyOf).length).map((v) => v.table)
1996
2011
  ]);
1997
2012
  const fieldRefs = (token) => {
@@ -2157,7 +2172,13 @@ function compileInstallPlan(written) {
2157
2172
  });
2158
2173
  break;
2159
2174
  case "automation":
2160
- throw new Error(automationHeld(e));
2175
+ steps.push({
2176
+ label: `automations.${e.token}`,
2177
+ door: "automation_declare",
2178
+ args: { p_organization_id: "${org}", p_table_id: tableRef(e.when.table), p_spec: automationSpec(e, fieldRefs(e.when.table)), p_automation_id: null },
2179
+ save: { [`automations.${e.token}`]: ["automation_id"] }
2180
+ });
2181
+ break;
2161
2182
  default:
2162
2183
  throw new Error(`The install plan has no door for a ${e.kind} yet ("${e.token ?? "?"}"), so this template cannot be declared until it does.`);
2163
2184
  }