@voyant-travel/finance 0.150.0 → 0.151.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.
@@ -1,3 +1,4 @@
1
+ import { type NodePgClient, type NodePgDatabase } from "drizzle-orm/node-postgres";
1
2
  import type { PostgresJsDatabase } from "drizzle-orm/postgres-js";
2
3
  export interface VoucherMigrationOptions {
3
4
  /**
@@ -22,6 +23,12 @@ export interface VoucherMigrationResult {
22
23
  skipped: VoucherMigrationSkip[];
23
24
  dryRun: boolean;
24
25
  }
26
+ export interface VoucherSetupMigrationContext {
27
+ client: NodePgClient;
28
+ dryRun: boolean;
29
+ }
30
+ /** Node migration-runner adapter exported by the package-owned setup facet. */
31
+ export declare function runVoucherSetupMigration(context: VoucherSetupMigrationContext): Promise<VoucherMigrationResult>;
25
32
  /**
26
33
  * Backfill the `vouchers` table from legacy voucher rows in
27
34
  * `payment_instruments`. A legacy voucher is a row with `instrumentType =
@@ -40,5 +47,5 @@ export interface VoucherMigrationResult {
40
47
  * migrated. Picking one source of truth avoids clobbering balances the
41
48
  * operator may have adjusted through the new redemption flow.
42
49
  */
43
- export declare function migrateVouchersFromPaymentInstruments(db: PostgresJsDatabase, options?: VoucherMigrationOptions): Promise<VoucherMigrationResult>;
50
+ export declare function migrateVouchersFromPaymentInstruments(db: PostgresJsDatabase | NodePgDatabase, options?: VoucherMigrationOptions): Promise<VoucherMigrationResult>;
44
51
  //# sourceMappingURL=service-vouchers-migration.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"service-vouchers-migration.d.ts","sourceRoot":"","sources":["../src/service-vouchers-migration.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAA;AAsCjE,MAAM,WAAW,uBAAuB;IACtC;;OAEG;IACH,MAAM,CAAC,EAAE,OAAO,CAAA;IAChB;;OAEG;IACH,aAAa,CAAC,EAAE,CAAC,IAAI,EAAE;QAAE,mBAAmB,EAAE,MAAM,CAAC;QAAC,WAAW,EAAE,MAAM,CAAA;KAAE,KAAK,IAAI,CAAA;CACrF;AAED,MAAM,WAAW,oBAAoB;IACnC,mBAAmB,EAAE,MAAM,CAAA;IAC3B,MAAM,EACF,kBAAkB,GAClB,cAAc,GACd,kBAAkB,GAClB,gBAAgB,GAChB,0BAA0B,CAAA;CAC/B;AAED,MAAM,WAAW,sBAAsB;IACrC,UAAU,EAAE,MAAM,CAAA;IAClB,QAAQ,EAAE,MAAM,CAAA;IAChB,OAAO,EAAE,oBAAoB,EAAE,CAAA;IAC/B,MAAM,EAAE,OAAO,CAAA;CAChB;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAsB,qCAAqC,CACzD,EAAE,EAAE,kBAAkB,EACtB,OAAO,GAAE,uBAA4B,GACpC,OAAO,CAAC,sBAAsB,CAAC,CA6GjC"}
1
+ {"version":3,"file":"service-vouchers-migration.d.ts","sourceRoot":"","sources":["../src/service-vouchers-migration.ts"],"names":[],"mappings":"AACA,OAAO,EAAW,KAAK,YAAY,EAAE,KAAK,cAAc,EAAE,MAAM,2BAA2B,CAAA;AAC3F,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAA;AAsCjE,MAAM,WAAW,uBAAuB;IACtC;;OAEG;IACH,MAAM,CAAC,EAAE,OAAO,CAAA;IAChB;;OAEG;IACH,aAAa,CAAC,EAAE,CAAC,IAAI,EAAE;QAAE,mBAAmB,EAAE,MAAM,CAAC;QAAC,WAAW,EAAE,MAAM,CAAA;KAAE,KAAK,IAAI,CAAA;CACrF;AAED,MAAM,WAAW,oBAAoB;IACnC,mBAAmB,EAAE,MAAM,CAAA;IAC3B,MAAM,EACF,kBAAkB,GAClB,cAAc,GACd,kBAAkB,GAClB,gBAAgB,GAChB,0BAA0B,CAAA;CAC/B;AAED,MAAM,WAAW,sBAAsB;IACrC,UAAU,EAAE,MAAM,CAAA;IAClB,QAAQ,EAAE,MAAM,CAAA;IAChB,OAAO,EAAE,oBAAoB,EAAE,CAAA;IAC/B,MAAM,EAAE,OAAO,CAAA;CAChB;AAED,MAAM,WAAW,4BAA4B;IAC3C,MAAM,EAAE,YAAY,CAAA;IACpB,MAAM,EAAE,OAAO,CAAA;CAChB;AAED,+EAA+E;AAC/E,wBAAsB,wBAAwB,CAC5C,OAAO,EAAE,4BAA4B,GACpC,OAAO,CAAC,sBAAsB,CAAC,CAGjC;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAsB,qCAAqC,CACzD,EAAE,EAAE,kBAAkB,GAAG,cAAc,EACvC,OAAO,GAAE,uBAA4B,GACpC,OAAO,CAAC,sBAAsB,CAAC,CA6GjC"}
@@ -1,4 +1,5 @@
1
1
  import { eq, sql } from "drizzle-orm";
2
+ import { drizzle } from "drizzle-orm/node-postgres";
2
3
  import { paymentInstruments, vouchers } from "./schema.js";
3
4
  /**
4
5
  * Pulls a (possibly nested, array-wrapped, or null) value out of a JSONB
@@ -31,6 +32,11 @@ function asDate(value) {
31
32
  const parsed = new Date(value);
32
33
  return Number.isNaN(parsed.getTime()) ? null : parsed;
33
34
  }
35
+ /** Node migration-runner adapter exported by the package-owned setup facet. */
36
+ export async function runVoucherSetupMigration(context) {
37
+ const db = drizzle(context.client);
38
+ return migrateVouchersFromPaymentInstruments(db, { dryRun: context.dryRun });
39
+ }
34
40
  /**
35
41
  * Backfill the `vouchers` table from legacy voucher rows in
36
42
  * `payment_instruments`. A legacy voucher is a row with `instrumentType =
@@ -1 +1 @@
1
- {"version":3,"file":"voyant.d.ts","sourceRoot":"","sources":["../src/voyant.ts"],"names":[],"mappings":"AAEA,wEAAwE;AACxE,eAAO,MAAM,mBAAmB,uDA4D9B,CAAA;AAEF,eAAO,MAAM,6BAA6B,uDAmBxC,CAAA;AAEF,eAAO,MAAM,iCAAiC,uDAmB5C,CAAA;AAEF,eAAO,MAAM,kCAAkC,uDA6B7C,CAAA;AAEF,eAAe,mBAAmB,CAAA"}
1
+ {"version":3,"file":"voyant.d.ts","sourceRoot":"","sources":["../src/voyant.ts"],"names":[],"mappings":"AAOA,wEAAwE;AACxE,eAAO,MAAM,mBAAmB,uDA+K9B,CAAA;AAEF,eAAO,MAAM,6BAA6B,uDAmBxC,CAAA;AAEF,eAAO,MAAM,iCAAiC,uDAmB5C,CAAA;AAEF,eAAO,MAAM,kCAAkC,uDA6B7C,CAAA;AAEF,eAAe,mBAAmB,CAAA"}
package/dist/voyant.js CHANGED
@@ -1,4 +1,8 @@
1
1
  import { defineModule, definePlugin } from "@voyant-travel/core/project";
2
+ const financeAdminRuntime = {
3
+ entry: "@voyant-travel/finance-react/admin",
4
+ export: "createFinanceAdminExtension",
5
+ };
2
6
  /** Import-cheap deployment declaration owned by the finance package. */
3
7
  export const financeVoyantModule = defineModule({
4
8
  id: "@voyant-travel/finance",
@@ -57,6 +61,117 @@ export const financeVoyantModule = defineModule({
57
61
  source: "@voyant-travel/finance/linkables",
58
62
  },
59
63
  ],
64
+ events: [
65
+ { id: "@voyant-travel/finance#event.invoice.issued", eventType: "invoice.issued" },
66
+ {
67
+ id: "@voyant-travel/finance#event.invoice.proforma.issued",
68
+ eventType: "invoice.proforma.issued",
69
+ },
70
+ {
71
+ id: "@voyant-travel/finance#event.invoice.proforma.converted",
72
+ eventType: "invoice.proforma.converted",
73
+ },
74
+ { id: "@voyant-travel/finance#event.invoice.voided", eventType: "invoice.voided" },
75
+ { id: "@voyant-travel/finance#event.invoice.settled", eventType: "invoice.settled" },
76
+ { id: "@voyant-travel/finance#event.invoice.rendered", eventType: "invoice.rendered" },
77
+ {
78
+ id: "@voyant-travel/finance#event.invoice.document.generated",
79
+ eventType: "invoice.document.generated",
80
+ },
81
+ {
82
+ id: "@voyant-travel/finance#event.invoice.payment.recorded",
83
+ eventType: "invoice.payment.recorded",
84
+ },
85
+ { id: "@voyant-travel/finance#event.payment.completed", eventType: "payment.completed" },
86
+ { id: "@voyant-travel/finance#event.booking.created", eventType: "booking.created" },
87
+ { id: "@voyant-travel/finance#event.booking.confirmed", eventType: "booking.confirmed" },
88
+ {
89
+ id: "@voyant-travel/finance#event.booking.dual-created",
90
+ eventType: "booking.dual-created",
91
+ },
92
+ {
93
+ id: "@voyant-travel/finance#event.booking-create.rejected",
94
+ eventType: "booking_create.rejected",
95
+ },
96
+ {
97
+ id: "@voyant-travel/finance#event.booking.contract-document.requested",
98
+ eventType: "booking.contract_document.requested",
99
+ },
100
+ {
101
+ id: "@voyant-travel/finance#event.booking-payment-schedule.paid",
102
+ eventType: "booking_payment_schedule.paid",
103
+ },
104
+ ],
105
+ setupMigrations: [
106
+ {
107
+ id: "@voyant-travel/finance#setup.vouchers-from-payment-instruments.v1",
108
+ source: "@voyant-travel/finance/setup/vouchers",
109
+ runtime: {
110
+ entry: "@voyant-travel/finance/setup/vouchers",
111
+ export: "runVoucherSetupMigration",
112
+ },
113
+ dependsOn: ["@voyant-travel/finance#migrations"],
114
+ },
115
+ ],
116
+ access: {
117
+ resources: [
118
+ {
119
+ id: "@voyant-travel/finance#access.finance",
120
+ resource: "finance",
121
+ actions: ["read", "write", "refund", "void"],
122
+ },
123
+ ],
124
+ },
125
+ tools: [
126
+ {
127
+ id: "@voyant-travel/finance#tool.list-invoices",
128
+ name: "list_invoices",
129
+ runtime: { entry: "@voyant-travel/finance/tools", export: "listInvoicesTool" },
130
+ requiredScopes: ["finance:read"],
131
+ },
132
+ {
133
+ id: "@voyant-travel/finance#tool.get-invoice",
134
+ name: "get_invoice",
135
+ runtime: { entry: "@voyant-travel/finance/tools", export: "getInvoiceTool" },
136
+ requiredScopes: ["finance:read"],
137
+ },
138
+ {
139
+ id: "@voyant-travel/finance#tool.void-invoice",
140
+ name: "void_invoice",
141
+ runtime: { entry: "@voyant-travel/finance/tools", export: "voidInvoiceTool" },
142
+ requiredScopes: ["finance:void"],
143
+ },
144
+ ],
145
+ admin: {
146
+ routes: [
147
+ ["index", "/finance"],
148
+ ["invoices-index", "/finance/invoices"],
149
+ ["invoices-detail", "/finance/invoices/$id"],
150
+ ["invoice-number-series", "/finance/invoice-number-series"],
151
+ ["payments-index", "/finance/payments"],
152
+ ["payments-detail", "/finance/payments/$id"],
153
+ ["supplier-invoices-index", "/finance/supplier-invoices"],
154
+ ["supplier-invoices-detail", "/finance/supplier-invoices/$id"],
155
+ ["profitability", "/finance/profitability"],
156
+ ].map(([id, path]) => ({
157
+ id: `@voyant-travel/finance#admin.route.${id}`,
158
+ path,
159
+ runtime: financeAdminRuntime,
160
+ })),
161
+ contributions: [
162
+ ["booking-invoices", "booking.details.invoices-tab"],
163
+ ["booking-pending-payment-sessions", "booking.details.finance-start"],
164
+ ["booking-payment-policy", "booking.details.finance-end"],
165
+ ["supplier-payment-policy", "supplier.details.payment-policy"],
166
+ ].map(([id, slotId]) => ({
167
+ id: `@voyant-travel/finance#admin.contribution.${id}`,
168
+ slotId,
169
+ runtime: financeAdminRuntime,
170
+ })),
171
+ },
172
+ lifecycle: {
173
+ uninstall: { default: "retain-data", purge: "not-supported" },
174
+ },
60
175
  meta: {
61
176
  ownership: "package",
62
177
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@voyant-travel/finance",
3
- "version": "0.150.0",
3
+ "version": "0.151.0",
4
4
  "license": "Apache-2.0",
5
5
  "type": "module",
6
6
  "exports": {
@@ -112,16 +112,16 @@
112
112
  "fflate": "^0.8.2",
113
113
  "hono": "^4.12.27",
114
114
  "zod": "^4.4.3",
115
- "@voyant-travel/action-ledger": "^0.105.15",
116
- "@voyant-travel/bookings": "^0.150.0",
117
- "@voyant-travel/core": "^0.113.0",
118
- "@voyant-travel/db": "^0.110.2",
119
- "@voyant-travel/types": "^0.107.1",
120
- "@voyant-travel/finance-contracts": "^0.105.9",
121
- "@voyant-travel/hono": "^0.122.3",
122
- "@voyant-travel/storage": "^0.106.0",
115
+ "@voyant-travel/action-ledger": "^0.106.0",
116
+ "@voyant-travel/core": "^0.114.0",
117
+ "@voyant-travel/bookings": "^0.151.0",
118
+ "@voyant-travel/db": "^0.111.0",
119
+ "@voyant-travel/types": "^0.107.2",
120
+ "@voyant-travel/hono": "^0.122.4",
121
+ "@voyant-travel/storage": "^0.107.0",
123
122
  "@voyant-travel/utils": "^0.106.0",
124
- "@voyant-travel/tools": "^0.1.0"
123
+ "@voyant-travel/tools": "^0.1.0",
124
+ "@voyant-travel/finance-contracts": "^0.105.9"
125
125
  },
126
126
  "devDependencies": {
127
127
  "drizzle-kit": "^0.31.10",
@@ -148,8 +148,7 @@
148
148
  "compatibleWith": {
149
149
  "framework": ">=0.26.0",
150
150
  "targets": [
151
- "node",
152
- "voyant-cloud"
151
+ "node"
153
152
  ],
154
153
  "modes": [
155
154
  "local",