@webiny/api-opensearch 6.3.0 → 6.4.0-beta.1

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 +1 @@
1
- {"version":3,"names":["WebinyError","stripConnectionFromException","OpenSearchCatNodes","constructor","client","getNodes","response","cat","nodes","format","Array","isArray","body","length","message","code","data","ex","console","error","log","JSON","stringify"],"sources":["OpenSearchCatNodes.ts"],"sourcesContent":["import type { IOpenSearchCatNodesResponse } from \"./types.js\";\nimport type { Client } from \"~/client.js\";\nimport { WebinyError } from \"@webiny/error\";\nimport { stripConnectionFromException } from \"~/operations/stripConnectionFromException.js\";\n\nexport class OpenSearchCatNodes {\n private readonly client: Client;\n\n public constructor(client: Client) {\n this.client = client;\n }\n\n public async getNodes(): Promise<IOpenSearchCatNodesResponse> {\n try {\n const response = await this.client.cat.nodes({\n format: \"json\"\n });\n if (!Array.isArray(response.body) || response.body.length === 0) {\n throw new WebinyError({\n message: `There is no valid response from cat.nodes operation.`,\n code: \"OPENSEARCH_NODES_INVALID_RESPONSE\",\n data: response.body\n });\n }\n return response.body;\n } catch (ex) {\n console.error(`Could not fetch cluster nodes information: ${ex.message}`);\n const error = stripConnectionFromException(ex);\n console.log(JSON.stringify(error));\n throw error;\n }\n }\n}\n"],"mappings":"AAEA,SAASA,WAAW,QAAQ,eAAe;AAC3C,SAASC,4BAA4B;AAErC,OAAO,MAAMC,kBAAkB,CAAC;EAGrBC,WAAWA,CAACC,MAAc,EAAE;IAC/B,IAAI,CAACA,MAAM,GAAGA,MAAM;EACxB;EAEA,MAAaC,QAAQA,CAAA,EAAyC;IAC1D,IAAI;MACA,MAAMC,QAAQ,GAAG,MAAM,IAAI,CAACF,MAAM,CAACG,GAAG,CAACC,KAAK,CAAC;QACzCC,MAAM,EAAE;MACZ,CAAC,CAAC;MACF,IAAI,CAACC,KAAK,CAACC,OAAO,CAACL,QAAQ,CAACM,IAAI,CAAC,IAAIN,QAAQ,CAACM,IAAI,CAACC,MAAM,KAAK,CAAC,EAAE;QAC7D,MAAM,IAAIb,WAAW,CAAC;UAClBc,OAAO,EAAE,sDAAsD;UAC/DC,IAAI,EAAE,mCAAmC;UACzCC,IAAI,EAAEV,QAAQ,CAACM;QACnB,CAAC,CAAC;MACN;MACA,OAAON,QAAQ,CAACM,IAAI;IACxB,CAAC,CAAC,OAAOK,EAAE,EAAE;MACTC,OAAO,CAACC,KAAK,CAAC,8CAA8CF,EAAE,CAACH,OAAO,EAAE,CAAC;MACzE,MAAMK,KAAK,GAAGlB,4BAA4B,CAACgB,EAAE,CAAC;MAC9CC,OAAO,CAACE,GAAG,CAACC,IAAI,CAACC,SAAS,CAACH,KAAK,CAAC,CAAC;MAClC,MAAMA,KAAK;IACf;EACJ;AACJ","ignoreList":[]}
1
+ {"version":3,"file":"operations/OpenSearchCatNodes.js","sources":["../../src/operations/OpenSearchCatNodes.ts"],"sourcesContent":["import type { IOpenSearchCatNodesResponse } from \"./types.js\";\nimport type { Client } from \"~/client.js\";\nimport { WebinyError } from \"@webiny/error\";\nimport { stripConnectionFromException } from \"~/operations/stripConnectionFromException.js\";\n\nexport class OpenSearchCatNodes {\n private readonly client: Client;\n\n public constructor(client: Client) {\n this.client = client;\n }\n\n public async getNodes(): Promise<IOpenSearchCatNodesResponse> {\n try {\n const response = await this.client.cat.nodes({\n format: \"json\"\n });\n if (!Array.isArray(response.body) || response.body.length === 0) {\n throw new WebinyError({\n message: `There is no valid response from cat.nodes operation.`,\n code: \"OPENSEARCH_NODES_INVALID_RESPONSE\",\n data: response.body\n });\n }\n return response.body;\n } catch (ex) {\n console.error(`Could not fetch cluster nodes information: ${ex.message}`);\n const error = stripConnectionFromException(ex);\n console.log(JSON.stringify(error));\n throw error;\n }\n }\n}\n"],"names":["OpenSearchCatNodes","client","response","Array","WebinyError","ex","console","error","stripConnectionFromException","JSON"],"mappings":";;AAKO,MAAMA;IAGT,YAAmBC,MAAc,CAAE;QAC/B,IAAI,CAAC,MAAM,GAAGA;IAClB;IAEA,MAAa,WAAiD;QAC1D,IAAI;YACA,MAAMC,WAAW,MAAM,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC;gBACzC,QAAQ;YACZ;YACA,IAAI,CAACC,MAAM,OAAO,CAACD,SAAS,IAAI,KAAKA,AAAyB,MAAzBA,SAAS,IAAI,CAAC,MAAM,EACrD,MAAM,IAAIE,YAAY;gBAClB,SAAS;gBACT,MAAM;gBACN,MAAMF,SAAS,IAAI;YACvB;YAEJ,OAAOA,SAAS,IAAI;QACxB,EAAE,OAAOG,IAAI;YACTC,QAAQ,KAAK,CAAC,CAAC,2CAA2C,EAAED,GAAG,OAAO,EAAE;YACxE,MAAME,QAAQC,6BAA6BH;YAC3CC,QAAQ,GAAG,CAACG,KAAK,SAAS,CAACF;YAC3B,MAAMA;QACV;IACJ;AACJ"}
@@ -1,5 +1,3 @@
1
1
  export * from "./OpenSearchCatHealth.js";
2
2
  export * from "./OpenSearchCatNodes.js";
3
3
  export * from "./types.js";
4
-
5
- //# sourceMappingURL=index.js.map
@@ -1,17 +1,14 @@
1
- export const stripConnectionFromException = ex => {
2
- if (typeof ex !== "object") {
3
- return ex;
4
- }
5
- if (!ex?.meta?.meta?.connection) {
6
- return ex;
7
- }
8
- return {
9
- ...ex.meta,
10
- meta: {
11
- ...ex.meta.meta,
12
- connection: null
13
- }
14
- };
1
+ const stripConnectionFromException = (ex)=>{
2
+ if ("object" != typeof ex) return ex;
3
+ if (!ex?.meta?.meta?.connection) return ex;
4
+ return {
5
+ ...ex.meta,
6
+ meta: {
7
+ ...ex.meta.meta,
8
+ connection: null
9
+ }
10
+ };
15
11
  };
12
+ export { stripConnectionFromException };
16
13
 
17
14
  //# sourceMappingURL=stripConnectionFromException.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["stripConnectionFromException","ex","meta","connection"],"sources":["stripConnectionFromException.ts"],"sourcesContent":["export const stripConnectionFromException = (ex: any): any => {\n if (typeof ex !== \"object\") {\n return ex;\n }\n if (!ex?.meta?.meta?.connection) {\n return ex;\n }\n return {\n ...ex.meta,\n meta: {\n ...ex.meta.meta,\n connection: null\n }\n };\n};\n"],"mappings":"AAAA,OAAO,MAAMA,4BAA4B,GAAIC,EAAO,IAAU;EAC1D,IAAI,OAAOA,EAAE,KAAK,QAAQ,EAAE;IACxB,OAAOA,EAAE;EACb;EACA,IAAI,CAACA,EAAE,EAAEC,IAAI,EAAEA,IAAI,EAAEC,UAAU,EAAE;IAC7B,OAAOF,EAAE;EACb;EACA,OAAO;IACH,GAAGA,EAAE,CAACC,IAAI;IACVA,IAAI,EAAE;MACF,GAAGD,EAAE,CAACC,IAAI,CAACA,IAAI;MACfC,UAAU,EAAE;IAChB;EACJ,CAAC;AACL,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"operations/stripConnectionFromException.js","sources":["../../src/operations/stripConnectionFromException.ts"],"sourcesContent":["export const stripConnectionFromException = (ex: any): any => {\n if (typeof ex !== \"object\") {\n return ex;\n }\n if (!ex?.meta?.meta?.connection) {\n return ex;\n }\n return {\n ...ex.meta,\n meta: {\n ...ex.meta.meta,\n connection: null\n }\n };\n};\n"],"names":["stripConnectionFromException","ex"],"mappings":"AAAO,MAAMA,+BAA+B,CAACC;IACzC,IAAI,AAAc,YAAd,OAAOA,IACP,OAAOA;IAEX,IAAI,CAACA,IAAI,MAAM,MAAM,YACjB,OAAOA;IAEX,OAAO;QACH,GAAGA,GAAG,IAAI;QACV,MAAM;YACF,GAAGA,GAAG,IAAI,CAAC,IAAI;YACf,YAAY;QAChB;IACJ;AACJ"}
@@ -1,8 +1,9 @@
1
- export let OpenSearchCatClusterHealthStatus = /*#__PURE__*/function (OpenSearchCatClusterHealthStatus) {
2
- OpenSearchCatClusterHealthStatus["Green"] = "green";
3
- OpenSearchCatClusterHealthStatus["Yellow"] = "yellow";
4
- OpenSearchCatClusterHealthStatus["Red"] = "red";
5
- return OpenSearchCatClusterHealthStatus;
1
+ var types_OpenSearchCatClusterHealthStatus = /*#__PURE__*/ function(OpenSearchCatClusterHealthStatus) {
2
+ OpenSearchCatClusterHealthStatus["Green"] = "green";
3
+ OpenSearchCatClusterHealthStatus["Yellow"] = "yellow";
4
+ OpenSearchCatClusterHealthStatus["Red"] = "red";
5
+ return OpenSearchCatClusterHealthStatus;
6
6
  }({});
7
+ export { types_OpenSearchCatClusterHealthStatus as OpenSearchCatClusterHealthStatus };
7
8
 
8
9
  //# sourceMappingURL=types.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["OpenSearchCatClusterHealthStatus"],"sources":["types.ts"],"sourcesContent":["import type {\n Cat_Health_ResponseBody,\n Cat_Nodes_ResponseBody\n} from \"@opensearch-project/opensearch/api/index.js\";\n\nexport enum OpenSearchCatClusterHealthStatus {\n Green = \"green\",\n Yellow = \"yellow\",\n Red = \"red\"\n}\n\ntype HealthRecord = Cat_Health_ResponseBody[number];\n\ntype NodesRecord = Cat_Nodes_ResponseBody[number];\n\nexport type IOpenSearchCatHealthResponse = HealthRecord;\n\nexport type IOpenSearchCatNodeResponse = NodesRecord;\n\nexport type IOpenSearchCatNodesResponse = IOpenSearchCatNodeResponse[];\n"],"mappings":"AAKA,WAAYA,gCAAgC,0BAAhCA,gCAAgC;EAAhCA,gCAAgC;EAAhCA,gCAAgC;EAAhCA,gCAAgC;EAAA,OAAhCA,gCAAgC;AAAA","ignoreList":[]}
1
+ {"version":3,"file":"operations/types.js","sources":["../../src/operations/types.ts"],"sourcesContent":["import type {\n Cat_Health_ResponseBody,\n Cat_Nodes_ResponseBody\n} from \"@opensearch-project/opensearch/api/index.js\";\n\nexport enum OpenSearchCatClusterHealthStatus {\n Green = \"green\",\n Yellow = \"yellow\",\n Red = \"red\"\n}\n\ntype HealthRecord = Cat_Health_ResponseBody[number];\n\ntype NodesRecord = Cat_Nodes_ResponseBody[number];\n\nexport type IOpenSearchCatHealthResponse = HealthRecord;\n\nexport type IOpenSearchCatNodeResponse = NodesRecord;\n\nexport type IOpenSearchCatNodesResponse = IOpenSearchCatNodeResponse[];\n"],"names":["OpenSearchCatClusterHealthStatus"],"mappings":"AAKO,IAAKA,yCAAgCA,WAAAA,GAAAA,SAAhCA,gCAAgC;;;;WAAhCA"}
package/operators.js CHANGED
@@ -1,9 +1,22 @@
1
- import { OpenSearchQueryBuilderOperatorBetweenPlugin, OpenSearchQueryBuilderOperatorAndInPlugin, OpenSearchQueryBuilderOperatorGreaterThanOrEqualToPlugin, OpenSearchQueryBuilderOperatorGreaterThanPlugin, OpenSearchQueryBuilderOperatorContainsPlugin, OpenSearchQueryBuilderOperatorLesserThanOrEqualToPlugin, OpenSearchQueryBuilderOperatorInPlugin, OpenSearchQueryBuilderOperatorLesserThanPlugin, OpenSearchQueryBuilderOperatorNotBetweenPlugin, OpenSearchQueryBuilderOperatorNotContainsPlugin, OpenSearchQueryBuilderOperatorNotPlugin, OpenSearchQueryBuilderOperatorNotInPlugin, OpenSearchQueryBuilderOperatorEqualPlugin, OpenSearchQueryBuilderOperatorStartsWithPlugin, OpenSearchQueryBuilderOperatorNotStartsWithPlugin } from "./plugins/operator/index.js";
2
- const operators = [new OpenSearchQueryBuilderOperatorBetweenPlugin(), new OpenSearchQueryBuilderOperatorNotBetweenPlugin(), new OpenSearchQueryBuilderOperatorContainsPlugin(), new OpenSearchQueryBuilderOperatorNotContainsPlugin(), new OpenSearchQueryBuilderOperatorEqualPlugin(), new OpenSearchQueryBuilderOperatorNotPlugin(), new OpenSearchQueryBuilderOperatorGreaterThanPlugin(), new OpenSearchQueryBuilderOperatorGreaterThanOrEqualToPlugin(), new OpenSearchQueryBuilderOperatorLesserThanPlugin(), new OpenSearchQueryBuilderOperatorLesserThanOrEqualToPlugin(), new OpenSearchQueryBuilderOperatorInPlugin(), new OpenSearchQueryBuilderOperatorAndInPlugin(), new OpenSearchQueryBuilderOperatorNotInPlugin(), new OpenSearchQueryBuilderOperatorStartsWithPlugin(), new OpenSearchQueryBuilderOperatorNotStartsWithPlugin()];
3
- /**
4
- * We export as a function because there might be something to be sent to the operators at some point.
5
- * This way, we make it easier to upgrade.
6
- */
7
- export const getOpenSearchOperators = () => operators;
1
+ import { OpenSearchQueryBuilderOperatorAndInPlugin, OpenSearchQueryBuilderOperatorBetweenPlugin, OpenSearchQueryBuilderOperatorContainsPlugin, OpenSearchQueryBuilderOperatorEqualPlugin, OpenSearchQueryBuilderOperatorGreaterThanOrEqualToPlugin, OpenSearchQueryBuilderOperatorGreaterThanPlugin, OpenSearchQueryBuilderOperatorInPlugin, OpenSearchQueryBuilderOperatorLesserThanOrEqualToPlugin, OpenSearchQueryBuilderOperatorLesserThanPlugin, OpenSearchQueryBuilderOperatorNotBetweenPlugin, OpenSearchQueryBuilderOperatorNotContainsPlugin, OpenSearchQueryBuilderOperatorNotInPlugin, OpenSearchQueryBuilderOperatorNotPlugin, OpenSearchQueryBuilderOperatorNotStartsWithPlugin, OpenSearchQueryBuilderOperatorStartsWithPlugin } from "./plugins/operator/index.js";
2
+ const operators = [
3
+ new OpenSearchQueryBuilderOperatorBetweenPlugin(),
4
+ new OpenSearchQueryBuilderOperatorNotBetweenPlugin(),
5
+ new OpenSearchQueryBuilderOperatorContainsPlugin(),
6
+ new OpenSearchQueryBuilderOperatorNotContainsPlugin(),
7
+ new OpenSearchQueryBuilderOperatorEqualPlugin(),
8
+ new OpenSearchQueryBuilderOperatorNotPlugin(),
9
+ new OpenSearchQueryBuilderOperatorGreaterThanPlugin(),
10
+ new OpenSearchQueryBuilderOperatorGreaterThanOrEqualToPlugin(),
11
+ new OpenSearchQueryBuilderOperatorLesserThanPlugin(),
12
+ new OpenSearchQueryBuilderOperatorLesserThanOrEqualToPlugin(),
13
+ new OpenSearchQueryBuilderOperatorInPlugin(),
14
+ new OpenSearchQueryBuilderOperatorAndInPlugin(),
15
+ new OpenSearchQueryBuilderOperatorNotInPlugin(),
16
+ new OpenSearchQueryBuilderOperatorStartsWithPlugin(),
17
+ new OpenSearchQueryBuilderOperatorNotStartsWithPlugin()
18
+ ];
19
+ const getOpenSearchOperators = ()=>operators;
20
+ export { getOpenSearchOperators };
8
21
 
9
22
  //# sourceMappingURL=operators.js.map
package/operators.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"names":["OpenSearchQueryBuilderOperatorBetweenPlugin","OpenSearchQueryBuilderOperatorAndInPlugin","OpenSearchQueryBuilderOperatorGreaterThanOrEqualToPlugin","OpenSearchQueryBuilderOperatorGreaterThanPlugin","OpenSearchQueryBuilderOperatorContainsPlugin","OpenSearchQueryBuilderOperatorLesserThanOrEqualToPlugin","OpenSearchQueryBuilderOperatorInPlugin","OpenSearchQueryBuilderOperatorLesserThanPlugin","OpenSearchQueryBuilderOperatorNotBetweenPlugin","OpenSearchQueryBuilderOperatorNotContainsPlugin","OpenSearchQueryBuilderOperatorNotPlugin","OpenSearchQueryBuilderOperatorNotInPlugin","OpenSearchQueryBuilderOperatorEqualPlugin","OpenSearchQueryBuilderOperatorStartsWithPlugin","OpenSearchQueryBuilderOperatorNotStartsWithPlugin","operators","getOpenSearchOperators"],"sources":["operators.ts"],"sourcesContent":["import {\n OpenSearchQueryBuilderOperatorBetweenPlugin,\n OpenSearchQueryBuilderOperatorAndInPlugin,\n OpenSearchQueryBuilderOperatorGreaterThanOrEqualToPlugin,\n OpenSearchQueryBuilderOperatorGreaterThanPlugin,\n OpenSearchQueryBuilderOperatorContainsPlugin,\n OpenSearchQueryBuilderOperatorLesserThanOrEqualToPlugin,\n OpenSearchQueryBuilderOperatorInPlugin,\n OpenSearchQueryBuilderOperatorLesserThanPlugin,\n OpenSearchQueryBuilderOperatorNotBetweenPlugin,\n OpenSearchQueryBuilderOperatorNotContainsPlugin,\n OpenSearchQueryBuilderOperatorNotPlugin,\n OpenSearchQueryBuilderOperatorNotInPlugin,\n OpenSearchQueryBuilderOperatorEqualPlugin,\n OpenSearchQueryBuilderOperatorStartsWithPlugin,\n OpenSearchQueryBuilderOperatorNotStartsWithPlugin\n} from \"~/plugins/operator/index.js\";\n\nconst operators = [\n new OpenSearchQueryBuilderOperatorBetweenPlugin(),\n new OpenSearchQueryBuilderOperatorNotBetweenPlugin(),\n new OpenSearchQueryBuilderOperatorContainsPlugin(),\n new OpenSearchQueryBuilderOperatorNotContainsPlugin(),\n new OpenSearchQueryBuilderOperatorEqualPlugin(),\n new OpenSearchQueryBuilderOperatorNotPlugin(),\n new OpenSearchQueryBuilderOperatorGreaterThanPlugin(),\n new OpenSearchQueryBuilderOperatorGreaterThanOrEqualToPlugin(),\n new OpenSearchQueryBuilderOperatorLesserThanPlugin(),\n new OpenSearchQueryBuilderOperatorLesserThanOrEqualToPlugin(),\n new OpenSearchQueryBuilderOperatorInPlugin(),\n new OpenSearchQueryBuilderOperatorAndInPlugin(),\n new OpenSearchQueryBuilderOperatorNotInPlugin(),\n new OpenSearchQueryBuilderOperatorStartsWithPlugin(),\n new OpenSearchQueryBuilderOperatorNotStartsWithPlugin()\n];\n/**\n * We export as a function because there might be something to be sent to the operators at some point.\n * This way, we make it easier to upgrade.\n */\nexport const getOpenSearchOperators = () => operators;\n"],"mappings":"AAAA,SACIA,2CAA2C,EAC3CC,yCAAyC,EACzCC,wDAAwD,EACxDC,+CAA+C,EAC/CC,4CAA4C,EAC5CC,uDAAuD,EACvDC,sCAAsC,EACtCC,8CAA8C,EAC9CC,8CAA8C,EAC9CC,+CAA+C,EAC/CC,uCAAuC,EACvCC,yCAAyC,EACzCC,yCAAyC,EACzCC,8CAA8C,EAC9CC,iDAAiD;AAGrD,MAAMC,SAAS,GAAG,CACd,IAAIf,2CAA2C,CAAC,CAAC,EACjD,IAAIQ,8CAA8C,CAAC,CAAC,EACpD,IAAIJ,4CAA4C,CAAC,CAAC,EAClD,IAAIK,+CAA+C,CAAC,CAAC,EACrD,IAAIG,yCAAyC,CAAC,CAAC,EAC/C,IAAIF,uCAAuC,CAAC,CAAC,EAC7C,IAAIP,+CAA+C,CAAC,CAAC,EACrD,IAAID,wDAAwD,CAAC,CAAC,EAC9D,IAAIK,8CAA8C,CAAC,CAAC,EACpD,IAAIF,uDAAuD,CAAC,CAAC,EAC7D,IAAIC,sCAAsC,CAAC,CAAC,EAC5C,IAAIL,yCAAyC,CAAC,CAAC,EAC/C,IAAIU,yCAAyC,CAAC,CAAC,EAC/C,IAAIE,8CAA8C,CAAC,CAAC,EACpD,IAAIC,iDAAiD,CAAC,CAAC,CAC1D;AACD;AACA;AACA;AACA;AACA,OAAO,MAAME,sBAAsB,GAAGA,CAAA,KAAMD,SAAS","ignoreList":[]}
1
+ {"version":3,"file":"operators.js","sources":["../src/operators.ts"],"sourcesContent":["import {\n OpenSearchQueryBuilderOperatorBetweenPlugin,\n OpenSearchQueryBuilderOperatorAndInPlugin,\n OpenSearchQueryBuilderOperatorGreaterThanOrEqualToPlugin,\n OpenSearchQueryBuilderOperatorGreaterThanPlugin,\n OpenSearchQueryBuilderOperatorContainsPlugin,\n OpenSearchQueryBuilderOperatorLesserThanOrEqualToPlugin,\n OpenSearchQueryBuilderOperatorInPlugin,\n OpenSearchQueryBuilderOperatorLesserThanPlugin,\n OpenSearchQueryBuilderOperatorNotBetweenPlugin,\n OpenSearchQueryBuilderOperatorNotContainsPlugin,\n OpenSearchQueryBuilderOperatorNotPlugin,\n OpenSearchQueryBuilderOperatorNotInPlugin,\n OpenSearchQueryBuilderOperatorEqualPlugin,\n OpenSearchQueryBuilderOperatorStartsWithPlugin,\n OpenSearchQueryBuilderOperatorNotStartsWithPlugin\n} from \"~/plugins/operator/index.js\";\n\nconst operators = [\n new OpenSearchQueryBuilderOperatorBetweenPlugin(),\n new OpenSearchQueryBuilderOperatorNotBetweenPlugin(),\n new OpenSearchQueryBuilderOperatorContainsPlugin(),\n new OpenSearchQueryBuilderOperatorNotContainsPlugin(),\n new OpenSearchQueryBuilderOperatorEqualPlugin(),\n new OpenSearchQueryBuilderOperatorNotPlugin(),\n new OpenSearchQueryBuilderOperatorGreaterThanPlugin(),\n new OpenSearchQueryBuilderOperatorGreaterThanOrEqualToPlugin(),\n new OpenSearchQueryBuilderOperatorLesserThanPlugin(),\n new OpenSearchQueryBuilderOperatorLesserThanOrEqualToPlugin(),\n new OpenSearchQueryBuilderOperatorInPlugin(),\n new OpenSearchQueryBuilderOperatorAndInPlugin(),\n new OpenSearchQueryBuilderOperatorNotInPlugin(),\n new OpenSearchQueryBuilderOperatorStartsWithPlugin(),\n new OpenSearchQueryBuilderOperatorNotStartsWithPlugin()\n];\n/**\n * We export as a function because there might be something to be sent to the operators at some point.\n * This way, we make it easier to upgrade.\n */\nexport const getOpenSearchOperators = () => operators;\n"],"names":["operators","OpenSearchQueryBuilderOperatorBetweenPlugin","OpenSearchQueryBuilderOperatorNotBetweenPlugin","OpenSearchQueryBuilderOperatorContainsPlugin","OpenSearchQueryBuilderOperatorNotContainsPlugin","OpenSearchQueryBuilderOperatorEqualPlugin","OpenSearchQueryBuilderOperatorNotPlugin","OpenSearchQueryBuilderOperatorGreaterThanPlugin","OpenSearchQueryBuilderOperatorGreaterThanOrEqualToPlugin","OpenSearchQueryBuilderOperatorLesserThanPlugin","OpenSearchQueryBuilderOperatorLesserThanOrEqualToPlugin","OpenSearchQueryBuilderOperatorInPlugin","OpenSearchQueryBuilderOperatorAndInPlugin","OpenSearchQueryBuilderOperatorNotInPlugin","OpenSearchQueryBuilderOperatorStartsWithPlugin","OpenSearchQueryBuilderOperatorNotStartsWithPlugin","getOpenSearchOperators"],"mappings":";AAkBA,MAAMA,YAAY;IACd,IAAIC;IACJ,IAAIC;IACJ,IAAIC;IACJ,IAAIC;IACJ,IAAIC;IACJ,IAAIC;IACJ,IAAIC;IACJ,IAAIC;IACJ,IAAIC;IACJ,IAAIC;IACJ,IAAIC;IACJ,IAAIC;IACJ,IAAIC;IACJ,IAAIC;IACJ,IAAIC;CACP;AAKM,MAAMC,yBAAyB,IAAMhB"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@webiny/api-opensearch",
3
- "version": "6.3.0",
3
+ "version": "6.4.0-beta.1",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": "./index.js",
@@ -18,23 +18,23 @@
18
18
  "license": "MIT",
19
19
  "dependencies": {
20
20
  "@opensearch-project/opensearch": "3.6.0",
21
- "@webiny/api": "6.3.0",
22
- "@webiny/aws-sdk": "6.3.0",
23
- "@webiny/db-dynamodb": "6.3.0",
24
- "@webiny/error": "6.3.0",
25
- "@webiny/feature": "6.3.0",
26
- "@webiny/plugins": "6.3.0"
21
+ "@webiny/api": "6.4.0-beta.1",
22
+ "@webiny/aws-sdk": "6.4.0-beta.1",
23
+ "@webiny/db-dynamodb": "6.4.0-beta.1",
24
+ "@webiny/error": "6.4.0-beta.1",
25
+ "@webiny/feature": "6.4.0-beta.1",
26
+ "@webiny/plugins": "6.4.0-beta.1"
27
27
  },
28
28
  "devDependencies": {
29
- "@webiny/build-tools": "6.3.0",
30
- "@webiny/project-utils": "6.3.0",
29
+ "@webiny/build-tools": "6.4.0-beta.1",
30
+ "@webiny/project-utils": "6.4.0-beta.1",
31
31
  "rimraf": "6.1.3",
32
32
  "typescript": "6.0.3",
33
- "vitest": "4.1.5"
33
+ "vitest": "4.1.6"
34
34
  },
35
35
  "publishConfig": {
36
36
  "access": "public",
37
37
  "directory": "dist"
38
38
  },
39
- "gitHead": "7cefe15431dbd65504e1f58147dc9e55bcbfa693"
39
+ "gitHead": "73237b8243693038c072bae1c0b783387448cbbe"
40
40
  }
@@ -1,18 +1,17 @@
1
- import WebinyError from "@webiny/error";
1
+ import error from "@webiny/error";
2
2
  import { Plugin } from "@webiny/plugins";
3
- export class OpenSearchBodyModifierPlugin extends Plugin {
4
- constructor(callable) {
5
- super();
6
- this.callable = callable;
7
- }
8
- modifyBody(params) {
9
- if (typeof this.callable !== "function") {
10
- throw new WebinyError(`Missing modification for the body.`, "BODY_MODIFICATION_MISSING", {
11
- params
12
- });
3
+ class OpenSearchBodyModifierPlugin extends Plugin {
4
+ constructor(callable){
5
+ super();
6
+ this.callable = callable;
7
+ }
8
+ modifyBody(params) {
9
+ if ("function" != typeof this.callable) throw new error("Missing modification for the body.", "BODY_MODIFICATION_MISSING", {
10
+ params
11
+ });
12
+ this.callable(params);
13
13
  }
14
- this.callable(params);
15
- }
16
14
  }
15
+ export { OpenSearchBodyModifierPlugin };
17
16
 
18
17
  //# sourceMappingURL=OpenSearchBodyModifierPlugin.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["WebinyError","Plugin","OpenSearchBodyModifierPlugin","constructor","callable","modifyBody","params"],"sources":["OpenSearchBodyModifierPlugin.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport { Plugin } from \"@webiny/plugins\";\nimport type { SearchBody } from \"~/types.js\";\n\nexport interface ModifyBodyParams {\n body: SearchBody;\n}\n\nexport interface ModifyBodyCallable<T extends ModifyBodyParams> {\n (params: T): void;\n}\n\nexport abstract class OpenSearchBodyModifierPlugin<\n T extends ModifyBodyParams = ModifyBodyParams\n> extends Plugin {\n private readonly callable?: ModifyBodyCallable<T>;\n\n public constructor(callable?: ModifyBodyCallable<T>) {\n super();\n this.callable = callable;\n }\n\n public modifyBody(params: T): void {\n if (typeof this.callable !== \"function\") {\n throw new WebinyError(\n `Missing modification for the body.`,\n \"BODY_MODIFICATION_MISSING\",\n {\n params\n }\n );\n }\n this.callable(params);\n }\n}\n"],"mappings":"AAAA,OAAOA,WAAW,MAAM,eAAe;AACvC,SAASC,MAAM,QAAQ,iBAAiB;AAWxC,OAAO,MAAeC,4BAA4B,SAExCD,MAAM,CAAC;EAGNE,WAAWA,CAACC,QAAgC,EAAE;IACjD,KAAK,CAAC,CAAC;IACP,IAAI,CAACA,QAAQ,GAAGA,QAAQ;EAC5B;EAEOC,UAAUA,CAACC,MAAS,EAAQ;IAC/B,IAAI,OAAO,IAAI,CAACF,QAAQ,KAAK,UAAU,EAAE;MACrC,MAAM,IAAIJ,WAAW,CACjB,oCAAoC,EACpC,2BAA2B,EAC3B;QACIM;MACJ,CACJ,CAAC;IACL;IACA,IAAI,CAACF,QAAQ,CAACE,MAAM,CAAC;EACzB;AACJ","ignoreList":[]}
1
+ {"version":3,"file":"plugins/definition/OpenSearchBodyModifierPlugin.js","sources":["../../../src/plugins/definition/OpenSearchBodyModifierPlugin.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport { Plugin } from \"@webiny/plugins\";\nimport type { SearchBody } from \"~/types.js\";\n\nexport interface ModifyBodyParams {\n body: SearchBody;\n}\n\nexport interface ModifyBodyCallable<T extends ModifyBodyParams> {\n (params: T): void;\n}\n\nexport abstract class OpenSearchBodyModifierPlugin<\n T extends ModifyBodyParams = ModifyBodyParams\n> extends Plugin {\n private readonly callable?: ModifyBodyCallable<T>;\n\n public constructor(callable?: ModifyBodyCallable<T>) {\n super();\n this.callable = callable;\n }\n\n public modifyBody(params: T): void {\n if (typeof this.callable !== \"function\") {\n throw new WebinyError(\n `Missing modification for the body.`,\n \"BODY_MODIFICATION_MISSING\",\n {\n params\n }\n );\n }\n this.callable(params);\n }\n}\n"],"names":["OpenSearchBodyModifierPlugin","Plugin","callable","params","WebinyError"],"mappings":";;AAYO,MAAeA,qCAEZC;IAGN,YAAmBC,QAAgC,CAAE;QACjD,KAAK;QACL,IAAI,CAAC,QAAQ,GAAGA;IACpB;IAEO,WAAWC,MAAS,EAAQ;QAC/B,IAAI,AAAyB,cAAzB,OAAO,IAAI,CAAC,QAAQ,EACpB,MAAM,IAAIC,MACN,sCACA,6BACA;YACID;QACJ;QAGR,IAAI,CAAC,QAAQ,CAACA;IAClB;AACJ"}
@@ -1,69 +1,52 @@
1
1
  import { Plugin } from "@webiny/plugins";
2
- const keywordLessUnmappedType = ["date", "long"];
3
- const unmappedTypeHasKeyword = type => {
4
- if (!type) {
2
+ const keywordLessUnmappedType = [
3
+ "date",
4
+ "long"
5
+ ];
6
+ const unmappedTypeHasKeyword = (type)=>{
7
+ if (type) {
8
+ if (keywordLessUnmappedType.includes(type)) return false;
9
+ }
5
10
  return true;
6
- } else if (keywordLessUnmappedType.includes(type)) {
7
- return false;
8
- }
9
- return true;
10
11
  };
11
- export class OpenSearchFieldPlugin extends Plugin {
12
- static type = "opensearch.fieldDefinition";
13
- static ALL = "*";
14
- constructor(params) {
15
- super();
16
- this.field = params.field;
17
- this.path = params.path || params.field;
18
- this.keyword = params.keyword === undefined ? true : params.keyword;
19
- this.unmappedType = params.unmappedType;
20
- if (unmappedTypeHasKeyword(params.unmappedType) === false) {
21
- this.keyword = false;
12
+ class OpenSearchFieldPlugin extends Plugin {
13
+ static{
14
+ this.type = "opensearch.fieldDefinition";
15
+ }
16
+ static{
17
+ this.ALL = "*";
18
+ }
19
+ constructor(params){
20
+ super();
21
+ this.field = params.field;
22
+ this.path = params.path || params.field;
23
+ this.keyword = void 0 === params.keyword ? true : params.keyword;
24
+ this.unmappedType = params.unmappedType;
25
+ if (false === unmappedTypeHasKeyword(params.unmappedType)) this.keyword = false;
26
+ this.sortable = void 0 === params.sortable ? true : params.sortable;
27
+ this.searchable = void 0 === params.searchable ? true : params.searchable;
28
+ }
29
+ getSortOptions(order) {
30
+ const options = {
31
+ order
32
+ };
33
+ if (!this.unmappedType) return options;
34
+ return {
35
+ ...options,
36
+ unmapped_type: this.unmappedType
37
+ };
38
+ }
39
+ getPath(field) {
40
+ return `${this.getBasePath(field)}${this.keyword ? ".keyword" : ""}`;
22
41
  }
23
- this.sortable = params.sortable === undefined ? true : params.sortable;
24
- this.searchable = params.searchable === undefined ? true : params.searchable;
25
- }
26
- /**
27
- * The default sort options. Extend in your own plugin if you want to add more options.
28
- */
29
- getSortOptions(order) {
30
- const options = {
31
- order
32
- };
33
- if (!this.unmappedType) {
34
- return options;
42
+ getBasePath(field) {
43
+ if (this.path === OpenSearchFieldPlugin.ALL) return field;
44
+ return this.path;
35
45
  }
36
- return {
37
- ...options,
38
- // TODO: Cast to the proper MappingFieldType once deep opensearch _types/ imports are resolvable under bundler resolution.
39
- unmapped_type: this.unmappedType
40
- };
41
- }
42
- /**
43
- * The default path generator. Extend in your own plugin if you want to add more options.
44
- * Field parameter is here because there is a possibility that this is the ALL field plugin, so we need to know which field are we working on.
45
- */
46
- getPath(field) {
47
- return `${this.getBasePath(field)}${this.keyword ? ".keyword" : ""}`;
48
- }
49
- /**
50
- * @see getPath
51
- *
52
- * This is the default base path generator. Basically it replaces ALL with given field name.
53
- */
54
- getBasePath(field) {
55
- if (this.path === OpenSearchFieldPlugin.ALL) {
56
- return field;
46
+ toSearchValue(params) {
47
+ return params.value;
57
48
  }
58
- return this.path;
59
- }
60
- /**
61
- * The default transformer. Just returns the value by default.
62
- * Override to implement what ever is required.
63
- */
64
- toSearchValue(params) {
65
- return params.value;
66
- }
67
49
  }
50
+ export { OpenSearchFieldPlugin };
68
51
 
69
52
  //# sourceMappingURL=OpenSearchFieldPlugin.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["Plugin","keywordLessUnmappedType","unmappedTypeHasKeyword","type","includes","OpenSearchFieldPlugin","ALL","constructor","params","field","path","keyword","undefined","unmappedType","sortable","searchable","getSortOptions","order","options","unmapped_type","getPath","getBasePath","toSearchValue","value"],"sources":["OpenSearchFieldPlugin.ts"],"sourcesContent":["import { Plugin } from \"@webiny/plugins\";\nimport type { FieldSortOptions, SortOrder } from \"~/types.js\";\n\nexport type UnmappedTypes = \"date\" | \"long\" | string;\n\nconst keywordLessUnmappedType = [\"date\", \"long\"];\n\nconst unmappedTypeHasKeyword = (type?: string): boolean => {\n if (!type) {\n return true;\n } else if (keywordLessUnmappedType.includes(type)) {\n return false;\n }\n return true;\n};\n\nexport interface ToSearchValueParams {\n /**\n * The value to transform.\n */\n value: any;\n /**\n * When using toSearchValue() in our code we send a field.getPath() value here.\n */\n path: string;\n /**\n * When using toSearchValue() in our code we send a field.getBasePath() value here.\n */\n basePath: string;\n}\nexport interface OpenSearchFieldPluginParams {\n /**\n * Which field is this plugin for.\n */\n field: string;\n /**\n * Some specific path of a field?\n * Example: createdBy is createdBy.id\n */\n path?: string;\n /**\n * Add a .keyword at the end of the field path?\n */\n keyword?: boolean;\n /**\n * Is the field of a specific type, but possibly not mapped?\n * Happens when inserting a date in string format.\n * You need to cast it as date when running the search/sort to work correctly.\n */\n unmappedType?: UnmappedTypes;\n /**\n * Is the field sortable?\n */\n sortable?: boolean;\n /**\n * Is the field searchable?\n */\n searchable?: boolean;\n /**\n * Used to transform the input value for the search.\n */\n toSearchValue?: (params: ToSearchValueParams) => any;\n}\n\nexport class OpenSearchFieldPlugin extends Plugin {\n public static override readonly type: string = \"opensearch.fieldDefinition\";\n public static readonly ALL: string = \"*\";\n\n public readonly field: string;\n public readonly path: string;\n public readonly keyword: boolean;\n public readonly unmappedType?: string;\n public readonly sortable: boolean;\n public readonly searchable: boolean;\n\n constructor(params: OpenSearchFieldPluginParams) {\n super();\n this.field = params.field;\n this.path = params.path || params.field;\n this.keyword = params.keyword === undefined ? true : params.keyword;\n this.unmappedType = params.unmappedType;\n if (unmappedTypeHasKeyword(params.unmappedType) === false) {\n this.keyword = false;\n }\n this.sortable = params.sortable === undefined ? true : params.sortable;\n this.searchable = params.searchable === undefined ? true : params.searchable;\n }\n /**\n * The default sort options. Extend in your own plugin if you want to add more options.\n */\n public getSortOptions(order: SortOrder): FieldSortOptions {\n const options = {\n order\n };\n if (!this.unmappedType) {\n return options;\n }\n return {\n ...options,\n // TODO: Cast to the proper MappingFieldType once deep opensearch _types/ imports are resolvable under bundler resolution.\n unmapped_type: this.unmappedType as any\n };\n }\n /**\n * The default path generator. Extend in your own plugin if you want to add more options.\n * Field parameter is here because there is a possibility that this is the ALL field plugin, so we need to know which field are we working on.\n */\n public getPath(field: string): string {\n return `${this.getBasePath(field)}${this.keyword ? \".keyword\" : \"\"}`;\n }\n /**\n * @see getPath\n *\n * This is the default base path generator. Basically it replaces ALL with given field name.\n */\n public getBasePath(field: string): string {\n if (this.path === OpenSearchFieldPlugin.ALL) {\n return field;\n }\n return this.path;\n }\n /**\n * The default transformer. Just returns the value by default.\n * Override to implement what ever is required.\n */\n public toSearchValue(params: ToSearchValueParams): any {\n return params.value;\n }\n}\n"],"mappings":"AAAA,SAASA,MAAM,QAAQ,iBAAiB;AAKxC,MAAMC,uBAAuB,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC;AAEhD,MAAMC,sBAAsB,GAAIC,IAAa,IAAc;EACvD,IAAI,CAACA,IAAI,EAAE;IACP,OAAO,IAAI;EACf,CAAC,MAAM,IAAIF,uBAAuB,CAACG,QAAQ,CAACD,IAAI,CAAC,EAAE;IAC/C,OAAO,KAAK;EAChB;EACA,OAAO,IAAI;AACf,CAAC;AAkDD,OAAO,MAAME,qBAAqB,SAASL,MAAM,CAAC;EAC9C,OAAgCG,IAAI,GAAW,4BAA4B;EAC3E,OAAuBG,GAAG,GAAW,GAAG;EASxCC,WAAWA,CAACC,MAAmC,EAAE;IAC7C,KAAK,CAAC,CAAC;IACP,IAAI,CAACC,KAAK,GAAGD,MAAM,CAACC,KAAK;IACzB,IAAI,CAACC,IAAI,GAAGF,MAAM,CAACE,IAAI,IAAIF,MAAM,CAACC,KAAK;IACvC,IAAI,CAACE,OAAO,GAAGH,MAAM,CAACG,OAAO,KAAKC,SAAS,GAAG,IAAI,GAAGJ,MAAM,CAACG,OAAO;IACnE,IAAI,CAACE,YAAY,GAAGL,MAAM,CAACK,YAAY;IACvC,IAAIX,sBAAsB,CAACM,MAAM,CAACK,YAAY,CAAC,KAAK,KAAK,EAAE;MACvD,IAAI,CAACF,OAAO,GAAG,KAAK;IACxB;IACA,IAAI,CAACG,QAAQ,GAAGN,MAAM,CAACM,QAAQ,KAAKF,SAAS,GAAG,IAAI,GAAGJ,MAAM,CAACM,QAAQ;IACtE,IAAI,CAACC,UAAU,GAAGP,MAAM,CAACO,UAAU,KAAKH,SAAS,GAAG,IAAI,GAAGJ,MAAM,CAACO,UAAU;EAChF;EACA;AACJ;AACA;EACWC,cAAcA,CAACC,KAAgB,EAAoB;IACtD,MAAMC,OAAO,GAAG;MACZD;IACJ,CAAC;IACD,IAAI,CAAC,IAAI,CAACJ,YAAY,EAAE;MACpB,OAAOK,OAAO;IAClB;IACA,OAAO;MACH,GAAGA,OAAO;MACV;MACAC,aAAa,EAAE,IAAI,CAACN;IACxB,CAAC;EACL;EACA;AACJ;AACA;AACA;EACWO,OAAOA,CAACX,KAAa,EAAU;IAClC,OAAO,GAAG,IAAI,CAACY,WAAW,CAACZ,KAAK,CAAC,GAAG,IAAI,CAACE,OAAO,GAAG,UAAU,GAAG,EAAE,EAAE;EACxE;EACA;AACJ;AACA;AACA;AACA;EACWU,WAAWA,CAACZ,KAAa,EAAU;IACtC,IAAI,IAAI,CAACC,IAAI,KAAKL,qBAAqB,CAACC,GAAG,EAAE;MACzC,OAAOG,KAAK;IAChB;IACA,OAAO,IAAI,CAACC,IAAI;EACpB;EACA;AACJ;AACA;AACA;EACWY,aAAaA,CAACd,MAA2B,EAAO;IACnD,OAAOA,MAAM,CAACe,KAAK;EACvB;AACJ","ignoreList":[]}
1
+ {"version":3,"file":"plugins/definition/OpenSearchFieldPlugin.js","sources":["../../../src/plugins/definition/OpenSearchFieldPlugin.ts"],"sourcesContent":["import { Plugin } from \"@webiny/plugins\";\nimport type { FieldSortOptions, SortOrder } from \"~/types.js\";\n\nexport type UnmappedTypes = \"date\" | \"long\" | string;\n\nconst keywordLessUnmappedType = [\"date\", \"long\"];\n\nconst unmappedTypeHasKeyword = (type?: string): boolean => {\n if (!type) {\n return true;\n } else if (keywordLessUnmappedType.includes(type)) {\n return false;\n }\n return true;\n};\n\nexport interface ToSearchValueParams {\n /**\n * The value to transform.\n */\n value: any;\n /**\n * When using toSearchValue() in our code we send a field.getPath() value here.\n */\n path: string;\n /**\n * When using toSearchValue() in our code we send a field.getBasePath() value here.\n */\n basePath: string;\n}\nexport interface OpenSearchFieldPluginParams {\n /**\n * Which field is this plugin for.\n */\n field: string;\n /**\n * Some specific path of a field?\n * Example: createdBy is createdBy.id\n */\n path?: string;\n /**\n * Add a .keyword at the end of the field path?\n */\n keyword?: boolean;\n /**\n * Is the field of a specific type, but possibly not mapped?\n * Happens when inserting a date in string format.\n * You need to cast it as date when running the search/sort to work correctly.\n */\n unmappedType?: UnmappedTypes;\n /**\n * Is the field sortable?\n */\n sortable?: boolean;\n /**\n * Is the field searchable?\n */\n searchable?: boolean;\n /**\n * Used to transform the input value for the search.\n */\n toSearchValue?: (params: ToSearchValueParams) => any;\n}\n\nexport class OpenSearchFieldPlugin extends Plugin {\n public static override readonly type: string = \"opensearch.fieldDefinition\";\n public static readonly ALL: string = \"*\";\n\n public readonly field: string;\n public readonly path: string;\n public readonly keyword: boolean;\n public readonly unmappedType?: string;\n public readonly sortable: boolean;\n public readonly searchable: boolean;\n\n constructor(params: OpenSearchFieldPluginParams) {\n super();\n this.field = params.field;\n this.path = params.path || params.field;\n this.keyword = params.keyword === undefined ? true : params.keyword;\n this.unmappedType = params.unmappedType;\n if (unmappedTypeHasKeyword(params.unmappedType) === false) {\n this.keyword = false;\n }\n this.sortable = params.sortable === undefined ? true : params.sortable;\n this.searchable = params.searchable === undefined ? true : params.searchable;\n }\n /**\n * The default sort options. Extend in your own plugin if you want to add more options.\n */\n public getSortOptions(order: SortOrder): FieldSortOptions {\n const options = {\n order\n };\n if (!this.unmappedType) {\n return options;\n }\n return {\n ...options,\n // TODO: Cast to the proper MappingFieldType once deep opensearch _types/ imports are resolvable under bundler resolution.\n unmapped_type: this.unmappedType as any\n };\n }\n /**\n * The default path generator. Extend in your own plugin if you want to add more options.\n * Field parameter is here because there is a possibility that this is the ALL field plugin, so we need to know which field are we working on.\n */\n public getPath(field: string): string {\n return `${this.getBasePath(field)}${this.keyword ? \".keyword\" : \"\"}`;\n }\n /**\n * @see getPath\n *\n * This is the default base path generator. Basically it replaces ALL with given field name.\n */\n public getBasePath(field: string): string {\n if (this.path === OpenSearchFieldPlugin.ALL) {\n return field;\n }\n return this.path;\n }\n /**\n * The default transformer. Just returns the value by default.\n * Override to implement what ever is required.\n */\n public toSearchValue(params: ToSearchValueParams): any {\n return params.value;\n }\n}\n"],"names":["keywordLessUnmappedType","unmappedTypeHasKeyword","type","OpenSearchFieldPlugin","Plugin","params","undefined","order","options","field"],"mappings":";AAKA,MAAMA,0BAA0B;IAAC;IAAQ;CAAO;AAEhD,MAAMC,yBAAyB,CAACC;IAC5B,IAAKA,MAEE;QAAA,IAAIF,wBAAwB,QAAQ,CAACE,OACxC,OAAO;IACX;IACA,OAAO;AACX;AAkDO,MAAMC,8BAA8BC;;aACP,IAAI,GAAW;;;aACxB,GAAG,GAAW;;IASrC,YAAYC,MAAmC,CAAE;QAC7C,KAAK;QACL,IAAI,CAAC,KAAK,GAAGA,OAAO,KAAK;QACzB,IAAI,CAAC,IAAI,GAAGA,OAAO,IAAI,IAAIA,OAAO,KAAK;QACvC,IAAI,CAAC,OAAO,GAAGA,AAAmBC,WAAnBD,OAAO,OAAO,GAAiB,OAAOA,OAAO,OAAO;QACnE,IAAI,CAAC,YAAY,GAAGA,OAAO,YAAY;QACvC,IAAIJ,AAAgD,UAAhDA,uBAAuBI,OAAO,YAAY,GAC1C,IAAI,CAAC,OAAO,GAAG;QAEnB,IAAI,CAAC,QAAQ,GAAGA,AAAoBC,WAApBD,OAAO,QAAQ,GAAiB,OAAOA,OAAO,QAAQ;QACtE,IAAI,CAAC,UAAU,GAAGA,AAAsBC,WAAtBD,OAAO,UAAU,GAAiB,OAAOA,OAAO,UAAU;IAChF;IAIO,eAAeE,KAAgB,EAAoB;QACtD,MAAMC,UAAU;YACZD;QACJ;QACA,IAAI,CAAC,IAAI,CAAC,YAAY,EAClB,OAAOC;QAEX,OAAO;YACH,GAAGA,OAAO;YAEV,eAAe,IAAI,CAAC,YAAY;QACpC;IACJ;IAKO,QAAQC,KAAa,EAAU;QAClC,OAAO,GAAG,IAAI,CAAC,WAAW,CAACA,SAAS,IAAI,CAAC,OAAO,GAAG,aAAa,IAAI;IACxE;IAMO,YAAYA,KAAa,EAAU;QACtC,IAAI,IAAI,CAAC,IAAI,KAAKN,sBAAsB,GAAG,EACvC,OAAOM;QAEX,OAAO,IAAI,CAAC,IAAI;IACpB;IAKO,cAAcJ,MAA2B,EAAO;QACnD,OAAOA,OAAO,KAAK;IACvB;AACJ"}
@@ -1,17 +1,16 @@
1
1
  import { Plugin } from "@webiny/plugins";
2
- export class OpenSearchIndexPlugin extends Plugin {
3
- constructor(params) {
4
- super();
5
- const {
6
- body
7
- } = params;
8
- this.body = {
9
- ...body
10
- };
11
- }
12
- canUse() {
13
- return true;
14
- }
2
+ class OpenSearchIndexPlugin extends Plugin {
3
+ constructor(params){
4
+ super();
5
+ const { body } = params;
6
+ this.body = {
7
+ ...body
8
+ };
9
+ }
10
+ canUse() {
11
+ return true;
12
+ }
15
13
  }
14
+ export { OpenSearchIndexPlugin };
16
15
 
17
16
  //# sourceMappingURL=OpenSearchIndexPlugin.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["Plugin","OpenSearchIndexPlugin","constructor","params","body","canUse"],"sources":["OpenSearchIndexPlugin.ts"],"sourcesContent":["import { Plugin } from \"@webiny/plugins\";\nimport type { OpenSearchIndexRequestBody } from \"~/types.js\";\n\nexport interface OpenSearchIndexPluginParams {\n body: OpenSearchIndexRequestBody;\n}\n\nexport abstract class OpenSearchIndexPlugin extends Plugin {\n public readonly body: OpenSearchIndexRequestBody;\n\n public constructor(params: OpenSearchIndexPluginParams) {\n super();\n const { body } = params;\n this.body = {\n ...body\n };\n }\n\n public canUse(): boolean {\n return true;\n }\n}\n"],"mappings":"AAAA,SAASA,MAAM,QAAQ,iBAAiB;AAOxC,OAAO,MAAeC,qBAAqB,SAASD,MAAM,CAAC;EAGhDE,WAAWA,CAACC,MAAmC,EAAE;IACpD,KAAK,CAAC,CAAC;IACP,MAAM;MAAEC;IAAK,CAAC,GAAGD,MAAM;IACvB,IAAI,CAACC,IAAI,GAAG;MACR,GAAGA;IACP,CAAC;EACL;EAEOC,MAAMA,CAAA,EAAY;IACrB,OAAO,IAAI;EACf;AACJ","ignoreList":[]}
1
+ {"version":3,"file":"plugins/definition/OpenSearchIndexPlugin.js","sources":["../../../src/plugins/definition/OpenSearchIndexPlugin.ts"],"sourcesContent":["import { Plugin } from \"@webiny/plugins\";\nimport type { OpenSearchIndexRequestBody } from \"~/types.js\";\n\nexport interface OpenSearchIndexPluginParams {\n body: OpenSearchIndexRequestBody;\n}\n\nexport abstract class OpenSearchIndexPlugin extends Plugin {\n public readonly body: OpenSearchIndexRequestBody;\n\n public constructor(params: OpenSearchIndexPluginParams) {\n super();\n const { body } = params;\n this.body = {\n ...body\n };\n }\n\n public canUse(): boolean {\n return true;\n }\n}\n"],"names":["OpenSearchIndexPlugin","Plugin","params","body"],"mappings":";AAOO,MAAeA,8BAA8BC;IAGhD,YAAmBC,MAAmC,CAAE;QACpD,KAAK;QACL,MAAM,EAAEC,IAAI,EAAE,GAAGD;QACjB,IAAI,CAAC,IAAI,GAAG;YACR,GAAGC,IAAI;QACX;IACJ;IAEO,SAAkB;QACrB,OAAO;IACX;AACJ"}
@@ -1,9 +1,9 @@
1
1
  import { Plugin } from "@webiny/plugins";
2
- /**
3
- * Built-in operators name ends with .default because user can override the operator, just write a name without the .default keyword.
4
- */
5
- export class OpenSearchQueryBuilderOperatorPlugin extends Plugin {
6
- static type = "opensearch.queryBuilder.operator";
2
+ class OpenSearchQueryBuilderOperatorPlugin extends Plugin {
3
+ static{
4
+ this.type = "opensearch.queryBuilder.operator";
5
+ }
7
6
  }
7
+ export { OpenSearchQueryBuilderOperatorPlugin };
8
8
 
9
9
  //# sourceMappingURL=OpenSearchQueryBuilderOperatorPlugin.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["Plugin","OpenSearchQueryBuilderOperatorPlugin","type"],"sources":["OpenSearchQueryBuilderOperatorPlugin.ts"],"sourcesContent":["import { Plugin } from \"@webiny/plugins\";\nimport type { OpenSearchBoolQueryConfig, OpenSearchQueryBuilderArgsPlugin } from \"~/types.js\";\n\n/**\n * Built-in operators name ends with .default because user can override the operator, just write a name without the .default keyword.\n */\nexport abstract class OpenSearchQueryBuilderOperatorPlugin extends Plugin {\n public static override readonly type: string = \"opensearch.queryBuilder.operator\";\n\n public abstract getOperator(): string;\n\n public abstract apply(\n query: OpenSearchBoolQueryConfig,\n params: OpenSearchQueryBuilderArgsPlugin\n ): void;\n}\n"],"mappings":"AAAA,SAASA,MAAM,QAAQ,iBAAiB;AAGxC;AACA;AACA;AACA,OAAO,MAAeC,oCAAoC,SAASD,MAAM,CAAC;EACtE,OAAgCE,IAAI,GAAW,kCAAkC;AAQrF","ignoreList":[]}
1
+ {"version":3,"file":"plugins/definition/OpenSearchQueryBuilderOperatorPlugin.js","sources":["../../../src/plugins/definition/OpenSearchQueryBuilderOperatorPlugin.ts"],"sourcesContent":["import { Plugin } from \"@webiny/plugins\";\nimport type { OpenSearchBoolQueryConfig, OpenSearchQueryBuilderArgsPlugin } from \"~/types.js\";\n\n/**\n * Built-in operators name ends with .default because user can override the operator, just write a name without the .default keyword.\n */\nexport abstract class OpenSearchQueryBuilderOperatorPlugin extends Plugin {\n public static override readonly type: string = \"opensearch.queryBuilder.operator\";\n\n public abstract getOperator(): string;\n\n public abstract apply(\n query: OpenSearchBoolQueryConfig,\n params: OpenSearchQueryBuilderArgsPlugin\n ): void;\n}\n"],"names":["OpenSearchQueryBuilderOperatorPlugin","Plugin"],"mappings":";AAMO,MAAeA,6CAA6CC;;aAC/B,IAAI,GAAW;;AAQnD"}
@@ -1,18 +1,17 @@
1
- import WebinyError from "@webiny/error";
1
+ import error from "@webiny/error";
2
2
  import { Plugin } from "@webiny/plugins";
3
- export class OpenSearchQueryModifierPlugin extends Plugin {
4
- constructor(callable) {
5
- super();
6
- this.callable = callable;
7
- }
8
- modifyQuery(params) {
9
- if (typeof this.callable !== "function") {
10
- throw new WebinyError(`Missing modification for the query.`, "QUERY_MODIFICATION_MISSING", {
11
- params
12
- });
3
+ class OpenSearchQueryModifierPlugin extends Plugin {
4
+ constructor(callable){
5
+ super();
6
+ this.callable = callable;
7
+ }
8
+ modifyQuery(params) {
9
+ if ("function" != typeof this.callable) throw new error("Missing modification for the query.", "QUERY_MODIFICATION_MISSING", {
10
+ params
11
+ });
12
+ this.callable(params);
13
13
  }
14
- this.callable(params);
15
- }
16
14
  }
15
+ export { OpenSearchQueryModifierPlugin };
17
16
 
18
17
  //# sourceMappingURL=OpenSearchQueryModifierPlugin.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["WebinyError","Plugin","OpenSearchQueryModifierPlugin","constructor","callable","modifyQuery","params"],"sources":["OpenSearchQueryModifierPlugin.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport { Plugin } from \"@webiny/plugins\";\nimport type { OpenSearchBoolQueryConfig } from \"~/types.js\";\n\nexport interface ModifyQueryParams {\n query: OpenSearchBoolQueryConfig;\n where: Record<string, any>;\n}\n\nexport interface ModifyQueryCallable<T extends ModifyQueryParams> {\n (params: T): void;\n}\n\nexport abstract class OpenSearchQueryModifierPlugin<\n T extends ModifyQueryParams = ModifyQueryParams\n> extends Plugin {\n private readonly callable?: ModifyQueryCallable<T>;\n\n public constructor(callable?: ModifyQueryCallable<T>) {\n super();\n this.callable = callable;\n }\n\n public modifyQuery(params: T): void {\n if (typeof this.callable !== \"function\") {\n throw new WebinyError(\n `Missing modification for the query.`,\n \"QUERY_MODIFICATION_MISSING\",\n {\n params\n }\n );\n }\n this.callable(params);\n }\n}\n"],"mappings":"AAAA,OAAOA,WAAW,MAAM,eAAe;AACvC,SAASC,MAAM,QAAQ,iBAAiB;AAYxC,OAAO,MAAeC,6BAA6B,SAEzCD,MAAM,CAAC;EAGNE,WAAWA,CAACC,QAAiC,EAAE;IAClD,KAAK,CAAC,CAAC;IACP,IAAI,CAACA,QAAQ,GAAGA,QAAQ;EAC5B;EAEOC,WAAWA,CAACC,MAAS,EAAQ;IAChC,IAAI,OAAO,IAAI,CAACF,QAAQ,KAAK,UAAU,EAAE;MACrC,MAAM,IAAIJ,WAAW,CACjB,qCAAqC,EACrC,4BAA4B,EAC5B;QACIM;MACJ,CACJ,CAAC;IACL;IACA,IAAI,CAACF,QAAQ,CAACE,MAAM,CAAC;EACzB;AACJ","ignoreList":[]}
1
+ {"version":3,"file":"plugins/definition/OpenSearchQueryModifierPlugin.js","sources":["../../../src/plugins/definition/OpenSearchQueryModifierPlugin.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport { Plugin } from \"@webiny/plugins\";\nimport type { OpenSearchBoolQueryConfig } from \"~/types.js\";\n\nexport interface ModifyQueryParams {\n query: OpenSearchBoolQueryConfig;\n where: Record<string, any>;\n}\n\nexport interface ModifyQueryCallable<T extends ModifyQueryParams> {\n (params: T): void;\n}\n\nexport abstract class OpenSearchQueryModifierPlugin<\n T extends ModifyQueryParams = ModifyQueryParams\n> extends Plugin {\n private readonly callable?: ModifyQueryCallable<T>;\n\n public constructor(callable?: ModifyQueryCallable<T>) {\n super();\n this.callable = callable;\n }\n\n public modifyQuery(params: T): void {\n if (typeof this.callable !== \"function\") {\n throw new WebinyError(\n `Missing modification for the query.`,\n \"QUERY_MODIFICATION_MISSING\",\n {\n params\n }\n );\n }\n this.callable(params);\n }\n}\n"],"names":["OpenSearchQueryModifierPlugin","Plugin","callable","params","WebinyError"],"mappings":";;AAaO,MAAeA,sCAEZC;IAGN,YAAmBC,QAAiC,CAAE;QAClD,KAAK;QACL,IAAI,CAAC,QAAQ,GAAGA;IACpB;IAEO,YAAYC,MAAS,EAAQ;QAChC,IAAI,AAAyB,cAAzB,OAAO,IAAI,CAAC,QAAQ,EACpB,MAAM,IAAIC,MACN,uCACA,8BACA;YACID;QACJ;QAGR,IAAI,CAAC,QAAQ,CAACA;IAClB;AACJ"}
@@ -1,18 +1,17 @@
1
- import WebinyError from "@webiny/error";
1
+ import error from "@webiny/error";
2
2
  import { Plugin } from "@webiny/plugins";
3
- export class OpenSearchSortModifierPlugin extends Plugin {
4
- constructor(callable) {
5
- super();
6
- this.callable = callable;
7
- }
8
- modifySort(params) {
9
- if (typeof this.callable !== "function") {
10
- throw new WebinyError(`Missing modification for the sort.`, "SORT_MODIFICATION_MISSING", {
11
- params
12
- });
3
+ class OpenSearchSortModifierPlugin extends Plugin {
4
+ constructor(callable){
5
+ super();
6
+ this.callable = callable;
7
+ }
8
+ modifySort(params) {
9
+ if ("function" != typeof this.callable) throw new error("Missing modification for the sort.", "SORT_MODIFICATION_MISSING", {
10
+ params
11
+ });
12
+ this.callable(params);
13
13
  }
14
- this.callable(params);
15
- }
16
14
  }
15
+ export { OpenSearchSortModifierPlugin };
17
16
 
18
17
  //# sourceMappingURL=OpenSearchSortModifierPlugin.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["WebinyError","Plugin","OpenSearchSortModifierPlugin","constructor","callable","modifySort","params"],"sources":["OpenSearchSortModifierPlugin.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport { Plugin } from \"@webiny/plugins\";\nimport type { Sort } from \"~/types.js\";\n\nexport interface ModifySortParams {\n sort: Sort;\n}\n\nexport interface ModifySortCallable<T extends ModifySortParams> {\n (params: T): void;\n}\n\nexport abstract class OpenSearchSortModifierPlugin<\n T extends ModifySortParams = ModifySortParams\n> extends Plugin {\n private readonly callable?: ModifySortCallable<T>;\n\n public constructor(callable?: ModifySortCallable<T>) {\n super();\n this.callable = callable;\n }\n\n public modifySort(params: T): void {\n if (typeof this.callable !== \"function\") {\n throw new WebinyError(\n `Missing modification for the sort.`,\n \"SORT_MODIFICATION_MISSING\",\n {\n params\n }\n );\n }\n this.callable(params);\n }\n}\n"],"mappings":"AAAA,OAAOA,WAAW,MAAM,eAAe;AACvC,SAASC,MAAM,QAAQ,iBAAiB;AAWxC,OAAO,MAAeC,4BAA4B,SAExCD,MAAM,CAAC;EAGNE,WAAWA,CAACC,QAAgC,EAAE;IACjD,KAAK,CAAC,CAAC;IACP,IAAI,CAACA,QAAQ,GAAGA,QAAQ;EAC5B;EAEOC,UAAUA,CAACC,MAAS,EAAQ;IAC/B,IAAI,OAAO,IAAI,CAACF,QAAQ,KAAK,UAAU,EAAE;MACrC,MAAM,IAAIJ,WAAW,CACjB,oCAAoC,EACpC,2BAA2B,EAC3B;QACIM;MACJ,CACJ,CAAC;IACL;IACA,IAAI,CAACF,QAAQ,CAACE,MAAM,CAAC;EACzB;AACJ","ignoreList":[]}
1
+ {"version":3,"file":"plugins/definition/OpenSearchSortModifierPlugin.js","sources":["../../../src/plugins/definition/OpenSearchSortModifierPlugin.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport { Plugin } from \"@webiny/plugins\";\nimport type { Sort } from \"~/types.js\";\n\nexport interface ModifySortParams {\n sort: Sort;\n}\n\nexport interface ModifySortCallable<T extends ModifySortParams> {\n (params: T): void;\n}\n\nexport abstract class OpenSearchSortModifierPlugin<\n T extends ModifySortParams = ModifySortParams\n> extends Plugin {\n private readonly callable?: ModifySortCallable<T>;\n\n public constructor(callable?: ModifySortCallable<T>) {\n super();\n this.callable = callable;\n }\n\n public modifySort(params: T): void {\n if (typeof this.callable !== \"function\") {\n throw new WebinyError(\n `Missing modification for the sort.`,\n \"SORT_MODIFICATION_MISSING\",\n {\n params\n }\n );\n }\n this.callable(params);\n }\n}\n"],"names":["OpenSearchSortModifierPlugin","Plugin","callable","params","WebinyError"],"mappings":";;AAYO,MAAeA,qCAEZC;IAGN,YAAmBC,QAAgC,CAAE;QACjD,KAAK;QACL,IAAI,CAAC,QAAQ,GAAGA;IACpB;IAEO,WAAWC,MAAS,EAAQ;QAC/B,IAAI,AAAyB,cAAzB,OAAO,IAAI,CAAC,QAAQ,EACpB,MAAM,IAAIC,MACN,sCACA,6BACA;YACID;QACJ;QAGR,IAAI,CAAC,QAAQ,CAACA;IAClB;AACJ"}
@@ -4,5 +4,3 @@ export * from "./OpenSearchIndexPlugin.js";
4
4
  export * from "./OpenSearchQueryBuilderOperatorPlugin.js";
5
5
  export * from "./OpenSearchQueryModifierPlugin.js";
6
6
  export * from "./OpenSearchSortModifierPlugin.js";
7
-
8
- //# sourceMappingURL=index.js.map
package/plugins/index.js CHANGED
@@ -1,4 +1,2 @@
1
1
  export * from "./definition/index.js";
2
2
  export * from "./operator/index.js";
3
-
4
- //# sourceMappingURL=index.js.map
@@ -1,35 +1,27 @@
1
1
  import { OpenSearchQueryBuilderOperatorPlugin } from "../definition/OpenSearchQueryBuilderOperatorPlugin.js";
2
- export class OpenSearchQueryBuilderOperatorAndInPlugin extends OpenSearchQueryBuilderOperatorPlugin {
3
- name = "opensearch.queryBuilder.operator.andIn.default";
4
- getOperator() {
5
- return "and_in";
6
- }
7
- apply(query, params) {
8
- const {
9
- value: values,
10
- path,
11
- basePath
12
- } = params;
13
- const isArray = Array.isArray(values);
14
- if (isArray === false || values.length === 0) {
15
- throw new Error(`You cannot filter field "${path}" with "in" operator and not send an array of values.`);
2
+ class OpenSearchQueryBuilderOperatorAndInPlugin extends OpenSearchQueryBuilderOperatorPlugin {
3
+ getOperator() {
4
+ return "and_in";
16
5
  }
17
- let useBasePath = false;
18
- // Only use ".keyword" if all of the provided values are strings.
19
- for (const value of values) {
20
- if (typeof value !== "string") {
21
- useBasePath = true;
22
- break;
23
- }
24
- }
25
- for (const value of values) {
26
- query.filter.push({
27
- term: {
28
- [useBasePath ? basePath : path]: value
6
+ apply(query, params) {
7
+ const { value: values, path, basePath } = params;
8
+ const isArray = Array.isArray(values);
9
+ if (false === isArray || 0 === values.length) throw new Error(`You cannot filter field "${path}" with "in" operator and not send an array of values.`);
10
+ let useBasePath = false;
11
+ for (const value of values)if ("string" != typeof value) {
12
+ useBasePath = true;
13
+ break;
29
14
  }
30
- });
15
+ for (const value of values)query.filter.push({
16
+ term: {
17
+ [useBasePath ? basePath : path]: value
18
+ }
19
+ });
20
+ }
21
+ constructor(...args){
22
+ super(...args), this.name = "opensearch.queryBuilder.operator.andIn.default";
31
23
  }
32
- }
33
24
  }
25
+ export { OpenSearchQueryBuilderOperatorAndInPlugin };
34
26
 
35
27
  //# sourceMappingURL=andIn.js.map