@simpleapps-com/augur-server 0.2.12 → 0.2.14
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 +45 -13
- package/dist/index.js.map +1 -1
- package/dist/{site-CZvrFj_i.d.ts → site-DibGofHe.d.ts} +24 -4
- 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,19 +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
316
|
const response = await api.items.categories.items.list(uid, {
|
|
301
|
-
...
|
|
317
|
+
...merged,
|
|
302
318
|
edgeCache
|
|
303
319
|
});
|
|
304
320
|
return response.data;
|
|
305
321
|
},
|
|
306
322
|
uid,
|
|
307
|
-
|
|
323
|
+
merged
|
|
308
324
|
);
|
|
309
325
|
}
|
|
310
326
|
async function getItemAttributes(categoryUid) {
|
|
@@ -930,8 +946,17 @@ function createCustomersActions(api, config = {}) {
|
|
|
930
946
|
function createSmartyStreetsActions(api, config = {}) {
|
|
931
947
|
const { cachePrefix: _cachePrefix = "" } = config;
|
|
932
948
|
async function validateAddress(params) {
|
|
933
|
-
|
|
934
|
-
|
|
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
|
+
}
|
|
935
960
|
}
|
|
936
961
|
return {
|
|
937
962
|
validateAddress
|
|
@@ -1033,10 +1058,13 @@ function createAvalaraActions(api, config = {}) {
|
|
|
1033
1058
|
|
|
1034
1059
|
// src/actions/payments.ts
|
|
1035
1060
|
function createPaymentsActions(api, config = {}) {
|
|
1036
|
-
const { cachePrefix: _cachePrefix = "" } = config;
|
|
1061
|
+
const { cachePrefix: _cachePrefix = "", mode = "live" } = config;
|
|
1062
|
+
function withMode(params) {
|
|
1063
|
+
return { mode, ...params };
|
|
1064
|
+
}
|
|
1037
1065
|
async function transactionSetup(params) {
|
|
1038
1066
|
try {
|
|
1039
|
-
const response = await api.payments.unified.transactionSetup.get(params);
|
|
1067
|
+
const response = await api.payments.unified.transactionSetup.get(withMode(params));
|
|
1040
1068
|
return response.data;
|
|
1041
1069
|
} catch {
|
|
1042
1070
|
return void 0;
|
|
@@ -1044,7 +1072,7 @@ function createPaymentsActions(api, config = {}) {
|
|
|
1044
1072
|
}
|
|
1045
1073
|
async function accountQuery(params) {
|
|
1046
1074
|
try {
|
|
1047
|
-
const response = await api.payments.unified.accountQuery.get(params);
|
|
1075
|
+
const response = await api.payments.unified.accountQuery.get(withMode(params));
|
|
1048
1076
|
return response.data;
|
|
1049
1077
|
} catch {
|
|
1050
1078
|
return void 0;
|
|
@@ -1052,7 +1080,7 @@ function createPaymentsActions(api, config = {}) {
|
|
|
1052
1080
|
}
|
|
1053
1081
|
async function getSurcharge(params) {
|
|
1054
1082
|
try {
|
|
1055
|
-
const response = await api.payments.unified.surcharge.get(params);
|
|
1083
|
+
const response = await api.payments.unified.surcharge.get(withMode(params));
|
|
1056
1084
|
return response.data;
|
|
1057
1085
|
} catch {
|
|
1058
1086
|
return void 0;
|
|
@@ -1060,7 +1088,7 @@ function createPaymentsActions(api, config = {}) {
|
|
|
1060
1088
|
}
|
|
1061
1089
|
async function cardInfo(params) {
|
|
1062
1090
|
try {
|
|
1063
|
-
const response = await api.payments.unified.cardInfo.get(params);
|
|
1091
|
+
const response = await api.payments.unified.cardInfo.get(withMode(params));
|
|
1064
1092
|
return response.data;
|
|
1065
1093
|
} catch {
|
|
1066
1094
|
return void 0;
|
|
@@ -1068,7 +1096,7 @@ function createPaymentsActions(api, config = {}) {
|
|
|
1068
1096
|
}
|
|
1069
1097
|
async function billingUpdate(params) {
|
|
1070
1098
|
try {
|
|
1071
|
-
const response = await api.payments.unified.billingUpdate.get(params);
|
|
1099
|
+
const response = await api.payments.unified.billingUpdate.get(withMode(params));
|
|
1072
1100
|
return response.data;
|
|
1073
1101
|
} catch {
|
|
1074
1102
|
return void 0;
|
|
@@ -1076,7 +1104,7 @@ function createPaymentsActions(api, config = {}) {
|
|
|
1076
1104
|
}
|
|
1077
1105
|
async function validatePayment(params) {
|
|
1078
1106
|
try {
|
|
1079
|
-
const response = await api.payments.unified.validate.get(params);
|
|
1107
|
+
const response = await api.payments.unified.validate.get(withMode(params));
|
|
1080
1108
|
return response.data;
|
|
1081
1109
|
} catch {
|
|
1082
1110
|
return void 0;
|
|
@@ -2158,7 +2186,10 @@ function createSiteActions(api, config = {}) {
|
|
|
2158
2186
|
() => createAvalaraActions(castApi(), { cachePrefix })
|
|
2159
2187
|
);
|
|
2160
2188
|
const payments = lazy(
|
|
2161
|
-
() => createPaymentsActions(castApi(), {
|
|
2189
|
+
() => createPaymentsActions(castApi(), {
|
|
2190
|
+
cachePrefix,
|
|
2191
|
+
...config.payments
|
|
2192
|
+
})
|
|
2162
2193
|
);
|
|
2163
2194
|
const ups = lazy(
|
|
2164
2195
|
() => createUpsActions(castApi(), { cachePrefix })
|
|
@@ -2324,6 +2355,7 @@ export {
|
|
|
2324
2355
|
isProduction,
|
|
2325
2356
|
isRedisConnected,
|
|
2326
2357
|
isStaging,
|
|
2358
|
+
paginateOffset,
|
|
2327
2359
|
safeAction,
|
|
2328
2360
|
sdkCall,
|
|
2329
2361
|
withServerCache
|