@simpleapps-com/augur-server 1.0.13 → 1.0.15
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.d.ts +171 -0
- package/dist/actions.js +606 -0
- package/dist/actions.js.map +1 -0
- package/dist/chunk-MQGUOFAZ.js +23 -0
- package/dist/chunk-MQGUOFAZ.js.map +1 -0
- package/dist/chunk-ZBS5CNBC.js +20 -0
- package/dist/chunk-ZBS5CNBC.js.map +1 -0
- package/dist/index.d.ts +5 -57
- package/dist/index.js +10 -15
- package/dist/index.js.map +1 -1
- package/dist/sdk-call-BgnoWAZK.d.ts +56 -0
- package/dist/server-site-registry-DlLN0e5y.d.ts +19 -0
- package/dist/{site-BBtab6v0.d.ts → site-DpL27QZc.d.ts} +3 -269
- package/dist/site.d.ts +2 -1
- package/dist/site.js +4 -0
- package/dist/site.js.map +1 -1
- package/dist/smarty-streets-1vGdsGf-.d.ts +272 -0
- package/dist/testing.d.ts +3 -1
- package/dist/testing.js +5 -0
- package/dist/testing.js.map +1 -1
- package/package.json +9 -5
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { EdgeCacheValue } from '@simpleapps-com/augur-core';
|
|
2
2
|
import { AugurAPI } from '@simpleapps-com/augur-api';
|
|
3
|
-
import { TPriceData, TTaxItem, TTax, TCategory, TAttribute, TInvMast, TInvMastDoc, TStockData, TItemAccessory, TCartLookUp, TCartLine,
|
|
3
|
+
import { TPriceData, TTaxItem, TTax, TCategory, TAttribute, TInvMast, TInvMastDoc, TStockData, TItemAccessory, TCartLookUp, TCartLine, TWebDesc } from '@simpleapps-com/augur-utils';
|
|
4
|
+
import { S as SearchActions, i as ShippingActions, J as JoomlaActions, a as CustomersActions, m as SmartyStreetsActions, k as ShippingAddress } from './smarty-streets-1vGdsGf-.js';
|
|
4
5
|
|
|
5
6
|
/** Derived from augur-api SDK — keeps types in sync automatically. */
|
|
6
7
|
type PricingApiClient = Pick<AugurAPI, "pricing">;
|
|
@@ -208,178 +209,6 @@ interface OrderActions {
|
|
|
208
209
|
*/
|
|
209
210
|
declare function createOrderActions(api: OrderApiClient, config?: OrderActionsConfig): OrderActions;
|
|
210
211
|
|
|
211
|
-
/** Derived from augur-api SDK — keeps types in sync automatically. */
|
|
212
|
-
type SearchApiClient = Pick<AugurAPI, "opensearch">;
|
|
213
|
-
interface SearchActionsConfig {
|
|
214
|
-
/** Cache key prefix (e.g. "ampro:"). Default: "". */
|
|
215
|
-
cachePrefix?: string;
|
|
216
|
-
/** CDN edge cache value passed to SDK. Default: 1 (hour). */
|
|
217
|
-
edgeCache?: EdgeCacheValue;
|
|
218
|
-
/** Redis TTL for search lookups in seconds. Default: 3600 (1 hour). */
|
|
219
|
-
redisTtl?: number;
|
|
220
|
-
/** Default source fields for item search. Default: "display_desc". */
|
|
221
|
-
defaultSourceFields?: string;
|
|
222
|
-
}
|
|
223
|
-
/** Paginated response for infinite scroll. */
|
|
224
|
-
interface SearchPage {
|
|
225
|
-
data: TProductItem[];
|
|
226
|
-
total: number;
|
|
227
|
-
nextCursor?: number;
|
|
228
|
-
}
|
|
229
|
-
interface SearchActions {
|
|
230
|
-
getSearchAttributes: (q: string) => Promise<TAttribute[]>;
|
|
231
|
-
getSearchSuggestions: (q: string, limit?: number, offset?: number) => Promise<{
|
|
232
|
-
data: unknown[];
|
|
233
|
-
total: number;
|
|
234
|
-
totalResults: number;
|
|
235
|
-
}>;
|
|
236
|
-
itemSearch: (filters: {
|
|
237
|
-
q: string;
|
|
238
|
-
limit: number;
|
|
239
|
-
offset: number;
|
|
240
|
-
sortBy?: string;
|
|
241
|
-
filters?: [string, string][];
|
|
242
|
-
}, itemCategoryUid?: number | string) => Promise<{
|
|
243
|
-
items: TProductItem[];
|
|
244
|
-
totalResults: number;
|
|
245
|
-
}>;
|
|
246
|
-
itemSearchInfinite: (filters: {
|
|
247
|
-
q: string;
|
|
248
|
-
limit: number;
|
|
249
|
-
sortBy?: string;
|
|
250
|
-
filters?: [string, string][];
|
|
251
|
-
}, itemCategoryUid?: number | string, pageParam?: number) => Promise<SearchPage>;
|
|
252
|
-
}
|
|
253
|
-
/**
|
|
254
|
-
* @deprecated Use `createSiteActions()` instead. This factory will be removed in the next major version.
|
|
255
|
-
*
|
|
256
|
-
* Creates server-side search actions with Redis caching and edge cache support.
|
|
257
|
-
*
|
|
258
|
-
* Uses `withServerCache` which produces cache keys compatible with augur-hooks'
|
|
259
|
-
* `withCache`, so server-prefetched data is shared with client-side hooks.
|
|
260
|
-
*
|
|
261
|
-
* @example
|
|
262
|
-
* ```ts
|
|
263
|
-
* // lib/search-actions.ts
|
|
264
|
-
* import { createSearchActions } from "@simpleapps-com/augur-server";
|
|
265
|
-
* import { getAugurClient } from "./augur-client";
|
|
266
|
-
*
|
|
267
|
-
* export const searchActions = createSearchActions(getAugurClient(), {
|
|
268
|
-
* cachePrefix: "ampro:",
|
|
269
|
-
* });
|
|
270
|
-
*
|
|
271
|
-
* // In a server component:
|
|
272
|
-
* const attrs = await searchActions.getSearchAttributes("widget");
|
|
273
|
-
* const results = await searchActions.itemSearch({ q: "widget", limit: 20, offset: 0 });
|
|
274
|
-
* ```
|
|
275
|
-
*/
|
|
276
|
-
declare function createSearchActions(api: SearchApiClient, config?: SearchActionsConfig): SearchActions;
|
|
277
|
-
|
|
278
|
-
interface ShippingAddress {
|
|
279
|
-
address1: string;
|
|
280
|
-
city: string;
|
|
281
|
-
state: string;
|
|
282
|
-
postalCode: string;
|
|
283
|
-
country?: string;
|
|
284
|
-
}
|
|
285
|
-
/** Derived from augur-api SDK — keeps types in sync automatically. */
|
|
286
|
-
type ShippingApiClient = Pick<AugurAPI, "ups">;
|
|
287
|
-
interface ShippingActionsConfig {
|
|
288
|
-
/** Warehouse/origin address for rate calculations. */
|
|
289
|
-
fromAddress: ShippingAddress;
|
|
290
|
-
/** UPS service codes to filter results. Default: undefined (return all). */
|
|
291
|
-
defaultServiceCodes?: string[];
|
|
292
|
-
/** Cache key prefix (e.g. "ampro:"). Default: "". */
|
|
293
|
-
cachePrefix?: string;
|
|
294
|
-
/** CDN edge cache value passed to SDK. Default: 1 (hour). */
|
|
295
|
-
edgeCache?: EdgeCacheValue;
|
|
296
|
-
/** Redis TTL for shipping rate lookups in seconds. Default: 3600 (1 hour). */
|
|
297
|
-
redisTtl?: number;
|
|
298
|
-
}
|
|
299
|
-
interface ShippingActions {
|
|
300
|
-
getShippingRates: (toAddress: ShippingAddress, weight: number, serviceCodes?: string[]) => Promise<unknown>;
|
|
301
|
-
}
|
|
302
|
-
/**
|
|
303
|
-
* @deprecated Use `createSiteActions()` instead. This factory will be removed in the next major version.
|
|
304
|
-
*
|
|
305
|
-
* Creates server-side shipping actions with Redis caching and edge cache support.
|
|
306
|
-
*
|
|
307
|
-
* Uses `withServerCache` which produces cache keys compatible with augur-hooks'
|
|
308
|
-
* `withCache`, so server-prefetched data is shared with client-side hooks.
|
|
309
|
-
*
|
|
310
|
-
* @example
|
|
311
|
-
* ```ts
|
|
312
|
-
* // lib/shipping-actions.ts
|
|
313
|
-
* import { createShippingActions } from "@simpleapps-com/augur-server";
|
|
314
|
-
* import { getAugurClient } from "./augur-client";
|
|
315
|
-
*
|
|
316
|
-
* export const shippingActions = createShippingActions(getAugurClient(), {
|
|
317
|
-
* fromAddress: {
|
|
318
|
-
* address1: "123 Warehouse Ln",
|
|
319
|
-
* city: "Chicago",
|
|
320
|
-
* state: "IL",
|
|
321
|
-
* postalCode: "60601",
|
|
322
|
-
* },
|
|
323
|
-
* });
|
|
324
|
-
*
|
|
325
|
-
* // In a server component:
|
|
326
|
-
* const rates = await shippingActions.getShippingRates(
|
|
327
|
-
* { address1: "456 Main St", city: "Denver", state: "CO", postalCode: "80202" },
|
|
328
|
-
* 5.0,
|
|
329
|
-
* );
|
|
330
|
-
* ```
|
|
331
|
-
*/
|
|
332
|
-
declare function createShippingActions(api: ShippingApiClient, config: ShippingActionsConfig): ShippingActions;
|
|
333
|
-
|
|
334
|
-
/** Derived from augur-api SDK — keeps types in sync automatically. */
|
|
335
|
-
type JoomlaApiClient = Pick<AugurAPI, "joomla">;
|
|
336
|
-
interface JoomlaActionsConfig {
|
|
337
|
-
/** Cache key prefix (e.g. "ampro:"). Default: "". */
|
|
338
|
-
cachePrefix?: string;
|
|
339
|
-
/** CDN edge cache value passed to SDK. Default: 1 (hour). */
|
|
340
|
-
edgeCache?: EdgeCacheValue;
|
|
341
|
-
/** Redis TTL for Joomla lookups in seconds. Default: 3600 (1 hour). */
|
|
342
|
-
redisTtl?: number;
|
|
343
|
-
}
|
|
344
|
-
interface NormalizedUserProfile {
|
|
345
|
-
id: string;
|
|
346
|
-
name: string;
|
|
347
|
-
email: string;
|
|
348
|
-
customerId: string;
|
|
349
|
-
permissions: string[];
|
|
350
|
-
}
|
|
351
|
-
interface JoomlaActions {
|
|
352
|
-
getJoomlaContent: (articleId: number) => Promise<unknown>;
|
|
353
|
-
getJoomlaContentList: (params?: Record<string, unknown>) => Promise<unknown[]>;
|
|
354
|
-
getJoomlaMenu: (params?: Record<string, unknown>) => Promise<unknown[]>;
|
|
355
|
-
getJoomlaMenuDoc: (menuId: number | string) => Promise<unknown>;
|
|
356
|
-
getUserProfile: (userId: number | string) => Promise<NormalizedUserProfile>;
|
|
357
|
-
}
|
|
358
|
-
/**
|
|
359
|
-
* @deprecated Use `createSiteActions()` instead. This factory will be removed in the next major version.
|
|
360
|
-
*
|
|
361
|
-
* Creates server-side Joomla content actions with Redis caching and edge cache support.
|
|
362
|
-
*
|
|
363
|
-
* Uses `withServerCache` which produces cache keys compatible with augur-hooks'
|
|
364
|
-
* `withCache`, so server-prefetched data is shared with client-side hooks.
|
|
365
|
-
*
|
|
366
|
-
* @example
|
|
367
|
-
* ```ts
|
|
368
|
-
* // lib/joomla-actions.ts
|
|
369
|
-
* import { createJoomlaActions } from "@simpleapps-com/augur-server";
|
|
370
|
-
* import { getAugurClient } from "./augur-client";
|
|
371
|
-
*
|
|
372
|
-
* export const joomlaActions = createJoomlaActions(getAugurClient(), {
|
|
373
|
-
* cachePrefix: "ampro:",
|
|
374
|
-
* });
|
|
375
|
-
*
|
|
376
|
-
* // In a server component:
|
|
377
|
-
* const article = await joomlaActions.getJoomlaContent(42);
|
|
378
|
-
* const articles = await joomlaActions.getJoomlaContentList({ catid: 5 });
|
|
379
|
-
* ```
|
|
380
|
-
*/
|
|
381
|
-
declare function createJoomlaActions(api: JoomlaApiClient, config?: JoomlaActionsConfig): JoomlaActions;
|
|
382
|
-
|
|
383
212
|
/** Derived from augur-api SDK — keeps types in sync automatically. */
|
|
384
213
|
type LegacyApiClient = Pick<AugurAPI, "legacy">;
|
|
385
214
|
interface LegacyActionsConfig {
|
|
@@ -425,101 +254,6 @@ interface LegacyActions {
|
|
|
425
254
|
*/
|
|
426
255
|
declare function createLegacyActions(api: LegacyApiClient, config?: LegacyActionsConfig): LegacyActions;
|
|
427
256
|
|
|
428
|
-
interface CustomerListResult {
|
|
429
|
-
data: unknown[];
|
|
430
|
-
total: number;
|
|
431
|
-
}
|
|
432
|
-
/** Derived from augur-api SDK — keeps types in sync automatically. */
|
|
433
|
-
type CustomersApiClient = Pick<AugurAPI, "customers">;
|
|
434
|
-
interface CustomersActionsConfig {
|
|
435
|
-
/** Cache key prefix (e.g. "ampro:"). Default: "". */
|
|
436
|
-
cachePrefix?: string;
|
|
437
|
-
/** CDN edge cache value passed to SDK. Default: 1 (hour). */
|
|
438
|
-
edgeCache?: EdgeCacheValue;
|
|
439
|
-
/** Redis TTL in seconds. Default: 3600 (1 hour). */
|
|
440
|
-
redisTtl?: number;
|
|
441
|
-
}
|
|
442
|
-
interface CustomersActions {
|
|
443
|
-
getCustomer: (customerId: number) => Promise<unknown>;
|
|
444
|
-
customerLookup: (params: Record<string, unknown>) => Promise<unknown[]>;
|
|
445
|
-
getCustomerDoc: (customerId: number) => Promise<unknown>;
|
|
446
|
-
getCustomerOrders: (customerId: number, params?: Record<string, unknown>) => Promise<CustomerListResult>;
|
|
447
|
-
getCustomerOrderDetail: (customerId: number, orderId: number) => Promise<unknown>;
|
|
448
|
-
getCustomerInvoices: (customerId: number, params?: Record<string, unknown>) => Promise<CustomerListResult>;
|
|
449
|
-
getCustomerInvoiceDetail: (customerId: number, invoiceNo: number) => Promise<unknown>;
|
|
450
|
-
getCustomerQuotes: (customerId: number, params?: Record<string, unknown>) => Promise<CustomerListResult>;
|
|
451
|
-
getCustomerQuoteDetail: (customerId: number, quoteNo: number) => Promise<unknown>;
|
|
452
|
-
getContacts: (params?: Record<string, unknown>) => Promise<unknown[]>;
|
|
453
|
-
getShipToAddresses: (customerId: number) => Promise<unknown[]>;
|
|
454
|
-
}
|
|
455
|
-
/**
|
|
456
|
-
* @deprecated Use `createSiteActions()` instead. This factory will be removed in the next major version.
|
|
457
|
-
*
|
|
458
|
-
* Creates server-side customer actions with Redis caching and edge cache support.
|
|
459
|
-
*
|
|
460
|
-
* Covers the customers microservice endpoints used by ecommerce sites:
|
|
461
|
-
* customer get, lookup, doc, orders, contacts, and ship-to addresses.
|
|
462
|
-
*
|
|
463
|
-
* @example
|
|
464
|
-
* ```ts
|
|
465
|
-
* import { createCustomersActions } from "@simpleapps-com/augur-server";
|
|
466
|
-
* import { getAugurClient } from "./augur-client";
|
|
467
|
-
*
|
|
468
|
-
* export const customersActions = createCustomersActions(getAugurClient(), {
|
|
469
|
-
* cachePrefix: "ampro:",
|
|
470
|
-
* });
|
|
471
|
-
*
|
|
472
|
-
* const customer = await customersActions.getCustomer(123);
|
|
473
|
-
* const orders = await customersActions.getCustomerOrders(123);
|
|
474
|
-
* ```
|
|
475
|
-
*/
|
|
476
|
-
declare function createCustomersActions(api: CustomersApiClient, config?: CustomersActionsConfig): CustomersActions;
|
|
477
|
-
|
|
478
|
-
/** Derived from augur-api SDK — keeps types in sync automatically. */
|
|
479
|
-
type SmartyStreetsApiClient = Pick<AugurAPI, "smartyStreets">;
|
|
480
|
-
interface SmartyStreetsActionsConfig {
|
|
481
|
-
/** Cache key prefix (e.g. "ampro:"). Default: "". */
|
|
482
|
-
cachePrefix?: string;
|
|
483
|
-
}
|
|
484
|
-
/** Standardized response from address validation. */
|
|
485
|
-
interface AddressValidationResult {
|
|
486
|
-
data: TSmartyStreets | undefined;
|
|
487
|
-
status: "success" | "not_found" | "error";
|
|
488
|
-
error?: {
|
|
489
|
-
message: string;
|
|
490
|
-
};
|
|
491
|
-
}
|
|
492
|
-
interface SmartyStreetsActions {
|
|
493
|
-
validateAddress: (params: Record<string, unknown>) => Promise<AddressValidationResult>;
|
|
494
|
-
}
|
|
495
|
-
/**
|
|
496
|
-
* @deprecated Use `createSiteActions()` instead. This factory will be removed in the next major version.
|
|
497
|
-
*
|
|
498
|
-
* Creates server-side SmartyStreets actions for address validation.
|
|
499
|
-
*
|
|
500
|
-
* Note: Address validation is a real-time operation and does NOT use caching.
|
|
501
|
-
* Each call hits the SmartyStreets API directly to ensure up-to-date results.
|
|
502
|
-
*
|
|
503
|
-
* @example
|
|
504
|
-
* ```ts
|
|
505
|
-
* import { createSmartyStreetsActions } from "@simpleapps-com/augur-server";
|
|
506
|
-
* import { getAugurClient } from "./augur-client";
|
|
507
|
-
*
|
|
508
|
-
* export const smartyStreetsActions = createSmartyStreetsActions(getAugurClient());
|
|
509
|
-
*
|
|
510
|
-
* const result = await smartyStreetsActions.validateAddress({
|
|
511
|
-
* address1: "123 Main St",
|
|
512
|
-
* city: "Provo",
|
|
513
|
-
* state: "UT",
|
|
514
|
-
* postalCode: "84606",
|
|
515
|
-
* });
|
|
516
|
-
* if (result.status === "success") {
|
|
517
|
-
* console.log(result.data); // TSmartyStreets
|
|
518
|
-
* }
|
|
519
|
-
* ```
|
|
520
|
-
*/
|
|
521
|
-
declare function createSmartyStreetsActions(api: SmartyStreetsApiClient, config?: SmartyStreetsActionsConfig): SmartyStreetsActions;
|
|
522
|
-
|
|
523
257
|
/** Derived from augur-api SDK — keeps types in sync automatically. */
|
|
524
258
|
type P21PimApiClient = Pick<AugurAPI, "p21Pim">;
|
|
525
259
|
interface P21PimActionsConfig {
|
|
@@ -1304,4 +1038,4 @@ interface SiteActions {
|
|
|
1304
1038
|
*/
|
|
1305
1039
|
declare function createSiteActions<TApi extends object>(api: TApi, config?: SiteActionsConfig): SiteActions;
|
|
1306
1040
|
|
|
1307
|
-
export { type
|
|
1041
|
+
export { type PaymentsApiClient as $, type AgrInfoActions as A, type Basecamp2Actions as B, type CommerceActions as C, type LogisticsApiClient as D, type NexusActionsConfig as E, type NexusApiClient as F, type GregorovichActions as G, type OrderActionsConfig as H, type ItemActions as I, type OrderApiClient as J, type P21ApisActionsConfig as K, type LegacyActions as L, type P21ApisApiClient as M, type NexusActions as N, type OrderActions as O, type P21ApisActions as P, type P21CoreActions as Q, type P21CoreActionsConfig as R, type P21CoreApiClient as S, type P21PimActions as T, type P21PimActionsConfig as U, type P21PimApiClient as V, type P21SismActions as W, type P21SismActionsConfig as X, type P21SismApiClient as Y, type PaymentsActions as Z, type PaymentsActionsConfig as _, type AgrInfoActionsConfig as a, type PricingActions as a0, type PricingActionsConfig as a1, type PricingApiClient as a2, type SiteActions as a3, type SiteActionsConfig as a4, type SlackActions as a5, type SlackActionsConfig as a6, type SlackApiClient as a7, type UpsActions as a8, type UpsActionsConfig as a9, createVmiActions as aA, type UpsApiClient as aa, type VmiActions as ab, type VmiActionsConfig as ac, type VmiApiClient as ad, createAgrInfoActions as ae, createAgrSiteActions as af, createAgrWorkActions as ag, createAvalaraActions as ah, createBasecamp2Actions as ai, createBrandFolderActions as aj, createCommerceActions as ak, createGregorovichActions as al, createItemActions as am, createLegacyActions as an, createLogisticsActions as ao, createNexusActions as ap, createOrderActions as aq, createP21ApisActions as ar, createP21CoreActions as as, createP21PimActions as at, createP21SismActions as au, createPaymentsActions as av, createPricingActions as aw, createSiteActions as ax, createSlackActions as ay, createUpsActions as az, type AgrInfoApiClient as b, type AgrSiteActions as c, type AgrSiteActionsConfig as d, type AgrSiteApiClient as e, type AgrWorkActions as f, type AgrWorkActionsConfig as g, type AgrWorkApiClient as h, type AvalaraActions as i, type AvalaraActionsConfig as j, type AvalaraApiClient as k, type Basecamp2ActionsConfig as l, type Basecamp2ApiClient as m, type BrandFolderActions as n, type BrandFolderActionsConfig as o, type BrandFolderApiClient as p, type CommerceActionsConfig as q, type CommerceApiClient as r, type GregorovichActionsConfig as s, type GregorovichApiClient as t, type ItemActionsConfig as u, type ItemsApiClient as v, type LegacyActionsConfig as w, type LegacyApiClient as x, type LogisticsActions as y, type LogisticsActionsConfig as z };
|
package/dist/site.d.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { a3 as SiteActions, a4 as SiteActionsConfig } from './site-DpL27QZc.js';
|
|
2
2
|
import { AugurAuthCallbacks } from './auth.js';
|
|
3
3
|
import { NextAuthConfig } from 'next-auth';
|
|
4
4
|
import '@simpleapps-com/augur-core';
|
|
5
5
|
import '@simpleapps-com/augur-api';
|
|
6
6
|
import '@simpleapps-com/augur-utils';
|
|
7
|
+
import './smarty-streets-1vGdsGf-.js';
|
|
7
8
|
|
|
8
9
|
/** Auth options forwarded to NextAuth when creating a server site. */
|
|
9
10
|
interface ServerSiteAuthConfig {
|
package/dist/site.js
CHANGED
|
@@ -5,10 +5,14 @@ import {
|
|
|
5
5
|
createAuthConfig
|
|
6
6
|
} from "./chunk-Z7QWERHW.js";
|
|
7
7
|
import "./chunk-XGRQ53P2.js";
|
|
8
|
+
import {
|
|
9
|
+
registerSiteActions
|
|
10
|
+
} from "./chunk-MQGUOFAZ.js";
|
|
8
11
|
|
|
9
12
|
// src/server-site.ts
|
|
10
13
|
function createServerSite(client, config = {}) {
|
|
11
14
|
const actions = createSiteActions(client, config);
|
|
15
|
+
registerSiteActions(actions);
|
|
12
16
|
const auth = config.auth ? createAuthConfig({
|
|
13
17
|
augurClient: client,
|
|
14
18
|
defaultCustomerId: config.defaultCustomerId,
|
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\";\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\";\n *\n * const api = new AugurApi({ baseUrl: process.env.AUGUR_API_URL! });\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\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":"
|
|
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\";\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\";\n *\n * const api = new AugurApi({ baseUrl: process.env.AUGUR_API_URL! });\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\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":";;;;;;;;;;;;AA2CO,SAAS,iBACd,QACA,SAA2B,CAAC,GACV;AAClB,QAAM,UAAU,kBAAkB,QAAQ,MAAM;AAChD,sBAAoB,OAAO;AAE3B,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":[]}
|
|
@@ -0,0 +1,272 @@
|
|
|
1
|
+
import { AugurAPI } from '@simpleapps-com/augur-api';
|
|
2
|
+
import { EdgeCacheValue } from '@simpleapps-com/augur-core';
|
|
3
|
+
import { TAttribute, TProductItem, TSmartyStreets } from '@simpleapps-com/augur-utils';
|
|
4
|
+
|
|
5
|
+
/** Derived from augur-api SDK — keeps types in sync automatically. */
|
|
6
|
+
type SearchApiClient = Pick<AugurAPI, "opensearch">;
|
|
7
|
+
interface SearchActionsConfig {
|
|
8
|
+
/** Cache key prefix (e.g. "ampro:"). Default: "". */
|
|
9
|
+
cachePrefix?: string;
|
|
10
|
+
/** CDN edge cache value passed to SDK. Default: 1 (hour). */
|
|
11
|
+
edgeCache?: EdgeCacheValue;
|
|
12
|
+
/** Redis TTL for search lookups in seconds. Default: 3600 (1 hour). */
|
|
13
|
+
redisTtl?: number;
|
|
14
|
+
/** Default source fields for item search. Default: "display_desc". */
|
|
15
|
+
defaultSourceFields?: string;
|
|
16
|
+
}
|
|
17
|
+
/** Paginated response for infinite scroll. */
|
|
18
|
+
interface SearchPage {
|
|
19
|
+
data: TProductItem[];
|
|
20
|
+
total: number;
|
|
21
|
+
nextCursor?: number;
|
|
22
|
+
}
|
|
23
|
+
interface SearchActions {
|
|
24
|
+
getSearchAttributes: (q: string) => Promise<TAttribute[]>;
|
|
25
|
+
getSearchSuggestions: (q: string, limit?: number, offset?: number) => Promise<{
|
|
26
|
+
data: unknown[];
|
|
27
|
+
total: number;
|
|
28
|
+
totalResults: number;
|
|
29
|
+
}>;
|
|
30
|
+
itemSearch: (filters: {
|
|
31
|
+
q: string;
|
|
32
|
+
limit: number;
|
|
33
|
+
offset: number;
|
|
34
|
+
sortBy?: string;
|
|
35
|
+
filters?: [string, string][];
|
|
36
|
+
}, itemCategoryUid?: number | string) => Promise<{
|
|
37
|
+
items: TProductItem[];
|
|
38
|
+
totalResults: number;
|
|
39
|
+
}>;
|
|
40
|
+
itemSearchInfinite: (filters: {
|
|
41
|
+
q: string;
|
|
42
|
+
limit: number;
|
|
43
|
+
sortBy?: string;
|
|
44
|
+
filters?: [string, string][];
|
|
45
|
+
}, itemCategoryUid?: number | string, pageParam?: number) => Promise<SearchPage>;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* @deprecated Use `createSiteActions()` instead. This factory will be removed in the next major version.
|
|
49
|
+
*
|
|
50
|
+
* Creates server-side search actions with Redis caching and edge cache support.
|
|
51
|
+
*
|
|
52
|
+
* Uses `withServerCache` which produces cache keys compatible with augur-hooks'
|
|
53
|
+
* `withCache`, so server-prefetched data is shared with client-side hooks.
|
|
54
|
+
*
|
|
55
|
+
* @example
|
|
56
|
+
* ```ts
|
|
57
|
+
* // lib/search-actions.ts
|
|
58
|
+
* import { createSearchActions } from "@simpleapps-com/augur-server";
|
|
59
|
+
* import { getAugurClient } from "./augur-client";
|
|
60
|
+
*
|
|
61
|
+
* export const searchActions = createSearchActions(getAugurClient(), {
|
|
62
|
+
* cachePrefix: "ampro:",
|
|
63
|
+
* });
|
|
64
|
+
*
|
|
65
|
+
* // In a server component:
|
|
66
|
+
* const attrs = await searchActions.getSearchAttributes("widget");
|
|
67
|
+
* const results = await searchActions.itemSearch({ q: "widget", limit: 20, offset: 0 });
|
|
68
|
+
* ```
|
|
69
|
+
*/
|
|
70
|
+
declare function createSearchActions(api: SearchApiClient, config?: SearchActionsConfig): SearchActions;
|
|
71
|
+
|
|
72
|
+
interface ShippingAddress {
|
|
73
|
+
address1: string;
|
|
74
|
+
city: string;
|
|
75
|
+
state: string;
|
|
76
|
+
postalCode: string;
|
|
77
|
+
country?: string;
|
|
78
|
+
}
|
|
79
|
+
/** Derived from augur-api SDK — keeps types in sync automatically. */
|
|
80
|
+
type ShippingApiClient = Pick<AugurAPI, "ups">;
|
|
81
|
+
interface ShippingActionsConfig {
|
|
82
|
+
/** Warehouse/origin address for rate calculations. */
|
|
83
|
+
fromAddress: ShippingAddress;
|
|
84
|
+
/** UPS service codes to filter results. Default: undefined (return all). */
|
|
85
|
+
defaultServiceCodes?: string[];
|
|
86
|
+
/** Cache key prefix (e.g. "ampro:"). Default: "". */
|
|
87
|
+
cachePrefix?: string;
|
|
88
|
+
/** CDN edge cache value passed to SDK. Default: 1 (hour). */
|
|
89
|
+
edgeCache?: EdgeCacheValue;
|
|
90
|
+
/** Redis TTL for shipping rate lookups in seconds. Default: 3600 (1 hour). */
|
|
91
|
+
redisTtl?: number;
|
|
92
|
+
}
|
|
93
|
+
interface ShippingActions {
|
|
94
|
+
getShippingRates: (toAddress: ShippingAddress, weight: number, serviceCodes?: string[]) => Promise<unknown>;
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* @deprecated Use `createSiteActions()` instead. This factory will be removed in the next major version.
|
|
98
|
+
*
|
|
99
|
+
* Creates server-side shipping actions with Redis caching and edge cache support.
|
|
100
|
+
*
|
|
101
|
+
* Uses `withServerCache` which produces cache keys compatible with augur-hooks'
|
|
102
|
+
* `withCache`, so server-prefetched data is shared with client-side hooks.
|
|
103
|
+
*
|
|
104
|
+
* @example
|
|
105
|
+
* ```ts
|
|
106
|
+
* // lib/shipping-actions.ts
|
|
107
|
+
* import { createShippingActions } from "@simpleapps-com/augur-server";
|
|
108
|
+
* import { getAugurClient } from "./augur-client";
|
|
109
|
+
*
|
|
110
|
+
* export const shippingActions = createShippingActions(getAugurClient(), {
|
|
111
|
+
* fromAddress: {
|
|
112
|
+
* address1: "123 Warehouse Ln",
|
|
113
|
+
* city: "Chicago",
|
|
114
|
+
* state: "IL",
|
|
115
|
+
* postalCode: "60601",
|
|
116
|
+
* },
|
|
117
|
+
* });
|
|
118
|
+
*
|
|
119
|
+
* // In a server component:
|
|
120
|
+
* const rates = await shippingActions.getShippingRates(
|
|
121
|
+
* { address1: "456 Main St", city: "Denver", state: "CO", postalCode: "80202" },
|
|
122
|
+
* 5.0,
|
|
123
|
+
* );
|
|
124
|
+
* ```
|
|
125
|
+
*/
|
|
126
|
+
declare function createShippingActions(api: ShippingApiClient, config: ShippingActionsConfig): ShippingActions;
|
|
127
|
+
|
|
128
|
+
/** Derived from augur-api SDK — keeps types in sync automatically. */
|
|
129
|
+
type JoomlaApiClient = Pick<AugurAPI, "joomla">;
|
|
130
|
+
interface JoomlaActionsConfig {
|
|
131
|
+
/** Cache key prefix (e.g. "ampro:"). Default: "". */
|
|
132
|
+
cachePrefix?: string;
|
|
133
|
+
/** CDN edge cache value passed to SDK. Default: 1 (hour). */
|
|
134
|
+
edgeCache?: EdgeCacheValue;
|
|
135
|
+
/** Redis TTL for Joomla lookups in seconds. Default: 3600 (1 hour). */
|
|
136
|
+
redisTtl?: number;
|
|
137
|
+
}
|
|
138
|
+
interface NormalizedUserProfile {
|
|
139
|
+
id: string;
|
|
140
|
+
name: string;
|
|
141
|
+
email: string;
|
|
142
|
+
customerId: string;
|
|
143
|
+
permissions: string[];
|
|
144
|
+
}
|
|
145
|
+
interface JoomlaActions {
|
|
146
|
+
getJoomlaContent: (articleId: number) => Promise<unknown>;
|
|
147
|
+
getJoomlaContentList: (params?: Record<string, unknown>) => Promise<unknown[]>;
|
|
148
|
+
getJoomlaMenu: (params?: Record<string, unknown>) => Promise<unknown[]>;
|
|
149
|
+
getJoomlaMenuDoc: (menuId: number | string) => Promise<unknown>;
|
|
150
|
+
getUserProfile: (userId: number | string) => Promise<NormalizedUserProfile>;
|
|
151
|
+
}
|
|
152
|
+
/**
|
|
153
|
+
* @deprecated Use `createSiteActions()` instead. This factory will be removed in the next major version.
|
|
154
|
+
*
|
|
155
|
+
* Creates server-side Joomla content actions with Redis caching and edge cache support.
|
|
156
|
+
*
|
|
157
|
+
* Uses `withServerCache` which produces cache keys compatible with augur-hooks'
|
|
158
|
+
* `withCache`, so server-prefetched data is shared with client-side hooks.
|
|
159
|
+
*
|
|
160
|
+
* @example
|
|
161
|
+
* ```ts
|
|
162
|
+
* // lib/joomla-actions.ts
|
|
163
|
+
* import { createJoomlaActions } from "@simpleapps-com/augur-server";
|
|
164
|
+
* import { getAugurClient } from "./augur-client";
|
|
165
|
+
*
|
|
166
|
+
* export const joomlaActions = createJoomlaActions(getAugurClient(), {
|
|
167
|
+
* cachePrefix: "ampro:",
|
|
168
|
+
* });
|
|
169
|
+
*
|
|
170
|
+
* // In a server component:
|
|
171
|
+
* const article = await joomlaActions.getJoomlaContent(42);
|
|
172
|
+
* const articles = await joomlaActions.getJoomlaContentList({ catid: 5 });
|
|
173
|
+
* ```
|
|
174
|
+
*/
|
|
175
|
+
declare function createJoomlaActions(api: JoomlaApiClient, config?: JoomlaActionsConfig): JoomlaActions;
|
|
176
|
+
|
|
177
|
+
interface CustomerListResult {
|
|
178
|
+
data: unknown[];
|
|
179
|
+
total: number;
|
|
180
|
+
}
|
|
181
|
+
/** Derived from augur-api SDK — keeps types in sync automatically. */
|
|
182
|
+
type CustomersApiClient = Pick<AugurAPI, "customers">;
|
|
183
|
+
interface CustomersActionsConfig {
|
|
184
|
+
/** Cache key prefix (e.g. "ampro:"). Default: "". */
|
|
185
|
+
cachePrefix?: string;
|
|
186
|
+
/** CDN edge cache value passed to SDK. Default: 1 (hour). */
|
|
187
|
+
edgeCache?: EdgeCacheValue;
|
|
188
|
+
/** Redis TTL in seconds. Default: 3600 (1 hour). */
|
|
189
|
+
redisTtl?: number;
|
|
190
|
+
}
|
|
191
|
+
interface CustomersActions {
|
|
192
|
+
getCustomer: (customerId: number) => Promise<unknown>;
|
|
193
|
+
customerLookup: (params: Record<string, unknown>) => Promise<unknown[]>;
|
|
194
|
+
getCustomerDoc: (customerId: number) => Promise<unknown>;
|
|
195
|
+
getCustomerOrders: (customerId: number, params?: Record<string, unknown>) => Promise<CustomerListResult>;
|
|
196
|
+
getCustomerOrderDetail: (customerId: number, orderId: number) => Promise<unknown>;
|
|
197
|
+
getCustomerInvoices: (customerId: number, params?: Record<string, unknown>) => Promise<CustomerListResult>;
|
|
198
|
+
getCustomerInvoiceDetail: (customerId: number, invoiceNo: number) => Promise<unknown>;
|
|
199
|
+
getCustomerQuotes: (customerId: number, params?: Record<string, unknown>) => Promise<CustomerListResult>;
|
|
200
|
+
getCustomerQuoteDetail: (customerId: number, quoteNo: number) => Promise<unknown>;
|
|
201
|
+
getContacts: (params?: Record<string, unknown>) => Promise<unknown[]>;
|
|
202
|
+
getShipToAddresses: (customerId: number) => Promise<unknown[]>;
|
|
203
|
+
}
|
|
204
|
+
/**
|
|
205
|
+
* @deprecated Use `createSiteActions()` instead. This factory will be removed in the next major version.
|
|
206
|
+
*
|
|
207
|
+
* Creates server-side customer actions with Redis caching and edge cache support.
|
|
208
|
+
*
|
|
209
|
+
* Covers the customers microservice endpoints used by ecommerce sites:
|
|
210
|
+
* customer get, lookup, doc, orders, contacts, and ship-to addresses.
|
|
211
|
+
*
|
|
212
|
+
* @example
|
|
213
|
+
* ```ts
|
|
214
|
+
* import { createCustomersActions } from "@simpleapps-com/augur-server";
|
|
215
|
+
* import { getAugurClient } from "./augur-client";
|
|
216
|
+
*
|
|
217
|
+
* export const customersActions = createCustomersActions(getAugurClient(), {
|
|
218
|
+
* cachePrefix: "ampro:",
|
|
219
|
+
* });
|
|
220
|
+
*
|
|
221
|
+
* const customer = await customersActions.getCustomer(123);
|
|
222
|
+
* const orders = await customersActions.getCustomerOrders(123);
|
|
223
|
+
* ```
|
|
224
|
+
*/
|
|
225
|
+
declare function createCustomersActions(api: CustomersApiClient, config?: CustomersActionsConfig): CustomersActions;
|
|
226
|
+
|
|
227
|
+
/** Derived from augur-api SDK — keeps types in sync automatically. */
|
|
228
|
+
type SmartyStreetsApiClient = Pick<AugurAPI, "smartyStreets">;
|
|
229
|
+
interface SmartyStreetsActionsConfig {
|
|
230
|
+
/** Cache key prefix (e.g. "ampro:"). Default: "". */
|
|
231
|
+
cachePrefix?: string;
|
|
232
|
+
}
|
|
233
|
+
/** Standardized response from address validation. */
|
|
234
|
+
interface AddressValidationResult {
|
|
235
|
+
data: TSmartyStreets | undefined;
|
|
236
|
+
status: "success" | "not_found" | "error";
|
|
237
|
+
error?: {
|
|
238
|
+
message: string;
|
|
239
|
+
};
|
|
240
|
+
}
|
|
241
|
+
interface SmartyStreetsActions {
|
|
242
|
+
validateAddress: (params: Record<string, unknown>) => Promise<AddressValidationResult>;
|
|
243
|
+
}
|
|
244
|
+
/**
|
|
245
|
+
* @deprecated Use `createSiteActions()` instead. This factory will be removed in the next major version.
|
|
246
|
+
*
|
|
247
|
+
* Creates server-side SmartyStreets actions for address validation.
|
|
248
|
+
*
|
|
249
|
+
* Note: Address validation is a real-time operation and does NOT use caching.
|
|
250
|
+
* Each call hits the SmartyStreets API directly to ensure up-to-date results.
|
|
251
|
+
*
|
|
252
|
+
* @example
|
|
253
|
+
* ```ts
|
|
254
|
+
* import { createSmartyStreetsActions } from "@simpleapps-com/augur-server";
|
|
255
|
+
* import { getAugurClient } from "./augur-client";
|
|
256
|
+
*
|
|
257
|
+
* export const smartyStreetsActions = createSmartyStreetsActions(getAugurClient());
|
|
258
|
+
*
|
|
259
|
+
* const result = await smartyStreetsActions.validateAddress({
|
|
260
|
+
* address1: "123 Main St",
|
|
261
|
+
* city: "Provo",
|
|
262
|
+
* state: "UT",
|
|
263
|
+
* postalCode: "84606",
|
|
264
|
+
* });
|
|
265
|
+
* if (result.status === "success") {
|
|
266
|
+
* console.log(result.data); // TSmartyStreets
|
|
267
|
+
* }
|
|
268
|
+
* ```
|
|
269
|
+
*/
|
|
270
|
+
declare function createSmartyStreetsActions(api: SmartyStreetsApiClient, config?: SmartyStreetsActionsConfig): SmartyStreetsActions;
|
|
271
|
+
|
|
272
|
+
export { type AddressValidationResult as A, type CustomerListResult as C, type JoomlaActions as J, type NormalizedUserProfile as N, type SearchActions as S, type CustomersActions as a, type CustomersActionsConfig as b, type CustomersApiClient as c, type JoomlaActionsConfig as d, type JoomlaApiClient as e, type SearchActionsConfig as f, type SearchApiClient as g, type SearchPage as h, type ShippingActions as i, type ShippingActionsConfig as j, type ShippingAddress as k, type ShippingApiClient as l, type SmartyStreetsActions as m, type SmartyStreetsActionsConfig as n, type SmartyStreetsApiClient as o, createCustomersActions as p, createJoomlaActions as q, createSearchActions as r, createShippingActions as s, createSmartyStreetsActions as t };
|
package/dist/testing.d.ts
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
export { DeepMockClient, MockClientResult, createMockClient } from '@simpleapps-com/augur-core/testing';
|
|
2
|
-
|
|
2
|
+
export { c as clearSiteActions } from './server-site-registry-DlLN0e5y.js';
|
|
3
|
+
import { a3 as SiteActions } from './site-DpL27QZc.js';
|
|
3
4
|
import '@simpleapps-com/augur-core';
|
|
4
5
|
import '@simpleapps-com/augur-api';
|
|
5
6
|
import '@simpleapps-com/augur-utils';
|
|
7
|
+
import './smarty-streets-1vGdsGf-.js';
|
|
6
8
|
|
|
7
9
|
/**
|
|
8
10
|
* A mock function type compatible with both Vitest and Jest.
|
package/dist/testing.js
CHANGED
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
import {
|
|
2
|
+
clearSiteActions
|
|
3
|
+
} from "./chunk-MQGUOFAZ.js";
|
|
4
|
+
|
|
1
5
|
// src/testing.ts
|
|
2
6
|
import { createMockClient } from "@simpleapps-com/augur-core/testing";
|
|
3
7
|
var SERVICE_METHODS = {
|
|
@@ -187,6 +191,7 @@ function createMockSiteActions() {
|
|
|
187
191
|
};
|
|
188
192
|
}
|
|
189
193
|
export {
|
|
194
|
+
clearSiteActions,
|
|
190
195
|
createMockClient,
|
|
191
196
|
createMockSiteActions
|
|
192
197
|
};
|