@simpleapps-com/augur-server 2.4.0 → 2026.11.2
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.
- package/EXPORTS.md +30 -73
- package/README.md +29 -198
- package/dist/actions/agr-info.d.ts +44 -0
- package/dist/actions/agr-info.d.ts.map +1 -0
- package/dist/actions/agr-site.d.ts +38 -0
- package/dist/actions/agr-site.d.ts.map +1 -0
- package/dist/actions/agr-work.d.ts +29 -0
- package/dist/actions/agr-work.d.ts.map +1 -0
- package/dist/actions/avalara.d.ts +38 -0
- package/dist/actions/avalara.d.ts.map +1 -0
- package/dist/actions/basecamp2.d.ts +48 -0
- package/dist/actions/basecamp2.d.ts.map +1 -0
- package/dist/actions/brand-folder.d.ts +39 -0
- package/dist/actions/brand-folder.d.ts.map +1 -0
- package/dist/actions/commerce.d.ts +58 -0
- package/dist/actions/commerce.d.ts.map +1 -0
- package/dist/actions/customers.d.ts +45 -0
- package/dist/actions/customers.d.ts.map +1 -0
- package/dist/actions/favorites.d.ts +21 -0
- package/dist/actions/favorites.d.ts.map +1 -0
- package/dist/actions/gregorovich.d.ts +35 -0
- package/dist/actions/gregorovich.d.ts.map +1 -0
- package/dist/actions/items.d.ts +81 -0
- package/dist/actions/items.d.ts.map +1 -0
- package/dist/actions/joomla.d.ts +60 -0
- package/dist/actions/joomla.d.ts.map +1 -0
- package/dist/actions/legacy.d.ts +46 -0
- package/dist/actions/legacy.d.ts.map +1 -0
- package/dist/actions/logistics.d.ts +41 -0
- package/dist/actions/logistics.d.ts.map +1 -0
- package/dist/actions/orders.d.ts +37 -0
- package/dist/actions/orders.d.ts.map +1 -0
- package/dist/actions/p21-apis.d.ts +34 -0
- package/dist/actions/p21-apis.d.ts.map +1 -0
- package/dist/actions/p21-core.d.ts +47 -0
- package/dist/actions/p21-core.d.ts.map +1 -0
- package/dist/actions/p21-pim.d.ts +37 -0
- package/dist/actions/p21-pim.d.ts.map +1 -0
- package/dist/actions/p21-sism.d.ts +38 -0
- package/dist/actions/p21-sism.d.ts.map +1 -0
- package/dist/actions/payments.d.ts +39 -0
- package/dist/actions/payments.d.ts.map +1 -0
- package/dist/actions/pricing.d.ts +46 -0
- package/dist/actions/pricing.d.ts.map +1 -0
- package/dist/actions/search.d.ts +62 -0
- package/dist/actions/search.d.ts.map +1 -0
- package/dist/actions/shipping.d.ts +57 -0
- package/dist/actions/shipping.d.ts.map +1 -0
- package/dist/actions/site.d.ts +142 -0
- package/dist/actions/site.d.ts.map +1 -0
- package/dist/actions/smarty-streets.d.ts +45 -0
- package/dist/actions/smarty-streets.d.ts.map +1 -0
- package/dist/actions/vmi.d.ts +45 -0
- package/dist/actions/vmi.d.ts.map +1 -0
- package/dist/actions/wishlists.d.ts +29 -0
- package/dist/actions/wishlists.d.ts.map +1 -0
- package/dist/api-handler.d.ts +25 -0
- package/dist/api-handler.d.ts.map +1 -0
- package/dist/api.d.ts +2 -26
- package/dist/api.d.ts.map +1 -0
- package/dist/api.js +19 -14
- package/dist/api.js.map +1 -1
- package/dist/auth.d.ts +10 -12
- package/dist/auth.d.ts.map +1 -0
- package/dist/auth.js +2 -2
- package/dist/cache/redis-client.d.ts +18 -0
- package/dist/cache/redis-client.d.ts.map +1 -0
- package/dist/cache/with-cache.d.ts +17 -0
- package/dist/cache/with-cache.d.ts.map +1 -0
- package/dist/{chunk-PIYHMA6F.js → chunk-6CSVIBHQ.js} +15 -18
- package/dist/chunk-6CSVIBHQ.js.map +1 -0
- package/dist/{chunk-ALTIINP6.js → chunk-A4IVBK6P.js} +30 -6
- package/dist/chunk-A4IVBK6P.js.map +1 -0
- package/dist/{chunk-KHFEDL47.js → chunk-INVDQQ7T.js} +18 -12
- package/dist/chunk-INVDQQ7T.js.map +1 -0
- package/dist/{chunk-26WZBC4F.js → chunk-LX7SJJOU.js} +275 -667
- package/dist/chunk-LX7SJJOU.js.map +1 -0
- package/dist/chunk-OBWQSGB6.js +205 -0
- package/dist/chunk-OBWQSGB6.js.map +1 -0
- package/dist/{chunk-2NL4QKJN.js → chunk-UVGG74FO.js} +31 -30
- package/dist/chunk-UVGG74FO.js.map +1 -0
- package/dist/duration.d.ts +16 -0
- package/dist/duration.d.ts.map +1 -0
- package/dist/environment.d.ts +10 -0
- package/dist/environment.d.ts.map +1 -0
- package/dist/hooks.d.ts +8 -10
- package/dist/hooks.d.ts.map +1 -0
- package/dist/hooks.js +3 -3
- package/dist/hooks.js.map +1 -1
- package/dist/index.d.ts +16 -125
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +9 -7
- package/dist/index.js.map +1 -1
- package/dist/pagination.d.ts +32 -0
- package/dist/pagination.d.ts.map +1 -0
- package/dist/query-action.d.ts +15 -117
- package/dist/query-action.d.ts.map +1 -0
- package/dist/query-action.js +3 -3
- package/dist/query-options-helper.d.ts +34 -0
- package/dist/query-options-helper.d.ts.map +1 -0
- package/dist/query.js +1 -2
- package/dist/recaptcha.d.ts +6 -0
- package/dist/recaptcha.d.ts.map +1 -0
- package/dist/rules.d.ts +230 -0
- package/dist/rules.d.ts.map +1 -0
- package/dist/scoped-client-key.d.ts +9 -0
- package/dist/scoped-client-key.d.ts.map +1 -0
- package/dist/sdk-call.d.ts +66 -0
- package/dist/sdk-call.d.ts.map +1 -0
- package/dist/sdk-client-store.d.ts +250 -0
- package/dist/sdk-client-store.d.ts.map +1 -0
- package/dist/server-actions.d.ts +2 -0
- package/dist/server-actions.d.ts.map +1 -0
- package/dist/server-query-client.d.ts +19 -0
- package/dist/server-query-client.d.ts.map +1 -0
- package/dist/{server-site-registry-CdBfczOj.d.ts → server-site-registry.d.ts} +7 -9
- package/dist/server-site-registry.d.ts.map +1 -0
- package/dist/{site.d.ts → server-site.d.ts} +11 -16
- package/dist/server-site.d.ts.map +1 -0
- package/dist/site-actions-store.d.ts +27 -0
- package/dist/site-actions-store.d.ts.map +1 -0
- package/dist/site.js +15 -14
- package/dist/site.js.map +1 -1
- package/dist/testing.d.ts +9 -12
- package/dist/testing.d.ts.map +1 -0
- package/dist/testing.js +7 -27
- package/dist/testing.js.map +1 -1
- package/dist/utils/batch-fetch.d.ts +7 -0
- package/dist/utils/batch-fetch.d.ts.map +1 -0
- package/llms.txt +72 -51
- package/package.json +30 -20
- package/dist/actions.d.ts +0 -2
- package/dist/chunk-26WZBC4F.js.map +0 -1
- package/dist/chunk-2NL4QKJN.js.map +0 -1
- package/dist/chunk-ALTIINP6.js.map +0 -1
- package/dist/chunk-DGUM43GV.js +0 -11
- package/dist/chunk-DGUM43GV.js.map +0 -1
- package/dist/chunk-KHFEDL47.js.map +0 -1
- package/dist/chunk-PIYHMA6F.js.map +0 -1
- package/dist/query.d.ts +0 -35
- package/dist/site-BjSFqufX.d.ts +0 -469
|
@@ -1,23 +1,19 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { AugurAuthCallbacks } from
|
|
3
|
-
import { NextAuthConfig } from
|
|
4
|
-
import '@simpleapps-com/augur-core';
|
|
5
|
-
import '@simpleapps-com/augur-utils';
|
|
6
|
-
import '@simpleapps-com/augur-api';
|
|
7
|
-
|
|
1
|
+
import type { SiteActionsConfig, SiteActions } from "./actions/site";
|
|
2
|
+
import type { AugurAuthCallbacks } from "./auth";
|
|
3
|
+
import type { NextAuthConfig } from "next-auth";
|
|
8
4
|
/** Auth options forwarded to NextAuth when creating a server site. */
|
|
9
|
-
interface ServerSiteAuthConfig {
|
|
5
|
+
export interface ServerSiteAuthConfig {
|
|
10
6
|
secret?: string;
|
|
11
7
|
maxAge?: number;
|
|
12
8
|
callbacks?: Partial<AugurAuthCallbacks>;
|
|
13
9
|
debug?: boolean;
|
|
14
10
|
}
|
|
15
11
|
/** Configuration for {@link createServerSite}, combining action config and auth. */
|
|
16
|
-
interface ServerSiteConfig extends SiteActionsConfig {
|
|
12
|
+
export interface ServerSiteConfig extends SiteActionsConfig {
|
|
17
13
|
auth?: ServerSiteAuthConfig;
|
|
18
14
|
}
|
|
19
15
|
/** The object returned by {@link createServerSite}. */
|
|
20
|
-
interface ServerSite<TApi extends object> {
|
|
16
|
+
export interface ServerSite<TApi extends object> {
|
|
21
17
|
client: TApi;
|
|
22
18
|
actions: SiteActions;
|
|
23
19
|
auth: NextAuthConfig | undefined;
|
|
@@ -28,16 +24,15 @@ interface ServerSite<TApi extends object> {
|
|
|
28
24
|
*
|
|
29
25
|
* @example
|
|
30
26
|
* ```ts
|
|
31
|
-
* import {
|
|
32
|
-
* import { createServerSite } from "@simpleapps-com/augur-server";
|
|
27
|
+
* import { AugurAPI } from "@simpleapps-com/augur-api";
|
|
28
|
+
* import { createServerSite } from "@simpleapps-com/augur-server/site";
|
|
33
29
|
*
|
|
34
|
-
* const api = new
|
|
30
|
+
* const api = new AugurAPI({ siteId: process.env.AUGUR_SITE_ID!, bearerToken: process.env.AUGUR_JWT! });
|
|
35
31
|
* export const site = createServerSite(api, {
|
|
36
32
|
* defaultCustomerId: "12345",
|
|
37
33
|
* auth: { secret: process.env.AUTH_SECRET },
|
|
38
34
|
* });
|
|
39
35
|
* ```
|
|
40
36
|
*/
|
|
41
|
-
declare function createServerSite<TApi extends object>(client: TApi, config?: ServerSiteConfig): ServerSite<TApi>;
|
|
42
|
-
|
|
43
|
-
export { type ServerSite, type ServerSiteAuthConfig, type ServerSiteConfig, createServerSite };
|
|
37
|
+
export declare function createServerSite<TApi extends object>(client: TApi, config?: ServerSiteConfig): ServerSite<TApi>;
|
|
38
|
+
//# sourceMappingURL=server-site.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server-site.d.ts","sourceRoot":"","sources":["../src/server-site.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,iBAAiB,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAErE,OAAO,KAAK,EAAE,kBAAkB,EAAmB,MAAM,QAAQ,CAAC;AAClE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAahD,sEAAsE;AACtE,MAAM,WAAW,oBAAoB;IACnC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,SAAS,CAAC,EAAE,OAAO,CAAC,kBAAkB,CAAC,CAAC;IACxC,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB;AAED,oFAAoF;AACpF,MAAM,WAAW,gBAAiB,SAAQ,iBAAiB;IACzD,IAAI,CAAC,EAAE,oBAAoB,CAAC;CAC7B;AAED,uDAAuD;AACvD,MAAM,WAAW,UAAU,CAAC,IAAI,SAAS,MAAM;IAC7C,MAAM,EAAE,IAAI,CAAC;IACb,OAAO,EAAE,WAAW,CAAC;IACrB,IAAI,EAAE,cAAc,GAAG,SAAS,CAAC;CAClC;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,SAAS,MAAM,EAClD,MAAM,EAAE,IAAI,EACZ,MAAM,GAAE,gBAAqB,GAC5B,UAAU,CAAC,IAAI,CAAC,CAsDlB"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Lightweight getter/setter for the site actions singleton.
|
|
3
|
+
*
|
|
4
|
+
* This module has ZERO imports from actions/site or any factory module.
|
|
5
|
+
* queryAction imports from here so that its bundle chunk does not
|
|
6
|
+
* transitively pull in ioredis, withServerCache, or any other server-only
|
|
7
|
+
* dependency.
|
|
8
|
+
*
|
|
9
|
+
* The heavy auto-init-from-env fallback lives in server-site-registry.ts,
|
|
10
|
+
* which is only imported by server-side entrypoints (index, actions, site).
|
|
11
|
+
*/
|
|
12
|
+
/**
|
|
13
|
+
* Stores the site actions instance for use by server action exports.
|
|
14
|
+
* Called automatically by {@link createServerSite} via the registry module.
|
|
15
|
+
*/
|
|
16
|
+
export declare function registerSiteActions(actions: unknown): void;
|
|
17
|
+
/**
|
|
18
|
+
* Returns the registered site actions instance, or null if not yet registered.
|
|
19
|
+
* Does NOT auto-init from env — that responsibility belongs to the registry.
|
|
20
|
+
*/
|
|
21
|
+
export declare function getSiteActionsOrNull(): unknown;
|
|
22
|
+
/**
|
|
23
|
+
* Clears the registered site actions. Used in tests only.
|
|
24
|
+
* @internal
|
|
25
|
+
*/
|
|
26
|
+
export declare function clearSiteActions(): void;
|
|
27
|
+
//# sourceMappingURL=site-actions-store.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"site-actions-store.d.ts","sourceRoot":"","sources":["../src/site-actions-store.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAMH;;;GAGG;AACH,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CAG1D;AAED;;;GAGG;AACH,wBAAgB,oBAAoB,IAAI,OAAO,CAS9C;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,IAAI,IAAI,CAGvC"}
|
package/dist/site.js
CHANGED
|
@@ -1,38 +1,39 @@
|
|
|
1
1
|
import {
|
|
2
2
|
createAuthConfig
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-INVDQQ7T.js";
|
|
4
4
|
import {
|
|
5
5
|
createSiteActions,
|
|
6
6
|
registerSiteActions,
|
|
7
|
-
|
|
8
|
-
} from "./chunk-
|
|
7
|
+
withRawSdkCache
|
|
8
|
+
} from "./chunk-LX7SJJOU.js";
|
|
9
9
|
import {
|
|
10
10
|
registerAuthSecret,
|
|
11
11
|
registerClientFactory,
|
|
12
12
|
registerScopedCacheWrapper,
|
|
13
13
|
registerSdkCallWrapper,
|
|
14
14
|
registerSdkClient
|
|
15
|
-
} from "./chunk-
|
|
16
|
-
import
|
|
15
|
+
} from "./chunk-A4IVBK6P.js";
|
|
16
|
+
import {
|
|
17
|
+
ttlFor
|
|
18
|
+
} from "./chunk-OBWQSGB6.js";
|
|
17
19
|
|
|
18
20
|
// src/server-site.ts
|
|
21
|
+
import { hours } from "@simpleapps-com/augur-utils";
|
|
19
22
|
import { getCacheTier } from "@simpleapps-com/augur-core";
|
|
20
23
|
function createServerSite(client, config = {}) {
|
|
21
24
|
const actions = createSiteActions(client, config);
|
|
22
25
|
registerSiteActions(actions);
|
|
23
26
|
registerSdkClient(client);
|
|
24
|
-
const { cachePrefix = "", redisTtl =
|
|
27
|
+
const { cachePrefix = "", redisTtl = hours(1), longRedisTtl = hours(8) } = config;
|
|
25
28
|
registerSdkCallWrapper((methodPath, sdkCall, ...keyArgs) => {
|
|
26
|
-
const
|
|
27
|
-
if (
|
|
28
|
-
|
|
29
|
-
return withServerCache(cachePrefix, ttl, methodPath, sdkCall, ...keyArgs);
|
|
29
|
+
const ttl = ttlFor(getCacheTier(methodPath).staleTime, redisTtl, longRedisTtl);
|
|
30
|
+
if (ttl === null) return sdkCall();
|
|
31
|
+
return withRawSdkCache(cachePrefix, ttl, methodPath, sdkCall, ...keyArgs);
|
|
30
32
|
});
|
|
31
33
|
registerScopedCacheWrapper((prefix, methodPath, sdkCall, ...keyArgs) => {
|
|
32
|
-
const
|
|
33
|
-
if (
|
|
34
|
-
|
|
35
|
-
return withServerCache(prefix, ttl, methodPath, sdkCall, ...keyArgs);
|
|
34
|
+
const ttl = ttlFor(getCacheTier(methodPath).staleTime, redisTtl, longRedisTtl);
|
|
35
|
+
if (ttl === null) return sdkCall();
|
|
36
|
+
return withRawSdkCache(prefix, ttl, methodPath, sdkCall, ...keyArgs);
|
|
36
37
|
});
|
|
37
38
|
const baseConfig = client["config"];
|
|
38
39
|
if (baseConfig) {
|
package/dist/site.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/server-site.ts"],"sourcesContent":["import { createSiteActions } from \"./actions/site\";\nimport type { SiteActionsConfig, SiteActions } from \"./actions/site\";\nimport { createAuthConfig } from \"./auth\";\nimport type { AugurAuthCallbacks, AugurAuthClient } from \"./auth\";\nimport type { NextAuthConfig } from \"next-auth\";\nimport { registerSiteActions } from \"./server-site-registry\";\nimport {\n registerSdkClient,\n registerSdkCallWrapper,\n registerAuthSecret,\n registerClientFactory,\n registerScopedCacheWrapper,\n} from \"./sdk-client-store\";\nimport {
|
|
1
|
+
{"version":3,"sources":["../src/server-site.ts"],"sourcesContent":["import { hours } from \"@simpleapps-com/augur-utils\";\nimport { createSiteActions } from \"./actions/site\";\nimport type { SiteActionsConfig, SiteActions } from \"./actions/site\";\nimport { createAuthConfig } from \"./auth\";\nimport type { AugurAuthCallbacks, AugurAuthClient } from \"./auth\";\nimport type { NextAuthConfig } from \"next-auth\";\nimport { registerSiteActions } from \"./server-site-registry\";\nimport {\n registerSdkClient,\n registerSdkCallWrapper,\n registerAuthSecret,\n registerClientFactory,\n registerScopedCacheWrapper,\n} from \"./sdk-client-store\";\nimport { withRawSdkCache } from \"./cache/with-cache\";\nimport { ttlFor } from \"./rules\";\nimport { getCacheTier } from \"@simpleapps-com/augur-core\";\n\n/** Auth options forwarded to NextAuth when creating a server site. */\nexport interface ServerSiteAuthConfig {\n secret?: string;\n maxAge?: number;\n callbacks?: Partial<AugurAuthCallbacks>;\n debug?: boolean;\n}\n\n/** Configuration for {@link createServerSite}, combining action config and auth. */\nexport interface ServerSiteConfig extends SiteActionsConfig {\n auth?: ServerSiteAuthConfig;\n}\n\n/** The object returned by {@link createServerSite}. */\nexport interface ServerSite<TApi extends object> {\n client: TApi;\n actions: SiteActions;\n auth: NextAuthConfig | undefined;\n}\n\n/**\n * Create a server-side site instance that bundles the SDK client, server\n * actions, and (optional) NextAuth configuration.\n *\n * @example\n * ```ts\n * import { AugurAPI } from \"@simpleapps-com/augur-api\";\n * import { createServerSite } from \"@simpleapps-com/augur-server/site\";\n *\n * const api = new AugurAPI({ siteId: process.env.AUGUR_SITE_ID!, bearerToken: process.env.AUGUR_JWT! });\n * export const site = createServerSite(api, {\n * defaultCustomerId: \"12345\",\n * auth: { secret: process.env.AUTH_SECRET },\n * });\n * ```\n */\nexport function createServerSite<TApi extends object>(\n client: TApi,\n config: ServerSiteConfig = {},\n): ServerSite<TApi> {\n const actions = createSiteActions(client, config);\n registerSiteActions(actions);\n registerSdkClient(client);\n\n // Register a cache wrapper that captures the site's Redis config.\n // queryAction uses this to wrap read methods in Redis caching without\n // importing the cache directly (which would pull ioredis into the client\n // bundle via tsup code splitting). The SDK's raw result is cached, in its\n // own key space (withRawSdkCache, #98); queryAction unwraps after the read.\n const { cachePrefix = \"\", redisTtl = hours(1), longRedisTtl = hours(8) } = config;\n registerSdkCallWrapper((methodPath, sdkCall, ...keyArgs) => {\n // An hour of staleTime or more: the long TTL; any other: the standard; 0: no caching.\n const ttl = ttlFor(getCacheTier(methodPath).staleTime, redisTtl, longRedisTtl);\n if (ttl === null) return sdkCall();\n return withRawSdkCache(cachePrefix, ttl, methodPath, sdkCall, ...keyArgs);\n });\n\n // Register scoped cache wrapper for per-request session credentials.\n // queryAction uses this to wrap scoped client calls with Redis caching\n // using the targetSiteId as the cache prefix.\n registerScopedCacheWrapper((prefix, methodPath, sdkCall, ...keyArgs) => {\n const ttl = ttlFor(getCacheTier(methodPath).staleTime, redisTtl, longRedisTtl);\n if (ttl === null) return sdkCall();\n return withRawSdkCache(prefix, ttl, methodPath, sdkCall, ...keyArgs);\n });\n\n // Register client factory for creating scoped SDK clients with\n // per-request credentials. Uses the same constructor + base config\n // (baseUrl, timeout, retries) but different siteId/bearerToken.\n const baseConfig = (client as Record<string, unknown>)[\"config\"] as\n Record<string, unknown> | undefined;\n if (baseConfig) {\n const Ctor = client.constructor as new (cfg: Record<string, unknown>) => object;\n registerClientFactory((siteId: string, bearerToken: string) => {\n return new Ctor({ ...baseConfig, siteId, bearerToken });\n });\n }\n\n const authSecret = config.auth?.secret ?? process.env[\"AUTH_SECRET\"];\n if (authSecret) {\n registerAuthSecret(authSecret);\n }\n\n const auth = config.auth\n ? createAuthConfig({\n augurClient: client as unknown as AugurAuthClient,\n defaultCustomerId: config.defaultCustomerId,\n defaultContactId: config.defaultContactId,\n ...config.auth,\n })\n : undefined;\n\n return { client, actions, auth };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA,SAAS,aAAa;AAgBtB,SAAS,oBAAoB;AAsCtB,SAAS,iBACd,QACA,SAA2B,CAAC,GACV;AAClB,QAAM,UAAU,kBAAkB,QAAQ,MAAM;AAChD,sBAAoB,OAAO;AAC3B,oBAAkB,MAAM;AAOxB,QAAM,EAAE,cAAc,IAAI,WAAW,MAAM,CAAC,GAAG,eAAe,MAAM,CAAC,EAAE,IAAI;AAC3E,yBAAuB,CAAC,YAAY,YAAY,YAAY;AAE1D,UAAM,MAAM,OAAO,aAAa,UAAU,EAAE,WAAW,UAAU,YAAY;AAC7E,QAAI,QAAQ,KAAM,QAAO,QAAQ;AACjC,WAAO,gBAAgB,aAAa,KAAK,YAAY,SAAS,GAAG,OAAO;AAAA,EAC1E,CAAC;AAKD,6BAA2B,CAAC,QAAQ,YAAY,YAAY,YAAY;AACtE,UAAM,MAAM,OAAO,aAAa,UAAU,EAAE,WAAW,UAAU,YAAY;AAC7E,QAAI,QAAQ,KAAM,QAAO,QAAQ;AACjC,WAAO,gBAAgB,QAAQ,KAAK,YAAY,SAAS,GAAG,OAAO;AAAA,EACrE,CAAC;AAKD,QAAM,aAAc,OAAmC,QAAQ;AAE/D,MAAI,YAAY;AACd,UAAM,OAAO,OAAO;AACpB,0BAAsB,CAAC,QAAgB,gBAAwB;AAC7D,aAAO,IAAI,KAAK,EAAE,GAAG,YAAY,QAAQ,YAAY,CAAC;AAAA,IACxD,CAAC;AAAA,EACH;AAEA,QAAM,aAAa,OAAO,MAAM,UAAU,QAAQ,IAAI,aAAa;AACnE,MAAI,YAAY;AACd,uBAAmB,UAAU;AAAA,EAC/B;AAEA,QAAM,OAAO,OAAO,OAChB,iBAAiB;AAAA,IACf,aAAa;AAAA,IACb,mBAAmB,OAAO;AAAA,IAC1B,kBAAkB,OAAO;AAAA,IACzB,GAAG,OAAO;AAAA,EACZ,CAAC,IACD;AAEJ,SAAO,EAAE,QAAQ,SAAS,KAAK;AACjC;","names":[]}
|
package/dist/testing.d.ts
CHANGED
|
@@ -1,14 +1,12 @@
|
|
|
1
|
-
export {
|
|
2
|
-
export {
|
|
3
|
-
|
|
4
|
-
import
|
|
5
|
-
import '@simpleapps-com/augur-utils';
|
|
6
|
-
|
|
1
|
+
export { createMockClient } from "@simpleapps-com/augur-core/testing";
|
|
2
|
+
export { clearSiteActions } from "./server-site-registry";
|
|
3
|
+
export type { DeepMockClient, MockClientResult } from "@simpleapps-com/augur-core/testing";
|
|
4
|
+
import type { SiteActions } from "./actions/site";
|
|
7
5
|
/**
|
|
8
6
|
* A mock function type compatible with both Vitest and Jest.
|
|
9
7
|
* Supports `.mockResolvedValue()`, `.mockRejectedValue()`, and call tracking.
|
|
10
8
|
*/
|
|
11
|
-
interface MockFn {
|
|
9
|
+
export interface MockFn {
|
|
12
10
|
(...args: unknown[]): unknown;
|
|
13
11
|
mockResolvedValue: (value: unknown) => MockFn;
|
|
14
12
|
mockRejectedValue: (value: unknown) => MockFn;
|
|
@@ -19,13 +17,13 @@ interface MockFn {
|
|
|
19
17
|
};
|
|
20
18
|
}
|
|
21
19
|
/** Mirror of SiteActions where every method is a MockFn. */
|
|
22
|
-
type MockSiteActions = {
|
|
20
|
+
export type MockSiteActions = {
|
|
23
21
|
[K in keyof SiteActions]: {
|
|
24
22
|
[M in keyof SiteActions[K]]: MockFn;
|
|
25
23
|
};
|
|
26
24
|
};
|
|
27
25
|
/** Return type of createMockSiteActions. */
|
|
28
|
-
interface MockSiteActionsResult {
|
|
26
|
+
export interface MockSiteActionsResult {
|
|
29
27
|
/** Typed as SiteActions — pass this to your components/server actions. */
|
|
30
28
|
actions: SiteActions;
|
|
31
29
|
/** Same object typed with MockFn — use for assertions and mock setup. */
|
|
@@ -54,6 +52,5 @@ interface MockSiteActionsResult {
|
|
|
54
52
|
* expect(mocks.pricing.getItemPrice.mock.calls[0]).toEqual(["ITEM-1"]);
|
|
55
53
|
* ```
|
|
56
54
|
*/
|
|
57
|
-
declare function createMockSiteActions(): MockSiteActionsResult;
|
|
58
|
-
|
|
59
|
-
export { type MockFn, type MockSiteActions, type MockSiteActionsResult, createMockSiteActions };
|
|
55
|
+
export declare function createMockSiteActions(): MockSiteActionsResult;
|
|
56
|
+
//# sourceMappingURL=testing.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"testing.d.ts","sourceRoot":"","sources":["../src/testing.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,oCAAoC,CAAC;AACtE,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC1D,YAAY,EAAE,cAAc,EAAE,gBAAgB,EAAE,MAAM,oCAAoC,CAAC;AAE3F,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAElD;;;GAGG;AACH,MAAM,WAAW,MAAM;IACrB,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC;IAC9B,iBAAiB,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,MAAM,CAAC;IAC9C,iBAAiB,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,MAAM,CAAC;IAC9C,eAAe,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,MAAM,CAAC;IAC5C,kBAAkB,EAAE,CAAC,EAAE,EAAE,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,OAAO,KAAK,MAAM,CAAC;IACpE,IAAI,EAAE;QAAE,KAAK,EAAE,OAAO,EAAE,EAAE,CAAA;KAAE,CAAC;CAC9B;AAED,4DAA4D;AAC5D,MAAM,MAAM,eAAe,GAAG;KAC3B,CAAC,IAAI,MAAM,WAAW,GAAG;SACvB,CAAC,IAAI,MAAM,WAAW,CAAC,CAAC,CAAC,GAAG,MAAM;KACpC;CACF,CAAC;AAEF,4CAA4C;AAC5C,MAAM,WAAW,qBAAqB;IACpC,0EAA0E;IAC1E,OAAO,EAAE,WAAW,CAAC;IACrB,yEAAyE;IACzE,KAAK,EAAE,eAAe,CAAC;CACxB;AAwJD;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,qBAAqB,IAAI,qBAAqB,CAe7D"}
|
package/dist/testing.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import {
|
|
2
2
|
clearSiteActions
|
|
3
|
-
} from "./chunk-
|
|
4
|
-
import "./chunk-
|
|
5
|
-
import "./chunk-
|
|
3
|
+
} from "./chunk-LX7SJJOU.js";
|
|
4
|
+
import "./chunk-A4IVBK6P.js";
|
|
5
|
+
import "./chunk-OBWQSGB6.js";
|
|
6
6
|
|
|
7
7
|
// src/testing.ts
|
|
8
8
|
import { createMockClient } from "@simpleapps-com/augur-core/testing";
|
|
@@ -47,7 +47,6 @@ var SERVICE_METHODS = {
|
|
|
47
47
|
],
|
|
48
48
|
legacy: ["getItemWebDesc", "getAlsoBoughtItems", "getItemTags", "getStates"],
|
|
49
49
|
customers: [
|
|
50
|
-
"getCustomer",
|
|
51
50
|
"customerLookup",
|
|
52
51
|
"getCustomerDoc",
|
|
53
52
|
"getCustomerOrders",
|
|
@@ -56,12 +55,11 @@ var SERVICE_METHODS = {
|
|
|
56
55
|
"getCustomerInvoiceDetail",
|
|
57
56
|
"getCustomerQuotes",
|
|
58
57
|
"getCustomerQuoteDetail",
|
|
59
|
-
"getContacts",
|
|
60
58
|
"getShipToAddresses"
|
|
61
59
|
],
|
|
62
60
|
smartyStreets: ["validateAddress"],
|
|
63
61
|
p21Pim: ["getInvMastExt", "listInvMastExt"],
|
|
64
|
-
agrSite: ["getSettings", "
|
|
62
|
+
agrSite: ["getSettings", "getRobots"],
|
|
65
63
|
avalara: ["calculateTax"],
|
|
66
64
|
payments: [
|
|
67
65
|
"transactionSetup",
|
|
@@ -72,14 +70,6 @@ var SERVICE_METHODS = {
|
|
|
72
70
|
"validatePayment"
|
|
73
71
|
],
|
|
74
72
|
logistics: ["getFreightRates", "getShipVia"],
|
|
75
|
-
nexus: [
|
|
76
|
-
"createBinTransfer",
|
|
77
|
-
"createReceiving",
|
|
78
|
-
"createTransfer",
|
|
79
|
-
"getPurchaseOrderReceipts",
|
|
80
|
-
"getTransferReceipts",
|
|
81
|
-
"getTransferShipping"
|
|
82
|
-
],
|
|
83
73
|
vmi: [
|
|
84
74
|
"getWarehouses",
|
|
85
75
|
"getWarehouseAvailability",
|
|
@@ -98,17 +88,8 @@ var SERVICE_METHODS = {
|
|
|
98
88
|
"getCashDrawers",
|
|
99
89
|
"getCodeP21"
|
|
100
90
|
],
|
|
101
|
-
p21Apis: [
|
|
102
|
-
|
|
103
|
-
"getCategoryDefaults",
|
|
104
|
-
"getCompanies",
|
|
105
|
-
"getUsers",
|
|
106
|
-
"getWebDisplayTypes",
|
|
107
|
-
"getWebDisplayTypeDefaults",
|
|
108
|
-
"refreshContacts",
|
|
109
|
-
"refreshCustomers"
|
|
110
|
-
],
|
|
111
|
-
p21Sism: ["getRecentImports", "getImport", "getImportLines", "getScheduledImports"],
|
|
91
|
+
p21Apis: ["refreshContacts", "refreshCustomers"],
|
|
92
|
+
p21Sism: ["getRecentImports", "getImport", "getScheduledImports"],
|
|
112
93
|
agrWork: ["healthCheck", "ping"],
|
|
113
94
|
agrInfo: ["getContext", "getRubrics", "getMicroservices", "generateAkasha", "generateJoomla"],
|
|
114
95
|
basecamp2: [
|
|
@@ -123,8 +104,7 @@ var SERVICE_METHODS = {
|
|
|
123
104
|
"getTodolists"
|
|
124
105
|
],
|
|
125
106
|
brandFolder: ["getCategories", "getCategory", "createFocus"],
|
|
126
|
-
gregorovich: ["
|
|
127
|
-
slack: ["sendWebhook", "getWebhooks"],
|
|
107
|
+
gregorovich: ["getDocuments"],
|
|
128
108
|
favorites: ["getFavorites", "addFavorite", "removeFavorite"],
|
|
129
109
|
wishlists: [
|
|
130
110
|
"getWishlists",
|
package/dist/testing.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/testing.ts"],"sourcesContent":["export { createMockClient } from \"@simpleapps-com/augur-core/testing\";\nexport { clearSiteActions } from \"./server-site-registry\";\nexport type { DeepMockClient, MockClientResult } from \"@simpleapps-com/augur-core/testing\";\n\nimport type { SiteActions } from \"./actions/site\";\n\n/**\n * A mock function type compatible with both Vitest and Jest.\n * Supports `.mockResolvedValue()`, `.mockRejectedValue()`, and call tracking.\n */\nexport interface MockFn {\n (...args: unknown[]): unknown;\n mockResolvedValue: (value: unknown) => MockFn;\n mockRejectedValue: (value: unknown) => MockFn;\n mockReturnValue: (value: unknown) => MockFn;\n mockImplementation: (fn: (...args: unknown[]) => unknown) => MockFn;\n mock: { calls: unknown[][] };\n}\n\n/** Mirror of SiteActions where every method is a MockFn. */\nexport type MockSiteActions = {\n [K in keyof SiteActions]: {\n [M in keyof SiteActions[K]]: MockFn;\n };\n};\n\n/** Return type of createMockSiteActions. */\nexport interface MockSiteActionsResult {\n /** Typed as SiteActions — pass this to your components/server actions. */\n actions: SiteActions;\n /** Same object typed with MockFn — use for assertions and mock setup. */\n mocks: MockSiteActions;\n}\n\n/** Shape definition: service name → method names. */\nconst SERVICE_METHODS: Record<string, string[]> = {\n pricing: [\"getItemPrice\", \"batchGetItemPrices\", \"getTaxEstimate\"],\n items: [\n \"itemCategoryLookup\",\n \"getItemCategory\",\n \"getCategoryItems\",\n \"getCategoryItemsInfinite\",\n \"getItemAttributes\",\n \"getInvMast\",\n \"getInvMastDoc\",\n \"getStock\",\n \"getStockCompanySummary\",\n \"getItemFaqs\",\n \"getItemSubstitutes\",\n \"getItemAccessories\",\n \"getSimilarItems\",\n \"batchGetInvMastDocs\",\n \"batchGetStockData\",\n ],\n commerce: [\n \"cartHdrLookup\",\n \"getCartLines\",\n \"addToCart\",\n \"updateCartLines\",\n \"deleteCartItems\",\n \"getCartAlsoBought\",\n \"checkoutOrder\",\n ],\n search: [\"getSearchAttributes\", \"getSearchSuggestions\", \"itemSearch\", \"itemSearchInfinite\"],\n orders: [\"getOrderDoc\"],\n shipping: [\"getShippingRates\"],\n joomla: [\n \"getJoomlaContent\",\n \"getJoomlaContentList\",\n \"getJoomlaMenu\",\n \"getJoomlaMenuDoc\",\n \"getUserProfile\",\n \"verifyPassword\",\n ],\n legacy: [\"getItemWebDesc\", \"getAlsoBoughtItems\", \"getItemTags\", \"getStates\"],\n customers: [\n \"
|
|
1
|
+
{"version":3,"sources":["../src/testing.ts"],"sourcesContent":["export { createMockClient } from \"@simpleapps-com/augur-core/testing\";\nexport { clearSiteActions } from \"./server-site-registry\";\nexport type { DeepMockClient, MockClientResult } from \"@simpleapps-com/augur-core/testing\";\n\nimport type { SiteActions } from \"./actions/site\";\n\n/**\n * A mock function type compatible with both Vitest and Jest.\n * Supports `.mockResolvedValue()`, `.mockRejectedValue()`, and call tracking.\n */\nexport interface MockFn {\n (...args: unknown[]): unknown;\n mockResolvedValue: (value: unknown) => MockFn;\n mockRejectedValue: (value: unknown) => MockFn;\n mockReturnValue: (value: unknown) => MockFn;\n mockImplementation: (fn: (...args: unknown[]) => unknown) => MockFn;\n mock: { calls: unknown[][] };\n}\n\n/** Mirror of SiteActions where every method is a MockFn. */\nexport type MockSiteActions = {\n [K in keyof SiteActions]: {\n [M in keyof SiteActions[K]]: MockFn;\n };\n};\n\n/** Return type of createMockSiteActions. */\nexport interface MockSiteActionsResult {\n /** Typed as SiteActions — pass this to your components/server actions. */\n actions: SiteActions;\n /** Same object typed with MockFn — use for assertions and mock setup. */\n mocks: MockSiteActions;\n}\n\n/** Shape definition: service name → method names. */\nconst SERVICE_METHODS: Record<string, string[]> = {\n pricing: [\"getItemPrice\", \"batchGetItemPrices\", \"getTaxEstimate\"],\n items: [\n \"itemCategoryLookup\",\n \"getItemCategory\",\n \"getCategoryItems\",\n \"getCategoryItemsInfinite\",\n \"getItemAttributes\",\n \"getInvMast\",\n \"getInvMastDoc\",\n \"getStock\",\n \"getStockCompanySummary\",\n \"getItemFaqs\",\n \"getItemSubstitutes\",\n \"getItemAccessories\",\n \"getSimilarItems\",\n \"batchGetInvMastDocs\",\n \"batchGetStockData\",\n ],\n commerce: [\n \"cartHdrLookup\",\n \"getCartLines\",\n \"addToCart\",\n \"updateCartLines\",\n \"deleteCartItems\",\n \"getCartAlsoBought\",\n \"checkoutOrder\",\n ],\n search: [\"getSearchAttributes\", \"getSearchSuggestions\", \"itemSearch\", \"itemSearchInfinite\"],\n orders: [\"getOrderDoc\"],\n shipping: [\"getShippingRates\"],\n joomla: [\n \"getJoomlaContent\",\n \"getJoomlaContentList\",\n \"getJoomlaMenu\",\n \"getJoomlaMenuDoc\",\n \"getUserProfile\",\n \"verifyPassword\",\n ],\n legacy: [\"getItemWebDesc\", \"getAlsoBoughtItems\", \"getItemTags\", \"getStates\"],\n customers: [\n \"customerLookup\",\n \"getCustomerDoc\",\n \"getCustomerOrders\",\n \"getCustomerOrderDetail\",\n \"getCustomerInvoices\",\n \"getCustomerInvoiceDetail\",\n \"getCustomerQuotes\",\n \"getCustomerQuoteDetail\",\n \"getShipToAddresses\",\n ],\n smartyStreets: [\"validateAddress\"],\n p21Pim: [\"getInvMastExt\", \"listInvMastExt\"],\n agrSite: [\"getSettings\", \"getRobots\"],\n avalara: [\"calculateTax\"],\n payments: [\n \"transactionSetup\",\n \"accountQuery\",\n \"getSurcharge\",\n \"cardInfo\",\n \"billingUpdate\",\n \"validatePayment\",\n ],\n logistics: [\"getFreightRates\", \"getShipVia\"],\n vmi: [\n \"getWarehouses\",\n \"getWarehouseAvailability\",\n \"getDistributors\",\n \"getProducts\",\n \"getInventoryProfiles\",\n \"getRestockHeaders\",\n \"getSections\",\n ],\n p21Core: [\n \"getAddresses\",\n \"getCompanies\",\n \"getCompany\",\n \"getLocations\",\n \"getPaymentTypes\",\n \"getCashDrawers\",\n \"getCodeP21\",\n ],\n p21Apis: [\"refreshContacts\", \"refreshCustomers\"],\n p21Sism: [\"getRecentImports\", \"getImport\", \"getScheduledImports\"],\n agrWork: [\"healthCheck\", \"ping\"],\n agrInfo: [\"getContext\", \"getRubrics\", \"getMicroservices\", \"generateAkasha\", \"generateJoomla\"],\n basecamp2: [\n \"getTodos\",\n \"getTodo\",\n \"getTodosSummary\",\n \"getComments\",\n \"getPeople\",\n \"getProjects\",\n \"getEvents\",\n \"getMetrics\",\n \"getTodolists\",\n ],\n brandFolder: [\"getCategories\", \"getCategory\", \"createFocus\"],\n gregorovich: [\"getDocuments\"],\n favorites: [\"getFavorites\", \"addFavorite\", \"removeFavorite\"],\n wishlists: [\n \"getWishlists\",\n \"createWishlist\",\n \"getWishlistDetail\",\n \"deleteWishlist\",\n \"addWishlistItems\",\n \"removeWishlistItem\",\n ],\n};\n\nfunction createStubFn(): MockFn {\n const calls: unknown[][] = [];\n\n const fn = ((...args: unknown[]) => {\n calls.push(args);\n const impl = (fn as MockFnInternal)._impl;\n return impl ? impl(...args) : undefined;\n }) as MockFn & MockFnInternal;\n\n fn._impl = undefined;\n fn.mock = { calls };\n\n fn.mockResolvedValue = (value: unknown) => {\n fn._impl = () => Promise.resolve(value);\n return fn;\n };\n\n fn.mockRejectedValue = (value: unknown) => {\n fn._impl = () => Promise.reject(value);\n return fn;\n };\n\n fn.mockReturnValue = (value: unknown) => {\n fn._impl = () => value;\n return fn;\n };\n\n fn.mockImplementation = (impl: (...args: unknown[]) => unknown) => {\n fn._impl = impl;\n return fn;\n };\n\n return fn;\n}\n\ninterface MockFnInternal {\n _impl: ((...args: unknown[]) => unknown) | undefined;\n}\n\n/**\n * Creates a fully-mocked SiteActions object for testing.\n *\n * Every method on every service is a stub function with call tracking\n * and `.mockResolvedValue()` / `.mockReturnValue()` support.\n * Works with both Vitest and Jest — no framework dependency.\n *\n * @example\n * ```ts\n * import { createMockSiteActions } from \"@simpleapps-com/augur-server/testing\";\n *\n * const { actions, mocks } = createMockSiteActions();\n *\n * // Setup return values\n * mocks.pricing.getItemPrice.mockResolvedValue({ price: 9.99 });\n *\n * // Pass actions to your component/server action\n * const price = await actions.pricing.getItemPrice(\"ITEM-1\");\n *\n * // Assert calls\n * expect(mocks.pricing.getItemPrice.mock.calls[0]).toEqual([\"ITEM-1\"]);\n * ```\n */\nexport function createMockSiteActions(): MockSiteActionsResult {\n const result: Record<string, Record<string, MockFn>> = {};\n\n for (const [service, methods] of Object.entries(SERVICE_METHODS)) {\n const serviceMock: Record<string, MockFn> = {};\n for (const method of methods) {\n serviceMock[method] = createStubFn();\n }\n result[service] = serviceMock;\n }\n\n return {\n actions: result as unknown as SiteActions,\n mocks: result as unknown as MockSiteActions,\n };\n}\n"],"mappings":"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","names":[]}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Fetches data for multiple params in parallel, returning a Record keyed by
|
|
3
|
+
* `getKey(param)`. Individual failures are silently excluded from the result
|
|
4
|
+
* so one bad item never takes down the entire batch.
|
|
5
|
+
*/
|
|
6
|
+
export declare function batchFetch<TParam, TKey extends string | number, TData>(params: TParam[], fetchOne: (param: TParam) => Promise<TData>, getKey: (param: TParam) => TKey): Promise<Record<TKey, TData>>;
|
|
7
|
+
//# sourceMappingURL=batch-fetch.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"batch-fetch.d.ts","sourceRoot":"","sources":["../../src/utils/batch-fetch.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,wBAAsB,UAAU,CAAC,MAAM,EAAE,IAAI,SAAS,MAAM,GAAG,MAAM,EAAE,KAAK,EAC1E,MAAM,EAAE,MAAM,EAAE,EAChB,QAAQ,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,OAAO,CAAC,KAAK,CAAC,EAC3C,MAAM,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,GAC9B,OAAO,CAAC,MAAM,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC,CAgB9B"}
|
package/llms.txt
CHANGED
|
@@ -1,22 +1,19 @@
|
|
|
1
1
|
# Augur Platform Packages
|
|
2
2
|
|
|
3
3
|
This package is part of the @simpleapps-com/augur-* platform.
|
|
4
|
-
|
|
5
|
-
The
|
|
6
|
-
Pure transform utilities bridge user-facing types to SDK params without breaking proxy type safety.
|
|
4
|
+
Each package releases on its own CalVer version; nothing requires them to share one.
|
|
5
|
+
The docs are at https://augur.build/docs/packages (the API reference lists every export).
|
|
7
6
|
|
|
8
7
|
## Sibling packages
|
|
9
8
|
|
|
10
|
-
- @simpleapps-com/augur-config - Shared tooling configuration presets for Augur ecommerce sites
|
|
11
9
|
- @simpleapps-com/augur-core - Universal foundation for Augur packages — proxy infrastructure, cache keys, method classification, shared types
|
|
10
|
+
- @simpleapps-com/augur-utils - Shared types, cache configuration, and utility functions for Augur ecommerce sites
|
|
12
11
|
- @simpleapps-com/augur-hooks - Cross-platform React Query hooks and Zustand stores for Augur ecommerce sites
|
|
13
|
-
- @simpleapps-com/augur-mobile - React Native/Expo adapters for Augur ecommerce apps (offline sync, biometrics, push)
|
|
14
12
|
- @simpleapps-com/augur-server (this package) - Server-side utilities for Augur ecommerce sites (Redis caching, SDK helpers, auth)
|
|
15
|
-
- @simpleapps-com/augur-tailwind - Shared Tailwind CSS v4 theme with HSL variables for Augur ecommerce sites
|
|
16
|
-
- @simpleapps-com/augur-utils - Shared types, cache configuration, and utility functions for Augur ecommerce sites
|
|
17
13
|
- @simpleapps-com/augur-web - Shared React UI components for Augur ecommerce sites (Radix + Tailwind)
|
|
18
|
-
|
|
19
|
-
|
|
14
|
+
- @simpleapps-com/augur-mobile - React Native/Expo adapters for Augur ecommerce apps (offline sync, biometrics, push)
|
|
15
|
+
- @simpleapps-com/augur-tailwind - Shared Tailwind CSS v4 theme with HSL variables for Augur ecommerce sites
|
|
16
|
+
- @simpleapps-com/augur-config - Shared tooling configuration presets for Augur ecommerce sites
|
|
20
17
|
|
|
21
18
|
---
|
|
22
19
|
|
|
@@ -24,43 +21,72 @@ Each package ships its own llms.txt with exports and usage patterns.
|
|
|
24
21
|
|
|
25
22
|
> Server-side utilities for Augur ecommerce sites (Redis caching, SDK helpers, auth)
|
|
26
23
|
|
|
27
|
-
Version: 2.2.29
|
|
28
|
-
|
|
29
24
|
## @simpleapps-com/augur-server
|
|
30
25
|
|
|
31
|
-
-
|
|
32
|
-
-
|
|
33
|
-
- value:
|
|
34
|
-
-
|
|
35
|
-
- function: batchFetch - Fetches data for multiple params in parallel, returning a Record keyed by
|
|
36
|
-
- function: cacheGet - Read a cached value by key.
|
|
37
|
-
- function: cacheSet - Write a value to cache with a TTL. Fire-and-forget semantics: no-ops
|
|
38
|
-
- value: createQueryOptions
|
|
26
|
+
- function: batchFetch - Fetches data for multiple params in parallel, returning a Record keyed by `getKey(param)`. Individual failures are silently excluded from the result so one bad item never takes down the entire batch.
|
|
27
|
+
- function: cacheGet - Read a cached value by key. Returns `null` on cache miss, circuit-open, connection failure, or if Redis is unavailable. Never throws.
|
|
28
|
+
- function: cacheSet - Write a value to cache with a TTL. Fire-and-forget semantics: no-ops silently when the circuit is open or Redis is unavailable. Never throws.
|
|
29
|
+
- const: createQueryOptions - Creates useQuery options with consistent key generation. Filters out undefined/null/empty params from the query key.
|
|
39
30
|
- function: createServerQueryClient - Creates a server-side query client optimised for prefetching.
|
|
40
|
-
- function: createSiteActions
|
|
41
|
-
-
|
|
31
|
+
- function: createSiteActions - Creates a unified site actions object with all service factories.
|
|
32
|
+
- const: createSuspenseQueryOptions - Creates useSuspenseQuery options with consistent key generation. Same as createQueryOptions but without enabledFn (suspense queries cannot be disabled).
|
|
42
33
|
- const: env - Resolved environment: `"development"`, `"staging"`, or `"production"`.
|
|
43
34
|
- function: getCircuitState - Returns the current circuit breaker state.
|
|
44
35
|
- const: getServerQueryClient - Returns a per-request singleton QueryClient for React Server Components.
|
|
45
|
-
- function: getSiteActions
|
|
36
|
+
- function: getSiteActions - Returns the registered site actions instance.
|
|
46
37
|
- const: isDev - `true` when running locally (localhost / NODE_ENV=development).
|
|
47
38
|
- const: isProduction - `true` when running on the production deployment.
|
|
48
39
|
- function: isRedisConnected - Whether the Redis client is connected and ready to accept commands.
|
|
49
40
|
- const: isStaging - `true` when running on the staging/dev deployment.
|
|
50
|
-
- function: paginateOffset
|
|
51
|
-
- function: registerSiteActions
|
|
52
|
-
- function: safeAction - Wraps an async function call with error handling, returning a
|
|
41
|
+
- function: paginateOffset - Wraps a list of items with offset-based pagination metadata.
|
|
42
|
+
- function: registerSiteActions - Stores the site actions instance for use by server action exports. Called automatically by {@link createServerSite}.
|
|
43
|
+
- function: safeAction - Wraps an async function call with error handling, returning a `SafeActionResult<T>` instead of throwing.
|
|
53
44
|
- function: sdkCall - Calls an Augur SDK method, forwarding all arguments with full type safety.
|
|
54
45
|
- value: unwrap
|
|
55
46
|
- value: unwrapOr
|
|
56
|
-
- function: verifyRecaptcha - Server-side Google reCAPTCHA v3 verification.
|
|
57
|
-
- function: withServerCache -
|
|
47
|
+
- function: verifyRecaptcha - Server-side Google reCAPTCHA v3 verification. Used by API routes that accept public form submissions.
|
|
48
|
+
- function: withServerCache - Caches an action's shaped value.
|
|
49
|
+
- type: ActionResult
|
|
50
|
+
- type: EdgeCacheValue
|
|
58
51
|
- type: PaginatedResult
|
|
52
|
+
- type: QueryOptionsConfig
|
|
53
|
+
- type: SafeActionResult
|
|
59
54
|
- type: SiteActions
|
|
60
55
|
- type: SiteActionsConfig
|
|
61
56
|
|
|
62
57
|
### Examples
|
|
63
58
|
|
|
59
|
+
createSiteActions:
|
|
60
|
+
```ts
|
|
61
|
+
import { createSiteActions } from "@simpleapps-com/augur-server";
|
|
62
|
+
import { getAugurClient } from "./augur-client";
|
|
63
|
+
|
|
64
|
+
// defaultCustomerId/defaultContactId fall back to DEFAULT_CUSTOMER_ID/DEFAULT_CONTACT_ID
|
|
65
|
+
// env vars when not provided — no need to set them if CDK injects them.
|
|
66
|
+
export const actions = createSiteActions(getAugurClient(), {
|
|
67
|
+
convertUnitOfMeasure: (uom) => uom === "EA" ? "EACH" : uom,
|
|
68
|
+
items: { sortChildren: true },
|
|
69
|
+
shipping: {
|
|
70
|
+
fromAddress: { address1: "123 Main", city: "Provo", state: "UT", postalCode: "84606" },
|
|
71
|
+
defaultServiceCodes: ["03"],
|
|
72
|
+
},
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
// Usage:
|
|
76
|
+
const price = await actions.pricing.getItemPrice("ITEM-1");
|
|
77
|
+
const doc = await actions.items.getInvMastDoc("ITEM-1");
|
|
78
|
+
const cart = await actions.commerce.cartHdrLookup({ userId: 123 });
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
paginateOffset:
|
|
82
|
+
```ts
|
|
83
|
+
const result = await actions.items.getCategoryItems(uid, {
|
|
84
|
+
...filters, offset: page * 24, limit: 24,
|
|
85
|
+
});
|
|
86
|
+
return paginateOffset(result.items, page, 24, result.total);
|
|
87
|
+
// { data: [...], total: 150, nextCursor: 1, hasMore: true }
|
|
88
|
+
```
|
|
89
|
+
|
|
64
90
|
safeAction:
|
|
65
91
|
```ts
|
|
66
92
|
const result = await safeAction(
|
|
@@ -82,7 +108,6 @@ const result = await sdkCall(
|
|
|
82
108
|
);
|
|
83
109
|
```
|
|
84
110
|
|
|
85
|
-
|
|
86
111
|
## @simpleapps-com/augur-server/auth
|
|
87
112
|
|
|
88
113
|
- function: createAuthConfig - Creates a NextAuth configuration with Joomla credential provider, session callbacks, and automatic cart initialization.
|
|
@@ -95,17 +120,17 @@ const result = await sdkCall(
|
|
|
95
120
|
|
|
96
121
|
## @simpleapps-com/augur-server/query
|
|
97
122
|
|
|
98
|
-
- const: createQueryOptions - Creates useQuery options with consistent key generation.
|
|
99
|
-
- const: createSuspenseQueryOptions - Creates useSuspenseQuery options with consistent key generation.
|
|
123
|
+
- const: createQueryOptions - Creates useQuery options with consistent key generation. Filters out undefined/null/empty params from the query key.
|
|
124
|
+
- const: createSuspenseQueryOptions - Creates useSuspenseQuery options with consistent key generation. Same as createQueryOptions but without enabledFn (suspense queries cannot be disabled).
|
|
100
125
|
- type: QueryOptionsConfig
|
|
101
126
|
|
|
102
127
|
## @simpleapps-com/augur-server/testing
|
|
103
128
|
|
|
104
|
-
-
|
|
105
|
-
- value: MockClientResult
|
|
106
|
-
- function: clearSiteActions
|
|
129
|
+
- function: clearSiteActions - Clears the registered site actions. Used in tests only.
|
|
107
130
|
- value: createMockClient
|
|
108
131
|
- function: createMockSiteActions - Creates a fully-mocked SiteActions object for testing.
|
|
132
|
+
- type: DeepMockClient
|
|
133
|
+
- type: MockClientResult
|
|
109
134
|
- type: MockFn
|
|
110
135
|
- type: MockSiteActions
|
|
111
136
|
- type: MockSiteActionsResult
|
|
@@ -128,10 +153,9 @@ const price = await actions.pricing.getItemPrice("ITEM-1");
|
|
|
128
153
|
expect(mocks.pricing.getItemPrice.mock.calls[0]).toEqual(["ITEM-1"]);
|
|
129
154
|
```
|
|
130
155
|
|
|
131
|
-
|
|
132
156
|
## @simpleapps-com/augur-server/site
|
|
133
157
|
|
|
134
|
-
- function: createServerSite - Create a server-side site instance that bundles the SDK client, server
|
|
158
|
+
- function: createServerSite - Create a server-side site instance that bundles the SDK client, server actions, and (optional) NextAuth configuration.
|
|
135
159
|
- type: ServerSite
|
|
136
160
|
- type: ServerSiteAuthConfig
|
|
137
161
|
- type: ServerSiteConfig
|
|
@@ -140,27 +164,26 @@ expect(mocks.pricing.getItemPrice.mock.calls[0]).toEqual(["ITEM-1"]);
|
|
|
140
164
|
|
|
141
165
|
createServerSite:
|
|
142
166
|
```ts
|
|
143
|
-
import {
|
|
144
|
-
import { createServerSite } from "@simpleapps-com/augur-server";
|
|
167
|
+
import { AugurAPI } from "@simpleapps-com/augur-api";
|
|
168
|
+
import { createServerSite } from "@simpleapps-com/augur-server/site";
|
|
145
169
|
|
|
146
|
-
const api = new
|
|
170
|
+
const api = new AugurAPI({ siteId: process.env.AUGUR_SITE_ID!, bearerToken: process.env.AUGUR_JWT! });
|
|
147
171
|
export const site = createServerSite(api, {
|
|
148
172
|
defaultCustomerId: "12345",
|
|
149
173
|
auth: { secret: process.env.AUTH_SECRET },
|
|
150
174
|
});
|
|
151
175
|
```
|
|
152
176
|
|
|
153
|
-
|
|
154
177
|
## @simpleapps-com/augur-server/actions
|
|
155
178
|
|
|
156
|
-
-
|
|
157
|
-
-
|
|
158
|
-
-
|
|
179
|
+
- type: ApiResult
|
|
180
|
+
- type: ListResult
|
|
181
|
+
- type: SafeActionResult
|
|
159
182
|
|
|
160
183
|
## @simpleapps-com/augur-server/hooks
|
|
161
184
|
|
|
162
|
-
-
|
|
163
|
-
-
|
|
185
|
+
- function: createServerQueryProxy - Creates a client-side proxy that mirrors the SDK namespace and routes every method call through a server action function.
|
|
186
|
+
- type: QueryActionFn
|
|
164
187
|
|
|
165
188
|
### Examples
|
|
166
189
|
|
|
@@ -172,12 +195,12 @@ const q = createServerQueryProxy();
|
|
|
172
195
|
|
|
173
196
|
// Reads — any SDK method, routed through server actions
|
|
174
197
|
const { data: item } = useQuery(q.items.invMast.doc.get(42));
|
|
175
|
-
const { data: price } = useQuery(q.pricing.priceEngine.
|
|
198
|
+
const { data: price } = useQuery(q.pricing.priceEngine.list({ itemId, customerId }));
|
|
176
199
|
|
|
177
200
|
// Infinite queries — spread and add infinite-specific options
|
|
178
201
|
const { data, fetchNextPage } = useInfiniteQuery({
|
|
179
|
-
...q.items.
|
|
180
|
-
getNextPageParam: (lastPage) => lastPage
|
|
202
|
+
...q.items.categories.items.list(itemCategoryUid, filters),
|
|
203
|
+
getNextPageParam: (lastPage, pages) => nextOffset(lastPage, pages), // the site's paging rule
|
|
181
204
|
initialPageParam: 0,
|
|
182
205
|
});
|
|
183
206
|
|
|
@@ -185,14 +208,13 @@ const { data, fetchNextPage } = useInfiniteQuery({
|
|
|
185
208
|
const addToCart = useMutation(q.commerce.cartLine.add.create());
|
|
186
209
|
```
|
|
187
210
|
|
|
188
|
-
|
|
189
211
|
## @simpleapps-com/augur-server/query-action
|
|
190
212
|
|
|
191
213
|
- function: getSessionCredentials - Resolve session credentials from the Auth.js JWT cookie.
|
|
192
|
-
- function: queryAction - Generic server action that routes any SDK method call through the raw
|
|
214
|
+
- function: queryAction - Generic server action that routes any SDK method call through the raw SDK client with optional Redis caching. Used internally by `createServerQueryProxy()` to bridge client-side React Query hooks to server-side API calls.
|
|
193
215
|
- function: resetSessionImports - Reset lazy-loaded imports. Used in tests only. @internal
|
|
194
216
|
- function: resolveMethod - Resolve a dot-separated method path on an object, returning the leaf function.
|
|
195
|
-
-
|
|
217
|
+
- value: unwrapBaseResponse
|
|
196
218
|
|
|
197
219
|
## @simpleapps-com/augur-server/api
|
|
198
220
|
|
|
@@ -209,6 +231,5 @@ const handler = createAugurApiHandler();
|
|
|
209
231
|
export const POST = handler;
|
|
210
232
|
```
|
|
211
233
|
|
|
212
|
-
|
|
213
234
|
## @simpleapps-com/augur-server/next-auth
|
|
214
235
|
|