Merge pull request #15143 from Budibase/eslint-strict-1
Enable a variety of useful looking lints.
This commit is contained in:
commit
40d7324328
|
@ -51,8 +51,23 @@ export default [
|
||||||
},
|
},
|
||||||
|
|
||||||
rules: {
|
rules: {
|
||||||
"no-self-assign": "off",
|
"no-self-compare": "error",
|
||||||
"prefer-const": "off",
|
"no-template-curly-in-string": "error",
|
||||||
|
"no-unmodified-loop-condition": "error",
|
||||||
|
"no-unreachable-loop": "error",
|
||||||
|
"no-implied-eval": "error",
|
||||||
|
"no-extend-native": "error",
|
||||||
|
"no-labels": "error",
|
||||||
|
"no-lone-blocks": "error",
|
||||||
|
"no-new-wrappers": "error",
|
||||||
|
"no-octal-escape": "error",
|
||||||
|
"no-return-assign": "error",
|
||||||
|
"no-useless-concat": "error",
|
||||||
|
"no-useless-constructor": "error",
|
||||||
|
"no-useless-rename": "error",
|
||||||
|
"no-var": "error",
|
||||||
|
"no-void": "error",
|
||||||
|
|
||||||
"no-unused-vars": [
|
"no-unused-vars": [
|
||||||
"error",
|
"error",
|
||||||
{
|
{
|
||||||
|
@ -65,8 +80,7 @@ export default [
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
...eslintPluginSvelte.configs["flat/recommended"].map(config => {
|
...eslintPluginSvelte.configs["flat/recommended"].map(config => ({
|
||||||
return {
|
|
||||||
...config,
|
...config,
|
||||||
files: ["**/*.svelte"],
|
files: ["**/*.svelte"],
|
||||||
|
|
||||||
|
@ -80,10 +94,8 @@ export default [
|
||||||
allowImportExportEverywhere: true,
|
allowImportExportEverywhere: true,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
})),
|
||||||
}),
|
...tseslint.configs.strict.map(config => ({
|
||||||
...tseslint.configs.recommended.map(config => {
|
|
||||||
return {
|
|
||||||
...config,
|
...config,
|
||||||
files: ["**/*.ts"],
|
files: ["**/*.ts"],
|
||||||
|
|
||||||
|
@ -100,7 +112,14 @@ export default [
|
||||||
"local-rules/no-budibase-imports": "error",
|
"local-rules/no-budibase-imports": "error",
|
||||||
"local-rules/no-console-error": "error",
|
"local-rules/no-console-error": "error",
|
||||||
|
|
||||||
// @typscript-eslint/no-unused-vars supersedes no-unused-vars
|
"@typescript-eslint/no-inferrable-types": "error",
|
||||||
|
"@typescript-eslint/adjacent-overload-signatures": "error",
|
||||||
|
"@typescript-eslint/class-literal-property-style": "error",
|
||||||
|
"@typescript-eslint/no-confusing-non-null-assertion": "error",
|
||||||
|
"@typescript-eslint/no-unnecessary-parameter-property-assignment":
|
||||||
|
"error",
|
||||||
|
"@typescript-eslint/no-useless-empty-export": "error",
|
||||||
|
|
||||||
"no-unused-vars": "off",
|
"no-unused-vars": "off",
|
||||||
"@typescript-eslint/no-unused-vars": [
|
"@typescript-eslint/no-unused-vars": [
|
||||||
"error",
|
"error",
|
||||||
|
@ -113,16 +132,17 @@ export default [
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
|
|
||||||
// @typescript-eslint/no-redeclare supersedes no-redeclare
|
|
||||||
"no-redeclare": "off",
|
"no-redeclare": "off",
|
||||||
"@typescript-eslint/no-redeclare": "error",
|
"@typescript-eslint/no-redeclare": "error",
|
||||||
|
|
||||||
// @typescript-eslint/no-dupe-class-members supersedes no-dupe-class-members
|
// @typescript-eslint/no-dupe-class-members supersedes no-dupe-class-members
|
||||||
"no-dupe-class-members": "off",
|
"no-dupe-class-members": "off",
|
||||||
"@typescript-eslint/no-dupe-class-members": "error",
|
"@typescript-eslint/no-dupe-class-members": "error",
|
||||||
|
|
||||||
|
"no-useless-constructor": "off",
|
||||||
|
"@typescript-eslint/no-useless-constructor": "error",
|
||||||
},
|
},
|
||||||
}
|
})),
|
||||||
}),
|
|
||||||
{
|
{
|
||||||
files: ["**/*.spec.ts", "**/*.spec.js"],
|
files: ["**/*.spec.ts", "**/*.spec.js"],
|
||||||
|
|
||||||
|
|
|
@ -289,7 +289,7 @@ export class DatabaseImpl implements Database {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
let errorFound = false
|
let errorFound = false
|
||||||
let errorMessage: string = "Unable to bulk remove documents: "
|
let errorMessage = "Unable to bulk remove documents: "
|
||||||
for (let res of response) {
|
for (let res of response) {
|
||||||
if (res.error) {
|
if (res.error) {
|
||||||
errorFound = true
|
errorFound = true
|
||||||
|
|
|
@ -4,7 +4,7 @@ import { checkSlashesInUrl } from "../../helpers"
|
||||||
|
|
||||||
export async function directCouchCall(
|
export async function directCouchCall(
|
||||||
path: string,
|
path: string,
|
||||||
method: string = "GET",
|
method = "GET",
|
||||||
body?: any
|
body?: any
|
||||||
) {
|
) {
|
||||||
let { url, cookie } = getCouchInfo()
|
let { url, cookie } = getCouchInfo()
|
||||||
|
@ -43,7 +43,7 @@ export async function directCouchUrlCall({
|
||||||
|
|
||||||
export async function directCouchQuery(
|
export async function directCouchQuery(
|
||||||
path: string,
|
path: string,
|
||||||
method: string = "GET",
|
method = "GET",
|
||||||
body?: any
|
body?: any
|
||||||
) {
|
) {
|
||||||
const response = await directCouchCall(path, method, body)
|
const response = await directCouchCall(path, method, body)
|
||||||
|
|
|
@ -279,7 +279,7 @@ export class QueryBuilder<T> {
|
||||||
let query = allOr ? "" : "*:*"
|
let query = allOr ? "" : "*:*"
|
||||||
let allFiltersEmpty = true
|
let allFiltersEmpty = true
|
||||||
const allPreProcessingOpts = { escape: true, lowercase: true, wrap: true }
|
const allPreProcessingOpts = { escape: true, lowercase: true, wrap: true }
|
||||||
let tableId: string = ""
|
let tableId = ""
|
||||||
if (this.#query.equal!.tableId) {
|
if (this.#query.equal!.tableId) {
|
||||||
tableId = this.#query.equal!.tableId
|
tableId = this.#query.equal!.tableId
|
||||||
delete this.#query.equal!.tableId
|
delete this.#query.equal!.tableId
|
||||||
|
|
|
@ -2,7 +2,7 @@ import { Event, Identity, Group } from "@budibase/types"
|
||||||
import { EventProcessor } from "./types"
|
import { EventProcessor } from "./types"
|
||||||
|
|
||||||
export default class Processor implements EventProcessor {
|
export default class Processor implements EventProcessor {
|
||||||
initialised: boolean = false
|
initialised = false
|
||||||
processors: EventProcessor[] = []
|
processors: EventProcessor[] = []
|
||||||
|
|
||||||
constructor(processors: EventProcessor[]) {
|
constructor(processors: EventProcessor[]) {
|
||||||
|
|
|
@ -137,9 +137,9 @@ export default function (
|
||||||
}
|
}
|
||||||
|
|
||||||
const tenantId = getHeader(ctx, Header.TENANT_ID)
|
const tenantId = getHeader(ctx, Header.TENANT_ID)
|
||||||
let authenticated: boolean = false,
|
let authenticated = false,
|
||||||
user: User | { tenantId: string } | undefined = undefined,
|
user: User | { tenantId: string } | undefined = undefined,
|
||||||
internal: boolean = false,
|
internal = false,
|
||||||
loginMethod: LoginMethod | undefined = undefined
|
loginMethod: LoginMethod | undefined = undefined
|
||||||
if (authCookie && !apiKey) {
|
if (authCookie && !apiKey) {
|
||||||
const sessionId = authCookie.sessionId
|
const sessionId = authCookie.sessionId
|
||||||
|
|
|
@ -20,7 +20,7 @@ export const ssoSaveUserNoOp: SaveSSOUserFunction = (user: SSOUser) =>
|
||||||
*/
|
*/
|
||||||
export async function authenticate(
|
export async function authenticate(
|
||||||
details: SSOAuthDetails,
|
details: SSOAuthDetails,
|
||||||
requireLocalAccount: boolean = true,
|
requireLocalAccount = true,
|
||||||
done: any,
|
done: any,
|
||||||
saveUserFn: SaveSSOUserFunction
|
saveUserFn: SaveSSOUserFunction
|
||||||
) {
|
) {
|
||||||
|
|
|
@ -334,7 +334,7 @@ export async function listAllObjects(bucketName: string, path: string) {
|
||||||
export function getPresignedUrl(
|
export function getPresignedUrl(
|
||||||
bucketName: string,
|
bucketName: string,
|
||||||
key: string,
|
key: string,
|
||||||
durationSeconds: number = 3600
|
durationSeconds = 3600
|
||||||
) {
|
) {
|
||||||
const objectStore = ObjectStore(bucketName, { presigning: true })
|
const objectStore = ObjectStore(bucketName, { presigning: true })
|
||||||
const params = {
|
const params = {
|
||||||
|
|
|
@ -92,7 +92,7 @@ function getLockName(opts: LockOptions) {
|
||||||
// determine lock name
|
// determine lock name
|
||||||
// by default use the tenantId for uniqueness, unless using a system lock
|
// by default use the tenantId for uniqueness, unless using a system lock
|
||||||
const prefix = opts.systemLock ? "system" : context.getTenantId()
|
const prefix = opts.systemLock ? "system" : context.getTenantId()
|
||||||
let name: string = `lock:${prefix}_${opts.name}`
|
let name = `lock:${prefix}_${opts.name}`
|
||||||
// add additional unique name if required
|
// add additional unique name if required
|
||||||
if (opts.resource) {
|
if (opts.resource) {
|
||||||
name = name + `_${opts.resource}`
|
name = name + `_${opts.resource}`
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import { MonthlyQuotaName, QuotaUsage } from "@budibase/types"
|
import { MonthlyQuotaName, QuotaUsage } from "@budibase/types"
|
||||||
|
|
||||||
export const usage = (users: number = 0, creators: number = 0): QuotaUsage => {
|
export const usage = (users = 0, creators = 0): QuotaUsage => {
|
||||||
return {
|
return {
|
||||||
_id: "usage_quota",
|
_id: "usage_quota",
|
||||||
quotaReset: new Date().toISOString(),
|
quotaReset: new Date().toISOString(),
|
||||||
|
|
|
@ -85,7 +85,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
const getPos = e => {
|
const getPos = e => {
|
||||||
var rect = canvasRef.getBoundingClientRect()
|
let rect = canvasRef.getBoundingClientRect()
|
||||||
const canvasX = e.offsetX || e.targetTouches?.[0].pageX - rect.left
|
const canvasX = e.offsetX || e.targetTouches?.[0].pageX - rect.left
|
||||||
const canvasY = e.offsetY || e.targetTouches?.[0].pageY - rect.top
|
const canvasY = e.offsetY || e.targetTouches?.[0].pageY - rect.top
|
||||||
|
|
||||||
|
|
|
@ -24,9 +24,9 @@
|
||||||
const j = 32 // Outer radius strength (higher is stronger)
|
const j = 32 // Outer radius strength (higher is stronger)
|
||||||
|
|
||||||
// Calculate unit vector
|
// Calculate unit vector
|
||||||
var dx = x1 - x2
|
let dx = x1 - x2
|
||||||
var dy = y1 - y2
|
let dy = y1 - y2
|
||||||
var len = Math.sqrt(dx * dx + dy * dy)
|
let len = Math.sqrt(dx * dx + dy * dy)
|
||||||
dx = dx / len
|
dx = dx / len
|
||||||
dy = dy / len
|
dy = dy / len
|
||||||
|
|
||||||
|
|
|
@ -30,7 +30,7 @@ const FullScreenControl = L.Control.extend({
|
||||||
fullScreenTitle: "Enter Fullscreen",
|
fullScreenTitle: "Enter Fullscreen",
|
||||||
},
|
},
|
||||||
onAdd: function () {
|
onAdd: function () {
|
||||||
var fullScreenClassName = "leaflet-control-fullscreen",
|
let fullScreenClassName = "leaflet-control-fullscreen",
|
||||||
container = L.DomUtil.create("div", fullScreenClassName + " leaflet-bar"),
|
container = L.DomUtil.create("div", fullScreenClassName + " leaflet-bar"),
|
||||||
options = this.options
|
options = this.options
|
||||||
|
|
||||||
|
@ -45,7 +45,7 @@ const FullScreenControl = L.Control.extend({
|
||||||
return container
|
return container
|
||||||
},
|
},
|
||||||
_fullScreen: function () {
|
_fullScreen: function () {
|
||||||
var map = this._map
|
let map = this._map
|
||||||
if (screenfull.isEnabled) {
|
if (screenfull.isEnabled) {
|
||||||
screenfull.toggle(map.getContainer())
|
screenfull.toggle(map.getContainer())
|
||||||
}
|
}
|
||||||
|
@ -80,7 +80,7 @@ const LocationControl = L.Control.extend({
|
||||||
locationTitle: "Show Your Location",
|
locationTitle: "Show Your Location",
|
||||||
},
|
},
|
||||||
onAdd: function () {
|
onAdd: function () {
|
||||||
var locationClassName = "leaflet-control-location",
|
let locationClassName = "leaflet-control-location",
|
||||||
container = L.DomUtil.create("div", locationClassName + " leaflet-bar"),
|
container = L.DomUtil.create("div", locationClassName + " leaflet-bar"),
|
||||||
options = this.options
|
options = this.options
|
||||||
|
|
||||||
|
@ -136,7 +136,7 @@ const LocationControl = L.Control.extend({
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
_getPosition: function () {
|
_getPosition: function () {
|
||||||
var options = {
|
let options = {
|
||||||
enableHighAccuracy: false,
|
enableHighAccuracy: false,
|
||||||
timeout: 5000,
|
timeout: 5000,
|
||||||
maximumAge: 30000,
|
maximumAge: 30000,
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
/* eslint-disable no-useless-concat */
|
||||||
import { derived } from "svelte/store"
|
import { derived } from "svelte/store"
|
||||||
import { appStore } from "./app"
|
import { appStore } from "./app"
|
||||||
import { builderStore } from "./builder"
|
import { builderStore } from "./builder"
|
||||||
|
|
|
@ -22,7 +22,7 @@ import {
|
||||||
async function redirect(
|
async function redirect(
|
||||||
ctx: any,
|
ctx: any,
|
||||||
method: "GET" | "POST" | "DELETE",
|
method: "GET" | "POST" | "DELETE",
|
||||||
path: string = "global"
|
path = "global"
|
||||||
) {
|
) {
|
||||||
const { devPath } = ctx.params
|
const { devPath } = ctx.params
|
||||||
const queryString = ctx.originalUrl.split("?")[1] || ""
|
const queryString = ctx.originalUrl.split("?")[1] || ""
|
||||||
|
|
|
@ -378,7 +378,7 @@ export class ExternalRequest<T extends Operation> {
|
||||||
}
|
}
|
||||||
// many to one
|
// many to one
|
||||||
else {
|
else {
|
||||||
const thisKey: string = "id"
|
const thisKey = "id"
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
const otherKey: string = field.fieldName
|
const otherKey: string = field.fieldName
|
||||||
for (const relationship of row[key]) {
|
for (const relationship of row[key]) {
|
||||||
|
|
|
@ -45,7 +45,7 @@ export function getInternalRowId(row: Row, table: Table): string {
|
||||||
export function generateIdForRow(
|
export function generateIdForRow(
|
||||||
row: Row | undefined,
|
row: Row | undefined,
|
||||||
table: Table,
|
table: Table,
|
||||||
isLinked: boolean = false
|
isLinked = false
|
||||||
): string {
|
): string {
|
||||||
const primary = table.primary
|
const primary = table.primary
|
||||||
if (!row || !primary) {
|
if (!row || !primary) {
|
||||||
|
|
|
@ -16,7 +16,7 @@ function escapeCsvString(str: string) {
|
||||||
export function csv(
|
export function csv(
|
||||||
headers: string[],
|
headers: string[],
|
||||||
rows: Row[],
|
rows: Row[],
|
||||||
delimiter: string = ",",
|
delimiter = ",",
|
||||||
customHeaders: { [key: string]: string } = {}
|
customHeaders: { [key: string]: string } = {}
|
||||||
) {
|
) {
|
||||||
let csvRows = [getHeaders(headers, customHeaders)]
|
let csvRows = [getHeaders(headers, customHeaders)]
|
||||||
|
|
|
@ -2133,7 +2133,7 @@ if (descriptions.length) {
|
||||||
// repeat the search many times to check the first row is always the same
|
// repeat the search many times to check the first row is always the same
|
||||||
let bookmark: string | number | undefined,
|
let bookmark: string | number | undefined,
|
||||||
hasNextPage: boolean | undefined = true,
|
hasNextPage: boolean | undefined = true,
|
||||||
rowCount: number = 0
|
rowCount = 0
|
||||||
do {
|
do {
|
||||||
const response = await config.api.row.search(
|
const response = await config.api.row.search(
|
||||||
tableOrViewId,
|
tableOrViewId,
|
||||||
|
|
|
@ -263,7 +263,7 @@ class AutomationBuilder extends BaseStepBuilder {
|
||||||
private automationConfig: Automation
|
private automationConfig: Automation
|
||||||
private config: TestConfiguration
|
private config: TestConfiguration
|
||||||
private triggerOutputs: any
|
private triggerOutputs: any
|
||||||
private triggerSet: boolean = false
|
private triggerSet = false
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
options: { name?: string; appId?: string; config?: TestConfiguration } = {}
|
options: { name?: string; appId?: string; config?: TestConfiguration } = {}
|
||||||
|
|
|
@ -223,7 +223,7 @@ const COLUMN_DEFINITION_METADATA: Record<string, ColumnDefinitionMetadata> = {
|
||||||
|
|
||||||
class SqlServerIntegration extends Sql implements DatasourcePlus {
|
class SqlServerIntegration extends Sql implements DatasourcePlus {
|
||||||
private readonly config: MSSQLConfig
|
private readonly config: MSSQLConfig
|
||||||
private index: number = 0
|
private index = 0
|
||||||
private client?: sqlServer.ConnectionPool
|
private client?: sqlServer.ConnectionPool
|
||||||
|
|
||||||
MASTER_TABLES = [
|
MASTER_TABLES = [
|
||||||
|
|
|
@ -116,7 +116,7 @@ const OracleContraintTypes = {
|
||||||
|
|
||||||
class OracleIntegration extends Sql implements DatasourcePlus {
|
class OracleIntegration extends Sql implements DatasourcePlus {
|
||||||
private readonly config: OracleConfig
|
private readonly config: OracleConfig
|
||||||
private index: number = 1
|
private index = 1
|
||||||
|
|
||||||
private static readonly COLUMNS_SQL = `
|
private static readonly COLUMNS_SQL = `
|
||||||
SELECT
|
SELECT
|
||||||
|
|
|
@ -149,7 +149,7 @@ const SCHEMA: Integration = {
|
||||||
class PostgresIntegration extends Sql implements DatasourcePlus {
|
class PostgresIntegration extends Sql implements DatasourcePlus {
|
||||||
private readonly client: Client
|
private readonly client: Client
|
||||||
private readonly config: PostgresConfig
|
private readonly config: PostgresConfig
|
||||||
private index: number = 1
|
private index = 1
|
||||||
private open: boolean
|
private open: boolean
|
||||||
|
|
||||||
PRIMARY_KEYS_SQL = () => `
|
PRIMARY_KEYS_SQL = () => `
|
||||||
|
@ -252,7 +252,7 @@ class PostgresIntegration extends Sql implements DatasourcePlus {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
async internalQuery(query: SqlQuery, close: boolean = true) {
|
async internalQuery(query: SqlQuery, close = true) {
|
||||||
if (!this.open) {
|
if (!this.open) {
|
||||||
await this.openConnection()
|
await this.openConnection()
|
||||||
}
|
}
|
||||||
|
|
|
@ -171,7 +171,7 @@ export class RestIntegration implements IntegrationBase {
|
||||||
path.basename(parse(contentDisposition).parameters?.filename) || ""
|
path.basename(parse(contentDisposition).parameters?.filename) || ""
|
||||||
}
|
}
|
||||||
|
|
||||||
let triedParsing: boolean = false,
|
let triedParsing = false,
|
||||||
responseTxt: string | undefined
|
responseTxt: string | undefined
|
||||||
try {
|
try {
|
||||||
if (filename) {
|
if (filename) {
|
||||||
|
|
|
@ -245,7 +245,7 @@ describe("Captures of real examples", () => {
|
||||||
tableNames.push(generator.guid())
|
tableNames.push(generator.guid())
|
||||||
}
|
}
|
||||||
const aliasing = new AliasTables(tableNames)
|
const aliasing = new AliasTables(tableNames)
|
||||||
let alias: string = ""
|
let alias = ""
|
||||||
for (let table of tableNames) {
|
for (let table of tableNames) {
|
||||||
alias = aliasing.getAlias(table)
|
alias = aliasing.getAlias(table)
|
||||||
}
|
}
|
||||||
|
|
|
@ -59,9 +59,7 @@ async function updateAppUpdatedAt(ctx: UserCtx) {
|
||||||
await setDebounce(appId, DEBOUNCE_TIME_SEC)
|
await setDebounce(appId, DEBOUNCE_TIME_SEC)
|
||||||
} catch (err: any) {
|
} catch (err: any) {
|
||||||
// if a 409 occurs, then multiple clients connected at the same time - ignore
|
// if a 409 occurs, then multiple clients connected at the same time - ignore
|
||||||
if (err?.status === 409) {
|
if (err && err.status !== 409) {
|
||||||
return
|
|
||||||
} else {
|
|
||||||
throw err
|
throw err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -104,8 +104,6 @@ export async function getDependantResources(
|
||||||
return p
|
return p
|
||||||
}, {} as Record<string, number>)
|
}, {} as Record<string, number>)
|
||||||
}
|
}
|
||||||
|
|
||||||
return
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function updatePermissionOnRole(
|
export async function updatePermissionOnRole(
|
||||||
|
|
|
@ -437,7 +437,7 @@ export async function search(
|
||||||
)
|
)
|
||||||
|
|
||||||
// check for pagination final row
|
// check for pagination final row
|
||||||
let nextRow: boolean = false
|
let nextRow = false
|
||||||
if (paginate && params.limit && rows.length > params.limit) {
|
if (paginate && params.limit && rows.length > params.limit) {
|
||||||
// remove the extra row that confirmed if there is another row to move to
|
// remove the extra row that confirmed if there is another row to move to
|
||||||
nextRow = true
|
nextRow = true
|
||||||
|
|
|
@ -535,7 +535,7 @@ export function basicRow(tableId: string) {
|
||||||
export function basicLinkedRow(
|
export function basicLinkedRow(
|
||||||
tableId: string,
|
tableId: string,
|
||||||
linkedRowId: string,
|
linkedRowId: string,
|
||||||
linkField: string = "link"
|
linkField = "link"
|
||||||
) {
|
) {
|
||||||
// this is based on the basic linked tables you get from the test configuration
|
// this is based on the basic linked tables you get from the test configuration
|
||||||
return {
|
return {
|
||||||
|
@ -586,14 +586,14 @@ export function basicUser(role: string) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export function basicScreen(route: string = "/") {
|
export function basicScreen(route = "/") {
|
||||||
return createHomeScreen({
|
return createHomeScreen({
|
||||||
roleId: BUILTIN_ROLE_IDS.BASIC,
|
roleId: BUILTIN_ROLE_IDS.BASIC,
|
||||||
route,
|
route,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
export function powerScreen(route: string = "/") {
|
export function powerScreen(route = "/") {
|
||||||
return createHomeScreen({
|
return createHomeScreen({
|
||||||
roleId: BUILTIN_ROLE_IDS.POWER,
|
roleId: BUILTIN_ROLE_IDS.POWER,
|
||||||
route,
|
route,
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
export async function retry<T extends (...arg0: any[]) => any>(
|
export async function retry<T extends (...arg0: any[]) => any>(
|
||||||
fn: T,
|
fn: T,
|
||||||
maxTry: number = 5,
|
maxTry = 5,
|
||||||
retryCount = 1
|
retryCount = 1
|
||||||
): Promise<Awaited<ReturnType<T>>> {
|
): Promise<Awaited<ReturnType<T>>> {
|
||||||
const currRetry = typeof retryCount === "number" ? retryCount : 1
|
const currRetry = typeof retryCount === "number" ? retryCount : 1
|
||||||
|
|
|
@ -33,7 +33,7 @@ export class BaseSocket {
|
||||||
constructor(
|
constructor(
|
||||||
app: Koa,
|
app: Koa,
|
||||||
server: http.Server,
|
server: http.Server,
|
||||||
path: string = "/",
|
path = "/",
|
||||||
additionalMiddlewares?: any[]
|
additionalMiddlewares?: any[]
|
||||||
) {
|
) {
|
||||||
this.app = app
|
this.app = app
|
||||||
|
|
|
@ -33,7 +33,7 @@ function improveErrors(errors: string[]): string[] {
|
||||||
|
|
||||||
export function getNextExecutionDates(
|
export function getNextExecutionDates(
|
||||||
cronExpression: string,
|
cronExpression: string,
|
||||||
limit: number = 4
|
limit = 4
|
||||||
): string[] {
|
): string[] {
|
||||||
const parsed = cronParser.parseExpression(cronExpression)
|
const parsed = cronParser.parseExpression(cronExpression)
|
||||||
const nextRuns = []
|
const nextRuns = []
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
/* eslint-disable no-template-curly-in-string */
|
||||||
import { convertToJS } from "../src/index"
|
import { convertToJS } from "../src/index"
|
||||||
|
|
||||||
function checkLines(response: string, lines: string[]) {
|
function checkLines(response: string, lines: string[]) {
|
||||||
|
|
|
@ -11,7 +11,7 @@ function tryParseJson(str: string) {
|
||||||
try {
|
try {
|
||||||
return JSON.parse(str.replace(/'/g, '"'))
|
return JSON.parse(str.replace(/'/g, '"'))
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
return
|
// do nothing
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -128,13 +128,13 @@ export interface Database {
|
||||||
name: string
|
name: string
|
||||||
|
|
||||||
exists(): Promise<boolean>
|
exists(): Promise<boolean>
|
||||||
|
exists(docId: string): Promise<boolean>
|
||||||
/**
|
/**
|
||||||
* @deprecated the plan is to get everything using `tryGet` instead, then rename
|
* @deprecated the plan is to get everything using `tryGet` instead, then rename
|
||||||
* `tryGet` to `get`.
|
* `tryGet` to `get`.
|
||||||
*/
|
*/
|
||||||
get<T extends Document>(id?: string): Promise<T>
|
get<T extends Document>(id?: string): Promise<T>
|
||||||
tryGet<T extends Document>(id?: string): Promise<T | undefined>
|
tryGet<T extends Document>(id?: string): Promise<T | undefined>
|
||||||
exists(docId: string): Promise<boolean>
|
|
||||||
getMultiple<T extends Document>(
|
getMultiple<T extends Document>(
|
||||||
ids: string[],
|
ids: string[],
|
||||||
opts?: { allowMissing?: boolean; excludeDocs?: boolean }
|
opts?: { allowMissing?: boolean; excludeDocs?: boolean }
|
||||||
|
|
|
@ -40,10 +40,7 @@ export const getMetadata = async (
|
||||||
try {
|
try {
|
||||||
return await db.get(accountId)
|
return await db.get(accountId)
|
||||||
} catch (e: any) {
|
} catch (e: any) {
|
||||||
if (e.status === 404) {
|
if (e.status !== 404) {
|
||||||
// do nothing
|
|
||||||
return
|
|
||||||
} else {
|
|
||||||
throw e
|
throw e
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,12 +1,7 @@
|
||||||
import { Account, AccountMetadata } from "@budibase/types"
|
import { Account, AccountMetadata } from "@budibase/types"
|
||||||
import TestConfiguration from "../TestConfiguration"
|
|
||||||
import { TestAPI } from "./base"
|
import { TestAPI } from "./base"
|
||||||
|
|
||||||
export class AccountAPI extends TestAPI {
|
export class AccountAPI extends TestAPI {
|
||||||
constructor(config: TestConfiguration) {
|
|
||||||
super(config)
|
|
||||||
}
|
|
||||||
|
|
||||||
saveMetadata = async (account: Account) => {
|
saveMetadata = async (account: Account) => {
|
||||||
const res = await this.request
|
const res = await this.request
|
||||||
.put(`/api/system/accounts/${account.accountId}/metadata`)
|
.put(`/api/system/accounts/${account.accountId}/metadata`)
|
||||||
|
|
|
@ -1,12 +1,7 @@
|
||||||
import { AuditLogSearchParams, SearchAuditLogsResponse } from "@budibase/types"
|
import { AuditLogSearchParams, SearchAuditLogsResponse } from "@budibase/types"
|
||||||
import TestConfiguration from "../TestConfiguration"
|
|
||||||
import { TestAPI } from "./base"
|
import { TestAPI } from "./base"
|
||||||
|
|
||||||
export class AuditLogAPI extends TestAPI {
|
export class AuditLogAPI extends TestAPI {
|
||||||
constructor(config: TestConfiguration) {
|
|
||||||
super(config)
|
|
||||||
}
|
|
||||||
|
|
||||||
search = async (search: AuditLogSearchParams) => {
|
search = async (search: AuditLogSearchParams) => {
|
||||||
const res = await this.request
|
const res = await this.request
|
||||||
.post("/api/global/auditlogs/search")
|
.post("/api/global/auditlogs/search")
|
||||||
|
|
|
@ -1,11 +1,6 @@
|
||||||
import TestConfiguration from "../TestConfiguration"
|
|
||||||
import { TestAPI, TestAPIOpts } from "./base"
|
import { TestAPI, TestAPIOpts } from "./base"
|
||||||
|
|
||||||
export class AuthAPI extends TestAPI {
|
export class AuthAPI extends TestAPI {
|
||||||
constructor(config: TestConfiguration) {
|
|
||||||
super(config)
|
|
||||||
}
|
|
||||||
|
|
||||||
updatePassword = (
|
updatePassword = (
|
||||||
resetCode: string,
|
resetCode: string,
|
||||||
password: string,
|
password: string,
|
||||||
|
|
|
@ -10,7 +10,7 @@ export abstract class TestAPI {
|
||||||
config: TestConfiguration
|
config: TestConfiguration
|
||||||
request: SuperTest<Test>
|
request: SuperTest<Test>
|
||||||
|
|
||||||
protected constructor(config: TestConfiguration) {
|
constructor(config: TestConfiguration) {
|
||||||
this.config = config
|
this.config = config
|
||||||
this.request = config.request
|
this.request = config.request
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,11 +1,6 @@
|
||||||
import TestConfiguration from "../TestConfiguration"
|
|
||||||
import { TestAPI } from "./base"
|
import { TestAPI } from "./base"
|
||||||
|
|
||||||
export class ConfigAPI extends TestAPI {
|
export class ConfigAPI extends TestAPI {
|
||||||
constructor(config: TestConfiguration) {
|
|
||||||
super(config)
|
|
||||||
}
|
|
||||||
|
|
||||||
getConfigChecklist = () => {
|
getConfigChecklist = () => {
|
||||||
return this.request
|
return this.request
|
||||||
.get(`/api/global/configs/checklist`)
|
.get(`/api/global/configs/checklist`)
|
||||||
|
|
|
@ -1,12 +1,7 @@
|
||||||
import { EmailAttachment } from "@budibase/types"
|
import { EmailAttachment } from "@budibase/types"
|
||||||
import TestConfiguration from "../TestConfiguration"
|
|
||||||
import { TestAPI } from "./base"
|
import { TestAPI } from "./base"
|
||||||
|
|
||||||
export class EmailAPI extends TestAPI {
|
export class EmailAPI extends TestAPI {
|
||||||
constructor(config: TestConfiguration) {
|
|
||||||
super(config)
|
|
||||||
}
|
|
||||||
|
|
||||||
sendEmail = (purpose: string, attachments?: EmailAttachment[]) => {
|
sendEmail = (purpose: string, attachments?: EmailAttachment[]) => {
|
||||||
return this.request
|
return this.request
|
||||||
.post(`/api/global/email/send`)
|
.post(`/api/global/email/send`)
|
||||||
|
|
|
@ -1,11 +1,6 @@
|
||||||
import TestConfiguration from "../TestConfiguration"
|
|
||||||
import { TestAPI } from "./base"
|
import { TestAPI } from "./base"
|
||||||
|
|
||||||
export class EnvironmentAPI extends TestAPI {
|
export class EnvironmentAPI extends TestAPI {
|
||||||
constructor(config: TestConfiguration) {
|
|
||||||
super(config)
|
|
||||||
}
|
|
||||||
|
|
||||||
getEnvironment = () => {
|
getEnvironment = () => {
|
||||||
return this.request
|
return this.request
|
||||||
.get(`/api/system/environment`)
|
.get(`/api/system/environment`)
|
||||||
|
|
|
@ -1,12 +1,7 @@
|
||||||
import { UserGroup } from "@budibase/types"
|
import { UserGroup } from "@budibase/types"
|
||||||
import TestConfiguration from "../TestConfiguration"
|
|
||||||
import { TestAPI } from "./base"
|
import { TestAPI } from "./base"
|
||||||
|
|
||||||
export class GroupsAPI extends TestAPI {
|
export class GroupsAPI extends TestAPI {
|
||||||
constructor(config: TestConfiguration) {
|
|
||||||
super(config)
|
|
||||||
}
|
|
||||||
|
|
||||||
saveGroup = (
|
saveGroup = (
|
||||||
group: UserGroup,
|
group: UserGroup,
|
||||||
{ expect }: { expect: number | object } = { expect: 200 }
|
{ expect }: { expect: number | object } = { expect: 200 }
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
import TestConfiguration from "../TestConfiguration"
|
|
||||||
import { TestAPI } from "./base"
|
import { TestAPI } from "./base"
|
||||||
import {
|
import {
|
||||||
ActivateLicenseKeyRequest,
|
ActivateLicenseKeyRequest,
|
||||||
|
@ -6,10 +5,6 @@ import {
|
||||||
} from "@budibase/types"
|
} from "@budibase/types"
|
||||||
|
|
||||||
export class LicenseAPI extends TestAPI {
|
export class LicenseAPI extends TestAPI {
|
||||||
constructor(config: TestConfiguration) {
|
|
||||||
super(config)
|
|
||||||
}
|
|
||||||
|
|
||||||
refresh = async () => {
|
refresh = async () => {
|
||||||
return this.request
|
return this.request
|
||||||
.post("/api/global/license/refresh")
|
.post("/api/global/license/refresh")
|
||||||
|
|
|
@ -1,11 +1,6 @@
|
||||||
import TestConfiguration from "../TestConfiguration"
|
|
||||||
import { TestAPI, TestAPIOpts } from "./base"
|
import { TestAPI, TestAPIOpts } from "./base"
|
||||||
|
|
||||||
export class MigrationAPI extends TestAPI {
|
export class MigrationAPI extends TestAPI {
|
||||||
constructor(config: TestConfiguration) {
|
|
||||||
super(config)
|
|
||||||
}
|
|
||||||
|
|
||||||
runMigrations = (opts?: TestAPIOpts) => {
|
runMigrations = (opts?: TestAPIOpts) => {
|
||||||
return this.request
|
return this.request
|
||||||
.post(`/api/system/migrations/run`)
|
.post(`/api/system/migrations/run`)
|
||||||
|
|
|
@ -1,11 +1,6 @@
|
||||||
import TestConfiguration from "../TestConfiguration"
|
|
||||||
import { TestAPI, TestAPIOpts } from "./base"
|
import { TestAPI, TestAPIOpts } from "./base"
|
||||||
|
|
||||||
export class RestoreAPI extends TestAPI {
|
export class RestoreAPI extends TestAPI {
|
||||||
constructor(config: TestConfiguration) {
|
|
||||||
super(config)
|
|
||||||
}
|
|
||||||
|
|
||||||
restored = (opts?: TestAPIOpts) => {
|
restored = (opts?: TestAPIOpts) => {
|
||||||
return this.request
|
return this.request
|
||||||
.post(`/api/system/restored`)
|
.post(`/api/system/restored`)
|
||||||
|
|
|
@ -1,11 +1,6 @@
|
||||||
import TestConfiguration from "../TestConfiguration"
|
|
||||||
import { TestAPI, TestAPIOpts } from "./base"
|
import { TestAPI, TestAPIOpts } from "./base"
|
||||||
|
|
||||||
export class RolesAPI extends TestAPI {
|
export class RolesAPI extends TestAPI {
|
||||||
constructor(config: TestConfiguration) {
|
|
||||||
super(config)
|
|
||||||
}
|
|
||||||
|
|
||||||
get = (opts?: TestAPIOpts) => {
|
get = (opts?: TestAPIOpts) => {
|
||||||
return this.request
|
return this.request
|
||||||
.get(`/api/global/roles`)
|
.get(`/api/global/roles`)
|
||||||
|
|
|
@ -4,14 +4,9 @@ import {
|
||||||
ScimGroupResponse,
|
ScimGroupResponse,
|
||||||
ScimUpdateRequest,
|
ScimUpdateRequest,
|
||||||
} from "@budibase/types"
|
} from "@budibase/types"
|
||||||
import TestConfiguration from "../../TestConfiguration"
|
|
||||||
import { RequestSettings, ScimTestAPI } from "./shared"
|
import { RequestSettings, ScimTestAPI } from "./shared"
|
||||||
|
|
||||||
export class ScimGroupsAPI extends ScimTestAPI {
|
export class ScimGroupsAPI extends ScimTestAPI {
|
||||||
constructor(config: TestConfiguration) {
|
|
||||||
super(config)
|
|
||||||
}
|
|
||||||
|
|
||||||
get = async (
|
get = async (
|
||||||
requestSettings?: Partial<RequestSettings> & {
|
requestSettings?: Partial<RequestSettings> & {
|
||||||
params?: {
|
params?: {
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
import TestConfiguration from "../../TestConfiguration"
|
|
||||||
import { TestAPI } from "../base"
|
import { TestAPI } from "../base"
|
||||||
|
|
||||||
const defaultConfig: RequestSettings = {
|
const defaultConfig: RequestSettings = {
|
||||||
|
@ -14,10 +13,6 @@ export type RequestSettings = {
|
||||||
}
|
}
|
||||||
|
|
||||||
export abstract class ScimTestAPI extends TestAPI {
|
export abstract class ScimTestAPI extends TestAPI {
|
||||||
constructor(config: TestConfiguration) {
|
|
||||||
super(config)
|
|
||||||
}
|
|
||||||
|
|
||||||
call = (
|
call = (
|
||||||
url: string,
|
url: string,
|
||||||
method: "get" | "post" | "patch" | "delete",
|
method: "get" | "post" | "patch" | "delete",
|
||||||
|
|
|
@ -4,14 +4,9 @@ import {
|
||||||
ScimUserResponse,
|
ScimUserResponse,
|
||||||
ScimUpdateRequest,
|
ScimUpdateRequest,
|
||||||
} from "@budibase/types"
|
} from "@budibase/types"
|
||||||
import TestConfiguration from "../../TestConfiguration"
|
|
||||||
import { RequestSettings, ScimTestAPI } from "./shared"
|
import { RequestSettings, ScimTestAPI } from "./shared"
|
||||||
|
|
||||||
export class ScimUsersAPI extends ScimTestAPI {
|
export class ScimUsersAPI extends ScimTestAPI {
|
||||||
constructor(config: TestConfiguration) {
|
|
||||||
super(config)
|
|
||||||
}
|
|
||||||
|
|
||||||
get = async (
|
get = async (
|
||||||
requestSettings?: Partial<RequestSettings> & {
|
requestSettings?: Partial<RequestSettings> & {
|
||||||
params?: {
|
params?: {
|
||||||
|
|
|
@ -1,12 +1,7 @@
|
||||||
import TestConfiguration from "../TestConfiguration"
|
|
||||||
import { User } from "@budibase/types"
|
import { User } from "@budibase/types"
|
||||||
import { TestAPI } from "./base"
|
import { TestAPI } from "./base"
|
||||||
|
|
||||||
export class SelfAPI extends TestAPI {
|
export class SelfAPI extends TestAPI {
|
||||||
constructor(config: TestConfiguration) {
|
|
||||||
super(config)
|
|
||||||
}
|
|
||||||
|
|
||||||
updateSelf = (user: User, update: any) => {
|
updateSelf = (user: User, update: any) => {
|
||||||
return this.request
|
return this.request
|
||||||
.post(`/api/global/self`)
|
.post(`/api/global/self`)
|
||||||
|
|
|
@ -1,11 +1,6 @@
|
||||||
import TestConfiguration from "../TestConfiguration"
|
|
||||||
import { TestAPI } from "./base"
|
import { TestAPI } from "./base"
|
||||||
|
|
||||||
export class StatusAPI extends TestAPI {
|
export class StatusAPI extends TestAPI {
|
||||||
constructor(config: TestConfiguration) {
|
|
||||||
super(config)
|
|
||||||
}
|
|
||||||
|
|
||||||
getStatus = () => {
|
getStatus = () => {
|
||||||
return this.request.get(`/api/system/status`).expect(200)
|
return this.request.get(`/api/system/status`).expect(200)
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,11 +1,6 @@
|
||||||
import TestConfiguration from "../TestConfiguration"
|
|
||||||
import { TestAPI, TestAPIOpts } from "./base"
|
import { TestAPI, TestAPIOpts } from "./base"
|
||||||
|
|
||||||
export class TemplatesAPI extends TestAPI {
|
export class TemplatesAPI extends TestAPI {
|
||||||
constructor(config: TestConfiguration) {
|
|
||||||
super(config)
|
|
||||||
}
|
|
||||||
|
|
||||||
definitions = (opts?: TestAPIOpts) => {
|
definitions = (opts?: TestAPIOpts) => {
|
||||||
return this.request
|
return this.request
|
||||||
.get(`/api/global/template/definitions`)
|
.get(`/api/global/template/definitions`)
|
||||||
|
|
|
@ -9,14 +9,9 @@ import {
|
||||||
} from "@budibase/types"
|
} from "@budibase/types"
|
||||||
import structures from "../structures"
|
import structures from "../structures"
|
||||||
import { generator } from "@budibase/backend-core/tests"
|
import { generator } from "@budibase/backend-core/tests"
|
||||||
import TestConfiguration from "../TestConfiguration"
|
|
||||||
import { TestAPI, TestAPIOpts } from "./base"
|
import { TestAPI, TestAPIOpts } from "./base"
|
||||||
|
|
||||||
export class UserAPI extends TestAPI {
|
export class UserAPI extends TestAPI {
|
||||||
constructor(config: TestConfiguration) {
|
|
||||||
super(config)
|
|
||||||
}
|
|
||||||
|
|
||||||
// INVITE
|
// INVITE
|
||||||
|
|
||||||
sendUserInvite = async (sendMailMock: any, email: string, status = 200) => {
|
sendUserInvite = async (sendMailMock: any, email: string, status = 200) => {
|
||||||
|
@ -178,11 +173,7 @@ export class UserAPI extends TestAPI {
|
||||||
.expect(opts?.status ? opts.status : 200)
|
.expect(opts?.status ? opts.status : 200)
|
||||||
}
|
}
|
||||||
|
|
||||||
grantBuilderToApp = (
|
grantBuilderToApp = (userId: string, appId: string, statusCode = 200) => {
|
||||||
userId: string,
|
|
||||||
appId: string,
|
|
||||||
statusCode: number = 200
|
|
||||||
) => {
|
|
||||||
return this.request
|
return this.request
|
||||||
.post(`/api/global/users/${userId}/app/${appId}/builder`)
|
.post(`/api/global/users/${userId}/app/${appId}/builder`)
|
||||||
.set(this.config.defaultHeaders())
|
.set(this.config.defaultHeaders())
|
||||||
|
|
|
@ -42,7 +42,7 @@ const svelteCompilePlugin = {
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
var { argv } = require("yargs")
|
let { argv } = require("yargs")
|
||||||
|
|
||||||
async function runBuild(entry, outfile) {
|
async function runBuild(entry, outfile) {
|
||||||
const isDev = process.env.NODE_ENV !== "production"
|
const isDev = process.env.NODE_ENV !== "production"
|
||||||
|
|
Loading…
Reference in New Issue