@voyantjs/ground-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 (40) 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 +7 -0
  5. package/dist/hooks/index.d.ts.map +1 -0
  6. package/dist/hooks/index.js +6 -0
  7. package/dist/hooks/use-ground-driver-mutation.d.ts +48 -0
  8. package/dist/hooks/use-ground-driver-mutation.d.ts.map +1 -0
  9. package/dist/hooks/use-ground-driver-mutation.js +40 -0
  10. package/dist/hooks/use-ground-drivers.d.ts +23 -0
  11. package/dist/hooks/use-ground-drivers.d.ts.map +1 -0
  12. package/dist/hooks/use-ground-drivers.js +12 -0
  13. package/dist/hooks/use-ground-operator-mutation.d.ts +42 -0
  14. package/dist/hooks/use-ground-operator-mutation.d.ts.map +1 -0
  15. package/dist/hooks/use-ground-operator-mutation.js +40 -0
  16. package/dist/hooks/use-ground-operators.d.ts +21 -0
  17. package/dist/hooks/use-ground-operators.d.ts.map +1 -0
  18. package/dist/hooks/use-ground-operators.js +12 -0
  19. package/dist/hooks/use-ground-vehicle-mutation.d.ts +60 -0
  20. package/dist/hooks/use-ground-vehicle-mutation.d.ts.map +1 -0
  21. package/dist/hooks/use-ground-vehicle-mutation.js +40 -0
  22. package/dist/hooks/use-ground-vehicles.d.ts +27 -0
  23. package/dist/hooks/use-ground-vehicles.d.ts.map +1 -0
  24. package/dist/hooks/use-ground-vehicles.js +12 -0
  25. package/dist/index.d.ts +7 -0
  26. package/dist/index.d.ts.map +1 -0
  27. package/dist/index.js +6 -0
  28. package/dist/provider.d.ts +2 -0
  29. package/dist/provider.d.ts.map +1 -0
  30. package/dist/provider.js +1 -0
  31. package/dist/query-keys.d.ts +35 -0
  32. package/dist/query-keys.d.ts.map +1 -0
  33. package/dist/query-keys.js +12 -0
  34. package/dist/query-options.d.ts +417 -0
  35. package/dist/query-options.d.ts.map +1 -0
  36. package/dist/query-options.js +63 -0
  37. package/dist/schemas.d.ts +212 -0
  38. package/dist/schemas.d.ts.map +1 -0
  39. package/dist/schemas.js +45 -0
  40. package/package.json +79 -0
@@ -0,0 +1,14 @@
1
+ import type { z } from "zod";
2
+ export type VoyantFetcher = (url: string, init?: RequestInit) => Promise<Response>;
3
+ export declare const defaultFetcher: VoyantFetcher;
4
+ export declare class VoyantApiError extends Error {
5
+ readonly status: number;
6
+ readonly body: unknown;
7
+ constructor(message: string, status: number, body: unknown);
8
+ }
9
+ export interface FetchWithValidationOptions {
10
+ baseUrl: string;
11
+ fetcher: VoyantFetcher;
12
+ }
13
+ export declare function fetchWithValidation<TOut>(path: string, schema: z.ZodType<TOut>, options: FetchWithValidationOptions, init?: RequestInit): Promise<TOut>;
14
+ //# sourceMappingURL=client.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAE5B,MAAM,MAAM,aAAa,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,WAAW,KAAK,OAAO,CAAC,QAAQ,CAAC,CAAA;AAElF,eAAO,MAAM,cAAc,EAAE,aACoB,CAAA;AAEjD,qBAAa,cAAe,SAAQ,KAAK;IACvC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;IACvB,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAA;gBAEV,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO;CAM3D;AAaD,MAAM,WAAW,0BAA0B;IACzC,OAAO,EAAE,MAAM,CAAA;IACf,OAAO,EAAE,aAAa,CAAA;CACvB;AAED,wBAAsB,mBAAmB,CAAC,IAAI,EAC5C,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,EACvB,OAAO,EAAE,0BAA0B,EACnC,IAAI,CAAC,EAAE,WAAW,GACjB,OAAO,CAAC,IAAI,CAAC,CA8Bf"}
package/dist/client.js ADDED
@@ -0,0 +1,58 @@
1
+ export const defaultFetcher = (url, init) => fetch(url, { credentials: "include", ...init });
2
+ export class VoyantApiError extends Error {
3
+ status;
4
+ body;
5
+ constructor(message, status, body) {
6
+ super(message);
7
+ this.name = "VoyantApiError";
8
+ this.status = status;
9
+ this.body = body;
10
+ }
11
+ }
12
+ function extractErrorMessage(status, statusText, body) {
13
+ if (typeof body === "object" && body !== null && "error" in body) {
14
+ const err = body.error;
15
+ if (typeof err === "string")
16
+ return err;
17
+ if (typeof err === "object" && err !== null && "message" in err) {
18
+ return String(err.message);
19
+ }
20
+ }
21
+ return `Voyant API error: ${status} ${statusText}`;
22
+ }
23
+ export async function fetchWithValidation(path, schema, options, init) {
24
+ const url = joinUrl(options.baseUrl, path);
25
+ const headers = new Headers(init?.headers);
26
+ if (init?.body !== undefined && !headers.has("Content-Type")) {
27
+ headers.set("Content-Type", "application/json");
28
+ }
29
+ const response = await options.fetcher(url, { ...init, headers });
30
+ if (!response.ok) {
31
+ const body = await safeJson(response);
32
+ throw new VoyantApiError(extractErrorMessage(response.status, response.statusText, body), response.status, body);
33
+ }
34
+ if (response.status === 204)
35
+ return schema.parse(undefined);
36
+ const body = await safeJson(response);
37
+ const parsed = schema.safeParse(body);
38
+ if (!parsed.success) {
39
+ throw new VoyantApiError(`Voyant API response failed validation: ${parsed.error.message}`, response.status, body);
40
+ }
41
+ return parsed.data;
42
+ }
43
+ async function safeJson(response) {
44
+ const text = await response.text();
45
+ if (!text)
46
+ return undefined;
47
+ try {
48
+ return JSON.parse(text);
49
+ }
50
+ catch {
51
+ return text;
52
+ }
53
+ }
54
+ function joinUrl(baseUrl, path) {
55
+ const trimmedBase = baseUrl.endsWith("/") ? baseUrl.slice(0, -1) : baseUrl;
56
+ const trimmedPath = path.startsWith("/") ? path : `/${path}`;
57
+ return `${trimmedBase}${trimmedPath}`;
58
+ }
@@ -0,0 +1,7 @@
1
+ export * from "./use-ground-driver-mutation.js";
2
+ export * from "./use-ground-drivers.js";
3
+ export * from "./use-ground-operator-mutation.js";
4
+ export * from "./use-ground-operators.js";
5
+ export * from "./use-ground-vehicle-mutation.js";
6
+ export * from "./use-ground-vehicles.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,iCAAiC,CAAA;AAC/C,cAAc,yBAAyB,CAAA;AACvC,cAAc,mCAAmC,CAAA;AACjD,cAAc,2BAA2B,CAAA;AACzC,cAAc,kCAAkC,CAAA;AAChD,cAAc,0BAA0B,CAAA"}
@@ -0,0 +1,6 @@
1
+ export * from "./use-ground-driver-mutation.js";
2
+ export * from "./use-ground-drivers.js";
3
+ export * from "./use-ground-operator-mutation.js";
4
+ export * from "./use-ground-operators.js";
5
+ export * from "./use-ground-vehicle-mutation.js";
6
+ export * from "./use-ground-vehicles.js";
@@ -0,0 +1,48 @@
1
+ import type { insertGroundDriverSchema, updateGroundDriverSchema } from "@voyantjs/ground";
2
+ import type { z } from "zod";
3
+ export type CreateGroundDriverInput = z.input<typeof insertGroundDriverSchema>;
4
+ export type UpdateGroundDriverInput = z.input<typeof updateGroundDriverSchema>;
5
+ export declare function useGroundDriverMutation(): {
6
+ create: import("@tanstack/react-query").UseMutationResult<{
7
+ resourceId: string;
8
+ spokenLanguages: string[];
9
+ isGuide: boolean;
10
+ isMeetAndGreetCapable: boolean;
11
+ active: boolean;
12
+ id: string;
13
+ operatorId: string | null;
14
+ licenseNumber: string | null;
15
+ notes: string | null;
16
+ createdAt: string;
17
+ updatedAt: string;
18
+ }, Error, {
19
+ resourceId: string;
20
+ operatorId?: string | null | undefined;
21
+ licenseNumber?: string | null | undefined;
22
+ spokenLanguages?: string[] | undefined;
23
+ isGuide?: boolean | undefined;
24
+ isMeetAndGreetCapable?: boolean | undefined;
25
+ active?: boolean | undefined;
26
+ notes?: string | null | undefined;
27
+ }, unknown>;
28
+ update: import("@tanstack/react-query").UseMutationResult<{
29
+ resourceId: string;
30
+ spokenLanguages: string[];
31
+ isGuide: boolean;
32
+ isMeetAndGreetCapable: boolean;
33
+ active: boolean;
34
+ id: string;
35
+ operatorId: string | null;
36
+ licenseNumber: string | null;
37
+ notes: string | null;
38
+ createdAt: string;
39
+ updatedAt: string;
40
+ }, Error, {
41
+ id: string;
42
+ input: UpdateGroundDriverInput;
43
+ }, unknown>;
44
+ remove: import("@tanstack/react-query").UseMutationResult<{
45
+ success: boolean;
46
+ }, Error, string, unknown>;
47
+ };
48
+ //# sourceMappingURL=use-ground-driver-mutation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-ground-driver-mutation.d.ts","sourceRoot":"","sources":["../../src/hooks/use-ground-driver-mutation.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,wBAAwB,EAAE,wBAAwB,EAAE,MAAM,kBAAkB,CAAA;AAC1F,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAO5B,MAAM,MAAM,uBAAuB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,wBAAwB,CAAC,CAAA;AAC9E,MAAM,MAAM,uBAAuB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,wBAAwB,CAAC,CAAA;AAE9E,wBAAgB,uBAAuB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;YAqBK,MAAM;eAAS,uBAAuB;;;;;EAgCjF"}
@@ -0,0 +1,40 @@
1
+ "use client";
2
+ import { useMutation, useQueryClient } from "@tanstack/react-query";
3
+ import { fetchWithValidation } from "../client.js";
4
+ import { useVoyantGroundContext } from "../provider.js";
5
+ import { groundQueryKeys } from "../query-keys.js";
6
+ import { groundDriverSingleResponse, successEnvelope } from "../schemas.js";
7
+ export function useGroundDriverMutation() {
8
+ const { baseUrl, fetcher } = useVoyantGroundContext();
9
+ const queryClient = useQueryClient();
10
+ const create = useMutation({
11
+ mutationFn: async (input) => {
12
+ const { data } = await fetchWithValidation("/v1/ground/drivers", groundDriverSingleResponse, { baseUrl, fetcher }, { method: "POST", body: JSON.stringify(input) });
13
+ return data;
14
+ },
15
+ onSuccess: (data) => {
16
+ void queryClient.invalidateQueries({ queryKey: groundQueryKeys.drivers() });
17
+ queryClient.setQueryData(groundQueryKeys.driver(data.id), data);
18
+ },
19
+ });
20
+ const update = useMutation({
21
+ mutationFn: async ({ id, input }) => {
22
+ const { data } = await fetchWithValidation(`/v1/ground/drivers/${id}`, groundDriverSingleResponse, { baseUrl, fetcher }, { method: "PATCH", body: JSON.stringify(input) });
23
+ return data;
24
+ },
25
+ onSuccess: (data) => {
26
+ void queryClient.invalidateQueries({ queryKey: groundQueryKeys.drivers() });
27
+ queryClient.setQueryData(groundQueryKeys.driver(data.id), data);
28
+ },
29
+ });
30
+ const remove = useMutation({
31
+ mutationFn: async (id) => fetchWithValidation(`/v1/ground/drivers/${id}`, successEnvelope, { baseUrl, fetcher }, {
32
+ method: "DELETE",
33
+ }),
34
+ onSuccess: (_data, id) => {
35
+ void queryClient.invalidateQueries({ queryKey: groundQueryKeys.drivers() });
36
+ queryClient.removeQueries({ queryKey: groundQueryKeys.driver(id) });
37
+ },
38
+ });
39
+ return { create, update, remove };
40
+ }
@@ -0,0 +1,23 @@
1
+ import type { GroundDriversListFilters } from "../query-keys.js";
2
+ export interface UseGroundDriversOptions extends GroundDriversListFilters {
3
+ enabled?: boolean;
4
+ }
5
+ export declare function useGroundDrivers(options?: UseGroundDriversOptions): import("@tanstack/react-query").UseQueryResult<{
6
+ data: {
7
+ resourceId: string;
8
+ spokenLanguages: string[];
9
+ isGuide: boolean;
10
+ isMeetAndGreetCapable: boolean;
11
+ active: boolean;
12
+ id: string;
13
+ operatorId: string | null;
14
+ licenseNumber: string | null;
15
+ notes: string | null;
16
+ createdAt: string;
17
+ updatedAt: string;
18
+ }[];
19
+ total: number;
20
+ limit: number;
21
+ offset: number;
22
+ }, Error>;
23
+ //# sourceMappingURL=use-ground-drivers.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-ground-drivers.d.ts","sourceRoot":"","sources":["../../src/hooks/use-ground-drivers.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,kBAAkB,CAAA;AAGhE,MAAM,WAAW,uBAAwB,SAAQ,wBAAwB;IACvE,OAAO,CAAC,EAAE,OAAO,CAAA;CAClB;AAED,wBAAgB,gBAAgB,CAAC,OAAO,GAAE,uBAA4B;;;;;;;;;;;;;;;;;UAQrE"}
@@ -0,0 +1,12 @@
1
+ "use client";
2
+ import { useQuery } from "@tanstack/react-query";
3
+ import { useVoyantGroundContext } from "../provider.js";
4
+ import { getGroundDriversQueryOptions } from "../query-options.js";
5
+ export function useGroundDrivers(options = {}) {
6
+ const { baseUrl, fetcher } = useVoyantGroundContext();
7
+ const { enabled = true, ...filters } = options;
8
+ return useQuery({
9
+ ...getGroundDriversQueryOptions({ baseUrl, fetcher }, filters),
10
+ enabled,
11
+ });
12
+ }
@@ -0,0 +1,42 @@
1
+ import type { insertGroundOperatorSchema, updateGroundOperatorSchema } from "@voyantjs/ground";
2
+ import type { z } from "zod";
3
+ export type CreateGroundOperatorInput = z.input<typeof insertGroundOperatorSchema>;
4
+ export type UpdateGroundOperatorInput = z.input<typeof updateGroundOperatorSchema>;
5
+ export declare function useGroundOperatorMutation(): {
6
+ create: import("@tanstack/react-query").UseMutationResult<{
7
+ name: string;
8
+ active: boolean;
9
+ id: string;
10
+ supplierId: string | null;
11
+ facilityId: string | null;
12
+ code: string | null;
13
+ notes: string | null;
14
+ createdAt: string;
15
+ updatedAt: string;
16
+ }, Error, {
17
+ name: string;
18
+ supplierId?: string | null | undefined;
19
+ facilityId?: string | null | undefined;
20
+ code?: string | null | undefined;
21
+ active?: boolean | undefined;
22
+ notes?: string | null | undefined;
23
+ }, unknown>;
24
+ update: import("@tanstack/react-query").UseMutationResult<{
25
+ name: string;
26
+ active: boolean;
27
+ id: string;
28
+ supplierId: string | null;
29
+ facilityId: string | null;
30
+ code: string | null;
31
+ notes: string | null;
32
+ createdAt: string;
33
+ updatedAt: string;
34
+ }, Error, {
35
+ id: string;
36
+ input: UpdateGroundOperatorInput;
37
+ }, unknown>;
38
+ remove: import("@tanstack/react-query").UseMutationResult<{
39
+ success: boolean;
40
+ }, Error, string, unknown>;
41
+ };
42
+ //# sourceMappingURL=use-ground-operator-mutation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-ground-operator-mutation.d.ts","sourceRoot":"","sources":["../../src/hooks/use-ground-operator-mutation.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,0BAA0B,EAAE,0BAA0B,EAAE,MAAM,kBAAkB,CAAA;AAC9F,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAO5B,MAAM,MAAM,yBAAyB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,0BAA0B,CAAC,CAAA;AAClF,MAAM,MAAM,yBAAyB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,0BAA0B,CAAC,CAAA;AAElF,wBAAgB,yBAAyB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;YAqBG,MAAM;eAAS,yBAAyB;;;;;EAgCnF"}
@@ -0,0 +1,40 @@
1
+ "use client";
2
+ import { useMutation, useQueryClient } from "@tanstack/react-query";
3
+ import { fetchWithValidation } from "../client.js";
4
+ import { useVoyantGroundContext } from "../provider.js";
5
+ import { groundQueryKeys } from "../query-keys.js";
6
+ import { groundOperatorSingleResponse, successEnvelope } from "../schemas.js";
7
+ export function useGroundOperatorMutation() {
8
+ const { baseUrl, fetcher } = useVoyantGroundContext();
9
+ const queryClient = useQueryClient();
10
+ const create = useMutation({
11
+ mutationFn: async (input) => {
12
+ const { data } = await fetchWithValidation("/v1/ground/operators", groundOperatorSingleResponse, { baseUrl, fetcher }, { method: "POST", body: JSON.stringify(input) });
13
+ return data;
14
+ },
15
+ onSuccess: (data) => {
16
+ void queryClient.invalidateQueries({ queryKey: groundQueryKeys.operators() });
17
+ queryClient.setQueryData(groundQueryKeys.operator(data.id), data);
18
+ },
19
+ });
20
+ const update = useMutation({
21
+ mutationFn: async ({ id, input }) => {
22
+ const { data } = await fetchWithValidation(`/v1/ground/operators/${id}`, groundOperatorSingleResponse, { baseUrl, fetcher }, { method: "PATCH", body: JSON.stringify(input) });
23
+ return data;
24
+ },
25
+ onSuccess: (data) => {
26
+ void queryClient.invalidateQueries({ queryKey: groundQueryKeys.operators() });
27
+ queryClient.setQueryData(groundQueryKeys.operator(data.id), data);
28
+ },
29
+ });
30
+ const remove = useMutation({
31
+ mutationFn: async (id) => fetchWithValidation(`/v1/ground/operators/${id}`, successEnvelope, { baseUrl, fetcher }, {
32
+ method: "DELETE",
33
+ }),
34
+ onSuccess: (_data, id) => {
35
+ void queryClient.invalidateQueries({ queryKey: groundQueryKeys.operators() });
36
+ queryClient.removeQueries({ queryKey: groundQueryKeys.operator(id) });
37
+ },
38
+ });
39
+ return { create, update, remove };
40
+ }
@@ -0,0 +1,21 @@
1
+ import type { GroundOperatorsListFilters } from "../query-keys.js";
2
+ export interface UseGroundOperatorsOptions extends GroundOperatorsListFilters {
3
+ enabled?: boolean;
4
+ }
5
+ export declare function useGroundOperators(options?: UseGroundOperatorsOptions): import("@tanstack/react-query").UseQueryResult<{
6
+ data: {
7
+ name: string;
8
+ active: boolean;
9
+ id: string;
10
+ supplierId: string | null;
11
+ facilityId: string | null;
12
+ code: string | null;
13
+ notes: string | null;
14
+ createdAt: string;
15
+ updatedAt: string;
16
+ }[];
17
+ total: number;
18
+ limit: number;
19
+ offset: number;
20
+ }, Error>;
21
+ //# sourceMappingURL=use-ground-operators.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-ground-operators.d.ts","sourceRoot":"","sources":["../../src/hooks/use-ground-operators.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,kBAAkB,CAAA;AAGlE,MAAM,WAAW,yBAA0B,SAAQ,0BAA0B;IAC3E,OAAO,CAAC,EAAE,OAAO,CAAA;CAClB;AAED,wBAAgB,kBAAkB,CAAC,OAAO,GAAE,yBAA8B;;;;;;;;;;;;;;;UAQzE"}
@@ -0,0 +1,12 @@
1
+ "use client";
2
+ import { useQuery } from "@tanstack/react-query";
3
+ import { useVoyantGroundContext } from "../provider.js";
4
+ import { getGroundOperatorsQueryOptions } from "../query-options.js";
5
+ export function useGroundOperators(options = {}) {
6
+ const { baseUrl, fetcher } = useVoyantGroundContext();
7
+ const { enabled = true, ...filters } = options;
8
+ return useQuery({
9
+ ...getGroundOperatorsQueryOptions({ baseUrl, fetcher }, filters),
10
+ enabled,
11
+ });
12
+ }
@@ -0,0 +1,60 @@
1
+ import type { insertGroundVehicleSchema, updateGroundVehicleSchema } from "@voyantjs/ground";
2
+ import type { z } from "zod";
3
+ export type CreateGroundVehicleInput = z.input<typeof insertGroundVehicleSchema>;
4
+ export type UpdateGroundVehicleInput = z.input<typeof updateGroundVehicleSchema>;
5
+ export declare function useGroundVehicleMutation(): {
6
+ create: import("@tanstack/react-query").UseMutationResult<{
7
+ resourceId: string;
8
+ category: "other" | "car" | "sedan" | "suv" | "van" | "minibus" | "bus" | "boat" | "train";
9
+ vehicleClass: "other" | "economy" | "standard" | "premium" | "luxury" | "accessible";
10
+ isAccessible: boolean;
11
+ active: boolean;
12
+ id: string;
13
+ operatorId: string | null;
14
+ passengerCapacity: number | null;
15
+ checkedBagCapacity: number | null;
16
+ carryOnCapacity: number | null;
17
+ wheelchairCapacity: number | null;
18
+ childSeatCapacity: number | null;
19
+ notes: string | null;
20
+ createdAt: string;
21
+ updatedAt: string;
22
+ }, Error, {
23
+ resourceId: string;
24
+ operatorId?: string | null | undefined;
25
+ category?: "other" | "car" | "sedan" | "suv" | "van" | "minibus" | "bus" | "boat" | "train" | undefined;
26
+ vehicleClass?: "other" | "economy" | "standard" | "premium" | "luxury" | "accessible" | undefined;
27
+ passengerCapacity?: number | null | undefined;
28
+ checkedBagCapacity?: number | null | undefined;
29
+ carryOnCapacity?: number | null | undefined;
30
+ wheelchairCapacity?: number | null | undefined;
31
+ childSeatCapacity?: number | null | undefined;
32
+ isAccessible?: boolean | undefined;
33
+ active?: boolean | undefined;
34
+ notes?: string | null | undefined;
35
+ }, unknown>;
36
+ update: import("@tanstack/react-query").UseMutationResult<{
37
+ resourceId: string;
38
+ category: "other" | "car" | "sedan" | "suv" | "van" | "minibus" | "bus" | "boat" | "train";
39
+ vehicleClass: "other" | "economy" | "standard" | "premium" | "luxury" | "accessible";
40
+ isAccessible: boolean;
41
+ active: boolean;
42
+ id: string;
43
+ operatorId: string | null;
44
+ passengerCapacity: number | null;
45
+ checkedBagCapacity: number | null;
46
+ carryOnCapacity: number | null;
47
+ wheelchairCapacity: number | null;
48
+ childSeatCapacity: number | null;
49
+ notes: string | null;
50
+ createdAt: string;
51
+ updatedAt: string;
52
+ }, Error, {
53
+ id: string;
54
+ input: UpdateGroundVehicleInput;
55
+ }, unknown>;
56
+ remove: import("@tanstack/react-query").UseMutationResult<{
57
+ success: boolean;
58
+ }, Error, string, unknown>;
59
+ };
60
+ //# sourceMappingURL=use-ground-vehicle-mutation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-ground-vehicle-mutation.d.ts","sourceRoot":"","sources":["../../src/hooks/use-ground-vehicle-mutation.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,yBAAyB,EAAE,yBAAyB,EAAE,MAAM,kBAAkB,CAAA;AAC5F,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAO5B,MAAM,MAAM,wBAAwB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,yBAAyB,CAAC,CAAA;AAChF,MAAM,MAAM,wBAAwB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,yBAAyB,CAAC,CAAA;AAEhF,wBAAgB,wBAAwB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;YAqBI,MAAM;eAAS,wBAAwB;;;;;EAgClF"}
@@ -0,0 +1,40 @@
1
+ "use client";
2
+ import { useMutation, useQueryClient } from "@tanstack/react-query";
3
+ import { fetchWithValidation } from "../client.js";
4
+ import { useVoyantGroundContext } from "../provider.js";
5
+ import { groundQueryKeys } from "../query-keys.js";
6
+ import { groundVehicleSingleResponse, successEnvelope } from "../schemas.js";
7
+ export function useGroundVehicleMutation() {
8
+ const { baseUrl, fetcher } = useVoyantGroundContext();
9
+ const queryClient = useQueryClient();
10
+ const create = useMutation({
11
+ mutationFn: async (input) => {
12
+ const { data } = await fetchWithValidation("/v1/ground/vehicles", groundVehicleSingleResponse, { baseUrl, fetcher }, { method: "POST", body: JSON.stringify(input) });
13
+ return data;
14
+ },
15
+ onSuccess: (data) => {
16
+ void queryClient.invalidateQueries({ queryKey: groundQueryKeys.vehicles() });
17
+ queryClient.setQueryData(groundQueryKeys.vehicle(data.id), data);
18
+ },
19
+ });
20
+ const update = useMutation({
21
+ mutationFn: async ({ id, input }) => {
22
+ const { data } = await fetchWithValidation(`/v1/ground/vehicles/${id}`, groundVehicleSingleResponse, { baseUrl, fetcher }, { method: "PATCH", body: JSON.stringify(input) });
23
+ return data;
24
+ },
25
+ onSuccess: (data) => {
26
+ void queryClient.invalidateQueries({ queryKey: groundQueryKeys.vehicles() });
27
+ queryClient.setQueryData(groundQueryKeys.vehicle(data.id), data);
28
+ },
29
+ });
30
+ const remove = useMutation({
31
+ mutationFn: async (id) => fetchWithValidation(`/v1/ground/vehicles/${id}`, successEnvelope, { baseUrl, fetcher }, {
32
+ method: "DELETE",
33
+ }),
34
+ onSuccess: (_data, id) => {
35
+ void queryClient.invalidateQueries({ queryKey: groundQueryKeys.vehicles() });
36
+ queryClient.removeQueries({ queryKey: groundQueryKeys.vehicle(id) });
37
+ },
38
+ });
39
+ return { create, update, remove };
40
+ }
@@ -0,0 +1,27 @@
1
+ import type { GroundVehiclesListFilters } from "../query-keys.js";
2
+ export interface UseGroundVehiclesOptions extends GroundVehiclesListFilters {
3
+ enabled?: boolean;
4
+ }
5
+ export declare function useGroundVehicles(options?: UseGroundVehiclesOptions): import("@tanstack/react-query").UseQueryResult<{
6
+ data: {
7
+ resourceId: string;
8
+ category: "other" | "car" | "sedan" | "suv" | "van" | "minibus" | "bus" | "boat" | "train";
9
+ vehicleClass: "other" | "economy" | "standard" | "premium" | "luxury" | "accessible";
10
+ isAccessible: boolean;
11
+ active: boolean;
12
+ id: string;
13
+ operatorId: string | null;
14
+ passengerCapacity: number | null;
15
+ checkedBagCapacity: number | null;
16
+ carryOnCapacity: number | null;
17
+ wheelchairCapacity: number | null;
18
+ childSeatCapacity: number | null;
19
+ notes: string | null;
20
+ createdAt: string;
21
+ updatedAt: string;
22
+ }[];
23
+ total: number;
24
+ limit: number;
25
+ offset: number;
26
+ }, Error>;
27
+ //# sourceMappingURL=use-ground-vehicles.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-ground-vehicles.d.ts","sourceRoot":"","sources":["../../src/hooks/use-ground-vehicles.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,kBAAkB,CAAA;AAGjE,MAAM,WAAW,wBAAyB,SAAQ,yBAAyB;IACzE,OAAO,CAAC,EAAE,OAAO,CAAA;CAClB;AAED,wBAAgB,iBAAiB,CAAC,OAAO,GAAE,wBAA6B;;;;;;;;;;;;;;;;;;;;;UAQvE"}
@@ -0,0 +1,12 @@
1
+ "use client";
2
+ import { useQuery } from "@tanstack/react-query";
3
+ import { useVoyantGroundContext } from "../provider.js";
4
+ import { getGroundVehiclesQueryOptions } from "../query-options.js";
5
+ export function useGroundVehicles(options = {}) {
6
+ const { baseUrl, fetcher } = useVoyantGroundContext();
7
+ const { enabled = true, ...filters } = options;
8
+ return useQuery({
9
+ ...getGroundVehiclesQueryOptions({ baseUrl, fetcher }, filters),
10
+ enabled,
11
+ });
12
+ }
@@ -0,0 +1,7 @@
1
+ export { defaultFetcher, fetchWithValidation, VoyantApiError, type VoyantFetcher, } from "./client.js";
2
+ export * from "./hooks/index.js";
3
+ export { useVoyantGroundContext, type VoyantGroundContextValue, VoyantGroundProvider, type VoyantGroundProviderProps, } from "./provider.js";
4
+ export { type GroundDriversListFilters, type GroundOperatorsListFilters, type GroundVehiclesListFilters, groundQueryKeys, } from "./query-keys.js";
5
+ export { getGroundDriverQueryOptions, getGroundDriversQueryOptions, getGroundOperatorQueryOptions, getGroundOperatorsQueryOptions, getGroundVehicleQueryOptions, getGroundVehiclesQueryOptions, } 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,mBAAmB,EACnB,cAAc,EACd,KAAK,aAAa,GACnB,MAAM,aAAa,CAAA;AACpB,cAAc,kBAAkB,CAAA;AAChC,OAAO,EACL,sBAAsB,EACtB,KAAK,wBAAwB,EAC7B,oBAAoB,EACpB,KAAK,yBAAyB,GAC/B,MAAM,eAAe,CAAA;AACtB,OAAO,EACL,KAAK,wBAAwB,EAC7B,KAAK,0BAA0B,EAC/B,KAAK,yBAAyB,EAC9B,eAAe,GAChB,MAAM,iBAAiB,CAAA;AACxB,OAAO,EACL,2BAA2B,EAC3B,4BAA4B,EAC5B,6BAA6B,EAC7B,8BAA8B,EAC9B,4BAA4B,EAC5B,6BAA6B,GAC9B,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 { useVoyantGroundContext, VoyantGroundProvider, } from "./provider.js";
4
+ export { groundQueryKeys, } from "./query-keys.js";
5
+ export { getGroundDriverQueryOptions, getGroundDriversQueryOptions, getGroundOperatorQueryOptions, getGroundOperatorsQueryOptions, getGroundVehicleQueryOptions, getGroundVehiclesQueryOptions, } from "./query-options.js";
6
+ export * from "./schemas.js";
@@ -0,0 +1,2 @@
1
+ export { useVoyantReactContext as useVoyantGroundContext, type VoyantReactContextValue as VoyantGroundContextValue, VoyantReactProvider as VoyantGroundProvider, type VoyantReactProviderProps as VoyantGroundProviderProps, } 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,sBAAsB,EAC/C,KAAK,uBAAuB,IAAI,wBAAwB,EACxD,mBAAmB,IAAI,oBAAoB,EAC3C,KAAK,wBAAwB,IAAI,yBAAyB,GAC3D,MAAM,iBAAiB,CAAA"}
@@ -0,0 +1 @@
1
+ export { useVoyantReactContext as useVoyantGroundContext, VoyantReactProvider as VoyantGroundProvider, } from "@voyantjs/react";
@@ -0,0 +1,35 @@
1
+ export interface GroundOperatorsListFilters {
2
+ supplierId?: string | undefined;
3
+ facilityId?: string | undefined;
4
+ active?: boolean | undefined;
5
+ limit?: number | undefined;
6
+ offset?: number | undefined;
7
+ }
8
+ export interface GroundVehiclesListFilters {
9
+ resourceId?: string | undefined;
10
+ operatorId?: string | undefined;
11
+ category?: string | undefined;
12
+ active?: boolean | undefined;
13
+ limit?: number | undefined;
14
+ offset?: number | undefined;
15
+ }
16
+ export interface GroundDriversListFilters {
17
+ resourceId?: string | undefined;
18
+ operatorId?: string | undefined;
19
+ active?: boolean | undefined;
20
+ limit?: number | undefined;
21
+ offset?: number | undefined;
22
+ }
23
+ export declare const groundQueryKeys: {
24
+ all: readonly ["ground"];
25
+ operators: () => readonly ["ground", "operators"];
26
+ operatorsList: (filters: GroundOperatorsListFilters) => readonly ["ground", "operators", GroundOperatorsListFilters];
27
+ operator: (id: string) => readonly ["ground", "operators", string];
28
+ vehicles: () => readonly ["ground", "vehicles"];
29
+ vehiclesList: (filters: GroundVehiclesListFilters) => readonly ["ground", "vehicles", GroundVehiclesListFilters];
30
+ vehicle: (id: string) => readonly ["ground", "vehicles", string];
31
+ drivers: () => readonly ["ground", "drivers"];
32
+ driversList: (filters: GroundDriversListFilters) => readonly ["ground", "drivers", GroundDriversListFilters];
33
+ driver: (id: string) => readonly ["ground", "drivers", string];
34
+ };
35
+ //# 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,0BAA0B;IACzC,UAAU,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;IAC/B,UAAU,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;IAC/B,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,yBAAyB;IACxC,UAAU,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;IAC/B,UAAU,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;IAC/B,QAAQ,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;IAC7B,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,wBAAwB;IACvC,UAAU,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;IAC/B,UAAU,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;IAC/B,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,eAAe;;;6BAGD,0BAA0B;mBAEpC,MAAM;;4BAEG,yBAAyB;kBAEnC,MAAM;;2BAEG,wBAAwB;iBAElC,MAAM;CACpB,CAAA"}
@@ -0,0 +1,12 @@
1
+ export const groundQueryKeys = {
2
+ all: ["ground"],
3
+ operators: () => [...groundQueryKeys.all, "operators"],
4
+ operatorsList: (filters) => [...groundQueryKeys.operators(), filters],
5
+ operator: (id) => [...groundQueryKeys.operators(), id],
6
+ vehicles: () => [...groundQueryKeys.all, "vehicles"],
7
+ vehiclesList: (filters) => [...groundQueryKeys.vehicles(), filters],
8
+ vehicle: (id) => [...groundQueryKeys.vehicles(), id],
9
+ drivers: () => [...groundQueryKeys.all, "drivers"],
10
+ driversList: (filters) => [...groundQueryKeys.drivers(), filters],
11
+ driver: (id) => [...groundQueryKeys.drivers(), id],
12
+ };