Augur

augur-core

Universal foundation — proxy infrastructure, cache keys, method classification, and shared types.

@simpleapps-com/augur-core

Universal foundation for all Augur consumers — zero framework dependencies. Powers augur-hooks, augur-server, and any future consumer (mobile, CLI, agents). Runs anywhere JavaScript runs.

Every SDK method is covered automatically via Proxy. No hand-written wrappers needed.

npm install @simpleapps-com/augur-core

Entry Points

ImportEnvironmentPurpose
augur-coreUniversalProxy factories, method classification, cache tiers, key builders, shared types
augur-core/testingTestcreateMockClient and mock types for testing

Proxy Factories

ExportDescription
createOptionsProxy(api)Returns TanStack Query options (queryKey, queryFn, staleTime, gcTime) for every SDK method
createActionsProxy(api, config?)Returns direct async actions for every SDK method with optional pre/post transforms
createDeepProxy(api, config, handler)Low-level factory for building custom proxy consumers
import { createOptionsProxy, createActionsProxy } from "@simpleapps-com/augur-core";
import { AugurAPI } from "@simpleapps-com/augur-api";

const api = new AugurAPI({ siteId: "my-site" });

// Query options — use with TanStack Query
const q = createOptionsProxy(api);
// q.items.invMast.stock.get(42) → { queryKey, queryFn, staleTime, gcTime }

// Direct actions — use in server actions, CLI, agents
const actions = createActionsProxy(api);
// await actions.items.invMast.stock.get(42) → stock data

Method Classification

SDK leaf methods are classified by name:

Method nameHTTPTypeTanStack
getGETreadUseQueryOptions
listGETreadUseQueryOptions
lookupGETreadUseQueryOptions
searchGETreadUseQueryOptions
suggestGETreadUseQueryOptions
createPOSTwriteUseMutationOptions
updatePUTwriteUseMutationOptions
deleteDELETEwriteUseMutationOptions
enablePUTwriteUseMutationOptions

Cache Tier Resolution

Every query is assigned a cache tier based on its SDK path:

TierstaleTimegcTimeUse casePaths
static60 min120 minReference dataagrSite.settings, items.categories, items.brands, p21Core.company, joomla.menu, legacy.state, and more
semiStatic1 min5 minFrequently-read dataDefault for everything not static or none
none00Real-time operationscommerce.*

Key Builders

ExportDescription
buildQueryKey(path, args)Deterministic query key array — identical on server and client for SSR hydration
buildCacheKey(prefix, methodPath, args)Redis/edge cache key with FNV-1a hash
stableStringify(value)Deterministic JSON with sorted keys
fnv1a(str)Fast non-cryptographic hash
import { buildQueryKey } from "@simpleapps-com/augur-core";

buildQueryKey(["items", "invMast", "stock", "get"], [42]);
// → ["items", "invMast", "stock", "get", 42]

Shared Types

TypeDescription
AugurAuthContextCustomer ID, contact ID, session, token
CacheConfigStatic + semiStatic tier settings
CacheTierConfigstaleTime, gcTime, edgeCache, redisTtl per tier
EdgeCacheValueCached response wrapper with timestamp
InfiniteScrollPagePage shape for infinite scroll queries
DeepQueryOptions<T>Mapped type — transforms SDK into query options tree
DeepActions<T>Mapped type — transforms SDK into async actions tree