1
0
Fork 0
mirror of synced 2024-09-18 02:08:34 +12:00
This commit is contained in:
Mel O'Hagan 2022-10-26 16:44:25 +01:00
parent d69abc4569
commit 86fef02567
2 changed files with 227 additions and 228 deletions

View file

@ -5,9 +5,8 @@ import {
DatasourceFieldType, DatasourceFieldType,
} from "@budibase/types" } from "@budibase/types"
module S3Module { const AWS = require("aws-sdk")
const AWS = require("aws-sdk") const csv = require("csvtojson")
const csv = require("csvtojson")
interface S3Config { interface S3Config {
region: string region: string
@ -17,7 +16,7 @@ interface S3Config {
endpoint?: string endpoint?: string
} }
const SCHEMA: Integration = { const SCHEMA: Integration = {
docs: "https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/S3.html", docs: "https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/S3.html",
description: description:
"Amazon Simple Storage Service (Amazon S3) is an object storage service that offers industry-leading scalability, data availability, security, and performance.", "Amazon Simple Storage Service (Amazon S3) is an object storage service that offers industry-leading scalability, data availability, security, and performance.",
@ -148,7 +147,7 @@ interface S3Config {
}, },
}, },
}, },
} }
class S3Integration implements IntegrationBase { class S3Integration implements IntegrationBase {
private readonly config: S3Config private readonly config: S3Config
@ -252,7 +251,7 @@ class S3Integration implements IntegrationBase {
}) })
.promise() .promise()
} }
} }
export default { export default {
schema: SCHEMA, schema: SCHEMA,

View file

@ -30,7 +30,7 @@ describe("S3 Integration", () => {
Delimiter: "/", Delimiter: "/",
Marker: "file.txt", Marker: "file.txt",
MaxKeys: 999, MaxKeys: 999,
Prefix: "directory/" Prefix: "directory/",
}) })
}) })
@ -45,13 +45,13 @@ describe("S3 Integration", () => {
grantWriteAcp: "he", grantWriteAcp: "he",
objectLockEnabledForBucket: true, objectLockEnabledForBucket: true,
extra: { extra: {
acl: "private" acl: "private",
} },
}) })
expect(config.integration.client.createBucket).toHaveBeenCalledWith({ expect(config.integration.client.createBucket).toHaveBeenCalledWith({
Bucket: "test", Bucket: "test",
CreateBucketConfiguration: { CreateBucketConfiguration: {
LocationConstraint: "af-south-1" LocationConstraint: "af-south-1",
}, },
GrantFullControl: "me", GrantFullControl: "me",
GrantRead: "him", GrantRead: "him",
@ -64,7 +64,7 @@ describe("S3 Integration", () => {
it("does not add undefined location constraint when calling the create method", async () => { it("does not add undefined location constraint when calling the create method", async () => {
await config.integration.create({ await config.integration.create({
bucket: "test" bucket: "test",
}) })
expect(config.integration.client.createBucket).toHaveBeenCalledWith({ expect(config.integration.client.createBucket).toHaveBeenCalledWith({
Bucket: "test", Bucket: "test",
@ -91,7 +91,7 @@ describe("S3 Integration", () => {
"VersionId": "yoz3HB.ZhCS_tKVEmIOr7qYyyAaZSKVd" "VersionId": "yoz3HB.ZhCS_tKVEmIOr7qYyyAaZSKVd"
} }
] ]
}` }`,
}) })
expect(config.integration.client.deleteObjects).toHaveBeenCalledWith({ expect(config.integration.client.deleteObjects).toHaveBeenCalledWith({
Bucket: "test", Bucket: "test",
@ -99,14 +99,14 @@ describe("S3 Integration", () => {
Objects: [ Objects: [
{ {
Key: "HappyFace.jpg", Key: "HappyFace.jpg",
VersionId: "2LWg7lQLnY41.maGB5Z6SWW.dcq0vx7b" VersionId: "2LWg7lQLnY41.maGB5Z6SWW.dcq0vx7b",
}, },
{ {
Key: "HappyFace.jpg", Key: "HappyFace.jpg",
VersionId: "yoz3HB.ZhCS_tKVEmIOr7qYyyAaZSKVd" VersionId: "yoz3HB.ZhCS_tKVEmIOr7qYyyAaZSKVd",
} },
] ],
} },
}) })
}) })
}) })