@simpleapps-com/augur-server 1.0.20 → 2.0.0
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/actions.d.ts +1 -1
- package/dist/actions.js +1 -1
- package/dist/{chunk-C3V6CBNQ.js → chunk-GYZT5Q2K.js} +2 -2
- package/dist/chunk-GYZT5Q2K.js.map +1 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/{sdk-call-CaW_esvl.d.ts → sdk-call-CPDSzeu0.d.ts} +10 -10
- package/package.json +5 -5
- package/dist/chunk-C3V6CBNQ.js.map +0 -1
package/dist/actions.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { S as SafeActionResult } from './sdk-call-
|
|
1
|
+
import { S as SafeActionResult } from './sdk-call-CPDSzeu0.js';
|
|
2
2
|
import { C as CustomerListResult, G as GetItemCategoryOptions, m as ShippingAddress, N as NormalizedUserProfile, j as SearchPage, A as AddressValidationResult } from './smarty-streets-wNE71Nip.js';
|
|
3
3
|
import { TAccountQuery, TInvMastDoc, TPriceData, TStockData, TBillingUpdate, TCardInfo, TCartLookUp, TCheckoutResult, CustomerDocument, TRelatedProduct, TCartLine, TCategoryItemsResult, TInvMast, TItemAccessory, TAttribute, TCategory, TWebDesc, TJoomlaContent, TMenu, TShippingMethod, TSurcharge, TTaxItem, TTax, TProductItem, TTransactionSetup, TPaymentValidation, TPasswordVerification } from '@simpleapps-com/augur-utils';
|
|
4
4
|
import '@simpleapps-com/augur-api';
|
package/dist/actions.js
CHANGED
|
@@ -5,7 +5,7 @@ async function sdkCall(method, ...args) {
|
|
|
5
5
|
async function safeAction(fn, onError) {
|
|
6
6
|
try {
|
|
7
7
|
const data = await fn();
|
|
8
|
-
return { ok: true, data
|
|
8
|
+
return { ok: true, data };
|
|
9
9
|
} catch (e) {
|
|
10
10
|
const error = e instanceof Error ? e : new Error(String(e));
|
|
11
11
|
if (onError) onError(error);
|
|
@@ -26,4 +26,4 @@ export {
|
|
|
26
26
|
unwrap,
|
|
27
27
|
unwrapOr
|
|
28
28
|
};
|
|
29
|
-
//# sourceMappingURL=chunk-
|
|
29
|
+
//# sourceMappingURL=chunk-GYZT5Q2K.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/sdk-call.ts"],"sourcesContent":["// Re-export EdgeCacheValue and ActionResult from augur-core (single source of truth)\nexport type { EdgeCacheValue, ActionResult } from \"@simpleapps-com/augur-core\";\n\n/**\n * Calls an Augur SDK method, forwarding all arguments with full type safety.\n *\n * With augur-api >= 0.9.6, SDK methods properly declare their `CacheParams`\n * option (including `edgeCache`), so this wrapper preserves both parameter\n * and return-type inference end-to-end.\n *\n * @example\n * ```ts\n * const result = await sdkCall(\n * augurServices.items.invMast.get,\n * invMastUid,\n * { edgeCache: 4 },\n * );\n * ```\n */\nexport async function sdkCall<TArgs extends unknown[], TResult>(\n method: (...args: TArgs) => Promise<TResult>,\n ...args: TArgs\n): Promise<TResult> {\n return method(...args);\n}\n\n/**\n * @deprecated No longer needed — `SafeActionResult<T>` uses `T` directly.\n * Kept as a passthrough alias for backwards compatibility.\n */\nexport type SafeData<T> = T;\n\n/** Result type for `safeAction`. */\nexport type SafeActionResult<T> =\n | { ok: true; data: T }\n | { ok: false; error: string };\n\n/**\n * Wraps an async function call with error handling, returning a\n * `SafeActionResult<T>` instead of throwing.\n *\n * Use this to eliminate try/catch boilerplate in server actions.\n * Reads that go through React Query should NOT use this — let errors\n * propagate so React Query can handle retries and error state.\n *\n * @param fn — The async function to execute\n * @param onError — Optional callback for logging/reporting\n *\n * @example\n * ```ts\n * const result = await safeAction(\n * () => actions.commerce.addToCart(cartId, items),\n * );\n * if (result.ok) {\n * // result.data is the response data (undefined for void actions)\n * } else {\n * // result.error is the error message\n * }\n * ```\n */\nexport async function safeAction<T>(\n fn: () => Promise<T>,\n onError?: (error: Error) => void,\n): Promise<SafeActionResult<T>> {\n try {\n const data = await fn();\n return { ok: true, data: data as T };\n } catch (e) {\n const error = e instanceof Error ? e : new Error(String(e));\n if (onError) onError(error);\n return { ok: false, error: error.message };\n }\n}\n\n/**\n * Extracts the data from a `SafeActionResult`, throwing on error.\n *\n * Ideal for React Query `queryFn` where errors should propagate\n * to the error boundary.\n *\n * @example\n * ```ts\n * const cart = unwrap(await getCartLines(cartId));\n * ```\n */\nexport function unwrap<T>(result: SafeActionResult<T>): T {\n if (!result.ok) throw new Error(result.error || \"Action failed\");\n return result.data;\n}\n\n/**\n * Extracts the data from a `SafeActionResult`, returning `null` on error.\n *\n * For direct calls that prefer `null` over thrown errors.\n *\n * @example\n * ```ts\n * const cart = unwrapOr(await getCartLines(cartId));\n * if (!cart) { /* handle missing data *\\/ }\n * ```\n */\nexport function unwrapOr<T>(result: SafeActionResult<T>): T | null {\n return result.ok ? result.data ?? null : null;\n}\n"],"mappings":";AAmBA,eAAsB,QACpB,WACG,MACe;AAClB,SAAO,OAAO,GAAG,IAAI;AACvB;AAoCA,eAAsB,WACpB,IACA,SAC8B;AAC9B,MAAI;AACF,UAAM,OAAO,MAAM,GAAG;AACtB,WAAO,EAAE,IAAI,MAAM,KAAgB;AAAA,EACrC,SAAS,GAAG;AACV,UAAM,QAAQ,aAAa,QAAQ,IAAI,IAAI,MAAM,OAAO,CAAC,CAAC;AAC1D,QAAI,QAAS,SAAQ,KAAK;AAC1B,WAAO,EAAE,IAAI,OAAO,OAAO,MAAM,QAAQ;AAAA,EAC3C;AACF;AAaO,SAAS,OAAU,QAAgC;AACxD,MAAI,CAAC,OAAO,GAAI,OAAM,IAAI,MAAM,OAAO,SAAS,eAAe;AAC/D,SAAO,OAAO;AAChB;AAaO,SAAS,SAAY,QAAuC;AACjE,SAAO,OAAO,KAAK,OAAO,QAAQ,OAAO;AAC3C;","names":[]}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { S as SafeActionResult, a as SafeData, s as safeAction, b as sdkCall, u as unwrap, c as unwrapOr } from './sdk-call-
|
|
1
|
+
export { S as SafeActionResult, a as SafeData, s as safeAction, b as sdkCall, u as unwrap, c as unwrapOr } from './sdk-call-CPDSzeu0.js';
|
|
2
2
|
import { QueryClient } from '@tanstack/react-query';
|
|
3
3
|
export { QueryOptionsConfig, createQueryOptions, createSuspenseQueryOptions } from './query.js';
|
|
4
4
|
export { A as AgrInfoActions, a as AgrInfoActionsConfig, b as AgrInfoApiClient, c as AgrSiteActions, d as AgrSiteActionsConfig, e as AgrSiteApiClient, f as AgrWorkActions, g as AgrWorkActionsConfig, h as AgrWorkApiClient, i as AvalaraActions, j as AvalaraActionsConfig, k as AvalaraApiClient, B as Basecamp2Actions, l as Basecamp2ActionsConfig, m as Basecamp2ApiClient, n as BrandFolderActions, o as BrandFolderActionsConfig, p as BrandFolderApiClient, C as CommerceActions, q as CommerceActionsConfig, r as CommerceApiClient, G as GregorovichActions, s as GregorovichActionsConfig, t as GregorovichApiClient, L as LegacyActions, u as LegacyActionsConfig, v as LegacyApiClient, w as LogisticsActions, x as LogisticsActionsConfig, y as LogisticsApiClient, N as NexusActions, z as NexusActionsConfig, D as NexusApiClient, O as OrderActions, E as OrderActionsConfig, F as OrderApiClient, P as P21ApisActions, H as P21ApisActionsConfig, I as P21ApisApiClient, J as P21CoreActions, K as P21CoreActionsConfig, M as P21CoreApiClient, Q as P21PimActions, R as P21PimActionsConfig, S as P21PimApiClient, T as P21SismActions, U as P21SismActionsConfig, V as P21SismApiClient, W as PaymentsActions, X as PaymentsActionsConfig, Y as PaymentsApiClient, Z as PricingActions, _ as PricingActionsConfig, $ as PricingApiClient, a0 as SiteActions, a1 as SiteActionsConfig, a2 as SlackActions, a3 as SlackActionsConfig, a4 as SlackApiClient, a5 as UpsActions, a6 as UpsActionsConfig, a7 as UpsApiClient, a8 as VmiActions, a9 as VmiActionsConfig, aa as VmiApiClient, ab as createAgrInfoActions, ac as createAgrSiteActions, ad as createAgrWorkActions, ae as createAvalaraActions, af as createBasecamp2Actions, ag as createBrandFolderActions, ah as createCommerceActions, ai as createGregorovichActions, aj as createLegacyActions, ak as createLogisticsActions, al as createNexusActions, am as createOrderActions, an as createP21ApisActions, ao as createP21CoreActions, ap as createP21PimActions, aq as createP21SismActions, ar as createPaymentsActions, as as createPricingActions, at as createSiteActions, au as createSlackActions, av as createUpsActions, aw as createVmiActions } from './site-B_2M8bT-.js';
|
package/dist/index.js
CHANGED
|
@@ -15,12 +15,15 @@
|
|
|
15
15
|
* ```
|
|
16
16
|
*/
|
|
17
17
|
declare function sdkCall<TArgs extends unknown[], TResult>(method: (...args: TArgs) => Promise<TResult>, ...args: TArgs): Promise<TResult>;
|
|
18
|
-
/**
|
|
19
|
-
|
|
20
|
-
|
|
18
|
+
/**
|
|
19
|
+
* @deprecated No longer needed — `SafeActionResult<T>` uses `T` directly.
|
|
20
|
+
* Kept as a passthrough alias for backwards compatibility.
|
|
21
|
+
*/
|
|
22
|
+
type SafeData<T> = T;
|
|
23
|
+
/** Result type for `safeAction`. */
|
|
21
24
|
type SafeActionResult<T> = {
|
|
22
25
|
ok: true;
|
|
23
|
-
data:
|
|
26
|
+
data: T;
|
|
24
27
|
} | {
|
|
25
28
|
ok: false;
|
|
26
29
|
error: string;
|
|
@@ -33,9 +36,6 @@ type SafeActionResult<T> = {
|
|
|
33
36
|
* Reads that go through React Query should NOT use this — let errors
|
|
34
37
|
* propagate so React Query can handle retries and error state.
|
|
35
38
|
*
|
|
36
|
-
* When the wrapped function returns `void`, `data` is set to `true`
|
|
37
|
-
* so that `result.data` is never `undefined` on a successful call.
|
|
38
|
-
*
|
|
39
39
|
* @param fn — The async function to execute
|
|
40
40
|
* @param onError — Optional callback for logging/reporting
|
|
41
41
|
*
|
|
@@ -45,7 +45,7 @@ type SafeActionResult<T> = {
|
|
|
45
45
|
* () => actions.commerce.addToCart(cartId, items),
|
|
46
46
|
* );
|
|
47
47
|
* if (result.ok) {
|
|
48
|
-
* // result.data is
|
|
48
|
+
* // result.data is the response data (undefined for void actions)
|
|
49
49
|
* } else {
|
|
50
50
|
* // result.error is the error message
|
|
51
51
|
* }
|
|
@@ -63,7 +63,7 @@ declare function safeAction<T>(fn: () => Promise<T>, onError?: (error: Error) =>
|
|
|
63
63
|
* const cart = unwrap(await getCartLines(cartId));
|
|
64
64
|
* ```
|
|
65
65
|
*/
|
|
66
|
-
declare function unwrap<T>(result: SafeActionResult<T>):
|
|
66
|
+
declare function unwrap<T>(result: SafeActionResult<T>): T;
|
|
67
67
|
/**
|
|
68
68
|
* Extracts the data from a `SafeActionResult`, returning `null` on error.
|
|
69
69
|
*
|
|
@@ -75,6 +75,6 @@ declare function unwrap<T>(result: SafeActionResult<T>): SafeData<T>;
|
|
|
75
75
|
* if (!cart) { /* handle missing data *\/ }
|
|
76
76
|
* ```
|
|
77
77
|
*/
|
|
78
|
-
declare function unwrapOr<T>(result: SafeActionResult<T>):
|
|
78
|
+
declare function unwrapOr<T>(result: SafeActionResult<T>): T | null;
|
|
79
79
|
|
|
80
80
|
export { type SafeActionResult as S, type SafeData as a, sdkCall as b, unwrapOr as c, safeAction as s, unwrap as u };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@simpleapps-com/augur-server",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0",
|
|
4
4
|
"description": "Server-side utilities for Augur ecommerce sites (Redis caching, SDK helpers, auth)",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -49,8 +49,8 @@
|
|
|
49
49
|
],
|
|
50
50
|
"dependencies": {
|
|
51
51
|
"valibot": "^1.0.0",
|
|
52
|
-
"@simpleapps-com/augur-core": "
|
|
53
|
-
"@simpleapps-com/augur-utils": "
|
|
52
|
+
"@simpleapps-com/augur-core": "2.0.0",
|
|
53
|
+
"@simpleapps-com/augur-utils": "2.0.0"
|
|
54
54
|
},
|
|
55
55
|
"peerDependencies": {
|
|
56
56
|
"@simpleapps-com/augur-api": "^2026.3.1",
|
|
@@ -59,7 +59,7 @@
|
|
|
59
59
|
"next": "^16.1.6",
|
|
60
60
|
"next-auth": ">=5.0.0-beta.30",
|
|
61
61
|
"react": "^19.0.0",
|
|
62
|
-
"@simpleapps-com/augur-hooks": "
|
|
62
|
+
"@simpleapps-com/augur-hooks": "2.0.0"
|
|
63
63
|
},
|
|
64
64
|
"peerDependenciesMeta": {
|
|
65
65
|
"ioredis": {
|
|
@@ -82,7 +82,7 @@
|
|
|
82
82
|
"tsup": "^8.5.0",
|
|
83
83
|
"vitest": "^3.2.0",
|
|
84
84
|
"@augur-packages/tsconfig": "0.0.0",
|
|
85
|
-
"@simpleapps-com/augur-hooks": "
|
|
85
|
+
"@simpleapps-com/augur-hooks": "2.0.0"
|
|
86
86
|
},
|
|
87
87
|
"scripts": {
|
|
88
88
|
"build": "tsup",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/sdk-call.ts"],"sourcesContent":["// Re-export EdgeCacheValue and ActionResult from augur-core (single source of truth)\nexport type { EdgeCacheValue, ActionResult } from \"@simpleapps-com/augur-core\";\n\n/**\n * Calls an Augur SDK method, forwarding all arguments with full type safety.\n *\n * With augur-api >= 0.9.6, SDK methods properly declare their `CacheParams`\n * option (including `edgeCache`), so this wrapper preserves both parameter\n * and return-type inference end-to-end.\n *\n * @example\n * ```ts\n * const result = await sdkCall(\n * augurServices.items.invMast.get,\n * invMastUid,\n * { edgeCache: 4 },\n * );\n * ```\n */\nexport async function sdkCall<TArgs extends unknown[], TResult>(\n method: (...args: TArgs) => Promise<TResult>,\n ...args: TArgs\n): Promise<TResult> {\n return method(...args);\n}\n\n/** Maps void-returning actions to `true` so `data` is never `undefined` on success. */\nexport type SafeData<T> = T extends void ? true : T;\n\n/** Result type for `safeAction` — void-returning actions get `data: true`. */\nexport type SafeActionResult<T> =\n | { ok: true; data: SafeData<T> }\n | { ok: false; error: string };\n\n/**\n * Wraps an async function call with error handling, returning a\n * `SafeActionResult<T>` instead of throwing.\n *\n * Use this to eliminate try/catch boilerplate in server actions.\n * Reads that go through React Query should NOT use this — let errors\n * propagate so React Query can handle retries and error state.\n *\n * When the wrapped function returns `void`, `data` is set to `true`\n * so that `result.data` is never `undefined` on a successful call.\n *\n * @param fn — The async function to execute\n * @param onError — Optional callback for logging/reporting\n *\n * @example\n * ```ts\n * const result = await safeAction(\n * () => actions.commerce.addToCart(cartId, items),\n * );\n * if (result.ok) {\n * // result.data is `true` for void actions, or the response data\n * } else {\n * // result.error is the error message\n * }\n * ```\n */\nexport async function safeAction<T>(\n fn: () => Promise<T>,\n onError?: (error: Error) => void,\n): Promise<SafeActionResult<T>> {\n try {\n const data = await fn();\n return { ok: true, data: (data ?? true) as SafeData<T> };\n } catch (e) {\n const error = e instanceof Error ? e : new Error(String(e));\n if (onError) onError(error);\n return { ok: false, error: error.message };\n }\n}\n\n/**\n * Extracts the data from a `SafeActionResult`, throwing on error.\n *\n * Ideal for React Query `queryFn` where errors should propagate\n * to the error boundary.\n *\n * @example\n * ```ts\n * const cart = unwrap(await getCartLines(cartId));\n * ```\n */\nexport function unwrap<T>(result: SafeActionResult<T>): SafeData<T> {\n if (!result.ok) throw new Error(result.error || \"Action failed\");\n return result.data;\n}\n\n/**\n * Extracts the data from a `SafeActionResult`, returning `null` on error.\n *\n * For direct calls that prefer `null` over thrown errors.\n *\n * @example\n * ```ts\n * const cart = unwrapOr(await getCartLines(cartId));\n * if (!cart) { /* handle missing data *\\/ }\n * ```\n */\nexport function unwrapOr<T>(result: SafeActionResult<T>): SafeData<T> | null {\n return result.ok ? result.data ?? null : null;\n}\n"],"mappings":";AAmBA,eAAsB,QACpB,WACG,MACe;AAClB,SAAO,OAAO,GAAG,IAAI;AACvB;AAoCA,eAAsB,WACpB,IACA,SAC8B;AAC9B,MAAI;AACF,UAAM,OAAO,MAAM,GAAG;AACtB,WAAO,EAAE,IAAI,MAAM,MAAO,QAAQ,KAAqB;AAAA,EACzD,SAAS,GAAG;AACV,UAAM,QAAQ,aAAa,QAAQ,IAAI,IAAI,MAAM,OAAO,CAAC,CAAC;AAC1D,QAAI,QAAS,SAAQ,KAAK;AAC1B,WAAO,EAAE,IAAI,OAAO,OAAO,MAAM,QAAQ;AAAA,EAC3C;AACF;AAaO,SAAS,OAAU,QAA0C;AAClE,MAAI,CAAC,OAAO,GAAI,OAAM,IAAI,MAAM,OAAO,SAAS,eAAe;AAC/D,SAAO,OAAO;AAChB;AAaO,SAAS,SAAY,QAAiD;AAC3E,SAAO,OAAO,KAAK,OAAO,QAAQ,OAAO;AAC3C;","names":[]}
|