@simpleapps-com/augur-server 2.4.0 → 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-2NL4QKJN.js → chunk-FWO6Q43T.js} +31 -30
- package/dist/chunk-FWO6Q43T.js.map +1 -0
- package/dist/{chunk-ALTIINP6.js → chunk-NTUPTNOI.js} +30 -6
- package/dist/chunk-NTUPTNOI.js.map +1 -0
- package/dist/{chunk-26WZBC4F.js → chunk-PFYEMJTQ.js} +203 -631
- 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-PIYHMA6F.js → chunk-U2BKHRJC.js} +10 -13
- 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 +9 -7
- 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 +15 -117
- package/dist/query-action.d.ts.map +1 -0
- package/dist/query-action.js +3 -3
- package/dist/{query.d.ts → query-options-helper.d.ts} +5 -7
- 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 +29 -20
- package/dist/actions.d.ts +0 -2
- package/dist/chunk-26WZBC4F.js.map +0 -1
- package/dist/chunk-2NL4QKJN.js.map +0 -1
- package/dist/chunk-ALTIINP6.js.map +0 -1
- package/dist/chunk-DGUM43GV.js +0 -11
- package/dist/chunk-DGUM43GV.js.map +0 -1
- package/dist/chunk-KHFEDL47.js.map +0 -1
- package/dist/chunk-PIYHMA6F.js.map +0 -1
- 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
|
-
|
|
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)");
|
|
552
561
|
}
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
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,59 +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
|
-
// Key on q AND pagination (
|
|
656
|
+
// Key on q AND pagination (limit/offset): different pages of the same query
|
|
658
657
|
// are distinct cache entries. Keying on q alone served a stale page.
|
|
659
658
|
q,
|
|
660
659
|
limit,
|
|
661
660
|
offset
|
|
662
661
|
);
|
|
663
662
|
}
|
|
664
|
-
|
|
665
|
-
|
|
663
|
+
function itemSearchParams(filters, from, itemCategoryUid) {
|
|
664
|
+
return {
|
|
666
665
|
q: filters.q,
|
|
667
666
|
searchType: "query",
|
|
668
667
|
size: filters.limit,
|
|
669
|
-
from
|
|
670
|
-
|
|
668
|
+
from,
|
|
669
|
+
sort: filters.sortBy,
|
|
671
670
|
classId5List: itemCategoryUid ? String(itemCategoryUid) : void 0,
|
|
672
671
|
filters: filters.filters?.length ? JSON.stringify(filters.filters) : void 0,
|
|
673
672
|
sourceFieldsList: defaultSourceFields,
|
|
674
673
|
edgeCache
|
|
675
674
|
};
|
|
675
|
+
}
|
|
676
|
+
async function itemSearch(filters, itemCategoryUid) {
|
|
677
|
+
const params = itemSearchParams(filters, filters.offset, itemCategoryUid);
|
|
676
678
|
return withServerCache(
|
|
677
679
|
cachePrefix,
|
|
678
680
|
redisTtl,
|
|
@@ -686,17 +688,7 @@ function createSearchActions(api, config = {}) {
|
|
|
686
688
|
);
|
|
687
689
|
}
|
|
688
690
|
async function itemSearchInfinite(filters, itemCategoryUid, pageParam = 0) {
|
|
689
|
-
const params =
|
|
690
|
-
q: filters.q,
|
|
691
|
-
searchType: "query",
|
|
692
|
-
size: filters.limit,
|
|
693
|
-
from: pageParam,
|
|
694
|
-
sortBy: filters.sortBy,
|
|
695
|
-
classId5List: itemCategoryUid ? String(itemCategoryUid) : void 0,
|
|
696
|
-
filters: filters.filters?.length ? JSON.stringify(filters.filters) : void 0,
|
|
697
|
-
sourceFieldsList: defaultSourceFields,
|
|
698
|
-
edgeCache
|
|
699
|
-
};
|
|
691
|
+
const params = itemSearchParams(filters, pageParam, itemCategoryUid);
|
|
700
692
|
return withServerCache(
|
|
701
693
|
cachePrefix,
|
|
702
694
|
redisTtl,
|
|
@@ -733,7 +725,7 @@ function createOrderActions(api, config = {}) {
|
|
|
733
725
|
redisTtl,
|
|
734
726
|
"orders.oeHdr.doc.get",
|
|
735
727
|
async () => {
|
|
736
|
-
const response = await api.orders.oeHdr.doc.get(
|
|
728
|
+
const response = await api.orders.oeHdr.doc.get(orderNo, {
|
|
737
729
|
postalCode,
|
|
738
730
|
edgeCache
|
|
739
731
|
});
|
|
@@ -896,19 +888,14 @@ function createJoomlaActions(api, config = {}) {
|
|
|
896
888
|
const response = await api.joomla.users.doc.get(Number(userId), {
|
|
897
889
|
edgeCache
|
|
898
890
|
});
|
|
899
|
-
const
|
|
900
|
-
if (!
|
|
901
|
-
const customerId = String(
|
|
902
|
-
raw["customerId"] ?? raw["customer_id"] ?? raw["p21_customer_id"] ?? ""
|
|
903
|
-
);
|
|
904
|
-
const groups = Array.isArray(raw["groups"]) ? raw["groups"] : [];
|
|
905
|
-
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");
|
|
906
893
|
return {
|
|
907
|
-
id: String(
|
|
908
|
-
name:
|
|
909
|
-
email:
|
|
910
|
-
customerId,
|
|
911
|
-
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)
|
|
912
899
|
};
|
|
913
900
|
},
|
|
914
901
|
userId
|
|
@@ -1006,20 +993,6 @@ function createLegacyActions(api, config = {}) {
|
|
|
1006
993
|
// src/actions/customers.ts
|
|
1007
994
|
function createCustomersActions(api, config = {}) {
|
|
1008
995
|
const { cachePrefix = "", edgeCache = 1, redisTtl = 3600 } = config;
|
|
1009
|
-
async function getCustomer(customerId) {
|
|
1010
|
-
return withServerCache(
|
|
1011
|
-
cachePrefix,
|
|
1012
|
-
redisTtl,
|
|
1013
|
-
"customers.customer.get",
|
|
1014
|
-
async () => {
|
|
1015
|
-
const response = await api.customers.customer.get(customerId, {
|
|
1016
|
-
edgeCache
|
|
1017
|
-
});
|
|
1018
|
-
return response.data;
|
|
1019
|
-
},
|
|
1020
|
-
customerId
|
|
1021
|
-
);
|
|
1022
|
-
}
|
|
1023
996
|
async function customerLookup(params) {
|
|
1024
997
|
return withServerCache(
|
|
1025
998
|
cachePrefix,
|
|
@@ -1029,7 +1002,6 @@ function createCustomersActions(api, config = {}) {
|
|
|
1029
1002
|
const response = await api.customers.customer.lookup.get({
|
|
1030
1003
|
...params,
|
|
1031
1004
|
edgeCache
|
|
1032
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1033
1005
|
});
|
|
1034
1006
|
return toListResult(response);
|
|
1035
1007
|
},
|
|
@@ -1059,7 +1031,6 @@ function createCustomersActions(api, config = {}) {
|
|
|
1059
1031
|
const response = await api.customers.customer.orders.list(customerId, {
|
|
1060
1032
|
...params,
|
|
1061
1033
|
edgeCache
|
|
1062
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1063
1034
|
});
|
|
1064
1035
|
return toListResult(response);
|
|
1065
1036
|
},
|
|
@@ -1073,7 +1044,7 @@ function createCustomersActions(api, config = {}) {
|
|
|
1073
1044
|
redisTtl,
|
|
1074
1045
|
"customers.customer.orders.get",
|
|
1075
1046
|
async () => {
|
|
1076
|
-
const response = await api.customers.customer.orders.get(customerId, orderId, {
|
|
1047
|
+
const response = await api.customers.customer.orders.get(customerId, String(orderId), {
|
|
1077
1048
|
edgeCache
|
|
1078
1049
|
});
|
|
1079
1050
|
return response.data;
|
|
@@ -1088,11 +1059,10 @@ function createCustomersActions(api, config = {}) {
|
|
|
1088
1059
|
redisTtl,
|
|
1089
1060
|
"customers.customer.invoices.list",
|
|
1090
1061
|
async () => {
|
|
1091
|
-
const response = await api.customers.customer.invoices.list(
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
);
|
|
1062
|
+
const response = await api.customers.customer.invoices.list(customerId, {
|
|
1063
|
+
...params,
|
|
1064
|
+
edgeCache
|
|
1065
|
+
});
|
|
1096
1066
|
return toListResult(response);
|
|
1097
1067
|
},
|
|
1098
1068
|
customerId,
|
|
@@ -1145,21 +1115,6 @@ function createCustomersActions(api, config = {}) {
|
|
|
1145
1115
|
quoteNo
|
|
1146
1116
|
);
|
|
1147
1117
|
}
|
|
1148
|
-
async function getContacts(params) {
|
|
1149
|
-
return withServerCache(
|
|
1150
|
-
cachePrefix,
|
|
1151
|
-
redisTtl,
|
|
1152
|
-
"customers.contacts.list",
|
|
1153
|
-
async () => {
|
|
1154
|
-
const response = await api.customers.contacts.list({
|
|
1155
|
-
...params,
|
|
1156
|
-
edgeCache
|
|
1157
|
-
});
|
|
1158
|
-
return toListResult(response);
|
|
1159
|
-
},
|
|
1160
|
-
params
|
|
1161
|
-
);
|
|
1162
|
-
}
|
|
1163
1118
|
async function getShipToAddresses(customerId) {
|
|
1164
1119
|
return withServerCache(
|
|
1165
1120
|
cachePrefix,
|
|
@@ -1175,7 +1130,6 @@ function createCustomersActions(api, config = {}) {
|
|
|
1175
1130
|
);
|
|
1176
1131
|
}
|
|
1177
1132
|
return {
|
|
1178
|
-
getCustomer,
|
|
1179
1133
|
customerLookup,
|
|
1180
1134
|
getCustomerDoc,
|
|
1181
1135
|
getCustomerOrders,
|
|
@@ -1184,14 +1138,12 @@ function createCustomersActions(api, config = {}) {
|
|
|
1184
1138
|
getCustomerInvoiceDetail,
|
|
1185
1139
|
getCustomerQuotes,
|
|
1186
1140
|
getCustomerQuoteDetail,
|
|
1187
|
-
getContacts,
|
|
1188
1141
|
getShipToAddresses
|
|
1189
1142
|
};
|
|
1190
1143
|
}
|
|
1191
1144
|
|
|
1192
1145
|
// src/actions/smarty-streets.ts
|
|
1193
|
-
function createSmartyStreetsActions(api,
|
|
1194
|
-
const { cachePrefix: _cachePrefix = "" } = config;
|
|
1146
|
+
function createSmartyStreetsActions(api, _config = {}) {
|
|
1195
1147
|
async function validateAddress(params) {
|
|
1196
1148
|
try {
|
|
1197
1149
|
const response = await api.smartyStreets.us.lookup.get(params);
|
|
@@ -1256,39 +1208,28 @@ function createAgrSiteActions(api, config = {}) {
|
|
|
1256
1208
|
"agrSite.settings.list",
|
|
1257
1209
|
async () => {
|
|
1258
1210
|
const response = await api.agrSite.settings.list({
|
|
1259
|
-
|
|
1211
|
+
serviceName,
|
|
1260
1212
|
edgeCache: longEdgeCache
|
|
1261
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1262
1213
|
});
|
|
1263
1214
|
return toListResult(response);
|
|
1264
1215
|
},
|
|
1265
1216
|
serviceName
|
|
1266
1217
|
);
|
|
1267
1218
|
}
|
|
1268
|
-
async function
|
|
1269
|
-
return withServerCache(
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
async () => {
|
|
1274
|
-
const response = await api.agrSite.metaFiles.list({
|
|
1275
|
-
...params,
|
|
1276
|
-
edgeCache: longEdgeCache
|
|
1277
|
-
});
|
|
1278
|
-
return toListResult(response);
|
|
1279
|
-
},
|
|
1280
|
-
params
|
|
1281
|
-
);
|
|
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
|
+
});
|
|
1282
1224
|
}
|
|
1283
1225
|
return {
|
|
1284
1226
|
getSettings,
|
|
1285
|
-
|
|
1227
|
+
getRobots
|
|
1286
1228
|
};
|
|
1287
1229
|
}
|
|
1288
1230
|
|
|
1289
1231
|
// src/actions/avalara.ts
|
|
1290
|
-
function createAvalaraActions(api,
|
|
1291
|
-
const { cachePrefix: _cachePrefix = "" } = config;
|
|
1232
|
+
function createAvalaraActions(api, _config = {}) {
|
|
1292
1233
|
async function calculateTax(data) {
|
|
1293
1234
|
const response = await api.avalara.rates.create(data);
|
|
1294
1235
|
return response.data;
|
|
@@ -1300,16 +1241,13 @@ function createAvalaraActions(api, config = {}) {
|
|
|
1300
1241
|
|
|
1301
1242
|
// src/actions/payments.ts
|
|
1302
1243
|
function createPaymentsActions(api, config = {}) {
|
|
1303
|
-
const
|
|
1244
|
+
const mode = configuredModeOf(config.mode);
|
|
1304
1245
|
function withMode(params) {
|
|
1305
1246
|
return { mode, ...params };
|
|
1306
1247
|
}
|
|
1307
1248
|
async function transactionSetup(params) {
|
|
1308
1249
|
try {
|
|
1309
|
-
const response = (
|
|
1310
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1311
|
-
await api.payments.unified.transactionSetup.list(withMode(params))
|
|
1312
|
-
);
|
|
1250
|
+
const response = await api.payments.unified.transactionSetup.list(withMode(params));
|
|
1313
1251
|
return response.data;
|
|
1314
1252
|
} catch {
|
|
1315
1253
|
return void 0;
|
|
@@ -1317,10 +1255,7 @@ function createPaymentsActions(api, config = {}) {
|
|
|
1317
1255
|
}
|
|
1318
1256
|
async function accountQuery(params) {
|
|
1319
1257
|
try {
|
|
1320
|
-
const response = (
|
|
1321
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1322
|
-
await api.payments.unified.accountQuery.list(withMode(params))
|
|
1323
|
-
);
|
|
1258
|
+
const response = await api.payments.unified.accountQuery.list(withMode(params));
|
|
1324
1259
|
return response.data;
|
|
1325
1260
|
} catch {
|
|
1326
1261
|
return void 0;
|
|
@@ -1328,10 +1263,7 @@ function createPaymentsActions(api, config = {}) {
|
|
|
1328
1263
|
}
|
|
1329
1264
|
async function getSurcharge(params) {
|
|
1330
1265
|
try {
|
|
1331
|
-
const response = (
|
|
1332
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1333
|
-
await api.payments.unified.surcharge.list(withMode(params))
|
|
1334
|
-
);
|
|
1266
|
+
const response = await api.payments.unified.surcharge.list(withMode(params));
|
|
1335
1267
|
return response.data;
|
|
1336
1268
|
} catch {
|
|
1337
1269
|
return void 0;
|
|
@@ -1339,10 +1271,7 @@ function createPaymentsActions(api, config = {}) {
|
|
|
1339
1271
|
}
|
|
1340
1272
|
async function cardInfo(params) {
|
|
1341
1273
|
try {
|
|
1342
|
-
const response = (
|
|
1343
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1344
|
-
await api.payments.unified.cardInfo.list(withMode(params))
|
|
1345
|
-
);
|
|
1274
|
+
const response = await api.payments.unified.cardInfo.list(withMode(params));
|
|
1346
1275
|
return response.data;
|
|
1347
1276
|
} catch {
|
|
1348
1277
|
return void 0;
|
|
@@ -1350,10 +1279,7 @@ function createPaymentsActions(api, config = {}) {
|
|
|
1350
1279
|
}
|
|
1351
1280
|
async function billingUpdate(params) {
|
|
1352
1281
|
try {
|
|
1353
|
-
const response = (
|
|
1354
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1355
|
-
await api.payments.unified.billingUpdate.list(withMode(params))
|
|
1356
|
-
);
|
|
1282
|
+
const response = await api.payments.unified.billingUpdate.list(withMode(params));
|
|
1357
1283
|
return response.data;
|
|
1358
1284
|
} catch {
|
|
1359
1285
|
return void 0;
|
|
@@ -1361,18 +1287,8 @@ function createPaymentsActions(api, config = {}) {
|
|
|
1361
1287
|
}
|
|
1362
1288
|
async function validatePayment(params) {
|
|
1363
1289
|
try {
|
|
1364
|
-
const response = (
|
|
1365
|
-
|
|
1366
|
-
await api.payments.unified.validate.list(withMode(params))
|
|
1367
|
-
);
|
|
1368
|
-
const raw = response.data;
|
|
1369
|
-
if (typeof raw === "boolean") {
|
|
1370
|
-
return { valid: raw };
|
|
1371
|
-
}
|
|
1372
|
-
if (typeof raw === "object" && raw !== null && "valid" in raw) {
|
|
1373
|
-
return raw;
|
|
1374
|
-
}
|
|
1375
|
-
return { valid: Boolean(raw) };
|
|
1290
|
+
const response = await api.payments.unified.validate.list(withMode(params));
|
|
1291
|
+
return response.data;
|
|
1376
1292
|
} catch {
|
|
1377
1293
|
return void 0;
|
|
1378
1294
|
}
|
|
@@ -1407,11 +1323,10 @@ function createLogisticsActions(api, config = {}) {
|
|
|
1407
1323
|
const response = await api.logistics.shipvia.rates.list({
|
|
1408
1324
|
...params,
|
|
1409
1325
|
edgeCache: longEdgeCache
|
|
1410
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1411
1326
|
});
|
|
1412
1327
|
return toListResult(response);
|
|
1413
1328
|
},
|
|
1414
|
-
|
|
1329
|
+
JSON.stringify(params)
|
|
1415
1330
|
);
|
|
1416
1331
|
}
|
|
1417
1332
|
return {
|
|
@@ -1420,88 +1335,6 @@ function createLogisticsActions(api, config = {}) {
|
|
|
1420
1335
|
};
|
|
1421
1336
|
}
|
|
1422
1337
|
|
|
1423
|
-
// src/actions/nexus.ts
|
|
1424
|
-
function createNexusActions(api, config = {}) {
|
|
1425
|
-
const { cachePrefix = "", edgeCache = 1, redisTtl = 3600 } = config;
|
|
1426
|
-
async function createBinTransfer(data) {
|
|
1427
|
-
try {
|
|
1428
|
-
const response = await api.nexus.binTransfer.create(data);
|
|
1429
|
-
return response.data;
|
|
1430
|
-
} catch {
|
|
1431
|
-
return void 0;
|
|
1432
|
-
}
|
|
1433
|
-
}
|
|
1434
|
-
async function createReceiving(data) {
|
|
1435
|
-
try {
|
|
1436
|
-
const response = await api.nexus.receiving.create(data);
|
|
1437
|
-
return response.data;
|
|
1438
|
-
} catch {
|
|
1439
|
-
return void 0;
|
|
1440
|
-
}
|
|
1441
|
-
}
|
|
1442
|
-
async function createTransfer(data) {
|
|
1443
|
-
try {
|
|
1444
|
-
const response = await api.nexus.transfer.create(data);
|
|
1445
|
-
return response.data;
|
|
1446
|
-
} catch {
|
|
1447
|
-
return void 0;
|
|
1448
|
-
}
|
|
1449
|
-
}
|
|
1450
|
-
async function getPurchaseOrderReceipts(params) {
|
|
1451
|
-
return withServerCache(
|
|
1452
|
-
cachePrefix,
|
|
1453
|
-
redisTtl,
|
|
1454
|
-
"nexus.purchaseOrderReceipt.list",
|
|
1455
|
-
async () => {
|
|
1456
|
-
const response = await api.nexus.purchaseOrderReceipt.list({
|
|
1457
|
-
...params,
|
|
1458
|
-
edgeCache
|
|
1459
|
-
});
|
|
1460
|
-
return toListResult(response);
|
|
1461
|
-
},
|
|
1462
|
-
params ? JSON.stringify(params) : void 0
|
|
1463
|
-
);
|
|
1464
|
-
}
|
|
1465
|
-
async function getTransferReceipts(params) {
|
|
1466
|
-
return withServerCache(
|
|
1467
|
-
cachePrefix,
|
|
1468
|
-
redisTtl,
|
|
1469
|
-
"nexus.transferReceipt.list",
|
|
1470
|
-
async () => {
|
|
1471
|
-
const response = await api.nexus.transferReceipt.list({
|
|
1472
|
-
...params,
|
|
1473
|
-
edgeCache
|
|
1474
|
-
});
|
|
1475
|
-
return toListResult(response);
|
|
1476
|
-
},
|
|
1477
|
-
params ? JSON.stringify(params) : void 0
|
|
1478
|
-
);
|
|
1479
|
-
}
|
|
1480
|
-
async function getTransferShipping(params) {
|
|
1481
|
-
return withServerCache(
|
|
1482
|
-
cachePrefix,
|
|
1483
|
-
redisTtl,
|
|
1484
|
-
"nexus.transferShipping.list",
|
|
1485
|
-
async () => {
|
|
1486
|
-
const response = await api.nexus.transferShipping.list({
|
|
1487
|
-
...params,
|
|
1488
|
-
edgeCache
|
|
1489
|
-
});
|
|
1490
|
-
return toListResult(response);
|
|
1491
|
-
},
|
|
1492
|
-
params ? JSON.stringify(params) : void 0
|
|
1493
|
-
);
|
|
1494
|
-
}
|
|
1495
|
-
return {
|
|
1496
|
-
createBinTransfer,
|
|
1497
|
-
createReceiving,
|
|
1498
|
-
createTransfer,
|
|
1499
|
-
getPurchaseOrderReceipts,
|
|
1500
|
-
getTransferReceipts,
|
|
1501
|
-
getTransferShipping
|
|
1502
|
-
};
|
|
1503
|
-
}
|
|
1504
|
-
|
|
1505
1338
|
// src/actions/vmi.ts
|
|
1506
1339
|
function createVmiActions(api, config = {}) {
|
|
1507
1340
|
const { cachePrefix = "", edgeCache = 1, redisTtl = 3600, shortRedisTtl = 300 } = config;
|
|
@@ -1511,14 +1344,10 @@ function createVmiActions(api, config = {}) {
|
|
|
1511
1344
|
redisTtl,
|
|
1512
1345
|
"vmi.warehouse.list",
|
|
1513
1346
|
async () => {
|
|
1514
|
-
const response = await api.vmi.warehouse.list({
|
|
1515
|
-
...params,
|
|
1516
|
-
edgeCache
|
|
1517
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1518
|
-
});
|
|
1347
|
+
const response = await api.vmi.warehouse.list({ ...params, edgeCache });
|
|
1519
1348
|
return toListResult(response);
|
|
1520
1349
|
},
|
|
1521
|
-
|
|
1350
|
+
JSON.stringify(params)
|
|
1522
1351
|
);
|
|
1523
1352
|
}
|
|
1524
1353
|
async function getWarehouseAvailability(warehouseUid, params) {
|
|
@@ -1527,15 +1356,14 @@ function createVmiActions(api, config = {}) {
|
|
|
1527
1356
|
shortRedisTtl,
|
|
1528
1357
|
"vmi.warehouse.availability.get",
|
|
1529
1358
|
async () => {
|
|
1530
|
-
const response = await api.vmi.warehouse.availability.list(
|
|
1531
|
-
|
|
1532
|
-
|
|
1533
|
-
|
|
1534
|
-
);
|
|
1359
|
+
const response = await api.vmi.warehouse.availability.list(warehouseUid, {
|
|
1360
|
+
...params,
|
|
1361
|
+
edgeCache
|
|
1362
|
+
});
|
|
1535
1363
|
return toListResult(response);
|
|
1536
1364
|
},
|
|
1537
1365
|
warehouseUid,
|
|
1538
|
-
|
|
1366
|
+
JSON.stringify(params)
|
|
1539
1367
|
);
|
|
1540
1368
|
}
|
|
1541
1369
|
async function getDistributors(params) {
|
|
@@ -1544,14 +1372,10 @@ function createVmiActions(api, config = {}) {
|
|
|
1544
1372
|
redisTtl,
|
|
1545
1373
|
"vmi.distributors.list",
|
|
1546
1374
|
async () => {
|
|
1547
|
-
const response = await api.vmi.distributors.list({
|
|
1548
|
-
...params,
|
|
1549
|
-
edgeCache
|
|
1550
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1551
|
-
});
|
|
1375
|
+
const response = await api.vmi.distributors.list({ ...params, edgeCache });
|
|
1552
1376
|
return toListResult(response);
|
|
1553
1377
|
},
|
|
1554
|
-
|
|
1378
|
+
JSON.stringify(params)
|
|
1555
1379
|
);
|
|
1556
1380
|
}
|
|
1557
1381
|
async function getProducts(params) {
|
|
@@ -1560,14 +1384,10 @@ function createVmiActions(api, config = {}) {
|
|
|
1560
1384
|
redisTtl,
|
|
1561
1385
|
"vmi.products.list",
|
|
1562
1386
|
async () => {
|
|
1563
|
-
const response = await api.vmi.products.list({
|
|
1564
|
-
...params,
|
|
1565
|
-
edgeCache
|
|
1566
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1567
|
-
});
|
|
1387
|
+
const response = await api.vmi.products.list({ ...params, edgeCache });
|
|
1568
1388
|
return toListResult(response);
|
|
1569
1389
|
},
|
|
1570
|
-
|
|
1390
|
+
JSON.stringify(params)
|
|
1571
1391
|
);
|
|
1572
1392
|
}
|
|
1573
1393
|
async function getInventoryProfiles(params) {
|
|
@@ -1576,14 +1396,10 @@ function createVmiActions(api, config = {}) {
|
|
|
1576
1396
|
redisTtl,
|
|
1577
1397
|
"vmi.invProfileHdr.list",
|
|
1578
1398
|
async () => {
|
|
1579
|
-
const response = await api.vmi.invProfileHdr.list({
|
|
1580
|
-
...params,
|
|
1581
|
-
edgeCache
|
|
1582
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1583
|
-
});
|
|
1399
|
+
const response = await api.vmi.invProfileHdr.list({ ...params, edgeCache });
|
|
1584
1400
|
return toListResult(response);
|
|
1585
1401
|
},
|
|
1586
|
-
|
|
1402
|
+
JSON.stringify(params)
|
|
1587
1403
|
);
|
|
1588
1404
|
}
|
|
1589
1405
|
async function getRestockHeaders(params) {
|
|
@@ -1592,11 +1408,7 @@ function createVmiActions(api, config = {}) {
|
|
|
1592
1408
|
redisTtl,
|
|
1593
1409
|
"vmi.restockHdr.list",
|
|
1594
1410
|
async () => {
|
|
1595
|
-
const response = await api.vmi.restockHdr.list({
|
|
1596
|
-
...params,
|
|
1597
|
-
edgeCache
|
|
1598
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1599
|
-
});
|
|
1411
|
+
const response = await api.vmi.restockHdr.list({ ...params, edgeCache });
|
|
1600
1412
|
return toListResult(response);
|
|
1601
1413
|
},
|
|
1602
1414
|
params ? JSON.stringify(params) : void 0
|
|
@@ -1608,14 +1420,10 @@ function createVmiActions(api, config = {}) {
|
|
|
1608
1420
|
redisTtl,
|
|
1609
1421
|
"vmi.sections.list",
|
|
1610
1422
|
async () => {
|
|
1611
|
-
const response = await api.vmi.sections.list({
|
|
1612
|
-
...params,
|
|
1613
|
-
edgeCache
|
|
1614
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1615
|
-
});
|
|
1423
|
+
const response = await api.vmi.sections.list({ ...params, edgeCache });
|
|
1616
1424
|
return toListResult(response);
|
|
1617
1425
|
},
|
|
1618
|
-
|
|
1426
|
+
JSON.stringify(params)
|
|
1619
1427
|
);
|
|
1620
1428
|
}
|
|
1621
1429
|
return {
|
|
@@ -1736,7 +1544,6 @@ function createP21CoreActions(api, config = {}) {
|
|
|
1736
1544
|
const response = await api.p21Core.codeP21.list({
|
|
1737
1545
|
...params,
|
|
1738
1546
|
edgeCache: longEdgeCache
|
|
1739
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1740
1547
|
});
|
|
1741
1548
|
return toListResult(response);
|
|
1742
1549
|
},
|
|
@@ -1755,103 +1562,10 @@ function createP21CoreActions(api, config = {}) {
|
|
|
1755
1562
|
}
|
|
1756
1563
|
|
|
1757
1564
|
// src/actions/p21-apis.ts
|
|
1758
|
-
function createP21ApisActions(api,
|
|
1759
|
-
const { cachePrefix = "", edgeCache = 1, redisTtl = 3600 } = config;
|
|
1760
|
-
async function getCategories(params) {
|
|
1761
|
-
return withServerCache(
|
|
1762
|
-
cachePrefix,
|
|
1763
|
-
redisTtl,
|
|
1764
|
-
"p21Apis.transCategory.list",
|
|
1765
|
-
async () => {
|
|
1766
|
-
const response = await api.p21Apis.transCategory.list({
|
|
1767
|
-
...params,
|
|
1768
|
-
edgeCache
|
|
1769
|
-
});
|
|
1770
|
-
return toListResult(response);
|
|
1771
|
-
},
|
|
1772
|
-
params
|
|
1773
|
-
);
|
|
1774
|
-
}
|
|
1775
|
-
async function getCategoryDefaults(categoryId) {
|
|
1776
|
-
return withServerCache(
|
|
1777
|
-
cachePrefix,
|
|
1778
|
-
redisTtl,
|
|
1779
|
-
"p21Apis.transCategory.defaults.get",
|
|
1780
|
-
async () => {
|
|
1781
|
-
const response = await api.p21Apis.transCategory.defaults.get(categoryId, {
|
|
1782
|
-
edgeCache
|
|
1783
|
-
});
|
|
1784
|
-
return response.data;
|
|
1785
|
-
},
|
|
1786
|
-
categoryId
|
|
1787
|
-
);
|
|
1788
|
-
}
|
|
1789
|
-
async function getCompanies(params) {
|
|
1790
|
-
return withServerCache(
|
|
1791
|
-
cachePrefix,
|
|
1792
|
-
redisTtl,
|
|
1793
|
-
"p21Apis.transCompany.list",
|
|
1794
|
-
async () => {
|
|
1795
|
-
const response = await api.p21Apis.transCompany.list({
|
|
1796
|
-
...params,
|
|
1797
|
-
edgeCache
|
|
1798
|
-
});
|
|
1799
|
-
return toListResult(response);
|
|
1800
|
-
},
|
|
1801
|
-
params
|
|
1802
|
-
);
|
|
1803
|
-
}
|
|
1804
|
-
async function getUsers(params) {
|
|
1805
|
-
return withServerCache(
|
|
1806
|
-
cachePrefix,
|
|
1807
|
-
redisTtl,
|
|
1808
|
-
"p21Apis.transUser.list",
|
|
1809
|
-
async () => {
|
|
1810
|
-
const response = await api.p21Apis.transUser.list({
|
|
1811
|
-
...params,
|
|
1812
|
-
edgeCache
|
|
1813
|
-
});
|
|
1814
|
-
return toListResult(response);
|
|
1815
|
-
},
|
|
1816
|
-
params
|
|
1817
|
-
);
|
|
1818
|
-
}
|
|
1819
|
-
async function getWebDisplayTypes(params) {
|
|
1820
|
-
return withServerCache(
|
|
1821
|
-
cachePrefix,
|
|
1822
|
-
redisTtl,
|
|
1823
|
-
"p21Apis.transWebDisplayType.list",
|
|
1824
|
-
async () => {
|
|
1825
|
-
const response = await api.p21Apis.transWebDisplayType.list({
|
|
1826
|
-
...params,
|
|
1827
|
-
edgeCache
|
|
1828
|
-
});
|
|
1829
|
-
return toListResult(response);
|
|
1830
|
-
},
|
|
1831
|
-
params
|
|
1832
|
-
);
|
|
1833
|
-
}
|
|
1834
|
-
async function getWebDisplayTypeDefaults(id) {
|
|
1835
|
-
return withServerCache(
|
|
1836
|
-
cachePrefix,
|
|
1837
|
-
redisTtl,
|
|
1838
|
-
"p21Apis.transWebDisplayType.defaults.get",
|
|
1839
|
-
async () => {
|
|
1840
|
-
const response = await api.p21Apis.transWebDisplayType.defaults.list({
|
|
1841
|
-
id,
|
|
1842
|
-
edgeCache
|
|
1843
|
-
});
|
|
1844
|
-
return response.data;
|
|
1845
|
-
},
|
|
1846
|
-
id
|
|
1847
|
-
);
|
|
1848
|
-
}
|
|
1565
|
+
function createP21ApisActions(api, _config = {}) {
|
|
1849
1566
|
async function refreshContacts(params) {
|
|
1850
1567
|
try {
|
|
1851
|
-
const response = (
|
|
1852
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1853
|
-
await api.p21Apis.entityContacts.refresh.create(params)
|
|
1854
|
-
);
|
|
1568
|
+
const response = await api.p21Apis.entityContacts.refresh.get(params);
|
|
1855
1569
|
return response.data;
|
|
1856
1570
|
} catch {
|
|
1857
1571
|
return void 0;
|
|
@@ -1859,22 +1573,13 @@ function createP21ApisActions(api, config = {}) {
|
|
|
1859
1573
|
}
|
|
1860
1574
|
async function refreshCustomers(params) {
|
|
1861
1575
|
try {
|
|
1862
|
-
const response = (
|
|
1863
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1864
|
-
await api.p21Apis.entityCustomers.refresh.create(params)
|
|
1865
|
-
);
|
|
1576
|
+
const response = await api.p21Apis.entityCustomers.refresh.get(params);
|
|
1866
1577
|
return response.data;
|
|
1867
1578
|
} catch {
|
|
1868
1579
|
return void 0;
|
|
1869
1580
|
}
|
|
1870
1581
|
}
|
|
1871
1582
|
return {
|
|
1872
|
-
getCategories,
|
|
1873
|
-
getCategoryDefaults,
|
|
1874
|
-
getCompanies,
|
|
1875
|
-
getUsers,
|
|
1876
|
-
getWebDisplayTypes,
|
|
1877
|
-
getWebDisplayTypeDefaults,
|
|
1878
1583
|
refreshContacts,
|
|
1879
1584
|
refreshCustomers
|
|
1880
1585
|
};
|
|
@@ -1898,33 +1603,16 @@ function createP21SismActions(api, config = {}) {
|
|
|
1898
1603
|
params
|
|
1899
1604
|
);
|
|
1900
1605
|
}
|
|
1901
|
-
async function getImport(
|
|
1606
|
+
async function getImport(importUid) {
|
|
1902
1607
|
return withServerCache(
|
|
1903
1608
|
cachePrefix,
|
|
1904
1609
|
redisTtl,
|
|
1905
1610
|
"p21Sism.import.get",
|
|
1906
1611
|
async () => {
|
|
1907
|
-
const response = await api.p21Sism.import.get(
|
|
1612
|
+
const response = await api.p21Sism.import.get(importUid);
|
|
1908
1613
|
return response.data;
|
|
1909
1614
|
},
|
|
1910
|
-
|
|
1911
|
-
);
|
|
1912
|
-
}
|
|
1913
|
-
async function getImportLines(importId, params) {
|
|
1914
|
-
return withServerCache(
|
|
1915
|
-
cachePrefix,
|
|
1916
|
-
redisTtl,
|
|
1917
|
-
"p21Sism.impOeLine.list",
|
|
1918
|
-
async () => {
|
|
1919
|
-
const response = await api.p21Sism.impOeLine.list({
|
|
1920
|
-
...params,
|
|
1921
|
-
importUid: importId,
|
|
1922
|
-
edgeCache
|
|
1923
|
-
});
|
|
1924
|
-
return toListResult(response);
|
|
1925
|
-
},
|
|
1926
|
-
importId,
|
|
1927
|
-
params
|
|
1615
|
+
importUid
|
|
1928
1616
|
);
|
|
1929
1617
|
}
|
|
1930
1618
|
async function getScheduledImports(params) {
|
|
@@ -1945,7 +1633,6 @@ function createP21SismActions(api, config = {}) {
|
|
|
1945
1633
|
return {
|
|
1946
1634
|
getRecentImports,
|
|
1947
1635
|
getImport,
|
|
1948
|
-
getImportLines,
|
|
1949
1636
|
getScheduledImports
|
|
1950
1637
|
};
|
|
1951
1638
|
}
|
|
@@ -2069,11 +1756,7 @@ function createBasecamp2Actions(api, config = {}) {
|
|
|
2069
1756
|
redisTtl,
|
|
2070
1757
|
"basecamp2.todos.list",
|
|
2071
1758
|
async () => {
|
|
2072
|
-
const response = await api.basecamp2.todos.list({
|
|
2073
|
-
...params,
|
|
2074
|
-
edgeCache
|
|
2075
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
2076
|
-
});
|
|
1759
|
+
const response = await api.basecamp2.todos.list({ ...params, edgeCache });
|
|
2077
1760
|
return toListResult(response);
|
|
2078
1761
|
},
|
|
2079
1762
|
params
|
|
@@ -2097,11 +1780,7 @@ function createBasecamp2Actions(api, config = {}) {
|
|
|
2097
1780
|
redisTtl,
|
|
2098
1781
|
"basecamp2.todosSummary.list",
|
|
2099
1782
|
async () => {
|
|
2100
|
-
const response = await api.basecamp2.todosSummary.list({
|
|
2101
|
-
...params,
|
|
2102
|
-
edgeCache
|
|
2103
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
2104
|
-
});
|
|
1783
|
+
const response = await api.basecamp2.todosSummary.list({ ...params, edgeCache });
|
|
2105
1784
|
return toListResult(response);
|
|
2106
1785
|
},
|
|
2107
1786
|
params
|
|
@@ -2113,11 +1792,7 @@ function createBasecamp2Actions(api, config = {}) {
|
|
|
2113
1792
|
redisTtl,
|
|
2114
1793
|
"basecamp2.comments.list",
|
|
2115
1794
|
async () => {
|
|
2116
|
-
const response = await api.basecamp2.comments.list({
|
|
2117
|
-
...params,
|
|
2118
|
-
edgeCache
|
|
2119
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
2120
|
-
});
|
|
1795
|
+
const response = await api.basecamp2.comments.list({ ...params, edgeCache });
|
|
2121
1796
|
return toListResult(response);
|
|
2122
1797
|
},
|
|
2123
1798
|
params
|
|
@@ -2132,7 +1807,6 @@ function createBasecamp2Actions(api, config = {}) {
|
|
|
2132
1807
|
const response = await api.basecamp2.people.list({
|
|
2133
1808
|
...params,
|
|
2134
1809
|
edgeCache: longEdgeCache
|
|
2135
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
2136
1810
|
});
|
|
2137
1811
|
return toListResult(response);
|
|
2138
1812
|
},
|
|
@@ -2145,11 +1819,7 @@ function createBasecamp2Actions(api, config = {}) {
|
|
|
2145
1819
|
redisTtl,
|
|
2146
1820
|
"basecamp2.projects.list",
|
|
2147
1821
|
async () => {
|
|
2148
|
-
const response = await api.basecamp2.projects.list({
|
|
2149
|
-
...params,
|
|
2150
|
-
edgeCache
|
|
2151
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
2152
|
-
});
|
|
1822
|
+
const response = await api.basecamp2.projects.list({ ...params, edgeCache });
|
|
2153
1823
|
return toListResult(response);
|
|
2154
1824
|
},
|
|
2155
1825
|
params
|
|
@@ -2161,11 +1831,7 @@ function createBasecamp2Actions(api, config = {}) {
|
|
|
2161
1831
|
redisTtl,
|
|
2162
1832
|
"basecamp2.events.list",
|
|
2163
1833
|
async () => {
|
|
2164
|
-
const response = await api.basecamp2.events.list({
|
|
2165
|
-
...params,
|
|
2166
|
-
edgeCache
|
|
2167
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
2168
|
-
});
|
|
1834
|
+
const response = await api.basecamp2.events.list({ ...params, edgeCache });
|
|
2169
1835
|
return toListResult(response);
|
|
2170
1836
|
},
|
|
2171
1837
|
params
|
|
@@ -2177,11 +1843,7 @@ function createBasecamp2Actions(api, config = {}) {
|
|
|
2177
1843
|
redisTtl,
|
|
2178
1844
|
"basecamp2.metrics.list",
|
|
2179
1845
|
async () => {
|
|
2180
|
-
const response = await api.basecamp2.metrics.list({
|
|
2181
|
-
...params,
|
|
2182
|
-
edgeCache
|
|
2183
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
2184
|
-
});
|
|
1846
|
+
const response = await api.basecamp2.metrics.list({ ...params, edgeCache });
|
|
2185
1847
|
return toListResult(response);
|
|
2186
1848
|
},
|
|
2187
1849
|
params
|
|
@@ -2193,11 +1855,7 @@ function createBasecamp2Actions(api, config = {}) {
|
|
|
2193
1855
|
redisTtl,
|
|
2194
1856
|
"basecamp2.todolists.list",
|
|
2195
1857
|
async () => {
|
|
2196
|
-
const response = await api.basecamp2.todolists.list({
|
|
2197
|
-
...params,
|
|
2198
|
-
edgeCache
|
|
2199
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
2200
|
-
});
|
|
1858
|
+
const response = await api.basecamp2.todolists.list({ ...params, edgeCache });
|
|
2201
1859
|
return toListResult(response);
|
|
2202
1860
|
},
|
|
2203
1861
|
params
|
|
@@ -2234,25 +1892,25 @@ function createBrandFolderActions(api, config = {}) {
|
|
|
2234
1892
|
params
|
|
2235
1893
|
);
|
|
2236
1894
|
}
|
|
2237
|
-
async function getCategory(
|
|
1895
|
+
async function getCategory(itemCategoryUid) {
|
|
2238
1896
|
return withServerCache(
|
|
2239
1897
|
cachePrefix,
|
|
2240
1898
|
redisTtl,
|
|
2241
1899
|
"brandFolder.categories.get",
|
|
2242
1900
|
async () => {
|
|
2243
|
-
const response = await api.brandFolder.categories.get(
|
|
1901
|
+
const response = await api.brandFolder.categories.get(itemCategoryUid, {
|
|
2244
1902
|
edgeCache
|
|
2245
1903
|
});
|
|
2246
1904
|
return response.data;
|
|
2247
1905
|
},
|
|
2248
|
-
|
|
1906
|
+
itemCategoryUid
|
|
2249
1907
|
);
|
|
2250
1908
|
}
|
|
2251
1909
|
async function createFocus(categoryId, data) {
|
|
2252
1910
|
try {
|
|
2253
1911
|
const response = await api.brandFolder.categories.focus.create({
|
|
2254
1912
|
...data,
|
|
2255
|
-
categoryId
|
|
1913
|
+
itemCategoryId: categoryId
|
|
2256
1914
|
});
|
|
2257
1915
|
return response.data;
|
|
2258
1916
|
} catch {
|
|
@@ -2269,74 +1927,13 @@ function createBrandFolderActions(api, config = {}) {
|
|
|
2269
1927
|
// src/actions/gregorovich.ts
|
|
2270
1928
|
function createGregorovichActions(api, config = {}) {
|
|
2271
1929
|
const { cachePrefix = "", redisTtl = 3600 } = config;
|
|
2272
|
-
async function askChatGpt(params) {
|
|
2273
|
-
try {
|
|
2274
|
-
const response = await api.gregorovich.chatGpt.ask.get(params);
|
|
2275
|
-
return response.data;
|
|
2276
|
-
} catch {
|
|
2277
|
-
return void 0;
|
|
2278
|
-
}
|
|
2279
|
-
}
|
|
2280
1930
|
async function getDocuments(_params) {
|
|
2281
1931
|
return withServerCache(cachePrefix, redisTtl, "gregorovich.documents.list", async () => {
|
|
2282
1932
|
const response = await api.gregorovich.documents.list();
|
|
2283
1933
|
return toListResult(response);
|
|
2284
1934
|
});
|
|
2285
1935
|
}
|
|
2286
|
-
|
|
2287
|
-
try {
|
|
2288
|
-
const response = await api.gregorovich.documents.create(data);
|
|
2289
|
-
return response.data;
|
|
2290
|
-
} catch {
|
|
2291
|
-
return void 0;
|
|
2292
|
-
}
|
|
2293
|
-
}
|
|
2294
|
-
async function generateOllama(data) {
|
|
2295
|
-
try {
|
|
2296
|
-
const response = await api.gregorovich.ollama.generate.create(data);
|
|
2297
|
-
return response.data;
|
|
2298
|
-
} catch {
|
|
2299
|
-
return void 0;
|
|
2300
|
-
}
|
|
2301
|
-
}
|
|
2302
|
-
return {
|
|
2303
|
-
askChatGpt,
|
|
2304
|
-
getDocuments,
|
|
2305
|
-
createDocument,
|
|
2306
|
-
generateOllama
|
|
2307
|
-
};
|
|
2308
|
-
}
|
|
2309
|
-
|
|
2310
|
-
// src/actions/slack.ts
|
|
2311
|
-
function createSlackActions(api, config = {}) {
|
|
2312
|
-
const { cachePrefix = "", edgeCache = 1, redisTtl = 3600 } = config;
|
|
2313
|
-
async function sendWebhook(data) {
|
|
2314
|
-
try {
|
|
2315
|
-
const response = await api.slack.webHook.create(data);
|
|
2316
|
-
return response.data;
|
|
2317
|
-
} catch {
|
|
2318
|
-
return void 0;
|
|
2319
|
-
}
|
|
2320
|
-
}
|
|
2321
|
-
async function getWebhooks(params) {
|
|
2322
|
-
return withServerCache(
|
|
2323
|
-
cachePrefix,
|
|
2324
|
-
redisTtl,
|
|
2325
|
-
"slack.webHook.list",
|
|
2326
|
-
async () => {
|
|
2327
|
-
const response = await api.slack.webHook.list({
|
|
2328
|
-
...params,
|
|
2329
|
-
edgeCache
|
|
2330
|
-
});
|
|
2331
|
-
return toListResult(response);
|
|
2332
|
-
},
|
|
2333
|
-
params
|
|
2334
|
-
);
|
|
2335
|
-
}
|
|
2336
|
-
return {
|
|
2337
|
-
sendWebhook,
|
|
2338
|
-
getWebhooks
|
|
2339
|
-
};
|
|
1936
|
+
return { getDocuments };
|
|
2340
1937
|
}
|
|
2341
1938
|
|
|
2342
1939
|
// src/actions/favorites.ts
|
|
@@ -2357,9 +1954,7 @@ function createFavoritesActions(api, config = {}) {
|
|
|
2357
1954
|
);
|
|
2358
1955
|
}
|
|
2359
1956
|
async function addFavorite(userId, invMastUid) {
|
|
2360
|
-
const response = await api.items.itemFavorites.items.create(userId,
|
|
2361
|
-
invMastUid
|
|
2362
|
-
});
|
|
1957
|
+
const response = await api.items.itemFavorites.items.create(userId, [invMastUid]);
|
|
2363
1958
|
return response.data;
|
|
2364
1959
|
}
|
|
2365
1960
|
async function removeFavorite(userId, invMastUid) {
|
|
@@ -2406,12 +2001,7 @@ function createWishlistActions(api, config = {}) {
|
|
|
2406
2001
|
await api.items.itemWishlist.hdr.delete(userId, wishlistId);
|
|
2407
2002
|
}
|
|
2408
2003
|
async function addWishlistItems(userId, wishlistId, items) {
|
|
2409
|
-
const response = await api.items.itemWishlist.hdr.create(
|
|
2410
|
-
userId,
|
|
2411
|
-
wishlistId,
|
|
2412
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
2413
|
-
items
|
|
2414
|
-
);
|
|
2004
|
+
const response = await api.items.itemWishlist.hdr.create(userId, wishlistId, items);
|
|
2415
2005
|
return response.data;
|
|
2416
2006
|
}
|
|
2417
2007
|
async function removeWishlistItem(userId, wishlistId, lineId) {
|
|
@@ -2431,14 +2021,14 @@ function createWishlistActions(api, config = {}) {
|
|
|
2431
2021
|
function createSiteActions(api, config = {}) {
|
|
2432
2022
|
const siteId = api.config?.siteId ?? "";
|
|
2433
2023
|
const {
|
|
2434
|
-
cachePrefix = siteId ?
|
|
2024
|
+
cachePrefix = siteId ? scopedPrefix(siteId) : "",
|
|
2435
2025
|
edgeCache,
|
|
2436
2026
|
redisTtl,
|
|
2437
2027
|
longEdgeCache,
|
|
2438
2028
|
longRedisTtl,
|
|
2439
2029
|
defaultContactId = process.env["DEFAULT_CONTACT_ID"],
|
|
2440
2030
|
defaultCustomerId = process.env["DEFAULT_CUSTOMER_ID"],
|
|
2441
|
-
defaultCompanyId
|
|
2031
|
+
// defaultCompanyId is accepted in the config but no action reads it yet
|
|
2442
2032
|
convertUnitOfMeasure
|
|
2443
2033
|
} = config;
|
|
2444
2034
|
const cache = { cachePrefix, edgeCache, redisTtl };
|
|
@@ -2447,13 +2037,7 @@ function createSiteActions(api, config = {}) {
|
|
|
2447
2037
|
return api;
|
|
2448
2038
|
}
|
|
2449
2039
|
function lazy(fn) {
|
|
2450
|
-
|
|
2451
|
-
return {
|
|
2452
|
-
get() {
|
|
2453
|
-
if (instance === void 0) instance = fn();
|
|
2454
|
-
return instance;
|
|
2455
|
-
}
|
|
2456
|
-
};
|
|
2040
|
+
return { get: fn };
|
|
2457
2041
|
}
|
|
2458
2042
|
const pricing = lazy(
|
|
2459
2043
|
() => createPricingActions(castApi(), {
|
|
@@ -2512,7 +2096,6 @@ function createSiteActions(api, config = {}) {
|
|
|
2512
2096
|
})
|
|
2513
2097
|
);
|
|
2514
2098
|
const logistics = lazy(() => createLogisticsActions(castApi(), longCache));
|
|
2515
|
-
const nexus = lazy(() => createNexusActions(castApi(), cache));
|
|
2516
2099
|
const vmi = lazy(() => createVmiActions(castApi(), { ...cache, ...config.vmi }));
|
|
2517
2100
|
const p21Core = lazy(() => createP21CoreActions(castApi(), longCache));
|
|
2518
2101
|
const p21Apis = lazy(() => createP21ApisActions(castApi(), cache));
|
|
@@ -2522,7 +2105,6 @@ function createSiteActions(api, config = {}) {
|
|
|
2522
2105
|
const basecamp2 = lazy(() => createBasecamp2Actions(castApi(), longCache));
|
|
2523
2106
|
const brandFolder = lazy(() => createBrandFolderActions(castApi(), cache));
|
|
2524
2107
|
const gregorovich = lazy(() => createGregorovichActions(castApi(), cache));
|
|
2525
|
-
const slack = lazy(() => createSlackActions(castApi(), cache));
|
|
2526
2108
|
const favorites = lazy(() => createFavoritesActions(castApi(), cache));
|
|
2527
2109
|
const wishlists = lazy(() => createWishlistActions(castApi(), cache));
|
|
2528
2110
|
const legacyServices = {
|
|
@@ -2571,9 +2153,6 @@ function createSiteActions(api, config = {}) {
|
|
|
2571
2153
|
get logistics() {
|
|
2572
2154
|
return logistics.get();
|
|
2573
2155
|
},
|
|
2574
|
-
get nexus() {
|
|
2575
|
-
return nexus.get();
|
|
2576
|
-
},
|
|
2577
2156
|
get vmi() {
|
|
2578
2157
|
return vmi.get();
|
|
2579
2158
|
},
|
|
@@ -2601,9 +2180,6 @@ function createSiteActions(api, config = {}) {
|
|
|
2601
2180
|
get gregorovich() {
|
|
2602
2181
|
return gregorovich.get();
|
|
2603
2182
|
},
|
|
2604
|
-
get slack() {
|
|
2605
|
-
return slack.get();
|
|
2606
|
-
},
|
|
2607
2183
|
get favorites() {
|
|
2608
2184
|
return favorites.get();
|
|
2609
2185
|
},
|
|
@@ -2633,20 +2209,17 @@ function createSiteActions(api, config = {}) {
|
|
|
2633
2209
|
const key = prop;
|
|
2634
2210
|
const cached = wrappedCache.get(key);
|
|
2635
2211
|
if (cached) return cached;
|
|
2636
|
-
|
|
2637
|
-
|
|
2638
|
-
const
|
|
2639
|
-
|
|
2640
|
-
|
|
2641
|
-
|
|
2642
|
-
|
|
2643
|
-
|
|
2644
|
-
|
|
2645
|
-
|
|
2646
|
-
|
|
2647
|
-
wrappedCache.set(key, wrapped);
|
|
2648
|
-
return wrapped;
|
|
2649
|
-
}
|
|
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;
|
|
2650
2223
|
}
|
|
2651
2224
|
const proxied = proxyFallback[key];
|
|
2652
2225
|
wrappedCache.set(key, proxied);
|
|
@@ -2679,15 +2252,15 @@ function clearSiteActions() {
|
|
|
2679
2252
|
|
|
2680
2253
|
// src/server-site-registry.ts
|
|
2681
2254
|
import { getCacheTier } from "@simpleapps-com/augur-core";
|
|
2255
|
+
import { AugurAPI } from "@simpleapps-com/augur-api";
|
|
2682
2256
|
function registerSiteActions2(actions) {
|
|
2683
2257
|
registerSiteActions(actions);
|
|
2684
2258
|
}
|
|
2685
2259
|
function registerClientAndWrapper(api) {
|
|
2686
2260
|
registerSdkClient(api);
|
|
2687
2261
|
registerSdkCallWrapper((methodPath, sdkCall2, ...keyArgs) => {
|
|
2688
|
-
const
|
|
2689
|
-
if (
|
|
2690
|
-
const ttl = tier.staleTime >= 36e5 ? 28800 : 3600;
|
|
2262
|
+
const ttl = ttlFor(getCacheTier(methodPath).staleTime, 3600, 28800);
|
|
2263
|
+
if (ttl === null) return sdkCall2();
|
|
2691
2264
|
return withServerCache("", ttl, methodPath, sdkCall2, ...keyArgs);
|
|
2692
2265
|
});
|
|
2693
2266
|
}
|
|
@@ -2695,7 +2268,6 @@ function autoInitFromEnv() {
|
|
|
2695
2268
|
const siteId = process.env["AUGUR_SITE_ID"];
|
|
2696
2269
|
const bearerToken = process.env["AUGUR_JWT"];
|
|
2697
2270
|
if (!siteId || !bearerToken) return null;
|
|
2698
|
-
const { AugurAPI } = __require("@simpleapps-com/augur-api");
|
|
2699
2271
|
const api = new AugurAPI({ siteId, bearerToken });
|
|
2700
2272
|
const actions = createSiteActions(api);
|
|
2701
2273
|
registerSiteActions2(actions);
|
|
@@ -2736,4 +2308,4 @@ export {
|
|
|
2736
2308
|
getSiteActions,
|
|
2737
2309
|
clearSiteActions2 as clearSiteActions
|
|
2738
2310
|
};
|
|
2739
|
-
//# sourceMappingURL=chunk-
|
|
2311
|
+
//# sourceMappingURL=chunk-PFYEMJTQ.js.map
|