@activepieces/piece-amazon-s3 0.6.0 → 0.6.2
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 +7 -14
- package/src/i18n/translation.json +0 -40
- package/src/index.js +43 -27
- package/src/index.d.ts +0 -12
- package/src/index.d.ts.map +0 -1
- package/src/index.js.map +0 -1
- package/src/lib/actions/decrypt-pgp-file.d.ts +0 -19
- package/src/lib/actions/decrypt-pgp-file.d.ts.map +0 -1
- package/src/lib/actions/decrypt-pgp-file.js +0 -208
- package/src/lib/actions/decrypt-pgp-file.js.map +0 -1
- package/src/lib/actions/delete-file.d.ts +0 -14
- package/src/lib/actions/delete-file.d.ts.map +0 -1
- package/src/lib/actions/delete-file.js +0 -39
- package/src/lib/actions/delete-file.js.map +0 -1
- package/src/lib/actions/generate-signed-upload-url.d.ts +0 -15
- package/src/lib/actions/generate-signed-upload-url.d.ts.map +0 -1
- package/src/lib/actions/generate-signed-upload-url.js +0 -66
- package/src/lib/actions/generate-signed-upload-url.js.map +0 -1
- package/src/lib/actions/generate-signed-url.d.ts +0 -15
- package/src/lib/actions/generate-signed-url.d.ts.map +0 -1
- package/src/lib/actions/generate-signed-url.js +0 -64
- package/src/lib/actions/generate-signed-url.js.map +0 -1
- package/src/lib/actions/list-files.d.ts +0 -15
- package/src/lib/actions/list-files.d.ts.map +0 -1
- package/src/lib/actions/list-files.js +0 -75
- package/src/lib/actions/list-files.js.map +0 -1
- package/src/lib/actions/move-file.d.ts +0 -15
- package/src/lib/actions/move-file.d.ts.map +0 -1
- package/src/lib/actions/move-file.js +0 -53
- package/src/lib/actions/move-file.js.map +0 -1
- package/src/lib/actions/read-file.d.ts +0 -14
- package/src/lib/actions/read-file.d.ts.map +0 -1
- package/src/lib/actions/read-file.js +0 -47
- package/src/lib/actions/read-file.js.map +0 -1
- package/src/lib/actions/upload-file.d.ts +0 -17
- package/src/lib/actions/upload-file.d.ts.map +0 -1
- package/src/lib/actions/upload-file.js +0 -110
- package/src/lib/actions/upload-file.js.map +0 -1
- package/src/lib/auth.d.ts +0 -37
- package/src/lib/auth.d.ts.map +0 -1
- package/src/lib/auth.js +0 -255
- package/src/lib/auth.js.map +0 -1
- package/src/lib/common.d.ts +0 -30
- package/src/lib/common.d.ts.map +0 -1
- package/src/lib/common.js +0 -124
- package/src/lib/common.js.map +0 -1
- package/src/lib/triggers/new-file.d.ts +0 -55
- package/src/lib/triggers/new-file.d.ts.map +0 -1
- package/src/lib/triggers/new-file.js +0 -125
- package/src/lib/triggers/new-file.js.map +0 -1
package/src/lib/auth.d.ts
DELETED
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
export declare const amazonS3Auth: import("@activepieces/pieces-framework").CustomAuthProperty<{
|
|
2
|
-
accessKeyId: import("@activepieces/pieces-framework").ShortTextProperty<true>;
|
|
3
|
-
secretAccessKey: import("@activepieces/pieces-framework").SecretTextProperty<true>;
|
|
4
|
-
endpoint: import("@activepieces/pieces-framework").ShortTextProperty<false>;
|
|
5
|
-
region: import("@activepieces/pieces-framework").StaticDropdownProperty<string, true>;
|
|
6
|
-
bucket: import("@activepieces/pieces-framework").ShortTextProperty<true>;
|
|
7
|
-
}>;
|
|
8
|
-
export declare const amazonS3OidcAuth: import("@activepieces/pieces-framework").OIDCProperty<{
|
|
9
|
-
roleArn: import("@activepieces/pieces-framework").ShortTextProperty<true>;
|
|
10
|
-
region: import("@activepieces/pieces-framework").StaticDropdownProperty<string, true>;
|
|
11
|
-
bucket: import("@activepieces/pieces-framework").ShortTextProperty<true>;
|
|
12
|
-
}>;
|
|
13
|
-
export declare const amazonS3CombinedAuth: (import("@activepieces/pieces-framework").CustomAuthProperty<{
|
|
14
|
-
accessKeyId: import("@activepieces/pieces-framework").ShortTextProperty<true>;
|
|
15
|
-
secretAccessKey: import("@activepieces/pieces-framework").SecretTextProperty<true>;
|
|
16
|
-
endpoint: import("@activepieces/pieces-framework").ShortTextProperty<false>;
|
|
17
|
-
region: import("@activepieces/pieces-framework").StaticDropdownProperty<string, true>;
|
|
18
|
-
bucket: import("@activepieces/pieces-framework").ShortTextProperty<true>;
|
|
19
|
-
}> | import("@activepieces/pieces-framework").OIDCProperty<{
|
|
20
|
-
roleArn: import("@activepieces/pieces-framework").ShortTextProperty<true>;
|
|
21
|
-
region: import("@activepieces/pieces-framework").StaticDropdownProperty<string, true>;
|
|
22
|
-
bucket: import("@activepieces/pieces-framework").ShortTextProperty<true>;
|
|
23
|
-
}>)[];
|
|
24
|
-
export type AccessKeyAuthProps = {
|
|
25
|
-
accessKeyId: string | undefined;
|
|
26
|
-
secretAccessKey: string | undefined;
|
|
27
|
-
endpoint: string | undefined;
|
|
28
|
-
bucket: string;
|
|
29
|
-
region: string;
|
|
30
|
-
};
|
|
31
|
-
export type OidcAuthProps = {
|
|
32
|
-
roleArn: string | undefined;
|
|
33
|
-
bucket: string;
|
|
34
|
-
region: string;
|
|
35
|
-
};
|
|
36
|
-
export type S3AuthProps = AccessKeyAuthProps | OidcAuthProps;
|
|
37
|
-
//# sourceMappingURL=auth.d.ts.map
|
package/src/lib/auth.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../../../src/lib/auth.ts"],"names":[],"mappings":"AA4KA,eAAO,MAAM,YAAY;;;;;;EA6CvB,CAAC;AAEH,eAAO,MAAM,gBAAgB;;;;EAiC3B,CAAC;AAEH,eAAO,MAAM,oBAAoB;;;;;;;;;;KAAmC,CAAC;AAErE,MAAM,MAAM,kBAAkB,GAAG;IAC/B,WAAW,EAAE,MAAM,GAAG,SAAS,CAAC;IAChC,eAAe,EAAE,MAAM,GAAG,SAAS,CAAC;IACpC,QAAQ,EAAE,MAAM,GAAG,SAAS,CAAC;IAC7B,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF,MAAM,MAAM,aAAa,GAAG;IAC1B,OAAO,EAAE,MAAM,GAAG,SAAS,CAAC;IAC5B,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF,MAAM,MAAM,WAAW,GAAG,kBAAkB,GAAG,aAAa,CAAC"}
|
package/src/lib/auth.js
DELETED
|
@@ -1,255 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.amazonS3CombinedAuth = exports.amazonS3OidcAuth = exports.amazonS3Auth = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
|
-
const pieces_framework_1 = require("@activepieces/pieces-framework");
|
|
6
|
-
const common_1 = require("./common");
|
|
7
|
-
const accessKeyDescription = `
|
|
8
|
-
Connect your Amazon S3 account using AWS Access Key credentials.
|
|
9
|
-
|
|
10
|
-
**How to get your credentials:**
|
|
11
|
-
1. Open the [AWS IAM Console](https://console.aws.amazon.com/iam/) and go to **Users**.
|
|
12
|
-
2. Select your user (or create a new one), then go to **Security credentials**.
|
|
13
|
-
3. Click **Create access key** — copy both the Access Key ID and Secret Access Key.
|
|
14
|
-
4. Make sure the IAM user has the **AmazonS3FullAccess** policy (or a scoped S3 policy for your bucket).
|
|
15
|
-
|
|
16
|
-
Using a non-AWS S3-compatible service (MinIO, DigitalOcean Spaces, Backblaze B2, etc.)? Set the **Endpoint** field to your service URL.
|
|
17
|
-
`;
|
|
18
|
-
const oidcDescription = `
|
|
19
|
-
Connect your Amazon S3 account using an IAM Role via OIDC — no permanent keys required.
|
|
20
|
-
|
|
21
|
-
Activepieces acts as an OIDC identity provider. AWS trusts this provider and issues temporary credentials via \`AssumeRoleWithWebIdentity\`.
|
|
22
|
-
|
|
23
|
-
**Setup steps:**
|
|
24
|
-
1. In AWS IAM → Identity Providers → Create Provider:
|
|
25
|
-
- Provider type: **OpenID Connect**
|
|
26
|
-
- Provider URL: \`{{frontendUrl}}\`
|
|
27
|
-
- Audience: \`sts.amazonaws.com\`
|
|
28
|
-
|
|
29
|
-
> AWS fetches \`{{frontendUrl}}/.well-known/openid-configuration\` to discover the OIDC metadata. If your frontend and API run on different domains, make sure the API server is reachable at \`{{frontendUrl}}\` (or that your frontend proxies \`/.well-known/*\` to the API), otherwise \`AssumeRoleWithWebIdentity\` will fail.
|
|
30
|
-
2. Create an IAM Role with this trust policy:
|
|
31
|
-
\`\`\`json
|
|
32
|
-
{
|
|
33
|
-
"Version": "2012-10-17",
|
|
34
|
-
"Statement": [{
|
|
35
|
-
"Effect": "Allow",
|
|
36
|
-
"Principal": { "Federated": "arn:aws:iam::YOUR_ACCOUNT_ID:oidc-provider/{{frontendHost}}" },
|
|
37
|
-
"Action": "sts:AssumeRoleWithWebIdentity",
|
|
38
|
-
"Condition": {
|
|
39
|
-
"StringEquals": {
|
|
40
|
-
"{{frontendHost}}:aud": "sts.amazonaws.com"
|
|
41
|
-
},
|
|
42
|
-
"StringLike": {
|
|
43
|
-
"{{frontendHost}}:sub": "platform:{{platformId}}:project:{{projectId}}"
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
}]
|
|
47
|
-
}
|
|
48
|
-
\`\`\`
|
|
49
|
-
3. Attach S3 permissions to the role and paste the **Role ARN** below.
|
|
50
|
-
`;
|
|
51
|
-
const AWS_REGIONS = [
|
|
52
|
-
{
|
|
53
|
-
label: 'Default',
|
|
54
|
-
value: 'us-east-1',
|
|
55
|
-
},
|
|
56
|
-
{
|
|
57
|
-
label: 'US East (N. Virginia) [us-east-1]',
|
|
58
|
-
value: 'us-east-1',
|
|
59
|
-
},
|
|
60
|
-
{
|
|
61
|
-
label: 'US East (Ohio) [us-east-2]',
|
|
62
|
-
value: 'us-east-2',
|
|
63
|
-
},
|
|
64
|
-
{
|
|
65
|
-
label: 'US West (N. California) [us-west-1]',
|
|
66
|
-
value: 'us-west-1',
|
|
67
|
-
},
|
|
68
|
-
{
|
|
69
|
-
label: 'US West (Oregon) [us-west-2]',
|
|
70
|
-
value: 'us-west-2',
|
|
71
|
-
},
|
|
72
|
-
{
|
|
73
|
-
label: 'Africa (Cape Town) [af-south-1]',
|
|
74
|
-
value: 'af-south-1',
|
|
75
|
-
},
|
|
76
|
-
{
|
|
77
|
-
label: 'Asia Pacific (Hong Kong) [ap-east-1]',
|
|
78
|
-
value: 'ap-east-1',
|
|
79
|
-
},
|
|
80
|
-
{
|
|
81
|
-
label: 'Asia Pacific (Mumbai) [ap-south-1]',
|
|
82
|
-
value: 'ap-south-1',
|
|
83
|
-
},
|
|
84
|
-
{
|
|
85
|
-
label: 'Asia Pacific (Osaka-Local) [ap-northeast-3]',
|
|
86
|
-
value: 'ap-northeast-3',
|
|
87
|
-
},
|
|
88
|
-
{
|
|
89
|
-
label: 'Asia Pacific (Seoul) [ap-northeast-2]',
|
|
90
|
-
value: 'ap-northeast-2',
|
|
91
|
-
},
|
|
92
|
-
{
|
|
93
|
-
label: 'Asia Pacific (Singapore) [ap-southeast-1]',
|
|
94
|
-
value: 'ap-southeast-1',
|
|
95
|
-
},
|
|
96
|
-
{
|
|
97
|
-
label: 'Asia Pacific (Sydney) [ap-southeast-2]',
|
|
98
|
-
value: 'ap-southeast-2',
|
|
99
|
-
},
|
|
100
|
-
{
|
|
101
|
-
label: 'Asia Pacific (Tokyo) [ap-northeast-1]',
|
|
102
|
-
value: 'ap-northeast-1',
|
|
103
|
-
},
|
|
104
|
-
{
|
|
105
|
-
label: 'Canada (Central) [ca-central-1]',
|
|
106
|
-
value: 'ca-central-1',
|
|
107
|
-
},
|
|
108
|
-
{
|
|
109
|
-
label: 'Europe (Frankfurt) [eu-central-1]',
|
|
110
|
-
value: 'eu-central-1',
|
|
111
|
-
},
|
|
112
|
-
{
|
|
113
|
-
label: 'Europe (Ireland) [eu-west-1]',
|
|
114
|
-
value: 'eu-west-1',
|
|
115
|
-
},
|
|
116
|
-
{
|
|
117
|
-
label: 'Europe (London) [eu-west-2]',
|
|
118
|
-
value: 'eu-west-2',
|
|
119
|
-
},
|
|
120
|
-
{
|
|
121
|
-
label: 'Europe (Milan) [eu-south-1]',
|
|
122
|
-
value: 'eu-south-1',
|
|
123
|
-
},
|
|
124
|
-
{
|
|
125
|
-
label: 'Europe (Paris) [eu-west-3]',
|
|
126
|
-
value: 'eu-west-3',
|
|
127
|
-
},
|
|
128
|
-
{
|
|
129
|
-
label: 'Europe (Stockholm) [eu-north-1]',
|
|
130
|
-
value: 'eu-north-1',
|
|
131
|
-
},
|
|
132
|
-
{
|
|
133
|
-
label: 'Middle East (Bahrain) [me-south-1]',
|
|
134
|
-
value: 'me-south-1',
|
|
135
|
-
},
|
|
136
|
-
{
|
|
137
|
-
label: 'South America (São Paulo) [sa-east-1]',
|
|
138
|
-
value: 'sa-east-1',
|
|
139
|
-
},
|
|
140
|
-
{
|
|
141
|
-
label: 'Europe (Spain) [eu-south-2]',
|
|
142
|
-
value: 'eu-south-2',
|
|
143
|
-
},
|
|
144
|
-
{
|
|
145
|
-
label: 'Asia Pacific (Hyderabad) [ap-south-2]',
|
|
146
|
-
value: 'ap-south-2',
|
|
147
|
-
},
|
|
148
|
-
{
|
|
149
|
-
label: 'Asia Pacific (Jakarta) [ap-southeast-3]',
|
|
150
|
-
value: 'ap-southeast-3',
|
|
151
|
-
},
|
|
152
|
-
{
|
|
153
|
-
label: 'Asia Pacific (Melbourne) [ap-southeast-4]',
|
|
154
|
-
value: 'ap-southeast-4',
|
|
155
|
-
},
|
|
156
|
-
{
|
|
157
|
-
label: 'China (Beijing) [cn-north-1]',
|
|
158
|
-
value: 'cn-north-1',
|
|
159
|
-
},
|
|
160
|
-
{
|
|
161
|
-
label: 'China (Ningxia) [cn-northwest-1]',
|
|
162
|
-
value: 'cn-northwest-1',
|
|
163
|
-
},
|
|
164
|
-
{
|
|
165
|
-
label: 'Europe (Zurich) [eu-central-2]',
|
|
166
|
-
value: 'eu-central-2',
|
|
167
|
-
},
|
|
168
|
-
{
|
|
169
|
-
label: 'Middle East (UAE) [me-central-1]',
|
|
170
|
-
value: 'me-central-1',
|
|
171
|
-
},
|
|
172
|
-
];
|
|
173
|
-
exports.amazonS3Auth = pieces_framework_1.PieceAuth.CustomAuth({
|
|
174
|
-
displayName: 'Amazon S3 (Access Key)',
|
|
175
|
-
description: accessKeyDescription,
|
|
176
|
-
props: {
|
|
177
|
-
accessKeyId: pieces_framework_1.Property.ShortText({
|
|
178
|
-
displayName: 'Access Key ID',
|
|
179
|
-
description: 'Your AWS access key ID. Found in AWS IAM Console → Users → Security credentials.',
|
|
180
|
-
required: true,
|
|
181
|
-
}),
|
|
182
|
-
secretAccessKey: pieces_framework_1.PieceAuth.SecretText({
|
|
183
|
-
displayName: 'Secret Access Key',
|
|
184
|
-
description: 'Your AWS secret access key. Only shown once when you create the access key.',
|
|
185
|
-
required: true,
|
|
186
|
-
}),
|
|
187
|
-
endpoint: pieces_framework_1.Property.ShortText({
|
|
188
|
-
displayName: 'Endpoint (Optional)',
|
|
189
|
-
description: 'Leave blank for Amazon S3. Only set when using MinIO, DigitalOcean Spaces, Backblaze B2, etc.',
|
|
190
|
-
required: false,
|
|
191
|
-
}),
|
|
192
|
-
region: pieces_framework_1.Property.StaticDropdown({
|
|
193
|
-
displayName: 'Region',
|
|
194
|
-
options: {
|
|
195
|
-
options: AWS_REGIONS,
|
|
196
|
-
},
|
|
197
|
-
required: true,
|
|
198
|
-
}),
|
|
199
|
-
bucket: pieces_framework_1.Property.ShortText({
|
|
200
|
-
displayName: 'Bucket Name',
|
|
201
|
-
description: 'The name of your S3 bucket (e.g. "my-company-files").',
|
|
202
|
-
required: true,
|
|
203
|
-
}),
|
|
204
|
-
},
|
|
205
|
-
validate: (_a) => tslib_1.__awaiter(void 0, [_a], void 0, function* ({ auth }) {
|
|
206
|
-
if (!auth.accessKeyId || !auth.secretAccessKey) {
|
|
207
|
-
return { valid: false, error: 'Access Key ID and Secret Access Key are required.' };
|
|
208
|
-
}
|
|
209
|
-
try {
|
|
210
|
-
const s3 = (0, common_1.createS3)(auth);
|
|
211
|
-
yield s3.listObjectsV2({ Bucket: auth.bucket, MaxKeys: 1 });
|
|
212
|
-
return { valid: true };
|
|
213
|
-
}
|
|
214
|
-
catch (e) {
|
|
215
|
-
return { valid: false, error: e === null || e === void 0 ? void 0 : e.message };
|
|
216
|
-
}
|
|
217
|
-
}),
|
|
218
|
-
required: true,
|
|
219
|
-
});
|
|
220
|
-
exports.amazonS3OidcAuth = pieces_framework_1.PieceAuth.OIDC({
|
|
221
|
-
displayName: 'Amazon S3 (IAM Role / OIDC)',
|
|
222
|
-
description: oidcDescription,
|
|
223
|
-
props: {
|
|
224
|
-
roleArn: pieces_framework_1.Property.ShortText({
|
|
225
|
-
displayName: 'Role ARN',
|
|
226
|
-
description: 'The ARN of the IAM role to assume (e.g. arn:aws:iam::123456789012:role/MyRole).',
|
|
227
|
-
required: true,
|
|
228
|
-
}),
|
|
229
|
-
region: pieces_framework_1.Property.StaticDropdown({
|
|
230
|
-
displayName: 'Region',
|
|
231
|
-
options: {
|
|
232
|
-
options: AWS_REGIONS,
|
|
233
|
-
},
|
|
234
|
-
required: true,
|
|
235
|
-
}),
|
|
236
|
-
bucket: pieces_framework_1.Property.ShortText({
|
|
237
|
-
displayName: 'Bucket Name',
|
|
238
|
-
description: 'The name of your S3 bucket (e.g. "my-company-files").',
|
|
239
|
-
required: true,
|
|
240
|
-
}),
|
|
241
|
-
},
|
|
242
|
-
validate: (_a) => tslib_1.__awaiter(void 0, [_a], void 0, function* ({ auth }) {
|
|
243
|
-
if (!auth.roleArn) {
|
|
244
|
-
return { valid: false, error: 'Role ARN is required for IAM Role authentication.' };
|
|
245
|
-
}
|
|
246
|
-
const arnRegex = /^arn:(?:aws|aws-us-gov|aws-cn):iam::\d{12}:role\/[\w+=,.@\-/]{1,512}$/;
|
|
247
|
-
if (!arnRegex.test(auth.roleArn)) {
|
|
248
|
-
return { valid: false, error: 'Invalid IAM Role ARN format. Expected: arn:aws:iam::123456789012:role/RoleName' };
|
|
249
|
-
}
|
|
250
|
-
return { valid: true };
|
|
251
|
-
}),
|
|
252
|
-
required: true,
|
|
253
|
-
});
|
|
254
|
-
exports.amazonS3CombinedAuth = [exports.amazonS3Auth, exports.amazonS3OidcAuth];
|
|
255
|
-
//# sourceMappingURL=auth.js.map
|
package/src/lib/auth.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"auth.js","sourceRoot":"","sources":["../../../src/lib/auth.ts"],"names":[],"mappings":";;;;AAAA,qEAAqE;AACrE,qCAAoC;AAEpC,MAAM,oBAAoB,GAAG;;;;;;;;;;CAU5B,CAAC;AAEF,MAAM,eAAe,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAgCvB,CAAC;AAEF,MAAM,WAAW,GAAG;IAClB;QACE,KAAK,EAAE,SAAS;QAChB,KAAK,EAAE,WAAW;KACnB;IACD;QACE,KAAK,EAAE,mCAAmC;QAC1C,KAAK,EAAE,WAAW;KACnB;IACD;QACE,KAAK,EAAE,4BAA4B;QACnC,KAAK,EAAE,WAAW;KACnB;IACD;QACE,KAAK,EAAE,qCAAqC;QAC5C,KAAK,EAAE,WAAW;KACnB;IACD;QACE,KAAK,EAAE,8BAA8B;QACrC,KAAK,EAAE,WAAW;KACnB;IACD;QACE,KAAK,EAAE,iCAAiC;QACxC,KAAK,EAAE,YAAY;KACpB;IACD;QACE,KAAK,EAAE,sCAAsC;QAC7C,KAAK,EAAE,WAAW;KACnB;IACD;QACE,KAAK,EAAE,oCAAoC;QAC3C,KAAK,EAAE,YAAY;KACpB;IACD;QACE,KAAK,EAAE,6CAA6C;QACpD,KAAK,EAAE,gBAAgB;KACxB;IACD;QACE,KAAK,EAAE,uCAAuC;QAC9C,KAAK,EAAE,gBAAgB;KACxB;IACD;QACE,KAAK,EAAE,2CAA2C;QAClD,KAAK,EAAE,gBAAgB;KACxB;IACD;QACE,KAAK,EAAE,wCAAwC;QAC/C,KAAK,EAAE,gBAAgB;KACxB;IACD;QACE,KAAK,EAAE,uCAAuC;QAC9C,KAAK,EAAE,gBAAgB;KACxB;I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30 +0,0 @@
|
|
|
1
|
-
import { S3 } from '@aws-sdk/client-s3';
|
|
2
|
-
import { SecretsManagerClient } from '@aws-sdk/client-secrets-manager';
|
|
3
|
-
import { ServerContext } from '@activepieces/pieces-framework';
|
|
4
|
-
import { AccessKeyAuthProps, OidcAuthProps, S3AuthProps } from './auth';
|
|
5
|
-
export declare function createS3(auth: AccessKeyAuthProps): S3;
|
|
6
|
-
export declare function createSecretsManagerClient(auth: AccessKeyAuthProps): SecretsManagerClient;
|
|
7
|
-
export declare function createS3WithAssumeRole({ auth, server, durationSeconds, }: {
|
|
8
|
-
auth: OidcAuthProps;
|
|
9
|
-
server: ServerContext;
|
|
10
|
-
durationSeconds?: number;
|
|
11
|
-
}): Promise<S3>;
|
|
12
|
-
export declare function isOidcAuth(authProps: S3AuthProps): authProps is OidcAuthProps;
|
|
13
|
-
export declare function resolveS3Client({ authProps, server, }: {
|
|
14
|
-
authProps: S3AuthProps;
|
|
15
|
-
server: ServerContext;
|
|
16
|
-
}): Promise<S3>;
|
|
17
|
-
export declare function getTemporaryCredentials({ auth, server, durationSeconds, }: {
|
|
18
|
-
auth: OidcAuthProps;
|
|
19
|
-
server: ServerContext;
|
|
20
|
-
durationSeconds?: number;
|
|
21
|
-
}): Promise<TemporaryCredentials>;
|
|
22
|
-
export declare const MIN_STS_DURATION_SECONDS = 900;
|
|
23
|
-
export declare const MAX_STS_DURATION_SECONDS = 43200;
|
|
24
|
-
type TemporaryCredentials = {
|
|
25
|
-
accessKeyId: string;
|
|
26
|
-
secretAccessKey: string;
|
|
27
|
-
sessionToken: string | undefined;
|
|
28
|
-
};
|
|
29
|
-
export {};
|
|
30
|
-
//# sourceMappingURL=common.d.ts.map
|
package/src/lib/common.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"common.d.ts","sourceRoot":"","sources":["../../../src/lib/common.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,EAAE,EAAE,MAAM,oBAAoB,CAAC;AAC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defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.MAX_STS_DURATION_SECONDS = exports.MIN_STS_DURATION_SECONDS = void 0;
|
|
4
|
-
exports.createS3 = createS3;
|
|
5
|
-
exports.createSecretsManagerClient = createSecretsManagerClient;
|
|
6
|
-
exports.createS3WithAssumeRole = createS3WithAssumeRole;
|
|
7
|
-
exports.isOidcAuth = isOidcAuth;
|
|
8
|
-
exports.resolveS3Client = resolveS3Client;
|
|
9
|
-
exports.getTemporaryCredentials = getTemporaryCredentials;
|
|
10
|
-
const tslib_1 = require("tslib");
|
|
11
|
-
const shared_1 = require("@activepieces/shared");
|
|
12
|
-
const client_s3_1 = require("@aws-sdk/client-s3");
|
|
13
|
-
const client_secrets_manager_1 = require("@aws-sdk/client-secrets-manager");
|
|
14
|
-
const client_sts_1 = require("@aws-sdk/client-sts");
|
|
15
|
-
const AWS_STS_AUDIENCE = 'sts.amazonaws.com';
|
|
16
|
-
function createS3(auth) {
|
|
17
|
-
if (!auth.accessKeyId || !auth.secretAccessKey) {
|
|
18
|
-
throw new Error('Access Key ID and Secret Access Key are required');
|
|
19
|
-
}
|
|
20
|
-
const s3 = new client_s3_1.S3({
|
|
21
|
-
credentials: {
|
|
22
|
-
accessKeyId: auth.accessKeyId,
|
|
23
|
-
secretAccessKey: auth.secretAccessKey,
|
|
24
|
-
},
|
|
25
|
-
forcePathStyle: auth.endpoint ? true : undefined,
|
|
26
|
-
region: auth.region,
|
|
27
|
-
endpoint: auth.endpoint === '' || (0, shared_1.isNil)(auth.endpoint) ? undefined : auth.endpoint,
|
|
28
|
-
});
|
|
29
|
-
return s3;
|
|
30
|
-
}
|
|
31
|
-
function createSecretsManagerClient(auth) {
|
|
32
|
-
if (!auth.accessKeyId || !auth.secretAccessKey) {
|
|
33
|
-
throw new Error('Access Key ID and Secret Access Key are required');
|
|
34
|
-
}
|
|
35
|
-
const client = new client_secrets_manager_1.SecretsManagerClient({
|
|
36
|
-
credentials: {
|
|
37
|
-
accessKeyId: auth.accessKeyId,
|
|
38
|
-
secretAccessKey: auth.secretAccessKey,
|
|
39
|
-
},
|
|
40
|
-
region: auth.region,
|
|
41
|
-
endpoint: undefined,
|
|
42
|
-
});
|
|
43
|
-
return client;
|
|
44
|
-
}
|
|
45
|
-
function createS3WithAssumeRole(_a) {
|
|
46
|
-
return tslib_1.__awaiter(this, arguments, void 0, function* ({ auth, server, durationSeconds, }) {
|
|
47
|
-
const credentials = yield getTemporaryCredentials({ auth, server, durationSeconds });
|
|
48
|
-
return new client_s3_1.S3({
|
|
49
|
-
credentials,
|
|
50
|
-
region: auth.region,
|
|
51
|
-
});
|
|
52
|
-
});
|
|
53
|
-
}
|
|
54
|
-
function isOidcAuth(authProps) {
|
|
55
|
-
return 'roleArn' in authProps;
|
|
56
|
-
}
|
|
57
|
-
function resolveS3Client(_a) {
|
|
58
|
-
return tslib_1.__awaiter(this, arguments, void 0, function* ({ authProps, server, }) {
|
|
59
|
-
return isOidcAuth(authProps)
|
|
60
|
-
? createS3WithAssumeRole({ auth: authProps, server })
|
|
61
|
-
: createS3(authProps);
|
|
62
|
-
});
|
|
63
|
-
}
|
|
64
|
-
function getTemporaryCredentials(_a) {
|
|
65
|
-
return tslib_1.__awaiter(this, arguments, void 0, function* ({ auth, server, durationSeconds = DEFAULT_STS_DURATION_SECONDS, }) {
|
|
66
|
-
var _b, _c;
|
|
67
|
-
if (!auth.roleArn) {
|
|
68
|
-
throw new Error('Role ARN is required for IAM Role authentication');
|
|
69
|
-
}
|
|
70
|
-
const clampedDuration = Math.min(Math.max(durationSeconds, exports.MIN_STS_DURATION_SECONDS), exports.MAX_STS_DURATION_SECONDS);
|
|
71
|
-
// Scoped by server.token (unique per flow execution) so credentials are never reused
|
|
72
|
-
// across projects/tenants, only across steps within the same run.
|
|
73
|
-
const cacheKey = `${server.token}:${auth.roleArn}:${auth.region}:${clampedDuration}`;
|
|
74
|
-
const cached = credentialsCache.get(cacheKey);
|
|
75
|
-
if (cached && cached.expiresAtMS - Date.now() > CREDENTIALS_EXPIRY_MARGIN_MS) {
|
|
76
|
-
return cached.credentials;
|
|
77
|
-
}
|
|
78
|
-
const response = yield fetch(`${server.apiUrl}v1/worker/oidc-token`, {
|
|
79
|
-
method: 'POST',
|
|
80
|
-
headers: {
|
|
81
|
-
Authorization: `Bearer ${server.token}`,
|
|
82
|
-
'Content-Type': 'application/json',
|
|
83
|
-
},
|
|
84
|
-
body: JSON.stringify({ audience: AWS_STS_AUDIENCE }),
|
|
85
|
-
});
|
|
86
|
-
if (!response.ok) {
|
|
87
|
-
throw new Error(`Failed to get OIDC token: ${response.statusText}`);
|
|
88
|
-
}
|
|
89
|
-
const { token } = (yield response.json());
|
|
90
|
-
const sts = new client_sts_1.STSClient({ region: auth.region });
|
|
91
|
-
const { Credentials } = yield sts.send(new client_sts_1.AssumeRoleWithWebIdentityCommand({
|
|
92
|
-
RoleArn: auth.roleArn,
|
|
93
|
-
RoleSessionName: 'activepieces-execution',
|
|
94
|
-
WebIdentityToken: token,
|
|
95
|
-
DurationSeconds: clampedDuration,
|
|
96
|
-
}));
|
|
97
|
-
if (!(Credentials === null || Credentials === void 0 ? void 0 : Credentials.AccessKeyId) || !Credentials.SecretAccessKey) {
|
|
98
|
-
throw new Error('Failed to assume role: no credentials returned');
|
|
99
|
-
}
|
|
100
|
-
const credentials = {
|
|
101
|
-
accessKeyId: Credentials.AccessKeyId,
|
|
102
|
-
secretAccessKey: Credentials.SecretAccessKey,
|
|
103
|
-
sessionToken: Credentials.SessionToken,
|
|
104
|
-
};
|
|
105
|
-
const expiresAtMS = (_c = (_b = Credentials.Expiration) === null || _b === void 0 ? void 0 : _b.getTime()) !== null && _c !== void 0 ? _c : Date.now() + clampedDuration * 1000;
|
|
106
|
-
sweepExpiredCredentials();
|
|
107
|
-
credentialsCache.set(cacheKey, { credentials, expiresAtMS });
|
|
108
|
-
return credentials;
|
|
109
|
-
});
|
|
110
|
-
}
|
|
111
|
-
function sweepExpiredCredentials() {
|
|
112
|
-
const now = Date.now();
|
|
113
|
-
for (const [key, value] of credentialsCache) {
|
|
114
|
-
if (value.expiresAtMS <= now) {
|
|
115
|
-
credentialsCache.delete(key);
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
const DEFAULT_STS_DURATION_SECONDS = 3600;
|
|
120
|
-
const CREDENTIALS_EXPIRY_MARGIN_MS = 5 * 60 * 1000;
|
|
121
|
-
const credentialsCache = new Map();
|
|
122
|
-
exports.MIN_STS_DURATION_SECONDS = 900;
|
|
123
|
-
exports.MAX_STS_DURATION_SECONDS = 43200;
|
|
124
|
-
//# sourceMappingURL=common.js.map
|
package/src/lib/common.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"common.js","sourceRoot":"","sources":["../../../src/lib/common.ts"],"names":[],"mappings":";;;AASA,4BAeC;AAED,gEAaC;AAED,wDAcC;AAED,gCAEC;AAED,0CAUC;AAED,0DAwDC;;AAjID,iDAA6C;AAC7C,kDAAwC;AACxC,4EAAuE;AACvE,oDAAkF;AAIlF,MAAM,gBAAgB,GAAG,mBAAmB,CAAC;AAE7C,SAAgB,QAAQ,CAAC,IAAwB;IAC/C,IAAI,CAAC,IAAI,CAAC,WAAW,IAAI,CAAC,IAAI,CAAC,eAAe,EAAE,CAAC;QAC/C,MAAM,IAAI,KAAK,CAAC,kDAAkD,CAAC,CAAC;IACtE,CAAC;IACD,MAAM,EAAE,GAAG,IAAI,cAAE,CAAC;QAChB,WAAW,EAAE;YACX,WAAW,EAAE,IAAI,CAAC,WAAW;YAC7B,eAAe,EAAE,IAAI,CAAC,eAAe;SACtC;QACD,cAAc,EAAE,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS;QAChD,MAAM,EAAE,IAAI,CAAC,MAAM;QACnB,QAAQ,EACN,IAAI,CAAC,QAAQ,KAAK,EAAE,IAAI,IAAA,cAAK,EAAC,IAAI,CAAC,QAAQ,CAAC,CAA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,gBAAgB,GAAG,IAAI,GAAG,EAA6B,CAAC;AAEjD,QAAA,wBAAwB,GAAG,GAAG,CAAC;AAC/B,QAAA,wBAAwB,GAAG,KAAK,CAAC"}
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
import { TriggerStrategy } from '@activepieces/pieces-framework';
|
|
2
|
-
export declare const newFile: import("@activepieces/pieces-framework").ITrigger<TriggerStrategy.WEBHOOK, (import("@activepieces/pieces-framework").CustomAuthProperty<{
|
|
3
|
-
accessKeyId: import("@activepieces/pieces-framework").ShortTextProperty<true>;
|
|
4
|
-
secretAccessKey: import("@activepieces/pieces-framework").SecretTextProperty<true>;
|
|
5
|
-
endpoint: import("@activepieces/pieces-framework").ShortTextProperty<false>;
|
|
6
|
-
region: import("@activepieces/pieces-framework").StaticDropdownProperty<string, true>;
|
|
7
|
-
bucket: import("@activepieces/pieces-framework").ShortTextProperty<true>;
|
|
8
|
-
}> | import("@activepieces/pieces-framework").OIDCProperty<{
|
|
9
|
-
roleArn: import("@activepieces/pieces-framework").ShortTextProperty<true>;
|
|
10
|
-
region: import("@activepieces/pieces-framework").StaticDropdownProperty<string, true>;
|
|
11
|
-
bucket: import("@activepieces/pieces-framework").ShortTextProperty<true>;
|
|
12
|
-
}>)[], {
|
|
13
|
-
markdown: import("@activepieces/pieces-framework/dist/src/lib/property/input/markdown-property").MarkDownProperty;
|
|
14
|
-
folderPath: import("@activepieces/pieces-framework").ShortTextProperty<false>;
|
|
15
|
-
}> | import("@activepieces/pieces-framework").ITrigger<TriggerStrategy.POLLING, (import("@activepieces/pieces-framework").CustomAuthProperty<{
|
|
16
|
-
accessKeyId: import("@activepieces/pieces-framework").ShortTextProperty<true>;
|
|
17
|
-
secretAccessKey: import("@activepieces/pieces-framework").SecretTextProperty<true>;
|
|
18
|
-
endpoint: import("@activepieces/pieces-framework").ShortTextProperty<false>;
|
|
19
|
-
region: import("@activepieces/pieces-framework").StaticDropdownProperty<string, true>;
|
|
20
|
-
bucket: import("@activepieces/pieces-framework").ShortTextProperty<true>;
|
|
21
|
-
}> | import("@activepieces/pieces-framework").OIDCProperty<{
|
|
22
|
-
roleArn: import("@activepieces/pieces-framework").ShortTextProperty<true>;
|
|
23
|
-
region: import("@activepieces/pieces-framework").StaticDropdownProperty<string, true>;
|
|
24
|
-
bucket: import("@activepieces/pieces-framework").ShortTextProperty<true>;
|
|
25
|
-
}>)[], {
|
|
26
|
-
markdown: import("@activepieces/pieces-framework/dist/src/lib/property/input/markdown-property").MarkDownProperty;
|
|
27
|
-
folderPath: import("@activepieces/pieces-framework").ShortTextProperty<false>;
|
|
28
|
-
}> | import("@activepieces/pieces-framework").ITrigger<TriggerStrategy.MANUAL, (import("@activepieces/pieces-framework").CustomAuthProperty<{
|
|
29
|
-
accessKeyId: import("@activepieces/pieces-framework").ShortTextProperty<true>;
|
|
30
|
-
secretAccessKey: import("@activepieces/pieces-framework").SecretTextProperty<true>;
|
|
31
|
-
endpoint: import("@activepieces/pieces-framework").ShortTextProperty<false>;
|
|
32
|
-
region: import("@activepieces/pieces-framework").StaticDropdownProperty<string, true>;
|
|
33
|
-
bucket: import("@activepieces/pieces-framework").ShortTextProperty<true>;
|
|
34
|
-
}> | import("@activepieces/pieces-framework").OIDCProperty<{
|
|
35
|
-
roleArn: import("@activepieces/pieces-framework").ShortTextProperty<true>;
|
|
36
|
-
region: import("@activepieces/pieces-framework").StaticDropdownProperty<string, true>;
|
|
37
|
-
bucket: import("@activepieces/pieces-framework").ShortTextProperty<true>;
|
|
38
|
-
}>)[], {
|
|
39
|
-
markdown: import("@activepieces/pieces-framework/dist/src/lib/property/input/markdown-property").MarkDownProperty;
|
|
40
|
-
folderPath: import("@activepieces/pieces-framework").ShortTextProperty<false>;
|
|
41
|
-
}> | import("@activepieces/pieces-framework").ITrigger<TriggerStrategy.APP_WEBHOOK, (import("@activepieces/pieces-framework").CustomAuthProperty<{
|
|
42
|
-
accessKeyId: import("@activepieces/pieces-framework").ShortTextProperty<true>;
|
|
43
|
-
secretAccessKey: import("@activepieces/pieces-framework").SecretTextProperty<true>;
|
|
44
|
-
endpoint: import("@activepieces/pieces-framework").ShortTextProperty<false>;
|
|
45
|
-
region: import("@activepieces/pieces-framework").StaticDropdownProperty<string, true>;
|
|
46
|
-
bucket: import("@activepieces/pieces-framework").ShortTextProperty<true>;
|
|
47
|
-
}> | import("@activepieces/pieces-framework").OIDCProperty<{
|
|
48
|
-
roleArn: import("@activepieces/pieces-framework").ShortTextProperty<true>;
|
|
49
|
-
region: import("@activepieces/pieces-framework").StaticDropdownProperty<string, true>;
|
|
50
|
-
bucket: import("@activepieces/pieces-framework").ShortTextProperty<true>;
|
|
51
|
-
}>)[], {
|
|
52
|
-
markdown: import("@activepieces/pieces-framework/dist/src/lib/property/input/markdown-property").MarkDownProperty;
|
|
53
|
-
folderPath: import("@activepieces/pieces-framework").ShortTextProperty<false>;
|
|
54
|
-
}>;
|
|
55
|
-
//# sourceMappingURL=new-file.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"new-file.d.ts","sourceRoot":"","sources":["../../../../src/lib/triggers/new-file.ts"],"names":[],"mappings":"AAAA,OAAO,EAA+C,eAAe,EAAiB,MAAM,gCAAgC,CAAC;AA0B7H,eAAO,MAAM,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA0DlB,CAAC"}
|
|
@@ -1,125 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.newFile = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
|
-
const pieces_framework_1 = require("@activepieces/pieces-framework");
|
|
6
|
-
const pieces_common_1 = require("@activepieces/pieces-common");
|
|
7
|
-
const shared_1 = require("@activepieces/shared");
|
|
8
|
-
const dayjs_1 = tslib_1.__importDefault(require("dayjs"));
|
|
9
|
-
const auth_1 = require("../auth");
|
|
10
|
-
const common_1 = require("../common");
|
|
11
|
-
const polling = {
|
|
12
|
-
strategy: pieces_common_1.DedupeStrategy.TIMEBASED,
|
|
13
|
-
items: (_a) => tslib_1.__awaiter(void 0, [_a], void 0, function* ({ auth, propsValue, lastFetchEpochMS, server }) {
|
|
14
|
-
if (!server) {
|
|
15
|
-
throw new Error('Server context is required to resolve Amazon S3 credentials');
|
|
16
|
-
}
|
|
17
|
-
const authProps = auth.props;
|
|
18
|
-
const s3 = yield (0, common_1.resolveS3Client)({ authProps, server });
|
|
19
|
-
const files = yield fetchS3FilesForTrigger({
|
|
20
|
-
s3,
|
|
21
|
-
bucket: authProps.bucket,
|
|
22
|
-
folderPath: propsValue.folderPath,
|
|
23
|
-
isTest: lastFetchEpochMS === 0,
|
|
24
|
-
});
|
|
25
|
-
return files.filter((f) => Number.isFinite(f.epochMilliSeconds));
|
|
26
|
-
}),
|
|
27
|
-
};
|
|
28
|
-
exports.newFile = (0, pieces_framework_1.createTrigger)({
|
|
29
|
-
auth: auth_1.amazonS3CombinedAuth,
|
|
30
|
-
name: 'new_file',
|
|
31
|
-
displayName: 'New or Updated File',
|
|
32
|
-
description: 'Triggers when you add or update a file in your bucket. The bucket/folder you choose must not contain more than 10,000 files.',
|
|
33
|
-
aiMetadata: {
|
|
34
|
-
description: 'Fires when an object is added or modified in the configured S3 bucket, optionally scoped to a folder prefix. Polls the bucket and emits each new or updated file based on its last-modified time. The watched bucket/folder must contain no more than 10,000 files.',
|
|
35
|
-
},
|
|
36
|
-
props: {
|
|
37
|
-
markdown: pieces_framework_1.Property.MarkDown({
|
|
38
|
-
variant: shared_1.MarkdownVariant.INFO,
|
|
39
|
-
value: 'Triggers when you add or update a file in your bucket. The bucket/folder you choose must not contain more than 10,000 files.',
|
|
40
|
-
}),
|
|
41
|
-
folderPath: pieces_framework_1.Property.ShortText({
|
|
42
|
-
displayName: 'Folder Path',
|
|
43
|
-
required: false,
|
|
44
|
-
}),
|
|
45
|
-
},
|
|
46
|
-
type: pieces_framework_1.TriggerStrategy.POLLING,
|
|
47
|
-
onEnable: (context) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
|
|
48
|
-
yield pieces_common_1.pollingHelper.onEnable(polling, {
|
|
49
|
-
auth: context.auth,
|
|
50
|
-
store: context.store,
|
|
51
|
-
propsValue: context.propsValue,
|
|
52
|
-
});
|
|
53
|
-
}),
|
|
54
|
-
onDisable: (context) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
|
|
55
|
-
yield pieces_common_1.pollingHelper.onDisable(polling, {
|
|
56
|
-
auth: context.auth,
|
|
57
|
-
store: context.store,
|
|
58
|
-
propsValue: context.propsValue,
|
|
59
|
-
});
|
|
60
|
-
}),
|
|
61
|
-
run: (context) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
|
|
62
|
-
return pieces_common_1.pollingHelper.poll(polling, {
|
|
63
|
-
auth: context.auth,
|
|
64
|
-
store: context.store,
|
|
65
|
-
propsValue: context.propsValue,
|
|
66
|
-
files: context.files,
|
|
67
|
-
server: context.server,
|
|
68
|
-
});
|
|
69
|
-
}),
|
|
70
|
-
test: (context) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
|
|
71
|
-
return pieces_common_1.pollingHelper.test(polling, {
|
|
72
|
-
auth: context.auth,
|
|
73
|
-
store: context.store,
|
|
74
|
-
propsValue: context.propsValue,
|
|
75
|
-
files: context.files,
|
|
76
|
-
server: context.server,
|
|
77
|
-
});
|
|
78
|
-
}),
|
|
79
|
-
sampleData: {
|
|
80
|
-
Key: 'myfolder/100-3.png',
|
|
81
|
-
LastModified: '2023-08-04T13:51:26.000Z',
|
|
82
|
-
ETag: '"e9f16cce12352322272525f5af65a2e"',
|
|
83
|
-
Size: 40239,
|
|
84
|
-
StorageClass: 'STANDARD',
|
|
85
|
-
},
|
|
86
|
-
});
|
|
87
|
-
function fetchS3FilesForTrigger(_a) {
|
|
88
|
-
return tslib_1.__awaiter(this, arguments, void 0, function* ({ s3, bucket, folderPath, isTest, }) {
|
|
89
|
-
var _b, _c;
|
|
90
|
-
const MAX_TOTAL_FILES = 10000;
|
|
91
|
-
const bucketFiles = [];
|
|
92
|
-
let totalFetched = 0;
|
|
93
|
-
let hasMore = true;
|
|
94
|
-
let nextToken;
|
|
95
|
-
do {
|
|
96
|
-
const params = {
|
|
97
|
-
Bucket: bucket,
|
|
98
|
-
MaxKeys: isTest ? 10 : 1000,
|
|
99
|
-
ContinuationToken: nextToken,
|
|
100
|
-
};
|
|
101
|
-
if (folderPath) {
|
|
102
|
-
params.Prefix = folderPath.endsWith('/')
|
|
103
|
-
? folderPath.slice(0, -1)
|
|
104
|
-
: folderPath;
|
|
105
|
-
}
|
|
106
|
-
const response = yield s3.listObjectsV2(params);
|
|
107
|
-
const items = (_b = response.Contents) !== null && _b !== void 0 ? _b : [];
|
|
108
|
-
if (totalFetched + items.length > MAX_TOTAL_FILES) {
|
|
109
|
-
bucketFiles.push(...items.slice(0, MAX_TOTAL_FILES - totalFetched));
|
|
110
|
-
break;
|
|
111
|
-
}
|
|
112
|
-
bucketFiles.push(...items);
|
|
113
|
-
totalFetched += items.length;
|
|
114
|
-
if (isTest)
|
|
115
|
-
break;
|
|
116
|
-
hasMore = !!response.IsTruncated;
|
|
117
|
-
nextToken = (_c = response.NextContinuationToken) !== null && _c !== void 0 ? _c : undefined;
|
|
118
|
-
} while (hasMore);
|
|
119
|
-
return bucketFiles.map((file) => ({
|
|
120
|
-
epochMilliSeconds: (0, dayjs_1.default)(file.LastModified).valueOf(),
|
|
121
|
-
data: file,
|
|
122
|
-
}));
|
|
123
|
-
});
|
|
124
|
-
}
|
|
125
|
-
//# sourceMappingURL=new-file.js.map
|