@vercel/aws 0.2.0 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md
CHANGED
package/dist/opensearch.d.ts
CHANGED
|
@@ -11,12 +11,12 @@ import { Client, type ClientOptions } from '@opensearch-project/opensearch';
|
|
|
11
11
|
export interface CreateOpenSearchOptions extends Partial<ClientOptions> {
|
|
12
12
|
/**
|
|
13
13
|
* The OpenSearch collection endpoint. Defaults to
|
|
14
|
-
* `process.env.
|
|
14
|
+
* `process.env.OPENSEARCH_ENDPOINT`.
|
|
15
15
|
*/
|
|
16
16
|
endpoint?: string;
|
|
17
17
|
/**
|
|
18
18
|
* The AWS region the collection lives in. Defaults to
|
|
19
|
-
* `process.env.
|
|
19
|
+
* `process.env.AWS_REGION`.
|
|
20
20
|
*/
|
|
21
21
|
region?: string;
|
|
22
22
|
/**
|
package/dist/opensearch.js
CHANGED
|
@@ -25,14 +25,14 @@ var import_opensearch = require("@opensearch-project/opensearch");
|
|
|
25
25
|
var import_aws = require("@opensearch-project/opensearch/aws");
|
|
26
26
|
var import_oidc_aws_credentials_provider = require("@vercel/oidc-aws-credentials-provider");
|
|
27
27
|
function createOpenSearch(opts = {}) {
|
|
28
|
-
const endpoint = opts.endpoint ?? process.env.
|
|
29
|
-
const region = opts.region ?? process.env.
|
|
28
|
+
const endpoint = opts.endpoint ?? process.env.OPENSEARCH_ENDPOINT;
|
|
29
|
+
const region = opts.region ?? process.env.AWS_REGION;
|
|
30
30
|
const roleArn = opts.roleArn ?? process.env.AWS_ROLE_ARN;
|
|
31
31
|
const missing = [];
|
|
32
32
|
if (!endpoint)
|
|
33
|
-
missing.push("
|
|
33
|
+
missing.push("OPENSEARCH_ENDPOINT");
|
|
34
34
|
if (!region)
|
|
35
|
-
missing.push("
|
|
35
|
+
missing.push("AWS_REGION");
|
|
36
36
|
if (!roleArn)
|
|
37
37
|
missing.push("AWS_ROLE_ARN");
|
|
38
38
|
if (missing.length > 0) {
|
package/dist/opensearch.test.js
CHANGED
|
@@ -20,11 +20,7 @@ import_vitest.vi.mock("@vercel/oidc-aws-credentials-provider", () => ({
|
|
|
20
20
|
secretAccessKey: "SECRET_TEST"
|
|
21
21
|
}))
|
|
22
22
|
}));
|
|
23
|
-
const ENV_KEYS = [
|
|
24
|
-
"OPENSEARCH_DASHBOARD_ENDPOINT",
|
|
25
|
-
"OPENSEARCH_REGION",
|
|
26
|
-
"AWS_ROLE_ARN"
|
|
27
|
-
];
|
|
23
|
+
const ENV_KEYS = ["OPENSEARCH_ENDPOINT", "AWS_REGION", "AWS_ROLE_ARN"];
|
|
28
24
|
(0, import_vitest.describe)("createOpenSearch", () => {
|
|
29
25
|
const originalEnv = {};
|
|
30
26
|
(0, import_vitest.beforeEach)(() => {
|
|
@@ -44,8 +40,8 @@ const ENV_KEYS = [
|
|
|
44
40
|
}
|
|
45
41
|
});
|
|
46
42
|
(0, import_vitest.test)("uses Vercel-injected env vars when no options are provided", async () => {
|
|
47
|
-
process.env.
|
|
48
|
-
process.env.
|
|
43
|
+
process.env.OPENSEARCH_ENDPOINT = "https://example.aoss.amazonaws.com";
|
|
44
|
+
process.env.AWS_REGION = "us-east-2";
|
|
49
45
|
process.env.AWS_ROLE_ARN = "arn:aws:iam::1234567890:role/vercel-opensearch";
|
|
50
46
|
const client = (0, import_opensearch.createOpenSearch)();
|
|
51
47
|
(0, import_vitest.expect)(import_aws.AwsSigv4Signer).toHaveBeenCalledTimes(1);
|
|
@@ -61,8 +57,8 @@ const ENV_KEYS = [
|
|
|
61
57
|
).toBe("https://example.aoss.amazonaws.com");
|
|
62
58
|
});
|
|
63
59
|
(0, import_vitest.test)("explicit options override env", () => {
|
|
64
|
-
process.env.
|
|
65
|
-
process.env.
|
|
60
|
+
process.env.OPENSEARCH_ENDPOINT = "https://env-endpoint.example";
|
|
61
|
+
process.env.AWS_REGION = "us-east-2";
|
|
66
62
|
process.env.AWS_ROLE_ARN = "arn:aws:iam::1:role/env";
|
|
67
63
|
(0, import_opensearch.createOpenSearch)({
|
|
68
64
|
endpoint: "https://override-endpoint.example",
|
|
@@ -75,15 +71,13 @@ const ENV_KEYS = [
|
|
|
75
71
|
});
|
|
76
72
|
(0, import_vitest.test)("throws a helpful error when env vars are missing", () => {
|
|
77
73
|
(0, import_vitest.expect)(() => (0, import_opensearch.createOpenSearch)()).toThrow(
|
|
78
|
-
/
|
|
74
|
+
/OPENSEARCH_ENDPOINT.*AWS_REGION.*AWS_ROLE_ARN/
|
|
79
75
|
);
|
|
80
76
|
});
|
|
81
77
|
(0, import_vitest.test)("lists only the missing env vars in the error", () => {
|
|
82
|
-
process.env.
|
|
83
|
-
process.env.
|
|
78
|
+
process.env.OPENSEARCH_ENDPOINT = "https://example";
|
|
79
|
+
process.env.AWS_REGION = "us-east-2";
|
|
84
80
|
(0, import_vitest.expect)(() => (0, import_opensearch.createOpenSearch)()).toThrow(/AWS_ROLE_ARN/);
|
|
85
|
-
(0, import_vitest.expect)(() => (0, import_opensearch.createOpenSearch)()).not.toThrow(
|
|
86
|
-
/OPENSEARCH_DASHBOARD_ENDPOINT/
|
|
87
|
-
);
|
|
81
|
+
(0, import_vitest.expect)(() => (0, import_opensearch.createOpenSearch)()).not.toThrow(/OPENSEARCH_ENDPOINT/);
|
|
88
82
|
});
|
|
89
83
|
});
|
|
@@ -159,7 +159,7 @@ Defined in: node_modules/.pnpm/@opensearch-project+opensearch@3.3.0/node_modules
|
|
|
159
159
|
Defined in: [packages/aws/src/opensearch.ts:19](https://github.com/vercel/vercel/blob/main/packages/aws/src/opensearch.ts#L19)
|
|
160
160
|
|
|
161
161
|
The OpenSearch collection endpoint. Defaults to
|
|
162
|
-
`process.env.
|
|
162
|
+
`process.env.OPENSEARCH_ENDPOINT`.
|
|
163
163
|
|
|
164
164
|
---
|
|
165
165
|
|
|
@@ -314,7 +314,7 @@ Defined in: node_modules/.pnpm/@opensearch-project+opensearch@3.3.0/node_modules
|
|
|
314
314
|
Defined in: [packages/aws/src/opensearch.ts:24](https://github.com/vercel/vercel/blob/main/packages/aws/src/opensearch.ts#L24)
|
|
315
315
|
|
|
316
316
|
The AWS region the collection lives in. Defaults to
|
|
317
|
-
`process.env.
|
|
317
|
+
`process.env.AWS_REGION`.
|
|
318
318
|
|
|
319
319
|
---
|
|
320
320
|
|