@voyantjs/markets-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.
- package/dist/client.d.ts +14 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +58 -0
- package/dist/hooks/index.d.ts +8 -0
- package/dist/hooks/index.d.ts.map +1 -0
- package/dist/hooks/index.js +7 -0
- package/dist/hooks/use-market-currencies.d.ts +20 -0
- package/dist/hooks/use-market-currencies.d.ts.map +1 -0
- package/dist/hooks/use-market-currencies.js +12 -0
- package/dist/hooks/use-market-currency-mutation.d.ts +36 -0
- package/dist/hooks/use-market-currency-mutation.d.ts.map +1 -0
- package/dist/hooks/use-market-currency-mutation.js +40 -0
- package/dist/hooks/use-market-locale-mutation.d.ts +32 -0
- package/dist/hooks/use-market-locale-mutation.d.ts.map +1 -0
- package/dist/hooks/use-market-locale-mutation.js +40 -0
- package/dist/hooks/use-market-locales.d.ts +18 -0
- package/dist/hooks/use-market-locales.d.ts.map +1 -0
- package/dist/hooks/use-market-locales.js +12 -0
- package/dist/hooks/use-market-mutation.d.ts +50 -0
- package/dist/hooks/use-market-mutation.d.ts.map +1 -0
- package/dist/hooks/use-market-mutation.js +42 -0
- package/dist/hooks/use-market.d.ts +17 -0
- package/dist/hooks/use-market.d.ts.map +1 -0
- package/dist/hooks/use-market.js +12 -0
- package/dist/hooks/use-markets.d.ts +23 -0
- package/dist/hooks/use-markets.d.ts.map +1 -0
- package/dist/hooks/use-markets.js +12 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +6 -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 +34 -0
- package/dist/query-keys.d.ts.map +1 -0
- package/dist/query-keys.js +12 -0
- package/dist/query-options.d.ts +337 -0
- package/dist/query-options.d.ts.map +1 -0
- package/dist/query-options.js +71 -0
- package/dist/schemas.d.ts +143 -0
- package/dist/schemas.d.ts.map +1 -0
- package/dist/schemas.js +32 -0
- package/package.json +79 -0
|
@@ -0,0 +1,337 @@
|
|
|
1
|
+
import { type FetchWithValidationOptions } from "./client.js";
|
|
2
|
+
import type { UseMarketCurrenciesOptions } from "./hooks/use-market-currencies.js";
|
|
3
|
+
import type { UseMarketLocalesOptions } from "./hooks/use-market-locales.js";
|
|
4
|
+
import type { UseMarketsOptions } from "./hooks/use-markets.js";
|
|
5
|
+
export declare function getMarketsQueryOptions(client: FetchWithValidationOptions, options?: UseMarketsOptions): import("@tanstack/react-query").OmitKeyof<import("@tanstack/react-query").UseQueryOptions<{
|
|
6
|
+
data: {
|
|
7
|
+
code: string;
|
|
8
|
+
name: string;
|
|
9
|
+
status: "active" | "inactive" | "archived";
|
|
10
|
+
defaultLanguageTag: string;
|
|
11
|
+
defaultCurrency: string;
|
|
12
|
+
id: string;
|
|
13
|
+
regionCode: string | null;
|
|
14
|
+
countryCode: string | null;
|
|
15
|
+
timezone: string | null;
|
|
16
|
+
taxContext: string | null;
|
|
17
|
+
metadata?: Record<string, unknown> | null | undefined;
|
|
18
|
+
}[];
|
|
19
|
+
total: number;
|
|
20
|
+
limit: number;
|
|
21
|
+
offset: number;
|
|
22
|
+
}, Error, {
|
|
23
|
+
data: {
|
|
24
|
+
code: string;
|
|
25
|
+
name: string;
|
|
26
|
+
status: "active" | "inactive" | "archived";
|
|
27
|
+
defaultLanguageTag: string;
|
|
28
|
+
defaultCurrency: string;
|
|
29
|
+
id: string;
|
|
30
|
+
regionCode: string | null;
|
|
31
|
+
countryCode: string | null;
|
|
32
|
+
timezone: string | null;
|
|
33
|
+
taxContext: string | null;
|
|
34
|
+
metadata?: Record<string, unknown> | null | undefined;
|
|
35
|
+
}[];
|
|
36
|
+
total: number;
|
|
37
|
+
limit: number;
|
|
38
|
+
offset: number;
|
|
39
|
+
}, readonly ["markets", "markets", import("./query-keys.js").MarketsListFilters]>, "queryFn"> & {
|
|
40
|
+
queryFn?: import("@tanstack/react-query").QueryFunction<{
|
|
41
|
+
data: {
|
|
42
|
+
code: string;
|
|
43
|
+
name: string;
|
|
44
|
+
status: "active" | "inactive" | "archived";
|
|
45
|
+
defaultLanguageTag: string;
|
|
46
|
+
defaultCurrency: string;
|
|
47
|
+
id: string;
|
|
48
|
+
regionCode: string | null;
|
|
49
|
+
countryCode: string | null;
|
|
50
|
+
timezone: string | null;
|
|
51
|
+
taxContext: string | null;
|
|
52
|
+
metadata?: Record<string, unknown> | null | undefined;
|
|
53
|
+
}[];
|
|
54
|
+
total: number;
|
|
55
|
+
limit: number;
|
|
56
|
+
offset: number;
|
|
57
|
+
}, readonly ["markets", "markets", import("./query-keys.js").MarketsListFilters], never> | undefined;
|
|
58
|
+
} & {
|
|
59
|
+
queryKey: readonly ["markets", "markets", import("./query-keys.js").MarketsListFilters] & {
|
|
60
|
+
[dataTagSymbol]: {
|
|
61
|
+
data: {
|
|
62
|
+
code: string;
|
|
63
|
+
name: string;
|
|
64
|
+
status: "active" | "inactive" | "archived";
|
|
65
|
+
defaultLanguageTag: string;
|
|
66
|
+
defaultCurrency: string;
|
|
67
|
+
id: string;
|
|
68
|
+
regionCode: string | null;
|
|
69
|
+
countryCode: string | null;
|
|
70
|
+
timezone: string | null;
|
|
71
|
+
taxContext: string | null;
|
|
72
|
+
metadata?: Record<string, unknown> | null | undefined;
|
|
73
|
+
}[];
|
|
74
|
+
total: number;
|
|
75
|
+
limit: number;
|
|
76
|
+
offset: number;
|
|
77
|
+
};
|
|
78
|
+
[dataTagErrorSymbol]: Error;
|
|
79
|
+
};
|
|
80
|
+
};
|
|
81
|
+
export declare function getMarketQueryOptions(client: FetchWithValidationOptions, id: string): import("@tanstack/react-query").OmitKeyof<import("@tanstack/react-query").UseQueryOptions<{
|
|
82
|
+
code: string;
|
|
83
|
+
name: string;
|
|
84
|
+
status: "active" | "inactive" | "archived";
|
|
85
|
+
defaultLanguageTag: string;
|
|
86
|
+
defaultCurrency: string;
|
|
87
|
+
id: string;
|
|
88
|
+
regionCode: string | null;
|
|
89
|
+
countryCode: string | null;
|
|
90
|
+
timezone: string | null;
|
|
91
|
+
taxContext: string | null;
|
|
92
|
+
metadata?: Record<string, unknown> | null | undefined;
|
|
93
|
+
}, Error, {
|
|
94
|
+
code: string;
|
|
95
|
+
name: string;
|
|
96
|
+
status: "active" | "inactive" | "archived";
|
|
97
|
+
defaultLanguageTag: string;
|
|
98
|
+
defaultCurrency: string;
|
|
99
|
+
id: string;
|
|
100
|
+
regionCode: string | null;
|
|
101
|
+
countryCode: string | null;
|
|
102
|
+
timezone: string | null;
|
|
103
|
+
taxContext: string | null;
|
|
104
|
+
metadata?: Record<string, unknown> | null | undefined;
|
|
105
|
+
}, readonly ["markets", "markets", string]>, "queryFn"> & {
|
|
106
|
+
queryFn?: import("@tanstack/react-query").QueryFunction<{
|
|
107
|
+
code: string;
|
|
108
|
+
name: string;
|
|
109
|
+
status: "active" | "inactive" | "archived";
|
|
110
|
+
defaultLanguageTag: string;
|
|
111
|
+
defaultCurrency: string;
|
|
112
|
+
id: string;
|
|
113
|
+
regionCode: string | null;
|
|
114
|
+
countryCode: string | null;
|
|
115
|
+
timezone: string | null;
|
|
116
|
+
taxContext: string | null;
|
|
117
|
+
metadata?: Record<string, unknown> | null | undefined;
|
|
118
|
+
}, readonly ["markets", "markets", string], never> | undefined;
|
|
119
|
+
} & {
|
|
120
|
+
queryKey: readonly ["markets", "markets", string] & {
|
|
121
|
+
[dataTagSymbol]: {
|
|
122
|
+
code: string;
|
|
123
|
+
name: string;
|
|
124
|
+
status: "active" | "inactive" | "archived";
|
|
125
|
+
defaultLanguageTag: string;
|
|
126
|
+
defaultCurrency: string;
|
|
127
|
+
id: string;
|
|
128
|
+
regionCode: string | null;
|
|
129
|
+
countryCode: string | null;
|
|
130
|
+
timezone: string | null;
|
|
131
|
+
taxContext: string | null;
|
|
132
|
+
metadata?: Record<string, unknown> | null | undefined;
|
|
133
|
+
};
|
|
134
|
+
[dataTagErrorSymbol]: Error;
|
|
135
|
+
};
|
|
136
|
+
};
|
|
137
|
+
export declare function getMarketLocalesQueryOptions(client: FetchWithValidationOptions, options: UseMarketLocalesOptions): import("@tanstack/react-query").OmitKeyof<import("@tanstack/react-query").UseQueryOptions<{
|
|
138
|
+
data: {
|
|
139
|
+
languageTag: string;
|
|
140
|
+
isDefault: boolean;
|
|
141
|
+
sortOrder: number;
|
|
142
|
+
active: boolean;
|
|
143
|
+
id: string;
|
|
144
|
+
marketId: string;
|
|
145
|
+
}[];
|
|
146
|
+
total: number;
|
|
147
|
+
limit: number;
|
|
148
|
+
offset: number;
|
|
149
|
+
}, Error, {
|
|
150
|
+
data: {
|
|
151
|
+
languageTag: string;
|
|
152
|
+
isDefault: boolean;
|
|
153
|
+
sortOrder: number;
|
|
154
|
+
active: boolean;
|
|
155
|
+
id: string;
|
|
156
|
+
marketId: string;
|
|
157
|
+
}[];
|
|
158
|
+
total: number;
|
|
159
|
+
limit: number;
|
|
160
|
+
offset: number;
|
|
161
|
+
}, readonly ["markets", "market-locales", import("./query-keys.js").MarketLocalesListFilters]>, "queryFn"> & {
|
|
162
|
+
queryFn?: import("@tanstack/react-query").QueryFunction<{
|
|
163
|
+
data: {
|
|
164
|
+
languageTag: string;
|
|
165
|
+
isDefault: boolean;
|
|
166
|
+
sortOrder: number;
|
|
167
|
+
active: boolean;
|
|
168
|
+
id: string;
|
|
169
|
+
marketId: string;
|
|
170
|
+
}[];
|
|
171
|
+
total: number;
|
|
172
|
+
limit: number;
|
|
173
|
+
offset: number;
|
|
174
|
+
}, readonly ["markets", "market-locales", import("./query-keys.js").MarketLocalesListFilters], never> | undefined;
|
|
175
|
+
} & {
|
|
176
|
+
queryKey: readonly ["markets", "market-locales", import("./query-keys.js").MarketLocalesListFilters] & {
|
|
177
|
+
[dataTagSymbol]: {
|
|
178
|
+
data: {
|
|
179
|
+
languageTag: string;
|
|
180
|
+
isDefault: boolean;
|
|
181
|
+
sortOrder: number;
|
|
182
|
+
active: boolean;
|
|
183
|
+
id: string;
|
|
184
|
+
marketId: string;
|
|
185
|
+
}[];
|
|
186
|
+
total: number;
|
|
187
|
+
limit: number;
|
|
188
|
+
offset: number;
|
|
189
|
+
};
|
|
190
|
+
[dataTagErrorSymbol]: Error;
|
|
191
|
+
};
|
|
192
|
+
};
|
|
193
|
+
export declare function getMarketLocaleQueryOptions(client: FetchWithValidationOptions, id: string): import("@tanstack/react-query").OmitKeyof<import("@tanstack/react-query").UseQueryOptions<{
|
|
194
|
+
languageTag: string;
|
|
195
|
+
isDefault: boolean;
|
|
196
|
+
sortOrder: number;
|
|
197
|
+
active: boolean;
|
|
198
|
+
id: string;
|
|
199
|
+
marketId: string;
|
|
200
|
+
}, Error, {
|
|
201
|
+
languageTag: string;
|
|
202
|
+
isDefault: boolean;
|
|
203
|
+
sortOrder: number;
|
|
204
|
+
active: boolean;
|
|
205
|
+
id: string;
|
|
206
|
+
marketId: string;
|
|
207
|
+
}, readonly ["markets", "market-locales", string]>, "queryFn"> & {
|
|
208
|
+
queryFn?: import("@tanstack/react-query").QueryFunction<{
|
|
209
|
+
languageTag: string;
|
|
210
|
+
isDefault: boolean;
|
|
211
|
+
sortOrder: number;
|
|
212
|
+
active: boolean;
|
|
213
|
+
id: string;
|
|
214
|
+
marketId: string;
|
|
215
|
+
}, readonly ["markets", "market-locales", string], never> | undefined;
|
|
216
|
+
} & {
|
|
217
|
+
queryKey: readonly ["markets", "market-locales", string] & {
|
|
218
|
+
[dataTagSymbol]: {
|
|
219
|
+
languageTag: string;
|
|
220
|
+
isDefault: boolean;
|
|
221
|
+
sortOrder: number;
|
|
222
|
+
active: boolean;
|
|
223
|
+
id: string;
|
|
224
|
+
marketId: string;
|
|
225
|
+
};
|
|
226
|
+
[dataTagErrorSymbol]: Error;
|
|
227
|
+
};
|
|
228
|
+
};
|
|
229
|
+
export declare function getMarketCurrenciesQueryOptions(client: FetchWithValidationOptions, options: UseMarketCurrenciesOptions): import("@tanstack/react-query").OmitKeyof<import("@tanstack/react-query").UseQueryOptions<{
|
|
230
|
+
data: {
|
|
231
|
+
currencyCode: string;
|
|
232
|
+
isDefault: boolean;
|
|
233
|
+
isSettlement: boolean;
|
|
234
|
+
isReporting: boolean;
|
|
235
|
+
sortOrder: number;
|
|
236
|
+
active: boolean;
|
|
237
|
+
id: string;
|
|
238
|
+
marketId: string;
|
|
239
|
+
}[];
|
|
240
|
+
total: number;
|
|
241
|
+
limit: number;
|
|
242
|
+
offset: number;
|
|
243
|
+
}, Error, {
|
|
244
|
+
data: {
|
|
245
|
+
currencyCode: string;
|
|
246
|
+
isDefault: boolean;
|
|
247
|
+
isSettlement: boolean;
|
|
248
|
+
isReporting: boolean;
|
|
249
|
+
sortOrder: number;
|
|
250
|
+
active: boolean;
|
|
251
|
+
id: string;
|
|
252
|
+
marketId: string;
|
|
253
|
+
}[];
|
|
254
|
+
total: number;
|
|
255
|
+
limit: number;
|
|
256
|
+
offset: number;
|
|
257
|
+
}, readonly ["markets", "market-currencies", import("./query-keys.js").MarketCurrenciesListFilters]>, "queryFn"> & {
|
|
258
|
+
queryFn?: import("@tanstack/react-query").QueryFunction<{
|
|
259
|
+
data: {
|
|
260
|
+
currencyCode: string;
|
|
261
|
+
isDefault: boolean;
|
|
262
|
+
isSettlement: boolean;
|
|
263
|
+
isReporting: boolean;
|
|
264
|
+
sortOrder: number;
|
|
265
|
+
active: boolean;
|
|
266
|
+
id: string;
|
|
267
|
+
marketId: string;
|
|
268
|
+
}[];
|
|
269
|
+
total: number;
|
|
270
|
+
limit: number;
|
|
271
|
+
offset: number;
|
|
272
|
+
}, readonly ["markets", "market-currencies", import("./query-keys.js").MarketCurrenciesListFilters], never> | undefined;
|
|
273
|
+
} & {
|
|
274
|
+
queryKey: readonly ["markets", "market-currencies", import("./query-keys.js").MarketCurrenciesListFilters] & {
|
|
275
|
+
[dataTagSymbol]: {
|
|
276
|
+
data: {
|
|
277
|
+
currencyCode: string;
|
|
278
|
+
isDefault: boolean;
|
|
279
|
+
isSettlement: boolean;
|
|
280
|
+
isReporting: boolean;
|
|
281
|
+
sortOrder: number;
|
|
282
|
+
active: boolean;
|
|
283
|
+
id: string;
|
|
284
|
+
marketId: string;
|
|
285
|
+
}[];
|
|
286
|
+
total: number;
|
|
287
|
+
limit: number;
|
|
288
|
+
offset: number;
|
|
289
|
+
};
|
|
290
|
+
[dataTagErrorSymbol]: Error;
|
|
291
|
+
};
|
|
292
|
+
};
|
|
293
|
+
export declare function getMarketCurrencyQueryOptions(client: FetchWithValidationOptions, id: string): import("@tanstack/react-query").OmitKeyof<import("@tanstack/react-query").UseQueryOptions<{
|
|
294
|
+
currencyCode: string;
|
|
295
|
+
isDefault: boolean;
|
|
296
|
+
isSettlement: boolean;
|
|
297
|
+
isReporting: boolean;
|
|
298
|
+
sortOrder: number;
|
|
299
|
+
active: boolean;
|
|
300
|
+
id: string;
|
|
301
|
+
marketId: string;
|
|
302
|
+
}, Error, {
|
|
303
|
+
currencyCode: string;
|
|
304
|
+
isDefault: boolean;
|
|
305
|
+
isSettlement: boolean;
|
|
306
|
+
isReporting: boolean;
|
|
307
|
+
sortOrder: number;
|
|
308
|
+
active: boolean;
|
|
309
|
+
id: string;
|
|
310
|
+
marketId: string;
|
|
311
|
+
}, readonly ["markets", "market-currencies", string]>, "queryFn"> & {
|
|
312
|
+
queryFn?: import("@tanstack/react-query").QueryFunction<{
|
|
313
|
+
currencyCode: string;
|
|
314
|
+
isDefault: boolean;
|
|
315
|
+
isSettlement: boolean;
|
|
316
|
+
isReporting: boolean;
|
|
317
|
+
sortOrder: number;
|
|
318
|
+
active: boolean;
|
|
319
|
+
id: string;
|
|
320
|
+
marketId: string;
|
|
321
|
+
}, readonly ["markets", "market-currencies", string], never> | undefined;
|
|
322
|
+
} & {
|
|
323
|
+
queryKey: readonly ["markets", "market-currencies", string] & {
|
|
324
|
+
[dataTagSymbol]: {
|
|
325
|
+
currencyCode: string;
|
|
326
|
+
isDefault: boolean;
|
|
327
|
+
isSettlement: boolean;
|
|
328
|
+
isReporting: boolean;
|
|
329
|
+
sortOrder: number;
|
|
330
|
+
active: boolean;
|
|
331
|
+
id: string;
|
|
332
|
+
marketId: string;
|
|
333
|
+
};
|
|
334
|
+
[dataTagErrorSymbol]: Error;
|
|
335
|
+
};
|
|
336
|
+
};
|
|
337
|
+
//# sourceMappingURL=query-options.d.ts.map
|
|
@@ -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,0BAA0B,EAAE,MAAM,kCAAkC,CAAA;AAClF,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,+BAA+B,CAAA;AAC5E,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAA;AAqB/D,wBAAgB,sBAAsB,CACpC,MAAM,EAAE,0BAA0B,EAClC,OAAO,GAAE,iBAAsB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAYhC;AAED,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,0BAA0B,EAAE,EAAE,EAAE,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAYnF;AAED,wBAAgB,4BAA4B,CAC1C,MAAM,EAAE,0BAA0B,EAClC,OAAO,EAAE,uBAAuB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAcjC;AAED,wBAAgB,2BAA2B,CAAC,MAAM,EAAE,0BAA0B,EAAE,EAAE,EAAE,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAYzF;AAED,wBAAgB,+BAA+B,CAC7C,MAAM,EAAE,0BAA0B,EAClC,OAAO,EAAE,0BAA0B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAcpC;AAED,wBAAgB,6BAA6B,CAAC,MAAM,EAAE,0BAA0B,EAAE,EAAE,EAAE,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAY3F"}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { queryOptions } from "@tanstack/react-query";
|
|
3
|
+
import { fetchWithValidation } from "./client.js";
|
|
4
|
+
import { marketsQueryKeys } from "./query-keys.js";
|
|
5
|
+
import { marketCurrencyListResponse, marketCurrencySingleResponse, marketListResponse, marketLocaleListResponse, marketLocaleSingleResponse, marketSingleResponse, } from "./schemas.js";
|
|
6
|
+
function toQueryString(filters) {
|
|
7
|
+
const params = new URLSearchParams();
|
|
8
|
+
for (const [key, value] of Object.entries(filters)) {
|
|
9
|
+
if (value === undefined || value === null || value === "")
|
|
10
|
+
continue;
|
|
11
|
+
params.set(key, String(value));
|
|
12
|
+
}
|
|
13
|
+
const qs = params.toString();
|
|
14
|
+
return qs ? `?${qs}` : "";
|
|
15
|
+
}
|
|
16
|
+
export function getMarketsQueryOptions(client, options = {}) {
|
|
17
|
+
const { enabled: _enabled = true, ...filters } = options;
|
|
18
|
+
return queryOptions({
|
|
19
|
+
queryKey: marketsQueryKeys.marketsList(filters),
|
|
20
|
+
queryFn: () => fetchWithValidation(`/v1/markets/markets${toQueryString(filters)}`, marketListResponse, client),
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
export function getMarketQueryOptions(client, id) {
|
|
24
|
+
return queryOptions({
|
|
25
|
+
queryKey: marketsQueryKeys.market(id),
|
|
26
|
+
queryFn: async () => {
|
|
27
|
+
const { data } = await fetchWithValidation(`/v1/markets/markets/${id}`, marketSingleResponse, client);
|
|
28
|
+
return data;
|
|
29
|
+
},
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
export function getMarketLocalesQueryOptions(client, options) {
|
|
33
|
+
const { enabled: _enabled = true, ...filters } = options;
|
|
34
|
+
return queryOptions({
|
|
35
|
+
queryKey: marketsQueryKeys.marketLocalesList(filters),
|
|
36
|
+
queryFn: async () => {
|
|
37
|
+
if (!filters.marketId)
|
|
38
|
+
throw new Error("getMarketLocalesQueryOptions requires a marketId");
|
|
39
|
+
return fetchWithValidation(`/v1/markets/market-locales${toQueryString(filters)}`, marketLocaleListResponse, client);
|
|
40
|
+
},
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
export function getMarketLocaleQueryOptions(client, id) {
|
|
44
|
+
return queryOptions({
|
|
45
|
+
queryKey: marketsQueryKeys.marketLocale(id),
|
|
46
|
+
queryFn: async () => {
|
|
47
|
+
const { data } = await fetchWithValidation(`/v1/markets/market-locales/${id}`, marketLocaleSingleResponse, client);
|
|
48
|
+
return data;
|
|
49
|
+
},
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
export function getMarketCurrenciesQueryOptions(client, options) {
|
|
53
|
+
const { enabled: _enabled = true, ...filters } = options;
|
|
54
|
+
return queryOptions({
|
|
55
|
+
queryKey: marketsQueryKeys.marketCurrenciesList(filters),
|
|
56
|
+
queryFn: async () => {
|
|
57
|
+
if (!filters.marketId)
|
|
58
|
+
throw new Error("getMarketCurrenciesQueryOptions requires a marketId");
|
|
59
|
+
return fetchWithValidation(`/v1/markets/market-currencies${toQueryString(filters)}`, marketCurrencyListResponse, client);
|
|
60
|
+
},
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
export function getMarketCurrencyQueryOptions(client, id) {
|
|
64
|
+
return queryOptions({
|
|
65
|
+
queryKey: marketsQueryKeys.marketCurrency(id),
|
|
66
|
+
queryFn: async () => {
|
|
67
|
+
const { data } = await fetchWithValidation(`/v1/markets/market-currencies/${id}`, marketCurrencySingleResponse, client);
|
|
68
|
+
return data;
|
|
69
|
+
},
|
|
70
|
+
});
|
|
71
|
+
}
|
|
@@ -0,0 +1,143 @@
|
|
|
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 marketRecordSchema: z.ZodObject<{
|
|
15
|
+
code: z.ZodString;
|
|
16
|
+
name: z.ZodString;
|
|
17
|
+
status: z.ZodDefault<z.ZodEnum<{
|
|
18
|
+
active: "active";
|
|
19
|
+
inactive: "inactive";
|
|
20
|
+
archived: "archived";
|
|
21
|
+
}>>;
|
|
22
|
+
defaultLanguageTag: z.ZodString;
|
|
23
|
+
defaultCurrency: z.ZodString;
|
|
24
|
+
id: z.ZodString;
|
|
25
|
+
regionCode: z.ZodNullable<z.ZodString>;
|
|
26
|
+
countryCode: z.ZodNullable<z.ZodString>;
|
|
27
|
+
timezone: z.ZodNullable<z.ZodString>;
|
|
28
|
+
taxContext: z.ZodNullable<z.ZodString>;
|
|
29
|
+
metadata: z.ZodOptional<z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
|
|
30
|
+
}, z.core.$strip>;
|
|
31
|
+
export type MarketRecord = z.infer<typeof marketRecordSchema>;
|
|
32
|
+
export declare const marketLocaleRecordSchema: z.ZodObject<{
|
|
33
|
+
languageTag: z.ZodString;
|
|
34
|
+
isDefault: z.ZodDefault<z.ZodBoolean>;
|
|
35
|
+
sortOrder: z.ZodDefault<z.ZodNumber>;
|
|
36
|
+
active: z.ZodDefault<z.ZodBoolean>;
|
|
37
|
+
id: z.ZodString;
|
|
38
|
+
marketId: z.ZodString;
|
|
39
|
+
}, z.core.$strip>;
|
|
40
|
+
export type MarketLocaleRecord = z.infer<typeof marketLocaleRecordSchema>;
|
|
41
|
+
export declare const marketCurrencyRecordSchema: z.ZodObject<{
|
|
42
|
+
currencyCode: z.ZodString;
|
|
43
|
+
isDefault: z.ZodDefault<z.ZodBoolean>;
|
|
44
|
+
isSettlement: z.ZodDefault<z.ZodBoolean>;
|
|
45
|
+
isReporting: z.ZodDefault<z.ZodBoolean>;
|
|
46
|
+
sortOrder: z.ZodDefault<z.ZodNumber>;
|
|
47
|
+
active: z.ZodDefault<z.ZodBoolean>;
|
|
48
|
+
id: z.ZodString;
|
|
49
|
+
marketId: z.ZodString;
|
|
50
|
+
}, z.core.$strip>;
|
|
51
|
+
export type MarketCurrencyRecord = z.infer<typeof marketCurrencyRecordSchema>;
|
|
52
|
+
export declare const marketListResponse: z.ZodObject<{
|
|
53
|
+
data: z.ZodArray<z.ZodObject<{
|
|
54
|
+
code: z.ZodString;
|
|
55
|
+
name: z.ZodString;
|
|
56
|
+
status: z.ZodDefault<z.ZodEnum<{
|
|
57
|
+
active: "active";
|
|
58
|
+
inactive: "inactive";
|
|
59
|
+
archived: "archived";
|
|
60
|
+
}>>;
|
|
61
|
+
defaultLanguageTag: z.ZodString;
|
|
62
|
+
defaultCurrency: z.ZodString;
|
|
63
|
+
id: z.ZodString;
|
|
64
|
+
regionCode: z.ZodNullable<z.ZodString>;
|
|
65
|
+
countryCode: z.ZodNullable<z.ZodString>;
|
|
66
|
+
timezone: z.ZodNullable<z.ZodString>;
|
|
67
|
+
taxContext: z.ZodNullable<z.ZodString>;
|
|
68
|
+
metadata: z.ZodOptional<z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
|
|
69
|
+
}, z.core.$strip>>;
|
|
70
|
+
total: z.ZodNumber;
|
|
71
|
+
limit: z.ZodNumber;
|
|
72
|
+
offset: z.ZodNumber;
|
|
73
|
+
}, z.core.$strip>;
|
|
74
|
+
export declare const marketSingleResponse: z.ZodObject<{
|
|
75
|
+
data: z.ZodObject<{
|
|
76
|
+
code: z.ZodString;
|
|
77
|
+
name: z.ZodString;
|
|
78
|
+
status: z.ZodDefault<z.ZodEnum<{
|
|
79
|
+
active: "active";
|
|
80
|
+
inactive: "inactive";
|
|
81
|
+
archived: "archived";
|
|
82
|
+
}>>;
|
|
83
|
+
defaultLanguageTag: z.ZodString;
|
|
84
|
+
defaultCurrency: z.ZodString;
|
|
85
|
+
id: z.ZodString;
|
|
86
|
+
regionCode: z.ZodNullable<z.ZodString>;
|
|
87
|
+
countryCode: z.ZodNullable<z.ZodString>;
|
|
88
|
+
timezone: z.ZodNullable<z.ZodString>;
|
|
89
|
+
taxContext: z.ZodNullable<z.ZodString>;
|
|
90
|
+
metadata: z.ZodOptional<z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
|
|
91
|
+
}, z.core.$strip>;
|
|
92
|
+
}, z.core.$strip>;
|
|
93
|
+
export declare const marketLocaleListResponse: z.ZodObject<{
|
|
94
|
+
data: z.ZodArray<z.ZodObject<{
|
|
95
|
+
languageTag: z.ZodString;
|
|
96
|
+
isDefault: z.ZodDefault<z.ZodBoolean>;
|
|
97
|
+
sortOrder: z.ZodDefault<z.ZodNumber>;
|
|
98
|
+
active: z.ZodDefault<z.ZodBoolean>;
|
|
99
|
+
id: z.ZodString;
|
|
100
|
+
marketId: z.ZodString;
|
|
101
|
+
}, z.core.$strip>>;
|
|
102
|
+
total: z.ZodNumber;
|
|
103
|
+
limit: z.ZodNumber;
|
|
104
|
+
offset: z.ZodNumber;
|
|
105
|
+
}, z.core.$strip>;
|
|
106
|
+
export declare const marketLocaleSingleResponse: z.ZodObject<{
|
|
107
|
+
data: z.ZodObject<{
|
|
108
|
+
languageTag: z.ZodString;
|
|
109
|
+
isDefault: z.ZodDefault<z.ZodBoolean>;
|
|
110
|
+
sortOrder: z.ZodDefault<z.ZodNumber>;
|
|
111
|
+
active: z.ZodDefault<z.ZodBoolean>;
|
|
112
|
+
id: z.ZodString;
|
|
113
|
+
marketId: z.ZodString;
|
|
114
|
+
}, z.core.$strip>;
|
|
115
|
+
}, z.core.$strip>;
|
|
116
|
+
export declare const marketCurrencyListResponse: z.ZodObject<{
|
|
117
|
+
data: z.ZodArray<z.ZodObject<{
|
|
118
|
+
currencyCode: z.ZodString;
|
|
119
|
+
isDefault: z.ZodDefault<z.ZodBoolean>;
|
|
120
|
+
isSettlement: z.ZodDefault<z.ZodBoolean>;
|
|
121
|
+
isReporting: z.ZodDefault<z.ZodBoolean>;
|
|
122
|
+
sortOrder: z.ZodDefault<z.ZodNumber>;
|
|
123
|
+
active: z.ZodDefault<z.ZodBoolean>;
|
|
124
|
+
id: z.ZodString;
|
|
125
|
+
marketId: z.ZodString;
|
|
126
|
+
}, z.core.$strip>>;
|
|
127
|
+
total: z.ZodNumber;
|
|
128
|
+
limit: z.ZodNumber;
|
|
129
|
+
offset: z.ZodNumber;
|
|
130
|
+
}, z.core.$strip>;
|
|
131
|
+
export declare const marketCurrencySingleResponse: z.ZodObject<{
|
|
132
|
+
data: z.ZodObject<{
|
|
133
|
+
currencyCode: z.ZodString;
|
|
134
|
+
isDefault: z.ZodDefault<z.ZodBoolean>;
|
|
135
|
+
isSettlement: z.ZodDefault<z.ZodBoolean>;
|
|
136
|
+
isReporting: z.ZodDefault<z.ZodBoolean>;
|
|
137
|
+
sortOrder: z.ZodDefault<z.ZodNumber>;
|
|
138
|
+
active: z.ZodDefault<z.ZodBoolean>;
|
|
139
|
+
id: z.ZodString;
|
|
140
|
+
marketId: z.ZodString;
|
|
141
|
+
}, z.core.$strip>;
|
|
142
|
+
}, z.core.$strip>;
|
|
143
|
+
//# sourceMappingURL=schemas.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schemas.d.ts","sourceRoot":"","sources":["../src/schemas.ts"],"names":[],"mappings":"AAKA,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;AAC3F,eAAO,MAAM,eAAe;;iBAAqC,CAAA;AAEjE,eAAO,MAAM,kBAAkB;;;;;;;;;;;;;;;;iBAO7B,CAAA;AAEF,MAAM,MAAM,YAAY,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,kBAAkB,CAAC,CAAA;AAE7D,eAAO,MAAM,wBAAwB;;;;;;;iBAGnC,CAAA;AAEF,MAAM,MAAM,kBAAkB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,wBAAwB,CAAC,CAAA;AAEzE,eAAO,MAAM,0BAA0B;;;;;;;;;iBAGrC,CAAA;AAEF,MAAM,MAAM,oBAAoB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,0BAA0B,CAAC,CAAA;AAE7E,eAAO,MAAM,kBAAkB;;;;;;;;;;;;;;;;;;;;;iBAAwC,CAAA;AACvE,eAAO,MAAM,oBAAoB;;;;;;;;;;;;;;;;;;iBAAqC,CAAA;AACtE,eAAO,MAAM,wBAAwB;;;;;;;;;;;;iBAA8C,CAAA;AACnF,eAAO,MAAM,0BAA0B;;;;;;;;;iBAA2C,CAAA;AAClF,eAAO,MAAM,0BAA0B;;;;;;;;;;;;;;iBAAgD,CAAA;AACvF,eAAO,MAAM,4BAA4B;;;;;;;;;;;iBAA6C,CAAA"}
|
package/dist/schemas.js
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { insertMarketCurrencySchema, insertMarketLocaleSchema, insertMarketSchema, } from "@voyantjs/markets";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
export const paginatedEnvelope = (item) => z.object({
|
|
4
|
+
data: z.array(item),
|
|
5
|
+
total: z.number().int(),
|
|
6
|
+
limit: z.number().int(),
|
|
7
|
+
offset: z.number().int(),
|
|
8
|
+
});
|
|
9
|
+
export const singleEnvelope = (item) => z.object({ data: item });
|
|
10
|
+
export const successEnvelope = z.object({ success: z.boolean() });
|
|
11
|
+
export const marketRecordSchema = insertMarketSchema.extend({
|
|
12
|
+
id: z.string(),
|
|
13
|
+
regionCode: z.string().nullable(),
|
|
14
|
+
countryCode: z.string().nullable(),
|
|
15
|
+
timezone: z.string().nullable(),
|
|
16
|
+
taxContext: z.string().nullable(),
|
|
17
|
+
metadata: z.record(z.string(), z.unknown()).nullable().optional(),
|
|
18
|
+
});
|
|
19
|
+
export const marketLocaleRecordSchema = insertMarketLocaleSchema.extend({
|
|
20
|
+
id: z.string(),
|
|
21
|
+
marketId: z.string(),
|
|
22
|
+
});
|
|
23
|
+
export const marketCurrencyRecordSchema = insertMarketCurrencySchema.extend({
|
|
24
|
+
id: z.string(),
|
|
25
|
+
marketId: z.string(),
|
|
26
|
+
});
|
|
27
|
+
export const marketListResponse = paginatedEnvelope(marketRecordSchema);
|
|
28
|
+
export const marketSingleResponse = singleEnvelope(marketRecordSchema);
|
|
29
|
+
export const marketLocaleListResponse = paginatedEnvelope(marketLocaleRecordSchema);
|
|
30
|
+
export const marketLocaleSingleResponse = singleEnvelope(marketLocaleRecordSchema);
|
|
31
|
+
export const marketCurrencyListResponse = paginatedEnvelope(marketCurrencyRecordSchema);
|
|
32
|
+
export const marketCurrencySingleResponse = singleEnvelope(marketCurrencyRecordSchema);
|
package/package.json
ADDED
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@voyantjs/markets-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/markets-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/markets": "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/markets": "workspace:*",
|
|
38
|
+
"@voyantjs/react": "workspace:*",
|
|
39
|
+
"@voyantjs/voyant-typescript-config": "workspace:*",
|
|
40
|
+
"react": "^19.2.4",
|
|
41
|
+
"react-dom": "^19.2.4",
|
|
42
|
+
"typescript": "^6.0.2",
|
|
43
|
+
"vitest": "^4.1.2",
|
|
44
|
+
"zod": "^4.3.6"
|
|
45
|
+
},
|
|
46
|
+
"dependencies": {
|
|
47
|
+
"@voyantjs/react": "workspace:*"
|
|
48
|
+
},
|
|
49
|
+
"files": [
|
|
50
|
+
"dist"
|
|
51
|
+
],
|
|
52
|
+
"publishConfig": {
|
|
53
|
+
"access": "public",
|
|
54
|
+
"exports": {
|
|
55
|
+
".": {
|
|
56
|
+
"types": "./dist/index.d.ts",
|
|
57
|
+
"import": "./dist/index.js"
|
|
58
|
+
},
|
|
59
|
+
"./provider": {
|
|
60
|
+
"types": "./dist/provider.d.ts",
|
|
61
|
+
"import": "./dist/provider.js"
|
|
62
|
+
},
|
|
63
|
+
"./hooks": {
|
|
64
|
+
"types": "./dist/hooks/index.d.ts",
|
|
65
|
+
"import": "./dist/hooks/index.js"
|
|
66
|
+
},
|
|
67
|
+
"./client": {
|
|
68
|
+
"types": "./dist/client.d.ts",
|
|
69
|
+
"import": "./dist/client.js"
|
|
70
|
+
},
|
|
71
|
+
"./query-keys": {
|
|
72
|
+
"types": "./dist/query-keys.d.ts",
|
|
73
|
+
"import": "./dist/query-keys.js"
|
|
74
|
+
}
|
|
75
|
+
},
|
|
76
|
+
"main": "./dist/index.js",
|
|
77
|
+
"types": "./dist/index.d.ts"
|
|
78
|
+
}
|
|
79
|
+
}
|