@voyant-travel/legal 0.119.2

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 (105) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +112 -0
  3. package/dist/contracts/index.d.ts +22 -0
  4. package/dist/contracts/index.d.ts.map +1 -0
  5. package/dist/contracts/index.js +24 -0
  6. package/dist/contracts/lifecycle.d.ts +66 -0
  7. package/dist/contracts/lifecycle.d.ts.map +1 -0
  8. package/dist/contracts/lifecycle.js +93 -0
  9. package/dist/contracts/route-runtime.d.ts +17 -0
  10. package/dist/contracts/route-runtime.d.ts.map +1 -0
  11. package/dist/contracts/route-runtime.js +12 -0
  12. package/dist/contracts/route-template-preview.d.ts +19 -0
  13. package/dist/contracts/route-template-preview.d.ts.map +1 -0
  14. package/dist/contracts/route-template-preview.js +20 -0
  15. package/dist/contracts/routes.d.ts +4671 -0
  16. package/dist/contracts/routes.d.ts.map +1 -0
  17. package/dist/contracts/routes.js +611 -0
  18. package/dist/contracts/schema.d.ts +1882 -0
  19. package/dist/contracts/schema.d.ts.map +1 -0
  20. package/dist/contracts/schema.js +298 -0
  21. package/dist/contracts/service-auto-generate-types.d.ts +395 -0
  22. package/dist/contracts/service-auto-generate-types.d.ts.map +1 -0
  23. package/dist/contracts/service-auto-generate-types.js +1 -0
  24. package/dist/contracts/service-auto-generate-variables.d.ts +9 -0
  25. package/dist/contracts/service-auto-generate-variables.d.ts.map +1 -0
  26. package/dist/contracts/service-auto-generate-variables.js +683 -0
  27. package/dist/contracts/service-auto-generate.d.ts +31 -0
  28. package/dist/contracts/service-auto-generate.d.ts.map +1 -0
  29. package/dist/contracts/service-auto-generate.js +236 -0
  30. package/dist/contracts/service-contracts.d.ts +1804 -0
  31. package/dist/contracts/service-contracts.d.ts.map +1 -0
  32. package/dist/contracts/service-contracts.js +411 -0
  33. package/dist/contracts/service-documents-browser.d.ts +132 -0
  34. package/dist/contracts/service-documents-browser.d.ts.map +1 -0
  35. package/dist/contracts/service-documents-browser.js +145 -0
  36. package/dist/contracts/service-documents.d.ts +81 -0
  37. package/dist/contracts/service-documents.d.ts.map +1 -0
  38. package/dist/contracts/service-documents.js +358 -0
  39. package/dist/contracts/service-series.d.ts +191 -0
  40. package/dist/contracts/service-series.d.ts.map +1 -0
  41. package/dist/contracts/service-series.js +188 -0
  42. package/dist/contracts/service-shared.d.ts +42 -0
  43. package/dist/contracts/service-shared.d.ts.map +1 -0
  44. package/dist/contracts/service-shared.js +194 -0
  45. package/dist/contracts/service-templates.d.ts +433 -0
  46. package/dist/contracts/service-templates.d.ts.map +1 -0
  47. package/dist/contracts/service-templates.js +251 -0
  48. package/dist/contracts/service.d.ts +2381 -0
  49. package/dist/contracts/service.d.ts.map +1 -0
  50. package/dist/contracts/service.js +12 -0
  51. package/dist/contracts/template-authoring.d.ts +45 -0
  52. package/dist/contracts/template-authoring.d.ts.map +1 -0
  53. package/dist/contracts/template-authoring.js +853 -0
  54. package/dist/contracts/validation.d.ts +2 -0
  55. package/dist/contracts/validation.d.ts.map +1 -0
  56. package/dist/contracts/validation.js +1 -0
  57. package/dist/index.d.ts +42 -0
  58. package/dist/index.d.ts.map +1 -0
  59. package/dist/index.js +96 -0
  60. package/dist/policies/index.d.ts +16 -0
  61. package/dist/policies/index.d.ts.map +1 -0
  62. package/dist/policies/index.js +26 -0
  63. package/dist/policies/routes.d.ts +920 -0
  64. package/dist/policies/routes.d.ts.map +1 -0
  65. package/dist/policies/routes.js +163 -0
  66. package/dist/policies/schema.d.ts +1226 -0
  67. package/dist/policies/schema.d.ts.map +1 -0
  68. package/dist/policies/schema.js +208 -0
  69. package/dist/policies/service-core.d.ts +1324 -0
  70. package/dist/policies/service-core.d.ts.map +1 -0
  71. package/dist/policies/service-core.js +430 -0
  72. package/dist/policies/service-shared.d.ts +100 -0
  73. package/dist/policies/service-shared.d.ts.map +1 -0
  74. package/dist/policies/service-shared.js +81 -0
  75. package/dist/policies/service.d.ts +1312 -0
  76. package/dist/policies/service.d.ts.map +1 -0
  77. package/dist/policies/service.js +6 -0
  78. package/dist/policies/validation.d.ts +2 -0
  79. package/dist/policies/validation.d.ts.map +1 -0
  80. package/dist/policies/validation.js +1 -0
  81. package/dist/schema.d.ts +5 -0
  82. package/dist/schema.d.ts.map +1 -0
  83. package/dist/schema.js +4 -0
  84. package/dist/targets/schema.d.ts +4 -0
  85. package/dist/targets/schema.d.ts.map +1 -0
  86. package/dist/targets/schema.js +11 -0
  87. package/dist/targets/service.d.ts +20 -0
  88. package/dist/targets/service.d.ts.map +1 -0
  89. package/dist/targets/service.js +25 -0
  90. package/dist/terms/index.d.ts +13 -0
  91. package/dist/terms/index.d.ts.map +1 -0
  92. package/dist/terms/index.js +13 -0
  93. package/dist/terms/routes.d.ts +287 -0
  94. package/dist/terms/routes.d.ts.map +1 -0
  95. package/dist/terms/routes.js +42 -0
  96. package/dist/terms/schema.d.ts +373 -0
  97. package/dist/terms/schema.d.ts.map +1 -0
  98. package/dist/terms/schema.js +64 -0
  99. package/dist/terms/service.d.ts +109 -0
  100. package/dist/terms/service.d.ts.map +1 -0
  101. package/dist/terms/service.js +79 -0
  102. package/dist/terms/validation.d.ts +2 -0
  103. package/dist/terms/validation.d.ts.map +1 -0
  104. package/dist/terms/validation.js +1 -0
  105. package/package.json +126 -0
package/LICENSE ADDED
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for describing the origin of the Work and
141
+ reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may accept and charge a
167
+ fee for, the acceptance of support, warranty, indemnity, or
168
+ other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright 2026 PixelMakers Studio SRL
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
package/README.md ADDED
@@ -0,0 +1,112 @@
1
+ # @voyant-travel/legal
2
+
3
+ Legal module for Voyant. Contracts and policies in a single package — templates with variable substitution, versioning, number series, signing workflow, structured cancellation/payment/T&C policies with rule evaluation, assignments, and acceptance tracking.
4
+
5
+ ## Install
6
+
7
+ ```bash
8
+ pnpm add @voyant-travel/legal
9
+ ```
10
+
11
+ ## Usage
12
+
13
+ ```typescript
14
+ import { legalHonoModule } from "@voyant-travel/legal"
15
+ import { createApp } from "@voyant-travel/hono"
16
+
17
+ const app = createApp({
18
+ modules: [legalHonoModule],
19
+ // ...
20
+ })
21
+ ```
22
+
23
+ ## Entities
24
+
25
+ ### Contracts
26
+
27
+ - **Contracts** (`cont`) — legal document instances with status lifecycle
28
+ - **Contract templates** (`ctpl`) — reusable templates with variable schemas,
29
+ optional channel scope, and explicit storefront defaults
30
+ - **Contract template versions** (`ctpv`) — immutable version snapshots
31
+ - **Contract signatures** (`ctsi`) — signing records (who/when/method/ip)
32
+ - **Contract number series** (`ctns`) — series definitions with auto-increment
33
+ - **Contract attachments** (`ctat`) — rendered PDFs and appendices
34
+
35
+ ## Default Storefront Contract Templates
36
+
37
+ Contract templates can be marked with `isDefault: true`. At most one default
38
+ template can exist for a given `(scope, channelId, language)` selector. A
39
+ default with `channelId: null` is the global fallback for that scope/language;
40
+ a channel-specific default wins when callers pass `channelId`.
41
+
42
+ Storefronts can resolve the active customer-safe template through:
43
+
44
+ - `GET /v1/public/legal/contracts/templates/default`
45
+ - `GET /v1/admin/legal/contracts/templates/default`
46
+
47
+ Supported query parameters are `scope` (defaults to `customer`), `channelId`,
48
+ `language`, and comma-separated `fallbackLanguages`. Selection checks requested
49
+ and fallback languages in order, prefers channel-specific defaults over global
50
+ defaults, ignores inactive templates, and falls back to the newest active
51
+ matching template only when no explicit default exists for that selector.
52
+
53
+ ## Contract Document Operations
54
+
55
+ The contracts route surface exposes stable operations for storefront previews
56
+ and stored document handling:
57
+
58
+ - `POST /v1/public/legal/contracts/templates/:id/render-preview`
59
+ - `POST /v1/public/legal/contracts/templates/by-slug/:slug/render-preview`
60
+ - `POST /v1/admin/legal/contracts/templates/:id/render-preview`
61
+ - `POST /v1/admin/legal/contracts/:id/attach-document`
62
+ - `POST /v1/admin/legal/contracts/:id/regenerate-pdf`
63
+
64
+ Preview routes accept `{ variables }` and return only the rendered text. Public
65
+ preview routes require the template to be active. `attach-document` expects a
66
+ multipart `file` field plus optional `name` and `kind`, uploads through the
67
+ configured `documentStorage`, and persists a contract attachment. `regenerate-pdf`
68
+ uses the configured contract document generator and replaces the canonical
69
+ generated document artifact.
70
+
71
+ ## Contract Lifecycle
72
+
73
+ Contract lifecycle transitions are enforced by the contract service:
74
+
75
+ ```text
76
+ draft -> issued -> sent -> signed -> executed
77
+ ```
78
+
79
+ Contracts may be voided from any non-void stage. Each service transition appends
80
+ to `stageHistory` and emits a domain event when an event bus is configured:
81
+ `contract.issued`, `contract.sent`, `contract.signed`, `contract.executed`, or
82
+ `contract.voided`. Event payloads are intentionally minimal: contract IDs,
83
+ relationship IDs, stage names, and timestamps only; rendered bodies, variables,
84
+ metadata, and signature details stay out of the event payload.
85
+
86
+ ### Policies
87
+
88
+ - **Policies** (`pol`) — policy definitions by kind (cancellation, payment, T&C, etc.)
89
+ - **Policy versions** (`plvr`) — immutable version snapshots with publish/retire lifecycle
90
+ - **Policy rules** (`plrl`) — structured rules per version (cancellation windows, percentages)
91
+ - **Policy assignments** (`plas`) — scope-based assignment to products, channels, markets
92
+ - **Policy acceptances** (`plac`) — acceptance records per booking/order/person
93
+
94
+ ## Exports
95
+
96
+ | Entry | Description |
97
+ | --- | --- |
98
+ | `.` | Combined module export + all linkable definitions |
99
+ | `./contracts` | Contract barrel (types, tables, service, validation) |
100
+ | `./contracts/schema` | Drizzle tables for contracts |
101
+ | `./contracts/validation` | Zod schemas for contracts |
102
+ | `./contracts/routes` | Hono routes for contracts (admin + public) |
103
+ | `./contracts/service` | Contract service functions |
104
+ | `./policies` | Policy barrel (types, tables, service, validation) |
105
+ | `./policies/schema` | Drizzle tables for policies |
106
+ | `./policies/validation` | Zod schemas for policies |
107
+ | `./policies/routes` | Hono routes for policies (admin + public) |
108
+ | `./policies/service` | Policy service functions |
109
+
110
+ ## License
111
+
112
+ Apache-2.0
@@ -0,0 +1,22 @@
1
+ import type { LinkableDefinition } from "@voyant-travel/core";
2
+ export type { ContractDocumentGenerator, ContractsAdminRoutes, ContractsPublicRoutes, ContractsRouteOptions, } from "./routes.js";
3
+ export { createContractsAdminRoutes, createContractsPublicRoutes } from "./routes.js";
4
+ export declare const contractLinkable: LinkableDefinition;
5
+ export declare const contractTemplateLinkable: LinkableDefinition;
6
+ export declare const contractsLinkable: {
7
+ contract: LinkableDefinition;
8
+ contractTemplate: LinkableDefinition;
9
+ };
10
+ export type { ContractLifecycleEvent, ContractLifecycleHook, ContractLifecycleRuntimeOptions, ContractLifecycleStage, ContractLifecycleTransition, } from "./lifecycle.js";
11
+ export { appendContractStageHistory, buildContractLifecycleEvent, CONTRACT_LIFECYCLE_EVENT_NAMES, CONTRACT_LIFECYCLE_STAGES, checkContractLifecycleTransition, createContractStageHistoryEntry, emitContractLifecycleEvent, } from "./lifecycle.js";
12
+ export type { Contract, ContractAttachment, ContractNumberSeries, ContractSignature, ContractStageHistoryEntry, ContractStatus, ContractTemplate, ContractTemplateVersion, NewContract, NewContractAttachment, NewContractNumberSeries, NewContractSignature, NewContractTemplate, NewContractTemplateVersion, } from "./schema.js";
13
+ export { contractAttachments, contractNumberSeries, contractSignatures, contractStatusValues, contracts, contractTemplates, contractTemplateVersions, } from "./schema.js";
14
+ export { allocateContractNumber, ContractTemplateSyntaxError, contractsService, isContractTemplateSyntaxError, renderTemplate, validateContractTemplateBody, validateTemplateVariables, } from "./service.js";
15
+ export type { ContractDocumentGeneratedEvent, ContractDocumentGeneratorContext, ContractDocumentRuntimeOptions, GeneratedContractDocumentArtifact, GeneratedContractDocumentRecord, StorageBackedContractDocumentGeneratorOptions, StorageBackedContractDocumentSerializer, StorageBackedContractDocumentUpload, } from "./service-documents.js";
16
+ export { createPdfContractDocumentGenerator, createStorageBackedContractDocumentGenerator, defaultPdfContractDocumentSerializer, defaultStorageBackedContractDocumentSerializer, } from "./service-documents.js";
17
+ export type { CloudBrowserGoToOptions, CloudBrowserPdfInput, CloudBrowserPdfOptions, CloudBrowserRenderClient, CloudBrowserWaitUntil, CreateBrowserRenderedPdfContractDocumentSerializerOptions, } from "./service-documents-browser.js";
18
+ export { createBrowserRenderedPdfContractDocumentSerializer, defaultContractHtmlWrapper, } from "./service-documents-browser.js";
19
+ export type { ContractTemplateLiquidSnippet, ContractTemplateVariableCategory, ContractTemplateVariableDefinition, ContractTemplateVariableType, } from "./template-authoring.js";
20
+ export { contractTemplateLiquidSnippets, contractTemplateVariableCatalog, } from "./template-authoring.js";
21
+ export { contractBodyFormatSchema, contractListQuerySchema, contractNumberResetStrategySchema, contractNumberSeriesListQuerySchema, contractScopeSchema, contractSignatureMethodSchema, contractStageHistoryEntrySchema, contractStatusSchema, contractTemplateDefaultQuerySchema, contractTemplateListQuerySchema, generateContractDocumentInputSchema, generateContractForBookingInputSchema, generatedContractDocumentAttachmentSchema, generatedContractDocumentResultSchema, insertContractAttachmentSchema, insertContractNumberSeriesSchema, insertContractSchema, insertContractSignatureSchema, insertContractTemplateSchema, insertContractTemplateVersionSchema, renderTemplateInputSchema, updateContractAttachmentSchema, updateContractNumberSeriesSchema, updateContractSchema, updateContractTemplateSchema, } from "./validation.js";
22
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/contracts/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAA;AAE7D,YAAY,EACV,yBAAyB,EACzB,oBAAoB,EACpB,qBAAqB,EACrB,qBAAqB,GACtB,MAAM,aAAa,CAAA;AACpB,OAAO,EAAE,0BAA0B,EAAE,2BAA2B,EAAE,MAAM,aAAa,CAAA;AAErF,eAAO,MAAM,gBAAgB,EAAE,kBAK9B,CAAA;AAED,eAAO,MAAM,wBAAwB,EAAE,kBAKtC,CAAA;AAED,eAAO,MAAM,iBAAiB;;;CAG7B,CAAA;AAED,YAAY,EACV,sBAAsB,EACtB,qBAAqB,EACrB,+BAA+B,EAC/B,sBAAsB,EACtB,2BAA2B,GAC5B,MAAM,gBAAgB,CAAA;AACvB,OAAO,EACL,0BAA0B,EAC1B,2BAA2B,EAC3B,8BAA8B,EAC9B,yB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ACvB,iCAAiC,EACjC,mCAAmC,EACnC,mBAAmB,EACnB,6BAA6B,EAC7B,+BAA+B,EAC/B,oBAAoB,EACpB,kCAAkC,EAClC,+BAA+B,EAC/B,mCAAmC,EACnC,qCAAqC,EACrC,yCAAyC,EACzC,qCAAqC,EACrC,8BAA8B,EAC9B,gCAAgC,EAChC,oBAAoB,EACpB,6BAA6B,EAC7B,4BAA4B,EAC5B,mCAAmC,EACnC,yBAAyB,EACzB,8BAA8B,EAC9B,gCAAgC,EAChC,oBAAoB,EACpB,4BAA4B,GAC7B,MAAM,iBAAiB,CAAA"}
@@ -0,0 +1,24 @@
1
+ export { createContractsAdminRoutes, createContractsPublicRoutes } from "./routes.js";
2
+ export const contractLinkable = {
3
+ module: "legal",
4
+ entity: "contract",
5
+ table: "contracts",
6
+ idPrefix: "cont",
7
+ };
8
+ export const contractTemplateLinkable = {
9
+ module: "legal",
10
+ entity: "contractTemplate",
11
+ table: "contract_templates",
12
+ idPrefix: "ctpl",
13
+ };
14
+ export const contractsLinkable = {
15
+ contract: contractLinkable,
16
+ contractTemplate: contractTemplateLinkable,
17
+ };
18
+ export { appendContractStageHistory, buildContractLifecycleEvent, CONTRACT_LIFECYCLE_EVENT_NAMES, CONTRACT_LIFECYCLE_STAGES, checkContractLifecycleTransition, createContractStageHistoryEntry, emitContractLifecycleEvent, } from "./lifecycle.js";
19
+ export { contractAttachments, contractNumberSeries, contractSignatures, contractStatusValues, contracts, contractTemplates, contractTemplateVersions, } from "./schema.js";
20
+ export { allocateContractNumber, ContractTemplateSyntaxError, contractsService, isContractTemplateSyntaxError, renderTemplate, validateContractTemplateBody, validateTemplateVariables, } from "./service.js";
21
+ export { createPdfContractDocumentGenerator, createStorageBackedContractDocumentGenerator, defaultPdfContractDocumentSerializer, defaultStorageBackedContractDocumentSerializer, } from "./service-documents.js";
22
+ export { createBrowserRenderedPdfContractDocumentSerializer, defaultContractHtmlWrapper, } from "./service-documents-browser.js";
23
+ export { contractTemplateLiquidSnippets, contractTemplateVariableCatalog, } from "./template-authoring.js";
24
+ export { contractBodyFormatSchema, contractListQuerySchema, contractNumberResetStrategySchema, contractNumberSeriesListQuerySchema, contractScopeSchema, contractSignatureMethodSchema, contractStageHistoryEntrySchema, contractStatusSchema, contractTemplateDefaultQuerySchema, contractTemplateListQuerySchema, generateContractDocumentInputSchema, generateContractForBookingInputSchema, generatedContractDocumentAttachmentSchema, generatedContractDocumentResultSchema, insertContractAttachmentSchema, insertContractNumberSeriesSchema, insertContractSchema, insertContractSignatureSchema, insertContractTemplateSchema, insertContractTemplateVersionSchema, renderTemplateInputSchema, updateContractAttachmentSchema, updateContractNumberSeriesSchema, updateContractSchema, updateContractTemplateSchema, } from "./validation.js";
@@ -0,0 +1,66 @@
1
+ import type { EventBus } from "@voyant-travel/core";
2
+ import type { Contract, ContractStageHistoryEntry } from "./schema.js";
3
+ export declare const CONTRACT_LIFECYCLE_STAGES: readonly ["draft", "issued", "sent", "signed", "executed", "expired", "void"];
4
+ export type ContractLifecycleStage = (typeof CONTRACT_LIFECYCLE_STAGES)[number];
5
+ export type ContractLifecycleTransition = "created" | "issued" | "sent" | "signed" | "executed" | "voided";
6
+ export declare const CONTRACT_LIFECYCLE_EVENT_NAMES: {
7
+ readonly issued: "contract.issued";
8
+ readonly sent: "contract.sent";
9
+ readonly signed: "contract.signed";
10
+ readonly executed: "contract.executed";
11
+ readonly voided: "contract.voided";
12
+ };
13
+ export interface ContractLifecycleEvent {
14
+ contractId: string;
15
+ contractNumber: string | null;
16
+ scope: Contract["scope"];
17
+ previousStage: ContractLifecycleStage;
18
+ stage: ContractLifecycleStage;
19
+ transition: Exclude<ContractLifecycleTransition, "created">;
20
+ occurredAt: string;
21
+ personId: string | null;
22
+ organizationId: string | null;
23
+ supplierId: string | null;
24
+ channelId: string | null;
25
+ bookingId: string | null;
26
+ targetKind: Contract["targetKind"] | null;
27
+ targetId: string | null;
28
+ targetProvider: string | null;
29
+ targetSourceRef: string | null;
30
+ legacyTransactionOfferId: string | null;
31
+ legacyTransactionOrderId: string | null;
32
+ /**
33
+ * Operator-supplied delivery override for the `sent` transition only —
34
+ * the Send-contract dialog forwards the typed-in subject + message +
35
+ * recipient through here so the downstream notification subscriber
36
+ * can build its email body from the operator's wording instead of a
37
+ * static template. Null on every other transition.
38
+ */
39
+ delivery?: {
40
+ recipientEmail: string | null;
41
+ subject: string | null;
42
+ message: string | null;
43
+ } | null;
44
+ }
45
+ export type ContractLifecycleHook = (event: ContractLifecycleEvent) => Promise<void> | void;
46
+ export interface ContractLifecycleRuntimeOptions {
47
+ eventBus?: EventBus;
48
+ lifecycleHooks?: readonly ContractLifecycleHook[];
49
+ }
50
+ export type ContractLifecycleTransitionCheck = {
51
+ ok: true;
52
+ } | {
53
+ ok: false;
54
+ reason: "not_draft" | "not_issued" | "not_sent" | "not_signed" | "already_void";
55
+ };
56
+ export declare function createContractStageHistoryEntry(stage: ContractLifecycleStage, options?: {
57
+ previousStage?: ContractLifecycleStage | null;
58
+ transition?: ContractLifecycleTransition;
59
+ enteredAt?: Date;
60
+ actorId?: string | null;
61
+ }): ContractStageHistoryEntry;
62
+ export declare function appendContractStageHistory(current: readonly ContractStageHistoryEntry[] | null | undefined, entry: ContractStageHistoryEntry): ContractStageHistoryEntry[];
63
+ export declare function checkContractLifecycleTransition(from: ContractLifecycleStage, transition: Exclude<ContractLifecycleTransition, "created">): ContractLifecycleTransitionCheck;
64
+ export declare function buildContractLifecycleEvent(contract: Contract, previousStage: ContractLifecycleStage, stage: ContractLifecycleStage, transition: Exclude<ContractLifecycleTransition, "created">, occurredAt: Date, delivery?: ContractLifecycleEvent["delivery"]): ContractLifecycleEvent;
65
+ export declare function emitContractLifecycleEvent(runtime: ContractLifecycleRuntimeOptions | undefined, event: ContractLifecycleEvent): Promise<void>;
66
+ //# sourceMappingURL=lifecycle.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"lifecycle.d.ts","sourceRoot":"","sources":["../../src/contracts/lifecycle.ts"],"names":[],"m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AAE,sBAAsB,EAC7B,UAAU,EAAE,OAAO,CAAC,2BAA2B,EAAE,SAAS,CAAC,EAC3D,UAAU,EAAE,IAAI,EAChB,QAAQ,CAAC,EAAE,sBAAsB,CAAC,UAAU,CAAC,GAC5C,sBAAsB,CAsBxB;AAED,wBAAsB,0BAA0B,CAC9C,OAAO,EAAE,+BAA+B,GAAG,SAAS,EACpD,KAAK,EAAE,sBAAsB,iBAe9B"}
@@ -0,0 +1,93 @@
1
+ export const CONTRACT_LIFECYCLE_STAGES = [
2
+ "draft",
3
+ "issued",
4
+ "sent",
5
+ "signed",
6
+ "executed",
7
+ "expired",
8
+ "void",
9
+ ];
10
+ export const CONTRACT_LIFECYCLE_EVENT_NAMES = {
11
+ issued: "contract.issued",
12
+ sent: "contract.sent",
13
+ signed: "contract.signed",
14
+ executed: "contract.executed",
15
+ voided: "contract.voided",
16
+ };
17
+ function isContractLifecycleStage(value) {
18
+ return (typeof value === "string" && CONTRACT_LIFECYCLE_STAGES.includes(value));
19
+ }
20
+ export function createContractStageHistoryEntry(stage, options = {}) {
21
+ return {
22
+ stage,
23
+ previousStage: options.previousStage ?? null,
24
+ transition: options.transition ?? "created",
25
+ enteredAt: (options.enteredAt ?? new Date()).toISOString(),
26
+ ...(options.actorId === undefined ? {} : { actorId: options.actorId }),
27
+ };
28
+ }
29
+ export function appendContractStageHistory(current, entry) {
30
+ const existing = Array.isArray(current)
31
+ ? current.filter((item) => isContractLifecycleStage(item.stage) &&
32
+ (item.previousStage === null ||
33
+ item.previousStage === undefined ||
34
+ isContractLifecycleStage(item.previousStage)) &&
35
+ typeof item.transition === "string" &&
36
+ typeof item.enteredAt === "string")
37
+ : [];
38
+ return [...existing, entry];
39
+ }
40
+ export function checkContractLifecycleTransition(from, transition) {
41
+ switch (transition) {
42
+ case "issued":
43
+ return from === "draft" ? { ok: true } : { ok: false, reason: "not_draft" };
44
+ case "sent":
45
+ return from === "issued" || from === "sent"
46
+ ? { ok: true }
47
+ : { ok: false, reason: "not_issued" };
48
+ case "signed":
49
+ return from === "sent" ? { ok: true } : { ok: false, reason: "not_sent" };
50
+ case "executed":
51
+ return from === "signed" ? { ok: true } : { ok: false, reason: "not_signed" };
52
+ case "voided":
53
+ return from === "void" ? { ok: false, reason: "already_void" } : { ok: true };
54
+ }
55
+ }
56
+ export function buildContractLifecycleEvent(contract, previousStage, stage, transition, occurredAt, delivery) {
57
+ return {
58
+ contractId: contract.id,
59
+ contractNumber: contract.contractNumber ?? null,
60
+ scope: contract.scope,
61
+ previousStage,
62
+ stage,
63
+ transition,
64
+ occurredAt: occurredAt.toISOString(),
65
+ personId: contract.personId ?? null,
66
+ organizationId: contract.organizationId ?? null,
67
+ supplierId: contract.supplierId ?? null,
68
+ channelId: contract.channelId ?? null,
69
+ bookingId: contract.bookingId ?? null,
70
+ targetKind: contract.targetKind ?? null,
71
+ targetId: contract.targetId ?? null,
72
+ targetProvider: contract.targetProvider ?? null,
73
+ targetSourceRef: contract.targetSourceRef ?? null,
74
+ legacyTransactionOfferId: contract.legacyTransactionOfferId ?? null,
75
+ legacyTransactionOrderId: contract.legacyTransactionOrderId ?? null,
76
+ delivery: delivery ?? null,
77
+ };
78
+ }
79
+ export async function emitContractLifecycleEvent(runtime, event) {
80
+ const eventName = CONTRACT_LIFECYCLE_EVENT_NAMES[event.transition];
81
+ await runtime?.eventBus?.emit(eventName, event, {
82
+ category: "domain",
83
+ source: "service",
84
+ });
85
+ for (const hook of runtime?.lifecycleHooks ?? []) {
86
+ try {
87
+ await hook(event);
88
+ }
89
+ catch (error) {
90
+ console.error(`[legal] lifecycle hook failed for ${eventName}:`, error);
91
+ }
92
+ }
93
+ }
@@ -0,0 +1,17 @@
1
+ import type { BookingPiiService } from "@voyant-travel/bookings";
2
+ import type { EventBus } from "@voyant-travel/core";
3
+ import type { StorageProvider } from "@voyant-travel/storage";
4
+ import type { ContractLifecycleHook } from "./lifecycle.js";
5
+ import type { ContractDocumentGenerator, ContractsRouteOptions } from "./routes.js";
6
+ export type ContractsRouteRuntime = {
7
+ documentGenerator?: ContractDocumentGenerator;
8
+ documentStorage?: StorageProvider | null;
9
+ resolveDocumentDownloadUrl?: ContractsRouteOptions["resolveDocumentDownloadUrl"];
10
+ eventBus?: EventBus;
11
+ lifecycleHooks?: readonly ContractLifecycleHook[];
12
+ bookingPiiService?: BookingPiiService | null;
13
+ resolveBookingPiiService?: ContractsRouteOptions["resolveBookingPiiService"];
14
+ };
15
+ export declare const CONTRACTS_ROUTE_RUNTIME_CONTAINER_KEY = "providers.legal.contracts.runtime";
16
+ export declare function buildContractsRouteRuntime(bindings: Record<string, unknown>, options?: ContractsRouteOptions): ContractsRouteRuntime;
17
+ //# sourceMappingURL=route-runtime.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"route-runtime.d.ts","sourceRoot":"","sources":["../../src/contracts/route-runtime.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAA;AAChE,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAA;AACnD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAA;AAE7D,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,gBAAgB,CAAA;AAC3D,OAAO,KAAK,EAAE,yBAAyB,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAA;AAEnF,MAAM,MAAM,qBAAqB,GAAG;IAClC,iBAAiB,CAAC,EAAE,yBAAyB,CAAA;IAC7C,eAAe,CAAC,EAAE,eAAe,GAAG,IAAI,CAAA;IACxC,0BAA0B,CAAC,EAAE,qBAAqB,CAAC,4BAA4B,CAAC,CAAA;IAChF,QAAQ,CAAC,EAAE,QAAQ,CAAA;IACnB,cAAc,CAAC,EAAE,SAAS,qBAAqB,EAAE,CAAA;IACjD,iBAAiB,CAAC,EAAE,iBAAiB,GAAG,IAAI,CAAA;IAC5C,wBAAwB,CAAC,EAAE,qBAAqB,CAAC,0BAA0B,CAAC,CAAA;CAC7E,CAAA;AAED,eAAO,MAAM,qCAAqC,sCAAsC,CAAA;AAExF,wBAAgB,0BAA0B,CACxC,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EACjC,OAAO,GAAE,qBAA0B,GAClC,qBAAqB,CAUvB"}
@@ -0,0 +1,12 @@
1
+ export const CONTRACTS_ROUTE_RUNTIME_CONTAINER_KEY = "providers.legal.contracts.runtime";
2
+ export function buildContractsRouteRuntime(bindings, options = {}) {
3
+ return {
4
+ documentGenerator: options.resolveDocumentGenerator?.(bindings) ?? options.documentGenerator,
5
+ documentStorage: options.resolveDocumentStorage?.(bindings) ?? options.documentStorage,
6
+ resolveDocumentDownloadUrl: options.resolveDocumentDownloadUrl,
7
+ eventBus: options.resolveEventBus?.(bindings) ?? options.eventBus,
8
+ lifecycleHooks: options.resolveLifecycleHooks?.(bindings) ?? options.lifecycleHooks,
9
+ bookingPiiService: options.bookingPiiService,
10
+ resolveBookingPiiService: options.resolveBookingPiiService,
11
+ };
12
+ }
@@ -0,0 +1,19 @@
1
+ import type { Context } from "hono";
2
+ import { type RenderTemplateInput } from "./service-shared.js";
3
+ export declare function contractTemplateSyntaxResponse(c: Context, error: unknown): Response & import("hono").TypedResponse<{
4
+ error: string;
5
+ issues: {
6
+ message: string;
7
+ }[];
8
+ }, 400, "json">;
9
+ export declare function renderPreviewResponse(c: Context, input: RenderTemplateInput, extraData?: Record<string, unknown>): (Response & import("hono").TypedResponse<{
10
+ error: string;
11
+ issues: {
12
+ message: string;
13
+ }[];
14
+ }, 400, "json">) | (Response & import("hono").TypedResponse<{
15
+ data: {
16
+ rendered: string;
17
+ };
18
+ }, import("hono/utils/http-status").ContentfulStatusCode, "json">);
19
+ //# sourceMappingURL=route-template-preview.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"route-template-preview.d.ts","sourceRoot":"","sources":["../../src/contracts/route-template-preview.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,MAAM,CAAA;AAGnC,OAAO,EAAiC,KAAK,mBAAmB,EAAE,MAAM,qBAAqB,CAAA;AAE7F,wBAAgB,8BAA8B,CAAC,CAAC,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO;;;;;gBAYxE;AAED,wBAAgB,qBAAqB,CACnC,CAAC,EAAE,OAAO,EACV,KAAK,EAAE,mBAAmB,EAC1B,SAAS,GAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAM;;;;;;;;;mEAQxC"}
@@ -0,0 +1,20 @@
1
+ import { contractsService } from "./service.js";
2
+ import { isContractTemplateSyntaxError } from "./service-shared.js";
3
+ export function contractTemplateSyntaxResponse(c, error) {
4
+ if (!isContractTemplateSyntaxError(error)) {
5
+ throw error;
6
+ }
7
+ return c.json({
8
+ error: error.message,
9
+ issues: error.issues,
10
+ }, 400);
11
+ }
12
+ export function renderPreviewResponse(c, input, extraData = {}) {
13
+ try {
14
+ const rendered = contractsService.renderPreview(input);
15
+ return c.json({ data: { ...extraData, rendered } });
16
+ }
17
+ catch (error) {
18
+ return contractTemplateSyntaxResponse(c, error);
19
+ }
20
+ }