Merge branch 'master' into fix/support-multiple-relationships-same-tables

This commit is contained in:
Adria Navarro 2024-10-28 10:40:06 +01:00 committed by GitHub
commit f28746089d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
7 changed files with 45 additions and 59 deletions

View File

@ -831,8 +831,7 @@
"type": "string", "type": "string",
"enum": [ "enum": [
"static", "static",
"dynamic", "dynamic"
"ai"
], ],
"description": "Defines whether this is a static or dynamic formula." "description": "Defines whether this is a static or dynamic formula."
} }
@ -1042,8 +1041,7 @@
"type": "string", "type": "string",
"enum": [ "enum": [
"static", "static",
"dynamic", "dynamic"
"ai"
], ],
"description": "Defines whether this is a static or dynamic formula." "description": "Defines whether this is a static or dynamic formula."
} }
@ -1264,8 +1262,7 @@
"type": "string", "type": "string",
"enum": [ "enum": [
"static", "static",
"dynamic", "dynamic"
"ai"
], ],
"description": "Defines whether this is a static or dynamic formula." "description": "Defines whether this is a static or dynamic formula."
} }

View File

@ -761,7 +761,6 @@ components:
enum: enum:
- static - static
- dynamic - dynamic
- ai
description: Defines whether this is a static or dynamic formula. description: Defines whether this is a static or dynamic formula.
- type: object - type: object
properties: properties:
@ -931,7 +930,6 @@ components:
enum: enum:
- static - static
- dynamic - dynamic
- ai
description: Defines whether this is a static or dynamic formula. description: Defines whether this is a static or dynamic formula.
- type: object - type: object
properties: properties:
@ -1108,7 +1106,6 @@ components:
enum: enum:
- static - static
- dynamic - dynamic
- ai
description: Defines whether this is a static or dynamic formula. description: Defines whether this is a static or dynamic formula.
- type: object - type: object
properties: properties:

View File

@ -138,7 +138,7 @@ const tableSchema = {
}, },
formulaType: { formulaType: {
type: "string", type: "string",
enum: Object.values(FormulaType), enum: [FormulaType.STATIC, FormulaType.DYNAMIC],
description: description:
"Defines whether this is a static or dynamic formula.", "Defines whether this is a static or dynamic formula.",
}, },

View File

@ -5,22 +5,35 @@ import { Expectations } from "../../../../tests/utilities/api/base"
type RequestOpts = { internal?: boolean; appId?: string } type RequestOpts = { internal?: boolean; appId?: string }
type PublicAPIExpectations = Omit<Expectations, "headers" | "headersNotPresent"> export interface PublicAPIExpectations {
status?: number
body?: Record<string, any>
}
export class PublicAPIRequest { export class PublicAPIRequest {
private makeRequest: MakeRequestResponse | undefined private makeRequest: MakeRequestResponse
private appId: string | undefined private appId: string | undefined
private _tables: PublicTableAPI | undefined
private _rows: PublicRowAPI | undefined
private _apiKey: string | undefined
async init(config: TestConfiguration, user: User, opts?: RequestOpts) { tables: PublicTableAPI
this._apiKey = await config.generateApiKey(user._id) rows: PublicRowAPI
this.makeRequest = generateMakeRequest(this.apiKey, opts) apiKey: string
this.appId = opts?.appId
this._tables = new PublicTableAPI(this) private constructor(
this._rows = new PublicRowAPI(this) apiKey: string,
return this makeRequest: MakeRequestResponse,
appId?: string
) {
this.apiKey = apiKey
this.makeRequest = makeRequest
this.appId = appId
this.tables = new PublicTableAPI(this)
this.rows = new PublicRowAPI(this)
}
static async init(config: TestConfiguration, user: User, opts?: RequestOpts) {
const apiKey = await config.generateApiKey(user._id)
const makeRequest = generateMakeRequest(apiKey, opts)
return new this(apiKey, makeRequest, opts?.appId)
} }
opts(opts: RequestOpts) { opts(opts: RequestOpts) {
@ -48,27 +61,6 @@ export class PublicAPIRequest {
} }
return res.body return res.body
} }
get apiKey(): string {
if (!this._apiKey) {
throw new Error("Init has not been called")
}
return this._apiKey
}
get tables(): PublicTableAPI {
if (!this._tables) {
throw new Error("Init has not been called")
}
return this._tables
}
get rows(): PublicRowAPI {
if (!this._rows) {
throw new Error("Init has not been called")
}
return this._rows
}
} }
export class PublicTableAPI { export class PublicTableAPI {

View File

@ -20,8 +20,8 @@ describe("check public API security", () => {
[config.getProdAppId()]: roles.BUILTIN_ROLE_IDS.BASIC, [config.getProdAppId()]: roles.BUILTIN_ROLE_IDS.BASIC,
}, },
}) })
builderRequest = await new PublicAPIRequest().init(config, builderUser) builderRequest = await PublicAPIRequest.init(config, builderUser)
appUserRequest = await new PublicAPIRequest().init(config, appUser) appUserRequest = await PublicAPIRequest.init(config, appUser)
table = (await builderRequest.tables.create(basicTable())).data table = (await builderRequest.tables.create(basicTable())).data
}) })

View File

@ -257,7 +257,7 @@ export interface components {
* @description Defines whether this is a static or dynamic formula. * @description Defines whether this is a static or dynamic formula.
* @enum {string} * @enum {string}
*/ */
formulaType?: "static" | "dynamic" | "ai"; formulaType?: "static" | "dynamic";
} }
| { | {
/** /**
@ -369,7 +369,7 @@ export interface components {
* @description Defines whether this is a static or dynamic formula. * @description Defines whether this is a static or dynamic formula.
* @enum {string} * @enum {string}
*/ */
formulaType?: "static" | "dynamic" | "ai"; formulaType?: "static" | "dynamic";
} }
| { | {
/** /**
@ -483,7 +483,7 @@ export interface components {
* @description Defines whether this is a static or dynamic formula. * @description Defines whether this is a static or dynamic formula.
* @enum {string} * @enum {string}
*/ */
formulaType?: "static" | "dynamic" | "ai"; formulaType?: "static" | "dynamic";
} }
| { | {
/** /**

View File

@ -2051,7 +2051,7 @@
resolved "https://registry.yarnpkg.com/@bcoe/v8-coverage/-/v8-coverage-0.2.3.tgz#75a2e8b51cb758a7553d6804a5932d7aace75c39" resolved "https://registry.yarnpkg.com/@bcoe/v8-coverage/-/v8-coverage-0.2.3.tgz#75a2e8b51cb758a7553d6804a5932d7aace75c39"
integrity sha512-0hYQ8SB4Db5zvZB4axdMHGwEaQjkZzFjQiN9LVYvIFB2nSUHW9tYpxWriPrWDASIxiaXax83REcLxuSdnGPZtw== integrity sha512-0hYQ8SB4Db5zvZB4axdMHGwEaQjkZzFjQiN9LVYvIFB2nSUHW9tYpxWriPrWDASIxiaXax83REcLxuSdnGPZtw==
"@budibase/backend-core@2.32.11": "@budibase/backend-core@2.33.2":
version "0.0.0" version "0.0.0"
dependencies: dependencies:
"@budibase/nano" "10.1.5" "@budibase/nano" "10.1.5"
@ -2132,15 +2132,15 @@
through2 "^2.0.0" through2 "^2.0.0"
"@budibase/pro@npm:@budibase/pro@latest": "@budibase/pro@npm:@budibase/pro@latest":
version "2.32.11" version "2.33.2"
resolved "https://registry.yarnpkg.com/@budibase/pro/-/pro-2.32.11.tgz#c94d534f829ca0ef252677757e157a7e58b87b4d" resolved "https://registry.yarnpkg.com/@budibase/pro/-/pro-2.33.2.tgz#5c2012f7b2bf0fd871cda1ad37ad7a0442c84658"
integrity sha512-mOkqJpqHKWsfTWZwWcvBCYFUIluSUHltQNinc1ZRsg9rC3OKoHSDop6gzm744++H/GzGRN8V86kLhCgtNIlkpA== integrity sha512-lBB6Wfp6OIOHRlGq82WS9KxvEXRs/P2QlwJT0Aj9PhmkQFsnXm2r8d18f0xTGvcflD+iR7XGP/k56JlCanmhQg==
dependencies: dependencies:
"@anthropic-ai/sdk" "^0.27.3" "@anthropic-ai/sdk" "^0.27.3"
"@budibase/backend-core" "2.32.11" "@budibase/backend-core" "2.33.2"
"@budibase/shared-core" "2.32.11" "@budibase/shared-core" "2.33.2"
"@budibase/string-templates" "2.32.11" "@budibase/string-templates" "2.33.2"
"@budibase/types" "2.32.11" "@budibase/types" "2.33.2"
"@koa/router" "8.0.8" "@koa/router" "8.0.8"
bull "4.10.1" bull "4.10.1"
dd-trace "5.2.0" dd-trace "5.2.0"
@ -2153,13 +2153,13 @@
scim-patch "^0.8.1" scim-patch "^0.8.1"
scim2-parse-filter "^0.2.8" scim2-parse-filter "^0.2.8"
"@budibase/shared-core@2.32.11": "@budibase/shared-core@2.33.2":
version "0.0.0" version "0.0.0"
dependencies: dependencies:
"@budibase/types" "0.0.0" "@budibase/types" "0.0.0"
cron-validate "1.4.5" cron-validate "1.4.5"
"@budibase/string-templates@2.32.11": "@budibase/string-templates@2.33.2":
version "0.0.0" version "0.0.0"
dependencies: dependencies:
"@budibase/handlebars-helpers" "^0.13.2" "@budibase/handlebars-helpers" "^0.13.2"
@ -2167,7 +2167,7 @@
handlebars "^4.7.8" handlebars "^4.7.8"
lodash.clonedeep "^4.5.0" lodash.clonedeep "^4.5.0"
"@budibase/types@2.32.11": "@budibase/types@2.33.2":
version "0.0.0" version "0.0.0"
dependencies: dependencies:
scim-patch "^0.8.1" scim-patch "^0.8.1"