@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,63 @@
1
+ import type { insertPolicyAssignmentSchema, updatePolicyAssignmentSchema } from "@voyantjs/legal/policies/validation";
2
+ import type { z } from "zod";
3
+ export type CreateLegalPolicyAssignmentInput = z.input<typeof insertPolicyAssignmentSchema>;
4
+ export type UpdateLegalPolicyAssignmentInput = z.input<typeof updatePolicyAssignmentSchema>;
5
+ export declare function useLegalPolicyAssignmentMutation(): {
6
+ create: import("@tanstack/react-query").UseMutationResult<{
7
+ policyId: string;
8
+ scope: "supplier" | "channel" | "product" | "market" | "organization" | "global";
9
+ priority: number;
10
+ id: string;
11
+ productId: string | null;
12
+ channelId: string | null;
13
+ supplierId: string | null;
14
+ marketId: string | null;
15
+ organizationId: string | null;
16
+ createdAt: string;
17
+ updatedAt: string;
18
+ validFrom?: string | null | undefined;
19
+ validTo?: string | null | undefined;
20
+ metadata?: Record<string, unknown> | null | undefined;
21
+ }, Error, {
22
+ policyId: string;
23
+ scope: "supplier" | "channel" | "product" | "market" | "organization" | "global";
24
+ productId?: string | null | undefined;
25
+ channelId?: string | null | undefined;
26
+ supplierId?: string | null | undefined;
27
+ marketId?: string | null | undefined;
28
+ organizationId?: string | null | undefined;
29
+ validFrom?: string | null | undefined;
30
+ validTo?: string | null | undefined;
31
+ priority?: number | undefined;
32
+ metadata?: Record<string, unknown> | null | undefined;
33
+ }, unknown>;
34
+ update: import("@tanstack/react-query").UseMutationResult<{
35
+ policyId: string;
36
+ scope: "supplier" | "channel" | "product" | "market" | "organization" | "global";
37
+ priority: number;
38
+ id: string;
39
+ productId: string | null;
40
+ channelId: string | null;
41
+ supplierId: string | null;
42
+ marketId: string | null;
43
+ organizationId: string | null;
44
+ createdAt: string;
45
+ updatedAt: string;
46
+ validFrom?: string | null | undefined;
47
+ validTo?: string | null | undefined;
48
+ metadata?: Record<string, unknown> | null | undefined;
49
+ }, Error, {
50
+ id: string;
51
+ input: UpdateLegalPolicyAssignmentInput;
52
+ }, unknown>;
53
+ remove: import("@tanstack/react-query").UseMutationResult<{
54
+ policyId: string;
55
+ data: {
56
+ success: boolean;
57
+ };
58
+ }, Error, {
59
+ policyId: string;
60
+ id: string;
61
+ }, unknown>;
62
+ };
63
+ //# sourceMappingURL=use-policy-assignment-mutation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-policy-assignment-mutation.d.ts","sourceRoot":"","sources":["../../src/hooks/use-policy-assignment-mutation.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EACV,4BAA4B,EAC5B,4BAA4B,EAC7B,MAAM,qCAAqC,CAAA;AAC5C,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAM5B,MAAM,MAAM,gCAAgC,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,4BAA4B,CAAC,CAAA;AAC3F,MAAM,MAAM,gCAAgC,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,4BAA4B,CAAC,CAAA;AAE3F,wBAAgB,gCAAgC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;YAsBJ,MAAM;eAAS,gCAAgC;;;;;;;;kBAiBtC,MAAM;YAAM,MAAM;;EAetE"}
@@ -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 { legalPolicyAssignmentSingleResponse, successEnvelope } from "../schemas.js";
7
+ export function useLegalPolicyAssignmentMutation() {
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/policies/assignments", legalPolicyAssignmentSingleResponse, { baseUrl, fetcher }, { method: "POST", body: JSON.stringify(input) });
13
+ return data;
14
+ },
15
+ onSuccess: (data) => {
16
+ void queryClient.invalidateQueries({
17
+ queryKey: legalQueryKeys.policyAssignments({ policyId: data.policyId }),
18
+ });
19
+ },
20
+ });
21
+ const update = useMutation({
22
+ mutationFn: async ({ id, input }) => {
23
+ const { data } = await fetchWithValidation(`/v1/admin/legal/policies/assignments/${id}`, legalPolicyAssignmentSingleResponse, { baseUrl, fetcher }, { method: "PATCH", body: JSON.stringify(input) });
24
+ return data;
25
+ },
26
+ onSuccess: (data) => {
27
+ void queryClient.invalidateQueries({
28
+ queryKey: legalQueryKeys.policyAssignments({ policyId: data.policyId }),
29
+ });
30
+ },
31
+ });
32
+ const remove = useMutation({
33
+ mutationFn: async ({ policyId, id }) => fetchWithValidation(`/v1/admin/legal/policies/assignments/${id}`, successEnvelope, { baseUrl, fetcher }, { method: "DELETE" }).then((data) => ({ policyId, data })),
34
+ onSuccess: ({ policyId }) => {
35
+ void queryClient.invalidateQueries({
36
+ queryKey: legalQueryKeys.policyAssignments({ policyId }),
37
+ });
38
+ },
39
+ });
40
+ return { create, update, remove };
41
+ }
@@ -0,0 +1,23 @@
1
+ import type { LegalPolicyAssignmentsListFilters } from "../query-keys.js";
2
+ export interface UseLegalPolicyAssignmentsOptions extends LegalPolicyAssignmentsListFilters {
3
+ enabled?: boolean;
4
+ }
5
+ export declare function useLegalPolicyAssignments(options?: UseLegalPolicyAssignmentsOptions): import("@tanstack/react-query").UseQueryResult<{
6
+ data: {
7
+ policyId: string;
8
+ scope: "supplier" | "channel" | "product" | "market" | "organization" | "global";
9
+ priority: number;
10
+ id: string;
11
+ productId: string | null;
12
+ channelId: string | null;
13
+ supplierId: string | null;
14
+ marketId: string | null;
15
+ organizationId: string | null;
16
+ createdAt: string;
17
+ updatedAt: string;
18
+ validFrom?: string | null | undefined;
19
+ validTo?: string | null | undefined;
20
+ metadata?: Record<string, unknown> | null | undefined;
21
+ }[];
22
+ }, Error>;
23
+ //# sourceMappingURL=use-policy-assignments.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-policy-assignments.d.ts","sourceRoot":"","sources":["../../src/hooks/use-policy-assignments.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,iCAAiC,EAAE,MAAM,kBAAkB,CAAA;AAGzE,MAAM,WAAW,gCAAiC,SAAQ,iCAAiC;IACzF,OAAO,CAAC,EAAE,OAAO,CAAA;CAClB;AAED,wBAAgB,yBAAyB,CAAC,OAAO,GAAE,gCAAqC;;;;;;;;;;;;;;;;;UAOvF"}
@@ -0,0 +1,12 @@
1
+ "use client";
2
+ import { useQuery } from "@tanstack/react-query";
3
+ import { useVoyantLegalContext } from "../provider.js";
4
+ import { getLegalPolicyAssignmentsQueryOptions } from "../query-options.js";
5
+ export function useLegalPolicyAssignments(options = {}) {
6
+ const { baseUrl, fetcher } = useVoyantLegalContext();
7
+ const { enabled = true, ...filters } = options;
8
+ return useQuery({
9
+ ...getLegalPolicyAssignmentsQueryOptions({ baseUrl, fetcher }, filters),
10
+ enabled,
11
+ });
12
+ }
@@ -0,0 +1,44 @@
1
+ import type { insertPolicySchema, updatePolicySchema } from "@voyantjs/legal/policies/validation";
2
+ import type { z } from "zod";
3
+ export type CreateLegalPolicyInput = z.input<typeof insertPolicySchema>;
4
+ export type UpdateLegalPolicyInput = z.input<typeof updatePolicySchema>;
5
+ export declare function useLegalPolicyMutation(): {
6
+ create: import("@tanstack/react-query").UseMutationResult<{
7
+ kind: "other" | "cancellation" | "payment" | "terms_and_conditions" | "privacy" | "refund" | "commission" | "guarantee";
8
+ name: string;
9
+ slug: string;
10
+ language: string;
11
+ id: string;
12
+ description: string | null;
13
+ createdAt: string;
14
+ updatedAt: string;
15
+ metadata?: Record<string, unknown> | null | undefined;
16
+ currentVersionId?: string | null | undefined;
17
+ }, Error, {
18
+ kind: "other" | "cancellation" | "payment" | "terms_and_conditions" | "privacy" | "refund" | "commission" | "guarantee";
19
+ name: string;
20
+ slug: string;
21
+ description?: string | null | undefined;
22
+ language?: string | undefined;
23
+ metadata?: Record<string, unknown> | null | undefined;
24
+ }, unknown>;
25
+ update: import("@tanstack/react-query").UseMutationResult<{
26
+ kind: "other" | "cancellation" | "payment" | "terms_and_conditions" | "privacy" | "refund" | "commission" | "guarantee";
27
+ name: string;
28
+ slug: string;
29
+ language: string;
30
+ id: string;
31
+ description: string | null;
32
+ createdAt: string;
33
+ updatedAt: string;
34
+ metadata?: Record<string, unknown> | null | undefined;
35
+ currentVersionId?: string | null | undefined;
36
+ }, Error, {
37
+ id: string;
38
+ input: UpdateLegalPolicyInput;
39
+ }, unknown>;
40
+ remove: import("@tanstack/react-query").UseMutationResult<{
41
+ success: boolean;
42
+ }, Error, string, unknown>;
43
+ };
44
+ //# sourceMappingURL=use-policy-mutation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-policy-mutation.d.ts","sourceRoot":"","sources":["../../src/hooks/use-policy-mutation.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,MAAM,qCAAqC,CAAA;AACjG,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAM5B,MAAM,MAAM,sBAAsB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,kBAAkB,CAAC,CAAA;AACvE,MAAM,MAAM,sBAAsB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,kBAAkB,CAAC,CAAA;AAEvE,wBAAgB,sBAAsB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;YAqBM,MAAM;eAAS,sBAAsB;;;;;EAgChF"}
@@ -0,0 +1,40 @@
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 { legalPolicySingleResponse, successEnvelope } from "../schemas.js";
7
+ export function useLegalPolicyMutation() {
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/policies", legalPolicySingleResponse, { baseUrl, fetcher }, { method: "POST", body: JSON.stringify(input) });
13
+ return data;
14
+ },
15
+ onSuccess: (data) => {
16
+ void queryClient.invalidateQueries({ queryKey: legalQueryKeys.policies() });
17
+ queryClient.setQueryData(legalQueryKeys.policy(data.id), data);
18
+ },
19
+ });
20
+ const update = useMutation({
21
+ mutationFn: async ({ id, input }) => {
22
+ const { data } = await fetchWithValidation(`/v1/admin/legal/policies/${id}`, legalPolicySingleResponse, { baseUrl, fetcher }, { method: "PATCH", body: JSON.stringify(input) });
23
+ return data;
24
+ },
25
+ onSuccess: (data) => {
26
+ void queryClient.invalidateQueries({ queryKey: legalQueryKeys.policies() });
27
+ queryClient.setQueryData(legalQueryKeys.policy(data.id), data);
28
+ },
29
+ });
30
+ const remove = useMutation({
31
+ mutationFn: async (id) => fetchWithValidation(`/v1/admin/legal/policies/${id}`, successEnvelope, { baseUrl, fetcher }, { method: "DELETE" }),
32
+ onSuccess: (_data, id) => {
33
+ void queryClient.invalidateQueries({ queryKey: legalQueryKeys.policies() });
34
+ queryClient.removeQueries({ queryKey: legalQueryKeys.policy(id) });
35
+ queryClient.removeQueries({ queryKey: legalQueryKeys.policyVersions(id) });
36
+ queryClient.removeQueries({ queryKey: legalQueryKeys.policyAssignments({ policyId: id }) });
37
+ },
38
+ });
39
+ return { create, update, remove };
40
+ }
@@ -0,0 +1,56 @@
1
+ import type { insertPolicyRuleSchema, updatePolicyRuleSchema } from "@voyantjs/legal/policies/validation";
2
+ import type { z } from "zod";
3
+ export type CreateLegalPolicyRuleInput = z.input<typeof insertPolicyRuleSchema>;
4
+ export type UpdateLegalPolicyRuleInput = z.input<typeof updatePolicyRuleSchema>;
5
+ export declare function useLegalPolicyRuleMutation(): {
6
+ create: import("@tanstack/react-query").UseMutationResult<{
7
+ ruleType: "custom" | "window" | "percentage" | "flat_amount" | "date_range";
8
+ sortOrder: number;
9
+ id: string;
10
+ policyVersionId: string;
11
+ label: string | null;
12
+ daysBeforeDeparture: number | null;
13
+ refundPercent: number | null;
14
+ flatAmountCents: number | null;
15
+ currency: string | null;
16
+ createdAt: string;
17
+ updatedAt: string;
18
+ refundType?: "cash" | "credit" | "cash_or_credit" | "none" | null | undefined;
19
+ validFrom?: string | null | undefined;
20
+ validTo?: string | null | undefined;
21
+ conditions?: Record<string, unknown> | null | undefined;
22
+ }, Error, {
23
+ versionId: string;
24
+ input: CreateLegalPolicyRuleInput;
25
+ }, unknown>;
26
+ update: import("@tanstack/react-query").UseMutationResult<{
27
+ ruleType: "custom" | "window" | "percentage" | "flat_amount" | "date_range";
28
+ sortOrder: number;
29
+ id: string;
30
+ policyVersionId: string;
31
+ label: string | null;
32
+ daysBeforeDeparture: number | null;
33
+ refundPercent: number | null;
34
+ flatAmountCents: number | null;
35
+ currency: string | null;
36
+ createdAt: string;
37
+ updatedAt: string;
38
+ refundType?: "cash" | "credit" | "cash_or_credit" | "none" | null | undefined;
39
+ validFrom?: string | null | undefined;
40
+ validTo?: string | null | undefined;
41
+ conditions?: Record<string, unknown> | null | undefined;
42
+ }, Error, {
43
+ id: string;
44
+ input: UpdateLegalPolicyRuleInput;
45
+ }, unknown>;
46
+ remove: import("@tanstack/react-query").UseMutationResult<{
47
+ versionId: string;
48
+ data: {
49
+ success: boolean;
50
+ };
51
+ }, Error, {
52
+ versionId: string;
53
+ id: string;
54
+ }, unknown>;
55
+ };
56
+ //# sourceMappingURL=use-policy-rule-mutation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-policy-rule-mutation.d.ts","sourceRoot":"","sources":["../../src/hooks/use-policy-rule-mutation.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EACV,sBAAsB,EACtB,sBAAsB,EACvB,MAAM,qCAAqC,CAAA;AAC5C,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAM5B,MAAM,MAAM,0BAA0B,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,sBAAsB,CAAC,CAAA;AAC/E,MAAM,MAAM,0BAA0B,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,sBAAsB,CAAC,CAAA;AAE/E,wBAAgB,0BAA0B;;;;;;;;;;;;;;;;;;mBASzB,MAAM;eACV,0BAA0B;;;;;;;;;;;;;;;;;;;YAkBK,MAAM;eAAS,0BAA0B;;;;;;;;mBAiB9B,MAAM;YAAM,MAAM;;EAaxE"}
@@ -0,0 +1,39 @@
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 { legalPolicyRuleSingleResponse, successEnvelope } from "../schemas.js";
7
+ export function useLegalPolicyRuleMutation() {
8
+ const { baseUrl, fetcher } = useVoyantLegalContext();
9
+ const queryClient = useQueryClient();
10
+ const create = useMutation({
11
+ mutationFn: async ({ versionId, input, }) => {
12
+ const { data } = await fetchWithValidation(`/v1/admin/legal/policies/versions/${versionId}/rules`, legalPolicyRuleSingleResponse, { baseUrl, fetcher }, { method: "POST", body: JSON.stringify(input) });
13
+ return data;
14
+ },
15
+ onSuccess: (data) => {
16
+ void queryClient.invalidateQueries({
17
+ queryKey: legalQueryKeys.policyRules(data.policyVersionId),
18
+ });
19
+ },
20
+ });
21
+ const update = useMutation({
22
+ mutationFn: async ({ id, input }) => {
23
+ const { data } = await fetchWithValidation(`/v1/admin/legal/policies/rules/${id}`, legalPolicyRuleSingleResponse, { baseUrl, fetcher }, { method: "PATCH", body: JSON.stringify(input) });
24
+ return data;
25
+ },
26
+ onSuccess: (data) => {
27
+ void queryClient.invalidateQueries({
28
+ queryKey: legalQueryKeys.policyRules(data.policyVersionId),
29
+ });
30
+ },
31
+ });
32
+ const remove = useMutation({
33
+ mutationFn: async ({ versionId, id }) => fetchWithValidation(`/v1/admin/legal/policies/rules/${id}`, successEnvelope, { baseUrl, fetcher }, { method: "DELETE" }).then((data) => ({ versionId, data })),
34
+ onSuccess: ({ versionId }) => {
35
+ void queryClient.invalidateQueries({ queryKey: legalQueryKeys.policyRules(versionId) });
36
+ },
37
+ });
38
+ return { create, update, remove };
39
+ }
@@ -0,0 +1,22 @@
1
+ export interface UseLegalPolicyRulesOptions {
2
+ versionId: string;
3
+ enabled?: boolean;
4
+ }
5
+ export declare function useLegalPolicyRules(options: UseLegalPolicyRulesOptions): import("@tanstack/react-query").UseQueryResult<{
6
+ ruleType: "custom" | "window" | "percentage" | "flat_amount" | "date_range";
7
+ sortOrder: number;
8
+ id: string;
9
+ policyVersionId: string;
10
+ label: string | null;
11
+ daysBeforeDeparture: number | null;
12
+ refundPercent: number | null;
13
+ flatAmountCents: number | null;
14
+ currency: string | null;
15
+ createdAt: string;
16
+ updatedAt: string;
17
+ refundType?: "cash" | "credit" | "cash_or_credit" | "none" | null | undefined;
18
+ validFrom?: string | null | undefined;
19
+ validTo?: string | null | undefined;
20
+ conditions?: Record<string, unknown> | null | undefined;
21
+ }[], Error>;
22
+ //# sourceMappingURL=use-policy-rules.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-policy-rules.d.ts","sourceRoot":"","sources":["../../src/hooks/use-policy-rules.ts"],"names":[],"mappings":"AAMA,MAAM,WAAW,0BAA0B;IACzC,SAAS,EAAE,MAAM,CAAA;IACjB,OAAO,CAAC,EAAE,OAAO,CAAA;CAClB;AAED,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,0BAA0B;;;;;;;;;;;;;;;;YAOtE"}
@@ -0,0 +1,12 @@
1
+ "use client";
2
+ import { useQuery } from "@tanstack/react-query";
3
+ import { useVoyantLegalContext } from "../provider.js";
4
+ import { getLegalPolicyRulesQueryOptions } from "../query-options.js";
5
+ export function useLegalPolicyRules(options) {
6
+ const { baseUrl, fetcher } = useVoyantLegalContext();
7
+ const { enabled = true, ...filters } = options;
8
+ return useQuery({
9
+ ...getLegalPolicyRulesQueryOptions({ baseUrl, fetcher }, filters),
10
+ enabled,
11
+ });
12
+ }
@@ -0,0 +1,73 @@
1
+ import type { insertPolicyVersionSchema, updatePolicyVersionSchema } from "@voyantjs/legal/policies/validation";
2
+ import type { z } from "zod";
3
+ export type CreateLegalPolicyVersionInput = z.input<typeof insertPolicyVersionSchema>;
4
+ export type UpdateLegalPolicyVersionInput = z.input<typeof updatePolicyVersionSchema>;
5
+ export declare function useLegalPolicyVersionMutation(): {
6
+ create: import("@tanstack/react-query").UseMutationResult<{
7
+ title: string;
8
+ bodyFormat: "markdown" | "html" | "plain";
9
+ id: string;
10
+ policyId: string;
11
+ version: number;
12
+ status: "draft" | "published" | "retired";
13
+ body: string | null;
14
+ publishedAt: string | null;
15
+ publishedBy: string | null;
16
+ createdAt: string;
17
+ updatedAt: string;
18
+ retiredAt?: string | null | undefined;
19
+ metadata?: Record<string, unknown> | null | undefined;
20
+ }, Error, {
21
+ policyId: string;
22
+ input: CreateLegalPolicyVersionInput;
23
+ }, unknown>;
24
+ update: import("@tanstack/react-query").UseMutationResult<{
25
+ title: string;
26
+ bodyFormat: "markdown" | "html" | "plain";
27
+ id: string;
28
+ policyId: string;
29
+ version: number;
30
+ status: "draft" | "published" | "retired";
31
+ body: string | null;
32
+ publishedAt: string | null;
33
+ publishedBy: string | null;
34
+ createdAt: string;
35
+ updatedAt: string;
36
+ retiredAt?: string | null | undefined;
37
+ metadata?: Record<string, unknown> | null | undefined;
38
+ }, Error, {
39
+ id: string;
40
+ input: UpdateLegalPolicyVersionInput;
41
+ }, unknown>;
42
+ publish: import("@tanstack/react-query").UseMutationResult<{
43
+ title: string;
44
+ bodyFormat: "markdown" | "html" | "plain";
45
+ id: string;
46
+ policyId: string;
47
+ version: number;
48
+ status: "draft" | "published" | "retired";
49
+ body: string | null;
50
+ publishedAt: string | null;
51
+ publishedBy: string | null;
52
+ createdAt: string;
53
+ updatedAt: string;
54
+ retiredAt?: string | null | undefined;
55
+ metadata?: Record<string, unknown> | null | undefined;
56
+ }, Error, string, unknown>;
57
+ retire: import("@tanstack/react-query").UseMutationResult<{
58
+ title: string;
59
+ bodyFormat: "markdown" | "html" | "plain";
60
+ id: string;
61
+ policyId: string;
62
+ version: number;
63
+ status: "draft" | "published" | "retired";
64
+ body: string | null;
65
+ publishedAt: string | null;
66
+ publishedBy: string | null;
67
+ createdAt: string;
68
+ updatedAt: string;
69
+ retiredAt?: string | null | undefined;
70
+ metadata?: Record<string, unknown> | null | undefined;
71
+ }, Error, string, unknown>;
72
+ };
73
+ //# sourceMappingURL=use-policy-version-mutation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-policy-version-mutation.d.ts","sourceRoot":"","sources":["../../src/hooks/use-policy-version-mutation.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EACV,yBAAyB,EACzB,yBAAyB,EAC1B,MAAM,qCAAqC,CAAA;AAC5C,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAM5B,MAAM,MAAM,6BAA6B,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,yBAAyB,CAAC,CAAA;AACrF,MAAM,MAAM,6BAA6B,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,yBAAyB,CAAC,CAAA;AAErF,wBAAgB,6BAA6B;;;;;;;;;;;;;;;;kBAS7B,MAAM;eACT,6BAA6B;;;;;;;;;;;;;;;;;YAgBE,MAAM;eAAS,6BAA6B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAgDvF"}
@@ -0,0 +1,50 @@
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 { legalPolicyVersionSingleResponse } from "../schemas.js";
7
+ export function useLegalPolicyVersionMutation() {
8
+ const { baseUrl, fetcher } = useVoyantLegalContext();
9
+ const queryClient = useQueryClient();
10
+ const create = useMutation({
11
+ mutationFn: async ({ policyId, input, }) => {
12
+ const { data } = await fetchWithValidation(`/v1/admin/legal/policies/${policyId}/versions`, legalPolicyVersionSingleResponse, { baseUrl, fetcher }, { method: "POST", body: JSON.stringify(input) });
13
+ return data;
14
+ },
15
+ onSuccess: (data) => {
16
+ void queryClient.invalidateQueries({ queryKey: legalQueryKeys.policyVersions(data.policyId) });
17
+ },
18
+ });
19
+ const update = useMutation({
20
+ mutationFn: async ({ id, input }) => {
21
+ const { data } = await fetchWithValidation(`/v1/admin/legal/policies/versions/${id}`, legalPolicyVersionSingleResponse, { baseUrl, fetcher }, { method: "PATCH", body: JSON.stringify(input) });
22
+ return data;
23
+ },
24
+ onSuccess: (data) => {
25
+ void queryClient.invalidateQueries({ queryKey: legalQueryKeys.policyVersions(data.policyId) });
26
+ void queryClient.invalidateQueries({ queryKey: legalQueryKeys.policy(data.policyId) });
27
+ },
28
+ });
29
+ const publish = useMutation({
30
+ mutationFn: async (id) => {
31
+ const { data } = await fetchWithValidation(`/v1/admin/legal/policies/versions/${id}/publish`, legalPolicyVersionSingleResponse, { baseUrl, fetcher }, { method: "POST" });
32
+ return data;
33
+ },
34
+ onSuccess: (data) => {
35
+ void queryClient.invalidateQueries({ queryKey: legalQueryKeys.policyVersions(data.policyId) });
36
+ void queryClient.invalidateQueries({ queryKey: legalQueryKeys.policy(data.policyId) });
37
+ },
38
+ });
39
+ const retire = useMutation({
40
+ mutationFn: async (id) => {
41
+ const { data } = await fetchWithValidation(`/v1/admin/legal/policies/versions/${id}/retire`, legalPolicyVersionSingleResponse, { baseUrl, fetcher }, { method: "POST" });
42
+ return data;
43
+ },
44
+ onSuccess: (data) => {
45
+ void queryClient.invalidateQueries({ queryKey: legalQueryKeys.policyVersions(data.policyId) });
46
+ void queryClient.invalidateQueries({ queryKey: legalQueryKeys.policy(data.policyId) });
47
+ },
48
+ });
49
+ return { create, update, publish, retire };
50
+ }
@@ -0,0 +1,20 @@
1
+ export interface UseLegalPolicyVersionsOptions {
2
+ policyId: string;
3
+ enabled?: boolean;
4
+ }
5
+ export declare function useLegalPolicyVersions(options: UseLegalPolicyVersionsOptions): import("@tanstack/react-query").UseQueryResult<{
6
+ title: string;
7
+ bodyFormat: "markdown" | "html" | "plain";
8
+ id: string;
9
+ policyId: string;
10
+ version: number;
11
+ status: "draft" | "published" | "retired";
12
+ body: string | null;
13
+ publishedAt: string | null;
14
+ publishedBy: string | null;
15
+ createdAt: string;
16
+ updatedAt: string;
17
+ retiredAt?: string | null | undefined;
18
+ metadata?: Record<string, unknown> | null | undefined;
19
+ }[], Error>;
20
+ //# sourceMappingURL=use-policy-versions.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-policy-versions.d.ts","sourceRoot":"","sources":["../../src/hooks/use-policy-versions.ts"],"names":[],"mappings":"AAMA,MAAM,WAAW,6BAA6B;IAC5C,QAAQ,EAAE,MAAM,CAAA;IAChB,OAAO,CAAC,EAAE,OAAO,CAAA;CAClB;AAED,wBAAgB,sBAAsB,CAAC,OAAO,EAAE,6BAA6B;;;;;;;;;;;;;;YAO5E"}
@@ -0,0 +1,12 @@
1
+ "use client";
2
+ import { useQuery } from "@tanstack/react-query";
3
+ import { useVoyantLegalContext } from "../provider.js";
4
+ import { getLegalPolicyVersionsQueryOptions } from "../query-options.js";
5
+ export function useLegalPolicyVersions(options) {
6
+ const { baseUrl, fetcher } = useVoyantLegalContext();
7
+ const { enabled = true, ...filters } = options;
8
+ return useQuery({
9
+ ...getLegalPolicyVersionsQueryOptions({ baseUrl, fetcher }, filters),
10
+ enabled,
11
+ });
12
+ }
@@ -0,0 +1,16 @@
1
+ export interface UseLegalPolicyOptions {
2
+ enabled?: boolean;
3
+ }
4
+ export declare function useLegalPolicy(id: string, options?: UseLegalPolicyOptions): import("@tanstack/react-query").UseQueryResult<{
5
+ kind: "other" | "cancellation" | "payment" | "terms_and_conditions" | "privacy" | "refund" | "commission" | "guarantee";
6
+ name: string;
7
+ slug: string;
8
+ language: string;
9
+ id: string;
10
+ description: string | null;
11
+ createdAt: string;
12
+ updatedAt: string;
13
+ metadata?: Record<string, unknown> | null | undefined;
14
+ currentVersionId?: string | null | undefined;
15
+ }, Error>;
16
+ //# sourceMappingURL=use-policy.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-policy.d.ts","sourceRoot":"","sources":["../../src/hooks/use-policy.ts"],"names":[],"mappings":"AAMA,MAAM,WAAW,qBAAqB;IACpC,OAAO,CAAC,EAAE,OAAO,CAAA;CAClB;AAED,wBAAgB,cAAc,CAAC,EAAE,EAAE,MAAM,EAAE,OAAO,GAAE,qBAA0B;;;;;;;;;;;UAO7E"}
@@ -0,0 +1,12 @@
1
+ "use client";
2
+ import { useQuery } from "@tanstack/react-query";
3
+ import { useVoyantLegalContext } from "../provider.js";
4
+ import { getLegalPolicyQueryOptions } from "../query-options.js";
5
+ export function useLegalPolicy(id, options = {}) {
6
+ const { baseUrl, fetcher } = useVoyantLegalContext();
7
+ const { enabled = true } = options;
8
+ return useQuery({
9
+ ...getLegalPolicyQueryOptions({ baseUrl, fetcher }, id),
10
+ enabled,
11
+ });
12
+ }
@@ -0,0 +1,7 @@
1
+ export { defaultFetcher, type FetchWithValidationOptions, fetchWithValidation, VoyantApiError, type VoyantFetcher, } from "./client.js";
2
+ export * from "./hooks/index.js";
3
+ export { useVoyantLegalContext, type VoyantLegalContextValue, VoyantLegalProvider, type VoyantLegalProviderProps, } from "./provider.js";
4
+ export { type LegalContractNumberSeriesListFilters, type LegalContractsListFilters, type LegalContractTemplatesListFilters, type LegalPoliciesListFilters, type LegalPolicyAcceptancesListFilters, type LegalPolicyAssignmentsListFilters, legalQueryKeys, } from "./query-keys.js";
5
+ export { getLegalContractAttachmentsQueryOptions, getLegalContractNumberSeriesDetailQueryOptions, getLegalContractNumberSeriesQueryOptions, getLegalContractQueryOptions, getLegalContractSignaturesQueryOptions, getLegalContractsQueryOptions, getLegalContractTemplateQueryOptions, getLegalContractTemplatesQueryOptions, getLegalContractTemplateVersionsQueryOptions, getLegalPoliciesQueryOptions, getLegalPolicyAcceptancesQueryOptions, getLegalPolicyAssignmentsQueryOptions, getLegalPolicyQueryOptions, getLegalPolicyRulesQueryOptions, getLegalPolicyVersionQueryOptions, getLegalPolicyVersionsQueryOptions, } from "./query-options.js";
6
+ export * from "./schemas.js";
7
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,cAAc,EACd,KAAK,0BAA0B,EAC/B,mBAAmB,EACnB,cAAc,EACd,KAAK,aAAa,GACnB,MAAM,aAAa,CAAA;AACpB,cAAc,kBAAkB,CAAA;AAChC,OAAO,EACL,qBAAqB,EACrB,KAAK,uBAAuB,EAC5B,mBAAmB,EACnB,KAAK,wBAAwB,GAC9B,MAAM,eAAe,CAAA;AACtB,OAAO,EACL,KAAK,oCAAoC,EACzC,KAAK,yBAAyB,EAC9B,KAAK,iCAAiC,EACtC,KAAK,wBAAwB,EAC7B,KAAK,iCAAiC,EACtC,KAAK,iCAAiC,EACtC,cAAc,GACf,MAAM,iBAAiB,CAAA;AACxB,OAAO,EACL,uCAAuC,EACvC,8CAA8C,EAC9C,wCAAwC,EACxC,4BAA4B,EAC5B,sCAAsC,EACtC,6BAA6B,EAC7B,oCAAoC,EACpC,qCAAqC,EACrC,4CAA4C,EAC5C,4BAA4B,EAC5B,qCAAqC,EACrC,qCAAqC,EACrC,0BAA0B,EAC1B,+BAA+B,EAC/B,iCAAiC,EACjC,kCAAkC,GACnC,MAAM,oBAAoB,CAAA;AAC3B,cAAc,cAAc,CAAA"}
package/dist/index.js ADDED
@@ -0,0 +1,6 @@
1
+ export { defaultFetcher, fetchWithValidation, VoyantApiError, } from "./client.js";
2
+ export * from "./hooks/index.js";
3
+ export { useVoyantLegalContext, VoyantLegalProvider, } from "./provider.js";
4
+ export { legalQueryKeys, } from "./query-keys.js";
5
+ export { getLegalContractAttachmentsQueryOptions, getLegalContractNumberSeriesDetailQueryOptions, getLegalContractNumberSeriesQueryOptions, getLegalContractQueryOptions, getLegalContractSignaturesQueryOptions, getLegalContractsQueryOptions, getLegalContractTemplateQueryOptions, getLegalContractTemplatesQueryOptions, getLegalContractTemplateVersionsQueryOptions, getLegalPoliciesQueryOptions, getLegalPolicyAcceptancesQueryOptions, getLegalPolicyAssignmentsQueryOptions, getLegalPolicyQueryOptions, getLegalPolicyRulesQueryOptions, getLegalPolicyVersionQueryOptions, getLegalPolicyVersionsQueryOptions, } from "./query-options.js";
6
+ export * from "./schemas.js";
@@ -0,0 +1,2 @@
1
+ export { useVoyantReactContext as useVoyantLegalContext, type VoyantReactContextValue as VoyantLegalContextValue, VoyantReactProvider as VoyantLegalProvider, type VoyantReactProviderProps as VoyantLegalProviderProps, } from "@voyantjs/react";
2
+ //# sourceMappingURL=provider.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"provider.d.ts","sourceRoot":"","sources":["../src/provider.tsx"],"names":[],"mappings":"AAAA,OAAO,EACL,qBAAqB,IAAI,qBAAqB,EAC9C,KAAK,uBAAuB,IAAI,uBAAuB,EACvD,mBAAmB,IAAI,mBAAmB,EAC1C,KAAK,wBAAwB,IAAI,wBAAwB,GAC1D,MAAM,iBAAiB,CAAA"}
@@ -0,0 +1 @@
1
+ export { useVoyantReactContext as useVoyantLegalContext, VoyantReactProvider as VoyantLegalProvider, } from "@voyantjs/react";