@8ms/helpers 2.2.9 → 2.2.12
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/.github/workflows/deploy_npmjs.yml +3 -0
- package/_class/BaseClass.js +43 -52
- package/_class/BaseNamespace.js +17 -20
- package/_class/index.js +2 -7
- package/adverity/getJobs.js +7 -11
- package/adverity/index.js +51 -54
- package/adverity/server.js +1 -5
- package/api/ApiResponseClass.js +84 -88
- package/api/functions.js +13 -22
- package/api/index.js +3 -19
- package/api/types.js +5 -9
- package/array/index.js +3 -11
- package/atInternet/index.js +10 -13
- package/aws/ec2/AwsEc2Namespace.js +34 -74
- package/aws/ec2/server.js +5 -9
- package/aws/ecs/AwsEcsNamespace.js +110 -150
- package/aws/ecs/server.js +5 -9
- package/aws/glue/AwsGlueNamespace.js +26 -66
- package/aws/glue/server.js +5 -9
- package/aws/isResponse200.js +3 -7
- package/aws/lambda/AwsLambdaNamespace.js +62 -102
- package/aws/lambda/server.js +6 -11
- package/aws/s3/AwsS3Namespace.js +347 -390
- package/aws/s3/payload.js +29 -32
- package/aws/s3/server.js +9 -14
- package/aws/server.js +5 -10
- package/aws/ses/AwsSesNamespace.js +36 -76
- package/aws/ses/SimpleEmail.js +267 -304
- package/aws/ses/server.js +6 -11
- package/aws/sqs/AwsSqsNamespace.js +49 -89
- package/aws/sqs/server.js +5 -9
- package/aws/ssm/AwsSsmNamespace.js +43 -79
- package/aws/ssm/server.js +5 -9
- package/axios/deleteRequest.js +8 -15
- package/axios/get.js +8 -15
- package/axios/index.js +3 -9
- package/axios/post.js +8 -15
- package/boolean/index.js +3 -10
- package/brightData/serpApi/buildGoogleSerpUrl.js +1 -5
- package/brightData/serpApi/buildGoogleTrendsUrl.js +1 -5
- package/brightData/serpApi/getAsyncRequestId.js +8 -12
- package/brightData/serpApi/getAsyncResults.js +8 -12
- package/brightData/serpApi/getRealtime.js +3 -7
- package/brightData/serpApi/server.js +6 -14
- package/brightData/server.js +2 -7
- package/brightData/webScraperIde/getBatch.js +3 -7
- package/brightData/webScraperIde/getRealtime.js +11 -15
- package/brightData/webScraperIde/server.js +2 -7
- package/cache/server.js +2 -7
- package/cache/test/cache.test.js +4 -6
- package/crud/index.js +1 -4
- package/crypto/getDecrypt.js +2 -39
- package/crypto/getEncrypt.js +2 -39
- package/crypto/getRandom.js +1 -5
- package/crypto/getSha256.js +4 -41
- package/crypto/index.js +4 -11
- package/date/calculation.js +70 -99
- package/date/financialYear.js +16 -23
- package/date/format.js +40 -61
- package/date/index.js +4 -20
- package/date/type.js +4 -7
- package/environment/index.js +15 -25
- package/eskimi/getAgeGroup.js +3 -7
- package/eskimi/getData.js +3 -7
- package/eskimi/getDevice.js +3 -7
- package/eskimi/getGender.js +3 -7
- package/eskimi/server.js +23 -26
- package/file/index.js +8 -46
- package/geo/countries.js +1 -4
- package/geo/index.js +2 -7
- package/geo/languages.js +1 -4
- package/google/bigQuery/GoogleBigQueryNamespace.js +108 -148
- package/google/bigQuery/loadData.js +1 -5
- package/google/bigQuery/server.js +8 -14
- package/google/server.js +1 -5
- package/google/sheets/GoogleSheetsNamespace.js +34 -74
- package/google/sheets/getAssociatedData.js +1 -5
- package/google/sheets/server.js +8 -14
- package/google/storage/GoogleCloudStorageNamespace.js +62 -102
- package/google/storage/server.js +6 -10
- package/googleAds/GoogleAdsNamespace.js +28 -68
- package/googleAds/keywordPlanner/server.js +32 -35
- package/googleAds/server.js +6 -10
- package/googlePageSpeed/GooglePageSpeedNamespace.js +21 -28
- package/googlePageSpeed/server.js +8 -12
- package/googleSearchIncidents/server.js +28 -32
- package/greenDomain/server.js +17 -21
- package/inngest/server.js +1 -4
- package/json/getJsonNewline.js +3 -7
- package/json/index.js +2 -7
- package/json/isJson.js +1 -5
- package/littleWarden/LittleWardenNamespace.js +24 -31
- package/littleWarden/getUrlStatus.js +3 -7
- package/littleWarden/server.js +14 -22
- package/lumar/api/buildRequest.js +14 -18
- package/lumar/api/getData.js +3 -7
- package/lumar/api/initClient.js +3 -7
- package/lumar/api/server.js +6 -12
- package/lumar/graphql/columns.js +1 -4
- package/lumar/graphql/getData.js +3 -7
- package/lumar/graphql/initClient.js +3 -7
- package/lumar/graphql/queries/crawl.js +1 -2
- package/lumar/graphql/queries/getCrawls.js +1 -3
- package/lumar/graphql/queries/getReportDifferences.js +3 -5
- package/lumar/graphql/queries/getRows.js +1 -3
- package/lumar/graphql/queries/getTotals.js +1 -3
- package/lumar/graphql/queries/row.js +1 -2
- package/lumar/graphql/reportTemplates.js +1 -4
- package/lumar/graphql/server.js +7 -15
- package/myTarget/server.js +3 -7
- package/nextAuth/index.js +2 -6
- package/nextAuth/isSessionReady.js +1 -5
- package/nextJs/client/LazyLoad.js +5 -12
- package/nextJs/client.js +1 -5
- package/nextJs/index.js +2 -7
- package/number/format.js +3 -7
- package/number/formatCurrency.js +1 -5
- package/number/getDecimal.js +3 -7
- package/number/getNumber.js +3 -7
- package/number/getPercentIncrease.js +4 -8
- package/number/getSafeDivide.js +6 -10
- package/number/index.js +6 -15
- package/object/index.js +1 -5
- package/object/replaceKeys.js +3 -7
- package/onePassword/OnePasswordNamespace.js +36 -76
- package/onePassword/server.js +3 -7
- package/openAi/OpenAiNamespace.js +32 -39
- package/openAi/server.js +6 -10
- package/package.json +224 -122
- package/prisma/PrismaNamespace.js +53 -93
- package/prisma/getDecimal.js +5 -12
- package/prisma/server.js +4 -9
- package/scripts/generate-exports.js +50 -0
- package/snapchat/SnapchatNamespace.js +20 -27
- package/snapchat/server.js +6 -10
- package/sorting/byNumberAscending.js +1 -5
- package/sorting/byNumberDescending.js +1 -5
- package/sorting/byStringAscending.js +1 -5
- package/sorting/byStringDescending.js +1 -5
- package/sorting/index.js +4 -11
- package/stream/server.js +1 -5
- package/stream/sort.js +1 -5
- package/string/getCapitalised.js +3 -7
- package/string/getClean.js +17 -21
- package/string/getFolder.js +3 -10
- package/string/getProperCase.js +4 -8
- package/string/getString.js +8 -15
- package/string/getStringFromStream.js +1 -5
- package/string/getUnescaped.js +3 -10
- package/string/getWithoutAccents.js +1 -5
- package/string/getWithoutHtmlTags.js +1 -5
- package/string/getWithoutPunctuation.js +1 -5
- package/string/getWithoutUnderscores.js +1 -5
- package/string/getWithoutWhitespaces.js +1 -5
- package/string/index.js +12 -27
- package/string/reservedWords.js +5 -9
- package/swr/index.js +9 -18
- package/upTimeRobot/UpTimeRobotNamespace.js +32 -42
- package/upTimeRobot/server.js +11 -15
- package/url/index.js +12 -23
- package/url/server.js +1 -5
- package/url/writeUrlContents.js +6 -46
- package/util/defaultTo.js +5 -12
- package/util/getBrotliCompressed.js +3 -10
- package/util/getBrotliDecompressed.js +3 -10
- package/util/getClean.js +5 -9
- package/util/getError.js +1 -5
- package/util/getGzipCompressed.js +3 -10
- package/util/getGzipDecompressed.js +3 -10
- package/util/getWithoutHash.js +1 -5
- package/util/getWithoutParameter.js +1 -5
- package/util/index.js +7 -17
- package/util/isUndefined.js +3 -7
- package/util/promiseChunks.js +6 -10
- package/util/server.js +4 -11
- package/util/sleep.js +1 -5
- package/webWorker/index.js +1 -4
- package/xml/getXml.js +3 -7
package/date/type.js
CHANGED
|
@@ -1,13 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
exports.defaultDate = "1901-01-01";
|
|
5
|
-
exports.defaultDateNumber = 19010101;
|
|
6
|
-
exports.defaultDateTime = "1901-01-01 00:00:00";
|
|
1
|
+
export const defaultDate = "1901-01-01";
|
|
2
|
+
export const defaultDateNumber = 19010101;
|
|
3
|
+
export const defaultDateTime = "1901-01-01 00:00:00";
|
|
7
4
|
/**
|
|
8
5
|
* Used by Google Ads API.
|
|
9
6
|
*/
|
|
10
|
-
|
|
7
|
+
export const Month = {
|
|
11
8
|
JANUARY: "JANUARY",
|
|
12
9
|
FEBRUARY: "FEBRUARY",
|
|
13
10
|
MARCH: "MARCH",
|
package/environment/index.js
CHANGED
|
@@ -1,19 +1,16 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.isLocalhost = exports.isProduction = exports.isStaging = exports.isDevelopment = exports.isServer = exports.isVercel = exports.isAws = exports.getEnvironment = exports.Platform = exports.Environment = void 0;
|
|
4
|
-
exports.Environment = {
|
|
1
|
+
export const Environment = {
|
|
5
2
|
DEVELOPMENT: "development",
|
|
6
3
|
STAGING: "staging",
|
|
7
4
|
PRODUCTION: "production",
|
|
8
5
|
};
|
|
9
|
-
|
|
6
|
+
export const Platform = {
|
|
10
7
|
AWS: "AWS",
|
|
11
8
|
VERCEL: "VERCEL",
|
|
12
9
|
};
|
|
13
10
|
/**
|
|
14
11
|
* Determine the environment we're using.
|
|
15
12
|
*/
|
|
16
|
-
const getEnvironment = () => {
|
|
13
|
+
export const getEnvironment = () => {
|
|
17
14
|
let platformEnvironment = process.env.ENVIRONMENT;
|
|
18
15
|
let response;
|
|
19
16
|
// Custom - Backend/AWS
|
|
@@ -37,54 +34,47 @@ const getEnvironment = () => {
|
|
|
37
34
|
.trim();
|
|
38
35
|
switch (platformEnvironmentClean) {
|
|
39
36
|
case "production":
|
|
40
|
-
response =
|
|
37
|
+
response = Environment.PRODUCTION;
|
|
41
38
|
break;
|
|
42
39
|
case "demo":
|
|
43
40
|
case "preview":
|
|
44
41
|
case "staging":
|
|
45
|
-
response =
|
|
42
|
+
response = Environment.STAGING;
|
|
46
43
|
break;
|
|
47
44
|
default:
|
|
48
|
-
response =
|
|
45
|
+
response = Environment.DEVELOPMENT;
|
|
49
46
|
}
|
|
50
47
|
return response;
|
|
51
48
|
};
|
|
52
|
-
exports.getEnvironment = getEnvironment;
|
|
53
49
|
/**
|
|
54
50
|
* Check to see if we are working on AWS Lambda.
|
|
55
51
|
*/
|
|
56
|
-
const isAws = () =>
|
|
57
|
-
|
|
58
|
-
const isVercel = () => undefined !== process.env.NEXT_PUBLIC_VERCEL_GIT_COMMIT_REF;
|
|
59
|
-
exports.isVercel = isVercel;
|
|
52
|
+
export const isAws = () => Platform.AWS === process.env["EMS_PLATFORM"];
|
|
53
|
+
export const isVercel = () => undefined !== process.env.NEXT_PUBLIC_VERCEL_GIT_COMMIT_REF;
|
|
60
54
|
/**
|
|
61
55
|
* Some code should only run on the server side to protect the data.
|
|
62
56
|
*/
|
|
63
|
-
|
|
57
|
+
export const isServer = typeof window === "undefined";
|
|
64
58
|
/**
|
|
65
59
|
* Check the environment currently running.
|
|
66
60
|
*/
|
|
67
|
-
const isDevelopment = () =>
|
|
68
|
-
|
|
69
|
-
const
|
|
70
|
-
exports.isStaging = isStaging;
|
|
71
|
-
const isProduction = () => exports.Environment.PRODUCTION === (0, exports.getEnvironment)();
|
|
72
|
-
exports.isProduction = isProduction;
|
|
61
|
+
export const isDevelopment = () => Environment.DEVELOPMENT === getEnvironment();
|
|
62
|
+
export const isStaging = () => Environment.STAGING === getEnvironment();
|
|
63
|
+
export const isProduction = () => Environment.PRODUCTION === getEnvironment();
|
|
73
64
|
/**
|
|
74
65
|
* Check to see if we are developing locally or on the hosted platform.
|
|
75
66
|
*/
|
|
76
|
-
const isLocalhost = () => {
|
|
67
|
+
export const isLocalhost = () => {
|
|
77
68
|
let response = false;
|
|
78
69
|
if ("true" === process.env["IS_LOCAL"]) {
|
|
79
70
|
response = true;
|
|
80
71
|
}
|
|
81
|
-
else if (
|
|
72
|
+
else if (isAws()) {
|
|
82
73
|
response = "true" === process.env["AWS_SAM_LOCAL"];
|
|
83
74
|
}
|
|
84
|
-
else if (
|
|
75
|
+
else if (isVercel()) {
|
|
85
76
|
// This value needs to only be included in Vercel but undefined in locally
|
|
86
77
|
response = undefined === process.env["NEXT_PUBLIC_VERCEL_GIT_REPO_ID"];
|
|
87
78
|
}
|
|
88
79
|
return response;
|
|
89
80
|
};
|
|
90
|
-
exports.isLocalhost = isLocalhost;
|
package/eskimi/getAgeGroup.js
CHANGED
|
@@ -1,15 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getAgeGroup = void 0;
|
|
4
|
-
const server_1 = require("./server");
|
|
1
|
+
import { ageGroups } from "./server";
|
|
5
2
|
/**
|
|
6
3
|
* Map the Age Group and return the user-friendly string.
|
|
7
4
|
*/
|
|
8
|
-
const getAgeGroup = (input) => {
|
|
9
|
-
const matches =
|
|
5
|
+
export const getAgeGroup = (input) => {
|
|
6
|
+
const matches = ageGroups.filter(group => group.id === input);
|
|
10
7
|
if (1 === matches.length) {
|
|
11
8
|
return matches[0].name;
|
|
12
9
|
}
|
|
13
10
|
return "Undefined";
|
|
14
11
|
};
|
|
15
|
-
exports.getAgeGroup = getAgeGroup;
|
package/eskimi/getData.js
CHANGED
|
@@ -1,12 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getData = void 0;
|
|
4
|
-
const axios_1 = require("../axios");
|
|
1
|
+
import { post } from "../axios";
|
|
5
2
|
/**
|
|
6
3
|
* Make the request to Eskimi API using the access token.
|
|
7
4
|
*/
|
|
8
|
-
const getData = async (accessToken, data, url) => {
|
|
9
|
-
const response = await
|
|
5
|
+
export const getData = async (accessToken, data, url) => {
|
|
6
|
+
const response = await post(url, data, {
|
|
10
7
|
headers: {
|
|
11
8
|
Authorization: `Bearer ${accessToken}`,
|
|
12
9
|
"Content-Type": "application/json",
|
|
@@ -14,4 +11,3 @@ const getData = async (accessToken, data, url) => {
|
|
|
14
11
|
});
|
|
15
12
|
return response.getBodyDefaultTo(["data"], null);
|
|
16
13
|
};
|
|
17
|
-
exports.getData = getData;
|
package/eskimi/getDevice.js
CHANGED
|
@@ -1,15 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getDevice = void 0;
|
|
4
|
-
const server_1 = require("./server");
|
|
1
|
+
import { devices } from "./server";
|
|
5
2
|
/**
|
|
6
3
|
* Map the Devices and return the user-friendly string.
|
|
7
4
|
*/
|
|
8
|
-
const getDevice = (input) => {
|
|
9
|
-
const matches =
|
|
5
|
+
export const getDevice = (input) => {
|
|
6
|
+
const matches = devices.filter(device => device.id === input);
|
|
10
7
|
if (1 === matches.length) {
|
|
11
8
|
return matches[0].name;
|
|
12
9
|
}
|
|
13
10
|
return "Undefined";
|
|
14
11
|
};
|
|
15
|
-
exports.getDevice = getDevice;
|
package/eskimi/getGender.js
CHANGED
|
@@ -1,15 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getGender = void 0;
|
|
4
|
-
const server_1 = require("./server");
|
|
1
|
+
import { genders } from "./server";
|
|
5
2
|
/**
|
|
6
3
|
* Map the Gender and return the user-friendly string.
|
|
7
4
|
*/
|
|
8
|
-
const getGender = (input) => {
|
|
9
|
-
const matches =
|
|
5
|
+
export const getGender = (input) => {
|
|
6
|
+
const matches = genders.filter(gender => gender.id === input);
|
|
10
7
|
if (1 === matches.length) {
|
|
11
8
|
return matches[0].name;
|
|
12
9
|
}
|
|
13
10
|
return "Undefined";
|
|
14
11
|
};
|
|
15
|
-
exports.getGender = getGender;
|
package/eskimi/server.js
CHANGED
|
@@ -1,11 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.genders = exports.devices = exports.ageGroups = exports.endpoints = void 0;
|
|
4
|
-
const v4_1 = require("zod/v4");
|
|
1
|
+
import { z } from "zod/v4";
|
|
5
2
|
/**
|
|
6
3
|
* https://dsp-api.eskimi.com/docs/api/v1/#api-Report-GetCampaignReportByAgeGroups
|
|
7
4
|
*/
|
|
8
|
-
|
|
5
|
+
export const endpoints = {
|
|
9
6
|
campaign: {
|
|
10
7
|
age: "https://dsp-api.eskimi.com/api/v1/report/ageGroups/get",
|
|
11
8
|
gender: "https://dsp-api.eskimi.com/api/v1/report/genders/get",
|
|
@@ -17,26 +14,26 @@ exports.endpoints = {
|
|
|
17
14
|
list: "https://dsp-api.eskimi.com/api/v1/report/sites/get",
|
|
18
15
|
},
|
|
19
16
|
};
|
|
20
|
-
const campaignSchema =
|
|
21
|
-
id:
|
|
22
|
-
name:
|
|
23
|
-
type:
|
|
24
|
-
user_id:
|
|
25
|
-
ad_domain:
|
|
26
|
-
click_url:
|
|
27
|
-
bid:
|
|
28
|
-
budget:
|
|
29
|
-
dates:
|
|
30
|
-
creative_set_ids:
|
|
31
|
-
audience_ids:
|
|
32
|
-
ad_placement_type_ids:
|
|
33
|
-
ad_placement_position_ids:
|
|
34
|
-
operator_ids:
|
|
35
|
-
devices:
|
|
36
|
-
auto_start:
|
|
37
|
-
created_at:
|
|
17
|
+
const campaignSchema = z.object({
|
|
18
|
+
id: z.number(),
|
|
19
|
+
name: z.string(),
|
|
20
|
+
type: z.number(),
|
|
21
|
+
user_id: z.number(),
|
|
22
|
+
ad_domain: z.string(),
|
|
23
|
+
click_url: z.string(),
|
|
24
|
+
bid: z.string(),
|
|
25
|
+
budget: z.any(),
|
|
26
|
+
dates: z.any(),
|
|
27
|
+
creative_set_ids: z.any(),
|
|
28
|
+
audience_ids: z.any(),
|
|
29
|
+
ad_placement_type_ids: z.any(),
|
|
30
|
+
ad_placement_position_ids: z.any(),
|
|
31
|
+
operator_ids: z.any(),
|
|
32
|
+
devices: z.any(),
|
|
33
|
+
auto_start: z.number(),
|
|
34
|
+
created_at: z.string(),
|
|
38
35
|
});
|
|
39
|
-
|
|
36
|
+
export const ageGroups = [
|
|
40
37
|
{
|
|
41
38
|
"id": 0,
|
|
42
39
|
"name": "0-17",
|
|
@@ -74,7 +71,7 @@ exports.ageGroups = [
|
|
|
74
71
|
"name": "65+",
|
|
75
72
|
},
|
|
76
73
|
];
|
|
77
|
-
|
|
74
|
+
export const devices = [
|
|
78
75
|
{
|
|
79
76
|
"id": 2,
|
|
80
77
|
"name": "Personal Computer",
|
|
@@ -84,7 +81,7 @@ exports.devices = [
|
|
|
84
81
|
"name": "Connected TV",
|
|
85
82
|
},
|
|
86
83
|
];
|
|
87
|
-
|
|
84
|
+
export const genders = [
|
|
88
85
|
{
|
|
89
86
|
"id": 1,
|
|
90
87
|
"name": "Male",
|
package/file/index.js
CHANGED
|
@@ -1,59 +1,22 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
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.getFileKey = exports.createDirectory = void 0;
|
|
37
|
-
const date_1 = require("../date");
|
|
38
|
-
const luxon_1 = require("luxon");
|
|
1
|
+
import { format } from "../date";
|
|
2
|
+
import { DateTime } from "luxon";
|
|
39
3
|
/**
|
|
40
4
|
* Create a directory recursively.
|
|
41
5
|
* Requires fs-extra
|
|
42
6
|
*/
|
|
43
|
-
const createDirectory = (filePath) => {
|
|
7
|
+
export const createDirectory = (filePath) => {
|
|
44
8
|
return new Promise(async (resolve, reject) => {
|
|
45
|
-
const fs = await
|
|
46
|
-
const path = await
|
|
9
|
+
const fs = await import("fs-extra");
|
|
10
|
+
const path = await import("path");
|
|
47
11
|
const fileDir = path.parse(filePath).dir;
|
|
48
12
|
fs.ensureDirSync(fileDir);
|
|
49
13
|
resolve(true);
|
|
50
14
|
});
|
|
51
15
|
};
|
|
52
|
-
exports.createDirectory = createDirectory;
|
|
53
16
|
/**
|
|
54
17
|
* Create a file key from the inputs so it can handle objects/number/etc.
|
|
55
18
|
*/
|
|
56
|
-
const getFileKey = (inputs) => {
|
|
19
|
+
export const getFileKey = (inputs) => {
|
|
57
20
|
let response = "";
|
|
58
21
|
for (let i = 0; i < inputs.length; i++) {
|
|
59
22
|
if (i > 0) {
|
|
@@ -62,8 +25,8 @@ const getFileKey = (inputs) => {
|
|
|
62
25
|
if ("string" === typeof inputs[i]) {
|
|
63
26
|
response += inputs[i];
|
|
64
27
|
}
|
|
65
|
-
else if (inputs[i] instanceof Date || inputs[i] instanceof
|
|
66
|
-
response +=
|
|
28
|
+
else if (inputs[i] instanceof Date || inputs[i] instanceof DateTime) {
|
|
29
|
+
response += format(inputs[i], "YYYY-MM-DD");
|
|
67
30
|
}
|
|
68
31
|
else {
|
|
69
32
|
response += JSON.stringify(inputs[i]);
|
|
@@ -71,4 +34,3 @@ const getFileKey = (inputs) => {
|
|
|
71
34
|
}
|
|
72
35
|
return response;
|
|
73
36
|
};
|
|
74
|
-
exports.getFileKey = getFileKey;
|
package/geo/countries.js
CHANGED
|
@@ -1,11 +1,8 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.countries = void 0;
|
|
4
1
|
/**
|
|
5
2
|
* Countries - excluded non-Google Ads supported ones
|
|
6
3
|
* https://docs.google.com/spreadsheets/d/1nrQ9h1n9p0Mab81_FKGqIw4fTOMOOjpcFrf0oSQvHIw/edit?gid=0#gid=0
|
|
7
4
|
*/
|
|
8
|
-
|
|
5
|
+
export const countries = [
|
|
9
6
|
{ name: 'Afghanistan', population: 42647492, iso2: 'AF', iso3: 'AFG', googleAdsId: 2004 },
|
|
10
7
|
{ name: 'Albania', population: 2791765, iso2: 'AL', iso3: 'ALB', googleAdsId: 2008 },
|
|
11
8
|
{ name: 'Algeria', population: 46814308, iso2: 'DZ', iso3: 'DZA', googleAdsId: 2012 },
|
package/geo/index.js
CHANGED
|
@@ -1,7 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.languages = exports.countries = void 0;
|
|
4
|
-
var countries_1 = require("./countries");
|
|
5
|
-
Object.defineProperty(exports, "countries", { enumerable: true, get: function () { return countries_1.countries; } });
|
|
6
|
-
var languages_1 = require("./languages");
|
|
7
|
-
Object.defineProperty(exports, "languages", { enumerable: true, get: function () { return languages_1.languages; } });
|
|
1
|
+
export { countries } from "./countries";
|
|
2
|
+
export { languages } from "./languages";
|
package/geo/languages.js
CHANGED
|
@@ -1,10 +1,7 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.languages = void 0;
|
|
4
1
|
/**
|
|
5
2
|
* https://docs.google.com/spreadsheets/d/1nrQ9h1n9p0Mab81_FKGqIw4fTOMOOjpcFrf0oSQvHIw/edit?gid=0#gid=0
|
|
6
3
|
*/
|
|
7
|
-
|
|
4
|
+
export const languages = [
|
|
8
5
|
{ name: 'Arabic', iso2: 'ar', googleAdsId: 1019 },
|
|
9
6
|
{ name: 'Bengali', iso2: 'bn', googleAdsId: 1056 },
|
|
10
7
|
{ name: 'Bulgarian', iso2: 'bg', googleAdsId: 1020 },
|
|
@@ -1,155 +1,115 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
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.GoogleBigQueryNamespace = void 0;
|
|
37
|
-
const _class_1 = require("../../_class");
|
|
38
|
-
const server_1 = require("../server");
|
|
39
|
-
class GoogleBigQueryNamespace extends _class_1.BaseNamespace {
|
|
40
|
-
constructor() {
|
|
41
|
-
super(...arguments);
|
|
42
|
-
this.ensureInit = async () => {
|
|
43
|
-
if (!this.client) {
|
|
44
|
-
try {
|
|
45
|
-
const { BigQuery } = await Promise.resolve().then(() => __importStar(require("@google-cloud/bigquery")));
|
|
46
|
-
const formattedConfig = (0, server_1.getConfig)(this.config, this.config?.projectId);
|
|
47
|
-
this.client = new BigQuery(formattedConfig);
|
|
48
|
-
}
|
|
49
|
-
catch (e) {
|
|
50
|
-
throw new Error("Google BigQuery Client not installed");
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
};
|
|
54
|
-
/**
|
|
55
|
-
* Create a Dataset if it doesn't already exist.
|
|
56
|
-
* Returns table instance.
|
|
57
|
-
*/
|
|
58
|
-
this.createDataset = async (datasetId, options = {}) => {
|
|
59
|
-
await this.ensureInit();
|
|
60
|
-
const datasetExists = await this.datasetExists(datasetId);
|
|
61
|
-
if (!datasetExists) {
|
|
62
|
-
await this.client
|
|
63
|
-
.createDataset(datasetId);
|
|
64
|
-
}
|
|
65
|
-
};
|
|
66
|
-
/**
|
|
67
|
-
* Check to see whether a given BigQuery dataset exists.
|
|
68
|
-
* Based off:
|
|
69
|
-
* https://github.com/googleapis/nodejs-bigquery/blob/main/samples/getDataset.js
|
|
70
|
-
*/
|
|
71
|
-
this.datasetExists = async (datasetId) => {
|
|
72
|
-
await this.ensureInit();
|
|
73
|
-
let response;
|
|
1
|
+
import { BaseNamespace } from "../../_class";
|
|
2
|
+
import { getConfig } from "../server";
|
|
3
|
+
export class GoogleBigQueryNamespace extends BaseNamespace {
|
|
4
|
+
ensureInit = async () => {
|
|
5
|
+
if (!this.client) {
|
|
74
6
|
try {
|
|
75
|
-
await
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
}
|
|
79
|
-
catch (exception) {
|
|
80
|
-
response = false;
|
|
7
|
+
const { BigQuery } = await import("@google-cloud/bigquery");
|
|
8
|
+
const formattedConfig = getConfig(this.config, this.config?.projectId);
|
|
9
|
+
this.client = new BigQuery(formattedConfig);
|
|
81
10
|
}
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
/**
|
|
85
|
-
* Retrieve all the Datasets
|
|
86
|
-
*/
|
|
87
|
-
this.getDatasets = async () => {
|
|
88
|
-
await this.ensureInit();
|
|
89
|
-
let response = [];
|
|
90
|
-
const datasets = await this.client.getDatasets();
|
|
91
|
-
if (datasets?.[0]) {
|
|
92
|
-
for (let i = 0; i < datasets[0].length; i++) {
|
|
93
|
-
response.push({
|
|
94
|
-
id: datasets[0][i].id,
|
|
95
|
-
location: datasets[0][i].location,
|
|
96
|
-
projectId: datasets[0][i].bigQuery.projectId,
|
|
97
|
-
});
|
|
98
|
-
}
|
|
11
|
+
catch (e) {
|
|
12
|
+
throw new Error("Google BigQuery Client not installed");
|
|
99
13
|
}
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
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
|
+
const datasetExists = await this.datasetExists(datasetId);
|
|
23
|
+
if (!datasetExists) {
|
|
24
|
+
await this.client
|
|
25
|
+
.createDataset(datasetId);
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
/**
|
|
29
|
+
* Check to see whether a given BigQuery dataset exists.
|
|
30
|
+
* Based off:
|
|
31
|
+
* https://github.com/googleapis/nodejs-bigquery/blob/main/samples/getDataset.js
|
|
32
|
+
*/
|
|
33
|
+
datasetExists = async (datasetId) => {
|
|
34
|
+
await this.ensureInit();
|
|
35
|
+
let response;
|
|
36
|
+
try {
|
|
37
|
+
await this.client.dataset(datasetId)
|
|
38
|
+
.get();
|
|
39
|
+
response = true;
|
|
40
|
+
}
|
|
41
|
+
catch (exception) {
|
|
42
|
+
response = false;
|
|
43
|
+
}
|
|
44
|
+
return response;
|
|
45
|
+
};
|
|
46
|
+
/**
|
|
47
|
+
* Retrieve all the Datasets
|
|
48
|
+
*/
|
|
49
|
+
getDatasets = async () => {
|
|
50
|
+
await this.ensureInit();
|
|
51
|
+
let response = [];
|
|
52
|
+
const datasets = await this.client.getDatasets();
|
|
53
|
+
if (datasets?.[0]) {
|
|
54
|
+
for (let i = 0; i < datasets[0].length; i++) {
|
|
55
|
+
response.push({
|
|
56
|
+
id: datasets[0][i].id,
|
|
57
|
+
location: datasets[0][i].location,
|
|
58
|
+
projectId: datasets[0][i].bigQuery.projectId,
|
|
59
|
+
});
|
|
121
60
|
}
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
61
|
+
}
|
|
62
|
+
return response;
|
|
63
|
+
};
|
|
64
|
+
query = async (props) => {
|
|
65
|
+
await this.ensureInit();
|
|
66
|
+
let queryString = "string" === typeof props ? props : props.query;
|
|
67
|
+
let options = "string" === typeof props ? {} : props?.params;
|
|
68
|
+
const apiResponse = await this.client.query(queryString, options);
|
|
69
|
+
return apiResponse;
|
|
70
|
+
};
|
|
71
|
+
/**
|
|
72
|
+
* Create a Table if it doesn't already exist.
|
|
73
|
+
*/
|
|
74
|
+
createTable = async (datasetId, datasetOptions = {}, tableId, options = {}) => {
|
|
75
|
+
await this.ensureInit();
|
|
76
|
+
// Create the BigQuery table if it doesn't exist
|
|
77
|
+
await this.createDataset(datasetId, datasetOptions);
|
|
78
|
+
const tableExists = await this.tableExists(datasetId, tableId);
|
|
79
|
+
if (!tableExists) {
|
|
80
|
+
await this.client
|
|
81
|
+
.dataset(datasetId)
|
|
82
|
+
.createTable(tableId, options || {});
|
|
83
|
+
}
|
|
84
|
+
};
|
|
85
|
+
/**
|
|
86
|
+
* Check to see whether a given BigQuery table exists.
|
|
87
|
+
* https://cloud.google.com/bigquery/docs/samples/bigquery-table-exists
|
|
88
|
+
*/
|
|
89
|
+
tableExists = async (datasetId, tableId) => {
|
|
90
|
+
await this.ensureInit();
|
|
91
|
+
let response = false;
|
|
92
|
+
const tables = await this.getTables(datasetId);
|
|
93
|
+
for (let i = 0; i < tables.length; i++) {
|
|
94
|
+
if (tables[i].id === tableId) {
|
|
95
|
+
response = true;
|
|
96
|
+
break;
|
|
136
97
|
}
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
}
|
|
98
|
+
}
|
|
99
|
+
return response;
|
|
100
|
+
};
|
|
101
|
+
getTables = async (datasetId) => {
|
|
102
|
+
await this.ensureInit();
|
|
103
|
+
let response = [];
|
|
104
|
+
const tables = await this.client.dataset(datasetId)
|
|
105
|
+
.getTables();
|
|
106
|
+
if (tables?.[0]) {
|
|
107
|
+
for (let i = 0; i < tables[0].length; i++) {
|
|
108
|
+
response.push({
|
|
109
|
+
id: tables[0][i].id,
|
|
110
|
+
});
|
|
150
111
|
}
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
}
|
|
112
|
+
}
|
|
113
|
+
return response;
|
|
114
|
+
};
|
|
154
115
|
}
|
|
155
|
-
exports.GoogleBigQueryNamespace = GoogleBigQueryNamespace;
|