@cmssy/next 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/server.d.cts CHANGED
@@ -1,196 +1,15 @@
1
1
  export { C as CmssyEditorProps, a as CreateCmssyPageOptions, c as createCmssyEditPage, b as createCmssyPage } from './index-C4vUxDkk.cjs';
2
- import * as react_jsx_runtime from 'react/jsx-runtime';
3
- import { ReactNode, ComponentType } from 'react';
4
- import { BlockDefinition, CmssyLayoutGroup } from '@cmssy/react';
5
- import { CmssyConfig, CmssySessionUser, CmssyClientConfig, FetchProductOptions, CmssyProduct, FetchProductsOptions, CmssyProductPage } from '@cmssy/core';
6
- import { Metadata, MetadataRoute } from 'next';
2
+ import { CmssyConfig, CmssyClientConfig } from '@cmssy/core';
3
+ import 'react/jsx-runtime';
4
+ import 'react';
5
+ import '@cmssy/react';
7
6
  import '@cmssy/react/client';
8
7
 
9
- interface CreateCmssyNotFoundOptions {
10
- /**
11
- * Rendered when no 404 page is configured in Settings, or the configured
12
- * page has no published content. Defaults to a minimal built-in message.
13
- */
14
- fallback?: ReactNode;
15
- }
16
- /**
17
- * Renders the workspace's configured 404 page (Settings → 404 page) as the
18
- * body of Next's `app/not-found.tsx`, preserving the HTTP 404 status. Drop the
19
- * returned component in as the default export of `app/not-found.tsx`:
20
- *
21
- * export default createCmssyNotFound(cmssy, blocks);
22
- */
23
- declare function createCmssyNotFound(config: CmssyConfig, blocks: BlockDefinition[], options?: CreateCmssyNotFoundOptions): () => Promise<string | number | bigint | boolean | react_jsx_runtime.JSX.Element | Iterable<ReactNode> | null | undefined>;
24
-
25
- interface CmssyLayoutSlotProps {
26
- config: CmssyConfig;
27
- blocks: BlockDefinition[];
28
- position: string;
29
- /**
30
- * The page whose layout to render. Defaults to "/" - the site-wide header
31
- * and footer.
32
- */
33
- page?: string;
34
- /**
35
- * The client wrapper around CmssyLazyLayout, rendered in edit mode. Without it
36
- * the header and the footer are markup the editor can select and cannot fill.
37
- *
38
- * A COMPONENT, not a function to call: it lives on the client, and the server
39
- * can only render it.
40
- */
41
- editable?: ComponentType<{
42
- groups: CmssyLayoutGroup[];
43
- position: string;
44
- locale: string;
45
- defaultLocale: string;
46
- enabledLocales: string[];
47
- edit: {
48
- editorOrigin: string;
49
- };
50
- data?: Record<string, unknown>;
51
- resolvedContent?: Record<string, Record<string, unknown>>;
52
- }>;
53
- }
54
- /**
55
- * The site-wide header and footer, rendered the way each mode needs them:
56
- *
57
- * - published traffic: server-rendered layout blocks (static, no client cost);
58
- * - the editor: the same blocks through the edit bridge, fetched with the
59
- * preview secret, so what you see is the draft you are editing.
60
- *
61
- * Getting this wrong is invisible - the site looks right and the editor shows a
62
- * header it cannot edit, or the published version of one. Both shipped before.
63
- */
64
- declare function CmssyLayoutSlot({ config, blocks, position, page, editable, }: CmssyLayoutSlotProps): Promise<react_jsx_runtime.JSX.Element>;
65
-
66
- interface SeoBaseUrlOption {
67
- /**
68
- * Override for the canonical origin. A string (e.g. https://cmssy.com) or a
69
- * resolver. Falls back to `config.siteUrl`, then the request `host` header.
70
- */
71
- baseUrl?: string | (() => string | Promise<string>);
72
- }
73
-
74
- interface BuildCmssyMetadataOptions extends SeoBaseUrlOption {
75
- /** Override the Open Graph / Twitter image (defaults to workspace branding). */
76
- image?: string;
77
- /** Open Graph type. Defaults to "website". */
78
- ogType?: string;
79
- /** Twitter card. Defaults to "summary_large_image" when an image exists. */
80
- twitterCard?: "summary" | "summary_large_image";
81
- /**
82
- * The language to render metadata in. Only needed when the language does not
83
- * live in the URL (a per-domain or cookie strategy); with a locale prefix the
84
- * path already says it.
85
- */
86
- locale?: string;
87
- }
88
- /**
89
- * Builds complete Next.js `Metadata` for a cmssy page from its SEO fields and
90
- * the workspace branding: title/description/keywords, canonical + per-locale
91
- * `hreflang` alternates, and Open Graph / Twitter cards (with the branding OG
92
- * image). Use in a route's `generateMetadata`:
93
- *
94
- * export const generateMetadata = async ({ params }) =>
95
- * buildCmssyMetadata(cmssy, (await params).path);
96
- *
97
- * Pass the catch-all segments **as routed**, locale prefix and all: the prefix
98
- * is what says which language this page is. Stripping it first (and leaving the
99
- * language to `config.resolveLocale`) is how every localized page ends up with
100
- * the default language's title - and a canonical pointing at the default
101
- * language's URL, which tells Google the translation is a duplicate.
102
- */
103
- declare function buildCmssyMetadata(config: CmssyConfig, path?: string | string[], options?: BuildCmssyMetadataOptions): Promise<Metadata>;
104
-
105
- interface CreateCmssyRobotsOptions extends SeoBaseUrlOption {
106
- /** Path prefixes to disallow. Defaults to `["/api/"]`. */
107
- disallow?: string[];
108
- /** Override the generated rules entirely. */
109
- rules?: MetadataRoute.Robots["rules"];
110
- /** Reference `${baseUrl}/sitemap.xml`. Defaults to true. */
111
- sitemap?: boolean;
112
- /**
113
- * Emit the non-standard `Host:` directive (a Yandex extension). Google
114
- * ignores it and reports a warning in Search Console, so it is off by
115
- * default. Enable only when targeting Yandex.
116
- */
117
- host?: boolean;
118
- }
119
- /**
120
- * Builds the default export for Next's `app/robots.ts`. Allows crawling and
121
- * points to the sitemap. Drop in as:
122
- *
123
- * export default createCmssyRobots(cmssy);
124
- */
125
- declare function createCmssyRobots(config: CmssyConfig, options?: CreateCmssyRobotsOptions): () => Promise<MetadataRoute.Robots>;
126
-
127
- /** What an `extra` resolver needs to build URLs that agree with the page ones. */
128
- interface CmssySitemapContext {
129
- baseUrl: string;
130
- defaultLocale: string;
131
- locales: string[];
132
- }
133
- interface CreateCmssySitemapOptions extends SeoBaseUrlOption {
134
- /**
135
- * Entries appended to the generated page list - the URLs a workspace's PAGES
136
- * cannot express, like a product or a category rendered from model records.
137
- * Pass a resolver to build them at request time; it gets the same baseUrl and
138
- * locales the page entries use, so the two cannot disagree.
139
- */
140
- extra?: MetadataRoute.Sitemap | ((context: CmssySitemapContext) => MetadataRoute.Sitemap | Promise<MetadataRoute.Sitemap>);
141
- /**
142
- * Additional page slugs to omit. The workspace's configured 404 page
143
- * (Settings → 404 page) is excluded automatically via its id, so this is
144
- * only for extra slugs you never want indexed.
145
- */
146
- excludeSlugs?: string[];
147
- }
148
- /**
149
- * Builds the default export for Next's `app/sitemap.ts` from the workspace's
150
- * published pages. Emits one entry per page with per-locale `alternates` when
151
- * the config enables multiple locales. Drop in as:
152
- *
153
- * export default createCmssySitemap(cmssy);
154
- */
155
- declare function createCmssySitemap(config: CmssyConfig, options?: CreateCmssySitemapOptions): () => Promise<MetadataRoute.Sitemap>;
156
-
157
- interface CmssyAuthRouteHandlers {
158
- POST(request: Request, context: {
159
- params: Promise<{
160
- action: string;
161
- }>;
162
- }): Promise<Response>;
163
- GET(request: Request, context: {
164
- params: Promise<{
165
- action: string;
166
- }>;
167
- }): Promise<Response>;
168
- }
169
- declare function createCmssyAuthRoute(config: CmssyConfig): CmssyAuthRouteHandlers;
170
-
171
- declare const CMSSY_CART_COOKIE = "cmssy_cart";
172
- interface CmssyCartRouteHandlers {
173
- POST(request: Request, context: {
174
- params: Promise<{
175
- action: string;
176
- }>;
177
- }): Promise<Response>;
178
- }
179
- declare function createCmssyCartRoute(config: CmssyConfig): CmssyCartRouteHandlers;
180
-
181
- interface CmssyOrdersRouteHandlers {
182
- GET(request: Request): Promise<Response>;
183
- }
184
- declare function createCmssyOrdersRoute(config: CmssyConfig): CmssyOrdersRouteHandlers;
185
-
186
8
  type CmssyDraftRouteConfig = Pick<CmssyConfig, "draftSecret"> & {
187
9
  defaultRedirect?: string;
188
10
  };
189
11
  declare function createDraftRoute(config: CmssyDraftRouteConfig): (request: Request) => Promise<Response>;
190
12
 
191
- declare function getCmssyUser(config: CmssyConfig): Promise<CmssySessionUser | null>;
192
- declare function getCmssyAccessToken(config: CmssyConfig): Promise<string | null>;
193
-
194
13
  /**
195
14
  * Resolve the active locale. Pass `options.path` (route params) wherever
196
15
  * possible - that path is static-safe. The no-argument form falls back to the
@@ -203,7 +22,4 @@ declare function getCmssyLocale(config: CmssyClientConfig, options?: {
203
22
 
204
23
  declare function isCmssyEditMode(): Promise<boolean>;
205
24
 
206
- declare function fetchProducts(config: CmssyConfig, options: FetchProductsOptions): Promise<CmssyProductPage>;
207
- declare function fetchProduct(config: CmssyConfig, options: FetchProductOptions): Promise<CmssyProduct | null>;
208
-
209
- export { type BuildCmssyMetadataOptions, CMSSY_CART_COOKIE, type CmssyAuthRouteHandlers, type CmssyCartRouteHandlers, type CmssyDraftRouteConfig, CmssyLayoutSlot, type CmssyLayoutSlotProps, type CmssyOrdersRouteHandlers, type CmssySitemapContext, type CreateCmssyNotFoundOptions, type CreateCmssyRobotsOptions, type CreateCmssySitemapOptions, buildCmssyMetadata, createCmssyAuthRoute, createCmssyCartRoute, createCmssyNotFound, createCmssyOrdersRoute, createCmssyRobots, createCmssySitemap, createDraftRoute, fetchProduct, fetchProducts, getCmssyAccessToken, getCmssyLocale, getCmssyUser, isCmssyEditMode };
25
+ export { type CmssyDraftRouteConfig, createDraftRoute, getCmssyLocale, isCmssyEditMode };
package/dist/server.d.ts CHANGED
@@ -1,196 +1,15 @@
1
1
  export { C as CmssyEditorProps, a as CreateCmssyPageOptions, c as createCmssyEditPage, b as createCmssyPage } from './index-C4vUxDkk.js';
2
- import * as react_jsx_runtime from 'react/jsx-runtime';
3
- import { ReactNode, ComponentType } from 'react';
4
- import { BlockDefinition, CmssyLayoutGroup } from '@cmssy/react';
5
- import { CmssyConfig, CmssySessionUser, CmssyClientConfig, FetchProductOptions, CmssyProduct, FetchProductsOptions, CmssyProductPage } from '@cmssy/core';
6
- import { Metadata, MetadataRoute } from 'next';
2
+ import { CmssyConfig, CmssyClientConfig } from '@cmssy/core';
3
+ import 'react/jsx-runtime';
4
+ import 'react';
5
+ import '@cmssy/react';
7
6
  import '@cmssy/react/client';
8
7
 
9
- interface CreateCmssyNotFoundOptions {
10
- /**
11
- * Rendered when no 404 page is configured in Settings, or the configured
12
- * page has no published content. Defaults to a minimal built-in message.
13
- */
14
- fallback?: ReactNode;
15
- }
16
- /**
17
- * Renders the workspace's configured 404 page (Settings → 404 page) as the
18
- * body of Next's `app/not-found.tsx`, preserving the HTTP 404 status. Drop the
19
- * returned component in as the default export of `app/not-found.tsx`:
20
- *
21
- * export default createCmssyNotFound(cmssy, blocks);
22
- */
23
- declare function createCmssyNotFound(config: CmssyConfig, blocks: BlockDefinition[], options?: CreateCmssyNotFoundOptions): () => Promise<string | number | bigint | boolean | react_jsx_runtime.JSX.Element | Iterable<ReactNode> | null | undefined>;
24
-
25
- interface CmssyLayoutSlotProps {
26
- config: CmssyConfig;
27
- blocks: BlockDefinition[];
28
- position: string;
29
- /**
30
- * The page whose layout to render. Defaults to "/" - the site-wide header
31
- * and footer.
32
- */
33
- page?: string;
34
- /**
35
- * The client wrapper around CmssyLazyLayout, rendered in edit mode. Without it
36
- * the header and the footer are markup the editor can select and cannot fill.
37
- *
38
- * A COMPONENT, not a function to call: it lives on the client, and the server
39
- * can only render it.
40
- */
41
- editable?: ComponentType<{
42
- groups: CmssyLayoutGroup[];
43
- position: string;
44
- locale: string;
45
- defaultLocale: string;
46
- enabledLocales: string[];
47
- edit: {
48
- editorOrigin: string;
49
- };
50
- data?: Record<string, unknown>;
51
- resolvedContent?: Record<string, Record<string, unknown>>;
52
- }>;
53
- }
54
- /**
55
- * The site-wide header and footer, rendered the way each mode needs them:
56
- *
57
- * - published traffic: server-rendered layout blocks (static, no client cost);
58
- * - the editor: the same blocks through the edit bridge, fetched with the
59
- * preview secret, so what you see is the draft you are editing.
60
- *
61
- * Getting this wrong is invisible - the site looks right and the editor shows a
62
- * header it cannot edit, or the published version of one. Both shipped before.
63
- */
64
- declare function CmssyLayoutSlot({ config, blocks, position, page, editable, }: CmssyLayoutSlotProps): Promise<react_jsx_runtime.JSX.Element>;
65
-
66
- interface SeoBaseUrlOption {
67
- /**
68
- * Override for the canonical origin. A string (e.g. https://cmssy.com) or a
69
- * resolver. Falls back to `config.siteUrl`, then the request `host` header.
70
- */
71
- baseUrl?: string | (() => string | Promise<string>);
72
- }
73
-
74
- interface BuildCmssyMetadataOptions extends SeoBaseUrlOption {
75
- /** Override the Open Graph / Twitter image (defaults to workspace branding). */
76
- image?: string;
77
- /** Open Graph type. Defaults to "website". */
78
- ogType?: string;
79
- /** Twitter card. Defaults to "summary_large_image" when an image exists. */
80
- twitterCard?: "summary" | "summary_large_image";
81
- /**
82
- * The language to render metadata in. Only needed when the language does not
83
- * live in the URL (a per-domain or cookie strategy); with a locale prefix the
84
- * path already says it.
85
- */
86
- locale?: string;
87
- }
88
- /**
89
- * Builds complete Next.js `Metadata` for a cmssy page from its SEO fields and
90
- * the workspace branding: title/description/keywords, canonical + per-locale
91
- * `hreflang` alternates, and Open Graph / Twitter cards (with the branding OG
92
- * image). Use in a route's `generateMetadata`:
93
- *
94
- * export const generateMetadata = async ({ params }) =>
95
- * buildCmssyMetadata(cmssy, (await params).path);
96
- *
97
- * Pass the catch-all segments **as routed**, locale prefix and all: the prefix
98
- * is what says which language this page is. Stripping it first (and leaving the
99
- * language to `config.resolveLocale`) is how every localized page ends up with
100
- * the default language's title - and a canonical pointing at the default
101
- * language's URL, which tells Google the translation is a duplicate.
102
- */
103
- declare function buildCmssyMetadata(config: CmssyConfig, path?: string | string[], options?: BuildCmssyMetadataOptions): Promise<Metadata>;
104
-
105
- interface CreateCmssyRobotsOptions extends SeoBaseUrlOption {
106
- /** Path prefixes to disallow. Defaults to `["/api/"]`. */
107
- disallow?: string[];
108
- /** Override the generated rules entirely. */
109
- rules?: MetadataRoute.Robots["rules"];
110
- /** Reference `${baseUrl}/sitemap.xml`. Defaults to true. */
111
- sitemap?: boolean;
112
- /**
113
- * Emit the non-standard `Host:` directive (a Yandex extension). Google
114
- * ignores it and reports a warning in Search Console, so it is off by
115
- * default. Enable only when targeting Yandex.
116
- */
117
- host?: boolean;
118
- }
119
- /**
120
- * Builds the default export for Next's `app/robots.ts`. Allows crawling and
121
- * points to the sitemap. Drop in as:
122
- *
123
- * export default createCmssyRobots(cmssy);
124
- */
125
- declare function createCmssyRobots(config: CmssyConfig, options?: CreateCmssyRobotsOptions): () => Promise<MetadataRoute.Robots>;
126
-
127
- /** What an `extra` resolver needs to build URLs that agree with the page ones. */
128
- interface CmssySitemapContext {
129
- baseUrl: string;
130
- defaultLocale: string;
131
- locales: string[];
132
- }
133
- interface CreateCmssySitemapOptions extends SeoBaseUrlOption {
134
- /**
135
- * Entries appended to the generated page list - the URLs a workspace's PAGES
136
- * cannot express, like a product or a category rendered from model records.
137
- * Pass a resolver to build them at request time; it gets the same baseUrl and
138
- * locales the page entries use, so the two cannot disagree.
139
- */
140
- extra?: MetadataRoute.Sitemap | ((context: CmssySitemapContext) => MetadataRoute.Sitemap | Promise<MetadataRoute.Sitemap>);
141
- /**
142
- * Additional page slugs to omit. The workspace's configured 404 page
143
- * (Settings → 404 page) is excluded automatically via its id, so this is
144
- * only for extra slugs you never want indexed.
145
- */
146
- excludeSlugs?: string[];
147
- }
148
- /**
149
- * Builds the default export for Next's `app/sitemap.ts` from the workspace's
150
- * published pages. Emits one entry per page with per-locale `alternates` when
151
- * the config enables multiple locales. Drop in as:
152
- *
153
- * export default createCmssySitemap(cmssy);
154
- */
155
- declare function createCmssySitemap(config: CmssyConfig, options?: CreateCmssySitemapOptions): () => Promise<MetadataRoute.Sitemap>;
156
-
157
- interface CmssyAuthRouteHandlers {
158
- POST(request: Request, context: {
159
- params: Promise<{
160
- action: string;
161
- }>;
162
- }): Promise<Response>;
163
- GET(request: Request, context: {
164
- params: Promise<{
165
- action: string;
166
- }>;
167
- }): Promise<Response>;
168
- }
169
- declare function createCmssyAuthRoute(config: CmssyConfig): CmssyAuthRouteHandlers;
170
-
171
- declare const CMSSY_CART_COOKIE = "cmssy_cart";
172
- interface CmssyCartRouteHandlers {
173
- POST(request: Request, context: {
174
- params: Promise<{
175
- action: string;
176
- }>;
177
- }): Promise<Response>;
178
- }
179
- declare function createCmssyCartRoute(config: CmssyConfig): CmssyCartRouteHandlers;
180
-
181
- interface CmssyOrdersRouteHandlers {
182
- GET(request: Request): Promise<Response>;
183
- }
184
- declare function createCmssyOrdersRoute(config: CmssyConfig): CmssyOrdersRouteHandlers;
185
-
186
8
  type CmssyDraftRouteConfig = Pick<CmssyConfig, "draftSecret"> & {
187
9
  defaultRedirect?: string;
188
10
  };
189
11
  declare function createDraftRoute(config: CmssyDraftRouteConfig): (request: Request) => Promise<Response>;
190
12
 
191
- declare function getCmssyUser(config: CmssyConfig): Promise<CmssySessionUser | null>;
192
- declare function getCmssyAccessToken(config: CmssyConfig): Promise<string | null>;
193
-
194
13
  /**
195
14
  * Resolve the active locale. Pass `options.path` (route params) wherever
196
15
  * possible - that path is static-safe. The no-argument form falls back to the
@@ -203,7 +22,4 @@ declare function getCmssyLocale(config: CmssyClientConfig, options?: {
203
22
 
204
23
  declare function isCmssyEditMode(): Promise<boolean>;
205
24
 
206
- declare function fetchProducts(config: CmssyConfig, options: FetchProductsOptions): Promise<CmssyProductPage>;
207
- declare function fetchProduct(config: CmssyConfig, options: FetchProductOptions): Promise<CmssyProduct | null>;
208
-
209
- export { type BuildCmssyMetadataOptions, CMSSY_CART_COOKIE, type CmssyAuthRouteHandlers, type CmssyCartRouteHandlers, type CmssyDraftRouteConfig, CmssyLayoutSlot, type CmssyLayoutSlotProps, type CmssyOrdersRouteHandlers, type CmssySitemapContext, type CreateCmssyNotFoundOptions, type CreateCmssyRobotsOptions, type CreateCmssySitemapOptions, buildCmssyMetadata, createCmssyAuthRoute, createCmssyCartRoute, createCmssyNotFound, createCmssyOrdersRoute, createCmssyRobots, createCmssySitemap, createDraftRoute, fetchProduct, fetchProducts, getCmssyAccessToken, getCmssyLocale, getCmssyUser, isCmssyEditMode };
25
+ export { type CmssyDraftRouteConfig, createDraftRoute, getCmssyLocale, isCmssyEditMode };