@simpleapps-com/augur-server 2.2.0 → 2.2.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/dist/actions.js +2 -2
- package/dist/auth.js +1 -1
- package/dist/{chunk-PVYUTFL3.js → chunk-BIRY5IYC.js} +2 -2
- package/dist/{chunk-R3XT54FD.js → chunk-DYHYL6ZS.js} +11 -10
- package/dist/chunk-DYHYL6ZS.js.map +1 -0
- package/dist/{chunk-SRX2DVOX.js → chunk-LOQGT6WV.js} +39 -30
- package/dist/chunk-LOQGT6WV.js.map +1 -0
- package/dist/hooks.d.ts +2 -2
- package/dist/hooks.js +2 -2
- package/dist/hooks.js.map +1 -1
- package/dist/index.js +1 -1
- package/dist/site.js +2 -2
- package/dist/testing.js +1 -1
- package/package.json +6 -6
- package/dist/chunk-R3XT54FD.js.map +0 -1
- package/dist/chunk-SRX2DVOX.js.map +0 -1
- /package/dist/{chunk-PVYUTFL3.js.map → chunk-BIRY5IYC.js.map} +0 -0
package/dist/actions.js
CHANGED
|
@@ -134,8 +134,8 @@ import {
|
|
|
134
134
|
validateAddress,
|
|
135
135
|
validatePayment,
|
|
136
136
|
verifyPassword
|
|
137
|
-
} from "./chunk-
|
|
138
|
-
import "./chunk-
|
|
137
|
+
} from "./chunk-BIRY5IYC.js";
|
|
138
|
+
import "./chunk-LOQGT6WV.js";
|
|
139
139
|
import "./chunk-DGUM43GV.js";
|
|
140
140
|
export {
|
|
141
141
|
accountQuery,
|
package/dist/auth.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
getSiteActions,
|
|
3
3
|
safeAction
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-LOQGT6WV.js";
|
|
5
5
|
|
|
6
6
|
// src/server-actions.ts
|
|
7
7
|
function siteAction(fn) {
|
|
@@ -567,4 +567,4 @@ export {
|
|
|
567
567
|
removeWishlistItem,
|
|
568
568
|
queryAction
|
|
569
569
|
};
|
|
570
|
-
//# sourceMappingURL=chunk-
|
|
570
|
+
//# sourceMappingURL=chunk-BIRY5IYC.js.map
|
|
@@ -12,20 +12,21 @@ function buildInternalCallbacks(augurClient) {
|
|
|
12
12
|
const data = result.data;
|
|
13
13
|
if (!data) return null;
|
|
14
14
|
return {
|
|
15
|
-
id: String(data
|
|
16
|
-
name: data
|
|
17
|
-
username: data
|
|
18
|
-
email: data
|
|
15
|
+
id: String(data["id"]),
|
|
16
|
+
name: data["name"],
|
|
17
|
+
username: data["username"],
|
|
18
|
+
email: data["email"],
|
|
19
19
|
isVerified: true,
|
|
20
|
-
customerId: data
|
|
21
|
-
contactId: data
|
|
20
|
+
customerId: data["customerId"],
|
|
21
|
+
contactId: data["contactId"]
|
|
22
22
|
};
|
|
23
23
|
},
|
|
24
24
|
async cartHdrLookup(userId, _token, contactId, customerId) {
|
|
25
25
|
const result = await augurClient.commerce.cartHdr.lookup.get({
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
26
|
+
user_id: Number(userId) || 0,
|
|
27
|
+
customer_id: Number(customerId) || 0,
|
|
28
|
+
contact_id: Number(contactId) || 0
|
|
29
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
29
30
|
});
|
|
30
31
|
return result.data ?? null;
|
|
31
32
|
}
|
|
@@ -155,4 +156,4 @@ function createAuthConfig(options) {
|
|
|
155
156
|
export {
|
|
156
157
|
createAuthConfig
|
|
157
158
|
};
|
|
158
|
-
//# sourceMappingURL=chunk-
|
|
159
|
+
//# sourceMappingURL=chunk-DYHYL6ZS.js.map
|
|
@@ -0,0 +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 { 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 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(augurClient: AugurAuthClient): 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 as Record<string, unknown>;\n if (!data) return null;\n return {\n id: String(data[\"id\"]),\n name: data[\"name\"] as string | undefined,\n username: data[\"username\"] as string,\n email: data[\"email\"] as string | undefined,\n isVerified: true,\n customerId: data[\"customerId\"] as string | number | undefined,\n contactId: data[\"contactId\"] as string | number | undefined,\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 user_id: Number(userId) || 0,\n customer_id: Number(customerId) || 0,\n contact_id: Number(contactId) || 0,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n } as any);\n return result.data ?? null;\n },\n };\n}\n\n/** Resolve final callbacks: callback overrides take priority over internal SDK calls. */\nfunction resolveCallbacks(options: CreateAuthConfigOptions): 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(\"createAuthConfig requires either `augurClient` or `callbacks.getUserProfile`\");\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/defaultContactId fall back to env vars automatically\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 * }),\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(options: CreateAuthConfigOptions): NextAuthConfig {\n const {\n secret = process.env[\"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,uBAAuB,aAAkD;AAChF,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,IAAI,CAAC;AAAA,QACrB,MAAM,KAAK,MAAM;AAAA,QACjB,UAAU,KAAK,UAAU;AAAA,QACzB,OAAO,KAAK,OAAO;AAAA,QACnB,YAAY;AAAA,QACZ,YAAY,KAAK,YAAY;AAAA,QAC7B,WAAW,KAAK,WAAW;AAAA,MAC7B;AAAA,IACF;AAAA,IACA,MAAM,cACJ,QACA,QACA,WACA,YACyC;AACzC,YAAM,SAAS,MAAM,YAAY,SAAS,QAAQ,O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AAW,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":[]}
|
|
@@ -222,7 +222,7 @@ function createPricingActions(api, config = {}) {
|
|
|
222
222
|
redisTtl,
|
|
223
223
|
"pricing.priceEngine.get",
|
|
224
224
|
async () => {
|
|
225
|
-
const response = await api.pricing.priceEngine.
|
|
225
|
+
const response = await api.pricing.priceEngine.list(params);
|
|
226
226
|
return response.data;
|
|
227
227
|
},
|
|
228
228
|
params
|
|
@@ -378,7 +378,9 @@ function createItemActions(api, config = {}) {
|
|
|
378
378
|
"items.categories.attributes.list",
|
|
379
379
|
async () => {
|
|
380
380
|
const response = await api.items.categories.attributes.list(categoryUid, { edgeCache });
|
|
381
|
-
return {
|
|
381
|
+
return {
|
|
382
|
+
attributes: response.data.attributes
|
|
383
|
+
};
|
|
382
384
|
},
|
|
383
385
|
categoryUid
|
|
384
386
|
);
|
|
@@ -562,6 +564,7 @@ function createCommerceActions(api, config = {}) {
|
|
|
562
564
|
}));
|
|
563
565
|
const response = await api.commerce.cartLine.add.create(
|
|
564
566
|
cartHdrUid,
|
|
567
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
565
568
|
mappedItems
|
|
566
569
|
);
|
|
567
570
|
return response.data;
|
|
@@ -577,6 +580,7 @@ function createCommerceActions(api, config = {}) {
|
|
|
577
580
|
}));
|
|
578
581
|
const response = await api.commerce.cartLine.update.create(
|
|
579
582
|
cartHdrUid,
|
|
583
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
580
584
|
mappedLines
|
|
581
585
|
);
|
|
582
586
|
return response.data;
|
|
@@ -591,7 +595,7 @@ function createCommerceActions(api, config = {}) {
|
|
|
591
595
|
}
|
|
592
596
|
}
|
|
593
597
|
async function getCartAlsoBought(cartHdrUid) {
|
|
594
|
-
const response = await api.commerce.cartHdr.alsoBought.
|
|
598
|
+
const response = await api.commerce.cartHdr.alsoBought.list(cartHdrUid);
|
|
595
599
|
return toListResult(response);
|
|
596
600
|
}
|
|
597
601
|
async function checkoutOrder(cartHdrUid, data) {
|
|
@@ -636,7 +640,9 @@ function createSearchActions(api, config = {}) {
|
|
|
636
640
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
637
641
|
await openSearch.itemSearch.attributes.list(params)
|
|
638
642
|
);
|
|
639
|
-
return {
|
|
643
|
+
return {
|
|
644
|
+
attributes: response.data.attributes
|
|
645
|
+
};
|
|
640
646
|
},
|
|
641
647
|
q
|
|
642
648
|
);
|
|
@@ -793,7 +799,7 @@ function createJoomlaActions(api, config = {}) {
|
|
|
793
799
|
redisTtl,
|
|
794
800
|
"joomla.content.doc.get",
|
|
795
801
|
async () => {
|
|
796
|
-
const response = await api.joomla.content.doc.get(articleId, {
|
|
802
|
+
const response = await api.joomla.content.doc.get(Number(articleId), {
|
|
797
803
|
alias: options.alias,
|
|
798
804
|
catid: options.catId ? Number(options.catId) : void 0,
|
|
799
805
|
edgeCache
|
|
@@ -879,7 +885,7 @@ function createJoomlaActions(api, config = {}) {
|
|
|
879
885
|
redisTtl,
|
|
880
886
|
"joomla.menu.doc.get",
|
|
881
887
|
async () => {
|
|
882
|
-
const response = await api.joomla.menu.doc.get(
|
|
888
|
+
const response = await api.joomla.menu.doc.get(Number(menuId));
|
|
883
889
|
return response.data;
|
|
884
890
|
},
|
|
885
891
|
menuId
|
|
@@ -891,20 +897,20 @@ function createJoomlaActions(api, config = {}) {
|
|
|
891
897
|
redisTtl,
|
|
892
898
|
"joomla.users.doc.get",
|
|
893
899
|
async () => {
|
|
894
|
-
const response = await api.joomla.users.doc.get(userId, {
|
|
900
|
+
const response = await api.joomla.users.doc.get(Number(userId), {
|
|
895
901
|
edgeCache
|
|
896
902
|
});
|
|
897
903
|
const raw = response.data;
|
|
898
904
|
if (!raw) throw new Error("User not found");
|
|
899
905
|
const customerId = String(
|
|
900
|
-
raw
|
|
906
|
+
raw["customerId"] ?? raw["customer_id"] ?? raw["p21_customer_id"] ?? ""
|
|
901
907
|
);
|
|
902
|
-
const groups = Array.isArray(raw
|
|
908
|
+
const groups = Array.isArray(raw["groups"]) ? raw["groups"] : [];
|
|
903
909
|
const permissions = groups.map((g3) => String(g3["title"] ?? g3["name"] ?? "")).filter(Boolean);
|
|
904
910
|
return {
|
|
905
|
-
id: String(raw
|
|
906
|
-
name: String(raw
|
|
907
|
-
email: String(raw
|
|
911
|
+
id: String(raw["id"] ?? userId),
|
|
912
|
+
name: String(raw["name"] ?? ""),
|
|
913
|
+
email: String(raw["email"] ?? ""),
|
|
908
914
|
customerId,
|
|
909
915
|
permissions
|
|
910
916
|
};
|
|
@@ -1057,6 +1063,7 @@ function createCustomersActions(api, config = {}) {
|
|
|
1057
1063
|
const response = await api.customers.customer.orders.list(customerId, {
|
|
1058
1064
|
...params,
|
|
1059
1065
|
edgeCache
|
|
1066
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1060
1067
|
});
|
|
1061
1068
|
return toListResult(response);
|
|
1062
1069
|
},
|
|
@@ -1305,7 +1312,7 @@ function createPaymentsActions(api, config = {}) {
|
|
|
1305
1312
|
try {
|
|
1306
1313
|
const response = (
|
|
1307
1314
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1308
|
-
await api.payments.unified.transactionSetup.
|
|
1315
|
+
await api.payments.unified.transactionSetup.list(withMode(params))
|
|
1309
1316
|
);
|
|
1310
1317
|
return response.data;
|
|
1311
1318
|
} catch {
|
|
@@ -1316,7 +1323,7 @@ function createPaymentsActions(api, config = {}) {
|
|
|
1316
1323
|
try {
|
|
1317
1324
|
const response = (
|
|
1318
1325
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1319
|
-
await api.payments.unified.accountQuery.
|
|
1326
|
+
await api.payments.unified.accountQuery.list(withMode(params))
|
|
1320
1327
|
);
|
|
1321
1328
|
return response.data;
|
|
1322
1329
|
} catch {
|
|
@@ -1327,7 +1334,7 @@ function createPaymentsActions(api, config = {}) {
|
|
|
1327
1334
|
try {
|
|
1328
1335
|
const response = (
|
|
1329
1336
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1330
|
-
await api.payments.unified.surcharge.
|
|
1337
|
+
await api.payments.unified.surcharge.list(withMode(params))
|
|
1331
1338
|
);
|
|
1332
1339
|
return response.data;
|
|
1333
1340
|
} catch {
|
|
@@ -1338,7 +1345,7 @@ function createPaymentsActions(api, config = {}) {
|
|
|
1338
1345
|
try {
|
|
1339
1346
|
const response = (
|
|
1340
1347
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1341
|
-
await api.payments.unified.cardInfo.
|
|
1348
|
+
await api.payments.unified.cardInfo.list(withMode(params))
|
|
1342
1349
|
);
|
|
1343
1350
|
return response.data;
|
|
1344
1351
|
} catch {
|
|
@@ -1349,7 +1356,7 @@ function createPaymentsActions(api, config = {}) {
|
|
|
1349
1356
|
try {
|
|
1350
1357
|
const response = (
|
|
1351
1358
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1352
|
-
await api.payments.unified.billingUpdate.
|
|
1359
|
+
await api.payments.unified.billingUpdate.list(withMode(params))
|
|
1353
1360
|
);
|
|
1354
1361
|
return response.data;
|
|
1355
1362
|
} catch {
|
|
@@ -1360,7 +1367,7 @@ function createPaymentsActions(api, config = {}) {
|
|
|
1360
1367
|
try {
|
|
1361
1368
|
const response = (
|
|
1362
1369
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1363
|
-
await api.payments.unified.validate.
|
|
1370
|
+
await api.payments.unified.validate.list(withMode(params))
|
|
1364
1371
|
);
|
|
1365
1372
|
const raw = response.data;
|
|
1366
1373
|
if (typeof raw === "boolean") {
|
|
@@ -1405,7 +1412,7 @@ function createLogisticsActions(api, config = {}) {
|
|
|
1405
1412
|
const { cachePrefix = "", longEdgeCache = 8, longRedisTtl = 28800 } = config;
|
|
1406
1413
|
async function getFreightRates(params) {
|
|
1407
1414
|
try {
|
|
1408
|
-
const response = await api.logistics.speedship.freight.
|
|
1415
|
+
const response = await api.logistics.speedship.freight.list(params);
|
|
1409
1416
|
return toListResult(response);
|
|
1410
1417
|
} catch {
|
|
1411
1418
|
return { data: [], total: 0 };
|
|
@@ -1527,6 +1534,7 @@ function createVmiActions(api, config = {}) {
|
|
|
1527
1534
|
const response = await api.vmi.warehouse.list({
|
|
1528
1535
|
...params,
|
|
1529
1536
|
edgeCache
|
|
1537
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1530
1538
|
});
|
|
1531
1539
|
return toListResult(response);
|
|
1532
1540
|
},
|
|
@@ -1539,7 +1547,7 @@ function createVmiActions(api, config = {}) {
|
|
|
1539
1547
|
shortRedisTtl,
|
|
1540
1548
|
"vmi.warehouse.availability.get",
|
|
1541
1549
|
async () => {
|
|
1542
|
-
const response = await api.vmi.warehouse.availability.
|
|
1550
|
+
const response = await api.vmi.warehouse.availability.list(
|
|
1543
1551
|
warehouseUid,
|
|
1544
1552
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1545
1553
|
{ ...params, edgeCache }
|
|
@@ -1559,6 +1567,7 @@ function createVmiActions(api, config = {}) {
|
|
|
1559
1567
|
const response = await api.vmi.distributors.list({
|
|
1560
1568
|
...params,
|
|
1561
1569
|
edgeCache
|
|
1570
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1562
1571
|
});
|
|
1563
1572
|
return toListResult(response);
|
|
1564
1573
|
},
|
|
@@ -1574,6 +1583,7 @@ function createVmiActions(api, config = {}) {
|
|
|
1574
1583
|
const response = await api.vmi.products.list({
|
|
1575
1584
|
...params,
|
|
1576
1585
|
edgeCache
|
|
1586
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1577
1587
|
});
|
|
1578
1588
|
return toListResult(response);
|
|
1579
1589
|
},
|
|
@@ -1684,8 +1694,7 @@ function createP21CoreActions(api, config = {}) {
|
|
|
1684
1694
|
longRedisTtl,
|
|
1685
1695
|
"p21Core.company.get",
|
|
1686
1696
|
async () => {
|
|
1687
|
-
const response = await api.p21Core.company.get({
|
|
1688
|
-
companyUid: companyId,
|
|
1697
|
+
const response = await api.p21Core.company.get(companyId, {
|
|
1689
1698
|
edgeCache: longEdgeCache
|
|
1690
1699
|
});
|
|
1691
1700
|
return response.data;
|
|
@@ -1848,7 +1857,7 @@ function createP21ApisActions(api, config = {}) {
|
|
|
1848
1857
|
redisTtl,
|
|
1849
1858
|
"p21Apis.transWebDisplayType.defaults.get",
|
|
1850
1859
|
async () => {
|
|
1851
|
-
const response = await api.p21Apis.transWebDisplayType.defaults.
|
|
1860
|
+
const response = await api.p21Apis.transWebDisplayType.defaults.list({
|
|
1852
1861
|
id,
|
|
1853
1862
|
edgeCache
|
|
1854
1863
|
});
|
|
@@ -2042,7 +2051,7 @@ function createAgrInfoActions(api, config = {}) {
|
|
|
2042
2051
|
}
|
|
2043
2052
|
async function generateAkasha(data) {
|
|
2044
2053
|
try {
|
|
2045
|
-
const response = await api.agrInfo.akasha.generate.create(data);
|
|
2054
|
+
const response = await api.agrInfo.akasha.generate.create(data ?? {});
|
|
2046
2055
|
return response.data;
|
|
2047
2056
|
} catch {
|
|
2048
2057
|
return void 0;
|
|
@@ -2050,7 +2059,7 @@ function createAgrInfoActions(api, config = {}) {
|
|
|
2050
2059
|
}
|
|
2051
2060
|
async function generateJoomla(data) {
|
|
2052
2061
|
try {
|
|
2053
|
-
const response = await api.agrInfo.joomla.generate.create(data);
|
|
2062
|
+
const response = await api.agrInfo.joomla.generate.create(data ?? {});
|
|
2054
2063
|
return response.data;
|
|
2055
2064
|
} catch {
|
|
2056
2065
|
return void 0;
|
|
@@ -2365,7 +2374,7 @@ function createFavoritesActions(api, config = {}) {
|
|
|
2365
2374
|
redisTtl,
|
|
2366
2375
|
"items.itemFavorites.list",
|
|
2367
2376
|
async () => {
|
|
2368
|
-
const response = await api.items.itemFavorites.list(userId, {
|
|
2377
|
+
const response = await api.items.itemFavorites.items.list(userId, {
|
|
2369
2378
|
edgeCache
|
|
2370
2379
|
});
|
|
2371
2380
|
return toListResult(response);
|
|
@@ -2374,13 +2383,13 @@ function createFavoritesActions(api, config = {}) {
|
|
|
2374
2383
|
);
|
|
2375
2384
|
}
|
|
2376
2385
|
async function addFavorite(userId, invMastUid) {
|
|
2377
|
-
const response = await api.items.itemFavorites.create(userId, {
|
|
2386
|
+
const response = await api.items.itemFavorites.items.create(userId, {
|
|
2378
2387
|
invMastUid
|
|
2379
2388
|
});
|
|
2380
2389
|
return response.data;
|
|
2381
2390
|
}
|
|
2382
2391
|
async function removeFavorite(userId, invMastUid) {
|
|
2383
|
-
await api.items.itemFavorites.delete(userId, invMastUid);
|
|
2392
|
+
await api.items.itemFavorites.items.delete(userId, invMastUid);
|
|
2384
2393
|
}
|
|
2385
2394
|
return { getFavorites, addFavorite, removeFavorite };
|
|
2386
2395
|
}
|
|
@@ -2394,7 +2403,7 @@ function createWishlistActions(api, config = {}) {
|
|
|
2394
2403
|
redisTtl,
|
|
2395
2404
|
"items.itemWishlist.list",
|
|
2396
2405
|
async () => {
|
|
2397
|
-
const response = await api.items.itemWishlist.
|
|
2406
|
+
const response = await api.items.itemWishlist.get(userId, {
|
|
2398
2407
|
edgeCache
|
|
2399
2408
|
});
|
|
2400
2409
|
return toListResult(response);
|
|
@@ -2733,4 +2742,4 @@ export {
|
|
|
2733
2742
|
getSiteActions,
|
|
2734
2743
|
clearSiteActions
|
|
2735
2744
|
};
|
|
2736
|
-
//# sourceMappingURL=chunk-
|
|
2745
|
+
//# sourceMappingURL=chunk-LOQGT6WV.js.map
|