@ai-matrx/records 0.98.11 → 0.98.12

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
@@ -5369,6 +5369,13 @@ function tableRenderSchema(facts) {
5369
5369
  function refuse(code, message, hint) {
5370
5370
  return { ok: false, error: { code, message, hint, ours: true } };
5371
5371
  }
5372
+ function displacedSource(envelope) {
5373
+ if (envelope.src) return { src: envelope.src };
5374
+ const by = envelope.actor === "agent" ? "an agent" : envelope.actor === "system" ? "the system" : envelope.actor ? "a person" : null;
5375
+ if (by === null) return {};
5376
+ const day = typeof envelope.at === "string" && envelope.at.length >= 10 ? ` on ${envelope.at.slice(0, 10)}` : "";
5377
+ return { src: { name: `Entered by ${by}${day}` } };
5378
+ }
5372
5379
  function alternatePatch(document, field_key, alternate_index, rank) {
5373
5380
  const block = document._values ?? {};
5374
5381
  const envelope = block[field_key];
@@ -5384,7 +5391,7 @@ function alternatePatch(document, field_key, alternate_index, rank) {
5384
5391
  const taken = new Set(kept.map((a) => a.rank));
5385
5392
  let rank2 = 1;
5386
5393
  while (taken.has(rank2)) rank2 += 1;
5387
- next.push({ value: current, ...envelope.src ? { src: envelope.src } : {}, rank: rank2 });
5394
+ next.push({ value: current, ...displacedSource(envelope), rank: rank2 });
5388
5395
  }
5389
5396
  const { ver: _ver, actor: _actor, at: _at, on_behalf_of: _on, absent: _absent, alternates: _alts, src: _src, ...rest } = envelope;
5390
5397
  const changed = { ...rest, ...chosen.src ? { src: chosen.src } : {} };