@voyantjs/legal 0.1.0

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 (36) hide show
  1. package/LICENSE +109 -0
  2. package/README.md +60 -0
  3. package/dist/contracts/index.d.ts +13 -0
  4. package/dist/contracts/index.d.ts.map +1 -0
  5. package/dist/contracts/index.js +19 -0
  6. package/dist/contracts/routes.d.ts +1297 -0
  7. package/dist/contracts/routes.d.ts.map +1 -0
  8. package/dist/contracts/routes.js +224 -0
  9. package/dist/contracts/schema.d.ts +1531 -0
  10. package/dist/contracts/schema.d.ts.map +1 -0
  11. package/dist/contracts/schema.js +227 -0
  12. package/dist/contracts/service.d.ts +1753 -0
  13. package/dist/contracts/service.d.ts.map +1 -0
  14. package/dist/contracts/service.js +570 -0
  15. package/dist/contracts/validation.d.ts +274 -0
  16. package/dist/contracts/validation.d.ts.map +1 -0
  17. package/dist/contracts/validation.js +125 -0
  18. package/dist/index.d.ts +14 -0
  19. package/dist/index.d.ts.map +1 -0
  20. package/dist/index.js +26 -0
  21. package/dist/policies/index.d.ts +16 -0
  22. package/dist/policies/index.d.ts.map +1 -0
  23. package/dist/policies/index.js +26 -0
  24. package/dist/policies/routes.d.ts +916 -0
  25. package/dist/policies/routes.d.ts.map +1 -0
  26. package/dist/policies/routes.js +162 -0
  27. package/dist/policies/schema.d.ts +1176 -0
  28. package/dist/policies/schema.d.ts.map +1 -0
  29. package/dist/policies/schema.js +189 -0
  30. package/dist/policies/service.d.ts +1384 -0
  31. package/dist/policies/service.d.ts.map +1 -0
  32. package/dist/policies/service.js +438 -0
  33. package/dist/policies/validation.d.ts +273 -0
  34. package/dist/policies/validation.d.ts.map +1 -0
  35. package/dist/policies/validation.js +140 -0
  36. package/package.json +83 -0
@@ -0,0 +1,1753 @@
1
+ import type { PostgresJsDatabase } from "drizzle-orm/postgres-js";
2
+ import type { z } from "zod";
3
+ import type { contractListQuerySchema, contractTemplateListQuerySchema, insertContractAttachmentSchema, insertContractNumberSeriesSchema, insertContractSchema, insertContractSignatureSchema, insertContractTemplateSchema, insertContractTemplateVersionSchema, renderTemplateInputSchema, updateContractAttachmentSchema, updateContractNumberSeriesSchema, updateContractSchema, updateContractTemplateSchema } from "./validation.js";
4
+ type ContractListQuery = z.infer<typeof contractListQuerySchema>;
5
+ type ContractTemplateListQuery = z.infer<typeof contractTemplateListQuerySchema>;
6
+ type CreateContractTemplateInput = z.infer<typeof insertContractTemplateSchema>;
7
+ type UpdateContractTemplateInput = z.infer<typeof updateContractTemplateSchema>;
8
+ type CreateContractTemplateVersionInput = z.infer<typeof insertContractTemplateVersionSchema>;
9
+ type CreateContractNumberSeriesInput = z.infer<typeof insertContractNumberSeriesSchema>;
10
+ type UpdateContractNumberSeriesInput = z.infer<typeof updateContractNumberSeriesSchema>;
11
+ type CreateContractInput = z.infer<typeof insertContractSchema>;
12
+ type UpdateContractInput = z.infer<typeof updateContractSchema>;
13
+ type CreateContractSignatureInput = z.infer<typeof insertContractSignatureSchema>;
14
+ type CreateContractAttachmentInput = z.infer<typeof insertContractAttachmentSchema>;
15
+ type UpdateContractAttachmentInput = z.infer<typeof updateContractAttachmentSchema>;
16
+ type RenderTemplateInput = z.infer<typeof renderTemplateInputSchema>;
17
+ /**
18
+ * Substitute variables in a template body. Supports:
19
+ * - markdown / html / plain text: mustache replacement `{{path.to.value}}`
20
+ * - lexical_json: walks the AST, rewriting text nodes only
21
+ */
22
+ export declare function renderTemplate(body: string, bodyFormat: "markdown" | "html" | "lexical_json", variables: Record<string, unknown>): string;
23
+ /**
24
+ * Validate variable values against a template's variableSchema (JSON object
25
+ * shape describing required fields). Returns a list of issues; empty array
26
+ * means valid.
27
+ */
28
+ export declare function validateTemplateVariables(variableSchema: unknown, values: Record<string, unknown>): string[];
29
+ /**
30
+ * Transactionally allocate the next sequence number for a series. Honors the
31
+ * reset strategy (never/annual/monthly). Uses SELECT ... FOR UPDATE to avoid
32
+ * concurrent-increment races.
33
+ */
34
+ export declare function allocateContractNumber(db: PostgresJsDatabase, seriesId: string): Promise<{
35
+ number: string;
36
+ sequence: number;
37
+ } | null>;
38
+ export declare const contractsService: {
39
+ listTemplates(db: PostgresJsDatabase, query: ContractTemplateListQuery): Promise<{
40
+ data: {
41
+ id: string;
42
+ name: string;
43
+ slug: string;
44
+ scope: "customer" | "partner" | "supplier" | "other" | "channel";
45
+ language: string;
46
+ description: string | null;
47
+ bodyFormat: "markdown" | "html" | "lexical_json";
48
+ body: string;
49
+ variableSchema: unknown;
50
+ currentVersionId: string | null;
51
+ active: boolean;
52
+ createdAt: Date;
53
+ updatedAt: Date;
54
+ }[];
55
+ total: number;
56
+ limit: number;
57
+ offset: number;
58
+ }>;
59
+ getTemplateById(db: PostgresJsDatabase, id: string): Promise<{
60
+ id: string;
61
+ name: string;
62
+ slug: string;
63
+ scope: "customer" | "partner" | "supplier" | "other" | "channel";
64
+ language: string;
65
+ description: string | null;
66
+ bodyFormat: "markdown" | "html" | "lexical_json";
67
+ body: string;
68
+ variableSchema: unknown;
69
+ currentVersionId: string | null;
70
+ active: boolean;
71
+ createdAt: Date;
72
+ updatedAt: Date;
73
+ } | null>;
74
+ createTemplate(db: PostgresJsDatabase, data: CreateContractTemplateInput): Promise<{
75
+ id: string;
76
+ name: string;
77
+ active: boolean;
78
+ createdAt: Date;
79
+ updatedAt: Date;
80
+ description: string | null;
81
+ slug: string;
82
+ scope: "customer" | "partner" | "supplier" | "other" | "channel";
83
+ language: string;
84
+ bodyFormat: "markdown" | "html" | "lexical_json";
85
+ body: string;
86
+ variableSchema: unknown;
87
+ currentVersionId: string | null;
88
+ } | null>;
89
+ updateTemplate(db: PostgresJsDatabase, id: string, data: UpdateContractTemplateInput): Promise<{
90
+ id: string;
91
+ name: string;
92
+ slug: string;
93
+ scope: "customer" | "partner" | "supplier" | "other" | "channel";
94
+ language: string;
95
+ description: string | null;
96
+ bodyFormat: "markdown" | "html" | "lexical_json";
97
+ body: string;
98
+ variableSchema: unknown;
99
+ currentVersionId: string | null;
100
+ active: boolean;
101
+ createdAt: Date;
102
+ updatedAt: Date;
103
+ } | null>;
104
+ deleteTemplate(db: PostgresJsDatabase, id: string): Promise<{
105
+ id: string;
106
+ } | null>;
107
+ listTemplateVersions(db: PostgresJsDatabase, templateId: string): Omit<import("drizzle-orm/pg-core").PgSelectBase<"contract_template_versions", {
108
+ id: import("drizzle-orm/pg-core").PgColumn<{
109
+ name: string;
110
+ tableName: "contract_template_versions";
111
+ dataType: "string";
112
+ columnType: "PgText";
113
+ data: string;
114
+ driverParam: string;
115
+ notNull: true;
116
+ hasDefault: true;
117
+ isPrimaryKey: true;
118
+ isAutoincrement: false;
119
+ hasRuntimeDefault: true;
120
+ enumValues: [string, ...string[]];
121
+ baseColumn: never;
122
+ identity: undefined;
123
+ generated: undefined;
124
+ }, {}, {}>;
125
+ templateId: import("drizzle-orm/pg-core").PgColumn<{
126
+ name: string;
127
+ tableName: "contract_template_versions";
128
+ dataType: "string";
129
+ columnType: "PgText";
130
+ data: string;
131
+ driverParam: string;
132
+ notNull: true;
133
+ hasDefault: false;
134
+ isPrimaryKey: false;
135
+ isAutoincrement: false;
136
+ hasRuntimeDefault: false;
137
+ enumValues: [string, ...string[]];
138
+ baseColumn: never;
139
+ identity: undefined;
140
+ generated: undefined;
141
+ }, {}, {}>;
142
+ version: import("drizzle-orm/pg-core").PgColumn<{
143
+ name: "version";
144
+ tableName: "contract_template_versions";
145
+ dataType: "number";
146
+ columnType: "PgInteger";
147
+ data: number;
148
+ driverParam: string | number;
149
+ notNull: true;
150
+ hasDefault: false;
151
+ isPrimaryKey: false;
152
+ isAutoincrement: false;
153
+ hasRuntimeDefault: false;
154
+ enumValues: undefined;
155
+ baseColumn: never;
156
+ identity: undefined;
157
+ generated: undefined;
158
+ }, {}, {}>;
159
+ bodyFormat: import("drizzle-orm/pg-core").PgColumn<{
160
+ name: "body_format";
161
+ tableName: "contract_template_versions";
162
+ dataType: "string";
163
+ columnType: "PgEnumColumn";
164
+ data: "markdown" | "html" | "lexical_json";
165
+ driverParam: string;
166
+ notNull: true;
167
+ hasDefault: true;
168
+ isPrimaryKey: false;
169
+ isAutoincrement: false;
170
+ hasRuntimeDefault: false;
171
+ enumValues: ["markdown", "html", "lexical_json"];
172
+ baseColumn: never;
173
+ identity: undefined;
174
+ generated: undefined;
175
+ }, {}, {}>;
176
+ body: import("drizzle-orm/pg-core").PgColumn<{
177
+ name: "body";
178
+ tableName: "contract_template_versions";
179
+ dataType: "string";
180
+ columnType: "PgText";
181
+ data: string;
182
+ driverParam: string;
183
+ notNull: true;
184
+ hasDefault: false;
185
+ isPrimaryKey: false;
186
+ isAutoincrement: false;
187
+ hasRuntimeDefault: false;
188
+ enumValues: [string, ...string[]];
189
+ baseColumn: never;
190
+ identity: undefined;
191
+ generated: undefined;
192
+ }, {}, {}>;
193
+ variableSchema: import("drizzle-orm/pg-core").PgColumn<{
194
+ name: "variable_schema";
195
+ tableName: "contract_template_versions";
196
+ dataType: "json";
197
+ columnType: "PgJsonb";
198
+ data: unknown;
199
+ driverParam: unknown;
200
+ notNull: false;
201
+ hasDefault: false;
202
+ isPrimaryKey: false;
203
+ isAutoincrement: false;
204
+ hasRuntimeDefault: false;
205
+ enumValues: undefined;
206
+ baseColumn: never;
207
+ identity: undefined;
208
+ generated: undefined;
209
+ }, {}, {}>;
210
+ changelog: import("drizzle-orm/pg-core").PgColumn<{
211
+ name: "changelog";
212
+ tableName: "contract_template_versions";
213
+ dataType: "string";
214
+ columnType: "PgText";
215
+ data: string;
216
+ driverParam: string;
217
+ notNull: false;
218
+ hasDefault: false;
219
+ isPrimaryKey: false;
220
+ isAutoincrement: false;
221
+ hasRuntimeDefault: false;
222
+ enumValues: [string, ...string[]];
223
+ baseColumn: never;
224
+ identity: undefined;
225
+ generated: undefined;
226
+ }, {}, {}>;
227
+ createdBy: import("drizzle-orm/pg-core").PgColumn<{
228
+ name: "created_by";
229
+ tableName: "contract_template_versions";
230
+ dataType: "string";
231
+ columnType: "PgText";
232
+ data: string;
233
+ driverParam: string;
234
+ notNull: false;
235
+ hasDefault: false;
236
+ isPrimaryKey: false;
237
+ isAutoincrement: false;
238
+ hasRuntimeDefault: false;
239
+ enumValues: [string, ...string[]];
240
+ baseColumn: never;
241
+ identity: undefined;
242
+ generated: undefined;
243
+ }, {}, {}>;
244
+ createdAt: import("drizzle-orm/pg-core").PgColumn<{
245
+ name: "created_at";
246
+ tableName: "contract_template_versions";
247
+ dataType: "date";
248
+ columnType: "PgTimestamp";
249
+ data: Date;
250
+ driverParam: string;
251
+ notNull: true;
252
+ hasDefault: true;
253
+ isPrimaryKey: false;
254
+ isAutoincrement: false;
255
+ hasRuntimeDefault: false;
256
+ enumValues: undefined;
257
+ baseColumn: never;
258
+ identity: undefined;
259
+ generated: undefined;
260
+ }, {}, {}>;
261
+ }, "single", Record<"contract_template_versions", "not-null">, false, "where" | "orderBy", {
262
+ id: string;
263
+ templateId: string;
264
+ version: number;
265
+ bodyFormat: "markdown" | "html" | "lexical_json";
266
+ body: string;
267
+ variableSchema: unknown;
268
+ changelog: string | null;
269
+ createdBy: string | null;
270
+ createdAt: Date;
271
+ }[], {
272
+ id: import("drizzle-orm/pg-core").PgColumn<{
273
+ name: string;
274
+ tableName: "contract_template_versions";
275
+ dataType: "string";
276
+ columnType: "PgText";
277
+ data: string;
278
+ driverParam: string;
279
+ notNull: true;
280
+ hasDefault: true;
281
+ isPrimaryKey: true;
282
+ isAutoincrement: false;
283
+ hasRuntimeDefault: true;
284
+ enumValues: [string, ...string[]];
285
+ baseColumn: never;
286
+ identity: undefined;
287
+ generated: undefined;
288
+ }, {}, {}>;
289
+ templateId: import("drizzle-orm/pg-core").PgColumn<{
290
+ name: string;
291
+ tableName: "contract_template_versions";
292
+ dataType: "string";
293
+ columnType: "PgText";
294
+ data: string;
295
+ driverParam: string;
296
+ notNull: true;
297
+ hasDefault: false;
298
+ isPrimaryKey: false;
299
+ isAutoincrement: false;
300
+ hasRuntimeDefault: false;
301
+ enumValues: [string, ...string[]];
302
+ baseColumn: never;
303
+ identity: undefined;
304
+ generated: undefined;
305
+ }, {}, {}>;
306
+ version: import("drizzle-orm/pg-core").PgColumn<{
307
+ name: "version";
308
+ tableName: "contract_template_versions";
309
+ dataType: "number";
310
+ columnType: "PgInteger";
311
+ data: number;
312
+ driverParam: string | number;
313
+ notNull: true;
314
+ hasDefault: false;
315
+ isPrimaryKey: false;
316
+ isAutoincrement: false;
317
+ hasRuntimeDefault: false;
318
+ enumValues: undefined;
319
+ baseColumn: never;
320
+ identity: undefined;
321
+ generated: undefined;
322
+ }, {}, {}>;
323
+ bodyFormat: import("drizzle-orm/pg-core").PgColumn<{
324
+ name: "body_format";
325
+ tableName: "contract_template_versions";
326
+ dataType: "string";
327
+ columnType: "PgEnumColumn";
328
+ data: "markdown" | "html" | "lexical_json";
329
+ driverParam: string;
330
+ notNull: true;
331
+ hasDefault: true;
332
+ isPrimaryKey: false;
333
+ isAutoincrement: false;
334
+ hasRuntimeDefault: false;
335
+ enumValues: ["markdown", "html", "lexical_json"];
336
+ baseColumn: never;
337
+ identity: undefined;
338
+ generated: undefined;
339
+ }, {}, {}>;
340
+ body: import("drizzle-orm/pg-core").PgColumn<{
341
+ name: "body";
342
+ tableName: "contract_template_versions";
343
+ dataType: "string";
344
+ columnType: "PgText";
345
+ data: string;
346
+ driverParam: string;
347
+ notNull: true;
348
+ hasDefault: false;
349
+ isPrimaryKey: false;
350
+ isAutoincrement: false;
351
+ hasRuntimeDefault: false;
352
+ enumValues: [string, ...string[]];
353
+ baseColumn: never;
354
+ identity: undefined;
355
+ generated: undefined;
356
+ }, {}, {}>;
357
+ variableSchema: import("drizzle-orm/pg-core").PgColumn<{
358
+ name: "variable_schema";
359
+ tableName: "contract_template_versions";
360
+ dataType: "json";
361
+ columnType: "PgJsonb";
362
+ data: unknown;
363
+ driverParam: unknown;
364
+ notNull: false;
365
+ hasDefault: false;
366
+ isPrimaryKey: false;
367
+ isAutoincrement: false;
368
+ hasRuntimeDefault: false;
369
+ enumValues: undefined;
370
+ baseColumn: never;
371
+ identity: undefined;
372
+ generated: undefined;
373
+ }, {}, {}>;
374
+ changelog: import("drizzle-orm/pg-core").PgColumn<{
375
+ name: "changelog";
376
+ tableName: "contract_template_versions";
377
+ dataType: "string";
378
+ columnType: "PgText";
379
+ data: string;
380
+ driverParam: string;
381
+ notNull: false;
382
+ hasDefault: false;
383
+ isPrimaryKey: false;
384
+ isAutoincrement: false;
385
+ hasRuntimeDefault: false;
386
+ enumValues: [string, ...string[]];
387
+ baseColumn: never;
388
+ identity: undefined;
389
+ generated: undefined;
390
+ }, {}, {}>;
391
+ createdBy: import("drizzle-orm/pg-core").PgColumn<{
392
+ name: "created_by";
393
+ tableName: "contract_template_versions";
394
+ dataType: "string";
395
+ columnType: "PgText";
396
+ data: string;
397
+ driverParam: string;
398
+ notNull: false;
399
+ hasDefault: false;
400
+ isPrimaryKey: false;
401
+ isAutoincrement: false;
402
+ hasRuntimeDefault: false;
403
+ enumValues: [string, ...string[]];
404
+ baseColumn: never;
405
+ identity: undefined;
406
+ generated: undefined;
407
+ }, {}, {}>;
408
+ createdAt: import("drizzle-orm/pg-core").PgColumn<{
409
+ name: "created_at";
410
+ tableName: "contract_template_versions";
411
+ dataType: "date";
412
+ columnType: "PgTimestamp";
413
+ data: Date;
414
+ driverParam: string;
415
+ notNull: true;
416
+ hasDefault: true;
417
+ isPrimaryKey: false;
418
+ isAutoincrement: false;
419
+ hasRuntimeDefault: false;
420
+ enumValues: undefined;
421
+ baseColumn: never;
422
+ identity: undefined;
423
+ generated: undefined;
424
+ }, {}, {}>;
425
+ }>, "where" | "orderBy">;
426
+ getTemplateVersionById(db: PostgresJsDatabase, id: string): Promise<{
427
+ id: string;
428
+ templateId: string;
429
+ version: number;
430
+ bodyFormat: "markdown" | "html" | "lexical_json";
431
+ body: string;
432
+ variableSchema: unknown;
433
+ changelog: string | null;
434
+ createdBy: string | null;
435
+ createdAt: Date;
436
+ } | null>;
437
+ createTemplateVersion(db: PostgresJsDatabase, templateId: string, data: CreateContractTemplateVersionInput): Promise<{
438
+ id: string;
439
+ createdAt: Date;
440
+ bodyFormat: "markdown" | "html" | "lexical_json";
441
+ body: string;
442
+ variableSchema: unknown;
443
+ templateId: string;
444
+ version: number;
445
+ changelog: string | null;
446
+ createdBy: string | null;
447
+ } | null>;
448
+ listSeries(db: PostgresJsDatabase): Promise<{
449
+ id: string;
450
+ code: string;
451
+ name: string;
452
+ prefix: string;
453
+ separator: string;
454
+ padLength: number;
455
+ currentSequence: number;
456
+ resetStrategy: "never" | "annual" | "monthly";
457
+ resetAt: Date | null;
458
+ scope: "customer" | "partner" | "supplier" | "other" | "channel";
459
+ active: boolean;
460
+ createdAt: Date;
461
+ updatedAt: Date;
462
+ }[]>;
463
+ getSeriesById(db: PostgresJsDatabase, id: string): Promise<{
464
+ id: string;
465
+ code: string;
466
+ name: string;
467
+ prefix: string;
468
+ separator: string;
469
+ padLength: number;
470
+ currentSequence: number;
471
+ resetStrategy: "never" | "annual" | "monthly";
472
+ resetAt: Date | null;
473
+ scope: "customer" | "partner" | "supplier" | "other" | "channel";
474
+ active: boolean;
475
+ createdAt: Date;
476
+ updatedAt: Date;
477
+ } | null>;
478
+ createSeries(db: PostgresJsDatabase, data: CreateContractNumberSeriesInput): Promise<{
479
+ id: string;
480
+ name: string;
481
+ active: boolean;
482
+ createdAt: Date;
483
+ updatedAt: Date;
484
+ code: string;
485
+ scope: "customer" | "partner" | "supplier" | "other" | "channel";
486
+ prefix: string;
487
+ separator: string;
488
+ padLength: number;
489
+ currentSequence: number;
490
+ resetStrategy: "never" | "annual" | "monthly";
491
+ resetAt: Date | null;
492
+ } | null>;
493
+ updateSeries(db: PostgresJsDatabase, id: string, data: UpdateContractNumberSeriesInput): Promise<{
494
+ id: string;
495
+ code: string;
496
+ name: string;
497
+ prefix: string;
498
+ separator: string;
499
+ padLength: number;
500
+ currentSequence: number;
501
+ resetStrategy: "never" | "annual" | "monthly";
502
+ resetAt: Date | null;
503
+ scope: "customer" | "partner" | "supplier" | "other" | "channel";
504
+ active: boolean;
505
+ createdAt: Date;
506
+ updatedAt: Date;
507
+ } | null>;
508
+ deleteSeries(db: PostgresJsDatabase, id: string): Promise<{
509
+ id: string;
510
+ } | null>;
511
+ listContracts(db: PostgresJsDatabase, query: ContractListQuery): Promise<{
512
+ data: {
513
+ id: string;
514
+ contractNumber: string | null;
515
+ scope: "customer" | "partner" | "supplier" | "other" | "channel";
516
+ status: "draft" | "sent" | "expired" | "issued" | "signed" | "executed" | "void";
517
+ title: string;
518
+ templateVersionId: string | null;
519
+ seriesId: string | null;
520
+ personId: string | null;
521
+ organizationId: string | null;
522
+ supplierId: string | null;
523
+ channelId: string | null;
524
+ bookingId: string | null;
525
+ orderId: string | null;
526
+ issuedAt: Date | null;
527
+ sentAt: Date | null;
528
+ executedAt: Date | null;
529
+ expiresAt: Date | null;
530
+ voidedAt: Date | null;
531
+ language: string;
532
+ renderedBodyFormat: "markdown" | "html" | "lexical_json";
533
+ renderedBody: string | null;
534
+ variables: unknown;
535
+ metadata: unknown;
536
+ createdAt: Date;
537
+ updatedAt: Date;
538
+ }[];
539
+ total: number;
540
+ limit: number;
541
+ offset: number;
542
+ }>;
543
+ getContractById(db: PostgresJsDatabase, id: string): Promise<{
544
+ id: string;
545
+ contractNumber: string | null;
546
+ scope: "customer" | "partner" | "supplier" | "other" | "channel";
547
+ status: "draft" | "sent" | "expired" | "issued" | "signed" | "executed" | "void";
548
+ title: string;
549
+ templateVersionId: string | null;
550
+ seriesId: string | null;
551
+ personId: string | null;
552
+ organizationId: string | null;
553
+ supplierId: string | null;
554
+ channelId: string | null;
555
+ bookingId: string | null;
556
+ orderId: string | null;
557
+ issuedAt: Date | null;
558
+ sentAt: Date | null;
559
+ executedAt: Date | null;
560
+ expiresAt: Date | null;
561
+ voidedAt: Date | null;
562
+ language: string;
563
+ renderedBodyFormat: "markdown" | "html" | "lexical_json";
564
+ renderedBody: string | null;
565
+ variables: unknown;
566
+ metadata: unknown;
567
+ createdAt: Date;
568
+ updatedAt: Date;
569
+ } | null>;
570
+ createContract(db: PostgresJsDatabase, data: CreateContractInput): Promise<{
571
+ id: string;
572
+ status: "draft" | "sent" | "expired" | "issued" | "signed" | "executed" | "void";
573
+ createdAt: Date;
574
+ updatedAt: Date;
575
+ organizationId: string | null;
576
+ title: string;
577
+ personId: string | null;
578
+ sentAt: Date | null;
579
+ metadata: unknown;
580
+ supplierId: string | null;
581
+ scope: "customer" | "partner" | "supplier" | "other" | "channel";
582
+ language: string;
583
+ contractNumber: string | null;
584
+ templateVersionId: string | null;
585
+ seriesId: string | null;
586
+ channelId: string | null;
587
+ bookingId: string | null;
588
+ orderId: string | null;
589
+ issuedAt: Date | null;
590
+ executedAt: Date | null;
591
+ expiresAt: Date | null;
592
+ voidedAt: Date | null;
593
+ renderedBodyFormat: "markdown" | "html" | "lexical_json";
594
+ renderedBody: string | null;
595
+ variables: unknown;
596
+ } | null>;
597
+ updateContract(db: PostgresJsDatabase, id: string, data: UpdateContractInput): Promise<{
598
+ id: string;
599
+ contractNumber: string | null;
600
+ scope: "customer" | "partner" | "supplier" | "other" | "channel";
601
+ status: "draft" | "sent" | "expired" | "issued" | "signed" | "executed" | "void";
602
+ title: string;
603
+ templateVersionId: string | null;
604
+ seriesId: string | null;
605
+ personId: string | null;
606
+ organizationId: string | null;
607
+ supplierId: string | null;
608
+ channelId: string | null;
609
+ bookingId: string | null;
610
+ orderId: string | null;
611
+ issuedAt: Date | null;
612
+ sentAt: Date | null;
613
+ executedAt: Date | null;
614
+ expiresAt: Date | null;
615
+ voidedAt: Date | null;
616
+ language: string;
617
+ renderedBodyFormat: "markdown" | "html" | "lexical_json";
618
+ renderedBody: string | null;
619
+ variables: unknown;
620
+ metadata: unknown;
621
+ createdAt: Date;
622
+ updatedAt: Date;
623
+ } | null>;
624
+ deleteContract(db: PostgresJsDatabase, id: string): Promise<{
625
+ status: "not_found";
626
+ } | {
627
+ status: "not_draft";
628
+ } | {
629
+ status: "deleted";
630
+ }>;
631
+ /**
632
+ * Transition a draft contract to `issued`: renders body from the template
633
+ * version, allocates a contract number if a series is set, timestamps
634
+ * `issuedAt`. Returns null if contract is missing or not in `draft`.
635
+ */
636
+ issueContract(db: PostgresJsDatabase, contractId: string): Promise<{
637
+ status: "not_found";
638
+ contract?: undefined;
639
+ } | {
640
+ status: "not_draft";
641
+ contract?: undefined;
642
+ } | {
643
+ status: "issued";
644
+ contract: {
645
+ id: string;
646
+ contractNumber: string | null;
647
+ scope: "customer" | "partner" | "supplier" | "other" | "channel";
648
+ status: "draft" | "sent" | "expired" | "issued" | "signed" | "executed" | "void";
649
+ title: string;
650
+ templateVersionId: string | null;
651
+ seriesId: string | null;
652
+ personId: string | null;
653
+ organizationId: string | null;
654
+ supplierId: string | null;
655
+ channelId: string | null;
656
+ bookingId: string | null;
657
+ orderId: string | null;
658
+ issuedAt: Date | null;
659
+ sentAt: Date | null;
660
+ executedAt: Date | null;
661
+ expiresAt: Date | null;
662
+ voidedAt: Date | null;
663
+ language: string;
664
+ renderedBodyFormat: "markdown" | "html" | "lexical_json";
665
+ renderedBody: string | null;
666
+ variables: unknown;
667
+ metadata: unknown;
668
+ createdAt: Date;
669
+ updatedAt: Date;
670
+ } | null;
671
+ }>;
672
+ sendContract(db: PostgresJsDatabase, contractId: string): Promise<{
673
+ status: "not_found";
674
+ contract?: undefined;
675
+ } | {
676
+ status: "not_issued";
677
+ contract?: undefined;
678
+ } | {
679
+ status: "sent";
680
+ contract: {
681
+ id: string;
682
+ contractNumber: string | null;
683
+ scope: "customer" | "partner" | "supplier" | "other" | "channel";
684
+ status: "draft" | "sent" | "expired" | "issued" | "signed" | "executed" | "void";
685
+ title: string;
686
+ templateVersionId: string | null;
687
+ seriesId: string | null;
688
+ personId: string | null;
689
+ organizationId: string | null;
690
+ supplierId: string | null;
691
+ channelId: string | null;
692
+ bookingId: string | null;
693
+ orderId: string | null;
694
+ issuedAt: Date | null;
695
+ sentAt: Date | null;
696
+ executedAt: Date | null;
697
+ expiresAt: Date | null;
698
+ voidedAt: Date | null;
699
+ language: string;
700
+ renderedBodyFormat: "markdown" | "html" | "lexical_json";
701
+ renderedBody: string | null;
702
+ variables: unknown;
703
+ metadata: unknown;
704
+ createdAt: Date;
705
+ updatedAt: Date;
706
+ } | null;
707
+ }>;
708
+ voidContract(db: PostgresJsDatabase, contractId: string): Promise<{
709
+ status: "not_found";
710
+ contract?: undefined;
711
+ } | {
712
+ status: "already_void";
713
+ contract?: undefined;
714
+ } | {
715
+ status: "voided";
716
+ contract: {
717
+ id: string;
718
+ contractNumber: string | null;
719
+ scope: "customer" | "partner" | "supplier" | "other" | "channel";
720
+ status: "draft" | "sent" | "expired" | "issued" | "signed" | "executed" | "void";
721
+ title: string;
722
+ templateVersionId: string | null;
723
+ seriesId: string | null;
724
+ personId: string | null;
725
+ organizationId: string | null;
726
+ supplierId: string | null;
727
+ channelId: string | null;
728
+ bookingId: string | null;
729
+ orderId: string | null;
730
+ issuedAt: Date | null;
731
+ sentAt: Date | null;
732
+ executedAt: Date | null;
733
+ expiresAt: Date | null;
734
+ voidedAt: Date | null;
735
+ language: string;
736
+ renderedBodyFormat: "markdown" | "html" | "lexical_json";
737
+ renderedBody: string | null;
738
+ variables: unknown;
739
+ metadata: unknown;
740
+ createdAt: Date;
741
+ updatedAt: Date;
742
+ } | null;
743
+ }>;
744
+ listSignatures(db: PostgresJsDatabase, contractId: string): Omit<import("drizzle-orm/pg-core").PgSelectBase<"contract_signatures", {
745
+ id: import("drizzle-orm/pg-core").PgColumn<{
746
+ name: string;
747
+ tableName: "contract_signatures";
748
+ dataType: "string";
749
+ columnType: "PgText";
750
+ data: string;
751
+ driverParam: string;
752
+ notNull: true;
753
+ hasDefault: true;
754
+ isPrimaryKey: true;
755
+ isAutoincrement: false;
756
+ hasRuntimeDefault: true;
757
+ enumValues: [string, ...string[]];
758
+ baseColumn: never;
759
+ identity: undefined;
760
+ generated: undefined;
761
+ }, {}, {}>;
762
+ contractId: import("drizzle-orm/pg-core").PgColumn<{
763
+ name: string;
764
+ tableName: "contract_signatures";
765
+ dataType: "string";
766
+ columnType: "PgText";
767
+ data: string;
768
+ driverParam: string;
769
+ notNull: true;
770
+ hasDefault: false;
771
+ isPrimaryKey: false;
772
+ isAutoincrement: false;
773
+ hasRuntimeDefault: false;
774
+ enumValues: [string, ...string[]];
775
+ baseColumn: never;
776
+ identity: undefined;
777
+ generated: undefined;
778
+ }, {}, {}>;
779
+ signerName: import("drizzle-orm/pg-core").PgColumn<{
780
+ name: "signer_name";
781
+ tableName: "contract_signatures";
782
+ dataType: "string";
783
+ columnType: "PgText";
784
+ data: string;
785
+ driverParam: string;
786
+ notNull: true;
787
+ hasDefault: false;
788
+ isPrimaryKey: false;
789
+ isAutoincrement: false;
790
+ hasRuntimeDefault: false;
791
+ enumValues: [string, ...string[]];
792
+ baseColumn: never;
793
+ identity: undefined;
794
+ generated: undefined;
795
+ }, {}, {}>;
796
+ signerEmail: import("drizzle-orm/pg-core").PgColumn<{
797
+ name: "signer_email";
798
+ tableName: "contract_signatures";
799
+ dataType: "string";
800
+ columnType: "PgText";
801
+ data: string;
802
+ driverParam: string;
803
+ notNull: false;
804
+ hasDefault: false;
805
+ isPrimaryKey: false;
806
+ isAutoincrement: false;
807
+ hasRuntimeDefault: false;
808
+ enumValues: [string, ...string[]];
809
+ baseColumn: never;
810
+ identity: undefined;
811
+ generated: undefined;
812
+ }, {}, {}>;
813
+ signerRole: import("drizzle-orm/pg-core").PgColumn<{
814
+ name: "signer_role";
815
+ tableName: "contract_signatures";
816
+ dataType: "string";
817
+ columnType: "PgText";
818
+ data: string;
819
+ driverParam: string;
820
+ notNull: false;
821
+ hasDefault: false;
822
+ isPrimaryKey: false;
823
+ isAutoincrement: false;
824
+ hasRuntimeDefault: false;
825
+ enumValues: [string, ...string[]];
826
+ baseColumn: never;
827
+ identity: undefined;
828
+ generated: undefined;
829
+ }, {}, {}>;
830
+ personId: import("drizzle-orm/pg-core").PgColumn<{
831
+ name: string;
832
+ tableName: "contract_signatures";
833
+ dataType: "string";
834
+ columnType: "PgText";
835
+ data: string;
836
+ driverParam: string;
837
+ notNull: false;
838
+ hasDefault: false;
839
+ isPrimaryKey: false;
840
+ isAutoincrement: false;
841
+ hasRuntimeDefault: false;
842
+ enumValues: [string, ...string[]];
843
+ baseColumn: never;
844
+ identity: undefined;
845
+ generated: undefined;
846
+ }, {}, {}>;
847
+ method: import("drizzle-orm/pg-core").PgColumn<{
848
+ name: "method";
849
+ tableName: "contract_signatures";
850
+ dataType: "string";
851
+ columnType: "PgEnumColumn";
852
+ data: "other" | "manual" | "electronic" | "docusign";
853
+ driverParam: string;
854
+ notNull: true;
855
+ hasDefault: true;
856
+ isPrimaryKey: false;
857
+ isAutoincrement: false;
858
+ hasRuntimeDefault: false;
859
+ enumValues: ["manual", "electronic", "docusign", "other"];
860
+ baseColumn: never;
861
+ identity: undefined;
862
+ generated: undefined;
863
+ }, {}, {}>;
864
+ provider: import("drizzle-orm/pg-core").PgColumn<{
865
+ name: "provider";
866
+ tableName: "contract_signatures";
867
+ dataType: "string";
868
+ columnType: "PgText";
869
+ data: string;
870
+ driverParam: string;
871
+ notNull: false;
872
+ hasDefault: false;
873
+ isPrimaryKey: false;
874
+ isAutoincrement: false;
875
+ hasRuntimeDefault: false;
876
+ enumValues: [string, ...string[]];
877
+ baseColumn: never;
878
+ identity: undefined;
879
+ generated: undefined;
880
+ }, {}, {}>;
881
+ externalReference: import("drizzle-orm/pg-core").PgColumn<{
882
+ name: "external_reference";
883
+ tableName: "contract_signatures";
884
+ dataType: "string";
885
+ columnType: "PgText";
886
+ data: string;
887
+ driverParam: string;
888
+ notNull: false;
889
+ hasDefault: false;
890
+ isPrimaryKey: false;
891
+ isAutoincrement: false;
892
+ hasRuntimeDefault: false;
893
+ enumValues: [string, ...string[]];
894
+ baseColumn: never;
895
+ identity: undefined;
896
+ generated: undefined;
897
+ }, {}, {}>;
898
+ signatureData: import("drizzle-orm/pg-core").PgColumn<{
899
+ name: "signature_data";
900
+ tableName: "contract_signatures";
901
+ dataType: "string";
902
+ columnType: "PgText";
903
+ data: string;
904
+ driverParam: string;
905
+ notNull: false;
906
+ hasDefault: false;
907
+ isPrimaryKey: false;
908
+ isAutoincrement: false;
909
+ hasRuntimeDefault: false;
910
+ enumValues: [string, ...string[]];
911
+ baseColumn: never;
912
+ identity: undefined;
913
+ generated: undefined;
914
+ }, {}, {}>;
915
+ ipAddress: import("drizzle-orm/pg-core").PgColumn<{
916
+ name: "ip_address";
917
+ tableName: "contract_signatures";
918
+ dataType: "string";
919
+ columnType: "PgText";
920
+ data: string;
921
+ driverParam: string;
922
+ notNull: false;
923
+ hasDefault: false;
924
+ isPrimaryKey: false;
925
+ isAutoincrement: false;
926
+ hasRuntimeDefault: false;
927
+ enumValues: [string, ...string[]];
928
+ baseColumn: never;
929
+ identity: undefined;
930
+ generated: undefined;
931
+ }, {}, {}>;
932
+ userAgent: import("drizzle-orm/pg-core").PgColumn<{
933
+ name: "user_agent";
934
+ tableName: "contract_signatures";
935
+ dataType: "string";
936
+ columnType: "PgText";
937
+ data: string;
938
+ driverParam: string;
939
+ notNull: false;
940
+ hasDefault: false;
941
+ isPrimaryKey: false;
942
+ isAutoincrement: false;
943
+ hasRuntimeDefault: false;
944
+ enumValues: [string, ...string[]];
945
+ baseColumn: never;
946
+ identity: undefined;
947
+ generated: undefined;
948
+ }, {}, {}>;
949
+ signedAt: import("drizzle-orm/pg-core").PgColumn<{
950
+ name: "signed_at";
951
+ tableName: "contract_signatures";
952
+ dataType: "date";
953
+ columnType: "PgTimestamp";
954
+ data: Date;
955
+ driverParam: string;
956
+ notNull: true;
957
+ hasDefault: true;
958
+ isPrimaryKey: false;
959
+ isAutoincrement: false;
960
+ hasRuntimeDefault: false;
961
+ enumValues: undefined;
962
+ baseColumn: never;
963
+ identity: undefined;
964
+ generated: undefined;
965
+ }, {}, {}>;
966
+ metadata: import("drizzle-orm/pg-core").PgColumn<{
967
+ name: "metadata";
968
+ tableName: "contract_signatures";
969
+ dataType: "json";
970
+ columnType: "PgJsonb";
971
+ data: unknown;
972
+ driverParam: unknown;
973
+ notNull: false;
974
+ hasDefault: false;
975
+ isPrimaryKey: false;
976
+ isAutoincrement: false;
977
+ hasRuntimeDefault: false;
978
+ enumValues: undefined;
979
+ baseColumn: never;
980
+ identity: undefined;
981
+ generated: undefined;
982
+ }, {}, {}>;
983
+ createdAt: import("drizzle-orm/pg-core").PgColumn<{
984
+ name: "created_at";
985
+ tableName: "contract_signatures";
986
+ dataType: "date";
987
+ columnType: "PgTimestamp";
988
+ data: Date;
989
+ driverParam: string;
990
+ notNull: true;
991
+ hasDefault: true;
992
+ isPrimaryKey: false;
993
+ isAutoincrement: false;
994
+ hasRuntimeDefault: false;
995
+ enumValues: undefined;
996
+ baseColumn: never;
997
+ identity: undefined;
998
+ generated: undefined;
999
+ }, {}, {}>;
1000
+ }, "single", Record<"contract_signatures", "not-null">, false, "where" | "orderBy", {
1001
+ id: string;
1002
+ contractId: string;
1003
+ signerName: string;
1004
+ signerEmail: string | null;
1005
+ signerRole: string | null;
1006
+ personId: string | null;
1007
+ method: "other" | "manual" | "electronic" | "docusign";
1008
+ provider: string | null;
1009
+ externalReference: string | null;
1010
+ signatureData: string | null;
1011
+ ipAddress: string | null;
1012
+ userAgent: string | null;
1013
+ signedAt: Date;
1014
+ metadata: unknown;
1015
+ createdAt: Date;
1016
+ }[], {
1017
+ id: import("drizzle-orm/pg-core").PgColumn<{
1018
+ name: string;
1019
+ tableName: "contract_signatures";
1020
+ dataType: "string";
1021
+ columnType: "PgText";
1022
+ data: string;
1023
+ driverParam: string;
1024
+ notNull: true;
1025
+ hasDefault: true;
1026
+ isPrimaryKey: true;
1027
+ isAutoincrement: false;
1028
+ hasRuntimeDefault: true;
1029
+ enumValues: [string, ...string[]];
1030
+ baseColumn: never;
1031
+ identity: undefined;
1032
+ generated: undefined;
1033
+ }, {}, {}>;
1034
+ contractId: import("drizzle-orm/pg-core").PgColumn<{
1035
+ name: string;
1036
+ tableName: "contract_signatures";
1037
+ dataType: "string";
1038
+ columnType: "PgText";
1039
+ data: string;
1040
+ driverParam: string;
1041
+ notNull: true;
1042
+ hasDefault: false;
1043
+ isPrimaryKey: false;
1044
+ isAutoincrement: false;
1045
+ hasRuntimeDefault: false;
1046
+ enumValues: [string, ...string[]];
1047
+ baseColumn: never;
1048
+ identity: undefined;
1049
+ generated: undefined;
1050
+ }, {}, {}>;
1051
+ signerName: import("drizzle-orm/pg-core").PgColumn<{
1052
+ name: "signer_name";
1053
+ tableName: "contract_signatures";
1054
+ dataType: "string";
1055
+ columnType: "PgText";
1056
+ data: string;
1057
+ driverParam: string;
1058
+ notNull: true;
1059
+ hasDefault: false;
1060
+ isPrimaryKey: false;
1061
+ isAutoincrement: false;
1062
+ hasRuntimeDefault: false;
1063
+ enumValues: [string, ...string[]];
1064
+ baseColumn: never;
1065
+ identity: undefined;
1066
+ generated: undefined;
1067
+ }, {}, {}>;
1068
+ signerEmail: import("drizzle-orm/pg-core").PgColumn<{
1069
+ name: "signer_email";
1070
+ tableName: "contract_signatures";
1071
+ dataType: "string";
1072
+ columnType: "PgText";
1073
+ data: string;
1074
+ driverParam: string;
1075
+ notNull: false;
1076
+ hasDefault: false;
1077
+ isPrimaryKey: false;
1078
+ isAutoincrement: false;
1079
+ hasRuntimeDefault: false;
1080
+ enumValues: [string, ...string[]];
1081
+ baseColumn: never;
1082
+ identity: undefined;
1083
+ generated: undefined;
1084
+ }, {}, {}>;
1085
+ signerRole: import("drizzle-orm/pg-core").PgColumn<{
1086
+ name: "signer_role";
1087
+ tableName: "contract_signatures";
1088
+ dataType: "string";
1089
+ columnType: "PgText";
1090
+ data: string;
1091
+ driverParam: string;
1092
+ notNull: false;
1093
+ hasDefault: false;
1094
+ isPrimaryKey: false;
1095
+ isAutoincrement: false;
1096
+ hasRuntimeDefault: false;
1097
+ enumValues: [string, ...string[]];
1098
+ baseColumn: never;
1099
+ identity: undefined;
1100
+ generated: undefined;
1101
+ }, {}, {}>;
1102
+ personId: import("drizzle-orm/pg-core").PgColumn<{
1103
+ name: string;
1104
+ tableName: "contract_signatures";
1105
+ dataType: "string";
1106
+ columnType: "PgText";
1107
+ data: string;
1108
+ driverParam: string;
1109
+ notNull: false;
1110
+ hasDefault: false;
1111
+ isPrimaryKey: false;
1112
+ isAutoincrement: false;
1113
+ hasRuntimeDefault: false;
1114
+ enumValues: [string, ...string[]];
1115
+ baseColumn: never;
1116
+ identity: undefined;
1117
+ generated: undefined;
1118
+ }, {}, {}>;
1119
+ method: import("drizzle-orm/pg-core").PgColumn<{
1120
+ name: "method";
1121
+ tableName: "contract_signatures";
1122
+ dataType: "string";
1123
+ columnType: "PgEnumColumn";
1124
+ data: "other" | "manual" | "electronic" | "docusign";
1125
+ driverParam: string;
1126
+ notNull: true;
1127
+ hasDefault: true;
1128
+ isPrimaryKey: false;
1129
+ isAutoincrement: false;
1130
+ hasRuntimeDefault: false;
1131
+ enumValues: ["manual", "electronic", "docusign", "other"];
1132
+ baseColumn: never;
1133
+ identity: undefined;
1134
+ generated: undefined;
1135
+ }, {}, {}>;
1136
+ provider: import("drizzle-orm/pg-core").PgColumn<{
1137
+ name: "provider";
1138
+ tableName: "contract_signatures";
1139
+ dataType: "string";
1140
+ columnType: "PgText";
1141
+ data: string;
1142
+ driverParam: string;
1143
+ notNull: false;
1144
+ hasDefault: false;
1145
+ isPrimaryKey: false;
1146
+ isAutoincrement: false;
1147
+ hasRuntimeDefault: false;
1148
+ enumValues: [string, ...string[]];
1149
+ baseColumn: never;
1150
+ identity: undefined;
1151
+ generated: undefined;
1152
+ }, {}, {}>;
1153
+ externalReference: import("drizzle-orm/pg-core").PgColumn<{
1154
+ name: "external_reference";
1155
+ tableName: "contract_signatures";
1156
+ dataType: "string";
1157
+ columnType: "PgText";
1158
+ data: string;
1159
+ driverParam: string;
1160
+ notNull: false;
1161
+ hasDefault: false;
1162
+ isPrimaryKey: false;
1163
+ isAutoincrement: false;
1164
+ hasRuntimeDefault: false;
1165
+ enumValues: [string, ...string[]];
1166
+ baseColumn: never;
1167
+ identity: undefined;
1168
+ generated: undefined;
1169
+ }, {}, {}>;
1170
+ signatureData: import("drizzle-orm/pg-core").PgColumn<{
1171
+ name: "signature_data";
1172
+ tableName: "contract_signatures";
1173
+ dataType: "string";
1174
+ columnType: "PgText";
1175
+ data: string;
1176
+ driverParam: string;
1177
+ notNull: false;
1178
+ hasDefault: false;
1179
+ isPrimaryKey: false;
1180
+ isAutoincrement: false;
1181
+ hasRuntimeDefault: false;
1182
+ enumValues: [string, ...string[]];
1183
+ baseColumn: never;
1184
+ identity: undefined;
1185
+ generated: undefined;
1186
+ }, {}, {}>;
1187
+ ipAddress: import("drizzle-orm/pg-core").PgColumn<{
1188
+ name: "ip_address";
1189
+ tableName: "contract_signatures";
1190
+ dataType: "string";
1191
+ columnType: "PgText";
1192
+ data: string;
1193
+ driverParam: string;
1194
+ notNull: false;
1195
+ hasDefault: false;
1196
+ isPrimaryKey: false;
1197
+ isAutoincrement: false;
1198
+ hasRuntimeDefault: false;
1199
+ enumValues: [string, ...string[]];
1200
+ baseColumn: never;
1201
+ identity: undefined;
1202
+ generated: undefined;
1203
+ }, {}, {}>;
1204
+ userAgent: import("drizzle-orm/pg-core").PgColumn<{
1205
+ name: "user_agent";
1206
+ tableName: "contract_signatures";
1207
+ dataType: "string";
1208
+ columnType: "PgText";
1209
+ data: string;
1210
+ driverParam: string;
1211
+ notNull: false;
1212
+ hasDefault: false;
1213
+ isPrimaryKey: false;
1214
+ isAutoincrement: false;
1215
+ hasRuntimeDefault: false;
1216
+ enumValues: [string, ...string[]];
1217
+ baseColumn: never;
1218
+ identity: undefined;
1219
+ generated: undefined;
1220
+ }, {}, {}>;
1221
+ signedAt: import("drizzle-orm/pg-core").PgColumn<{
1222
+ name: "signed_at";
1223
+ tableName: "contract_signatures";
1224
+ dataType: "date";
1225
+ columnType: "PgTimestamp";
1226
+ data: Date;
1227
+ driverParam: string;
1228
+ notNull: true;
1229
+ hasDefault: true;
1230
+ isPrimaryKey: false;
1231
+ isAutoincrement: false;
1232
+ hasRuntimeDefault: false;
1233
+ enumValues: undefined;
1234
+ baseColumn: never;
1235
+ identity: undefined;
1236
+ generated: undefined;
1237
+ }, {}, {}>;
1238
+ metadata: import("drizzle-orm/pg-core").PgColumn<{
1239
+ name: "metadata";
1240
+ tableName: "contract_signatures";
1241
+ dataType: "json";
1242
+ columnType: "PgJsonb";
1243
+ data: unknown;
1244
+ driverParam: unknown;
1245
+ notNull: false;
1246
+ hasDefault: false;
1247
+ isPrimaryKey: false;
1248
+ isAutoincrement: false;
1249
+ hasRuntimeDefault: false;
1250
+ enumValues: undefined;
1251
+ baseColumn: never;
1252
+ identity: undefined;
1253
+ generated: undefined;
1254
+ }, {}, {}>;
1255
+ createdAt: import("drizzle-orm/pg-core").PgColumn<{
1256
+ name: "created_at";
1257
+ tableName: "contract_signatures";
1258
+ dataType: "date";
1259
+ columnType: "PgTimestamp";
1260
+ data: Date;
1261
+ driverParam: string;
1262
+ notNull: true;
1263
+ hasDefault: true;
1264
+ isPrimaryKey: false;
1265
+ isAutoincrement: false;
1266
+ hasRuntimeDefault: false;
1267
+ enumValues: undefined;
1268
+ baseColumn: never;
1269
+ identity: undefined;
1270
+ generated: undefined;
1271
+ }, {}, {}>;
1272
+ }>, "where" | "orderBy">;
1273
+ signContract(db: PostgresJsDatabase, contractId: string, data: CreateContractSignatureInput): Promise<{
1274
+ status: "not_found";
1275
+ contract?: undefined;
1276
+ signature?: undefined;
1277
+ } | {
1278
+ status: "not_signable";
1279
+ contract?: undefined;
1280
+ signature?: undefined;
1281
+ } | {
1282
+ status: "signed";
1283
+ contract: {
1284
+ id: string;
1285
+ contractNumber: string | null;
1286
+ scope: "customer" | "partner" | "supplier" | "other" | "channel";
1287
+ status: "draft" | "sent" | "expired" | "issued" | "signed" | "executed" | "void";
1288
+ title: string;
1289
+ templateVersionId: string | null;
1290
+ seriesId: string | null;
1291
+ personId: string | null;
1292
+ organizationId: string | null;
1293
+ supplierId: string | null;
1294
+ channelId: string | null;
1295
+ bookingId: string | null;
1296
+ orderId: string | null;
1297
+ issuedAt: Date | null;
1298
+ sentAt: Date | null;
1299
+ executedAt: Date | null;
1300
+ expiresAt: Date | null;
1301
+ voidedAt: Date | null;
1302
+ language: string;
1303
+ renderedBodyFormat: "markdown" | "html" | "lexical_json";
1304
+ renderedBody: string | null;
1305
+ variables: unknown;
1306
+ metadata: unknown;
1307
+ createdAt: Date;
1308
+ updatedAt: Date;
1309
+ } | null;
1310
+ signature: {
1311
+ id: string;
1312
+ createdAt: Date;
1313
+ personId: string | null;
1314
+ metadata: unknown;
1315
+ contractId: string;
1316
+ signerName: string;
1317
+ signerEmail: string | null;
1318
+ signerRole: string | null;
1319
+ method: "other" | "manual" | "electronic" | "docusign";
1320
+ provider: string | null;
1321
+ externalReference: string | null;
1322
+ signatureData: string | null;
1323
+ ipAddress: string | null;
1324
+ userAgent: string | null;
1325
+ signedAt: Date;
1326
+ } | null;
1327
+ }>;
1328
+ executeContract(db: PostgresJsDatabase, contractId: string): Promise<{
1329
+ status: "not_found";
1330
+ contract?: undefined;
1331
+ } | {
1332
+ status: "not_signed";
1333
+ contract?: undefined;
1334
+ } | {
1335
+ status: "executed";
1336
+ contract: {
1337
+ id: string;
1338
+ contractNumber: string | null;
1339
+ scope: "customer" | "partner" | "supplier" | "other" | "channel";
1340
+ status: "draft" | "sent" | "expired" | "issued" | "signed" | "executed" | "void";
1341
+ title: string;
1342
+ templateVersionId: string | null;
1343
+ seriesId: string | null;
1344
+ personId: string | null;
1345
+ organizationId: string | null;
1346
+ supplierId: string | null;
1347
+ channelId: string | null;
1348
+ bookingId: string | null;
1349
+ orderId: string | null;
1350
+ issuedAt: Date | null;
1351
+ sentAt: Date | null;
1352
+ executedAt: Date | null;
1353
+ expiresAt: Date | null;
1354
+ voidedAt: Date | null;
1355
+ language: string;
1356
+ renderedBodyFormat: "markdown" | "html" | "lexical_json";
1357
+ renderedBody: string | null;
1358
+ variables: unknown;
1359
+ metadata: unknown;
1360
+ createdAt: Date;
1361
+ updatedAt: Date;
1362
+ } | null;
1363
+ }>;
1364
+ listAttachments(db: PostgresJsDatabase, contractId: string): Omit<import("drizzle-orm/pg-core").PgSelectBase<"contract_attachments", {
1365
+ id: import("drizzle-orm/pg-core").PgColumn<{
1366
+ name: string;
1367
+ tableName: "contract_attachments";
1368
+ dataType: "string";
1369
+ columnType: "PgText";
1370
+ data: string;
1371
+ driverParam: string;
1372
+ notNull: true;
1373
+ hasDefault: true;
1374
+ isPrimaryKey: true;
1375
+ isAutoincrement: false;
1376
+ hasRuntimeDefault: true;
1377
+ enumValues: [string, ...string[]];
1378
+ baseColumn: never;
1379
+ identity: undefined;
1380
+ generated: undefined;
1381
+ }, {}, {}>;
1382
+ contractId: import("drizzle-orm/pg-core").PgColumn<{
1383
+ name: string;
1384
+ tableName: "contract_attachments";
1385
+ dataType: "string";
1386
+ columnType: "PgText";
1387
+ data: string;
1388
+ driverParam: string;
1389
+ notNull: true;
1390
+ hasDefault: false;
1391
+ isPrimaryKey: false;
1392
+ isAutoincrement: false;
1393
+ hasRuntimeDefault: false;
1394
+ enumValues: [string, ...string[]];
1395
+ baseColumn: never;
1396
+ identity: undefined;
1397
+ generated: undefined;
1398
+ }, {}, {}>;
1399
+ kind: import("drizzle-orm/pg-core").PgColumn<{
1400
+ name: "kind";
1401
+ tableName: "contract_attachments";
1402
+ dataType: "string";
1403
+ columnType: "PgText";
1404
+ data: string;
1405
+ driverParam: string;
1406
+ notNull: true;
1407
+ hasDefault: true;
1408
+ isPrimaryKey: false;
1409
+ isAutoincrement: false;
1410
+ hasRuntimeDefault: false;
1411
+ enumValues: [string, ...string[]];
1412
+ baseColumn: never;
1413
+ identity: undefined;
1414
+ generated: undefined;
1415
+ }, {}, {}>;
1416
+ name: import("drizzle-orm/pg-core").PgColumn<{
1417
+ name: "name";
1418
+ tableName: "contract_attachments";
1419
+ dataType: "string";
1420
+ columnType: "PgText";
1421
+ data: string;
1422
+ driverParam: string;
1423
+ notNull: true;
1424
+ hasDefault: false;
1425
+ isPrimaryKey: false;
1426
+ isAutoincrement: false;
1427
+ hasRuntimeDefault: false;
1428
+ enumValues: [string, ...string[]];
1429
+ baseColumn: never;
1430
+ identity: undefined;
1431
+ generated: undefined;
1432
+ }, {}, {}>;
1433
+ mimeType: import("drizzle-orm/pg-core").PgColumn<{
1434
+ name: "mime_type";
1435
+ tableName: "contract_attachments";
1436
+ dataType: "string";
1437
+ columnType: "PgText";
1438
+ data: string;
1439
+ driverParam: string;
1440
+ notNull: false;
1441
+ hasDefault: false;
1442
+ isPrimaryKey: false;
1443
+ isAutoincrement: false;
1444
+ hasRuntimeDefault: false;
1445
+ enumValues: [string, ...string[]];
1446
+ baseColumn: never;
1447
+ identity: undefined;
1448
+ generated: undefined;
1449
+ }, {}, {}>;
1450
+ fileSize: import("drizzle-orm/pg-core").PgColumn<{
1451
+ name: "file_size";
1452
+ tableName: "contract_attachments";
1453
+ dataType: "number";
1454
+ columnType: "PgInteger";
1455
+ data: number;
1456
+ driverParam: string | number;
1457
+ notNull: false;
1458
+ hasDefault: false;
1459
+ isPrimaryKey: false;
1460
+ isAutoincrement: false;
1461
+ hasRuntimeDefault: false;
1462
+ enumValues: undefined;
1463
+ baseColumn: never;
1464
+ identity: undefined;
1465
+ generated: undefined;
1466
+ }, {}, {}>;
1467
+ storageKey: import("drizzle-orm/pg-core").PgColumn<{
1468
+ name: "storage_key";
1469
+ tableName: "contract_attachments";
1470
+ dataType: "string";
1471
+ columnType: "PgText";
1472
+ data: string;
1473
+ driverParam: string;
1474
+ notNull: false;
1475
+ hasDefault: false;
1476
+ isPrimaryKey: false;
1477
+ isAutoincrement: false;
1478
+ hasRuntimeDefault: false;
1479
+ enumValues: [string, ...string[]];
1480
+ baseColumn: never;
1481
+ identity: undefined;
1482
+ generated: undefined;
1483
+ }, {}, {}>;
1484
+ checksum: import("drizzle-orm/pg-core").PgColumn<{
1485
+ name: "checksum";
1486
+ tableName: "contract_attachments";
1487
+ dataType: "string";
1488
+ columnType: "PgText";
1489
+ data: string;
1490
+ driverParam: string;
1491
+ notNull: false;
1492
+ hasDefault: false;
1493
+ isPrimaryKey: false;
1494
+ isAutoincrement: false;
1495
+ hasRuntimeDefault: false;
1496
+ enumValues: [string, ...string[]];
1497
+ baseColumn: never;
1498
+ identity: undefined;
1499
+ generated: undefined;
1500
+ }, {}, {}>;
1501
+ metadata: import("drizzle-orm/pg-core").PgColumn<{
1502
+ name: "metadata";
1503
+ tableName: "contract_attachments";
1504
+ dataType: "json";
1505
+ columnType: "PgJsonb";
1506
+ data: unknown;
1507
+ driverParam: unknown;
1508
+ notNull: false;
1509
+ hasDefault: false;
1510
+ isPrimaryKey: false;
1511
+ isAutoincrement: false;
1512
+ hasRuntimeDefault: false;
1513
+ enumValues: undefined;
1514
+ baseColumn: never;
1515
+ identity: undefined;
1516
+ generated: undefined;
1517
+ }, {}, {}>;
1518
+ createdAt: import("drizzle-orm/pg-core").PgColumn<{
1519
+ name: "created_at";
1520
+ tableName: "contract_attachments";
1521
+ dataType: "date";
1522
+ columnType: "PgTimestamp";
1523
+ data: Date;
1524
+ driverParam: string;
1525
+ notNull: true;
1526
+ hasDefault: true;
1527
+ isPrimaryKey: false;
1528
+ isAutoincrement: false;
1529
+ hasRuntimeDefault: false;
1530
+ enumValues: undefined;
1531
+ baseColumn: never;
1532
+ identity: undefined;
1533
+ generated: undefined;
1534
+ }, {}, {}>;
1535
+ }, "single", Record<"contract_attachments", "not-null">, false, "where" | "orderBy", {
1536
+ id: string;
1537
+ contractId: string;
1538
+ kind: string;
1539
+ name: string;
1540
+ mimeType: string | null;
1541
+ fileSize: number | null;
1542
+ storageKey: string | null;
1543
+ checksum: string | null;
1544
+ metadata: unknown;
1545
+ createdAt: Date;
1546
+ }[], {
1547
+ id: import("drizzle-orm/pg-core").PgColumn<{
1548
+ name: string;
1549
+ tableName: "contract_attachments";
1550
+ dataType: "string";
1551
+ columnType: "PgText";
1552
+ data: string;
1553
+ driverParam: string;
1554
+ notNull: true;
1555
+ hasDefault: true;
1556
+ isPrimaryKey: true;
1557
+ isAutoincrement: false;
1558
+ hasRuntimeDefault: true;
1559
+ enumValues: [string, ...string[]];
1560
+ baseColumn: never;
1561
+ identity: undefined;
1562
+ generated: undefined;
1563
+ }, {}, {}>;
1564
+ contractId: import("drizzle-orm/pg-core").PgColumn<{
1565
+ name: string;
1566
+ tableName: "contract_attachments";
1567
+ dataType: "string";
1568
+ columnType: "PgText";
1569
+ data: string;
1570
+ driverParam: string;
1571
+ notNull: true;
1572
+ hasDefault: false;
1573
+ isPrimaryKey: false;
1574
+ isAutoincrement: false;
1575
+ hasRuntimeDefault: false;
1576
+ enumValues: [string, ...string[]];
1577
+ baseColumn: never;
1578
+ identity: undefined;
1579
+ generated: undefined;
1580
+ }, {}, {}>;
1581
+ kind: import("drizzle-orm/pg-core").PgColumn<{
1582
+ name: "kind";
1583
+ tableName: "contract_attachments";
1584
+ dataType: "string";
1585
+ columnType: "PgText";
1586
+ data: string;
1587
+ driverParam: string;
1588
+ notNull: true;
1589
+ hasDefault: true;
1590
+ isPrimaryKey: false;
1591
+ isAutoincrement: false;
1592
+ hasRuntimeDefault: false;
1593
+ enumValues: [string, ...string[]];
1594
+ baseColumn: never;
1595
+ identity: undefined;
1596
+ generated: undefined;
1597
+ }, {}, {}>;
1598
+ name: import("drizzle-orm/pg-core").PgColumn<{
1599
+ name: "name";
1600
+ tableName: "contract_attachments";
1601
+ dataType: "string";
1602
+ columnType: "PgText";
1603
+ data: string;
1604
+ driverParam: string;
1605
+ notNull: true;
1606
+ hasDefault: false;
1607
+ isPrimaryKey: false;
1608
+ isAutoincrement: false;
1609
+ hasRuntimeDefault: false;
1610
+ enumValues: [string, ...string[]];
1611
+ baseColumn: never;
1612
+ identity: undefined;
1613
+ generated: undefined;
1614
+ }, {}, {}>;
1615
+ mimeType: import("drizzle-orm/pg-core").PgColumn<{
1616
+ name: "mime_type";
1617
+ tableName: "contract_attachments";
1618
+ dataType: "string";
1619
+ columnType: "PgText";
1620
+ data: string;
1621
+ driverParam: string;
1622
+ notNull: false;
1623
+ hasDefault: false;
1624
+ isPrimaryKey: false;
1625
+ isAutoincrement: false;
1626
+ hasRuntimeDefault: false;
1627
+ enumValues: [string, ...string[]];
1628
+ baseColumn: never;
1629
+ identity: undefined;
1630
+ generated: undefined;
1631
+ }, {}, {}>;
1632
+ fileSize: import("drizzle-orm/pg-core").PgColumn<{
1633
+ name: "file_size";
1634
+ tableName: "contract_attachments";
1635
+ dataType: "number";
1636
+ columnType: "PgInteger";
1637
+ data: number;
1638
+ driverParam: string | number;
1639
+ notNull: false;
1640
+ hasDefault: false;
1641
+ isPrimaryKey: false;
1642
+ isAutoincrement: false;
1643
+ hasRuntimeDefault: false;
1644
+ enumValues: undefined;
1645
+ baseColumn: never;
1646
+ identity: undefined;
1647
+ generated: undefined;
1648
+ }, {}, {}>;
1649
+ storageKey: import("drizzle-orm/pg-core").PgColumn<{
1650
+ name: "storage_key";
1651
+ tableName: "contract_attachments";
1652
+ dataType: "string";
1653
+ columnType: "PgText";
1654
+ data: string;
1655
+ driverParam: string;
1656
+ notNull: false;
1657
+ hasDefault: false;
1658
+ isPrimaryKey: false;
1659
+ isAutoincrement: false;
1660
+ hasRuntimeDefault: false;
1661
+ enumValues: [string, ...string[]];
1662
+ baseColumn: never;
1663
+ identity: undefined;
1664
+ generated: undefined;
1665
+ }, {}, {}>;
1666
+ checksum: import("drizzle-orm/pg-core").PgColumn<{
1667
+ name: "checksum";
1668
+ tableName: "contract_attachments";
1669
+ dataType: "string";
1670
+ columnType: "PgText";
1671
+ data: string;
1672
+ driverParam: string;
1673
+ notNull: false;
1674
+ hasDefault: false;
1675
+ isPrimaryKey: false;
1676
+ isAutoincrement: false;
1677
+ hasRuntimeDefault: false;
1678
+ enumValues: [string, ...string[]];
1679
+ baseColumn: never;
1680
+ identity: undefined;
1681
+ generated: undefined;
1682
+ }, {}, {}>;
1683
+ metadata: import("drizzle-orm/pg-core").PgColumn<{
1684
+ name: "metadata";
1685
+ tableName: "contract_attachments";
1686
+ dataType: "json";
1687
+ columnType: "PgJsonb";
1688
+ data: unknown;
1689
+ driverParam: unknown;
1690
+ notNull: false;
1691
+ hasDefault: false;
1692
+ isPrimaryKey: false;
1693
+ isAutoincrement: false;
1694
+ hasRuntimeDefault: false;
1695
+ enumValues: undefined;
1696
+ baseColumn: never;
1697
+ identity: undefined;
1698
+ generated: undefined;
1699
+ }, {}, {}>;
1700
+ createdAt: import("drizzle-orm/pg-core").PgColumn<{
1701
+ name: "created_at";
1702
+ tableName: "contract_attachments";
1703
+ dataType: "date";
1704
+ columnType: "PgTimestamp";
1705
+ data: Date;
1706
+ driverParam: string;
1707
+ notNull: true;
1708
+ hasDefault: true;
1709
+ isPrimaryKey: false;
1710
+ isAutoincrement: false;
1711
+ hasRuntimeDefault: false;
1712
+ enumValues: undefined;
1713
+ baseColumn: never;
1714
+ identity: undefined;
1715
+ generated: undefined;
1716
+ }, {}, {}>;
1717
+ }>, "where" | "orderBy">;
1718
+ createAttachment(db: PostgresJsDatabase, contractId: string, data: CreateContractAttachmentInput): Promise<{
1719
+ id: string;
1720
+ name: string;
1721
+ createdAt: Date;
1722
+ kind: string;
1723
+ metadata: unknown;
1724
+ contractId: string;
1725
+ mimeType: string | null;
1726
+ fileSize: number | null;
1727
+ storageKey: string | null;
1728
+ checksum: string | null;
1729
+ } | null>;
1730
+ updateAttachment(db: PostgresJsDatabase, attachmentId: string, data: UpdateContractAttachmentInput): Promise<{
1731
+ id: string;
1732
+ contractId: string;
1733
+ kind: string;
1734
+ name: string;
1735
+ mimeType: string | null;
1736
+ fileSize: number | null;
1737
+ storageKey: string | null;
1738
+ checksum: string | null;
1739
+ metadata: unknown;
1740
+ createdAt: Date;
1741
+ } | null>;
1742
+ deleteAttachment(db: PostgresJsDatabase, attachmentId: string): Promise<{
1743
+ id: string;
1744
+ } | null>;
1745
+ /**
1746
+ * Preview render: substitute variables against an arbitrary body without
1747
+ * touching the database. Used by `/v1/admin/contracts/:id/render` and
1748
+ * `/v1/admin/contracts/templates/:id/preview`.
1749
+ */
1750
+ renderPreview(input: RenderTemplateInput): string;
1751
+ };
1752
+ export {};
1753
+ //# sourceMappingURL=service.d.ts.map