perspectapi-ts-sdk 7.0.0 → 7.1.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/{chunk-K3T2AFYA.mjs → chunk-MMKJ2WBF.mjs} +93 -5
- package/dist/{index-CWvUyMt3.d.mts → index-DuNDHod-.d.mts} +73 -2
- package/dist/{index-CWvUyMt3.d.ts → index-DuNDHod-.d.ts} +73 -2
- package/dist/index.d.mts +4 -2
- package/dist/index.d.ts +4 -2
- package/dist/index.js +92 -5
- package/dist/index.mjs +1 -1
- package/dist/v2/index.d.mts +1 -1
- package/dist/v2/index.d.ts +1 -1
- package/dist/v2/index.js +94 -5
- package/dist/v2/index.mjs +3 -1
- package/package.json +1 -1
- package/src/client/site-users-client.ts +2 -0
- package/src/v2/client/email-client.ts +23 -0
- package/src/v2/client/orders-client.ts +99 -5
- package/src/v2/index.ts +4 -0
- package/src/v2/types.ts +54 -0
|
@@ -892,13 +892,40 @@ var CollectionsV2Client = class extends BaseV2Client {
|
|
|
892
892
|
// src/v2/client/orders-client.ts
|
|
893
893
|
var OrdersV2Client = class extends BaseV2Client {
|
|
894
894
|
async list(siteName, params, cachePolicy) {
|
|
895
|
-
return this.getList(
|
|
895
|
+
return this.getList(
|
|
896
|
+
this.sitePath(siteName, "orders"),
|
|
897
|
+
params,
|
|
898
|
+
this.withOrderTags(siteName, cachePolicy, {
|
|
899
|
+
fulfillmentStatus: params?.fulfillment_status
|
|
900
|
+
})
|
|
901
|
+
);
|
|
896
902
|
}
|
|
897
|
-
async *listAutoPaginated(siteName, params) {
|
|
898
|
-
|
|
903
|
+
async *listAutoPaginated(siteName, params, cachePolicy) {
|
|
904
|
+
let startingAfter;
|
|
905
|
+
let hasMore = true;
|
|
906
|
+
while (hasMore) {
|
|
907
|
+
const queryParams = { ...params ?? {} };
|
|
908
|
+
if (startingAfter) {
|
|
909
|
+
queryParams.starting_after = startingAfter;
|
|
910
|
+
}
|
|
911
|
+
const page = await this.list(siteName, queryParams, cachePolicy);
|
|
912
|
+
for (const item of page.data) {
|
|
913
|
+
yield item;
|
|
914
|
+
}
|
|
915
|
+
hasMore = page.has_more;
|
|
916
|
+
if (page.data.length > 0) {
|
|
917
|
+
startingAfter = page.data[page.data.length - 1].id;
|
|
918
|
+
} else {
|
|
919
|
+
hasMore = false;
|
|
920
|
+
}
|
|
921
|
+
}
|
|
899
922
|
}
|
|
900
923
|
async get(siteName, id, cachePolicy) {
|
|
901
|
-
return this.getOne(
|
|
924
|
+
return this.getOne(
|
|
925
|
+
this.sitePath(siteName, "orders", id),
|
|
926
|
+
void 0,
|
|
927
|
+
this.withOrderTags(siteName, cachePolicy, { id })
|
|
928
|
+
);
|
|
902
929
|
}
|
|
903
930
|
/**
|
|
904
931
|
* Create a checkout session via Stripe. Returns the session ID and a
|
|
@@ -920,10 +947,51 @@ var OrdersV2Client = class extends BaseV2Client {
|
|
|
920
947
|
* fulfillment state to send the customer fulfillment email.
|
|
921
948
|
*/
|
|
922
949
|
async updateFulfillment(siteName, id, data) {
|
|
923
|
-
|
|
950
|
+
const result = await this.patchOne(
|
|
924
951
|
this.sitePath(siteName, "orders", `${id}/fulfillment`),
|
|
925
952
|
data
|
|
926
953
|
);
|
|
954
|
+
await this.invalidateCache({
|
|
955
|
+
tags: this.buildOrderTags(siteName, { id }),
|
|
956
|
+
keys: [this.sitePath(siteName, "orders", id)]
|
|
957
|
+
});
|
|
958
|
+
return result;
|
|
959
|
+
}
|
|
960
|
+
/**
|
|
961
|
+
* Send the customer fulfillment template for an external delivery/packing
|
|
962
|
+
* record without mutating a checkout session.
|
|
963
|
+
*/
|
|
964
|
+
async sendFulfillmentNotification(siteName, data) {
|
|
965
|
+
return this.post(
|
|
966
|
+
this.sitePath(siteName, "orders", "fulfillment-notifications"),
|
|
967
|
+
data
|
|
968
|
+
);
|
|
969
|
+
}
|
|
970
|
+
withOrderTags(siteName, cachePolicy, options = {}) {
|
|
971
|
+
const tags = new Set(cachePolicy?.tags ?? []);
|
|
972
|
+
for (const tag of this.buildOrderTags(siteName, options)) {
|
|
973
|
+
tags.add(tag);
|
|
974
|
+
}
|
|
975
|
+
return {
|
|
976
|
+
...cachePolicy,
|
|
977
|
+
tags: Array.from(tags)
|
|
978
|
+
};
|
|
979
|
+
}
|
|
980
|
+
buildOrderTags(siteName, options = {}) {
|
|
981
|
+
const tags = /* @__PURE__ */ new Set(["orders", `orders:site:${siteName}`]);
|
|
982
|
+
if (options.id) {
|
|
983
|
+
tags.add(`orders:id:${options.id}`);
|
|
984
|
+
}
|
|
985
|
+
const fulfillmentStatus = this.normalizeTagPart(options.fulfillmentStatus);
|
|
986
|
+
if (fulfillmentStatus) {
|
|
987
|
+
tags.add(`orders:fulfillment:${siteName}:${fulfillmentStatus}`);
|
|
988
|
+
}
|
|
989
|
+
return Array.from(tags);
|
|
990
|
+
}
|
|
991
|
+
normalizeTagPart(value) {
|
|
992
|
+
if (!value) return null;
|
|
993
|
+
const normalized = value.trim().toLowerCase().replace(/[^a-z0-9_-]+/g, "-");
|
|
994
|
+
return normalized || null;
|
|
927
995
|
}
|
|
928
996
|
};
|
|
929
997
|
|
|
@@ -1309,6 +1377,23 @@ var CreditsV2Client = class extends BaseV2Client {
|
|
|
1309
1377
|
}
|
|
1310
1378
|
};
|
|
1311
1379
|
|
|
1380
|
+
// src/v2/client/email-client.ts
|
|
1381
|
+
var EmailV2Client = class extends BaseV2Client {
|
|
1382
|
+
/**
|
|
1383
|
+
* Send a transactional email using the site's configured email provider.
|
|
1384
|
+
*
|
|
1385
|
+
* Requires a server-side API key — never call this from a browser.
|
|
1386
|
+
* The site must have an email provider configured in its settings.
|
|
1387
|
+
* At least one of `html` or `text` must be provided.
|
|
1388
|
+
*/
|
|
1389
|
+
async send(siteName, params) {
|
|
1390
|
+
return this.post(
|
|
1391
|
+
this.sitePath(siteName, "email", "send"),
|
|
1392
|
+
params
|
|
1393
|
+
);
|
|
1394
|
+
}
|
|
1395
|
+
};
|
|
1396
|
+
|
|
1312
1397
|
// src/v2/index.ts
|
|
1313
1398
|
var PerspectApiV2Client = class {
|
|
1314
1399
|
http;
|
|
@@ -1327,6 +1412,7 @@ var PerspectApiV2Client = class {
|
|
|
1327
1412
|
webhooks;
|
|
1328
1413
|
subscriptions;
|
|
1329
1414
|
credits;
|
|
1415
|
+
email;
|
|
1330
1416
|
constructor(config) {
|
|
1331
1417
|
const baseUrl = config.baseUrl.replace(/\/+$/, "");
|
|
1332
1418
|
const v2BaseUrl = baseUrl.endsWith("/api/v2") ? baseUrl : `${baseUrl}/api/v2`;
|
|
@@ -1348,6 +1434,7 @@ var PerspectApiV2Client = class {
|
|
|
1348
1434
|
this.webhooks = new WebhooksV2Client(this.http, basePath, cache);
|
|
1349
1435
|
this.subscriptions = new SubscriptionsV2Client(this.http, basePath, cache);
|
|
1350
1436
|
this.credits = new CreditsV2Client(this.http, basePath, cache);
|
|
1437
|
+
this.email = new EmailV2Client(this.http, basePath, cache);
|
|
1351
1438
|
}
|
|
1352
1439
|
/** Update the JWT token for authenticated requests. */
|
|
1353
1440
|
setAuth(jwt) {
|
|
@@ -1388,6 +1475,7 @@ export {
|
|
|
1388
1475
|
WebhooksV2Client,
|
|
1389
1476
|
SubscriptionsV2Client,
|
|
1390
1477
|
CreditsV2Client,
|
|
1478
|
+
EmailV2Client,
|
|
1391
1479
|
PerspectApiV2Client,
|
|
1392
1480
|
createPerspectApiV2Client
|
|
1393
1481
|
};
|
|
@@ -1462,9 +1462,40 @@ interface V2OrderFulfillmentUpdate {
|
|
|
1462
1462
|
fulfillment_status: string;
|
|
1463
1463
|
tracking_number?: string;
|
|
1464
1464
|
notes?: string;
|
|
1465
|
+
fulfillment_details_text?: string;
|
|
1466
|
+
fulfillment_details_html?: string;
|
|
1465
1467
|
/** When true, a terminal fulfillment status triggers a customer email. */
|
|
1466
1468
|
notify_customer?: boolean;
|
|
1467
1469
|
}
|
|
1470
|
+
interface V2OrderFulfillmentNotificationLineItem {
|
|
1471
|
+
quantity: number;
|
|
1472
|
+
description: string;
|
|
1473
|
+
amount_total?: number;
|
|
1474
|
+
currency?: string;
|
|
1475
|
+
}
|
|
1476
|
+
interface V2OrderFulfillmentNotificationParams {
|
|
1477
|
+
session_id?: string;
|
|
1478
|
+
order_id?: string;
|
|
1479
|
+
customer_email: string;
|
|
1480
|
+
customer_name?: string;
|
|
1481
|
+
fulfillment_status?: string;
|
|
1482
|
+
fulfillment_details_text?: string;
|
|
1483
|
+
fulfillment_details_html?: string;
|
|
1484
|
+
line_items?: V2OrderFulfillmentNotificationLineItem[];
|
|
1485
|
+
amount_total?: number;
|
|
1486
|
+
currency?: string;
|
|
1487
|
+
shipping_details?: Record<string, unknown>;
|
|
1488
|
+
customer_details?: Record<string, unknown>;
|
|
1489
|
+
metadata?: Record<string, unknown>;
|
|
1490
|
+
created_at?: string;
|
|
1491
|
+
}
|
|
1492
|
+
interface V2OrderFulfillmentNotificationResult extends V2Object {
|
|
1493
|
+
object: "fulfillment_notification";
|
|
1494
|
+
order_id: string;
|
|
1495
|
+
notified: boolean;
|
|
1496
|
+
queued: boolean;
|
|
1497
|
+
reason?: string;
|
|
1498
|
+
}
|
|
1468
1499
|
interface V2OrderCreateResult extends V2Object {
|
|
1469
1500
|
object: "checkout_session";
|
|
1470
1501
|
checkout_url: string | null;
|
|
@@ -1802,6 +1833,22 @@ interface V2GrantCreditResult {
|
|
|
1802
1833
|
object: "grant_credit_result";
|
|
1803
1834
|
new_balance_cents: number;
|
|
1804
1835
|
}
|
|
1836
|
+
interface V2EmailSendParams {
|
|
1837
|
+
to: string | string[];
|
|
1838
|
+
subject: string;
|
|
1839
|
+
html?: string;
|
|
1840
|
+
text?: string;
|
|
1841
|
+
from?: string;
|
|
1842
|
+
reply_to?: string;
|
|
1843
|
+
cc?: string | string[];
|
|
1844
|
+
bcc?: string | string[];
|
|
1845
|
+
}
|
|
1846
|
+
interface V2EmailSendResult {
|
|
1847
|
+
object: "email";
|
|
1848
|
+
id: string | null;
|
|
1849
|
+
status: "sent";
|
|
1850
|
+
to: string | string[];
|
|
1851
|
+
}
|
|
1805
1852
|
|
|
1806
1853
|
/**
|
|
1807
1854
|
* v2 Base Client — cursor pagination, expand support, caching, typed errors.
|
|
@@ -1941,7 +1988,7 @@ declare class CollectionsV2Client extends BaseV2Client {
|
|
|
1941
1988
|
|
|
1942
1989
|
declare class OrdersV2Client extends BaseV2Client {
|
|
1943
1990
|
list(siteName: string, params?: V2OrderListParams, cachePolicy?: CachePolicy): Promise<V2List<V2Order>>;
|
|
1944
|
-
listAutoPaginated(siteName: string, params?: Omit<V2OrderListParams, 'starting_after' | 'ending_before'
|
|
1991
|
+
listAutoPaginated(siteName: string, params?: Omit<V2OrderListParams, 'starting_after' | 'ending_before'>, cachePolicy?: CachePolicy): AsyncGenerator<V2Order, void, unknown>;
|
|
1945
1992
|
get(siteName: string, id: string, cachePolicy?: CachePolicy): Promise<V2Order>;
|
|
1946
1993
|
/**
|
|
1947
1994
|
* Create a checkout session via Stripe. Returns the session ID and a
|
|
@@ -1958,6 +2005,14 @@ declare class OrdersV2Client extends BaseV2Client {
|
|
|
1958
2005
|
* fulfillment state to send the customer fulfillment email.
|
|
1959
2006
|
*/
|
|
1960
2007
|
updateFulfillment(siteName: string, id: string, data: V2OrderFulfillmentUpdate): Promise<V2Order>;
|
|
2008
|
+
/**
|
|
2009
|
+
* Send the customer fulfillment template for an external delivery/packing
|
|
2010
|
+
* record without mutating a checkout session.
|
|
2011
|
+
*/
|
|
2012
|
+
sendFulfillmentNotification(siteName: string, data: V2OrderFulfillmentNotificationParams): Promise<V2OrderFulfillmentNotificationResult>;
|
|
2013
|
+
private withOrderTags;
|
|
2014
|
+
private buildOrderTags;
|
|
2015
|
+
private normalizeTagPart;
|
|
1961
2016
|
}
|
|
1962
2017
|
|
|
1963
2018
|
/**
|
|
@@ -2179,6 +2234,21 @@ declare class CreditsV2Client extends BaseV2Client {
|
|
|
2179
2234
|
grantCredit(siteName: string, userId: string, data: V2GrantCreditParams): Promise<V2GrantCreditResult>;
|
|
2180
2235
|
}
|
|
2181
2236
|
|
|
2237
|
+
/**
|
|
2238
|
+
* v2 Email Client — send transactional email through a site's configured provider.
|
|
2239
|
+
*/
|
|
2240
|
+
|
|
2241
|
+
declare class EmailV2Client extends BaseV2Client {
|
|
2242
|
+
/**
|
|
2243
|
+
* Send a transactional email using the site's configured email provider.
|
|
2244
|
+
*
|
|
2245
|
+
* Requires a server-side API key — never call this from a browser.
|
|
2246
|
+
* The site must have an email provider configured in its settings.
|
|
2247
|
+
* At least one of `html` or `text` must be provided.
|
|
2248
|
+
*/
|
|
2249
|
+
send(siteName: string, params: V2EmailSendParams): Promise<V2EmailSendResult>;
|
|
2250
|
+
}
|
|
2251
|
+
|
|
2182
2252
|
/**
|
|
2183
2253
|
* PerspectAPI v2 SDK Client
|
|
2184
2254
|
*
|
|
@@ -2211,6 +2281,7 @@ declare class PerspectApiV2Client {
|
|
|
2211
2281
|
readonly webhooks: WebhooksV2Client;
|
|
2212
2282
|
readonly subscriptions: SubscriptionsV2Client;
|
|
2213
2283
|
readonly credits: CreditsV2Client;
|
|
2284
|
+
readonly email: EmailV2Client;
|
|
2214
2285
|
constructor(config: PerspectApiV2Config);
|
|
2215
2286
|
/** Update the JWT token for authenticated requests. */
|
|
2216
2287
|
setAuth(jwt: string): void;
|
|
@@ -2221,4 +2292,4 @@ declare class PerspectApiV2Client {
|
|
|
2221
2292
|
}
|
|
2222
2293
|
declare function createPerspectApiV2Client(config: PerspectApiConfig): PerspectApiV2Client;
|
|
2223
2294
|
|
|
2224
|
-
export { type NewsletterManagementList as $, type ApiResponse as A, type CreateNewsletterSubscriptionRequest as B, CacheManager as C, type NewsletterConfirmResponse as D, type NewsletterUnsubscribeRequest as E, type NewsletterUnsubscribeResponse as F, type NewsletterPreferences as G, HttpClient as H, type NewsletterList as I, type NewsletterCampaignListResponse as J, type NewsletterCampaignDetail as K, type NewsletterStatusResponse as L, type NewsletterManagementSubscriptionsListResponse as M, type NewsletterSubscribeResponse as N, type Organization as O, type PaginatedResponse as P, type NewsletterManagementSubscription as Q, type NewsletterSubscriptionSyncRequest as R, type Site as S, type NewsletterSubscriptionSyncResponse as T, type User as U, type NewsletterSubscriptionsBulkUpdateRequest as V, type Webhook as W, type NewsletterSubscriptionsBulkUpdateResponse as X, type NewsletterSubscriptionMembershipUpdateRequest as Y, type NewsletterSubscriptionsImportRequest as Z, type NewsletterSubscriptionsImportResponse as _, type CachePolicy as a, type V2ContentListParams as a$, type NewsletterManagementSeries as a0, type NewsletterManagementCampaignListResponse as a1, type NewsletterManagementCampaign as a2, type NewsletterCampaignTestSendRequest as a3, type NewsletterCampaignTestSendResponse as a4, type NewsletterManagementStatsResponse as a5, type NewsletterExportCreateRequest as a6, type NewsletterExportCreateResponse as a7, type RequestOtpRequest as a8, type VerifyOtpRequest as a9, PerspectV2Error as aA, createApiError as aB, PerspectApiError as aC, type CacheConfig as aD, type ApiError as aE, type MediaItem as aF, type CategorySummary as aG, type PaymentGateway as aH, type NewsletterSubscription as aI, type NewsletterCampaignSummary as aJ, type NewsletterManagementListMembership as aK, type NewsletterSubscriptionsBulkAction as aL, type NewsletterSubscriptionsBulkOutcome as aM, type NewsletterSubscriptionImportRowRequest as aN, type NewsletterSubscriptionsImportRowResult as aO, type NewsletterManagementPagination as aP, type SetProfileValueRequest as aQ, type V2Object as aR, type V2List as aS, type V2Deleted as aT, type V2Error as aU, type V2ErrorType as aV, type V2PaginationParams as aW, type V2Media as aX, type V2Content as aY, type V2ContentCreateParams as aZ, type V2ContentUpdateParams as a_, type VerifyOtpResponse as aa, type SiteUser as ab, type SiteUserProfile as ac, type UpdateSiteUserRequest as ad, type SiteUserOrder as ae, type SiteUserSubscription as af, type CancelSubscriptionRequest as ag, type CancelSubscriptionResponse as ah, type CreditBalance as ai, type CreditBalanceWithTransactions as aj, type GrantCreditRequest as ak, type ProductBundleGroup as al, type CreateBundleGroupRequest as am, type BundleCollection as an, type BundleCollectionItemWithProduct as ao, type CreateBundleCollectionRequest as ap, type AddCollectionItemRequest as aq, type BundleCollectionItem as ar, type PerspectApiConfig as as, type CacheAdapter as at, type BlogPost as au, type CheckoutMetadata as av, type CheckoutAddress as aw, type CheckoutTaxRequest as ax, PerspectApiV2Client as ay, createPerspectApiV2Client as az, type CacheInvalidateOptions as b, type
|
|
2295
|
+
export { type NewsletterManagementList as $, type ApiResponse as A, type CreateNewsletterSubscriptionRequest as B, CacheManager as C, type NewsletterConfirmResponse as D, type NewsletterUnsubscribeRequest as E, type NewsletterUnsubscribeResponse as F, type NewsletterPreferences as G, HttpClient as H, type NewsletterList as I, type NewsletterCampaignListResponse as J, type NewsletterCampaignDetail as K, type NewsletterStatusResponse as L, type NewsletterManagementSubscriptionsListResponse as M, type NewsletterSubscribeResponse as N, type Organization as O, type PaginatedResponse as P, type NewsletterManagementSubscription as Q, type NewsletterSubscriptionSyncRequest as R, type Site as S, type NewsletterSubscriptionSyncResponse as T, type User as U, type NewsletterSubscriptionsBulkUpdateRequest as V, type Webhook as W, type NewsletterSubscriptionsBulkUpdateResponse as X, type NewsletterSubscriptionMembershipUpdateRequest as Y, type NewsletterSubscriptionsImportRequest as Z, type NewsletterSubscriptionsImportResponse as _, type CachePolicy as a, type V2ContentListParams as a$, type NewsletterManagementSeries as a0, type NewsletterManagementCampaignListResponse as a1, type NewsletterManagementCampaign as a2, type NewsletterCampaignTestSendRequest as a3, type NewsletterCampaignTestSendResponse as a4, type NewsletterManagementStatsResponse as a5, type NewsletterExportCreateRequest as a6, type NewsletterExportCreateResponse as a7, type RequestOtpRequest as a8, type VerifyOtpRequest as a9, PerspectV2Error as aA, createApiError as aB, PerspectApiError as aC, type CacheConfig as aD, type ApiError as aE, type MediaItem as aF, type CategorySummary as aG, type PaymentGateway as aH, type NewsletterSubscription as aI, type NewsletterCampaignSummary as aJ, type NewsletterManagementListMembership as aK, type NewsletterSubscriptionsBulkAction as aL, type NewsletterSubscriptionsBulkOutcome as aM, type NewsletterSubscriptionImportRowRequest as aN, type NewsletterSubscriptionsImportRowResult as aO, type NewsletterManagementPagination as aP, type SetProfileValueRequest as aQ, type V2Object as aR, type V2List as aS, type V2Deleted as aT, type V2Error as aU, type V2ErrorType as aV, type V2PaginationParams as aW, type V2Media as aX, type V2Content as aY, type V2ContentCreateParams as aZ, type V2ContentUpdateParams as a_, type VerifyOtpResponse as aa, type SiteUser as ab, type SiteUserProfile as ac, type UpdateSiteUserRequest as ad, type SiteUserOrder as ae, type SiteUserSubscription as af, type CancelSubscriptionRequest as ag, type CancelSubscriptionResponse as ah, type CreditBalance as ai, type CreditBalanceWithTransactions as aj, type GrantCreditRequest as ak, type ProductBundleGroup as al, type CreateBundleGroupRequest as am, type BundleCollection as an, type BundleCollectionItemWithProduct as ao, type CreateBundleCollectionRequest as ap, type AddCollectionItemRequest as aq, type BundleCollectionItem as ar, type PerspectApiConfig as as, type CacheAdapter as at, type BlogPost as au, type CheckoutMetadata as av, type CheckoutAddress as aw, type CheckoutTaxRequest as ax, PerspectApiV2Client as ay, createPerspectApiV2Client as az, type CacheInvalidateOptions as b, type ContentType as b$, type V2Product as b0, type V2ProductCreateParams as b1, type V2ProductUpdateParams as b2, type V2ProductListParams as b3, type V2Category as b4, type V2CategoryCreateParams as b5, type V2CategoryUpdateParams as b6, type V2Collection as b7, type V2CollectionItem as b8, type V2CollectionCreateParams as b9, type V2NewsletterSyncResult as bA, type V2NewsletterSubscriptionListMembershipUpdate as bB, type V2NewsletterImportRequest as bC, type V2NewsletterImportResult as bD, type V2ContactSubmission as bE, type V2Organization as bF, type V2Site as bG, type V2ApiKey as bH, type V2WebhookEventType as bI, type V2Webhook as bJ, type V2WebhookCreateParams as bK, type V2WebhookUpdateParams as bL, type V2SiteUserSubscription as bM, type V2SubscriptionPauseParams as bN, type V2SubscriptionCancelParams as bO, type V2SubscriptionChangePlanParams as bP, type V2SubscriptionChargeParams as bQ, type V2SubscriptionChargeResult as bR, type V2CancelSubscriptionResult as bS, type V2CreditTransaction as bT, type V2CreditBalance as bU, type V2GrantCreditParams as bV, type V2GrantCreditResult as bW, type V2EmailSendParams as bX, type V2EmailSendResult as bY, type PaginationParams as bZ, type ContentStatus as b_, type V2CollectionUpdateParams as ba, type V2Order as bb, type V2OrderListParams as bc, type V2OrderLineItemPriceData as bd, type V2OrderLineItem as be, type V2OrderAddress as bf, type V2OrderTaxRequest as bg, type V2OrderCreateParams as bh, type V2OrderFulfillmentUpdate as bi, type V2OrderFulfillmentNotificationLineItem as bj, type V2OrderFulfillmentNotificationParams as bk, type V2OrderFulfillmentNotificationResult as bl, type V2OrderCreateResult as bm, type V2SiteUser as bn, type V2SiteUserUpdateParams as bo, type V2SiteUserMeUpdateParams as bp, type V2SiteUserListParams as bq, type V2SiteUserWithProfile as br, type V2SiteUserProfile as bs, type V2NewsletterSubscription as bt, type V2NewsletterList as bu, type V2NewsletterCampaign as bv, type V2NewsletterTrackingResponse as bw, type V2NewsletterListCreateParams as bx, type V2NewsletterListUpdateParams as by, type V2NewsletterSyncInput as bz, type ContentQueryParams as c, type ProductSkuMediaItem as c0, type ProductSkuOption as c1, type CreatePaymentGatewayRequest as c2, type WebhookEventType as c3, type CheckoutMetadataValue as c4, type CheckoutTaxStrategy as c5, type CheckoutTaxExemptionStatus as c6, type CheckoutTaxCustomerExemptionRequest as c7, type CheckoutTaxBreakdownItem as c8, type CheckoutSessionTax as c9, type SubscriptionCancellationMode as ca, type CreditTransaction as cb, type HttpMethod as cc, type RequestOptions as cd, type PerspectApiV2Config as ce, BaseV2Client as cf, ContentV2Client as cg, ProductsV2Client as ch, CategoriesV2Client as ci, CollectionsV2Client as cj, OrdersV2Client as ck, SiteUsersV2Client as cl, NewsletterV2Client as cm, ContactsV2Client as cn, OrganizationsV2Client as co, SitesV2Client as cp, ApiKeysV2Client as cq, WebhooksV2Client as cr, SubscriptionsV2Client as cs, CreditsV2Client as ct, EmailV2Client as cu, type Content as d, type ContentCategoryResponse as e, type CreateContentRequest as f, type UpdateContentRequest as g, type ApiKey as h, type CreateApiKeyRequest as i, type UpdateApiKeyRequest as j, type CreateOrganizationRequest as k, type CreateSiteRequest as l, type ProductQueryParams as m, type Product as n, type CreateProductRequest as o, type ProductSku as p, type CreateProductSkuRequest as q, type Category as r, type CreateCategoryRequest as s, type CreateWebhookRequest as t, type CreateCheckoutSessionRequest as u, type CheckoutSession as v, type CreateContactRequest as w, type ContactSubmitResponse as x, type ContactStatusResponse as y, type ContactSubmission as z };
|
|
@@ -1462,9 +1462,40 @@ interface V2OrderFulfillmentUpdate {
|
|
|
1462
1462
|
fulfillment_status: string;
|
|
1463
1463
|
tracking_number?: string;
|
|
1464
1464
|
notes?: string;
|
|
1465
|
+
fulfillment_details_text?: string;
|
|
1466
|
+
fulfillment_details_html?: string;
|
|
1465
1467
|
/** When true, a terminal fulfillment status triggers a customer email. */
|
|
1466
1468
|
notify_customer?: boolean;
|
|
1467
1469
|
}
|
|
1470
|
+
interface V2OrderFulfillmentNotificationLineItem {
|
|
1471
|
+
quantity: number;
|
|
1472
|
+
description: string;
|
|
1473
|
+
amount_total?: number;
|
|
1474
|
+
currency?: string;
|
|
1475
|
+
}
|
|
1476
|
+
interface V2OrderFulfillmentNotificationParams {
|
|
1477
|
+
session_id?: string;
|
|
1478
|
+
order_id?: string;
|
|
1479
|
+
customer_email: string;
|
|
1480
|
+
customer_name?: string;
|
|
1481
|
+
fulfillment_status?: string;
|
|
1482
|
+
fulfillment_details_text?: string;
|
|
1483
|
+
fulfillment_details_html?: string;
|
|
1484
|
+
line_items?: V2OrderFulfillmentNotificationLineItem[];
|
|
1485
|
+
amount_total?: number;
|
|
1486
|
+
currency?: string;
|
|
1487
|
+
shipping_details?: Record<string, unknown>;
|
|
1488
|
+
customer_details?: Record<string, unknown>;
|
|
1489
|
+
metadata?: Record<string, unknown>;
|
|
1490
|
+
created_at?: string;
|
|
1491
|
+
}
|
|
1492
|
+
interface V2OrderFulfillmentNotificationResult extends V2Object {
|
|
1493
|
+
object: "fulfillment_notification";
|
|
1494
|
+
order_id: string;
|
|
1495
|
+
notified: boolean;
|
|
1496
|
+
queued: boolean;
|
|
1497
|
+
reason?: string;
|
|
1498
|
+
}
|
|
1468
1499
|
interface V2OrderCreateResult extends V2Object {
|
|
1469
1500
|
object: "checkout_session";
|
|
1470
1501
|
checkout_url: string | null;
|
|
@@ -1802,6 +1833,22 @@ interface V2GrantCreditResult {
|
|
|
1802
1833
|
object: "grant_credit_result";
|
|
1803
1834
|
new_balance_cents: number;
|
|
1804
1835
|
}
|
|
1836
|
+
interface V2EmailSendParams {
|
|
1837
|
+
to: string | string[];
|
|
1838
|
+
subject: string;
|
|
1839
|
+
html?: string;
|
|
1840
|
+
text?: string;
|
|
1841
|
+
from?: string;
|
|
1842
|
+
reply_to?: string;
|
|
1843
|
+
cc?: string | string[];
|
|
1844
|
+
bcc?: string | string[];
|
|
1845
|
+
}
|
|
1846
|
+
interface V2EmailSendResult {
|
|
1847
|
+
object: "email";
|
|
1848
|
+
id: string | null;
|
|
1849
|
+
status: "sent";
|
|
1850
|
+
to: string | string[];
|
|
1851
|
+
}
|
|
1805
1852
|
|
|
1806
1853
|
/**
|
|
1807
1854
|
* v2 Base Client — cursor pagination, expand support, caching, typed errors.
|
|
@@ -1941,7 +1988,7 @@ declare class CollectionsV2Client extends BaseV2Client {
|
|
|
1941
1988
|
|
|
1942
1989
|
declare class OrdersV2Client extends BaseV2Client {
|
|
1943
1990
|
list(siteName: string, params?: V2OrderListParams, cachePolicy?: CachePolicy): Promise<V2List<V2Order>>;
|
|
1944
|
-
listAutoPaginated(siteName: string, params?: Omit<V2OrderListParams, 'starting_after' | 'ending_before'
|
|
1991
|
+
listAutoPaginated(siteName: string, params?: Omit<V2OrderListParams, 'starting_after' | 'ending_before'>, cachePolicy?: CachePolicy): AsyncGenerator<V2Order, void, unknown>;
|
|
1945
1992
|
get(siteName: string, id: string, cachePolicy?: CachePolicy): Promise<V2Order>;
|
|
1946
1993
|
/**
|
|
1947
1994
|
* Create a checkout session via Stripe. Returns the session ID and a
|
|
@@ -1958,6 +2005,14 @@ declare class OrdersV2Client extends BaseV2Client {
|
|
|
1958
2005
|
* fulfillment state to send the customer fulfillment email.
|
|
1959
2006
|
*/
|
|
1960
2007
|
updateFulfillment(siteName: string, id: string, data: V2OrderFulfillmentUpdate): Promise<V2Order>;
|
|
2008
|
+
/**
|
|
2009
|
+
* Send the customer fulfillment template for an external delivery/packing
|
|
2010
|
+
* record without mutating a checkout session.
|
|
2011
|
+
*/
|
|
2012
|
+
sendFulfillmentNotification(siteName: string, data: V2OrderFulfillmentNotificationParams): Promise<V2OrderFulfillmentNotificationResult>;
|
|
2013
|
+
private withOrderTags;
|
|
2014
|
+
private buildOrderTags;
|
|
2015
|
+
private normalizeTagPart;
|
|
1961
2016
|
}
|
|
1962
2017
|
|
|
1963
2018
|
/**
|
|
@@ -2179,6 +2234,21 @@ declare class CreditsV2Client extends BaseV2Client {
|
|
|
2179
2234
|
grantCredit(siteName: string, userId: string, data: V2GrantCreditParams): Promise<V2GrantCreditResult>;
|
|
2180
2235
|
}
|
|
2181
2236
|
|
|
2237
|
+
/**
|
|
2238
|
+
* v2 Email Client — send transactional email through a site's configured provider.
|
|
2239
|
+
*/
|
|
2240
|
+
|
|
2241
|
+
declare class EmailV2Client extends BaseV2Client {
|
|
2242
|
+
/**
|
|
2243
|
+
* Send a transactional email using the site's configured email provider.
|
|
2244
|
+
*
|
|
2245
|
+
* Requires a server-side API key — never call this from a browser.
|
|
2246
|
+
* The site must have an email provider configured in its settings.
|
|
2247
|
+
* At least one of `html` or `text` must be provided.
|
|
2248
|
+
*/
|
|
2249
|
+
send(siteName: string, params: V2EmailSendParams): Promise<V2EmailSendResult>;
|
|
2250
|
+
}
|
|
2251
|
+
|
|
2182
2252
|
/**
|
|
2183
2253
|
* PerspectAPI v2 SDK Client
|
|
2184
2254
|
*
|
|
@@ -2211,6 +2281,7 @@ declare class PerspectApiV2Client {
|
|
|
2211
2281
|
readonly webhooks: WebhooksV2Client;
|
|
2212
2282
|
readonly subscriptions: SubscriptionsV2Client;
|
|
2213
2283
|
readonly credits: CreditsV2Client;
|
|
2284
|
+
readonly email: EmailV2Client;
|
|
2214
2285
|
constructor(config: PerspectApiV2Config);
|
|
2215
2286
|
/** Update the JWT token for authenticated requests. */
|
|
2216
2287
|
setAuth(jwt: string): void;
|
|
@@ -2221,4 +2292,4 @@ declare class PerspectApiV2Client {
|
|
|
2221
2292
|
}
|
|
2222
2293
|
declare function createPerspectApiV2Client(config: PerspectApiConfig): PerspectApiV2Client;
|
|
2223
2294
|
|
|
2224
|
-
export { type NewsletterManagementList as $, type ApiResponse as A, type CreateNewsletterSubscriptionRequest as B, CacheManager as C, type NewsletterConfirmResponse as D, type NewsletterUnsubscribeRequest as E, type NewsletterUnsubscribeResponse as F, type NewsletterPreferences as G, HttpClient as H, type NewsletterList as I, type NewsletterCampaignListResponse as J, type NewsletterCampaignDetail as K, type NewsletterStatusResponse as L, type NewsletterManagementSubscriptionsListResponse as M, type NewsletterSubscribeResponse as N, type Organization as O, type PaginatedResponse as P, type NewsletterManagementSubscription as Q, type NewsletterSubscriptionSyncRequest as R, type Site as S, type NewsletterSubscriptionSyncResponse as T, type User as U, type NewsletterSubscriptionsBulkUpdateRequest as V, type Webhook as W, type NewsletterSubscriptionsBulkUpdateResponse as X, type NewsletterSubscriptionMembershipUpdateRequest as Y, type NewsletterSubscriptionsImportRequest as Z, type NewsletterSubscriptionsImportResponse as _, type CachePolicy as a, type V2ContentListParams as a$, type NewsletterManagementSeries as a0, type NewsletterManagementCampaignListResponse as a1, type NewsletterManagementCampaign as a2, type NewsletterCampaignTestSendRequest as a3, type NewsletterCampaignTestSendResponse as a4, type NewsletterManagementStatsResponse as a5, type NewsletterExportCreateRequest as a6, type NewsletterExportCreateResponse as a7, type RequestOtpRequest as a8, type VerifyOtpRequest as a9, PerspectV2Error as aA, createApiError as aB, PerspectApiError as aC, type CacheConfig as aD, type ApiError as aE, type MediaItem as aF, type CategorySummary as aG, type PaymentGateway as aH, type NewsletterSubscription as aI, type NewsletterCampaignSummary as aJ, type NewsletterManagementListMembership as aK, type NewsletterSubscriptionsBulkAction as aL, type NewsletterSubscriptionsBulkOutcome as aM, type NewsletterSubscriptionImportRowRequest as aN, type NewsletterSubscriptionsImportRowResult as aO, type NewsletterManagementPagination as aP, type SetProfileValueRequest as aQ, type V2Object as aR, type V2List as aS, type V2Deleted as aT, type V2Error as aU, type V2ErrorType as aV, type V2PaginationParams as aW, type V2Media as aX, type V2Content as aY, type V2ContentCreateParams as aZ, type V2ContentUpdateParams as a_, type VerifyOtpResponse as aa, type SiteUser as ab, type SiteUserProfile as ac, type UpdateSiteUserRequest as ad, type SiteUserOrder as ae, type SiteUserSubscription as af, type CancelSubscriptionRequest as ag, type CancelSubscriptionResponse as ah, type CreditBalance as ai, type CreditBalanceWithTransactions as aj, type GrantCreditRequest as ak, type ProductBundleGroup as al, type CreateBundleGroupRequest as am, type BundleCollection as an, type BundleCollectionItemWithProduct as ao, type CreateBundleCollectionRequest as ap, type AddCollectionItemRequest as aq, type BundleCollectionItem as ar, type PerspectApiConfig as as, type CacheAdapter as at, type BlogPost as au, type CheckoutMetadata as av, type CheckoutAddress as aw, type CheckoutTaxRequest as ax, PerspectApiV2Client as ay, createPerspectApiV2Client as az, type CacheInvalidateOptions as b, type
|
|
2295
|
+
export { type NewsletterManagementList as $, type ApiResponse as A, type CreateNewsletterSubscriptionRequest as B, CacheManager as C, type NewsletterConfirmResponse as D, type NewsletterUnsubscribeRequest as E, type NewsletterUnsubscribeResponse as F, type NewsletterPreferences as G, HttpClient as H, type NewsletterList as I, type NewsletterCampaignListResponse as J, type NewsletterCampaignDetail as K, type NewsletterStatusResponse as L, type NewsletterManagementSubscriptionsListResponse as M, type NewsletterSubscribeResponse as N, type Organization as O, type PaginatedResponse as P, type NewsletterManagementSubscription as Q, type NewsletterSubscriptionSyncRequest as R, type Site as S, type NewsletterSubscriptionSyncResponse as T, type User as U, type NewsletterSubscriptionsBulkUpdateRequest as V, type Webhook as W, type NewsletterSubscriptionsBulkUpdateResponse as X, type NewsletterSubscriptionMembershipUpdateRequest as Y, type NewsletterSubscriptionsImportRequest as Z, type NewsletterSubscriptionsImportResponse as _, type CachePolicy as a, type V2ContentListParams as a$, type NewsletterManagementSeries as a0, type NewsletterManagementCampaignListResponse as a1, type NewsletterManagementCampaign as a2, type NewsletterCampaignTestSendRequest as a3, type NewsletterCampaignTestSendResponse as a4, type NewsletterManagementStatsResponse as a5, type NewsletterExportCreateRequest as a6, type NewsletterExportCreateResponse as a7, type RequestOtpRequest as a8, type VerifyOtpRequest as a9, PerspectV2Error as aA, createApiError as aB, PerspectApiError as aC, type CacheConfig as aD, type ApiError as aE, type MediaItem as aF, type CategorySummary as aG, type PaymentGateway as aH, type NewsletterSubscription as aI, type NewsletterCampaignSummary as aJ, type NewsletterManagementListMembership as aK, type NewsletterSubscriptionsBulkAction as aL, type NewsletterSubscriptionsBulkOutcome as aM, type NewsletterSubscriptionImportRowRequest as aN, type NewsletterSubscriptionsImportRowResult as aO, type NewsletterManagementPagination as aP, type SetProfileValueRequest as aQ, type V2Object as aR, type V2List as aS, type V2Deleted as aT, type V2Error as aU, type V2ErrorType as aV, type V2PaginationParams as aW, type V2Media as aX, type V2Content as aY, type V2ContentCreateParams as aZ, type V2ContentUpdateParams as a_, type VerifyOtpResponse as aa, type SiteUser as ab, type SiteUserProfile as ac, type UpdateSiteUserRequest as ad, type SiteUserOrder as ae, type SiteUserSubscription as af, type CancelSubscriptionRequest as ag, type CancelSubscriptionResponse as ah, type CreditBalance as ai, type CreditBalanceWithTransactions as aj, type GrantCreditRequest as ak, type ProductBundleGroup as al, type CreateBundleGroupRequest as am, type BundleCollection as an, type BundleCollectionItemWithProduct as ao, type CreateBundleCollectionRequest as ap, type AddCollectionItemRequest as aq, type BundleCollectionItem as ar, type PerspectApiConfig as as, type CacheAdapter as at, type BlogPost as au, type CheckoutMetadata as av, type CheckoutAddress as aw, type CheckoutTaxRequest as ax, PerspectApiV2Client as ay, createPerspectApiV2Client as az, type CacheInvalidateOptions as b, type ContentType as b$, type V2Product as b0, type V2ProductCreateParams as b1, type V2ProductUpdateParams as b2, type V2ProductListParams as b3, type V2Category as b4, type V2CategoryCreateParams as b5, type V2CategoryUpdateParams as b6, type V2Collection as b7, type V2CollectionItem as b8, type V2CollectionCreateParams as b9, type V2NewsletterSyncResult as bA, type V2NewsletterSubscriptionListMembershipUpdate as bB, type V2NewsletterImportRequest as bC, type V2NewsletterImportResult as bD, type V2ContactSubmission as bE, type V2Organization as bF, type V2Site as bG, type V2ApiKey as bH, type V2WebhookEventType as bI, type V2Webhook as bJ, type V2WebhookCreateParams as bK, type V2WebhookUpdateParams as bL, type V2SiteUserSubscription as bM, type V2SubscriptionPauseParams as bN, type V2SubscriptionCancelParams as bO, type V2SubscriptionChangePlanParams as bP, type V2SubscriptionChargeParams as bQ, type V2SubscriptionChargeResult as bR, type V2CancelSubscriptionResult as bS, type V2CreditTransaction as bT, type V2CreditBalance as bU, type V2GrantCreditParams as bV, type V2GrantCreditResult as bW, type V2EmailSendParams as bX, type V2EmailSendResult as bY, type PaginationParams as bZ, type ContentStatus as b_, type V2CollectionUpdateParams as ba, type V2Order as bb, type V2OrderListParams as bc, type V2OrderLineItemPriceData as bd, type V2OrderLineItem as be, type V2OrderAddress as bf, type V2OrderTaxRequest as bg, type V2OrderCreateParams as bh, type V2OrderFulfillmentUpdate as bi, type V2OrderFulfillmentNotificationLineItem as bj, type V2OrderFulfillmentNotificationParams as bk, type V2OrderFulfillmentNotificationResult as bl, type V2OrderCreateResult as bm, type V2SiteUser as bn, type V2SiteUserUpdateParams as bo, type V2SiteUserMeUpdateParams as bp, type V2SiteUserListParams as bq, type V2SiteUserWithProfile as br, type V2SiteUserProfile as bs, type V2NewsletterSubscription as bt, type V2NewsletterList as bu, type V2NewsletterCampaign as bv, type V2NewsletterTrackingResponse as bw, type V2NewsletterListCreateParams as bx, type V2NewsletterListUpdateParams as by, type V2NewsletterSyncInput as bz, type ContentQueryParams as c, type ProductSkuMediaItem as c0, type ProductSkuOption as c1, type CreatePaymentGatewayRequest as c2, type WebhookEventType as c3, type CheckoutMetadataValue as c4, type CheckoutTaxStrategy as c5, type CheckoutTaxExemptionStatus as c6, type CheckoutTaxCustomerExemptionRequest as c7, type CheckoutTaxBreakdownItem as c8, type CheckoutSessionTax as c9, type SubscriptionCancellationMode as ca, type CreditTransaction as cb, type HttpMethod as cc, type RequestOptions as cd, type PerspectApiV2Config as ce, BaseV2Client as cf, ContentV2Client as cg, ProductsV2Client as ch, CategoriesV2Client as ci, CollectionsV2Client as cj, OrdersV2Client as ck, SiteUsersV2Client as cl, NewsletterV2Client as cm, ContactsV2Client as cn, OrganizationsV2Client as co, SitesV2Client as cp, ApiKeysV2Client as cq, WebhooksV2Client as cr, SubscriptionsV2Client as cs, CreditsV2Client as ct, EmailV2Client as cu, type Content as d, type ContentCategoryResponse as e, type CreateContentRequest as f, type UpdateContentRequest as g, type ApiKey as h, type CreateApiKeyRequest as i, type UpdateApiKeyRequest as j, type CreateOrganizationRequest as k, type CreateSiteRequest as l, type ProductQueryParams as m, type Product as n, type CreateProductRequest as o, type ProductSku as p, type CreateProductSkuRequest as q, type Category as r, type CreateCategoryRequest as s, type CreateWebhookRequest as t, type CreateCheckoutSessionRequest as u, type CheckoutSession as v, type CreateContactRequest as w, type ContactSubmitResponse as x, type ContactStatusResponse as y, type ContactSubmission as z };
|
package/dist/index.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { H as HttpClient, C as CacheManager, A as ApiResponse, a as CachePolicy, b as CacheInvalidateOptions, U as User, c as ContentQueryParams, P as PaginatedResponse, d as Content, e as ContentCategoryResponse, f as CreateContentRequest, g as UpdateContentRequest, h as ApiKey, i as CreateApiKeyRequest, j as UpdateApiKeyRequest, O as Organization, k as CreateOrganizationRequest, S as Site, l as CreateSiteRequest, m as ProductQueryParams, n as Product, o as CreateProductRequest, p as ProductSku, q as CreateProductSkuRequest, r as Category, s as CreateCategoryRequest, W as Webhook, t as CreateWebhookRequest, u as CreateCheckoutSessionRequest, v as CheckoutSession, w as CreateContactRequest, x as ContactSubmitResponse, y as ContactStatusResponse, z as ContactSubmission, B as CreateNewsletterSubscriptionRequest, N as NewsletterSubscribeResponse, D as NewsletterConfirmResponse, E as NewsletterUnsubscribeRequest, F as NewsletterUnsubscribeResponse, G as NewsletterPreferences, I as NewsletterList, J as NewsletterCampaignListResponse, K as NewsletterCampaignDetail, L as NewsletterStatusResponse, M as NewsletterManagementSubscriptionsListResponse, Q as NewsletterManagementSubscription, R as NewsletterSubscriptionSyncRequest, T as NewsletterSubscriptionSyncResponse, V as NewsletterSubscriptionsBulkUpdateRequest, X as NewsletterSubscriptionsBulkUpdateResponse, Y as NewsletterSubscriptionMembershipUpdateRequest, Z as NewsletterSubscriptionsImportRequest, _ as NewsletterSubscriptionsImportResponse, $ as NewsletterManagementList, a0 as NewsletterManagementSeries, a1 as NewsletterManagementCampaignListResponse, a2 as NewsletterManagementCampaign, a3 as NewsletterCampaignTestSendRequest, a4 as NewsletterCampaignTestSendResponse, a5 as NewsletterManagementStatsResponse, a6 as NewsletterExportCreateRequest, a7 as NewsletterExportCreateResponse, a8 as RequestOtpRequest, a9 as VerifyOtpRequest, aa as VerifyOtpResponse, ab as SiteUser, ac as SiteUserProfile, ad as UpdateSiteUserRequest, ae as SiteUserOrder, af as SiteUserSubscription, ag as CancelSubscriptionRequest, ah as CancelSubscriptionResponse, ai as CreditBalance, aj as CreditBalanceWithTransactions, ak as GrantCreditRequest, al as ProductBundleGroup, am as CreateBundleGroupRequest, an as BundleCollection, ao as BundleCollectionItemWithProduct, ap as CreateBundleCollectionRequest, aq as AddCollectionItemRequest, ar as BundleCollectionItem, as as PerspectApiConfig, at as CacheAdapter, au as BlogPost, av as CheckoutMetadata, aw as CheckoutAddress, ax as CheckoutTaxRequest } from './index-
|
|
2
|
-
export { aE as ApiError, aD as CacheConfig, aG as CategorySummary,
|
|
1
|
+
import { H as HttpClient, C as CacheManager, A as ApiResponse, a as CachePolicy, b as CacheInvalidateOptions, U as User, c as ContentQueryParams, P as PaginatedResponse, d as Content, e as ContentCategoryResponse, f as CreateContentRequest, g as UpdateContentRequest, h as ApiKey, i as CreateApiKeyRequest, j as UpdateApiKeyRequest, O as Organization, k as CreateOrganizationRequest, S as Site, l as CreateSiteRequest, m as ProductQueryParams, n as Product, o as CreateProductRequest, p as ProductSku, q as CreateProductSkuRequest, r as Category, s as CreateCategoryRequest, W as Webhook, t as CreateWebhookRequest, u as CreateCheckoutSessionRequest, v as CheckoutSession, w as CreateContactRequest, x as ContactSubmitResponse, y as ContactStatusResponse, z as ContactSubmission, B as CreateNewsletterSubscriptionRequest, N as NewsletterSubscribeResponse, D as NewsletterConfirmResponse, E as NewsletterUnsubscribeRequest, F as NewsletterUnsubscribeResponse, G as NewsletterPreferences, I as NewsletterList, J as NewsletterCampaignListResponse, K as NewsletterCampaignDetail, L as NewsletterStatusResponse, M as NewsletterManagementSubscriptionsListResponse, Q as NewsletterManagementSubscription, R as NewsletterSubscriptionSyncRequest, T as NewsletterSubscriptionSyncResponse, V as NewsletterSubscriptionsBulkUpdateRequest, X as NewsletterSubscriptionsBulkUpdateResponse, Y as NewsletterSubscriptionMembershipUpdateRequest, Z as NewsletterSubscriptionsImportRequest, _ as NewsletterSubscriptionsImportResponse, $ as NewsletterManagementList, a0 as NewsletterManagementSeries, a1 as NewsletterManagementCampaignListResponse, a2 as NewsletterManagementCampaign, a3 as NewsletterCampaignTestSendRequest, a4 as NewsletterCampaignTestSendResponse, a5 as NewsletterManagementStatsResponse, a6 as NewsletterExportCreateRequest, a7 as NewsletterExportCreateResponse, a8 as RequestOtpRequest, a9 as VerifyOtpRequest, aa as VerifyOtpResponse, ab as SiteUser, ac as SiteUserProfile, ad as UpdateSiteUserRequest, ae as SiteUserOrder, af as SiteUserSubscription, ag as CancelSubscriptionRequest, ah as CancelSubscriptionResponse, ai as CreditBalance, aj as CreditBalanceWithTransactions, ak as GrantCreditRequest, al as ProductBundleGroup, am as CreateBundleGroupRequest, an as BundleCollection, ao as BundleCollectionItemWithProduct, ap as CreateBundleCollectionRequest, aq as AddCollectionItemRequest, ar as BundleCollectionItem, as as PerspectApiConfig, at as CacheAdapter, au as BlogPost, av as CheckoutMetadata, aw as CheckoutAddress, ax as CheckoutTaxRequest } from './index-DuNDHod-.mjs';
|
|
2
|
+
export { aE as ApiError, aD as CacheConfig, aG as CategorySummary, c4 as CheckoutMetadataValue, c9 as CheckoutSessionTax, c8 as CheckoutTaxBreakdownItem, c7 as CheckoutTaxCustomerExemptionRequest, c6 as CheckoutTaxExemptionStatus, c5 as CheckoutTaxStrategy, b_ as ContentStatus, b$ as ContentType, c2 as CreatePaymentGatewayRequest, cb as CreditTransaction, cc as HttpMethod, aF as MediaItem, aJ as NewsletterCampaignSummary, aK as NewsletterManagementListMembership, aP as NewsletterManagementPagination, aI as NewsletterSubscription, aN as NewsletterSubscriptionImportRowRequest, aL as NewsletterSubscriptionsBulkAction, aM as NewsletterSubscriptionsBulkOutcome, aO as NewsletterSubscriptionsImportRowResult, bZ as PaginationParams, aH as PaymentGateway, aC as PerspectApiError, ay as PerspectApiV2Client, aA as PerspectV2Error, c0 as ProductSkuMediaItem, c1 as ProductSkuOption, cd as RequestOptions, aQ as SetProfileValueRequest, ca as SubscriptionCancellationMode, bH as V2ApiKey, bS as V2CancelSubscriptionResult, b4 as V2Category, b5 as V2CategoryCreateParams, b6 as V2CategoryUpdateParams, b7 as V2Collection, b9 as V2CollectionCreateParams, b8 as V2CollectionItem, ba as V2CollectionUpdateParams, bE as V2ContactSubmission, aY as V2Content, aZ as V2ContentCreateParams, a$ as V2ContentListParams, a_ as V2ContentUpdateParams, bU as V2CreditBalance, bT as V2CreditTransaction, aT as V2Deleted, bX as V2EmailSendParams, bY as V2EmailSendResult, aU as V2Error, aV as V2ErrorType, bV as V2GrantCreditParams, bW as V2GrantCreditResult, aS as V2List, aX as V2Media, bv as V2NewsletterCampaign, bC as V2NewsletterImportRequest, bD as V2NewsletterImportResult, bu as V2NewsletterList, bx as V2NewsletterListCreateParams, by as V2NewsletterListUpdateParams, bt as V2NewsletterSubscription, bB as V2NewsletterSubscriptionListMembershipUpdate, bz as V2NewsletterSyncInput, bA as V2NewsletterSyncResult, bw as V2NewsletterTrackingResponse, aR as V2Object, bb as V2Order, bf as V2OrderAddress, bh as V2OrderCreateParams, bm as V2OrderCreateResult, bj as V2OrderFulfillmentNotificationLineItem, bk as V2OrderFulfillmentNotificationParams, bl as V2OrderFulfillmentNotificationResult, bi as V2OrderFulfillmentUpdate, be as V2OrderLineItem, bd as V2OrderLineItemPriceData, bc as V2OrderListParams, bg as V2OrderTaxRequest, bF as V2Organization, aW as V2PaginationParams, b0 as V2Product, b1 as V2ProductCreateParams, b3 as V2ProductListParams, b2 as V2ProductUpdateParams, bG as V2Site, bn as V2SiteUser, bq as V2SiteUserListParams, bp as V2SiteUserMeUpdateParams, bs as V2SiteUserProfile, bM as V2SiteUserSubscription, bo as V2SiteUserUpdateParams, br as V2SiteUserWithProfile, bO as V2SubscriptionCancelParams, bP as V2SubscriptionChangePlanParams, bQ as V2SubscriptionChargeParams, bR as V2SubscriptionChargeResult, bN as V2SubscriptionPauseParams, bJ as V2Webhook, bK as V2WebhookCreateParams, bI as V2WebhookEventType, bL as V2WebhookUpdateParams, c3 as WebhookEventType, aB as createApiError, az as createPerspectApiV2Client } from './index-DuNDHod-.mjs';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* v1 deprecation constants — kept in sync with the backend's
|
|
@@ -1775,6 +1775,8 @@ declare class SiteUsersClient extends BaseClient {
|
|
|
1775
1775
|
fulfillment_status: string;
|
|
1776
1776
|
tracking_number?: string;
|
|
1777
1777
|
notes?: string;
|
|
1778
|
+
fulfillment_details_text?: string;
|
|
1779
|
+
fulfillment_details_html?: string;
|
|
1778
1780
|
notify_customer?: boolean;
|
|
1779
1781
|
}): Promise<ApiResponse<{
|
|
1780
1782
|
success: boolean;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { H as HttpClient, C as CacheManager, A as ApiResponse, a as CachePolicy, b as CacheInvalidateOptions, U as User, c as ContentQueryParams, P as PaginatedResponse, d as Content, e as ContentCategoryResponse, f as CreateContentRequest, g as UpdateContentRequest, h as ApiKey, i as CreateApiKeyRequest, j as UpdateApiKeyRequest, O as Organization, k as CreateOrganizationRequest, S as Site, l as CreateSiteRequest, m as ProductQueryParams, n as Product, o as CreateProductRequest, p as ProductSku, q as CreateProductSkuRequest, r as Category, s as CreateCategoryRequest, W as Webhook, t as CreateWebhookRequest, u as CreateCheckoutSessionRequest, v as CheckoutSession, w as CreateContactRequest, x as ContactSubmitResponse, y as ContactStatusResponse, z as ContactSubmission, B as CreateNewsletterSubscriptionRequest, N as NewsletterSubscribeResponse, D as NewsletterConfirmResponse, E as NewsletterUnsubscribeRequest, F as NewsletterUnsubscribeResponse, G as NewsletterPreferences, I as NewsletterList, J as NewsletterCampaignListResponse, K as NewsletterCampaignDetail, L as NewsletterStatusResponse, M as NewsletterManagementSubscriptionsListResponse, Q as NewsletterManagementSubscription, R as NewsletterSubscriptionSyncRequest, T as NewsletterSubscriptionSyncResponse, V as NewsletterSubscriptionsBulkUpdateRequest, X as NewsletterSubscriptionsBulkUpdateResponse, Y as NewsletterSubscriptionMembershipUpdateRequest, Z as NewsletterSubscriptionsImportRequest, _ as NewsletterSubscriptionsImportResponse, $ as NewsletterManagementList, a0 as NewsletterManagementSeries, a1 as NewsletterManagementCampaignListResponse, a2 as NewsletterManagementCampaign, a3 as NewsletterCampaignTestSendRequest, a4 as NewsletterCampaignTestSendResponse, a5 as NewsletterManagementStatsResponse, a6 as NewsletterExportCreateRequest, a7 as NewsletterExportCreateResponse, a8 as RequestOtpRequest, a9 as VerifyOtpRequest, aa as VerifyOtpResponse, ab as SiteUser, ac as SiteUserProfile, ad as UpdateSiteUserRequest, ae as SiteUserOrder, af as SiteUserSubscription, ag as CancelSubscriptionRequest, ah as CancelSubscriptionResponse, ai as CreditBalance, aj as CreditBalanceWithTransactions, ak as GrantCreditRequest, al as ProductBundleGroup, am as CreateBundleGroupRequest, an as BundleCollection, ao as BundleCollectionItemWithProduct, ap as CreateBundleCollectionRequest, aq as AddCollectionItemRequest, ar as BundleCollectionItem, as as PerspectApiConfig, at as CacheAdapter, au as BlogPost, av as CheckoutMetadata, aw as CheckoutAddress, ax as CheckoutTaxRequest } from './index-
|
|
2
|
-
export { aE as ApiError, aD as CacheConfig, aG as CategorySummary,
|
|
1
|
+
import { H as HttpClient, C as CacheManager, A as ApiResponse, a as CachePolicy, b as CacheInvalidateOptions, U as User, c as ContentQueryParams, P as PaginatedResponse, d as Content, e as ContentCategoryResponse, f as CreateContentRequest, g as UpdateContentRequest, h as ApiKey, i as CreateApiKeyRequest, j as UpdateApiKeyRequest, O as Organization, k as CreateOrganizationRequest, S as Site, l as CreateSiteRequest, m as ProductQueryParams, n as Product, o as CreateProductRequest, p as ProductSku, q as CreateProductSkuRequest, r as Category, s as CreateCategoryRequest, W as Webhook, t as CreateWebhookRequest, u as CreateCheckoutSessionRequest, v as CheckoutSession, w as CreateContactRequest, x as ContactSubmitResponse, y as ContactStatusResponse, z as ContactSubmission, B as CreateNewsletterSubscriptionRequest, N as NewsletterSubscribeResponse, D as NewsletterConfirmResponse, E as NewsletterUnsubscribeRequest, F as NewsletterUnsubscribeResponse, G as NewsletterPreferences, I as NewsletterList, J as NewsletterCampaignListResponse, K as NewsletterCampaignDetail, L as NewsletterStatusResponse, M as NewsletterManagementSubscriptionsListResponse, Q as NewsletterManagementSubscription, R as NewsletterSubscriptionSyncRequest, T as NewsletterSubscriptionSyncResponse, V as NewsletterSubscriptionsBulkUpdateRequest, X as NewsletterSubscriptionsBulkUpdateResponse, Y as NewsletterSubscriptionMembershipUpdateRequest, Z as NewsletterSubscriptionsImportRequest, _ as NewsletterSubscriptionsImportResponse, $ as NewsletterManagementList, a0 as NewsletterManagementSeries, a1 as NewsletterManagementCampaignListResponse, a2 as NewsletterManagementCampaign, a3 as NewsletterCampaignTestSendRequest, a4 as NewsletterCampaignTestSendResponse, a5 as NewsletterManagementStatsResponse, a6 as NewsletterExportCreateRequest, a7 as NewsletterExportCreateResponse, a8 as RequestOtpRequest, a9 as VerifyOtpRequest, aa as VerifyOtpResponse, ab as SiteUser, ac as SiteUserProfile, ad as UpdateSiteUserRequest, ae as SiteUserOrder, af as SiteUserSubscription, ag as CancelSubscriptionRequest, ah as CancelSubscriptionResponse, ai as CreditBalance, aj as CreditBalanceWithTransactions, ak as GrantCreditRequest, al as ProductBundleGroup, am as CreateBundleGroupRequest, an as BundleCollection, ao as BundleCollectionItemWithProduct, ap as CreateBundleCollectionRequest, aq as AddCollectionItemRequest, ar as BundleCollectionItem, as as PerspectApiConfig, at as CacheAdapter, au as BlogPost, av as CheckoutMetadata, aw as CheckoutAddress, ax as CheckoutTaxRequest } from './index-DuNDHod-.js';
|
|
2
|
+
export { aE as ApiError, aD as CacheConfig, aG as CategorySummary, c4 as CheckoutMetadataValue, c9 as CheckoutSessionTax, c8 as CheckoutTaxBreakdownItem, c7 as CheckoutTaxCustomerExemptionRequest, c6 as CheckoutTaxExemptionStatus, c5 as CheckoutTaxStrategy, b_ as ContentStatus, b$ as ContentType, c2 as CreatePaymentGatewayRequest, cb as CreditTransaction, cc as HttpMethod, aF as MediaItem, aJ as NewsletterCampaignSummary, aK as NewsletterManagementListMembership, aP as NewsletterManagementPagination, aI as NewsletterSubscription, aN as NewsletterSubscriptionImportRowRequest, aL as NewsletterSubscriptionsBulkAction, aM as NewsletterSubscriptionsBulkOutcome, aO as NewsletterSubscriptionsImportRowResult, bZ as PaginationParams, aH as PaymentGateway, aC as PerspectApiError, ay as PerspectApiV2Client, aA as PerspectV2Error, c0 as ProductSkuMediaItem, c1 as ProductSkuOption, cd as RequestOptions, aQ as SetProfileValueRequest, ca as SubscriptionCancellationMode, bH as V2ApiKey, bS as V2CancelSubscriptionResult, b4 as V2Category, b5 as V2CategoryCreateParams, b6 as V2CategoryUpdateParams, b7 as V2Collection, b9 as V2CollectionCreateParams, b8 as V2CollectionItem, ba as V2CollectionUpdateParams, bE as V2ContactSubmission, aY as V2Content, aZ as V2ContentCreateParams, a$ as V2ContentListParams, a_ as V2ContentUpdateParams, bU as V2CreditBalance, bT as V2CreditTransaction, aT as V2Deleted, bX as V2EmailSendParams, bY as V2EmailSendResult, aU as V2Error, aV as V2ErrorType, bV as V2GrantCreditParams, bW as V2GrantCreditResult, aS as V2List, aX as V2Media, bv as V2NewsletterCampaign, bC as V2NewsletterImportRequest, bD as V2NewsletterImportResult, bu as V2NewsletterList, bx as V2NewsletterListCreateParams, by as V2NewsletterListUpdateParams, bt as V2NewsletterSubscription, bB as V2NewsletterSubscriptionListMembershipUpdate, bz as V2NewsletterSyncInput, bA as V2NewsletterSyncResult, bw as V2NewsletterTrackingResponse, aR as V2Object, bb as V2Order, bf as V2OrderAddress, bh as V2OrderCreateParams, bm as V2OrderCreateResult, bj as V2OrderFulfillmentNotificationLineItem, bk as V2OrderFulfillmentNotificationParams, bl as V2OrderFulfillmentNotificationResult, bi as V2OrderFulfillmentUpdate, be as V2OrderLineItem, bd as V2OrderLineItemPriceData, bc as V2OrderListParams, bg as V2OrderTaxRequest, bF as V2Organization, aW as V2PaginationParams, b0 as V2Product, b1 as V2ProductCreateParams, b3 as V2ProductListParams, b2 as V2ProductUpdateParams, bG as V2Site, bn as V2SiteUser, bq as V2SiteUserListParams, bp as V2SiteUserMeUpdateParams, bs as V2SiteUserProfile, bM as V2SiteUserSubscription, bo as V2SiteUserUpdateParams, br as V2SiteUserWithProfile, bO as V2SubscriptionCancelParams, bP as V2SubscriptionChangePlanParams, bQ as V2SubscriptionChargeParams, bR as V2SubscriptionChargeResult, bN as V2SubscriptionPauseParams, bJ as V2Webhook, bK as V2WebhookCreateParams, bI as V2WebhookEventType, bL as V2WebhookUpdateParams, c3 as WebhookEventType, aB as createApiError, az as createPerspectApiV2Client } from './index-DuNDHod-.js';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* v1 deprecation constants — kept in sync with the backend's
|
|
@@ -1775,6 +1775,8 @@ declare class SiteUsersClient extends BaseClient {
|
|
|
1775
1775
|
fulfillment_status: string;
|
|
1776
1776
|
tracking_number?: string;
|
|
1777
1777
|
notes?: string;
|
|
1778
|
+
fulfillment_details_text?: string;
|
|
1779
|
+
fulfillment_details_html?: string;
|
|
1778
1780
|
notify_customer?: boolean;
|
|
1779
1781
|
}): Promise<ApiResponse<{
|
|
1780
1782
|
success: boolean;
|
package/dist/index.js
CHANGED
|
@@ -978,13 +978,40 @@ var CollectionsV2Client = class extends BaseV2Client {
|
|
|
978
978
|
// src/v2/client/orders-client.ts
|
|
979
979
|
var OrdersV2Client = class extends BaseV2Client {
|
|
980
980
|
async list(siteName, params, cachePolicy) {
|
|
981
|
-
return this.getList(
|
|
981
|
+
return this.getList(
|
|
982
|
+
this.sitePath(siteName, "orders"),
|
|
983
|
+
params,
|
|
984
|
+
this.withOrderTags(siteName, cachePolicy, {
|
|
985
|
+
fulfillmentStatus: params?.fulfillment_status
|
|
986
|
+
})
|
|
987
|
+
);
|
|
982
988
|
}
|
|
983
|
-
async *listAutoPaginated(siteName, params) {
|
|
984
|
-
|
|
989
|
+
async *listAutoPaginated(siteName, params, cachePolicy) {
|
|
990
|
+
let startingAfter;
|
|
991
|
+
let hasMore = true;
|
|
992
|
+
while (hasMore) {
|
|
993
|
+
const queryParams = { ...params ?? {} };
|
|
994
|
+
if (startingAfter) {
|
|
995
|
+
queryParams.starting_after = startingAfter;
|
|
996
|
+
}
|
|
997
|
+
const page = await this.list(siteName, queryParams, cachePolicy);
|
|
998
|
+
for (const item of page.data) {
|
|
999
|
+
yield item;
|
|
1000
|
+
}
|
|
1001
|
+
hasMore = page.has_more;
|
|
1002
|
+
if (page.data.length > 0) {
|
|
1003
|
+
startingAfter = page.data[page.data.length - 1].id;
|
|
1004
|
+
} else {
|
|
1005
|
+
hasMore = false;
|
|
1006
|
+
}
|
|
1007
|
+
}
|
|
985
1008
|
}
|
|
986
1009
|
async get(siteName, id, cachePolicy) {
|
|
987
|
-
return this.getOne(
|
|
1010
|
+
return this.getOne(
|
|
1011
|
+
this.sitePath(siteName, "orders", id),
|
|
1012
|
+
void 0,
|
|
1013
|
+
this.withOrderTags(siteName, cachePolicy, { id })
|
|
1014
|
+
);
|
|
988
1015
|
}
|
|
989
1016
|
/**
|
|
990
1017
|
* Create a checkout session via Stripe. Returns the session ID and a
|
|
@@ -1006,10 +1033,51 @@ var OrdersV2Client = class extends BaseV2Client {
|
|
|
1006
1033
|
* fulfillment state to send the customer fulfillment email.
|
|
1007
1034
|
*/
|
|
1008
1035
|
async updateFulfillment(siteName, id, data) {
|
|
1009
|
-
|
|
1036
|
+
const result = await this.patchOne(
|
|
1010
1037
|
this.sitePath(siteName, "orders", `${id}/fulfillment`),
|
|
1011
1038
|
data
|
|
1012
1039
|
);
|
|
1040
|
+
await this.invalidateCache({
|
|
1041
|
+
tags: this.buildOrderTags(siteName, { id }),
|
|
1042
|
+
keys: [this.sitePath(siteName, "orders", id)]
|
|
1043
|
+
});
|
|
1044
|
+
return result;
|
|
1045
|
+
}
|
|
1046
|
+
/**
|
|
1047
|
+
* Send the customer fulfillment template for an external delivery/packing
|
|
1048
|
+
* record without mutating a checkout session.
|
|
1049
|
+
*/
|
|
1050
|
+
async sendFulfillmentNotification(siteName, data) {
|
|
1051
|
+
return this.post(
|
|
1052
|
+
this.sitePath(siteName, "orders", "fulfillment-notifications"),
|
|
1053
|
+
data
|
|
1054
|
+
);
|
|
1055
|
+
}
|
|
1056
|
+
withOrderTags(siteName, cachePolicy, options = {}) {
|
|
1057
|
+
const tags = new Set(cachePolicy?.tags ?? []);
|
|
1058
|
+
for (const tag of this.buildOrderTags(siteName, options)) {
|
|
1059
|
+
tags.add(tag);
|
|
1060
|
+
}
|
|
1061
|
+
return {
|
|
1062
|
+
...cachePolicy,
|
|
1063
|
+
tags: Array.from(tags)
|
|
1064
|
+
};
|
|
1065
|
+
}
|
|
1066
|
+
buildOrderTags(siteName, options = {}) {
|
|
1067
|
+
const tags = /* @__PURE__ */ new Set(["orders", `orders:site:${siteName}`]);
|
|
1068
|
+
if (options.id) {
|
|
1069
|
+
tags.add(`orders:id:${options.id}`);
|
|
1070
|
+
}
|
|
1071
|
+
const fulfillmentStatus = this.normalizeTagPart(options.fulfillmentStatus);
|
|
1072
|
+
if (fulfillmentStatus) {
|
|
1073
|
+
tags.add(`orders:fulfillment:${siteName}:${fulfillmentStatus}`);
|
|
1074
|
+
}
|
|
1075
|
+
return Array.from(tags);
|
|
1076
|
+
}
|
|
1077
|
+
normalizeTagPart(value) {
|
|
1078
|
+
if (!value) return null;
|
|
1079
|
+
const normalized = value.trim().toLowerCase().replace(/[^a-z0-9_-]+/g, "-");
|
|
1080
|
+
return normalized || null;
|
|
1013
1081
|
}
|
|
1014
1082
|
};
|
|
1015
1083
|
|
|
@@ -1395,6 +1463,23 @@ var CreditsV2Client = class extends BaseV2Client {
|
|
|
1395
1463
|
}
|
|
1396
1464
|
};
|
|
1397
1465
|
|
|
1466
|
+
// src/v2/client/email-client.ts
|
|
1467
|
+
var EmailV2Client = class extends BaseV2Client {
|
|
1468
|
+
/**
|
|
1469
|
+
* Send a transactional email using the site's configured email provider.
|
|
1470
|
+
*
|
|
1471
|
+
* Requires a server-side API key — never call this from a browser.
|
|
1472
|
+
* The site must have an email provider configured in its settings.
|
|
1473
|
+
* At least one of `html` or `text` must be provided.
|
|
1474
|
+
*/
|
|
1475
|
+
async send(siteName, params) {
|
|
1476
|
+
return this.post(
|
|
1477
|
+
this.sitePath(siteName, "email", "send"),
|
|
1478
|
+
params
|
|
1479
|
+
);
|
|
1480
|
+
}
|
|
1481
|
+
};
|
|
1482
|
+
|
|
1398
1483
|
// src/v2/index.ts
|
|
1399
1484
|
var PerspectApiV2Client = class {
|
|
1400
1485
|
http;
|
|
@@ -1413,6 +1498,7 @@ var PerspectApiV2Client = class {
|
|
|
1413
1498
|
webhooks;
|
|
1414
1499
|
subscriptions;
|
|
1415
1500
|
credits;
|
|
1501
|
+
email;
|
|
1416
1502
|
constructor(config) {
|
|
1417
1503
|
const baseUrl = config.baseUrl.replace(/\/+$/, "");
|
|
1418
1504
|
const v2BaseUrl = baseUrl.endsWith("/api/v2") ? baseUrl : `${baseUrl}/api/v2`;
|
|
@@ -1434,6 +1520,7 @@ var PerspectApiV2Client = class {
|
|
|
1434
1520
|
this.webhooks = new WebhooksV2Client(this.http, basePath, cache);
|
|
1435
1521
|
this.subscriptions = new SubscriptionsV2Client(this.http, basePath, cache);
|
|
1436
1522
|
this.credits = new CreditsV2Client(this.http, basePath, cache);
|
|
1523
|
+
this.email = new EmailV2Client(this.http, basePath, cache);
|
|
1437
1524
|
}
|
|
1438
1525
|
/** Update the JWT token for authenticated requests. */
|
|
1439
1526
|
setAuth(jwt) {
|
package/dist/index.mjs
CHANGED
package/dist/v2/index.d.mts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { cq as ApiKeysV2Client, cf as BaseV2Client, ci as CategoriesV2Client, cj as CollectionsV2Client, cn as ContactsV2Client, cg as ContentV2Client, ct as CreditsV2Client, cu as EmailV2Client, cm as NewsletterV2Client, ck as OrdersV2Client, co as OrganizationsV2Client, ay as PerspectApiV2Client, ce as PerspectApiV2Config, aA as PerspectV2Error, ch as ProductsV2Client, cl as SiteUsersV2Client, cp as SitesV2Client, cs as SubscriptionsV2Client, bH as V2ApiKey, bS as V2CancelSubscriptionResult, b4 as V2Category, b5 as V2CategoryCreateParams, b6 as V2CategoryUpdateParams, b7 as V2Collection, b9 as V2CollectionCreateParams, b8 as V2CollectionItem, ba as V2CollectionUpdateParams, bE as V2ContactSubmission, aY as V2Content, aZ as V2ContentCreateParams, a$ as V2ContentListParams, a_ as V2ContentUpdateParams, bU as V2CreditBalance, bT as V2CreditTransaction, aT as V2Deleted, bX as V2EmailSendParams, bY as V2EmailSendResult, aU as V2Error, aV as V2ErrorType, bV as V2GrantCreditParams, bW as V2GrantCreditResult, aS as V2List, aX as V2Media, bv as V2NewsletterCampaign, bC as V2NewsletterImportRequest, bD as V2NewsletterImportResult, bu as V2NewsletterList, bx as V2NewsletterListCreateParams, by as V2NewsletterListUpdateParams, bt as V2NewsletterSubscription, bB as V2NewsletterSubscriptionListMembershipUpdate, bz as V2NewsletterSyncInput, bA as V2NewsletterSyncResult, bw as V2NewsletterTrackingResponse, aR as V2Object, bb as V2Order, bf as V2OrderAddress, bh as V2OrderCreateParams, bm as V2OrderCreateResult, bj as V2OrderFulfillmentNotificationLineItem, bk as V2OrderFulfillmentNotificationParams, bl as V2OrderFulfillmentNotificationResult, bi as V2OrderFulfillmentUpdate, be as V2OrderLineItem, bd as V2OrderLineItemPriceData, bc as V2OrderListParams, bg as V2OrderTaxRequest, bF as V2Organization, aW as V2PaginationParams, b0 as V2Product, b1 as V2ProductCreateParams, b3 as V2ProductListParams, b2 as V2ProductUpdateParams, bG as V2Site, bn as V2SiteUser, bq as V2SiteUserListParams, bp as V2SiteUserMeUpdateParams, bs as V2SiteUserProfile, bM as V2SiteUserSubscription, bo as V2SiteUserUpdateParams, br as V2SiteUserWithProfile, bO as V2SubscriptionCancelParams, bP as V2SubscriptionChangePlanParams, bQ as V2SubscriptionChargeParams, bR as V2SubscriptionChargeResult, bN as V2SubscriptionPauseParams, bJ as V2Webhook, bK as V2WebhookCreateParams, bI as V2WebhookEventType, bL as V2WebhookUpdateParams, cr as WebhooksV2Client, az as createPerspectApiV2Client } from '../index-DuNDHod-.mjs';
|
package/dist/v2/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { cq as ApiKeysV2Client, cf as BaseV2Client, ci as CategoriesV2Client, cj as CollectionsV2Client, cn as ContactsV2Client, cg as ContentV2Client, ct as CreditsV2Client, cu as EmailV2Client, cm as NewsletterV2Client, ck as OrdersV2Client, co as OrganizationsV2Client, ay as PerspectApiV2Client, ce as PerspectApiV2Config, aA as PerspectV2Error, ch as ProductsV2Client, cl as SiteUsersV2Client, cp as SitesV2Client, cs as SubscriptionsV2Client, bH as V2ApiKey, bS as V2CancelSubscriptionResult, b4 as V2Category, b5 as V2CategoryCreateParams, b6 as V2CategoryUpdateParams, b7 as V2Collection, b9 as V2CollectionCreateParams, b8 as V2CollectionItem, ba as V2CollectionUpdateParams, bE as V2ContactSubmission, aY as V2Content, aZ as V2ContentCreateParams, a$ as V2ContentListParams, a_ as V2ContentUpdateParams, bU as V2CreditBalance, bT as V2CreditTransaction, aT as V2Deleted, bX as V2EmailSendParams, bY as V2EmailSendResult, aU as V2Error, aV as V2ErrorType, bV as V2GrantCreditParams, bW as V2GrantCreditResult, aS as V2List, aX as V2Media, bv as V2NewsletterCampaign, bC as V2NewsletterImportRequest, bD as V2NewsletterImportResult, bu as V2NewsletterList, bx as V2NewsletterListCreateParams, by as V2NewsletterListUpdateParams, bt as V2NewsletterSubscription, bB as V2NewsletterSubscriptionListMembershipUpdate, bz as V2NewsletterSyncInput, bA as V2NewsletterSyncResult, bw as V2NewsletterTrackingResponse, aR as V2Object, bb as V2Order, bf as V2OrderAddress, bh as V2OrderCreateParams, bm as V2OrderCreateResult, bj as V2OrderFulfillmentNotificationLineItem, bk as V2OrderFulfillmentNotificationParams, bl as V2OrderFulfillmentNotificationResult, bi as V2OrderFulfillmentUpdate, be as V2OrderLineItem, bd as V2OrderLineItemPriceData, bc as V2OrderListParams, bg as V2OrderTaxRequest, bF as V2Organization, aW as V2PaginationParams, b0 as V2Product, b1 as V2ProductCreateParams, b3 as V2ProductListParams, b2 as V2ProductUpdateParams, bG as V2Site, bn as V2SiteUser, bq as V2SiteUserListParams, bp as V2SiteUserMeUpdateParams, bs as V2SiteUserProfile, bM as V2SiteUserSubscription, bo as V2SiteUserUpdateParams, br as V2SiteUserWithProfile, bO as V2SubscriptionCancelParams, bP as V2SubscriptionChangePlanParams, bQ as V2SubscriptionChargeParams, bR as V2SubscriptionChargeResult, bN as V2SubscriptionPauseParams, bJ as V2Webhook, bK as V2WebhookCreateParams, bI as V2WebhookEventType, bL as V2WebhookUpdateParams, cr as WebhooksV2Client, az as createPerspectApiV2Client } from '../index-DuNDHod-.js';
|
package/dist/v2/index.js
CHANGED
|
@@ -27,6 +27,7 @@ __export(v2_exports, {
|
|
|
27
27
|
ContactsV2Client: () => ContactsV2Client,
|
|
28
28
|
ContentV2Client: () => ContentV2Client,
|
|
29
29
|
CreditsV2Client: () => CreditsV2Client,
|
|
30
|
+
EmailV2Client: () => EmailV2Client,
|
|
30
31
|
NewsletterV2Client: () => NewsletterV2Client,
|
|
31
32
|
OrdersV2Client: () => OrdersV2Client,
|
|
32
33
|
OrganizationsV2Client: () => OrganizationsV2Client,
|
|
@@ -923,13 +924,40 @@ var CollectionsV2Client = class extends BaseV2Client {
|
|
|
923
924
|
// src/v2/client/orders-client.ts
|
|
924
925
|
var OrdersV2Client = class extends BaseV2Client {
|
|
925
926
|
async list(siteName, params, cachePolicy) {
|
|
926
|
-
return this.getList(
|
|
927
|
+
return this.getList(
|
|
928
|
+
this.sitePath(siteName, "orders"),
|
|
929
|
+
params,
|
|
930
|
+
this.withOrderTags(siteName, cachePolicy, {
|
|
931
|
+
fulfillmentStatus: params?.fulfillment_status
|
|
932
|
+
})
|
|
933
|
+
);
|
|
927
934
|
}
|
|
928
|
-
async *listAutoPaginated(siteName, params) {
|
|
929
|
-
|
|
935
|
+
async *listAutoPaginated(siteName, params, cachePolicy) {
|
|
936
|
+
let startingAfter;
|
|
937
|
+
let hasMore = true;
|
|
938
|
+
while (hasMore) {
|
|
939
|
+
const queryParams = { ...params ?? {} };
|
|
940
|
+
if (startingAfter) {
|
|
941
|
+
queryParams.starting_after = startingAfter;
|
|
942
|
+
}
|
|
943
|
+
const page = await this.list(siteName, queryParams, cachePolicy);
|
|
944
|
+
for (const item of page.data) {
|
|
945
|
+
yield item;
|
|
946
|
+
}
|
|
947
|
+
hasMore = page.has_more;
|
|
948
|
+
if (page.data.length > 0) {
|
|
949
|
+
startingAfter = page.data[page.data.length - 1].id;
|
|
950
|
+
} else {
|
|
951
|
+
hasMore = false;
|
|
952
|
+
}
|
|
953
|
+
}
|
|
930
954
|
}
|
|
931
955
|
async get(siteName, id, cachePolicy) {
|
|
932
|
-
return this.getOne(
|
|
956
|
+
return this.getOne(
|
|
957
|
+
this.sitePath(siteName, "orders", id),
|
|
958
|
+
void 0,
|
|
959
|
+
this.withOrderTags(siteName, cachePolicy, { id })
|
|
960
|
+
);
|
|
933
961
|
}
|
|
934
962
|
/**
|
|
935
963
|
* Create a checkout session via Stripe. Returns the session ID and a
|
|
@@ -951,10 +979,51 @@ var OrdersV2Client = class extends BaseV2Client {
|
|
|
951
979
|
* fulfillment state to send the customer fulfillment email.
|
|
952
980
|
*/
|
|
953
981
|
async updateFulfillment(siteName, id, data) {
|
|
954
|
-
|
|
982
|
+
const result = await this.patchOne(
|
|
955
983
|
this.sitePath(siteName, "orders", `${id}/fulfillment`),
|
|
956
984
|
data
|
|
957
985
|
);
|
|
986
|
+
await this.invalidateCache({
|
|
987
|
+
tags: this.buildOrderTags(siteName, { id }),
|
|
988
|
+
keys: [this.sitePath(siteName, "orders", id)]
|
|
989
|
+
});
|
|
990
|
+
return result;
|
|
991
|
+
}
|
|
992
|
+
/**
|
|
993
|
+
* Send the customer fulfillment template for an external delivery/packing
|
|
994
|
+
* record without mutating a checkout session.
|
|
995
|
+
*/
|
|
996
|
+
async sendFulfillmentNotification(siteName, data) {
|
|
997
|
+
return this.post(
|
|
998
|
+
this.sitePath(siteName, "orders", "fulfillment-notifications"),
|
|
999
|
+
data
|
|
1000
|
+
);
|
|
1001
|
+
}
|
|
1002
|
+
withOrderTags(siteName, cachePolicy, options = {}) {
|
|
1003
|
+
const tags = new Set(cachePolicy?.tags ?? []);
|
|
1004
|
+
for (const tag of this.buildOrderTags(siteName, options)) {
|
|
1005
|
+
tags.add(tag);
|
|
1006
|
+
}
|
|
1007
|
+
return {
|
|
1008
|
+
...cachePolicy,
|
|
1009
|
+
tags: Array.from(tags)
|
|
1010
|
+
};
|
|
1011
|
+
}
|
|
1012
|
+
buildOrderTags(siteName, options = {}) {
|
|
1013
|
+
const tags = /* @__PURE__ */ new Set(["orders", `orders:site:${siteName}`]);
|
|
1014
|
+
if (options.id) {
|
|
1015
|
+
tags.add(`orders:id:${options.id}`);
|
|
1016
|
+
}
|
|
1017
|
+
const fulfillmentStatus = this.normalizeTagPart(options.fulfillmentStatus);
|
|
1018
|
+
if (fulfillmentStatus) {
|
|
1019
|
+
tags.add(`orders:fulfillment:${siteName}:${fulfillmentStatus}`);
|
|
1020
|
+
}
|
|
1021
|
+
return Array.from(tags);
|
|
1022
|
+
}
|
|
1023
|
+
normalizeTagPart(value) {
|
|
1024
|
+
if (!value) return null;
|
|
1025
|
+
const normalized = value.trim().toLowerCase().replace(/[^a-z0-9_-]+/g, "-");
|
|
1026
|
+
return normalized || null;
|
|
958
1027
|
}
|
|
959
1028
|
};
|
|
960
1029
|
|
|
@@ -1340,6 +1409,23 @@ var CreditsV2Client = class extends BaseV2Client {
|
|
|
1340
1409
|
}
|
|
1341
1410
|
};
|
|
1342
1411
|
|
|
1412
|
+
// src/v2/client/email-client.ts
|
|
1413
|
+
var EmailV2Client = class extends BaseV2Client {
|
|
1414
|
+
/**
|
|
1415
|
+
* Send a transactional email using the site's configured email provider.
|
|
1416
|
+
*
|
|
1417
|
+
* Requires a server-side API key — never call this from a browser.
|
|
1418
|
+
* The site must have an email provider configured in its settings.
|
|
1419
|
+
* At least one of `html` or `text` must be provided.
|
|
1420
|
+
*/
|
|
1421
|
+
async send(siteName, params) {
|
|
1422
|
+
return this.post(
|
|
1423
|
+
this.sitePath(siteName, "email", "send"),
|
|
1424
|
+
params
|
|
1425
|
+
);
|
|
1426
|
+
}
|
|
1427
|
+
};
|
|
1428
|
+
|
|
1343
1429
|
// src/v2/index.ts
|
|
1344
1430
|
var PerspectApiV2Client = class {
|
|
1345
1431
|
http;
|
|
@@ -1358,6 +1444,7 @@ var PerspectApiV2Client = class {
|
|
|
1358
1444
|
webhooks;
|
|
1359
1445
|
subscriptions;
|
|
1360
1446
|
credits;
|
|
1447
|
+
email;
|
|
1361
1448
|
constructor(config) {
|
|
1362
1449
|
const baseUrl = config.baseUrl.replace(/\/+$/, "");
|
|
1363
1450
|
const v2BaseUrl = baseUrl.endsWith("/api/v2") ? baseUrl : `${baseUrl}/api/v2`;
|
|
@@ -1379,6 +1466,7 @@ var PerspectApiV2Client = class {
|
|
|
1379
1466
|
this.webhooks = new WebhooksV2Client(this.http, basePath, cache);
|
|
1380
1467
|
this.subscriptions = new SubscriptionsV2Client(this.http, basePath, cache);
|
|
1381
1468
|
this.credits = new CreditsV2Client(this.http, basePath, cache);
|
|
1469
|
+
this.email = new EmailV2Client(this.http, basePath, cache);
|
|
1382
1470
|
}
|
|
1383
1471
|
/** Update the JWT token for authenticated requests. */
|
|
1384
1472
|
setAuth(jwt) {
|
|
@@ -1405,6 +1493,7 @@ function createPerspectApiV2Client(config) {
|
|
|
1405
1493
|
ContactsV2Client,
|
|
1406
1494
|
ContentV2Client,
|
|
1407
1495
|
CreditsV2Client,
|
|
1496
|
+
EmailV2Client,
|
|
1408
1497
|
NewsletterV2Client,
|
|
1409
1498
|
OrdersV2Client,
|
|
1410
1499
|
OrganizationsV2Client,
|
package/dist/v2/index.mjs
CHANGED
|
@@ -6,6 +6,7 @@ import {
|
|
|
6
6
|
ContactsV2Client,
|
|
7
7
|
ContentV2Client,
|
|
8
8
|
CreditsV2Client,
|
|
9
|
+
EmailV2Client,
|
|
9
10
|
NewsletterV2Client,
|
|
10
11
|
OrdersV2Client,
|
|
11
12
|
OrganizationsV2Client,
|
|
@@ -17,7 +18,7 @@ import {
|
|
|
17
18
|
SubscriptionsV2Client,
|
|
18
19
|
WebhooksV2Client,
|
|
19
20
|
createPerspectApiV2Client
|
|
20
|
-
} from "../chunk-
|
|
21
|
+
} from "../chunk-MMKJ2WBF.mjs";
|
|
21
22
|
export {
|
|
22
23
|
ApiKeysV2Client,
|
|
23
24
|
BaseV2Client,
|
|
@@ -26,6 +27,7 @@ export {
|
|
|
26
27
|
ContactsV2Client,
|
|
27
28
|
ContentV2Client,
|
|
28
29
|
CreditsV2Client,
|
|
30
|
+
EmailV2Client,
|
|
29
31
|
NewsletterV2Client,
|
|
30
32
|
OrdersV2Client,
|
|
31
33
|
OrganizationsV2Client,
|
package/package.json
CHANGED
|
@@ -519,6 +519,8 @@ export class SiteUsersClient extends BaseClient {
|
|
|
519
519
|
fulfillment_status: string;
|
|
520
520
|
tracking_number?: string;
|
|
521
521
|
notes?: string;
|
|
522
|
+
fulfillment_details_text?: string;
|
|
523
|
+
fulfillment_details_html?: string;
|
|
522
524
|
notify_customer?: boolean;
|
|
523
525
|
}
|
|
524
526
|
): Promise<ApiResponse<{ success: boolean }>> {
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* v2 Email Client — send transactional email through a site's configured provider.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import { BaseV2Client } from './base-v2-client';
|
|
6
|
+
import type { V2EmailSendParams, V2EmailSendResult } from '../types';
|
|
7
|
+
|
|
8
|
+
export class EmailV2Client extends BaseV2Client {
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Send a transactional email using the site's configured email provider.
|
|
12
|
+
*
|
|
13
|
+
* Requires a server-side API key — never call this from a browser.
|
|
14
|
+
* The site must have an email provider configured in its settings.
|
|
15
|
+
* At least one of `html` or `text` must be provided.
|
|
16
|
+
*/
|
|
17
|
+
async send(siteName: string, params: V2EmailSendParams): Promise<V2EmailSendResult> {
|
|
18
|
+
return this.post<V2EmailSendResult>(
|
|
19
|
+
this.sitePath(siteName, 'email', 'send'),
|
|
20
|
+
params,
|
|
21
|
+
);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
@@ -13,21 +13,57 @@ import type {
|
|
|
13
13
|
V2OrderCreateParams,
|
|
14
14
|
V2OrderCreateResult,
|
|
15
15
|
V2OrderFulfillmentUpdate,
|
|
16
|
+
V2OrderFulfillmentNotificationParams,
|
|
17
|
+
V2OrderFulfillmentNotificationResult,
|
|
16
18
|
V2List,
|
|
17
19
|
} from '../types';
|
|
18
20
|
|
|
19
21
|
export class OrdersV2Client extends BaseV2Client {
|
|
20
22
|
|
|
21
23
|
async list(siteName: string, params?: V2OrderListParams, cachePolicy?: CachePolicy): Promise<V2List<V2Order>> {
|
|
22
|
-
return this.getList<V2Order>(
|
|
24
|
+
return this.getList<V2Order>(
|
|
25
|
+
this.sitePath(siteName, 'orders'),
|
|
26
|
+
params,
|
|
27
|
+
this.withOrderTags(siteName, cachePolicy, {
|
|
28
|
+
fulfillmentStatus: params?.fulfillment_status,
|
|
29
|
+
}),
|
|
30
|
+
);
|
|
23
31
|
}
|
|
24
32
|
|
|
25
|
-
async *listAutoPaginated(
|
|
26
|
-
|
|
33
|
+
async *listAutoPaginated(
|
|
34
|
+
siteName: string,
|
|
35
|
+
params?: Omit<V2OrderListParams, 'starting_after' | 'ending_before'>,
|
|
36
|
+
cachePolicy?: CachePolicy,
|
|
37
|
+
) {
|
|
38
|
+
let startingAfter: string | undefined;
|
|
39
|
+
let hasMore = true;
|
|
40
|
+
|
|
41
|
+
while (hasMore) {
|
|
42
|
+
const queryParams: V2OrderListParams = { ...(params ?? {}) };
|
|
43
|
+
if (startingAfter) {
|
|
44
|
+
queryParams.starting_after = startingAfter;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
const page = await this.list(siteName, queryParams, cachePolicy);
|
|
48
|
+
for (const item of page.data) {
|
|
49
|
+
yield item;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
hasMore = page.has_more;
|
|
53
|
+
if (page.data.length > 0) {
|
|
54
|
+
startingAfter = page.data[page.data.length - 1].id;
|
|
55
|
+
} else {
|
|
56
|
+
hasMore = false;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
27
59
|
}
|
|
28
60
|
|
|
29
61
|
async get(siteName: string, id: string, cachePolicy?: CachePolicy): Promise<V2Order> {
|
|
30
|
-
return this.getOne<V2Order>(
|
|
62
|
+
return this.getOne<V2Order>(
|
|
63
|
+
this.sitePath(siteName, 'orders', id),
|
|
64
|
+
undefined,
|
|
65
|
+
this.withOrderTags(siteName, cachePolicy, { id }),
|
|
66
|
+
);
|
|
31
67
|
}
|
|
32
68
|
|
|
33
69
|
/**
|
|
@@ -58,9 +94,67 @@ export class OrdersV2Client extends BaseV2Client {
|
|
|
58
94
|
id: string,
|
|
59
95
|
data: V2OrderFulfillmentUpdate,
|
|
60
96
|
): Promise<V2Order> {
|
|
61
|
-
|
|
97
|
+
const result = await this.patchOne<V2Order>(
|
|
62
98
|
this.sitePath(siteName, 'orders', `${id}/fulfillment`),
|
|
63
99
|
data,
|
|
64
100
|
);
|
|
101
|
+
await this.invalidateCache({
|
|
102
|
+
tags: this.buildOrderTags(siteName, { id }),
|
|
103
|
+
keys: [this.sitePath(siteName, 'orders', id)],
|
|
104
|
+
});
|
|
105
|
+
return result;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* Send the customer fulfillment template for an external delivery/packing
|
|
110
|
+
* record without mutating a checkout session.
|
|
111
|
+
*/
|
|
112
|
+
async sendFulfillmentNotification(
|
|
113
|
+
siteName: string,
|
|
114
|
+
data: V2OrderFulfillmentNotificationParams,
|
|
115
|
+
): Promise<V2OrderFulfillmentNotificationResult> {
|
|
116
|
+
return this.post<V2OrderFulfillmentNotificationResult>(
|
|
117
|
+
this.sitePath(siteName, 'orders', 'fulfillment-notifications'),
|
|
118
|
+
data,
|
|
119
|
+
);
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
private withOrderTags(
|
|
123
|
+
siteName: string,
|
|
124
|
+
cachePolicy: CachePolicy | undefined,
|
|
125
|
+
options: { id?: string; fulfillmentStatus?: string | null } = {},
|
|
126
|
+
): CachePolicy {
|
|
127
|
+
const tags = new Set<string>(cachePolicy?.tags ?? []);
|
|
128
|
+
for (const tag of this.buildOrderTags(siteName, options)) {
|
|
129
|
+
tags.add(tag);
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
return {
|
|
133
|
+
...cachePolicy,
|
|
134
|
+
tags: Array.from(tags),
|
|
135
|
+
};
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
private buildOrderTags(
|
|
139
|
+
siteName: string,
|
|
140
|
+
options: { id?: string; fulfillmentStatus?: string | null } = {},
|
|
141
|
+
): string[] {
|
|
142
|
+
const tags = new Set<string>(['orders', `orders:site:${siteName}`]);
|
|
143
|
+
if (options.id) {
|
|
144
|
+
tags.add(`orders:id:${options.id}`);
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
const fulfillmentStatus = this.normalizeTagPart(options.fulfillmentStatus);
|
|
148
|
+
if (fulfillmentStatus) {
|
|
149
|
+
tags.add(`orders:fulfillment:${siteName}:${fulfillmentStatus}`);
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
return Array.from(tags);
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
private normalizeTagPart(value?: string | null): string | null {
|
|
156
|
+
if (!value) return null;
|
|
157
|
+
const normalized = value.trim().toLowerCase().replace(/[^a-z0-9_-]+/g, '-');
|
|
158
|
+
return normalized || null;
|
|
65
159
|
}
|
|
66
160
|
}
|
package/src/v2/index.ts
CHANGED
|
@@ -29,6 +29,7 @@ import { ApiKeysV2Client } from './client/api-keys-client';
|
|
|
29
29
|
import { WebhooksV2Client } from './client/webhooks-client';
|
|
30
30
|
import { SubscriptionsV2Client } from './client/subscriptions-client';
|
|
31
31
|
import { CreditsV2Client } from './client/credits-client';
|
|
32
|
+
import { EmailV2Client } from './client/email-client';
|
|
32
33
|
|
|
33
34
|
export interface PerspectApiV2Config extends PerspectApiConfig {
|
|
34
35
|
cache?: CacheConfig;
|
|
@@ -52,6 +53,7 @@ export class PerspectApiV2Client {
|
|
|
52
53
|
readonly webhooks: WebhooksV2Client;
|
|
53
54
|
readonly subscriptions: SubscriptionsV2Client;
|
|
54
55
|
readonly credits: CreditsV2Client;
|
|
56
|
+
readonly email: EmailV2Client;
|
|
55
57
|
|
|
56
58
|
constructor(config: PerspectApiV2Config) {
|
|
57
59
|
// Ensure base URL points to /api/v2
|
|
@@ -79,6 +81,7 @@ export class PerspectApiV2Client {
|
|
|
79
81
|
this.webhooks = new WebhooksV2Client(this.http, basePath, cache);
|
|
80
82
|
this.subscriptions = new SubscriptionsV2Client(this.http, basePath, cache);
|
|
81
83
|
this.credits = new CreditsV2Client(this.http, basePath, cache);
|
|
84
|
+
this.email = new EmailV2Client(this.http, basePath, cache);
|
|
82
85
|
}
|
|
83
86
|
|
|
84
87
|
/** Update the JWT token for authenticated requests. */
|
|
@@ -120,3 +123,4 @@ export { ApiKeysV2Client } from './client/api-keys-client';
|
|
|
120
123
|
export { WebhooksV2Client } from './client/webhooks-client';
|
|
121
124
|
export { SubscriptionsV2Client } from './client/subscriptions-client';
|
|
122
125
|
export { CreditsV2Client } from './client/credits-client';
|
|
126
|
+
export { EmailV2Client } from './client/email-client';
|
package/src/v2/types.ts
CHANGED
|
@@ -328,10 +328,44 @@ export interface V2OrderFulfillmentUpdate {
|
|
|
328
328
|
fulfillment_status: string;
|
|
329
329
|
tracking_number?: string;
|
|
330
330
|
notes?: string;
|
|
331
|
+
fulfillment_details_text?: string;
|
|
332
|
+
fulfillment_details_html?: string;
|
|
331
333
|
/** When true, a terminal fulfillment status triggers a customer email. */
|
|
332
334
|
notify_customer?: boolean;
|
|
333
335
|
}
|
|
334
336
|
|
|
337
|
+
export interface V2OrderFulfillmentNotificationLineItem {
|
|
338
|
+
quantity: number;
|
|
339
|
+
description: string;
|
|
340
|
+
amount_total?: number;
|
|
341
|
+
currency?: string;
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
export interface V2OrderFulfillmentNotificationParams {
|
|
345
|
+
session_id?: string;
|
|
346
|
+
order_id?: string;
|
|
347
|
+
customer_email: string;
|
|
348
|
+
customer_name?: string;
|
|
349
|
+
fulfillment_status?: string;
|
|
350
|
+
fulfillment_details_text?: string;
|
|
351
|
+
fulfillment_details_html?: string;
|
|
352
|
+
line_items?: V2OrderFulfillmentNotificationLineItem[];
|
|
353
|
+
amount_total?: number;
|
|
354
|
+
currency?: string;
|
|
355
|
+
shipping_details?: Record<string, unknown>;
|
|
356
|
+
customer_details?: Record<string, unknown>;
|
|
357
|
+
metadata?: Record<string, unknown>;
|
|
358
|
+
created_at?: string;
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
export interface V2OrderFulfillmentNotificationResult extends V2Object {
|
|
362
|
+
object: "fulfillment_notification";
|
|
363
|
+
order_id: string;
|
|
364
|
+
notified: boolean;
|
|
365
|
+
queued: boolean;
|
|
366
|
+
reason?: string;
|
|
367
|
+
}
|
|
368
|
+
|
|
335
369
|
export interface V2OrderCreateResult extends V2Object {
|
|
336
370
|
object: "checkout_session";
|
|
337
371
|
checkout_url: string | null;
|
|
@@ -751,3 +785,23 @@ export interface V2GrantCreditResult {
|
|
|
751
785
|
object: "grant_credit_result";
|
|
752
786
|
new_balance_cents: number;
|
|
753
787
|
}
|
|
788
|
+
|
|
789
|
+
// --- Email ---
|
|
790
|
+
|
|
791
|
+
export interface V2EmailSendParams {
|
|
792
|
+
to: string | string[];
|
|
793
|
+
subject: string;
|
|
794
|
+
html?: string;
|
|
795
|
+
text?: string;
|
|
796
|
+
from?: string;
|
|
797
|
+
reply_to?: string;
|
|
798
|
+
cc?: string | string[];
|
|
799
|
+
bcc?: string | string[];
|
|
800
|
+
}
|
|
801
|
+
|
|
802
|
+
export interface V2EmailSendResult {
|
|
803
|
+
object: "email";
|
|
804
|
+
id: string | null;
|
|
805
|
+
status: "sent";
|
|
806
|
+
to: string | string[];
|
|
807
|
+
}
|