@c1m-public/channel-client 0.16.0 → 0.17.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 CHANGED
@@ -69,6 +69,10 @@ const directory = await channel.dash.directory.list({ region: "london" });
69
69
  // channel client. Every account read is forced to no-store.
70
70
  const account = channel.withCustomer(customerAccessToken);
71
71
  const addresses = await account.addresses.list();
72
+ const agreement = await account.subscriptions.start(
73
+ { plan_id: selectedPlan.id },
74
+ { idempotencyKey: acquisitionAttemptId },
75
+ );
72
76
  const subscriptions = await account.subscriptions.list({ status: "active" });
73
77
  const sessions = await account.sessions.list();
74
78
  const activity = await account.securityActivity();
@@ -251,7 +255,7 @@ separate, parallel reads. `dash.init()` is the same shape for dash sites
251
255
 
252
256
  The core also exposes the complete current channel door: public category,
253
257
  collection and brand navigation; published blog and giving reads; subscription
254
- plan reads for a membership picker; cart and checkout; Quick Print settings,
258
+ plan reads and authenticated acquisition; cart and checkout; Quick Print settings,
255
259
  quotes and multipart intake; assembled dining menus; and signed-in customer
256
260
  orders, addresses, giving history, saved payment methods and subscriptions. `pnpm contract:check` compares both client
257
261
  inventories with the canonical server OpenAPI document when the repositories
package/dist/index.d.ts CHANGED
@@ -2,7 +2,7 @@ import "server-only";
2
2
  export * from "./webhooks.js";
3
3
  export * from "./errors.js";
4
4
  export type * from "./types.js";
5
- import type { CatalogBrand, CatalogCategory, CatalogCollection, CatalogProductsResponse, BlogPostResponse, DiningMenu, DashDirectoryEntry, DashDirectoryProfileResponse, DashDirectoryRegion, DashInitResponse, DashLead, DashPlansResponse, DashProfileResponse, GivingEntry, SubscriptionPlanListResponse, SubscriptionPlanResponse, GivingIntentListResponse, AddCartItemInput, CartResponse, CheckoutAddressesInput, CheckoutCustomerInput, CheckoutFulfillmentInput, CheckoutOptions, CheckoutPayInput, CheckoutPayResponse, CheckoutStatusResponse, ChannelPing, CustomerResponse, CustomerAuthSession, CustomerSecurityActivityPage, ChannelGeo, CustomerSession, CustomerSignupResponse, LeadResponse, LightInitResponse, ListResponse, Order, OrderSummary, MergeCartInput, SendCodeResponse, Product, ProductAsset, PrintIntakeInput, PrintJob, PrintOptionsSelection, PrintQuoteResponse, PrintSettingsResponse, PublicPage, PublicPageSummary, PublicSubmitReviewInput, PublicWorkspaceInit, MenuResponse, Review, ReviewSummaryResponse, SavedAddress, SavedAddressDefaultKind, SavedAddressInput, SavedAddressResponse, SavedAddressUpdateInput, SavedPaymentMethod, SiteDocument, StartGivingInput, StartGivingResponse, PaymentMethodConfirmInput, PaymentMethodMutationResponse, PaymentMethodSetupInput, PaymentMethodSetupResult, SubscriptionAgreementResponse, SubscriptionInvoiceListResponse, SubscriptionInvoiceResponse, SubscriptionListResponse, SubscriptionSourceResponse, ThemeResponse, UpdateCartItemInput } from "./types.js";
5
+ import type { CatalogBrand, CatalogCategory, CatalogCollection, CatalogProductsResponse, BlogPostResponse, DiningMenu, DashDirectoryEntry, DashDirectoryProfileResponse, DashDirectoryRegion, DashInitResponse, DashLead, DashPlansResponse, DashProfileResponse, GivingEntry, SubscriptionPlanListResponse, SubscriptionPlanResponse, StartSubscriptionInput, GivingIntentListResponse, AddCartItemInput, CartResponse, CheckoutAddressesInput, CheckoutCustomerInput, CheckoutFulfillmentInput, CheckoutOptions, CheckoutPayInput, CheckoutPayResponse, CheckoutStatusResponse, ChannelPing, CustomerResponse, CustomerAuthSession, CustomerSecurityActivityPage, ChannelGeo, CustomerSession, CustomerSignupResponse, LeadResponse, LightInitResponse, ListResponse, Order, OrderSummary, MergeCartInput, SendCodeResponse, Product, ProductAsset, PrintIntakeInput, PrintJob, PrintOptionsSelection, PrintQuoteResponse, PrintSettingsResponse, PublicPage, PublicPageSummary, PublicSubmitReviewInput, PublicWorkspaceInit, MenuResponse, Review, ReviewSummaryResponse, SavedAddress, SavedAddressDefaultKind, SavedAddressInput, SavedAddressResponse, SavedAddressUpdateInput, SavedPaymentMethod, SiteDocument, StartGivingInput, StartGivingResponse, PaymentMethodConfirmInput, PaymentMethodMutationResponse, PaymentMethodSetupInput, PaymentMethodSetupResult, SubscriptionAgreementResponse, SubscriptionInvoiceListResponse, SubscriptionInvoiceResponse, SubscriptionListResponse, SubscriptionSourceResponse, ThemeResponse, UpdateCartItemInput } from "./types.js";
6
6
  export declare const DEFAULT_CHANNEL_API_URL = "https://api.saasdash.app";
7
7
  export interface ChannelRetryPolicy {
8
8
  attempts?: number;
@@ -39,7 +39,7 @@ export interface ChannelVisitor {
39
39
  userAgent?: string;
40
40
  }
41
41
  export type ChannelRequestOutcome = "success" | "api_error" | "network_error" | "timeout" | "invalid_response" | "cancelled";
42
- export type ChannelOperation = "channel.ping" | "channel.geo.detect" | "channel.site.resolve" | "channel.init.get" | "channel.init.light" | "content.pages.public.list.channel" | "content.pages.public.get.channel" | "shop.public.products.list.channel" | "shop.public.products.get.channel" | "shop.public.products.media.channel" | "reviews.public.list.channel" | "reviews.public.summary.channel" | "reviews.public.submit.channel" | "channel.theme.get" | "channel.menus.get" | "channel.blog.get" | "channel.blog.list" | "channel.giving.entries.list" | "channel.giving.entries.get" | "channel.giving.start" | "channel.subscriptions.plans.list" | "channel.subscriptions.plans.get" | "channel.print.settings" | "channel.print.quote" | "channel.print.intake" | "dining.public.board_menu.channel" | "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.orders.list" | "channel.account.orders.summary" | "channel.account.orders.get" | "channel.account.payment_methods.list" | "channel.account.payment_methods.setup" | "channel.account.payment_methods.confirm" | "channel.account.payment_methods.default" | "channel.account.payment_methods.delete" | "channel.account.subscriptions.list" | "channel.account.subscriptions.get" | "channel.account.subscriptions.source" | "channel.account.subscriptions.cancel" | "channel.account.subscriptions.pause" | "channel.account.subscriptions.resume" | "channel.account.subscriptions.invoices.list" | "channel.account.subscriptions.invoices.get" | "channel.account.subscriptions.invoices.pay_now" | "channel.catalog.brands.list" | "channel.catalog.categories.list" | "channel.catalog.categories.products" | "channel.catalog.collections.list" | "channel.catalog.collections.products" | "channel.cart.get" | "channel.cart.items.add" | "channel.cart.items.update" | "channel.cart.items.remove" | "channel.cart.clear" | "channel.cart.merge" | "channel.checkout.options" | "channel.checkout.status" | "channel.checkout.customer.set" | "channel.checkout.addresses.set" | "channel.checkout.fulfillment.set" | "channel.checkout.pay" | "channel.dash.profile" | "channel.dash.init" | "channel.dash.plans" | "channel.dash.directory.regions" | "channel.dash.directory.browse" | "channel.dash.directory.get" | "channel.dash.leads.capture" | "growth.public_workspace.leads.capture.channel";
42
+ export type ChannelOperation = "channel.ping" | "channel.geo.detect" | "channel.site.resolve" | "channel.init.get" | "channel.init.light" | "content.pages.public.list.channel" | "content.pages.public.get.channel" | "shop.public.products.list.channel" | "shop.public.products.get.channel" | "shop.public.products.media.channel" | "reviews.public.list.channel" | "reviews.public.summary.channel" | "reviews.public.submit.channel" | "channel.theme.get" | "channel.menus.get" | "channel.blog.get" | "channel.blog.list" | "channel.giving.entries.list" | "channel.giving.entries.get" | "channel.giving.start" | "channel.subscriptions.plans.list" | "channel.subscriptions.plans.get" | "channel.subscriptions.start" | "channel.print.settings" | "channel.print.quote" | "channel.print.intake" | "dining.public.board_menu.channel" | "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.orders.list" | "channel.account.orders.summary" | "channel.account.orders.get" | "channel.account.payment_methods.list" | "channel.account.payment_methods.setup" | "channel.account.payment_methods.confirm" | "channel.account.payment_methods.default" | "channel.account.payment_methods.delete" | "channel.account.subscriptions.list" | "channel.account.subscriptions.get" | "channel.account.subscriptions.source" | "channel.account.subscriptions.cancel" | "channel.account.subscriptions.pause" | "channel.account.subscriptions.resume" | "channel.account.subscriptions.invoices.list" | "channel.account.subscriptions.invoices.get" | "channel.account.subscriptions.invoices.pay_now" | "channel.catalog.brands.list" | "channel.catalog.categories.list" | "channel.catalog.categories.products" | "channel.catalog.collections.list" | "channel.catalog.collections.products" | "channel.cart.get" | "channel.cart.items.add" | "channel.cart.items.update" | "channel.cart.items.remove" | "channel.cart.clear" | "channel.cart.merge" | "channel.checkout.options" | "channel.checkout.status" | "channel.checkout.customer.set" | "channel.checkout.addresses.set" | "channel.checkout.fulfillment.set" | "channel.checkout.pay" | "channel.dash.profile" | "channel.dash.init" | "channel.dash.plans" | "channel.dash.directory.regions" | "channel.dash.directory.browse" | "channel.dash.directory.get" | "channel.dash.leads.capture" | "growth.public_workspace.leads.capture.channel";
43
43
  export interface ChannelRequestObservation {
44
44
  operation: ChannelOperation;
45
45
  method: string;
@@ -308,6 +308,7 @@ export declare function createChannelClient(options: CreateChannelClientOptions)
308
308
  readonly delete: (methodId: string, mutation?: ChannelMutationOptions) => Promise<PaymentMethodMutationResponse>;
309
309
  };
310
310
  readonly subscriptions: {
311
+ readonly start: (input: StartSubscriptionInput, mutation?: ChannelMutationOptions) => Promise<SubscriptionAgreementResponse>;
311
312
  readonly list: (params?: ChannelSubscriptionListParams) => Promise<SubscriptionListResponse>;
312
313
  readonly get: (agreementId: string) => Promise<SubscriptionAgreementResponse>;
313
314
  readonly source: (agreementId: string) => Promise<SubscriptionSourceResponse>;
package/dist/index.js CHANGED
@@ -458,6 +458,9 @@ export function createChannelClient(options) {
458
458
  }, customerSession),
459
459
  },
460
460
  subscriptions: {
461
+ start: (input, mutation) => request("channel.subscriptions.start", "/subscriptions/start", {
462
+ method: "POST", headers: mutationHeaders(mutation), body: JSON.stringify(input),
463
+ }, customerSession),
461
464
  list: (params = {}) => request("channel.account.subscriptions.list", appendQuery("/account/subscriptions", params), {}, customerSession),
462
465
  get: (agreementId) => request("channel.account.subscriptions.get", `/account/subscriptions/${encodePath(agreementId)}`, {}, customerSession),
463
466
  source: (agreementId) => request("channel.account.subscriptions.source", `/account/subscriptions/${encodePath(agreementId)}/source`, {}, customerSession),
@@ -1,4 +1,4 @@
1
- import type { MovingAddress } from "./quote-model";
1
+ import type { MovingAddress } from "./quote-model.js";
2
2
  interface ManualMovingAddressFields {
3
3
  line1: string;
4
4
  line2: string;
@@ -1,3 +1,3 @@
1
- export type { AddressLookupNormalizedAddress, AddressLookupRegionSuggestion, AddressSelection, LookupAddress, } from "./address-types";
2
- export * from "./address-model";
3
- export * from "./quote-model";
1
+ export type { AddressLookupNormalizedAddress, AddressLookupRegionSuggestion, AddressSelection, LookupAddress, } from "./address-types.js";
2
+ export * from "./address-model.js";
3
+ export * from "./quote-model.js";
@@ -1,2 +1,2 @@
1
- export * from "./address-model";
2
- export * from "./quote-model";
1
+ export * from "./address-model.js";
2
+ export * from "./quote-model.js";
@@ -1,4 +1,4 @@
1
- import type { AddressSelection } from "./address-types";
1
+ import type { AddressSelection } from "./address-types.js";
2
2
  import { z } from "zod";
3
3
  export type ContactPreference = "email" | "phone" | "any";
4
4
  export type TimePreference = "morning" | "afternoon" | "evening" | "any";
package/dist/next.d.ts CHANGED
@@ -211,6 +211,7 @@ export declare function createNextChannelClient(options: CreateNextChannelClient
211
211
  readonly delete: (methodId: string, mutation?: import("./index.js").ChannelMutationOptions) => Promise<import("./types.js").PaymentMethodMutationResponse>;
212
212
  };
213
213
  readonly subscriptions: {
214
+ readonly start: (input: import("./types.js").StartSubscriptionInput, mutation?: import("./index.js").ChannelMutationOptions) => Promise<import("./types.js").SubscriptionAgreementResponse>;
214
215
  readonly list: (params?: import("./index.js").ChannelSubscriptionListParams) => Promise<import("./types.js").SubscriptionListResponse>;
215
216
  readonly get: (agreementId: string) => Promise<import("./types.js").SubscriptionAgreementResponse>;
216
217
  readonly source: (agreementId: string) => Promise<import("./types.js").SubscriptionSourceResponse>;
package/dist/types.d.ts CHANGED
@@ -1195,3 +1195,7 @@ export interface SubscriptionPlanListResponse {
1195
1195
  export interface SubscriptionPlanResponse {
1196
1196
  plan: SubscriptionPlanOffer;
1197
1197
  }
1198
+ /** Customer-controlled subscription acquisition. Price and terms come from the plan. */
1199
+ export interface StartSubscriptionInput {
1200
+ plan_id: string;
1201
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@c1m-public/channel-client",
3
- "version": "0.16.0",
3
+ "version": "0.17.0",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "description": "Typed server-side client for the MML headless Channel API",