@simpleapps-com/augur-server 0.2.11 → 0.2.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +34 -2
- package/dist/index.js +46 -15
- package/dist/index.js.map +1 -1
- package/dist/{site-ByP_eK_M.d.ts → site-DibGofHe.d.ts} +25 -5
- package/dist/testing.d.ts +1 -1
- package/package.json +4 -4
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { QueryClient } from '@tanstack/react-query';
|
|
2
2
|
export { QueryOptionsConfig, createQueryOptions, createSuspenseQueryOptions } from './query.js';
|
|
3
|
-
export { A as
|
|
3
|
+
export { A as AddressValidationResult, a as AgrInfoActions, b as AgrInfoActionsConfig, c as AgrInfoApiClient, d as AgrSiteActions, e as AgrSiteActionsConfig, f as AgrSiteApiClient, g as AgrWorkActions, h as AgrWorkActionsConfig, i as AgrWorkApiClient, j as AvalaraActions, k as AvalaraActionsConfig, l as AvalaraApiClient, B as Basecamp2Actions, m as Basecamp2ActionsConfig, n as Basecamp2ApiClient, o as BrandFolderActions, p as BrandFolderActionsConfig, q as BrandFolderApiClient, C as CommerceActions, r as CommerceActionsConfig, s as CommerceApiClient, t as CustomersActions, u as CustomersActionsConfig, v as CustomersApiClient, G as GregorovichActions, w as GregorovichActionsConfig, x as GregorovichApiClient, I as ItemActions, y as ItemActionsConfig, z as ItemsApiClient, J as JoomlaActions, D as JoomlaActionsConfig, E as JoomlaApiClient, L as LegacyActions, F as LegacyActionsConfig, H as LegacyApiClient, K as LogisticsActions, M as LogisticsActionsConfig, N as LogisticsApiClient, O as NexusActions, P as NexusActionsConfig, Q as NexusApiClient, R as OrderActions, S as OrderActionsConfig, T as OrderApiClient, U as P21ApisActions, V as P21ApisActionsConfig, W as P21ApisApiClient, X as P21CoreActions, Y as P21CoreActionsConfig, Z as P21CoreApiClient, _ as P21PimActions, $ as P21PimActionsConfig, a0 as P21PimApiClient, a1 as P21SismActions, a2 as P21SismActionsConfig, a3 as P21SismApiClient, a4 as PaymentsActions, a5 as PaymentsActionsConfig, a6 as PaymentsApiClient, a7 as PricingActions, a8 as PricingActionsConfig, a9 as PricingApiClient, aa as SearchActions, ab as SearchActionsConfig, ac as SearchApiClient, ad as SearchPage, ae as ShippingActions, af as ShippingActionsConfig, ag as ShippingAddress, ah as ShippingApiClient, ai as SiteActions, aj as SiteActionsConfig, ak as SlackActions, al as SlackActionsConfig, am as SlackApiClient, an as SmartyStreetsActions, ao as SmartyStreetsActionsConfig, ap as SmartyStreetsApiClient, aq as UpsActions, ar as UpsActionsConfig, as as UpsApiClient, at as VmiActions, au as VmiActionsConfig, av as VmiApiClient, aw as createAgrInfoActions, ax as createAgrSiteActions, ay as createAgrWorkActions, az as createAvalaraActions, aA as createBasecamp2Actions, aB as createBrandFolderActions, aC as createCommerceActions, aD as createCustomersActions, aE as createGregorovichActions, aF as createItemActions, aG as createJoomlaActions, aH as createLegacyActions, aI as createLogisticsActions, aJ as createNexusActions, aK as createOrderActions, aL as createP21ApisActions, aM as createP21CoreActions, aN as createP21PimActions, aO as createP21SismActions, aP as createPaymentsActions, aQ as createPricingActions, aR as createSearchActions, aS as createShippingActions, aT as createSiteActions, aU as createSlackActions, aV as createSmartyStreetsActions, aW as createUpsActions, aX as createVmiActions } from './site-DibGofHe.js';
|
|
4
4
|
import '@simpleapps-com/augur-utils';
|
|
5
5
|
|
|
6
6
|
declare const env: "development" | "staging" | "production";
|
|
@@ -113,4 +113,36 @@ declare const getServerQueryClient: () => QueryClient;
|
|
|
113
113
|
*/
|
|
114
114
|
declare function withServerCache<T>(prefix: string, redisTtl: number | undefined, methodPath: string, fn: () => Promise<T>, ...keyArgs: unknown[]): Promise<T>;
|
|
115
115
|
|
|
116
|
-
|
|
116
|
+
/**
|
|
117
|
+
* Standardized paginated response shape.
|
|
118
|
+
* Works with any factory method — compose with `paginateOffset()`.
|
|
119
|
+
*/
|
|
120
|
+
interface PaginatedResult<T> {
|
|
121
|
+
data: T[];
|
|
122
|
+
total?: number;
|
|
123
|
+
nextCursor?: number;
|
|
124
|
+
hasMore: boolean;
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* Wraps a list of items with offset-based pagination metadata.
|
|
128
|
+
*
|
|
129
|
+
* Use this to standardize pagination responses from any factory method.
|
|
130
|
+
* Compatible with React Query's infinite query pattern (`getNextPageParam`).
|
|
131
|
+
*
|
|
132
|
+
* @param items - The items returned from the current page
|
|
133
|
+
* @param pageParam - The current page number (0-based)
|
|
134
|
+
* @param limit - The page size
|
|
135
|
+
* @param total - Optional total count of items (from API response)
|
|
136
|
+
*
|
|
137
|
+
* @example
|
|
138
|
+
* ```ts
|
|
139
|
+
* const result = await actions.items.getCategoryItems(uid, {
|
|
140
|
+
* ...filters, offset: page * 24, limit: 24,
|
|
141
|
+
* });
|
|
142
|
+
* return paginateOffset(result.items, page, 24, result.total);
|
|
143
|
+
* // { data: [...], total: 150, nextCursor: 1, hasMore: true }
|
|
144
|
+
* ```
|
|
145
|
+
*/
|
|
146
|
+
declare function paginateOffset<T>(items: T[], pageParam: number, limit: number, total?: number): PaginatedResult<T>;
|
|
147
|
+
|
|
148
|
+
export { type ActionResult, type PaginatedResult, cacheGet, cacheSet, createServerQueryClient, env, getCircuitState, getServerQueryClient, isDev, isProduction, isRedisConnected, isStaging, paginateOffset, safeAction, sdkCall, withServerCache };
|
package/dist/index.js
CHANGED
|
@@ -187,6 +187,17 @@ async function withServerCache(prefix, redisTtl, methodPath, fn, ...keyArgs) {
|
|
|
187
187
|
return result;
|
|
188
188
|
}
|
|
189
189
|
|
|
190
|
+
// src/pagination.ts
|
|
191
|
+
function paginateOffset(items, pageParam, limit, total) {
|
|
192
|
+
const hasMore = total !== void 0 ? (pageParam + 1) * limit < total : items.length === limit;
|
|
193
|
+
return {
|
|
194
|
+
data: items,
|
|
195
|
+
total,
|
|
196
|
+
nextCursor: hasMore ? pageParam + 1 : void 0,
|
|
197
|
+
hasMore
|
|
198
|
+
};
|
|
199
|
+
}
|
|
200
|
+
|
|
190
201
|
// src/actions/pricing.ts
|
|
191
202
|
function resolveCustomerId(explicit, fallback) {
|
|
192
203
|
const raw = explicit ?? fallback;
|
|
@@ -250,7 +261,8 @@ function createItemActions(api, config = {}) {
|
|
|
250
261
|
longEdgeCache = 8,
|
|
251
262
|
redisTtl = 3600,
|
|
252
263
|
longRedisTtl = 28800,
|
|
253
|
-
sortChildren = true
|
|
264
|
+
sortChildren = true,
|
|
265
|
+
sortByPrefix
|
|
254
266
|
} = config;
|
|
255
267
|
function sortCategoryChildren(children) {
|
|
256
268
|
if (!sortChildren) return children;
|
|
@@ -292,20 +304,23 @@ function createItemActions(api, config = {}) {
|
|
|
292
304
|
};
|
|
293
305
|
}
|
|
294
306
|
async function getCategoryItems(uid, filters) {
|
|
307
|
+
const merged = { ...filters };
|
|
308
|
+
if (sortByPrefix && typeof merged.sortBy === "string" && merged.sortBy) {
|
|
309
|
+
merged.sortBy = `${sortByPrefix}${merged.sortBy}`;
|
|
310
|
+
}
|
|
295
311
|
return withServerCache(
|
|
296
312
|
cachePrefix,
|
|
297
313
|
redisTtl,
|
|
298
314
|
"items.categories.items.list",
|
|
299
315
|
async () => {
|
|
300
|
-
const response = await api.items.categories.items.list({
|
|
301
|
-
...
|
|
302
|
-
itemCategoryUid: uid,
|
|
316
|
+
const response = await api.items.categories.items.list(uid, {
|
|
317
|
+
...merged,
|
|
303
318
|
edgeCache
|
|
304
319
|
});
|
|
305
320
|
return response.data;
|
|
306
321
|
},
|
|
307
322
|
uid,
|
|
308
|
-
|
|
323
|
+
merged
|
|
309
324
|
);
|
|
310
325
|
}
|
|
311
326
|
async function getItemAttributes(categoryUid) {
|
|
@@ -931,8 +946,17 @@ function createCustomersActions(api, config = {}) {
|
|
|
931
946
|
function createSmartyStreetsActions(api, config = {}) {
|
|
932
947
|
const { cachePrefix: _cachePrefix = "" } = config;
|
|
933
948
|
async function validateAddress(params) {
|
|
934
|
-
|
|
935
|
-
|
|
949
|
+
try {
|
|
950
|
+
const response = await api.smartyStreets.us.lookup.get(params);
|
|
951
|
+
const data = response.data;
|
|
952
|
+
if (data) {
|
|
953
|
+
return { data, status: "success" };
|
|
954
|
+
}
|
|
955
|
+
return { data: void 0, status: "not_found" };
|
|
956
|
+
} catch (e) {
|
|
957
|
+
const message = e instanceof Error ? e.message : String(e);
|
|
958
|
+
return { data: void 0, status: "error", error: { message } };
|
|
959
|
+
}
|
|
936
960
|
}
|
|
937
961
|
return {
|
|
938
962
|
validateAddress
|
|
@@ -1034,10 +1058,13 @@ function createAvalaraActions(api, config = {}) {
|
|
|
1034
1058
|
|
|
1035
1059
|
// src/actions/payments.ts
|
|
1036
1060
|
function createPaymentsActions(api, config = {}) {
|
|
1037
|
-
const { cachePrefix: _cachePrefix = "" } = config;
|
|
1061
|
+
const { cachePrefix: _cachePrefix = "", mode = "live" } = config;
|
|
1062
|
+
function withMode(params) {
|
|
1063
|
+
return { mode, ...params };
|
|
1064
|
+
}
|
|
1038
1065
|
async function transactionSetup(params) {
|
|
1039
1066
|
try {
|
|
1040
|
-
const response = await api.payments.unified.transactionSetup.get(params);
|
|
1067
|
+
const response = await api.payments.unified.transactionSetup.get(withMode(params));
|
|
1041
1068
|
return response.data;
|
|
1042
1069
|
} catch {
|
|
1043
1070
|
return void 0;
|
|
@@ -1045,7 +1072,7 @@ function createPaymentsActions(api, config = {}) {
|
|
|
1045
1072
|
}
|
|
1046
1073
|
async function accountQuery(params) {
|
|
1047
1074
|
try {
|
|
1048
|
-
const response = await api.payments.unified.accountQuery.get(params);
|
|
1075
|
+
const response = await api.payments.unified.accountQuery.get(withMode(params));
|
|
1049
1076
|
return response.data;
|
|
1050
1077
|
} catch {
|
|
1051
1078
|
return void 0;
|
|
@@ -1053,7 +1080,7 @@ function createPaymentsActions(api, config = {}) {
|
|
|
1053
1080
|
}
|
|
1054
1081
|
async function getSurcharge(params) {
|
|
1055
1082
|
try {
|
|
1056
|
-
const response = await api.payments.unified.surcharge.get(params);
|
|
1083
|
+
const response = await api.payments.unified.surcharge.get(withMode(params));
|
|
1057
1084
|
return response.data;
|
|
1058
1085
|
} catch {
|
|
1059
1086
|
return void 0;
|
|
@@ -1061,7 +1088,7 @@ function createPaymentsActions(api, config = {}) {
|
|
|
1061
1088
|
}
|
|
1062
1089
|
async function cardInfo(params) {
|
|
1063
1090
|
try {
|
|
1064
|
-
const response = await api.payments.unified.cardInfo.get(params);
|
|
1091
|
+
const response = await api.payments.unified.cardInfo.get(withMode(params));
|
|
1065
1092
|
return response.data;
|
|
1066
1093
|
} catch {
|
|
1067
1094
|
return void 0;
|
|
@@ -1069,7 +1096,7 @@ function createPaymentsActions(api, config = {}) {
|
|
|
1069
1096
|
}
|
|
1070
1097
|
async function billingUpdate(params) {
|
|
1071
1098
|
try {
|
|
1072
|
-
const response = await api.payments.unified.billingUpdate.get(params);
|
|
1099
|
+
const response = await api.payments.unified.billingUpdate.get(withMode(params));
|
|
1073
1100
|
return response.data;
|
|
1074
1101
|
} catch {
|
|
1075
1102
|
return void 0;
|
|
@@ -1077,7 +1104,7 @@ function createPaymentsActions(api, config = {}) {
|
|
|
1077
1104
|
}
|
|
1078
1105
|
async function validatePayment(params) {
|
|
1079
1106
|
try {
|
|
1080
|
-
const response = await api.payments.unified.validate.get(params);
|
|
1107
|
+
const response = await api.payments.unified.validate.get(withMode(params));
|
|
1081
1108
|
return response.data;
|
|
1082
1109
|
} catch {
|
|
1083
1110
|
return void 0;
|
|
@@ -2159,7 +2186,10 @@ function createSiteActions(api, config = {}) {
|
|
|
2159
2186
|
() => createAvalaraActions(castApi(), { cachePrefix })
|
|
2160
2187
|
);
|
|
2161
2188
|
const payments = lazy(
|
|
2162
|
-
() => createPaymentsActions(castApi(), {
|
|
2189
|
+
() => createPaymentsActions(castApi(), {
|
|
2190
|
+
cachePrefix,
|
|
2191
|
+
...config.payments
|
|
2192
|
+
})
|
|
2163
2193
|
);
|
|
2164
2194
|
const ups = lazy(
|
|
2165
2195
|
() => createUpsActions(castApi(), { cachePrefix })
|
|
@@ -2325,6 +2355,7 @@ export {
|
|
|
2325
2355
|
isProduction,
|
|
2326
2356
|
isRedisConnected,
|
|
2327
2357
|
isStaging,
|
|
2358
|
+
paginateOffset,
|
|
2328
2359
|
safeAction,
|
|
2329
2360
|
sdkCall,
|
|
2330
2361
|
withServerCache
|