@simpleapps-com/augur-server 0.3.0 → 0.4.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/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { QueryClient } from '@tanstack/react-query';
2
2
  export { QueryOptionsConfig, createQueryOptions, createSuspenseQueryOptions } from './query.js';
3
- export { A as AddressValidationResult, a as AgrInfoActions, b as AgrInfoActionsConfig, c as AgrInfoApiClient, d as AgrSiteActions, e as AgrSiteActionsConfig, f as AgrSiteApiClient, g as AgrWorkActions, h as AgrWorkActionsConfig, i as AgrWorkApiClient, j as AvalaraActions, k as AvalaraActionsConfig, l as AvalaraApiClient, B as Basecamp2Actions, m as Basecamp2ActionsConfig, n as Basecamp2ApiClient, o as BrandFolderActions, p as BrandFolderActionsConfig, q as BrandFolderApiClient, C as CommerceActions, r as CommerceActionsConfig, s as CommerceApiClient, t as CustomersActions, u as CustomersActionsConfig, v as CustomersApiClient, G as GregorovichActions, w as GregorovichActionsConfig, x as GregorovichApiClient, I as ItemActions, y as ItemActionsConfig, z as ItemsApiClient, J as JoomlaActions, D as JoomlaActionsConfig, E as JoomlaApiClient, L as LegacyActions, F as LegacyActionsConfig, H as LegacyApiClient, K as LogisticsActions, M as LogisticsActionsConfig, N as LogisticsApiClient, O as NexusActions, P as NexusActionsConfig, Q as NexusApiClient, R as OrderActions, S as OrderActionsConfig, T as OrderApiClient, U as P21ApisActions, V as P21ApisActionsConfig, W as P21ApisApiClient, X as P21CoreActions, Y as P21CoreActionsConfig, Z as P21CoreApiClient, _ as P21PimActions, $ as P21PimActionsConfig, a0 as P21PimApiClient, a1 as P21SismActions, a2 as P21SismActionsConfig, a3 as P21SismApiClient, a4 as PaymentsActions, a5 as PaymentsActionsConfig, a6 as PaymentsApiClient, a7 as PricingActions, a8 as PricingActionsConfig, a9 as PricingApiClient, aa as SearchActions, ab as SearchActionsConfig, ac as SearchApiClient, ad as SearchPage, ae as ShippingActions, af as ShippingActionsConfig, ag as ShippingAddress, ah as ShippingApiClient, ai as SiteActions, aj as SiteActionsConfig, ak as SlackActions, al as SlackActionsConfig, am as SlackApiClient, an as SmartyStreetsActions, ao as SmartyStreetsActionsConfig, ap as SmartyStreetsApiClient, aq as UpsActions, ar as UpsActionsConfig, as as UpsApiClient, at as VmiActions, au as VmiActionsConfig, av as VmiApiClient, aw as createAgrInfoActions, ax as createAgrSiteActions, ay as createAgrWorkActions, az as createAvalaraActions, aA as createBasecamp2Actions, aB as createBrandFolderActions, aC as createCommerceActions, aD as createCustomersActions, aE as createGregorovichActions, aF as createItemActions, aG as createJoomlaActions, aH as createLegacyActions, aI as createLogisticsActions, aJ as createNexusActions, aK as createOrderActions, aL as createP21ApisActions, aM as createP21CoreActions, aN as createP21PimActions, aO as createP21SismActions, aP as createPaymentsActions, aQ as createPricingActions, aR as createSearchActions, aS as createShippingActions, aT as createSiteActions, aU as createSlackActions, aV as createSmartyStreetsActions, aW as createUpsActions, aX as createVmiActions } from './site-DibGofHe.js';
3
+ export { A as AddressValidationResult, a as AgrInfoActions, b as AgrInfoActionsConfig, c as AgrInfoApiClient, d as AgrSiteActions, e as AgrSiteActionsConfig, f as AgrSiteApiClient, g as AgrWorkActions, h as AgrWorkActionsConfig, i as AgrWorkApiClient, j as AvalaraActions, k as AvalaraActionsConfig, l as AvalaraApiClient, B as Basecamp2Actions, m as Basecamp2ActionsConfig, n as Basecamp2ApiClient, o as BrandFolderActions, p as BrandFolderActionsConfig, q as BrandFolderApiClient, C as CommerceActions, r as CommerceActionsConfig, s as CommerceApiClient, t as CustomerListResult, u as CustomersActions, v as CustomersActionsConfig, w as CustomersApiClient, G as GregorovichActions, x as GregorovichActionsConfig, y as GregorovichApiClient, I as ItemActions, z as ItemActionsConfig, D as ItemsApiClient, J as JoomlaActions, E as JoomlaActionsConfig, F as JoomlaApiClient, L as LegacyActions, H as LegacyActionsConfig, K as LegacyApiClient, M as LogisticsActions, N as LogisticsActionsConfig, O as LogisticsApiClient, P as NexusActions, Q as NexusActionsConfig, R as NexusApiClient, S as NormalizedUserProfile, T as OrderActions, U as OrderActionsConfig, V as OrderApiClient, W as P21ApisActions, X as P21ApisActionsConfig, Y as P21ApisApiClient, Z as P21CoreActions, _ as P21CoreActionsConfig, $ as P21CoreApiClient, a0 as P21PimActions, a1 as P21PimActionsConfig, a2 as P21PimApiClient, a3 as P21SismActions, a4 as P21SismActionsConfig, a5 as P21SismApiClient, a6 as PaymentsActions, a7 as PaymentsActionsConfig, a8 as PaymentsApiClient, a9 as PricingActions, aa as PricingActionsConfig, ab as PricingApiClient, ac as SearchActions, ad as SearchActionsConfig, ae as SearchApiClient, af as SearchPage, ag as ShippingActions, ah as ShippingActionsConfig, ai as ShippingAddress, aj as ShippingApiClient, ak as SiteActions, al as SiteActionsConfig, am as SlackActions, an as SlackActionsConfig, ao as SlackApiClient, ap as SmartyStreetsActions, aq as SmartyStreetsActionsConfig, ar as SmartyStreetsApiClient, as as UpsActions, at as UpsActionsConfig, au as UpsApiClient, av as VmiActions, aw as VmiActionsConfig, ax as VmiApiClient, ay as createAgrInfoActions, az as createAgrSiteActions, aA as createAgrWorkActions, aB as createAvalaraActions, aC as createBasecamp2Actions, aD as createBrandFolderActions, aE as createCommerceActions, aF as createCustomersActions, aG as createGregorovichActions, aH as createItemActions, aI as createJoomlaActions, aJ as createLegacyActions, aK as createLogisticsActions, aL as createNexusActions, aM as createOrderActions, aN as createP21ApisActions, aO as createP21CoreActions, aP as createP21PimActions, aQ as createP21SismActions, aR as createPaymentsActions, aS as createPricingActions, aT as createSearchActions, aU as createShippingActions, aV as createSiteActions, aW as createSlackActions, aX as createSmartyStreetsActions, aY as createUpsActions, aZ as createVmiActions } from './site-IpNMQZr5.js';
4
4
  import '@simpleapps-com/augur-utils';
5
5
 
6
6
  declare const env: "development" | "staging" | "production";
@@ -145,4 +145,79 @@ interface PaginatedResult<T> {
145
145
  */
146
146
  declare function paginateOffset<T>(items: T[], pageParam: number, limit: number, total?: number): PaginatedResult<T>;
147
147
 
148
- export { type ActionResult, type PaginatedResult, cacheGet, cacheSet, createServerQueryClient, env, getCircuitState, getServerQueryClient, isDev, isProduction, isRedisConnected, isStaging, paginateOffset, safeAction, sdkCall, withServerCache };
148
+ interface WishlistsApiClient {
149
+ items: {
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
+ }
172
+ interface WishlistActionsConfig {
173
+ /** Cache key prefix (e.g. "ampro:"). Default: "". */
174
+ cachePrefix?: string;
175
+ /** CDN edge cache value passed to SDK. Default: 1 (hour). */
176
+ edgeCache?: number;
177
+ /** Redis TTL in seconds. Default: 3600 (1 hour). */
178
+ redisTtl?: number;
179
+ }
180
+ interface WishlistActions {
181
+ getWishlists: (userId: number) => Promise<unknown[]>;
182
+ createWishlist: (userId: number, data: {
183
+ name: string;
184
+ description?: string;
185
+ }) => Promise<unknown>;
186
+ getWishlistDetail: (userId: number, wishlistId: number) => Promise<unknown>;
187
+ deleteWishlist: (userId: number, wishlistId: number) => Promise<void>;
188
+ addWishlistItems: (userId: number, wishlistId: number, items: {
189
+ invMastUid: number;
190
+ }[]) => Promise<unknown>;
191
+ removeWishlistItem: (userId: number, wishlistId: number, lineId: number) => Promise<void>;
192
+ }
193
+ declare function createWishlistActions(api: WishlistsApiClient, config?: WishlistActionsConfig): WishlistActions;
194
+
195
+ interface FavoritesApiClient {
196
+ items: {
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
+ }
208
+ interface FavoritesActionsConfig {
209
+ /** Cache key prefix (e.g. "ampro:"). Default: "". */
210
+ cachePrefix?: string;
211
+ /** CDN edge cache value passed to SDK. Default: 1 (hour). */
212
+ edgeCache?: number;
213
+ /** Redis TTL in seconds. Default: 3600 (1 hour). */
214
+ redisTtl?: number;
215
+ }
216
+ interface FavoritesActions {
217
+ getFavorites: (userId: number) => Promise<unknown[]>;
218
+ addFavorite: (userId: number, invMastUid: number) => Promise<unknown>;
219
+ removeFavorite: (userId: number, invMastUid: number) => Promise<void>;
220
+ }
221
+ declare function createFavoritesActions(api: FavoritesApiClient, config?: FavoritesActionsConfig): FavoritesActions;
222
+
223
+ export { type ActionResult, type FavoritesActions, type FavoritesActionsConfig, type FavoritesApiClient, type PaginatedResult, type WishlistActions, type WishlistActionsConfig, type WishlistsApiClient, cacheGet, cacheSet, createFavoritesActions, createServerQueryClient, createWishlistActions, env, getCircuitState, getServerQueryClient, isDev, isProduction, isRedisConnected, isStaging, paginateOffset, safeAction, sdkCall, withServerCache };
package/dist/index.js CHANGED
@@ -763,7 +763,65 @@ function createJoomlaActions(api, config = {}) {
763
763
  params
764
764
  );
765
765
  }
766
- return { getJoomlaContent, getJoomlaContentList };
766
+ async function getJoomlaMenu(params) {
767
+ return withServerCache(
768
+ cachePrefix,
769
+ redisTtl,
770
+ "joomla.menu.list",
771
+ async () => {
772
+ const response = await api.joomla.menu.list({
773
+ ...params,
774
+ edgeCache
775
+ });
776
+ return response.data;
777
+ },
778
+ params
779
+ );
780
+ }
781
+ async function getJoomlaMenuDoc(menuId) {
782
+ return withServerCache(
783
+ cachePrefix,
784
+ redisTtl,
785
+ "joomla.menu.doc.get",
786
+ async () => {
787
+ const response = await api.joomla.menu.doc.get(menuId, {
788
+ edgeCache
789
+ });
790
+ return response.data;
791
+ },
792
+ menuId
793
+ );
794
+ }
795
+ async function getUserProfile(userId) {
796
+ return withServerCache(
797
+ cachePrefix,
798
+ redisTtl,
799
+ "joomla.users.doc.get",
800
+ async () => {
801
+ const response = await api.joomla.users.doc.get(userId, {
802
+ edgeCache
803
+ });
804
+ const raw = response.data;
805
+ if (!raw) throw new Error("User not found");
806
+ const customerId = String(
807
+ raw.customerId ?? raw.customer_id ?? raw.p21_customer_id ?? ""
808
+ );
809
+ const groups = Array.isArray(raw.groups) ? raw.groups : [];
810
+ const permissions = groups.map(
811
+ (g2) => String(g2.title ?? g2.name ?? "")
812
+ ).filter(Boolean);
813
+ return {
814
+ id: String(raw.id ?? userId),
815
+ name: String(raw.name ?? ""),
816
+ email: String(raw.email ?? ""),
817
+ customerId,
818
+ permissions
819
+ };
820
+ },
821
+ userId
822
+ );
823
+ }
824
+ return { getJoomlaContent, getJoomlaContentList, getJoomlaMenu, getJoomlaMenuDoc, getUserProfile };
767
825
  }
768
826
 
769
827
  // src/actions/legacy.ts
@@ -897,12 +955,95 @@ function createCustomersActions(api, config = {}) {
897
955
  ...params,
898
956
  edgeCache
899
957
  });
958
+ return { data: response.data, total: response.total };
959
+ },
960
+ customerId,
961
+ params
962
+ );
963
+ }
964
+ async function getCustomerOrderDetail(customerId, orderId) {
965
+ return withServerCache(
966
+ cachePrefix,
967
+ redisTtl,
968
+ "customers.customer.orders.get",
969
+ async () => {
970
+ const response = await api.customers.customer.orders.get(
971
+ customerId,
972
+ orderId,
973
+ { edgeCache }
974
+ );
900
975
  return response.data;
901
976
  },
902
977
  customerId,
978
+ orderId
979
+ );
980
+ }
981
+ async function getCustomerInvoices(customerId, params) {
982
+ return withServerCache(
983
+ cachePrefix,
984
+ redisTtl,
985
+ "customers.customer.invoices.list",
986
+ async () => {
987
+ const response = await api.customers.customer.invoices.list(
988
+ customerId,
989
+ { ...params, edgeCache }
990
+ );
991
+ return { data: response.data, total: response.total };
992
+ },
993
+ customerId,
903
994
  params
904
995
  );
905
996
  }
997
+ async function getCustomerInvoiceDetail(customerId, invoiceNo) {
998
+ return withServerCache(
999
+ cachePrefix,
1000
+ redisTtl,
1001
+ "customers.customer.invoices.get",
1002
+ async () => {
1003
+ const response = await api.customers.customer.invoices.get(
1004
+ customerId,
1005
+ invoiceNo,
1006
+ { edgeCache }
1007
+ );
1008
+ return response.data;
1009
+ },
1010
+ customerId,
1011
+ invoiceNo
1012
+ );
1013
+ }
1014
+ async function getCustomerQuotes(customerId, params) {
1015
+ return withServerCache(
1016
+ cachePrefix,
1017
+ redisTtl,
1018
+ "customers.customer.quotes.list",
1019
+ async () => {
1020
+ const response = await api.customers.customer.quotes.list(customerId, {
1021
+ ...params,
1022
+ edgeCache
1023
+ });
1024
+ return { data: response.data, total: response.total };
1025
+ },
1026
+ customerId,
1027
+ params
1028
+ );
1029
+ }
1030
+ async function getCustomerQuoteDetail(customerId, quoteNo) {
1031
+ return withServerCache(
1032
+ cachePrefix,
1033
+ redisTtl,
1034
+ "customers.customer.quotes.get",
1035
+ async () => {
1036
+ const response = await api.customers.customer.quotes.get(
1037
+ customerId,
1038
+ quoteNo,
1039
+ { edgeCache }
1040
+ );
1041
+ return response.data;
1042
+ },
1043
+ customerId,
1044
+ quoteNo
1045
+ );
1046
+ }
906
1047
  async function getContacts(params) {
907
1048
  return withServerCache(
908
1049
  cachePrefix,
@@ -937,6 +1078,11 @@ function createCustomersActions(api, config = {}) {
937
1078
  customerLookup,
938
1079
  getCustomerDoc,
939
1080
  getCustomerOrders,
1081
+ getCustomerOrderDetail,
1082
+ getCustomerInvoices,
1083
+ getCustomerInvoiceDetail,
1084
+ getCustomerQuotes,
1085
+ getCustomerQuoteDetail,
940
1086
  getContacts,
941
1087
  getShipToAddresses
942
1088
  };
@@ -2097,6 +2243,97 @@ function createSlackActions(api, config = {}) {
2097
2243
  };
2098
2244
  }
2099
2245
 
2246
+ // src/actions/wishlists.ts
2247
+ function createWishlistActions(api, config = {}) {
2248
+ const { cachePrefix = "", edgeCache = 1, redisTtl = 3600 } = config;
2249
+ async function getWishlists(userId) {
2250
+ return withServerCache(
2251
+ cachePrefix,
2252
+ redisTtl,
2253
+ "items.itemWishlist.list",
2254
+ async () => {
2255
+ const response = await api.items.itemWishlist.list(userId, {
2256
+ edgeCache
2257
+ });
2258
+ return response.data;
2259
+ },
2260
+ userId
2261
+ );
2262
+ }
2263
+ async function createWishlist(userId, data) {
2264
+ const response = await api.items.itemWishlist.create(userId, data);
2265
+ return response.data;
2266
+ }
2267
+ async function getWishlistDetail(userId, wishlistId) {
2268
+ return withServerCache(
2269
+ cachePrefix,
2270
+ redisTtl,
2271
+ "items.itemWishlist.hdr.get",
2272
+ async () => {
2273
+ const response = await api.items.itemWishlist.hdr.get(
2274
+ userId,
2275
+ wishlistId,
2276
+ { edgeCache }
2277
+ );
2278
+ return response.data;
2279
+ },
2280
+ userId,
2281
+ wishlistId
2282
+ );
2283
+ }
2284
+ async function deleteWishlist(userId, wishlistId) {
2285
+ await api.items.itemWishlist.hdr.delete(userId, wishlistId);
2286
+ }
2287
+ async function addWishlistItems(userId, wishlistId, items) {
2288
+ const response = await api.items.itemWishlist.hdr.create(
2289
+ userId,
2290
+ wishlistId,
2291
+ items
2292
+ );
2293
+ return response.data;
2294
+ }
2295
+ async function removeWishlistItem(userId, wishlistId, lineId) {
2296
+ await api.items.itemWishlist.hdr.line.delete(userId, wishlistId, lineId);
2297
+ }
2298
+ return {
2299
+ getWishlists,
2300
+ createWishlist,
2301
+ getWishlistDetail,
2302
+ deleteWishlist,
2303
+ addWishlistItems,
2304
+ removeWishlistItem
2305
+ };
2306
+ }
2307
+
2308
+ // src/actions/favorites.ts
2309
+ function createFavoritesActions(api, config = {}) {
2310
+ const { cachePrefix = "", edgeCache = 1, redisTtl = 3600 } = config;
2311
+ async function getFavorites(userId) {
2312
+ return withServerCache(
2313
+ cachePrefix,
2314
+ redisTtl,
2315
+ "items.itemFavorites.list",
2316
+ async () => {
2317
+ const response = await api.items.itemFavorites.list(userId, {
2318
+ edgeCache
2319
+ });
2320
+ return response.data;
2321
+ },
2322
+ userId
2323
+ );
2324
+ }
2325
+ async function addFavorite(userId, invMastUid) {
2326
+ const response = await api.items.itemFavorites.create(userId, {
2327
+ invMastUid
2328
+ });
2329
+ return response.data;
2330
+ }
2331
+ async function removeFavorite(userId, invMastUid) {
2332
+ await api.items.itemFavorites.delete(userId, invMastUid);
2333
+ }
2334
+ return { getFavorites, addFavorite, removeFavorite };
2335
+ }
2336
+
2100
2337
  // src/actions/site.ts
2101
2338
  function createSiteActions(api, config = {}) {
2102
2339
  const {
@@ -2325,6 +2562,7 @@ export {
2325
2562
  createBrandFolderActions,
2326
2563
  createCommerceActions,
2327
2564
  createCustomersActions,
2565
+ createFavoritesActions,
2328
2566
  createGregorovichActions,
2329
2567
  createItemActions,
2330
2568
  createJoomlaActions,
@@ -2348,6 +2586,7 @@ export {
2348
2586
  createSuspenseQueryOptions,
2349
2587
  createUpsActions,
2350
2588
  createVmiActions,
2589
+ createWishlistActions,
2351
2590
  env,
2352
2591
  getCircuitState,
2353
2592
  getServerQueryClient,