@happyvertical/smrt-sales 0.57.2 → 0.57.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.
Files changed (46) hide show
  1. package/README.md +70 -2
  2. package/agents/commissions.md +1 -1
  3. package/agents/referrals.md +1 -0
  4. package/dist/agreements/collections/AgreementCollection.d.ts +50 -0
  5. package/dist/agreements/collections/AgreementCollection.d.ts.map +1 -0
  6. package/dist/agreements/index.d.ts +2 -0
  7. package/dist/agreements/index.d.ts.map +1 -1
  8. package/dist/agreements/models/Agreement.d.ts +67 -0
  9. package/dist/agreements/models/Agreement.d.ts.map +1 -0
  10. package/dist/agreements/types.d.ts +32 -0
  11. package/dist/agreements/types.d.ts.map +1 -1
  12. package/dist/agreements.d.ts +2 -2
  13. package/dist/agreements.js +3 -3
  14. package/dist/chunks/__smrt-register__-Bvg_UsSM.js +6 -0
  15. package/dist/chunks/__smrt-register__-Bvg_UsSM.js.map +1 -0
  16. package/dist/chunks/{agreements-BB_tNU0U.js → agreements-jBiVmttD.js} +450 -4
  17. package/dist/chunks/agreements-jBiVmttD.js.map +1 -0
  18. package/dist/chunks/{commissions-Cs4MsxVg.js → commissions-Cip6QZ9Q.js} +350 -6
  19. package/dist/chunks/commissions-Cip6QZ9Q.js.map +1 -0
  20. package/dist/chunks/{referrals-CrFDsdq-.js → referrals-CYgrGkEo.js} +17 -3
  21. package/dist/chunks/{referrals-CrFDsdq-.js.map → referrals-CYgrGkEo.js.map} +1 -1
  22. package/dist/commissions/collections/CommissionAdjustmentOperationCollection.d.ts.map +1 -1
  23. package/dist/commissions/collections/CommissionPlanCollection.d.ts +5 -1
  24. package/dist/commissions/collections/CommissionPlanCollection.d.ts.map +1 -1
  25. package/dist/commissions/models/CommissionPlan.d.ts +20 -1
  26. package/dist/commissions/models/CommissionPlan.d.ts.map +1 -1
  27. package/dist/commissions/services/WaterfallCalculationService.d.ts +22 -0
  28. package/dist/commissions/services/WaterfallCalculationService.d.ts.map +1 -0
  29. package/dist/commissions/services/index.d.ts +1 -0
  30. package/dist/commissions/services/index.d.ts.map +1 -1
  31. package/dist/commissions/types.d.ts +100 -0
  32. package/dist/commissions/types.d.ts.map +1 -1
  33. package/dist/commissions.js +3 -3
  34. package/dist/crm.js +1 -1
  35. package/dist/index.d.ts +2 -2
  36. package/dist/index.js +5 -5
  37. package/dist/manifest.json +1399 -514
  38. package/dist/referrals/services/ReferralQualificationService.d.ts +4 -3
  39. package/dist/referrals/services/ReferralQualificationService.d.ts.map +1 -1
  40. package/dist/referrals.js +2 -2
  41. package/dist/smrt-knowledge.json +985 -34
  42. package/package.json +8 -8
  43. package/dist/chunks/__smrt-register__-CNn8HXhK.js +0 -6
  44. package/dist/chunks/__smrt-register__-CNn8HXhK.js.map +0 -1
  45. package/dist/chunks/agreements-BB_tNU0U.js.map +0 -1
  46. package/dist/chunks/commissions-Cs4MsxVg.js.map +0 -1
@@ -2,199 +2,164 @@
2
2
  "version": "1.0.0",
3
3
  "timestamp": 0,
4
4
  "packageName": "@happyvertical/smrt-sales",
5
- "packageVersion": "0.57.2",
5
+ "packageVersion": "0.57.4",
6
6
  "objects": {
7
- "@happyvertical/smrt-sales:AgreementExecutionCollection": {
8
- "name": "agreementexecutioncollection",
9
- "className": "AgreementExecutionCollection",
10
- "qualifiedName": "@happyvertical/smrt-sales:AgreementExecutionCollection",
11
- "collection": "agreementexecutions",
12
- "filePath": "/home/runner/work/smrt/smrt/packages/sales/src/agreements/collections/AgreementExecutionCollection.ts",
7
+ "@happyvertical/smrt-sales:AgreementCollection": {
8
+ "name": "agreementcollection",
9
+ "className": "AgreementCollection",
10
+ "qualifiedName": "@happyvertical/smrt-sales:AgreementCollection",
11
+ "collection": "agreements",
12
+ "description": "Versioned rows for one ordered (kind, partyA, partyB) relationship.",
13
+ "filePath": "/home/runner/work/smrt/smrt/packages/sales/src/agreements/collections/AgreementCollection.ts",
13
14
  "packageName": "@happyvertical/smrt-sales",
14
15
  "fields": {},
15
16
  "methods": {
16
- "findByIdempotencyKey": {
17
- "name": "findByIdempotencyKey",
17
+ "findVersions": {
18
+ "name": "findVersions",
18
19
  "async": true,
19
20
  "parameters": [
20
21
  {
21
- "name": "idempotencyKey",
22
+ "name": "kind",
22
23
  "type": "string",
23
24
  "optional": false
24
- }
25
- ],
26
- "returnType": "Promise<AgreementExecution | null>",
27
- "isStatic": false,
28
- "isPublic": true
29
- },
30
- "findByProviderRequest": {
31
- "name": "findByProviderRequest",
32
- "async": true,
33
- "parameters": [
25
+ },
34
26
  {
35
- "name": "provider",
36
- "type": "string",
27
+ "name": "partyA",
28
+ "type": "AgreementParty",
37
29
  "optional": false
38
30
  },
39
31
  {
40
- "name": "providerRequestId",
41
- "type": "string",
32
+ "name": "partyB",
33
+ "type": "AgreementParty",
42
34
  "optional": false
43
35
  }
44
36
  ],
45
- "returnType": "Promise<AgreementExecution | null>",
37
+ "returnType": "Promise<Agreement[]>",
46
38
  "isStatic": false,
47
39
  "isPublic": true
48
40
  },
49
- "claimCreateAttempt": {
50
- "name": "claimCreateAttempt",
41
+ "activeFor": {
42
+ "name": "activeFor",
51
43
  "async": true,
52
44
  "parameters": [
53
45
  {
54
- "name": "input",
55
- "type": "ClaimAgreementCreateAttemptInput",
46
+ "name": "kind",
47
+ "type": "string",
56
48
  "optional": false
57
- }
58
- ],
59
- "returnType": "Promise<AgreementExecution | null>",
60
- "isStatic": false,
61
- "isPublic": true
62
- },
63
- "completeCreateAttempt": {
64
- "name": "completeCreateAttempt",
65
- "async": true,
66
- "parameters": [
49
+ },
67
50
  {
68
- "name": "input",
69
- "type": "CompleteAgreementCreateAttemptInput",
51
+ "name": "partyA",
52
+ "type": "AgreementParty",
70
53
  "optional": false
71
- }
72
- ],
73
- "returnType": "Promise<AgreementExecution | null>",
74
- "isStatic": false,
75
- "isPublic": true
76
- },
77
- "failCreateAttempt": {
78
- "name": "failCreateAttempt",
79
- "async": true,
80
- "parameters": [
54
+ },
81
55
  {
82
- "name": "input",
83
- "type": "FailAgreementCreateAttemptInput",
56
+ "name": "partyB",
57
+ "type": "AgreementParty",
84
58
  "optional": false
85
- }
86
- ],
87
- "returnType": "Promise<AgreementExecution | null>",
88
- "isStatic": false,
89
- "isPublic": true
90
- },
91
- "bindProviderRequest": {
92
- "name": "bindProviderRequest",
93
- "async": true,
94
- "parameters": [
59
+ },
95
60
  {
96
- "name": "input",
97
- "type": "BindAgreementProviderRequestInput",
98
- "optional": false
99
- }
100
- ],
101
- "returnType": "Promise<AgreementExecution | null>",
102
- "isStatic": false,
103
- "isPublic": true
104
- },
105
- "compareAndSetLifecycle": {
106
- "name": "compareAndSetLifecycle",
107
- "async": true,
108
- "parameters": [
61
+ "name": "at",
62
+ "type": "Date",
63
+ "optional": true
64
+ },
109
65
  {
110
- "name": "input",
111
- "type": "CompareAndSetAgreementLifecycleInput",
112
- "optional": false
66
+ "name": "tenantId",
67
+ "type": "string | null",
68
+ "optional": true,
69
+ "unionBranches": [
70
+ {
71
+ "type": "string"
72
+ },
73
+ {
74
+ "type": "null"
75
+ }
76
+ ]
113
77
  }
114
78
  ],
115
- "returnType": "Promise<AgreementExecution | null>",
79
+ "returnType": "Promise<Agreement | null>",
116
80
  "isStatic": false,
117
81
  "isPublic": true
118
82
  },
119
- "incrementAttemptCount": {
120
- "name": "incrementAttemptCount",
83
+ "createAmendment": {
84
+ "name": "createAmendment",
121
85
  "async": true,
122
86
  "parameters": [
123
87
  {
124
- "name": "tenantId",
88
+ "name": "kind",
125
89
  "type": "string",
126
90
  "optional": false
127
91
  },
128
92
  {
129
- "name": "executionId",
130
- "type": "string",
93
+ "name": "partyA",
94
+ "type": "AgreementParty",
131
95
  "optional": false
132
- }
133
- ],
134
- "returnType": "Promise<AgreementExecution>",
135
- "isStatic": false,
136
- "isPublic": true
137
- },
138
- "updateLastError": {
139
- "name": "updateLastError",
140
- "async": true,
141
- "parameters": [
96
+ },
142
97
  {
143
- "name": "input",
144
- "type": "UpdateAgreementExecutionErrorInput",
98
+ "name": "partyB",
99
+ "type": "AgreementParty",
145
100
  "optional": false
101
+ },
102
+ {
103
+ "name": "changes",
104
+ "type": "AgreementAmendmentChanges",
105
+ "optional": true
146
106
  }
147
107
  ],
148
- "returnType": "Promise<AgreementExecution>",
108
+ "returnType": "Promise<Agreement>",
149
109
  "isStatic": false,
150
110
  "isPublic": true
151
111
  },
152
- "bindEvidenceArtifact": {
153
- "name": "bindEvidenceArtifact",
112
+ "activateAmendment": {
113
+ "name": "activateAmendment",
154
114
  "async": true,
155
115
  "parameters": [
156
116
  {
157
- "name": "input",
158
- "type": "BindAgreementEvidenceArtifactInput",
117
+ "name": "id",
118
+ "type": "string",
159
119
  "optional": false
160
120
  }
161
121
  ],
162
- "returnType": "Promise<AgreementExecution | null>",
122
+ "returnType": "Promise<Agreement>",
163
123
  "isStatic": false,
164
124
  "isPublic": true
165
125
  },
166
- "findBySource": {
167
- "name": "findBySource",
126
+ "withdrawAmendment": {
127
+ "name": "withdrawAmendment",
168
128
  "async": true,
169
129
  "parameters": [
170
130
  {
171
- "name": "sourceKind",
172
- "type": "string",
173
- "optional": false
174
- },
175
- {
176
- "name": "sourceId",
131
+ "name": "id",
177
132
  "type": "string",
178
133
  "optional": false
179
134
  }
180
135
  ],
181
- "returnType": "Promise<AgreementExecution[]>",
136
+ "returnType": "Promise<Agreement>",
182
137
  "isStatic": false,
183
138
  "isPublic": true
184
139
  }
185
140
  },
186
141
  "decoratorConfig": {
187
- "api": false,
188
- "mcp": false,
189
- "cli": false
142
+ "api": {
143
+ "include": [
144
+ "list",
145
+ "get",
146
+ "create"
147
+ ]
148
+ },
149
+ "mcp": {
150
+ "include": [
151
+ "list",
152
+ "get"
153
+ ]
154
+ }
190
155
  },
191
156
  "extends": "SmrtCollection",
192
- "extendsTypeArg": "AgreementExecution",
193
- "exportName": "AgreementExecutionCollection",
194
- "collectionExportName": "AgreementExecutionCollectionCollection",
157
+ "extendsTypeArg": "Agreement",
158
+ "exportName": "AgreementCollection",
159
+ "collectionExportName": "AgreementCollectionCollection",
195
160
  "schema": {
196
- "tableName": "agreement_executions",
197
- "ddl": "CREATE TABLE IF NOT EXISTS \"agreement_executions\" (\n \"id\" UUID PRIMARY KEY NOT NULL,\n \"slug\" TEXT NOT NULL,\n \"context\" TEXT NOT NULL DEFAULT '',\n \"created_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"updated_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"tenant_id\" UUID NOT NULL,\n \"provider\" TEXT NOT NULL DEFAULT '',\n \"provider_account_ref\" TEXT DEFAULT '',\n \"credential_ref\" TEXT DEFAULT '',\n \"idempotency_key\" TEXT NOT NULL DEFAULT '',\n \"source_kind\" TEXT NOT NULL DEFAULT '',\n \"source_id\" TEXT NOT NULL DEFAULT '',\n \"source_version\" INTEGER DEFAULT 1,\n \"source_asset_id\" UUID,\n \"source_sha256\" TEXT DEFAULT '',\n \"source_size_bytes\" INTEGER DEFAULT 0,\n \"request_intent_sha256\" TEXT DEFAULT '',\n \"title\" TEXT DEFAULT '',\n \"signer_intent\" TEXT DEFAULT '[]',\n \"provider_request_id\" TEXT DEFAULT '',\n \"provider_request_key\" TEXT UNIQUE,\n \"status\" TEXT DEFAULT 'prepared',\n \"expires_at\" TIMESTAMP,\n \"cancellation_reason\" TEXT DEFAULT '',\n \"last_provider_event_at\" TIMESTAMP,\n \"last_reconciled_at\" TIMESTAMP,\n \"completed_at\" TIMESTAMP,\n \"effective_from\" TIMESTAMP,\n \"effective_to\" TIMESTAMP,\n \"supersedes_executed_agreement_id\" TEXT DEFAULT '',\n \"signed_document_asset_id\" UUID,\n \"signed_document_sha256\" TEXT DEFAULT '',\n \"signed_document_size_bytes\" INTEGER DEFAULT 0,\n \"signed_document_media_type\" TEXT DEFAULT '',\n \"signed_document_filename\" TEXT DEFAULT '',\n \"audit_trail_asset_id\" UUID,\n \"audit_trail_sha256\" TEXT DEFAULT '',\n \"audit_trail_size_bytes\" INTEGER DEFAULT 0,\n \"audit_trail_media_type\" TEXT DEFAULT '',\n \"audit_trail_filename\" TEXT DEFAULT '',\n \"attempt_count\" INTEGER DEFAULT 0,\n \"create_lease_id\" TEXT DEFAULT '',\n \"create_lease_expires_at\" TIMESTAMP,\n \"last_error\" TEXT DEFAULT '',\n \"metadata\" TEXT DEFAULT '{}'\n);",
161
+ "tableName": "agreements",
162
+ "ddl": "CREATE TABLE IF NOT EXISTS \"agreements\" (\n \"id\" UUID PRIMARY KEY NOT NULL,\n \"slug\" TEXT NOT NULL,\n \"context\" TEXT NOT NULL DEFAULT '',\n \"created_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"updated_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"tenant_id\" UUID,\n \"kind\" TEXT NOT NULL DEFAULT '',\n \"party_a\" TEXT NOT NULL DEFAULT '',\n \"party_b\" TEXT NOT NULL DEFAULT '',\n \"version\" INTEGER DEFAULT 1,\n \"status\" TEXT DEFAULT 'draft',\n \"terms\" TEXT DEFAULT '{}',\n \"effective_from\" TIMESTAMP,\n \"effective_to\" TIMESTAMP,\n \"executed_agreement_id\" UUID,\n \"amendment_predecessor_id\" UUID,\n \"amendment_predecessor_end\" TIMESTAMP,\n \"metadata\" TEXT DEFAULT '{}'\n);",
198
163
  "columns": {
199
164
  "id": {
200
165
  "type": "UUID",
@@ -224,230 +189,85 @@
224
189
  "tenant_id": {
225
190
  "type": "UUID",
226
191
  "referenceKind": "tenantId",
227
- "notNull": true,
228
- "unique": false
229
- },
230
- "provider": {
231
- "type": "TEXT",
232
- "notNull": true,
233
- "unique": false,
234
- "default": ""
235
- },
236
- "provider_account_ref": {
237
- "type": "TEXT",
238
- "notNull": false,
239
- "unique": false,
240
- "default": ""
241
- },
242
- "credential_ref": {
243
- "type": "TEXT",
244
192
  "notNull": false,
245
- "unique": false,
246
- "default": ""
193
+ "unique": false
247
194
  },
248
- "idempotency_key": {
195
+ "kind": {
249
196
  "type": "TEXT",
250
197
  "notNull": true,
251
198
  "unique": false,
252
199
  "default": ""
253
200
  },
254
- "source_kind": {
201
+ "party_a": {
255
202
  "type": "TEXT",
256
203
  "notNull": true,
257
204
  "unique": false,
258
205
  "default": ""
259
206
  },
260
- "source_id": {
207
+ "party_b": {
261
208
  "type": "TEXT",
262
209
  "notNull": true,
263
210
  "unique": false,
264
211
  "default": ""
265
212
  },
266
- "source_version": {
213
+ "version": {
267
214
  "type": "INTEGER",
268
215
  "notNull": false,
269
216
  "unique": false,
270
217
  "default": 1
271
218
  },
272
- "source_asset_id": {
273
- "type": "UUID",
274
- "referenceKind": "crossPackageRef",
275
- "notNull": false,
276
- "unique": false
277
- },
278
- "source_sha256": {
219
+ "status": {
279
220
  "type": "TEXT",
280
221
  "notNull": false,
281
222
  "unique": false,
282
- "default": ""
283
- },
284
- "source_size_bytes": {
285
- "type": "INTEGER",
286
- "notNull": false,
287
- "unique": false,
288
- "default": 0
223
+ "default": "draft"
289
224
  },
290
- "request_intent_sha256": {
225
+ "terms": {
291
226
  "type": "TEXT",
292
227
  "notNull": false,
293
228
  "unique": false,
294
- "default": ""
229
+ "default": "{}"
295
230
  },
296
- "title": {
297
- "type": "TEXT",
231
+ "effective_from": {
232
+ "type": "TIMESTAMP",
298
233
  "notNull": false,
299
- "unique": false,
300
- "default": ""
234
+ "unique": false
301
235
  },
302
- "signer_intent": {
303
- "type": "TEXT",
236
+ "effective_to": {
237
+ "type": "TIMESTAMP",
304
238
  "notNull": false,
305
- "unique": false,
306
- "default": "[]"
239
+ "unique": false
307
240
  },
308
- "provider_request_id": {
309
- "type": "TEXT",
241
+ "executed_agreement_id": {
242
+ "type": "UUID",
243
+ "referenceKind": "foreignKey",
310
244
  "notNull": false,
311
245
  "unique": false,
312
- "default": ""
313
- },
314
- "provider_request_key": {
315
- "type": "TEXT",
316
- "notNull": false,
317
- "unique": true
246
+ "foreignKey": {
247
+ "table": "executed_agreements",
248
+ "column": "id",
249
+ "onDelete": "NO ACTION",
250
+ "onUpdate": "CASCADE"
251
+ }
318
252
  },
319
- "status": {
320
- "type": "TEXT",
253
+ "amendment_predecessor_id": {
254
+ "type": "UUID",
255
+ "referenceKind": "foreignKey",
321
256
  "notNull": false,
322
257
  "unique": false,
323
- "default": "prepared"
258
+ "foreignKey": {
259
+ "table": "agreements",
260
+ "column": "id",
261
+ "onDelete": "NO ACTION",
262
+ "onUpdate": "CASCADE"
263
+ }
324
264
  },
325
- "expires_at": {
265
+ "amendment_predecessor_end": {
326
266
  "type": "TIMESTAMP",
327
267
  "notNull": false,
328
268
  "unique": false
329
269
  },
330
- "cancellation_reason": {
331
- "type": "TEXT",
332
- "notNull": false,
333
- "unique": false,
334
- "default": ""
335
- },
336
- "last_provider_event_at": {
337
- "type": "TIMESTAMP",
338
- "notNull": false,
339
- "unique": false
340
- },
341
- "last_reconciled_at": {
342
- "type": "TIMESTAMP",
343
- "notNull": false,
344
- "unique": false
345
- },
346
- "completed_at": {
347
- "type": "TIMESTAMP",
348
- "notNull": false,
349
- "unique": false
350
- },
351
- "effective_from": {
352
- "type": "TIMESTAMP",
353
- "notNull": false,
354
- "unique": false
355
- },
356
- "effective_to": {
357
- "type": "TIMESTAMP",
358
- "notNull": false,
359
- "unique": false
360
- },
361
- "supersedes_executed_agreement_id": {
362
- "type": "TEXT",
363
- "notNull": false,
364
- "unique": false,
365
- "default": ""
366
- },
367
- "signed_document_asset_id": {
368
- "type": "UUID",
369
- "referenceKind": "crossPackageRef",
370
- "notNull": false,
371
- "unique": false
372
- },
373
- "signed_document_sha256": {
374
- "type": "TEXT",
375
- "notNull": false,
376
- "unique": false,
377
- "default": ""
378
- },
379
- "signed_document_size_bytes": {
380
- "type": "INTEGER",
381
- "notNull": false,
382
- "unique": false,
383
- "default": 0
384
- },
385
- "signed_document_media_type": {
386
- "type": "TEXT",
387
- "notNull": false,
388
- "unique": false,
389
- "default": ""
390
- },
391
- "signed_document_filename": {
392
- "type": "TEXT",
393
- "notNull": false,
394
- "unique": false,
395
- "default": ""
396
- },
397
- "audit_trail_asset_id": {
398
- "type": "UUID",
399
- "referenceKind": "crossPackageRef",
400
- "notNull": false,
401
- "unique": false
402
- },
403
- "audit_trail_sha256": {
404
- "type": "TEXT",
405
- "notNull": false,
406
- "unique": false,
407
- "default": ""
408
- },
409
- "audit_trail_size_bytes": {
410
- "type": "INTEGER",
411
- "notNull": false,
412
- "unique": false,
413
- "default": 0
414
- },
415
- "audit_trail_media_type": {
416
- "type": "TEXT",
417
- "notNull": false,
418
- "unique": false,
419
- "default": ""
420
- },
421
- "audit_trail_filename": {
422
- "type": "TEXT",
423
- "notNull": false,
424
- "unique": false,
425
- "default": ""
426
- },
427
- "attempt_count": {
428
- "type": "INTEGER",
429
- "notNull": false,
430
- "unique": false,
431
- "default": 0
432
- },
433
- "create_lease_id": {
434
- "type": "TEXT",
435
- "notNull": false,
436
- "unique": false,
437
- "default": ""
438
- },
439
- "create_lease_expires_at": {
440
- "type": "TIMESTAMP",
441
- "notNull": false,
442
- "unique": false
443
- },
444
- "last_error": {
445
- "type": "TEXT",
446
- "notNull": false,
447
- "unique": false,
448
- "default": ""
449
- },
450
- "metadata": {
270
+ "metadata": {
451
271
  "type": "TEXT",
452
272
  "notNull": false,
453
273
  "unique": false,
@@ -456,128 +276,239 @@
456
276
  },
457
277
  "indexes": [
458
278
  {
459
- "name": "agreement_executions_tenant_id_idempotency_key_idx",
279
+ "name": "agreements_tenant_id_kind_idx",
460
280
  "columns": [
461
281
  "tenant_id",
462
- "idempotency_key"
282
+ "kind",
283
+ "party_a",
284
+ "party_b",
285
+ "version"
463
286
  ],
464
- "unique": true
287
+ "unique": true,
288
+ "nullsNotDistinct": true
465
289
  },
466
290
  {
467
- "name": "agreement_executions_slug_context_idx",
291
+ "name": "agreements_slug_context_idx",
468
292
  "columns": [
469
293
  "slug",
470
294
  "context"
471
295
  ]
472
296
  },
473
297
  {
474
- "name": "agreement_executions_tenant_id_created_at_idx",
298
+ "name": "agreements_tenant_id_created_at_idx",
475
299
  "columns": [
476
300
  "tenant_id",
477
301
  "created_at"
478
302
  ]
479
303
  },
480
304
  {
481
- "name": "agreement_executions_source_asset_id_idx",
482
- "columns": [
483
- "source_asset_id"
484
- ]
485
- },
486
- {
487
- "name": "agreement_executions_signed_document_asset_id_idx",
305
+ "name": "agreements_executed_agreement_id_idx",
488
306
  "columns": [
489
- "signed_document_asset_id"
307
+ "executed_agreement_id"
490
308
  ]
491
309
  },
492
310
  {
493
- "name": "agreement_executions_audit_trail_asset_id_idx",
311
+ "name": "agreements_amendment_predecessor_id_idx",
494
312
  "columns": [
495
- "audit_trail_asset_id"
313
+ "amendment_predecessor_id"
496
314
  ]
497
315
  }
498
316
  ],
499
- "version": "33a93a76"
317
+ "version": "b9d6d0e8"
500
318
  },
501
319
  "importPath": "@happyvertical/smrt-sales/agreements"
502
320
  },
503
- "@happyvertical/smrt-sales:AgreementExecutionEventCollection": {
504
- "name": "agreementexecutioneventcollection",
505
- "className": "AgreementExecutionEventCollection",
506
- "qualifiedName": "@happyvertical/smrt-sales:AgreementExecutionEventCollection",
507
- "collection": "agreementexecutionevents",
508
- "filePath": "/home/runner/work/smrt/smrt/packages/sales/src/agreements/collections/AgreementExecutionEventCollection.ts",
321
+ "@happyvertical/smrt-sales:AgreementExecutionCollection": {
322
+ "name": "agreementexecutioncollection",
323
+ "className": "AgreementExecutionCollection",
324
+ "qualifiedName": "@happyvertical/smrt-sales:AgreementExecutionCollection",
325
+ "collection": "agreementexecutions",
326
+ "filePath": "/home/runner/work/smrt/smrt/packages/sales/src/agreements/collections/AgreementExecutionCollection.ts",
509
327
  "packageName": "@happyvertical/smrt-sales",
510
328
  "fields": {},
511
329
  "methods": {
512
- "findByDedupeKey": {
513
- "name": "findByDedupeKey",
330
+ "findByIdempotencyKey": {
331
+ "name": "findByIdempotencyKey",
514
332
  "async": true,
515
333
  "parameters": [
516
334
  {
517
- "name": "dedupeKey",
335
+ "name": "idempotencyKey",
518
336
  "type": "string",
519
337
  "optional": false
520
338
  }
521
339
  ],
522
- "returnType": "Promise<AgreementExecutionEvent | null>",
340
+ "returnType": "Promise<AgreementExecution | null>",
523
341
  "isStatic": false,
524
342
  "isPublic": true
525
343
  },
526
- "recordVerified": {
527
- "name": "recordVerified",
344
+ "findByProviderRequest": {
345
+ "name": "findByProviderRequest",
528
346
  "async": true,
529
347
  "parameters": [
530
348
  {
531
- "name": "options",
532
- "type": "VerifiedAgreementExecutionEventOptions",
349
+ "name": "provider",
350
+ "type": "string",
351
+ "optional": false
352
+ },
353
+ {
354
+ "name": "providerRequestId",
355
+ "type": "string",
533
356
  "optional": false
534
357
  }
535
358
  ],
536
- "returnType": "Promise<object>",
359
+ "returnType": "Promise<AgreementExecution | null>",
537
360
  "isStatic": false,
538
361
  "isPublic": true
539
362
  },
540
- "findByExecution": {
541
- "name": "findByExecution",
363
+ "claimCreateAttempt": {
364
+ "name": "claimCreateAttempt",
542
365
  "async": true,
543
366
  "parameters": [
544
367
  {
545
- "name": "executionId",
546
- "type": "string",
368
+ "name": "input",
369
+ "type": "ClaimAgreementCreateAttemptInput",
547
370
  "optional": false
548
371
  }
549
372
  ],
550
- "returnType": "Promise<AgreementExecutionEvent[]>",
373
+ "returnType": "Promise<AgreementExecution | null>",
551
374
  "isStatic": false,
552
375
  "isPublic": true
553
376
  },
554
- "findProviderEventsByExecution": {
555
- "name": "findProviderEventsByExecution",
377
+ "completeCreateAttempt": {
378
+ "name": "completeCreateAttempt",
379
+ "async": true,
380
+ "parameters": [
381
+ {
382
+ "name": "input",
383
+ "type": "CompleteAgreementCreateAttemptInput",
384
+ "optional": false
385
+ }
386
+ ],
387
+ "returnType": "Promise<AgreementExecution | null>",
388
+ "isStatic": false,
389
+ "isPublic": true
390
+ },
391
+ "failCreateAttempt": {
392
+ "name": "failCreateAttempt",
393
+ "async": true,
394
+ "parameters": [
395
+ {
396
+ "name": "input",
397
+ "type": "FailAgreementCreateAttemptInput",
398
+ "optional": false
399
+ }
400
+ ],
401
+ "returnType": "Promise<AgreementExecution | null>",
402
+ "isStatic": false,
403
+ "isPublic": true
404
+ },
405
+ "bindProviderRequest": {
406
+ "name": "bindProviderRequest",
407
+ "async": true,
408
+ "parameters": [
409
+ {
410
+ "name": "input",
411
+ "type": "BindAgreementProviderRequestInput",
412
+ "optional": false
413
+ }
414
+ ],
415
+ "returnType": "Promise<AgreementExecution | null>",
416
+ "isStatic": false,
417
+ "isPublic": true
418
+ },
419
+ "compareAndSetLifecycle": {
420
+ "name": "compareAndSetLifecycle",
421
+ "async": true,
422
+ "parameters": [
423
+ {
424
+ "name": "input",
425
+ "type": "CompareAndSetAgreementLifecycleInput",
426
+ "optional": false
427
+ }
428
+ ],
429
+ "returnType": "Promise<AgreementExecution | null>",
430
+ "isStatic": false,
431
+ "isPublic": true
432
+ },
433
+ "incrementAttemptCount": {
434
+ "name": "incrementAttemptCount",
556
435
  "async": true,
557
436
  "parameters": [
437
+ {
438
+ "name": "tenantId",
439
+ "type": "string",
440
+ "optional": false
441
+ },
558
442
  {
559
443
  "name": "executionId",
560
444
  "type": "string",
561
445
  "optional": false
562
446
  }
563
447
  ],
564
- "returnType": "Promise<AgreementExecutionEvent[]>",
448
+ "returnType": "Promise<AgreementExecution>",
565
449
  "isStatic": false,
566
450
  "isPublic": true
567
- }
568
- },
569
- "decoratorConfig": {
570
- "api": false,
571
- "mcp": false,
572
- "cli": false
573
- },
574
- "extends": "SmrtCollection",
575
- "extendsTypeArg": "AgreementExecutionEvent",
576
- "exportName": "AgreementExecutionEventCollection",
577
- "collectionExportName": "AgreementExecutionEventCollectionCollection",
451
+ },
452
+ "updateLastError": {
453
+ "name": "updateLastError",
454
+ "async": true,
455
+ "parameters": [
456
+ {
457
+ "name": "input",
458
+ "type": "UpdateAgreementExecutionErrorInput",
459
+ "optional": false
460
+ }
461
+ ],
462
+ "returnType": "Promise<AgreementExecution>",
463
+ "isStatic": false,
464
+ "isPublic": true
465
+ },
466
+ "bindEvidenceArtifact": {
467
+ "name": "bindEvidenceArtifact",
468
+ "async": true,
469
+ "parameters": [
470
+ {
471
+ "name": "input",
472
+ "type": "BindAgreementEvidenceArtifactInput",
473
+ "optional": false
474
+ }
475
+ ],
476
+ "returnType": "Promise<AgreementExecution | null>",
477
+ "isStatic": false,
478
+ "isPublic": true
479
+ },
480
+ "findBySource": {
481
+ "name": "findBySource",
482
+ "async": true,
483
+ "parameters": [
484
+ {
485
+ "name": "sourceKind",
486
+ "type": "string",
487
+ "optional": false
488
+ },
489
+ {
490
+ "name": "sourceId",
491
+ "type": "string",
492
+ "optional": false
493
+ }
494
+ ],
495
+ "returnType": "Promise<AgreementExecution[]>",
496
+ "isStatic": false,
497
+ "isPublic": true
498
+ }
499
+ },
500
+ "decoratorConfig": {
501
+ "api": false,
502
+ "mcp": false,
503
+ "cli": false
504
+ },
505
+ "extends": "SmrtCollection",
506
+ "extendsTypeArg": "AgreementExecution",
507
+ "exportName": "AgreementExecutionCollection",
508
+ "collectionExportName": "AgreementExecutionCollectionCollection",
578
509
  "schema": {
579
- "tableName": "agreement_execution_events",
580
- "ddl": "CREATE TABLE IF NOT EXISTS \"agreement_execution_events\" (\n \"id\" UUID PRIMARY KEY NOT NULL,\n \"slug\" TEXT NOT NULL,\n \"context\" TEXT NOT NULL DEFAULT '',\n \"created_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"updated_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"tenant_id\" UUID NOT NULL,\n \"execution_id\" UUID NOT NULL,\n \"provider\" TEXT DEFAULT '',\n \"provider_event_id\" TEXT DEFAULT '',\n \"event_origin\" TEXT DEFAULT 'provider_webhook',\n \"operation_id\" TEXT DEFAULT '',\n \"dedupe_key\" TEXT NOT NULL DEFAULT '',\n \"ordering_key\" TEXT DEFAULT '',\n \"event_type\" TEXT DEFAULT '',\n \"status\" TEXT DEFAULT 'prepared',\n \"occurred_at\" TIMESTAMP,\n \"received_at\" TIMESTAMP,\n \"payload_sha256\" TEXT DEFAULT '',\n \"signer_evidence\" TEXT DEFAULT '[]',\n \"payload\" TEXT DEFAULT '{}'\n);",
510
+ "tableName": "agreement_executions",
511
+ "ddl": "CREATE TABLE IF NOT EXISTS \"agreement_executions\" (\n \"id\" UUID PRIMARY KEY NOT NULL,\n \"slug\" TEXT NOT NULL,\n \"context\" TEXT NOT NULL DEFAULT '',\n \"created_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"updated_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"tenant_id\" UUID NOT NULL,\n \"provider\" TEXT NOT NULL DEFAULT '',\n \"provider_account_ref\" TEXT DEFAULT '',\n \"credential_ref\" TEXT DEFAULT '',\n \"idempotency_key\" TEXT NOT NULL DEFAULT '',\n \"source_kind\" TEXT NOT NULL DEFAULT '',\n \"source_id\" TEXT NOT NULL DEFAULT '',\n \"source_version\" INTEGER DEFAULT 1,\n \"source_asset_id\" UUID,\n \"source_sha256\" TEXT DEFAULT '',\n \"source_size_bytes\" INTEGER DEFAULT 0,\n \"request_intent_sha256\" TEXT DEFAULT '',\n \"title\" TEXT DEFAULT '',\n \"signer_intent\" TEXT DEFAULT '[]',\n \"provider_request_id\" TEXT DEFAULT '',\n \"provider_request_key\" TEXT UNIQUE,\n \"status\" TEXT DEFAULT 'prepared',\n \"expires_at\" TIMESTAMP,\n \"cancellation_reason\" TEXT DEFAULT '',\n \"last_provider_event_at\" TIMESTAMP,\n \"last_reconciled_at\" TIMESTAMP,\n \"completed_at\" TIMESTAMP,\n \"effective_from\" TIMESTAMP,\n \"effective_to\" TIMESTAMP,\n \"supersedes_executed_agreement_id\" TEXT DEFAULT '',\n \"signed_document_asset_id\" UUID,\n \"signed_document_sha256\" TEXT DEFAULT '',\n \"signed_document_size_bytes\" INTEGER DEFAULT 0,\n \"signed_document_media_type\" TEXT DEFAULT '',\n \"signed_document_filename\" TEXT DEFAULT '',\n \"audit_trail_asset_id\" UUID,\n \"audit_trail_sha256\" TEXT DEFAULT '',\n \"audit_trail_size_bytes\" INTEGER DEFAULT 0,\n \"audit_trail_media_type\" TEXT DEFAULT '',\n \"audit_trail_filename\" TEXT DEFAULT '',\n \"attempt_count\" INTEGER DEFAULT 0,\n \"create_lease_id\" TEXT DEFAULT '',\n \"create_lease_expires_at\" TIMESTAMP,\n \"last_error\" TEXT DEFAULT '',\n \"metadata\" TEXT DEFAULT '{}'\n);",
581
512
  "columns": {
582
513
  "id": {
583
514
  "type": "UUID",
@@ -610,89 +541,227 @@
610
541
  "notNull": true,
611
542
  "unique": false
612
543
  },
613
- "execution_id": {
614
- "type": "UUID",
615
- "referenceKind": "foreignKey",
544
+ "provider": {
545
+ "type": "TEXT",
616
546
  "notNull": true,
617
547
  "unique": false,
618
- "foreignKey": {
619
- "table": "agreement_executions",
620
- "column": "id",
621
- "onDelete": "NO ACTION",
622
- "onUpdate": "CASCADE"
623
- }
548
+ "default": ""
624
549
  },
625
- "provider": {
550
+ "provider_account_ref": {
626
551
  "type": "TEXT",
627
552
  "notNull": false,
628
553
  "unique": false,
629
554
  "default": ""
630
555
  },
631
- "provider_event_id": {
556
+ "credential_ref": {
632
557
  "type": "TEXT",
633
558
  "notNull": false,
634
559
  "unique": false,
635
560
  "default": ""
636
561
  },
637
- "event_origin": {
562
+ "idempotency_key": {
563
+ "type": "TEXT",
564
+ "notNull": true,
565
+ "unique": false,
566
+ "default": ""
567
+ },
568
+ "source_kind": {
638
569
  "type": "TEXT",
570
+ "notNull": true,
571
+ "unique": false,
572
+ "default": ""
573
+ },
574
+ "source_id": {
575
+ "type": "TEXT",
576
+ "notNull": true,
577
+ "unique": false,
578
+ "default": ""
579
+ },
580
+ "source_version": {
581
+ "type": "INTEGER",
639
582
  "notNull": false,
640
583
  "unique": false,
641
- "default": "provider_webhook"
584
+ "default": 1
642
585
  },
643
- "operation_id": {
586
+ "source_asset_id": {
587
+ "type": "UUID",
588
+ "referenceKind": "crossPackageRef",
589
+ "notNull": false,
590
+ "unique": false
591
+ },
592
+ "source_sha256": {
644
593
  "type": "TEXT",
645
594
  "notNull": false,
646
595
  "unique": false,
647
596
  "default": ""
648
597
  },
649
- "dedupe_key": {
598
+ "source_size_bytes": {
599
+ "type": "INTEGER",
600
+ "notNull": false,
601
+ "unique": false,
602
+ "default": 0
603
+ },
604
+ "request_intent_sha256": {
650
605
  "type": "TEXT",
651
- "notNull": true,
606
+ "notNull": false,
652
607
  "unique": false,
653
608
  "default": ""
654
609
  },
655
- "ordering_key": {
610
+ "title": {
656
611
  "type": "TEXT",
657
612
  "notNull": false,
658
613
  "unique": false,
659
614
  "default": ""
660
615
  },
661
- "event_type": {
616
+ "signer_intent": {
617
+ "type": "TEXT",
618
+ "notNull": false,
619
+ "unique": false,
620
+ "default": "[]"
621
+ },
622
+ "provider_request_id": {
662
623
  "type": "TEXT",
663
624
  "notNull": false,
664
625
  "unique": false,
665
626
  "default": ""
666
627
  },
628
+ "provider_request_key": {
629
+ "type": "TEXT",
630
+ "notNull": false,
631
+ "unique": true
632
+ },
667
633
  "status": {
668
634
  "type": "TEXT",
669
635
  "notNull": false,
670
636
  "unique": false,
671
637
  "default": "prepared"
672
638
  },
673
- "occurred_at": {
639
+ "expires_at": {
674
640
  "type": "TIMESTAMP",
675
641
  "notNull": false,
676
642
  "unique": false
677
643
  },
678
- "received_at": {
644
+ "cancellation_reason": {
645
+ "type": "TEXT",
646
+ "notNull": false,
647
+ "unique": false,
648
+ "default": ""
649
+ },
650
+ "last_provider_event_at": {
679
651
  "type": "TIMESTAMP",
680
652
  "notNull": false,
681
653
  "unique": false
682
654
  },
683
- "payload_sha256": {
655
+ "last_reconciled_at": {
656
+ "type": "TIMESTAMP",
657
+ "notNull": false,
658
+ "unique": false
659
+ },
660
+ "completed_at": {
661
+ "type": "TIMESTAMP",
662
+ "notNull": false,
663
+ "unique": false
664
+ },
665
+ "effective_from": {
666
+ "type": "TIMESTAMP",
667
+ "notNull": false,
668
+ "unique": false
669
+ },
670
+ "effective_to": {
671
+ "type": "TIMESTAMP",
672
+ "notNull": false,
673
+ "unique": false
674
+ },
675
+ "supersedes_executed_agreement_id": {
684
676
  "type": "TEXT",
685
677
  "notNull": false,
686
678
  "unique": false,
687
679
  "default": ""
688
680
  },
689
- "signer_evidence": {
681
+ "signed_document_asset_id": {
682
+ "type": "UUID",
683
+ "referenceKind": "crossPackageRef",
684
+ "notNull": false,
685
+ "unique": false
686
+ },
687
+ "signed_document_sha256": {
690
688
  "type": "TEXT",
691
689
  "notNull": false,
692
690
  "unique": false,
693
- "default": "[]"
691
+ "default": ""
694
692
  },
695
- "payload": {
693
+ "signed_document_size_bytes": {
694
+ "type": "INTEGER",
695
+ "notNull": false,
696
+ "unique": false,
697
+ "default": 0
698
+ },
699
+ "signed_document_media_type": {
700
+ "type": "TEXT",
701
+ "notNull": false,
702
+ "unique": false,
703
+ "default": ""
704
+ },
705
+ "signed_document_filename": {
706
+ "type": "TEXT",
707
+ "notNull": false,
708
+ "unique": false,
709
+ "default": ""
710
+ },
711
+ "audit_trail_asset_id": {
712
+ "type": "UUID",
713
+ "referenceKind": "crossPackageRef",
714
+ "notNull": false,
715
+ "unique": false
716
+ },
717
+ "audit_trail_sha256": {
718
+ "type": "TEXT",
719
+ "notNull": false,
720
+ "unique": false,
721
+ "default": ""
722
+ },
723
+ "audit_trail_size_bytes": {
724
+ "type": "INTEGER",
725
+ "notNull": false,
726
+ "unique": false,
727
+ "default": 0
728
+ },
729
+ "audit_trail_media_type": {
730
+ "type": "TEXT",
731
+ "notNull": false,
732
+ "unique": false,
733
+ "default": ""
734
+ },
735
+ "audit_trail_filename": {
736
+ "type": "TEXT",
737
+ "notNull": false,
738
+ "unique": false,
739
+ "default": ""
740
+ },
741
+ "attempt_count": {
742
+ "type": "INTEGER",
743
+ "notNull": false,
744
+ "unique": false,
745
+ "default": 0
746
+ },
747
+ "create_lease_id": {
748
+ "type": "TEXT",
749
+ "notNull": false,
750
+ "unique": false,
751
+ "default": ""
752
+ },
753
+ "create_lease_expires_at": {
754
+ "type": "TIMESTAMP",
755
+ "notNull": false,
756
+ "unique": false
757
+ },
758
+ "last_error": {
759
+ "type": "TEXT",
760
+ "notNull": false,
761
+ "unique": false,
762
+ "default": ""
763
+ },
764
+ "metadata": {
696
765
  "type": "TEXT",
697
766
  "notNull": false,
698
767
  "unique": false,
@@ -701,15 +770,260 @@
701
770
  },
702
771
  "indexes": [
703
772
  {
704
- "name": "agreement_execution_events_tenant_id_dedupe_key_idx",
773
+ "name": "agreement_executions_tenant_id_idempotency_key_idx",
705
774
  "columns": [
706
775
  "tenant_id",
707
- "dedupe_key"
776
+ "idempotency_key"
708
777
  ],
709
778
  "unique": true
710
779
  },
711
780
  {
712
- "name": "agreement_execution_events_slug_context_idx",
781
+ "name": "agreement_executions_slug_context_idx",
782
+ "columns": [
783
+ "slug",
784
+ "context"
785
+ ]
786
+ },
787
+ {
788
+ "name": "agreement_executions_tenant_id_created_at_idx",
789
+ "columns": [
790
+ "tenant_id",
791
+ "created_at"
792
+ ]
793
+ },
794
+ {
795
+ "name": "agreement_executions_source_asset_id_idx",
796
+ "columns": [
797
+ "source_asset_id"
798
+ ]
799
+ },
800
+ {
801
+ "name": "agreement_executions_signed_document_asset_id_idx",
802
+ "columns": [
803
+ "signed_document_asset_id"
804
+ ]
805
+ },
806
+ {
807
+ "name": "agreement_executions_audit_trail_asset_id_idx",
808
+ "columns": [
809
+ "audit_trail_asset_id"
810
+ ]
811
+ }
812
+ ],
813
+ "version": "33a93a76"
814
+ },
815
+ "importPath": "@happyvertical/smrt-sales/agreements"
816
+ },
817
+ "@happyvertical/smrt-sales:AgreementExecutionEventCollection": {
818
+ "name": "agreementexecutioneventcollection",
819
+ "className": "AgreementExecutionEventCollection",
820
+ "qualifiedName": "@happyvertical/smrt-sales:AgreementExecutionEventCollection",
821
+ "collection": "agreementexecutionevents",
822
+ "filePath": "/home/runner/work/smrt/smrt/packages/sales/src/agreements/collections/AgreementExecutionEventCollection.ts",
823
+ "packageName": "@happyvertical/smrt-sales",
824
+ "fields": {},
825
+ "methods": {
826
+ "findByDedupeKey": {
827
+ "name": "findByDedupeKey",
828
+ "async": true,
829
+ "parameters": [
830
+ {
831
+ "name": "dedupeKey",
832
+ "type": "string",
833
+ "optional": false
834
+ }
835
+ ],
836
+ "returnType": "Promise<AgreementExecutionEvent | null>",
837
+ "isStatic": false,
838
+ "isPublic": true
839
+ },
840
+ "recordVerified": {
841
+ "name": "recordVerified",
842
+ "async": true,
843
+ "parameters": [
844
+ {
845
+ "name": "options",
846
+ "type": "VerifiedAgreementExecutionEventOptions",
847
+ "optional": false
848
+ }
849
+ ],
850
+ "returnType": "Promise<object>",
851
+ "isStatic": false,
852
+ "isPublic": true
853
+ },
854
+ "findByExecution": {
855
+ "name": "findByExecution",
856
+ "async": true,
857
+ "parameters": [
858
+ {
859
+ "name": "executionId",
860
+ "type": "string",
861
+ "optional": false
862
+ }
863
+ ],
864
+ "returnType": "Promise<AgreementExecutionEvent[]>",
865
+ "isStatic": false,
866
+ "isPublic": true
867
+ },
868
+ "findProviderEventsByExecution": {
869
+ "name": "findProviderEventsByExecution",
870
+ "async": true,
871
+ "parameters": [
872
+ {
873
+ "name": "executionId",
874
+ "type": "string",
875
+ "optional": false
876
+ }
877
+ ],
878
+ "returnType": "Promise<AgreementExecutionEvent[]>",
879
+ "isStatic": false,
880
+ "isPublic": true
881
+ }
882
+ },
883
+ "decoratorConfig": {
884
+ "api": false,
885
+ "mcp": false,
886
+ "cli": false
887
+ },
888
+ "extends": "SmrtCollection",
889
+ "extendsTypeArg": "AgreementExecutionEvent",
890
+ "exportName": "AgreementExecutionEventCollection",
891
+ "collectionExportName": "AgreementExecutionEventCollectionCollection",
892
+ "schema": {
893
+ "tableName": "agreement_execution_events",
894
+ "ddl": "CREATE TABLE IF NOT EXISTS \"agreement_execution_events\" (\n \"id\" UUID PRIMARY KEY NOT NULL,\n \"slug\" TEXT NOT NULL,\n \"context\" TEXT NOT NULL DEFAULT '',\n \"created_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"updated_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"tenant_id\" UUID NOT NULL,\n \"execution_id\" UUID NOT NULL,\n \"provider\" TEXT DEFAULT '',\n \"provider_event_id\" TEXT DEFAULT '',\n \"event_origin\" TEXT DEFAULT 'provider_webhook',\n \"operation_id\" TEXT DEFAULT '',\n \"dedupe_key\" TEXT NOT NULL DEFAULT '',\n \"ordering_key\" TEXT DEFAULT '',\n \"event_type\" TEXT DEFAULT '',\n \"status\" TEXT DEFAULT 'prepared',\n \"occurred_at\" TIMESTAMP,\n \"received_at\" TIMESTAMP,\n \"payload_sha256\" TEXT DEFAULT '',\n \"signer_evidence\" TEXT DEFAULT '[]',\n \"payload\" TEXT DEFAULT '{}'\n);",
895
+ "columns": {
896
+ "id": {
897
+ "type": "UUID",
898
+ "primaryKey": true,
899
+ "referenceKind": "id",
900
+ "notNull": true
901
+ },
902
+ "slug": {
903
+ "type": "TEXT",
904
+ "notNull": true
905
+ },
906
+ "context": {
907
+ "type": "TEXT",
908
+ "notNull": true,
909
+ "default": ""
910
+ },
911
+ "created_at": {
912
+ "type": "TIMESTAMP",
913
+ "notNull": true,
914
+ "default": "current_timestamp"
915
+ },
916
+ "updated_at": {
917
+ "type": "TIMESTAMP",
918
+ "notNull": true,
919
+ "default": "current_timestamp"
920
+ },
921
+ "tenant_id": {
922
+ "type": "UUID",
923
+ "referenceKind": "tenantId",
924
+ "notNull": true,
925
+ "unique": false
926
+ },
927
+ "execution_id": {
928
+ "type": "UUID",
929
+ "referenceKind": "foreignKey",
930
+ "notNull": true,
931
+ "unique": false,
932
+ "foreignKey": {
933
+ "table": "agreement_executions",
934
+ "column": "id",
935
+ "onDelete": "NO ACTION",
936
+ "onUpdate": "CASCADE"
937
+ }
938
+ },
939
+ "provider": {
940
+ "type": "TEXT",
941
+ "notNull": false,
942
+ "unique": false,
943
+ "default": ""
944
+ },
945
+ "provider_event_id": {
946
+ "type": "TEXT",
947
+ "notNull": false,
948
+ "unique": false,
949
+ "default": ""
950
+ },
951
+ "event_origin": {
952
+ "type": "TEXT",
953
+ "notNull": false,
954
+ "unique": false,
955
+ "default": "provider_webhook"
956
+ },
957
+ "operation_id": {
958
+ "type": "TEXT",
959
+ "notNull": false,
960
+ "unique": false,
961
+ "default": ""
962
+ },
963
+ "dedupe_key": {
964
+ "type": "TEXT",
965
+ "notNull": true,
966
+ "unique": false,
967
+ "default": ""
968
+ },
969
+ "ordering_key": {
970
+ "type": "TEXT",
971
+ "notNull": false,
972
+ "unique": false,
973
+ "default": ""
974
+ },
975
+ "event_type": {
976
+ "type": "TEXT",
977
+ "notNull": false,
978
+ "unique": false,
979
+ "default": ""
980
+ },
981
+ "status": {
982
+ "type": "TEXT",
983
+ "notNull": false,
984
+ "unique": false,
985
+ "default": "prepared"
986
+ },
987
+ "occurred_at": {
988
+ "type": "TIMESTAMP",
989
+ "notNull": false,
990
+ "unique": false
991
+ },
992
+ "received_at": {
993
+ "type": "TIMESTAMP",
994
+ "notNull": false,
995
+ "unique": false
996
+ },
997
+ "payload_sha256": {
998
+ "type": "TEXT",
999
+ "notNull": false,
1000
+ "unique": false,
1001
+ "default": ""
1002
+ },
1003
+ "signer_evidence": {
1004
+ "type": "TEXT",
1005
+ "notNull": false,
1006
+ "unique": false,
1007
+ "default": "[]"
1008
+ },
1009
+ "payload": {
1010
+ "type": "TEXT",
1011
+ "notNull": false,
1012
+ "unique": false,
1013
+ "default": "{}"
1014
+ }
1015
+ },
1016
+ "indexes": [
1017
+ {
1018
+ "name": "agreement_execution_events_tenant_id_dedupe_key_idx",
1019
+ "columns": [
1020
+ "tenant_id",
1021
+ "dedupe_key"
1022
+ ],
1023
+ "unique": true
1024
+ },
1025
+ {
1026
+ "name": "agreement_execution_events_slug_context_idx",
713
1027
  "columns": [
714
1028
  "slug",
715
1029
  "context"
@@ -827,15 +1141,549 @@
827
1141
  "get"
828
1142
  ]
829
1143
  },
830
- "cli": false
831
- },
832
- "extends": "SmrtCollection",
833
- "extendsTypeArg": "ExecutedAgreement",
834
- "exportName": "ExecutedAgreementCollection",
835
- "collectionExportName": "ExecutedAgreementCollectionCollection",
1144
+ "cli": false
1145
+ },
1146
+ "extends": "SmrtCollection",
1147
+ "extendsTypeArg": "ExecutedAgreement",
1148
+ "exportName": "ExecutedAgreementCollection",
1149
+ "collectionExportName": "ExecutedAgreementCollectionCollection",
1150
+ "schema": {
1151
+ "tableName": "executed_agreements",
1152
+ "ddl": "CREATE TABLE IF NOT EXISTS \"executed_agreements\" (\n \"id\" UUID PRIMARY KEY NOT NULL,\n \"slug\" TEXT NOT NULL,\n \"context\" TEXT NOT NULL DEFAULT '',\n \"created_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"updated_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"tenant_id\" UUID NOT NULL,\n \"execution_id\" UUID NOT NULL,\n \"source_kind\" TEXT NOT NULL DEFAULT '',\n \"source_id\" TEXT NOT NULL DEFAULT '',\n \"source_version\" INTEGER DEFAULT 1,\n \"source_asset_id\" UUID,\n \"source_sha256\" TEXT DEFAULT '',\n \"source_size_bytes\" INTEGER DEFAULT 0,\n \"signed_document_asset_id\" UUID,\n \"signed_document_sha256\" TEXT DEFAULT '',\n \"signed_document_size_bytes\" INTEGER DEFAULT 0,\n \"signed_document_media_type\" TEXT DEFAULT '',\n \"signed_document_filename\" TEXT DEFAULT '',\n \"audit_trail_asset_id\" UUID,\n \"audit_trail_sha256\" TEXT DEFAULT '',\n \"audit_trail_size_bytes\" INTEGER DEFAULT 0,\n \"audit_trail_media_type\" TEXT DEFAULT '',\n \"audit_trail_filename\" TEXT DEFAULT '',\n \"signer_evidence\" TEXT DEFAULT '[]',\n \"accepted_at\" TIMESTAMP,\n \"effective_from\" TIMESTAMP,\n \"effective_to\" TIMESTAMP,\n \"supersedes_executed_agreement_id\" UUID,\n \"metadata\" TEXT DEFAULT '{}'\n);",
1153
+ "columns": {
1154
+ "id": {
1155
+ "type": "UUID",
1156
+ "primaryKey": true,
1157
+ "referenceKind": "id",
1158
+ "notNull": true
1159
+ },
1160
+ "slug": {
1161
+ "type": "TEXT",
1162
+ "notNull": true
1163
+ },
1164
+ "context": {
1165
+ "type": "TEXT",
1166
+ "notNull": true,
1167
+ "default": ""
1168
+ },
1169
+ "created_at": {
1170
+ "type": "TIMESTAMP",
1171
+ "notNull": true,
1172
+ "default": "current_timestamp"
1173
+ },
1174
+ "updated_at": {
1175
+ "type": "TIMESTAMP",
1176
+ "notNull": true,
1177
+ "default": "current_timestamp"
1178
+ },
1179
+ "tenant_id": {
1180
+ "type": "UUID",
1181
+ "referenceKind": "tenantId",
1182
+ "notNull": true,
1183
+ "unique": false
1184
+ },
1185
+ "execution_id": {
1186
+ "type": "UUID",
1187
+ "referenceKind": "foreignKey",
1188
+ "notNull": true,
1189
+ "unique": false,
1190
+ "foreignKey": {
1191
+ "table": "agreement_executions",
1192
+ "column": "id",
1193
+ "onDelete": "CASCADE",
1194
+ "onUpdate": "CASCADE"
1195
+ }
1196
+ },
1197
+ "source_kind": {
1198
+ "type": "TEXT",
1199
+ "notNull": true,
1200
+ "unique": false,
1201
+ "default": ""
1202
+ },
1203
+ "source_id": {
1204
+ "type": "TEXT",
1205
+ "notNull": true,
1206
+ "unique": false,
1207
+ "default": ""
1208
+ },
1209
+ "source_version": {
1210
+ "type": "INTEGER",
1211
+ "notNull": false,
1212
+ "unique": false,
1213
+ "default": 1
1214
+ },
1215
+ "source_asset_id": {
1216
+ "type": "UUID",
1217
+ "referenceKind": "crossPackageRef",
1218
+ "notNull": false,
1219
+ "unique": false
1220
+ },
1221
+ "source_sha256": {
1222
+ "type": "TEXT",
1223
+ "notNull": false,
1224
+ "unique": false,
1225
+ "default": ""
1226
+ },
1227
+ "source_size_bytes": {
1228
+ "type": "INTEGER",
1229
+ "notNull": false,
1230
+ "unique": false,
1231
+ "default": 0
1232
+ },
1233
+ "signed_document_asset_id": {
1234
+ "type": "UUID",
1235
+ "referenceKind": "crossPackageRef",
1236
+ "notNull": false,
1237
+ "unique": false
1238
+ },
1239
+ "signed_document_sha256": {
1240
+ "type": "TEXT",
1241
+ "notNull": false,
1242
+ "unique": false,
1243
+ "default": ""
1244
+ },
1245
+ "signed_document_size_bytes": {
1246
+ "type": "INTEGER",
1247
+ "notNull": false,
1248
+ "unique": false,
1249
+ "default": 0
1250
+ },
1251
+ "signed_document_media_type": {
1252
+ "type": "TEXT",
1253
+ "notNull": false,
1254
+ "unique": false,
1255
+ "default": ""
1256
+ },
1257
+ "signed_document_filename": {
1258
+ "type": "TEXT",
1259
+ "notNull": false,
1260
+ "unique": false,
1261
+ "default": ""
1262
+ },
1263
+ "audit_trail_asset_id": {
1264
+ "type": "UUID",
1265
+ "referenceKind": "crossPackageRef",
1266
+ "notNull": false,
1267
+ "unique": false
1268
+ },
1269
+ "audit_trail_sha256": {
1270
+ "type": "TEXT",
1271
+ "notNull": false,
1272
+ "unique": false,
1273
+ "default": ""
1274
+ },
1275
+ "audit_trail_size_bytes": {
1276
+ "type": "INTEGER",
1277
+ "notNull": false,
1278
+ "unique": false,
1279
+ "default": 0
1280
+ },
1281
+ "audit_trail_media_type": {
1282
+ "type": "TEXT",
1283
+ "notNull": false,
1284
+ "unique": false,
1285
+ "default": ""
1286
+ },
1287
+ "audit_trail_filename": {
1288
+ "type": "TEXT",
1289
+ "notNull": false,
1290
+ "unique": false,
1291
+ "default": ""
1292
+ },
1293
+ "signer_evidence": {
1294
+ "type": "TEXT",
1295
+ "notNull": false,
1296
+ "unique": false,
1297
+ "default": "[]"
1298
+ },
1299
+ "accepted_at": {
1300
+ "type": "TIMESTAMP",
1301
+ "notNull": false,
1302
+ "unique": false
1303
+ },
1304
+ "effective_from": {
1305
+ "type": "TIMESTAMP",
1306
+ "notNull": false,
1307
+ "unique": false
1308
+ },
1309
+ "effective_to": {
1310
+ "type": "TIMESTAMP",
1311
+ "notNull": false,
1312
+ "unique": false
1313
+ },
1314
+ "supersedes_executed_agreement_id": {
1315
+ "type": "UUID",
1316
+ "referenceKind": "foreignKey",
1317
+ "notNull": false,
1318
+ "unique": false,
1319
+ "foreignKey": {
1320
+ "table": "executed_agreements",
1321
+ "column": "id",
1322
+ "onDelete": "NO ACTION",
1323
+ "onUpdate": "CASCADE"
1324
+ }
1325
+ },
1326
+ "metadata": {
1327
+ "type": "TEXT",
1328
+ "notNull": false,
1329
+ "unique": false,
1330
+ "default": "{}"
1331
+ }
1332
+ },
1333
+ "indexes": [
1334
+ {
1335
+ "name": "executed_agreements_tenant_id_execution_id_idx",
1336
+ "columns": [
1337
+ "tenant_id",
1338
+ "execution_id"
1339
+ ],
1340
+ "unique": true
1341
+ },
1342
+ {
1343
+ "name": "executed_agreements_slug_context_idx",
1344
+ "columns": [
1345
+ "slug",
1346
+ "context"
1347
+ ]
1348
+ },
1349
+ {
1350
+ "name": "executed_agreements_tenant_id_created_at_idx",
1351
+ "columns": [
1352
+ "tenant_id",
1353
+ "created_at"
1354
+ ]
1355
+ },
1356
+ {
1357
+ "name": "executed_agreements_execution_id_idx",
1358
+ "columns": [
1359
+ "execution_id"
1360
+ ]
1361
+ },
1362
+ {
1363
+ "name": "executed_agreements_source_asset_id_idx",
1364
+ "columns": [
1365
+ "source_asset_id"
1366
+ ]
1367
+ },
1368
+ {
1369
+ "name": "executed_agreements_signed_document_asset_id_idx",
1370
+ "columns": [
1371
+ "signed_document_asset_id"
1372
+ ]
1373
+ },
1374
+ {
1375
+ "name": "executed_agreements_audit_trail_asset_id_idx",
1376
+ "columns": [
1377
+ "audit_trail_asset_id"
1378
+ ]
1379
+ },
1380
+ {
1381
+ "name": "executed_agreements_supersedes_executed_agreement_id_idx",
1382
+ "columns": [
1383
+ "supersedes_executed_agreement_id"
1384
+ ]
1385
+ }
1386
+ ],
1387
+ "version": "9b3fcc48"
1388
+ },
1389
+ "importPath": "@happyvertical/smrt-sales/agreements"
1390
+ },
1391
+ "@happyvertical/smrt-sales:Agreement": {
1392
+ "name": "agreement",
1393
+ "className": "Agreement",
1394
+ "qualifiedName": "@happyvertical/smrt-sales:Agreement",
1395
+ "collection": "agreements",
1396
+ "filePath": "/home/runner/work/smrt/smrt/packages/sales/src/agreements/models/Agreement.ts",
1397
+ "packageName": "@happyvertical/smrt-sales",
1398
+ "fields": {
1399
+ "tenantId": {
1400
+ "type": "text",
1401
+ "required": false,
1402
+ "_meta": {
1403
+ "sqlType": "UUID",
1404
+ "nullable": true,
1405
+ "__tenancy": {
1406
+ "isTenantIdField": true,
1407
+ "autoFilter": true,
1408
+ "required": false,
1409
+ "autoPopulate": true,
1410
+ "nullable": true,
1411
+ "mode": "optional",
1412
+ "field": "tenantId",
1413
+ "allowSuperAdminBypass": false
1414
+ }
1415
+ }
1416
+ },
1417
+ "kind": {
1418
+ "type": "text",
1419
+ "required": true,
1420
+ "default": "",
1421
+ "_meta": {
1422
+ "required": true
1423
+ }
1424
+ },
1425
+ "partyA": {
1426
+ "type": "text",
1427
+ "required": true,
1428
+ "default": "",
1429
+ "_meta": {
1430
+ "required": true
1431
+ }
1432
+ },
1433
+ "partyB": {
1434
+ "type": "text",
1435
+ "required": true,
1436
+ "default": "",
1437
+ "_meta": {
1438
+ "required": true
1439
+ }
1440
+ },
1441
+ "version": {
1442
+ "type": "integer",
1443
+ "required": false,
1444
+ "default": 1
1445
+ },
1446
+ "status": {
1447
+ "type": "text",
1448
+ "required": false,
1449
+ "default": "draft"
1450
+ },
1451
+ "terms": {
1452
+ "type": "text",
1453
+ "required": false,
1454
+ "default": "{}"
1455
+ },
1456
+ "effectiveFrom": {
1457
+ "type": "datetime",
1458
+ "required": false
1459
+ },
1460
+ "effectiveTo": {
1461
+ "type": "datetime",
1462
+ "required": false
1463
+ },
1464
+ "executedAgreementId": {
1465
+ "type": "foreignKey",
1466
+ "required": false,
1467
+ "related": "ExecutedAgreement"
1468
+ },
1469
+ "amendmentPredecessorId": {
1470
+ "type": "foreignKey",
1471
+ "required": false,
1472
+ "related": "Agreement"
1473
+ },
1474
+ "amendmentPredecessorEnd": {
1475
+ "type": "datetime",
1476
+ "required": false
1477
+ },
1478
+ "metadata": {
1479
+ "type": "text",
1480
+ "required": false,
1481
+ "default": "{}"
1482
+ }
1483
+ },
1484
+ "methods": {
1485
+ "initialize": {
1486
+ "name": "initialize",
1487
+ "async": true,
1488
+ "parameters": [],
1489
+ "returnType": "Promise<this>",
1490
+ "isStatic": false,
1491
+ "isPublic": true
1492
+ },
1493
+ "isDraft": {
1494
+ "name": "isDraft",
1495
+ "async": false,
1496
+ "parameters": [],
1497
+ "returnType": "boolean",
1498
+ "isStatic": false,
1499
+ "isPublic": true
1500
+ },
1501
+ "isActive": {
1502
+ "name": "isActive",
1503
+ "async": false,
1504
+ "parameters": [],
1505
+ "returnType": "boolean",
1506
+ "isStatic": false,
1507
+ "isPublic": true
1508
+ },
1509
+ "isEffectiveAt": {
1510
+ "name": "isEffectiveAt",
1511
+ "async": false,
1512
+ "parameters": [
1513
+ {
1514
+ "name": "at",
1515
+ "type": "Date",
1516
+ "optional": false
1517
+ }
1518
+ ],
1519
+ "returnType": "boolean",
1520
+ "isStatic": false,
1521
+ "isPublic": true
1522
+ },
1523
+ "getPartyA": {
1524
+ "name": "getPartyA",
1525
+ "async": false,
1526
+ "parameters": [],
1527
+ "returnType": "AgreementParty | null",
1528
+ "isStatic": false,
1529
+ "isPublic": true
1530
+ },
1531
+ "getPartyB": {
1532
+ "name": "getPartyB",
1533
+ "async": false,
1534
+ "parameters": [],
1535
+ "returnType": "AgreementParty | null",
1536
+ "isStatic": false,
1537
+ "isPublic": true
1538
+ },
1539
+ "setPartyA": {
1540
+ "name": "setPartyA",
1541
+ "async": false,
1542
+ "parameters": [
1543
+ {
1544
+ "name": "party",
1545
+ "type": "AgreementParty",
1546
+ "optional": false
1547
+ }
1548
+ ],
1549
+ "returnType": "void",
1550
+ "isStatic": false,
1551
+ "isPublic": true
1552
+ },
1553
+ "setPartyB": {
1554
+ "name": "setPartyB",
1555
+ "async": false,
1556
+ "parameters": [
1557
+ {
1558
+ "name": "party",
1559
+ "type": "AgreementParty",
1560
+ "optional": false
1561
+ }
1562
+ ],
1563
+ "returnType": "void",
1564
+ "isStatic": false,
1565
+ "isPublic": true
1566
+ },
1567
+ "getTerms": {
1568
+ "name": "getTerms",
1569
+ "async": false,
1570
+ "parameters": [],
1571
+ "returnType": "Record<string, unknown>",
1572
+ "isStatic": false,
1573
+ "isPublic": true
1574
+ },
1575
+ "setTerms": {
1576
+ "name": "setTerms",
1577
+ "async": false,
1578
+ "parameters": [
1579
+ {
1580
+ "name": "terms",
1581
+ "type": "Record<string, unknown>",
1582
+ "optional": false
1583
+ }
1584
+ ],
1585
+ "returnType": "void",
1586
+ "isStatic": false,
1587
+ "isPublic": true
1588
+ },
1589
+ "activate": {
1590
+ "name": "activate",
1591
+ "async": false,
1592
+ "parameters": [],
1593
+ "returnType": "void",
1594
+ "isStatic": false,
1595
+ "isPublic": true
1596
+ },
1597
+ "supersede": {
1598
+ "name": "supersede",
1599
+ "async": false,
1600
+ "parameters": [],
1601
+ "returnType": "void",
1602
+ "isStatic": false,
1603
+ "isPublic": true
1604
+ },
1605
+ "terminate": {
1606
+ "name": "terminate",
1607
+ "async": false,
1608
+ "parameters": [
1609
+ {
1610
+ "name": "at",
1611
+ "type": "Date",
1612
+ "optional": true
1613
+ }
1614
+ ],
1615
+ "returnType": "void",
1616
+ "isStatic": false,
1617
+ "isPublic": true
1618
+ },
1619
+ "save": {
1620
+ "name": "save",
1621
+ "async": true,
1622
+ "parameters": [],
1623
+ "returnType": "Promise<this>",
1624
+ "isStatic": false,
1625
+ "isPublic": true
1626
+ },
1627
+ "refreshAfterLifecycleTransition": {
1628
+ "name": "refreshAfterLifecycleTransition",
1629
+ "async": true,
1630
+ "parameters": [],
1631
+ "returnType": "Promise<void>",
1632
+ "isStatic": false,
1633
+ "isPublic": true
1634
+ }
1635
+ },
1636
+ "decoratorConfig": {
1637
+ "conflictColumns": [
1638
+ "tenant_id",
1639
+ "kind",
1640
+ "party_a",
1641
+ "party_b",
1642
+ "version"
1643
+ ],
1644
+ "api": {
1645
+ "include": [
1646
+ "list",
1647
+ "get",
1648
+ "create"
1649
+ ]
1650
+ },
1651
+ "mcp": {
1652
+ "include": [
1653
+ "list",
1654
+ "get"
1655
+ ]
1656
+ },
1657
+ "cli": {
1658
+ "skipApiCheck": true
1659
+ },
1660
+ "tenantScoped": {
1661
+ "mode": "optional"
1662
+ }
1663
+ },
1664
+ "extends": "SmrtObject",
1665
+ "exportName": "Agreement",
1666
+ "collectionExportName": "AgreementCollection",
1667
+ "validationRules": [
1668
+ {
1669
+ "field": "kind",
1670
+ "rule": "required",
1671
+ "fieldType": "text"
1672
+ },
1673
+ {
1674
+ "field": "partyA",
1675
+ "rule": "required",
1676
+ "fieldType": "text"
1677
+ },
1678
+ {
1679
+ "field": "partyB",
1680
+ "rule": "required",
1681
+ "fieldType": "text"
1682
+ }
1683
+ ],
836
1684
  "schema": {
837
- "tableName": "executed_agreements",
838
- "ddl": "CREATE TABLE IF NOT EXISTS \"executed_agreements\" (\n \"id\" UUID PRIMARY KEY NOT NULL,\n \"slug\" TEXT NOT NULL,\n \"context\" TEXT NOT NULL DEFAULT '',\n \"created_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"updated_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"tenant_id\" UUID NOT NULL,\n \"execution_id\" UUID NOT NULL,\n \"source_kind\" TEXT NOT NULL DEFAULT '',\n \"source_id\" TEXT NOT NULL DEFAULT '',\n \"source_version\" INTEGER DEFAULT 1,\n \"source_asset_id\" UUID,\n \"source_sha256\" TEXT DEFAULT '',\n \"source_size_bytes\" INTEGER DEFAULT 0,\n \"signed_document_asset_id\" UUID,\n \"signed_document_sha256\" TEXT DEFAULT '',\n \"signed_document_size_bytes\" INTEGER DEFAULT 0,\n \"signed_document_media_type\" TEXT DEFAULT '',\n \"signed_document_filename\" TEXT DEFAULT '',\n \"audit_trail_asset_id\" UUID,\n \"audit_trail_sha256\" TEXT DEFAULT '',\n \"audit_trail_size_bytes\" INTEGER DEFAULT 0,\n \"audit_trail_media_type\" TEXT DEFAULT '',\n \"audit_trail_filename\" TEXT DEFAULT '',\n \"signer_evidence\" TEXT DEFAULT '[]',\n \"accepted_at\" TIMESTAMP,\n \"effective_from\" TIMESTAMP,\n \"effective_to\" TIMESTAMP,\n \"supersedes_executed_agreement_id\" UUID,\n \"metadata\" TEXT DEFAULT '{}'\n);",
1685
+ "tableName": "agreements",
1686
+ "ddl": "CREATE TABLE IF NOT EXISTS \"agreements\" (\n \"id\" UUID PRIMARY KEY NOT NULL,\n \"slug\" TEXT NOT NULL,\n \"context\" TEXT NOT NULL DEFAULT '',\n \"created_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"updated_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"tenant_id\" UUID,\n \"kind\" TEXT NOT NULL DEFAULT '',\n \"party_a\" TEXT NOT NULL DEFAULT '',\n \"party_b\" TEXT NOT NULL DEFAULT '',\n \"version\" INTEGER DEFAULT 1,\n \"status\" TEXT DEFAULT 'draft',\n \"terms\" TEXT DEFAULT '{}',\n \"effective_from\" TIMESTAMP,\n \"effective_to\" TIMESTAMP,\n \"executed_agreement_id\" UUID,\n \"amendment_predecessor_id\" UUID,\n \"amendment_predecessor_end\" TIMESTAMP,\n \"metadata\" TEXT DEFAULT '{}'\n);",
839
1687
  "columns": {
840
1688
  "id": {
841
1689
  "type": "UUID",
@@ -865,127 +1713,44 @@
865
1713
  "tenant_id": {
866
1714
  "type": "UUID",
867
1715
  "referenceKind": "tenantId",
868
- "notNull": true,
1716
+ "notNull": false,
869
1717
  "unique": false
870
1718
  },
871
- "execution_id": {
872
- "type": "UUID",
873
- "referenceKind": "foreignKey",
874
- "notNull": true,
875
- "unique": false,
876
- "foreignKey": {
877
- "table": "agreement_executions",
878
- "column": "id",
879
- "onDelete": "CASCADE",
880
- "onUpdate": "CASCADE"
881
- }
882
- },
883
- "source_kind": {
1719
+ "kind": {
884
1720
  "type": "TEXT",
885
1721
  "notNull": true,
886
1722
  "unique": false,
887
1723
  "default": ""
888
1724
  },
889
- "source_id": {
1725
+ "party_a": {
890
1726
  "type": "TEXT",
891
1727
  "notNull": true,
892
1728
  "unique": false,
893
1729
  "default": ""
894
1730
  },
895
- "source_version": {
896
- "type": "INTEGER",
897
- "notNull": false,
898
- "unique": false,
899
- "default": 1
900
- },
901
- "source_asset_id": {
902
- "type": "UUID",
903
- "referenceKind": "crossPackageRef",
904
- "notNull": false,
905
- "unique": false
906
- },
907
- "source_sha256": {
908
- "type": "TEXT",
909
- "notNull": false,
910
- "unique": false,
911
- "default": ""
912
- },
913
- "source_size_bytes": {
914
- "type": "INTEGER",
915
- "notNull": false,
916
- "unique": false,
917
- "default": 0
918
- },
919
- "signed_document_asset_id": {
920
- "type": "UUID",
921
- "referenceKind": "crossPackageRef",
922
- "notNull": false,
923
- "unique": false
924
- },
925
- "signed_document_sha256": {
926
- "type": "TEXT",
927
- "notNull": false,
928
- "unique": false,
929
- "default": ""
930
- },
931
- "signed_document_size_bytes": {
932
- "type": "INTEGER",
933
- "notNull": false,
934
- "unique": false,
935
- "default": 0
936
- },
937
- "signed_document_media_type": {
938
- "type": "TEXT",
939
- "notNull": false,
940
- "unique": false,
941
- "default": ""
942
- },
943
- "signed_document_filename": {
944
- "type": "TEXT",
945
- "notNull": false,
946
- "unique": false,
947
- "default": ""
948
- },
949
- "audit_trail_asset_id": {
950
- "type": "UUID",
951
- "referenceKind": "crossPackageRef",
952
- "notNull": false,
953
- "unique": false
954
- },
955
- "audit_trail_sha256": {
1731
+ "party_b": {
956
1732
  "type": "TEXT",
957
- "notNull": false,
1733
+ "notNull": true,
958
1734
  "unique": false,
959
1735
  "default": ""
960
1736
  },
961
- "audit_trail_size_bytes": {
1737
+ "version": {
962
1738
  "type": "INTEGER",
963
1739
  "notNull": false,
964
1740
  "unique": false,
965
- "default": 0
966
- },
967
- "audit_trail_media_type": {
968
- "type": "TEXT",
969
- "notNull": false,
970
- "unique": false,
971
- "default": ""
1741
+ "default": 1
972
1742
  },
973
- "audit_trail_filename": {
1743
+ "status": {
974
1744
  "type": "TEXT",
975
1745
  "notNull": false,
976
1746
  "unique": false,
977
- "default": ""
1747
+ "default": "draft"
978
1748
  },
979
- "signer_evidence": {
1749
+ "terms": {
980
1750
  "type": "TEXT",
981
1751
  "notNull": false,
982
1752
  "unique": false,
983
- "default": "[]"
984
- },
985
- "accepted_at": {
986
- "type": "TIMESTAMP",
987
- "notNull": false,
988
- "unique": false
1753
+ "default": "{}"
989
1754
  },
990
1755
  "effective_from": {
991
1756
  "type": "TIMESTAMP",
@@ -997,7 +1762,7 @@
997
1762
  "notNull": false,
998
1763
  "unique": false
999
1764
  },
1000
- "supersedes_executed_agreement_id": {
1765
+ "executed_agreement_id": {
1001
1766
  "type": "UUID",
1002
1767
  "referenceKind": "foreignKey",
1003
1768
  "notNull": false,
@@ -1009,6 +1774,23 @@
1009
1774
  "onUpdate": "CASCADE"
1010
1775
  }
1011
1776
  },
1777
+ "amendment_predecessor_id": {
1778
+ "type": "UUID",
1779
+ "referenceKind": "foreignKey",
1780
+ "notNull": false,
1781
+ "unique": false,
1782
+ "foreignKey": {
1783
+ "table": "agreements",
1784
+ "column": "id",
1785
+ "onDelete": "NO ACTION",
1786
+ "onUpdate": "CASCADE"
1787
+ }
1788
+ },
1789
+ "amendment_predecessor_end": {
1790
+ "type": "TIMESTAMP",
1791
+ "notNull": false,
1792
+ "unique": false
1793
+ },
1012
1794
  "metadata": {
1013
1795
  "type": "TEXT",
1014
1796
  "notNull": false,
@@ -1018,59 +1800,45 @@
1018
1800
  },
1019
1801
  "indexes": [
1020
1802
  {
1021
- "name": "executed_agreements_tenant_id_execution_id_idx",
1803
+ "name": "agreements_tenant_id_kind_idx",
1022
1804
  "columns": [
1023
1805
  "tenant_id",
1024
- "execution_id"
1806
+ "kind",
1807
+ "party_a",
1808
+ "party_b",
1809
+ "version"
1025
1810
  ],
1026
- "unique": true
1811
+ "unique": true,
1812
+ "nullsNotDistinct": true
1027
1813
  },
1028
1814
  {
1029
- "name": "executed_agreements_slug_context_idx",
1815
+ "name": "agreements_slug_context_idx",
1030
1816
  "columns": [
1031
1817
  "slug",
1032
1818
  "context"
1033
1819
  ]
1034
1820
  },
1035
1821
  {
1036
- "name": "executed_agreements_tenant_id_created_at_idx",
1822
+ "name": "agreements_tenant_id_created_at_idx",
1037
1823
  "columns": [
1038
1824
  "tenant_id",
1039
1825
  "created_at"
1040
1826
  ]
1041
1827
  },
1042
1828
  {
1043
- "name": "executed_agreements_execution_id_idx",
1044
- "columns": [
1045
- "execution_id"
1046
- ]
1047
- },
1048
- {
1049
- "name": "executed_agreements_source_asset_id_idx",
1050
- "columns": [
1051
- "source_asset_id"
1052
- ]
1053
- },
1054
- {
1055
- "name": "executed_agreements_signed_document_asset_id_idx",
1056
- "columns": [
1057
- "signed_document_asset_id"
1058
- ]
1059
- },
1060
- {
1061
- "name": "executed_agreements_audit_trail_asset_id_idx",
1829
+ "name": "agreements_executed_agreement_id_idx",
1062
1830
  "columns": [
1063
- "audit_trail_asset_id"
1831
+ "executed_agreement_id"
1064
1832
  ]
1065
1833
  },
1066
1834
  {
1067
- "name": "executed_agreements_supersedes_executed_agreement_id_idx",
1835
+ "name": "agreements_amendment_predecessor_id_idx",
1068
1836
  "columns": [
1069
- "supersedes_executed_agreement_id"
1837
+ "amendment_predecessor_id"
1070
1838
  ]
1071
1839
  }
1072
1840
  ],
1073
- "version": "9b3fcc48"
1841
+ "version": "b9d6d0e8"
1074
1842
  },
1075
1843
  "importPath": "@happyvertical/smrt-sales/agreements"
1076
1844
  },
@@ -3693,7 +4461,7 @@
3693
4461
  "collectionExportName": "CommissionPlanCollectionCollection",
3694
4462
  "schema": {
3695
4463
  "tableName": "commission_plans",
3696
- "ddl": "CREATE TABLE IF NOT EXISTS \"commission_plans\" (\n \"id\" UUID PRIMARY KEY NOT NULL,\n \"slug\" TEXT NOT NULL,\n \"context\" TEXT NOT NULL DEFAULT '',\n \"created_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"updated_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"tenant_id\" UUID,\n \"plan_key\" TEXT NOT NULL DEFAULT '',\n \"version\" INTEGER DEFAULT 1,\n \"name\" TEXT DEFAULT '',\n \"description\" TEXT DEFAULT '',\n \"status\" TEXT DEFAULT 'draft',\n \"effective_from\" TIMESTAMP,\n \"currency\" TEXT DEFAULT 'USD',\n \"components\" TEXT DEFAULT '[]',\n \"metadata\" TEXT DEFAULT '{}'\n);",
4464
+ "ddl": "CREATE TABLE IF NOT EXISTS \"commission_plans\" (\n \"id\" UUID PRIMARY KEY NOT NULL,\n \"slug\" TEXT NOT NULL,\n \"context\" TEXT NOT NULL DEFAULT '',\n \"created_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"updated_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"tenant_id\" UUID,\n \"plan_key\" TEXT NOT NULL DEFAULT '',\n \"version\" INTEGER DEFAULT 1,\n \"name\" TEXT DEFAULT '',\n \"description\" TEXT DEFAULT '',\n \"status\" TEXT DEFAULT 'draft',\n \"effective_from\" TIMESTAMP,\n \"effective_to\" TIMESTAMP,\n \"currency\" TEXT DEFAULT 'USD',\n \"components\" TEXT DEFAULT '[]',\n \"steps\" TEXT DEFAULT '[]',\n \"remainder_sink\" TEXT DEFAULT '{}',\n \"application_fee_offset_recipient\" TEXT DEFAULT '{}',\n \"metadata\" TEXT DEFAULT '{}'\n);",
3697
4465
  "columns": {
3698
4466
  "id": {
3699
4467
  "type": "UUID",
@@ -3761,6 +4529,11 @@
3761
4529
  "notNull": false,
3762
4530
  "unique": false
3763
4531
  },
4532
+ "effective_to": {
4533
+ "type": "TIMESTAMP",
4534
+ "notNull": false,
4535
+ "unique": false
4536
+ },
3764
4537
  "currency": {
3765
4538
  "type": "TEXT",
3766
4539
  "notNull": false,
@@ -3773,6 +4546,24 @@
3773
4546
  "unique": false,
3774
4547
  "default": "[]"
3775
4548
  },
4549
+ "steps": {
4550
+ "type": "TEXT",
4551
+ "notNull": false,
4552
+ "unique": false,
4553
+ "default": "[]"
4554
+ },
4555
+ "remainder_sink": {
4556
+ "type": "TEXT",
4557
+ "notNull": false,
4558
+ "unique": false,
4559
+ "default": "{}"
4560
+ },
4561
+ "application_fee_offset_recipient": {
4562
+ "type": "TEXT",
4563
+ "notNull": false,
4564
+ "unique": false,
4565
+ "default": "{}"
4566
+ },
3776
4567
  "metadata": {
3777
4568
  "type": "TEXT",
3778
4569
  "notNull": false,
@@ -3806,7 +4597,7 @@
3806
4597
  ]
3807
4598
  }
3808
4599
  ],
3809
- "version": "19b92dec"
4600
+ "version": "2fe6eb4a"
3810
4601
  },
3811
4602
  "importPath": "@happyvertical/smrt-sales/commissions"
3812
4603
  },
@@ -6063,6 +6854,10 @@
6063
6854
  "type": "datetime",
6064
6855
  "required": false
6065
6856
  },
6857
+ "effectiveTo": {
6858
+ "type": "datetime",
6859
+ "required": false
6860
+ },
6066
6861
  "currency": {
6067
6862
  "type": "text",
6068
6863
  "required": false,
@@ -6073,6 +6868,21 @@
6073
6868
  "required": false,
6074
6869
  "default": "[]"
6075
6870
  },
6871
+ "steps": {
6872
+ "type": "text",
6873
+ "required": false,
6874
+ "default": "[]"
6875
+ },
6876
+ "remainderSink": {
6877
+ "type": "text",
6878
+ "required": false,
6879
+ "default": "{}"
6880
+ },
6881
+ "applicationFeeOffsetRecipient": {
6882
+ "type": "text",
6883
+ "required": false,
6884
+ "default": "{}"
6885
+ },
6076
6886
  "metadata": {
6077
6887
  "type": "text",
6078
6888
  "required": false,
@@ -6126,6 +6936,58 @@
6126
6936
  "isStatic": false,
6127
6937
  "isPublic": true
6128
6938
  },
6939
+ "getSteps": {
6940
+ "name": "getSteps",
6941
+ "async": false,
6942
+ "parameters": [],
6943
+ "returnType": "WaterfallStep[]",
6944
+ "isStatic": false,
6945
+ "isPublic": true
6946
+ },
6947
+ "setSteps": {
6948
+ "name": "setSteps",
6949
+ "async": false,
6950
+ "parameters": [
6951
+ {
6952
+ "name": "steps",
6953
+ "type": "WaterfallStep[]",
6954
+ "optional": false
6955
+ }
6956
+ ],
6957
+ "returnType": "void",
6958
+ "isStatic": false,
6959
+ "isPublic": true
6960
+ },
6961
+ "getRemainderSink": {
6962
+ "name": "getRemainderSink",
6963
+ "async": false,
6964
+ "parameters": [],
6965
+ "returnType": "WaterfallRecipientDescriptor | null",
6966
+ "isStatic": false,
6967
+ "isPublic": true
6968
+ },
6969
+ "setRemainderSink": {
6970
+ "name": "setRemainderSink",
6971
+ "async": false,
6972
+ "parameters": [
6973
+ {
6974
+ "name": "sink",
6975
+ "type": "WaterfallRecipientDescriptor",
6976
+ "optional": false
6977
+ }
6978
+ ],
6979
+ "returnType": "void",
6980
+ "isStatic": false,
6981
+ "isPublic": true
6982
+ },
6983
+ "getWaterfallPlan": {
6984
+ "name": "getWaterfallPlan",
6985
+ "async": false,
6986
+ "parameters": [],
6987
+ "returnType": "WaterfallPlan | null",
6988
+ "isStatic": false,
6989
+ "isPublic": true
6990
+ },
6129
6991
  "getMetadata": {
6130
6992
  "name": "getMetadata",
6131
6993
  "async": false,
@@ -6220,7 +7082,7 @@
6220
7082
  ],
6221
7083
  "schema": {
6222
7084
  "tableName": "commission_plans",
6223
- "ddl": "CREATE TABLE IF NOT EXISTS \"commission_plans\" (\n \"id\" UUID PRIMARY KEY NOT NULL,\n \"slug\" TEXT NOT NULL,\n \"context\" TEXT NOT NULL DEFAULT '',\n \"created_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"updated_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"tenant_id\" UUID,\n \"plan_key\" TEXT NOT NULL DEFAULT '',\n \"version\" INTEGER DEFAULT 1,\n \"name\" TEXT DEFAULT '',\n \"description\" TEXT DEFAULT '',\n \"status\" TEXT DEFAULT 'draft',\n \"effective_from\" TIMESTAMP,\n \"currency\" TEXT DEFAULT 'USD',\n \"components\" TEXT DEFAULT '[]',\n \"metadata\" TEXT DEFAULT '{}'\n);",
7085
+ "ddl": "CREATE TABLE IF NOT EXISTS \"commission_plans\" (\n \"id\" UUID PRIMARY KEY NOT NULL,\n \"slug\" TEXT NOT NULL,\n \"context\" TEXT NOT NULL DEFAULT '',\n \"created_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"updated_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"tenant_id\" UUID,\n \"plan_key\" TEXT NOT NULL DEFAULT '',\n \"version\" INTEGER DEFAULT 1,\n \"name\" TEXT DEFAULT '',\n \"description\" TEXT DEFAULT '',\n \"status\" TEXT DEFAULT 'draft',\n \"effective_from\" TIMESTAMP,\n \"effective_to\" TIMESTAMP,\n \"currency\" TEXT DEFAULT 'USD',\n \"components\" TEXT DEFAULT '[]',\n \"steps\" TEXT DEFAULT '[]',\n \"remainder_sink\" TEXT DEFAULT '{}',\n \"application_fee_offset_recipient\" TEXT DEFAULT '{}',\n \"metadata\" TEXT DEFAULT '{}'\n);",
6224
7086
  "columns": {
6225
7087
  "id": {
6226
7088
  "type": "UUID",
@@ -6288,6 +7150,11 @@
6288
7150
  "notNull": false,
6289
7151
  "unique": false
6290
7152
  },
7153
+ "effective_to": {
7154
+ "type": "TIMESTAMP",
7155
+ "notNull": false,
7156
+ "unique": false
7157
+ },
6291
7158
  "currency": {
6292
7159
  "type": "TEXT",
6293
7160
  "notNull": false,
@@ -6300,6 +7167,24 @@
6300
7167
  "unique": false,
6301
7168
  "default": "[]"
6302
7169
  },
7170
+ "steps": {
7171
+ "type": "TEXT",
7172
+ "notNull": false,
7173
+ "unique": false,
7174
+ "default": "[]"
7175
+ },
7176
+ "remainder_sink": {
7177
+ "type": "TEXT",
7178
+ "notNull": false,
7179
+ "unique": false,
7180
+ "default": "{}"
7181
+ },
7182
+ "application_fee_offset_recipient": {
7183
+ "type": "TEXT",
7184
+ "notNull": false,
7185
+ "unique": false,
7186
+ "default": "{}"
7187
+ },
6303
7188
  "metadata": {
6304
7189
  "type": "TEXT",
6305
7190
  "notNull": false,
@@ -6333,7 +7218,7 @@
6333
7218
  ]
6334
7219
  }
6335
7220
  ],
6336
- "version": "19b92dec"
7221
+ "version": "2fe6eb4a"
6337
7222
  },
6338
7223
  "importPath": "@happyvertical/smrt-sales/commissions"
6339
7224
  },