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