@voyantjs/pricing-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 (38) hide show
  1. package/README.md +8 -0
  2. package/dist/client.d.ts +14 -0
  3. package/dist/client.d.ts.map +1 -0
  4. package/dist/client.js +59 -0
  5. package/dist/hooks/index.d.ts +7 -0
  6. package/dist/hooks/index.d.ts.map +1 -0
  7. package/dist/hooks/index.js +6 -0
  8. package/dist/hooks/use-pricing-categories.d.ts +30 -0
  9. package/dist/hooks/use-pricing-categories.d.ts.map +1 -0
  10. package/dist/hooks/use-pricing-categories.js +33 -0
  11. package/dist/hooks/use-pricing-category-dependencies.d.ts +22 -0
  12. package/dist/hooks/use-pricing-category-dependencies.d.ts.map +1 -0
  13. package/dist/hooks/use-pricing-category-dependencies.js +32 -0
  14. package/dist/hooks/use-pricing-category-dependency-mutation.d.ts +43 -0
  15. package/dist/hooks/use-pricing-category-dependency-mutation.d.ts.map +1 -0
  16. package/dist/hooks/use-pricing-category-dependency-mutation.js +43 -0
  17. package/dist/hooks/use-pricing-category-dependency.d.ts +16 -0
  18. package/dist/hooks/use-pricing-category-dependency.d.ts.map +1 -0
  19. package/dist/hooks/use-pricing-category-dependency.js +18 -0
  20. package/dist/hooks/use-pricing-category-mutation.d.ts +67 -0
  21. package/dist/hooks/use-pricing-category-mutation.d.ts.map +1 -0
  22. package/dist/hooks/use-pricing-category-mutation.js +37 -0
  23. package/dist/hooks/use-pricing-category.d.ts +24 -0
  24. package/dist/hooks/use-pricing-category.d.ts.map +1 -0
  25. package/dist/hooks/use-pricing-category.js +18 -0
  26. package/dist/index.d.ts +6 -0
  27. package/dist/index.d.ts.map +1 -0
  28. package/dist/index.js +5 -0
  29. package/dist/provider.d.ts +14 -0
  30. package/dist/provider.d.ts.map +1 -0
  31. package/dist/provider.js +16 -0
  32. package/dist/query-keys.d.ts +27 -0
  33. package/dist/query-keys.d.ts.map +1 -0
  34. package/dist/query-keys.js +9 -0
  35. package/dist/schemas.d.ts +171 -0
  36. package/dist/schemas.d.ts.map +1 -0
  37. package/dist/schemas.js +55 -0
  38. package/package.json +75 -0
package/README.md ADDED
@@ -0,0 +1,8 @@
1
+ # @voyantjs/pricing-react
2
+
3
+ React hooks and provider utilities for Voyant pricing APIs.
4
+
5
+ Current surface:
6
+
7
+ - pricing categories
8
+ - pricing category dependencies
@@ -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,CAgCf"}
package/dist/client.js ADDED
@@ -0,0 +1,59 @@
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
+ }
37
+ const body = await safeJson(response);
38
+ const parsed = schema.safeParse(body);
39
+ if (!parsed.success) {
40
+ throw new VoyantApiError(`Voyant API response failed validation: ${parsed.error.message}`, response.status, body);
41
+ }
42
+ return parsed.data;
43
+ }
44
+ async function safeJson(response) {
45
+ const text = await response.text();
46
+ if (!text)
47
+ return undefined;
48
+ try {
49
+ return JSON.parse(text);
50
+ }
51
+ catch {
52
+ return text;
53
+ }
54
+ }
55
+ function joinUrl(baseUrl, path) {
56
+ const trimmedBase = baseUrl.endsWith("/") ? baseUrl.slice(0, -1) : baseUrl;
57
+ const trimmedPath = path.startsWith("/") ? path : `/${path}`;
58
+ return `${trimmedBase}${trimmedPath}`;
59
+ }
@@ -0,0 +1,7 @@
1
+ export * from "./use-pricing-categories.js";
2
+ export * from "./use-pricing-category.js";
3
+ export * from "./use-pricing-category-dependencies.js";
4
+ export * from "./use-pricing-category-dependency.js";
5
+ export * from "./use-pricing-category-dependency-mutation.js";
6
+ export * from "./use-pricing-category-mutation.js";
7
+ //# 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,6BAA6B,CAAA;AAC3C,cAAc,2BAA2B,CAAA;AACzC,cAAc,wCAAwC,CAAA;AACtD,cAAc,sCAAsC,CAAA;AACpD,cAAc,+CAA+C,CAAA;AAC7D,cAAc,oCAAoC,CAAA"}
@@ -0,0 +1,6 @@
1
+ export * from "./use-pricing-categories.js";
2
+ export * from "./use-pricing-category.js";
3
+ export * from "./use-pricing-category-dependencies.js";
4
+ export * from "./use-pricing-category-dependency.js";
5
+ export * from "./use-pricing-category-dependency-mutation.js";
6
+ export * from "./use-pricing-category-mutation.js";
@@ -0,0 +1,30 @@
1
+ import { type PricingCategoriesListFilters } from "../query-keys.js";
2
+ export interface UsePricingCategoriesOptions extends PricingCategoriesListFilters {
3
+ enabled?: boolean;
4
+ }
5
+ export declare function usePricingCategories(options?: UsePricingCategoriesOptions): import("@tanstack/react-query").UseQueryResult<{
6
+ data: {
7
+ id: string;
8
+ productId: string | null;
9
+ optionId: string | null;
10
+ unitId: string | null;
11
+ code: string | null;
12
+ name: string;
13
+ categoryType: "adult" | "child" | "infant" | "senior" | "group" | "room" | "vehicle" | "service" | "other";
14
+ seatOccupancy: number;
15
+ groupSize: number | null;
16
+ isAgeQualified: boolean;
17
+ minAge: number | null;
18
+ maxAge: number | null;
19
+ internalUseOnly: boolean;
20
+ active: boolean;
21
+ sortOrder: number;
22
+ createdAt: string;
23
+ updatedAt: string;
24
+ metadata?: Record<string, unknown> | null | undefined;
25
+ }[];
26
+ total: number;
27
+ limit: number;
28
+ offset: number;
29
+ }, Error>;
30
+ //# sourceMappingURL=use-pricing-categories.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-pricing-categories.d.ts","sourceRoot":"","sources":["../../src/hooks/use-pricing-categories.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,KAAK,4BAA4B,EAAoB,MAAM,kBAAkB,CAAA;AAGtF,MAAM,WAAW,2BAA4B,SAAQ,4BAA4B;IAC/E,OAAO,CAAC,EAAE,OAAO,CAAA;CAClB;AAED,wBAAgB,oBAAoB,CAAC,OAAO,GAAE,2BAAgC;;;;;;;;;;;;;;;;;;;;;;;;UAwB7E"}
@@ -0,0 +1,33 @@
1
+ "use client";
2
+ import { useQuery } from "@tanstack/react-query";
3
+ import { fetchWithValidation } from "../client.js";
4
+ import { useVoyantPricingContext } from "../provider.js";
5
+ import { pricingQueryKeys } from "../query-keys.js";
6
+ import { pricingCategoryListResponse } from "../schemas.js";
7
+ export function usePricingCategories(options = {}) {
8
+ const { baseUrl, fetcher } = useVoyantPricingContext();
9
+ const { enabled = true, ...filters } = options;
10
+ return useQuery({
11
+ queryKey: pricingQueryKeys.pricingCategoriesList(filters),
12
+ queryFn: () => {
13
+ const params = new URLSearchParams();
14
+ if (filters.productId)
15
+ params.set("productId", filters.productId);
16
+ if (filters.optionId)
17
+ params.set("optionId", filters.optionId);
18
+ if (filters.unitId)
19
+ params.set("unitId", filters.unitId);
20
+ if (filters.categoryType)
21
+ params.set("categoryType", filters.categoryType);
22
+ if (filters.active !== undefined)
23
+ params.set("active", String(filters.active));
24
+ if (filters.limit !== undefined)
25
+ params.set("limit", String(filters.limit));
26
+ if (filters.offset !== undefined)
27
+ params.set("offset", String(filters.offset));
28
+ const qs = params.toString();
29
+ return fetchWithValidation(`/v1/pricing/pricing-categories${qs ? `?${qs}` : ""}`, pricingCategoryListResponse, { baseUrl, fetcher });
30
+ },
31
+ enabled,
32
+ });
33
+ }
@@ -0,0 +1,22 @@
1
+ import { type PricingCategoryDependenciesListFilters } from "../query-keys.js";
2
+ export interface UsePricingCategoryDependenciesOptions extends PricingCategoryDependenciesListFilters {
3
+ enabled?: boolean;
4
+ }
5
+ export declare function usePricingCategoryDependencies(options?: UsePricingCategoryDependenciesOptions): import("@tanstack/react-query").UseQueryResult<{
6
+ data: {
7
+ id: string;
8
+ pricingCategoryId: string;
9
+ masterPricingCategoryId: string;
10
+ dependencyType: "requires" | "limits_per_master" | "limits_sum" | "excludes";
11
+ maxPerMaster: number | null;
12
+ maxDependentSum: number | null;
13
+ active: boolean;
14
+ notes: string | null;
15
+ createdAt: string;
16
+ updatedAt: string;
17
+ }[];
18
+ total: number;
19
+ limit: number;
20
+ offset: number;
21
+ }, Error>;
22
+ //# sourceMappingURL=use-pricing-category-dependencies.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-pricing-category-dependencies.d.ts","sourceRoot":"","sources":["../../src/hooks/use-pricing-category-dependencies.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,KAAK,sCAAsC,EAAoB,MAAM,kBAAkB,CAAA;AAGhG,MAAM,WAAW,qCACf,SAAQ,sCAAsC;IAC9C,OAAO,CAAC,EAAE,OAAO,CAAA;CAClB;AAED,wBAAgB,8BAA8B,CAC5C,OAAO,GAAE,qCAA0C;;;;;;;;;;;;;;;;UA0BpD"}
@@ -0,0 +1,32 @@
1
+ "use client";
2
+ import { useQuery } from "@tanstack/react-query";
3
+ import { fetchWithValidation } from "../client.js";
4
+ import { useVoyantPricingContext } from "../provider.js";
5
+ import { pricingQueryKeys } from "../query-keys.js";
6
+ import { pricingCategoryDependencyListResponse } from "../schemas.js";
7
+ export function usePricingCategoryDependencies(options = {}) {
8
+ const { baseUrl, fetcher } = useVoyantPricingContext();
9
+ const { enabled = true, ...filters } = options;
10
+ return useQuery({
11
+ queryKey: pricingQueryKeys.pricingCategoryDependenciesList(filters),
12
+ queryFn: () => {
13
+ const params = new URLSearchParams();
14
+ if (filters.pricingCategoryId)
15
+ params.set("pricingCategoryId", filters.pricingCategoryId);
16
+ if (filters.masterPricingCategoryId) {
17
+ params.set("masterPricingCategoryId", filters.masterPricingCategoryId);
18
+ }
19
+ if (filters.dependencyType)
20
+ params.set("dependencyType", filters.dependencyType);
21
+ if (filters.active !== undefined)
22
+ params.set("active", String(filters.active));
23
+ if (filters.limit !== undefined)
24
+ params.set("limit", String(filters.limit));
25
+ if (filters.offset !== undefined)
26
+ params.set("offset", String(filters.offset));
27
+ const qs = params.toString();
28
+ return fetchWithValidation(`/v1/pricing/pricing-category-dependencies${qs ? `?${qs}` : ""}`, pricingCategoryDependencyListResponse, { baseUrl, fetcher });
29
+ },
30
+ enabled,
31
+ });
32
+ }
@@ -0,0 +1,43 @@
1
+ export interface CreatePricingCategoryDependencyInput {
2
+ pricingCategoryId: string;
3
+ masterPricingCategoryId: string;
4
+ dependencyType?: "requires" | "limits_per_master" | "limits_sum" | "excludes";
5
+ maxPerMaster?: number | null;
6
+ maxDependentSum?: number | null;
7
+ active?: boolean;
8
+ notes?: string | null;
9
+ }
10
+ export type UpdatePricingCategoryDependencyInput = Partial<CreatePricingCategoryDependencyInput>;
11
+ export declare function usePricingCategoryDependencyMutation(): {
12
+ create: import("@tanstack/react-query").UseMutationResult<{
13
+ id: string;
14
+ pricingCategoryId: string;
15
+ masterPricingCategoryId: string;
16
+ dependencyType: "requires" | "limits_per_master" | "limits_sum" | "excludes";
17
+ maxPerMaster: number | null;
18
+ maxDependentSum: number | null;
19
+ active: boolean;
20
+ notes: string | null;
21
+ createdAt: string;
22
+ updatedAt: string;
23
+ }, Error, CreatePricingCategoryDependencyInput, unknown>;
24
+ update: import("@tanstack/react-query").UseMutationResult<{
25
+ id: string;
26
+ pricingCategoryId: string;
27
+ masterPricingCategoryId: string;
28
+ dependencyType: "requires" | "limits_per_master" | "limits_sum" | "excludes";
29
+ maxPerMaster: number | null;
30
+ maxDependentSum: number | null;
31
+ active: boolean;
32
+ notes: string | null;
33
+ createdAt: string;
34
+ updatedAt: string;
35
+ }, Error, {
36
+ id: string;
37
+ input: UpdatePricingCategoryDependencyInput;
38
+ }, unknown>;
39
+ remove: import("@tanstack/react-query").UseMutationResult<{
40
+ success: boolean;
41
+ }, Error, string, unknown>;
42
+ };
43
+ //# sourceMappingURL=use-pricing-category-dependency-mutation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-pricing-category-dependency-mutation.d.ts","sourceRoot":"","sources":["../../src/hooks/use-pricing-category-dependency-mutation.ts"],"names":[],"mappings":"AASA,MAAM,WAAW,oCAAoC;IACnD,iBAAiB,EAAE,MAAM,CAAA;IACzB,uBAAuB,EAAE,MAAM,CAAA;IAC/B,cAAc,CAAC,EAAE,UAAU,GAAG,mBAAmB,GAAG,YAAY,GAAG,UAAU,CAAA;IAC7E,YAAY,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IAC5B,eAAe,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IAC/B,MAAM,CAAC,EAAE,OAAO,CAAA;IAChB,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;CACtB;AAED,MAAM,MAAM,oCAAoC,GAAG,OAAO,CAAC,oCAAoC,CAAC,CAAA;AAEhG,wBAAgB,oCAAoC;;;;;;;;;;;;;;;;;;;;;;;;;YA0B1C,MAAM;eACH,oCAAoC;;;;;EAmChD"}
@@ -0,0 +1,43 @@
1
+ "use client";
2
+ import { useMutation, useQueryClient } from "@tanstack/react-query";
3
+ import { fetchWithValidation } from "../client.js";
4
+ import { useVoyantPricingContext } from "../provider.js";
5
+ import { pricingQueryKeys } from "../query-keys.js";
6
+ import { pricingCategoryDependencySingleResponse, successEnvelope } from "../schemas.js";
7
+ export function usePricingCategoryDependencyMutation() {
8
+ const { baseUrl, fetcher } = useVoyantPricingContext();
9
+ const queryClient = useQueryClient();
10
+ const create = useMutation({
11
+ mutationFn: async (input) => {
12
+ const { data } = await fetchWithValidation("/v1/pricing/pricing-category-dependencies", pricingCategoryDependencySingleResponse, { baseUrl, fetcher }, { method: "POST", body: JSON.stringify(input) });
13
+ return data;
14
+ },
15
+ onSuccess: () => {
16
+ void queryClient.invalidateQueries({
17
+ queryKey: pricingQueryKeys.pricingCategoryDependencies(),
18
+ });
19
+ },
20
+ });
21
+ const update = useMutation({
22
+ mutationFn: async ({ id, input, }) => {
23
+ const { data } = await fetchWithValidation(`/v1/pricing/pricing-category-dependencies/${id}`, pricingCategoryDependencySingleResponse, { baseUrl, fetcher }, { method: "PATCH", body: JSON.stringify(input) });
24
+ return data;
25
+ },
26
+ onSuccess: (data) => {
27
+ void queryClient.invalidateQueries({
28
+ queryKey: pricingQueryKeys.pricingCategoryDependencies(),
29
+ });
30
+ queryClient.setQueryData(pricingQueryKeys.pricingCategoryDependency(data.id), data);
31
+ },
32
+ });
33
+ const remove = useMutation({
34
+ mutationFn: async (id) => fetchWithValidation(`/v1/pricing/pricing-category-dependencies/${id}`, successEnvelope, { baseUrl, fetcher }, { method: "DELETE" }),
35
+ onSuccess: (_data, id) => {
36
+ void queryClient.invalidateQueries({
37
+ queryKey: pricingQueryKeys.pricingCategoryDependencies(),
38
+ });
39
+ queryClient.removeQueries({ queryKey: pricingQueryKeys.pricingCategoryDependency(id) });
40
+ },
41
+ });
42
+ return { create, update, remove };
43
+ }
@@ -0,0 +1,16 @@
1
+ export interface UsePricingCategoryDependencyOptions {
2
+ enabled?: boolean;
3
+ }
4
+ export declare function usePricingCategoryDependency(id: string | null | undefined, options?: UsePricingCategoryDependencyOptions): import("@tanstack/react-query").UseQueryResult<{
5
+ id: string;
6
+ pricingCategoryId: string;
7
+ masterPricingCategoryId: string;
8
+ dependencyType: "requires" | "limits_per_master" | "limits_sum" | "excludes";
9
+ maxPerMaster: number | null;
10
+ maxDependentSum: number | null;
11
+ active: boolean;
12
+ notes: string | null;
13
+ createdAt: string;
14
+ updatedAt: string;
15
+ }, Error>;
16
+ //# sourceMappingURL=use-pricing-category-dependency.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-pricing-category-dependency.d.ts","sourceRoot":"","sources":["../../src/hooks/use-pricing-category-dependency.ts"],"names":[],"mappings":"AASA,MAAM,WAAW,mCAAmC;IAClD,OAAO,CAAC,EAAE,OAAO,CAAA;CAClB;AAED,wBAAgB,4BAA4B,CAC1C,EAAE,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,EAC7B,OAAO,GAAE,mCAAwC;;;;;;;;;;;UAiBlD"}
@@ -0,0 +1,18 @@
1
+ "use client";
2
+ import { useQuery } from "@tanstack/react-query";
3
+ import { fetchWithValidation } from "../client.js";
4
+ import { useVoyantPricingContext } from "../provider.js";
5
+ import { pricingQueryKeys } from "../query-keys.js";
6
+ import { pricingCategoryDependencySingleResponse } from "../schemas.js";
7
+ export function usePricingCategoryDependency(id, options = {}) {
8
+ const { baseUrl, fetcher } = useVoyantPricingContext();
9
+ const { enabled = true } = options;
10
+ return useQuery({
11
+ queryKey: pricingQueryKeys.pricingCategoryDependency(id ?? "__missing__"),
12
+ queryFn: async () => {
13
+ const { data } = await fetchWithValidation(`/v1/pricing/pricing-category-dependencies/${id}`, pricingCategoryDependencySingleResponse, { baseUrl, fetcher });
14
+ return data;
15
+ },
16
+ enabled: enabled && Boolean(id),
17
+ });
18
+ }
@@ -0,0 +1,67 @@
1
+ export interface CreatePricingCategoryInput {
2
+ productId?: string | null;
3
+ optionId?: string | null;
4
+ unitId?: string | null;
5
+ code?: string | null;
6
+ name: string;
7
+ categoryType?: "adult" | "child" | "infant" | "senior" | "group" | "room" | "vehicle" | "service" | "other";
8
+ seatOccupancy?: number;
9
+ groupSize?: number | null;
10
+ isAgeQualified?: boolean;
11
+ minAge?: number | null;
12
+ maxAge?: number | null;
13
+ internalUseOnly?: boolean;
14
+ active?: boolean;
15
+ sortOrder?: number;
16
+ metadata?: Record<string, unknown> | null;
17
+ }
18
+ export type UpdatePricingCategoryInput = Partial<CreatePricingCategoryInput>;
19
+ export declare function usePricingCategoryMutation(): {
20
+ create: import("@tanstack/react-query").UseMutationResult<{
21
+ id: string;
22
+ productId: string | null;
23
+ optionId: string | null;
24
+ unitId: string | null;
25
+ code: string | null;
26
+ name: string;
27
+ categoryType: "adult" | "child" | "infant" | "senior" | "group" | "room" | "vehicle" | "service" | "other";
28
+ seatOccupancy: number;
29
+ groupSize: number | null;
30
+ isAgeQualified: boolean;
31
+ minAge: number | null;
32
+ maxAge: number | null;
33
+ internalUseOnly: boolean;
34
+ active: boolean;
35
+ sortOrder: number;
36
+ createdAt: string;
37
+ updatedAt: string;
38
+ metadata?: Record<string, unknown> | null | undefined;
39
+ }, Error, CreatePricingCategoryInput, unknown>;
40
+ update: import("@tanstack/react-query").UseMutationResult<{
41
+ id: string;
42
+ productId: string | null;
43
+ optionId: string | null;
44
+ unitId: string | null;
45
+ code: string | null;
46
+ name: string;
47
+ categoryType: "adult" | "child" | "infant" | "senior" | "group" | "room" | "vehicle" | "service" | "other";
48
+ seatOccupancy: number;
49
+ groupSize: number | null;
50
+ isAgeQualified: boolean;
51
+ minAge: number | null;
52
+ maxAge: number | null;
53
+ internalUseOnly: boolean;
54
+ active: boolean;
55
+ sortOrder: number;
56
+ createdAt: string;
57
+ updatedAt: string;
58
+ metadata?: Record<string, unknown> | null | undefined;
59
+ }, Error, {
60
+ id: string;
61
+ input: UpdatePricingCategoryInput;
62
+ }, unknown>;
63
+ remove: import("@tanstack/react-query").UseMutationResult<{
64
+ success: boolean;
65
+ }, Error, string, unknown>;
66
+ };
67
+ //# sourceMappingURL=use-pricing-category-mutation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-pricing-category-mutation.d.ts","sourceRoot":"","sources":["../../src/hooks/use-pricing-category-mutation.ts"],"names":[],"mappings":"AASA,MAAM,WAAW,0BAA0B;IACzC,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IACzB,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IACxB,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IACtB,IAAI,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IACpB,IAAI,EAAE,MAAM,CAAA;IACZ,YAAY,CAAC,EACT,OAAO,GACP,OAAO,GACP,QAAQ,GACR,QAAQ,GACR,OAAO,GACP,MAAM,GACN,SAAS,GACT,SAAS,GACT,OAAO,CAAA;IACX,aAAa,CAAC,EAAE,MAAM,CAAA;IACtB,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IACzB,cAAc,CAAC,EAAE,OAAO,CAAA;IACxB,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IACtB,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IACtB,eAAe,CAAC,EAAE,OAAO,CAAA;IACzB,MAAM,CAAC,EAAE,OAAO,CAAA;IAChB,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAAA;CAC1C;AAED,MAAM,MAAM,0BAA0B,GAAG,OAAO,CAAC,0BAA0B,CAAC,CAAA;AAE5E,wBAAgB,0BAA0B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;YAoBE,MAAM;eAAS,0BAA0B;;;;;EA8BpF"}
@@ -0,0 +1,37 @@
1
+ "use client";
2
+ import { useMutation, useQueryClient } from "@tanstack/react-query";
3
+ import { fetchWithValidation } from "../client.js";
4
+ import { useVoyantPricingContext } from "../provider.js";
5
+ import { pricingQueryKeys } from "../query-keys.js";
6
+ import { pricingCategorySingleResponse, successEnvelope } from "../schemas.js";
7
+ export function usePricingCategoryMutation() {
8
+ const { baseUrl, fetcher } = useVoyantPricingContext();
9
+ const queryClient = useQueryClient();
10
+ const create = useMutation({
11
+ mutationFn: async (input) => {
12
+ const { data } = await fetchWithValidation("/v1/pricing/pricing-categories", pricingCategorySingleResponse, { baseUrl, fetcher }, { method: "POST", body: JSON.stringify(input) });
13
+ return data;
14
+ },
15
+ onSuccess: () => {
16
+ void queryClient.invalidateQueries({ queryKey: pricingQueryKeys.pricingCategories() });
17
+ },
18
+ });
19
+ const update = useMutation({
20
+ mutationFn: async ({ id, input }) => {
21
+ const { data } = await fetchWithValidation(`/v1/pricing/pricing-categories/${id}`, pricingCategorySingleResponse, { baseUrl, fetcher }, { method: "PATCH", body: JSON.stringify(input) });
22
+ return data;
23
+ },
24
+ onSuccess: (data) => {
25
+ void queryClient.invalidateQueries({ queryKey: pricingQueryKeys.pricingCategories() });
26
+ queryClient.setQueryData(pricingQueryKeys.pricingCategory(data.id), data);
27
+ },
28
+ });
29
+ const remove = useMutation({
30
+ mutationFn: async (id) => fetchWithValidation(`/v1/pricing/pricing-categories/${id}`, successEnvelope, { baseUrl, fetcher }, { method: "DELETE" }),
31
+ onSuccess: (_data, id) => {
32
+ void queryClient.invalidateQueries({ queryKey: pricingQueryKeys.pricingCategories() });
33
+ queryClient.removeQueries({ queryKey: pricingQueryKeys.pricingCategory(id) });
34
+ },
35
+ });
36
+ return { create, update, remove };
37
+ }
@@ -0,0 +1,24 @@
1
+ export interface UsePricingCategoryOptions {
2
+ enabled?: boolean;
3
+ }
4
+ export declare function usePricingCategory(id: string | null | undefined, options?: UsePricingCategoryOptions): import("@tanstack/react-query").UseQueryResult<{
5
+ id: string;
6
+ productId: string | null;
7
+ optionId: string | null;
8
+ unitId: string | null;
9
+ code: string | null;
10
+ name: string;
11
+ categoryType: "adult" | "child" | "infant" | "senior" | "group" | "room" | "vehicle" | "service" | "other";
12
+ seatOccupancy: number;
13
+ groupSize: number | null;
14
+ isAgeQualified: boolean;
15
+ minAge: number | null;
16
+ maxAge: number | null;
17
+ internalUseOnly: boolean;
18
+ active: boolean;
19
+ sortOrder: number;
20
+ createdAt: string;
21
+ updatedAt: string;
22
+ metadata?: Record<string, unknown> | null | undefined;
23
+ }, Error>;
24
+ //# sourceMappingURL=use-pricing-category.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-pricing-category.d.ts","sourceRoot":"","sources":["../../src/hooks/use-pricing-category.ts"],"names":[],"mappings":"AASA,MAAM,WAAW,yBAAyB;IACxC,OAAO,CAAC,EAAE,OAAO,CAAA;CAClB;AAED,wBAAgB,kBAAkB,CAChC,EAAE,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,EAC7B,OAAO,GAAE,yBAA8B;;;;;;;;;;;;;;;;;;;UAiBxC"}
@@ -0,0 +1,18 @@
1
+ "use client";
2
+ import { useQuery } from "@tanstack/react-query";
3
+ import { fetchWithValidation } from "../client.js";
4
+ import { useVoyantPricingContext } from "../provider.js";
5
+ import { pricingQueryKeys } from "../query-keys.js";
6
+ import { pricingCategorySingleResponse } from "../schemas.js";
7
+ export function usePricingCategory(id, options = {}) {
8
+ const { baseUrl, fetcher } = useVoyantPricingContext();
9
+ const { enabled = true } = options;
10
+ return useQuery({
11
+ queryKey: pricingQueryKeys.pricingCategory(id ?? "__missing__"),
12
+ queryFn: async () => {
13
+ const { data } = await fetchWithValidation(`/v1/pricing/pricing-categories/${id}`, pricingCategorySingleResponse, { baseUrl, fetcher });
14
+ return data;
15
+ },
16
+ enabled: enabled && Boolean(id),
17
+ });
18
+ }
@@ -0,0 +1,6 @@
1
+ export { defaultFetcher, fetchWithValidation, VoyantApiError, type VoyantFetcher, } from "./client.js";
2
+ export * from "./hooks/index.js";
3
+ export { useVoyantPricingContext, type VoyantPricingContextValue, VoyantPricingProvider, type VoyantPricingProviderProps, } from "./provider.js";
4
+ export { pricingQueryKeys } from "./query-keys.js";
5
+ export * from "./schemas.js";
6
+ //# 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,mBAAmB,EACnB,cAAc,EACd,KAAK,aAAa,GACnB,MAAM,aAAa,CAAA;AACpB,cAAc,kBAAkB,CAAA;AAChC,OAAO,EACL,uBAAuB,EACvB,KAAK,yBAAyB,EAC9B,qBAAqB,EACrB,KAAK,0BAA0B,GAChC,MAAM,eAAe,CAAA;AACtB,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAA;AAClD,cAAc,cAAc,CAAA"}
package/dist/index.js ADDED
@@ -0,0 +1,5 @@
1
+ export { defaultFetcher, fetchWithValidation, VoyantApiError, } from "./client.js";
2
+ export * from "./hooks/index.js";
3
+ export { useVoyantPricingContext, VoyantPricingProvider, } from "./provider.js";
4
+ export { pricingQueryKeys } from "./query-keys.js";
5
+ export * from "./schemas.js";
@@ -0,0 +1,14 @@
1
+ import { type ReactNode } from "react";
2
+ import { type VoyantFetcher } from "./client.js";
3
+ export interface VoyantPricingContextValue {
4
+ baseUrl: string;
5
+ fetcher: VoyantFetcher;
6
+ }
7
+ export interface VoyantPricingProviderProps {
8
+ baseUrl: string;
9
+ fetcher?: VoyantFetcher;
10
+ children: ReactNode;
11
+ }
12
+ export declare function VoyantPricingProvider({ baseUrl, fetcher, children }: VoyantPricingProviderProps): import("react/jsx-runtime").JSX.Element;
13
+ export declare function useVoyantPricingContext(): VoyantPricingContextValue;
14
+ //# sourceMappingURL=provider.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"provider.d.ts","sourceRoot":"","sources":["../src/provider.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAiB,KAAK,SAAS,EAAuB,MAAM,OAAO,CAAA;AAE1E,OAAO,EAAkB,KAAK,aAAa,EAAE,MAAM,aAAa,CAAA;AAEhE,MAAM,WAAW,yBAAyB;IACxC,OAAO,EAAE,MAAM,CAAA;IACf,OAAO,EAAE,aAAa,CAAA;CACvB;AAID,MAAM,WAAW,0BAA0B;IACzC,OAAO,EAAE,MAAM,CAAA;IACf,OAAO,CAAC,EAAE,aAAa,CAAA;IACvB,QAAQ,EAAE,SAAS,CAAA;CACpB;AAED,wBAAgB,qBAAqB,CAAC,EAAE,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,EAAE,0BAA0B,2CAO/F;AAED,wBAAgB,uBAAuB,IAAI,yBAAyB,CAQnE"}
@@ -0,0 +1,16 @@
1
+ "use client";
2
+ import { jsx as _jsx } from "react/jsx-runtime";
3
+ import { createContext, useContext, useMemo } from "react";
4
+ import { defaultFetcher } from "./client.js";
5
+ const VoyantPricingContext = createContext(null);
6
+ export function VoyantPricingProvider({ baseUrl, fetcher, children }) {
7
+ const value = useMemo(() => ({ baseUrl, fetcher: fetcher ?? defaultFetcher }), [baseUrl, fetcher]);
8
+ return _jsx(VoyantPricingContext.Provider, { value: value, children: children });
9
+ }
10
+ export function useVoyantPricingContext() {
11
+ const context = useContext(VoyantPricingContext);
12
+ if (!context) {
13
+ throw new Error('useVoyantPricingContext must be used inside <VoyantPricingProvider>. Wrap your app with <VoyantPricingProvider baseUrl="/api" />.');
14
+ }
15
+ return context;
16
+ }
@@ -0,0 +1,27 @@
1
+ export interface PricingCategoriesListFilters {
2
+ productId?: string | undefined;
3
+ optionId?: string | undefined;
4
+ unitId?: string | undefined;
5
+ categoryType?: string | undefined;
6
+ active?: boolean | undefined;
7
+ limit?: number | undefined;
8
+ offset?: number | undefined;
9
+ }
10
+ export interface PricingCategoryDependenciesListFilters {
11
+ pricingCategoryId?: string | undefined;
12
+ masterPricingCategoryId?: string | undefined;
13
+ dependencyType?: string | undefined;
14
+ active?: boolean | undefined;
15
+ limit?: number | undefined;
16
+ offset?: number | undefined;
17
+ }
18
+ export declare const pricingQueryKeys: {
19
+ readonly all: readonly ["voyant", "pricing"];
20
+ readonly pricingCategories: () => readonly ["voyant", "pricing", "pricing-categories"];
21
+ readonly pricingCategoriesList: (filters: PricingCategoriesListFilters) => readonly ["voyant", "pricing", "pricing-categories", "list", PricingCategoriesListFilters];
22
+ readonly pricingCategory: (id: string) => readonly ["voyant", "pricing", "pricing-categories", "detail", string];
23
+ readonly pricingCategoryDependencies: () => readonly ["voyant", "pricing", "pricing-category-dependencies"];
24
+ readonly pricingCategoryDependenciesList: (filters: PricingCategoryDependenciesListFilters) => readonly ["voyant", "pricing", "pricing-category-dependencies", "list", PricingCategoryDependenciesListFilters];
25
+ readonly pricingCategoryDependency: (id: string) => readonly ["voyant", "pricing", "pricing-category-dependencies", "detail", string];
26
+ };
27
+ //# sourceMappingURL=query-keys.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"query-keys.d.ts","sourceRoot":"","sources":["../src/query-keys.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,4BAA4B;IAC3C,SAAS,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;IAC9B,QAAQ,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;IAC7B,MAAM,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;IAC3B,YAAY,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;IACjC,MAAM,CAAC,EAAE,OAAO,GAAG,SAAS,CAAA;IAC5B,KAAK,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;IAC1B,MAAM,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;CAC5B;AAED,MAAM,WAAW,sCAAsC;IACrD,iBAAiB,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;IACtC,uBAAuB,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;IAC5C,cAAc,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;IACnC,MAAM,CAAC,EAAE,OAAO,GAAG,SAAS,CAAA;IAC5B,KAAK,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;IAC1B,MAAM,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;CAC5B;AAED,eAAO,MAAM,gBAAgB;;;8CAIM,4BAA4B;mCAEvC,MAAM;;wDAIe,sCAAsC;6CAEjD,MAAM;CAE9B,CAAA"}
@@ -0,0 +1,9 @@
1
+ export const pricingQueryKeys = {
2
+ all: ["voyant", "pricing"],
3
+ pricingCategories: () => [...pricingQueryKeys.all, "pricing-categories"],
4
+ pricingCategoriesList: (filters) => [...pricingQueryKeys.pricingCategories(), "list", filters],
5
+ pricingCategory: (id) => [...pricingQueryKeys.pricingCategories(), "detail", id],
6
+ pricingCategoryDependencies: () => [...pricingQueryKeys.all, "pricing-category-dependencies"],
7
+ pricingCategoryDependenciesList: (filters) => [...pricingQueryKeys.pricingCategoryDependencies(), "list", filters],
8
+ pricingCategoryDependency: (id) => [...pricingQueryKeys.pricingCategoryDependencies(), "detail", id],
9
+ };
@@ -0,0 +1,171 @@
1
+ import { z } from "zod";
2
+ export declare const paginatedEnvelope: <T extends z.ZodTypeAny>(item: T) => z.ZodObject<{
3
+ data: z.ZodArray<T>;
4
+ total: z.ZodNumber;
5
+ limit: z.ZodNumber;
6
+ offset: z.ZodNumber;
7
+ }, z.core.$strip>;
8
+ export declare const singleEnvelope: <T extends z.ZodTypeAny>(item: T) => z.ZodObject<{
9
+ data: T;
10
+ }, z.core.$strip>;
11
+ export declare const successEnvelope: z.ZodObject<{
12
+ success: z.ZodBoolean;
13
+ }, z.core.$strip>;
14
+ export declare const pricingCategoryRecordSchema: z.ZodObject<{
15
+ id: z.ZodString;
16
+ productId: z.ZodNullable<z.ZodString>;
17
+ optionId: z.ZodNullable<z.ZodString>;
18
+ unitId: z.ZodNullable<z.ZodString>;
19
+ code: z.ZodNullable<z.ZodString>;
20
+ name: z.ZodString;
21
+ categoryType: z.ZodEnum<{
22
+ adult: "adult";
23
+ child: "child";
24
+ infant: "infant";
25
+ senior: "senior";
26
+ group: "group";
27
+ room: "room";
28
+ vehicle: "vehicle";
29
+ service: "service";
30
+ other: "other";
31
+ }>;
32
+ seatOccupancy: z.ZodNumber;
33
+ groupSize: z.ZodNullable<z.ZodNumber>;
34
+ isAgeQualified: z.ZodBoolean;
35
+ minAge: z.ZodNullable<z.ZodNumber>;
36
+ maxAge: z.ZodNullable<z.ZodNumber>;
37
+ internalUseOnly: z.ZodBoolean;
38
+ active: z.ZodBoolean;
39
+ sortOrder: z.ZodNumber;
40
+ metadata: z.ZodOptional<z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
41
+ createdAt: z.ZodString;
42
+ updatedAt: z.ZodString;
43
+ }, z.core.$strip>;
44
+ export type PricingCategoryRecord = z.infer<typeof pricingCategoryRecordSchema>;
45
+ export declare const pricingCategoryDependencyRecordSchema: z.ZodObject<{
46
+ id: z.ZodString;
47
+ pricingCategoryId: z.ZodString;
48
+ masterPricingCategoryId: z.ZodString;
49
+ dependencyType: z.ZodEnum<{
50
+ requires: "requires";
51
+ limits_per_master: "limits_per_master";
52
+ limits_sum: "limits_sum";
53
+ excludes: "excludes";
54
+ }>;
55
+ maxPerMaster: z.ZodNullable<z.ZodNumber>;
56
+ maxDependentSum: z.ZodNullable<z.ZodNumber>;
57
+ active: z.ZodBoolean;
58
+ notes: z.ZodNullable<z.ZodString>;
59
+ createdAt: z.ZodString;
60
+ updatedAt: z.ZodString;
61
+ }, z.core.$strip>;
62
+ export type PricingCategoryDependencyRecord = z.infer<typeof pricingCategoryDependencyRecordSchema>;
63
+ export declare const pricingCategoryListResponse: z.ZodObject<{
64
+ data: z.ZodArray<z.ZodObject<{
65
+ id: z.ZodString;
66
+ productId: z.ZodNullable<z.ZodString>;
67
+ optionId: z.ZodNullable<z.ZodString>;
68
+ unitId: z.ZodNullable<z.ZodString>;
69
+ code: z.ZodNullable<z.ZodString>;
70
+ name: z.ZodString;
71
+ categoryType: z.ZodEnum<{
72
+ adult: "adult";
73
+ child: "child";
74
+ infant: "infant";
75
+ senior: "senior";
76
+ group: "group";
77
+ room: "room";
78
+ vehicle: "vehicle";
79
+ service: "service";
80
+ other: "other";
81
+ }>;
82
+ seatOccupancy: z.ZodNumber;
83
+ groupSize: z.ZodNullable<z.ZodNumber>;
84
+ isAgeQualified: z.ZodBoolean;
85
+ minAge: z.ZodNullable<z.ZodNumber>;
86
+ maxAge: z.ZodNullable<z.ZodNumber>;
87
+ internalUseOnly: z.ZodBoolean;
88
+ active: z.ZodBoolean;
89
+ sortOrder: z.ZodNumber;
90
+ metadata: z.ZodOptional<z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
91
+ createdAt: z.ZodString;
92
+ updatedAt: z.ZodString;
93
+ }, z.core.$strip>>;
94
+ total: z.ZodNumber;
95
+ limit: z.ZodNumber;
96
+ offset: z.ZodNumber;
97
+ }, z.core.$strip>;
98
+ export declare const pricingCategorySingleResponse: z.ZodObject<{
99
+ data: z.ZodObject<{
100
+ id: z.ZodString;
101
+ productId: z.ZodNullable<z.ZodString>;
102
+ optionId: z.ZodNullable<z.ZodString>;
103
+ unitId: z.ZodNullable<z.ZodString>;
104
+ code: z.ZodNullable<z.ZodString>;
105
+ name: z.ZodString;
106
+ categoryType: z.ZodEnum<{
107
+ adult: "adult";
108
+ child: "child";
109
+ infant: "infant";
110
+ senior: "senior";
111
+ group: "group";
112
+ room: "room";
113
+ vehicle: "vehicle";
114
+ service: "service";
115
+ other: "other";
116
+ }>;
117
+ seatOccupancy: z.ZodNumber;
118
+ groupSize: z.ZodNullable<z.ZodNumber>;
119
+ isAgeQualified: z.ZodBoolean;
120
+ minAge: z.ZodNullable<z.ZodNumber>;
121
+ maxAge: z.ZodNullable<z.ZodNumber>;
122
+ internalUseOnly: z.ZodBoolean;
123
+ active: z.ZodBoolean;
124
+ sortOrder: z.ZodNumber;
125
+ metadata: z.ZodOptional<z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
126
+ createdAt: z.ZodString;
127
+ updatedAt: z.ZodString;
128
+ }, z.core.$strip>;
129
+ }, z.core.$strip>;
130
+ export declare const pricingCategoryDependencyListResponse: z.ZodObject<{
131
+ data: z.ZodArray<z.ZodObject<{
132
+ id: z.ZodString;
133
+ pricingCategoryId: z.ZodString;
134
+ masterPricingCategoryId: z.ZodString;
135
+ dependencyType: z.ZodEnum<{
136
+ requires: "requires";
137
+ limits_per_master: "limits_per_master";
138
+ limits_sum: "limits_sum";
139
+ excludes: "excludes";
140
+ }>;
141
+ maxPerMaster: z.ZodNullable<z.ZodNumber>;
142
+ maxDependentSum: z.ZodNullable<z.ZodNumber>;
143
+ active: z.ZodBoolean;
144
+ notes: z.ZodNullable<z.ZodString>;
145
+ createdAt: z.ZodString;
146
+ updatedAt: z.ZodString;
147
+ }, z.core.$strip>>;
148
+ total: z.ZodNumber;
149
+ limit: z.ZodNumber;
150
+ offset: z.ZodNumber;
151
+ }, z.core.$strip>;
152
+ export declare const pricingCategoryDependencySingleResponse: z.ZodObject<{
153
+ data: z.ZodObject<{
154
+ id: z.ZodString;
155
+ pricingCategoryId: z.ZodString;
156
+ masterPricingCategoryId: z.ZodString;
157
+ dependencyType: z.ZodEnum<{
158
+ requires: "requires";
159
+ limits_per_master: "limits_per_master";
160
+ limits_sum: "limits_sum";
161
+ excludes: "excludes";
162
+ }>;
163
+ maxPerMaster: z.ZodNullable<z.ZodNumber>;
164
+ maxDependentSum: z.ZodNullable<z.ZodNumber>;
165
+ active: z.ZodBoolean;
166
+ notes: z.ZodNullable<z.ZodString>;
167
+ createdAt: z.ZodString;
168
+ updatedAt: z.ZodString;
169
+ }, z.core.$strip>;
170
+ }, z.core.$strip>;
171
+ //# sourceMappingURL=schemas.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schemas.d.ts","sourceRoot":"","sources":["../src/schemas.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAEvB,eAAO,MAAM,iBAAiB,GAAI,CAAC,SAAS,CAAC,CAAC,UAAU,EAAE,MAAM,CAAC;;;;;iBAM7D,CAAA;AAEJ,eAAO,MAAM,cAAc,GAAI,CAAC,SAAS,CAAC,CAAC,UAAU,EAAE,MAAM,CAAC;;iBAA6B,CAAA;AAE3F,eAAO,MAAM,eAAe;;iBAAqC,CAAA;AAEjE,eAAO,MAAM,2BAA2B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBA6BtC,CAAA;AAEF,MAAM,MAAM,qBAAqB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,2BAA2B,CAAC,CAAA;AAE/E,eAAO,MAAM,qCAAqC;;;;;;;;;;;;;;;;iBAWhD,CAAA;AAEF,MAAM,MAAM,+BAA+B,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,qCAAqC,CAAC,CAAA;AAEnG,eAAO,MAAM,2BAA2B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAAiD,CAAA;AACzF,eAAO,MAAM,6BAA6B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAA8C,CAAA;AACxF,eAAO,MAAM,qCAAqC;;;;;;;;;;;;;;;;;;;;;iBAEjD,CAAA;AACD,eAAO,MAAM,uCAAuC;;;;;;;;;;;;;;;;;;iBAEnD,CAAA"}
@@ -0,0 +1,55 @@
1
+ import { z } from "zod";
2
+ export const paginatedEnvelope = (item) => z.object({
3
+ data: z.array(item),
4
+ total: z.number().int(),
5
+ limit: z.number().int(),
6
+ offset: z.number().int(),
7
+ });
8
+ export const singleEnvelope = (item) => z.object({ data: item });
9
+ export const successEnvelope = z.object({ success: z.boolean() });
10
+ export const pricingCategoryRecordSchema = z.object({
11
+ id: z.string(),
12
+ productId: z.string().nullable(),
13
+ optionId: z.string().nullable(),
14
+ unitId: z.string().nullable(),
15
+ code: z.string().nullable(),
16
+ name: z.string(),
17
+ categoryType: z.enum([
18
+ "adult",
19
+ "child",
20
+ "infant",
21
+ "senior",
22
+ "group",
23
+ "room",
24
+ "vehicle",
25
+ "service",
26
+ "other",
27
+ ]),
28
+ seatOccupancy: z.number().int(),
29
+ groupSize: z.number().int().nullable(),
30
+ isAgeQualified: z.boolean(),
31
+ minAge: z.number().int().nullable(),
32
+ maxAge: z.number().int().nullable(),
33
+ internalUseOnly: z.boolean(),
34
+ active: z.boolean(),
35
+ sortOrder: z.number().int(),
36
+ metadata: z.record(z.string(), z.unknown()).nullable().optional(),
37
+ createdAt: z.string(),
38
+ updatedAt: z.string(),
39
+ });
40
+ export const pricingCategoryDependencyRecordSchema = z.object({
41
+ id: z.string(),
42
+ pricingCategoryId: z.string(),
43
+ masterPricingCategoryId: z.string(),
44
+ dependencyType: z.enum(["requires", "limits_per_master", "limits_sum", "excludes"]),
45
+ maxPerMaster: z.number().int().nullable(),
46
+ maxDependentSum: z.number().int().nullable(),
47
+ active: z.boolean(),
48
+ notes: z.string().nullable(),
49
+ createdAt: z.string(),
50
+ updatedAt: z.string(),
51
+ });
52
+ export const pricingCategoryListResponse = paginatedEnvelope(pricingCategoryRecordSchema);
53
+ export const pricingCategorySingleResponse = singleEnvelope(pricingCategoryRecordSchema);
54
+ export const pricingCategoryDependencyListResponse = paginatedEnvelope(pricingCategoryDependencyRecordSchema);
55
+ export const pricingCategoryDependencySingleResponse = singleEnvelope(pricingCategoryDependencyRecordSchema);
package/package.json ADDED
@@ -0,0 +1,75 @@
1
+ {
2
+ "name": "@voyantjs/pricing-react",
3
+ "version": "0.2.0",
4
+ "license": "FSL-1.1-Apache-2.0",
5
+ "repository": {
6
+ "type": "git",
7
+ "url": "https://github.com/voyantjs/voyant.git",
8
+ "directory": "packages/pricing-react"
9
+ },
10
+ "type": "module",
11
+ "exports": {
12
+ ".": "./src/index.ts",
13
+ "./provider": "./src/provider.tsx",
14
+ "./hooks": "./src/hooks/index.ts",
15
+ "./client": "./src/client.ts",
16
+ "./query-keys": "./src/query-keys.ts"
17
+ },
18
+ "scripts": {
19
+ "build": "tsc -p tsconfig.json",
20
+ "clean": "rm -rf dist",
21
+ "prepack": "pnpm run build",
22
+ "typecheck": "tsc --noEmit",
23
+ "lint": "biome check src/",
24
+ "test": "vitest run --passWithNoTests"
25
+ },
26
+ "peerDependencies": {
27
+ "@voyantjs/pricing": "workspace:*",
28
+ "@tanstack/react-query": "^5.0.0",
29
+ "react": "^19.0.0",
30
+ "react-dom": "^19.0.0",
31
+ "zod": "^4.0.0"
32
+ },
33
+ "devDependencies": {
34
+ "@tanstack/react-query": "^5.96.2",
35
+ "@types/react": "^19.2.14",
36
+ "@types/react-dom": "^19.2.3",
37
+ "@voyantjs/pricing": "workspace:*",
38
+ "@voyantjs/voyant-typescript-config": "workspace:*",
39
+ "react": "^19.2.4",
40
+ "react-dom": "^19.2.4",
41
+ "typescript": "^6.0.2",
42
+ "vitest": "^4.1.2",
43
+ "zod": "^4.3.6"
44
+ },
45
+ "files": [
46
+ "dist"
47
+ ],
48
+ "publishConfig": {
49
+ "access": "public",
50
+ "exports": {
51
+ ".": {
52
+ "types": "./dist/index.d.ts",
53
+ "import": "./dist/index.js"
54
+ },
55
+ "./provider": {
56
+ "types": "./dist/provider.d.ts",
57
+ "import": "./dist/provider.js"
58
+ },
59
+ "./hooks": {
60
+ "types": "./dist/hooks/index.d.ts",
61
+ "import": "./dist/hooks/index.js"
62
+ },
63
+ "./client": {
64
+ "types": "./dist/client.d.ts",
65
+ "import": "./dist/client.js"
66
+ },
67
+ "./query-keys": {
68
+ "types": "./dist/query-keys.d.ts",
69
+ "import": "./dist/query-keys.js"
70
+ }
71
+ },
72
+ "main": "./dist/index.js",
73
+ "types": "./dist/index.d.ts"
74
+ }
75
+ }