@8ms/helpers 2.4.10 → 2.4.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/dist/_class/BaseClass.cjs +31 -21
- package/dist/_class/BaseClass.mjs +31 -21
- package/dist/_class/BaseNamespace.cjs +10 -9
- package/dist/_class/BaseNamespace.mjs +10 -9
- package/dist/_virtual/_rolldown/runtime.cjs +1 -1
- package/dist/_virtual/_rolldown/runtime.mjs +1 -1
- package/dist/api/ApiResponseClass.cjs +96 -96
- package/dist/api/ApiResponseClass.mjs +96 -96
- package/dist/aws/cloudWatchLog/server/AwsCloudWatchLogNamespace.cjs +70 -60
- package/dist/aws/cloudWatchLog/server/AwsCloudWatchLogNamespace.mjs +70 -60
- package/dist/aws/cloudWatchMetric/server/AwsCloudWatchMetricNamespace.cjs +30 -28
- package/dist/aws/cloudWatchMetric/server/AwsCloudWatchMetricNamespace.mjs +30 -28
- package/dist/aws/ec2/server/AwsEc2Namespace.cjs +29 -32
- package/dist/aws/ec2/server/AwsEc2Namespace.mjs +29 -32
- package/dist/aws/ecs/server/AwsEcsNamespace.cjs +92 -78
- package/dist/aws/ecs/server/AwsEcsNamespace.mjs +92 -78
- package/dist/aws/glue/server/AwsGlueNamespace.cjs +17 -17
- package/dist/aws/glue/server/AwsGlueNamespace.mjs +17 -17
- package/dist/aws/lambda/server/AwsLambdaNamespace.cjs +33 -31
- package/dist/aws/lambda/server/AwsLambdaNamespace.mjs +33 -31
- package/dist/aws/s3/server/AwsS3Namespace.cjs +280 -265
- package/dist/aws/s3/server/AwsS3Namespace.mjs +280 -265
- package/dist/aws/ses/server/AwsSesNamespace.cjs +27 -30
- package/dist/aws/ses/server/AwsSesNamespace.mjs +27 -30
- package/dist/aws/ses/server/SimpleEmail.cjs +202 -199
- package/dist/aws/ses/server/SimpleEmail.mjs +202 -199
- package/dist/aws/sqs/server/AwsSqsNamespace.cjs +35 -38
- package/dist/aws/sqs/server/AwsSqsNamespace.mjs +35 -38
- package/dist/aws/ssm/server/AwsSsmNamespace.cjs +24 -23
- package/dist/aws/ssm/server/AwsSsmNamespace.mjs +24 -23
- package/dist/date/index.cjs +1 -1
- package/dist/date/index.mjs +1 -1
- package/dist/drizzle/server/DrizzleNamespace.cjs +39 -42
- package/dist/drizzle/server/DrizzleNamespace.d.cts +1 -0
- package/dist/drizzle/server/DrizzleNamespace.mjs +39 -42
- package/dist/googleAds/server/GoogleAdsNamespace.cjs +21 -24
- package/dist/googleAds/server/GoogleAdsNamespace.mjs +21 -24
- package/dist/googleCloud/bigquery/server/GoogleCloudBigqueryNamespace.cjs +87 -70
- package/dist/googleCloud/bigquery/server/GoogleCloudBigqueryNamespace.mjs +87 -70
- package/dist/googleCloud/sheets/server/GoogleCloudSheetsNamespace.cjs +22 -25
- package/dist/googleCloud/sheets/server/GoogleCloudSheetsNamespace.mjs +22 -25
- package/dist/googleCloud/storage/server/GoogleCloudStorageNamespace.cjs +45 -38
- package/dist/googleCloud/storage/server/GoogleCloudStorageNamespace.mjs +45 -38
- package/dist/googlePageSpeed/server/GooglePageSpeedNamespace.cjs +12 -15
- package/dist/googlePageSpeed/server/GooglePageSpeedNamespace.mjs +12 -15
- package/dist/littleWarden/server/LittleWardenNamespace.cjs +12 -15
- package/dist/littleWarden/server/LittleWardenNamespace.mjs +12 -15
- package/dist/nextJs/client/index.cjs +2 -0
- package/dist/nextJs/client/index.d.cts +2 -1
- package/dist/nextJs/client/index.d.mts +2 -1
- package/dist/nextJs/client/index.mjs +2 -1
- package/dist/nextJs/client/useAsyncEffect.cjs +23 -0
- package/dist/nextJs/client/useAsyncEffect.d.cts +4 -0
- package/dist/nextJs/client/useAsyncEffect.d.mts +4 -0
- package/dist/nextJs/client/useAsyncEffect.mjs +21 -0
- package/dist/onePassword/server/OnePasswordNamespace.cjs +30 -33
- package/dist/onePassword/server/OnePasswordNamespace.mjs +30 -33
- package/dist/openAi/server/OpenAiNamespace.cjs +20 -20
- package/dist/openAi/server/OpenAiNamespace.mjs +20 -20
- package/dist/prisma/server/PrismaNamespace.cjs +35 -38
- package/dist/prisma/server/PrismaNamespace.mjs +35 -38
- package/dist/snapchat/server/SnapchatNamespace.cjs +12 -12
- package/dist/snapchat/server/SnapchatNamespace.mjs +12 -12
- package/dist/upTimeRobot/server/UpTimeRobotNamespace.cjs +19 -19
- package/dist/upTimeRobot/server/UpTimeRobotNamespace.mjs +19 -19
- package/package.json +4 -12
- package/dist/nextJs/index.cjs +0 -4
- package/dist/nextJs/index.d.cts +0 -2
- package/dist/nextJs/index.d.mts +0 -2
- package/dist/nextJs/index.mjs +0 -2
- package/dist/nextJs/nextJs.cjs +0 -13
- package/dist/nextJs/nextJs.d.cts +0 -19
- package/dist/nextJs/nextJs.d.mts +0 -19
- package/dist/nextJs/nextJs.mjs +0 -11
- package/dist/nextJs/tests/getIp.cjs +0 -9
- package/dist/nextJs/tests/getIp.d.cts +0 -1
- package/dist/nextJs/tests/getIp.d.mts +0 -1
- package/dist/nextJs/tests/getIp.mjs +0 -10
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
require("../../_virtual/_rolldown/runtime.cjs");
|
|
3
|
+
let react = require("react");
|
|
4
|
+
//#region src/nextJs/client/useAsyncEffect.ts
|
|
5
|
+
const useAsyncEffect = (effect, destroy, inputs) => {
|
|
6
|
+
const hasDestroy = typeof destroy === "function";
|
|
7
|
+
(0, react.useEffect)(function() {
|
|
8
|
+
let result;
|
|
9
|
+
let mounted = true;
|
|
10
|
+
let maybePromise = effect(function() {
|
|
11
|
+
return mounted;
|
|
12
|
+
});
|
|
13
|
+
Promise.resolve(maybePromise).then(function(value) {
|
|
14
|
+
result = value;
|
|
15
|
+
});
|
|
16
|
+
return function() {
|
|
17
|
+
mounted = false;
|
|
18
|
+
if (hasDestroy) destroy(result);
|
|
19
|
+
};
|
|
20
|
+
}, hasDestroy ? inputs : destroy);
|
|
21
|
+
};
|
|
22
|
+
//#endregion
|
|
23
|
+
exports.useAsyncEffect = useAsyncEffect;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { useEffect } from "react";
|
|
2
|
+
//#region src/nextJs/client/useAsyncEffect.ts
|
|
3
|
+
const useAsyncEffect = (effect, destroy, inputs) => {
|
|
4
|
+
const hasDestroy = typeof destroy === "function";
|
|
5
|
+
useEffect(function() {
|
|
6
|
+
let result;
|
|
7
|
+
let mounted = true;
|
|
8
|
+
let maybePromise = effect(function() {
|
|
9
|
+
return mounted;
|
|
10
|
+
});
|
|
11
|
+
Promise.resolve(maybePromise).then(function(value) {
|
|
12
|
+
result = value;
|
|
13
|
+
});
|
|
14
|
+
return function() {
|
|
15
|
+
mounted = false;
|
|
16
|
+
if (hasDestroy) destroy(result);
|
|
17
|
+
};
|
|
18
|
+
}, hasDestroy ? inputs : destroy);
|
|
19
|
+
};
|
|
20
|
+
//#endregion
|
|
21
|
+
export { useAsyncEffect };
|
|
@@ -2,39 +2,36 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
|
2
2
|
const require__class_BaseNamespace = require("../../_class/BaseNamespace.cjs");
|
|
3
3
|
//#region src/onePassword/server/OnePasswordNamespace.ts
|
|
4
4
|
var OnePasswordNamespace = class extends require__class_BaseNamespace.BaseNamespace {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
this.
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
this.
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
this.
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
this.
|
|
34
|
-
|
|
35
|
-
return this.client.items.list(vaultId);
|
|
36
|
-
};
|
|
37
|
-
}
|
|
5
|
+
ensureInit = async () => {
|
|
6
|
+
if (!this.client) try {
|
|
7
|
+
const { createClient } = await import("@1password/sdk");
|
|
8
|
+
this.client = await createClient({
|
|
9
|
+
auth: this.config.serviceAccountToken,
|
|
10
|
+
integrationName: this.config.integrationName || "8MS Helper TS",
|
|
11
|
+
integrationVersion: this.config.integrationVersion || "v1.0.0"
|
|
12
|
+
});
|
|
13
|
+
} catch (e) {
|
|
14
|
+
throw new Error("1Password SDK not installed");
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
listVaults = async () => {
|
|
18
|
+
await this.ensureInit();
|
|
19
|
+
return this.client.vaults.list();
|
|
20
|
+
};
|
|
21
|
+
getItem = async (vaultId, itemId) => {
|
|
22
|
+
await this.ensureInit();
|
|
23
|
+
return this.client.items.get(vaultId, itemId);
|
|
24
|
+
};
|
|
25
|
+
getJsonNote = async (vaultId, itemId) => {
|
|
26
|
+
let response = null;
|
|
27
|
+
const item = await this.getItem(vaultId, itemId);
|
|
28
|
+
if (item && "undefined" !== typeof item.notes) response = JSON.parse(item.notes);
|
|
29
|
+
return response;
|
|
30
|
+
};
|
|
31
|
+
listItems = async (vaultId) => {
|
|
32
|
+
await this.ensureInit();
|
|
33
|
+
return this.client.items.list(vaultId);
|
|
34
|
+
};
|
|
38
35
|
};
|
|
39
36
|
//#endregion
|
|
40
37
|
exports.OnePasswordNamespace = OnePasswordNamespace;
|
|
@@ -1,39 +1,36 @@
|
|
|
1
1
|
import { BaseNamespace } from "../../_class/BaseNamespace.mjs";
|
|
2
2
|
//#region src/onePassword/server/OnePasswordNamespace.ts
|
|
3
3
|
var OnePasswordNamespace = class extends BaseNamespace {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
this.
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
this.
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
this.
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
this.
|
|
33
|
-
|
|
34
|
-
return this.client.items.list(vaultId);
|
|
35
|
-
};
|
|
36
|
-
}
|
|
4
|
+
ensureInit = async () => {
|
|
5
|
+
if (!this.client) try {
|
|
6
|
+
const { createClient } = await import("@1password/sdk");
|
|
7
|
+
this.client = await createClient({
|
|
8
|
+
auth: this.config.serviceAccountToken,
|
|
9
|
+
integrationName: this.config.integrationName || "8MS Helper TS",
|
|
10
|
+
integrationVersion: this.config.integrationVersion || "v1.0.0"
|
|
11
|
+
});
|
|
12
|
+
} catch (e) {
|
|
13
|
+
throw new Error("1Password SDK not installed");
|
|
14
|
+
}
|
|
15
|
+
};
|
|
16
|
+
listVaults = async () => {
|
|
17
|
+
await this.ensureInit();
|
|
18
|
+
return this.client.vaults.list();
|
|
19
|
+
};
|
|
20
|
+
getItem = async (vaultId, itemId) => {
|
|
21
|
+
await this.ensureInit();
|
|
22
|
+
return this.client.items.get(vaultId, itemId);
|
|
23
|
+
};
|
|
24
|
+
getJsonNote = async (vaultId, itemId) => {
|
|
25
|
+
let response = null;
|
|
26
|
+
const item = await this.getItem(vaultId, itemId);
|
|
27
|
+
if (item && "undefined" !== typeof item.notes) response = JSON.parse(item.notes);
|
|
28
|
+
return response;
|
|
29
|
+
};
|
|
30
|
+
listItems = async (vaultId) => {
|
|
31
|
+
await this.ensureInit();
|
|
32
|
+
return this.client.items.list(vaultId);
|
|
33
|
+
};
|
|
37
34
|
};
|
|
38
35
|
//#endregion
|
|
39
36
|
export { OnePasswordNamespace };
|
|
@@ -3,26 +3,26 @@ const require__class_BaseNamespace = require("../../_class/BaseNamespace.cjs");
|
|
|
3
3
|
const require_api_post = require("../../api/post.cjs");
|
|
4
4
|
//#region src/openAi/server/OpenAiNamespace.ts
|
|
5
5
|
var OpenAiNamespace = class extends require__class_BaseNamespace.BaseNamespace {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
}
|
|
6
|
+
/**
|
|
7
|
+
* Renew the access token as it expires every 3 hours.
|
|
8
|
+
*/
|
|
9
|
+
ensureInit = async () => {
|
|
10
|
+
if (!this.client) this.client = true;
|
|
11
|
+
};
|
|
12
|
+
completion = async (prompt, temperature = 1, maxTokens = null, model = "gpt-3.5-turbo") => {
|
|
13
|
+
let response = null;
|
|
14
|
+
const apiResponse = await require_api_post.post(`https://api.openai.com/v1/chat/completions`, {
|
|
15
|
+
max_tokens: maxTokens,
|
|
16
|
+
model,
|
|
17
|
+
messages: [{
|
|
18
|
+
role: "user",
|
|
19
|
+
content: prompt
|
|
20
|
+
}],
|
|
21
|
+
temperature: 1
|
|
22
|
+
}, { headers: { Authorization: `Bearer ${this.config.apiKey}` } });
|
|
23
|
+
if (apiResponse.isSuccess()) response = apiResponse.getBody();
|
|
24
|
+
return response;
|
|
25
|
+
};
|
|
26
26
|
};
|
|
27
27
|
//#endregion
|
|
28
28
|
exports.OpenAiNamespace = OpenAiNamespace;
|
|
@@ -2,26 +2,26 @@ import { BaseNamespace } from "../../_class/BaseNamespace.mjs";
|
|
|
2
2
|
import { post } from "../../api/post.mjs";
|
|
3
3
|
//#region src/openAi/server/OpenAiNamespace.ts
|
|
4
4
|
var OpenAiNamespace = class extends BaseNamespace {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
}
|
|
5
|
+
/**
|
|
6
|
+
* Renew the access token as it expires every 3 hours.
|
|
7
|
+
*/
|
|
8
|
+
ensureInit = async () => {
|
|
9
|
+
if (!this.client) this.client = true;
|
|
10
|
+
};
|
|
11
|
+
completion = async (prompt, temperature = 1, maxTokens = null, model = "gpt-3.5-turbo") => {
|
|
12
|
+
let response = null;
|
|
13
|
+
const apiResponse = await post(`https://api.openai.com/v1/chat/completions`, {
|
|
14
|
+
max_tokens: maxTokens,
|
|
15
|
+
model,
|
|
16
|
+
messages: [{
|
|
17
|
+
role: "user",
|
|
18
|
+
content: prompt
|
|
19
|
+
}],
|
|
20
|
+
temperature: 1
|
|
21
|
+
}, { headers: { Authorization: `Bearer ${this.config.apiKey}` } });
|
|
22
|
+
if (apiResponse.isSuccess()) response = apiResponse.getBody();
|
|
23
|
+
return response;
|
|
24
|
+
};
|
|
25
25
|
};
|
|
26
26
|
//#endregion
|
|
27
27
|
export { OpenAiNamespace };
|
|
@@ -3,45 +3,42 @@ const require_util_getError = require("../../util/getError.cjs");
|
|
|
3
3
|
const require__class_BaseNamespace = require("../../_class/BaseNamespace.cjs");
|
|
4
4
|
//#region src/prisma/server/PrismaNamespace.ts
|
|
5
5
|
var PrismaNamespace = class extends require__class_BaseNamespace.BaseNamespace {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
if (
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
} catch (e) {
|
|
15
|
-
throw new Error(`PlanetScale adapter not installed - ${require_util_getError.getError(e)}`);
|
|
16
|
-
}
|
|
17
|
-
if (this.config.isMysql) try {
|
|
18
|
-
const { PrismaMariaDb } = await import("@prisma/adapter-mariadb");
|
|
19
|
-
adapter = new PrismaMariaDb(this.config.url);
|
|
20
|
-
} catch (e) {
|
|
21
|
-
throw new Error(`MariaDB adapter not installed - ${require_util_getError.getError(e)}`);
|
|
22
|
-
}
|
|
23
|
-
if (this.config.isPostgres) try {
|
|
24
|
-
const { PrismaPg } = await import("@prisma/adapter-pg");
|
|
25
|
-
adapter = new PrismaPg({ connectionString: process.env.DATABASE_URL });
|
|
26
|
-
} catch (e) {
|
|
27
|
-
throw new Error(`Postgres adapter not installed - ${require_util_getError.getError(e)}`);
|
|
28
|
-
}
|
|
29
|
-
try {
|
|
30
|
-
const { PrismaClient } = await import("@prisma/client");
|
|
31
|
-
if (this.config.isDebug) this.client = new PrismaClient({
|
|
32
|
-
adapter,
|
|
33
|
-
log: [{
|
|
34
|
-
emit: "event",
|
|
35
|
-
level: "query"
|
|
36
|
-
}]
|
|
37
|
-
});
|
|
38
|
-
else this.client = new PrismaClient({ adapter });
|
|
39
|
-
} catch (e) {
|
|
40
|
-
throw new Error(`Prisma Client not installed - ${require_util_getError.getError(e)}`);
|
|
41
|
-
}
|
|
6
|
+
ensureInit = async () => {
|
|
7
|
+
if (!this.client) {
|
|
8
|
+
let adapter = null;
|
|
9
|
+
if (this.config.isPlanetScale) try {
|
|
10
|
+
const { PrismaPlanetScale } = await import("@prisma/adapter-planetscale");
|
|
11
|
+
adapter = new PrismaPlanetScale({ url: this.config.url });
|
|
12
|
+
} catch (e) {
|
|
13
|
+
throw new Error(`PlanetScale adapter not installed - ${require_util_getError.getError(e)}`);
|
|
42
14
|
}
|
|
43
|
-
|
|
44
|
-
|
|
15
|
+
if (this.config.isMysql) try {
|
|
16
|
+
const { PrismaMariaDb } = await import("@prisma/adapter-mariadb");
|
|
17
|
+
adapter = new PrismaMariaDb(this.config.url);
|
|
18
|
+
} catch (e) {
|
|
19
|
+
throw new Error(`MariaDB adapter not installed - ${require_util_getError.getError(e)}`);
|
|
20
|
+
}
|
|
21
|
+
if (this.config.isPostgres) try {
|
|
22
|
+
const { PrismaPg } = await import("@prisma/adapter-pg");
|
|
23
|
+
adapter = new PrismaPg({ connectionString: process.env.DATABASE_URL });
|
|
24
|
+
} catch (e) {
|
|
25
|
+
throw new Error(`Postgres adapter not installed - ${require_util_getError.getError(e)}`);
|
|
26
|
+
}
|
|
27
|
+
try {
|
|
28
|
+
const { PrismaClient } = await import("@prisma/client");
|
|
29
|
+
if (this.config.isDebug) this.client = new PrismaClient({
|
|
30
|
+
adapter,
|
|
31
|
+
log: [{
|
|
32
|
+
emit: "event",
|
|
33
|
+
level: "query"
|
|
34
|
+
}]
|
|
35
|
+
});
|
|
36
|
+
else this.client = new PrismaClient({ adapter });
|
|
37
|
+
} catch (e) {
|
|
38
|
+
throw new Error(`Prisma Client not installed - ${require_util_getError.getError(e)}`);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
};
|
|
45
42
|
};
|
|
46
43
|
//#endregion
|
|
47
44
|
exports.PrismaNamespace = PrismaNamespace;
|
|
@@ -2,45 +2,42 @@ import { getError } from "../../util/getError.mjs";
|
|
|
2
2
|
import { BaseNamespace } from "../../_class/BaseNamespace.mjs";
|
|
3
3
|
//#region src/prisma/server/PrismaNamespace.ts
|
|
4
4
|
var PrismaNamespace = class extends BaseNamespace {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
if (
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
} catch (e) {
|
|
14
|
-
throw new Error(`PlanetScale adapter not installed - ${getError(e)}`);
|
|
15
|
-
}
|
|
16
|
-
if (this.config.isMysql) try {
|
|
17
|
-
const { PrismaMariaDb } = await import("@prisma/adapter-mariadb");
|
|
18
|
-
adapter = new PrismaMariaDb(this.config.url);
|
|
19
|
-
} catch (e) {
|
|
20
|
-
throw new Error(`MariaDB adapter not installed - ${getError(e)}`);
|
|
21
|
-
}
|
|
22
|
-
if (this.config.isPostgres) try {
|
|
23
|
-
const { PrismaPg } = await import("@prisma/adapter-pg");
|
|
24
|
-
adapter = new PrismaPg({ connectionString: process.env.DATABASE_URL });
|
|
25
|
-
} catch (e) {
|
|
26
|
-
throw new Error(`Postgres adapter not installed - ${getError(e)}`);
|
|
27
|
-
}
|
|
28
|
-
try {
|
|
29
|
-
const { PrismaClient } = await import("@prisma/client");
|
|
30
|
-
if (this.config.isDebug) this.client = new PrismaClient({
|
|
31
|
-
adapter,
|
|
32
|
-
log: [{
|
|
33
|
-
emit: "event",
|
|
34
|
-
level: "query"
|
|
35
|
-
}]
|
|
36
|
-
});
|
|
37
|
-
else this.client = new PrismaClient({ adapter });
|
|
38
|
-
} catch (e) {
|
|
39
|
-
throw new Error(`Prisma Client not installed - ${getError(e)}`);
|
|
40
|
-
}
|
|
5
|
+
ensureInit = async () => {
|
|
6
|
+
if (!this.client) {
|
|
7
|
+
let adapter = null;
|
|
8
|
+
if (this.config.isPlanetScale) try {
|
|
9
|
+
const { PrismaPlanetScale } = await import("@prisma/adapter-planetscale");
|
|
10
|
+
adapter = new PrismaPlanetScale({ url: this.config.url });
|
|
11
|
+
} catch (e) {
|
|
12
|
+
throw new Error(`PlanetScale adapter not installed - ${getError(e)}`);
|
|
41
13
|
}
|
|
42
|
-
|
|
43
|
-
|
|
14
|
+
if (this.config.isMysql) try {
|
|
15
|
+
const { PrismaMariaDb } = await import("@prisma/adapter-mariadb");
|
|
16
|
+
adapter = new PrismaMariaDb(this.config.url);
|
|
17
|
+
} catch (e) {
|
|
18
|
+
throw new Error(`MariaDB adapter not installed - ${getError(e)}`);
|
|
19
|
+
}
|
|
20
|
+
if (this.config.isPostgres) try {
|
|
21
|
+
const { PrismaPg } = await import("@prisma/adapter-pg");
|
|
22
|
+
adapter = new PrismaPg({ connectionString: process.env.DATABASE_URL });
|
|
23
|
+
} catch (e) {
|
|
24
|
+
throw new Error(`Postgres adapter not installed - ${getError(e)}`);
|
|
25
|
+
}
|
|
26
|
+
try {
|
|
27
|
+
const { PrismaClient } = await import("@prisma/client");
|
|
28
|
+
if (this.config.isDebug) this.client = new PrismaClient({
|
|
29
|
+
adapter,
|
|
30
|
+
log: [{
|
|
31
|
+
emit: "event",
|
|
32
|
+
level: "query"
|
|
33
|
+
}]
|
|
34
|
+
});
|
|
35
|
+
else this.client = new PrismaClient({ adapter });
|
|
36
|
+
} catch (e) {
|
|
37
|
+
throw new Error(`Prisma Client not installed - ${getError(e)}`);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
};
|
|
44
41
|
};
|
|
45
42
|
//#endregion
|
|
46
43
|
export { PrismaNamespace };
|
|
@@ -5,18 +5,18 @@ const require_api_post = require("../../api/post.cjs");
|
|
|
5
5
|
let luxon = require("luxon");
|
|
6
6
|
//#region src/snapchat/server/SnapchatNamespace.ts
|
|
7
7
|
var SnapchatNamespace = class extends require__class_BaseNamespace.BaseNamespace {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
}
|
|
8
|
+
/**
|
|
9
|
+
* Renew the access token as it expires every 3 hours.
|
|
10
|
+
*/
|
|
11
|
+
ensureInit = async () => {
|
|
12
|
+
if (!this.client) {
|
|
13
|
+
const apiResponse = await require_api_post.post(`https://accounts.snapchat.com/login/oauth2/access_token?client_id=${this.config.clientId}&client_secret=${this.config.clientSecret}&grant_type=refresh_token&refresh_token=${this.config.refreshToken}`);
|
|
14
|
+
if (apiResponse.isSuccess()) this.client = {
|
|
15
|
+
expires: luxon.DateTime.now().toUnixInteger() + 10800 * 1e3,
|
|
16
|
+
refreshToken: apiResponse.getBodyDefaultTo(["data", "access_token"], null)
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
20
|
};
|
|
21
21
|
//#endregion
|
|
22
22
|
exports.SnapchatNamespace = SnapchatNamespace;
|
|
@@ -3,18 +3,18 @@ import { post } from "../../api/post.mjs";
|
|
|
3
3
|
import { DateTime } from "luxon";
|
|
4
4
|
//#region src/snapchat/server/SnapchatNamespace.ts
|
|
5
5
|
var SnapchatNamespace = class extends BaseNamespace {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
}
|
|
6
|
+
/**
|
|
7
|
+
* Renew the access token as it expires every 3 hours.
|
|
8
|
+
*/
|
|
9
|
+
ensureInit = async () => {
|
|
10
|
+
if (!this.client) {
|
|
11
|
+
const apiResponse = await post(`https://accounts.snapchat.com/login/oauth2/access_token?client_id=${this.config.clientId}&client_secret=${this.config.clientSecret}&grant_type=refresh_token&refresh_token=${this.config.refreshToken}`);
|
|
12
|
+
if (apiResponse.isSuccess()) this.client = {
|
|
13
|
+
expires: DateTime.now().toUnixInteger() + 10800 * 1e3,
|
|
14
|
+
refreshToken: apiResponse.getBodyDefaultTo(["data", "access_token"], null)
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
18
|
};
|
|
19
19
|
//#endregion
|
|
20
20
|
export { SnapchatNamespace };
|
|
@@ -7,25 +7,25 @@ const require_api_post = require("../../api/post.cjs");
|
|
|
7
7
|
* https://uptimerobot.com/api/
|
|
8
8
|
*/
|
|
9
9
|
var UpTimeRobotNamespace = class extends require__class_BaseNamespace.BaseNamespace {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
}
|
|
10
|
+
/**
|
|
11
|
+
* Renew the access token as it expires every 3 hours.
|
|
12
|
+
*/
|
|
13
|
+
ensureInit = async () => {
|
|
14
|
+
if (!this.client) this.client = true;
|
|
15
|
+
};
|
|
16
|
+
getReport = async (props) => {
|
|
17
|
+
let response = null;
|
|
18
|
+
let finalParams = {};
|
|
19
|
+
if (void 0 !== props) {
|
|
20
|
+
finalParams = { ...props };
|
|
21
|
+
if (void 0 !== props.monitors && Array.isArray(props.monitors)) finalParams["monitors"] = props.monitors.join("-");
|
|
22
|
+
if (void 0 !== props.statuses && Array.isArray(props.statuses)) finalParams["statuses"] = props.statuses.join("-");
|
|
23
|
+
if (void 0 !== props.types && Array.isArray(props.types)) finalParams["types"] = props.types.join("-");
|
|
24
|
+
}
|
|
25
|
+
const apiResponse = await require_api_post.post(`https://api.uptimerobot.com/v2/getMonitors?api_key=${this.config.apiKey}`, finalParams);
|
|
26
|
+
if (apiResponse.isSuccess()) response = apiResponse.getBody();
|
|
27
|
+
return response;
|
|
28
|
+
};
|
|
29
29
|
};
|
|
30
30
|
//#endregion
|
|
31
31
|
exports.UpTimeRobotNamespace = UpTimeRobotNamespace;
|
|
@@ -6,25 +6,25 @@ import { post } from "../../api/post.mjs";
|
|
|
6
6
|
* https://uptimerobot.com/api/
|
|
7
7
|
*/
|
|
8
8
|
var UpTimeRobotNamespace = class extends BaseNamespace {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
}
|
|
9
|
+
/**
|
|
10
|
+
* Renew the access token as it expires every 3 hours.
|
|
11
|
+
*/
|
|
12
|
+
ensureInit = async () => {
|
|
13
|
+
if (!this.client) this.client = true;
|
|
14
|
+
};
|
|
15
|
+
getReport = async (props) => {
|
|
16
|
+
let response = null;
|
|
17
|
+
let finalParams = {};
|
|
18
|
+
if (void 0 !== props) {
|
|
19
|
+
finalParams = { ...props };
|
|
20
|
+
if (void 0 !== props.monitors && Array.isArray(props.monitors)) finalParams["monitors"] = props.monitors.join("-");
|
|
21
|
+
if (void 0 !== props.statuses && Array.isArray(props.statuses)) finalParams["statuses"] = props.statuses.join("-");
|
|
22
|
+
if (void 0 !== props.types && Array.isArray(props.types)) finalParams["types"] = props.types.join("-");
|
|
23
|
+
}
|
|
24
|
+
const apiResponse = await post(`https://api.uptimerobot.com/v2/getMonitors?api_key=${this.config.apiKey}`, finalParams);
|
|
25
|
+
if (apiResponse.isSuccess()) response = apiResponse.getBody();
|
|
26
|
+
return response;
|
|
27
|
+
};
|
|
28
28
|
};
|
|
29
29
|
//#endregion
|
|
30
30
|
export { UpTimeRobotNamespace };
|