@budibase/server 2.1.19-alpha.0 → 2.1.20
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/__mocks__/aws-sdk.ts +0 -14
- package/builder/assets/{index.b14b0f23.js → index.76fb357a.js} +216 -216
- package/builder/index.html +1 -1
- package/coverage/clover.xml +6 -6
- package/coverage/coverage-final.json +1 -1
- package/coverage/lcov-report/api/controllers/apikeys.js.html +1 -1
- package/coverage/lcov-report/api/controllers/automation.js.html +1 -1
- package/coverage/lcov-report/api/controllers/cloud.js.html +1 -1
- package/coverage/lcov-report/api/controllers/datasource.js.html +1 -1
- package/coverage/lcov-report/api/controllers/dev.js.html +1 -1
- package/coverage/lcov-report/api/controllers/index.html +1 -1
- package/coverage/lcov-report/api/controllers/integration.js.html +1 -1
- package/coverage/lcov-report/api/controllers/layout.js.html +1 -1
- package/coverage/lcov-report/api/controllers/metadata.js.html +1 -1
- package/coverage/lcov-report/api/controllers/migrations.js.html +1 -1
- package/coverage/lcov-report/api/controllers/permission.js.html +1 -1
- package/coverage/lcov-report/api/controllers/query/index.html +1 -1
- package/coverage/lcov-report/api/controllers/query/validation.js.html +1 -1
- package/coverage/lcov-report/api/controllers/role.js.html +1 -1
- package/coverage/lcov-report/api/controllers/routing.js.html +1 -1
- package/coverage/lcov-report/api/controllers/row/external.js.html +1 -1
- package/coverage/lcov-report/api/controllers/row/index.html +1 -1
- package/coverage/lcov-report/api/controllers/row/internal.js.html +1 -1
- package/coverage/lcov-report/api/controllers/row/internalSearch.js.html +1 -1
- package/coverage/lcov-report/api/controllers/row/staticFormula.js.html +1 -1
- package/coverage/lcov-report/api/controllers/row/utils.js.html +1 -1
- package/coverage/lcov-report/api/controllers/script.js.html +1 -1
- package/coverage/lcov-report/api/controllers/table/bulkFormula.js.html +1 -1
- package/coverage/lcov-report/api/controllers/table/external.js.html +1 -1
- package/coverage/lcov-report/api/controllers/table/index.html +1 -1
- package/coverage/lcov-report/api/controllers/table/index.js.html +1 -1
- package/coverage/lcov-report/api/controllers/templates.js.html +1 -1
- package/coverage/lcov-report/api/controllers/user.js.html +1 -1
- package/coverage/lcov-report/api/controllers/view/exporters.js.html +1 -1
- package/coverage/lcov-report/api/controllers/view/index.html +1 -1
- package/coverage/lcov-report/api/controllers/view/index.js.html +1 -1
- package/coverage/lcov-report/api/controllers/view/utils.js.html +1 -1
- package/coverage/lcov-report/api/controllers/view/viewBuilder.js.html +1 -1
- package/coverage/lcov-report/api/index.html +1 -1
- package/coverage/lcov-report/api/index.js.html +1 -1
- package/coverage/lcov-report/api/routes/analytics.js.html +1 -1
- package/coverage/lcov-report/api/routes/apikeys.js.html +1 -1
- package/coverage/lcov-report/api/routes/automation.js.html +1 -1
- package/coverage/lcov-report/api/routes/cloud.js.html +1 -1
- package/coverage/lcov-report/api/routes/component.js.html +1 -1
- package/coverage/lcov-report/api/routes/datasource.js.html +1 -1
- package/coverage/lcov-report/api/routes/deploy.js.html +1 -1
- package/coverage/lcov-report/api/routes/dev.js.html +1 -1
- package/coverage/lcov-report/api/routes/index.html +1 -1
- package/coverage/lcov-report/api/routes/integration.js.html +1 -1
- package/coverage/lcov-report/api/routes/layout.js.html +1 -1
- package/coverage/lcov-report/api/routes/metadata.js.html +1 -1
- package/coverage/lcov-report/api/routes/migrations.js.html +1 -1
- package/coverage/lcov-report/api/routes/permission.js.html +1 -1
- package/coverage/lcov-report/api/routes/query.js.html +1 -1
- package/coverage/lcov-report/api/routes/role.js.html +1 -1
- package/coverage/lcov-report/api/routes/routing.js.html +1 -1
- package/coverage/lcov-report/api/routes/screen.js.html +1 -1
- package/coverage/lcov-report/api/routes/script.js.html +1 -1
- package/coverage/lcov-report/api/routes/table.js.html +1 -1
- package/coverage/lcov-report/api/routes/templates.js.html +1 -1
- package/coverage/lcov-report/api/routes/user.js.html +1 -1
- package/coverage/lcov-report/api/routes/utils/index.html +1 -1
- package/coverage/lcov-report/api/routes/utils/validators.js.html +1 -1
- package/coverage/lcov-report/api/routes/view.js.html +1 -1
- package/coverage/lcov-report/automations/actions.js.html +1 -1
- package/coverage/lcov-report/automations/automationUtils.js.html +1 -1
- package/coverage/lcov-report/automations/bullboard.js.html +1 -1
- package/coverage/lcov-report/automations/index.html +1 -1
- package/coverage/lcov-report/automations/index.js.html +1 -1
- package/coverage/lcov-report/automations/steps/bash.js.html +1 -1
- package/coverage/lcov-report/automations/steps/delay.js.html +1 -1
- package/coverage/lcov-report/automations/steps/discord.js.html +1 -1
- package/coverage/lcov-report/automations/steps/executeQuery.js.html +1 -1
- package/coverage/lcov-report/automations/steps/executeScript.js.html +1 -1
- package/coverage/lcov-report/automations/steps/filter.js.html +1 -1
- package/coverage/lcov-report/automations/steps/index.html +15 -15
- package/coverage/lcov-report/automations/steps/integromat.js.html +1 -1
- package/coverage/lcov-report/automations/steps/loop.js.html +1 -1
- package/coverage/lcov-report/automations/steps/outgoingWebhook.js.html +1 -1
- package/coverage/lcov-report/automations/steps/queryRows.js.html +1 -1
- package/coverage/lcov-report/automations/steps/sendSmtpEmail.js.html +1 -1
- package/coverage/lcov-report/automations/steps/serverLog.js.html +1 -1
- package/coverage/lcov-report/automations/steps/slack.js.html +1 -1
- package/coverage/lcov-report/automations/steps/updateRow.js.html +1 -1
- package/coverage/lcov-report/automations/steps/utils.js.html +10 -10
- package/coverage/lcov-report/automations/steps/zapier.js.html +1 -1
- package/coverage/lcov-report/automations/triggerInfo/app.js.html +1 -1
- package/coverage/lcov-report/automations/triggerInfo/cron.js.html +1 -1
- package/coverage/lcov-report/automations/triggerInfo/index.html +1 -1
- package/coverage/lcov-report/automations/triggerInfo/index.js.html +1 -1
- package/coverage/lcov-report/automations/triggerInfo/rowDeleted.js.html +1 -1
- package/coverage/lcov-report/automations/triggerInfo/rowSaved.js.html +1 -1
- package/coverage/lcov-report/automations/triggerInfo/rowUpdated.js.html +1 -1
- package/coverage/lcov-report/automations/triggerInfo/webhook.js.html +1 -1
- package/coverage/lcov-report/automations/triggers.js.html +1 -1
- package/coverage/lcov-report/constants/index.html +1 -1
- package/coverage/lcov-report/constants/index.js.html +1 -1
- package/coverage/lcov-report/constants/layouts.js.html +1 -1
- package/coverage/lcov-report/constants/screens.js.html +1 -1
- package/coverage/lcov-report/db/inMemoryView.js.html +1 -1
- package/coverage/lcov-report/db/index.html +1 -1
- package/coverage/lcov-report/db/index.js.html +1 -1
- package/coverage/lcov-report/db/linkedRows/LinkController.js.html +1 -1
- package/coverage/lcov-report/db/linkedRows/index.html +1 -1
- package/coverage/lcov-report/db/linkedRows/index.js.html +1 -1
- package/coverage/lcov-report/db/linkedRows/linkUtils.js.html +1 -1
- package/coverage/lcov-report/db/newid.js.html +1 -1
- package/coverage/lcov-report/db/utils.js.html +1 -1
- package/coverage/lcov-report/events/AutomationEmitter.js.html +1 -1
- package/coverage/lcov-report/events/index.html +1 -1
- package/coverage/lcov-report/events/index.js.html +1 -1
- package/coverage/lcov-report/events/utils.js.html +1 -1
- package/coverage/lcov-report/index.html +14 -14
- package/coverage/lcov-report/integrations/tests/TestConfiguration.js.html +1 -1
- package/coverage/lcov-report/integrations/tests/index.html +1 -1
- package/coverage/lcov-report/middleware/appInfo.js.html +1 -1
- package/coverage/lcov-report/middleware/builder.js.html +1 -1
- package/coverage/lcov-report/middleware/currentapp.js.html +1 -1
- package/coverage/lcov-report/middleware/index.html +1 -1
- package/coverage/lcov-report/middleware/joi-validator.js.html +1 -1
- package/coverage/lcov-report/middleware/publicApi.js.html +1 -1
- package/coverage/lcov-report/middleware/resourceId.js.html +1 -1
- package/coverage/lcov-report/middleware/selfhost.js.html +1 -1
- package/coverage/lcov-report/middleware/utils.js.html +1 -1
- package/coverage/lcov-report/utilities/budibaseDir.js.html +1 -1
- package/coverage/lcov-report/utilities/centralPath.js.html +1 -1
- package/coverage/lcov-report/utilities/csvParser.js.html +1 -1
- package/coverage/lcov-report/utilities/global.js.html +1 -1
- package/coverage/lcov-report/utilities/index.html +1 -1
- package/coverage/lcov-report/utilities/index.js.html +1 -1
- package/coverage/lcov-report/utilities/plugins.js.html +1 -1
- package/coverage/lcov-report/utilities/queue/inMemoryQueue.js.html +1 -1
- package/coverage/lcov-report/utilities/queue/index.html +1 -1
- package/coverage/lcov-report/utilities/routing/index.html +1 -1
- package/coverage/lcov-report/utilities/routing/index.js.html +1 -1
- package/coverage/lcov-report/utilities/rowProcessor/index.html +1 -1
- package/coverage/lcov-report/utilities/rowProcessor/index.js.html +1 -1
- package/coverage/lcov-report/utilities/rowProcessor/utils.js.html +1 -1
- package/coverage/lcov-report/utilities/scriptRunner.js.html +1 -1
- package/coverage/lcov-report/utilities/security.js.html +1 -1
- package/coverage/lcov-report/utilities/statusCodes.js.html +1 -1
- package/coverage/lcov-report/utilities/usageQuota/index.html +1 -1
- package/coverage/lcov-report/utilities/usageQuota/rows.js.html +1 -1
- package/coverage/lcov-report/utilities/usageQuota/usageQuoteReset.js.html +1 -1
- package/coverage/lcov-report/utilities/users.js.html +1 -1
- package/coverage/lcov-report/utilities/workerRequests.js.html +1 -1
- package/coverage/lcov.info +4 -4
- package/dist/api/controllers/row/ExternalRequest.js +1 -6
- package/dist/api/controllers/row/index.js +7 -16
- package/dist/integrations/elasticsearch.js +2 -26
- package/dist/integrations/s3.js +1 -157
- package/dist/package.json +6 -6
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +7 -7
- package/src/api/controllers/row/ExternalRequest.ts +3 -5
- package/src/api/controllers/row/index.ts +9 -17
- package/src/integrations/elasticsearch.ts +2 -32
- package/src/integrations/s3.ts +3 -179
- package/src/integrations/tests/s3.spec.ts +1 -85
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@budibase/server",
|
|
3
3
|
"email": "hi@budibase.com",
|
|
4
|
-
"version": "2.1.
|
|
4
|
+
"version": "2.1.20",
|
|
5
5
|
"description": "Budibase Web Server",
|
|
6
6
|
"main": "src/index.ts",
|
|
7
7
|
"repository": {
|
|
@@ -77,11 +77,11 @@
|
|
|
77
77
|
"license": "GPL-3.0",
|
|
78
78
|
"dependencies": {
|
|
79
79
|
"@apidevtools/swagger-parser": "10.0.3",
|
|
80
|
-
"@budibase/backend-core": "2.1.
|
|
81
|
-
"@budibase/client": "2.1.
|
|
82
|
-
"@budibase/pro": "2.1.
|
|
83
|
-
"@budibase/string-templates": "2.1.
|
|
84
|
-
"@budibase/types": "2.1.
|
|
80
|
+
"@budibase/backend-core": "^2.1.20",
|
|
81
|
+
"@budibase/client": "^2.1.20",
|
|
82
|
+
"@budibase/pro": "2.1.19",
|
|
83
|
+
"@budibase/string-templates": "^2.1.20",
|
|
84
|
+
"@budibase/types": "^2.1.20",
|
|
85
85
|
"@bull-board/api": "3.7.0",
|
|
86
86
|
"@bull-board/koa": "3.9.4",
|
|
87
87
|
"@elastic/elasticsearch": "7.10.0",
|
|
@@ -199,5 +199,5 @@
|
|
|
199
199
|
"optionalDependencies": {
|
|
200
200
|
"oracledb": "5.3.0"
|
|
201
201
|
},
|
|
202
|
-
"gitHead": "
|
|
202
|
+
"gitHead": "be9e2f83278ab4358e65ac2cd30f254d999a54a7"
|
|
203
203
|
}
|
|
@@ -282,11 +282,9 @@ module External {
|
|
|
282
282
|
const linkTablePrimary = linkTable.primary[0]
|
|
283
283
|
// one to many
|
|
284
284
|
if (isOneSide(field)) {
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
}
|
|
289
|
-
newRow[field.foreignKey || linkTablePrimary] = breakRowIdField(id)[0]
|
|
285
|
+
newRow[field.foreignKey || linkTablePrimary] = breakRowIdField(
|
|
286
|
+
row[key][0]
|
|
287
|
+
)[0]
|
|
290
288
|
}
|
|
291
289
|
// many to many
|
|
292
290
|
else if (field.through) {
|
|
@@ -30,24 +30,16 @@ export async function patch(ctx: any): Promise<any> {
|
|
|
30
30
|
if (body && !body._id) {
|
|
31
31
|
return save(ctx)
|
|
32
32
|
}
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
datasourceId: tableId,
|
|
38
|
-
}
|
|
39
|
-
)
|
|
40
|
-
if (!row) {
|
|
41
|
-
ctx.throw(404, "Row not found")
|
|
33
|
+
const { row, table } = await quotas.addQuery(
|
|
34
|
+
() => pickApi(tableId).patch(ctx),
|
|
35
|
+
{
|
|
36
|
+
datasourceId: tableId,
|
|
42
37
|
}
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
} catch (err) {
|
|
49
|
-
ctx.throw(400, err)
|
|
50
|
-
}
|
|
38
|
+
)
|
|
39
|
+
ctx.status = 200
|
|
40
|
+
ctx.eventEmitter && ctx.eventEmitter.emitRow(`row:update`, appId, row, table)
|
|
41
|
+
ctx.message = `${table.name} updated successfully.`
|
|
42
|
+
ctx.body = row
|
|
51
43
|
}
|
|
52
44
|
|
|
53
45
|
export const save = async (ctx: any) => {
|
|
@@ -5,13 +5,10 @@ import {
|
|
|
5
5
|
IntegrationBase,
|
|
6
6
|
} from "@budibase/types"
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
const { Client } = require("@elastic/elasticsearch")
|
|
9
9
|
|
|
10
10
|
interface ElasticsearchConfig {
|
|
11
11
|
url: string
|
|
12
|
-
ssl?: boolean
|
|
13
|
-
ca?: string
|
|
14
|
-
rejectUnauthorized?: boolean
|
|
15
12
|
}
|
|
16
13
|
|
|
17
14
|
const SCHEMA: Integration = {
|
|
@@ -26,21 +23,6 @@ const SCHEMA: Integration = {
|
|
|
26
23
|
required: true,
|
|
27
24
|
default: "http://localhost:9200",
|
|
28
25
|
},
|
|
29
|
-
ssl: {
|
|
30
|
-
type: DatasourceFieldType.BOOLEAN,
|
|
31
|
-
default: false,
|
|
32
|
-
required: false,
|
|
33
|
-
},
|
|
34
|
-
rejectUnauthorized: {
|
|
35
|
-
type: DatasourceFieldType.BOOLEAN,
|
|
36
|
-
default: true,
|
|
37
|
-
required: false,
|
|
38
|
-
},
|
|
39
|
-
ca: {
|
|
40
|
-
type: DatasourceFieldType.LONGFORM,
|
|
41
|
-
default: false,
|
|
42
|
-
required: false,
|
|
43
|
-
},
|
|
44
26
|
},
|
|
45
27
|
query: {
|
|
46
28
|
create: {
|
|
@@ -99,19 +81,7 @@ class ElasticSearchIntegration implements IntegrationBase {
|
|
|
99
81
|
|
|
100
82
|
constructor(config: ElasticsearchConfig) {
|
|
101
83
|
this.config = config
|
|
102
|
-
|
|
103
|
-
const clientConfig: ClientOptions = {
|
|
104
|
-
node: this.config.url,
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
if (this.config.ssl) {
|
|
108
|
-
clientConfig.ssl = {
|
|
109
|
-
rejectUnauthorized: this.config.rejectUnauthorized,
|
|
110
|
-
ca: this.config.ca || undefined,
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
this.client = new Client(clientConfig)
|
|
84
|
+
this.client = new Client({ node: config.url })
|
|
115
85
|
}
|
|
116
86
|
|
|
117
87
|
async create(query: { index: string; json: object }) {
|
package/src/integrations/s3.ts
CHANGED
|
@@ -1,12 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
Integration,
|
|
3
|
-
QueryType,
|
|
4
|
-
IntegrationBase,
|
|
5
|
-
DatasourceFieldType,
|
|
6
|
-
} from "@budibase/types"
|
|
7
|
-
|
|
1
|
+
import { Integration, QueryType, IntegrationBase } from "@budibase/types"
|
|
8
2
|
const AWS = require("aws-sdk")
|
|
9
|
-
const csv = require("csvtojson")
|
|
10
3
|
|
|
11
4
|
interface S3Config {
|
|
12
5
|
region: string
|
|
@@ -47,106 +40,16 @@ const SCHEMA: Integration = {
|
|
|
47
40
|
},
|
|
48
41
|
},
|
|
49
42
|
query: {
|
|
50
|
-
create: {
|
|
51
|
-
type: QueryType.FIELDS,
|
|
52
|
-
fields: {
|
|
53
|
-
bucket: {
|
|
54
|
-
display: "New Bucket",
|
|
55
|
-
type: DatasourceFieldType.STRING,
|
|
56
|
-
required: true,
|
|
57
|
-
},
|
|
58
|
-
location: {
|
|
59
|
-
required: true,
|
|
60
|
-
default: "us-east-1",
|
|
61
|
-
type: DatasourceFieldType.STRING,
|
|
62
|
-
},
|
|
63
|
-
grantFullControl: {
|
|
64
|
-
display: "Grant full control",
|
|
65
|
-
type: DatasourceFieldType.STRING,
|
|
66
|
-
},
|
|
67
|
-
grantRead: {
|
|
68
|
-
display: "Grant read",
|
|
69
|
-
type: DatasourceFieldType.STRING,
|
|
70
|
-
},
|
|
71
|
-
grantReadAcp: {
|
|
72
|
-
display: "Grant read ACP",
|
|
73
|
-
type: DatasourceFieldType.STRING,
|
|
74
|
-
},
|
|
75
|
-
grantWrite: {
|
|
76
|
-
display: "Grant write",
|
|
77
|
-
type: DatasourceFieldType.STRING,
|
|
78
|
-
},
|
|
79
|
-
grantWriteAcp: {
|
|
80
|
-
display: "Grant write ACP",
|
|
81
|
-
type: DatasourceFieldType.STRING,
|
|
82
|
-
},
|
|
83
|
-
},
|
|
84
|
-
},
|
|
85
43
|
read: {
|
|
86
44
|
type: QueryType.FIELDS,
|
|
87
45
|
fields: {
|
|
88
46
|
bucket: {
|
|
89
|
-
type:
|
|
90
|
-
required: true,
|
|
91
|
-
},
|
|
92
|
-
delimiter: {
|
|
93
|
-
type: DatasourceFieldType.STRING,
|
|
94
|
-
},
|
|
95
|
-
marker: {
|
|
96
|
-
type: DatasourceFieldType.STRING,
|
|
97
|
-
},
|
|
98
|
-
maxKeys: {
|
|
99
|
-
type: DatasourceFieldType.NUMBER,
|
|
100
|
-
display: "Max Keys",
|
|
101
|
-
},
|
|
102
|
-
prefix: {
|
|
103
|
-
type: DatasourceFieldType.STRING,
|
|
104
|
-
},
|
|
105
|
-
},
|
|
106
|
-
},
|
|
107
|
-
readCsv: {
|
|
108
|
-
displayName: "Read CSV",
|
|
109
|
-
type: QueryType.FIELDS,
|
|
110
|
-
fields: {
|
|
111
|
-
bucket: {
|
|
112
|
-
type: DatasourceFieldType.STRING,
|
|
113
|
-
required: true,
|
|
114
|
-
},
|
|
115
|
-
key: {
|
|
116
|
-
type: DatasourceFieldType.STRING,
|
|
117
|
-
required: true,
|
|
118
|
-
},
|
|
119
|
-
},
|
|
120
|
-
},
|
|
121
|
-
delete: {
|
|
122
|
-
type: QueryType.FIELDS,
|
|
123
|
-
fields: {
|
|
124
|
-
bucket: {
|
|
125
|
-
type: DatasourceFieldType.STRING,
|
|
126
|
-
required: true,
|
|
127
|
-
},
|
|
128
|
-
delete: {
|
|
129
|
-
type: DatasourceFieldType.JSON,
|
|
47
|
+
type: "string",
|
|
130
48
|
required: true,
|
|
131
49
|
},
|
|
132
50
|
},
|
|
133
51
|
},
|
|
134
52
|
},
|
|
135
|
-
extra: {
|
|
136
|
-
acl: {
|
|
137
|
-
required: false,
|
|
138
|
-
displayName: "ACL",
|
|
139
|
-
type: DatasourceFieldType.LIST,
|
|
140
|
-
data: {
|
|
141
|
-
create: [
|
|
142
|
-
"private",
|
|
143
|
-
"public-read",
|
|
144
|
-
"public-read-write",
|
|
145
|
-
"authenticated-read",
|
|
146
|
-
],
|
|
147
|
-
},
|
|
148
|
-
},
|
|
149
|
-
},
|
|
150
53
|
}
|
|
151
54
|
|
|
152
55
|
class S3Integration implements IntegrationBase {
|
|
@@ -164,93 +67,14 @@ class S3Integration implements IntegrationBase {
|
|
|
164
67
|
this.client = new AWS.S3(this.config)
|
|
165
68
|
}
|
|
166
69
|
|
|
167
|
-
async
|
|
168
|
-
bucket: string
|
|
169
|
-
location: string
|
|
170
|
-
grantFullControl: string
|
|
171
|
-
grantRead: string
|
|
172
|
-
grantReadAcp: string
|
|
173
|
-
grantWrite: string
|
|
174
|
-
grantWriteAcp: string
|
|
175
|
-
extra: {
|
|
176
|
-
acl: string
|
|
177
|
-
}
|
|
178
|
-
}) {
|
|
179
|
-
let params: any = {
|
|
180
|
-
Bucket: query.bucket,
|
|
181
|
-
ACL: query.extra?.acl,
|
|
182
|
-
GrantFullControl: query.grantFullControl,
|
|
183
|
-
GrantRead: query.grantRead,
|
|
184
|
-
GrantReadACP: query.grantReadAcp,
|
|
185
|
-
GrantWrite: query.grantWrite,
|
|
186
|
-
GrantWriteACP: query.grantWriteAcp,
|
|
187
|
-
}
|
|
188
|
-
if (query.location) {
|
|
189
|
-
params["CreateBucketConfiguration"] = {
|
|
190
|
-
LocationConstraint: query.location,
|
|
191
|
-
}
|
|
192
|
-
}
|
|
193
|
-
return await this.client.createBucket(params).promise()
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
async read(query: {
|
|
197
|
-
bucket: string
|
|
198
|
-
delimiter: string
|
|
199
|
-
expectedBucketOwner: string
|
|
200
|
-
marker: string
|
|
201
|
-
maxKeys: number
|
|
202
|
-
prefix: string
|
|
203
|
-
}) {
|
|
70
|
+
async read(query: { bucket: string }) {
|
|
204
71
|
const response = await this.client
|
|
205
72
|
.listObjects({
|
|
206
73
|
Bucket: query.bucket,
|
|
207
|
-
Delimiter: query.delimiter,
|
|
208
|
-
Marker: query.marker,
|
|
209
|
-
MaxKeys: query.maxKeys,
|
|
210
|
-
Prefix: query.prefix,
|
|
211
74
|
})
|
|
212
75
|
.promise()
|
|
213
76
|
return response.Contents
|
|
214
77
|
}
|
|
215
|
-
|
|
216
|
-
async readCsv(query: { bucket: string; key: string }) {
|
|
217
|
-
const stream = this.client
|
|
218
|
-
.getObject({
|
|
219
|
-
Bucket: query.bucket,
|
|
220
|
-
Key: query.key,
|
|
221
|
-
})
|
|
222
|
-
.createReadStream()
|
|
223
|
-
|
|
224
|
-
let csvError = false
|
|
225
|
-
return new Promise((resolve, reject) => {
|
|
226
|
-
stream.on("error", (err: Error) => {
|
|
227
|
-
reject(err)
|
|
228
|
-
})
|
|
229
|
-
const response = csv()
|
|
230
|
-
.fromStream(stream)
|
|
231
|
-
.on("error", () => {
|
|
232
|
-
csvError = true
|
|
233
|
-
})
|
|
234
|
-
stream.on("finish", () => {
|
|
235
|
-
resolve(response)
|
|
236
|
-
})
|
|
237
|
-
}).catch(err => {
|
|
238
|
-
if (csvError) {
|
|
239
|
-
throw new Error("Could not read CSV")
|
|
240
|
-
} else {
|
|
241
|
-
throw err
|
|
242
|
-
}
|
|
243
|
-
})
|
|
244
|
-
}
|
|
245
|
-
|
|
246
|
-
async delete(query: { bucket: string; delete: string }) {
|
|
247
|
-
return await this.client
|
|
248
|
-
.deleteObjects({
|
|
249
|
-
Bucket: query.bucket,
|
|
250
|
-
Delete: JSON.parse(query.delete),
|
|
251
|
-
})
|
|
252
|
-
.promise()
|
|
253
|
-
}
|
|
254
78
|
}
|
|
255
79
|
|
|
256
80
|
export default {
|
|
@@ -18,95 +18,11 @@ describe("S3 Integration", () => {
|
|
|
18
18
|
})
|
|
19
19
|
|
|
20
20
|
it("calls the read method with the correct params", async () => {
|
|
21
|
-
await config.integration.read({
|
|
21
|
+
const response = await config.integration.read({
|
|
22
22
|
bucket: "test",
|
|
23
|
-
delimiter: "/",
|
|
24
|
-
marker: "file.txt",
|
|
25
|
-
maxKeys: 999,
|
|
26
|
-
prefix: "directory/",
|
|
27
23
|
})
|
|
28
24
|
expect(config.integration.client.listObjects).toHaveBeenCalledWith({
|
|
29
25
|
Bucket: "test",
|
|
30
|
-
Delimiter: "/",
|
|
31
|
-
Marker: "file.txt",
|
|
32
|
-
MaxKeys: 999,
|
|
33
|
-
Prefix: "directory/",
|
|
34
|
-
})
|
|
35
|
-
})
|
|
36
|
-
|
|
37
|
-
it("calls the create method with the correct params", async () => {
|
|
38
|
-
await config.integration.create({
|
|
39
|
-
bucket: "test",
|
|
40
|
-
location: "af-south-1",
|
|
41
|
-
grantFullControl: "me",
|
|
42
|
-
grantRead: "him",
|
|
43
|
-
grantReadAcp: "her",
|
|
44
|
-
grantWrite: "she",
|
|
45
|
-
grantWriteAcp: "he",
|
|
46
|
-
objectLockEnabledForBucket: true,
|
|
47
|
-
extra: {
|
|
48
|
-
acl: "private",
|
|
49
|
-
},
|
|
50
|
-
})
|
|
51
|
-
expect(config.integration.client.createBucket).toHaveBeenCalledWith({
|
|
52
|
-
Bucket: "test",
|
|
53
|
-
CreateBucketConfiguration: {
|
|
54
|
-
LocationConstraint: "af-south-1",
|
|
55
|
-
},
|
|
56
|
-
GrantFullControl: "me",
|
|
57
|
-
GrantRead: "him",
|
|
58
|
-
GrantReadACP: "her",
|
|
59
|
-
GrantWrite: "she",
|
|
60
|
-
GrantWriteACP: "he",
|
|
61
|
-
ACL: "private",
|
|
62
|
-
})
|
|
63
|
-
})
|
|
64
|
-
|
|
65
|
-
it("does not add undefined location constraint when calling the create method", async () => {
|
|
66
|
-
await config.integration.create({
|
|
67
|
-
bucket: "test",
|
|
68
|
-
})
|
|
69
|
-
expect(config.integration.client.createBucket).toHaveBeenCalledWith({
|
|
70
|
-
Bucket: "test",
|
|
71
|
-
GrantFullControl: undefined,
|
|
72
|
-
GrantRead: undefined,
|
|
73
|
-
GrantReadACP: undefined,
|
|
74
|
-
GrantWrite: undefined,
|
|
75
|
-
GrantWriteACP: undefined,
|
|
76
|
-
ACL: undefined,
|
|
77
|
-
})
|
|
78
|
-
})
|
|
79
|
-
|
|
80
|
-
it("calls the delete method with the correct params ", async () => {
|
|
81
|
-
await config.integration.delete({
|
|
82
|
-
bucket: "test",
|
|
83
|
-
delete: `{
|
|
84
|
-
"Objects": [
|
|
85
|
-
{
|
|
86
|
-
"Key": "HappyFace.jpg",
|
|
87
|
-
"VersionId": "2LWg7lQLnY41.maGB5Z6SWW.dcq0vx7b"
|
|
88
|
-
},
|
|
89
|
-
{
|
|
90
|
-
"Key": "HappyFace.jpg",
|
|
91
|
-
"VersionId": "yoz3HB.ZhCS_tKVEmIOr7qYyyAaZSKVd"
|
|
92
|
-
}
|
|
93
|
-
]
|
|
94
|
-
}`,
|
|
95
|
-
})
|
|
96
|
-
expect(config.integration.client.deleteObjects).toHaveBeenCalledWith({
|
|
97
|
-
Bucket: "test",
|
|
98
|
-
Delete: {
|
|
99
|
-
Objects: [
|
|
100
|
-
{
|
|
101
|
-
Key: "HappyFace.jpg",
|
|
102
|
-
VersionId: "2LWg7lQLnY41.maGB5Z6SWW.dcq0vx7b",
|
|
103
|
-
},
|
|
104
|
-
{
|
|
105
|
-
Key: "HappyFace.jpg",
|
|
106
|
-
VersionId: "yoz3HB.ZhCS_tKVEmIOr7qYyyAaZSKVd",
|
|
107
|
-
},
|
|
108
|
-
],
|
|
109
|
-
},
|
|
110
26
|
})
|
|
111
27
|
})
|
|
112
28
|
})
|