@simpleapps-com/augur-hooks 0.1.9 → 0.2.1
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/chunk-4CNSPZ7Q.cjs +575 -0
- package/dist/chunk-4CNSPZ7Q.cjs.map +1 -0
- package/dist/chunk-D3APHDL4.js +575 -0
- package/dist/chunk-D3APHDL4.js.map +1 -0
- package/dist/index.cjs +58 -46
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +5 -3
- package/dist/index.d.ts +5 -3
- package/dist/index.js +48 -36
- package/dist/index.js.map +1 -1
- package/dist/{joomla-content-list-MMF5wDQy.d.ts → joomla-content-list-CDF5-OJ3.d.cts} +93 -93
- package/dist/{joomla-content-list-MMF5wDQy.d.cts → joomla-content-list-CDF5-OJ3.d.ts} +93 -93
- package/dist/server.cjs +2 -16
- package/dist/server.cjs.map +1 -1
- package/dist/server.d.cts +1 -1
- package/dist/server.d.ts +1 -1
- package/dist/server.js +1 -15
- package/package.json +2 -2
- package/dist/chunk-ENELW5AU.cjs +0 -374
- package/dist/chunk-ENELW5AU.cjs.map +0 -1
- package/dist/chunk-TUNAYTS6.js +0 -374
- package/dist/chunk-TUNAYTS6.js.map +0 -1
|
@@ -0,0 +1,575 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }// src/queries/stable-stringify.ts
|
|
2
|
+
function stableStringify(value) {
|
|
3
|
+
if (value === null || value === void 0) return JSON.stringify(value);
|
|
4
|
+
if (typeof value !== "object") return JSON.stringify(value);
|
|
5
|
+
if (Array.isArray(value)) {
|
|
6
|
+
return `[${value.map(stableStringify).join(",")}]`;
|
|
7
|
+
}
|
|
8
|
+
const obj = value;
|
|
9
|
+
const keys = Object.keys(obj).sort();
|
|
10
|
+
const entries = keys.map(
|
|
11
|
+
(key) => `${JSON.stringify(key)}:${stableStringify(obj[key])}`
|
|
12
|
+
);
|
|
13
|
+
return `{${entries.join(",")}}`;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
// src/queries/cache-helper.ts
|
|
17
|
+
function fnv1a(str) {
|
|
18
|
+
let h = 2166136261;
|
|
19
|
+
for (let i = 0; i < str.length; i++) {
|
|
20
|
+
h ^= str.charCodeAt(i);
|
|
21
|
+
h = Math.imul(h, 16777619);
|
|
22
|
+
}
|
|
23
|
+
return (h >>> 0).toString(16).padStart(8, "0");
|
|
24
|
+
}
|
|
25
|
+
async function withCache(provider, tier, methodPath, fn, ...keyArgs) {
|
|
26
|
+
const redisTtl = _optionalChain([tier, 'optionalAccess', _ => _.redis]);
|
|
27
|
+
if (!provider || !redisTtl) return fn();
|
|
28
|
+
const key = `${provider.prefix}sdk:${methodPath}:${fnv1a(stableStringify(keyArgs))}`;
|
|
29
|
+
try {
|
|
30
|
+
const cached = await provider.get(key);
|
|
31
|
+
if (cached != null) return JSON.parse(cached);
|
|
32
|
+
} catch (e) {
|
|
33
|
+
}
|
|
34
|
+
const result = await fn();
|
|
35
|
+
try {
|
|
36
|
+
provider.set(key, JSON.stringify(result), redisTtl).catch(() => {
|
|
37
|
+
});
|
|
38
|
+
} catch (e2) {
|
|
39
|
+
}
|
|
40
|
+
return result;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
// src/queries/item-price.ts
|
|
44
|
+
var getItemPriceKey = (itemId, customerId, quantity = 1) => {
|
|
45
|
+
return ["price", _optionalChain([itemId, 'optionalAccess', _2 => _2.toUpperCase, 'call', _3 => _3()]) || "", customerId, quantity];
|
|
46
|
+
};
|
|
47
|
+
var getItemPriceOptions = (api, itemId, customerId, quantity = 1, cache) => {
|
|
48
|
+
const tier = _optionalChain([cache, 'optionalAccess', _4 => _4.semiStatic]);
|
|
49
|
+
return {
|
|
50
|
+
queryKey: getItemPriceKey(itemId, customerId, quantity),
|
|
51
|
+
queryFn: async () => {
|
|
52
|
+
const edgeCache = _optionalChain([tier, 'optionalAccess', _5 => _5.edgeCache]);
|
|
53
|
+
return withCache(
|
|
54
|
+
_optionalChain([cache, 'optionalAccess', _6 => _6.provider]),
|
|
55
|
+
tier,
|
|
56
|
+
"pricing.priceEngine.get",
|
|
57
|
+
async () => {
|
|
58
|
+
const response = await api.pricing.priceEngine.get({
|
|
59
|
+
itemId: _optionalChain([itemId, 'optionalAccess', _7 => _7.toUpperCase, 'call', _8 => _8()]) || "",
|
|
60
|
+
customerId: Number(customerId),
|
|
61
|
+
quantity,
|
|
62
|
+
...edgeCache != null ? { edgeCache } : {}
|
|
63
|
+
});
|
|
64
|
+
return response.data;
|
|
65
|
+
},
|
|
66
|
+
itemId,
|
|
67
|
+
customerId,
|
|
68
|
+
quantity
|
|
69
|
+
);
|
|
70
|
+
},
|
|
71
|
+
staleTime: _optionalChain([tier, 'optionalAccess', _9 => _9.staleTime]),
|
|
72
|
+
gcTime: _optionalChain([tier, 'optionalAccess', _10 => _10.gcTime]),
|
|
73
|
+
refetchOnReconnect: true,
|
|
74
|
+
refetchOnWindowFocus: false,
|
|
75
|
+
meta: { persist: true }
|
|
76
|
+
};
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
// src/queries/inv-mast-doc.ts
|
|
80
|
+
var getInvMastDocKey = (invMastUid, itemId, includePricing) => {
|
|
81
|
+
return [
|
|
82
|
+
"invMastDoc",
|
|
83
|
+
invMastUid,
|
|
84
|
+
itemId.toUpperCase(),
|
|
85
|
+
includePricing
|
|
86
|
+
];
|
|
87
|
+
};
|
|
88
|
+
var getInvMastDocOptions = (api, invMastUid, itemId, includePricing, cache) => {
|
|
89
|
+
const tier = _optionalChain([cache, 'optionalAccess', _11 => _11.static]);
|
|
90
|
+
return {
|
|
91
|
+
queryKey: getInvMastDocKey(invMastUid, itemId, includePricing),
|
|
92
|
+
queryFn: async () => {
|
|
93
|
+
const edgeCache = _optionalChain([tier, 'optionalAccess', _12 => _12.edgeCache]);
|
|
94
|
+
return withCache(
|
|
95
|
+
_optionalChain([cache, 'optionalAccess', _13 => _13.provider]),
|
|
96
|
+
tier,
|
|
97
|
+
"items.invMast.doc.list",
|
|
98
|
+
async () => {
|
|
99
|
+
const response = await api.items.invMast.doc.list(invMastUid, {
|
|
100
|
+
itemId: itemId.toUpperCase(),
|
|
101
|
+
includePricing,
|
|
102
|
+
...edgeCache != null ? { edgeCache } : {}
|
|
103
|
+
});
|
|
104
|
+
if (!response.data) throw new Error("Item not found");
|
|
105
|
+
return response.data;
|
|
106
|
+
},
|
|
107
|
+
invMastUid,
|
|
108
|
+
itemId,
|
|
109
|
+
includePricing
|
|
110
|
+
);
|
|
111
|
+
},
|
|
112
|
+
staleTime: _optionalChain([tier, 'optionalAccess', _14 => _14.staleTime]),
|
|
113
|
+
gcTime: _optionalChain([tier, 'optionalAccess', _15 => _15.gcTime])
|
|
114
|
+
};
|
|
115
|
+
};
|
|
116
|
+
|
|
117
|
+
// src/queries/item-category.ts
|
|
118
|
+
var getItemCategoryKey = (itemCategoryUid, apiOptions) => {
|
|
119
|
+
return ["itemCategory", itemCategoryUid, apiOptions];
|
|
120
|
+
};
|
|
121
|
+
var getItemCategoryOptions = (api, itemCategoryUid, apiOptions, cache) => {
|
|
122
|
+
const tier = _optionalChain([cache, 'optionalAccess', _16 => _16.static]);
|
|
123
|
+
return {
|
|
124
|
+
queryKey: getItemCategoryKey(itemCategoryUid, apiOptions),
|
|
125
|
+
queryFn: async () => {
|
|
126
|
+
const edgeCache = _optionalChain([tier, 'optionalAccess', _17 => _17.edgeCache]);
|
|
127
|
+
return withCache(
|
|
128
|
+
_optionalChain([cache, 'optionalAccess', _18 => _18.provider]),
|
|
129
|
+
tier,
|
|
130
|
+
"items.itemCategory.get",
|
|
131
|
+
async () => {
|
|
132
|
+
const response = await api.items.itemCategory.get(
|
|
133
|
+
itemCategoryUid,
|
|
134
|
+
{ ...apiOptions, ...edgeCache != null ? { edgeCache } : {} }
|
|
135
|
+
);
|
|
136
|
+
if (!response.data) throw new Error("Item category not found");
|
|
137
|
+
return response.data;
|
|
138
|
+
},
|
|
139
|
+
itemCategoryUid,
|
|
140
|
+
apiOptions
|
|
141
|
+
);
|
|
142
|
+
},
|
|
143
|
+
staleTime: _optionalChain([tier, 'optionalAccess', _19 => _19.staleTime]),
|
|
144
|
+
gcTime: _optionalChain([tier, 'optionalAccess', _20 => _20.gcTime])
|
|
145
|
+
};
|
|
146
|
+
};
|
|
147
|
+
|
|
148
|
+
// src/queries/inv-mast.ts
|
|
149
|
+
var getInvMastKey = (invMastUid, itemId) => {
|
|
150
|
+
return ["invMast", invMastUid, itemId.toUpperCase()];
|
|
151
|
+
};
|
|
152
|
+
var getInvMastOptions = (api, invMastUid, itemId, cache) => {
|
|
153
|
+
const tier = _optionalChain([cache, 'optionalAccess', _21 => _21.static]);
|
|
154
|
+
return {
|
|
155
|
+
queryKey: getInvMastKey(invMastUid, itemId),
|
|
156
|
+
queryFn: async () => {
|
|
157
|
+
const edgeCache = _optionalChain([tier, 'optionalAccess', _22 => _22.edgeCache]);
|
|
158
|
+
return withCache(
|
|
159
|
+
_optionalChain([cache, 'optionalAccess', _23 => _23.provider]),
|
|
160
|
+
tier,
|
|
161
|
+
"items.invMast.get",
|
|
162
|
+
async () => {
|
|
163
|
+
const response = await api.items.invMast.get(invMastUid, {
|
|
164
|
+
...edgeCache != null ? { edgeCache } : {}
|
|
165
|
+
});
|
|
166
|
+
if (!response.data) throw new Error("Item not found");
|
|
167
|
+
return response.data;
|
|
168
|
+
},
|
|
169
|
+
invMastUid
|
|
170
|
+
);
|
|
171
|
+
},
|
|
172
|
+
staleTime: _optionalChain([tier, 'optionalAccess', _24 => _24.staleTime]),
|
|
173
|
+
gcTime: _optionalChain([tier, 'optionalAccess', _25 => _25.gcTime])
|
|
174
|
+
};
|
|
175
|
+
};
|
|
176
|
+
|
|
177
|
+
// src/queries/inv-mast-stock.ts
|
|
178
|
+
var getInvMastStockKey = (invMastUid) => {
|
|
179
|
+
return ["invMastStock", invMastUid];
|
|
180
|
+
};
|
|
181
|
+
var getInvMastStockOptions = (api, invMastUid, cache) => {
|
|
182
|
+
const tier = _optionalChain([cache, 'optionalAccess', _26 => _26.semiStatic]);
|
|
183
|
+
return {
|
|
184
|
+
queryKey: getInvMastStockKey(invMastUid),
|
|
185
|
+
queryFn: async () => {
|
|
186
|
+
const edgeCache = _optionalChain([tier, 'optionalAccess', _27 => _27.edgeCache]);
|
|
187
|
+
return withCache(
|
|
188
|
+
_optionalChain([cache, 'optionalAccess', _28 => _28.provider]),
|
|
189
|
+
tier,
|
|
190
|
+
"items.invMast.stock.list",
|
|
191
|
+
async () => {
|
|
192
|
+
const response = await api.items.invMast.stock.list(Number(invMastUid), {
|
|
193
|
+
...edgeCache != null ? { edgeCache } : {}
|
|
194
|
+
});
|
|
195
|
+
const stockData = _nullishCoalesce(_optionalChain([response, 'access', _29 => _29.data, 'optionalAccess', _30 => _30.stockData]), () => ( []));
|
|
196
|
+
return stockData.reduce(
|
|
197
|
+
(qty, stock) => qty + stock.qtyOnHand,
|
|
198
|
+
0
|
|
199
|
+
);
|
|
200
|
+
},
|
|
201
|
+
invMastUid
|
|
202
|
+
);
|
|
203
|
+
},
|
|
204
|
+
staleTime: _optionalChain([tier, 'optionalAccess', _31 => _31.staleTime]),
|
|
205
|
+
gcTime: _optionalChain([tier, 'optionalAccess', _32 => _32.gcTime])
|
|
206
|
+
};
|
|
207
|
+
};
|
|
208
|
+
|
|
209
|
+
// src/queries/product-category.ts
|
|
210
|
+
var getProductCategoryKey = (itemCategoryUid) => {
|
|
211
|
+
return ["productCategory", itemCategoryUid];
|
|
212
|
+
};
|
|
213
|
+
var getProductCategoryOptions = (api, itemCategoryUid, cache) => {
|
|
214
|
+
const tier = _optionalChain([cache, 'optionalAccess', _33 => _33.static]);
|
|
215
|
+
return {
|
|
216
|
+
queryKey: getProductCategoryKey(itemCategoryUid),
|
|
217
|
+
queryFn: async () => {
|
|
218
|
+
const edgeCache = _optionalChain([tier, 'optionalAccess', _34 => _34.edgeCache]);
|
|
219
|
+
return withCache(
|
|
220
|
+
_optionalChain([cache, 'optionalAccess', _35 => _35.provider]),
|
|
221
|
+
tier,
|
|
222
|
+
"items.itemCategory.get",
|
|
223
|
+
async () => {
|
|
224
|
+
const response = await api.items.itemCategory.get(Number(itemCategoryUid), {
|
|
225
|
+
...edgeCache != null ? { edgeCache } : {}
|
|
226
|
+
});
|
|
227
|
+
return response.data;
|
|
228
|
+
},
|
|
229
|
+
itemCategoryUid
|
|
230
|
+
);
|
|
231
|
+
},
|
|
232
|
+
staleTime: _optionalChain([tier, 'optionalAccess', _36 => _36.staleTime]),
|
|
233
|
+
gcTime: _optionalChain([tier, 'optionalAccess', _37 => _37.gcTime])
|
|
234
|
+
};
|
|
235
|
+
};
|
|
236
|
+
|
|
237
|
+
// src/queries/item-details.ts
|
|
238
|
+
var getItemDetailsKey = (itemId) => {
|
|
239
|
+
const normalizedId = typeof itemId === "string" ? itemId.toUpperCase() : itemId;
|
|
240
|
+
return ["itemDetails", normalizedId];
|
|
241
|
+
};
|
|
242
|
+
var getItemDetailsOptions = (api, itemId, cache) => {
|
|
243
|
+
const tier = _optionalChain([cache, 'optionalAccess', _38 => _38.static]);
|
|
244
|
+
return {
|
|
245
|
+
queryKey: getItemDetailsKey(itemId),
|
|
246
|
+
queryFn: async () => {
|
|
247
|
+
const edgeCache = _optionalChain([tier, 'optionalAccess', _39 => _39.edgeCache]);
|
|
248
|
+
return withCache(
|
|
249
|
+
_optionalChain([cache, 'optionalAccess', _40 => _40.provider]),
|
|
250
|
+
tier,
|
|
251
|
+
"items.invMast.doc.list",
|
|
252
|
+
async () => {
|
|
253
|
+
const response = await api.items.invMast.doc.list(Number(itemId), {
|
|
254
|
+
...edgeCache != null ? { edgeCache } : {}
|
|
255
|
+
});
|
|
256
|
+
if (!response.data) throw new Error("Item not found");
|
|
257
|
+
return response.data;
|
|
258
|
+
},
|
|
259
|
+
itemId
|
|
260
|
+
);
|
|
261
|
+
},
|
|
262
|
+
staleTime: _optionalChain([tier, 'optionalAccess', _41 => _41.staleTime]),
|
|
263
|
+
gcTime: _optionalChain([tier, 'optionalAccess', _42 => _42.gcTime])
|
|
264
|
+
};
|
|
265
|
+
};
|
|
266
|
+
|
|
267
|
+
// src/queries/item-attributes.ts
|
|
268
|
+
var getItemAttributesKey = (itemCategoryUid) => {
|
|
269
|
+
return ["itemAttributes", itemCategoryUid];
|
|
270
|
+
};
|
|
271
|
+
var getItemAttributesOptions = (api, itemCategoryUid, cache) => {
|
|
272
|
+
const tier = _optionalChain([cache, 'optionalAccess', _43 => _43.static]);
|
|
273
|
+
return {
|
|
274
|
+
queryKey: getItemAttributesKey(itemCategoryUid),
|
|
275
|
+
queryFn: async () => {
|
|
276
|
+
const edgeCache = _optionalChain([tier, 'optionalAccess', _44 => _44.edgeCache]);
|
|
277
|
+
return withCache(
|
|
278
|
+
_optionalChain([cache, 'optionalAccess', _45 => _45.provider]),
|
|
279
|
+
tier,
|
|
280
|
+
"openSearch.itemSearch.attributes.list",
|
|
281
|
+
async () => {
|
|
282
|
+
const response = await api.openSearch.itemSearch.attributes.list({
|
|
283
|
+
q: "",
|
|
284
|
+
searchType: "query",
|
|
285
|
+
classId5List: String(itemCategoryUid),
|
|
286
|
+
...edgeCache != null ? { edgeCache } : {}
|
|
287
|
+
});
|
|
288
|
+
return response.data;
|
|
289
|
+
},
|
|
290
|
+
itemCategoryUid
|
|
291
|
+
);
|
|
292
|
+
},
|
|
293
|
+
staleTime: _optionalChain([tier, 'optionalAccess', _46 => _46.staleTime]),
|
|
294
|
+
gcTime: _optionalChain([tier, 'optionalAccess', _47 => _47.gcTime])
|
|
295
|
+
};
|
|
296
|
+
};
|
|
297
|
+
|
|
298
|
+
// src/queries/product-search.ts
|
|
299
|
+
var getProductSearchKey = (pageData) => {
|
|
300
|
+
return [
|
|
301
|
+
"productSearch",
|
|
302
|
+
pageData.q,
|
|
303
|
+
pageData.limit,
|
|
304
|
+
pageData.offset,
|
|
305
|
+
pageData.sortBy,
|
|
306
|
+
pageData.itemCategoryUid
|
|
307
|
+
];
|
|
308
|
+
};
|
|
309
|
+
var getProductSearchOptions = (api, pageData, cache) => {
|
|
310
|
+
const tier = _optionalChain([cache, 'optionalAccess', _48 => _48.semiStatic]);
|
|
311
|
+
return {
|
|
312
|
+
queryKey: getProductSearchKey(pageData),
|
|
313
|
+
queryFn: async () => {
|
|
314
|
+
const edgeCache = _optionalChain([tier, 'optionalAccess', _49 => _49.edgeCache]);
|
|
315
|
+
return withCache(
|
|
316
|
+
_optionalChain([cache, 'optionalAccess', _50 => _50.provider]),
|
|
317
|
+
tier,
|
|
318
|
+
"openSearch.itemSearch.list",
|
|
319
|
+
async () => {
|
|
320
|
+
const response = await api.openSearch.itemSearch.list({
|
|
321
|
+
q: pageData.q,
|
|
322
|
+
searchType: "query",
|
|
323
|
+
size: pageData.limit,
|
|
324
|
+
from: pageData.offset,
|
|
325
|
+
classId5List: pageData.itemCategoryUid ? String(pageData.itemCategoryUid) : void 0,
|
|
326
|
+
filters: pageData.filters ? JSON.stringify(pageData.filters) : void 0,
|
|
327
|
+
...edgeCache != null ? { edgeCache } : {}
|
|
328
|
+
});
|
|
329
|
+
return response.data;
|
|
330
|
+
},
|
|
331
|
+
pageData
|
|
332
|
+
);
|
|
333
|
+
},
|
|
334
|
+
staleTime: _optionalChain([tier, 'optionalAccess', _51 => _51.staleTime]),
|
|
335
|
+
gcTime: _optionalChain([tier, 'optionalAccess', _52 => _52.gcTime])
|
|
336
|
+
};
|
|
337
|
+
};
|
|
338
|
+
|
|
339
|
+
// src/queries/search-suggestions.ts
|
|
340
|
+
var getSearchSuggestionsKey = (query, limit, offset) => {
|
|
341
|
+
return ["searchSuggestions", query, limit, offset];
|
|
342
|
+
};
|
|
343
|
+
var getSearchSuggestionsOptions = (api, query, limit = 10, offset = 0, cache) => {
|
|
344
|
+
const tier = _optionalChain([cache, 'optionalAccess', _53 => _53.static]);
|
|
345
|
+
return {
|
|
346
|
+
queryKey: getSearchSuggestionsKey(query, limit, offset),
|
|
347
|
+
queryFn: async () => {
|
|
348
|
+
const edgeCache = _optionalChain([tier, 'optionalAccess', _54 => _54.edgeCache]);
|
|
349
|
+
return withCache(
|
|
350
|
+
_optionalChain([cache, 'optionalAccess', _55 => _55.provider]),
|
|
351
|
+
tier,
|
|
352
|
+
"openSearch.suggestions.suggest.list",
|
|
353
|
+
async () => {
|
|
354
|
+
const response = await api.openSearch.suggestions.suggest.list({
|
|
355
|
+
q: query,
|
|
356
|
+
size: limit,
|
|
357
|
+
from: offset,
|
|
358
|
+
...edgeCache != null ? { edgeCache } : {}
|
|
359
|
+
});
|
|
360
|
+
return response.data;
|
|
361
|
+
},
|
|
362
|
+
query,
|
|
363
|
+
limit,
|
|
364
|
+
offset
|
|
365
|
+
);
|
|
366
|
+
},
|
|
367
|
+
staleTime: _optionalChain([tier, 'optionalAccess', _56 => _56.staleTime]),
|
|
368
|
+
gcTime: _optionalChain([tier, 'optionalAccess', _57 => _57.gcTime])
|
|
369
|
+
};
|
|
370
|
+
};
|
|
371
|
+
|
|
372
|
+
// src/queries/cart-pricing.ts
|
|
373
|
+
function getCartPricingQueryOptions(api, cartLines, customerId, cache) {
|
|
374
|
+
return cartLines.map((line) => ({
|
|
375
|
+
...getItemPriceOptions(api, line.itemId, customerId, line.quantity, cache),
|
|
376
|
+
enabled: !!customerId && !!line.itemId
|
|
377
|
+
}));
|
|
378
|
+
}
|
|
379
|
+
|
|
380
|
+
// src/queries/category-items-infinite.ts
|
|
381
|
+
var getCategoryItemsInfiniteKey = (itemCategoryUid, itemsFilters) => {
|
|
382
|
+
return [
|
|
383
|
+
"categoryItemsInfinite",
|
|
384
|
+
itemCategoryUid,
|
|
385
|
+
stableStringify(itemsFilters)
|
|
386
|
+
];
|
|
387
|
+
};
|
|
388
|
+
var getCategoryItemsInfiniteOptions = (api, itemCategoryUid, itemsFilters, cache) => {
|
|
389
|
+
const tier = _optionalChain([cache, 'optionalAccess', _58 => _58.semiStatic]);
|
|
390
|
+
return {
|
|
391
|
+
queryKey: getCategoryItemsInfiniteKey(itemCategoryUid, itemsFilters),
|
|
392
|
+
queryFn: async ({
|
|
393
|
+
pageParam = 0
|
|
394
|
+
}) => {
|
|
395
|
+
const edgeCache = _optionalChain([tier, 'optionalAccess', _59 => _59.edgeCache]);
|
|
396
|
+
return withCache(
|
|
397
|
+
_optionalChain([cache, 'optionalAccess', _60 => _60.provider]),
|
|
398
|
+
tier,
|
|
399
|
+
"openSearch.itemSearch.list",
|
|
400
|
+
async () => {
|
|
401
|
+
const response = await api.openSearch.itemSearch.list({
|
|
402
|
+
q: itemsFilters.q || "",
|
|
403
|
+
searchType: "query",
|
|
404
|
+
size: itemsFilters.limit,
|
|
405
|
+
from: pageParam,
|
|
406
|
+
classId5List: String(itemCategoryUid),
|
|
407
|
+
filters: _optionalChain([itemsFilters, 'access', _61 => _61.filters, 'optionalAccess', _62 => _62.length]) ? JSON.stringify(itemsFilters.filters) : void 0,
|
|
408
|
+
...edgeCache != null ? { edgeCache } : {}
|
|
409
|
+
});
|
|
410
|
+
const items = _nullishCoalesce(_optionalChain([response, 'access', _63 => _63.data, 'optionalAccess', _64 => _64.items]), () => ( []));
|
|
411
|
+
const total = _nullishCoalesce(_optionalChain([response, 'access', _65 => _65.data, 'optionalAccess', _66 => _66.totalResults]), () => ( 0));
|
|
412
|
+
const nextOffset = pageParam + itemsFilters.limit;
|
|
413
|
+
return {
|
|
414
|
+
data: items,
|
|
415
|
+
total,
|
|
416
|
+
nextCursor: nextOffset < total ? nextOffset : void 0
|
|
417
|
+
};
|
|
418
|
+
},
|
|
419
|
+
itemCategoryUid,
|
|
420
|
+
itemsFilters,
|
|
421
|
+
pageParam
|
|
422
|
+
);
|
|
423
|
+
},
|
|
424
|
+
initialPageParam: 0,
|
|
425
|
+
getNextPageParam: (lastPage) => lastPage.nextCursor,
|
|
426
|
+
staleTime: _optionalChain([tier, 'optionalAccess', _67 => _67.staleTime]),
|
|
427
|
+
gcTime: _optionalChain([tier, 'optionalAccess', _68 => _68.gcTime])
|
|
428
|
+
};
|
|
429
|
+
};
|
|
430
|
+
|
|
431
|
+
// src/queries/item-search-infinite.ts
|
|
432
|
+
var getItemSearchInfiniteKey = (itemsFilters, itemCategoryUid) => {
|
|
433
|
+
return [
|
|
434
|
+
"itemSearchInfinite",
|
|
435
|
+
stableStringify(itemsFilters),
|
|
436
|
+
itemCategoryUid
|
|
437
|
+
];
|
|
438
|
+
};
|
|
439
|
+
var getItemSearchInfiniteOptions = (api, itemsFilters, itemCategoryUid, cache) => {
|
|
440
|
+
const tier = _optionalChain([cache, 'optionalAccess', _69 => _69.semiStatic]);
|
|
441
|
+
return {
|
|
442
|
+
queryKey: getItemSearchInfiniteKey(itemsFilters, itemCategoryUid),
|
|
443
|
+
queryFn: async ({
|
|
444
|
+
pageParam = 0
|
|
445
|
+
}) => {
|
|
446
|
+
const edgeCache = _optionalChain([tier, 'optionalAccess', _70 => _70.edgeCache]);
|
|
447
|
+
return withCache(
|
|
448
|
+
_optionalChain([cache, 'optionalAccess', _71 => _71.provider]),
|
|
449
|
+
tier,
|
|
450
|
+
"openSearch.itemSearch.list",
|
|
451
|
+
async () => {
|
|
452
|
+
const response = await api.openSearch.itemSearch.list({
|
|
453
|
+
q: itemsFilters.q,
|
|
454
|
+
searchType: "query",
|
|
455
|
+
size: itemsFilters.limit,
|
|
456
|
+
from: pageParam,
|
|
457
|
+
classId5List: itemCategoryUid ? String(itemCategoryUid) : void 0,
|
|
458
|
+
filters: _optionalChain([itemsFilters, 'access', _72 => _72.filters, 'optionalAccess', _73 => _73.length]) ? JSON.stringify(itemsFilters.filters) : void 0,
|
|
459
|
+
...edgeCache != null ? { edgeCache } : {}
|
|
460
|
+
});
|
|
461
|
+
const items = _nullishCoalesce(_optionalChain([response, 'access', _74 => _74.data, 'optionalAccess', _75 => _75.items]), () => ( []));
|
|
462
|
+
const total = _nullishCoalesce(_optionalChain([response, 'access', _76 => _76.data, 'optionalAccess', _77 => _77.totalResults]), () => ( 0));
|
|
463
|
+
const nextOffset = pageParam + itemsFilters.limit;
|
|
464
|
+
return {
|
|
465
|
+
data: items,
|
|
466
|
+
total,
|
|
467
|
+
nextCursor: nextOffset < total ? nextOffset : void 0
|
|
468
|
+
};
|
|
469
|
+
},
|
|
470
|
+
itemsFilters,
|
|
471
|
+
itemCategoryUid,
|
|
472
|
+
pageParam
|
|
473
|
+
);
|
|
474
|
+
},
|
|
475
|
+
initialPageParam: 0,
|
|
476
|
+
getNextPageParam: (lastPage) => lastPage.nextCursor,
|
|
477
|
+
staleTime: _optionalChain([tier, 'optionalAccess', _78 => _78.staleTime]),
|
|
478
|
+
gcTime: _optionalChain([tier, 'optionalAccess', _79 => _79.gcTime]),
|
|
479
|
+
meta: { persist: true }
|
|
480
|
+
};
|
|
481
|
+
};
|
|
482
|
+
|
|
483
|
+
// src/queries/joomla-content.ts
|
|
484
|
+
var getJoomlaContentKey = (articleId) => {
|
|
485
|
+
return ["joomlaContent", articleId];
|
|
486
|
+
};
|
|
487
|
+
var getJoomlaContentOptions = (api, articleId, cache) => {
|
|
488
|
+
const tier = _optionalChain([cache, 'optionalAccess', _80 => _80.static]);
|
|
489
|
+
return {
|
|
490
|
+
queryKey: getJoomlaContentKey(articleId),
|
|
491
|
+
queryFn: async () => {
|
|
492
|
+
const edgeCache = _optionalChain([tier, 'optionalAccess', _81 => _81.edgeCache]);
|
|
493
|
+
return withCache(
|
|
494
|
+
_optionalChain([cache, 'optionalAccess', _82 => _82.provider]),
|
|
495
|
+
tier,
|
|
496
|
+
"joomla.content.doc.get",
|
|
497
|
+
async () => {
|
|
498
|
+
const response = await api.joomla.content.doc.get(articleId, {
|
|
499
|
+
...edgeCache != null ? { edgeCache } : {}
|
|
500
|
+
});
|
|
501
|
+
if (!response.data) throw new Error("Article not found");
|
|
502
|
+
return response.data;
|
|
503
|
+
},
|
|
504
|
+
articleId
|
|
505
|
+
);
|
|
506
|
+
},
|
|
507
|
+
staleTime: _optionalChain([tier, 'optionalAccess', _83 => _83.staleTime]),
|
|
508
|
+
gcTime: _optionalChain([tier, 'optionalAccess', _84 => _84.gcTime])
|
|
509
|
+
};
|
|
510
|
+
};
|
|
511
|
+
|
|
512
|
+
// src/queries/joomla-content-list.ts
|
|
513
|
+
var getJoomlaContentListKey = (categoryId, filters) => {
|
|
514
|
+
return ["joomlaContentList", categoryId, filters];
|
|
515
|
+
};
|
|
516
|
+
var getJoomlaContentListOptions = (api, categoryId, filters, cache) => {
|
|
517
|
+
const tier = _optionalChain([cache, 'optionalAccess', _85 => _85.semiStatic]);
|
|
518
|
+
return {
|
|
519
|
+
queryKey: getJoomlaContentListKey(categoryId, filters),
|
|
520
|
+
queryFn: async () => {
|
|
521
|
+
const edgeCache = _optionalChain([tier, 'optionalAccess', _86 => _86.edgeCache]);
|
|
522
|
+
return withCache(
|
|
523
|
+
_optionalChain([cache, 'optionalAccess', _87 => _87.provider]),
|
|
524
|
+
tier,
|
|
525
|
+
"joomla.content.list",
|
|
526
|
+
async () => {
|
|
527
|
+
const response = await api.joomla.content.list({
|
|
528
|
+
catid: categoryId,
|
|
529
|
+
...filters,
|
|
530
|
+
...edgeCache != null ? { edgeCache } : {}
|
|
531
|
+
});
|
|
532
|
+
return _nullishCoalesce(response.data, () => ( []));
|
|
533
|
+
},
|
|
534
|
+
categoryId,
|
|
535
|
+
filters
|
|
536
|
+
);
|
|
537
|
+
},
|
|
538
|
+
staleTime: _optionalChain([tier, 'optionalAccess', _88 => _88.staleTime]),
|
|
539
|
+
gcTime: _optionalChain([tier, 'optionalAccess', _89 => _89.gcTime])
|
|
540
|
+
};
|
|
541
|
+
};
|
|
542
|
+
|
|
543
|
+
|
|
544
|
+
|
|
545
|
+
|
|
546
|
+
|
|
547
|
+
|
|
548
|
+
|
|
549
|
+
|
|
550
|
+
|
|
551
|
+
|
|
552
|
+
|
|
553
|
+
|
|
554
|
+
|
|
555
|
+
|
|
556
|
+
|
|
557
|
+
|
|
558
|
+
|
|
559
|
+
|
|
560
|
+
|
|
561
|
+
|
|
562
|
+
|
|
563
|
+
|
|
564
|
+
|
|
565
|
+
|
|
566
|
+
|
|
567
|
+
|
|
568
|
+
|
|
569
|
+
|
|
570
|
+
|
|
571
|
+
|
|
572
|
+
|
|
573
|
+
|
|
574
|
+
exports.stableStringify = stableStringify; exports.getItemPriceKey = getItemPriceKey; exports.getItemPriceOptions = getItemPriceOptions; exports.getInvMastDocKey = getInvMastDocKey; exports.getInvMastDocOptions = getInvMastDocOptions; exports.getItemCategoryKey = getItemCategoryKey; exports.getItemCategoryOptions = getItemCategoryOptions; exports.getInvMastKey = getInvMastKey; exports.getInvMastOptions = getInvMastOptions; exports.getInvMastStockKey = getInvMastStockKey; exports.getInvMastStockOptions = getInvMastStockOptions; exports.getProductCategoryKey = getProductCategoryKey; exports.getProductCategoryOptions = getProductCategoryOptions; exports.getItemDetailsKey = getItemDetailsKey; exports.getItemDetailsOptions = getItemDetailsOptions; exports.getItemAttributesKey = getItemAttributesKey; exports.getItemAttributesOptions = getItemAttributesOptions; exports.getProductSearchKey = getProductSearchKey; exports.getProductSearchOptions = getProductSearchOptions; exports.getSearchSuggestionsKey = getSearchSuggestionsKey; exports.getSearchSuggestionsOptions = getSearchSuggestionsOptions; exports.getCartPricingQueryOptions = getCartPricingQueryOptions; exports.getCategoryItemsInfiniteKey = getCategoryItemsInfiniteKey; exports.getCategoryItemsInfiniteOptions = getCategoryItemsInfiniteOptions; exports.getItemSearchInfiniteKey = getItemSearchInfiniteKey; exports.getItemSearchInfiniteOptions = getItemSearchInfiniteOptions; exports.getJoomlaContentKey = getJoomlaContentKey; exports.getJoomlaContentOptions = getJoomlaContentOptions; exports.getJoomlaContentListKey = getJoomlaContentListKey; exports.getJoomlaContentListOptions = getJoomlaContentListOptions;
|
|
575
|
+
//# sourceMappingURL=chunk-4CNSPZ7Q.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["/home/runner/work/augur-packages/augur-packages/packages/augur-hooks/dist/chunk-4CNSPZ7Q.cjs","../src/queries/stable-stringify.ts","../src/queries/cache-helper.ts","../src/queries/item-price.ts","../src/queries/inv-mast-doc.ts","../src/queries/item-category.ts","../src/queries/inv-mast.ts","../src/queries/inv-mast-stock.ts","../src/queries/product-category.ts","../src/queries/item-details.ts","../src/queries/item-attributes.ts","../src/queries/product-search.ts","../src/queries/search-suggestions.ts","../src/queries/cart-pricing.ts","../src/queries/category-items-infinite.ts","../src/queries/item-search-infinite.ts","../src/queries/joomla-content.ts","../src/queries/joomla-content-list.ts"],"names":[],"mappings":"AAAA;ACIO,SAAS,eAAA,CAAgB,KAAA,EAAwB;AACtD,EAAA,GAAA,CAAI,MAAA,IAAU,KAAA,GAAQ,MAAA,IAAU,KAAA,CAAA,EAAW,OAAO,IAAA,CAAK,SAAA,CAAU,KAAK,CAAA;AACtE,EAAA,GAAA,CAAI,OAAO,MAAA,IAAU,QAAA,EAAU,OAAO,IAAA,CAAK,SAAA,CAAU,KAAK,CAAA;AAC1D,EAAA,GAAA,CAAI,KAAA,CAAM,OAAA,CAAQ,KAAK,CAAA,EAAG;AACxB,IAAA,OAAO,CAAA,CAAA,EAAI,KAAA,CAAM,GAAA,CAAI,eAAe,CAAA,CAAE,IAAA,CAAK,GAAG,CAAC,CAAA,CAAA,CAAA;AAAA,EACjD;AACA,EAAA,MAAM,IAAA,EAAM,KAAA;AACZ,EAAA,MAAM,KAAA,EAAO,MAAA,CAAO,IAAA,CAAK,GAAG,CAAA,CAAE,IAAA,CAAK,CAAA;AACnC,EAAA,MAAM,QAAA,EAAU,IAAA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AAA;AACC,MAAA;AACL,wBAAA;AACA,QAAA;AACA,QAAA;AACA,QAAA;AACE,UAAA;AACE,YAAA;AACD,UAAA;AACG,UAAA;AACJ,UAAA;AACF,QAAA;AACA,QAAA;AACF,MAAA;AACF,IAAA;AACA,IAAA;AACQ,IAAA;AACV,EAAA;AACF;AhB0dc;AACA;AiBvfD;AAIH,EAAA;AACV;AAEa;AAML,EAAA;AACC,EAAA;AACK,IAAA;AACD,IAAA;AACD,MAAA;AACC,MAAA;AACL,wBAAA;AACA,QAAA;AACA,QAAA;AACA,QAAA;AACE,UAAA;AACE,YAAA;AACA,YAAA;AACA,YAAA;AACD,UAAA;AACD,UAAA;AACF,QAAA;AACA,QAAA;AAAY,QAAA;AACd,MAAA;AACF,IAAA;AACA,IAAA;AACQ,IAAA;AACV,EAAA;AACF;AjBifc;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA","file":"/home/runner/work/augur-packages/augur-packages/packages/augur-hooks/dist/chunk-4CNSPZ7Q.cjs","sourcesContent":[null,"/**\n * JSON.stringify with sorted object keys for deterministic cache keys.\n * Ensures { a: 1, b: 2 } and { b: 2, a: 1 } produce the same string.\n */\nexport function stableStringify(value: unknown): string {\n if (value === null || value === undefined) return JSON.stringify(value);\n if (typeof value !== \"object\") return JSON.stringify(value);\n if (Array.isArray(value)) {\n return `[${value.map(stableStringify).join(\",\")}]`;\n }\n const obj = value as Record<string, unknown>;\n const keys = Object.keys(obj).sort();\n const entries = keys.map(\n (key) => `${JSON.stringify(key)}:${stableStringify(obj[key])}`,\n );\n return `{${entries.join(\",\")}}`;\n}\n","import type { CacheProvider, CacheTierConfig } from \"../types\";\nimport { stableStringify } from \"./stable-stringify\";\n\n/**\n * FNV-1a 32-bit hash. Fast, cross-platform (no Node crypto needed).\n */\nfunction fnv1a(str: string): string {\n let h = 0x811c9dc5;\n for (let i = 0; i < str.length; i++) {\n h ^= str.charCodeAt(i);\n h = Math.imul(h, 0x01000193);\n }\n return (h >>> 0).toString(16).padStart(8, \"0\");\n}\n\n/**\n * Wraps an async function with optional Redis caching.\n *\n * - When `provider` and `tier.redis` are both set, checks Redis before\n * calling `fn`, then caches the result on miss.\n * - When either is missing, calls `fn` directly (no-op passthrough).\n *\n * @param provider Redis-compatible get/set + prefix. Undefined = skip Redis.\n * @param tier Cache tier config. Undefined or missing `redis` = skip Redis.\n * @param methodPath Dot-separated SDK method path (used as cache key segment).\n * @param fn The async function to cache (typically the SDK call).\n * @param keyArgs Values to hash for the cache key (e.g. query params).\n */\nexport async function withCache<T>(\n provider: CacheProvider | undefined,\n tier: CacheTierConfig | undefined,\n methodPath: string,\n fn: () => Promise<T>,\n ...keyArgs: unknown[]\n): Promise<T> {\n const redisTtl = tier?.redis;\n if (!provider || !redisTtl) return fn();\n\n const key = `${provider.prefix}sdk:${methodPath}:${fnv1a(stableStringify(keyArgs))}`;\n\n try {\n const cached = await provider.get(key);\n if (cached != null) return JSON.parse(cached) as T;\n } catch {\n /* Redis read error — fall through to SDK call */\n }\n\n const result = await fn();\n\n try {\n provider.set(key, JSON.stringify(result), redisTtl).catch(() => {});\n } catch {\n /* Non-serializable or write error — skip caching */\n }\n\n return result;\n}\n","import type { TPriceData } from \"@simpleapps-com/augur-utils\";\nimport type { AugurApiClient } from \"../provider\";\nimport type { CacheConfig } from \"../types\";\nimport { withCache } from \"./cache-helper\";\n\n/**\n * Generates a consistent query key for item price queries.\n * Usable in both client hooks and server-side prefetch.\n */\nexport const getItemPriceKey = (\n itemId: string | undefined,\n customerId: string | number | undefined,\n quantity: number = 1,\n) => {\n return [\"price\", itemId?.toUpperCase() || \"\", customerId, quantity] as const;\n};\n\n/**\n * Query options for item price. Accepts the SDK instance so it works\n * in both client (via provider) and server (via direct construction).\n */\nexport const getItemPriceOptions = (\n api: AugurApiClient,\n itemId: string | undefined,\n customerId: string | number | undefined,\n quantity: number = 1,\n cache?: CacheConfig,\n) => {\n const tier = cache?.semiStatic;\n return {\n queryKey: getItemPriceKey(itemId, customerId, quantity),\n queryFn: async (): Promise<TPriceData> => {\n const edgeCache = tier?.edgeCache;\n return withCache(\n cache?.provider,\n tier,\n \"pricing.priceEngine.get\",\n async () => {\n const response = await api.pricing.priceEngine.get({\n itemId: itemId?.toUpperCase() || \"\",\n customerId: Number(customerId),\n quantity,\n ...(edgeCache != null ? { edgeCache } : {}),\n });\n return response.data;\n },\n itemId, customerId, quantity,\n );\n },\n staleTime: tier?.staleTime,\n gcTime: tier?.gcTime,\n refetchOnReconnect: true,\n refetchOnWindowFocus: false,\n meta: { persist: true },\n };\n};\n","import type { TInvMastDoc } from \"@simpleapps-com/augur-utils\";\nimport type { AugurApiClient } from \"../provider\";\nimport type { CacheConfig } from \"../types\";\nimport { withCache } from \"./cache-helper\";\n\n/**\n * Generates a consistent query key for inv mast doc queries.\n * Usable in both client hooks and server-side prefetch.\n */\nexport const getInvMastDocKey = (\n invMastUid: number,\n itemId: string,\n includePricing: \"Y\" | \"N\",\n) => {\n return [\n \"invMastDoc\",\n invMastUid,\n itemId.toUpperCase(),\n includePricing,\n ] as const;\n};\n\n/**\n * Query options for inv mast doc. Accepts the SDK instance so it works\n * in both client (via provider) and server (via direct construction).\n */\nexport const getInvMastDocOptions = (\n api: AugurApiClient,\n invMastUid: number,\n itemId: string,\n includePricing: \"Y\" | \"N\",\n cache?: CacheConfig,\n) => {\n const tier = cache?.static;\n return {\n queryKey: getInvMastDocKey(invMastUid, itemId, includePricing),\n queryFn: async (): Promise<TInvMastDoc> => {\n const edgeCache = tier?.edgeCache;\n return withCache(\n cache?.provider,\n tier,\n \"items.invMast.doc.list\",\n async () => {\n const response = await api.items.invMast.doc.list(invMastUid, {\n itemId: itemId.toUpperCase(),\n includePricing,\n ...(edgeCache != null ? { edgeCache } : {}),\n });\n if (!response.data) throw new Error(\"Item not found\");\n return response.data;\n },\n invMastUid,\n itemId,\n includePricing,\n );\n },\n staleTime: tier?.staleTime,\n gcTime: tier?.gcTime,\n };\n};\n","import type { TCategory } from \"@simpleapps-com/augur-utils\";\nimport type { AugurApiClient } from \"../provider\";\nimport type { CacheConfig, GetItemCategoryApiOptions } from \"../types\";\nimport { withCache } from \"./cache-helper\";\n\ntype ItemCategoryQueryKey = readonly [\n \"itemCategory\",\n number,\n GetItemCategoryApiOptions | undefined,\n];\n\n/**\n * Generates a consistent query key for item category queries.\n * Usable in both client hooks and server-side prefetch.\n */\nexport const getItemCategoryKey = (\n itemCategoryUid: number,\n apiOptions?: GetItemCategoryApiOptions,\n): ItemCategoryQueryKey => {\n return [\"itemCategory\", itemCategoryUid, apiOptions] as const;\n};\n\n/**\n * Query options for item category. Accepts the SDK instance so it works\n * in both client (via provider) and server (via direct construction).\n */\nexport const getItemCategoryOptions = (\n api: AugurApiClient,\n itemCategoryUid: number,\n apiOptions?: GetItemCategoryApiOptions,\n cache?: CacheConfig,\n) => {\n const tier = cache?.static;\n return {\n queryKey: getItemCategoryKey(itemCategoryUid, apiOptions),\n queryFn: async (): Promise<TCategory> => {\n const edgeCache = tier?.edgeCache;\n return withCache(\n cache?.provider,\n tier,\n \"items.itemCategory.get\",\n async () => {\n const response = await api.items.itemCategory.get(\n itemCategoryUid,\n { ...apiOptions, ...(edgeCache != null ? { edgeCache } : {}) },\n );\n if (!response.data) throw new Error(\"Item category not found\");\n return response.data;\n },\n itemCategoryUid,\n apiOptions,\n );\n },\n staleTime: tier?.staleTime,\n gcTime: tier?.gcTime,\n };\n};\n","import type { TItemDetails } from \"@simpleapps-com/augur-utils\";\nimport type { AugurApiClient } from \"../provider\";\nimport type { CacheConfig } from \"../types\";\nimport { withCache } from \"./cache-helper\";\n\nexport const getInvMastKey = (invMastUid: number, itemId: string) => {\n return [\"invMast\", invMastUid, itemId.toUpperCase()] as const;\n};\n\nexport const getInvMastOptions = (\n api: AugurApiClient,\n invMastUid: number,\n itemId: string,\n cache?: CacheConfig,\n) => {\n const tier = cache?.static;\n return {\n queryKey: getInvMastKey(invMastUid, itemId),\n queryFn: async (): Promise<TItemDetails> => {\n const edgeCache = tier?.edgeCache;\n return withCache(\n cache?.provider,\n tier,\n \"items.invMast.get\",\n async () => {\n const response = await api.items.invMast.get(invMastUid, {\n ...(edgeCache != null ? { edgeCache } : {}),\n });\n if (!response.data) throw new Error(\"Item not found\");\n return response.data;\n },\n invMastUid,\n );\n },\n staleTime: tier?.staleTime,\n gcTime: tier?.gcTime,\n };\n};\n","import type { TStockData } from \"@simpleapps-com/augur-utils\";\nimport type { AugurApiClient } from \"../provider\";\nimport type { CacheConfig } from \"../types\";\nimport { withCache } from \"./cache-helper\";\n\nexport const getInvMastStockKey = (invMastUid: number | string) => {\n return [\"invMastStock\", invMastUid] as const;\n};\n\nexport const getInvMastStockOptions = (\n api: AugurApiClient,\n invMastUid: number | string,\n cache?: CacheConfig,\n) => {\n const tier = cache?.semiStatic;\n return {\n queryKey: getInvMastStockKey(invMastUid),\n queryFn: async (): Promise<number> => {\n const edgeCache = tier?.edgeCache;\n return withCache(\n cache?.provider,\n tier,\n \"items.invMast.stock.list\",\n async () => {\n const response = await api.items.invMast.stock.list(Number(invMastUid), {\n ...(edgeCache != null ? { edgeCache } : {}),\n });\n const stockData: TStockData[] = response.data?.stockData ?? [];\n return stockData.reduce(\n (qty: number, stock: TStockData) => qty + stock.qtyOnHand,\n 0,\n );\n },\n invMastUid,\n );\n },\n staleTime: tier?.staleTime,\n gcTime: tier?.gcTime,\n };\n};\n","import type { TProductCategory } from \"@simpleapps-com/augur-utils\";\nimport type { AugurApiClient } from \"../provider\";\nimport type { CacheConfig } from \"../types\";\nimport { withCache } from \"./cache-helper\";\n\ntype ProductCategoryResponse = {\n itemCategoryDesc: string;\n childrenTotal: number;\n children: TProductCategory[];\n categoryImage: string | null;\n};\n\nexport const getProductCategoryKey = (\n itemCategoryUid: number | string | null,\n) => {\n return [\"productCategory\", itemCategoryUid] as const;\n};\n\nexport const getProductCategoryOptions = (\n api: AugurApiClient,\n itemCategoryUid: number | string,\n cache?: CacheConfig,\n) => {\n const tier = cache?.static;\n return {\n queryKey: getProductCategoryKey(itemCategoryUid),\n queryFn: async (): Promise<ProductCategoryResponse> => {\n const edgeCache = tier?.edgeCache;\n return withCache(\n cache?.provider,\n tier,\n \"items.itemCategory.get\",\n async () => {\n const response = await api.items.itemCategory.get(Number(itemCategoryUid), {\n ...(edgeCache != null ? { edgeCache } : {}),\n });\n return response.data;\n },\n itemCategoryUid,\n );\n },\n staleTime: tier?.staleTime,\n gcTime: tier?.gcTime,\n };\n};\n","import type { TItemDetails } from \"@simpleapps-com/augur-utils\";\nimport type { AugurApiClient } from \"../provider\";\nimport type { CacheConfig } from \"../types\";\nimport { withCache } from \"./cache-helper\";\n\nexport const getItemDetailsKey = (itemId: number | string) => {\n const normalizedId = typeof itemId === \"string\" ? itemId.toUpperCase() : itemId;\n return [\"itemDetails\", normalizedId] as const;\n};\n\nexport const getItemDetailsOptions = (\n api: AugurApiClient,\n itemId: number | string,\n cache?: CacheConfig,\n) => {\n const tier = cache?.static;\n return {\n queryKey: getItemDetailsKey(itemId),\n queryFn: async (): Promise<TItemDetails> => {\n const edgeCache = tier?.edgeCache;\n return withCache(\n cache?.provider,\n tier,\n \"items.invMast.doc.list\",\n async () => {\n const response = await api.items.invMast.doc.list(Number(itemId), {\n ...(edgeCache != null ? { edgeCache } : {}),\n });\n if (!response.data) throw new Error(\"Item not found\");\n return response.data;\n },\n itemId,\n );\n },\n staleTime: tier?.staleTime,\n gcTime: tier?.gcTime,\n };\n};\n","import type { AugurApiClient } from \"../provider\";\nimport type { CacheConfig } from \"../types\";\nimport { withCache } from \"./cache-helper\";\n\nexport const getItemAttributesKey = (\n itemCategoryUid: number | string | null,\n) => {\n return [\"itemAttributes\", itemCategoryUid] as const;\n};\n\nexport const getItemAttributesOptions = (\n api: AugurApiClient,\n itemCategoryUid: number | string,\n cache?: CacheConfig,\n) => {\n const tier = cache?.static;\n return {\n queryKey: getItemAttributesKey(itemCategoryUid),\n queryFn: async () => {\n const edgeCache = tier?.edgeCache;\n return withCache(\n cache?.provider,\n tier,\n \"openSearch.itemSearch.attributes.list\",\n async () => {\n const response = await api.openSearch.itemSearch.attributes.list({\n q: \"\",\n searchType: \"query\",\n classId5List: String(itemCategoryUid),\n ...(edgeCache != null ? { edgeCache } : {}),\n });\n return response.data;\n },\n itemCategoryUid,\n );\n },\n staleTime: tier?.staleTime,\n gcTime: tier?.gcTime,\n };\n};\n","import type { TProductItem } from \"@simpleapps-com/augur-utils\";\nimport type { AugurApiClient } from \"../provider\";\nimport type { CacheConfig, PageData } from \"../types\";\nimport { withCache } from \"./cache-helper\";\n\ntype ProductSearchResponse = {\n items: TProductItem[];\n totalResults: number;\n};\n\n/**\n * Generates a consistent query key for product search queries.\n */\nexport const getProductSearchKey = (pageData: PageData) => {\n return [\n \"productSearch\",\n pageData.q,\n pageData.limit,\n pageData.offset,\n pageData.sortBy,\n pageData.itemCategoryUid,\n ] as const;\n};\n\n/**\n * Query options for product search. Accepts the SDK instance so it works\n * in both client (via provider) and server (via direct construction).\n */\nexport const getProductSearchOptions = (\n api: AugurApiClient,\n pageData: PageData,\n cache?: CacheConfig,\n) => {\n const tier = cache?.semiStatic;\n return {\n queryKey: getProductSearchKey(pageData),\n queryFn: async (): Promise<ProductSearchResponse> => {\n const edgeCache = tier?.edgeCache;\n return withCache(\n cache?.provider,\n tier,\n \"openSearch.itemSearch.list\",\n async () => {\n const response = await api.openSearch.itemSearch.list({\n q: pageData.q,\n searchType: \"query\",\n size: pageData.limit,\n from: pageData.offset,\n classId5List: pageData.itemCategoryUid\n ? String(pageData.itemCategoryUid)\n : undefined,\n filters: pageData.filters\n ? JSON.stringify(pageData.filters)\n : undefined,\n ...(edgeCache != null ? { edgeCache } : {}),\n });\n return response.data;\n },\n pageData,\n );\n },\n staleTime: tier?.staleTime,\n gcTime: tier?.gcTime,\n };\n};\n","import type { AugurApiClient } from \"../provider\";\nimport type { CacheConfig, SearchSuggestionsResponse } from \"../types\";\nimport { withCache } from \"./cache-helper\";\n\n/**\n * Generates a consistent query key for search suggestion queries.\n */\nexport const getSearchSuggestionsKey = (\n query: string,\n limit: number,\n offset: number,\n) => {\n return [\"searchSuggestions\", query, limit, offset] as const;\n};\n\n/**\n * Query options for search suggestions. Accepts the SDK instance so it works\n * in both client (via provider) and server (via direct construction).\n */\nexport const getSearchSuggestionsOptions = (\n api: AugurApiClient,\n query: string,\n limit: number = 10,\n offset: number = 0,\n cache?: CacheConfig,\n) => {\n const tier = cache?.static;\n return {\n queryKey: getSearchSuggestionsKey(query, limit, offset),\n queryFn: async (): Promise<SearchSuggestionsResponse> => {\n const edgeCache = tier?.edgeCache;\n return withCache(\n cache?.provider,\n tier,\n \"openSearch.suggestions.suggest.list\",\n async () => {\n const response = await api.openSearch.suggestions.suggest.list({\n q: query,\n size: limit,\n from: offset,\n ...(edgeCache != null ? { edgeCache } : {}),\n });\n return response.data;\n },\n query,\n limit,\n offset,\n );\n },\n staleTime: tier?.staleTime,\n gcTime: tier?.gcTime,\n };\n};\n","import type { AugurApiClient } from \"../provider\";\nimport type { CacheConfig } from \"../types\";\nimport { getItemPriceOptions } from \"./item-price\";\n\n/**\n * Get cart pricing query options for prefetching or parent components.\n */\nexport function getCartPricingQueryOptions(\n api: AugurApiClient,\n cartLines: Array<{ itemId: string; quantity: number }>,\n customerId: string | number | undefined,\n cache?: CacheConfig,\n) {\n return cartLines.map((line) => ({\n ...getItemPriceOptions(api, line.itemId, customerId, line.quantity, cache),\n enabled: !!customerId && !!line.itemId,\n }));\n}\n","import {\n type TItemsFilters,\n type TProductItem,\n} from \"@simpleapps-com/augur-utils\";\nimport type { AugurApiClient } from \"../provider\";\nimport type { InfiniteScrollPage } from \"../callbacks\";\nimport type { CacheConfig } from \"../types\";\nimport { withCache } from \"./cache-helper\";\n\nimport { stableStringify } from \"./stable-stringify\";\n\nexport const getCategoryItemsInfiniteKey = (\n itemCategoryUid: number,\n itemsFilters: TItemsFilters,\n) => {\n return [\n \"categoryItemsInfinite\",\n itemCategoryUid,\n stableStringify(itemsFilters),\n ] as const;\n};\n\n/**\n * Full infinite query options for category items.\n * Usable for server-side prefetch with `queryClient.prefetchInfiniteQuery()`.\n */\nexport const getCategoryItemsInfiniteOptions = (\n api: AugurApiClient,\n itemCategoryUid: number,\n itemsFilters: TItemsFilters,\n cache?: CacheConfig,\n) => {\n const tier = cache?.semiStatic;\n return {\n queryKey: getCategoryItemsInfiniteKey(itemCategoryUid, itemsFilters),\n queryFn: async ({\n pageParam = 0,\n }: {\n pageParam?: unknown;\n }): Promise<InfiniteScrollPage> => {\n const edgeCache = tier?.edgeCache;\n return withCache(\n cache?.provider,\n tier,\n \"openSearch.itemSearch.list\",\n async () => {\n const response = await api.openSearch.itemSearch.list({\n q: itemsFilters.q || \"\",\n searchType: \"query\",\n size: itemsFilters.limit,\n from: pageParam as number,\n classId5List: String(itemCategoryUid),\n filters: itemsFilters.filters?.length\n ? JSON.stringify(itemsFilters.filters)\n : undefined,\n ...(edgeCache != null ? { edgeCache } : {}),\n });\n const items: TProductItem[] = response.data?.items ?? [];\n const total: number = response.data?.totalResults ?? 0;\n const nextOffset = (pageParam as number) + itemsFilters.limit;\n return {\n data: items,\n total,\n nextCursor: nextOffset < total ? nextOffset : undefined,\n };\n },\n itemCategoryUid, itemsFilters, pageParam,\n );\n },\n initialPageParam: 0,\n getNextPageParam: (lastPage: InfiniteScrollPage) => lastPage.nextCursor,\n staleTime: tier?.staleTime,\n gcTime: tier?.gcTime,\n };\n};\n","import {\n type TItemsFilters,\n type TProductItem,\n} from \"@simpleapps-com/augur-utils\";\nimport type { AugurApiClient } from \"../provider\";\nimport type { InfiniteScrollPage } from \"../callbacks\";\nimport type { CacheConfig } from \"../types\";\nimport { withCache } from \"./cache-helper\";\n\nimport { stableStringify } from \"./stable-stringify\";\n\nexport const getItemSearchInfiniteKey = (\n itemsFilters: TItemsFilters,\n itemCategoryUid?: number | string,\n) => {\n return [\n \"itemSearchInfinite\",\n stableStringify(itemsFilters),\n itemCategoryUid,\n ] as const;\n};\n\n/**\n * Full infinite query options for item search.\n * Usable for server-side prefetch with `queryClient.prefetchInfiniteQuery()`.\n */\nexport const getItemSearchInfiniteOptions = (\n api: AugurApiClient,\n itemsFilters: TItemsFilters,\n itemCategoryUid?: number | string,\n cache?: CacheConfig,\n) => {\n const tier = cache?.semiStatic;\n return {\n queryKey: getItemSearchInfiniteKey(itemsFilters, itemCategoryUid),\n queryFn: async ({\n pageParam = 0,\n }: {\n pageParam?: unknown;\n }): Promise<InfiniteScrollPage> => {\n const edgeCache = tier?.edgeCache;\n return withCache(\n cache?.provider,\n tier,\n \"openSearch.itemSearch.list\",\n async () => {\n const response = await api.openSearch.itemSearch.list({\n q: itemsFilters.q,\n searchType: \"query\",\n size: itemsFilters.limit,\n from: pageParam as number,\n classId5List: itemCategoryUid ? String(itemCategoryUid) : undefined,\n filters: itemsFilters.filters?.length\n ? JSON.stringify(itemsFilters.filters)\n : undefined,\n ...(edgeCache != null ? { edgeCache } : {}),\n });\n const items: TProductItem[] = response.data?.items ?? [];\n const total: number = response.data?.totalResults ?? 0;\n const nextOffset = (pageParam as number) + itemsFilters.limit;\n return {\n data: items,\n total,\n nextCursor: nextOffset < total ? nextOffset : undefined,\n };\n },\n itemsFilters, itemCategoryUid, pageParam,\n );\n },\n initialPageParam: 0,\n getNextPageParam: (lastPage: InfiniteScrollPage) => lastPage.nextCursor,\n staleTime: tier?.staleTime,\n gcTime: tier?.gcTime,\n meta: { persist: true },\n };\n};\n","import type { TJoomlaContent } from \"@simpleapps-com/augur-utils\";\nimport type { AugurApiClient } from \"../provider\";\nimport type { CacheConfig } from \"../types\";\nimport { withCache } from \"./cache-helper\";\n\nexport const getJoomlaContentKey = (articleId: number | string) => {\n return [\"joomlaContent\", articleId] as const;\n};\n\nexport const getJoomlaContentOptions = (\n api: AugurApiClient,\n articleId: number | string,\n cache?: CacheConfig,\n) => {\n const tier = cache?.static;\n return {\n queryKey: getJoomlaContentKey(articleId),\n queryFn: async (): Promise<TJoomlaContent> => {\n const edgeCache = tier?.edgeCache;\n return withCache(\n cache?.provider,\n tier,\n \"joomla.content.doc.get\",\n async () => {\n const response = await api.joomla.content.doc.get(articleId, {\n ...(edgeCache != null ? { edgeCache } : {}),\n });\n if (!response.data) throw new Error(\"Article not found\");\n return response.data;\n },\n articleId,\n );\n },\n staleTime: tier?.staleTime,\n gcTime: tier?.gcTime,\n };\n};\n","import {\n type TJoomlaContent,\n type TJoomlaContentFilters,\n} from \"@simpleapps-com/augur-utils\";\nimport type { AugurApiClient } from \"../provider\";\nimport type { CacheConfig } from \"../types\";\nimport { withCache } from \"./cache-helper\";\n\nexport const getJoomlaContentListKey = (\n categoryId: number | string,\n filters?: Partial<TJoomlaContentFilters>,\n) => {\n return [\"joomlaContentList\", categoryId, filters] as const;\n};\n\nexport const getJoomlaContentListOptions = (\n api: AugurApiClient,\n categoryId: number | string,\n filters?: Partial<TJoomlaContentFilters>,\n cache?: CacheConfig,\n) => {\n const tier = cache?.semiStatic;\n return {\n queryKey: getJoomlaContentListKey(categoryId, filters),\n queryFn: async (): Promise<TJoomlaContent[]> => {\n const edgeCache = tier?.edgeCache;\n return withCache(\n cache?.provider,\n tier,\n \"joomla.content.list\",\n async () => {\n const response = await api.joomla.content.list({\n catid: categoryId,\n ...filters,\n ...(edgeCache != null ? { edgeCache } : {}),\n });\n return response.data ?? [];\n },\n categoryId, filters,\n );\n },\n staleTime: tier?.staleTime,\n gcTime: tier?.gcTime,\n };\n};\n"]}
|