Replacing some require statements with imports.
This commit is contained in:
parent
69b9af51ff
commit
d27674de5c
|
@ -3,7 +3,7 @@ import * as rowController from "../controllers/row"
|
|||
import authorized from "../../middleware/authorized"
|
||||
import { paramResource, paramSubResource } from "../../middleware/resourceId"
|
||||
import { permissions } from "@budibase/backend-core"
|
||||
const { internalSearchValidator } = require("./utils/validators")
|
||||
import { internalSearchValidator } from "./utils/validators"
|
||||
const { PermissionType, PermissionLevel } = permissions
|
||||
|
||||
const router: Router = new Router()
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import { bootstrap } from "global-agent"
|
||||
const fixPath = require("fix-path")
|
||||
const { checkDevelopmentEnvironment } = require("./utilities/fileSystem")
|
||||
import { checkDevelopmentEnvironment } from "./utilities/fileSystem"
|
||||
|
||||
function runServer() {
|
||||
// this will shutdown the system if development environment not ready
|
||||
|
|
|
@ -3,7 +3,7 @@ import { Operation, QueryJson, RenameColumn, Table } from "@budibase/types"
|
|||
import { breakExternalTableId } from "../utils"
|
||||
import SchemaBuilder = Knex.SchemaBuilder
|
||||
import CreateTableBuilder = Knex.CreateTableBuilder
|
||||
const { FieldTypes, RelationshipTypes } = require("../../constants")
|
||||
import { FieldTypes, RelationshipTypes } from "../../constants"
|
||||
|
||||
function generateSchema(
|
||||
schema: CreateTableBuilder,
|
||||
|
|
|
@ -5,8 +5,8 @@ import {
|
|||
IntegrationBase,
|
||||
} from "@budibase/types"
|
||||
|
||||
const AWS = require("aws-sdk")
|
||||
const { AWS_REGION } = require("../db/dynamoClient")
|
||||
import AWS from "aws-sdk"
|
||||
import { AWS_REGION } from "../db/dynamoClient"
|
||||
|
||||
interface DynamoDBConfig {
|
||||
region: string
|
||||
|
@ -182,7 +182,7 @@ class DynamoDBIntegration implements IntegrationBase {
|
|||
return response
|
||||
}
|
||||
|
||||
async describe(query: { table: string }) {
|
||||
async describe(query: { table: string }): Promise<any> {
|
||||
const params = {
|
||||
TableName: query.table,
|
||||
}
|
||||
|
|
|
@ -16,7 +16,7 @@ import {
|
|||
finaliseExternalTables,
|
||||
} from "./utils"
|
||||
import dayjs from "dayjs"
|
||||
const { NUMBER_REGEX } = require("../utilities")
|
||||
import { NUMBER_REGEX } from "../utilities"
|
||||
import Sql from "./base/sql"
|
||||
import { MySQLColumn } from "./base/types"
|
||||
|
||||
|
|
|
@ -16,11 +16,11 @@ import {
|
|||
import { get } from "lodash"
|
||||
import * as https from "https"
|
||||
import qs from "querystring"
|
||||
const fetch = require("node-fetch")
|
||||
const { formatBytes } = require("../utilities")
|
||||
const { performance } = require("perf_hooks")
|
||||
const FormData = require("form-data")
|
||||
const { URLSearchParams } = require("url")
|
||||
import fetch from "node-fetch"
|
||||
import { formatBytes } from "../utilities"
|
||||
import { performance } from "perf_hooks"
|
||||
import FormData from "form-data"
|
||||
import { URLSearchParams } from "url"
|
||||
|
||||
const BodyTypes = {
|
||||
NONE: "none",
|
||||
|
@ -204,12 +204,12 @@ class RestIntegration implements IntegrationBase {
|
|||
|
||||
// Append page number or cursor param if configured
|
||||
if (pageParam && paginationValues.page != null) {
|
||||
params.append(pageParam, paginationValues.page)
|
||||
params.append(pageParam, paginationValues.page as string)
|
||||
}
|
||||
|
||||
// Append page size param if configured
|
||||
if (sizeParam && paginationValues.limit != null) {
|
||||
params.append(sizeParam, paginationValues.limit)
|
||||
params.append(sizeParam, String(paginationValues.limit))
|
||||
}
|
||||
|
||||
// Prepend query string with pagination params
|
||||
|
@ -280,7 +280,7 @@ class RestIntegration implements IntegrationBase {
|
|||
case BodyTypes.ENCODED:
|
||||
const params = new URLSearchParams()
|
||||
for (let [key, value] of Object.entries(object)) {
|
||||
params.append(key, value)
|
||||
params.append(key, value as string)
|
||||
}
|
||||
addPaginationToBody((key: string, value: any) => {
|
||||
params.append(key, value)
|
||||
|
|
|
@ -9,11 +9,11 @@ import { getGlobalIDFromUserMetadataID } from "../db/utils"
|
|||
import sdk from "../sdk"
|
||||
import { cloneDeep } from "lodash/fp"
|
||||
|
||||
const { isSQL } = require("../integrations/utils")
|
||||
const {
|
||||
import { isSQL } from "../integrations/utils"
|
||||
import {
|
||||
enrichQueryFields,
|
||||
interpolateSQL,
|
||||
} = require("../integrations/queries/sql")
|
||||
} from "../integrations/queries/sql"
|
||||
|
||||
class QueryRunner {
|
||||
datasource: any
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
import { PathLike } from "fs"
|
||||
const { budibaseTempDir } = require("../budibaseDir")
|
||||
const fs = require("fs")
|
||||
const { join } = require("path")
|
||||
const uuid = require("uuid/v4")
|
||||
import fs from "fs"
|
||||
import { budibaseTempDir } from "../budibaseDir"
|
||||
import { join } from "path"
|
||||
import env from "../../environment"
|
||||
import tar from "tar"
|
||||
const uuid = require("uuid/v4")
|
||||
|
||||
export const TOP_LEVEL_PATH = join(__dirname, "..", "..", "..")
|
||||
|
||||
|
@ -112,6 +112,7 @@ export const sendTempFile = (fileContents: any) => {
|
|||
* allows a centralised location to check logic is all good.
|
||||
*/
|
||||
export const readFileSync = (filepath: PathLike, options = "utf8") => {
|
||||
// @ts-ignore
|
||||
return fs.readFileSync(filepath, options)
|
||||
}
|
||||
|
||||
|
@ -147,6 +148,7 @@ export const findFileRec = (startPath: PathLike, filter: string): any => {
|
|||
|
||||
const files = fs.readdirSync(startPath)
|
||||
for (let i = 0, len = files.length; i < len; i++) {
|
||||
// @ts-ignore
|
||||
const filename = join(startPath, files[i])
|
||||
const stat = fs.lstatSync(filename)
|
||||
|
||||
|
|
|
@ -1,8 +1,7 @@
|
|||
import { Plugin } from "@budibase/types"
|
||||
|
||||
const { budibaseTempDir } = require("../budibaseDir")
|
||||
const fs = require("fs")
|
||||
const { join } = require("path")
|
||||
import { budibaseTempDir } from "../budibaseDir"
|
||||
import fs from "fs"
|
||||
import { join } from "path"
|
||||
import { objectStore } from "@budibase/backend-core"
|
||||
|
||||
const DATASOURCE_PATH = join(budibaseTempDir(), "datasource")
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
const fs = require("fs")
|
||||
const { join } = require("path")
|
||||
import fs from "fs"
|
||||
import { join } from "path"
|
||||
import { ObjectStoreBuckets } from "../../constants"
|
||||
import { objectStore } from "@budibase/backend-core"
|
||||
|
||||
|
|
Loading…
Reference in New Issue