@8ms/helpers 2.3.40 → 2.3.42
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/aws/cloudWatchLog/server/index.d.mts +5 -8
- package/dist/aws/cloudWatchLog/server/index.mjs +5 -4
- package/dist/aws/cloudWatchMetric/server/index.d.mts +1 -1
- package/dist/aws/cloudWatchMetric/server/index.mjs +3 -2
- package/dist/aws/s3/server/index.mjs +2 -2
- package/dist/axios/index.mjs +4 -4
- package/dist/url/server/index.mjs +2 -2
- package/package.json +1 -1
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { t as BaseNamespace } from "../../../index-DwB8X1lz.mjs";
|
|
2
|
+
import { X as InputDate } from "../../../index-1fBbJGQz.mjs";
|
|
2
3
|
import { t as AwsConfig } from "../../../index-CqTOMR8f.mjs";
|
|
3
4
|
import * as _aws_sdk_client_cloudwatch_logs0 from "@aws-sdk/client-cloudwatch-logs";
|
|
4
5
|
import { CloudWatchLogsClient } from "@aws-sdk/client-cloudwatch-logs";
|
|
@@ -11,12 +12,8 @@ declare const logLevel: {
|
|
|
11
12
|
};
|
|
12
13
|
type LogLevel = typeof logLevel[keyof typeof logLevel];
|
|
13
14
|
type LogEvent = {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
app: string;
|
|
17
|
-
environment: string;
|
|
18
|
-
stream: string;
|
|
19
|
-
data: object;
|
|
15
|
+
timestamp: InputDate;
|
|
16
|
+
event: string | object;
|
|
20
17
|
};
|
|
21
18
|
//#endregion
|
|
22
19
|
//#region src/aws/cloudWatchLog/server/AwsCloudWatchLogNamespace.d.ts
|
|
@@ -41,8 +38,8 @@ declare class AwsCloudWatchLogNamespace extends BaseNamespace {
|
|
|
41
38
|
* Checks whether a CloudWatch Log Stream exists within a given Log Group.
|
|
42
39
|
*/
|
|
43
40
|
logStreamExists: (logGroupName: string, logStreamName: string) => Promise<boolean>;
|
|
44
|
-
|
|
45
|
-
|
|
41
|
+
logEvent: (logGroupName: string, logStreamName: string, logEvent: LogEvent) => Promise<_aws_sdk_client_cloudwatch_logs0.PutLogEventsCommandOutput>;
|
|
42
|
+
logEvents: (logGroupName: string, logStreamName: string, logEvents: LogEvent[]) => Promise<_aws_sdk_client_cloudwatch_logs0.PutLogEventsCommandOutput>;
|
|
46
43
|
}
|
|
47
44
|
//#endregion
|
|
48
45
|
//#region src/aws/cloudWatchLog/server/awsCloudWatchLog.d.ts
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { BaseNamespace } from "../../../_class/index.mjs";
|
|
2
|
+
import { getLuxonDate } from "../../../date/index.mjs";
|
|
2
3
|
import { t as getConfig } from "../../../server-Bwy4JI8Z.mjs";
|
|
3
4
|
|
|
4
5
|
//#region src/aws/cloudWatchLog/server/AwsCloudWatchLogNamespace.ts
|
|
@@ -58,17 +59,17 @@ var AwsCloudWatchLogNamespace = class extends BaseNamespace {
|
|
|
58
59
|
if (!response?.logStreams || 0 === response.logStreams.length) return false;
|
|
59
60
|
return true;
|
|
60
61
|
};
|
|
61
|
-
|
|
62
|
-
return await this.
|
|
62
|
+
logEvent = async (logGroupName, logStreamName, logEvent) => {
|
|
63
|
+
return await this.logEvents(logGroupName, logStreamName, [logEvent]);
|
|
63
64
|
};
|
|
64
|
-
|
|
65
|
+
logEvents = async (logGroupName, logStreamName, logEvents) => {
|
|
65
66
|
await this.ensureInit();
|
|
66
67
|
const { PutLogEventsCommand } = await import("@aws-sdk/client-cloudwatch-logs");
|
|
67
68
|
return await this.client.send(new PutLogEventsCommand({
|
|
68
69
|
logGroupName,
|
|
69
70
|
logStreamName,
|
|
70
71
|
logEvents: logEvents.map((event) => ({
|
|
71
|
-
timestamp: event.
|
|
72
|
+
timestamp: getLuxonDate(event.timestamp).toUnixInteger(),
|
|
72
73
|
message: typeof event === "string" ? event : JSON.stringify(event)
|
|
73
74
|
}))
|
|
74
75
|
}));
|
|
@@ -26,7 +26,7 @@ declare class AwsCloudWatchMetricNamespace extends BaseNamespace {
|
|
|
26
26
|
* The namespace is created automatically.
|
|
27
27
|
* Dimensions should contain additional info (but top level).
|
|
28
28
|
*/
|
|
29
|
-
|
|
29
|
+
logMetric: (namespace: string, metricData: LogMetric | LogMetric[]) => Promise<_aws_sdk_client_cloudwatch0.PutMetricDataCommandOutput>;
|
|
30
30
|
}
|
|
31
31
|
//#endregion
|
|
32
32
|
//#region src/aws/cloudWatchMetric/server/awsCloudWatchMetric.d.ts
|
|
@@ -2,6 +2,7 @@ import { getArray } from "../../../array/index.mjs";
|
|
|
2
2
|
import { BaseNamespace } from "../../../_class/index.mjs";
|
|
3
3
|
import { getLuxonDate } from "../../../date/index.mjs";
|
|
4
4
|
import { t as getConfig } from "../../../server-Bwy4JI8Z.mjs";
|
|
5
|
+
import { StandardUnit } from "@aws-sdk/client-cloudwatch";
|
|
5
6
|
|
|
6
7
|
//#region src/aws/cloudWatchMetric/server/AwsCloudWatchMetricNamespace.ts
|
|
7
8
|
var AwsCloudWatchMetricNamespace = class extends BaseNamespace {
|
|
@@ -18,7 +19,7 @@ var AwsCloudWatchMetricNamespace = class extends BaseNamespace {
|
|
|
18
19
|
* The namespace is created automatically.
|
|
19
20
|
* Dimensions should contain additional info (but top level).
|
|
20
21
|
*/
|
|
21
|
-
|
|
22
|
+
logMetric = async (namespace, metricData) => {
|
|
22
23
|
await this.ensureInit();
|
|
23
24
|
const { PutMetricDataCommand } = await import("@aws-sdk/client-cloudwatch");
|
|
24
25
|
const data = getArray(metricData);
|
|
@@ -27,7 +28,7 @@ var AwsCloudWatchMetricNamespace = class extends BaseNamespace {
|
|
|
27
28
|
MetricData: data.map((metric) => ({
|
|
28
29
|
MetricName: metric.metricName,
|
|
29
30
|
Value: metric.value,
|
|
30
|
-
Unit: metric.
|
|
31
|
+
Unit: metric?.unit || StandardUnit.Count,
|
|
31
32
|
Timestamp: getLuxonDate(metric.timestamp).toJSDate(),
|
|
32
33
|
Dimensions: metric.dimensions?.map((dimension) => ({
|
|
33
34
|
Name: dimension.name,
|
|
@@ -4,7 +4,7 @@ import { getFolder, getStringFromStream } from "../../../string/index.mjs";
|
|
|
4
4
|
import { n as isResponse200, t as getConfig } from "../../../server-Bwy4JI8Z.mjs";
|
|
5
5
|
import { getBrotliCompressed, getBrotliDecompressed, getGzipCompressed, getGzipDecompressed } from "../../../util/server/index.mjs";
|
|
6
6
|
import { z } from "zod/v4";
|
|
7
|
-
import
|
|
7
|
+
import get from "axios";
|
|
8
8
|
|
|
9
9
|
//#region src/aws/s3/server/AwsS3Namespace.ts
|
|
10
10
|
var AwsS3Namespace = class extends BaseNamespace {
|
|
@@ -293,7 +293,7 @@ var AwsS3Namespace = class extends BaseNamespace {
|
|
|
293
293
|
*/
|
|
294
294
|
urlContents = async (bucket, key, url) => {
|
|
295
295
|
await this.ensureInit();
|
|
296
|
-
return
|
|
296
|
+
return get(url, {
|
|
297
297
|
responseType: "arraybuffer",
|
|
298
298
|
responseEncoding: "binary"
|
|
299
299
|
}).then(async (response) => {
|
package/dist/axios/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { u as ApiResponseClass } from "../api-DGKJDAfb.mjs";
|
|
2
|
-
import
|
|
2
|
+
import get$1 from "axios";
|
|
3
3
|
|
|
4
4
|
//#region src/axios/deleteRequest.ts
|
|
5
5
|
/**
|
|
@@ -7,7 +7,7 @@ import axios from "axios";
|
|
|
7
7
|
* Can't use the function name delete as it's reserved
|
|
8
8
|
*/
|
|
9
9
|
const deleteRequest = async (url, config = {}) => {
|
|
10
|
-
return await
|
|
10
|
+
return await get$1.delete(url, config).then(async (response) => {
|
|
11
11
|
if (void 0 !== response.data.body && void 0 !== response.data.error && void 0 !== response.data.state) return new ApiResponseClass(response.data);
|
|
12
12
|
else if (response.status >= 200 && response.status <= 299) return new ApiResponseClass().setToSuccess(response.data);
|
|
13
13
|
return new ApiResponseClass().setToError(response.data, response.statusText);
|
|
@@ -22,7 +22,7 @@ const deleteRequest = async (url, config = {}) => {
|
|
|
22
22
|
* Make a GET request.
|
|
23
23
|
*/
|
|
24
24
|
const get = async (url, config = {}) => {
|
|
25
|
-
return await
|
|
25
|
+
return await get$1.get(url, config).then(async (response) => {
|
|
26
26
|
if (void 0 !== response.data.body && void 0 !== response.data.error && void 0 !== response.data.state) return new ApiResponseClass(response.data);
|
|
27
27
|
else if (response.status >= 200 && response.status <= 299) return new ApiResponseClass().setToSuccess(response.data);
|
|
28
28
|
return new ApiResponseClass().setToError(response.data, response.statusText);
|
|
@@ -37,7 +37,7 @@ const get = async (url, config = {}) => {
|
|
|
37
37
|
* Make a POST request.
|
|
38
38
|
*/
|
|
39
39
|
const post = async (url, data = {}, config = {}) => {
|
|
40
|
-
return await
|
|
40
|
+
return await get$1.post(url, data, config).then(async (response) => {
|
|
41
41
|
if (void 0 !== response.data.body && void 0 !== response.data.error && void 0 !== response.data.state) return new ApiResponseClass(response.data);
|
|
42
42
|
else if (response.status >= 200 && response.status <= 299) return new ApiResponseClass().setToSuccess(response.data);
|
|
43
43
|
return new ApiResponseClass().setToError(response.data, response.statusText);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createDirectory } from "../../file/server/index.mjs";
|
|
2
|
-
import
|
|
2
|
+
import get from "axios";
|
|
3
3
|
|
|
4
4
|
//#region src/url/server/writeUrlContents.ts
|
|
5
5
|
/**
|
|
@@ -11,7 +11,7 @@ const writeUrlContents = async (filePath, url) => {
|
|
|
11
11
|
const fs = await import("fs-extra");
|
|
12
12
|
await createDirectory(filePath);
|
|
13
13
|
const writer = fs.createWriteStream(filePath);
|
|
14
|
-
await
|
|
14
|
+
await get({
|
|
15
15
|
method: "get",
|
|
16
16
|
url,
|
|
17
17
|
responseType: "stream"
|