@webiny/api-opensearch 6.3.0-beta.4 → 6.4.0-beta.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (139) hide show
  1. package/client.js +52 -62
  2. package/client.js.map +1 -1
  3. package/cursors.js +20 -32
  4. package/cursors.js.map +1 -1
  5. package/db/entity.js +14 -16
  6. package/db/entity.js.map +1 -1
  7. package/db/index.js +0 -2
  8. package/db/table.js +10 -14
  9. package/db/table.js.map +1 -1
  10. package/db/types.js +0 -3
  11. package/exports/api/opensearch.js +0 -2
  12. package/features/OpenSearchClient/OpenSearchClient.js +13 -10
  13. package/features/OpenSearchClient/OpenSearchClient.js.map +1 -1
  14. package/features/OpenSearchClient/abstraction.js +2 -1
  15. package/features/OpenSearchClient/abstraction.js.map +1 -1
  16. package/features/OpenSearchClient/feature.js +6 -5
  17. package/features/OpenSearchClient/feature.js.map +1 -1
  18. package/features/OpenSearchClientFactory/OpenSearchClientFactory.js +8 -9
  19. package/features/OpenSearchClientFactory/OpenSearchClientFactory.js.map +1 -1
  20. package/features/OpenSearchClientFactory/abstraction.js +2 -1
  21. package/features/OpenSearchClientFactory/abstraction.js.map +1 -1
  22. package/features/OpenSearchClientFactory/feature.js +6 -5
  23. package/features/OpenSearchClientFactory/feature.js.map +1 -1
  24. package/features/OpenSearchContext/OpenSearchContext.js +11 -10
  25. package/features/OpenSearchContext/OpenSearchContext.js.map +1 -1
  26. package/features/OpenSearchContext/abstraction.js +2 -1
  27. package/features/OpenSearchContext/abstraction.js.map +1 -1
  28. package/features/OpenSearchContext/feature.js +7 -8
  29. package/features/OpenSearchContext/feature.js.map +1 -1
  30. package/index.js +14 -16
  31. package/index.js.map +1 -1
  32. package/indexConfiguration/base.js +25 -26
  33. package/indexConfiguration/base.js.map +1 -1
  34. package/indexConfiguration/common.js +39 -41
  35. package/indexConfiguration/common.js.map +1 -1
  36. package/indexConfiguration/index.js +0 -2
  37. package/indexPrefix.js +2 -3
  38. package/indexPrefix.js.map +1 -1
  39. package/indices.js +8 -16
  40. package/indices.js.map +1 -1
  41. package/limit.js +5 -27
  42. package/limit.js.map +1 -1
  43. package/normalize.js +50 -49
  44. package/normalize.js.map +1 -1
  45. package/operations/OpenSearchCatHealth.js +24 -25
  46. package/operations/OpenSearchCatHealth.js.map +1 -1
  47. package/operations/OpenSearchCatNodes.js +22 -23
  48. package/operations/OpenSearchCatNodes.js.map +1 -1
  49. package/operations/index.js +0 -2
  50. package/operations/stripConnectionFromException.js +11 -14
  51. package/operations/stripConnectionFromException.js.map +1 -1
  52. package/operations/types.js +6 -5
  53. package/operations/types.js.map +1 -1
  54. package/operators.js +20 -7
  55. package/operators.js.map +1 -1
  56. package/package.json +11 -11
  57. package/plugins/definition/OpenSearchBodyModifierPlugin.js +12 -13
  58. package/plugins/definition/OpenSearchBodyModifierPlugin.js.map +1 -1
  59. package/plugins/definition/OpenSearchFieldPlugin.js +43 -60
  60. package/plugins/definition/OpenSearchFieldPlugin.js.map +1 -1
  61. package/plugins/definition/OpenSearchIndexPlugin.js +12 -13
  62. package/plugins/definition/OpenSearchIndexPlugin.js.map +1 -1
  63. package/plugins/definition/OpenSearchQueryBuilderOperatorPlugin.js +5 -5
  64. package/plugins/definition/OpenSearchQueryBuilderOperatorPlugin.js.map +1 -1
  65. package/plugins/definition/OpenSearchQueryModifierPlugin.js +12 -13
  66. package/plugins/definition/OpenSearchQueryModifierPlugin.js.map +1 -1
  67. package/plugins/definition/OpenSearchSortModifierPlugin.js +12 -13
  68. package/plugins/definition/OpenSearchSortModifierPlugin.js.map +1 -1
  69. package/plugins/definition/index.js +0 -2
  70. package/plugins/index.js +0 -2
  71. package/plugins/operator/andIn.js +20 -28
  72. package/plugins/operator/andIn.js.map +1 -1
  73. package/plugins/operator/between.js +21 -27
  74. package/plugins/operator/between.js.map +1 -1
  75. package/plugins/operator/contains.js +21 -19
  76. package/plugins/operator/contains.js.map +1 -1
  77. package/plugins/operator/equal.js +27 -44
  78. package/plugins/operator/equal.js.map +1 -1
  79. package/plugins/operator/gt.js +18 -18
  80. package/plugins/operator/gt.js.map +1 -1
  81. package/plugins/operator/gte.js +18 -18
  82. package/plugins/operator/gte.js.map +1 -1
  83. package/plugins/operator/in.js +18 -24
  84. package/plugins/operator/in.js.map +1 -1
  85. package/plugins/operator/index.js +0 -2
  86. package/plugins/operator/lt.js +18 -18
  87. package/plugins/operator/lt.js.map +1 -1
  88. package/plugins/operator/lte.js +18 -18
  89. package/plugins/operator/lte.js.map +1 -1
  90. package/plugins/operator/not.js +29 -36
  91. package/plugins/operator/not.js.map +1 -1
  92. package/plugins/operator/notBetween.js +21 -27
  93. package/plugins/operator/notBetween.js.map +1 -1
  94. package/plugins/operator/notContains.js +21 -19
  95. package/plugins/operator/notContains.js.map +1 -1
  96. package/plugins/operator/notIn.js +18 -22
  97. package/plugins/operator/notIn.js.map +1 -1
  98. package/plugins/operator/notStartsWith.js +16 -18
  99. package/plugins/operator/notStartsWith.js.map +1 -1
  100. package/plugins/operator/startsWith.js +16 -18
  101. package/plugins/operator/startsWith.js.map +1 -1
  102. package/sharedIndex.js +2 -3
  103. package/sharedIndex.js.map +1 -1
  104. package/sort.js +29 -58
  105. package/sort.js.map +1 -1
  106. package/types.js +5 -65
  107. package/types.js.map +1 -1
  108. package/utils/createIndex.js +56 -78
  109. package/utils/createIndex.js.map +1 -1
  110. package/utils/index.js +0 -2
  111. package/utils/waitUntilHealthy/UnhealthyClusterError.js +8 -7
  112. package/utils/waitUntilHealthy/UnhealthyClusterError.js.map +1 -1
  113. package/utils/waitUntilHealthy/WaitUntilHealthy.js +111 -141
  114. package/utils/waitUntilHealthy/WaitUntilHealthy.js.map +1 -1
  115. package/utils/waitUntilHealthy/WaitingHealthyClusterAbortedError.js +8 -7
  116. package/utils/waitUntilHealthy/WaitingHealthyClusterAbortedError.js.map +1 -1
  117. package/utils/waitUntilHealthy/index.js +0 -2
  118. package/utils/waitUntilHealthy/reason/ClusterHealthReason.js +9 -10
  119. package/utils/waitUntilHealthy/reason/ClusterHealthReason.js.map +1 -1
  120. package/utils/waitUntilHealthy/reason/IReason.js +0 -3
  121. package/utils/waitUntilHealthy/reason/MemoryReason.js +9 -10
  122. package/utils/waitUntilHealthy/reason/MemoryReason.js.map +1 -1
  123. package/utils/waitUntilHealthy/reason/ProcessorReason.js +9 -10
  124. package/utils/waitUntilHealthy/reason/ProcessorReason.js.map +1 -1
  125. package/utils/waitUntilHealthy/reason/index.js +0 -2
  126. package/where.js +41 -74
  127. package/where.js.map +1 -1
  128. package/db/index.js.map +0 -1
  129. package/db/types.js.map +0 -1
  130. package/exports/api/opensearch.js.map +0 -1
  131. package/indexConfiguration/index.js.map +0 -1
  132. package/operations/index.js.map +0 -1
  133. package/plugins/definition/index.js.map +0 -1
  134. package/plugins/index.js.map +0 -1
  135. package/plugins/operator/index.js.map +0 -1
  136. package/utils/index.js.map +0 -1
  137. package/utils/waitUntilHealthy/index.js.map +0 -1
  138. package/utils/waitUntilHealthy/reason/IReason.js.map +0 -1
  139. package/utils/waitUntilHealthy/reason/index.js.map +0 -1
@@ -1,13 +1,12 @@
1
- export class MemoryReason {
2
- name = "memory";
3
- constructor(params) {
4
- this.maximum = params.maximum;
5
- this.current = params.current;
6
- this.description = params.description;
7
- }
1
+ class MemoryReason {
2
+ constructor(params){
3
+ this.name = "memory";
4
+ this.maximum = params.maximum;
5
+ this.current = params.current;
6
+ this.description = params.description;
7
+ }
8
8
  }
9
- export const createMemoryReason = params => {
10
- return new MemoryReason(params);
11
- };
9
+ const createMemoryReason = (params)=>new MemoryReason(params);
10
+ export { MemoryReason, createMemoryReason };
12
11
 
13
12
  //# sourceMappingURL=MemoryReason.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["MemoryReason","name","constructor","params","maximum","current","description","createMemoryReason"],"sources":["MemoryReason.ts"],"sourcesContent":["import type { IReason } from \"~/utils/waitUntilHealthy/reason/IReason.js\";\n\nexport interface IMemoryReasonParams {\n maximum: number;\n current: number;\n description?: string;\n}\n\nexport class MemoryReason implements IReason {\n public readonly name = \"memory\";\n public readonly maximum: number;\n public readonly current: number;\n public readonly description?: string;\n\n public constructor(params: IMemoryReasonParams) {\n this.maximum = params.maximum;\n this.current = params.current;\n this.description = params.description;\n }\n}\n\nexport const createMemoryReason = (params: IMemoryReasonParams): MemoryReason => {\n return new MemoryReason(params);\n};\n"],"mappings":"AAQA,OAAO,MAAMA,YAAY,CAAoB;EACzBC,IAAI,GAAG,QAAQ;EAKxBC,WAAWA,CAACC,MAA2B,EAAE;IAC5C,IAAI,CAACC,OAAO,GAAGD,MAAM,CAACC,OAAO;IAC7B,IAAI,CAACC,OAAO,GAAGF,MAAM,CAACE,OAAO;IAC7B,IAAI,CAACC,WAAW,GAAGH,MAAM,CAACG,WAAW;EACzC;AACJ;AAEA,OAAO,MAAMC,kBAAkB,GAAIJ,MAA2B,IAAmB;EAC7E,OAAO,IAAIH,YAAY,CAACG,MAAM,CAAC;AACnC,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"utils/waitUntilHealthy/reason/MemoryReason.js","sources":["../../../../src/utils/waitUntilHealthy/reason/MemoryReason.ts"],"sourcesContent":["import type { IReason } from \"~/utils/waitUntilHealthy/reason/IReason.js\";\n\nexport interface IMemoryReasonParams {\n maximum: number;\n current: number;\n description?: string;\n}\n\nexport class MemoryReason implements IReason {\n public readonly name = \"memory\";\n public readonly maximum: number;\n public readonly current: number;\n public readonly description?: string;\n\n public constructor(params: IMemoryReasonParams) {\n this.maximum = params.maximum;\n this.current = params.current;\n this.description = params.description;\n }\n}\n\nexport const createMemoryReason = (params: IMemoryReasonParams): MemoryReason => {\n return new MemoryReason(params);\n};\n"],"names":["MemoryReason","params","createMemoryReason"],"mappings":"AAQO,MAAMA;IAMT,YAAmBC,MAA2B,CAAE;aALhC,IAAI,GAAG;QAMnB,IAAI,CAAC,OAAO,GAAGA,OAAO,OAAO;QAC7B,IAAI,CAAC,OAAO,GAAGA,OAAO,OAAO;QAC7B,IAAI,CAAC,WAAW,GAAGA,OAAO,WAAW;IACzC;AACJ;AAEO,MAAMC,qBAAqB,CAACD,SACxB,IAAID,aAAaC"}
@@ -1,13 +1,12 @@
1
- export class ProcessorReason {
2
- name = "processor";
3
- constructor(params) {
4
- this.maximum = params.maximum;
5
- this.current = params.current;
6
- this.description = params.description;
7
- }
1
+ class ProcessorReason {
2
+ constructor(params){
3
+ this.name = "processor";
4
+ this.maximum = params.maximum;
5
+ this.current = params.current;
6
+ this.description = params.description;
7
+ }
8
8
  }
9
- export const createProcessorReason = params => {
10
- return new ProcessorReason(params);
11
- };
9
+ const createProcessorReason = (params)=>new ProcessorReason(params);
10
+ export { ProcessorReason, createProcessorReason };
12
11
 
13
12
  //# sourceMappingURL=ProcessorReason.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["ProcessorReason","name","constructor","params","maximum","current","description","createProcessorReason"],"sources":["ProcessorReason.ts"],"sourcesContent":["import type { IReason } from \"~/utils/waitUntilHealthy/reason/IReason.js\";\n\nexport interface IProcessorReasonParams {\n maximum: number;\n current: number;\n description?: string;\n}\n\nexport class ProcessorReason implements IReason {\n public readonly name = \"processor\";\n public readonly maximum: number;\n public readonly current: number;\n public readonly description?: string;\n\n public constructor(params: IProcessorReasonParams) {\n this.maximum = params.maximum;\n this.current = params.current;\n this.description = params.description;\n }\n}\n\nexport const createProcessorReason = (params: IProcessorReasonParams): ProcessorReason => {\n return new ProcessorReason(params);\n};\n"],"mappings":"AAQA,OAAO,MAAMA,eAAe,CAAoB;EAC5BC,IAAI,GAAG,WAAW;EAK3BC,WAAWA,CAACC,MAA8B,EAAE;IAC/C,IAAI,CAACC,OAAO,GAAGD,MAAM,CAACC,OAAO;IAC7B,IAAI,CAACC,OAAO,GAAGF,MAAM,CAACE,OAAO;IAC7B,IAAI,CAACC,WAAW,GAAGH,MAAM,CAACG,WAAW;EACzC;AACJ;AAEA,OAAO,MAAMC,qBAAqB,GAAIJ,MAA8B,IAAsB;EACtF,OAAO,IAAIH,eAAe,CAACG,MAAM,CAAC;AACtC,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"utils/waitUntilHealthy/reason/ProcessorReason.js","sources":["../../../../src/utils/waitUntilHealthy/reason/ProcessorReason.ts"],"sourcesContent":["import type { IReason } from \"~/utils/waitUntilHealthy/reason/IReason.js\";\n\nexport interface IProcessorReasonParams {\n maximum: number;\n current: number;\n description?: string;\n}\n\nexport class ProcessorReason implements IReason {\n public readonly name = \"processor\";\n public readonly maximum: number;\n public readonly current: number;\n public readonly description?: string;\n\n public constructor(params: IProcessorReasonParams) {\n this.maximum = params.maximum;\n this.current = params.current;\n this.description = params.description;\n }\n}\n\nexport const createProcessorReason = (params: IProcessorReasonParams): ProcessorReason => {\n return new ProcessorReason(params);\n};\n"],"names":["ProcessorReason","params","createProcessorReason"],"mappings":"AAQO,MAAMA;IAMT,YAAmBC,MAA8B,CAAE;aALnC,IAAI,GAAG;QAMnB,IAAI,CAAC,OAAO,GAAGA,OAAO,OAAO;QAC7B,IAAI,CAAC,OAAO,GAAGA,OAAO,OAAO;QAC7B,IAAI,CAAC,WAAW,GAAGA,OAAO,WAAW;IACzC;AACJ;AAEO,MAAMC,wBAAwB,CAACD,SAC3B,IAAID,gBAAgBC"}
@@ -1,5 +1,3 @@
1
1
  export * from "./ClusterHealthReason.js";
2
2
  export * from "./MemoryReason.js";
3
3
  export * from "./ProcessorReason.js";
4
-
5
- //# sourceMappingURL=index.js.map
package/where.js CHANGED
@@ -1,82 +1,49 @@
1
1
  import { OpenSearchFieldPlugin } from "./plugins/definition/OpenSearchFieldPlugin.js";
2
- import WebinyError from "@webiny/error";
3
- /**
4
- * TODO remove the wbyAco prefix when we move the user fields to the values property.
5
- */
2
+ import error from "@webiny/error";
6
3
  const parseWhereKeyRegExp = new RegExp(/^((?:wbyAco_)?[a-zA-Z0-9]+)(_[a-zA-Z0-9_]+)?$/);
7
- export const parseWhereKey = key => {
8
- const match = key.match(parseWhereKeyRegExp);
9
- if (!match) {
10
- throw new Error(`It is not possible to search by key "${key}"`);
11
- }
12
- const [, field, operation = "eq"] = match;
13
- if (!field.match(/^(?:wbyAco_)?([a-zA-Z0-9]+)$/)) {
14
- throw new Error(`Cannot filter by "${field}".`);
15
- }
16
- const operator = operation.match(/^_/) ? operation.slice(1) : operation;
17
- return {
18
- field,
19
- operator
20
- };
4
+ const parseWhereKey = (key)=>{
5
+ const match = key.match(parseWhereKeyRegExp);
6
+ if (!match) throw new Error(`It is not possible to search by key "${key}"`);
7
+ const [, field, operation = "eq"] = match;
8
+ if (!field.match(/^(?:wbyAco_)?([a-zA-Z0-9]+)$/)) throw new Error(`Cannot filter by "${field}".`);
9
+ const operator = operation.match(/^_/) ? operation.slice(1) : operation;
10
+ return {
11
+ field,
12
+ operator
13
+ };
21
14
  };
22
15
  const ALL = OpenSearchFieldPlugin.ALL;
23
- export const applyWhere = params => {
24
- const {
25
- query,
26
- where,
27
- fields,
28
- operators
29
- } = params;
30
- for (const key in where) {
31
- if (where.hasOwnProperty(key) === false) {
32
- continue;
33
- }
34
- const initialValue = where[key];
35
- /**
36
- * There is a possibility that undefined is sent as a value, so just skip it.
37
- */
38
- if (initialValue === undefined) {
39
- continue;
40
- }
41
- const {
42
- field,
43
- operator
44
- } = parseWhereKey(key);
45
- const fieldPlugin = fields[field] || fields[ALL];
46
- if (!fieldPlugin) {
47
- throw new WebinyError(`Missing plugin for the field "${field}".`, "PLUGIN_WHERE_ERROR", {
48
- field
49
- });
16
+ const applyWhere = (params)=>{
17
+ const { query, where, fields, operators } = params;
18
+ for(const key in where){
19
+ if (false === where.hasOwnProperty(key)) continue;
20
+ const initialValue = where[key];
21
+ if (void 0 === initialValue) continue;
22
+ const { field, operator } = parseWhereKey(key);
23
+ const fieldPlugin = fields[field] || fields[ALL];
24
+ if (!fieldPlugin) throw new error(`Missing plugin for the field "${field}".`, "PLUGIN_WHERE_ERROR", {
25
+ field
26
+ });
27
+ const operatorPlugin = operators[operator];
28
+ if (!operatorPlugin) throw new error(`Missing plugin for the operator "${operator}"`, "PLUGIN_WHERE_ERROR", {
29
+ operator
30
+ });
31
+ const path = fieldPlugin.getPath(field);
32
+ const basePath = fieldPlugin.getBasePath(field);
33
+ const value = fieldPlugin.toSearchValue({
34
+ value: initialValue,
35
+ path,
36
+ basePath
37
+ });
38
+ operatorPlugin.apply(query, {
39
+ name: field,
40
+ value,
41
+ path,
42
+ basePath,
43
+ keyword: fieldPlugin.keyword
44
+ });
50
45
  }
51
- const operatorPlugin = operators[operator];
52
- if (!operatorPlugin) {
53
- throw new WebinyError(`Missing plugin for the operator "${operator}"`, "PLUGIN_WHERE_ERROR", {
54
- operator
55
- });
56
- }
57
-
58
- /**
59
- * Get the path but in the case of * (all fields, replace * with the field.
60
- * Custom path would return its own value anyways.
61
- */
62
- const path = fieldPlugin.getPath(field);
63
- const basePath = fieldPlugin.getBasePath(field);
64
- /**
65
- * Transform the value for the search.
66
- */
67
- const value = fieldPlugin.toSearchValue({
68
- value: initialValue,
69
- path,
70
- basePath
71
- });
72
- operatorPlugin.apply(query, {
73
- name: field,
74
- value,
75
- path,
76
- basePath,
77
- keyword: fieldPlugin.keyword
78
- });
79
- }
80
46
  };
47
+ export { applyWhere, parseWhereKey };
81
48
 
82
49
  //# sourceMappingURL=where.js.map
package/where.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"names":["OpenSearchFieldPlugin","WebinyError","parseWhereKeyRegExp","RegExp","parseWhereKey","key","match","Error","field","operation","operator","slice","ALL","applyWhere","params","query","where","fields","operators","hasOwnProperty","initialValue","undefined","fieldPlugin","operatorPlugin","path","getPath","basePath","getBasePath","value","toSearchValue","apply","name","keyword"],"sources":["where.ts"],"sourcesContent":["import type { OpenSearchBoolQueryConfig } from \"~/types.js\";\nimport { OpenSearchFieldPlugin } from \"~/plugins/definition/OpenSearchFieldPlugin.js\";\nimport type { OpenSearchQueryBuilderOperatorPlugin } from \"~/plugins/definition/OpenSearchQueryBuilderOperatorPlugin.js\";\nimport WebinyError from \"@webiny/error\";\n\ntype Records<T> = Record<string, T>;\n\nexport interface ApplyWhereParams {\n query: OpenSearchBoolQueryConfig;\n where: Records<any>;\n fields: Records<OpenSearchFieldPlugin>;\n operators: Records<OpenSearchQueryBuilderOperatorPlugin>;\n}\n\nexport interface ParseWhereKeyResult {\n field: string;\n operator: string;\n}\n\n/**\n * TODO remove the wbyAco prefix when we move the user fields to the values property.\n */\nconst parseWhereKeyRegExp = new RegExp(/^((?:wbyAco_)?[a-zA-Z0-9]+)(_[a-zA-Z0-9_]+)?$/);\n\nexport const parseWhereKey = (key: string): ParseWhereKeyResult => {\n const match = key.match(parseWhereKeyRegExp);\n\n if (!match) {\n throw new Error(`It is not possible to search by key \"${key}\"`);\n }\n\n const [, field, operation = \"eq\"] = match;\n\n if (!field.match(/^(?:wbyAco_)?([a-zA-Z0-9]+)$/)) {\n throw new Error(`Cannot filter by \"${field}\".`);\n }\n\n const operator = operation.match(/^_/) ? operation.slice(1) : operation;\n\n return { field, operator };\n};\n\nconst ALL = OpenSearchFieldPlugin.ALL;\n\nexport const applyWhere = (params: ApplyWhereParams): void => {\n const { query, where, fields, operators } = params;\n\n for (const key in where) {\n if (where.hasOwnProperty(key) === false) {\n continue;\n }\n const initialValue = where[key];\n /**\n * There is a possibility that undefined is sent as a value, so just skip it.\n */\n if (initialValue === undefined) {\n continue;\n }\n const { field, operator } = parseWhereKey(key);\n const fieldPlugin: OpenSearchFieldPlugin = fields[field] || fields[ALL];\n if (!fieldPlugin) {\n throw new WebinyError(\n `Missing plugin for the field \"${field}\".`,\n \"PLUGIN_WHERE_ERROR\",\n {\n field\n }\n );\n }\n const operatorPlugin = operators[operator];\n if (!operatorPlugin) {\n throw new WebinyError(\n `Missing plugin for the operator \"${operator}\"`,\n \"PLUGIN_WHERE_ERROR\",\n {\n operator\n }\n );\n }\n\n /**\n * Get the path but in the case of * (all fields, replace * with the field.\n * Custom path would return its own value anyways.\n */\n const path = fieldPlugin.getPath(field);\n const basePath = fieldPlugin.getBasePath(field);\n /**\n * Transform the value for the search.\n */\n const value = fieldPlugin.toSearchValue({\n value: initialValue,\n path,\n basePath\n });\n\n operatorPlugin.apply(query, {\n name: field,\n value,\n path,\n basePath,\n keyword: fieldPlugin.keyword\n });\n }\n};\n"],"mappings":"AACA,SAASA,qBAAqB;AAE9B,OAAOC,WAAW,MAAM,eAAe;AAgBvC;AACA;AACA;AACA,MAAMC,mBAAmB,GAAG,IAAIC,MAAM,CAAC,+CAA+C,CAAC;AAEvF,OAAO,MAAMC,aAAa,GAAIC,GAAW,IAA0B;EAC/D,MAAMC,KAAK,GAAGD,GAAG,CAACC,KAAK,CAACJ,mBAAmB,CAAC;EAE5C,IAAI,CAACI,KAAK,EAAE;IACR,MAAM,IAAIC,KAAK,CAAC,wCAAwCF,GAAG,GAAG,CAAC;EACnE;EAEA,MAAM,GAAGG,KAAK,EAAEC,SAAS,GAAG,IAAI,CAAC,GAAGH,KAAK;EAEzC,IAAI,CAACE,KAAK,CAACF,KAAK,CAAC,8BAA8B,CAAC,EAAE;IAC9C,MAAM,IAAIC,KAAK,CAAC,qBAAqBC,KAAK,IAAI,CAAC;EACnD;EAEA,MAAME,QAAQ,GAAGD,SAAS,CAACH,KAAK,CAAC,IAAI,CAAC,GAAGG,SAAS,CAACE,KAAK,CAAC,CAAC,CAAC,GAAGF,SAAS;EAEvE,OAAO;IAAED,KAAK;IAAEE;EAAS,CAAC;AAC9B,CAAC;AAED,MAAME,GAAG,GAAGZ,qBAAqB,CAACY,GAAG;AAErC,OAAO,MAAMC,UAAU,GAAIC,MAAwB,IAAW;EAC1D,MAAM;IAAEC,KAAK;IAAEC,KAAK;IAAEC,MAAM;IAAEC;EAAU,CAAC,GAAGJ,MAAM;EAElD,KAAK,MAAMT,GAAG,IAAIW,KAAK,EAAE;IACrB,IAAIA,KAAK,CAACG,cAAc,CAACd,GAAG,CAAC,KAAK,KAAK,EAAE;MACrC;IACJ;IACA,MAAMe,YAAY,GAAGJ,KAAK,CAACX,GAAG,CAAC;IAC/B;AACR;AACA;IACQ,IAAIe,YAAY,KAAKC,SAAS,EAAE;MAC5B;IACJ;IACA,MAAM;MAAEb,KAAK;MAAEE;IAAS,CAAC,GAAGN,aAAa,CAACC,GAAG,CAAC;IAC9C,MAAMiB,WAAkC,GAAGL,MAAM,CAACT,KAAK,CAAC,IAAIS,MAAM,CAACL,GAAG,CAAC;IACvE,IAAI,CAACU,WAAW,EAAE;MACd,MAAM,IAAIrB,WAAW,CACjB,iCAAiCO,KAAK,IAAI,EAC1C,oBAAoB,EACpB;QACIA;MACJ,CACJ,CAAC;IACL;IACA,MAAMe,cAAc,GAAGL,SAAS,CAACR,QAAQ,CAAC;IAC1C,IAAI,CAACa,cAAc,EAAE;MACjB,MAAM,IAAItB,WAAW,CACjB,oCAAoCS,QAAQ,GAAG,EAC/C,oBAAoB,EACpB;QACIA;MACJ,CACJ,CAAC;IACL;;IAEA;AACR;AACA;AACA;IACQ,MAAMc,IAAI,GAAGF,WAAW,CAACG,OAAO,CAACjB,KAAK,CAAC;IACvC,MAAMkB,QAAQ,GAAGJ,WAAW,CAACK,WAAW,CAACnB,KAAK,CAAC;IAC/C;AACR;AACA;IACQ,MAAMoB,KAAK,GAAGN,WAAW,CAACO,aAAa,CAAC;MACpCD,KAAK,EAAER,YAAY;MACnBI,IAAI;MACJE;IACJ,CAAC,CAAC;IAEFH,cAAc,CAACO,KAAK,CAACf,KAAK,EAAE;MACxBgB,IAAI,EAAEvB,KAAK;MACXoB,KAAK;MACLJ,IAAI;MACJE,QAAQ;MACRM,OAAO,EAAEV,WAAW,CAACU;IACzB,CAAC,CAAC;EACN;AACJ,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"where.js","sources":["../src/where.ts"],"sourcesContent":["import type { OpenSearchBoolQueryConfig } from \"~/types.js\";\nimport { OpenSearchFieldPlugin } from \"~/plugins/definition/OpenSearchFieldPlugin.js\";\nimport type { OpenSearchQueryBuilderOperatorPlugin } from \"~/plugins/definition/OpenSearchQueryBuilderOperatorPlugin.js\";\nimport WebinyError from \"@webiny/error\";\n\ntype Records<T> = Record<string, T>;\n\nexport interface ApplyWhereParams {\n query: OpenSearchBoolQueryConfig;\n where: Records<any>;\n fields: Records<OpenSearchFieldPlugin>;\n operators: Records<OpenSearchQueryBuilderOperatorPlugin>;\n}\n\nexport interface ParseWhereKeyResult {\n field: string;\n operator: string;\n}\n\n/**\n * TODO remove the wbyAco prefix when we move the user fields to the values property.\n */\nconst parseWhereKeyRegExp = new RegExp(/^((?:wbyAco_)?[a-zA-Z0-9]+)(_[a-zA-Z0-9_]+)?$/);\n\nexport const parseWhereKey = (key: string): ParseWhereKeyResult => {\n const match = key.match(parseWhereKeyRegExp);\n\n if (!match) {\n throw new Error(`It is not possible to search by key \"${key}\"`);\n }\n\n const [, field, operation = \"eq\"] = match;\n\n if (!field.match(/^(?:wbyAco_)?([a-zA-Z0-9]+)$/)) {\n throw new Error(`Cannot filter by \"${field}\".`);\n }\n\n const operator = operation.match(/^_/) ? operation.slice(1) : operation;\n\n return { field, operator };\n};\n\nconst ALL = OpenSearchFieldPlugin.ALL;\n\nexport const applyWhere = (params: ApplyWhereParams): void => {\n const { query, where, fields, operators } = params;\n\n for (const key in where) {\n if (where.hasOwnProperty(key) === false) {\n continue;\n }\n const initialValue = where[key];\n /**\n * There is a possibility that undefined is sent as a value, so just skip it.\n */\n if (initialValue === undefined) {\n continue;\n }\n const { field, operator } = parseWhereKey(key);\n const fieldPlugin: OpenSearchFieldPlugin = fields[field] || fields[ALL];\n if (!fieldPlugin) {\n throw new WebinyError(\n `Missing plugin for the field \"${field}\".`,\n \"PLUGIN_WHERE_ERROR\",\n {\n field\n }\n );\n }\n const operatorPlugin = operators[operator];\n if (!operatorPlugin) {\n throw new WebinyError(\n `Missing plugin for the operator \"${operator}\"`,\n \"PLUGIN_WHERE_ERROR\",\n {\n operator\n }\n );\n }\n\n /**\n * Get the path but in the case of * (all fields, replace * with the field.\n * Custom path would return its own value anyways.\n */\n const path = fieldPlugin.getPath(field);\n const basePath = fieldPlugin.getBasePath(field);\n /**\n * Transform the value for the search.\n */\n const value = fieldPlugin.toSearchValue({\n value: initialValue,\n path,\n basePath\n });\n\n operatorPlugin.apply(query, {\n name: field,\n value,\n path,\n basePath,\n keyword: fieldPlugin.keyword\n });\n }\n};\n"],"names":["parseWhereKeyRegExp","RegExp","parseWhereKey","key","match","Error","field","operation","operator","ALL","OpenSearchFieldPlugin","applyWhere","params","query","where","fields","operators","initialValue","undefined","fieldPlugin","WebinyError","operatorPlugin","path","basePath","value"],"mappings":";;AAsBA,MAAMA,sBAAsB,IAAIC,OAAO;AAEhC,MAAMC,gBAAgB,CAACC;IAC1B,MAAMC,QAAQD,IAAI,KAAK,CAACH;IAExB,IAAI,CAACI,OACD,MAAM,IAAIC,MAAM,CAAC,qCAAqC,EAAEF,IAAI,CAAC,CAAC;IAGlE,MAAM,GAAGG,OAAOC,YAAY,IAAI,CAAC,GAAGH;IAEpC,IAAI,CAACE,MAAM,KAAK,CAAC,iCACb,MAAM,IAAID,MAAM,CAAC,kBAAkB,EAAEC,MAAM,EAAE,CAAC;IAGlD,MAAME,WAAWD,UAAU,KAAK,CAAC,QAAQA,UAAU,KAAK,CAAC,KAAKA;IAE9D,OAAO;QAAED;QAAOE;IAAS;AAC7B;AAEA,MAAMC,MAAMC,sBAAsB,GAAG;AAE9B,MAAMC,aAAa,CAACC;IACvB,MAAM,EAAEC,KAAK,EAAEC,KAAK,EAAEC,MAAM,EAAEC,SAAS,EAAE,GAAGJ;IAE5C,IAAK,MAAMT,OAAOW,MAAO;QACrB,IAAIA,AAA8B,UAA9BA,MAAM,cAAc,CAACX,MACrB;QAEJ,MAAMc,eAAeH,KAAK,CAACX,IAAI;QAI/B,IAAIc,AAAiBC,WAAjBD,cACA;QAEJ,MAAM,EAAEX,KAAK,EAAEE,QAAQ,EAAE,GAAGN,cAAcC;QAC1C,MAAMgB,cAAqCJ,MAAM,CAACT,MAAM,IAAIS,MAAM,CAACN,IAAI;QACvE,IAAI,CAACU,aACD,MAAM,IAAIC,MACN,CAAC,8BAA8B,EAAEd,MAAM,EAAE,CAAC,EAC1C,sBACA;YACIA;QACJ;QAGR,MAAMe,iBAAiBL,SAAS,CAACR,SAAS;QAC1C,IAAI,CAACa,gBACD,MAAM,IAAID,MACN,CAAC,iCAAiC,EAAEZ,SAAS,CAAC,CAAC,EAC/C,sBACA;YACIA;QACJ;QAQR,MAAMc,OAAOH,YAAY,OAAO,CAACb;QACjC,MAAMiB,WAAWJ,YAAY,WAAW,CAACb;QAIzC,MAAMkB,QAAQL,YAAY,aAAa,CAAC;YACpC,OAAOF;YACPK;YACAC;QACJ;QAEAF,eAAe,KAAK,CAACR,OAAO;YACxB,MAAMP;YACNkB;YACAF;YACAC;YACA,SAASJ,YAAY,OAAO;QAChC;IACJ;AACJ"}
package/db/index.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["export * from \"./table.js\";\nexport * from \"./entity.js\";\nexport * from \"./types.js\";\n"],"mappings":"AAAA;AACA;AACA","ignoreList":[]}
package/db/types.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"names":[],"sources":["types.ts"],"sourcesContent":["import type { IEntity, IStandardEntityAttributes } from \"@webiny/db-dynamodb\";\nimport type { GenericRecord } from \"@webiny/api/types.js\";\n\nexport interface IOpenSearchEntityAttributes extends IStandardEntityAttributes<GenericRecord> {\n index: string;\n}\n\nexport type IOpenSearchEntity = IEntity<IOpenSearchEntityAttributes>;\n"],"mappings":"","ignoreList":[]}
@@ -1 +0,0 @@
1
- {"version":3,"names":["createOpenSearchClient","OpenSearchClient","OpenSearchContext","OpenSearchClientFactory"],"sources":["opensearch.ts"],"sourcesContent":["export { createOpenSearchClient } from \"~/client.js\";\nexport { OpenSearchClient } from \"~/features/OpenSearchClient/abstraction.js\";\nexport { OpenSearchContext } from \"~/features/OpenSearchContext/abstraction.js\";\nexport { OpenSearchClientFactory } from \"~/features/OpenSearchClientFactory/abstraction.js\";\n"],"mappings":"AAAA,SAASA,sBAAsB;AAC/B,SAASC,gBAAgB;AACzB,SAASC,iBAAiB;AAC1B,SAASC,uBAAuB","ignoreList":[]}
@@ -1 +0,0 @@
1
- {"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["export * from \"./base.js\";\nexport * from \"./common.js\";\n"],"mappings":"AAAA;AACA","ignoreList":[]}
@@ -1 +0,0 @@
1
- {"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["export * from \"./OpenSearchCatHealth.js\";\nexport * from \"./OpenSearchCatNodes.js\";\nexport * from \"./types.js\";\n"],"mappings":"AAAA;AACA;AACA","ignoreList":[]}
@@ -1 +0,0 @@
1
- {"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["export * from \"./OpenSearchBodyModifierPlugin.js\";\nexport * from \"./OpenSearchFieldPlugin.js\";\nexport * from \"./OpenSearchIndexPlugin.js\";\nexport * from \"./OpenSearchQueryBuilderOperatorPlugin.js\";\nexport * from \"./OpenSearchQueryModifierPlugin.js\";\nexport * from \"./OpenSearchSortModifierPlugin.js\";\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA","ignoreList":[]}
@@ -1 +0,0 @@
1
- {"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["export * from \"./definition/index.js\";\nexport * from \"./operator/index.js\";\n"],"mappings":"AAAA;AACA","ignoreList":[]}
@@ -1 +0,0 @@
1
- {"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["export * from \"./between.js\";\nexport * from \"./contains.js\";\nexport * from \"./equal.js\";\nexport * from \"./gt.js\";\nexport * from \"./gte.js\";\nexport * from \"./andIn.js\";\nexport * from \"./in.js\";\nexport * from \"./lt.js\";\nexport * from \"./lte.js\";\nexport * from \"./not.js\";\nexport * from \"./notBetween.js\";\nexport * from \"./notContains.js\";\nexport * from \"./notIn.js\";\nexport * from \"./startsWith.js\";\nexport * from \"./notStartsWith.js\";\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA","ignoreList":[]}
@@ -1 +0,0 @@
1
- {"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["export * from \"./waitUntilHealthy/index.js\";\nexport * from \"./createIndex.js\";\n"],"mappings":"AAAA;AACA","ignoreList":[]}
@@ -1 +0,0 @@
1
- {"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["export * from \"./WaitingHealthyClusterAbortedError.js\";\nexport * from \"./UnhealthyClusterError.js\";\nexport * from \"./WaitUntilHealthy.js\";\nexport * from \"./reason/index.js\";\n"],"mappings":"AAAA;AACA;AACA;AACA","ignoreList":[]}
@@ -1 +0,0 @@
1
- {"version":3,"names":[],"sources":["IReason.ts"],"sourcesContent":["export interface IReason {\n name: string;\n description?: string;\n}\n"],"mappings":"","ignoreList":[]}
@@ -1 +0,0 @@
1
- {"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["export * from \"./ClusterHealthReason.js\";\nexport * from \"./MemoryReason.js\";\nexport * from \"./ProcessorReason.js\";\n"],"mappings":"AAAA;AACA;AACA","ignoreList":[]}