@c1m-public/channel-client 5.1.0 → 6.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +36 -8
- package/dist/{chunk-ZO3ME5FP.js → chunk-4GSTY323.js} +1 -1
- package/dist/{chunk-J3Y6KAEC.js → chunk-5ULF3TZJ.js} +8 -11
- package/dist/{chunk-EKMKL3XK.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 +7 -9
- package/dist/index.js +1 -1
- package/dist/leads.d.ts +60 -0
- package/dist/leads.js +75 -0
- package/dist/next.d.ts +1 -4
- package/dist/next.js +2 -2
- package/dist/renderer.js +1 -1
- package/dist/site.d.ts +51 -3
- package/dist/site.js +71 -1
- package/dist/{types-BSN-nxmG.d.ts → types-BedZ9_Y2.d.ts} +1 -3
- package/package.json +8 -5
package/README.md
CHANGED
|
@@ -19,7 +19,8 @@ transport core.
|
|
|
19
19
|
split; see [The `/next` kits](#the-next-kits).
|
|
20
20
|
- `@c1m-public/channel-client/site` — what a public site serves, decided from
|
|
21
21
|
the `signals` block every bootstrap carries, plus the site-mode settings
|
|
22
|
-
helpers owner and operator screens share
|
|
22
|
+
helpers owner and operator screens share, and the brand-colour theme
|
|
23
|
+
helpers; see [`./site`](#site). Pure, no
|
|
23
24
|
transport, safe in a proxy or a client component.
|
|
24
25
|
- `@c1m-public/channel-client/moving-lead-model` — the moving-quote domain
|
|
25
26
|
model shared by dash sites and SaaSDash; no transport, optional `zod` peer.
|
|
@@ -34,7 +35,7 @@ Channel credentials resolve the tenant and scope at the API door (plus the
|
|
|
34
35
|
workspace for workspace-scoped channels), so site URLs never carry those
|
|
35
36
|
identifiers.
|
|
36
37
|
|
|
37
|
-
Managed C1M sites need one deployment secret: `
|
|
38
|
+
Managed C1M sites need one deployment secret: `SAASDASH_CHANNEL_TOKEN`. The client
|
|
38
39
|
uses `https://api.saasdash.app` by default. Pass `baseUrl` directly only for
|
|
39
40
|
local development or private C1M infrastructure; it is not part of the normal
|
|
40
41
|
deployment contract.
|
|
@@ -45,7 +46,7 @@ deployment contract.
|
|
|
45
46
|
import { createNextChannelClient } from "@c1m-public/channel-client/next";
|
|
46
47
|
|
|
47
48
|
const channel = createNextChannelClient({
|
|
48
|
-
token: process.env.
|
|
49
|
+
token: process.env.SAASDASH_CHANNEL_TOKEN!,
|
|
49
50
|
cache: { revalidate: 60 },
|
|
50
51
|
});
|
|
51
52
|
|
|
@@ -70,7 +71,7 @@ const checkout = await channel.checkout.pay(
|
|
|
70
71
|
import { createChannelClient } from "@c1m-public/channel-client";
|
|
71
72
|
|
|
72
73
|
const channel = createChannelClient({
|
|
73
|
-
token: process.env.
|
|
74
|
+
token: process.env.SAASDASH_CHANNEL_TOKEN!,
|
|
74
75
|
});
|
|
75
76
|
|
|
76
77
|
const category = await channel.categories.products("electric-cars");
|
|
@@ -231,7 +232,7 @@ const { hold: current } = await bookings.holds.get(token);
|
|
|
231
232
|
|
|
232
233
|
```ts
|
|
233
234
|
const channel = createChannelClient({
|
|
234
|
-
token: process.env.
|
|
235
|
+
token: process.env.SAASDASH_CHANNEL_TOKEN!,
|
|
235
236
|
observe(event) {
|
|
236
237
|
console.info("c1m.channel", event);
|
|
237
238
|
},
|
|
@@ -246,7 +247,7 @@ Verify webhook requests before parsing or acting on their payload:
|
|
|
246
247
|
import { parseChannelWebhookEvent } from "@c1m-public/channel-client/webhooks";
|
|
247
248
|
|
|
248
249
|
const event = await parseChannelWebhookEvent(request, {
|
|
249
|
-
secret: process.env.
|
|
250
|
+
secret: process.env.SAASDASH_CHANNEL_WEBHOOK_SECRET!,
|
|
250
251
|
});
|
|
251
252
|
```
|
|
252
253
|
|
|
@@ -288,7 +289,7 @@ import { revalidatePath, revalidateTag } from "next/cache";
|
|
|
288
289
|
import { createChannelWebhookRoute } from "@c1m-public/channel-client/next";
|
|
289
290
|
|
|
290
291
|
export const POST = createChannelWebhookRoute({
|
|
291
|
-
secret: () => process.env.
|
|
292
|
+
secret: () => process.env.SAASDASH_CHANNEL_WEBHOOK_SECRET!,
|
|
292
293
|
invalidate: { revalidatePath, revalidateTag },
|
|
293
294
|
});
|
|
294
295
|
```
|
|
@@ -305,7 +306,7 @@ the classifier (`defaultChannelCacheTags` is exported to compose with).
|
|
|
305
306
|
|
|
306
307
|
```ts
|
|
307
308
|
const channel = createNextChannelClient({
|
|
308
|
-
token: process.env.
|
|
309
|
+
token: process.env.SAASDASH_CHANNEL_TOKEN!,
|
|
309
310
|
cache: { revalidate: 3600 }, // products.list() → tags ["channel:catalog"]
|
|
310
311
|
});
|
|
311
312
|
```
|
|
@@ -364,6 +365,33 @@ itself when the site is available.
|
|
|
364
365
|
`describeLiveGate`, `toDateTimeLocal` and `fromDateTimeLocal` are the shared
|
|
365
366
|
pieces of a site-mode settings form.
|
|
366
367
|
|
|
368
|
+
### Site theme
|
|
369
|
+
|
|
370
|
+
`createSiteTheme(primaryColor, options?)` turns the owner's brand colour
|
|
371
|
+
(`content.theme.get()` or `dash.init().branding`) into the accent tokens, and
|
|
372
|
+
`themeStyle(theme)` returns them as CSS custom properties for the root
|
|
373
|
+
element's `style`:
|
|
374
|
+
|
|
375
|
+
```tsx
|
|
376
|
+
import type { CSSProperties } from "react";
|
|
377
|
+
import { createSiteTheme, themeStyle } from "@c1m-public/channel-client/site";
|
|
378
|
+
|
|
379
|
+
const theme = createSiteTheme(brand.primary_color);
|
|
380
|
+
<body style={themeStyle(theme) as CSSProperties}>…</body>
|
|
381
|
+
```
|
|
382
|
+
|
|
383
|
+
| Token | Meaning |
|
|
384
|
+
| --- | --- |
|
|
385
|
+
| `--accent` | The brand colour, or `options.fallbackAccent` (default `#262626`) when missing or not a six-digit hex |
|
|
386
|
+
| `--accent-foreground` | White or `options.darkText` (default `#171717`), whichever contrasts more with the accent |
|
|
387
|
+
| `--accent-text` | The accent darkened until it reads as text on white (contrast 5:1) |
|
|
388
|
+
| `--accent-strong` | Hover and pressed shade: 14% toward black, or 18% toward white for a near-black accent |
|
|
389
|
+
| `--accent-soft` | Tint for selected surfaces: 90% toward white |
|
|
390
|
+
|
|
391
|
+
The full site token contract, with a copy-paste `globals.css`, is in the
|
|
392
|
+
`@c1m-public/dash-site-kit` README under "Styling contract"; workspace sites
|
|
393
|
+
use the same token names.
|
|
394
|
+
|
|
367
395
|
## `./moving-lead-model`
|
|
368
396
|
|
|
369
397
|
A subpath carrying the moving-quote domain model: lead payload schemas, the
|
|
@@ -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;
|
|
@@ -323,18 +328,10 @@ function buildChannelClient(options, viewer) {
|
|
|
323
328
|
)
|
|
324
329
|
},
|
|
325
330
|
/**
|
|
326
|
-
*
|
|
327
|
-
*
|
|
328
|
-
* 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`.
|
|
329
333
|
*/
|
|
330
334
|
waitlist: {
|
|
331
|
-
status: () => request("channel.waitlist.status", "/waitlist", { cache: "no-store" }),
|
|
332
|
-
form: () => request("channel.waitlist.form", "/waitlist/form", { cache: "no-store" }),
|
|
333
|
-
submit: (input, mutation) => request("channel.waitlist.submit", "/waitlist/entries", {
|
|
334
|
-
method: "POST",
|
|
335
|
-
headers: mutationHeaders(mutation),
|
|
336
|
-
body: JSON.stringify(input)
|
|
337
|
-
}),
|
|
338
335
|
verify: (token2) => linkRequest("/verify", { token: required(token2, "token") }),
|
|
339
336
|
unsubscribe: (key) => linkRequest("/unsubscribe", { key: required(key, "key") })
|
|
340
337
|
},
|
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 { 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-
|
|
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.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.
|
|
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;
|
|
@@ -135,6 +135,8 @@ interface ChannelLeadInput {
|
|
|
135
135
|
message?: string;
|
|
136
136
|
source?: string;
|
|
137
137
|
meta?: Record<string, unknown>;
|
|
138
|
+
/** Bot trap, forwarded unchanged; the API silently drops non-blank values. */
|
|
139
|
+
_gotcha?: string;
|
|
138
140
|
}
|
|
139
141
|
interface DashDirectoryListParams extends ChannelListParams {
|
|
140
142
|
category?: string;
|
|
@@ -195,14 +197,10 @@ declare function createChannelClient(options: CreateChannelClientOptions): {
|
|
|
195
197
|
readonly availability: () => Promise<PaymentCollectionAvailability>;
|
|
196
198
|
};
|
|
197
199
|
/**
|
|
198
|
-
*
|
|
199
|
-
*
|
|
200
|
-
* 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`.
|
|
201
202
|
*/
|
|
202
203
|
readonly waitlist: {
|
|
203
|
-
readonly status: () => Promise<WaitlistGateStatus>;
|
|
204
|
-
readonly form: () => Promise<WaitlistFormSettings>;
|
|
205
|
-
readonly submit: (input: WaitlistSubmission, mutation?: ChannelMutationOptions) => Promise<WaitlistAcknowledgement>;
|
|
206
204
|
readonly verify: (token: string) => Promise<WaitlistVerification>;
|
|
207
205
|
readonly unsubscribe: (key: string) => Promise<WaitlistUnsubscription>;
|
|
208
206
|
};
|
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
|
};
|
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,11 +1,59 @@
|
|
|
1
|
-
import { cf as SiteRef, ca as PublicGate, cc as PublicSiteSignals } from './types-
|
|
1
|
+
import { cf as SiteRef, ca as PublicGate, cc as PublicSiteSignals } from './types-BedZ9_Y2.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Site theme: the accent tokens a public site derives from the owner's brand
|
|
5
|
+
* colour. Pure and framework-free, so a Next layout, a plain server and a
|
|
6
|
+
* settings preview share one reading of the colour.
|
|
7
|
+
*/
|
|
8
|
+
interface SiteThemeOptions {
|
|
9
|
+
/** Accent used when the primary colour is missing or not a six-digit hex. Default `#262626`. */
|
|
10
|
+
fallbackAccent?: string;
|
|
11
|
+
/** Text colour used on a light accent. Default `#171717`. */
|
|
12
|
+
darkText?: string;
|
|
13
|
+
}
|
|
14
|
+
/** The accent tokens of a site, as `#RRGGBB` strings. */
|
|
15
|
+
interface SiteTheme {
|
|
16
|
+
/** The normalised brand colour, or the fallback accent. */
|
|
17
|
+
accent: string;
|
|
18
|
+
/** White or the configured dark text, whichever contrasts more with the accent. */
|
|
19
|
+
accentForeground: string;
|
|
20
|
+
/** The accent darkened until it reads as text on white. */
|
|
21
|
+
accentText: string;
|
|
22
|
+
/**
|
|
23
|
+
* The hover and pressed accent: 14% darker, or 18% lighter for a
|
|
24
|
+
* near-black accent. Matches the `color-mix` the sites used in CSS.
|
|
25
|
+
*/
|
|
26
|
+
accentStrong: string;
|
|
27
|
+
/** A tint for selected and highlighted surfaces: the accent mixed with 90% white. */
|
|
28
|
+
accentSoft: string;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* What `themeStyle` reads. `accentStrong` and `accentSoft` are optional so a
|
|
32
|
+
* theme built by hand before they existed still renders; they are derived
|
|
33
|
+
* from `accent` when absent.
|
|
34
|
+
*/
|
|
35
|
+
type SiteThemeTokens = Pick<SiteTheme, "accent" | "accentForeground" | "accentText"> & Partial<Pick<SiteTheme, "accentStrong" | "accentSoft">>;
|
|
36
|
+
/**
|
|
37
|
+
* The site's accent from the platform's brand colour, with text colours that
|
|
38
|
+
* stay readable on it and on a white page, plus its hover and tint shades. A
|
|
39
|
+
* missing or malformed colour falls back to `options.fallbackAccent`.
|
|
40
|
+
*/
|
|
41
|
+
declare function createSiteTheme(primaryColor: string | undefined, options?: SiteThemeOptions): SiteTheme;
|
|
42
|
+
/**
|
|
43
|
+
* The theme as the CSS custom properties a site's `globals.css` reads:
|
|
44
|
+
* `--accent`, `--accent-foreground`, `--accent-text`, `--accent-strong` and
|
|
45
|
+
* `--accent-soft`. A plain record so the entry needs no React types; cast it
|
|
46
|
+
* to `CSSProperties` to pass it as a `style` prop.
|
|
47
|
+
*/
|
|
48
|
+
declare function themeStyle(theme: SiteThemeTokens): Record<string, string>;
|
|
2
49
|
|
|
3
50
|
/**
|
|
4
51
|
* Site signals: what a public site serves, decided from the `signals` block
|
|
5
52
|
* every bootstrap carries (dash init, workspace init and light init). Pure and
|
|
6
53
|
* framework-free, so a proxy, a layout and an admin screen share one reading.
|
|
7
54
|
* The server decides whether a gate applies; this only maps the decision to a
|
|
8
|
-
* request.
|
|
55
|
+
* request. The entry also carries the site theme helpers (`createSiteTheme`,
|
|
56
|
+
* `themeStyle`), which derive the accent tokens from the brand colour.
|
|
9
57
|
*/
|
|
10
58
|
|
|
11
59
|
type SiteGateKind = "waitlist" | "maintenance" | "private";
|
|
@@ -125,4 +173,4 @@ declare function toDateTimeLocal(value?: string): string;
|
|
|
125
173
|
/** A datetime-local value back to RFC 3339; undefined when empty or invalid. */
|
|
126
174
|
declare function fromDateTimeLocal(value: string): string | undefined;
|
|
127
175
|
|
|
128
|
-
export { GATE_EXEMPT_PATHS, PRIVATE_PATH, PublicGate, PublicSiteSignals, SITE_MODE_CHOICES, type SiteDecision, type SiteGate, type SiteGateKind, type SiteModeChoice, type SiteModeFields, SiteRef, type SiteResponse, type SiteSignals, UNAVAILABLE_PATH, describeLiveGate, fromDateTimeLocal, normalizeGate, normalizeSignals, siteDecision, siteModeChoice, siteResponse, toDateTimeLocal, withSiteModeChoice };
|
|
176
|
+
export { GATE_EXEMPT_PATHS, PRIVATE_PATH, PublicGate, PublicSiteSignals, SITE_MODE_CHOICES, type SiteDecision, type SiteGate, type SiteGateKind, type SiteModeChoice, type SiteModeFields, SiteRef, type SiteResponse, type SiteSignals, type SiteTheme, type SiteThemeOptions, type SiteThemeTokens, UNAVAILABLE_PATH, createSiteTheme, describeLiveGate, fromDateTimeLocal, normalizeGate, normalizeSignals, siteDecision, siteModeChoice, siteResponse, themeStyle, toDateTimeLocal, withSiteModeChoice };
|
package/dist/site.js
CHANGED
|
@@ -1,3 +1,73 @@
|
|
|
1
|
+
// src/site-theme.ts
|
|
2
|
+
var DEFAULT_FALLBACK_ACCENT = "#262626";
|
|
3
|
+
var DEFAULT_DARK_TEXT = "#171717";
|
|
4
|
+
var WHITE = "#FFFFFF";
|
|
5
|
+
var HEX_COLOR = /^#?([0-9a-f]{6})$/i;
|
|
6
|
+
var NEAR_BLACK_LUMINANCE = 0.02;
|
|
7
|
+
function rgbOf(value) {
|
|
8
|
+
return [1, 3, 5].map((offset) => Number.parseInt(value.slice(offset, offset + 2), 16));
|
|
9
|
+
}
|
|
10
|
+
function hexOf(rgb) {
|
|
11
|
+
return `#${rgb.map((value) => Math.round(value).toString(16).padStart(2, "0")).join("").toUpperCase()}`;
|
|
12
|
+
}
|
|
13
|
+
function linearize(value) {
|
|
14
|
+
return value <= 0.04045 ? value / 12.92 : ((value + 0.055) / 1.055) ** 2.4;
|
|
15
|
+
}
|
|
16
|
+
function relativeLuminance(value) {
|
|
17
|
+
const [r, g, b] = rgbOf(value).map((channel) => linearize(channel / 255));
|
|
18
|
+
return 0.2126 * r + 0.7152 * g + 0.0722 * b;
|
|
19
|
+
}
|
|
20
|
+
function contrast(lighter, darker) {
|
|
21
|
+
return (lighter + 0.05) / (darker + 0.05);
|
|
22
|
+
}
|
|
23
|
+
function mix(accent, target, weight) {
|
|
24
|
+
return hexOf(rgbOf(accent).map((value) => value * (1 - weight) + target * weight));
|
|
25
|
+
}
|
|
26
|
+
function readableAccentText(accent) {
|
|
27
|
+
let rgb = rgbOf(accent);
|
|
28
|
+
let candidate = accent;
|
|
29
|
+
while (contrast(1, relativeLuminance(candidate)) < 5) {
|
|
30
|
+
rgb = rgb.map((value) => Math.floor(value * 0.82));
|
|
31
|
+
candidate = hexOf(rgb);
|
|
32
|
+
}
|
|
33
|
+
return candidate;
|
|
34
|
+
}
|
|
35
|
+
function strongAccent(accent) {
|
|
36
|
+
return relativeLuminance(accent) < NEAR_BLACK_LUMINANCE ? mix(accent, 255, 0.18) : mix(accent, 0, 0.14);
|
|
37
|
+
}
|
|
38
|
+
function softAccent(accent) {
|
|
39
|
+
return mix(accent, 255, 0.9);
|
|
40
|
+
}
|
|
41
|
+
function normalizeHex(value) {
|
|
42
|
+
const match = value.trim().match(HEX_COLOR);
|
|
43
|
+
return match ? `#${match[1].toUpperCase()}` : void 0;
|
|
44
|
+
}
|
|
45
|
+
function createSiteTheme(primaryColor, options = {}) {
|
|
46
|
+
const fallback = options.fallbackAccent ?? DEFAULT_FALLBACK_ACCENT;
|
|
47
|
+
const darkText = options.darkText ?? DEFAULT_DARK_TEXT;
|
|
48
|
+
const accent = (primaryColor === void 0 ? void 0 : normalizeHex(primaryColor)) ?? fallback;
|
|
49
|
+
const luminance = relativeLuminance(accent);
|
|
50
|
+
const whiteContrast = contrast(1, luminance);
|
|
51
|
+
const darkContrast = contrast(luminance, relativeLuminance(darkText));
|
|
52
|
+
return {
|
|
53
|
+
accent,
|
|
54
|
+
accentForeground: whiteContrast >= darkContrast ? WHITE : darkText,
|
|
55
|
+
accentText: readableAccentText(accent),
|
|
56
|
+
accentStrong: strongAccent(accent),
|
|
57
|
+
accentSoft: softAccent(accent)
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
function themeStyle(theme) {
|
|
61
|
+
const accent = normalizeHex(theme.accent);
|
|
62
|
+
return {
|
|
63
|
+
"--accent": theme.accent,
|
|
64
|
+
"--accent-foreground": theme.accentForeground,
|
|
65
|
+
"--accent-text": theme.accentText,
|
|
66
|
+
"--accent-strong": theme.accentStrong ?? (accent ? strongAccent(accent) : theme.accent),
|
|
67
|
+
"--accent-soft": theme.accentSoft ?? (accent ? softAccent(accent) : theme.accent)
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
|
|
1
71
|
// src/site.ts
|
|
2
72
|
var GATE_EXEMPT_PATHS = [
|
|
3
73
|
"/api",
|
|
@@ -125,4 +195,4 @@ function fromDateTimeLocal(value) {
|
|
|
125
195
|
return Number.isNaN(date.getTime()) ? void 0 : date.toISOString();
|
|
126
196
|
}
|
|
127
197
|
|
|
128
|
-
export { GATE_EXEMPT_PATHS, PRIVATE_PATH, SITE_MODE_CHOICES, UNAVAILABLE_PATH, describeLiveGate, fromDateTimeLocal, normalizeGate, normalizeSignals, siteDecision, siteModeChoice, siteResponse, toDateTimeLocal, withSiteModeChoice };
|
|
198
|
+
export { GATE_EXEMPT_PATHS, PRIVATE_PATH, SITE_MODE_CHOICES, UNAVAILABLE_PATH, createSiteTheme, describeLiveGate, fromDateTimeLocal, normalizeGate, normalizeSignals, siteDecision, siteModeChoice, siteResponse, themeStyle, toDateTimeLocal, withSiteModeChoice };
|
|
@@ -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;
|
|
@@ -1872,4 +1870,4 @@ interface AccountPayment {
|
|
|
1872
1870
|
reference: string;
|
|
1873
1871
|
}
|
|
1874
1872
|
|
|
1875
|
-
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,
|
|
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,17 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@c1m-public/channel-client",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "6.1.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"description": "Typed server-side client for the MML headless Channel API",
|
|
7
7
|
"repository": {
|
|
8
8
|
"type": "git",
|
|
9
|
-
"url": "https://github.com/cloud1mediaLtd/
|
|
10
|
-
"directory": "packages/channel-client"
|
|
9
|
+
"url": "https://github.com/cloud1mediaLtd/workspace-site-starter.git"
|
|
11
10
|
},
|
|
12
|
-
"homepage": "https://github.com/cloud1mediaLtd/
|
|
11
|
+
"homepage": "https://github.com/cloud1mediaLtd/workspace-site-starter#readme",
|
|
13
12
|
"bugs": {
|
|
14
|
-
"url": "https://github.com/cloud1mediaLtd/
|
|
13
|
+
"url": "https://github.com/cloud1mediaLtd/workspace-site-starter/issues"
|
|
15
14
|
},
|
|
16
15
|
"main": "./dist/index.js",
|
|
17
16
|
"types": "./dist/index.d.ts",
|
|
@@ -44,6 +43,10 @@
|
|
|
44
43
|
"types": "./dist/site.d.ts",
|
|
45
44
|
"default": "./dist/site.js"
|
|
46
45
|
},
|
|
46
|
+
"./leads": {
|
|
47
|
+
"types": "./dist/leads.d.ts",
|
|
48
|
+
"default": "./dist/leads.js"
|
|
49
|
+
},
|
|
47
50
|
"./moving-lead-model": {
|
|
48
51
|
"types": "./dist/moving-lead-model/index.d.ts",
|
|
49
52
|
"default": "./dist/moving-lead-model/index.js"
|