@simpleapps-com/augur-server 2.2.28 → 2.3.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.
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/query-action.ts"],"sourcesContent":["// \"use server\" banner is injected by tsup at build time.\n// Isolated server action for the proxy pattern.\n// This file MUST NOT import from server-actions.ts, server-site-registry.ts,\n// cache/, or any factory. It imports only from lightweight stores with zero\n// deps, plus augur-core (external in tsup — not bundled into chunks).\n// Dynamic imports of next/headers and next-auth/jwt are used for session\n// credential resolution (both are external in tsup).\n\nimport {\n getSdkClientOrNull,\n getSdkCallWrapper,\n getAuthSecret,\n getOrCreateScopedClient,\n getScopedCacheWrapper,\n} from \"./sdk-client-store\";\nimport { isReadMethod, stripEdgeCacheForNoCachePaths } from \"@simpleapps-com/augur-core\";\n\n/** Auth.js v5 session cookie names (HTTPS secure prefix + HTTP fallback). */\nconst SECURE_COOKIE = \"__Secure-authjs.session-token\";\nconst PLAIN_COOKIE = \"authjs.session-token\";\n\n/** Simplified function types for lazy-loaded external deps. */\ntype DecodeFn = (params: {\n token?: string;\n secret: string | string[];\n salt: string;\n}) => Promise<Record<string, unknown> | null>;\ntype CookiesFn = () => Promise<{ get: (name: string) => { value: string } | undefined }>;\n\n/** Cached dynamic imports for next-auth/jwt decode and next/headers cookies. */\nlet _decode: DecodeFn | null | undefined;\nlet _cookies: CookiesFn | null | undefined;\n\n/** Lazy-load decode and cookies functions from external deps. Cached after first call. */\nasync function ensureImports(): Promise<boolean> {\n if (_decode === undefined) {\n try {\n const mod = await import(\"next-auth/jwt\");\n _decode = mod.decode as unknown as DecodeFn;\n /* v8 ignore next 3 -- dynamic import only fails when next-auth is not installed */\n } catch {\n _decode = null;\n }\n }\n if (_cookies === undefined) {\n try {\n const mod = await import(\"next/headers\");\n _cookies = mod.cookies as unknown as CookiesFn;\n /* v8 ignore next 3 -- dynamic import only fails when next is not installed */\n } catch {\n _cookies = null;\n }\n }\n /* v8 ignore next -- _decode/_cookies null branch only when imports fail (untestable with vi.mock) */\n return !!_decode && !!_cookies;\n}\n\n/** Read and decode the Auth.js session JWT from request cookies. */\nasync function decodeSessionJwt(secret: string): Promise<Record<string, unknown> | null> {\n const cookieStore = await _cookies!();\n const secureCookie = cookieStore.get(SECURE_COOKIE);\n const plainCookie = secureCookie ? undefined : cookieStore.get(PLAIN_COOKIE);\n const cookie = secureCookie ?? plainCookie;\n if (!cookie?.value) return null;\n\n const salt = secureCookie ? SECURE_COOKIE : PLAIN_COOKIE;\n return _decode!({ token: cookie.value, secret, salt });\n}\n\n/**\n * Resolve session credentials from the Auth.js JWT cookie.\n * Returns the targetSiteId and token if present, or null.\n * Falls back to null on any error (no cookie, no secret, not in request context).\n */\nasync function getSessionCredentials(): Promise<{ siteId: string; token: string } | null> {\n const secret = getAuthSecret();\n if (!secret) return null;\n /* v8 ignore next -- ensureImports returns false only when dynamic imports fail (untestable with vi.mock) */\n if (!(await ensureImports())) return null;\n\n try {\n const decoded = await decodeSessionJwt(secret);\n if (!decoded) return null;\n\n const targetSiteId = decoded[\"targetSiteId\"] as string | undefined;\n const token = decoded[\"token\"] as string | undefined;\n if (targetSiteId && token) {\n return { siteId: targetSiteId, token };\n }\n } catch {\n // Not in a request context (build time, tests), or decode failed\n }\n\n return null;\n}\n\n/**\n * Resolve the SDK client and cache prefix for this request.\n * If the session has targetSiteId + token, returns a scoped client.\n * Otherwise returns the global client.\n */\nasync function resolveClientAndPrefix(): Promise<{\n client: unknown;\n cachePrefix: string | null;\n}> {\n const globalClient = getSdkClientOrNull();\n\n const creds = await getSessionCredentials();\n if (creds) {\n const scoped = getOrCreateScopedClient(creds.siteId, creds.token);\n if (scoped) {\n return { client: scoped, cachePrefix: `${creds.siteId}:` };\n }\n }\n\n return { client: globalClient, cachePrefix: null };\n}\n\n/**\n * Unwrap SDK BaseResponse if the result matches the standard shape.\n * The SDK wraps all responses in `{ data: T, status: number, message: string }`.\n * SiteActions previously unwrapped this; queryAction now does it automatically\n * so consumers receive `T` directly.\n */\nfunction unwrapBaseResponse(raw: unknown): unknown {\n if (\n raw != null &&\n typeof raw === \"object\" &&\n \"data\" in raw &&\n \"status\" in raw &&\n \"message\" in raw\n ) {\n return (raw as { data: unknown }).data;\n }\n return raw;\n}\n\n/** Resolve a dot-separated method path on an object, returning the leaf function. */\nfunction resolveMethod(client: unknown, methodPath: string): (...a: unknown[]) => Promise<unknown> {\n const segments = methodPath.split(\".\");\n\n let current: unknown = client;\n for (const segment of segments) {\n if (current == null || (typeof current !== \"object\" && typeof current !== \"function\")) {\n throw new Error(\n `Cannot resolve \"${methodPath}\": \"${segment}\" is not accessible on ${typeof current}`,\n );\n }\n current = (current as Record<string, unknown>)[segment];\n }\n\n if (typeof current !== \"function\") {\n throw new Error(`\"${methodPath}\" does not resolve to a function (got ${typeof current})`);\n }\n\n return current as (...a: unknown[]) => Promise<unknown>;\n}\n\n/**\n * Generic server action that routes any SDK method call through the raw\n * SDK client with optional Redis caching. Used internally by\n * `createServerQueryProxy()` to bridge client-side React Query hooks\n * to server-side API calls.\n *\n * For read methods (get, list, lookup, search, suggest), the call is\n * wrapped in the registered cache wrapper (Redis) if one was registered\n * by createServerSite(). Write methods bypass caching.\n *\n * When the request has an active session with targetSiteId + token\n * (from cross-site auth), the call uses a scoped SDK client with those\n * credentials. Redis caching uses targetSiteId as the cache prefix so\n * users managing the same site share cached data.\n *\n * SDK responses wrapped in BaseResponse are automatically unwrapped --\n * consumers receive `T` instead of `{ data: T, status, message }`.\n *\n * @param methodPath Dot-separated SDK method path (e.g. \"items.invMast.doc.get\")\n * @param args Arguments to pass to the resolved method\n * @returns The unwrapped result from the SDK method (possibly from Redis cache)\n */\nexport async function queryAction(methodPath: string, ...args: unknown[]): Promise<unknown> {\n const { client, cachePrefix } = await resolveClientAndPrefix();\n if (!client) {\n throw new Error(\n \"SDK client not initialized. Call createServerSite() or set AUGUR_SITE_ID + AUGUR_JWT env vars.\",\n );\n }\n\n const resolvedMethod = resolveMethod(client, methodPath);\n const leafName = methodPath.split(\".\").pop()!;\n // Defense in depth: strip `edgeCache` from no-cache paths before the SDK\n // sees it. The augur-api SDK transforms `edgeCache` into a Cloudflare\n // `cacheSiteId{N}` query param; removing it here guarantees no CDN edge\n // caching of identity-bound responses even if a caller explicitly passed\n // one. Also keeps cache keys consistent with what is actually sent.\n const safeArgs = stripEdgeCacheForNoCachePaths(methodPath, args);\n\n // Scoped client — use scoped cache wrapper with targetSiteId prefix\n if (cachePrefix !== null) {\n const scopedWrapper = getScopedCacheWrapper();\n if (scopedWrapper && isReadMethod(leafName)) {\n const result = await scopedWrapper(\n cachePrefix,\n methodPath,\n () => resolvedMethod(...safeArgs),\n ...safeArgs,\n );\n return unwrapBaseResponse(result);\n }\n const result = await resolvedMethod(...safeArgs);\n return unwrapBaseResponse(result);\n }\n\n // Global client — use standard cache wrapper\n const wrapper = getSdkCallWrapper();\n if (wrapper && isReadMethod(leafName)) {\n const result = await wrapper(methodPath, () => resolvedMethod(...safeArgs), ...safeArgs);\n return unwrapBaseResponse(result);\n }\n\n const result = await resolvedMethod(...safeArgs);\n return unwrapBaseResponse(result);\n}\n\n/** Reset lazy-loaded imports. Used in tests only. @internal */\nexport function resetSessionImports(): void {\n _decode = undefined;\n _cookies = undefined;\n}\n\nexport { unwrapBaseResponse, getSessionCredentials, resolveMethod };\n"],"mappings":";;;;;;;;;AAeA,SAAS,cAAc,qCAAqC;AAG5D,IAAM,gBAAgB;AACtB,IAAM,eAAe;AAWrB,IAAI;AACJ,IAAI;AAGJ,eAAe,gBAAkC;AAC/C,MAAI,YAAY,QAAW;AACzB,QAAI;AACF,YAAM,MAAM,MAAM,OAAO,eAAe;AACxC,gBAAU,IAAI;AAAA,IAEhB,QAAQ;AACN,gBAAU;AAAA,IACZ;AAAA,EACF;AACA,MAAI,aAAa,QAAW;AAC1B,QAAI;AACF,YAAM,MAAM,MAAM,OAAO,cAAc;AACvC,iBAAW,IAAI;AAAA,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AAmBA,OAAM;AAAA,EAClC;AAEA,QAAM,SAAS,MAAM,eAAe,GAAG,QAAQ;AAC/C,SAAO,mBAAmB,MAAM;AAClC;AAGO,SAAS,sBAA4B;AAC1C,YAAU;AACV,aAAW;AACb;","names":["result"]}
package/dist/hooks.js CHANGED
@@ -1,7 +1,7 @@
1
1
  "use client";
2
2
  import {
3
3
  queryAction
4
- } from "./chunk-OOR3XGUT.js";
4
+ } from "./chunk-ZUJZDRTP.js";
5
5
  import "./chunk-HPQQYROJ.js";
6
6
  import "./chunk-DGUM43GV.js";
7
7
 
package/dist/index.d.ts CHANGED
@@ -2,9 +2,8 @@ import { SafeActionResult } from '@simpleapps-com/augur-utils';
2
2
  export { SafeActionResult, unwrap, unwrapOr } from '@simpleapps-com/augur-utils';
3
3
  import { QueryClient } from '@tanstack/react-query';
4
4
  export { QueryOptionsConfig, createQueryOptions, createSuspenseQueryOptions } from './query.js';
5
- export { P as PaginatedResult, p as paginateOffset } from './smarty-streets-BnEIKoi8.js';
6
- export { S as SiteActions, a as SiteActionsConfig, c as createSiteActions } from './site-BdJFUwsM.js';
7
- export { g as getSiteActions, r as registerSiteActions } from './server-site-registry-vsuD5FAk.js';
5
+ export { P as PaginatedResult, S as SiteActions, a as SiteActionsConfig, c as createSiteActions, p as paginateOffset } from './site-BjSFqufX.js';
6
+ export { g as getSiteActions, r as registerSiteActions } from './server-site-registry-CdBfczOj.js';
8
7
  export { ActionResult, EdgeCacheValue } from '@simpleapps-com/augur-core';
9
8
 
10
9
  /** Resolved environment: `"development"`, `"staging"`, or `"production"`. */
package/dist/index.js CHANGED
@@ -21,7 +21,7 @@ import {
21
21
  unwrap,
22
22
  unwrapOr,
23
23
  withServerCache
24
- } from "./chunk-4OK7EWLJ.js";
24
+ } from "./chunk-WOHZDFJF.js";
25
25
  import "./chunk-HPQQYROJ.js";
26
26
  import "./chunk-DGUM43GV.js";
27
27
 
@@ -5,7 +5,7 @@ import {
5
5
  resetSessionImports,
6
6
  resolveMethod,
7
7
  unwrapBaseResponse
8
- } from "./chunk-OOR3XGUT.js";
8
+ } from "./chunk-ZUJZDRTP.js";
9
9
  import "./chunk-HPQQYROJ.js";
10
10
  import "./chunk-DGUM43GV.js";
11
11
  export {
@@ -1,4 +1,4 @@
1
- import { S as SiteActions } from './site-BdJFUwsM.js';
1
+ import { S as SiteActions } from './site-BjSFqufX.js';
2
2
 
3
3
  /**
4
4
  * Process-global storage for the site actions singleton.
@@ -1,6 +1,37 @@
1
1
  import { ListResult, EdgeCacheValue } from '@simpleapps-com/augur-core';
2
- import { TPriceData, TTaxItem, TTax, TCartLookUp, TCartLine, TRelatedProduct, TCheckoutResult, TWebDesc, CustomerDocument, TTransactionSetup, TAccountQuery, TSurcharge, TCardInfo, TBillingUpdate, TPaymentValidation } from '@simpleapps-com/augur-utils';
3
- import { I as ItemActions, S as SearchActions, a as ShippingActions, J as JoomlaActions, b as SmartyStreetsActions, c as ShippingAddress } from './smarty-streets-BnEIKoi8.js';
2
+ import { TPriceData, TTaxItem, TTax, TCategory, TCategoryItemsResult, TItemsFilters, TProductItem, TAttribute, TInvMast, TInvMastDoc, TStock, TItemAccessory, TCartLookUp, TCartLine, TRelatedProduct, TCheckoutResult, TSearchSuggestionsResponse, TShippingMethod, TJoomlaContent, TMenu, MenuItem, TPasswordVerification, TWebDesc, CustomerDocument, TSmartyStreets, TTransactionSetup, TAccountQuery, TSurcharge, TCardInfo, TBillingUpdate, TPaymentValidation } from '@simpleapps-com/augur-utils';
3
+
4
+ /**
5
+ * Standardized paginated response shape.
6
+ * Works with any factory method — compose with `paginateOffset()`.
7
+ */
8
+ interface PaginatedResult<T> {
9
+ data: T[];
10
+ total: number;
11
+ nextCursor?: number;
12
+ hasMore: boolean;
13
+ }
14
+ /**
15
+ * Wraps a list of items with offset-based pagination metadata.
16
+ *
17
+ * Use this to standardize pagination responses from any factory method.
18
+ * Compatible with React Query's infinite query pattern (`getNextPageParam`).
19
+ *
20
+ * @param items - The items returned from the current page
21
+ * @param pageParam - The current page number (0-based)
22
+ * @param limit - The page size
23
+ * @param total - Optional total count of items (from API response)
24
+ *
25
+ * @example
26
+ * ```ts
27
+ * const result = await actions.items.getCategoryItems(uid, {
28
+ * ...filters, offset: page * 24, limit: 24,
29
+ * });
30
+ * return paginateOffset(result.items, page, 24, result.total);
31
+ * // { data: [...], total: 150, nextCursor: 1, hasMore: true }
32
+ * ```
33
+ */
34
+ declare function paginateOffset<T>(items: T[], pageParam: number, limit: number, total?: number): PaginatedResult<T>;
4
35
 
5
36
  interface PricingActions {
6
37
  getItemPrice: (itemId: string, customerId?: string | number, quantity?: number) => Promise<TPriceData>;
@@ -8,6 +39,51 @@ interface PricingActions {
8
39
  getTaxEstimate: (customerId?: string | number, postalCode?: string, items?: TTaxItem[]) => Promise<TTax>;
9
40
  }
10
41
 
42
+ /** Typed options for getItemCategory. */
43
+ interface GetItemCategoryOptions {
44
+ childrenFilter?: string;
45
+ childrenLimit?: number;
46
+ childrenOffset?: number;
47
+ classId5List?: string;
48
+ filters?: Record<string, string>;
49
+ orderBy?: string;
50
+ path?: string;
51
+ productCollection?: string;
52
+ rootItemCategoryId?: string;
53
+ }
54
+ interface ItemActions {
55
+ itemCategoryLookup: (path: string) => Promise<unknown>;
56
+ getItemCategory: (uid: number, options?: GetItemCategoryOptions) => Promise<TCategory>;
57
+ getCategoryItems: {
58
+ (uid: number, filters: Record<string, unknown>): Promise<TCategoryItemsResult>;
59
+ (uid: number, itemsFilters: TItemsFilters): Promise<TCategoryItemsResult>;
60
+ };
61
+ getCategoryItemsInfinite: (uid: number, itemsFilters?: TItemsFilters, pageParam?: number) => Promise<PaginatedResult<TProductItem>>;
62
+ getItemAttributes: (categoryUid: number) => Promise<{
63
+ attributes: TAttribute[];
64
+ }>;
65
+ getInvMast: (uid: number) => Promise<TInvMast>;
66
+ getInvMastDoc: {
67
+ (params: {
68
+ invMastUid?: number;
69
+ itemId?: string;
70
+ includePricing?: "Y" | "N";
71
+ }): Promise<TInvMastDoc>;
72
+ (invMastUid: number, itemId?: string, includePricing?: "Y" | "N"): Promise<TInvMastDoc>;
73
+ };
74
+ getStock: (invMastUid: number) => Promise<TStock>;
75
+ getStockCompanySummary: (invMastUid: number) => Promise<Record<string, number>>;
76
+ getItemFaqs: (invMastUid: number) => Promise<ListResult>;
77
+ getItemSubstitutes: (invMastUid: number) => Promise<ListResult>;
78
+ getItemAccessories: (invMastUid: number) => Promise<ListResult<TItemAccessory>>;
79
+ getSimilarItems: (invMastUid: number) => Promise<ListResult>;
80
+ batchGetInvMastDocs: (params: {
81
+ invMastUid?: number;
82
+ itemId?: string;
83
+ }[]) => Promise<Record<string, TInvMastDoc>>;
84
+ batchGetStockData: (invMastUids: number[]) => Promise<Record<number, TStock>>;
85
+ }
86
+
11
87
  interface CommerceActions {
12
88
  cartHdrLookup: (params: {
13
89
  userId?: string | number;
@@ -32,10 +108,75 @@ interface CommerceActions {
32
108
  checkoutOrder: (cartHdrUid: number, data: Record<string, unknown>) => Promise<TCheckoutResult>;
33
109
  }
34
110
 
111
+ /** Paginated response for infinite scroll. */
112
+ interface SearchPage {
113
+ data: TProductItem[];
114
+ total: number;
115
+ nextCursor?: number;
116
+ }
117
+ interface SearchActions {
118
+ getSearchAttributes: (q: string) => Promise<{
119
+ attributes: TAttribute[];
120
+ }>;
121
+ getSearchSuggestions: (q: string, limit?: number, offset?: number) => Promise<TSearchSuggestionsResponse>;
122
+ itemSearch: (filters: {
123
+ q: string;
124
+ limit: number;
125
+ offset: number;
126
+ sortBy?: string;
127
+ filters?: [string, string][];
128
+ }, itemCategoryUid?: number | string) => Promise<{
129
+ items: TProductItem[];
130
+ totalResults: number;
131
+ }>;
132
+ itemSearchInfinite: (filters: {
133
+ q: string;
134
+ limit: number;
135
+ sortBy?: string;
136
+ filters?: [string, string][];
137
+ }, itemCategoryUid?: number | string, pageParam?: number) => Promise<SearchPage>;
138
+ }
139
+
35
140
  interface OrderActions {
36
141
  getOrderDoc: (orderNo: string, postalCode: string) => Promise<unknown>;
37
142
  }
38
143
 
144
+ interface ShippingAddress {
145
+ address1: string;
146
+ city: string;
147
+ state: string;
148
+ postalCode: string;
149
+ country?: string;
150
+ }
151
+ interface ShippingActions {
152
+ getShippingRates: (toAddress: ShippingAddress, weight: number, serviceCodes?: string[]) => Promise<ListResult<TShippingMethod>>;
153
+ }
154
+
155
+ interface NormalizedUserProfile {
156
+ id: string;
157
+ name: string;
158
+ email: string;
159
+ customerId: string;
160
+ permissions: string[];
161
+ }
162
+ interface JoomlaActions {
163
+ getJoomlaContent: {
164
+ (articleId: number): Promise<TJoomlaContent>;
165
+ (articleId: number | string, options: {
166
+ alias: string;
167
+ catId?: number;
168
+ }): Promise<TJoomlaContent>;
169
+ };
170
+ getJoomlaContentList: (params?: Record<string, unknown>) => Promise<ListResult<TJoomlaContent>>;
171
+ getJoomlaMenu: {
172
+ (params?: Record<string, unknown>): Promise<ListResult<TMenu>>;
173
+ (parentId: number, menuType: string): Promise<ListResult<TMenu>>;
174
+ };
175
+ getJoomlaMenuDoc: (menuId: number | string) => Promise<MenuItem>;
176
+ getUserProfile: (userId: number | string) => Promise<NormalizedUserProfile>;
177
+ verifyPassword: (username: string, password: string) => Promise<TPasswordVerification>;
178
+ }
179
+
39
180
  interface LegacyActions {
40
181
  getItemWebDesc: (invMastUid: number) => Promise<TWebDesc | undefined>;
41
182
  getAlsoBoughtItems: (invMastUid: number) => Promise<ListResult<TRelatedProduct>>;
@@ -59,6 +200,18 @@ interface CustomersActions {
59
200
  getShipToAddresses: (customerId: number) => Promise<ListResult>;
60
201
  }
61
202
 
203
+ /** Standardized response from address validation. */
204
+ interface AddressValidationResult {
205
+ data: TSmartyStreets | undefined;
206
+ status: "success" | "not_found" | "error";
207
+ error?: {
208
+ message: string;
209
+ };
210
+ }
211
+ interface SmartyStreetsActions {
212
+ validateAddress: (params: Record<string, unknown>) => Promise<AddressValidationResult>;
213
+ }
214
+
62
215
  interface P21PimActions {
63
216
  getInvMastExt: (invMastUid: number) => Promise<unknown>;
64
217
  listInvMastExt: (params?: Record<string, unknown>) => Promise<ListResult>;
@@ -313,4 +466,4 @@ interface SiteActions {
313
466
  */
314
467
  declare function createSiteActions<TApi extends object>(api: TApi, config?: SiteActionsConfig): SiteActions;
315
468
 
316
- export { type SiteActions as S, type SiteActionsConfig as a, createSiteActions as c };
469
+ export { type PaginatedResult as P, type SiteActions as S, type SiteActionsConfig as a, createSiteActions as c, paginateOffset as p };
package/dist/site.d.ts CHANGED
@@ -1,9 +1,8 @@
1
- import { S as SiteActions, a as SiteActionsConfig } from './site-BdJFUwsM.js';
1
+ import { S as SiteActions, a as SiteActionsConfig } from './site-BjSFqufX.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-utils';
6
- import './smarty-streets-BnEIKoi8.js';
7
6
  import '@simpleapps-com/augur-api';
8
7
 
9
8
  /** Auth options forwarded to NextAuth when creating a server site. */
package/dist/site.js CHANGED
@@ -5,7 +5,7 @@ import {
5
5
  createSiteActions,
6
6
  registerSiteActions,
7
7
  withServerCache
8
- } from "./chunk-4OK7EWLJ.js";
8
+ } from "./chunk-WOHZDFJF.js";
9
9
  import {
10
10
  registerAuthSecret,
11
11
  registerClientFactory,
package/dist/testing.d.ts CHANGED
@@ -1,9 +1,8 @@
1
1
  export { DeepMockClient, MockClientResult, createMockClient } from '@simpleapps-com/augur-core/testing';
2
- export { c as clearSiteActions } from './server-site-registry-vsuD5FAk.js';
3
- import { S as SiteActions } from './site-BdJFUwsM.js';
2
+ export { c as clearSiteActions } from './server-site-registry-CdBfczOj.js';
3
+ import { S as SiteActions } from './site-BjSFqufX.js';
4
4
  import '@simpleapps-com/augur-core';
5
5
  import '@simpleapps-com/augur-utils';
6
- import './smarty-streets-BnEIKoi8.js';
7
6
 
8
7
  /**
9
8
  * A mock function type compatible with both Vitest and Jest.
package/dist/testing.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  clearSiteActions
3
- } from "./chunk-4OK7EWLJ.js";
3
+ } from "./chunk-WOHZDFJF.js";
4
4
  import "./chunk-HPQQYROJ.js";
5
5
  import "./chunk-DGUM43GV.js";
6
6
 
package/llms.txt CHANGED
@@ -24,7 +24,7 @@ Each package ships its own llms.txt with exports and usage patterns.
24
24
 
25
25
  > Server-side utilities for Augur ecommerce sites (Redis caching, SDK helpers, auth)
26
26
 
27
- Version: 2.2.10
27
+ Version: 2.2.29
28
28
 
29
29
  ## @simpleapps-com/augur-server
30
30
 
@@ -85,7 +85,7 @@ const result = await sdkCall(
85
85
 
86
86
  ## @simpleapps-com/augur-server/auth
87
87
 
88
- - function: createAuthConfig
88
+ - function: createAuthConfig - Creates a NextAuth configuration with Joomla credential provider, session callbacks, and automatic cart initialization.
89
89
  - type: AugurAuthCallbacks
90
90
  - type: AugurAuthClient
91
91
  - type: AugurJWT
@@ -156,140 +156,6 @@ export const site = createServerSite(api, {
156
156
  - value: ApiResult
157
157
  - value: ListResult
158
158
  - value: SafeActionResult
159
- - function: accountQuery
160
- - function: addFavorite
161
- - function: addToCart
162
- - function: addWishlistItems
163
- - function: askChatGpt
164
- - function: batchGetInvMastDocs
165
- - function: batchGetItemPrices
166
- - function: batchGetStockData
167
- - function: billingUpdate
168
- - function: calculateTax
169
- - function: cardInfo
170
- - function: cartHdrLookup
171
- - function: checkoutOrder
172
- - function: createBinTransfer
173
- - function: createDocument
174
- - function: createFocus
175
- - function: createReceiving
176
- - function: createTransfer
177
- - function: createWishlist
178
- - function: customerLookup
179
- - function: deleteCartItems
180
- - function: deleteWishlist
181
- - function: generateAkasha
182
- - function: generateJoomla
183
- - function: generateOllama
184
- - function: getAddresses
185
- - function: getAlsoBoughtItems
186
- - function: getBrandFolderCategories
187
- - function: getCartAlsoBought
188
- - function: getCartLines
189
- - function: getCashDrawers
190
- - function: getCategory
191
- - function: getCategoryDefaults
192
- - function: getCategoryItems
193
- - function: getCategoryItemsInfinite
194
- - function: getCodeP21
195
- - function: getComments
196
- - function: getCompanies
197
- - function: getCompany
198
- - function: getContacts
199
- - function: getContext
200
- - function: getCustomer
201
- - function: getCustomerDoc
202
- - function: getCustomerInvoiceDetail
203
- - function: getCustomerInvoices
204
- - function: getCustomerOrderDetail
205
- - function: getCustomerOrders
206
- - function: getCustomerQuoteDetail
207
- - function: getCustomerQuotes
208
- - function: getDistributors
209
- - function: getDocuments
210
- - function: getEvents
211
- - function: getFavorites
212
- - function: getFreightRates
213
- - function: getImport
214
- - function: getImportLines
215
- - function: getInvMast
216
- - function: getInvMastDoc
217
- - function: getInvMastExt
218
- - function: getInventoryProfiles
219
- - function: getItemAccessories
220
- - function: getItemAttributes
221
- - function: getItemCategory
222
- - function: getItemFaqs
223
- - function: getItemPrice
224
- - function: getItemSubstitutes
225
- - function: getItemTags
226
- - function: getItemWebDesc
227
- - function: getJoomlaContent
228
- - function: getJoomlaContentList
229
- - function: getJoomlaMenu
230
- - function: getJoomlaMenuDoc
231
- - function: getLocations
232
- - function: getMetaFiles
233
- - function: getMetrics
234
- - function: getMicroservices
235
- - function: getOrderDoc
236
- - function: getP21Categories
237
- - function: getP21Companies
238
- - function: getPaymentTypes
239
- - function: getPeople
240
- - function: getProducts
241
- - function: getProjects
242
- - function: getPurchaseOrderReceipts
243
- - function: getRates
244
- - function: getRecentImports
245
- - function: getRestockHeaders
246
- - function: getRubrics
247
- - function: getScheduledImports
248
- - function: getSearchAttributes
249
- - function: getSearchSuggestions
250
- - function: getSections
251
- - function: getSettings
252
- - function: getShipToAddresses
253
- - function: getShipVia
254
- - function: getShippingRates
255
- - function: getSimilarItems
256
- - function: getStates
257
- - function: getStock
258
- - function: getStockCompanySummary
259
- - function: getSurcharge
260
- - function: getTaxEstimate
261
- - function: getTodo
262
- - function: getTodolists
263
- - function: getTodos
264
- - function: getTodosSummary
265
- - function: getTransferReceipts
266
- - function: getTransferShipping
267
- - function: getUserProfile
268
- - function: getUsers
269
- - function: getWarehouseAvailability
270
- - function: getWarehouses
271
- - function: getWebDisplayTypeDefaults
272
- - function: getWebDisplayTypes
273
- - function: getWebhooks
274
- - function: getWishlistDetail
275
- - function: getWishlists
276
- - function: healthCheck
277
- - function: itemCategoryLookup
278
- - function: itemSearch
279
- - function: itemSearchInfinite
280
- - function: listInvMastExt
281
- - function: ping
282
- - value: queryAction
283
- - function: refreshContacts
284
- - function: refreshCustomers
285
- - function: removeFavorite
286
- - function: removeWishlistItem
287
- - function: sendWebhook
288
- - function: transactionSetup
289
- - function: updateCartLines
290
- - function: validateAddress
291
- - function: validatePayment
292
- - function: verifyPassword
293
159
 
294
160
  ## @simpleapps-com/augur-server/hooks
295
161
 
@@ -322,8 +188,27 @@ const addToCart = useMutation(q.commerce.cartLine.add.create());
322
188
 
323
189
  ## @simpleapps-com/augur-server/query-action
324
190
 
191
+ - function: getSessionCredentials - Resolve session credentials from the Auth.js JWT cookie.
325
192
  - function: queryAction - Generic server action that routes any SDK method call through the raw
193
+ - function: resetSessionImports - Reset lazy-loaded imports. Used in tests only. @internal
194
+ - function: resolveMethod - Resolve a dot-separated method path on an object, returning the leaf function.
326
195
  - function: unwrapBaseResponse - Unwrap SDK BaseResponse if the result matches the standard shape.
327
196
 
197
+ ## @simpleapps-com/augur-server/api
198
+
199
+ - function: createAugurApiHandler - Creates a Next.js Route Handler that routes method calls through queryAction.
200
+
201
+ ### Examples
202
+
203
+ createAugurApiHandler:
204
+ ```ts
205
+ // app/api/augur/route.ts
206
+ import { createAugurApiHandler } from "@simpleapps-com/augur-server/api";
207
+
208
+ const handler = createAugurApiHandler();
209
+ export const POST = handler;
210
+ ```
211
+
212
+
328
213
  ## @simpleapps-com/augur-server/next-auth
329
214
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@simpleapps-com/augur-server",
3
- "version": "2.2.28",
3
+ "version": "2.3.0",
4
4
  "description": "Server-side utilities for Augur ecommerce sites (Redis caching, SDK helpers, auth)",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -58,9 +58,9 @@
58
58
  "llms.txt"
59
59
  ],
60
60
  "dependencies": {
61
- "@simpleapps-com/augur-core": "2.2.28",
62
- "@simpleapps-com/augur-hooks": "2.2.28",
63
- "@simpleapps-com/augur-utils": "2.2.28"
61
+ "@simpleapps-com/augur-core": "2.3.0",
62
+ "@simpleapps-com/augur-hooks": "2.3.0",
63
+ "@simpleapps-com/augur-utils": "2.3.0"
64
64
  },
65
65
  "peerDependencies": {
66
66
  "@simpleapps-com/augur-api": "^2026.4.6",
@@ -88,7 +88,7 @@
88
88
  "tsup": "^8.5.0",
89
89
  "vitest": "^3.2.0",
90
90
  "@augur-packages/tsconfig": "0.0.0",
91
- "@simpleapps-com/augur-hooks": "2.2.28"
91
+ "@simpleapps-com/augur-hooks": "2.3.0"
92
92
  },
93
93
  "scripts": {
94
94
  "build": "tsup",