perspectapi-ts-sdk 7.0.0 → 7.0.1
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-MZ22HQBX.mjs} +63 -5
- package/dist/{index-CWvUyMt3.d.mts → index-BL9-AZpq.d.mts} +4 -1
- package/dist/{index-CWvUyMt3.d.ts → index-BL9-AZpq.d.ts} +4 -1
- package/dist/index.d.mts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +63 -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 +63 -5
- package/dist/v2/index.mjs +1 -1
- package/package.json +1 -1
- package/src/v2/client/orders-client.ts +83 -5
|
@@ -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,41 @@ 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
|
+
withOrderTags(siteName, cachePolicy, options = {}) {
|
|
961
|
+
const tags = new Set(cachePolicy?.tags ?? []);
|
|
962
|
+
for (const tag of this.buildOrderTags(siteName, options)) {
|
|
963
|
+
tags.add(tag);
|
|
964
|
+
}
|
|
965
|
+
return {
|
|
966
|
+
...cachePolicy,
|
|
967
|
+
tags: Array.from(tags)
|
|
968
|
+
};
|
|
969
|
+
}
|
|
970
|
+
buildOrderTags(siteName, options = {}) {
|
|
971
|
+
const tags = /* @__PURE__ */ new Set(["orders", `orders:site:${siteName}`]);
|
|
972
|
+
if (options.id) {
|
|
973
|
+
tags.add(`orders:id:${options.id}`);
|
|
974
|
+
}
|
|
975
|
+
const fulfillmentStatus = this.normalizeTagPart(options.fulfillmentStatus);
|
|
976
|
+
if (fulfillmentStatus) {
|
|
977
|
+
tags.add(`orders:fulfillment:${siteName}:${fulfillmentStatus}`);
|
|
978
|
+
}
|
|
979
|
+
return Array.from(tags);
|
|
980
|
+
}
|
|
981
|
+
normalizeTagPart(value) {
|
|
982
|
+
if (!value) return null;
|
|
983
|
+
const normalized = value.trim().toLowerCase().replace(/[^a-z0-9_-]+/g, "-");
|
|
984
|
+
return normalized || null;
|
|
927
985
|
}
|
|
928
986
|
};
|
|
929
987
|
|
|
@@ -1941,7 +1941,7 @@ declare class CollectionsV2Client extends BaseV2Client {
|
|
|
1941
1941
|
|
|
1942
1942
|
declare class OrdersV2Client extends BaseV2Client {
|
|
1943
1943
|
list(siteName: string, params?: V2OrderListParams, cachePolicy?: CachePolicy): Promise<V2List<V2Order>>;
|
|
1944
|
-
listAutoPaginated(siteName: string, params?: Omit<V2OrderListParams, 'starting_after' | 'ending_before'
|
|
1944
|
+
listAutoPaginated(siteName: string, params?: Omit<V2OrderListParams, 'starting_after' | 'ending_before'>, cachePolicy?: CachePolicy): AsyncGenerator<V2Order, void, unknown>;
|
|
1945
1945
|
get(siteName: string, id: string, cachePolicy?: CachePolicy): Promise<V2Order>;
|
|
1946
1946
|
/**
|
|
1947
1947
|
* Create a checkout session via Stripe. Returns the session ID and a
|
|
@@ -1958,6 +1958,9 @@ declare class OrdersV2Client extends BaseV2Client {
|
|
|
1958
1958
|
* fulfillment state to send the customer fulfillment email.
|
|
1959
1959
|
*/
|
|
1960
1960
|
updateFulfillment(siteName: string, id: string, data: V2OrderFulfillmentUpdate): Promise<V2Order>;
|
|
1961
|
+
private withOrderTags;
|
|
1962
|
+
private buildOrderTags;
|
|
1963
|
+
private normalizeTagPart;
|
|
1961
1964
|
}
|
|
1962
1965
|
|
|
1963
1966
|
/**
|
|
@@ -1941,7 +1941,7 @@ declare class CollectionsV2Client extends BaseV2Client {
|
|
|
1941
1941
|
|
|
1942
1942
|
declare class OrdersV2Client extends BaseV2Client {
|
|
1943
1943
|
list(siteName: string, params?: V2OrderListParams, cachePolicy?: CachePolicy): Promise<V2List<V2Order>>;
|
|
1944
|
-
listAutoPaginated(siteName: string, params?: Omit<V2OrderListParams, 'starting_after' | 'ending_before'
|
|
1944
|
+
listAutoPaginated(siteName: string, params?: Omit<V2OrderListParams, 'starting_after' | 'ending_before'>, cachePolicy?: CachePolicy): AsyncGenerator<V2Order, void, unknown>;
|
|
1945
1945
|
get(siteName: string, id: string, cachePolicy?: CachePolicy): Promise<V2Order>;
|
|
1946
1946
|
/**
|
|
1947
1947
|
* Create a checkout session via Stripe. Returns the session ID and a
|
|
@@ -1958,6 +1958,9 @@ declare class OrdersV2Client extends BaseV2Client {
|
|
|
1958
1958
|
* fulfillment state to send the customer fulfillment email.
|
|
1959
1959
|
*/
|
|
1960
1960
|
updateFulfillment(siteName: string, id: string, data: V2OrderFulfillmentUpdate): Promise<V2Order>;
|
|
1961
|
+
private withOrderTags;
|
|
1962
|
+
private buildOrderTags;
|
|
1963
|
+
private normalizeTagPart;
|
|
1961
1964
|
}
|
|
1962
1965
|
|
|
1963
1966
|
/**
|
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, b$ as CheckoutMetadataValue, c4 as CheckoutSessionTax, c3 as CheckoutTaxBreakdownItem, c2 as CheckoutTaxCustomerExemptionRequest, c1 as CheckoutTaxExemptionStatus, c0 as CheckoutTaxStrategy, bV as ContentStatus, bW as ContentType, bZ as CreatePaymentGatewayRequest, c6 as CreditTransaction, c7 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, bU as PaginationParams, aH as PaymentGateway, aC as PerspectApiError, ay as PerspectApiV2Client, aA as PerspectV2Error, bX as ProductSkuMediaItem, bY as ProductSkuOption, c8 as RequestOptions, aQ as SetProfileValueRequest, c5 as SubscriptionCancellationMode, bE as V2ApiKey, bP as V2CancelSubscriptionResult, b4 as V2Category, b5 as V2CategoryCreateParams, b6 as V2CategoryUpdateParams, b7 as V2Collection, b9 as V2CollectionCreateParams, b8 as V2CollectionItem, ba as V2CollectionUpdateParams, bB as V2ContactSubmission, aY as V2Content, aZ as V2ContentCreateParams, a$ as V2ContentListParams, a_ as V2ContentUpdateParams, bR as V2CreditBalance, bQ as V2CreditTransaction, aT as V2Deleted, aU as V2Error, aV as V2ErrorType, bS as V2GrantCreditParams, bT as V2GrantCreditResult, aS as V2List, aX as V2Media, bs as V2NewsletterCampaign, bz as V2NewsletterImportRequest, bA as V2NewsletterImportResult, br as V2NewsletterList, bu as V2NewsletterListCreateParams, bv as V2NewsletterListUpdateParams, bq as V2NewsletterSubscription, by as V2NewsletterSubscriptionListMembershipUpdate, bw as V2NewsletterSyncInput, bx as V2NewsletterSyncResult, bt as V2NewsletterTrackingResponse, aR as V2Object, bb as V2Order, bf as V2OrderAddress, bh as V2OrderCreateParams, bj as V2OrderCreateResult, bi as V2OrderFulfillmentUpdate, be as V2OrderLineItem, bd as V2OrderLineItemPriceData, bc as V2OrderListParams, bg as V2OrderTaxRequest, bC as V2Organization, aW as V2PaginationParams, b0 as V2Product, b1 as V2ProductCreateParams, b3 as V2ProductListParams, b2 as V2ProductUpdateParams, bD as V2Site, bk as V2SiteUser, bn as V2SiteUserListParams, bm as V2SiteUserMeUpdateParams, bp as V2SiteUserProfile, bJ as V2SiteUserSubscription, bl as V2SiteUserUpdateParams, bo as V2SiteUserWithProfile, bL as V2SubscriptionCancelParams, bM as V2SubscriptionChangePlanParams, bN as V2SubscriptionChargeParams, bO as V2SubscriptionChargeResult, bK as V2SubscriptionPauseParams, bG as V2Webhook, bH as V2WebhookCreateParams, bF as V2WebhookEventType, bI as V2WebhookUpdateParams, b_ as WebhookEventType, aB as createApiError, az as createPerspectApiV2Client } from './index-
|
|
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-BL9-AZpq.mjs';
|
|
2
|
+
export { aE as ApiError, aD as CacheConfig, aG as CategorySummary, b$ as CheckoutMetadataValue, c4 as CheckoutSessionTax, c3 as CheckoutTaxBreakdownItem, c2 as CheckoutTaxCustomerExemptionRequest, c1 as CheckoutTaxExemptionStatus, c0 as CheckoutTaxStrategy, bV as ContentStatus, bW as ContentType, bZ as CreatePaymentGatewayRequest, c6 as CreditTransaction, c7 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, bU as PaginationParams, aH as PaymentGateway, aC as PerspectApiError, ay as PerspectApiV2Client, aA as PerspectV2Error, bX as ProductSkuMediaItem, bY as ProductSkuOption, c8 as RequestOptions, aQ as SetProfileValueRequest, c5 as SubscriptionCancellationMode, bE as V2ApiKey, bP as V2CancelSubscriptionResult, b4 as V2Category, b5 as V2CategoryCreateParams, b6 as V2CategoryUpdateParams, b7 as V2Collection, b9 as V2CollectionCreateParams, b8 as V2CollectionItem, ba as V2CollectionUpdateParams, bB as V2ContactSubmission, aY as V2Content, aZ as V2ContentCreateParams, a$ as V2ContentListParams, a_ as V2ContentUpdateParams, bR as V2CreditBalance, bQ as V2CreditTransaction, aT as V2Deleted, aU as V2Error, aV as V2ErrorType, bS as V2GrantCreditParams, bT as V2GrantCreditResult, aS as V2List, aX as V2Media, bs as V2NewsletterCampaign, bz as V2NewsletterImportRequest, bA as V2NewsletterImportResult, br as V2NewsletterList, bu as V2NewsletterListCreateParams, bv as V2NewsletterListUpdateParams, bq as V2NewsletterSubscription, by as V2NewsletterSubscriptionListMembershipUpdate, bw as V2NewsletterSyncInput, bx as V2NewsletterSyncResult, bt as V2NewsletterTrackingResponse, aR as V2Object, bb as V2Order, bf as V2OrderAddress, bh as V2OrderCreateParams, bj as V2OrderCreateResult, bi as V2OrderFulfillmentUpdate, be as V2OrderLineItem, bd as V2OrderLineItemPriceData, bc as V2OrderListParams, bg as V2OrderTaxRequest, bC as V2Organization, aW as V2PaginationParams, b0 as V2Product, b1 as V2ProductCreateParams, b3 as V2ProductListParams, b2 as V2ProductUpdateParams, bD as V2Site, bk as V2SiteUser, bn as V2SiteUserListParams, bm as V2SiteUserMeUpdateParams, bp as V2SiteUserProfile, bJ as V2SiteUserSubscription, bl as V2SiteUserUpdateParams, bo as V2SiteUserWithProfile, bL as V2SubscriptionCancelParams, bM as V2SubscriptionChangePlanParams, bN as V2SubscriptionChargeParams, bO as V2SubscriptionChargeResult, bK as V2SubscriptionPauseParams, bG as V2Webhook, bH as V2WebhookCreateParams, bF as V2WebhookEventType, bI as V2WebhookUpdateParams, b_ as WebhookEventType, aB as createApiError, az as createPerspectApiV2Client } from './index-BL9-AZpq.mjs';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* v1 deprecation constants — kept in sync with the backend's
|
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, b$ as CheckoutMetadataValue, c4 as CheckoutSessionTax, c3 as CheckoutTaxBreakdownItem, c2 as CheckoutTaxCustomerExemptionRequest, c1 as CheckoutTaxExemptionStatus, c0 as CheckoutTaxStrategy, bV as ContentStatus, bW as ContentType, bZ as CreatePaymentGatewayRequest, c6 as CreditTransaction, c7 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, bU as PaginationParams, aH as PaymentGateway, aC as PerspectApiError, ay as PerspectApiV2Client, aA as PerspectV2Error, bX as ProductSkuMediaItem, bY as ProductSkuOption, c8 as RequestOptions, aQ as SetProfileValueRequest, c5 as SubscriptionCancellationMode, bE as V2ApiKey, bP as V2CancelSubscriptionResult, b4 as V2Category, b5 as V2CategoryCreateParams, b6 as V2CategoryUpdateParams, b7 as V2Collection, b9 as V2CollectionCreateParams, b8 as V2CollectionItem, ba as V2CollectionUpdateParams, bB as V2ContactSubmission, aY as V2Content, aZ as V2ContentCreateParams, a$ as V2ContentListParams, a_ as V2ContentUpdateParams, bR as V2CreditBalance, bQ as V2CreditTransaction, aT as V2Deleted, aU as V2Error, aV as V2ErrorType, bS as V2GrantCreditParams, bT as V2GrantCreditResult, aS as V2List, aX as V2Media, bs as V2NewsletterCampaign, bz as V2NewsletterImportRequest, bA as V2NewsletterImportResult, br as V2NewsletterList, bu as V2NewsletterListCreateParams, bv as V2NewsletterListUpdateParams, bq as V2NewsletterSubscription, by as V2NewsletterSubscriptionListMembershipUpdate, bw as V2NewsletterSyncInput, bx as V2NewsletterSyncResult, bt as V2NewsletterTrackingResponse, aR as V2Object, bb as V2Order, bf as V2OrderAddress, bh as V2OrderCreateParams, bj as V2OrderCreateResult, bi as V2OrderFulfillmentUpdate, be as V2OrderLineItem, bd as V2OrderLineItemPriceData, bc as V2OrderListParams, bg as V2OrderTaxRequest, bC as V2Organization, aW as V2PaginationParams, b0 as V2Product, b1 as V2ProductCreateParams, b3 as V2ProductListParams, b2 as V2ProductUpdateParams, bD as V2Site, bk as V2SiteUser, bn as V2SiteUserListParams, bm as V2SiteUserMeUpdateParams, bp as V2SiteUserProfile, bJ as V2SiteUserSubscription, bl as V2SiteUserUpdateParams, bo as V2SiteUserWithProfile, bL as V2SubscriptionCancelParams, bM as V2SubscriptionChangePlanParams, bN as V2SubscriptionChargeParams, bO as V2SubscriptionChargeResult, bK as V2SubscriptionPauseParams, bG as V2Webhook, bH as V2WebhookCreateParams, bF as V2WebhookEventType, bI as V2WebhookUpdateParams, b_ as WebhookEventType, aB as createApiError, az as createPerspectApiV2Client } from './index-
|
|
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-BL9-AZpq.js';
|
|
2
|
+
export { aE as ApiError, aD as CacheConfig, aG as CategorySummary, b$ as CheckoutMetadataValue, c4 as CheckoutSessionTax, c3 as CheckoutTaxBreakdownItem, c2 as CheckoutTaxCustomerExemptionRequest, c1 as CheckoutTaxExemptionStatus, c0 as CheckoutTaxStrategy, bV as ContentStatus, bW as ContentType, bZ as CreatePaymentGatewayRequest, c6 as CreditTransaction, c7 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, bU as PaginationParams, aH as PaymentGateway, aC as PerspectApiError, ay as PerspectApiV2Client, aA as PerspectV2Error, bX as ProductSkuMediaItem, bY as ProductSkuOption, c8 as RequestOptions, aQ as SetProfileValueRequest, c5 as SubscriptionCancellationMode, bE as V2ApiKey, bP as V2CancelSubscriptionResult, b4 as V2Category, b5 as V2CategoryCreateParams, b6 as V2CategoryUpdateParams, b7 as V2Collection, b9 as V2CollectionCreateParams, b8 as V2CollectionItem, ba as V2CollectionUpdateParams, bB as V2ContactSubmission, aY as V2Content, aZ as V2ContentCreateParams, a$ as V2ContentListParams, a_ as V2ContentUpdateParams, bR as V2CreditBalance, bQ as V2CreditTransaction, aT as V2Deleted, aU as V2Error, aV as V2ErrorType, bS as V2GrantCreditParams, bT as V2GrantCreditResult, aS as V2List, aX as V2Media, bs as V2NewsletterCampaign, bz as V2NewsletterImportRequest, bA as V2NewsletterImportResult, br as V2NewsletterList, bu as V2NewsletterListCreateParams, bv as V2NewsletterListUpdateParams, bq as V2NewsletterSubscription, by as V2NewsletterSubscriptionListMembershipUpdate, bw as V2NewsletterSyncInput, bx as V2NewsletterSyncResult, bt as V2NewsletterTrackingResponse, aR as V2Object, bb as V2Order, bf as V2OrderAddress, bh as V2OrderCreateParams, bj as V2OrderCreateResult, bi as V2OrderFulfillmentUpdate, be as V2OrderLineItem, bd as V2OrderLineItemPriceData, bc as V2OrderListParams, bg as V2OrderTaxRequest, bC as V2Organization, aW as V2PaginationParams, b0 as V2Product, b1 as V2ProductCreateParams, b3 as V2ProductListParams, b2 as V2ProductUpdateParams, bD as V2Site, bk as V2SiteUser, bn as V2SiteUserListParams, bm as V2SiteUserMeUpdateParams, bp as V2SiteUserProfile, bJ as V2SiteUserSubscription, bl as V2SiteUserUpdateParams, bo as V2SiteUserWithProfile, bL as V2SubscriptionCancelParams, bM as V2SubscriptionChangePlanParams, bN as V2SubscriptionChargeParams, bO as V2SubscriptionChargeResult, bK as V2SubscriptionPauseParams, bG as V2Webhook, bH as V2WebhookCreateParams, bF as V2WebhookEventType, bI as V2WebhookUpdateParams, b_ as WebhookEventType, aB as createApiError, az as createPerspectApiV2Client } from './index-BL9-AZpq.js';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* v1 deprecation constants — kept in sync with the backend's
|
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,41 @@ 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
|
+
withOrderTags(siteName, cachePolicy, options = {}) {
|
|
1047
|
+
const tags = new Set(cachePolicy?.tags ?? []);
|
|
1048
|
+
for (const tag of this.buildOrderTags(siteName, options)) {
|
|
1049
|
+
tags.add(tag);
|
|
1050
|
+
}
|
|
1051
|
+
return {
|
|
1052
|
+
...cachePolicy,
|
|
1053
|
+
tags: Array.from(tags)
|
|
1054
|
+
};
|
|
1055
|
+
}
|
|
1056
|
+
buildOrderTags(siteName, options = {}) {
|
|
1057
|
+
const tags = /* @__PURE__ */ new Set(["orders", `orders:site:${siteName}`]);
|
|
1058
|
+
if (options.id) {
|
|
1059
|
+
tags.add(`orders:id:${options.id}`);
|
|
1060
|
+
}
|
|
1061
|
+
const fulfillmentStatus = this.normalizeTagPart(options.fulfillmentStatus);
|
|
1062
|
+
if (fulfillmentStatus) {
|
|
1063
|
+
tags.add(`orders:fulfillment:${siteName}:${fulfillmentStatus}`);
|
|
1064
|
+
}
|
|
1065
|
+
return Array.from(tags);
|
|
1066
|
+
}
|
|
1067
|
+
normalizeTagPart(value) {
|
|
1068
|
+
if (!value) return null;
|
|
1069
|
+
const normalized = value.trim().toLowerCase().replace(/[^a-z0-9_-]+/g, "-");
|
|
1070
|
+
return normalized || null;
|
|
1013
1071
|
}
|
|
1014
1072
|
};
|
|
1015
1073
|
|
package/dist/index.mjs
CHANGED
package/dist/v2/index.d.mts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { cl as ApiKeysV2Client, ca as BaseV2Client, cd as CategoriesV2Client, ce as CollectionsV2Client, ci as ContactsV2Client, cb as ContentV2Client, co as CreditsV2Client, ch as NewsletterV2Client, cf as OrdersV2Client, cj as OrganizationsV2Client, ay as PerspectApiV2Client, c9 as PerspectApiV2Config, aA as PerspectV2Error, cc as ProductsV2Client, cg as SiteUsersV2Client, ck as SitesV2Client, cn as SubscriptionsV2Client, bE as V2ApiKey, bP as V2CancelSubscriptionResult, b4 as V2Category, b5 as V2CategoryCreateParams, b6 as V2CategoryUpdateParams, b7 as V2Collection, b9 as V2CollectionCreateParams, b8 as V2CollectionItem, ba as V2CollectionUpdateParams, bB as V2ContactSubmission, aY as V2Content, aZ as V2ContentCreateParams, a$ as V2ContentListParams, a_ as V2ContentUpdateParams, bR as V2CreditBalance, bQ as V2CreditTransaction, aT as V2Deleted, aU as V2Error, aV as V2ErrorType, bS as V2GrantCreditParams, bT as V2GrantCreditResult, aS as V2List, aX as V2Media, bs as V2NewsletterCampaign, bz as V2NewsletterImportRequest, bA as V2NewsletterImportResult, br as V2NewsletterList, bu as V2NewsletterListCreateParams, bv as V2NewsletterListUpdateParams, bq as V2NewsletterSubscription, by as V2NewsletterSubscriptionListMembershipUpdate, bw as V2NewsletterSyncInput, bx as V2NewsletterSyncResult, bt as V2NewsletterTrackingResponse, aR as V2Object, bb as V2Order, bf as V2OrderAddress, bh as V2OrderCreateParams, bj as V2OrderCreateResult, bi as V2OrderFulfillmentUpdate, be as V2OrderLineItem, bd as V2OrderLineItemPriceData, bc as V2OrderListParams, bg as V2OrderTaxRequest, bC as V2Organization, aW as V2PaginationParams, b0 as V2Product, b1 as V2ProductCreateParams, b3 as V2ProductListParams, b2 as V2ProductUpdateParams, bD as V2Site, bk as V2SiteUser, bn as V2SiteUserListParams, bm as V2SiteUserMeUpdateParams, bp as V2SiteUserProfile, bJ as V2SiteUserSubscription, bl as V2SiteUserUpdateParams, bo as V2SiteUserWithProfile, bL as V2SubscriptionCancelParams, bM as V2SubscriptionChangePlanParams, bN as V2SubscriptionChargeParams, bO as V2SubscriptionChargeResult, bK as V2SubscriptionPauseParams, bG as V2Webhook, bH as V2WebhookCreateParams, bF as V2WebhookEventType, bI as V2WebhookUpdateParams, cm as WebhooksV2Client, az as createPerspectApiV2Client } from '../index-
|
|
1
|
+
export { cl as ApiKeysV2Client, ca as BaseV2Client, cd as CategoriesV2Client, ce as CollectionsV2Client, ci as ContactsV2Client, cb as ContentV2Client, co as CreditsV2Client, ch as NewsletterV2Client, cf as OrdersV2Client, cj as OrganizationsV2Client, ay as PerspectApiV2Client, c9 as PerspectApiV2Config, aA as PerspectV2Error, cc as ProductsV2Client, cg as SiteUsersV2Client, ck as SitesV2Client, cn as SubscriptionsV2Client, bE as V2ApiKey, bP as V2CancelSubscriptionResult, b4 as V2Category, b5 as V2CategoryCreateParams, b6 as V2CategoryUpdateParams, b7 as V2Collection, b9 as V2CollectionCreateParams, b8 as V2CollectionItem, ba as V2CollectionUpdateParams, bB as V2ContactSubmission, aY as V2Content, aZ as V2ContentCreateParams, a$ as V2ContentListParams, a_ as V2ContentUpdateParams, bR as V2CreditBalance, bQ as V2CreditTransaction, aT as V2Deleted, aU as V2Error, aV as V2ErrorType, bS as V2GrantCreditParams, bT as V2GrantCreditResult, aS as V2List, aX as V2Media, bs as V2NewsletterCampaign, bz as V2NewsletterImportRequest, bA as V2NewsletterImportResult, br as V2NewsletterList, bu as V2NewsletterListCreateParams, bv as V2NewsletterListUpdateParams, bq as V2NewsletterSubscription, by as V2NewsletterSubscriptionListMembershipUpdate, bw as V2NewsletterSyncInput, bx as V2NewsletterSyncResult, bt as V2NewsletterTrackingResponse, aR as V2Object, bb as V2Order, bf as V2OrderAddress, bh as V2OrderCreateParams, bj as V2OrderCreateResult, bi as V2OrderFulfillmentUpdate, be as V2OrderLineItem, bd as V2OrderLineItemPriceData, bc as V2OrderListParams, bg as V2OrderTaxRequest, bC as V2Organization, aW as V2PaginationParams, b0 as V2Product, b1 as V2ProductCreateParams, b3 as V2ProductListParams, b2 as V2ProductUpdateParams, bD as V2Site, bk as V2SiteUser, bn as V2SiteUserListParams, bm as V2SiteUserMeUpdateParams, bp as V2SiteUserProfile, bJ as V2SiteUserSubscription, bl as V2SiteUserUpdateParams, bo as V2SiteUserWithProfile, bL as V2SubscriptionCancelParams, bM as V2SubscriptionChangePlanParams, bN as V2SubscriptionChargeParams, bO as V2SubscriptionChargeResult, bK as V2SubscriptionPauseParams, bG as V2Webhook, bH as V2WebhookCreateParams, bF as V2WebhookEventType, bI as V2WebhookUpdateParams, cm as WebhooksV2Client, az as createPerspectApiV2Client } from '../index-BL9-AZpq.mjs';
|
package/dist/v2/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { cl as ApiKeysV2Client, ca as BaseV2Client, cd as CategoriesV2Client, ce as CollectionsV2Client, ci as ContactsV2Client, cb as ContentV2Client, co as CreditsV2Client, ch as NewsletterV2Client, cf as OrdersV2Client, cj as OrganizationsV2Client, ay as PerspectApiV2Client, c9 as PerspectApiV2Config, aA as PerspectV2Error, cc as ProductsV2Client, cg as SiteUsersV2Client, ck as SitesV2Client, cn as SubscriptionsV2Client, bE as V2ApiKey, bP as V2CancelSubscriptionResult, b4 as V2Category, b5 as V2CategoryCreateParams, b6 as V2CategoryUpdateParams, b7 as V2Collection, b9 as V2CollectionCreateParams, b8 as V2CollectionItem, ba as V2CollectionUpdateParams, bB as V2ContactSubmission, aY as V2Content, aZ as V2ContentCreateParams, a$ as V2ContentListParams, a_ as V2ContentUpdateParams, bR as V2CreditBalance, bQ as V2CreditTransaction, aT as V2Deleted, aU as V2Error, aV as V2ErrorType, bS as V2GrantCreditParams, bT as V2GrantCreditResult, aS as V2List, aX as V2Media, bs as V2NewsletterCampaign, bz as V2NewsletterImportRequest, bA as V2NewsletterImportResult, br as V2NewsletterList, bu as V2NewsletterListCreateParams, bv as V2NewsletterListUpdateParams, bq as V2NewsletterSubscription, by as V2NewsletterSubscriptionListMembershipUpdate, bw as V2NewsletterSyncInput, bx as V2NewsletterSyncResult, bt as V2NewsletterTrackingResponse, aR as V2Object, bb as V2Order, bf as V2OrderAddress, bh as V2OrderCreateParams, bj as V2OrderCreateResult, bi as V2OrderFulfillmentUpdate, be as V2OrderLineItem, bd as V2OrderLineItemPriceData, bc as V2OrderListParams, bg as V2OrderTaxRequest, bC as V2Organization, aW as V2PaginationParams, b0 as V2Product, b1 as V2ProductCreateParams, b3 as V2ProductListParams, b2 as V2ProductUpdateParams, bD as V2Site, bk as V2SiteUser, bn as V2SiteUserListParams, bm as V2SiteUserMeUpdateParams, bp as V2SiteUserProfile, bJ as V2SiteUserSubscription, bl as V2SiteUserUpdateParams, bo as V2SiteUserWithProfile, bL as V2SubscriptionCancelParams, bM as V2SubscriptionChangePlanParams, bN as V2SubscriptionChargeParams, bO as V2SubscriptionChargeResult, bK as V2SubscriptionPauseParams, bG as V2Webhook, bH as V2WebhookCreateParams, bF as V2WebhookEventType, bI as V2WebhookUpdateParams, cm as WebhooksV2Client, az as createPerspectApiV2Client } from '../index-
|
|
1
|
+
export { cl as ApiKeysV2Client, ca as BaseV2Client, cd as CategoriesV2Client, ce as CollectionsV2Client, ci as ContactsV2Client, cb as ContentV2Client, co as CreditsV2Client, ch as NewsletterV2Client, cf as OrdersV2Client, cj as OrganizationsV2Client, ay as PerspectApiV2Client, c9 as PerspectApiV2Config, aA as PerspectV2Error, cc as ProductsV2Client, cg as SiteUsersV2Client, ck as SitesV2Client, cn as SubscriptionsV2Client, bE as V2ApiKey, bP as V2CancelSubscriptionResult, b4 as V2Category, b5 as V2CategoryCreateParams, b6 as V2CategoryUpdateParams, b7 as V2Collection, b9 as V2CollectionCreateParams, b8 as V2CollectionItem, ba as V2CollectionUpdateParams, bB as V2ContactSubmission, aY as V2Content, aZ as V2ContentCreateParams, a$ as V2ContentListParams, a_ as V2ContentUpdateParams, bR as V2CreditBalance, bQ as V2CreditTransaction, aT as V2Deleted, aU as V2Error, aV as V2ErrorType, bS as V2GrantCreditParams, bT as V2GrantCreditResult, aS as V2List, aX as V2Media, bs as V2NewsletterCampaign, bz as V2NewsletterImportRequest, bA as V2NewsletterImportResult, br as V2NewsletterList, bu as V2NewsletterListCreateParams, bv as V2NewsletterListUpdateParams, bq as V2NewsletterSubscription, by as V2NewsletterSubscriptionListMembershipUpdate, bw as V2NewsletterSyncInput, bx as V2NewsletterSyncResult, bt as V2NewsletterTrackingResponse, aR as V2Object, bb as V2Order, bf as V2OrderAddress, bh as V2OrderCreateParams, bj as V2OrderCreateResult, bi as V2OrderFulfillmentUpdate, be as V2OrderLineItem, bd as V2OrderLineItemPriceData, bc as V2OrderListParams, bg as V2OrderTaxRequest, bC as V2Organization, aW as V2PaginationParams, b0 as V2Product, b1 as V2ProductCreateParams, b3 as V2ProductListParams, b2 as V2ProductUpdateParams, bD as V2Site, bk as V2SiteUser, bn as V2SiteUserListParams, bm as V2SiteUserMeUpdateParams, bp as V2SiteUserProfile, bJ as V2SiteUserSubscription, bl as V2SiteUserUpdateParams, bo as V2SiteUserWithProfile, bL as V2SubscriptionCancelParams, bM as V2SubscriptionChangePlanParams, bN as V2SubscriptionChargeParams, bO as V2SubscriptionChargeResult, bK as V2SubscriptionPauseParams, bG as V2Webhook, bH as V2WebhookCreateParams, bF as V2WebhookEventType, bI as V2WebhookUpdateParams, cm as WebhooksV2Client, az as createPerspectApiV2Client } from '../index-BL9-AZpq.js';
|
package/dist/v2/index.js
CHANGED
|
@@ -923,13 +923,40 @@ var CollectionsV2Client = class extends BaseV2Client {
|
|
|
923
923
|
// src/v2/client/orders-client.ts
|
|
924
924
|
var OrdersV2Client = class extends BaseV2Client {
|
|
925
925
|
async list(siteName, params, cachePolicy) {
|
|
926
|
-
return this.getList(
|
|
926
|
+
return this.getList(
|
|
927
|
+
this.sitePath(siteName, "orders"),
|
|
928
|
+
params,
|
|
929
|
+
this.withOrderTags(siteName, cachePolicy, {
|
|
930
|
+
fulfillmentStatus: params?.fulfillment_status
|
|
931
|
+
})
|
|
932
|
+
);
|
|
927
933
|
}
|
|
928
|
-
async *listAutoPaginated(siteName, params) {
|
|
929
|
-
|
|
934
|
+
async *listAutoPaginated(siteName, params, cachePolicy) {
|
|
935
|
+
let startingAfter;
|
|
936
|
+
let hasMore = true;
|
|
937
|
+
while (hasMore) {
|
|
938
|
+
const queryParams = { ...params ?? {} };
|
|
939
|
+
if (startingAfter) {
|
|
940
|
+
queryParams.starting_after = startingAfter;
|
|
941
|
+
}
|
|
942
|
+
const page = await this.list(siteName, queryParams, cachePolicy);
|
|
943
|
+
for (const item of page.data) {
|
|
944
|
+
yield item;
|
|
945
|
+
}
|
|
946
|
+
hasMore = page.has_more;
|
|
947
|
+
if (page.data.length > 0) {
|
|
948
|
+
startingAfter = page.data[page.data.length - 1].id;
|
|
949
|
+
} else {
|
|
950
|
+
hasMore = false;
|
|
951
|
+
}
|
|
952
|
+
}
|
|
930
953
|
}
|
|
931
954
|
async get(siteName, id, cachePolicy) {
|
|
932
|
-
return this.getOne(
|
|
955
|
+
return this.getOne(
|
|
956
|
+
this.sitePath(siteName, "orders", id),
|
|
957
|
+
void 0,
|
|
958
|
+
this.withOrderTags(siteName, cachePolicy, { id })
|
|
959
|
+
);
|
|
933
960
|
}
|
|
934
961
|
/**
|
|
935
962
|
* Create a checkout session via Stripe. Returns the session ID and a
|
|
@@ -951,10 +978,41 @@ var OrdersV2Client = class extends BaseV2Client {
|
|
|
951
978
|
* fulfillment state to send the customer fulfillment email.
|
|
952
979
|
*/
|
|
953
980
|
async updateFulfillment(siteName, id, data) {
|
|
954
|
-
|
|
981
|
+
const result = await this.patchOne(
|
|
955
982
|
this.sitePath(siteName, "orders", `${id}/fulfillment`),
|
|
956
983
|
data
|
|
957
984
|
);
|
|
985
|
+
await this.invalidateCache({
|
|
986
|
+
tags: this.buildOrderTags(siteName, { id }),
|
|
987
|
+
keys: [this.sitePath(siteName, "orders", id)]
|
|
988
|
+
});
|
|
989
|
+
return result;
|
|
990
|
+
}
|
|
991
|
+
withOrderTags(siteName, cachePolicy, options = {}) {
|
|
992
|
+
const tags = new Set(cachePolicy?.tags ?? []);
|
|
993
|
+
for (const tag of this.buildOrderTags(siteName, options)) {
|
|
994
|
+
tags.add(tag);
|
|
995
|
+
}
|
|
996
|
+
return {
|
|
997
|
+
...cachePolicy,
|
|
998
|
+
tags: Array.from(tags)
|
|
999
|
+
};
|
|
1000
|
+
}
|
|
1001
|
+
buildOrderTags(siteName, options = {}) {
|
|
1002
|
+
const tags = /* @__PURE__ */ new Set(["orders", `orders:site:${siteName}`]);
|
|
1003
|
+
if (options.id) {
|
|
1004
|
+
tags.add(`orders:id:${options.id}`);
|
|
1005
|
+
}
|
|
1006
|
+
const fulfillmentStatus = this.normalizeTagPart(options.fulfillmentStatus);
|
|
1007
|
+
if (fulfillmentStatus) {
|
|
1008
|
+
tags.add(`orders:fulfillment:${siteName}:${fulfillmentStatus}`);
|
|
1009
|
+
}
|
|
1010
|
+
return Array.from(tags);
|
|
1011
|
+
}
|
|
1012
|
+
normalizeTagPart(value) {
|
|
1013
|
+
if (!value) return null;
|
|
1014
|
+
const normalized = value.trim().toLowerCase().replace(/[^a-z0-9_-]+/g, "-");
|
|
1015
|
+
return normalized || null;
|
|
958
1016
|
}
|
|
959
1017
|
};
|
|
960
1018
|
|
package/dist/v2/index.mjs
CHANGED
package/package.json
CHANGED
|
@@ -19,15 +19,49 @@ import type {
|
|
|
19
19
|
export class OrdersV2Client extends BaseV2Client {
|
|
20
20
|
|
|
21
21
|
async list(siteName: string, params?: V2OrderListParams, cachePolicy?: CachePolicy): Promise<V2List<V2Order>> {
|
|
22
|
-
return this.getList<V2Order>(
|
|
22
|
+
return this.getList<V2Order>(
|
|
23
|
+
this.sitePath(siteName, 'orders'),
|
|
24
|
+
params,
|
|
25
|
+
this.withOrderTags(siteName, cachePolicy, {
|
|
26
|
+
fulfillmentStatus: params?.fulfillment_status,
|
|
27
|
+
}),
|
|
28
|
+
);
|
|
23
29
|
}
|
|
24
30
|
|
|
25
|
-
async *listAutoPaginated(
|
|
26
|
-
|
|
31
|
+
async *listAutoPaginated(
|
|
32
|
+
siteName: string,
|
|
33
|
+
params?: Omit<V2OrderListParams, 'starting_after' | 'ending_before'>,
|
|
34
|
+
cachePolicy?: CachePolicy,
|
|
35
|
+
) {
|
|
36
|
+
let startingAfter: string | undefined;
|
|
37
|
+
let hasMore = true;
|
|
38
|
+
|
|
39
|
+
while (hasMore) {
|
|
40
|
+
const queryParams: V2OrderListParams = { ...(params ?? {}) };
|
|
41
|
+
if (startingAfter) {
|
|
42
|
+
queryParams.starting_after = startingAfter;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
const page = await this.list(siteName, queryParams, cachePolicy);
|
|
46
|
+
for (const item of page.data) {
|
|
47
|
+
yield item;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
hasMore = page.has_more;
|
|
51
|
+
if (page.data.length > 0) {
|
|
52
|
+
startingAfter = page.data[page.data.length - 1].id;
|
|
53
|
+
} else {
|
|
54
|
+
hasMore = false;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
27
57
|
}
|
|
28
58
|
|
|
29
59
|
async get(siteName: string, id: string, cachePolicy?: CachePolicy): Promise<V2Order> {
|
|
30
|
-
return this.getOne<V2Order>(
|
|
60
|
+
return this.getOne<V2Order>(
|
|
61
|
+
this.sitePath(siteName, 'orders', id),
|
|
62
|
+
undefined,
|
|
63
|
+
this.withOrderTags(siteName, cachePolicy, { id }),
|
|
64
|
+
);
|
|
31
65
|
}
|
|
32
66
|
|
|
33
67
|
/**
|
|
@@ -58,9 +92,53 @@ export class OrdersV2Client extends BaseV2Client {
|
|
|
58
92
|
id: string,
|
|
59
93
|
data: V2OrderFulfillmentUpdate,
|
|
60
94
|
): Promise<V2Order> {
|
|
61
|
-
|
|
95
|
+
const result = await this.patchOne<V2Order>(
|
|
62
96
|
this.sitePath(siteName, 'orders', `${id}/fulfillment`),
|
|
63
97
|
data,
|
|
64
98
|
);
|
|
99
|
+
await this.invalidateCache({
|
|
100
|
+
tags: this.buildOrderTags(siteName, { id }),
|
|
101
|
+
keys: [this.sitePath(siteName, 'orders', id)],
|
|
102
|
+
});
|
|
103
|
+
return result;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
private withOrderTags(
|
|
107
|
+
siteName: string,
|
|
108
|
+
cachePolicy: CachePolicy | undefined,
|
|
109
|
+
options: { id?: string; fulfillmentStatus?: string | null } = {},
|
|
110
|
+
): CachePolicy {
|
|
111
|
+
const tags = new Set<string>(cachePolicy?.tags ?? []);
|
|
112
|
+
for (const tag of this.buildOrderTags(siteName, options)) {
|
|
113
|
+
tags.add(tag);
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
return {
|
|
117
|
+
...cachePolicy,
|
|
118
|
+
tags: Array.from(tags),
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
private buildOrderTags(
|
|
123
|
+
siteName: string,
|
|
124
|
+
options: { id?: string; fulfillmentStatus?: string | null } = {},
|
|
125
|
+
): string[] {
|
|
126
|
+
const tags = new Set<string>(['orders', `orders:site:${siteName}`]);
|
|
127
|
+
if (options.id) {
|
|
128
|
+
tags.add(`orders:id:${options.id}`);
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
const fulfillmentStatus = this.normalizeTagPart(options.fulfillmentStatus);
|
|
132
|
+
if (fulfillmentStatus) {
|
|
133
|
+
tags.add(`orders:fulfillment:${siteName}:${fulfillmentStatus}`);
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
return Array.from(tags);
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
private normalizeTagPart(value?: string | null): string | null {
|
|
140
|
+
if (!value) return null;
|
|
141
|
+
const normalized = value.trim().toLowerCase().replace(/[^a-z0-9_-]+/g, '-');
|
|
142
|
+
return normalized || null;
|
|
65
143
|
}
|
|
66
144
|
}
|