@c1m-public/channel-client 0.5.0 → 0.8.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 +67 -5
- package/dist/index.d.ts +44 -10
- package/dist/index.js +92 -10
- package/dist/next-cart.d.ts +76 -0
- package/dist/next-cart.js +87 -0
- package/dist/next-session.d.ts +109 -0
- package/dist/next-session.js +178 -0
- package/dist/next-webhooks.d.ts +58 -0
- package/dist/next-webhooks.js +112 -0
- package/dist/next.d.ts +34 -6
- package/dist/next.js +7 -0
- package/dist/types.d.ts +314 -0
- package/dist/webhooks.d.ts +42 -2
- package/dist/webhooks.js +61 -2
- package/package.json +1 -1
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
import "server-only";
|
|
2
|
+
import { createChannelClient, isChannelAPIError } from "./index.js";
|
|
3
|
+
function inProduction() {
|
|
4
|
+
return typeof process !== "undefined" && process?.env?.NODE_ENV === "production";
|
|
5
|
+
}
|
|
6
|
+
/** Match the refresh token's life (~30 days), not the access token's (~15 min). */
|
|
7
|
+
const MAX_AGE_SECONDS = 60 * 60 * 24 * 30;
|
|
8
|
+
/** Refresh slightly BEFORE expiry: a token that dies mid-render fails the request it was meant to serve. */
|
|
9
|
+
const REFRESH_SKEW_MS = 60_000;
|
|
10
|
+
/**
|
|
11
|
+
* The one definition of the session cookie. A second definition is how a cookie
|
|
12
|
+
* ends up readable on one path and not another.
|
|
13
|
+
*/
|
|
14
|
+
export const sessionCookie = {
|
|
15
|
+
name: "c1m_session",
|
|
16
|
+
attributes(isProduction = inProduction()) {
|
|
17
|
+
return {
|
|
18
|
+
// Never readable from JavaScript: an XSS bug must not become a stolen session.
|
|
19
|
+
httpOnly: true,
|
|
20
|
+
secure: isProduction,
|
|
21
|
+
// Lax, not Strict: the session must survive a customer arriving from an
|
|
22
|
+
// emailed link. Not None — that would ship the cookie cross-site.
|
|
23
|
+
sameSite: "lax",
|
|
24
|
+
path: "/",
|
|
25
|
+
maxAge: MAX_AGE_SECONDS,
|
|
26
|
+
};
|
|
27
|
+
},
|
|
28
|
+
serialize(tokens) {
|
|
29
|
+
return JSON.stringify(tokens);
|
|
30
|
+
},
|
|
31
|
+
/**
|
|
32
|
+
* A cookie is attacker-controlled input: truncated, stale-shaped, or
|
|
33
|
+
* hand-written. Anything unreadable is "not signed in", never a crash.
|
|
34
|
+
*/
|
|
35
|
+
parse(raw) {
|
|
36
|
+
if (!raw)
|
|
37
|
+
return null;
|
|
38
|
+
try {
|
|
39
|
+
const parsed = JSON.parse(raw);
|
|
40
|
+
if (!parsed || typeof parsed !== "object")
|
|
41
|
+
return null;
|
|
42
|
+
const { accessToken, refreshToken, expiresAt } = parsed;
|
|
43
|
+
if (typeof accessToken !== "string" || !accessToken)
|
|
44
|
+
return null;
|
|
45
|
+
if (typeof refreshToken !== "string" || !refreshToken)
|
|
46
|
+
return null;
|
|
47
|
+
if (typeof expiresAt !== "string" || !expiresAt)
|
|
48
|
+
return null;
|
|
49
|
+
return { accessToken, refreshToken, expiresAt };
|
|
50
|
+
}
|
|
51
|
+
catch {
|
|
52
|
+
return null;
|
|
53
|
+
}
|
|
54
|
+
},
|
|
55
|
+
needsRefresh(tokens, now = Date.now()) {
|
|
56
|
+
const expiresAt = Date.parse(tokens.expiresAt);
|
|
57
|
+
// Unparseable expiry: refresh and find out, rather than trusting it forever.
|
|
58
|
+
if (Number.isNaN(expiresAt))
|
|
59
|
+
return true;
|
|
60
|
+
return expiresAt - now <= REFRESH_SKEW_MS;
|
|
61
|
+
},
|
|
62
|
+
};
|
|
63
|
+
/** The server's code for "another request rotated this token moments ago". */
|
|
64
|
+
const CONTESTED = "refresh_contested";
|
|
65
|
+
function normalizeCustomer(customer) {
|
|
66
|
+
return {
|
|
67
|
+
id: customer.id,
|
|
68
|
+
email: customer.email,
|
|
69
|
+
name: customer.name?.trim() || customer.email,
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
function toTokens(session) {
|
|
73
|
+
return {
|
|
74
|
+
accessToken: session.access_token,
|
|
75
|
+
refreshToken: session.refresh_token,
|
|
76
|
+
expiresAt: session.expires_at,
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* The session surface a site actually needs, mapped to intentional outcomes —
|
|
81
|
+
* a route renders "that code was wrong" without ever seeing an HTTP status.
|
|
82
|
+
*/
|
|
83
|
+
export function createCustomerSession(options) {
|
|
84
|
+
const resolve = typeof options.client === "function" ? options.client : () => options.client;
|
|
85
|
+
return {
|
|
86
|
+
cookie: sessionCookie,
|
|
87
|
+
async requestCode(email) {
|
|
88
|
+
try {
|
|
89
|
+
await resolve().auth.sendCode(email);
|
|
90
|
+
return { state: "sent" };
|
|
91
|
+
}
|
|
92
|
+
catch {
|
|
93
|
+
return { state: "failed" };
|
|
94
|
+
}
|
|
95
|
+
},
|
|
96
|
+
async signIn(email, code) {
|
|
97
|
+
try {
|
|
98
|
+
const session = await resolve().auth.verifyCode({ email, code });
|
|
99
|
+
const tokens = toTokens(session);
|
|
100
|
+
return {
|
|
101
|
+
state: "signed-in",
|
|
102
|
+
customer: normalizeCustomer(session.end_user),
|
|
103
|
+
tokens,
|
|
104
|
+
cookie: {
|
|
105
|
+
name: sessionCookie.name,
|
|
106
|
+
value: sessionCookie.serialize(tokens),
|
|
107
|
+
attributes: sessionCookie.attributes(),
|
|
108
|
+
},
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
catch (error) {
|
|
112
|
+
// A wrong code is an ordinary thing a person does, not a failure.
|
|
113
|
+
if (isChannelAPIError(error) && error.code === "invalid_code") {
|
|
114
|
+
return { state: "invalid-code" };
|
|
115
|
+
}
|
|
116
|
+
return { state: "failed" };
|
|
117
|
+
}
|
|
118
|
+
},
|
|
119
|
+
/**
|
|
120
|
+
* Decide what this request should do to the session cookie. Designed to be
|
|
121
|
+
* the whole body of proxy.ts.
|
|
122
|
+
*/
|
|
123
|
+
async refresh(raw) {
|
|
124
|
+
const session = sessionCookie.parse(raw);
|
|
125
|
+
if (!session)
|
|
126
|
+
return { action: "keep" };
|
|
127
|
+
if (!sessionCookie.needsRefresh(session))
|
|
128
|
+
return { action: "keep" };
|
|
129
|
+
try {
|
|
130
|
+
const rotated = await resolve().auth.refresh(session.refreshToken);
|
|
131
|
+
return {
|
|
132
|
+
action: "write",
|
|
133
|
+
value: sessionCookie.serialize(toTokens(rotated)),
|
|
134
|
+
attributes: sessionCookie.attributes(),
|
|
135
|
+
};
|
|
136
|
+
}
|
|
137
|
+
catch (error) {
|
|
138
|
+
if (isChannelAPIError(error)) {
|
|
139
|
+
// Lost a race with the customer's own other tab: the session is alive
|
|
140
|
+
// and that tab already stored a good token. KEEP the cookie.
|
|
141
|
+
if (error.code === CONTESTED)
|
|
142
|
+
return { action: "keep" };
|
|
143
|
+
// Genuinely dead — logged out, revoked, or aged out. Clear it.
|
|
144
|
+
if (error.status === 401)
|
|
145
|
+
return { action: "clear" };
|
|
146
|
+
}
|
|
147
|
+
// An upstream wobble is not evidence anyone's session is dead.
|
|
148
|
+
return { action: "keep" };
|
|
149
|
+
}
|
|
150
|
+
},
|
|
151
|
+
/** Who is signed in, or null. Never throws — a broken cookie is "signed out". */
|
|
152
|
+
async getCustomer(raw) {
|
|
153
|
+
const session = sessionCookie.parse(raw);
|
|
154
|
+
if (!session)
|
|
155
|
+
return null;
|
|
156
|
+
try {
|
|
157
|
+
const { end_user } = await resolve().withCustomer(session.accessToken).me();
|
|
158
|
+
return normalizeCustomer(end_user);
|
|
159
|
+
}
|
|
160
|
+
catch {
|
|
161
|
+
return null;
|
|
162
|
+
}
|
|
163
|
+
},
|
|
164
|
+
/** Best-effort server logout; the caller clears the cookie REGARDLESS. */
|
|
165
|
+
async signOut(raw) {
|
|
166
|
+
const session = sessionCookie.parse(raw);
|
|
167
|
+
if (!session)
|
|
168
|
+
return;
|
|
169
|
+
try {
|
|
170
|
+
await resolve().withCustomer(session.accessToken).logout();
|
|
171
|
+
}
|
|
172
|
+
catch {
|
|
173
|
+
// A customer who clicks "sign out" must end up signed out of this
|
|
174
|
+
// browser even if the API is down.
|
|
175
|
+
}
|
|
176
|
+
},
|
|
177
|
+
};
|
|
178
|
+
}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import "server-only";
|
|
2
|
+
import { type ChannelWebhookEvent, type ChannelWebhookEventDataMap } from "./webhooks.js";
|
|
3
|
+
/**
|
|
4
|
+
* Webhook route factory: the whole app/api/webhooks/c1m/route.ts in one call.
|
|
5
|
+
*
|
|
6
|
+
* import { revalidatePath, revalidateTag } from "next/cache";
|
|
7
|
+
* export const POST = createChannelWebhookRoute({
|
|
8
|
+
* secret: () => process.env.C1M_CHANNEL_WEBHOOK_SECRET!,
|
|
9
|
+
* invalidate: { revalidatePath, revalidateTag },
|
|
10
|
+
* });
|
|
11
|
+
*
|
|
12
|
+
* The invalidator is injected rather than imported here on purpose: it keeps
|
|
13
|
+
* this module free of `next` (bundler-safe, unit-testable with a fake), and it
|
|
14
|
+
* is the app's two-line import — not eighty lines of verification, dispatch,
|
|
15
|
+
* path-safety and error-mapping boilerplate.
|
|
16
|
+
*/
|
|
17
|
+
/** The cache tag every anonymous site read is filed under. */
|
|
18
|
+
export declare const CHANNEL_SITE_CACHE_TAG = "channel:site";
|
|
19
|
+
/**
|
|
20
|
+
* The cache tag catalog reads (product list, product detail) are filed under.
|
|
21
|
+
* `product.*` events bust this tag by default, so a merchant's price edit
|
|
22
|
+
* reaches the storefront on the next request instead of at the end of a TTL.
|
|
23
|
+
*/
|
|
24
|
+
export declare const CHANNEL_CATALOG_CACHE_TAG = "channel:catalog";
|
|
25
|
+
export interface ChannelCacheInvalidator {
|
|
26
|
+
revalidatePath(path: string): void;
|
|
27
|
+
revalidateTag(tag: string): void;
|
|
28
|
+
}
|
|
29
|
+
export interface ChannelWebhookRouteLogger {
|
|
30
|
+
info(message: string, context?: Record<string, unknown>): void;
|
|
31
|
+
warn(message: string, context?: Record<string, unknown>): void;
|
|
32
|
+
error(message: string, context?: Record<string, unknown>): void;
|
|
33
|
+
}
|
|
34
|
+
export type ChannelWebhookHandlers = {
|
|
35
|
+
[T in keyof ChannelWebhookEventDataMap]?: (event: ChannelWebhookEvent<T>, invalidate: ChannelCacheInvalidator) => void | Promise<void>;
|
|
36
|
+
};
|
|
37
|
+
export interface CreateChannelWebhookRouteOptions {
|
|
38
|
+
/** The whsec_ signing secret, or a lazy resolver (resolved per request so builds without env pass). */
|
|
39
|
+
secret: string | (() => string);
|
|
40
|
+
/** Next's cache invalidation, injected: `{ revalidatePath, revalidateTag }` from next/cache. */
|
|
41
|
+
invalidate: ChannelCacheInvalidator;
|
|
42
|
+
/**
|
|
43
|
+
* Per-event handlers. A handler REPLACES the built-in behavior for that type;
|
|
44
|
+
* types without a handler get the default (page.published revalidates the
|
|
45
|
+
* site tag + the published path; everything else is acknowledged and ignored
|
|
46
|
+
* — delivery is at-least-once, so an unhandled event must still 204 or the
|
|
47
|
+
* server will retry it for hours).
|
|
48
|
+
*/
|
|
49
|
+
onEvent?: ChannelWebhookHandlers;
|
|
50
|
+
logger?: ChannelWebhookRouteLogger;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* A route_pattern arrives from the network; it is input, not truth. Reject
|
|
54
|
+
* anything that is not a plain absolute path before handing it to the cache.
|
|
55
|
+
*/
|
|
56
|
+
export declare function safePublishedPath(path: string): string | undefined;
|
|
57
|
+
/** Build the POST handler for the channel webhook endpoint. */
|
|
58
|
+
export declare function createChannelWebhookRoute(options: CreateChannelWebhookRouteOptions): (request: Request) => Promise<Response>;
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import "server-only";
|
|
2
|
+
import { ChannelWebhookVerificationError, isChannelWebhookEventType, parseChannelWebhookEvent, } from "./webhooks.js";
|
|
3
|
+
/**
|
|
4
|
+
* Webhook route factory: the whole app/api/webhooks/c1m/route.ts in one call.
|
|
5
|
+
*
|
|
6
|
+
* import { revalidatePath, revalidateTag } from "next/cache";
|
|
7
|
+
* export const POST = createChannelWebhookRoute({
|
|
8
|
+
* secret: () => process.env.C1M_CHANNEL_WEBHOOK_SECRET!,
|
|
9
|
+
* invalidate: { revalidatePath, revalidateTag },
|
|
10
|
+
* });
|
|
11
|
+
*
|
|
12
|
+
* The invalidator is injected rather than imported here on purpose: it keeps
|
|
13
|
+
* this module free of `next` (bundler-safe, unit-testable with a fake), and it
|
|
14
|
+
* is the app's two-line import — not eighty lines of verification, dispatch,
|
|
15
|
+
* path-safety and error-mapping boilerplate.
|
|
16
|
+
*/
|
|
17
|
+
/** The cache tag every anonymous site read is filed under. */
|
|
18
|
+
export const CHANNEL_SITE_CACHE_TAG = "channel:site";
|
|
19
|
+
/**
|
|
20
|
+
* The cache tag catalog reads (product list, product detail) are filed under.
|
|
21
|
+
* `product.*` events bust this tag by default, so a merchant's price edit
|
|
22
|
+
* reaches the storefront on the next request instead of at the end of a TTL.
|
|
23
|
+
*/
|
|
24
|
+
export const CHANNEL_CATALOG_CACHE_TAG = "channel:catalog";
|
|
25
|
+
/**
|
|
26
|
+
* A route_pattern arrives from the network; it is input, not truth. Reject
|
|
27
|
+
* anything that is not a plain absolute path before handing it to the cache.
|
|
28
|
+
*/
|
|
29
|
+
export function safePublishedPath(path) {
|
|
30
|
+
const normalized = path.trim();
|
|
31
|
+
if (!normalized.startsWith("/") || normalized.startsWith("//") || normalized.length > 1024) {
|
|
32
|
+
return undefined;
|
|
33
|
+
}
|
|
34
|
+
return normalized;
|
|
35
|
+
}
|
|
36
|
+
/** Structural, not instanceof — see the session kit for why. */
|
|
37
|
+
function isVerificationError(error) {
|
|
38
|
+
if (error instanceof ChannelWebhookVerificationError)
|
|
39
|
+
return true;
|
|
40
|
+
return (typeof error === "object" && error !== null &&
|
|
41
|
+
error.name === "ChannelWebhookVerificationError" &&
|
|
42
|
+
typeof error.code === "string");
|
|
43
|
+
}
|
|
44
|
+
function defaultBehavior(event, invalidate) {
|
|
45
|
+
if (event.type === "page.published") {
|
|
46
|
+
const path = safePublishedPath(event.data.route_pattern);
|
|
47
|
+
if (!path)
|
|
48
|
+
throw new Error("page.published contains an invalid route_pattern");
|
|
49
|
+
invalidate.revalidateTag(CHANNEL_SITE_CACHE_TAG);
|
|
50
|
+
invalidate.revalidatePath(path);
|
|
51
|
+
return path;
|
|
52
|
+
}
|
|
53
|
+
// A catalog edit with no cache bust means the site serves the old price
|
|
54
|
+
// until its TTL expires — so product.* busts the catalog tag by default,
|
|
55
|
+
// with no configuration. Tag your product reads with
|
|
56
|
+
// CHANNEL_CATALOG_CACHE_TAG and a price change lands on the next request.
|
|
57
|
+
if (event.type === "product.created" || event.type === "product.updated" || event.type === "product.deleted") {
|
|
58
|
+
invalidate.revalidateTag(CHANNEL_CATALOG_CACHE_TAG);
|
|
59
|
+
return undefined;
|
|
60
|
+
}
|
|
61
|
+
return undefined;
|
|
62
|
+
}
|
|
63
|
+
/** Build the POST handler for the channel webhook endpoint. */
|
|
64
|
+
export function createChannelWebhookRoute(options) {
|
|
65
|
+
const logger = options.logger ?? console;
|
|
66
|
+
const resolveSecret = typeof options.secret === "function" ? options.secret : () => options.secret;
|
|
67
|
+
return async (request) => {
|
|
68
|
+
let event;
|
|
69
|
+
try {
|
|
70
|
+
event = await parseChannelWebhookEvent(request, { secret: resolveSecret() });
|
|
71
|
+
}
|
|
72
|
+
catch (error) {
|
|
73
|
+
if (isVerificationError(error)) {
|
|
74
|
+
// An unverifiable request is noise or an attack; log the code, say
|
|
75
|
+
// nothing useful back.
|
|
76
|
+
logger.warn("channel_webhook_rejected", { code: error.code });
|
|
77
|
+
return Response.json({ code: "invalid_channel_webhook" }, { status: 401 });
|
|
78
|
+
}
|
|
79
|
+
logger.error("channel_webhook_failed", { error });
|
|
80
|
+
return Response.json({ code: "channel_webhook_failed" }, { status: 500 });
|
|
81
|
+
}
|
|
82
|
+
try {
|
|
83
|
+
if (!isChannelWebhookEventType(event.type)) {
|
|
84
|
+
logger.info("channel_webhook_ignored", { eventId: event.id, eventType: event.type });
|
|
85
|
+
return new Response(null, { status: 204 });
|
|
86
|
+
}
|
|
87
|
+
const knownEvent = event;
|
|
88
|
+
const handler = options.onEvent?.[knownEvent.type];
|
|
89
|
+
let revalidatedPath;
|
|
90
|
+
if (handler) {
|
|
91
|
+
await handler(knownEvent, options.invalidate);
|
|
92
|
+
}
|
|
93
|
+
else {
|
|
94
|
+
revalidatedPath = defaultBehavior(knownEvent, options.invalidate);
|
|
95
|
+
}
|
|
96
|
+
logger.info("channel_webhook_processed", {
|
|
97
|
+
eventId: event.id,
|
|
98
|
+
eventType: knownEvent.type,
|
|
99
|
+
...(revalidatedPath ? { revalidatedPath } : {}),
|
|
100
|
+
});
|
|
101
|
+
return new Response(null, { status: 204 });
|
|
102
|
+
}
|
|
103
|
+
catch (error) {
|
|
104
|
+
// A handler failure is OURS: the signature verified, the event is real.
|
|
105
|
+
// A 500 makes the server retry on its ladder — which is what you want
|
|
106
|
+
// when the failure is transient, and visible in delivery history when
|
|
107
|
+
// it is not.
|
|
108
|
+
logger.error("channel_webhook_failed", { eventId: event.id, eventType: event.type, error });
|
|
109
|
+
return Response.json({ code: "channel_webhook_failed" }, { status: 500 });
|
|
110
|
+
}
|
|
111
|
+
};
|
|
112
|
+
}
|
package/dist/next.d.ts
CHANGED
|
@@ -46,12 +46,12 @@ export declare function createNextChannelClient(options: CreateNextChannelClient
|
|
|
46
46
|
readonly merge: (input: import("./types.js").MergeCartInput, mutation?: import("./index.js").ChannelMutationOptions) => Promise<import("./types.js").CartResponse>;
|
|
47
47
|
};
|
|
48
48
|
readonly checkout: {
|
|
49
|
-
readonly options: (cartToken: string) => Promise<import("./types.js").CheckoutOptions>;
|
|
50
|
-
readonly status: (params?: import("./index.js").ChannelCheckoutStatusParams) => Promise<import("./types.js").CheckoutStatusResponse>;
|
|
51
|
-
readonly setCustomer: (input: import("./types.js").CheckoutCustomerInput, mutation?: import("./index.js").ChannelMutationOptions) => Promise<import("./types.js").CartResponse>;
|
|
52
|
-
readonly setAddresses: (input: import("./types.js").CheckoutAddressesInput, mutation?: import("./index.js").ChannelMutationOptions) => Promise<import("./types.js").CartResponse>;
|
|
53
|
-
readonly setFulfillment: (input: import("./types.js").CheckoutFulfillmentInput, mutation?: import("./index.js").ChannelMutationOptions) => Promise<import("./types.js").CartResponse>;
|
|
54
|
-
readonly pay: (input: import("./types.js").CheckoutPayInput, mutation?: import("./index.js").ChannelMutationOptions) => Promise<import("./types.js").CheckoutPayResponse>;
|
|
49
|
+
readonly options: (orderId: string, cartToken: string) => Promise<import("./types.js").CheckoutOptions>;
|
|
50
|
+
readonly status: (orderId: string, params?: import("./index.js").ChannelCheckoutStatusParams) => Promise<import("./types.js").CheckoutStatusResponse>;
|
|
51
|
+
readonly setCustomer: (orderId: string, input: import("./types.js").CheckoutCustomerInput, mutation?: import("./index.js").ChannelMutationOptions) => Promise<import("./types.js").CartResponse>;
|
|
52
|
+
readonly setAddresses: (orderId: string, input: import("./types.js").CheckoutAddressesInput, mutation?: import("./index.js").ChannelMutationOptions) => Promise<import("./types.js").CartResponse>;
|
|
53
|
+
readonly setFulfillment: (orderId: string, input: import("./types.js").CheckoutFulfillmentInput, mutation?: import("./index.js").ChannelMutationOptions) => Promise<import("./types.js").CartResponse>;
|
|
54
|
+
readonly pay: (orderId: string, input: import("./types.js").CheckoutPayInput, mutation?: import("./index.js").ChannelMutationOptions) => Promise<import("./types.js").CheckoutPayResponse>;
|
|
55
55
|
};
|
|
56
56
|
readonly reviews: {
|
|
57
57
|
readonly list: (params?: import("./index.js").ChannelListParams) => Promise<import("./types.js").ListResponse<import("./types.js").Review>>;
|
|
@@ -67,8 +67,30 @@ export declare function createNextChannelClient(options: CreateNextChannelClient
|
|
|
67
67
|
readonly get: (handle: string) => Promise<import("./types.js").MenuResponse>;
|
|
68
68
|
};
|
|
69
69
|
readonly blog: {
|
|
70
|
+
readonly list: (params?: import("./index.js").ChannelListParams) => Promise<import("./types.js").ListResponse<import("./types.js").BlogPost>>;
|
|
70
71
|
readonly get: (slug: string) => Promise<import("./types.js").BlogPostResponse>;
|
|
71
72
|
};
|
|
73
|
+
readonly giving: {
|
|
74
|
+
readonly entries: {
|
|
75
|
+
readonly list: () => Promise<{
|
|
76
|
+
items: import("./types.js").GivingEntry[];
|
|
77
|
+
}>;
|
|
78
|
+
readonly get: (slug: string) => Promise<{
|
|
79
|
+
entry: import("./types.js").GivingEntry;
|
|
80
|
+
}>;
|
|
81
|
+
};
|
|
82
|
+
readonly start: (input: import("./types.js").StartGivingInput, mutation?: import("./index.js").ChannelMutationOptions) => Promise<import("./types.js").StartGivingResponse>;
|
|
83
|
+
};
|
|
84
|
+
readonly print: {
|
|
85
|
+
readonly settings: () => Promise<import("./types.js").PrintSettingsResponse>;
|
|
86
|
+
readonly quote: (input: import("./types.js").PrintOptionsSelection) => Promise<import("./types.js").PrintQuoteResponse>;
|
|
87
|
+
readonly intake: (input: import("./types.js").PrintIntakeInput, mutation?: import("./index.js").ChannelMutationOptions) => Promise<{
|
|
88
|
+
job: import("./types.js").PrintJob;
|
|
89
|
+
}>;
|
|
90
|
+
};
|
|
91
|
+
readonly dining: {
|
|
92
|
+
readonly menu: (boardSlug: string) => Promise<import("./types.js").DiningMenu>;
|
|
93
|
+
};
|
|
72
94
|
readonly auth: {
|
|
73
95
|
readonly check: (email: string) => Promise<{
|
|
74
96
|
exists: boolean;
|
|
@@ -103,6 +125,9 @@ export declare function createNextChannelClient(options: CreateNextChannelClient
|
|
|
103
125
|
order: import("./types.js").Order;
|
|
104
126
|
}>;
|
|
105
127
|
};
|
|
128
|
+
readonly giving: {
|
|
129
|
+
readonly start: (input: import("./types.js").StartGivingInput, mutation?: import("./index.js").ChannelMutationOptions) => Promise<import("./types.js").StartGivingResponse>;
|
|
130
|
+
};
|
|
106
131
|
};
|
|
107
132
|
readonly leads: {
|
|
108
133
|
readonly create: (input: import("./index.js").ChannelLeadInput, mutation?: import("./index.js").ChannelMutationOptions) => Promise<{
|
|
@@ -110,3 +135,6 @@ export declare function createNextChannelClient(options: CreateNextChannelClient
|
|
|
110
135
|
}>;
|
|
111
136
|
};
|
|
112
137
|
};
|
|
138
|
+
export * from "./next-session.js";
|
|
139
|
+
export * from "./next-webhooks.js";
|
|
140
|
+
export * from "./next-cart.js";
|
package/dist/next.js
CHANGED
|
@@ -38,3 +38,10 @@ export function createNextChannelClient(options) {
|
|
|
38
38
|
};
|
|
39
39
|
return createChannelClient({ ...coreOptions, fetch: nextFetch });
|
|
40
40
|
}
|
|
41
|
+
// The kits: the ~600 lines of plumbing every headless site was copy-pasting —
|
|
42
|
+
// session cookie + refresh decision, the webhook route, the cart's token
|
|
43
|
+
// threading — shipped once, injection-shaped, framework-honest (no `next`
|
|
44
|
+
// imports; apps pass next/cache + apply cookies where Next allows writes).
|
|
45
|
+
export * from "./next-session.js";
|
|
46
|
+
export * from "./next-webhooks.js";
|
|
47
|
+
export * from "./next-cart.js";
|