@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 +1 @@
1
- {"version":3,"names":["OpenSearchQueryBuilderOperatorPlugin","OpenSearchQueryBuilderOperatorNotPlugin","name","getOperator","apply","query","params","value","path","basePath","undefined","filter","push","exists","field","typeOf","bool","must_not","term","useBasePath","valuePath"],"sources":["not.ts"],"sourcesContent":["import { OpenSearchQueryBuilderOperatorPlugin } from \"~/plugins/definition/OpenSearchQueryBuilderOperatorPlugin.js\";\nimport type { OpenSearchBoolQueryConfig, OpenSearchQueryBuilderArgsPlugin } from \"~/types.js\";\n\nexport class OpenSearchQueryBuilderOperatorNotPlugin extends OpenSearchQueryBuilderOperatorPlugin {\n public override name = \"opensearch.queryBuilder.operator.not.default\";\n\n public getOperator(): string {\n return \"not\";\n }\n\n public apply(query: OpenSearchBoolQueryConfig, params: OpenSearchQueryBuilderArgsPlugin): void {\n const { value, path, basePath } = params;\n\n if (value === null || value === undefined) {\n query.filter.push({\n exists: {\n field: path\n }\n });\n return;\n }\n\n const typeOf = typeof value;\n\n if (typeOf === \"boolean\") {\n query.filter.push({\n bool: {\n must_not: {\n term: {\n [path]: value\n }\n }\n }\n });\n return;\n }\n\n const useBasePath = typeOf !== \"string\";\n const valuePath = useBasePath ? basePath : path;\n query.must_not.push({\n term: {\n [valuePath]: value\n }\n });\n }\n}\n"],"mappings":"AAAA,SAASA,oCAAoC;AAG7C,OAAO,MAAMC,uCAAuC,SAASD,oCAAoC,CAAC;EAC9EE,IAAI,GAAG,8CAA8C;EAE9DC,WAAWA,CAAA,EAAW;IACzB,OAAO,KAAK;EAChB;EAEOC,KAAKA,CAACC,KAAgC,EAAEC,MAAwC,EAAQ;IAC3F,MAAM;MAAEC,KAAK;MAAEC,IAAI;MAAEC;IAAS,CAAC,GAAGH,MAAM;IAExC,IAAIC,KAAK,KAAK,IAAI,IAAIA,KAAK,KAAKG,SAAS,EAAE;MACvCL,KAAK,CAACM,MAAM,CAACC,IAAI,CAAC;QACdC,MAAM,EAAE;UACJC,KAAK,EAAEN;QACX;MACJ,CAAC,CAAC;MACF;IACJ;IAEA,MAAMO,MAAM,GAAG,OAAOR,KAAK;IAE3B,IAAIQ,MAAM,KAAK,SAAS,EAAE;MACtBV,KAAK,CAACM,MAAM,CAACC,IAAI,CAAC;QACdI,IAAI,EAAE;UACFC,QAAQ,EAAE;YACNC,IAAI,EAAE;cACF,CAACV,IAAI,GAAGD;YACZ;UACJ;QACJ;MACJ,CAAC,CAAC;MACF;IACJ;IAEA,MAAMY,WAAW,GAAGJ,MAAM,KAAK,QAAQ;IACvC,MAAMK,SAAS,GAAGD,WAAW,GAAGV,QAAQ,GAAGD,IAAI;IAC/CH,KAAK,CAACY,QAAQ,CAACL,IAAI,CAAC;MAChBM,IAAI,EAAE;QACF,CAACE,SAAS,GAAGb;MACjB;IACJ,CAAC,CAAC;EACN;AACJ","ignoreList":[]}
1
+ {"version":3,"file":"plugins/operator/not.js","sources":["../../../src/plugins/operator/not.ts"],"sourcesContent":["import { OpenSearchQueryBuilderOperatorPlugin } from \"~/plugins/definition/OpenSearchQueryBuilderOperatorPlugin.js\";\nimport type { OpenSearchBoolQueryConfig, OpenSearchQueryBuilderArgsPlugin } from \"~/types.js\";\n\nexport class OpenSearchQueryBuilderOperatorNotPlugin extends OpenSearchQueryBuilderOperatorPlugin {\n public override name = \"opensearch.queryBuilder.operator.not.default\";\n\n public getOperator(): string {\n return \"not\";\n }\n\n public apply(query: OpenSearchBoolQueryConfig, params: OpenSearchQueryBuilderArgsPlugin): void {\n const { value, path, basePath } = params;\n\n if (value === null || value === undefined) {\n query.filter.push({\n exists: {\n field: path\n }\n });\n return;\n }\n\n const typeOf = typeof value;\n\n if (typeOf === \"boolean\") {\n query.filter.push({\n bool: {\n must_not: {\n term: {\n [path]: value\n }\n }\n }\n });\n return;\n }\n\n const useBasePath = typeOf !== \"string\";\n const valuePath = useBasePath ? basePath : path;\n query.must_not.push({\n term: {\n [valuePath]: value\n }\n });\n }\n}\n"],"names":["OpenSearchQueryBuilderOperatorNotPlugin","OpenSearchQueryBuilderOperatorPlugin","query","params","value","path","basePath","typeOf","useBasePath","valuePath"],"mappings":";AAGO,MAAMA,gDAAgDC;IAGlD,cAAsB;QACzB,OAAO;IACX;IAEO,MAAMC,KAAgC,EAAEC,MAAwC,EAAQ;QAC3F,MAAM,EAAEC,KAAK,EAAEC,IAAI,EAAEC,QAAQ,EAAE,GAAGH;QAElC,IAAIC,QAAAA,OAAuC,YACvCF,MAAM,MAAM,CAAC,IAAI,CAAC;YACd,QAAQ;gBACJ,OAAOG;YACX;QACJ;QAIJ,MAAME,SAAS,OAAOH;QAEtB,IAAIG,AAAW,cAAXA,QAAsB,YACtBL,MAAM,MAAM,CAAC,IAAI,CAAC;YACd,MAAM;gBACF,UAAU;oBACN,MAAM;wBACF,CAACG,KAAK,EAAED;oBACZ;gBACJ;YACJ;QACJ;QAIJ,MAAMI,cAAcD,AAAW,aAAXA;QACpB,MAAME,YAAYD,cAAcF,WAAWD;QAC3CH,MAAM,QAAQ,CAAC,IAAI,CAAC;YAChB,MAAM;gBACF,CAACO,UAAU,EAAEL;YACjB;QACJ;IACJ;;QAzCG,qBACa,IAAI,GAAG;;AAyC3B"}
@@ -1,32 +1,26 @@
1
1
  import { OpenSearchQueryBuilderOperatorPlugin } from "../definition/OpenSearchQueryBuilderOperatorPlugin.js";
2
- export class OpenSearchQueryBuilderOperatorNotBetweenPlugin extends OpenSearchQueryBuilderOperatorPlugin {
3
- name = "opensearch.queryBuilder.operator.notBetween.default";
4
- getOperator() {
5
- return "not_between";
6
- }
7
- apply(query, params) {
8
- const {
9
- value,
10
- basePath,
11
- name
12
- } = params;
13
- if (Array.isArray(value) === false) {
14
- throw new Error(`You cannot filter field path "${name}" with "not_between" query and not send an array of values.`);
15
- } else if (value.length !== 2) {
16
- throw new Error(`You must pass 2 values in the array for field path "${name}" filtering.`);
2
+ class OpenSearchQueryBuilderOperatorNotBetweenPlugin extends OpenSearchQueryBuilderOperatorPlugin {
3
+ getOperator() {
4
+ return "not_between";
5
+ }
6
+ apply(query, params) {
7
+ const { value, basePath, name } = params;
8
+ if (false === Array.isArray(value)) throw new Error(`You cannot filter field path "${name}" with "not_between" query and not send an array of values.`);
9
+ if (2 !== value.length) throw new Error(`You must pass 2 values in the array for field path "${name}" filtering.`);
10
+ const [gte, lte] = value;
11
+ query.must_not.push({
12
+ range: {
13
+ [basePath]: {
14
+ lte,
15
+ gte
16
+ }
17
+ }
18
+ });
19
+ }
20
+ constructor(...args){
21
+ super(...args), this.name = "opensearch.queryBuilder.operator.notBetween.default";
17
22
  }
18
- // we take gte first because it should be a lesser value than lte, eg [5, 10]
19
- // 6 >= gte && 6 <= lte === true which in this case it means that record will not match
20
- const [gte, lte] = value;
21
- query.must_not.push({
22
- range: {
23
- [basePath]: {
24
- lte,
25
- gte
26
- }
27
- }
28
- });
29
- }
30
23
  }
24
+ export { OpenSearchQueryBuilderOperatorNotBetweenPlugin };
31
25
 
32
26
  //# sourceMappingURL=notBetween.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["OpenSearchQueryBuilderOperatorPlugin","OpenSearchQueryBuilderOperatorNotBetweenPlugin","name","getOperator","apply","query","params","value","basePath","Array","isArray","Error","length","gte","lte","must_not","push","range"],"sources":["notBetween.ts"],"sourcesContent":["import { OpenSearchQueryBuilderOperatorPlugin } from \"~/plugins/definition/OpenSearchQueryBuilderOperatorPlugin.js\";\nimport type { OpenSearchBoolQueryConfig, OpenSearchQueryBuilderArgsPlugin } from \"~/types.js\";\n\nexport class OpenSearchQueryBuilderOperatorNotBetweenPlugin extends OpenSearchQueryBuilderOperatorPlugin {\n public override name = \"opensearch.queryBuilder.operator.notBetween.default\";\n\n public getOperator(): string {\n return \"not_between\";\n }\n\n public apply(query: OpenSearchBoolQueryConfig, params: OpenSearchQueryBuilderArgsPlugin): void {\n const { value, basePath, name } = params;\n if (Array.isArray(value) === false) {\n throw new Error(\n `You cannot filter field path \"${name}\" with \"not_between\" query and not send an array of values.`\n );\n } else if (value.length !== 2) {\n throw new Error(\n `You must pass 2 values in the array for field path \"${name}\" filtering.`\n );\n }\n // we take gte first because it should be a lesser value than lte, eg [5, 10]\n // 6 >= gte && 6 <= lte === true which in this case it means that record will not match\n const [gte, lte] = value;\n query.must_not.push({\n range: {\n [basePath]: {\n lte,\n gte\n }\n }\n });\n }\n}\n"],"mappings":"AAAA,SAASA,oCAAoC;AAG7C,OAAO,MAAMC,8CAA8C,SAASD,oCAAoC,CAAC;EACrFE,IAAI,GAAG,qDAAqD;EAErEC,WAAWA,CAAA,EAAW;IACzB,OAAO,aAAa;EACxB;EAEOC,KAAKA,CAACC,KAAgC,EAAEC,MAAwC,EAAQ;IAC3F,MAAM;MAAEC,KAAK;MAAEC,QAAQ;MAAEN;IAAK,CAAC,GAAGI,MAAM;IACxC,IAAIG,KAAK,CAACC,OAAO,CAACH,KAAK,CAAC,KAAK,KAAK,EAAE;MAChC,MAAM,IAAII,KAAK,CACX,iCAAiCT,IAAI,6DACzC,CAAC;IACL,CAAC,MAAM,IAAIK,KAAK,CAACK,MAAM,KAAK,CAAC,EAAE;MAC3B,MAAM,IAAID,KAAK,CACX,uDAAuDT,IAAI,cAC/D,CAAC;IACL;IACA;IACA;IACA,MAAM,CAACW,GAAG,EAAEC,GAAG,CAAC,GAAGP,KAAK;IACxBF,KAAK,CAACU,QAAQ,CAACC,IAAI,CAAC;MAChBC,KAAK,EAAE;QACH,CAACT,QAAQ,GAAG;UACRM,GAAG;UACHD;QACJ;MACJ;IACJ,CAAC,CAAC;EACN;AACJ","ignoreList":[]}
1
+ {"version":3,"file":"plugins/operator/notBetween.js","sources":["../../../src/plugins/operator/notBetween.ts"],"sourcesContent":["import { OpenSearchQueryBuilderOperatorPlugin } from \"~/plugins/definition/OpenSearchQueryBuilderOperatorPlugin.js\";\nimport type { OpenSearchBoolQueryConfig, OpenSearchQueryBuilderArgsPlugin } from \"~/types.js\";\n\nexport class OpenSearchQueryBuilderOperatorNotBetweenPlugin extends OpenSearchQueryBuilderOperatorPlugin {\n public override name = \"opensearch.queryBuilder.operator.notBetween.default\";\n\n public getOperator(): string {\n return \"not_between\";\n }\n\n public apply(query: OpenSearchBoolQueryConfig, params: OpenSearchQueryBuilderArgsPlugin): void {\n const { value, basePath, name } = params;\n if (Array.isArray(value) === false) {\n throw new Error(\n `You cannot filter field path \"${name}\" with \"not_between\" query and not send an array of values.`\n );\n } else if (value.length !== 2) {\n throw new Error(\n `You must pass 2 values in the array for field path \"${name}\" filtering.`\n );\n }\n // we take gte first because it should be a lesser value than lte, eg [5, 10]\n // 6 >= gte && 6 <= lte === true which in this case it means that record will not match\n const [gte, lte] = value;\n query.must_not.push({\n range: {\n [basePath]: {\n lte,\n gte\n }\n }\n });\n }\n}\n"],"names":["OpenSearchQueryBuilderOperatorNotBetweenPlugin","OpenSearchQueryBuilderOperatorPlugin","query","params","value","basePath","name","Array","Error","gte","lte"],"mappings":";AAGO,MAAMA,uDAAuDC;IAGzD,cAAsB;QACzB,OAAO;IACX;IAEO,MAAMC,KAAgC,EAAEC,MAAwC,EAAQ;QAC3F,MAAM,EAAEC,KAAK,EAAEC,QAAQ,EAAEC,IAAI,EAAE,GAAGH;QAClC,IAAII,AAAyB,UAAzBA,MAAM,OAAO,CAACH,QACd,MAAM,IAAII,MACN,CAAC,8BAA8B,EAAEF,KAAK,2DAA2D,CAAC;QAEnG,IAAIF,AAAiB,MAAjBA,MAAM,MAAM,EACnB,MAAM,IAAII,MACN,CAAC,oDAAoD,EAAEF,KAAK,YAAY,CAAC;QAKjF,MAAM,CAACG,KAAKC,IAAI,GAAGN;QACnBF,MAAM,QAAQ,CAAC,IAAI,CAAC;YAChB,OAAO;gBACH,CAACG,SAAS,EAAE;oBACRK;oBACAD;gBACJ;YACJ;QACJ;IACJ;;QA7BG,qBACa,IAAI,GAAG;;AA6B3B"}
@@ -1,24 +1,26 @@
1
1
  import { OpenSearchQueryBuilderOperatorPlugin } from "../definition/OpenSearchQueryBuilderOperatorPlugin.js";
2
2
  import { normalizeValueWithAsterisk } from "../../normalize.js";
3
- export class OpenSearchQueryBuilderOperatorNotContainsPlugin extends OpenSearchQueryBuilderOperatorPlugin {
4
- name = "opensearch.queryBuilder.operator.notContains.default";
5
- getOperator() {
6
- return "not_contains";
7
- }
8
- apply(query, params) {
9
- const {
10
- value,
11
- basePath
12
- } = params;
13
- query.must_not.push({
14
- query_string: {
15
- allow_leading_wildcard: true,
16
- fields: [basePath],
17
- query: normalizeValueWithAsterisk(value),
18
- default_operator: "and"
19
- }
20
- });
21
- }
3
+ class OpenSearchQueryBuilderOperatorNotContainsPlugin extends OpenSearchQueryBuilderOperatorPlugin {
4
+ getOperator() {
5
+ return "not_contains";
6
+ }
7
+ apply(query, params) {
8
+ const { value, basePath } = params;
9
+ query.must_not.push({
10
+ query_string: {
11
+ allow_leading_wildcard: true,
12
+ fields: [
13
+ basePath
14
+ ],
15
+ query: normalizeValueWithAsterisk(value),
16
+ default_operator: "and"
17
+ }
18
+ });
19
+ }
20
+ constructor(...args){
21
+ super(...args), this.name = "opensearch.queryBuilder.operator.notContains.default";
22
+ }
22
23
  }
24
+ export { OpenSearchQueryBuilderOperatorNotContainsPlugin };
23
25
 
24
26
  //# sourceMappingURL=notContains.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["OpenSearchQueryBuilderOperatorPlugin","normalizeValueWithAsterisk","OpenSearchQueryBuilderOperatorNotContainsPlugin","name","getOperator","apply","query","params","value","basePath","must_not","push","query_string","allow_leading_wildcard","fields","default_operator"],"sources":["notContains.ts"],"sourcesContent":["import { OpenSearchQueryBuilderOperatorPlugin } from \"~/plugins/definition/OpenSearchQueryBuilderOperatorPlugin.js\";\nimport { normalizeValueWithAsterisk } from \"~/normalize.js\";\nimport type { OpenSearchBoolQueryConfig, OpenSearchQueryBuilderArgsPlugin } from \"~/types.js\";\n\nexport class OpenSearchQueryBuilderOperatorNotContainsPlugin extends OpenSearchQueryBuilderOperatorPlugin {\n public override name = \"opensearch.queryBuilder.operator.notContains.default\";\n\n public getOperator(): string {\n return \"not_contains\";\n }\n\n public apply(query: OpenSearchBoolQueryConfig, params: OpenSearchQueryBuilderArgsPlugin): void {\n const { value, basePath } = params;\n query.must_not.push({\n query_string: {\n allow_leading_wildcard: true,\n fields: [basePath],\n query: normalizeValueWithAsterisk(value),\n default_operator: \"and\"\n }\n });\n }\n}\n"],"mappings":"AAAA,SAASA,oCAAoC;AAC7C,SAASC,0BAA0B;AAGnC,OAAO,MAAMC,+CAA+C,SAASF,oCAAoC,CAAC;EACtFG,IAAI,GAAG,sDAAsD;EAEtEC,WAAWA,CAAA,EAAW;IACzB,OAAO,cAAc;EACzB;EAEOC,KAAKA,CAACC,KAAgC,EAAEC,MAAwC,EAAQ;IAC3F,MAAM;MAAEC,KAAK;MAAEC;IAAS,CAAC,GAAGF,MAAM;IAClCD,KAAK,CAACI,QAAQ,CAACC,IAAI,CAAC;MAChBC,YAAY,EAAE;QACVC,sBAAsB,EAAE,IAAI;QAC5BC,MAAM,EAAE,CAACL,QAAQ,CAAC;QAClBH,KAAK,EAAEL,0BAA0B,CAACO,KAAK,CAAC;QACxCO,gBAAgB,EAAE;MACtB;IACJ,CAAC,CAAC;EACN;AACJ","ignoreList":[]}
1
+ {"version":3,"file":"plugins/operator/notContains.js","sources":["../../../src/plugins/operator/notContains.ts"],"sourcesContent":["import { OpenSearchQueryBuilderOperatorPlugin } from \"~/plugins/definition/OpenSearchQueryBuilderOperatorPlugin.js\";\nimport { normalizeValueWithAsterisk } from \"~/normalize.js\";\nimport type { OpenSearchBoolQueryConfig, OpenSearchQueryBuilderArgsPlugin } from \"~/types.js\";\n\nexport class OpenSearchQueryBuilderOperatorNotContainsPlugin extends OpenSearchQueryBuilderOperatorPlugin {\n public override name = \"opensearch.queryBuilder.operator.notContains.default\";\n\n public getOperator(): string {\n return \"not_contains\";\n }\n\n public apply(query: OpenSearchBoolQueryConfig, params: OpenSearchQueryBuilderArgsPlugin): void {\n const { value, basePath } = params;\n query.must_not.push({\n query_string: {\n allow_leading_wildcard: true,\n fields: [basePath],\n query: normalizeValueWithAsterisk(value),\n default_operator: \"and\"\n }\n });\n }\n}\n"],"names":["OpenSearchQueryBuilderOperatorNotContainsPlugin","OpenSearchQueryBuilderOperatorPlugin","query","params","value","basePath","normalizeValueWithAsterisk"],"mappings":";;AAIO,MAAMA,wDAAwDC;IAG1D,cAAsB;QACzB,OAAO;IACX;IAEO,MAAMC,KAAgC,EAAEC,MAAwC,EAAQ;QAC3F,MAAM,EAAEC,KAAK,EAAEC,QAAQ,EAAE,GAAGF;QAC5BD,MAAM,QAAQ,CAAC,IAAI,CAAC;YAChB,cAAc;gBACV,wBAAwB;gBACxB,QAAQ;oBAACG;iBAAS;gBAClB,OAAOC,2BAA2BF;gBAClC,kBAAkB;YACtB;QACJ;IACJ;;QAjBG,qBACa,IAAI,GAAG;;AAiB3B"}
@@ -1,27 +1,23 @@
1
1
  import { OpenSearchQueryBuilderOperatorPlugin } from "../definition/OpenSearchQueryBuilderOperatorPlugin.js";
2
- export class OpenSearchQueryBuilderOperatorNotInPlugin extends OpenSearchQueryBuilderOperatorPlugin {
3
- name = "opensearch.queryBuilder.operator.notIn.default";
4
- getOperator() {
5
- return "not_in";
6
- }
7
- apply(query, params) {
8
- const {
9
- value: values,
10
- path,
11
- basePath,
12
- name
13
- } = params;
14
- const isArray = Array.isArray(values);
15
- if (isArray === false || values.length === 0) {
16
- throw new Error(`You cannot filter field "${name}" with "not_in" operator and not send an array of values.`);
2
+ class OpenSearchQueryBuilderOperatorNotInPlugin extends OpenSearchQueryBuilderOperatorPlugin {
3
+ getOperator() {
4
+ return "not_in";
5
+ }
6
+ apply(query, params) {
7
+ const { value: values, path, basePath, name } = params;
8
+ const isArray = Array.isArray(values);
9
+ if (false === isArray || 0 === values.length) throw new Error(`You cannot filter field "${name}" with "not_in" operator and not send an array of values.`);
10
+ const useBasePath = values.some((value)=>"string" != typeof value);
11
+ query.must_not.push({
12
+ terms: {
13
+ [useBasePath ? basePath : path]: values
14
+ }
15
+ });
16
+ }
17
+ constructor(...args){
18
+ super(...args), this.name = "opensearch.queryBuilder.operator.notIn.default";
17
19
  }
18
- const useBasePath = values.some(value => typeof value !== "string");
19
- query.must_not.push({
20
- terms: {
21
- [useBasePath ? basePath : path]: values
22
- }
23
- });
24
- }
25
20
  }
21
+ export { OpenSearchQueryBuilderOperatorNotInPlugin };
26
22
 
27
23
  //# sourceMappingURL=notIn.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["OpenSearchQueryBuilderOperatorPlugin","OpenSearchQueryBuilderOperatorNotInPlugin","name","getOperator","apply","query","params","value","values","path","basePath","isArray","Array","length","Error","useBasePath","some","must_not","push","terms"],"sources":["notIn.ts"],"sourcesContent":["import { OpenSearchQueryBuilderOperatorPlugin } from \"~/plugins/definition/OpenSearchQueryBuilderOperatorPlugin.js\";\nimport type { OpenSearchBoolQueryConfig, OpenSearchQueryBuilderArgsPlugin } from \"~/types.js\";\n\nexport class OpenSearchQueryBuilderOperatorNotInPlugin extends OpenSearchQueryBuilderOperatorPlugin {\n public override name = \"opensearch.queryBuilder.operator.notIn.default\";\n\n public getOperator(): string {\n return \"not_in\";\n }\n\n public apply(query: OpenSearchBoolQueryConfig, params: OpenSearchQueryBuilderArgsPlugin): void {\n const { value: values, path, basePath, name } = params;\n const isArray = Array.isArray(values);\n if (isArray === false || values.length === 0) {\n throw new Error(\n `You cannot filter field \"${name}\" with \"not_in\" operator and not send an array of values.`\n );\n }\n\n const useBasePath = values.some(\n (value: string | number | boolean | null | undefined) => typeof value !== \"string\"\n );\n\n query.must_not.push({\n terms: {\n [useBasePath ? basePath : path]: values\n }\n });\n }\n}\n"],"mappings":"AAAA,SAASA,oCAAoC;AAG7C,OAAO,MAAMC,yCAAyC,SAASD,oCAAoC,CAAC;EAChFE,IAAI,GAAG,gDAAgD;EAEhEC,WAAWA,CAAA,EAAW;IACzB,OAAO,QAAQ;EACnB;EAEOC,KAAKA,CAACC,KAAgC,EAAEC,MAAwC,EAAQ;IAC3F,MAAM;MAAEC,KAAK,EAAEC,MAAM;MAAEC,IAAI;MAAEC,QAAQ;MAAER;IAAK,CAAC,GAAGI,MAAM;IACtD,MAAMK,OAAO,GAAGC,KAAK,CAACD,OAAO,CAACH,MAAM,CAAC;IACrC,IAAIG,OAAO,KAAK,KAAK,IAAIH,MAAM,CAACK,MAAM,KAAK,CAAC,EAAE;MAC1C,MAAM,IAAIC,KAAK,CACX,4BAA4BZ,IAAI,2DACpC,CAAC;IACL;IAEA,MAAMa,WAAW,GAAGP,MAAM,CAACQ,IAAI,CAC1BT,KAAmD,IAAK,OAAOA,KAAK,KAAK,QAC9E,CAAC;IAEDF,KAAK,CAACY,QAAQ,CAACC,IAAI,CAAC;MAChBC,KAAK,EAAE;QACH,CAACJ,WAAW,GAAGL,QAAQ,GAAGD,IAAI,GAAGD;MACrC;IACJ,CAAC,CAAC;EACN;AACJ","ignoreList":[]}
1
+ {"version":3,"file":"plugins/operator/notIn.js","sources":["../../../src/plugins/operator/notIn.ts"],"sourcesContent":["import { OpenSearchQueryBuilderOperatorPlugin } from \"~/plugins/definition/OpenSearchQueryBuilderOperatorPlugin.js\";\nimport type { OpenSearchBoolQueryConfig, OpenSearchQueryBuilderArgsPlugin } from \"~/types.js\";\n\nexport class OpenSearchQueryBuilderOperatorNotInPlugin extends OpenSearchQueryBuilderOperatorPlugin {\n public override name = \"opensearch.queryBuilder.operator.notIn.default\";\n\n public getOperator(): string {\n return \"not_in\";\n }\n\n public apply(query: OpenSearchBoolQueryConfig, params: OpenSearchQueryBuilderArgsPlugin): void {\n const { value: values, path, basePath, name } = params;\n const isArray = Array.isArray(values);\n if (isArray === false || values.length === 0) {\n throw new Error(\n `You cannot filter field \"${name}\" with \"not_in\" operator and not send an array of values.`\n );\n }\n\n const useBasePath = values.some(\n (value: string | number | boolean | null | undefined) => typeof value !== \"string\"\n );\n\n query.must_not.push({\n terms: {\n [useBasePath ? basePath : path]: values\n }\n });\n }\n}\n"],"names":["OpenSearchQueryBuilderOperatorNotInPlugin","OpenSearchQueryBuilderOperatorPlugin","query","params","values","path","basePath","name","isArray","Array","Error","useBasePath","value"],"mappings":";AAGO,MAAMA,kDAAkDC;IAGpD,cAAsB;QACzB,OAAO;IACX;IAEO,MAAMC,KAAgC,EAAEC,MAAwC,EAAQ;QAC3F,MAAM,EAAE,OAAOC,MAAM,EAAEC,IAAI,EAAEC,QAAQ,EAAEC,IAAI,EAAE,GAAGJ;QAChD,MAAMK,UAAUC,MAAM,OAAO,CAACL;QAC9B,IAAII,AAAY,UAAZA,WAAqBJ,AAAkB,MAAlBA,OAAO,MAAM,EAClC,MAAM,IAAIM,MACN,CAAC,yBAAyB,EAAEH,KAAK,yDAAyD,CAAC;QAInG,MAAMI,cAAcP,OAAO,IAAI,CAC3B,CAACQ,QAAwD,AAAiB,YAAjB,OAAOA;QAGpEV,MAAM,QAAQ,CAAC,IAAI,CAAC;YAChB,OAAO;gBACH,CAACS,cAAcL,WAAWD,KAAK,EAAED;YACrC;QACJ;IACJ;;QAzBG,qBACa,IAAI,GAAG;;AAyB3B"}
@@ -1,23 +1,21 @@
1
1
  import { OpenSearchQueryBuilderOperatorPlugin } from "../definition/OpenSearchQueryBuilderOperatorPlugin.js";
2
- export class OpenSearchQueryBuilderOperatorNotStartsWithPlugin extends OpenSearchQueryBuilderOperatorPlugin {
3
- name = "opensearch.queryBuilder.operator.notStartsWith.default";
4
- getOperator() {
5
- return "not_startsWith";
6
- }
7
- apply(query, params) {
8
- const {
9
- value,
10
- basePath
11
- } = params;
12
- if (value === "" || value === null || value === undefined) {
13
- return;
2
+ class OpenSearchQueryBuilderOperatorNotStartsWithPlugin extends OpenSearchQueryBuilderOperatorPlugin {
3
+ getOperator() {
4
+ return "not_startsWith";
5
+ }
6
+ apply(query, params) {
7
+ const { value, basePath } = params;
8
+ if ("" === value || null == value) return;
9
+ query.must_not.push({
10
+ match_phrase_prefix: {
11
+ [basePath]: value
12
+ }
13
+ });
14
+ }
15
+ constructor(...args){
16
+ super(...args), this.name = "opensearch.queryBuilder.operator.notStartsWith.default";
14
17
  }
15
- query.must_not.push({
16
- match_phrase_prefix: {
17
- [basePath]: value
18
- }
19
- });
20
- }
21
18
  }
19
+ export { OpenSearchQueryBuilderOperatorNotStartsWithPlugin };
22
20
 
23
21
  //# sourceMappingURL=notStartsWith.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["OpenSearchQueryBuilderOperatorPlugin","OpenSearchQueryBuilderOperatorNotStartsWithPlugin","name","getOperator","apply","query","params","value","basePath","undefined","must_not","push","match_phrase_prefix"],"sources":["notStartsWith.ts"],"sourcesContent":["import { OpenSearchQueryBuilderOperatorPlugin } from \"~/plugins/definition/OpenSearchQueryBuilderOperatorPlugin.js\";\nimport type { OpenSearchBoolQueryConfig, OpenSearchQueryBuilderArgsPlugin } from \"~/types.js\";\n\nexport class OpenSearchQueryBuilderOperatorNotStartsWithPlugin extends OpenSearchQueryBuilderOperatorPlugin {\n public override name = \"opensearch.queryBuilder.operator.notStartsWith.default\";\n\n public getOperator(): string {\n return \"not_startsWith\";\n }\n\n public apply(query: OpenSearchBoolQueryConfig, params: OpenSearchQueryBuilderArgsPlugin): void {\n const { value, basePath } = params;\n if (value === \"\" || value === null || value === undefined) {\n return;\n }\n query.must_not.push({\n match_phrase_prefix: {\n [basePath]: value\n }\n });\n }\n}\n"],"mappings":"AAAA,SAASA,oCAAoC;AAG7C,OAAO,MAAMC,iDAAiD,SAASD,oCAAoC,CAAC;EACxFE,IAAI,GAAG,wDAAwD;EAExEC,WAAWA,CAAA,EAAW;IACzB,OAAO,gBAAgB;EAC3B;EAEOC,KAAKA,CAACC,KAAgC,EAAEC,MAAwC,EAAQ;IAC3F,MAAM;MAAEC,KAAK;MAAEC;IAAS,CAAC,GAAGF,MAAM;IAClC,IAAIC,KAAK,KAAK,EAAE,IAAIA,KAAK,KAAK,IAAI,IAAIA,KAAK,KAAKE,SAAS,EAAE;MACvD;IACJ;IACAJ,KAAK,CAACK,QAAQ,CAACC,IAAI,CAAC;MAChBC,mBAAmB,EAAE;QACjB,CAACJ,QAAQ,GAAGD;MAChB;IACJ,CAAC,CAAC;EACN;AACJ","ignoreList":[]}
1
+ {"version":3,"file":"plugins/operator/notStartsWith.js","sources":["../../../src/plugins/operator/notStartsWith.ts"],"sourcesContent":["import { OpenSearchQueryBuilderOperatorPlugin } from \"~/plugins/definition/OpenSearchQueryBuilderOperatorPlugin.js\";\nimport type { OpenSearchBoolQueryConfig, OpenSearchQueryBuilderArgsPlugin } from \"~/types.js\";\n\nexport class OpenSearchQueryBuilderOperatorNotStartsWithPlugin extends OpenSearchQueryBuilderOperatorPlugin {\n public override name = \"opensearch.queryBuilder.operator.notStartsWith.default\";\n\n public getOperator(): string {\n return \"not_startsWith\";\n }\n\n public apply(query: OpenSearchBoolQueryConfig, params: OpenSearchQueryBuilderArgsPlugin): void {\n const { value, basePath } = params;\n if (value === \"\" || value === null || value === undefined) {\n return;\n }\n query.must_not.push({\n match_phrase_prefix: {\n [basePath]: value\n }\n });\n }\n}\n"],"names":["OpenSearchQueryBuilderOperatorNotStartsWithPlugin","OpenSearchQueryBuilderOperatorPlugin","query","params","value","basePath"],"mappings":";AAGO,MAAMA,0DAA0DC;IAG5D,cAAsB;QACzB,OAAO;IACX;IAEO,MAAMC,KAAgC,EAAEC,MAAwC,EAAQ;QAC3F,MAAM,EAAEC,KAAK,EAAEC,QAAQ,EAAE,GAAGF;QAC5B,IAAIC,AAAU,OAAVA,SAAkCA,QAAlBA,OAChB;QAEJF,MAAM,QAAQ,CAAC,IAAI,CAAC;YAChB,qBAAqB;gBACjB,CAACG,SAAS,EAAED;YAChB;QACJ;IACJ;;QAjBG,qBACa,IAAI,GAAG;;AAiB3B"}
@@ -1,23 +1,21 @@
1
1
  import { OpenSearchQueryBuilderOperatorPlugin } from "../definition/OpenSearchQueryBuilderOperatorPlugin.js";
2
- export class OpenSearchQueryBuilderOperatorStartsWithPlugin extends OpenSearchQueryBuilderOperatorPlugin {
3
- name = "opensearch.queryBuilder.operator.startsWith.default";
4
- getOperator() {
5
- return "startsWith";
6
- }
7
- apply(query, params) {
8
- const {
9
- value,
10
- basePath
11
- } = params;
12
- if (value === "" || value === null || value === undefined) {
13
- return;
2
+ class OpenSearchQueryBuilderOperatorStartsWithPlugin extends OpenSearchQueryBuilderOperatorPlugin {
3
+ getOperator() {
4
+ return "startsWith";
5
+ }
6
+ apply(query, params) {
7
+ const { value, basePath } = params;
8
+ if ("" === value || null == value) return;
9
+ query.filter.push({
10
+ match_phrase_prefix: {
11
+ [basePath]: value
12
+ }
13
+ });
14
+ }
15
+ constructor(...args){
16
+ super(...args), this.name = "opensearch.queryBuilder.operator.startsWith.default";
14
17
  }
15
- query.filter.push({
16
- match_phrase_prefix: {
17
- [basePath]: value
18
- }
19
- });
20
- }
21
18
  }
19
+ export { OpenSearchQueryBuilderOperatorStartsWithPlugin };
22
20
 
23
21
  //# sourceMappingURL=startsWith.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["OpenSearchQueryBuilderOperatorPlugin","OpenSearchQueryBuilderOperatorStartsWithPlugin","name","getOperator","apply","query","params","value","basePath","undefined","filter","push","match_phrase_prefix"],"sources":["startsWith.ts"],"sourcesContent":["import { OpenSearchQueryBuilderOperatorPlugin } from \"~/plugins/definition/OpenSearchQueryBuilderOperatorPlugin.js\";\nimport type { OpenSearchBoolQueryConfig, OpenSearchQueryBuilderArgsPlugin } from \"~/types.js\";\n\nexport class OpenSearchQueryBuilderOperatorStartsWithPlugin extends OpenSearchQueryBuilderOperatorPlugin {\n public override name = \"opensearch.queryBuilder.operator.startsWith.default\";\n\n public getOperator(): string {\n return \"startsWith\";\n }\n\n public apply(query: OpenSearchBoolQueryConfig, params: OpenSearchQueryBuilderArgsPlugin): void {\n const { value, basePath } = params;\n if (value === \"\" || value === null || value === undefined) {\n return;\n }\n query.filter.push({\n match_phrase_prefix: {\n [basePath]: value\n }\n });\n }\n}\n"],"mappings":"AAAA,SAASA,oCAAoC;AAG7C,OAAO,MAAMC,8CAA8C,SAASD,oCAAoC,CAAC;EACrFE,IAAI,GAAG,qDAAqD;EAErEC,WAAWA,CAAA,EAAW;IACzB,OAAO,YAAY;EACvB;EAEOC,KAAKA,CAACC,KAAgC,EAAEC,MAAwC,EAAQ;IAC3F,MAAM;MAAEC,KAAK;MAAEC;IAAS,CAAC,GAAGF,MAAM;IAClC,IAAIC,KAAK,KAAK,EAAE,IAAIA,KAAK,KAAK,IAAI,IAAIA,KAAK,KAAKE,SAAS,EAAE;MACvD;IACJ;IACAJ,KAAK,CAACK,MAAM,CAACC,IAAI,CAAC;MACdC,mBAAmB,EAAE;QACjB,CAACJ,QAAQ,GAAGD;MAChB;IACJ,CAAC,CAAC;EACN;AACJ","ignoreList":[]}
1
+ {"version":3,"file":"plugins/operator/startsWith.js","sources":["../../../src/plugins/operator/startsWith.ts"],"sourcesContent":["import { OpenSearchQueryBuilderOperatorPlugin } from \"~/plugins/definition/OpenSearchQueryBuilderOperatorPlugin.js\";\nimport type { OpenSearchBoolQueryConfig, OpenSearchQueryBuilderArgsPlugin } from \"~/types.js\";\n\nexport class OpenSearchQueryBuilderOperatorStartsWithPlugin extends OpenSearchQueryBuilderOperatorPlugin {\n public override name = \"opensearch.queryBuilder.operator.startsWith.default\";\n\n public getOperator(): string {\n return \"startsWith\";\n }\n\n public apply(query: OpenSearchBoolQueryConfig, params: OpenSearchQueryBuilderArgsPlugin): void {\n const { value, basePath } = params;\n if (value === \"\" || value === null || value === undefined) {\n return;\n }\n query.filter.push({\n match_phrase_prefix: {\n [basePath]: value\n }\n });\n }\n}\n"],"names":["OpenSearchQueryBuilderOperatorStartsWithPlugin","OpenSearchQueryBuilderOperatorPlugin","query","params","value","basePath"],"mappings":";AAGO,MAAMA,uDAAuDC;IAGzD,cAAsB;QACzB,OAAO;IACX;IAEO,MAAMC,KAAgC,EAAEC,MAAwC,EAAQ;QAC3F,MAAM,EAAEC,KAAK,EAAEC,QAAQ,EAAE,GAAGF;QAC5B,IAAIC,AAAU,OAAVA,SAAkCA,QAAlBA,OAChB;QAEJF,MAAM,MAAM,CAAC,IAAI,CAAC;YACd,qBAAqB;gBACjB,CAACG,SAAS,EAAED;YAChB;QACJ;IACJ;;QAjBG,qBACa,IAAI,GAAG;;AAiB3B"}
package/sharedIndex.js CHANGED
@@ -1,5 +1,4 @@
1
- export const isSharedOpenSearchIndex = () => {
2
- return process.env.OPENSEARCH_SHARED_INDEXES === "true";
3
- };
1
+ const isSharedOpenSearchIndex = ()=>"true" === process.env.OPENSEARCH_SHARED_INDEXES;
2
+ export { isSharedOpenSearchIndex };
4
3
 
5
4
  //# sourceMappingURL=sharedIndex.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["isSharedOpenSearchIndex","process","env","OPENSEARCH_SHARED_INDEXES"],"sources":["sharedIndex.ts"],"sourcesContent":["export const isSharedOpenSearchIndex = () => {\n return process.env.OPENSEARCH_SHARED_INDEXES === \"true\";\n};\n"],"mappings":"AAAA,OAAO,MAAMA,uBAAuB,GAAGA,CAAA,KAAM;EACzC,OAAOC,OAAO,CAACC,GAAG,CAACC,yBAAyB,KAAK,MAAM;AAC3D,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"sharedIndex.js","sources":["../src/sharedIndex.ts"],"sourcesContent":["export const isSharedOpenSearchIndex = () => {\n return process.env.OPENSEARCH_SHARED_INDEXES === \"true\";\n};\n"],"names":["isSharedOpenSearchIndex","process"],"mappings":"AAAO,MAAMA,0BAA0B,IAC5BC,AAA0C,WAA1CA,QAAQ,GAAG,CAAC,yBAAyB"}
package/sort.js CHANGED
@@ -1,65 +1,36 @@
1
- import WebinyError from "@webiny/error";
1
+ import error from "@webiny/error";
2
2
  import { OpenSearchFieldPlugin } from "./plugins/index.js";
3
3
  const sortRegExp = /^((?:values\.)?[a-zA-Z0-9_@-]+)_(ASC|DESC)$/;
4
- export const createSort = params => {
5
- const {
6
- sort,
7
- defaults,
8
- fieldPlugins
9
- } = params;
10
- if (!sort || sort.length === 0) {
11
- const {
12
- field,
13
- order,
14
- unmappedType
15
- } = defaults || {};
16
- /**
17
- * We say that our system defaults is always id since all records we create have some kind of primary ID.
18
- */
19
- return {
20
- [field || "id.keyword"]: {
21
- order: order || "desc",
22
- // TODO: Cast to the proper MappingFieldType once deep opensearch _types/ imports are resolvable under bundler resolution.
23
- unmapped_type: unmappedType || undefined
24
- }
25
- };
26
- }
27
- /**
28
- * Cast as string because nothing else should be allowed yet.
29
- */
30
- const result = sort.reduce((acc, value) => {
31
- if (typeof value !== "string") {
32
- throw new WebinyError(`Sort as object is not supported..`);
33
- }
34
- const match = value.match(sortRegExp);
35
- if (!match) {
36
- throw new WebinyError(`Cannot sort by "${value}".`);
37
- }
38
- const [, field, initialOrder] = match;
39
- const order = initialOrder.toLowerCase() === "asc" ? "asc" : "desc";
40
- const plugin = fieldPlugins[field] || fieldPlugins[OpenSearchFieldPlugin.ALL];
41
- if (!plugin) {
42
- throw new WebinyError(`Missing plugin for the field "${field}"`, "PLUGIN_SORT_ERROR", {
43
- field
44
- });
4
+ const createSort = (params)=>{
5
+ const { sort, defaults, fieldPlugins } = params;
6
+ if (!sort || 0 === sort.length) {
7
+ const { field, order, unmappedType } = defaults || {};
8
+ return {
9
+ [field || "id.keyword"]: {
10
+ order: order || "desc",
11
+ unmapped_type: unmappedType || void 0
12
+ }
13
+ };
45
14
  }
46
- /**
47
- * In case field plugin is the global one, change the * with actual field name.
48
- * Custom path methods will return their own values anyway so replacing * will not matter.
49
- */
50
- const path = plugin.getPath(field);
51
- acc[path] = plugin.getSortOptions(order);
52
- return acc;
53
- }, {});
54
- /**
55
- * If we do not have id in the sort, we add it as we need a tie_breaker for the OpenSearch to be able to sort consistently.
56
- */
57
- if (!result["id.keyword"] && !result["id"]) {
58
- result["id.keyword"] = {
59
- order: "asc"
15
+ const result = sort.reduce((acc, value)=>{
16
+ if ("string" != typeof value) throw new error("Sort as object is not supported..");
17
+ const match = value.match(sortRegExp);
18
+ if (!match) throw new error(`Cannot sort by "${value}".`);
19
+ const [, field, initialOrder] = match;
20
+ const order = "asc" === initialOrder.toLowerCase() ? "asc" : "desc";
21
+ const plugin = fieldPlugins[field] || fieldPlugins[OpenSearchFieldPlugin.ALL];
22
+ if (!plugin) throw new error(`Missing plugin for the field "${field}"`, "PLUGIN_SORT_ERROR", {
23
+ field
24
+ });
25
+ const path = plugin.getPath(field);
26
+ acc[path] = plugin.getSortOptions(order);
27
+ return acc;
28
+ }, {});
29
+ if (!result["id.keyword"] && !result["id"]) result["id.keyword"] = {
30
+ order: "asc"
60
31
  };
61
- }
62
- return result;
32
+ return result;
63
33
  };
34
+ export { createSort };
64
35
 
65
36
  //# sourceMappingURL=sort.js.map
package/sort.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"names":["WebinyError","OpenSearchFieldPlugin","sortRegExp","createSort","params","sort","defaults","fieldPlugins","length","field","order","unmappedType","unmapped_type","undefined","result","reduce","acc","value","match","initialOrder","toLowerCase","plugin","ALL","path","getPath","getSortOptions"],"sources":["sort.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport type { FieldSortOptions, SortOrder, SortType } from \"~/types.js\";\nimport { OpenSearchFieldPlugin } from \"~/plugins/index.js\";\n\nconst sortRegExp = /^((?:values\\.)?[a-zA-Z0-9_@-]+)_(ASC|DESC)$/;\n\ninterface CreateSortParams {\n sort: string[];\n defaults?: {\n field?: string;\n order?: SortOrder;\n unmappedType?: string;\n };\n fieldPlugins: Record<string, OpenSearchFieldPlugin>;\n}\n\nexport const createSort = (params: CreateSortParams): SortType => {\n const { sort, defaults, fieldPlugins } = params;\n if (!sort || sort.length === 0) {\n const { field, order, unmappedType } = defaults || {};\n /**\n * We say that our system defaults is always id since all records we create have some kind of primary ID.\n */\n return {\n [field || \"id.keyword\"]: {\n order: order || \"desc\",\n // TODO: Cast to the proper MappingFieldType once deep opensearch _types/ imports are resolvable under bundler resolution.\n unmapped_type: (unmappedType || undefined) as any\n }\n };\n }\n /**\n * Cast as string because nothing else should be allowed yet.\n */\n const result = sort.reduce(\n (acc, value) => {\n if (typeof value !== \"string\") {\n throw new WebinyError(`Sort as object is not supported..`);\n }\n const match = value.match(sortRegExp);\n\n if (!match) {\n throw new WebinyError(`Cannot sort by \"${value}\".`);\n }\n\n const [, field, initialOrder] = match;\n const order: SortOrder = initialOrder.toLowerCase() === \"asc\" ? \"asc\" : \"desc\";\n\n const plugin: OpenSearchFieldPlugin =\n fieldPlugins[field] || fieldPlugins[OpenSearchFieldPlugin.ALL];\n if (!plugin) {\n throw new WebinyError(\n `Missing plugin for the field \"${field}\"`,\n \"PLUGIN_SORT_ERROR\",\n {\n field\n }\n );\n }\n /**\n * In case field plugin is the global one, change the * with actual field name.\n * Custom path methods will return their own values anyway so replacing * will not matter.\n */\n const path = plugin.getPath(field);\n\n acc[path] = plugin.getSortOptions(order);\n\n return acc;\n },\n {} as Record<string, FieldSortOptions>\n );\n /**\n * If we do not have id in the sort, we add it as we need a tie_breaker for the OpenSearch to be able to sort consistently.\n */\n if (!result[\"id.keyword\"] && !result[\"id\"]) {\n result[\"id.keyword\"] = {\n order: \"asc\"\n };\n }\n return result;\n};\n"],"mappings":"AAAA,OAAOA,WAAW,MAAM,eAAe;AAEvC,SAASC,qBAAqB;AAE9B,MAAMC,UAAU,GAAG,6CAA6C;AAYhE,OAAO,MAAMC,UAAU,GAAIC,MAAwB,IAAe;EAC9D,MAAM;IAAEC,IAAI;IAAEC,QAAQ;IAAEC;EAAa,CAAC,GAAGH,MAAM;EAC/C,IAAI,CAACC,IAAI,IAAIA,IAAI,CAACG,MAAM,KAAK,CAAC,EAAE;IAC5B,MAAM;MAAEC,KAAK;MAAEC,KAAK;MAAEC;IAAa,CAAC,GAAGL,QAAQ,IAAI,CAAC,CAAC;IACrD;AACR;AACA;IACQ,OAAO;MACH,CAACG,KAAK,IAAI,YAAY,GAAG;QACrBC,KAAK,EAAEA,KAAK,IAAI,MAAM;QACtB;QACAE,aAAa,EAAGD,YAAY,IAAIE;MACpC;IACJ,CAAC;EACL;EACA;AACJ;AACA;EACI,MAAMC,MAAM,GAAGT,IAAI,CAACU,MAAM,CACtB,CAACC,GAAG,EAAEC,KAAK,KAAK;IACZ,IAAI,OAAOA,KAAK,KAAK,QAAQ,EAAE;MAC3B,MAAM,IAAIjB,WAAW,CAAC,mCAAmC,CAAC;IAC9D;IACA,MAAMkB,KAAK,GAAGD,KAAK,CAACC,KAAK,CAAChB,UAAU,CAAC;IAErC,IAAI,CAACgB,KAAK,EAAE;MACR,MAAM,IAAIlB,WAAW,CAAC,mBAAmBiB,KAAK,IAAI,CAAC;IACvD;IAEA,MAAM,GAAGR,KAAK,EAAEU,YAAY,CAAC,GAAGD,KAAK;IACrC,MAAMR,KAAgB,GAAGS,YAAY,CAACC,WAAW,CAAC,CAAC,KAAK,KAAK,GAAG,KAAK,GAAG,MAAM;IAE9E,MAAMC,MAA6B,GAC/Bd,YAAY,CAACE,KAAK,CAAC,IAAIF,YAAY,CAACN,qBAAqB,CAACqB,GAAG,CAAC;IAClE,IAAI,CAACD,MAAM,EAAE;MACT,MAAM,IAAIrB,WAAW,CACjB,iCAAiCS,KAAK,GAAG,EACzC,mBAAmB,EACnB;QACIA;MACJ,CACJ,CAAC;IACL;IACA;AACZ;AACA;AACA;IACY,MAAMc,IAAI,GAAGF,MAAM,CAACG,OAAO,CAACf,KAAK,CAAC;IAElCO,GAAG,CAACO,IAAI,CAAC,GAAGF,MAAM,CAACI,cAAc,CAACf,KAAK,CAAC;IAExC,OAAOM,GAAG;EACd,CAAC,EACD,CAAC,CACL,CAAC;EACD;AACJ;AACA;EACI,IAAI,CAACF,MAAM,CAAC,YAAY,CAAC,IAAI,CAACA,MAAM,CAAC,IAAI,CAAC,EAAE;IACxCA,MAAM,CAAC,YAAY,CAAC,GAAG;MACnBJ,KAAK,EAAE;IACX,CAAC;EACL;EACA,OAAOI,MAAM;AACjB,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"sort.js","sources":["../src/sort.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport type { FieldSortOptions, SortOrder, SortType } from \"~/types.js\";\nimport { OpenSearchFieldPlugin } from \"~/plugins/index.js\";\n\nconst sortRegExp = /^((?:values\\.)?[a-zA-Z0-9_@-]+)_(ASC|DESC)$/;\n\ninterface CreateSortParams {\n sort: string[];\n defaults?: {\n field?: string;\n order?: SortOrder;\n unmappedType?: string;\n };\n fieldPlugins: Record<string, OpenSearchFieldPlugin>;\n}\n\nexport const createSort = (params: CreateSortParams): SortType => {\n const { sort, defaults, fieldPlugins } = params;\n if (!sort || sort.length === 0) {\n const { field, order, unmappedType } = defaults || {};\n /**\n * We say that our system defaults is always id since all records we create have some kind of primary ID.\n */\n return {\n [field || \"id.keyword\"]: {\n order: order || \"desc\",\n // TODO: Cast to the proper MappingFieldType once deep opensearch _types/ imports are resolvable under bundler resolution.\n unmapped_type: (unmappedType || undefined) as any\n }\n };\n }\n /**\n * Cast as string because nothing else should be allowed yet.\n */\n const result = sort.reduce(\n (acc, value) => {\n if (typeof value !== \"string\") {\n throw new WebinyError(`Sort as object is not supported..`);\n }\n const match = value.match(sortRegExp);\n\n if (!match) {\n throw new WebinyError(`Cannot sort by \"${value}\".`);\n }\n\n const [, field, initialOrder] = match;\n const order: SortOrder = initialOrder.toLowerCase() === \"asc\" ? \"asc\" : \"desc\";\n\n const plugin: OpenSearchFieldPlugin =\n fieldPlugins[field] || fieldPlugins[OpenSearchFieldPlugin.ALL];\n if (!plugin) {\n throw new WebinyError(\n `Missing plugin for the field \"${field}\"`,\n \"PLUGIN_SORT_ERROR\",\n {\n field\n }\n );\n }\n /**\n * In case field plugin is the global one, change the * with actual field name.\n * Custom path methods will return their own values anyway so replacing * will not matter.\n */\n const path = plugin.getPath(field);\n\n acc[path] = plugin.getSortOptions(order);\n\n return acc;\n },\n {} as Record<string, FieldSortOptions>\n );\n /**\n * If we do not have id in the sort, we add it as we need a tie_breaker for the OpenSearch to be able to sort consistently.\n */\n if (!result[\"id.keyword\"] && !result[\"id\"]) {\n result[\"id.keyword\"] = {\n order: \"asc\"\n };\n }\n return result;\n};\n"],"names":["sortRegExp","createSort","params","sort","defaults","fieldPlugins","field","order","unmappedType","undefined","result","acc","value","WebinyError","match","initialOrder","plugin","OpenSearchFieldPlugin","path"],"mappings":";;AAIA,MAAMA,aAAa;AAYZ,MAAMC,aAAa,CAACC;IACvB,MAAM,EAAEC,IAAI,EAAEC,QAAQ,EAAEC,YAAY,EAAE,GAAGH;IACzC,IAAI,CAACC,QAAQA,AAAgB,MAAhBA,KAAK,MAAM,EAAQ;QAC5B,MAAM,EAAEG,KAAK,EAAEC,KAAK,EAAEC,YAAY,EAAE,GAAGJ,YAAY,CAAC;QAIpD,OAAO;YACH,CAACE,SAAS,aAAa,EAAE;gBACrB,OAAOC,SAAS;gBAEhB,eAAgBC,gBAAgBC;YACpC;QACJ;IACJ;IAIA,MAAMC,SAASP,KAAK,MAAM,CACtB,CAACQ,KAAKC;QACF,IAAI,AAAiB,YAAjB,OAAOA,OACP,MAAM,IAAIC,MAAY;QAE1B,MAAMC,QAAQF,MAAM,KAAK,CAACZ;QAE1B,IAAI,CAACc,OACD,MAAM,IAAID,MAAY,CAAC,gBAAgB,EAAED,MAAM,EAAE,CAAC;QAGtD,MAAM,GAAGN,OAAOS,aAAa,GAAGD;QAChC,MAAMP,QAAmBQ,AAA+B,UAA/BA,aAAa,WAAW,KAAe,QAAQ;QAExE,MAAMC,SACFX,YAAY,CAACC,MAAM,IAAID,YAAY,CAACY,sBAAsB,GAAG,CAAC;QAClE,IAAI,CAACD,QACD,MAAM,IAAIH,MACN,CAAC,8BAA8B,EAAEP,MAAM,CAAC,CAAC,EACzC,qBACA;YACIA;QACJ;QAOR,MAAMY,OAAOF,OAAO,OAAO,CAACV;QAE5BK,GAAG,CAACO,KAAK,GAAGF,OAAO,cAAc,CAACT;QAElC,OAAOI;IACX,GACA,CAAC;IAKL,IAAI,CAACD,MAAM,CAAC,aAAa,IAAI,CAACA,MAAM,CAAC,KAAK,EACtCA,MAAM,CAAC,aAAa,GAAG;QACnB,OAAO;IACX;IAEJ,OAAOA;AACX"}
package/types.js CHANGED
@@ -1,68 +1,8 @@
1
- // ---------------------------------------------------------------------------
2
- // Types inferred from the accessible API surface.
3
- // The `_types/` directory in the opensearch package only ships `.d.ts` files
4
- // (no `.js` runtime modules), so deep imports are unresolvable under
5
- // `moduleResolution: "bundler"`. We infer what we can from the public
6
- // barrel (`api/index.js`) and use `string` where structural extraction
7
- // is not possible.
8
- // ---------------------------------------------------------------------------
9
-
10
- // Distribute over the SortOptions union and extract only the Record<string, FieldSort> variant.
11
-
12
- // ---------------------------------------------------------------------------
13
- // Local type aliases replacing elastic-ts
14
- // ---------------------------------------------------------------------------
15
-
16
- /** Replaces elastic-ts PrimitiveValue. Aligns with opensearch FieldValue. */
17
-
18
- /** Replaces elastic-ts Query */
19
-
20
- /** Replaces elastic-ts BoolQueryConfig */
21
-
22
- /** Replaces elastic-ts FieldSortOptions */
23
-
24
- /** Replaces elastic-ts SortOrder. Narrowed to "asc" | "desc" (excludes "_doc"). */
25
-
26
- /** Replaces elastic-ts Sort */
27
-
28
- /** Single sort entry as an object map. Replaces elastic-ts SortType. */
29
-
30
- /** Replaces elastic-ts SearchBody. Overrides search_after to allow PrimitiveValue[] (null | boolean | string | number). */
31
-
32
- // ---------------------------------------------------------------------------
33
- // Context
34
- // ---------------------------------------------------------------------------
35
-
36
- // ---------------------------------------------------------------------------
37
- // Bool query with required arrays (our convention)
38
- // ---------------------------------------------------------------------------
39
-
40
- // ---------------------------------------------------------------------------
41
- // Operator plugin types
42
- // ---------------------------------------------------------------------------
43
-
44
- // ---------------------------------------------------------------------------
45
- // Search response shapes (aligned with @opensearch-project/opensearch v3)
46
- // ---------------------------------------------------------------------------
47
-
48
- /**
49
- * Extract the total count from an opensearch hits response.
50
- * Handles both `TotalHits` (object with `value`) and plain `number` formats.
51
- */
52
- export const getTotalCount = total => {
53
- if (total === undefined || total === null) {
54
- return 0;
55
- }
56
- if (typeof total === "number") {
57
- return total;
58
- }
59
- return total.value;
1
+ const getTotalCount = (total)=>{
2
+ if (null == total) return 0;
3
+ if ("number" == typeof total) return total;
4
+ return total.value;
60
5
  };
61
-
62
- // ---------------------------------------------------------------------------
63
- // Index request body shapes (re-exported from opensearch package)
64
- // ---------------------------------------------------------------------------
65
-
66
- // Re-export SearchSortOrder for consumers that need it (including "_doc")
6
+ export { getTotalCount };
67
7
 
68
8
  //# sourceMappingURL=types.js.map
package/types.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"names":["getTotalCount","total","undefined","value"],"sources":["types.ts"],"sourcesContent":["import type { Client } from \"@opensearch-project/opensearch\";\nimport type {\n Search_RequestBody as SearchRequestBody,\n Search_Response,\n Indices_Create_RequestBody\n} from \"@opensearch-project/opensearch/api/index.js\";\nimport type { Context } from \"@webiny/api/types.js\";\n\n// ---------------------------------------------------------------------------\n// Types inferred from the accessible API surface.\n// The `_types/` directory in the opensearch package only ships `.d.ts` files\n// (no `.js` runtime modules), so deep imports are unresolvable under\n// `moduleResolution: \"bundler\"`. We infer what we can from the public\n// barrel (`api/index.js`) and use `string` where structural extraction\n// is not possible.\n// ---------------------------------------------------------------------------\n\ntype QueryDslQueryContainer = NonNullable<SearchRequestBody[\"query\"]>;\ntype QueryDslBoolQuery = NonNullable<QueryDslQueryContainer[\"bool\"]>;\ntype SearchSort = NonNullable<SearchRequestBody[\"sort\"]>;\ntype SearchSortOrder = \"asc\" | \"desc\";\n\n// Distribute over the SortOptions union and extract only the Record<string, FieldSort> variant.\ntype _ExtractRecordValue<T> = T extends Record<string, infer V> ? V : never;\ntype _SortMember =\n NonNullable<SearchRequestBody[\"sort\"]> extends (infer U)[] | (infer U) ? U : never;\ntype SearchFieldSort = _ExtractRecordValue<Exclude<_SortMember, string>>;\n\ntype DynamicTemplate = NonNullable<\n NonNullable<Indices_Create_RequestBody[\"mappings\"]>[\"dynamic_templates\"]\n>[number][string];\n\nexport type { ApiResponse } from \"@opensearch-project/opensearch\";\n\nexport type { Client };\n\n// ---------------------------------------------------------------------------\n// Local type aliases replacing elastic-ts\n// ---------------------------------------------------------------------------\n\n/** Replaces elastic-ts PrimitiveValue. Aligns with opensearch FieldValue. */\nexport type PrimitiveValue = boolean | undefined | number | string;\n\n/** Replaces elastic-ts Query */\nexport type { QueryDslQueryContainer };\n\n/** Replaces elastic-ts BoolQueryConfig */\nexport type { QueryDslBoolQuery };\n\n/** Replaces elastic-ts FieldSortOptions */\nexport type FieldSortOptions = SearchFieldSort;\n\n/** Replaces elastic-ts SortOrder. Narrowed to \"asc\" | \"desc\" (excludes \"_doc\"). */\nexport type SortOrder = \"asc\" | \"desc\";\n\n/** Replaces elastic-ts Sort */\nexport type { SearchSort as Sort };\n\n/** Single sort entry as an object map. Replaces elastic-ts SortType. */\nexport type SortType = Record<string, FieldSortOptions>;\n\n/** Replaces elastic-ts SearchBody. Overrides search_after to allow PrimitiveValue[] (null | boolean | string | number). */\nexport type SearchBody = Omit<SearchRequestBody, \"search_after\"> & {\n search_after?: PrimitiveValue[];\n};\n\n// ---------------------------------------------------------------------------\n// Context\n// ---------------------------------------------------------------------------\n\nexport interface OpenSearchContext extends Context {\n /**\n * @deprecated Use `context.opensearch` instead.\n */\n elasticsearch: Client;\n opensearch: Client;\n}\n\n// ---------------------------------------------------------------------------\n// Bool query with required arrays (our convention)\n// ---------------------------------------------------------------------------\n\nexport interface OpenSearchBoolQueryConfig extends QueryDslBoolQuery {\n must: QueryDslQueryContainer[];\n filter: QueryDslQueryContainer[];\n should: QueryDslQueryContainer[];\n must_not: QueryDslQueryContainer[];\n}\n\n// ---------------------------------------------------------------------------\n// Operator plugin types\n// ---------------------------------------------------------------------------\n\nexport type OpenSearchQueryOperator =\n | \"eq\"\n | \"not\"\n | \"in\"\n | \"not_in\"\n | \"contains\"\n | \"not_contains\"\n | \"between\"\n | \"not_between\"\n | \"gt\"\n | \"gte\"\n | \"lt\"\n | \"lte\"\n | string;\n\nexport interface OpenSearchQueryBuilderArgsPlugin {\n name: string;\n path: string;\n basePath: string;\n value: any;\n keyword: boolean;\n}\n\n// ---------------------------------------------------------------------------\n// Search response shapes (aligned with @opensearch-project/opensearch v3)\n// ---------------------------------------------------------------------------\n\nexport type OpenSearchSearchResponseHit = Search_Response[\"body\"][\"hits\"][\"hits\"][number];\n\nexport interface OpenSearchSearchResponseAggregationBucket {\n key: PrimitiveValue;\n doc_count: number;\n}\n\nexport type OpenSearchSearchResponseBodyHits = Search_Response[\"body\"][\"hits\"];\n\nexport type OpenSearchSearchResponseBody = Search_Response[\"body\"];\n\nexport type OpenSearchSearchResponse = Search_Response;\n\n/**\n * Extract the total count from an opensearch hits response.\n * Handles both `TotalHits` (object with `value`) and plain `number` formats.\n */\nexport const getTotalCount = (total: OpenSearchSearchResponseBodyHits[\"total\"]): number => {\n if (total === undefined || total === null) {\n return 0;\n }\n if (typeof total === \"number\") {\n return total;\n }\n return total.value;\n};\n\n// ---------------------------------------------------------------------------\n// Index request body shapes (re-exported from opensearch package)\n// ---------------------------------------------------------------------------\n\nexport type OpenSearchIndexRequestBodyMappingsDynamicTemplate = Record<string, DynamicTemplate>;\n\nexport type OpenSearchIndexRequestBody = Indices_Create_RequestBody;\n\n// Re-export SearchSortOrder for consumers that need it (including \"_doc\")\nexport type { SearchSortOrder };\n"],"mappings":"AAQA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAOA;;AAcA;AACA;AACA;;AAEA;;AAGA;;AAGA;;AAGA;;AAGA;;AAGA;;AAGA;;AAGA;;AAKA;AACA;AACA;;AAUA;AACA;AACA;;AASA;AACA;AACA;;AAyBA;AACA;AACA;;AAeA;AACA;AACA;AACA;AACA,OAAO,MAAMA,aAAa,GAAIC,KAAgD,IAAa;EACvF,IAAIA,KAAK,KAAKC,SAAS,IAAID,KAAK,KAAK,IAAI,EAAE;IACvC,OAAO,CAAC;EACZ;EACA,IAAI,OAAOA,KAAK,KAAK,QAAQ,EAAE;IAC3B,OAAOA,KAAK;EAChB;EACA,OAAOA,KAAK,CAACE,KAAK;AACtB,CAAC;;AAED;AACA;AACA;;AAMA","ignoreList":[]}
1
+ {"version":3,"file":"types.js","sources":["../src/types.ts"],"sourcesContent":["import type { Client } from \"@opensearch-project/opensearch\";\nimport type {\n Search_RequestBody as SearchRequestBody,\n Search_Response,\n Indices_Create_RequestBody\n} from \"@opensearch-project/opensearch/api/index.js\";\nimport type { Context } from \"@webiny/api/types.js\";\n\n// ---------------------------------------------------------------------------\n// Types inferred from the accessible API surface.\n// The `_types/` directory in the opensearch package only ships `.d.ts` files\n// (no `.js` runtime modules), so deep imports are unresolvable under\n// `moduleResolution: \"bundler\"`. We infer what we can from the public\n// barrel (`api/index.js`) and use `string` where structural extraction\n// is not possible.\n// ---------------------------------------------------------------------------\n\ntype QueryDslQueryContainer = NonNullable<SearchRequestBody[\"query\"]>;\ntype QueryDslBoolQuery = NonNullable<QueryDslQueryContainer[\"bool\"]>;\ntype SearchSort = NonNullable<SearchRequestBody[\"sort\"]>;\ntype SearchSortOrder = \"asc\" | \"desc\";\n\n// Distribute over the SortOptions union and extract only the Record<string, FieldSort> variant.\ntype _ExtractRecordValue<T> = T extends Record<string, infer V> ? V : never;\ntype _SortMember =\n NonNullable<SearchRequestBody[\"sort\"]> extends (infer U)[] | (infer U) ? U : never;\ntype SearchFieldSort = _ExtractRecordValue<Exclude<_SortMember, string>>;\n\ntype DynamicTemplate = NonNullable<\n NonNullable<Indices_Create_RequestBody[\"mappings\"]>[\"dynamic_templates\"]\n>[number][string];\n\nexport type { ApiResponse } from \"@opensearch-project/opensearch\";\n\nexport type { Client };\n\n// ---------------------------------------------------------------------------\n// Local type aliases replacing elastic-ts\n// ---------------------------------------------------------------------------\n\n/** Replaces elastic-ts PrimitiveValue. Aligns with opensearch FieldValue. */\nexport type PrimitiveValue = boolean | undefined | number | string;\n\n/** Replaces elastic-ts Query */\nexport type { QueryDslQueryContainer };\n\n/** Replaces elastic-ts BoolQueryConfig */\nexport type { QueryDslBoolQuery };\n\n/** Replaces elastic-ts FieldSortOptions */\nexport type FieldSortOptions = SearchFieldSort;\n\n/** Replaces elastic-ts SortOrder. Narrowed to \"asc\" | \"desc\" (excludes \"_doc\"). */\nexport type SortOrder = \"asc\" | \"desc\";\n\n/** Replaces elastic-ts Sort */\nexport type { SearchSort as Sort };\n\n/** Single sort entry as an object map. Replaces elastic-ts SortType. */\nexport type SortType = Record<string, FieldSortOptions>;\n\n/** Replaces elastic-ts SearchBody. Overrides search_after to allow PrimitiveValue[] (null | boolean | string | number). */\nexport type SearchBody = Omit<SearchRequestBody, \"search_after\"> & {\n search_after?: PrimitiveValue[];\n};\n\n// ---------------------------------------------------------------------------\n// Context\n// ---------------------------------------------------------------------------\n\nexport interface OpenSearchContext extends Context {\n /**\n * @deprecated Use `context.opensearch` instead.\n */\n elasticsearch: Client;\n opensearch: Client;\n}\n\n// ---------------------------------------------------------------------------\n// Bool query with required arrays (our convention)\n// ---------------------------------------------------------------------------\n\nexport interface OpenSearchBoolQueryConfig extends QueryDslBoolQuery {\n must: QueryDslQueryContainer[];\n filter: QueryDslQueryContainer[];\n should: QueryDslQueryContainer[];\n must_not: QueryDslQueryContainer[];\n}\n\n// ---------------------------------------------------------------------------\n// Operator plugin types\n// ---------------------------------------------------------------------------\n\nexport type OpenSearchQueryOperator =\n | \"eq\"\n | \"not\"\n | \"in\"\n | \"not_in\"\n | \"contains\"\n | \"not_contains\"\n | \"between\"\n | \"not_between\"\n | \"gt\"\n | \"gte\"\n | \"lt\"\n | \"lte\"\n | string;\n\nexport interface OpenSearchQueryBuilderArgsPlugin {\n name: string;\n path: string;\n basePath: string;\n value: any;\n keyword: boolean;\n}\n\n// ---------------------------------------------------------------------------\n// Search response shapes (aligned with @opensearch-project/opensearch v3)\n// ---------------------------------------------------------------------------\n\nexport type OpenSearchSearchResponseHit = Search_Response[\"body\"][\"hits\"][\"hits\"][number];\n\nexport interface OpenSearchSearchResponseAggregationBucket {\n key: PrimitiveValue;\n doc_count: number;\n}\n\nexport type OpenSearchSearchResponseBodyHits = Search_Response[\"body\"][\"hits\"];\n\nexport type OpenSearchSearchResponseBody = Search_Response[\"body\"];\n\nexport type OpenSearchSearchResponse = Search_Response;\n\n/**\n * Extract the total count from an opensearch hits response.\n * Handles both `TotalHits` (object with `value`) and plain `number` formats.\n */\nexport const getTotalCount = (total: OpenSearchSearchResponseBodyHits[\"total\"]): number => {\n if (total === undefined || total === null) {\n return 0;\n }\n if (typeof total === \"number\") {\n return total;\n }\n return total.value;\n};\n\n// ---------------------------------------------------------------------------\n// Index request body shapes (re-exported from opensearch package)\n// ---------------------------------------------------------------------------\n\nexport type OpenSearchIndexRequestBodyMappingsDynamicTemplate = Record<string, DynamicTemplate>;\n\nexport type OpenSearchIndexRequestBody = Indices_Create_RequestBody;\n\n// Re-export SearchSortOrder for consumers that need it (including \"_doc\")\nexport type { SearchSortOrder };\n"],"names":["getTotalCount","total"],"mappings":"AAyIO,MAAMA,gBAAgB,CAACC;IAC1B,IAAIA,QAAAA,OACA,OAAO;IAEX,IAAI,AAAiB,YAAjB,OAAOA,OACP,OAAOA;IAEX,OAAOA,MAAM,KAAK;AACtB"}