amalgm 0.1.155 → 0.1.156

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.
@@ -69,6 +69,8 @@ function normalizeEventRow(row) {
69
69
  };
70
70
  if (row.id != null) event.id = row.id;
71
71
  if (row.client_mutation_id != null) event.clientMutationId = row.client_mutation_id;
72
+ if (row.mutation_id != null) event.mutationId = row.mutation_id;
73
+ if (row.shared_resource_id != null) event.sharedResourceId = row.shared_resource_id;
72
74
  if (row.source != null) event.source = row.source;
73
75
  if (row.resource_version != null) event.version = Number(row.resource_version);
74
76
  const value = safeJsonParse(row.value_json);
@@ -93,6 +95,8 @@ function insertStateEvent(database, input) {
93
95
  const valueJson = input.valueJson !== undefined ? input.valueJson : safeJsonStringify(input.value);
94
96
  const id = input.id ?? null;
95
97
  const clientMutationId = input.clientMutationId ?? input.client_mutation_id ?? null;
98
+ const mutationId = input.mutationId ?? input.mutation_id ?? null;
99
+ const sharedResourceId = input.sharedResourceId ?? input.shared_resource_id ?? null;
96
100
  const source = input.source ?? null;
97
101
  const version = input.version ?? input.resourceVersion ?? null;
98
102
 
@@ -105,10 +109,12 @@ function insertStateEvent(database, input) {
105
109
  value_json,
106
110
  patch_json,
107
111
  client_mutation_id,
112
+ mutation_id,
113
+ shared_resource_id,
108
114
  source,
109
115
  resource_version
110
116
  )
111
- VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)
117
+ VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
112
118
  `).run(
113
119
  ts,
114
120
  input.resource,
@@ -117,6 +123,8 @@ function insertStateEvent(database, input) {
117
123
  valueJson,
118
124
  safeJsonStringify(input.patch),
119
125
  clientMutationId,
126
+ mutationId,
127
+ sharedResourceId,
120
128
  source,
121
129
  version,
122
130
  );
@@ -133,6 +141,8 @@ function insertStateEvent(database, input) {
133
141
  };
134
142
  if (id != null) event.id = String(id);
135
143
  if (clientMutationId != null) event.clientMutationId = String(clientMutationId);
144
+ if (mutationId != null) event.mutationId = String(mutationId);
145
+ if (sharedResourceId != null) event.sharedResourceId = String(sharedResourceId);
136
146
  if (source != null) event.source = String(source);
137
147
  if (version != null) event.version = Number(version);
138
148
  if (input.value !== undefined) event.value = input.value;
@@ -239,7 +249,15 @@ function maybePruneEventLog(options = {}) {
239
249
  }
240
250
  lastPruneAttemptAt = now;
241
251
  try {
242
- return pruneEventLog(options);
252
+ const result = pruneEventLog(options);
253
+ // The journal uses the same retention cadence but a stricter eligibility
254
+ // rule: only locally complete rows (local-only saved rows or cloud-synced
255
+ // rows) may age out. Pending/rejected/conflicted work is never time-pruned.
256
+ const journal = require('./mutations').pruneMutationJournal({
257
+ ...options,
258
+ cutoffIso: result.cutoffIso,
259
+ });
260
+ return { ...result, journalDeleted: journal.deleted || 0 };
243
261
  } catch (error) {
244
262
  const message = error instanceof Error ? error.message : String(error);
245
263
  console.warn('[LocalLive] Event log retention failed:', message);