@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
package/index.js CHANGED
@@ -13,28 +13,26 @@ export * from "./limit.js";
13
13
  export * from "./normalize.js";
14
14
  export * from "./operators.js";
15
15
  export * from "./cursors.js";
16
- export { createOpenSearchClient } from "./client.js";
17
16
  export * from "./utils/index.js";
18
17
  export * from "./operations/index.js";
19
18
  export * from "./sharedIndex.js";
20
19
  export * from "./indexPrefix.js";
21
20
  export * from "./db/index.js";
22
21
  export * from "./types.js";
23
- export const createOpenSearchContext = params => {
24
- const plugin = new ContextPlugin(context => {
25
- if (context.opensearch) {
26
- throw new Error("OpenSearch context must not be loaded more than once!");
27
- }
28
- const client = params instanceof Client ? params : createOpenSearchClient(params);
29
- context.opensearch = client;
30
- context.elasticsearch = client;
31
- context.plugins.register(getOpenSearchOperators());
32
- OpenSearchContextFeature.register(context.container, context);
33
- OpenSearchClientFeature.register(context.container);
34
- OpenSearchClientFactoryFeature.register(context.container);
35
- });
36
- plugin.name = "context.opensearch";
37
- return plugin;
22
+ const createOpenSearchContext = (params)=>{
23
+ const plugin = new ContextPlugin((context)=>{
24
+ if (context.opensearch) throw new Error("OpenSearch context must not be loaded more than once!");
25
+ const client = params instanceof Client ? params : createOpenSearchClient(params);
26
+ context.opensearch = client;
27
+ context.elasticsearch = client;
28
+ context.plugins.register(getOpenSearchOperators());
29
+ OpenSearchContextFeature.register(context.container, context);
30
+ OpenSearchClientFeature.register(context.container);
31
+ OpenSearchClientFactoryFeature.register(context.container);
32
+ });
33
+ plugin.name = "context.opensearch";
34
+ return plugin;
38
35
  };
36
+ export { createOpenSearchClient, createOpenSearchContext };
39
37
 
40
38
  //# sourceMappingURL=index.js.map
package/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"names":["ContextPlugin","Client","createOpenSearchClient","getOpenSearchOperators","OpenSearchClientFactoryFeature","OpenSearchClientFeature","OpenSearchContextFeature","createOpenSearchContext","params","plugin","context","opensearch","Error","client","elasticsearch","plugins","register","container","name"],"sources":["index.ts"],"sourcesContent":["import type { OpenSearchContext } from \"./types.js\";\nimport { ContextPlugin } from \"@webiny/api\";\nimport type { OpenSearchClientOptions } from \"./client.js\";\nimport { Client, createOpenSearchClient } from \"./client.js\";\nimport { getOpenSearchOperators } from \"./operators.js\";\nimport { OpenSearchClientFactoryFeature } from \"./features/OpenSearchClientFactory/feature.js\";\nimport { OpenSearchClientFeature } from \"./features/OpenSearchClient/feature.js\";\nimport { OpenSearchContextFeature } from \"~/features/OpenSearchContext/feature.js\";\n\nexport * from \"./indexConfiguration/index.js\";\nexport * from \"./plugins/index.js\";\nexport * from \"./sort.js\";\nexport * from \"./indices.js\";\nexport * from \"./where.js\";\nexport * from \"./limit.js\";\nexport * from \"./normalize.js\";\nexport * from \"./operators.js\";\nexport * from \"./cursors.js\";\nexport {\n createOpenSearchClient,\n type Client,\n type ClientOptions,\n type OpenSearchClientOptions\n} from \"./client.js\";\nexport * from \"./utils/index.js\";\nexport * from \"./operations/index.js\";\nexport * from \"./sharedIndex.js\";\nexport * from \"./indexPrefix.js\";\nexport * from \"./db/index.js\";\nexport * from \"./types.js\";\n\nexport const createOpenSearchContext = (\n params: OpenSearchClientOptions | Client\n): ContextPlugin<OpenSearchContext> => {\n const plugin = new ContextPlugin<OpenSearchContext>(context => {\n if (context.opensearch) {\n throw new Error(\"OpenSearch context must not be loaded more than once!\");\n }\n const client = params instanceof Client ? params : createOpenSearchClient(params);\n context.opensearch = client;\n context.elasticsearch = client;\n\n context.plugins.register(getOpenSearchOperators());\n\n OpenSearchContextFeature.register(context.container, context);\n OpenSearchClientFeature.register(context.container);\n OpenSearchClientFactoryFeature.register(context.container);\n });\n\n plugin.name = \"context.opensearch\";\n\n return plugin;\n};\n"],"mappings":"AACA,SAASA,aAAa,QAAQ,aAAa;AAE3C,SAASC,MAAM,EAAEC,sBAAsB;AACvC,SAASC,sBAAsB;AAC/B,SAASC,8BAA8B;AACvC,SAASC,uBAAuB;AAChC,SAASC,wBAAwB;AAEjC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SACIJ,sBAAsB;AAK1B;AACA;AACA;AACA;AACA;AACA;AAEA,OAAO,MAAMK,uBAAuB,GAChCC,MAAwC,IACL;EACnC,MAAMC,MAAM,GAAG,IAAIT,aAAa,CAAoBU,OAAO,IAAI;IAC3D,IAAIA,OAAO,CAACC,UAAU,EAAE;MACpB,MAAM,IAAIC,KAAK,CAAC,uDAAuD,CAAC;IAC5E;IACA,MAAMC,MAAM,GAAGL,MAAM,YAAYP,MAAM,GAAGO,MAAM,GAAGN,sBAAsB,CAACM,MAAM,CAAC;IACjFE,OAAO,CAACC,UAAU,GAAGE,MAAM;IAC3BH,OAAO,CAACI,aAAa,GAAGD,MAAM;IAE9BH,OAAO,CAACK,OAAO,CAACC,QAAQ,CAACb,sBAAsB,CAAC,CAAC,CAAC;IAElDG,wBAAwB,CAACU,QAAQ,CAACN,OAAO,CAACO,SAAS,EAAEP,OAAO,CAAC;IAC7DL,uBAAuB,CAACW,QAAQ,CAACN,OAAO,CAACO,SAAS,CAAC;IACnDb,8BAA8B,CAACY,QAAQ,CAACN,OAAO,CAACO,SAAS,CAAC;EAC9D,CAAC,CAAC;EAEFR,MAAM,CAACS,IAAI,GAAG,oBAAoB;EAElC,OAAOT,MAAM;AACjB,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"index.js","sources":["../src/index.ts"],"sourcesContent":["import type { OpenSearchContext } from \"./types.js\";\nimport { ContextPlugin } from \"@webiny/api\";\nimport type { OpenSearchClientOptions } from \"./client.js\";\nimport { Client, createOpenSearchClient } from \"./client.js\";\nimport { getOpenSearchOperators } from \"./operators.js\";\nimport { OpenSearchClientFactoryFeature } from \"./features/OpenSearchClientFactory/feature.js\";\nimport { OpenSearchClientFeature } from \"./features/OpenSearchClient/feature.js\";\nimport { OpenSearchContextFeature } from \"~/features/OpenSearchContext/feature.js\";\n\nexport * from \"./indexConfiguration/index.js\";\nexport * from \"./plugins/index.js\";\nexport * from \"./sort.js\";\nexport * from \"./indices.js\";\nexport * from \"./where.js\";\nexport * from \"./limit.js\";\nexport * from \"./normalize.js\";\nexport * from \"./operators.js\";\nexport * from \"./cursors.js\";\nexport {\n createOpenSearchClient,\n type Client,\n type ClientOptions,\n type OpenSearchClientOptions\n} from \"./client.js\";\nexport * from \"./utils/index.js\";\nexport * from \"./operations/index.js\";\nexport * from \"./sharedIndex.js\";\nexport * from \"./indexPrefix.js\";\nexport * from \"./db/index.js\";\nexport * from \"./types.js\";\n\nexport const createOpenSearchContext = (\n params: OpenSearchClientOptions | Client\n): ContextPlugin<OpenSearchContext> => {\n const plugin = new ContextPlugin<OpenSearchContext>(context => {\n if (context.opensearch) {\n throw new Error(\"OpenSearch context must not be loaded more than once!\");\n }\n const client = params instanceof Client ? params : createOpenSearchClient(params);\n context.opensearch = client;\n context.elasticsearch = client;\n\n context.plugins.register(getOpenSearchOperators());\n\n OpenSearchContextFeature.register(context.container, context);\n OpenSearchClientFeature.register(context.container);\n OpenSearchClientFactoryFeature.register(context.container);\n });\n\n plugin.name = \"context.opensearch\";\n\n return plugin;\n};\n"],"names":["createOpenSearchContext","params","plugin","ContextPlugin","context","Error","client","Client","createOpenSearchClient","getOpenSearchOperators","OpenSearchContextFeature","OpenSearchClientFeature","OpenSearchClientFactoryFeature"],"mappings":";;;;;;;;;;;;;;;;;;;;;AA+BO,MAAMA,0BAA0B,CACnCC;IAEA,MAAMC,SAAS,IAAIC,cAAiCC,CAAAA;QAChD,IAAIA,QAAQ,UAAU,EAClB,MAAM,IAAIC,MAAM;QAEpB,MAAMC,SAASL,kBAAkBM,SAASN,SAASO,uBAAuBP;QAC1EG,QAAQ,UAAU,GAAGE;QACrBF,QAAQ,aAAa,GAAGE;QAExBF,QAAQ,OAAO,CAAC,QAAQ,CAACK;QAEzBC,yBAAyB,QAAQ,CAACN,QAAQ,SAAS,EAAEA;QACrDO,wBAAwB,QAAQ,CAACP,QAAQ,SAAS;QAClDQ,+BAA+B,QAAQ,CAACR,QAAQ,SAAS;IAC7D;IAEAF,OAAO,IAAI,GAAG;IAEd,OAAOA;AACX"}
@@ -1,35 +1,34 @@
1
1
  import { getCommonMappings } from "./common.js";
2
2
  const config = {
3
- mappings: {
4
- dynamic_templates: getCommonMappings(mappings => {
5
- return mappings.concat([{
6
- strings: {
7
- match_mapping_type: "string",
8
- mapping: {
9
- type: "text",
10
- fields: {
11
- keyword: {
12
- type: "keyword",
13
- ignore_above: 256
14
- }
3
+ mappings: {
4
+ dynamic_templates: getCommonMappings((mappings)=>mappings.concat([
5
+ {
6
+ strings: {
7
+ match_mapping_type: "string",
8
+ mapping: {
9
+ type: "text",
10
+ fields: {
11
+ keyword: {
12
+ type: "keyword",
13
+ ignore_above: 256
14
+ }
15
+ }
16
+ }
17
+ }
18
+ }
19
+ ])),
20
+ properties: {
21
+ rawValues: {
22
+ type: "object",
23
+ enabled: false
15
24
  }
16
- }
17
25
  }
18
- }]);
19
- }),
20
- properties: {
21
- rawValues: {
22
- type: "object",
23
- enabled: false
24
- }
25
26
  }
26
- }
27
27
  };
28
- export const getBaseConfiguration = modifier => {
29
- if (!modifier) {
30
- return config;
31
- }
32
- return modifier(config);
28
+ const getBaseConfiguration = (modifier)=>{
29
+ if (!modifier) return config;
30
+ return modifier(config);
33
31
  };
32
+ export { getBaseConfiguration };
34
33
 
35
34
  //# sourceMappingURL=base.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["getCommonMappings","config","mappings","dynamic_templates","concat","strings","match_mapping_type","mapping","type","fields","keyword","ignore_above","properties","rawValues","enabled","getBaseConfiguration","modifier"],"sources":["base.ts"],"sourcesContent":["import type { OpenSearchIndexRequestBody } from \"~/types.js\";\nimport { getCommonMappings } from \"./common.js\";\n\nconst config: OpenSearchIndexRequestBody = {\n mappings: {\n dynamic_templates: getCommonMappings(mappings => {\n return mappings.concat([\n {\n strings: {\n match_mapping_type: \"string\",\n mapping: {\n type: \"text\",\n fields: {\n keyword: {\n type: \"keyword\",\n ignore_above: 256\n }\n }\n }\n }\n }\n ]);\n }),\n properties: {\n rawValues: {\n type: \"object\",\n enabled: false\n }\n }\n }\n};\n\ninterface Modifier {\n (config: OpenSearchIndexRequestBody): OpenSearchIndexRequestBody;\n}\nexport const getBaseConfiguration = (modifier?: Modifier) => {\n if (!modifier) {\n return config;\n }\n return modifier(config);\n};\n"],"mappings":"AACA,SAASA,iBAAiB;AAE1B,MAAMC,MAAkC,GAAG;EACvCC,QAAQ,EAAE;IACNC,iBAAiB,EAAEH,iBAAiB,CAACE,QAAQ,IAAI;MAC7C,OAAOA,QAAQ,CAACE,MAAM,CAAC,CACnB;QACIC,OAAO,EAAE;UACLC,kBAAkB,EAAE,QAAQ;UAC5BC,OAAO,EAAE;YACLC,IAAI,EAAE,MAAM;YACZC,MAAM,EAAE;cACJC,OAAO,EAAE;gBACLF,IAAI,EAAE,SAAS;gBACfG,YAAY,EAAE;cAClB;YACJ;UACJ;QACJ;MACJ,CAAC,CACJ,CAAC;IACN,CAAC,CAAC;IACFC,UAAU,EAAE;MACRC,SAAS,EAAE;QACPL,IAAI,EAAE,QAAQ;QACdM,OAAO,EAAE;MACb;IACJ;EACJ;AACJ,CAAC;AAKD,OAAO,MAAMC,oBAAoB,GAAIC,QAAmB,IAAK;EACzD,IAAI,CAACA,QAAQ,EAAE;IACX,OAAOf,MAAM;EACjB;EACA,OAAOe,QAAQ,CAACf,MAAM,CAAC;AAC3B,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"indexConfiguration/base.js","sources":["../../src/indexConfiguration/base.ts"],"sourcesContent":["import type { OpenSearchIndexRequestBody } from \"~/types.js\";\nimport { getCommonMappings } from \"./common.js\";\n\nconst config: OpenSearchIndexRequestBody = {\n mappings: {\n dynamic_templates: getCommonMappings(mappings => {\n return mappings.concat([\n {\n strings: {\n match_mapping_type: \"string\",\n mapping: {\n type: \"text\",\n fields: {\n keyword: {\n type: \"keyword\",\n ignore_above: 256\n }\n }\n }\n }\n }\n ]);\n }),\n properties: {\n rawValues: {\n type: \"object\",\n enabled: false\n }\n }\n }\n};\n\ninterface Modifier {\n (config: OpenSearchIndexRequestBody): OpenSearchIndexRequestBody;\n}\nexport const getBaseConfiguration = (modifier?: Modifier) => {\n if (!modifier) {\n return config;\n }\n return modifier(config);\n};\n"],"names":["config","getCommonMappings","mappings","getBaseConfiguration","modifier"],"mappings":";AAGA,MAAMA,SAAqC;IACvC,UAAU;QACN,mBAAmBC,kBAAkBC,CAAAA,WAC1BA,SAAS,MAAM,CAAC;gBACnB;oBACI,SAAS;wBACL,oBAAoB;wBACpB,SAAS;4BACL,MAAM;4BACN,QAAQ;gCACJ,SAAS;oCACL,MAAM;oCACN,cAAc;gCAClB;4BACJ;wBACJ;oBACJ;gBACJ;aACH;QAEL,YAAY;YACR,WAAW;gBACP,MAAM;gBACN,SAAS;YACb;QACJ;IACJ;AACJ;AAKO,MAAMC,uBAAuB,CAACC;IACjC,IAAI,CAACA,UACD,OAAOJ;IAEX,OAAOI,SAASJ;AACpB"}
@@ -1,44 +1,42 @@
1
- const getDefaultMappings = () => {
2
- return [{
3
- ids: {
4
- match: "^id|entryId$",
5
- mapping: {
6
- type: "keyword"
7
- }
8
- }
9
- }, {
10
- /* Update with the correct date fields. */
11
- dates: {
12
- match: "^createdOn|savedOn|publishedOn$",
13
- mapping: {
14
- type: "date"
15
- }
16
- }
17
- }, {
18
- numbers: {
19
- match: "number@*",
20
- mapping: {
21
- type: "scaled_float",
22
- scaling_factor: 10000
23
- }
24
- }
25
- }, {
26
- booleans: {
27
- match: "boolean@*",
28
- mapping: {
29
- type: "boolean"
30
- }
31
- }
32
- }];
33
- };
34
- /**
35
- * @internal
36
- */
37
- export const getCommonMappings = cb => {
38
- if (!cb) {
39
- return getDefaultMappings();
40
- }
41
- return cb(getDefaultMappings());
1
+ const getDefaultMappings = ()=>[
2
+ {
3
+ ids: {
4
+ match: "^id|entryId$",
5
+ mapping: {
6
+ type: "keyword"
7
+ }
8
+ }
9
+ },
10
+ {
11
+ dates: {
12
+ match: "^createdOn|savedOn|publishedOn$",
13
+ mapping: {
14
+ type: "date"
15
+ }
16
+ }
17
+ },
18
+ {
19
+ numbers: {
20
+ match: "number@*",
21
+ mapping: {
22
+ type: "scaled_float",
23
+ scaling_factor: 10000
24
+ }
25
+ }
26
+ },
27
+ {
28
+ booleans: {
29
+ match: "boolean@*",
30
+ mapping: {
31
+ type: "boolean"
32
+ }
33
+ }
34
+ }
35
+ ];
36
+ const getCommonMappings = (cb)=>{
37
+ if (!cb) return getDefaultMappings();
38
+ return cb(getDefaultMappings());
42
39
  };
40
+ export { getCommonMappings };
43
41
 
44
42
  //# sourceMappingURL=common.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["getDefaultMappings","ids","match","mapping","type","dates","numbers","scaling_factor","booleans","getCommonMappings","cb"],"sources":["common.ts"],"sourcesContent":["import type { OpenSearchIndexRequestBodyMappingsDynamicTemplate } from \"~/types.js\";\n\nconst getDefaultMappings = (): OpenSearchIndexRequestBodyMappingsDynamicTemplate[] => {\n return [\n {\n ids: {\n match: \"^id|entryId$\",\n mapping: {\n type: \"keyword\"\n }\n }\n },\n {\n /* Update with the correct date fields. */\n dates: {\n match: \"^createdOn|savedOn|publishedOn$\",\n mapping: {\n type: \"date\"\n }\n }\n },\n {\n numbers: {\n match: \"number@*\",\n mapping: {\n type: \"scaled_float\",\n scaling_factor: 10000\n }\n }\n },\n {\n booleans: {\n match: \"boolean@*\",\n mapping: {\n type: \"boolean\"\n }\n }\n }\n ];\n};\n\ninterface Modifier {\n (\n mappings: OpenSearchIndexRequestBodyMappingsDynamicTemplate[]\n ): OpenSearchIndexRequestBodyMappingsDynamicTemplate[];\n}\n/**\n * @internal\n */\nexport const getCommonMappings = (\n cb?: Modifier\n): OpenSearchIndexRequestBodyMappingsDynamicTemplate[] => {\n if (!cb) {\n return getDefaultMappings();\n }\n\n return cb(getDefaultMappings());\n};\n"],"mappings":"AAEA,MAAMA,kBAAkB,GAAGA,CAAA,KAA2D;EAClF,OAAO,CACH;IACIC,GAAG,EAAE;MACDC,KAAK,EAAE,cAAc;MACrBC,OAAO,EAAE;QACLC,IAAI,EAAE;MACV;IACJ;EACJ,CAAC,EACD;IACI;IACAC,KAAK,EAAE;MACHH,KAAK,EAAE,iCAAiC;MACxCC,OAAO,EAAE;QACLC,IAAI,EAAE;MACV;IACJ;EACJ,CAAC,EACD;IACIE,OAAO,EAAE;MACLJ,KAAK,EAAE,UAAU;MACjBC,OAAO,EAAE;QACLC,IAAI,EAAE,cAAc;QACpBG,cAAc,EAAE;MACpB;IACJ;EACJ,CAAC,EACD;IACIC,QAAQ,EAAE;MACNN,KAAK,EAAE,WAAW;MAClBC,OAAO,EAAE;QACLC,IAAI,EAAE;MACV;IACJ;EACJ,CAAC,CACJ;AACL,CAAC;AAOD;AACA;AACA;AACA,OAAO,MAAMK,iBAAiB,GAC1BC,EAAa,IACyC;EACtD,IAAI,CAACA,EAAE,EAAE;IACL,OAAOV,kBAAkB,CAAC,CAAC;EAC/B;EAEA,OAAOU,EAAE,CAACV,kBAAkB,CAAC,CAAC,CAAC;AACnC,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"indexConfiguration/common.js","sources":["../../src/indexConfiguration/common.ts"],"sourcesContent":["import type { OpenSearchIndexRequestBodyMappingsDynamicTemplate } from \"~/types.js\";\n\nconst getDefaultMappings = (): OpenSearchIndexRequestBodyMappingsDynamicTemplate[] => {\n return [\n {\n ids: {\n match: \"^id|entryId$\",\n mapping: {\n type: \"keyword\"\n }\n }\n },\n {\n /* Update with the correct date fields. */\n dates: {\n match: \"^createdOn|savedOn|publishedOn$\",\n mapping: {\n type: \"date\"\n }\n }\n },\n {\n numbers: {\n match: \"number@*\",\n mapping: {\n type: \"scaled_float\",\n scaling_factor: 10000\n }\n }\n },\n {\n booleans: {\n match: \"boolean@*\",\n mapping: {\n type: \"boolean\"\n }\n }\n }\n ];\n};\n\ninterface Modifier {\n (\n mappings: OpenSearchIndexRequestBodyMappingsDynamicTemplate[]\n ): OpenSearchIndexRequestBodyMappingsDynamicTemplate[];\n}\n/**\n * @internal\n */\nexport const getCommonMappings = (\n cb?: Modifier\n): OpenSearchIndexRequestBodyMappingsDynamicTemplate[] => {\n if (!cb) {\n return getDefaultMappings();\n }\n\n return cb(getDefaultMappings());\n};\n"],"names":["getDefaultMappings","getCommonMappings","cb"],"mappings":"AAEA,MAAMA,qBAAqB,IAChB;QACH;YACI,KAAK;gBACD,OAAO;gBACP,SAAS;oBACL,MAAM;gBACV;YACJ;QACJ;QACA;YAEI,OAAO;gBACH,OAAO;gBACP,SAAS;oBACL,MAAM;gBACV;YACJ;QACJ;QACA;YACI,SAAS;gBACL,OAAO;gBACP,SAAS;oBACL,MAAM;oBACN,gBAAgB;gBACpB;YACJ;QACJ;QACA;YACI,UAAU;gBACN,OAAO;gBACP,SAAS;oBACL,MAAM;gBACV;YACJ;QACJ;KACH;AAWE,MAAMC,oBAAoB,CAC7BC;IAEA,IAAI,CAACA,IACD,OAAOF;IAGX,OAAOE,GAAGF;AACd"}
@@ -1,4 +1,2 @@
1
1
  export * from "./base.js";
2
2
  export * from "./common.js";
3
-
4
- //# sourceMappingURL=index.js.map
package/indexPrefix.js CHANGED
@@ -1,5 +1,4 @@
1
- export const getOpenSearchIndexPrefix = () => {
2
- return process.env.OPENSEARCH_INDEX_PREFIX || process.env.ELASTICSEARCH_INDEX_PREFIX || process.env.WEBINY_OPENSEARCH_INDEX_PREFIX || process.env.WEBINY_ELASTICSEARCH_INDEX_PREFIX || "";
3
- };
1
+ const getOpenSearchIndexPrefix = ()=>process.env.OPENSEARCH_INDEX_PREFIX || process.env.ELASTICSEARCH_INDEX_PREFIX || process.env.WEBINY_OPENSEARCH_INDEX_PREFIX || process.env.WEBINY_ELASTICSEARCH_INDEX_PREFIX || "";
2
+ export { getOpenSearchIndexPrefix };
4
3
 
5
4
  //# sourceMappingURL=indexPrefix.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["getOpenSearchIndexPrefix","process","env","OPENSEARCH_INDEX_PREFIX","ELASTICSEARCH_INDEX_PREFIX","WEBINY_OPENSEARCH_INDEX_PREFIX","WEBINY_ELASTICSEARCH_INDEX_PREFIX"],"sources":["indexPrefix.ts"],"sourcesContent":["export const getOpenSearchIndexPrefix = (): string => {\n return (\n process.env.OPENSEARCH_INDEX_PREFIX ||\n process.env.ELASTICSEARCH_INDEX_PREFIX ||\n process.env.WEBINY_OPENSEARCH_INDEX_PREFIX ||\n process.env.WEBINY_ELASTICSEARCH_INDEX_PREFIX ||\n \"\"\n );\n};\n"],"mappings":"AAAA,OAAO,MAAMA,wBAAwB,GAAGA,CAAA,KAAc;EAClD,OACIC,OAAO,CAACC,GAAG,CAACC,uBAAuB,IACnCF,OAAO,CAACC,GAAG,CAACE,0BAA0B,IACtCH,OAAO,CAACC,GAAG,CAACG,8BAA8B,IAC1CJ,OAAO,CAACC,GAAG,CAACI,iCAAiC,IAC7C,EAAE;AAEV,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"indexPrefix.js","sources":["../src/indexPrefix.ts"],"sourcesContent":["export const getOpenSearchIndexPrefix = (): string => {\n return (\n process.env.OPENSEARCH_INDEX_PREFIX ||\n process.env.ELASTICSEARCH_INDEX_PREFIX ||\n process.env.WEBINY_OPENSEARCH_INDEX_PREFIX ||\n process.env.WEBINY_ELASTICSEARCH_INDEX_PREFIX ||\n \"\"\n );\n};\n"],"names":["getOpenSearchIndexPrefix","process"],"mappings":"AAAO,MAAMA,2BAA2B,IAEhCC,QAAQ,GAAG,CAAC,uBAAuB,IACnCA,QAAQ,GAAG,CAAC,0BAA0B,IACtCA,QAAQ,GAAG,CAAC,8BAA8B,IAC1CA,QAAQ,GAAG,CAAC,iCAAiC,IAC7C"}
package/indices.js CHANGED
@@ -1,20 +1,12 @@
1
- import WebinyError from "@webiny/error";
2
- const listIndicesPlugins = ({
3
- container,
4
- type
5
- }) => {
6
- return container.byType(type).filter(plugin => {
7
- return plugin.canUse();
8
- });
9
- };
10
- export const getLastAddedIndexPlugin = params => {
11
- const plugins = listIndicesPlugins(params);
12
- if (plugins.length === 0) {
13
- throw new WebinyError(`Could not find a single OpenSearchIndexPlugin of type "${params.type}".`, "OPENSEARCH_INDEX_TEMPLATE_ERROR", {
14
- type: params.type
1
+ import error from "@webiny/error";
2
+ const listIndicesPlugins = ({ container, type })=>container.byType(type).filter((plugin)=>plugin.canUse());
3
+ const getLastAddedIndexPlugin = (params)=>{
4
+ const plugins = listIndicesPlugins(params);
5
+ if (0 === plugins.length) throw new error(`Could not find a single OpenSearchIndexPlugin of type "${params.type}".`, "OPENSEARCH_INDEX_TEMPLATE_ERROR", {
6
+ type: params.type
15
7
  });
16
- }
17
- return plugins.pop();
8
+ return plugins.pop();
18
9
  };
10
+ export { getLastAddedIndexPlugin };
19
11
 
20
12
  //# sourceMappingURL=indices.js.map
package/indices.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"names":["WebinyError","listIndicesPlugins","container","type","byType","filter","plugin","canUse","getLastAddedIndexPlugin","params","plugins","length","pop"],"sources":["indices.ts"],"sourcesContent":["import type { OpenSearchIndexPlugin } from \"~/plugins/definition/OpenSearchIndexPlugin.js\";\nimport type { PluginsContainer } from \"@webiny/plugins\";\nimport WebinyError from \"@webiny/error\";\n\ninterface IndicesPluginsParams {\n container: PluginsContainer;\n type: string;\n}\nconst listIndicesPlugins = <T extends OpenSearchIndexPlugin>({\n container,\n type\n}: IndicesPluginsParams): T[] => {\n return container.byType<T>(type).filter(plugin => {\n return plugin.canUse();\n });\n};\n\nexport const getLastAddedIndexPlugin = <T extends OpenSearchIndexPlugin>(\n params: IndicesPluginsParams\n): T => {\n const plugins = listIndicesPlugins<T>(params);\n if (plugins.length === 0) {\n throw new WebinyError(\n `Could not find a single OpenSearchIndexPlugin of type \"${params.type}\".`,\n \"OPENSEARCH_INDEX_TEMPLATE_ERROR\",\n {\n type: params.type\n }\n );\n }\n\n return plugins.pop() as T;\n};\n"],"mappings":"AAEA,OAAOA,WAAW,MAAM,eAAe;AAMvC,MAAMC,kBAAkB,GAAGA,CAAkC;EACzDC,SAAS;EACTC;AACkB,CAAC,KAAU;EAC7B,OAAOD,SAAS,CAACE,MAAM,CAAID,IAAI,CAAC,CAACE,MAAM,CAACC,MAAM,IAAI;IAC9C,OAAOA,MAAM,CAACC,MAAM,CAAC,CAAC;EAC1B,CAAC,CAAC;AACN,CAAC;AAED,OAAO,MAAMC,uBAAuB,GAChCC,MAA4B,IACxB;EACJ,MAAMC,OAAO,GAAGT,kBAAkB,CAAIQ,MAAM,CAAC;EAC7C,IAAIC,OAAO,CAACC,MAAM,KAAK,CAAC,EAAE;IACtB,MAAM,IAAIX,WAAW,CACjB,0DAA0DS,MAAM,CAACN,IAAI,IAAI,EACzE,iCAAiC,EACjC;MACIA,IAAI,EAAEM,MAAM,CAACN;IACjB,CACJ,CAAC;EACL;EAEA,OAAOO,OAAO,CAACE,GAAG,CAAC,CAAC;AACxB,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"indices.js","sources":["../src/indices.ts"],"sourcesContent":["import type { OpenSearchIndexPlugin } from \"~/plugins/definition/OpenSearchIndexPlugin.js\";\nimport type { PluginsContainer } from \"@webiny/plugins\";\nimport WebinyError from \"@webiny/error\";\n\ninterface IndicesPluginsParams {\n container: PluginsContainer;\n type: string;\n}\nconst listIndicesPlugins = <T extends OpenSearchIndexPlugin>({\n container,\n type\n}: IndicesPluginsParams): T[] => {\n return container.byType<T>(type).filter(plugin => {\n return plugin.canUse();\n });\n};\n\nexport const getLastAddedIndexPlugin = <T extends OpenSearchIndexPlugin>(\n params: IndicesPluginsParams\n): T => {\n const plugins = listIndicesPlugins<T>(params);\n if (plugins.length === 0) {\n throw new WebinyError(\n `Could not find a single OpenSearchIndexPlugin of type \"${params.type}\".`,\n \"OPENSEARCH_INDEX_TEMPLATE_ERROR\",\n {\n type: params.type\n }\n );\n }\n\n return plugins.pop() as T;\n};\n"],"names":["listIndicesPlugins","container","type","plugin","getLastAddedIndexPlugin","params","plugins","WebinyError"],"mappings":";AAQA,MAAMA,qBAAqB,CAAkC,EACzDC,SAAS,EACTC,IAAI,EACe,GACZD,UAAU,MAAM,CAAIC,MAAM,MAAM,CAACC,CAAAA,SAC7BA,OAAO,MAAM;AAIrB,MAAMC,0BAA0B,CACnCC;IAEA,MAAMC,UAAUN,mBAAsBK;IACtC,IAAIC,AAAmB,MAAnBA,QAAQ,MAAM,EACd,MAAM,IAAIC,MACN,CAAC,uDAAuD,EAAEF,OAAO,IAAI,CAAC,EAAE,CAAC,EACzE,mCACA;QACI,MAAMA,OAAO,IAAI;IACrB;IAIR,OAAOC,QAAQ,GAAG;AACtB"}
package/limit.js CHANGED
@@ -1,32 +1,10 @@
1
- /**
2
- * This is the max limit of the OpenSearch.
3
- * Change here if it changes (and if it is necessary).
4
- */
5
1
  const ES_LIMIT_MAX = 10000;
6
- /**
7
- * Our system default limit.
8
- */
9
2
  const ES_LIMIT_DEFAULT = 50;
10
- export const createLimit = (limit, defaultValue = ES_LIMIT_DEFAULT) => {
11
- /**
12
- * Limit can possibly be null/undefined or less than 1.
13
- * In that case return the defaults.
14
- */
15
- if (!limit || limit < 1) {
16
- return defaultValue;
17
- }
18
- /**
19
- * Users input limit cannot be greater than the OpenSearch one.
20
- * OpenSearch query breaks because of that.
21
- */
22
- if (limit < ES_LIMIT_MAX) {
23
- return limit;
24
- }
25
- /**
26
- * Always reduce by 1 because we check if there are more items by adding 1 to the limit
27
- * and then remove that last one loaded.
28
- */
29
- return ES_LIMIT_MAX - 1;
3
+ const createLimit = (limit, defaultValue = ES_LIMIT_DEFAULT)=>{
4
+ if (!limit || limit < 1) return defaultValue;
5
+ if (limit < ES_LIMIT_MAX) return limit;
6
+ return ES_LIMIT_MAX - 1;
30
7
  };
8
+ export { createLimit };
31
9
 
32
10
  //# sourceMappingURL=limit.js.map
package/limit.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"names":["ES_LIMIT_MAX","ES_LIMIT_DEFAULT","createLimit","limit","defaultValue"],"sources":["limit.ts"],"sourcesContent":["/**\n * This is the max limit of the OpenSearch.\n * Change here if it changes (and if it is necessary).\n */\nconst ES_LIMIT_MAX = 10000;\n/**\n * Our system default limit.\n */\nconst ES_LIMIT_DEFAULT = 50;\n\nexport const createLimit = (limit?: number, defaultValue = ES_LIMIT_DEFAULT): number => {\n /**\n * Limit can possibly be null/undefined or less than 1.\n * In that case return the defaults.\n */\n if (!limit || limit < 1) {\n return defaultValue;\n }\n /**\n * Users input limit cannot be greater than the OpenSearch one.\n * OpenSearch query breaks because of that.\n */\n if (limit < ES_LIMIT_MAX) {\n return limit;\n }\n /**\n * Always reduce by 1 because we check if there are more items by adding 1 to the limit\n * and then remove that last one loaded.\n */\n return ES_LIMIT_MAX - 1;\n};\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA,MAAMA,YAAY,GAAG,KAAK;AAC1B;AACA;AACA;AACA,MAAMC,gBAAgB,GAAG,EAAE;AAE3B,OAAO,MAAMC,WAAW,GAAGA,CAACC,KAAc,EAAEC,YAAY,GAAGH,gBAAgB,KAAa;EACpF;AACJ;AACA;AACA;EACI,IAAI,CAACE,KAAK,IAAIA,KAAK,GAAG,CAAC,EAAE;IACrB,OAAOC,YAAY;EACvB;EACA;AACJ;AACA;AACA;EACI,IAAID,KAAK,GAAGH,YAAY,EAAE;IACtB,OAAOG,KAAK;EAChB;EACA;AACJ;AACA;AACA;EACI,OAAOH,YAAY,GAAG,CAAC;AAC3B,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"limit.js","sources":["../src/limit.ts"],"sourcesContent":["/**\n * This is the max limit of the OpenSearch.\n * Change here if it changes (and if it is necessary).\n */\nconst ES_LIMIT_MAX = 10000;\n/**\n * Our system default limit.\n */\nconst ES_LIMIT_DEFAULT = 50;\n\nexport const createLimit = (limit?: number, defaultValue = ES_LIMIT_DEFAULT): number => {\n /**\n * Limit can possibly be null/undefined or less than 1.\n * In that case return the defaults.\n */\n if (!limit || limit < 1) {\n return defaultValue;\n }\n /**\n * Users input limit cannot be greater than the OpenSearch one.\n * OpenSearch query breaks because of that.\n */\n if (limit < ES_LIMIT_MAX) {\n return limit;\n }\n /**\n * Always reduce by 1 because we check if there are more items by adding 1 to the limit\n * and then remove that last one loaded.\n */\n return ES_LIMIT_MAX - 1;\n};\n"],"names":["ES_LIMIT_MAX","ES_LIMIT_DEFAULT","createLimit","limit","defaultValue"],"mappings":"AAIA,MAAMA,eAAe;AAIrB,MAAMC,mBAAmB;AAElB,MAAMC,cAAc,CAACC,OAAgBC,eAAeH,gBAAgB;IAKvE,IAAI,CAACE,SAASA,QAAQ,GAClB,OAAOC;IAMX,IAAID,QAAQH,cACR,OAAOG;IAMX,OAAOH,eAAe;AAC1B"}
package/normalize.js CHANGED
@@ -1,54 +1,55 @@
1
- /**
2
- * Before performing the query, we need to escape all special characters.
3
- * @see https://opensearch.org/docs/latest/query-dsl/full-text/query-string/
4
- */
5
-
6
- const specialCharactersToRemove = [`\\?`];
7
- const specialCharacterToSpace = ["-", "\\\\"];
8
- const specialCharacters = ["\\\\", "\\+",
9
- // "\\-",
10
- "\\=", `&`, `\\|`, ">", "<", `!`, "\\(", "\\)", "\\{", "\\}", "\\[", "\\]", "\\^", '\\"', "\\~", "\\*", `:`, `/`, "\\#"];
11
- export const normalizeValue = value => {
12
- let result = value || "";
13
- if (!result) {
14
- return result;
15
- }
16
- for (const character of specialCharactersToRemove) {
17
- result = result.replace(new RegExp(character, "g"), "");
18
- }
19
- for (const character of specialCharacterToSpace) {
20
- result = result.replace(new RegExp(character, "g"), " ");
21
- }
22
- for (const character of specialCharacters) {
23
- result = result.replace(new RegExp(character, "g"), `\\${character}`);
24
- }
25
- return result || "";
1
+ const specialCharactersToRemove = [
2
+ "\\?"
3
+ ];
4
+ const specialCharacterToSpace = [
5
+ "-",
6
+ "\\\\"
7
+ ];
8
+ const specialCharacters = [
9
+ "\\\\",
10
+ "\\+",
11
+ "\\=",
12
+ "&",
13
+ "\\|",
14
+ ">",
15
+ "<",
16
+ "!",
17
+ "\\(",
18
+ "\\)",
19
+ "\\{",
20
+ "\\}",
21
+ "\\[",
22
+ "\\]",
23
+ "\\^",
24
+ '\\"',
25
+ "\\~",
26
+ "\\*",
27
+ ":",
28
+ "/",
29
+ "\\#"
30
+ ];
31
+ const normalizeValue = (value)=>{
32
+ let result = value || "";
33
+ if (!result) return result;
34
+ for (const character of specialCharactersToRemove)result = result.replace(new RegExp(character, "g"), "");
35
+ for (const character of specialCharacterToSpace)result = result.replace(new RegExp(character, "g"), " ");
36
+ for (const character of specialCharacters)result = result.replace(new RegExp(character, "g"), `\\${character}`);
37
+ return result || "";
26
38
  };
27
- const hasSpecialChar = value => {
28
- if (!value) {
29
- return null;
30
- }
31
- return value.match(/^([0-9a-zA-Z]+)$/i) === null;
39
+ const hasSpecialChar = (value)=>{
40
+ if (!value) return null;
41
+ return null === value.match(/^([0-9a-zA-Z]+)$/i);
32
42
  };
33
- export const normalizeValueWithAsterisk = initial => {
34
- const value = normalizeValue(initial);
35
- const results = value.split(" ");
36
- let result = value;
37
- /**
38
- * If there is a / in the first word, do not put asterisk in front of it.
39
- */
40
- const firstWord = results[0];
41
- if (hasSpecialChar(firstWord) === false) {
42
- result = `*${result}`;
43
- }
44
- /**
45
- * If there is a / in the last word, do not put asterisk at the end of it.
46
- */
47
- const lastWord = results[results.length - 1];
48
- if (hasSpecialChar(lastWord) === false) {
49
- result = `${result}*`;
50
- }
51
- return result;
43
+ const normalizeValueWithAsterisk = (initial)=>{
44
+ const value = normalizeValue(initial);
45
+ const results = value.split(" ");
46
+ let result = value;
47
+ const firstWord = results[0];
48
+ if (false === hasSpecialChar(firstWord)) result = `*${result}`;
49
+ const lastWord = results[results.length - 1];
50
+ if (false === hasSpecialChar(lastWord)) result = `${result}*`;
51
+ return result;
52
52
  };
53
+ export { normalizeValue, normalizeValueWithAsterisk };
53
54
 
54
55
  //# sourceMappingURL=normalize.js.map
package/normalize.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"names":["specialCharactersToRemove","specialCharacterToSpace","specialCharacters","normalizeValue","value","result","character","replace","RegExp","hasSpecialChar","match","normalizeValueWithAsterisk","initial","results","split","firstWord","lastWord","length"],"sources":["normalize.ts"],"sourcesContent":["/**\n * Before performing the query, we need to escape all special characters.\n * @see https://opensearch.org/docs/latest/query-dsl/full-text/query-string/\n */\n\nconst specialCharactersToRemove = [`\\\\?`];\n\nconst specialCharacterToSpace = [\"-\", \"\\\\\\\\\"];\n\nconst specialCharacters = [\n \"\\\\\\\\\",\n \"\\\\+\",\n // \"\\\\-\",\n \"\\\\=\",\n `&`,\n `\\\\|`,\n \">\",\n \"<\",\n `!`,\n \"\\\\(\",\n \"\\\\)\",\n \"\\\\{\",\n \"\\\\}\",\n \"\\\\[\",\n \"\\\\]\",\n \"\\\\^\",\n '\\\\\"',\n \"\\\\~\",\n \"\\\\*\",\n `:`,\n `/`,\n \"\\\\#\"\n];\n\nexport const normalizeValue = (value: string) => {\n let result = value || \"\";\n if (!result) {\n return result;\n }\n for (const character of specialCharactersToRemove) {\n result = result.replace(new RegExp(character, \"g\"), \"\");\n }\n for (const character of specialCharacterToSpace) {\n result = result.replace(new RegExp(character, \"g\"), \" \");\n }\n\n for (const character of specialCharacters) {\n result = result.replace(new RegExp(character, \"g\"), `\\\\${character}`);\n }\n\n return result || \"\";\n};\n\nconst hasSpecialChar = (value: string): boolean | null => {\n if (!value) {\n return null;\n }\n return value.match(/^([0-9a-zA-Z]+)$/i) === null;\n};\n\nexport const normalizeValueWithAsterisk = (initial: string) => {\n const value = normalizeValue(initial);\n const results = value.split(\" \");\n\n let result = value;\n /**\n * If there is a / in the first word, do not put asterisk in front of it.\n */\n const firstWord = results[0];\n if (hasSpecialChar(firstWord) === false) {\n result = `*${result}`;\n }\n /**\n * If there is a / in the last word, do not put asterisk at the end of it.\n */\n const lastWord = results[results.length - 1];\n if (hasSpecialChar(lastWord) === false) {\n result = `${result}*`;\n }\n\n return result;\n};\n"],"mappings":"AAAA;AACA;AACA;AACA;;AAEA,MAAMA,yBAAyB,GAAG,CAAC,KAAK,CAAC;AAEzC,MAAMC,uBAAuB,GAAG,CAAC,GAAG,EAAE,MAAM,CAAC;AAE7C,MAAMC,iBAAiB,GAAG,CACtB,MAAM,EACN,KAAK;AACL;AACA,KAAK,EACL,GAAG,EACH,KAAK,EACL,GAAG,EACH,GAAG,EACH,GAAG,EACH,KAAK,EACL,KAAK,EACL,KAAK,EACL,KAAK,EACL,KAAK,EACL,KAAK,EACL,KAAK,EACL,KAAK,EACL,KAAK,EACL,KAAK,EACL,GAAG,EACH,GAAG,EACH,KAAK,CACR;AAED,OAAO,MAAMC,cAAc,GAAIC,KAAa,IAAK;EAC7C,IAAIC,MAAM,GAAGD,KAAK,IAAI,EAAE;EACxB,IAAI,CAACC,MAAM,EAAE;IACT,OAAOA,MAAM;EACjB;EACA,KAAK,MAAMC,SAAS,IAAIN,yBAAyB,EAAE;IAC/CK,MAAM,GAAGA,MAAM,CAACE,OAAO,CAAC,IAAIC,MAAM,CAACF,SAAS,EAAE,GAAG,CAAC,EAAE,EAAE,CAAC;EAC3D;EACA,KAAK,MAAMA,SAAS,IAAIL,uBAAuB,EAAE;IAC7CI,MAAM,GAAGA,MAAM,CAACE,OAAO,CAAC,IAAIC,MAAM,CAACF,SAAS,EAAE,GAAG,CAAC,EAAE,GAAG,CAAC;EAC5D;EAEA,KAAK,MAAMA,SAAS,IAAIJ,iBAAiB,EAAE;IACvCG,MAAM,GAAGA,MAAM,CAACE,OAAO,CAAC,IAAIC,MAAM,CAACF,SAAS,EAAE,GAAG,CAAC,EAAE,KAAKA,SAAS,EAAE,CAAC;EACzE;EAEA,OAAOD,MAAM,IAAI,EAAE;AACvB,CAAC;AAED,MAAMI,cAAc,GAAIL,KAAa,IAAqB;EACtD,IAAI,CAACA,KAAK,EAAE;IACR,OAAO,IAAI;EACf;EACA,OAAOA,KAAK,CAACM,KAAK,CAAC,mBAAmB,CAAC,KAAK,IAAI;AACpD,CAAC;AAED,OAAO,MAAMC,0BAA0B,GAAIC,OAAe,IAAK;EAC3D,MAAMR,KAAK,GAAGD,cAAc,CAACS,OAAO,CAAC;EACrC,MAAMC,OAAO,GAAGT,KAAK,CAACU,KAAK,CAAC,GAAG,CAAC;EAEhC,IAAIT,MAAM,GAAGD,KAAK;EAClB;AACJ;AACA;EACI,MAAMW,SAAS,GAAGF,OAAO,CAAC,CAAC,CAAC;EAC5B,IAAIJ,cAAc,CAACM,SAAS,CAAC,KAAK,KAAK,EAAE;IACrCV,MAAM,GAAG,IAAIA,MAAM,EAAE;EACzB;EACA;AACJ;AACA;EACI,MAAMW,QAAQ,GAAGH,OAAO,CAACA,OAAO,CAACI,MAAM,GAAG,CAAC,CAAC;EAC5C,IAAIR,cAAc,CAACO,QAAQ,CAAC,KAAK,KAAK,EAAE;IACpCX,MAAM,GAAG,GAAGA,MAAM,GAAG;EACzB;EAEA,OAAOA,MAAM;AACjB,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"normalize.js","sources":["../src/normalize.ts"],"sourcesContent":["/**\n * Before performing the query, we need to escape all special characters.\n * @see https://opensearch.org/docs/latest/query-dsl/full-text/query-string/\n */\n\nconst specialCharactersToRemove = [`\\\\?`];\n\nconst specialCharacterToSpace = [\"-\", \"\\\\\\\\\"];\n\nconst specialCharacters = [\n \"\\\\\\\\\",\n \"\\\\+\",\n // \"\\\\-\",\n \"\\\\=\",\n `&`,\n `\\\\|`,\n \">\",\n \"<\",\n `!`,\n \"\\\\(\",\n \"\\\\)\",\n \"\\\\{\",\n \"\\\\}\",\n \"\\\\[\",\n \"\\\\]\",\n \"\\\\^\",\n '\\\\\"',\n \"\\\\~\",\n \"\\\\*\",\n `:`,\n `/`,\n \"\\\\#\"\n];\n\nexport const normalizeValue = (value: string) => {\n let result = value || \"\";\n if (!result) {\n return result;\n }\n for (const character of specialCharactersToRemove) {\n result = result.replace(new RegExp(character, \"g\"), \"\");\n }\n for (const character of specialCharacterToSpace) {\n result = result.replace(new RegExp(character, \"g\"), \" \");\n }\n\n for (const character of specialCharacters) {\n result = result.replace(new RegExp(character, \"g\"), `\\\\${character}`);\n }\n\n return result || \"\";\n};\n\nconst hasSpecialChar = (value: string): boolean | null => {\n if (!value) {\n return null;\n }\n return value.match(/^([0-9a-zA-Z]+)$/i) === null;\n};\n\nexport const normalizeValueWithAsterisk = (initial: string) => {\n const value = normalizeValue(initial);\n const results = value.split(\" \");\n\n let result = value;\n /**\n * If there is a / in the first word, do not put asterisk in front of it.\n */\n const firstWord = results[0];\n if (hasSpecialChar(firstWord) === false) {\n result = `*${result}`;\n }\n /**\n * If there is a / in the last word, do not put asterisk at the end of it.\n */\n const lastWord = results[results.length - 1];\n if (hasSpecialChar(lastWord) === false) {\n result = `${result}*`;\n }\n\n return result;\n};\n"],"names":["specialCharactersToRemove","specialCharacterToSpace","specialCharacters","normalizeValue","value","result","character","RegExp","hasSpecialChar","normalizeValueWithAsterisk","initial","results","firstWord","lastWord"],"mappings":"AAKA,MAAMA,4BAA4B;IAAC;CAAM;AAEzC,MAAMC,0BAA0B;IAAC;IAAK;CAAO;AAE7C,MAAMC,oBAAoB;IACtB;IACA;IAEA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;CACH;AAEM,MAAMC,iBAAiB,CAACC;IAC3B,IAAIC,SAASD,SAAS;IACtB,IAAI,CAACC,QACD,OAAOA;IAEX,KAAK,MAAMC,aAAaN,0BACpBK,SAASA,OAAO,OAAO,CAAC,IAAIE,OAAOD,WAAW,MAAM;IAExD,KAAK,MAAMA,aAAaL,wBACpBI,SAASA,OAAO,OAAO,CAAC,IAAIE,OAAOD,WAAW,MAAM;IAGxD,KAAK,MAAMA,aAAaJ,kBACpBG,SAASA,OAAO,OAAO,CAAC,IAAIE,OAAOD,WAAW,MAAM,CAAC,EAAE,EAAEA,WAAW;IAGxE,OAAOD,UAAU;AACrB;AAEA,MAAMG,iBAAiB,CAACJ;IACpB,IAAI,CAACA,OACD,OAAO;IAEX,OAAOA,AAAqC,SAArCA,MAAM,KAAK,CAAC;AACvB;AAEO,MAAMK,6BAA6B,CAACC;IACvC,MAAMN,QAAQD,eAAeO;IAC7B,MAAMC,UAAUP,MAAM,KAAK,CAAC;IAE5B,IAAIC,SAASD;IAIb,MAAMQ,YAAYD,OAAO,CAAC,EAAE;IAC5B,IAAIH,AAA8B,UAA9BA,eAAeI,YACfP,SAAS,CAAC,CAAC,EAAEA,QAAQ;IAKzB,MAAMQ,WAAWF,OAAO,CAACA,QAAQ,MAAM,GAAG,EAAE;IAC5C,IAAIH,AAA6B,UAA7BA,eAAeK,WACfR,SAAS,GAAGA,OAAO,CAAC,CAAC;IAGzB,OAAOA;AACX"}
@@ -1,31 +1,30 @@
1
1
  import { WebinyError } from "@webiny/error";
2
2
  import { stripConnectionFromException } from "./stripConnectionFromException.js";
3
- export class OpenSearchCatHealth {
4
- constructor(client) {
5
- this.client = client;
6
- }
7
- async getHealth() {
8
- try {
9
- const response = await this.client.cat.health({
10
- format: "json"
11
- });
12
- if (!Array.isArray(response.body) || response.body.length === 0) {
13
- throw new WebinyError({
14
- message: `There is no valid response from cat.health operation.`,
15
- code: "OPENSEARCH_HEALTH_INVALID_RESPONSE",
16
- data: response.body
17
- });
18
- }
19
- return {
20
- ...response.body[0]
21
- };
22
- } catch (ex) {
23
- console.error(`Could not fetch cluster health information: ${ex.message}`);
24
- const error = stripConnectionFromException(ex);
25
- console.log(JSON.stringify(error));
26
- throw error;
3
+ class OpenSearchCatHealth {
4
+ constructor(client){
5
+ this.client = client;
6
+ }
7
+ async getHealth() {
8
+ try {
9
+ const response = await this.client.cat.health({
10
+ format: "json"
11
+ });
12
+ if (!Array.isArray(response.body) || 0 === response.body.length) throw new WebinyError({
13
+ message: "There is no valid response from cat.health operation.",
14
+ code: "OPENSEARCH_HEALTH_INVALID_RESPONSE",
15
+ data: response.body
16
+ });
17
+ return {
18
+ ...response.body[0]
19
+ };
20
+ } catch (ex) {
21
+ console.error(`Could not fetch cluster health information: ${ex.message}`);
22
+ const error = stripConnectionFromException(ex);
23
+ console.log(JSON.stringify(error));
24
+ throw error;
25
+ }
27
26
  }
28
- }
29
27
  }
28
+ export { OpenSearchCatHealth };
30
29
 
31
30
  //# sourceMappingURL=OpenSearchCatHealth.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["WebinyError","stripConnectionFromException","OpenSearchCatHealth","constructor","client","getHealth","response","cat","health","format","Array","isArray","body","length","message","code","data","ex","console","error","log","JSON","stringify"],"sources":["OpenSearchCatHealth.ts"],"sourcesContent":["import { WebinyError } from \"@webiny/error\";\nimport type { Client } from \"~/client.js\";\nimport type { IOpenSearchCatHealthResponse } from \"./types.js\";\nimport { stripConnectionFromException } from \"~/operations/stripConnectionFromException.js\";\n\nexport class OpenSearchCatHealth {\n private readonly client: Client;\n\n public constructor(client: Client) {\n this.client = client;\n }\n\n public async getHealth(): Promise<IOpenSearchCatHealthResponse> {\n try {\n const response = await this.client.cat.health({\n format: \"json\"\n });\n\n if (!Array.isArray(response.body) || response.body.length === 0) {\n throw new WebinyError({\n message: `There is no valid response from cat.health operation.`,\n code: \"OPENSEARCH_HEALTH_INVALID_RESPONSE\",\n data: response.body\n });\n }\n\n return {\n ...response.body[0]\n };\n } catch (ex) {\n console.error(`Could not fetch cluster health information: ${ex.message}`);\n const error = stripConnectionFromException(ex);\n console.log(JSON.stringify(error));\n throw error;\n }\n }\n}\n"],"mappings":"AAAA,SAASA,WAAW,QAAQ,eAAe;AAG3C,SAASC,4BAA4B;AAErC,OAAO,MAAMC,mBAAmB,CAAC;EAGtBC,WAAWA,CAACC,MAAc,EAAE;IAC/B,IAAI,CAACA,MAAM,GAAGA,MAAM;EACxB;EAEA,MAAaC,SAASA,CAAA,EAA0C;IAC5D,IAAI;MACA,MAAMC,QAAQ,GAAG,MAAM,IAAI,CAACF,MAAM,CAACG,GAAG,CAACC,MAAM,CAAC;QAC1CC,MAAM,EAAE;MACZ,CAAC,CAAC;MAEF,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,uDAAuD;UAChEC,IAAI,EAAE,oCAAoC;UAC1CC,IAAI,EAAEV,QAAQ,CAACM;QACnB,CAAC,CAAC;MACN;MAEA,OAAO;QACH,GAAGN,QAAQ,CAACM,IAAI,CAAC,CAAC;MACtB,CAAC;IACL,CAAC,CAAC,OAAOK,EAAE,EAAE;MACTC,OAAO,CAACC,KAAK,CAAC,+CAA+CF,EAAE,CAACH,OAAO,EAAE,CAAC;MAC1E,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/OpenSearchCatHealth.js","sources":["../../src/operations/OpenSearchCatHealth.ts"],"sourcesContent":["import { WebinyError } from \"@webiny/error\";\nimport type { Client } from \"~/client.js\";\nimport type { IOpenSearchCatHealthResponse } from \"./types.js\";\nimport { stripConnectionFromException } from \"~/operations/stripConnectionFromException.js\";\n\nexport class OpenSearchCatHealth {\n private readonly client: Client;\n\n public constructor(client: Client) {\n this.client = client;\n }\n\n public async getHealth(): Promise<IOpenSearchCatHealthResponse> {\n try {\n const response = await this.client.cat.health({\n format: \"json\"\n });\n\n if (!Array.isArray(response.body) || response.body.length === 0) {\n throw new WebinyError({\n message: `There is no valid response from cat.health operation.`,\n code: \"OPENSEARCH_HEALTH_INVALID_RESPONSE\",\n data: response.body\n });\n }\n\n return {\n ...response.body[0]\n };\n } catch (ex) {\n console.error(`Could not fetch cluster health information: ${ex.message}`);\n const error = stripConnectionFromException(ex);\n console.log(JSON.stringify(error));\n throw error;\n }\n }\n}\n"],"names":["OpenSearchCatHealth","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,YAAmD;QAC5D,IAAI;YACA,MAAMC,WAAW,MAAM,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,MAAM,CAAC;gBAC1C,QAAQ;YACZ;YAEA,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;YAGJ,OAAO;gBACH,GAAGA,SAAS,IAAI,CAAC,EAAE;YACvB;QACJ,EAAE,OAAOG,IAAI;YACTC,QAAQ,KAAK,CAAC,CAAC,4CAA4C,EAAED,GAAG,OAAO,EAAE;YACzE,MAAME,QAAQC,6BAA6BH;YAC3CC,QAAQ,GAAG,CAACG,KAAK,SAAS,CAACF;YAC3B,MAAMA;QACV;IACJ;AACJ"}
@@ -1,29 +1,28 @@
1
1
  import { WebinyError } from "@webiny/error";
2
2
  import { stripConnectionFromException } from "./stripConnectionFromException.js";
3
- export class OpenSearchCatNodes {
4
- constructor(client) {
5
- this.client = client;
6
- }
7
- async getNodes() {
8
- try {
9
- const response = await this.client.cat.nodes({
10
- format: "json"
11
- });
12
- if (!Array.isArray(response.body) || response.body.length === 0) {
13
- throw new WebinyError({
14
- message: `There is no valid response from cat.nodes operation.`,
15
- code: "OPENSEARCH_NODES_INVALID_RESPONSE",
16
- data: response.body
17
- });
18
- }
19
- return response.body;
20
- } catch (ex) {
21
- console.error(`Could not fetch cluster nodes information: ${ex.message}`);
22
- const error = stripConnectionFromException(ex);
23
- console.log(JSON.stringify(error));
24
- throw error;
3
+ class OpenSearchCatNodes {
4
+ constructor(client){
5
+ this.client = client;
6
+ }
7
+ async getNodes() {
8
+ try {
9
+ const response = await this.client.cat.nodes({
10
+ format: "json"
11
+ });
12
+ if (!Array.isArray(response.body) || 0 === response.body.length) throw new WebinyError({
13
+ message: "There is no valid response from cat.nodes operation.",
14
+ code: "OPENSEARCH_NODES_INVALID_RESPONSE",
15
+ data: response.body
16
+ });
17
+ return response.body;
18
+ } catch (ex) {
19
+ console.error(`Could not fetch cluster nodes information: ${ex.message}`);
20
+ const error = stripConnectionFromException(ex);
21
+ console.log(JSON.stringify(error));
22
+ throw error;
23
+ }
25
24
  }
26
- }
27
25
  }
26
+ export { OpenSearchCatNodes };
28
27
 
29
28
  //# sourceMappingURL=OpenSearchCatNodes.js.map