@ai-matrx/records 0.87.2 → 0.87.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/CHANGELOG.md CHANGED
@@ -1,9 +1,9 @@
1
1
  # Changelog — @ai-matrx/records
2
2
 
3
- ## 0.87.2
3
+ ## 0.87.4
4
4
 
5
5
  Automatic changed-only republish (docs/metadata drift since the last tag — see
6
- `git diff npm/records/v0.87.1..npm/records/v0.87.2 -- apps/shared/records`).
6
+ `git diff npm/records/v0.87.3..npm/records/v0.87.4 -- apps/shared/records`).
7
7
  No source changes intended and no consumer action required.
8
8
 
9
9
  ## 0.87.1
@@ -9614,7 +9614,8 @@ async function ensureAppAutomations(client, def, specs, options = {}) {
9614
9614
  actions.push({
9615
9615
  do: "edit_rows",
9616
9616
  table_id: other.data.table,
9617
- where: keyed(a.where, theirs.data, own.data, a.table.name),
9617
+ // A Rule (`{ op, args }`) is the store's filter; a flat `{ key: value }` map is keyed.
9618
+ where: typeof a.where.op === "string" ? rewriteWhere(a.where, theirs.data, own.data) : keyed(a.where, theirs.data, own.data, a.table.name),
9618
9619
  values: keyed(a.values, theirs.data, own.data, a.table.name),
9619
9620
  ...a.limit ? { limit: a.limit } : {}
9620
9621
  });
@@ -9639,6 +9640,19 @@ async function ensureAppAutomations(client, def, specs, options = {}) {
9639
9640
  }
9640
9641
  return { ok: true, data: ids };
9641
9642
  }
9643
+ function rewriteWhere(node, target, source) {
9644
+ const walk = (n) => {
9645
+ if (Array.isArray(n)) return n.map(walk);
9646
+ if (n && typeof n === "object") {
9647
+ const o = n;
9648
+ if (Object.keys(o).length === 1 && typeof o.field === "string") return { field: byId(target, o.field, "the edited table") };
9649
+ if (Object.keys(o).length === 1 && typeof o.trigger === "string") return { trigger: byId(source, o.trigger, "the triggering table") };
9650
+ return Object.fromEntries(Object.entries(o).map(([k, v]) => [k, walk(v)]));
9651
+ }
9652
+ return n;
9653
+ };
9654
+ return walk(node);
9655
+ }
9642
9656
  function rewriteCondition(node, ids) {
9643
9657
  const walk = (n) => {
9644
9658
  if (Array.isArray(n)) return n.map(walk);