@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
|
@@ -1,109 +1,69 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
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.AwsLambdaNamespace = void 0;
|
|
37
|
-
const _class_1 = require("../../_class");
|
|
38
|
-
const server_1 = require("../server");
|
|
39
|
-
const api_1 = require("../../api");
|
|
40
|
-
class AwsLambdaNamespace extends _class_1.BaseNamespace {
|
|
41
|
-
constructor() {
|
|
42
|
-
super(...arguments);
|
|
43
|
-
this.ensureInit = async () => {
|
|
44
|
-
if (!this.client) {
|
|
45
|
-
try {
|
|
46
|
-
const { LambdaClient } = await Promise.resolve().then(() => __importStar(require("@aws-sdk/client-lambda")));
|
|
47
|
-
this.client = new LambdaClient(this.config);
|
|
48
|
-
}
|
|
49
|
-
catch (e) {
|
|
50
|
-
throw new Error("AWS Lambda Client not installed");
|
|
51
|
-
}
|
|
1
|
+
import { BaseNamespace } from "../../_class";
|
|
2
|
+
import { isResponse200 } from "../server";
|
|
3
|
+
import { ApiResponseClass } from "../../api";
|
|
4
|
+
export class AwsLambdaNamespace extends BaseNamespace {
|
|
5
|
+
ensureInit = async () => {
|
|
6
|
+
if (!this.client) {
|
|
7
|
+
try {
|
|
8
|
+
const { LambdaClient } = await import("@aws-sdk/client-lambda");
|
|
9
|
+
this.client = new LambdaClient(this.config);
|
|
52
10
|
}
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
* Invoke a AWS Lambda function by passing in the Function name and optional Payload data.
|
|
56
|
-
* Runs asynchronously, doesn't wait for function to fully end.
|
|
57
|
-
* Library: @aws-sdk/client-lambda
|
|
58
|
-
*/
|
|
59
|
-
this.invoke = async (props) => {
|
|
60
|
-
await this.ensureInit();
|
|
61
|
-
const { InvokeCommand } = await Promise.resolve().then(() => __importStar(require("@aws-sdk/client-lambda")));
|
|
62
|
-
let response = false;
|
|
63
|
-
const params = {
|
|
64
|
-
FunctionName: props.functionName,
|
|
65
|
-
InvocationType: true === props.awaitResponse ? "RequestResponse" : "Event",
|
|
66
|
-
};
|
|
67
|
-
// Payload is defined add to parameters
|
|
68
|
-
if (undefined !== props.payload) {
|
|
69
|
-
params["Payload"] = new Uint8Array(Buffer.from(JSON.stringify(props.payload)));
|
|
11
|
+
catch (e) {
|
|
12
|
+
throw new Error("AWS Lambda Client not installed");
|
|
70
13
|
}
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
14
|
+
}
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* Invoke a AWS Lambda function by passing in the Function name and optional Payload data.
|
|
18
|
+
* Runs asynchronously, doesn't wait for function to fully end.
|
|
19
|
+
* Library: @aws-sdk/client-lambda
|
|
20
|
+
*/
|
|
21
|
+
invoke = async (props) => {
|
|
22
|
+
await this.ensureInit();
|
|
23
|
+
const { InvokeCommand } = await import("@aws-sdk/client-lambda");
|
|
24
|
+
let response = false;
|
|
25
|
+
const params = {
|
|
26
|
+
FunctionName: props.functionName,
|
|
27
|
+
InvocationType: true === props.awaitResponse ? "RequestResponse" : "Event",
|
|
28
|
+
};
|
|
29
|
+
// Payload is defined add to parameters
|
|
30
|
+
if (undefined !== props.payload) {
|
|
31
|
+
params["Payload"] = new Uint8Array(Buffer.from(JSON.stringify(props.payload)));
|
|
32
|
+
}
|
|
33
|
+
// Create the Lambda Command
|
|
34
|
+
// @ts-ignore
|
|
35
|
+
const command = new InvokeCommand(params);
|
|
36
|
+
// Fire the event but don't wait for it to complete
|
|
37
|
+
const apiResponse = await this.client.send(command);
|
|
38
|
+
// Success
|
|
39
|
+
if (isResponse200(apiResponse)) {
|
|
40
|
+
// Return the data
|
|
41
|
+
if (props.awaitResponse && undefined !== apiResponse.Payload) {
|
|
42
|
+
const asciiDecoder = new TextDecoder("ascii");
|
|
43
|
+
response = asciiDecoder.decode(apiResponse.Payload);
|
|
44
|
+
// Decode string as JSON object
|
|
45
|
+
if (true === props.isJson) {
|
|
46
|
+
response = JSON.parse(response);
|
|
47
|
+
// If it's still a string, double decode it
|
|
48
|
+
if ("string" === typeof response) {
|
|
84
49
|
response = JSON.parse(response);
|
|
85
|
-
// If it's still a string, double decode it
|
|
86
|
-
if ("string" === typeof response) {
|
|
87
|
-
response = JSON.parse(response);
|
|
88
|
-
}
|
|
89
|
-
// If the response is a ApiResponse compatible
|
|
90
|
-
if (undefined !== response &&
|
|
91
|
-
// @ts-ignore
|
|
92
|
-
undefined !== response?.error &&
|
|
93
|
-
// @ts-ignore
|
|
94
|
-
undefined !== response?.state) {
|
|
95
|
-
// @ts-ignore
|
|
96
|
-
response = (new api_1.ApiResponseClass()).fromJson(response);
|
|
97
|
-
}
|
|
98
50
|
}
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
51
|
+
// If the response is a ApiResponse compatible
|
|
52
|
+
if (undefined !== response &&
|
|
53
|
+
// @ts-ignore
|
|
54
|
+
undefined !== response?.error &&
|
|
55
|
+
// @ts-ignore
|
|
56
|
+
undefined !== response?.state) {
|
|
57
|
+
// @ts-ignore
|
|
58
|
+
response = (new ApiResponseClass()).fromJson(response);
|
|
59
|
+
}
|
|
103
60
|
}
|
|
104
61
|
}
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
62
|
+
// Success but not waiting for response
|
|
63
|
+
else {
|
|
64
|
+
response = true;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
return response;
|
|
68
|
+
};
|
|
108
69
|
}
|
|
109
|
-
exports.AwsLambdaNamespace = AwsLambdaNamespace;
|
package/aws/lambda/server.js
CHANGED
|
@@ -1,21 +1,16 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.getHandlerPath = exports.awsLambdaClient = void 0;
|
|
4
|
-
const AwsLambdaNamespace_1 = require("./AwsLambdaNamespace");
|
|
5
|
-
const server_1 = require("../server");
|
|
1
|
+
import { AwsLambdaNamespace } from "./AwsLambdaNamespace";
|
|
2
|
+
import { getConfig } from "../server";
|
|
6
3
|
const awsLambdaNamespaces = new Map();
|
|
7
|
-
const awsLambdaClient = async (key = "default", config, vaultId, itemId) => {
|
|
4
|
+
export const awsLambdaClient = async (key = "default", config, vaultId, itemId) => {
|
|
8
5
|
if (awsLambdaNamespaces.has(key)) {
|
|
9
6
|
return awsLambdaNamespaces.get(key);
|
|
10
7
|
}
|
|
11
|
-
const instanceConfig = await
|
|
12
|
-
const namespace = new
|
|
8
|
+
const instanceConfig = await getConfig(key, config, vaultId, itemId);
|
|
9
|
+
const namespace = new AwsLambdaNamespace(key, instanceConfig);
|
|
13
10
|
awsLambdaNamespaces.set(key, namespace);
|
|
14
11
|
return namespace;
|
|
15
12
|
};
|
|
16
|
-
|
|
17
|
-
const getHandlerPath = (input) => {
|
|
13
|
+
export const getHandlerPath = (input) => {
|
|
18
14
|
return `${input.split(process.cwd())[1].substring(1)
|
|
19
15
|
.replace(/\\/g, "/")}`;
|
|
20
16
|
};
|
|
21
|
-
exports.getHandlerPath = getHandlerPath;
|