@budibase/server 1.0.191 → 1.0.192-alpha.2

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.
Files changed (190) hide show
  1. package/builder/assets/index.125b5754.js +1315 -0
  2. package/builder/assets/{index.bb5e3dfd.css → index.8a6f249b.css} +2 -2
  3. package/builder/assets/{vendor.5240f480.js → vendor.9bf2fcb4.js} +53 -53
  4. package/builder/index.html +3 -3
  5. package/coverage/clover.xml +73 -68
  6. package/coverage/coverage-final.json +8 -8
  7. package/coverage/lcov-report/api/controllers/analytics.js.html +1 -1
  8. package/coverage/lcov-report/api/controllers/apikeys.js.html +1 -1
  9. package/coverage/lcov-report/api/controllers/auth.js.html +1 -1
  10. package/coverage/lcov-report/api/controllers/automation.js.html +1 -1
  11. package/coverage/lcov-report/api/controllers/backup.js.html +1 -1
  12. package/coverage/lcov-report/api/controllers/cloud.js.html +1 -1
  13. package/coverage/lcov-report/api/controllers/component.js.html +1 -1
  14. package/coverage/lcov-report/api/controllers/datasource.js.html +1 -1
  15. package/coverage/lcov-report/api/controllers/dev.js.html +1 -1
  16. package/coverage/lcov-report/api/controllers/index.html +15 -15
  17. package/coverage/lcov-report/api/controllers/integration.js.html +1 -1
  18. package/coverage/lcov-report/api/controllers/layout.js.html +1 -1
  19. package/coverage/lcov-report/api/controllers/metadata.js.html +1 -1
  20. package/coverage/lcov-report/api/controllers/migrations.js.html +1 -1
  21. package/coverage/lcov-report/api/controllers/permission.js.html +1 -1
  22. package/coverage/lcov-report/api/controllers/query/index.html +1 -1
  23. package/coverage/lcov-report/api/controllers/query/validation.js.html +1 -1
  24. package/coverage/lcov-report/api/controllers/role.js.html +1 -1
  25. package/coverage/lcov-report/api/controllers/routing.js.html +1 -1
  26. package/coverage/lcov-report/api/controllers/row/external.js.html +1 -1
  27. package/coverage/lcov-report/api/controllers/row/index.html +15 -15
  28. package/coverage/lcov-report/api/controllers/row/internal.js.html +1 -1
  29. package/coverage/lcov-report/api/controllers/row/internalSearch.js.html +1 -1
  30. package/coverage/lcov-report/api/controllers/row/staticFormula.js.html +1 -1
  31. package/coverage/lcov-report/api/controllers/row/utils.js.html +17 -8
  32. package/coverage/lcov-report/api/controllers/screen.js.html +1 -1
  33. package/coverage/lcov-report/api/controllers/script.js.html +1 -1
  34. package/coverage/lcov-report/api/controllers/table/bulkFormula.js.html +1 -1
  35. package/coverage/lcov-report/api/controllers/table/external.js.html +1 -1
  36. package/coverage/lcov-report/api/controllers/table/index.html +1 -1
  37. package/coverage/lcov-report/api/controllers/table/index.js.html +1 -1
  38. package/coverage/lcov-report/api/controllers/templates.js.html +12 -9
  39. package/coverage/lcov-report/api/controllers/user.js.html +1 -1
  40. package/coverage/lcov-report/api/controllers/view/exporters.js.html +3 -3
  41. package/coverage/lcov-report/api/controllers/view/index.html +4 -4
  42. package/coverage/lcov-report/api/controllers/view/index.js.html +1 -1
  43. package/coverage/lcov-report/api/controllers/view/utils.js.html +1 -1
  44. package/coverage/lcov-report/api/controllers/view/viewBuilder.js.html +1 -1
  45. package/coverage/lcov-report/api/controllers/webhook.js.html +1 -1
  46. package/coverage/lcov-report/api/index.html +1 -1
  47. package/coverage/lcov-report/api/index.js.html +1 -1
  48. package/coverage/lcov-report/api/routes/analytics.js.html +1 -1
  49. package/coverage/lcov-report/api/routes/apikeys.js.html +1 -1
  50. package/coverage/lcov-report/api/routes/auth.js.html +1 -1
  51. package/coverage/lcov-report/api/routes/automation.js.html +1 -1
  52. package/coverage/lcov-report/api/routes/backup.js.html +1 -1
  53. package/coverage/lcov-report/api/routes/cloud.js.html +1 -1
  54. package/coverage/lcov-report/api/routes/component.js.html +1 -1
  55. package/coverage/lcov-report/api/routes/datasource.js.html +1 -1
  56. package/coverage/lcov-report/api/routes/deploy.js.html +1 -1
  57. package/coverage/lcov-report/api/routes/dev.js.html +1 -1
  58. package/coverage/lcov-report/api/routes/index.html +1 -1
  59. package/coverage/lcov-report/api/routes/integration.js.html +1 -1
  60. package/coverage/lcov-report/api/routes/layout.js.html +1 -1
  61. package/coverage/lcov-report/api/routes/metadata.js.html +1 -1
  62. package/coverage/lcov-report/api/routes/migrations.js.html +1 -1
  63. package/coverage/lcov-report/api/routes/permission.js.html +1 -1
  64. package/coverage/lcov-report/api/routes/query.js.html +1 -1
  65. package/coverage/lcov-report/api/routes/role.js.html +1 -1
  66. package/coverage/lcov-report/api/routes/routing.js.html +1 -1
  67. package/coverage/lcov-report/api/routes/screen.js.html +1 -1
  68. package/coverage/lcov-report/api/routes/script.js.html +1 -1
  69. package/coverage/lcov-report/api/routes/table.js.html +1 -1
  70. package/coverage/lcov-report/api/routes/templates.js.html +1 -1
  71. package/coverage/lcov-report/api/routes/user.js.html +1 -1
  72. package/coverage/lcov-report/api/routes/utils/index.html +1 -1
  73. package/coverage/lcov-report/api/routes/utils/validators.js.html +1 -1
  74. package/coverage/lcov-report/api/routes/view.js.html +1 -1
  75. package/coverage/lcov-report/api/routes/webhook.js.html +1 -1
  76. package/coverage/lcov-report/automations/actions.js.html +1 -1
  77. package/coverage/lcov-report/automations/automationUtils.js.html +1 -1
  78. package/coverage/lcov-report/automations/bullboard.js.html +1 -1
  79. package/coverage/lcov-report/automations/index.html +1 -1
  80. package/coverage/lcov-report/automations/index.js.html +1 -1
  81. package/coverage/lcov-report/automations/steps/bash.js.html +1 -1
  82. package/coverage/lcov-report/automations/steps/delay.js.html +1 -1
  83. package/coverage/lcov-report/automations/steps/discord.js.html +1 -1
  84. package/coverage/lcov-report/automations/steps/executeQuery.js.html +1 -1
  85. package/coverage/lcov-report/automations/steps/executeScript.js.html +1 -1
  86. package/coverage/lcov-report/automations/steps/filter.js.html +1 -1
  87. package/coverage/lcov-report/automations/steps/index.html +14 -14
  88. package/coverage/lcov-report/automations/steps/integromat.js.html +1 -1
  89. package/coverage/lcov-report/automations/steps/loop.js.html +1 -1
  90. package/coverage/lcov-report/automations/steps/outgoingWebhook.js.html +1 -1
  91. package/coverage/lcov-report/automations/steps/queryRows.js.html +5 -2
  92. package/coverage/lcov-report/automations/steps/sendSmtpEmail.js.html +10 -7
  93. package/coverage/lcov-report/automations/steps/serverLog.js.html +1 -1
  94. package/coverage/lcov-report/automations/steps/slack.js.html +1 -1
  95. package/coverage/lcov-report/automations/steps/updateRow.js.html +1 -1
  96. package/coverage/lcov-report/automations/steps/utils.js.html +1 -1
  97. package/coverage/lcov-report/automations/steps/zapier.js.html +1 -1
  98. package/coverage/lcov-report/automations/triggerInfo/app.js.html +1 -1
  99. package/coverage/lcov-report/automations/triggerInfo/cron.js.html +1 -1
  100. package/coverage/lcov-report/automations/triggerInfo/index.html +1 -1
  101. package/coverage/lcov-report/automations/triggerInfo/index.js.html +1 -1
  102. package/coverage/lcov-report/automations/triggerInfo/rowDeleted.js.html +1 -1
  103. package/coverage/lcov-report/automations/triggerInfo/rowSaved.js.html +1 -1
  104. package/coverage/lcov-report/automations/triggerInfo/rowUpdated.js.html +1 -1
  105. package/coverage/lcov-report/automations/triggerInfo/webhook.js.html +1 -1
  106. package/coverage/lcov-report/automations/triggers.js.html +1 -1
  107. package/coverage/lcov-report/constants/index.html +1 -1
  108. package/coverage/lcov-report/constants/index.js.html +1 -1
  109. package/coverage/lcov-report/constants/layouts.js.html +1 -1
  110. package/coverage/lcov-report/constants/screens.js.html +1 -1
  111. package/coverage/lcov-report/db/inMemoryView.js.html +1 -1
  112. package/coverage/lcov-report/db/index.html +1 -1
  113. package/coverage/lcov-report/db/index.js.html +1 -1
  114. package/coverage/lcov-report/db/linkedRows/LinkController.js.html +1 -1
  115. package/coverage/lcov-report/db/linkedRows/index.html +1 -1
  116. package/coverage/lcov-report/db/linkedRows/index.js.html +1 -1
  117. package/coverage/lcov-report/db/linkedRows/linkUtils.js.html +1 -1
  118. package/coverage/lcov-report/db/newid.js.html +1 -1
  119. package/coverage/lcov-report/db/utils.js.html +4 -4
  120. package/coverage/lcov-report/events/AutomationEmitter.js.html +1 -1
  121. package/coverage/lcov-report/events/index.html +1 -1
  122. package/coverage/lcov-report/events/index.js.html +1 -1
  123. package/coverage/lcov-report/events/utils.js.html +1 -1
  124. package/coverage/lcov-report/index.html +49 -49
  125. package/coverage/lcov-report/integrations/tests/TestConfiguration.js.html +1 -1
  126. package/coverage/lcov-report/integrations/tests/index.html +1 -1
  127. package/coverage/lcov-report/middleware/appInfo.js.html +1 -1
  128. package/coverage/lcov-report/middleware/builder.js.html +43 -10
  129. package/coverage/lcov-report/middleware/currentapp.js.html +1 -1
  130. package/coverage/lcov-report/middleware/index.html +14 -14
  131. package/coverage/lcov-report/middleware/joi-validator.js.html +1 -1
  132. package/coverage/lcov-report/middleware/publicApi.js.html +1 -1
  133. package/coverage/lcov-report/middleware/resourceId.js.html +1 -1
  134. package/coverage/lcov-report/middleware/selfhost.js.html +1 -1
  135. package/coverage/lcov-report/middleware/utils.js.html +1 -1
  136. package/coverage/lcov-report/threads/automation.js.html +1 -1
  137. package/coverage/lcov-report/threads/index.html +1 -1
  138. package/coverage/lcov-report/threads/query.js.html +1 -1
  139. package/coverage/lcov-report/threads/utils.js.html +1 -1
  140. package/coverage/lcov-report/utilities/budibaseDir.js.html +11 -32
  141. package/coverage/lcov-report/utilities/centralPath.js.html +1 -1
  142. package/coverage/lcov-report/utilities/csvParser.js.html +1 -1
  143. package/coverage/lcov-report/utilities/global.js.html +1 -1
  144. package/coverage/lcov-report/utilities/index.html +19 -19
  145. package/coverage/lcov-report/utilities/index.js.html +1 -1
  146. package/coverage/lcov-report/utilities/queue/inMemoryQueue.js.html +1 -1
  147. package/coverage/lcov-report/utilities/queue/index.html +1 -1
  148. package/coverage/lcov-report/utilities/routing/index.html +1 -1
  149. package/coverage/lcov-report/utilities/routing/index.js.html +1 -1
  150. package/coverage/lcov-report/utilities/rowProcessor/index.html +1 -1
  151. package/coverage/lcov-report/utilities/rowProcessor/index.js.html +1 -1
  152. package/coverage/lcov-report/utilities/rowProcessor/utils.js.html +1 -1
  153. package/coverage/lcov-report/utilities/scriptRunner.js.html +1 -1
  154. package/coverage/lcov-report/utilities/security.js.html +1 -1
  155. package/coverage/lcov-report/utilities/statusCodes.js.html +1 -1
  156. package/coverage/lcov-report/utilities/usageQuota/index.html +1 -1
  157. package/coverage/lcov-report/utilities/usageQuota/rows.js.html +1 -1
  158. package/coverage/lcov-report/utilities/usageQuota/usageQuoteReset.js.html +1 -1
  159. package/coverage/lcov-report/utilities/users.js.html +1 -1
  160. package/coverage/lcov-report/utilities/workerRequests.js.html +1 -1
  161. package/coverage/lcov.info +128 -116
  162. package/dist/api/controllers/row/utils.js +3 -0
  163. package/dist/api/controllers/templates.js +2 -1
  164. package/dist/api/controllers/view/exporters.js +1 -1
  165. package/dist/automations/steps/queryRows.js +1 -0
  166. package/dist/automations/steps/sendSmtpEmail.js +1 -0
  167. package/dist/definitions/datasource.js +1 -0
  168. package/dist/environment.js +9 -13
  169. package/dist/integrations/index.js +3 -0
  170. package/dist/integrations/snowflake.js +101 -0
  171. package/dist/middleware/builder.js +9 -2
  172. package/dist/package.json +6 -5
  173. package/dist/tsconfig.build.tsbuildinfo +1 -1
  174. package/dist/utilities/budibaseDir.js +0 -6
  175. package/dist/utilities/redis.js +1 -1
  176. package/package.json +7 -6
  177. package/scripts/likeCypress.ts +0 -1
  178. package/src/api/controllers/row/utils.js +3 -0
  179. package/src/api/controllers/templates.js +2 -1
  180. package/src/api/controllers/view/exporters.js +1 -1
  181. package/src/automations/steps/queryRows.js +1 -0
  182. package/src/automations/steps/sendSmtpEmail.js +1 -0
  183. package/src/definitions/datasource.ts +1 -0
  184. package/src/environment.js +9 -13
  185. package/src/integrations/index.ts +3 -0
  186. package/src/integrations/snowflake.ts +98 -0
  187. package/src/middleware/builder.js +13 -2
  188. package/src/utilities/budibaseDir.js +0 -7
  189. package/src/utilities/redis.js +2 -0
  190. package/builder/assets/index.dae59da9.js +0 -1299
@@ -1,9 +1,3 @@
1
1
  "use strict";
2
- const { join } = require("./centralPath");
3
- const { homedir } = require("os");
4
- const env = require("../environment");
5
2
  const { budibaseTempDir } = require("@budibase/backend-core/objectStore");
6
- module.exports.budibaseAppsDir = function () {
7
- return env.BUDIBASE_DIR || join(homedir(), ".budibase");
8
- };
9
3
  module.exports.budibaseTempDir = budibaseTempDir;
@@ -51,7 +51,7 @@ exports.getAllLocks = () => __awaiter(void 0, void 0, void 0, function* () {
51
51
  exports.updateLock = (devAppId, user) => __awaiter(void 0, void 0, void 0, function* () {
52
52
  // make sure always global user ID
53
53
  const globalId = getGlobalIDFromUserMetadataID(user._id);
54
- const inputUser = Object.assign(Object.assign({}, user), { userId: globalId, _id: globalId });
54
+ const inputUser = Object.assign(Object.assign({}, user), { userId: globalId, _id: globalId, lockedAt: new Date().getTime() });
55
55
  yield devAppClient.store(devAppId, inputUser, APP_DEV_LOCK_SECONDS);
56
56
  });
57
57
  exports.clearLock = (devAppId, user) => __awaiter(void 0, void 0, void 0, function* () {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@budibase/server",
3
3
  "email": "hi@budibase.com",
4
- "version": "1.0.191",
4
+ "version": "1.0.192-alpha.2",
5
5
  "description": "Budibase Web Server",
6
6
  "main": "src/index.ts",
7
7
  "repository": {
@@ -70,10 +70,10 @@
70
70
  "license": "GPL-3.0",
71
71
  "dependencies": {
72
72
  "@apidevtools/swagger-parser": "^10.0.3",
73
- "@budibase/backend-core": "^1.0.191",
74
- "@budibase/client": "^1.0.191",
75
- "@budibase/pro": "1.0.190",
76
- "@budibase/string-templates": "^1.0.191",
73
+ "@budibase/backend-core": "^1.0.192-alpha.2",
74
+ "@budibase/client": "^1.0.192-alpha.2",
75
+ "@budibase/pro": "1.0.192-alpha.1",
76
+ "@budibase/string-templates": "^1.0.192-alpha.2",
77
77
  "@bull-board/api": "^3.7.0",
78
78
  "@bull-board/koa": "^3.7.0",
79
79
  "@elastic/elasticsearch": "7.10.0",
@@ -130,6 +130,7 @@
130
130
  "pouchdb-replication-stream": "1.2.9",
131
131
  "redis": "4",
132
132
  "server-destroy": "1.0.1",
133
+ "snowflake-promise": "^4.5.0",
133
134
  "svelte": "^3.38.2",
134
135
  "swagger-parser": "^10.0.3",
135
136
  "to-json-schema": "0.2.5",
@@ -184,5 +185,5 @@
184
185
  "optionalDependencies": {
185
186
  "oracledb": "^5.3.0"
186
187
  },
187
- "gitHead": "5f9a79722351f52ddddc54fba5b5f9ef0804ea97"
188
+ "gitHead": "3229fac63b9d277ef97cb2594ec8c0ecda1290fd"
188
189
  }
@@ -9,7 +9,6 @@ const SERVER_PORT = "4100"
9
9
  const WORKER_PORT = "4200"
10
10
 
11
11
  // @ts-ignore
12
- process.env.BUDIBASE_API_KEY = "6BE826CB-6B30-4AEC-8777-2E90464633DE"
13
12
  process.env.NODE_ENV = "cypress"
14
13
  process.env.ENABLE_ANALYTICS = "false"
15
14
  process.env.JWT_SECRET = "budibase"
@@ -64,6 +64,9 @@ exports.validate = async ({ tableId, row, table }) => {
64
64
  // Validate.js doesn't seem to handle array
65
65
  if (type === FieldTypes.ARRAY && row[fieldName]) {
66
66
  if (row[fieldName].length) {
67
+ if (!Array.isArray(row[fieldName])) {
68
+ row[fieldName] = row[fieldName].split(",")
69
+ }
67
70
  row[fieldName].map(val => {
68
71
  if (
69
72
  !constraints.inclusion.includes(val) &&
@@ -1,12 +1,13 @@
1
1
  const fetch = require("node-fetch")
2
2
  const { downloadTemplate } = require("../../utilities/fileSystem")
3
+ const env = require("../../environment")
3
4
 
4
5
  // development flag, can be used to test against templates exported locally
5
6
  const DEFAULT_TEMPLATES_BUCKET =
6
7
  "prod-budi-templates.s3-eu-west-1.amazonaws.com"
7
8
 
8
9
  exports.fetch = async function (ctx) {
9
- const { type = "app" } = ctx.query
10
+ let type = env.TEMPLATE_REPOSITORY
10
11
  let response,
11
12
  error = false
12
13
  try {
@@ -6,7 +6,7 @@ exports.csv = function (headers, rows) {
6
6
  .map(header => {
7
7
  let val = row[header]
8
8
  val =
9
- typeof val === "object"
9
+ typeof val === "object" && !(val instanceof Date)
10
10
  ? `"${JSON.stringify(val).replace(/"/g, "'")}"`
11
11
  : `"${val}"`
12
12
  return val.trim()
@@ -50,6 +50,7 @@ exports.definition = {
50
50
  limit: {
51
51
  type: "number",
52
52
  title: "Limit",
53
+ customType: "queryLimit",
53
54
  },
54
55
  },
55
56
  required: ["tableId"],
@@ -53,6 +53,7 @@ exports.run = async function ({ inputs }) {
53
53
  if (!contents) {
54
54
  contents = "<h1>No content</h1>"
55
55
  }
56
+ to = to || undefined
56
57
  try {
57
58
  let response = await sendSmtpEmail(to, from, subject, contents, true)
58
59
  return {
@@ -50,6 +50,7 @@ export enum SourceNames {
50
50
  GOOGLE_SHEETS = "GOOGLE_SHEETS",
51
51
  FIREBASE = "FIREBASE",
52
52
  REDIS = "REDIS",
53
+ SNOWFLAKE = "SNOWFLAKE",
53
54
  }
54
55
 
55
56
  export enum IncludeRelationships {
@@ -43,15 +43,12 @@ module.exports = {
43
43
  COUCH_DB_URL: process.env.COUCH_DB_URL,
44
44
  MINIO_URL: process.env.MINIO_URL,
45
45
  WORKER_URL: process.env.WORKER_URL,
46
- SELF_HOSTED: process.env.SELF_HOSTED,
47
46
  AWS_REGION: process.env.AWS_REGION,
48
- ENABLE_ANALYTICS: process.env.ENABLE_ANALYTICS,
49
47
  MINIO_ACCESS_KEY: process.env.MINIO_ACCESS_KEY,
50
48
  MINIO_SECRET_KEY: process.env.MINIO_SECRET_KEY,
51
49
  REDIS_URL: process.env.REDIS_URL,
52
50
  REDIS_PASSWORD: process.env.REDIS_PASSWORD,
53
51
  INTERNAL_API_KEY: process.env.INTERNAL_API_KEY,
54
- MULTI_TENANCY: process.env.MULTI_TENANCY,
55
52
  HTTP_MIGRATIONS: process.env.HTTP_MIGRATIONS,
56
53
  API_REQ_LIMIT_PER_SEC: process.env.API_REQ_LIMIT_PER_SEC,
57
54
  GOOGLE_CLIENT_ID: process.env.GOOGLE_CLIENT_ID,
@@ -61,28 +58,27 @@ module.exports = {
61
58
  JEST_WORKER_ID: process.env.JEST_WORKER_ID,
62
59
  BUDIBASE_ENVIRONMENT: process.env.BUDIBASE_ENVIRONMENT,
63
60
  DISABLE_ACCOUNT_PORTAL: process.env.DISABLE_ACCOUNT_PORTAL,
61
+ TEMPLATE_REPOSITORY: process.env.TEMPLATE_REPOSITORY || "app",
64
62
  DISABLE_AUTO_PROD_APP_SYNC: process.env.DISABLE_AUTO_PROD_APP_SYNC,
65
63
  // minor
66
64
  SALT_ROUNDS: process.env.SALT_ROUNDS,
67
65
  LOGGER: process.env.LOGGER,
68
66
  LOG_LEVEL: process.env.LOG_LEVEL,
69
- AUTOMATION_DIRECTORY: process.env.AUTOMATION_DIRECTORY,
70
- AUTOMATION_BUCKET: process.env.AUTOMATION_BUCKET,
71
67
  AUTOMATION_MAX_ITERATIONS: process.env.AUTOMATION_MAX_ITERATIONS,
72
68
  SENDGRID_API_KEY: process.env.SENDGRID_API_KEY,
73
69
  DYNAMO_ENDPOINT: process.env.DYNAMO_ENDPOINT,
74
70
  POSTHOG_TOKEN: process.env.POSTHOG_TOKEN,
75
71
  QUERY_THREAD_TIMEOUT: parseIntSafe(process.env.QUERY_THREAD_TIMEOUT),
76
- // old - to remove
77
- CLIENT_ID: process.env.CLIENT_ID,
78
- BUDIBASE_DIR: process.env.BUDIBASE_DIR,
79
- DEPLOYMENT_DB_URL: process.env.DEPLOYMENT_DB_URL,
80
- BUDIBASE_API_KEY: process.env.BUDIBASE_API_KEY,
81
- USERID_API_KEY: process.env.USERID_API_KEY,
82
- DEPLOYMENT_CREDENTIALS_URL: process.env.DEPLOYMENT_CREDENTIALS_URL,
72
+ SQL_MAX_ROWS: process.env.SQL_MAX_ROWS,
73
+ // flags
83
74
  ALLOW_DEV_AUTOMATIONS: process.env.ALLOW_DEV_AUTOMATIONS,
84
75
  DISABLE_THREADING: process.env.DISABLE_THREADING,
85
- SQL_MAX_ROWS: process.env.SQL_MAX_ROWS,
76
+ DISABLE_DEVELOPER_LICENSE: process.env.DISABLE_DEVELOPER_LICENSE,
77
+ MULTI_TENANCY: process.env.MULTI_TENANCY,
78
+ ENABLE_ANALYTICS: process.env.ENABLE_ANALYTICS,
79
+ SELF_HOSTED: process.env.SELF_HOSTED,
80
+ // old
81
+ CLIENT_ID: process.env.CLIENT_ID,
86
82
  _set(key, value) {
87
83
  process.env[key] = value
88
84
  module.exports[key] = value
@@ -12,6 +12,7 @@ const rest = require("./rest")
12
12
  const googlesheets = require("./googlesheets")
13
13
  const firebase = require("./firebase")
14
14
  const redis = require("./redis")
15
+ const snowflake = require("./snowflake")
15
16
  const { SourceNames } = require("../definitions/datasource")
16
17
  const environment = require("../environment")
17
18
 
@@ -29,6 +30,7 @@ const DEFINITIONS = {
29
30
  [SourceNames.REST]: rest.schema,
30
31
  [SourceNames.FIREBASE]: firebase.schema,
31
32
  [SourceNames.REDIS]: redis.schema,
33
+ [SourceNames.SNOWFLAKE]: snowflake.schema,
32
34
  }
33
35
 
34
36
  const INTEGRATIONS = {
@@ -47,6 +49,7 @@ const INTEGRATIONS = {
47
49
  [SourceNames.GOOGLE_SHEETS]: googlesheets.integration,
48
50
  [SourceNames.REDIS]: redis.integration,
49
51
  [SourceNames.FIREBASE]: firebase.integration,
52
+ [SourceNames.SNOWFLAKE]: snowflake.integration,
50
53
  }
51
54
 
52
55
  // optionally add oracle integration if the oracle binary can be installed
@@ -0,0 +1,98 @@
1
+ import { Integration, QueryTypes, SqlQuery } from "../definitions/datasource"
2
+ import { Snowflake } from "snowflake-promise"
3
+
4
+ module SnowflakeModule {
5
+ interface SnowflakeConfig {
6
+ account: string
7
+ username: string
8
+ password: string
9
+ warehouse: string
10
+ database: string
11
+ schema: string
12
+ }
13
+
14
+ const SCHEMA: Integration = {
15
+ docs: "https://developers.snowflake.com/",
16
+ description:
17
+ "Snowflake is a solution for data warehousing, data lakes, data engineering, data science, data application development, and securely sharing and consuming shared data.",
18
+ friendlyName: "Snowflake",
19
+ datasource: {
20
+ account: {
21
+ type: "string",
22
+ required: true,
23
+ },
24
+ username: {
25
+ type: "string",
26
+ required: true,
27
+ },
28
+ password: {
29
+ type: "password",
30
+ required: true,
31
+ },
32
+ warehouse: {
33
+ type: "string",
34
+ required: true,
35
+ },
36
+ database: {
37
+ type: "string",
38
+ required: true,
39
+ },
40
+ schema: {
41
+ type: "string",
42
+ required: true,
43
+ },
44
+ },
45
+ query: {
46
+ create: {
47
+ type: QueryTypes.SQL,
48
+ },
49
+ read: {
50
+ type: QueryTypes.SQL,
51
+ },
52
+ update: {
53
+ type: QueryTypes.SQL,
54
+ },
55
+ delete: {
56
+ type: QueryTypes.SQL,
57
+ },
58
+ },
59
+ }
60
+
61
+ class SnowflakeIntegration {
62
+ private client: Snowflake
63
+
64
+ constructor(config: SnowflakeConfig) {
65
+ this.client = new Snowflake(config)
66
+ }
67
+
68
+ async internalQuery(query: SqlQuery) {
69
+ await this.client.connect()
70
+ try {
71
+ return await this.client.execute(query.sql)
72
+ } catch (err: any) {
73
+ throw err?.message.split(":")[1] || err?.message
74
+ }
75
+ }
76
+
77
+ async create(query: SqlQuery) {
78
+ return this.internalQuery(query)
79
+ }
80
+
81
+ async read(query: SqlQuery) {
82
+ return this.internalQuery(query)
83
+ }
84
+
85
+ async update(query: SqlQuery) {
86
+ return this.internalQuery(query)
87
+ }
88
+
89
+ async delete(query: SqlQuery) {
90
+ return this.internalQuery(query)
91
+ }
92
+ }
93
+
94
+ module.exports = {
95
+ schema: SCHEMA,
96
+ integration: SnowflakeIntegration,
97
+ }
98
+ }
@@ -6,7 +6,7 @@ const {
6
6
  setDebounce,
7
7
  } = require("../utilities/redis")
8
8
  const { doWithDB } = require("@budibase/backend-core/db")
9
- const { DocumentTypes } = require("../db/utils")
9
+ const { DocumentTypes, 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
 
@@ -51,6 +51,9 @@ async function updateAppUpdatedAt(ctx) {
51
51
  await doWithDB(appId, async db => {
52
52
  const metadata = await db.get(DocumentTypes.APP_METADATA)
53
53
  metadata.updatedAt = new Date().toISOString()
54
+
55
+ metadata.updatedBy = getGlobalIDFromUserMetadataID(ctx.user.userId)
56
+
54
57
  const response = await db.put(metadata)
55
58
  metadata._rev = response.rev
56
59
  await appCache.invalidateAppMetadata(appId, metadata)
@@ -67,7 +70,15 @@ module.exports = async (ctx, permType) => {
67
70
  }
68
71
  const isBuilderApi = permType === PermissionTypes.BUILDER
69
72
  const referer = ctx.headers["referer"]
70
- const editingApp = referer ? referer.includes(appId) : false
73
+
74
+ const overviewPath = "/builder/portal/overview/"
75
+ const overviewContext = !referer ? false : referer.includes(overviewPath)
76
+ if (overviewContext) {
77
+ return
78
+ }
79
+
80
+ const hasAppId = !referer ? false : referer.includes(appId)
81
+ const editingApp = referer ? hasAppId : false
71
82
  // check this is a builder call and editing
72
83
  if (!isBuilderApi || !editingApp) {
73
84
  return
@@ -1,10 +1,3 @@
1
- const { join } = require("./centralPath")
2
- const { homedir } = require("os")
3
- const env = require("../environment")
4
1
  const { budibaseTempDir } = require("@budibase/backend-core/objectStore")
5
2
 
6
- module.exports.budibaseAppsDir = function () {
7
- return env.BUDIBASE_DIR || join(homedir(), ".budibase")
8
- }
9
-
10
3
  module.exports.budibaseTempDir = budibaseTempDir
@@ -48,7 +48,9 @@ exports.updateLock = async (devAppId, user) => {
48
48
  ...user,
49
49
  userId: globalId,
50
50
  _id: globalId,
51
+ lockedAt: new Date().getTime(),
51
52
  }
53
+
52
54
  await devAppClient.store(devAppId, inputUser, APP_DEV_LOCK_SECONDS)
53
55
  }
54
56