@c1m-public/channel-client 5.0.0 → 6.0.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/README.md +22 -7
- package/dist/{chunk-7D26WVWG.js → chunk-4GSTY323.js} +1 -1
- package/dist/{chunk-654FCSVE.js → chunk-5ULF3TZJ.js} +28 -12
- package/dist/{chunk-K4WHHUTW.js → chunk-SFPJ6HJJ.js} +1 -1
- package/dist/dash-next.d.ts +1 -1
- package/dist/dash-next.js +3 -3
- package/dist/dash.d.ts +1 -1
- package/dist/dash.js +2 -2
- package/dist/index.d.ts +18 -10
- package/dist/index.js +1 -1
- package/dist/leads.d.ts +60 -0
- package/dist/leads.js +75 -0
- package/dist/next.d.ts +10 -4
- package/dist/next.js +2 -2
- package/dist/renderer.js +1 -1
- package/dist/site.d.ts +1 -1
- package/dist/{types-Ch86mCHw.d.ts → types-BedZ9_Y2.d.ts} +51 -3
- package/package.json +5 -1
package/README.md
CHANGED
|
@@ -34,7 +34,7 @@ Channel credentials resolve the tenant and scope at the API door (plus the
|
|
|
34
34
|
workspace for workspace-scoped channels), so site URLs never carry those
|
|
35
35
|
identifiers.
|
|
36
36
|
|
|
37
|
-
Managed C1M sites need one deployment secret: `
|
|
37
|
+
Managed C1M sites need one deployment secret: `SAASDASH_CHANNEL_TOKEN`. The client
|
|
38
38
|
uses `https://api.saasdash.app` by default. Pass `baseUrl` directly only for
|
|
39
39
|
local development or private C1M infrastructure; it is not part of the normal
|
|
40
40
|
deployment contract.
|
|
@@ -45,7 +45,7 @@ deployment contract.
|
|
|
45
45
|
import { createNextChannelClient } from "@c1m-public/channel-client/next";
|
|
46
46
|
|
|
47
47
|
const channel = createNextChannelClient({
|
|
48
|
-
token: process.env.
|
|
48
|
+
token: process.env.SAASDASH_CHANNEL_TOKEN!,
|
|
49
49
|
cache: { revalidate: 60 },
|
|
50
50
|
});
|
|
51
51
|
|
|
@@ -70,7 +70,7 @@ const checkout = await channel.checkout.pay(
|
|
|
70
70
|
import { createChannelClient } from "@c1m-public/channel-client";
|
|
71
71
|
|
|
72
72
|
const channel = createChannelClient({
|
|
73
|
-
token: process.env.
|
|
73
|
+
token: process.env.SAASDASH_CHANNEL_TOKEN!,
|
|
74
74
|
});
|
|
75
75
|
|
|
76
76
|
const category = await channel.categories.products("electric-cars");
|
|
@@ -109,6 +109,21 @@ const visitorChannel = channel.withVisitor({
|
|
|
109
109
|
const geo = await visitorChannel.geo.detect();
|
|
110
110
|
```
|
|
111
111
|
|
|
112
|
+
### Country-aware catalogue
|
|
113
|
+
|
|
114
|
+
The 5.1.0 SDK candidate adds three workspace-channel reads:
|
|
115
|
+
|
|
116
|
+
- `products.markets()` discovers the countries available on the channel.
|
|
117
|
+
- `products.listForCountry({ country: "IE" })` returns a product list and,
|
|
118
|
+
on compatible servers, a `browse` object with the selected market,
|
|
119
|
+
selector choices, and fallback country. An empty list can still carry
|
|
120
|
+
this context. Use discovery if the response omits it.
|
|
121
|
+
- `products.getForCountry(slug, "IE")` reads a product with its contextual price.
|
|
122
|
+
|
|
123
|
+
Render the price and currency returned by the API and use the market's
|
|
124
|
+
`can_purchase` flag for purchase controls. The Next.js client keeps these
|
|
125
|
+
reads out of the shared Data Cache.
|
|
126
|
+
|
|
112
127
|
### Canonical document renderer
|
|
113
128
|
|
|
114
129
|
The renderer owns safe mechanics, not presentation. A site supplies a registry
|
|
@@ -216,7 +231,7 @@ const { hold: current } = await bookings.holds.get(token);
|
|
|
216
231
|
|
|
217
232
|
```ts
|
|
218
233
|
const channel = createChannelClient({
|
|
219
|
-
token: process.env.
|
|
234
|
+
token: process.env.SAASDASH_CHANNEL_TOKEN!,
|
|
220
235
|
observe(event) {
|
|
221
236
|
console.info("c1m.channel", event);
|
|
222
237
|
},
|
|
@@ -231,7 +246,7 @@ Verify webhook requests before parsing or acting on their payload:
|
|
|
231
246
|
import { parseChannelWebhookEvent } from "@c1m-public/channel-client/webhooks";
|
|
232
247
|
|
|
233
248
|
const event = await parseChannelWebhookEvent(request, {
|
|
234
|
-
secret: process.env.
|
|
249
|
+
secret: process.env.SAASDASH_CHANNEL_WEBHOOK_SECRET!,
|
|
235
250
|
});
|
|
236
251
|
```
|
|
237
252
|
|
|
@@ -273,7 +288,7 @@ import { revalidatePath, revalidateTag } from "next/cache";
|
|
|
273
288
|
import { createChannelWebhookRoute } from "@c1m-public/channel-client/next";
|
|
274
289
|
|
|
275
290
|
export const POST = createChannelWebhookRoute({
|
|
276
|
-
secret: () => process.env.
|
|
291
|
+
secret: () => process.env.SAASDASH_CHANNEL_WEBHOOK_SECRET!,
|
|
277
292
|
invalidate: { revalidatePath, revalidateTag },
|
|
278
293
|
});
|
|
279
294
|
```
|
|
@@ -290,7 +305,7 @@ the classifier (`defaultChannelCacheTags` is exported to compose with).
|
|
|
290
305
|
|
|
291
306
|
```ts
|
|
292
307
|
const channel = createNextChannelClient({
|
|
293
|
-
token: process.env.
|
|
308
|
+
token: process.env.SAASDASH_CHANNEL_TOKEN!,
|
|
294
309
|
cache: { revalidate: 3600 }, // products.list() → tags ["channel:catalog"]
|
|
295
310
|
});
|
|
296
311
|
```
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { isChannelAPIError, createChannelClient } from './chunk-
|
|
1
|
+
import { isChannelAPIError, createChannelClient } from './chunk-5ULF3TZJ.js';
|
|
2
2
|
import { parseChannelWebhookEvent, isChannelWebhookVerificationError, isChannelWebhookEventType, ChannelConfigurationError } from './chunk-XPO7C3DW.js';
|
|
3
3
|
import 'server-only';
|
|
4
4
|
|
|
@@ -41,6 +41,9 @@ var TransportError = class extends Error {
|
|
|
41
41
|
function isTransportError(error) {
|
|
42
42
|
return error instanceof TransportError || typeof error === "object" && error !== null && error.name === "TransportError";
|
|
43
43
|
}
|
|
44
|
+
function detailsRecord(value) {
|
|
45
|
+
return typeof value === "object" && value !== null && !Array.isArray(value) ? value : void 0;
|
|
46
|
+
}
|
|
44
47
|
function positiveNumber(value, label, fail) {
|
|
45
48
|
if (typeof value !== "number" || !Number.isFinite(value) || value <= 0) throw fail(`${label} must be a positive finite number`);
|
|
46
49
|
return value;
|
|
@@ -101,12 +104,14 @@ async function performRequest(transport, url, init, observe, decode) {
|
|
|
101
104
|
if (!response.ok) {
|
|
102
105
|
const envelope = await response.json().catch(() => ({}));
|
|
103
106
|
if (typeof envelope.request_id === "string") requestId = envelope.request_id;
|
|
107
|
+
const details = detailsRecord(envelope.details);
|
|
104
108
|
return fail({
|
|
105
109
|
outcome: "api_error",
|
|
106
110
|
status,
|
|
107
111
|
code: typeof envelope.code === "string" ? envelope.code : "",
|
|
108
112
|
message: typeof envelope.message === "string" ? envelope.message : "",
|
|
109
|
-
requestId
|
|
113
|
+
requestId,
|
|
114
|
+
...details ? { details } : {}
|
|
110
115
|
});
|
|
111
116
|
}
|
|
112
117
|
let payload;
|
|
@@ -279,6 +284,13 @@ function buildChannelClient(options, viewer) {
|
|
|
279
284
|
if (!key) throw new ChannelConfigurationError("idempotencyKey is required");
|
|
280
285
|
return { "Idempotency-Key": key };
|
|
281
286
|
}
|
|
287
|
+
function listProducts(params) {
|
|
288
|
+
return request(
|
|
289
|
+
"channel.catalog.products.list",
|
|
290
|
+
appendQuery("/products", params),
|
|
291
|
+
params.country !== void 0 ? { cache: "no-store" } : void 0
|
|
292
|
+
);
|
|
293
|
+
}
|
|
282
294
|
return {
|
|
283
295
|
/**
|
|
284
296
|
* Verify the channel token and see what it points at.
|
|
@@ -316,18 +328,10 @@ function buildChannelClient(options, viewer) {
|
|
|
316
328
|
)
|
|
317
329
|
},
|
|
318
330
|
/**
|
|
319
|
-
*
|
|
320
|
-
*
|
|
321
|
-
* follow the links in waitlist emails and work with any scope.
|
|
331
|
+
* Scope-free waitlist email links (`verify` and `unsubscribe`).
|
|
332
|
+
* Dash waitlist status, form and signups live under `dash.waitlist`.
|
|
322
333
|
*/
|
|
323
334
|
waitlist: {
|
|
324
|
-
status: () => request("channel.waitlist.status", "/waitlist", { cache: "no-store" }),
|
|
325
|
-
form: () => request("channel.waitlist.form", "/waitlist/form", { cache: "no-store" }),
|
|
326
|
-
submit: (input, mutation) => request("channel.waitlist.submit", "/waitlist/entries", {
|
|
327
|
-
method: "POST",
|
|
328
|
-
headers: mutationHeaders(mutation),
|
|
329
|
-
body: JSON.stringify(input)
|
|
330
|
-
}),
|
|
331
335
|
verify: (token2) => linkRequest("/verify", { token: required(token2, "token") }),
|
|
332
336
|
unsubscribe: (key) => linkRequest("/unsubscribe", { key: required(key, "key") })
|
|
333
337
|
},
|
|
@@ -436,8 +440,11 @@ function buildChannelClient(options, viewer) {
|
|
|
436
440
|
get: (slug) => request("channel.pages.get", `/pages/${encodePath(slug)}`)
|
|
437
441
|
},
|
|
438
442
|
products: {
|
|
439
|
-
|
|
443
|
+
markets: () => request("channel.catalog.markets.list", "/catalog/markets", { cache: "no-store" }),
|
|
444
|
+
list: (params = {}) => listProducts(params),
|
|
445
|
+
listForCountry: (params) => listProducts(params),
|
|
440
446
|
get: (slug) => request("channel.catalog.products.get", `/products/${encodePath(slug)}`),
|
|
447
|
+
getForCountry: (slug, country) => request("channel.catalog.products.get", appendQuery(`/products/${encodePath(slug)}`, { country }), { cache: "no-store" }),
|
|
441
448
|
media: (slug) => request("channel.catalog.products.media", `/products/${encodePath(slug)}/media`)
|
|
442
449
|
},
|
|
443
450
|
artwork: {
|
|
@@ -489,6 +496,15 @@ function buildChannelClient(options, viewer) {
|
|
|
489
496
|
method: "POST",
|
|
490
497
|
headers: mutationHeaders(mutation),
|
|
491
498
|
body: JSON.stringify(input)
|
|
499
|
+
}),
|
|
500
|
+
previewMarket: (cartToken, country) => request("channel.cart.market.preview", appendQuery("/cart/market/preview", {
|
|
501
|
+
cart_token: required(cartToken, "cartToken"),
|
|
502
|
+
country: required(country, "country")
|
|
503
|
+
}), { cache: "no-store" }),
|
|
504
|
+
confirmMarket: (input, mutation) => request("channel.cart.market.confirm", "/cart/market/confirm", {
|
|
505
|
+
method: "POST",
|
|
506
|
+
headers: requiredIdempotencyHeaders(mutation),
|
|
507
|
+
body: JSON.stringify(input)
|
|
492
508
|
})
|
|
493
509
|
},
|
|
494
510
|
// Checkout is addressed by the ORDER the cart became: the server mounts
|
package/dist/dash-next.d.ts
CHANGED
package/dist/dash-next.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { createNextChannelClient } from './chunk-
|
|
2
|
-
import { narrow } from './chunk-
|
|
3
|
-
import './chunk-
|
|
1
|
+
import { createNextChannelClient } from './chunk-4GSTY323.js';
|
|
2
|
+
import { narrow } from './chunk-SFPJ6HJJ.js';
|
|
3
|
+
import './chunk-5ULF3TZJ.js';
|
|
4
4
|
import './chunk-XPO7C3DW.js';
|
|
5
5
|
import 'server-only';
|
|
6
6
|
|
package/dist/dash.d.ts
CHANGED
package/dist/dash.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { createDashChannelClient, narrow as narrowToDash } from './chunk-
|
|
2
|
-
import './chunk-
|
|
1
|
+
export { createDashChannelClient, narrow as narrowToDash } from './chunk-SFPJ6HJJ.js';
|
|
2
|
+
import './chunk-5ULF3TZJ.js';
|
|
3
3
|
import './chunk-XPO7C3DW.js';
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { i as ChannelPing, j as ChannelGeo, P as PaymentCollectionAvailability, W as
|
|
2
|
-
export {
|
|
1
|
+
import { i as ChannelPing, j as ChannelGeo, P as PaymentCollectionAvailability, W as WaitlistVerification, k as WaitlistUnsubscription, F as FileRequestView, l as FileRequestUploadInput, m as FileRequestUploadTicket, n as FileRequestCompleteInput, o as FileRequestReceivedFile, p as FileRequestClosed, q as ChannelReceiptResponse, D as DashProfileResponse, r as DashInitResponse, s as WaitlistGateStatus, t as WaitlistFormSettings, u as WaitlistSubmission, v as WaitlistAcknowledgement, w as DashPlansResponse, L as ListResponse, x as DashDirectoryRegion, y as DashDirectoryEntry, z as DashDirectoryProfileResponse, B as DashLead, E as DashLeadPortalRequestLinkInput, G as DashLeadPortalRequestLinkResponse, H as DashLeadPortalView, I as DashMovingQuoteInput, J as DashMovingQuoteReceipt, K as DashMovingAddressList, M as DashMovingAddress, N as DashMovingDistance, S as SiteAccess, Q as SiteDocument, R as PublicWorkspaceInit, T as LightInitResponse, U as PublicPageSummary, V as PublicPage, X as BrowseMarketsResponse, Y as Product, Z as ChannelProductListResponse, _ as ProductAsset, $ as SlotsResponse, a0 as DownloadResponse, b3 as BeginUploadInput, b4 as CompleteUploadInput, a1 as ArtworkMutationReceipt, b5 as DecisionInput, a2 as PublicConfiguration, a3 as PublicConfigurationQuoteInput, a4 as PublicConfigurationQuote, a5 as CatalogCategory, a6 as CatalogProductsResponse, a7 as CatalogCollection, a8 as CatalogBrand, a9 as CartLookupResponse, A as AddCartItemInput, C as CartResponse, aa as UpdateCartItemInput, ab as MergeCartInput, ac as CartMarketPreview, ad as ConfirmCartMarketInput, a as CheckoutOptions, b as CheckoutStatusResponse, c as CheckoutCustomerInput, d as CheckoutAddressesInput, e as CheckoutFulfillmentInput, f as CheckoutPayInput, g as CheckoutPayResponse, h as CheckoutCancelInput, ae as Review, af as ReviewSummaryResponse, ag as PublicSubmitReviewInput, ah as ThemeResponse, ai as MenuResponse, aj as BlogPost, ak as BlogPostResponse, al as GivingEntry, am as StartGivingInput, an as StartGivingResponse, ao as SubscriptionPlanListResponse, ap as SubscriptionPlanResponse, aq as BookingService, ar as BookingServiceResponse, as as BookingAvailabilityParams, at as BookingAvailabilityResponse, au as BookingQuoteParams, av as BookingQuoteResponse, aw as CreateBookingHoldInput, ax as BookingHoldResponse, ay as PublicPaymentLinkResponse, az as PaymentLinkCheckoutInput, aA as PaymentLinkCheckoutResponse, aB as PaymentLinkRedemptionStatusResponse, aC as PrintSettingsResponse, aD as PrintOptionsSelection, aE as PrintQuoteResponse, aF as PrintIntakeInput, aG as PrintJob, aH as DiningMenu, aI as CustomerSignupResponse, aJ as SendCodeResponse, aK as CustomerSession, aL as CustomerResponse, aM as CustomerAuthSession, aN as CustomerSecurityActivityPage, O as Order, aO as OrderSummary, aP as SavedAddress, aQ as SavedAddressResponse, aR as SavedAddressInput, aS as SavedAddressUpdateInput, aT as AccountBillingPortalInput, aU as AccountBillingPortalResponse, aV as StartSubscriptionInput, aW as SubscriptionCheckoutResponse, aX as SubscriptionListResponse, aY as SubscriptionAgreementResponse, aZ as SubscriptionSourceResponse, a_ as SubscriptionPaymentRecoveryResponse, a$ as AccountBooking, b0 as AccountPayment, b1 as GivingIntentListResponse, b2 as LeadResponse, b6 as Slot } from './types-BedZ9_Y2.js';
|
|
2
|
+
export { b7 as BookingAvailability, b8 as BookingCancellationPolicy, b9 as BookingCustomerInput, ba as BookingFreeSpan, bb as BookingHold, bc as BookingIntakeQuestion, bd as BookingPriceQuote, be as BookingServicePricing, bf as BookingTimeRange, bg as BrowseCatalogueContext, bh as BrowseMarket, bi as BrowseMarketPrice, bj as CatalogProduct, bk as ChannelReceipt, bl as ChannelReceiptLine, bm as ChannelReceiptRecurring, bn as CheckoutAddress, bo as CheckoutStatus, bp as ConfigDocument, bq as ConfigQuote, br as ConfigSelectionRequest, bs as Customer, bt as CustomerSecurityActivity, bu as DashBrandingInfo, bv as DashDirectoryGalleryItem, bw as DashDirectoryLocation, bx as DashDirectoryProfile, by as DashLeadPortalMatch, bz as DashLeadPortalMovingSummary, bA as DashLeadPortalRequest, bB as DashLeadPortalRequestStatus, bC as DashLocaleInfo, bD as DashPlan, bE as DashPlanLimitValue, bF as DashPlanPricing, bG as DashPublicPage, bH as DashPublicProfileInfo, bI as DashTenantInfo, bJ as DiningAvailability, bK as DiningAvailabilityRule, bL as DiningComboChoice, bM as DiningComboGroup, bN as DiningItemSize, bO as DiningMenuItem, bP as DiningModifier, bQ as DiningModifierGroup, bR as DiningOffer, bS as DiningOfferBadge, bT as DirectoryVerificationStatus, bU as FileRequestTokenInput, bV as GivingIntent, bW as Menu, bX as MenuItem, bY as OrderItem, bZ as PaymentLinkRedemptionStatus, b_ as PaymentMethodOption, b$ as PaymentReadiness, c0 as PrintBranding, c1 as PrintIntakeLimits, c2 as PrintJobFile, c3 as PrintPaperSize, c4 as PrintPerPagePricing, c5 as PrintPriceBreakdown, c6 as PrintPriceLine, c7 as PrintPricing, c8 as PrintPricingOption, c9 as ProductLineConfiguration, ca as PublicGate, cb as PublicPaymentLink, cc as PublicSiteSignals, cd as ShippingMethodOption, ce as SiteGatedDocument, cf as SiteRef, cg as SiteResolvedDocument, ch as SiteSubject, ci as SubscriptionAgreement, cj as SubscriptionPlanOffer, ck as SubscriptionSourceDisplay, cl as WaitlistAttribution, cm as WorkspaceInfo } from './types-BedZ9_Y2.js';
|
|
3
3
|
export { AnyChannelWebhookEvent, CHANNEL_WEBHOOK_EVENT_ID_HEADER, CHANNEL_WEBHOOK_EVENT_TYPES, CHANNEL_WEBHOOK_SIGNATURE_HEADER, CHANNEL_WEBHOOK_TIMESTAMP_HEADER, ChannelWebhookEvent, ChannelWebhookEventDataMap, ChannelWebhookEventType, ChannelWebhookVerificationCode, ChannelWebhookVerificationError, DEFAULT_TOLERANCE_SECONDS, FulfillmentEventData, LeadCreatedEventData, MenuUpdatedEventData, OrderEventData, PagePublishedEventData, ParseChannelWebhookEventOptions, ParsedChannelWebhookEvent, ProductEventData, ReviewPublishedEventData, ReviewSubmittedEventData, UnknownChannelWebhookEvent, VerifyChannelWebhookSignatureOptions, isChannelWebhookEventType, isChannelWebhookVerificationError, isKnownChannelWebhookEvent, parseChannelWebhookEvent, verifyChannelWebhookSignature } from './webhooks.js';
|
|
4
4
|
|
|
5
5
|
/**
|
|
@@ -94,7 +94,7 @@ interface ChannelVisitor {
|
|
|
94
94
|
userAgent?: string;
|
|
95
95
|
}
|
|
96
96
|
type ChannelRequestOutcome = "success" | "api_error" | "network_error" | "timeout" | "invalid_response" | "cancelled";
|
|
97
|
-
type ChannelOperation = "channel.commerce.artwork.list" | "channel.commerce.artwork.download" | "channel.commerce.artwork.decide" | "channel.commerce.artwork.uploads.begin" | "channel.commerce.artwork.uploads.complete" | "channel.ping" | "channel.geo.detect" | "channel.site.access" | "channel.site.resolve" | "channel.init.get" | "channel.init.light" | "channel.pages.list" | "channel.pages.get" | "channel.catalog.products.list" | "channel.catalog.products.get" | "channel.catalog.products.media" | "channel.catalog.products.configuration.get" | "channel.catalog.products.configuration.quote" | "channel.reviews.list" | "channel.reviews.summary" | "channel.reviews.submit" | "channel.theme.get" | "channel.menus.get" | "channel.blog.get" | "channel.blog.list" | "channel.payments.availability" | "channel.giving.entries.list" | "channel.giving.entries.get" | "channel.giving.start" | "channel.subscriptions.plans.list" | "channel.subscriptions.plans.get" | "channel.subscriptions.start" | "channel.book.services.list" | "channel.book.services.get" | "channel.book.availability.get" | "channel.book.quote.get" | "channel.book.holds.create" | "channel.book.holds.checkout" | "channel.book.holds.get" | "channel.book.holds.release" | "channel.payment_links.get" | "channel.payment_links.checkout" | "channel.payment_links.redemptions.get" | "channel.print.settings" | "channel.print.quote" | "channel.print.intake" | "channel.menu.boards.menu" | "channel.auth.check" | "channel.auth.signup" | "channel.auth.send_code" | "channel.auth.verify_code" | "channel.auth.refresh" | "channel.auth.me" | "channel.auth.me.update" | "channel.auth.logout" | "channel.auth.sessions.list" | "channel.auth.sessions.revoke" | "channel.auth.sessions.revoke_others" | "channel.auth.sessions.revoke_all" | "channel.auth.security_activity.list" | "channel.account.addresses.list" | "channel.account.addresses.create" | "channel.account.addresses.get" | "channel.account.addresses.update" | "channel.account.addresses.delete" | "channel.account.addresses.set_default" | "channel.account.giving.list" | "channel.account.bookings.list" | "channel.account.payment_links.list" | "channel.account.orders.list" | "channel.account.orders.summary" | "channel.account.orders.get" | "channel.account.billing.portal" | "channel.account.subscriptions.list" | "channel.account.subscriptions.get" | "channel.account.subscriptions.payment_recovery" | "channel.account.subscriptions.source" | "channel.catalog.brands.list" | "channel.catalog.categories.list" | "channel.catalog.categories.products" | "channel.catalog.collections.list" | "channel.catalog.collections.products" | "channel.catalog.collections.get" | "channel.cart.get" | "channel.cart.items.add" | "channel.cart.items.update" | "channel.cart.items.remove" | "channel.cart.clear" | "channel.cart.merge" | "channel.checkout.options" | "channel.checkout.status" | "channel.checkout.customer.set" | "channel.checkout.addresses.set" | "channel.checkout.fulfillment.set" | "channel.checkout.pay" | "channel.checkout.cancel" | "channel.dash.profile" | "channel.dash.init" | "channel.
|
|
97
|
+
type ChannelOperation = "channel.commerce.artwork.list" | "channel.commerce.artwork.download" | "channel.commerce.artwork.decide" | "channel.commerce.artwork.uploads.begin" | "channel.commerce.artwork.uploads.complete" | "channel.ping" | "channel.geo.detect" | "channel.site.access" | "channel.site.resolve" | "channel.init.get" | "channel.init.light" | "channel.pages.list" | "channel.pages.get" | "channel.catalog.markets.list" | "channel.catalog.products.list" | "channel.catalog.products.get" | "channel.catalog.products.media" | "channel.catalog.products.configuration.get" | "channel.catalog.products.configuration.quote" | "channel.reviews.list" | "channel.reviews.summary" | "channel.reviews.submit" | "channel.theme.get" | "channel.menus.get" | "channel.blog.get" | "channel.blog.list" | "channel.payments.availability" | "channel.giving.entries.list" | "channel.giving.entries.get" | "channel.giving.start" | "channel.subscriptions.plans.list" | "channel.subscriptions.plans.get" | "channel.subscriptions.start" | "channel.book.services.list" | "channel.book.services.get" | "channel.book.availability.get" | "channel.book.quote.get" | "channel.book.holds.create" | "channel.book.holds.checkout" | "channel.book.holds.get" | "channel.book.holds.release" | "channel.payment_links.get" | "channel.payment_links.checkout" | "channel.payment_links.redemptions.get" | "channel.print.settings" | "channel.print.quote" | "channel.print.intake" | "channel.menu.boards.menu" | "channel.auth.check" | "channel.auth.signup" | "channel.auth.send_code" | "channel.auth.verify_code" | "channel.auth.refresh" | "channel.auth.me" | "channel.auth.me.update" | "channel.auth.logout" | "channel.auth.sessions.list" | "channel.auth.sessions.revoke" | "channel.auth.sessions.revoke_others" | "channel.auth.sessions.revoke_all" | "channel.auth.security_activity.list" | "channel.account.addresses.list" | "channel.account.addresses.create" | "channel.account.addresses.get" | "channel.account.addresses.update" | "channel.account.addresses.delete" | "channel.account.addresses.set_default" | "channel.account.giving.list" | "channel.account.bookings.list" | "channel.account.payment_links.list" | "channel.account.orders.list" | "channel.account.orders.summary" | "channel.account.orders.get" | "channel.account.billing.portal" | "channel.account.subscriptions.list" | "channel.account.subscriptions.get" | "channel.account.subscriptions.payment_recovery" | "channel.account.subscriptions.source" | "channel.catalog.brands.list" | "channel.catalog.categories.list" | "channel.catalog.categories.products" | "channel.catalog.collections.list" | "channel.catalog.collections.products" | "channel.catalog.collections.get" | "channel.cart.get" | "channel.cart.items.add" | "channel.cart.items.update" | "channel.cart.items.remove" | "channel.cart.clear" | "channel.cart.merge" | "channel.cart.market.preview" | "channel.cart.market.confirm" | "channel.checkout.options" | "channel.checkout.status" | "channel.checkout.customer.set" | "channel.checkout.addresses.set" | "channel.checkout.fulfillment.set" | "channel.checkout.pay" | "channel.checkout.cancel" | "channel.dash.profile" | "channel.dash.init" | "channel.file_requests.view" | "channel.file_requests.uploads.begin" | "channel.file_requests.uploads.complete" | "channel.file_requests.close" | "channel.receipts.get" | "channel.dash.waitlist.status" | "channel.dash.waitlist.form" | "channel.dash.waitlist.submit" | "channel.dash.plans" | "channel.dash.directory.regions" | "channel.dash.directory.browse" | "channel.dash.directory.get" | "channel.dash.leads.capture" | "channel.dash.lead_portal.my_quotes" | "channel.dash.lead_portal.request_link" | "channel.dash.quote_requests.moving.capture" | "channel.dash.addresses.lookup" | "channel.dash.addresses.resolve" | "channel.dash.addresses.distance" | "channel.leads.capture";
|
|
98
98
|
interface ChannelRequestObservation {
|
|
99
99
|
operation: ChannelOperation;
|
|
100
100
|
method: string;
|
|
@@ -118,6 +118,7 @@ interface ChannelAccountBookingListParams extends ChannelListParams {
|
|
|
118
118
|
when?: "upcoming" | "past";
|
|
119
119
|
}
|
|
120
120
|
interface ChannelProductListParams extends ChannelListParams {
|
|
121
|
+
country?: string;
|
|
121
122
|
currency?: string;
|
|
122
123
|
search?: string;
|
|
123
124
|
category_id?: string;
|
|
@@ -134,6 +135,8 @@ interface ChannelLeadInput {
|
|
|
134
135
|
message?: string;
|
|
135
136
|
source?: string;
|
|
136
137
|
meta?: Record<string, unknown>;
|
|
138
|
+
/** Bot trap, forwarded unchanged; the API silently drops non-blank values. */
|
|
139
|
+
_gotcha?: string;
|
|
137
140
|
}
|
|
138
141
|
interface DashDirectoryListParams extends ChannelListParams {
|
|
139
142
|
category?: string;
|
|
@@ -194,14 +197,10 @@ declare function createChannelClient(options: CreateChannelClientOptions): {
|
|
|
194
197
|
readonly availability: () => Promise<PaymentCollectionAvailability>;
|
|
195
198
|
};
|
|
196
199
|
/**
|
|
197
|
-
*
|
|
198
|
-
*
|
|
199
|
-
* follow the links in waitlist emails and work with any scope.
|
|
200
|
+
* Scope-free waitlist email links (`verify` and `unsubscribe`).
|
|
201
|
+
* Dash waitlist status, form and signups live under `dash.waitlist`.
|
|
200
202
|
*/
|
|
201
203
|
readonly waitlist: {
|
|
202
|
-
readonly status: () => Promise<WaitlistGateStatus>;
|
|
203
|
-
readonly form: () => Promise<WaitlistFormSettings>;
|
|
204
|
-
readonly submit: (input: WaitlistSubmission, mutation?: ChannelMutationOptions) => Promise<WaitlistAcknowledgement>;
|
|
205
204
|
readonly verify: (token: string) => Promise<WaitlistVerification>;
|
|
206
205
|
readonly unsubscribe: (key: string) => Promise<WaitlistUnsubscription>;
|
|
207
206
|
};
|
|
@@ -277,10 +276,17 @@ declare function createChannelClient(options: CreateChannelClientOptions): {
|
|
|
277
276
|
}>;
|
|
278
277
|
};
|
|
279
278
|
readonly products: {
|
|
279
|
+
readonly markets: () => Promise<BrowseMarketsResponse>;
|
|
280
280
|
readonly list: (params?: ChannelProductListParams) => Promise<ListResponse<Product>>;
|
|
281
|
+
readonly listForCountry: (params: ChannelProductListParams & {
|
|
282
|
+
country: string;
|
|
283
|
+
}) => Promise<ChannelProductListResponse>;
|
|
281
284
|
readonly get: (slug: string) => Promise<{
|
|
282
285
|
product: Product;
|
|
283
286
|
}>;
|
|
287
|
+
readonly getForCountry: (slug: string, country: string) => Promise<{
|
|
288
|
+
product: Product;
|
|
289
|
+
}>;
|
|
284
290
|
readonly media: (slug: string) => Promise<ListResponse<ProductAsset>>;
|
|
285
291
|
};
|
|
286
292
|
readonly artwork: {
|
|
@@ -315,6 +321,8 @@ declare function createChannelClient(options: CreateChannelClientOptions): {
|
|
|
315
321
|
readonly removeItem: (itemId: string, cartToken: string, mutation?: ChannelMutationOptions) => Promise<CartResponse>;
|
|
316
322
|
readonly clear: (cartToken: string, mutation?: ChannelMutationOptions) => Promise<CartResponse>;
|
|
317
323
|
readonly merge: (input: MergeCartInput, mutation?: ChannelMutationOptions) => Promise<CartResponse>;
|
|
324
|
+
readonly previewMarket: (cartToken: string, country: string) => Promise<CartMarketPreview>;
|
|
325
|
+
readonly confirmMarket: (input: ConfirmCartMarketInput, mutation: RequiredIdempotency) => Promise<CartResponse>;
|
|
318
326
|
};
|
|
319
327
|
readonly checkout: {
|
|
320
328
|
readonly options: (orderId: string, cartToken: string) => Promise<CheckoutOptions>;
|
|
@@ -496,4 +504,4 @@ declare function createChannelClient(options: CreateChannelClientOptions): {
|
|
|
496
504
|
};
|
|
497
505
|
};
|
|
498
506
|
|
|
499
|
-
export { AccountBillingPortalInput, AccountBillingPortalResponse, AccountBooking, AccountPayment, AddCartItemInput, type ArtworkCompleteInput, ArtworkMutationReceipt, type ArtworkProofDecision, type ArtworkSlot, type ArtworkSlotsResponse, type ArtworkUploadInput, type ArtworkUploadTicket, BlogPost, BlogPostResponse, BookingAvailabilityParams, BookingAvailabilityResponse, BookingHoldResponse, BookingQuoteParams, BookingQuoteResponse, BookingService, BookingServiceResponse, CartLookupResponse, CartResponse, CatalogBrand, CatalogCategory, CatalogCollection, CatalogProductsResponse, ChannelAPIError, type ChannelAccountBookingListParams, type ChannelCheckoutStatusParams, ChannelConfigurationError, ChannelGeo, type ChannelLeadInput, type ChannelListParams, type ChannelMutationOptions, type ChannelOperation, ChannelPing, type ChannelProductListParams, ChannelReceiptResponse, type ChannelRequestObservation, type ChannelRequestObserver, type ChannelRequestOutcome, type ChannelRetryPolicy, type ChannelSitePage, type ChannelSiteResolveParams, type ChannelSubscriptionListParams, type ChannelVisitor, CheckoutAddressesInput, CheckoutCancelInput, CheckoutCustomerInput, CheckoutFulfillmentInput, CheckoutOptions, CheckoutPayInput, CheckoutPayResponse, CheckoutStatusResponse, CreateBookingHoldInput, type CreateChannelClientOptions, CustomerAuthSession, CustomerResponse, CustomerSecurityActivityPage, CustomerSession, CustomerSignupResponse, DEFAULT_CHANNEL_API_URL, DashDirectoryEntry, type DashDirectoryListParams, DashDirectoryProfileResponse, DashDirectoryRegion, DashInitResponse, DashLead, DashLeadPortalRequestLinkInput, DashLeadPortalRequestLinkResponse, DashLeadPortalView, DashMovingAddress, DashMovingAddressList, DashMovingDistance, DashMovingQuoteInput, DashMovingQuoteReceipt, DashPlansResponse, DashProfileResponse, DiningMenu, DownloadResponse, FileRequestClosed, FileRequestCompleteInput, FileRequestReceivedFile, FileRequestUploadInput, FileRequestUploadTicket, FileRequestView, GivingEntry, GivingIntentListResponse, LeadResponse, LightInitResponse, ListResponse, MenuResponse, MergeCartInput, Order, OrderSummary, PaymentCollectionAvailability, PaymentLinkCheckoutInput, PaymentLinkCheckoutResponse, PaymentLinkRedemptionStatusResponse, PrintIntakeInput, PrintJob, PrintOptionsSelection, PrintQuoteResponse, PrintSettingsResponse, Product, ProductAsset, PublicConfiguration, PublicConfigurationQuote, PublicConfigurationQuoteInput, PublicPage, PublicPageSummary, PublicPaymentLinkResponse, PublicSubmitReviewInput, PublicWorkspaceInit, type RequiredIdempotency, Review, ReviewSummaryResponse, SavedAddress, SavedAddressInput, SavedAddressResponse, SavedAddressUpdateInput, SendCodeResponse, SiteAccess, SiteDocument, SlotsResponse, StartGivingInput, StartGivingResponse, StartSubscriptionInput, SubscriptionAgreementResponse, SubscriptionCheckoutResponse, SubscriptionListResponse, SubscriptionPaymentRecoveryResponse, SubscriptionPlanListResponse, SubscriptionPlanResponse, SubscriptionSourceResponse, ThemeResponse, UpdateCartItemInput, type UploadTicket, WaitlistAcknowledgement, WaitlistFormSettings, WaitlistGateStatus, WaitlistSubmission, WaitlistUnsubscription, WaitlistVerification, createChannelClient, isChannelAPIError, isChannelConfigurationError };
|
|
507
|
+
export { AccountBillingPortalInput, AccountBillingPortalResponse, AccountBooking, AccountPayment, AddCartItemInput, type ArtworkCompleteInput, ArtworkMutationReceipt, type ArtworkProofDecision, type ArtworkSlot, type ArtworkSlotsResponse, type ArtworkUploadInput, type ArtworkUploadTicket, BlogPost, BlogPostResponse, BookingAvailabilityParams, BookingAvailabilityResponse, BookingHoldResponse, BookingQuoteParams, BookingQuoteResponse, BookingService, BookingServiceResponse, BrowseMarketsResponse, CartLookupResponse, CartMarketPreview, CartResponse, CatalogBrand, CatalogCategory, CatalogCollection, CatalogProductsResponse, ChannelAPIError, type ChannelAccountBookingListParams, type ChannelCheckoutStatusParams, ChannelConfigurationError, ChannelGeo, type ChannelLeadInput, type ChannelListParams, type ChannelMutationOptions, type ChannelOperation, ChannelPing, type ChannelProductListParams, ChannelProductListResponse, ChannelReceiptResponse, type ChannelRequestObservation, type ChannelRequestObserver, type ChannelRequestOutcome, type ChannelRetryPolicy, type ChannelSitePage, type ChannelSiteResolveParams, type ChannelSubscriptionListParams, type ChannelVisitor, CheckoutAddressesInput, CheckoutCancelInput, CheckoutCustomerInput, CheckoutFulfillmentInput, CheckoutOptions, CheckoutPayInput, CheckoutPayResponse, CheckoutStatusResponse, ConfirmCartMarketInput, CreateBookingHoldInput, type CreateChannelClientOptions, CustomerAuthSession, CustomerResponse, CustomerSecurityActivityPage, CustomerSession, CustomerSignupResponse, DEFAULT_CHANNEL_API_URL, DashDirectoryEntry, type DashDirectoryListParams, DashDirectoryProfileResponse, DashDirectoryRegion, DashInitResponse, DashLead, DashLeadPortalRequestLinkInput, DashLeadPortalRequestLinkResponse, DashLeadPortalView, DashMovingAddress, DashMovingAddressList, DashMovingDistance, DashMovingQuoteInput, DashMovingQuoteReceipt, DashPlansResponse, DashProfileResponse, DiningMenu, DownloadResponse, FileRequestClosed, FileRequestCompleteInput, FileRequestReceivedFile, FileRequestUploadInput, FileRequestUploadTicket, FileRequestView, GivingEntry, GivingIntentListResponse, LeadResponse, LightInitResponse, ListResponse, MenuResponse, MergeCartInput, Order, OrderSummary, PaymentCollectionAvailability, PaymentLinkCheckoutInput, PaymentLinkCheckoutResponse, PaymentLinkRedemptionStatusResponse, PrintIntakeInput, PrintJob, PrintOptionsSelection, PrintQuoteResponse, PrintSettingsResponse, Product, ProductAsset, PublicConfiguration, PublicConfigurationQuote, PublicConfigurationQuoteInput, PublicPage, PublicPageSummary, PublicPaymentLinkResponse, PublicSubmitReviewInput, PublicWorkspaceInit, type RequiredIdempotency, Review, ReviewSummaryResponse, SavedAddress, SavedAddressInput, SavedAddressResponse, SavedAddressUpdateInput, SendCodeResponse, SiteAccess, SiteDocument, SlotsResponse, StartGivingInput, StartGivingResponse, StartSubscriptionInput, SubscriptionAgreementResponse, SubscriptionCheckoutResponse, SubscriptionListResponse, SubscriptionPaymentRecoveryResponse, SubscriptionPlanListResponse, SubscriptionPlanResponse, SubscriptionSourceResponse, ThemeResponse, UpdateCartItemInput, type UploadTicket, WaitlistAcknowledgement, WaitlistFormSettings, WaitlistGateStatus, WaitlistSubmission, WaitlistUnsubscription, WaitlistVerification, createChannelClient, isChannelAPIError, isChannelConfigurationError };
|
package/dist/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { ChannelAPIError, DEFAULT_CHANNEL_API_URL, createChannelClient, isChannelAPIError } from './chunk-
|
|
1
|
+
export { ChannelAPIError, DEFAULT_CHANNEL_API_URL, createChannelClient, isChannelAPIError } from './chunk-5ULF3TZJ.js';
|
|
2
2
|
export { CHANNEL_WEBHOOK_EVENT_ID_HEADER, CHANNEL_WEBHOOK_EVENT_TYPES, CHANNEL_WEBHOOK_SIGNATURE_HEADER, CHANNEL_WEBHOOK_TIMESTAMP_HEADER, ChannelConfigurationError, ChannelWebhookVerificationError, DEFAULT_TOLERANCE_SECONDS, isChannelConfigurationError, isChannelWebhookEventType, isChannelWebhookVerificationError, isKnownChannelWebhookEvent, parseChannelWebhookEvent, verifyChannelWebhookSignature } from './chunk-XPO7C3DW.js';
|
package/dist/leads.d.ts
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/** Form field name for the hidden bot trap; forwarded unchanged as `_gotcha`. */
|
|
2
|
+
declare const HONEYPOT_FIELD_NAME = "_gotcha";
|
|
3
|
+
/** Backend-aligned character limits for public lead capture forms. */
|
|
4
|
+
declare const LEAD_LIMITS: {
|
|
5
|
+
readonly name: 120;
|
|
6
|
+
readonly email: 254;
|
|
7
|
+
readonly phone: 40;
|
|
8
|
+
readonly message: 4000;
|
|
9
|
+
};
|
|
10
|
+
interface LeadCaptureInput {
|
|
11
|
+
name?: string;
|
|
12
|
+
email: string;
|
|
13
|
+
phone?: string;
|
|
14
|
+
message?: string;
|
|
15
|
+
/** Bot trap, forwarded unchanged as `_gotcha`. */
|
|
16
|
+
_gotcha?: string;
|
|
17
|
+
}
|
|
18
|
+
interface ValidatedLead {
|
|
19
|
+
attemptId: string;
|
|
20
|
+
input: LeadCaptureInput;
|
|
21
|
+
}
|
|
22
|
+
type LeadField = "name" | "email" | "phone" | "message";
|
|
23
|
+
type LeadValidationResult = {
|
|
24
|
+
valid: true;
|
|
25
|
+
value: ValidatedLead;
|
|
26
|
+
} | {
|
|
27
|
+
valid: false;
|
|
28
|
+
fieldErrors: Partial<Record<LeadField, string>>;
|
|
29
|
+
formError?: string;
|
|
30
|
+
};
|
|
31
|
+
type LeadCaptureOutcome = {
|
|
32
|
+
state: "created";
|
|
33
|
+
id: string;
|
|
34
|
+
} | {
|
|
35
|
+
state: "disabled";
|
|
36
|
+
} | {
|
|
37
|
+
state: "invalid";
|
|
38
|
+
} | {
|
|
39
|
+
state: "error";
|
|
40
|
+
};
|
|
41
|
+
/**
|
|
42
|
+
* Validates a public lead-capture `FormData` payload against the Channel API's
|
|
43
|
+
* field limits (including 254-character email and UUID `lead_attempt_id`) and
|
|
44
|
+
* preserves `_gotcha` unchanged for server-side evaluation.
|
|
45
|
+
*/
|
|
46
|
+
declare function validateLeadForm(formData: FormData): LeadValidationResult;
|
|
47
|
+
/**
|
|
48
|
+
* Maps a failed `leads.create` error onto the visitor-facing state:
|
|
49
|
+
* - 401/403/404/410 -> `"disabled"` (channel or lead capture unavailable)
|
|
50
|
+
* - other 4xx -> `"invalid"` (submission rejected; visitor can correct input)
|
|
51
|
+
* - 5xx / transport -> `"error"` (transient failure; retryable)
|
|
52
|
+
*/
|
|
53
|
+
declare function classifyLeadCaptureError(error: unknown): Exclude<LeadCaptureOutcome["state"], "created">;
|
|
54
|
+
/**
|
|
55
|
+
* True when a failed capture returned a definite 4xx refusal and the form
|
|
56
|
+
* should rotate its `lead_attempt_id` before the next submission.
|
|
57
|
+
*/
|
|
58
|
+
declare function shouldRotateLeadAttemptKey(error: unknown): boolean;
|
|
59
|
+
|
|
60
|
+
export { HONEYPOT_FIELD_NAME, LEAD_LIMITS, type LeadCaptureInput, type LeadCaptureOutcome, type LeadField, type LeadValidationResult, type ValidatedLead, classifyLeadCaptureError, shouldRotateLeadAttemptKey, validateLeadForm };
|
package/dist/leads.js
ADDED
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { isChannelAPIError } from './chunk-5ULF3TZJ.js';
|
|
2
|
+
import './chunk-XPO7C3DW.js';
|
|
3
|
+
|
|
4
|
+
// src/leads.ts
|
|
5
|
+
var HONEYPOT_FIELD_NAME = "_gotcha";
|
|
6
|
+
var LEAD_LIMITS = {
|
|
7
|
+
name: 120,
|
|
8
|
+
email: 254,
|
|
9
|
+
phone: 40,
|
|
10
|
+
message: 4e3
|
|
11
|
+
};
|
|
12
|
+
var attemptPattern = /^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;
|
|
13
|
+
var emailPattern = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
|
|
14
|
+
var DISABLED_STATUSES = /* @__PURE__ */ new Set([401, 403, 404, 410]);
|
|
15
|
+
function optional(value, max) {
|
|
16
|
+
if (typeof value !== "string") return void 0;
|
|
17
|
+
const normalized = value.trim();
|
|
18
|
+
return normalized && normalized.length <= max ? normalized : void 0;
|
|
19
|
+
}
|
|
20
|
+
function validateLeadForm(formData) {
|
|
21
|
+
const attemptId = optional(formData.get("lead_attempt_id"), 64);
|
|
22
|
+
const rawName = formData.get("name");
|
|
23
|
+
const rawEmail = formData.get("email");
|
|
24
|
+
const rawPhone = formData.get("phone");
|
|
25
|
+
const rawMessage = formData.get("message");
|
|
26
|
+
const rawGotcha = formData.get(HONEYPOT_FIELD_NAME);
|
|
27
|
+
const name = optional(rawName, LEAD_LIMITS.name);
|
|
28
|
+
const email = optional(rawEmail, LEAD_LIMITS.email)?.toLowerCase();
|
|
29
|
+
const phone = optional(rawPhone, LEAD_LIMITS.phone);
|
|
30
|
+
const message = optional(rawMessage, LEAD_LIMITS.message);
|
|
31
|
+
const fieldErrors = {};
|
|
32
|
+
if (!email) {
|
|
33
|
+
fieldErrors.email = typeof rawEmail === "string" && rawEmail.trim().length > LEAD_LIMITS.email ? `Email must be ${LEAD_LIMITS.email} characters or fewer.` : "Enter your email address.";
|
|
34
|
+
} else if (!emailPattern.test(email)) {
|
|
35
|
+
fieldErrors.email = "Enter a valid email address.";
|
|
36
|
+
}
|
|
37
|
+
if (typeof rawName === "string" && rawName.trim() && !name) {
|
|
38
|
+
fieldErrors.name = `Name must be ${LEAD_LIMITS.name} characters or fewer.`;
|
|
39
|
+
}
|
|
40
|
+
if (typeof rawPhone === "string" && rawPhone.trim() && !phone) {
|
|
41
|
+
fieldErrors.phone = `Phone must be ${LEAD_LIMITS.phone} characters or fewer.`;
|
|
42
|
+
}
|
|
43
|
+
if (typeof rawMessage === "string" && rawMessage.trim() && !message) {
|
|
44
|
+
fieldErrors.message = `Message must be ${LEAD_LIMITS.message} characters or fewer.`;
|
|
45
|
+
}
|
|
46
|
+
const formError = !attemptId || !attemptPattern.test(attemptId) ? "This form has expired. Refresh the page and try again." : void 0;
|
|
47
|
+
if (formError || Object.keys(fieldErrors).length > 0) {
|
|
48
|
+
return { valid: false, fieldErrors, ...formError ? { formError } : {} };
|
|
49
|
+
}
|
|
50
|
+
return {
|
|
51
|
+
valid: true,
|
|
52
|
+
value: {
|
|
53
|
+
attemptId,
|
|
54
|
+
input: {
|
|
55
|
+
email,
|
|
56
|
+
...name ? { name } : {},
|
|
57
|
+
...phone ? { phone } : {},
|
|
58
|
+
...message ? { message } : {},
|
|
59
|
+
...typeof rawGotcha === "string" ? { _gotcha: rawGotcha } : {}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
function classifyLeadCaptureError(error) {
|
|
65
|
+
if (isChannelAPIError(error)) {
|
|
66
|
+
if (DISABLED_STATUSES.has(error.status)) return "disabled";
|
|
67
|
+
if (error.status >= 400 && error.status < 500) return "invalid";
|
|
68
|
+
}
|
|
69
|
+
return "error";
|
|
70
|
+
}
|
|
71
|
+
function shouldRotateLeadAttemptKey(error) {
|
|
72
|
+
return isChannelAPIError(error) && error.status >= 400 && error.status < 500;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
export { HONEYPOT_FIELD_NAME, LEAD_LIMITS, classifyLeadCaptureError, shouldRotateLeadAttemptKey, validateLeadForm };
|
package/dist/next.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createChannelClient, ChannelCheckoutStatusParams, ChannelMutationOptions, CreateChannelClientOptions, ChannelVisitor, DashDirectoryListParams, ChannelLeadInput, ChannelSiteResolveParams, ChannelListParams, ChannelProductListParams, ArtworkUploadInput, UploadTicket, ArtworkCompleteInput, ArtworkProofDecision, RequiredIdempotency, ChannelSubscriptionListParams, ChannelAccountBookingListParams } from './index.js';
|
|
2
|
-
import { O as Order, A as AddCartItemInput, C as CartResponse, a as CheckoutOptions, b as CheckoutStatusResponse, c as CheckoutCustomerInput, d as CheckoutAddressesInput, e as CheckoutFulfillmentInput, f as CheckoutPayInput, g as CheckoutPayResponse, h as CheckoutCancelInput, i as ChannelPing, j as ChannelGeo, P as PaymentCollectionAvailability, W as
|
|
2
|
+
import { O as Order, A as AddCartItemInput, C as CartResponse, a as CheckoutOptions, b as CheckoutStatusResponse, c as CheckoutCustomerInput, d as CheckoutAddressesInput, e as CheckoutFulfillmentInput, f as CheckoutPayInput, g as CheckoutPayResponse, h as CheckoutCancelInput, i as ChannelPing, j as ChannelGeo, P as PaymentCollectionAvailability, W as WaitlistVerification, k as WaitlistUnsubscription, F as FileRequestView, l as FileRequestUploadInput, m as FileRequestUploadTicket, n as FileRequestCompleteInput, o as FileRequestReceivedFile, p as FileRequestClosed, q as ChannelReceiptResponse, D as DashProfileResponse, r as DashInitResponse, s as WaitlistGateStatus, t as WaitlistFormSettings, u as WaitlistSubmission, v as WaitlistAcknowledgement, w as DashPlansResponse, L as ListResponse, x as DashDirectoryRegion, y as DashDirectoryEntry, z as DashDirectoryProfileResponse, B as DashLead, E as DashLeadPortalRequestLinkInput, G as DashLeadPortalRequestLinkResponse, H as DashLeadPortalView, I as DashMovingQuoteInput, J as DashMovingQuoteReceipt, K as DashMovingAddressList, M as DashMovingAddress, N as DashMovingDistance, S as SiteAccess, Q as SiteDocument, R as PublicWorkspaceInit, T as LightInitResponse, U as PublicPageSummary, V as PublicPage, X as BrowseMarketsResponse, Y as Product, Z as ChannelProductListResponse, _ as ProductAsset, $ as SlotsResponse, a0 as DownloadResponse, a1 as ArtworkMutationReceipt, a2 as PublicConfiguration, a3 as PublicConfigurationQuoteInput, a4 as PublicConfigurationQuote, a5 as CatalogCategory, a6 as CatalogProductsResponse, a7 as CatalogCollection, a8 as CatalogBrand, a9 as CartLookupResponse, aa as UpdateCartItemInput, ab as MergeCartInput, ac as CartMarketPreview, ad as ConfirmCartMarketInput, ae as Review, af as ReviewSummaryResponse, ag as PublicSubmitReviewInput, ah as ThemeResponse, ai as MenuResponse, aj as BlogPost, ak as BlogPostResponse, al as GivingEntry, am as StartGivingInput, an as StartGivingResponse, ao as SubscriptionPlanListResponse, ap as SubscriptionPlanResponse, aq as BookingService, ar as BookingServiceResponse, as as BookingAvailabilityParams, at as BookingAvailabilityResponse, au as BookingQuoteParams, av as BookingQuoteResponse, aw as CreateBookingHoldInput, ax as BookingHoldResponse, ay as PublicPaymentLinkResponse, az as PaymentLinkCheckoutInput, aA as PaymentLinkCheckoutResponse, aB as PaymentLinkRedemptionStatusResponse, aC as PrintSettingsResponse, aD as PrintOptionsSelection, aE as PrintQuoteResponse, aF as PrintIntakeInput, aG as PrintJob, aH as DiningMenu, aI as CustomerSignupResponse, aJ as SendCodeResponse, aK as CustomerSession, aL as CustomerResponse, aM as CustomerAuthSession, aN as CustomerSecurityActivityPage, aO as OrderSummary, aP as SavedAddress, aQ as SavedAddressResponse, aR as SavedAddressInput, aS as SavedAddressUpdateInput, aT as AccountBillingPortalInput, aU as AccountBillingPortalResponse, aV as StartSubscriptionInput, aW as SubscriptionCheckoutResponse, aX as SubscriptionListResponse, aY as SubscriptionAgreementResponse, aZ as SubscriptionSourceResponse, a_ as SubscriptionPaymentRecoveryResponse, a$ as AccountBooking, b0 as AccountPayment, b1 as GivingIntentListResponse, b2 as LeadResponse } from './types-BedZ9_Y2.js';
|
|
3
3
|
import { ChannelWebhookEventDataMap, ChannelWebhookEvent } from './webhooks.js';
|
|
4
4
|
|
|
5
5
|
/**
|
|
@@ -292,9 +292,6 @@ declare function createNextChannelClient(options: CreateNextChannelClientOptions
|
|
|
292
292
|
readonly availability: () => Promise<PaymentCollectionAvailability>;
|
|
293
293
|
};
|
|
294
294
|
readonly waitlist: {
|
|
295
|
-
readonly status: () => Promise<WaitlistGateStatus>;
|
|
296
|
-
readonly form: () => Promise<WaitlistFormSettings>;
|
|
297
|
-
readonly submit: (input: WaitlistSubmission, mutation?: ChannelMutationOptions) => Promise<WaitlistAcknowledgement>;
|
|
298
295
|
readonly verify: (token: string) => Promise<WaitlistVerification>;
|
|
299
296
|
readonly unsubscribe: (key: string) => Promise<WaitlistUnsubscription>;
|
|
300
297
|
};
|
|
@@ -357,10 +354,17 @@ declare function createNextChannelClient(options: CreateNextChannelClientOptions
|
|
|
357
354
|
}>;
|
|
358
355
|
};
|
|
359
356
|
readonly products: {
|
|
357
|
+
readonly markets: () => Promise<BrowseMarketsResponse>;
|
|
360
358
|
readonly list: (params?: ChannelProductListParams) => Promise<ListResponse<Product>>;
|
|
359
|
+
readonly listForCountry: (params: ChannelProductListParams & {
|
|
360
|
+
country: string;
|
|
361
|
+
}) => Promise<ChannelProductListResponse>;
|
|
361
362
|
readonly get: (slug: string) => Promise<{
|
|
362
363
|
product: Product;
|
|
363
364
|
}>;
|
|
365
|
+
readonly getForCountry: (slug: string, country: string) => Promise<{
|
|
366
|
+
product: Product;
|
|
367
|
+
}>;
|
|
364
368
|
readonly media: (slug: string) => Promise<ListResponse<ProductAsset>>;
|
|
365
369
|
};
|
|
366
370
|
readonly artwork: {
|
|
@@ -395,6 +399,8 @@ declare function createNextChannelClient(options: CreateNextChannelClientOptions
|
|
|
395
399
|
readonly removeItem: (itemId: string, cartToken: string, mutation?: ChannelMutationOptions) => Promise<CartResponse>;
|
|
396
400
|
readonly clear: (cartToken: string, mutation?: ChannelMutationOptions) => Promise<CartResponse>;
|
|
397
401
|
readonly merge: (input: MergeCartInput, mutation?: ChannelMutationOptions) => Promise<CartResponse>;
|
|
402
|
+
readonly previewMarket: (cartToken: string, country: string) => Promise<CartMarketPreview>;
|
|
403
|
+
readonly confirmMarket: (input: ConfirmCartMarketInput, mutation: RequiredIdempotency) => Promise<CartResponse>;
|
|
398
404
|
};
|
|
399
405
|
readonly checkout: {
|
|
400
406
|
readonly options: (orderId: string, cartToken: string) => Promise<CheckoutOptions>;
|
package/dist/next.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { CHANNEL_CATALOG_CACHE_TAG, CHANNEL_SITE_CACHE_TAG, cartCookie, createCart, createChannelWebhookRoute, createCustomerSession, createNextChannelClient, defaultChannelCacheTags, safePublishedPath, sessionCookie } from './chunk-
|
|
2
|
-
import './chunk-
|
|
1
|
+
export { CHANNEL_CATALOG_CACHE_TAG, CHANNEL_SITE_CACHE_TAG, cartCookie, createCart, createChannelWebhookRoute, createCustomerSession, createNextChannelClient, defaultChannelCacheTags, safePublishedPath, sessionCookie } from './chunk-4GSTY323.js';
|
|
2
|
+
import './chunk-5ULF3TZJ.js';
|
|
3
3
|
import './chunk-XPO7C3DW.js';
|
package/dist/renderer.js
CHANGED
|
@@ -43,7 +43,7 @@ function safeStyleRule(properties) {
|
|
|
43
43
|
}
|
|
44
44
|
function collectResponsiveCSS(document, widths = {}) {
|
|
45
45
|
if (!isSiteBuilderDocument(document)) return "";
|
|
46
|
-
const mobile = widths.mobile ??
|
|
46
|
+
const mobile = widths.mobile ?? 480;
|
|
47
47
|
const tablet = widths.tablet ?? 768;
|
|
48
48
|
const rules = [];
|
|
49
49
|
const walk = (nodes) => {
|
package/dist/site.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { cf as SiteRef, ca as PublicGate, cc as PublicSiteSignals } from './types-BedZ9_Y2.js';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Site signals: what a public site serves, decided from the `signals` block
|
|
@@ -502,8 +502,6 @@ interface DashDirectoryEntry {
|
|
|
502
502
|
logo_square_url?: string;
|
|
503
503
|
card_media_url?: string;
|
|
504
504
|
primary_color?: string;
|
|
505
|
-
review_count: number;
|
|
506
|
-
average_rating: number;
|
|
507
505
|
verification_status?: DirectoryVerificationStatus;
|
|
508
506
|
verified: boolean;
|
|
509
507
|
service_tags?: unknown;
|
|
@@ -686,7 +684,37 @@ interface PublicPage extends PublicPageSummary {
|
|
|
686
684
|
theme_id?: string;
|
|
687
685
|
default_shell_template_id?: string;
|
|
688
686
|
}
|
|
687
|
+
interface BrowseMarket {
|
|
688
|
+
country: string;
|
|
689
|
+
market_code: string;
|
|
690
|
+
name: string;
|
|
691
|
+
currency: string;
|
|
692
|
+
locale: string;
|
|
693
|
+
can_purchase: boolean;
|
|
694
|
+
can_switch_cart?: boolean;
|
|
695
|
+
}
|
|
696
|
+
interface BrowseMarketPrice {
|
|
697
|
+
amount: {
|
|
698
|
+
minor: number;
|
|
699
|
+
currency: string;
|
|
700
|
+
};
|
|
701
|
+
source: string;
|
|
702
|
+
expires_at?: string;
|
|
703
|
+
}
|
|
704
|
+
interface BrowseMarketsResponse {
|
|
705
|
+
markets: BrowseMarket[];
|
|
706
|
+
fallback_country?: string;
|
|
707
|
+
}
|
|
708
|
+
interface BrowseCatalogueContext extends BrowseMarketsResponse {
|
|
709
|
+
market: BrowseMarket;
|
|
710
|
+
}
|
|
711
|
+
interface ChannelProductListResponse extends ListResponse<Product> {
|
|
712
|
+
/** Available on successful country-aware reads from capable channel servers. */
|
|
713
|
+
browse?: BrowseCatalogueContext;
|
|
714
|
+
}
|
|
689
715
|
interface Product {
|
|
716
|
+
browse_market?: BrowseMarket;
|
|
717
|
+
browse_price?: BrowseMarketPrice;
|
|
690
718
|
kind?: string;
|
|
691
719
|
id: string;
|
|
692
720
|
workspace_id: string;
|
|
@@ -1458,6 +1486,7 @@ interface Order {
|
|
|
1458
1486
|
order_number: string;
|
|
1459
1487
|
cart_token?: string;
|
|
1460
1488
|
channel_id?: string;
|
|
1489
|
+
buyer_country?: string;
|
|
1461
1490
|
status: string;
|
|
1462
1491
|
payment_status: string;
|
|
1463
1492
|
currency: string;
|
|
@@ -1500,6 +1529,25 @@ interface CartResponse {
|
|
|
1500
1529
|
interface CartLookupResponse {
|
|
1501
1530
|
order?: Order | null;
|
|
1502
1531
|
}
|
|
1532
|
+
interface CartMarketPreview {
|
|
1533
|
+
market: BrowseMarket;
|
|
1534
|
+
lines: {
|
|
1535
|
+
item_id: string;
|
|
1536
|
+
title: string;
|
|
1537
|
+
quantity: number;
|
|
1538
|
+
previous_unit_price: BrowseMarketPrice["amount"];
|
|
1539
|
+
proposed_unit_price: BrowseMarketPrice["amount"];
|
|
1540
|
+
}[];
|
|
1541
|
+
subtotal: BrowseMarketPrice["amount"];
|
|
1542
|
+
reset_fulfillment: boolean;
|
|
1543
|
+
expires_at: string;
|
|
1544
|
+
review_token: string;
|
|
1545
|
+
}
|
|
1546
|
+
interface ConfirmCartMarketInput {
|
|
1547
|
+
cart_token: string;
|
|
1548
|
+
country: string;
|
|
1549
|
+
review_token: string;
|
|
1550
|
+
}
|
|
1503
1551
|
interface ProductLineConfiguration {
|
|
1504
1552
|
revision_id?: string;
|
|
1505
1553
|
selection: ConfigSelectionRequest;
|
|
@@ -1822,4 +1870,4 @@ interface AccountPayment {
|
|
|
1822
1870
|
reference: string;
|
|
1823
1871
|
}
|
|
1824
1872
|
|
|
1825
|
-
export type {
|
|
1873
|
+
export type { SlotsResponse as $, AddCartItemInput as A, DashLead as B, CartResponse as C, DashProfileResponse as D, DashLeadPortalRequestLinkInput as E, FileRequestView as F, DashLeadPortalRequestLinkResponse as G, DashLeadPortalView as H, DashMovingQuoteInput as I, DashMovingQuoteReceipt as J, DashMovingAddressList as K, ListResponse as L, DashMovingAddress as M, DashMovingDistance as N, Order as O, PaymentCollectionAvailability as P, SiteDocument as Q, PublicWorkspaceInit as R, SiteAccess as S, LightInitResponse as T, PublicPageSummary as U, PublicPage as V, WaitlistVerification as W, BrowseMarketsResponse as X, Product as Y, ChannelProductListResponse as Z, ProductAsset as _, CheckoutOptions as a, AccountBooking as a$, DownloadResponse as a0, ArtworkMutationReceipt as a1, PublicConfiguration as a2, PublicConfigurationQuoteInput as a3, PublicConfigurationQuote as a4, CatalogCategory as a5, CatalogProductsResponse as a6, CatalogCollection as a7, CatalogBrand as a8, CartLookupResponse as a9, PaymentLinkCheckoutResponse as aA, PaymentLinkRedemptionStatusResponse as aB, PrintSettingsResponse as aC, PrintOptionsSelection as aD, PrintQuoteResponse as aE, PrintIntakeInput as aF, PrintJob as aG, DiningMenu as aH, CustomerSignupResponse as aI, SendCodeResponse as aJ, CustomerSession as aK, CustomerResponse as aL, CustomerAuthSession as aM, CustomerSecurityActivityPage as aN, OrderSummary as aO, SavedAddress as aP, SavedAddressResponse as aQ, SavedAddressInput as aR, SavedAddressUpdateInput as aS, AccountBillingPortalInput as aT, AccountBillingPortalResponse as aU, StartSubscriptionInput as aV, SubscriptionCheckoutResponse as aW, SubscriptionListResponse as aX, SubscriptionAgreementResponse as aY, SubscriptionSourceResponse as aZ, SubscriptionPaymentRecoveryResponse as a_, UpdateCartItemInput as aa, MergeCartInput as ab, CartMarketPreview as ac, ConfirmCartMarketInput as ad, Review as ae, ReviewSummaryResponse as af, PublicSubmitReviewInput as ag, ThemeResponse as ah, MenuResponse as ai, BlogPost as aj, BlogPostResponse as ak, GivingEntry as al, StartGivingInput as am, StartGivingResponse as an, SubscriptionPlanListResponse as ao, SubscriptionPlanResponse as ap, BookingService as aq, BookingServiceResponse as ar, BookingAvailabilityParams as as, BookingAvailabilityResponse as at, BookingQuoteParams as au, BookingQuoteResponse as av, CreateBookingHoldInput as aw, BookingHoldResponse as ax, PublicPaymentLinkResponse as ay, PaymentLinkCheckoutInput as az, CheckoutStatusResponse as b, PaymentReadiness as b$, AccountPayment as b0, GivingIntentListResponse as b1, LeadResponse as b2, BeginUploadInput as b3, CompleteUploadInput as b4, DecisionInput as b5, Slot as b6, BookingAvailability as b7, BookingCancellationPolicy as b8, BookingCustomerInput as b9, DashLeadPortalRequest as bA, DashLeadPortalRequestStatus as bB, DashLocaleInfo as bC, DashPlan as bD, DashPlanLimitValue as bE, DashPlanPricing as bF, DashPublicPage as bG, DashPublicProfileInfo as bH, DashTenantInfo as bI, DiningAvailability as bJ, DiningAvailabilityRule as bK, DiningComboChoice as bL, DiningComboGroup as bM, DiningItemSize as bN, DiningMenuItem as bO, DiningModifier as bP, DiningModifierGroup as bQ, DiningOffer as bR, DiningOfferBadge as bS, DirectoryVerificationStatus as bT, FileRequestTokenInput as bU, GivingIntent as bV, Menu as bW, MenuItem as bX, OrderItem as bY, PaymentLinkRedemptionStatus as bZ, PaymentMethodOption as b_, BookingFreeSpan as ba, BookingHold as bb, BookingIntakeQuestion as bc, BookingPriceQuote as bd, BookingServicePricing as be, BookingTimeRange as bf, BrowseCatalogueContext as bg, BrowseMarket as bh, BrowseMarketPrice as bi, CatalogProduct as bj, ChannelReceipt as bk, ChannelReceiptLine as bl, ChannelReceiptRecurring as bm, CheckoutAddress as bn, CheckoutStatus as bo, ConfigDocument as bp, ConfigQuote as bq, ConfigSelectionRequest as br, Customer as bs, CustomerSecurityActivity as bt, DashBrandingInfo as bu, DashDirectoryGalleryItem as bv, DashDirectoryLocation as bw, DashDirectoryProfile as bx, DashLeadPortalMatch as by, DashLeadPortalMovingSummary as bz, CheckoutCustomerInput as c, PrintBranding as c0, PrintIntakeLimits as c1, PrintJobFile as c2, PrintPaperSize as c3, PrintPerPagePricing as c4, PrintPriceBreakdown as c5, PrintPriceLine as c6, PrintPricing as c7, PrintPricingOption as c8, ProductLineConfiguration as c9, PublicGate as ca, PublicPaymentLink as cb, PublicSiteSignals as cc, ShippingMethodOption as cd, SiteGatedDocument as ce, SiteRef as cf, SiteResolvedDocument as cg, SiteSubject as ch, SubscriptionAgreement as ci, SubscriptionPlanOffer as cj, SubscriptionSourceDisplay as ck, WaitlistAttribution as cl, WorkspaceInfo as cm, CheckoutAddressesInput as d, CheckoutFulfillmentInput as e, CheckoutPayInput as f, CheckoutPayResponse as g, CheckoutCancelInput as h, ChannelPing as i, ChannelGeo as j, WaitlistUnsubscription as k, FileRequestUploadInput as l, FileRequestUploadTicket as m, FileRequestCompleteInput as n, FileRequestReceivedFile as o, FileRequestClosed as p, ChannelReceiptResponse as q, DashInitResponse as r, WaitlistGateStatus as s, WaitlistFormSettings as t, WaitlistSubmission as u, WaitlistAcknowledgement as v, DashPlansResponse as w, DashDirectoryRegion as x, DashDirectoryEntry as y, DashDirectoryProfileResponse as z };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@c1m-public/channel-client",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "6.0.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"description": "Typed server-side client for the MML headless Channel API",
|
|
@@ -44,6 +44,10 @@
|
|
|
44
44
|
"types": "./dist/site.d.ts",
|
|
45
45
|
"default": "./dist/site.js"
|
|
46
46
|
},
|
|
47
|
+
"./leads": {
|
|
48
|
+
"types": "./dist/leads.d.ts",
|
|
49
|
+
"default": "./dist/leads.js"
|
|
50
|
+
},
|
|
47
51
|
"./moving-lead-model": {
|
|
48
52
|
"types": "./dist/moving-lead-model/index.d.ts",
|
|
49
53
|
"default": "./dist/moving-lead-model/index.js"
|