@cmssy/next 0.7.3 → 0.7.4

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.cjs CHANGED
@@ -95,6 +95,33 @@ function resolveEditorOrigin(editorOrigin) {
95
95
  }
96
96
  return value.trim().length > 0 ? value : DEFAULT_CMSSY_EDITOR_ORIGINS;
97
97
  }
98
+ var REQUIRED_CONFIG_ENV = [
99
+ ["workspaceSlug", "CMSSY_WORKSPACE_SLUG"],
100
+ ["draftSecret", "CMSSY_DRAFT_SECRET"]
101
+ ];
102
+ function defineCmssyConfig(config) {
103
+ const resolved = { ...config };
104
+ const missing = [];
105
+ for (const [key, env] of REQUIRED_CONFIG_ENV) {
106
+ const value = config[key];
107
+ const trimmed = typeof value === "string" ? value.trim() : "";
108
+ if (trimmed) {
109
+ resolved[key] = trimmed;
110
+ } else {
111
+ missing.push(`${env} (config.${key})`);
112
+ }
113
+ }
114
+ if (missing.length > 0) {
115
+ throw new Error(
116
+ `cmssy: missing required configuration:
117
+ - ${missing.join(
118
+ "\n - "
119
+ )}
120
+ Set the listed environment variables (e.g. in .env.local) and restart the dev server.`
121
+ );
122
+ }
123
+ return resolved;
124
+ }
98
125
  function assertAuthConfig(config) {
99
126
  const auth = config.auth;
100
127
  if (!auth || typeof auth.modelSlug !== "string" || !auth.modelSlug) {
@@ -1671,6 +1698,7 @@ exports.createCmssyPage = createCmssyPage;
1671
1698
  exports.createCmssyRobots = createCmssyRobots;
1672
1699
  exports.createCmssySitemap = createCmssySitemap;
1673
1700
  exports.createDraftRoute = createDraftRoute;
1701
+ exports.defineCmssyConfig = defineCmssyConfig;
1674
1702
  exports.fetchProduct = fetchProduct;
1675
1703
  exports.fetchProducts = fetchProducts;
1676
1704
  exports.getCmssyAccessToken = getCmssyAccessToken;
package/dist/index.d.cts CHANGED
@@ -46,6 +46,24 @@ interface CmssyNextConfig {
46
46
  enabledLocales?: string[];
47
47
  resolveLocale?: () => string | Promise<string>;
48
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<CmssyNextConfig, "workspaceSlug" | "draftSecret"> & {
56
+ workspaceSlug?: string;
57
+ draftSecret?: string;
58
+ };
59
+ /**
60
+ * Validates an env-sourced config and returns a strictly-typed
61
+ * {@link CmssyNextConfig}. Pass raw `process.env.*` values; this throws a clear,
62
+ * actionable error listing any missing required variables (rendered by the
63
+ * Next.js error overlay / boundary), so the app fails fast instead of running
64
+ * with silently-empty config.
65
+ */
66
+ declare function defineCmssyConfig(config: CmssyEnvConfig): CmssyNextConfig;
49
67
  declare function assertAuthConfig(config: CmssyNextConfig): CmssyAuthConfig;
50
68
 
51
69
  interface CmssyEditorProps {
@@ -349,4 +367,4 @@ declare class CmssyWebhookError extends Error {
349
367
  */
350
368
  declare function verifyCmssyWebhook(options: VerifyCmssyWebhookOptions): CmssyWebhookEvent;
351
369
 
352
- export { type BuildCmssyMetadataOptions, CMSSY_CART_COOKIE, CMSSY_EDIT_HEADER, CMSSY_LOCALE_HEADER, CMSSY_SESSION_COOKIE, type CmssyAuthConfig, type CmssyAuthMiddleware, type CmssyAuthRouteHandlers, type CmssyCartRouteHandlers, type CmssyCspOptions, type CmssyDraftRouteConfig, type CmssyEditorProps, type CmssyNextConfig, type CmssyOrdersRouteHandlers, type CmssySessionPayload, type CmssySessionUser, CmssyWebhookError, type CmssyWebhookEvent, type CmssyWebhookOrder, type CreateCmssyNotFoundOptions, type CreateCmssyPageOptions, type CreateCmssyRobotsOptions, type CreateCmssySitemapOptions, DEFAULT_CMSSY_EDITOR_ORIGINS, type FetchProductOptions, type FetchProductsOptions, type MyOrdersResult, SESSION_MAX_AGE_SECONDS, type SessionCookieOptions, type VerifyCmssyWebhookOptions, applyCmssyCsp, assertAuthConfig, buildCmssyMetadata, cmssyCspHeaders, createCmssyAuthMiddleware, createCmssyAuthRoute, createCmssyCartRoute, createCmssyLocaleMiddleware, createCmssyNotFound, createCmssyOrdersRoute, createCmssyPage, createCmssyRobots, createCmssySitemap, createDraftRoute, fetchProduct, fetchProducts, getCmssyAccessToken, getCmssyLocale, getCmssyUser, isAccessExpired, isCmssyEditMode, isCmssyEditRequest, localeForPathname, openSession, resolveEditorOrigin, resolveLocaleFromPathname, sealSession, sessionCookieOptions, splitCmssyLocale, verifyCmssyWebhook };
370
+ export { type BuildCmssyMetadataOptions, CMSSY_CART_COOKIE, CMSSY_EDIT_HEADER, CMSSY_LOCALE_HEADER, CMSSY_SESSION_COOKIE, type CmssyAuthConfig, type CmssyAuthMiddleware, type CmssyAuthRouteHandlers, type CmssyCartRouteHandlers, type CmssyCspOptions, type CmssyDraftRouteConfig, type CmssyEditorProps, type CmssyEnvConfig, type CmssyNextConfig, type CmssyOrdersRouteHandlers, type CmssySessionPayload, type CmssySessionUser, CmssyWebhookError, type CmssyWebhookEvent, type CmssyWebhookOrder, type CreateCmssyNotFoundOptions, type CreateCmssyPageOptions, type CreateCmssyRobotsOptions, type CreateCmssySitemapOptions, DEFAULT_CMSSY_EDITOR_ORIGINS, type FetchProductOptions, type FetchProductsOptions, type MyOrdersResult, SESSION_MAX_AGE_SECONDS, type SessionCookieOptions, type VerifyCmssyWebhookOptions, applyCmssyCsp, assertAuthConfig, buildCmssyMetadata, cmssyCspHeaders, createCmssyAuthMiddleware, createCmssyAuthRoute, createCmssyCartRoute, createCmssyLocaleMiddleware, createCmssyNotFound, createCmssyOrdersRoute, createCmssyPage, createCmssyRobots, createCmssySitemap, createDraftRoute, defineCmssyConfig, fetchProduct, fetchProducts, getCmssyAccessToken, getCmssyLocale, getCmssyUser, isAccessExpired, isCmssyEditMode, isCmssyEditRequest, localeForPathname, openSession, resolveEditorOrigin, resolveLocaleFromPathname, sealSession, sessionCookieOptions, splitCmssyLocale, verifyCmssyWebhook };
package/dist/index.d.ts CHANGED
@@ -46,6 +46,24 @@ interface CmssyNextConfig {
46
46
  enabledLocales?: string[];
47
47
  resolveLocale?: () => string | Promise<string>;
48
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<CmssyNextConfig, "workspaceSlug" | "draftSecret"> & {
56
+ workspaceSlug?: string;
57
+ draftSecret?: string;
58
+ };
59
+ /**
60
+ * Validates an env-sourced config and returns a strictly-typed
61
+ * {@link CmssyNextConfig}. Pass raw `process.env.*` values; this throws a clear,
62
+ * actionable error listing any missing required variables (rendered by the
63
+ * Next.js error overlay / boundary), so the app fails fast instead of running
64
+ * with silently-empty config.
65
+ */
66
+ declare function defineCmssyConfig(config: CmssyEnvConfig): CmssyNextConfig;
49
67
  declare function assertAuthConfig(config: CmssyNextConfig): CmssyAuthConfig;
50
68
 
51
69
  interface CmssyEditorProps {
@@ -349,4 +367,4 @@ declare class CmssyWebhookError extends Error {
349
367
  */
350
368
  declare function verifyCmssyWebhook(options: VerifyCmssyWebhookOptions): CmssyWebhookEvent;
351
369
 
352
- export { type BuildCmssyMetadataOptions, CMSSY_CART_COOKIE, CMSSY_EDIT_HEADER, CMSSY_LOCALE_HEADER, CMSSY_SESSION_COOKIE, type CmssyAuthConfig, type CmssyAuthMiddleware, type CmssyAuthRouteHandlers, type CmssyCartRouteHandlers, type CmssyCspOptions, type CmssyDraftRouteConfig, type CmssyEditorProps, type CmssyNextConfig, type CmssyOrdersRouteHandlers, type CmssySessionPayload, type CmssySessionUser, CmssyWebhookError, type CmssyWebhookEvent, type CmssyWebhookOrder, type CreateCmssyNotFoundOptions, type CreateCmssyPageOptions, type CreateCmssyRobotsOptions, type CreateCmssySitemapOptions, DEFAULT_CMSSY_EDITOR_ORIGINS, type FetchProductOptions, type FetchProductsOptions, type MyOrdersResult, SESSION_MAX_AGE_SECONDS, type SessionCookieOptions, type VerifyCmssyWebhookOptions, applyCmssyCsp, assertAuthConfig, buildCmssyMetadata, cmssyCspHeaders, createCmssyAuthMiddleware, createCmssyAuthRoute, createCmssyCartRoute, createCmssyLocaleMiddleware, createCmssyNotFound, createCmssyOrdersRoute, createCmssyPage, createCmssyRobots, createCmssySitemap, createDraftRoute, fetchProduct, fetchProducts, getCmssyAccessToken, getCmssyLocale, getCmssyUser, isAccessExpired, isCmssyEditMode, isCmssyEditRequest, localeForPathname, openSession, resolveEditorOrigin, resolveLocaleFromPathname, sealSession, sessionCookieOptions, splitCmssyLocale, verifyCmssyWebhook };
370
+ export { type BuildCmssyMetadataOptions, CMSSY_CART_COOKIE, CMSSY_EDIT_HEADER, CMSSY_LOCALE_HEADER, CMSSY_SESSION_COOKIE, type CmssyAuthConfig, type CmssyAuthMiddleware, type CmssyAuthRouteHandlers, type CmssyCartRouteHandlers, type CmssyCspOptions, type CmssyDraftRouteConfig, type CmssyEditorProps, type CmssyEnvConfig, type CmssyNextConfig, type CmssyOrdersRouteHandlers, type CmssySessionPayload, type CmssySessionUser, CmssyWebhookError, type CmssyWebhookEvent, type CmssyWebhookOrder, type CreateCmssyNotFoundOptions, type CreateCmssyPageOptions, type CreateCmssyRobotsOptions, type CreateCmssySitemapOptions, DEFAULT_CMSSY_EDITOR_ORIGINS, type FetchProductOptions, type FetchProductsOptions, type MyOrdersResult, SESSION_MAX_AGE_SECONDS, type SessionCookieOptions, type VerifyCmssyWebhookOptions, applyCmssyCsp, assertAuthConfig, buildCmssyMetadata, cmssyCspHeaders, createCmssyAuthMiddleware, createCmssyAuthRoute, createCmssyCartRoute, createCmssyLocaleMiddleware, createCmssyNotFound, createCmssyOrdersRoute, createCmssyPage, createCmssyRobots, createCmssySitemap, createDraftRoute, defineCmssyConfig, fetchProduct, fetchProducts, getCmssyAccessToken, getCmssyLocale, getCmssyUser, isAccessExpired, isCmssyEditMode, isCmssyEditRequest, localeForPathname, openSession, resolveEditorOrigin, resolveLocaleFromPathname, sealSession, sessionCookieOptions, splitCmssyLocale, verifyCmssyWebhook };
package/dist/index.js CHANGED
@@ -94,6 +94,33 @@ function resolveEditorOrigin(editorOrigin) {
94
94
  }
95
95
  return value.trim().length > 0 ? value : DEFAULT_CMSSY_EDITOR_ORIGINS;
96
96
  }
97
+ var REQUIRED_CONFIG_ENV = [
98
+ ["workspaceSlug", "CMSSY_WORKSPACE_SLUG"],
99
+ ["draftSecret", "CMSSY_DRAFT_SECRET"]
100
+ ];
101
+ function defineCmssyConfig(config) {
102
+ const resolved = { ...config };
103
+ const missing = [];
104
+ for (const [key, env] of REQUIRED_CONFIG_ENV) {
105
+ const value = config[key];
106
+ const trimmed = typeof value === "string" ? value.trim() : "";
107
+ if (trimmed) {
108
+ resolved[key] = trimmed;
109
+ } else {
110
+ missing.push(`${env} (config.${key})`);
111
+ }
112
+ }
113
+ if (missing.length > 0) {
114
+ throw new Error(
115
+ `cmssy: missing required configuration:
116
+ - ${missing.join(
117
+ "\n - "
118
+ )}
119
+ Set the listed environment variables (e.g. in .env.local) and restart the dev server.`
120
+ );
121
+ }
122
+ return resolved;
123
+ }
97
124
  function assertAuthConfig(config) {
98
125
  const auth = config.auth;
99
126
  if (!auth || typeof auth.modelSlug !== "string" || !auth.modelSlug) {
@@ -1641,4 +1668,4 @@ function verifyCmssyWebhook(options) {
1641
1668
  return parsed;
1642
1669
  }
1643
1670
 
1644
- export { CMSSY_CART_COOKIE, CMSSY_EDIT_HEADER, CMSSY_LOCALE_HEADER, CMSSY_SESSION_COOKIE, CmssyWebhookError, DEFAULT_CMSSY_EDITOR_ORIGINS, SESSION_MAX_AGE_SECONDS, applyCmssyCsp, assertAuthConfig, buildCmssyMetadata, cmssyCspHeaders, createCmssyAuthMiddleware, createCmssyAuthRoute, createCmssyCartRoute, createCmssyLocaleMiddleware, createCmssyNotFound, createCmssyOrdersRoute, createCmssyPage, createCmssyRobots, createCmssySitemap, createDraftRoute, fetchProduct, fetchProducts, getCmssyAccessToken, getCmssyLocale, getCmssyUser, isAccessExpired, isCmssyEditMode, isCmssyEditRequest, localeForPathname, openSession, resolveEditorOrigin, resolveLocaleFromPathname, sealSession, sessionCookieOptions, splitCmssyLocale, verifyCmssyWebhook };
1671
+ export { CMSSY_CART_COOKIE, CMSSY_EDIT_HEADER, CMSSY_LOCALE_HEADER, CMSSY_SESSION_COOKIE, CmssyWebhookError, DEFAULT_CMSSY_EDITOR_ORIGINS, SESSION_MAX_AGE_SECONDS, applyCmssyCsp, assertAuthConfig, buildCmssyMetadata, cmssyCspHeaders, createCmssyAuthMiddleware, createCmssyAuthRoute, createCmssyCartRoute, createCmssyLocaleMiddleware, createCmssyNotFound, createCmssyOrdersRoute, createCmssyPage, createCmssyRobots, createCmssySitemap, createDraftRoute, defineCmssyConfig, fetchProduct, fetchProducts, getCmssyAccessToken, getCmssyLocale, getCmssyUser, isAccessExpired, isCmssyEditMode, isCmssyEditRequest, localeForPathname, openSession, resolveEditorOrigin, resolveLocaleFromPathname, sealSession, sessionCookieOptions, splitCmssyLocale, verifyCmssyWebhook };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cmssy/next",
3
- "version": "0.7.3",
3
+ "version": "0.7.4",
4
4
  "description": "Next.js App Router bindings for cmssy headless sites (createCmssyPage + draft preview)",
5
5
  "keywords": [
6
6
  "cmssy",
@@ -41,7 +41,7 @@
41
41
  "dist"
42
42
  ],
43
43
  "peerDependencies": {
44
- "@cmssy/react": "^0.7.3",
44
+ "@cmssy/react": "^0.7.4",
45
45
  "next": ">=15",
46
46
  "react": "^18.2.0 || ^19.0.0",
47
47
  "react-dom": "^18.2.0 || ^19.0.0"
@@ -54,7 +54,7 @@
54
54
  "tsup": "^8.3.0",
55
55
  "typescript": "^5.6.0",
56
56
  "vitest": "^2.1.0",
57
- "@cmssy/react": "0.7.3"
57
+ "@cmssy/react": "0.7.4"
58
58
  },
59
59
  "dependencies": {
60
60
  "jose": "^6.2.3"