@simpleapps-com/augur-server 2.4.0 → 2026.11.2
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 +30 -73
- package/README.md +29 -198
- package/dist/actions/agr-info.d.ts +44 -0
- package/dist/actions/agr-info.d.ts.map +1 -0
- package/dist/actions/agr-site.d.ts +38 -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 +48 -0
- package/dist/actions/basecamp2.d.ts.map +1 -0
- package/dist/actions/brand-folder.d.ts +39 -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 +45 -0
- package/dist/actions/customers.d.ts.map +1 -0
- package/dist/actions/favorites.d.ts +21 -0
- package/dist/actions/favorites.d.ts.map +1 -0
- package/dist/actions/gregorovich.d.ts +35 -0
- package/dist/actions/gregorovich.d.ts.map +1 -0
- package/dist/actions/items.d.ts +81 -0
- package/dist/actions/items.d.ts.map +1 -0
- package/dist/actions/joomla.d.ts +60 -0
- package/dist/actions/joomla.d.ts.map +1 -0
- package/dist/actions/legacy.d.ts +46 -0
- package/dist/actions/legacy.d.ts.map +1 -0
- package/dist/actions/logistics.d.ts +41 -0
- package/dist/actions/logistics.d.ts.map +1 -0
- package/dist/actions/orders.d.ts +37 -0
- package/dist/actions/orders.d.ts.map +1 -0
- package/dist/actions/p21-apis.d.ts +34 -0
- package/dist/actions/p21-apis.d.ts.map +1 -0
- package/dist/actions/p21-core.d.ts +47 -0
- package/dist/actions/p21-core.d.ts.map +1 -0
- package/dist/actions/p21-pim.d.ts +37 -0
- package/dist/actions/p21-pim.d.ts.map +1 -0
- package/dist/actions/p21-sism.d.ts +38 -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 +46 -0
- package/dist/actions/pricing.d.ts.map +1 -0
- package/dist/actions/search.d.ts +62 -0
- package/dist/actions/search.d.ts.map +1 -0
- package/dist/actions/shipping.d.ts +57 -0
- package/dist/actions/shipping.d.ts.map +1 -0
- package/dist/actions/site.d.ts +142 -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 +45 -0
- package/dist/actions/vmi.d.ts.map +1 -0
- package/dist/actions/wishlists.d.ts +29 -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 +18 -0
- package/dist/cache/redis-client.d.ts.map +1 -0
- package/dist/cache/with-cache.d.ts +17 -0
- package/dist/cache/with-cache.d.ts.map +1 -0
- package/dist/{chunk-PIYHMA6F.js → chunk-6CSVIBHQ.js} +15 -18
- package/dist/chunk-6CSVIBHQ.js.map +1 -0
- package/dist/{chunk-ALTIINP6.js → chunk-A4IVBK6P.js} +30 -6
- package/dist/chunk-A4IVBK6P.js.map +1 -0
- package/dist/{chunk-KHFEDL47.js → chunk-INVDQQ7T.js} +18 -12
- package/dist/chunk-INVDQQ7T.js.map +1 -0
- package/dist/{chunk-26WZBC4F.js → chunk-LX7SJJOU.js} +275 -667
- package/dist/chunk-LX7SJJOU.js.map +1 -0
- package/dist/chunk-OBWQSGB6.js +205 -0
- package/dist/chunk-OBWQSGB6.js.map +1 -0
- package/dist/{chunk-2NL4QKJN.js → chunk-UVGG74FO.js} +31 -30
- package/dist/chunk-UVGG74FO.js.map +1 -0
- package/dist/duration.d.ts +16 -0
- package/dist/duration.d.ts.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-options-helper.d.ts +34 -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 +230 -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 +15 -14
- 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 +72 -51
- package/package.json +30 -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/query.d.ts +0 -35
- package/dist/site-BjSFqufX.d.ts +0 -469
|
@@ -1,24 +1,37 @@
|
|
|
1
1
|
import {
|
|
2
2
|
registerSdkCallWrapper,
|
|
3
3
|
registerSdkClient
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-A4IVBK6P.js";
|
|
5
5
|
import {
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
cacheTtlOf,
|
|
7
|
+
circuitCheck,
|
|
8
|
+
configuredModeOf,
|
|
9
|
+
docUidOf,
|
|
10
|
+
envOf,
|
|
11
|
+
hasDocKey,
|
|
12
|
+
hasMoreOf,
|
|
13
|
+
itemsLimitOf,
|
|
14
|
+
nextCursorOf,
|
|
15
|
+
opensAt,
|
|
16
|
+
positiveOrZero,
|
|
17
|
+
recordFailureOf,
|
|
18
|
+
recordSuccessOf,
|
|
19
|
+
scopedPrefix,
|
|
20
|
+
shouldCache,
|
|
21
|
+
takesItemId,
|
|
22
|
+
ttlFor
|
|
23
|
+
} from "./chunk-OBWQSGB6.js";
|
|
8
24
|
|
|
9
25
|
// src/environment.ts
|
|
10
26
|
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";
|
|
27
|
+
const isServer = typeof window === "undefined";
|
|
28
|
+
return envOf(
|
|
29
|
+
process.env["DEPLOYMENT_ENV"] ?? "",
|
|
30
|
+
isServer,
|
|
31
|
+
process.env["NODE_ENV"] ?? "",
|
|
32
|
+
// The host is read only in the browser, as before.
|
|
33
|
+
isServer ? "" : window.location.hostname
|
|
34
|
+
);
|
|
22
35
|
}
|
|
23
36
|
var env = getEnvironment();
|
|
24
37
|
var isDev = env === "development";
|
|
@@ -26,14 +39,14 @@ var isStaging = env === "staging";
|
|
|
26
39
|
var isProduction = env === "production";
|
|
27
40
|
|
|
28
41
|
// src/cache/redis-client.ts
|
|
29
|
-
|
|
30
|
-
var
|
|
42
|
+
import { millis, minutes } from "@simpleapps-com/augur-utils";
|
|
43
|
+
var CIRCUIT_BREAKER_RESET = minutes(1);
|
|
31
44
|
var g = globalThis;
|
|
32
45
|
if (!g.__redisState) {
|
|
33
46
|
g.__redisState = {
|
|
34
47
|
client: null,
|
|
35
48
|
consecutiveFailures: 0,
|
|
36
|
-
circuitOpenUntil: 0
|
|
49
|
+
circuitOpenUntil: millis(0)
|
|
37
50
|
};
|
|
38
51
|
}
|
|
39
52
|
var state = g.__redisState;
|
|
@@ -43,25 +56,28 @@ function log(...args) {
|
|
|
43
56
|
console.log("[Redis]", ...args);
|
|
44
57
|
}
|
|
45
58
|
}
|
|
59
|
+
function circuit() {
|
|
60
|
+
return { failures: state.consecutiveFailures, openUntil: state.circuitOpenUntil };
|
|
61
|
+
}
|
|
62
|
+
function setCircuit(next) {
|
|
63
|
+
state.consecutiveFailures = next.failures;
|
|
64
|
+
state.circuitOpenUntil = next.openUntil;
|
|
65
|
+
}
|
|
46
66
|
function isCircuitOpen() {
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
return false;
|
|
53
|
-
}
|
|
54
|
-
return true;
|
|
67
|
+
const wasOpen = state.circuitOpenUntil !== 0;
|
|
68
|
+
const answer = circuitCheck(circuit(), millis(Date.now()));
|
|
69
|
+
setCircuit(answer.next);
|
|
70
|
+
if (wasOpen && !answer.open) log("Circuit breaker reset -- retrying Redis");
|
|
71
|
+
return answer.open;
|
|
55
72
|
}
|
|
56
73
|
function recordFailure() {
|
|
57
|
-
|
|
58
|
-
if (state.consecutiveFailures
|
|
59
|
-
|
|
60
|
-
log(`Circuit breaker OPEN -- skipping Redis for ${CIRCUIT_BREAKER_RESET_MS / 1e3}s`);
|
|
74
|
+
setCircuit(recordFailureOf(circuit(), millis(Date.now())));
|
|
75
|
+
if (opensAt(state.consecutiveFailures)) {
|
|
76
|
+
log(`Circuit breaker OPEN -- skipping Redis for ${CIRCUIT_BREAKER_RESET}s`);
|
|
61
77
|
}
|
|
62
78
|
}
|
|
63
79
|
function recordSuccess() {
|
|
64
|
-
|
|
80
|
+
setCircuit(recordSuccessOf(circuit()));
|
|
65
81
|
}
|
|
66
82
|
function getRedisUrl() {
|
|
67
83
|
const containerRedis = process.env["REDIS_SERVERS"];
|
|
@@ -111,12 +127,12 @@ async function cacheGet(key) {
|
|
|
111
127
|
return null;
|
|
112
128
|
}
|
|
113
129
|
}
|
|
114
|
-
async function cacheSet(key, value,
|
|
130
|
+
async function cacheSet(key, value, ttl) {
|
|
115
131
|
if (isCircuitOpen()) return;
|
|
116
132
|
const client = await getClient();
|
|
117
133
|
if (!client) return;
|
|
118
134
|
try {
|
|
119
|
-
await client.setex(key,
|
|
135
|
+
await client.setex(key, ttl, value);
|
|
120
136
|
recordSuccess();
|
|
121
137
|
} catch {
|
|
122
138
|
recordFailure();
|
|
@@ -171,10 +187,12 @@ async function batchFetch(params, fetchOne, getKey) {
|
|
|
171
187
|
}
|
|
172
188
|
|
|
173
189
|
// src/cache/with-cache.ts
|
|
174
|
-
import { buildCacheKey } from "@simpleapps-com/augur-core";
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
const
|
|
190
|
+
import { buildCacheKey, buildRawCacheKey } from "@simpleapps-com/augur-core";
|
|
191
|
+
import { seconds } from "@simpleapps-com/augur-utils";
|
|
192
|
+
async function readThrough(redisTtl, keyOf, fn) {
|
|
193
|
+
const ttl = cacheTtlOf(redisTtl === void 0 || Number.isNaN(redisTtl), redisTtl ?? seconds(0));
|
|
194
|
+
if (!shouldCache(ttl)) return fn();
|
|
195
|
+
const key = keyOf();
|
|
178
196
|
try {
|
|
179
197
|
const cached = await cacheGet(key);
|
|
180
198
|
if (cached != null) return JSON.parse(cached);
|
|
@@ -182,21 +200,26 @@ async function withServerCache(prefix, redisTtl, methodPath, fn, ...keyArgs) {
|
|
|
182
200
|
}
|
|
183
201
|
const result = await fn();
|
|
184
202
|
try {
|
|
185
|
-
cacheSet(key, JSON.stringify(result),
|
|
203
|
+
cacheSet(key, JSON.stringify(result), ttl).catch(() => {
|
|
186
204
|
});
|
|
187
205
|
} catch {
|
|
188
206
|
}
|
|
189
207
|
return result;
|
|
190
208
|
}
|
|
209
|
+
async function withServerCache(prefix, redisTtl, methodPath, fn, ...keyArgs) {
|
|
210
|
+
return readThrough(redisTtl, () => buildCacheKey(prefix, methodPath, keyArgs), fn);
|
|
211
|
+
}
|
|
212
|
+
async function withRawSdkCache(prefix, redisTtl, methodPath, fn, ...keyArgs) {
|
|
213
|
+
return readThrough(redisTtl, () => buildRawCacheKey(prefix, methodPath, keyArgs), fn);
|
|
214
|
+
}
|
|
191
215
|
|
|
192
216
|
// src/pagination.ts
|
|
193
217
|
function paginateOffset(items, pageParam, limit, total) {
|
|
194
|
-
const
|
|
195
|
-
const hasMore = total !== void 0 ? (pageParam + 1) * limit < resolvedTotal : items.length === limit;
|
|
218
|
+
const hasMore = hasMoreOf(pageParam, limit, total, items.length);
|
|
196
219
|
return {
|
|
197
220
|
data: items,
|
|
198
|
-
total:
|
|
199
|
-
nextCursor: hasMore
|
|
221
|
+
total: total ?? 0,
|
|
222
|
+
nextCursor: nextCursorOf(hasMore, pageParam),
|
|
200
223
|
hasMore
|
|
201
224
|
};
|
|
202
225
|
}
|
|
@@ -205,18 +228,17 @@ function paginateOffset(items, pageParam, limit, total) {
|
|
|
205
228
|
import { createActionsProxy } from "@simpleapps-com/augur-core";
|
|
206
229
|
|
|
207
230
|
// src/actions/pricing.ts
|
|
231
|
+
import { hours, minutes as minutes2 } from "@simpleapps-com/augur-utils";
|
|
208
232
|
function resolveCustomerId(explicit, fallback) {
|
|
209
|
-
|
|
210
|
-
const num = Number(raw);
|
|
211
|
-
return num > 0 ? num : 0;
|
|
233
|
+
return positiveOrZero(Number(explicit ?? fallback));
|
|
212
234
|
}
|
|
213
235
|
function createPricingActions(api, config = {}) {
|
|
214
236
|
const {
|
|
215
237
|
defaultCustomerId,
|
|
216
238
|
cachePrefix = "",
|
|
217
239
|
edgeCache = 2,
|
|
218
|
-
redisTtl =
|
|
219
|
-
taxRedisTtl =
|
|
240
|
+
redisTtl = hours(1),
|
|
241
|
+
taxRedisTtl = minutes2(30)
|
|
220
242
|
} = config;
|
|
221
243
|
async function getItemPrice(itemId, customerId, quantity = 1) {
|
|
222
244
|
const custId = resolveCustomerId(customerId, defaultCustomerId);
|
|
@@ -241,7 +263,12 @@ function createPricingActions(api, config = {}) {
|
|
|
241
263
|
}
|
|
242
264
|
async function getTaxEstimate(customerId, postalCode, items = []) {
|
|
243
265
|
const custId = resolveCustomerId(customerId, defaultCustomerId);
|
|
244
|
-
const params = {
|
|
266
|
+
const params = {
|
|
267
|
+
customerId: custId,
|
|
268
|
+
postalCode: postalCode ?? "",
|
|
269
|
+
items,
|
|
270
|
+
edgeCache
|
|
271
|
+
};
|
|
245
272
|
return withServerCache(
|
|
246
273
|
cachePrefix,
|
|
247
274
|
taxRedisTtl,
|
|
@@ -257,13 +284,15 @@ function createPricingActions(api, config = {}) {
|
|
|
257
284
|
}
|
|
258
285
|
|
|
259
286
|
// src/actions/items.ts
|
|
287
|
+
import { hours as hours2 } from "@simpleapps-com/augur-utils";
|
|
288
|
+
import { categorySortBy } from "@simpleapps-com/augur-utils";
|
|
260
289
|
function createItemActions(api, config = {}) {
|
|
261
290
|
const {
|
|
262
291
|
cachePrefix = "",
|
|
263
292
|
edgeCache = 1,
|
|
264
293
|
longEdgeCache = 8,
|
|
265
|
-
redisTtl =
|
|
266
|
-
longRedisTtl =
|
|
294
|
+
redisTtl = hours2(1),
|
|
295
|
+
longRedisTtl = hours2(8),
|
|
267
296
|
sortChildren = true,
|
|
268
297
|
sortByPrefix
|
|
269
298
|
} = config;
|
|
@@ -287,10 +316,12 @@ function createItemActions(api, config = {}) {
|
|
|
287
316
|
);
|
|
288
317
|
}
|
|
289
318
|
async function getItemCategory(uid, options) {
|
|
290
|
-
const
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
319
|
+
const { filters, ...rest } = options ?? {};
|
|
320
|
+
const sdkParams = {
|
|
321
|
+
...rest,
|
|
322
|
+
edgeCache,
|
|
323
|
+
...filters ? { filters: JSON.stringify(filters) } : {}
|
|
324
|
+
};
|
|
294
325
|
const category = await withServerCache(
|
|
295
326
|
cachePrefix,
|
|
296
327
|
redisTtl,
|
|
@@ -302,12 +333,9 @@ function createItemActions(api, config = {}) {
|
|
|
302
333
|
uid,
|
|
303
334
|
options
|
|
304
335
|
);
|
|
305
|
-
const cat = category;
|
|
306
336
|
return {
|
|
307
|
-
...
|
|
308
|
-
|
|
309
|
-
categoryImage: cat.categoryImage || null,
|
|
310
|
-
children: sortCategoryChildren(cat.children)
|
|
337
|
+
...category,
|
|
338
|
+
children: sortCategoryChildren(category.children)
|
|
311
339
|
};
|
|
312
340
|
}
|
|
313
341
|
function buildCategoryParams(itemsFilters, overrides) {
|
|
@@ -322,55 +350,46 @@ function createItemActions(api, config = {}) {
|
|
|
322
350
|
params["filters"] = JSON.stringify([]);
|
|
323
351
|
params["q"] = "";
|
|
324
352
|
params["sortBy"] = "desc";
|
|
325
|
-
|
|
326
|
-
|
|
353
|
+
params["limit"] = overrides?.limit;
|
|
354
|
+
params["offset"] = overrides?.offset;
|
|
327
355
|
}
|
|
328
356
|
return params;
|
|
329
357
|
}
|
|
330
358
|
function isItemsFilters(v) {
|
|
331
359
|
return Array.isArray(v.filters);
|
|
332
360
|
}
|
|
333
|
-
|
|
334
|
-
const
|
|
335
|
-
if (
|
|
336
|
-
|
|
337
|
-
|
|
361
|
+
function applySortByPrefix(params) {
|
|
362
|
+
const sortBy = params["sortBy"];
|
|
363
|
+
if (typeof sortBy === "string") params["sortBy"] = categorySortBy(sortByPrefix ?? "", sortBy);
|
|
364
|
+
}
|
|
365
|
+
function listCategoryItems(uid, params) {
|
|
338
366
|
return withServerCache(
|
|
339
367
|
cachePrefix,
|
|
340
368
|
redisTtl,
|
|
341
369
|
"items.categories.items.list",
|
|
342
370
|
async () => {
|
|
343
371
|
const response = await api.items.categories.items.list(uid, {
|
|
344
|
-
...
|
|
372
|
+
...params,
|
|
345
373
|
edgeCache
|
|
346
374
|
});
|
|
347
375
|
return response.data;
|
|
348
376
|
},
|
|
349
377
|
uid,
|
|
350
|
-
|
|
378
|
+
params
|
|
351
379
|
);
|
|
352
380
|
}
|
|
381
|
+
async function getCategoryItems(uid, filters) {
|
|
382
|
+
const merged = isItemsFilters(filters) ? buildCategoryParams(filters) : { ...filters };
|
|
383
|
+
applySortByPrefix(merged);
|
|
384
|
+
return listCategoryItems(uid, merged);
|
|
385
|
+
}
|
|
353
386
|
async function getCategoryItemsInfinite(uid, itemsFilters, pageParam = 0) {
|
|
354
|
-
const
|
|
387
|
+
const given = itemsFilters?.limit;
|
|
388
|
+
const limit = itemsLimitOf(given === void 0 || Number.isNaN(given) ? void 0 : given);
|
|
355
389
|
const offset = pageParam * limit;
|
|
356
390
|
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
|
-
);
|
|
391
|
+
applySortByPrefix(merged);
|
|
392
|
+
const result = await listCategoryItems(uid, merged);
|
|
374
393
|
const items = result.items || [];
|
|
375
394
|
const total = result.total || 0;
|
|
376
395
|
return paginateOffset(items, pageParam, limit, total);
|
|
@@ -403,11 +422,11 @@ function createItemActions(api, config = {}) {
|
|
|
403
422
|
}
|
|
404
423
|
async function getInvMastDoc(paramsOrUid, itemIdArg, includePricingArg) {
|
|
405
424
|
const params = typeof paramsOrUid === "number" ? {
|
|
406
|
-
invMastUid: paramsOrUid
|
|
407
|
-
itemId: paramsOrUid
|
|
425
|
+
invMastUid: docUidOf(paramsOrUid),
|
|
426
|
+
itemId: takesItemId(paramsOrUid, itemIdArg ?? "") ? itemIdArg.toUpperCase().trim() : void 0,
|
|
408
427
|
includePricing: includePricingArg
|
|
409
428
|
} : paramsOrUid;
|
|
410
|
-
if (!params.invMastUid
|
|
429
|
+
if (!hasDocKey(!!params.invMastUid, params.itemId ?? "")) {
|
|
411
430
|
throw new Error("Either invMastUid must be positive or itemId must be provided");
|
|
412
431
|
}
|
|
413
432
|
return withServerCache(
|
|
@@ -546,14 +565,19 @@ function createItemActions(api, config = {}) {
|
|
|
546
565
|
function createCommerceActions(api, config = {}) {
|
|
547
566
|
const { defaultContactId, defaultCustomerId, convertUnitOfMeasure } = config;
|
|
548
567
|
async function cartHdrLookup(params) {
|
|
549
|
-
const
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
if (lookupParams["customerId"] == null && defaultCustomerId != null) {
|
|
554
|
-
lookupParams["customerId"] = defaultCustomerId;
|
|
568
|
+
const contactId = params.contactId ?? defaultContactId;
|
|
569
|
+
const customerId = params.customerId ?? defaultCustomerId;
|
|
570
|
+
if (contactId == null || customerId == null) {
|
|
571
|
+
throw new Error("cartHdrLookup requires contactId and customerId (param or config default)");
|
|
555
572
|
}
|
|
556
|
-
const response = await api.commerce.cartHdr.lookup.get(
|
|
573
|
+
const response = await api.commerce.cartHdr.lookup.get({
|
|
574
|
+
// SDK: userId 0 = anonymous cart keyed on cartToken.
|
|
575
|
+
// `|| 0` also maps a non-numeric userId (NaN) to anonymous, as auth.ts does.
|
|
576
|
+
userId: Number(params.userId) || 0,
|
|
577
|
+
cartToken: params.cartToken,
|
|
578
|
+
contactId: Number(contactId),
|
|
579
|
+
customerId: Number(customerId)
|
|
580
|
+
});
|
|
557
581
|
return response.data;
|
|
558
582
|
}
|
|
559
583
|
async function getCartLines(cartHdrUid) {
|
|
@@ -565,11 +589,7 @@ function createCommerceActions(api, config = {}) {
|
|
|
565
589
|
...item,
|
|
566
590
|
unitOfMeasure: convertUnitOfMeasure ? convertUnitOfMeasure(item.unitOfMeasure) : item.unitOfMeasure
|
|
567
591
|
}));
|
|
568
|
-
const response = await api.commerce.cartLine.add.create(
|
|
569
|
-
cartHdrUid,
|
|
570
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
571
|
-
mappedItems
|
|
572
|
-
);
|
|
592
|
+
const response = await api.commerce.cartLine.add.create(cartHdrUid, mappedItems);
|
|
573
593
|
return response.data;
|
|
574
594
|
}
|
|
575
595
|
async function updateCartLines(cartHdrUid, lines) {
|
|
@@ -577,11 +597,7 @@ function createCommerceActions(api, config = {}) {
|
|
|
577
597
|
...line,
|
|
578
598
|
unitOfMeasure: convertUnitOfMeasure ? convertUnitOfMeasure(line.unitOfMeasure) : line.unitOfMeasure
|
|
579
599
|
}));
|
|
580
|
-
const response = await api.commerce.cartLine.update.create(
|
|
581
|
-
cartHdrUid,
|
|
582
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
583
|
-
mappedLines
|
|
584
|
-
);
|
|
600
|
+
const response = await api.commerce.cartLine.update.create(cartHdrUid, mappedLines);
|
|
585
601
|
return response.data;
|
|
586
602
|
}
|
|
587
603
|
async function deleteCartItems(cartHdrUid) {
|
|
@@ -613,66 +629,64 @@ function createCommerceActions(api, config = {}) {
|
|
|
613
629
|
}
|
|
614
630
|
|
|
615
631
|
// src/actions/search.ts
|
|
632
|
+
import { hours as hours3 } from "@simpleapps-com/augur-utils";
|
|
616
633
|
function createSearchActions(api, config = {}) {
|
|
617
634
|
const {
|
|
618
635
|
cachePrefix = "",
|
|
619
636
|
edgeCache = 1,
|
|
620
|
-
redisTtl =
|
|
637
|
+
redisTtl = hours3(1),
|
|
621
638
|
defaultSourceFields = "display_desc"
|
|
622
639
|
} = config;
|
|
623
|
-
const openSearch = api.
|
|
640
|
+
const openSearch = api.openSearch;
|
|
624
641
|
async function getSearchAttributes(q) {
|
|
625
|
-
const params = {
|
|
642
|
+
const params = {
|
|
643
|
+
q,
|
|
644
|
+
searchType: "query",
|
|
645
|
+
edgeCache
|
|
646
|
+
};
|
|
626
647
|
return withServerCache(
|
|
627
648
|
cachePrefix,
|
|
628
649
|
redisTtl,
|
|
629
650
|
"openSearch.itemSearch.attributes.list",
|
|
630
651
|
async () => {
|
|
631
|
-
const response = (
|
|
632
|
-
|
|
633
|
-
await openSearch.itemSearch.attributes.list(params)
|
|
634
|
-
);
|
|
635
|
-
return {
|
|
636
|
-
attributes: response.data.attributes
|
|
637
|
-
};
|
|
652
|
+
const response = await openSearch.itemSearch.attributes.list(params);
|
|
653
|
+
return { attributes: response.data.attributes };
|
|
638
654
|
},
|
|
639
655
|
q
|
|
640
656
|
);
|
|
641
657
|
}
|
|
642
658
|
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;
|
|
659
|
+
const params = { q, limit, offset, edgeCache };
|
|
646
660
|
return withServerCache(
|
|
647
661
|
cachePrefix,
|
|
648
662
|
redisTtl,
|
|
649
663
|
"openSearch.suggestions.suggest.list",
|
|
650
664
|
async () => {
|
|
651
|
-
const response = (
|
|
652
|
-
|
|
653
|
-
await openSearch.suggestions.suggest.list(params)
|
|
654
|
-
);
|
|
655
|
-
return response.data;
|
|
665
|
+
const response = await openSearch.suggestions.suggest.list(params);
|
|
666
|
+
return toListResult(response);
|
|
656
667
|
},
|
|
657
|
-
// Key on q AND pagination (
|
|
668
|
+
// Key on q AND pagination (limit/offset): different pages of the same query
|
|
658
669
|
// are distinct cache entries. Keying on q alone served a stale page.
|
|
659
670
|
q,
|
|
660
671
|
limit,
|
|
661
672
|
offset
|
|
662
673
|
);
|
|
663
674
|
}
|
|
664
|
-
|
|
665
|
-
|
|
675
|
+
function itemSearchParams(filters, from, itemCategoryUid) {
|
|
676
|
+
return {
|
|
666
677
|
q: filters.q,
|
|
667
678
|
searchType: "query",
|
|
668
679
|
size: filters.limit,
|
|
669
|
-
from
|
|
670
|
-
|
|
680
|
+
from,
|
|
681
|
+
sort: filters.sortBy,
|
|
671
682
|
classId5List: itemCategoryUid ? String(itemCategoryUid) : void 0,
|
|
672
683
|
filters: filters.filters?.length ? JSON.stringify(filters.filters) : void 0,
|
|
673
684
|
sourceFieldsList: defaultSourceFields,
|
|
674
685
|
edgeCache
|
|
675
686
|
};
|
|
687
|
+
}
|
|
688
|
+
async function itemSearch(filters, itemCategoryUid) {
|
|
689
|
+
const params = itemSearchParams(filters, filters.offset, itemCategoryUid);
|
|
676
690
|
return withServerCache(
|
|
677
691
|
cachePrefix,
|
|
678
692
|
redisTtl,
|
|
@@ -686,17 +700,7 @@ function createSearchActions(api, config = {}) {
|
|
|
686
700
|
);
|
|
687
701
|
}
|
|
688
702
|
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
|
-
};
|
|
703
|
+
const params = itemSearchParams(filters, pageParam, itemCategoryUid);
|
|
700
704
|
return withServerCache(
|
|
701
705
|
cachePrefix,
|
|
702
706
|
redisTtl,
|
|
@@ -725,15 +729,16 @@ function createSearchActions(api, config = {}) {
|
|
|
725
729
|
}
|
|
726
730
|
|
|
727
731
|
// src/actions/orders.ts
|
|
732
|
+
import { hours as hours4 } from "@simpleapps-com/augur-utils";
|
|
728
733
|
function createOrderActions(api, config = {}) {
|
|
729
|
-
const { cachePrefix = "", edgeCache = 1, redisTtl =
|
|
734
|
+
const { cachePrefix = "", edgeCache = 1, redisTtl = hours4(1) } = config;
|
|
730
735
|
async function getOrderDoc(orderNo, postalCode) {
|
|
731
736
|
return withServerCache(
|
|
732
737
|
cachePrefix,
|
|
733
738
|
redisTtl,
|
|
734
739
|
"orders.oeHdr.doc.get",
|
|
735
740
|
async () => {
|
|
736
|
-
const response = await api.orders.oeHdr.doc.get(
|
|
741
|
+
const response = await api.orders.oeHdr.doc.get(orderNo, {
|
|
737
742
|
postalCode,
|
|
738
743
|
edgeCache
|
|
739
744
|
});
|
|
@@ -747,13 +752,14 @@ function createOrderActions(api, config = {}) {
|
|
|
747
752
|
}
|
|
748
753
|
|
|
749
754
|
// src/actions/shipping.ts
|
|
755
|
+
import { hours as hours5 } from "@simpleapps-com/augur-utils";
|
|
750
756
|
function createShippingActions(api, config) {
|
|
751
757
|
const {
|
|
752
758
|
fromAddress,
|
|
753
759
|
defaultServiceCodes,
|
|
754
760
|
cachePrefix = "",
|
|
755
761
|
edgeCache = 1,
|
|
756
|
-
redisTtl =
|
|
762
|
+
redisTtl = hours5(1)
|
|
757
763
|
} = config;
|
|
758
764
|
async function getShippingRates(toAddress, weight, serviceCodes) {
|
|
759
765
|
const params = {
|
|
@@ -786,8 +792,9 @@ function createShippingActions(api, config) {
|
|
|
786
792
|
}
|
|
787
793
|
|
|
788
794
|
// src/actions/joomla.ts
|
|
795
|
+
import { hours as hours6 } from "@simpleapps-com/augur-utils";
|
|
789
796
|
function createJoomlaActions(api, config = {}) {
|
|
790
|
-
const { cachePrefix = "", edgeCache = 1, redisTtl =
|
|
797
|
+
const { cachePrefix = "", edgeCache = 1, redisTtl = hours6(1) } = config;
|
|
791
798
|
async function getJoomlaContent(articleId, options) {
|
|
792
799
|
if (options?.alias) {
|
|
793
800
|
return withServerCache(
|
|
@@ -896,19 +903,14 @@ function createJoomlaActions(api, config = {}) {
|
|
|
896
903
|
const response = await api.joomla.users.doc.get(Number(userId), {
|
|
897
904
|
edgeCache
|
|
898
905
|
});
|
|
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);
|
|
906
|
+
const user = response.data;
|
|
907
|
+
if (!user) throw new Error("User not found");
|
|
906
908
|
return {
|
|
907
|
-
id: String(
|
|
908
|
-
name:
|
|
909
|
-
email:
|
|
910
|
-
customerId,
|
|
911
|
-
permissions
|
|
909
|
+
id: String(user.id),
|
|
910
|
+
name: user.name,
|
|
911
|
+
email: user.email,
|
|
912
|
+
customerId: user.customerId,
|
|
913
|
+
permissions: user.groups.map((group) => group.title).filter(Boolean)
|
|
912
914
|
};
|
|
913
915
|
},
|
|
914
916
|
userId
|
|
@@ -932,13 +934,14 @@ function createJoomlaActions(api, config = {}) {
|
|
|
932
934
|
}
|
|
933
935
|
|
|
934
936
|
// src/actions/legacy.ts
|
|
937
|
+
import { hours as hours7 } from "@simpleapps-com/augur-utils";
|
|
935
938
|
function createLegacyActions(api, config = {}) {
|
|
936
939
|
const {
|
|
937
940
|
cachePrefix = "",
|
|
938
941
|
edgeCache = 1,
|
|
939
942
|
longEdgeCache = 8,
|
|
940
|
-
redisTtl =
|
|
941
|
-
longRedisTtl =
|
|
943
|
+
redisTtl = hours7(1),
|
|
944
|
+
longRedisTtl = hours7(8)
|
|
942
945
|
} = config;
|
|
943
946
|
async function getItemWebDesc(invMastUid) {
|
|
944
947
|
return withServerCache(
|
|
@@ -1004,22 +1007,9 @@ function createLegacyActions(api, config = {}) {
|
|
|
1004
1007
|
}
|
|
1005
1008
|
|
|
1006
1009
|
// src/actions/customers.ts
|
|
1010
|
+
import { hours as hours8 } from "@simpleapps-com/augur-utils";
|
|
1007
1011
|
function createCustomersActions(api, config = {}) {
|
|
1008
|
-
const { cachePrefix = "", edgeCache = 1, redisTtl =
|
|
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
|
-
}
|
|
1012
|
+
const { cachePrefix = "", edgeCache = 1, redisTtl = hours8(1) } = config;
|
|
1023
1013
|
async function customerLookup(params) {
|
|
1024
1014
|
return withServerCache(
|
|
1025
1015
|
cachePrefix,
|
|
@@ -1029,7 +1019,6 @@ function createCustomersActions(api, config = {}) {
|
|
|
1029
1019
|
const response = await api.customers.customer.lookup.get({
|
|
1030
1020
|
...params,
|
|
1031
1021
|
edgeCache
|
|
1032
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1033
1022
|
});
|
|
1034
1023
|
return toListResult(response);
|
|
1035
1024
|
},
|
|
@@ -1059,7 +1048,6 @@ function createCustomersActions(api, config = {}) {
|
|
|
1059
1048
|
const response = await api.customers.customer.orders.list(customerId, {
|
|
1060
1049
|
...params,
|
|
1061
1050
|
edgeCache
|
|
1062
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1063
1051
|
});
|
|
1064
1052
|
return toListResult(response);
|
|
1065
1053
|
},
|
|
@@ -1073,7 +1061,7 @@ function createCustomersActions(api, config = {}) {
|
|
|
1073
1061
|
redisTtl,
|
|
1074
1062
|
"customers.customer.orders.get",
|
|
1075
1063
|
async () => {
|
|
1076
|
-
const response = await api.customers.customer.orders.get(customerId, orderId, {
|
|
1064
|
+
const response = await api.customers.customer.orders.get(customerId, String(orderId), {
|
|
1077
1065
|
edgeCache
|
|
1078
1066
|
});
|
|
1079
1067
|
return response.data;
|
|
@@ -1088,11 +1076,10 @@ function createCustomersActions(api, config = {}) {
|
|
|
1088
1076
|
redisTtl,
|
|
1089
1077
|
"customers.customer.invoices.list",
|
|
1090
1078
|
async () => {
|
|
1091
|
-
const response = await api.customers.customer.invoices.list(
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
);
|
|
1079
|
+
const response = await api.customers.customer.invoices.list(customerId, {
|
|
1080
|
+
...params,
|
|
1081
|
+
edgeCache
|
|
1082
|
+
});
|
|
1096
1083
|
return toListResult(response);
|
|
1097
1084
|
},
|
|
1098
1085
|
customerId,
|
|
@@ -1145,21 +1132,6 @@ function createCustomersActions(api, config = {}) {
|
|
|
1145
1132
|
quoteNo
|
|
1146
1133
|
);
|
|
1147
1134
|
}
|
|
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
1135
|
async function getShipToAddresses(customerId) {
|
|
1164
1136
|
return withServerCache(
|
|
1165
1137
|
cachePrefix,
|
|
@@ -1175,7 +1147,6 @@ function createCustomersActions(api, config = {}) {
|
|
|
1175
1147
|
);
|
|
1176
1148
|
}
|
|
1177
1149
|
return {
|
|
1178
|
-
getCustomer,
|
|
1179
1150
|
customerLookup,
|
|
1180
1151
|
getCustomerDoc,
|
|
1181
1152
|
getCustomerOrders,
|
|
@@ -1184,14 +1155,12 @@ function createCustomersActions(api, config = {}) {
|
|
|
1184
1155
|
getCustomerInvoiceDetail,
|
|
1185
1156
|
getCustomerQuotes,
|
|
1186
1157
|
getCustomerQuoteDetail,
|
|
1187
|
-
getContacts,
|
|
1188
1158
|
getShipToAddresses
|
|
1189
1159
|
};
|
|
1190
1160
|
}
|
|
1191
1161
|
|
|
1192
1162
|
// src/actions/smarty-streets.ts
|
|
1193
|
-
function createSmartyStreetsActions(api,
|
|
1194
|
-
const { cachePrefix: _cachePrefix = "" } = config;
|
|
1163
|
+
function createSmartyStreetsActions(api, _config = {}) {
|
|
1195
1164
|
async function validateAddress(params) {
|
|
1196
1165
|
try {
|
|
1197
1166
|
const response = await api.smartyStreets.us.lookup.get(params);
|
|
@@ -1211,8 +1180,9 @@ function createSmartyStreetsActions(api, config = {}) {
|
|
|
1211
1180
|
}
|
|
1212
1181
|
|
|
1213
1182
|
// src/actions/p21-pim.ts
|
|
1183
|
+
import { hours as hours9 } from "@simpleapps-com/augur-utils";
|
|
1214
1184
|
function createP21PimActions(api, config = {}) {
|
|
1215
|
-
const { cachePrefix = "", edgeCache = 1, redisTtl =
|
|
1185
|
+
const { cachePrefix = "", edgeCache = 1, redisTtl = hours9(1) } = config;
|
|
1216
1186
|
async function getInvMastExt(invMastUid) {
|
|
1217
1187
|
return withServerCache(
|
|
1218
1188
|
cachePrefix,
|
|
@@ -1247,8 +1217,9 @@ function createP21PimActions(api, config = {}) {
|
|
|
1247
1217
|
}
|
|
1248
1218
|
|
|
1249
1219
|
// src/actions/agr-site.ts
|
|
1220
|
+
import { hours as hours10 } from "@simpleapps-com/augur-utils";
|
|
1250
1221
|
function createAgrSiteActions(api, config = {}) {
|
|
1251
|
-
const { cachePrefix = "", longEdgeCache = 8, longRedisTtl =
|
|
1222
|
+
const { cachePrefix = "", longEdgeCache = 8, longRedisTtl = hours10(8) } = config;
|
|
1252
1223
|
async function getSettings(serviceName) {
|
|
1253
1224
|
return withServerCache(
|
|
1254
1225
|
cachePrefix,
|
|
@@ -1256,39 +1227,28 @@ function createAgrSiteActions(api, config = {}) {
|
|
|
1256
1227
|
"agrSite.settings.list",
|
|
1257
1228
|
async () => {
|
|
1258
1229
|
const response = await api.agrSite.settings.list({
|
|
1259
|
-
|
|
1230
|
+
serviceName,
|
|
1260
1231
|
edgeCache: longEdgeCache
|
|
1261
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1262
1232
|
});
|
|
1263
1233
|
return toListResult(response);
|
|
1264
1234
|
},
|
|
1265
1235
|
serviceName
|
|
1266
1236
|
);
|
|
1267
1237
|
}
|
|
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
|
-
);
|
|
1238
|
+
async function getRobots() {
|
|
1239
|
+
return withServerCache(cachePrefix, longRedisTtl, "agrSite.metaFiles.robots.list", async () => {
|
|
1240
|
+
const response = await api.agrSite.metaFiles.robots.list({ edgeCache: longEdgeCache });
|
|
1241
|
+
return response.data;
|
|
1242
|
+
});
|
|
1282
1243
|
}
|
|
1283
1244
|
return {
|
|
1284
1245
|
getSettings,
|
|
1285
|
-
|
|
1246
|
+
getRobots
|
|
1286
1247
|
};
|
|
1287
1248
|
}
|
|
1288
1249
|
|
|
1289
1250
|
// src/actions/avalara.ts
|
|
1290
|
-
function createAvalaraActions(api,
|
|
1291
|
-
const { cachePrefix: _cachePrefix = "" } = config;
|
|
1251
|
+
function createAvalaraActions(api, _config = {}) {
|
|
1292
1252
|
async function calculateTax(data) {
|
|
1293
1253
|
const response = await api.avalara.rates.create(data);
|
|
1294
1254
|
return response.data;
|
|
@@ -1300,16 +1260,13 @@ function createAvalaraActions(api, config = {}) {
|
|
|
1300
1260
|
|
|
1301
1261
|
// src/actions/payments.ts
|
|
1302
1262
|
function createPaymentsActions(api, config = {}) {
|
|
1303
|
-
const
|
|
1263
|
+
const mode = configuredModeOf(config.mode);
|
|
1304
1264
|
function withMode(params) {
|
|
1305
1265
|
return { mode, ...params };
|
|
1306
1266
|
}
|
|
1307
1267
|
async function transactionSetup(params) {
|
|
1308
1268
|
try {
|
|
1309
|
-
const response = (
|
|
1310
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1311
|
-
await api.payments.unified.transactionSetup.list(withMode(params))
|
|
1312
|
-
);
|
|
1269
|
+
const response = await api.payments.unified.transactionSetup.list(withMode(params));
|
|
1313
1270
|
return response.data;
|
|
1314
1271
|
} catch {
|
|
1315
1272
|
return void 0;
|
|
@@ -1317,10 +1274,7 @@ function createPaymentsActions(api, config = {}) {
|
|
|
1317
1274
|
}
|
|
1318
1275
|
async function accountQuery(params) {
|
|
1319
1276
|
try {
|
|
1320
|
-
const response = (
|
|
1321
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1322
|
-
await api.payments.unified.accountQuery.list(withMode(params))
|
|
1323
|
-
);
|
|
1277
|
+
const response = await api.payments.unified.accountQuery.list(withMode(params));
|
|
1324
1278
|
return response.data;
|
|
1325
1279
|
} catch {
|
|
1326
1280
|
return void 0;
|
|
@@ -1328,10 +1282,7 @@ function createPaymentsActions(api, config = {}) {
|
|
|
1328
1282
|
}
|
|
1329
1283
|
async function getSurcharge(params) {
|
|
1330
1284
|
try {
|
|
1331
|
-
const response = (
|
|
1332
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1333
|
-
await api.payments.unified.surcharge.list(withMode(params))
|
|
1334
|
-
);
|
|
1285
|
+
const response = await api.payments.unified.surcharge.list(withMode(params));
|
|
1335
1286
|
return response.data;
|
|
1336
1287
|
} catch {
|
|
1337
1288
|
return void 0;
|
|
@@ -1339,10 +1290,7 @@ function createPaymentsActions(api, config = {}) {
|
|
|
1339
1290
|
}
|
|
1340
1291
|
async function cardInfo(params) {
|
|
1341
1292
|
try {
|
|
1342
|
-
const response = (
|
|
1343
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1344
|
-
await api.payments.unified.cardInfo.list(withMode(params))
|
|
1345
|
-
);
|
|
1293
|
+
const response = await api.payments.unified.cardInfo.list(withMode(params));
|
|
1346
1294
|
return response.data;
|
|
1347
1295
|
} catch {
|
|
1348
1296
|
return void 0;
|
|
@@ -1350,10 +1298,7 @@ function createPaymentsActions(api, config = {}) {
|
|
|
1350
1298
|
}
|
|
1351
1299
|
async function billingUpdate(params) {
|
|
1352
1300
|
try {
|
|
1353
|
-
const response = (
|
|
1354
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1355
|
-
await api.payments.unified.billingUpdate.list(withMode(params))
|
|
1356
|
-
);
|
|
1301
|
+
const response = await api.payments.unified.billingUpdate.list(withMode(params));
|
|
1357
1302
|
return response.data;
|
|
1358
1303
|
} catch {
|
|
1359
1304
|
return void 0;
|
|
@@ -1361,18 +1306,8 @@ function createPaymentsActions(api, config = {}) {
|
|
|
1361
1306
|
}
|
|
1362
1307
|
async function validatePayment(params) {
|
|
1363
1308
|
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) };
|
|
1309
|
+
const response = await api.payments.unified.validate.list(withMode(params));
|
|
1310
|
+
return response.data;
|
|
1376
1311
|
} catch {
|
|
1377
1312
|
return void 0;
|
|
1378
1313
|
}
|
|
@@ -1388,8 +1323,9 @@ function createPaymentsActions(api, config = {}) {
|
|
|
1388
1323
|
}
|
|
1389
1324
|
|
|
1390
1325
|
// src/actions/logistics.ts
|
|
1326
|
+
import { hours as hours11 } from "@simpleapps-com/augur-utils";
|
|
1391
1327
|
function createLogisticsActions(api, config = {}) {
|
|
1392
|
-
const { cachePrefix = "", longEdgeCache = 8, longRedisTtl =
|
|
1328
|
+
const { cachePrefix = "", longEdgeCache = 8, longRedisTtl = hours11(8) } = config;
|
|
1393
1329
|
async function getFreightRates(params) {
|
|
1394
1330
|
try {
|
|
1395
1331
|
const response = await api.logistics.speedship.freight.list(params);
|
|
@@ -1407,11 +1343,10 @@ function createLogisticsActions(api, config = {}) {
|
|
|
1407
1343
|
const response = await api.logistics.shipvia.rates.list({
|
|
1408
1344
|
...params,
|
|
1409
1345
|
edgeCache: longEdgeCache
|
|
1410
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1411
1346
|
});
|
|
1412
1347
|
return toListResult(response);
|
|
1413
1348
|
},
|
|
1414
|
-
|
|
1349
|
+
JSON.stringify(params)
|
|
1415
1350
|
);
|
|
1416
1351
|
}
|
|
1417
1352
|
return {
|
|
@@ -1420,105 +1355,25 @@ function createLogisticsActions(api, config = {}) {
|
|
|
1420
1355
|
};
|
|
1421
1356
|
}
|
|
1422
1357
|
|
|
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
1358
|
// src/actions/vmi.ts
|
|
1359
|
+
import { hours as hours12, minutes as minutes3 } from "@simpleapps-com/augur-utils";
|
|
1506
1360
|
function createVmiActions(api, config = {}) {
|
|
1507
|
-
const {
|
|
1361
|
+
const {
|
|
1362
|
+
cachePrefix = "",
|
|
1363
|
+
edgeCache = 1,
|
|
1364
|
+
redisTtl = hours12(1),
|
|
1365
|
+
shortRedisTtl = minutes3(5)
|
|
1366
|
+
} = config;
|
|
1508
1367
|
async function getWarehouses(params) {
|
|
1509
1368
|
return withServerCache(
|
|
1510
1369
|
cachePrefix,
|
|
1511
1370
|
redisTtl,
|
|
1512
1371
|
"vmi.warehouse.list",
|
|
1513
1372
|
async () => {
|
|
1514
|
-
const response = await api.vmi.warehouse.list({
|
|
1515
|
-
...params,
|
|
1516
|
-
edgeCache
|
|
1517
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1518
|
-
});
|
|
1373
|
+
const response = await api.vmi.warehouse.list({ ...params, edgeCache });
|
|
1519
1374
|
return toListResult(response);
|
|
1520
1375
|
},
|
|
1521
|
-
|
|
1376
|
+
JSON.stringify(params)
|
|
1522
1377
|
);
|
|
1523
1378
|
}
|
|
1524
1379
|
async function getWarehouseAvailability(warehouseUid, params) {
|
|
@@ -1527,15 +1382,14 @@ function createVmiActions(api, config = {}) {
|
|
|
1527
1382
|
shortRedisTtl,
|
|
1528
1383
|
"vmi.warehouse.availability.get",
|
|
1529
1384
|
async () => {
|
|
1530
|
-
const response = await api.vmi.warehouse.availability.list(
|
|
1531
|
-
|
|
1532
|
-
|
|
1533
|
-
|
|
1534
|
-
);
|
|
1385
|
+
const response = await api.vmi.warehouse.availability.list(warehouseUid, {
|
|
1386
|
+
...params,
|
|
1387
|
+
edgeCache
|
|
1388
|
+
});
|
|
1535
1389
|
return toListResult(response);
|
|
1536
1390
|
},
|
|
1537
1391
|
warehouseUid,
|
|
1538
|
-
|
|
1392
|
+
JSON.stringify(params)
|
|
1539
1393
|
);
|
|
1540
1394
|
}
|
|
1541
1395
|
async function getDistributors(params) {
|
|
@@ -1544,14 +1398,10 @@ function createVmiActions(api, config = {}) {
|
|
|
1544
1398
|
redisTtl,
|
|
1545
1399
|
"vmi.distributors.list",
|
|
1546
1400
|
async () => {
|
|
1547
|
-
const response = await api.vmi.distributors.list({
|
|
1548
|
-
...params,
|
|
1549
|
-
edgeCache
|
|
1550
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1551
|
-
});
|
|
1401
|
+
const response = await api.vmi.distributors.list({ ...params, edgeCache });
|
|
1552
1402
|
return toListResult(response);
|
|
1553
1403
|
},
|
|
1554
|
-
|
|
1404
|
+
JSON.stringify(params)
|
|
1555
1405
|
);
|
|
1556
1406
|
}
|
|
1557
1407
|
async function getProducts(params) {
|
|
@@ -1560,14 +1410,10 @@ function createVmiActions(api, config = {}) {
|
|
|
1560
1410
|
redisTtl,
|
|
1561
1411
|
"vmi.products.list",
|
|
1562
1412
|
async () => {
|
|
1563
|
-
const response = await api.vmi.products.list({
|
|
1564
|
-
...params,
|
|
1565
|
-
edgeCache
|
|
1566
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1567
|
-
});
|
|
1413
|
+
const response = await api.vmi.products.list({ ...params, edgeCache });
|
|
1568
1414
|
return toListResult(response);
|
|
1569
1415
|
},
|
|
1570
|
-
|
|
1416
|
+
JSON.stringify(params)
|
|
1571
1417
|
);
|
|
1572
1418
|
}
|
|
1573
1419
|
async function getInventoryProfiles(params) {
|
|
@@ -1576,14 +1422,10 @@ function createVmiActions(api, config = {}) {
|
|
|
1576
1422
|
redisTtl,
|
|
1577
1423
|
"vmi.invProfileHdr.list",
|
|
1578
1424
|
async () => {
|
|
1579
|
-
const response = await api.vmi.invProfileHdr.list({
|
|
1580
|
-
...params,
|
|
1581
|
-
edgeCache
|
|
1582
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1583
|
-
});
|
|
1425
|
+
const response = await api.vmi.invProfileHdr.list({ ...params, edgeCache });
|
|
1584
1426
|
return toListResult(response);
|
|
1585
1427
|
},
|
|
1586
|
-
|
|
1428
|
+
JSON.stringify(params)
|
|
1587
1429
|
);
|
|
1588
1430
|
}
|
|
1589
1431
|
async function getRestockHeaders(params) {
|
|
@@ -1592,11 +1434,7 @@ function createVmiActions(api, config = {}) {
|
|
|
1592
1434
|
redisTtl,
|
|
1593
1435
|
"vmi.restockHdr.list",
|
|
1594
1436
|
async () => {
|
|
1595
|
-
const response = await api.vmi.restockHdr.list({
|
|
1596
|
-
...params,
|
|
1597
|
-
edgeCache
|
|
1598
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1599
|
-
});
|
|
1437
|
+
const response = await api.vmi.restockHdr.list({ ...params, edgeCache });
|
|
1600
1438
|
return toListResult(response);
|
|
1601
1439
|
},
|
|
1602
1440
|
params ? JSON.stringify(params) : void 0
|
|
@@ -1608,14 +1446,10 @@ function createVmiActions(api, config = {}) {
|
|
|
1608
1446
|
redisTtl,
|
|
1609
1447
|
"vmi.sections.list",
|
|
1610
1448
|
async () => {
|
|
1611
|
-
const response = await api.vmi.sections.list({
|
|
1612
|
-
...params,
|
|
1613
|
-
edgeCache
|
|
1614
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1615
|
-
});
|
|
1449
|
+
const response = await api.vmi.sections.list({ ...params, edgeCache });
|
|
1616
1450
|
return toListResult(response);
|
|
1617
1451
|
},
|
|
1618
|
-
|
|
1452
|
+
JSON.stringify(params)
|
|
1619
1453
|
);
|
|
1620
1454
|
}
|
|
1621
1455
|
return {
|
|
@@ -1630,13 +1464,14 @@ function createVmiActions(api, config = {}) {
|
|
|
1630
1464
|
}
|
|
1631
1465
|
|
|
1632
1466
|
// src/actions/p21-core.ts
|
|
1467
|
+
import { hours as hours13 } from "@simpleapps-com/augur-utils";
|
|
1633
1468
|
function createP21CoreActions(api, config = {}) {
|
|
1634
1469
|
const {
|
|
1635
1470
|
cachePrefix = "",
|
|
1636
1471
|
edgeCache = 1,
|
|
1637
1472
|
longEdgeCache = 8,
|
|
1638
|
-
redisTtl =
|
|
1639
|
-
longRedisTtl =
|
|
1473
|
+
redisTtl = hours13(1),
|
|
1474
|
+
longRedisTtl = hours13(8)
|
|
1640
1475
|
} = config;
|
|
1641
1476
|
async function getAddresses(params) {
|
|
1642
1477
|
return withServerCache(
|
|
@@ -1736,7 +1571,6 @@ function createP21CoreActions(api, config = {}) {
|
|
|
1736
1571
|
const response = await api.p21Core.codeP21.list({
|
|
1737
1572
|
...params,
|
|
1738
1573
|
edgeCache: longEdgeCache
|
|
1739
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1740
1574
|
});
|
|
1741
1575
|
return toListResult(response);
|
|
1742
1576
|
},
|
|
@@ -1755,103 +1589,10 @@ function createP21CoreActions(api, config = {}) {
|
|
|
1755
1589
|
}
|
|
1756
1590
|
|
|
1757
1591
|
// 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
|
-
}
|
|
1592
|
+
function createP21ApisActions(api, _config = {}) {
|
|
1849
1593
|
async function refreshContacts(params) {
|
|
1850
1594
|
try {
|
|
1851
|
-
const response = (
|
|
1852
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1853
|
-
await api.p21Apis.entityContacts.refresh.create(params)
|
|
1854
|
-
);
|
|
1595
|
+
const response = await api.p21Apis.entityContacts.refresh.get(params);
|
|
1855
1596
|
return response.data;
|
|
1856
1597
|
} catch {
|
|
1857
1598
|
return void 0;
|
|
@@ -1859,30 +1600,22 @@ function createP21ApisActions(api, config = {}) {
|
|
|
1859
1600
|
}
|
|
1860
1601
|
async function refreshCustomers(params) {
|
|
1861
1602
|
try {
|
|
1862
|
-
const response = (
|
|
1863
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1864
|
-
await api.p21Apis.entityCustomers.refresh.create(params)
|
|
1865
|
-
);
|
|
1603
|
+
const response = await api.p21Apis.entityCustomers.refresh.get(params);
|
|
1866
1604
|
return response.data;
|
|
1867
1605
|
} catch {
|
|
1868
1606
|
return void 0;
|
|
1869
1607
|
}
|
|
1870
1608
|
}
|
|
1871
1609
|
return {
|
|
1872
|
-
getCategories,
|
|
1873
|
-
getCategoryDefaults,
|
|
1874
|
-
getCompanies,
|
|
1875
|
-
getUsers,
|
|
1876
|
-
getWebDisplayTypes,
|
|
1877
|
-
getWebDisplayTypeDefaults,
|
|
1878
1610
|
refreshContacts,
|
|
1879
1611
|
refreshCustomers
|
|
1880
1612
|
};
|
|
1881
1613
|
}
|
|
1882
1614
|
|
|
1883
1615
|
// src/actions/p21-sism.ts
|
|
1616
|
+
import { hours as hours14 } from "@simpleapps-com/augur-utils";
|
|
1884
1617
|
function createP21SismActions(api, config = {}) {
|
|
1885
|
-
const { cachePrefix = "", edgeCache = 1, redisTtl =
|
|
1618
|
+
const { cachePrefix = "", edgeCache = 1, redisTtl = hours14(1) } = config;
|
|
1886
1619
|
async function getRecentImports(params) {
|
|
1887
1620
|
return withServerCache(
|
|
1888
1621
|
cachePrefix,
|
|
@@ -1898,33 +1631,16 @@ function createP21SismActions(api, config = {}) {
|
|
|
1898
1631
|
params
|
|
1899
1632
|
);
|
|
1900
1633
|
}
|
|
1901
|
-
async function getImport(
|
|
1634
|
+
async function getImport(importUid) {
|
|
1902
1635
|
return withServerCache(
|
|
1903
1636
|
cachePrefix,
|
|
1904
1637
|
redisTtl,
|
|
1905
1638
|
"p21Sism.import.get",
|
|
1906
1639
|
async () => {
|
|
1907
|
-
const response = await api.p21Sism.import.get(
|
|
1640
|
+
const response = await api.p21Sism.import.get(importUid);
|
|
1908
1641
|
return response.data;
|
|
1909
1642
|
},
|
|
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
|
|
1643
|
+
importUid
|
|
1928
1644
|
);
|
|
1929
1645
|
}
|
|
1930
1646
|
async function getScheduledImports(params) {
|
|
@@ -1945,7 +1661,6 @@ function createP21SismActions(api, config = {}) {
|
|
|
1945
1661
|
return {
|
|
1946
1662
|
getRecentImports,
|
|
1947
1663
|
getImport,
|
|
1948
|
-
getImportLines,
|
|
1949
1664
|
getScheduledImports
|
|
1950
1665
|
};
|
|
1951
1666
|
}
|
|
@@ -1975,13 +1690,14 @@ function createAgrWorkActions(api, _config = {}) {
|
|
|
1975
1690
|
}
|
|
1976
1691
|
|
|
1977
1692
|
// src/actions/agr-info.ts
|
|
1693
|
+
import { hours as hours15 } from "@simpleapps-com/augur-utils";
|
|
1978
1694
|
function createAgrInfoActions(api, config = {}) {
|
|
1979
1695
|
const {
|
|
1980
1696
|
cachePrefix = "",
|
|
1981
1697
|
edgeCache = 1,
|
|
1982
1698
|
longEdgeCache = 8,
|
|
1983
|
-
redisTtl =
|
|
1984
|
-
longRedisTtl =
|
|
1699
|
+
redisTtl = hours15(1),
|
|
1700
|
+
longRedisTtl = hours15(8)
|
|
1985
1701
|
} = config;
|
|
1986
1702
|
async function getContext(params) {
|
|
1987
1703
|
return withServerCache(
|
|
@@ -2055,13 +1771,14 @@ function createAgrInfoActions(api, config = {}) {
|
|
|
2055
1771
|
}
|
|
2056
1772
|
|
|
2057
1773
|
// src/actions/basecamp2.ts
|
|
1774
|
+
import { hours as hours16 } from "@simpleapps-com/augur-utils";
|
|
2058
1775
|
function createBasecamp2Actions(api, config = {}) {
|
|
2059
1776
|
const {
|
|
2060
1777
|
cachePrefix = "",
|
|
2061
1778
|
edgeCache = 1,
|
|
2062
1779
|
longEdgeCache = 8,
|
|
2063
|
-
redisTtl =
|
|
2064
|
-
longRedisTtl =
|
|
1780
|
+
redisTtl = hours16(1),
|
|
1781
|
+
longRedisTtl = hours16(8)
|
|
2065
1782
|
} = config;
|
|
2066
1783
|
async function getTodos(params) {
|
|
2067
1784
|
return withServerCache(
|
|
@@ -2069,11 +1786,7 @@ function createBasecamp2Actions(api, config = {}) {
|
|
|
2069
1786
|
redisTtl,
|
|
2070
1787
|
"basecamp2.todos.list",
|
|
2071
1788
|
async () => {
|
|
2072
|
-
const response = await api.basecamp2.todos.list({
|
|
2073
|
-
...params,
|
|
2074
|
-
edgeCache
|
|
2075
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
2076
|
-
});
|
|
1789
|
+
const response = await api.basecamp2.todos.list({ ...params, edgeCache });
|
|
2077
1790
|
return toListResult(response);
|
|
2078
1791
|
},
|
|
2079
1792
|
params
|
|
@@ -2097,11 +1810,7 @@ function createBasecamp2Actions(api, config = {}) {
|
|
|
2097
1810
|
redisTtl,
|
|
2098
1811
|
"basecamp2.todosSummary.list",
|
|
2099
1812
|
async () => {
|
|
2100
|
-
const response = await api.basecamp2.todosSummary.list({
|
|
2101
|
-
...params,
|
|
2102
|
-
edgeCache
|
|
2103
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
2104
|
-
});
|
|
1813
|
+
const response = await api.basecamp2.todosSummary.list({ ...params, edgeCache });
|
|
2105
1814
|
return toListResult(response);
|
|
2106
1815
|
},
|
|
2107
1816
|
params
|
|
@@ -2113,11 +1822,7 @@ function createBasecamp2Actions(api, config = {}) {
|
|
|
2113
1822
|
redisTtl,
|
|
2114
1823
|
"basecamp2.comments.list",
|
|
2115
1824
|
async () => {
|
|
2116
|
-
const response = await api.basecamp2.comments.list({
|
|
2117
|
-
...params,
|
|
2118
|
-
edgeCache
|
|
2119
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
2120
|
-
});
|
|
1825
|
+
const response = await api.basecamp2.comments.list({ ...params, edgeCache });
|
|
2121
1826
|
return toListResult(response);
|
|
2122
1827
|
},
|
|
2123
1828
|
params
|
|
@@ -2132,7 +1837,6 @@ function createBasecamp2Actions(api, config = {}) {
|
|
|
2132
1837
|
const response = await api.basecamp2.people.list({
|
|
2133
1838
|
...params,
|
|
2134
1839
|
edgeCache: longEdgeCache
|
|
2135
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
2136
1840
|
});
|
|
2137
1841
|
return toListResult(response);
|
|
2138
1842
|
},
|
|
@@ -2145,11 +1849,7 @@ function createBasecamp2Actions(api, config = {}) {
|
|
|
2145
1849
|
redisTtl,
|
|
2146
1850
|
"basecamp2.projects.list",
|
|
2147
1851
|
async () => {
|
|
2148
|
-
const response = await api.basecamp2.projects.list({
|
|
2149
|
-
...params,
|
|
2150
|
-
edgeCache
|
|
2151
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
2152
|
-
});
|
|
1852
|
+
const response = await api.basecamp2.projects.list({ ...params, edgeCache });
|
|
2153
1853
|
return toListResult(response);
|
|
2154
1854
|
},
|
|
2155
1855
|
params
|
|
@@ -2161,11 +1861,7 @@ function createBasecamp2Actions(api, config = {}) {
|
|
|
2161
1861
|
redisTtl,
|
|
2162
1862
|
"basecamp2.events.list",
|
|
2163
1863
|
async () => {
|
|
2164
|
-
const response = await api.basecamp2.events.list({
|
|
2165
|
-
...params,
|
|
2166
|
-
edgeCache
|
|
2167
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
2168
|
-
});
|
|
1864
|
+
const response = await api.basecamp2.events.list({ ...params, edgeCache });
|
|
2169
1865
|
return toListResult(response);
|
|
2170
1866
|
},
|
|
2171
1867
|
params
|
|
@@ -2177,11 +1873,7 @@ function createBasecamp2Actions(api, config = {}) {
|
|
|
2177
1873
|
redisTtl,
|
|
2178
1874
|
"basecamp2.metrics.list",
|
|
2179
1875
|
async () => {
|
|
2180
|
-
const response = await api.basecamp2.metrics.list({
|
|
2181
|
-
...params,
|
|
2182
|
-
edgeCache
|
|
2183
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
2184
|
-
});
|
|
1876
|
+
const response = await api.basecamp2.metrics.list({ ...params, edgeCache });
|
|
2185
1877
|
return toListResult(response);
|
|
2186
1878
|
},
|
|
2187
1879
|
params
|
|
@@ -2193,11 +1885,7 @@ function createBasecamp2Actions(api, config = {}) {
|
|
|
2193
1885
|
redisTtl,
|
|
2194
1886
|
"basecamp2.todolists.list",
|
|
2195
1887
|
async () => {
|
|
2196
|
-
const response = await api.basecamp2.todolists.list({
|
|
2197
|
-
...params,
|
|
2198
|
-
edgeCache
|
|
2199
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
2200
|
-
});
|
|
1888
|
+
const response = await api.basecamp2.todolists.list({ ...params, edgeCache });
|
|
2201
1889
|
return toListResult(response);
|
|
2202
1890
|
},
|
|
2203
1891
|
params
|
|
@@ -2217,8 +1905,9 @@ function createBasecamp2Actions(api, config = {}) {
|
|
|
2217
1905
|
}
|
|
2218
1906
|
|
|
2219
1907
|
// src/actions/brand-folder.ts
|
|
1908
|
+
import { hours as hours17 } from "@simpleapps-com/augur-utils";
|
|
2220
1909
|
function createBrandFolderActions(api, config = {}) {
|
|
2221
|
-
const { cachePrefix = "", edgeCache = 1, redisTtl =
|
|
1910
|
+
const { cachePrefix = "", edgeCache = 1, redisTtl = hours17(1) } = config;
|
|
2222
1911
|
async function getCategories(params) {
|
|
2223
1912
|
return withServerCache(
|
|
2224
1913
|
cachePrefix,
|
|
@@ -2234,25 +1923,25 @@ function createBrandFolderActions(api, config = {}) {
|
|
|
2234
1923
|
params
|
|
2235
1924
|
);
|
|
2236
1925
|
}
|
|
2237
|
-
async function getCategory(
|
|
1926
|
+
async function getCategory(itemCategoryUid) {
|
|
2238
1927
|
return withServerCache(
|
|
2239
1928
|
cachePrefix,
|
|
2240
1929
|
redisTtl,
|
|
2241
1930
|
"brandFolder.categories.get",
|
|
2242
1931
|
async () => {
|
|
2243
|
-
const response = await api.brandFolder.categories.get(
|
|
1932
|
+
const response = await api.brandFolder.categories.get(itemCategoryUid, {
|
|
2244
1933
|
edgeCache
|
|
2245
1934
|
});
|
|
2246
1935
|
return response.data;
|
|
2247
1936
|
},
|
|
2248
|
-
|
|
1937
|
+
itemCategoryUid
|
|
2249
1938
|
);
|
|
2250
1939
|
}
|
|
2251
1940
|
async function createFocus(categoryId, data) {
|
|
2252
1941
|
try {
|
|
2253
1942
|
const response = await api.brandFolder.categories.focus.create({
|
|
2254
1943
|
...data,
|
|
2255
|
-
categoryId
|
|
1944
|
+
itemCategoryId: categoryId
|
|
2256
1945
|
});
|
|
2257
1946
|
return response.data;
|
|
2258
1947
|
} catch {
|
|
@@ -2267,81 +1956,22 @@ function createBrandFolderActions(api, config = {}) {
|
|
|
2267
1956
|
}
|
|
2268
1957
|
|
|
2269
1958
|
// src/actions/gregorovich.ts
|
|
1959
|
+
import { hours as hours18 } from "@simpleapps-com/augur-utils";
|
|
2270
1960
|
function createGregorovichActions(api, config = {}) {
|
|
2271
|
-
const { cachePrefix = "", redisTtl =
|
|
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
|
-
}
|
|
1961
|
+
const { cachePrefix = "", redisTtl = hours18(1) } = config;
|
|
2280
1962
|
async function getDocuments(_params) {
|
|
2281
1963
|
return withServerCache(cachePrefix, redisTtl, "gregorovich.documents.list", async () => {
|
|
2282
1964
|
const response = await api.gregorovich.documents.list();
|
|
2283
1965
|
return toListResult(response);
|
|
2284
1966
|
});
|
|
2285
1967
|
}
|
|
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
|
-
};
|
|
1968
|
+
return { getDocuments };
|
|
2340
1969
|
}
|
|
2341
1970
|
|
|
2342
1971
|
// src/actions/favorites.ts
|
|
1972
|
+
import { hours as hours19 } from "@simpleapps-com/augur-utils";
|
|
2343
1973
|
function createFavoritesActions(api, config = {}) {
|
|
2344
|
-
const { cachePrefix = "", edgeCache = 1, redisTtl =
|
|
1974
|
+
const { cachePrefix = "", edgeCache = 1, redisTtl = hours19(1) } = config;
|
|
2345
1975
|
async function getFavorites(userId) {
|
|
2346
1976
|
return withServerCache(
|
|
2347
1977
|
cachePrefix,
|
|
@@ -2357,9 +1987,7 @@ function createFavoritesActions(api, config = {}) {
|
|
|
2357
1987
|
);
|
|
2358
1988
|
}
|
|
2359
1989
|
async function addFavorite(userId, invMastUid) {
|
|
2360
|
-
const response = await api.items.itemFavorites.items.create(userId,
|
|
2361
|
-
invMastUid
|
|
2362
|
-
});
|
|
1990
|
+
const response = await api.items.itemFavorites.items.create(userId, [invMastUid]);
|
|
2363
1991
|
return response.data;
|
|
2364
1992
|
}
|
|
2365
1993
|
async function removeFavorite(userId, invMastUid) {
|
|
@@ -2369,8 +1997,9 @@ function createFavoritesActions(api, config = {}) {
|
|
|
2369
1997
|
}
|
|
2370
1998
|
|
|
2371
1999
|
// src/actions/wishlists.ts
|
|
2000
|
+
import { hours as hours20 } from "@simpleapps-com/augur-utils";
|
|
2372
2001
|
function createWishlistActions(api, config = {}) {
|
|
2373
|
-
const { cachePrefix = "", edgeCache = 1, redisTtl =
|
|
2002
|
+
const { cachePrefix = "", edgeCache = 1, redisTtl = hours20(1) } = config;
|
|
2374
2003
|
async function getWishlists(userId) {
|
|
2375
2004
|
return withServerCache(
|
|
2376
2005
|
cachePrefix,
|
|
@@ -2406,12 +2035,7 @@ function createWishlistActions(api, config = {}) {
|
|
|
2406
2035
|
await api.items.itemWishlist.hdr.delete(userId, wishlistId);
|
|
2407
2036
|
}
|
|
2408
2037
|
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
|
-
);
|
|
2038
|
+
const response = await api.items.itemWishlist.hdr.create(userId, wishlistId, items);
|
|
2415
2039
|
return response.data;
|
|
2416
2040
|
}
|
|
2417
2041
|
async function removeWishlistItem(userId, wishlistId, lineId) {
|
|
@@ -2431,14 +2055,14 @@ function createWishlistActions(api, config = {}) {
|
|
|
2431
2055
|
function createSiteActions(api, config = {}) {
|
|
2432
2056
|
const siteId = api.config?.siteId ?? "";
|
|
2433
2057
|
const {
|
|
2434
|
-
cachePrefix = siteId ?
|
|
2058
|
+
cachePrefix = siteId ? scopedPrefix(siteId) : "",
|
|
2435
2059
|
edgeCache,
|
|
2436
2060
|
redisTtl,
|
|
2437
2061
|
longEdgeCache,
|
|
2438
2062
|
longRedisTtl,
|
|
2439
2063
|
defaultContactId = process.env["DEFAULT_CONTACT_ID"],
|
|
2440
2064
|
defaultCustomerId = process.env["DEFAULT_CUSTOMER_ID"],
|
|
2441
|
-
defaultCompanyId
|
|
2065
|
+
// defaultCompanyId is accepted in the config but no action reads it yet
|
|
2442
2066
|
convertUnitOfMeasure
|
|
2443
2067
|
} = config;
|
|
2444
2068
|
const cache = { cachePrefix, edgeCache, redisTtl };
|
|
@@ -2447,13 +2071,7 @@ function createSiteActions(api, config = {}) {
|
|
|
2447
2071
|
return api;
|
|
2448
2072
|
}
|
|
2449
2073
|
function lazy(fn) {
|
|
2450
|
-
|
|
2451
|
-
return {
|
|
2452
|
-
get() {
|
|
2453
|
-
if (instance === void 0) instance = fn();
|
|
2454
|
-
return instance;
|
|
2455
|
-
}
|
|
2456
|
-
};
|
|
2074
|
+
return { get: fn };
|
|
2457
2075
|
}
|
|
2458
2076
|
const pricing = lazy(
|
|
2459
2077
|
() => createPricingActions(castApi(), {
|
|
@@ -2512,7 +2130,6 @@ function createSiteActions(api, config = {}) {
|
|
|
2512
2130
|
})
|
|
2513
2131
|
);
|
|
2514
2132
|
const logistics = lazy(() => createLogisticsActions(castApi(), longCache));
|
|
2515
|
-
const nexus = lazy(() => createNexusActions(castApi(), cache));
|
|
2516
2133
|
const vmi = lazy(() => createVmiActions(castApi(), { ...cache, ...config.vmi }));
|
|
2517
2134
|
const p21Core = lazy(() => createP21CoreActions(castApi(), longCache));
|
|
2518
2135
|
const p21Apis = lazy(() => createP21ApisActions(castApi(), cache));
|
|
@@ -2522,7 +2139,6 @@ function createSiteActions(api, config = {}) {
|
|
|
2522
2139
|
const basecamp2 = lazy(() => createBasecamp2Actions(castApi(), longCache));
|
|
2523
2140
|
const brandFolder = lazy(() => createBrandFolderActions(castApi(), cache));
|
|
2524
2141
|
const gregorovich = lazy(() => createGregorovichActions(castApi(), cache));
|
|
2525
|
-
const slack = lazy(() => createSlackActions(castApi(), cache));
|
|
2526
2142
|
const favorites = lazy(() => createFavoritesActions(castApi(), cache));
|
|
2527
2143
|
const wishlists = lazy(() => createWishlistActions(castApi(), cache));
|
|
2528
2144
|
const legacyServices = {
|
|
@@ -2571,9 +2187,6 @@ function createSiteActions(api, config = {}) {
|
|
|
2571
2187
|
get logistics() {
|
|
2572
2188
|
return logistics.get();
|
|
2573
2189
|
},
|
|
2574
|
-
get nexus() {
|
|
2575
|
-
return nexus.get();
|
|
2576
|
-
},
|
|
2577
2190
|
get vmi() {
|
|
2578
2191
|
return vmi.get();
|
|
2579
2192
|
},
|
|
@@ -2601,9 +2214,6 @@ function createSiteActions(api, config = {}) {
|
|
|
2601
2214
|
get gregorovich() {
|
|
2602
2215
|
return gregorovich.get();
|
|
2603
2216
|
},
|
|
2604
|
-
get slack() {
|
|
2605
|
-
return slack.get();
|
|
2606
|
-
},
|
|
2607
2217
|
get favorites() {
|
|
2608
2218
|
return favorites.get();
|
|
2609
2219
|
},
|
|
@@ -2615,7 +2225,7 @@ function createSiteActions(api, config = {}) {
|
|
|
2615
2225
|
cachePrefix,
|
|
2616
2226
|
wrapCall: async ({ methodPath, args, sdkCall: sdkCall2, tier, isRead: read }) => {
|
|
2617
2227
|
if (read && tier.redisTtl) {
|
|
2618
|
-
return
|
|
2228
|
+
return withRawSdkCache(
|
|
2619
2229
|
cachePrefix,
|
|
2620
2230
|
tier.redisTtl,
|
|
2621
2231
|
methodPath,
|
|
@@ -2633,20 +2243,17 @@ function createSiteActions(api, config = {}) {
|
|
|
2633
2243
|
const key = prop;
|
|
2634
2244
|
const cached = wrappedCache.get(key);
|
|
2635
2245
|
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
|
-
}
|
|
2246
|
+
if (Object.hasOwn(target, key)) {
|
|
2247
|
+
const legacySvc = Reflect.get(target, key);
|
|
2248
|
+
const wrapped = new Proxy(legacySvc, {
|
|
2249
|
+
get(svc, method) {
|
|
2250
|
+
if (typeof method === "symbol") return void 0;
|
|
2251
|
+
if (method in svc) return svc[method];
|
|
2252
|
+
return proxyFallback[key]?.[method];
|
|
2253
|
+
}
|
|
2254
|
+
});
|
|
2255
|
+
wrappedCache.set(key, wrapped);
|
|
2256
|
+
return wrapped;
|
|
2650
2257
|
}
|
|
2651
2258
|
const proxied = proxyFallback[key];
|
|
2652
2259
|
wrappedCache.set(key, proxied);
|
|
@@ -2679,23 +2286,23 @@ function clearSiteActions() {
|
|
|
2679
2286
|
|
|
2680
2287
|
// src/server-site-registry.ts
|
|
2681
2288
|
import { getCacheTier } from "@simpleapps-com/augur-core";
|
|
2289
|
+
import { hours as hours21 } from "@simpleapps-com/augur-utils";
|
|
2290
|
+
import { AugurAPI } from "@simpleapps-com/augur-api";
|
|
2682
2291
|
function registerSiteActions2(actions) {
|
|
2683
2292
|
registerSiteActions(actions);
|
|
2684
2293
|
}
|
|
2685
2294
|
function registerClientAndWrapper(api) {
|
|
2686
2295
|
registerSdkClient(api);
|
|
2687
2296
|
registerSdkCallWrapper((methodPath, sdkCall2, ...keyArgs) => {
|
|
2688
|
-
const
|
|
2689
|
-
if (
|
|
2690
|
-
|
|
2691
|
-
return withServerCache("", ttl, methodPath, sdkCall2, ...keyArgs);
|
|
2297
|
+
const ttl = ttlFor(getCacheTier(methodPath).staleTime, hours21(1), hours21(8));
|
|
2298
|
+
if (ttl === null) return sdkCall2();
|
|
2299
|
+
return withRawSdkCache("", ttl, methodPath, sdkCall2, ...keyArgs);
|
|
2692
2300
|
});
|
|
2693
2301
|
}
|
|
2694
2302
|
function autoInitFromEnv() {
|
|
2695
2303
|
const siteId = process.env["AUGUR_SITE_ID"];
|
|
2696
2304
|
const bearerToken = process.env["AUGUR_JWT"];
|
|
2697
2305
|
if (!siteId || !bearerToken) return null;
|
|
2698
|
-
const { AugurAPI } = __require("@simpleapps-com/augur-api");
|
|
2699
2306
|
const api = new AugurAPI({ siteId, bearerToken });
|
|
2700
2307
|
const actions = createSiteActions(api);
|
|
2701
2308
|
registerSiteActions2(actions);
|
|
@@ -2730,10 +2337,11 @@ export {
|
|
|
2730
2337
|
unwrapOr,
|
|
2731
2338
|
batchFetch,
|
|
2732
2339
|
withServerCache,
|
|
2340
|
+
withRawSdkCache,
|
|
2733
2341
|
paginateOffset,
|
|
2734
2342
|
createSiteActions,
|
|
2735
2343
|
registerSiteActions2 as registerSiteActions,
|
|
2736
2344
|
getSiteActions,
|
|
2737
2345
|
clearSiteActions2 as clearSiteActions
|
|
2738
2346
|
};
|
|
2739
|
-
//# sourceMappingURL=chunk-
|
|
2347
|
+
//# sourceMappingURL=chunk-LX7SJJOU.js.map
|