@budibase/backend-core 2.6.16-alpha.1 → 2.6.16

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@budibase/backend-core",
3
- "version": "2.6.16-alpha.1",
3
+ "version": "2.6.16",
4
4
  "description": "Budibase backend core libraries used in server and worker",
5
5
  "main": "dist/src/index.js",
6
6
  "types": "dist/src/index.d.ts",
@@ -15,6 +15,8 @@
15
15
  "prebuild": "rimraf dist/",
16
16
  "prepack": "cp package.json dist",
17
17
  "build": "tsc -p tsconfig.build.json",
18
+ "build:pro": "../../scripts/pro/build.sh",
19
+ "postbuild": "yarn run build:pro",
18
20
  "build:dev": "yarn prebuild && tsc --build --watch --preserveWatchOutput",
19
21
  "test": "bash scripts/test.sh",
20
22
  "test:watch": "jest --watchAll"
@@ -22,7 +24,7 @@
22
24
  "dependencies": {
23
25
  "@budibase/nano": "10.1.2",
24
26
  "@budibase/pouchdb-replication-stream": "1.2.10",
25
- "@budibase/types": "2.6.16-alpha.1",
27
+ "@budibase/types": "^2.6.16",
26
28
  "@shopify/jest-koa-mocks": "5.0.1",
27
29
  "@techpass/passport-openidconnect": "0.3.2",
28
30
  "aws-cloudfront-sign": "2.2.0",
@@ -88,5 +90,5 @@
88
90
  "tsconfig-paths": "4.0.0",
89
91
  "typescript": "4.7.3"
90
92
  },
91
- "gitHead": "f117256d4e83d59b5ac23b0070ee25591e8f6d93"
93
+ "gitHead": "d43a6a44bd074e077ea131303c0f7a2b0e0ddb75"
92
94
  }
@@ -21,7 +21,7 @@ export enum ViewName {
21
21
  AUTOMATION_LOGS = "automation_logs",
22
22
  ACCOUNT_BY_EMAIL = "account_by_email",
23
23
  PLATFORM_USERS_LOWERCASE = "platform_users_lowercase",
24
- USER_BY_GROUP = "user_by_group",
24
+ USER_BY_GROUP = "by_group_user",
25
25
  APP_BACKUP_BY_TRIGGER = "by_trigger",
26
26
  }
27
27
 
@@ -5,7 +5,6 @@ import * as db from "../../db"
5
5
  import { Header } from "../../constants"
6
6
  import { newid } from "../../utils"
7
7
  import env from "../../environment"
8
- import { BBContext } from "@budibase/types"
9
8
 
10
9
  describe("utils", () => {
11
10
  const config = new DBTestConfiguration()
@@ -107,85 +106,4 @@ describe("utils", () => {
107
106
  expect(actual).toBe(undefined)
108
107
  })
109
108
  })
110
-
111
- describe("isServingBuilder", () => {
112
- let ctx: BBContext
113
-
114
- const expectResult = (result: boolean) =>
115
- expect(utils.isServingBuilder(ctx)).toBe(result)
116
-
117
- beforeEach(() => {
118
- ctx = structures.koa.newContext()
119
- })
120
-
121
- it("returns true if current path is in builder", async () => {
122
- ctx.path = "/builder/app/app_"
123
- expectResult(true)
124
- })
125
-
126
- it("returns false if current path doesn't have '/' suffix", async () => {
127
- ctx.path = "/builder/app"
128
- expectResult(false)
129
-
130
- ctx.path = "/xx"
131
- expectResult(false)
132
- })
133
- })
134
-
135
- describe("isServingBuilderPreview", () => {
136
- let ctx: BBContext
137
-
138
- const expectResult = (result: boolean) =>
139
- expect(utils.isServingBuilderPreview(ctx)).toBe(result)
140
-
141
- beforeEach(() => {
142
- ctx = structures.koa.newContext()
143
- })
144
-
145
- it("returns true if current path is in builder preview", async () => {
146
- ctx.path = "/app/preview/xx"
147
- expectResult(true)
148
- })
149
-
150
- it("returns false if current path is not in builder preview", async () => {
151
- ctx.path = "/builder"
152
- expectResult(false)
153
-
154
- ctx.path = "/xx"
155
- expectResult(false)
156
- })
157
- })
158
-
159
- describe("isPublicAPIRequest", () => {
160
- let ctx: BBContext
161
-
162
- const expectResult = (result: boolean) =>
163
- expect(utils.isPublicApiRequest(ctx)).toBe(result)
164
-
165
- beforeEach(() => {
166
- ctx = structures.koa.newContext()
167
- })
168
-
169
- it("returns true if current path remains to public API", async () => {
170
- ctx.path = "/api/public/v1/invoices"
171
- expectResult(true)
172
-
173
- ctx.path = "/api/public/v1"
174
- expectResult(true)
175
-
176
- ctx.path = "/api/public/v2"
177
- expectResult(true)
178
-
179
- ctx.path = "/api/public/v21"
180
- expectResult(true)
181
- })
182
-
183
- it("returns false if current path doesn't remain to public API", async () => {
184
- ctx.path = "/api/public"
185
- expectResult(false)
186
-
187
- ctx.path = "/xx"
188
- expectResult(false)
189
- })
190
- })
191
109
  })
@@ -1,5 +1,11 @@
1
- import { getAllApps } from "../db"
2
- import { Header, MAX_VALID_DATE, DocumentType, SEPARATOR } from "../constants"
1
+ import { getAllApps, queryGlobalView } from "../db"
2
+ import {
3
+ Header,
4
+ MAX_VALID_DATE,
5
+ DocumentType,
6
+ SEPARATOR,
7
+ ViewName,
8
+ } from "../constants"
3
9
  import env from "../environment"
4
10
  import * as tenancy from "../tenancy"
5
11
  import * as context from "../context"
@@ -17,9 +23,7 @@ const APP_PREFIX = DocumentType.APP + SEPARATOR
17
23
  const PROD_APP_PREFIX = "/app/"
18
24
 
19
25
  const BUILDER_PREVIEW_PATH = "/app/preview"
20
- const BUILDER_PREFIX = "/builder"
21
- const BUILDER_APP_PREFIX = `${BUILDER_PREFIX}/app/`
22
- const PUBLIC_API_PREFIX = "/api/public/v"
26
+ const BUILDER_REFERER_PREFIX = "/builder/app/"
23
27
 
24
28
  function confirmAppId(possibleAppId: string | undefined) {
25
29
  return possibleAppId && possibleAppId.startsWith(APP_PREFIX)
@@ -65,18 +69,6 @@ export function isServingApp(ctx: Ctx) {
65
69
  return false
66
70
  }
67
71
 
68
- export function isServingBuilder(ctx: Ctx): boolean {
69
- return ctx.path.startsWith(BUILDER_APP_PREFIX)
70
- }
71
-
72
- export function isServingBuilderPreview(ctx: Ctx): boolean {
73
- return ctx.path.startsWith(BUILDER_PREVIEW_PATH)
74
- }
75
-
76
- export function isPublicApiRequest(ctx: Ctx): boolean {
77
- return ctx.path.startsWith(PUBLIC_API_PREFIX)
78
- }
79
-
80
72
  /**
81
73
  * Given a request tries to find the appId, which can be located in various places
82
74
  * @param {object} ctx The main request body to look through.
@@ -118,7 +110,7 @@ export async function getAppIdFromCtx(ctx: Ctx) {
118
110
  // make sure this is performed after prod app url resolution, in case the
119
111
  // referer header is present from a builder redirect
120
112
  const referer = ctx.request.headers.referer
121
- if (!appId && referer?.includes(BUILDER_APP_PREFIX)) {
113
+ if (!appId && referer?.includes(BUILDER_REFERER_PREFIX)) {
122
114
  const refererId = parseAppIdFromUrl(ctx.request.headers.referer)
123
115
  appId = confirmAppId(refererId)
124
116
  }
package/tsconfig.json CHANGED
@@ -7,6 +7,11 @@
7
7
  "@budibase/types": ["../types/src"]
8
8
  }
9
9
  },
10
-
11
- "exclude": ["node_modules", "dist"]
12
- }
10
+ "references": [
11
+ { "path": "../types" }
12
+ ],
13
+ "exclude": [
14
+ "node_modules",
15
+ "dist",
16
+ ]
17
+ }