@budibase/backend-core 2.27.4 → 2.27.6
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/dist/index.js +1414 -163
- package/dist/index.js.map +4 -4
- package/dist/index.js.meta.json +1 -1
- package/dist/package.json +5 -4
- package/dist/plugins.js.map +1 -1
- package/dist/plugins.js.meta.json +1 -1
- package/dist/src/constants/db.d.ts +6 -0
- package/dist/src/constants/db.js +7 -1
- package/dist/src/constants/db.js.map +1 -1
- package/dist/src/environment.d.ts +2 -0
- package/dist/src/environment.js +2 -0
- package/dist/src/environment.js.map +1 -1
- package/dist/src/index.d.ts +1 -0
- package/dist/src/index.js +2 -1
- package/dist/src/index.js.map +1 -1
- package/dist/src/objectStore/objectStore.d.ts +10 -2
- package/dist/src/objectStore/objectStore.js +13 -2
- package/dist/src/objectStore/objectStore.js.map +1 -1
- package/dist/src/sql/designDoc.d.ts +2 -0
- package/dist/src/sql/designDoc.js +20 -0
- package/dist/src/sql/designDoc.js.map +1 -0
- package/dist/src/sql/index.d.ts +4 -0
- package/dist/src/sql/index.js +36 -0
- package/dist/src/sql/index.js.map +1 -0
- package/dist/src/sql/sql.d.ts +21 -0
- package/dist/src/sql/sql.js +752 -0
- package/dist/src/sql/sql.js.map +1 -0
- package/dist/src/sql/sqlStatements.d.ts +14 -0
- package/dist/src/sql/sqlStatements.js +60 -0
- package/dist/src/sql/sqlStatements.js.map +1 -0
- package/dist/src/sql/sqlTable.d.ts +13 -0
- package/dist/src/sql/sqlTable.js +231 -0
- package/dist/src/sql/sqlTable.js.map +1 -0
- package/dist/src/sql/utils.d.ts +22 -0
- package/dist/src/sql/utils.js +133 -0
- package/dist/src/sql/utils.js.map +1 -0
- package/dist/tests/core/utilities/mocks/licenses.d.ts +1 -0
- package/dist/tests/core/utilities/mocks/licenses.js +5 -1
- package/dist/tests/core/utilities/mocks/licenses.js.map +1 -1
- package/package.json +5 -4
- package/src/constants/db.ts +6 -0
- package/src/environment.ts +3 -0
- package/src/index.ts +1 -0
- package/src/objectStore/objectStore.ts +21 -7
- package/src/sql/designDoc.ts +17 -0
- package/src/sql/index.ts +5 -0
- package/src/sql/sql.ts +852 -0
- package/src/sql/sqlStatements.ts +79 -0
- package/src/sql/sqlTable.ts +289 -0
- package/src/sql/utils.ts +134 -0
- package/tests/core/utilities/mocks/licenses.ts +4 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@budibase/backend-core",
|
|
3
|
-
"version": "2.27.
|
|
3
|
+
"version": "2.27.6",
|
|
4
4
|
"description": "Budibase backend core libraries used in server and worker",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/src/index.d.ts",
|
|
@@ -23,8 +23,8 @@
|
|
|
23
23
|
"dependencies": {
|
|
24
24
|
"@budibase/nano": "10.1.5",
|
|
25
25
|
"@budibase/pouchdb-replication-stream": "1.2.10",
|
|
26
|
-
"@budibase/shared-core": "2.27.
|
|
27
|
-
"@budibase/types": "2.27.
|
|
26
|
+
"@budibase/shared-core": "2.27.6",
|
|
27
|
+
"@budibase/types": "2.27.6",
|
|
28
28
|
"@govtechsg/passport-openidconnect": "^1.0.2",
|
|
29
29
|
"aws-cloudfront-sign": "3.0.2",
|
|
30
30
|
"aws-sdk": "2.1030.0",
|
|
@@ -37,6 +37,7 @@
|
|
|
37
37
|
"ioredis": "5.3.2",
|
|
38
38
|
"joi": "17.6.0",
|
|
39
39
|
"jsonwebtoken": "9.0.2",
|
|
40
|
+
"knex": "2.4.2",
|
|
40
41
|
"koa-passport": "^6.0.0",
|
|
41
42
|
"koa-pino-logger": "4.0.0",
|
|
42
43
|
"lodash": "4.17.21",
|
|
@@ -95,5 +96,5 @@
|
|
|
95
96
|
}
|
|
96
97
|
}
|
|
97
98
|
},
|
|
98
|
-
"gitHead": "
|
|
99
|
+
"gitHead": "67671b9dfc8698315cb394a427266a4d184b0e26"
|
|
99
100
|
}
|
package/src/constants/db.ts
CHANGED
|
@@ -65,5 +65,11 @@ export const StaticDatabases = {
|
|
|
65
65
|
export const APP_PREFIX = prefixed(DocumentType.APP)
|
|
66
66
|
export const APP_DEV = prefixed(DocumentType.APP_DEV)
|
|
67
67
|
export const APP_DEV_PREFIX = APP_DEV
|
|
68
|
+
export const SQS_DATASOURCE_INTERNAL = "internal"
|
|
68
69
|
export const BUDIBASE_DATASOURCE_TYPE = "budibase"
|
|
69
70
|
export const SQLITE_DESIGN_DOC_ID = "_design/sqlite"
|
|
71
|
+
export const DEFAULT_JOBS_TABLE_ID = "ta_bb_jobs"
|
|
72
|
+
export const DEFAULT_INVENTORY_TABLE_ID = "ta_bb_inventory"
|
|
73
|
+
export const DEFAULT_EXPENSES_TABLE_ID = "ta_bb_expenses"
|
|
74
|
+
export const DEFAULT_EMPLOYEE_TABLE_ID = "ta_bb_employee"
|
|
75
|
+
export const DEFAULT_BB_DATASOURCE_ID = "datasource_internal_bb_default"
|
package/src/environment.ts
CHANGED
|
@@ -159,6 +159,9 @@ const environment = {
|
|
|
159
159
|
process.env.DEPLOYMENT_ENVIRONMENT || "docker-compose",
|
|
160
160
|
HTTP_LOGGING: httpLogging(),
|
|
161
161
|
ENABLE_AUDIT_LOG_IP_ADDR: process.env.ENABLE_AUDIT_LOG_IP_ADDR,
|
|
162
|
+
// Couch/search
|
|
163
|
+
SQL_LOGGING_ENABLE: process.env.SQL_LOGGING_ENABLE,
|
|
164
|
+
SQL_MAX_ROWS: process.env.SQL_MAX_ROWS,
|
|
162
165
|
// smtp
|
|
163
166
|
SMTP_FALLBACK_ENABLED: process.env.SMTP_FALLBACK_ENABLED,
|
|
164
167
|
SMTP_USER: process.env.SMTP_USER,
|
package/src/index.ts
CHANGED
|
@@ -34,6 +34,7 @@ export * as docUpdates from "./docUpdates"
|
|
|
34
34
|
export * from "./utils/Duration"
|
|
35
35
|
export * as docIds from "./docIds"
|
|
36
36
|
export * as security from "./security"
|
|
37
|
+
export * as sql from "./sql"
|
|
37
38
|
// Add context to tenancy for backwards compatibility
|
|
38
39
|
// only do this for external usages to prevent internal
|
|
39
40
|
// circular dependencies
|
|
@@ -14,6 +14,7 @@ import { v4 } from "uuid"
|
|
|
14
14
|
import { APP_PREFIX, APP_DEV_PREFIX } from "../db"
|
|
15
15
|
import fsp from "fs/promises"
|
|
16
16
|
import { HeadObjectOutput } from "aws-sdk/clients/s3"
|
|
17
|
+
import { ReadableStream } from "stream/web"
|
|
17
18
|
|
|
18
19
|
const streamPipeline = promisify(stream.pipeline)
|
|
19
20
|
// use this as a temporary store of buckets that are being created
|
|
@@ -41,10 +42,7 @@ type UploadParams = BaseUploadParams & {
|
|
|
41
42
|
path?: string | PathLike
|
|
42
43
|
}
|
|
43
44
|
|
|
44
|
-
export type StreamTypes =
|
|
45
|
-
| ReadStream
|
|
46
|
-
| NodeJS.ReadableStream
|
|
47
|
-
| ReadableStream<Uint8Array>
|
|
45
|
+
export type StreamTypes = ReadStream | NodeJS.ReadableStream
|
|
48
46
|
|
|
49
47
|
export type StreamUploadParams = BaseUploadParams & {
|
|
50
48
|
stream?: StreamTypes
|
|
@@ -222,6 +220,9 @@ export async function streamUpload({
|
|
|
222
220
|
extra,
|
|
223
221
|
ttl,
|
|
224
222
|
}: StreamUploadParams) {
|
|
223
|
+
if (!stream) {
|
|
224
|
+
throw new Error("Stream to upload is invalid/undefined")
|
|
225
|
+
}
|
|
225
226
|
const extension = filename.split(".").pop()
|
|
226
227
|
const objectStore = ObjectStore(bucketName)
|
|
227
228
|
const bucketCreated = await createBucketIfNotExists(objectStore, bucketName)
|
|
@@ -251,14 +252,27 @@ export async function streamUpload({
|
|
|
251
252
|
: CONTENT_TYPE_MAP.txt
|
|
252
253
|
}
|
|
253
254
|
|
|
255
|
+
const bucket = sanitizeBucket(bucketName),
|
|
256
|
+
objKey = sanitizeKey(filename)
|
|
254
257
|
const params = {
|
|
255
|
-
Bucket:
|
|
256
|
-
Key:
|
|
258
|
+
Bucket: bucket,
|
|
259
|
+
Key: objKey,
|
|
257
260
|
Body: stream,
|
|
258
261
|
ContentType: contentType,
|
|
259
262
|
...extra,
|
|
260
263
|
}
|
|
261
|
-
|
|
264
|
+
|
|
265
|
+
const details = await objectStore.upload(params).promise()
|
|
266
|
+
const headDetails = await objectStore
|
|
267
|
+
.headObject({
|
|
268
|
+
Bucket: bucket,
|
|
269
|
+
Key: objKey,
|
|
270
|
+
})
|
|
271
|
+
.promise()
|
|
272
|
+
return {
|
|
273
|
+
...details,
|
|
274
|
+
ContentLength: headDetails.ContentLength,
|
|
275
|
+
}
|
|
262
276
|
}
|
|
263
277
|
|
|
264
278
|
/**
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { PreSaveSQLiteDefinition } from "@budibase/types"
|
|
2
|
+
import { SQLITE_DESIGN_DOC_ID } from "../constants"
|
|
3
|
+
|
|
4
|
+
// the table id property defines which property in the document
|
|
5
|
+
// to use when splitting the documents into different sqlite tables
|
|
6
|
+
export function base(tableIdProp: string): PreSaveSQLiteDefinition {
|
|
7
|
+
return {
|
|
8
|
+
_id: SQLITE_DESIGN_DOC_ID,
|
|
9
|
+
language: "sqlite",
|
|
10
|
+
sql: {
|
|
11
|
+
tables: {},
|
|
12
|
+
options: {
|
|
13
|
+
table_name: tableIdProp,
|
|
14
|
+
},
|
|
15
|
+
},
|
|
16
|
+
}
|
|
17
|
+
}
|