@8ms/helpers 2.3.25 → 2.3.26
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/package.json +118 -189
- package/.github/workflows/deploy_npmjs.yml +0 -41
- package/.yarn/install-state.gz +0 -0
- package/.yarn/releases/yarn-4.12.0.cjs +0 -942
- package/.yarnrc.yml +0 -2
- package/dist/_class/index.d.mts +0 -2
- package/dist/_class/index.mjs +0 -61
- package/dist/adverity/index.d.mts +0 -2
- package/dist/adverity/index.mjs +0 -64
- package/dist/adverity/server/index.d.mts +0 -18
- package/dist/adverity/server/index.mjs +0 -25
- package/dist/api/index.d.mts +0 -2
- package/dist/api/index.mjs +0 -3
- package/dist/api-DGKJDAfb.mjs +0 -139
- package/dist/array/index.d.mts +0 -11
- package/dist/array/index.mjs +0 -12
- package/dist/atInternet/index.d.mts +0 -20
- package/dist/atInternet/index.mjs +0 -18
- package/dist/aws/ec2/server/index.d.mts +0 -18
- package/dist/aws/ec2/server/index.mjs +0 -48
- package/dist/aws/ecs/server/index.d.mts +0 -59
- package/dist/aws/ecs/server/index.mjs +0 -113
- package/dist/aws/glue/server/index.d.mts +0 -19
- package/dist/aws/glue/server/index.mjs +0 -36
- package/dist/aws/lambda/server/index.d.mts +0 -28
- package/dist/aws/lambda/server/index.mjs +0 -57
- package/dist/aws/s3/server/index.d.mts +0 -124
- package/dist/aws/s3/server/index.mjs +0 -360
- package/dist/aws/server/index.d.mts +0 -2
- package/dist/aws/server/index.mjs +0 -3
- package/dist/aws/ses/server/index.d.mts +0 -105
- package/dist/aws/ses/server/index.mjs +0 -268
- package/dist/aws/sqs/server/index.d.mts +0 -41
- package/dist/aws/sqs/server/index.mjs +0 -56
- package/dist/aws/ssm/server/index.d.mts +0 -18
- package/dist/aws/ssm/server/index.mjs +0 -47
- package/dist/axios/index.d.mts +0 -22
- package/dist/axios/index.mjs +0 -50
- package/dist/boolean/index.d.mts +0 -7
- package/dist/boolean/index.mjs +0 -13
- package/dist/brightData/serpApi/server/index.d.mts +0 -93
- package/dist/brightData/serpApi/server/index.mjs +0 -229
- package/dist/brightData/server/index.d.mts +0 -2
- package/dist/brightData/server/index.mjs +0 -18
- package/dist/brightData/webScraperIde/server/index.d.mts +0 -19
- package/dist/brightData/webScraperIde/server/index.mjs +0 -50
- package/dist/cache/server/index.d.mts +0 -10
- package/dist/cache/server/index.mjs +0 -31
- package/dist/chunk-DDarj8oW.mjs +0 -7
- package/dist/crud/index.d.mts +0 -10
- package/dist/crud/index.mjs +0 -10
- package/dist/crypto/index.d.mts +0 -25
- package/dist/crypto/index.mjs +0 -57
- package/dist/date/index.d.mts +0 -2
- package/dist/date/index.mjs +0 -471
- package/dist/drizzle/server/index.d.mts +0 -22
- package/dist/drizzle/server/index.mjs +0 -69
- package/dist/environment/index.d.mts +0 -37
- package/dist/environment/index.mjs +0 -60
- package/dist/eskimi/index.d.mts +0 -52
- package/dist/eskimi/index.mjs +0 -90
- package/dist/eskimi/server/index.d.mts +0 -25
- package/dist/eskimi/server/index.mjs +0 -50
- package/dist/file/index.d.mts +0 -7
- package/dist/file/index.mjs +0 -20
- package/dist/file/server/index.d.mts +0 -8
- package/dist/file/server/index.mjs +0 -16
- package/dist/geo/index.d.mts +0 -26
- package/dist/geo/index.mjs +0 -1591
- package/dist/getDecimal-CafxtLhH.mjs +0 -40
- package/dist/googleAds/keywordPlanner/server/index.d.mts +0 -45
- package/dist/googleAds/keywordPlanner/server/index.mjs +0 -51
- package/dist/googleAds/server/index.d.mts +0 -27
- package/dist/googleAds/server/index.mjs +0 -48
- package/dist/googleCloud/bigquery/server/index.d.mts +0 -82
- package/dist/googleCloud/bigquery/server/index.mjs +0 -133
- package/dist/googleCloud/server/index.d.mts +0 -2
- package/dist/googleCloud/server/index.mjs +0 -24
- package/dist/googleCloud/sheets/server/index.d.mts +0 -22
- package/dist/googleCloud/sheets/server/index.mjs +0 -31
- package/dist/googleCloud/storage/server/index.d.mts +0 -31
- package/dist/googleCloud/storage/server/index.mjs +0 -79
- package/dist/googlePageSpeed/server/index.d.mts +0 -34
- package/dist/googlePageSpeed/server/index.mjs +0 -53
- package/dist/googleSearchIncidents/server/index.d.mts +0 -73
- package/dist/googleSearchIncidents/server/index.mjs +0 -55
- package/dist/greenDomain/server/index.d.mts +0 -25
- package/dist/greenDomain/server/index.mjs +0 -31
- package/dist/index-1fBbJGQz.d.mts +0 -246
- package/dist/index-BHuvb_7y.d.mts +0 -116
- package/dist/index-BfyGIdDD.d.mts +0 -18
- package/dist/index-CqTOMR8f.d.mts +0 -17
- package/dist/index-DW9yJLtI.d.mts +0 -67
- package/dist/index-DmCSxHCc.d.mts +0 -32
- package/dist/index-DwB8X1lz.d.mts +0 -32
- package/dist/inngest/index.d.mts +0 -10
- package/dist/inngest/index.mjs +0 -10
- package/dist/json/index.d.mts +0 -7
- package/dist/json/index.mjs +0 -27
- package/dist/littleWarden/server/index.d.mts +0 -56
- package/dist/littleWarden/server/index.mjs +0 -79
- package/dist/lodash/index.d.mts +0 -45
- package/dist/lodash/index.mjs +0 -176
- package/dist/lumar/api/server/index.d.mts +0 -66
- package/dist/lumar/api/server/index.mjs +0 -111
- package/dist/lumar/graphql/server/index.d.mts +0 -308
- package/dist/lumar/graphql/server/index.mjs +0 -172
- package/dist/myTarget/server/index.d.mts +0 -9
- package/dist/myTarget/server/index.mjs +0 -16
- package/dist/nextAuth/index.d.mts +0 -12
- package/dist/nextAuth/index.mjs +0 -15
- package/dist/nextJs/client/index.d.mts +0 -10
- package/dist/nextJs/client/index.mjs +0 -12
- package/dist/nextJs/index.d.mts +0 -19
- package/dist/nextJs/index.mjs +0 -12
- package/dist/number/index.d.mts +0 -54
- package/dist/number/index.mjs +0 -75
- package/dist/object/index.d.mts +0 -8
- package/dist/object/index.mjs +0 -22
- package/dist/onePassword/server/index.d.mts +0 -24
- package/dist/onePassword/server/index.mjs +0 -50
- package/dist/openAi/server/index.d.mts +0 -20
- package/dist/openAi/server/index.mjs +0 -46
- package/dist/prisma/index.d.mts +0 -7
- package/dist/prisma/index.mjs +0 -15
- package/dist/prisma/server/index.d.mts +0 -31
- package/dist/prisma/server/index.mjs +0 -64
- package/dist/server-Bwy4JI8Z.mjs +0 -33
- package/dist/snapchat/server/index.d.mts +0 -25
- package/dist/snapchat/server/index.mjs +0 -39
- package/dist/sorting/index.d.mts +0 -25
- package/dist/sorting/index.mjs +0 -50
- package/dist/stream/server/index.d.mts +0 -15
- package/dist/stream/server/index.mjs +0 -48
- package/dist/string/index.d.mts +0 -107
- package/dist/string/index.mjs +0 -187
- package/dist/swr/client/index.d.mts +0 -46
- package/dist/swr/client/index.mjs +0 -40
- package/dist/upTimeRobot/server/index.d.mts +0 -72
- package/dist/upTimeRobot/server/index.mjs +0 -82
- package/dist/url/index.d.mts +0 -29
- package/dist/url/index.mjs +0 -52
- package/dist/url/server/index.d.mts +0 -9
- package/dist/url/server/index.mjs +0 -35
- package/dist/util/index.d.mts +0 -50
- package/dist/util/index.mjs +0 -107
- package/dist/util/server/index.d.mts +0 -27
- package/dist/util/server/index.mjs +0 -61
- package/dist/webWorker/index.d.mts +0 -11
- package/dist/webWorker/index.mjs +0 -11
- package/dist/xml/server/index.d.mts +0 -4
- package/dist/xml/server/index.mjs +0 -17
- package/tsdown.config.ts +0 -11
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import { isJson } from "./json/index.mjs";
|
|
2
|
-
|
|
3
|
-
//#region src/number/getNumber.ts
|
|
4
|
-
/**
|
|
5
|
-
* Take an input and return a number.
|
|
6
|
-
*/
|
|
7
|
-
const getNumber = (input, defaultValue = 0) => {
|
|
8
|
-
if (input == null) return defaultValue;
|
|
9
|
-
let response = input;
|
|
10
|
-
if (typeof input === "string" && isJson(input)) try {
|
|
11
|
-
response = JSON.parse(input);
|
|
12
|
-
} catch {
|
|
13
|
-
response = input;
|
|
14
|
-
}
|
|
15
|
-
if (typeof response === "number") return isNaN(response) ? defaultValue : response;
|
|
16
|
-
if (typeof response === "string") {
|
|
17
|
-
const directConversion = Number(response.trim());
|
|
18
|
-
if (!isNaN(directConversion)) return directConversion;
|
|
19
|
-
const match = response.match(/^\D*([0-9]*\.?[0-9]+)\D*$/);
|
|
20
|
-
if (match && match[1]) {
|
|
21
|
-
const extracted = Number(match[1]);
|
|
22
|
-
if (!isNaN(extracted)) return extracted;
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
const converted = Number(response);
|
|
26
|
-
return isNaN(converted) ? defaultValue : converted;
|
|
27
|
-
};
|
|
28
|
-
|
|
29
|
-
//#endregion
|
|
30
|
-
//#region src/number/getDecimal.ts
|
|
31
|
-
/**
|
|
32
|
-
* Return a decimal number after rounding.
|
|
33
|
-
*/
|
|
34
|
-
const getDecimal = (input, dp = 2) => {
|
|
35
|
-
const number = getNumber(input);
|
|
36
|
-
return Number(number.toFixed(dp));
|
|
37
|
-
};
|
|
38
|
-
|
|
39
|
-
//#endregion
|
|
40
|
-
export { getNumber as n, getDecimal as t };
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
import { z } from "zod/v4";
|
|
2
|
-
|
|
3
|
-
//#region src/googleAds/keywordPlanner/server/googleAdsKeywordPlanner.d.ts
|
|
4
|
-
declare const network: {
|
|
5
|
-
readonly GOOGLE_SEARCH_ONLY: 2;
|
|
6
|
-
readonly GOOGLE_SEARCH_AND_PARTNERS: 3;
|
|
7
|
-
};
|
|
8
|
-
type Network = typeof network[keyof typeof network];
|
|
9
|
-
declare const requestSchema: z.ZodObject<{
|
|
10
|
-
countries: z.ZodOptional<z.ZodArray<z.ZodNumber>>;
|
|
11
|
-
customerId: z.ZodOptional<z.ZodString>;
|
|
12
|
-
historicalMetricsOptions: z.ZodOptional<z.ZodObject<{
|
|
13
|
-
startMonth: z.ZodString;
|
|
14
|
-
startYear: z.ZodNumber;
|
|
15
|
-
endMonth: z.ZodString;
|
|
16
|
-
endYear: z.ZodNumber;
|
|
17
|
-
}, z.core.$strip>>;
|
|
18
|
-
includeAdultKeywords: z.ZodOptional<z.ZodBoolean>;
|
|
19
|
-
keywordPlanNetwork: z.ZodOptional<z.ZodNumber>;
|
|
20
|
-
queries: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
21
|
-
language: z.ZodOptional<z.ZodNumber>;
|
|
22
|
-
url: z.ZodOptional<z.ZodString>;
|
|
23
|
-
}, z.core.$strip>;
|
|
24
|
-
type RequestSchemaType = z.infer<typeof requestSchema>;
|
|
25
|
-
declare const defaultRequest: RequestSchemaType;
|
|
26
|
-
declare const responseSchema: z.ZodObject<{
|
|
27
|
-
payload: z.ZodObject<{}, z.core.$strip>;
|
|
28
|
-
keyword: z.ZodString;
|
|
29
|
-
avgCpc: z.ZodNumber;
|
|
30
|
-
avgSearchVolume: z.ZodNumber;
|
|
31
|
-
competition: z.ZodNumber;
|
|
32
|
-
competitionIndex: z.ZodNumber;
|
|
33
|
-
months: z.ZodArray<z.ZodObject<{
|
|
34
|
-
date: z.ZodString;
|
|
35
|
-
month: z.ZodNumber;
|
|
36
|
-
searchVolume: z.ZodNumber;
|
|
37
|
-
year: z.ZodNumber;
|
|
38
|
-
}, z.core.$strip>>;
|
|
39
|
-
topOfPageBidHigh: z.ZodNumber;
|
|
40
|
-
topOfPageBidLow: z.ZodNumber;
|
|
41
|
-
totalSearchVolume: z.ZodNumber;
|
|
42
|
-
}, z.core.$strip>;
|
|
43
|
-
type ResponseSchemaType = z.infer<typeof responseSchema>;
|
|
44
|
-
//#endregion
|
|
45
|
-
export { Network, RequestSchemaType, ResponseSchemaType, defaultRequest, network, requestSchema, responseSchema };
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
import { z } from "zod/v4";
|
|
2
|
-
|
|
3
|
-
//#region src/googleAds/keywordPlanner/server/googleAdsKeywordPlanner.ts
|
|
4
|
-
const network = {
|
|
5
|
-
GOOGLE_SEARCH_ONLY: 2,
|
|
6
|
-
GOOGLE_SEARCH_AND_PARTNERS: 3
|
|
7
|
-
};
|
|
8
|
-
const requestSchema = z.object({
|
|
9
|
-
countries: z.array(z.number()).optional(),
|
|
10
|
-
customerId: z.string().optional(),
|
|
11
|
-
historicalMetricsOptions: z.object({
|
|
12
|
-
startMonth: z.string(),
|
|
13
|
-
startYear: z.number(),
|
|
14
|
-
endMonth: z.string(),
|
|
15
|
-
endYear: z.number()
|
|
16
|
-
}).optional(),
|
|
17
|
-
includeAdultKeywords: z.boolean().optional(),
|
|
18
|
-
keywordPlanNetwork: z.number().optional(),
|
|
19
|
-
queries: z.array(z.string()).optional(),
|
|
20
|
-
language: z.number().optional(),
|
|
21
|
-
url: z.string().optional()
|
|
22
|
-
});
|
|
23
|
-
const defaultRequest = {
|
|
24
|
-
countries: [],
|
|
25
|
-
customerId: "",
|
|
26
|
-
historicalMetricsOptions: null,
|
|
27
|
-
includeAdultKeywords: false,
|
|
28
|
-
keywordPlanNetwork: network.GOOGLE_SEARCH_ONLY,
|
|
29
|
-
queries: [],
|
|
30
|
-
language: null
|
|
31
|
-
};
|
|
32
|
-
const responseSchema = z.object({
|
|
33
|
-
payload: z.object(),
|
|
34
|
-
keyword: z.string(),
|
|
35
|
-
avgCpc: z.number(),
|
|
36
|
-
avgSearchVolume: z.number(),
|
|
37
|
-
competition: z.number(),
|
|
38
|
-
competitionIndex: z.number(),
|
|
39
|
-
months: z.object({
|
|
40
|
-
date: z.string(),
|
|
41
|
-
month: z.number(),
|
|
42
|
-
searchVolume: z.number(),
|
|
43
|
-
year: z.number()
|
|
44
|
-
}).array(),
|
|
45
|
-
topOfPageBidHigh: z.number(),
|
|
46
|
-
topOfPageBidLow: z.number(),
|
|
47
|
-
totalSearchVolume: z.number()
|
|
48
|
-
});
|
|
49
|
-
|
|
50
|
-
//#endregion
|
|
51
|
-
export { defaultRequest, network, requestSchema, responseSchema };
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { t as BaseNamespace } from "../../index-DwB8X1lz.mjs";
|
|
2
|
-
import * as google_ads_api0 from "google-ads-api";
|
|
3
|
-
import { GoogleAdsApi } from "google-ads-api";
|
|
4
|
-
|
|
5
|
-
//#region src/googleAds/server/GoogleAdsNamespace.d.ts
|
|
6
|
-
declare class GoogleAdsNamespace extends BaseNamespace {
|
|
7
|
-
client: GoogleAdsApi;
|
|
8
|
-
config: Config;
|
|
9
|
-
mccAccountId: string;
|
|
10
|
-
refreshToken: string;
|
|
11
|
-
ensureInit: () => Promise<void>;
|
|
12
|
-
getCustomer: (customerId: string) => Promise<google_ads_api0.Customer>;
|
|
13
|
-
}
|
|
14
|
-
//#endregion
|
|
15
|
-
//#region src/googleAds/server/googleAds.d.ts
|
|
16
|
-
type Config = {
|
|
17
|
-
client: {
|
|
18
|
-
clientId: string;
|
|
19
|
-
clientSecret: string;
|
|
20
|
-
developerToken: string;
|
|
21
|
-
};
|
|
22
|
-
mccAccountId: string;
|
|
23
|
-
refreshToken: string;
|
|
24
|
-
};
|
|
25
|
-
declare const googleAdsClient: (key?: string, config?: Config, vaultId?: string, itemId?: string) => Promise<GoogleAdsNamespace>;
|
|
26
|
-
//#endregion
|
|
27
|
-
export { Config, GoogleAdsNamespace, googleAdsClient };
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
import { BaseNamespace } from "../../_class/index.mjs";
|
|
2
|
-
import { onePasswordClient } from "../../onePassword/server/index.mjs";
|
|
3
|
-
|
|
4
|
-
//#region src/googleAds/server/GoogleAdsNamespace.ts
|
|
5
|
-
var GoogleAdsNamespace = class extends BaseNamespace {
|
|
6
|
-
mccAccountId = "";
|
|
7
|
-
refreshToken = "";
|
|
8
|
-
ensureInit = async () => {
|
|
9
|
-
if (!this.client) try {
|
|
10
|
-
const { GoogleAdsApi } = await import("google-ads-api");
|
|
11
|
-
this.client = new GoogleAdsApi({
|
|
12
|
-
client_id: this.config.client.clientId,
|
|
13
|
-
client_secret: this.config.client.clientSecret,
|
|
14
|
-
developer_token: this.config.client.developerToken
|
|
15
|
-
});
|
|
16
|
-
this.mccAccountId = this.config.mccAccountId;
|
|
17
|
-
this.refreshToken = this.config.refreshToken;
|
|
18
|
-
} catch (e) {
|
|
19
|
-
throw new Error("Google Sheets Client not installed");
|
|
20
|
-
}
|
|
21
|
-
};
|
|
22
|
-
getCustomer = async (customerId) => {
|
|
23
|
-
await this.ensureInit();
|
|
24
|
-
return this.client.Customer({
|
|
25
|
-
customer_id: customerId,
|
|
26
|
-
login_customer_id: this.mccAccountId,
|
|
27
|
-
refresh_token: this.refreshToken
|
|
28
|
-
});
|
|
29
|
-
};
|
|
30
|
-
};
|
|
31
|
-
|
|
32
|
-
//#endregion
|
|
33
|
-
//#region src/googleAds/server/googleAds.ts
|
|
34
|
-
const googleAdsNamespaces = /* @__PURE__ */ new Map();
|
|
35
|
-
const googleAdsClient = async (key = "default", config, vaultId, itemId) => {
|
|
36
|
-
if (googleAdsNamespaces.has(key)) return googleAdsNamespaces.get(key);
|
|
37
|
-
let instanceConfig;
|
|
38
|
-
if (config) instanceConfig = config;
|
|
39
|
-
else if (vaultId && itemId) instanceConfig = await (await onePasswordClient()).getJsonNote(vaultId, itemId);
|
|
40
|
-
else if (process.env.GOOGLE_ADS_VAULT_ID && process.env.GOOGLE_ADS_ITEM_ID) instanceConfig = await (await onePasswordClient()).getJsonNote(process.env.GOOGLE_ADS_VAULT_ID, process.env.GOOGLE_ADS_ITEM_ID);
|
|
41
|
-
else throw new Error(`Config required for namespace '${key}'`);
|
|
42
|
-
const namespace = new GoogleAdsNamespace(key, instanceConfig);
|
|
43
|
-
googleAdsNamespaces.set(key, namespace);
|
|
44
|
-
return namespace;
|
|
45
|
-
};
|
|
46
|
-
|
|
47
|
-
//#endregion
|
|
48
|
-
export { GoogleAdsNamespace, googleAdsClient };
|
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
import { t as BaseNamespace } from "../../../index-DwB8X1lz.mjs";
|
|
2
|
-
import { t as GoogleCloudConfig } from "../../../index-DmCSxHCc.mjs";
|
|
3
|
-
import { BigQuery, DatasetResource, QueryOptions } from "@google-cloud/bigquery";
|
|
4
|
-
import { GoogleAuthOptions } from "@google-cloud/common";
|
|
5
|
-
|
|
6
|
-
//#region src/googleCloud/bigquery/server/GoogleCloudBigqueryNamespace.d.ts
|
|
7
|
-
type QueryInput = string | {
|
|
8
|
-
query: string;
|
|
9
|
-
location?: string;
|
|
10
|
-
params: QueryOptions;
|
|
11
|
-
};
|
|
12
|
-
type Dataset = {
|
|
13
|
-
id: string;
|
|
14
|
-
location: string;
|
|
15
|
-
projectId: string;
|
|
16
|
-
};
|
|
17
|
-
type Table = {
|
|
18
|
-
id: string;
|
|
19
|
-
};
|
|
20
|
-
declare class GoogleCloudBigqueryNamespace extends BaseNamespace {
|
|
21
|
-
client: BigQuery;
|
|
22
|
-
config: GoogleCloudConfig & {
|
|
23
|
-
projectId?: string;
|
|
24
|
-
};
|
|
25
|
-
ensureInit: () => Promise<void>;
|
|
26
|
-
/**
|
|
27
|
-
* Create a Dataset if it doesn't already exist.
|
|
28
|
-
* Returns table instance.
|
|
29
|
-
*/
|
|
30
|
-
createDataset: (datasetId: string, options?: DatasetResource) => Promise<void>;
|
|
31
|
-
/**
|
|
32
|
-
* Check to see whether a given Bigquery dataset exists.
|
|
33
|
-
* Based off:
|
|
34
|
-
* https://github.com/googleapis/nodejs-bigquery/blob/main/samples/getDataset.js
|
|
35
|
-
*/
|
|
36
|
-
datasetExists: (datasetId: string) => Promise<any>;
|
|
37
|
-
/**
|
|
38
|
-
* Retrieve all the Datasets
|
|
39
|
-
*/
|
|
40
|
-
getDatasets: () => Promise<Dataset[]>;
|
|
41
|
-
query: (props: QueryInput) => Promise<any>;
|
|
42
|
-
/**
|
|
43
|
-
* Create a Table if it doesn't already exist.
|
|
44
|
-
*/
|
|
45
|
-
createTable: (datasetId: string, datasetOptions: object, tableId: string, options?: object) => Promise<void>;
|
|
46
|
-
/**
|
|
47
|
-
* Check to see whether a given BigQuery table exists.
|
|
48
|
-
* https://cloud.google.com/bigquery/docs/samples/bigquery-table-exists
|
|
49
|
-
*/
|
|
50
|
-
tableExists: (datasetId: string, tableId: string) => Promise<boolean>;
|
|
51
|
-
getTables: (datasetId: string) => Promise<Table[]>;
|
|
52
|
-
}
|
|
53
|
-
//#endregion
|
|
54
|
-
//#region src/googleCloud/bigquery/server/googleCloudBigquery.d.ts
|
|
55
|
-
declare const googleCloudBigqueryClient$1: (key?: string, projectId?: string, config?: GoogleAuthOptions, vaultId?: string, itemId?: string) => Promise<GoogleCloudBigqueryNamespace>;
|
|
56
|
-
declare const getHandlerPath: (input: string) => string;
|
|
57
|
-
//#endregion
|
|
58
|
-
//#region src/googleCloud/bigquery/server/loadData.d.ts
|
|
59
|
-
type LoadData = {
|
|
60
|
-
googleCloudBigqueryClient: GoogleCloudBigqueryNamespace;
|
|
61
|
-
googleCloudStorageClient: any;
|
|
62
|
-
file: {
|
|
63
|
-
bucket: string;
|
|
64
|
-
key: string;
|
|
65
|
-
metadata: object;
|
|
66
|
-
};
|
|
67
|
-
table: {
|
|
68
|
-
datasetId: string;
|
|
69
|
-
tableId: string;
|
|
70
|
-
};
|
|
71
|
-
};
|
|
72
|
-
/**
|
|
73
|
-
* Load data into a given table using Google Cloud Storage.
|
|
74
|
-
*/
|
|
75
|
-
declare const loadData: ({
|
|
76
|
-
file,
|
|
77
|
-
googleCloudBigqueryClient,
|
|
78
|
-
googleCloudStorageClient,
|
|
79
|
-
table
|
|
80
|
-
}: LoadData) => Promise<void>;
|
|
81
|
-
//#endregion
|
|
82
|
-
export { type GoogleCloudBigqueryNamespace, QueryInput, getHandlerPath, googleCloudBigqueryClient$1 as googleCloudBigqueryClient, loadData };
|
|
@@ -1,133 +0,0 @@
|
|
|
1
|
-
import { isObject } from "../../../lodash/index.mjs";
|
|
2
|
-
import { BaseNamespace } from "../../../_class/index.mjs";
|
|
3
|
-
import { onePasswordClient } from "../../../onePassword/server/index.mjs";
|
|
4
|
-
import { getConfig } from "../../server/index.mjs";
|
|
5
|
-
|
|
6
|
-
//#region src/googleCloud/bigquery/server/GoogleCloudBigqueryNamespace.ts
|
|
7
|
-
var GoogleCloudBigqueryNamespace = class extends BaseNamespace {
|
|
8
|
-
ensureInit = async () => {
|
|
9
|
-
if (!this.client) try {
|
|
10
|
-
const { BigQuery } = await import("@google-cloud/bigquery");
|
|
11
|
-
this.client = new BigQuery(getConfig(this.config, this.config?.projectId));
|
|
12
|
-
} catch (e) {
|
|
13
|
-
throw new Error("Google BigQuery Client not installed");
|
|
14
|
-
}
|
|
15
|
-
};
|
|
16
|
-
/**
|
|
17
|
-
* Create a Dataset if it doesn't already exist.
|
|
18
|
-
* Returns table instance.
|
|
19
|
-
*/
|
|
20
|
-
createDataset = async (datasetId, options = {}) => {
|
|
21
|
-
await this.ensureInit();
|
|
22
|
-
if (!await this.datasetExists(datasetId)) await this.client.createDataset(datasetId);
|
|
23
|
-
};
|
|
24
|
-
/**
|
|
25
|
-
* Check to see whether a given Bigquery dataset exists.
|
|
26
|
-
* Based off:
|
|
27
|
-
* https://github.com/googleapis/nodejs-bigquery/blob/main/samples/getDataset.js
|
|
28
|
-
*/
|
|
29
|
-
datasetExists = async (datasetId) => {
|
|
30
|
-
await this.ensureInit();
|
|
31
|
-
let response;
|
|
32
|
-
try {
|
|
33
|
-
await this.client.dataset(datasetId).get();
|
|
34
|
-
response = true;
|
|
35
|
-
} catch (exception) {
|
|
36
|
-
response = false;
|
|
37
|
-
}
|
|
38
|
-
return response;
|
|
39
|
-
};
|
|
40
|
-
/**
|
|
41
|
-
* Retrieve all the Datasets
|
|
42
|
-
*/
|
|
43
|
-
getDatasets = async () => {
|
|
44
|
-
await this.ensureInit();
|
|
45
|
-
let response = [];
|
|
46
|
-
const datasets = await this.client.getDatasets();
|
|
47
|
-
if (datasets?.[0]) for (let i = 0; i < datasets[0].length; i++) response.push({
|
|
48
|
-
id: datasets[0][i].id,
|
|
49
|
-
location: datasets[0][i].location,
|
|
50
|
-
projectId: datasets[0][i].bigQuery.projectId
|
|
51
|
-
});
|
|
52
|
-
return response;
|
|
53
|
-
};
|
|
54
|
-
query = async (props) => {
|
|
55
|
-
await this.ensureInit();
|
|
56
|
-
let options = { query: "" };
|
|
57
|
-
if ("string" === props) options.query = props;
|
|
58
|
-
else if (isObject(props)) {
|
|
59
|
-
options.query = props.query;
|
|
60
|
-
if (props?.location) options["location"] = props.location;
|
|
61
|
-
if (props?.params) options["params"] = props.params;
|
|
62
|
-
}
|
|
63
|
-
return await this.client.query(options);
|
|
64
|
-
};
|
|
65
|
-
/**
|
|
66
|
-
* Create a Table if it doesn't already exist.
|
|
67
|
-
*/
|
|
68
|
-
createTable = async (datasetId, datasetOptions = {}, tableId, options = {}) => {
|
|
69
|
-
await this.ensureInit();
|
|
70
|
-
await this.createDataset(datasetId, datasetOptions);
|
|
71
|
-
if (!await this.tableExists(datasetId, tableId)) await this.client.dataset(datasetId).createTable(tableId, options || {});
|
|
72
|
-
};
|
|
73
|
-
/**
|
|
74
|
-
* Check to see whether a given BigQuery table exists.
|
|
75
|
-
* https://cloud.google.com/bigquery/docs/samples/bigquery-table-exists
|
|
76
|
-
*/
|
|
77
|
-
tableExists = async (datasetId, tableId) => {
|
|
78
|
-
await this.ensureInit();
|
|
79
|
-
let response = false;
|
|
80
|
-
const tables = await this.getTables(datasetId);
|
|
81
|
-
for (let i = 0; i < tables.length; i++) if (tables[i].id === tableId) {
|
|
82
|
-
response = true;
|
|
83
|
-
break;
|
|
84
|
-
}
|
|
85
|
-
return response;
|
|
86
|
-
};
|
|
87
|
-
getTables = async (datasetId) => {
|
|
88
|
-
await this.ensureInit();
|
|
89
|
-
let response = [];
|
|
90
|
-
const tables = await this.client.dataset(datasetId).getTables();
|
|
91
|
-
if (tables?.[0]) for (let i = 0; i < tables[0].length; i++) response.push({ id: tables[0][i].id });
|
|
92
|
-
return response;
|
|
93
|
-
};
|
|
94
|
-
};
|
|
95
|
-
|
|
96
|
-
//#endregion
|
|
97
|
-
//#region src/googleCloud/bigquery/server/googleCloudBigquery.ts
|
|
98
|
-
const googleCloudBigqueryNamespaces = /* @__PURE__ */ new Map();
|
|
99
|
-
const googleCloudBigqueryClient = async (key = "default", projectId, config, vaultId, itemId) => {
|
|
100
|
-
if (googleCloudBigqueryNamespaces.has(key)) return googleCloudBigqueryNamespaces.get(key);
|
|
101
|
-
let instanceConfig;
|
|
102
|
-
if (config) instanceConfig = {
|
|
103
|
-
...config,
|
|
104
|
-
projectId
|
|
105
|
-
};
|
|
106
|
-
else if (vaultId && itemId) instanceConfig = {
|
|
107
|
-
...await (await onePasswordClient()).getJsonNote(vaultId, itemId),
|
|
108
|
-
projectId
|
|
109
|
-
};
|
|
110
|
-
else if (process.env.GOOGLE_CLOUD_VAULT_ID && process.env.GOOGLE_CLOUD_ITEM_ID) instanceConfig = {
|
|
111
|
-
...await (await onePasswordClient()).getJsonNote(process.env.GOOGLE_CLOUD_VAULT_ID, process.env.GOOGLE_CLOUD_ITEM_ID),
|
|
112
|
-
projectId
|
|
113
|
-
};
|
|
114
|
-
else throw new Error(`Config required for namespace '${key}'`);
|
|
115
|
-
const namespace = new GoogleCloudBigqueryNamespace(key, instanceConfig);
|
|
116
|
-
googleCloudBigqueryNamespaces.set(key, namespace);
|
|
117
|
-
return namespace;
|
|
118
|
-
};
|
|
119
|
-
const getHandlerPath = (input) => {
|
|
120
|
-
return `${input.split(process.cwd())[1].substring(1).replace(/\\/g, "/")}`;
|
|
121
|
-
};
|
|
122
|
-
|
|
123
|
-
//#endregion
|
|
124
|
-
//#region src/googleCloud/bigquery/server/loadData.ts
|
|
125
|
-
/**
|
|
126
|
-
* Load data into a given table using Google Cloud Storage.
|
|
127
|
-
*/
|
|
128
|
-
const loadData = async ({ file, googleCloudBigqueryClient, googleCloudStorageClient, table }) => {
|
|
129
|
-
if (await googleCloudBigqueryClient.tableExists(table.datasetId, table.tableId)) await googleCloudBigqueryClient.client.dataset(table.datasetId).table(table.tableId).load(googleCloudStorageClient.client.bucket(file.bucket).file(file.key), file.metadata);
|
|
130
|
-
};
|
|
131
|
-
|
|
132
|
-
//#endregion
|
|
133
|
-
export { GoogleCloudBigqueryNamespace, getHandlerPath, googleCloudBigqueryClient, loadData };
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
//#region src/googleCloud/server/googleCloud.ts
|
|
2
|
-
/**
|
|
3
|
-
* Using the response from Parameter Store and format it ready to be used with Google API.
|
|
4
|
-
*/
|
|
5
|
-
const getConfig = (parameter, projectId) => {
|
|
6
|
-
const privateKey = parameter["private_key"].replace(/\\n/g, "\n");
|
|
7
|
-
let response = { credentials: {
|
|
8
|
-
type: parameter["type"],
|
|
9
|
-
project_id: parameter["project_id"],
|
|
10
|
-
private_key_id: parameter["private_key_id"],
|
|
11
|
-
private_key: privateKey,
|
|
12
|
-
client_email: parameter["client_email"],
|
|
13
|
-
client_id: parameter["client_id"],
|
|
14
|
-
auth_uri: parameter["auth_uri"],
|
|
15
|
-
token_uri: parameter["token_uri"],
|
|
16
|
-
auth_provider_x509_cert_url: parameter["auth_provider_x509_cert_url"],
|
|
17
|
-
client_x509_cert_url: parameter["client_x509_cert_url"]
|
|
18
|
-
} };
|
|
19
|
-
if (projectId) response["projectId"] = projectId;
|
|
20
|
-
return response;
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
//#endregion
|
|
24
|
-
export { getConfig };
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { t as BaseNamespace } from "../../../index-DwB8X1lz.mjs";
|
|
2
|
-
import { t as GoogleCloudConfig } from "../../../index-DmCSxHCc.mjs";
|
|
3
|
-
import * as _googleapis_sheets0 from "@googleapis/sheets";
|
|
4
|
-
import { GoogleAuth } from "googleapis-common";
|
|
5
|
-
|
|
6
|
-
//#region src/googleCloud/sheets/server/GoogleCloudSheetsNamespace.d.ts
|
|
7
|
-
type GetBatchDataProps = {
|
|
8
|
-
spreadsheetId: string;
|
|
9
|
-
ranges: string[];
|
|
10
|
-
dateTimeRender?: string;
|
|
11
|
-
valueRender?: string;
|
|
12
|
-
};
|
|
13
|
-
declare class GoogleCloudSheetsNamespace extends BaseNamespace {
|
|
14
|
-
client: GoogleAuth;
|
|
15
|
-
config: GoogleCloudConfig & {
|
|
16
|
-
projectId?: string;
|
|
17
|
-
};
|
|
18
|
-
ensureInit: () => Promise<void>;
|
|
19
|
-
getBatchData: (props: GetBatchDataProps) => Promise<_googleapis_sheets0.sheets_v4.Schema$BatchGetValuesResponse>;
|
|
20
|
-
}
|
|
21
|
-
//#endregion
|
|
22
|
-
export { GoogleCloudSheetsNamespace };
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import { BaseNamespace } from "../../../_class/index.mjs";
|
|
2
|
-
import { getConfig } from "../../server/index.mjs";
|
|
3
|
-
|
|
4
|
-
//#region src/googleCloud/sheets/server/GoogleCloudSheetsNamespace.ts
|
|
5
|
-
var GoogleCloudSheetsNamespace = class extends BaseNamespace {
|
|
6
|
-
ensureInit = async () => {
|
|
7
|
-
if (!this.client) try {
|
|
8
|
-
const googleApisSheets = await import("@googleapis/sheets");
|
|
9
|
-
const formattedConfig = getConfig(this.config, this.config?.projectId);
|
|
10
|
-
this.client = new googleApisSheets.auth.GoogleAuth({
|
|
11
|
-
...formattedConfig,
|
|
12
|
-
scopes: ["https://www.googleapis.com/auth/spreadsheets"]
|
|
13
|
-
});
|
|
14
|
-
} catch (e) {
|
|
15
|
-
throw new Error("Google Sheets Client not installed");
|
|
16
|
-
}
|
|
17
|
-
};
|
|
18
|
-
getBatchData = async (props) => {
|
|
19
|
-
await this.ensureInit();
|
|
20
|
-
return (await (await import("@googleapis/sheets")).sheets("v4").spreadsheets.values.batchGet({
|
|
21
|
-
auth: this.client,
|
|
22
|
-
dateTimeRenderOption: props?.dateTimeRender || "FORMATTED_STRING",
|
|
23
|
-
ranges: props.ranges,
|
|
24
|
-
spreadsheetId: props.spreadsheetId,
|
|
25
|
-
valueRenderOption: props?.valueRender || "UNFORMATTED_VALUE"
|
|
26
|
-
})).data;
|
|
27
|
-
};
|
|
28
|
-
};
|
|
29
|
-
|
|
30
|
-
//#endregion
|
|
31
|
-
export { GoogleCloudSheetsNamespace };
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import { t as BaseNamespace } from "../../../index-DwB8X1lz.mjs";
|
|
2
|
-
import { t as GoogleCloudConfig } from "../../../index-DmCSxHCc.mjs";
|
|
3
|
-
import * as _google_cloud_storage0 from "@google-cloud/storage";
|
|
4
|
-
import { Storage } from "@google-cloud/storage";
|
|
5
|
-
import { GoogleAuthOptions } from "@google-cloud/common";
|
|
6
|
-
|
|
7
|
-
//#region src/googleCloud/storage/server/GoogleCloudStorageNamespace.d.ts
|
|
8
|
-
declare class GoogleCloudStorageNamespace extends BaseNamespace {
|
|
9
|
-
client: Storage;
|
|
10
|
-
config: GoogleCloudConfig & {
|
|
11
|
-
projectId?: string;
|
|
12
|
-
};
|
|
13
|
-
ensureInit: () => Promise<void>;
|
|
14
|
-
/**
|
|
15
|
-
* Copy a local file to Google Cloud Storage.
|
|
16
|
-
*/
|
|
17
|
-
copyToCloud: (bucket: string, localFile: string, options?: {}) => Promise<_google_cloud_storage0.UploadResponse>;
|
|
18
|
-
/**
|
|
19
|
-
* Check to see if a file exists but don't get the contents.
|
|
20
|
-
*/
|
|
21
|
-
fileExists: (bucket: string, key: string) => Promise<boolean>;
|
|
22
|
-
/**
|
|
23
|
-
* Write a file to Google Cloud Storage.
|
|
24
|
-
*/
|
|
25
|
-
writeFile: (bucket: string, key: string, data: any, options?: {}) => Promise<unknown>;
|
|
26
|
-
}
|
|
27
|
-
//#endregion
|
|
28
|
-
//#region src/googleCloud/storage/server/googleCloudStorage.d.ts
|
|
29
|
-
declare const googleCloudStorageClient: (key?: string, projectId?: string, config?: GoogleAuthOptions, vaultId?: string, itemId?: string) => Promise<GoogleCloudStorageNamespace>;
|
|
30
|
-
//#endregion
|
|
31
|
-
export { GoogleCloudStorageNamespace, googleCloudStorageClient };
|
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
import { BaseNamespace } from "../../../_class/index.mjs";
|
|
2
|
-
import { onePasswordClient } from "../../../onePassword/server/index.mjs";
|
|
3
|
-
import { getConfig } from "../../server/index.mjs";
|
|
4
|
-
|
|
5
|
-
//#region src/googleCloud/storage/server/GoogleCloudStorageNamespace.ts
|
|
6
|
-
var GoogleCloudStorageNamespace = class extends BaseNamespace {
|
|
7
|
-
ensureInit = async () => {
|
|
8
|
-
if (!this.client) try {
|
|
9
|
-
const { Storage } = await import("@google-cloud/storage");
|
|
10
|
-
this.client = new Storage(getConfig(this.config, this.config?.projectId));
|
|
11
|
-
} catch (e) {
|
|
12
|
-
throw new Error("Google Cloud Storage Client not installed");
|
|
13
|
-
}
|
|
14
|
-
};
|
|
15
|
-
/**
|
|
16
|
-
* Copy a local file to Google Cloud Storage.
|
|
17
|
-
*/
|
|
18
|
-
copyToCloud = async (bucket, localFile, options = {}) => {
|
|
19
|
-
await this.ensureInit();
|
|
20
|
-
return await this.client.bucket(bucket).upload(localFile, options);
|
|
21
|
-
};
|
|
22
|
-
/**
|
|
23
|
-
* Check to see if a file exists but don't get the contents.
|
|
24
|
-
*/
|
|
25
|
-
fileExists = async (bucket, key) => {
|
|
26
|
-
await this.ensureInit();
|
|
27
|
-
return (await this.client.bucket(bucket).file(key).exists())?.[0];
|
|
28
|
-
};
|
|
29
|
-
/**
|
|
30
|
-
* Write a file to Google Cloud Storage.
|
|
31
|
-
*/
|
|
32
|
-
writeFile = async (bucket, key, data, options = {}) => {
|
|
33
|
-
await this.ensureInit();
|
|
34
|
-
const dataStream = new (await (import("stream"))).PassThrough();
|
|
35
|
-
const googleFile = this.client.bucket(bucket).file(key);
|
|
36
|
-
dataStream.push(data);
|
|
37
|
-
dataStream.push(null);
|
|
38
|
-
return await new Promise((resolve, reject) => {
|
|
39
|
-
dataStream.pipe(googleFile.createWriteStream({
|
|
40
|
-
contentType: "auto",
|
|
41
|
-
resumable: false,
|
|
42
|
-
validation: false,
|
|
43
|
-
metadata: {},
|
|
44
|
-
...options
|
|
45
|
-
})).on("error", (error) => {
|
|
46
|
-
reject(error);
|
|
47
|
-
}).on("finish", () => {
|
|
48
|
-
resolve(true);
|
|
49
|
-
});
|
|
50
|
-
});
|
|
51
|
-
};
|
|
52
|
-
};
|
|
53
|
-
|
|
54
|
-
//#endregion
|
|
55
|
-
//#region src/googleCloud/storage/server/googleCloudStorage.ts
|
|
56
|
-
const googleCloudStorageNamespaces = /* @__PURE__ */ new Map();
|
|
57
|
-
const googleCloudStorageClient = async (key = "default", projectId, config, vaultId, itemId) => {
|
|
58
|
-
if (googleCloudStorageNamespaces.has(key)) return googleCloudStorageNamespaces.get(key);
|
|
59
|
-
let instanceConfig;
|
|
60
|
-
if (config) instanceConfig = {
|
|
61
|
-
...config,
|
|
62
|
-
projectId
|
|
63
|
-
};
|
|
64
|
-
else if (vaultId && itemId) instanceConfig = {
|
|
65
|
-
...await (await onePasswordClient()).getJsonNote(vaultId, itemId),
|
|
66
|
-
projectId
|
|
67
|
-
};
|
|
68
|
-
else if (process.env.GOOGLE_CLOUD_VAULT_ID && process.env.GOOGLE_CLOUD_ITEM_ID) instanceConfig = {
|
|
69
|
-
...await (await onePasswordClient()).getJsonNote(process.env.GOOGLE_CLOUD_VAULT_ID, process.env.GOOGLE_CLOUD_ITEM_ID),
|
|
70
|
-
projectId
|
|
71
|
-
};
|
|
72
|
-
else throw new Error(`Config required for namespace '${key}'`);
|
|
73
|
-
const namespace = new GoogleCloudStorageNamespace(key, instanceConfig);
|
|
74
|
-
googleCloudStorageNamespaces.set(key, namespace);
|
|
75
|
-
return namespace;
|
|
76
|
-
};
|
|
77
|
-
|
|
78
|
-
//#endregion
|
|
79
|
-
export { GoogleCloudStorageNamespace, googleCloudStorageClient };
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import { t as BaseNamespace } from "../../index-DwB8X1lz.mjs";
|
|
2
|
-
|
|
3
|
-
//#region src/googlePageSpeed/server/GooglePageSpeedNamespace.d.ts
|
|
4
|
-
/**
|
|
5
|
-
* Based on https://developers.google.com/speed/docs/insights/rest/v5/pagespeedapi/runpagespeed
|
|
6
|
-
*/
|
|
7
|
-
declare class GooglePageSpeedNamespace extends BaseNamespace {
|
|
8
|
-
client: boolean;
|
|
9
|
-
config: GooglePageSpeedConfig;
|
|
10
|
-
ensureInit: () => Promise<void>;
|
|
11
|
-
getReport: (url: string, inputCategory?: Category, inputStrategy?: Strategy) => Promise<any>;
|
|
12
|
-
}
|
|
13
|
-
//#endregion
|
|
14
|
-
//#region src/googlePageSpeed/server/googlePageSpeed.d.ts
|
|
15
|
-
type GooglePageSpeedConfig = {
|
|
16
|
-
apiKey: string;
|
|
17
|
-
};
|
|
18
|
-
declare const googlePageSpeedClient: (key?: string, config?: GooglePageSpeedConfig, vaultId?: string, itemId?: string) => Promise<GooglePageSpeedNamespace>;
|
|
19
|
-
declare const category: {
|
|
20
|
-
readonly CATEGORY_UNSPECIFIED: "CATEGORY_UNSPECIFIED";
|
|
21
|
-
readonly ACCESSIBILITY: "ACCESSIBILITY";
|
|
22
|
-
readonly BEST_PRACTICES: "BEST_PRACTICES";
|
|
23
|
-
readonly PERFORMANCE: "PERFORMANCE";
|
|
24
|
-
readonly SEO: "SEO";
|
|
25
|
-
};
|
|
26
|
-
type Category = typeof category[keyof typeof category];
|
|
27
|
-
declare const strategy: {
|
|
28
|
-
readonly STRATEGY_UNSPECIFIED: "STRATEGY_UNSPECIFIED";
|
|
29
|
-
readonly DESKTOP: "DESKTOP";
|
|
30
|
-
readonly MOBILE: "MOBILE";
|
|
31
|
-
};
|
|
32
|
-
type Strategy = typeof strategy[keyof typeof strategy];
|
|
33
|
-
//#endregion
|
|
34
|
-
export { Category, GooglePageSpeedConfig, GooglePageSpeedNamespace, Strategy, category, googlePageSpeedClient, strategy };
|