@c1m-public/channel-client 0.28.0 → 0.30.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 +29 -0
- package/dist/{chunk-CPQT34K2.js → chunk-EDG3ZGPF.js} +2 -1
- package/dist/dash-next.d.ts +1 -0
- package/dist/dash-next.js +1 -1
- package/dist/dash.d.ts +1 -0
- package/dist/index.d.ts +3 -1332
- package/dist/next.d.ts +2 -1
- package/dist/next.js +1 -1
- package/dist/site.d.ts +107 -0
- package/dist/site.js +109 -0
- package/dist/types-DPJD4m2o.d.ts +1358 -0
- package/package.json +5 -1
package/dist/next.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { createChannelClient,
|
|
1
|
+
import { createChannelClient, ChannelCheckoutStatusParams, ChannelMutationOptions, CreateChannelClientOptions, ChannelVisitor, DashDirectoryListParams, ChannelLeadInput, ChannelSiteResolveParams, ChannelListParams, ChannelProductListParams, ChannelSubscriptionListParams, ChannelSubscriptionCancelParams, ChannelInvoiceListParams } 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 WaitlistVerification, k as WaitlistUnsubscription, D as DashProfileResponse, l as DashInitResponse, m as WaitlistGateStatus, n as WaitlistFormSettings, o as WaitlistSubmission, p as WaitlistAcknowledgement, q as DashPlansResponse, L as ListResponse, r as DashDirectoryRegion, s as DashDirectoryEntry, t as DashDirectoryProfileResponse, u as DashLead, v as DashLeadPortalRequestLinkInput, w as DashLeadPortalRequestLinkResponse, x as DashLeadPortalView, S as SiteDocument, y as PublicWorkspaceInit, z as LightInitResponse, B as PublicPageSummary, E as PublicPage, F as Product, G as ProductAsset, H as CatalogCategory, I as CatalogProductsResponse, J as CatalogCollection, K as CatalogBrand, U as UpdateCartItemInput, M as MergeCartInput, R as Review, N as ReviewSummaryResponse, Q as PublicSubmitReviewInput, T as ThemeResponse, V as MenuResponse, X as BlogPost, Y as BlogPostResponse, Z as GivingEntry, _ as StartGivingInput, $ as StartGivingResponse, a0 as SubscriptionPlanListResponse, a1 as SubscriptionPlanResponse, a2 as PublicPaymentLinkResponse, a3 as PaymentLinkCheckoutInput, a4 as PaymentLinkCheckoutResponse, a5 as PaymentLinkRedemptionStatusResponse, a6 as PrintSettingsResponse, a7 as PrintOptionsSelection, a8 as PrintQuoteResponse, a9 as PrintIntakeInput, aa as PrintJob, ab as DiningMenu, ac as CustomerSignupResponse, ad as SendCodeResponse, ae as CustomerSession, af as CustomerResponse, ag as CustomerAuthSession, ah as CustomerSecurityActivityPage, ai as OrderSummary, aj as SavedAddress, ak as SavedAddressResponse, al as SavedAddressInput, am as SavedAddressUpdateInput, an as SavedPaymentMethod, ao as PaymentMethodSetupInput, ap as PaymentMethodSetupResult, aq as PaymentMethodConfirmInput, ar as PaymentMethodMutationResponse, as as StartSubscriptionInput, at as SubscriptionAgreementResponse, au as SubscriptionListResponse, av as SubscriptionSourceResponse, aw as SubscriptionInvoiceListResponse, ax as SubscriptionInvoiceResponse, ay as GivingIntentListResponse, az as LeadResponse } from './types-DPJD4m2o.js';
|
|
2
3
|
import { ChannelWebhookEventDataMap, ChannelWebhookEvent } from './webhooks.js';
|
|
3
4
|
|
|
4
5
|
/**
|
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-
|
|
1
|
+
export { CHANNEL_CATALOG_CACHE_TAG, CHANNEL_SITE_CACHE_TAG, cartCookie, createCart, createChannelWebhookRoute, createCustomerSession, createNextChannelClient, defaultChannelCacheTags, safePublishedPath, sessionCookie } from './chunk-EDG3ZGPF.js';
|
|
2
2
|
import './chunk-LBOYLZ4J.js';
|
|
3
3
|
import './chunk-XPO7C3DW.js';
|
package/dist/site.d.ts
ADDED
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import { bl as SiteRef, bg as PublicGate, bi as PublicSiteSignals } from './types-DPJD4m2o.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Site signals: what a public site serves, decided from the `signals` block
|
|
5
|
+
* every bootstrap carries (dash init, workspace init and light init). Pure and
|
|
6
|
+
* framework-free, so a proxy, a layout and an admin screen share one reading.
|
|
7
|
+
* The server decides whether a gate applies; this only maps the decision to a
|
|
8
|
+
* request.
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
type SiteGateKind = "waitlist" | "maintenance" | "private";
|
|
12
|
+
/** A gate this client understands, in site-code casing. */
|
|
13
|
+
interface SiteGate {
|
|
14
|
+
kind: SiteGateKind;
|
|
15
|
+
placement: "page" | "block";
|
|
16
|
+
/** The gate's own page; empty for private (rendered in place). */
|
|
17
|
+
path: string;
|
|
18
|
+
enforcement: "redirect" | "rewrite";
|
|
19
|
+
status?: number;
|
|
20
|
+
retryAfter?: number;
|
|
21
|
+
message?: string;
|
|
22
|
+
/** RFC 3339 end of a maintenance window. */
|
|
23
|
+
until?: string;
|
|
24
|
+
}
|
|
25
|
+
interface SiteSignals {
|
|
26
|
+
site: SiteRef | null;
|
|
27
|
+
gate: SiteGate | null;
|
|
28
|
+
/** The owner's state; only `active` serves normally. */
|
|
29
|
+
lifecycle: string;
|
|
30
|
+
visibility: "public" | "private";
|
|
31
|
+
/** Whether the owner's plan includes a public site. */
|
|
32
|
+
siteEnabled: boolean;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Paths no gate touches: framework and API routes, crawler files and legal
|
|
36
|
+
* pages (consent must stay readable). Sites add their own (account, payment
|
|
37
|
+
* links) through `exempt`.
|
|
38
|
+
*/
|
|
39
|
+
declare const GATE_EXEMPT_PATHS: readonly string[];
|
|
40
|
+
/**
|
|
41
|
+
* Keeps only a gate this client can enforce. An unknown kind is dropped, so a
|
|
42
|
+
* mode added on the server after a site shipped never breaks that site.
|
|
43
|
+
*/
|
|
44
|
+
declare function normalizeGate(gate: Partial<PublicGate> | null | undefined): SiteGate | null;
|
|
45
|
+
/**
|
|
46
|
+
* Reads a bootstrap's signals. A backend older than the signals block sends
|
|
47
|
+
* only the top-level `gate` and `site`; those are read as an active, public,
|
|
48
|
+
* entitled site so an upgrade never depends on release order.
|
|
49
|
+
*/
|
|
50
|
+
declare function normalizeSignals(bootstrap: {
|
|
51
|
+
signals?: PublicSiteSignals;
|
|
52
|
+
gate?: PublicGate;
|
|
53
|
+
site?: SiteRef;
|
|
54
|
+
} | null | undefined): SiteSignals;
|
|
55
|
+
/** What a request gets. `gate-page` is the gate's own page, served bare. */
|
|
56
|
+
type SiteDecision = {
|
|
57
|
+
type: "serve";
|
|
58
|
+
} | {
|
|
59
|
+
type: "no-site";
|
|
60
|
+
} | {
|
|
61
|
+
type: "inactive";
|
|
62
|
+
lifecycle: string;
|
|
63
|
+
} | {
|
|
64
|
+
type: "private";
|
|
65
|
+
} | {
|
|
66
|
+
type: "gate-page";
|
|
67
|
+
gate: SiteGate;
|
|
68
|
+
} | {
|
|
69
|
+
type: "redirect";
|
|
70
|
+
path: string;
|
|
71
|
+
} | {
|
|
72
|
+
type: "rewrite";
|
|
73
|
+
path: string;
|
|
74
|
+
status: number;
|
|
75
|
+
retryAfter?: number;
|
|
76
|
+
};
|
|
77
|
+
/**
|
|
78
|
+
* Decides one request, in the server's order: no public site, then an
|
|
79
|
+
* inactive owner, then the gate. Exempt paths are always served. `private`
|
|
80
|
+
* means the public may not see the site; a site with member sessions checks
|
|
81
|
+
* membership (site/resolve does) before showing its private page.
|
|
82
|
+
*/
|
|
83
|
+
declare function siteDecision(signals: SiteSignals, pathname: string, options?: {
|
|
84
|
+
exempt?: readonly string[];
|
|
85
|
+
}): SiteDecision;
|
|
86
|
+
/** A site mode as an owner picks it: mode and placement in one choice. */
|
|
87
|
+
type SiteModeChoice = "off" | "waitlist-page" | "waitlist-block" | "maintenance";
|
|
88
|
+
interface SiteModeFields {
|
|
89
|
+
mode: "off" | "waitlist" | "maintenance";
|
|
90
|
+
placement: "page" | "block";
|
|
91
|
+
}
|
|
92
|
+
declare const SITE_MODE_CHOICES: readonly {
|
|
93
|
+
value: SiteModeChoice;
|
|
94
|
+
label: string;
|
|
95
|
+
description: string;
|
|
96
|
+
}[];
|
|
97
|
+
declare function siteModeChoice(cfg: SiteModeFields): SiteModeChoice;
|
|
98
|
+
/** Applies a choice to a configuration, keeping its other settings. */
|
|
99
|
+
declare function withSiteModeChoice<T extends SiteModeFields>(base: T, choice: SiteModeChoice): T;
|
|
100
|
+
/** One line for what visitors see now, from the server-decided gate. */
|
|
101
|
+
declare function describeLiveGate(gate: Pick<PublicGate, "kind" | "placement"> | null | undefined): string;
|
|
102
|
+
/** An RFC 3339 instant as a datetime-local value in the viewer's zone. */
|
|
103
|
+
declare function toDateTimeLocal(value?: string): string;
|
|
104
|
+
/** A datetime-local value back to RFC 3339; undefined when empty or invalid. */
|
|
105
|
+
declare function fromDateTimeLocal(value: string): string | undefined;
|
|
106
|
+
|
|
107
|
+
export { GATE_EXEMPT_PATHS, PublicGate, PublicSiteSignals, SITE_MODE_CHOICES, type SiteDecision, type SiteGate, type SiteGateKind, type SiteModeChoice, type SiteModeFields, SiteRef, type SiteSignals, describeLiveGate, fromDateTimeLocal, normalizeGate, normalizeSignals, siteDecision, siteModeChoice, toDateTimeLocal, withSiteModeChoice };
|
package/dist/site.js
ADDED
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
// src/site.ts
|
|
2
|
+
var GATE_EXEMPT_PATHS = [
|
|
3
|
+
"/api",
|
|
4
|
+
"/_next",
|
|
5
|
+
"/.well-known",
|
|
6
|
+
"/robots.txt",
|
|
7
|
+
"/sitemap.xml",
|
|
8
|
+
"/favicon.ico",
|
|
9
|
+
"/privacy",
|
|
10
|
+
"/terms",
|
|
11
|
+
"/cookies",
|
|
12
|
+
"/legal"
|
|
13
|
+
];
|
|
14
|
+
var DEFAULT_GATE_PATH = { waitlist: "/waitlist", maintenance: "/maintenance" };
|
|
15
|
+
function safePath(path) {
|
|
16
|
+
return typeof path === "string" && path.startsWith("/") && !path.startsWith("//") ? path : void 0;
|
|
17
|
+
}
|
|
18
|
+
function normalizeGate(gate) {
|
|
19
|
+
const kind = gate?.kind;
|
|
20
|
+
if (kind === "private") return { kind, placement: "page", path: "", enforcement: "rewrite" };
|
|
21
|
+
if (kind !== "waitlist" && kind !== "maintenance") return null;
|
|
22
|
+
const placement = kind === "maintenance" ? "page" : gate?.placement;
|
|
23
|
+
if (placement !== "page" && placement !== "block") return null;
|
|
24
|
+
const enforcement = gate?.enforcement === "rewrite" || gate?.enforcement === "redirect" ? gate.enforcement : kind === "maintenance" ? "rewrite" : "redirect";
|
|
25
|
+
const status = kind === "maintenance" ? 503 : typeof gate?.status === "number" ? gate.status : void 0;
|
|
26
|
+
const message = typeof gate?.message === "string" ? gate.message.trim() : "";
|
|
27
|
+
return {
|
|
28
|
+
kind,
|
|
29
|
+
placement,
|
|
30
|
+
enforcement,
|
|
31
|
+
path: safePath(gate?.path) ?? DEFAULT_GATE_PATH[kind],
|
|
32
|
+
...status ? { status } : {},
|
|
33
|
+
...typeof gate?.retry_after === "number" && gate.retry_after > 0 ? { retryAfter: Math.ceil(gate.retry_after) } : {},
|
|
34
|
+
...message ? { message } : {},
|
|
35
|
+
...typeof gate?.until === "string" ? { until: gate.until } : {}
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
function normalizeSignals(bootstrap) {
|
|
39
|
+
const signals = bootstrap?.signals;
|
|
40
|
+
if (!signals) {
|
|
41
|
+
return { site: bootstrap?.site ?? null, gate: normalizeGate(bootstrap?.gate), lifecycle: "active", visibility: "public", siteEnabled: true };
|
|
42
|
+
}
|
|
43
|
+
return {
|
|
44
|
+
site: signals.site ?? null,
|
|
45
|
+
gate: normalizeGate(signals.gate),
|
|
46
|
+
lifecycle: signals.lifecycle || "active",
|
|
47
|
+
visibility: signals.visibility === "private" ? "private" : "public",
|
|
48
|
+
siteEnabled: signals.site_enabled !== false
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
function underPath(pathname, prefix) {
|
|
52
|
+
return pathname === prefix || pathname.startsWith(prefix.endsWith("/") ? prefix : `${prefix}/`);
|
|
53
|
+
}
|
|
54
|
+
function siteDecision(signals, pathname, options = {}) {
|
|
55
|
+
const exempt = [...GATE_EXEMPT_PATHS, ...options.exempt ?? []];
|
|
56
|
+
if (exempt.some((prefix) => underPath(pathname, prefix))) return { type: "serve" };
|
|
57
|
+
if (!signals.siteEnabled) return { type: "no-site" };
|
|
58
|
+
if (signals.lifecycle !== "active") return { type: "inactive", lifecycle: signals.lifecycle };
|
|
59
|
+
const gate = signals.gate;
|
|
60
|
+
if (!gate || gate.placement !== "page") return { type: "serve" };
|
|
61
|
+
if (gate.kind === "private") return { type: "private" };
|
|
62
|
+
if (underPath(pathname, gate.path)) return { type: "gate-page", gate };
|
|
63
|
+
if (gate.enforcement === "rewrite") {
|
|
64
|
+
return { type: "rewrite", path: gate.path, status: gate.status ?? 200, ...gate.retryAfter ? { retryAfter: gate.retryAfter } : {} };
|
|
65
|
+
}
|
|
66
|
+
return { type: "redirect", path: gate.path };
|
|
67
|
+
}
|
|
68
|
+
var SITE_MODE_CHOICES = [
|
|
69
|
+
{ value: "off", label: "Live", description: "Visitors see the normal site." },
|
|
70
|
+
{ value: "waitlist-page", label: "Waitlist page", description: "Every storefront page redirects to /waitlist. Account and legal pages stay reachable." },
|
|
71
|
+
{ value: "waitlist-block", label: "Waitlist block", description: "The site stays public; pages can embed the signup form." },
|
|
72
|
+
{ value: "maintenance", label: "Maintenance", description: "Every storefront page shows a maintenance notice (HTTP 503). Legal pages stay reachable." }
|
|
73
|
+
];
|
|
74
|
+
function siteModeChoice(cfg) {
|
|
75
|
+
if (cfg.mode === "maintenance") return "maintenance";
|
|
76
|
+
if (cfg.mode === "waitlist") return cfg.placement === "block" ? "waitlist-block" : "waitlist-page";
|
|
77
|
+
return "off";
|
|
78
|
+
}
|
|
79
|
+
function withSiteModeChoice(base, choice) {
|
|
80
|
+
switch (choice) {
|
|
81
|
+
case "off":
|
|
82
|
+
return { ...base, mode: "off" };
|
|
83
|
+
case "maintenance":
|
|
84
|
+
return { ...base, mode: "maintenance", placement: "page" };
|
|
85
|
+
case "waitlist-block":
|
|
86
|
+
return { ...base, mode: "waitlist", placement: "block" };
|
|
87
|
+
default:
|
|
88
|
+
return { ...base, mode: "waitlist", placement: "page" };
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
function describeLiveGate(gate) {
|
|
92
|
+
if (!gate) return "Live \xB7 visitors see the normal site";
|
|
93
|
+
if (gate.kind === "maintenance") return "Maintenance \xB7 visitors see the maintenance notice";
|
|
94
|
+
if (gate.kind === "private") return "Private \xB7 only members see the site";
|
|
95
|
+
return gate.placement === "page" ? "Waitlist \xB7 every page redirects to /waitlist" : "Waitlist \xB7 the site stays open with a signup form";
|
|
96
|
+
}
|
|
97
|
+
function toDateTimeLocal(value) {
|
|
98
|
+
if (!value) return "";
|
|
99
|
+
const date = new Date(value);
|
|
100
|
+
if (Number.isNaN(date.getTime())) return "";
|
|
101
|
+
return new Date(date.getTime() - date.getTimezoneOffset() * 6e4).toISOString().slice(0, 16);
|
|
102
|
+
}
|
|
103
|
+
function fromDateTimeLocal(value) {
|
|
104
|
+
if (!value) return void 0;
|
|
105
|
+
const date = new Date(value);
|
|
106
|
+
return Number.isNaN(date.getTime()) ? void 0 : date.toISOString();
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
export { GATE_EXEMPT_PATHS, SITE_MODE_CHOICES, describeLiveGate, fromDateTimeLocal, normalizeGate, normalizeSignals, siteDecision, siteModeChoice, toDateTimeLocal, withSiteModeChoice };
|