@budibase/server 1.2.36 → 1.2.39-alpha.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/__mocks__/mongodb.ts +4 -0
- package/__mocks__/node-fetch.ts +8 -1
- package/builder/assets/index.b2106af1.js +977 -0
- package/builder/assets/{index.08dd0c5e.css → index.f1c7e247.css} +1 -1
- package/builder/index.html +2 -2
- package/coverage/clover.xml +385 -380
- package/coverage/coverage-final.json +21 -21
- package/coverage/lcov-report/api/controllers/apikeys.js.html +1 -1
- package/coverage/lcov-report/api/controllers/auth.js.html +1 -1
- package/coverage/lcov-report/api/controllers/automation.js.html +3 -3
- package/coverage/lcov-report/api/controllers/backup.js.html +3 -3
- package/coverage/lcov-report/api/controllers/cloud.js.html +4 -4
- package/coverage/lcov-report/api/controllers/component.js.html +3 -3
- package/coverage/lcov-report/api/controllers/datasource.js.html +3 -3
- package/coverage/lcov-report/api/controllers/dev.js.html +4 -4
- package/coverage/lcov-report/api/controllers/index.html +1 -1
- package/coverage/lcov-report/api/controllers/integration.js.html +3 -3
- 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 +25 -25
- package/coverage/lcov-report/api/controllers/row/internal.js.html +3 -3
- package/coverage/lcov-report/api/controllers/row/internalSearch.js.html +209 -191
- package/coverage/lcov-report/api/controllers/row/staticFormula.js.html +1 -1
- package/coverage/lcov-report/api/controllers/row/utils.js.html +27 -18
- package/coverage/lcov-report/api/controllers/screen.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 +2 -2
- 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 +19 -19
- 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 +3 -3
- package/coverage/lcov-report/api/controllers/view/utils.js.html +5 -5
- package/coverage/lcov-report/api/controllers/view/viewBuilder.js.html +1 -1
- package/coverage/lcov-report/api/controllers/webhook.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/auth.js.html +1 -1
- package/coverage/lcov-report/api/routes/automation.js.html +1 -1
- package/coverage/lcov-report/api/routes/backup.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/api/routes/webhook.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 +1 -1
- 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 +1 -1
- 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 +30 -30
- 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 +3 -3
- package/coverage/lcov-report/db/newid.js.html +3 -3
- package/coverage/lcov-report/db/utils.js.html +99 -99
- 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 +19 -19
- 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 +3 -3
- 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 +16 -16
- package/coverage/lcov-report/utilities/index.html +1 -1
- package/coverage/lcov-report/utilities/index.js.html +23 -23
- 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 +3 -3
- 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 +9 -9
- 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 +7 -7
- package/coverage/lcov-report/utilities/workerRequests.js.html +1 -1
- package/coverage/lcov.info +598 -593
- package/dist/api/controllers/analytics.js +1 -1
- package/dist/api/controllers/application.js +8 -8
- package/dist/api/controllers/automation.js +2 -2
- package/dist/api/controllers/backup.js +2 -2
- package/dist/api/controllers/cloud.js +3 -3
- package/dist/api/controllers/component.js +2 -2
- package/dist/api/controllers/datasource.js +2 -2
- package/dist/api/controllers/deploy/index.js +6 -6
- package/dist/api/controllers/dev.js +3 -3
- package/dist/api/controllers/integration.js +2 -2
- package/dist/api/controllers/public/utils.js +1 -1
- package/dist/api/controllers/row/ExternalRequest.js +3 -3
- package/dist/api/controllers/row/internal.js +2 -2
- package/dist/api/controllers/row/internalSearch.js +5 -0
- package/dist/api/controllers/row/utils.js +3 -1
- package/dist/api/controllers/static/index.js +2 -2
- package/dist/api/controllers/table/external.js +1 -1
- package/dist/api/controllers/view/index.js +2 -2
- package/dist/api/controllers/view/utils.js +3 -3
- package/dist/automations/logging/index.js +3 -0
- package/dist/db/linkedRows/linkUtils.js +2 -2
- package/dist/db/utils.js +37 -37
- package/dist/db/views/staticViews.js +4 -4
- package/dist/definitions/automations.js +6 -6
- package/dist/definitions/datasource.js +6 -70
- package/dist/integrations/airtable.js +13 -13
- package/dist/integrations/arangodb.js +8 -8
- package/dist/integrations/base/query.js +27 -0
- package/dist/integrations/base/sql.js +33 -32
- package/dist/integrations/base/sqlTable.js +4 -4
- package/dist/integrations/base/utils.js +13 -27
- package/dist/integrations/couchdb.js +8 -8
- package/dist/integrations/dynamodb.js +21 -21
- package/dist/integrations/elasticsearch.js +12 -12
- package/dist/integrations/firebase.js +12 -12
- package/dist/integrations/googlesheets.js +14 -14
- package/dist/integrations/index.js +34 -34
- package/dist/integrations/microsoftSqlServer.js +19 -16
- package/dist/integrations/mongodb.js +44 -17
- package/dist/integrations/mysql.js +15 -15
- package/dist/integrations/oracle.js +13 -13
- package/dist/integrations/postgres.js +20 -17
- package/dist/integrations/redis.js +10 -10
- package/dist/integrations/rest.js +15 -14
- package/dist/integrations/s3.js +2 -2
- package/dist/integrations/snowflake.js +5 -5
- package/dist/integrations/utils.js +14 -14
- package/dist/middleware/builder.js +2 -2
- package/dist/migrations/functions/appUrls.js +2 -2
- package/dist/migrations/functions/backfill/app/queries.js +3 -1
- package/dist/migrations/functions/backfill/app.js +1 -1
- package/dist/migrations/functions/backfill/global/users.js +1 -1
- package/dist/package.json +7 -7
- package/dist/tests/utilities/TestConfiguration.js +2 -2
- package/dist/threads/automation.js +2 -2
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/dist/utilities/routing/index.js +2 -2
- package/dist/utilities/security.js +8 -8
- package/package.json +8 -8
- package/src/api/controllers/analytics.ts +2 -2
- package/src/api/controllers/application.ts +9 -9
- package/src/api/controllers/automation.js +2 -2
- package/src/api/controllers/backup.js +2 -2
- package/src/api/controllers/cloud.js +3 -3
- package/src/api/controllers/component.js +2 -2
- package/src/api/controllers/datasource.js +2 -2
- package/src/api/controllers/deploy/index.ts +7 -7
- package/src/api/controllers/dev.js +3 -3
- package/src/api/controllers/integration.js +2 -2
- package/src/api/controllers/public/utils.ts +2 -2
- package/src/api/controllers/query/import/sources/openapi2.ts +1 -1
- package/src/api/controllers/query/import/sources/openapi3.ts +1 -1
- package/src/api/controllers/row/ExternalRequest.ts +5 -7
- package/src/api/controllers/row/internal.js +2 -2
- package/src/api/controllers/row/internalSearch.js +6 -0
- package/src/api/controllers/row/utils.js +4 -1
- package/src/api/controllers/static/index.ts +2 -2
- package/src/api/controllers/table/external.js +1 -1
- package/src/api/controllers/view/index.js +2 -2
- package/src/api/controllers/view/utils.js +4 -4
- package/src/api/routes/tests/internalSearch.spec.js +157 -0
- package/src/automations/logging/index.ts +3 -0
- package/src/db/linkedRows/linkUtils.js +2 -2
- package/src/db/utils.js +38 -38
- package/src/db/views/staticViews.js +4 -9
- package/src/definitions/automations.ts +2 -2
- package/src/definitions/common.ts +14 -65
- package/src/definitions/datasource.ts +5 -250
- package/src/integrations/airtable.ts +16 -16
- package/src/integrations/arangodb.ts +11 -11
- package/src/integrations/base/query.ts +16 -0
- package/src/integrations/base/sql.ts +21 -20
- package/src/integrations/base/sqlTable.ts +1 -6
- package/src/integrations/base/utils.ts +9 -19
- package/src/integrations/couchdb.ts +11 -11
- package/src/integrations/dynamodb.ts +24 -24
- package/src/integrations/elasticsearch.ts +15 -15
- package/src/integrations/firebase.ts +15 -15
- package/src/integrations/googlesheets.ts +19 -18
- package/src/integrations/index.ts +34 -34
- package/src/integrations/microsoftSqlServer.ts +22 -20
- package/src/integrations/mongodb.ts +47 -20
- package/src/integrations/mysql.ts +20 -19
- package/src/integrations/oracle.ts +16 -16
- package/src/integrations/postgres.ts +22 -21
- package/src/integrations/queries/sql.ts +1 -2
- package/src/integrations/redis.ts +10 -14
- package/src/integrations/rest.ts +22 -20
- package/src/integrations/s3.ts +2 -3
- package/src/integrations/snowflake.ts +5 -5
- package/src/integrations/tests/mongo.spec.js +218 -0
- package/src/integrations/tests/sql.spec.js +8 -8
- package/src/integrations/utils.ts +8 -9
- package/src/middleware/builder.js +2 -2
- package/src/migrations/functions/appUrls.ts +2 -2
- package/src/migrations/functions/backfill/app/queries.ts +3 -2
- package/src/migrations/functions/backfill/app.ts +1 -1
- package/src/migrations/functions/backfill/global/users.ts +1 -1
- package/src/migrations/functions/tests/appUrls.spec.js +3 -3
- package/src/migrations/tests/index.spec.ts +2 -2
- package/src/tests/utilities/TestConfiguration.js +2 -2
- package/src/threads/automation.ts +3 -3
- package/src/utilities/routing/index.js +2 -2
- package/src/utilities/security.js +8 -8
- package/builder/assets/index.3fdb9fab.js +0 -975
- package/dist/integrations/base/IntegrationBase.js +0 -2
- package/dist/integrations/base/datasourcePlus.js +0 -2
- package/src/integrations/base/IntegrationBase.ts +0 -6
- package/src/integrations/base/datasourcePlus.ts +0 -13
|
@@ -102,4 +102,222 @@ describe("MongoDB Integration", () => {
|
|
|
102
102
|
expect(error).toBeDefined()
|
|
103
103
|
restore()
|
|
104
104
|
})
|
|
105
|
+
|
|
106
|
+
it("creates ObjectIds if the _id fields contains a match on ObjectId", async () => {
|
|
107
|
+
const query = {
|
|
108
|
+
json: {
|
|
109
|
+
filter: {
|
|
110
|
+
_id: "ObjectId('ACBD12345678ABCD12345678')",
|
|
111
|
+
name: "ObjectId('name')"
|
|
112
|
+
},
|
|
113
|
+
update: {
|
|
114
|
+
_id: "ObjectId('FFFF12345678ABCD12345678')",
|
|
115
|
+
name: "ObjectId('updatedName')",
|
|
116
|
+
},
|
|
117
|
+
options: {
|
|
118
|
+
upsert: false,
|
|
119
|
+
},
|
|
120
|
+
},
|
|
121
|
+
extra: { collection: "testCollection", actionTypes: "updateOne" },
|
|
122
|
+
}
|
|
123
|
+
await config.integration.update(query)
|
|
124
|
+
expect(config.integration.client.updateOne).toHaveBeenCalled()
|
|
125
|
+
|
|
126
|
+
const args = config.integration.client.updateOne.mock.calls[0]
|
|
127
|
+
expect(args[0]).toEqual({
|
|
128
|
+
_id: mongo.ObjectID.createFromHexString("ACBD12345678ABCD12345678"),
|
|
129
|
+
name: "ObjectId('name')",
|
|
130
|
+
})
|
|
131
|
+
expect(args[1]).toEqual({
|
|
132
|
+
_id: mongo.ObjectID.createFromHexString("FFFF12345678ABCD12345678"),
|
|
133
|
+
name: "ObjectId('updatedName')",
|
|
134
|
+
})
|
|
135
|
+
expect(args[2]).toEqual({
|
|
136
|
+
upsert: false
|
|
137
|
+
})
|
|
138
|
+
})
|
|
139
|
+
|
|
140
|
+
it("creates ObjectIds if the $ operator fields contains a match on ObjectId", async () => {
|
|
141
|
+
const query = {
|
|
142
|
+
json: {
|
|
143
|
+
filter: {
|
|
144
|
+
_id: {
|
|
145
|
+
$eq: "ObjectId('ACBD12345678ABCD12345678')",
|
|
146
|
+
}
|
|
147
|
+
},
|
|
148
|
+
update: {
|
|
149
|
+
$set: {
|
|
150
|
+
_id: "ObjectId('FFFF12345678ABCD12345678')",
|
|
151
|
+
},
|
|
152
|
+
},
|
|
153
|
+
options: {
|
|
154
|
+
upsert: true,
|
|
155
|
+
},
|
|
156
|
+
},
|
|
157
|
+
extra: { collection: "testCollection", actionTypes: "updateOne" },
|
|
158
|
+
}
|
|
159
|
+
await config.integration.update(query)
|
|
160
|
+
expect(config.integration.client.updateOne).toHaveBeenCalled()
|
|
161
|
+
|
|
162
|
+
const args = config.integration.client.updateOne.mock.calls[0]
|
|
163
|
+
expect(args[0]).toEqual({
|
|
164
|
+
_id: {
|
|
165
|
+
$eq: mongo.ObjectID.createFromHexString("ACBD12345678ABCD12345678"),
|
|
166
|
+
}
|
|
167
|
+
})
|
|
168
|
+
expect(args[1]).toEqual({
|
|
169
|
+
$set: {
|
|
170
|
+
_id: mongo.ObjectID.createFromHexString("FFFF12345678ABCD12345678"),
|
|
171
|
+
}
|
|
172
|
+
})
|
|
173
|
+
expect(args[2]).toEqual({
|
|
174
|
+
upsert: true
|
|
175
|
+
})
|
|
176
|
+
})
|
|
177
|
+
|
|
178
|
+
it("supports findOneAndUpdate", async () => {
|
|
179
|
+
const query = {
|
|
180
|
+
json: {
|
|
181
|
+
filter: {
|
|
182
|
+
_id: {
|
|
183
|
+
$eq: "ObjectId('ACBD12345678ABCD12345678')",
|
|
184
|
+
}
|
|
185
|
+
},
|
|
186
|
+
update: {
|
|
187
|
+
$set: {
|
|
188
|
+
name: "UPDATED",
|
|
189
|
+
age: 99
|
|
190
|
+
},
|
|
191
|
+
},
|
|
192
|
+
options: {
|
|
193
|
+
upsert: false,
|
|
194
|
+
},
|
|
195
|
+
},
|
|
196
|
+
extra: { collection: "testCollection", actionTypes: "findOneAndUpdate" },
|
|
197
|
+
}
|
|
198
|
+
await config.integration.read(query)
|
|
199
|
+
expect(config.integration.client.findOneAndUpdate).toHaveBeenCalled()
|
|
200
|
+
|
|
201
|
+
const args = config.integration.client.findOneAndUpdate.mock.calls[0]
|
|
202
|
+
expect(args[0]).toEqual({
|
|
203
|
+
_id: {
|
|
204
|
+
$eq: mongo.ObjectID.createFromHexString("ACBD12345678ABCD12345678"),
|
|
205
|
+
}
|
|
206
|
+
})
|
|
207
|
+
expect(args[1]).toEqual({
|
|
208
|
+
$set: {
|
|
209
|
+
name: "UPDATED",
|
|
210
|
+
age: 99
|
|
211
|
+
}
|
|
212
|
+
})
|
|
213
|
+
expect(args[2]).toEqual({
|
|
214
|
+
upsert: false
|
|
215
|
+
})
|
|
216
|
+
})
|
|
217
|
+
|
|
218
|
+
it("can parse nested objects with arrays", async () => {
|
|
219
|
+
const query = {
|
|
220
|
+
json: `{
|
|
221
|
+
"_id": {
|
|
222
|
+
"$eq": "ObjectId('ACBD12345678ABCD12345678')"
|
|
223
|
+
}
|
|
224
|
+
},
|
|
225
|
+
{
|
|
226
|
+
"$set": {
|
|
227
|
+
"value": {
|
|
228
|
+
"data": [
|
|
229
|
+
{ "cid": 1 },
|
|
230
|
+
{ "cid": 2 },
|
|
231
|
+
{ "nested": {
|
|
232
|
+
"name": "test"
|
|
233
|
+
}}
|
|
234
|
+
]
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
},
|
|
238
|
+
{
|
|
239
|
+
"upsert": true
|
|
240
|
+
}`,
|
|
241
|
+
extra: { collection: "testCollection", actionTypes: "updateOne" },
|
|
242
|
+
}
|
|
243
|
+
await config.integration.update(query)
|
|
244
|
+
expect(config.integration.client.updateOne).toHaveBeenCalled()
|
|
245
|
+
|
|
246
|
+
const args = config.integration.client.updateOne.mock.calls[0]
|
|
247
|
+
expect(args[0]).toEqual({
|
|
248
|
+
_id: {
|
|
249
|
+
$eq: mongo.ObjectID.createFromHexString("ACBD12345678ABCD12345678"),
|
|
250
|
+
}
|
|
251
|
+
})
|
|
252
|
+
expect(args[1]).toEqual({
|
|
253
|
+
$set: {
|
|
254
|
+
value: {
|
|
255
|
+
data: [
|
|
256
|
+
{ cid: 1 },
|
|
257
|
+
{ cid: 2 },
|
|
258
|
+
{ nested: {
|
|
259
|
+
name: "test"
|
|
260
|
+
}}
|
|
261
|
+
]
|
|
262
|
+
},
|
|
263
|
+
},
|
|
264
|
+
})
|
|
265
|
+
expect(args[2]).toEqual({
|
|
266
|
+
upsert: true
|
|
267
|
+
})
|
|
268
|
+
})
|
|
269
|
+
|
|
270
|
+
it("ignores braces within strings when parsing nested objects", async () => {
|
|
271
|
+
const query = {
|
|
272
|
+
json: `{
|
|
273
|
+
"_id": {
|
|
274
|
+
"$eq": "ObjectId('ACBD12345678ABCD12345678')"
|
|
275
|
+
}
|
|
276
|
+
},
|
|
277
|
+
{
|
|
278
|
+
"$set": {
|
|
279
|
+
"value": {
|
|
280
|
+
"data": [
|
|
281
|
+
{ "cid": 1 },
|
|
282
|
+
{ "cid": 2 },
|
|
283
|
+
{ "nested": {
|
|
284
|
+
"name": "te}st"
|
|
285
|
+
}}
|
|
286
|
+
]
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
},
|
|
290
|
+
{
|
|
291
|
+
"upsert": true,
|
|
292
|
+
"extra": "ad\\"{\\"d"
|
|
293
|
+
}`,
|
|
294
|
+
extra: { collection: "testCollection", actionTypes: "updateOne" },
|
|
295
|
+
}
|
|
296
|
+
await config.integration.update(query)
|
|
297
|
+
expect(config.integration.client.updateOne).toHaveBeenCalled()
|
|
298
|
+
|
|
299
|
+
const args = config.integration.client.updateOne.mock.calls[0]
|
|
300
|
+
expect(args[0]).toEqual({
|
|
301
|
+
_id: {
|
|
302
|
+
$eq: mongo.ObjectID.createFromHexString("ACBD12345678ABCD12345678"),
|
|
303
|
+
}
|
|
304
|
+
})
|
|
305
|
+
expect(args[1]).toEqual({
|
|
306
|
+
$set: {
|
|
307
|
+
value: {
|
|
308
|
+
data: [
|
|
309
|
+
{ cid: 1 },
|
|
310
|
+
{ cid: 2 },
|
|
311
|
+
{ nested: {
|
|
312
|
+
name: "te}st"
|
|
313
|
+
}}
|
|
314
|
+
]
|
|
315
|
+
},
|
|
316
|
+
},
|
|
317
|
+
})
|
|
318
|
+
expect(args[2]).toEqual({
|
|
319
|
+
upsert: true,
|
|
320
|
+
extra: "ad\"{\"d"
|
|
321
|
+
})
|
|
322
|
+
})
|
|
105
323
|
})
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
const Sql = require("../base/sql")
|
|
2
|
-
const {
|
|
1
|
+
const Sql = require("../base/sql").default
|
|
2
|
+
const { SqlClient } = require("../utils")
|
|
3
3
|
|
|
4
4
|
const TABLE_NAME = "test"
|
|
5
5
|
|
|
@@ -47,7 +47,7 @@ function generateDeleteJson(table = TABLE_NAME, filters = {}) {
|
|
|
47
47
|
|
|
48
48
|
describe("SQL query builder", () => {
|
|
49
49
|
const limit = 500
|
|
50
|
-
const client =
|
|
50
|
+
const client = SqlClient.POSTGRES
|
|
51
51
|
let sql
|
|
52
52
|
|
|
53
53
|
beforeEach(() => {
|
|
@@ -174,7 +174,7 @@ describe("SQL query builder", () => {
|
|
|
174
174
|
})
|
|
175
175
|
|
|
176
176
|
it("should work with MS-SQL", () => {
|
|
177
|
-
const query = new Sql(
|
|
177
|
+
const query = new Sql(SqlClient.MS_SQL, 10)._query(generateReadJson())
|
|
178
178
|
expect(query).toEqual({
|
|
179
179
|
bindings: [10],
|
|
180
180
|
sql: `select * from (select top (@p0) * from [${TABLE_NAME}]) as [${TABLE_NAME}]`
|
|
@@ -182,7 +182,7 @@ describe("SQL query builder", () => {
|
|
|
182
182
|
})
|
|
183
183
|
|
|
184
184
|
it("should work with MySQL", () => {
|
|
185
|
-
const query = new Sql(
|
|
185
|
+
const query = new Sql(SqlClient.MY_SQL, 10)._query(generateReadJson())
|
|
186
186
|
expect(query).toEqual({
|
|
187
187
|
bindings: [10],
|
|
188
188
|
sql: `select * from (select * from \`${TABLE_NAME}\` limit ?) as \`${TABLE_NAME}\``
|
|
@@ -241,7 +241,7 @@ describe("SQL query builder", () => {
|
|
|
241
241
|
})
|
|
242
242
|
|
|
243
243
|
it("should use like expression for MS-SQL when filter is contains", () => {
|
|
244
|
-
const query = new Sql(
|
|
244
|
+
const query = new Sql(SqlClient.MS_SQL, 10)._query(generateReadJson({
|
|
245
245
|
filters: {
|
|
246
246
|
contains: {
|
|
247
247
|
age: 20,
|
|
@@ -256,7 +256,7 @@ describe("SQL query builder", () => {
|
|
|
256
256
|
})
|
|
257
257
|
|
|
258
258
|
it("should use JSON_CONTAINS expression for MySQL when filter is contains", () => {
|
|
259
|
-
const query = new Sql(
|
|
259
|
+
const query = new Sql(SqlClient.MY_SQL, 10)._query(generateReadJson({
|
|
260
260
|
filters: {
|
|
261
261
|
contains: {
|
|
262
262
|
age: 20,
|
|
@@ -271,7 +271,7 @@ describe("SQL query builder", () => {
|
|
|
271
271
|
})
|
|
272
272
|
|
|
273
273
|
it("should use jsonb operator expression for PostgreSQL when filter is contains", () => {
|
|
274
|
-
const query = new Sql(
|
|
274
|
+
const query = new Sql(SqlClient.POSTGRES, 10)._query(generateReadJson({
|
|
275
275
|
filters: {
|
|
276
276
|
contains: {
|
|
277
277
|
age: 20,
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { DocumentTypes, SEPARATOR } from "../db/utils"
|
|
1
|
+
import { SourceName, SqlQuery, Datasource, Table } from "@budibase/types"
|
|
2
|
+
import { DocumentType, SEPARATOR } from "../db/utils"
|
|
4
3
|
import { FieldTypes, BuildSchemaErrors, InvalidColumns } from "../constants"
|
|
5
4
|
|
|
6
5
|
const DOUBLE_SEPARATOR = `${SEPARATOR}${SEPARATOR}`
|
|
@@ -68,7 +67,7 @@ const SQL_TYPE_MAP = {
|
|
|
68
67
|
...SQL_MISC_TYPE_MAP,
|
|
69
68
|
}
|
|
70
69
|
|
|
71
|
-
export enum
|
|
70
|
+
export enum SqlClient {
|
|
72
71
|
MS_SQL = "mssql",
|
|
73
72
|
POSTGRES = "pg",
|
|
74
73
|
MY_SQL = "mysql2",
|
|
@@ -76,7 +75,7 @@ export enum SqlClients {
|
|
|
76
75
|
}
|
|
77
76
|
|
|
78
77
|
export function isExternalTable(tableId: string) {
|
|
79
|
-
return tableId.includes(
|
|
78
|
+
return tableId.includes(DocumentType.DATASOURCE)
|
|
80
79
|
}
|
|
81
80
|
|
|
82
81
|
export function buildExternalTableId(datasourceId: string, tableName: string) {
|
|
@@ -169,10 +168,10 @@ export function isSQL(datasource: Datasource): boolean {
|
|
|
169
168
|
return false
|
|
170
169
|
}
|
|
171
170
|
const SQL = [
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
171
|
+
SourceName.POSTGRES,
|
|
172
|
+
SourceName.SQL_SERVER,
|
|
173
|
+
SourceName.MYSQL,
|
|
174
|
+
SourceName.ORACLE,
|
|
176
175
|
]
|
|
177
176
|
return SQL.indexOf(datasource.source) !== -1
|
|
178
177
|
}
|
|
@@ -6,7 +6,7 @@ const {
|
|
|
6
6
|
setDebounce,
|
|
7
7
|
} = require("../utilities/redis")
|
|
8
8
|
const { doWithDB } = require("@budibase/backend-core/db")
|
|
9
|
-
const {
|
|
9
|
+
const { DocumentType, getGlobalIDFromUserMetadataID } = require("../db/utils")
|
|
10
10
|
const { PermissionTypes } = require("@budibase/backend-core/permissions")
|
|
11
11
|
const { app: appCache } = require("@budibase/backend-core/cache")
|
|
12
12
|
|
|
@@ -49,7 +49,7 @@ async function updateAppUpdatedAt(ctx) {
|
|
|
49
49
|
return
|
|
50
50
|
}
|
|
51
51
|
await doWithDB(appId, async db => {
|
|
52
|
-
const metadata = await db.get(
|
|
52
|
+
const metadata = await db.get(DocumentType.APP_METADATA)
|
|
53
53
|
metadata.updatedAt = new Date().toISOString()
|
|
54
54
|
|
|
55
55
|
metadata.updatedBy = getGlobalIDFromUserMetadataID(ctx.user.userId)
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const {
|
|
1
|
+
const { DocumentType } = require("@budibase/backend-core/db")
|
|
2
2
|
import { getAppUrl } from "../../api/controllers/application"
|
|
3
3
|
|
|
4
4
|
/**
|
|
@@ -11,7 +11,7 @@ import { getAppUrl } from "../../api/controllers/application"
|
|
|
11
11
|
export const run = async (appDb: any) => {
|
|
12
12
|
let metadata
|
|
13
13
|
try {
|
|
14
|
-
metadata = await appDb.get(
|
|
14
|
+
metadata = await appDb.get(DocumentType.APP_METADATA)
|
|
15
15
|
} catch (e) {
|
|
16
16
|
// sometimes the metadata document doesn't exist
|
|
17
17
|
// exit early instead of failing the migration
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { events } from "@budibase/backend-core"
|
|
2
2
|
import { getQueryParams } from "../../../../db/utils"
|
|
3
|
-
import { Query, Datasource } from "@budibase/types"
|
|
3
|
+
import { Query, Datasource, SourceName } from "@budibase/types"
|
|
4
4
|
|
|
5
5
|
const getQueries = async (appDb: any): Promise<Query[]> => {
|
|
6
6
|
const response = await appDb.allDocs(
|
|
@@ -31,8 +31,9 @@ export const backfill = async (appDb: any, timestamp: string | number) => {
|
|
|
31
31
|
// and the query has not
|
|
32
32
|
if (e.status === 404) {
|
|
33
33
|
datasource = {
|
|
34
|
+
type: "unknown",
|
|
34
35
|
_id: query.datasourceId,
|
|
35
|
-
source:
|
|
36
|
+
source: SourceName.UNKNOWN,
|
|
36
37
|
}
|
|
37
38
|
} else {
|
|
38
39
|
throw e
|
|
@@ -62,7 +62,7 @@ export const run = async (appDb: any) => {
|
|
|
62
62
|
await events.backfillCache.start(EVENTS)
|
|
63
63
|
|
|
64
64
|
let timestamp: string | number = DEFAULT_TIMESTAMP
|
|
65
|
-
const app: App = await appDb.get(dbUtils.
|
|
65
|
+
const app: App = await appDb.get(dbUtils.DocumentType.APP_METADATA)
|
|
66
66
|
if (app.createdAt) {
|
|
67
67
|
timestamp = app.createdAt as string
|
|
68
68
|
}
|
|
@@ -4,7 +4,7 @@ import { DEFAULT_TIMESTAMP } from ".."
|
|
|
4
4
|
|
|
5
5
|
// manually define user doc params - normally server doesn't read users from the db
|
|
6
6
|
const getUserParams = (props: any) => {
|
|
7
|
-
return dbUtils.getDocParams(dbUtils.
|
|
7
|
+
return dbUtils.getDocParams(dbUtils.DocumentType.USER, null, props)
|
|
8
8
|
}
|
|
9
9
|
|
|
10
10
|
export const getUsers = async (globalDb: any): Promise<User[]> => {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const {
|
|
1
|
+
const { DocumentType, doWithDB } = require("@budibase/backend-core/db")
|
|
2
2
|
const TestConfig = require("../../../tests/utilities/TestConfiguration")
|
|
3
3
|
|
|
4
4
|
const migration = require("../appUrls")
|
|
@@ -15,11 +15,11 @@ describe("run", () => {
|
|
|
15
15
|
it("runs successfully", async () => {
|
|
16
16
|
const app = await config.createApp("testApp")
|
|
17
17
|
const metadata = await doWithDB(app.appId, async db => {
|
|
18
|
-
const metadataDoc = await db.get(
|
|
18
|
+
const metadataDoc = await db.get( DocumentType.APP_METADATA)
|
|
19
19
|
delete metadataDoc.url
|
|
20
20
|
await db.put(metadataDoc)
|
|
21
21
|
await migration.run(db)
|
|
22
|
-
return await db.get(
|
|
22
|
+
return await db.get( DocumentType.APP_METADATA)
|
|
23
23
|
})
|
|
24
24
|
expect(metadata.url).toEqual("/testapp")
|
|
25
25
|
})
|
|
@@ -2,7 +2,7 @@ import {
|
|
|
2
2
|
events,
|
|
3
3
|
migrations,
|
|
4
4
|
tenancy,
|
|
5
|
-
|
|
5
|
+
DocumentType,
|
|
6
6
|
context,
|
|
7
7
|
db,
|
|
8
8
|
} from "@budibase/backend-core"
|
|
@@ -17,7 +17,7 @@ const timestamp = mocks.date.MOCK_DATE.toISOString()
|
|
|
17
17
|
const clearMigrations = async () => {
|
|
18
18
|
const dbs = [context.getDevAppDB(), context.getProdAppDB()]
|
|
19
19
|
for (const db of dbs) {
|
|
20
|
-
const doc = await db.get(
|
|
20
|
+
const doc = await db.get(DocumentType.MIGRATIONS)
|
|
21
21
|
const newDoc = { _id: doc._id, _rev: doc._rev }
|
|
22
22
|
await db.put(newDoc)
|
|
23
23
|
}
|
|
@@ -25,7 +25,7 @@ const newid = require("../../db/newid")
|
|
|
25
25
|
const context = require("@budibase/backend-core/context")
|
|
26
26
|
const { generateDevInfoID, SEPARATOR } = require("@budibase/backend-core/db")
|
|
27
27
|
const { encrypt } = require("@budibase/backend-core/encryption")
|
|
28
|
-
const {
|
|
28
|
+
const { DocumentType } = require("../../db/utils")
|
|
29
29
|
|
|
30
30
|
const GLOBAL_USER_ID = "us_uuid1"
|
|
31
31
|
const EMAIL = "babs@babs.com"
|
|
@@ -344,7 +344,7 @@ class TestConfiguration {
|
|
|
344
344
|
|
|
345
345
|
return context.doInAppContext(prodAppId, async () => {
|
|
346
346
|
const db = context.getProdAppDB()
|
|
347
|
-
return await db.get(
|
|
347
|
+
return await db.get(DocumentType.APP_METADATA)
|
|
348
348
|
})
|
|
349
349
|
}
|
|
350
350
|
|
|
@@ -11,7 +11,7 @@ import { storeLog } from "../automations/logging"
|
|
|
11
11
|
import { Automation, AutomationStep, AutomationStatus } from "@budibase/types"
|
|
12
12
|
import {
|
|
13
13
|
LoopStep,
|
|
14
|
-
|
|
14
|
+
LoopStepType,
|
|
15
15
|
LoopInput,
|
|
16
16
|
AutomationEvent,
|
|
17
17
|
TriggerOutput,
|
|
@@ -35,12 +35,12 @@ function typecastForLooping(loopStep: LoopStep, input: LoopInput) {
|
|
|
35
35
|
}
|
|
36
36
|
try {
|
|
37
37
|
switch (loopStep.inputs.option) {
|
|
38
|
-
case
|
|
38
|
+
case LoopStepType.ARRAY:
|
|
39
39
|
if (typeof input.binding === "string") {
|
|
40
40
|
return JSON.parse(input.binding)
|
|
41
41
|
}
|
|
42
42
|
break
|
|
43
|
-
case
|
|
43
|
+
case LoopStepType.STRING:
|
|
44
44
|
if (Array.isArray(input.binding)) {
|
|
45
45
|
return input.binding.join(",")
|
|
46
46
|
}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
const { createRoutingView } = require("../../db/views/staticViews")
|
|
2
|
-
const {
|
|
2
|
+
const { ViewName, getQueryIndex, UNICODE_MAX } = require("../../db/utils")
|
|
3
3
|
const { getAppDB } = require("@budibase/backend-core/context")
|
|
4
4
|
|
|
5
5
|
exports.getRoutingInfo = async () => {
|
|
6
6
|
const db = getAppDB()
|
|
7
7
|
try {
|
|
8
|
-
const allRouting = await db.query(getQueryIndex(
|
|
8
|
+
const allRouting = await db.query(getQueryIndex(ViewName.ROUTING), {
|
|
9
9
|
startKey: "",
|
|
10
10
|
endKey: UNICODE_MAX,
|
|
11
11
|
})
|
|
@@ -8,7 +8,7 @@ const {
|
|
|
8
8
|
lowerBuiltinRoleID,
|
|
9
9
|
getBuiltinRoles,
|
|
10
10
|
} = require("@budibase/backend-core/roles")
|
|
11
|
-
const {
|
|
11
|
+
const { DocumentType } = require("../db/utils")
|
|
12
12
|
|
|
13
13
|
const CURRENTLY_SUPPORTED_LEVELS = [
|
|
14
14
|
PermissionLevels.WRITE,
|
|
@@ -17,19 +17,19 @@ const CURRENTLY_SUPPORTED_LEVELS = [
|
|
|
17
17
|
]
|
|
18
18
|
|
|
19
19
|
exports.getPermissionType = resourceId => {
|
|
20
|
-
const docType = Object.values(
|
|
20
|
+
const docType = Object.values(DocumentType).filter(docType =>
|
|
21
21
|
resourceId.startsWith(docType)
|
|
22
22
|
)[0]
|
|
23
23
|
switch (docType) {
|
|
24
|
-
case
|
|
25
|
-
case
|
|
24
|
+
case DocumentType.TABLE:
|
|
25
|
+
case DocumentType.ROW:
|
|
26
26
|
return PermissionTypes.TABLE
|
|
27
|
-
case
|
|
27
|
+
case DocumentType.AUTOMATION:
|
|
28
28
|
return PermissionTypes.AUTOMATION
|
|
29
|
-
case
|
|
29
|
+
case DocumentType.WEBHOOK:
|
|
30
30
|
return PermissionTypes.WEBHOOK
|
|
31
|
-
case
|
|
32
|
-
case
|
|
31
|
+
case DocumentType.QUERY:
|
|
32
|
+
case DocumentType.DATASOURCE:
|
|
33
33
|
return PermissionTypes.QUERY
|
|
34
34
|
default:
|
|
35
35
|
// views don't have an ID, will end up here
|