@webiny/api-elasticsearch 5.43.0-beta.0 → 5.43.0-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/client.js +0 -1
- package/client.js.map +1 -1
- package/package.json +8 -9
package/client.js
CHANGED
package/client.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_awsElasticsearchConnector","_interopRequireDefault","require","_crypto","_error","_elasticsearch","clients","Map","createClientKey","options","key","JSON","stringify","hash","crypto","createHash","update","digest","createElasticsearchClient","existing","get","cached","endpoint","node","rest","clientOptions","auth","region","String","process","env","AWS_REGION","credentials","accessKeyId","AWS_ACCESS_KEY_ID","secretAccessKey","AWS_SECRET_ACCESS_KEY","sessionToken","AWS_SESSION_TOKEN","errors","Object","keys","filter","value","length","WebinyError","join","createAwsElasticsearchConnector","Client","ex","data","error","undefined","console","client","set","exports"],"sources":["client.ts"],"sourcesContent":["import createAwsElasticsearchConnector from \"aws-elasticsearch-connector\";\nimport crypto from \"crypto\";\nimport WebinyError from \"@webiny/error\";\nimport { Client, ClientOptions } from \"@elastic/elasticsearch\";\n\nexport interface ElasticsearchClientOptions extends ClientOptions {\n endpoint?: string;\n}\n\nconst clients = new Map<string, Client>();\n\nconst createClientKey = (options: ElasticsearchClientOptions) => {\n const key = JSON.stringify(options);\n const hash = crypto.createHash(\"sha1\");\n hash.update(key);\n return hash.digest(\"hex\");\n};\n\nexport { Client, ClientOptions };\n\nexport const createElasticsearchClient = (options: ElasticsearchClientOptions): Client => {\n const key = createClientKey(options);\n const existing = clients.get(key);\n if (existing) {\n return existing;\n }\n\n const cached = (): Client => {\n const { endpoint, node, ...rest } = options;\n\n let clientOptions: ClientOptions = {\n node: endpoint || node,\n ...rest\n };\n\n if (!clientOptions.auth) {\n const region = String(process.env.AWS_REGION);\n\n const credentials = {\n accessKeyId: process.env.AWS_ACCESS_KEY_ID,\n secretAccessKey: process.env.AWS_SECRET_ACCESS_KEY,\n sessionToken: process.env.AWS_SESSION_TOKEN\n };\n\n const errors = Object.keys(credentials).filter(key => {\n const value = credentials[key as keyof typeof credentials];\n return !value;\n });\n if (errors.length > 0) {\n throw new WebinyError(\n `Missing keys values: ${errors.join(\", \")}`,\n \"MISSING_AWS_CREDENTIALS\"\n );\n }\n\n clientOptions = {\n ...clientOptions,\n ...createAwsElasticsearchConnector({\n region,\n
|
|
1
|
+
{"version":3,"names":["_awsElasticsearchConnector","_interopRequireDefault","require","_crypto","_error","_elasticsearch","clients","Map","createClientKey","options","key","JSON","stringify","hash","crypto","createHash","update","digest","createElasticsearchClient","existing","get","cached","endpoint","node","rest","clientOptions","auth","region","String","process","env","AWS_REGION","credentials","accessKeyId","AWS_ACCESS_KEY_ID","secretAccessKey","AWS_SECRET_ACCESS_KEY","sessionToken","AWS_SESSION_TOKEN","errors","Object","keys","filter","value","length","WebinyError","join","createAwsElasticsearchConnector","Client","ex","data","error","undefined","console","client","set","exports"],"sources":["client.ts"],"sourcesContent":["import createAwsElasticsearchConnector from \"aws-elasticsearch-connector\";\nimport crypto from \"crypto\";\nimport WebinyError from \"@webiny/error\";\nimport { Client, ClientOptions } from \"@elastic/elasticsearch\";\n\nexport interface ElasticsearchClientOptions extends ClientOptions {\n endpoint?: string;\n}\n\nconst clients = new Map<string, Client>();\n\nconst createClientKey = (options: ElasticsearchClientOptions) => {\n const key = JSON.stringify(options);\n const hash = crypto.createHash(\"sha1\");\n hash.update(key);\n return hash.digest(\"hex\");\n};\n\nexport { Client, ClientOptions };\n\nexport const createElasticsearchClient = (options: ElasticsearchClientOptions): Client => {\n const key = createClientKey(options);\n const existing = clients.get(key);\n if (existing) {\n return existing;\n }\n\n const cached = (): Client => {\n const { endpoint, node, ...rest } = options;\n\n let clientOptions: ClientOptions = {\n node: endpoint || node,\n ...rest\n };\n\n if (!clientOptions.auth) {\n const region = String(process.env.AWS_REGION);\n\n const credentials = {\n accessKeyId: process.env.AWS_ACCESS_KEY_ID,\n secretAccessKey: process.env.AWS_SECRET_ACCESS_KEY,\n sessionToken: process.env.AWS_SESSION_TOKEN\n };\n\n const errors = Object.keys(credentials).filter(key => {\n const value = credentials[key as keyof typeof credentials];\n return !value;\n });\n if (errors.length > 0) {\n throw new WebinyError(\n `Missing keys values: ${errors.join(\", \")}`,\n \"MISSING_AWS_CREDENTIALS\"\n );\n }\n\n clientOptions = {\n ...clientOptions,\n ...createAwsElasticsearchConnector({\n region,\n credentials\n })\n };\n }\n\n try {\n return new Client(clientOptions);\n } catch (ex) {\n const data = {\n error: ex,\n node: endpoint || node,\n ...rest,\n auth: undefined\n };\n console.error({\n ...data\n });\n throw new WebinyError(\n \"Could not connect to Elasticsearch.\",\n \"ELASTICSEARCH_CLIENT_ERROR\",\n data\n );\n }\n };\n\n const client = cached();\n\n clients.set(key, client);\n return client;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA,IAAAA,0BAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,OAAA,GAAAF,sBAAA,CAAAC,OAAA;AACA,IAAAE,MAAA,GAAAH,sBAAA,CAAAC,OAAA;AACA,IAAAG,cAAA,GAAAH,OAAA;AAMA,MAAMI,OAAO,GAAG,IAAIC,GAAG,CAAiB,CAAC;AAEzC,MAAMC,eAAe,GAAIC,OAAmC,IAAK;EAC7D,MAAMC,GAAG,GAAGC,IAAI,CAACC,SAAS,CAACH,OAAO,CAAC;EACnC,MAAMI,IAAI,GAAGC,eAAM,CAACC,UAAU,CAAC,MAAM,CAAC;EACtCF,IAAI,CAACG,MAAM,CAACN,GAAG,CAAC;EAChB,OAAOG,IAAI,CAACI,MAAM,CAAC,KAAK,CAAC;AAC7B,CAAC;AAIM,MAAMC,yBAAyB,GAAIT,OAAmC,IAAa;EACtF,MAAMC,GAAG,GAAGF,eAAe,CAACC,OAAO,CAAC;EACpC,MAAMU,QAAQ,GAAGb,OAAO,CAACc,GAAG,CAACV,GAAG,CAAC;EACjC,IAAIS,QAAQ,EAAE;IAC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E0B;MACV,CAAC;MACDC,OAAO,CAACF,KAAK,CAAC;QACV,GAAGD;MACP,CAAC,CAAC;MACF,MAAM,IAAIL,cAAW,CACjB,qCAAqC,EACrC,4BAA4B,EAC5BK,IACJ,CAAC;IACL;EACJ,CAAC;EAED,MAAMI,MAAM,GAAGjC,MAAM,CAAC,CAAC;EAEvBf,OAAO,CAACiD,GAAG,CAAC7C,GAAG,EAAE4C,MAAM,CAAC;EACxB,OAAOA,MAAM;AACjB,CAAC;AAACE,OAAA,CAAAtC,yBAAA,GAAAA,yBAAA","ignoreList":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webiny/api-elasticsearch",
|
|
3
|
-
"version": "5.43.0-beta.
|
|
3
|
+
"version": "5.43.0-beta.1",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "https://github.com/webiny/webiny-js.git",
|
|
@@ -13,18 +13,17 @@
|
|
|
13
13
|
"license": "MIT",
|
|
14
14
|
"dependencies": {
|
|
15
15
|
"@elastic/elasticsearch": "7.12.0",
|
|
16
|
-
"@webiny/api": "5.43.0-beta.
|
|
17
|
-
"@webiny/error": "5.43.0-beta.
|
|
18
|
-
"@webiny/plugins": "5.43.0-beta.
|
|
19
|
-
"@webiny/utils": "5.43.0-beta.
|
|
16
|
+
"@webiny/api": "5.43.0-beta.1",
|
|
17
|
+
"@webiny/error": "5.43.0-beta.1",
|
|
18
|
+
"@webiny/plugins": "5.43.0-beta.1",
|
|
19
|
+
"@webiny/utils": "5.43.0-beta.1",
|
|
20
20
|
"aws-elasticsearch-connector": "9.2.0",
|
|
21
21
|
"elastic-ts": "0.12.0"
|
|
22
22
|
},
|
|
23
23
|
"devDependencies": {
|
|
24
|
-
"@webiny/project-utils": "5.43.0-beta.
|
|
24
|
+
"@webiny/project-utils": "5.43.0-beta.1",
|
|
25
25
|
"rimraf": "6.0.1",
|
|
26
|
-
"
|
|
27
|
-
"typescript": "4.9.5"
|
|
26
|
+
"typescript": "5.3.3"
|
|
28
27
|
},
|
|
29
28
|
"publishConfig": {
|
|
30
29
|
"access": "public",
|
|
@@ -34,5 +33,5 @@
|
|
|
34
33
|
"build": "node ../cli/bin.js run build",
|
|
35
34
|
"watch": "node ../cli/bin.js run watch"
|
|
36
35
|
},
|
|
37
|
-
"gitHead": "
|
|
36
|
+
"gitHead": "d47a234b09383cb7ab2d9907300b8eaa89aa64d6"
|
|
38
37
|
}
|