@simpleapps-com/augur-server 2.3.1 → 2026.11.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/EXPORTS.md +29 -72
- package/README.md +29 -198
- package/dist/actions/agr-info.d.ts +43 -0
- package/dist/actions/agr-info.d.ts.map +1 -0
- package/dist/actions/agr-site.d.ts +37 -0
- package/dist/actions/agr-site.d.ts.map +1 -0
- package/dist/actions/agr-work.d.ts +29 -0
- package/dist/actions/agr-work.d.ts.map +1 -0
- package/dist/actions/avalara.d.ts +38 -0
- package/dist/actions/avalara.d.ts.map +1 -0
- package/dist/actions/basecamp2.d.ts +47 -0
- package/dist/actions/basecamp2.d.ts.map +1 -0
- package/dist/actions/brand-folder.d.ts +38 -0
- package/dist/actions/brand-folder.d.ts.map +1 -0
- package/dist/actions/commerce.d.ts +58 -0
- package/dist/actions/commerce.d.ts.map +1 -0
- package/dist/actions/customers.d.ts +44 -0
- package/dist/actions/customers.d.ts.map +1 -0
- package/dist/actions/favorites.d.ts +20 -0
- package/dist/actions/favorites.d.ts.map +1 -0
- package/dist/actions/gregorovich.d.ts +34 -0
- package/dist/actions/gregorovich.d.ts.map +1 -0
- package/dist/actions/items.d.ts +80 -0
- package/dist/actions/items.d.ts.map +1 -0
- package/dist/actions/joomla.d.ts +59 -0
- package/dist/actions/joomla.d.ts.map +1 -0
- package/dist/actions/legacy.d.ts +45 -0
- package/dist/actions/legacy.d.ts.map +1 -0
- package/dist/actions/logistics.d.ts +40 -0
- package/dist/actions/logistics.d.ts.map +1 -0
- package/dist/actions/orders.d.ts +36 -0
- package/dist/actions/orders.d.ts.map +1 -0
- package/dist/actions/p21-apis.d.ts +33 -0
- package/dist/actions/p21-apis.d.ts.map +1 -0
- package/dist/actions/p21-core.d.ts +46 -0
- package/dist/actions/p21-core.d.ts.map +1 -0
- package/dist/actions/p21-pim.d.ts +36 -0
- package/dist/actions/p21-pim.d.ts.map +1 -0
- package/dist/actions/p21-sism.d.ts +37 -0
- package/dist/actions/p21-sism.d.ts.map +1 -0
- package/dist/actions/payments.d.ts +39 -0
- package/dist/actions/payments.d.ts.map +1 -0
- package/dist/actions/pricing.d.ts +45 -0
- package/dist/actions/pricing.d.ts.map +1 -0
- package/dist/actions/search.d.ts +61 -0
- package/dist/actions/search.d.ts.map +1 -0
- package/dist/actions/shipping.d.ts +56 -0
- package/dist/actions/shipping.d.ts.map +1 -0
- package/dist/actions/site.d.ts +141 -0
- package/dist/actions/site.d.ts.map +1 -0
- package/dist/actions/smarty-streets.d.ts +45 -0
- package/dist/actions/smarty-streets.d.ts.map +1 -0
- package/dist/actions/vmi.d.ts +44 -0
- package/dist/actions/vmi.d.ts.map +1 -0
- package/dist/actions/wishlists.d.ts +28 -0
- package/dist/actions/wishlists.d.ts.map +1 -0
- package/dist/api-handler.d.ts +25 -0
- package/dist/api-handler.d.ts.map +1 -0
- package/dist/api.d.ts +2 -26
- package/dist/api.d.ts.map +1 -0
- package/dist/api.js +19 -14
- package/dist/api.js.map +1 -1
- package/dist/auth.d.ts +10 -12
- package/dist/auth.d.ts.map +1 -0
- package/dist/auth.js +2 -2
- package/dist/cache/redis-client.d.ts +16 -0
- package/dist/cache/redis-client.d.ts.map +1 -0
- package/dist/cache/with-cache.d.ts +18 -0
- package/dist/cache/with-cache.d.ts.map +1 -0
- package/dist/chunk-FWO6Q43T.js +162 -0
- package/dist/chunk-FWO6Q43T.js.map +1 -0
- package/dist/{chunk-HPQQYROJ.js → chunk-NTUPTNOI.js} +40 -7
- package/dist/chunk-NTUPTNOI.js.map +1 -0
- package/dist/{chunk-WOHZDFJF.js → chunk-PFYEMJTQ.js} +212 -642
- package/dist/chunk-PFYEMJTQ.js.map +1 -0
- package/dist/{chunk-KHFEDL47.js → chunk-SXXWBSTX.js} +18 -12
- package/dist/chunk-SXXWBSTX.js.map +1 -0
- package/dist/chunk-TVH5EONP.js +178 -0
- package/dist/chunk-TVH5EONP.js.map +1 -0
- package/dist/{chunk-TQP67TGL.js → chunk-U2BKHRJC.js} +13 -15
- package/dist/chunk-U2BKHRJC.js.map +1 -0
- package/dist/environment.d.ts +10 -0
- package/dist/environment.d.ts.map +1 -0
- package/dist/hooks.d.ts +8 -10
- package/dist/hooks.d.ts.map +1 -0
- package/dist/hooks.js +3 -3
- package/dist/hooks.js.map +1 -1
- package/dist/index.d.ts +16 -125
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +12 -8
- package/dist/index.js.map +1 -1
- package/dist/pagination.d.ts +32 -0
- package/dist/pagination.d.ts.map +1 -0
- package/dist/query-action.d.ts +156 -17
- package/dist/query-action.d.ts.map +1 -0
- package/dist/query-action.js +3 -3
- package/dist/query-options-helper.d.ts +33 -0
- package/dist/query-options-helper.d.ts.map +1 -0
- package/dist/query.js +1 -2
- package/dist/recaptcha.d.ts +6 -0
- package/dist/recaptcha.d.ts.map +1 -0
- package/dist/rules.d.ts +221 -0
- package/dist/rules.d.ts.map +1 -0
- package/dist/scoped-client-key.d.ts +9 -0
- package/dist/scoped-client-key.d.ts.map +1 -0
- package/dist/sdk-call.d.ts +66 -0
- package/dist/sdk-call.d.ts.map +1 -0
- package/dist/sdk-client-store.d.ts +250 -0
- package/dist/sdk-client-store.d.ts.map +1 -0
- package/dist/server-actions.d.ts +2 -0
- package/dist/server-actions.d.ts.map +1 -0
- package/dist/server-query-client.d.ts +19 -0
- package/dist/server-query-client.d.ts.map +1 -0
- package/dist/{server-site-registry-CdBfczOj.d.ts → server-site-registry.d.ts} +7 -9
- package/dist/server-site-registry.d.ts.map +1 -0
- package/dist/{site.d.ts → server-site.d.ts} +11 -16
- package/dist/server-site.d.ts.map +1 -0
- package/dist/site-actions-store.d.ts +27 -0
- package/dist/site-actions-store.d.ts.map +1 -0
- package/dist/site.js +10 -10
- package/dist/site.js.map +1 -1
- package/dist/testing.d.ts +9 -12
- package/dist/testing.d.ts.map +1 -0
- package/dist/testing.js +7 -27
- package/dist/testing.js.map +1 -1
- package/dist/utils/batch-fetch.d.ts +7 -0
- package/dist/utils/batch-fetch.d.ts.map +1 -0
- package/llms.txt +71 -50
- package/package.json +34 -20
- package/dist/actions.d.ts +0 -2
- package/dist/chunk-DGUM43GV.js +0 -11
- package/dist/chunk-DGUM43GV.js.map +0 -1
- package/dist/chunk-HPQQYROJ.js.map +0 -1
- package/dist/chunk-KHFEDL47.js.map +0 -1
- package/dist/chunk-TQP67TGL.js.map +0 -1
- package/dist/chunk-WOHZDFJF.js.map +0 -1
- package/dist/chunk-ZUJZDRTP.js +0 -136
- package/dist/chunk-ZUJZDRTP.js.map +0 -1
- package/dist/query.d.ts +0 -31
- package/dist/site-BjSFqufX.d.ts +0 -469
|
@@ -1,24 +1,36 @@
|
|
|
1
1
|
import {
|
|
2
2
|
registerSdkCallWrapper,
|
|
3
3
|
registerSdkClient
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-NTUPTNOI.js";
|
|
5
5
|
import {
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
circuitCheck,
|
|
7
|
+
configuredModeOf,
|
|
8
|
+
docUidOf,
|
|
9
|
+
envOf,
|
|
10
|
+
hasDocKey,
|
|
11
|
+
hasMoreOf,
|
|
12
|
+
itemsLimitOf,
|
|
13
|
+
nextCursorOf,
|
|
14
|
+
opensAt,
|
|
15
|
+
positiveOrZero,
|
|
16
|
+
recordFailureOf,
|
|
17
|
+
recordSuccessOf,
|
|
18
|
+
scopedPrefix,
|
|
19
|
+
shouldCache,
|
|
20
|
+
takesItemId,
|
|
21
|
+
ttlFor
|
|
22
|
+
} from "./chunk-TVH5EONP.js";
|
|
8
23
|
|
|
9
24
|
// src/environment.ts
|
|
10
25
|
function getEnvironment() {
|
|
11
|
-
const
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
if (host.includes("localhost") || host.includes("127.0.0.1")) return "development";
|
|
20
|
-
if (host.includes("agr-hosting.dev")) return "staging";
|
|
21
|
-
return "production";
|
|
26
|
+
const isServer = typeof window === "undefined";
|
|
27
|
+
return envOf(
|
|
28
|
+
process.env["DEPLOYMENT_ENV"] ?? "",
|
|
29
|
+
isServer,
|
|
30
|
+
process.env["NODE_ENV"] ?? "",
|
|
31
|
+
// The host is read only in the browser, as before.
|
|
32
|
+
isServer ? "" : window.location.hostname
|
|
33
|
+
);
|
|
22
34
|
}
|
|
23
35
|
var env = getEnvironment();
|
|
24
36
|
var isDev = env === "development";
|
|
@@ -26,7 +38,6 @@ var isStaging = env === "staging";
|
|
|
26
38
|
var isProduction = env === "production";
|
|
27
39
|
|
|
28
40
|
// src/cache/redis-client.ts
|
|
29
|
-
var CIRCUIT_BREAKER_THRESHOLD = 5;
|
|
30
41
|
var CIRCUIT_BREAKER_RESET_MS = 6e4;
|
|
31
42
|
var g = globalThis;
|
|
32
43
|
if (!g.__redisState) {
|
|
@@ -43,25 +54,28 @@ function log(...args) {
|
|
|
43
54
|
console.log("[Redis]", ...args);
|
|
44
55
|
}
|
|
45
56
|
}
|
|
57
|
+
function circuit() {
|
|
58
|
+
return { failures: state.consecutiveFailures, openUntil: state.circuitOpenUntil };
|
|
59
|
+
}
|
|
60
|
+
function setCircuit(next) {
|
|
61
|
+
state.consecutiveFailures = next.failures;
|
|
62
|
+
state.circuitOpenUntil = next.openUntil;
|
|
63
|
+
}
|
|
46
64
|
function isCircuitOpen() {
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
return false;
|
|
53
|
-
}
|
|
54
|
-
return true;
|
|
65
|
+
const wasOpen = state.circuitOpenUntil !== 0;
|
|
66
|
+
const answer = circuitCheck(circuit(), Date.now());
|
|
67
|
+
setCircuit(answer.next);
|
|
68
|
+
if (wasOpen && !answer.open) log("Circuit breaker reset -- retrying Redis");
|
|
69
|
+
return answer.open;
|
|
55
70
|
}
|
|
56
71
|
function recordFailure() {
|
|
57
|
-
|
|
58
|
-
if (state.consecutiveFailures
|
|
59
|
-
state.circuitOpenUntil = Date.now() + CIRCUIT_BREAKER_RESET_MS;
|
|
72
|
+
setCircuit(recordFailureOf(circuit(), Date.now()));
|
|
73
|
+
if (opensAt(state.consecutiveFailures)) {
|
|
60
74
|
log(`Circuit breaker OPEN -- skipping Redis for ${CIRCUIT_BREAKER_RESET_MS / 1e3}s`);
|
|
61
75
|
}
|
|
62
76
|
}
|
|
63
77
|
function recordSuccess() {
|
|
64
|
-
|
|
78
|
+
setCircuit(recordSuccessOf(circuit()));
|
|
65
79
|
}
|
|
66
80
|
function getRedisUrl() {
|
|
67
81
|
const containerRedis = process.env["REDIS_SERVERS"];
|
|
@@ -173,7 +187,8 @@ async function batchFetch(params, fetchOne, getKey) {
|
|
|
173
187
|
// src/cache/with-cache.ts
|
|
174
188
|
import { buildCacheKey } from "@simpleapps-com/augur-core";
|
|
175
189
|
async function withServerCache(prefix, redisTtl, methodPath, fn, ...keyArgs) {
|
|
176
|
-
|
|
190
|
+
const ttl = redisTtl === void 0 || Number.isNaN(redisTtl) ? 0 : redisTtl;
|
|
191
|
+
if (!shouldCache(ttl)) return fn();
|
|
177
192
|
const key = buildCacheKey(prefix, methodPath, keyArgs);
|
|
178
193
|
try {
|
|
179
194
|
const cached = await cacheGet(key);
|
|
@@ -182,7 +197,7 @@ async function withServerCache(prefix, redisTtl, methodPath, fn, ...keyArgs) {
|
|
|
182
197
|
}
|
|
183
198
|
const result = await fn();
|
|
184
199
|
try {
|
|
185
|
-
cacheSet(key, JSON.stringify(result),
|
|
200
|
+
cacheSet(key, JSON.stringify(result), ttl).catch(() => {
|
|
186
201
|
});
|
|
187
202
|
} catch {
|
|
188
203
|
}
|
|
@@ -191,12 +206,11 @@ async function withServerCache(prefix, redisTtl, methodPath, fn, ...keyArgs) {
|
|
|
191
206
|
|
|
192
207
|
// src/pagination.ts
|
|
193
208
|
function paginateOffset(items, pageParam, limit, total) {
|
|
194
|
-
const
|
|
195
|
-
const hasMore = total !== void 0 ? (pageParam + 1) * limit < resolvedTotal : items.length === limit;
|
|
209
|
+
const hasMore = hasMoreOf(pageParam, limit, total, items.length);
|
|
196
210
|
return {
|
|
197
211
|
data: items,
|
|
198
|
-
total:
|
|
199
|
-
nextCursor: hasMore
|
|
212
|
+
total: total ?? 0,
|
|
213
|
+
nextCursor: nextCursorOf(hasMore, pageParam),
|
|
200
214
|
hasMore
|
|
201
215
|
};
|
|
202
216
|
}
|
|
@@ -206,9 +220,7 @@ import { createActionsProxy } from "@simpleapps-com/augur-core";
|
|
|
206
220
|
|
|
207
221
|
// src/actions/pricing.ts
|
|
208
222
|
function resolveCustomerId(explicit, fallback) {
|
|
209
|
-
|
|
210
|
-
const num = Number(raw);
|
|
211
|
-
return num > 0 ? num : 0;
|
|
223
|
+
return positiveOrZero(Number(explicit ?? fallback));
|
|
212
224
|
}
|
|
213
225
|
function createPricingActions(api, config = {}) {
|
|
214
226
|
const {
|
|
@@ -241,7 +253,12 @@ function createPricingActions(api, config = {}) {
|
|
|
241
253
|
}
|
|
242
254
|
async function getTaxEstimate(customerId, postalCode, items = []) {
|
|
243
255
|
const custId = resolveCustomerId(customerId, defaultCustomerId);
|
|
244
|
-
const params = {
|
|
256
|
+
const params = {
|
|
257
|
+
customerId: custId,
|
|
258
|
+
postalCode: postalCode ?? "",
|
|
259
|
+
items,
|
|
260
|
+
edgeCache
|
|
261
|
+
};
|
|
245
262
|
return withServerCache(
|
|
246
263
|
cachePrefix,
|
|
247
264
|
taxRedisTtl,
|
|
@@ -257,6 +274,7 @@ function createPricingActions(api, config = {}) {
|
|
|
257
274
|
}
|
|
258
275
|
|
|
259
276
|
// src/actions/items.ts
|
|
277
|
+
import { categorySortBy } from "@simpleapps-com/augur-utils";
|
|
260
278
|
function createItemActions(api, config = {}) {
|
|
261
279
|
const {
|
|
262
280
|
cachePrefix = "",
|
|
@@ -287,10 +305,12 @@ function createItemActions(api, config = {}) {
|
|
|
287
305
|
);
|
|
288
306
|
}
|
|
289
307
|
async function getItemCategory(uid, options) {
|
|
290
|
-
const
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
308
|
+
const { filters, ...rest } = options ?? {};
|
|
309
|
+
const sdkParams = {
|
|
310
|
+
...rest,
|
|
311
|
+
edgeCache,
|
|
312
|
+
...filters ? { filters: JSON.stringify(filters) } : {}
|
|
313
|
+
};
|
|
294
314
|
const category = await withServerCache(
|
|
295
315
|
cachePrefix,
|
|
296
316
|
redisTtl,
|
|
@@ -302,12 +322,9 @@ function createItemActions(api, config = {}) {
|
|
|
302
322
|
uid,
|
|
303
323
|
options
|
|
304
324
|
);
|
|
305
|
-
const cat = category;
|
|
306
325
|
return {
|
|
307
|
-
...
|
|
308
|
-
|
|
309
|
-
categoryImage: cat.categoryImage || null,
|
|
310
|
-
children: sortCategoryChildren(cat.children)
|
|
326
|
+
...category,
|
|
327
|
+
children: sortCategoryChildren(category.children)
|
|
311
328
|
};
|
|
312
329
|
}
|
|
313
330
|
function buildCategoryParams(itemsFilters, overrides) {
|
|
@@ -322,55 +339,46 @@ function createItemActions(api, config = {}) {
|
|
|
322
339
|
params["filters"] = JSON.stringify([]);
|
|
323
340
|
params["q"] = "";
|
|
324
341
|
params["sortBy"] = "desc";
|
|
325
|
-
|
|
326
|
-
|
|
342
|
+
params["limit"] = overrides?.limit;
|
|
343
|
+
params["offset"] = overrides?.offset;
|
|
327
344
|
}
|
|
328
345
|
return params;
|
|
329
346
|
}
|
|
330
347
|
function isItemsFilters(v) {
|
|
331
348
|
return Array.isArray(v.filters);
|
|
332
349
|
}
|
|
333
|
-
|
|
334
|
-
const
|
|
335
|
-
if (
|
|
336
|
-
|
|
337
|
-
|
|
350
|
+
function applySortByPrefix(params) {
|
|
351
|
+
const sortBy = params["sortBy"];
|
|
352
|
+
if (typeof sortBy === "string") params["sortBy"] = categorySortBy(sortByPrefix ?? "", sortBy);
|
|
353
|
+
}
|
|
354
|
+
function listCategoryItems(uid, params) {
|
|
338
355
|
return withServerCache(
|
|
339
356
|
cachePrefix,
|
|
340
357
|
redisTtl,
|
|
341
358
|
"items.categories.items.list",
|
|
342
359
|
async () => {
|
|
343
360
|
const response = await api.items.categories.items.list(uid, {
|
|
344
|
-
...
|
|
361
|
+
...params,
|
|
345
362
|
edgeCache
|
|
346
363
|
});
|
|
347
364
|
return response.data;
|
|
348
365
|
},
|
|
349
366
|
uid,
|
|
350
|
-
|
|
367
|
+
params
|
|
351
368
|
);
|
|
352
369
|
}
|
|
370
|
+
async function getCategoryItems(uid, filters) {
|
|
371
|
+
const merged = isItemsFilters(filters) ? buildCategoryParams(filters) : { ...filters };
|
|
372
|
+
applySortByPrefix(merged);
|
|
373
|
+
return listCategoryItems(uid, merged);
|
|
374
|
+
}
|
|
353
375
|
async function getCategoryItemsInfinite(uid, itemsFilters, pageParam = 0) {
|
|
354
|
-
const
|
|
376
|
+
const given = itemsFilters?.limit;
|
|
377
|
+
const limit = itemsLimitOf(given === void 0 || Number.isNaN(given) ? void 0 : given);
|
|
355
378
|
const offset = pageParam * limit;
|
|
356
379
|
const merged = buildCategoryParams(itemsFilters, { limit, offset });
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
}
|
|
360
|
-
const result = await withServerCache(
|
|
361
|
-
cachePrefix,
|
|
362
|
-
redisTtl,
|
|
363
|
-
"items.categories.items.list",
|
|
364
|
-
async () => {
|
|
365
|
-
const response = await api.items.categories.items.list(uid, {
|
|
366
|
-
...merged,
|
|
367
|
-
edgeCache
|
|
368
|
-
});
|
|
369
|
-
return response.data;
|
|
370
|
-
},
|
|
371
|
-
uid,
|
|
372
|
-
merged
|
|
373
|
-
);
|
|
380
|
+
applySortByPrefix(merged);
|
|
381
|
+
const result = await listCategoryItems(uid, merged);
|
|
374
382
|
const items = result.items || [];
|
|
375
383
|
const total = result.total || 0;
|
|
376
384
|
return paginateOffset(items, pageParam, limit, total);
|
|
@@ -403,11 +411,11 @@ function createItemActions(api, config = {}) {
|
|
|
403
411
|
}
|
|
404
412
|
async function getInvMastDoc(paramsOrUid, itemIdArg, includePricingArg) {
|
|
405
413
|
const params = typeof paramsOrUid === "number" ? {
|
|
406
|
-
invMastUid: paramsOrUid
|
|
407
|
-
itemId: paramsOrUid
|
|
414
|
+
invMastUid: docUidOf(paramsOrUid),
|
|
415
|
+
itemId: takesItemId(paramsOrUid, itemIdArg ?? "") ? itemIdArg.toUpperCase().trim() : void 0,
|
|
408
416
|
includePricing: includePricingArg
|
|
409
417
|
} : paramsOrUid;
|
|
410
|
-
if (!params.invMastUid
|
|
418
|
+
if (!hasDocKey(!!params.invMastUid, params.itemId ?? "")) {
|
|
411
419
|
throw new Error("Either invMastUid must be positive or itemId must be provided");
|
|
412
420
|
}
|
|
413
421
|
return withServerCache(
|
|
@@ -546,14 +554,19 @@ function createItemActions(api, config = {}) {
|
|
|
546
554
|
function createCommerceActions(api, config = {}) {
|
|
547
555
|
const { defaultContactId, defaultCustomerId, convertUnitOfMeasure } = config;
|
|
548
556
|
async function cartHdrLookup(params) {
|
|
549
|
-
const
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
if (lookupParams["customerId"] == null && defaultCustomerId != null) {
|
|
554
|
-
lookupParams["customerId"] = defaultCustomerId;
|
|
557
|
+
const contactId = params.contactId ?? defaultContactId;
|
|
558
|
+
const customerId = params.customerId ?? defaultCustomerId;
|
|
559
|
+
if (contactId == null || customerId == null) {
|
|
560
|
+
throw new Error("cartHdrLookup requires contactId and customerId (param or config default)");
|
|
555
561
|
}
|
|
556
|
-
const response = await api.commerce.cartHdr.lookup.get(
|
|
562
|
+
const response = await api.commerce.cartHdr.lookup.get({
|
|
563
|
+
// SDK: userId 0 = anonymous cart keyed on cartToken.
|
|
564
|
+
// `|| 0` also maps a non-numeric userId (NaN) to anonymous, as auth.ts does.
|
|
565
|
+
userId: Number(params.userId) || 0,
|
|
566
|
+
cartToken: params.cartToken,
|
|
567
|
+
contactId: Number(contactId),
|
|
568
|
+
customerId: Number(customerId)
|
|
569
|
+
});
|
|
557
570
|
return response.data;
|
|
558
571
|
}
|
|
559
572
|
async function getCartLines(cartHdrUid) {
|
|
@@ -565,11 +578,7 @@ function createCommerceActions(api, config = {}) {
|
|
|
565
578
|
...item,
|
|
566
579
|
unitOfMeasure: convertUnitOfMeasure ? convertUnitOfMeasure(item.unitOfMeasure) : item.unitOfMeasure
|
|
567
580
|
}));
|
|
568
|
-
const response = await api.commerce.cartLine.add.create(
|
|
569
|
-
cartHdrUid,
|
|
570
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
571
|
-
mappedItems
|
|
572
|
-
);
|
|
581
|
+
const response = await api.commerce.cartLine.add.create(cartHdrUid, mappedItems);
|
|
573
582
|
return response.data;
|
|
574
583
|
}
|
|
575
584
|
async function updateCartLines(cartHdrUid, lines) {
|
|
@@ -577,11 +586,7 @@ function createCommerceActions(api, config = {}) {
|
|
|
577
586
|
...line,
|
|
578
587
|
unitOfMeasure: convertUnitOfMeasure ? convertUnitOfMeasure(line.unitOfMeasure) : line.unitOfMeasure
|
|
579
588
|
}));
|
|
580
|
-
const response = await api.commerce.cartLine.update.create(
|
|
581
|
-
cartHdrUid,
|
|
582
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
583
|
-
mappedLines
|
|
584
|
-
);
|
|
589
|
+
const response = await api.commerce.cartLine.update.create(cartHdrUid, mappedLines);
|
|
585
590
|
return response.data;
|
|
586
591
|
}
|
|
587
592
|
async function deleteCartItems(cartHdrUid) {
|
|
@@ -620,55 +625,56 @@ function createSearchActions(api, config = {}) {
|
|
|
620
625
|
redisTtl = 3600,
|
|
621
626
|
defaultSourceFields = "display_desc"
|
|
622
627
|
} = config;
|
|
623
|
-
const openSearch = api.
|
|
628
|
+
const openSearch = api.openSearch;
|
|
624
629
|
async function getSearchAttributes(q) {
|
|
625
|
-
const params = {
|
|
630
|
+
const params = {
|
|
631
|
+
q,
|
|
632
|
+
searchType: "query",
|
|
633
|
+
edgeCache
|
|
634
|
+
};
|
|
626
635
|
return withServerCache(
|
|
627
636
|
cachePrefix,
|
|
628
637
|
redisTtl,
|
|
629
638
|
"openSearch.itemSearch.attributes.list",
|
|
630
639
|
async () => {
|
|
631
|
-
const response = (
|
|
632
|
-
|
|
633
|
-
await openSearch.itemSearch.attributes.list(params)
|
|
634
|
-
);
|
|
635
|
-
return {
|
|
636
|
-
attributes: response.data.attributes
|
|
637
|
-
};
|
|
640
|
+
const response = await openSearch.itemSearch.attributes.list(params);
|
|
641
|
+
return { attributes: response.data.attributes };
|
|
638
642
|
},
|
|
639
643
|
q
|
|
640
644
|
);
|
|
641
645
|
}
|
|
642
646
|
async function getSearchSuggestions(q, limit, offset) {
|
|
643
|
-
const params = { q, edgeCache };
|
|
644
|
-
if (limit !== void 0) params["size"] = limit;
|
|
645
|
-
if (offset !== void 0) params["from"] = offset;
|
|
647
|
+
const params = { q, limit, offset, edgeCache };
|
|
646
648
|
return withServerCache(
|
|
647
649
|
cachePrefix,
|
|
648
650
|
redisTtl,
|
|
649
651
|
"openSearch.suggestions.suggest.list",
|
|
650
652
|
async () => {
|
|
651
|
-
const response = (
|
|
652
|
-
|
|
653
|
-
await openSearch.suggestions.suggest.list(params)
|
|
654
|
-
);
|
|
655
|
-
return response.data;
|
|
653
|
+
const response = await openSearch.suggestions.suggest.list(params);
|
|
654
|
+
return toListResult(response);
|
|
656
655
|
},
|
|
657
|
-
q
|
|
656
|
+
// Key on q AND pagination (limit/offset): different pages of the same query
|
|
657
|
+
// are distinct cache entries. Keying on q alone served a stale page.
|
|
658
|
+
q,
|
|
659
|
+
limit,
|
|
660
|
+
offset
|
|
658
661
|
);
|
|
659
662
|
}
|
|
660
|
-
|
|
661
|
-
|
|
663
|
+
function itemSearchParams(filters, from, itemCategoryUid) {
|
|
664
|
+
return {
|
|
662
665
|
q: filters.q,
|
|
663
666
|
searchType: "query",
|
|
664
667
|
size: filters.limit,
|
|
665
|
-
from
|
|
666
|
-
|
|
668
|
+
from,
|
|
669
|
+
sort: filters.sortBy,
|
|
667
670
|
classId5List: itemCategoryUid ? String(itemCategoryUid) : void 0,
|
|
668
671
|
filters: filters.filters?.length ? JSON.stringify(filters.filters) : void 0,
|
|
669
672
|
sourceFieldsList: defaultSourceFields,
|
|
670
673
|
edgeCache
|
|
671
674
|
};
|
|
675
|
+
}
|
|
676
|
+
async function itemSearch(filters, itemCategoryUid) {
|
|
677
|
+
const params = itemSearchParams(filters, filters.offset, itemCategoryUid);
|
|
672
678
|
return withServerCache(
|
|
673
679
|
cachePrefix,
|
|
674
680
|
redisTtl,
|
|
@@ -682,17 +688,7 @@ function createSearchActions(api, config = {}) {
|
|
|
682
688
|
);
|
|
683
689
|
}
|
|
684
690
|
async function itemSearchInfinite(filters, itemCategoryUid, pageParam = 0) {
|
|
685
|
-
const params =
|
|
686
|
-
q: filters.q,
|
|
687
|
-
searchType: "query",
|
|
688
|
-
size: filters.limit,
|
|
689
|
-
from: pageParam,
|
|
690
|
-
sortBy: filters.sortBy,
|
|
691
|
-
classId5List: itemCategoryUid ? String(itemCategoryUid) : void 0,
|
|
692
|
-
filters: filters.filters?.length ? JSON.stringify(filters.filters) : void 0,
|
|
693
|
-
sourceFieldsList: defaultSourceFields,
|
|
694
|
-
edgeCache
|
|
695
|
-
};
|
|
691
|
+
const params = itemSearchParams(filters, pageParam, itemCategoryUid);
|
|
696
692
|
return withServerCache(
|
|
697
693
|
cachePrefix,
|
|
698
694
|
redisTtl,
|
|
@@ -729,7 +725,7 @@ function createOrderActions(api, config = {}) {
|
|
|
729
725
|
redisTtl,
|
|
730
726
|
"orders.oeHdr.doc.get",
|
|
731
727
|
async () => {
|
|
732
|
-
const response = await api.orders.oeHdr.doc.get(
|
|
728
|
+
const response = await api.orders.oeHdr.doc.get(orderNo, {
|
|
733
729
|
postalCode,
|
|
734
730
|
edgeCache
|
|
735
731
|
});
|
|
@@ -892,19 +888,14 @@ function createJoomlaActions(api, config = {}) {
|
|
|
892
888
|
const response = await api.joomla.users.doc.get(Number(userId), {
|
|
893
889
|
edgeCache
|
|
894
890
|
});
|
|
895
|
-
const
|
|
896
|
-
if (!
|
|
897
|
-
const customerId = String(
|
|
898
|
-
raw["customerId"] ?? raw["customer_id"] ?? raw["p21_customer_id"] ?? ""
|
|
899
|
-
);
|
|
900
|
-
const groups = Array.isArray(raw["groups"]) ? raw["groups"] : [];
|
|
901
|
-
const permissions = groups.map((g3) => String(g3["title"] ?? g3["name"] ?? "")).filter(Boolean);
|
|
891
|
+
const user = response.data;
|
|
892
|
+
if (!user) throw new Error("User not found");
|
|
902
893
|
return {
|
|
903
|
-
id: String(
|
|
904
|
-
name:
|
|
905
|
-
email:
|
|
906
|
-
customerId,
|
|
907
|
-
permissions
|
|
894
|
+
id: String(user.id),
|
|
895
|
+
name: user.name,
|
|
896
|
+
email: user.email,
|
|
897
|
+
customerId: user.customerId,
|
|
898
|
+
permissions: user.groups.map((group) => group.title).filter(Boolean)
|
|
908
899
|
};
|
|
909
900
|
},
|
|
910
901
|
userId
|
|
@@ -1002,20 +993,6 @@ function createLegacyActions(api, config = {}) {
|
|
|
1002
993
|
// src/actions/customers.ts
|
|
1003
994
|
function createCustomersActions(api, config = {}) {
|
|
1004
995
|
const { cachePrefix = "", edgeCache = 1, redisTtl = 3600 } = config;
|
|
1005
|
-
async function getCustomer(customerId) {
|
|
1006
|
-
return withServerCache(
|
|
1007
|
-
cachePrefix,
|
|
1008
|
-
redisTtl,
|
|
1009
|
-
"customers.customer.get",
|
|
1010
|
-
async () => {
|
|
1011
|
-
const response = await api.customers.customer.get(customerId, {
|
|
1012
|
-
edgeCache
|
|
1013
|
-
});
|
|
1014
|
-
return response.data;
|
|
1015
|
-
},
|
|
1016
|
-
customerId
|
|
1017
|
-
);
|
|
1018
|
-
}
|
|
1019
996
|
async function customerLookup(params) {
|
|
1020
997
|
return withServerCache(
|
|
1021
998
|
cachePrefix,
|
|
@@ -1025,7 +1002,6 @@ function createCustomersActions(api, config = {}) {
|
|
|
1025
1002
|
const response = await api.customers.customer.lookup.get({
|
|
1026
1003
|
...params,
|
|
1027
1004
|
edgeCache
|
|
1028
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1029
1005
|
});
|
|
1030
1006
|
return toListResult(response);
|
|
1031
1007
|
},
|
|
@@ -1055,7 +1031,6 @@ function createCustomersActions(api, config = {}) {
|
|
|
1055
1031
|
const response = await api.customers.customer.orders.list(customerId, {
|
|
1056
1032
|
...params,
|
|
1057
1033
|
edgeCache
|
|
1058
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1059
1034
|
});
|
|
1060
1035
|
return toListResult(response);
|
|
1061
1036
|
},
|
|
@@ -1069,7 +1044,7 @@ function createCustomersActions(api, config = {}) {
|
|
|
1069
1044
|
redisTtl,
|
|
1070
1045
|
"customers.customer.orders.get",
|
|
1071
1046
|
async () => {
|
|
1072
|
-
const response = await api.customers.customer.orders.get(customerId, orderId, {
|
|
1047
|
+
const response = await api.customers.customer.orders.get(customerId, String(orderId), {
|
|
1073
1048
|
edgeCache
|
|
1074
1049
|
});
|
|
1075
1050
|
return response.data;
|
|
@@ -1084,11 +1059,10 @@ function createCustomersActions(api, config = {}) {
|
|
|
1084
1059
|
redisTtl,
|
|
1085
1060
|
"customers.customer.invoices.list",
|
|
1086
1061
|
async () => {
|
|
1087
|
-
const response = await api.customers.customer.invoices.list(
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
);
|
|
1062
|
+
const response = await api.customers.customer.invoices.list(customerId, {
|
|
1063
|
+
...params,
|
|
1064
|
+
edgeCache
|
|
1065
|
+
});
|
|
1092
1066
|
return toListResult(response);
|
|
1093
1067
|
},
|
|
1094
1068
|
customerId,
|
|
@@ -1141,21 +1115,6 @@ function createCustomersActions(api, config = {}) {
|
|
|
1141
1115
|
quoteNo
|
|
1142
1116
|
);
|
|
1143
1117
|
}
|
|
1144
|
-
async function getContacts(params) {
|
|
1145
|
-
return withServerCache(
|
|
1146
|
-
cachePrefix,
|
|
1147
|
-
redisTtl,
|
|
1148
|
-
"customers.contacts.list",
|
|
1149
|
-
async () => {
|
|
1150
|
-
const response = await api.customers.contacts.list({
|
|
1151
|
-
...params,
|
|
1152
|
-
edgeCache
|
|
1153
|
-
});
|
|
1154
|
-
return toListResult(response);
|
|
1155
|
-
},
|
|
1156
|
-
params
|
|
1157
|
-
);
|
|
1158
|
-
}
|
|
1159
1118
|
async function getShipToAddresses(customerId) {
|
|
1160
1119
|
return withServerCache(
|
|
1161
1120
|
cachePrefix,
|
|
@@ -1171,7 +1130,6 @@ function createCustomersActions(api, config = {}) {
|
|
|
1171
1130
|
);
|
|
1172
1131
|
}
|
|
1173
1132
|
return {
|
|
1174
|
-
getCustomer,
|
|
1175
1133
|
customerLookup,
|
|
1176
1134
|
getCustomerDoc,
|
|
1177
1135
|
getCustomerOrders,
|
|
@@ -1180,14 +1138,12 @@ function createCustomersActions(api, config = {}) {
|
|
|
1180
1138
|
getCustomerInvoiceDetail,
|
|
1181
1139
|
getCustomerQuotes,
|
|
1182
1140
|
getCustomerQuoteDetail,
|
|
1183
|
-
getContacts,
|
|
1184
1141
|
getShipToAddresses
|
|
1185
1142
|
};
|
|
1186
1143
|
}
|
|
1187
1144
|
|
|
1188
1145
|
// src/actions/smarty-streets.ts
|
|
1189
|
-
function createSmartyStreetsActions(api,
|
|
1190
|
-
const { cachePrefix: _cachePrefix = "" } = config;
|
|
1146
|
+
function createSmartyStreetsActions(api, _config = {}) {
|
|
1191
1147
|
async function validateAddress(params) {
|
|
1192
1148
|
try {
|
|
1193
1149
|
const response = await api.smartyStreets.us.lookup.get(params);
|
|
@@ -1252,39 +1208,28 @@ function createAgrSiteActions(api, config = {}) {
|
|
|
1252
1208
|
"agrSite.settings.list",
|
|
1253
1209
|
async () => {
|
|
1254
1210
|
const response = await api.agrSite.settings.list({
|
|
1255
|
-
|
|
1211
|
+
serviceName,
|
|
1256
1212
|
edgeCache: longEdgeCache
|
|
1257
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1258
1213
|
});
|
|
1259
1214
|
return toListResult(response);
|
|
1260
1215
|
},
|
|
1261
1216
|
serviceName
|
|
1262
1217
|
);
|
|
1263
1218
|
}
|
|
1264
|
-
async function
|
|
1265
|
-
return withServerCache(
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
async () => {
|
|
1270
|
-
const response = await api.agrSite.metaFiles.list({
|
|
1271
|
-
...params,
|
|
1272
|
-
edgeCache: longEdgeCache
|
|
1273
|
-
});
|
|
1274
|
-
return toListResult(response);
|
|
1275
|
-
},
|
|
1276
|
-
params
|
|
1277
|
-
);
|
|
1219
|
+
async function getRobots() {
|
|
1220
|
+
return withServerCache(cachePrefix, longRedisTtl, "agrSite.metaFiles.robots.list", async () => {
|
|
1221
|
+
const response = await api.agrSite.metaFiles.robots.list({ edgeCache: longEdgeCache });
|
|
1222
|
+
return response.data;
|
|
1223
|
+
});
|
|
1278
1224
|
}
|
|
1279
1225
|
return {
|
|
1280
1226
|
getSettings,
|
|
1281
|
-
|
|
1227
|
+
getRobots
|
|
1282
1228
|
};
|
|
1283
1229
|
}
|
|
1284
1230
|
|
|
1285
1231
|
// src/actions/avalara.ts
|
|
1286
|
-
function createAvalaraActions(api,
|
|
1287
|
-
const { cachePrefix: _cachePrefix = "" } = config;
|
|
1232
|
+
function createAvalaraActions(api, _config = {}) {
|
|
1288
1233
|
async function calculateTax(data) {
|
|
1289
1234
|
const response = await api.avalara.rates.create(data);
|
|
1290
1235
|
return response.data;
|
|
@@ -1296,16 +1241,13 @@ function createAvalaraActions(api, config = {}) {
|
|
|
1296
1241
|
|
|
1297
1242
|
// src/actions/payments.ts
|
|
1298
1243
|
function createPaymentsActions(api, config = {}) {
|
|
1299
|
-
const
|
|
1244
|
+
const mode = configuredModeOf(config.mode);
|
|
1300
1245
|
function withMode(params) {
|
|
1301
1246
|
return { mode, ...params };
|
|
1302
1247
|
}
|
|
1303
1248
|
async function transactionSetup(params) {
|
|
1304
1249
|
try {
|
|
1305
|
-
const response = (
|
|
1306
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1307
|
-
await api.payments.unified.transactionSetup.list(withMode(params))
|
|
1308
|
-
);
|
|
1250
|
+
const response = await api.payments.unified.transactionSetup.list(withMode(params));
|
|
1309
1251
|
return response.data;
|
|
1310
1252
|
} catch {
|
|
1311
1253
|
return void 0;
|
|
@@ -1313,10 +1255,7 @@ function createPaymentsActions(api, config = {}) {
|
|
|
1313
1255
|
}
|
|
1314
1256
|
async function accountQuery(params) {
|
|
1315
1257
|
try {
|
|
1316
|
-
const response = (
|
|
1317
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1318
|
-
await api.payments.unified.accountQuery.list(withMode(params))
|
|
1319
|
-
);
|
|
1258
|
+
const response = await api.payments.unified.accountQuery.list(withMode(params));
|
|
1320
1259
|
return response.data;
|
|
1321
1260
|
} catch {
|
|
1322
1261
|
return void 0;
|
|
@@ -1324,10 +1263,7 @@ function createPaymentsActions(api, config = {}) {
|
|
|
1324
1263
|
}
|
|
1325
1264
|
async function getSurcharge(params) {
|
|
1326
1265
|
try {
|
|
1327
|
-
const response = (
|
|
1328
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1329
|
-
await api.payments.unified.surcharge.list(withMode(params))
|
|
1330
|
-
);
|
|
1266
|
+
const response = await api.payments.unified.surcharge.list(withMode(params));
|
|
1331
1267
|
return response.data;
|
|
1332
1268
|
} catch {
|
|
1333
1269
|
return void 0;
|
|
@@ -1335,10 +1271,7 @@ function createPaymentsActions(api, config = {}) {
|
|
|
1335
1271
|
}
|
|
1336
1272
|
async function cardInfo(params) {
|
|
1337
1273
|
try {
|
|
1338
|
-
const response = (
|
|
1339
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1340
|
-
await api.payments.unified.cardInfo.list(withMode(params))
|
|
1341
|
-
);
|
|
1274
|
+
const response = await api.payments.unified.cardInfo.list(withMode(params));
|
|
1342
1275
|
return response.data;
|
|
1343
1276
|
} catch {
|
|
1344
1277
|
return void 0;
|
|
@@ -1346,10 +1279,7 @@ function createPaymentsActions(api, config = {}) {
|
|
|
1346
1279
|
}
|
|
1347
1280
|
async function billingUpdate(params) {
|
|
1348
1281
|
try {
|
|
1349
|
-
const response = (
|
|
1350
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1351
|
-
await api.payments.unified.billingUpdate.list(withMode(params))
|
|
1352
|
-
);
|
|
1282
|
+
const response = await api.payments.unified.billingUpdate.list(withMode(params));
|
|
1353
1283
|
return response.data;
|
|
1354
1284
|
} catch {
|
|
1355
1285
|
return void 0;
|
|
@@ -1357,18 +1287,8 @@ function createPaymentsActions(api, config = {}) {
|
|
|
1357
1287
|
}
|
|
1358
1288
|
async function validatePayment(params) {
|
|
1359
1289
|
try {
|
|
1360
|
-
const response = (
|
|
1361
|
-
|
|
1362
|
-
await api.payments.unified.validate.list(withMode(params))
|
|
1363
|
-
);
|
|
1364
|
-
const raw = response.data;
|
|
1365
|
-
if (typeof raw === "boolean") {
|
|
1366
|
-
return { valid: raw };
|
|
1367
|
-
}
|
|
1368
|
-
if (typeof raw === "object" && raw !== null && "valid" in raw) {
|
|
1369
|
-
return raw;
|
|
1370
|
-
}
|
|
1371
|
-
return { valid: Boolean(raw) };
|
|
1290
|
+
const response = await api.payments.unified.validate.list(withMode(params));
|
|
1291
|
+
return response.data;
|
|
1372
1292
|
} catch {
|
|
1373
1293
|
return void 0;
|
|
1374
1294
|
}
|
|
@@ -1403,11 +1323,10 @@ function createLogisticsActions(api, config = {}) {
|
|
|
1403
1323
|
const response = await api.logistics.shipvia.rates.list({
|
|
1404
1324
|
...params,
|
|
1405
1325
|
edgeCache: longEdgeCache
|
|
1406
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1407
1326
|
});
|
|
1408
1327
|
return toListResult(response);
|
|
1409
1328
|
},
|
|
1410
|
-
|
|
1329
|
+
JSON.stringify(params)
|
|
1411
1330
|
);
|
|
1412
1331
|
}
|
|
1413
1332
|
return {
|
|
@@ -1416,88 +1335,6 @@ function createLogisticsActions(api, config = {}) {
|
|
|
1416
1335
|
};
|
|
1417
1336
|
}
|
|
1418
1337
|
|
|
1419
|
-
// src/actions/nexus.ts
|
|
1420
|
-
function createNexusActions(api, config = {}) {
|
|
1421
|
-
const { cachePrefix = "", edgeCache = 1, redisTtl = 3600 } = config;
|
|
1422
|
-
async function createBinTransfer(data) {
|
|
1423
|
-
try {
|
|
1424
|
-
const response = await api.nexus.binTransfer.create(data);
|
|
1425
|
-
return response.data;
|
|
1426
|
-
} catch {
|
|
1427
|
-
return void 0;
|
|
1428
|
-
}
|
|
1429
|
-
}
|
|
1430
|
-
async function createReceiving(data) {
|
|
1431
|
-
try {
|
|
1432
|
-
const response = await api.nexus.receiving.create(data);
|
|
1433
|
-
return response.data;
|
|
1434
|
-
} catch {
|
|
1435
|
-
return void 0;
|
|
1436
|
-
}
|
|
1437
|
-
}
|
|
1438
|
-
async function createTransfer(data) {
|
|
1439
|
-
try {
|
|
1440
|
-
const response = await api.nexus.transfer.create(data);
|
|
1441
|
-
return response.data;
|
|
1442
|
-
} catch {
|
|
1443
|
-
return void 0;
|
|
1444
|
-
}
|
|
1445
|
-
}
|
|
1446
|
-
async function getPurchaseOrderReceipts(params) {
|
|
1447
|
-
return withServerCache(
|
|
1448
|
-
cachePrefix,
|
|
1449
|
-
redisTtl,
|
|
1450
|
-
"nexus.purchaseOrderReceipt.list",
|
|
1451
|
-
async () => {
|
|
1452
|
-
const response = await api.nexus.purchaseOrderReceipt.list({
|
|
1453
|
-
...params,
|
|
1454
|
-
edgeCache
|
|
1455
|
-
});
|
|
1456
|
-
return toListResult(response);
|
|
1457
|
-
},
|
|
1458
|
-
params ? JSON.stringify(params) : void 0
|
|
1459
|
-
);
|
|
1460
|
-
}
|
|
1461
|
-
async function getTransferReceipts(params) {
|
|
1462
|
-
return withServerCache(
|
|
1463
|
-
cachePrefix,
|
|
1464
|
-
redisTtl,
|
|
1465
|
-
"nexus.transferReceipt.list",
|
|
1466
|
-
async () => {
|
|
1467
|
-
const response = await api.nexus.transferReceipt.list({
|
|
1468
|
-
...params,
|
|
1469
|
-
edgeCache
|
|
1470
|
-
});
|
|
1471
|
-
return toListResult(response);
|
|
1472
|
-
},
|
|
1473
|
-
params ? JSON.stringify(params) : void 0
|
|
1474
|
-
);
|
|
1475
|
-
}
|
|
1476
|
-
async function getTransferShipping(params) {
|
|
1477
|
-
return withServerCache(
|
|
1478
|
-
cachePrefix,
|
|
1479
|
-
redisTtl,
|
|
1480
|
-
"nexus.transferShipping.list",
|
|
1481
|
-
async () => {
|
|
1482
|
-
const response = await api.nexus.transferShipping.list({
|
|
1483
|
-
...params,
|
|
1484
|
-
edgeCache
|
|
1485
|
-
});
|
|
1486
|
-
return toListResult(response);
|
|
1487
|
-
},
|
|
1488
|
-
params ? JSON.stringify(params) : void 0
|
|
1489
|
-
);
|
|
1490
|
-
}
|
|
1491
|
-
return {
|
|
1492
|
-
createBinTransfer,
|
|
1493
|
-
createReceiving,
|
|
1494
|
-
createTransfer,
|
|
1495
|
-
getPurchaseOrderReceipts,
|
|
1496
|
-
getTransferReceipts,
|
|
1497
|
-
getTransferShipping
|
|
1498
|
-
};
|
|
1499
|
-
}
|
|
1500
|
-
|
|
1501
1338
|
// src/actions/vmi.ts
|
|
1502
1339
|
function createVmiActions(api, config = {}) {
|
|
1503
1340
|
const { cachePrefix = "", edgeCache = 1, redisTtl = 3600, shortRedisTtl = 300 } = config;
|
|
@@ -1507,14 +1344,10 @@ function createVmiActions(api, config = {}) {
|
|
|
1507
1344
|
redisTtl,
|
|
1508
1345
|
"vmi.warehouse.list",
|
|
1509
1346
|
async () => {
|
|
1510
|
-
const response = await api.vmi.warehouse.list({
|
|
1511
|
-
...params,
|
|
1512
|
-
edgeCache
|
|
1513
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1514
|
-
});
|
|
1347
|
+
const response = await api.vmi.warehouse.list({ ...params, edgeCache });
|
|
1515
1348
|
return toListResult(response);
|
|
1516
1349
|
},
|
|
1517
|
-
|
|
1350
|
+
JSON.stringify(params)
|
|
1518
1351
|
);
|
|
1519
1352
|
}
|
|
1520
1353
|
async function getWarehouseAvailability(warehouseUid, params) {
|
|
@@ -1523,15 +1356,14 @@ function createVmiActions(api, config = {}) {
|
|
|
1523
1356
|
shortRedisTtl,
|
|
1524
1357
|
"vmi.warehouse.availability.get",
|
|
1525
1358
|
async () => {
|
|
1526
|
-
const response = await api.vmi.warehouse.availability.list(
|
|
1527
|
-
|
|
1528
|
-
|
|
1529
|
-
|
|
1530
|
-
);
|
|
1359
|
+
const response = await api.vmi.warehouse.availability.list(warehouseUid, {
|
|
1360
|
+
...params,
|
|
1361
|
+
edgeCache
|
|
1362
|
+
});
|
|
1531
1363
|
return toListResult(response);
|
|
1532
1364
|
},
|
|
1533
1365
|
warehouseUid,
|
|
1534
|
-
|
|
1366
|
+
JSON.stringify(params)
|
|
1535
1367
|
);
|
|
1536
1368
|
}
|
|
1537
1369
|
async function getDistributors(params) {
|
|
@@ -1540,14 +1372,10 @@ function createVmiActions(api, config = {}) {
|
|
|
1540
1372
|
redisTtl,
|
|
1541
1373
|
"vmi.distributors.list",
|
|
1542
1374
|
async () => {
|
|
1543
|
-
const response = await api.vmi.distributors.list({
|
|
1544
|
-
...params,
|
|
1545
|
-
edgeCache
|
|
1546
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1547
|
-
});
|
|
1375
|
+
const response = await api.vmi.distributors.list({ ...params, edgeCache });
|
|
1548
1376
|
return toListResult(response);
|
|
1549
1377
|
},
|
|
1550
|
-
|
|
1378
|
+
JSON.stringify(params)
|
|
1551
1379
|
);
|
|
1552
1380
|
}
|
|
1553
1381
|
async function getProducts(params) {
|
|
@@ -1556,14 +1384,10 @@ function createVmiActions(api, config = {}) {
|
|
|
1556
1384
|
redisTtl,
|
|
1557
1385
|
"vmi.products.list",
|
|
1558
1386
|
async () => {
|
|
1559
|
-
const response = await api.vmi.products.list({
|
|
1560
|
-
...params,
|
|
1561
|
-
edgeCache
|
|
1562
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1563
|
-
});
|
|
1387
|
+
const response = await api.vmi.products.list({ ...params, edgeCache });
|
|
1564
1388
|
return toListResult(response);
|
|
1565
1389
|
},
|
|
1566
|
-
|
|
1390
|
+
JSON.stringify(params)
|
|
1567
1391
|
);
|
|
1568
1392
|
}
|
|
1569
1393
|
async function getInventoryProfiles(params) {
|
|
@@ -1572,14 +1396,10 @@ function createVmiActions(api, config = {}) {
|
|
|
1572
1396
|
redisTtl,
|
|
1573
1397
|
"vmi.invProfileHdr.list",
|
|
1574
1398
|
async () => {
|
|
1575
|
-
const response = await api.vmi.invProfileHdr.list({
|
|
1576
|
-
...params,
|
|
1577
|
-
edgeCache
|
|
1578
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1579
|
-
});
|
|
1399
|
+
const response = await api.vmi.invProfileHdr.list({ ...params, edgeCache });
|
|
1580
1400
|
return toListResult(response);
|
|
1581
1401
|
},
|
|
1582
|
-
|
|
1402
|
+
JSON.stringify(params)
|
|
1583
1403
|
);
|
|
1584
1404
|
}
|
|
1585
1405
|
async function getRestockHeaders(params) {
|
|
@@ -1588,11 +1408,7 @@ function createVmiActions(api, config = {}) {
|
|
|
1588
1408
|
redisTtl,
|
|
1589
1409
|
"vmi.restockHdr.list",
|
|
1590
1410
|
async () => {
|
|
1591
|
-
const response = await api.vmi.restockHdr.list({
|
|
1592
|
-
...params,
|
|
1593
|
-
edgeCache
|
|
1594
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1595
|
-
});
|
|
1411
|
+
const response = await api.vmi.restockHdr.list({ ...params, edgeCache });
|
|
1596
1412
|
return toListResult(response);
|
|
1597
1413
|
},
|
|
1598
1414
|
params ? JSON.stringify(params) : void 0
|
|
@@ -1604,14 +1420,10 @@ function createVmiActions(api, config = {}) {
|
|
|
1604
1420
|
redisTtl,
|
|
1605
1421
|
"vmi.sections.list",
|
|
1606
1422
|
async () => {
|
|
1607
|
-
const response = await api.vmi.sections.list({
|
|
1608
|
-
...params,
|
|
1609
|
-
edgeCache
|
|
1610
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1611
|
-
});
|
|
1423
|
+
const response = await api.vmi.sections.list({ ...params, edgeCache });
|
|
1612
1424
|
return toListResult(response);
|
|
1613
1425
|
},
|
|
1614
|
-
|
|
1426
|
+
JSON.stringify(params)
|
|
1615
1427
|
);
|
|
1616
1428
|
}
|
|
1617
1429
|
return {
|
|
@@ -1732,7 +1544,6 @@ function createP21CoreActions(api, config = {}) {
|
|
|
1732
1544
|
const response = await api.p21Core.codeP21.list({
|
|
1733
1545
|
...params,
|
|
1734
1546
|
edgeCache: longEdgeCache
|
|
1735
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1736
1547
|
});
|
|
1737
1548
|
return toListResult(response);
|
|
1738
1549
|
},
|
|
@@ -1751,103 +1562,10 @@ function createP21CoreActions(api, config = {}) {
|
|
|
1751
1562
|
}
|
|
1752
1563
|
|
|
1753
1564
|
// src/actions/p21-apis.ts
|
|
1754
|
-
function createP21ApisActions(api,
|
|
1755
|
-
const { cachePrefix = "", edgeCache = 1, redisTtl = 3600 } = config;
|
|
1756
|
-
async function getCategories(params) {
|
|
1757
|
-
return withServerCache(
|
|
1758
|
-
cachePrefix,
|
|
1759
|
-
redisTtl,
|
|
1760
|
-
"p21Apis.transCategory.list",
|
|
1761
|
-
async () => {
|
|
1762
|
-
const response = await api.p21Apis.transCategory.list({
|
|
1763
|
-
...params,
|
|
1764
|
-
edgeCache
|
|
1765
|
-
});
|
|
1766
|
-
return toListResult(response);
|
|
1767
|
-
},
|
|
1768
|
-
params
|
|
1769
|
-
);
|
|
1770
|
-
}
|
|
1771
|
-
async function getCategoryDefaults(categoryId) {
|
|
1772
|
-
return withServerCache(
|
|
1773
|
-
cachePrefix,
|
|
1774
|
-
redisTtl,
|
|
1775
|
-
"p21Apis.transCategory.defaults.get",
|
|
1776
|
-
async () => {
|
|
1777
|
-
const response = await api.p21Apis.transCategory.defaults.get(categoryId, {
|
|
1778
|
-
edgeCache
|
|
1779
|
-
});
|
|
1780
|
-
return response.data;
|
|
1781
|
-
},
|
|
1782
|
-
categoryId
|
|
1783
|
-
);
|
|
1784
|
-
}
|
|
1785
|
-
async function getCompanies(params) {
|
|
1786
|
-
return withServerCache(
|
|
1787
|
-
cachePrefix,
|
|
1788
|
-
redisTtl,
|
|
1789
|
-
"p21Apis.transCompany.list",
|
|
1790
|
-
async () => {
|
|
1791
|
-
const response = await api.p21Apis.transCompany.list({
|
|
1792
|
-
...params,
|
|
1793
|
-
edgeCache
|
|
1794
|
-
});
|
|
1795
|
-
return toListResult(response);
|
|
1796
|
-
},
|
|
1797
|
-
params
|
|
1798
|
-
);
|
|
1799
|
-
}
|
|
1800
|
-
async function getUsers(params) {
|
|
1801
|
-
return withServerCache(
|
|
1802
|
-
cachePrefix,
|
|
1803
|
-
redisTtl,
|
|
1804
|
-
"p21Apis.transUser.list",
|
|
1805
|
-
async () => {
|
|
1806
|
-
const response = await api.p21Apis.transUser.list({
|
|
1807
|
-
...params,
|
|
1808
|
-
edgeCache
|
|
1809
|
-
});
|
|
1810
|
-
return toListResult(response);
|
|
1811
|
-
},
|
|
1812
|
-
params
|
|
1813
|
-
);
|
|
1814
|
-
}
|
|
1815
|
-
async function getWebDisplayTypes(params) {
|
|
1816
|
-
return withServerCache(
|
|
1817
|
-
cachePrefix,
|
|
1818
|
-
redisTtl,
|
|
1819
|
-
"p21Apis.transWebDisplayType.list",
|
|
1820
|
-
async () => {
|
|
1821
|
-
const response = await api.p21Apis.transWebDisplayType.list({
|
|
1822
|
-
...params,
|
|
1823
|
-
edgeCache
|
|
1824
|
-
});
|
|
1825
|
-
return toListResult(response);
|
|
1826
|
-
},
|
|
1827
|
-
params
|
|
1828
|
-
);
|
|
1829
|
-
}
|
|
1830
|
-
async function getWebDisplayTypeDefaults(id) {
|
|
1831
|
-
return withServerCache(
|
|
1832
|
-
cachePrefix,
|
|
1833
|
-
redisTtl,
|
|
1834
|
-
"p21Apis.transWebDisplayType.defaults.get",
|
|
1835
|
-
async () => {
|
|
1836
|
-
const response = await api.p21Apis.transWebDisplayType.defaults.list({
|
|
1837
|
-
id,
|
|
1838
|
-
edgeCache
|
|
1839
|
-
});
|
|
1840
|
-
return response.data;
|
|
1841
|
-
},
|
|
1842
|
-
id
|
|
1843
|
-
);
|
|
1844
|
-
}
|
|
1565
|
+
function createP21ApisActions(api, _config = {}) {
|
|
1845
1566
|
async function refreshContacts(params) {
|
|
1846
1567
|
try {
|
|
1847
|
-
const response = (
|
|
1848
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1849
|
-
await api.p21Apis.entityContacts.refresh.create(params)
|
|
1850
|
-
);
|
|
1568
|
+
const response = await api.p21Apis.entityContacts.refresh.get(params);
|
|
1851
1569
|
return response.data;
|
|
1852
1570
|
} catch {
|
|
1853
1571
|
return void 0;
|
|
@@ -1855,22 +1573,13 @@ function createP21ApisActions(api, config = {}) {
|
|
|
1855
1573
|
}
|
|
1856
1574
|
async function refreshCustomers(params) {
|
|
1857
1575
|
try {
|
|
1858
|
-
const response = (
|
|
1859
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1860
|
-
await api.p21Apis.entityCustomers.refresh.create(params)
|
|
1861
|
-
);
|
|
1576
|
+
const response = await api.p21Apis.entityCustomers.refresh.get(params);
|
|
1862
1577
|
return response.data;
|
|
1863
1578
|
} catch {
|
|
1864
1579
|
return void 0;
|
|
1865
1580
|
}
|
|
1866
1581
|
}
|
|
1867
1582
|
return {
|
|
1868
|
-
getCategories,
|
|
1869
|
-
getCategoryDefaults,
|
|
1870
|
-
getCompanies,
|
|
1871
|
-
getUsers,
|
|
1872
|
-
getWebDisplayTypes,
|
|
1873
|
-
getWebDisplayTypeDefaults,
|
|
1874
1583
|
refreshContacts,
|
|
1875
1584
|
refreshCustomers
|
|
1876
1585
|
};
|
|
@@ -1894,33 +1603,16 @@ function createP21SismActions(api, config = {}) {
|
|
|
1894
1603
|
params
|
|
1895
1604
|
);
|
|
1896
1605
|
}
|
|
1897
|
-
async function getImport(
|
|
1606
|
+
async function getImport(importUid) {
|
|
1898
1607
|
return withServerCache(
|
|
1899
1608
|
cachePrefix,
|
|
1900
1609
|
redisTtl,
|
|
1901
1610
|
"p21Sism.import.get",
|
|
1902
1611
|
async () => {
|
|
1903
|
-
const response = await api.p21Sism.import.get(
|
|
1612
|
+
const response = await api.p21Sism.import.get(importUid);
|
|
1904
1613
|
return response.data;
|
|
1905
1614
|
},
|
|
1906
|
-
|
|
1907
|
-
);
|
|
1908
|
-
}
|
|
1909
|
-
async function getImportLines(importId, params) {
|
|
1910
|
-
return withServerCache(
|
|
1911
|
-
cachePrefix,
|
|
1912
|
-
redisTtl,
|
|
1913
|
-
"p21Sism.impOeLine.list",
|
|
1914
|
-
async () => {
|
|
1915
|
-
const response = await api.p21Sism.impOeLine.list({
|
|
1916
|
-
...params,
|
|
1917
|
-
importUid: importId,
|
|
1918
|
-
edgeCache
|
|
1919
|
-
});
|
|
1920
|
-
return toListResult(response);
|
|
1921
|
-
},
|
|
1922
|
-
importId,
|
|
1923
|
-
params
|
|
1615
|
+
importUid
|
|
1924
1616
|
);
|
|
1925
1617
|
}
|
|
1926
1618
|
async function getScheduledImports(params) {
|
|
@@ -1941,7 +1633,6 @@ function createP21SismActions(api, config = {}) {
|
|
|
1941
1633
|
return {
|
|
1942
1634
|
getRecentImports,
|
|
1943
1635
|
getImport,
|
|
1944
|
-
getImportLines,
|
|
1945
1636
|
getScheduledImports
|
|
1946
1637
|
};
|
|
1947
1638
|
}
|
|
@@ -2065,11 +1756,7 @@ function createBasecamp2Actions(api, config = {}) {
|
|
|
2065
1756
|
redisTtl,
|
|
2066
1757
|
"basecamp2.todos.list",
|
|
2067
1758
|
async () => {
|
|
2068
|
-
const response = await api.basecamp2.todos.list({
|
|
2069
|
-
...params,
|
|
2070
|
-
edgeCache
|
|
2071
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
2072
|
-
});
|
|
1759
|
+
const response = await api.basecamp2.todos.list({ ...params, edgeCache });
|
|
2073
1760
|
return toListResult(response);
|
|
2074
1761
|
},
|
|
2075
1762
|
params
|
|
@@ -2093,11 +1780,7 @@ function createBasecamp2Actions(api, config = {}) {
|
|
|
2093
1780
|
redisTtl,
|
|
2094
1781
|
"basecamp2.todosSummary.list",
|
|
2095
1782
|
async () => {
|
|
2096
|
-
const response = await api.basecamp2.todosSummary.list({
|
|
2097
|
-
...params,
|
|
2098
|
-
edgeCache
|
|
2099
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
2100
|
-
});
|
|
1783
|
+
const response = await api.basecamp2.todosSummary.list({ ...params, edgeCache });
|
|
2101
1784
|
return toListResult(response);
|
|
2102
1785
|
},
|
|
2103
1786
|
params
|
|
@@ -2109,11 +1792,7 @@ function createBasecamp2Actions(api, config = {}) {
|
|
|
2109
1792
|
redisTtl,
|
|
2110
1793
|
"basecamp2.comments.list",
|
|
2111
1794
|
async () => {
|
|
2112
|
-
const response = await api.basecamp2.comments.list({
|
|
2113
|
-
...params,
|
|
2114
|
-
edgeCache
|
|
2115
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
2116
|
-
});
|
|
1795
|
+
const response = await api.basecamp2.comments.list({ ...params, edgeCache });
|
|
2117
1796
|
return toListResult(response);
|
|
2118
1797
|
},
|
|
2119
1798
|
params
|
|
@@ -2128,7 +1807,6 @@ function createBasecamp2Actions(api, config = {}) {
|
|
|
2128
1807
|
const response = await api.basecamp2.people.list({
|
|
2129
1808
|
...params,
|
|
2130
1809
|
edgeCache: longEdgeCache
|
|
2131
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
2132
1810
|
});
|
|
2133
1811
|
return toListResult(response);
|
|
2134
1812
|
},
|
|
@@ -2141,11 +1819,7 @@ function createBasecamp2Actions(api, config = {}) {
|
|
|
2141
1819
|
redisTtl,
|
|
2142
1820
|
"basecamp2.projects.list",
|
|
2143
1821
|
async () => {
|
|
2144
|
-
const response = await api.basecamp2.projects.list({
|
|
2145
|
-
...params,
|
|
2146
|
-
edgeCache
|
|
2147
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
2148
|
-
});
|
|
1822
|
+
const response = await api.basecamp2.projects.list({ ...params, edgeCache });
|
|
2149
1823
|
return toListResult(response);
|
|
2150
1824
|
},
|
|
2151
1825
|
params
|
|
@@ -2157,11 +1831,7 @@ function createBasecamp2Actions(api, config = {}) {
|
|
|
2157
1831
|
redisTtl,
|
|
2158
1832
|
"basecamp2.events.list",
|
|
2159
1833
|
async () => {
|
|
2160
|
-
const response = await api.basecamp2.events.list({
|
|
2161
|
-
...params,
|
|
2162
|
-
edgeCache
|
|
2163
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
2164
|
-
});
|
|
1834
|
+
const response = await api.basecamp2.events.list({ ...params, edgeCache });
|
|
2165
1835
|
return toListResult(response);
|
|
2166
1836
|
},
|
|
2167
1837
|
params
|
|
@@ -2173,11 +1843,7 @@ function createBasecamp2Actions(api, config = {}) {
|
|
|
2173
1843
|
redisTtl,
|
|
2174
1844
|
"basecamp2.metrics.list",
|
|
2175
1845
|
async () => {
|
|
2176
|
-
const response = await api.basecamp2.metrics.list({
|
|
2177
|
-
...params,
|
|
2178
|
-
edgeCache
|
|
2179
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
2180
|
-
});
|
|
1846
|
+
const response = await api.basecamp2.metrics.list({ ...params, edgeCache });
|
|
2181
1847
|
return toListResult(response);
|
|
2182
1848
|
},
|
|
2183
1849
|
params
|
|
@@ -2189,11 +1855,7 @@ function createBasecamp2Actions(api, config = {}) {
|
|
|
2189
1855
|
redisTtl,
|
|
2190
1856
|
"basecamp2.todolists.list",
|
|
2191
1857
|
async () => {
|
|
2192
|
-
const response = await api.basecamp2.todolists.list({
|
|
2193
|
-
...params,
|
|
2194
|
-
edgeCache
|
|
2195
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
2196
|
-
});
|
|
1858
|
+
const response = await api.basecamp2.todolists.list({ ...params, edgeCache });
|
|
2197
1859
|
return toListResult(response);
|
|
2198
1860
|
},
|
|
2199
1861
|
params
|
|
@@ -2230,25 +1892,25 @@ function createBrandFolderActions(api, config = {}) {
|
|
|
2230
1892
|
params
|
|
2231
1893
|
);
|
|
2232
1894
|
}
|
|
2233
|
-
async function getCategory(
|
|
1895
|
+
async function getCategory(itemCategoryUid) {
|
|
2234
1896
|
return withServerCache(
|
|
2235
1897
|
cachePrefix,
|
|
2236
1898
|
redisTtl,
|
|
2237
1899
|
"brandFolder.categories.get",
|
|
2238
1900
|
async () => {
|
|
2239
|
-
const response = await api.brandFolder.categories.get(
|
|
1901
|
+
const response = await api.brandFolder.categories.get(itemCategoryUid, {
|
|
2240
1902
|
edgeCache
|
|
2241
1903
|
});
|
|
2242
1904
|
return response.data;
|
|
2243
1905
|
},
|
|
2244
|
-
|
|
1906
|
+
itemCategoryUid
|
|
2245
1907
|
);
|
|
2246
1908
|
}
|
|
2247
1909
|
async function createFocus(categoryId, data) {
|
|
2248
1910
|
try {
|
|
2249
1911
|
const response = await api.brandFolder.categories.focus.create({
|
|
2250
1912
|
...data,
|
|
2251
|
-
categoryId
|
|
1913
|
+
itemCategoryId: categoryId
|
|
2252
1914
|
});
|
|
2253
1915
|
return response.data;
|
|
2254
1916
|
} catch {
|
|
@@ -2265,80 +1927,13 @@ function createBrandFolderActions(api, config = {}) {
|
|
|
2265
1927
|
// src/actions/gregorovich.ts
|
|
2266
1928
|
function createGregorovichActions(api, config = {}) {
|
|
2267
1929
|
const { cachePrefix = "", redisTtl = 3600 } = config;
|
|
2268
|
-
async function
|
|
2269
|
-
|
|
2270
|
-
const response = await api.gregorovich.
|
|
2271
|
-
return response
|
|
2272
|
-
}
|
|
2273
|
-
return void 0;
|
|
2274
|
-
}
|
|
2275
|
-
}
|
|
2276
|
-
async function getDocuments(params) {
|
|
2277
|
-
return withServerCache(
|
|
2278
|
-
cachePrefix,
|
|
2279
|
-
redisTtl,
|
|
2280
|
-
"gregorovich.documents.list",
|
|
2281
|
-
async () => {
|
|
2282
|
-
const response = await api.gregorovich.documents.list();
|
|
2283
|
-
return toListResult(response);
|
|
2284
|
-
},
|
|
2285
|
-
params
|
|
2286
|
-
);
|
|
2287
|
-
}
|
|
2288
|
-
async function createDocument(data) {
|
|
2289
|
-
try {
|
|
2290
|
-
const response = await api.gregorovich.documents.create(data);
|
|
2291
|
-
return response.data;
|
|
2292
|
-
} catch {
|
|
2293
|
-
return void 0;
|
|
2294
|
-
}
|
|
2295
|
-
}
|
|
2296
|
-
async function generateOllama(data) {
|
|
2297
|
-
try {
|
|
2298
|
-
const response = await api.gregorovich.ollama.generate.create(data);
|
|
2299
|
-
return response.data;
|
|
2300
|
-
} catch {
|
|
2301
|
-
return void 0;
|
|
2302
|
-
}
|
|
2303
|
-
}
|
|
2304
|
-
return {
|
|
2305
|
-
askChatGpt,
|
|
2306
|
-
getDocuments,
|
|
2307
|
-
createDocument,
|
|
2308
|
-
generateOllama
|
|
2309
|
-
};
|
|
2310
|
-
}
|
|
2311
|
-
|
|
2312
|
-
// src/actions/slack.ts
|
|
2313
|
-
function createSlackActions(api, config = {}) {
|
|
2314
|
-
const { cachePrefix = "", edgeCache = 1, redisTtl = 3600 } = config;
|
|
2315
|
-
async function sendWebhook(data) {
|
|
2316
|
-
try {
|
|
2317
|
-
const response = await api.slack.webHook.create(data);
|
|
2318
|
-
return response.data;
|
|
2319
|
-
} catch {
|
|
2320
|
-
return void 0;
|
|
2321
|
-
}
|
|
2322
|
-
}
|
|
2323
|
-
async function getWebhooks(params) {
|
|
2324
|
-
return withServerCache(
|
|
2325
|
-
cachePrefix,
|
|
2326
|
-
redisTtl,
|
|
2327
|
-
"slack.webHook.list",
|
|
2328
|
-
async () => {
|
|
2329
|
-
const response = await api.slack.webHook.list({
|
|
2330
|
-
...params,
|
|
2331
|
-
edgeCache
|
|
2332
|
-
});
|
|
2333
|
-
return toListResult(response);
|
|
2334
|
-
},
|
|
2335
|
-
params
|
|
2336
|
-
);
|
|
1930
|
+
async function getDocuments(_params) {
|
|
1931
|
+
return withServerCache(cachePrefix, redisTtl, "gregorovich.documents.list", async () => {
|
|
1932
|
+
const response = await api.gregorovich.documents.list();
|
|
1933
|
+
return toListResult(response);
|
|
1934
|
+
});
|
|
2337
1935
|
}
|
|
2338
|
-
return {
|
|
2339
|
-
sendWebhook,
|
|
2340
|
-
getWebhooks
|
|
2341
|
-
};
|
|
1936
|
+
return { getDocuments };
|
|
2342
1937
|
}
|
|
2343
1938
|
|
|
2344
1939
|
// src/actions/favorites.ts
|
|
@@ -2359,9 +1954,7 @@ function createFavoritesActions(api, config = {}) {
|
|
|
2359
1954
|
);
|
|
2360
1955
|
}
|
|
2361
1956
|
async function addFavorite(userId, invMastUid) {
|
|
2362
|
-
const response = await api.items.itemFavorites.items.create(userId,
|
|
2363
|
-
invMastUid
|
|
2364
|
-
});
|
|
1957
|
+
const response = await api.items.itemFavorites.items.create(userId, [invMastUid]);
|
|
2365
1958
|
return response.data;
|
|
2366
1959
|
}
|
|
2367
1960
|
async function removeFavorite(userId, invMastUid) {
|
|
@@ -2408,12 +2001,7 @@ function createWishlistActions(api, config = {}) {
|
|
|
2408
2001
|
await api.items.itemWishlist.hdr.delete(userId, wishlistId);
|
|
2409
2002
|
}
|
|
2410
2003
|
async function addWishlistItems(userId, wishlistId, items) {
|
|
2411
|
-
const response = await api.items.itemWishlist.hdr.create(
|
|
2412
|
-
userId,
|
|
2413
|
-
wishlistId,
|
|
2414
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
2415
|
-
items
|
|
2416
|
-
);
|
|
2004
|
+
const response = await api.items.itemWishlist.hdr.create(userId, wishlistId, items);
|
|
2417
2005
|
return response.data;
|
|
2418
2006
|
}
|
|
2419
2007
|
async function removeWishlistItem(userId, wishlistId, lineId) {
|
|
@@ -2433,14 +2021,14 @@ function createWishlistActions(api, config = {}) {
|
|
|
2433
2021
|
function createSiteActions(api, config = {}) {
|
|
2434
2022
|
const siteId = api.config?.siteId ?? "";
|
|
2435
2023
|
const {
|
|
2436
|
-
cachePrefix = siteId ?
|
|
2024
|
+
cachePrefix = siteId ? scopedPrefix(siteId) : "",
|
|
2437
2025
|
edgeCache,
|
|
2438
2026
|
redisTtl,
|
|
2439
2027
|
longEdgeCache,
|
|
2440
2028
|
longRedisTtl,
|
|
2441
2029
|
defaultContactId = process.env["DEFAULT_CONTACT_ID"],
|
|
2442
2030
|
defaultCustomerId = process.env["DEFAULT_CUSTOMER_ID"],
|
|
2443
|
-
defaultCompanyId
|
|
2031
|
+
// defaultCompanyId is accepted in the config but no action reads it yet
|
|
2444
2032
|
convertUnitOfMeasure
|
|
2445
2033
|
} = config;
|
|
2446
2034
|
const cache = { cachePrefix, edgeCache, redisTtl };
|
|
@@ -2449,13 +2037,7 @@ function createSiteActions(api, config = {}) {
|
|
|
2449
2037
|
return api;
|
|
2450
2038
|
}
|
|
2451
2039
|
function lazy(fn) {
|
|
2452
|
-
|
|
2453
|
-
return {
|
|
2454
|
-
get() {
|
|
2455
|
-
if (instance === void 0) instance = fn();
|
|
2456
|
-
return instance;
|
|
2457
|
-
}
|
|
2458
|
-
};
|
|
2040
|
+
return { get: fn };
|
|
2459
2041
|
}
|
|
2460
2042
|
const pricing = lazy(
|
|
2461
2043
|
() => createPricingActions(castApi(), {
|
|
@@ -2514,7 +2096,6 @@ function createSiteActions(api, config = {}) {
|
|
|
2514
2096
|
})
|
|
2515
2097
|
);
|
|
2516
2098
|
const logistics = lazy(() => createLogisticsActions(castApi(), longCache));
|
|
2517
|
-
const nexus = lazy(() => createNexusActions(castApi(), cache));
|
|
2518
2099
|
const vmi = lazy(() => createVmiActions(castApi(), { ...cache, ...config.vmi }));
|
|
2519
2100
|
const p21Core = lazy(() => createP21CoreActions(castApi(), longCache));
|
|
2520
2101
|
const p21Apis = lazy(() => createP21ApisActions(castApi(), cache));
|
|
@@ -2524,7 +2105,6 @@ function createSiteActions(api, config = {}) {
|
|
|
2524
2105
|
const basecamp2 = lazy(() => createBasecamp2Actions(castApi(), longCache));
|
|
2525
2106
|
const brandFolder = lazy(() => createBrandFolderActions(castApi(), cache));
|
|
2526
2107
|
const gregorovich = lazy(() => createGregorovichActions(castApi(), cache));
|
|
2527
|
-
const slack = lazy(() => createSlackActions(castApi(), cache));
|
|
2528
2108
|
const favorites = lazy(() => createFavoritesActions(castApi(), cache));
|
|
2529
2109
|
const wishlists = lazy(() => createWishlistActions(castApi(), cache));
|
|
2530
2110
|
const legacyServices = {
|
|
@@ -2573,9 +2153,6 @@ function createSiteActions(api, config = {}) {
|
|
|
2573
2153
|
get logistics() {
|
|
2574
2154
|
return logistics.get();
|
|
2575
2155
|
},
|
|
2576
|
-
get nexus() {
|
|
2577
|
-
return nexus.get();
|
|
2578
|
-
},
|
|
2579
2156
|
get vmi() {
|
|
2580
2157
|
return vmi.get();
|
|
2581
2158
|
},
|
|
@@ -2603,9 +2180,6 @@ function createSiteActions(api, config = {}) {
|
|
|
2603
2180
|
get gregorovich() {
|
|
2604
2181
|
return gregorovich.get();
|
|
2605
2182
|
},
|
|
2606
|
-
get slack() {
|
|
2607
|
-
return slack.get();
|
|
2608
|
-
},
|
|
2609
2183
|
get favorites() {
|
|
2610
2184
|
return favorites.get();
|
|
2611
2185
|
},
|
|
@@ -2635,20 +2209,17 @@ function createSiteActions(api, config = {}) {
|
|
|
2635
2209
|
const key = prop;
|
|
2636
2210
|
const cached = wrappedCache.get(key);
|
|
2637
2211
|
if (cached) return cached;
|
|
2638
|
-
|
|
2639
|
-
|
|
2640
|
-
const
|
|
2641
|
-
|
|
2642
|
-
|
|
2643
|
-
|
|
2644
|
-
|
|
2645
|
-
|
|
2646
|
-
|
|
2647
|
-
|
|
2648
|
-
|
|
2649
|
-
wrappedCache.set(key, wrapped);
|
|
2650
|
-
return wrapped;
|
|
2651
|
-
}
|
|
2212
|
+
if (Object.hasOwn(target, key)) {
|
|
2213
|
+
const legacySvc = Reflect.get(target, key);
|
|
2214
|
+
const wrapped = new Proxy(legacySvc, {
|
|
2215
|
+
get(svc, method) {
|
|
2216
|
+
if (typeof method === "symbol") return void 0;
|
|
2217
|
+
if (method in svc) return svc[method];
|
|
2218
|
+
return proxyFallback[key]?.[method];
|
|
2219
|
+
}
|
|
2220
|
+
});
|
|
2221
|
+
wrappedCache.set(key, wrapped);
|
|
2222
|
+
return wrapped;
|
|
2652
2223
|
}
|
|
2653
2224
|
const proxied = proxyFallback[key];
|
|
2654
2225
|
wrappedCache.set(key, proxied);
|
|
@@ -2681,15 +2252,15 @@ function clearSiteActions() {
|
|
|
2681
2252
|
|
|
2682
2253
|
// src/server-site-registry.ts
|
|
2683
2254
|
import { getCacheTier } from "@simpleapps-com/augur-core";
|
|
2255
|
+
import { AugurAPI } from "@simpleapps-com/augur-api";
|
|
2684
2256
|
function registerSiteActions2(actions) {
|
|
2685
2257
|
registerSiteActions(actions);
|
|
2686
2258
|
}
|
|
2687
2259
|
function registerClientAndWrapper(api) {
|
|
2688
2260
|
registerSdkClient(api);
|
|
2689
2261
|
registerSdkCallWrapper((methodPath, sdkCall2, ...keyArgs) => {
|
|
2690
|
-
const
|
|
2691
|
-
if (
|
|
2692
|
-
const ttl = tier.staleTime >= 36e5 ? 28800 : 3600;
|
|
2262
|
+
const ttl = ttlFor(getCacheTier(methodPath).staleTime, 3600, 28800);
|
|
2263
|
+
if (ttl === null) return sdkCall2();
|
|
2693
2264
|
return withServerCache("", ttl, methodPath, sdkCall2, ...keyArgs);
|
|
2694
2265
|
});
|
|
2695
2266
|
}
|
|
@@ -2697,7 +2268,6 @@ function autoInitFromEnv() {
|
|
|
2697
2268
|
const siteId = process.env["AUGUR_SITE_ID"];
|
|
2698
2269
|
const bearerToken = process.env["AUGUR_JWT"];
|
|
2699
2270
|
if (!siteId || !bearerToken) return null;
|
|
2700
|
-
const { AugurAPI } = __require("@simpleapps-com/augur-api");
|
|
2701
2271
|
const api = new AugurAPI({ siteId, bearerToken });
|
|
2702
2272
|
const actions = createSiteActions(api);
|
|
2703
2273
|
registerSiteActions2(actions);
|
|
@@ -2738,4 +2308,4 @@ export {
|
|
|
2738
2308
|
getSiteActions,
|
|
2739
2309
|
clearSiteActions2 as clearSiteActions
|
|
2740
2310
|
};
|
|
2741
|
-
//# sourceMappingURL=chunk-
|
|
2311
|
+
//# sourceMappingURL=chunk-PFYEMJTQ.js.map
|