@8ms/helpers 2.1.3 → 2.2.9

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/.yarnrc.yml DELETED
@@ -1,3 +0,0 @@
1
- nodeLinker: node-modules
2
-
3
- yarnPath: .yarn/releases/yarn-4.9.4.cjs
@@ -1,8 +0,0 @@
1
- import { BaseNamespace } from "../../_class";
2
- import { AthenaConfig } from "./server";
3
- export declare class AwsAthenaNamespace extends BaseNamespace {
4
- client: any | null;
5
- config: AthenaConfig;
6
- ensureInit: () => Promise<void>;
7
- query: (query: string) => Promise<any>;
8
- }
@@ -1,82 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || (function () {
19
- var ownKeys = function(o) {
20
- ownKeys = Object.getOwnPropertyNames || function (o) {
21
- var ar = [];
22
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
- return ar;
24
- };
25
- return ownKeys(o);
26
- };
27
- return function (mod) {
28
- if (mod && mod.__esModule) return mod;
29
- var result = {};
30
- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
- __setModuleDefault(result, mod);
32
- return result;
33
- };
34
- })();
35
- Object.defineProperty(exports, "__esModule", { value: true });
36
- exports.AwsAthenaNamespace = void 0;
37
- const _class_1 = require("../../_class");
38
- class AwsAthenaNamespace extends _class_1.BaseNamespace {
39
- constructor() {
40
- super(...arguments);
41
- this.client = null;
42
- this.config = null;
43
- this.ensureInit = async () => {
44
- if (!this.client) {
45
- try {
46
- const athenaExpress = await Promise.resolve().then(() => __importStar(require("athena-express")));
47
- const awsSdk = await Promise.resolve().then(() => __importStar(require("aws-sdk")));
48
- const formattedConfig = {
49
- region: this.config.region,
50
- accessKeyId: this.config.accessKeyId,
51
- secretAccessKey: this.config.secretAccessKey,
52
- };
53
- // Set the aws authentication
54
- awsSdk.config.update(formattedConfig);
55
- this.client = new athenaExpress.AthenaExpress({
56
- aws: awsSdk,
57
- s3: `s3://${this.config.s3Bucket}/${this.config.s3Key}`,
58
- db: this.config.database,
59
- formatJson: true,
60
- retry: 200,
61
- getStats: false,
62
- });
63
- }
64
- catch (e) {
65
- throw new Error("AWS Athena Client not installed");
66
- }
67
- }
68
- };
69
- this.query = async (query) => {
70
- await this.ensureInit();
71
- return await this.client.query(query)
72
- .then(data => {
73
- let subResponse = [];
74
- if (undefined !== data["Items"]) {
75
- subResponse = data["Items"];
76
- }
77
- return subResponse;
78
- });
79
- };
80
- }
81
- }
82
- exports.AwsAthenaNamespace = AwsAthenaNamespace;
@@ -1,10 +0,0 @@
1
- import { AwsAthenaNamespace } from "./AwsAthenaNamespace";
2
- export type AthenaConfig = {
3
- region: string;
4
- accessKeyId: string;
5
- secretAccessKey: string;
6
- s3Bucket: string;
7
- s3Key: string;
8
- database: string;
9
- };
10
- export declare const awsAthenaClient: (key?: string, config?: AthenaConfig, vaultId?: string, itemId?: string) => Promise<AwsAthenaNamespace>;
@@ -1,40 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.awsAthenaClient = void 0;
4
- const AwsAthenaNamespace_1 = require("./AwsAthenaNamespace");
5
- const server_1 = require("../../onePassword/server");
6
- const awsAthenaNamespaces = new Map();
7
- const awsAthenaClient = async (key = "default", config, vaultId, itemId) => {
8
- if (awsAthenaNamespaces.has(key)) {
9
- return awsAthenaNamespaces.get(key);
10
- }
11
- let instanceConfig;
12
- if (config) {
13
- instanceConfig = config;
14
- }
15
- else if (vaultId && itemId) {
16
- instanceConfig = await (await (0, server_1.onePasswordClient)())
17
- .getJsonNote(vaultId, itemId);
18
- }
19
- else if (process.env.AWS_VAULT_ID && process.env.AWS_ITEM_ID) {
20
- instanceConfig = await (await (0, server_1.onePasswordClient)())
21
- .getJsonNote(process.env.AWS_VAULT_ID, process.env.AWS_ITEM_ID);
22
- }
23
- else if (process.env.ATHENA_REGION && process.env.ATHENA_ACCESS_KEY_ID && process.env.ATHENA_SECRET_ACCESS_KEY && process.env.ATHENA_S3_BUCKET && process.env.ATHENA_S3_KEY && process.env.ATHENA_DATABASE) {
24
- instanceConfig = {
25
- region: process.env.ATHENA_REGION,
26
- accessKeyId: process.env.ATHENA_ACCESS_KEY_ID,
27
- secretAccessKey: process.env.ATHENA_SECRET_ACCESS_KEY,
28
- s3Bucket: process.env.ATHENA_S3_BUCKET,
29
- s3Key: process.env.ATHENA_S3_KEY,
30
- database: process.env.ATHENA_DATABASE,
31
- };
32
- }
33
- else {
34
- throw new Error(`Config required for namespace '${key}'`);
35
- }
36
- const namespace = new AwsAthenaNamespace_1.AwsAthenaNamespace(key, instanceConfig);
37
- awsAthenaNamespaces.set(key, namespace);
38
- return namespace;
39
- };
40
- exports.awsAthenaClient = awsAthenaClient;