@voyantjs/finance 0.5.0 → 0.6.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.
- package/dist/index.d.ts +6 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +14 -6
- package/dist/route-runtime.d.ts +13 -0
- package/dist/route-runtime.d.ts.map +1 -0
- package/dist/route-runtime.js +8 -0
- package/dist/routes-documents.d.ts +45 -8
- package/dist/routes-documents.d.ts.map +1 -1
- package/dist/routes-documents.js +45 -8
- package/dist/routes-public.d.ts +564 -9
- package/dist/routes-public.d.ts.map +1 -1
- package/dist/routes-public.js +65 -54
- package/dist/routes-settlement.d.ts +3 -2
- package/dist/routes-settlement.d.ts.map +1 -1
- package/dist/routes-settlement.js +9 -8
- package/dist/routes.d.ts +123 -134
- package/dist/routes.d.ts.map +1 -1
- package/dist/routes.js +59 -61
- package/dist/schema.d.ts +9 -9
- package/dist/service-documents.d.ts +0 -1
- package/dist/service-documents.d.ts.map +1 -1
- package/dist/service-documents.js +3 -5
- package/dist/service-public.d.ts +11 -8
- package/dist/service-public.d.ts.map +1 -1
- package/dist/service-public.js +10 -38
- package/dist/service-settlement.d.ts.map +1 -1
- package/dist/service-settlement.js +3 -0
- package/dist/service.d.ts +126 -126
- package/dist/validation-billing.d.ts +6 -6
- package/dist/validation-payments.d.ts +18 -18
- package/dist/validation-public.d.ts +8 -8
- package/dist/validation-shared.d.ts +8 -8
- package/package.json +7 -7
package/dist/service-public.d.ts
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
import type { PostgresJsDatabase } from "drizzle-orm/postgres-js";
|
|
2
2
|
import type { PublicBookingFinanceDocuments, PublicBookingFinancePayments, PublicFinanceDocumentLookup, PublicPaymentOptionsQuery, PublicStartPaymentSessionInput, PublicValidateVoucherInput } from "./validation-public.js";
|
|
3
|
+
export interface PublicFinanceRuntimeOptions {
|
|
4
|
+
resolveDocumentDownloadUrl?: (storageKey: string) => Promise<string | null> | string | null;
|
|
5
|
+
}
|
|
3
6
|
export declare const publicFinanceService: {
|
|
4
|
-
getBookingDocuments(db: PostgresJsDatabase, bookingId: string): Promise<PublicBookingFinanceDocuments | null>;
|
|
5
|
-
getDocumentByReference(db: PostgresJsDatabase, reference: string): Promise<PublicFinanceDocumentLookup | null>;
|
|
7
|
+
getBookingDocuments(db: PostgresJsDatabase, bookingId: string, runtime?: PublicFinanceRuntimeOptions): Promise<PublicBookingFinanceDocuments | null>;
|
|
8
|
+
getDocumentByReference(db: PostgresJsDatabase, reference: string, runtime?: PublicFinanceRuntimeOptions): Promise<PublicFinanceDocumentLookup | null>;
|
|
6
9
|
getBookingPaymentOptions(db: PostgresJsDatabase, bookingId: string, query: PublicPaymentOptionsQuery): Promise<{
|
|
7
10
|
bookingId: string;
|
|
8
11
|
accounts: {
|
|
@@ -20,7 +23,7 @@ export declare const publicFinanceService: {
|
|
|
20
23
|
schedules: {
|
|
21
24
|
id: string;
|
|
22
25
|
scheduleType: "other" | "deposit" | "installment" | "balance" | "hold";
|
|
23
|
-
status: "
|
|
26
|
+
status: "pending" | "expired" | "cancelled" | "paid" | "due" | "waived";
|
|
24
27
|
dueDate: string;
|
|
25
28
|
currency: string;
|
|
26
29
|
amountCents: number;
|
|
@@ -30,7 +33,7 @@ export declare const publicFinanceService: {
|
|
|
30
33
|
id: string;
|
|
31
34
|
bookingPaymentScheduleId: string | null;
|
|
32
35
|
guaranteeType: "other" | "voucher" | "bank_transfer" | "credit_card" | "deposit" | "preauth" | "card_on_file" | "agency_letter";
|
|
33
|
-
status: "
|
|
36
|
+
status: "pending" | "expired" | "cancelled" | "released" | "failed" | "active";
|
|
34
37
|
currency: string | null;
|
|
35
38
|
amountCents: number | null;
|
|
36
39
|
provider: string | null;
|
|
@@ -52,7 +55,7 @@ export declare const publicFinanceService: {
|
|
|
52
55
|
invoiceId: string | null;
|
|
53
56
|
bookingPaymentScheduleId: string | null;
|
|
54
57
|
bookingGuaranteeId: string | null;
|
|
55
|
-
status: "
|
|
58
|
+
status: "pending" | "expired" | "cancelled" | "failed" | "paid" | "requires_redirect" | "processing" | "authorized";
|
|
56
59
|
provider: string | null;
|
|
57
60
|
providerSessionId: string | null;
|
|
58
61
|
providerPaymentId: string | null;
|
|
@@ -79,7 +82,7 @@ export declare const publicFinanceService: {
|
|
|
79
82
|
invoiceId: string | null;
|
|
80
83
|
bookingPaymentScheduleId: string | null;
|
|
81
84
|
bookingGuaranteeId: string | null;
|
|
82
|
-
status: "
|
|
85
|
+
status: "pending" | "expired" | "cancelled" | "failed" | "paid" | "requires_redirect" | "processing" | "authorized";
|
|
83
86
|
provider: string | null;
|
|
84
87
|
providerSessionId: string | null;
|
|
85
88
|
providerPaymentId: string | null;
|
|
@@ -106,7 +109,7 @@ export declare const publicFinanceService: {
|
|
|
106
109
|
invoiceId: string | null;
|
|
107
110
|
bookingPaymentScheduleId: string | null;
|
|
108
111
|
bookingGuaranteeId: string | null;
|
|
109
|
-
status: "
|
|
112
|
+
status: "pending" | "expired" | "cancelled" | "failed" | "paid" | "requires_redirect" | "processing" | "authorized";
|
|
110
113
|
provider: string | null;
|
|
111
114
|
providerSessionId: string | null;
|
|
112
115
|
providerPaymentId: string | null;
|
|
@@ -133,7 +136,7 @@ export declare const publicFinanceService: {
|
|
|
133
136
|
invoiceId: string | null;
|
|
134
137
|
bookingPaymentScheduleId: string | null;
|
|
135
138
|
bookingGuaranteeId: string | null;
|
|
136
|
-
status: "
|
|
139
|
+
status: "pending" | "expired" | "cancelled" | "failed" | "paid" | "requires_redirect" | "processing" | "authorized";
|
|
137
140
|
provider: string | null;
|
|
138
141
|
providerSessionId: string | null;
|
|
139
142
|
providerPaymentId: string | null;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"service-public.d.ts","sourceRoot":"","sources":["../src/service-public.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAA;AAWjE,OAAO,KAAK,EACV,6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,0BAA0B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA8FhF,CAAA"}
|
package/dist/service-public.js
CHANGED
|
@@ -43,38 +43,7 @@ function maybeUrl(value) {
|
|
|
43
43
|
return /^https?:\/\//i.test(value) ? value : null;
|
|
44
44
|
}
|
|
45
45
|
function getMetadataDownloadUrl(record) {
|
|
46
|
-
|
|
47
|
-
"downloadUrl",
|
|
48
|
-
"download_url",
|
|
49
|
-
"signedUrl",
|
|
50
|
-
"signed_url",
|
|
51
|
-
"publicUrl",
|
|
52
|
-
"public_url",
|
|
53
|
-
"fileUrl",
|
|
54
|
-
"file_url",
|
|
55
|
-
"url",
|
|
56
|
-
];
|
|
57
|
-
for (const key of directKeys) {
|
|
58
|
-
const value = getMetadataString(record, key);
|
|
59
|
-
const url = maybeUrl(value);
|
|
60
|
-
if (url) {
|
|
61
|
-
return url;
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
const artifact = record?.artifact;
|
|
65
|
-
if (artifact && typeof artifact === "object" && !Array.isArray(artifact)) {
|
|
66
|
-
const nested = artifact;
|
|
67
|
-
for (const key of ["downloadUrl", "download_url", "signedUrl", "publicUrl", "url"]) {
|
|
68
|
-
const value = nested[key];
|
|
69
|
-
if (typeof value === "string") {
|
|
70
|
-
const url = maybeUrl(value);
|
|
71
|
-
if (url) {
|
|
72
|
-
return url;
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
return null;
|
|
46
|
+
return maybeUrl(getMetadataString(record, "url"));
|
|
78
47
|
}
|
|
79
48
|
function toPublicPaymentSession(session) {
|
|
80
49
|
return {
|
|
@@ -105,10 +74,13 @@ function toPublicPaymentSession(session) {
|
|
|
105
74
|
failureMessage: session.failureMessage ?? null,
|
|
106
75
|
};
|
|
107
76
|
}
|
|
108
|
-
function mapInvoiceDocument(invoice, renditions) {
|
|
77
|
+
async function mapInvoiceDocument(invoice, renditions, runtime = {}) {
|
|
109
78
|
const selectedRendition = renditions.find((rendition) => rendition.status === "ready") ?? renditions[0] ?? null;
|
|
110
79
|
const metadata = getMetadataRecord(selectedRendition?.metadata ?? null);
|
|
111
|
-
const
|
|
80
|
+
const resolvedDownloadUrl = selectedRendition?.storageKey && runtime.resolveDocumentDownloadUrl
|
|
81
|
+
? await runtime.resolveDocumentDownloadUrl(selectedRendition.storageKey)
|
|
82
|
+
: null;
|
|
83
|
+
const downloadUrl = resolvedDownloadUrl ?? getMetadataDownloadUrl(metadata);
|
|
112
84
|
return {
|
|
113
85
|
invoiceId: invoice.id,
|
|
114
86
|
invoiceNumber: invoice.invoiceNumber,
|
|
@@ -131,7 +103,7 @@ function mapInvoiceDocument(invoice, renditions) {
|
|
|
131
103
|
};
|
|
132
104
|
}
|
|
133
105
|
export const publicFinanceService = {
|
|
134
|
-
async getBookingDocuments(db, bookingId) {
|
|
106
|
+
async getBookingDocuments(db, bookingId, runtime = {}) {
|
|
135
107
|
const [booking] = await db
|
|
136
108
|
.select({ id: bookings.id })
|
|
137
109
|
.from(bookings)
|
|
@@ -161,10 +133,10 @@ export const publicFinanceService = {
|
|
|
161
133
|
}
|
|
162
134
|
return {
|
|
163
135
|
bookingId,
|
|
164
|
-
documents: invoiceRows.map((invoice) => mapInvoiceDocument(invoice, renditionByInvoiceId.get(invoice.id) ?? [])),
|
|
136
|
+
documents: await Promise.all(invoiceRows.map((invoice) => mapInvoiceDocument(invoice, renditionByInvoiceId.get(invoice.id) ?? [], runtime))),
|
|
165
137
|
};
|
|
166
138
|
},
|
|
167
|
-
async getDocumentByReference(db, reference) {
|
|
139
|
+
async getDocumentByReference(db, reference, runtime = {}) {
|
|
168
140
|
const [invoiceMatch, paymentMatch] = await Promise.all([
|
|
169
141
|
db
|
|
170
142
|
.select()
|
|
@@ -196,7 +168,7 @@ export const publicFinanceService = {
|
|
|
196
168
|
.orderBy(desc(invoiceRenditions.createdAt));
|
|
197
169
|
return {
|
|
198
170
|
bookingId: invoice.bookingId,
|
|
199
|
-
...mapInvoiceDocument(invoice, renditions),
|
|
171
|
+
...(await mapInvoiceDocument(invoice, renditions, runtime)),
|
|
200
172
|
};
|
|
201
173
|
},
|
|
202
174
|
async getBookingPaymentOptions(db, bookingId, query) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"service-settlement.d.ts","sourceRoot":"","sources":["../src/service-settlement.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAA;AAC9C,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAA;AAEjE,OAAO,KAAK,EAAE,OAAO,IAAI,cAAc,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAA;AAEhF,OAAO,KAAK,EAAE,6BAA6B,EAAE,0BAA0B,EAAE,MAAM,iBAAiB,CAAA;AAEhG,KAAK,iBAAiB,GAAG,cAAc,CAAA;AACvC,KAAK,qBAAqB,GAAG,kBAAkB,CAAA;AAE/C,MAAM,WAAW,8BAA8B;IAC7C,EAAE,EAAE,kBAAkB,CAAA;IACtB,OAAO,EAAE,iBAAiB,CAAA;IAC1B,WAAW,EAAE,qBAAqB,CAAA;IAClC,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;CAClC;AAED,MAAM,WAAW,6BAA6B;IAC5C,UAAU,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IAC1B,cAAc,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IAC9B,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IAC3B,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IACtB,eAAe,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IAC/B,iBAAiB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IACjC,QAAQ,CAAC,EAAE,MAAM,GAAG,I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