@webiny/api-aco 0.0.0-unstable.b02d94bba0 → 0.0.0-unstable.c2780f51fe

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/README.md CHANGED
@@ -18,16 +18,16 @@ yarn add @webiny/api-aco
18
18
  ```
19
19
  ## Testing
20
20
 
21
- To run tests api-apw tests with targeted storage operations loaded use:
21
+ To run tests api-aco tests with targeted storage operations loaded use:
22
22
 
23
23
  ### DynamoDB
24
24
 
25
25
  ```
26
- yarn test packages/api-aco --keyword=cms:ddb --keyword=aco:base
26
+ yarn test packages/api-aco/* --keyword=cms:ddb --keyword=aco:base
27
27
  ```
28
28
 
29
- #### Note
29
+ ### DynamoDB + ElasticSearch
30
30
 
31
- > All the tests in `@webiny/api-aco` package are being tested against ddb-only storage operations because
32
- current jest setup doesn't allow usage of more than one storage operations at a time with the help of --keyword flag.
33
- We should revisit these tests once we have the ability to load multiple storage operations in the jest setup.
31
+ ```
32
+ yarn test packages/api-aco/* --keyword=cms:ddb-es --keyword=aco:base
33
+ ```
@@ -26,7 +26,6 @@ const createAcoModels = context => {
26
26
  })) {
27
27
  return;
28
28
  }
29
- context.security.disableAuthorization();
30
29
  const locale = context.i18n.getContentLocale();
31
30
  if (!locale) {
32
31
  throw new _error.default("Missing content locale in api-aco/storageOperations/index.ts", "LOCALE_ERROR");
@@ -62,6 +61,5 @@ const createAcoModels = context => {
62
61
  * Register them so that they are accessible in cms context
63
62
  */
64
63
  context.plugins.register([cmsGroupPlugin, cmsModelPlugins]);
65
- context.security.enableAuthorization();
66
64
  };
67
65
  exports.createAcoModels = createAcoModels;
@@ -1 +1 @@
1
- {"version":3,"names":["createAcoModels","context","cms","console","warn","isInstallationPending","tenancy","i18n","security","disableAuthorization","locale","getContentLocale","WebinyError","groupId","cmsGroupPlugin","CmsGroupPlugin","id","slug","name","description","icon","isPrivate","modelDefinitions","createFolderModelDefinition","createSearchModelDefinition","cmsModelPlugins","map","modelDefinition","modelFactory","group","contentModelGroup","tenant","getCurrentTenant","code","plugins","register","enableAuthorization"],"sources":["createAcoModels.ts"],"sourcesContent":["import { CmsGroupPlugin } from \"@webiny/api-headless-cms\";\nimport { CmsContext } from \"@webiny/api-headless-cms/types\";\nimport WebinyError from \"@webiny/error\";\n\nimport { createFolderModelDefinition } from \"~/folder/folder.model\";\nimport { createSearchModelDefinition } from \"~/record/record.model\";\nimport { modelFactory } from \"~/utils/modelFactory\";\nimport { isInstallationPending } from \"~/utils/isInstallationPending\";\n\nexport const createAcoModels = (context: CmsContext) => {\n /**\n * This should never happen in the actual project.\n * It is to make sure that we load setup context before the CRUD init in our internal code.\n */\n if (!context.cms) {\n console.warn(\"Creating model before cms init.\");\n return;\n }\n\n if (isInstallationPending({ tenancy: context.tenancy, i18n: context.i18n })) {\n return;\n }\n\n context.security.disableAuthorization();\n\n const locale = context.i18n.getContentLocale();\n if (!locale) {\n throw new WebinyError(\n \"Missing content locale in api-aco/storageOperations/index.ts\",\n \"LOCALE_ERROR\"\n );\n }\n\n const groupId = \"contentModelGroup_aco\";\n\n /**\n * Create a CmsGroup.\n */\n const cmsGroupPlugin = new CmsGroupPlugin({\n id: groupId,\n slug: \"aco\",\n name: \"ACO\",\n description: \"Group for Advanced Content Organisation and Search\",\n icon: \"fas/folder\",\n isPrivate: true\n });\n\n /**\n * Create CmsModel plugins.\n */\n const modelDefinitions = [createFolderModelDefinition(), createSearchModelDefinition()];\n const cmsModelPlugins = modelDefinitions.map(modelDefinition => {\n return modelFactory({\n group: cmsGroupPlugin.contentModelGroup,\n tenant: context.tenancy.getCurrentTenant().id,\n locale: locale.code,\n modelDefinition\n });\n });\n\n /**\n * Register them so that they are accessible in cms context\n */\n context.plugins.register([cmsGroupPlugin, cmsModelPlugins]);\n\n context.security.enableAuthorization();\n};\n"],"mappings":";;;;;;;AAAA;AAEA;AAEA;AACA;AACA;AACA;AAEO,MAAMA,eAAe,GAAIC,OAAmB,IAAK;EACpD;AACJ;AACA;A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,CAACO,QAAQ,CAAC4B,mBAAmB,EAAE;AAC1C,CAAC;AAAC"}
1
+ {"version":3,"names":["createAcoModels","context","cms","console","warn","isInstallationPending","tenancy","i18n","locale","getContentLocale","WebinyError","groupId","cmsGroupPlugin","CmsGroupPlugin","id","slug","name","description","icon","isPrivate","modelDefinitions","createFolderModelDefinition","createSearchModelDefinition","cmsModelPlugins","map","modelDefinition","modelFactory","group","contentModelGroup","tenant","getCurrentTenant","code","plugins","register"],"sources":["createAcoModels.ts"],"sourcesContent":["import { CmsGroupPlugin } from \"@webiny/api-headless-cms\";\nimport { CmsContext } from \"@webiny/api-headless-cms/types\";\nimport WebinyError from \"@webiny/error\";\n\nimport { createFolderModelDefinition } from \"~/folder/folder.model\";\nimport { createSearchModelDefinition } from \"~/record/record.model\";\nimport { modelFactory } from \"~/utils/modelFactory\";\nimport { isInstallationPending } from \"~/utils/isInstallationPending\";\n\nexport const createAcoModels = (context: CmsContext) => {\n /**\n * This should never happen in the actual project.\n * It is to make sure that we load setup context before the CRUD init in our internal code.\n */\n if (!context.cms) {\n console.warn(\"Creating model before cms init.\");\n return;\n }\n\n if (isInstallationPending({ tenancy: context.tenancy, i18n: context.i18n })) {\n return;\n }\n\n const locale = context.i18n.getContentLocale();\n if (!locale) {\n throw new WebinyError(\n \"Missing content locale in api-aco/storageOperations/index.ts\",\n \"LOCALE_ERROR\"\n );\n }\n\n const groupId = \"contentModelGroup_aco\";\n\n /**\n * Create a CmsGroup.\n */\n const cmsGroupPlugin = new CmsGroupPlugin({\n id: groupId,\n slug: \"aco\",\n name: \"ACO\",\n description: \"Group for Advanced Content Organisation and Search\",\n icon: \"fas/folder\",\n isPrivate: true\n });\n\n /**\n * Create CmsModel plugins.\n */\n const modelDefinitions = [createFolderModelDefinition(), createSearchModelDefinition()];\n const cmsModelPlugins = modelDefinitions.map(modelDefinition => {\n return modelFactory({\n group: cmsGroupPlugin.contentModelGroup,\n tenant: context.tenancy.getCurrentTenant().id,\n locale: locale.code,\n modelDefinition\n });\n });\n\n /**\n * Register them so that they are accessible in cms context\n */\n context.plugins.register([cmsGroupPlugin, cmsModelPlugins]);\n};\n"],"mappings":";;;;;;;AAAA;AAEA;AAEA;AACA;AACA;AACA;AAEO,MAAMA,eAAe,GAAIC,OAAmB,IAAK;EACpD;AACJ;AACA;AACA;EACI,IAAI,CAACA,OAAO,CAACC,GAAG,EAAE;IACdC,OAAO,CAACC,IAAI,CAAC,iCAAiC,CAAC;IAC/C;EACJ;EAEA,IAAI,IAAAC,4CAAqB,EAAC;IAAEC,OAAO,EAAEL,OAAO,CAACK,OAAO;IAAEC,IAAI,EAAEN,OAAO,CAACM;EAAK,CAAC,CAAC,EAAE;IACzE;EACJ;EAEA,MAAMC,MAAM,GAAGP,OAAO,CAACM,IAAI,CAACE,gBAAgB,EAAE;EAC9C,IAAI,CAACD,MAAM,EAAE;IACT,MAAM,IAAIE,cAAW,CACjB,8DAA8D,EAC9D,cAAc,CACjB;EACL;EAEA,MAAMC,OAAO,GAAG,uBAAuB;;EAEvC;AACJ;AACA;EACI,MAAMC,cAAc,GAAG,IAAIC,8BAAc,CAAC;IACtCC,EAAE,EAAEH,OAAO;IACXI,IAAI,EAAE,KAAK;IACXC,IAAI,EAAE,KAAK;IACXC,WAAW,EAAE,oDAAoD;IACjEC,IAAI,EAAE,YAAY;IAClBC,SAAS,EAAE;EACf,CAAC,CAAC;;EAEF;AACJ;AACA;EACI,MAAMC,gBAAgB,GAAG,CAAC,IAAAC,mCAA2B,GAAE,EAAE,IAAAC,mCAA2B,GAAE,CAAC;EACvF,MAAMC,eAAe,GAAGH,gBAAgB,CAACI,GAAG,CAACC,eAAe,IAAI;IAC5D,OAAO,IAAAC,0BAAY,EAAC;MAChBC,KAAK,EAAEf,cAAc,CAACgB,iBAAiB;MACvCC,MAAM,EAAE5B,OAAO,CAACK,OAAO,CAACwB,gBAAgB,EAAE,CAAChB,EAAE;MAC7CN,MAAM,EAAEA,MAAM,CAACuB,IAAI;MACnBN;IACJ,CAAC,CAAC;EACN,CAAC,CAAC;;EAEF;AACJ;AACA;EACIxB,OAAO,CAAC+B,OAAO,CAACC,QAAQ,CAAC,CAACrB,cAAc,EAAEW,eAAe,CAAC,CAAC;AAC/D,CAAC;AAAC"}
@@ -1,6 +1,4 @@
1
- import { CmsModel } from "@webiny/api-headless-cms/types";
2
- export declare type FolderModelDefinition = Pick<CmsModel, "name" | "modelId" | "layout" | "titleFieldId" | "description" | "fields" | "isPrivate"> & {
3
- isPrivate: true;
4
- };
1
+ import { CmsPrivateModelFull } from "@webiny/api-headless-cms";
2
+ export declare type FolderModelDefinition = Omit<CmsPrivateModelFull, "noValidate" | "group">;
5
3
  export declare const FOLDER_MODEL_ID = "acoFolder";
6
4
  export declare const createFolderModelDefinition: () => FolderModelDefinition;
@@ -8,7 +8,6 @@ var _createModelField = require("../utils/createModelField");
8
8
  const titleField = () => (0, _createModelField.createModelField)({
9
9
  label: "Title",
10
10
  type: "text",
11
- parent: "folder",
12
11
  validation: [{
13
12
  name: "required",
14
13
  message: "Value is required."
@@ -23,7 +22,6 @@ const titleField = () => (0, _createModelField.createModelField)({
23
22
  const slugField = () => (0, _createModelField.createModelField)({
24
23
  label: "Slug",
25
24
  type: "text",
26
- parent: "folder",
27
25
  validation: [{
28
26
  name: "required",
29
27
  message: "Value is required."
@@ -52,7 +50,6 @@ const slugField = () => (0, _createModelField.createModelField)({
52
50
  const typeField = () => (0, _createModelField.createModelField)({
53
51
  label: "Type",
54
52
  type: "text",
55
- parent: "folder",
56
53
  validation: [{
57
54
  name: "required",
58
55
  message: "Value is required."
@@ -60,8 +57,7 @@ const typeField = () => (0, _createModelField.createModelField)({
60
57
  });
61
58
  const parentIdField = () => (0, _createModelField.createModelField)({
62
59
  label: "Parent Id",
63
- type: "text",
64
- parent: "folder"
60
+ type: "text"
65
61
  });
66
62
  const FOLDER_MODEL_ID = "acoFolder";
67
63
  exports.FOLDER_MODEL_ID = FOLDER_MODEL_ID;
@@ -70,7 +66,7 @@ const createFolderModelDefinition = () => {
70
66
  name: "ACO - Folder",
71
67
  modelId: FOLDER_MODEL_ID,
72
68
  titleFieldId: "title",
73
- layout: [["folder_title"], ["folder_slug"], ["folder_type"], ["folder_parentId"]],
69
+ layout: [["title"], ["slug"], ["type"], ["parentId"]],
74
70
  fields: [titleField(), slugField(), typeField(), parentIdField()],
75
71
  description: "ACO - Folder content model",
76
72
  isPrivate: true
@@ -1 +1 @@
1
- {"version":3,"names":["titleField","createModelField","label","type","parent","validation","name","message","settings","value","slugField","preset","regex","flags","typeField","parentIdField","FOLDER_MODEL_ID","createFolderModelDefinition","modelId","titleFieldId","layout","fields","description","isPrivate"],"sources":["folder.model.ts"],"sourcesContent":["import { CmsModel } from \"@webiny/api-headless-cms/types\";\n\nimport { createModelField } from \"~/utils/createModelField\";\n\nexport type FolderModelDefinition = Pick<\n CmsModel,\n \"name\" | \"modelId\" | \"layout\" | \"titleFieldId\" | \"description\" | \"fields\" | \"isPrivate\"\n> & { isPrivate: true };\n\nconst titleField = () =>\n createModelField({\n label: \"Title\",\n type: \"text\",\n parent: \"folder\",\n validation: [\n {\n name: \"required\",\n message: \"Value is required.\"\n },\n {\n name: \"minLength\",\n settings: {\n value: \"3\"\n },\n message: \"Value is too short.\"\n }\n ]\n });\n\nconst slugField = () =>\n createModelField({\n label: \"Slug\",\n type: \"text\",\n parent: \"folder\",\n validation: [\n {\n name: \"required\",\n message: \"Value is required.\"\n },\n {\n name: \"minLength\",\n settings: {\n value: \"3\"\n },\n message: \"Value is too short.\"\n },\n {\n name: \"maxLength\",\n settings: {\n value: \"100\"\n },\n message: \"Value is too long.\"\n },\n {\n name: \"pattern\",\n settings: {\n preset: \"custom\",\n regex: \"^[a-z0-9]+(-[a-z0-9]+)*$\",\n flags: \"g\"\n },\n message: \"Value must consist of only 'a-z', '0-9' and '-'.\"\n }\n ]\n });\n\nconst typeField = () =>\n createModelField({\n label: \"Type\",\n type: \"text\",\n parent: \"folder\",\n validation: [\n {\n name: \"required\",\n message: \"Value is required.\"\n }\n ]\n });\n\nconst parentIdField = () =>\n createModelField({\n label: \"Parent Id\",\n type: \"text\",\n parent: \"folder\"\n });\n\nexport const FOLDER_MODEL_ID = \"acoFolder\";\n\nexport const createFolderModelDefinition = (): FolderModelDefinition => {\n return {\n name: \"ACO - Folder\",\n modelId: FOLDER_MODEL_ID,\n titleFieldId: \"title\",\n layout: [[\"folder_title\"], [\"folder_slug\"], [\"folder_type\"], [\"folder_parentId\"]],\n fields: [titleField(), slugField(), typeField(), parentIdField()],\n description: \"ACO - Folder content model\",\n isPrivate: true\n };\n};\n"],"mappings":";;;;;;AAEA;AAOA,MAAMA,UAAU,GAAG,MACf,IAAAC,kCAAgB,EAAC;EACbC,KAAK,EAAE,OAAO;EACdC,IAAI,EAAE,MAAM;EACZC,MAAM,EAAE,QAAQ;EAChBC,UAAU,EAAE,CACR;IACIC,IAAI,EAAE,UAAU;IAChBC,OAAO,EAAE;EACb,CAAC,EACD;IACID,IAAI,EAAE,WAAW;IACjBE,QAAQ,EAAE;MACNC,KAAK,EAAE;IACX,CAAC;IACDF,OAAO,EAAE;EACb,CAAC;AAET,CAAC,CAAC;AAEN,MAAMG,SAAS,GAAG,MACd,IAAAT,kCAAgB,EAAC;EACbC,KAAK,EAAE,MAAM;EACbC,IAAI,EAAE,MAAM;EACZC,MAAM,EAAE,QAAQ;EAChBC,UAAU,EAAE,CACR;IACIC,IAAI,EAAE,UAAU;IAChBC,OAAO,EAAE;EACb,CAAC,EACD;IACID,IAAI,EAAE,WAAW;IACjBE,QAAQ,EAAE;MACNC,KAAK,EAAE;IACX,CAAC;IACDF,OAAO,EAAE;EACb,CAAC,EACD;IACID,IAAI,EAAE,WAAW;IACjBE,QAAQ,EAAE;MACNC,KAAK,EAAE;IACX,CAAC;IACDF,OAAO,EAAE;EACb,CAAC,EACD;IACID,IAAI,EAAE,SAAS;IACfE,QAAQ,EAAE;MACNG,MAAM,EAAE,QAAQ;MAChBC,KAAK,EAAE,0BAA0B;MACjCC,KAAK,EAAE;IACX,CAAC;IACDN,OAAO,EAAE;EACb,CAAC;AAET,CAAC,CAAC;AAEN,MAAMO,SAAS,GAAG,MACd,IAAAb,kCAAgB,EAAC;EACbC,KAAK,EAAE,MAAM;EACbC,IAAI,EAAE,MAAM;EACZC,MAAM,EAAE,QAAQ;EAChBC,UAAU,EAAE,CACR;IACIC,IAAI,EAAE,UAAU;IAChBC,OAAO,EAAE;EACb,CAAC;AAET,CAAC,CAAC;AAEN,MAAMQ,aAAa,GAAG,MAClB,IAAAd,kCAAgB,EAAC;EACbC,KAAK,EAAE,WAAW;EAClBC,IAAI,EAAE,MAAM;EACZC,MAAM,EAAE;AACZ,CAAC,CAAC;AAEC,MAAMY,eAAe,GAAG,WAAW;AAAC;AAEpC,MAAMC,2BAA2B,GAAG,MAA6B;EACpE,OAAO;IACHX,IAAI,EAAE,cAAc;IACpBY,OAAO,EAAEF,eAAe;IACxBG,YAAY,EAAE,OAAO;IACrBC,MAAM,EAAE,CAAC,CAAC,cAAc,CAAC,EAAE,CAAC,aAAa,CAAC,EAAE,CAAC,aAAa,CAAC,EAAE,CAAC,iBAAiB,CAAC,CAAC;IACjFC,MAAM,EAAE,CAACrB,UAAU,EAAE,EAAEU,SAAS,EAAE,EAAEI,SAAS,EAAE,EAAEC,aAAa,EAAE,CAAC;IACjEO,WAAW,EAAE,4BAA4B;IACzCC,SAAS,EAAE;EACf,CAAC;AACL,CAAC;AAAC"}
1
+ {"version":3,"names":["titleField","createModelField","label","type","validation","name","message","settings","value","slugField","preset","regex","flags","typeField","parentIdField","FOLDER_MODEL_ID","createFolderModelDefinition","modelId","titleFieldId","layout","fields","description","isPrivate"],"sources":["folder.model.ts"],"sourcesContent":["import { createModelField } from \"~/utils/createModelField\";\nimport { CmsPrivateModelFull } from \"@webiny/api-headless-cms\";\n\nexport type FolderModelDefinition = Omit<CmsPrivateModelFull, \"noValidate\" | \"group\">;\n\nconst titleField = () =>\n createModelField({\n label: \"Title\",\n type: \"text\",\n validation: [\n {\n name: \"required\",\n message: \"Value is required.\"\n },\n {\n name: \"minLength\",\n settings: {\n value: \"3\"\n },\n message: \"Value is too short.\"\n }\n ]\n });\n\nconst slugField = () =>\n createModelField({\n label: \"Slug\",\n type: \"text\",\n validation: [\n {\n name: \"required\",\n message: \"Value is required.\"\n },\n {\n name: \"minLength\",\n settings: {\n value: \"3\"\n },\n message: \"Value is too short.\"\n },\n {\n name: \"maxLength\",\n settings: {\n value: \"100\"\n },\n message: \"Value is too long.\"\n },\n {\n name: \"pattern\",\n settings: {\n preset: \"custom\",\n regex: \"^[a-z0-9]+(-[a-z0-9]+)*$\",\n flags: \"g\"\n },\n message: \"Value must consist of only 'a-z', '0-9' and '-'.\"\n }\n ]\n });\n\nconst typeField = () =>\n createModelField({\n label: \"Type\",\n type: \"text\",\n validation: [\n {\n name: \"required\",\n message: \"Value is required.\"\n }\n ]\n });\n\nconst parentIdField = () =>\n createModelField({\n label: \"Parent Id\",\n type: \"text\"\n });\n\nexport const FOLDER_MODEL_ID = \"acoFolder\";\n\nexport const createFolderModelDefinition = (): FolderModelDefinition => {\n return {\n name: \"ACO - Folder\",\n modelId: FOLDER_MODEL_ID,\n titleFieldId: \"title\",\n layout: [[\"title\"], [\"slug\"], [\"type\"], [\"parentId\"]],\n fields: [titleField(), slugField(), typeField(), parentIdField()],\n description: \"ACO - Folder content model\",\n isPrivate: true\n };\n};\n"],"mappings":";;;;;;AAAA;AAKA,MAAMA,UAAU,GAAG,MACf,IAAAC,kCAAgB,EAAC;EACbC,KAAK,EAAE,OAAO;EACdC,IAAI,EAAE,MAAM;EACZC,UAAU,EAAE,CACR;IACIC,IAAI,EAAE,UAAU;IAChBC,OAAO,EAAE;EACb,CAAC,EACD;IACID,IAAI,EAAE,WAAW;IACjBE,QAAQ,EAAE;MACNC,KAAK,EAAE;IACX,CAAC;IACDF,OAAO,EAAE;EACb,CAAC;AAET,CAAC,CAAC;AAEN,MAAMG,SAAS,GAAG,MACd,IAAAR,kCAA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E,4BAA4B;IACzCC,SAAS,EAAE;EACf,CAAC;AACL,CAAC;AAAC"}
package/index.d.ts CHANGED
@@ -1 +1 @@
1
- export declare const createACO: () => (import("@webiny/api").ContextPlugin<import("./types").AcoContext> | import("@webiny/api-headless-cms/types").CmsModelFieldToGraphQLPlugin<import("@webiny/api-headless-cms/types").CmsModelField>[] | import("@webiny/api").ContextPlugin<import("@webiny/api-admin-settings/types").AdminSettingsContext>)[];
1
+ export declare const createAco: () => (import("@webiny/api").ContextPlugin<import("./types").AcoContext> | import("@webiny/api-headless-cms/types").CmsModelFieldToGraphQLPlugin<import("@webiny/api-headless-cms/types").CmsModelField>[] | import("@webiny/api").ContextPlugin<import("@webiny/api-admin-settings/types").AdminSettingsContext>)[];
package/index.js CHANGED
@@ -3,12 +3,12 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.createACO = void 0;
6
+ exports.createAco = void 0;
7
7
  var _apiAdminSettings = require("@webiny/api-admin-settings");
8
8
  var _createAcoContext = require("./createAcoContext");
9
9
  var _createAcoFields = require("./createAcoFields");
10
10
  var _createAcoGraphQL = require("./createAcoGraphQL");
11
- const createACO = () => {
11
+ const createAco = () => {
12
12
  return [...(0, _apiAdminSettings.createAdminSettingsContext)(), (0, _createAcoContext.createAcoContext)(), (0, _createAcoFields.createAcoFields)(), (0, _createAcoGraphQL.createAcoGraphQL)()];
13
13
  };
14
- exports.createACO = createACO;
14
+ exports.createAco = createAco;
package/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"names":["createACO","createAdminSettingsContext","createAcoContext","createAcoFields","createAcoGraphQL"],"sources":["index.ts"],"sourcesContent":["import { createAdminSettingsContext } from \"@webiny/api-admin-settings\";\n\nimport { createAcoContext } from \"~/createAcoContext\";\nimport { createAcoFields } from \"~/createAcoFields\";\nimport { createAcoGraphQL } from \"~/createAcoGraphQL\";\n\nexport const createACO = () => {\n return [\n ...createAdminSettingsContext(),\n createAcoContext(),\n createAcoFields(),\n createAcoGraphQL()\n ];\n};\n"],"mappings":";;;;;;AAAA;AAEA;AACA;AACA;AAEO,MAAMA,SAAS,GAAG,MAAM;EAC3B,OAAO,CACH,GAAG,IAAAC,4CAA0B,GAAE,EAC/B,IAAAC,kCAAgB,GAAE,EAClB,IAAAC,gCAAe,GAAE,EACjB,IAAAC,kCAAgB,GAAE,CACrB;AACL,CAAC;AAAC"}
1
+ {"version":3,"names":["createAco","createAdminSettingsContext","createAcoContext","createAcoFields","createAcoGraphQL"],"sources":["index.ts"],"sourcesContent":["import { createAdminSettingsContext } from \"@webiny/api-admin-settings\";\n\nimport { createAcoContext } from \"~/createAcoContext\";\nimport { createAcoFields } from \"~/createAcoFields\";\nimport { createAcoGraphQL } from \"~/createAcoGraphQL\";\n\nexport const createAco = () => {\n return [\n ...createAdminSettingsContext(),\n createAcoContext(),\n createAcoFields(),\n createAcoGraphQL()\n ];\n};\n"],"mappings":";;;;;;AAAA;AAEA;AACA;AACA;AAEO,MAAMA,SAAS,GAAG,MAAM;EAC3B,OAAO,CACH,GAAG,IAAAC,4CAA0B,GAAE,EAC/B,IAAAC,kCAAgB,GAAE,EAClB,IAAAC,gCAAe,GAAE,EACjB,IAAAC,kCAAgB,GAAE,CACrB;AACL,CAAC;AAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@webiny/api-aco",
3
- "version": "0.0.0-unstable.b02d94bba0",
3
+ "version": "0.0.0-unstable.c2780f51fe",
4
4
  "main": "index.js",
5
5
  "keywords": [
6
6
  "aco:base"
@@ -27,32 +27,32 @@
27
27
  "@babel/preset-env": "^7.19.4",
28
28
  "@babel/preset-typescript": "^7.18.6",
29
29
  "@babel/runtime": "^7.19.0",
30
- "@webiny/api-headless-cms-ddb": "^0.0.0-unstable.b02d94bba0",
31
- "@webiny/api-i18n-ddb": "^0.0.0-unstable.b02d94bba0",
32
- "@webiny/api-security-so-ddb": "^0.0.0-unstable.b02d94bba0",
33
- "@webiny/api-tenancy-so-ddb": "^0.0.0-unstable.b02d94bba0",
34
- "@webiny/api-wcp": "^0.0.0-unstable.b02d94bba0",
35
- "@webiny/cli": "^0.0.0-unstable.b02d94bba0",
36
- "@webiny/handler-aws": "^0.0.0-unstable.b02d94bba0",
37
- "@webiny/plugins": "^0.0.0-unstable.b02d94bba0",
38
- "@webiny/project-utils": "^0.0.0-unstable.b02d94bba0",
30
+ "@webiny/api-headless-cms-ddb": "^0.0.0-unstable.c2780f51fe",
31
+ "@webiny/api-i18n-ddb": "^0.0.0-unstable.c2780f51fe",
32
+ "@webiny/api-security-so-ddb": "^0.0.0-unstable.c2780f51fe",
33
+ "@webiny/api-tenancy-so-ddb": "^0.0.0-unstable.c2780f51fe",
34
+ "@webiny/api-wcp": "^0.0.0-unstable.c2780f51fe",
35
+ "@webiny/cli": "^0.0.0-unstable.c2780f51fe",
36
+ "@webiny/handler-aws": "^0.0.0-unstable.c2780f51fe",
37
+ "@webiny/plugins": "^0.0.0-unstable.c2780f51fe",
38
+ "@webiny/project-utils": "^0.0.0-unstable.c2780f51fe",
39
39
  "rimraf": "^3.0.2",
40
40
  "ttypescript": "^1.5.13",
41
41
  "typescript": "^4.7.4"
42
42
  },
43
43
  "dependencies": {
44
- "@webiny/api": "0.0.0-unstable.b02d94bba0",
45
- "@webiny/api-admin-settings": "0.0.0-unstable.b02d94bba0",
46
- "@webiny/api-headless-cms": "0.0.0-unstable.b02d94bba0",
47
- "@webiny/api-i18n": "0.0.0-unstable.b02d94bba0",
48
- "@webiny/api-security": "0.0.0-unstable.b02d94bba0",
49
- "@webiny/api-tenancy": "0.0.0-unstable.b02d94bba0",
50
- "@webiny/error": "0.0.0-unstable.b02d94bba0",
51
- "@webiny/handler": "0.0.0-unstable.b02d94bba0",
52
- "@webiny/handler-graphql": "0.0.0-unstable.b02d94bba0",
53
- "@webiny/pubsub": "0.0.0-unstable.b02d94bba0",
54
- "@webiny/utils": "0.0.0-unstable.b02d94bba0",
44
+ "@webiny/api": "0.0.0-unstable.c2780f51fe",
45
+ "@webiny/api-admin-settings": "0.0.0-unstable.c2780f51fe",
46
+ "@webiny/api-headless-cms": "0.0.0-unstable.c2780f51fe",
47
+ "@webiny/api-i18n": "0.0.0-unstable.c2780f51fe",
48
+ "@webiny/api-security": "0.0.0-unstable.c2780f51fe",
49
+ "@webiny/api-tenancy": "0.0.0-unstable.c2780f51fe",
50
+ "@webiny/error": "0.0.0-unstable.c2780f51fe",
51
+ "@webiny/handler": "0.0.0-unstable.c2780f51fe",
52
+ "@webiny/handler-graphql": "0.0.0-unstable.c2780f51fe",
53
+ "@webiny/pubsub": "0.0.0-unstable.c2780f51fe",
54
+ "@webiny/utils": "0.0.0-unstable.c2780f51fe",
55
55
  "lodash": "4.17.21"
56
56
  },
57
- "gitHead": "b02d94bba01eb4d2b17732279216fbc1c7ab5cd5"
57
+ "gitHead": "c2780f51fe628e1ef0f6b55c2bce9b74d3470d79"
58
58
  }
@@ -1,6 +1,4 @@
1
- import { CmsModel } from "@webiny/api-headless-cms/types";
2
- export declare type SearchRecordModelDefinition = Pick<CmsModel, "name" | "modelId" | "layout" | "titleFieldId" | "description" | "fields" | "isPrivate"> & {
3
- isPrivate: true;
4
- };
1
+ import { CmsPrivateModelFull } from "@webiny/api-headless-cms";
2
+ export declare type SearchRecordModelDefinition = Omit<CmsPrivateModelFull, "noValidate" | "group">;
5
3
  export declare const SEARCH_RECORD_MODEL_ID = "acoSearchRecord";
6
4
  export declare const createSearchModelDefinition: () => SearchRecordModelDefinition;
@@ -8,7 +8,6 @@ var _createModelField = require("../utils/createModelField");
8
8
  const typeField = () => (0, _createModelField.createModelField)({
9
9
  label: "Type",
10
10
  type: "text",
11
- parent: "searchRecord",
12
11
  validation: [{
13
12
  name: "required",
14
13
  message: "Value is required."
@@ -16,18 +15,15 @@ const typeField = () => (0, _createModelField.createModelField)({
16
15
  });
17
16
  const titleField = () => (0, _createModelField.createModelField)({
18
17
  label: "Title",
19
- type: "text",
20
- parent: "searchRecord"
18
+ type: "text"
21
19
  });
22
20
  const contentField = () => (0, _createModelField.createModelField)({
23
21
  label: "Content",
24
- type: "text",
25
- parent: "searchRecord"
22
+ type: "text"
26
23
  });
27
24
  const locationField = fields => (0, _createModelField.createModelField)({
28
25
  label: "Location",
29
26
  type: "object",
30
- parent: "searchRecord",
31
27
  multipleValues: false,
32
28
  settings: {
33
29
  fields
@@ -36,7 +32,6 @@ const locationField = fields => (0, _createModelField.createModelField)({
36
32
  const locationFolderIdField = () => (0, _createModelField.createModelField)({
37
33
  label: "Folder Id",
38
34
  type: "text",
39
- parent: "searchRecord Location",
40
35
  validation: [{
41
36
  name: "required",
42
37
  message: "Value is required."
@@ -44,8 +39,7 @@ const locationFolderIdField = () => (0, _createModelField.createModelField)({
44
39
  });
45
40
  const dataField = () => (0, _createModelField.createModelField)({
46
41
  label: "Data",
47
- type: "wby-aco-json",
48
- parent: "searchRecord"
42
+ type: "wby-aco-json"
49
43
  });
50
44
  const SEARCH_RECORD_MODEL_ID = "acoSearchRecord";
51
45
  exports.SEARCH_RECORD_MODEL_ID = SEARCH_RECORD_MODEL_ID;
@@ -54,7 +48,7 @@ const createSearchModelDefinition = () => {
54
48
  name: "ACO - Search Record",
55
49
  modelId: SEARCH_RECORD_MODEL_ID,
56
50
  titleFieldId: "title",
57
- layout: [["searchRecord_type"], ["searchRecord_title"], ["searchRecord_content"], ["searchRecord_location"], ["searchRecord_data"]],
51
+ layout: [["type"], ["title"], ["content"], ["location"], ["data"]],
58
52
  fields: [typeField(), titleField(), contentField(), locationField([locationFolderIdField()]), dataField()],
59
53
  description: "ACO - Search record model",
60
54
  isPrivate: true
@@ -1 +1 @@
1
- {"version":3,"names":["typeField","createModelField","label","type","parent","validation","name","message","titleField","contentField","locationField","fields","multipleValues","settings","locationFolderIdField","dataField","SEARCH_RECORD_MODEL_ID","createSearchModelDefinition","modelId","titleFieldId","layout","description","isPrivate"],"sources":["record.model.ts"],"sourcesContent":["import { CmsModel, CmsModelField } from \"@webiny/api-headless-cms/types\";\n\nimport { createModelField } from \"~/utils/createModelField\";\n\nexport type SearchRecordModelDefinition = Pick<\n CmsModel,\n \"name\" | \"modelId\" | \"layout\" | \"titleFieldId\" | \"description\" | \"fields\" | \"isPrivate\"\n> & { isPrivate: true };\n\nconst typeField = () =>\n createModelField({\n label: \"Type\",\n type: \"text\",\n parent: \"searchRecord\",\n validation: [\n {\n name: \"required\",\n message: \"Value is required.\"\n }\n ]\n });\n\nconst titleField = () =>\n createModelField({\n label: \"Title\",\n type: \"text\",\n parent: \"searchRecord\"\n });\n\nconst contentField = () =>\n createModelField({\n label: \"Content\",\n type: \"text\",\n parent: \"searchRecord\"\n });\n\nconst locationField = (fields: CmsModelField[]) =>\n createModelField({\n label: \"Location\",\n type: \"object\",\n parent: \"searchRecord\",\n multipleValues: false,\n settings: { fields }\n });\n\nconst locationFolderIdField = () =>\n createModelField({\n label: \"Folder Id\",\n type: \"text\",\n parent: \"searchRecord Location\",\n validation: [\n {\n name: \"required\",\n message: \"Value is required.\"\n }\n ]\n });\n\nconst dataField = () =>\n createModelField({\n label: \"Data\",\n type: \"wby-aco-json\",\n parent: \"searchRecord\"\n });\n\nexport const SEARCH_RECORD_MODEL_ID = \"acoSearchRecord\";\n\nexport const createSearchModelDefinition = (): SearchRecordModelDefinition => {\n return {\n name: \"ACO - Search Record\",\n modelId: SEARCH_RECORD_MODEL_ID,\n titleFieldId: \"title\",\n layout: [\n [\"searchRecord_type\"],\n [\"searchRecord_title\"],\n [\"searchRecord_content\"],\n [\"searchRecord_location\"],\n [\"searchRecord_data\"]\n ],\n fields: [\n typeField(),\n titleField(),\n contentField(),\n locationField([locationFolderIdField()]),\n dataField()\n ],\n description: \"ACO - Search record model\",\n isPrivate: true\n };\n};\n"],"mappings":";;;;;;AAEA;AAOA,MAAMA,SAAS,GAAG,MACd,IAAAC,kCAAgB,EAAC;EACbC,KAAK,EAAE,MAAM;EACbC,IAAI,EAAE,MAAM;EACZC,MAAM,EAAE,cAAc;EACtBC,U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AuB,CAAC,EACzB,CAAC,mBAAmB,CAAC,CACxB;IACDT,MAAM,EAAE,CACJX,SAAS,EAAE,EACXQ,UAAU,EAAE,EACZC,YAAY,EAAE,EACdC,aAAa,CAAC,CAACI,qBAAqB,EAAE,CAAC,CAAC,EACxCC,SAAS,EAAE,CACd;IACDM,WAAW,EAAE,2BAA2B;IACxCC,SAAS,EAAE;EACf,CAAC;AACL,CAAC;AAAC"}
1
+ {"version":3,"names":["typeField","createModelField","label","type","validation","name","message","titleField","contentField","locationField","fields","multipleValues","settings","locationFolderIdField","dataField","SEARCH_RECORD_MODEL_ID","createSearchModelDefinition","modelId","titleFieldId","layout","description","isPrivate"],"sources":["record.model.ts"],"sourcesContent":["import { CmsModelField } from \"@webiny/api-headless-cms/types\";\nimport { createModelField } from \"~/utils/createModelField\";\nimport { CmsPrivateModelFull } from \"@webiny/api-headless-cms\";\n\nexport type SearchRecordModelDefinition = Omit<CmsPrivateModelFull, \"noValidate\" | \"group\">;\n\nconst typeField = () =>\n createModelField({\n label: \"Type\",\n type: \"text\",\n validation: [\n {\n name: \"required\",\n message: \"Value is required.\"\n }\n ]\n });\n\nconst titleField = () =>\n createModelField({\n label: \"Title\",\n type: \"text\"\n });\n\nconst contentField = () =>\n createModelField({\n label: \"Content\",\n type: \"text\"\n });\n\nconst locationField = (fields: CmsModelField[]) =>\n createModelField({\n label: \"Location\",\n type: \"object\",\n multipleValues: false,\n settings: { fields }\n });\n\nconst locationFolderIdField = () =>\n createModelField({\n label: \"Folder Id\",\n type: \"text\",\n validation: [\n {\n name: \"required\",\n message: \"Value is required.\"\n }\n ]\n });\n\nconst dataField = () =>\n createModelField({\n label: \"Data\",\n type: \"wby-aco-json\"\n });\n\nexport const SEARCH_RECORD_MODEL_ID = \"acoSearchRecord\";\n\nexport const createSearchModelDefinition = (): SearchRecordModelDefinition => {\n return {\n name: \"ACO - Search Record\",\n modelId: SEARCH_RECORD_MODEL_ID,\n titleFieldId: \"title\",\n layout: [[\"type\"], [\"title\"], [\"content\"], [\"location\"], [\"data\"]],\n fields: [\n typeField(),\n titleField(),\n contentField(),\n locationField([locationFolderIdField()]),\n dataField()\n ],\n description: \"ACO - Search record model\",\n isPrivate: true\n };\n};\n"],"mappings":";;;;;;AACA;AAKA,MAAMA,SAAS,GAAG,MACd,IAAAC,kCAAgB,EAAC;EACbC,KAAK,EAAE,MAAM;EACbC,IAAI,EAAE,MAAM;EACZC,UAAU,EAAE,CACR;IACIC,IAAI,EAAE,UAAU;IAChBC,OAAO,EAAE;EACb,CAAC;AAET,CAAC,CAAC;AAEN,MAAMC,UAAU,GAAG,MACf,IAAAN,kCAAgB,EAAC;EACbC,KAAK,EAAE,OAAO;EACdC,IAAI,EAAE;AACV,CAAC,CAAC;AAEN,MAAMK,YAAY,GAAG,MACjB,IAAAP,kCAAgB,EAAC;EACbC,KAAK,EAAE,SAAS;EAChBC,IAAI,EAAE;AACV,CAAC,CAAC;AAEN,MAAMM,aAAa,GAAIC,MAAuB,IAC1C,IAAAT,kCAAgB,EAAC;EACbC,KAAK,EAAE,UAAU;EACjBC,IAAI,EAAE,QAAQ;EACdQ,cAAc,EAAE,KAAK;EACrBC,QAAQ,EAAE;IAAEF;EAAO;AACvB,CAAC,CAAC;AAEN,MAAMG,qBAAqB,GAAG,MAC1B,IAAAZ,kCAAgB,EAAC;EACbC,KAAK,EAAE,WAAW;EAClBC,IAAI,EAAE,MAAM;EACZC,UAAU,EAAE,CACR;IACIC,IAAI,EAAE,UAAU;IAChBC,OAAO,EAAE;EACb,CAAC;AAET,CAAC,CAAC;AAEN,MAAMQ,SAAS,GAAG,MACd,IAAAb,kCAAgB,EAAC;EACbC,KAAK,EAAE,MAAM;EACbC,IAAI,EAAE;AACV,CAAC,CAAC;AAEC,MAAMY,sBAAsB,GAAG,iBAAiB;AAAC;AAEjD,MAAMC,2BAA2B,GAAG,MAAmC;EAC1E,OAAO;IACHX,IAAI,EAAE,qBAAqB;IAC3BY,OAAO,EAAEF,sBAAsB;IAC/BG,YAAY,EAAE,OAAO;IACrBC,MAAM,EAAE,CAAC,CAAC,MAAM,CAAC,EAAE,CAAC,OAAO,CAAC,EAAE,CAAC,SAAS,CAAC,EAAE,CAAC,UAAU,CAAC,EAAE,CAAC,MAAM,CAAC,CAAC;IAClET,MAAM,EAAE,CACJV,SAAS,EAAE,EACXO,UAAU,EAAE,EACZC,YAAY,EAAE,EACdC,aAAa,CAAC,CAACI,qBAAqB,EAAE,CAAC,CAAC,EACxCC,SAAS,EAAE,CACd;IACDM,WAAW,EAAE,2BAA2B;IACxCC,SAAS,EAAE;EACf,CAAC;AACL,CAAC;AAAC"}
@@ -6,7 +6,6 @@ Object.defineProperty(exports, "__esModule", {
6
6
  });
7
7
  exports.createSearchRecordOperations = void 0;
8
8
  var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
9
- var _valueKeyStorageConverter = require("@webiny/api-headless-cms/utils/converters/valueKeyStorageConverter");
10
9
  var _error = _interopRequireDefault(require("@webiny/error"));
11
10
  var _record = require("./record.model");
12
11
  var _createAcoStorageOperations = require("../createAcoStorageOperations");
@@ -15,21 +14,14 @@ var _createOperationsWrapper = require("../utils/createOperationsWrapper");
15
14
  var _getFieldValues = require("../utils/getFieldValues");
16
15
  const createSearchRecordOperations = params => {
17
16
  const {
18
- cms,
19
- getCmsContext
17
+ cms
20
18
  } = params;
21
19
  const {
22
20
  withModel
23
21
  } = (0, _createOperationsWrapper.createOperationsWrapper)((0, _objectSpread2.default)((0, _objectSpread2.default)({}, params), {}, {
24
22
  modelName: _record.SEARCH_RECORD_MODEL_ID
25
23
  }));
26
- const getRecord = async (initialModel, id) => {
27
- const context = getCmsContext();
28
- const model = (0, _valueKeyStorageConverter.attachCmsModelFieldConverters)({
29
- model: initialModel,
30
- plugins: context.plugins
31
- });
32
-
24
+ const getRecord = async (model, id) => {
33
25
  /**
34
26
  * The record "id" has been passed by the original entry.
35
27
  * We need to retrieve it via `cms.storageOperations.entries.getLatestByIds()` method and return the first one.
@@ -1 +1 @@
1
- {"version":3,"names":["createSearchRecordOperations","params","cms","getCmsContext","withModel","createOperationsWrapper","modelName","SEARCH_RECORD_MODEL_ID","getRecord","initialModel","id","context","model","attachCmsModelFieldConverters","plugins","revisions","storageOperations","entries","getLatestByIds","ids","length","WebinyError","record","getFieldValues","baseFields","listRecords","sort","where","meta","listLatestEntries","createListSort","map","entry","createRecord","data","createEntry","updateRecord","original","input","updateEntry","deleteRecord","deleteEntry"],"sources":["record.so.ts"],"sourcesContent":["import { attachCmsModelFieldConverters } from \"@webiny/api-headless-cms/utils/converters/valueKeyStorageConverter\";\n\nimport WebinyError from \"@webiny/error\";\n\nimport { SEARCH_RECORD_MODEL_ID } from \"./record.model\";\nimport { baseFields, CreateAcoStorageOperationsParams } from \"~/createAcoStorageOperations\";\nimport { createListSort } from \"~/utils/createListSort\";\nimport { createOperationsWrapper } from \"~/utils/createOperationsWrapper\";\nimport { getFieldValues } from \"~/utils/getFieldValues\";\n\nimport { AcoSearchRecordStorageOperations } from \"./record.types\";\nimport { CmsModel } from \"@webiny/api-headless-cms/types\";\n\nexport const createSearchRecordOperations = (\n params: CreateAcoStorageOperationsParams\n): AcoSearchRecordStorageOperations => {\n const { cms, getCmsContext } = params;\n\n const { withModel } = createOperationsWrapper({\n ...params,\n modelName: SEARCH_RECORD_MODEL_ID\n });\n\n const getRecord = async (initialModel: CmsModel, id: string) => {\n const context = getCmsContext();\n\n const model = attachCmsModelFieldConverters({\n model: initialModel,\n plugins: context.plugins\n });\n\n /**\n * The record \"id\" has been passed by the original entry.\n * We need to retrieve it via `cms.storageOperations.entries.getLatestByIds()` method and return the first one.\n */\n const revisions = await cms.storageOperations.entries.getLatestByIds(model, {\n ids: [id]\n });\n\n if (revisions.length === 0) {\n throw new WebinyError(\"Record not found.\", \"NOT_FOUND\", {\n id\n });\n }\n\n return revisions[0];\n };\n\n return {\n async getRecord({ id }) {\n return withModel(async model => {\n const record = await getRecord(model, id);\n return getFieldValues(record, baseFields, true);\n });\n },\n listRecords(params) {\n return withModel(async model => {\n const { sort, where } = params;\n\n const [entries, meta] = await cms.listLatestEntries(model, {\n ...params,\n sort: createListSort(sort),\n where: {\n ...(where || {})\n }\n });\n\n return [entries.map(entry => getFieldValues(entry, baseFields, true)), meta];\n });\n },\n createRecord({ data }) {\n return withModel(async model => {\n const entry = await cms.createEntry(model, data);\n\n return getFieldValues(entry, baseFields, true);\n });\n },\n updateRecord({ id, data }) {\n return withModel(async model => {\n const original = await getRecord(model, id);\n\n const input = {\n ...original,\n ...data\n };\n\n const entry = await cms.updateEntry(model, original.id, input);\n\n return getFieldValues(entry, baseFields, true);\n });\n },\n deleteRecord({ id }) {\n return withModel(async model => {\n await cms.deleteEntry(model, id);\n return true;\n });\n }\n };\n};\n"],"mappings":";;;;;;;;AAAA;AAEA;AAEA;AACA;AACA;AACA;AACA;AAKO,MAAMA,4BAA4B,GACrCC,MAAwC,IACL;EACnC,MAAM;IAAEC,GAAG;IAAEC;EAAc,CAAC,GAAGF,MAAM;EAErC,MAAM;IAAEG;EAAU,CAAC,GAAG,IAAAC,gDAAuB,8DACtCJ,MAAM;IACTK,SAAS,EAAEC;EAAsB,GACnC;EAEF,MAAMC,SAAS,GAAG,OAAOC,YAAsB,EAAEC,EAAU,KAAK;IAC5D,MAAMC,OAAO,GAAGR,aAAa,EAAE;IAE/B,MAAMS,KAAK,GAAG,IAAAC,uDAA6B,EAAC;MACxCD,KAAK,EAAEH,YAAY;MACnBK,OAAO,EAAEH,OAAO,CAACG;IACrB,CAAC,CAAC;;IAEF;AACR;AACA;AACA;IACQ,MAAMC,SAAS,GAAG,MAAMb,GAAG,CAACc,iBAAiB,CAACC,OAAO,CAACC,cAAc,CAACN,KAAK,EAAE;MACxEO,GAAG,EAAE,CAACT,EAAE;IACZ,CAAC,CAAC;IAEF,IAAIK,SAAS,CAACK,MAAM,KAAK,CAAC,EAAE;MACxB,MAAM,IAAIC,cAAW,CAAC,mBAAmB,EAAE,WAAW,EAAE;QAC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S,CAAC,MAAMQ,KAAK,IAAI;QAC5B,MAAMyB,QAAQ,GAAG,MAAM7B,SAAS,CAACI,KAAK,EAAEF,EAAE,CAAC;QAE3C,MAAM4B,KAAK,+DACJD,QAAQ,GACRH,IAAI,CACV;QAED,MAAMF,KAAK,GAAG,MAAM9B,GAAG,CAACqC,WAAW,CAAC3B,KAAK,EAAEyB,QAAQ,CAAC3B,EAAE,EAAE4B,KAAK,CAAC;QAE9D,OAAO,IAAAf,8BAAc,EAACS,KAAK,EAAER,sCAAU,EAAE,IAAI,CAAC;MAClD,CAAC,CAAC;IACN,CAAC;IACDgB,YAAY,CAAC;MAAE9B;IAAG,CAAC,EAAE;MACjB,OAAON,SAAS,CAAC,MAAMQ,KAAK,IAAI;QAC5B,MAAMV,GAAG,CAACuC,WAAW,CAAC7B,KAAK,EAAEF,EAAE,CAAC;QAChC,OAAO,IAAI;MACf,CAAC,CAAC;IACN;EACJ,CAAC;AACL,CAAC;AAAC"}
1
+ {"version":3,"names":["createSearchRecordOperations","params","cms","withModel","createOperationsWrapper","modelName","SEARCH_RECORD_MODEL_ID","getRecord","model","id","revisions","storageOperations","entries","getLatestByIds","ids","length","WebinyError","record","getFieldValues","baseFields","listRecords","sort","where","meta","listLatestEntries","createListSort","map","entry","createRecord","data","createEntry","updateRecord","original","input","updateEntry","deleteRecord","deleteEntry"],"sources":["record.so.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport { SEARCH_RECORD_MODEL_ID } from \"./record.model\";\nimport { baseFields, CreateAcoStorageOperationsParams } from \"~/createAcoStorageOperations\";\nimport { createListSort } from \"~/utils/createListSort\";\nimport { createOperationsWrapper } from \"~/utils/createOperationsWrapper\";\nimport { getFieldValues } from \"~/utils/getFieldValues\";\nimport { AcoSearchRecordStorageOperations } from \"./record.types\";\nimport { CmsModel } from \"@webiny/api-headless-cms/types\";\n\nexport const createSearchRecordOperations = (\n params: CreateAcoStorageOperationsParams\n): AcoSearchRecordStorageOperations => {\n const { cms } = params;\n\n const { withModel } = createOperationsWrapper({\n ...params,\n modelName: SEARCH_RECORD_MODEL_ID\n });\n\n const getRecord = async (model: CmsModel, id: string) => {\n /**\n * The record \"id\" has been passed by the original entry.\n * We need to retrieve it via `cms.storageOperations.entries.getLatestByIds()` method and return the first one.\n */\n const revisions = await cms.storageOperations.entries.getLatestByIds(model, {\n ids: [id]\n });\n\n if (revisions.length === 0) {\n throw new WebinyError(\"Record not found.\", \"NOT_FOUND\", {\n id\n });\n }\n\n return revisions[0];\n };\n\n return {\n async getRecord({ id }) {\n return withModel(async model => {\n const record = await getRecord(model, id);\n return getFieldValues(record, baseFields, true);\n });\n },\n listRecords(params) {\n return withModel(async model => {\n const { sort, where } = params;\n\n const [entries, meta] = await cms.listLatestEntries(model, {\n ...params,\n sort: createListSort(sort),\n where: {\n ...(where || {})\n }\n });\n\n return [entries.map(entry => getFieldValues(entry, baseFields, true)), meta];\n });\n },\n createRecord({ data }) {\n return withModel(async model => {\n const entry = await cms.createEntry(model, data);\n\n return getFieldValues(entry, baseFields, true);\n });\n },\n updateRecord({ id, data }) {\n return withModel(async model => {\n const original = await getRecord(model, id);\n\n const input = {\n ...original,\n ...data\n };\n\n const entry = await cms.updateEntry(model, original.id, input);\n\n return getFieldValues(entry, baseFields, true);\n });\n },\n deleteRecord({ id }) {\n return withModel(async model => {\n await cms.deleteEntry(model, id);\n return true;\n });\n }\n };\n};\n"],"mappings":";;;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AAIO,MAAMA,4BAA4B,GACrCC,MAAwC,IACL;EACnC,MAAM;IAAEC;EAAI,CAAC,GAAGD,MAAM;EAEtB,MAAM;IAAEE;EAAU,CAAC,GAAG,IAAAC,gDAAuB,8DACtCH,MAAM;IACTI,SAAS,EAAEC;EAAsB,GACnC;EAEF,MAAMC,SAAS,GAAG,OAAOC,KAAe,EAAEC,EAAU,KAAK;IACrD;AACR;AACA;AACA;IACQ,MAAMC,SAAS,GAAG,MAAMR,GAAG,CAACS,iBAAi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EAAEqB,IAAI,CAAC;QAEhD,OAAO,IAAAX,8BAAc,EAACS,KAAK,EAAER,sCAAU,EAAE,IAAI,CAAC;MAClD,CAAC,CAAC;IACN,CAAC;IACDY,YAAY,CAAC;MAAEtB,EAAE;MAAEoB;IAAK,CAAC,EAAE;MACvB,OAAO1B,SAAS,CAAC,MAAMK,KAAK,IAAI;QAC5B,MAAMwB,QAAQ,GAAG,MAAMzB,SAAS,CAACC,KAAK,EAAEC,EAAE,CAAC;QAE3C,MAAMwB,KAAK,+DACJD,QAAQ,GACRH,IAAI,CACV;QAED,MAAMF,KAAK,GAAG,MAAMzB,GAAG,CAACgC,WAAW,CAAC1B,KAAK,EAAEwB,QAAQ,CAACvB,EAAE,EAAEwB,KAAK,CAAC;QAE9D,OAAO,IAAAf,8BAAc,EAACS,KAAK,EAAER,sCAAU,EAAE,IAAI,CAAC;MAClD,CAAC,CAAC;IACN,CAAC;IACDgB,YAAY,CAAC;MAAE1B;IAAG,CAAC,EAAE;MACjB,OAAON,SAAS,CAAC,MAAMK,KAAK,IAAI;QAC5B,MAAMN,GAAG,CAACkC,WAAW,CAAC5B,KAAK,EAAEC,EAAE,CAAC;QAChC,OAAO,IAAI;MACf,CAAC,CAAC;IACN;EACJ,CAAC;AACL,CAAC;AAAC"}
package/types.d.ts CHANGED
@@ -41,3 +41,7 @@ export declare type AcoStorageOperations = AcoFolderStorageOperations & AcoSearc
41
41
  export interface AcoContext extends BaseContext, I18NContext, TenancyContext, SecurityContext, CmsContext {
42
42
  aco: AdvancedContentOrganisation;
43
43
  }
44
+ /**
45
+ * @deprecated Use AcoContext instead
46
+ */
47
+ export declare type ACOContext = AcoContext;
package/types.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"names":["ListSortDirection"],"sources":["types.ts"],"sourcesContent":["import { Tenant, TenancyContext } from \"@webiny/api-tenancy/types\";\nimport { Context as BaseContext } from \"@webiny/handler/types\";\nimport { I18NContext, I18NLocale } from \"@webiny/api-i18n/types\";\nimport { SecurityContext, SecurityIdentity } from \"@webiny/api-security/types\";\nimport { CmsContext } from \"@webiny/api-headless-cms/types\";\nimport { AcoSearchRecordCrud, AcoSearchRecordStorageOperations } from \"~/record/record.types\";\nimport { AcoFolderCrud, AcoFolderStorageOperations } from \"~/folder/folder.types\";\n\nexport interface User {\n id: string;\n type: string;\n displayName: string | null;\n}\n\nexport interface ListMeta {\n cursor: string | null;\n totalCount: number;\n hasMoreItems: boolean;\n}\n\nexport enum ListSortDirection {\n ASC,\n DESC\n}\n\nexport type ListSort = Record<string, ListSortDirection>;\n\nexport interface AcoBaseFields {\n id: string;\n entryId: string;\n createdOn: string;\n createdBy: User;\n savedOn: string;\n}\n\nexport interface AdvancedContentOrganisation {\n folder: AcoFolderCrud;\n search: AcoSearchRecordCrud;\n}\n\nexport interface CreateAcoParams {\n getIdentity: () => SecurityIdentity;\n getLocale: () => I18NLocale;\n getTenant: () => Tenant;\n storageOperations: AcoStorageOperations;\n}\n\nexport type AcoStorageOperations = AcoFolderStorageOperations & AcoSearchRecordStorageOperations;\n\nexport interface AcoContext\n extends BaseContext,\n I18NContext,\n TenancyContext,\n SecurityContext,\n CmsContext {\n aco: AdvancedContentOrganisation;\n}\n"],"mappings":";;;;;;IAoBYA,iBAAiB;AAAA;AAAA,WAAjBA,iBAAiB;EAAjBA,iBAAiB,CAAjBA,iBAAiB;EAAjBA,iBAAiB,CAAjBA,iBAAiB;AAAA,GAAjBA,iBAAiB,iCAAjBA,iBAAiB"}
1
+ {"version":3,"names":["ListSortDirection"],"sources":["types.ts"],"sourcesContent":["import { Tenant, TenancyContext } from \"@webiny/api-tenancy/types\";\nimport { Context as BaseContext } from \"@webiny/handler/types\";\nimport { I18NContext, I18NLocale } from \"@webiny/api-i18n/types\";\nimport { SecurityContext, SecurityIdentity } from \"@webiny/api-security/types\";\nimport { CmsContext } from \"@webiny/api-headless-cms/types\";\nimport { AcoSearchRecordCrud, AcoSearchRecordStorageOperations } from \"~/record/record.types\";\nimport { AcoFolderCrud, AcoFolderStorageOperations } from \"~/folder/folder.types\";\n\nexport interface User {\n id: string;\n type: string;\n displayName: string | null;\n}\n\nexport interface ListMeta {\n cursor: string | null;\n totalCount: number;\n hasMoreItems: boolean;\n}\n\nexport enum ListSortDirection {\n ASC,\n DESC\n}\n\nexport type ListSort = Record<string, ListSortDirection>;\n\nexport interface AcoBaseFields {\n id: string;\n entryId: string;\n createdOn: string;\n createdBy: User;\n savedOn: string;\n}\n\nexport interface AdvancedContentOrganisation {\n folder: AcoFolderCrud;\n search: AcoSearchRecordCrud;\n}\n\nexport interface CreateAcoParams {\n getIdentity: () => SecurityIdentity;\n getLocale: () => I18NLocale;\n getTenant: () => Tenant;\n storageOperations: AcoStorageOperations;\n}\n\nexport type AcoStorageOperations = AcoFolderStorageOperations & AcoSearchRecordStorageOperations;\n\nexport interface AcoContext\n extends BaseContext,\n I18NContext,\n TenancyContext,\n SecurityContext,\n CmsContext {\n aco: AdvancedContentOrganisation;\n}\n\n/**\n * @deprecated Use AcoContext instead\n */\nexport type ACOContext = AcoContext;\n"],"mappings":";;;;;;IAoBYA,iBAAiB;AAAA;AAAA,WAAjBA,iBAAiB;EAAjBA,iBAAiB,CAAjBA,iBAAiB;EAAjBA,iBAAiB,CAAjBA,iBAAiB;AAAA,GAAjBA,iBAAiB,iCAAjBA,iBAAiB"}
@@ -1,6 +1,5 @@
1
1
  import { CmsModelField } from "@webiny/api-headless-cms/types";
2
2
  export interface CreateModelFieldParams extends Omit<CmsModelField, "id" | "storageId" | "fieldId"> {
3
3
  fieldId?: string;
4
- parent: string;
5
4
  }
6
5
  export declare const createModelField: (params: CreateModelFieldParams) => CmsModelField;
@@ -11,7 +11,6 @@ const createModelField = params => {
11
11
  label,
12
12
  fieldId: initialFieldId,
13
13
  type,
14
- parent,
15
14
  settings = {},
16
15
  listValidation = [],
17
16
  validation = [],
@@ -22,10 +21,9 @@ const createModelField = params => {
22
21
  }
23
22
  } = params;
24
23
  const fieldId = initialFieldId ? (0, _camelCase.default)(initialFieldId) : (0, _camelCase.default)(label);
25
- const id = `${(0, _camelCase.default)(parent)}_${fieldId}`;
26
24
  return {
27
- id,
28
- storageId: fieldId,
25
+ id: fieldId,
26
+ storageId: `${type}@${fieldId}`,
29
27
  fieldId,
30
28
  label,
31
29
  type,
@@ -1 +1 @@
1
- {"version":3,"names":["createModelField","params","label","fieldId","initialFieldId","type","parent","settings","listValidation","validation","multipleValues","predefinedValues","values","enabled","camelCase","id","storageId"],"sources":["createModelField.ts"],"sourcesContent":["import { CmsModelField } from \"@webiny/api-headless-cms/types\";\nimport camelCase from \"lodash/camelCase\";\n\nexport interface CreateModelFieldParams\n extends Omit<CmsModelField, \"id\" | \"storageId\" | \"fieldId\"> {\n fieldId?: string;\n parent: string;\n}\n\nexport const createModelField = (params: CreateModelFieldParams): CmsModelField => {\n const {\n label,\n fieldId: initialFieldId,\n type,\n parent,\n settings = {},\n listValidation = [],\n validation = [],\n multipleValues = false,\n predefinedValues = {\n values: [],\n enabled: false\n }\n } = params;\n\n const fieldId = initialFieldId ? camelCase(initialFieldId) : camelCase(label);\n const id = `${camelCase(parent)}_${fieldId}`;\n\n return {\n id,\n storageId: fieldId,\n fieldId,\n label,\n type,\n settings,\n listValidation,\n validation,\n multipleValues,\n predefinedValues\n };\n};\n"],"mappings":";;;;;;;AACA;AAQO,MAAMA,gBAAgB,GAAIC,MAA8B,IAAoB;EAC/E,MAAM;IACFC,KAAK;IACLC,OAAO,EAAEC,cAAc;IACvBC,IAAI;IACJC,MAAM;IACNC,QAAQ,GAAG,CAAC,CAAC;IACbC,cAAc,GAAG,EAAE;IACnBC,UAAU,GAAG,EAAE;IACfC,cAAc,GAAG,KAAK;IACtBC,gBAAgB,GAAG;MACfC,MAAM,EAAE,EAAE;MACVC,OAAO,EAAE;IACb;EACJ,CAAC,GAAGZ,MAAM;EAEV,MAAME,OAAO,GAAGC,cAAc,GAAG,IAAAU,kBAAS,EAACV,cAAc,CAAC,GAAG,IAAAU,kBAAS,EAACZ,KAAK,CAAC;EAC7E,MAAMa,EAAE,GAAI,GAAE,IAAAD,kBAAS,EAACR,MAAM,CAAE,IAAGH,OAAQ,EAAC;EAE5C,OAAO;IACHY,EAAE;IACFC,SAAS,EAAEb,OAAO;IAClBA,OAAO;IACPD,KAAK;IACLG,IAAI;IACJE,QAAQ;IACRC,cAAc;IACdC,UAAU;IACVC,cAAc;IACdC;EACJ,CAAC;AACL,CAAC;AAAC"}
1
+ {"version":3,"names":["createModelField","params","label","fieldId","initialFieldId","type","settings","listValidation","validation","multipleValues","predefinedValues","values","enabled","camelCase","id","storageId"],"sources":["createModelField.ts"],"sourcesContent":["import { CmsModelField } from \"@webiny/api-headless-cms/types\";\nimport camelCase from \"lodash/camelCase\";\n\nexport interface CreateModelFieldParams\n extends Omit<CmsModelField, \"id\" | \"storageId\" | \"fieldId\"> {\n fieldId?: string;\n}\n\nexport const createModelField = (params: CreateModelFieldParams): CmsModelField => {\n const {\n label,\n fieldId: initialFieldId,\n type,\n settings = {},\n listValidation = [],\n validation = [],\n multipleValues = false,\n predefinedValues = {\n values: [],\n enabled: false\n }\n } = params;\n\n const fieldId = initialFieldId ? camelCase(initialFieldId) : camelCase(label);\n\n return {\n id: fieldId,\n storageId: `${type}@${fieldId}`,\n fieldId,\n label,\n type,\n settings,\n listValidation,\n validation,\n multipleValues,\n predefinedValues\n };\n};\n"],"mappings":";;;;;;;AACA;AAOO,MAAMA,gBAAgB,GAAIC,MAA8B,IAAoB;EAC/E,MAAM;IACFC,KAAK;IACLC,OAAO,EAAEC,cAAc;IACvBC,IAAI;IACJC,QAAQ,GAAG,CAAC,CAAC;IACbC,cAAc,GAAG,EAAE;IACnBC,UAAU,GAAG,EAAE;IACfC,cAAc,GAAG,KAAK;IACtBC,gBAAgB,GAAG;MACfC,MAAM,EAAE,EAAE;MACVC,OAAO,EAAE;IACb;EACJ,CAAC,GAAGX,MAAM;EAEV,MAAME,OAAO,GAAGC,cAAc,GAAG,IAAAS,kBAAS,EAACT,cAAc,CAAC,GAAG,IAAAS,kBAAS,EAACX,KAAK,CAAC;EAE7E,OAAO;IACHY,EAAE,EAAEX,OAAO;IACXY,SAAS,EAAG,GAAEV,IAAK,IAAGF,OAAQ,EAAC;IAC/BA,OAAO;IACPD,KAAK;IACLG,IAAI;IACJC,QAAQ;IACRC,cAAc;IACdC,UAAU;IACVC,cAAc;IACdC;EACJ,CAAC;AACL,CAAC;AAAC"}
@@ -13,14 +13,14 @@ const createOperationsWrapper = params => {
13
13
  modelName
14
14
  } = params;
15
15
  const withModel = async cb => {
16
- security.disableAuthorization();
17
- const model = await cms.getModel(modelName);
18
- if (!model) {
19
- throw new _error.default(`Could not find "${modelName}" model.`, "MODEL_NOT_FOUND_ERROR");
20
- }
21
- const result = await cb(model);
22
- security.enableAuthorization();
23
- return result;
16
+ return security.withoutAuthorization(async () => {
17
+ const model = await cms.getModel(modelName);
18
+ if (!model) {
19
+ throw new _error.default(`Could not find "${modelName}" model.`, "MODEL_NOT_FOUND_ERROR");
20
+ }
21
+ const result = await cb(model);
22
+ return result;
23
+ });
24
24
  };
25
25
  return {
26
26
  withModel
@@ -1 +1 @@
1
- {"version":3,"names":["createOperationsWrapper","params","cms","security","modelName","withModel","cb","disableAuthorization","model","getModel","WebinyError","result","enableAuthorization"],"sources":["createOperationsWrapper.ts"],"sourcesContent":["import { CreateAcoStorageOperationsParams } from \"~/createAcoStorageOperations\";\nimport { CmsModel } from \"@webiny/api-headless-cms/types\";\nimport WebinyError from \"@webiny/error\";\n\ninterface CreateOperationsWrapperParams extends CreateAcoStorageOperationsParams {\n modelName: string;\n}\n\nexport const createOperationsWrapper = (params: CreateOperationsWrapperParams) => {\n const { cms, security, modelName } = params;\n\n const withModel = async <TResult>(\n cb: (model: CmsModel) => Promise<TResult>\n ): Promise<TResult> => {\n security.disableAuthorization();\n const model = await cms.getModel(modelName);\n\n if (!model) {\n throw new WebinyError(`Could not find \"${modelName}\" model.`, \"MODEL_NOT_FOUND_ERROR\");\n }\n\n const result = await cb(model);\n\n security.enableAuthorization();\n\n return result;\n };\n\n return {\n withModel\n };\n};\n"],"mappings":";;;;;;;AAEA;AAMO,MAAMA,uBAAuB,GAAIC,MAAqC,IAAK;EAC9E,MAAM;IAAEC,GAAG;IAAEC,QAAQ;IAAEC;EAAU,CAAC,GAAGH,MAAM;EAE3C,MAAMI,SAAS,GAAG,MACdC,EAAyC,IACtB;IACnBH,QAAQ,CAACI,oBAAoB,EAAE;IAC/B,MAAMC,KAAK,GAAG,MAAMN,GAAG,CAACO,QAAQ,CAACL,SAAS,CAAC;IAE3C,IAAI,CAACI,KAAK,EAAE;MACR,MAAM,IAAIE,cAAW,CAAE,mBAAkBN,SAAU,UAAS,EAAE,uBAAuB,CAAC;IAC1F;IAEA,MAAMO,MAAM,GAAG,MAAML,EAAE,CAACE,KAAK,CAAC;IAE9BL,QAAQ,CAACS,mBAAmB,EAAE;IAE9B,OAAOD,MAAM;EACjB,CAAC;EAED,OAAO;IACHN;EACJ,CAAC;AACL,CAAC;AAAC"}
1
+ {"version":3,"names":["createOperationsWrapper","params","cms","security","modelName","withModel","cb","withoutAuthorization","model","getModel","WebinyError","result"],"sources":["createOperationsWrapper.ts"],"sourcesContent":["import { CreateAcoStorageOperationsParams } from \"~/createAcoStorageOperations\";\nimport { CmsModel } from \"@webiny/api-headless-cms/types\";\nimport WebinyError from \"@webiny/error\";\n\ninterface CreateOperationsWrapperParams extends CreateAcoStorageOperationsParams {\n modelName: string;\n}\n\nexport const createOperationsWrapper = (params: CreateOperationsWrapperParams) => {\n const { cms, security, modelName } = params;\n\n const withModel = async <TResult>(\n cb: (model: CmsModel) => Promise<TResult>\n ): Promise<TResult> => {\n return security.withoutAuthorization(async () => {\n const model = await cms.getModel(modelName);\n\n if (!model) {\n throw new WebinyError(\n `Could not find \"${modelName}\" model.`,\n \"MODEL_NOT_FOUND_ERROR\"\n );\n }\n\n const result = await cb(model);\n\n return result;\n });\n };\n\n return {\n withModel\n };\n};\n"],"mappings":";;;;;;;AAEA;AAMO,MAAMA,uBAAuB,GAAIC,MAAqC,IAAK;EAC9E,MAAM;IAAEC,GAAG;IAAEC,QAAQ;IAAEC;EAAU,CAAC,GAAGH,MAAM;EAE3C,MAAMI,SAAS,GAAG,MACdC,EAAyC,IACtB;IACnB,OAAOH,QAAQ,CAACI,oBAAoB,CAAC,YAAY;MAC7C,MAAMC,KAAK,GAAG,MAAMN,GAAG,CAACO,QAAQ,CAACL,SAAS,CAAC;MAE3C,IAAI,CAACI,KAAK,EAAE;QACR,MAAM,IAAIE,cAAW,CAChB,mBAAkBN,SAAU,UAAS,EACtC,uBAAuB,CAC1B;MACL;MAEA,MAAMO,MAAM,GAAG,MAAML,EAAE,CAACE,KAAK,CAAC;MAE9B,OAAOG,MAAM;IACjB,CAAC,CAAC;EACN,CAAC;EAED,OAAO;IACHN;EACJ,CAAC;AACL,CAAC;AAAC"}
@@ -1,5 +1,5 @@
1
- import { CmsModelPlugin } from "@webiny/api-headless-cms";
2
- import { CmsModel, CmsGroup } from "@webiny/api-headless-cms/types";
1
+ import { CmsModelPlugin, CmsPrivateModelFull } from "@webiny/api-headless-cms";
2
+ import { CmsGroup } from "@webiny/api-headless-cms/types";
3
3
  interface Params {
4
4
  group: Pick<CmsGroup, "id" | "name">;
5
5
  /**
@@ -9,9 +9,7 @@ interface Params {
9
9
  */
10
10
  locale?: string;
11
11
  tenant?: string;
12
- modelDefinition: Omit<CmsModel, "locale" | "tenant" | "webinyVersion" | "group" | "singularApiName" | "pluralApiName"> & {
13
- isPrivate: true;
14
- };
12
+ modelDefinition: Omit<CmsPrivateModelFull, "noValidate" | "group">;
15
13
  }
16
14
  export declare const modelFactory: (params: Params) => CmsModelPlugin;
17
15
  export {};
@@ -14,10 +14,12 @@ const modelFactory = params => {
14
14
  tenant,
15
15
  modelDefinition
16
16
  } = params;
17
- return (0, _apiHeadlessCms.createCmsModel)((0, _objectSpread2.default)({
17
+ return (0, _apiHeadlessCms.createCmsModel)((0, _objectSpread2.default)((0, _objectSpread2.default)({
18
18
  group,
19
19
  locale,
20
20
  tenant
21
- }, modelDefinition));
21
+ }, modelDefinition), {}, {
22
+ noValidate: true
23
+ }));
22
24
  };
23
25
  exports.modelFactory = modelFactory;
@@ -1 +1 @@
1
- {"version":3,"names":["modelFactory","params","group","locale","tenant","modelDefinition","createCmsModel"],"sources":["modelFactory.ts"],"sourcesContent":["import { CmsModelPlugin, createCmsModel } from \"@webiny/api-headless-cms\";\nimport { CmsModel, CmsGroup } from \"@webiny/api-headless-cms/types\";\n\ninterface Params {\n group: Pick<CmsGroup, \"id\" | \"name\">;\n /**\n * Locale and tenant do not need to be defined.\n * In that case model is not bound to any locale or tenant.\n * You can bind it to locale, tenant, both or none.\n */\n locale?: string;\n tenant?: string;\n modelDefinition: Omit<\n CmsModel,\n \"locale\" | \"tenant\" | \"webinyVersion\" | \"group\" | \"singularApiName\" | \"pluralApiName\"\n > & { isPrivate: true };\n}\n\nexport const modelFactory = (params: Params): CmsModelPlugin => {\n const { group, locale, tenant, modelDefinition } = params;\n\n return createCmsModel({\n group,\n locale,\n tenant,\n ...modelDefinition\n });\n};\n"],"mappings":";;;;;;;;AAAA;AAkBO,MAAMA,YAAY,GAAIC,MAAc,IAAqB;EAC5D,MAAM;IAAEC,KAAK;IAAEC,MAAM;IAAEC,MAAM;IAAEC;EAAgB,CAAC,GAAGJ,MAAM;EAEzD,OAAO,IAAAK,8BAAc;IACjBJ,KAAK;IACLC,MAAM;IACNC;EAAM,GACHC,eAAe,EACpB;AACN,CAAC;AAAC"}
1
+ {"version":3,"names":["modelFactory","params","group","locale","tenant","modelDefinition","createCmsModel","noValidate"],"sources":["modelFactory.ts"],"sourcesContent":["import { CmsModelPlugin, CmsPrivateModelFull, createCmsModel } from \"@webiny/api-headless-cms\";\nimport { CmsGroup } from \"@webiny/api-headless-cms/types\";\n\ninterface Params {\n group: Pick<CmsGroup, \"id\" | \"name\">;\n /**\n * Locale and tenant do not need to be defined.\n * In that case model is not bound to any locale or tenant.\n * You can bind it to locale, tenant, both or none.\n */\n locale?: string;\n tenant?: string;\n modelDefinition: Omit<CmsPrivateModelFull, \"noValidate\" | \"group\">;\n}\n\nexport const modelFactory = (params: Params): CmsModelPlugin => {\n const { group, locale, tenant, modelDefinition } = params;\n\n return createCmsModel({\n group,\n locale,\n tenant,\n ...modelDefinition,\n noValidate: true\n });\n};\n"],"mappings":";;;;;;;;AAAA;AAeO,MAAMA,YAAY,GAAIC,MAAc,IAAqB;EAC5D,MAAM;IAAEC,KAAK;IAAEC,MAAM;IAAEC,MAAM;IAAEC;EAAgB,CAAC,GAAGJ,MAAM;EAEzD,OAAO,IAAAK,8BAAc;IACjBJ,KAAK;IACLC,MAAM;IACNC;EAAM,GACHC,eAAe;IAClBE,UAAU,EAAE;EAAI,GAClB;AACN,CAAC;AAAC"}