@makehq/forman-schema 1.6.0 → 1.7.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
@@ -238,6 +238,7 @@ var FORMAN_TYPE_MAP = {
238
238
  collection: "object",
239
239
  dynamicCollection: "object",
240
240
  text: "string",
241
+ editor: "string",
241
242
  number: "number",
242
243
  boolean: "boolean",
243
244
  date: "string",
@@ -327,6 +328,12 @@ function handleCollectionType(field, result, context) {
327
328
  required: []
328
329
  });
329
330
  function addField(subField, tail) {
331
+ if (typeof subField === "string") {
332
+ const value = { $ref: appendQueryString(subField, context.domain, tail || context.tail) };
333
+ result.allOf ||= [];
334
+ result.allOf.push(value);
335
+ return;
336
+ }
330
337
  if (isVisualType(subField.type)) {
331
338
  return;
332
339
  }
@@ -499,9 +506,7 @@ function handleSelectType(field, result, context) {
499
506
  }
500
507
  }
501
508
  if (nested && domain && domain !== context.domain) {
502
- if (typeof nested === "string" || nestedContainsStrings) {
503
- throw new SchemaConversionError("Dynamic nested fields with domain change are not supported.");
504
- }
509
+ const normalizedNested = typeof nested === "string" ? [nested] : nested;
505
510
  let root = context.roots[domain];
506
511
  if (!root) {
507
512
  const buffer = [];
@@ -512,7 +517,7 @@ function handleSelectType(field, result, context) {
512
517
  }
513
518
  };
514
519
  }
515
- root.addFields(nested, [...context.tail, field.name]);
520
+ root.addFields(normalizedNested, [...context.tail, field.name]);
516
521
  } else if (nested) {
517
522
  Object.defineProperty(result, "x-nested", {
518
523
  configurable: true,
package/dist/index.d.cts CHANGED
@@ -146,7 +146,7 @@ type FormanSchemaNested = (FormanSchemaField | string)[] | string | FormanSchema
146
146
  */
147
147
  type FormanSchemaExtendedNested = {
148
148
  /** Store for the nested fields */
149
- store: FormanSchemaField[] | string;
149
+ store: (FormanSchemaField | string)[] | string;
150
150
  /** Domain for the nested fields */
151
151
  domain?: string;
152
152
  };
package/dist/index.d.ts CHANGED
@@ -146,7 +146,7 @@ type FormanSchemaNested = (FormanSchemaField | string)[] | string | FormanSchema
146
146
  */
147
147
  type FormanSchemaExtendedNested = {
148
148
  /** Store for the nested fields */
149
- store: FormanSchemaField[] | string;
149
+ store: (FormanSchemaField | string)[] | string;
150
150
  /** Domain for the nested fields */
151
151
  domain?: string;
152
152
  };
package/dist/index.js CHANGED
@@ -209,6 +209,7 @@ var FORMAN_TYPE_MAP = {
209
209
  collection: "object",
210
210
  dynamicCollection: "object",
211
211
  text: "string",
212
+ editor: "string",
212
213
  number: "number",
213
214
  boolean: "boolean",
214
215
  date: "string",
@@ -298,6 +299,12 @@ function handleCollectionType(field, result, context) {
298
299
  required: []
299
300
  });
300
301
  function addField(subField, tail) {
302
+ if (typeof subField === "string") {
303
+ const value = { $ref: appendQueryString(subField, context.domain, tail || context.tail) };
304
+ result.allOf ||= [];
305
+ result.allOf.push(value);
306
+ return;
307
+ }
301
308
  if (isVisualType(subField.type)) {
302
309
  return;
303
310
  }
@@ -470,9 +477,7 @@ function handleSelectType(field, result, context) {
470
477
  }
471
478
  }
472
479
  if (nested && domain && domain !== context.domain) {
473
- if (typeof nested === "string" || nestedContainsStrings) {
474
- throw new SchemaConversionError("Dynamic nested fields with domain change are not supported.");
475
- }
480
+ const normalizedNested = typeof nested === "string" ? [nested] : nested;
476
481
  let root = context.roots[domain];
477
482
  if (!root) {
478
483
  const buffer = [];
@@ -483,7 +488,7 @@ function handleSelectType(field, result, context) {
483
488
  }
484
489
  };
485
490
  }
486
- root.addFields(nested, [...context.tail, field.name]);
491
+ root.addFields(normalizedNested, [...context.tail, field.name]);
487
492
  } else if (nested) {
488
493
  Object.defineProperty(result, "x-nested", {
489
494
  configurable: true,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@makehq/forman-schema",
3
- "version": "1.6.0",
3
+ "version": "1.7.0",
4
4
  "description": "Forman Schema Tools",
5
5
  "license": "MIT",
6
6
  "author": "Make",