@simpleapps-com/augur-server 1.0.20 → 2.0.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/dist/actions.d.ts +13 -9
- package/dist/actions.js +17 -7
- package/dist/actions.js.map +1 -1
- package/dist/{chunk-C3V6CBNQ.js → chunk-GYZT5Q2K.js} +2 -2
- package/dist/chunk-GYZT5Q2K.js.map +1 -0
- package/dist/{chunk-DF3HMPTP.js → chunk-M4BTYIE4.js} +118 -8
- package/dist/chunk-M4BTYIE4.js.map +1 -0
- package/dist/index.d.ts +5 -37
- package/dist/index.js +3 -13
- package/dist/index.js.map +1 -1
- package/dist/{sdk-call-CaW_esvl.d.ts → sdk-call-CPDSzeu0.d.ts} +10 -10
- package/dist/{server-site-registry-DXum3EsN.d.ts → server-site-registry-DpHfqqw5.d.ts} +1 -1
- package/dist/{site-B_2M8bT-.d.ts → site-HFRLBNg5.d.ts} +1 -1
- package/dist/site.d.ts +2 -2
- package/dist/site.js +1 -1
- package/dist/{smarty-streets-wNE71Nip.d.ts → smarty-streets-BNHJ_f7T.d.ts} +58 -10
- package/dist/testing.d.ts +3 -3
- package/dist/testing.js +1 -0
- package/dist/testing.js.map +1 -1
- package/package.json +5 -5
- package/dist/chunk-C3V6CBNQ.js.map +0 -1
- package/dist/chunk-DF3HMPTP.js.map +0 -1
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/
|
|
1
|
+
{"version":3,"sources":["../src/actions/wishlists.ts","../src/actions/favorites.ts"],"sourcesContent":["import type { AugurAPI } from \"@simpleapps-com/augur-api\";\nimport type { EdgeCacheValue } from \"../sdk-call\";\nimport { withServerCache } from \"../cache/with-cache\";\n\n/** Derived from augur-api SDK — keeps types in sync automatically. */\nexport type WishlistsApiClient = Pick<AugurAPI, \"items\">;\n\nexport interface WishlistActionsConfig {\n /** Cache key prefix (e.g. \"ampro:\"). Default: \"\". */\n cachePrefix?: string;\n /** CDN edge cache value passed to SDK. Default: 1 (hour). */\n edgeCache?: EdgeCacheValue;\n /** Redis TTL in seconds. Default: 3600 (1 hour). */\n redisTtl?: number;\n}\n\nexport interface WishlistActions {\n getWishlists: (userId: number) => Promise<unknown[]>;\n createWishlist: (\n userId: number,\n data: { name: string; description?: string },\n ) => Promise<unknown>;\n getWishlistDetail: (\n userId: number,\n wishlistId: number,\n ) => Promise<unknown>;\n deleteWishlist: (userId: number, wishlistId: number) => Promise<void>;\n addWishlistItems: (\n userId: number,\n wishlistId: number,\n items: { invMastUid: number }[],\n ) => Promise<unknown>;\n removeWishlistItem: (\n userId: number,\n wishlistId: number,\n lineId: number,\n ) => Promise<void>;\n}\n\n/** @deprecated Use `createSiteActions()` instead. This factory will be removed in the next major version. */\nexport function createWishlistActions(\n api: WishlistsApiClient,\n config: WishlistActionsConfig = {},\n): WishlistActions {\n const { cachePrefix = \"\", edgeCache = 1, redisTtl = 3600 } = config;\n\n async function getWishlists(userId: number): Promise<unknown[]> {\n return withServerCache(\n cachePrefix,\n redisTtl,\n \"items.itemWishlist.list\",\n async () => {\n const response = await api.items.itemWishlist.list(userId, {\n edgeCache,\n });\n return response.data;\n },\n userId,\n );\n }\n\n async function createWishlist(\n userId: number,\n data: { name: string; description?: string },\n ): Promise<unknown> {\n const response = await api.items.itemWishlist.create(userId, data);\n return response.data;\n }\n\n async function getWishlistDetail(\n userId: number,\n wishlistId: number,\n ): Promise<unknown> {\n return withServerCache(\n cachePrefix,\n redisTtl,\n \"items.itemWishlist.hdr.get\",\n async () => {\n const response = await api.items.itemWishlist.hdr.get(\n userId,\n wishlistId,\n { edgeCache },\n );\n return response.data;\n },\n userId,\n wishlistId,\n );\n }\n\n async function deleteWishlist(\n userId: number,\n wishlistId: number,\n ): Promise<void> {\n await api.items.itemWishlist.hdr.delete(userId, wishlistId);\n }\n\n async function addWishlistItems(\n userId: number,\n wishlistId: number,\n items: { invMastUid: number }[],\n ): Promise<unknown> {\n const response = await api.items.itemWishlist.hdr.create(\n userId,\n wishlistId,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n items as any,\n );\n return response.data;\n }\n\n async function removeWishlistItem(\n userId: number,\n wishlistId: number,\n lineId: number,\n ): Promise<void> {\n await api.items.itemWishlist.hdr.line.delete(userId, wishlistId, lineId);\n }\n\n return {\n getWishlists,\n createWishlist,\n getWishlistDetail,\n deleteWishlist,\n addWishlistItems,\n removeWishlistItem,\n };\n}\n","import type { AugurAPI } from \"@simpleapps-com/augur-api\";\nimport type { EdgeCacheValue } from \"../sdk-call\";\nimport { withServerCache } from \"../cache/with-cache\";\n\n/** Derived from augur-api SDK — keeps types in sync automatically. */\nexport type FavoritesApiClient = Pick<AugurAPI, \"items\">;\n\nexport interface FavoritesActionsConfig {\n /** Cache key prefix (e.g. \"ampro:\"). Default: \"\". */\n cachePrefix?: string;\n /** CDN edge cache value passed to SDK. Default: 1 (hour). */\n edgeCache?: EdgeCacheValue;\n /** Redis TTL in seconds. Default: 3600 (1 hour). */\n redisTtl?: number;\n}\n\nexport interface FavoritesActions {\n getFavorites: (userId: number) => Promise<unknown[]>;\n addFavorite: (userId: number, invMastUid: number) => Promise<unknown>;\n removeFavorite: (userId: number, invMastUid: number) => Promise<void>;\n}\n\n/** @deprecated Use `createSiteActions()` instead. This factory will be removed in the next major version. */\nexport function createFavoritesActions(\n api: FavoritesApiClient,\n config: FavoritesActionsConfig = {},\n): FavoritesActions {\n const { cachePrefix = \"\", edgeCache = 1, redisTtl = 3600 } = config;\n\n async function getFavorites(userId: number): Promise<unknown[]> {\n return withServerCache(\n cachePrefix,\n redisTtl,\n \"items.itemFavorites.list\",\n async () => {\n const response = await api.items.itemFavorites.list(userId, {\n edgeCache,\n });\n return response.data;\n },\n userId,\n );\n }\n\n async function addFavorite(\n userId: number,\n invMastUid: number,\n ): Promise<unknown> {\n const response = await api.items.itemFavorites.create(userId, {\n invMastUid,\n });\n return response.data;\n }\n\n async function removeFavorite(\n userId: number,\n invMastUid: number,\n ): Promise<void> {\n await api.items.itemFavorites.delete(userId, invMastUid);\n }\n\n return { getFavorites, addFavorite, removeFavorite };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAwCO,SAAS,sBACd,KACA,SAAgC,CAAC,GAChB;AACjB,QAAM,EAAE,cAAc,IAAI,YAAY,GAAG,WAAW,KAAK,IAAI;AAE7D,iBAAe,aAAa,QAAoC;AAC9D,WAAO;AAAA,MACL;AAAA,MACA;AAAA,MACA;AAAA,MACA,YAAY;AACV,cAAM,WAAW,MAAM,IAAI,MAAM,aAAa,KAAK,QAAQ;AAAA,UACzD;AAAA,QACF,CAAC;AACD,eAAO,SAAS;AAAA,MAClB;AAAA,MACA;AAAA,IACF;AAAA,EACF;AAEA,iBAAe,eACb,QACA,MACkB;AAClB,UAAM,WAAW,MAAM,IAAI,MAAM,aAAa,OAAO,QAAQ,IAAI;AACjE,WAAO,SAAS;AAAA,EAClB;AAEA,iBAAe,kBACb,QACA,YACkB;AAClB,WAAO;AAAA,MACL;AAAA,MACA;AAAA,MACA;AAAA,MACA,YAAY;AACV,cAAM,WAAW,MAAM,IAAI,MAAM,aAAa,IAAI;AAAA,UAChD;AAAA,UACA;AAAA,UACA,EAAE,UAAU;AAAA,QACd;AACA,eAAO,SAAS;AAAA,MAClB;AAAA,MACA;AAAA,MACA;AAAA,IACF;AAAA,EACF;AAEA,iBAAe,eACb,QACA,YACe;AACf,UAAM,IAAI,MAAM,aAAa,IAAI,OAAO,QAAQ,UAAU;AAAA,EAC5D;AAEA,iBAAe,iBACb,QACA,YACA,OACkB;AAClB,UAAM,WAAW,MAAM,IAAI,MAAM,aAAa,IAAI;AAAA,MAChD;AAAA,MACA;AAAA;AAAA,MAEA;AAAA,IACF;AACA,WAAO,SAAS;AAAA,EAClB;AAEA,iBAAe,mBACb,QACA,YACA,QACe;AACf,UAAM,IAAI,MAAM,aAAa,IAAI,KAAK,OAAO,QAAQ,YAAY,MAAM;AAAA,EACzE;AAEA,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACF;;;ACxGO,SAAS,uBACd,KACA,SAAiC,CAAC,GAChB;AAClB,QAAM,EAAE,cAAc,IAAI,YAAY,GAAG,WAAW,KAAK,IAAI;AAE7D,iBAAe,aAAa,QAAoC;AAC9D,WAAO;AAAA,MACL;AAAA,MACA;AAAA,MACA;AAAA,MACA,YAAY;AACV,cAAM,WAAW,MAAM,IAAI,MAAM,cAAc,KAAK,QAAQ;AAAA,UAC1D;AAAA,QACF,CAAC;AACD,eAAO,SAAS;AAAA,MAClB;AAAA,MACA;AAAA,IACF;AAAA,EACF;AAEA,iBAAe,YACb,QACA,YACkB;AAClB,UAAM,WAAW,MAAM,IAAI,MAAM,cAAc,OAAO,QAAQ;AAAA,MAC5D;AAAA,IACF,CAAC;AACD,WAAO,SAAS;AAAA,EAClB;AAEA,iBAAe,eACb,QACA,YACe;AACf,UAAM,IAAI,MAAM,cAAc,OAAO,QAAQ,UAAU;AAAA,EACzD;AAEA,SAAO,EAAE,cAAc,aAAa,eAAe;AACrD;","names":[]}
|
|
@@ -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 };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { EdgeCacheValue } from '@simpleapps-com/augur-core';
|
|
2
2
|
import { AugurAPI } from '@simpleapps-com/augur-api';
|
|
3
3
|
import { TPriceData, TTaxItem, TTax, TCartLookUp, TCartLine, TRelatedProduct, TCheckoutResult, TWebDesc, TTransactionSetup, TAccountQuery, TSurcharge, TCardInfo, TBillingUpdate, TPaymentValidation, TShippingMethod } from '@simpleapps-com/augur-utils';
|
|
4
|
-
import { I as ItemActions, S as SearchActions, k as ShippingActions, J as JoomlaActions, a as CustomersActions, o as SmartyStreetsActions, m as ShippingAddress } from './smarty-streets-
|
|
4
|
+
import { I as ItemActions, S as SearchActions, k as ShippingActions, J as JoomlaActions, a as CustomersActions, o as SmartyStreetsActions, m as ShippingAddress } from './smarty-streets-BNHJ_f7T.js';
|
|
5
5
|
|
|
6
6
|
/** Derived from augur-api SDK — keeps types in sync automatically. */
|
|
7
7
|
type PricingApiClient = Pick<AugurAPI, "pricing">;
|
package/dist/site.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { a0 as SiteActions, a1 as SiteActionsConfig } from './site-
|
|
1
|
+
import { a0 as SiteActions, a1 as SiteActionsConfig } from './site-HFRLBNg5.js';
|
|
2
2
|
import { AugurAuthCallbacks } from './auth.js';
|
|
3
3
|
import { NextAuthConfig } from 'next-auth';
|
|
4
4
|
import '@simpleapps-com/augur-core';
|
|
5
5
|
import '@simpleapps-com/augur-api';
|
|
6
6
|
import '@simpleapps-com/augur-utils';
|
|
7
|
-
import './smarty-streets-
|
|
7
|
+
import './smarty-streets-BNHJ_f7T.js';
|
|
8
8
|
|
|
9
9
|
/** Auth options forwarded to NextAuth when creating a server site. */
|
|
10
10
|
interface ServerSiteAuthConfig {
|
package/dist/site.js
CHANGED
|
@@ -1,6 +1,38 @@
|
|
|
1
1
|
import { AugurAPI } from '@simpleapps-com/augur-api';
|
|
2
2
|
import { EdgeCacheValue } from '@simpleapps-com/augur-core';
|
|
3
|
-
import { TCategory, TCategoryItemsResult, TAttribute, TInvMast, TInvMastDoc, TStockData, TItemAccessory,
|
|
3
|
+
import { TCategory, TCategoryItemsResult, TItemsFilters, TProductItem, TAttribute, TInvMast, TInvMastDoc, TStockData, TItemAccessory, TShippingMethod, TJoomlaContent, TMenu, TPasswordVerification, CustomerDocument, TSmartyStreets } from '@simpleapps-com/augur-utils';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Standardized paginated response shape.
|
|
7
|
+
* Works with any factory method — compose with `paginateOffset()`.
|
|
8
|
+
*/
|
|
9
|
+
interface PaginatedResult<T> {
|
|
10
|
+
data: T[];
|
|
11
|
+
total?: number;
|
|
12
|
+
nextCursor?: number;
|
|
13
|
+
hasMore: boolean;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Wraps a list of items with offset-based pagination metadata.
|
|
17
|
+
*
|
|
18
|
+
* Use this to standardize pagination responses from any factory method.
|
|
19
|
+
* Compatible with React Query's infinite query pattern (`getNextPageParam`).
|
|
20
|
+
*
|
|
21
|
+
* @param items - The items returned from the current page
|
|
22
|
+
* @param pageParam - The current page number (0-based)
|
|
23
|
+
* @param limit - The page size
|
|
24
|
+
* @param total - Optional total count of items (from API response)
|
|
25
|
+
*
|
|
26
|
+
* @example
|
|
27
|
+
* ```ts
|
|
28
|
+
* const result = await actions.items.getCategoryItems(uid, {
|
|
29
|
+
* ...filters, offset: page * 24, limit: 24,
|
|
30
|
+
* });
|
|
31
|
+
* return paginateOffset(result.items, page, 24, result.total);
|
|
32
|
+
* // { data: [...], total: 150, nextCursor: 1, hasMore: true }
|
|
33
|
+
* ```
|
|
34
|
+
*/
|
|
35
|
+
declare function paginateOffset<T>(items: T[], pageParam: number, limit: number, total?: number): PaginatedResult<T>;
|
|
4
36
|
|
|
5
37
|
/** Derived from augur-api SDK — keeps types in sync automatically. */
|
|
6
38
|
type ItemsApiClient = Pick<AugurAPI, "items">;
|
|
@@ -35,14 +67,21 @@ interface GetItemCategoryOptions {
|
|
|
35
67
|
interface ItemActions {
|
|
36
68
|
itemCategoryLookup: (path: string) => Promise<unknown>;
|
|
37
69
|
getItemCategory: (uid: number, options?: GetItemCategoryOptions) => Promise<TCategory>;
|
|
38
|
-
getCategoryItems:
|
|
70
|
+
getCategoryItems: {
|
|
71
|
+
(uid: number, filters: Record<string, unknown>): Promise<TCategoryItemsResult>;
|
|
72
|
+
(uid: number, itemsFilters: TItemsFilters): Promise<TCategoryItemsResult>;
|
|
73
|
+
};
|
|
74
|
+
getCategoryItemsInfinite: (uid: number, itemsFilters?: TItemsFilters, pageParam?: number) => Promise<PaginatedResult<TProductItem>>;
|
|
39
75
|
getItemAttributes: (categoryUid: number) => Promise<TAttribute[]>;
|
|
40
76
|
getInvMast: (uid: number) => Promise<TInvMast>;
|
|
41
|
-
getInvMastDoc:
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
77
|
+
getInvMastDoc: {
|
|
78
|
+
(params: {
|
|
79
|
+
invMastUid?: number;
|
|
80
|
+
itemId?: string;
|
|
81
|
+
includePricing?: "Y" | "N";
|
|
82
|
+
}): Promise<TInvMastDoc>;
|
|
83
|
+
(invMastUid: number, itemId?: string, includePricing?: "Y" | "N"): Promise<TInvMastDoc>;
|
|
84
|
+
};
|
|
46
85
|
getStock: (invMastUid: number) => Promise<TStockData[]>;
|
|
47
86
|
getStockCompanySummary: (invMastUid: number) => Promise<Record<string, number>>;
|
|
48
87
|
getItemFaqs: (invMastUid: number) => Promise<unknown[]>;
|
|
@@ -221,9 +260,18 @@ interface NormalizedUserProfile {
|
|
|
221
260
|
permissions: string[];
|
|
222
261
|
}
|
|
223
262
|
interface JoomlaActions {
|
|
224
|
-
getJoomlaContent:
|
|
263
|
+
getJoomlaContent: {
|
|
264
|
+
(articleId: number): Promise<TJoomlaContent>;
|
|
265
|
+
(articleId: number | string, options: {
|
|
266
|
+
alias: string;
|
|
267
|
+
catId?: number;
|
|
268
|
+
}): Promise<TJoomlaContent>;
|
|
269
|
+
};
|
|
225
270
|
getJoomlaContentList: (params?: Record<string, unknown>) => Promise<TJoomlaContent[]>;
|
|
226
|
-
getJoomlaMenu:
|
|
271
|
+
getJoomlaMenu: {
|
|
272
|
+
(params?: Record<string, unknown>): Promise<TMenu[]>;
|
|
273
|
+
(parentId: number, menuType: string): Promise<TMenu[]>;
|
|
274
|
+
};
|
|
227
275
|
getJoomlaMenuDoc: (menuId: number | string) => Promise<TMenu>;
|
|
228
276
|
getUserProfile: (userId: number | string) => Promise<NormalizedUserProfile>;
|
|
229
277
|
verifyPassword: (username: string, password: string) => Promise<TPasswordVerification>;
|
|
@@ -348,4 +396,4 @@ interface SmartyStreetsActions {
|
|
|
348
396
|
*/
|
|
349
397
|
declare function createSmartyStreetsActions(api: SmartyStreetsApiClient, config?: SmartyStreetsActionsConfig): SmartyStreetsActions;
|
|
350
398
|
|
|
351
|
-
export { type AddressValidationResult as A, type CustomerListResult as C, type GetItemCategoryOptions as G, type ItemActions as I, type JoomlaActions as J, type NormalizedUserProfile as N, type SearchActions as S, type CustomersActions as a, type CustomersActionsConfig as b, type CustomersApiClient as c, type ItemActionsConfig as d, type ItemsApiClient as e, type JoomlaActionsConfig as f, type JoomlaApiClient as g, type SearchActionsConfig as h, type SearchApiClient as i, type SearchPage as j, type ShippingActions as k, type ShippingActionsConfig as l, type ShippingAddress as m, type ShippingApiClient as n, type SmartyStreetsActions as o, type SmartyStreetsActionsConfig as p, type SmartyStreetsApiClient as q, createCustomersActions as r, createItemActions as s, createJoomlaActions as t, createSearchActions as u, createShippingActions as v, createSmartyStreetsActions as w };
|
|
399
|
+
export { type AddressValidationResult as A, type CustomerListResult as C, type GetItemCategoryOptions as G, type ItemActions as I, type JoomlaActions as J, type NormalizedUserProfile as N, type PaginatedResult as P, type SearchActions as S, type CustomersActions as a, type CustomersActionsConfig as b, type CustomersApiClient as c, type ItemActionsConfig as d, type ItemsApiClient as e, type JoomlaActionsConfig as f, type JoomlaApiClient as g, type SearchActionsConfig as h, type SearchApiClient as i, type SearchPage as j, type ShippingActions as k, type ShippingActionsConfig as l, type ShippingAddress as m, type ShippingApiClient as n, type SmartyStreetsActions as o, type SmartyStreetsActionsConfig as p, type SmartyStreetsApiClient as q, createCustomersActions as r, createItemActions as s, createJoomlaActions as t, createSearchActions as u, createShippingActions as v, createSmartyStreetsActions as w, paginateOffset as x };
|
package/dist/testing.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
export { DeepMockClient, MockClientResult, createMockClient } from '@simpleapps-com/augur-core/testing';
|
|
2
|
-
export { c as clearSiteActions } from './server-site-registry-
|
|
3
|
-
import { a0 as SiteActions } from './site-
|
|
2
|
+
export { c as clearSiteActions } from './server-site-registry-DpHfqqw5.js';
|
|
3
|
+
import { a0 as SiteActions } from './site-HFRLBNg5.js';
|
|
4
4
|
import '@simpleapps-com/augur-core';
|
|
5
5
|
import '@simpleapps-com/augur-api';
|
|
6
6
|
import '@simpleapps-com/augur-utils';
|
|
7
|
-
import './smarty-streets-
|
|
7
|
+
import './smarty-streets-BNHJ_f7T.js';
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
10
|
* A mock function type compatible with both Vitest and Jest.
|
package/dist/testing.js
CHANGED
package/dist/testing.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/testing.ts"],"sourcesContent":["export { createMockClient } from \"@simpleapps-com/augur-core/testing\";\nexport { clearSiteActions } from \"./server-site-registry\";\nexport type {\n DeepMockClient,\n MockClientResult,\n} from \"@simpleapps-com/augur-core/testing\";\n\nimport type { SiteActions } from \"./actions/site\";\n\n/**\n * A mock function type compatible with both Vitest and Jest.\n * Supports `.mockResolvedValue()`, `.mockRejectedValue()`, and call tracking.\n */\nexport interface MockFn {\n (...args: unknown[]): unknown;\n mockResolvedValue: (value: unknown) => MockFn;\n mockRejectedValue: (value: unknown) => MockFn;\n mockReturnValue: (value: unknown) => MockFn;\n mockImplementation: (fn: (...args: unknown[]) => unknown) => MockFn;\n mock: { calls: unknown[][] };\n}\n\n/** Mirror of SiteActions where every method is a MockFn. */\nexport type MockSiteActions = {\n [K in keyof SiteActions]: {\n [M in keyof SiteActions[K]]: MockFn;\n };\n};\n\n/** Return type of createMockSiteActions. */\nexport interface MockSiteActionsResult {\n /** Typed as SiteActions — pass this to your components/server actions. */\n actions: SiteActions;\n /** Same object typed with MockFn — use for assertions and mock setup. */\n mocks: MockSiteActions;\n}\n\n/** Shape definition: service name → method names. */\nconst SERVICE_METHODS: Record<string, string[]> = {\n pricing: [\"getItemPrice\", \"batchGetItemPrices\", \"getTaxEstimate\"],\n items: [\n \"itemCategoryLookup\",\n \"getItemCategory\",\n \"getCategoryItems\",\n \"getItemAttributes\",\n \"getInvMast\",\n \"getInvMastDoc\",\n \"getStock\",\n \"getStockCompanySummary\",\n \"getItemFaqs\",\n \"getItemSubstitutes\",\n \"getItemAccessories\",\n \"getSimilarItems\",\n \"batchGetInvMastDocs\",\n \"batchGetStockData\",\n ],\n commerce: [\n \"cartHdrLookup\",\n \"getCartLines\",\n \"addToCart\",\n \"updateCartLines\",\n \"deleteCartItems\",\n \"getCartAlsoBought\",\n \"checkoutOrder\",\n ],\n search: [\n \"getSearchAttributes\",\n \"getSearchSuggestions\",\n \"itemSearch\",\n \"itemSearchInfinite\",\n ],\n orders: [\"getOrderDoc\"],\n shipping: [\"getShippingRates\"],\n joomla: [\n \"getJoomlaContent\",\n \"getJoomlaContentList\",\n \"getJoomlaMenu\",\n \"getJoomlaMenuDoc\",\n \"getUserProfile\",\n \"verifyPassword\",\n ],\n legacy: [\n \"getItemWebDesc\",\n \"getAlsoBoughtItems\",\n \"getItemTags\",\n \"getStates\",\n ],\n customers: [\n \"getCustomer\",\n \"customerLookup\",\n \"getCustomerDoc\",\n \"getCustomerOrders\",\n \"getCustomerOrderDetail\",\n \"getCustomerInvoices\",\n \"getCustomerInvoiceDetail\",\n \"getCustomerQuotes\",\n \"getCustomerQuoteDetail\",\n \"getContacts\",\n \"getShipToAddresses\",\n ],\n smartyStreets: [\"validateAddress\"],\n p21Pim: [\"getInvMastExt\", \"listInvMastExt\"],\n agrSite: [\"getSettings\", \"getMetaFiles\"],\n avalara: [\"calculateTax\"],\n payments: [\n \"transactionSetup\",\n \"accountQuery\",\n \"getSurcharge\",\n \"cardInfo\",\n \"billingUpdate\",\n \"validatePayment\",\n ],\n ups: [\"getRates\"],\n logistics: [\"getFreightRates\", \"getShipVia\"],\n nexus: [\n \"createBinTransfer\",\n \"createReceiving\",\n \"createTransfer\",\n \"getPurchaseOrderReceipts\",\n \"getTransferReceipts\",\n \"getTransferShipping\",\n ],\n vmi: [\n \"getWarehouses\",\n \"getWarehouseAvailability\",\n \"getDistributors\",\n \"getProducts\",\n \"getInventoryProfiles\",\n \"getRestockHeaders\",\n \"getSections\",\n ],\n p21Core: [\n \"getAddresses\",\n \"getCompanies\",\n \"getCompany\",\n \"getLocations\",\n \"getPaymentTypes\",\n \"getCashDrawers\",\n \"getCodeP21\",\n ],\n p21Apis: [\n \"getCategories\",\n \"getCategoryDefaults\",\n \"getCompanies\",\n \"getUsers\",\n \"getWebDisplayTypes\",\n \"getWebDisplayTypeDefaults\",\n \"refreshContacts\",\n \"refreshCustomers\",\n ],\n p21Sism: [\n \"getRecentImports\",\n \"getImport\",\n \"getImportLines\",\n \"getScheduledImports\",\n ],\n agrWork: [\"healthCheck\", \"ping\"],\n agrInfo: [\n \"getContext\",\n \"getRubrics\",\n \"getMicroservices\",\n \"generateAkasha\",\n \"generateJoomla\",\n ],\n basecamp2: [\n \"getTodos\",\n \"getTodo\",\n \"getTodosSummary\",\n \"getComments\",\n \"getPeople\",\n \"getProjects\",\n \"getEvents\",\n \"getMetrics\",\n \"getTodolists\",\n ],\n brandFolder: [\"getCategories\", \"getCategory\", \"createFocus\"],\n gregorovich: [\n \"askChatGpt\",\n \"getDocuments\",\n \"createDocument\",\n \"generateOllama\",\n ],\n slack: [\"sendWebhook\", \"getWebhooks\"],\n};\n\nfunction createStubFn(): MockFn {\n const calls: unknown[][] = [];\n\n const fn = ((...args: unknown[]) => {\n calls.push(args);\n const impl = (fn as MockFnInternal)._impl;\n return impl ? impl(...args) : undefined;\n }) as MockFn & MockFnInternal;\n\n fn._impl = undefined;\n fn.mock = { calls };\n\n fn.mockResolvedValue = (value: unknown) => {\n fn._impl = () => Promise.resolve(value);\n return fn;\n };\n\n fn.mockRejectedValue = (value: unknown) => {\n fn._impl = () => Promise.reject(value);\n return fn;\n };\n\n fn.mockReturnValue = (value: unknown) => {\n fn._impl = () => value;\n return fn;\n };\n\n fn.mockImplementation = (impl: (...args: unknown[]) => unknown) => {\n fn._impl = impl;\n return fn;\n };\n\n return fn;\n}\n\ninterface MockFnInternal {\n _impl: ((...args: unknown[]) => unknown) | undefined;\n}\n\n/**\n * Creates a fully-mocked SiteActions object for testing.\n *\n * Every method on every service is a stub function with call tracking\n * and `.mockResolvedValue()` / `.mockReturnValue()` support.\n * Works with both Vitest and Jest — no framework dependency.\n *\n * @example\n * ```ts\n * import { createMockSiteActions } from \"@simpleapps-com/augur-server/testing\";\n *\n * const { actions, mocks } = createMockSiteActions();\n *\n * // Setup return values\n * mocks.pricing.getItemPrice.mockResolvedValue({ price: 9.99 });\n *\n * // Pass actions to your component/server action\n * const price = await actions.pricing.getItemPrice(\"ITEM-1\");\n *\n * // Assert calls\n * expect(mocks.pricing.getItemPrice.mock.calls[0]).toEqual([\"ITEM-1\"]);\n * ```\n */\nexport function createMockSiteActions(): MockSiteActionsResult {\n const result: Record<string, Record<string, MockFn>> = {};\n\n for (const [service, methods] of Object.entries(SERVICE_METHODS)) {\n const serviceMock: Record<string, MockFn> = {};\n for (const method of methods) {\n serviceMock[method] = createStubFn();\n }\n result[service] = serviceMock;\n }\n\n return {\n actions: result as unknown as SiteActions,\n mocks: result as unknown as MockSiteActions,\n };\n}\n"],"mappings":";;;;;AAAA,SAAS,wBAAwB;AAsCjC,IAAM,kBAA4C;AAAA,EAChD,SAAS,CAAC,gBAAgB,sBAAsB,gBAAgB;AAAA,EAChE,OAAO;AAAA,IAC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;AACX,WAAO;AAAA,EACT;AAEA,SAAO;AACT;AA6BO,SAAS,wBAA+C;AAC7D,QAAM,SAAiD,CAAC;AAExD,aAAW,CAAC,SAAS,OAAO,KAAK,OAAO,QAAQ,eAAe,GAAG;AAChE,UAAM,cAAsC,CAAC;AAC7C,eAAW,UAAU,SAAS;AAC5B,kBAAY,MAAM,IAAI,aAAa;AAAA,IACrC;AACA,WAAO,OAAO,IAAI;AAAA,EACpB;AAEA,SAAO;AAAA,IACL,SAAS;AAAA,IACT,OAAO;AAAA,EACT;AACF;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../src/testing.ts"],"sourcesContent":["export { createMockClient } from \"@simpleapps-com/augur-core/testing\";\nexport { clearSiteActions } from \"./server-site-registry\";\nexport type {\n DeepMockClient,\n MockClientResult,\n} from \"@simpleapps-com/augur-core/testing\";\n\nimport type { SiteActions } from \"./actions/site\";\n\n/**\n * A mock function type compatible with both Vitest and Jest.\n * Supports `.mockResolvedValue()`, `.mockRejectedValue()`, and call tracking.\n */\nexport interface MockFn {\n (...args: unknown[]): unknown;\n mockResolvedValue: (value: unknown) => MockFn;\n mockRejectedValue: (value: unknown) => MockFn;\n mockReturnValue: (value: unknown) => MockFn;\n mockImplementation: (fn: (...args: unknown[]) => unknown) => MockFn;\n mock: { calls: unknown[][] };\n}\n\n/** Mirror of SiteActions where every method is a MockFn. */\nexport type MockSiteActions = {\n [K in keyof SiteActions]: {\n [M in keyof SiteActions[K]]: MockFn;\n };\n};\n\n/** Return type of createMockSiteActions. */\nexport interface MockSiteActionsResult {\n /** Typed as SiteActions — pass this to your components/server actions. */\n actions: SiteActions;\n /** Same object typed with MockFn — use for assertions and mock setup. */\n mocks: MockSiteActions;\n}\n\n/** Shape definition: service name → method names. */\nconst SERVICE_METHODS: Record<string, string[]> = {\n pricing: [\"getItemPrice\", \"batchGetItemPrices\", \"getTaxEstimate\"],\n items: [\n \"itemCategoryLookup\",\n \"getItemCategory\",\n \"getCategoryItems\",\n \"getCategoryItemsInfinite\",\n \"getItemAttributes\",\n \"getInvMast\",\n \"getInvMastDoc\",\n \"getStock\",\n \"getStockCompanySummary\",\n \"getItemFaqs\",\n \"getItemSubstitutes\",\n \"getItemAccessories\",\n \"getSimilarItems\",\n \"batchGetInvMastDocs\",\n \"batchGetStockData\",\n ],\n commerce: [\n \"cartHdrLookup\",\n \"getCartLines\",\n \"addToCart\",\n \"updateCartLines\",\n \"deleteCartItems\",\n \"getCartAlsoBought\",\n \"checkoutOrder\",\n ],\n search: [\n \"getSearchAttributes\",\n \"getSearchSuggestions\",\n \"itemSearch\",\n \"itemSearchInfinite\",\n ],\n orders: [\"getOrderDoc\"],\n shipping: [\"getShippingRates\"],\n joomla: [\n \"getJoomlaContent\",\n \"getJoomlaContentList\",\n \"getJoomlaMenu\",\n \"getJoomlaMenuDoc\",\n \"getUserProfile\",\n \"verifyPassword\",\n ],\n legacy: [\n \"getItemWebDesc\",\n \"getAlsoBoughtItems\",\n \"getItemTags\",\n \"getStates\",\n ],\n customers: [\n \"getCustomer\",\n \"customerLookup\",\n \"getCustomerDoc\",\n \"getCustomerOrders\",\n \"getCustomerOrderDetail\",\n \"getCustomerInvoices\",\n \"getCustomerInvoiceDetail\",\n \"getCustomerQuotes\",\n \"getCustomerQuoteDetail\",\n \"getContacts\",\n \"getShipToAddresses\",\n ],\n smartyStreets: [\"validateAddress\"],\n p21Pim: [\"getInvMastExt\", \"listInvMastExt\"],\n agrSite: [\"getSettings\", \"getMetaFiles\"],\n avalara: [\"calculateTax\"],\n payments: [\n \"transactionSetup\",\n \"accountQuery\",\n \"getSurcharge\",\n \"cardInfo\",\n \"billingUpdate\",\n \"validatePayment\",\n ],\n ups: [\"getRates\"],\n logistics: [\"getFreightRates\", \"getShipVia\"],\n nexus: [\n \"createBinTransfer\",\n \"createReceiving\",\n \"createTransfer\",\n \"getPurchaseOrderReceipts\",\n \"getTransferReceipts\",\n \"getTransferShipping\",\n ],\n vmi: [\n \"getWarehouses\",\n \"getWarehouseAvailability\",\n \"getDistributors\",\n \"getProducts\",\n \"getInventoryProfiles\",\n \"getRestockHeaders\",\n \"getSections\",\n ],\n p21Core: [\n \"getAddresses\",\n \"getCompanies\",\n \"getCompany\",\n \"getLocations\",\n \"getPaymentTypes\",\n \"getCashDrawers\",\n \"getCodeP21\",\n ],\n p21Apis: [\n \"getCategories\",\n \"getCategoryDefaults\",\n \"getCompanies\",\n \"getUsers\",\n \"getWebDisplayTypes\",\n \"getWebDisplayTypeDefaults\",\n \"refreshContacts\",\n \"refreshCustomers\",\n ],\n p21Sism: [\n \"getRecentImports\",\n \"getImport\",\n \"getImportLines\",\n \"getScheduledImports\",\n ],\n agrWork: [\"healthCheck\", \"ping\"],\n agrInfo: [\n \"getContext\",\n \"getRubrics\",\n \"getMicroservices\",\n \"generateAkasha\",\n \"generateJoomla\",\n ],\n basecamp2: [\n \"getTodos\",\n \"getTodo\",\n \"getTodosSummary\",\n \"getComments\",\n \"getPeople\",\n \"getProjects\",\n \"getEvents\",\n \"getMetrics\",\n \"getTodolists\",\n ],\n brandFolder: [\"getCategories\", \"getCategory\", \"createFocus\"],\n gregorovich: [\n \"askChatGpt\",\n \"getDocuments\",\n \"createDocument\",\n \"generateOllama\",\n ],\n slack: [\"sendWebhook\", \"getWebhooks\"],\n};\n\nfunction createStubFn(): MockFn {\n const calls: unknown[][] = [];\n\n const fn = ((...args: unknown[]) => {\n calls.push(args);\n const impl = (fn as MockFnInternal)._impl;\n return impl ? impl(...args) : undefined;\n }) as MockFn & MockFnInternal;\n\n fn._impl = undefined;\n fn.mock = { calls };\n\n fn.mockResolvedValue = (value: unknown) => {\n fn._impl = () => Promise.resolve(value);\n return fn;\n };\n\n fn.mockRejectedValue = (value: unknown) => {\n fn._impl = () => Promise.reject(value);\n return fn;\n };\n\n fn.mockReturnValue = (value: unknown) => {\n fn._impl = () => value;\n return fn;\n };\n\n fn.mockImplementation = (impl: (...args: unknown[]) => unknown) => {\n fn._impl = impl;\n return fn;\n };\n\n return fn;\n}\n\ninterface MockFnInternal {\n _impl: ((...args: unknown[]) => unknown) | undefined;\n}\n\n/**\n * Creates a fully-mocked SiteActions object for testing.\n *\n * Every method on every service is a stub function with call tracking\n * and `.mockResolvedValue()` / `.mockReturnValue()` support.\n * Works with both Vitest and Jest — no framework dependency.\n *\n * @example\n * ```ts\n * import { createMockSiteActions } from \"@simpleapps-com/augur-server/testing\";\n *\n * const { actions, mocks } = createMockSiteActions();\n *\n * // Setup return values\n * mocks.pricing.getItemPrice.mockResolvedValue({ price: 9.99 });\n *\n * // Pass actions to your component/server action\n * const price = await actions.pricing.getItemPrice(\"ITEM-1\");\n *\n * // Assert calls\n * expect(mocks.pricing.getItemPrice.mock.calls[0]).toEqual([\"ITEM-1\"]);\n * ```\n */\nexport function createMockSiteActions(): MockSiteActionsResult {\n const result: Record<string, Record<string, MockFn>> = {};\n\n for (const [service, methods] of Object.entries(SERVICE_METHODS)) {\n const serviceMock: Record<string, MockFn> = {};\n for (const method of methods) {\n serviceMock[method] = createStubFn();\n }\n result[service] = serviceMock;\n }\n\n return {\n actions: result as unknown as SiteActions,\n mocks: result as unknown as MockSiteActions,\n };\n}\n"],"mappings":";;;;;AAAA,SAAS,wBAAwB;AAsCjC,IAAM,kBAA4C;AAAA,EAChD,SAAS,CAAC,gBAAgB,sBAAsB,gBAAgB;AAAA,EAChE,OAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF;AAAA,EACA,UAAU;AAAA,IACR;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF;AAAA,EACA,QAAQ;AAAA,IACN;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF;AAAA,EACA,QAAQ,CAAC,aAAa;AAAA,EACtB,UA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1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@simpleapps-com/augur-server",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.2",
|
|
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.2",
|
|
53
|
+
"@simpleapps-com/augur-utils": "2.0.2"
|
|
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.2"
|
|
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.2"
|
|
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":[]}
|