Merge master.
This commit is contained in:
commit
da2dfcfad0
|
@ -36,12 +36,14 @@
|
|||
"files": ["**/*.ts"],
|
||||
"excludedFiles": ["qa-core/**"],
|
||||
"parser": "@typescript-eslint/parser",
|
||||
"plugins": ["@typescript-eslint"],
|
||||
"extends": ["eslint:recommended"],
|
||||
"globals": {
|
||||
"NodeJS": true
|
||||
},
|
||||
"rules": {
|
||||
"no-unused-vars": "off",
|
||||
"@typescript-eslint/no-unused-vars": "error",
|
||||
"local-rules/no-budibase-imports": "error"
|
||||
}
|
||||
},
|
||||
|
@ -49,7 +51,7 @@
|
|||
"files": ["**/*.spec.ts"],
|
||||
"excludedFiles": ["qa-core/**"],
|
||||
"parser": "@typescript-eslint/parser",
|
||||
"plugins": ["jest"],
|
||||
"plugins": ["jest", "@typescript-eslint"],
|
||||
"extends": ["eslint:recommended", "plugin:jest/recommended"],
|
||||
"env": {
|
||||
"jest/globals": true
|
||||
|
@ -59,6 +61,7 @@
|
|||
},
|
||||
"rules": {
|
||||
"no-unused-vars": "off",
|
||||
"@typescript-eslint/no-unused-vars": "error",
|
||||
"local-rules/no-test-com": "error",
|
||||
"local-rules/email-domain-example-com": "error",
|
||||
"no-console": "warn",
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
{
|
||||
"version": "2.22.5",
|
||||
"version": "2.22.7",
|
||||
"npmClient": "yarn",
|
||||
"packages": [
|
||||
"packages/*",
|
||||
|
|
|
@ -26,6 +26,7 @@
|
|||
"svelte": "^4.2.10",
|
||||
"svelte-eslint-parser": "^0.33.1",
|
||||
"typescript": "5.2.2",
|
||||
"typescript-eslint": "^7.3.1",
|
||||
"yargs": "^17.7.2"
|
||||
},
|
||||
"scripts": {
|
||||
|
|
|
@ -129,7 +129,7 @@ export default class BaseCache {
|
|||
}
|
||||
}
|
||||
|
||||
async bustCache(key: string, opts = { client: null }) {
|
||||
async bustCache(key: string) {
|
||||
const client = await this.getClient()
|
||||
try {
|
||||
await client.delete(generateTenantKey(key))
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import * as utils from "../utils"
|
||||
import { Duration, DurationType } from "../utils"
|
||||
import { Duration } from "../utils"
|
||||
import env from "../environment"
|
||||
import { getTenantId } from "../context"
|
||||
import * as redis from "../redis/init"
|
||||
|
|
|
@ -8,7 +8,7 @@ const DEFAULT_WRITE_RATE_MS = 10000
|
|||
let CACHE: BaseCache | null = null
|
||||
|
||||
interface CacheItem<T extends Document> {
|
||||
doc: any
|
||||
doc: T
|
||||
lastWrite: number
|
||||
}
|
||||
|
||||
|
|
|
@ -10,10 +10,6 @@ interface SearchResponse<T> {
|
|||
totalRows: number
|
||||
}
|
||||
|
||||
interface PaginatedSearchResponse<T> extends SearchResponse<T> {
|
||||
hasNextPage: boolean
|
||||
}
|
||||
|
||||
export type SearchParams<T> = {
|
||||
tableId?: string
|
||||
sort?: string
|
||||
|
|
|
@ -17,13 +17,8 @@ export function init(processors: ProcessorMap) {
|
|||
// if not processing in this instance, kick it off
|
||||
if (!processingPromise) {
|
||||
processingPromise = asyncEventQueue.process(async job => {
|
||||
const { event, identity, properties, timestamp } = job.data
|
||||
await documentProcessor.processEvent(
|
||||
event,
|
||||
identity,
|
||||
properties,
|
||||
timestamp
|
||||
)
|
||||
const { event, identity, properties } = job.data
|
||||
await documentProcessor.processEvent(event, identity, properties)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
import {
|
||||
Event,
|
||||
Identity,
|
||||
Group,
|
||||
IdentityType,
|
||||
AuditLogQueueEvent,
|
||||
AuditLogFn,
|
||||
|
@ -79,11 +78,11 @@ export default class AuditLogsProcessor implements EventProcessor {
|
|||
}
|
||||
}
|
||||
|
||||
async identify(identity: Identity, timestamp?: string | number) {
|
||||
async identify() {
|
||||
// no-op
|
||||
}
|
||||
|
||||
async identifyGroup(group: Group, timestamp?: string | number) {
|
||||
async identifyGroup() {
|
||||
// no-op
|
||||
}
|
||||
|
||||
|
|
|
@ -8,8 +8,7 @@ export default class LoggingProcessor implements EventProcessor {
|
|||
async processEvent(
|
||||
event: Event,
|
||||
identity: Identity,
|
||||
properties: any,
|
||||
timestamp?: string
|
||||
properties: any
|
||||
): Promise<void> {
|
||||
if (skipLogging) {
|
||||
return
|
||||
|
@ -17,14 +16,14 @@ export default class LoggingProcessor implements EventProcessor {
|
|||
console.log(`[audit] [identityType=${identity.type}] ${event}`, properties)
|
||||
}
|
||||
|
||||
async identify(identity: Identity, timestamp?: string | number) {
|
||||
async identify(identity: Identity) {
|
||||
if (skipLogging) {
|
||||
return
|
||||
}
|
||||
console.log(`[audit] identified`, identity)
|
||||
}
|
||||
|
||||
async identifyGroup(group: Group, timestamp?: string | number) {
|
||||
async identifyGroup(group: Group) {
|
||||
if (skipLogging) {
|
||||
return
|
||||
}
|
||||
|
|
|
@ -14,12 +14,7 @@ export default class DocumentUpdateProcessor implements EventProcessor {
|
|||
this.processors = processors
|
||||
}
|
||||
|
||||
async processEvent(
|
||||
event: Event,
|
||||
identity: Identity,
|
||||
properties: any,
|
||||
timestamp?: string | number
|
||||
) {
|
||||
async processEvent(event: Event, identity: Identity, properties: any) {
|
||||
const tenantId = identity.realTenantId
|
||||
const docId = getDocumentId(event, properties)
|
||||
if (!tenantId || !docId) {
|
||||
|
|
|
@ -28,7 +28,7 @@ export const buildMatcherRegex = (
|
|||
}
|
||||
|
||||
export const matches = (ctx: BBContext, options: RegexMatcher[]) => {
|
||||
return options.find(({ regex, method, route }) => {
|
||||
return options.find(({ regex, method }) => {
|
||||
const urlMatch = regex.test(ctx.request.url)
|
||||
const methodMatch =
|
||||
method === "ALL"
|
||||
|
|
|
@ -3,7 +3,7 @@ import { Cookie } from "../../../constants"
|
|||
import * as configs from "../../../configs"
|
||||
import * as cache from "../../../cache"
|
||||
import * as utils from "../../../utils"
|
||||
import { UserCtx, SSOProfile, DatasourceAuthCookie } from "@budibase/types"
|
||||
import { UserCtx, SSOProfile } from "@budibase/types"
|
||||
import { ssoSaveUserNoOp } from "../sso/sso"
|
||||
|
||||
const GoogleStrategy = require("passport-google-oauth").OAuth2Strategy
|
||||
|
|
|
@ -5,7 +5,6 @@ import * as context from "../../../context"
|
|||
import fetch from "node-fetch"
|
||||
import {
|
||||
SaveSSOUserFunction,
|
||||
SaveUserOpts,
|
||||
SSOAuthDetails,
|
||||
SSOUser,
|
||||
User,
|
||||
|
@ -14,10 +13,8 @@ import {
|
|||
// no-op function for user save
|
||||
// - this allows datasource auth and access token refresh to work correctly
|
||||
// - prefer no-op over an optional argument to ensure function is provided to login flows
|
||||
export const ssoSaveUserNoOp: SaveSSOUserFunction = (
|
||||
user: SSOUser,
|
||||
opts: SaveUserOpts
|
||||
) => Promise.resolve(user)
|
||||
export const ssoSaveUserNoOp: SaveSSOUserFunction = (user: SSOUser) =>
|
||||
Promise.resolve(user)
|
||||
|
||||
/**
|
||||
* Common authentication logic for third parties. e.g. OAuth, OIDC.
|
||||
|
|
|
@ -45,10 +45,6 @@ export const runMigration = async (
|
|||
options: MigrationOptions = {}
|
||||
) => {
|
||||
const migrationType = migration.type
|
||||
let tenantId: string | undefined
|
||||
if (migrationType !== MigrationType.INSTALLATION) {
|
||||
tenantId = context.getTenantId()
|
||||
}
|
||||
const migrationName = migration.name
|
||||
const silent = migration.silent
|
||||
|
||||
|
|
|
@ -126,7 +126,7 @@ describe("app", () => {
|
|||
|
||||
it("gets url with embedded minio", async () => {
|
||||
testEnv.withMinio()
|
||||
await testEnv.withTenant(tenantId => {
|
||||
await testEnv.withTenant(() => {
|
||||
const url = getAppFileUrl()
|
||||
expect(url).toBe(
|
||||
"/files/signed/prod-budi-app-assets/app_123/attachments/image.jpeg"
|
||||
|
@ -136,7 +136,7 @@ describe("app", () => {
|
|||
|
||||
it("gets url with custom S3", async () => {
|
||||
testEnv.withS3()
|
||||
await testEnv.withTenant(tenantId => {
|
||||
await testEnv.withTenant(() => {
|
||||
const url = getAppFileUrl()
|
||||
expect(url).toBe(
|
||||
"http://s3.example.com/prod-budi-app-assets/app_123/attachments/image.jpeg"
|
||||
|
@ -146,7 +146,7 @@ describe("app", () => {
|
|||
|
||||
it("gets url with cloudfront + s3", async () => {
|
||||
testEnv.withCloudfront()
|
||||
await testEnv.withTenant(tenantId => {
|
||||
await testEnv.withTenant(() => {
|
||||
const url = getAppFileUrl()
|
||||
// omit rest of signed params
|
||||
expect(
|
||||
|
|
|
@ -3,7 +3,7 @@ import { DBTestConfiguration } from "../../../tests/extra"
|
|||
import * as tenants from "../tenants"
|
||||
|
||||
describe("tenants", () => {
|
||||
const config = new DBTestConfiguration()
|
||||
new DBTestConfiguration()
|
||||
|
||||
describe("addTenant", () => {
|
||||
it("concurrently adds multiple tenants safely", async () => {
|
||||
|
|
|
@ -166,7 +166,7 @@ class InMemoryQueue implements Partial<Queue> {
|
|||
return []
|
||||
}
|
||||
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
async removeJobs(pattern: string) {
|
||||
// no-op
|
||||
}
|
||||
|
|
|
@ -132,7 +132,7 @@ function logging(queue: Queue, jobQueue: JobQueue) {
|
|||
// A Job is waiting to be processed as soon as a worker is idling.
|
||||
console.info(...getLogParams(eventType, BullEvent.WAITING, { jobId }))
|
||||
})
|
||||
.on(BullEvent.ACTIVE, async (job: Job, jobPromise: any) => {
|
||||
.on(BullEvent.ACTIVE, async (job: Job) => {
|
||||
// A job has started. You can use `jobPromise.cancel()`` to abort it.
|
||||
await doInJobContext(job, () => {
|
||||
console.info(...getLogParams(eventType, BullEvent.ACTIVE, { job }))
|
||||
|
|
|
@ -40,6 +40,7 @@ export async function shutdown() {
|
|||
if (inviteClient) await inviteClient.finish()
|
||||
if (passwordResetClient) await passwordResetClient.finish()
|
||||
if (socketClient) await socketClient.finish()
|
||||
if (docWritethroughClient) await docWritethroughClient.finish()
|
||||
}
|
||||
|
||||
process.on("exit", async () => {
|
||||
|
|
|
@ -120,7 +120,7 @@ describe("redis", () => {
|
|||
|
||||
await redis.bulkStore(data, ttl)
|
||||
|
||||
for (const [key, value] of Object.entries(data)) {
|
||||
for (const key of Object.keys(data)) {
|
||||
expect(await redis.get(key)).toBe(null)
|
||||
}
|
||||
|
||||
|
|
|
@ -45,7 +45,7 @@ describe("Users", () => {
|
|||
...{ _id: groupId, roles: { app1: "ADMIN" } },
|
||||
}
|
||||
const users: User[] = []
|
||||
for (const _ of Array.from({ length: usersInGroup })) {
|
||||
for (let i = 0; i < usersInGroup; i++) {
|
||||
const userId = `us_${generator.guid()}`
|
||||
const user: User = structures.users.user({
|
||||
_id: userId,
|
||||
|
|
|
@ -39,19 +39,23 @@ const handleClick = event => {
|
|||
return
|
||||
}
|
||||
|
||||
if (handler.allowedType && event.type !== handler.allowedType) {
|
||||
return
|
||||
}
|
||||
|
||||
handler.callback?.(event)
|
||||
})
|
||||
}
|
||||
document.documentElement.addEventListener("click", handleClick, true)
|
||||
document.documentElement.addEventListener("contextmenu", handleClick, true)
|
||||
document.documentElement.addEventListener("mousedown", handleClick, true)
|
||||
|
||||
/**
|
||||
* Adds or updates a click handler
|
||||
*/
|
||||
const updateHandler = (id, element, anchor, callback) => {
|
||||
const updateHandler = (id, element, anchor, callback, allowedType) => {
|
||||
let existingHandler = clickHandlers.find(x => x.id === id)
|
||||
if (!existingHandler) {
|
||||
clickHandlers.push({ id, element, anchor, callback })
|
||||
clickHandlers.push({ id, element, anchor, callback, allowedType })
|
||||
} else {
|
||||
existingHandler.callback = callback
|
||||
}
|
||||
|
@ -77,7 +81,8 @@ export default (element, opts) => {
|
|||
const update = newOpts => {
|
||||
const callback = newOpts?.callback || newOpts
|
||||
const anchor = newOpts?.anchor || element
|
||||
updateHandler(id, element, anchor, callback)
|
||||
const allowedType = newOpts?.allowedType || "click"
|
||||
updateHandler(id, element, anchor, callback, allowedType)
|
||||
}
|
||||
update(opts)
|
||||
return {
|
||||
|
|
|
@ -129,10 +129,7 @@
|
|||
filteredUsers = $usersFetch.rows
|
||||
.filter(user => user.email !== $auth.user.email)
|
||||
.map(user => {
|
||||
const isAdminOrGlobalBuilder = sdk.users.isAdminOrGlobalBuilder(
|
||||
user,
|
||||
prodAppId
|
||||
)
|
||||
const isAdminOrGlobalBuilder = sdk.users.isAdminOrGlobalBuilder(user)
|
||||
const isAppBuilder = user.builder?.apps?.includes(prodAppId)
|
||||
let role
|
||||
if (isAdminOrGlobalBuilder) {
|
||||
|
|
|
@ -291,7 +291,10 @@
|
|||
<div
|
||||
id="side-panel-container"
|
||||
class:open={$sidePanelStore.open}
|
||||
use:clickOutside={autoCloseSidePanel ? sidePanelStore.actions.close : null}
|
||||
use:clickOutside={{
|
||||
callback: autoCloseSidePanel ? sidePanelStore.actions.close : null,
|
||||
allowedType: "mousedown",
|
||||
}}
|
||||
class:builder={$builderStore.inBuilder}
|
||||
>
|
||||
<div class="side-panel-header">
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
module FirebaseMock {
|
||||
const firebase: any = {}
|
||||
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
module SendgridMock {
|
||||
class Email {
|
||||
constructor() {
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
module ArangoMock {
|
||||
const arangodb: any = {}
|
||||
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
module MongoMock {
|
||||
const mongodb: any = {}
|
||||
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
module MySQLMock {
|
||||
const mysql: any = {}
|
||||
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
// @ts-ignore
|
||||
import fs from "fs"
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
module FetchMock {
|
||||
// @ts-ignore
|
||||
const fetch = jest.requireActual("node-fetch")
|
||||
|
|
|
@ -26,7 +26,6 @@ import {
|
|||
env as envCore,
|
||||
ErrorCode,
|
||||
events,
|
||||
HTTPError,
|
||||
migrations,
|
||||
objectStore,
|
||||
roles,
|
||||
|
|
|
@ -116,7 +116,7 @@ export async function save(ctx: UserCtx<SaveRoleRequest, SaveRoleResponse>) {
|
|||
target: prodDb.name,
|
||||
})
|
||||
await replication.replicate({
|
||||
filter: (doc: any, params: any) => {
|
||||
filter: (doc: any) => {
|
||||
return doc._id && doc._id.startsWith("role_")
|
||||
},
|
||||
})
|
||||
|
|
|
@ -7,13 +7,11 @@ import {
|
|||
FilterType,
|
||||
IncludeRelationship,
|
||||
ManyToManyRelationshipFieldMetadata,
|
||||
ManyToOneRelationshipFieldMetadata,
|
||||
OneToManyRelationshipFieldMetadata,
|
||||
Operation,
|
||||
PaginationJson,
|
||||
RelationshipFieldMetadata,
|
||||
RelationshipsJson,
|
||||
RelationshipType,
|
||||
Row,
|
||||
SearchFilters,
|
||||
SortJson,
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
import { quotas } from "@budibase/pro"
|
||||
import {
|
||||
UserCtx,
|
||||
ViewV2,
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import { generateUserFlagID, InternalTables } from "../../db/utils"
|
||||
import { getFullUser } from "../../utilities/users"
|
||||
import { cache, context } from "@budibase/backend-core"
|
||||
import { context } from "@budibase/backend-core"
|
||||
import {
|
||||
ContextUserMetadata,
|
||||
Ctx,
|
||||
|
|
|
@ -24,7 +24,7 @@ async function parseSchema(view: CreateViewRequest) {
|
|||
icon: schemaValue.icon,
|
||||
}
|
||||
Object.entries(fieldSchema)
|
||||
.filter(([_, val]) => val === undefined)
|
||||
.filter(([, val]) => val === undefined)
|
||||
.forEach(([key]) => {
|
||||
delete fieldSchema[key as keyof UIFieldMetadata]
|
||||
})
|
||||
|
|
|
@ -33,7 +33,6 @@ export { default as staticRoutes } from "./static"
|
|||
export { default as publicRoutes } from "./public"
|
||||
|
||||
const appBackupRoutes = pro.appBackups
|
||||
const scheduleRoutes = pro.schedules
|
||||
const environmentVariableRoutes = pro.environmentVariables
|
||||
|
||||
export const mainRoutes: Router[] = [
|
||||
|
@ -65,7 +64,6 @@ export const mainRoutes: Router[] = [
|
|||
pluginRoutes,
|
||||
opsRoutes,
|
||||
debugRoutes,
|
||||
scheduleRoutes,
|
||||
environmentVariableRoutes,
|
||||
// these need to be handled last as they still use /api/:tableId
|
||||
// this could be breaking as koa may recognise other routes as this
|
||||
|
|
|
@ -16,7 +16,7 @@ describe("/applications/:appId/import", () => {
|
|||
|
||||
it("should be able to perform import", async () => {
|
||||
const appId = config.getAppId()
|
||||
const res = await request
|
||||
await request
|
||||
.post(`/api/applications/${appId}/import`)
|
||||
.field("encryptionPassword", PASSWORD)
|
||||
.attach("appExport", path.join(__dirname, "assets", "export.tar.gz"))
|
||||
|
|
|
@ -2,7 +2,6 @@ import * as setup from "./utilities"
|
|||
import { roles, db as dbCore } from "@budibase/backend-core"
|
||||
|
||||
describe("/api/applications/:appId/sync", () => {
|
||||
let request = setup.getRequest()
|
||||
let config = setup.getConfig()
|
||||
let app
|
||||
|
||||
|
|
|
@ -369,7 +369,7 @@ describe("/applications", () => {
|
|||
})
|
||||
|
||||
it("should reject with a known name", async () => {
|
||||
const resp = await config.api.application.duplicateApp(
|
||||
await config.api.application.duplicateApp(
|
||||
app.appId,
|
||||
{
|
||||
name: app.name,
|
||||
|
@ -381,7 +381,7 @@ describe("/applications", () => {
|
|||
})
|
||||
|
||||
it("should reject with a known url", async () => {
|
||||
const resp = await config.api.application.duplicateApp(
|
||||
await config.api.application.duplicateApp(
|
||||
app.appId,
|
||||
{
|
||||
name: "this is fine",
|
||||
|
|
|
@ -156,7 +156,7 @@ describe("/permission", () => {
|
|||
level: PermissionLevel.READ,
|
||||
})
|
||||
|
||||
const response = await config.api.permission.revoke(
|
||||
await config.api.permission.revoke(
|
||||
{
|
||||
roleId: STD_ROLE_ID,
|
||||
resourceId: table._id,
|
||||
|
|
|
@ -65,7 +65,7 @@ describe("/queries", () => {
|
|||
|
||||
beforeEach(async () => {
|
||||
await withConnection(async connection => {
|
||||
const resp = await connection.query(createTableSQL)
|
||||
await connection.query(createTableSQL)
|
||||
await connection.query(insertSQL)
|
||||
})
|
||||
})
|
||||
|
|
|
@ -74,7 +74,7 @@ describe("/views", () => {
|
|||
|
||||
describe("create", () => {
|
||||
it("returns a success message when the view is successfully created", async () => {
|
||||
const res = await saveView()
|
||||
await saveView()
|
||||
expect(events.view.created).toHaveBeenCalledTimes(1)
|
||||
})
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@ import {
|
|||
} from "@budibase/string-templates"
|
||||
import sdk from "../sdk"
|
||||
import { Row } from "@budibase/types"
|
||||
import { LoopInput, LoopStep, LoopStepType } from "../definitions/automations"
|
||||
import { LoopInput, LoopStepType } from "../definitions/automations"
|
||||
|
||||
/**
|
||||
* When values are input to the system generally they will be of type string as this is required for template strings.
|
||||
|
|
|
@ -4,7 +4,6 @@ import {
|
|||
AutomationStepInput,
|
||||
AutomationStepType,
|
||||
AutomationIOType,
|
||||
AutomationFeature,
|
||||
} from "@budibase/types"
|
||||
|
||||
export const definition: AutomationStepSchema = {
|
||||
|
|
|
@ -10,8 +10,6 @@ import {
|
|||
AutomationStepSchema,
|
||||
AutomationStepType,
|
||||
} from "@budibase/types"
|
||||
import { utils } from "@budibase/backend-core"
|
||||
import env from "../../environment"
|
||||
|
||||
export const definition: AutomationStepSchema = {
|
||||
name: "External Data Connector",
|
||||
|
|
|
@ -58,7 +58,7 @@ export const definition: AutomationStepSchema = {
|
|||
},
|
||||
}
|
||||
|
||||
export async function run({ inputs, context }: AutomationStepInput) {
|
||||
export async function run({ inputs }: AutomationStepInput) {
|
||||
if (!environment.OPENAI_API_KEY) {
|
||||
return {
|
||||
success: false,
|
||||
|
|
|
@ -62,6 +62,7 @@ export const definition: AutomationStepSchema = {
|
|||
}
|
||||
|
||||
export async function run({ inputs }: AutomationStepInput) {
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
const { automationId, ...fieldParams } = inputs.automation
|
||||
|
||||
if (await features.isTriggerAutomationRunEnabled()) {
|
||||
|
|
|
@ -3,19 +3,18 @@ import * as triggers from "../triggers"
|
|||
import { loopAutomation } from "../../tests/utilities/structures"
|
||||
import { context } from "@budibase/backend-core"
|
||||
import * as setup from "./utilities"
|
||||
import { Row, Table } from "@budibase/types"
|
||||
import { Table } from "@budibase/types"
|
||||
import { LoopInput, LoopStepType } from "../../definitions/automations"
|
||||
|
||||
describe("Attempt to run a basic loop automation", () => {
|
||||
let config = setup.getConfig(),
|
||||
table: Table,
|
||||
row: Row
|
||||
table: Table
|
||||
|
||||
beforeEach(async () => {
|
||||
await automation.init()
|
||||
await config.init()
|
||||
table = await config.createTable()
|
||||
row = await config.createRow()
|
||||
await config.createRow()
|
||||
})
|
||||
|
||||
afterAll(setup.afterAll)
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { LoopStep, LoopStepType } from "../../definitions/automations"
|
||||
import { LoopStepType } from "../../definitions/automations"
|
||||
import {
|
||||
typecastForLooping,
|
||||
cleanInputValues,
|
||||
|
|
|
@ -6,6 +6,10 @@ import {
|
|||
TableSourceType,
|
||||
} from "@budibase/types"
|
||||
|
||||
import env from "../environment"
|
||||
|
||||
export const AWS_REGION = env.AWS_REGION ? env.AWS_REGION : "eu-west-1"
|
||||
|
||||
export enum FilterTypes {
|
||||
STRING = "string",
|
||||
FUZZY = "fuzzy",
|
||||
|
|
|
@ -1,147 +0,0 @@
|
|||
import merge from "lodash/merge"
|
||||
import env from "../environment"
|
||||
|
||||
export const AWS_REGION = env.AWS_REGION ? env.AWS_REGION : "eu-west-1"
|
||||
|
||||
const TableInfo = {
|
||||
API_KEYS: {
|
||||
name: "beta-api-key-table",
|
||||
primary: "pk",
|
||||
},
|
||||
USERS: {
|
||||
name: "prod-budi-table",
|
||||
primary: "pk",
|
||||
sort: "sk",
|
||||
},
|
||||
}
|
||||
|
||||
let docClient: any = null
|
||||
|
||||
type GetOpts = {
|
||||
primary: string
|
||||
sort?: string
|
||||
otherProps?: any
|
||||
}
|
||||
|
||||
type UpdateOpts = {
|
||||
primary: string
|
||||
sort?: string
|
||||
expression?: string
|
||||
condition?: string
|
||||
names?: string[]
|
||||
values?: any[]
|
||||
exists?: boolean
|
||||
otherProps?: any
|
||||
}
|
||||
|
||||
type PutOpts = {
|
||||
item: any
|
||||
otherProps?: any
|
||||
}
|
||||
|
||||
class Table {
|
||||
_name: string
|
||||
_primary: string
|
||||
_sort?: string
|
||||
|
||||
constructor(tableInfo: { name: string; primary: string; sort?: string }) {
|
||||
if (!tableInfo.name || !tableInfo.primary) {
|
||||
throw "Table info must specify a name and a primary key"
|
||||
}
|
||||
this._name = tableInfo.name
|
||||
this._primary = tableInfo.primary
|
||||
this._sort = tableInfo.sort
|
||||
}
|
||||
|
||||
async get({ primary, sort, otherProps }: GetOpts) {
|
||||
let params = {
|
||||
TableName: this._name,
|
||||
Key: {
|
||||
[this._primary]: primary,
|
||||
},
|
||||
}
|
||||
if (this._sort && sort) {
|
||||
params.Key[this._sort] = sort
|
||||
}
|
||||
if (otherProps) {
|
||||
params = merge(params, otherProps)
|
||||
}
|
||||
let response = await docClient.get(params).promise()
|
||||
return response.Item
|
||||
}
|
||||
|
||||
async update({
|
||||
primary,
|
||||
sort,
|
||||
expression,
|
||||
condition,
|
||||
names,
|
||||
values,
|
||||
exists,
|
||||
otherProps,
|
||||
}: UpdateOpts) {
|
||||
let params: any = {
|
||||
TableName: this._name,
|
||||
Key: {
|
||||
[this._primary]: primary,
|
||||
},
|
||||
ExpressionAttributeNames: names,
|
||||
ExpressionAttributeValues: values,
|
||||
UpdateExpression: expression,
|
||||
}
|
||||
if (condition) {
|
||||
params.ConditionExpression = condition
|
||||
}
|
||||
if (this._sort && sort) {
|
||||
params.Key[this._sort] = sort
|
||||
}
|
||||
if (exists) {
|
||||
params.ExpressionAttributeNames["#PRIMARY"] = this._primary
|
||||
if (params.ConditionExpression) {
|
||||
params.ConditionExpression += " AND "
|
||||
}
|
||||
params.ConditionExpression += "attribute_exists(#PRIMARY)"
|
||||
}
|
||||
if (otherProps) {
|
||||
params = merge(params, otherProps)
|
||||
}
|
||||
return docClient.update(params).promise()
|
||||
}
|
||||
|
||||
async put({ item, otherProps }: PutOpts) {
|
||||
if (
|
||||
item[this._primary] == null ||
|
||||
(this._sort && item[this._sort] == null)
|
||||
) {
|
||||
throw "Cannot put item without primary and sort key (if required)"
|
||||
}
|
||||
let params = {
|
||||
TableName: this._name,
|
||||
Item: item,
|
||||
}
|
||||
if (otherProps) {
|
||||
params = merge(params, otherProps)
|
||||
}
|
||||
return docClient.put(params).promise()
|
||||
}
|
||||
}
|
||||
|
||||
export function init(endpoint: string) {
|
||||
let AWS = require("aws-sdk")
|
||||
let docClientParams: any = {
|
||||
correctClockSkew: true,
|
||||
region: AWS_REGION,
|
||||
}
|
||||
if (endpoint) {
|
||||
docClientParams.endpoint = endpoint
|
||||
} else if (env.DYNAMO_ENDPOINT) {
|
||||
docClientParams.endpoint = env.DYNAMO_ENDPOINT
|
||||
}
|
||||
docClient = new AWS.DynamoDB.DocumentClient(docClientParams)
|
||||
}
|
||||
|
||||
if (!env.isProd() && !env.isJest()) {
|
||||
env._set("AWS_ACCESS_KEY_ID", "KEY_ID")
|
||||
env._set("AWS_SECRET_ACCESS_KEY", "SECRET_KEY")
|
||||
init("http://localhost:8333")
|
||||
}
|
|
@ -18,7 +18,6 @@ import {
|
|||
Row,
|
||||
LinkDocumentValue,
|
||||
FieldType,
|
||||
LinkDocument,
|
||||
ContextUser,
|
||||
} from "@budibase/types"
|
||||
import sdk from "../../sdk"
|
||||
|
|
|
@ -1,8 +1,11 @@
|
|||
import { features } from "@budibase/backend-core"
|
||||
import env from "./environment"
|
||||
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
enum AppFeature {
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
API = "api",
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
AUTOMATIONS = "automations",
|
||||
}
|
||||
|
||||
|
|
|
@ -12,7 +12,6 @@ import {
|
|||
TableRequest,
|
||||
TableSourceType,
|
||||
} from "@budibase/types"
|
||||
import _ from "lodash"
|
||||
import { databaseTestProviders } from "../integrations/tests/utils"
|
||||
import mysql from "mysql2/promise"
|
||||
import { builderSocket } from "../websockets"
|
||||
|
|
|
@ -8,7 +8,7 @@ import {
|
|||
} from "@budibase/types"
|
||||
|
||||
import AWS from "aws-sdk"
|
||||
import { AWS_REGION } from "../db/dynamoClient"
|
||||
import { AWS_REGION } from "../constants"
|
||||
import { DocumentClient } from "aws-sdk/clients/dynamodb"
|
||||
|
||||
interface DynamoDBConfig {
|
||||
|
|
|
@ -168,6 +168,7 @@ class GoogleSheetsIntegration implements DatasourcePlus {
|
|||
return ""
|
||||
}
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
getStringConcat(parts: string[]) {
|
||||
return ""
|
||||
}
|
||||
|
|
|
@ -14,8 +14,6 @@ import {
|
|||
Schema,
|
||||
TableSourceType,
|
||||
DatasourcePlusQueryResponse,
|
||||
FieldType,
|
||||
FieldSubtype,
|
||||
} from "@budibase/types"
|
||||
import {
|
||||
getSqlQuery,
|
||||
|
|
|
@ -13,8 +13,6 @@ import {
|
|||
Schema,
|
||||
TableSourceType,
|
||||
DatasourcePlusQueryResponse,
|
||||
FieldType,
|
||||
FieldSubtype,
|
||||
} from "@budibase/types"
|
||||
import {
|
||||
getSqlQuery,
|
||||
|
|
|
@ -28,7 +28,7 @@ describe("Airtable Integration", () => {
|
|||
})
|
||||
|
||||
it("calls the create method with the correct params", async () => {
|
||||
const response = await config.integration.create({
|
||||
await config.integration.create({
|
||||
table: "test",
|
||||
json: {},
|
||||
})
|
||||
|
@ -40,7 +40,7 @@ describe("Airtable Integration", () => {
|
|||
})
|
||||
|
||||
it("calls the read method with the correct params", async () => {
|
||||
const response = await config.integration.read({
|
||||
await config.integration.read({
|
||||
table: "test",
|
||||
view: "Grid view",
|
||||
})
|
||||
|
@ -51,7 +51,7 @@ describe("Airtable Integration", () => {
|
|||
})
|
||||
|
||||
it("calls the update method with the correct params", async () => {
|
||||
const response = await config.integration.update({
|
||||
await config.integration.update({
|
||||
table: "table",
|
||||
id: "123",
|
||||
json: {
|
||||
|
@ -68,7 +68,7 @@ describe("Airtable Integration", () => {
|
|||
|
||||
it("calls the delete method with the correct params", async () => {
|
||||
const ids = [1, 2, 3, 4]
|
||||
const response = await config.integration.delete({
|
||||
await config.integration.delete({
|
||||
ids,
|
||||
})
|
||||
expect(config.client.destroy).toHaveBeenCalledWith(ids)
|
||||
|
|
|
@ -12,7 +12,6 @@ class TestConfiguration {
|
|||
|
||||
describe("ArangoDB Integration", () => {
|
||||
let config: any
|
||||
let indexName = "Users"
|
||||
|
||||
beforeEach(() => {
|
||||
config = new TestConfiguration()
|
||||
|
@ -23,7 +22,7 @@ describe("ArangoDB Integration", () => {
|
|||
json: "Hello",
|
||||
}
|
||||
|
||||
const response = await config.integration.create(body)
|
||||
await config.integration.create(body)
|
||||
expect(config.integration.client.query).toHaveBeenCalledWith(
|
||||
`INSERT Hello INTO collection RETURN NEW`
|
||||
)
|
||||
|
@ -33,7 +32,7 @@ describe("ArangoDB Integration", () => {
|
|||
const query = {
|
||||
sql: `test`,
|
||||
}
|
||||
const response = await config.integration.read(query)
|
||||
await config.integration.read(query)
|
||||
expect(config.integration.client.query).toHaveBeenCalledWith(query.sql)
|
||||
})
|
||||
})
|
||||
|
|
|
@ -79,7 +79,7 @@ describe("CouchDB Integration", () => {
|
|||
|
||||
it("calls the delete method with the correct params", async () => {
|
||||
const id = "1234"
|
||||
const response = await config.integration.delete({ id })
|
||||
await config.integration.delete({ id })
|
||||
expect(config.integration.client.get).toHaveBeenCalledWith(id)
|
||||
expect(config.integration.client.remove).toHaveBeenCalled()
|
||||
})
|
||||
|
|
|
@ -19,7 +19,7 @@ describe("DynamoDB Integration", () => {
|
|||
})
|
||||
|
||||
it("calls the create method with the correct params", async () => {
|
||||
const response = await config.integration.create({
|
||||
await config.integration.create({
|
||||
table: tableName,
|
||||
json: {
|
||||
Name: "John",
|
||||
|
@ -66,7 +66,7 @@ describe("DynamoDB Integration", () => {
|
|||
})
|
||||
|
||||
it("calls the get method with the correct params", async () => {
|
||||
const response = await config.integration.get({
|
||||
await config.integration.get({
|
||||
table: tableName,
|
||||
json: {
|
||||
Id: 123,
|
||||
|
@ -80,7 +80,7 @@ describe("DynamoDB Integration", () => {
|
|||
})
|
||||
|
||||
it("calls the update method with the correct params", async () => {
|
||||
const response = await config.integration.update({
|
||||
await config.integration.update({
|
||||
table: tableName,
|
||||
json: {
|
||||
Name: "John",
|
||||
|
@ -93,7 +93,7 @@ describe("DynamoDB Integration", () => {
|
|||
})
|
||||
|
||||
it("calls the delete method with the correct params", async () => {
|
||||
const response = await config.integration.delete({
|
||||
await config.integration.delete({
|
||||
table: tableName,
|
||||
json: {
|
||||
Name: "John",
|
||||
|
|
|
@ -22,7 +22,7 @@ describe("Elasticsearch Integration", () => {
|
|||
const body = {
|
||||
name: "Hello",
|
||||
}
|
||||
const response = await config.integration.create({
|
||||
await config.integration.create({
|
||||
index: indexName,
|
||||
json: body,
|
||||
})
|
||||
|
|
|
@ -81,7 +81,7 @@ describe("Firebase Integration", () => {
|
|||
})
|
||||
|
||||
it("calls the delete method with the correct params", async () => {
|
||||
const response = await config.integration.delete({
|
||||
await config.integration.delete({
|
||||
table: tableName,
|
||||
json: {
|
||||
id: "test",
|
||||
|
|
|
@ -44,7 +44,7 @@ describe("Oracle Integration", () => {
|
|||
|
||||
it("calls the update method with the correct params", async () => {
|
||||
const sql = "update table users set name = 'test';"
|
||||
const response = await config.integration.update({
|
||||
await config.integration.update({
|
||||
sql,
|
||||
})
|
||||
expect(oracledb.executeMock).toHaveBeenCalledWith(sql, [], options)
|
||||
|
|
|
@ -37,7 +37,7 @@ describe("Postgres Integration", () => {
|
|||
|
||||
it("calls the update method with the correct params", async () => {
|
||||
const sql = "update table users set name = 'test';"
|
||||
const response = await config.integration.update({
|
||||
await config.integration.update({
|
||||
sql,
|
||||
})
|
||||
expect(pg.queryMock).toHaveBeenCalledWith(sql, [])
|
||||
|
|
|
@ -70,7 +70,7 @@ describe("REST Integration", () => {
|
|||
Accept: "text/html",
|
||||
},
|
||||
}
|
||||
const response = await config.integration.read(query)
|
||||
await config.integration.read(query)
|
||||
expect(fetch).toHaveBeenCalledWith(`${BASE_URL}/api?test=1`, {
|
||||
headers: {
|
||||
Accept: "text/html",
|
||||
|
@ -91,7 +91,7 @@ describe("REST Integration", () => {
|
|||
name: "test",
|
||||
}),
|
||||
}
|
||||
const response = await config.integration.update(query)
|
||||
await config.integration.update(query)
|
||||
expect(fetch).toHaveBeenCalledWith(`${BASE_URL}/api?test=1`, {
|
||||
method: "PUT",
|
||||
body: '{"name":"test"}',
|
||||
|
@ -111,7 +111,7 @@ describe("REST Integration", () => {
|
|||
name: "test",
|
||||
}),
|
||||
}
|
||||
const response = await config.integration.delete(query)
|
||||
await config.integration.delete(query)
|
||||
expect(fetch).toHaveBeenCalledWith(`${BASE_URL}/api?test=1`, {
|
||||
method: "DELETE",
|
||||
headers: HEADERS,
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
const AWS = require("aws-sdk")
|
||||
|
||||
import { default as S3Integration } from "../s3"
|
||||
|
||||
jest.mock("aws-sdk")
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
import { utils } from "@budibase/shared-core"
|
||||
import environment from "../../environment"
|
||||
import fs from "fs"
|
||||
|
||||
export const enum BundleType {
|
||||
|
|
|
@ -8,11 +8,10 @@ import {
|
|||
import { context, logging } from "@budibase/backend-core"
|
||||
import tracer from "dd-trace"
|
||||
import { IsolatedVM } from "./vm"
|
||||
import type { VM } from "@budibase/types"
|
||||
|
||||
export function init() {
|
||||
setJSRunner((js: string, ctx: Record<string, any>) => {
|
||||
return tracer.trace("runJS", {}, span => {
|
||||
return tracer.trace("runJS", {}, () => {
|
||||
try {
|
||||
// Reuse an existing isolate from context, or make a new one
|
||||
const bbCtx = context.getCurrentContext()
|
||||
|
@ -36,6 +35,7 @@ export function init() {
|
|||
// Because we can't pass functions into an Isolate, we remove them from
|
||||
// the passed context and rely on the withHelpers() method to add them
|
||||
// back in.
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
const { helpers, snippets, ...rest } = ctx
|
||||
return vm.withContext(rest, () => vm.execute(js))
|
||||
} catch (error: any) {
|
||||
|
|
|
@ -13,7 +13,7 @@ export default async (ctx: Ctx, next: any) => {
|
|||
let errors = []
|
||||
for (let fn of current.cleanup) {
|
||||
try {
|
||||
await tracer.trace("cleanup", async span => {
|
||||
await tracer.trace("cleanup", async () => {
|
||||
await fn()
|
||||
})
|
||||
} catch (e) {
|
||||
|
|
|
@ -11,7 +11,6 @@ import {
|
|||
|
||||
import authorizedMiddleware from "../authorized"
|
||||
import env from "../../environment"
|
||||
import { generateTableID, generateViewID } from "../../db/utils"
|
||||
import { generator, mocks } from "@budibase/backend-core/tests"
|
||||
import { initProMocks } from "../../tests/utilities/mocks/pro"
|
||||
import { getResourcePerms } from "../../sdk/app/permissions"
|
||||
|
|
|
@ -32,10 +32,7 @@ export default async (ctx: Ctx<Row>, next: Next) => {
|
|||
}
|
||||
|
||||
// have to mutate the koa context, can't return
|
||||
export async function trimViewFields<T extends Row>(
|
||||
body: Row,
|
||||
viewId: string
|
||||
): Promise<void> {
|
||||
export async function trimViewFields(body: Row, viewId: string): Promise<void> {
|
||||
const view = await sdk.views.get(viewId)
|
||||
const allowedKeys = sdk.views.allowedFields(view)
|
||||
// have to mutate the context, can't update reference
|
||||
|
|
|
@ -43,7 +43,7 @@ export const backfill = async (
|
|||
}
|
||||
|
||||
if (user.roles) {
|
||||
for (const [appId, role] of Object.entries(user.roles)) {
|
||||
for (const [, role] of Object.entries(user.roles)) {
|
||||
await events.role.assigned(user, role, timestamp)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,7 +11,6 @@ import env from "../environment"
|
|||
// migration functions
|
||||
import * as userEmailViewCasing from "./functions/userEmailViewCasing"
|
||||
import * as syncQuotas from "./functions/syncQuotas"
|
||||
import * as syncUsers from "./functions/usageQuotas/syncUsers"
|
||||
import * as appUrls from "./functions/appUrls"
|
||||
import * as tableSettings from "./functions/tableSettings"
|
||||
import * as backfill from "./functions/backfill"
|
||||
|
|
|
@ -3,11 +3,7 @@ import { db as dbCore, context, logging, roles } from "@budibase/backend-core"
|
|||
import { User, ContextUser, UserGroup } from "@budibase/types"
|
||||
import { sdk as proSdk } from "@budibase/pro"
|
||||
import sdk from "../../"
|
||||
import {
|
||||
getGlobalUsers,
|
||||
getRawGlobalUsers,
|
||||
processUser,
|
||||
} from "../../../utilities/global"
|
||||
import { getRawGlobalUsers, processUser } from "../../../utilities/global"
|
||||
import { generateUserMetadataID, InternalTables } from "../../../db/utils"
|
||||
|
||||
type DeletedUser = { _id: string; deleted: boolean }
|
||||
|
|
|
@ -6,7 +6,7 @@ import EventEmitter from "events"
|
|||
import { UserGroup, UserMetadata, UserRoles, User } from "@budibase/types"
|
||||
|
||||
const config = new TestConfiguration()
|
||||
let app, group: UserGroup, groupUser: User
|
||||
let group: UserGroup, groupUser: User
|
||||
const ROLE_ID = roles.BUILTIN_ROLE_IDS.BASIC
|
||||
|
||||
const emitter = new EventEmitter()
|
||||
|
@ -36,7 +36,7 @@ function waitForUpdate(opts: { group?: boolean }) {
|
|||
}
|
||||
|
||||
beforeAll(async () => {
|
||||
app = await config.init("syncApp")
|
||||
await config.init("syncApp")
|
||||
})
|
||||
|
||||
async function createUser(email: string, roles: UserRoles, builder?: boolean) {
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { db, env, roles } from "@budibase/backend-core"
|
||||
import { db, roles } from "@budibase/backend-core"
|
||||
import { features } from "@budibase/pro"
|
||||
import {
|
||||
DocumentType,
|
||||
|
@ -133,7 +133,7 @@ export async function getDependantResources(
|
|||
}
|
||||
|
||||
const permissions = await getResourcePerms(view.id)
|
||||
for (const [level, roleInfo] of Object.entries(permissions)) {
|
||||
for (const [, roleInfo] of Object.entries(permissions)) {
|
||||
if (roleInfo.type === PermissionSource.INHERITED) {
|
||||
dependants[VirtualDocumentType.VIEW] ??= new Set()
|
||||
dependants[VirtualDocumentType.VIEW].add(view.id)
|
||||
|
|
|
@ -351,6 +351,7 @@ describe("table sdk", () => {
|
|||
const view: ViewV2 = {
|
||||
...basicView,
|
||||
}
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
const { name, description, ...newTableSchema } = basicTable.schema
|
||||
|
||||
const result = syncSchema(_.cloneDeep(view), newTableSchema, undefined)
|
||||
|
@ -364,6 +365,7 @@ describe("table sdk", () => {
|
|||
const view: ViewV2 = {
|
||||
...basicView,
|
||||
}
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
const { description, ...newTableSchema } = {
|
||||
...basicTable.schema,
|
||||
updatedDescription: {
|
||||
|
@ -448,6 +450,7 @@ describe("table sdk", () => {
|
|||
hiddenField: { visible: false },
|
||||
},
|
||||
}
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
const { name, description, ...newTableSchema } = basicTable.schema
|
||||
|
||||
const result = syncSchema(_.cloneDeep(view), newTableSchema, undefined)
|
||||
|
@ -471,6 +474,7 @@ describe("table sdk", () => {
|
|||
hiddenField: { visible: false },
|
||||
},
|
||||
}
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
const { name, description, ...newTableSchema } = {
|
||||
...basicTable.schema,
|
||||
newField1: {
|
||||
|
@ -502,6 +506,7 @@ describe("table sdk", () => {
|
|||
hiddenField: { visible: false },
|
||||
},
|
||||
}
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
const { description, ...newTableSchema } = {
|
||||
...basicTable.schema,
|
||||
updatedDescription: {
|
||||
|
|
|
@ -49,7 +49,6 @@ import {
|
|||
AuthToken,
|
||||
Automation,
|
||||
CreateViewRequest,
|
||||
Ctx,
|
||||
Datasource,
|
||||
FieldType,
|
||||
INTERNAL_TABLE_SOURCE_ID,
|
||||
|
|
|
@ -6,7 +6,6 @@ import {
|
|||
PaginatedSearchRowResponse,
|
||||
} from "@budibase/types"
|
||||
import { Expectations, TestAPI } from "./base"
|
||||
import { generator } from "@budibase/backend-core/tests"
|
||||
import sdk from "../../../sdk"
|
||||
|
||||
export class ViewV2API extends TestAPI {
|
||||
|
|
|
@ -9,9 +9,7 @@ export async function jsonFromCsvString(csvString: string) {
|
|||
// ignoreEmpty will remove the key completly if empty, so creating this empty object will ensure we return the values with the keys but empty values
|
||||
const result = await csv({ ignoreEmpty: false }).fromString(csvString)
|
||||
result.forEach((r, i) => {
|
||||
for (const [key] of Object.entries(r).filter(
|
||||
([key, value]) => value === ""
|
||||
)) {
|
||||
for (const [key] of Object.entries(r).filter(([, value]) => value === "")) {
|
||||
if (castedWithEmptyValues[i][key] === undefined) {
|
||||
r[key] = null
|
||||
}
|
||||
|
|
|
@ -34,21 +34,6 @@ interface ValidationResults {
|
|||
errors: Record<string, string>
|
||||
}
|
||||
|
||||
const PARSERS: any = {
|
||||
[FieldType.NUMBER]: (attribute?: string) => {
|
||||
if (!attribute) {
|
||||
return attribute
|
||||
}
|
||||
return Number(attribute)
|
||||
},
|
||||
[FieldType.DATETIME]: (attribute?: string) => {
|
||||
if (!attribute) {
|
||||
return attribute
|
||||
}
|
||||
return new Date(attribute).toISOString()
|
||||
},
|
||||
}
|
||||
|
||||
export function isSchema(schema: any): schema is Schema {
|
||||
return (
|
||||
typeof schema === "object" &&
|
||||
|
|
|
@ -1,18 +0,0 @@
|
|||
// UNUSED CODE
|
||||
// Preserved for future use
|
||||
|
||||
/* eslint-disable no-unused-vars */
|
||||
|
||||
function getNewQuotaReset() {
|
||||
return Date.now() + 2592000000
|
||||
}
|
||||
|
||||
function resetQuotasIfRequired(quota: { quotaReset: number; usageQuota: any }) {
|
||||
// Check if the quota needs reset
|
||||
if (Date.now() >= quota.quotaReset) {
|
||||
quota.quotaReset = getNewQuotaReset()
|
||||
for (let prop of Object.keys(quota.usageQuota)) {
|
||||
quota.usageQuota[prop] = 0
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,10 +1,4 @@
|
|||
import {
|
||||
Response,
|
||||
default as fetch,
|
||||
type RequestInit,
|
||||
Headers,
|
||||
HeadersInit,
|
||||
} from "node-fetch"
|
||||
import { Response, default as fetch, type RequestInit } from "node-fetch"
|
||||
import env from "../environment"
|
||||
import { checkSlashesInUrl } from "./index"
|
||||
import {
|
||||
|
@ -13,7 +7,6 @@ import {
|
|||
tenancy,
|
||||
logging,
|
||||
env as coreEnv,
|
||||
utils,
|
||||
} from "@budibase/backend-core"
|
||||
import { Ctx, User, EmailInvite } from "@budibase/types"
|
||||
|
||||
|
|
|
@ -262,10 +262,12 @@ export class BaseSocket {
|
|||
}
|
||||
}
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
async onConnect(socket: Socket) {
|
||||
// Override
|
||||
}
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
async onDisconnect(socket: Socket) {
|
||||
// Override
|
||||
}
|
||||
|
|
|
@ -46,10 +46,7 @@ export function isAdminOrBuilder(
|
|||
return isBuilder(user, appId) || isAdmin(user)
|
||||
}
|
||||
|
||||
export function isAdminOrGlobalBuilder(
|
||||
user: User | ContextUser,
|
||||
appId?: string
|
||||
): boolean {
|
||||
export function isAdminOrGlobalBuilder(user: User | ContextUser): boolean {
|
||||
return isGlobalBuilder(user) || isAdmin(user)
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
{
|
||||
"extends": "./tsconfig.build.json",
|
||||
"compilerOptions": {
|
||||
"baseUrl": "..",
|
||||
"rootDir": "src",
|
||||
"composite": true,
|
||||
"types": ["node", "jest"]
|
||||
},
|
||||
|
|
|
@ -34,7 +34,7 @@ export const getParsedManifest = () => {
|
|||
requiresBlock: boolean
|
||||
}>(manifest[collection])
|
||||
.filter(
|
||||
([_, details]) =>
|
||||
([, details]) =>
|
||||
details.example?.split("->").map(x => x.trim()).length > 1
|
||||
)
|
||||
.map(([name, details]): ExampleType => {
|
||||
|
@ -93,7 +93,7 @@ export const runJsHelpersTests = ({
|
|||
|
||||
describe.each(Object.keys(jsExamples))("%s", collection => {
|
||||
const examplesToRun = jsExamples[collection]
|
||||
.filter(([_, { requiresHbsBody }]) => !requiresHbsBody)
|
||||
.filter(([, { requiresHbsBody }]) => !requiresHbsBody)
|
||||
.filter(([key]) => !testsToSkip?.includes(key))
|
||||
|
||||
examplesToRun.length &&
|
||||
|
|
|
@ -1,9 +1,5 @@
|
|||
import { Event, AuditedEventFriendlyName } from "../../../sdk"
|
||||
import {
|
||||
PaginationResponse,
|
||||
PaginationRequest,
|
||||
BasicPaginationRequest,
|
||||
} from "../"
|
||||
import { Event } from "../../../sdk"
|
||||
import { PaginationResponse, BasicPaginationRequest } from "../"
|
||||
import { User, App } from "../../../"
|
||||
|
||||
export interface AuditLogSearchParams {
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
import { Document } from "../document"
|
||||
import type { Row } from "./row"
|
||||
|
||||
export interface QuerySchema {
|
||||
name?: string
|
||||
|
|
|
@ -225,7 +225,7 @@ export async function oidcCallbackUrl() {
|
|||
return ssoCallbackUrl(ConfigType.OIDC)
|
||||
}
|
||||
|
||||
export const oidcStrategyFactory = async (ctx: any, configId: any) => {
|
||||
export const oidcStrategyFactory = async (ctx: any) => {
|
||||
const config = await configs.getOIDCConfig()
|
||||
if (!config) {
|
||||
return ctx.throw(400, "OIDC config not found")
|
||||
|
@ -247,7 +247,7 @@ export const oidcPreAuth = async (ctx: Ctx, next: any) => {
|
|||
if (!configId) {
|
||||
ctx.throw(400, "OIDC config id is required")
|
||||
}
|
||||
const strategy = await oidcStrategyFactory(ctx, configId)
|
||||
const strategy = await oidcStrategyFactory(ctx)
|
||||
|
||||
setCookie(ctx, configId, Cookie.OIDC_CONFIG)
|
||||
|
||||
|
@ -268,8 +268,7 @@ export const oidcPreAuth = async (ctx: Ctx, next: any) => {
|
|||
}
|
||||
|
||||
export const oidcCallback = async (ctx: any, next: any) => {
|
||||
const configId = getCookie(ctx, Cookie.OIDC_CONFIG)
|
||||
const strategy = await oidcStrategyFactory(ctx, configId)
|
||||
const strategy = await oidcStrategyFactory(ctx)
|
||||
|
||||
return passport.authenticate(
|
||||
strategy,
|
||||
|
|
|
@ -170,10 +170,7 @@ describe("/api/global/auth", () => {
|
|||
let user: User
|
||||
|
||||
async function testSSOUser() {
|
||||
const { res } = await config.api.auth.requestPasswordReset(
|
||||
sendMailMock,
|
||||
user.email
|
||||
)
|
||||
await config.api.auth.requestPasswordReset(sendMailMock, user.email)
|
||||
expect(sendMailMock).not.toHaveBeenCalled()
|
||||
}
|
||||
|
||||
|
|
|
@ -704,6 +704,7 @@ describe("scim", () => {
|
|||
expect(response).toEqual({
|
||||
Resources: expect.arrayContaining(
|
||||
groups.map(g => {
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
const { members, ...groupData } = g
|
||||
return groupData
|
||||
})
|
||||
|
@ -723,6 +724,7 @@ describe("scim", () => {
|
|||
expect(response).toEqual({
|
||||
Resources: expect.arrayContaining(
|
||||
groups.map(g => {
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
const { members, displayName, ...groupData } = g
|
||||
return groupData
|
||||
})
|
||||
|
@ -872,6 +874,7 @@ describe("scim", () => {
|
|||
qs: "excludedAttributes=members",
|
||||
})
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
const { members, ...expectedResponse } = group
|
||||
|
||||
expect(response).toEqual(expectedResponse)
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
import { features } from "@budibase/backend-core"
|
||||
import env from "./environment"
|
||||
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
enum WorkerFeature {}
|
||||
|
||||
const featureList: WorkerFeature[] = features.processFeatureEnvVar(
|
||||
|
|
|
@ -9,7 +9,7 @@ import { platform } from "@budibase/backend-core"
|
|||
* Description:
|
||||
* Re-sync the global-db users to the global-info db users
|
||||
*/
|
||||
export const run = async (globalDb: any) => {
|
||||
export const run = async () => {
|
||||
const users = (await usersSdk.db.allUsers()) as User[]
|
||||
const promises = []
|
||||
for (let user of users) {
|
||||
|
|
|
@ -19,7 +19,6 @@ import {
|
|||
users,
|
||||
context,
|
||||
sessions,
|
||||
auth,
|
||||
constants,
|
||||
env as coreEnv,
|
||||
db as dbCore,
|
||||
|
|
|
@ -5,7 +5,7 @@ import { UserGroup as UserGroupType, UserGroupRoles } from "@budibase/types"
|
|||
export function UserGroup(): UserGroupType {
|
||||
const appsCount = generator.integer({ min: 0, max: 3 })
|
||||
const roles = Array.from({ length: appsCount }).reduce(
|
||||
(p: UserGroupRoles, v) => {
|
||||
(p: UserGroupRoles) => {
|
||||
return {
|
||||
...p,
|
||||
[db.generateAppID()]: generator.pickone(["ADMIN", "POWER", "BASIC"]),
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue