@budibase/server 2.4.27-alpha.1 → 2.4.27-alpha.11

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 (43) hide show
  1. package/__mocks__/node-fetch.ts +6 -1
  2. package/builder/assets/{index.2be50fcd.js → index.022bf557.js} +371 -371
  3. package/builder/assets/index.514bf77a.css +6 -0
  4. package/builder/index.html +7 -7
  5. package/dist/api/controllers/application.js +28 -24
  6. package/dist/api/controllers/row/utils.js +4 -3
  7. package/dist/api/controllers/static/index.js +84 -24
  8. package/dist/api/controllers/static/templates/BudibaseApp.svelte +33 -10
  9. package/dist/app.js +1 -0
  10. package/dist/integrations/redis.js +1 -1
  11. package/dist/package.json +13 -12
  12. package/dist/sdk/users/utils.js +2 -1
  13. package/dist/tsconfig.build.tsbuildinfo +1 -1
  14. package/dist/utilities/global.js +17 -7
  15. package/jest.config.ts +1 -0
  16. package/package.json +14 -13
  17. package/scripts/test.sh +3 -3
  18. package/src/api/controllers/application.ts +20 -21
  19. package/src/api/controllers/row/utils.ts +4 -3
  20. package/src/api/controllers/static/index.ts +69 -26
  21. package/src/api/controllers/static/templates/BudibaseApp.svelte +33 -10
  22. package/src/api/controllers/view/tests/__snapshots__/viewBuilder.spec.js.snap +48 -48
  23. package/src/api/routes/tests/__snapshots__/datasource.spec.ts.snap +22 -22
  24. package/src/api/routes/tests/__snapshots__/view.spec.js.snap +5 -5
  25. package/src/api/routes/tests/appSync.spec.ts +31 -0
  26. package/src/api/routes/tests/internalSearch.spec.js +8 -7
  27. package/src/app.ts +2 -1
  28. package/src/automations/automationUtils.ts +1 -1
  29. package/src/automations/tests/automation.spec.ts +99 -0
  30. package/src/integration-test/postgres.spec.ts +46 -52
  31. package/src/integrations/redis.ts +1 -1
  32. package/src/integrations/tests/googlesheets.spec.ts +13 -13
  33. package/src/integrations/tests/redis.spec.ts +9 -5
  34. package/src/middleware/currentapp.ts +2 -2
  35. package/src/sdk/users/utils.ts +4 -1
  36. package/src/tests/jestEnv.ts +1 -0
  37. package/src/tests/jestSetup.ts +5 -1
  38. package/src/tests/utilities/TestConfiguration.ts +13 -0
  39. package/src/tests/utilities/structures.ts +13 -1
  40. package/src/utilities/global.ts +21 -9
  41. package/builder/assets/favicon.e7fc7733.png +0 -0
  42. package/builder/assets/index.68ae453c.css +0 -6
  43. package/src/automations/tests/automation.spec.js +0 -84
@@ -45,26 +45,33 @@ function updateAppRole(user, { appId } = {}) {
45
45
  return user;
46
46
  }
47
47
  exports.updateAppRole = updateAppRole;
48
- function checkGroupRoles(user, { appId } = {}) {
48
+ function checkGroupRoles(user, opts = {}) {
49
49
  return __awaiter(this, void 0, void 0, function* () {
50
50
  if (user.roleId && user.roleId !== backend_core_1.roles.BUILTIN_ROLE_IDS.PUBLIC) {
51
51
  return user;
52
52
  }
53
- if (appId) {
54
- user.roleId = yield pro_1.groups.getGroupRoleId(user, appId);
53
+ if (opts.appId) {
54
+ user.roleId = yield pro_1.groups.getGroupRoleId(user, opts.appId, {
55
+ groups: opts.groups,
56
+ });
57
+ }
58
+ // final fallback, simply couldn't find a role - user must be public
59
+ if (!user.roleId) {
60
+ user.roleId = backend_core_1.roles.BUILTIN_ROLE_IDS.PUBLIC;
55
61
  }
56
62
  return user;
57
63
  });
58
64
  }
59
- function processUser(user, { appId } = {}) {
65
+ function processUser(user, opts = {}) {
60
66
  var _a;
61
67
  return __awaiter(this, void 0, void 0, function* () {
62
68
  if (user) {
63
69
  delete user.password;
64
70
  }
65
- user = yield updateAppRole(user, { appId });
71
+ const appId = opts.appId || backend_core_1.context.getAppId();
72
+ user = updateAppRole(user, { appId });
66
73
  if (!user.roleId && ((_a = user === null || user === void 0 ? void 0 : user.userGroups) === null || _a === void 0 ? void 0 : _a.length)) {
67
- user = yield checkGroupRoles(user, { appId });
74
+ user = yield checkGroupRoles(user, { appId, groups: opts === null || opts === void 0 ? void 0 : opts.groups });
68
75
  }
69
76
  return user;
70
77
  });
@@ -98,6 +105,7 @@ function getGlobalUsers(users) {
98
105
  return __awaiter(this, void 0, void 0, function* () {
99
106
  const appId = backend_core_1.context.getAppId();
100
107
  const db = backend_core_1.tenancy.getGlobalDB();
108
+ const allGroups = yield pro_1.groups.fetch();
101
109
  let globalUsers;
102
110
  if (users) {
103
111
  const globalIds = users.map(user => (0, utils_1.getGlobalIDFromUserMetadataID)(user._id));
@@ -118,7 +126,9 @@ function getGlobalUsers(users) {
118
126
  if (!appId) {
119
127
  return globalUsers;
120
128
  }
121
- return globalUsers.map(user => updateAppRole(user));
129
+ // pass in the groups, meaning we don't actually need to retrieve them for
130
+ // each user individually
131
+ return Promise.all(globalUsers.map(user => processUser(user, { groups: allGroups })));
122
132
  });
123
133
  }
124
134
  exports.getGlobalUsers = getGlobalUsers;
package/jest.config.ts CHANGED
@@ -43,6 +43,7 @@ const config: Config.InitialOptions = {
43
43
  "../backend-core/src/**/*.{js,ts}",
44
44
  // The use of coverage with couchdb view functions breaks tests
45
45
  "!src/db/views/staticViews.*",
46
+ "!src/**/*.spec.{js,ts}",
46
47
  ],
47
48
  coverageReporters: ["lcov", "json", "clover"],
48
49
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@budibase/server",
3
3
  "email": "hi@budibase.com",
4
- "version": "2.4.27-alpha.1",
4
+ "version": "2.4.27-alpha.11",
5
5
  "description": "Budibase Web Server",
6
6
  "main": "src/index.ts",
7
7
  "repository": {
@@ -14,7 +14,8 @@
14
14
  "build:dev": "yarn prebuild && tsc --build --watch --preserveWatchOutput",
15
15
  "debug": "yarn build && node --expose-gc --inspect=9222 dist/index.js",
16
16
  "postbuild": "copyfiles -u 1 src/**/*.svelte dist/ && copyfiles -u 1 src/**/*.hbs dist/ && copyfiles -u 1 src/**/*.json dist/",
17
- "test": "bash scripts/test.sh",
17
+ "test": "NODE_OPTIONS=\"--max-old-space-size=4096\" bash scripts/test.sh",
18
+ "test:memory": "jest --maxWorkers=2 --logHeapUsage --forceExit",
18
19
  "test:watch": "jest --watch",
19
20
  "predocker": "copyfiles -f ../client/dist/budibase-client.js ../client/manifest.json client",
20
21
  "build:docker": "yarn run predocker && docker build . -t app-service --label version=$BUDIBASE_RELEASE_VERSION",
@@ -43,12 +44,12 @@
43
44
  "license": "GPL-3.0",
44
45
  "dependencies": {
45
46
  "@apidevtools/swagger-parser": "10.0.3",
46
- "@budibase/backend-core": "2.4.27-alpha.1",
47
- "@budibase/client": "2.4.27-alpha.1",
48
- "@budibase/pro": "2.4.27-alpha.0",
49
- "@budibase/shared-core": "2.4.27-alpha.1",
50
- "@budibase/string-templates": "2.4.27-alpha.1",
51
- "@budibase/types": "2.4.27-alpha.1",
47
+ "@budibase/backend-core": "2.4.27-alpha.11",
48
+ "@budibase/client": "2.4.27-alpha.11",
49
+ "@budibase/pro": "2.4.27-alpha.10",
50
+ "@budibase/shared-core": "2.4.27-alpha.11",
51
+ "@budibase/string-templates": "2.4.27-alpha.11",
52
+ "@budibase/types": "2.4.27-alpha.11",
52
53
  "@bull-board/api": "3.7.0",
53
54
  "@bull-board/koa": "3.9.4",
54
55
  "@elastic/elasticsearch": "7.10.0",
@@ -125,7 +126,7 @@
125
126
  "@babel/core": "7.17.4",
126
127
  "@babel/preset-env": "7.16.11",
127
128
  "@budibase/standard-components": "^0.9.139",
128
- "@jest/test-sequencer": "24.9.0",
129
+ "@jest/test-sequencer": "29.5.0",
129
130
  "@swc/core": "^1.3.25",
130
131
  "@swc/jest": "^0.2.24",
131
132
  "@trendyol/jest-testcontainers": "^2.1.1",
@@ -134,7 +135,7 @@
134
135
  "@types/global-agent": "2.1.1",
135
136
  "@types/google-spreadsheet": "3.1.5",
136
137
  "@types/ioredis": "4.28.10",
137
- "@types/jest": "27.5.1",
138
+ "@types/jest": "29.5.0",
138
139
  "@types/koa": "2.13.4",
139
140
  "@types/koa__router": "8.0.8",
140
141
  "@types/lodash": "4.14.180",
@@ -154,7 +155,7 @@
154
155
  "eslint": "6.8.0",
155
156
  "ioredis-mock": "7.2.0",
156
157
  "is-wsl": "2.2.0",
157
- "jest": "28.1.1",
158
+ "jest": "29.5.0",
158
159
  "jest-openapi": "0.14.2",
159
160
  "jest-serial-runner": "^1.2.1",
160
161
  "nodemon": "2.0.15",
@@ -166,7 +167,7 @@
166
167
  "supertest": "6.2.2",
167
168
  "swagger-jsdoc": "6.1.0",
168
169
  "timekeeper": "2.2.0",
169
- "ts-jest": "28.0.4",
170
+ "ts-jest": "29.0.5",
170
171
  "ts-node": "10.8.1",
171
172
  "tsconfig-paths": "4.0.0",
172
173
  "typescript": "4.7.3",
@@ -175,5 +176,5 @@
175
176
  "optionalDependencies": {
176
177
  "oracledb": "5.3.0"
177
178
  },
178
- "gitHead": "6427e02e1854db744eacb5c32312f6caba8e3427"
179
+ "gitHead": "302eb8fbea8c7b9e70b266bfcbea6712635d02a9"
179
180
  }
package/scripts/test.sh CHANGED
@@ -3,10 +3,10 @@
3
3
  if [[ -n $CI ]]
4
4
  then
5
5
  # --runInBand performs better in ci where resources are limited
6
- echo "jest --coverage --runInBand"
7
- jest --coverage --runInBand
6
+ echo "jest --coverage --runInBand --forceExit"
7
+ jest --coverage --runInBand --forceExit
8
8
  else
9
9
  # --maxWorkers performs better in development
10
10
  echo "jest --coverage --maxWorkers=2"
11
11
  jest --coverage --maxWorkers=2
12
- fi
12
+ fi
@@ -20,10 +20,10 @@ import {
20
20
  cache,
21
21
  tenancy,
22
22
  context,
23
- errors,
24
23
  events,
25
24
  migrations,
26
25
  objectStore,
26
+ ErrorCode,
27
27
  } from "@budibase/backend-core"
28
28
  import { USERS_TABLE_SCHEMA } from "../../constants"
29
29
  import { buildDefaultDocs } from "../../db/defaultData/datasource_bb_default"
@@ -44,7 +44,6 @@ import {
44
44
  Layout,
45
45
  Screen,
46
46
  MigrationType,
47
- BBContext,
48
47
  Database,
49
48
  UserCtx,
50
49
  } from "@budibase/types"
@@ -74,14 +73,14 @@ async function getScreens() {
74
73
  ).rows.map((row: any) => row.doc)
75
74
  }
76
75
 
77
- function getUserRoleId(ctx: BBContext) {
76
+ function getUserRoleId(ctx: UserCtx) {
78
77
  return !ctx.user?.role || !ctx.user.role._id
79
78
  ? roles.BUILTIN_ROLE_IDS.PUBLIC
80
79
  : ctx.user.role._id
81
80
  }
82
81
 
83
82
  function checkAppUrl(
84
- ctx: BBContext,
83
+ ctx: UserCtx,
85
84
  apps: App[],
86
85
  url: string,
87
86
  currentAppId?: string
@@ -95,7 +94,7 @@ function checkAppUrl(
95
94
  }
96
95
 
97
96
  function checkAppName(
98
- ctx: BBContext,
97
+ ctx: UserCtx,
99
98
  apps: App[],
100
99
  name: string,
101
100
  currentAppId?: string
@@ -160,7 +159,7 @@ async function addDefaultTables(db: Database) {
160
159
  await db.bulkDocs([...defaultDbDocs])
161
160
  }
162
161
 
163
- export async function fetch(ctx: BBContext) {
162
+ export async function fetch(ctx: UserCtx) {
164
163
  const dev = ctx.query && ctx.query.status === AppStatus.DEV
165
164
  const all = ctx.query && ctx.query.status === AppStatus.ALL
166
165
  const apps = (await dbCore.getAllApps({ dev, all })) as App[]
@@ -185,7 +184,7 @@ export async function fetch(ctx: BBContext) {
185
184
  ctx.body = await checkAppMetadata(apps)
186
185
  }
187
186
 
188
- export async function fetchAppDefinition(ctx: BBContext) {
187
+ export async function fetchAppDefinition(ctx: UserCtx) {
189
188
  const layouts = await getLayouts()
190
189
  const userRoleId = getUserRoleId(ctx)
191
190
  const accessController = new roles.AccessController()
@@ -231,7 +230,7 @@ export async function fetchAppPackage(ctx: UserCtx) {
231
230
  }
232
231
  }
233
232
 
234
- async function performAppCreate(ctx: BBContext) {
233
+ async function performAppCreate(ctx: UserCtx) {
235
234
  const apps = (await dbCore.getAllApps({ dev: true })) as App[]
236
235
  const name = ctx.request.body.name,
237
236
  possibleUrl = ctx.request.body.url
@@ -360,7 +359,7 @@ async function creationEvents(request: any, app: App) {
360
359
  }
361
360
  }
362
361
 
363
- async function appPostCreate(ctx: BBContext, app: App) {
362
+ async function appPostCreate(ctx: UserCtx, app: App) {
364
363
  const tenantId = tenancy.getTenantId()
365
364
  await migrations.backPopulateMigrations({
366
365
  type: MigrationType.APP,
@@ -378,7 +377,7 @@ async function appPostCreate(ctx: BBContext, app: App) {
378
377
  return quotas.addRows(rowCount)
379
378
  })
380
379
  } catch (err: any) {
381
- if (err.code && err.code === errors.codes.USAGE_LIMIT_EXCEEDED) {
380
+ if (err.code && err.code === ErrorCode.USAGE_LIMIT_EXCEEDED) {
382
381
  // this import resulted in row usage exceeding the quota
383
382
  // delete the app
384
383
  // skip pre and post-steps as no rows have been added to quotas yet
@@ -391,7 +390,7 @@ async function appPostCreate(ctx: BBContext, app: App) {
391
390
  }
392
391
  }
393
392
 
394
- export async function create(ctx: BBContext) {
393
+ export async function create(ctx: UserCtx) {
395
394
  const newApplication = await quotas.addApp(() => performAppCreate(ctx))
396
395
  await appPostCreate(ctx, newApplication)
397
396
  await cache.bustCache(cache.CacheKey.CHECKLIST)
@@ -401,7 +400,7 @@ export async function create(ctx: BBContext) {
401
400
 
402
401
  // This endpoint currently operates as a PATCH rather than a PUT
403
402
  // Thus name and url fields are handled only if present
404
- export async function update(ctx: BBContext) {
403
+ export async function update(ctx: UserCtx) {
405
404
  const apps = (await dbCore.getAllApps({ dev: true })) as App[]
406
405
  // validation
407
406
  const name = ctx.request.body.name,
@@ -421,7 +420,7 @@ export async function update(ctx: BBContext) {
421
420
  ctx.body = app
422
421
  }
423
422
 
424
- export async function updateClient(ctx: BBContext) {
423
+ export async function updateClient(ctx: UserCtx) {
425
424
  // Get current app version
426
425
  const db = context.getAppDB()
427
426
  const application = await db.get(DocumentType.APP_METADATA)
@@ -445,7 +444,7 @@ export async function updateClient(ctx: BBContext) {
445
444
  ctx.body = app
446
445
  }
447
446
 
448
- export async function revertClient(ctx: BBContext) {
447
+ export async function revertClient(ctx: UserCtx) {
449
448
  // Check app can be reverted
450
449
  const db = context.getAppDB()
451
450
  const application = await db.get(DocumentType.APP_METADATA)
@@ -471,7 +470,7 @@ export async function revertClient(ctx: BBContext) {
471
470
  ctx.body = app
472
471
  }
473
472
 
474
- const unpublishApp = async (ctx: any) => {
473
+ async function unpublishApp(ctx: UserCtx) {
475
474
  let appId = ctx.params.appId
476
475
  appId = dbCore.getProdAppID(appId)
477
476
 
@@ -487,7 +486,7 @@ const unpublishApp = async (ctx: any) => {
487
486
  return result
488
487
  }
489
488
 
490
- async function destroyApp(ctx: BBContext) {
489
+ async function destroyApp(ctx: UserCtx) {
491
490
  let appId = ctx.params.appId
492
491
  appId = dbCore.getProdAppID(appId)
493
492
  const devAppId = dbCore.getDevAppID(appId)
@@ -515,12 +514,12 @@ async function destroyApp(ctx: BBContext) {
515
514
  return result
516
515
  }
517
516
 
518
- async function preDestroyApp(ctx: BBContext) {
517
+ async function preDestroyApp(ctx: UserCtx) {
519
518
  const { rows } = await getUniqueRows([ctx.params.appId])
520
519
  ctx.rowCount = rows.length
521
520
  }
522
521
 
523
- async function postDestroyApp(ctx: BBContext) {
522
+ async function postDestroyApp(ctx: UserCtx) {
524
523
  const rowCount = ctx.rowCount
525
524
  await groups.cleanupApp(ctx.params.appId)
526
525
  if (rowCount) {
@@ -528,7 +527,7 @@ async function postDestroyApp(ctx: BBContext) {
528
527
  }
529
528
  }
530
529
 
531
- export async function destroy(ctx: BBContext) {
530
+ export async function destroy(ctx: UserCtx) {
532
531
  await preDestroyApp(ctx)
533
532
  const result = await destroyApp(ctx)
534
533
  await postDestroyApp(ctx)
@@ -536,7 +535,7 @@ export async function destroy(ctx: BBContext) {
536
535
  ctx.body = result
537
536
  }
538
537
 
539
- export const unpublish = async (ctx: BBContext) => {
538
+ export async function unpublish(ctx: UserCtx) {
540
539
  const prodAppId = dbCore.getProdAppID(ctx.params.appId)
541
540
  const dbExists = await dbCore.dbExists(prodAppId)
542
541
 
@@ -551,7 +550,7 @@ export const unpublish = async (ctx: BBContext) => {
551
550
  ctx.status = 204
552
551
  }
553
552
 
554
- export async function sync(ctx: BBContext) {
553
+ export async function sync(ctx: UserCtx) {
555
554
  const appId = ctx.params.appId
556
555
  try {
557
556
  ctx.body = await sdk.applications.syncApp(appId)
@@ -62,10 +62,11 @@ export async function validate({
62
62
  }
63
63
  const errors: any = {}
64
64
  for (let fieldName of Object.keys(fetchedTable.schema)) {
65
- const constraints = cloneDeep(fetchedTable.schema[fieldName].constraints)
66
- const type = fetchedTable.schema[fieldName].type
65
+ const column = fetchedTable.schema[fieldName]
66
+ const constraints = cloneDeep(column.constraints)
67
+ const type = column.type
67
68
  // formulas shouldn't validated, data will be deleted anyway
68
- if (type === FieldTypes.FORMULA) {
69
+ if (type === FieldTypes.FORMULA || column.autocolumn) {
69
70
  continue
70
71
  }
71
72
  // special case for options, need to always allow unselected (null)
@@ -11,10 +11,12 @@ import {
11
11
  } from "../../../utilities/fileSystem"
12
12
  import env from "../../../environment"
13
13
  import { DocumentType } from "../../../db/utils"
14
- import { context, objectStore, utils } from "@budibase/backend-core"
14
+ import { context, objectStore, utils, configs } from "@budibase/backend-core"
15
15
  import AWS from "aws-sdk"
16
16
  import fs from "fs"
17
17
  import sdk from "../../../sdk"
18
+ import * as pro from "@budibase/pro"
19
+
18
20
  const send = require("koa-send")
19
21
 
20
22
  async function prepareUpload({ s3Key, bucket, metadata, file }: any) {
@@ -98,33 +100,74 @@ export const deleteObjects = async function (ctx: any) {
98
100
  }
99
101
 
100
102
  export const serveApp = async function (ctx: any) {
101
- const db = context.getAppDB({ skip_setup: true })
102
- const appInfo = await db.get(DocumentType.APP_METADATA)
103
- let appId = context.getAppId()
103
+ //Public Settings
104
+ const { config } = await configs.getSettingsConfigDoc()
105
+ const branding = await pro.branding.getBrandingConfig(config)
104
106
 
105
- if (!env.isJest()) {
106
- const App = require("./templates/BudibaseApp.svelte").default
107
- const plugins = objectStore.enrichPluginURLs(appInfo.usedPlugins)
108
- const { head, html, css } = App.render({
109
- metaImage:
110
- "https://res.cloudinary.com/daog6scxm/image/upload/v1666109324/meta-images/budibase-meta-image_uukc1m.png",
111
- title: appInfo.name,
112
- production: env.isProd(),
113
- appId,
114
- clientLibPath: objectStore.clientLibraryUrl(appId!, appInfo.version),
115
- usedPlugins: plugins,
116
- })
107
+ let db
108
+ try {
109
+ db = context.getAppDB({ skip_setup: true })
110
+ const appInfo = await db.get(DocumentType.APP_METADATA)
111
+ let appId = context.getAppId()
117
112
 
118
- const appHbs = loadHandlebarsFile(`${__dirname}/templates/app.hbs`)
119
- ctx.body = await processString(appHbs, {
120
- head,
121
- body: html,
122
- style: css.code,
123
- appId,
124
- })
125
- } else {
126
- // just return the app info for jest to assert on
127
- ctx.body = appInfo
113
+ if (!env.isJest()) {
114
+ const App = require("./templates/BudibaseApp.svelte").default
115
+ const plugins = objectStore.enrichPluginURLs(appInfo.usedPlugins)
116
+ const { head, html, css } = App.render({
117
+ metaImage:
118
+ branding?.metaImageUrl ||
119
+ "https://res.cloudinary.com/daog6scxm/image/upload/v1666109324/meta-images/budibase-meta-image_uukc1m.png",
120
+ metaDescription: branding?.metaDescription || "",
121
+ metaTitle:
122
+ branding?.metaTitle || `${appInfo.name} - built with Budibase`,
123
+ title: appInfo.name,
124
+ production: env.isProd(),
125
+ appId,
126
+ clientLibPath: objectStore.clientLibraryUrl(appId!, appInfo.version),
127
+ usedPlugins: plugins,
128
+ favicon:
129
+ branding.faviconUrl !== ""
130
+ ? objectStore.getGlobalFileUrl("settings", "faviconUrl")
131
+ : "",
132
+ logo:
133
+ config?.logoUrl !== ""
134
+ ? objectStore.getGlobalFileUrl("settings", "logoUrl")
135
+ : "",
136
+ })
137
+ const appHbs = loadHandlebarsFile(`${__dirname}/templates/app.hbs`)
138
+ ctx.body = await processString(appHbs, {
139
+ head,
140
+ body: html,
141
+ style: css.code,
142
+ appId,
143
+ })
144
+ } else {
145
+ // just return the app info for jest to assert on
146
+ ctx.body = appInfo
147
+ }
148
+ } catch (error) {
149
+ if (!env.isJest()) {
150
+ const App = require("./templates/BudibaseApp.svelte").default
151
+ const { head, html, css } = App.render({
152
+ title: branding?.metaTitle,
153
+ metaTitle: branding?.metaTitle,
154
+ metaImage:
155
+ branding?.metaImageUrl ||
156
+ "https://res.cloudinary.com/daog6scxm/image/upload/v1666109324/meta-images/budibase-meta-image_uukc1m.png",
157
+ metaDescription: branding?.metaDescription || "",
158
+ favicon:
159
+ branding.faviconUrl !== ""
160
+ ? objectStore.getGlobalFileUrl("settings", "faviconUrl")
161
+ : "",
162
+ })
163
+
164
+ const appHbs = loadHandlebarsFile(`${__dirname}/templates/app.hbs`)
165
+ ctx.body = await processString(appHbs, {
166
+ head,
167
+ body: html,
168
+ style: css.code,
169
+ })
170
+ }
128
171
  }
129
172
  }
130
173
 
@@ -1,7 +1,10 @@
1
1
  <script>
2
2
  export let title = ""
3
3
  export let favicon = ""
4
+
4
5
  export let metaImage = ""
6
+ export let metaTitle = ""
7
+ export let metaDescription = ""
5
8
 
6
9
  export let clientLibPath
7
10
  export let usedPlugins
@@ -13,18 +16,33 @@
13
16
  name="viewport"
14
17
  content="width=device-width, initial-scale=1.0, viewport-fit=cover"
15
18
  />
19
+
20
+ <!-- Primary Meta Tags -->
21
+ <meta name="title" content={metaTitle} />
22
+ <meta name="description" content={metaDescription} />
23
+
16
24
  <!-- Opengraph Meta Tags -->
17
- <meta name="twitter:card" content="summary_large_image" />
18
- <meta name="twitter:site" content="@budibase" />
19
- <meta name="twitter:image" content={metaImage} />
20
- <meta name="twitter:title" content="{title} - built with Budibase" />
21
25
  <meta property="og:site_name" content="Budibase" />
22
26
  <meta property="og:title" content="{title} - built with Budibase" />
27
+ <meta property="og:description" content={metaDescription} />
23
28
  <meta property="og:type" content="website" />
24
29
  <meta property="og:image" content={metaImage} />
25
30
 
31
+ <!-- Twitter -->
32
+ <meta property="twitter:card" content="summary_large_image" />
33
+ <meta property="twitter:site" content="@budibase" />
34
+ <meta property="twitter:image" content={metaImage} />
35
+ <meta property="twitter:image:alt" content="{title} - built with Budibase" />
36
+ <meta property="twitter:title" content="{title} - built with Budibase" />
37
+ <meta property="twitter:description" content={metaDescription} />
38
+
26
39
  <title>{title}</title>
27
- <link rel="icon" type="image/png" href={favicon} />
40
+ {#if favicon !== ""}
41
+ <link rel="icon" type="image/png" href={favicon} />
42
+ {:else}
43
+ <link rel="icon" type="image/png" href="https://i.imgur.com/Xhdt1YP.png" />
44
+ {/if}
45
+
28
46
  <link rel="stylesheet" href="https://rsms.me/inter/inter.css" />
29
47
  <link rel="preconnect" href="https://fonts.gstatic.com" />
30
48
  <link
@@ -83,11 +101,16 @@
83
101
 
84
102
  <body id="app">
85
103
  <div id="error">
86
- <h1>There was an error loading your app</h1>
87
- <h2>
88
- The Budibase client library could not be loaded. Try republishing your
89
- app.
90
- </h2>
104
+ {#if clientLibPath}
105
+ <h1>There was an error loading your app</h1>
106
+ <h2>
107
+ The Budibase client library could not be loaded. Try republishing your
108
+ app.
109
+ </h2>
110
+ {:else}
111
+ <h2>We couldn't find that application</h2>
112
+ <p />
113
+ {/if}
91
114
  </div>
92
115
  <script type="application/javascript">
93
116
  window.INIT_TIME = Date.now()