@8ms/helpers 1.1.73 → 1.1.77
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/api/response.d.ts +8 -0
- package/api/response.js +12 -1
- package/api/states.d.ts +9 -0
- package/api/states.js +10 -1
- package/api/unexpectedError.d.ts +2 -0
- package/api/unexpectedError.js +4 -1
- package/array/contains.d.ts +8 -0
- package/array/contains.js +6 -2
- package/array/getArray.d.ts +7 -0
- package/array/getArray.js +10 -2
- package/atInternet/request.d.ts +30 -0
- package/atInternet/request.js +2 -1
- package/aws/athenaExpress/initClient.d.ts +12 -0
- package/aws/athenaExpress/initClient.js +27 -3
- package/aws/athenaExpress/query.d.ts +8 -0
- package/aws/athenaExpress/query.js +9 -2
- package/aws/getConfig.d.ts +13 -0
- package/aws/getConfig.js +26 -2
- package/aws/glue/initClient.d.ts +10 -0
- package/aws/glue/initClient.js +17 -2
- package/aws/glue/invoke.d.ts +9 -0
- package/aws/glue/invoke.js +19 -2
- package/aws/isResponse200.d.ts +7 -0
- package/aws/isResponse200.js +21 -2
- package/aws/lambda/getHandlerPath.d.ts +5 -0
- package/aws/lambda/getHandlerPath.js +7 -1
- package/aws/lambda/initClient.d.ts +10 -0
- package/aws/lambda/initClient.js +17 -2
- package/aws/lambda/invoke.d.ts +12 -0
- package/aws/lambda/invoke.js +39 -2
- package/aws/s3/copyFile.d.ts +13 -0
- package/aws/s3/copyFile.js +13 -2
- package/aws/s3/deleteFile.d.ts +9 -0
- package/aws/s3/deleteFile.js +12 -2
- package/aws/s3/deleteFiles.d.ts +9 -0
- package/aws/s3/deleteFiles.js +16 -2
- package/aws/s3/deleteFolder.d.ts +9 -0
- package/aws/s3/deleteFolder.js +35 -2
- package/aws/s3/getGlueJson.d.ts +5 -0
- package/aws/s3/getGlueJson.js +15 -2
- package/aws/s3/getPresignedPost.d.ts +20 -0
- package/aws/s3/getPresignedPost.js +16 -3
- package/aws/s3/getSignedUrl.d.ts +12 -0
- package/aws/s3/getSignedUrl.js +15 -2
- package/aws/s3/initClient.d.ts +10 -0
- package/aws/s3/initClient.js +17 -2
- package/aws/s3/isFileExists.d.ts +9 -0
- package/aws/s3/isFileExists.js +26 -2
- package/aws/s3/listFiles.d.ts +9 -0
- package/aws/s3/listFiles.js +32 -2
- package/aws/s3/listFolders.d.ts +9 -0
- package/aws/s3/listFolders.js +31 -4
- package/aws/s3/moveFile.d.ts +10 -0
- package/aws/s3/moveFile.js +20 -2
- package/aws/s3/readBuffer.d.ts +13 -0
- package/aws/s3/readBuffer.js +51 -2
- package/aws/s3/readFile.d.ts +30 -0
- package/aws/s3/readFile.js +69 -2
- package/aws/s3/writeFile.d.ts +10 -0
- package/aws/s3/writeFile.js +15 -2
- package/aws/s3/writePresignedPost.d.ts +14 -0
- package/aws/s3/writePresignedPost.js +30 -2
- package/aws/s3cache/cache.d.ts +7 -0
- package/aws/s3cache/cache.js +2 -1
- package/aws/s3cache/getCache.d.ts +12 -0
- package/aws/s3cache/getCache.js +35 -2
- package/aws/s3cache/getKey.d.ts +10 -0
- package/aws/s3cache/getKey.js +16 -2
- package/aws/s3cache/saveCache.d.ts +10 -0
- package/aws/s3cache/saveCache.js +12 -2
- package/aws/s3cache/updateCache.d.ts +10 -0
- package/aws/s3cache/updateCache.js +23 -2
- package/aws/ses/SimpleEmail.d.ts +51 -0
- package/aws/ses/SimpleEmail.js +115 -2
- package/aws/ses/initClient.d.ts +10 -0
- package/aws/ses/initClient.js +17 -2
- package/aws/ssm/getParameter.d.ts +10 -0
- package/aws/ssm/getParameter.js +39 -2
- package/aws/ssm/initClient.d.ts +10 -0
- package/aws/ssm/initClient.js +17 -2
- package/axios/get.d.ts +8 -0
- package/axios/get.js +44 -1
- package/axios/post.d.ts +12 -0
- package/axios/post.js +46 -2
- package/boolean/getBoolean.d.ts +7 -0
- package/boolean/getBoolean.js +15 -2
- package/class/BaseClass.d.ts +31 -0
- package/class/BaseClass.js +50 -9
- package/crud/actions.d.ts +8 -0
- package/crud/actions.js +10 -1
- package/crypto/getDecrypt.d.ts +10 -0
- package/crypto/getDecrypt.js +11 -2
- package/crypto/getEncrypt.d.ts +10 -0
- package/crypto/getEncrypt.js +11 -2
- package/crypto/getRandom.d.ts +8 -0
- package/crypto/getRandom.js +10 -2
- package/crypto/getSha256.d.ts +8 -0
- package/crypto/getSha256.js +15 -2
- package/date/date.d.ts +4 -0
- package/date/date.js +2 -1
- package/date/duration.d.ts +5 -0
- package/date/duration.js +2 -1
- package/date/durationComparisons.d.ts +5 -0
- package/date/durationComparisons.js +7 -1
- package/date/durations.d.ts +8 -0
- package/date/durations.js +10 -1
- package/date/financialYear.d.ts +4 -0
- package/date/financialYear.js +2 -1
- package/date/financialYearWeek.d.ts +6 -0
- package/date/financialYearWeek.js +2 -1
- package/date/format.d.ts +13 -0
- package/date/format.js +18 -2
- package/date/getDate.d.ts +12 -0
- package/date/getDate.js +96 -9
- package/date/getDatesBetween.d.ts +10 -0
- package/date/getDatesBetween.js +25 -3
- package/date/getDurationHours.d.ts +8 -0
- package/date/getDurationHours.js +25 -2
- package/date/getDurationMinutes.d.ts +8 -0
- package/date/getDurationMinutes.js +24 -2
- package/date/getFinancialYear.d.ts +9 -0
- package/date/getFinancialYear.js +48 -8
- package/date/getFinancialYearToDate.d.ts +7 -0
- package/date/getFinancialYearToDate.js +18 -2
- package/date/getFinancialYearToYesterday.d.ts +7 -0
- package/date/getFinancialYearToYesterday.js +18 -2
- package/date/getFinancialYearWeeks.d.ts +9 -0
- package/date/getFinancialYearWeeks.js +29 -2
- package/date/getLastWeek.d.ts +10 -0
- package/date/getLastWeek.js +28 -2
- package/date/getMax.d.ts +12 -0
- package/date/getMax.js +15 -2
- package/date/getMidnight.d.ts +10 -0
- package/date/getMidnight.js +12 -2
- package/date/getMin.d.ts +12 -0
- package/date/getMin.js +15 -2
- package/date/getMonday.d.ts +14 -0
- package/date/getMonday.js +32 -5
- package/date/getNumber.d.ts +11 -0
- package/date/getNumber.js +14 -2
- package/date/getPredefinedTimeframe.d.ts +9 -0
- package/date/getPredefinedTimeframe.js +23 -2
- package/date/getSunday.d.ts +14 -0
- package/date/getSunday.js +32 -5
- package/date/getThisWeek.d.ts +10 -0
- package/date/getThisWeek.js +28 -2
- package/date/getTimeZoned.d.ts +13 -0
- package/date/getTimeZoned.js +36 -5
- package/date/getToday.d.ts +9 -0
- package/date/getToday.js +39 -2
- package/date/getTwoWeeksAgo.d.ts +10 -0
- package/date/getTwoWeeksAgo.js +28 -2
- package/date/getWeeksAgo.d.ts +12 -0
- package/date/getWeeksAgo.js +16 -2
- package/date/getYesterday.d.ts +9 -0
- package/date/getYesterday.js +40 -2
- package/date/isDateValid.d.ts +7 -0
- package/date/isDateValid.js +22 -2
- package/date/isLastWeek.d.ts +6 -0
- package/date/isLastWeek.js +13 -2
- package/date/isThisWeek.d.ts +6 -0
- package/date/isThisWeek.js +13 -2
- package/date/parseExcelDate.d.ts +8 -0
- package/date/parseExcelDate.js +17 -2
- package/date/predefinedTimeframes.d.ts +7 -0
- package/date/predefinedTimeframes.js +9 -1
- package/date/timeframe.d.ts +8 -0
- package/date/timeframe.js +2 -1
- package/date/timeframes.d.ts +4 -0
- package/date/timeframes.js +7 -1
- package/deepCrawl/buildRequest.d.ts +15 -0
- package/deepCrawl/buildRequest.js +83 -4
- package/deepCrawl/filter.d.ts +5 -0
- package/deepCrawl/filter.js +2 -1
- package/deepCrawl/getData.d.ts +5 -0
- package/deepCrawl/getData.js +29 -1
- package/deepCrawl/initClient.d.ts +13 -0
- package/deepCrawl/initClient.js +31 -2
- package/deepCrawl/operands.d.ts +11 -0
- package/deepCrawl/operands.js +13 -1
- package/deepCrawl/orders.d.ts +9 -0
- package/deepCrawl/orders.js +7 -1
- package/deepCrawl/reports.d.ts +11 -0
- package/deepCrawl/reports.js +13 -1
- package/environment/environments.d.ts +7 -0
- package/environment/environments.js +8 -1
- package/environment/getEnvironment.d.ts +6 -0
- package/environment/getEnvironment.js +42 -2
- package/environment/isAws.d.ts +5 -0
- package/environment/isAws.js +10 -2
- package/environment/isDevelopment.d.ts +2 -0
- package/environment/isDevelopment.js +9 -1
- package/environment/isLocalhost.d.ts +5 -0
- package/environment/isLocalhost.js +21 -2
- package/environment/isProduction.d.ts +2 -0
- package/environment/isProduction.js +9 -1
- package/environment/isStaging.d.ts +2 -0
- package/environment/isStaging.js +9 -1
- package/environment/isVercel.d.ts +5 -0
- package/environment/isVercel.js +6 -2
- package/environment/platforms.d.ts +6 -0
- package/environment/platforms.js +7 -1
- package/eskimi/ageGroups.d.ts +5 -0
- package/eskimi/ageGroups.js +41 -1
- package/eskimi/campaign.d.ts +19 -0
- package/eskimi/campaign.js +2 -1
- package/eskimi/devices.d.ts +5 -0
- package/eskimi/devices.js +13 -1
- package/eskimi/endpoints.d.ts +16 -0
- package/eskimi/endpoints.js +17 -2
- package/eskimi/genders.d.ts +5 -0
- package/eskimi/genders.js +13 -1
- package/eskimi/getAccessToken.d.ts +9 -0
- package/eskimi/getAccessToken.js +22 -2
- package/eskimi/getAgeGroup.d.ts +7 -0
- package/eskimi/getAgeGroup.js +16 -2
- package/eskimi/getCampaignIds.d.ts +7 -0
- package/eskimi/getCampaignIds.js +11 -2
- package/eskimi/getDevice.d.ts +7 -0
- package/eskimi/getDevice.js +16 -2
- package/eskimi/getGender.d.ts +7 -0
- package/eskimi/getGender.js +16 -2
- package/eskimi/request.d.ts +8 -0
- package/eskimi/request.js +23 -2
- package/google/bigQuery/initClient.d.ts +11 -0
- package/google/bigQuery/initClient.js +20 -2
- package/google/bigQuery/query.d.ts +9 -0
- package/google/bigQuery/query.js +9 -2
- package/google/getConfig.d.ts +20 -0
- package/google/getConfig.js +21 -3
- package/google/sheets/getAssociatedData.d.ts +16 -0
- package/google/sheets/getAssociatedData.js +52 -8
- package/google/sheets/getBatchData.d.ts +18 -0
- package/google/sheets/getBatchData.js +19 -1
- package/google/sheets/initClient.d.ts +11 -0
- package/google/sheets/initClient.js +22 -2
- package/google/sheets/isCellNa.d.ts +7 -0
- package/google/sheets/isCellNa.js +6 -2
- package/google/storage/initClient.d.ts +12 -0
- package/google/storage/initClient.js +20 -2
- package/google/storage/writeFile.d.ts +12 -0
- package/google/storage/writeFile.js +30 -2
- package/googleAds/getCustomer.d.ts +8 -0
- package/googleAds/getCustomer.js +13 -2
- package/googleAds/initClient.d.ts +16 -0
- package/googleAds/initClient.js +23 -2
- package/initClients.d.ts +40 -0
- package/initClients.js +99 -5
- package/json/isJson.d.ts +8 -0
- package/json/isJson.js +18 -2
- package/littleWarden/getUrlStatus.d.ts +9 -0
- package/littleWarden/getUrlStatus.js +20 -2
- package/littleWarden/isAllGood.d.ts +7 -0
- package/littleWarden/isAllGood.js +17 -2
- package/littleWarden/isDanger.d.ts +7 -0
- package/littleWarden/isDanger.js +17 -2
- package/littleWarden/isWarning.d.ts +7 -0
- package/littleWarden/isWarning.js +17 -2
- package/littleWarden/states.d.ts +7 -0
- package/littleWarden/states.js +8 -1
- package/myTarget/getAccessToken.d.ts +9 -0
- package/myTarget/getAccessToken.js +22 -2
- package/myTarget/request.d.ts +8 -0
- package/myTarget/request.js +23 -2
- package/nextAuth/isSessionReady.d.ts +4 -0
- package/nextAuth/isSessionReady.js +12 -1
- package/nextAuth/states.d.ts +7 -0
- package/nextAuth/states.js +8 -2
- package/nextJs/getIp.d.ts +7 -0
- package/nextJs/getIp.js +12 -2
- package/nextJs/getUserAgent.d.ts +7 -0
- package/nextJs/getUserAgent.js +6 -2
- package/number/getDivide.d.ts +9 -0
- package/number/getDivide.js +17 -2
- package/number/getNumber.d.ts +8 -0
- package/number/getNumber.js +50 -7
- package/number/getPercent.d.ts +9 -0
- package/number/getPercent.js +17 -2
- package/number/getPercentIncrease.d.ts +9 -0
- package/number/getPercentIncrease.js +17 -2
- package/number/getRounded.d.ts +9 -0
- package/number/getRounded.js +21 -2
- package/package.json +44 -47
- package/prisma/initClient.d.ts +4 -0
- package/prisma/initClient.js +33 -3
- package/snapchat/getAccessToken.d.ts +9 -0
- package/snapchat/getAccessToken.js +36 -2
- package/sorting/byNumberAscending.d.ts +8 -0
- package/sorting/byNumberAscending.js +16 -2
- package/sorting/byNumberDescending.d.ts +8 -0
- package/sorting/byNumberDescending.js +16 -2
- package/sorting/byStringAscending.d.ts +8 -0
- package/sorting/byStringAscending.js +20 -2
- package/sorting/byStringDescending.d.ts +8 -0
- package/sorting/byStringDescending.js +20 -2
- package/string/formatCapitalise.d.ts +9 -0
- package/string/formatCapitalise.js +14 -2
- package/string/getCleanFolder.d.ts +7 -0
- package/string/getCleanFolder.js +11 -2
- package/string/getString.d.ts +7 -0
- package/string/getString.js +35 -2
- package/string/getStringFromStream.d.ts +8 -0
- package/string/getStringFromStream.js +14 -2
- package/string/toProperCase.d.ts +7 -0
- package/string/toProperCase.js +17 -2
- package/swr/isAllData.d.ts +7 -0
- package/swr/isAllData.js +18 -2
- package/swr/isAnyError.d.ts +7 -0
- package/swr/isAnyError.js +18 -2
- package/swr/isAnyLoading.d.ts +7 -0
- package/swr/isAnyLoading.js +20 -2
- package/swr/isData.d.ts +7 -0
- package/swr/isData.js +6 -2
- package/swr/isError.d.ts +7 -0
- package/swr/isError.js +6 -2
- package/swr/isLoading.d.ts +7 -0
- package/swr/isLoading.js +11 -2
- package/upTimeRobot/getMonitors.d.ts +1 -0
- package/upTimeRobot/getMonitors.js +31 -2
- package/upTimeRobot/logTypes.d.ts +7 -0
- package/upTimeRobot/logTypes.js +9 -1
- package/upTimeRobot/monitorStatuses.d.ts +8 -0
- package/upTimeRobot/monitorStatuses.js +10 -1
- package/upTimeRobot/monitorSubTypes.d.ts +10 -0
- package/upTimeRobot/monitorSubTypes.js +12 -1
- package/upTimeRobot/monitorTypes.d.ts +8 -0
- package/upTimeRobot/monitorTypes.js +10 -1
- package/upTimeRobot/requestStatuses.d.ts +5 -0
- package/upTimeRobot/requestStatuses.js +7 -1
- package/url/buildParameters.d.ts +8 -0
- package/url/buildParameters.js +21 -2
- package/url/buildRelative.d.ts +8 -0
- package/url/buildRelative.js +12 -2
- package/url/buildUrl.d.ts +10 -0
- package/url/buildUrl.js +28 -2
- package/url/isAbsolute.d.ts +7 -0
- package/url/isAbsolute.js +14 -2
- package/url/isRelative.d.ts +7 -0
- package/url/isRelative.js +7 -2
- package/url/url.d.ts +6 -0
- package/url/url.js +2 -1
- package/util/defaultTo.d.ts +10 -0
- package/util/defaultTo.js +34 -2
- package/util/isUndefined.d.ts +9 -0
- package/util/isUndefined.js +18 -2
- package/util/sleep.d.ts +4 -0
- package/util/sleep.js +6 -1
- package/webWorker/states.d.ts +7 -0
- package/webWorker/states.js +8 -1
- package/xml/getXml.d.ts +4 -0
- package/xml/getXml.js +14 -1
- package/globals.d.js +0 -1
package/google/getConfig.js
CHANGED
|
@@ -1,5 +1,23 @@
|
|
|
1
|
-
"use strict";
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
2
3
|
/**
|
|
3
4
|
* Using the response from Parameter Store and format it ready to be used with Google API.
|
|
4
|
-
*/
|
|
5
|
-
|
|
5
|
+
*/
|
|
6
|
+
const getConfig = ({ parameter }) => {
|
|
7
|
+
// Format the private key to be in the same format as required by Google
|
|
8
|
+
const privateKey = parameter['private_key'].replace(/\\n/g, '\n');
|
|
9
|
+
const response = {
|
|
10
|
+
type: parameter['type'],
|
|
11
|
+
project_id: parameter['project_id'],
|
|
12
|
+
private_key_id: parameter['private_key_id'],
|
|
13
|
+
private_key: privateKey,
|
|
14
|
+
client_email: parameter['client_email'],
|
|
15
|
+
client_id: parameter['client_id'],
|
|
16
|
+
auth_uri: parameter['auth_uri'],
|
|
17
|
+
token_uri: parameter['token_uri'],
|
|
18
|
+
auth_provider_x509_cert_url: parameter['auth_provider_x509_cert_url'],
|
|
19
|
+
client_x509_cert_url: parameter['client_x509_cert_url'],
|
|
20
|
+
};
|
|
21
|
+
return response;
|
|
22
|
+
};
|
|
23
|
+
exports.default = getConfig;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
declare type GetAssociatedData = {
|
|
2
|
+
spreadsheetId: string;
|
|
3
|
+
ranges: [
|
|
4
|
+
format: string,
|
|
5
|
+
defaultRange: string,
|
|
6
|
+
heading: string,
|
|
7
|
+
data: string
|
|
8
|
+
];
|
|
9
|
+
dateTimeRender: 'FORMATTED_STRING' | 'SERIAL_NUMBER';
|
|
10
|
+
valueRender: 'FORMATTED_VALUE' | 'UNFORMATTED_VALUE' | 'FORMULA';
|
|
11
|
+
};
|
|
12
|
+
/**
|
|
13
|
+
* Make a batch get to Google Sheets to retrieve the data correctly formatted, with default values provided.
|
|
14
|
+
*/
|
|
15
|
+
declare const getAssociatedData: ({ dateTimeRender, ranges, spreadsheetId, valueRender }: GetAssociatedData) => Promise<object[]>;
|
|
16
|
+
export default getAssociatedData;
|
|
@@ -1,9 +1,53 @@
|
|
|
1
|
-
"use strict";
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const getBatchData_1 = __importDefault(require("./getBatchData"));
|
|
7
|
+
/**
|
|
2
8
|
* Make a batch get to Google Sheets to retrieve the data correctly formatted, with default values provided.
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
//
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
9
|
+
*/
|
|
10
|
+
const getAssociatedData = async ({ dateTimeRender, ranges, spreadsheetId, valueRender }) => {
|
|
11
|
+
// Make the API request
|
|
12
|
+
const apiResponse = await (0, getBatchData_1.default)({
|
|
13
|
+
spreadsheetId,
|
|
14
|
+
ranges,
|
|
15
|
+
dateTimeRender,
|
|
16
|
+
valueRender,
|
|
17
|
+
});
|
|
18
|
+
let template = [];
|
|
19
|
+
let response = [];
|
|
20
|
+
// Missing ranges or too many ranges
|
|
21
|
+
if (4 !== apiResponse.valueRanges.length) {
|
|
22
|
+
throw new Error("Associated data response length must be 4.");
|
|
23
|
+
}
|
|
24
|
+
// Get the first data range
|
|
25
|
+
const initialRangeLength = apiResponse.valueRanges[0].values[0].length;
|
|
26
|
+
// Loop through the headings
|
|
27
|
+
for (let i = 0; i < initialRangeLength; i++) {
|
|
28
|
+
template.push({
|
|
29
|
+
format: apiResponse.valueRanges[0].values[0][i],
|
|
30
|
+
default: apiResponse.valueRanges[1].values[0][i],
|
|
31
|
+
heading: apiResponse.valueRanges[2].values[0][i],
|
|
32
|
+
index: i,
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
// console.log('template', template);
|
|
36
|
+
// Loop through each row of data
|
|
37
|
+
if (undefined !== apiResponse.valueRanges[3].values) {
|
|
38
|
+
for (let rowIndex = 0; rowIndex < apiResponse.valueRanges[3].values.length; rowIndex++) {
|
|
39
|
+
let row = {};
|
|
40
|
+
// Loop through each column within the row
|
|
41
|
+
for (let columnIndex = 0; columnIndex < apiResponse.valueRanges[3].values[rowIndex].length; columnIndex++) {
|
|
42
|
+
const refValue = apiResponse.valueRanges[3].values[rowIndex][columnIndex];
|
|
43
|
+
const value = ('' === refValue ? template[columnIndex]['default'] : refValue);
|
|
44
|
+
// Add this to our row
|
|
45
|
+
row[template[columnIndex]['heading']] = value;
|
|
46
|
+
}
|
|
47
|
+
// Add the row to our response
|
|
48
|
+
response.push(row);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
return response;
|
|
52
|
+
};
|
|
53
|
+
exports.default = getAssociatedData;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
declare type BatchData = {
|
|
2
|
+
spreadsheetId: string;
|
|
3
|
+
valueRanges: {
|
|
4
|
+
range: string;
|
|
5
|
+
majorDimension: 'rows' | 'dimension';
|
|
6
|
+
values: [
|
|
7
|
+
any[]
|
|
8
|
+
];
|
|
9
|
+
}[];
|
|
10
|
+
};
|
|
11
|
+
declare type GetBatchData = {
|
|
12
|
+
spreadsheetId: string;
|
|
13
|
+
ranges: string[];
|
|
14
|
+
dateTimeRender?: string;
|
|
15
|
+
valueRender?: string;
|
|
16
|
+
};
|
|
17
|
+
declare const getBatchData: ({ spreadsheetId, ranges, dateTimeRender, valueRender, }: GetBatchData) => Promise<BatchData>;
|
|
18
|
+
export default getBatchData;
|
|
@@ -1 +1,19 @@
|
|
|
1
|
-
"use strict";
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const getBatchData = async ({ spreadsheetId, ranges, dateTimeRender = 'FORMATTED_STRING', valueRender = 'UNFORMATTED_VALUE', }) => {
|
|
4
|
+
const googleApisSheets = require('@googleapis/sheets');
|
|
5
|
+
const request = {
|
|
6
|
+
auth: global.googleSheetsClient,
|
|
7
|
+
dateTimeRenderOption: dateTimeRender,
|
|
8
|
+
ranges: ranges,
|
|
9
|
+
spreadsheetId: spreadsheetId,
|
|
10
|
+
valueRenderOption: valueRender,
|
|
11
|
+
};
|
|
12
|
+
// Make the API request
|
|
13
|
+
const apiResponse = (await googleApisSheets.sheets('v4')
|
|
14
|
+
.spreadsheets
|
|
15
|
+
.values
|
|
16
|
+
.batchGet(request));
|
|
17
|
+
return apiResponse.data;
|
|
18
|
+
};
|
|
19
|
+
exports.default = getBatchData;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Config } from '../getConfig';
|
|
2
|
+
declare type InitClient = {
|
|
3
|
+
parameter: Config;
|
|
4
|
+
};
|
|
5
|
+
/**
|
|
6
|
+
* Initialise the Google Sheets instance using the separate service method.
|
|
7
|
+
* https://github.com/googleapis/google-api-nodejs-client
|
|
8
|
+
* Library: @googleapis/sheets
|
|
9
|
+
*/
|
|
10
|
+
declare const initClient: ({ parameter }: InitClient) => void;
|
|
11
|
+
export default initClient;
|
|
@@ -1,5 +1,25 @@
|
|
|
1
|
-
"use strict";
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const getConfig_1 = __importDefault(require("../getConfig"));
|
|
7
|
+
global.googleSheetsClient = null;
|
|
8
|
+
/**
|
|
2
9
|
* Initialise the Google Sheets instance using the separate service method.
|
|
3
10
|
* https://github.com/googleapis/google-api-nodejs-client
|
|
4
11
|
* Library: @googleapis/sheets
|
|
5
|
-
*/
|
|
12
|
+
*/
|
|
13
|
+
const initClient = ({ parameter }) => {
|
|
14
|
+
if (!global.googleSheetsClient) {
|
|
15
|
+
const googleApisSheets = require('@googleapis/sheets');
|
|
16
|
+
const formattedConfig = (0, getConfig_1.default)({ parameter });
|
|
17
|
+
global.googleSheetsClient = new googleApisSheets.auth.GoogleAuth({
|
|
18
|
+
credentials: formattedConfig,
|
|
19
|
+
scopes: [
|
|
20
|
+
'https://www.googleapis.com/auth/spreadsheets',
|
|
21
|
+
],
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
exports.default = initClient;
|
|
@@ -1,3 +1,7 @@
|
|
|
1
|
-
"use strict";
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
/**
|
|
2
4
|
* Noticed sometimes Google Sheets can struggle with import XML resulting to N/A values.
|
|
3
|
-
*/
|
|
5
|
+
*/
|
|
6
|
+
const isCellNa = ({ input }) => '#N/A' === input;
|
|
7
|
+
exports.default = isCellNa;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Config } from '../getConfig';
|
|
2
|
+
declare type InitClient = {
|
|
3
|
+
parameter: Config;
|
|
4
|
+
projectId: string;
|
|
5
|
+
};
|
|
6
|
+
/**
|
|
7
|
+
* Initialise the Google Sheets instance using the separate service method.
|
|
8
|
+
* https://github.com/googleapis/google-api-nodejs-client
|
|
9
|
+
* Library: @googleapis/sheets
|
|
10
|
+
*/
|
|
11
|
+
declare const initClient: ({ parameter, projectId }: InitClient) => void;
|
|
12
|
+
export default initClient;
|
|
@@ -1,5 +1,23 @@
|
|
|
1
|
-
"use strict";
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const getConfig_1 = __importDefault(require("../getConfig"));
|
|
7
|
+
global.googleStorageClient = {};
|
|
8
|
+
/**
|
|
2
9
|
* Initialise the Google Sheets instance using the separate service method.
|
|
3
10
|
* https://github.com/googleapis/google-api-nodejs-client
|
|
4
11
|
* Library: @googleapis/sheets
|
|
5
|
-
*/
|
|
12
|
+
*/
|
|
13
|
+
const initClient = ({ parameter, projectId }) => {
|
|
14
|
+
if (!global.googleStorageClient[projectId]) {
|
|
15
|
+
const { Storage } = require('@google-cloud/storage');
|
|
16
|
+
const formattedConfig = (0, getConfig_1.default)({ parameter });
|
|
17
|
+
global.googleStorageClient[projectId] = new Storage({
|
|
18
|
+
credentials: formattedConfig,
|
|
19
|
+
projectId: projectId,
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
exports.default = initClient;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
declare type WriteFile = {
|
|
2
|
+
bucket: string;
|
|
3
|
+
credentials: any;
|
|
4
|
+
data: any;
|
|
5
|
+
key: string;
|
|
6
|
+
projectId: string;
|
|
7
|
+
};
|
|
8
|
+
/**
|
|
9
|
+
* Write a file to Google Cloud Storage.
|
|
10
|
+
*/
|
|
11
|
+
export declare const writeFile: ({ bucket, data, key, projectId }: WriteFile) => Promise<any>;
|
|
12
|
+
export default writeFile;
|
|
@@ -1,3 +1,31 @@
|
|
|
1
|
-
"use strict";
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.writeFile = void 0;
|
|
4
|
+
/**
|
|
2
5
|
* Write a file to Google Cloud Storage.
|
|
3
|
-
*/
|
|
6
|
+
*/
|
|
7
|
+
const writeFile = async ({ bucket, data, key, projectId }) => {
|
|
8
|
+
const stream = require('stream');
|
|
9
|
+
const dataStream = new stream.PassThrough();
|
|
10
|
+
const googleFile = global.googleStorageClient[projectId].bucket(bucket)
|
|
11
|
+
.file(key);
|
|
12
|
+
dataStream.push(data);
|
|
13
|
+
dataStream.push(null);
|
|
14
|
+
return await new Promise((resolve, reject) => {
|
|
15
|
+
dataStream.pipe(googleFile.createWriteStream({
|
|
16
|
+
contentType: 'auto',
|
|
17
|
+
resumable: false,
|
|
18
|
+
validation: false,
|
|
19
|
+
metadata: {},
|
|
20
|
+
}))
|
|
21
|
+
.on('error', (error) => {
|
|
22
|
+
reject(error);
|
|
23
|
+
})
|
|
24
|
+
.on('finish', () => {
|
|
25
|
+
// console.log(`File uploaded successfully.`);
|
|
26
|
+
resolve(true);
|
|
27
|
+
});
|
|
28
|
+
});
|
|
29
|
+
};
|
|
30
|
+
exports.writeFile = writeFile;
|
|
31
|
+
exports.default = exports.writeFile;
|
package/googleAds/getCustomer.js
CHANGED
|
@@ -1,3 +1,14 @@
|
|
|
1
|
-
"use strict";
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
/**
|
|
2
4
|
* Return the Google Ads Client with the specified customer set.
|
|
3
|
-
*/
|
|
5
|
+
*/
|
|
6
|
+
const getCustomer = async ({ customerId }) => {
|
|
7
|
+
const customer = global.googleAdsClient.instance.Customer({
|
|
8
|
+
customer_id: customerId,
|
|
9
|
+
login_customer_id: global.googleAdsClient.mccAccountId,
|
|
10
|
+
refresh_token: global.googleAdsClient.refreshToken,
|
|
11
|
+
});
|
|
12
|
+
return customer;
|
|
13
|
+
};
|
|
14
|
+
exports.default = getCustomer;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export declare type GoogleAdsParameter = {
|
|
2
|
+
clientId: string;
|
|
3
|
+
clientSecret: string;
|
|
4
|
+
developerToken: string;
|
|
5
|
+
mccAccountId: string;
|
|
6
|
+
refreshToken: string;
|
|
7
|
+
};
|
|
8
|
+
declare type InitClient = {
|
|
9
|
+
parameter: GoogleAdsParameter;
|
|
10
|
+
};
|
|
11
|
+
/**
|
|
12
|
+
* Shorthand function to get the Google Ads Client.
|
|
13
|
+
* Library: google-ads-api
|
|
14
|
+
*/
|
|
15
|
+
declare const initClient: ({ parameter }: InitClient) => Promise<void>;
|
|
16
|
+
export default initClient;
|
package/googleAds/initClient.js
CHANGED
|
@@ -1,4 +1,25 @@
|
|
|
1
|
-
"use strict";
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
global.googleAdsClient = {
|
|
4
|
+
instance: null,
|
|
5
|
+
mccAccountId: '',
|
|
6
|
+
refreshToken: '',
|
|
7
|
+
};
|
|
8
|
+
/**
|
|
2
9
|
* Shorthand function to get the Google Ads Client.
|
|
3
10
|
* Library: google-ads-api
|
|
4
|
-
*/
|
|
11
|
+
*/
|
|
12
|
+
const initClient = async ({ parameter }) => {
|
|
13
|
+
if (!global.googleAdsClient.instance) {
|
|
14
|
+
const { GoogleAdsApi } = require('google-ads-api');
|
|
15
|
+
// Create a new client instance
|
|
16
|
+
global.googleAdsClient.instance = new GoogleAdsApi({
|
|
17
|
+
client_id: parameter.clientId,
|
|
18
|
+
client_secret: parameter.clientSecret,
|
|
19
|
+
developer_token: parameter.developerToken,
|
|
20
|
+
});
|
|
21
|
+
global.googleAdsClient.mccAccountId = parameter.mccAccountId;
|
|
22
|
+
global.googleAdsClient.refreshToken = parameter.refreshToken;
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
exports.default = initClient;
|
package/initClients.d.ts
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { Config as AwsConfig } from './aws/getConfig';
|
|
2
|
+
declare type InitClients = {
|
|
3
|
+
athenaExpress?: {
|
|
4
|
+
database: string;
|
|
5
|
+
s3Bucket: string;
|
|
6
|
+
s3Key: string;
|
|
7
|
+
};
|
|
8
|
+
awsConfig?: AwsConfig;
|
|
9
|
+
awsGlue?: boolean;
|
|
10
|
+
awsLambda?: boolean;
|
|
11
|
+
awsS3?: boolean;
|
|
12
|
+
awsSes?: boolean;
|
|
13
|
+
awsSsm?: boolean;
|
|
14
|
+
deepCrawl?: {
|
|
15
|
+
parameterName: string;
|
|
16
|
+
};
|
|
17
|
+
eskimi?: boolean;
|
|
18
|
+
googleAds?: {
|
|
19
|
+
parameterName: string;
|
|
20
|
+
};
|
|
21
|
+
googleBigQuery?: {
|
|
22
|
+
projectId: string;
|
|
23
|
+
};
|
|
24
|
+
googleConfig?: {
|
|
25
|
+
parameterName: string;
|
|
26
|
+
};
|
|
27
|
+
googleSheets?: boolean;
|
|
28
|
+
googleStorage?: {
|
|
29
|
+
projectId: string;
|
|
30
|
+
};
|
|
31
|
+
prisma?: {
|
|
32
|
+
debug?: boolean;
|
|
33
|
+
};
|
|
34
|
+
myTarget?: boolean;
|
|
35
|
+
};
|
|
36
|
+
/**
|
|
37
|
+
* Function to simplify initialising the clients.
|
|
38
|
+
*/
|
|
39
|
+
declare const initClients: ({ athenaExpress, awsConfig, awsGlue, awsS3, awsSes, awsSsm, deepCrawl, googleAds, googleConfig, googleBigQuery, googleSheets, googleStorage, prisma, }: InitClients) => Promise<void>;
|
|
40
|
+
export default initClients;
|