@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,1384 @@
1
+ import { inArray } from "drizzle-orm";
2
+ import type { PostgresJsDatabase } from "drizzle-orm/postgres-js";
3
+ import type { z } from "zod";
4
+ import type { evaluateCancellationInputSchema, insertPolicyAcceptanceSchema, insertPolicyAssignmentSchema, insertPolicyRuleSchema, insertPolicySchema, insertPolicyVersionSchema, policyAcceptanceListQuerySchema, policyAssignmentListQuerySchema, policyListQuerySchema, resolvePolicyInputSchema, updatePolicyAssignmentSchema, updatePolicyRuleSchema, updatePolicySchema, updatePolicyVersionSchema } from "./validation.js";
5
+ type PolicyListQuery = z.infer<typeof policyListQuerySchema>;
6
+ type CreatePolicyInput = z.infer<typeof insertPolicySchema>;
7
+ type UpdatePolicyInput = z.infer<typeof updatePolicySchema>;
8
+ type CreatePolicyVersionInput = z.infer<typeof insertPolicyVersionSchema>;
9
+ type UpdatePolicyVersionInput = z.infer<typeof updatePolicyVersionSchema>;
10
+ type CreatePolicyRuleInput = z.infer<typeof insertPolicyRuleSchema>;
11
+ type UpdatePolicyRuleInput = z.infer<typeof updatePolicyRuleSchema>;
12
+ type CreatePolicyAssignmentInput = z.infer<typeof insertPolicyAssignmentSchema>;
13
+ type UpdatePolicyAssignmentInput = z.infer<typeof updatePolicyAssignmentSchema>;
14
+ type PolicyAssignmentListQuery = z.infer<typeof policyAssignmentListQuerySchema>;
15
+ type CreatePolicyAcceptanceInput = z.infer<typeof insertPolicyAcceptanceSchema>;
16
+ type PolicyAcceptanceListQuery = z.infer<typeof policyAcceptanceListQuerySchema>;
17
+ type EvaluateCancellationInput = z.infer<typeof evaluateCancellationInputSchema>;
18
+ type ResolvePolicyInput = z.infer<typeof resolvePolicyInputSchema>;
19
+ export type CancellationRule = {
20
+ id?: string;
21
+ daysBeforeDeparture: number | null;
22
+ refundPercent: number | null;
23
+ refundType: "cash" | "credit" | "cash_or_credit" | "none" | null;
24
+ flatAmountCents: number | null;
25
+ label: string | null;
26
+ };
27
+ export type CancellationResult = {
28
+ refundPercent: number;
29
+ refundCents: number;
30
+ refundType: "cash" | "credit" | "cash_or_credit" | "none";
31
+ appliedRule: CancellationRule | null;
32
+ };
33
+ /**
34
+ * Evaluate a cancellation policy against a context. Rules are sorted descending
35
+ * by `daysBeforeDeparture`; the first rule whose threshold is satisfied by the
36
+ * input's `daysBeforeDeparture` is applied. `refundPercent` is expressed in
37
+ * basis points (0-10000 where 10000 = 100%).
38
+ */
39
+ export declare function evaluateCancellationPolicy(rules: CancellationRule[], input: EvaluateCancellationInput): CancellationResult;
40
+ export declare const policiesService: {
41
+ listPolicies(db: PostgresJsDatabase, query: PolicyListQuery): Promise<{
42
+ data: {
43
+ id: string;
44
+ kind: "other" | "cancellation" | "payment" | "terms_and_conditions" | "privacy" | "refund" | "commission" | "guarantee";
45
+ name: string;
46
+ slug: string;
47
+ description: string | null;
48
+ language: string;
49
+ currentVersionId: string | null;
50
+ metadata: unknown;
51
+ createdAt: Date;
52
+ updatedAt: Date;
53
+ }[];
54
+ total: number;
55
+ limit: number;
56
+ offset: number;
57
+ }>;
58
+ getPolicyById(db: PostgresJsDatabase, id: string): Promise<{
59
+ id: string;
60
+ kind: "other" | "cancellation" | "payment" | "terms_and_conditions" | "privacy" | "refund" | "commission" | "guarantee";
61
+ name: string;
62
+ slug: string;
63
+ description: string | null;
64
+ language: string;
65
+ currentVersionId: string | null;
66
+ metadata: unknown;
67
+ createdAt: Date;
68
+ updatedAt: Date;
69
+ } | null>;
70
+ getPolicyBySlug(db: PostgresJsDatabase, slug: string): Promise<{
71
+ id: string;
72
+ kind: "other" | "cancellation" | "payment" | "terms_and_conditions" | "privacy" | "refund" | "commission" | "guarantee";
73
+ name: string;
74
+ slug: string;
75
+ description: string | null;
76
+ language: string;
77
+ currentVersionId: string | null;
78
+ metadata: unknown;
79
+ createdAt: Date;
80
+ updatedAt: Date;
81
+ } | null>;
82
+ createPolicy(db: PostgresJsDatabase, data: CreatePolicyInput): Promise<{
83
+ id: string;
84
+ name: string;
85
+ createdAt: Date;
86
+ updatedAt: Date;
87
+ description: string | null;
88
+ kind: "other" | "cancellation" | "payment" | "terms_and_conditions" | "privacy" | "refund" | "commission" | "guarantee";
89
+ metadata: unknown;
90
+ slug: string;
91
+ language: string;
92
+ currentVersionId: string | null;
93
+ } | null>;
94
+ updatePolicy(db: PostgresJsDatabase, id: string, data: UpdatePolicyInput): Promise<{
95
+ id: string;
96
+ kind: "other" | "cancellation" | "payment" | "terms_and_conditions" | "privacy" | "refund" | "commission" | "guarantee";
97
+ name: string;
98
+ slug: string;
99
+ description: string | null;
100
+ language: string;
101
+ currentVersionId: string | null;
102
+ metadata: unknown;
103
+ createdAt: Date;
104
+ updatedAt: Date;
105
+ } | null>;
106
+ deletePolicy(db: PostgresJsDatabase, id: string): Promise<{
107
+ id: string;
108
+ } | null>;
109
+ listPolicyVersions(db: PostgresJsDatabase, policyId: string): Omit<import("drizzle-orm/pg-core").PgSelectBase<"policy_versions", {
110
+ id: import("drizzle-orm/pg-core").PgColumn<{
111
+ name: string;
112
+ tableName: "policy_versions";
113
+ dataType: "string";
114
+ columnType: "PgText";
115
+ data: string;
116
+ driverParam: string;
117
+ notNull: true;
118
+ hasDefault: true;
119
+ isPrimaryKey: true;
120
+ isAutoincrement: false;
121
+ hasRuntimeDefault: true;
122
+ enumValues: [string, ...string[]];
123
+ baseColumn: never;
124
+ identity: undefined;
125
+ generated: undefined;
126
+ }, {}, {}>;
127
+ policyId: import("drizzle-orm/pg-core").PgColumn<{
128
+ name: string;
129
+ tableName: "policy_versions";
130
+ dataType: "string";
131
+ columnType: "PgText";
132
+ data: string;
133
+ driverParam: string;
134
+ notNull: true;
135
+ hasDefault: false;
136
+ isPrimaryKey: false;
137
+ isAutoincrement: false;
138
+ hasRuntimeDefault: false;
139
+ enumValues: [string, ...string[]];
140
+ baseColumn: never;
141
+ identity: undefined;
142
+ generated: undefined;
143
+ }, {}, {}>;
144
+ version: import("drizzle-orm/pg-core").PgColumn<{
145
+ name: "version";
146
+ tableName: "policy_versions";
147
+ dataType: "number";
148
+ columnType: "PgInteger";
149
+ data: number;
150
+ driverParam: string | number;
151
+ notNull: true;
152
+ hasDefault: false;
153
+ isPrimaryKey: false;
154
+ isAutoincrement: false;
155
+ hasRuntimeDefault: false;
156
+ enumValues: undefined;
157
+ baseColumn: never;
158
+ identity: undefined;
159
+ generated: undefined;
160
+ }, {}, {}>;
161
+ status: import("drizzle-orm/pg-core").PgColumn<{
162
+ name: "status";
163
+ tableName: "policy_versions";
164
+ dataType: "string";
165
+ columnType: "PgEnumColumn";
166
+ data: "draft" | "published" | "retired";
167
+ driverParam: string;
168
+ notNull: true;
169
+ hasDefault: true;
170
+ isPrimaryKey: false;
171
+ isAutoincrement: false;
172
+ hasRuntimeDefault: false;
173
+ enumValues: ["draft", "published", "retired"];
174
+ baseColumn: never;
175
+ identity: undefined;
176
+ generated: undefined;
177
+ }, {}, {}>;
178
+ title: import("drizzle-orm/pg-core").PgColumn<{
179
+ name: "title";
180
+ tableName: "policy_versions";
181
+ dataType: "string";
182
+ columnType: "PgText";
183
+ data: string;
184
+ driverParam: string;
185
+ notNull: true;
186
+ hasDefault: false;
187
+ isPrimaryKey: false;
188
+ isAutoincrement: false;
189
+ hasRuntimeDefault: false;
190
+ enumValues: [string, ...string[]];
191
+ baseColumn: never;
192
+ identity: undefined;
193
+ generated: undefined;
194
+ }, {}, {}>;
195
+ bodyFormat: import("drizzle-orm/pg-core").PgColumn<{
196
+ name: "body_format";
197
+ tableName: "policy_versions";
198
+ dataType: "string";
199
+ columnType: "PgEnumColumn";
200
+ data: "markdown" | "html" | "plain";
201
+ driverParam: string;
202
+ notNull: true;
203
+ hasDefault: true;
204
+ isPrimaryKey: false;
205
+ isAutoincrement: false;
206
+ hasRuntimeDefault: false;
207
+ enumValues: ["markdown", "html", "plain"];
208
+ baseColumn: never;
209
+ identity: undefined;
210
+ generated: undefined;
211
+ }, {}, {}>;
212
+ body: import("drizzle-orm/pg-core").PgColumn<{
213
+ name: "body";
214
+ tableName: "policy_versions";
215
+ dataType: "string";
216
+ columnType: "PgText";
217
+ data: string;
218
+ driverParam: string;
219
+ notNull: false;
220
+ hasDefault: false;
221
+ isPrimaryKey: false;
222
+ isAutoincrement: false;
223
+ hasRuntimeDefault: false;
224
+ enumValues: [string, ...string[]];
225
+ baseColumn: never;
226
+ identity: undefined;
227
+ generated: undefined;
228
+ }, {}, {}>;
229
+ publishedAt: import("drizzle-orm/pg-core").PgColumn<{
230
+ name: "published_at";
231
+ tableName: "policy_versions";
232
+ dataType: "date";
233
+ columnType: "PgTimestamp";
234
+ data: Date;
235
+ driverParam: string;
236
+ notNull: false;
237
+ hasDefault: false;
238
+ isPrimaryKey: false;
239
+ isAutoincrement: false;
240
+ hasRuntimeDefault: false;
241
+ enumValues: undefined;
242
+ baseColumn: never;
243
+ identity: undefined;
244
+ generated: undefined;
245
+ }, {}, {}>;
246
+ publishedBy: import("drizzle-orm/pg-core").PgColumn<{
247
+ name: "published_by";
248
+ tableName: "policy_versions";
249
+ dataType: "string";
250
+ columnType: "PgText";
251
+ data: string;
252
+ driverParam: string;
253
+ notNull: false;
254
+ hasDefault: false;
255
+ isPrimaryKey: false;
256
+ isAutoincrement: false;
257
+ hasRuntimeDefault: false;
258
+ enumValues: [string, ...string[]];
259
+ baseColumn: never;
260
+ identity: undefined;
261
+ generated: undefined;
262
+ }, {}, {}>;
263
+ retiredAt: import("drizzle-orm/pg-core").PgColumn<{
264
+ name: "retired_at";
265
+ tableName: "policy_versions";
266
+ dataType: "date";
267
+ columnType: "PgTimestamp";
268
+ data: Date;
269
+ driverParam: string;
270
+ notNull: false;
271
+ hasDefault: false;
272
+ isPrimaryKey: false;
273
+ isAutoincrement: false;
274
+ hasRuntimeDefault: false;
275
+ enumValues: undefined;
276
+ baseColumn: never;
277
+ identity: undefined;
278
+ generated: undefined;
279
+ }, {}, {}>;
280
+ metadata: import("drizzle-orm/pg-core").PgColumn<{
281
+ name: "metadata";
282
+ tableName: "policy_versions";
283
+ dataType: "json";
284
+ columnType: "PgJsonb";
285
+ data: unknown;
286
+ driverParam: unknown;
287
+ notNull: false;
288
+ hasDefault: false;
289
+ isPrimaryKey: false;
290
+ isAutoincrement: false;
291
+ hasRuntimeDefault: false;
292
+ enumValues: undefined;
293
+ baseColumn: never;
294
+ identity: undefined;
295
+ generated: undefined;
296
+ }, {}, {}>;
297
+ createdAt: import("drizzle-orm/pg-core").PgColumn<{
298
+ name: "created_at";
299
+ tableName: "policy_versions";
300
+ dataType: "date";
301
+ columnType: "PgTimestamp";
302
+ data: Date;
303
+ driverParam: string;
304
+ notNull: true;
305
+ hasDefault: true;
306
+ isPrimaryKey: false;
307
+ isAutoincrement: false;
308
+ hasRuntimeDefault: false;
309
+ enumValues: undefined;
310
+ baseColumn: never;
311
+ identity: undefined;
312
+ generated: undefined;
313
+ }, {}, {}>;
314
+ updatedAt: import("drizzle-orm/pg-core").PgColumn<{
315
+ name: "updated_at";
316
+ tableName: "policy_versions";
317
+ dataType: "date";
318
+ columnType: "PgTimestamp";
319
+ data: Date;
320
+ driverParam: string;
321
+ notNull: true;
322
+ hasDefault: true;
323
+ isPrimaryKey: false;
324
+ isAutoincrement: false;
325
+ hasRuntimeDefault: false;
326
+ enumValues: undefined;
327
+ baseColumn: never;
328
+ identity: undefined;
329
+ generated: undefined;
330
+ }, {}, {}>;
331
+ }, "single", Record<"policy_versions", "not-null">, false, "where" | "orderBy", {
332
+ id: string;
333
+ policyId: string;
334
+ version: number;
335
+ status: "draft" | "published" | "retired";
336
+ title: string;
337
+ bodyFormat: "markdown" | "html" | "plain";
338
+ body: string | null;
339
+ publishedAt: Date | null;
340
+ publishedBy: string | null;
341
+ retiredAt: Date | null;
342
+ metadata: unknown;
343
+ createdAt: Date;
344
+ updatedAt: Date;
345
+ }[], {
346
+ id: import("drizzle-orm/pg-core").PgColumn<{
347
+ name: string;
348
+ tableName: "policy_versions";
349
+ dataType: "string";
350
+ columnType: "PgText";
351
+ data: string;
352
+ driverParam: string;
353
+ notNull: true;
354
+ hasDefault: true;
355
+ isPrimaryKey: true;
356
+ isAutoincrement: false;
357
+ hasRuntimeDefault: true;
358
+ enumValues: [string, ...string[]];
359
+ baseColumn: never;
360
+ identity: undefined;
361
+ generated: undefined;
362
+ }, {}, {}>;
363
+ policyId: import("drizzle-orm/pg-core").PgColumn<{
364
+ name: string;
365
+ tableName: "policy_versions";
366
+ dataType: "string";
367
+ columnType: "PgText";
368
+ data: string;
369
+ driverParam: string;
370
+ notNull: true;
371
+ hasDefault: false;
372
+ isPrimaryKey: false;
373
+ isAutoincrement: false;
374
+ hasRuntimeDefault: false;
375
+ enumValues: [string, ...string[]];
376
+ baseColumn: never;
377
+ identity: undefined;
378
+ generated: undefined;
379
+ }, {}, {}>;
380
+ version: import("drizzle-orm/pg-core").PgColumn<{
381
+ name: "version";
382
+ tableName: "policy_versions";
383
+ dataType: "number";
384
+ columnType: "PgInteger";
385
+ data: number;
386
+ driverParam: string | number;
387
+ notNull: true;
388
+ hasDefault: false;
389
+ isPrimaryKey: false;
390
+ isAutoincrement: false;
391
+ hasRuntimeDefault: false;
392
+ enumValues: undefined;
393
+ baseColumn: never;
394
+ identity: undefined;
395
+ generated: undefined;
396
+ }, {}, {}>;
397
+ status: import("drizzle-orm/pg-core").PgColumn<{
398
+ name: "status";
399
+ tableName: "policy_versions";
400
+ dataType: "string";
401
+ columnType: "PgEnumColumn";
402
+ data: "draft" | "published" | "retired";
403
+ driverParam: string;
404
+ notNull: true;
405
+ hasDefault: true;
406
+ isPrimaryKey: false;
407
+ isAutoincrement: false;
408
+ hasRuntimeDefault: false;
409
+ enumValues: ["draft", "published", "retired"];
410
+ baseColumn: never;
411
+ identity: undefined;
412
+ generated: undefined;
413
+ }, {}, {}>;
414
+ title: import("drizzle-orm/pg-core").PgColumn<{
415
+ name: "title";
416
+ tableName: "policy_versions";
417
+ dataType: "string";
418
+ columnType: "PgText";
419
+ data: string;
420
+ driverParam: string;
421
+ notNull: true;
422
+ hasDefault: false;
423
+ isPrimaryKey: false;
424
+ isAutoincrement: false;
425
+ hasRuntimeDefault: false;
426
+ enumValues: [string, ...string[]];
427
+ baseColumn: never;
428
+ identity: undefined;
429
+ generated: undefined;
430
+ }, {}, {}>;
431
+ bodyFormat: import("drizzle-orm/pg-core").PgColumn<{
432
+ name: "body_format";
433
+ tableName: "policy_versions";
434
+ dataType: "string";
435
+ columnType: "PgEnumColumn";
436
+ data: "markdown" | "html" | "plain";
437
+ driverParam: string;
438
+ notNull: true;
439
+ hasDefault: true;
440
+ isPrimaryKey: false;
441
+ isAutoincrement: false;
442
+ hasRuntimeDefault: false;
443
+ enumValues: ["markdown", "html", "plain"];
444
+ baseColumn: never;
445
+ identity: undefined;
446
+ generated: undefined;
447
+ }, {}, {}>;
448
+ body: import("drizzle-orm/pg-core").PgColumn<{
449
+ name: "body";
450
+ tableName: "policy_versions";
451
+ dataType: "string";
452
+ columnType: "PgText";
453
+ data: string;
454
+ driverParam: string;
455
+ notNull: false;
456
+ hasDefault: false;
457
+ isPrimaryKey: false;
458
+ isAutoincrement: false;
459
+ hasRuntimeDefault: false;
460
+ enumValues: [string, ...string[]];
461
+ baseColumn: never;
462
+ identity: undefined;
463
+ generated: undefined;
464
+ }, {}, {}>;
465
+ publishedAt: import("drizzle-orm/pg-core").PgColumn<{
466
+ name: "published_at";
467
+ tableName: "policy_versions";
468
+ dataType: "date";
469
+ columnType: "PgTimestamp";
470
+ data: Date;
471
+ driverParam: string;
472
+ notNull: false;
473
+ hasDefault: false;
474
+ isPrimaryKey: false;
475
+ isAutoincrement: false;
476
+ hasRuntimeDefault: false;
477
+ enumValues: undefined;
478
+ baseColumn: never;
479
+ identity: undefined;
480
+ generated: undefined;
481
+ }, {}, {}>;
482
+ publishedBy: import("drizzle-orm/pg-core").PgColumn<{
483
+ name: "published_by";
484
+ tableName: "policy_versions";
485
+ dataType: "string";
486
+ columnType: "PgText";
487
+ data: string;
488
+ driverParam: string;
489
+ notNull: false;
490
+ hasDefault: false;
491
+ isPrimaryKey: false;
492
+ isAutoincrement: false;
493
+ hasRuntimeDefault: false;
494
+ enumValues: [string, ...string[]];
495
+ baseColumn: never;
496
+ identity: undefined;
497
+ generated: undefined;
498
+ }, {}, {}>;
499
+ retiredAt: import("drizzle-orm/pg-core").PgColumn<{
500
+ name: "retired_at";
501
+ tableName: "policy_versions";
502
+ dataType: "date";
503
+ columnType: "PgTimestamp";
504
+ data: Date;
505
+ driverParam: string;
506
+ notNull: false;
507
+ hasDefault: false;
508
+ isPrimaryKey: false;
509
+ isAutoincrement: false;
510
+ hasRuntimeDefault: false;
511
+ enumValues: undefined;
512
+ baseColumn: never;
513
+ identity: undefined;
514
+ generated: undefined;
515
+ }, {}, {}>;
516
+ metadata: import("drizzle-orm/pg-core").PgColumn<{
517
+ name: "metadata";
518
+ tableName: "policy_versions";
519
+ dataType: "json";
520
+ columnType: "PgJsonb";
521
+ data: unknown;
522
+ driverParam: unknown;
523
+ notNull: false;
524
+ hasDefault: false;
525
+ isPrimaryKey: false;
526
+ isAutoincrement: false;
527
+ hasRuntimeDefault: false;
528
+ enumValues: undefined;
529
+ baseColumn: never;
530
+ identity: undefined;
531
+ generated: undefined;
532
+ }, {}, {}>;
533
+ createdAt: import("drizzle-orm/pg-core").PgColumn<{
534
+ name: "created_at";
535
+ tableName: "policy_versions";
536
+ dataType: "date";
537
+ columnType: "PgTimestamp";
538
+ data: Date;
539
+ driverParam: string;
540
+ notNull: true;
541
+ hasDefault: true;
542
+ isPrimaryKey: false;
543
+ isAutoincrement: false;
544
+ hasRuntimeDefault: false;
545
+ enumValues: undefined;
546
+ baseColumn: never;
547
+ identity: undefined;
548
+ generated: undefined;
549
+ }, {}, {}>;
550
+ updatedAt: import("drizzle-orm/pg-core").PgColumn<{
551
+ name: "updated_at";
552
+ tableName: "policy_versions";
553
+ dataType: "date";
554
+ columnType: "PgTimestamp";
555
+ data: Date;
556
+ driverParam: string;
557
+ notNull: true;
558
+ hasDefault: true;
559
+ isPrimaryKey: false;
560
+ isAutoincrement: false;
561
+ hasRuntimeDefault: false;
562
+ enumValues: undefined;
563
+ baseColumn: never;
564
+ identity: undefined;
565
+ generated: undefined;
566
+ }, {}, {}>;
567
+ }>, "where" | "orderBy">;
568
+ getPolicyVersionById(db: PostgresJsDatabase, id: string): Promise<{
569
+ id: string;
570
+ policyId: string;
571
+ version: number;
572
+ status: "draft" | "published" | "retired";
573
+ title: string;
574
+ bodyFormat: "markdown" | "html" | "plain";
575
+ body: string | null;
576
+ publishedAt: Date | null;
577
+ publishedBy: string | null;
578
+ retiredAt: Date | null;
579
+ metadata: unknown;
580
+ createdAt: Date;
581
+ updatedAt: Date;
582
+ } | null>;
583
+ createPolicyVersion(db: PostgresJsDatabase, policyId: string, data: CreatePolicyVersionInput): Promise<{
584
+ id: string;
585
+ status: "draft" | "published" | "retired";
586
+ createdAt: Date;
587
+ updatedAt: Date;
588
+ title: string;
589
+ metadata: unknown;
590
+ bodyFormat: "markdown" | "html" | "plain";
591
+ body: string | null;
592
+ version: number;
593
+ policyId: string;
594
+ publishedAt: Date | null;
595
+ publishedBy: string | null;
596
+ retiredAt: Date | null;
597
+ } | null>;
598
+ updatePolicyVersion(db: PostgresJsDatabase, versionId: string, data: UpdatePolicyVersionInput): Promise<{
599
+ id: string;
600
+ policyId: string;
601
+ version: number;
602
+ status: "draft" | "published" | "retired";
603
+ title: string;
604
+ bodyFormat: "markdown" | "html" | "plain";
605
+ body: string | null;
606
+ publishedAt: Date | null;
607
+ publishedBy: string | null;
608
+ retiredAt: Date | null;
609
+ metadata: unknown;
610
+ createdAt: Date;
611
+ updatedAt: Date;
612
+ } | null>;
613
+ /**
614
+ * Publish a draft version: retires any currently-published version of the
615
+ * same policy, marks the target as published, updates `policies.currentVersionId`.
616
+ */
617
+ publishPolicyVersion(db: PostgresJsDatabase, versionId: string): Promise<{
618
+ status: "not_found";
619
+ version?: undefined;
620
+ } | {
621
+ status: "not_draft";
622
+ version?: undefined;
623
+ } | {
624
+ status: "published";
625
+ version: {
626
+ id: string;
627
+ policyId: string;
628
+ version: number;
629
+ status: "draft" | "published" | "retired";
630
+ title: string;
631
+ bodyFormat: "markdown" | "html" | "plain";
632
+ body: string | null;
633
+ publishedAt: Date | null;
634
+ publishedBy: string | null;
635
+ retiredAt: Date | null;
636
+ metadata: unknown;
637
+ createdAt: Date;
638
+ updatedAt: Date;
639
+ } | null;
640
+ }>;
641
+ retirePolicyVersion(db: PostgresJsDatabase, versionId: string): Promise<{
642
+ id: string;
643
+ policyId: string;
644
+ version: number;
645
+ status: "draft" | "published" | "retired";
646
+ title: string;
647
+ bodyFormat: "markdown" | "html" | "plain";
648
+ body: string | null;
649
+ publishedAt: Date | null;
650
+ publishedBy: string | null;
651
+ retiredAt: Date | null;
652
+ metadata: unknown;
653
+ createdAt: Date;
654
+ updatedAt: Date;
655
+ } | null>;
656
+ listPolicyRules(db: PostgresJsDatabase, versionId: string): Omit<import("drizzle-orm/pg-core").PgSelectBase<"policy_rules", {
657
+ id: import("drizzle-orm/pg-core").PgColumn<{
658
+ name: string;
659
+ tableName: "policy_rules";
660
+ dataType: "string";
661
+ columnType: "PgText";
662
+ data: string;
663
+ driverParam: string;
664
+ notNull: true;
665
+ hasDefault: true;
666
+ isPrimaryKey: true;
667
+ isAutoincrement: false;
668
+ hasRuntimeDefault: true;
669
+ enumValues: [string, ...string[]];
670
+ baseColumn: never;
671
+ identity: undefined;
672
+ generated: undefined;
673
+ }, {}, {}>;
674
+ policyVersionId: import("drizzle-orm/pg-core").PgColumn<{
675
+ name: string;
676
+ tableName: "policy_rules";
677
+ dataType: "string";
678
+ columnType: "PgText";
679
+ data: string;
680
+ driverParam: string;
681
+ notNull: true;
682
+ hasDefault: false;
683
+ isPrimaryKey: false;
684
+ isAutoincrement: false;
685
+ hasRuntimeDefault: false;
686
+ enumValues: [string, ...string[]];
687
+ baseColumn: never;
688
+ identity: undefined;
689
+ generated: undefined;
690
+ }, {}, {}>;
691
+ ruleType: import("drizzle-orm/pg-core").PgColumn<{
692
+ name: "rule_type";
693
+ tableName: "policy_rules";
694
+ dataType: "string";
695
+ columnType: "PgEnumColumn";
696
+ data: "custom" | "window" | "percentage" | "flat_amount" | "date_range";
697
+ driverParam: string;
698
+ notNull: true;
699
+ hasDefault: false;
700
+ isPrimaryKey: false;
701
+ isAutoincrement: false;
702
+ hasRuntimeDefault: false;
703
+ enumValues: ["window", "percentage", "flat_amount", "date_range", "custom"];
704
+ baseColumn: never;
705
+ identity: undefined;
706
+ generated: undefined;
707
+ }, {}, {}>;
708
+ label: import("drizzle-orm/pg-core").PgColumn<{
709
+ name: "label";
710
+ tableName: "policy_rules";
711
+ dataType: "string";
712
+ columnType: "PgText";
713
+ data: string;
714
+ driverParam: string;
715
+ notNull: false;
716
+ hasDefault: false;
717
+ isPrimaryKey: false;
718
+ isAutoincrement: false;
719
+ hasRuntimeDefault: false;
720
+ enumValues: [string, ...string[]];
721
+ baseColumn: never;
722
+ identity: undefined;
723
+ generated: undefined;
724
+ }, {}, {}>;
725
+ daysBeforeDeparture: import("drizzle-orm/pg-core").PgColumn<{
726
+ name: "days_before_departure";
727
+ tableName: "policy_rules";
728
+ dataType: "number";
729
+ columnType: "PgInteger";
730
+ data: number;
731
+ driverParam: string | number;
732
+ notNull: false;
733
+ hasDefault: false;
734
+ isPrimaryKey: false;
735
+ isAutoincrement: false;
736
+ hasRuntimeDefault: false;
737
+ enumValues: undefined;
738
+ baseColumn: never;
739
+ identity: undefined;
740
+ generated: undefined;
741
+ }, {}, {}>;
742
+ refundPercent: import("drizzle-orm/pg-core").PgColumn<{
743
+ name: "refund_percent";
744
+ tableName: "policy_rules";
745
+ dataType: "number";
746
+ columnType: "PgInteger";
747
+ data: number;
748
+ driverParam: string | number;
749
+ notNull: false;
750
+ hasDefault: false;
751
+ isPrimaryKey: false;
752
+ isAutoincrement: false;
753
+ hasRuntimeDefault: false;
754
+ enumValues: undefined;
755
+ baseColumn: never;
756
+ identity: undefined;
757
+ generated: undefined;
758
+ }, {}, {}>;
759
+ refundType: import("drizzle-orm/pg-core").PgColumn<{
760
+ name: "refund_type";
761
+ tableName: "policy_rules";
762
+ dataType: "string";
763
+ columnType: "PgEnumColumn";
764
+ data: "cash" | "credit" | "cash_or_credit" | "none";
765
+ driverParam: string;
766
+ notNull: false;
767
+ hasDefault: false;
768
+ isPrimaryKey: false;
769
+ isAutoincrement: false;
770
+ hasRuntimeDefault: false;
771
+ enumValues: ["cash", "credit", "cash_or_credit", "none"];
772
+ baseColumn: never;
773
+ identity: undefined;
774
+ generated: undefined;
775
+ }, {}, {}>;
776
+ flatAmountCents: import("drizzle-orm/pg-core").PgColumn<{
777
+ name: "flat_amount_cents";
778
+ tableName: "policy_rules";
779
+ dataType: "number";
780
+ columnType: "PgInteger";
781
+ data: number;
782
+ driverParam: string | number;
783
+ notNull: false;
784
+ hasDefault: false;
785
+ isPrimaryKey: false;
786
+ isAutoincrement: false;
787
+ hasRuntimeDefault: false;
788
+ enumValues: undefined;
789
+ baseColumn: never;
790
+ identity: undefined;
791
+ generated: undefined;
792
+ }, {}, {}>;
793
+ currency: import("drizzle-orm/pg-core").PgColumn<{
794
+ name: "currency";
795
+ tableName: "policy_rules";
796
+ dataType: "string";
797
+ columnType: "PgText";
798
+ data: string;
799
+ driverParam: string;
800
+ notNull: false;
801
+ hasDefault: false;
802
+ isPrimaryKey: false;
803
+ isAutoincrement: false;
804
+ hasRuntimeDefault: false;
805
+ enumValues: [string, ...string[]];
806
+ baseColumn: never;
807
+ identity: undefined;
808
+ generated: undefined;
809
+ }, {}, {}>;
810
+ validFrom: import("drizzle-orm/pg-core").PgColumn<{
811
+ name: "valid_from";
812
+ tableName: "policy_rules";
813
+ dataType: "string";
814
+ columnType: "PgDateString";
815
+ data: string;
816
+ driverParam: string;
817
+ notNull: false;
818
+ hasDefault: false;
819
+ isPrimaryKey: false;
820
+ isAutoincrement: false;
821
+ hasRuntimeDefault: false;
822
+ enumValues: undefined;
823
+ baseColumn: never;
824
+ identity: undefined;
825
+ generated: undefined;
826
+ }, {}, {}>;
827
+ validTo: import("drizzle-orm/pg-core").PgColumn<{
828
+ name: "valid_to";
829
+ tableName: "policy_rules";
830
+ dataType: "string";
831
+ columnType: "PgDateString";
832
+ data: string;
833
+ driverParam: string;
834
+ notNull: false;
835
+ hasDefault: false;
836
+ isPrimaryKey: false;
837
+ isAutoincrement: false;
838
+ hasRuntimeDefault: false;
839
+ enumValues: undefined;
840
+ baseColumn: never;
841
+ identity: undefined;
842
+ generated: undefined;
843
+ }, {}, {}>;
844
+ conditions: import("drizzle-orm/pg-core").PgColumn<{
845
+ name: "conditions";
846
+ tableName: "policy_rules";
847
+ dataType: "json";
848
+ columnType: "PgJsonb";
849
+ data: unknown;
850
+ driverParam: unknown;
851
+ notNull: false;
852
+ hasDefault: false;
853
+ isPrimaryKey: false;
854
+ isAutoincrement: false;
855
+ hasRuntimeDefault: false;
856
+ enumValues: undefined;
857
+ baseColumn: never;
858
+ identity: undefined;
859
+ generated: undefined;
860
+ }, {}, {}>;
861
+ sortOrder: import("drizzle-orm/pg-core").PgColumn<{
862
+ name: "sort_order";
863
+ tableName: "policy_rules";
864
+ dataType: "number";
865
+ columnType: "PgInteger";
866
+ data: number;
867
+ driverParam: string | number;
868
+ notNull: true;
869
+ hasDefault: true;
870
+ isPrimaryKey: false;
871
+ isAutoincrement: false;
872
+ hasRuntimeDefault: false;
873
+ enumValues: undefined;
874
+ baseColumn: never;
875
+ identity: undefined;
876
+ generated: undefined;
877
+ }, {}, {}>;
878
+ createdAt: import("drizzle-orm/pg-core").PgColumn<{
879
+ name: "created_at";
880
+ tableName: "policy_rules";
881
+ dataType: "date";
882
+ columnType: "PgTimestamp";
883
+ data: Date;
884
+ driverParam: string;
885
+ notNull: true;
886
+ hasDefault: true;
887
+ isPrimaryKey: false;
888
+ isAutoincrement: false;
889
+ hasRuntimeDefault: false;
890
+ enumValues: undefined;
891
+ baseColumn: never;
892
+ identity: undefined;
893
+ generated: undefined;
894
+ }, {}, {}>;
895
+ updatedAt: import("drizzle-orm/pg-core").PgColumn<{
896
+ name: "updated_at";
897
+ tableName: "policy_rules";
898
+ dataType: "date";
899
+ columnType: "PgTimestamp";
900
+ data: Date;
901
+ driverParam: string;
902
+ notNull: true;
903
+ hasDefault: true;
904
+ isPrimaryKey: false;
905
+ isAutoincrement: false;
906
+ hasRuntimeDefault: false;
907
+ enumValues: undefined;
908
+ baseColumn: never;
909
+ identity: undefined;
910
+ generated: undefined;
911
+ }, {}, {}>;
912
+ }, "single", Record<"policy_rules", "not-null">, false, "where" | "orderBy", {
913
+ id: string;
914
+ policyVersionId: string;
915
+ ruleType: "custom" | "window" | "percentage" | "flat_amount" | "date_range";
916
+ label: string | null;
917
+ daysBeforeDeparture: number | null;
918
+ refundPercent: number | null;
919
+ refundType: "cash" | "credit" | "cash_or_credit" | "none" | null;
920
+ flatAmountCents: number | null;
921
+ currency: string | null;
922
+ validFrom: string | null;
923
+ validTo: string | null;
924
+ conditions: unknown;
925
+ sortOrder: number;
926
+ createdAt: Date;
927
+ updatedAt: Date;
928
+ }[], {
929
+ id: import("drizzle-orm/pg-core").PgColumn<{
930
+ name: string;
931
+ tableName: "policy_rules";
932
+ dataType: "string";
933
+ columnType: "PgText";
934
+ data: string;
935
+ driverParam: string;
936
+ notNull: true;
937
+ hasDefault: true;
938
+ isPrimaryKey: true;
939
+ isAutoincrement: false;
940
+ hasRuntimeDefault: true;
941
+ enumValues: [string, ...string[]];
942
+ baseColumn: never;
943
+ identity: undefined;
944
+ generated: undefined;
945
+ }, {}, {}>;
946
+ policyVersionId: import("drizzle-orm/pg-core").PgColumn<{
947
+ name: string;
948
+ tableName: "policy_rules";
949
+ dataType: "string";
950
+ columnType: "PgText";
951
+ data: string;
952
+ driverParam: string;
953
+ notNull: true;
954
+ hasDefault: false;
955
+ isPrimaryKey: false;
956
+ isAutoincrement: false;
957
+ hasRuntimeDefault: false;
958
+ enumValues: [string, ...string[]];
959
+ baseColumn: never;
960
+ identity: undefined;
961
+ generated: undefined;
962
+ }, {}, {}>;
963
+ ruleType: import("drizzle-orm/pg-core").PgColumn<{
964
+ name: "rule_type";
965
+ tableName: "policy_rules";
966
+ dataType: "string";
967
+ columnType: "PgEnumColumn";
968
+ data: "custom" | "window" | "percentage" | "flat_amount" | "date_range";
969
+ driverParam: string;
970
+ notNull: true;
971
+ hasDefault: false;
972
+ isPrimaryKey: false;
973
+ isAutoincrement: false;
974
+ hasRuntimeDefault: false;
975
+ enumValues: ["window", "percentage", "flat_amount", "date_range", "custom"];
976
+ baseColumn: never;
977
+ identity: undefined;
978
+ generated: undefined;
979
+ }, {}, {}>;
980
+ label: import("drizzle-orm/pg-core").PgColumn<{
981
+ name: "label";
982
+ tableName: "policy_rules";
983
+ dataType: "string";
984
+ columnType: "PgText";
985
+ data: string;
986
+ driverParam: string;
987
+ notNull: false;
988
+ hasDefault: false;
989
+ isPrimaryKey: false;
990
+ isAutoincrement: false;
991
+ hasRuntimeDefault: false;
992
+ enumValues: [string, ...string[]];
993
+ baseColumn: never;
994
+ identity: undefined;
995
+ generated: undefined;
996
+ }, {}, {}>;
997
+ daysBeforeDeparture: import("drizzle-orm/pg-core").PgColumn<{
998
+ name: "days_before_departure";
999
+ tableName: "policy_rules";
1000
+ dataType: "number";
1001
+ columnType: "PgInteger";
1002
+ data: number;
1003
+ driverParam: string | number;
1004
+ notNull: false;
1005
+ hasDefault: false;
1006
+ isPrimaryKey: false;
1007
+ isAutoincrement: false;
1008
+ hasRuntimeDefault: false;
1009
+ enumValues: undefined;
1010
+ baseColumn: never;
1011
+ identity: undefined;
1012
+ generated: undefined;
1013
+ }, {}, {}>;
1014
+ refundPercent: import("drizzle-orm/pg-core").PgColumn<{
1015
+ name: "refund_percent";
1016
+ tableName: "policy_rules";
1017
+ dataType: "number";
1018
+ columnType: "PgInteger";
1019
+ data: number;
1020
+ driverParam: string | number;
1021
+ notNull: false;
1022
+ hasDefault: false;
1023
+ isPrimaryKey: false;
1024
+ isAutoincrement: false;
1025
+ hasRuntimeDefault: false;
1026
+ enumValues: undefined;
1027
+ baseColumn: never;
1028
+ identity: undefined;
1029
+ generated: undefined;
1030
+ }, {}, {}>;
1031
+ refundType: import("drizzle-orm/pg-core").PgColumn<{
1032
+ name: "refund_type";
1033
+ tableName: "policy_rules";
1034
+ dataType: "string";
1035
+ columnType: "PgEnumColumn";
1036
+ data: "cash" | "credit" | "cash_or_credit" | "none";
1037
+ driverParam: string;
1038
+ notNull: false;
1039
+ hasDefault: false;
1040
+ isPrimaryKey: false;
1041
+ isAutoincrement: false;
1042
+ hasRuntimeDefault: false;
1043
+ enumValues: ["cash", "credit", "cash_or_credit", "none"];
1044
+ baseColumn: never;
1045
+ identity: undefined;
1046
+ generated: undefined;
1047
+ }, {}, {}>;
1048
+ flatAmountCents: import("drizzle-orm/pg-core").PgColumn<{
1049
+ name: "flat_amount_cents";
1050
+ tableName: "policy_rules";
1051
+ dataType: "number";
1052
+ columnType: "PgInteger";
1053
+ data: number;
1054
+ driverParam: string | number;
1055
+ notNull: false;
1056
+ hasDefault: false;
1057
+ isPrimaryKey: false;
1058
+ isAutoincrement: false;
1059
+ hasRuntimeDefault: false;
1060
+ enumValues: undefined;
1061
+ baseColumn: never;
1062
+ identity: undefined;
1063
+ generated: undefined;
1064
+ }, {}, {}>;
1065
+ currency: import("drizzle-orm/pg-core").PgColumn<{
1066
+ name: "currency";
1067
+ tableName: "policy_rules";
1068
+ dataType: "string";
1069
+ columnType: "PgText";
1070
+ data: string;
1071
+ driverParam: string;
1072
+ notNull: false;
1073
+ hasDefault: false;
1074
+ isPrimaryKey: false;
1075
+ isAutoincrement: false;
1076
+ hasRuntimeDefault: false;
1077
+ enumValues: [string, ...string[]];
1078
+ baseColumn: never;
1079
+ identity: undefined;
1080
+ generated: undefined;
1081
+ }, {}, {}>;
1082
+ validFrom: import("drizzle-orm/pg-core").PgColumn<{
1083
+ name: "valid_from";
1084
+ tableName: "policy_rules";
1085
+ dataType: "string";
1086
+ columnType: "PgDateString";
1087
+ data: string;
1088
+ driverParam: string;
1089
+ notNull: false;
1090
+ hasDefault: false;
1091
+ isPrimaryKey: false;
1092
+ isAutoincrement: false;
1093
+ hasRuntimeDefault: false;
1094
+ enumValues: undefined;
1095
+ baseColumn: never;
1096
+ identity: undefined;
1097
+ generated: undefined;
1098
+ }, {}, {}>;
1099
+ validTo: import("drizzle-orm/pg-core").PgColumn<{
1100
+ name: "valid_to";
1101
+ tableName: "policy_rules";
1102
+ dataType: "string";
1103
+ columnType: "PgDateString";
1104
+ data: string;
1105
+ driverParam: string;
1106
+ notNull: false;
1107
+ hasDefault: false;
1108
+ isPrimaryKey: false;
1109
+ isAutoincrement: false;
1110
+ hasRuntimeDefault: false;
1111
+ enumValues: undefined;
1112
+ baseColumn: never;
1113
+ identity: undefined;
1114
+ generated: undefined;
1115
+ }, {}, {}>;
1116
+ conditions: import("drizzle-orm/pg-core").PgColumn<{
1117
+ name: "conditions";
1118
+ tableName: "policy_rules";
1119
+ dataType: "json";
1120
+ columnType: "PgJsonb";
1121
+ data: unknown;
1122
+ driverParam: unknown;
1123
+ notNull: false;
1124
+ hasDefault: false;
1125
+ isPrimaryKey: false;
1126
+ isAutoincrement: false;
1127
+ hasRuntimeDefault: false;
1128
+ enumValues: undefined;
1129
+ baseColumn: never;
1130
+ identity: undefined;
1131
+ generated: undefined;
1132
+ }, {}, {}>;
1133
+ sortOrder: import("drizzle-orm/pg-core").PgColumn<{
1134
+ name: "sort_order";
1135
+ tableName: "policy_rules";
1136
+ dataType: "number";
1137
+ columnType: "PgInteger";
1138
+ data: number;
1139
+ driverParam: string | number;
1140
+ notNull: true;
1141
+ hasDefault: true;
1142
+ isPrimaryKey: false;
1143
+ isAutoincrement: false;
1144
+ hasRuntimeDefault: false;
1145
+ enumValues: undefined;
1146
+ baseColumn: never;
1147
+ identity: undefined;
1148
+ generated: undefined;
1149
+ }, {}, {}>;
1150
+ createdAt: import("drizzle-orm/pg-core").PgColumn<{
1151
+ name: "created_at";
1152
+ tableName: "policy_rules";
1153
+ dataType: "date";
1154
+ columnType: "PgTimestamp";
1155
+ data: Date;
1156
+ driverParam: string;
1157
+ notNull: true;
1158
+ hasDefault: true;
1159
+ isPrimaryKey: false;
1160
+ isAutoincrement: false;
1161
+ hasRuntimeDefault: false;
1162
+ enumValues: undefined;
1163
+ baseColumn: never;
1164
+ identity: undefined;
1165
+ generated: undefined;
1166
+ }, {}, {}>;
1167
+ updatedAt: import("drizzle-orm/pg-core").PgColumn<{
1168
+ name: "updated_at";
1169
+ tableName: "policy_rules";
1170
+ dataType: "date";
1171
+ columnType: "PgTimestamp";
1172
+ data: Date;
1173
+ driverParam: string;
1174
+ notNull: true;
1175
+ hasDefault: true;
1176
+ isPrimaryKey: false;
1177
+ isAutoincrement: false;
1178
+ hasRuntimeDefault: false;
1179
+ enumValues: undefined;
1180
+ baseColumn: never;
1181
+ identity: undefined;
1182
+ generated: undefined;
1183
+ }, {}, {}>;
1184
+ }>, "where" | "orderBy">;
1185
+ createPolicyRule(db: PostgresJsDatabase, versionId: string, data: CreatePolicyRuleInput): Promise<{
1186
+ id: string;
1187
+ createdAt: Date;
1188
+ updatedAt: Date;
1189
+ sortOrder: number;
1190
+ currency: string | null;
1191
+ label: string | null;
1192
+ conditions: unknown;
1193
+ validFrom: string | null;
1194
+ validTo: string | null;
1195
+ policyVersionId: string;
1196
+ ruleType: "custom" | "window" | "percentage" | "flat_amount" | "date_range";
1197
+ daysBeforeDeparture: number | null;
1198
+ refundPercent: number | null;
1199
+ refundType: "cash" | "credit" | "cash_or_credit" | "none" | null;
1200
+ flatAmountCents: number | null;
1201
+ } | null>;
1202
+ updatePolicyRule(db: PostgresJsDatabase, ruleId: string, data: UpdatePolicyRuleInput): Promise<{
1203
+ id: string;
1204
+ policyVersionId: string;
1205
+ ruleType: "custom" | "window" | "percentage" | "flat_amount" | "date_range";
1206
+ label: string | null;
1207
+ daysBeforeDeparture: number | null;
1208
+ refundPercent: number | null;
1209
+ refundType: "cash" | "credit" | "cash_or_credit" | "none" | null;
1210
+ flatAmountCents: number | null;
1211
+ currency: string | null;
1212
+ validFrom: string | null;
1213
+ validTo: string | null;
1214
+ conditions: unknown;
1215
+ sortOrder: number;
1216
+ createdAt: Date;
1217
+ updatedAt: Date;
1218
+ } | null>;
1219
+ deletePolicyRule(db: PostgresJsDatabase, ruleId: string): Promise<{
1220
+ id: string;
1221
+ } | null>;
1222
+ listPolicyAssignments(db: PostgresJsDatabase, query: PolicyAssignmentListQuery): Promise<{
1223
+ data: {
1224
+ id: string;
1225
+ policyId: string;
1226
+ scope: "supplier" | "organization" | "channel" | "product" | "market" | "global";
1227
+ productId: string | null;
1228
+ channelId: string | null;
1229
+ supplierId: string | null;
1230
+ marketId: string | null;
1231
+ organizationId: string | null;
1232
+ validFrom: string | null;
1233
+ validTo: string | null;
1234
+ priority: number;
1235
+ metadata: unknown;
1236
+ createdAt: Date;
1237
+ updatedAt: Date;
1238
+ }[];
1239
+ total: number;
1240
+ limit: number;
1241
+ offset: number;
1242
+ }>;
1243
+ createPolicyAssignment(db: PostgresJsDatabase, data: CreatePolicyAssignmentInput): Promise<{
1244
+ id: string;
1245
+ createdAt: Date;
1246
+ updatedAt: Date;
1247
+ organizationId: string | null;
1248
+ productId: string | null;
1249
+ metadata: unknown;
1250
+ validFrom: string | null;
1251
+ validTo: string | null;
1252
+ supplierId: string | null;
1253
+ scope: "supplier" | "organization" | "channel" | "product" | "market" | "global";
1254
+ channelId: string | null;
1255
+ policyId: string;
1256
+ marketId: string | null;
1257
+ priority: number;
1258
+ } | null>;
1259
+ updatePolicyAssignment(db: PostgresJsDatabase, id: string, data: UpdatePolicyAssignmentInput): Promise<{
1260
+ id: string;
1261
+ policyId: string;
1262
+ scope: "supplier" | "organization" | "channel" | "product" | "market" | "global";
1263
+ productId: string | null;
1264
+ channelId: string | null;
1265
+ supplierId: string | null;
1266
+ marketId: string | null;
1267
+ organizationId: string | null;
1268
+ validFrom: string | null;
1269
+ validTo: string | null;
1270
+ priority: number;
1271
+ metadata: unknown;
1272
+ createdAt: Date;
1273
+ updatedAt: Date;
1274
+ } | null>;
1275
+ deletePolicyAssignment(db: PostgresJsDatabase, id: string): Promise<{
1276
+ id: string;
1277
+ } | null>;
1278
+ /**
1279
+ * Resolve the best-matching policy for a context. Matches candidate
1280
+ * assignments on scope column values and (optional) validity window, then
1281
+ * picks the highest-priority one for the requested policy kind.
1282
+ */
1283
+ resolvePolicy(db: PostgresJsDatabase, input: ResolvePolicyInput): Promise<{
1284
+ policy: {
1285
+ id: string;
1286
+ kind: "other" | "cancellation" | "payment" | "terms_and_conditions" | "privacy" | "refund" | "commission" | "guarantee";
1287
+ name: string;
1288
+ slug: string;
1289
+ description: string | null;
1290
+ language: string;
1291
+ currentVersionId: string | null;
1292
+ metadata: unknown;
1293
+ createdAt: Date;
1294
+ updatedAt: Date;
1295
+ };
1296
+ assignment: {
1297
+ id: string;
1298
+ policyId: string;
1299
+ scope: "supplier" | "organization" | "channel" | "product" | "market" | "global";
1300
+ productId: string | null;
1301
+ channelId: string | null;
1302
+ supplierId: string | null;
1303
+ marketId: string | null;
1304
+ organizationId: string | null;
1305
+ validFrom: string | null;
1306
+ validTo: string | null;
1307
+ priority: number;
1308
+ metadata: unknown;
1309
+ createdAt: Date;
1310
+ updatedAt: Date;
1311
+ };
1312
+ version: {
1313
+ id: string;
1314
+ policyId: string;
1315
+ version: number;
1316
+ status: "draft" | "published" | "retired";
1317
+ title: string;
1318
+ bodyFormat: "markdown" | "html" | "plain";
1319
+ body: string | null;
1320
+ publishedAt: Date | null;
1321
+ publishedBy: string | null;
1322
+ retiredAt: Date | null;
1323
+ metadata: unknown;
1324
+ createdAt: Date;
1325
+ updatedAt: Date;
1326
+ } | null;
1327
+ rules: {
1328
+ id: string;
1329
+ policyVersionId: string;
1330
+ ruleType: "custom" | "window" | "percentage" | "flat_amount" | "date_range";
1331
+ label: string | null;
1332
+ daysBeforeDeparture: number | null;
1333
+ refundPercent: number | null;
1334
+ refundType: "cash" | "credit" | "cash_or_credit" | "none" | null;
1335
+ flatAmountCents: number | null;
1336
+ currency: string | null;
1337
+ validFrom: string | null;
1338
+ validTo: string | null;
1339
+ conditions: unknown;
1340
+ sortOrder: number;
1341
+ createdAt: Date;
1342
+ updatedAt: Date;
1343
+ }[];
1344
+ } | null>;
1345
+ evaluateCancellation(db: PostgresJsDatabase, policyId: string, input: EvaluateCancellationInput): Promise<CancellationResult | null>;
1346
+ listPolicyAcceptances(db: PostgresJsDatabase, query: PolicyAcceptanceListQuery): Promise<{
1347
+ data: {
1348
+ id: string;
1349
+ policyVersionId: string;
1350
+ personId: string | null;
1351
+ bookingId: string | null;
1352
+ orderId: string | null;
1353
+ offerId: string | null;
1354
+ acceptedAt: Date;
1355
+ acceptedBy: string | null;
1356
+ method: "signature" | "implicit" | "explicit_checkbox";
1357
+ ipAddress: string | null;
1358
+ userAgent: string | null;
1359
+ metadata: unknown;
1360
+ createdAt: Date;
1361
+ }[];
1362
+ total: number;
1363
+ limit: number;
1364
+ offset: number;
1365
+ }>;
1366
+ recordPolicyAcceptance(db: PostgresJsDatabase, data: CreatePolicyAcceptanceInput): Promise<{
1367
+ id: string;
1368
+ createdAt: Date;
1369
+ personId: string | null;
1370
+ metadata: unknown;
1371
+ bookingId: string | null;
1372
+ orderId: string | null;
1373
+ method: "signature" | "implicit" | "explicit_checkbox";
1374
+ ipAddress: string | null;
1375
+ userAgent: string | null;
1376
+ policyVersionId: string;
1377
+ offerId: string | null;
1378
+ acceptedAt: Date;
1379
+ acceptedBy: string | null;
1380
+ } | null>;
1381
+ };
1382
+ export declare const _unused: typeof inArray;
1383
+ export {};
1384
+ //# sourceMappingURL=service.d.ts.map