@voyantjs/legal-react 0.2.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.
Files changed (94) hide show
  1. package/dist/client.d.ts +14 -0
  2. package/dist/client.d.ts.map +1 -0
  3. package/dist/client.js +58 -0
  4. package/dist/hooks/index.d.ts +25 -0
  5. package/dist/hooks/index.d.ts.map +1 -0
  6. package/dist/hooks/index.js +24 -0
  7. package/dist/hooks/use-contract-attachment-mutation.d.ts +53 -0
  8. package/dist/hooks/use-contract-attachment-mutation.d.ts.map +1 -0
  9. package/dist/hooks/use-contract-attachment-mutation.js +41 -0
  10. package/dist/hooks/use-contract-attachments.d.ts +17 -0
  11. package/dist/hooks/use-contract-attachments.d.ts.map +1 -0
  12. package/dist/hooks/use-contract-attachments.js +12 -0
  13. package/dist/hooks/use-contract-mutation.d.ts +191 -0
  14. package/dist/hooks/use-contract-mutation.d.ts.map +1 -0
  15. package/dist/hooks/use-contract-mutation.js +82 -0
  16. package/dist/hooks/use-contract-signature-mutation.d.ts +29 -0
  17. package/dist/hooks/use-contract-signature-mutation.d.ts.map +1 -0
  18. package/dist/hooks/use-contract-signature-mutation.js +23 -0
  19. package/dist/hooks/use-contract-signatures.d.ts +22 -0
  20. package/dist/hooks/use-contract-signatures.d.ts.map +1 -0
  21. package/dist/hooks/use-contract-signatures.js +12 -0
  22. package/dist/hooks/use-contract-template-mutation.d.ts +53 -0
  23. package/dist/hooks/use-contract-template-mutation.d.ts.map +1 -0
  24. package/dist/hooks/use-contract-template-mutation.js +39 -0
  25. package/dist/hooks/use-contract-template-version-mutation.d.ts +23 -0
  26. package/dist/hooks/use-contract-template-version-mutation.d.ts.map +1 -0
  27. package/dist/hooks/use-contract-template-version-mutation.js +22 -0
  28. package/dist/hooks/use-contract-template-versions.d.ts +16 -0
  29. package/dist/hooks/use-contract-template-versions.d.ts.map +1 -0
  30. package/dist/hooks/use-contract-template-versions.js +12 -0
  31. package/dist/hooks/use-contract-template.d.ts +19 -0
  32. package/dist/hooks/use-contract-template.d.ts.map +1 -0
  33. package/dist/hooks/use-contract-template.js +12 -0
  34. package/dist/hooks/use-contract-templates.d.ts +25 -0
  35. package/dist/hooks/use-contract-templates.d.ts.map +1 -0
  36. package/dist/hooks/use-contract-templates.js +12 -0
  37. package/dist/hooks/use-contract.d.ts +31 -0
  38. package/dist/hooks/use-contract.d.ts.map +1 -0
  39. package/dist/hooks/use-contract.js +12 -0
  40. package/dist/hooks/use-contracts.d.ts +37 -0
  41. package/dist/hooks/use-contracts.d.ts.map +1 -0
  42. package/dist/hooks/use-contracts.js +12 -0
  43. package/dist/hooks/use-number-series-mutation.d.ts +52 -0
  44. package/dist/hooks/use-number-series-mutation.d.ts.map +1 -0
  45. package/dist/hooks/use-number-series-mutation.js +38 -0
  46. package/dist/hooks/use-number-series.d.ts +25 -0
  47. package/dist/hooks/use-number-series.d.ts.map +1 -0
  48. package/dist/hooks/use-number-series.js +12 -0
  49. package/dist/hooks/use-policies.d.ts +22 -0
  50. package/dist/hooks/use-policies.d.ts.map +1 -0
  51. package/dist/hooks/use-policies.js +12 -0
  52. package/dist/hooks/use-policy-acceptances.d.ts +22 -0
  53. package/dist/hooks/use-policy-acceptances.d.ts.map +1 -0
  54. package/dist/hooks/use-policy-acceptances.js +12 -0
  55. package/dist/hooks/use-policy-assignment-mutation.d.ts +63 -0
  56. package/dist/hooks/use-policy-assignment-mutation.d.ts.map +1 -0
  57. package/dist/hooks/use-policy-assignment-mutation.js +41 -0
  58. package/dist/hooks/use-policy-assignments.d.ts +23 -0
  59. package/dist/hooks/use-policy-assignments.d.ts.map +1 -0
  60. package/dist/hooks/use-policy-assignments.js +12 -0
  61. package/dist/hooks/use-policy-mutation.d.ts +44 -0
  62. package/dist/hooks/use-policy-mutation.d.ts.map +1 -0
  63. package/dist/hooks/use-policy-mutation.js +40 -0
  64. package/dist/hooks/use-policy-rule-mutation.d.ts +56 -0
  65. package/dist/hooks/use-policy-rule-mutation.d.ts.map +1 -0
  66. package/dist/hooks/use-policy-rule-mutation.js +39 -0
  67. package/dist/hooks/use-policy-rules.d.ts +22 -0
  68. package/dist/hooks/use-policy-rules.d.ts.map +1 -0
  69. package/dist/hooks/use-policy-rules.js +12 -0
  70. package/dist/hooks/use-policy-version-mutation.d.ts +73 -0
  71. package/dist/hooks/use-policy-version-mutation.d.ts.map +1 -0
  72. package/dist/hooks/use-policy-version-mutation.js +50 -0
  73. package/dist/hooks/use-policy-versions.d.ts +20 -0
  74. package/dist/hooks/use-policy-versions.d.ts.map +1 -0
  75. package/dist/hooks/use-policy-versions.js +12 -0
  76. package/dist/hooks/use-policy.d.ts +16 -0
  77. package/dist/hooks/use-policy.d.ts.map +1 -0
  78. package/dist/hooks/use-policy.js +12 -0
  79. package/dist/index.d.ts +7 -0
  80. package/dist/index.d.ts.map +1 -0
  81. package/dist/index.js +6 -0
  82. package/dist/provider.d.ts +2 -0
  83. package/dist/provider.d.ts.map +1 -0
  84. package/dist/provider.js +1 -0
  85. package/dist/query-keys.d.ts +68 -0
  86. package/dist/query-keys.d.ts.map +1 -0
  87. package/dist/query-keys.js +22 -0
  88. package/dist/query-options.d.ts +1200 -0
  89. package/dist/query-options.d.ts.map +1 -0
  90. package/dist/query-options.js +152 -0
  91. package/dist/schemas.d.ts +779 -0
  92. package/dist/schemas.d.ts.map +1 -0
  93. package/dist/schemas.js +163 -0
  94. package/package.json +79 -0
@@ -0,0 +1,14 @@
1
+ import type { z } from "zod";
2
+ export type VoyantFetcher = (url: string, init?: RequestInit) => Promise<Response>;
3
+ export declare const defaultFetcher: VoyantFetcher;
4
+ export declare class VoyantApiError extends Error {
5
+ readonly status: number;
6
+ readonly body: unknown;
7
+ constructor(message: string, status: number, body: unknown);
8
+ }
9
+ export interface FetchWithValidationOptions {
10
+ baseUrl: string;
11
+ fetcher: VoyantFetcher;
12
+ }
13
+ export declare function fetchWithValidation<TOut>(path: string, schema: z.ZodType<TOut>, options: FetchWithValidationOptions, init?: RequestInit): Promise<TOut>;
14
+ //# sourceMappingURL=client.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAE5B,MAAM,MAAM,aAAa,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,WAAW,KAAK,OAAO,CAAC,QAAQ,CAAC,CAAA;AAElF,eAAO,MAAM,cAAc,EAAE,aACoB,CAAA;AAEjD,qBAAa,cAAe,SAAQ,KAAK;IACvC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;IACvB,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAA;gBAEV,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO;CAM3D;AAaD,MAAM,WAAW,0BAA0B;IACzC,OAAO,EAAE,MAAM,CAAA;IACf,OAAO,EAAE,aAAa,CAAA;CACvB;AAED,wBAAsB,mBAAmB,CAAC,IAAI,EAC5C,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,EACvB,OAAO,EAAE,0BAA0B,EACnC,IAAI,CAAC,EAAE,WAAW,GACjB,OAAO,CAAC,IAAI,CAAC,CA8Bf"}
package/dist/client.js ADDED
@@ -0,0 +1,58 @@
1
+ export const defaultFetcher = (url, init) => fetch(url, { credentials: "include", ...init });
2
+ export class VoyantApiError extends Error {
3
+ status;
4
+ body;
5
+ constructor(message, status, body) {
6
+ super(message);
7
+ this.name = "VoyantApiError";
8
+ this.status = status;
9
+ this.body = body;
10
+ }
11
+ }
12
+ function extractErrorMessage(status, statusText, body) {
13
+ if (typeof body === "object" && body !== null && "error" in body) {
14
+ const err = body.error;
15
+ if (typeof err === "string")
16
+ return err;
17
+ if (typeof err === "object" && err !== null && "message" in err) {
18
+ return String(err.message);
19
+ }
20
+ }
21
+ return `Voyant API error: ${status} ${statusText}`;
22
+ }
23
+ export async function fetchWithValidation(path, schema, options, init) {
24
+ const url = joinUrl(options.baseUrl, path);
25
+ const headers = new Headers(init?.headers);
26
+ if (init?.body !== undefined && !headers.has("Content-Type")) {
27
+ headers.set("Content-Type", "application/json");
28
+ }
29
+ const response = await options.fetcher(url, { ...init, headers });
30
+ if (!response.ok) {
31
+ const body = await safeJson(response);
32
+ throw new VoyantApiError(extractErrorMessage(response.status, response.statusText, body), response.status, body);
33
+ }
34
+ if (response.status === 204)
35
+ return schema.parse(undefined);
36
+ const body = await safeJson(response);
37
+ const parsed = schema.safeParse(body);
38
+ if (!parsed.success) {
39
+ throw new VoyantApiError(`Voyant API response failed validation: ${parsed.error.message}`, response.status, body);
40
+ }
41
+ return parsed.data;
42
+ }
43
+ async function safeJson(response) {
44
+ const text = await response.text();
45
+ if (!text)
46
+ return undefined;
47
+ try {
48
+ return JSON.parse(text);
49
+ }
50
+ catch {
51
+ return text;
52
+ }
53
+ }
54
+ function joinUrl(baseUrl, path) {
55
+ const trimmedBase = baseUrl.endsWith("/") ? baseUrl.slice(0, -1) : baseUrl;
56
+ const trimmedPath = path.startsWith("/") ? path : `/${path}`;
57
+ return `${trimmedBase}${trimmedPath}`;
58
+ }
@@ -0,0 +1,25 @@
1
+ export * from "./use-contract.js";
2
+ export * from "./use-contract-attachment-mutation.js";
3
+ export * from "./use-contract-attachments.js";
4
+ export * from "./use-contract-mutation.js";
5
+ export * from "./use-contract-signature-mutation.js";
6
+ export * from "./use-contract-signatures.js";
7
+ export * from "./use-contract-template.js";
8
+ export * from "./use-contract-template-mutation.js";
9
+ export * from "./use-contract-template-version-mutation.js";
10
+ export * from "./use-contract-template-versions.js";
11
+ export * from "./use-contract-templates.js";
12
+ export * from "./use-contracts.js";
13
+ export * from "./use-number-series.js";
14
+ export * from "./use-number-series-mutation.js";
15
+ export * from "./use-policies.js";
16
+ export * from "./use-policy.js";
17
+ export * from "./use-policy-acceptances.js";
18
+ export * from "./use-policy-assignment-mutation.js";
19
+ export * from "./use-policy-assignments.js";
20
+ export * from "./use-policy-mutation.js";
21
+ export * from "./use-policy-rule-mutation.js";
22
+ export * from "./use-policy-rules.js";
23
+ export * from "./use-policy-version-mutation.js";
24
+ export * from "./use-policy-versions.js";
25
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/hooks/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAA;AACjC,cAAc,uCAAuC,CAAA;AACrD,cAAc,+BAA+B,CAAA;AAC7C,cAAc,4BAA4B,CAAA;AAC1C,cAAc,sCAAsC,CAAA;AACpD,cAAc,8BAA8B,CAAA;AAC5C,cAAc,4BAA4B,CAAA;AAC1C,cAAc,qCAAqC,CAAA;AACnD,cAAc,6CAA6C,CAAA;AAC3D,cAAc,qCAAqC,CAAA;AACnD,cAAc,6BAA6B,CAAA;AAC3C,cAAc,oBAAoB,CAAA;AAClC,cAAc,wBAAwB,CAAA;AACtC,cAAc,iCAAiC,CAAA;AAC/C,cAAc,mBAAmB,CAAA;AACjC,cAAc,iBAAiB,CAAA;AAC/B,cAAc,6BAA6B,CAAA;AAC3C,cAAc,qCAAqC,CAAA;AACnD,cAAc,6BAA6B,CAAA;AAC3C,cAAc,0BAA0B,CAAA;AACxC,cAAc,+BAA+B,CAAA;AAC7C,cAAc,uBAAuB,CAAA;AACrC,cAAc,kCAAkC,CAAA;AAChD,cAAc,0BAA0B,CAAA"}
@@ -0,0 +1,24 @@
1
+ export * from "./use-contract.js";
2
+ export * from "./use-contract-attachment-mutation.js";
3
+ export * from "./use-contract-attachments.js";
4
+ export * from "./use-contract-mutation.js";
5
+ export * from "./use-contract-signature-mutation.js";
6
+ export * from "./use-contract-signatures.js";
7
+ export * from "./use-contract-template.js";
8
+ export * from "./use-contract-template-mutation.js";
9
+ export * from "./use-contract-template-version-mutation.js";
10
+ export * from "./use-contract-template-versions.js";
11
+ export * from "./use-contract-templates.js";
12
+ export * from "./use-contracts.js";
13
+ export * from "./use-number-series.js";
14
+ export * from "./use-number-series-mutation.js";
15
+ export * from "./use-policies.js";
16
+ export * from "./use-policy.js";
17
+ export * from "./use-policy-acceptances.js";
18
+ export * from "./use-policy-assignment-mutation.js";
19
+ export * from "./use-policy-assignments.js";
20
+ export * from "./use-policy-mutation.js";
21
+ export * from "./use-policy-rule-mutation.js";
22
+ export * from "./use-policy-rules.js";
23
+ export * from "./use-policy-version-mutation.js";
24
+ export * from "./use-policy-versions.js";
@@ -0,0 +1,53 @@
1
+ import type { insertContractAttachmentSchema, updateContractAttachmentSchema } from "@voyantjs/legal/contracts/validation";
2
+ import type { z } from "zod";
3
+ export type CreateLegalContractAttachmentInput = z.input<typeof insertContractAttachmentSchema>;
4
+ export type UpdateLegalContractAttachmentInput = z.input<typeof updateContractAttachmentSchema>;
5
+ export declare function useLegalContractAttachmentMutation(): {
6
+ create: import("@tanstack/react-query").UseMutationResult<{
7
+ contractId: string;
8
+ data: {
9
+ kind: string;
10
+ name: string;
11
+ id: string;
12
+ contractId: string;
13
+ mimeType: string | null;
14
+ fileSize: number | null;
15
+ storageKey: string | null;
16
+ checksum: string | null;
17
+ createdAt: string;
18
+ metadata?: Record<string, unknown> | null | undefined;
19
+ };
20
+ }, Error, {
21
+ contractId: string;
22
+ input: CreateLegalContractAttachmentInput;
23
+ }, unknown>;
24
+ update: import("@tanstack/react-query").UseMutationResult<{
25
+ contractId: string;
26
+ data: {
27
+ kind: string;
28
+ name: string;
29
+ id: string;
30
+ contractId: string;
31
+ mimeType: string | null;
32
+ fileSize: number | null;
33
+ storageKey: string | null;
34
+ checksum: string | null;
35
+ createdAt: string;
36
+ metadata?: Record<string, unknown> | null | undefined;
37
+ };
38
+ }, Error, {
39
+ contractId: string;
40
+ id: string;
41
+ input: UpdateLegalContractAttachmentInput;
42
+ }, unknown>;
43
+ remove: import("@tanstack/react-query").UseMutationResult<{
44
+ contractId: string;
45
+ data: {
46
+ success: boolean;
47
+ };
48
+ }, Error, {
49
+ contractId: string;
50
+ id: string;
51
+ }, unknown>;
52
+ };
53
+ //# sourceMappingURL=use-contract-attachment-mutation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-contract-attachment-mutation.d.ts","sourceRoot":"","sources":["../../src/hooks/use-contract-attachment-mutation.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EACV,8BAA8B,EAC9B,8BAA8B,EAC/B,MAAM,sCAAsC,CAAA;AAC7C,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAO5B,MAAM,MAAM,kCAAkC,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,8BAA8B,CAAC,CAAA;AAC/F,MAAM,MAAM,kCAAkC,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,8BAA8B,CAAC,CAAA;AAE/F,wBAAgB,kCAAkC;;;;;;;;;;;;;;;;oBAShC,MAAM;eACX,kCAAkC;;;;;;;;;;;;;;;;;oBAuB7B,MAAM;YACd,MAAM;eACH,kCAAkC;;;;;;;;oBAkBU,MAAM;YAAM,MAAM;;EAe1E"}
@@ -0,0 +1,41 @@
1
+ "use client";
2
+ import { useMutation, useQueryClient } from "@tanstack/react-query";
3
+ import { fetchWithValidation } from "../client.js";
4
+ import { useVoyantLegalContext } from "../provider.js";
5
+ import { legalQueryKeys } from "../query-keys.js";
6
+ import { legalContractAttachmentRecordSchema, successEnvelope } from "../schemas.js";
7
+ export function useLegalContractAttachmentMutation() {
8
+ const { baseUrl, fetcher } = useVoyantLegalContext();
9
+ const queryClient = useQueryClient();
10
+ const create = useMutation({
11
+ mutationFn: async ({ contractId, input, }) => {
12
+ const data = await fetchWithValidation(`/v1/admin/legal/contracts/${contractId}/attachments`, legalContractAttachmentRecordSchema, { baseUrl, fetcher }, { method: "POST", body: JSON.stringify(input) });
13
+ return { contractId, data };
14
+ },
15
+ onSuccess: ({ contractId }) => {
16
+ void queryClient.invalidateQueries({
17
+ queryKey: legalQueryKeys.contractAttachments(contractId),
18
+ });
19
+ },
20
+ });
21
+ const update = useMutation({
22
+ mutationFn: async ({ contractId, id, input, }) => {
23
+ const data = await fetchWithValidation(`/v1/admin/legal/contracts/attachments/${id}`, legalContractAttachmentRecordSchema, { baseUrl, fetcher }, { method: "PATCH", body: JSON.stringify(input) });
24
+ return { contractId, data };
25
+ },
26
+ onSuccess: ({ contractId }) => {
27
+ void queryClient.invalidateQueries({
28
+ queryKey: legalQueryKeys.contractAttachments(contractId),
29
+ });
30
+ },
31
+ });
32
+ const remove = useMutation({
33
+ mutationFn: async ({ contractId, id }) => fetchWithValidation(`/v1/admin/legal/contracts/attachments/${id}`, successEnvelope, { baseUrl, fetcher }, { method: "DELETE" }).then((data) => ({ contractId, data })),
34
+ onSuccess: ({ contractId }) => {
35
+ void queryClient.invalidateQueries({
36
+ queryKey: legalQueryKeys.contractAttachments(contractId),
37
+ });
38
+ },
39
+ });
40
+ return { create, update, remove };
41
+ }
@@ -0,0 +1,17 @@
1
+ export interface UseLegalContractAttachmentsOptions {
2
+ contractId: string;
3
+ enabled?: boolean;
4
+ }
5
+ export declare function useLegalContractAttachments(options: UseLegalContractAttachmentsOptions): import("@tanstack/react-query").UseQueryResult<{
6
+ kind: string;
7
+ name: string;
8
+ id: string;
9
+ contractId: string;
10
+ mimeType: string | null;
11
+ fileSize: number | null;
12
+ storageKey: string | null;
13
+ checksum: string | null;
14
+ createdAt: string;
15
+ metadata?: Record<string, unknown> | null | undefined;
16
+ }[], Error>;
17
+ //# sourceMappingURL=use-contract-attachments.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-contract-attachments.d.ts","sourceRoot":"","sources":["../../src/hooks/use-contract-attachments.ts"],"names":[],"mappings":"AAOA,MAAM,WAAW,kCAAkC;IACjD,UAAU,EAAE,MAAM,CAAA;IAClB,OAAO,CAAC,EAAE,OAAO,CAAA;CAClB;AAED,wBAAgB,2BAA2B,CAAC,OAAO,EAAE,kCAAkC;;;;;;;;;;;YAQtF"}
@@ -0,0 +1,12 @@
1
+ "use client";
2
+ import { useQuery } from "@tanstack/react-query";
3
+ import { useVoyantLegalContext } from "../provider.js";
4
+ import { getLegalContractAttachmentsQueryOptions } from "../query-options.js";
5
+ export function useLegalContractAttachments(options) {
6
+ const { baseUrl, fetcher } = useVoyantLegalContext();
7
+ const { enabled = true, ...filters } = options;
8
+ return useQuery({
9
+ ...getLegalContractAttachmentsQueryOptions({ baseUrl, fetcher }, filters),
10
+ enabled,
11
+ });
12
+ }
@@ -0,0 +1,191 @@
1
+ import type { insertContractSchema, updateContractSchema } from "@voyantjs/legal/contracts/validation";
2
+ import type { z } from "zod";
3
+ export type CreateLegalContractInput = z.input<typeof insertContractSchema>;
4
+ export type UpdateLegalContractInput = z.input<typeof updateContractSchema>;
5
+ export declare function useLegalContractMutation(): {
6
+ create: import("@tanstack/react-query").UseMutationResult<{
7
+ scope: "other" | "customer" | "supplier" | "partner" | "channel";
8
+ status: "void" | "draft" | "issued" | "sent" | "signed" | "executed" | "expired";
9
+ title: string;
10
+ language: string;
11
+ id: string;
12
+ contractNumber: string | null;
13
+ templateVersionId: string | null;
14
+ seriesId: string | null;
15
+ personId: string | null;
16
+ organizationId: string | null;
17
+ supplierId: string | null;
18
+ channelId: string | null;
19
+ bookingId: string | null;
20
+ orderId: string | null;
21
+ renderedBodyFormat: "markdown" | "html" | "lexical_json";
22
+ renderedBody: string | null;
23
+ createdAt: string;
24
+ updatedAt: string;
25
+ variables?: Record<string, unknown> | null | undefined;
26
+ metadata?: Record<string, unknown> | null | undefined;
27
+ issuedAt?: string | null | undefined;
28
+ sentAt?: string | null | undefined;
29
+ executedAt?: string | null | undefined;
30
+ expiresAt?: string | null | undefined;
31
+ voidedAt?: string | null | undefined;
32
+ }, Error, {
33
+ scope: "other" | "customer" | "supplier" | "partner" | "channel";
34
+ title: string;
35
+ status?: "void" | "draft" | "issued" | "sent" | "signed" | "executed" | "expired" | undefined;
36
+ templateVersionId?: string | null | undefined;
37
+ seriesId?: string | null | undefined;
38
+ personId?: string | null | undefined;
39
+ organizationId?: string | null | undefined;
40
+ supplierId?: string | null | undefined;
41
+ channelId?: string | null | undefined;
42
+ bookingId?: string | null | undefined;
43
+ orderId?: string | null | undefined;
44
+ expiresAt?: string | null | undefined;
45
+ language?: string | undefined;
46
+ variables?: Record<string, unknown> | null | undefined;
47
+ metadata?: Record<string, unknown> | null | undefined;
48
+ }, unknown>;
49
+ update: import("@tanstack/react-query").UseMutationResult<{
50
+ scope: "other" | "customer" | "supplier" | "partner" | "channel";
51
+ status: "void" | "draft" | "issued" | "sent" | "signed" | "executed" | "expired";
52
+ title: string;
53
+ language: string;
54
+ id: string;
55
+ contractNumber: string | null;
56
+ templateVersionId: string | null;
57
+ seriesId: string | null;
58
+ personId: string | null;
59
+ organizationId: string | null;
60
+ supplierId: string | null;
61
+ channelId: string | null;
62
+ bookingId: string | null;
63
+ orderId: string | null;
64
+ renderedBodyFormat: "markdown" | "html" | "lexical_json";
65
+ renderedBody: string | null;
66
+ createdAt: string;
67
+ updatedAt: string;
68
+ variables?: Record<string, unknown> | null | undefined;
69
+ metadata?: Record<string, unknown> | null | undefined;
70
+ issuedAt?: string | null | undefined;
71
+ sentAt?: string | null | undefined;
72
+ executedAt?: string | null | undefined;
73
+ expiresAt?: string | null | undefined;
74
+ voidedAt?: string | null | undefined;
75
+ }, Error, {
76
+ id: string;
77
+ input: UpdateLegalContractInput;
78
+ }, unknown>;
79
+ remove: import("@tanstack/react-query").UseMutationResult<{
80
+ success: boolean;
81
+ }, Error, string, unknown>;
82
+ issue: import("@tanstack/react-query").UseMutationResult<{
83
+ scope: "other" | "customer" | "supplier" | "partner" | "channel";
84
+ status: "void" | "draft" | "issued" | "sent" | "signed" | "executed" | "expired";
85
+ title: string;
86
+ language: string;
87
+ id: string;
88
+ contractNumber: string | null;
89
+ templateVersionId: string | null;
90
+ seriesId: string | null;
91
+ personId: string | null;
92
+ organizationId: string | null;
93
+ supplierId: string | null;
94
+ channelId: string | null;
95
+ bookingId: string | null;
96
+ orderId: string | null;
97
+ renderedBodyFormat: "markdown" | "html" | "lexical_json";
98
+ renderedBody: string | null;
99
+ createdAt: string;
100
+ updatedAt: string;
101
+ variables?: Record<string, unknown> | null | undefined;
102
+ metadata?: Record<string, unknown> | null | undefined;
103
+ issuedAt?: string | null | undefined;
104
+ sentAt?: string | null | undefined;
105
+ executedAt?: string | null | undefined;
106
+ expiresAt?: string | null | undefined;
107
+ voidedAt?: string | null | undefined;
108
+ }, Error, string, unknown>;
109
+ send: import("@tanstack/react-query").UseMutationResult<{
110
+ scope: "other" | "customer" | "supplier" | "partner" | "channel";
111
+ status: "void" | "draft" | "issued" | "sent" | "signed" | "executed" | "expired";
112
+ title: string;
113
+ language: string;
114
+ id: string;
115
+ contractNumber: string | null;
116
+ templateVersionId: string | null;
117
+ seriesId: string | null;
118
+ personId: string | null;
119
+ organizationId: string | null;
120
+ supplierId: string | null;
121
+ channelId: string | null;
122
+ bookingId: string | null;
123
+ orderId: string | null;
124
+ renderedBodyFormat: "markdown" | "html" | "lexical_json";
125
+ renderedBody: string | null;
126
+ createdAt: string;
127
+ updatedAt: string;
128
+ variables?: Record<string, unknown> | null | undefined;
129
+ metadata?: Record<string, unknown> | null | undefined;
130
+ issuedAt?: string | null | undefined;
131
+ sentAt?: string | null | undefined;
132
+ executedAt?: string | null | undefined;
133
+ expiresAt?: string | null | undefined;
134
+ voidedAt?: string | null | undefined;
135
+ }, Error, string, unknown>;
136
+ execute: import("@tanstack/react-query").UseMutationResult<{
137
+ scope: "other" | "customer" | "supplier" | "partner" | "channel";
138
+ status: "void" | "draft" | "issued" | "sent" | "signed" | "executed" | "expired";
139
+ title: string;
140
+ language: string;
141
+ id: string;
142
+ contractNumber: string | null;
143
+ templateVersionId: string | null;
144
+ seriesId: string | null;
145
+ personId: string | null;
146
+ organizationId: string | null;
147
+ supplierId: string | null;
148
+ channelId: string | null;
149
+ bookingId: string | null;
150
+ orderId: string | null;
151
+ renderedBodyFormat: "markdown" | "html" | "lexical_json";
152
+ renderedBody: string | null;
153
+ createdAt: string;
154
+ updatedAt: string;
155
+ variables?: Record<string, unknown> | null | undefined;
156
+ metadata?: Record<string, unknown> | null | undefined;
157
+ issuedAt?: string | null | undefined;
158
+ sentAt?: string | null | undefined;
159
+ executedAt?: string | null | undefined;
160
+ expiresAt?: string | null | undefined;
161
+ voidedAt?: string | null | undefined;
162
+ }, Error, string, unknown>;
163
+ voidContract: import("@tanstack/react-query").UseMutationResult<{
164
+ scope: "other" | "customer" | "supplier" | "partner" | "channel";
165
+ status: "void" | "draft" | "issued" | "sent" | "signed" | "executed" | "expired";
166
+ title: string;
167
+ language: string;
168
+ id: string;
169
+ contractNumber: string | null;
170
+ templateVersionId: string | null;
171
+ seriesId: string | null;
172
+ personId: string | null;
173
+ organizationId: string | null;
174
+ supplierId: string | null;
175
+ channelId: string | null;
176
+ bookingId: string | null;
177
+ orderId: string | null;
178
+ renderedBodyFormat: "markdown" | "html" | "lexical_json";
179
+ renderedBody: string | null;
180
+ createdAt: string;
181
+ updatedAt: string;
182
+ variables?: Record<string, unknown> | null | undefined;
183
+ metadata?: Record<string, unknown> | null | undefined;
184
+ issuedAt?: string | null | undefined;
185
+ sentAt?: string | null | undefined;
186
+ executedAt?: string | null | undefined;
187
+ expiresAt?: string | null | undefined;
188
+ voidedAt?: string | null | undefined;
189
+ }, Error, string, unknown>;
190
+ };
191
+ //# sourceMappingURL=use-contract-mutation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-contract-mutation.d.ts","sourceRoot":"","sources":["../../src/hooks/use-contract-mutation.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EACV,oBAAoB,EACpB,oBAAoB,EACrB,MAAM,sCAAsC,CAAA;AAC7C,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAO5B,MAAM,MAAM,wBAAwB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,oBAAoB,CAAC,CAAA;AAC3E,MAAM,MAAM,wBAAwB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,oBAAoB,CAAC,CAAA;AAE3E,wBAAgB,wBAAwB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;YAqBI,MAAM;eAAS,wBAAwB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAkGlF"}
@@ -0,0 +1,82 @@
1
+ "use client";
2
+ import { useMutation, useQueryClient } from "@tanstack/react-query";
3
+ import { fetchWithValidation } from "../client.js";
4
+ import { useVoyantLegalContext } from "../provider.js";
5
+ import { legalQueryKeys } from "../query-keys.js";
6
+ import { legalContractSingleResponse, successEnvelope } from "../schemas.js";
7
+ export function useLegalContractMutation() {
8
+ const { baseUrl, fetcher } = useVoyantLegalContext();
9
+ const queryClient = useQueryClient();
10
+ const create = useMutation({
11
+ mutationFn: async (input) => {
12
+ const { data } = await fetchWithValidation("/v1/admin/legal/contracts", legalContractSingleResponse, { baseUrl, fetcher }, { method: "POST", body: JSON.stringify(input) });
13
+ return data;
14
+ },
15
+ onSuccess: (data) => {
16
+ void queryClient.invalidateQueries({ queryKey: legalQueryKeys.contracts() });
17
+ queryClient.setQueryData(legalQueryKeys.contract(data.id), data);
18
+ },
19
+ });
20
+ const update = useMutation({
21
+ mutationFn: async ({ id, input }) => {
22
+ const { data } = await fetchWithValidation(`/v1/admin/legal/contracts/${id}`, legalContractSingleResponse, { baseUrl, fetcher }, { method: "PATCH", body: JSON.stringify(input) });
23
+ return data;
24
+ },
25
+ onSuccess: (data) => {
26
+ void queryClient.invalidateQueries({ queryKey: legalQueryKeys.contracts() });
27
+ queryClient.setQueryData(legalQueryKeys.contract(data.id), data);
28
+ },
29
+ });
30
+ const remove = useMutation({
31
+ mutationFn: async (id) => fetchWithValidation(`/v1/admin/legal/contracts/${id}`, successEnvelope, { baseUrl, fetcher }, {
32
+ method: "DELETE",
33
+ }),
34
+ onSuccess: (_data, id) => {
35
+ void queryClient.invalidateQueries({ queryKey: legalQueryKeys.contracts() });
36
+ queryClient.removeQueries({ queryKey: legalQueryKeys.contract(id) });
37
+ queryClient.removeQueries({ queryKey: legalQueryKeys.contractSignatures(id) });
38
+ queryClient.removeQueries({ queryKey: legalQueryKeys.contractAttachments(id) });
39
+ },
40
+ });
41
+ const issue = useMutation({
42
+ mutationFn: async (id) => {
43
+ const { data } = await fetchWithValidation(`/v1/admin/legal/contracts/${id}/issue`, legalContractSingleResponse, { baseUrl, fetcher }, { method: "POST" });
44
+ return data;
45
+ },
46
+ onSuccess: (data) => {
47
+ void queryClient.invalidateQueries({ queryKey: legalQueryKeys.contracts() });
48
+ queryClient.setQueryData(legalQueryKeys.contract(data.id), data);
49
+ },
50
+ });
51
+ const send = useMutation({
52
+ mutationFn: async (id) => {
53
+ const { data } = await fetchWithValidation(`/v1/admin/legal/contracts/${id}/send`, legalContractSingleResponse, { baseUrl, fetcher }, { method: "POST" });
54
+ return data;
55
+ },
56
+ onSuccess: (data) => {
57
+ void queryClient.invalidateQueries({ queryKey: legalQueryKeys.contracts() });
58
+ queryClient.setQueryData(legalQueryKeys.contract(data.id), data);
59
+ },
60
+ });
61
+ const execute = useMutation({
62
+ mutationFn: async (id) => {
63
+ const { data } = await fetchWithValidation(`/v1/admin/legal/contracts/${id}/execute`, legalContractSingleResponse, { baseUrl, fetcher }, { method: "POST" });
64
+ return data;
65
+ },
66
+ onSuccess: (data) => {
67
+ void queryClient.invalidateQueries({ queryKey: legalQueryKeys.contracts() });
68
+ queryClient.setQueryData(legalQueryKeys.contract(data.id), data);
69
+ },
70
+ });
71
+ const voidContract = useMutation({
72
+ mutationFn: async (id) => {
73
+ const { data } = await fetchWithValidation(`/v1/admin/legal/contracts/${id}/void`, legalContractSingleResponse, { baseUrl, fetcher }, { method: "POST" });
74
+ return data;
75
+ },
76
+ onSuccess: (data) => {
77
+ void queryClient.invalidateQueries({ queryKey: legalQueryKeys.contracts() });
78
+ queryClient.setQueryData(legalQueryKeys.contract(data.id), data);
79
+ },
80
+ });
81
+ return { create, update, remove, issue, send, execute, voidContract };
82
+ }
@@ -0,0 +1,29 @@
1
+ import type { insertContractSignatureSchema } from "@voyantjs/legal/contracts/validation";
2
+ import type { z } from "zod";
3
+ export type CreateLegalContractSignatureInput = z.input<typeof insertContractSignatureSchema>;
4
+ export declare function useLegalContractSignatureMutation(): {
5
+ create: import("@tanstack/react-query").UseMutationResult<{
6
+ contractId: string;
7
+ data: {
8
+ signerName: string;
9
+ method: "manual" | "electronic" | "docusign" | "other";
10
+ id: string;
11
+ contractId: string;
12
+ signerEmail: string | null;
13
+ signerRole: string | null;
14
+ personId: string | null;
15
+ provider: string | null;
16
+ externalReference: string | null;
17
+ signatureData: string | null;
18
+ ipAddress: string | null;
19
+ userAgent: string | null;
20
+ signedAt: string;
21
+ createdAt: string;
22
+ metadata?: Record<string, unknown> | null | undefined;
23
+ };
24
+ }, Error, {
25
+ contractId: string;
26
+ input: CreateLegalContractSignatureInput;
27
+ }, unknown>;
28
+ };
29
+ //# sourceMappingURL=use-contract-signature-mutation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-contract-signature-mutation.d.ts","sourceRoot":"","sources":["../../src/hooks/use-contract-signature-mutation.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,6BAA6B,EAAE,MAAM,sCAAsC,CAAA;AACzF,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAO5B,MAAM,MAAM,iCAAiC,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,6BAA6B,CAAC,CAAA;AAE7F,wBAAgB,iCAAiC;;;;;;;;;;;;;;;;;;;;;oBAS/B,MAAM;eACX,iCAAiC;;EAmB7C"}
@@ -0,0 +1,23 @@
1
+ "use client";
2
+ import { useMutation, useQueryClient } from "@tanstack/react-query";
3
+ import { fetchWithValidation } from "../client.js";
4
+ import { useVoyantLegalContext } from "../provider.js";
5
+ import { legalQueryKeys } from "../query-keys.js";
6
+ import { legalContractSignatureRecordSchema } from "../schemas.js";
7
+ export function useLegalContractSignatureMutation() {
8
+ const { baseUrl, fetcher } = useVoyantLegalContext();
9
+ const queryClient = useQueryClient();
10
+ const create = useMutation({
11
+ mutationFn: async ({ contractId, input, }) => {
12
+ const data = await fetchWithValidation(`/v1/admin/legal/contracts/${contractId}/sign`, legalContractSignatureRecordSchema, { baseUrl, fetcher }, { method: "POST", body: JSON.stringify(input) });
13
+ return { contractId, data };
14
+ },
15
+ onSuccess: ({ contractId }) => {
16
+ void queryClient.invalidateQueries({ queryKey: legalQueryKeys.contract(contractId) });
17
+ void queryClient.invalidateQueries({
18
+ queryKey: legalQueryKeys.contractSignatures(contractId),
19
+ });
20
+ },
21
+ });
22
+ return { create };
23
+ }
@@ -0,0 +1,22 @@
1
+ export interface UseLegalContractSignaturesOptions {
2
+ contractId: string;
3
+ enabled?: boolean;
4
+ }
5
+ export declare function useLegalContractSignatures(options: UseLegalContractSignaturesOptions): import("@tanstack/react-query").UseQueryResult<{
6
+ signerName: string;
7
+ method: "manual" | "electronic" | "docusign" | "other";
8
+ id: string;
9
+ contractId: string;
10
+ signerEmail: string | null;
11
+ signerRole: string | null;
12
+ personId: string | null;
13
+ provider: string | null;
14
+ externalReference: string | null;
15
+ signatureData: string | null;
16
+ ipAddress: string | null;
17
+ userAgent: string | null;
18
+ signedAt: string;
19
+ createdAt: string;
20
+ metadata?: Record<string, unknown> | null | undefined;
21
+ }[], Error>;
22
+ //# sourceMappingURL=use-contract-signatures.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-contract-signatures.d.ts","sourceRoot":"","sources":["../../src/hooks/use-contract-signatures.ts"],"names":[],"mappings":"AAOA,MAAM,WAAW,iCAAiC;IAChD,UAAU,EAAE,MAAM,CAAA;IAClB,OAAO,CAAC,EAAE,OAAO,CAAA;CAClB;AAED,wBAAgB,0BAA0B,CAAC,OAAO,EAAE,iCAAiC;;;;;;;;;;;;;;;;YAQpF"}
@@ -0,0 +1,12 @@
1
+ "use client";
2
+ import { useQuery } from "@tanstack/react-query";
3
+ import { useVoyantLegalContext } from "../provider.js";
4
+ import { getLegalContractSignaturesQueryOptions } from "../query-options.js";
5
+ export function useLegalContractSignatures(options) {
6
+ const { baseUrl, fetcher } = useVoyantLegalContext();
7
+ const { enabled = true, ...filters } = options;
8
+ return useQuery({
9
+ ...getLegalContractSignaturesQueryOptions({ baseUrl, fetcher }, filters),
10
+ enabled,
11
+ });
12
+ }