@webiny/api-headless-cms-ddb-es 0.0.0-unstable.3386f66516 → 0.0.0-unstable.496cf268ac

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 (153) hide show
  1. package/configurations.js +0 -8
  2. package/configurations.js.map +1 -1
  3. package/definitions/entry.js +3 -5
  4. package/definitions/entry.js.map +1 -1
  5. package/definitions/entryElasticsearch.js +0 -5
  6. package/definitions/entryElasticsearch.js.map +1 -1
  7. package/definitions/group.js +0 -5
  8. package/definitions/group.js.map +1 -1
  9. package/definitions/model.js +17 -5
  10. package/definitions/model.js.map +1 -1
  11. package/definitions/settings.js +0 -5
  12. package/definitions/settings.js.map +1 -1
  13. package/definitions/system.js +0 -5
  14. package/definitions/system.js.map +1 -1
  15. package/definitions/table.js +0 -3
  16. package/definitions/table.js.map +1 -1
  17. package/definitions/tableElasticsearch.js +0 -3
  18. package/definitions/tableElasticsearch.js.map +1 -1
  19. package/dynamoDb/index.js +0 -5
  20. package/dynamoDb/index.js.map +1 -1
  21. package/dynamoDb/storage/date.js +4 -17
  22. package/dynamoDb/storage/date.js.map +1 -1
  23. package/dynamoDb/storage/longText.js +4 -19
  24. package/dynamoDb/storage/longText.js.map +1 -1
  25. package/dynamoDb/storage/richText.js +12 -30
  26. package/dynamoDb/storage/richText.js.map +1 -1
  27. package/elasticsearch/createElasticsearchIndex.js +0 -11
  28. package/elasticsearch/createElasticsearchIndex.js.map +1 -1
  29. package/elasticsearch/deleteElasticsearchIndex.js +0 -7
  30. package/elasticsearch/deleteElasticsearchIndex.js.map +1 -1
  31. package/elasticsearch/index.js +0 -5
  32. package/elasticsearch/index.js.map +1 -1
  33. package/elasticsearch/indexing/dateTimeIndexing.js +4 -21
  34. package/elasticsearch/indexing/dateTimeIndexing.js.map +1 -1
  35. package/elasticsearch/indexing/defaultFieldIndexing.js +15 -10
  36. package/elasticsearch/indexing/defaultFieldIndexing.js.map +1 -1
  37. package/elasticsearch/indexing/index.js +0 -9
  38. package/elasticsearch/indexing/index.js.map +1 -1
  39. package/elasticsearch/indexing/longTextIndexing.js +0 -6
  40. package/elasticsearch/indexing/longTextIndexing.js.map +1 -1
  41. package/elasticsearch/indexing/numberIndexing.js +0 -9
  42. package/elasticsearch/indexing/numberIndexing.js.map +1 -1
  43. package/elasticsearch/indexing/objectIndexing.js +3 -30
  44. package/elasticsearch/indexing/objectIndexing.js.map +1 -1
  45. package/elasticsearch/indexing/richTextIndexing.js +0 -5
  46. package/elasticsearch/indexing/richTextIndexing.js.map +1 -1
  47. package/elasticsearch/indices/base.js +0 -3
  48. package/elasticsearch/indices/base.js.map +1 -1
  49. package/elasticsearch/indices/index.js +0 -4
  50. package/elasticsearch/indices/index.js.map +1 -1
  51. package/elasticsearch/indices/japanese.js +0 -3
  52. package/elasticsearch/indices/japanese.js.map +1 -1
  53. package/elasticsearch/search/index.js +0 -4
  54. package/elasticsearch/search/index.js.map +1 -1
  55. package/elasticsearch/search/refSearch.js +0 -6
  56. package/elasticsearch/search/refSearch.js.map +1 -1
  57. package/elasticsearch/search/timeSearch.js +0 -7
  58. package/elasticsearch/search/timeSearch.js.map +1 -1
  59. package/helpers/entryIndexHelpers.js +20 -49
  60. package/helpers/entryIndexHelpers.js.map +1 -1
  61. package/helpers/index.js +0 -2
  62. package/helpers/index.js.map +1 -1
  63. package/index.js +11 -66
  64. package/index.js.map +1 -1
  65. package/operations/entry/dataLoaders.js +0 -52
  66. package/operations/entry/dataLoaders.js.map +1 -1
  67. package/operations/entry/elasticsearch/assignMinimumShouldMatchToQuery.js +1 -3
  68. package/operations/entry/elasticsearch/assignMinimumShouldMatchToQuery.js.map +1 -1
  69. package/operations/entry/elasticsearch/body.js +3 -25
  70. package/operations/entry/elasticsearch/body.js.map +1 -1
  71. package/operations/entry/elasticsearch/fields.js +0 -19
  72. package/operations/entry/elasticsearch/fields.js.map +1 -1
  73. package/operations/entry/elasticsearch/filtering/applyFiltering.js +1 -10
  74. package/operations/entry/elasticsearch/filtering/applyFiltering.js.map +1 -1
  75. package/operations/entry/elasticsearch/filtering/exec.js +8 -51
  76. package/operations/entry/elasticsearch/filtering/exec.js.map +1 -1
  77. package/operations/entry/elasticsearch/filtering/index.js +0 -2
  78. package/operations/entry/elasticsearch/filtering/index.js.map +1 -1
  79. package/operations/entry/elasticsearch/filtering/path.js +0 -8
  80. package/operations/entry/elasticsearch/filtering/path.js.map +1 -1
  81. package/operations/entry/elasticsearch/filtering/plugins/defaultFilterPlugin.js +0 -7
  82. package/operations/entry/elasticsearch/filtering/plugins/defaultFilterPlugin.js.map +1 -1
  83. package/operations/entry/elasticsearch/filtering/plugins/index.js +0 -5
  84. package/operations/entry/elasticsearch/filtering/plugins/index.js.map +1 -1
  85. package/operations/entry/elasticsearch/filtering/plugins/objectFilterPlugin.js +0 -13
  86. package/operations/entry/elasticsearch/filtering/plugins/objectFilterPlugin.js.map +1 -1
  87. package/operations/entry/elasticsearch/filtering/plugins/refFilterPlugin.js +0 -10
  88. package/operations/entry/elasticsearch/filtering/plugins/refFilterPlugin.js.map +1 -1
  89. package/operations/entry/elasticsearch/filtering/populated.js +0 -7
  90. package/operations/entry/elasticsearch/filtering/populated.js.map +1 -1
  91. package/operations/entry/elasticsearch/filtering/values.js +0 -6
  92. package/operations/entry/elasticsearch/filtering/values.js.map +1 -1
  93. package/operations/entry/elasticsearch/fullTextSearch.d.ts +4 -1
  94. package/operations/entry/elasticsearch/fullTextSearch.js +70 -15
  95. package/operations/entry/elasticsearch/fullTextSearch.js.map +1 -1
  96. package/operations/entry/elasticsearch/fullTextSearchFields.js +8 -35
  97. package/operations/entry/elasticsearch/fullTextSearchFields.js.map +1 -1
  98. package/operations/entry/elasticsearch/initialQuery.js +5 -19
  99. package/operations/entry/elasticsearch/initialQuery.js.map +1 -1
  100. package/operations/entry/elasticsearch/keyword.js +0 -4
  101. package/operations/entry/elasticsearch/keyword.js.map +1 -1
  102. package/operations/entry/elasticsearch/plugins/bodyModifier.js +0 -3
  103. package/operations/entry/elasticsearch/plugins/bodyModifier.js.map +1 -1
  104. package/operations/entry/elasticsearch/plugins/operator.js +0 -8
  105. package/operations/entry/elasticsearch/plugins/operator.js.map +1 -1
  106. package/operations/entry/elasticsearch/plugins/queryModifier.js +0 -3
  107. package/operations/entry/elasticsearch/plugins/queryModifier.js.map +1 -1
  108. package/operations/entry/elasticsearch/plugins/search.js +0 -6
  109. package/operations/entry/elasticsearch/plugins/search.js.map +1 -1
  110. package/operations/entry/elasticsearch/plugins/sortModifier.js +0 -3
  111. package/operations/entry/elasticsearch/plugins/sortModifier.js.map +1 -1
  112. package/operations/entry/elasticsearch/sort.js +0 -15
  113. package/operations/entry/elasticsearch/sort.js.map +1 -1
  114. package/operations/entry/elasticsearch/transformValueForSearch.js +0 -4
  115. package/operations/entry/elasticsearch/transformValueForSearch.js.map +1 -1
  116. package/operations/entry/index.js +7 -130
  117. package/operations/entry/index.js.map +1 -1
  118. package/operations/entry/keys.js +0 -9
  119. package/operations/entry/keys.js.map +1 -1
  120. package/operations/entry/recordType.js +0 -6
  121. package/operations/entry/recordType.js.map +1 -1
  122. package/operations/group/index.js +2 -32
  123. package/operations/group/index.js.map +1 -1
  124. package/operations/model/index.js +1 -34
  125. package/operations/model/index.js.map +1 -1
  126. package/operations/settings/index.js +0 -24
  127. package/operations/settings/index.js.map +1 -1
  128. package/operations/system/index.js +0 -17
  129. package/operations/system/index.js.map +1 -1
  130. package/package.json +16 -16
  131. package/plugins/CmsEntryElasticsearchBodyModifierPlugin.js +0 -8
  132. package/plugins/CmsEntryElasticsearchBodyModifierPlugin.js.map +1 -1
  133. package/plugins/CmsEntryElasticsearchFieldPlugin.js +0 -6
  134. package/plugins/CmsEntryElasticsearchFieldPlugin.js.map +1 -1
  135. package/plugins/CmsEntryElasticsearchFullTextSearchPlugin.d.ts +23 -0
  136. package/plugins/CmsEntryElasticsearchFullTextSearchPlugin.js +28 -0
  137. package/plugins/CmsEntryElasticsearchFullTextSearchPlugin.js.map +1 -0
  138. package/plugins/CmsEntryElasticsearchIndexPlugin.js +0 -5
  139. package/plugins/CmsEntryElasticsearchIndexPlugin.js.map +1 -1
  140. package/plugins/CmsEntryElasticsearchQueryBuilderValueSearchPlugin.d.ts +1 -0
  141. package/plugins/CmsEntryElasticsearchQueryBuilderValueSearchPlugin.js +6 -12
  142. package/plugins/CmsEntryElasticsearchQueryBuilderValueSearchPlugin.js.map +1 -1
  143. package/plugins/CmsEntryElasticsearchQueryModifierPlugin.js +0 -8
  144. package/plugins/CmsEntryElasticsearchQueryModifierPlugin.js.map +1 -1
  145. package/plugins/CmsEntryElasticsearchSortModifierPlugin.js +0 -8
  146. package/plugins/CmsEntryElasticsearchSortModifierPlugin.js.map +1 -1
  147. package/plugins/CmsEntryFilterPlugin.js +0 -7
  148. package/plugins/CmsEntryFilterPlugin.js.map +1 -1
  149. package/plugins/index.d.ts +1 -0
  150. package/plugins/index.js +11 -12
  151. package/plugins/index.js.map +1 -1
  152. package/types.js +0 -5
  153. package/types.js.map +1 -1
@@ -1 +1 @@
1
- {"version":3,"names":["createSystemField","field","id","fieldId","label","createSystemFields","type","isSystemField","isSearchable","isSortable","storageId","parents","entryId","savedOn","unmappedType","keyword","settings","createdOn","createdBy","undefined","path","ownedBy","version","status","buildFieldsList","params","plugins","fields","reduce","result","plugin","WebinyError","fullTextSearch","childFields","length","childResult","Object","assign","identifier","map","p","join","createModelFields","unmappedTypes","byType","acc","fieldType","fieldTypePlugins","types"],"sources":["fields.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport { PluginsContainer } from \"@webiny/plugins\";\nimport { CmsModelField, CmsModelFieldToGraphQLPlugin } from \"@webiny/api-headless-cms/types\";\nimport { CmsModelFieldToElasticsearchPlugin } from \"~/types\";\nimport { ModelFieldParent, ModelFields } from \"./types\";\n\ntype PartialCmsModelField = Partial<CmsModelField> &\n Pick<CmsModelField, \"storageId\" | \"fieldId\" | \"type\">;\nconst createSystemField = (field: PartialCmsModelField): CmsModelField => {\n return {\n ...field,\n id: field.fieldId,\n label: field.fieldId\n };\n};\n\nconst createSystemFields = (): ModelFields => {\n return {\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 parents: []\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 parents: []\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 parents: []\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 parents: []\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 parents: []\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 parents: []\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 parents: []\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 parents: []\n }\n };\n};\n\ninterface 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 fullTextSearch?: boolean;\n}\ninterface FieldTypePlugins {\n [key: string]: FieldTypePlugin;\n}\n\ninterface BuildParams {\n plugins: FieldTypePlugins;\n fields: CmsModelField[];\n parents: ModelFieldParent[];\n}\nconst buildFieldsList = (params: BuildParams): ModelFields => {\n const { plugins, fields, parents } = params;\n\n return fields.reduce<ModelFields>((result, field) => {\n const plugin = plugins[field.type];\n if (!plugin) {\n throw new WebinyError(`There is no plugin for field type \"${field.type}\".`);\n }\n\n const { isSearchable, isSortable, unmappedType, fullTextSearch } = plugin;\n /**\n * If a field has child fields, go through them and add them to a result.\n */\n const childFields = field.settings?.fields || [];\n if (childFields.length > 0) {\n /**\n * Let's build all the child fields\n */\n const childResult = buildFieldsList({\n fields: childFields,\n plugins,\n parents: [\n ...parents,\n {\n fieldId: field.fieldId,\n storageId: field.storageId,\n type: field.type\n }\n ]\n });\n /**\n *\n */\n Object.assign(result, childResult);\n }\n\n const identifier = [...parents.map(p => p.fieldId), field.fieldId].join(\".\");\n\n result[identifier] = {\n type: field.type,\n parents,\n isSearchable,\n isSortable,\n fullTextSearch,\n unmappedType: typeof unmappedType === \"function\" ? unmappedType(field) : undefined,\n isSystemField: false,\n field\n };\n\n return result;\n }, {});\n};\n\ninterface Params {\n plugins: PluginsContainer;\n fields?: CmsModelField[];\n}\nexport const createModelFields = ({ plugins, fields }: Params) => {\n if (!fields || fields.length === 0) {\n return createSystemFields();\n }\n /**\n * Collect all unmappedType from elastic plugins.\n */\n const unmappedTypes = plugins\n .byType<CmsModelFieldToElasticsearchPlugin>(\"cms-model-field-to-elastic-search\")\n .reduce<UnmappedFieldTypes>((acc, plugin) => {\n if (!plugin.unmappedType) {\n return acc;\n }\n acc[plugin.fieldType] = plugin.unmappedType;\n return acc;\n }, {});\n /**\n * Collect all field types from the plugins.\n */\n const fieldTypePlugins = plugins\n .byType<CmsModelFieldToGraphQLPlugin>(\"cms-model-field-to-graphql\")\n .reduce<FieldTypePlugins>((types, plugin) => {\n const { fieldType, isSearchable, isSortable, fullTextSearch } = plugin;\n types[fieldType] = {\n unmappedType: unmappedTypes[fieldType],\n isSearchable,\n isSortable,\n fullTextSearch\n };\n return types;\n }, {});\n\n return {\n ...createSystemFields(),\n ...buildFieldsList({\n fields,\n plugins: fieldTypePlugins,\n parents: []\n })\n };\n};\n"],"mappings":";;;;;;;;;;;AAAA;;AAQA,MAAMA,iBAAiB,GAAIC,KAAD,IAAgD;EACtE,mEACOA,KADP;IAEIC,EAAE,EAAED,KAAK,CAACE,OAFd;IAGIC,KAAK,EAAEH,KAAK,CAACE;EAHjB;AAKH,CAND;;AAQA,MAAME,kBAAkB,GAAG,MAAmB;EAC1C,OAAO;IACHH,EAAE,EAAE;MACAI,IAAI,EAAE,MADN;MAEAC,aAAa,EAAE,IAFf;MAGAC,YAAY,EAAE,IAHd;MAIAC,UAAU,EAAE,IAJZ;MAKAR,KAAK,EAAED,iBAAiB,CAAC;QACrBU,SAAS,EAAE,IADU;QAErBP,OAAO,EAAE,IAFY;QAGrBG,IAAI,EAAE;MAHe,CAAD,CALxB;MAUAK,OAAO,EAAE;IAVT,CADD;IAaHC,OAAO,EAAE;MACLN,IAAI,EAAE,MADD;MAELC,aAAa,EAAE,IAFV;MAGLC,YAAY,EAAE,IAHT;MAILC,UAAU,EAAE,IAJP;MAKLR,KAAK,EAAED,iBAAiB,CAAC;QACrBU,SAAS,EAAE,SADU;QAErBP,OAAO,EAAE,SAFY;QAGrBG,IAAI,EAAE;MAHe,CAAD,CALnB;MAULK,OAAO,EAAE;IAVJ,CAbN;IAyBHE,OAAO,EAAE;MACLP,IAAI,EAAE,MADD;MAELQ,YAAY,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AzB;EACH;EACD;AACJ;AACA;;;EACI,MAAMsC,aAAa,GAAGjB,OAAO,CACxBkB,MADiB,CAC0B,mCAD1B,EAEjBhB,MAFiB,CAEU,CAACiB,GAAD,EAAMf,MAAN,KAAiB;IACzC,IAAI,CAACA,MAAM,CAAChB,YAAZ,EAA0B;MACtB,OAAO+B,GAAP;IACH;;IACDA,GAAG,CAACf,MAAM,CAACgB,SAAR,CAAH,GAAwBhB,MAAM,CAAChB,YAA/B;IACA,OAAO+B,GAAP;EACH,CARiB,EAQf,EARe,CAAtB;EASA;AACJ;AACA;;EACI,MAAME,gBAAgB,GAAGrB,OAAO,CAC3BkB,MADoB,CACiB,4BADjB,EAEpBhB,MAFoB,CAEK,CAACoB,KAAD,EAAQlB,MAAR,KAAmB;IACzC,MAAM;MAAEgB,SAAF;MAAatC,YAAb;MAA2BC,UAA3B;MAAuCuB;IAAvC,IAA0DF,MAAhE;IACAkB,KAAK,CAACF,SAAD,CAAL,GAAmB;MACfhC,YAAY,EAAE6B,aAAa,CAACG,SAAD,CADZ;MAEftC,YAFe;MAGfC,UAHe;MAIfuB;IAJe,CAAnB;IAMA,OAAOgB,KAAP;EACH,CAXoB,EAWlB,EAXkB,CAAzB;EAaA,mEACO3C,kBAAkB,EADzB,GAEOmB,eAAe,CAAC;IACfG,MADe;IAEfD,OAAO,EAAEqB,gBAFM;IAGfpC,OAAO,EAAE;EAHM,CAAD,CAFtB;AAQH,CAxCM"}
1
+ {"version":3,"names":["createSystemField","field","id","fieldId","label","createSystemFields","type","isSystemField","isSearchable","isSortable","storageId","parents","entryId","savedOn","unmappedType","keyword","settings","createdOn","createdBy","undefined","path","ownedBy","version","status","buildFieldsList","params","plugins","fields","reduce","result","plugin","WebinyError","fullTextSearch","childFields","length","childResult","Object","assign","identifier","map","p","join","createModelFields","unmappedTypes","byType","acc","fieldType","fieldTypePlugins","types"],"sources":["fields.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport { PluginsContainer } from \"@webiny/plugins\";\nimport { CmsModelField, CmsModelFieldToGraphQLPlugin } from \"@webiny/api-headless-cms/types\";\nimport { CmsModelFieldToElasticsearchPlugin } from \"~/types\";\nimport { ModelFieldParent, ModelFields } from \"./types\";\n\ntype PartialCmsModelField = Partial<CmsModelField> &\n Pick<CmsModelField, \"storageId\" | \"fieldId\" | \"type\">;\nconst createSystemField = (field: PartialCmsModelField): CmsModelField => {\n return {\n ...field,\n id: field.fieldId,\n label: field.fieldId\n };\n};\n\nconst createSystemFields = (): ModelFields => {\n return {\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 parents: []\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 parents: []\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 parents: []\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 parents: []\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 parents: []\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 parents: []\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 parents: []\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 parents: []\n }\n };\n};\n\ninterface 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 fullTextSearch?: boolean;\n}\ninterface FieldTypePlugins {\n [key: string]: FieldTypePlugin;\n}\n\ninterface BuildParams {\n plugins: FieldTypePlugins;\n fields: CmsModelField[];\n parents: ModelFieldParent[];\n}\nconst buildFieldsList = (params: BuildParams): ModelFields => {\n const { plugins, fields, parents } = params;\n\n return fields.reduce<ModelFields>((result, field) => {\n const plugin = plugins[field.type];\n if (!plugin) {\n throw new WebinyError(`There is no plugin for field type \"${field.type}\".`);\n }\n\n const { isSearchable, isSortable, unmappedType, fullTextSearch } = plugin;\n /**\n * If a field has child fields, go through them and add them to a result.\n */\n const childFields = field.settings?.fields || [];\n if (childFields.length > 0) {\n /**\n * Let's build all the child fields\n */\n const childResult = buildFieldsList({\n fields: childFields,\n plugins,\n parents: [\n ...parents,\n {\n fieldId: field.fieldId,\n storageId: field.storageId,\n type: field.type\n }\n ]\n });\n /**\n *\n */\n Object.assign(result, childResult);\n }\n\n const identifier = [...parents.map(p => p.fieldId), field.fieldId].join(\".\");\n\n result[identifier] = {\n type: field.type,\n parents,\n isSearchable,\n isSortable,\n fullTextSearch,\n unmappedType: typeof unmappedType === \"function\" ? unmappedType(field) : undefined,\n isSystemField: false,\n field\n };\n\n return result;\n }, {});\n};\n\ninterface Params {\n plugins: PluginsContainer;\n fields?: CmsModelField[];\n}\nexport const createModelFields = ({ plugins, fields }: Params) => {\n if (!fields || fields.length === 0) {\n return createSystemFields();\n }\n /**\n * Collect all unmappedType from elastic plugins.\n */\n const unmappedTypes = plugins\n .byType<CmsModelFieldToElasticsearchPlugin>(\"cms-model-field-to-elastic-search\")\n .reduce<UnmappedFieldTypes>((acc, plugin) => {\n if (!plugin.unmappedType) {\n return acc;\n }\n acc[plugin.fieldType] = plugin.unmappedType;\n return acc;\n }, {});\n /**\n * Collect all field types from the plugins.\n */\n const fieldTypePlugins = plugins\n .byType<CmsModelFieldToGraphQLPlugin>(\"cms-model-field-to-graphql\")\n .reduce<FieldTypePlugins>((types, plugin) => {\n const { fieldType, isSearchable, isSortable, fullTextSearch } = plugin;\n types[fieldType] = {\n unmappedType: unmappedTypes[fieldType],\n isSearchable,\n isSortable,\n fullTextSearch\n };\n return types;\n }, {});\n\n return {\n ...createSystemFields(),\n ...buildFieldsList({\n fields,\n plugins: fieldTypePlugins,\n parents: []\n })\n };\n};\n"],"mappings":";;;;;;;;AAAA;AAQA,MAAMA,iBAAiB,GAAIC,KAA2B,IAAoB;EACtE,mEACOA,KAAK;IACRC,EAAE,EAAED,KAAK,CAACE,OAAO;IACjBC,KAAK,EAAEH,KAAK,CAACE;EAAO;AAE5B,CAAC;AAED,MAAME,kBAAkB,GAAG,MAAmB;EAC1C,OAAO;IACHH,EAAE,EAAE;MACAI,IAAI,EAAE,MAAM;MACZC,aAAa,EAAE,IAAI;MACnBC,YAAY,EAAE,IAAI;MAClBC,UAAU,EAAE,IAAI;MAChBR,KAAK,EAAED,iBAAiB,CAAC;QACrBU,SAAS,EAAE,IAAI;QACfP,OAAO,EAAE,IAAI;QACbG,IAAI,EAAE;MACV,CAAC,CAAC;MACFK,OAAO,EAAE;IACb,CAAC;IACDC,OAAO,EAAE;MACLN,IAAI,EAAE,MAAM;MACZC,aAAa,EAAE,IAAI;MACnBC,YAAY,EAAE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AiB,GAAG,CAAC;EAAEhB,OAAO;EAAEC;AAAe,CAAC,KAAK;EAC9D,IAAI,CAACA,MAAM,IAAIA,MAAM,CAACO,MAAM,KAAK,CAAC,EAAE;IAChC,OAAO7B,kBAAkB,EAAE;EAC/B;EACA;AACJ;AACA;EACI,MAAMsC,aAAa,GAAGjB,OAAO,CACxBkB,MAAM,CAAqC,mCAAmC,CAAC,CAC/EhB,MAAM,CAAqB,CAACiB,GAAG,EAAEf,MAAM,KAAK;IACzC,IAAI,CAACA,MAAM,CAAChB,YAAY,EAAE;MACtB,OAAO+B,GAAG;IACd;IACAA,GAAG,CAACf,MAAM,CAACgB,SAAS,CAAC,GAAGhB,MAAM,CAAChB,YAAY;IAC3C,OAAO+B,GAAG;EACd,CAAC,EAAE,CAAC,CAAC,CAAC;EACV;AACJ;AACA;EACI,MAAME,gBAAgB,GAAGrB,OAAO,CAC3BkB,MAAM,CAA+B,4BAA4B,CAAC,CAClEhB,MAAM,CAAmB,CAACoB,KAAK,EAAElB,MAAM,KAAK;IACzC,MAAM;MAAEgB,SAAS;MAAEtC,YAAY;MAAEC,UAAU;MAAEuB;IAAe,CAAC,GAAGF,MAAM;IACtEkB,KAAK,CAACF,SAAS,CAAC,GAAG;MACfhC,YAAY,EAAE6B,aAAa,CAACG,SAAS,CAAC;MACtCtC,YAAY;MACZC,UAAU;MACVuB;IACJ,CAAC;IACD,OAAOgB,KAAK;EAChB,CAAC,EAAE,CAAC,CAAC,CAAC;EAEV,mEACO3C,kBAAkB,EAAE,GACpBmB,eAAe,CAAC;IACfG,MAAM;IACND,OAAO,EAAEqB,gBAAgB;IACzBpC,OAAO,EAAE;EACb,CAAC,CAAC;AAEV,CAAC;AAAC"}
@@ -1,20 +1,14 @@
1
1
  "use strict";
2
2
 
3
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
-
5
4
  Object.defineProperty(exports, "__esModule", {
6
5
  value: true
7
6
  });
8
7
  exports.createApplyFiltering = void 0;
9
-
10
8
  var _error = _interopRequireDefault(require("@webiny/error"));
11
-
12
9
  var _transformValueForSearch = require("../transformValueForSearch");
13
-
14
10
  var _keyword = require("../keyword");
15
-
16
11
  var _path = require("./path");
17
-
18
12
  const createApplyFiltering = ({
19
13
  operatorPlugins,
20
14
  searchPlugins
@@ -31,13 +25,11 @@ const createApplyFiltering = ({
31
25
  field
32
26
  } = params;
33
27
  const plugin = operatorPlugins[operator];
34
-
35
28
  if (!plugin) {
36
- throw new _error.default("Operator plugin missing.", "PLUGIN_MISSING", {
29
+ throw new _error.default(`Elasticsearch operator "${operator}" plugin missing.`, "PLUGIN_MISSING", {
37
30
  operator
38
31
  });
39
32
  }
40
-
41
33
  const value = (0, _transformValueForSearch.transformValueForSearch)({
42
34
  plugins: searchPlugins,
43
35
  field: field.field,
@@ -62,5 +54,4 @@ const createApplyFiltering = ({
62
54
  });
63
55
  };
64
56
  };
65
-
66
57
  exports.createApplyFiltering = createApplyFiltering;
@@ -1 +1 @@
1
- {"version":3,"names":["createApplyFiltering","operatorPlugins","searchPlugins","createFieldPath","createFieldPathFactory","plugins","params","key","value","initialValue","query","operator","field","plugin","WebinyError","transformValueForSearch","keyword","hasKeyword","basePath","path","apply","name","fieldId"],"sources":["applyFiltering.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport { transformValueForSearch } from \"~/operations/entry/elasticsearch/transformValueForSearch\";\nimport { hasKeyword } from \"~/operations/entry/elasticsearch/keyword\";\nimport {\n ElasticsearchQueryBuilderOperatorPlugins,\n ElasticsearchQuerySearchValuePlugins\n} from \"~/operations/entry/elasticsearch/types\";\nimport { createFieldPathFactory } from \"~/operations/entry/elasticsearch/filtering/path\";\nimport { ApplyFilteringCb } from \"~/plugins/CmsEntryFilterPlugin\";\n\ninterface CreateParams {\n operatorPlugins: ElasticsearchQueryBuilderOperatorPlugins;\n searchPlugins: ElasticsearchQuerySearchValuePlugins;\n}\n\nexport const createApplyFiltering = ({\n operatorPlugins,\n searchPlugins\n}: CreateParams): ApplyFilteringCb => {\n const createFieldPath = createFieldPathFactory({\n plugins: searchPlugins\n });\n\n return params => {\n const { key, value: initialValue, query, operator, field } = params;\n\n const plugin = operatorPlugins[operator];\n if (!plugin) {\n throw new WebinyError(\"Operator plugin missing.\", \"PLUGIN_MISSING\", {\n operator\n });\n }\n\n const value = transformValueForSearch({\n plugins: searchPlugins,\n field: field.field,\n value: initialValue\n });\n\n const keyword = hasKeyword(field);\n\n const { basePath, path } = createFieldPath({\n field,\n value,\n key,\n keyword\n });\n\n plugin.apply(query, {\n name: field.field.fieldId,\n basePath,\n path,\n value,\n keyword\n });\n };\n};\n"],"mappings":";;;;;;;;;AAAA;;AACA;;AACA;;AAKA;;AAQO,MAAMA,oBAAoB,GAAG,CAAC;EACjCC,eADiC;EAEjCC;AAFiC,CAAD,KAGE;EAClC,MAAMC,eAAe,GAAG,IAAAC,4BAAA,EAAuB;IAC3CC,OAAO,EAAEH;EADkC,CAAvB,CAAxB;EAIA,OAAOI,MAAM,IAAI;IACb,MAAM;MAAEC,GAAF;MAAOC,KAAK,EAAEC,YAAd;MAA4BC,KAA5B;MAAmCC,QAAnC;MAA6CC;IAA7C,IAAuDN,MAA7D;IAEA,MAAMO,MAAM,GAAGZ,eAAe,CAACU,QAAD,CAA9B;;IACA,IAAI,CAACE,MAAL,EAAa;MACT,MAAM,IAAIC,cAAJ,CAAgB,0BAAhB,EAA4C,gBAA5C,EAA8D;QAChEH;MADgE,CAA9D,CAAN;IAGH;;IAED,MAAMH,KAAK,GAAG,IAAAO,gDAAA,EAAwB;MAClCV,OAAO,EAAEH,aADyB;MAElCU,KAAK,EAAEA,KAAK,CAACA,KAFqB;MAGlCJ,KAAK,EAAEC;IAH2B,CAAxB,CAAd;IAMA,MAAMO,OAAO,GAAG,IAAAC,mBAAA,EAAWL,KAAX,CAAhB;IAEA,MAAM;MAAEM,QAAF;MAAYC;IAAZ,IAAqBhB,eAAe,CAAC;MACvCS,KADuC;MAEvCJ,KAFuC;MAGvCD,GAHuC;MAIvCS;IAJuC,CAAD,CAA1C;IAOAH,MAAM,CAACO,KAAP,CAAaV,KAAb,EAAoB;MAChBW,IAAI,EAAET,KAAK,CAACA,KAAN,CAAYU,OADF;MAEhBJ,QAFgB;MAGhBC,IAHgB;MAIhBX,KAJgB;MAKhBQ;IALgB,CAApB;EAOH,CAhCD;AAiCH,CAzCM"}
1
+ {"version":3,"names":["createApplyFiltering","operatorPlugins","searchPlugins","createFieldPath","createFieldPathFactory","plugins","params","key","value","initialValue","query","operator","field","plugin","WebinyError","transformValueForSearch","keyword","hasKeyword","basePath","path","apply","name","fieldId"],"sources":["applyFiltering.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport { transformValueForSearch } from \"~/operations/entry/elasticsearch/transformValueForSearch\";\nimport { hasKeyword } from \"~/operations/entry/elasticsearch/keyword\";\nimport {\n ElasticsearchQueryBuilderOperatorPlugins,\n ElasticsearchQuerySearchValuePlugins\n} from \"~/operations/entry/elasticsearch/types\";\nimport { createFieldPathFactory } from \"~/operations/entry/elasticsearch/filtering/path\";\nimport { ApplyFilteringCb } from \"~/plugins/CmsEntryFilterPlugin\";\n\ninterface CreateParams {\n operatorPlugins: ElasticsearchQueryBuilderOperatorPlugins;\n searchPlugins: ElasticsearchQuerySearchValuePlugins;\n}\n\nexport const createApplyFiltering = ({\n operatorPlugins,\n searchPlugins\n}: CreateParams): ApplyFilteringCb => {\n const createFieldPath = createFieldPathFactory({\n plugins: searchPlugins\n });\n\n return params => {\n const { key, value: initialValue, query, operator, field } = params;\n\n const plugin = operatorPlugins[operator];\n if (!plugin) {\n throw new WebinyError(\n `Elasticsearch operator \"${operator}\" plugin missing.`,\n \"PLUGIN_MISSING\",\n {\n operator\n }\n );\n }\n\n const value = transformValueForSearch({\n plugins: searchPlugins,\n field: field.field,\n value: initialValue\n });\n\n const keyword = hasKeyword(field);\n\n const { basePath, path } = createFieldPath({\n field,\n value,\n key,\n keyword\n });\n\n plugin.apply(query, {\n name: field.field.fieldId,\n basePath,\n path,\n value,\n keyword\n });\n };\n};\n"],"mappings":";;;;;;;AAAA;AACA;AACA;AAKA;AAQO,MAAMA,oBAAoB,GAAG,CAAC;EACjCC,eAAe;EACfC;AACU,CAAC,KAAuB;EAClC,MAAMC,eAAe,GAAG,IAAAC,4BAAsB,EAAC;IAC3CC,OAAO,EAAEH;EACb,CAAC,CAAC;EAEF,OAAOI,MAAM,IAAI;IACb,MAAM;MAAEC,GAAG;MAAEC,KAAK,EAAEC,YAAY;MAAEC,KAAK;MAAEC,QAAQ;MAAEC;IAAM,CAAC,GAAGN,MAAM;IAEnE,MAAMO,MAAM,GAAGZ,eAAe,CAACU,QAAQ,CAAC;IACxC,IAAI,CAACE,MAAM,EAAE;MACT,MAAM,IAAIC,cAAW,CAChB,2BAA0BH,QAAS,mBAAkB,EACtD,gBAAgB,EAChB;QACIA;MACJ,CAAC,CACJ;IACL;IAEA,MAAMH,KAAK,GAAG,IAAAO,gDAAuB,EAAC;MAClCV,OAAO,EAAEH,aAAa;MACtBU,KAAK,EAAEA,KAAK,CAACA,KAAK;MAClBJ,KAAK,EAAEC;IACX,CAAC,CAAC;IAEF,MAAMO,OAAO,GAAG,IAAAC,mBAAU,EAACL,KAAK,CAAC;IAEjC,MAAM;MAAEM,QAAQ;MAAEC;IAAK,CAAC,GAAGhB,eAAe,CAAC;MACvCS,KAAK;MACLJ,KAAK;MACLD,GAAG;MACHS;IACJ,CAAC,CAAC;IAEFH,MAAM,CAACO,KAAK,CAACV,KAAK,EAAE;MAChBW,IAAI,EAAET,KAAK,CAACA,KAAK,CAACU,OAAO;MACzBJ,QAAQ;MACRC,IAAI;MACJX,KAAK;MACLQ;IACJ,CAAC,CAAC;EACN,CAAC;AACL,CAAC;AAAC"}
@@ -1,51 +1,37 @@
1
1
  "use strict";
2
2
 
3
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
-
5
4
  Object.defineProperty(exports, "__esModule", {
6
5
  value: true
7
6
  });
8
7
  exports.createExecFiltering = void 0;
9
-
10
8
  var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
11
-
12
9
  var _error = _interopRequireDefault(require("@webiny/error"));
13
-
14
10
  var _search = require("../plugins/search");
15
-
16
11
  var _operator = require("../plugins/operator");
17
-
18
12
  var _initialQuery = require("../initialQuery");
19
-
20
13
  var _apiElasticsearch = require("@webiny/api-elasticsearch");
21
-
22
14
  var _values = require("./values");
23
-
24
15
  var _populated = require("./populated");
25
-
26
16
  var _applyFiltering = require("./applyFiltering");
27
-
28
17
  var _CmsEntryFilterPlugin = require("../../../../plugins/CmsEntryFilterPlugin");
29
-
30
18
  var _assignMinimumShouldMatchToQuery = require("../assignMinimumShouldMatchToQuery");
31
-
32
19
  const createExecFiltering = params => {
33
20
  const {
34
21
  fields,
35
22
  plugins,
36
23
  model
37
24
  } = params;
25
+
38
26
  /**
39
27
  * We need the search plugins as key -> plugin value, so it is easy to find plugin we need, without iterating through array.
40
28
  */
41
-
42
29
  const searchPlugins = (0, _search.createSearchPluginList)({
43
30
  plugins
44
31
  });
45
32
  /**
46
33
  * We need the operator plugins, which we execute on our where conditions.
47
34
  */
48
-
49
35
  const operatorPlugins = (0, _operator.createOperatorPluginList)({
50
36
  plugins,
51
37
  locale: model.locale
@@ -58,19 +44,15 @@ const createExecFiltering = params => {
58
44
  collection[plugin.fieldType] = plugin;
59
45
  return collection;
60
46
  }, {});
61
-
62
47
  const getFilterPlugin = type => {
63
48
  const plugin = filteringPlugins[type] || filteringPlugins["*"];
64
-
65
49
  if (plugin) {
66
50
  return plugin;
67
51
  }
68
-
69
52
  throw new _error.default(`There is no filtering plugin for the given field type "${type}".`, "FILTERING_PLUGIN_ERROR", {
70
53
  type
71
54
  });
72
55
  };
73
-
74
56
  const execFiltering = params => {
75
57
  const {
76
58
  where: initialWhere,
@@ -79,63 +61,50 @@ const createExecFiltering = params => {
79
61
  /**
80
62
  * No point in continuing if no "where" conditions exist.
81
63
  */
82
-
83
64
  const keys = Object.keys(initialWhere);
84
-
85
65
  if (keys.length === 0) {
86
66
  return;
87
67
  }
88
-
89
68
  const where = (0, _objectSpread2.default)({}, initialWhere);
90
-
91
69
  for (const key in where) {
92
70
  const value = where[key];
93
71
  /**
94
72
  * We always skip if no value is defined.
95
73
  * Only skip undefined value, null is valid.
96
74
  */
97
-
98
75
  if (value === undefined) {
99
76
  continue;
100
- } //
101
-
77
+ }
78
+ //
102
79
  /**
103
80
  * When we are running with AND, the "value" MUST be an array.
104
- */
105
- else if (key === "AND") {
81
+ */else if (key === "AND") {
106
82
  const childWhereList = (0, _values.getWhereValues)(value, "AND");
107
83
  const childQuery = (0, _initialQuery.createBaseQuery)();
108
-
109
84
  for (const childWhere of childWhereList) {
110
85
  execFiltering({
111
86
  query: childQuery,
112
87
  where: childWhere
113
88
  });
114
89
  }
115
-
116
90
  const childQueryBool = (0, _populated.getPopulated)(childQuery);
117
-
118
91
  if (Object.keys(childQueryBool).length === 0) {
119
92
  continue;
120
93
  }
121
-
122
94
  query.filter.push({
123
95
  bool: childQueryBool
124
96
  });
125
97
  continue;
126
- } //
127
-
98
+ }
99
+ //
128
100
  /**
129
101
  * When we are running with OR, the "value" must be an array.
130
- */
131
- else if (key === "OR") {
102
+ */else if (key === "OR") {
132
103
  const childWhereList = (0, _values.getWhereValues)(value, "OR");
133
104
  /**
134
105
  * Each of the conditions MUST produce it's own should section.
135
106
  */
136
-
137
107
  const should = [];
138
-
139
108
  for (const childWhere of childWhereList) {
140
109
  const childQuery = (0, _initialQuery.createBaseQuery)();
141
110
  execFiltering({
@@ -143,58 +112,48 @@ const createExecFiltering = params => {
143
112
  where: childWhere
144
113
  });
145
114
  const childQueryBool = (0, _populated.getPopulated)(childQuery);
146
-
147
115
  if (Object.keys(childQueryBool).length === 0) {
148
116
  continue;
149
117
  }
150
-
151
118
  should.push({
152
119
  bool: childQueryBool
153
120
  });
154
121
  }
155
-
156
122
  if (should.length === 0) {
157
123
  continue;
158
124
  }
159
-
160
125
  query.should.push(...should);
161
126
  /**
162
127
  * If there are any should, minimum to have is 1.
163
128
  * Of course, do not override if it's already set.
164
129
  */
165
-
166
130
  (0, _assignMinimumShouldMatchToQuery.assignMinimumShouldMatchToQuery)({
167
131
  query
168
132
  });
169
133
  continue;
170
134
  }
171
-
172
135
  const {
173
136
  field: whereFieldId,
174
137
  operator
175
138
  } = (0, _apiElasticsearch.parseWhereKey)(key);
176
139
  let fieldId = whereFieldId;
140
+
177
141
  /**
178
142
  * TODO This will be required until the storage operations receive the fieldId instead of field storageId.
179
143
  * TODO For this to work without field searching, we need to refactor how the query looks like.
180
144
  *
181
145
  * Storage operations should NEVER receive an field storageId, only alias - fieldId.
182
146
  */
183
-
184
147
  const cmsModelField = model.fields.find(f => f.fieldId === fieldId);
185
-
186
148
  if (!cmsModelField && !fields[fieldId]) {
187
149
  throw new _error.default(`There is no CMS Model Field field "${fieldId}".`);
188
150
  } else if (cmsModelField) {
189
151
  fieldId = cmsModelField.fieldId;
190
152
  }
191
-
192
153
  const field = fields[fieldId];
193
-
194
154
  if (!field) {
195
155
  throw new _error.default(`There is no field "${fieldId}".`);
196
156
  }
197
-
198
157
  const filterPlugin = getFilterPlugin(field.type);
199
158
  filterPlugin.exec({
200
159
  applyFiltering,
@@ -208,8 +167,6 @@ const createExecFiltering = params => {
208
167
  });
209
168
  }
210
169
  };
211
-
212
170
  return execFiltering;
213
171
  };
214
-
215
172
  exports.createExecFiltering = createExecFiltering;
@@ -1 +1 @@
1
- {"version":3,"names":["createExecFiltering","params","fields","plugins","model","searchPlugins","createSearchPluginList","operatorPlugins","createOperatorPluginList","locale","applyFiltering","createApplyFiltering","filteringPlugins","byType","CmsEntryFilterPlugin","type","reduce","collection","plugin","fieldType","getFilterPlugin","WebinyError","execFiltering","where","initialWhere","query","keys","Object","length","key","value","undefined","childWhereList","getWhereValues","childQuery","createBaseQuery","childWhere","childQueryBool","getPopulated","filter","push","bool","should","assignMinimumShouldMatchToQuery","field","whereFieldId","operator","parseWhereKey","fieldId","cmsModelField","find","f","filterPlugin","exec"],"sources":["exec.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport { CmsEntryListWhere, CmsModel } from \"@webiny/api-headless-cms/types\";\nimport { ModelFields } from \"~/operations/entry/elasticsearch/types\";\nimport { PluginsContainer } from \"@webiny/plugins\";\nimport { ElasticsearchBoolQueryConfig, Query } from \"@webiny/api-elasticsearch/types\";\nimport { createSearchPluginList } from \"~/operations/entry/elasticsearch/plugins/search\";\nimport { createOperatorPluginList } from \"~/operations/entry/elasticsearch/plugins/operator\";\nimport { createBaseQuery } from \"~/operations/entry/elasticsearch/initialQuery\";\nimport { parseWhereKey } from \"@webiny/api-elasticsearch\";\nimport { getWhereValues } from \"./values\";\nimport { getPopulated } from \"./populated\";\nimport { createApplyFiltering } from \"./applyFiltering\";\nimport { CmsEntryFilterPlugin } from \"~/plugins/CmsEntryFilterPlugin\";\nimport { assignMinimumShouldMatchToQuery } from \"~/operations/entry/elasticsearch/assignMinimumShouldMatchToQuery\";\n\nexport interface CreateExecParams {\n model: CmsModel;\n fields: ModelFields;\n plugins: PluginsContainer;\n}\nexport interface ExecParams {\n where: CmsEntryListWhere;\n query: ElasticsearchBoolQueryConfig;\n}\nexport interface CreateExecFilteringResponse {\n (params: ExecParams): void;\n}\nexport const createExecFiltering = (params: CreateExecParams): CreateExecFilteringResponse => {\n const { fields, plugins, model } = params;\n\n /**\n * We need the search plugins as key -> plugin value, so it is easy to find plugin we need, without iterating through array.\n */\n const searchPlugins = createSearchPluginList({\n plugins\n });\n /**\n * We need the operator plugins, which we execute on our where conditions.\n */\n const operatorPlugins = createOperatorPluginList({\n plugins,\n locale: model.locale\n });\n\n const applyFiltering = createApplyFiltering({\n operatorPlugins,\n searchPlugins\n });\n\n const filteringPlugins = plugins\n .byType<CmsEntryFilterPlugin>(CmsEntryFilterPlugin.type)\n .reduce<Record<string, CmsEntryFilterPlugin>>((collection, plugin) => {\n collection[plugin.fieldType] = plugin;\n\n return collection;\n }, {});\n\n const getFilterPlugin = (type: string) => {\n const plugin = filteringPlugins[type] || filteringPlugins[\"*\"];\n if (plugin) {\n return plugin;\n }\n throw new WebinyError(\n `There is no filtering plugin for the given field type \"${type}\".`,\n \"FILTERING_PLUGIN_ERROR\",\n {\n type\n }\n );\n };\n\n const execFiltering = (params: ExecParams) => {\n const { where: initialWhere, query } = params;\n /**\n * No point in continuing if no \"where\" conditions exist.\n */\n const keys = Object.keys(initialWhere);\n if (keys.length === 0) {\n return;\n }\n const where: CmsEntryListWhere = {\n ...initialWhere\n };\n\n for (const key in where) {\n const value = where[key] as unknown as any;\n /**\n * We always skip if no value is defined.\n * Only skip undefined value, null is valid.\n */\n if (value === undefined) {\n continue;\n }\n //\n /**\n * When we are running with AND, the \"value\" MUST be an array.\n */\n else if (key === \"AND\") {\n const childWhereList = getWhereValues(value, \"AND\");\n\n const childQuery = createBaseQuery();\n\n for (const childWhere of childWhereList) {\n execFiltering({\n query: childQuery,\n where: childWhere\n });\n }\n const childQueryBool = getPopulated(childQuery);\n if (Object.keys(childQueryBool).length === 0) {\n continue;\n }\n query.filter.push({\n bool: childQueryBool\n });\n\n continue;\n }\n //\n /**\n * When we are running with OR, the \"value\" must be an array.\n */\n else if (key === \"OR\") {\n const childWhereList = getWhereValues(value, \"OR\");\n /**\n * Each of the conditions MUST produce it's own should section.\n */\n const should: Query[] = [];\n for (const childWhere of childWhereList) {\n const childQuery = createBaseQuery();\n execFiltering({\n query: childQuery,\n where: childWhere\n });\n const childQueryBool = getPopulated(childQuery);\n if (Object.keys(childQueryBool).length === 0) {\n continue;\n }\n should.push({\n bool: childQueryBool\n });\n }\n if (should.length === 0) {\n continue;\n }\n query.should.push(...should);\n /**\n * If there are any should, minimum to have is 1.\n * Of course, do not override if it's already set.\n */\n assignMinimumShouldMatchToQuery({\n query\n });\n continue;\n }\n const { field: whereFieldId, operator } = parseWhereKey(key);\n\n let fieldId: string = whereFieldId;\n\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 const cmsModelField = model.fields.find(f => f.fieldId === fieldId);\n if (!cmsModelField && !fields[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 field = fields[fieldId];\n if (!field) {\n throw new WebinyError(`There is no field \"${fieldId}\".`);\n }\n const filterPlugin = getFilterPlugin(field.type);\n\n filterPlugin.exec({\n applyFiltering,\n getFilterPlugin,\n key,\n value,\n operator,\n field,\n fields,\n query\n });\n }\n };\n\n return execFiltering;\n};\n"],"mappings":";;;;;;;;;;;AAAA;;AAKA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAcO,MAAMA,mBAAmB,GAAIC,MAAD,IAA2D;EAC1F,MAAM;IAAEC,MAAF;IAAUC,OAAV;IAAmBC;EAAnB,IAA6BH,MAAnC;EAEA;AACJ;AACA;;EACI,MAAMI,aAAa,GAAG,IAAAC,8BAAA,EAAuB;IACzCH;EADyC,CAAvB,CAAtB;EAGA;AACJ;AACA;;EACI,MAAMI,eAAe,GAAG,IAAAC,kCAAA,EAAyB;IAC7CL,OAD6C;IAE7CM,MAAM,EAAEL,KAAK,CAACK;EAF+B,CAAzB,CAAxB;EAKA,MAAMC,cAAc,GAAG,IAAAC,oCAAA,EAAqB;IACxCJ,eADwC;IAExCF;EAFwC,CAArB,CAAvB;EAKA,MAAMO,gBAAgB,GAAGT,OAAO,CAC3BU,MADoB,CACSC,0CAAA,CAAqBC,IAD9B,EAEpBC,MAFoB,CAEyB,CAACC,UAAD,EAAaC,MAAb,KAAwB;IAClED,UAAU,CAACC,MAAM,CAACC,SAAR,CAAV,GAA+BD,MAA/B;IAEA,OAAOD,UAAP;EACH,CANoB,EAMlB,EANkB,CAAzB;;EAQA,MAAMG,eAAe,GAAIL,IAAD,IAAkB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AAwC;QACpC,MAAM,IAAI3B,cAAJ,CAAiB,sCAAqC2B,OAAQ,IAA9D,CAAN;MACH,CAFD,MAEO,IAAIC,aAAJ,EAAmB;QACtBD,OAAO,GAAGC,aAAa,CAACD,OAAxB;MACH;;MAED,MAAMJ,KAAK,GAAG1C,MAAM,CAAC8C,OAAD,CAApB;;MACA,IAAI,CAACJ,KAAL,EAAY;QACR,MAAM,IAAIvB,cAAJ,CAAiB,sBAAqB2B,OAAQ,IAA9C,CAAN;MACH;;MACD,MAAMI,YAAY,GAAGhC,eAAe,CAACwB,KAAK,CAAC7B,IAAP,CAApC;MAEAqC,YAAY,CAACC,IAAb,CAAkB;QACd3C,cADc;QAEdU,eAFc;QAGdS,GAHc;QAIdC,KAJc;QAKdgB,QALc;QAMdF,KANc;QAOd1C,MAPc;QAQduB;MARc,CAAlB;IAUH;EACJ,CAtHD;;EAwHA,OAAOH,aAAP;AACH,CArKM"}
1
+ {"version":3,"names":["createExecFiltering","params","fields","plugins","model","searchPlugins","createSearchPluginList","operatorPlugins","createOperatorPluginList","locale","applyFiltering","createApplyFiltering","filteringPlugins","byType","CmsEntryFilterPlugin","type","reduce","collection","plugin","fieldType","getFilterPlugin","WebinyError","execFiltering","where","initialWhere","query","keys","Object","length","key","value","undefined","childWhereList","getWhereValues","childQuery","createBaseQuery","childWhere","childQueryBool","getPopulated","filter","push","bool","should","assignMinimumShouldMatchToQuery","field","whereFieldId","operator","parseWhereKey","fieldId","cmsModelField","find","f","filterPlugin","exec"],"sources":["exec.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport { CmsEntryListWhere, CmsModel } from \"@webiny/api-headless-cms/types\";\nimport { ModelFields } from \"~/operations/entry/elasticsearch/types\";\nimport { PluginsContainer } from \"@webiny/plugins\";\nimport { ElasticsearchBoolQueryConfig, Query } from \"@webiny/api-elasticsearch/types\";\nimport { createSearchPluginList } from \"~/operations/entry/elasticsearch/plugins/search\";\nimport { createOperatorPluginList } from \"~/operations/entry/elasticsearch/plugins/operator\";\nimport { createBaseQuery } from \"~/operations/entry/elasticsearch/initialQuery\";\nimport { parseWhereKey } from \"@webiny/api-elasticsearch\";\nimport { getWhereValues } from \"./values\";\nimport { getPopulated } from \"./populated\";\nimport { createApplyFiltering } from \"./applyFiltering\";\nimport { CmsEntryFilterPlugin } from \"~/plugins/CmsEntryFilterPlugin\";\nimport { assignMinimumShouldMatchToQuery } from \"~/operations/entry/elasticsearch/assignMinimumShouldMatchToQuery\";\n\nexport interface CreateExecParams {\n model: CmsModel;\n fields: ModelFields;\n plugins: PluginsContainer;\n}\nexport interface ExecParams {\n where: CmsEntryListWhere;\n query: ElasticsearchBoolQueryConfig;\n}\nexport interface CreateExecFilteringResponse {\n (params: ExecParams): void;\n}\nexport const createExecFiltering = (params: CreateExecParams): CreateExecFilteringResponse => {\n const { fields, plugins, model } = params;\n\n /**\n * We need the search plugins as key -> plugin value, so it is easy to find plugin we need, without iterating through array.\n */\n const searchPlugins = createSearchPluginList({\n plugins\n });\n /**\n * We need the operator plugins, which we execute on our where conditions.\n */\n const operatorPlugins = createOperatorPluginList({\n plugins,\n locale: model.locale\n });\n\n const applyFiltering = createApplyFiltering({\n operatorPlugins,\n searchPlugins\n });\n\n const filteringPlugins = plugins\n .byType<CmsEntryFilterPlugin>(CmsEntryFilterPlugin.type)\n .reduce<Record<string, CmsEntryFilterPlugin>>((collection, plugin) => {\n collection[plugin.fieldType] = plugin;\n\n return collection;\n }, {});\n\n const getFilterPlugin = (type: string) => {\n const plugin = filteringPlugins[type] || filteringPlugins[\"*\"];\n if (plugin) {\n return plugin;\n }\n throw new WebinyError(\n `There is no filtering plugin for the given field type \"${type}\".`,\n \"FILTERING_PLUGIN_ERROR\",\n {\n type\n }\n );\n };\n\n const execFiltering = (params: ExecParams) => {\n const { where: initialWhere, query } = params;\n /**\n * No point in continuing if no \"where\" conditions exist.\n */\n const keys = Object.keys(initialWhere);\n if (keys.length === 0) {\n return;\n }\n const where: CmsEntryListWhere = {\n ...initialWhere\n };\n\n for (const key in where) {\n const value = where[key] as unknown as any;\n /**\n * We always skip if no value is defined.\n * Only skip undefined value, null is valid.\n */\n if (value === undefined) {\n continue;\n }\n //\n /**\n * When we are running with AND, the \"value\" MUST be an array.\n */\n else if (key === \"AND\") {\n const childWhereList = getWhereValues(value, \"AND\");\n\n const childQuery = createBaseQuery();\n\n for (const childWhere of childWhereList) {\n execFiltering({\n query: childQuery,\n where: childWhere\n });\n }\n const childQueryBool = getPopulated(childQuery);\n if (Object.keys(childQueryBool).length === 0) {\n continue;\n }\n query.filter.push({\n bool: childQueryBool\n });\n\n continue;\n }\n //\n /**\n * When we are running with OR, the \"value\" must be an array.\n */\n else if (key === \"OR\") {\n const childWhereList = getWhereValues(value, \"OR\");\n /**\n * Each of the conditions MUST produce it's own should section.\n */\n const should: Query[] = [];\n for (const childWhere of childWhereList) {\n const childQuery = createBaseQuery();\n execFiltering({\n query: childQuery,\n where: childWhere\n });\n const childQueryBool = getPopulated(childQuery);\n if (Object.keys(childQueryBool).length === 0) {\n continue;\n }\n should.push({\n bool: childQueryBool\n });\n }\n if (should.length === 0) {\n continue;\n }\n query.should.push(...should);\n /**\n * If there are any should, minimum to have is 1.\n * Of course, do not override if it's already set.\n */\n assignMinimumShouldMatchToQuery({\n query\n });\n continue;\n }\n const { field: whereFieldId, operator } = parseWhereKey(key);\n\n let fieldId: string = whereFieldId;\n\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 const cmsModelField = model.fields.find(f => f.fieldId === fieldId);\n if (!cmsModelField && !fields[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 field = fields[fieldId];\n if (!field) {\n throw new WebinyError(`There is no field \"${fieldId}\".`);\n }\n const filterPlugin = getFilterPlugin(field.type);\n\n filterPlugin.exec({\n applyFiltering,\n getFilterPlugin,\n key,\n value,\n operator,\n field,\n fields,\n query\n });\n }\n };\n\n return execFiltering;\n};\n"],"mappings":";;;;;;;;AAAA;AAKA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAcO,MAAMA,mBAAmB,GAAIC,MAAwB,IAAkC;EAC1F,MAAM;IAAEC,MAAM;IAAEC,OAAO;IAAEC;EAAM,CAAC,GAAGH,MAAM;;EAEzC;AACJ;AACA;EACI,MAAMI,aAAa,GAAG,IAAAC,8BAAsB,EAAC;IACzCH;EACJ,CAAC,CAAC;EACF;AACJ;AACA;EACI,MAAMI,eAAe,GAAG,IAAAC,kCAAwB,EAAC;IAC7CL,OAAO;IACPM,MAAM,EAAEL,KAAK,CAACK;EAClB,CAAC,CAAC;EAEF,MAAMC,cAAc,GAAG,IAAAC,oCAAoB,EAAC;IACxCJ,eAAe;IACfF;EACJ,CAAC,CAAC;EAEF,MAAMO,gBAAgB,GAAGT,OAAO,CAC3BU,MAAM,CAAuBC,0CAAoB,CAACC,IAAI,CAAC,CACvDC,MAAM,CAAuC,CAACC,UAAU,EAAEC,MAAM,KAAK;IAClED,UAAU,CAACC,MAAM,CAACC,SAAS,CAAC,GAAGD,MAAM;IAErC,OAAOD,UAAU;EACrB,CAAC,EAAE,CAAC,CAAC,CAAC;EAEV,MAAMG,eAAe,GAAIL,IAAY,IAAK;IACtC,MAAMG,MAAM,GAAGN,gBAAgB,CAACG,IAAI,CAAC,IAAIH,gBAAgB,CAAC,GAAG,CAAC;IAC9D,IAAIM,MAAM,EAAE;MACR,OAAOA,MAAM;IACjB;IACA,MAAM,IAAIG,cAAW,CAChB,0DAAyDN,IAAK,IAAG,EAClE,wBAAwB,EACxB;MACIA;IACJ,CAAC,CACJ;EACL,CAAC;EAED,MAAMO,aAAa,GAAIrB,MAAkB,IAAK;IAC1C,MAAM;MAAEsB,KAAK,EAAEC,YAAY;MAAEC;IAAM,CAAC,GAAGxB,MAAM;IAC7C;AACR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GAAG;QACHC,KAAK;QACLgB,QAAQ;QACRF,KAAK;QACL1C,MAAM;QACNuB;MACJ,CAAC,CAAC;IACN;EACJ,CAAC;EAED,OAAOH,aAAa;AACxB,CAAC;AAAC"}
@@ -3,9 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
-
7
6
  var _exec = require("./exec");
8
-
9
7
  Object.keys(_exec).forEach(function (key) {
10
8
  if (key === "default" || key === "__esModule") return;
11
9
  if (key in exports && exports[key] === _exec[key]) return;
@@ -1 +1 @@
1
- {"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["export * from \"./exec\";\n"],"mappings":";;;;;;AAAA;;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA"}
1
+ {"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["export * from \"./exec\";\n"],"mappings":";;;;;AAAA;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA"}
@@ -4,7 +4,6 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.createFieldPathFactory = void 0;
7
-
8
7
  const createFieldPathFactory = ({
9
8
  plugins
10
9
  }) => {
@@ -17,7 +16,6 @@ const createFieldPathFactory = ({
17
16
  } = params;
18
17
  const plugin = plugins[field.type];
19
18
  let fieldPath = null;
20
-
21
19
  if (plugin) {
22
20
  fieldPath = plugin.createPath({
23
21
  field: field.field,
@@ -25,21 +23,16 @@ const createFieldPathFactory = ({
25
23
  key
26
24
  });
27
25
  }
28
-
29
26
  if (!fieldPath) {
30
27
  fieldPath = field.field.storageId;
31
-
32
28
  if (field.path) {
33
29
  fieldPath = typeof field.path === "function" ? field.path(value) : field.path;
34
30
  }
35
31
  }
36
-
37
32
  const result = [];
38
-
39
33
  if (!field.isSystemField) {
40
34
  result.push("values");
41
35
  }
42
-
43
36
  result.push(...field.parents.map(p => p.storageId));
44
37
  result.push(fieldPath);
45
38
  return {
@@ -48,5 +41,4 @@ const createFieldPathFactory = ({
48
41
  };
49
42
  };
50
43
  };
51
-
52
44
  exports.createFieldPathFactory = createFieldPathFactory;
@@ -1 +1 @@
1
- {"version":3,"names":["createFieldPathFactory","plugins","params","field","key","value","keyword","plugin","type","fieldPath","createPath","storageId","path","result","isSystemField","push","parents","map","p","basePath","join","concat"],"sources":["path.ts"],"sourcesContent":["import {\n ElasticsearchQuerySearchValuePlugins,\n ModelField\n} from \"~/operations/entry/elasticsearch/types\";\n\ninterface FieldPathFactoryParams {\n plugins: ElasticsearchQuerySearchValuePlugins;\n}\ninterface FieldPathParams {\n field: ModelField;\n key: string;\n value: any;\n keyword: boolean;\n}\n\nexport const createFieldPathFactory = ({ plugins }: FieldPathFactoryParams) => {\n return (params: FieldPathParams) => {\n const { field, key, value, keyword } = params;\n const plugin = plugins[field.type];\n\n let fieldPath: string | null = null;\n if (plugin) {\n fieldPath = plugin.createPath({ field: field.field, value, key });\n }\n if (!fieldPath) {\n fieldPath = field.field.storageId;\n if (field.path) {\n fieldPath = typeof field.path === \"function\" ? field.path(value) : field.path;\n }\n }\n\n const result: string[] = [];\n if (!field.isSystemField) {\n result.push(\"values\");\n }\n result.push(...field.parents.map(p => p.storageId));\n result.push(fieldPath);\n\n return {\n basePath: result.join(\".\"),\n path: result.concat(keyword ? [\"keyword\"] : []).join(\".\")\n };\n };\n};\n"],"mappings":";;;;;;;AAeO,MAAMA,sBAAsB,GAAG,CAAC;EAAEC;AAAF,CAAD,KAAyC;EAC3E,OAAQC,MAAD,IAA6B;IAChC,MAAM;MAAEC,KAAF;MAASC,GAAT;MAAcC,KAAd;MAAqBC;IAArB,IAAiCJ,MAAvC;IACA,MAAMK,MAAM,GAAGN,OAAO,CAACE,KAAK,CAACK,IAAP,CAAtB;IAEA,IAAIC,SAAwB,GAAG,IAA/B;;IACA,IAAIF,MAAJ,EAAY;MACRE,SAAS,GAAGF,MAAM,CAACG,UAAP,CAAkB;QAAEP,KAAK,EAAEA,KAAK,CAACA,KAAf;QAAsBE,KAAtB;QAA6BD;MAA7B,CAAlB,CAAZ;IACH;;IACD,IAAI,CAACK,SAAL,EAAgB;MACZA,SAAS,GAAGN,KAAK,CAACA,KAAN,CAAYQ,SAAxB;;MACA,IAAIR,KAAK,CAACS,IAAV,EAAgB;QACZH,SAAS,GAAG,OAAON,KAAK,CAACS,IAAb,KAAsB,UAAtB,GAAmCT,KAAK,CAACS,IAAN,CAAWP,KAAX,CAAnC,GAAuDF,KAAK,CAACS,IAAzE;MACH;IACJ;;IAED,MAAMC,MAAgB,GAAG,EAAzB;;IACA,IAAI,CAACV,KAAK,CAACW,aAAX,EAA0B;MACtBD,MAAM,CAACE,IAAP,CAAY,QAAZ;IACH;;IACDF,MAAM,CAACE,IAAP,CAAY,GAAGZ,KAAK,CAACa,OAAN,CAAcC,GAAd,CAAkBC,CAAC,IAAIA,CAAC,CAACP,SAAzB,CAAf;IACAE,MAAM,CAACE,IAAP,CAAYN,SAAZ;IAEA,OAAO;MACHU,QAAQ,EAAEN,MAAM,CAACO,IAAP,CAAY,GAAZ,CADP;MAEHR,IAAI,EAAEC,MAAM,CAACQ,MAAP,CAAcf,OAAO,GAAG,CAAC,SAAD,CAAH,GAAiB,EAAtC,EAA0Cc,IAA1C,CAA+C,GAA/C;IAFH,CAAP;EAIH,CA1BD;AA2BH,CA5BM"}
1
+ {"version":3,"names":["createFieldPathFactory","plugins","params","field","key","value","keyword","plugin","type","fieldPath","createPath","storageId","path","result","isSystemField","push","parents","map","p","basePath","join","concat"],"sources":["path.ts"],"sourcesContent":["import {\n ElasticsearchQuerySearchValuePlugins,\n ModelField\n} from \"~/operations/entry/elasticsearch/types\";\n\ninterface FieldPathFactoryParams {\n plugins: ElasticsearchQuerySearchValuePlugins;\n}\ninterface FieldPathParams {\n field: ModelField;\n key: string;\n value: any;\n keyword: boolean;\n}\n\nexport const createFieldPathFactory = ({ plugins }: FieldPathFactoryParams) => {\n return (params: FieldPathParams) => {\n const { field, key, value, keyword } = params;\n const plugin = plugins[field.type];\n\n let fieldPath: string | null = null;\n if (plugin) {\n fieldPath = plugin.createPath({ field: field.field, value, key });\n }\n if (!fieldPath) {\n fieldPath = field.field.storageId;\n if (field.path) {\n fieldPath = typeof field.path === \"function\" ? field.path(value) : field.path;\n }\n }\n\n const result: string[] = [];\n if (!field.isSystemField) {\n result.push(\"values\");\n }\n result.push(...field.parents.map(p => p.storageId));\n result.push(fieldPath);\n\n return {\n basePath: result.join(\".\"),\n path: result.concat(keyword ? [\"keyword\"] : []).join(\".\")\n };\n };\n};\n"],"mappings":";;;;;;AAeO,MAAMA,sBAAsB,GAAG,CAAC;EAAEC;AAAgC,CAAC,KAAK;EAC3E,OAAQC,MAAuB,IAAK;IAChC,MAAM;MAAEC,KAAK;MAAEC,GAAG;MAAEC,KAAK;MAAEC;IAAQ,CAAC,GAAGJ,MAAM;IAC7C,MAAMK,MAAM,GAAGN,OAAO,CAACE,KAAK,CAACK,IAAI,CAAC;IAElC,IAAIC,SAAwB,GAAG,IAAI;IACnC,IAAIF,MAAM,EAAE;MACRE,SAAS,GAAGF,MAAM,CAACG,UAAU,CAAC;QAAEP,KAAK,EAAEA,KAAK,CAACA,KAAK;QAAEE,KAAK;QAAED;MAAI,CAAC,CAAC;IACrE;IACA,IAAI,CAACK,SAAS,EAAE;MACZA,SAAS,GAAGN,KAAK,CAACA,KAAK,CAACQ,SAAS;MACjC,IAAIR,KAAK,CAACS,IAAI,EAAE;QACZH,SAAS,GAAG,OAAON,KAAK,CAACS,IAAI,KAAK,UAAU,GAAGT,KAAK,CAACS,IAAI,CAACP,KAAK,CAAC,GAAGF,KAAK,CAACS,IAAI;MACjF;IACJ;IAEA,MAAMC,MAAgB,GAAG,EAAE;IAC3B,IAAI,CAACV,KAAK,CAACW,aAAa,EAAE;MACtBD,MAAM,CAACE,IAAI,CAAC,QAAQ,CAAC;IACzB;IACAF,MAAM,CAACE,IAAI,CAAC,GAAGZ,KAAK,CAACa,OAAO,CAACC,GAAG,CAACC,CAAC,IAAIA,CAAC,CAACP,SAAS,CAAC,CAAC;IACnDE,MAAM,CAACE,IAAI,CAACN,SAAS,CAAC;IAEtB,OAAO;MACHU,QAAQ,EAAEN,MAAM,CAACO,IAAI,CAAC,GAAG,CAAC;MAC1BR,IAAI,EAAEC,MAAM,CAACQ,MAAM,CAACf,OAAO,GAAG,CAAC,SAAS,CAAC,GAAG,EAAE,CAAC,CAACc,IAAI,CAAC,GAAG;IAC5D,CAAC;EACL,CAAC;AACL,CAAC;AAAC"}
@@ -1,16 +1,12 @@
1
1
  "use strict";
2
2
 
3
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
-
5
4
  Object.defineProperty(exports, "__esModule", {
6
5
  value: true
7
6
  });
8
7
  exports.createDefaultFilterPlugin = void 0;
9
-
10
8
  var _error = _interopRequireDefault(require("@webiny/error"));
11
-
12
9
  var _CmsEntryFilterPlugin = require("../../../../../plugins/CmsEntryFilterPlugin");
13
-
14
10
  const createDefaultFilterPlugin = () => {
15
11
  const plugin = new _CmsEntryFilterPlugin.CmsEntryFilterPlugin({
16
12
  fieldType: _CmsEntryFilterPlugin.CmsEntryFilterPlugin.ALL,
@@ -19,17 +15,14 @@ const createDefaultFilterPlugin = () => {
19
15
  applyFiltering,
20
16
  field
21
17
  } = params;
22
-
23
18
  if (!params.field.isSearchable) {
24
19
  const identifier = [...field.parents.map(p => p.fieldId), field.field.fieldId].join(".");
25
20
  throw new _error.default(`Field "${identifier}" is not searchable.`);
26
21
  }
27
-
28
22
  applyFiltering(params);
29
23
  }
30
24
  });
31
25
  plugin.name = `${plugin.type}.default.all`;
32
26
  return plugin;
33
27
  };
34
-
35
28
  exports.createDefaultFilterPlugin = createDefaultFilterPlugin;
@@ -1 +1 @@
1
- {"version":3,"names":["createDefaultFilterPlugin","plugin","CmsEntryFilterPlugin","fieldType","ALL","exec","params","applyFiltering","field","isSearchable","identifier","parents","map","p","fieldId","join","WebinyError","name","type"],"sources":["defaultFilterPlugin.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport { CmsEntryFilterPlugin } from \"~/plugins/CmsEntryFilterPlugin\";\n\nexport const createDefaultFilterPlugin = () => {\n const plugin = new CmsEntryFilterPlugin({\n fieldType: CmsEntryFilterPlugin.ALL,\n exec: params => {\n const { applyFiltering, field } = params;\n if (!params.field.isSearchable) {\n const identifier = [...field.parents.map(p => p.fieldId), field.field.fieldId].join(\n \".\"\n );\n throw new WebinyError(`Field \"${identifier}\" is not searchable.`);\n }\n applyFiltering(params);\n }\n });\n\n plugin.name = `${plugin.type}.default.all`;\n\n return plugin;\n};\n"],"mappings":";;;;;;;;;AAAA;;AACA;;AAEO,MAAMA,yBAAyB,GAAG,MAAM;EAC3C,MAAMC,MAAM,GAAG,IAAIC,0CAAJ,CAAyB;IACpCC,SAAS,EAAED,0CAAA,CAAqBE,GADI;IAEpCC,IAAI,EAAEC,MAAM,IAAI;MACZ,MAAM;QAAEC,cAAF;QAAkBC;MAAlB,IAA4BF,MAAlC;;MACA,IAAI,CAACA,MAAM,CAACE,KAAP,CAAaC,YAAlB,EAAgC;QAC5B,MAAMC,UAAU,GAAG,CAAC,GAAGF,KAAK,CAACG,OAAN,CAAcC,GAAd,CAAkBC,CAAC,IAAIA,CAAC,CAACC,OAAzB,CAAJ,EAAuCN,KAAK,CAACA,KAAN,CAAYM,OAAnD,EAA4DC,IAA5D,CACf,GADe,CAAnB;QAGA,MAAM,IAAIC,cAAJ,CAAiB,UAASN,UAAW,sBAArC,CAAN;MACH;;MACDH,cAAc,CAACD,MAAD,CAAd;IACH;EAXmC,CAAzB,CAAf;EAcAL,MAAM,CAACgB,IAAP,GAAe,GAAEhB,MAAM,CAACiB,IAAK,cAA7B;EAEA,OAAOjB,MAAP;AACH,CAlBM"}
1
+ {"version":3,"names":["createDefaultFilterPlugin","plugin","CmsEntryFilterPlugin","fieldType","ALL","exec","params","applyFiltering","field","isSearchable","identifier","parents","map","p","fieldId","join","WebinyError","name","type"],"sources":["defaultFilterPlugin.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport { CmsEntryFilterPlugin } from \"~/plugins/CmsEntryFilterPlugin\";\n\nexport const createDefaultFilterPlugin = () => {\n const plugin = new CmsEntryFilterPlugin({\n fieldType: CmsEntryFilterPlugin.ALL,\n exec: params => {\n const { applyFiltering, field } = params;\n if (!params.field.isSearchable) {\n const identifier = [...field.parents.map(p => p.fieldId), field.field.fieldId].join(\n \".\"\n );\n throw new WebinyError(`Field \"${identifier}\" is not searchable.`);\n }\n applyFiltering(params);\n }\n });\n\n plugin.name = `${plugin.type}.default.all`;\n\n return plugin;\n};\n"],"mappings":";;;;;;;AAAA;AACA;AAEO,MAAMA,yBAAyB,GAAG,MAAM;EAC3C,MAAMC,MAAM,GAAG,IAAIC,0CAAoB,CAAC;IACpCC,SAAS,EAAED,0CAAoB,CAACE,GAAG;IACnCC,IAAI,EAAEC,MAAM,IAAI;MACZ,MAAM;QAAEC,cAAc;QAAEC;MAAM,CAAC,GAAGF,MAAM;MACxC,IAAI,CAACA,MAAM,CAACE,KAAK,CAACC,YAAY,EAAE;QAC5B,MAAMC,UAAU,GAAG,CAAC,GAAGF,KAAK,CAACG,OAAO,CAACC,GAAG,CAACC,CAAC,IAAIA,CAAC,CAACC,OAAO,CAAC,EAAEN,KAAK,CAACA,KAAK,CAACM,OAAO,CAAC,CAACC,IAAI,CAC/E,GAAG,CACN;QACD,MAAM,IAAIC,cAAW,CAAE,UAASN,UAAW,sBAAqB,CAAC;MACrE;MACAH,cAAc,CAACD,MAAM,CAAC;IAC1B;EACJ,CAAC,CAAC;EAEFL,MAAM,CAACgB,IAAI,GAAI,GAAEhB,MAAM,CAACiB,IAAK,cAAa;EAE1C,OAAOjB,MAAM;AACjB,CAAC;AAAC"}
@@ -4,15 +4,10 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.createFilterPlugins = void 0;
7
-
8
7
  var _defaultFilterPlugin = require("./defaultFilterPlugin");
9
-
10
8
  var _objectFilterPlugin = require("./objectFilterPlugin");
11
-
12
9
  var _refFilterPlugin = require("./refFilterPlugin");
13
-
14
10
  const createFilterPlugins = () => {
15
11
  return [(0, _defaultFilterPlugin.createDefaultFilterPlugin)(), (0, _objectFilterPlugin.createObjectFilterPlugin)(), (0, _refFilterPlugin.createRefFilterPlugin)()];
16
12
  };
17
-
18
13
  exports.createFilterPlugins = createFilterPlugins;
@@ -1 +1 @@
1
- {"version":3,"names":["createFilterPlugins","createDefaultFilterPlugin","createObjectFilterPlugin","createRefFilterPlugin"],"sources":["index.ts"],"sourcesContent":["import { createDefaultFilterPlugin } from \"./defaultFilterPlugin\";\nimport { createObjectFilterPlugin } from \"./objectFilterPlugin\";\nimport { createRefFilterPlugin } from \"./refFilterPlugin\";\n\nexport const createFilterPlugins = () => {\n return [createDefaultFilterPlugin(), createObjectFilterPlugin(), createRefFilterPlugin()];\n};\n"],"mappings":";;;;;;;AAAA;;AACA;;AACA;;AAEO,MAAMA,mBAAmB,GAAG,MAAM;EACrC,OAAO,CAAC,IAAAC,8CAAA,GAAD,EAA8B,IAAAC,4CAAA,GAA9B,EAA0D,IAAAC,sCAAA,GAA1D,CAAP;AACH,CAFM"}
1
+ {"version":3,"names":["createFilterPlugins","createDefaultFilterPlugin","createObjectFilterPlugin","createRefFilterPlugin"],"sources":["index.ts"],"sourcesContent":["import { createDefaultFilterPlugin } from \"./defaultFilterPlugin\";\nimport { createObjectFilterPlugin } from \"./objectFilterPlugin\";\nimport { createRefFilterPlugin } from \"./refFilterPlugin\";\n\nexport const createFilterPlugins = () => {\n return [createDefaultFilterPlugin(), createObjectFilterPlugin(), createRefFilterPlugin()];\n};\n"],"mappings":";;;;;;AAAA;AACA;AACA;AAEO,MAAMA,mBAAmB,GAAG,MAAM;EACrC,OAAO,CAAC,IAAAC,8CAAyB,GAAE,EAAE,IAAAC,4CAAwB,GAAE,EAAE,IAAAC,sCAAqB,GAAE,CAAC;AAC7F,CAAC;AAAC"}
@@ -1,18 +1,13 @@
1
1
  "use strict";
2
2
 
3
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
-
5
4
  Object.defineProperty(exports, "__esModule", {
6
5
  value: true
7
6
  });
8
7
  exports.createObjectFilterPlugin = void 0;
9
-
10
8
  var _CmsEntryFilterPlugin = require("../../../../../plugins/CmsEntryFilterPlugin");
11
-
12
9
  var _apiElasticsearch = require("@webiny/api-elasticsearch");
13
-
14
10
  var _error = _interopRequireDefault(require("@webiny/error"));
15
-
16
11
  const createObjectFilterPlugin = () => {
17
12
  const plugin = new _CmsEntryFilterPlugin.CmsEntryFilterPlugin({
18
13
  fieldType: "object",
@@ -29,21 +24,17 @@ const createObjectFilterPlugin = () => {
29
24
  * Because this is an object field, we must construct filters based on the value property.
30
25
  * Value property is actually a where condition.
31
26
  */
32
-
33
27
  for (const key in where) {
34
28
  const value = where[key];
35
-
36
29
  if (value === undefined) {
37
30
  continue;
38
31
  }
39
-
40
32
  const {
41
33
  field: whereFieldId,
42
34
  operator
43
35
  } = (0, _apiElasticsearch.parseWhereKey)(key);
44
36
  const identifier = [...parentField.parents.map(p => p.fieldId), parentField.field.fieldId, whereFieldId].join(".");
45
37
  const field = fields[identifier];
46
-
47
38
  if (!field) {
48
39
  throw new _error.default(`There is no field "${identifier}".`);
49
40
  }
@@ -51,13 +42,10 @@ const createObjectFilterPlugin = () => {
51
42
  * We need to find the filter plugin for the child field.
52
43
  * This will throw error if no plugin can be found.
53
44
  */
54
-
55
-
56
45
  const plugin = getFilterPlugin(field.type);
57
46
  /**
58
47
  * Basically this allows us to go into depth as much as we want with the object fields.
59
48
  */
60
-
61
49
  plugin.exec({
62
50
  applyFiltering,
63
51
  getFilterPlugin,
@@ -74,5 +62,4 @@ const createObjectFilterPlugin = () => {
74
62
  plugin.name = `${plugin.type}.default.object`;
75
63
  return plugin;
76
64
  };
77
-
78
65
  exports.createObjectFilterPlugin = createObjectFilterPlugin;
@@ -1 +1 @@
1
- {"version":3,"names":["createObjectFilterPlugin","plugin","CmsEntryFilterPlugin","fieldType","exec","params","applyFiltering","value","where","fields","field","parentField","getFilterPlugin","query","key","undefined","whereFieldId","operator","parseWhereKey","identifier","parents","map","p","fieldId","join","WebinyError","type","name"],"sources":["objectFilterPlugin.ts"],"sourcesContent":["import { CmsEntryFilterPlugin } from \"~/plugins/CmsEntryFilterPlugin\";\nimport { parseWhereKey } from \"@webiny/api-elasticsearch\";\nimport WebinyError from \"@webiny/error\";\n\nexport const createObjectFilterPlugin = () => {\n const plugin = new CmsEntryFilterPlugin({\n fieldType: \"object\",\n exec: params => {\n const {\n applyFiltering,\n value: where,\n fields,\n field: parentField,\n getFilterPlugin,\n query\n } = params;\n /**\n * Because this is an object field, we must construct filters based on the value property.\n * Value property is actually a where condition.\n */\n for (const key in where) {\n const value = where[key];\n if (value === undefined) {\n continue;\n }\n const { field: whereFieldId, operator } = parseWhereKey(key);\n\n const identifier = [\n ...parentField.parents.map(p => p.fieldId),\n parentField.field.fieldId,\n whereFieldId\n ].join(\".\");\n const field = fields[identifier];\n if (!field) {\n throw new WebinyError(`There is no field \"${identifier}\".`);\n }\n /**\n * We need to find the filter plugin for the child field.\n * This will throw error if no plugin can be found.\n */\n const plugin = getFilterPlugin(field.type);\n /**\n * Basically this allows us to go into depth as much as we want with the object fields.\n */\n plugin.exec({\n applyFiltering,\n getFilterPlugin,\n key,\n value,\n operator,\n field,\n fields,\n query\n });\n }\n }\n });\n\n plugin.name = `${plugin.type}.default.object`;\n\n return plugin;\n};\n"],"mappings":";;;;;;;;;AAAA;;AACA;;AACA;;AAEO,MAAMA,wBAAwB,GAAG,MAAM;EAC1C,MAAMC,MAAM,GAAG,IAAIC,0CAAJ,CAAyB;IACpCC,SAAS,EAAE,QADyB;IAEpCC,IAAI,EAAEC,MAAM,IAAI;MACZ,MAAM;QACFC,cADE;QAEFC,KAAK,EAAEC,KAFL;QAGFC,MAHE;QAIFC,KAAK,EAAEC,WAJL;QAKFC,eALE;QAMFC;MANE,IAOFR,MAPJ;MAQA;AACZ;AACA;AACA;;MACY,KAAK,MAAMS,GAAX,IAAkBN,KAAlB,EAAyB;QACrB,MAAMD,KAAK,GAAGC,KAAK,CAACM,GAAD,CAAnB;;QACA,IAAIP,KAAK,KAAKQ,SAAd,EAAyB;UACrB;QACH;;QACD,MAAM;UAAEL,KAAK,EAAEM,YAAT;UAAuBC;QAAvB,IAAoC,IAAAC,+BAAA,EAAcJ,GAAd,CAA1C;QAEA,MAAMK,UAAU,GAAG,CACf,GAAGR,WAAW,CAACS,OAAZ,CAAoBC,GAApB,CAAwBC,CAAC,IAAIA,CAAC,CAACC,OAA/B,CADY,EAEfZ,WAAW,CAACD,KAAZ,CAAkBa,OAFH,EAGfP,YAHe,EAIjBQ,IAJiB,CAIZ,GAJY,CAAnB;QAKA,MAAMd,KAAK,GAAGD,MAAM,CAACU,UAAD,CAApB;;QACA,IAAI,CAACT,KAAL,EAAY;UACR,MAAM,IAAIe,cAAJ,CAAiB,sBAAqBN,UAAW,IAAjD,CAAN;QACH;QACD;AAChB;AACA;AACA;;;QACgB,MAAMlB,MAAM,GAAGW,eAAe,CAACF,KAAK,CAACgB,IAAP,CAA9B;QACA;AAChB;AACA;;QACgBzB,MAAM,CAACG,IAAP,CAAY;UACRE,cADQ;UAERM,eAFQ;UAGRE,GAHQ;UAIRP,KAJQ;UAKRU,QALQ;UAMRP,KANQ;UAORD,MAPQ;UAQRI;QARQ,CAAZ;MAUH;IACJ;EAlDmC,CAAzB,CAAf;EAqDAZ,MAAM,CAAC0B,IAAP,GAAe,GAAE1B,MAAM,CAACyB,IAAK,iBAA7B;EAEA,OAAOzB,MAAP;AACH,CAzDM"}
1
+ {"version":3,"names":["createObjectFilterPlugin","plugin","CmsEntryFilterPlugin","fieldType","exec","params","applyFiltering","value","where","fields","field","parentField","getFilterPlugin","query","key","undefined","whereFieldId","operator","parseWhereKey","identifier","parents","map","p","fieldId","join","WebinyError","type","name"],"sources":["objectFilterPlugin.ts"],"sourcesContent":["import { CmsEntryFilterPlugin } from \"~/plugins/CmsEntryFilterPlugin\";\nimport { parseWhereKey } from \"@webiny/api-elasticsearch\";\nimport WebinyError from \"@webiny/error\";\n\nexport const createObjectFilterPlugin = () => {\n const plugin = new CmsEntryFilterPlugin({\n fieldType: \"object\",\n exec: params => {\n const {\n applyFiltering,\n value: where,\n fields,\n field: parentField,\n getFilterPlugin,\n query\n } = params;\n /**\n * Because this is an object field, we must construct filters based on the value property.\n * Value property is actually a where condition.\n */\n for (const key in where) {\n const value = where[key];\n if (value === undefined) {\n continue;\n }\n const { field: whereFieldId, operator } = parseWhereKey(key);\n\n const identifier = [\n ...parentField.parents.map(p => p.fieldId),\n parentField.field.fieldId,\n whereFieldId\n ].join(\".\");\n const field = fields[identifier];\n if (!field) {\n throw new WebinyError(`There is no field \"${identifier}\".`);\n }\n /**\n * We need to find the filter plugin for the child field.\n * This will throw error if no plugin can be found.\n */\n const plugin = getFilterPlugin(field.type);\n /**\n * Basically this allows us to go into depth as much as we want with the object fields.\n */\n plugin.exec({\n applyFiltering,\n getFilterPlugin,\n key,\n value,\n operator,\n field,\n fields,\n query\n });\n }\n }\n });\n\n plugin.name = `${plugin.type}.default.object`;\n\n return plugin;\n};\n"],"mappings":";;;;;;;AAAA;AACA;AACA;AAEO,MAAMA,wBAAwB,GAAG,MAAM;EAC1C,MAAMC,MAAM,GAAG,IAAIC,0CAAoB,CAAC;IACpCC,SAAS,EAAE,QAAQ;IACnBC,IAAI,EAAEC,MAAM,IAAI;MACZ,MAAM;QACFC,cAAc;QACdC,KAAK,EAAEC,KAAK;QACZC,MAAM;QACNC,KAAK,EAAEC,WAAW;QAClBC,eAAe;QACfC;MACJ,CAAC,GAAGR,MAAM;MACV;AACZ;AACA;AACA;MACY,KAAK,MAAMS,GAAG,IAAIN,KAAK,EAAE;QACrB,MAAMD,KAAK,GAAGC,KAAK,CAACM,GAAG,CAAC;QACxB,IAAIP,KAAK,KAAKQ,SAAS,EAAE;UAC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