@webiny/api-headless-cms-ddb-es 0.0.0-unstable.78f581c1d2 → 0.0.0-unstable.97a151f74d

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 (105) hide show
  1. package/definitions/model.js +5 -0
  2. package/definitions/model.js.map +1 -1
  3. package/dynamoDb/index.d.ts +1 -1
  4. package/dynamoDb/storage/date.d.ts +2 -1
  5. package/dynamoDb/storage/date.js.map +1 -1
  6. package/dynamoDb/storage/longText.d.ts +1 -1
  7. package/dynamoDb/storage/richText.d.ts +1 -1
  8. package/elasticsearch/indexing/longTextIndexing.d.ts +4 -0
  9. package/elasticsearch/indexing/longTextIndexing.js +20 -4
  10. package/elasticsearch/indexing/longTextIndexing.js.map +1 -1
  11. package/elasticsearch/search/refSearch.js +4 -2
  12. package/elasticsearch/search/refSearch.js.map +1 -1
  13. package/helpers/createElasticsearchQueryBody.js +12 -5
  14. package/helpers/createElasticsearchQueryBody.js.map +1 -1
  15. package/helpers/fields.js +9 -18
  16. package/helpers/fields.js.map +1 -1
  17. package/helpers/index.d.ts +0 -1
  18. package/helpers/index.js +0 -13
  19. package/helpers/index.js.map +1 -1
  20. package/helpers/searchPluginsList.js +1 -1
  21. package/index.js +13 -6
  22. package/index.js.map +1 -1
  23. package/operations/entry/dataLoaders.js.map +1 -1
  24. package/operations/entry/elasticsearch/body.d.ts +13 -0
  25. package/operations/entry/elasticsearch/body.js +162 -0
  26. package/operations/entry/elasticsearch/body.js.map +1 -0
  27. package/operations/entry/elasticsearch/fields.d.ts +9 -0
  28. package/operations/entry/elasticsearch/fields.js +248 -0
  29. package/operations/entry/elasticsearch/fields.js.map +1 -0
  30. package/operations/entry/elasticsearch/filtering/applyFiltering.d.ts +8 -0
  31. package/operations/entry/elasticsearch/filtering/applyFiltering.js +66 -0
  32. package/operations/entry/elasticsearch/filtering/applyFiltering.js.map +1 -0
  33. package/operations/entry/elasticsearch/filtering/exec.d.ts +17 -0
  34. package/operations/entry/elasticsearch/filtering/exec.js +214 -0
  35. package/operations/entry/elasticsearch/filtering/exec.js.map +1 -0
  36. package/operations/entry/elasticsearch/filtering/index.d.ts +1 -0
  37. package/operations/entry/elasticsearch/filtering/index.js +18 -0
  38. package/operations/entry/elasticsearch/filtering/index.js.map +1 -0
  39. package/operations/entry/elasticsearch/filtering/path.d.ts +15 -0
  40. package/operations/entry/elasticsearch/filtering/path.js +52 -0
  41. package/operations/entry/elasticsearch/filtering/path.js.map +1 -0
  42. package/operations/entry/elasticsearch/filtering/plugins/defaultFilterPlugin.d.ts +2 -0
  43. package/operations/entry/elasticsearch/filtering/plugins/defaultFilterPlugin.js +35 -0
  44. package/operations/entry/elasticsearch/filtering/plugins/defaultFilterPlugin.js.map +1 -0
  45. package/operations/entry/elasticsearch/filtering/plugins/index.d.ts +1 -0
  46. package/operations/entry/elasticsearch/filtering/plugins/index.js +18 -0
  47. package/operations/entry/elasticsearch/filtering/plugins/index.js.map +1 -0
  48. package/operations/entry/elasticsearch/filtering/plugins/objectFilterPlugin.d.ts +2 -0
  49. package/operations/entry/elasticsearch/filtering/plugins/objectFilterPlugin.js +78 -0
  50. package/operations/entry/elasticsearch/filtering/plugins/objectFilterPlugin.js.map +1 -0
  51. package/operations/entry/elasticsearch/filtering/plugins/refFilterPlugin.d.ts +2 -0
  52. package/operations/entry/elasticsearch/filtering/plugins/refFilterPlugin.js +58 -0
  53. package/operations/entry/elasticsearch/filtering/plugins/refFilterPlugin.js.map +1 -0
  54. package/operations/entry/elasticsearch/filtering/populated.d.ts +2 -0
  55. package/operations/entry/elasticsearch/filtering/populated.js +30 -0
  56. package/operations/entry/elasticsearch/filtering/populated.js.map +1 -0
  57. package/operations/entry/elasticsearch/filtering/values.d.ts +2 -0
  58. package/operations/entry/elasticsearch/filtering/values.js +28 -0
  59. package/operations/entry/elasticsearch/filtering/values.js.map +1 -0
  60. package/operations/entry/elasticsearch/fullTextSearch.d.ts +9 -0
  61. package/operations/entry/elasticsearch/fullTextSearch.js +34 -0
  62. package/operations/entry/elasticsearch/fullTextSearch.js.map +1 -0
  63. package/operations/entry/elasticsearch/fullTextSearchFields.d.ts +8 -0
  64. package/operations/entry/elasticsearch/fullTextSearchFields.js +52 -0
  65. package/operations/entry/elasticsearch/fullTextSearchFields.js.map +1 -0
  66. package/operations/entry/elasticsearch/initialQuery.d.ts +17 -0
  67. package/operations/entry/elasticsearch/initialQuery.js +117 -0
  68. package/operations/entry/elasticsearch/initialQuery.js.map +1 -0
  69. package/operations/entry/elasticsearch/keyword.d.ts +2 -0
  70. package/operations/entry/elasticsearch/keyword.js +38 -0
  71. package/operations/entry/elasticsearch/keyword.js.map +1 -0
  72. package/operations/entry/elasticsearch/plugins/bodyModifier.d.ts +9 -0
  73. package/operations/entry/elasticsearch/plugins/bodyModifier.js +19 -0
  74. package/operations/entry/elasticsearch/plugins/bodyModifier.js.map +1 -0
  75. package/operations/entry/elasticsearch/plugins/operator.d.ts +8 -0
  76. package/operations/entry/elasticsearch/plugins/operator.js +45 -0
  77. package/operations/entry/elasticsearch/plugins/operator.js.map +1 -0
  78. package/operations/entry/elasticsearch/plugins/queryModifier.d.ts +9 -0
  79. package/operations/entry/elasticsearch/plugins/queryModifier.js +19 -0
  80. package/operations/entry/elasticsearch/plugins/queryModifier.js.map +1 -0
  81. package/operations/entry/elasticsearch/plugins/search.d.ts +7 -0
  82. package/operations/entry/elasticsearch/plugins/search.js +30 -0
  83. package/operations/entry/elasticsearch/plugins/search.js.map +1 -0
  84. package/operations/entry/elasticsearch/plugins/sortModifier.d.ts +9 -0
  85. package/operations/entry/elasticsearch/plugins/sortModifier.js +19 -0
  86. package/operations/entry/elasticsearch/plugins/sortModifier.js.map +1 -0
  87. package/operations/entry/elasticsearch/sort.d.ts +12 -0
  88. package/operations/entry/elasticsearch/sort.js +92 -0
  89. package/operations/entry/elasticsearch/sort.js.map +1 -0
  90. package/operations/entry/elasticsearch/transformValueForSearch.d.ts +16 -0
  91. package/operations/entry/elasticsearch/transformValueForSearch.js +34 -0
  92. package/operations/entry/elasticsearch/transformValueForSearch.js.map +1 -0
  93. package/operations/entry/elasticsearch/types.d.ts +41 -0
  94. package/operations/entry/elasticsearch/types.js +5 -0
  95. package/operations/entry/elasticsearch/types.js.map +1 -0
  96. package/operations/entry/index.d.ts +0 -2
  97. package/operations/entry/index.js +47 -62
  98. package/operations/entry/index.js.map +1 -1
  99. package/operations/entry/recordType.d.ts +3 -0
  100. package/operations/entry/recordType.js +24 -0
  101. package/operations/entry/recordType.js.map +1 -0
  102. package/package.json +14 -14
  103. package/plugins/CmsEntryFilterPlugin.d.ts +49 -0
  104. package/plugins/CmsEntryFilterPlugin.js +31 -0
  105. package/plugins/CmsEntryFilterPlugin.js.map +1 -0
@@ -74,6 +74,11 @@ const createModelEntity = params => {
74
74
  type: "list",
75
75
  required: true
76
76
  },
77
+ tags: {
78
+ type: "list",
79
+ required: false,
80
+ default: []
81
+ },
77
82
  lockedFields: {
78
83
  type: "list",
79
84
  required: true
@@ -1 +1 @@
1
- {"version":3,"names":["createModelEntity","params","table","attributes","entityName","Entity","name","PK","partitionKey","SK","sortKey","TYPE","type","required","webinyVersion","modelId","locale","group","description","createdOn","savedOn","createdBy","fields","layout","lockedFields","titleFieldId","tenant"],"sources":["model.ts"],"sourcesContent":["import { Entity, Table } from \"dynamodb-toolbox\";\nimport { Attributes } from \"~/types\";\n\nexport interface CreateModelEntityParams {\n table: Table;\n entityName: string;\n attributes: Attributes;\n}\n\nexport const createModelEntity = (params: CreateModelEntityParams): Entity<any> => {\n const { table, attributes, entityName } = params;\n return new Entity({\n name: entityName,\n table,\n attributes: {\n PK: {\n partitionKey: true\n },\n SK: {\n sortKey: true\n },\n TYPE: {\n type: \"string\",\n required: true\n },\n webinyVersion: {\n type: \"string\",\n required: true\n },\n name: {\n type: \"string\",\n required: true\n },\n modelId: {\n type: \"string\",\n required: true\n },\n locale: {\n type: \"string\",\n required: true\n },\n group: {\n type: \"map\",\n required: true\n },\n description: {\n type: \"string\"\n },\n createdOn: {\n type: \"string\",\n required: true\n },\n savedOn: {\n type: \"string\",\n required: true\n },\n createdBy: {\n type: \"map\",\n required: true\n },\n fields: {\n type: \"list\",\n required: true\n },\n layout: {\n type: \"list\",\n required: true\n },\n lockedFields: {\n type: \"list\",\n required: true\n },\n titleFieldId: {\n type: \"string\"\n },\n tenant: {\n type: \"string\",\n required: true\n },\n ...(attributes || {})\n }\n });\n};\n"],"mappings":";;;;;;;;;;;AAAA;;AASO,MAAMA,iBAAiB,GAAIC,MAAD,IAAkD;EAC/E,MAAM;IAAEC,KAAF;IAASC,UAAT;IAAqBC;EAArB,IAAoCH,MAA1C;EACA,OAAO,IAAII,uBAAJ,CAAW;IACdC,IAAI,EAAEF,UADQ;IAEdF,KAFc;IAGdC,UAAU;MACNI,EAAE,EAAE;QACAC,YAAY,EAAE;MADd,CADE;MAINC,EAAE,EAAE;QACAC,OAAO,EAAE;MADT,CAJE;MAONC,IAAI,EAAE;QACFC,IAAI,EAAE,QADJ;QAEFC,QAAQ,EAAE;MAFR,CAPA;MAWNC,aAAa,EAAE;QACXF,IAAI,EAAE,QADK;QAEXC,QAAQ,EAAE;MAFC,CAXT;MAeNP,IAAI,EAAE;QACFM,IAAI,EAAE,QADJ;QAEFC,QAAQ,EAAE;MAFR,CAfA;MAmBNE,OAAO,EAAE;QACLH,IAAI,EAAE,QADD;QAELC,QAAQ,EAAE;MAFL,CAnBH;MAuBNG,MAAM,EAAE;QACJJ,IAAI,EAAE,QADF;QAEJC,QAAQ,EAAE;MAFN,CAvBF;MA2BNI,KAAK,EAAE;QACHL,IAAI,EAAE,KADH;QAEHC,QAAQ,EAAE;MAFP,CA3BD;MA+BNK,WAAW,EAAE;QACTN,IAAI,EAAE;MADG,CA/BP;MAkCNO,SAAS,EAAE;QACPP,IAAI,EAAE,QADC;QAEPC,QAAQ,EAAE;MAFH,CAlCL;MAsCNO,OAAO,EAAE;QACLR,IAAI,EAAE,QADD;QAELC,QAAQ,EAAE;MAFL,CAtCH;MA0CNQ,SAAS,EAAE;QACPT,IAAI,EAAE,KADC;QAEPC,QAAQ,EAAE;MAFH,CA1CL;MA8CNS,MAAM,EAAE;QACJV,IAAI,EAAE,MADF;QAEJC,QAAQ,EAAE;MAFN,CA9CF;MAkDNU,MAAM,EAAE;QACJX,IAAI,EAAE,MADF;QAEJC,QAAQ,EAAE;MAFN,CAlDF;MAsDNW,YAAY,EAAE;QACVZ,IAAI,EAAE,MADI;QAEVC,QAAQ,EAAE;MAFA,CAtDR;MA0DNY,YAAY,EAAE;QACVb,IAAI,EAAE;MADI,CA1DR;MA6DNc,MAAM,EAAE;QACJd,IAAI,EAAE,QADF;QAEJC,QAAQ,EAAE;MAFN;IA7DF,GAiEFV,UAAU,IAAI,EAjEZ;EAHI,CAAX,CAAP;AAuEH,CAzEM"}
1
+ {"version":3,"names":["createModelEntity","params","table","attributes","entityName","Entity","name","PK","partitionKey","SK","sortKey","TYPE","type","required","webinyVersion","modelId","locale","group","description","createdOn","savedOn","createdBy","fields","layout","tags","default","lockedFields","titleFieldId","tenant"],"sources":["model.ts"],"sourcesContent":["import { Entity, Table } from \"dynamodb-toolbox\";\nimport { Attributes } from \"~/types\";\n\nexport interface CreateModelEntityParams {\n table: Table;\n entityName: string;\n attributes: Attributes;\n}\n\nexport const createModelEntity = (params: CreateModelEntityParams): Entity<any> => {\n const { table, attributes, entityName } = params;\n return new Entity({\n name: entityName,\n table,\n attributes: {\n PK: {\n partitionKey: true\n },\n SK: {\n sortKey: true\n },\n TYPE: {\n type: \"string\",\n required: true\n },\n webinyVersion: {\n type: \"string\",\n required: true\n },\n name: {\n type: \"string\",\n required: true\n },\n modelId: {\n type: \"string\",\n required: true\n },\n locale: {\n type: \"string\",\n required: true\n },\n group: {\n type: \"map\",\n required: true\n },\n description: {\n type: \"string\"\n },\n createdOn: {\n type: \"string\",\n required: true\n },\n savedOn: {\n type: \"string\",\n required: true\n },\n createdBy: {\n type: \"map\",\n required: true\n },\n fields: {\n type: \"list\",\n required: true\n },\n layout: {\n type: \"list\",\n required: true\n },\n tags: {\n type: \"list\",\n required: false,\n default: []\n },\n lockedFields: {\n type: \"list\",\n required: true\n },\n titleFieldId: {\n type: \"string\"\n },\n tenant: {\n type: \"string\",\n required: true\n },\n ...(attributes || {})\n }\n });\n};\n"],"mappings":";;;;;;;;;;;AAAA;;AASO,MAAMA,iBAAiB,GAAIC,MAAD,IAAkD;EAC/E,MAAM;IAAEC,KAAF;IAASC,UAAT;IAAqBC;EAArB,IAAoCH,MAA1C;EACA,OAAO,IAAII,uBAAJ,CAAW;IACdC,IAAI,EAAEF,UADQ;IAEdF,KAFc;IAGdC,UAAU;MACNI,EAAE,EAAE;QACAC,YAAY,EAAE;MADd,CADE;MAINC,EAAE,EAAE;QACAC,OAAO,EAAE;MADT,CAJE;MAONC,IAAI,EAAE;QACFC,IAAI,EAAE,QADJ;QAEFC,QAAQ,EAAE;MAFR,CAPA;MAWNC,aAAa,EAAE;QACXF,IAAI,EAAE,QADK;QAEXC,QAAQ,EAAE;MAFC,CAXT;MAeNP,IAAI,EAAE;QACFM,IAAI,EAAE,QADJ;QAEFC,QAAQ,EAAE;MAFR,CAfA;MAmBNE,OAAO,EAAE;QACLH,IAAI,EAAE,QADD;QAELC,QAAQ,EAAE;MAFL,CAnBH;MAuBNG,MAAM,EAAE;QACJJ,IAAI,EAAE,QADF;QAEJC,QAAQ,EAAE;MAFN,CAvBF;MA2BNI,KAAK,EAAE;QACHL,IAAI,EAAE,KADH;QAEHC,QAAQ,EAAE;MAFP,CA3BD;MA+BNK,WAAW,EAAE;QACTN,IAAI,EAAE;MADG,CA/BP;MAkCNO,SAAS,EAAE;QACPP,IAAI,EAAE,QADC;QAEPC,QAAQ,EAAE;MAFH,CAlCL;MAsCNO,OAAO,EAAE;QACLR,IAAI,EAAE,QADD;QAELC,QAAQ,EAAE;MAFL,CAtCH;MA0CNQ,SAAS,EAAE;QACPT,IAAI,EAAE,KADC;QAEPC,QAAQ,EAAE;MAFH,CA1CL;MA8CNS,MAAM,EAAE;QACJV,IAAI,EAAE,MADF;QAEJC,QAAQ,EAAE;MAFN,CA9CF;MAkDNU,MAAM,EAAE;QACJX,IAAI,EAAE,MADF;QAEJC,QAAQ,EAAE;MAFN,CAlDF;MAsDNW,IAAI,EAAE;QACFZ,IAAI,EAAE,MADJ;QAEFC,QAAQ,EAAE,KAFR;QAGFY,OAAO,EAAE;MAHP,CAtDA;MA2DNC,YAAY,EAAE;QACVd,IAAI,EAAE,MADI;QAEVC,QAAQ,EAAE;MAFA,CA3DR;MA+DNc,YAAY,EAAE;QACVf,IAAI,EAAE;MADI,CA/DR;MAkENgB,MAAM,EAAE;QACJhB,IAAI,EAAE,QADF;QAEJC,QAAQ,EAAE;MAFN;IAlEF,GAsEFV,UAAU,IAAI,EAtEZ;EAHI,CAAX,CAAP;AA4EH,CA9EM"}
@@ -1,2 +1,2 @@
1
- declare const _default: () => import("@webiny/api-headless-cms").StorageTransformPlugin<any, any>[];
1
+ declare const _default: () => import("@webiny/api-headless-cms").StorageTransformPlugin<any, any, import("@webiny/api-headless-cms/types").CmsModelField>[];
2
2
  export default _default;
@@ -1,2 +1,3 @@
1
1
  import { StorageTransformPlugin } from "@webiny/api-headless-cms";
2
- export declare const createDateStorageTransformPlugin: () => StorageTransformPlugin<any, any>;
2
+ import { CmsModelField } from "@webiny/api-headless-cms/types";
3
+ export declare const createDateStorageTransformPlugin: () => StorageTransformPlugin<any, any, CmsModelField>;
@@ -1 +1 @@
1
- {"version":3,"names":["excludeTypes","convertFromStorage","field","value","multipleValues","filter","v","map","Date","console","log","convertValueToStorage","toISOString","WebinyError","fieldId","storageId","createDateStorageTransformPlugin","StorageTransformPlugin","fieldType","fromStorage","type","settings","includes","toStorage"],"sources":["date.ts"],"sourcesContent":["/**\n * File is @internal\n */\nimport WebinyError from \"@webiny/error\";\nimport { StorageTransformPlugin } from \"@webiny/api-headless-cms\";\nimport { CmsModelField } from \"@webiny/api-headless-cms/types\";\n\nconst excludeTypes = [\"time\", \"dateTimeWithTimezone\"];\n\nconst convertFromStorage = (field: CmsModelField, value: string | string[]) => {\n try {\n if (field.multipleValues) {\n return ((value as string[]) || [])\n .filter(v => !!v)\n .map((v: string) => {\n return new Date(v);\n });\n }\n return new Date(value as string);\n } catch {\n console.log(`Could not transform from storage for field type`);\n return value;\n }\n};\n\nconst convertValueToStorage = (field: CmsModelField, value: any): any => {\n if ((value as any).toISOString) {\n return (value as Date).toISOString();\n } else if (typeof value === \"string\") {\n return value as string;\n }\n throw new WebinyError(\"Error converting value to a storage type.\", \"TO_STORAGE_ERROR\", {\n value: value,\n fieldId: field.fieldId,\n storageId: field.storageId\n });\n};\n\nexport const createDateStorageTransformPlugin = () => {\n return new StorageTransformPlugin({\n fieldType: \"datetime\",\n fromStorage: async ({ value, field }) => {\n const { type } = field.settings || {};\n if (!value || !type || excludeTypes.includes(type)) {\n return value;\n }\n return convertFromStorage(field, value);\n },\n toStorage: async ({ value, field }) => {\n const { type } = field.settings || {};\n if (!value || !type || excludeTypes.includes(type)) {\n return value;\n }\n if (field.multipleValues) {\n const multipleValues = value as (string | Date | null | undefined)[];\n return (multipleValues || [])\n .filter(v => !!v)\n .map(v => {\n return convertValueToStorage(field, v);\n });\n }\n if ((value as any).toISOString) {\n return (value as Date).toISOString();\n } else if (typeof value === \"string\") {\n return value as string;\n }\n throw new WebinyError(\"Error converting value to a storage type.\", \"TO_STORAGE_ERROR\", {\n value,\n fieldId: field.fieldId,\n storageId: field.storageId\n });\n }\n });\n};\n"],"mappings":";;;;;;;;;AAGA;;AACA;;AAJA;AACA;AACA;AAKA,MAAMA,YAAY,GAAG,CAAC,MAAD,EAAS,sBAAT,CAArB;;AAEA,MAAMC,kBAAkB,GAAG,CAACC,KAAD,EAAuBC,KAAvB,KAAoD;EAC3E,IAAI;IACA,IAAID,KAAK,CAACE,cAAV,EAA0B;MACtB,OAAO,CAAED,KAAD,IAAuB,EAAxB,EACFE,MADE,CACKC,CAAC,IAAI,CAAC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kB,EAAnC;;MACA,IAAI,CAAClB,KAAD,IAAU,CAACiB,IAAX,IAAmBpB,YAAY,CAACsB,QAAb,CAAsBF,IAAtB,CAAvB,EAAoD;QAChD,OAAOjB,KAAP;MACH;;MACD,IAAID,KAAK,CAACE,cAAV,EAA0B;QACtB,MAAMA,cAAc,GAAGD,KAAvB;QACA,OAAO,CAACC,cAAc,IAAI,EAAnB,EACFC,MADE,CACKC,CAAC,IAAI,CAAC,CAACA,CADZ,EAEFC,GAFE,CAEED,CAAC,IAAI;UACN,OAAOK,qBAAqB,CAACT,KAAD,EAAQI,CAAR,CAA5B;QACH,CAJE,CAAP;MAKH;;MACD,IAAKH,KAAD,CAAeS,WAAnB,EAAgC;QAC5B,OAAQT,KAAD,CAAgBS,WAAhB,EAAP;MACH,CAFD,MAEO,IAAI,OAAOT,KAAP,KAAiB,QAArB,EAA+B;QAClC,OAAOA,KAAP;MACH;;MACD,MAAM,IAAIU,cAAJ,CAAgB,2CAAhB,EAA6D,kBAA7D,EAAiF;QACnFV,KADmF;QAEnFW,OAAO,EAAEZ,KAAK,CAACY,OAFoE;QAGnFC,SAAS,EAAEb,KAAK,CAACa;MAHkE,CAAjF,CAAN;IAKH;EAhC6B,CAA3B,CAAP;AAkCH,CAnCM"}
1
+ {"version":3,"names":["excludeTypes","convertFromStorage","field","value","multipleValues","filter","v","map","Date","console","log","convertValueToStorage","toISOString","WebinyError","fieldId","storageId","createDateStorageTransformPlugin","StorageTransformPlugin","fieldType","fromStorage","type","settings","includes","toStorage"],"sources":["date.ts"],"sourcesContent":["/**\n * File is @internal\n */\nimport WebinyError from \"@webiny/error\";\nimport { StorageTransformPlugin } from \"@webiny/api-headless-cms\";\nimport { CmsModelField } from \"@webiny/api-headless-cms/types\";\n\ntype PartialCmsModelField = Pick<CmsModelField, \"fieldId\" | \"storageId\" | \"multipleValues\">;\n\nconst excludeTypes = [\"time\", \"dateTimeWithTimezone\"];\n\nconst convertFromStorage = (field: PartialCmsModelField, value: string | string[]) => {\n try {\n if (field.multipleValues) {\n return ((value as string[]) || [])\n .filter(v => !!v)\n .map((v: string) => {\n return new Date(v);\n });\n }\n return new Date(value as string);\n } catch {\n console.log(`Could not transform from storage for field type`);\n return value;\n }\n};\n\nconst convertValueToStorage = (field: PartialCmsModelField, value: any): any => {\n if ((value as any).toISOString) {\n return (value as Date).toISOString();\n } else if (typeof value === \"string\") {\n return value as string;\n }\n throw new WebinyError(\"Error converting value to a storage type.\", \"TO_STORAGE_ERROR\", {\n value: value,\n fieldId: field.fieldId,\n storageId: field.storageId\n });\n};\n\nexport const createDateStorageTransformPlugin = () => {\n return new StorageTransformPlugin({\n fieldType: \"datetime\",\n fromStorage: async ({ value, field }) => {\n const { type } = field.settings || {};\n if (!value || !type || excludeTypes.includes(type)) {\n return value;\n }\n return convertFromStorage(field, value);\n },\n toStorage: async ({ value, field }) => {\n const { type } = field.settings || {};\n if (!value || !type || excludeTypes.includes(type)) {\n return value;\n }\n if (field.multipleValues) {\n const multipleValues = value as (string | Date | null | undefined)[];\n return (multipleValues || [])\n .filter(v => !!v)\n .map(v => {\n return convertValueToStorage(field, v);\n });\n }\n if ((value as any).toISOString) {\n return (value as Date).toISOString();\n } else if (typeof value === \"string\") {\n return value as string;\n }\n throw new WebinyError(\"Error converting value to a storage type.\", \"TO_STORAGE_ERROR\", {\n value,\n fieldId: field.fieldId,\n storageId: field.storageId\n });\n }\n });\n};\n"],"mappings":";;;;;;;;;AAGA;;AACA;;AAJA;AACA;AACA;AAOA,MAAMA,YAAY,GAAG,CAAC,MAAD,EAAS,sBAAT,CAArB;;AAEA,MAAMC,kBAAkB,GAAG,CAACC,KAAD,EAA8BC,KAA9B,KAA2D;EAClF,IAAI;IACA,IAAID,KAAK,CAACE,cAAV,EAA0B;MACtB,OAAO,CAAED,KAAD,IAAuB,EAAxB,EACFE,MADE,CACKC,CAAC,IAAI,CAAC,CAACA,CADZ,EAEFC,GAFE,CAEGD,CAAD,IAAe;QAChB,OAAO,IAAIE,IAAJ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Y,CAACsB,QAAb,CAAsBF,IAAtB,CAAvB,EAAoD;QAChD,OAAOjB,KAAP;MACH;;MACD,IAAID,KAAK,CAACE,cAAV,EAA0B;QACtB,MAAMA,cAAc,GAAGD,KAAvB;QACA,OAAO,CAACC,cAAc,IAAI,EAAnB,EACFC,MADE,CACKC,CAAC,IAAI,CAAC,CAACA,CADZ,EAEFC,GAFE,CAEED,CAAC,IAAI;UACN,OAAOK,qBAAqB,CAACT,KAAD,EAAQI,CAAR,CAA5B;QACH,CAJE,CAAP;MAKH;;MACD,IAAKH,KAAD,CAAeS,WAAnB,EAAgC;QAC5B,OAAQT,KAAD,CAAgBS,WAAhB,EAAP;MACH,CAFD,MAEO,IAAI,OAAOT,KAAP,KAAiB,QAArB,EAA+B;QAClC,OAAOA,KAAP;MACH;;MACD,MAAM,IAAIU,cAAJ,CAAgB,2CAAhB,EAA6D,kBAA7D,EAAiF;QACnFV,KADmF;QAEnFW,OAAO,EAAEZ,KAAK,CAACY,OAFoE;QAGnFC,SAAS,EAAEb,KAAK,CAACa;MAHkE,CAAjF,CAAN;IAKH;EAhC6B,CAA3B,CAAP;AAkCH,CAnCM"}
@@ -7,4 +7,4 @@ export interface StorageValue {
7
7
  value: string;
8
8
  isArray?: boolean;
9
9
  }
10
- export declare const createLongTextStorageTransformPlugin: () => StorageTransformPlugin<string | string[], StorageValue>;
10
+ export declare const createLongTextStorageTransformPlugin: () => StorageTransformPlugin<string | string[], StorageValue, import("@webiny/api-headless-cms/types").CmsModelField>;
@@ -4,4 +4,4 @@ export interface StorageValue {
4
4
  compression: string;
5
5
  value: any;
6
6
  }
7
- export declare const createRichTextStorageTransformPlugin: () => StorageTransformPlugin<any, any>;
7
+ export declare const createRichTextStorageTransformPlugin: () => StorageTransformPlugin<any, any, import("@webiny/api-headless-cms/types").CmsModelField>;
@@ -1,3 +1,7 @@
1
1
  import { CmsModelFieldToElasticsearchPlugin } from "../../types";
2
+ /**
3
+ * The long-text indexing plugin must take in consideration that users might have list of long-text fields.
4
+ * Also, we used to encode values, and we do not do that anymore - but we need to have backward compatibility.
5
+ */
2
6
  declare const _default: () => CmsModelFieldToElasticsearchPlugin;
3
7
  export default _default;
@@ -5,6 +5,10 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.default = void 0;
7
7
 
8
+ /**
9
+ * The long-text indexing plugin must take in consideration that users might have list of long-text fields.
10
+ * Also, we used to encode values, and we do not do that anymore - but we need to have backward compatibility.
11
+ */
8
12
  var _default = () => ({
9
13
  type: "cms-model-field-to-elastic-search",
10
14
  name: "cms-model-field-to-elastic-search-long-text",
@@ -14,20 +18,32 @@ var _default = () => ({
14
18
  rawValue
15
19
  }) {
16
20
  /**
17
- * We want to store the value (rawValue) from entry before it was prepared for storage as value to be searched on.
18
- * And we want to store prepared value into rawValue so it is not indexed.
21
+ * We take the raw value, before it was prepared via `transformToStorage` for storage (there might be some transform due to DynamoDB) and store it in the Elasticsearch to be indexed.
19
22
  */
20
23
  return {
21
- value: rawValue ? encodeURIComponent(rawValue) : ""
24
+ /**
25
+ * // TODO @Bruno validate and test
26
+ * I have no idea why we encoded the raw value. We will see in testing and when upgrading our test projects.
27
+ * // TODO remove comments when tested and verified.
28
+ */
29
+ // value: rawValue ? encodeURIComponent(rawValue) : "",
30
+ value: Array.isArray(rawValue) ? rawValue : rawValue || ""
22
31
  };
23
32
  },
24
33
 
25
34
  /**
26
- * When extracting from index, we can return the value that was stored to be searched - and then no decompression will be required.
35
+ * When taking value from the index, we can return the original value.
36
+ * At that point the `transformFromStorage` does not need to do anything.
37
+ *
38
+ * We need to decode to support older systems.
27
39
  */
28
40
  fromIndex({
29
41
  value
30
42
  }) {
43
+ if (Array.isArray(value)) {
44
+ return value.map(decodeURIComponent);
45
+ }
46
+
31
47
  return value ? decodeURIComponent(value) : "";
32
48
  }
33
49
 
@@ -1 +1 @@
1
- {"version":3,"names":["type","name","fieldType","toIndex","rawValue","value","encodeURIComponent","fromIndex","decodeURIComponent"],"sources":["longTextIndexing.ts"],"sourcesContent":["import { CmsModelFieldToElasticsearchPlugin } from \"~/types\";\n\nexport default (): CmsModelFieldToElasticsearchPlugin => ({\n type: \"cms-model-field-to-elastic-search\",\n name: \"cms-model-field-to-elastic-search-long-text\",\n fieldType: \"long-text\",\n toIndex({ rawValue }) {\n /**\n * We want to store the value (rawValue) from entry before it was prepared for storage as value to be searched on.\n * And we want to store prepared value into rawValue so it is not indexed.\n */\n return {\n value: rawValue ? encodeURIComponent(rawValue) : \"\"\n };\n },\n /**\n * When extracting from index, we can return the value that was stored to be searched - and then no decompression will be required.\n */\n fromIndex({ value }) {\n return value ? decodeURIComponent(value) : \"\";\n }\n});\n"],"mappings":";;;;;;;eAEe,OAA2C;EACtDA,IAAI,EAAE,mCADgD;EAEtDC,IAAI,EAAE,6CAFgD;EAGtDC,SAAS,EAAE,WAH2C;;EAItDC,OAAO,CAAC;IAAEC;EAAF,CAAD,EAAe;IAClB;AACR;AACA;AACA;IACQ,OAAO;MACHC,KAAK,EAAED,QAAQ,GAAGE,kBAAkB,CAACF,QAAD,CAArB,GAAkC;IAD9C,CAAP;EAGH,CAZqD;;EAatD;AACJ;AACA;EACIG,SAAS,CAAC;IAAEF;EAAF,CAAD,EAAY;IACjB,OAAOA,KAAK,GAAGG,kBAAkB,CAACH,KAAD,CAArB,GAA+B,EAA3C;EACH;;AAlBqD,CAA3C,C"}
1
+ {"version":3,"names":["type","name","fieldType","toIndex","rawValue","value","Array","isArray","fromIndex","map","decodeURIComponent"],"sources":["longTextIndexing.ts"],"sourcesContent":["import { CmsModelFieldToElasticsearchPlugin } from \"~/types\";\n\n/**\n * The long-text indexing plugin must take in consideration that users might have list of long-text fields.\n * Also, we used to encode values, and we do not do that anymore - but we need to have backward compatibility.\n */\nexport default (): CmsModelFieldToElasticsearchPlugin => ({\n type: \"cms-model-field-to-elastic-search\",\n name: \"cms-model-field-to-elastic-search-long-text\",\n fieldType: \"long-text\",\n toIndex({ rawValue }) {\n /**\n * We take the raw value, before it was prepared via `transformToStorage` for storage (there might be some transform due to DynamoDB) and store it in the Elasticsearch to be indexed.\n */\n return {\n /**\n * // TODO @Bruno validate and test\n * I have no idea why we encoded the raw value. We will see in testing and when upgrading our test projects.\n * // TODO remove comments when tested and verified.\n */\n // value: rawValue ? encodeURIComponent(rawValue) : \"\",\n value: Array.isArray(rawValue) ? rawValue : rawValue || \"\"\n };\n },\n /**\n * When taking value from the index, we can return the original value.\n * At that point the `transformFromStorage` does not need to do anything.\n *\n * We need to decode to support older systems.\n */\n fromIndex({ value }) {\n if (Array.isArray(value)) {\n return value.map(decodeURIComponent);\n }\n return value ? decodeURIComponent(value) : \"\";\n }\n});\n"],"mappings":";;;;;;;AAEA;AACA;AACA;AACA;eACe,OAA2C;EACtDA,IAAI,EAAE,mCADgD;EAEtDC,IAAI,EAAE,6CAFgD;EAGtDC,SAAS,EAAE,WAH2C;;EAItDC,OAAO,CAAC;IAAEC;EAAF,CAAD,EAAe;IAClB;AACR;AACA;IACQ,OAAO;MACH;AACZ;AACA;AACA;AACA;MACY;MACAC,KAAK,EAAEC,KAAK,CAACC,OAAN,CAAcH,QAAd,IAA0BA,QAA1B,GAAqCA,QAAQ,IAAI;IAPrD,CAAP;EASH,CAjBqD;;EAkBtD;AACJ;AACA;AACA;AACA;AACA;EACII,SAAS,CAAC;IAAEH;EAAF,CAAD,EAAY;IACjB,IAAIC,KAAK,CAACC,OAAN,CAAcF,KAAd,CAAJ,EAA0B;MACtB,OAAOA,KAAK,CAACI,GAAN,CAAUC,kBAAV,CAAP;IACH;;IACD,OAAOL,KAAK,GAAGK,kBAAkB,CAACL,KAAD,CAArB,GAA+B,EAA3C;EACH;;AA7BqD,CAA3C,C"}
@@ -18,8 +18,10 @@ const createPath = ({
18
18
  return `${field.storageId}.entryId`;
19
19
  };
20
20
 
21
- const transform = params => {
22
- return params.value;
21
+ const transform = ({
22
+ value
23
+ }) => {
24
+ return value;
23
25
  };
24
26
 
25
27
  const createRefSearchPlugin = () => {
@@ -1 +1 @@
1
- {"version":3,"names":["createPath","field","key","match","storageId","transform","params","value","createRefSearchPlugin","CmsEntryElasticsearchQueryBuilderValueSearchPlugin","fieldType","path"],"sources":["refSearch.ts"],"sourcesContent":["import {\n CmsEntryElasticsearchQueryBuilderValueSearchPlugin,\n CreatePathCallable,\n TransformCallable\n} from \"~/plugins/CmsEntryElasticsearchQueryBuilderValueSearchPlugin\";\n\nconst createPath: CreatePathCallable<string> = ({ field, key }) => {\n if (key && key.match(\"entryId\") === null) {\n return `${field.storageId}.id`;\n }\n return `${field.storageId}.entryId`;\n};\n\nconst transform: TransformCallable<string> = params => {\n return params.value;\n};\n\nexport const createRefSearchPlugin = (): CmsEntryElasticsearchQueryBuilderValueSearchPlugin => {\n return new CmsEntryElasticsearchQueryBuilderValueSearchPlugin({\n fieldType: \"ref\",\n path: createPath,\n transform\n });\n};\n"],"mappings":";;;;;;;AAAA;;AAMA,MAAMA,UAAsC,GAAG,CAAC;EAAEC,KAAF;EAASC;AAAT,CAAD,KAAoB;EAC/D,IAAIA,GAAG,IAAIA,GAAG,CAACC,KAAJ,CAAU,SAAV,MAAyB,IAApC,EAA0C;IACtC,OAAQ,GAAEF,KAAK,CAACG,SAAU,KAA1B;EACH;;EACD,OAAQ,GAAEH,KAAK,CAACG,SAAU,UAA1B;AACH,CALD;;AAOA,MAAMC,SAAoC,GAAGC,MAAM,IAAI;EACnD,OAAOA,MAAM,CAACC,KAAd;AACH,CAFD;;AAIO,MAAMC,qBAAqB,GAAG,MAA0D;EAC3F,OAAO,IAAIC,sGAAJ,CAAuD;IAC1DC,SAAS,EAAE,KAD+C;IAE1DC,IAAI,EAAEX,UAFoD;IAG1DK;EAH0D,CAAvD,CAAP;AAKH,CANM"}
1
+ {"version":3,"names":["createPath","field","key","match","storageId","transform","value","createRefSearchPlugin","CmsEntryElasticsearchQueryBuilderValueSearchPlugin","fieldType","path"],"sources":["refSearch.ts"],"sourcesContent":["import {\n CmsEntryElasticsearchQueryBuilderValueSearchPlugin,\n CreatePathCallable,\n TransformCallable\n} from \"~/plugins/CmsEntryElasticsearchQueryBuilderValueSearchPlugin\";\n\nconst createPath: CreatePathCallable<string> = ({ field, key }) => {\n if (key && key.match(\"entryId\") === null) {\n return `${field.storageId}.id`;\n }\n return `${field.storageId}.entryId`;\n};\n\nconst transform: TransformCallable = ({ value }) => {\n return value;\n};\n\nexport const createRefSearchPlugin = (): CmsEntryElasticsearchQueryBuilderValueSearchPlugin => {\n return new CmsEntryElasticsearchQueryBuilderValueSearchPlugin({\n fieldType: \"ref\",\n path: createPath,\n transform\n });\n};\n"],"mappings":";;;;;;;AAAA;;AAMA,MAAMA,UAAsC,GAAG,CAAC;EAAEC,KAAF;EAASC;AAAT,CAAD,KAAoB;EAC/D,IAAIA,GAAG,IAAIA,GAAG,CAACC,KAAJ,CAAU,SAAV,MAAyB,IAApC,EAA0C;IACtC,OAAQ,GAAEF,KAAK,CAACG,SAAU,KAA1B;EACH;;EACD,OAAQ,GAAEH,KAAK,CAACG,SAAU,UAA1B;AACH,CALD;;AAOA,MAAMC,SAA4B,GAAG,CAAC;EAAEC;AAAF,CAAD,KAAe;EAChD,OAAOA,KAAP;AACH,CAFD;;AAIO,MAAMC,qBAAqB,GAAG,MAA0D;EAC3F,OAAO,IAAIC,sGAAJ,CAAuD;IAC1DC,SAAS,EAAE,KAD+C;IAE1DC,IAAI,EAAEV,UAFoD;IAG1DK;EAH0D,CAAvD,CAAP;AAKH,CANM"}
@@ -1,13 +1,13 @@
1
1
  "use strict";
2
2
 
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
4
 
5
5
  Object.defineProperty(exports, "__esModule", {
6
6
  value: true
7
7
  });
8
8
  exports.createElasticsearchQueryBody = void 0;
9
9
 
10
- var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
10
+ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
11
11
 
12
12
  var _error = _interopRequireDefault(require("@webiny/error"));
13
13
 
@@ -29,6 +29,10 @@ var _CmsEntryElasticsearchSortModifierPlugin = require("../plugins/CmsEntryElast
29
29
 
30
30
  var _CmsEntryElasticsearchBodyModifierPlugin = require("../plugins/CmsEntryElasticsearchBodyModifierPlugin");
31
31
 
32
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
33
+
34
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
35
+
32
36
  const specialFields = ["published", "latest"];
33
37
  const noKeywordFields = ["date", "datetime", "number", "boolean"];
34
38
 
@@ -113,7 +117,8 @@ const createInitialQueryValue = params => {
113
117
  * Cast as partial so we can remove unnecessary keys.
114
118
  */
115
119
 
116
- const where = (0, _objectSpread2.default)({}, initialWhere);
120
+ const where = _objectSpread({}, initialWhere);
121
+
117
122
  const query = {
118
123
  must: [],
119
124
  must_not: [],
@@ -373,8 +378,10 @@ const execElasticsearchBuildQueryPlugins = params => {
373
378
  searchPlugins,
374
379
  fullTextSearch
375
380
  } = params;
376
- const where = (0, _objectSpread2.default)({}, initialWhere);
377
- const query = createInitialQueryValue((0, _objectSpread2.default)((0, _objectSpread2.default)({}, params), {}, {
381
+
382
+ const where = _objectSpread({}, initialWhere);
383
+
384
+ const query = createInitialQueryValue(_objectSpread(_objectSpread({}, params), {}, {
378
385
  where
379
386
  }));
380
387
  /**
@@ -1 +1 @@
1
- {"version":3,"names":["specialFields","noKeywordFields","createElasticsearchSortParams","args","sort","modelFields","parentPath","searchPlugins","length","fieldIdToStorageIdIdMap","sortPlugins","Object","values","reduce","plugins","modelField","searchPlugin","type","fieldId","storageId","field","CmsEntryElasticsearchFieldPlugin","unmappedType","keyword","hasKeyword","sortable","isSortable","searchable","isSearchable","path","createFieldPath","key","transformedSort","map","value","matched","match","order","filter","Boolean","createSort","fieldPlugins","findFieldByFieldId","model","fields","find","createInitialQueryValue","params","where","initialWhere","query","must","must_not","should","sharedIndex","process","env","ELASTICSEARCH_SHARED_INDEXES","push","term","tenant","locale","published","createPublishedType","latest","createLatestType","WebinyError","createPath","id","isSystemField","includes","nonRefFieldTypes","isRefFieldFiltering","typeOf","Array","isArray","Date","toISOString","fieldPathFactory","plugin","fieldPath","keywordValue","applyFiltering","operator","initialValue","operatorPlugins","fieldSearchPlugin","transformValueForSearch","apply","basePath","applyFullTextSearch","fieldPaths","collection","query_string","allow_leading_wildcard","normalizeValue","default_operator","execElasticsearchBuildQueryPlugins","fullTextSearch","sf","keys","getElasticsearchOperatorPluginsByLocale","hasOwnProperty","undefined","parseWhereKey","cmsModelField","cmsField","whereKey","createElasticsearchQueryBody","after","limit","initialSort","search","createModelFields","searchPluginsList","fullTextSearchFields","f","queryPlugins","byType","CmsEntryElasticsearchQueryModifierPlugin","pl","modelId","modifyQuery","CmsEntryElasticsearchSortModifierPlugin","modifySort","body","bool","size","search_after","decodeCursor","track_total_hits","bodyPlugins","CmsEntryElasticsearchBodyModifierPlugin","modifyBody"],"sources":["createElasticsearchQueryBody.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport { transformValueForSearch } from \"./transformValueForSearch\";\nimport { searchPluginsList } from \"./searchPluginsList\";\nimport {\n CmsEntryListParams,\n CmsEntryListSort,\n CmsEntryListWhere,\n CmsModel,\n CmsModelField\n} from \"@webiny/api-headless-cms/types\";\nimport {\n SearchBody as esSearchBody,\n Sort as esSort,\n ElasticsearchBoolQueryConfig\n} from \"@webiny/api-elasticsearch/types\";\nimport {\n decodeCursor,\n createSort,\n parseWhereKey,\n ElasticsearchQueryBuilderOperatorPlugin,\n normalizeValue,\n getElasticsearchOperatorPluginsByLocale\n} from \"@webiny/api-elasticsearch\";\nimport { createModelFields, ModelField, ModelFields } from \"./fields\";\nimport { CmsEntryElasticsearchFieldPlugin } from \"~/plugins/CmsEntryElasticsearchFieldPlugin\";\nimport { PluginsContainer } from \"@webiny/plugins\";\nimport { createLatestType, createPublishedType } from \"~/operations/entry\";\nimport { CmsEntryElasticsearchQueryModifierPlugin } from \"~/plugins/CmsEntryElasticsearchQueryModifierPlugin\";\nimport { CmsEntryElasticsearchSortModifierPlugin } from \"~/plugins/CmsEntryElasticsearchSortModifierPlugin\";\nimport { CmsEntryElasticsearchBodyModifierPlugin } from \"~/plugins/CmsEntryElasticsearchBodyModifierPlugin\";\nimport {\n CmsEntryElasticsearchQueryBuilderValueSearchPlugin,\n CreatePathCallableParams\n} from \"~/plugins/CmsEntryElasticsearchQueryBuilderValueSearchPlugin\";\n\ninterface CreateElasticsearchParams {\n plugins: PluginsContainer;\n model: CmsModel;\n args: CmsEntryListParams;\n parentPath?: string;\n}\n\ninterface CreateElasticsearchSortParams {\n plugins: PluginsContainer;\n sort?: CmsEntryListSort;\n modelFields: ModelFields;\n parentPath?: string | null;\n model: CmsModel;\n searchPlugins: Record<string, CmsEntryElasticsearchQueryBuilderValueSearchPlugin>;\n}\n\ninterface CreateElasticsearchQueryArgs {\n model: CmsModel;\n plugins: PluginsContainer;\n where: CmsEntryListWhere;\n modelFields: ModelFields;\n parentPath?: string | null;\n searchPlugins: Record<string, CmsEntryElasticsearchQueryBuilderValueSearchPlugin>;\n fullTextSearch: {\n term?: string;\n fields: CmsModelField[];\n };\n}\n\nconst specialFields: (keyof Partial<CmsEntryListWhere>)[] = [\"published\", \"latest\"];\nconst noKeywordFields = [\"date\", \"datetime\", \"number\", \"boolean\"];\n\nconst createElasticsearchSortParams = (args: CreateElasticsearchSortParams): esSort => {\n const { sort, modelFields, parentPath, searchPlugins } = args;\n\n if (!sort || sort.length === 0) {\n return [];\n }\n\n const fieldIdToStorageIdIdMap: Record<string, string> = {};\n\n const sortPlugins = Object.values(modelFields).reduce((plugins, modelField) => {\n const searchPlugin = searchPlugins[modelField.type];\n\n const { fieldId, storageId } = modelField.field;\n\n fieldIdToStorageIdIdMap[fieldId] = fieldId;\n /**\n * Plugins must be stored with fieldId as key because it is later used to find the sorting plugin.\n */\n plugins[fieldId] = new CmsEntryElasticsearchFieldPlugin({\n unmappedType: modelField.unmappedType,\n keyword: hasKeyword(modelField),\n sortable: modelField.isSortable,\n searchable: modelField.isSearchable,\n field: fieldId,\n path: createFieldPath({\n key: storageId,\n parentPath,\n modelField,\n searchPlugin\n })\n });\n return plugins;\n }, {} as Record<string, CmsEntryElasticsearchFieldPlugin>);\n\n const transformedSort = sort\n .map(value => {\n const matched = value.match(/^([a-zA-Z-0-9_]+)_(ASC|DESC)$/);\n if (!matched) {\n return null;\n }\n const [, fieldId, order] = matched;\n if (fieldIdToStorageIdIdMap[fieldId]) {\n return `${fieldIdToStorageIdIdMap[fieldId]}_${order}`;\n }\n\n return value;\n })\n .filter(Boolean) as string[];\n return createSort({\n fieldPlugins: sortPlugins,\n sort: transformedSort\n });\n};\n\nconst findFieldByFieldId = (model: CmsModel, fieldId: string): CmsModelField | undefined => {\n return model.fields.find(field => {\n return field.fieldId === fieldId;\n });\n};\n/**\n * Latest and published are specific in Elasticsearch to that extend that they are tagged in the __type property.\n * We allow either published or either latest.\n * Latest is used in the manage API and published in the read API.\n */\nconst createInitialQueryValue = (\n params: CreateElasticsearchQueryArgs\n): ElasticsearchBoolQueryConfig => {\n const { model, where: initialWhere } = params;\n /**\n * Cast as partial so we can remove unnecessary keys.\n */\n const where: CmsEntryListWhere = {\n ...initialWhere\n };\n\n const query: ElasticsearchBoolQueryConfig = {\n must: [],\n must_not: [],\n should: [],\n filter: []\n };\n\n // When ES index is shared between tenants, we need to filter records by tenant ID\n const sharedIndex = process.env.ELASTICSEARCH_SHARED_INDEXES === \"true\";\n if (sharedIndex) {\n query.must.push({ term: { \"tenant.keyword\": model.tenant } });\n }\n\n query.must.push({\n term: {\n \"locale.keyword\": model.locale\n }\n });\n\n /**\n * We must transform published and latest where args into something that is understandable by our Elasticsearch\n */\n if (where.published === true) {\n query.must.push({\n term: {\n \"__type.keyword\": createPublishedType()\n }\n });\n } else if (where.latest === true) {\n query.must.push({\n term: {\n \"__type.keyword\": createLatestType()\n }\n });\n }\n // we do not allow not published and not latest\n else {\n throw new WebinyError(\n `Cannot call Elasticsearch query when not setting \"published\" or \"latest\".`,\n \"ELASTICSEARCH_UNSUPPORTED_QUERY\",\n {\n where\n }\n );\n }\n //\n return query;\n};\n\ninterface CreateFieldPathParams {\n modelField: ModelField;\n key: string;\n searchPlugin?: CmsEntryElasticsearchQueryBuilderValueSearchPlugin;\n parentPath?: string | null;\n}\nconst createFieldPath = ({\n modelField,\n searchPlugin,\n parentPath,\n key\n}: CreateFieldPathParams): string => {\n let path: string | null = null;\n if (searchPlugin && typeof searchPlugin.createPath === \"function\") {\n path = searchPlugin.createPath({\n field: modelField.field,\n value: null,\n key\n });\n } else if (typeof modelField.path === \"function\") {\n path = modelField.path(modelField.field.storageId);\n }\n if (!path) {\n /**\n * We know that modelFieldPath is a string or undefined at this point.\n */\n path = (modelField.path as string) || modelField.field.storageId || modelField.field.id;\n }\n return modelField.isSystemField || !parentPath || path.match(parentPath)\n ? path\n : `${parentPath}.${path}`;\n};\n\nconst hasKeyword = (modelField: ModelField): boolean => {\n /**\n * We defined some field types that MUST have no keyword added to the field path\n */\n if (noKeywordFields.includes(modelField.type)) {\n return false;\n } else if (modelField.unmappedType) {\n /**\n * If modelField has unmapped type defined, do not add keyword.\n */\n return false;\n } else if (modelField.keyword === false) {\n /**\n * And if specifically defined that modelField has no keyword, do not add it.\n */\n return false;\n }\n /**\n * All other fields have keyword added.\n */\n return true;\n};\n\ninterface IsRefFieldFilteringParams {\n key: string;\n value: any;\n field: CmsModelField;\n}\n\n/**\n * A list of typeof strings that are 100% not ref field filtering.\n * We also need to check for array and date.\n */\nconst nonRefFieldTypes: string[] = [\n \"string\",\n \"number\",\n \"undefined\",\n \"symbol\",\n \"bigint\",\n \"function\",\n \"boolean\"\n];\nconst isRefFieldFiltering = (params: IsRefFieldFilteringParams): boolean => {\n const { key, value, field } = params;\n const typeOf = typeof value;\n if (\n !value ||\n nonRefFieldTypes.includes(typeOf) ||\n Array.isArray(value) ||\n value instanceof Date ||\n !!value.toISOString\n ) {\n return false;\n } else if (typeOf === \"object\" && field.type === \"ref\") {\n return true;\n }\n throw new WebinyError(\n \"Could not determine if the search value is ref field search.\",\n \"REF_FIELD_SEARCH_ERROR\",\n {\n value,\n field,\n key\n }\n );\n};\n\ninterface FieldPathFactoryParams extends Omit<CreatePathCallableParams, \"field\"> {\n plugin?: CmsEntryElasticsearchQueryBuilderValueSearchPlugin;\n modelField: ModelField;\n key: string;\n parentPath?: string | null;\n keyword?: boolean;\n}\nconst fieldPathFactory = (params: FieldPathFactoryParams): string => {\n const { plugin, modelField, value, parentPath, keyword, key } = params;\n\n const field = modelField.field;\n\n let fieldPath: string | null = null;\n if (plugin) {\n fieldPath = plugin.createPath({ field, value, key });\n }\n if (!fieldPath) {\n fieldPath = field.storageId;\n if (modelField.path) {\n fieldPath =\n typeof modelField.path === \"function\" ? modelField.path(value) : modelField.path;\n }\n }\n\n const keywordValue = keyword ? \".keyword\" : \"\";\n if (!parentPath) {\n return `${fieldPath}${keywordValue}`;\n }\n return `${parentPath}.${fieldPath}${keywordValue}`;\n};\n\ninterface ApplyFilteringParams {\n query: ElasticsearchBoolQueryConfig;\n modelField: ModelField;\n operator: string;\n key: string;\n value: any;\n operatorPlugins: Record<string, ElasticsearchQueryBuilderOperatorPlugin>;\n searchPlugins: Record<string, CmsEntryElasticsearchQueryBuilderValueSearchPlugin>;\n parentPath?: string | null;\n}\nconst applyFiltering = (params: ApplyFilteringParams) => {\n const {\n query,\n modelField,\n operator,\n key,\n value: initialValue,\n operatorPlugins,\n searchPlugins,\n parentPath\n } = params;\n const plugin = operatorPlugins[operator];\n if (!plugin) {\n throw new WebinyError(\"Operator plugin missing.\", \"PLUGIN_MISSING\", {\n operator\n });\n }\n const fieldSearchPlugin = searchPlugins[modelField.type];\n const value = transformValueForSearch({\n plugins: searchPlugins,\n field: modelField.field,\n value: initialValue\n });\n\n const keyword = hasKeyword(modelField);\n plugin.apply(query, {\n basePath: fieldPathFactory({\n plugin: fieldSearchPlugin,\n modelField,\n parentPath: modelField.isSystemField ? null : parentPath,\n value,\n key\n }),\n path: fieldPathFactory({\n plugin: fieldSearchPlugin,\n modelField,\n value,\n parentPath: modelField.isSystemField ? null : parentPath,\n keyword,\n key\n }),\n value,\n keyword\n });\n};\n\ninterface ApplyFullTextSearchParams {\n query: ElasticsearchBoolQueryConfig;\n modelFields: ModelFields;\n term?: string;\n fields: CmsModelField[];\n}\nconst applyFullTextSearch = (params: ApplyFullTextSearchParams): void => {\n const { query, modelFields, term, fields } = params;\n if (!term || term.length === 0 || fields.length === 0) {\n return;\n }\n\n const fieldPaths = fields.reduce((collection, field) => {\n const modelField = modelFields[field.fieldId];\n if (!modelField) {\n return collection;\n }\n\n collection.push(`values.${field.storageId}`);\n\n return collection;\n }, [] as string[]);\n\n query.must.push({\n query_string: {\n allow_leading_wildcard: true,\n fields: fieldPaths,\n query: normalizeValue(term),\n default_operator: \"or\"\n }\n });\n};\n\n/*\n * Iterate through where keys and apply plugins where necessary\n */\nconst execElasticsearchBuildQueryPlugins = (\n params: CreateElasticsearchQueryArgs\n): ElasticsearchBoolQueryConfig => {\n const {\n model,\n where: initialWhere,\n modelFields,\n parentPath,\n plugins,\n searchPlugins,\n fullTextSearch\n } = params;\n\n const where: Partial<CmsEntryListWhere> = {\n ...initialWhere\n };\n const query = createInitialQueryValue({\n ...params,\n where\n });\n\n /**\n * Add full text search for requested fields.\n */\n applyFullTextSearch({\n query,\n modelFields,\n term: fullTextSearch.term,\n fields: fullTextSearch.fields\n });\n\n /**\n * Always remove special fields, as these do not exist in Elasticsearch.\n */\n for (const sf of specialFields) {\n delete where[sf];\n }\n\n if (Object.keys(where).length === 0) {\n return query;\n }\n\n const operatorPlugins = getElasticsearchOperatorPluginsByLocale(plugins, model.locale);\n\n for (const key in where) {\n if (where.hasOwnProperty(key) === false) {\n continue;\n }\n /**\n * We do not need to go further if value is undefined.\n * There are few hardcoded possibilities when value is undefined, for example, ownedBy.\n */\n // TODO figure out how to have type.\n const value = (where as any)[key];\n if (value === undefined) {\n continue;\n }\n const { field, operator } = parseWhereKey(key);\n /**\n * TODO This will be required until the storage operations receive the fieldId instead of field storageId.\n * TODO For this to work without field searching, we need to refactor how the query looks like.\n *\n * Storage operations should NEVER receive an field storageId, only alias - fieldId.\n */\n\n let fieldId = field;\n const cmsModelField = findFieldByFieldId(model, fieldId);\n if (!cmsModelField && !modelFields[fieldId]) {\n throw new WebinyError(`There is no CMS Model Field field \"${fieldId}\".`);\n } else if (cmsModelField) {\n fieldId = cmsModelField.fieldId;\n }\n\n const modelField = modelFields[fieldId];\n\n if (!modelField) {\n throw new WebinyError(`There is no field \"${fieldId}\".`);\n }\n const { isSearchable = false, field: cmsField } = modelField;\n if (!isSearchable) {\n throw new WebinyError(`Field \"${fieldId}\" is not searchable.`);\n }\n /**\n * There is a possibility that value is an object.\n * In that case, check if field is ref field and continue a bit differently.\n */\n if (isRefFieldFiltering({ key, value, field: cmsField })) {\n /**\n * We we need to go through each key in where[key] to determine the filters.\n */\n for (const whereKey in value) {\n const { operator } = parseWhereKey(whereKey);\n applyFiltering({\n query,\n modelField,\n operator,\n key: whereKey,\n value: value[whereKey],\n searchPlugins,\n operatorPlugins,\n parentPath\n });\n }\n continue;\n }\n applyFiltering({\n query,\n modelField,\n operator,\n key,\n value,\n searchPlugins,\n operatorPlugins,\n parentPath\n });\n }\n\n return query;\n};\n\nexport const createElasticsearchQueryBody = (params: CreateElasticsearchParams): esSearchBody => {\n const { plugins, model, args, parentPath = null } = params;\n const { where = {}, after, limit, sort: initialSort, search, fields = [] } = args;\n\n const modelFields = createModelFields(plugins, model);\n const searchPlugins = searchPluginsList(plugins);\n\n const fullTextSearchFields: CmsModelField[] = [];\n /**\n * No point in going through fields if there is no search performed.\n */\n if (!!search) {\n for (const fieldId of fields) {\n const field = model.fields.find(f => f.fieldId === fieldId);\n if (!field) {\n continue;\n }\n fullTextSearchFields.push(field);\n }\n }\n\n const query = execElasticsearchBuildQueryPlugins({\n model,\n plugins,\n where,\n modelFields,\n parentPath,\n searchPlugins,\n fullTextSearch: {\n term: search,\n fields: fullTextSearchFields\n }\n });\n\n const queryPlugins = plugins\n .byType<CmsEntryElasticsearchQueryModifierPlugin>(\n CmsEntryElasticsearchQueryModifierPlugin.type\n )\n .filter(pl => {\n return !pl.modelId || pl.modelId === model.modelId;\n });\n for (const pl of queryPlugins) {\n pl.modifyQuery({ query, model, where });\n }\n\n const sort = createElasticsearchSortParams({\n plugins,\n sort: initialSort,\n modelFields,\n parentPath,\n model,\n searchPlugins\n });\n\n const sortPlugins = plugins\n .byType<CmsEntryElasticsearchSortModifierPlugin>(\n CmsEntryElasticsearchSortModifierPlugin.type\n )\n .filter(pl => {\n return !pl.modelId || pl.modelId === model.modelId;\n });\n for (const pl of sortPlugins) {\n pl.modifySort({\n sort,\n model\n });\n }\n\n const body: esSearchBody = {\n query: {\n bool: {\n must: query.must.length > 0 ? query.must : undefined,\n must_not: query.must_not.length > 0 ? query.must_not : undefined,\n should: query.should.length > 0 ? query.should : undefined,\n filter: query.filter.length > 0 ? query.filter : undefined\n }\n },\n sort,\n size: (limit || 0) + 1,\n // eslint-disable-next-line\n search_after: decodeCursor(after) as any,\n // eslint-disable-next-line\n track_total_hits: true\n };\n\n const bodyPlugins = plugins\n .byType<CmsEntryElasticsearchBodyModifierPlugin>(\n CmsEntryElasticsearchBodyModifierPlugin.type\n )\n .filter(pl => {\n return !pl.modelId || pl.modelId === model.modelId;\n });\n for (const pl of bodyPlugins) {\n pl.modifyBody({\n body,\n model,\n where\n });\n }\n\n return body;\n};\n"],"mappings":";;;;;;;;;;;AAAA;;AACA;;AACA;;AAaA;;AAQA;;AACA;;AAEA;;AACA;;AACA;;AACA;;AAmCA,MAAMA,aAAmD,GAAG,CAAC,WAAD,EAAc,QAAd,CAA5D;AACA,MAAMC,eAAe,GAAG,CAAC,MAAD,EAAS,UAAT,EAAqB,QAArB,EAA+B,SAA/B,CAAxB;;AAEA,MAAMC,6BAA6B,GAAIC,IAAD,IAAiD;EACnF,MAAM;IAAEC,IAAF;IAAQC,WAAR;IAAqBC,UAArB;IAAiCC;EAAjC,IAAmDJ,IAAzD;;EAEA,IAAI,CAACC,IAAD,IAASA,IAAI,CAACI,MAAL,KAAgB,CAA7B,EAAgC;IAC5B,OAAO,EAAP;EACH;;EAED,MAAMC,uBAA+C,GAAG,EAAxD;EAEA,MAAMC,WAAW,GAAGC,MAAM,CAACC,MAAP,CAAcP,WAAd,EAA2BQ,MAA3B,CAAkC,CAACC,OAAD,EAAUC,UAAV,KAAyB;IAC3E,MAAMC,YAAY,GAAGT,aAAa,CAACQ,UAAU,CAACE,IAAZ,CAAlC;IAEA,MAAM;MAAEC,OAAF;MAAWC;IAAX,IAAyBJ,UAAU,CAACK,KAA1C;IAEAX,uBAAuB,CAACS,OAAD,CAAvB,GAAmCA,OAAnC;IACA;AACR;AACA;;IACQJ,OAAO,CAACI,OAAD,CAAP,GAAmB,IAAIG,kEAAJ,CAAqC;MACpDC,YAAY,EAAEP,UAAU,CAACO,YAD2B;MAEpDC,OAAO,EAAEC,UAAU,CAACT,UAAD,CAFiC;MAGpDU,QAAQ,EAAEV,UAAU,CAACW,UAH+B;MAIpDC,UAAU,EAAEZ,UAAU,CAACa,YAJ6B;MAKpDR,KAAK,EAAEF,OAL6C;MAMpDW,IAAI,EAAEC,eAAe,CAAC;QAClBC,GAAG,EAAEZ,SADa;Q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1BX,EAAE,CAACa,UAAH,CAAc;MACVR,IADU;MAEVlF,KAFU;MAGVK;IAHU,CAAd;EAKH;;EAED,OAAO6E,IAAP;AACH,CArGM"}
1
+ {"version":3,"names":["specialFields","noKeywordFields","createElasticsearchSortParams","args","sort","modelFields","parentPath","searchPlugins","length","fieldIdToStorageIdIdMap","sortPlugins","Object","values","reduce","plugins","modelField","searchPlugin","type","fieldId","storageId","field","CmsEntryElasticsearchFieldPlugin","unmappedType","keyword","hasKeyword","sortable","isSortable","searchable","isSearchable","path","createFieldPath","key","transformedSort","map","value","matched","match","order","filter","Boolean","createSort","fieldPlugins","findFieldByFieldId","model","fields","find","createInitialQueryValue","params","where","initialWhere","query","must","must_not","should","sharedIndex","process","env","ELASTICSEARCH_SHARED_INDEXES","push","term","tenant","locale","published","createPublishedType","latest","createLatestType","WebinyError","createPath","id","isSystemField","includes","nonRefFieldTypes","isRefFieldFiltering","typeOf","Array","isArray","Date","toISOString","fieldPathFactory","plugin","fieldPath","keywordValue","applyFiltering","operator","initialValue","operatorPlugins","fieldSearchPlugin","transformValueForSearch","apply","basePath","applyFullTextSearch","fieldPaths","collection","query_string","allow_leading_wildcard","normalizeValue","default_operator","execElasticsearchBuildQueryPlugins","fullTextSearch","sf","keys","getElasticsearchOperatorPluginsByLocale","hasOwnProperty","undefined","parseWhereKey","cmsModelField","cmsField","whereKey","createElasticsearchQueryBody","after","limit","initialSort","search","createModelFields","searchPluginsList","fullTextSearchFields","f","queryPlugins","byType","CmsEntryElasticsearchQueryModifierPlugin","pl","modelId","modifyQuery","CmsEntryElasticsearchSortModifierPlugin","modifySort","body","bool","size","search_after","decodeCursor","track_total_hits","bodyPlugins","CmsEntryElasticsearchBodyModifierPlugin","modifyBody"],"sources":["createElasticsearchQueryBody.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport { transformValueForSearch } from \"./transformValueForSearch\";\nimport { searchPluginsList } from \"./searchPluginsList\";\nimport {\n CmsEntryListParams,\n CmsEntryListSort,\n CmsEntryListWhere,\n CmsModel,\n CmsModelField\n} from \"@webiny/api-headless-cms/types\";\nimport {\n SearchBody as esSearchBody,\n Sort as esSort,\n ElasticsearchBoolQueryConfig\n} from \"@webiny/api-elasticsearch/types\";\nimport {\n decodeCursor,\n createSort,\n parseWhereKey,\n ElasticsearchQueryBuilderOperatorPlugin,\n normalizeValue,\n getElasticsearchOperatorPluginsByLocale\n} from \"@webiny/api-elasticsearch\";\nimport { createModelFields, ModelField, ModelFields } from \"./fields\";\nimport { CmsEntryElasticsearchFieldPlugin } from \"~/plugins/CmsEntryElasticsearchFieldPlugin\";\nimport { PluginsContainer } from \"@webiny/plugins\";\nimport { createLatestType, createPublishedType } from \"~/operations/entry\";\nimport { CmsEntryElasticsearchQueryModifierPlugin } from \"~/plugins/CmsEntryElasticsearchQueryModifierPlugin\";\nimport { CmsEntryElasticsearchSortModifierPlugin } from \"~/plugins/CmsEntryElasticsearchSortModifierPlugin\";\nimport { CmsEntryElasticsearchBodyModifierPlugin } from \"~/plugins/CmsEntryElasticsearchBodyModifierPlugin\";\nimport {\n CmsEntryElasticsearchQueryBuilderValueSearchPlugin,\n CreatePathCallableParams\n} from \"~/plugins/CmsEntryElasticsearchQueryBuilderValueSearchPlugin\";\n\ninterface CreateElasticsearchParams {\n plugins: PluginsContainer;\n model: CmsModel;\n args: CmsEntryListParams;\n parentPath?: string;\n}\n\ninterface CreateElasticsearchSortParams {\n plugins: PluginsContainer;\n sort?: CmsEntryListSort;\n modelFields: ModelFields;\n parentPath?: string | null;\n model: CmsModel;\n searchPlugins: Record<string, CmsEntryElasticsearchQueryBuilderValueSearchPlugin>;\n}\n\ninterface CreateElasticsearchQueryArgs {\n model: CmsModel;\n plugins: PluginsContainer;\n where: CmsEntryListWhere;\n modelFields: ModelFields;\n parentPath?: string | null;\n searchPlugins: Record<string, CmsEntryElasticsearchQueryBuilderValueSearchPlugin>;\n fullTextSearch: {\n term?: string;\n fields: CmsModelField[];\n };\n}\n\nconst specialFields: (keyof Partial<CmsEntryListWhere>)[] = [\"published\", \"latest\"];\nconst noKeywordFields = [\"date\", \"datetime\", \"number\", \"boolean\"];\n\nconst createElasticsearchSortParams = (args: CreateElasticsearchSortParams): esSort => {\n const { sort, modelFields, parentPath, searchPlugins } = args;\n\n if (!sort || sort.length === 0) {\n return [];\n }\n\n const fieldIdToStorageIdIdMap: Record<string, string> = {};\n\n const sortPlugins = Object.values(modelFields).reduce((plugins, modelField) => {\n const searchPlugin = searchPlugins[modelField.type];\n\n const { fieldId, storageId } = modelField.field;\n\n fieldIdToStorageIdIdMap[fieldId] = fieldId;\n /**\n * Plugins must be stored with fieldId as key because it is later used to find the sorting plugin.\n */\n plugins[fieldId] = new CmsEntryElasticsearchFieldPlugin({\n unmappedType: modelField.unmappedType,\n keyword: hasKeyword(modelField),\n sortable: modelField.isSortable,\n searchable: modelField.isSearchable,\n field: fieldId,\n path: createFieldPath({\n key: storageId,\n parentPath,\n modelField,\n searchPlugin\n })\n });\n return plugins;\n }, {} as Record<string, CmsEntryElasticsearchFieldPlugin>);\n\n const transformedSort = sort\n .map(value => {\n const matched = value.match(/^([a-zA-Z-0-9_]+)_(ASC|DESC)$/);\n if (!matched) {\n return null;\n }\n const [, fieldId, order] = matched;\n if (fieldIdToStorageIdIdMap[fieldId]) {\n return `${fieldIdToStorageIdIdMap[fieldId]}_${order}`;\n }\n\n return value;\n })\n .filter(Boolean) as string[];\n return createSort({\n fieldPlugins: sortPlugins,\n sort: transformedSort\n });\n};\n\nconst findFieldByFieldId = (model: CmsModel, fieldId: string): CmsModelField | undefined => {\n return model.fields.find(field => {\n return field.fieldId === fieldId;\n });\n};\n/**\n * Latest and published are specific in Elasticsearch to that extend that they are tagged in the __type property.\n * We allow either published or either latest.\n * Latest is used in the manage API and published in the read API.\n */\nconst createInitialQueryValue = (\n params: CreateElasticsearchQueryArgs\n): ElasticsearchBoolQueryConfig => {\n const { model, where: initialWhere } = params;\n /**\n * Cast as partial so we can remove unnecessary keys.\n */\n const where: CmsEntryListWhere = {\n ...initialWhere\n };\n\n const query: ElasticsearchBoolQueryConfig = {\n must: [],\n must_not: [],\n should: [],\n filter: []\n };\n\n // When ES index is shared between tenants, we need to filter records by tenant ID\n const sharedIndex = process.env.ELASTICSEARCH_SHARED_INDEXES === \"true\";\n if (sharedIndex) {\n query.must.push({ term: { \"tenant.keyword\": model.tenant } });\n }\n\n query.must.push({\n term: {\n \"locale.keyword\": model.locale\n }\n });\n\n /**\n * We must transform published and latest where args into something that is understandable by our Elasticsearch\n */\n if (where.published === true) {\n query.must.push({\n term: {\n \"__type.keyword\": createPublishedType()\n }\n });\n } else if (where.latest === true) {\n query.must.push({\n term: {\n \"__type.keyword\": createLatestType()\n }\n });\n }\n // we do not allow not published and not latest\n else {\n throw new WebinyError(\n `Cannot call Elasticsearch query when not setting \"published\" or \"latest\".`,\n \"ELASTICSEARCH_UNSUPPORTED_QUERY\",\n {\n where\n }\n );\n }\n //\n return query;\n};\n\ninterface CreateFieldPathParams {\n modelField: ModelField;\n key: string;\n searchPlugin?: CmsEntryElasticsearchQueryBuilderValueSearchPlugin;\n parentPath?: string | null;\n}\nconst createFieldPath = ({\n modelField,\n searchPlugin,\n parentPath,\n key\n}: CreateFieldPathParams): string => {\n let path: string | null = null;\n if (searchPlugin && typeof searchPlugin.createPath === \"function\") {\n path = searchPlugin.createPath({\n field: modelField.field,\n value: null,\n key\n });\n } else if (typeof modelField.path === \"function\") {\n path = modelField.path(modelField.field.storageId);\n }\n if (!path) {\n /**\n * We know that modelFieldPath is a string or undefined at this point.\n */\n path = (modelField.path as string) || modelField.field.storageId || modelField.field.id;\n }\n return modelField.isSystemField || !parentPath || path.match(parentPath)\n ? path\n : `${parentPath}.${path}`;\n};\n\nconst hasKeyword = (modelField: ModelField): boolean => {\n /**\n * We defined some field types that MUST have no keyword added to the field path\n */\n if (noKeywordFields.includes(modelField.type)) {\n return false;\n } else if (modelField.unmappedType) {\n /**\n * If modelField has unmapped type defined, do not add keyword.\n */\n return false;\n } else if (modelField.keyword === false) {\n /**\n * And if specifically defined that modelField has no keyword, do not add it.\n */\n return false;\n }\n /**\n * All other fields have keyword added.\n */\n return true;\n};\n\ninterface IsRefFieldFilteringParams {\n key: string;\n value: any;\n field: CmsModelField;\n}\n\n/**\n * A list of typeof strings that are 100% not ref field filtering.\n * We also need to check for array and date.\n */\nconst nonRefFieldTypes: string[] = [\n \"string\",\n \"number\",\n \"undefined\",\n \"symbol\",\n \"bigint\",\n \"function\",\n \"boolean\"\n];\nconst isRefFieldFiltering = (params: IsRefFieldFilteringParams): boolean => {\n const { key, value, field } = params;\n const typeOf = typeof value;\n if (\n !value ||\n nonRefFieldTypes.includes(typeOf) ||\n Array.isArray(value) ||\n value instanceof Date ||\n !!value.toISOString\n ) {\n return false;\n } else if (typeOf === \"object\" && field.type === \"ref\") {\n return true;\n }\n throw new WebinyError(\n \"Could not determine if the search value is ref field search.\",\n \"REF_FIELD_SEARCH_ERROR\",\n {\n value,\n field,\n key\n }\n );\n};\n\ninterface FieldPathFactoryParams extends Omit<CreatePathCallableParams, \"field\"> {\n plugin?: CmsEntryElasticsearchQueryBuilderValueSearchPlugin;\n modelField: ModelField;\n key: string;\n parentPath?: string | null;\n keyword?: boolean;\n}\nconst fieldPathFactory = (params: FieldPathFactoryParams): string => {\n const { plugin, modelField, value, parentPath, keyword, key } = params;\n\n const field = modelField.field;\n\n let fieldPath: string | null = null;\n if (plugin) {\n fieldPath = plugin.createPath({ field, value, key });\n }\n if (!fieldPath) {\n fieldPath = field.storageId;\n if (modelField.path) {\n fieldPath =\n typeof modelField.path === \"function\" ? modelField.path(value) : modelField.path;\n }\n }\n\n const keywordValue = keyword ? \".keyword\" : \"\";\n if (!parentPath) {\n return `${fieldPath}${keywordValue}`;\n }\n return `${parentPath}.${fieldPath}${keywordValue}`;\n};\n\ninterface ApplyFilteringParams {\n query: ElasticsearchBoolQueryConfig;\n modelField: ModelField;\n operator: string;\n key: string;\n value: any;\n operatorPlugins: Record<string, ElasticsearchQueryBuilderOperatorPlugin>;\n searchPlugins: Record<string, CmsEntryElasticsearchQueryBuilderValueSearchPlugin>;\n parentPath?: string | null;\n}\nconst applyFiltering = (params: ApplyFilteringParams) => {\n const {\n query,\n modelField,\n operator,\n key,\n value: initialValue,\n operatorPlugins,\n searchPlugins,\n parentPath\n } = params;\n const plugin = operatorPlugins[operator];\n if (!plugin) {\n throw new WebinyError(\"Operator plugin missing.\", \"PLUGIN_MISSING\", {\n operator\n });\n }\n const fieldSearchPlugin = searchPlugins[modelField.type];\n const value = transformValueForSearch({\n plugins: searchPlugins,\n field: modelField.field,\n value: initialValue\n });\n\n const keyword = hasKeyword(modelField);\n plugin.apply(query, {\n basePath: fieldPathFactory({\n plugin: fieldSearchPlugin,\n modelField,\n parentPath: modelField.isSystemField ? null : parentPath,\n value,\n key\n }),\n path: fieldPathFactory({\n plugin: fieldSearchPlugin,\n modelField,\n value,\n parentPath: modelField.isSystemField ? null : parentPath,\n keyword,\n key\n }),\n value,\n keyword\n });\n};\n\ninterface ApplyFullTextSearchParams {\n query: ElasticsearchBoolQueryConfig;\n modelFields: ModelFields;\n term?: string;\n fields: CmsModelField[];\n}\nconst applyFullTextSearch = (params: ApplyFullTextSearchParams): void => {\n const { query, modelFields, term, fields } = params;\n if (!term || term.length === 0 || fields.length === 0) {\n return;\n }\n\n const fieldPaths = fields.reduce((collection, field) => {\n const modelField = modelFields[field.fieldId];\n if (!modelField) {\n return collection;\n }\n\n collection.push(`values.${field.storageId}`);\n\n return collection;\n }, [] as string[]);\n\n query.must.push({\n query_string: {\n allow_leading_wildcard: true,\n fields: fieldPaths,\n query: normalizeValue(term),\n default_operator: \"or\"\n }\n });\n};\n\n/*\n * Iterate through where keys and apply plugins where necessary\n */\nconst execElasticsearchBuildQueryPlugins = (\n params: CreateElasticsearchQueryArgs\n): ElasticsearchBoolQueryConfig => {\n const {\n model,\n where: initialWhere,\n modelFields,\n parentPath,\n plugins,\n searchPlugins,\n fullTextSearch\n } = params;\n\n const where: Partial<CmsEntryListWhere> = {\n ...initialWhere\n };\n const query = createInitialQueryValue({\n ...params,\n where\n });\n\n /**\n * Add full text search for requested fields.\n */\n applyFullTextSearch({\n query,\n modelFields,\n term: fullTextSearch.term,\n fields: fullTextSearch.fields\n });\n\n /**\n * Always remove special fields, as these do not exist in Elasticsearch.\n */\n for (const sf of specialFields) {\n delete where[sf];\n }\n\n if (Object.keys(where).length === 0) {\n return query;\n }\n\n const operatorPlugins = getElasticsearchOperatorPluginsByLocale(plugins, model.locale);\n\n for (const key in where) {\n if (where.hasOwnProperty(key) === false) {\n continue;\n }\n /**\n * We do not need to go further if value is undefined.\n * There are few hardcoded possibilities when value is undefined, for example, ownedBy.\n */\n // TODO figure out how to have type.\n const value = (where as any)[key];\n if (value === undefined) {\n continue;\n }\n const { field, operator } = parseWhereKey(key);\n /**\n * TODO This will be required until the storage operations receive the fieldId instead of field storageId.\n * TODO For this to work without field searching, we need to refactor how the query looks like.\n *\n * Storage operations should NEVER receive an field storageId, only alias - fieldId.\n */\n\n let fieldId = field;\n const cmsModelField = findFieldByFieldId(model, fieldId);\n if (!cmsModelField && !modelFields[fieldId]) {\n throw new WebinyError(`There is no CMS Model Field field \"${fieldId}\".`);\n } else if (cmsModelField) {\n fieldId = cmsModelField.fieldId;\n }\n\n const modelField = modelFields[fieldId];\n\n if (!modelField) {\n throw new WebinyError(`There is no field \"${fieldId}\".`);\n }\n const { isSearchable = false, field: cmsField } = modelField;\n if (!isSearchable) {\n throw new WebinyError(`Field \"${fieldId}\" is not searchable.`);\n }\n /**\n * There is a possibility that value is an object.\n * In that case, check if field is ref field and continue a bit differently.\n */\n if (isRefFieldFiltering({ key, value, field: cmsField })) {\n /**\n * We we need to go through each key in where[key] to determine the filters.\n */\n for (const whereKey in value) {\n const { operator } = parseWhereKey(whereKey);\n applyFiltering({\n query,\n modelField,\n operator,\n key: whereKey,\n value: value[whereKey],\n searchPlugins,\n operatorPlugins,\n parentPath\n });\n }\n continue;\n }\n applyFiltering({\n query,\n modelField,\n operator,\n key,\n value,\n searchPlugins,\n operatorPlugins,\n parentPath\n });\n }\n\n return query;\n};\n\nexport const createElasticsearchQueryBody = (params: CreateElasticsearchParams): esSearchBody => {\n const { plugins, model, args, parentPath = null } = params;\n const { where = {}, after, limit, sort: initialSort, search, fields = [] } = args;\n\n const modelFields = createModelFields(plugins, model);\n const searchPlugins = searchPluginsList(plugins);\n\n const fullTextSearchFields: CmsModelField[] = [];\n /**\n * No point in going through fields if there is no search performed.\n */\n if (!!search) {\n for (const fieldId of fields) {\n const field = model.fields.find(f => f.fieldId === fieldId);\n if (!field) {\n continue;\n }\n fullTextSearchFields.push(field);\n }\n }\n\n const query = execElasticsearchBuildQueryPlugins({\n model,\n plugins,\n where,\n modelFields,\n parentPath,\n searchPlugins,\n fullTextSearch: {\n term: search,\n fields: fullTextSearchFields\n }\n });\n\n const queryPlugins = plugins\n .byType<CmsEntryElasticsearchQueryModifierPlugin>(\n CmsEntryElasticsearchQueryModifierPlugin.type\n )\n .filter(pl => {\n return !pl.modelId || pl.modelId === model.modelId;\n });\n for (const pl of queryPlugins) {\n pl.modifyQuery({ query, model, where });\n }\n\n const sort = createElasticsearchSortParams({\n plugins,\n sort: initialSort,\n modelFields,\n parentPath,\n model,\n searchPlugins\n });\n\n const sortPlugins = plugins\n .byType<CmsEntryElasticsearchSortModifierPlugin>(\n CmsEntryElasticsearchSortModifierPlugin.type\n )\n .filter(pl => {\n return !pl.modelId || pl.modelId === model.modelId;\n });\n for (const pl of sortPlugins) {\n pl.modifySort({\n sort,\n model\n });\n }\n\n const body: esSearchBody = {\n query: {\n bool: {\n must: query.must.length > 0 ? query.must : undefined,\n must_not: query.must_not.length > 0 ? query.must_not : undefined,\n should: query.should.length > 0 ? query.should : undefined,\n filter: query.filter.length > 0 ? query.filter : undefined\n }\n },\n sort,\n size: (limit || 0) + 1,\n // eslint-disable-next-line\n search_after: decodeCursor(after) as any,\n // eslint-disable-next-line\n track_total_hits: true\n };\n\n const bodyPlugins = plugins\n .byType<CmsEntryElasticsearchBodyModifierPlugin>(\n CmsEntryElasticsearchBodyModifierPlugin.type\n )\n .filter(pl => {\n return !pl.modelId || pl.modelId === model.modelId;\n });\n for (const pl of bodyPlugins) {\n pl.modifyBody({\n body,\n model,\n where\n });\n }\n\n return body;\n};\n"],"mappings":";;;;;;;;;;;AAAA;;AACA;;AACA;;AAaA;;AAQA;;AACA;;AAEA;;AACA;;AACA;;AACA;;;;;;AAmCA,MAAMA,aAAmD,GAAG,CAAC,WAAD,EAAc,QAAd,CAA5D;AACA,MAAMC,eAAe,GAAG,CAAC,MAAD,EAAS,UAAT,EAAqB,QAArB,EAA+B,SAA/B,CAAxB;;AAEA,MAAMC,6BAA6B,GAAIC,IAAD,IAAiD;EACnF,MAAM;IAAEC,IAAF;IAAQC,WAAR;IAAqBC,UAArB;IAAiCC;EAAjC,IAAmDJ,IAAzD;;EAEA,IAAI,CAACC,IAAD,IAASA,IAAI,CAACI,MAAL,KAAgB,CAA7B,EAAgC;IAC5B,OAAO,EAAP;EACH;;EAED,MAAMC,uBAA+C,GAAG,EAAxD;EAEA,MAAMC,WAAW,GAAGC,MAAM,CAACC,MAAP,CAAcP,WAAd,EAA2BQ,MAA3B,CAAkC,CAACC,OAAD,EAAUC,UAAV,KAAyB;IAC3E,MAAMC,YAAY,GAAGT,aAAa,CAACQ,UAAU,CAACE,IAAZ,CAAlC;IAEA,MAAM;MAAEC,OAAF;MAAWC;IAAX,IAAyBJ,UAAU,CAACK,KAA1C;IAEAX,uBAAuB,CAACS,OAAD,CAAvB,GAAmCA,OAAnC;IACA;AACR;AACA;;IACQJ,OAAO,CAACI,OAAD,CAAP,GAAmB,IAAIG,kEAAJ,CAAqC;MACpDC,YAAY,EAAEP,UAAU,CAACO,YAD2B;MAEpDC,OAAO,EAAEC,UAAU,CAACT,UAAD,CAFiC;MAGpDU,QAAQ,EAAEV,UAAU,CAACW,UAH+B;MAIpDC,UAAU,EAAEZ,UAAU,CAACa,YAJ6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Ae9E,KAAK,CAAC8E,OAA3C;EACH,CANe,CAApB;;EAOA,KAAK,MAAMD,EAAX,IAAiBW,WAAjB,EAA8B;IAC1BX,EAAE,CAACa,UAAH,CAAc;MACVR,IADU;MAEVlF,KAFU;MAGVK;IAHU,CAAd;EAKH;;EAED,OAAO6E,IAAP;AACH,CArGM"}
package/helpers/fields.js CHANGED
@@ -1,18 +1,22 @@
1
1
  "use strict";
2
2
 
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
4
 
5
5
  Object.defineProperty(exports, "__esModule", {
6
6
  value: true
7
7
  });
8
8
  exports.systemFields = exports.createModelFields = void 0;
9
9
 
10
- var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
10
+ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
11
11
 
12
12
  var _error = _interopRequireDefault(require("@webiny/error"));
13
13
 
14
14
  var _cloneDeep = _interopRequireDefault(require("lodash/cloneDeep"));
15
15
 
16
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
17
+
18
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
19
+
16
20
  const createSystemField = field => {
17
21
  if (!field.storageId) {
18
22
  throw new _error.default(`When creating system field it must have a "storageId".`, "SYSTEM_FIELD_ERROR", {
@@ -28,7 +32,7 @@ const createSystemField = field => {
28
32
  });
29
33
  }
30
34
 
31
- return (0, _objectSpread2.default)((0, _objectSpread2.default)({}, field), {}, {
35
+ return _objectSpread(_objectSpread({}, field), {}, {
32
36
  id: field.fieldId,
33
37
  label: field.fieldId
34
38
  });
@@ -127,19 +131,6 @@ const systemFields = {
127
131
  fieldId: "version",
128
132
  type: "number"
129
133
  })
130
- },
131
- status: {
132
- type: "string",
133
- unmappedType: undefined,
134
- keyword: false,
135
- isSystemField: true,
136
- isSearchable: true,
137
- isSortable: false,
138
- field: createSystemField({
139
- storageId: "status",
140
- fieldId: "status",
141
- type: "string"
142
- })
143
134
  }
144
135
  };
145
136
  /*
@@ -170,8 +161,8 @@ const createModelFields = (plugins, model) => {
170
161
  } = plugin;
171
162
  types[fieldType] = {
172
163
  unmappedType: unmappedTypes[fieldType],
173
- isSearchable,
174
- isSortable
164
+ isSearchable: isSearchable === true,
165
+ isSortable: isSortable === true
175
166
  };
176
167
  return types;
177
168
  }, {});
@@ -1 +1 @@
1
- {"version":3,"names":["createSystemField","field","storageId","WebinyError","fieldId","type","id","label","systemFields","isSystemField","isSearchable","isSortable","entryId","savedOn","unmappedType","keyword","settings","createdOn","createdBy","undefined","path","ownedBy","version","status","createModelFields","plugins","model","unmappedTypes","byType","reduce","acc","plugin","fieldType","fieldTypePlugins","types","fields","lodashCloneDeep"],"sources":["fields.ts"],"sourcesContent":["import {\n CmsModel,\n CmsModelField,\n CmsModelFieldToGraphQLPlugin\n} from \"@webiny/api-headless-cms/types\";\nimport WebinyError from \"@webiny/error\";\nimport { CmsModelFieldToElasticsearchPlugin } from \"~/types\";\nimport { PluginsContainer } from \"@webiny/plugins\";\nimport lodashCloneDeep from \"lodash/cloneDeep\";\n\ntype ModelFieldPath = string | ((value: string) => string);\nexport interface ModelField {\n unmappedType?: string;\n keyword?: boolean;\n isSearchable: boolean;\n isSortable: boolean;\n type: string;\n isSystemField?: boolean;\n field: CmsModelField;\n path?: ModelFieldPath;\n}\n\nexport interface ModelFields {\n [fieldId: string]: ModelField;\n}\n\ntype UnmappedFieldTypes = {\n [type: string]: (field: CmsModelField) => string | undefined;\n};\n\ninterface FieldTypePlugin {\n unmappedType?: (field: CmsModelField) => string | undefined;\n isSearchable: boolean;\n isSortable: boolean;\n}\ntype FieldTypePlugins = Record<string, FieldTypePlugin>;\n\ntype PartialCmsModelField = Partial<CmsModelField> &\n Pick<CmsModelField, \"storageId\" | \"fieldId\" | \"type\">;\nconst createSystemField = (field: PartialCmsModelField): CmsModelField => {\n if (!field.storageId) {\n throw new WebinyError(\n `When creating system field it must have a \"storageId\".`,\n \"SYSTEM_FIELD_ERROR\",\n {\n field\n }\n );\n } else if (!field.fieldId) {\n throw new WebinyError(\n `When creating system field it must have a \"fieldId\".`,\n \"SYSTEM_FIELD_ERROR\",\n {\n field\n }\n );\n } else if (!field.type) {\n throw new WebinyError(\n `When creating system field it must have a \"type\".`,\n \"SYSTEM_FIELD_ERROR\",\n {\n field\n }\n );\n }\n return {\n ...field,\n id: field.fieldId,\n label: field.fieldId\n };\n};\n\nexport const systemFields: ModelFields = {\n id: {\n type: \"text\",\n isSystemField: true,\n isSearchable: true,\n isSortable: true,\n field: createSystemField({\n storageId: \"id\",\n fieldId: \"id\",\n type: \"text\"\n })\n },\n entryId: {\n type: \"text\",\n isSystemField: true,\n isSearchable: true,\n isSortable: true,\n field: createSystemField({\n storageId: \"entryId\",\n fieldId: \"entryId\",\n type: \"text\"\n })\n },\n savedOn: {\n type: \"date\",\n unmappedType: \"date\",\n keyword: false,\n isSystemField: true,\n isSearchable: true,\n isSortable: true,\n field: createSystemField({\n storageId: \"savedOn\",\n fieldId: \"savedOn\",\n type: \"datetime\",\n settings: {\n type: \"dateTimeWithoutTimezone\"\n }\n })\n },\n createdOn: {\n type: \"date\",\n unmappedType: \"date\",\n keyword: false,\n isSystemField: true,\n isSearchable: true,\n isSortable: true,\n field: createSystemField({\n storageId: \"createdOn\",\n fieldId: \"createdOn\",\n type: \"text\",\n settings: {\n type: \"dateTimeWithoutTimezone\"\n }\n })\n },\n createdBy: {\n type: \"text\",\n unmappedType: undefined,\n isSystemField: true,\n isSearchable: true,\n isSortable: false,\n path: \"createdBy.id\",\n field: createSystemField({\n storageId: \"createdBy\",\n fieldId: \"createdBy\",\n type: \"text\"\n })\n },\n ownedBy: {\n type: \"text\",\n unmappedType: undefined,\n isSystemField: true,\n isSearchable: true,\n isSortable: false,\n path: \"ownedBy.id\",\n field: createSystemField({\n storageId: \"ownedBy\",\n fieldId: \"ownedBy\",\n type: \"text\"\n })\n },\n version: {\n type: \"number\",\n unmappedType: undefined,\n keyword: false,\n isSystemField: true,\n isSearchable: true,\n isSortable: true,\n field: createSystemField({\n storageId: \"version\",\n fieldId: \"version\",\n type: \"number\"\n })\n },\n status: {\n type: \"string\",\n unmappedType: undefined,\n keyword: false,\n isSystemField: true,\n isSearchable: true,\n isSortable: false,\n field: createSystemField({\n storageId: \"status\",\n fieldId: \"status\",\n type: \"string\"\n })\n }\n};\n\n/*\n * Create an object with key fieldType and options for that field\n */\nexport const createModelFields = (plugins: PluginsContainer, model: CmsModel): ModelFields => {\n // collect all unmappedType from elastic plugins\n const unmappedTypes = plugins\n .byType<CmsModelFieldToElasticsearchPlugin>(\"cms-model-field-to-elastic-search\")\n .reduce((acc, plugin) => {\n if (!plugin.unmappedType) {\n return acc;\n }\n acc[plugin.fieldType] = plugin.unmappedType;\n return acc;\n }, {} as UnmappedFieldTypes);\n /**\n * collect all field types from the plugins\n */\n const fieldTypePlugins = plugins\n .byType<CmsModelFieldToGraphQLPlugin>(\"cms-model-field-to-graphql\")\n .reduce((types, plugin) => {\n const { fieldType, isSearchable, isSortable } = plugin;\n types[fieldType] = {\n unmappedType: unmappedTypes[fieldType],\n isSearchable,\n isSortable\n };\n return types;\n }, {} as FieldTypePlugins);\n\n return model.fields.reduce((fields, field) => {\n const { fieldId, type } = field;\n if (!fieldTypePlugins[type]) {\n throw new WebinyError(`There is no plugin for field type \"${type}\".`);\n }\n const { isSearchable, isSortable, unmappedType } = fieldTypePlugins[type];\n fields[fieldId] = {\n type,\n isSearchable,\n isSortable,\n unmappedType: typeof unmappedType === \"function\" ? unmappedType(field) : undefined,\n isSystemField: false,\n field\n };\n\n return fields;\n }, lodashCloneDeep(systemFields));\n};\n"],"mappings":";;;;;;;;;;;AAKA;;AAGA;;AA+BA,MAAMA,iBAAiB,GAAIC,KAAD,IAAgD;EACtE,IAAI,CAACA,KAAK,CAACC,SAAX,EAAsB;IAClB,MAAM,IAAIC,cAAJ,CACD,wDADC,EAEF,oBAFE,EAGF;MACIF;IADJ,CAHE,CAAN;EAOH,CARD,MAQO,IAAI,CAACA,KAAK,CAACG,OAAX,EAAoB;IACvB,MAAM,IAAID,cAAJ,CACD,sDADC,EAEF,oBAFE,EAGF;MACIF;IADJ,CAHE,CAAN;EAOH,CARM,MAQA,IAAI,CAACA,KAAK,CAACI,IAAX,EAAiB;IACpB,MAAM,IAAIF,cAAJ,CACD,mDADC,EAEF,oBAFE,EAGF;MACIF;IADJ,CAHE,CAAN;EAOH;;EACD,mEACOA,KADP;IAEIK,EAAE,EAAEL,KAAK,CAACG,OAFd;IAGIG,KAAK,EAAEN,KAAK,CAACG;EAHjB;AAKH,CA/BD;;AAiCO,MAAMI,YAAyB,GAAG;EACrCF,EAAE,EAAE;IACAD,IAAI,EAAE,MADN;IAEAI,aAAa,EAAE,IAFf;IAGAC,YAAY,EAAE,IAHd;IAIAC,UAAU,EAAE,IAJZ;IAKAV,KAAK,EAAED,iBAAiB,CAAC;MACrBE,SAAS,EAAE,IADU;MAErBE,OAAO,EAAE,IAFY;MAGrBC,IAAI,EAAE;IAHe,CAAD;EALxB,CADiC;EAYrCO,OAAO,EAAE;IACLP,IAAI,EAAE,MADD;IAELI,aAAa,EAAE,IAFV;IAGLC,YAAY,EAAE,IAHT;IAILC,UAAU,EAAE,IAJP;IAKLV,KAAK,EAAED,iBAAiB,CAAC;MACrBE,SAAS,EAAE,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ADjB,EAEpBC,MAFoB,CAEb,CAACK,KAAD,EAAQH,MAAR,KAAmB;IACvB,MAAM;MAAEC,SAAF;MAAatB,YAAb;MAA2BC;IAA3B,IAA0CoB,MAAhD;IACAG,KAAK,CAACF,SAAD,CAAL,GAAmB;MACflB,YAAY,EAAEa,aAAa,CAACK,SAAD,CADZ;MAEftB,YAFe;MAGfC;IAHe,CAAnB;IAKA,OAAOuB,KAAP;EACH,CAVoB,EAUlB,EAVkB,CAAzB;EAYA,OAAOR,KAAK,CAACS,MAAN,CAAaN,MAAb,CAAoB,CAACM,MAAD,EAASlC,KAAT,KAAmB;IAC1C,MAAM;MAAEG,OAAF;MAAWC;IAAX,IAAoBJ,KAA1B;;IACA,IAAI,CAACgC,gBAAgB,CAAC5B,IAAD,CAArB,EAA6B;MACzB,MAAM,IAAIF,cAAJ,CAAiB,sCAAqCE,IAAK,IAA3D,CAAN;IACH;;IACD,MAAM;MAAEK,YAAF;MAAgBC,UAAhB;MAA4BG;IAA5B,IAA6CmB,gBAAgB,CAAC5B,IAAD,CAAnE;IACA8B,MAAM,CAAC/B,OAAD,CAAN,GAAkB;MACdC,IADc;MAEdK,YAFc;MAGdC,UAHc;MAIdG,YAAY,EAAE,OAAOA,YAAP,KAAwB,UAAxB,GAAqCA,YAAY,CAACb,KAAD,CAAjD,GAA2DkB,SAJ3D;MAKdV,aAAa,EAAE,KALD;MAMdR;IANc,CAAlB;IASA,OAAOkC,MAAP;EACH,CAhBM,EAgBJ,IAAAC,kBAAA,EAAgB5B,YAAhB,CAhBI,CAAP;AAiBH,CA3CM"}
1
+ {"version":3,"names":["createSystemField","field","storageId","WebinyError","fieldId","type","id","label","systemFields","isSystemField","isSearchable","isSortable","entryId","savedOn","unmappedType","keyword","settings","createdOn","createdBy","undefined","path","ownedBy","version","createModelFields","plugins","model","unmappedTypes","byType","reduce","acc","plugin","fieldType","fieldTypePlugins","types","fields","lodashCloneDeep"],"sources":["fields.ts"],"sourcesContent":["import {\n CmsModel,\n CmsModelField,\n CmsModelFieldToGraphQLPlugin\n} from \"@webiny/api-headless-cms/types\";\nimport WebinyError from \"@webiny/error\";\nimport { CmsModelFieldToElasticsearchPlugin } from \"~/types\";\nimport { PluginsContainer } from \"@webiny/plugins\";\nimport lodashCloneDeep from \"lodash/cloneDeep\";\n\ntype ModelFieldPath = string | ((value: string) => string);\nexport interface ModelField {\n unmappedType?: string;\n keyword?: boolean;\n isSearchable: boolean;\n isSortable: boolean;\n type: string;\n isSystemField?: boolean;\n field: CmsModelField;\n path?: ModelFieldPath;\n}\n\nexport interface ModelFields {\n [fieldId: string]: ModelField;\n}\n\ntype UnmappedFieldTypes = {\n [type: string]: (field: CmsModelField) => string | undefined;\n};\n\ninterface FieldTypePlugin {\n unmappedType?: (field: CmsModelField) => string | undefined;\n isSearchable: boolean;\n isSortable: boolean;\n}\ntype FieldTypePlugins = Record<string, FieldTypePlugin>;\n\ntype PartialCmsModelField = Partial<CmsModelField> &\n Pick<CmsModelField, \"storageId\" | \"fieldId\" | \"type\">;\nconst createSystemField = (field: PartialCmsModelField): CmsModelField => {\n if (!field.storageId) {\n throw new WebinyError(\n `When creating system field it must have a \"storageId\".`,\n \"SYSTEM_FIELD_ERROR\",\n {\n field\n }\n );\n } else if (!field.fieldId) {\n throw new WebinyError(\n `When creating system field it must have a \"fieldId\".`,\n \"SYSTEM_FIELD_ERROR\",\n {\n field\n }\n );\n } else if (!field.type) {\n throw new WebinyError(\n `When creating system field it must have a \"type\".`,\n \"SYSTEM_FIELD_ERROR\",\n {\n field\n }\n );\n }\n return {\n ...field,\n id: field.fieldId,\n label: field.fieldId\n };\n};\n\nexport const systemFields: ModelFields = {\n id: {\n type: \"text\",\n isSystemField: true,\n isSearchable: true,\n isSortable: true,\n field: createSystemField({\n storageId: \"id\",\n fieldId: \"id\",\n type: \"text\"\n })\n },\n entryId: {\n type: \"text\",\n isSystemField: true,\n isSearchable: true,\n isSortable: true,\n field: createSystemField({\n storageId: \"entryId\",\n fieldId: \"entryId\",\n type: \"text\"\n })\n },\n savedOn: {\n type: \"date\",\n unmappedType: \"date\",\n keyword: false,\n isSystemField: true,\n isSearchable: true,\n isSortable: true,\n field: createSystemField({\n storageId: \"savedOn\",\n fieldId: \"savedOn\",\n type: \"datetime\",\n settings: {\n type: \"dateTimeWithoutTimezone\"\n }\n })\n },\n createdOn: {\n type: \"date\",\n unmappedType: \"date\",\n keyword: false,\n isSystemField: true,\n isSearchable: true,\n isSortable: true,\n field: createSystemField({\n storageId: \"createdOn\",\n fieldId: \"createdOn\",\n type: \"text\",\n settings: {\n type: \"dateTimeWithoutTimezone\"\n }\n })\n },\n createdBy: {\n type: \"text\",\n unmappedType: undefined,\n isSystemField: true,\n isSearchable: true,\n isSortable: false,\n path: \"createdBy.id\",\n field: createSystemField({\n storageId: \"createdBy\",\n fieldId: \"createdBy\",\n type: \"text\"\n })\n },\n ownedBy: {\n type: \"text\",\n unmappedType: undefined,\n isSystemField: true,\n isSearchable: true,\n isSortable: false,\n path: \"ownedBy.id\",\n field: createSystemField({\n storageId: \"ownedBy\",\n fieldId: \"ownedBy\",\n type: \"text\"\n })\n },\n version: {\n type: \"number\",\n unmappedType: undefined,\n keyword: false,\n isSystemField: true,\n isSearchable: true,\n isSortable: true,\n field: createSystemField({\n storageId: \"version\",\n fieldId: \"version\",\n type: \"number\"\n })\n }\n};\n\n/*\n * Create an object with key fieldType and options for that field\n */\nexport const createModelFields = (plugins: PluginsContainer, model: CmsModel): ModelFields => {\n // collect all unmappedType from elastic plugins\n const unmappedTypes = plugins\n .byType<CmsModelFieldToElasticsearchPlugin>(\"cms-model-field-to-elastic-search\")\n .reduce((acc, plugin) => {\n if (!plugin.unmappedType) {\n return acc;\n }\n acc[plugin.fieldType] = plugin.unmappedType;\n return acc;\n }, {} as UnmappedFieldTypes);\n /**\n * collect all field types from the plugins\n */\n const fieldTypePlugins = plugins\n .byType<CmsModelFieldToGraphQLPlugin>(\"cms-model-field-to-graphql\")\n .reduce((types, plugin) => {\n const { fieldType, isSearchable, isSortable } = plugin;\n types[fieldType] = {\n unmappedType: unmappedTypes[fieldType],\n isSearchable: isSearchable === true,\n isSortable: isSortable === true\n };\n return types;\n }, {} as FieldTypePlugins);\n\n return model.fields.reduce((fields, field) => {\n const { fieldId, type } = field;\n if (!fieldTypePlugins[type]) {\n throw new WebinyError(`There is no plugin for field type \"${type}\".`);\n }\n const { isSearchable, isSortable, unmappedType } = fieldTypePlugins[type];\n fields[fieldId] = {\n type,\n isSearchable,\n isSortable,\n unmappedType: typeof unmappedType === \"function\" ? unmappedType(field) : undefined,\n isSystemField: false,\n field\n };\n\n return fields;\n }, lodashCloneDeep(systemFields));\n};\n"],"mappings":";;;;;;;;;;;AAKA;;AAGA;;;;;;AA+BA,MAAMA,iBAAiB,GAAIC,KAAD,IAAgD;EACtE,IAAI,CAACA,KAAK,CAACC,SAAX,EAAsB;IAClB,MAAM,IAAIC,cAAJ,CACD,wDADC,EAEF,oBAFE,EAGF;MACIF;IADJ,CAHE,CAAN;EAOH,CARD,MAQO,IAAI,CAACA,KAAK,CAACG,OAAX,EAAoB;IACvB,MAAM,IAAID,cAAJ,CACD,sDADC,EAEF,oBAFE,EAGF;MACIF;IADJ,CAHE,CAAN;EAOH,CARM,MAQA,IAAI,CAACA,KAAK,CAACI,IAAX,EAAiB;IACpB,MAAM,IAAIF,cAAJ,CACD,mDADC,EAEF,oBAFE,EAGF;MACIF;IADJ,CAHE,CAAN;EAOH;;EACD,uCACOA,KADP;IAEIK,EAAE,EAAEL,KAAK,CAACG,OAFd;IAGIG,KAAK,EAAEN,KAAK,CAACG;EAHjB;AAKH,CA/BD;;AAiCO,MAAMI,YAAyB,GAAG;EACrCF,EAAE,EAAE;IACAD,IAAI,EAAE,MADN;IAEAI,aAAa,EAAE,IAFf;IAGAC,YAAY,EAAE,IAHd;IAIAC,UAAU,EAAE,IAJZ;IAKAV,KAAK,EAAED,iBAAiB,CAAC;MACrBE,SAAS,EAAE,IADU;MAErBE,OAAO,EAAE,IAF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,YAAb;MAA2BC;IAA3B,IAA0CmB,MAAhD;IACAG,KAAK,CAACF,SAAD,CAAL,GAAmB;MACfjB,YAAY,EAAEY,aAAa,CAACK,SAAD,CADZ;MAEfrB,YAAY,EAAEA,YAAY,KAAK,IAFhB;MAGfC,UAAU,EAAEA,UAAU,KAAK;IAHZ,CAAnB;IAKA,OAAOsB,KAAP;EACH,CAVoB,EAUlB,EAVkB,CAAzB;EAYA,OAAOR,KAAK,CAACS,MAAN,CAAaN,MAAb,CAAoB,CAACM,MAAD,EAASjC,KAAT,KAAmB;IAC1C,MAAM;MAAEG,OAAF;MAAWC;IAAX,IAAoBJ,KAA1B;;IACA,IAAI,CAAC+B,gBAAgB,CAAC3B,IAAD,CAArB,EAA6B;MACzB,MAAM,IAAIF,cAAJ,CAAiB,sCAAqCE,IAAK,IAA3D,CAAN;IACH;;IACD,MAAM;MAAEK,YAAF;MAAgBC,UAAhB;MAA4BG;IAA5B,IAA6CkB,gBAAgB,CAAC3B,IAAD,CAAnE;IACA6B,MAAM,CAAC9B,OAAD,CAAN,GAAkB;MACdC,IADc;MAEdK,YAFc;MAGdC,UAHc;MAIdG,YAAY,EAAE,OAAOA,YAAP,KAAwB,UAAxB,GAAqCA,YAAY,CAACb,KAAD,CAAjD,GAA2DkB,SAJ3D;MAKdV,aAAa,EAAE,KALD;MAMdR;IANc,CAAlB;IASA,OAAOiC,MAAP;EACH,CAhBM,EAgBJ,IAAAC,kBAAA,EAAgB3B,YAAhB,CAhBI,CAAP;AAiBH,CA3CM"}
@@ -1,2 +1 @@
1
- export * from "./createElasticsearchQueryBody";
2
1
  export * from "./entryIndexHelpers";
package/helpers/index.js CHANGED
@@ -4,19 +4,6 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
 
7
- var _createElasticsearchQueryBody = require("./createElasticsearchQueryBody");
8
-
9
- Object.keys(_createElasticsearchQueryBody).forEach(function (key) {
10
- if (key === "default" || key === "__esModule") return;
11
- if (key in exports && exports[key] === _createElasticsearchQueryBody[key]) return;
12
- Object.defineProperty(exports, key, {
13
- enumerable: true,
14
- get: function () {
15
- return _createElasticsearchQueryBody[key];
16
- }
17
- });
18
- });
19
-
20
7
  var _entryIndexHelpers = require("./entryIndexHelpers");
21
8
 
22
9
  Object.keys(_entryIndexHelpers).forEach(function (key) {
@@ -1 +1 @@
1
- {"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["export * from \"./createElasticsearchQueryBody\";\nexport * from \"./entryIndexHelpers\";\n"],"mappings":";;;;;;AAAA;;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;;AACA;;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA"}
1
+ {"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["export * from \"./entryIndexHelpers\";\n"],"mappings":";;;;;;AAAA;;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA"}
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
 
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
4
 
5
5
  Object.defineProperty(exports, "__esModule", {
6
6
  value: true