@simpleapps-com/augur-server 0.4.3 → 0.5.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.
- package/dist/auth.d.ts +3 -40
- package/dist/auth.js.map +1 -1
- package/dist/{chunk-I7EWYSPA.js → chunk-R3XKAWHN.js} +17 -1
- package/dist/chunk-R3XKAWHN.js.map +1 -0
- package/dist/index.d.ts +14 -103
- package/dist/index.js +90 -61
- package/dist/index.js.map +1 -1
- package/dist/prefetch.js +8 -13
- package/dist/prefetch.js.map +1 -1
- package/dist/{site-IpNMQZr5.d.ts → site-D21WJ8z1.d.ts} +178 -862
- package/dist/testing.d.ts +2 -1
- package/package.json +4 -4
- package/dist/chunk-I7EWYSPA.js.map +0 -1
package/dist/auth.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { AugurAPI } from '@simpleapps-com/augur-api';
|
|
1
2
|
import { NextAuthConfig } from 'next-auth';
|
|
2
3
|
|
|
3
4
|
/** Base user fields shared across all Augur sites. */
|
|
@@ -34,46 +35,8 @@ interface AugurAuthCallbacks {
|
|
|
34
35
|
cartHdrUid?: number;
|
|
35
36
|
} | null>;
|
|
36
37
|
}
|
|
37
|
-
/**
|
|
38
|
-
|
|
39
|
-
* Any `AugurAPI` instance from `@simpleapps-com/augur-api` satisfies this.
|
|
40
|
-
*/
|
|
41
|
-
interface AugurAuthClient {
|
|
42
|
-
joomla: {
|
|
43
|
-
users: {
|
|
44
|
-
doc: {
|
|
45
|
-
get(userId: number, params?: {
|
|
46
|
-
edgeCache?: number | string;
|
|
47
|
-
}): Promise<{
|
|
48
|
-
data: {
|
|
49
|
-
id: number;
|
|
50
|
-
name: string;
|
|
51
|
-
username: string;
|
|
52
|
-
email: string;
|
|
53
|
-
customerId?: string;
|
|
54
|
-
contactId?: string;
|
|
55
|
-
};
|
|
56
|
-
}>;
|
|
57
|
-
};
|
|
58
|
-
};
|
|
59
|
-
};
|
|
60
|
-
commerce: {
|
|
61
|
-
cartHdr: {
|
|
62
|
-
lookup: {
|
|
63
|
-
get(params: {
|
|
64
|
-
userId: number;
|
|
65
|
-
customerId: number;
|
|
66
|
-
contactId: number;
|
|
67
|
-
cartToken?: string;
|
|
68
|
-
}): Promise<{
|
|
69
|
-
data: {
|
|
70
|
-
cartHdrUid?: number;
|
|
71
|
-
};
|
|
72
|
-
}>;
|
|
73
|
-
};
|
|
74
|
-
};
|
|
75
|
-
};
|
|
76
|
-
}
|
|
38
|
+
/** Derived from augur-api SDK — keeps types in sync automatically. */
|
|
39
|
+
type AugurAuthClient = Pick<AugurAPI, "joomla" | "commerce">;
|
|
77
40
|
interface CreateAuthConfigOptions {
|
|
78
41
|
/** Augur SDK client. When provided, auth SDK calls are handled internally. */
|
|
79
42
|
augurClient?: AugurAuthClient;
|
package/dist/auth.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/auth.ts"],"sourcesContent":["// @simpleapps-com/augur-server/auth\n// NextAuth 5 configuration factory for Augur ecommerce sites.\n\nimport type { NextAuthConfig } from \"next-auth\";\nimport Credentials from \"next-auth/providers/credentials\";\n\n/** Base user fields shared across all Augur sites. */\nexport interface AugurUser {\n id: string;\n username: string;\n isVerified: boolean;\n name?: string;\n email?: string;\n customerId?: string | number;\n contactId?: string | number;\n cartHdrUid?: number;\n token?: string;\n}\n\n/** Session shape returned by all Augur sites. */\nexport interface AugurSession {\n user: AugurUser;\n token?: string;\n expires: string;\n}\n\n/** JWT token shape used by Augur auth. */\nexport interface AugurJWT {\n id: string;\n username: string;\n isVerified: boolean;\n token?: string;\n}\n\n/** Site-specific callbacks the consumer can provide. */\nexport interface AugurAuthCallbacks {\n /** Fetch user profile from the Augur API given the user's Joomla ID. */\n getUserProfile: (userId: string) => Promise<AugurUser | null>;\n /** Look up or create a cart header for the authenticated user. */\n cartHdrLookup?: (\n userId: string | number,\n token: string,\n contactId: string | number,\n customerId: string | number,\n ) => Promise<{ cartHdrUid?: number } | null>;\n}\n\n/**\n * Minimal interface for the Augur SDK client used by auth internals.\n * Any `AugurAPI` instance from `@simpleapps-com/augur-api` satisfies this.\n */\nexport interface AugurAuthClient {\n joomla: {\n users: {\n doc: {\n get(\n userId: number,\n params?: { edgeCache?: number | string },\n ): Promise<{\n data: {\n id: number;\n name: string;\n username: string;\n email: string;\n customerId?: string;\n contactId?: string;\n };\n }>;\n };\n };\n };\n commerce: {\n cartHdr: {\n lookup: {\n get(params: {\n userId: number;\n customerId: number;\n contactId: number;\n cartToken?: string;\n }): Promise<{\n data: { cartHdrUid?: number };\n }>;\n };\n };\n };\n}\n\nexport interface CreateAuthConfigOptions {\n /** Augur SDK client. When provided, auth SDK calls are handled internally. */\n augurClient?: AugurAuthClient;\n /** Site-specific callbacks. Override internal SDK calls when custom behavior is needed. */\n callbacks?: Partial<AugurAuthCallbacks>;\n /** NextAuth secret (defaults to NEXT_PUBLIC_AUTH_SECRET env var). */\n secret?: string;\n /** Session max age in seconds (defaults to 4 hours). */\n maxAge?: number;\n /** Default customer ID when profile doesn't provide one. */\n defaultCustomerId?: string | number;\n /** Default contact ID for cart header lookups. */\n defaultContactId?: string | number;\n /** Enable NextAuth debug logging (defaults to NODE_ENV === \"development\"). */\n debug?: boolean;\n}\n\n/** Build internal callbacks that call the Augur SDK directly. */\nfunction buildInternalCallbacks(\n augurClient: AugurAuthClient,\n): AugurAuthCallbacks {\n return {\n async getUserProfile(userId: string): Promise<AugurUser | null> {\n if (!userId) return null;\n const uid = parseInt(userId, 10);\n if (isNaN(uid)) return null;\n const result = await augurClient.joomla.users.doc.get(uid, {\n edgeCache: 1,\n });\n const data = result.data;\n if (!data) return null;\n return {\n id: String(data.id),\n name: data.name,\n username: data.username,\n email: data.email,\n isVerified: true,\n customerId: data.customerId,\n contactId: data.contactId,\n };\n },\n async cartHdrLookup(\n userId: string | number,\n _token: string,\n contactId: string | number,\n customerId: string | number,\n ): Promise<{ cartHdrUid?: number } | null> {\n const result = await augurClient.commerce.cartHdr.lookup.get({\n userId: Number(userId) || 0,\n customerId: Number(customerId) || 0,\n contactId: Number(contactId) || 0,\n });\n return result.data ?? null;\n },\n };\n}\n\n/** Resolve final callbacks: callback overrides take priority over internal SDK calls. */\nfunction resolveCallbacks(\n options: CreateAuthConfigOptions,\n): AugurAuthCallbacks {\n const { augurClient, callbacks } = options;\n\n if (augurClient) {\n const internal = buildInternalCallbacks(augurClient);\n return {\n getUserProfile: callbacks?.getUserProfile ?? internal.getUserProfile,\n cartHdrLookup: callbacks?.cartHdrLookup ?? internal.cartHdrLookup,\n };\n }\n\n if (!callbacks?.getUserProfile) {\n throw new Error(\n \"createAuthConfig requires either `augurClient` or `callbacks.getUserProfile`\",\n );\n }\n\n return {\n getUserProfile: callbacks.getUserProfile,\n cartHdrLookup: callbacks.cartHdrLookup,\n };\n}\n\n/**\n * Create a NextAuth 5 configuration for an Augur ecommerce site.\n *\n * Accepts either an `augurClient` (recommended) for zero-boilerplate auth,\n * or explicit `callbacks` for custom behavior. Callback overrides take\n * priority when both are provided.\n *\n * @example\n * ```ts\n * // Recommended: pass the SDK client directly\n * import NextAuth from \"next-auth\";\n * import { createAuthConfig } from \"@simpleapps-com/augur-server/auth\";\n * import { augurClient } from \"@/lib/augur-client\";\n *\n * export const { handlers, signIn, signOut, auth } = NextAuth(\n * createAuthConfig({\n * augurClient,\n * defaultCustomerId: process.env.NEXT_PUBLIC_DEFAULT_CUSTOMER_ID,\n * defaultContactId: process.env.NEXT_PUBLIC_DEFAULT_CONTACT_ID,\n * }),\n * );\n * ```\n *\n * @example\n * ```ts\n * // Custom callbacks (backward-compatible)\n * import NextAuth from \"next-auth\";\n * import { createAuthConfig } from \"@simpleapps-com/augur-server/auth\";\n *\n * export const { handlers, signIn, signOut, auth } = NextAuth(\n * createAuthConfig({\n * callbacks: { getUserProfile, cartHdrLookup },\n * defaultCustomerId: process.env.NEXT_PUBLIC_DEFAULT_CUSTOMER_ID,\n * }),\n * );\n * ```\n */\nasync function lookupCartHdr(\n siteCallbacks: AugurAuthCallbacks,\n profile: AugurUser,\n defaultCustomerId?: string | number,\n defaultContactId?: string | number,\n): Promise<number | undefined> {\n if (!siteCallbacks.cartHdrLookup || !profile.id) return undefined;\n const cartHdr = await siteCallbacks.cartHdrLookup(\n profile.id,\n \"\",\n profile.contactId ?? defaultContactId ?? \"\",\n profile.customerId ?? defaultCustomerId ?? \"\",\n );\n return cartHdr?.cartHdrUid;\n}\n\nexport function createAuthConfig(\n options: CreateAuthConfigOptions,\n): NextAuthConfig {\n const {\n secret = process.env.NEXT_PUBLIC_AUTH_SECRET,\n maxAge = 4 * 60 * 60,\n defaultCustomerId,\n defaultContactId,\n debug = process.env.NODE_ENV === \"development\",\n } = options;\n\n const siteCallbacks = resolveCallbacks(options);\n\n return {\n providers: [\n Credentials({\n name: \"Credentials\",\n credentials: {\n username: { label: \"Username\", type: \"text\" },\n password: { label: \"Password\", type: \"password\" },\n id: { label: \"ID\", type: \"text\" },\n isVerified: { label: \"Is Verified\", type: \"text\" },\n token: { label: \"Token\", type: \"text\" },\n },\n async authorize(credentials) {\n if (!credentials) return null;\n\n const { id, isVerified, username, token } = credentials as {\n id: string;\n isVerified: string;\n username: string;\n token: string;\n };\n\n return {\n id,\n isVerified: isVerified === \"true\",\n username,\n token,\n };\n },\n }),\n ],\n callbacks: {\n async signIn() {\n return true;\n },\n async redirect({ baseUrl }) {\n return baseUrl;\n },\n async session({ session, token }) {\n const baseUser = {\n id: (token.id as string) || \"\",\n username: (token.username as string) || \"\",\n isVerified: (token.isVerified as boolean) || false,\n };\n\n const buildSession = (userOverrides = {}) => ({\n ...session,\n user: { ...session.user, ...baseUser, ...userOverrides },\n token: token.token as string | undefined,\n });\n\n try {\n const userProfile = await siteCallbacks.getUserProfile(baseUser.id);\n if (!userProfile) return buildSession();\n\n const cartHdrUid = await lookupCartHdr(\n siteCallbacks,\n userProfile,\n defaultCustomerId,\n defaultContactId,\n );\n\n return buildSession({\n name: userProfile.name ?? session.user?.name,\n email: userProfile.email ?? session.user?.email,\n customerId: userProfile.customerId ?? defaultCustomerId,\n contactId: userProfile.contactId,\n cartHdrUid,\n });\n } catch {\n return buildSession();\n }\n },\n async jwt({ token, user }) {\n if (user) {\n const typedUser = user as {\n id: string;\n isVerified: boolean;\n username: string;\n token: string;\n };\n\n return {\n ...token,\n id: typedUser.id,\n isVerified: typedUser.isVerified,\n username: typedUser.username,\n token: typedUser.token,\n };\n }\n return token;\n },\n },\n secret,\n debug,\n session: {\n strategy: \"jwt\",\n maxAge,\n },\n trustHost: true,\n };\n}\n"],"mappings":";AAIA,OAAO,iBAAiB;AAqGxB,SAAS,uBACP,aACoB;AACpB,SAAO;AAAA,IACL,MAAM,eAAe,QAA2C;AAC9D,UAAI,CAAC,OAAQ,QAAO;AACpB,YAAM,MAAM,SAAS,QAAQ,EAAE;AAC/B,UAAI,MAAM,GAAG,EAAG,QAAO;AACvB,YAAM,SAAS,MAAM,YAAY,OAAO,MAAM,IAAI,IAAI,KAAK;AAAA,QACzD,WAAW;AAAA,MACb,CAAC;AACD,YAAM,OAAO,OAAO;AACpB,UAAI,CAAC,KAAM,QAAO;AAClB,aAAO;AAAA,QACL,IAAI,OAAO,KAAK,EAAE;AAAA,QAClB,MAAM,KAAK;AAAA,QACX,UAAU,KAAK;AAAA,QACf,OAAO,KAAK;AAAA,QACZ,YAAY;AAAA,QACZ,YAAY,KAAK;AAAA,QACjB,WAAW,KAAK;AAAA,MAClB;AAAA,IACF;AAAA,IACA,MAAM,cACJ,QACA,QACA,WACA,YACyC;AACzC,YAAM,SAAS,MAAM,YAAY,SAAS,QAAQ,OAAO,IAAI;AAAA,QAC3D,QAAQ,OAAO,MAAM,KAAK;AAAA,QAC1B,YAAY,OAAO,UAAU,KAAK;AAAA,QAClC,WAAW,OAAO,SAAS,KAAK;AAAA,MAClC,CAAC;AACD,aAAO,OAAO,QAAQ;AAAA,IACxB;AAAA,EACF;AACF;AAGA,SAAS,iBACP,SACoB;AACpB,QAAM,EAAE,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;AAAA,YACpB,OAAO,UAAU;AAAA,UACnB;AAAA,QACF;AACA,eAAO;AAAA,MACT;AAAA,IACF;AAAA,IACA;AAAA,IACA;AAAA,IACA,SAAS;AAAA,MACP,UAAU;AAAA,MACV;AAAA,IACF;AAAA,IACA,WAAW;AAAA,EACb;AACF;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../src/auth.ts"],"sourcesContent":["// @simpleapps-com/augur-server/auth\n// NextAuth 5 configuration factory for Augur ecommerce sites.\n\nimport type { AugurAPI } from \"@simpleapps-com/augur-api\";\nimport type { NextAuthConfig } from \"next-auth\";\nimport Credentials from \"next-auth/providers/credentials\";\n\n/** Base user fields shared across all Augur sites. */\nexport interface AugurUser {\n id: string;\n username: string;\n isVerified: boolean;\n name?: string;\n email?: string;\n customerId?: string | number;\n contactId?: string | number;\n cartHdrUid?: number;\n token?: string;\n}\n\n/** Session shape returned by all Augur sites. */\nexport interface AugurSession {\n user: AugurUser;\n token?: string;\n expires: string;\n}\n\n/** JWT token shape used by Augur auth. */\nexport interface AugurJWT {\n id: string;\n username: string;\n isVerified: boolean;\n token?: string;\n}\n\n/** Site-specific callbacks the consumer can provide. */\nexport interface AugurAuthCallbacks {\n /** Fetch user profile from the Augur API given the user's Joomla ID. */\n getUserProfile: (userId: string) => Promise<AugurUser | null>;\n /** Look up or create a cart header for the authenticated user. */\n cartHdrLookup?: (\n userId: string | number,\n token: string,\n contactId: string | number,\n customerId: string | number,\n ) => Promise<{ cartHdrUid?: number } | null>;\n}\n\n/** Derived from augur-api SDK — keeps types in sync automatically. */\nexport type AugurAuthClient = Pick<AugurAPI, \"joomla\" | \"commerce\">;\n\nexport interface CreateAuthConfigOptions {\n /** Augur SDK client. When provided, auth SDK calls are handled internally. */\n augurClient?: AugurAuthClient;\n /** Site-specific callbacks. Override internal SDK calls when custom behavior is needed. */\n callbacks?: Partial<AugurAuthCallbacks>;\n /** NextAuth secret (defaults to NEXT_PUBLIC_AUTH_SECRET env var). */\n secret?: string;\n /** Session max age in seconds (defaults to 4 hours). */\n maxAge?: number;\n /** Default customer ID when profile doesn't provide one. */\n defaultCustomerId?: string | number;\n /** Default contact ID for cart header lookups. */\n defaultContactId?: string | number;\n /** Enable NextAuth debug logging (defaults to NODE_ENV === \"development\"). */\n debug?: boolean;\n}\n\n/** Build internal callbacks that call the Augur SDK directly. */\nfunction buildInternalCallbacks(\n augurClient: AugurAuthClient,\n): AugurAuthCallbacks {\n return {\n async getUserProfile(userId: string): Promise<AugurUser | null> {\n if (!userId) return null;\n const uid = parseInt(userId, 10);\n if (isNaN(uid)) return null;\n const result = await augurClient.joomla.users.doc.get(uid, {\n edgeCache: 1,\n });\n const data = result.data;\n if (!data) return null;\n return {\n id: String(data.id),\n name: data.name,\n username: data.username,\n email: data.email,\n isVerified: true,\n customerId: data.customerId,\n contactId: data.contactId,\n };\n },\n async cartHdrLookup(\n userId: string | number,\n _token: string,\n contactId: string | number,\n customerId: string | number,\n ): Promise<{ cartHdrUid?: number } | null> {\n const result = await augurClient.commerce.cartHdr.lookup.get({\n userId: Number(userId) || 0,\n customerId: Number(customerId) || 0,\n contactId: Number(contactId) || 0,\n });\n return result.data ?? null;\n },\n };\n}\n\n/** Resolve final callbacks: callback overrides take priority over internal SDK calls. */\nfunction resolveCallbacks(\n options: CreateAuthConfigOptions,\n): AugurAuthCallbacks {\n const { augurClient, callbacks } = options;\n\n if (augurClient) {\n const internal = buildInternalCallbacks(augurClient);\n return {\n getUserProfile: callbacks?.getUserProfile ?? internal.getUserProfile,\n cartHdrLookup: callbacks?.cartHdrLookup ?? internal.cartHdrLookup,\n };\n }\n\n if (!callbacks?.getUserProfile) {\n throw new Error(\n \"createAuthConfig requires either `augurClient` or `callbacks.getUserProfile`\",\n );\n }\n\n return {\n getUserProfile: callbacks.getUserProfile,\n cartHdrLookup: callbacks.cartHdrLookup,\n };\n}\n\n/**\n * Create a NextAuth 5 configuration for an Augur ecommerce site.\n *\n * Accepts either an `augurClient` (recommended) for zero-boilerplate auth,\n * or explicit `callbacks` for custom behavior. Callback overrides take\n * priority when both are provided.\n *\n * @example\n * ```ts\n * // Recommended: pass the SDK client directly\n * import NextAuth from \"next-auth\";\n * import { createAuthConfig } from \"@simpleapps-com/augur-server/auth\";\n * import { augurClient } from \"@/lib/augur-client\";\n *\n * export const { handlers, signIn, signOut, auth } = NextAuth(\n * createAuthConfig({\n * augurClient,\n * defaultCustomerId: process.env.NEXT_PUBLIC_DEFAULT_CUSTOMER_ID,\n * defaultContactId: process.env.NEXT_PUBLIC_DEFAULT_CONTACT_ID,\n * }),\n * );\n * ```\n *\n * @example\n * ```ts\n * // Custom callbacks (backward-compatible)\n * import NextAuth from \"next-auth\";\n * import { createAuthConfig } from \"@simpleapps-com/augur-server/auth\";\n *\n * export const { handlers, signIn, signOut, auth } = NextAuth(\n * createAuthConfig({\n * callbacks: { getUserProfile, cartHdrLookup },\n * defaultCustomerId: process.env.NEXT_PUBLIC_DEFAULT_CUSTOMER_ID,\n * }),\n * );\n * ```\n */\nasync function lookupCartHdr(\n siteCallbacks: AugurAuthCallbacks,\n profile: AugurUser,\n defaultCustomerId?: string | number,\n defaultContactId?: string | number,\n): Promise<number | undefined> {\n if (!siteCallbacks.cartHdrLookup || !profile.id) return undefined;\n const cartHdr = await siteCallbacks.cartHdrLookup(\n profile.id,\n \"\",\n profile.contactId ?? defaultContactId ?? \"\",\n profile.customerId ?? defaultCustomerId ?? \"\",\n );\n return cartHdr?.cartHdrUid;\n}\n\nexport function createAuthConfig(\n options: CreateAuthConfigOptions,\n): NextAuthConfig {\n const {\n secret = process.env.NEXT_PUBLIC_AUTH_SECRET,\n maxAge = 4 * 60 * 60,\n defaultCustomerId,\n defaultContactId,\n debug = process.env.NODE_ENV === \"development\",\n } = options;\n\n const siteCallbacks = resolveCallbacks(options);\n\n return {\n providers: [\n Credentials({\n name: \"Credentials\",\n credentials: {\n username: { label: \"Username\", type: \"text\" },\n password: { label: \"Password\", type: \"password\" },\n id: { label: \"ID\", type: \"text\" },\n isVerified: { label: \"Is Verified\", type: \"text\" },\n token: { label: \"Token\", type: \"text\" },\n },\n async authorize(credentials) {\n if (!credentials) return null;\n\n const { id, isVerified, username, token } = credentials as {\n id: string;\n isVerified: string;\n username: string;\n token: string;\n };\n\n return {\n id,\n isVerified: isVerified === \"true\",\n username,\n token,\n };\n },\n }),\n ],\n callbacks: {\n async signIn() {\n return true;\n },\n async redirect({ baseUrl }) {\n return baseUrl;\n },\n async session({ session, token }) {\n const baseUser = {\n id: (token.id as string) || \"\",\n username: (token.username as string) || \"\",\n isVerified: (token.isVerified as boolean) || false,\n };\n\n const buildSession = (userOverrides = {}) => ({\n ...session,\n user: { ...session.user, ...baseUser, ...userOverrides },\n token: token.token as string | undefined,\n });\n\n try {\n const userProfile = await siteCallbacks.getUserProfile(baseUser.id);\n if (!userProfile) return buildSession();\n\n const cartHdrUid = await lookupCartHdr(\n siteCallbacks,\n userProfile,\n defaultCustomerId,\n defaultContactId,\n );\n\n return buildSession({\n name: userProfile.name ?? session.user?.name,\n email: userProfile.email ?? session.user?.email,\n customerId: userProfile.customerId ?? defaultCustomerId,\n contactId: userProfile.contactId,\n cartHdrUid,\n });\n } catch {\n return buildSession();\n }\n },\n async jwt({ token, user }) {\n if (user) {\n const typedUser = user as {\n id: string;\n isVerified: boolean;\n username: string;\n token: string;\n };\n\n return {\n ...token,\n id: typedUser.id,\n isVerified: typedUser.isVerified,\n username: typedUser.username,\n token: typedUser.token,\n };\n }\n return token;\n },\n },\n secret,\n debug,\n session: {\n strategy: \"jwt\",\n maxAge,\n },\n trustHost: true,\n };\n}\n"],"mappings":";AAKA,OAAO,iBAAiB;AAgExB,SAAS,uBACP,aACoB;AACpB,SAAO;AAAA,IACL,MAAM,eAAe,QAA2C;AAC9D,UAAI,CAAC,OAAQ,QAAO;AACpB,YAAM,MAAM,SAAS,QAAQ,EAAE;AAC/B,UAAI,MAAM,GAAG,EAAG,QAAO;AACvB,YAAM,SAAS,MAAM,YAAY,OAAO,MAAM,IAAI,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MAAM;AAAA,QACf;AAEA,YAAI;AACF,gBAAM,cAAc,MAAM,cAAc,eAAe,SAAS,EAAE;AAClE,cAAI,CAAC,YAAa,QAAO,aAAa;AAEtC,gBAAM,aAAa,MAAM;AAAA,YACvB;AAAA,YACA;AAAA,YACA;AAAA,YACA;AAAA,UACF;AAEA,iBAAO,aAAa;AAAA,YAClB,MAAM,YAAY,QAAQ,QAAQ,MAAM;AAAA,YACxC,OAAO,YAAY,SAAS,QAAQ,MAAM;AAAA,YAC1C,YAAY,YAAY,cAAc;AAAA,YACtC,WAAW,YAAY;AAAA,YACvB;AAAA,UACF,CAAC;AAAA,QACH,QAAQ;AACN,iBAAO,aAAa;AAAA,QACtB;AAAA,MACF;AAAA,MACA,MAAM,IAAI,EAAE,OAAO,KAAK,GAAG;AACzB,YAAI,MAAM;AACR,gBAAM,YAAY;AAOlB,iBAAO;AAAA,YACL,GAAG;AAAA,YACH,IAAI,UAAU;AAAA,YACd,YAAY,UAAU;AAAA,YACtB,UAAU,UAAU;AAAA,YACpB,OAAO,UAAU;AAAA,UACnB;AAAA,QACF;AACA,eAAO;AAAA,MACT;AAAA,IACF;AAAA,IACA;AAAA,IACA;AAAA,IACA,SAAS;AAAA,MACP,UAAU;AAAA,MACV;AAAA,IACF;AAAA,IACA,WAAW;AAAA,EACb;AACF;","names":[]}
|
|
@@ -1,3 +1,18 @@
|
|
|
1
|
+
// src/utils/batch-fetch.ts
|
|
2
|
+
async function batchFetch(params, fetchOne, getKey) {
|
|
3
|
+
if (params.length === 0) return {};
|
|
4
|
+
const results = await Promise.all(
|
|
5
|
+
params.map(
|
|
6
|
+
(p) => fetchOne(p).then((data) => [getKey(p), data]).catch(() => [getKey(p), void 0])
|
|
7
|
+
)
|
|
8
|
+
);
|
|
9
|
+
const out = {};
|
|
10
|
+
for (const [key, data] of results) {
|
|
11
|
+
if (data !== void 0) out[key] = data;
|
|
12
|
+
}
|
|
13
|
+
return out;
|
|
14
|
+
}
|
|
15
|
+
|
|
1
16
|
// src/server-query-client.ts
|
|
2
17
|
import { cache } from "react";
|
|
3
18
|
import { QueryClient } from "@tanstack/react-query";
|
|
@@ -21,7 +36,8 @@ var getServerQueryClient = cache(
|
|
|
21
36
|
);
|
|
22
37
|
|
|
23
38
|
export {
|
|
39
|
+
batchFetch,
|
|
24
40
|
createServerQueryClient,
|
|
25
41
|
getServerQueryClient
|
|
26
42
|
};
|
|
27
|
-
//# sourceMappingURL=chunk-
|
|
43
|
+
//# sourceMappingURL=chunk-R3XKAWHN.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/utils/batch-fetch.ts","../src/server-query-client.ts"],"sourcesContent":["/**\n * Fetches data for multiple params in parallel, returning a Record keyed by\n * `getKey(param)`. Individual failures are silently excluded from the result\n * so one bad item never takes down the entire batch.\n */\nexport async function batchFetch<TParam, TKey extends string | number, TData>(\n params: TParam[],\n fetchOne: (param: TParam) => Promise<TData>,\n getKey: (param: TParam) => TKey,\n): Promise<Record<TKey, TData>> {\n if (params.length === 0) return {} as Record<TKey, TData>;\n\n const results = await Promise.all(\n params.map((p) =>\n fetchOne(p)\n .then((data) => [getKey(p), data] as const)\n .catch(() => [getKey(p), undefined] as const),\n ),\n );\n\n const out = {} as Record<TKey, TData>;\n for (const [key, data] of results) {\n if (data !== undefined) out[key] = data;\n }\n return out;\n}\n","import { cache } from \"react\";\nimport { QueryClient } from \"@tanstack/react-query\";\nimport { CACHE_CONFIG } from \"@simpleapps-com/augur-utils\";\n\n/**\n * Creates a server-side query client optimised for prefetching.\n *\n * - No persistence (server-only)\n * - Longer cache times for prefetched data\n * - No retries (fail fast on server)\n * - No refetching (server renders are one-shot)\n */\nexport function createServerQueryClient(): QueryClient {\n return new QueryClient({\n defaultOptions: {\n queries: {\n staleTime: CACHE_CONFIG.STATIC.staleTime,\n gcTime: CACHE_CONFIG.STATIC.staleTime,\n retry: 0,\n refetchOnMount: false,\n refetchOnWindowFocus: false,\n refetchOnReconnect: false,\n },\n },\n });\n}\n\n/**\n * Returns a per-request singleton QueryClient for React Server Components.\n *\n * React's `cache()` deduplicates calls within a single server request,\n * so each request gets its own QueryClient while avoiding the cross-request\n * state leakage that a module-level singleton would cause.\n */\nexport const getServerQueryClient = cache(\n (): QueryClient => createServerQueryClient(),\n);\n"],"mappings":";AAKA,eAAsB,WACpB,QACA,UACA,QAC8B;AAC9B,MAAI,OAAO,WAAW,EAAG,QAAO,CAAC;AAEjC,QAAM,UAAU,MAAM,QAAQ;AAAA,IAC5B,OAAO;AAAA,MAAI,CAAC,MACV,SAAS,CAAC,EACP,KAAK,CAAC,SAAS,CAAC,OAAO,CAAC,GAAG,IAAI,CAAU,EACzC,MAAM,MAAM,CAAC,OAAO,CAAC,GAAG,MAAS,CAAU;AAAA,IAChD;AAAA,EACF;AAEA,QAAM,MAAM,CAAC;AACb,aAAW,CAAC,KAAK,IAAI,KAAK,SAAS;AACjC,QAAI,SAAS,OAAW,KAAI,GAAG,IAAI;AAAA,EACrC;AACA,SAAO;AACT;;;ACzBA,SAAS,aAAa;AACtB,SAAS,mBAAmB;AAC5B,SAAS,oBAAoB;AAUtB,SAAS,0BAAuC;AACrD,SAAO,IAAI,YAAY;AAAA,IACrB,gBAAgB;AAAA,MACd,SAAS;AAAA,QACP,WAAW,aAAa,OAAO;AAAA,QAC/B,QAAQ,aAAa,OAAO;AAAA,QAC5B,OAAO;AAAA,QACP,gBAAgB;AAAA,QAChB,sBAAsB;AAAA,QACtB,oBAAoB;AAAA,MACtB;AAAA,IACF;AAAA,EACF,CAAC;AACH;AASO,IAAM,uBAAuB;AAAA,EAClC,MAAmB,wBAAwB;AAC7C;","names":[]}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
|
+
import { E as EdgeCacheValue } from './site-D21WJ8z1.js';
|
|
2
|
+
export { A as ActionResult, a as AddressValidationResult, b as AgrInfoActions, c as AgrInfoActionsConfig, d as AgrInfoApiClient, e as AgrSiteActions, f as AgrSiteActionsConfig, g as AgrSiteApiClient, h as AgrWorkActions, i as AgrWorkActionsConfig, j as AgrWorkApiClient, k as AvalaraActions, l as AvalaraActionsConfig, m as AvalaraApiClient, B as Basecamp2Actions, n as Basecamp2ActionsConfig, o as Basecamp2ApiClient, p as BrandFolderActions, q as BrandFolderActionsConfig, r as BrandFolderApiClient, C as CommerceActions, s as CommerceActionsConfig, t as CommerceApiClient, u as CustomerListResult, v as CustomersActions, w as CustomersActionsConfig, x as CustomersApiClient, G as GregorovichActions, y as GregorovichActionsConfig, z as GregorovichApiClient, I as ItemActions, D as ItemActionsConfig, F as ItemsApiClient, J as JoomlaActions, H as JoomlaActionsConfig, K as JoomlaApiClient, L as LegacyActions, M as LegacyActionsConfig, N as LegacyApiClient, O as LogisticsActions, P as LogisticsActionsConfig, Q as LogisticsApiClient, R as NexusActions, S as NexusActionsConfig, T as NexusApiClient, U as NormalizedUserProfile, V as OrderActions, W as OrderActionsConfig, X as OrderApiClient, Y as P21ApisActions, Z as P21ApisActionsConfig, _ as P21ApisApiClient, $ as P21CoreActions, a0 as P21CoreActionsConfig, a1 as P21CoreApiClient, a2 as P21PimActions, a3 as P21PimActionsConfig, a4 as P21PimApiClient, a5 as P21SismActions, a6 as P21SismActionsConfig, a7 as P21SismApiClient, a8 as PaymentsActions, a9 as PaymentsActionsConfig, aa as PaymentsApiClient, ab as PricingActions, ac as PricingActionsConfig, ad as PricingApiClient, ae as SearchActions, af as SearchActionsConfig, ag as SearchApiClient, ah as SearchPage, ai as ShippingActions, aj as ShippingActionsConfig, ak as ShippingAddress, al as ShippingApiClient, am as SiteActions, an as SiteActionsConfig, ao as SlackActions, ap as SlackActionsConfig, aq as SlackApiClient, ar as SmartyStreetsActions, as as SmartyStreetsActionsConfig, at as SmartyStreetsApiClient, au as UpsActions, av as UpsActionsConfig, aw as UpsApiClient, ax as VmiActions, ay as VmiActionsConfig, az as VmiApiClient, aA as createAgrInfoActions, aB as createAgrSiteActions, aC as createAgrWorkActions, aD as createAvalaraActions, aE as createBasecamp2Actions, aF as createBrandFolderActions, aG as createCommerceActions, aH as createCustomersActions, aI as createGregorovichActions, aJ as createItemActions, aK as createJoomlaActions, aL as createLegacyActions, aM as createLogisticsActions, aN as createNexusActions, aO as createOrderActions, aP as createP21ApisActions, aQ as createP21CoreActions, aR as createP21PimActions, aS as createP21SismActions, aT as createPaymentsActions, aU as createPricingActions, aV as createSearchActions, aW as createShippingActions, aX as createSiteActions, aY as createSlackActions, aZ as createSmartyStreetsActions, a_ as createUpsActions, a$ as createVmiActions, b0 as safeAction, b1 as sdkCall } from './site-D21WJ8z1.js';
|
|
1
3
|
import { QueryClient } from '@tanstack/react-query';
|
|
2
4
|
export { QueryOptionsConfig, createQueryOptions, createSuspenseQueryOptions } from './query.js';
|
|
3
|
-
|
|
5
|
+
import { AugurAPI } from '@simpleapps-com/augur-api';
|
|
4
6
|
import '@simpleapps-com/augur-utils';
|
|
5
7
|
|
|
6
8
|
declare const env: "development" | "staging" | "production";
|
|
@@ -14,69 +16,11 @@ declare function getCircuitState(): "closed" | "open";
|
|
|
14
16
|
declare function isRedisConnected(): boolean;
|
|
15
17
|
|
|
16
18
|
/**
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
* option (including `edgeCache`), so this wrapper preserves both parameter
|
|
21
|
-
* and return-type inference end-to-end.
|
|
22
|
-
*
|
|
23
|
-
* @example
|
|
24
|
-
* ```ts
|
|
25
|
-
* const result = await sdkCall(
|
|
26
|
-
* augurServices.items.invMast.get,
|
|
27
|
-
* invMastUid,
|
|
28
|
-
* { edgeCache: 4 },
|
|
29
|
-
* );
|
|
30
|
-
* ```
|
|
31
|
-
*/
|
|
32
|
-
declare function sdkCall<TArgs extends unknown[], TResult>(method: (...args: TArgs) => Promise<TResult>, ...args: TArgs): Promise<TResult>;
|
|
33
|
-
/**
|
|
34
|
-
* Discriminated union for safe action results.
|
|
35
|
-
* Same pattern as next-safe-action — callers check `result.ok` to
|
|
36
|
-
* determine success or failure with typed error info.
|
|
37
|
-
*/
|
|
38
|
-
type ActionResult<T> = {
|
|
39
|
-
ok: true;
|
|
40
|
-
data: T;
|
|
41
|
-
} | {
|
|
42
|
-
ok: false;
|
|
43
|
-
error: string;
|
|
44
|
-
};
|
|
45
|
-
/**
|
|
46
|
-
* Wraps an async function call with error handling, returning an
|
|
47
|
-
* `ActionResult<T>` instead of throwing.
|
|
48
|
-
*
|
|
49
|
-
* Use this to eliminate try/catch boilerplate in server actions.
|
|
50
|
-
* Reads that go through React Query should NOT use this — let errors
|
|
51
|
-
* propagate so React Query can handle retries and error state.
|
|
52
|
-
*
|
|
53
|
-
* @param fn — The async function to execute
|
|
54
|
-
* @param onError — Optional callback for logging/reporting
|
|
55
|
-
*
|
|
56
|
-
* @example
|
|
57
|
-
* ```ts
|
|
58
|
-
* // Before (boilerplate wrapper):
|
|
59
|
-
* export async function addToCart(cartId: number, items: CartItem[]) {
|
|
60
|
-
* try {
|
|
61
|
-
* return await actions.commerce.addToCart(cartId, items);
|
|
62
|
-
* } catch (error) {
|
|
63
|
-
* console.error("addToCart error:", error);
|
|
64
|
-
* return undefined;
|
|
65
|
-
* }
|
|
66
|
-
* }
|
|
67
|
-
*
|
|
68
|
-
* // After (one-liner):
|
|
69
|
-
* const result = await safeAction(
|
|
70
|
-
* () => actions.commerce.addToCart(cartId, items),
|
|
71
|
-
* );
|
|
72
|
-
* if (result.ok) {
|
|
73
|
-
* // result.data is the response
|
|
74
|
-
* } else {
|
|
75
|
-
* // result.error is the error message
|
|
76
|
-
* }
|
|
77
|
-
* ```
|
|
19
|
+
* Fetches data for multiple params in parallel, returning a Record keyed by
|
|
20
|
+
* `getKey(param)`. Individual failures are silently excluded from the result
|
|
21
|
+
* so one bad item never takes down the entire batch.
|
|
78
22
|
*/
|
|
79
|
-
declare function
|
|
23
|
+
declare function batchFetch<TParam, TKey extends string | number, TData>(params: TParam[], fetchOne: (param: TParam) => Promise<TData>, getKey: (param: TParam) => TKey): Promise<Record<TKey, TData>>;
|
|
80
24
|
|
|
81
25
|
/**
|
|
82
26
|
* Creates a server-side query client optimised for prefetching.
|
|
@@ -145,35 +89,13 @@ interface PaginatedResult<T> {
|
|
|
145
89
|
*/
|
|
146
90
|
declare function paginateOffset<T>(items: T[], pageParam: number, limit: number, total?: number): PaginatedResult<T>;
|
|
147
91
|
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
itemWishlist: {
|
|
151
|
-
list: (userId: number, params?: Record<string, unknown>) => Promise<{
|
|
152
|
-
data: unknown[];
|
|
153
|
-
}>;
|
|
154
|
-
create: (userId: number, data: Record<string, unknown>) => Promise<{
|
|
155
|
-
data: unknown;
|
|
156
|
-
}>;
|
|
157
|
-
hdr: {
|
|
158
|
-
get: (userId: number, wishlistId: number, params?: Record<string, unknown>) => Promise<{
|
|
159
|
-
data: unknown;
|
|
160
|
-
}>;
|
|
161
|
-
delete: (userId: number, wishlistId: number) => Promise<void>;
|
|
162
|
-
create: (userId: number, wishlistId: number, items: Record<string, unknown>[]) => Promise<{
|
|
163
|
-
data: unknown;
|
|
164
|
-
}>;
|
|
165
|
-
line: {
|
|
166
|
-
delete: (userId: number, wishlistId: number, lineId: number) => Promise<void>;
|
|
167
|
-
};
|
|
168
|
-
};
|
|
169
|
-
};
|
|
170
|
-
};
|
|
171
|
-
}
|
|
92
|
+
/** Derived from augur-api SDK — keeps types in sync automatically. */
|
|
93
|
+
type WishlistsApiClient = Pick<AugurAPI, "items">;
|
|
172
94
|
interface WishlistActionsConfig {
|
|
173
95
|
/** Cache key prefix (e.g. "ampro:"). Default: "". */
|
|
174
96
|
cachePrefix?: string;
|
|
175
97
|
/** CDN edge cache value passed to SDK. Default: 1 (hour). */
|
|
176
|
-
edgeCache?:
|
|
98
|
+
edgeCache?: EdgeCacheValue;
|
|
177
99
|
/** Redis TTL in seconds. Default: 3600 (1 hour). */
|
|
178
100
|
redisTtl?: number;
|
|
179
101
|
}
|
|
@@ -192,24 +114,13 @@ interface WishlistActions {
|
|
|
192
114
|
}
|
|
193
115
|
declare function createWishlistActions(api: WishlistsApiClient, config?: WishlistActionsConfig): WishlistActions;
|
|
194
116
|
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
itemFavorites: {
|
|
198
|
-
list: (userId: number, params?: Record<string, unknown>) => Promise<{
|
|
199
|
-
data: unknown[];
|
|
200
|
-
}>;
|
|
201
|
-
create: (userId: number, data: Record<string, unknown>) => Promise<{
|
|
202
|
-
data: unknown;
|
|
203
|
-
}>;
|
|
204
|
-
delete: (userId: number, invMastUid: number) => Promise<void>;
|
|
205
|
-
};
|
|
206
|
-
};
|
|
207
|
-
}
|
|
117
|
+
/** Derived from augur-api SDK — keeps types in sync automatically. */
|
|
118
|
+
type FavoritesApiClient = Pick<AugurAPI, "items">;
|
|
208
119
|
interface FavoritesActionsConfig {
|
|
209
120
|
/** Cache key prefix (e.g. "ampro:"). Default: "". */
|
|
210
121
|
cachePrefix?: string;
|
|
211
122
|
/** CDN edge cache value passed to SDK. Default: 1 (hour). */
|
|
212
|
-
edgeCache?:
|
|
123
|
+
edgeCache?: EdgeCacheValue;
|
|
213
124
|
/** Redis TTL in seconds. Default: 3600 (1 hour). */
|
|
214
125
|
redisTtl?: number;
|
|
215
126
|
}
|
|
@@ -220,4 +131,4 @@ interface FavoritesActions {
|
|
|
220
131
|
}
|
|
221
132
|
declare function createFavoritesActions(api: FavoritesApiClient, config?: FavoritesActionsConfig): FavoritesActions;
|
|
222
133
|
|
|
223
|
-
export {
|
|
134
|
+
export { EdgeCacheValue, type FavoritesActions, type FavoritesActionsConfig, type FavoritesApiClient, type PaginatedResult, type WishlistActions, type WishlistActionsConfig, type WishlistsApiClient, batchFetch, cacheGet, cacheSet, createFavoritesActions, createServerQueryClient, createWishlistActions, env, getCircuitState, getServerQueryClient, isDev, isProduction, isRedisConnected, isStaging, paginateOffset, withServerCache };
|