@webiny/app-headless-cms-common 6.3.0 → 6.4.0-beta.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.
Files changed (82) hide show
  1. package/Fields/ErrorBoundary.js +29 -34
  2. package/Fields/ErrorBoundary.js.map +1 -1
  3. package/Fields/FieldElement.js +38 -61
  4. package/Fields/FieldElement.js.map +1 -1
  5. package/Fields/FieldElementError.js +13 -22
  6. package/Fields/FieldElementError.js.map +1 -1
  7. package/Fields/FieldRulesProvider.js +11 -17
  8. package/Fields/FieldRulesProvider.js.map +1 -1
  9. package/Fields/Fields.js +76 -139
  10. package/Fields/Fields.js.map +1 -1
  11. package/Fields/Label.js +7 -7
  12. package/Fields/Label.js.map +1 -1
  13. package/Fields/LayoutDescriptorCell.js +33 -40
  14. package/Fields/LayoutDescriptorCell.js.map +1 -1
  15. package/Fields/evaluateExpression.js +54 -94
  16. package/Fields/evaluateExpression.js.map +1 -1
  17. package/Fields/fieldOptions.js +56 -104
  18. package/Fields/fieldOptions.js.map +1 -1
  19. package/Fields/index.js +0 -2
  20. package/Fields/layoutFieldRenderers/AlertFieldRenderer.js +7 -10
  21. package/Fields/layoutFieldRenderers/AlertFieldRenderer.js.map +1 -1
  22. package/Fields/layoutFieldRenderers/SeparatorFieldRenderer.js +12 -15
  23. package/Fields/layoutFieldRenderers/SeparatorFieldRenderer.js.map +1 -1
  24. package/Fields/layoutFieldRenderers/TabsFieldRenderer.js +52 -63
  25. package/Fields/layoutFieldRenderers/TabsFieldRenderer.js.map +1 -1
  26. package/Fields/operatorOptions.js +115 -87
  27. package/Fields/operatorOptions.js.map +1 -1
  28. package/Fields/useBind.js +101 -107
  29. package/Fields/useBind.js.map +1 -1
  30. package/Fields/useFieldRules.js +79 -133
  31. package/Fields/useFieldRules.js.map +1 -1
  32. package/Fields/useRenderPlugins.js +3 -2
  33. package/Fields/useRenderPlugins.js.map +1 -1
  34. package/ModelFieldProvider/CanEditField.js +6 -9
  35. package/ModelFieldProvider/CanEditField.js.map +1 -1
  36. package/ModelFieldProvider/ModelFieldContext.js +15 -22
  37. package/ModelFieldProvider/ModelFieldContext.js.map +1 -1
  38. package/ModelFieldProvider/index.js +0 -2
  39. package/ModelFieldProvider/useModelField.js +15 -21
  40. package/ModelFieldProvider/useModelField.js.map +1 -1
  41. package/ModelProvider/ModelContext.js +11 -15
  42. package/ModelProvider/ModelContext.js.map +1 -1
  43. package/ModelProvider/index.js +0 -2
  44. package/ModelProvider/useModel.js +7 -11
  45. package/ModelProvider/useModel.js.map +1 -1
  46. package/constants.js +2 -1
  47. package/constants.js.map +1 -1
  48. package/createFieldsList.js +27 -49
  49. package/createFieldsList.js.map +1 -1
  50. package/createValidationContainer.js +13 -20
  51. package/createValidationContainer.js.map +1 -1
  52. package/createValidators.js +42 -47
  53. package/createValidators.js.map +1 -1
  54. package/entries.graphql.d.ts +11 -0
  55. package/entries.graphql.js +74 -164
  56. package/entries.graphql.js.map +1 -1
  57. package/exports/admin/cms/model.js +0 -2
  58. package/exports/admin/cms.d.ts +1 -1
  59. package/exports/admin/cms.js +0 -3
  60. package/getModelTitleFieldId.js +4 -5
  61. package/getModelTitleFieldId.js.map +1 -1
  62. package/index.js +0 -2
  63. package/normalizeIcon.js +8 -7
  64. package/normalizeIcon.js.map +1 -1
  65. package/package.json +11 -13
  66. package/prepareFormData.js +39 -61
  67. package/prepareFormData.js.map +1 -1
  68. package/types/index.d.ts +2 -0
  69. package/types/index.js +1 -41
  70. package/types/model.js +4 -27
  71. package/types/model.js.map +1 -1
  72. package/types/shared.js +0 -3
  73. package/types/validation.js +0 -3
  74. package/Fields/index.js.map +0 -1
  75. package/ModelFieldProvider/index.js.map +0 -1
  76. package/ModelProvider/index.js.map +0 -1
  77. package/exports/admin/cms/model.js.map +0 -1
  78. package/exports/admin/cms.js.map +0 -1
  79. package/index.js.map +0 -1
  80. package/types/index.js.map +0 -1
  81. package/types/shared.js.map +0 -1
  82. package/types/validation.js.map +0 -1
@@ -1,71 +1,49 @@
1
1
  import { plugins } from "@webiny/plugins";
2
- /**
3
- * This method builds transformer plugins only once.
4
- * Really no need in building more than once because at this point all plugins are registered.
5
- */
6
- let availableTransformerPlugins = undefined;
7
- const getAvailableTransformerPlugins = () => {
8
- if (availableTransformerPlugins) {
2
+ let availableTransformerPlugins;
3
+ const getAvailableTransformerPlugins = ()=>{
4
+ if (availableTransformerPlugins) return availableTransformerPlugins;
5
+ availableTransformerPlugins = plugins.byType("cms-field-value-transformer").reduce((transformers, pl)=>{
6
+ const fieldTypes = Array.isArray(pl.fieldType) ? pl.fieldType : [
7
+ pl.fieldType
8
+ ];
9
+ for (const fieldType of fieldTypes){
10
+ if (transformers[fieldType]) {
11
+ console.warn(`Transformer for field type "${fieldType}" is already defined. There cannot be more than one transformer.`);
12
+ continue;
13
+ }
14
+ transformers[fieldType] = pl;
15
+ }
16
+ return transformers;
17
+ }, {});
9
18
  return availableTransformerPlugins;
10
- }
11
- availableTransformerPlugins = plugins.byType("cms-field-value-transformer").reduce((transformers, pl) => {
12
- const fieldTypes = Array.isArray(pl.fieldType) ? pl.fieldType : [pl.fieldType];
13
- for (const fieldType of fieldTypes) {
14
- if (transformers[fieldType]) {
15
- console.warn(`Transformer for field type "${fieldType}" is already defined. There cannot be more than one transformer.`);
16
- continue;
17
- }
18
- transformers[fieldType] = pl;
19
- }
20
- return transformers;
21
- }, {});
22
- return availableTransformerPlugins;
23
19
  };
24
20
  let transformationRunner;
25
- const createTransformationRunner = () => {
26
- if (transformationRunner) {
21
+ const createTransformationRunner = ()=>{
22
+ if (transformationRunner) return transformationRunner;
23
+ const availablePlugins = getAvailableTransformerPlugins();
24
+ transformationRunner = (field, value)=>{
25
+ const transformer = availablePlugins[field.type];
26
+ if (!transformer) return value;
27
+ return transformer.transform(value, field);
28
+ };
27
29
  return transformationRunner;
28
- }
29
- const availablePlugins = getAvailableTransformerPlugins();
30
- transformationRunner = (field, value) => {
31
- const transformer = availablePlugins[field.type];
32
- if (!transformer) {
33
- return value;
34
- }
35
- return transformer.transform(value, field);
36
- };
37
- return transformationRunner;
38
30
  };
39
- export const prepareFormData = (input, fields) => {
40
- const runTransformation = createTransformationRunner();
41
- return fields.reduce((output, field) => {
42
- const inputValue = input[field.fieldId];
43
- const fieldId = field.fieldId;
44
- if (field.list) {
45
- const values = Array.isArray(inputValue) ? inputValue : undefined;
46
- if (!values) {
31
+ const prepareFormData = (input, fields)=>{
32
+ const runTransformation = createTransformationRunner();
33
+ return fields.reduce((output, field)=>{
34
+ const inputValue = input[field.fieldId];
35
+ const fieldId = field.fieldId;
36
+ if (field.list) {
37
+ const values = Array.isArray(inputValue) ? inputValue : void 0;
38
+ if (!values) return output;
39
+ if (1 === values.length && (null === values[0] || void 0 === values[0])) return output;
40
+ output[fieldId] = values.map((value)=>runTransformation(field, value));
41
+ return output;
42
+ }
43
+ output[fieldId] = runTransformation(field, inputValue);
47
44
  return output;
48
- }
49
- /**
50
- * We need to skip sending the values if there is only one item in the array, and it is a null or undefined value.
51
- *
52
- * In case there are more items in the array, and they are null / undefined,
53
- * we must not do anything because it means the user added new items into the array,
54
- * and they want to have it like that - or is a mistake by user - in that case they will then remove the extra item(s).
55
- */
56
- //
57
- else if (values.length === 1 && (values[0] === null || values[0] === undefined)) {
58
- return output;
59
- }
60
- output[fieldId] = values.map(value => runTransformation(field, value));
61
- return output;
62
- }
63
- /**
64
- * Regular values, single values.
65
- */
66
- output[fieldId] = runTransformation(field, inputValue);
67
- return output;
68
- }, {});
45
+ }, {});
69
46
  };
47
+ export { prepareFormData };
70
48
 
71
49
  //# sourceMappingURL=prepareFormData.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["plugins","availableTransformerPlugins","undefined","getAvailableTransformerPlugins","byType","reduce","transformers","pl","fieldTypes","Array","isArray","fieldType","console","warn","transformationRunner","createTransformationRunner","availablePlugins","field","value","transformer","type","transform","prepareFormData","input","fields","runTransformation","output","inputValue","fieldId","list","values","length","map"],"sources":["prepareFormData.ts"],"sourcesContent":["import type { CmsFieldValueTransformer, CmsModelField } from \"~/types/index.js\";\nimport { plugins } from \"@webiny/plugins\";\n\ninterface AvailableFieldTransformers {\n [fieldType: string]: CmsFieldValueTransformer;\n}\n\n/**\n * This method builds transformer plugins only once.\n * Really no need in building more than once because at this point all plugins are registered.\n */\nlet availableTransformerPlugins: AvailableFieldTransformers | undefined = undefined;\nconst getAvailableTransformerPlugins = (): AvailableFieldTransformers => {\n if (availableTransformerPlugins) {\n return availableTransformerPlugins;\n }\n availableTransformerPlugins = plugins\n .byType<CmsFieldValueTransformer>(\"cms-field-value-transformer\")\n .reduce<AvailableFieldTransformers>((transformers, pl) => {\n const fieldTypes = Array.isArray(pl.fieldType) ? pl.fieldType : [pl.fieldType];\n for (const fieldType of fieldTypes) {\n if (transformers[fieldType]) {\n console.warn(\n `Transformer for field type \"${fieldType}\" is already defined. There cannot be more than one transformer.`\n );\n continue;\n }\n transformers[fieldType] = pl;\n }\n return transformers;\n }, {});\n\n return availableTransformerPlugins;\n};\n\ninterface TransformationRunnerCallable {\n (field: CmsModelField, value: any): any;\n}\n\nlet transformationRunner: TransformationRunnerCallable;\nconst createTransformationRunner = (): TransformationRunnerCallable => {\n if (transformationRunner) {\n return transformationRunner;\n }\n const availablePlugins = getAvailableTransformerPlugins();\n\n transformationRunner = (field, value) => {\n const transformer = availablePlugins[field.type];\n if (!transformer) {\n return value;\n }\n return transformer.transform(value, field);\n };\n return transformationRunner;\n};\n\nexport const prepareFormData = <T extends Record<string, any>>(\n input: T,\n fields: CmsModelField[]\n): T => {\n const runTransformation = createTransformationRunner();\n\n return fields.reduce<Record<keyof T, any>>((output, field) => {\n const inputValue = input[field.fieldId];\n\n const fieldId: keyof T = field.fieldId;\n\n if (field.list) {\n const values = Array.isArray(inputValue) ? inputValue : undefined;\n if (!values) {\n return output;\n }\n /**\n * We need to skip sending the values if there is only one item in the array, and it is a null or undefined value.\n *\n * In case there are more items in the array, and they are null / undefined,\n * we must not do anything because it means the user added new items into the array,\n * and they want to have it like that - or is a mistake by user - in that case they will then remove the extra item(s).\n */\n //\n else if (values.length === 1 && (values[0] === null || values[0] === undefined)) {\n return output;\n }\n\n output[fieldId] = values.map(value => runTransformation(field, value));\n\n return output;\n }\n /**\n * Regular values, single values.\n */\n output[fieldId] = runTransformation(field, inputValue);\n\n return output;\n }, {} as T);\n};\n"],"mappings":"AACA,SAASA,OAAO,QAAQ,iBAAiB;AAMzC;AACA;AACA;AACA;AACA,IAAIC,2BAAmE,GAAGC,SAAS;AACnF,MAAMC,8BAA8B,GAAGA,CAAA,KAAkC;EACrE,IAAIF,2BAA2B,EAAE;IAC7B,OAAOA,2BAA2B;EACtC;EACAA,2BAA2B,GAAGD,OAAO,CAChCI,MAAM,CAA2B,6BAA6B,CAAC,CAC/DC,MAAM,CAA6B,CAACC,YAAY,EAAEC,EAAE,KAAK;IACtD,MAAMC,UAAU,GAAGC,KAAK,CAACC,OAAO,CAACH,EAAE,CAACI,SAAS,CAAC,GAAGJ,EAAE,CAACI,SAAS,GAAG,CAACJ,EAAE,CAACI,SAAS,CAAC;IAC9E,KAAK,MAAMA,SAAS,IAAIH,UAAU,EAAE;MAChC,IAAIF,YAAY,CAACK,SAAS,CAAC,EAAE;QACzBC,OAAO,CAACC,IAAI,CACR,+BAA+BF,SAAS,kEAC5C,CAAC;QACD;MACJ;MACAL,YAAY,CAACK,SAAS,CAAC,GAAGJ,EAAE;IAChC;IACA,OAAOD,YAAY;EACvB,CAAC,EAAE,CAAC,CAAC,CAAC;EAEV,OAAOL,2BAA2B;AACtC,CAAC;AAMD,IAAIa,oBAAkD;AACtD,MAAMC,0BAA0B,GAAGA,CAAA,KAAoC;EACnE,IAAID,oBAAoB,EAAE;IACtB,OAAOA,oBAAoB;EAC/B;EACA,MAAME,gBAAgB,GAAGb,8BAA8B,CAAC,CAAC;EAEzDW,oBAAoB,GAAGA,CAACG,KAAK,EAAEC,KAAK,KAAK;IACrC,MAAMC,WAAW,GAAGH,gBAAgB,CAACC,KAAK,CAACG,IAAI,CAAC;IAChD,IAAI,CAACD,WAAW,EAAE;MACd,OAAOD,KAAK;IAChB;IACA,OAAOC,WAAW,CAACE,SAAS,CAACH,KAAK,EAAED,KAAK,CAAC;EAC9C,CAAC;EACD,OAAOH,oBAAoB;AAC/B,CAAC;AAED,OAAO,MAAMQ,eAAe,GAAGA,CAC3BC,KAAQ,EACRC,MAAuB,KACnB;EACJ,MAAMC,iBAAiB,GAAGV,0BAA0B,CAAC,CAAC;EAEtD,OAAOS,MAAM,CAACnB,MAAM,CAAuB,CAACqB,MAAM,EAAET,KAAK,KAAK;IAC1D,MAAMU,UAAU,GAAGJ,KAAK,CAACN,KAAK,CAACW,OAAO,CAAC;IAEvC,MAAMA,OAAgB,GAAGX,KAAK,CAACW,OAAO;IAEtC,IAAIX,KAAK,CAACY,IAAI,EAAE;MACZ,MAAMC,MAAM,GAAGrB,KAAK,CAACC,OAAO,CAACiB,UAAU,CAAC,GAAGA,UAAU,GAAGzB,SAAS;MACjE,IAAI,CAAC4B,MAAM,EAAE;QACT,OAAOJ,MAAM;MACjB;MACA;AACZ;AACA;AACA;AACA;AACA;AACA;MACY;MAAA,KACK,IAAII,MAAM,CAACC,MAAM,KAAK,CAAC,KAAKD,MAAM,CAAC,CAAC,CAAC,KAAK,IAAI,IAAIA,MAAM,CAAC,CAAC,CAAC,KAAK5B,SAAS,CAAC,EAAE;QAC7E,OAAOwB,MAAM;MACjB;MAEAA,MAAM,CAACE,OAAO,CAAC,GAAGE,MAAM,CAACE,GAAG,CAACd,KAAK,IAAIO,iBAAiB,CAACR,KAAK,EAAEC,KAAK,CAAC,CAAC;MAEtE,OAAOQ,MAAM;IACjB;IACA;AACR;AACA;IACQA,MAAM,CAACE,OAAO,CAAC,GAAGH,iBAAiB,CAACR,KAAK,EAAEU,UAAU,CAAC;IAEtD,OAAOD,MAAM;EACjB,CAAC,EAAE,CAAC,CAAM,CAAC;AACf,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"prepareFormData.js","sources":["../src/prepareFormData.ts"],"sourcesContent":["import type { CmsFieldValueTransformer, CmsModelField } from \"~/types/index.js\";\nimport { plugins } from \"@webiny/plugins\";\n\ninterface AvailableFieldTransformers {\n [fieldType: string]: CmsFieldValueTransformer;\n}\n\n/**\n * This method builds transformer plugins only once.\n * Really no need in building more than once because at this point all plugins are registered.\n */\nlet availableTransformerPlugins: AvailableFieldTransformers | undefined = undefined;\nconst getAvailableTransformerPlugins = (): AvailableFieldTransformers => {\n if (availableTransformerPlugins) {\n return availableTransformerPlugins;\n }\n availableTransformerPlugins = plugins\n .byType<CmsFieldValueTransformer>(\"cms-field-value-transformer\")\n .reduce<AvailableFieldTransformers>((transformers, pl) => {\n const fieldTypes = Array.isArray(pl.fieldType) ? pl.fieldType : [pl.fieldType];\n for (const fieldType of fieldTypes) {\n if (transformers[fieldType]) {\n console.warn(\n `Transformer for field type \"${fieldType}\" is already defined. There cannot be more than one transformer.`\n );\n continue;\n }\n transformers[fieldType] = pl;\n }\n return transformers;\n }, {});\n\n return availableTransformerPlugins;\n};\n\ninterface TransformationRunnerCallable {\n (field: CmsModelField, value: any): any;\n}\n\nlet transformationRunner: TransformationRunnerCallable;\nconst createTransformationRunner = (): TransformationRunnerCallable => {\n if (transformationRunner) {\n return transformationRunner;\n }\n const availablePlugins = getAvailableTransformerPlugins();\n\n transformationRunner = (field, value) => {\n const transformer = availablePlugins[field.type];\n if (!transformer) {\n return value;\n }\n return transformer.transform(value, field);\n };\n return transformationRunner;\n};\n\nexport const prepareFormData = <T extends Record<string, any>>(\n input: T,\n fields: CmsModelField[]\n): T => {\n const runTransformation = createTransformationRunner();\n\n return fields.reduce<Record<keyof T, any>>((output, field) => {\n const inputValue = input[field.fieldId];\n\n const fieldId: keyof T = field.fieldId;\n\n if (field.list) {\n const values = Array.isArray(inputValue) ? inputValue : undefined;\n if (!values) {\n return output;\n }\n /**\n * We need to skip sending the values if there is only one item in the array, and it is a null or undefined value.\n *\n * In case there are more items in the array, and they are null / undefined,\n * we must not do anything because it means the user added new items into the array,\n * and they want to have it like that - or is a mistake by user - in that case they will then remove the extra item(s).\n */\n //\n else if (values.length === 1 && (values[0] === null || values[0] === undefined)) {\n return output;\n }\n\n output[fieldId] = values.map(value => runTransformation(field, value));\n\n return output;\n }\n /**\n * Regular values, single values.\n */\n output[fieldId] = runTransformation(field, inputValue);\n\n return output;\n }, {} as T);\n};\n"],"names":["availableTransformerPlugins","getAvailableTransformerPlugins","plugins","transformers","pl","fieldTypes","Array","fieldType","console","transformationRunner","createTransformationRunner","availablePlugins","field","value","transformer","prepareFormData","input","fields","runTransformation","output","inputValue","fieldId","values","undefined"],"mappings":";AAWA,IAAIA;AACJ,MAAMC,iCAAiC;IACnC,IAAID,6BACA,OAAOA;IAEXA,8BAA8BE,QAAAA,MACnB,CAA2B,+BACjC,MAAM,CAA6B,CAACC,cAAcC;QAC/C,MAAMC,aAAaC,MAAM,OAAO,CAACF,GAAG,SAAS,IAAIA,GAAG,SAAS,GAAG;YAACA,GAAG,SAAS;SAAC;QAC9E,KAAK,MAAMG,aAAaF,WAAY;YAChC,IAAIF,YAAY,CAACI,UAAU,EAAE;gBACzBC,QAAQ,IAAI,CACR,CAAC,4BAA4B,EAAED,UAAU,gEAAgE,CAAC;gBAE9G;YACJ;YACAJ,YAAY,CAACI,UAAU,GAAGH;QAC9B;QACA,OAAOD;IACX,GAAG,CAAC;IAER,OAAOH;AACX;AAMA,IAAIS;AACJ,MAAMC,6BAA6B;IAC/B,IAAID,sBACA,OAAOA;IAEX,MAAME,mBAAmBV;IAEzBQ,uBAAuB,CAACG,OAAOC;QAC3B,MAAMC,cAAcH,gBAAgB,CAACC,MAAM,IAAI,CAAC;QAChD,IAAI,CAACE,aACD,OAAOD;QAEX,OAAOC,YAAY,SAAS,CAACD,OAAOD;IACxC;IACA,OAAOH;AACX;AAEO,MAAMM,kBAAkB,CAC3BC,OACAC;IAEA,MAAMC,oBAAoBR;IAE1B,OAAOO,OAAO,MAAM,CAAuB,CAACE,QAAQP;QAChD,MAAMQ,aAAaJ,KAAK,CAACJ,MAAM,OAAO,CAAC;QAEvC,MAAMS,UAAmBT,MAAM,OAAO;QAEtC,IAAIA,MAAM,IAAI,EAAE;YACZ,MAAMU,SAAShB,MAAM,OAAO,CAACc,cAAcA,aAAaG;YACxD,IAAI,CAACD,QACD,OAAOH;YAUN,IAAIG,AAAkB,MAAlBA,OAAO,MAAM,IAAWA,CAAAA,AAAc,SAAdA,MAAM,CAAC,EAAE,IAAaA,AAAcC,WAAdD,MAAM,CAAC,EAAE,AAAa,GACzE,OAAOH;YAGXA,MAAM,CAACE,QAAQ,GAAGC,OAAO,GAAG,CAACT,CAAAA,QAASK,kBAAkBN,OAAOC;YAE/D,OAAOM;QACX;QAIAA,MAAM,CAACE,QAAQ,GAAGH,kBAAkBN,OAAOQ;QAE3C,OAAOD;IACX,GAAG,CAAC;AACR"}
package/types/index.d.ts CHANGED
@@ -424,6 +424,7 @@ export interface CmsContentEntry<TValues extends GenericRecord = GenericRecord>
424
424
  status: CmsContentEntryStatusType;
425
425
  version: number;
426
426
  };
427
+ revisionDescription?: string;
427
428
  values: TValues;
428
429
  }
429
430
  export interface CmsContentEntryRevision {
@@ -448,6 +449,7 @@ export interface CmsContentEntryRevision {
448
449
  revisionFirstPublishedBy: CmsIdentity | null;
449
450
  revisionLastPublishedBy: CmsIdentity | null;
450
451
  wbyAco_location: Location;
452
+ revisionDescription?: string;
451
453
  meta: {
452
454
  title: string;
453
455
  locked: boolean;
package/types/index.js CHANGED
@@ -1,41 +1 @@
1
- export { isLayoutField, isLayoutDescriptor } from "./model.js";
2
-
3
- /**
4
- * @deprecated Use `CmsContentEntry`.
5
- */
6
-
7
- // ------------------------------------------------------------------------------------------------------------
8
-
9
- /**
10
- * Transform field value when sending data to the API.
11
- */
12
-
13
- /**
14
- * Define a custom form layout renderer for a specific content model.
15
- */
16
-
17
- /**
18
- * #########################
19
- * Data types
20
- * #########################
21
- */
22
-
23
- /**
24
- * @category GraphQL
25
- * @category Error
26
- */
27
-
28
- /**
29
- * @category GraphQL
30
- * @category Meta
31
- */
32
-
33
- /***
34
- * ###### FORM ########
35
- */
36
-
37
- /**
38
- * After RequestReview and RequestChanges was removed, we need an option to add new status filters
39
- */
40
-
41
- //# sourceMappingURL=index.js.map
1
+ export { isLayoutDescriptor, isLayoutField } from "./model.js";
package/types/model.js CHANGED
@@ -1,30 +1,7 @@
1
- /**
2
- * Distinguish layout fields from field IDs (strings) and CmsModelField objects.
3
- *
4
- * In raw layout data (`CmsEditorFieldsLayout`), cells are either strings (field IDs)
5
- * or layout field objects — the `typeof` check handles that.
6
- *
7
- * In resolved layout data (after `getFieldsInLayout`), cells are either `CmsModelField`
8
- * or layout field objects — both have `{ id, type }`, but only `CmsModelField`
9
- * has `fieldId`, so we use its absence as the discriminator.
10
- */
11
- export function isLayoutField(cell) {
12
- return typeof cell === "object" && cell !== null && "type" in cell && typeof cell.type === "string" && !("fieldId" in cell);
1
+ function isLayoutField(cell) {
2
+ return "object" == typeof cell && null !== cell && "type" in cell && "string" == typeof cell.type && !("fieldId" in cell);
13
3
  }
14
-
15
- /**
16
- * @deprecated Use `isLayoutField` instead.
17
- */
18
- export const isLayoutDescriptor = isLayoutField;
19
-
20
- /**
21
- * @category GraphQL
22
- * @category Model
23
- */
24
-
25
- /**
26
- * @category GraphQL
27
- * @category Group
28
- */
4
+ const isLayoutDescriptor = isLayoutField;
5
+ export { isLayoutDescriptor, isLayoutField };
29
6
 
30
7
  //# sourceMappingURL=model.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["isLayoutField","cell","type","isLayoutDescriptor"],"sources":["model.ts"],"sourcesContent":["import type { Validator } from \"@webiny/validation/types.js\";\nimport type { CmsModelFieldValidator } from \"~/types/validation.js\";\nimport type {\n CmsDynamicZoneTemplate,\n CmsEditorFieldPredefinedValues,\n CmsModelFieldRendererPlugin\n} from \"~/types/index.js\";\nimport type { CmsIdentity } from \"~/types/shared.js\";\nimport type React from \"react\";\n\nexport interface CmsModelFieldSettings<T = unknown> {\n defaultValue?: string | boolean | number | null | undefined;\n defaultSetValue?: string;\n type?: string;\n fields?: CmsModelField<T>[];\n layout?: CmsEditorFieldsLayout;\n models?: Pick<CmsModel, \"modelId\">[];\n templates?: CmsDynamicZoneTemplate[];\n imagesOnly?: boolean;\n [key: string]: any;\n}\n\nexport type FieldRuleAction = \"hide\" | \"disable\" | string;\n\nexport interface FieldRule {\n type: \"accessControl\" | \"condition\";\n target: string;\n operator: string;\n value: string | number | boolean | null;\n action: FieldRuleAction;\n}\n\nexport type CmsModelField<T = unknown> = T & {\n id: string;\n type: string;\n fieldId: CmsEditorFieldId;\n storageId?: string;\n label: string;\n help?: string | React.ReactNode;\n description?: string | React.ReactNode;\n note?: string | React.ReactNode;\n placeholder?: string;\n validation?: (CmsModelFieldValidator | Validator)[];\n listValidation?: CmsModelFieldValidator[];\n list?: boolean;\n predefinedValues?: CmsEditorFieldPredefinedValues;\n settings?: CmsModelFieldSettings<T>;\n renderer:\n | {\n name: string;\n settings?: Record<string, any>;\n }\n /**\n * Use this only for programmatic assignment of renderers.\n * Since functions cannot be serialized, this can only work via code.\n */\n | CmsModelFieldRendererPlugin[\"renderer\"][\"render\"];\n tags?: string[];\n rules?: FieldRule[];\n};\n\nexport type CmsEditorFieldId = string;\n\nexport interface CmsModelLayoutField {\n id: string;\n type: string;\n rules?: FieldRule[];\n}\n\nexport interface CmsSeparatorLayoutField extends CmsModelLayoutField {\n type: \"separator\";\n label: string;\n description?: string;\n}\n\nexport interface CmsAlertLayoutField extends CmsModelLayoutField {\n type: \"alert\";\n label: string;\n alertType: \"info\" | \"success\" | \"warning\" | \"danger\";\n}\n\nexport interface CmsTabLayoutTab {\n id: string;\n label: string;\n icon?: string;\n layout: CmsEditorFieldsLayout;\n rules?: FieldRule[];\n}\n\nexport interface CmsTabLayoutField extends CmsModelLayoutField {\n type: \"tabs\";\n label: string;\n description?: string | null;\n help?: string | null;\n tabs: CmsTabLayoutTab[];\n}\n\nexport type CmsLayoutField =\n | CmsSeparatorLayoutField\n | CmsAlertLayoutField\n | CmsTabLayoutField\n | CmsModelLayoutField;\n\nexport type CmsEditorLayoutCell = CmsEditorFieldId | CmsLayoutField;\nexport type CmsEditorFieldsLayout = CmsEditorLayoutCell[][];\n\n/**\n * Distinguish layout fields from field IDs (strings) and CmsModelField objects.\n *\n * In raw layout data (`CmsEditorFieldsLayout`), cells are either strings (field IDs)\n * or layout field objects — the `typeof` check handles that.\n *\n * In resolved layout data (after `getFieldsInLayout`), cells are either `CmsModelField`\n * or layout field objects — both have `{ id, type }`, but only `CmsModelField`\n * has `fieldId`, so we use its absence as the discriminator.\n */\nexport function isLayoutField(cell: unknown): cell is CmsLayoutField {\n return (\n typeof cell === \"object\" &&\n cell !== null &&\n \"type\" in cell &&\n typeof (cell as any).type === \"string\" &&\n !(\"fieldId\" in cell)\n );\n}\n\n/**\n * @deprecated Use `isLayoutField` instead.\n */\nexport const isLayoutDescriptor = isLayoutField;\n\n/**\n * @category GraphQL\n * @category Model\n */\nexport type CmsEditorContentModel = CmsModel;\n\n/**\n * @category GraphQL\n * @category Group\n */\nexport interface CmsGroup {\n id: string;\n name: string;\n slug: string;\n icon: string;\n description?: string;\n contentModels: CmsModel[];\n createdBy: CmsIdentity;\n /**\n * Tells if this group is a plugin one (cannot be changed/deleted)\n */\n plugin?: boolean;\n}\n\nexport interface CmsModel {\n id: string;\n group: string;\n description?: string;\n version: number;\n layout?: CmsEditorFieldsLayout;\n fields: CmsModelField[];\n icon: string;\n name: string;\n modelId: string;\n singularApiName: string;\n pluralApiName: string;\n titleFieldId: string | null;\n descriptionFieldId: string | null;\n imageFieldId: string | null;\n status: string;\n savedOn: string;\n meta: any;\n createdBy: CmsIdentity;\n tags: string[];\n /**\n * If model is a plugin one (it cannot be changed/deleted)\n */\n plugin?: boolean;\n /**\n * Is model currently being deleted?\n */\n isBeingDeleted?: boolean;\n settings: {\n [key: string]: any;\n };\n}\n"],"mappings":"AA0GA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASA,aAAaA,CAACC,IAAa,EAA0B;EACjE,OACI,OAAOA,IAAI,KAAK,QAAQ,IACxBA,IAAI,KAAK,IAAI,IACb,MAAM,IAAIA,IAAI,IACd,OAAQA,IAAI,CAASC,IAAI,KAAK,QAAQ,IACtC,EAAE,SAAS,IAAID,IAAI,CAAC;AAE5B;;AAEA;AACA;AACA;AACA,OAAO,MAAME,kBAAkB,GAAGH,aAAa;;AAE/C;AACA;AACA;AACA;;AAGA;AACA;AACA;AACA","ignoreList":[]}
1
+ {"version":3,"file":"types/model.js","sources":["../../src/types/model.ts"],"sourcesContent":["import type { Validator } from \"@webiny/validation/types.js\";\nimport type { CmsModelFieldValidator } from \"~/types/validation.js\";\nimport type {\n CmsDynamicZoneTemplate,\n CmsEditorFieldPredefinedValues,\n CmsModelFieldRendererPlugin\n} from \"~/types/index.js\";\nimport type { CmsIdentity } from \"~/types/shared.js\";\nimport type React from \"react\";\n\nexport interface CmsModelFieldSettings<T = unknown> {\n defaultValue?: string | boolean | number | null | undefined;\n defaultSetValue?: string;\n type?: string;\n fields?: CmsModelField<T>[];\n layout?: CmsEditorFieldsLayout;\n models?: Pick<CmsModel, \"modelId\">[];\n templates?: CmsDynamicZoneTemplate[];\n imagesOnly?: boolean;\n [key: string]: any;\n}\n\nexport type FieldRuleAction = \"hide\" | \"disable\" | string;\n\nexport interface FieldRule {\n type: \"accessControl\" | \"condition\";\n target: string;\n operator: string;\n value: string | number | boolean | null;\n action: FieldRuleAction;\n}\n\nexport type CmsModelField<T = unknown> = T & {\n id: string;\n type: string;\n fieldId: CmsEditorFieldId;\n storageId?: string;\n label: string;\n help?: string | React.ReactNode;\n description?: string | React.ReactNode;\n note?: string | React.ReactNode;\n placeholder?: string;\n validation?: (CmsModelFieldValidator | Validator)[];\n listValidation?: CmsModelFieldValidator[];\n list?: boolean;\n predefinedValues?: CmsEditorFieldPredefinedValues;\n settings?: CmsModelFieldSettings<T>;\n renderer:\n | {\n name: string;\n settings?: Record<string, any>;\n }\n /**\n * Use this only for programmatic assignment of renderers.\n * Since functions cannot be serialized, this can only work via code.\n */\n | CmsModelFieldRendererPlugin[\"renderer\"][\"render\"];\n tags?: string[];\n rules?: FieldRule[];\n};\n\nexport type CmsEditorFieldId = string;\n\nexport interface CmsModelLayoutField {\n id: string;\n type: string;\n rules?: FieldRule[];\n}\n\nexport interface CmsSeparatorLayoutField extends CmsModelLayoutField {\n type: \"separator\";\n label: string;\n description?: string;\n}\n\nexport interface CmsAlertLayoutField extends CmsModelLayoutField {\n type: \"alert\";\n label: string;\n alertType: \"info\" | \"success\" | \"warning\" | \"danger\";\n}\n\nexport interface CmsTabLayoutTab {\n id: string;\n label: string;\n icon?: string;\n layout: CmsEditorFieldsLayout;\n rules?: FieldRule[];\n}\n\nexport interface CmsTabLayoutField extends CmsModelLayoutField {\n type: \"tabs\";\n label: string;\n description?: string | null;\n help?: string | null;\n tabs: CmsTabLayoutTab[];\n}\n\nexport type CmsLayoutField =\n | CmsSeparatorLayoutField\n | CmsAlertLayoutField\n | CmsTabLayoutField\n | CmsModelLayoutField;\n\nexport type CmsEditorLayoutCell = CmsEditorFieldId | CmsLayoutField;\nexport type CmsEditorFieldsLayout = CmsEditorLayoutCell[][];\n\n/**\n * Distinguish layout fields from field IDs (strings) and CmsModelField objects.\n *\n * In raw layout data (`CmsEditorFieldsLayout`), cells are either strings (field IDs)\n * or layout field objects — the `typeof` check handles that.\n *\n * In resolved layout data (after `getFieldsInLayout`), cells are either `CmsModelField`\n * or layout field objects — both have `{ id, type }`, but only `CmsModelField`\n * has `fieldId`, so we use its absence as the discriminator.\n */\nexport function isLayoutField(cell: unknown): cell is CmsLayoutField {\n return (\n typeof cell === \"object\" &&\n cell !== null &&\n \"type\" in cell &&\n typeof (cell as any).type === \"string\" &&\n !(\"fieldId\" in cell)\n );\n}\n\n/**\n * @deprecated Use `isLayoutField` instead.\n */\nexport const isLayoutDescriptor = isLayoutField;\n\n/**\n * @category GraphQL\n * @category Model\n */\nexport type CmsEditorContentModel = CmsModel;\n\n/**\n * @category GraphQL\n * @category Group\n */\nexport interface CmsGroup {\n id: string;\n name: string;\n slug: string;\n icon: string;\n description?: string;\n contentModels: CmsModel[];\n createdBy: CmsIdentity;\n /**\n * Tells if this group is a plugin one (cannot be changed/deleted)\n */\n plugin?: boolean;\n}\n\nexport interface CmsModel {\n id: string;\n group: string;\n description?: string;\n version: number;\n layout?: CmsEditorFieldsLayout;\n fields: CmsModelField[];\n icon: string;\n name: string;\n modelId: string;\n singularApiName: string;\n pluralApiName: string;\n titleFieldId: string | null;\n descriptionFieldId: string | null;\n imageFieldId: string | null;\n status: string;\n savedOn: string;\n meta: any;\n createdBy: CmsIdentity;\n tags: string[];\n /**\n * If model is a plugin one (it cannot be changed/deleted)\n */\n plugin?: boolean;\n /**\n * Is model currently being deleted?\n */\n isBeingDeleted?: boolean;\n settings: {\n [key: string]: any;\n };\n}\n"],"names":["isLayoutField","cell","isLayoutDescriptor"],"mappings":"AAoHO,SAASA,cAAcC,IAAa;IACvC,OACI,AAAgB,YAAhB,OAAOA,QACPA,AAAS,SAATA,QACA,UAAUA,QACV,AAA8B,YAA9B,OAAQA,KAAa,IAAI,IACzB,CAAE,cAAaA,IAAG;AAE1B;AAKO,MAAMC,qBAAqBF"}
package/types/shared.js CHANGED
@@ -1,3 +0,0 @@
1
- export {};
2
-
3
- //# sourceMappingURL=shared.js.map
@@ -1,3 +0,0 @@
1
- export {};
2
-
3
- //# sourceMappingURL=validation.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["export * from \"./FieldElement.js\";\nexport * from \"./Fields.js\";\nexport * from \"./useBind.js\";\nexport * from \"./FieldRulesProvider.js\";\nexport * from \"./evaluateExpression.js\";\nexport * from \"./useFieldRules.js\";\nexport * from \"./fieldOptions.js\";\nexport * from \"./operatorOptions.js\";\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA","ignoreList":[]}
@@ -1 +0,0 @@
1
- {"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["export * from \"./ModelFieldContext.js\";\nexport * from \"./useModelField.js\";\nexport * from \"./CanEditField.js\";\n"],"mappings":"AAAA;AACA;AACA","ignoreList":[]}
@@ -1 +0,0 @@
1
- {"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["export * from \"./ModelContext.js\";\nexport * from \"./useModel.js\";\n"],"mappings":"AAAA;AACA","ignoreList":[]}
@@ -1 +0,0 @@
1
- {"version":3,"names":["useFieldAccessControlRules","useFieldEffectiveRules"],"sources":["model.ts"],"sourcesContent":["export { useFieldAccessControlRules, useFieldEffectiveRules } from \"~/Fields/index.js\";\n"],"mappings":"AAAA,SAASA,0BAA0B,EAAEC,sBAAsB","ignoreList":[]}
@@ -1 +0,0 @@
1
- {"version":3,"names":[],"sources":["cms.ts"],"sourcesContent":["export type {\n CmsContentEntry,\n CmsModel,\n CmsModelField,\n CmsModelLayoutField,\n CmsIdentity\n} from \"~/types/index.ts\";\n"],"mappings":"","ignoreList":[]}
package/index.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["export * from \"./Fields/index.js\";\nexport * from \"./ModelFieldProvider/index.js\";\nexport * from \"./ModelProvider/index.js\";\nexport * from \"./entries.graphql.js\";\nexport * from \"./getModelTitleFieldId.js\";\nexport * from \"./createFieldsList.js\";\nexport * from \"./createValidationContainer.js\";\nexport * from \"./createValidators.js\";\nexport * from \"./prepareFormData.js\";\nexport * from \"./constants.js\";\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA","ignoreList":[]}
@@ -1 +0,0 @@
1
- {"version":3,"names":["isLayoutField","isLayoutDescriptor"],"sources":["index.ts"],"sourcesContent":["import type * as React from \"react\";\nimport type { ReactElement, ReactNode } from \"react\";\nimport type { Plugin } from \"@webiny/plugins/types.js\";\nimport type {\n BindComponent as BaseBindComponent,\n BindComponentProps as BaseBindComponentProps,\n BindComponentRenderProp as BaseBindComponentRenderProp,\n FormAPI\n} from \"@webiny/form\";\nimport type { IconName, IconPrefix } from \"@fortawesome/fontawesome-svg-core\";\nimport type {\n CmsModelFieldValidator,\n CmsModelFieldValidatorsFactory,\n CmsModelFieldValidatorsGroup\n} from \"./validation.js\";\nimport type {\n CmsModelLayoutField,\n CmsEditorFieldsLayout,\n CmsLayoutField,\n CmsModel,\n CmsModelField\n} from \"./model.js\";\nimport type { CmsIdentity } from \"~/types/shared.js\";\nimport type { SourceType } from \"dnd-core\";\nimport type { IconPickerIconDto } from \"@webiny/admin-ui\";\nimport { GenericRecord } from \"@webiny/app/types.js\";\nimport { Identity } from \"@webiny/app-admin/domain/Identity.js\";\n\nexport type DragObjectWithType = {\n type: SourceType;\n};\n\nexport type * from \"./validation.js\";\nexport type * from \"./model.js\";\nexport { isLayoutField, isLayoutDescriptor } from \"./model.js\";\nexport type * from \"./shared.js\";\n\ninterface QueryFieldParams {\n model: CmsModel;\n field: CmsModelField;\n graphQLTypePrefix: string;\n}\n\ninterface Position {\n row: number;\n index: number;\n}\n\ninterface Location {\n folderId: string;\n}\n\nexport interface DragSource extends DragObjectWithType {\n parent?: string;\n pos?: Partial<Position>;\n type: \"row\" | \"field\" | \"newField\" | \"newLayoutField\" | \"layoutField\";\n fieldType?: string;\n layoutFieldType?: string;\n field?: CmsModelField | null;\n fields?: CmsModelField[];\n layoutField?: CmsLayoutField;\n}\n\nexport interface CmsModelFieldTypePlugin extends Plugin {\n /**\n * a plugin type\n */\n type: \"cms-editor-field-type\";\n field: {\n /**\n * A unique identifier of the field type (text, number, json, myField, ...).\n *\n * ```ts\n * type: \"myField\"\n * ```\n */\n type: string;\n /**\n * A display name for the field.\n *\n * ```ts\n * label: \"Field name\"\n * ```\n */\n label: string;\n /**\n * A list of available validators for the model field.\n *\n * ```ts\n * validators: [\n * \"required\",\n * \"gte\",\n * \"lte\"\n * ]\n * ```\n */\n validators?: string[] | CmsModelFieldValidatorsGroup | CmsModelFieldValidatorsFactory;\n /**\n * A list of available validators when a model field accepts a list (array) of values.\n *\n * ```ts\n * listValidators: [\n * \"minLength\",\n * \"maxLength\"\n * ]\n * ```\n */\n listValidators?: string[] | CmsModelFieldValidatorsGroup | CmsModelFieldValidatorsFactory;\n /**\n * An explanation of the field displayed beneath the label.\n *\n * ```ts\n * description: \"A short description of the field\"\n * ```\n */\n description: string;\n /**\n * A ReactNode to display the icon for the field.\n *\n * ```tsx\n * icon: <MyIconComponent />\n * ```\n */\n icon: React.ReactNode;\n /**\n * Is it allowed to have multiple values in this field?\n *\n * ```ts\n * allowList: true\n * ```\n */\n allowList?: boolean;\n /**\n * Does this field type have a fixed list of values that can be selected?\n *\n * ```ts\n * allowPredefinedValues: false\n * ```\n */\n allowPredefinedValues?: boolean;\n /**\n * A ReactNode label when multiple values are enabled.\n */\n listLabel?: React.ReactNode;\n /**\n * Determines if this field type should be hidden from the admin UI.\n * If set to `true`, the field type will not be visible or selectable in the admin interface.\n */\n hideInAdmin?: boolean;\n /**\n * These are default values when the field is first created. This is a representation of the field that is stored in the database.\n *\n * ```ts\n * createField: () => ({\n * type: \"fieldType\",\n * validation: [],\n * renderer: {\n * name: \"fieldTypeRenderer\"\n * }\n * })\n * ```\n */\n createField: () => Pick<CmsModelField, \"type\" | \"validation\" | \"renderer\" | \"settings\">;\n /**\n * If `true` (default), this field will be configurable via a settings dialog.\n * If `false`, a user will not be able to open the settings dialog, not will the dialog be opened on field drop.\n */\n canEditSettings?: boolean;\n /**\n * Determine if a `draggable` can be dropped into this field.\n * NOTE: This is only applicable to nested field types.\n */\n canAccept?(field: CmsModelField, draggable: DragSource): boolean;\n /**\n * If `true` (default), will allow fields to be laid out into columns (next to each other).\n * If `false`, horizontal layout will not be allowed.\n * NOTE: This is only applicable to nested field types.\n */\n allowLayout?: boolean;\n /**\n * A ReactNode that you can add in the section below the help text when creating/editing field.\n *\n * ```tsx\n * renderSettings: (params) => {\n * return <FieldSettingsComponent />;\n * }\n * ```\n */\n renderSettings?: (params: {\n afterChangeLabel: (value: string) => void;\n uniqueFieldIdValidator: (fieldId: string) => void;\n contentModel: CmsModel;\n }) => React.ReactNode;\n /**\n * A ReactNode that renders in the Predefined values tab.\n *\n * ```tsx\n * renderPredefinedValues: (params) => {\n * const {form: {Bind}} = params;\n * return (\n * <Bind name=\"fieldProperty\">\n * <InputComponent />\n * </Bind>\n * );\n * }\n * ```\n */\n renderPredefinedValues?: (params: {\n getBind: (index?: number) => any;\n }) => React.ReactElement;\n /**\n * Object wrapper for GraphQL stuff\n */\n graphql?: {\n /**\n * Define field selection.\n *\n * ```ts\n * graphql: {\n * queryField: `\n * {\n * id\n * title\n * createdOn\n * }\n * `,\n * }\n * ```\n */\n queryField?: string | ((params: QueryFieldParams) => string | null);\n };\n render?(params: any): React.ReactElement;\n tags?: string[];\n /**\n * Render additional information in the Admin UI Model edit view\n */\n renderInfo?: (params: { field: CmsModelField; model: CmsModel }) => React.ReactElement;\n };\n}\n\nexport interface CmsModelLayoutFieldTypePlugin<\n T extends CmsModelLayoutField = CmsModelLayoutField\n> extends Plugin {\n type: \"cms-editor-layout-field-type\";\n field: {\n type: T[\"type\"];\n label: string;\n description: string;\n icon: React.ReactElement;\n createField(): Omit<T, \"id\">;\n canEditSettings?: boolean;\n renderSettings?(): React.ReactNode;\n /**\n * Collect all model fields embedded inside a layout field's nested layout.\n * Used during drag-and-drop to move embedded fields along with the layout field\n * across parent boundaries. Return `[]` or omit for layout fields with no nested fields.\n */\n collectFields?(params: {\n field: T;\n getField: (id: string) => CmsModelField | undefined;\n }): CmsModelField[];\n /**\n * Return a label prefix for each field ID nested inside this layout field.\n * Used by `buildFieldOptions` to include layout hierarchy in field labels.\n *\n * For example, a tabs layout field with label \"My Tabs\" containing a tab \"SEO\"\n * with field \"metaTitle\" would return: `{ \"metaTitle\": \"My Tabs › SEO\" }`.\n *\n * Omit or return `{}` for layout fields that don't group fields.\n */\n getFieldLabelPrefixes?(params: { field: T }): Record<string, string>;\n /**\n * Controls how this layout field looks on the model editor canvas.\n * Each plugin fully owns its visual representation.\n */\n render(params: {\n field: T;\n onUpdate: (d: T) => void;\n onDelete: () => void;\n }): React.ReactElement;\n };\n}\n\nexport interface CmsModelLayoutFieldRendererPlugin<\n T extends CmsModelLayoutField = CmsModelLayoutField\n> extends Plugin {\n type: \"cms-layout-field-renderer\";\n fieldType: string;\n render(props: {\n field: T;\n Bind: BindComponent;\n fields: CmsModelField[];\n contentModel: CmsModel;\n gridClassName?: string;\n }): React.ReactElement | null;\n}\n\nexport interface CmsModelFieldRendererSettingsProps {\n field: CmsModelField;\n}\n\nexport interface CmsModelFieldRendererProps {\n field: CmsModelField;\n Label: React.ComponentType<React.PropsWithChildren>;\n getBind: <T = any>(index?: number, key?: string) => BindComponent<T>;\n contentModel: CmsModel;\n}\n\nexport interface CmsModelFieldRendererPlugin extends Plugin {\n /**\n * a plugin type\n */\n type: \"cms-editor-field-renderer\";\n renderer: {\n /**\n * Name of the renderer to match the one from `createField()` method in `CmsModelFieldTypePlugin`.\n *\n * ```ts\n * renderName: \"myFieldTypeRenderer\"\n * ```\n */\n rendererName: string;\n /**\n * A display name for the field in the UI. It is a `ReactNode` type, so you can use a JSX element.\n *\n * ```tsx\n * name: <MyFieldNameComponent />\n * ```\n */\n name: React.ReactNode;\n /**\n * A description for the field in the UI. Works exactly like the `name` property.\n *\n * ```tsx\n * name: <MyFieldDescriptionComponent />\n * ```\n */\n description: React.ReactNode;\n /**\n * A method that determines if the field can be rendered by this plugin.\n *\n * ```ts\n * canUse({ field }) {\n * return (\n * field.type === \"myType\" && !field.list\n * );\n * }\n * ```\n */\n canUse(props: {\n field: CmsModelField;\n fieldPlugin: CmsModelFieldTypePlugin;\n model: CmsModel;\n }): boolean;\n /**\n * Renders a field in the UI.\n *\n * ```tsx\n * render({ field, getBind }) {\n * const Bind = getBind();\n *\n * return (\n * <Bind>\n * {bind => {\n * return (\n * <Input\n * value={bind.value}\n * onChange={bind.onChange}\n * />\n * )\n * }}\n * </Bind>\n * );\n * }\n * ```\n */\n render(props: CmsModelFieldRendererProps): React.ReactNode;\n renderSettings?: (props: CmsModelFieldRendererSettingsProps) => React.ReactNode;\n };\n}\n\nexport interface CmsEditorFieldPredefinedValuesEntry {\n label: string;\n value: string;\n selected?: boolean;\n}\n\nexport interface CmsEditorFieldPredefinedValues {\n enabled: boolean;\n values: CmsEditorFieldPredefinedValuesEntry[];\n}\n\nexport interface CmsDynamicZoneTemplate {\n id: string;\n name: string;\n gqlTypeName: string;\n description: string;\n icon: string;\n fields: CmsModelField[];\n layout: CmsEditorFieldsLayout;\n validation: CmsModelFieldValidator[];\n tags?: string[];\n}\n\nexport interface CmsDynamicZoneTemplateWithTypename extends CmsDynamicZoneTemplate {\n __typename: string;\n}\n\nexport type CmsContentEntryStatusType = \"draft\" | \"published\" | \"unpublished\";\n\n/**\n * @deprecated Use `CmsContentEntry`.\n */\nexport type CmsEditorContentEntry = CmsContentEntry;\n\nexport interface CmsContentEntryLive {\n version: number;\n}\n\nexport interface CmsContentEntrySystem {\n // to be extended\n}\n\nexport interface CmsContentEntry<TValues extends GenericRecord = GenericRecord> {\n id: string;\n entryId: string;\n modelId: string;\n createdOn: string;\n createdBy: CmsIdentity;\n savedOn: string;\n savedBy: CmsIdentity;\n modifiedOn: string | null;\n modifiedBy: CmsIdentity | null;\n deletedOn: string | null;\n deletedBy: CmsIdentity | null;\n firstPublishedOn: string | null;\n firstPublishedBy: CmsIdentity | null;\n lastPublishedOn: string | null;\n lastPublishedBy: CmsIdentity | null;\n revisionCreatedOn: string;\n revisionCreatedBy: CmsIdentity;\n revisionSavedOn: string;\n revisionSavedBy: CmsIdentity;\n revisionModifiedOn: string | null;\n revisionModifiedBy: CmsIdentity | null;\n revisionDeletedOn: string | null;\n revisionDeletedBy: CmsIdentity | null;\n revisionFirstPublishedOn: string | null;\n revisionFirstPublishedBy: CmsIdentity | null;\n revisionLastPublishedOn: string | null;\n revisionLastPublishedBy: CmsIdentity | null;\n wbyAco_location: Location;\n live: CmsContentEntryLive | null;\n system: CmsContentEntrySystem | null;\n meta: {\n title: string;\n description?: string;\n image?: string;\n locked: boolean;\n status: CmsContentEntryStatusType;\n version: number;\n };\n values: TValues;\n}\n\nexport interface CmsContentEntryRevision {\n id: string;\n modelId: string;\n savedOn: string;\n deletedOn: string | null;\n firstPublishedOn: string | null;\n lastPublishedOn: string | null;\n createdBy: CmsIdentity;\n deletedBy: CmsIdentity | null;\n revisionCreatedOn: string;\n revisionSavedOn: string;\n revisionModifiedOn: string | null;\n revisionDeletedOn: string | null;\n revisionFirstPublishedOn: string | null;\n revisionLastPublishedOn: string | null;\n revisionCreatedBy: CmsIdentity;\n revisionSavedBy: CmsIdentity;\n revisionModifiedBy: CmsIdentity | null;\n revisionDeletedBy: CmsIdentity | null;\n revisionFirstPublishedBy: CmsIdentity | null;\n revisionLastPublishedBy: CmsIdentity | null;\n wbyAco_location: Location;\n meta: {\n title: string;\n locked: boolean;\n status: CmsContentEntryStatusType;\n version: number;\n };\n}\n\nexport type CmsEditorContentTab = React.ComponentType<{ activeTab: boolean }>;\n\n// ------------------------------------------------------------------------------------------------------------\nexport interface CmsEditorFieldOptionPlugin extends Plugin {\n type: \"cms-editor-field-option\";\n render(): ReactElement;\n}\n\nexport interface CmsContentDetailsPlugin extends Plugin {\n render: (params: any) => ReactNode;\n}\n\nexport interface FieldLayoutPosition {\n row: number;\n index: number | null;\n}\n\nexport interface CmsEditorFormSettingsPlugin<T = GenericRecord> extends Plugin {\n type: \"cms-editor-form-settings\";\n title: string;\n description: string;\n icon: React.ReactElement;\n showSave?: boolean;\n render(props: { Bind: BaseBindComponent; form: FormAPI<T>; formData: T }): React.ReactNode;\n renderHeaderActions?(props: {\n Bind: BaseBindComponent;\n form: FormAPI<T>;\n formData: T;\n }): React.ReactNode;\n}\n\nexport interface CmsIcon {\n /**\n * [ pack, icon ], ex: [\"fab\", \"cog\"]\n */\n id: [IconPrefix, IconName];\n /**\n * Icon name\n */\n name: string;\n /**\n * SVG element\n */\n svg: ReactElement;\n}\n\nexport interface CmsIconsPlugin extends Plugin {\n type: \"cms-icons\";\n getIcons(): IconPickerIconDto[];\n}\n\n/**\n * Transform field value when sending data to the API.\n */\nexport interface CmsFieldValueTransformer<\n TField extends CmsModelField = CmsModelField\n> extends Plugin {\n /**\n * A plugin type.\n */\n type: \"cms-field-value-transformer\";\n /**\n * A field type for the value transformer. Or a list of field types.\n */\n fieldType: string | string[];\n /**\n * A transformer function that takes a value and returns a new one.\n */\n transform: (value: any, field: TField) => any;\n}\n\n/**\n * Define a custom form layout renderer for a specific content model.\n */\nexport interface CmsContentFormRendererPlugin extends Plugin {\n /**\n * A plugin type.\n */\n type: \"cms-content-form-renderer\";\n /**\n * Content model ID that will use this renderer.\n */\n modelId: string;\n\n /**\n * A function that will render a custom form layout.\n */\n render(props: {\n /**\n * Content model that is being rendered.\n */\n contentModel: CmsModel;\n /**\n * Content entry data handled by the Form element.\n */\n data: Record<string, any>;\n /**\n * A component to bind data to the Form.\n */\n Bind: BindComponent;\n /**\n * Content model fields to render.\n */\n fields: Record<string, React.ReactElement>;\n }): React.ReactNode;\n}\n/**\n * #########################\n * Data types\n * #########################\n */\nexport interface CmsSecurityPermission extends Identity.Permission {\n accessLevel?: \"full\" | \"no\" | \"custom\";\n models?: string[];\n groups?: string[];\n endpoints?: string[];\n rwd?: string;\n own?: boolean;\n pw?: string;\n _src?: string;\n}\n\n/**\n * @category GraphQL\n * @category Error\n */\nexport interface CmsErrorResponse {\n message: string;\n code: string;\n data?: Record<string, any> | null;\n}\n/**\n * @category GraphQL\n * @category Meta\n */\nexport interface CmsMetaResponse {\n totalCount: number;\n cursor: string | null;\n hasMoreItems: boolean;\n}\n\n/***\n * ###### FORM ########\n */\nexport interface BindComponentRenderProp<T = any> extends BaseBindComponentRenderProp<T> {\n parentName: string;\n appendValue: (value: any, index?: number) => void;\n prependValue: (value: any) => void;\n appendValues: (values: any[]) => void;\n removeValue: (index: number) => void;\n moveValueUp: (index: number) => void;\n moveValueDown: (index: number) => void;\n}\n\ninterface BindComponentProps<T = any> extends Omit<BaseBindComponentProps, \"children\" | \"name\"> {\n name?: string;\n children?: ((props: BindComponentRenderProp<T>) => React.ReactElement) | React.ReactElement;\n}\n\nexport type BindComponent<T = any> = React.ComponentType<BindComponentProps<T>> & {\n parentName: string;\n ValidationContainer: React.ComponentType<{ children: React.ReactNode }>;\n};\n\n/**\n * After RequestReview and RequestChanges was removed, we need an option to add new status filters\n */\nexport interface CmsEntryFilterStatusPlugin extends Plugin {\n type: \"cms.entry.filter.status\";\n label: string;\n value: string;\n}\n"],"mappings":"AAkCA,SAASA,aAAa,EAAEC,kBAAkB;;AAwX1C;AACA;AACA;;AAqFA;;AAiDA;AACA;AACA;;AAkBA;AACA;AACA;;AAiCA;AACA;AACA;AACA;AACA;;AAYA;AACA;AACA;AACA;;AAMA;AACA;AACA;AACA;;AAOA;AACA;AACA;;AAqBA;AACA;AACA","ignoreList":[]}
@@ -1 +0,0 @@
1
- {"version":3,"names":[],"sources":["shared.ts"],"sourcesContent":["export interface CmsIdentity {\n id: string;\n displayName: string;\n type: string;\n}\n"],"mappings":"","ignoreList":[]}
@@ -1 +0,0 @@
1
- {"version":3,"names":[],"sources":["validation.ts"],"sourcesContent":["import type * as React from \"react\";\nimport type { Plugin } from \"@webiny/plugins/types.js\";\nimport type { CmsModelField } from \"~/types/index.js\";\n\nexport interface CmsModelFieldValidatorConfigAdapter {\n isRequired(): boolean;\n getName(): string;\n getLabel(): string;\n getDescription(): string;\n getDefaultMessage(): string;\n getDefaultSettings(): Record<string, any> | undefined;\n getVariables(): CmsModelFieldValidatorVariable[];\n getVariableDescription(variableName: string): string | undefined;\n}\n\nexport interface CmsModelFieldValidatorVariable {\n name: string;\n description: string;\n}\n\n/**\n * This interface is used in the validator configuration UI (Field dialog).\n */\nexport interface CmsModelFieldValidatorConfig {\n name: string;\n required?: boolean;\n label?: string;\n description?: string;\n defaultMessage?: string;\n defaultSettings?: Record<string, any>;\n variables?: CmsModelFieldValidatorVariable[];\n}\n\n/**\n * This interface allows you to control the title, description, and validators located in the specific\n * validators group, like `validators` or `listValidators` within the Field dialog.\n */\nexport interface CmsModelFieldValidatorsGroup {\n validators: (string | CmsModelFieldValidatorConfig)[];\n title?: string;\n description?: string;\n}\n\n/**\n * This interface allows you to generate validators based on the field configuration.\n */\nexport interface CmsModelFieldValidatorsFactory {\n (field: CmsModelField): string[] | CmsModelFieldValidatorsGroup;\n}\n\nexport interface CmsModelFieldValidator {\n name: string;\n message?: string;\n settings?: any;\n}\n\nexport interface CmsModelFieldValidatorPlugin<T = any> extends Plugin {\n type: \"cms-model-field-validator\";\n validator: {\n name: string;\n label: string;\n description: string;\n defaultMessage: string;\n variables?: CmsModelFieldValidatorVariable[];\n defaultSettings?: Record<string, any>;\n getVariableValues?: (context: {\n validator: CmsModelFieldValidator;\n }) => Record<string, string>;\n renderSettings?: (config: CmsModelFieldValidatorConfigAdapter) => React.ReactElement;\n renderCustomUi?: () => React.ReactElement;\n validate: (\n value: T,\n context: {\n validator: CmsModelFieldValidator;\n field: CmsModelField;\n }\n ) => Promise<any>;\n };\n}\n\nexport interface CmsModelFieldRegexValidatorExpressionPlugin extends Plugin {\n type: \"cms-model-field-regex-validator-expression\";\n pattern: {\n name: string;\n message: string;\n label: string;\n regex: string;\n flags: string;\n };\n}\n"],"mappings":"","ignoreList":[]}