npm package: @simpleapps-com/augur-server
Description: Server-side utilities for Augur ecommerce sites (Redis caching, SDK helpers, auth)
Latest version: 2.2.29

# @simpleapps-com/augur-server

> Server-side utilities for Augur ecommerce sites (Redis caching, SDK helpers, auth)

> Auto-generated. Do not edit manually. Regenerate with: `pnpm run generate-exports`

Part of the **@simpleapps-com/augur-\*** platform. All packages use fixed versioning (same version number).

## Install

```bash
pnpm add @simpleapps-com/augur-server
```

### Peer Dependencies

`@simpleapps-com/augur-api`, `@tanstack/react-query`, `ioredis`, `next`, `next-auth`, `react`

## Entry Points

| Import | Description |
|--------|-------------|
| `@simpleapps-com/augur-server` | 27 exports, 3 types |
| `@simpleapps-com/augur-server/auth` | 1 exports, 6 types |
| `@simpleapps-com/augur-server/query` | 2 exports, 1 types |
| `@simpleapps-com/augur-server/testing` | 5 exports, 3 types |
| `@simpleapps-com/augur-server/site` | 1 exports, 3 types |
| `@simpleapps-com/augur-server/actions` | 137 exports, 0 types |
| `@simpleapps-com/augur-server/hooks` | 2 exports, 0 types |
| `@simpleapps-com/augur-server/query-action` | 2 exports, 0 types |
| `@simpleapps-com/augur-server/next-auth` | 0 exports, 0 types |

## Exports

### Auth & Context

| Export | Kind | Description |
|--------|------|-------------|
| `QueryOptionsConfig` | value |  |
| `createQueryOptions` | value |  |
| `createSiteActions` | function |  |
| `createSuspenseQueryOptions` | value |  |
| `getSiteActions` | function |  |
| `registerSiteActions` | function |  |
| `createAuthConfig` | function |  |
| `createQueryOptions` | const | Creates useQuery options with consistent key generation. |
| `createSuspenseQueryOptions` | const | Creates useSuspenseQuery options with consistent key generation. |
| `clearSiteActions` | function |  |
| `createMockSiteActions` | function | Creates a fully-mocked SiteActions object for testing. |
| `createServerSite` | function | Create a server-side site instance that bundles the SDK client, server |

### Cart

| Export | Kind | Description |
|--------|------|-------------|
| `addToCart` | function |  |
| `cartHdrLookup` | function |  |
| `deleteCartItems` | function |  |
| `getCartAlsoBought` | function |  |
| `getCartLines` | function |  |
| `updateCartLines` | function |  |

### Items & Categories

| Export | Kind | Description |
|--------|------|-------------|
| `isProduction` | const | `true` when running on the production deployment. |
| `addWishlistItems` | function |  |
| `batchGetInvMastDocs` | function |  |
| `getAlsoBoughtItems` | function |  |
| `getCategory` | function |  |
| `getCategoryDefaults` | function |  |
| `getCategoryItems` | function |  |
| `getCategoryItemsInfinite` | function |  |
| `getInvMast` | function |  |
| `getInvMastDoc` | function |  |
| `getInvMastExt` | function |  |
| `getItemAccessories` | function |  |
| `getItemAttributes` | function |  |
| `getItemCategory` | function |  |
| `getItemFaqs` | function |  |
| `getItemSubstitutes` | function |  |
| `getItemTags` | function |  |
| `getItemWebDesc` | function |  |
| `getProducts` | function |  |
| `getSimilarItems` | function |  |
| `itemCategoryLookup` | function |  |
| `listInvMastExt` | function |  |
| `removeWishlistItem` | function |  |

### Orders

| Export | Kind | Description |
|--------|------|-------------|
| `getCustomerOrderDetail` | function |  |
| `getCustomerOrders` | function |  |
| `getOrderDoc` | function |  |
| `getPurchaseOrderReceipts` | function |  |

### Payment & Checkout

| Export | Kind | Description |
|--------|------|-------------|
| `billingUpdate` | function |  |
| `checkoutOrder` | function |  |
| `getPaymentTypes` | function |  |
| `getSurcharge` | function |  |
| `transactionSetup` | function |  |
| `validatePayment` | function |  |

### Pricing

| Export | Kind | Description |
|--------|------|-------------|
| `batchGetItemPrices` | function |  |
| `getItemPrice` | function |  |

### Search

| Export | Kind | Description |
|--------|------|-------------|
| `getSearchAttributes` | function |  |
| `getSearchSuggestions` | function |  |
| `itemSearch` | function |  |
| `itemSearchInfinite` | function |  |

### Shipping & Address

| Export | Kind | Description |
|--------|------|-------------|
| `getAddresses` | function |  |
| `getShipToAddresses` | function |  |
| `getShipVia` | function |  |
| `getShippingRates` | function |  |
| `getTransferShipping` | function |  |
| `validateAddress` | function |  |

### Stock

| Export | Kind | Description |
|--------|------|-------------|
| `batchGetStockData` | function |  |
| `getRestockHeaders` | function |  |
| `getStock` | function |  |
| `getStockCompanySummary` | function |  |

### Transforms

| Export | Kind | Description |
|--------|------|-------------|
| `paginateOffset` | function |  |

### Utilities

| Export | Kind | Description |
|--------|------|-------------|
| `unwrap` | value |  |
| `unwrapOr` | value |  |
| `unwrapBaseResponse` | function | Unwrap SDK BaseResponse if the result matches the standard shape. |

### Other

| Export | Kind | Description |
|--------|------|-------------|
| `ActionResult` | value |  |
| `EdgeCacheValue` | value |  |
| `SafeActionResult` | value |  |
| `batchFetch` | function | Fetches data for multiple params in parallel, returning a Record keyed by |
| `cacheGet` | function | Read a cached value by key. |
| `cacheSet` | function | Write a value to cache with a TTL. Fire-and-forget semantics: no-ops |
| `createServerQueryClient` | function | Creates a server-side query client optimised for prefetching. |
| `env` | const | Resolved environment: `"development"`, `"staging"`, or `"production"`. |
| `getCircuitState` | function | Returns the current circuit breaker state. |
| `getServerQueryClient` | const | Returns a per-request singleton QueryClient for React Server Components. |
| `isDev` | const | `true` when running locally (localhost / NODE_ENV=development). |
| `isRedisConnected` | function | Whether the Redis client is connected and ready to accept commands. |
| `isStaging` | const | `true` when running on the staging/dev deployment. |
| `safeAction` | function | Wraps an async function call with error handling, returning a |
| `sdkCall` | function | Calls an Augur SDK method, forwarding all arguments with full type safety. |
| `verifyRecaptcha` | function | Server-side Google reCAPTCHA v3 verification. |
| `withServerCache` | function | Server-side cache wrapper using augur-server's Redis client. |
| `DeepMockClient` | value |  |
| `MockClientResult` | value |  |
| `createMockClient` | value |  |
| `ApiResult` | value |  |
| `ListResult` | value |  |
| `SafeActionResult` | value |  |
| `accountQuery` | function |  |
| `addFavorite` | function |  |
| `askChatGpt` | function |  |
| `calculateTax` | function |  |
| `cardInfo` | function |  |
| `createBinTransfer` | function |  |
| `createDocument` | function |  |
| `createFocus` | function |  |
| `createReceiving` | function |  |
| `createTransfer` | function |  |
| `createWishlist` | function |  |
| `customerLookup` | function |  |
| `deleteWishlist` | function |  |
| `generateAkasha` | function |  |
| `generateJoomla` | function |  |
| `generateOllama` | function |  |
| `getBrandFolderCategories` | function |  |
| `getCashDrawers` | function |  |
| `getCodeP21` | function |  |
| `getComments` | function |  |
| `getCompanies` | function |  |
| `getCompany` | function |  |
| `getContacts` | function |  |
| `getContext` | function |  |
| `getCustomer` | function |  |
| `getCustomerDoc` | function |  |
| `getCustomerInvoiceDetail` | function |  |
| `getCustomerInvoices` | function |  |
| `getCustomerQuoteDetail` | function |  |
| `getCustomerQuotes` | function |  |
| `getDistributors` | function |  |
| `getDocuments` | function |  |
| `getEvents` | function |  |
| `getFavorites` | function |  |
| `getFreightRates` | function |  |
| `getImport` | function |  |
| `getImportLines` | function |  |
| `getInventoryProfiles` | function |  |
| `getJoomlaContent` | function |  |
| `getJoomlaContentList` | function |  |
| `getJoomlaMenu` | function |  |
| `getJoomlaMenuDoc` | function |  |
| `getLocations` | function |  |
| `getMetaFiles` | function |  |
| `getMetrics` | function |  |
| `getMicroservices` | function |  |
| `getP21Categories` | function |  |
| `getP21Companies` | function |  |
| `getPeople` | function |  |
| `getProjects` | function |  |
| `getRates` | function |  |
| `getRecentImports` | function |  |
| `getRubrics` | function |  |
| `getScheduledImports` | function |  |
| `getSections` | function |  |
| `getSettings` | function |  |
| `getStates` | function |  |
| `getTaxEstimate` | function |  |
| `getTodo` | function |  |
| `getTodolists` | function |  |
| `getTodos` | function |  |
| `getTodosSummary` | function |  |
| `getTransferReceipts` | function |  |
| `getUserProfile` | function |  |
| `getUsers` | function |  |
| `getWarehouseAvailability` | function |  |
| `getWarehouses` | function |  |
| `getWebDisplayTypeDefaults` | function |  |
| `getWebDisplayTypes` | function |  |
| `getWebhooks` | function |  |
| `getWishlistDetail` | function |  |
| `getWishlists` | function |  |
| `healthCheck` | function |  |
| `ping` | function |  |
| `queryAction` | value |  |
| `refreshContacts` | function |  |
| `refreshCustomers` | function |  |
| `removeFavorite` | function |  |
| `sendWebhook` | function |  |
| `verifyPassword` | function |  |
| `QueryActionFn` | value |  |
| `createServerQueryProxy` | function | Creates a client-side proxy that mirrors the SDK namespace and routes |
| `queryAction` | function | Generic server action that routes any SDK method call through the raw |

## Examples

### safeAction

```ts
const result = await safeAction(
  () => actions.commerce.addToCart(cartId, items),
);
if (result.ok) {
  // result.data is the response data (undefined for void actions)
} else {
  // result.error is the error message
}
```

### sdkCall

```ts
const result = await sdkCall(
  augurServices.items.invMast.get,
  invMastUid,
  { edgeCache: 4 },
);
```

### createMockSiteActions

```ts
import { createMockSiteActions } from "@simpleapps-com/augur-server/testing";

const { actions, mocks } = createMockSiteActions();

// Setup return values
mocks.pricing.getItemPrice.mockResolvedValue({ price: 9.99 });

// Pass actions to your component/server action
const price = await actions.pricing.getItemPrice("ITEM-1");

// Assert calls
expect(mocks.pricing.getItemPrice.mock.calls[0]).toEqual(["ITEM-1"]);
```

### createServerSite

```ts
import { AugurApi } from "@simpleapps-com/augur-api";
import { createServerSite } from "@simpleapps-com/augur-server";

const api = new AugurApi({ baseUrl: process.env.AUGUR_API_URL! });
export const site = createServerSite(api, {
  defaultCustomerId: "12345",
  auth: { secret: process.env.AUTH_SECRET },
});
```

### createServerQueryProxy

```tsx
import { createServerQueryProxy } from "@simpleapps-com/augur-server/hooks";

const q = createServerQueryProxy();

// Reads — any SDK method, routed through server actions
const { data: item } = useQuery(q.items.invMast.doc.get(42));
const { data: price } = useQuery(q.pricing.priceEngine.get({ itemId, customerId }));

// Infinite queries — spread and add infinite-specific options
const { data, fetchNextPage } = useInfiniteQuery({
  ...q.items.itemCategory.categoryItems.get(uid, filters),
  getNextPageParam: (lastPage) => lastPage.nextCursor,
  initialPageParam: 0,
});

// Mutations — write methods return mutation options
const addToCart = useMutation(q.commerce.cartLine.add.create());
```

## Types

`PaginatedResult`, `SiteActions`, `SiteActionsConfig`, `AugurAuthCallbacks`, `AugurAuthClient`, `AugurJWT`, `AugurSession`, `AugurUser`, `CreateAuthConfigOptions`, `QueryOptionsConfig`, `MockFn`, `MockSiteActions`, `MockSiteActionsResult`, `ServerSite`, `ServerSiteAuthConfig`, `ServerSiteConfig`


## Related Packages

All packages use fixed versioning -- same version number across the platform.

| Package | Description |
|---------|-------------|
| `@simpleapps-com/augur-config` | Shared tooling configuration presets for Augur ecommerce sites |
| `@simpleapps-com/augur-core` | Universal foundation for Augur packages — proxy infrastructure, cache keys, method classification, shared types |
| `@simpleapps-com/augur-hooks` | Cross-platform React Query hooks and Zustand stores for Augur ecommerce sites |
| `@simpleapps-com/augur-mobile` | React Native/Expo adapters for Augur ecommerce apps (offline sync, biometrics, push) |
| `@simpleapps-com/augur-tailwind` | Shared Tailwind CSS v4 theme with HSL variables for Augur ecommerce sites |
| `@simpleapps-com/augur-utils` | Shared types, cache configuration, and utility functions for Augur ecommerce sites |
| `@simpleapps-com/augur-web` | Shared React UI components for Augur ecommerce sites (Radix + Tailwind) |