@cmssy/core 10.2.0 → 10.3.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/internal.cjs CHANGED
@@ -819,14 +819,6 @@ function localizedPath(slug, locale, defaultLocale) {
819
819
  }
820
820
 
821
821
  // src/block-context.ts
822
- function blockPageOf(page) {
823
- if (!page?.slug) return void 0;
824
- return {
825
- id: page.id,
826
- slug: page.slug,
827
- pageType: page.pageType ?? null
828
- };
829
- }
830
822
  function buildBlockContext(locale, defaultLocale, enabledLocales, isPreview, forms, extra) {
831
823
  return {
832
824
  locale: {
@@ -838,7 +830,18 @@ function buildBlockContext(locale, defaultLocale, enabledLocales, isPreview, for
838
830
  forms,
839
831
  ...extra?.auth ? { auth: extra.auth } : {},
840
832
  ...extra?.workspace ? { workspace: extra.workspace } : {},
841
- ...extra?.page ? { page: extra.page } : {}
833
+ // Identity only, and only when the page has one. A page fetched by an older
834
+ // SDK has no slug, and then a block gets no `page` at all rather than one
835
+ // with a hole in it: "I don't know where I am" has to stay distinguishable
836
+ // from "I am at /".
837
+ ...extra?.page?.slug ? {
838
+ page: {
839
+ id: extra.page.id,
840
+ slug: extra.page.slug,
841
+ pageType: extra.page.pageType ?? null
842
+ }
843
+ } : {},
844
+ ...extra?.app ? { app: extra.app } : {}
842
845
  };
843
846
  }
844
847
 
@@ -945,7 +948,6 @@ exports.RECORDS_BY_IDS_QUERY = RECORDS_BY_IDS_QUERY;
945
948
  exports.SITE_CONFIG_QUERY = SITE_CONFIG_QUERY;
946
949
  exports.SUBMIT_FORM_MUTATION = SUBMIT_FORM_MUTATION;
947
950
  exports.asBucket = asBucket;
948
- exports.blockPageOf = blockPageOf;
949
951
  exports.buildBlockContext = buildBlockContext;
950
952
  exports.buildLocaleSwitchHref = buildLocaleSwitchHref;
951
953
  exports.cachedWorkspaceId = cachedWorkspaceId;
@@ -1,5 +1,5 @@
1
1
  export { 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.cjs';
2
- import { CmssyPageData, CmssyBlockPage, CmssyFormDefinition, BuildBlockContextExtra, CmssyBlockContext, CmssyClientConfig, CmssySiteConfig, RawBlock, FieldDefinition } from '@cmssy/types';
2
+ import { CmssyFormDefinition, BuildBlockContextExtra, CmssyBlockContext, CmssyClientConfig, CmssySiteConfig, RawBlock, FieldDefinition } from '@cmssy/types';
3
3
  export { CmssySiteLocales } from '@cmssy/types';
4
4
  import { G as GraphqlRequestOptions } from './locale-rhYcXU5z.cjs';
5
5
  export { C as CMSSY_LOCALE_HEADER, b as buildLocaleSwitchHref, a as localeForPath, c as localeForPathname, l as localizeHref, d as localizeHtmlLinks, s as splitCmssyLocale } from './locale-rhYcXU5z.cjs';
@@ -13,14 +13,6 @@ declare const MODEL_RECORDS_QUERY = "query PublicModelRecords($workspaceId: Stri
13
13
  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}";
14
14
  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}";
15
15
 
16
- /**
17
- * The identity half of a fetched page, for `context.page`.
18
- *
19
- * A page fetched by an older SDK - or by a consumer that builds `CmssyPageData`
20
- * itself - has no slug, and then a block gets no `page` at all rather than one
21
- * with a hole in it: `context.page ? … : …` is a question a block can answer.
22
- */
23
- declare function blockPageOf(page: CmssyPageData | null | undefined): CmssyBlockPage | undefined;
24
16
  declare function buildBlockContext(locale: string, defaultLocale: string, enabledLocales?: string[], isPreview?: boolean, forms?: Record<string, CmssyFormDefinition>, extra?: BuildBlockContextExtra): CmssyBlockContext;
25
17
 
26
18
  declare function getBlockContentForLanguage(content: unknown, locale: string, defaultLocale?: string, availableLocales?: string[]): Record<string, unknown>;
@@ -70,4 +62,4 @@ declare function resolveRelationContent(config: CmssyClientConfig, entries: Rela
70
62
 
71
63
  declare function cmssySecretsMatch(a: string, b: string): Promise<boolean>;
72
64
 
73
- export { type BlockSchemaMap, FORM_QUERY, MODEL_DEFINITIONS_QUERY, MODEL_RECORDS_QUERY, RECORDS_BY_IDS_QUERY, type RelationContentEntry, SITE_CONFIG_QUERY, SUBMIT_FORM_MUTATION, asBucket, blockPageOf, buildBlockContext, cachedWorkspaceId, clearWorkspaceIdCache, cmssySecretsMatch, collectFormIds, fetchSiteConfig, getBlockContentForLanguage, normalizeRelationContent, resolveForms, resolveRelationContent, resolveWorkspaceId };
65
+ export { type BlockSchemaMap, FORM_QUERY, MODEL_DEFINITIONS_QUERY, MODEL_RECORDS_QUERY, RECORDS_BY_IDS_QUERY, type RelationContentEntry, SITE_CONFIG_QUERY, SUBMIT_FORM_MUTATION, asBucket, buildBlockContext, cachedWorkspaceId, clearWorkspaceIdCache, cmssySecretsMatch, collectFormIds, fetchSiteConfig, getBlockContentForLanguage, normalizeRelationContent, resolveForms, resolveRelationContent, resolveWorkspaceId };
@@ -1,5 +1,5 @@
1
1
  export { 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';
2
- import { CmssyPageData, CmssyBlockPage, CmssyFormDefinition, BuildBlockContextExtra, CmssyBlockContext, CmssyClientConfig, CmssySiteConfig, RawBlock, FieldDefinition } from '@cmssy/types';
2
+ import { CmssyFormDefinition, BuildBlockContextExtra, CmssyBlockContext, CmssyClientConfig, CmssySiteConfig, RawBlock, FieldDefinition } from '@cmssy/types';
3
3
  export { CmssySiteLocales } from '@cmssy/types';
4
4
  import { G as GraphqlRequestOptions } from './locale-XintNd0n.js';
5
5
  export { C as CMSSY_LOCALE_HEADER, b as buildLocaleSwitchHref, a as localeForPath, c as localeForPathname, l as localizeHref, d as localizeHtmlLinks, s as splitCmssyLocale } from './locale-XintNd0n.js';
@@ -13,14 +13,6 @@ declare const MODEL_RECORDS_QUERY = "query PublicModelRecords($workspaceId: Stri
13
13
  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}";
14
14
  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}";
15
15
 
16
- /**
17
- * The identity half of a fetched page, for `context.page`.
18
- *
19
- * A page fetched by an older SDK - or by a consumer that builds `CmssyPageData`
20
- * itself - has no slug, and then a block gets no `page` at all rather than one
21
- * with a hole in it: `context.page ? … : …` is a question a block can answer.
22
- */
23
- declare function blockPageOf(page: CmssyPageData | null | undefined): CmssyBlockPage | undefined;
24
16
  declare function buildBlockContext(locale: string, defaultLocale: string, enabledLocales?: string[], isPreview?: boolean, forms?: Record<string, CmssyFormDefinition>, extra?: BuildBlockContextExtra): CmssyBlockContext;
25
17
 
26
18
  declare function getBlockContentForLanguage(content: unknown, locale: string, defaultLocale?: string, availableLocales?: string[]): Record<string, unknown>;
@@ -70,4 +62,4 @@ declare function resolveRelationContent(config: CmssyClientConfig, entries: Rela
70
62
 
71
63
  declare function cmssySecretsMatch(a: string, b: string): Promise<boolean>;
72
64
 
73
- export { type BlockSchemaMap, FORM_QUERY, MODEL_DEFINITIONS_QUERY, MODEL_RECORDS_QUERY, RECORDS_BY_IDS_QUERY, type RelationContentEntry, SITE_CONFIG_QUERY, SUBMIT_FORM_MUTATION, asBucket, blockPageOf, buildBlockContext, cachedWorkspaceId, clearWorkspaceIdCache, cmssySecretsMatch, collectFormIds, fetchSiteConfig, getBlockContentForLanguage, normalizeRelationContent, resolveForms, resolveRelationContent, resolveWorkspaceId };
65
+ export { type BlockSchemaMap, FORM_QUERY, MODEL_DEFINITIONS_QUERY, MODEL_RECORDS_QUERY, RECORDS_BY_IDS_QUERY, type RelationContentEntry, SITE_CONFIG_QUERY, SUBMIT_FORM_MUTATION, asBucket, buildBlockContext, cachedWorkspaceId, clearWorkspaceIdCache, cmssySecretsMatch, collectFormIds, fetchSiteConfig, getBlockContentForLanguage, normalizeRelationContent, resolveForms, resolveRelationContent, resolveWorkspaceId };
package/dist/internal.js CHANGED
@@ -817,14 +817,6 @@ function localizedPath(slug, locale, defaultLocale) {
817
817
  }
818
818
 
819
819
  // src/block-context.ts
820
- function blockPageOf(page) {
821
- if (!page?.slug) return void 0;
822
- return {
823
- id: page.id,
824
- slug: page.slug,
825
- pageType: page.pageType ?? null
826
- };
827
- }
828
820
  function buildBlockContext(locale, defaultLocale, enabledLocales, isPreview, forms, extra) {
829
821
  return {
830
822
  locale: {
@@ -836,7 +828,18 @@ function buildBlockContext(locale, defaultLocale, enabledLocales, isPreview, for
836
828
  forms,
837
829
  ...extra?.auth ? { auth: extra.auth } : {},
838
830
  ...extra?.workspace ? { workspace: extra.workspace } : {},
839
- ...extra?.page ? { page: extra.page } : {}
831
+ // Identity only, and only when the page has one. A page fetched by an older
832
+ // SDK has no slug, and then a block gets no `page` at all rather than one
833
+ // with a hole in it: "I don't know where I am" has to stay distinguishable
834
+ // from "I am at /".
835
+ ...extra?.page?.slug ? {
836
+ page: {
837
+ id: extra.page.id,
838
+ slug: extra.page.slug,
839
+ pageType: extra.page.pageType ?? null
840
+ }
841
+ } : {},
842
+ ...extra?.app ? { app: extra.app } : {}
840
843
  };
841
844
  }
842
845
 
@@ -935,4 +938,4 @@ function cmssyCspHeaders(options) {
935
938
  };
936
939
  }
937
940
 
938
- export { CMSSY_LOCALE_HEADER, FORM_QUERY, MODEL_DEFINITIONS_QUERY, MODEL_RECORDS_QUERY, RECORDS_BY_IDS_QUERY, SITE_CONFIG_QUERY, SUBMIT_FORM_MUTATION, asBucket, blockPageOf, buildBlockContext, buildLocaleSwitchHref, cachedWorkspaceId, clearWorkspaceIdCache, cmssyCspHeaders, cmssySecretsMatch, collectFormIds, fetchLayouts, fetchPage, fetchPageById, fetchPageMeta, fetchPages, fetchSiteConfig, getBlockContentForLanguage, isDevelopment, localeForPath, localeForPathname, localesFromSiteConfig, localizeHref, localizeHtmlLinks, localizedPath, normalizeRelationContent, normalizeSlug, resolveApiUrl, resolveForms, resolveInitialTarget, resolvePublicUrl, resolveRelationContent, resolveSiteLocales, resolveWorkspaceId, splitCmssyLocale, splitLocaleFromPath, toCspOrigin };
941
+ export { CMSSY_LOCALE_HEADER, FORM_QUERY, MODEL_DEFINITIONS_QUERY, MODEL_RECORDS_QUERY, RECORDS_BY_IDS_QUERY, SITE_CONFIG_QUERY, SUBMIT_FORM_MUTATION, asBucket, buildBlockContext, buildLocaleSwitchHref, cachedWorkspaceId, clearWorkspaceIdCache, cmssyCspHeaders, cmssySecretsMatch, collectFormIds, fetchLayouts, fetchPage, fetchPageById, fetchPageMeta, fetchPages, fetchSiteConfig, getBlockContentForLanguage, isDevelopment, localeForPath, localeForPathname, localesFromSiteConfig, localizeHref, localizeHtmlLinks, localizedPath, normalizeRelationContent, normalizeSlug, resolveApiUrl, resolveForms, resolveInitialTarget, resolvePublicUrl, resolveRelationContent, resolveSiteLocales, resolveWorkspaceId, splitCmssyLocale, splitLocaleFromPath, toCspOrigin };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cmssy/core",
3
- "version": "10.2.0",
3
+ "version": "10.3.0",
4
4
  "description": "Framework-agnostic cmssy gateway: GraphQL client, block/field system, editor protocol. No React, no Next.",
5
5
  "keywords": [
6
6
  "cmssy",
@@ -62,7 +62,7 @@
62
62
  "vitest": "^2.1.0"
63
63
  },
64
64
  "dependencies": {
65
- "@cmssy/types": "0.30.0",
65
+ "@cmssy/types": "0.31.0",
66
66
  "jose": "^6.2.3"
67
67
  },
68
68
  "scripts": {