@cmssy/core 9.10.0 → 10.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -1,198 +1,9 @@
1
+ export { A as AppToEditorMessage, B as BoundsMessage, C as ClickMessage, a as CmssyClient, b as CmssyConfig, c as CmssyCspOptions, d as CmssyEnvConfig, D as DEFAULT_CMSSY_EDITOR_ORIGINS, E as EditorToAppMessage, P as PROTOCOL_VERSION, e as ParentReadyMessage, f as PatchMessage, g as PostTarget, Q as QueryScopedOptions, R as ReadyMessage, S as SelectMessage, h as applyCmssyCsp, i as createCmssyClient, j as defineCmssyConfig, k as isProtocolCompatible, n as normalizeOrigin, p as parseEditorMessage, l as postToEditor, r as resolveEditorOrigin } from './csp-DpssAFJC.js';
2
+ export { G as GraphqlRequestOptions, g as graphqlRequest } from './graphql-request-CDh6IRok.js';
3
+ export { C as CmssyRequestError, D as DEFAULT_CMSSY_API_URL, F as FetchLike, a as FetchLikeResponse, b as FetchPageOptions, R as RetryPolicy } from './content-client-D0EdiqbQ.js';
1
4
  import * as _cmssy_types from '@cmssy/types';
2
- import { CmssyAuthConfig, CmssyClientConfig, CmssySiteConfig, RawBlock, CmssyFormDefinition, CmssySiteLocales, BuildBlockContextExtra, CmssyBlockContext, CmssyLocaleContext, FieldDefinition, FieldOptions, TypedField, BlockPropsSchema, InferBlockContent, RelationMode, CmssyModelRecord, BlockRect, BlockSchema, BlockMeta, CmssySessionPayload, SessionCookieOptions, CmssySessionUser, CmssyAddress, CmssyCart, CmssyOrder, CmssyProduct, MyOrdersResult, FetchProductOptions, FetchProductsOptions, CmssyProductPage, FetchOrderByTokenOptions, VerifyCmssyWebhookOptions, CmssyWebhookEvent } from '@cmssy/types';
3
- export { BlockMeta, BlockPropsSchema, BlockRect, BlockSchema, BuildBlockContextExtra, CmssyAddress, CmssyAuthConfig, CmssyBlockAuthContext, CmssyBlockContext, CmssyBlockMember, CmssyBlockWorkspace, CmssyBranding, CmssyCart, CmssyCartDiscount, CmssyCartItem, CmssyCartItemSnapshot, CmssyClientConfig, CmssyFormDefinition, CmssyFormField, CmssyFormSettings, CmssyFormSubmitResponse, CmssyLayoutGroup, CmssyLayoutSettings, CmssyLocaleContext, CmssyLocalizedValue, CmssyModelDefinition, CmssyModelRecord, CmssyOrder, CmssyOrderDiscount, CmssyOrderItem, CmssyOrderTaxSummaryLine, CmssyPageData, CmssyPageMeta, CmssyPageSummary, CmssyPriceTier, CmssyProduct, CmssyProductPage, CmssyProductVariant, CmssyRecordList, CmssySessionPayload, CmssySessionUser, CmssyShippingMethod, CmssySiteConfig, CmssySiteLocales, CmssyStockState, CmssyTaxSummaryLine, CmssyWebhookEvent, CmssyWebhookOrder, FetchOrderByTokenOptions, FetchProductOptions, FetchProductsOptions, FieldCondition, FieldConditionGroup, FieldConditionLogic, FieldControl, FieldDefinition, FieldOptions, FieldType, InferBlockContent, MyOrdersResult, RawBlock, RawLayoutBlock, SessionCookieOptions, SubmitFormInput, TypedField, VerifyCmssyWebhookOptions, evaluateFieldConditionGroup } from '@cmssy/types';
4
- import { F as FetchLike, R as RetryPolicy } from './content-client-D0EdiqbQ.js';
5
- export { C as CmssyRequestError, D as DEFAULT_CMSSY_API_URL, a as FetchLikeResponse, b as FetchPageOptions, f as fetchLayouts, c as fetchPage, d as fetchPageById, e as fetchPageMeta, g as fetchPages, n as normalizeSlug, r as resolveApiUrl, h as resolvePublicUrl } from './content-client-D0EdiqbQ.js';
6
-
7
- declare const DEFAULT_CMSSY_EDITOR_ORIGINS: string[];
8
- declare function isDevelopment(): boolean;
9
- declare function resolveEditorOrigin(editorOrigin: string | string[] | undefined): string | string[];
10
- interface CmssyConfig {
11
- /**
12
- * Full GraphQL delivery endpoint. Defaults to the cmssy cloud endpoint
13
- * (`https://api.cmssy.io/graphql`); set it only for self-hosted / staging.
14
- */
15
- apiUrl?: string;
16
- /** Organization slug - part of the org-scoped delivery path. */
17
- org: string;
18
- workspaceSlug: string;
19
- draftSecret: string;
20
- /**
21
- * A cmssy API token (`cs_…`) that opts this app into the editor-controlled dev
22
- * preview. In development only, the SDK sends it on every page fetch so the
23
- * backend can resolve the token's user and honour that user's dev-preview flag
24
- * (toggled from the editor's dev-mode switch): flag on + a saved dev draft ⇒
25
- * the draft overlay renders, otherwise published content. Server-only (never
26
- * reaches the client); ignored outside development. See the Quickstart
27
- * "Dev preview" section.
28
- */
29
- devToken?: string;
30
- /**
31
- * Origin allowed to frame your app in the editor. Defaults to
32
- * {@link DEFAULT_CMSSY_EDITOR_ORIGINS}; set it only for self-hosted admins.
33
- */
34
- editorOrigin?: string | string[];
35
- /**
36
- * Canonical absolute site URL (e.g. https://cmssy.com), used by
37
- * createCmssyRobots / createCmssySitemap. When omitted the helpers derive the
38
- * origin from the request `host` header at render time (multi-domain safe).
39
- */
40
- siteUrl?: string;
41
- auth?: CmssyAuthConfig;
42
- /**
43
- * Fallback locale resolver for a site whose URLs carry no language (e.g. a
44
- * cookie or Accept-Language strategy). The workspace site config remains the
45
- * source of truth for the default and enabled languages.
46
- */
47
- resolveLocale?: () => string | Promise<string>;
48
- }
49
- /**
50
- * Env-shaped input for {@link defineCmssyConfig}: the required string fields are
51
- * widened to `string | undefined` so a config can pass `process.env.*` straight
52
- * through without a `?? ""` fallback (which would mask a missing value as an
53
- * empty string) or a cast.
54
- */
55
- type CmssyEnvConfig = Omit<CmssyConfig, "org" | "workspaceSlug" | "draftSecret"> & {
56
- org?: string;
57
- workspaceSlug?: string;
58
- draftSecret?: string;
59
- };
60
- /**
61
- * Validates an env-sourced config and returns a strictly-typed
62
- * {@link CmssyConfig}. Pass raw `process.env.*` values; this throws a clear,
63
- * actionable error listing any missing required variables (rendered by the
64
- * Next.js error overlay / boundary), so the app fails fast instead of running
65
- * with silently-empty config.
66
- */
67
- declare function defineCmssyConfig(config: CmssyEnvConfig): CmssyConfig;
68
- declare function assertAuthConfig(config: CmssyConfig): CmssyAuthConfig;
69
-
70
- declare function getBlockContentForLanguage(content: unknown, locale: string, defaultLocale?: string, availableLocales?: string[]): Record<string, unknown>;
71
- /**
72
- * Coerce a block bucket (`style` / `advanced`) to a plain object. These buckets
73
- * are flat (not locale-keyed) and free-form; a missing/invalid bucket becomes
74
- * an empty object so components can destructure it safely.
75
- */
76
- declare function asBucket(value: unknown): Record<string, unknown>;
77
-
78
- interface GraphqlRequestOptions {
79
- fetch?: FetchLike;
80
- signal?: AbortSignal;
81
- headers?: Record<string, string>;
82
- /**
83
- * Route through the org-scoped public delivery path instead of the base
84
- * `/graphql` endpoint. Set for unauthenticated public queries so the backend
85
- * resolves the workspace from the URL rather than a global slug lookup.
86
- */
87
- public?: boolean;
88
- /**
89
- * Retry transient HTTP failures (429/503, honoring Retry-After). Off by
90
- * default: this function also carries mutations (auth, cart, checkout),
91
- * which must never be blind-retried. Read-only callers opt in with `{}`.
92
- */
93
- retry?: RetryPolicy | false;
94
- }
95
- declare function graphqlRequest<T>(config: CmssyClientConfig, query: string, variables: Record<string, unknown>, options?: GraphqlRequestOptions, label?: string): Promise<T>;
96
-
97
- interface QueryScopedOptions extends GraphqlRequestOptions {
98
- workspaceId?: string;
99
- }
100
- interface CmssyClient {
101
- readonly config: CmssyClientConfig;
102
- query<T = unknown>(document: string, variables?: Record<string, unknown>, options?: GraphqlRequestOptions): Promise<T>;
103
- queryScoped<T = unknown>(document: string, variables?: Record<string, unknown>, options?: QueryScopedOptions): Promise<T>;
104
- resolveWorkspaceId(options?: GraphqlRequestOptions): Promise<string>;
105
- }
106
- declare function createCmssyClient(input: CmssyClientConfig): CmssyClient;
107
-
108
- declare const SITE_CONFIG_QUERY = "query PublicSiteConfig($workspaceSlug: String!) {\n public {\n siteConfig(workspaceSlug: $workspaceSlug) {\n id\n workspaceId\n siteName\n defaultLanguage\n enabledLanguages\n enabledFeatures\n notFoundPageId\n previewUrl\n branding {\n brandName\n logoUrl\n faviconUrl\n ogImageUrl\n }\n }\n }\n}";
109
- declare const MODEL_DEFINITIONS_QUERY = "query PublicModelDefinitions($workspaceId: String!) {\n public {\n model {\n definitions(workspaceId: $workspaceId) {\n id name slug description icon color displayField recordCount\n }\n }\n }\n}";
110
- declare const MODEL_RECORDS_QUERY = "query PublicModelRecords($workspaceId: String!, $modelSlug: String!, $filter: JSON, $sort: String, $locale: String, $limit: Int, $offset: Int, $populate: [String!]) {\n public {\n model {\n records(workspaceId: $workspaceId, modelSlug: $modelSlug, filter: $filter, sort: $sort, locale: $locale, limit: $limit, offset: $offset, populate: $populate) {\n items { id modelId data status createdAt updatedAt }\n total\n hasMore\n }\n }\n }\n}";
111
- declare const FORM_QUERY = "query PublicForm($formId: ID!) {\n public {\n form {\n get(formId: $formId) {\n id\n name\n slug\n description\n fields {\n id name fieldType label placeholder helpText\n defaultValue width order showWhen requiredWhen\n options { value label disabled }\n validation { required minLength maxLength minValue maxValue pattern customMessage }\n }\n settings {\n actionType submitButtonLabel successMessage errorMessage\n redirectUrl requireLogin enableCaptcha\n }\n }\n }\n }\n}";
112
- declare const SUBMIT_FORM_MUTATION = "mutation SubmitForm($formId: ID!, $input: SubmitFormInput!) {\n public {\n form {\n submit(formId: $formId, input: $input) {\n success message submissionId redirectUrl accessToken customer\n }\n }\n }\n}";
113
-
114
- declare function fetchSiteConfig(config: CmssyClientConfig, options?: GraphqlRequestOptions): Promise<CmssySiteConfig | null>;
115
- declare function resolveWorkspaceId(config: CmssyClientConfig, options?: GraphqlRequestOptions): Promise<string>;
116
- /**
117
- * Every authenticated operation needs the workspace id, and it never changes for
118
- * a given (endpoint, workspace) pair - so it is resolved once and shared. A
119
- * failed lookup is evicted, otherwise one bad request would be cached forever.
120
- */
121
- declare function cachedWorkspaceId(config: CmssyClientConfig): Promise<string>;
122
- declare function clearWorkspaceIdCache(): void;
123
-
124
- declare function collectFormIds(blocks: RawBlock[], locale: string, defaultLocale: string): string[];
125
- declare function resolveForms(config: CmssyClientConfig, blocks: RawBlock[], locale: string, defaultLocale: string, options?: QueryScopedOptions): Promise<Record<string, CmssyFormDefinition>>;
126
-
127
- /**
128
- * Maps a workspace site config to its locale set. The single place that
129
- * decides the default and enabled languages - the router and the SEO helpers
130
- * must agree, so both go through here.
131
- */
132
- declare function localesFromSiteConfig(siteConfig: {
133
- defaultLanguage?: string | null;
134
- enabledLanguages?: string[];
135
- } | null): CmssySiteLocales;
136
- declare function resolveSiteLocales(config: CmssyClientConfig, options?: GraphqlRequestOptions): Promise<CmssySiteLocales>;
137
- declare function splitLocaleFromPath(path: string[] | undefined, siteLocales: CmssySiteLocales): {
138
- locale: string;
139
- path: string[] | undefined;
140
- };
141
-
142
- declare function buildBlockContext(locale: string, defaultLocale: string, enabledLocales?: string[], isPreview?: boolean, forms?: Record<string, CmssyFormDefinition>, extra?: BuildBlockContextExtra): CmssyBlockContext;
143
-
144
- /**
145
- * Rewrites an internal href to carry the active locale as a path prefix.
146
- * External hrefs, fragments and relative paths are returned untouched. Already
147
- * prefixed hrefs are normalized so the prefix never doubles.
148
- */
149
- declare function localizeHref(href: string, locale: CmssyLocaleContext): string;
150
- /**
151
- * Builds the href that switches the current `pathname` to `target` locale,
152
- * preserving the rest of the path. Used by a language switcher.
153
- */
154
- declare function buildLocaleSwitchHref(target: string, pathname: string, locale: CmssyLocaleContext): string;
155
- /**
156
- * Rewrites every `<a href>` inside an HTML string with {@link localizeHref}.
157
- * For rich-text content stored in CMS blocks where links are raw markup.
158
- */
159
- declare function localizeHtmlLinks(html: string, locale: CmssyLocaleContext): string;
160
-
161
- declare const RECORDS_BY_IDS_QUERY = "query PublicRecordsByIds($workspaceId: String!, $ids: [String!]!, $locale: String) {\n public {\n model {\n recordsByIds(workspaceId: $workspaceId, ids: $ids, locale: $locale) {\n id modelId data status createdAt updatedAt\n }\n }\n }\n}";
162
- interface RelationContentEntry {
163
- type: string;
164
- content: Record<string, unknown>;
165
- }
166
- type BlockSchemaMap = Record<string, Record<string, FieldDefinition>>;
167
- /**
168
- * The editor canvas renders stored content without the server-side resolve, so
169
- * a relation field there holds raw ids - or the "" a freshly inserted block is
170
- * seeded with. A component is typed against resolved records, so anything that
171
- * is not one falls back to the server-resolved value for that key (the admin
172
- * hydrates the canvas with raw stored content, clobbering it), and only then
173
- * to the safe empty shape.
174
- */
175
- declare function normalizeRelationContent(content: Record<string, unknown>, schema: Record<string, FieldDefinition>, resolved?: Record<string, unknown>): void;
176
- /**
177
- * Resolves every `fields.relation` value on the given block contents in place:
178
- * stored record ids become full records (one batched read for the whole page),
179
- * and a `mode: "all"` field becomes the model's record list. A dangling id and
180
- * a failed fetch both degrade to "no value" - a relation must never break a
181
- * render.
182
- */
183
- declare function resolveRelationContent(config: CmssyClientConfig, entries: RelationContentEntry[], schemas: BlockSchemaMap, locale?: string, requestOptions?: QueryScopedOptions): Promise<void>;
184
-
185
- declare const CMSSY_LOCALE_HEADER = "x-cmssy-locale";
186
- declare function localeForPathname(config: CmssyClientConfig, pathname: string): Promise<string>;
187
- declare function splitCmssyLocale(config: CmssyClientConfig, path: string[] | undefined): Promise<{
188
- locale: string;
189
- path: string[] | undefined;
190
- }>;
191
- /**
192
- * Resolve the locale a path asks for. The prefix IS the language, so a routed
193
- * path is all it takes - no request, no headers, static-safe.
194
- */
195
- declare function localeForPath(config: CmssyClientConfig, path: string | string[]): Promise<string>;
5
+ import { FieldOptions, TypedField, BlockPropsSchema, InferBlockContent, RelationMode, CmssyModelRecord, CmssyFormDefinition, BuildBlockContextExtra, CmssyBlockContext, VerifyCmssyWebhookOptions, CmssyWebhookEvent } from '@cmssy/types';
6
+ export { BlockMeta, BlockPropsSchema, BlockRect, BlockSchema, BuildBlockContextExtra, CmssyBlockAuthContext, CmssyBlockContext, CmssyBlockMember, CmssyBlockWorkspace, CmssyBranding, CmssyClientConfig, CmssyFormDefinition, CmssyFormField, CmssyFormSettings, CmssyFormSubmitResponse, CmssyLayoutGroup, CmssyLayoutSettings, CmssyLocaleContext, CmssyLocalizedValue, CmssyModelDefinition, CmssyModelRecord, CmssyPageData, CmssyPageMeta, CmssyPageSummary, CmssyRecordList, CmssySiteConfig, CmssyWebhookEvent, CmssyWebhookOrder, FieldCondition, FieldConditionGroup, FieldConditionLogic, FieldControl, FieldDefinition, FieldOptions, FieldType, InferBlockContent, RawBlock, RawLayoutBlock, SubmitFormInput, TypedField, VerifyCmssyWebhookOptions, evaluateFieldConditionGroup } from '@cmssy/types';
196
7
 
197
8
  type Declared<O> = O extends {
198
9
  required: true;
@@ -255,103 +66,7 @@ declare const fields: {
255
66
  relation: <const O extends RelationFieldOptions>(opts: O) => TypedField<RelationValue<O>, Declared<O>>;
256
67
  };
257
68
 
258
- declare const PROTOCOL_VERSION = 2;
259
-
260
- interface ReadyMessage {
261
- type: "cmssy:ready";
262
- protocolVersion: number;
263
- blocks: Array<{
264
- id: string;
265
- type: string;
266
- bounds: BlockRect;
267
- layoutPosition?: string;
268
- }>;
269
- schemas: Record<string, BlockSchema>;
270
- blockMeta?: Record<string, BlockMeta>;
271
- }
272
- interface BoundsMessage {
273
- type: "cmssy:bounds";
274
- blockId: string;
275
- rect: BlockRect;
276
- }
277
- interface ClickMessage {
278
- type: "cmssy:click";
279
- blockId: string;
280
- rect: BlockRect;
281
- layoutPosition?: string;
282
- }
283
- interface DeselectMessage {
284
- type: "cmssy:deselect";
285
- }
286
- interface MoveMessage {
287
- type: "cmssy:move";
288
- protocolVersion: number;
289
- blockId: string;
290
- index: number;
291
- }
292
- interface DragIndexMessage {
293
- type: "cmssy:drag-index";
294
- protocolVersion: number;
295
- index: number;
296
- }
297
- type AppToEditorMessage = ReadyMessage | BoundsMessage | ClickMessage | DeselectMessage | MoveMessage | DragIndexMessage;
298
- interface SelectMessage {
299
- type: "cmssy:select";
300
- protocolVersion: number;
301
- blockId: string;
302
- }
303
- interface PatchMessage {
304
- type: "cmssy:patch";
305
- protocolVersion: number;
306
- blockId: string;
307
- content: Record<string, unknown>;
308
- style?: Record<string, unknown>;
309
- advanced?: Record<string, unknown>;
310
- layoutPosition?: string;
311
- }
312
- interface ParentReadyMessage {
313
- type: "cmssy:parent-ready";
314
- protocolVersion: number;
315
- }
316
- interface InsertMessage {
317
- type: "cmssy:insert";
318
- protocolVersion: number;
319
- blockId: string;
320
- blockType: string;
321
- content: Record<string, unknown>;
322
- style?: Record<string, unknown>;
323
- advanced?: Record<string, unknown>;
324
- index: number;
325
- }
326
- interface ReorderMessage {
327
- type: "cmssy:reorder";
328
- protocolVersion: number;
329
- blockIds: string[];
330
- }
331
- interface RemoveMessage {
332
- type: "cmssy:remove";
333
- protocolVersion: number;
334
- blockId: string;
335
- }
336
- interface DragOverMessage {
337
- type: "cmssy:drag-over";
338
- protocolVersion: number;
339
- y: number;
340
- }
341
- interface DragEndMessage {
342
- type: "cmssy:drag-end";
343
- protocolVersion: number;
344
- }
345
- type EditorToAppMessage = SelectMessage | PatchMessage | ParentReadyMessage | InsertMessage | ReorderMessage | RemoveMessage | DragOverMessage | DragEndMessage;
346
- declare function isProtocolCompatible(version: number): boolean;
347
-
348
- interface PostTarget {
349
- postMessage: (message: unknown, targetOrigin: string) => void;
350
- }
351
- declare function normalizeOrigin(origin: string): string;
352
- declare function postToEditor(target: PostTarget, editorOrigin: string, message: AppToEditorMessage): void;
353
- declare function resolveInitialTarget(editorOrigin: string | string[]): string;
354
- declare function parseEditorMessage(data: unknown, origin: string, expectedOrigin: string | string[]): EditorToAppMessage | null;
69
+ declare function buildBlockContext(locale: string, defaultLocale: string, enabledLocales?: string[], isPreview?: boolean, forms?: Record<string, CmssyFormDefinition>, extra?: BuildBlockContextExtra): CmssyBlockContext;
355
70
 
356
71
  declare const CMSSY_EDIT_HEADER = "x-cmssy-edit";
357
72
  declare const CMSSY_EDIT_QUERY_PARAM = "cmssyEdit";
@@ -366,114 +81,6 @@ declare function isVerifiedEditUrl(url: {
366
81
  draftSecret: string;
367
82
  }): Promise<boolean>;
368
83
 
369
- declare function cmssySecretsMatch(a: string, b: string): Promise<boolean>;
370
-
371
- interface CmssyCspOptions {
372
- /** Defaults to the cmssy cloud admin origin when unset. */
373
- editorOrigin?: string | string[];
374
- }
375
- interface MutableHeaders {
376
- headers: {
377
- get: (name: string) => string | null;
378
- set: (name: string, value: string) => void;
379
- delete: (name: string) => void;
380
- };
381
- }
382
- declare function toCspOrigin(origin: string): string;
383
- declare function cmssyCspHeaders(options: CmssyCspOptions): Record<string, string>;
384
- declare function applyCmssyCsp<T extends MutableHeaders>(response: T, options: CmssyCspOptions): T;
385
-
386
- /**
387
- * Maps a page slug to its path for a locale: the default locale gets no
388
- * prefix, others get `/${locale}`. The homepage ("/") stays "/" (or "/${locale}").
389
- */
390
- declare function localizedPath(slug: string, locale: string, defaultLocale: string): string;
391
-
392
- declare const CMSSY_SESSION_COOKIE = "cmssy_session";
393
- declare const SESSION_MAX_AGE_SECONDS: number;
394
- declare const MIN_SESSION_SECRET_LENGTH = 32;
395
- declare function sealSession(payload: CmssySessionPayload, secret: string, audience?: string): Promise<string>;
396
- declare function openSession(token: string, secret: string, audience?: string): Promise<CmssySessionPayload | null>;
397
- declare function isAccessExpired(payload: CmssySessionPayload, now?: number): boolean;
398
- declare function sessionCookieOptions(): SessionCookieOptions;
399
-
400
- interface AuthMutationResult {
401
- success: boolean;
402
- message: string;
403
- }
404
- interface AuthTokenResult extends AuthMutationResult {
405
- accessToken: string | null;
406
- refreshToken: string | null;
407
- accessTokenExpiresIn: number | null;
408
- }
409
- declare function decodeAccessClaims(accessToken: string): CmssySessionUser | null;
410
- declare function toSessionPayload(result: AuthTokenResult): CmssySessionPayload | null;
411
- declare function backendSignIn(config: CmssyConfig, modelSlug: string, identity: string, password: string): Promise<AuthTokenResult>;
412
- declare function backendRegister(config: CmssyConfig, modelSlug: string, identity: string, password: string, fields: Record<string, unknown>): Promise<AuthMutationResult>;
413
- declare function backendRefresh(config: CmssyConfig, refreshToken: string): Promise<AuthTokenResult>;
414
- declare function backendSignOut(config: CmssyConfig, refreshToken: string): Promise<void>;
415
- declare function backendSignOutEverywhere(config: CmssyConfig, accessToken: string): Promise<void>;
416
- declare function backendForgotPassword(config: CmssyConfig, modelSlug: string, identity: string): Promise<AuthMutationResult>;
417
- declare function backendResetPassword(config: CmssyConfig, token: string, newPassword: string): Promise<AuthMutationResult>;
418
- declare function backendVerifyEmail(config: CmssyConfig, token: string): Promise<AuthMutationResult>;
419
-
420
- interface CartRequestContext {
421
- cartToken: string;
422
- accessToken?: string;
423
- }
424
- declare function backendGetCart(config: CmssyConfig, ctx: CartRequestContext): Promise<CmssyCart | null>;
425
- declare function backendAddToCart(config: CmssyConfig, ctx: CartRequestContext, input: {
426
- recordId: string;
427
- quantity: number;
428
- variantSelections?: Record<string, string>;
429
- notes?: string;
430
- }): Promise<CmssyCart>;
431
- declare function backendUpdateItem(config: CmssyConfig, ctx: CartRequestContext, input: {
432
- itemId: string;
433
- quantity: number;
434
- }): Promise<CmssyCart>;
435
- declare function backendRemoveItem(config: CmssyConfig, ctx: CartRequestContext, itemId: string): Promise<CmssyCart>;
436
- declare function backendClearCart(config: CmssyConfig, ctx: CartRequestContext): Promise<CmssyCart>;
437
- declare function backendApplyDiscount(config: CmssyConfig, ctx: CartRequestContext, code: string): Promise<CmssyCart>;
438
- declare function backendRemoveDiscount(config: CmssyConfig, ctx: CartRequestContext): Promise<CmssyCart>;
439
- declare function backendSetShippingMethod(config: CmssyConfig, ctx: CartRequestContext, shippingMethodId: string | null): Promise<CmssyCart>;
440
- declare function backendMergeCart(config: CmssyConfig, ctx: CartRequestContext): Promise<CmssyCart>;
441
- interface CheckoutInput {
442
- customerEmail: string;
443
- poNumber?: string | null;
444
- customerNote?: string | null;
445
- shippingAddress?: CmssyAddress | null;
446
- }
447
- declare function backendCheckout(config: CmssyConfig, ctx: CartRequestContext, input: CheckoutInput): Promise<CmssyOrder>;
448
- declare function backendProduct(config: CmssyConfig, ctx: CartRequestContext, modelSlug: string, filter: Record<string, unknown>): Promise<CmssyProduct | null>;
449
-
450
- declare function backendMyOrders(config: CmssyConfig, accessToken: string, options: {
451
- skip?: number;
452
- limit?: number;
453
- }): Promise<MyOrdersResult>;
454
- declare function backendMyOrder(config: CmssyConfig, accessToken: string, id: string): Promise<CmssyOrder | null>;
455
- declare function backendOrderByToken(config: CmssyConfig, options: {
456
- orderId: string;
457
- accessToken: string;
458
- }): Promise<CmssyOrder>;
459
-
460
- declare const PRODUCTS_QUERY = "query Products($workspaceId: String!, $modelSlug: String!, $filter: JSON, $stockState: String, $locale: String, $limit: Int, $offset: Int, $sort: String) {\n public {\n model {\n records(workspaceId: $workspaceId, modelSlug: $modelSlug, filter: $filter, stockState: $stockState, locale: $locale, limit: $limit, offset: $offset, sort: $sort) {\n total\n hasMore\n items {\n id\n data\n priceTiers { minQty price }\n variants { id sku price inventory tiers { minQty price } selectedOptions { name value } }\n }\n }\n }\n }\n}";
461
- /**
462
- * A catalog read is plain data: it takes the locale it is given. Framework
463
- * adapters are the ones that know how to find the locale of the current request
464
- * (@cmssy/next reads it from the middleware header) and pass it in. Omitting it
465
- * means "the workspace's default language".
466
- */
467
- declare function fetchProducts(config: CmssyConfig, options: FetchProductsOptions): Promise<CmssyProductPage>;
468
- declare function fetchProduct(config: CmssyConfig, options: FetchProductOptions): Promise<CmssyProduct | null>;
469
-
470
- declare function fetchOrderByToken(config: CmssyConfig, options: FetchOrderByTokenOptions): Promise<CmssyOrder>;
471
-
472
- declare function fractionDigits(currency: string): number;
473
- declare function fromMinorUnits(minor: number, currency: string): number;
474
- declare function toMinorUnits(amount: number, currency: string): number;
475
- declare function formatPrice(minor: number, currency: string | null | undefined): string;
476
-
477
84
  /**
478
85
  * Verify + parse an inbound cmssy webhook (CMS-693 / CMS-694).
479
86
  *
@@ -496,4 +103,4 @@ declare class CmssyWebhookError extends Error {
496
103
  */
497
104
  declare function verifyCmssyWebhook(options: VerifyCmssyWebhookOptions): Promise<CmssyWebhookEvent>;
498
105
 
499
- export { type AppToEditorMessage, type AuthMutationResult, type AuthTokenResult, type BlockSchemaMap, type BoundsMessage, CMSSY_EDIT_HEADER, CMSSY_EDIT_QUERY_PARAM, CMSSY_LOCALE_HEADER, CMSSY_SECRET_QUERY_PARAM, CMSSY_SESSION_COOKIE, type CartRequestContext, type CheckoutInput, type ClickMessage, type CmssyClient, type CmssyConfig, type CmssyCspOptions, type CmssyEnvConfig, CmssyWebhookError, DEFAULT_CMSSY_EDITOR_ORIGINS, type EditorToAppMessage, FORM_QUERY, FetchLike, type GraphqlRequestOptions, MIN_SESSION_SECRET_LENGTH, MODEL_DEFINITIONS_QUERY, MODEL_RECORDS_QUERY, PRODUCTS_QUERY, PROTOCOL_VERSION, type ParentReadyMessage, type PatchMessage, type PostTarget, type QueryScopedOptions, RECORDS_BY_IDS_QUERY, type ReadyMessage, type RelationContentEntry, RetryPolicy, SESSION_MAX_AGE_SECONDS, SITE_CONFIG_QUERY, SUBMIT_FORM_MUTATION, type SelectMessage, applyCmssyCsp, asBucket, assertAuthConfig, backendAddToCart, backendApplyDiscount, backendCheckout, backendClearCart, backendForgotPassword, backendGetCart, backendMergeCart, backendMyOrder, backendMyOrders, backendOrderByToken, backendProduct, backendRefresh, backendRegister, backendRemoveDiscount, backendRemoveItem, backendResetPassword, backendSetShippingMethod, backendSignIn, backendSignOut, backendSignOutEverywhere, backendUpdateItem, backendVerifyEmail, buildBlockContext, buildLocaleSwitchHref, cachedWorkspaceId, clearWorkspaceIdCache, cmssyCspHeaders, cmssySecretsMatch, collectFormIds, createCmssyClient, decodeAccessClaims, defineCmssyConfig, fetchOrderByToken, fetchProduct, fetchProducts, fetchSiteConfig, fields, formatPrice, fractionDigits, fromMinorUnits, getBlockContentForLanguage, graphqlRequest, isAccessExpired, isDevelopment, isProtocolCompatible, isVerifiedEditUrl, localeForPath, localeForPathname, localesFromSiteConfig, localizeHref, localizeHtmlLinks, localizedPath, normalizeOrigin, normalizeRelationContent, openSession, parseEditorMessage, postToEditor, resolveEditorOrigin, resolveForms, resolveInitialTarget, resolveRelationContent, resolveSiteLocales, resolveWorkspaceId, sealSession, sessionCookieOptions, splitCmssyLocale, splitLocaleFromPath, toCspOrigin, toMinorUnits, toSessionPayload, verifyCmssyWebhook };
106
+ export { CMSSY_EDIT_HEADER, CMSSY_EDIT_QUERY_PARAM, CMSSY_SECRET_QUERY_PARAM, CmssyWebhookError, buildBlockContext, fields, isVerifiedEditUrl, verifyCmssyWebhook };