@voyantjs/legal 0.75.7 → 0.77.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.
- package/dist/contracts/route-runtime.d.ts +1 -0
- package/dist/contracts/route-runtime.d.ts.map +1 -1
- package/dist/contracts/route-runtime.js +1 -0
- package/dist/contracts/routes.d.ts +0 -12
- package/dist/contracts/routes.d.ts.map +1 -1
- package/dist/contracts/routes.js +28 -29
- package/package.json +9 -9
|
@@ -5,6 +5,7 @@ import type { ContractDocumentGenerator, ContractsRouteOptions } from "./routes.
|
|
|
5
5
|
export type ContractsRouteRuntime = {
|
|
6
6
|
documentGenerator?: ContractDocumentGenerator;
|
|
7
7
|
documentStorage?: StorageProvider | null;
|
|
8
|
+
resolveDocumentDownloadUrl?: ContractsRouteOptions["resolveDocumentDownloadUrl"];
|
|
8
9
|
eventBus?: EventBus;
|
|
9
10
|
lifecycleHooks?: readonly ContractLifecycleHook[];
|
|
10
11
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"route-runtime.d.ts","sourceRoot":"","sources":["../../src/contracts/route-runtime.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAA;AAC9C,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAA;AAExD,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,QAAQ,CAAC,EAAE,QAAQ,CAAA;IACnB,cAAc,CAAC,EAAE,SAAS,qBAAqB,EAAE,CAAA;CAClD,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,
|
|
1
|
+
{"version":3,"file":"route-runtime.d.ts","sourceRoot":"","sources":["../../src/contracts/route-runtime.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAA;AAC9C,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAA;AAExD,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;CAClD,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,CAQvB"}
|
|
@@ -3,6 +3,7 @@ export function buildContractsRouteRuntime(bindings, options = {}) {
|
|
|
3
3
|
return {
|
|
4
4
|
documentGenerator: options.resolveDocumentGenerator?.(bindings) ?? options.documentGenerator,
|
|
5
5
|
documentStorage: options.resolveDocumentStorage?.(bindings) ?? options.documentStorage,
|
|
6
|
+
resolveDocumentDownloadUrl: options.resolveDocumentDownloadUrl,
|
|
6
7
|
eventBus: options.resolveEventBus?.(bindings) ?? options.eventBus,
|
|
7
8
|
lifecycleHooks: options.resolveLifecycleHooks?.(bindings) ?? options.lifecycleHooks,
|
|
8
9
|
};
|
|
@@ -1426,8 +1426,6 @@ export declare function createContractsAdminRoutes(options?: ContractsRouteOptio
|
|
|
1426
1426
|
};
|
|
1427
1427
|
output: {
|
|
1428
1428
|
data: {
|
|
1429
|
-
status: "not_found" | "not_draft" | "render_unavailable" | "generator_failed";
|
|
1430
|
-
} | {
|
|
1431
1429
|
status: "generated";
|
|
1432
1430
|
contractId: string;
|
|
1433
1431
|
contractStatus: "executed" | "void" | "draft" | "sent" | "expired" | "issued" | "signed";
|
|
@@ -1505,8 +1503,6 @@ export declare function createContractsAdminRoutes(options?: ContractsRouteOptio
|
|
|
1505
1503
|
};
|
|
1506
1504
|
output: {
|
|
1507
1505
|
data: {
|
|
1508
|
-
status: "not_found" | "not_draft" | "render_unavailable" | "generator_failed";
|
|
1509
|
-
} | {
|
|
1510
1506
|
status: "generated";
|
|
1511
1507
|
contractId: string;
|
|
1512
1508
|
contractStatus: "executed" | "void" | "draft" | "sent" | "expired" | "issued" | "signed";
|
|
@@ -1584,8 +1580,6 @@ export declare function createContractsAdminRoutes(options?: ContractsRouteOptio
|
|
|
1584
1580
|
};
|
|
1585
1581
|
output: {
|
|
1586
1582
|
data: {
|
|
1587
|
-
status: "not_found" | "not_draft" | "render_unavailable" | "generator_failed";
|
|
1588
|
-
} | {
|
|
1589
1583
|
status: "generated";
|
|
1590
1584
|
contractId: string;
|
|
1591
1585
|
contractStatus: "executed" | "void" | "draft" | "sent" | "expired" | "issued" | "signed";
|
|
@@ -3298,8 +3292,6 @@ export declare const contractsAdminRoutes: import("hono/hono-base").HonoBase<Env
|
|
|
3298
3292
|
};
|
|
3299
3293
|
output: {
|
|
3300
3294
|
data: {
|
|
3301
|
-
status: "not_found" | "not_draft" | "render_unavailable" | "generator_failed";
|
|
3302
|
-
} | {
|
|
3303
3295
|
status: "generated";
|
|
3304
3296
|
contractId: string;
|
|
3305
3297
|
contractStatus: "executed" | "void" | "draft" | "sent" | "expired" | "issued" | "signed";
|
|
@@ -3377,8 +3369,6 @@ export declare const contractsAdminRoutes: import("hono/hono-base").HonoBase<Env
|
|
|
3377
3369
|
};
|
|
3378
3370
|
output: {
|
|
3379
3371
|
data: {
|
|
3380
|
-
status: "not_found" | "not_draft" | "render_unavailable" | "generator_failed";
|
|
3381
|
-
} | {
|
|
3382
3372
|
status: "generated";
|
|
3383
3373
|
contractId: string;
|
|
3384
3374
|
contractStatus: "executed" | "void" | "draft" | "sent" | "expired" | "issued" | "signed";
|
|
@@ -3456,8 +3446,6 @@ export declare const contractsAdminRoutes: import("hono/hono-base").HonoBase<Env
|
|
|
3456
3446
|
};
|
|
3457
3447
|
output: {
|
|
3458
3448
|
data: {
|
|
3459
|
-
status: "not_found" | "not_draft" | "render_unavailable" | "generator_failed";
|
|
3460
|
-
} | {
|
|
3461
3449
|
status: "generated";
|
|
3462
3450
|
contractId: string;
|
|
3463
3451
|
contractStatus: "executed" | "void" | "draft" | "sent" | "expired" | "issued" | "signed";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"routes.d.ts","sourceRoot":"","sources":["../../src/contracts/routes.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAA;
|
|
1
|
+
{"version":3,"file":"routes.d.ts","sourceRoot":"","sources":["../../src/contracts/routes.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAA;AAO/D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAA;AACxD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAA;AAGjE,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,gBAAgB,CAAA;AAO3D,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAA;AAwB/C,KAAK,GAAG,GAAG;IACT,QAAQ,EAAE,MAAM,CAA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;;;;;;;;;;;;;;;qBAyC9E;AAED,eAAO,MAAM,qBAAqB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;oBAAgC,CAAA;AAElE,MAAM,MAAM,oBAAoB,GAAG,OAAO,oBAAoB,CAAA;AAC9D,MAAM,MAAM,qBAAqB,GAAG,OAAO,qBAAqB,CAAA"}
|
package/dist/contracts/routes.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { parseJsonBody, parseOptionalJsonBody, parseQuery } from "@voyantjs/hono";
|
|
1
|
+
import { parseJsonBody, parseOptionalJsonBody, parseQuery, resolveStoredDocumentDownload, } from "@voyantjs/hono";
|
|
2
2
|
import { Hono } from "hono";
|
|
3
3
|
import { buildContractsRouteRuntime, CONTRACTS_ROUTE_RUNTIME_CONTAINER_KEY, } from "./route-runtime.js";
|
|
4
4
|
import { renderPreviewResponse } from "./route-template-preview.js";
|
|
@@ -9,22 +9,6 @@ function getRuntime(options, bindings, resolveFromContainer) {
|
|
|
9
9
|
return (resolveFromContainer?.(CONTRACTS_ROUTE_RUNTIME_CONTAINER_KEY) ??
|
|
10
10
|
buildContractsRouteRuntime(bindings, options));
|
|
11
11
|
}
|
|
12
|
-
function getMetadataRecord(metadata) {
|
|
13
|
-
if (!metadata || typeof metadata !== "object" || Array.isArray(metadata)) {
|
|
14
|
-
return null;
|
|
15
|
-
}
|
|
16
|
-
return metadata;
|
|
17
|
-
}
|
|
18
|
-
function maybeUrl(value) {
|
|
19
|
-
return typeof value === "string" && /^https?:\/\//i.test(value) ? value : null;
|
|
20
|
-
}
|
|
21
|
-
function getFallbackDownloadUrl(metadata) {
|
|
22
|
-
const record = getMetadataRecord(metadata);
|
|
23
|
-
if (!record) {
|
|
24
|
-
return null;
|
|
25
|
-
}
|
|
26
|
-
return maybeUrl(record.url);
|
|
27
|
-
}
|
|
28
12
|
function getMultipartString(value) {
|
|
29
13
|
const resolved = Array.isArray(value) ? value[0] : value;
|
|
30
14
|
return typeof resolved === "string" ? resolved : null;
|
|
@@ -178,7 +162,10 @@ async function regenerateContractDocument(c, options, contractId) {
|
|
|
178
162
|
if (result.status === "generator_failed") {
|
|
179
163
|
return c.json({ error: "Contract document generation failed" }, 502);
|
|
180
164
|
}
|
|
181
|
-
|
|
165
|
+
if (!("attachment" in result)) {
|
|
166
|
+
return c.json({ error: "Contract document generation failed" }, 502);
|
|
167
|
+
}
|
|
168
|
+
return c.json({ data: await attachDownloadEnvelope(c.env, runtime, result) });
|
|
182
169
|
}
|
|
183
170
|
async function generateContractDocumentForBooking(c, options) {
|
|
184
171
|
const runtime = getRuntime(options, c.env, (key) => c.var.container?.resolve(key));
|
|
@@ -225,7 +212,9 @@ async function generateContractDocumentForBooking(c, options) {
|
|
|
225
212
|
if (!contract || !attachment) {
|
|
226
213
|
return c.json({ error: "Generated contract document could not be loaded" }, 500);
|
|
227
214
|
}
|
|
228
|
-
return c.json({
|
|
215
|
+
return c.json({
|
|
216
|
+
data: await attachDownloadEnvelope(c.env, runtime, { contract, attachment }),
|
|
217
|
+
}, 201);
|
|
229
218
|
}
|
|
230
219
|
export function createContractsAdminRoutes(options = {}) {
|
|
231
220
|
return new Hono()
|
|
@@ -425,7 +414,10 @@ export function createContractsAdminRoutes(options = {}) {
|
|
|
425
414
|
if (result.status === "generator_failed") {
|
|
426
415
|
return c.json({ error: "Contract document generation failed" }, 502);
|
|
427
416
|
}
|
|
428
|
-
|
|
417
|
+
if (!("attachment" in result)) {
|
|
418
|
+
return c.json({ error: "Contract document generation failed" }, 502);
|
|
419
|
+
}
|
|
420
|
+
return c.json({ data: await attachDownloadEnvelope(c.env, runtime, result) }, 201);
|
|
429
421
|
})
|
|
430
422
|
.post("/:id/regenerate-document", async (c) => {
|
|
431
423
|
return regenerateContractDocument(c, options, c.req.param("id"));
|
|
@@ -493,18 +485,18 @@ export function createContractsAdminRoutes(options = {}) {
|
|
|
493
485
|
const attachment = await contractsService.getAttachmentById(c.get("db"), c.req.param("attachmentId"));
|
|
494
486
|
if (!attachment)
|
|
495
487
|
return c.json({ error: "Attachment not found" }, 404);
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
488
|
+
const runtime = getRuntime(options, c.env, (key) => c.var.container?.resolve(key));
|
|
489
|
+
const download = await resolveStoredDocumentDownload({ ...attachment, filename: attachment.name }, {
|
|
490
|
+
bindings: c.env,
|
|
491
|
+
resolveDocumentDownloadUrl: runtime.resolveDocumentDownloadUrl,
|
|
492
|
+
});
|
|
493
|
+
if (download.status === "resolver_not_configured") {
|
|
494
|
+
return c.json({ error: "Document download resolver is not configured" }, 501);
|
|
502
495
|
}
|
|
503
|
-
|
|
504
|
-
if (!location) {
|
|
496
|
+
if (download.status !== "ready") {
|
|
505
497
|
return c.json({ error: "Attachment file is not available" }, 404);
|
|
506
498
|
}
|
|
507
|
-
return c.redirect(
|
|
499
|
+
return c.redirect(download.download.url, 302);
|
|
508
500
|
})
|
|
509
501
|
.delete("/attachments/:attachmentId", async (c) => {
|
|
510
502
|
const row = await contractsService.deleteAttachment(c.get("db"), c.req.param("attachmentId"));
|
|
@@ -514,6 +506,13 @@ export function createContractsAdminRoutes(options = {}) {
|
|
|
514
506
|
});
|
|
515
507
|
}
|
|
516
508
|
export const contractsAdminRoutes = createContractsAdminRoutes();
|
|
509
|
+
async function attachDownloadEnvelope(bindings, runtime, result) {
|
|
510
|
+
const download = await resolveStoredDocumentDownload({ ...result.attachment, filename: result.attachment.name }, {
|
|
511
|
+
bindings,
|
|
512
|
+
resolveDocumentDownloadUrl: runtime.resolveDocumentDownloadUrl,
|
|
513
|
+
});
|
|
514
|
+
return download.status === "ready" ? { ...result, download: download.download } : result;
|
|
515
|
+
}
|
|
517
516
|
export function createContractsPublicRoutes(options = {}) {
|
|
518
517
|
return (new Hono()
|
|
519
518
|
.get("/templates/default", async (c) => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@voyantjs/legal",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.77.0",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -59,14 +59,14 @@
|
|
|
59
59
|
"drizzle-orm": "^0.45.2",
|
|
60
60
|
"hono": "^4.12.10",
|
|
61
61
|
"zod": "^4.3.6",
|
|
62
|
-
"@voyantjs/bookings": "0.
|
|
63
|
-
"@voyantjs/core": "0.
|
|
64
|
-
"@voyantjs/crm": "0.
|
|
65
|
-
"@voyantjs/db": "0.
|
|
66
|
-
"@voyantjs/hono": "0.
|
|
67
|
-
"@voyantjs/suppliers": "0.
|
|
68
|
-
"@voyantjs/utils": "0.
|
|
69
|
-
"@voyantjs/storage": "0.
|
|
62
|
+
"@voyantjs/bookings": "0.77.0",
|
|
63
|
+
"@voyantjs/core": "0.77.0",
|
|
64
|
+
"@voyantjs/crm": "0.77.0",
|
|
65
|
+
"@voyantjs/db": "0.77.0",
|
|
66
|
+
"@voyantjs/hono": "0.77.0",
|
|
67
|
+
"@voyantjs/suppliers": "0.77.0",
|
|
68
|
+
"@voyantjs/utils": "0.77.0",
|
|
69
|
+
"@voyantjs/storage": "0.77.0"
|
|
70
70
|
},
|
|
71
71
|
"devDependencies": {
|
|
72
72
|
"typescript": "^6.0.2",
|