@simpleapps-com/augur-server 2.0.2 → 2.0.4

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.
@@ -1,6 +1,6 @@
1
1
  import { AugurAPI } from '@simpleapps-com/augur-api';
2
- import { EdgeCacheValue } from '@simpleapps-com/augur-core';
3
- import { TCategory, TCategoryItemsResult, TItemsFilters, TProductItem, TAttribute, TInvMast, TInvMastDoc, TStockData, TItemAccessory, TShippingMethod, TJoomlaContent, TMenu, TPasswordVerification, CustomerDocument, TSmartyStreets } from '@simpleapps-com/augur-utils';
2
+ import { ListResult, EdgeCacheValue } from '@simpleapps-com/augur-core';
3
+ import { TCategory, TCategoryItemsResult, TItemsFilters, TProductItem, TAttribute, TInvMast, TInvMastDoc, TStock, TItemAccessory, TSearchSuggestionsResponse, TShippingMethod, TJoomlaContent, TMenu, TPasswordVerification, TSmartyStreets } from '@simpleapps-com/augur-utils';
4
4
 
5
5
  /**
6
6
  * Standardized paginated response shape.
@@ -8,7 +8,7 @@ import { TCategory, TCategoryItemsResult, TItemsFilters, TProductItem, TAttribut
8
8
  */
9
9
  interface PaginatedResult<T> {
10
10
  data: T[];
11
- total?: number;
11
+ total: number;
12
12
  nextCursor?: number;
13
13
  hasMore: boolean;
14
14
  }
@@ -72,7 +72,9 @@ interface ItemActions {
72
72
  (uid: number, itemsFilters: TItemsFilters): Promise<TCategoryItemsResult>;
73
73
  };
74
74
  getCategoryItemsInfinite: (uid: number, itemsFilters?: TItemsFilters, pageParam?: number) => Promise<PaginatedResult<TProductItem>>;
75
- getItemAttributes: (categoryUid: number) => Promise<TAttribute[]>;
75
+ getItemAttributes: (categoryUid: number) => Promise<{
76
+ attributes: TAttribute[];
77
+ }>;
76
78
  getInvMast: (uid: number) => Promise<TInvMast>;
77
79
  getInvMastDoc: {
78
80
  (params: {
@@ -82,17 +84,17 @@ interface ItemActions {
82
84
  }): Promise<TInvMastDoc>;
83
85
  (invMastUid: number, itemId?: string, includePricing?: "Y" | "N"): Promise<TInvMastDoc>;
84
86
  };
85
- getStock: (invMastUid: number) => Promise<TStockData[]>;
87
+ getStock: (invMastUid: number) => Promise<TStock>;
86
88
  getStockCompanySummary: (invMastUid: number) => Promise<Record<string, number>>;
87
- getItemFaqs: (invMastUid: number) => Promise<unknown[]>;
88
- getItemSubstitutes: (invMastUid: number) => Promise<unknown[]>;
89
- getItemAccessories: (invMastUid: number) => Promise<TItemAccessory[]>;
90
- getSimilarItems: (invMastUid: number) => Promise<unknown[]>;
89
+ getItemFaqs: (invMastUid: number) => Promise<ListResult>;
90
+ getItemSubstitutes: (invMastUid: number) => Promise<ListResult>;
91
+ getItemAccessories: (invMastUid: number) => Promise<ListResult<TItemAccessory>>;
92
+ getSimilarItems: (invMastUid: number) => Promise<ListResult>;
91
93
  batchGetInvMastDocs: (params: {
92
94
  invMastUid?: number;
93
95
  itemId?: string;
94
96
  }[]) => Promise<Record<string, TInvMastDoc>>;
95
- batchGetStockData: (invMastUids: number[]) => Promise<Record<number, TStockData[]>>;
97
+ batchGetStockData: (invMastUids: number[]) => Promise<Record<number, TStock>>;
96
98
  }
97
99
  /**
98
100
  * @deprecated Use `createSiteActions()` instead. This factory will be removed in the next major version.
@@ -138,12 +140,10 @@ interface SearchPage {
138
140
  nextCursor?: number;
139
141
  }
140
142
  interface SearchActions {
141
- getSearchAttributes: (q: string) => Promise<TAttribute[]>;
142
- getSearchSuggestions: (q: string, limit?: number, offset?: number) => Promise<{
143
- data: unknown[];
144
- total: number;
145
- totalResults: number;
143
+ getSearchAttributes: (q: string) => Promise<{
144
+ attributes: TAttribute[];
146
145
  }>;
146
+ getSearchSuggestions: (q: string, limit?: number, offset?: number) => Promise<TSearchSuggestionsResponse>;
147
147
  itemSearch: (filters: {
148
148
  q: string;
149
149
  limit: number;
@@ -208,7 +208,7 @@ interface ShippingActionsConfig {
208
208
  redisTtl?: number;
209
209
  }
210
210
  interface ShippingActions {
211
- getShippingRates: (toAddress: ShippingAddress, weight: number, serviceCodes?: string[]) => Promise<TShippingMethod[]>;
211
+ getShippingRates: (toAddress: ShippingAddress, weight: number, serviceCodes?: string[]) => Promise<ListResult<TShippingMethod>>;
212
212
  }
213
213
  /**
214
214
  * @deprecated Use `createSiteActions()` instead. This factory will be removed in the next major version.
@@ -267,10 +267,10 @@ interface JoomlaActions {
267
267
  catId?: number;
268
268
  }): Promise<TJoomlaContent>;
269
269
  };
270
- getJoomlaContentList: (params?: Record<string, unknown>) => Promise<TJoomlaContent[]>;
270
+ getJoomlaContentList: (params?: Record<string, unknown>) => Promise<ListResult<TJoomlaContent>>;
271
271
  getJoomlaMenu: {
272
- (params?: Record<string, unknown>): Promise<TMenu[]>;
273
- (parentId: number, menuType: string): Promise<TMenu[]>;
272
+ (params?: Record<string, unknown>): Promise<ListResult<TMenu>>;
273
+ (parentId: number, menuType: string): Promise<ListResult<TMenu>>;
274
274
  };
275
275
  getJoomlaMenuDoc: (menuId: number | string) => Promise<TMenu>;
276
276
  getUserProfile: (userId: number | string) => Promise<NormalizedUserProfile>;
@@ -301,56 +301,6 @@ interface JoomlaActions {
301
301
  */
302
302
  declare function createJoomlaActions(api: JoomlaApiClient, config?: JoomlaActionsConfig): JoomlaActions;
303
303
 
304
- interface CustomerListResult {
305
- data: unknown[];
306
- total: number;
307
- }
308
- /** Derived from augur-api SDK — keeps types in sync automatically. */
309
- type CustomersApiClient = Pick<AugurAPI, "customers">;
310
- interface CustomersActionsConfig {
311
- /** Cache key prefix (e.g. "ampro:"). Default: "". */
312
- cachePrefix?: string;
313
- /** CDN edge cache value passed to SDK. Default: 1 (hour). */
314
- edgeCache?: EdgeCacheValue;
315
- /** Redis TTL in seconds. Default: 3600 (1 hour). */
316
- redisTtl?: number;
317
- }
318
- interface CustomersActions {
319
- getCustomer: (customerId: number) => Promise<CustomerDocument>;
320
- customerLookup: (params: Record<string, unknown>) => Promise<CustomerDocument[]>;
321
- getCustomerDoc: (customerId: number) => Promise<CustomerDocument>;
322
- getCustomerOrders: (customerId: number, params?: Record<string, unknown>) => Promise<CustomerListResult>;
323
- getCustomerOrderDetail: (customerId: number, orderId: number) => Promise<unknown>;
324
- getCustomerInvoices: (customerId: number, params?: Record<string, unknown>) => Promise<CustomerListResult>;
325
- getCustomerInvoiceDetail: (customerId: number, invoiceNo: number) => Promise<unknown>;
326
- getCustomerQuotes: (customerId: number, params?: Record<string, unknown>) => Promise<CustomerListResult>;
327
- getCustomerQuoteDetail: (customerId: number, quoteNo: number) => Promise<unknown>;
328
- getContacts: (params?: Record<string, unknown>) => Promise<unknown[]>;
329
- getShipToAddresses: (customerId: number) => Promise<unknown[]>;
330
- }
331
- /**
332
- * @deprecated Use `createSiteActions()` instead. This factory will be removed in the next major version.
333
- *
334
- * Creates server-side customer actions with Redis caching and edge cache support.
335
- *
336
- * Covers the customers microservice endpoints used by ecommerce sites:
337
- * customer get, lookup, doc, orders, contacts, and ship-to addresses.
338
- *
339
- * @example
340
- * ```ts
341
- * import { createCustomersActions } from "@simpleapps-com/augur-server";
342
- * import { getAugurClient } from "./augur-client";
343
- *
344
- * export const customersActions = createCustomersActions(getAugurClient(), {
345
- * cachePrefix: "ampro:",
346
- * });
347
- *
348
- * const customer = await customersActions.getCustomer(123);
349
- * const orders = await customersActions.getCustomerOrders(123);
350
- * ```
351
- */
352
- declare function createCustomersActions(api: CustomersApiClient, config?: CustomersActionsConfig): CustomersActions;
353
-
354
304
  /** Derived from augur-api SDK — keeps types in sync automatically. */
355
305
  type SmartyStreetsApiClient = Pick<AugurAPI, "smartyStreets">;
356
306
  interface SmartyStreetsActionsConfig {
@@ -396,4 +346,4 @@ interface SmartyStreetsActions {
396
346
  */
397
347
  declare function createSmartyStreetsActions(api: SmartyStreetsApiClient, config?: SmartyStreetsActionsConfig): SmartyStreetsActions;
398
348
 
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 };
349
+ export { type AddressValidationResult as A, 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 ItemActionsConfig as a, type ItemsApiClient as b, type JoomlaActionsConfig as c, type JoomlaApiClient as d, type SearchActionsConfig as e, type SearchApiClient as f, type SearchPage as g, type ShippingActions as h, type ShippingActionsConfig as i, type ShippingAddress as j, type ShippingApiClient as k, type SmartyStreetsActions as l, type SmartyStreetsActionsConfig as m, type SmartyStreetsApiClient as n, createItemActions as o, createJoomlaActions as p, createSearchActions as q, createShippingActions as r, createSmartyStreetsActions as s, paginateOffset as t };
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-DpHfqqw5.js';
3
- import { a0 as SiteActions } from './site-HFRLBNg5.js';
2
+ export { c as clearSiteActions } from './server-site-registry-BtBMmWYF.js';
3
+ import { a4 as SiteActions } from './site-C1raVxkq.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-BNHJ_f7T.js';
7
+ import './smarty-streets-DshoLeug.js';
8
8
 
9
9
  /**
10
10
  * A mock function type compatible with both Vitest and Jest.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@simpleapps-com/augur-server",
3
- "version": "2.0.2",
3
+ "version": "2.0.4",
4
4
  "description": "Server-side utilities for Augur ecommerce sites (Redis caching, SDK helpers, auth)",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -49,17 +49,17 @@
49
49
  ],
50
50
  "dependencies": {
51
51
  "valibot": "^1.0.0",
52
- "@simpleapps-com/augur-core": "2.0.2",
53
- "@simpleapps-com/augur-utils": "2.0.2"
52
+ "@simpleapps-com/augur-core": "2.0.4",
53
+ "@simpleapps-com/augur-utils": "2.0.4"
54
54
  },
55
55
  "peerDependencies": {
56
- "@simpleapps-com/augur-api": "^2026.3.1",
56
+ "@simpleapps-com/augur-api": "^2026.3.3",
57
57
  "@tanstack/react-query": "^5.80.0",
58
58
  "ioredis": "^5.9.0",
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": "2.0.2"
62
+ "@simpleapps-com/augur-hooks": "2.0.4"
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": "2.0.2"
85
+ "@simpleapps-com/augur-hooks": "2.0.4"
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/**\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":[]}