@simpleapps-com/augur-server
v2.3.1
Published
Server-side utilities for Augur ecommerce sites (Redis caching, SDK helpers, auth)
Readme
@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
pnpm add @simpleapps-com/augur-serverPeer 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 | 3 exports, 0 types |
| @simpleapps-com/augur-server/hooks | 2 exports, 0 types |
| @simpleapps-com/augur-server/query-action | 5 exports, 0 types |
| @simpleapps-com/augur-server/api | 1 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 | Creates a NextAuth configuration with Joomla credential provider, session callbacks, and automatic cart initialization. |
| 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 |
| getSessionCredentials | function | Resolve session credentials from the Auth.js JWT cookie. |
| resetSessionImports | function | Reset lazy-loaded imports. Used in tests only. @internal |
Items & Categories
| Export | Kind | Description |
|--------|------|-------------|
| isProduction | const | true when running on the production deployment. |
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 | |
| 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 |
| resolveMethod | function | Resolve a dot-separated method path on an object, returning the leaf function. |
| createAugurApiHandler | function | Creates a Next.js Route Handler that routes method calls through queryAction. |
Examples
safeAction
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
const result = await sdkCall(
augurServices.items.invMast.get,
invMastUid,
{ edgeCache: 4 },
);createMockSiteActions
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
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
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());createAugurApiHandler
// app/api/augur/route.ts
import { createAugurApiHandler } from "@simpleapps-com/augur-server/api";
const handler = createAugurApiHandler();
export const POST = handler;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) |
