@cmssy/core 19.32.0 → 19.33.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.cjs CHANGED
@@ -225,7 +225,7 @@ function documentText(document2) {
225
225
  }
226
226
 
227
227
  // src/version.ts
228
- var CMSSY_CORE_VERSION = "19.32.0" ;
228
+ var CMSSY_CORE_VERSION = "19.33.0" ;
229
229
  var CMSSY_USER_AGENT = `@cmssy/core/${CMSSY_CORE_VERSION}`;
230
230
 
231
231
  // src/data/http.ts
@@ -1166,6 +1166,7 @@ var fields = {
1166
1166
  media: (opts = {}) => build("media", opts),
1167
1167
  pageSelector: (opts = {}) => build("pageSelector", opts),
1168
1168
  repeater: (opts) => build("repeater", opts),
1169
+ object: (opts) => build("object", opts),
1169
1170
  relation: (opts) => {
1170
1171
  const { model, mode, ...rest } = opts;
1171
1172
  return build("relation", {
package/dist/index.d.cts CHANGED
@@ -261,7 +261,7 @@ declare function maintenanceRefusal(error: unknown): CmssyMaintenanceRefusal | n
261
261
  type Declared<O> = O extends {
262
262
  required: true;
263
263
  } ? true : false;
264
- type BaseFieldOptions = Pick<FieldOptions, "label" | "defaultValue" | "helperText" | "required" | "placeholder" | "tab" | "localized"> & {
264
+ type BaseFieldOptions = Pick<FieldOptions, "label" | "defaultValue" | "helperText" | "required" | "placeholder" | "tab" | "localized" | "showWhen"> & {
265
265
  validation?: FieldValidation;
266
266
  };
267
267
  type ItemCountOptions = Pick<FieldOptions, "minItems" | "maxItems">;
@@ -270,6 +270,7 @@ type MultiselectFieldOptions = ChoiceFieldOptions & ItemCountOptions;
270
270
  type MediaFieldOptions = BaseFieldOptions & Pick<FieldOptions, "multiple" | "acceptedTypes" | "accept" | "maxSize" | "aspectRatio" | "aspectRatios">;
271
271
  type PageSelectorFieldOptions = BaseFieldOptions & Pick<FieldOptions, "multiple" | "pageType">;
272
272
  type RepeaterFieldOptions = BaseFieldOptions & Pick<FieldOptions, "itemSchema" | "minItems" | "maxItems" | "itemLabel" | "addButtonLabel" | "collapsible">;
273
+ type ObjectFieldOptions = BaseFieldOptions & Required<Pick<FieldOptions, "itemSchema">>;
273
274
  type TableFieldOptions = BaseFieldOptions & Pick<FieldOptions, "maxColumns">;
274
275
  type RelationFieldOptions = BaseFieldOptions & ItemCountOptions & {
275
276
  model: string;
@@ -296,6 +297,9 @@ type MediaValue<O> = ResolvedMediaValue<O extends {
296
297
  type RepeaterValue<O> = O extends {
297
298
  itemSchema: infer Schema extends BlockPropsSchema;
298
299
  } ? InferBlockContent<Schema>[] : Record<string, unknown>[];
300
+ type ObjectValue<O> = O extends {
301
+ itemSchema: infer Schema extends BlockPropsSchema;
302
+ } ? InferBlockContent<Schema> : Record<string, unknown>;
299
303
  type RelationValue<O> = O extends {
300
304
  mode: "all";
301
305
  } | {
@@ -331,6 +335,7 @@ declare const fields: {
331
335
  media: <const O extends MediaOnly<O>>(opts?: O) => TypedField<MediaValue<O>, Declared<O>>;
332
336
  pageSelector: <const O extends Only<O, PageSelectorFieldOptions, "pageSelector">>(opts?: O) => TypedField<PageSelectorValue<O>, Declared<O>>;
333
337
  repeater: <const O extends Only<O, RepeaterFieldOptions, "repeater">>(opts: O) => TypedField<RepeaterValue<O>, Declared<O>>;
338
+ object: <const O extends Only<O, ObjectFieldOptions, "object">>(opts: O) => TypedField<ObjectValue<O>, Declared<O>>;
334
339
  relation: <const O extends Only<O, RelationFieldOptions, "relation">>(opts: O) => TypedField<RelationValue<O>, Declared<O>>;
335
340
  };
336
341
 
package/dist/index.d.ts CHANGED
@@ -261,7 +261,7 @@ declare function maintenanceRefusal(error: unknown): CmssyMaintenanceRefusal | n
261
261
  type Declared<O> = O extends {
262
262
  required: true;
263
263
  } ? true : false;
264
- type BaseFieldOptions = Pick<FieldOptions, "label" | "defaultValue" | "helperText" | "required" | "placeholder" | "tab" | "localized"> & {
264
+ type BaseFieldOptions = Pick<FieldOptions, "label" | "defaultValue" | "helperText" | "required" | "placeholder" | "tab" | "localized" | "showWhen"> & {
265
265
  validation?: FieldValidation;
266
266
  };
267
267
  type ItemCountOptions = Pick<FieldOptions, "minItems" | "maxItems">;
@@ -270,6 +270,7 @@ type MultiselectFieldOptions = ChoiceFieldOptions & ItemCountOptions;
270
270
  type MediaFieldOptions = BaseFieldOptions & Pick<FieldOptions, "multiple" | "acceptedTypes" | "accept" | "maxSize" | "aspectRatio" | "aspectRatios">;
271
271
  type PageSelectorFieldOptions = BaseFieldOptions & Pick<FieldOptions, "multiple" | "pageType">;
272
272
  type RepeaterFieldOptions = BaseFieldOptions & Pick<FieldOptions, "itemSchema" | "minItems" | "maxItems" | "itemLabel" | "addButtonLabel" | "collapsible">;
273
+ type ObjectFieldOptions = BaseFieldOptions & Required<Pick<FieldOptions, "itemSchema">>;
273
274
  type TableFieldOptions = BaseFieldOptions & Pick<FieldOptions, "maxColumns">;
274
275
  type RelationFieldOptions = BaseFieldOptions & ItemCountOptions & {
275
276
  model: string;
@@ -296,6 +297,9 @@ type MediaValue<O> = ResolvedMediaValue<O extends {
296
297
  type RepeaterValue<O> = O extends {
297
298
  itemSchema: infer Schema extends BlockPropsSchema;
298
299
  } ? InferBlockContent<Schema>[] : Record<string, unknown>[];
300
+ type ObjectValue<O> = O extends {
301
+ itemSchema: infer Schema extends BlockPropsSchema;
302
+ } ? InferBlockContent<Schema> : Record<string, unknown>;
299
303
  type RelationValue<O> = O extends {
300
304
  mode: "all";
301
305
  } | {
@@ -331,6 +335,7 @@ declare const fields: {
331
335
  media: <const O extends MediaOnly<O>>(opts?: O) => TypedField<MediaValue<O>, Declared<O>>;
332
336
  pageSelector: <const O extends Only<O, PageSelectorFieldOptions, "pageSelector">>(opts?: O) => TypedField<PageSelectorValue<O>, Declared<O>>;
333
337
  repeater: <const O extends Only<O, RepeaterFieldOptions, "repeater">>(opts: O) => TypedField<RepeaterValue<O>, Declared<O>>;
338
+ object: <const O extends Only<O, ObjectFieldOptions, "object">>(opts: O) => TypedField<ObjectValue<O>, Declared<O>>;
334
339
  relation: <const O extends Only<O, RelationFieldOptions, "relation">>(opts: O) => TypedField<RelationValue<O>, Declared<O>>;
335
340
  };
336
341
 
package/dist/index.js CHANGED
@@ -224,7 +224,7 @@ function documentText(document2) {
224
224
  }
225
225
 
226
226
  // src/version.ts
227
- var CMSSY_CORE_VERSION = "19.32.0" ;
227
+ var CMSSY_CORE_VERSION = "19.33.0" ;
228
228
  var CMSSY_USER_AGENT = `@cmssy/core/${CMSSY_CORE_VERSION}`;
229
229
 
230
230
  // src/data/http.ts
@@ -1165,6 +1165,7 @@ var fields = {
1165
1165
  media: (opts = {}) => build("media", opts),
1166
1166
  pageSelector: (opts = {}) => build("pageSelector", opts),
1167
1167
  repeater: (opts) => build("repeater", opts),
1168
+ object: (opts) => build("object", opts),
1168
1169
  relation: (opts) => {
1169
1170
  const { model, mode, ...rest } = opts;
1170
1171
  return build("relation", {
@@ -154,7 +154,7 @@ function documentText(document) {
154
154
  }
155
155
 
156
156
  // src/version.ts
157
- var CMSSY_CORE_VERSION = "19.32.0" ;
157
+ var CMSSY_CORE_VERSION = "19.33.0" ;
158
158
  var CMSSY_USER_AGENT = `@cmssy/core/${CMSSY_CORE_VERSION}`;
159
159
 
160
160
  // src/data/http.ts
@@ -152,7 +152,7 @@ function documentText(document) {
152
152
  }
153
153
 
154
154
  // src/version.ts
155
- var CMSSY_CORE_VERSION = "19.32.0" ;
155
+ var CMSSY_CORE_VERSION = "19.33.0" ;
156
156
  var CMSSY_USER_AGENT = `@cmssy/core/${CMSSY_CORE_VERSION}`;
157
157
 
158
158
  // src/data/http.ts
package/dist/internal.cjs CHANGED
@@ -154,7 +154,7 @@ function documentText(document2) {
154
154
  }
155
155
 
156
156
  // src/version.ts
157
- var CMSSY_CORE_VERSION = "19.32.0" ;
157
+ var CMSSY_CORE_VERSION = "19.33.0" ;
158
158
  var CMSSY_USER_AGENT = `@cmssy/core/${CMSSY_CORE_VERSION}`;
159
159
 
160
160
  // src/data/http.ts
@@ -844,6 +844,15 @@ function walkBlockFields(values, schema, visit, options = {}, path = []) {
844
844
  });
845
845
  continue;
846
846
  }
847
+ if (field.type === "object") {
848
+ const itemSchema = field.itemSchema;
849
+ const stored = values[key];
850
+ if (!itemSchema || !isRecord(stored)) continue;
851
+ const group = options.copyRows ? { ...stored } : stored;
852
+ if (options.copyRows) values[key] = group;
853
+ walkBlockFields(group, itemSchema, visit, options, [...path, key]);
854
+ continue;
855
+ }
847
856
  visit(values, key, field, path);
848
857
  }
849
858
  }
@@ -1272,6 +1281,31 @@ function buildBlockContext(locale, defaultLocale, enabledLocales, isPreview, for
1272
1281
  };
1273
1282
  }
1274
1283
 
1284
+ // src/show-when-targets.ts
1285
+ function unreachableShowWhenTargets(blockType, schema, path = []) {
1286
+ return Object.entries(schema).flatMap(([key, field]) => {
1287
+ const at = [...path, key].join(".");
1288
+ const own = field.showWhen ? unreachable(schema, key, field, path.length === 0) : null;
1289
+ const problems = own ? [
1290
+ `cmssy: block "${blockType}" field "${at}" has showWhen on ${JSON.stringify(field.showWhen?.field)}, ${own}`
1291
+ ] : [];
1292
+ const nested = field.itemSchema ? unreachableShowWhenTargets(blockType, field.itemSchema, [...path, key]) : [];
1293
+ return [...problems, ...nested];
1294
+ });
1295
+ }
1296
+ function unreachable(schema, key, field, topLevel) {
1297
+ const target = field.showWhen?.field;
1298
+ if (typeof target !== "string" || target === key) {
1299
+ return "which is not a field next to it";
1300
+ }
1301
+ const sibling = Object.hasOwn(schema, target) ? schema[target] : void 0;
1302
+ if (!sibling) return "which is not a field next to it";
1303
+ if (topLevel && bucketOf(sibling) !== bucketOf(field)) {
1304
+ return `which is on the ${bucketOf(sibling)} tab, not the ${bucketOf(field)} tab`;
1305
+ }
1306
+ return null;
1307
+ }
1308
+
1275
1309
  // src/bridge/messages.ts
1276
1310
  function normalizeOrigin(origin) {
1277
1311
  const trimmed = origin.trim();
@@ -1519,3 +1553,4 @@ exports.resolveWorkspaceId = resolveWorkspaceId;
1519
1553
  exports.splitCmssyLocale = splitCmssyLocale;
1520
1554
  exports.splitLocaleFromPath = splitLocaleFromPath;
1521
1555
  exports.toCspOrigin = toCspOrigin;
1556
+ exports.unreachableShowWhenTargets = unreachableShowWhenTargets;
@@ -46,6 +46,8 @@ declare function createCmssyLayoutStore(): CmssyLayoutStore;
46
46
  declare function layoutStoreKey(config: CmssyClientConfig, pageSlug: string, previewSecret: string | undefined): string;
47
47
  declare function readThroughLayoutStore(store: CmssyLayoutStore | undefined, key: string, load: () => Promise<CmssyLayoutGroup[]>): Promise<CmssyLayoutGroup[]>;
48
48
 
49
+ declare function unreachableShowWhenTargets(blockType: string, schema: Record<string, FieldDefinition>, path?: readonly string[]): string[];
50
+
49
51
  declare function cmssySecretsMatch(a: string, b: string): Promise<boolean>;
50
52
 
51
53
  interface CmssyDeliveryOperation {
@@ -54,4 +56,4 @@ interface CmssyDeliveryOperation {
54
56
  }
55
57
  declare const CMSSY_DELIVERY_OPERATIONS: readonly CmssyDeliveryOperation[];
56
58
 
57
- export { type BlockSchemaMap, CMSSY_DELIVERY_OPERATIONS, type CmssyLayoutStore, type RelationContentEntry, asBucket, buildBlockContext, clearWorkspaceIdCache, cmssySecretsMatch, collectFormIds, createCmssyLayoutStore, fetchSiteConfig, getBlockContentForLanguage, layoutStoreKey, normalizeBlockContent, readThroughLayoutStore, resolveForms, resolveRelationContent, resolveWorkspaceId };
59
+ export { type BlockSchemaMap, CMSSY_DELIVERY_OPERATIONS, type CmssyLayoutStore, type RelationContentEntry, asBucket, buildBlockContext, clearWorkspaceIdCache, cmssySecretsMatch, collectFormIds, createCmssyLayoutStore, fetchSiteConfig, getBlockContentForLanguage, layoutStoreKey, normalizeBlockContent, readThroughLayoutStore, resolveForms, resolveRelationContent, resolveWorkspaceId, unreachableShowWhenTargets };
@@ -46,6 +46,8 @@ declare function createCmssyLayoutStore(): CmssyLayoutStore;
46
46
  declare function layoutStoreKey(config: CmssyClientConfig, pageSlug: string, previewSecret: string | undefined): string;
47
47
  declare function readThroughLayoutStore(store: CmssyLayoutStore | undefined, key: string, load: () => Promise<CmssyLayoutGroup[]>): Promise<CmssyLayoutGroup[]>;
48
48
 
49
+ declare function unreachableShowWhenTargets(blockType: string, schema: Record<string, FieldDefinition>, path?: readonly string[]): string[];
50
+
49
51
  declare function cmssySecretsMatch(a: string, b: string): Promise<boolean>;
50
52
 
51
53
  interface CmssyDeliveryOperation {
@@ -54,4 +56,4 @@ interface CmssyDeliveryOperation {
54
56
  }
55
57
  declare const CMSSY_DELIVERY_OPERATIONS: readonly CmssyDeliveryOperation[];
56
58
 
57
- export { type BlockSchemaMap, CMSSY_DELIVERY_OPERATIONS, type CmssyLayoutStore, type RelationContentEntry, asBucket, buildBlockContext, clearWorkspaceIdCache, cmssySecretsMatch, collectFormIds, createCmssyLayoutStore, fetchSiteConfig, getBlockContentForLanguage, layoutStoreKey, normalizeBlockContent, readThroughLayoutStore, resolveForms, resolveRelationContent, resolveWorkspaceId };
59
+ export { type BlockSchemaMap, CMSSY_DELIVERY_OPERATIONS, type CmssyLayoutStore, type RelationContentEntry, asBucket, buildBlockContext, clearWorkspaceIdCache, cmssySecretsMatch, collectFormIds, createCmssyLayoutStore, fetchSiteConfig, getBlockContentForLanguage, layoutStoreKey, normalizeBlockContent, readThroughLayoutStore, resolveForms, resolveRelationContent, resolveWorkspaceId, unreachableShowWhenTargets };
package/dist/internal.js CHANGED
@@ -152,7 +152,7 @@ function documentText(document2) {
152
152
  }
153
153
 
154
154
  // src/version.ts
155
- var CMSSY_CORE_VERSION = "19.32.0" ;
155
+ var CMSSY_CORE_VERSION = "19.33.0" ;
156
156
  var CMSSY_USER_AGENT = `@cmssy/core/${CMSSY_CORE_VERSION}`;
157
157
 
158
158
  // src/data/http.ts
@@ -842,6 +842,15 @@ function walkBlockFields(values, schema, visit, options = {}, path = []) {
842
842
  });
843
843
  continue;
844
844
  }
845
+ if (field.type === "object") {
846
+ const itemSchema = field.itemSchema;
847
+ const stored = values[key];
848
+ if (!itemSchema || !isRecord(stored)) continue;
849
+ const group = options.copyRows ? { ...stored } : stored;
850
+ if (options.copyRows) values[key] = group;
851
+ walkBlockFields(group, itemSchema, visit, options, [...path, key]);
852
+ continue;
853
+ }
845
854
  visit(values, key, field, path);
846
855
  }
847
856
  }
@@ -1270,6 +1279,31 @@ function buildBlockContext(locale, defaultLocale, enabledLocales, isPreview, for
1270
1279
  };
1271
1280
  }
1272
1281
 
1282
+ // src/show-when-targets.ts
1283
+ function unreachableShowWhenTargets(blockType, schema, path = []) {
1284
+ return Object.entries(schema).flatMap(([key, field]) => {
1285
+ const at = [...path, key].join(".");
1286
+ const own = field.showWhen ? unreachable(schema, key, field, path.length === 0) : null;
1287
+ const problems = own ? [
1288
+ `cmssy: block "${blockType}" field "${at}" has showWhen on ${JSON.stringify(field.showWhen?.field)}, ${own}`
1289
+ ] : [];
1290
+ const nested = field.itemSchema ? unreachableShowWhenTargets(blockType, field.itemSchema, [...path, key]) : [];
1291
+ return [...problems, ...nested];
1292
+ });
1293
+ }
1294
+ function unreachable(schema, key, field, topLevel) {
1295
+ const target = field.showWhen?.field;
1296
+ if (typeof target !== "string" || target === key) {
1297
+ return "which is not a field next to it";
1298
+ }
1299
+ const sibling = Object.hasOwn(schema, target) ? schema[target] : void 0;
1300
+ if (!sibling) return "which is not a field next to it";
1301
+ if (topLevel && bucketOf(sibling) !== bucketOf(field)) {
1302
+ return `which is on the ${bucketOf(sibling)} tab, not the ${bucketOf(field)} tab`;
1303
+ }
1304
+ return null;
1305
+ }
1306
+
1273
1307
  // src/bridge/messages.ts
1274
1308
  function normalizeOrigin(origin) {
1275
1309
  const trimmed = origin.trim();
@@ -1478,4 +1512,4 @@ function layoutRegionIds(layout) {
1478
1512
  return (layout?.regions ?? DEFAULT_LAYOUT_REGIONS).map((region) => region.id);
1479
1513
  }
1480
1514
 
1481
- export { CMSSY_DELIVERY_OPERATIONS, CMSSY_LOCALE_HEADER, FORM_QUERY, MODEL_DEFINITIONS_QUERY, MODEL_RECORDS_QUERY, SITE_CONFIG_QUERY, SUBMIT_FORM_MUTATION, asBucket, buildBlockContext, clearWorkspaceIdCache, cmssyCspHeaders, cmssySecretsMatch, collectFormIds, createCmssyLayoutStore, fetchLayouts, fetchPage, fetchPageById, fetchPageMeta, fetchPages, fetchSiteConfig, getBlockContentForLanguage, isDevelopment, layoutRegionIds, layoutStoreKey, localeForPath, localeForPathname, localizeHref, localizedPath, normalizeBlockContent, readThroughLayoutStore, resolveApiUrl, resolveForms, resolveInitialTarget, resolveRelationContent, resolveSiteLocales, resolveWorkspaceId, splitCmssyLocale, splitLocaleFromPath, toCspOrigin };
1515
+ export { CMSSY_DELIVERY_OPERATIONS, CMSSY_LOCALE_HEADER, FORM_QUERY, MODEL_DEFINITIONS_QUERY, MODEL_RECORDS_QUERY, SITE_CONFIG_QUERY, SUBMIT_FORM_MUTATION, asBucket, buildBlockContext, clearWorkspaceIdCache, cmssyCspHeaders, cmssySecretsMatch, collectFormIds, createCmssyLayoutStore, fetchLayouts, fetchPage, fetchPageById, fetchPageMeta, fetchPages, fetchSiteConfig, getBlockContentForLanguage, isDevelopment, layoutRegionIds, layoutStoreKey, localeForPath, localeForPathname, localizeHref, localizedPath, normalizeBlockContent, readThroughLayoutStore, resolveApiUrl, resolveForms, resolveInitialTarget, resolveRelationContent, resolveSiteLocales, resolveWorkspaceId, splitCmssyLocale, splitLocaleFromPath, toCspOrigin, unreachableShowWhenTargets };
@@ -152,7 +152,7 @@ function documentText(document) {
152
152
  }
153
153
 
154
154
  // src/version.ts
155
- var CMSSY_CORE_VERSION = "19.32.0" ;
155
+ var CMSSY_CORE_VERSION = "19.33.0" ;
156
156
  var CMSSY_USER_AGENT = `@cmssy/core/${CMSSY_CORE_VERSION}`;
157
157
 
158
158
  // src/content/content-client.ts
package/dist/preflight.js CHANGED
@@ -150,7 +150,7 @@ function documentText(document) {
150
150
  }
151
151
 
152
152
  // src/version.ts
153
- var CMSSY_CORE_VERSION = "19.32.0" ;
153
+ var CMSSY_CORE_VERSION = "19.33.0" ;
154
154
  var CMSSY_USER_AGENT = `@cmssy/core/${CMSSY_CORE_VERSION}`;
155
155
 
156
156
  // src/content/content-client.ts
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cmssy/core",
3
- "version": "19.32.0",
3
+ "version": "19.33.0",
4
4
  "engines": {
5
5
  "node": ">=20"
6
6
  },
@@ -90,7 +90,7 @@
90
90
  "vitest": "^2.1.0"
91
91
  },
92
92
  "dependencies": {
93
- "@cmssy/types": "0.75.1",
93
+ "@cmssy/types": "0.76.0",
94
94
  "jose": "^6.2.3"
95
95
  },
96
96
  "scripts": {