1
0
Fork 0
mirror of synced 2024-09-29 08:41:16 +13:00

Merge branch 'master' of github.com:budibase/budibase into reenable-no-unused-vars

This commit is contained in:
Sam Rose 2024-03-20 11:46:59 +00:00
commit 4783426b0f
No known key found for this signature in database
14 changed files with 43 additions and 53 deletions

@ -1 +1 @@
Subproject commit d68b4f40f85dba3184da8b9d63ef2cd66d4a8ef2 Subproject commit 8baf8586ec078951230c8466d5f13f9b6d5ed055

View file

@ -23,6 +23,12 @@ const DISABLED_WRITE_CLIENTS: SqlClient[] = [
SqlClient.ORACLE, SqlClient.ORACLE,
] ]
const DISABLED_OPERATIONS: Operation[] = [
Operation.CREATE_TABLE,
Operation.UPDATE_TABLE,
Operation.DELETE_TABLE,
]
class CharSequence { class CharSequence {
static alphabet = "abcdefghijklmnopqrstuvwxyz" static alphabet = "abcdefghijklmnopqrstuvwxyz"
counters: number[] counters: number[]
@ -59,13 +65,18 @@ export default class AliasTables {
} }
isAliasingEnabled(json: QueryJson, datasource: Datasource) { isAliasingEnabled(json: QueryJson, datasource: Datasource) {
const operation = json.endpoint.operation
const fieldLength = json.resource?.fields?.length const fieldLength = json.resource?.fields?.length
if (!fieldLength || fieldLength <= 0) { if (
!fieldLength ||
fieldLength <= 0 ||
DISABLED_OPERATIONS.includes(operation)
) {
return false return false
} }
try { try {
const sqlClient = getSQLClient(datasource) const sqlClient = getSQLClient(datasource)
const isWrite = WRITE_OPERATIONS.includes(json.endpoint.operation) const isWrite = WRITE_OPERATIONS.includes(operation)
const isDisabledClient = DISABLED_WRITE_CLIENTS.includes(sqlClient) const isDisabledClient = DISABLED_WRITE_CLIENTS.includes(sqlClient)
if (isWrite && isDisabledClient) { if (isWrite && isDisabledClient) {
return false return false

View file

@ -19,6 +19,7 @@ import env from "../../../environment"
import { type App } from "@budibase/types" import { type App } from "@budibase/types"
import tk from "timekeeper" import tk from "timekeeper"
import * as uuid from "uuid" import * as uuid from "uuid"
import { structures } from "@budibase/backend-core/tests"
describe("/applications", () => { describe("/applications", () => {
let config = setup.getConfig() let config = setup.getConfig()
@ -356,7 +357,7 @@ describe("/applications", () => {
it("should reject an unknown app id with a 404", async () => { it("should reject an unknown app id with a 404", async () => {
await config.api.application.duplicateApp( await config.api.application.duplicateApp(
app.appId.slice(0, -1) + "a", structures.db.id(),
{ {
name: "to-dupe 123", name: "to-dupe 123",
url: "/to-dupe-123", url: "/to-dupe-123",

View file

@ -0,0 +1,10 @@
export default {
preset: "ts-jest",
testEnvironment: "node",
transform: {
"^.+\\.ts?$": "@swc/jest",
},
moduleNameMapper: {
"@budibase/types": "<rootDir>/../types/src",
},
}

View file

@ -11,7 +11,9 @@
"build": "node ../../scripts/build.js && tsc -p tsconfig.build.json --emitDeclarationOnly --paths null", "build": "node ../../scripts/build.js && tsc -p tsconfig.build.json --emitDeclarationOnly --paths null",
"build:dev": "yarn prebuild && tsc --build --watch --preserveWatchOutput", "build:dev": "yarn prebuild && tsc --build --watch --preserveWatchOutput",
"dev": "tsc -p tsconfig.json --watch --preserveWatchOutput", "dev": "tsc -p tsconfig.json --watch --preserveWatchOutput",
"check:types": "tsc -p tsconfig.json --noEmit --paths null" "check:types": "tsc -p tsconfig.json --noEmit --paths null",
"test": "jest",
"test:watch": "yarn test --watchAll"
}, },
"dependencies": { "dependencies": {
"@budibase/types": "0.0.0", "@budibase/types": "0.0.0",
@ -20,29 +22,5 @@
"devDependencies": { "devDependencies": {
"rimraf": "3.0.2", "rimraf": "3.0.2",
"typescript": "5.2.2" "typescript": "5.2.2"
},
"nx": {
"targets": {
"build": {
"dependsOn": [
{
"projects": [
"@budibase/types"
],
"target": "build"
}
]
},
"dev": {
"dependsOn": [
{
"projects": [
"@budibase/types"
],
"target": "build"
}
]
}
}
} }
} }

View file

@ -1,4 +1,3 @@
import { expect, describe, it } from "vitest"
import { cron } from "../helpers" import { cron } from "../helpers"
describe("check valid and invalid crons", () => { describe("check valid and invalid crons", () => {

View file

@ -5,7 +5,6 @@ import {
SearchFilter, SearchFilter,
} from "@budibase/types" } from "@budibase/types"
import { buildLuceneQuery, runLuceneQuery } from "../filters" import { buildLuceneQuery, runLuceneQuery } from "../filters"
import { expect, describe, it, test } from "vitest"
describe("runLuceneQuery", () => { describe("runLuceneQuery", () => {
const docs = [ const docs = [
@ -194,7 +193,7 @@ describe("runLuceneQuery", () => {
expect(runLuceneQuery(docs, query).map(row => row.order_id)).toEqual([2, 3]) expect(runLuceneQuery(docs, query).map(row => row.order_id)).toEqual([2, 3])
}) })
test.each([[523, 259], "523,259"])( it.each([[523, 259], "523,259"])(
"should return rows with matches on numeric oneOf filter", "should return rows with matches on numeric oneOf filter",
input => { input => {
const query = buildQuery({ const query = buildQuery({
@ -209,7 +208,7 @@ describe("runLuceneQuery", () => {
} }
) )
test.each([ it.each([
[false, []], [false, []],
[true, [1, 2, 3]], [true, [1, 2, 3]],
])("should return %s if allOr is %s ", (allOr, expectedResult) => { ])("should return %s if allOr is %s ", (allOr, expectedResult) => {

View file

@ -18,13 +18,6 @@
}, },
"tsBuildInfoFile": "dist/tsconfig.tsbuildinfo" "tsBuildInfoFile": "dist/tsconfig.tsbuildinfo"
}, },
"include": ["**/*.js", "**/*.ts"], "include": ["src/**/*"],
"exclude": [ "exclude": ["**/*.spec.ts", "**/*.spec.js", "__mocks__", "src/tests"]
"node_modules",
"dist",
"**/*.spec.ts",
"**/*.spec.js",
"__mocks__",
"src/tests"
]
} }

View file

@ -1,9 +1,8 @@
{ {
"extends": "./tsconfig.build.json", "extends": "./tsconfig.build.json",
"compilerOptions": { "compilerOptions": {
"baseUrl": "..", "composite": true,
"rootDir": "src", "types": ["node", "jest"]
"composite": true
}, },
"exclude": ["node_modules", "dist"] "exclude": ["node_modules", "dist"]
} }

View file

@ -3,7 +3,7 @@
"version": "0.0.0", "version": "0.0.0",
"description": "Budibase types", "description": "Budibase types",
"main": "dist/index.js", "main": "dist/index.js",
"types": "dist/index.d.ts", "types": "src/index.ts",
"author": "Budibase", "author": "Budibase",
"license": "GPL-3.0", "license": "GPL-3.0",
"scripts": { "scripts": {

View file

@ -7,7 +7,7 @@ import {
ViewTemplateOpts, ViewTemplateOpts,
} from "../" } from "../"
import { Writable } from "stream" import { Writable } from "stream"
import PouchDB from "pouchdb-find" import type PouchDB from "pouchdb-find"
export enum SearchIndex { export enum SearchIndex {
ROWS = "rows", ROWS = "rows",

View file

@ -1,8 +1,6 @@
{ {
"extends": "./tsconfig.build.json", "extends": "./tsconfig.build.json",
"compilerOptions": { "compilerOptions": {
"baseUrl": ".",
"rootDir": "./src",
"composite": true "composite": true
}, },
"exclude": ["node_modules", "dist"] "exclude": ["node_modules", "dist"]

View file

@ -4,10 +4,10 @@ set -e
if [[ -n $CI ]] if [[ -n $CI ]]
then then
# Running in ci, where resources are limited # Running in ci, where resources are limited
echo "jest --coverage --maxWorkers=2 --forceExit --bail $@" echo "jest --coverage --maxWorkers=2 --forceExit --bail $@"
jest --coverage --maxWorkers=2 --forceExit --bail $@ jest --coverage --maxWorkers=2 --forceExit --bail $@
else else
# --maxWorkers performs better in development # --maxWorkers performs better in development
echo "jest --coverage --maxWorkers=2 --forceExit $@" echo "jest --coverage --detectOpenHandles $@"
jest --coverage --maxWorkers=2 --forceExit $@ jest --coverage --detectOpenHandles $@
fi fi

View file

@ -6,6 +6,8 @@ import { TestConfiguration } from "../../../tests"
describe("auth", () => { describe("auth", () => {
const config = new TestConfiguration() const config = new TestConfiguration()
afterAll(config.afterAll)
describe("resetUpdate", () => { describe("resetUpdate", () => {
it("providing a valid code will update the password", async () => { it("providing a valid code will update the password", async () => {
await context.doInTenant(structures.tenant.id(), async () => { await context.doInTenant(structures.tenant.id(), async () => {