@webiny/api-headless-cms-utils-os 0.0.0-unstable.d0f34a8194 → 0.0.0-unstable.e1999482d0

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 (21) hide show
  1. package/features/CmsEntryOpenSearchExecFiltering/CmsEntryOpenSearchExecFiltering.js +2 -3
  2. package/features/CmsEntryOpenSearchExecFiltering/CmsEntryOpenSearchExecFiltering.js.map +1 -1
  3. package/features/CmsEntryOpenSearchFieldIndex/fields/DateTimeFieldIndex.js +4 -4
  4. package/features/CmsEntryOpenSearchFieldIndex/fields/DateTimeFieldIndex.js.map +1 -1
  5. package/features/CmsEntryOpenSearchFieldIndex/fields/TextCompressedFieldIndex.js +1 -1
  6. package/features/CmsEntryOpenSearchFieldIndex/fields/TextCompressedFieldIndex.js.map +1 -1
  7. package/features/CmsEntryOpenSearchFieldIndex/fields/TextEncryptedFieldIndex.js +1 -1
  8. package/features/CmsEntryOpenSearchFieldIndex/fields/TextEncryptedFieldIndex.js.map +1 -1
  9. package/features/CmsEntryOpenSearchValueSearch/fields/SearchableJsonSearch.js +1 -1
  10. package/features/CmsEntryOpenSearchValueSearch/fields/SearchableJsonSearch.js.map +1 -1
  11. package/helpers/fieldIdentifier.js +2 -2
  12. package/helpers/fieldIdentifier.js.map +1 -1
  13. package/operations/entry/elasticsearch/assignMinimumShouldMatchToQuery.js +2 -2
  14. package/operations/entry/elasticsearch/assignMinimumShouldMatchToQuery.js.map +1 -1
  15. package/operations/entry/elasticsearch/fullTextSearch.js +2 -2
  16. package/operations/entry/elasticsearch/fullTextSearch.js.map +1 -1
  17. package/operations/entry/elasticsearch/initialQuery.test.js +2 -2
  18. package/operations/entry/elasticsearch/initialQuery.test.js.map +1 -1
  19. package/operations/entry/elasticsearch/keyword.js +2 -2
  20. package/operations/entry/elasticsearch/keyword.js.map +1 -1
  21. package/package.json +7 -7
@@ -34,7 +34,7 @@ class CmsEntryOpenSearchExecFilteringImpl {
34
34
  for(const key in where){
35
35
  const value = where[key];
36
36
  if (void 0 === value) continue;
37
- if ("AND" === key) {
37
+ else if ("AND" === key) {
38
38
  const childWhereList = getWhereValues(value, "AND");
39
39
  const childQuery = createBaseQuery();
40
40
  for (const childWhere of childWhereList)execFiltering({
@@ -48,8 +48,7 @@ class CmsEntryOpenSearchExecFilteringImpl {
48
48
  bool: childQueryBool
49
49
  });
50
50
  continue;
51
- }
52
- if ("OR" === key) {
51
+ } else if ("OR" === key) {
53
52
  const childWhereList = getWhereValues(value, "OR");
54
53
  const should = [];
55
54
  for (const childWhere of childWhereList){
@@ -1 +1 @@
1
- {"version":3,"file":"features/CmsEntryOpenSearchExecFiltering/CmsEntryOpenSearchExecFiltering.js","sources":["../../../src/features/CmsEntryOpenSearchExecFiltering/CmsEntryOpenSearchExecFiltering.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport type { CmsEntryListWhere } from \"@webiny/api-headless-cms/types/index.js\";\nimport type { QueryDslQueryContainer as Query } from \"@webiny/api-opensearch/types.js\";\nimport { parseWhereKey } from \"@webiny/api-opensearch\";\nimport { createBaseQuery } from \"~/operations/entry/elasticsearch/initialQuery.js\";\nimport { assignMinimumShouldMatchToQuery } from \"~/operations/entry/elasticsearch/assignMinimumShouldMatchToQuery.js\";\nimport { CmsEntryOpenSearchFilterRegistry } from \"~/features/CmsEntryOpenSearchFilter/index.js\";\nimport { CmsEntryOpenSearchOperatorList } from \"~/features/CmsEntryOpenSearchOperatorList/index.js\";\nimport { CmsEntryOpenSearchValueTransformer } from \"~/features/CmsEntryOpenSearchValueTransformer/index.js\";\nimport { CmsEntryOpenSearchFieldPathFactory } from \"~/features/CmsEntryOpenSearchFieldPathFactory/index.js\";\nimport { CmsEntryOpenSearchExecFiltering as CmsEntryOpenSearchExecFilteringAbstraction } from \"./abstractions.js\";\nimport { getWhereValues } from \"./values.js\";\nimport { getPopulated } from \"./populated.js\";\nimport { createApplyFiltering } from \"./applyFiltering.js\";\n\ninterface InternalExecParams {\n where: CmsEntryListWhere;\n query: CmsEntryOpenSearchExecFilteringAbstraction.Params[\"query\"];\n isValues?: boolean;\n}\n\nclass CmsEntryOpenSearchExecFilteringImpl\n implements CmsEntryOpenSearchExecFilteringAbstraction.Interface\n{\n public constructor(\n private readonly operatorList: CmsEntryOpenSearchOperatorList.Interface,\n private readonly valueTransformer: CmsEntryOpenSearchValueTransformer.Interface,\n private readonly fieldPathFactory: CmsEntryOpenSearchFieldPathFactory.Interface,\n private readonly filterRegistry: CmsEntryOpenSearchFilterRegistry.Interface\n ) {}\n\n public execute(params: CmsEntryOpenSearchExecFilteringAbstraction.Params): void {\n const { model, fields, where, query } = params;\n\n const operators = this.operatorList.getAll();\n\n const applyFiltering = createApplyFiltering({\n operators,\n valueTransformer: this.valueTransformer,\n fieldPathFactory: this.fieldPathFactory\n });\n\n const getFilter = (type: string) => {\n return this.filterRegistry.get(type);\n };\n\n const execFiltering = (params: InternalExecParams) => {\n const { where: initialWhere, query, isValues = false } = params;\n const keys = Object.keys(initialWhere);\n if (keys.length === 0) {\n return;\n }\n const where = structuredClone(initialWhere);\n\n for (const key in where) {\n const value = where[key as keyof typeof where];\n if (value === undefined) {\n continue;\n } else if (key === \"AND\") {\n const childWhereList = getWhereValues(value, \"AND\");\n const childQuery = createBaseQuery();\n for (const childWhere of childWhereList) {\n execFiltering({ query: childQuery, where: childWhere, isValues });\n }\n const childQueryBool = getPopulated(childQuery);\n if (Object.keys(childQueryBool).length === 0) {\n continue;\n }\n query.filter.push({ bool: childQueryBool });\n continue;\n } else if (key === \"OR\") {\n const childWhereList = getWhereValues(value, \"OR\");\n const should: Query[] = [];\n for (const childWhere of childWhereList) {\n const childQuery = createBaseQuery();\n execFiltering({ query: childQuery, where: childWhere, isValues });\n const childQueryBool = getPopulated(childQuery);\n if (Object.keys(childQueryBool).length === 0) {\n continue;\n }\n should.push({ bool: childQueryBool });\n }\n if (should.length === 0) {\n continue;\n }\n query.should.push(...should);\n assignMinimumShouldMatchToQuery({ query });\n continue;\n } else if (key === \"values\") {\n execFiltering({\n query,\n where: where[key] as CmsEntryListWhere,\n isValues: true\n });\n continue;\n }\n const { field: whereFieldId, operator } = parseWhereKey(key);\n let fieldId: string = isValues ? `values.${whereFieldId}` : whereFieldId;\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 \"${fieldId}\".`);\n } else if (cmsModelField) {\n fieldId = cmsModelField.fieldId;\n }\n\n const field = fields[fieldId];\n if (!field) {\n throw new WebinyError(\n `There is no field \"${fieldId}\".`,\n \"EXEC_FILTERING_ERROR\"\n );\n }\n const filter = getFilter(field.type);\n\n filter.exec({\n applyFiltering,\n getFilter,\n key,\n value,\n operator,\n field,\n fields,\n query\n });\n }\n };\n\n execFiltering({ where, query });\n }\n}\n\nexport const CmsEntryOpenSearchExecFiltering =\n CmsEntryOpenSearchExecFilteringAbstraction.createImplementation({\n implementation: CmsEntryOpenSearchExecFilteringImpl,\n dependencies: [\n CmsEntryOpenSearchOperatorList,\n CmsEntryOpenSearchValueTransformer,\n CmsEntryOpenSearchFieldPathFactory,\n CmsEntryOpenSearchFilterRegistry\n ]\n });\n"],"names":["CmsEntryOpenSearchExecFilteringImpl","operatorList","valueTransformer","fieldPathFactory","filterRegistry","params","model","fields","where","query","operators","applyFiltering","createApplyFiltering","getFilter","type","execFiltering","initialWhere","isValues","keys","Object","structuredClone","key","value","undefined","childWhereList","getWhereValues","childQuery","createBaseQuery","childWhere","childQueryBool","getPopulated","should","assignMinimumShouldMatchToQuery","whereFieldId","operator","parseWhereKey","fieldId","cmsModelField","f","WebinyError","field","filter","CmsEntryOpenSearchExecFiltering","CmsEntryOpenSearchExecFilteringAbstraction","CmsEntryOpenSearchOperatorList","CmsEntryOpenSearchValueTransformer","CmsEntryOpenSearchFieldPathFactory","CmsEntryOpenSearchFilterRegistry"],"mappings":";;;;;;;;;;;;AAqBA,MAAMA;IAGF,YACqBC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C;oBACAE;gBACJ;YACJ;QACJ;QAEAM,cAAc;YAAEP;YAAOC;QAAM;IACjC;AACJ;AAEO,MAAMiC,kEACTC,gCAAAA,oBAA+D,CAAC;IAC5D,gBAAgB3C;IAChB,cAAc;QACV4C;QACAC;QACAC;QACAC;KACH;AACL"}
1
+ {"version":3,"file":"features/CmsEntryOpenSearchExecFiltering/CmsEntryOpenSearchExecFiltering.js","sources":["../../../src/features/CmsEntryOpenSearchExecFiltering/CmsEntryOpenSearchExecFiltering.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport type { CmsEntryListWhere } from \"@webiny/api-headless-cms/types/index.js\";\nimport type { QueryDslQueryContainer as Query } from \"@webiny/api-opensearch/types.js\";\nimport { parseWhereKey } from \"@webiny/api-opensearch\";\nimport { createBaseQuery } from \"~/operations/entry/elasticsearch/initialQuery.js\";\nimport { assignMinimumShouldMatchToQuery } from \"~/operations/entry/elasticsearch/assignMinimumShouldMatchToQuery.js\";\nimport { CmsEntryOpenSearchFilterRegistry } from \"~/features/CmsEntryOpenSearchFilter/index.js\";\nimport { CmsEntryOpenSearchOperatorList } from \"~/features/CmsEntryOpenSearchOperatorList/index.js\";\nimport { CmsEntryOpenSearchValueTransformer } from \"~/features/CmsEntryOpenSearchValueTransformer/index.js\";\nimport { CmsEntryOpenSearchFieldPathFactory } from \"~/features/CmsEntryOpenSearchFieldPathFactory/index.js\";\nimport { CmsEntryOpenSearchExecFiltering as CmsEntryOpenSearchExecFilteringAbstraction } from \"./abstractions.js\";\nimport { getWhereValues } from \"./values.js\";\nimport { getPopulated } from \"./populated.js\";\nimport { createApplyFiltering } from \"./applyFiltering.js\";\n\ninterface InternalExecParams {\n where: CmsEntryListWhere;\n query: CmsEntryOpenSearchExecFilteringAbstraction.Params[\"query\"];\n isValues?: boolean;\n}\n\nclass CmsEntryOpenSearchExecFilteringImpl\n implements CmsEntryOpenSearchExecFilteringAbstraction.Interface\n{\n public constructor(\n private readonly operatorList: CmsEntryOpenSearchOperatorList.Interface,\n private readonly valueTransformer: CmsEntryOpenSearchValueTransformer.Interface,\n private readonly fieldPathFactory: CmsEntryOpenSearchFieldPathFactory.Interface,\n private readonly filterRegistry: CmsEntryOpenSearchFilterRegistry.Interface\n ) {}\n\n public execute(params: CmsEntryOpenSearchExecFilteringAbstraction.Params): void {\n const { model, fields, where, query } = params;\n\n const operators = this.operatorList.getAll();\n\n const applyFiltering = createApplyFiltering({\n operators,\n valueTransformer: this.valueTransformer,\n fieldPathFactory: this.fieldPathFactory\n });\n\n const getFilter = (type: string) => {\n return this.filterRegistry.get(type);\n };\n\n const execFiltering = (params: InternalExecParams) => {\n const { where: initialWhere, query, isValues = false } = params;\n const keys = Object.keys(initialWhere);\n if (keys.length === 0) {\n return;\n }\n const where = structuredClone(initialWhere);\n\n for (const key in where) {\n const value = where[key as keyof typeof where];\n if (value === undefined) {\n continue;\n } else if (key === \"AND\") {\n const childWhereList = getWhereValues(value, \"AND\");\n const childQuery = createBaseQuery();\n for (const childWhere of childWhereList) {\n execFiltering({ query: childQuery, where: childWhere, isValues });\n }\n const childQueryBool = getPopulated(childQuery);\n if (Object.keys(childQueryBool).length === 0) {\n continue;\n }\n query.filter.push({ bool: childQueryBool });\n continue;\n } else if (key === \"OR\") {\n const childWhereList = getWhereValues(value, \"OR\");\n const should: Query[] = [];\n for (const childWhere of childWhereList) {\n const childQuery = createBaseQuery();\n execFiltering({ query: childQuery, where: childWhere, isValues });\n const childQueryBool = getPopulated(childQuery);\n if (Object.keys(childQueryBool).length === 0) {\n continue;\n }\n should.push({ bool: childQueryBool });\n }\n if (should.length === 0) {\n continue;\n }\n query.should.push(...should);\n assignMinimumShouldMatchToQuery({ query });\n continue;\n } else if (key === \"values\") {\n execFiltering({\n query,\n where: where[key] as CmsEntryListWhere,\n isValues: true\n });\n continue;\n }\n const { field: whereFieldId, operator } = parseWhereKey(key);\n let fieldId: string = isValues ? `values.${whereFieldId}` : whereFieldId;\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 \"${fieldId}\".`);\n } else if (cmsModelField) {\n fieldId = cmsModelField.fieldId;\n }\n\n const field = fields[fieldId];\n if (!field) {\n throw new WebinyError(\n `There is no field \"${fieldId}\".`,\n \"EXEC_FILTERING_ERROR\"\n );\n }\n const filter = getFilter(field.type);\n\n filter.exec({\n applyFiltering,\n getFilter,\n key,\n value,\n operator,\n field,\n fields,\n query\n });\n }\n };\n\n execFiltering({ where, query });\n }\n}\n\nexport const CmsEntryOpenSearchExecFiltering =\n CmsEntryOpenSearchExecFilteringAbstraction.createImplementation({\n implementation: CmsEntryOpenSearchExecFilteringImpl,\n dependencies: [\n CmsEntryOpenSearchOperatorList,\n CmsEntryOpenSearchValueTransformer,\n CmsEntryOpenSearchFieldPathFactory,\n CmsEntryOpenSearchFilterRegistry\n ]\n });\n"],"names":["CmsEntryOpenSearchExecFilteringImpl","operatorList","valueTransformer","fieldPathFactory","filterRegistry","params","model","fields","where","query","operators","applyFiltering","createApplyFiltering","getFilter","type","execFiltering","initialWhere","isValues","keys","Object","structuredClone","key","value","undefined","childWhereList","getWhereValues","childQuery","createBaseQuery","childWhere","childQueryBool","getPopulated","should","assignMinimumShouldMatchToQuery","whereFieldId","operator","parseWhereKey","fieldId","cmsModelField","f","WebinyError","field","filter","CmsEntryOpenSearchExecFiltering","CmsEntryOpenSearchExecFilteringAbstraction","CmsEntryOpenSearchOperatorList","CmsEntryOpenSearchValueTransformer","CmsEntryOpenSearchFieldPathFactory","CmsEntryOpenSearchFilterRegistry"],"mappings":";;;;;;;;;;;;AAqBA,MAAMA;IAGF,YACqBC,YAAsD,EACtDC,gBAA8D,EAC9DC,gBAA8D,EAC9DC,cAA0D,CAC7E;aAJmBH,YAAY,GAAZA;aACAC,gBAAgB,GAAhBA;aACAC,gBAAgB,GAAhBA;aACAC,cAAc,GAAdA;IAClB;IAEI,QAAQC,MAAyD,EAAQ;QAC5E,MAAM,E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15 @@ const convertNumberToTime = (value)=>{
17
17
  };
18
18
  const convertValueToIndex = (value, field)=>{
19
19
  if (!value) return null;
20
- if (field.settings?.type === "time") return convertTimeToNumber(value);
20
+ else if (field.settings?.type === "time") return convertTimeToNumber(value);
21
21
  return value;
22
22
  };
23
23
  const convertValueFromIndex = (value, field)=>{
24
24
  const type = field.settings?.type;
25
25
  if ("time" === type) return convertNumberToTime(value);
26
- if (!value) return null;
27
- if ("dateTimeWithTimezone" === type) return value;
28
- if ("date" === type) {
26
+ else if (!value) return null;
27
+ else if ("dateTimeWithTimezone" === type) return value;
28
+ else if ("date" === type) {
29
29
  const dateValue = new Date(value);
30
30
  return dateValue.toISOString().slice(0, 10);
31
31
  }
@@ -1 +1 @@
1
- {"version":3,"file":"features/CmsEntryOpenSearchFieldIndex/fields/DateTimeFieldIndex.js","sources":["../../../../src/features/CmsEntryOpenSearchFieldIndex/fields/DateTimeFieldIndex.ts"],"sourcesContent":["import type { CmsModelDateTimeField } from \"@webiny/api-headless-cms/types/index.js\";\nimport { CmsEntryOpenSearchFieldIndex } from \"../abstractions/CmsEntryOpenSearchFieldIndex.js\";\n\nconst convertTimeToNumber = (time?: string): number | null => {\n if (!time) {\n return null;\n }\n const [hours, minutes, seconds = 0] = time.split(\":\").map(Number);\n return hours * 60 * 60 + minutes * 60 + seconds;\n};\n\nconst convertNumberToTime = (value?: number): string | null => {\n if (value === undefined || value === null) {\n return null;\n }\n\n const hours = Math.floor(value / 60 / 60);\n const minutes = Math.floor((value - hours * 60 * 60) / 60);\n const seconds = Math.floor(value - hours * 60 * 60 - minutes * 60);\n\n return [hours, minutes, seconds].map(v => String(v).padStart(2, \"0\")).join(\":\");\n};\n\nconst convertValueToIndex = (value: string, field: CmsModelDateTimeField) => {\n if (!value) {\n return null;\n } else if (field.settings?.type === \"time\") {\n return convertTimeToNumber(value);\n }\n return value;\n};\n\nconst convertValueFromIndex = (\n value: string | number,\n field: CmsModelDateTimeField\n): string | null => {\n const type = field.settings?.type;\n if (type === \"time\") {\n return convertNumberToTime(value as number);\n } else if (!value) {\n return null;\n } else if (type === \"dateTimeWithTimezone\") {\n return value as string;\n } else if (type === \"date\") {\n const dateValue = new Date(value);\n return dateValue.toISOString().slice(0, 10);\n }\n return new Date(value).toISOString();\n};\n\nclass DateTimeFieldIndexImpl implements CmsEntryOpenSearchFieldIndex.Interface {\n public readonly fieldType = \"datetime\";\n\n public unmappedType(): string {\n return \"date\";\n }\n\n public toIndex({\n field,\n value\n }: CmsEntryOpenSearchFieldIndex.ToIndex): CmsEntryOpenSearchFieldIndex.ToValue {\n if (Array.isArray(value) === true) {\n return {\n value: value.map((v: string) => {\n return convertValueToIndex(v, field as CmsModelDateTimeField);\n })\n };\n }\n return {\n value: convertValueToIndex(value, field as CmsModelDateTimeField)\n };\n }\n\n public fromIndex({ field, value }: CmsEntryOpenSearchFieldIndex.FromIndex): any {\n if (Array.isArray(value) === true) {\n return value.map((v: string) => {\n return convertValueFromIndex(v, field as CmsModelDateTimeField);\n });\n }\n return convertValueFromIndex(value, field as CmsModelDateTimeField);\n }\n}\n\nexport const DateTimeFieldIndex = CmsEntryOpenSearchFieldIndex.createImplementation({\n implementation: DateTimeFieldIndexImpl,\n dependencies: []\n});\n"],"names":["convertTimeToNumber","time","hours","minutes","seconds","Number","convertNumberToTime","value","Math","v","String","convertValueToIndex","field","convertValueFromIndex","type","dateValue","Date","DateTimeFieldIndexImpl","Array","DateTimeFieldIndex","CmsEntryOpenSearchFieldIndex"],"mappings":";AAGA,MAAMA,sBAAsB,CAACC;IACzB,IAAI,CAACA,MACD,OAAO;IAEX,MAAM,CAACC,OAAOC,SAASC,UAAU,CAAC,CAAC,GAAGH,KAAK,KAAK,CAAC,KAAK,GAAG,CAACI;IAC1D,OAAOH,AAAQ,KAARA,QAAa,KAAKC,AAAU,KAAVA,UAAeC;AAC5C;AAEA,MAAME,sBAAsB,CAACC;IACzB,IAAIA,QAAAA,OACA,OAAO;IAGX,MAAML,QAAQM,KAAK,KAA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CAAC,CAACE,IACPI,sBAAsBJ,GAAGG;QAGxC,OAAOC,sBAAsBN,OAAOK;IACxC;;aA7BgB,SAAS,GAAG;;AA8BhC;AAEO,MAAMO,qBAAqBC,6BAA6B,oBAAoB,CAAC;IAChF,gBAAgBH;IAChB,cAAc,EAAE;AACpB"}
1
+ {"version":3,"file":"features/CmsEntryOpenSearchFieldIndex/fields/DateTimeFieldIndex.js","sources":["../../../../src/features/CmsEntryOpenSearchFieldIndex/fields/DateTimeFieldIndex.ts"],"sourcesContent":["import type { CmsModelDateTimeField } from \"@webiny/api-headless-cms/types/index.js\";\nimport { CmsEntryOpenSearchFieldIndex } from \"../abstractions/CmsEntryOpenSearchFieldIndex.js\";\n\nconst convertTimeToNumber = (time?: string): number | null => {\n if (!time) {\n return null;\n }\n const [hours, minutes, seconds = 0] = time.split(\":\").map(Number);\n return hours * 60 * 60 + minutes * 60 + seconds;\n};\n\nconst convertNumberToTime = (value?: number): string | null => {\n if (value === undefined || value === null) {\n return null;\n }\n\n const hours = Math.floor(value / 60 / 60);\n const minutes = Math.floor((value - hours * 60 * 60) / 60);\n const seconds = Math.floor(value - hours * 60 * 60 - minutes * 60);\n\n return [hours, minutes, seconds].map(v => String(v).padStart(2, \"0\")).join(\":\");\n};\n\nconst convertValueToIndex = (value: string, field: CmsModelDateTimeField) => {\n if (!value) {\n return null;\n } else if (field.settings?.type === \"time\") {\n return convertTimeToNumber(value);\n }\n return value;\n};\n\nconst convertValueFromIndex = (\n value: string | number,\n field: CmsModelDateTimeField\n): string | null => {\n const type = field.settings?.type;\n if (type === \"time\") {\n return convertNumberToTime(value as number);\n } else if (!value) {\n return null;\n } else if (type === \"dateTimeWithTimezone\") {\n return value as string;\n } else if (type === \"date\") {\n const dateValue = new Date(value);\n return dateValue.toISOString().slice(0, 10);\n }\n return new Date(value).toISOString();\n};\n\nclass DateTimeFieldIndexImpl implements CmsEntryOpenSearchFieldIndex.Interface {\n public readonly fieldType = \"datetime\";\n\n public unmappedType(): string {\n return \"date\";\n }\n\n public toIndex({\n field,\n value\n }: CmsEntryOpenSearchFieldIndex.ToIndex): CmsEntryOpenSearchFieldIndex.ToValue {\n if (Array.isArray(value) === true) {\n return {\n value: value.map((v: string) => {\n return convertValueToIndex(v, field as CmsModelDateTimeField);\n })\n };\n }\n return {\n value: convertValueToIndex(value, field as CmsModelDateTimeField)\n };\n }\n\n public fromIndex({ field, value }: CmsEntryOpenSearchFieldIndex.FromIndex): any {\n if (Array.isArray(value) === true) {\n return value.map((v: string) => {\n return convertValueFromIndex(v, field as CmsModelDateTimeField);\n });\n }\n return convertValueFromIndex(value, field as CmsModelDateTimeField);\n }\n}\n\nexport const DateTimeFieldIndex = CmsEntryOpenSearchFieldIndex.createImplementation({\n implementation: DateTimeFieldIndexImpl,\n dependencies: []\n});\n"],"names":["convertTimeToNumber","time","hours","minutes","seconds","Number","convertNumberToTime","value","Math","v","String","convertValueToIndex","field","convertValueFromIndex","type","dateValue","Date","DateTimeFieldIndexImpl","Array","DateTimeFieldIndex","CmsEntryOpenSearchFieldIndex"],"mappings":";AAGA,MAAMA,sBAAsB,CAACC;IACzB,IAAI,CAACA,MACD,OAAO;IAEX,MAAM,CAACC,OAAOC,SAASC,UAAU,CAAC,CAAC,GAAGH,KAAK,KAAK,CAAC,KAAK,GAAG,CAACI;IAC1D,OAAOH,AAAQ,KAARA,QAAa,KAAKC,AAAU,KAAVA,UAAeC;AAC5C;AAEA,MAAME,sBAAsB,CAACC;IACzB,IAAIA,QAAAA,OACA,OAAO;IAGX,MAAML,QAAQM,KAAK,KAAK,CAACD,QAAQ,KAAK;IACtC,MAAMJ,UAAUK,KAAK,KAAK,CAAED,AAAAA,CAAAA,QAAQL,AAAQ,KAARA,QAAa,EAAC,IAAK;IACvD,MAAME,UAAUI,KAAK,KAAK,CAACD,QAAQL,AAAQ,KAARA,QAAa,KAAKC,AAAU,KAAVA;IAErD,OAAO;QAACD;QAAOC;QAASC;KAAQ,CAAC,GAAG,CAACK,CAAAA,IA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this.fieldRegistry.get(field.type);
27
27
  if (!fieldType?.isSearchable) return false;
28
- if (field.settings?.disableFullTextSearch === true) return false;
28
+ else if (field.settings?.disableFullTextSearch === true) return false;
29
29
  return true;
30
30
  }
31
31
  }
@@ -1 +1 @@
1
- {"version":3,"file":"features/CmsEntryOpenSearchFieldIndex/fields/TextCompressedFieldIndex.js","sources":["../../../../src/features/CmsEntryOpenSearchFieldIndex/fields/TextCompressedFieldIndex.ts"],"sourcesContent":["import { CmsEntryOpenSearchFieldIndex } from \"../abstractions/CmsEntryOpenSearchFieldIndex.js\";\nimport type { CmsModelField } from \"@webiny/api-headless-cms/types/index.js\";\nimport { CmsModelFieldToGraphQLRegistry } from \"@webiny/api-headless-cms/exports/api/cms/graphql.js\";\nimport { TextFieldTypes } from \"@webiny/api-headless-cms/features/modelBuilder/index.js\";\n\nclass TextCompressedFieldIndexImpl implements CmsEntryOpenSearchFieldIndex.Interface {\n public readonly fieldType = TextFieldTypes.COMPRESSED;\n\n public constructor(private readonly fieldRegistry: CmsModelFieldToGraphQLRegistry.Interface) {}\n\n public toIndex(\n params: CmsEntryOpenSearchFieldIndex.ToIndex\n ): CmsEntryOpenSearchFieldIndex.ToValue {\n const { field, value } = params;\n const isSearchable = this.isSearchable(field);\n\n if (isSearchable) {\n return { value };\n }\n\n return {\n rawValue: value\n };\n }\n\n public fromIndex(params: CmsEntryOpenSearchFieldIndex.FromIndex): any {\n const { field, value, rawValue } = params;\n const isSearchable = this.isSearchable(field);\n\n if (isSearchable) {\n return value === undefined ? rawValue : value;\n }\n return rawValue === undefined ? value : rawValue;\n }\n\n private isSearchable(field: CmsModelField): boolean {\n const fieldType = this.fieldRegistry.get(field.type);\n if (!fieldType?.isSearchable) {\n return false;\n } else if (field.settings?.disableFullTextSearch === true) {\n return false;\n }\n return true;\n }\n}\n\nexport const TextCompressedFieldIndex = CmsEntryOpenSearchFieldIndex.createImplementation({\n implementation: TextCompressedFieldIndexImpl,\n dependencies: [CmsModelFieldToGraphQLRegistry]\n});\n"],"names":["TextCompressedFieldIndexImpl","fieldRegistry","TextFieldTypes","params","field","value","isSearchable","rawValue","undefined","fieldType","TextCompressedFieldIndex","CmsEntryOpenSearchFieldIndex","CmsModelFieldToGraphQLRegistry"],"mappings":";;;AAKA,MAAMA;IAGF,YAAoCC,aAAuD,CAAE;aAAzDA,aAAa,GAAbA;aAFpB,SAAS,GAAGC,eAAe,UAAU;IAEyC;IAEvF,QACHC,MAA4C,EACR;QACpC,MAAM,EAAEC,KAAK,EAAEC,KAAK,EAAE,GAAGF;QACzB,MAAMG,eAAe,IAAI,CAAC,YAAY,CAACF;QAEvC,IAAIE,cACA,OAAO;YAAED;QAAM;QAGnB,OAAO;YACH,UAAUA;QACd;IACJ;IAEO,UAAUF,MAA8C,EAAO;QAClE,MAAM,EAAEC,KAAK,EAAEC,KAAK,EAAEE,QAAQ,EAAE,GAAGJ;QACnC,MAAMG,eAAe,IAAI,CAAC,YAAY,CAACF;QAEvC,IAAIE,cACA,OAAOD,AAAUG,WAAVH,QAAsBE,WAAWF;QAE5C,OAAOE,AAAaC,WAAbD,WAAyBF,QAAQE;IAC5C;IAEQ,aAAaH,KAAoB,EAAW;QAChD,MAAMK,YAAY,IAAI,CAAC,aAAa,CAAC,GAAG,CAACL,MAAM,IAAI;QACnD,IAAI,CAACK,WAAW,cACZ,OAAO;QACJ,IAAIL,MAAM,QAAQ,EAAE,0BAA0B,MACjD,OAAO;QAEX,OAAO;IACX;AACJ;AAEO,MAAMM,2BAA2BC,6BAA6B,oBAAoB,CAAC;IACtF,gBAAgBX;IAChB,cAAc;QAACY;KAA+B;AAClD"}
1
+ {"version":3,"file":"features/CmsEntryOpenSearchFieldIndex/fields/TextCompressedFieldIndex.js","sources":["../../../../src/features/CmsEntryOpenSearchFieldIndex/fields/TextCompressedFieldIndex.ts"],"sourcesContent":["import { CmsEntryOpenSearchFieldIndex } from \"../abstractions/CmsEntryOpenSearchFieldIndex.js\";\nimport type { CmsModelField } from \"@webiny/api-headless-cms/types/index.js\";\nimport { CmsModelFieldToGraphQLRegistry } from \"@webiny/api-headless-cms/exports/api/cms/graphql.js\";\nimport { TextFieldTypes } from \"@webiny/api-headless-cms/features/modelBuilder/index.js\";\n\nclass TextCompressedFieldIndexImpl implements CmsEntryOpenSearchFieldIndex.Interface {\n public readonly fieldType = TextFieldTypes.COMPRESSED;\n\n public constructor(private readonly fieldRegistry: CmsModelFieldToGraphQLRegistry.Interface) {}\n\n public toIndex(\n params: CmsEntryOpenSearchFieldIndex.ToIndex\n ): CmsEntryOpenSearchFieldIndex.ToValue {\n const { field, value } = params;\n const isSearchable = this.isSearchable(field);\n\n if (isSearchable) {\n return { value };\n }\n\n return {\n rawValue: value\n };\n }\n\n public fromIndex(params: CmsEntryOpenSearchFieldIndex.FromIndex): any {\n const { field, value, rawValue } = params;\n const isSearchable = this.isSearchable(field);\n\n if (isSearchable) {\n return value === undefined ? rawValue : value;\n }\n return rawValue === undefined ? value : rawValue;\n }\n\n private isSearchable(field: CmsModelField): boolean {\n const fieldType = this.fieldRegistry.get(field.type);\n if (!fieldType?.isSearchable) {\n return false;\n } else if (field.settings?.disableFullTextSearch === true) {\n return false;\n }\n return true;\n }\n}\n\nexport const TextCompressedFieldIndex = CmsEntryOpenSearchFieldIndex.createImplementation({\n implementation: TextCompressedFieldIndexImpl,\n dependencies: [CmsModelFieldToGraphQLRegistry]\n});\n"],"names":["TextCompressedFieldIndexImpl","fieldRegistry","TextFieldTypes","params","field","value","isSearchable","rawValue","undefined","fieldType","TextCompressedFieldIndex","CmsEntryOpenSearchFieldIndex","CmsModelFieldToGraphQLRegistry"],"mappings":";;;AAKA,MAAMA;IAGF,YAAoCC,aAAuD,CAAE;aAAzDA,aAAa,GAAbA;aAFpB,SAAS,GAAGC,eAAe,UAAU;IAEyC;IAEvF,QACHC,MAA4C,EACR;QACpC,MAAM,EAAEC,KAAK,EAAEC,KAAK,EAAE,GAAGF;QACzB,MAAMG,eAAe,IAAI,CAAC,YAAY,CAACF;QAEvC,IAAIE,cACA,OAAO;YAAED;QAAM;QAGnB,OAAO;YACH,UAAUA;QACd;IACJ;IAEO,UAAUF,MAA8C,EAAO;QAClE,MAAM,EAAEC,KAAK,EAAEC,KAAK,EAAEE,QAAQ,EAAE,GAAGJ;QACnC,MAAMG,eAAe,IAAI,CAAC,YAAY,CAACF;QAEvC,IAAIE,cACA,OAAOD,AAAUG,WAAVH,QAAsBE,WAAWF;QAE5C,OAAOE,AAAaC,WAAbD,WAAyBF,QAAQE;IAC5C;IAEQ,aAAaH,KAAoB,EAAW;QAChD,MAAMK,YAAY,IAAI,CAAC,aAAa,CAAC,GAAG,CAACL,MAAM,IAAI;QACnD,IAAI,CAACK,WAAW,cACZ,OAAO;aACJ,IAAIL,MAAM,QAAQ,EAAE,0BAA0B,MACjD,OAAO;QAEX,OAAO;IACX;AACJ;AAEO,MAAMM,2BAA2BC,6BAA6B,oBAAoB,CAAC;IACtF,gBAAgBX;IAChB,cAAc;QAACY;KAA+B;AAClD"}
@@ -25,7 +25,7 @@ class TextEncryptedFieldIndexImpl {
25
25
  isSearchable(field) {
26
26
  const fieldType = this.fieldRegistry.get(field.type);
27
27
  if (!fieldType?.isSearchable) return false;
28
- if (field.settings?.disableFullTextSearch === true) return false;
28
+ else if (field.settings?.disableFullTextSearch === true) return false;
29
29
  return true;
30
30
  }
31
31
  }
@@ -1 +1 @@
1
- {"version":3,"file":"features/CmsEntryOpenSearchFieldIndex/fields/TextEncryptedFieldIndex.js","sources":["../../../../src/features/CmsEntryOpenSearchFieldIndex/fields/TextEncryptedFieldIndex.ts"],"sourcesContent":["import { CmsEntryOpenSearchFieldIndex } from \"../abstractions/CmsEntryOpenSearchFieldIndex.js\";\nimport type { CmsModelField } from \"@webiny/api-headless-cms/types/index.js\";\nimport { CmsModelFieldToGraphQLRegistry } from \"@webiny/api-headless-cms/exports/api/cms/graphql.js\";\nimport { TextFieldTypes } from \"@webiny/api-headless-cms/features/modelBuilder/index.js\";\n\nclass TextEncryptedFieldIndexImpl implements CmsEntryOpenSearchFieldIndex.Interface {\n public readonly fieldType = TextFieldTypes.ENCRYPTED;\n\n public constructor(private readonly fieldRegistry: CmsModelFieldToGraphQLRegistry.Interface) {}\n\n public toIndex(\n params: CmsEntryOpenSearchFieldIndex.ToIndex\n ): CmsEntryOpenSearchFieldIndex.ToValue {\n const { field, value } = params;\n const isSearchable = this.isSearchable(field);\n\n if (isSearchable) {\n return { value };\n }\n\n return {\n rawValue: value\n };\n }\n\n public fromIndex(params: CmsEntryOpenSearchFieldIndex.FromIndex): any {\n const { field, value, rawValue } = params;\n const isSearchable = this.isSearchable(field);\n\n if (isSearchable) {\n return value === undefined ? rawValue : value;\n }\n return rawValue === undefined ? value : rawValue;\n }\n\n private isSearchable(field: CmsModelField): boolean {\n const fieldType = this.fieldRegistry.get(field.type);\n if (!fieldType?.isSearchable) {\n return false;\n } else if (field.settings?.disableFullTextSearch === true) {\n return false;\n }\n return true;\n }\n}\n\nexport const TextEncryptedFieldIndex = CmsEntryOpenSearchFieldIndex.createImplementation({\n implementation: TextEncryptedFieldIndexImpl,\n dependencies: [CmsModelFieldToGraphQLRegistry]\n});\n"],"names":["TextEncryptedFieldIndexImpl","fieldRegistry","TextFieldTypes","params","field","value","isSearchable","rawValue","undefined","fieldType","TextEncryptedFieldIndex","CmsEntryOpenSearchFieldIndex","CmsModelFieldToGraphQLRegistry"],"mappings":";;;AAKA,MAAMA;IAGF,YAAoCC,aAAuD,CAAE;aAAzDA,aAAa,GAAbA;aAFpB,SAAS,GAAGC,eAAe,SAAS;IAE0C;IAEvF,QACHC,MAA4C,EACR;QACpC,MAAM,EAAEC,KAAK,EAAEC,KAAK,EAAE,GAAGF;QACzB,MAAMG,eAAe,IAAI,CAAC,YAAY,CAACF;QAEvC,IAAIE,cACA,OAAO;YAAED;QAAM;QAGnB,OAAO;YACH,UAAUA;QACd;IACJ;IAEO,UAAUF,MAA8C,EAAO;QAClE,MAAM,EAAEC,KAAK,EAAEC,KAAK,EAAEE,QAAQ,EAAE,GAAGJ;QACnC,MAAMG,eAAe,IAAI,CAAC,YAAY,CAACF;QAEvC,IAAIE,cACA,OAAOD,AAAUG,WAAVH,QAAsBE,WAAWF;QAE5C,OAAOE,AAAaC,WAAbD,WAAyBF,QAAQE;IAC5C;IAEQ,aAAaH,KAAoB,EAAW;QAChD,MAAMK,YAAY,IAAI,CAAC,aAAa,CAAC,GAAG,CAACL,MAAM,IAAI;QACnD,IAAI,CAACK,WAAW,cACZ,OAAO;QACJ,IAAIL,MAAM,QAAQ,EAAE,0BAA0B,MACjD,OAAO;QAEX,OAAO;IACX;AACJ;AAEO,MAAMM,0BAA0BC,6BAA6B,oBAAoB,CAAC;IACrF,gBAAgBX;IAChB,cAAc;QAACY;KAA+B;AAClD"}
1
+ {"version":3,"file":"features/CmsEntryOpenSearchFieldIndex/fields/TextEncryptedFieldIndex.js","sources":["../../../../src/features/CmsEntryOpenSearchFieldIndex/fields/TextEncryptedFieldIndex.ts"],"sourcesContent":["import { CmsEntryOpenSearchFieldIndex } from \"../abstractions/CmsEntryOpenSearchFieldIndex.js\";\nimport type { CmsModelField } from \"@webiny/api-headless-cms/types/index.js\";\nimport { CmsModelFieldToGraphQLRegistry } from \"@webiny/api-headless-cms/exports/api/cms/graphql.js\";\nimport { TextFieldTypes } from \"@webiny/api-headless-cms/features/modelBuilder/index.js\";\n\nclass TextEncryptedFieldIndexImpl implements CmsEntryOpenSearchFieldIndex.Interface {\n public readonly fieldType = TextFieldTypes.ENCRYPTED;\n\n public constructor(private readonly fieldRegistry: CmsModelFieldToGraphQLRegistry.Interface) {}\n\n public toIndex(\n params: CmsEntryOpenSearchFieldIndex.ToIndex\n ): CmsEntryOpenSearchFieldIndex.ToValue {\n const { field, value } = params;\n const isSearchable = this.isSearchable(field);\n\n if (isSearchable) {\n return { value };\n }\n\n return {\n rawValue: value\n };\n }\n\n public fromIndex(params: CmsEntryOpenSearchFieldIndex.FromIndex): any {\n const { field, value, rawValue } = params;\n const isSearchable = this.isSearchable(field);\n\n if (isSearchable) {\n return value === undefined ? rawValue : value;\n }\n return rawValue === undefined ? value : rawValue;\n }\n\n private isSearchable(field: CmsModelField): boolean {\n const fieldType = this.fieldRegistry.get(field.type);\n if (!fieldType?.isSearchable) {\n return false;\n } else if (field.settings?.disableFullTextSearch === true) {\n return false;\n }\n return true;\n }\n}\n\nexport const TextEncryptedFieldIndex = CmsEntryOpenSearchFieldIndex.createImplementation({\n implementation: TextEncryptedFieldIndexImpl,\n dependencies: [CmsModelFieldToGraphQLRegistry]\n});\n"],"names":["TextEncryptedFieldIndexImpl","fieldRegistry","TextFieldTypes","params","field","value","isSearchable","rawValue","undefined","fieldType","TextEncryptedFieldIndex","CmsEntryOpenSearchFieldIndex","CmsModelFieldToGraphQLRegistry"],"mappings":";;;AAKA,MAAMA;IAGF,YAAoCC,aAAuD,CAAE;aAAzDA,aAAa,GAAbA;aAFpB,SAAS,GAAGC,eAAe,SAAS;IAE0C;IAEvF,QACHC,MAA4C,EACR;QACpC,MAAM,EAAEC,KAAK,EAAEC,KAAK,EAAE,GAAGF;QACzB,MAAMG,eAAe,IAAI,CAAC,YAAY,CAACF;QAEvC,IAAIE,cACA,OAAO;YAAED;QAAM;QAGnB,OAAO;YACH,UAAUA;QACd;IACJ;IAEO,UAAUF,MAA8C,EAAO;QAClE,MAAM,EAAEC,KAAK,EAAEC,KAAK,EAAEE,QAAQ,EAAE,GAAGJ;QACnC,MAAMG,eAAe,IAAI,CAAC,YAAY,CAACF;QAEvC,IAAIE,cACA,OAAOD,AAAUG,WAAVH,QAAsBE,WAAWF;QAE5C,OAAOE,AAAaC,WAAbD,WAAyBF,QAAQE;IAC5C;IAEQ,aAAaH,KAAoB,EAAW;QAChD,MAAMK,YAAY,IAAI,CAAC,aAAa,CAAC,GAAG,CAACL,MAAM,IAAI;QACnD,IAAI,CAACK,WAAW,cACZ,OAAO;aACJ,IAAIL,MAAM,QAAQ,EAAE,0BAA0B,MACjD,OAAO;QAEX,OAAO;IACX;AACJ;AAEO,MAAMM,0BAA0BC,6BAA6B,oBAAoB,CAAC;IACrF,gBAAgBX;IAChB,cAAc;QAACY;KAA+B;AAClD"}
@@ -8,7 +8,7 @@ const getKey = (params)=>{
8
8
  field,
9
9
  value
10
10
  });
11
- if (keys.length > 1) throw new WebinyError(`Searchable JSON field "${field.fieldId}" can only have one key.`, "MULTIPLE_KEYS_IN_SEARCHABLE_JSON_FIELD", {
11
+ else if (keys.length > 1) throw new WebinyError(`Searchable JSON field "${field.fieldId}" can only have one key.`, "MULTIPLE_KEYS_IN_SEARCHABLE_JSON_FIELD", {
12
12
  field,
13
13
  value,
14
14
  keys
@@ -1 +1 @@
1
- {"version":3,"file":"features/CmsEntryOpenSearchValueSearch/fields/SearchableJsonSearch.js","sources":["../../../../src/features/CmsEntryOpenSearchValueSearch/fields/SearchableJsonSearch.ts"],"sourcesContent":["import { CmsModelField } from \"@webiny/api-headless-cms/types/index.js\";\nimport { CmsEntryOpenSearchValueSearch } from \"../abstractions/CmsEntryOpenSearchValueSearch.js\";\nimport { WebinyError } from \"@webiny/error\";\nimport { NoValueContainer } from \"~/values/NoValueContainer.js\";\n\ninterface IGetKeyParams {\n field: CmsModelField;\n value: {\n [key: string]: any;\n };\n}\n\nconst getKey = (params: IGetKeyParams): string => {\n const { field, value } = params;\n const keys = Object.keys(value);\n if (keys.length === 0) {\n throw new WebinyError(\n `Searchable JSON field \"${field.fieldId}\" cannot be empty.`,\n \"EMPTY_SEARCHABLE_JSON_FIELD\",\n {\n field,\n value\n }\n );\n } else if (keys.length > 1) {\n throw new WebinyError(\n `Searchable JSON field \"${field.fieldId}\" can only have one key.`,\n \"MULTIPLE_KEYS_IN_SEARCHABLE_JSON_FIELD\",\n {\n field,\n value,\n keys\n }\n );\n }\n return keys[0];\n};\n\nclass SearchableJsonSearchImpl implements CmsEntryOpenSearchValueSearch.Interface {\n public readonly fieldType = \"searchable-json\";\n\n public transform(params: CmsEntryOpenSearchValueSearch.Transform): any {\n const { value } = params;\n\n if (NoValueContainer.is(value)) {\n return null;\n }\n\n const key = getKey(params);\n return value[key] || null;\n }\n\n public createPath(params: CmsEntryOpenSearchValueSearch.CreatePath): string | null {\n const { field } = params;\n\n if (NoValueContainer.is(params.originalValue)) {\n return `${field.storageId}.unknown`;\n }\n\n const key = getKey({\n field,\n value: params.originalValue\n });\n\n return `${field.storageId}.${key}`;\n }\n}\n\nexport const SearchableJsonSearch = CmsEntryOpenSearchValueSearch.createImplementation({\n implementation: SearchableJsonSearchImpl,\n dependencies: []\n});\n"],"names":["getKey","params","field","value","keys","Object","WebinyError","SearchableJsonSearchImpl","NoValueContainer","key","SearchableJsonSearch","CmsEntryOpenSearchValueSearch"],"mappings":";;;AAYA,MAAMA,SAAS,CAACC;IACZ,MAAM,EAAEC,KAAK,EAAEC,KAAK,EAAE,GAAGF;IACzB,MAAMG,OAAOC,OAAO,IAAI,CAACF;IACzB,IAAIC,AAAgB,MAAhBA,KAAK,MAAM,EACX,MAAM,IAAIE,YACN,CAAC,uBAAuB,EAAEJ,MAAM,OAAO,CAAC,kBAAkB,CAAC,EAC3D,+BACA;QACIA;QACAC;IACJ;IAED,IAAIC,KAAK,MAAM,GAAG,GACrB,MAAM,IAAIE,YACN,CAAC,uBAAuB,EAAEJ,MAAM,OAAO,CAAC,wBAAwB,CAAC,EACjE,0CACA;QACIA;QACAC;QACAC;IACJ;IAGR,OAAOA,IAAI,CAAC,EAAE;AAClB;AAEA,MAAMG;IAGK,UAAUN,MAA+C,EAAO;QACnE,MAAM,EAAEE,KAAK,EAAE,GAAGF;QAElB,IAAIO,iBAAiB,EAAE,CAACL,QACpB,OAAO;QAGX,MAAMM,MAAMT,OAAOC;QACnB,OAAOE,KAAK,CAACM,IAAI,IAAI;IACzB;IAEO,WAAWR,MAAgD,EAAiB;QAC/E,MAAM,EAAEC,KAAK,EAAE,GAAGD;QAElB,IAAIO,iBAAiB,EAAE,CAACP,OAAO,aAAa,GACxC,OAAO,GAAGC,MAAM,SAAS,CAAC,QAAQ,CAAC;QAGvC,MAAMO,MAAMT,OAAO;YACfE;YACA,OAAOD,OAAO,aAAa;QAC/B;QAEA,OAAO,GAAGC,MAAM,SAAS,CAAC,CAAC,EAAEO,KAAK;IACtC;;aA1BgB,SAAS,GAAG;;AA2BhC;AAEO,MAAMC,uBAAuBC,8BAA8B,oBAAoB,CAAC;IACnF,gBAAgBJ;IAChB,cAAc,EAAE;AACpB"}
1
+ {"version":3,"file":"features/CmsEntryOpenSearchValueSearch/fields/SearchableJsonSearch.js","sources":["../../../../src/features/CmsEntryOpenSearchValueSearch/fields/SearchableJsonSearch.ts"],"sourcesContent":["import { CmsModelField } from \"@webiny/api-headless-cms/types/index.js\";\nimport { CmsEntryOpenSearchValueSearch } from \"../abstractions/CmsEntryOpenSearchValueSearch.js\";\nimport { WebinyError } from \"@webiny/error\";\nimport { NoValueContainer } from \"~/values/NoValueContainer.js\";\n\ninterface IGetKeyParams {\n field: CmsModelField;\n value: {\n [key: string]: any;\n };\n}\n\nconst getKey = (params: IGetKeyParams): string => {\n const { field, value } = params;\n const keys = Object.keys(value);\n if (keys.length === 0) {\n throw new WebinyError(\n `Searchable JSON field \"${field.fieldId}\" cannot be empty.`,\n \"EMPTY_SEARCHABLE_JSON_FIELD\",\n {\n field,\n value\n }\n );\n } else if (keys.length > 1) {\n throw new WebinyError(\n `Searchable JSON field \"${field.fieldId}\" can only have one key.`,\n \"MULTIPLE_KEYS_IN_SEARCHABLE_JSON_FIELD\",\n {\n field,\n value,\n keys\n }\n );\n }\n return keys[0];\n};\n\nclass SearchableJsonSearchImpl implements CmsEntryOpenSearchValueSearch.Interface {\n public readonly fieldType = \"searchable-json\";\n\n public transform(params: CmsEntryOpenSearchValueSearch.Transform): any {\n const { value } = params;\n\n if (NoValueContainer.is(value)) {\n return null;\n }\n\n const key = getKey(params);\n return value[key] || null;\n }\n\n public createPath(params: CmsEntryOpenSearchValueSearch.CreatePath): string | null {\n const { field } = params;\n\n if (NoValueContainer.is(params.originalValue)) {\n return `${field.storageId}.unknown`;\n }\n\n const key = getKey({\n field,\n value: params.originalValue\n });\n\n return `${field.storageId}.${key}`;\n }\n}\n\nexport const SearchableJsonSearch = CmsEntryOpenSearchValueSearch.createImplementation({\n implementation: SearchableJsonSearchImpl,\n dependencies: []\n});\n"],"names":["getKey","params","field","value","keys","Object","WebinyError","SearchableJsonSearchImpl","NoValueContainer","key","SearchableJsonSearch","CmsEntryOpenSearchValueSearch"],"mappings":";;;AAYA,MAAMA,SAAS,CAACC;IACZ,MAAM,EAAEC,KAAK,EAAEC,KAAK,EAAE,GAAGF;IACzB,MAAMG,OAAOC,OAAO,IAAI,CAACF;IACzB,IAAIC,AAAgB,MAAhBA,KAAK,MAAM,EACX,MAAM,IAAIE,YACN,CAAC,uBAAuB,EAAEJ,MAAM,OAAO,CAAC,kBAAkB,CAAC,EAC3D,+BACA;QACIA;QACAC;IACJ;SAED,IAAIC,KAAK,MAAM,GAAG,GACrB,MAAM,IAAIE,YACN,CAAC,uBAAuB,EAAEJ,MAAM,OAAO,CAAC,wBAAwB,CAAC,EACjE,0CACA;QACIA;QACAC;QACAC;IACJ;IAGR,OAAOA,IAAI,CAAC,EAAE;AAClB;AAEA,MAAMG;IAGK,UAAUN,MAA+C,EAAO;QACnE,MAAM,EAAEE,KAAK,EAAE,GAAGF;QAElB,IAAIO,iBAAiB,EAAE,CAACL,QACpB,OAAO;QAGX,MAAMM,MAAMT,OAAOC;QACnB,OAAOE,KAAK,CAACM,IAAI,IAAI;IACzB;IAEO,WAAWR,MAAgD,EAAiB;QAC/E,MAAM,EAAEC,KAAK,EAAE,GAAGD;QAElB,IAAIO,iBAAiB,EAAE,CAACP,OAAO,aAAa,GACxC,OAAO,GAAGC,MAAM,SAAS,CAAC,QAAQ,CAAC;QAGvC,MAAMO,MAAMT,OAAO;YACfE;YACA,OAAOD,OAAO,aAAa;QAC/B;QAEA,OAAO,GAAGC,MAAM,SAAS,CAAC,CAAC,EAAEO,KAAK;IACtC;;aA1BgB,SAAS,GAAG;;AA2BhC;AAEO,MAAMC,uBAAuBC,8BAA8B,oBAAoB,CAAC;IACnF,gBAAgBJ;IAChB,cAAc,EAAE;AACpB"}
@@ -1,11 +1,11 @@
1
1
  const fieldIdentifier_hasOwnProperty = (values = {}, property)=>{
2
2
  if (!values) return false;
3
- if (values.hasOwnProperty) return values.hasOwnProperty(property);
3
+ else if (values.hasOwnProperty) return values.hasOwnProperty(property);
4
4
  return void 0 !== values[property];
5
5
  };
6
6
  const getFieldIdentifier = (values, field)=>{
7
7
  if (field.storageId && fieldIdentifier_hasOwnProperty(values, field.storageId)) return field.storageId;
8
- if (fieldIdentifier_hasOwnProperty(values, field.fieldId)) return field.fieldId;
8
+ else if (fieldIdentifier_hasOwnProperty(values, field.fieldId)) return field.fieldId;
9
9
  };
10
10
  const getFieldIdentifiers = (values, rawValues, field)=>{
11
11
  let valueIdentifier = getFieldIdentifier(values, field);
@@ -1 +1 @@
1
- {"version":3,"file":"helpers/fieldIdentifier.js","sources":["../../src/helpers/fieldIdentifier.ts"],"sourcesContent":["import type { CmsEntryValues, CmsModelField } from \"@webiny/api-headless-cms/types/index.js\";\n\nconst hasOwnProperty = (\n values: CmsEntryValues | null | undefined = {},\n property: string\n): boolean => {\n if (!values) {\n return false;\n } else if (values.hasOwnProperty) {\n return values.hasOwnProperty(property);\n }\n return values[property] !== undefined;\n};\n\nexport const getFieldIdentifier = (\n values: CmsEntryValues | null | undefined,\n field: CmsModelField\n): string | undefined => {\n if (field.storageId && hasOwnProperty(values, field.storageId)) {\n return field.storageId;\n } else if (hasOwnProperty(values, field.fieldId)) {\n return field.fieldId;\n }\n return undefined;\n};\n\nexport const getFieldIdentifiers = (\n values: CmsEntryValues,\n rawValues: CmsEntryValues | null | undefined,\n field: CmsModelField\n) => {\n let valueIdentifier = getFieldIdentifier(values, field);\n let rawValueIdentifier = getFieldIdentifier(rawValues, field);\n if (!valueIdentifier && !rawValueIdentifier) {\n return null;\n }\n if (!valueIdentifier) {\n valueIdentifier = rawValueIdentifier as string;\n }\n if (!rawValueIdentifier) {\n rawValueIdentifier = valueIdentifier as string;\n }\n return {\n valueIdentifier,\n rawValueIdentifier\n };\n};\n"],"names":["hasOwnProperty","values","property","undefined","getFieldIdentifier","field","getFieldIdentifiers","rawValues","valueIdentifier","rawValueIdentifier"],"mappings":"AAEA,MAAMA,iCAAiB,CACnBC,SAA4C,CAAC,CAAC,EAC9CC;IAEA,IAAI,CAACD,QACD,OAAO;IACJ,IAAIA,OAAO,cAAc,EAC5B,OAAOA,OAAO,cAAc,CAACC;IAEjC,OAAOD,AAAqBE,WAArBF,MAAM,CAACC,SAAS;AAC3B;AAEO,MAAME,qBAAqB,CAC9BH,QACAI;IAEA,IAAIA,MAAM,SAAS,IAAIL,+BAAeC,QAAQI,MAAM,SAAS,GACzD,OAAOA,MAAM,SAAS;IACnB,IAAIL,+BAAeC,QAAQI,MAAM,OAAO,GAC3C,OAAOA,MAAM,OAAO;AAG5B;AAEO,MAAMC,sBAAsB,CAC/BL,QACAM,WACAF;IAEA,IAAIG,kBAAkBJ,mBAAmBH,QAAQI;IACjD,IAAII,qBAAqBL,mBAAmBG,WAAWF;IACvD,IAAI,CAACG,mBAAmB,CAACC,oBACrB,OAAO;IAEX,IAAI,CAACD,iBACDA,kBAAkBC;IAEtB,IAAI,CAACA,oBACDA,qBAAqBD;IAEzB,OAAO;QACHA;QACAC;IACJ;AACJ"}
1
+ {"version":3,"file":"helpers/fieldIdentifier.js","sources":["../../src/helpers/fieldIdentifier.ts"],"sourcesContent":["import type { CmsEntryValues, CmsModelField } from \"@webiny/api-headless-cms/types/index.js\";\n\nconst hasOwnProperty = (\n values: CmsEntryValues | null | undefined = {},\n property: string\n): boolean => {\n if (!values) {\n return false;\n } else if (values.hasOwnProperty) {\n return values.hasOwnProperty(property);\n }\n return values[property] !== undefined;\n};\n\nexport const getFieldIdentifier = (\n values: CmsEntryValues | null | undefined,\n field: CmsModelField\n): string | undefined => {\n if (field.storageId && hasOwnProperty(values, field.storageId)) {\n return field.storageId;\n } else if (hasOwnProperty(values, field.fieldId)) {\n return field.fieldId;\n }\n return undefined;\n};\n\nexport const getFieldIdentifiers = (\n values: CmsEntryValues,\n rawValues: CmsEntryValues | null | undefined,\n field: CmsModelField\n) => {\n let valueIdentifier = getFieldIdentifier(values, field);\n let rawValueIdentifier = getFieldIdentifier(rawValues, field);\n if (!valueIdentifier && !rawValueIdentifier) {\n return null;\n }\n if (!valueIdentifier) {\n valueIdentifier = rawValueIdentifier as string;\n }\n if (!rawValueIdentifier) {\n rawValueIdentifier = valueIdentifier as string;\n }\n return {\n valueIdentifier,\n rawValueIdentifier\n };\n};\n"],"names":["hasOwnProperty","values","property","undefined","getFieldIdentifier","field","getFieldIdentifiers","rawValues","valueIdentifier","rawValueIdentifier"],"mappings":"AAEA,MAAMA,iCAAiB,CACnBC,SAA4C,CAAC,CAAC,EAC9CC;IAEA,IAAI,CAACD,QACD,OAAO;SACJ,IAAIA,OAAO,cAAc,EAC5B,OAAOA,OAAO,cAAc,CAACC;IAEjC,OAAOD,AAAqBE,WAArBF,MAAM,CAACC,SAAS;AAC3B;AAEO,MAAME,qBAAqB,CAC9BH,QACAI;IAEA,IAAIA,MAAM,SAAS,IAAIL,+BAAeC,QAAQI,MAAM,SAAS,GACzD,OAAOA,MAAM,SAAS;SACnB,IAAIL,+BAAeC,QAAQI,MAAM,OAAO,GAC3C,OAAOA,MAAM,OAAO;AAG5B;AAEO,MAAMC,sBAAsB,CAC/BL,QACAM,WACAF;IAEA,IAAIG,kBAAkBJ,mBAAmBH,QAAQI;IACjD,IAAII,qBAAqBL,mBAAmBG,WAAWF;IACvD,IAAI,CAACG,mBAAmB,CAACC,oBACrB,OAAO;IAEX,IAAI,CAACD,iBACDA,kBAAkBC;IAEtB,IAAI,CAACA,oBACDA,qBAAqBD;IAEzB,OAAO;QACHA;QACAC;IACJ;AACJ"}
@@ -1,7 +1,7 @@
1
1
  const assignMinimumShouldMatchToQuery = ({ query, value = 1 })=>{
2
2
  if (!Array.isArray(query.should)) return;
3
- if (0 === query.should.length) return;
4
- if (query.minimum_should_match) return;
3
+ else if (0 === query.should.length) return;
4
+ else if (query.minimum_should_match) return;
5
5
  query.minimum_should_match = value > 0 ? value : 1;
6
6
  };
7
7
  export { assignMinimumShouldMatchToQuery };
@@ -1 +1 @@
1
- {"version":3,"file":"operations/entry/elasticsearch/assignMinimumShouldMatchToQuery.js","sources":["../../../../src/operations/entry/elasticsearch/assignMinimumShouldMatchToQuery.ts"],"sourcesContent":["import type { QueryDslBoolQuery as BoolQueryConfig } from \"@webiny/api-opensearch/types.js\";\n\n/**\n * This function will assign a minimum_should_match for the query if conditions are met:\n * * should is an array\n * * it is not empty\n * * minimum_should_match is not already set\n *\n *\n * By the default we set it to 1 as we want at least one OR condition to produce results.\n *\n * Users can modify minimum_should_match value via the body or query modification plugins.\n */\ninterface Params {\n query: BoolQueryConfig;\n value?: number;\n}\nexport const assignMinimumShouldMatchToQuery = ({ query, value = 1 }: Params): void => {\n if (!Array.isArray(query.should)) {\n return;\n } else if (query.should.length === 0) {\n return;\n } else if (query.minimum_should_match) {\n return;\n }\n query.minimum_should_match = value > 0 ? value : 1;\n};\n"],"names":["assignMinimumShouldMatchToQuery","query","value","Array"],"mappings":"AAiBO,MAAMA,kCAAkC,CAAC,EAAEC,KAAK,EAAEC,QAAQ,CAAC,EAAU;IACxE,IAAI,CAACC,MAAM,OAAO,CAACF,MAAM,MAAM,GAC3B;IACG,IAAIA,AAAwB,MAAxBA,MAAM,MAAM,CAAC,MAAM,EAC1B;IACG,IAAIA,MAAM,oBAAoB,EACjC;IAEJA,MAAM,oBAAoB,GAAGC,QAAQ,IAAIA,QAAQ;AACrD"}
1
+ {"version":3,"file":"operations/entry/elasticsearch/assignMinimumShouldMatchToQuery.js","sources":["../../../../src/operations/entry/elasticsearch/assignMinimumShouldMatchToQuery.ts"],"sourcesContent":["import type { QueryDslBoolQuery as BoolQueryConfig } from \"@webiny/api-opensearch/types.js\";\n\n/**\n * This function will assign a minimum_should_match for the query if conditions are met:\n * * should is an array\n * * it is not empty\n * * minimum_should_match is not already set\n *\n *\n * By the default we set it to 1 as we want at least one OR condition to produce results.\n *\n * Users can modify minimum_should_match value via the body or query modification plugins.\n */\ninterface Params {\n query: BoolQueryConfig;\n value?: number;\n}\nexport const assignMinimumShouldMatchToQuery = ({ query, value = 1 }: Params): void => {\n if (!Array.isArray(query.should)) {\n return;\n } else if (query.should.length === 0) {\n return;\n } else if (query.minimum_should_match) {\n return;\n }\n query.minimum_should_match = value > 0 ? value : 1;\n};\n"],"names":["assignMinimumShouldMatchToQuery","query","value","Array"],"mappings":"AAiBO,MAAMA,kCAAkC,CAAC,EAAEC,KAAK,EAAEC,QAAQ,CAAC,EAAU;IACxE,IAAI,CAACC,MAAM,OAAO,CAACF,MAAM,MAAM,GAC3B;SACG,IAAIA,AAAwB,MAAxBA,MAAM,MAAM,CAAC,MAAM,EAC1B;SACG,IAAIA,MAAM,oBAAoB,EACjC;IAEJA,MAAM,oBAAoB,GAAGC,QAAQ,IAAIA,QAAQ;AACrD"}
@@ -22,7 +22,7 @@ const getFullTextSearch = (params)=>{
22
22
  for (const item of reversed){
23
23
  const models = item.models || [];
24
24
  if (models.includes(model.modelId)) return item;
25
- if (!fallback && 0 === models.length) fallback = item;
25
+ else if (!fallback && 0 === models.length) fallback = item;
26
26
  }
27
27
  return fallback || defaultFullTextSearch;
28
28
  };
@@ -38,7 +38,7 @@ const applyFullTextSearch = (params)=>{
38
38
  model,
39
39
  createFieldPath: (field)=>{
40
40
  if ("function" == typeof field.path) return field.path(term);
41
- if (field.systemField) return field.path || field.field.storageId;
41
+ else if (field.systemField) return field.path || field.field.storageId;
42
42
  const parents = field.parents.length > 0 ? field.parents.map((p)=>p.storageId) : [
43
43
  "values"
44
44
  ];
@@ -1 +1 @@
1
- {"version":3,"file":"operations/entry/elasticsearch/fullTextSearch.js","sources":["../../../../src/operations/entry/elasticsearch/fullTextSearch.ts"],"sourcesContent":["import type { OpenSearchBoolQueryConfig } from \"@webiny/api-opensearch/types.js\";\nimport { normalizeValue } from \"@webiny/api-opensearch\";\nimport type { CmsModel } from \"@webiny/api-headless-cms/types/index.js\";\nimport type { CmsEntryOpenSearchFullTextSearch } from \"~/features/CmsEntryOpenSearchFullTextSearch/index.js\";\nimport type { ModelFields } from \"~/operations/entry/elasticsearch/types.js\";\n\n/**\n * Our default implementation works with the AND operator for the multiple words query string.\n */\nconst defaultFullTextSearch: CmsEntryOpenSearchFullTextSearch.Interface = {\n apply: params => {\n const { query, term, fields, createFieldPath, prepareTerm } = params;\n\n query.must.push({\n query_string: {\n allow_leading_wildcard: true,\n /**\n * Searchable JSON fields are dynamically mapped, so their subfields can be of any type (date, number, boolean...).\n * Wildcard queries are not allowed on those types, so we need to ignore them instead of failing the whole query.\n */\n lenient: true,\n fields: Object.values(fields).map(createFieldPath),\n query: `*${prepareTerm(term)}*`,\n default_operator: \"and\"\n }\n });\n }\n};\n\ninterface GetFullTextSearchParams {\n fullTextSearches: CmsEntryOpenSearchFullTextSearch.Interface[];\n model: CmsModel;\n}\nconst getFullTextSearch = (\n params: GetFullTextSearchParams\n): CmsEntryOpenSearchFullTextSearch.Interface => {\n const { fullTextSearches, model } = params;\n /**\n * We need to reverse the list, so we can take the last one first - possibility to override existing implementations.\n */\n const reversed = [...fullTextSearches].reverse();\n /**\n * We need to find the most specific implementation for the given model.\n * Also, we need to use the first possible implementation if the specific one is not found.\n */\n let fallback: CmsEntryOpenSearchFullTextSearch.Interface | null = null;\n for (const item of reversed) {\n const models = item.models || [];\n /**\n * We take the first available implementation for the given model.\n */\n if (models.includes(model.modelId)) {\n return item;\n } else if (!fallback && models.length === 0) {\n /**\n * Then we set the first possible implementation, which has no models defined, as the default one.\n * It is important not to set the one which has models defined as they are specifically for the targeted model.\n */\n fallback = item;\n }\n }\n\n return fallback || defaultFullTextSearch;\n};\n\ninterface Params {\n fullTextSearches: CmsEntryOpenSearchFullTextSearch.Interface[];\n model: CmsModel;\n query: OpenSearchBoolQueryConfig;\n term?: string;\n fields: ModelFields;\n}\nexport const applyFullTextSearch = (params: Params): void => {\n const { fullTextSearches, query, term, fields, model } = params;\n const keys = Object.keys(fields);\n if (!term || term.length === 0 || keys.length === 0) {\n return;\n }\n\n const fullTextSearch = getFullTextSearch({\n fullTextSearches,\n model\n });\n\n fullTextSearch.apply({\n model,\n createFieldPath: field => {\n if (typeof field.path === \"function\") {\n return field.path(term);\n } else if (field.systemField) {\n return field.path || field.field.storageId;\n }\n /**\n * Fields can live inside object fields, so we need to prepend the storage ids of all the parents.\n * Root fields have the `values` parent only.\n */\n const parents =\n field.parents.length > 0 ? field.parents.map(p => p.storageId) : [\"values\"];\n const path = [...parents, field.path || field.field.storageId].join(\".\");\n /*\n * Searchable JSON fields are indexed as objects, so the searchable values live on the\n * nested keys. Target all of them with a wildcard.\n */\n if (field.type === \"searchable-json\") {\n return `${path}.*`;\n }\n return path;\n },\n fields,\n query,\n term,\n prepareTerm: normalizeValue\n });\n};\n"],"names":["defaultFullTextSearch","params","query","term","fields","createFieldPath","prepareTerm","Object","getFullTextSearch","fullTextSearches","model","reversed","fallback","item","models","applyFullTextSearch","keys","fullTextSearch","field","parents","p","path","normalizeValue"],"mappings":";AASA,MAAMA,wBAAoE;IACtE,OAAOC,CAAAA;QACH,MAAM,EAAEC,KAAK,EAAEC,IAAI,EAAEC,MAAM,EAAEC,eAAe,EAAEC,WAAW,EAAE,GAAGL;QAE9DC,MAAM,IAAI,CAAC,IAAI,CAAC;YACZ,cAAc;gBACV,wBAAwB;gBAKxB,SAAS;gBACT,QAAQK,OAAO,MAAM,CAACH,QAAQ,GAAG,CAACC;gBAClC,OAAO,CAAC,CAAC,EAAEC,YAAYH,MAAM,CAAC,CAAC;gBAC/B,kBAAkB;YACtB;QACJ;IACJ;AACJ;AAMA,MAAMK,oBAAoB,CACtBP;IAEA,MAAM,EAAEQ,gBAAgB,EAAEC,KAAK,EAAE,GAAGT;IAIpC,MAAMU,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.js","sources":["../../../../src/operations/entry/elasticsearch/fullTextSearch.ts"],"sourcesContent":["import type { OpenSearchBoolQueryConfig } from \"@webiny/api-opensearch/types.js\";\nimport { normalizeValue } from \"@webiny/api-opensearch\";\nimport type { CmsModel } from \"@webiny/api-headless-cms/types/index.js\";\nimport type { CmsEntryOpenSearchFullTextSearch } from \"~/features/CmsEntryOpenSearchFullTextSearch/index.js\";\nimport type { ModelFields } from \"~/operations/entry/elasticsearch/types.js\";\n\n/**\n * Our default implementation works with the AND operator for the multiple words query string.\n */\nconst defaultFullTextSearch: CmsEntryOpenSearchFullTextSearch.Interface = {\n apply: params => {\n const { query, term, fields, createFieldPath, prepareTerm } = params;\n\n query.must.push({\n query_string: {\n allow_leading_wildcard: true,\n /**\n * Searchable JSON fields are dynamically mapped, so their subfields can be of any type (date, number, boolean...).\n * Wildcard queries are not allowed on those types, so we need to ignore them instead of failing the whole query.\n */\n lenient: true,\n fields: Object.values(fields).map(createFieldPath),\n query: `*${prepareTerm(term)}*`,\n default_operator: \"and\"\n }\n });\n }\n};\n\ninterface GetFullTextSearchParams {\n fullTextSearches: CmsEntryOpenSearchFullTextSearch.Interface[];\n model: CmsModel;\n}\nconst getFullTextSearch = (\n params: GetFullTextSearchParams\n): CmsEntryOpenSearchFullTextSearch.Interface => {\n const { fullTextSearches, model } = params;\n /**\n * We need to reverse the list, so we can take the last one first - possibility to override existing implementations.\n */\n const reversed = [...fullTextSearches].reverse();\n /**\n * We need to find the most specific implementation for the given model.\n * Also, we need to use the first possible implementation if the specific one is not found.\n */\n let fallback: CmsEntryOpenSearchFullTextSearch.Interface | null = null;\n for (const item of reversed) {\n const models = item.models || [];\n /**\n * We take the first available implementation for the given model.\n */\n if (models.includes(model.modelId)) {\n return item;\n } else if (!fallback && models.length === 0) {\n /**\n * Then we set the first possible implementation, which has no models defined, as the default one.\n * It is important not to set the one which has models defined as they are specifically for the targeted model.\n */\n fallback = item;\n }\n }\n\n return fallback || defaultFullTextSearch;\n};\n\ninterface Params {\n fullTextSearches: CmsEntryOpenSearchFullTextSearch.Interface[];\n model: CmsModel;\n query: OpenSearchBoolQueryConfig;\n term?: string;\n fields: ModelFields;\n}\nexport const applyFullTextSearch = (params: Params): void => {\n const { fullTextSearches, query, term, fields, model } = params;\n const keys = Object.keys(fields);\n if (!term || term.length === 0 || keys.length === 0) {\n return;\n }\n\n const fullTextSearch = getFullTextSearch({\n fullTextSearches,\n model\n });\n\n fullTextSearch.apply({\n model,\n createFieldPath: field => {\n if (typeof field.path === \"function\") {\n return field.path(term);\n } else if (field.systemField) {\n return field.path || field.field.storageId;\n }\n /**\n * Fields can live inside object fields, so we need to prepend the storage ids of all the parents.\n * Root fields have the `values` parent only.\n */\n const parents =\n field.parents.length > 0 ? field.parents.map(p => p.storageId) : [\"values\"];\n const path = [...parents, field.path || field.field.storageId].join(\".\");\n /*\n * Searchable JSON fields are indexed as objects, so the searchable values live on the\n * nested keys. Target all of them with a wildcard.\n */\n if (field.type === \"searchable-json\") {\n return `${path}.*`;\n }\n return path;\n },\n fields,\n query,\n term,\n prepareTerm: normalizeValue\n });\n};\n"],"names":["defaultFullTextSearch","params","query","term","fields","createFieldPath","prepareTerm","Object","getFullTextSearch","fullTextSearches","model","reversed","fallback","item","models","applyFullTextSearch","keys","fullTextSearch","field","parents","p","path","normalizeValue"],"mappings":";AASA,MAAMA,wBAAoE;IACtE,OAAOC,CAAAA;QACH,MAAM,EAAEC,KAAK,EAAEC,IAAI,EAAEC,MAAM,EAAEC,eAAe,EAAEC,WAAW,EAAE,GAAGL;QAE9DC,MAAM,IAAI,CAAC,IAAI,CAAC;YACZ,cAAc;gBACV,wBAAwB;gBAKxB,SAAS;gBACT,QAAQK,OAAO,MAAM,CAACH,QAAQ,GAAG,CAACC;gBAClC,OAAO,CAAC,CAAC,EAAEC,YAAYH,MAAM,CAAC,CAAC;gBAC/B,kBAAkB;YACtB;QACJ;IACJ;AACJ;AAMA,MAAMK,oBAAoB,CACtBP;IAEA,MAAM,EAAEQ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jB;AACJ"}
@@ -22,7 +22,7 @@ describe("createInitialQuery", ()=>{
22
22
  it("filters by tenant and model when the index is shared, even if the variable says otherwise", ()=>{
23
23
  process.env.OPENSEARCH_SHARED_INDEXES = "false";
24
24
  const query = createInitialQuery({
25
- model: model,
25
+ model,
26
26
  where: {
27
27
  latest: true
28
28
  },
@@ -34,7 +34,7 @@ describe("createInitialQuery", ()=>{
34
34
  it("doesn't filter by tenant when the index isn't shared, even if the variable says it is", ()=>{
35
35
  process.env.OPENSEARCH_SHARED_INDEXES = "true";
36
36
  const query = createInitialQuery({
37
- model: model,
37
+ model,
38
38
  where: {
39
39
  latest: true
40
40
  },
@@ -1 +1 @@
1
- {"version":3,"file":"operations/entry/elasticsearch/initialQuery.test.js","sources":["../../../../src/operations/entry/elasticsearch/initialQuery.test.ts"],"sourcesContent":["import { afterEach, describe, expect, it } from \"vitest\";\nimport type { CmsModel } from \"@webiny/api-headless-cms/types/index.js\";\nimport { createInitialQuery } from \"./initialQuery.js\";\n\nconst model = { modelId: \"article\", tenant: \"acme\" } as CmsModel;\n\nconst tenantFilter = { term: { \"tenant.keyword\": \"acme\" } };\nconst modelFilter = { term: { \"modelId.keyword\": \"article\" } };\n\n/*\n * Whether entries are filtered by tenant must follow the model's index (CmsModelOpenSearchIndex),\n * not the OPENSEARCH_SHARED_INDEXES variable. A decorator can isolate or share an index per model,\n * so the two can disagree.\n */\ndescribe(\"createInitialQuery\", () => {\n const original = process.env.OPENSEARCH_SHARED_INDEXES;\n\n afterEach(() => {\n process.env.OPENSEARCH_SHARED_INDEXES = original;\n });\n\n it(\"filters by tenant and model when the index is shared, even if the variable says otherwise\", () => {\n process.env.OPENSEARCH_SHARED_INDEXES = \"false\";\n\n const query = createInitialQuery({ model, where: { latest: true }, shared: true });\n\n expect(query.filter).toContainEqual(tenantFilter);\n expect(query.filter).toContainEqual(modelFilter);\n });\n\n it(\"doesn't filter by tenant when the index isn't shared, even if the variable says it is\", () => {\n process.env.OPENSEARCH_SHARED_INDEXES = \"true\";\n\n const query = createInitialQuery({ model, where: { latest: true }, shared: false });\n\n expect(query.filter).not.toContainEqual(tenantFilter);\n expect(query.filter).not.toContainEqual(modelFilter);\n });\n});\n"],"names":["model","tenantFilter","modelFilter","describe","original","process","afterEach","it","query","createInitialQuery","expect"],"mappings":";;AAIA,MAAMA,QAAQ;IAAE,SAAS;IAAW,QAAQ;AAAO;AAEnD,MAAMC,eAAe;IAAE,MAAM;QAAE,kBAAkB;IAAO;AAAE;AAC1D,MAAMC,cAAc;IAAE,MAAM;QAAE,mBAAmB;IAAU;AAAE;AAO7DC,SAAS,sBAAsB;IAC3B,MAAMC,WAAWC,QAAQ,GAAG,CAAC,yBAAyB;IAEtDC,UAAU;QACND,QAAQ,GAAG,CAAC,yBAAyB,GAAGD;IAC5C;IAEAG,GAAG,6FAA6F;QAC5FF,QAAQ,GAAG,CAAC,yBAAyB,GAAG;QAExC,MAAMG,QAAQC,mBAAmB;YAAET,OAAAA;YAAO,OAAO;gBAAE,QAAQ;YAAK;YAAG,QAAQ;QAAK;QAEhFU,OAAOF,MAAM,MAAM,EAAE,cAAc,CAACP;QACpCS,OAAOF,MAAM,MAAM,EAAE,cAAc,CAACN;IACxC;IAEAK,GAAG,yFAAyF;QACxFF,QAAQ,GAAG,CAAC,yBAAyB,GAAG;QAExC,MAAMG,QAAQC,mBAAmB;YAAET,OAAAA;YAAO,OAAO;gBAAE,QAAQ;YAAK;YAAG,QAAQ;QAAM;QAEjFU,OAAOF,MAAM,MAAM,EAAE,GAAG,CAAC,cAAc,CAACP;QACxCS,OAAOF,MAAM,MAAM,EAAE,GAAG,CAAC,cAAc,CAACN;IAC5C;AACJ"}
1
+ {"version":3,"file":"operations/entry/elasticsearch/initialQuery.test.js","sources":["../../../../src/operations/entry/elasticsearch/initialQuery.test.ts"],"sourcesContent":["import { afterEach, describe, expect, it } from \"vitest\";\nimport type { CmsModel } from \"@webiny/api-headless-cms/types/index.js\";\nimport { createInitialQuery } from \"./initialQuery.js\";\n\nconst model = { modelId: \"article\", tenant: \"acme\" } as CmsModel;\n\nconst tenantFilter = { term: { \"tenant.keyword\": \"acme\" } };\nconst modelFilter = { term: { \"modelId.keyword\": \"article\" } };\n\n/*\n * Whether entries are filtered by tenant must follow the model's index (CmsModelOpenSearchIndex),\n * not the OPENSEARCH_SHARED_INDEXES variable. A decorator can isolate or share an index per model,\n * so the two can disagree.\n */\ndescribe(\"createInitialQuery\", () => {\n const original = process.env.OPENSEARCH_SHARED_INDEXES;\n\n afterEach(() => {\n process.env.OPENSEARCH_SHARED_INDEXES = original;\n });\n\n it(\"filters by tenant and model when the index is shared, even if the variable says otherwise\", () => {\n process.env.OPENSEARCH_SHARED_INDEXES = \"false\";\n\n const query = createInitialQuery({ model, where: { latest: true }, shared: true });\n\n expect(query.filter).toContainEqual(tenantFilter);\n expect(query.filter).toContainEqual(modelFilter);\n });\n\n it(\"doesn't filter by tenant when the index isn't shared, even if the variable says it is\", () => {\n process.env.OPENSEARCH_SHARED_INDEXES = \"true\";\n\n const query = createInitialQuery({ model, where: { latest: true }, shared: false });\n\n expect(query.filter).not.toContainEqual(tenantFilter);\n expect(query.filter).not.toContainEqual(modelFilter);\n });\n});\n"],"names":["model","tenantFilter","modelFilter","describe","original","process","afterEach","it","query","createInitialQuery","expect"],"mappings":";;AAIA,MAAMA,QAAQ;IAAE,SAAS;IAAW,QAAQ;AAAO;AAEnD,MAAMC,eAAe;IAAE,MAAM;QAAE,kBAAkB;IAAO;AAAE;AAC1D,MAAMC,cAAc;IAAE,MAAM;QAAE,mBAAmB;IAAU;AAAE;AAO7DC,SAAS,sBAAsB;IAC3B,MAAMC,WAAWC,QAAQ,GAAG,CAAC,yBAAyB;IAEtDC,UAAU;QACND,QAAQ,GAAG,CAAC,yBAAyB,GAAGD;IAC5C;IAEAG,GAAG,6FAA6F;QAC5FF,QAAQ,GAAG,CAAC,yBAAyB,GAAG;QAExC,MAAMG,QAAQC,mBAAmB;YAAET;YAAO,OAAO;gBAAE,QAAQ;YAAK;YAAG,QAAQ;QAAK;QAEhFU,OAAOF,MAAM,MAAM,EAAE,cAAc,CAACP;QACpCS,OAAOF,MAAM,MAAM,EAAE,cAAc,CAACN;IACxC;IAEAK,GAAG,yFAAyF;QACxFF,QAAQ,GAAG,CAAC,yBAAyB,GAAG;QAExC,MAAMG,QAAQC,mBAAmB;YAAET;YAAO,OAAO;gBAAE,QAAQ;YAAK;YAAG,QAAQ;QAAM;QAEjFU,OAAOF,MAAM,MAAM,EAAE,GAAG,CAAC,cAAc,CAACP;QACxCS,OAAOF,MAAM,MAAM,EAAE,GAAG,CAAC,cAAc,CAACN;IAC5C;AACJ"}
@@ -8,8 +8,8 @@ const noKeywordFields = [
8
8
  const hasKeyword = (field)=>{
9
9
  const fieldType = getBaseFieldType(field);
10
10
  if (noKeywordFields.includes(fieldType)) return false;
11
- if (field.unmappedType) return false;
12
- if (false === field.keyword) return false;
11
+ else if (field.unmappedType) return false;
12
+ else if (false === field.keyword) return false;
13
13
  return true;
14
14
  };
15
15
  export { hasKeyword };
@@ -1 +1 @@
1
- {"version":3,"file":"operations/entry/elasticsearch/keyword.js","sources":["../../../../src/operations/entry/elasticsearch/keyword.ts"],"sourcesContent":["import type { ModelField } from \"./types.js\";\nimport { getBaseFieldType } from \"@webiny/api-headless-cms/utils/getBaseFieldType.js\";\n\nconst noKeywordFields: string[] = [\"date\", \"datetime\", \"number\", \"boolean\"];\nexport const hasKeyword = (field: ModelField): boolean => {\n const fieldType = getBaseFieldType(field);\n /**\n * We defined some field types that MUST have no keyword added to the field path\n */\n if (noKeywordFields.includes(fieldType)) {\n return false;\n }\n /**\n * If field has unmapped type defined, do not add keyword.\n */\n //\n else if (field.unmappedType) {\n return false;\n }\n /**\n * And if specifically defined that field has no keyword, do not add it.\n */\n //\n else if (field.keyword === false) {\n return false;\n }\n /**\n * All other fields have keyword added.\n */\n return true;\n};\n"],"names":["noKeywordFields","hasKeyword","field","fieldType","getBaseFieldType"],"mappings":";AAGA,MAAMA,kBAA4B;IAAC;IAAQ;IAAY;IAAU;CAAU;AACpE,MAAMC,aAAa,CAACC;IACvB,MAAMC,YAAYC,iBAAiBF;IAInC,IAAIF,gBAAgB,QAAQ,CAACG,YACzB,OAAO;IAMN,IAAID,MAAM,YAAY,EACvB,OAAO;IAMN,IAAIA,AAAkB,UAAlBA,MAAM,OAAO,EAClB,OAAO;IAKX,OAAO;AACX"}
1
+ {"version":3,"file":"operations/entry/elasticsearch/keyword.js","sources":["../../../../src/operations/entry/elasticsearch/keyword.ts"],"sourcesContent":["import type { ModelField } from \"./types.js\";\nimport { getBaseFieldType } from \"@webiny/api-headless-cms/utils/getBaseFieldType.js\";\n\nconst noKeywordFields: string[] = [\"date\", \"datetime\", \"number\", \"boolean\"];\nexport const hasKeyword = (field: ModelField): boolean => {\n const fieldType = getBaseFieldType(field);\n /**\n * We defined some field types that MUST have no keyword added to the field path\n */\n if (noKeywordFields.includes(fieldType)) {\n return false;\n }\n /**\n * If field has unmapped type defined, do not add keyword.\n */\n //\n else if (field.unmappedType) {\n return false;\n }\n /**\n * And if specifically defined that field has no keyword, do not add it.\n */\n //\n else if (field.keyword === false) {\n return false;\n }\n /**\n * All other fields have keyword added.\n */\n return true;\n};\n"],"names":["noKeywordFields","hasKeyword","field","fieldType","getBaseFieldType"],"mappings":";AAGA,MAAMA,kBAA4B;IAAC;IAAQ;IAAY;IAAU;CAAU;AACpE,MAAMC,aAAa,CAACC;IACvB,MAAMC,YAAYC,iBAAiBF;IAInC,IAAIF,gBAAgB,QAAQ,CAACG,YACzB,OAAO;SAMN,IAAID,MAAM,YAAY,EACvB,OAAO;SAMN,IAAIA,AAAkB,UAAlBA,MAAM,OAAO,EAClB,OAAO;IAKX,OAAO;AACX"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@webiny/api-headless-cms-utils-os",
3
- "version": "0.0.0-unstable.d0f34a8194",
3
+ "version": "0.0.0-unstable.e1999482d0",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": "./index.js",
@@ -15,15 +15,15 @@
15
15
  "license": "MIT",
16
16
  "author": "Webiny Ltd.",
17
17
  "dependencies": {
18
- "@webiny/api-headless-cms": "0.0.0-unstable.d0f34a8194",
19
- "@webiny/api-opensearch": "0.0.0-unstable.d0f34a8194",
20
- "@webiny/error": "0.0.0-unstable.d0f34a8194",
21
- "@webiny/feature": "0.0.0-unstable.d0f34a8194"
18
+ "@webiny/api-headless-cms": "0.0.0-unstable.e1999482d0",
19
+ "@webiny/api-opensearch": "0.0.0-unstable.e1999482d0",
20
+ "@webiny/error": "0.0.0-unstable.e1999482d0",
21
+ "@webiny/feature": "0.0.0-unstable.e1999482d0"
22
22
  },
23
23
  "devDependencies": {
24
- "@webiny/build-tools": "0.0.0-unstable.d0f34a8194",
24
+ "@webiny/build-tools": "0.0.0-unstable.e1999482d0",
25
25
  "typescript": "7.0.2",
26
- "vitest": "4.1.11"
26
+ "vitest": "5.1.1"
27
27
  },
28
28
  "publishConfig": {
29
29
  "access": "public"