@webiny/api-opensearch-aws 6.6.0-alpha.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.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) Webiny
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,11 @@
1
+ # @webiny/api-opensearch-aws
2
+
3
+ > [!NOTE]
4
+ > This package is part of the [Webiny](https://www.webiny.com) monorepo.
5
+ > It’s **included in every Webiny project by default** and is not meant to be used as a standalone package.
6
+
7
+ 📘 **Documentation:** [https://www.webiny.com/docs](https://www.webiny.com/docs)
8
+
9
+ ---
10
+
11
+ _This README file is automatically generated during the publish process._
@@ -0,0 +1,2 @@
1
+ import { type OpenSearchClientOptions, type Client } from "@webiny/api-opensearch";
2
+ export declare const createAwsOpenSearchClient: (options: OpenSearchClientOptions) => Client;
@@ -0,0 +1,29 @@
1
+ import { AwsSigv4Signer } from "@opensearch-project/opensearch/aws";
2
+ import { createOpenSearchClient } from "@webiny/api-opensearch";
3
+ import error from "@webiny/error";
4
+ const createAwsOpenSearchClient = (options)=>{
5
+ if (options.auth) return createOpenSearchClient(options);
6
+ const region = process.env.AWS_REGION;
7
+ if (!region) throw new error("Missing AWS_REGION environment variable.", "MISSING_AWS_REGION");
8
+ return createOpenSearchClient({
9
+ ...options,
10
+ ...AwsSigv4Signer({
11
+ region,
12
+ service: "es",
13
+ getCredentials: ()=>{
14
+ const accessKeyId = process.env.AWS_ACCESS_KEY_ID;
15
+ const secretAccessKey = process.env.AWS_SECRET_ACCESS_KEY;
16
+ const sessionToken = process.env.AWS_SESSION_TOKEN;
17
+ if (!accessKeyId || !secretAccessKey) throw new error("Missing AWS credentials (AWS_ACCESS_KEY_ID or AWS_SECRET_ACCESS_KEY).", "MISSING_AWS_CREDENTIALS");
18
+ return Promise.resolve({
19
+ accessKeyId,
20
+ secretAccessKey,
21
+ sessionToken
22
+ });
23
+ }
24
+ })
25
+ });
26
+ };
27
+ export { createAwsOpenSearchClient };
28
+
29
+ //# sourceMappingURL=createAwsOpenSearchClient.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"createAwsOpenSearchClient.js","sources":["../src/createAwsOpenSearchClient.ts"],"sourcesContent":["import { AwsSigv4Signer } from \"@opensearch-project/opensearch/aws\";\nimport {\n createOpenSearchClient,\n type OpenSearchClientOptions,\n type Client\n} from \"@webiny/api-opensearch\";\nimport WebinyError from \"@webiny/error\";\n\nexport const createAwsOpenSearchClient = (options: OpenSearchClientOptions): Client => {\n if (options.auth) {\n return createOpenSearchClient(options);\n }\n\n const region = process.env.AWS_REGION;\n if (!region) {\n throw new WebinyError(\"Missing AWS_REGION environment variable.\", \"MISSING_AWS_REGION\");\n }\n\n return createOpenSearchClient({\n ...options,\n ...AwsSigv4Signer({\n region,\n service: \"es\",\n getCredentials: () => {\n const accessKeyId = process.env.AWS_ACCESS_KEY_ID;\n const secretAccessKey = process.env.AWS_SECRET_ACCESS_KEY;\n const sessionToken = process.env.AWS_SESSION_TOKEN;\n\n if (!accessKeyId || !secretAccessKey) {\n throw new WebinyError(\n \"Missing AWS credentials (AWS_ACCESS_KEY_ID or AWS_SECRET_ACCESS_KEY).\",\n \"MISSING_AWS_CREDENTIALS\"\n );\n }\n\n return Promise.resolve({ accessKeyId, secretAccessKey, sessionToken });\n }\n })\n });\n};\n"],"names":["createAwsOpenSearchClient","options","createOpenSearchClient","region","process","WebinyError","AwsSigv4Signer","accessKeyId","secretAccessKey","sessionToken","Promise"],"mappings":";;;AAQO,MAAMA,4BAA4B,CAACC;IACtC,IAAIA,QAAQ,IAAI,EACZ,OAAOC,uBAAuBD;IAGlC,MAAME,SAASC,QAAQ,GAAG,CAAC,UAAU;IACrC,IAAI,CAACD,QACD,MAAM,IAAIE,MAAY,4CAA4C;IAGtE,OAAOH,uBAAuB;QAC1B,GAAGD,OAAO;QACV,GAAGK,eAAe;YACdH;YACA,SAAS;YACT,gBAAgB;gBACZ,MAAMI,cAAcH,QAAQ,GAAG,CAAC,iBAAiB;gBACjD,MAAMI,kBAAkBJ,QAAQ,GAAG,CAAC,qBAAqB;gBACzD,MAAMK,eAAeL,QAAQ,GAAG,CAAC,iBAAiB;gBAElD,IAAI,CAACG,eAAe,CAACC,iBACjB,MAAM,IAAIH,MACN,yEACA;gBAIR,OAAOK,QAAQ,OAAO,CAAC;oBAAEH;oBAAaC;oBAAiBC;gBAAa;YACxE;QACJ,EAAE;IACN;AACJ"}
@@ -0,0 +1,9 @@
1
+ import { OpenSearchClientFactory as OpenSearchClientFactoryAbstraction } from "@webiny/api-opensearch/features/OpenSearchClientFactory/abstraction.js";
2
+ import type { Client, OpenSearchClientOptions } from "@webiny/api-opensearch";
3
+ declare class AwsOpenSearchClientFactoryImpl implements OpenSearchClientFactoryAbstraction.Interface {
4
+ getClient(params: OpenSearchClientOptions): Client;
5
+ }
6
+ export declare const AwsOpenSearchClientFactory: typeof AwsOpenSearchClientFactoryImpl & {
7
+ __abstraction: import("@webiny/di").Abstraction<import("@webiny/api-opensearch/features/OpenSearchClientFactory/abstraction.js").IOpenSearchClientFactory>;
8
+ };
9
+ export {};
@@ -0,0 +1,15 @@
1
+ import { OpenSearchClientFactory } from "@webiny/api-opensearch/features/OpenSearchClientFactory/abstraction.js";
2
+ import { createAwsOpenSearchClient } from "../../createAwsOpenSearchClient.js";
3
+ class AwsOpenSearchClientFactoryImpl {
4
+ getClient(params) {
5
+ if (!params.endpoint && !params.node && !params.nodes) throw new Error("OpenSearch client requires an endpoint, nodes or node to be specified.");
6
+ return createAwsOpenSearchClient(params);
7
+ }
8
+ }
9
+ const AwsOpenSearchClientFactory = OpenSearchClientFactory.createImplementation({
10
+ implementation: AwsOpenSearchClientFactoryImpl,
11
+ dependencies: []
12
+ });
13
+ export { AwsOpenSearchClientFactory };
14
+
15
+ //# sourceMappingURL=AwsOpenSearchClientFactory.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"features/AwsOpenSearchClientFactory/AwsOpenSearchClientFactory.js","sources":["../../../src/features/AwsOpenSearchClientFactory/AwsOpenSearchClientFactory.ts"],"sourcesContent":["import { OpenSearchClientFactory as OpenSearchClientFactoryAbstraction } from \"@webiny/api-opensearch/features/OpenSearchClientFactory/abstraction.js\";\nimport type { Client, OpenSearchClientOptions } from \"@webiny/api-opensearch\";\nimport { createAwsOpenSearchClient } from \"~/createAwsOpenSearchClient.js\";\n\nclass AwsOpenSearchClientFactoryImpl implements OpenSearchClientFactoryAbstraction.Interface {\n public getClient(params: OpenSearchClientOptions): Client {\n if (!params.endpoint && !params.node && !params.nodes) {\n throw new Error(\n \"OpenSearch client requires an endpoint, nodes or node to be specified.\"\n );\n }\n return createAwsOpenSearchClient(params);\n }\n}\n\nexport const AwsOpenSearchClientFactory = OpenSearchClientFactoryAbstraction.createImplementation({\n implementation: AwsOpenSearchClientFactoryImpl,\n dependencies: []\n});\n"],"names":["AwsOpenSearchClientFactoryImpl","params","Error","createAwsOpenSearchClient","AwsOpenSearchClientFactory","OpenSearchClientFactoryAbstraction"],"mappings":";;AAIA,MAAMA;IACK,UAAUC,MAA+B,EAAU;QACtD,IAAI,CAACA,OAAO,QAAQ,IAAI,CAACA,OAAO,IAAI,IAAI,CAACA,OAAO,KAAK,EACjD,MAAM,IAAIC,MACN;QAGR,OAAOC,0BAA0BF;IACrC;AACJ;AAEO,MAAMG,6BAA6BC,wBAAAA,oBAAuD,CAAC;IAC9F,gBAAgBL;IAChB,cAAc,EAAE;AACpB"}
@@ -0,0 +1,4 @@
1
+ export declare const AwsOpenSearchClientFactoryFeature: {
2
+ name: string;
3
+ register(container: import("@webiny/di").Container): void;
4
+ };
@@ -0,0 +1,11 @@
1
+ import { createFeature } from "@webiny/feature/api/index.js";
2
+ import { AwsOpenSearchClientFactory } from "./AwsOpenSearchClientFactory.js";
3
+ const AwsOpenSearchClientFactoryFeature = createFeature({
4
+ name: "opensearch.aws.clientFactory",
5
+ register (container) {
6
+ container.register(AwsOpenSearchClientFactory).inSingletonScope();
7
+ }
8
+ });
9
+ export { AwsOpenSearchClientFactoryFeature };
10
+
11
+ //# sourceMappingURL=feature.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"features/AwsOpenSearchClientFactory/feature.js","sources":["../../../src/features/AwsOpenSearchClientFactory/feature.ts"],"sourcesContent":["import { createFeature } from \"@webiny/feature/api/index.js\";\nimport { AwsOpenSearchClientFactory } from \"./AwsOpenSearchClientFactory.js\";\n\nexport const AwsOpenSearchClientFactoryFeature = createFeature({\n name: \"opensearch.aws.clientFactory\",\n register(container) {\n container.register(AwsOpenSearchClientFactory).inSingletonScope();\n }\n});\n"],"names":["AwsOpenSearchClientFactoryFeature","createFeature","container","AwsOpenSearchClientFactory"],"mappings":";;AAGO,MAAMA,oCAAoCC,cAAc;IAC3D,MAAM;IACN,UAASC,SAAS;QACdA,UAAU,QAAQ,CAACC,4BAA4B,gBAAgB;IACnE;AACJ"}
package/index.d.ts ADDED
@@ -0,0 +1,2 @@
1
+ export { AwsOpenSearchClientFactoryFeature } from "./features/AwsOpenSearchClientFactory/feature.js";
2
+ export { createAwsOpenSearchClient } from "./createAwsOpenSearchClient.js";
package/index.js ADDED
@@ -0,0 +1,2 @@
1
+ export { AwsOpenSearchClientFactoryFeature } from "./features/AwsOpenSearchClientFactory/feature.js";
2
+ export { createAwsOpenSearchClient } from "./createAwsOpenSearchClient.js";
package/package.json ADDED
@@ -0,0 +1,35 @@
1
+ {
2
+ "name": "@webiny/api-opensearch-aws",
3
+ "version": "6.6.0-alpha.0",
4
+ "type": "module",
5
+ "exports": {
6
+ ".": "./index.js",
7
+ "./*": "./*"
8
+ },
9
+ "repository": {
10
+ "type": "git",
11
+ "url": "https://github.com/webiny/webiny-js.git",
12
+ "directory": "packages/api-opensearch-aws"
13
+ },
14
+ "description": "AWS-specific OpenSearch client factory for Webiny.",
15
+ "license": "MIT",
16
+ "dependencies": {
17
+ "@opensearch-project/opensearch": "3.6.0",
18
+ "@webiny/api-opensearch": "6.6.0-alpha.0",
19
+ "@webiny/error": "6.6.0-alpha.0",
20
+ "@webiny/feature": "6.6.0-alpha.0"
21
+ },
22
+ "devDependencies": {
23
+ "@webiny/build-tools": "6.6.0-alpha.0",
24
+ "@webiny/project-utils": "6.6.0-alpha.0",
25
+ "rimraf": "6.1.3",
26
+ "typescript": "7.0.2",
27
+ "vitest": "4.1.10"
28
+ },
29
+ "publishConfig": {
30
+ "access": "public"
31
+ },
32
+ "webiny": {
33
+ "publishFrom": "dist"
34
+ }
35
+ }