@superdurable/connector-amazon-s3 0.1.2 → 0.2.0
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/README.md +5 -16
- package/dex-connector.json +499 -2
- package/dist/chunk-6LKGFP44.js +755 -0
- package/dist/{connection-BXFHjy1h.d.ts → connection-CmMVOLxi.d.ts} +330 -3
- package/dist/index.d.ts +494 -8
- package/dist/index.js +923 -21
- package/dist/mock.d.ts +182 -2
- package/dist/mock.js +454 -12
- package/package.json +2 -2
- package/dist/chunk-IGAKQPN2.js +0 -326
package/dist/chunk-IGAKQPN2.js
DELETED
|
@@ -1,326 +0,0 @@
|
|
|
1
|
-
// src/generated/models.ts
|
|
2
|
-
import { z } from "zod";
|
|
3
|
-
import { SecretString } from "@superdurable/connectors-sdk";
|
|
4
|
-
var goTimeJSONPattern = /^(\d{4})-(\d{2})-(\d{2})T(\d{1,2}):(\d{2}):(\d{2})(?:[.,](\d+))?(Z|([+-])(\d{2}):(\d{2}))$/;
|
|
5
|
-
function isGoTimeJSON(value) {
|
|
6
|
-
const match = goTimeJSONPattern.exec(value);
|
|
7
|
-
if (!match) return false;
|
|
8
|
-
const [, yearText, monthText, dayText, hourText, minuteText, secondText, , zone, , zoneHourText, zoneMinuteText] = match;
|
|
9
|
-
const year = Number(yearText);
|
|
10
|
-
const month = Number(monthText);
|
|
11
|
-
const day = Number(dayText);
|
|
12
|
-
const isLeap = year % 4 === 0 && (year % 100 !== 0 || year % 400 === 0);
|
|
13
|
-
const monthDays = [31, isLeap ? 29 : 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
|
|
14
|
-
return month >= 1 && month <= 12 && day >= 1 && day <= monthDays[month - 1] && Number(hourText) <= 23 && Number(minuteText) <= 59 && Number(secondText) <= 59 && (zone === "Z" || Number(zoneHourText) <= 24 && Number(zoneMinuteText) <= 60);
|
|
15
|
-
}
|
|
16
|
-
function canonicalGoTimeJSON(value) {
|
|
17
|
-
const match = goTimeJSONPattern.exec(value);
|
|
18
|
-
const [, year, month, day, hour, minute, second, fraction, zone, sign, zoneHour, zoneMinute] = match;
|
|
19
|
-
const clock = year + "-" + month + "-" + day + "T" + hour.padStart(2, "0") + ":" + minute + ":" + second;
|
|
20
|
-
const digits = (fraction ?? "").slice(0, 9).replace(/0+$/, "");
|
|
21
|
-
const offsetMinutes = zone === "Z" ? 0 : (Number(zoneHour) * 60 + Number(zoneMinute)) * (sign === "+" ? 1 : -1);
|
|
22
|
-
if (Math.abs(offsetMinutes) >= 1440) return value;
|
|
23
|
-
const offset = offsetMinutes === 0 ? "Z" : (offsetMinutes > 0 ? "+" : "-") + String(Math.floor(Math.abs(offsetMinutes) / 60)).padStart(2, "0") + ":" + String(Math.abs(offsetMinutes) % 60).padStart(2, "0");
|
|
24
|
-
return clock + (digits ? "." + digits : "") + offset;
|
|
25
|
-
}
|
|
26
|
-
var GoTimeJSONSchema = z.string().refine(isGoTimeJSON, "invalid Go time.Time JSON timestamp").transform(canonicalGoTimeJSON);
|
|
27
|
-
var ConfigSchema = z.object({
|
|
28
|
-
"region": z.string().optional(),
|
|
29
|
-
"endpoint": z.string().optional(),
|
|
30
|
-
"addressingStyle": z.string().optional(),
|
|
31
|
-
"defaultBucket": z.string().optional(),
|
|
32
|
-
"listPageSize": z.number().int().optional(),
|
|
33
|
-
"maxResponseBytes": z.number().int().optional(),
|
|
34
|
-
"maxTextBytes": z.number().int().optional(),
|
|
35
|
-
"maxUploadBytes": z.number().int().optional()
|
|
36
|
-
});
|
|
37
|
-
var CredentialMaterialError = class extends TypeError {
|
|
38
|
-
constructor(message) {
|
|
39
|
-
super(message);
|
|
40
|
-
this.name = "CredentialMaterialError";
|
|
41
|
-
}
|
|
42
|
-
};
|
|
43
|
-
var sdkCredentialDecodingFailureMessages = /* @__PURE__ */ new Set([
|
|
44
|
-
"project credential decoding failed",
|
|
45
|
-
"shared project credential decoding failed",
|
|
46
|
-
"project credential decoding failed: this connector version does not support shared credentials"
|
|
47
|
-
]);
|
|
48
|
-
function isCredentialMaterialError(error) {
|
|
49
|
-
return error instanceof CredentialMaterialError || error instanceof TypeError && sdkCredentialDecodingFailureMessages.has(error.message);
|
|
50
|
-
}
|
|
51
|
-
function decodeCredentials(value) {
|
|
52
|
-
if (!value || typeof value !== "object" || Array.isArray(value)) throw new CredentialMaterialError("credential fields are invalid");
|
|
53
|
-
const fields = value;
|
|
54
|
-
const allowed = /* @__PURE__ */ new Set(["access_key_id", "secret_access_key", "session_token"]);
|
|
55
|
-
if (Object.keys(fields).some((key) => !allowed.has(key))) throw new CredentialMaterialError("stored credential does not match the connector credential fields");
|
|
56
|
-
if (fields["access_key_id"] != null && !(typeof fields["access_key_id"] === "string")) throw new CredentialMaterialError("credential access_key_id has an invalid type");
|
|
57
|
-
if (fields["secret_access_key"] != null && !(typeof fields["secret_access_key"] === "string")) throw new CredentialMaterialError("credential secret_access_key has an invalid type");
|
|
58
|
-
if (fields["session_token"] != null && !(typeof fields["session_token"] === "string")) throw new CredentialMaterialError("credential session_token has an invalid type");
|
|
59
|
-
const credentials = {};
|
|
60
|
-
if (!fields["access_key_id"]) throw new CredentialMaterialError("credential access_key_id is required");
|
|
61
|
-
credentials.accessKeyId = new SecretString(fields["access_key_id"] ?? "");
|
|
62
|
-
if (!fields["secret_access_key"]) throw new CredentialMaterialError("credential secret_access_key is required");
|
|
63
|
-
credentials.secretAccessKey = new SecretString(fields["secret_access_key"] ?? "");
|
|
64
|
-
credentials.sessionToken = new SecretString(fields["session_token"] ?? "");
|
|
65
|
-
return credentials;
|
|
66
|
-
}
|
|
67
|
-
var ListObjectsInputSchema = z.strictObject({
|
|
68
|
-
"bucket": z.string().optional(),
|
|
69
|
-
"prefix": z.string().optional(),
|
|
70
|
-
"delimiter": z.string().optional(),
|
|
71
|
-
"startAfter": z.string().optional(),
|
|
72
|
-
"continuationToken": z.string().optional(),
|
|
73
|
-
"maxKeys": z.number().int().optional()
|
|
74
|
-
});
|
|
75
|
-
var ObjectSummarySchema = z.strictObject({
|
|
76
|
-
"key": z.string(),
|
|
77
|
-
"sizeBytes": z.number().int(),
|
|
78
|
-
"eTag": z.string().optional(),
|
|
79
|
-
"lastModified": GoTimeJSONSchema.optional(),
|
|
80
|
-
"storageClass": z.string().optional()
|
|
81
|
-
});
|
|
82
|
-
var ListObjectsOutputSchema = z.strictObject({
|
|
83
|
-
"bucket": z.string(),
|
|
84
|
-
"prefix": z.string().optional(),
|
|
85
|
-
"delimiter": z.string().optional(),
|
|
86
|
-
"objects": z.array(ObjectSummarySchema).optional(),
|
|
87
|
-
"commonPrefixes": z.array(z.string()).optional(),
|
|
88
|
-
"isTruncated": z.boolean(),
|
|
89
|
-
"nextContinuationToken": z.string().optional()
|
|
90
|
-
});
|
|
91
|
-
var HeadObjectInputSchema = z.strictObject({
|
|
92
|
-
"bucket": z.string().optional(),
|
|
93
|
-
"key": z.string()
|
|
94
|
-
});
|
|
95
|
-
var ObjectMetadataSchema = z.strictObject({
|
|
96
|
-
"bucket": z.string(),
|
|
97
|
-
"key": z.string(),
|
|
98
|
-
"sizeBytes": z.number().int(),
|
|
99
|
-
"eTag": z.string().optional(),
|
|
100
|
-
"contentType": z.string().optional(),
|
|
101
|
-
"contentEncoding": z.string().optional(),
|
|
102
|
-
"contentLanguage": z.string().optional(),
|
|
103
|
-
"contentDisposition": z.string().optional(),
|
|
104
|
-
"cacheControl": z.string().optional(),
|
|
105
|
-
"lastModified": GoTimeJSONSchema.optional(),
|
|
106
|
-
"versionId": z.string().optional(),
|
|
107
|
-
"storageClass": z.string().optional(),
|
|
108
|
-
"serverSideEncryption": z.string().optional(),
|
|
109
|
-
"metadata": z.record(z.string(), z.string()).optional(),
|
|
110
|
-
"missingMetadataCount": z.number().int().optional()
|
|
111
|
-
});
|
|
112
|
-
var GetObjectTextInputSchema = z.strictObject({
|
|
113
|
-
"bucket": z.string().optional(),
|
|
114
|
-
"key": z.string()
|
|
115
|
-
});
|
|
116
|
-
var ObjectTextSchema = z.strictObject({
|
|
117
|
-
"bucket": z.string(),
|
|
118
|
-
"key": z.string(),
|
|
119
|
-
"contentType": z.string().optional(),
|
|
120
|
-
"eTag": z.string().optional(),
|
|
121
|
-
"versionId": z.string().optional(),
|
|
122
|
-
"lastModified": GoTimeJSONSchema.optional(),
|
|
123
|
-
"sizeBytes": z.number().int(),
|
|
124
|
-
"text": z.string().optional()
|
|
125
|
-
});
|
|
126
|
-
var PutObjectInputSchema = z.strictObject({
|
|
127
|
-
"bucket": z.string().optional(),
|
|
128
|
-
"key": z.string(),
|
|
129
|
-
"contentType": z.string(),
|
|
130
|
-
"textContent": z.string().optional(),
|
|
131
|
-
"byteContent": z.base64().optional(),
|
|
132
|
-
"metadata": z.record(z.string(), z.string()).optional(),
|
|
133
|
-
"isCreateOnly": z.boolean().optional()
|
|
134
|
-
});
|
|
135
|
-
var StoredObjectSchema = z.strictObject({
|
|
136
|
-
"bucket": z.string(),
|
|
137
|
-
"key": z.string(),
|
|
138
|
-
"eTag": z.string().optional(),
|
|
139
|
-
"versionId": z.string().optional(),
|
|
140
|
-
"sizeBytes": z.number().int(),
|
|
141
|
-
"contentType": z.string().optional(),
|
|
142
|
-
"lastModified": GoTimeJSONSchema.optional(),
|
|
143
|
-
"isFromEarlierAttempt": z.boolean().optional()
|
|
144
|
-
});
|
|
145
|
-
|
|
146
|
-
// src/generated/definitions.ts
|
|
147
|
-
var ConnectorID = "amazon-s3";
|
|
148
|
-
var ProviderID = "amazon-s3";
|
|
149
|
-
var ListObjectsBranch = {
|
|
150
|
-
Found: "found",
|
|
151
|
-
NotFound: "notFound",
|
|
152
|
-
ProviderRejected: "providerRejected",
|
|
153
|
-
InvalidResponse: "invalidResponse",
|
|
154
|
-
Defect: "defect"
|
|
155
|
-
};
|
|
156
|
-
var ListObjectsBranchFound = ListObjectsBranch.Found;
|
|
157
|
-
var ListObjectsBranchNotFound = ListObjectsBranch.NotFound;
|
|
158
|
-
var ListObjectsBranchProviderRejected = ListObjectsBranch.ProviderRejected;
|
|
159
|
-
var ListObjectsBranchInvalidResponse = ListObjectsBranch.InvalidResponse;
|
|
160
|
-
var ListObjectsBranchDefect = ListObjectsBranch.Defect;
|
|
161
|
-
var ListObjectsDefinition = {
|
|
162
|
-
operation: { connectorId: ConnectorID, operationId: "listObjects" },
|
|
163
|
-
branches: [
|
|
164
|
-
{ id: "found", description: "The page holds objects or common prefixes, or more pages remain." },
|
|
165
|
-
{ id: "notFound", description: "No object matched the prefix and no further page remains.", optional: true },
|
|
166
|
-
{ id: "providerRejected", description: "The store conclusively rejected the list, such as a missing bucket, a wrong Region, invalid credentials, or missing s3:ListBucket permission.", optional: true },
|
|
167
|
-
{ id: "invalidResponse", description: "The store returned an invalid or oversized list page.", optional: true },
|
|
168
|
-
{ id: "defect", description: "Local input, connection configuration, or connector definition is invalid.", optional: true }
|
|
169
|
-
],
|
|
170
|
-
stepDefaults: { executeMethodTimeoutMs: 3e4, executeDurability: "async" }
|
|
171
|
-
};
|
|
172
|
-
var ListObjectsMetadata = { kind: "query", idempotency: "none", authorization: "required" };
|
|
173
|
-
var HeadObjectBranch = {
|
|
174
|
-
Found: "found",
|
|
175
|
-
NotFound: "notFound",
|
|
176
|
-
ProviderRejected: "providerRejected",
|
|
177
|
-
InvalidResponse: "invalidResponse",
|
|
178
|
-
Defect: "defect"
|
|
179
|
-
};
|
|
180
|
-
var HeadObjectBranchFound = HeadObjectBranch.Found;
|
|
181
|
-
var HeadObjectBranchNotFound = HeadObjectBranch.NotFound;
|
|
182
|
-
var HeadObjectBranchProviderRejected = HeadObjectBranch.ProviderRejected;
|
|
183
|
-
var HeadObjectBranchInvalidResponse = HeadObjectBranch.InvalidResponse;
|
|
184
|
-
var HeadObjectBranchDefect = HeadObjectBranch.Defect;
|
|
185
|
-
var HeadObjectDefinition = {
|
|
186
|
-
operation: { connectorId: ConnectorID, operationId: "headObject" },
|
|
187
|
-
branches: [
|
|
188
|
-
{ id: "found", description: "The store returned the object's metadata." },
|
|
189
|
-
{ id: "notFound", description: "The object, or its bucket, does not exist; a HEAD response cannot say which.", optional: true },
|
|
190
|
-
{ id: "providerRejected", description: "The store conclusively rejected the read, such as a wrong Region, invalid credentials, or missing s3:GetObject permission.", optional: true },
|
|
191
|
-
{ id: "invalidResponse", description: "The store returned metadata without a valid size or modification time.", optional: true },
|
|
192
|
-
{ id: "defect", description: "Local input, connection configuration, or connector definition is invalid.", optional: true }
|
|
193
|
-
],
|
|
194
|
-
stepDefaults: { executeMethodTimeoutMs: 3e4, executeDurability: "async" }
|
|
195
|
-
};
|
|
196
|
-
var HeadObjectMetadata = { kind: "query", idempotency: "none", authorization: "required" };
|
|
197
|
-
var GetObjectTextBranch = {
|
|
198
|
-
Read: "read",
|
|
199
|
-
NotFound: "notFound",
|
|
200
|
-
UnsupportedContent: "unsupportedContent",
|
|
201
|
-
TooLarge: "tooLarge",
|
|
202
|
-
ProviderRejected: "providerRejected",
|
|
203
|
-
InvalidResponse: "invalidResponse",
|
|
204
|
-
Defect: "defect"
|
|
205
|
-
};
|
|
206
|
-
var GetObjectTextBranchRead = GetObjectTextBranch.Read;
|
|
207
|
-
var GetObjectTextBranchNotFound = GetObjectTextBranch.NotFound;
|
|
208
|
-
var GetObjectTextBranchUnsupportedContent = GetObjectTextBranch.UnsupportedContent;
|
|
209
|
-
var GetObjectTextBranchTooLarge = GetObjectTextBranch.TooLarge;
|
|
210
|
-
var GetObjectTextBranchProviderRejected = GetObjectTextBranch.ProviderRejected;
|
|
211
|
-
var GetObjectTextBranchInvalidResponse = GetObjectTextBranch.InvalidResponse;
|
|
212
|
-
var GetObjectTextBranchDefect = GetObjectTextBranch.Defect;
|
|
213
|
-
var GetObjectTextDefinition = {
|
|
214
|
-
operation: { connectorId: ConnectorID, operationId: "getObjectText" },
|
|
215
|
-
branches: [
|
|
216
|
-
{ id: "read", description: "The object's complete text was read within maxTextBytes." },
|
|
217
|
-
{ id: "notFound", description: "The object does not exist.", optional: true },
|
|
218
|
-
{ id: "unsupportedContent", description: "The object's content type is not text, its content is encoded such as gzip, or its bytes are not valid UTF-8 text.", optional: true },
|
|
219
|
-
{ id: "tooLarge", description: "The object is larger than maxTextBytes.", optional: true },
|
|
220
|
-
{ id: "providerRejected", description: "The store conclusively rejected the read, such as a missing bucket, a wrong Region, invalid credentials, or missing s3:GetObject permission.", optional: true },
|
|
221
|
-
{ id: "invalidResponse", description: "The store returned a response without a valid size or with content that contains the connection's credentials.", optional: true },
|
|
222
|
-
{ id: "defect", description: "Local input, connection configuration, or connector definition is invalid.", optional: true }
|
|
223
|
-
],
|
|
224
|
-
stepDefaults: { executeMethodTimeoutMs: 3e4, executeDurability: "async" }
|
|
225
|
-
};
|
|
226
|
-
var GetObjectTextMetadata = { kind: "query", idempotency: "none", authorization: "required" };
|
|
227
|
-
var PutObjectBranch = {
|
|
228
|
-
Stored: "stored",
|
|
229
|
-
AlreadyExists: "alreadyExists",
|
|
230
|
-
ProviderRejected: "providerRejected",
|
|
231
|
-
Defect: "defect"
|
|
232
|
-
};
|
|
233
|
-
var PutObjectBranchStored = PutObjectBranch.Stored;
|
|
234
|
-
var PutObjectBranchAlreadyExists = PutObjectBranch.AlreadyExists;
|
|
235
|
-
var PutObjectBranchProviderRejected = PutObjectBranch.ProviderRejected;
|
|
236
|
-
var PutObjectBranchDefect = PutObjectBranch.Defect;
|
|
237
|
-
var PutObjectDefinition = {
|
|
238
|
-
operation: { connectorId: ConnectorID, operationId: "putObject" },
|
|
239
|
-
branches: [
|
|
240
|
-
{ id: "stored", description: "The store holds the object this Step execution wrote." },
|
|
241
|
-
{ id: "alreadyExists", description: "Create-only mode found an object at the key that this Step execution did not write; nothing was written.", optional: true },
|
|
242
|
-
{ id: "providerRejected", description: "The store conclusively rejected the write, such as a missing bucket, a wrong Region, invalid credentials, missing s3:PutObject permission, or a store that does not support create-only writes.", optional: true },
|
|
243
|
-
{ id: "defect", description: "Local input, connection configuration, or connector definition is invalid.", optional: true }
|
|
244
|
-
],
|
|
245
|
-
stepDefaults: { executeMethodTimeoutMs: 3e4, executeDurability: "async" }
|
|
246
|
-
};
|
|
247
|
-
var PutObjectMetadata = { kind: "mutation", idempotency: "required", authorization: "required" };
|
|
248
|
-
|
|
249
|
-
// src/generated/connection.ts
|
|
250
|
-
import { ConnectionRefSchema } from "@superdurable/connectors-sdk";
|
|
251
|
-
var Connection = class {
|
|
252
|
-
/** Stable provider and connection name. */
|
|
253
|
-
reference;
|
|
254
|
-
/** Bound provider operations. */
|
|
255
|
-
operations;
|
|
256
|
-
/** Validate a reference and bind operations. */
|
|
257
|
-
constructor(reference, operations) {
|
|
258
|
-
this.reference = ConnectionRefSchema.parse(reference);
|
|
259
|
-
if (this.reference.provider !== ProviderID) throw new TypeError("connection provider differs from the manifest");
|
|
260
|
-
if (!operations) throw new TypeError("connector operations are required");
|
|
261
|
-
this.operations = operations;
|
|
262
|
-
}
|
|
263
|
-
};
|
|
264
|
-
function newConnection(client, reference) {
|
|
265
|
-
if (!client) throw new TypeError("connector client is required");
|
|
266
|
-
return new Connection(reference, client);
|
|
267
|
-
}
|
|
268
|
-
function newConnectionWithOperations(operations, reference) {
|
|
269
|
-
return new Connection(reference, operations);
|
|
270
|
-
}
|
|
271
|
-
var ConnectionNameProvider = "amazon-s3";
|
|
272
|
-
|
|
273
|
-
export {
|
|
274
|
-
ConfigSchema,
|
|
275
|
-
CredentialMaterialError,
|
|
276
|
-
isCredentialMaterialError,
|
|
277
|
-
decodeCredentials,
|
|
278
|
-
ListObjectsInputSchema,
|
|
279
|
-
ObjectSummarySchema,
|
|
280
|
-
ListObjectsOutputSchema,
|
|
281
|
-
HeadObjectInputSchema,
|
|
282
|
-
ObjectMetadataSchema,
|
|
283
|
-
GetObjectTextInputSchema,
|
|
284
|
-
ObjectTextSchema,
|
|
285
|
-
PutObjectInputSchema,
|
|
286
|
-
StoredObjectSchema,
|
|
287
|
-
ConnectorID,
|
|
288
|
-
ProviderID,
|
|
289
|
-
ListObjectsBranch,
|
|
290
|
-
ListObjectsBranchFound,
|
|
291
|
-
ListObjectsBranchNotFound,
|
|
292
|
-
ListObjectsBranchProviderRejected,
|
|
293
|
-
ListObjectsBranchInvalidResponse,
|
|
294
|
-
ListObjectsBranchDefect,
|
|
295
|
-
ListObjectsDefinition,
|
|
296
|
-
ListObjectsMetadata,
|
|
297
|
-
HeadObjectBranch,
|
|
298
|
-
HeadObjectBranchFound,
|
|
299
|
-
HeadObjectBranchNotFound,
|
|
300
|
-
HeadObjectBranchProviderRejected,
|
|
301
|
-
HeadObjectBranchInvalidResponse,
|
|
302
|
-
HeadObjectBranchDefect,
|
|
303
|
-
HeadObjectDefinition,
|
|
304
|
-
HeadObjectMetadata,
|
|
305
|
-
GetObjectTextBranch,
|
|
306
|
-
GetObjectTextBranchRead,
|
|
307
|
-
GetObjectTextBranchNotFound,
|
|
308
|
-
GetObjectTextBranchUnsupportedContent,
|
|
309
|
-
GetObjectTextBranchTooLarge,
|
|
310
|
-
GetObjectTextBranchProviderRejected,
|
|
311
|
-
GetObjectTextBranchInvalidResponse,
|
|
312
|
-
GetObjectTextBranchDefect,
|
|
313
|
-
GetObjectTextDefinition,
|
|
314
|
-
GetObjectTextMetadata,
|
|
315
|
-
PutObjectBranch,
|
|
316
|
-
PutObjectBranchStored,
|
|
317
|
-
PutObjectBranchAlreadyExists,
|
|
318
|
-
PutObjectBranchProviderRejected,
|
|
319
|
-
PutObjectBranchDefect,
|
|
320
|
-
PutObjectDefinition,
|
|
321
|
-
PutObjectMetadata,
|
|
322
|
-
Connection,
|
|
323
|
-
newConnection,
|
|
324
|
-
newConnectionWithOperations,
|
|
325
|
-
ConnectionNameProvider
|
|
326
|
-
};
|