@voyantjs/distribution-react 0.1.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.
- package/README.md +32 -0
- package/dist/client.d.ts +14 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +59 -0
- package/dist/constants.d.ts +100 -0
- package/dist/constants.d.ts.map +1 -0
- package/dist/constants.js +47 -0
- package/dist/hooks/index.d.ts +12 -0
- package/dist/hooks/index.d.ts.map +1 -0
- package/dist/hooks/index.js +12 -0
- package/dist/hooks/use-booking-links.d.ts +20 -0
- package/dist/hooks/use-booking-links.d.ts.map +1 -0
- package/dist/hooks/use-booking-links.js +9 -0
- package/dist/hooks/use-bookings.d.ts +14 -0
- package/dist/hooks/use-bookings.d.ts.map +1 -0
- package/dist/hooks/use-bookings.js +9 -0
- package/dist/hooks/use-channel-mutation.d.ts +68 -0
- package/dist/hooks/use-channel-mutation.d.ts.map +1 -0
- package/dist/hooks/use-channel-mutation.js +49 -0
- package/dist/hooks/use-channel.d.ts +16 -0
- package/dist/hooks/use-channel.d.ts.map +1 -0
- package/dist/hooks/use-channel.js +13 -0
- package/dist/hooks/use-channels.d.ts +20 -0
- package/dist/hooks/use-channels.d.ts.map +1 -0
- package/dist/hooks/use-channels.js +9 -0
- package/dist/hooks/use-commission-rules.d.ts +23 -0
- package/dist/hooks/use-commission-rules.d.ts.map +1 -0
- package/dist/hooks/use-commission-rules.js +9 -0
- package/dist/hooks/use-contracts.d.ts +22 -0
- package/dist/hooks/use-contracts.d.ts.map +1 -0
- package/dist/hooks/use-contracts.js +9 -0
- package/dist/hooks/use-mappings.d.ts +19 -0
- package/dist/hooks/use-mappings.d.ts.map +1 -0
- package/dist/hooks/use-mappings.js +9 -0
- package/dist/hooks/use-products.d.ts +14 -0
- package/dist/hooks/use-products.d.ts.map +1 -0
- package/dist/hooks/use-products.js +9 -0
- package/dist/hooks/use-suppliers.d.ts +14 -0
- package/dist/hooks/use-suppliers.d.ts.map +1 -0
- package/dist/hooks/use-suppliers.js +9 -0
- package/dist/hooks/use-webhook-events.d.ts +21 -0
- package/dist/hooks/use-webhook-events.d.ts.map +1 -0
- package/dist/hooks/use-webhook-events.js +9 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +8 -0
- package/dist/provider.d.ts +2 -0
- package/dist/provider.d.ts.map +1 -0
- package/dist/provider.js +1 -0
- package/dist/query-keys.d.ts +61 -0
- package/dist/query-keys.d.ts.map +1 -0
- package/dist/query-keys.js +30 -0
- package/dist/query-options.d.ts +999 -0
- package/dist/query-options.d.ts.map +1 -0
- package/dist/query-options.js +219 -0
- package/dist/schemas.d.ts +610 -0
- package/dist/schemas.d.ts.map +1 -0
- package/dist/schemas.js +143 -0
- package/dist/utils.d.ts +10 -0
- package/dist/utils.d.ts.map +1 -0
- package/dist/utils.js +44 -0
- package/package.json +79 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"query-options.d.ts","sourceRoot":"","sources":["../src/query-options.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,0BAA0B,EAAuB,MAAM,aAAa,CAAA;AAClF,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,8BAA8B,CAAA;AAC1E,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAA;AACjE,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAA;AACjE,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,iCAAiC,CAAA;AAChF,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAA;AACnE,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAA;AACjE,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAA;AACjE,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAA;AACnE,OAAO,KAAK,EAAE,uBAAuB,EAAE,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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAa9B;AAED,wBAAgB,4BAA4B,CAC1C,MAAM,EAAE,0BAA0B,EAClC,OAAO,GAAE,uBAA4B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAiBtC;AAED,wBAAgB,2BAA2B,CACzC,MAAM,EAAE,0BAA0B,EAClC,EAAE,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAa9B"}
|
|
@@ -0,0 +1,219 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { queryOptions } from "@tanstack/react-query";
|
|
3
|
+
import { fetchWithValidation } from "./client.js";
|
|
4
|
+
import { distributionQueryKeys } from "./query-keys.js";
|
|
5
|
+
import { bookingListResponse, bookingSingleResponse, channelBookingLinkListResponse, channelBookingLinkSingleResponse, channelCommissionRuleListResponse, channelCommissionRuleSingleResponse, channelContractListResponse, channelContractSingleResponse, channelListResponse, channelProductMappingListResponse, channelProductMappingSingleResponse, channelSingleResponse, channelWebhookEventListResponse, channelWebhookEventSingleResponse, productListResponse, productSingleResponse, supplierListResponse, supplierSingleResponse, } from "./schemas.js";
|
|
6
|
+
function appendPagination(params, filters) {
|
|
7
|
+
if (filters.limit !== undefined)
|
|
8
|
+
params.set("limit", String(filters.limit));
|
|
9
|
+
if (filters.offset !== undefined)
|
|
10
|
+
params.set("offset", String(filters.offset));
|
|
11
|
+
}
|
|
12
|
+
export function getSuppliersQueryOptions(client, options = {}) {
|
|
13
|
+
const { enabled: _enabled = true, ...filters } = options;
|
|
14
|
+
return queryOptions({
|
|
15
|
+
queryKey: distributionQueryKeys.suppliersList(filters),
|
|
16
|
+
queryFn: () => {
|
|
17
|
+
const params = new URLSearchParams();
|
|
18
|
+
appendPagination(params, filters);
|
|
19
|
+
const qs = params.toString();
|
|
20
|
+
return fetchWithValidation(`/v1/suppliers${qs ? `?${qs}` : ""}`, supplierListResponse, client);
|
|
21
|
+
},
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
export function getSupplierQueryOptions(client, id) {
|
|
25
|
+
return queryOptions({
|
|
26
|
+
queryKey: distributionQueryKeys.supplier(id ?? ""),
|
|
27
|
+
queryFn: async () => {
|
|
28
|
+
if (!id)
|
|
29
|
+
throw new Error("getSupplierQueryOptions requires an id");
|
|
30
|
+
return fetchWithValidation(`/v1/suppliers/${id}`, supplierSingleResponse, client);
|
|
31
|
+
},
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
export function getProductsQueryOptions(client, options = {}) {
|
|
35
|
+
const { enabled: _enabled = true, ...filters } = options;
|
|
36
|
+
return queryOptions({
|
|
37
|
+
queryKey: distributionQueryKeys.productsList(filters),
|
|
38
|
+
queryFn: () => {
|
|
39
|
+
const params = new URLSearchParams();
|
|
40
|
+
appendPagination(params, filters);
|
|
41
|
+
const qs = params.toString();
|
|
42
|
+
return fetchWithValidation(`/v1/products${qs ? `?${qs}` : ""}`, productListResponse, client);
|
|
43
|
+
},
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
export function getProductQueryOptions(client, id) {
|
|
47
|
+
return queryOptions({
|
|
48
|
+
queryKey: distributionQueryKeys.product(id ?? ""),
|
|
49
|
+
queryFn: async () => {
|
|
50
|
+
if (!id)
|
|
51
|
+
throw new Error("getProductQueryOptions requires an id");
|
|
52
|
+
return fetchWithValidation(`/v1/products/${id}`, productSingleResponse, client);
|
|
53
|
+
},
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
export function getBookingsQueryOptions(client, options = {}) {
|
|
57
|
+
const { enabled: _enabled = true, ...filters } = options;
|
|
58
|
+
return queryOptions({
|
|
59
|
+
queryKey: distributionQueryKeys.bookingsList(filters),
|
|
60
|
+
queryFn: () => {
|
|
61
|
+
const params = new URLSearchParams();
|
|
62
|
+
appendPagination(params, filters);
|
|
63
|
+
const qs = params.toString();
|
|
64
|
+
return fetchWithValidation(`/v1/bookings${qs ? `?${qs}` : ""}`, bookingListResponse, client);
|
|
65
|
+
},
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
export function getBookingQueryOptions(client, id) {
|
|
69
|
+
return queryOptions({
|
|
70
|
+
queryKey: distributionQueryKeys.booking(id ?? ""),
|
|
71
|
+
queryFn: async () => {
|
|
72
|
+
if (!id)
|
|
73
|
+
throw new Error("getBookingQueryOptions requires an id");
|
|
74
|
+
return fetchWithValidation(`/v1/bookings/${id}`, bookingSingleResponse, client);
|
|
75
|
+
},
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
export function getChannelsQueryOptions(client, options = {}) {
|
|
79
|
+
const { enabled: _enabled = true, ...filters } = options;
|
|
80
|
+
return queryOptions({
|
|
81
|
+
queryKey: distributionQueryKeys.channelsList(filters),
|
|
82
|
+
queryFn: () => {
|
|
83
|
+
const params = new URLSearchParams();
|
|
84
|
+
appendPagination(params, filters);
|
|
85
|
+
const qs = params.toString();
|
|
86
|
+
return fetchWithValidation(`/v1/distribution/channels${qs ? `?${qs}` : ""}`, channelListResponse, client);
|
|
87
|
+
},
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
export function getChannelQueryOptions(client, id) {
|
|
91
|
+
return queryOptions({
|
|
92
|
+
queryKey: distributionQueryKeys.channel(id ?? ""),
|
|
93
|
+
queryFn: async () => {
|
|
94
|
+
if (!id)
|
|
95
|
+
throw new Error("getChannelQueryOptions requires an id");
|
|
96
|
+
return fetchWithValidation(`/v1/distribution/channels/${id}`, channelSingleResponse, client);
|
|
97
|
+
},
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
export function getContractsQueryOptions(client, options = {}) {
|
|
101
|
+
const { enabled: _enabled = true, ...filters } = options;
|
|
102
|
+
return queryOptions({
|
|
103
|
+
queryKey: distributionQueryKeys.contractsList(filters),
|
|
104
|
+
queryFn: () => {
|
|
105
|
+
const params = new URLSearchParams();
|
|
106
|
+
if ("channelId" in filters && filters.channelId)
|
|
107
|
+
params.set("channelId", filters.channelId);
|
|
108
|
+
appendPagination(params, filters);
|
|
109
|
+
const qs = params.toString();
|
|
110
|
+
return fetchWithValidation(`/v1/distribution/contracts${qs ? `?${qs}` : ""}`, channelContractListResponse, client);
|
|
111
|
+
},
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
export function getContractQueryOptions(client, id) {
|
|
115
|
+
return queryOptions({
|
|
116
|
+
queryKey: distributionQueryKeys.contract(id ?? ""),
|
|
117
|
+
queryFn: async () => {
|
|
118
|
+
if (!id)
|
|
119
|
+
throw new Error("getContractQueryOptions requires an id");
|
|
120
|
+
return fetchWithValidation(`/v1/distribution/contracts/${id}`, channelContractSingleResponse, client);
|
|
121
|
+
},
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
export function getCommissionRulesQueryOptions(client, options = {}) {
|
|
125
|
+
const { enabled: _enabled = true, ...filters } = options;
|
|
126
|
+
return queryOptions({
|
|
127
|
+
queryKey: distributionQueryKeys.commissionRulesList(filters),
|
|
128
|
+
queryFn: () => {
|
|
129
|
+
const params = new URLSearchParams();
|
|
130
|
+
if (filters.contractId)
|
|
131
|
+
params.set("contractId", filters.contractId);
|
|
132
|
+
appendPagination(params, filters);
|
|
133
|
+
const qs = params.toString();
|
|
134
|
+
return fetchWithValidation(`/v1/distribution/commission-rules${qs ? `?${qs}` : ""}`, channelCommissionRuleListResponse, client);
|
|
135
|
+
},
|
|
136
|
+
});
|
|
137
|
+
}
|
|
138
|
+
export function getCommissionRuleQueryOptions(client, id) {
|
|
139
|
+
return queryOptions({
|
|
140
|
+
queryKey: distributionQueryKeys.commissionRule(id ?? ""),
|
|
141
|
+
queryFn: async () => {
|
|
142
|
+
if (!id)
|
|
143
|
+
throw new Error("getCommissionRuleQueryOptions requires an id");
|
|
144
|
+
return fetchWithValidation(`/v1/distribution/commission-rules/${id}`, channelCommissionRuleSingleResponse, client);
|
|
145
|
+
},
|
|
146
|
+
});
|
|
147
|
+
}
|
|
148
|
+
export function getMappingsQueryOptions(client, options = {}) {
|
|
149
|
+
const { enabled: _enabled = true, ...filters } = options;
|
|
150
|
+
return queryOptions({
|
|
151
|
+
queryKey: distributionQueryKeys.mappingsList(filters),
|
|
152
|
+
queryFn: () => {
|
|
153
|
+
const params = new URLSearchParams();
|
|
154
|
+
if (filters.channelId)
|
|
155
|
+
params.set("channelId", filters.channelId);
|
|
156
|
+
appendPagination(params, filters);
|
|
157
|
+
const qs = params.toString();
|
|
158
|
+
return fetchWithValidation(`/v1/distribution/product-mappings${qs ? `?${qs}` : ""}`, channelProductMappingListResponse, client);
|
|
159
|
+
},
|
|
160
|
+
});
|
|
161
|
+
}
|
|
162
|
+
export function getMappingQueryOptions(client, id) {
|
|
163
|
+
return queryOptions({
|
|
164
|
+
queryKey: distributionQueryKeys.mapping(id ?? ""),
|
|
165
|
+
queryFn: async () => {
|
|
166
|
+
if (!id)
|
|
167
|
+
throw new Error("getMappingQueryOptions requires an id");
|
|
168
|
+
return fetchWithValidation(`/v1/distribution/product-mappings/${id}`, channelProductMappingSingleResponse, client);
|
|
169
|
+
},
|
|
170
|
+
});
|
|
171
|
+
}
|
|
172
|
+
export function getBookingLinksQueryOptions(client, options = {}) {
|
|
173
|
+
const { enabled: _enabled = true, ...filters } = options;
|
|
174
|
+
return queryOptions({
|
|
175
|
+
queryKey: distributionQueryKeys.bookingLinksList(filters),
|
|
176
|
+
queryFn: () => {
|
|
177
|
+
const params = new URLSearchParams();
|
|
178
|
+
if (filters.channelId)
|
|
179
|
+
params.set("channelId", filters.channelId);
|
|
180
|
+
appendPagination(params, filters);
|
|
181
|
+
const qs = params.toString();
|
|
182
|
+
return fetchWithValidation(`/v1/distribution/booking-links${qs ? `?${qs}` : ""}`, channelBookingLinkListResponse, client);
|
|
183
|
+
},
|
|
184
|
+
});
|
|
185
|
+
}
|
|
186
|
+
export function getBookingLinkQueryOptions(client, id) {
|
|
187
|
+
return queryOptions({
|
|
188
|
+
queryKey: distributionQueryKeys.bookingLink(id ?? ""),
|
|
189
|
+
queryFn: async () => {
|
|
190
|
+
if (!id)
|
|
191
|
+
throw new Error("getBookingLinkQueryOptions requires an id");
|
|
192
|
+
return fetchWithValidation(`/v1/distribution/booking-links/${id}`, channelBookingLinkSingleResponse, client);
|
|
193
|
+
},
|
|
194
|
+
});
|
|
195
|
+
}
|
|
196
|
+
export function getWebhookEventsQueryOptions(client, options = {}) {
|
|
197
|
+
const { enabled: _enabled = true, ...filters } = options;
|
|
198
|
+
return queryOptions({
|
|
199
|
+
queryKey: distributionQueryKeys.webhookEventsList(filters),
|
|
200
|
+
queryFn: () => {
|
|
201
|
+
const params = new URLSearchParams();
|
|
202
|
+
if (filters.channelId)
|
|
203
|
+
params.set("channelId", filters.channelId);
|
|
204
|
+
appendPagination(params, filters);
|
|
205
|
+
const qs = params.toString();
|
|
206
|
+
return fetchWithValidation(`/v1/distribution/webhook-events${qs ? `?${qs}` : ""}`, channelWebhookEventListResponse, client);
|
|
207
|
+
},
|
|
208
|
+
});
|
|
209
|
+
}
|
|
210
|
+
export function getWebhookEventQueryOptions(client, id) {
|
|
211
|
+
return queryOptions({
|
|
212
|
+
queryKey: distributionQueryKeys.webhookEvent(id ?? ""),
|
|
213
|
+
queryFn: async () => {
|
|
214
|
+
if (!id)
|
|
215
|
+
throw new Error("getWebhookEventQueryOptions requires an id");
|
|
216
|
+
return fetchWithValidation(`/v1/distribution/webhook-events/${id}`, channelWebhookEventSingleResponse, client);
|
|
217
|
+
},
|
|
218
|
+
});
|
|
219
|
+
}
|