@fleetless/contracts 15.1.0-next.1 → 15.1.0-next.3

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.
@@ -24,8 +24,14 @@ const uuidRowTable = z.enum([
24
24
  'assets', 'audit_events', 'job_runs', 'oidc_interactions',
25
25
  'organization_exports', 'ops_notification_jobs', 'console_oauth_codes',
26
26
  'waitlist', 'waitlist_invitations', 'waitlist_invitation_proofs', 'waitlist_consents',
27
- 'operator_effect_outbox', 'operator_effect_mail_deliveries',
28
27
  ]);
28
+ /**
29
+ * The operator mail effects that concern the waiting list. The outbox and its
30
+ * deliveries are shared with billing and plan-change effects, so a waiting-list
31
+ * member names the effect's source action and replay deletes a row only when
32
+ * it still has it: no manifest can make a restore delete another effect.
33
+ */
34
+ const waitlistMailAction = z.enum(['waitlist_invite', 'waitlist_reinvite', 'waitlist_decline', 'waitlist_confirm']);
29
35
  const member = { membership_kind: membership };
30
36
  // Retention sweeps name an expired time range instead of every deleted row.
31
37
  const retentionRangeTable = z.enum(['datapoint_series_samples', 'bridge_latency_buckets']);
@@ -49,6 +55,15 @@ export const journalManifestRow = z.union([
49
55
  z.strictObject({ ...member, type: z.literal('global_ops_event'), event_id: uuid }),
50
56
  z.strictObject({ ...member, type: z.literal('org_operator_audit'), org_id: uuid, audit_id: uuid }),
51
57
  z.strictObject({ ...member, type: z.literal('global_operator_audit'), audit_id: uuid }),
58
+ z.strictObject({
59
+ ...member, type: z.literal('waitlist_mail_effect'), effect_id: uuid,
60
+ source_action: waitlistMailAction.meta({ description: 'The source action the operator_effect_outbox row had when it was frozen. Replay deletes the row only while it still has it and has no delivery left: an invitation effect carries the deliveries of many entries, and deleting it would cascade to them.' }),
61
+ }),
62
+ z.strictObject({
63
+ ...member, type: z.literal('waitlist_mail_delivery'), delivery_id: uuid, effect_id: uuid,
64
+ entry_id: uuid.meta({ description: 'The waiting-list entry the delivery was addressed for (its target); the entry itself may already be gone.' }),
65
+ source_action: waitlistMailAction.meta({ description: 'The source action of the delivery\'s effect when it was frozen; replay deletes the delivery only if its effect still has it.' }),
66
+ }),
52
67
  z.strictObject({
53
68
  type: z.literal('retention_range'),
54
69
  membership_kind: z.literal('affected'),
@@ -116,6 +131,8 @@ function rowKey(row) {
116
131
  case 'global_ops_event': return JSON.stringify(['ops_events', row.event_id]);
117
132
  case 'org_operator_audit':
118
133
  case 'global_operator_audit': return JSON.stringify(['operator_audit', row.audit_id]);
134
+ case 'waitlist_mail_effect': return JSON.stringify(['operator_effect_outbox', row.effect_id]);
135
+ case 'waitlist_mail_delivery': return JSON.stringify(['operator_effect_mail_deliveries', row.delivery_id]);
119
136
  case 'retention_range': return JSON.stringify([row.table, 'range', row.robot_id, row.series_id ?? null, row.from]);
120
137
  }
121
138
  }
@@ -143,11 +160,10 @@ const backedBranches = journalIntentV2Body.options.filter((branch) => 'manifest_
143
160
  export const journalManifestIntentProjection = z.union(backedBranches.map((branch) => z.strictObject({
144
161
  operation_id: branch.shape.operation_id, kind: branch.shape.kind, ids: branch.shape.ids,
145
162
  })));
146
- /** What a waiting-list retention batch may name: the entries, what hangs off them, and the mail rows that carry their addresses. */
147
- const waitlistTables = new Set([
148
- 'waitlist', 'waitlist_invitations', 'waitlist_invitation_proofs', 'waitlist_consents',
149
- 'operator_effect_outbox', 'operator_effect_mail_deliveries',
150
- ]);
163
+ /** The waiting list's own tables. Their rows, and the waiting-list mail members, belong to the `waitlist` scope and to no other. */
164
+ const waitlistTables = new Set(['waitlist', 'waitlist_invitations', 'waitlist_invitation_proofs', 'waitlist_consents']);
165
+ const isWaitlistMember = (row) => (row.type === 'uuid_row' && waitlistTables.has(row.table))
166
+ || row.type === 'waitlist_mail_effect' || row.type === 'waitlist_mail_delivery';
151
167
  const nonOrganizationScope = {
152
168
  'mcp_central_client.revoke': 'central_mcp',
153
169
  'mcp_central_interaction.expire': 'central_mcp',
@@ -157,6 +173,7 @@ const nonOrganizationScope = {
157
173
  'ops_global_event.retention': 'global_ops_event',
158
174
  'operator_audit.retention': 'operator_audit',
159
175
  'waitlist.retention': 'waitlist',
176
+ 'waitlist.withdrawal': 'waitlist',
160
177
  'auth_factor.remove': 'subject',
161
178
  };
162
179
  const rangeTableOfKind = {
@@ -233,11 +250,40 @@ export const journalManifestBinding = z.strictObject({
233
250
  console_oauth: (row) => row.type === 'console_interaction' || (row.type === 'uuid_row' && row.table === 'console_oauth_codes'),
234
251
  global_ops_event: (row) => row.type === 'global_ops_event' || (row.type === 'uuid_row' && row.table === 'ops_notification_jobs'),
235
252
  operator_audit: (row) => row.type === 'global_operator_audit' || row.type === 'org_operator_audit',
236
- waitlist: (row) => row.type === 'uuid_row' && waitlistTables.has(row.table),
253
+ waitlist: isWaitlistMember,
237
254
  };
238
255
  const allows = allowedRows[manifest.scope.kind];
239
256
  if (allows && !manifest.rows.every(allows))
240
257
  problem('Row outside closed source scope', ['manifest', 'rows']);
258
+ if (manifest.scope.kind !== 'waitlist' && manifest.rows.some(isWaitlistMember))
259
+ problem('Waiting-list row outside the waitlist scope', ['manifest', 'rows']);
260
+ if (manifest.scope.kind === 'waitlist') {
261
+ // The waiting list has no objects: no mapping, so no free string can carry an address into this manifest.
262
+ if (manifest.entries.length !== 0)
263
+ problem('A waitlist manifest has no object entries', ['manifest', 'entries']);
264
+ const effects = new Map(manifest.rows.flatMap((row) => (row.type === 'waitlist_mail_effect' ? [[row.effect_id, row.source_action]] : [])));
265
+ const deliveries = manifest.rows.filter((row) => row.type === 'waitlist_mail_delivery');
266
+ if (deliveries.some((row) => effects.has(row.effect_id) && effects.get(row.effect_id) !== row.source_action)) {
267
+ problem('A delivery and its effect disagree on the source action', ['manifest', 'rows']);
268
+ }
269
+ if (intent.kind === 'waitlist.withdrawal') {
270
+ // One entry: exactly its own row, and mail deliveries addressed for it alone.
271
+ const entries = manifest.rows.filter((row) => row.type === 'uuid_row' && row.table === 'waitlist');
272
+ const only = entries[0];
273
+ if (entries.length !== 1 || only?.type !== 'uuid_row' || only.id !== ids.entry_id || only.membership_kind !== 'affected') {
274
+ problem('A withdrawal names exactly its own entry', ['manifest', 'rows']);
275
+ }
276
+ if (deliveries.some((row) => row.entry_id !== ids.entry_id)) {
277
+ problem('A withdrawal deletes only its own entry\'s deliveries', ['manifest', 'rows']);
278
+ }
279
+ // An effect goes only as the parent of one of the withdrawal's own deliveries (replay then deletes it only once it has none left).
280
+ for (const [effectId, sourceAction] of effects) {
281
+ if (!deliveries.some((row) => row.effect_id === effectId && row.source_action === sourceAction)) {
282
+ problem('A withdrawal deletes only the effects of its own deliveries', ['manifest', 'rows']);
283
+ }
284
+ }
285
+ }
286
+ }
241
287
  const ranges = manifest.rows.filter((row) => row.type === 'retention_range');
242
288
  if (ranges.length > 0)
243
289
  for (const message of new Set(retentionRangeProblems(intent.kind, ids, ranges)))
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fleetless/contracts",
3
- "version": "15.1.0-next.1",
3
+ "version": "15.1.0-next.3",
4
4
  "description": "Fleetless wire contracts: the bridge-cloud protocol, the REST API schemas and the error codes, as zod schemas with generated JSON Schema and OpenAPI artifacts.",
5
5
  "license": "Apache-2.0",
6
6
  "author": "Dehne Robotik GmbH",