@8ms/helpers 2.3.24 → 2.3.26
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/package.json +118 -189
- package/.github/workflows/deploy_npmjs.yml +0 -41
- package/.yarn/install-state.gz +0 -0
- package/.yarn/releases/yarn-4.12.0.cjs +0 -942
- package/.yarnrc.yml +0 -2
- package/dist/_class/index.d.mts +0 -2
- package/dist/_class/index.mjs +0 -61
- package/dist/adverity/index.d.mts +0 -2
- package/dist/adverity/index.mjs +0 -64
- package/dist/adverity/server/index.d.mts +0 -18
- package/dist/adverity/server/index.mjs +0 -25
- package/dist/api/index.d.mts +0 -2
- package/dist/api/index.mjs +0 -3
- package/dist/api-DGKJDAfb.mjs +0 -139
- package/dist/array/index.d.mts +0 -11
- package/dist/array/index.mjs +0 -12
- package/dist/atInternet/index.d.mts +0 -20
- package/dist/atInternet/index.mjs +0 -18
- package/dist/aws/ec2/server/index.d.mts +0 -18
- package/dist/aws/ec2/server/index.mjs +0 -48
- package/dist/aws/ecs/server/index.d.mts +0 -59
- package/dist/aws/ecs/server/index.mjs +0 -113
- package/dist/aws/glue/server/index.d.mts +0 -19
- package/dist/aws/glue/server/index.mjs +0 -36
- package/dist/aws/lambda/server/index.d.mts +0 -28
- package/dist/aws/lambda/server/index.mjs +0 -57
- package/dist/aws/s3/server/index.d.mts +0 -124
- package/dist/aws/s3/server/index.mjs +0 -360
- package/dist/aws/server/index.d.mts +0 -2
- package/dist/aws/server/index.mjs +0 -3
- package/dist/aws/ses/server/index.d.mts +0 -105
- package/dist/aws/ses/server/index.mjs +0 -268
- package/dist/aws/sqs/server/index.d.mts +0 -41
- package/dist/aws/sqs/server/index.mjs +0 -56
- package/dist/aws/ssm/server/index.d.mts +0 -18
- package/dist/aws/ssm/server/index.mjs +0 -47
- package/dist/axios/index.d.mts +0 -22
- package/dist/axios/index.mjs +0 -50
- package/dist/boolean/index.d.mts +0 -7
- package/dist/boolean/index.mjs +0 -13
- package/dist/brightData/serpApi/server/index.d.mts +0 -93
- package/dist/brightData/serpApi/server/index.mjs +0 -229
- package/dist/brightData/server/index.d.mts +0 -2
- package/dist/brightData/server/index.mjs +0 -18
- package/dist/brightData/webScraperIde/server/index.d.mts +0 -19
- package/dist/brightData/webScraperIde/server/index.mjs +0 -50
- package/dist/cache/server/index.d.mts +0 -10
- package/dist/cache/server/index.mjs +0 -31
- package/dist/chunk-DDarj8oW.mjs +0 -7
- package/dist/crud/index.d.mts +0 -10
- package/dist/crud/index.mjs +0 -10
- package/dist/crypto/index.d.mts +0 -25
- package/dist/crypto/index.mjs +0 -57
- package/dist/date/index.d.mts +0 -2
- package/dist/date/index.mjs +0 -471
- package/dist/drizzle/server/index.d.mts +0 -22
- package/dist/drizzle/server/index.mjs +0 -69
- package/dist/environment/index.d.mts +0 -37
- package/dist/environment/index.mjs +0 -60
- package/dist/eskimi/index.d.mts +0 -52
- package/dist/eskimi/index.mjs +0 -90
- package/dist/eskimi/server/index.d.mts +0 -25
- package/dist/eskimi/server/index.mjs +0 -50
- package/dist/file/index.d.mts +0 -7
- package/dist/file/index.mjs +0 -20
- package/dist/file/server/index.d.mts +0 -8
- package/dist/file/server/index.mjs +0 -16
- package/dist/geo/index.d.mts +0 -26
- package/dist/geo/index.mjs +0 -1591
- package/dist/getDecimal-CafxtLhH.mjs +0 -40
- package/dist/googleAds/keywordPlanner/server/index.d.mts +0 -45
- package/dist/googleAds/keywordPlanner/server/index.mjs +0 -51
- package/dist/googleAds/server/index.d.mts +0 -27
- package/dist/googleAds/server/index.mjs +0 -48
- package/dist/googleCloud/bigquery/server/index.d.mts +0 -82
- package/dist/googleCloud/bigquery/server/index.mjs +0 -133
- package/dist/googleCloud/server/index.d.mts +0 -2
- package/dist/googleCloud/server/index.mjs +0 -24
- package/dist/googleCloud/sheets/server/index.d.mts +0 -22
- package/dist/googleCloud/sheets/server/index.mjs +0 -31
- package/dist/googleCloud/storage/server/index.d.mts +0 -31
- package/dist/googleCloud/storage/server/index.mjs +0 -79
- package/dist/googlePageSpeed/server/index.d.mts +0 -34
- package/dist/googlePageSpeed/server/index.mjs +0 -53
- package/dist/googleSearchIncidents/server/index.d.mts +0 -73
- package/dist/googleSearchIncidents/server/index.mjs +0 -55
- package/dist/greenDomain/server/index.d.mts +0 -25
- package/dist/greenDomain/server/index.mjs +0 -31
- package/dist/index-1fBbJGQz.d.mts +0 -246
- package/dist/index-BHuvb_7y.d.mts +0 -116
- package/dist/index-BfyGIdDD.d.mts +0 -18
- package/dist/index-CqTOMR8f.d.mts +0 -17
- package/dist/index-DW9yJLtI.d.mts +0 -67
- package/dist/index-DmCSxHCc.d.mts +0 -32
- package/dist/index-DwB8X1lz.d.mts +0 -32
- package/dist/inngest/index.d.mts +0 -10
- package/dist/inngest/index.mjs +0 -10
- package/dist/json/index.d.mts +0 -7
- package/dist/json/index.mjs +0 -27
- package/dist/littleWarden/server/index.d.mts +0 -56
- package/dist/littleWarden/server/index.mjs +0 -79
- package/dist/lodash/index.d.mts +0 -45
- package/dist/lodash/index.mjs +0 -176
- package/dist/lumar/api/server/index.d.mts +0 -66
- package/dist/lumar/api/server/index.mjs +0 -111
- package/dist/lumar/graphql/server/index.d.mts +0 -308
- package/dist/lumar/graphql/server/index.mjs +0 -172
- package/dist/myTarget/server/index.d.mts +0 -9
- package/dist/myTarget/server/index.mjs +0 -16
- package/dist/nextAuth/index.d.mts +0 -12
- package/dist/nextAuth/index.mjs +0 -15
- package/dist/nextJs/client/index.d.mts +0 -10
- package/dist/nextJs/client/index.mjs +0 -12
- package/dist/nextJs/index.d.mts +0 -19
- package/dist/nextJs/index.mjs +0 -12
- package/dist/number/index.d.mts +0 -54
- package/dist/number/index.mjs +0 -75
- package/dist/object/index.d.mts +0 -8
- package/dist/object/index.mjs +0 -22
- package/dist/onePassword/server/index.d.mts +0 -24
- package/dist/onePassword/server/index.mjs +0 -50
- package/dist/openAi/server/index.d.mts +0 -20
- package/dist/openAi/server/index.mjs +0 -46
- package/dist/prisma/index.d.mts +0 -7
- package/dist/prisma/index.mjs +0 -15
- package/dist/prisma/server/index.d.mts +0 -31
- package/dist/prisma/server/index.mjs +0 -64
- package/dist/server-Bwy4JI8Z.mjs +0 -33
- package/dist/snapchat/server/index.d.mts +0 -25
- package/dist/snapchat/server/index.mjs +0 -39
- package/dist/sorting/index.d.mts +0 -25
- package/dist/sorting/index.mjs +0 -50
- package/dist/stream/server/index.d.mts +0 -15
- package/dist/stream/server/index.mjs +0 -48
- package/dist/string/index.d.mts +0 -107
- package/dist/string/index.mjs +0 -187
- package/dist/swr/client/index.d.mts +0 -46
- package/dist/swr/client/index.mjs +0 -40
- package/dist/upTimeRobot/server/index.d.mts +0 -72
- package/dist/upTimeRobot/server/index.mjs +0 -82
- package/dist/url/index.d.mts +0 -29
- package/dist/url/index.mjs +0 -52
- package/dist/url/server/index.d.mts +0 -9
- package/dist/url/server/index.mjs +0 -35
- package/dist/util/index.d.mts +0 -50
- package/dist/util/index.mjs +0 -107
- package/dist/util/server/index.d.mts +0 -27
- package/dist/util/server/index.mjs +0 -61
- package/dist/webWorker/index.d.mts +0 -11
- package/dist/webWorker/index.mjs +0 -11
- package/dist/xml/server/index.d.mts +0 -4
- package/dist/xml/server/index.mjs +0 -17
- package/tsdown.config.ts +0 -11
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import { BaseNamespace } from "../../../_class/index.mjs";
|
|
2
|
-
import { n as isResponse200, t as getConfig } from "../../../server-Bwy4JI8Z.mjs";
|
|
3
|
-
|
|
4
|
-
//#region src/aws/glue/server/AwsGlueNamespace.ts
|
|
5
|
-
var AwsGlueNamespace = class extends BaseNamespace {
|
|
6
|
-
ensureInit = async () => {
|
|
7
|
-
if (!this.client) try {
|
|
8
|
-
const { GlueClient } = await import("@aws-sdk/client-glue");
|
|
9
|
-
this.client = new GlueClient(this.config);
|
|
10
|
-
} catch (e) {
|
|
11
|
-
throw new Error("AWS Glue Client not installed");
|
|
12
|
-
}
|
|
13
|
-
};
|
|
14
|
-
/**
|
|
15
|
-
* Invoke an AWS Glue Crawler by passing in the name of the Crawler.
|
|
16
|
-
*/
|
|
17
|
-
invoke = async (crawler) => {
|
|
18
|
-
await this.ensureInit();
|
|
19
|
-
const { StartCrawlerCommand } = await import("@aws-sdk/client-glue");
|
|
20
|
-
const command = new StartCrawlerCommand({ Name: crawler });
|
|
21
|
-
return isResponse200(await this.client.send(command));
|
|
22
|
-
};
|
|
23
|
-
};
|
|
24
|
-
|
|
25
|
-
//#endregion
|
|
26
|
-
//#region src/aws/glue/server/awsGlue.ts
|
|
27
|
-
const awsGlueNamespaces = /* @__PURE__ */ new Map();
|
|
28
|
-
const awsGlueClient = async (key = "default", config, vaultId, itemId) => {
|
|
29
|
-
if (awsGlueNamespaces.has(key)) return awsGlueNamespaces.get(key);
|
|
30
|
-
const namespace = new AwsGlueNamespace(key, await getConfig(key, config, vaultId, itemId));
|
|
31
|
-
awsGlueNamespaces.set(key, namespace);
|
|
32
|
-
return namespace;
|
|
33
|
-
};
|
|
34
|
-
|
|
35
|
-
//#endregion
|
|
36
|
-
export { AwsGlueNamespace, awsGlueClient };
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { t as BaseNamespace } from "../../../index-DwB8X1lz.mjs";
|
|
2
|
-
import { t as AwsConfig } from "../../../index-CqTOMR8f.mjs";
|
|
3
|
-
import { LambdaClient } from "@aws-sdk/client-lambda";
|
|
4
|
-
|
|
5
|
-
//#region src/aws/lambda/server/AwsLambdaNamespace.d.ts
|
|
6
|
-
type InvokeProps = {
|
|
7
|
-
awaitResponse?: boolean;
|
|
8
|
-
functionName: string;
|
|
9
|
-
isJson?: boolean;
|
|
10
|
-
payload?: object;
|
|
11
|
-
};
|
|
12
|
-
declare class AwsLambdaNamespace extends BaseNamespace {
|
|
13
|
-
client: LambdaClient;
|
|
14
|
-
config: AwsConfig;
|
|
15
|
-
ensureInit: () => Promise<void>;
|
|
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: (props: InvokeProps) => Promise<any>;
|
|
22
|
-
}
|
|
23
|
-
//#endregion
|
|
24
|
-
//#region src/aws/lambda/server/awsLambda.d.ts
|
|
25
|
-
declare const awsLambdaClient: (key?: string, config?: AwsConfig, vaultId?: string, itemId?: string) => Promise<AwsLambdaNamespace>;
|
|
26
|
-
declare const getHandlerPath: (input: string) => string;
|
|
27
|
-
//#endregion
|
|
28
|
-
export { AwsLambdaNamespace, awsLambdaClient, getHandlerPath };
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
import { BaseNamespace } from "../../../_class/index.mjs";
|
|
2
|
-
import { u as ApiResponseClass } from "../../../api-DGKJDAfb.mjs";
|
|
3
|
-
import { n as isResponse200, t as getConfig } from "../../../server-Bwy4JI8Z.mjs";
|
|
4
|
-
|
|
5
|
-
//#region src/aws/lambda/server/AwsLambdaNamespace.ts
|
|
6
|
-
var AwsLambdaNamespace = class extends BaseNamespace {
|
|
7
|
-
ensureInit = async () => {
|
|
8
|
-
if (!this.client) try {
|
|
9
|
-
const { LambdaClient } = await import("@aws-sdk/client-lambda");
|
|
10
|
-
this.client = new LambdaClient(this.config);
|
|
11
|
-
} catch (e) {
|
|
12
|
-
throw new Error("AWS Lambda Client not installed");
|
|
13
|
-
}
|
|
14
|
-
};
|
|
15
|
-
/**
|
|
16
|
-
* Invoke a AWS Lambda function by passing in the Function name and optional Payload data.
|
|
17
|
-
* Runs asynchronously, doesn't wait for function to fully end.
|
|
18
|
-
* Library: @aws-sdk/client-lambda
|
|
19
|
-
*/
|
|
20
|
-
invoke = async (props) => {
|
|
21
|
-
await this.ensureInit();
|
|
22
|
-
const { InvokeCommand } = await import("@aws-sdk/client-lambda");
|
|
23
|
-
let response = false;
|
|
24
|
-
const params = {
|
|
25
|
-
FunctionName: props.functionName,
|
|
26
|
-
InvocationType: true === props.awaitResponse ? "RequestResponse" : "Event"
|
|
27
|
-
};
|
|
28
|
-
if (void 0 !== props.payload) params["Payload"] = new Uint8Array(Buffer.from(JSON.stringify(props.payload)));
|
|
29
|
-
const command = new InvokeCommand(params);
|
|
30
|
-
const apiResponse = await this.client.send(command);
|
|
31
|
-
if (isResponse200(apiResponse)) if (props.awaitResponse && void 0 !== apiResponse.Payload) {
|
|
32
|
-
response = new TextDecoder("ascii").decode(apiResponse.Payload);
|
|
33
|
-
if (true === props.isJson) {
|
|
34
|
-
response = JSON.parse(response);
|
|
35
|
-
if ("string" === typeof response) response = JSON.parse(response);
|
|
36
|
-
if (void 0 !== response && void 0 !== response?.error && void 0 !== response?.state) response = new ApiResponseClass().fromJson(response);
|
|
37
|
-
}
|
|
38
|
-
} else response = true;
|
|
39
|
-
return response;
|
|
40
|
-
};
|
|
41
|
-
};
|
|
42
|
-
|
|
43
|
-
//#endregion
|
|
44
|
-
//#region src/aws/lambda/server/awsLambda.ts
|
|
45
|
-
const awsLambdaNamespaces = /* @__PURE__ */ new Map();
|
|
46
|
-
const awsLambdaClient = async (key = "default", config, vaultId, itemId) => {
|
|
47
|
-
if (awsLambdaNamespaces.has(key)) return awsLambdaNamespaces.get(key);
|
|
48
|
-
const namespace = new AwsLambdaNamespace(key, await getConfig(key, config, vaultId, itemId));
|
|
49
|
-
awsLambdaNamespaces.set(key, namespace);
|
|
50
|
-
return namespace;
|
|
51
|
-
};
|
|
52
|
-
const getHandlerPath = (input) => {
|
|
53
|
-
return `${input.split(process.cwd())[1].substring(1).replace(/\\/g, "/")}`;
|
|
54
|
-
};
|
|
55
|
-
|
|
56
|
-
//#endregion
|
|
57
|
-
export { AwsLambdaNamespace, awsLambdaClient, getHandlerPath };
|
|
@@ -1,124 +0,0 @@
|
|
|
1
|
-
import { t as BaseNamespace } from "../../../index-DwB8X1lz.mjs";
|
|
2
|
-
import { t as AwsConfig } from "../../../index-CqTOMR8f.mjs";
|
|
3
|
-
import { z } from "zod/v4";
|
|
4
|
-
import * as _aws_sdk_client_s30 from "@aws-sdk/client-s3";
|
|
5
|
-
import { S3Client } from "@aws-sdk/client-s3";
|
|
6
|
-
|
|
7
|
-
//#region src/aws/s3/server/AwsS3Namespace.d.ts
|
|
8
|
-
type ReadBufferResponse = Modified & {
|
|
9
|
-
buffer: any;
|
|
10
|
-
};
|
|
11
|
-
type Options = {
|
|
12
|
-
[key: string]: any;
|
|
13
|
-
};
|
|
14
|
-
type WritePresignedPostProps = {
|
|
15
|
-
bucket: string;
|
|
16
|
-
fields: any;
|
|
17
|
-
file: any;
|
|
18
|
-
key: string;
|
|
19
|
-
url: string;
|
|
20
|
-
};
|
|
21
|
-
declare class AwsS3Namespace extends BaseNamespace {
|
|
22
|
-
client: S3Client;
|
|
23
|
-
config: AwsConfig;
|
|
24
|
-
ensureInit: () => Promise<void>;
|
|
25
|
-
copy: (fromBucket: string, fromKey: string, toBucket: string, toKey: string) => Promise<void>;
|
|
26
|
-
deleteFile: (bucket: string, key: string) => Promise<void>;
|
|
27
|
-
deleteFiles: (bucket: string, keys: string[]) => Promise<void>;
|
|
28
|
-
deleteFolder: (bucket: string, folder: string) => Promise<void>;
|
|
29
|
-
/**
|
|
30
|
-
* List the files in the given bucket and option folder
|
|
31
|
-
*/
|
|
32
|
-
listFiles: (bucket: string, folder?: string) => Promise<string[]>;
|
|
33
|
-
/**
|
|
34
|
-
* Fetch all the files within a given directory recursively
|
|
35
|
-
*/
|
|
36
|
-
filesIteratively: (bucket: string, folder: string) => Promise<string[]>;
|
|
37
|
-
/**
|
|
38
|
-
* Sub function
|
|
39
|
-
*/
|
|
40
|
-
private iterateFolders;
|
|
41
|
-
/**
|
|
42
|
-
* List the files in the given bucket and option folder.
|
|
43
|
-
*/
|
|
44
|
-
listFolders: (bucket: string, folder: string) => Promise<string[]>;
|
|
45
|
-
move: (fromBucket: string, fromKey: string, toBucket: string, toKey: string) => Promise<void>;
|
|
46
|
-
readBrotli: (bucket: string, key: string, brotliOptions?: object, awsS3Options?: Options) => Promise<ReadFileResponse>;
|
|
47
|
-
readJsonBrotli: (bucket: string, key: string, brotliOptions?: object, awsS3Options?: Options) => Promise<ReadFileResponse>;
|
|
48
|
-
readBuffer: (bucket: string, key: string) => Promise<ReadBufferResponse>;
|
|
49
|
-
fileExists: (bucket: string, key: string) => Promise<boolean>;
|
|
50
|
-
readFile: (bucket: string, key: string, options?: Options) => Promise<ReadFileResponse>;
|
|
51
|
-
readJson: (bucket: string, key: string) => Promise<ReadFileResponse>;
|
|
52
|
-
readJsonGzip: (bucket: string, key: string, gzipOptions?: object, awsS3Options?: Options) => Promise<ReadFileResponse>;
|
|
53
|
-
readGzip: (bucket: string, key: string, gzipOptions?: object, awsS3Options?: Options) => Promise<ReadFileResponse>;
|
|
54
|
-
writeBrotli: (bucket: string, key: string, data: any, brotliOptions?: object, awsS3Options?: Options) => Promise<_aws_sdk_client_s30.PutObjectCommandOutput>;
|
|
55
|
-
writeFile: (bucket: string, key: string, data: any, options?: Options) => Promise<_aws_sdk_client_s30.PutObjectCommandOutput>;
|
|
56
|
-
writeJson: (bucket: string, key: string, data: any, options?: Options) => Promise<_aws_sdk_client_s30.PutObjectCommandOutput>;
|
|
57
|
-
writeJsonGzip: (bucket: string, key: string, data: any, gzipOptions?: object, awsS3Options?: Options) => Promise<_aws_sdk_client_s30.PutObjectCommandOutput>;
|
|
58
|
-
writeGzip: (bucket: string, key: string, data: any, gzipOptions?: object, awsS3Options?: Options) => Promise<_aws_sdk_client_s30.PutObjectCommandOutput>;
|
|
59
|
-
/**
|
|
60
|
-
* Get a presigned post URL so we can upload directly to S3 via frontend.
|
|
61
|
-
*/
|
|
62
|
-
presignedPost: (props: WritePresignedPostProps) => Promise<null | string>;
|
|
63
|
-
/**
|
|
64
|
-
* Download a file and write to S3.
|
|
65
|
-
*/
|
|
66
|
-
urlContents: (bucket: string, key: string, url: string) => Promise<void>;
|
|
67
|
-
}
|
|
68
|
-
//#endregion
|
|
69
|
-
//#region src/aws/s3/server/awsS3.d.ts
|
|
70
|
-
declare const awsS3Client: (key?: string, config?: AwsConfig, vaultId?: string, itemId?: string) => Promise<AwsS3Namespace>;
|
|
71
|
-
type Modified = {
|
|
72
|
-
now: number;
|
|
73
|
-
modified: string;
|
|
74
|
-
};
|
|
75
|
-
type ReadFileResponse = Modified & {
|
|
76
|
-
body: any;
|
|
77
|
-
error: any;
|
|
78
|
-
};
|
|
79
|
-
declare const readFileDefault: ReadFileResponse;
|
|
80
|
-
//#endregion
|
|
81
|
-
//#region src/aws/s3/server/payload.d.ts
|
|
82
|
-
/**
|
|
83
|
-
* https://docs.aws.amazon.com/AmazonS3/latest/userguide/notification-content-structure.html
|
|
84
|
-
*/
|
|
85
|
-
declare const payloadSchema: z.ZodObject<{
|
|
86
|
-
Records: z.ZodArray<z.ZodObject<{
|
|
87
|
-
eventVersion: z.ZodString;
|
|
88
|
-
eventSource: z.ZodString;
|
|
89
|
-
awsRegion: z.ZodString;
|
|
90
|
-
eventTime: z.ZodString;
|
|
91
|
-
eventName: z.ZodString;
|
|
92
|
-
userIdentity: z.ZodObject<{
|
|
93
|
-
principalId: z.ZodString;
|
|
94
|
-
}, z.core.$strip>;
|
|
95
|
-
requestParameters: z.ZodObject<{
|
|
96
|
-
sourceIPAddress: z.ZodString;
|
|
97
|
-
}, z.core.$strip>;
|
|
98
|
-
responseElements: z.ZodObject<{
|
|
99
|
-
"x-amz-request-id": z.ZodString;
|
|
100
|
-
"x-amz-id-2": z.ZodString;
|
|
101
|
-
}, z.core.$strip>;
|
|
102
|
-
s3: z.ZodObject<{
|
|
103
|
-
s3SchemaVersion: z.ZodString;
|
|
104
|
-
configurationId: z.ZodString;
|
|
105
|
-
bucket: z.ZodObject<{
|
|
106
|
-
name: z.ZodString;
|
|
107
|
-
ownerIdentity: z.ZodObject<{
|
|
108
|
-
principalId: z.ZodString;
|
|
109
|
-
}, z.core.$strip>;
|
|
110
|
-
arn: z.ZodString;
|
|
111
|
-
}, z.core.$strip>;
|
|
112
|
-
object: z.ZodObject<{
|
|
113
|
-
key: z.ZodString;
|
|
114
|
-
size: z.ZodString;
|
|
115
|
-
eTag: z.ZodString;
|
|
116
|
-
versionId: z.ZodOptional<z.ZodString>;
|
|
117
|
-
sequencer: z.ZodString;
|
|
118
|
-
}, z.core.$strip>;
|
|
119
|
-
}, z.core.$strip>;
|
|
120
|
-
}, z.core.$strip>>;
|
|
121
|
-
}, z.core.$strip>;
|
|
122
|
-
type PayloadSchemaType = z.infer<typeof payloadSchema>;
|
|
123
|
-
//#endregion
|
|
124
|
-
export { AwsS3Namespace, Modified, PayloadSchemaType, ReadBufferResponse, ReadFileResponse, awsS3Client, payloadSchema, readFileDefault };
|
|
@@ -1,360 +0,0 @@
|
|
|
1
|
-
import { BaseNamespace } from "../../../_class/index.mjs";
|
|
2
|
-
import { defaultDateTime, getToday, getYmdHisString } from "../../../date/index.mjs";
|
|
3
|
-
import { getFolder, getStringFromStream } from "../../../string/index.mjs";
|
|
4
|
-
import { n as isResponse200, t as getConfig } from "../../../server-Bwy4JI8Z.mjs";
|
|
5
|
-
import { getBrotliCompressed, getBrotliDecompressed, getGzipCompressed, getGzipDecompressed } from "../../../util/server/index.mjs";
|
|
6
|
-
import { z } from "zod/v4";
|
|
7
|
-
import axios from "axios";
|
|
8
|
-
|
|
9
|
-
//#region src/aws/s3/server/AwsS3Namespace.ts
|
|
10
|
-
var AwsS3Namespace = class extends BaseNamespace {
|
|
11
|
-
ensureInit = async () => {
|
|
12
|
-
if (!this.client) try {
|
|
13
|
-
const { S3Client } = await import("@aws-sdk/client-s3");
|
|
14
|
-
this.client = new S3Client(this.config);
|
|
15
|
-
} catch (e) {
|
|
16
|
-
throw new Error("AWS S3 Client not installed");
|
|
17
|
-
}
|
|
18
|
-
};
|
|
19
|
-
copy = async (fromBucket, fromKey, toBucket, toKey) => {
|
|
20
|
-
await this.ensureInit();
|
|
21
|
-
const { CopyObjectCommand } = await import("@aws-sdk/client-s3");
|
|
22
|
-
await this.client.send(new CopyObjectCommand({
|
|
23
|
-
Bucket: toBucket,
|
|
24
|
-
CopySource: encodeURIComponent(`${fromBucket}/${fromKey}`),
|
|
25
|
-
Key: toKey
|
|
26
|
-
}));
|
|
27
|
-
};
|
|
28
|
-
deleteFile = async (bucket, key) => {
|
|
29
|
-
await this.ensureInit();
|
|
30
|
-
const { DeleteObjectCommand } = await import("@aws-sdk/client-s3");
|
|
31
|
-
await this.client.send(new DeleteObjectCommand({
|
|
32
|
-
Bucket: bucket,
|
|
33
|
-
Key: key
|
|
34
|
-
}));
|
|
35
|
-
};
|
|
36
|
-
deleteFiles = async (bucket, keys) => {
|
|
37
|
-
await this.ensureInit();
|
|
38
|
-
const { DeleteObjectsCommand } = await import("@aws-sdk/client-s3");
|
|
39
|
-
await this.client.send(new DeleteObjectsCommand({
|
|
40
|
-
Bucket: bucket,
|
|
41
|
-
Delete: { Objects: keys.map((key) => ({ Key: key })) }
|
|
42
|
-
}));
|
|
43
|
-
};
|
|
44
|
-
deleteFolder = async (bucket, folder) => {
|
|
45
|
-
await this.ensureInit();
|
|
46
|
-
const { ListObjectsV2Command, DeleteObjectsCommand } = await import("@aws-sdk/client-s3");
|
|
47
|
-
const cleanFolder = getFolder(folder);
|
|
48
|
-
const apiResponse = await this.client.send(new ListObjectsV2Command({
|
|
49
|
-
Bucket: bucket,
|
|
50
|
-
Prefix: "" === cleanFolder ? "" : cleanFolder + "/"
|
|
51
|
-
}));
|
|
52
|
-
if (apiResponse.Contents.length === 0) return;
|
|
53
|
-
const keys = apiResponse.Contents.map((file) => ({ Key: file.Key }));
|
|
54
|
-
await this.client.send(new DeleteObjectsCommand({
|
|
55
|
-
Bucket: bucket,
|
|
56
|
-
Delete: { Objects: keys }
|
|
57
|
-
}));
|
|
58
|
-
if (apiResponse.IsTruncated) await this.deleteFolder(bucket, folder);
|
|
59
|
-
};
|
|
60
|
-
/**
|
|
61
|
-
* List the files in the given bucket and option folder
|
|
62
|
-
*/
|
|
63
|
-
listFiles = async (bucket, folder = "") => {
|
|
64
|
-
await this.ensureInit();
|
|
65
|
-
const { ListObjectsV2Command } = await import("@aws-sdk/client-s3");
|
|
66
|
-
const cleanFolder = getFolder(folder);
|
|
67
|
-
let response = [];
|
|
68
|
-
let valid = [];
|
|
69
|
-
const apiResponse = await this.client.send(new ListObjectsV2Command({
|
|
70
|
-
Bucket: bucket,
|
|
71
|
-
Delimiter: "/",
|
|
72
|
-
Prefix: "" === cleanFolder ? "" : cleanFolder + "/"
|
|
73
|
-
}));
|
|
74
|
-
if (void 0 !== apiResponse["Contents"]) {
|
|
75
|
-
valid = apiResponse["Contents"].filter((content) => {
|
|
76
|
-
const keyExploded = content["Key"].split("/");
|
|
77
|
-
return keyExploded[keyExploded.length - 1].indexOf(".") > -1;
|
|
78
|
-
});
|
|
79
|
-
if (valid.length) response = valid.map((entry) => entry["Key"]);
|
|
80
|
-
}
|
|
81
|
-
return response;
|
|
82
|
-
};
|
|
83
|
-
/**
|
|
84
|
-
* Fetch all the files within a given directory recursively
|
|
85
|
-
*/
|
|
86
|
-
filesIteratively = async (bucket, folder) => {
|
|
87
|
-
await this.ensureInit();
|
|
88
|
-
return await this.iterateFolders(bucket, folder);
|
|
89
|
-
};
|
|
90
|
-
/**
|
|
91
|
-
* Sub function
|
|
92
|
-
*/
|
|
93
|
-
iterateFolders = async (bucket, folder) => {
|
|
94
|
-
let response = [];
|
|
95
|
-
const folders = await this.listFolders(bucket, folder);
|
|
96
|
-
for (let i = 0; i < folders.length; i++) {
|
|
97
|
-
const subFolderFiles = await this.listFolders(bucket, `${folder}/${folders[i]}`);
|
|
98
|
-
const files = await this.listFiles(bucket, `${folder}/${folders[i]}`);
|
|
99
|
-
response = [
|
|
100
|
-
...response,
|
|
101
|
-
...files,
|
|
102
|
-
...subFolderFiles
|
|
103
|
-
];
|
|
104
|
-
}
|
|
105
|
-
return response;
|
|
106
|
-
};
|
|
107
|
-
/**
|
|
108
|
-
* List the files in the given bucket and option folder.
|
|
109
|
-
*/
|
|
110
|
-
listFolders = async (bucket, folder) => {
|
|
111
|
-
await this.ensureInit();
|
|
112
|
-
const { ListObjectsV2Command } = await import("@aws-sdk/client-s3");
|
|
113
|
-
const cleanFolder = getFolder(folder);
|
|
114
|
-
let response = [];
|
|
115
|
-
const apiResponse = await this.client.send(new ListObjectsV2Command({
|
|
116
|
-
Bucket: bucket,
|
|
117
|
-
Delimiter: "/",
|
|
118
|
-
Prefix: "" === cleanFolder ? "" : cleanFolder + "/"
|
|
119
|
-
}));
|
|
120
|
-
if (void 0 !== apiResponse["CommonPrefixes"]) response = apiResponse["CommonPrefixes"].map((prefix) => {
|
|
121
|
-
const fileFolders = prefix.Prefix.slice(0, -1).split("/");
|
|
122
|
-
return fileFolders[fileFolders.length - 1];
|
|
123
|
-
});
|
|
124
|
-
return response;
|
|
125
|
-
};
|
|
126
|
-
move = async (fromBucket, fromKey, toBucket, toKey) => {
|
|
127
|
-
await this.ensureInit();
|
|
128
|
-
const { CopyObjectCommand, DeleteObjectCommand } = await import("@aws-sdk/client-s3");
|
|
129
|
-
await this.client.send(new CopyObjectCommand({
|
|
130
|
-
Bucket: toBucket,
|
|
131
|
-
CopySource: encodeURIComponent(`${fromBucket}/${fromKey}`),
|
|
132
|
-
Key: toKey
|
|
133
|
-
}));
|
|
134
|
-
await this.client.send(new DeleteObjectCommand({
|
|
135
|
-
Bucket: fromBucket,
|
|
136
|
-
Key: fromKey
|
|
137
|
-
}));
|
|
138
|
-
};
|
|
139
|
-
readBrotli = async (bucket, key, brotliOptions = {}, awsS3Options = {}) => {
|
|
140
|
-
await this.ensureInit();
|
|
141
|
-
const apiResponse = await this.readFile(bucket, key, awsS3Options);
|
|
142
|
-
if (void 0 !== apiResponse.body) apiResponse.body = await getBrotliDecompressed(apiResponse.body, brotliOptions);
|
|
143
|
-
return apiResponse;
|
|
144
|
-
};
|
|
145
|
-
readJsonBrotli = async (bucket, key, brotliOptions = {}, awsS3Options = {}) => {
|
|
146
|
-
await this.ensureInit();
|
|
147
|
-
const apiResponse = await this.readFile(bucket, key, awsS3Options);
|
|
148
|
-
if (void 0 !== apiResponse.body) {
|
|
149
|
-
apiResponse.body = await getBrotliDecompressed(apiResponse.body, brotliOptions);
|
|
150
|
-
apiResponse.body = JSON.parse(apiResponse.body) || null;
|
|
151
|
-
}
|
|
152
|
-
return apiResponse;
|
|
153
|
-
};
|
|
154
|
-
readBuffer = async (bucket, key) => {
|
|
155
|
-
await this.ensureInit();
|
|
156
|
-
const { GetObjectCommand } = await import("@aws-sdk/client-s3");
|
|
157
|
-
let response = {
|
|
158
|
-
...readFileDefault,
|
|
159
|
-
buffer: void 0
|
|
160
|
-
};
|
|
161
|
-
const apiResponse = await this.client.send(new GetObjectCommand({
|
|
162
|
-
Bucket: bucket,
|
|
163
|
-
Key: key
|
|
164
|
-
}));
|
|
165
|
-
if (isResponse200(apiResponse)) {
|
|
166
|
-
const chunks = [];
|
|
167
|
-
response.buffer = await new Promise((resolve, reject) => {
|
|
168
|
-
apiResponse.Body.on("data", (chunk) => chunks.push(chunk));
|
|
169
|
-
apiResponse.Body.on("error", (err) => reject(err));
|
|
170
|
-
apiResponse.Body.on("end", () => resolve(Buffer.concat(chunks)));
|
|
171
|
-
});
|
|
172
|
-
} else throw new Error("Error reading file.");
|
|
173
|
-
return response;
|
|
174
|
-
};
|
|
175
|
-
fileExists = async (bucket, key) => {
|
|
176
|
-
await this.ensureInit();
|
|
177
|
-
let response = false;
|
|
178
|
-
try {
|
|
179
|
-
const { HeadObjectCommand } = await import("@aws-sdk/client-s3");
|
|
180
|
-
response = isResponse200(await this.client.send(new HeadObjectCommand({
|
|
181
|
-
Bucket: bucket,
|
|
182
|
-
Key: key
|
|
183
|
-
})));
|
|
184
|
-
} catch (exception) {
|
|
185
|
-
response = false;
|
|
186
|
-
}
|
|
187
|
-
return response;
|
|
188
|
-
};
|
|
189
|
-
readFile = async (bucket, key, options = {}) => {
|
|
190
|
-
await this.ensureInit();
|
|
191
|
-
let response = structuredClone(readFileDefault);
|
|
192
|
-
const today = getToday();
|
|
193
|
-
getToday(true);
|
|
194
|
-
try {
|
|
195
|
-
response.now = today.toUnixInteger();
|
|
196
|
-
const { GetObjectCommand } = await import("@aws-sdk/client-s3");
|
|
197
|
-
const apiResponse = await this.client.send(new GetObjectCommand({
|
|
198
|
-
Bucket: bucket,
|
|
199
|
-
Key: key,
|
|
200
|
-
...options
|
|
201
|
-
}));
|
|
202
|
-
if (isResponse200(apiResponse)) {
|
|
203
|
-
response.modified = getYmdHisString(apiResponse.LastModified);
|
|
204
|
-
response.body = await getStringFromStream(apiResponse.Body);
|
|
205
|
-
}
|
|
206
|
-
} catch (error) {
|
|
207
|
-
response.body = null;
|
|
208
|
-
response.error = error;
|
|
209
|
-
}
|
|
210
|
-
return response;
|
|
211
|
-
};
|
|
212
|
-
readJson = async (bucket, key) => {
|
|
213
|
-
await this.ensureInit();
|
|
214
|
-
const apiResponse = await this.readFile(bucket, key);
|
|
215
|
-
apiResponse.body = JSON.parse(apiResponse.body) || null;
|
|
216
|
-
return apiResponse;
|
|
217
|
-
};
|
|
218
|
-
readJsonGzip = async (bucket, key, gzipOptions = {}, awsS3Options = {}) => {
|
|
219
|
-
await this.ensureInit();
|
|
220
|
-
const apiResponse = await this.readFile(bucket, key, awsS3Options);
|
|
221
|
-
if (void 0 !== apiResponse.body) {
|
|
222
|
-
apiResponse.body = await getGzipDecompressed(apiResponse.body, gzipOptions);
|
|
223
|
-
apiResponse.body = JSON.parse(apiResponse.body) || null;
|
|
224
|
-
}
|
|
225
|
-
return apiResponse;
|
|
226
|
-
};
|
|
227
|
-
readGzip = async (bucket, key, gzipOptions = {}, awsS3Options = {}) => {
|
|
228
|
-
await this.ensureInit();
|
|
229
|
-
const apiResponse = await this.readFile(bucket, key, awsS3Options);
|
|
230
|
-
if (void 0 !== apiResponse.body) apiResponse.body = await getGzipDecompressed(apiResponse.body, gzipOptions);
|
|
231
|
-
return apiResponse;
|
|
232
|
-
};
|
|
233
|
-
writeBrotli = async (bucket, key, data, brotliOptions = {}, awsS3Options = {}) => {
|
|
234
|
-
await this.ensureInit();
|
|
235
|
-
let finalData = data;
|
|
236
|
-
finalData = await getBrotliCompressed(finalData, brotliOptions);
|
|
237
|
-
return await this.writeFile(bucket, key, finalData, awsS3Options);
|
|
238
|
-
};
|
|
239
|
-
writeFile = async (bucket, key, data, options = {}) => {
|
|
240
|
-
await this.ensureInit();
|
|
241
|
-
const { PutObjectCommand } = await import("@aws-sdk/client-s3");
|
|
242
|
-
return await this.client.send(new PutObjectCommand({
|
|
243
|
-
Bucket: bucket,
|
|
244
|
-
Body: data,
|
|
245
|
-
Key: key,
|
|
246
|
-
...options
|
|
247
|
-
}));
|
|
248
|
-
};
|
|
249
|
-
writeJson = async (bucket, key, data, options = {}) => {
|
|
250
|
-
await this.ensureInit();
|
|
251
|
-
return await this.writeFile(bucket, key, JSON.stringify(data), options);
|
|
252
|
-
};
|
|
253
|
-
writeJsonGzip = async (bucket, key, data, gzipOptions = {}, awsS3Options = {}) => {
|
|
254
|
-
await this.ensureInit();
|
|
255
|
-
let finalData = JSON.stringify(data);
|
|
256
|
-
finalData = await getGzipCompressed(finalData, gzipOptions);
|
|
257
|
-
return await this.writeFile(bucket, key, finalData, awsS3Options);
|
|
258
|
-
};
|
|
259
|
-
writeGzip = async (bucket, key, data, gzipOptions = {}, awsS3Options = {}) => {
|
|
260
|
-
await this.ensureInit();
|
|
261
|
-
let finalData = data;
|
|
262
|
-
finalData = await getGzipCompressed(finalData, gzipOptions);
|
|
263
|
-
return await this.writeFile(bucket, key, finalData, awsS3Options);
|
|
264
|
-
};
|
|
265
|
-
/**
|
|
266
|
-
* Get a presigned post URL so we can upload directly to S3 via frontend.
|
|
267
|
-
*/
|
|
268
|
-
presignedPost = async (props) => {
|
|
269
|
-
await this.ensureInit();
|
|
270
|
-
return new Promise(async (resolve, reject) => {
|
|
271
|
-
let response = null;
|
|
272
|
-
const formData = new FormData();
|
|
273
|
-
Object.entries({
|
|
274
|
-
fields: props.fields,
|
|
275
|
-
file: props.file
|
|
276
|
-
}).forEach(([key, value]) => {
|
|
277
|
-
formData.append(key, value);
|
|
278
|
-
});
|
|
279
|
-
if ((await fetch(props.url, {
|
|
280
|
-
method: "POST",
|
|
281
|
-
body: formData
|
|
282
|
-
})).ok) {
|
|
283
|
-
response = `https://${props.bucket}.s3.${this.config.region}.amazonaws.com/${props.key}`;
|
|
284
|
-
resolve(response);
|
|
285
|
-
} else {
|
|
286
|
-
response = null;
|
|
287
|
-
reject(response);
|
|
288
|
-
}
|
|
289
|
-
});
|
|
290
|
-
};
|
|
291
|
-
/**
|
|
292
|
-
* Download a file and write to S3.
|
|
293
|
-
*/
|
|
294
|
-
urlContents = async (bucket, key, url) => {
|
|
295
|
-
await this.ensureInit();
|
|
296
|
-
return axios(url, {
|
|
297
|
-
responseType: "arraybuffer",
|
|
298
|
-
responseEncoding: "binary"
|
|
299
|
-
}).then(async (response) => {
|
|
300
|
-
await this.writeFile(bucket, response.data, key, {
|
|
301
|
-
ContentType: response.headers["content-type"],
|
|
302
|
-
ContentLength: response.headers["content-length"]
|
|
303
|
-
});
|
|
304
|
-
});
|
|
305
|
-
};
|
|
306
|
-
};
|
|
307
|
-
|
|
308
|
-
//#endregion
|
|
309
|
-
//#region src/aws/s3/server/awsS3.ts
|
|
310
|
-
const awsS3Namespaces = /* @__PURE__ */ new Map();
|
|
311
|
-
const awsS3Client = async (key = "default", config, vaultId, itemId) => {
|
|
312
|
-
if (awsS3Namespaces.has(key)) return awsS3Namespaces.get(key);
|
|
313
|
-
const namespace = new AwsS3Namespace(key, await getConfig(key, config, vaultId, itemId));
|
|
314
|
-
awsS3Namespaces.set(key, namespace);
|
|
315
|
-
return namespace;
|
|
316
|
-
};
|
|
317
|
-
const readFileDefault = {
|
|
318
|
-
body: void 0,
|
|
319
|
-
now: void 0,
|
|
320
|
-
error: void 0,
|
|
321
|
-
modified: defaultDateTime
|
|
322
|
-
};
|
|
323
|
-
|
|
324
|
-
//#endregion
|
|
325
|
-
//#region src/aws/s3/server/payload.ts
|
|
326
|
-
/**
|
|
327
|
-
* https://docs.aws.amazon.com/AmazonS3/latest/userguide/notification-content-structure.html
|
|
328
|
-
*/
|
|
329
|
-
const payloadSchema = z.object({ Records: z.object({
|
|
330
|
-
eventVersion: z.string(),
|
|
331
|
-
eventSource: z.string(),
|
|
332
|
-
awsRegion: z.string(),
|
|
333
|
-
eventTime: z.string(),
|
|
334
|
-
eventName: z.string(),
|
|
335
|
-
userIdentity: z.object({ principalId: z.string() }),
|
|
336
|
-
requestParameters: z.object({ sourceIPAddress: z.string() }),
|
|
337
|
-
responseElements: z.object({
|
|
338
|
-
"x-amz-request-id": z.string(),
|
|
339
|
-
"x-amz-id-2": z.string()
|
|
340
|
-
}),
|
|
341
|
-
s3: z.object({
|
|
342
|
-
s3SchemaVersion: z.string(),
|
|
343
|
-
configurationId: z.string(),
|
|
344
|
-
bucket: z.object({
|
|
345
|
-
name: z.string(),
|
|
346
|
-
ownerIdentity: z.object({ principalId: z.string() }),
|
|
347
|
-
arn: z.string()
|
|
348
|
-
}),
|
|
349
|
-
object: z.object({
|
|
350
|
-
key: z.string(),
|
|
351
|
-
size: z.string(),
|
|
352
|
-
eTag: z.string(),
|
|
353
|
-
versionId: z.string().optional(),
|
|
354
|
-
sequencer: z.string()
|
|
355
|
-
})
|
|
356
|
-
})
|
|
357
|
-
}).array() });
|
|
358
|
-
|
|
359
|
-
//#endregion
|
|
360
|
-
export { AwsS3Namespace, awsS3Client, payloadSchema, readFileDefault };
|