@voyantjs/notifications-react 0.6.8

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 (55) hide show
  1. package/dist/client.d.ts +14 -0
  2. package/dist/client.d.ts.map +1 -0
  3. package/dist/client.js +71 -0
  4. package/dist/hooks/index.d.ts +12 -0
  5. package/dist/hooks/index.d.ts.map +1 -0
  6. package/dist/hooks/index.js +12 -0
  7. package/dist/hooks/use-notification-deliveries.d.ts +39 -0
  8. package/dist/hooks/use-notification-deliveries.d.ts.map +1 -0
  9. package/dist/hooks/use-notification-deliveries.js +12 -0
  10. package/dist/hooks/use-notification-delivery.d.ts +32 -0
  11. package/dist/hooks/use-notification-delivery.d.ts.map +1 -0
  12. package/dist/hooks/use-notification-delivery.js +12 -0
  13. package/dist/hooks/use-notification-reminder-rule-mutation.d.ts +54 -0
  14. package/dist/hooks/use-notification-reminder-rule-mutation.d.ts.map +1 -0
  15. package/dist/hooks/use-notification-reminder-rule-mutation.js +31 -0
  16. package/dist/hooks/use-notification-reminder-rule.d.ts +20 -0
  17. package/dist/hooks/use-notification-reminder-rule.d.ts.map +1 -0
  18. package/dist/hooks/use-notification-reminder-rule.js +12 -0
  19. package/dist/hooks/use-notification-reminder-rules.d.ts +26 -0
  20. package/dist/hooks/use-notification-reminder-rules.d.ts.map +1 -0
  21. package/dist/hooks/use-notification-reminder-rules.js +12 -0
  22. package/dist/hooks/use-notification-reminder-runs.d.ts +57 -0
  23. package/dist/hooks/use-notification-reminder-runs.d.ts.map +1 -0
  24. package/dist/hooks/use-notification-reminder-runs.js +12 -0
  25. package/dist/hooks/use-notification-template-authoring.d.ts +5 -0
  26. package/dist/hooks/use-notification-template-authoring.d.ts.map +1 -0
  27. package/dist/hooks/use-notification-template-authoring.js +8 -0
  28. package/dist/hooks/use-notification-template-mutation.d.ts +54 -0
  29. package/dist/hooks/use-notification-template-mutation.d.ts.map +1 -0
  30. package/dist/hooks/use-notification-template-mutation.js +31 -0
  31. package/dist/hooks/use-notification-template-tools.d.ts +80 -0
  32. package/dist/hooks/use-notification-template-tools.d.ts.map +1 -0
  33. package/dist/hooks/use-notification-template-tools.js +21 -0
  34. package/dist/hooks/use-notification-template.d.ts +20 -0
  35. package/dist/hooks/use-notification-template.d.ts.map +1 -0
  36. package/dist/hooks/use-notification-template.js +12 -0
  37. package/dist/hooks/use-notification-templates.d.ts +26 -0
  38. package/dist/hooks/use-notification-templates.d.ts.map +1 -0
  39. package/dist/hooks/use-notification-templates.js +12 -0
  40. package/dist/index.d.ts +7 -0
  41. package/dist/index.d.ts.map +1 -0
  42. package/dist/index.js +6 -0
  43. package/dist/provider.d.ts +2 -0
  44. package/dist/provider.d.ts.map +1 -0
  45. package/dist/provider.js +1 -0
  46. package/dist/query-keys.d.ts +63 -0
  47. package/dist/query-keys.d.ts.map +1 -0
  48. package/dist/query-keys.js +15 -0
  49. package/dist/query-options.d.ts +979 -0
  50. package/dist/query-options.d.ts.map +1 -0
  51. package/dist/query-options.js +79 -0
  52. package/dist/schemas.d.ts +515 -0
  53. package/dist/schemas.d.ts.map +1 -0
  54. package/dist/schemas.js +89 -0
  55. 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,aAIzB,CAAA;AAEJ,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;AAcD,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,71 @@
1
+ export const defaultFetcher = (url, init) => fetch(url, {
2
+ credentials: "include",
3
+ ...init,
4
+ });
5
+ export class VoyantApiError extends Error {
6
+ status;
7
+ body;
8
+ constructor(message, status, body) {
9
+ super(message);
10
+ this.name = "VoyantApiError";
11
+ this.status = status;
12
+ this.body = body;
13
+ }
14
+ }
15
+ function extractErrorMessage(status, statusText, body) {
16
+ if (typeof body === "object" && body !== null && "error" in body) {
17
+ const err = body.error;
18
+ if (typeof err === "string")
19
+ return err;
20
+ if (typeof err === "object" && err !== null && "message" in err) {
21
+ return String(err.message);
22
+ }
23
+ }
24
+ return `Voyant API error: ${status} ${statusText}`;
25
+ }
26
+ export async function fetchWithValidation(path, schema, options, init) {
27
+ const url = joinUrl(options.baseUrl, path);
28
+ const headers = new Headers(init?.headers);
29
+ if (init?.body !== undefined && !headers.has("Content-Type")) {
30
+ headers.set("Content-Type", "application/json");
31
+ }
32
+ const response = await options.fetcher(url, { ...init, headers });
33
+ if (!response.ok) {
34
+ const body = await safeJson(response);
35
+ throw new VoyantApiError(extractErrorMessage(response.status, response.statusText, body), response.status, body);
36
+ }
37
+ if (response.status === 204)
38
+ return schema.parse(undefined);
39
+ const body = await safeJson(response);
40
+ const parsed = schema.safeParse(body);
41
+ if (!parsed.success) {
42
+ throw new VoyantApiError(`Voyant API response failed validation: ${parsed.error.message}`, response.status, body);
43
+ }
44
+ return parsed.data;
45
+ }
46
+ async function safeJson(response) {
47
+ const text = await response.text();
48
+ if (!text)
49
+ return undefined;
50
+ try {
51
+ return JSON.parse(text);
52
+ }
53
+ catch {
54
+ return text;
55
+ }
56
+ }
57
+ function joinUrl(baseUrl, path) {
58
+ const resolvedBaseUrl = resolveBaseUrl(baseUrl);
59
+ const trimmedBase = resolvedBaseUrl.endsWith("/") ? resolvedBaseUrl.slice(0, -1) : resolvedBaseUrl;
60
+ const trimmedPath = path.startsWith("/") ? path : `/${path}`;
61
+ return `${trimmedBase}${trimmedPath}`;
62
+ }
63
+ function resolveBaseUrl(baseUrl) {
64
+ if (baseUrl.trim()) {
65
+ return baseUrl;
66
+ }
67
+ if (typeof window !== "undefined") {
68
+ return `${window.location.origin}/api`;
69
+ }
70
+ return "http://localhost:3300/api";
71
+ }
@@ -0,0 +1,12 @@
1
+ export * from "./use-notification-deliveries.js";
2
+ export * from "./use-notification-delivery.js";
3
+ export * from "./use-notification-reminder-rule.js";
4
+ export * from "./use-notification-reminder-rule-mutation.js";
5
+ export * from "./use-notification-reminder-rules.js";
6
+ export * from "./use-notification-reminder-runs.js";
7
+ export * from "./use-notification-template.js";
8
+ export * from "./use-notification-template-authoring.js";
9
+ export * from "./use-notification-template-mutation.js";
10
+ export * from "./use-notification-template-tools.js";
11
+ export * from "./use-notification-templates.js";
12
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/hooks/index.ts"],"names":[],"mappings":"AAEA,cAAc,kCAAkC,CAAA;AAChD,cAAc,gCAAgC,CAAA;AAC9C,cAAc,qCAAqC,CAAA;AACnD,cAAc,8CAA8C,CAAA;AAC5D,cAAc,sCAAsC,CAAA;AACpD,cAAc,qCAAqC,CAAA;AACnD,cAAc,gCAAgC,CAAA;AAC9C,cAAc,0CAA0C,CAAA;AACxD,cAAc,yCAAyC,CAAA;AACvD,cAAc,sCAAsC,CAAA;AACpD,cAAc,iCAAiC,CAAA"}
@@ -0,0 +1,12 @@
1
+ "use client";
2
+ export * from "./use-notification-deliveries.js";
3
+ export * from "./use-notification-delivery.js";
4
+ export * from "./use-notification-reminder-rule.js";
5
+ export * from "./use-notification-reminder-rule-mutation.js";
6
+ export * from "./use-notification-reminder-rules.js";
7
+ export * from "./use-notification-reminder-runs.js";
8
+ export * from "./use-notification-template.js";
9
+ export * from "./use-notification-template-authoring.js";
10
+ export * from "./use-notification-template-mutation.js";
11
+ export * from "./use-notification-template-tools.js";
12
+ export * from "./use-notification-templates.js";
@@ -0,0 +1,39 @@
1
+ import type { NotificationDeliveriesListFilters } from "../query-keys.js";
2
+ export interface UseNotificationDeliveriesOptions extends NotificationDeliveriesListFilters {
3
+ enabled?: boolean;
4
+ }
5
+ export declare function useNotificationDeliveries(options?: UseNotificationDeliveriesOptions): import("@tanstack/react-query").UseQueryResult<{
6
+ data: {
7
+ id: string;
8
+ templateId: string | null;
9
+ templateSlug: string | null;
10
+ targetType: "booking_payment_schedule" | "invoice" | "booking" | "booking_guarantee" | "payment_session" | "person" | "organization" | "other";
11
+ targetId: string | null;
12
+ personId: string | null;
13
+ organizationId: string | null;
14
+ bookingId: string | null;
15
+ invoiceId: string | null;
16
+ paymentSessionId: string | null;
17
+ channel: "email" | "sms";
18
+ provider: string;
19
+ providerMessageId: string | null;
20
+ status: "pending" | "sent" | "failed" | "cancelled";
21
+ toAddress: string;
22
+ fromAddress: string | null;
23
+ subject: string | null;
24
+ htmlBody: string | null;
25
+ textBody: string | null;
26
+ payloadData: Record<string, unknown> | null;
27
+ metadata: Record<string, unknown> | null;
28
+ errorMessage: string | null;
29
+ scheduledFor: string | null;
30
+ sentAt: string | null;
31
+ failedAt: string | null;
32
+ createdAt: string;
33
+ updatedAt: string;
34
+ }[];
35
+ total: number;
36
+ limit: number;
37
+ offset: number;
38
+ }, Error>;
39
+ //# sourceMappingURL=use-notification-deliveries.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-notification-deliveries.d.ts","sourceRoot":"","sources":["../../src/hooks/use-notification-deliveries.ts"],"names":[],"mappings":"AAKA,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 { useVoyantNotificationsContext } from "../provider.js";
4
+ import { getNotificationDeliveriesQueryOptions } from "../query-options.js";
5
+ export function useNotificationDeliveries(options = {}) {
6
+ const { baseUrl, fetcher } = useVoyantNotificationsContext();
7
+ const { enabled = true, ...filters } = options;
8
+ return useQuery({
9
+ ...getNotificationDeliveriesQueryOptions({ baseUrl, fetcher }, filters),
10
+ enabled,
11
+ });
12
+ }
@@ -0,0 +1,32 @@
1
+ export declare function useNotificationDelivery(id: string, options?: {
2
+ enabled?: boolean;
3
+ }): import("@tanstack/react-query").UseQueryResult<{
4
+ id: string;
5
+ templateId: string | null;
6
+ templateSlug: string | null;
7
+ targetType: "booking_payment_schedule" | "invoice" | "booking" | "booking_guarantee" | "payment_session" | "person" | "organization" | "other";
8
+ targetId: string | null;
9
+ personId: string | null;
10
+ organizationId: string | null;
11
+ bookingId: string | null;
12
+ invoiceId: string | null;
13
+ paymentSessionId: string | null;
14
+ channel: "email" | "sms";
15
+ provider: string;
16
+ providerMessageId: string | null;
17
+ status: "pending" | "sent" | "failed" | "cancelled";
18
+ toAddress: string;
19
+ fromAddress: string | null;
20
+ subject: string | null;
21
+ htmlBody: string | null;
22
+ textBody: string | null;
23
+ payloadData: Record<string, unknown> | null;
24
+ metadata: Record<string, unknown> | null;
25
+ errorMessage: string | null;
26
+ scheduledFor: string | null;
27
+ sentAt: string | null;
28
+ failedAt: string | null;
29
+ createdAt: string;
30
+ updatedAt: string;
31
+ }, Error>;
32
+ //# sourceMappingURL=use-notification-delivery.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-notification-delivery.d.ts","sourceRoot":"","sources":["../../src/hooks/use-notification-delivery.ts"],"names":[],"mappings":"AAOA,wBAAgB,uBAAuB,CAAC,EAAE,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE;IAAE,OAAO,CAAC,EAAE,OAAO,CAAA;CAAE;;;;;;;;;;;;;;;;;;;;;;;;;;;;UAQlF"}
@@ -0,0 +1,12 @@
1
+ "use client";
2
+ import { useQuery } from "@tanstack/react-query";
3
+ import { useVoyantNotificationsContext } from "../provider.js";
4
+ import { getNotificationDeliveryQueryOptions } from "../query-options.js";
5
+ export function useNotificationDelivery(id, options) {
6
+ const { baseUrl, fetcher } = useVoyantNotificationsContext();
7
+ const enabled = options?.enabled ?? true;
8
+ return useQuery({
9
+ ...getNotificationDeliveryQueryOptions({ baseUrl, fetcher }, id),
10
+ enabled: enabled && Boolean(id),
11
+ });
12
+ }
@@ -0,0 +1,54 @@
1
+ import type { insertNotificationReminderRuleSchema, updateNotificationReminderRuleSchema } from "@voyantjs/notifications";
2
+ import type { z } from "zod";
3
+ export type CreateNotificationReminderRuleInput = z.input<typeof insertNotificationReminderRuleSchema>;
4
+ export type UpdateNotificationReminderRuleInput = z.input<typeof updateNotificationReminderRuleSchema>;
5
+ export declare function useNotificationReminderRuleMutation(): {
6
+ create: import("@tanstack/react-query").UseMutationResult<{
7
+ id: string;
8
+ slug: string;
9
+ name: string;
10
+ status: "draft" | "active" | "archived";
11
+ targetType: "booking_payment_schedule" | "invoice";
12
+ channel: "email" | "sms";
13
+ provider: string | null;
14
+ templateId: string | null;
15
+ templateSlug: string | null;
16
+ relativeDaysFromDueDate: number;
17
+ isSystem: boolean;
18
+ metadata: Record<string, unknown> | null;
19
+ createdAt: string;
20
+ updatedAt: string;
21
+ }, Error, {
22
+ slug: string;
23
+ name: string;
24
+ targetType: "booking_payment_schedule" | "invoice";
25
+ channel: "email" | "sms";
26
+ status?: "draft" | "active" | "archived" | undefined;
27
+ provider?: string | null | undefined;
28
+ templateId?: string | null | undefined;
29
+ templateSlug?: string | null | undefined;
30
+ relativeDaysFromDueDate?: unknown;
31
+ isSystem?: boolean | undefined;
32
+ metadata?: Record<string, unknown> | null | undefined;
33
+ }, unknown>;
34
+ update: import("@tanstack/react-query").UseMutationResult<{
35
+ id: string;
36
+ slug: string;
37
+ name: string;
38
+ status: "draft" | "active" | "archived";
39
+ targetType: "booking_payment_schedule" | "invoice";
40
+ channel: "email" | "sms";
41
+ provider: string | null;
42
+ templateId: string | null;
43
+ templateSlug: string | null;
44
+ relativeDaysFromDueDate: number;
45
+ isSystem: boolean;
46
+ metadata: Record<string, unknown> | null;
47
+ createdAt: string;
48
+ updatedAt: string;
49
+ }, Error, {
50
+ id: string;
51
+ input: UpdateNotificationReminderRuleInput;
52
+ }, unknown>;
53
+ };
54
+ //# sourceMappingURL=use-notification-reminder-rule-mutation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-notification-reminder-rule-mutation.d.ts","sourceRoot":"","sources":["../../src/hooks/use-notification-reminder-rule-mutation.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EACV,oCAAoC,EACpC,oCAAoC,EACrC,MAAM,yBAAyB,CAAA;AAChC,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAO5B,MAAM,MAAM,mCAAmC,GAAG,CAAC,CAAC,KAAK,CACvD,OAAO,oCAAoC,CAC5C,CAAA;AACD,MAAM,MAAM,mCAAmC,GAAG,CAAC,CAAC,KAAK,CACvD,OAAO,oCAAoC,CAC5C,CAAA;AAED,wBAAgB,mCAAmC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;YAyBzC,MAAM;eACH,mCAAmC;;EAiB/C"}
@@ -0,0 +1,31 @@
1
+ "use client";
2
+ import { useMutation, useQueryClient } from "@tanstack/react-query";
3
+ import { fetchWithValidation } from "../client.js";
4
+ import { useVoyantNotificationsContext } from "../provider.js";
5
+ import { notificationsQueryKeys } from "../query-keys.js";
6
+ import { notificationReminderRuleSingleResponse } from "../schemas.js";
7
+ export function useNotificationReminderRuleMutation() {
8
+ const { baseUrl, fetcher } = useVoyantNotificationsContext();
9
+ const queryClient = useQueryClient();
10
+ const create = useMutation({
11
+ mutationFn: async (input) => {
12
+ const { data } = await fetchWithValidation("/v1/admin/notifications/reminder-rules", notificationReminderRuleSingleResponse, { baseUrl, fetcher }, { method: "POST", body: JSON.stringify(input) });
13
+ return data;
14
+ },
15
+ onSuccess: (data) => {
16
+ void queryClient.invalidateQueries({ queryKey: notificationsQueryKeys.reminderRules() });
17
+ queryClient.setQueryData(notificationsQueryKeys.reminderRule(data.id), data);
18
+ },
19
+ });
20
+ const update = useMutation({
21
+ mutationFn: async ({ id, input, }) => {
22
+ const { data } = await fetchWithValidation(`/v1/admin/notifications/reminder-rules/${id}`, notificationReminderRuleSingleResponse, { baseUrl, fetcher }, { method: "PATCH", body: JSON.stringify(input) });
23
+ return data;
24
+ },
25
+ onSuccess: (data) => {
26
+ void queryClient.invalidateQueries({ queryKey: notificationsQueryKeys.reminderRules() });
27
+ queryClient.setQueryData(notificationsQueryKeys.reminderRule(data.id), data);
28
+ },
29
+ });
30
+ return { create, update };
31
+ }
@@ -0,0 +1,20 @@
1
+ export interface UseNotificationReminderRuleOptions {
2
+ enabled?: boolean;
3
+ }
4
+ export declare function useNotificationReminderRule(id: string, options?: UseNotificationReminderRuleOptions): import("@tanstack/react-query").UseQueryResult<{
5
+ id: string;
6
+ slug: string;
7
+ name: string;
8
+ status: "draft" | "active" | "archived";
9
+ targetType: "booking_payment_schedule" | "invoice";
10
+ channel: "email" | "sms";
11
+ provider: string | null;
12
+ templateId: string | null;
13
+ templateSlug: string | null;
14
+ relativeDaysFromDueDate: number;
15
+ isSystem: boolean;
16
+ metadata: Record<string, unknown> | null;
17
+ createdAt: string;
18
+ updatedAt: string;
19
+ }, Error>;
20
+ //# sourceMappingURL=use-notification-reminder-rule.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-notification-reminder-rule.d.ts","sourceRoot":"","sources":["../../src/hooks/use-notification-reminder-rule.ts"],"names":[],"mappings":"AAOA,MAAM,WAAW,kCAAkC;IACjD,OAAO,CAAC,EAAE,OAAO,CAAA;CAClB;AAED,wBAAgB,2BAA2B,CACzC,EAAE,EAAE,MAAM,EACV,OAAO,GAAE,kCAAuC;;;;;;;;;;;;;;;UAQjD"}
@@ -0,0 +1,12 @@
1
+ "use client";
2
+ import { useQuery } from "@tanstack/react-query";
3
+ import { useVoyantNotificationsContext } from "../provider.js";
4
+ import { getNotificationReminderRuleQueryOptions } from "../query-options.js";
5
+ export function useNotificationReminderRule(id, options = {}) {
6
+ const { baseUrl, fetcher } = useVoyantNotificationsContext();
7
+ const { enabled = true } = options;
8
+ return useQuery({
9
+ ...getNotificationReminderRuleQueryOptions({ baseUrl, fetcher }, id),
10
+ enabled: enabled && Boolean(id),
11
+ });
12
+ }
@@ -0,0 +1,26 @@
1
+ import type { NotificationReminderRulesListFilters } from "../query-keys.js";
2
+ export interface UseNotificationReminderRulesOptions extends NotificationReminderRulesListFilters {
3
+ enabled?: boolean;
4
+ }
5
+ export declare function useNotificationReminderRules(options?: UseNotificationReminderRulesOptions): import("@tanstack/react-query").UseQueryResult<{
6
+ data: {
7
+ id: string;
8
+ slug: string;
9
+ name: string;
10
+ status: "draft" | "active" | "archived";
11
+ targetType: "booking_payment_schedule" | "invoice";
12
+ channel: "email" | "sms";
13
+ provider: string | null;
14
+ templateId: string | null;
15
+ templateSlug: string | null;
16
+ relativeDaysFromDueDate: number;
17
+ isSystem: boolean;
18
+ metadata: Record<string, unknown> | null;
19
+ createdAt: string;
20
+ updatedAt: string;
21
+ }[];
22
+ total: number;
23
+ limit: number;
24
+ offset: number;
25
+ }, Error>;
26
+ //# sourceMappingURL=use-notification-reminder-rules.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-notification-reminder-rules.d.ts","sourceRoot":"","sources":["../../src/hooks/use-notification-reminder-rules.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,oCAAoC,EAAE,MAAM,kBAAkB,CAAA;AAG5E,MAAM,WAAW,mCAAoC,SAAQ,oCAAoC;IAC/F,OAAO,CAAC,EAAE,OAAO,CAAA;CAClB;AAED,wBAAgB,4BAA4B,CAAC,OAAO,GAAE,mCAAwC;;;;;;;;;;;;;;;;;;;;UAO7F"}
@@ -0,0 +1,12 @@
1
+ "use client";
2
+ import { useQuery } from "@tanstack/react-query";
3
+ import { useVoyantNotificationsContext } from "../provider.js";
4
+ import { getNotificationReminderRulesQueryOptions } from "../query-options.js";
5
+ export function useNotificationReminderRules(options = {}) {
6
+ const { baseUrl, fetcher } = useVoyantNotificationsContext();
7
+ const { enabled = true, ...filters } = options;
8
+ return useQuery({
9
+ ...getNotificationReminderRulesQueryOptions({ baseUrl, fetcher }, filters),
10
+ enabled,
11
+ });
12
+ }
@@ -0,0 +1,57 @@
1
+ import type { NotificationReminderRunsListFilters } from "../query-keys.js";
2
+ export interface UseNotificationReminderRunsOptions extends NotificationReminderRunsListFilters {
3
+ enabled?: boolean;
4
+ }
5
+ export declare function useNotificationReminderRuns(options?: UseNotificationReminderRunsOptions): import("@tanstack/react-query").UseQueryResult<{
6
+ data: {
7
+ id: string;
8
+ reminderRuleId: string;
9
+ targetType: "booking_payment_schedule" | "invoice";
10
+ targetId: string;
11
+ dedupeKey: string;
12
+ status: "sent" | "failed" | "queued" | "processing" | "skipped";
13
+ recipient: string | null;
14
+ scheduledFor: string;
15
+ processedAt: string;
16
+ errorMessage: string | null;
17
+ metadata: Record<string, unknown> | null;
18
+ createdAt: string;
19
+ updatedAt: string;
20
+ links: {
21
+ bookingId: string | null;
22
+ bookingPaymentScheduleId: string | null;
23
+ invoiceId: string | null;
24
+ paymentSessionId: string | null;
25
+ personId: string | null;
26
+ organizationId: string | null;
27
+ notificationDeliveryId: string | null;
28
+ };
29
+ reminderRule: {
30
+ id: string;
31
+ slug: string;
32
+ name: string;
33
+ status: "draft" | "active" | "archived";
34
+ targetType: "booking_payment_schedule" | "invoice";
35
+ channel: "email" | "sms";
36
+ provider: string | null;
37
+ templateId: string | null;
38
+ templateSlug: string | null;
39
+ relativeDaysFromDueDate: number;
40
+ };
41
+ delivery: {
42
+ id: string;
43
+ status: "pending" | "sent" | "failed" | "cancelled";
44
+ channel: "email" | "sms";
45
+ provider: string;
46
+ toAddress: string;
47
+ subject: string | null;
48
+ sentAt: string | null;
49
+ failedAt: string | null;
50
+ errorMessage: string | null;
51
+ } | null;
52
+ }[];
53
+ total: number;
54
+ limit: number;
55
+ offset: number;
56
+ }, Error>;
57
+ //# sourceMappingURL=use-notification-reminder-runs.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-notification-reminder-runs.d.ts","sourceRoot":"","sources":["../../src/hooks/use-notification-reminder-runs.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,mCAAmC,EAAE,MAAM,kBAAkB,CAAA;AAG3E,MAAM,WAAW,kCAAmC,SAAQ,mCAAmC;IAC7F,OAAO,CAAC,EAAE,OAAO,CAAA;CAClB;AAED,wBAAgB,2BAA2B,CAAC,OAAO,GAAE,kCAAuC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;UAO3F"}
@@ -0,0 +1,12 @@
1
+ "use client";
2
+ import { useQuery } from "@tanstack/react-query";
3
+ import { useVoyantNotificationsContext } from "../provider.js";
4
+ import { getNotificationReminderRunsQueryOptions } from "../query-options.js";
5
+ export function useNotificationReminderRuns(options = {}) {
6
+ const { baseUrl, fetcher } = useVoyantNotificationsContext();
7
+ const { enabled = true, ...filters } = options;
8
+ return useQuery({
9
+ ...getNotificationReminderRunsQueryOptions({ baseUrl, fetcher }, filters),
10
+ enabled,
11
+ });
12
+ }
@@ -0,0 +1,5 @@
1
+ export declare function useNotificationTemplateAuthoring(): {
2
+ variableCatalog: import("@voyantjs/notifications").NotificationTemplateVariableCategory[];
3
+ liquidSnippets: import("@voyantjs/notifications").NotificationLiquidSnippet[];
4
+ };
5
+ //# sourceMappingURL=use-notification-template-authoring.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-notification-template-authoring.d.ts","sourceRoot":"","sources":["../../src/hooks/use-notification-template-authoring.ts"],"names":[],"mappings":"AAOA,wBAAgB,gCAAgC;;;EAK/C"}
@@ -0,0 +1,8 @@
1
+ "use client";
2
+ import { notificationLiquidSnippets, notificationTemplateVariableCatalog, } from "@voyantjs/notifications";
3
+ export function useNotificationTemplateAuthoring() {
4
+ return {
5
+ variableCatalog: notificationTemplateVariableCatalog,
6
+ liquidSnippets: notificationLiquidSnippets,
7
+ };
8
+ }
@@ -0,0 +1,54 @@
1
+ import type { insertNotificationTemplateSchema, updateNotificationTemplateSchema } from "@voyantjs/notifications";
2
+ import type { z } from "zod";
3
+ export type CreateNotificationTemplateInput = z.input<typeof insertNotificationTemplateSchema>;
4
+ export type UpdateNotificationTemplateInput = z.input<typeof updateNotificationTemplateSchema>;
5
+ export declare function useNotificationTemplateMutation(): {
6
+ create: import("@tanstack/react-query").UseMutationResult<{
7
+ id: string;
8
+ slug: string;
9
+ name: string;
10
+ channel: "email" | "sms";
11
+ provider: string | null;
12
+ status: "draft" | "active" | "archived";
13
+ subjectTemplate: string | null;
14
+ htmlTemplate: string | null;
15
+ textTemplate: string | null;
16
+ fromAddress: string | null;
17
+ isSystem: boolean;
18
+ metadata: Record<string, unknown> | null;
19
+ createdAt: string;
20
+ updatedAt: string;
21
+ }, Error, {
22
+ slug: string;
23
+ name: string;
24
+ channel: "email" | "sms";
25
+ provider?: string | null | undefined;
26
+ status?: "draft" | "active" | "archived" | undefined;
27
+ subjectTemplate?: string | null | undefined;
28
+ htmlTemplate?: string | null | undefined;
29
+ textTemplate?: string | null | undefined;
30
+ fromAddress?: string | null | undefined;
31
+ isSystem?: boolean | undefined;
32
+ metadata?: Record<string, unknown> | null | undefined;
33
+ }, unknown>;
34
+ update: import("@tanstack/react-query").UseMutationResult<{
35
+ id: string;
36
+ slug: string;
37
+ name: string;
38
+ channel: "email" | "sms";
39
+ provider: string | null;
40
+ status: "draft" | "active" | "archived";
41
+ subjectTemplate: string | null;
42
+ htmlTemplate: string | null;
43
+ textTemplate: string | null;
44
+ fromAddress: string | null;
45
+ isSystem: boolean;
46
+ metadata: Record<string, unknown> | null;
47
+ createdAt: string;
48
+ updatedAt: string;
49
+ }, Error, {
50
+ id: string;
51
+ input: UpdateNotificationTemplateInput;
52
+ }, unknown>;
53
+ };
54
+ //# sourceMappingURL=use-notification-template-mutation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-notification-template-mutation.d.ts","sourceRoot":"","sources":["../../src/hooks/use-notification-template-mutation.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EACV,gCAAgC,EAChC,gCAAgC,EACjC,MAAM,yBAAyB,CAAA;AAChC,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAO5B,MAAM,MAAM,+BAA+B,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,gCAAgC,CAAC,CAAA;AAC9F,MAAM,MAAM,+BAA+B,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,gCAAgC,CAAC,CAAA;AAE9F,wBAAgB,+BAA+B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;YAqBH,MAAM;eAAS,+BAA+B;;EAgBzF"}
@@ -0,0 +1,31 @@
1
+ "use client";
2
+ import { useMutation, useQueryClient } from "@tanstack/react-query";
3
+ import { fetchWithValidation } from "../client.js";
4
+ import { useVoyantNotificationsContext } from "../provider.js";
5
+ import { notificationsQueryKeys } from "../query-keys.js";
6
+ import { notificationTemplateSingleResponse } from "../schemas.js";
7
+ export function useNotificationTemplateMutation() {
8
+ const { baseUrl, fetcher } = useVoyantNotificationsContext();
9
+ const queryClient = useQueryClient();
10
+ const create = useMutation({
11
+ mutationFn: async (input) => {
12
+ const { data } = await fetchWithValidation("/v1/admin/notifications/templates", notificationTemplateSingleResponse, { baseUrl, fetcher }, { method: "POST", body: JSON.stringify(input) });
13
+ return data;
14
+ },
15
+ onSuccess: (data) => {
16
+ void queryClient.invalidateQueries({ queryKey: notificationsQueryKeys.templates() });
17
+ queryClient.setQueryData(notificationsQueryKeys.template(data.id), data);
18
+ },
19
+ });
20
+ const update = useMutation({
21
+ mutationFn: async ({ id, input }) => {
22
+ const { data } = await fetchWithValidation(`/v1/admin/notifications/templates/${id}`, notificationTemplateSingleResponse, { baseUrl, fetcher }, { method: "PATCH", body: JSON.stringify(input) });
23
+ return data;
24
+ },
25
+ onSuccess: (data) => {
26
+ void queryClient.invalidateQueries({ queryKey: notificationsQueryKeys.templates() });
27
+ queryClient.setQueryData(notificationsQueryKeys.template(data.id), data);
28
+ },
29
+ });
30
+ return { create, update };
31
+ }