@voyantjs/legal 0.2.0 → 0.3.1

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 (32) hide show
  1. package/dist/contracts/routes.d.ts +94 -1
  2. package/dist/contracts/routes.d.ts.map +1 -1
  3. package/dist/contracts/routes.js +27 -1
  4. package/dist/contracts/service-contracts.d.ts +1234 -0
  5. package/dist/contracts/service-contracts.d.ts.map +1 -0
  6. package/dist/contracts/service-contracts.js +233 -0
  7. package/dist/contracts/service-series.d.ts +68 -0
  8. package/dist/contracts/service-series.d.ts.map +1 -0
  9. package/dist/contracts/service-series.js +34 -0
  10. package/dist/contracts/service-shared.d.ts +32 -0
  11. package/dist/contracts/service-shared.d.ts.map +1 -0
  12. package/dist/contracts/service-shared.js +142 -0
  13. package/dist/contracts/service-templates.d.ts +434 -0
  14. package/dist/contracts/service-templates.d.ts.map +1 -0
  15. package/dist/contracts/service-templates.js +132 -0
  16. package/dist/contracts/service.d.ts +882 -909
  17. package/dist/contracts/service.d.ts.map +1 -1
  18. package/dist/contracts/service.js +8 -568
  19. package/dist/contracts/validation.d.ts +14 -0
  20. package/dist/contracts/validation.d.ts.map +1 -1
  21. package/dist/contracts/validation.js +16 -0
  22. package/dist/policies/routes.d.ts +2 -2
  23. package/dist/policies/service-core.d.ts +1336 -0
  24. package/dist/policies/service-core.d.ts.map +1 -0
  25. package/dist/policies/service-core.js +357 -0
  26. package/dist/policies/service-shared.d.ts +43 -0
  27. package/dist/policies/service-shared.d.ts.map +1 -0
  28. package/dist/policies/service-shared.js +30 -0
  29. package/dist/policies/service.d.ts +28 -76
  30. package/dist/policies/service.d.ts.map +1 -1
  31. package/dist/policies/service.js +4 -436
  32. package/package.json +6 -6
@@ -33,6 +33,38 @@ export declare const contractsAdminRoutes: import("hono/hono-base").HonoBase<Env
33
33
  status: import("hono/utils/http-status").ContentfulStatusCode;
34
34
  };
35
35
  };
36
+ } & {
37
+ "/templates/default": {
38
+ $get: {
39
+ input: {};
40
+ output: {
41
+ error: string;
42
+ };
43
+ outputFormat: "json";
44
+ status: 404;
45
+ } | {
46
+ input: {};
47
+ output: {
48
+ data: {
49
+ id: string;
50
+ name: string;
51
+ slug: string;
52
+ scope: "customer" | "partner" | "supplier" | "other" | "channel";
53
+ language: string;
54
+ description: string | null;
55
+ bodyFormat: "markdown" | "html" | "lexical_json";
56
+ body: string;
57
+ variableSchema: import("hono/utils/types").JSONValue;
58
+ currentVersionId: string | null;
59
+ active: boolean;
60
+ createdAt: string;
61
+ updatedAt: string;
62
+ };
63
+ };
64
+ outputFormat: "json";
65
+ status: import("hono/utils/http-status").ContentfulStatusCode;
66
+ };
67
+ };
36
68
  } & {
37
69
  "/templates": {
38
70
  $post: {
@@ -497,9 +529,9 @@ export declare const contractsAdminRoutes: import("hono/hono-base").HonoBase<Env
497
529
  createdAt: string;
498
530
  updatedAt: string;
499
531
  organizationId: string | null;
500
- title: string;
501
532
  personId: string | null;
502
533
  sentAt: string | null;
534
+ title: string;
503
535
  metadata: import("hono/utils/types").JSONValue;
504
536
  supplierId: string | null;
505
537
  scope: "customer" | "partner" | "supplier" | "other" | "channel";
@@ -1186,6 +1218,67 @@ export declare const contractsAdminRoutes: import("hono/hono-base").HonoBase<Env
1186
1218
  }, "/", "/attachments/:attachmentId">;
1187
1219
  export type ContractsAdminRoutes = typeof contractsAdminRoutes;
1188
1220
  export declare const contractsPublicRoutes: import("hono/hono-base").HonoBase<Env, {
1221
+ "/templates/default": {
1222
+ $get: {
1223
+ input: {};
1224
+ output: {
1225
+ error: string;
1226
+ };
1227
+ outputFormat: "json";
1228
+ status: 404;
1229
+ } | {
1230
+ input: {};
1231
+ output: {
1232
+ data: {
1233
+ id: string;
1234
+ name: string;
1235
+ slug: string;
1236
+ scope: "customer" | "partner" | "supplier" | "other" | "channel";
1237
+ language: string;
1238
+ description: string | null;
1239
+ bodyFormat: "markdown" | "html" | "lexical_json";
1240
+ body: string;
1241
+ variableSchema: import("hono/utils/types").JSONValue;
1242
+ currentVersionId: string | null;
1243
+ active: boolean;
1244
+ createdAt: string;
1245
+ updatedAt: string;
1246
+ };
1247
+ };
1248
+ outputFormat: "json";
1249
+ status: import("hono/utils/http-status").ContentfulStatusCode;
1250
+ };
1251
+ };
1252
+ } & {
1253
+ "/templates/:id/preview": {
1254
+ $post: {
1255
+ input: {
1256
+ param: {
1257
+ id: string;
1258
+ };
1259
+ };
1260
+ output: {
1261
+ error: string;
1262
+ };
1263
+ outputFormat: "json";
1264
+ status: 404;
1265
+ } | {
1266
+ input: {
1267
+ param: {
1268
+ id: string;
1269
+ };
1270
+ };
1271
+ output: {
1272
+ data: {
1273
+ rendered: string;
1274
+ bodyFormat: "markdown" | "html" | "lexical_json";
1275
+ };
1276
+ };
1277
+ outputFormat: "json";
1278
+ status: import("hono/utils/http-status").ContentfulStatusCode;
1279
+ };
1280
+ };
1281
+ } & {
1189
1282
  "/:id": {
1190
1283
  $get: {
1191
1284
  input: {
@@ -1 +1 @@
1
- {"version":3,"file":"routes.d.ts","sourceRoot":"","sources":["../../src/contracts/routes.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAA;AAoBjE,KAAK,GAAG,GAAG;IACT,SAAS,EAAE;QACT,EAAE,EAAE,kBAAkB,CAAA;QACtB,MAAM,CAAC,EAAE,MAAM,CAAA;KAChB,CAAA;CACF,CAAA;AAMD,eAAO,MAAM,oBAAoB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;qCA6P7B,CAAA;AAEJ,MAAM,MAAM,oBAAoB,GAAG,OAAO,oBAAoB,CAAA;AAO9D,eAAO,MAAM,qBAAqB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;oBAuC9B,CAAA;AAEJ,MAAM,MAAM,qBAAqB,GAAG,OAAO,qBAAqB,CAAA"}
@@ -1,6 +1,6 @@
1
1
  import { Hono } from "hono";
2
2
  import { contractsService } from "./service.js";
3
- import { contractListQuerySchema, contractTemplateListQuerySchema, insertContractAttachmentSchema, insertContractNumberSeriesSchema, insertContractSchema, insertContractSignatureSchema, insertContractTemplateSchema, insertContractTemplateVersionSchema, renderTemplateInputSchema, updateContractAttachmentSchema, updateContractNumberSeriesSchema, updateContractSchema, updateContractTemplateSchema, } from "./validation.js";
3
+ import { contractListQuerySchema, contractTemplateDefaultQuerySchema, contractTemplateListQuerySchema, insertContractAttachmentSchema, insertContractNumberSeriesSchema, insertContractSchema, insertContractSignatureSchema, insertContractTemplateSchema, insertContractTemplateVersionSchema, publicRenderTemplatePreviewInputSchema, renderTemplateInputSchema, updateContractAttachmentSchema, updateContractNumberSeriesSchema, updateContractSchema, updateContractTemplateSchema, } from "./validation.js";
4
4
  // ============================================================================
5
5
  // Contracts admin routes — `/v1/admin/contracts/*`
6
6
  // ============================================================================
@@ -9,6 +9,13 @@ export const contractsAdminRoutes = new Hono()
9
9
  .get("/templates", async (c) => {
10
10
  const query = contractTemplateListQuerySchema.parse(Object.fromEntries(new URL(c.req.url).searchParams));
11
11
  return c.json(await contractsService.listTemplates(c.get("db"), query));
12
+ })
13
+ .get("/templates/default", async (c) => {
14
+ const query = contractTemplateDefaultQuerySchema.parse(Object.fromEntries(new URL(c.req.url).searchParams));
15
+ const row = await contractsService.getDefaultTemplate(c.get("db"), query);
16
+ if (!row)
17
+ return c.json({ error: "Template not found" }, 404);
18
+ return c.json({ data: row });
12
19
  })
13
20
  .post("/templates", async (c) => {
14
21
  const row = await contractsService.createTemplate(c.get("db"), insertContractTemplateSchema.parse(await c.req.json()));
@@ -204,6 +211,25 @@ export const contractsAdminRoutes = new Hono()
204
211
  // Customer-facing: fetch own contract + self-sign
205
212
  // ============================================================================
206
213
  export const contractsPublicRoutes = new Hono()
214
+ .get("/templates/default", async (c) => {
215
+ const query = contractTemplateDefaultQuerySchema.parse(Object.fromEntries(new URL(c.req.url).searchParams));
216
+ const row = await contractsService.getDefaultTemplate(c.get("db"), query);
217
+ if (!row)
218
+ return c.json({ error: "Template not found" }, 404);
219
+ return c.json({ data: row });
220
+ })
221
+ .post("/templates/:id/preview", async (c) => {
222
+ const input = publicRenderTemplatePreviewInputSchema.parse(await c.req.json());
223
+ const template = await contractsService.getTemplateById(c.get("db"), c.req.param("id"));
224
+ if (!template?.active)
225
+ return c.json({ error: "Template not found" }, 404);
226
+ const rendered = contractsService.renderPreview({
227
+ variables: input.variables,
228
+ body: template.body,
229
+ bodyFormat: template.bodyFormat,
230
+ });
231
+ return c.json({ data: { rendered, bodyFormat: template.bodyFormat } });
232
+ })
207
233
  .get("/:id", async (c) => {
208
234
  const row = await contractsService.getContractById(c.get("db"), c.req.param("id"));
209
235
  if (!row)