From 0ec6ac3372c35aab0541626436e297446853c2d7 Mon Sep 17 00:00:00 2001 From: Andrew Kingston Date: Wed, 10 Aug 2022 12:04:58 +0100 Subject: [PATCH 001/203] Add PoC of using a custom component inside client library --- packages/client/src/components/ClientApp.svelte | 10 ++++++++++ packages/client/src/index.js | 6 ++++++ .../controllers/static/templates/BudibaseApp.svelte | 5 +++++ 3 files changed, 21 insertions(+) diff --git a/packages/client/src/components/ClientApp.svelte b/packages/client/src/components/ClientApp.svelte index 64b1712b89..c883dd4206 100644 --- a/packages/client/src/components/ClientApp.svelte +++ b/packages/client/src/components/ClientApp.svelte @@ -85,8 +85,18 @@ builderStore.actions.notifyLoaded() } }) + + // TODO: remove. this is a test to render the first custom component + console.log(window["##BUDIBASE_CUSTOM_COMPONENTS##"]?.[0]) + const custom = window["##BUDIBASE_CUSTOM_COMPONENTS##"]?.[0]?.Component +{#if custom} +
+ +
+{/if} + {#if dataLoaded}
+ + + -{#if custom} -
- -
-{/if} - {#if dataLoaded}
import { getContext, setContext, onMount, onDestroy } from "svelte" import { writable, get } from "svelte/store" - import * as AppComponents from "components/app" - import Router from "./Router.svelte" import { enrichProps, propsAreSame, @@ -180,7 +178,7 @@ // Pull definition and constructor const component = instance._component - constructor = getComponentConstructor(component) + constructor = componentStore.actions.getComponentConstructor(component) definition = componentStore.actions.getComponentDefinition(component) if (!definition) { return @@ -237,16 +235,6 @@ }) } - // Gets the component constructor for the specified component - const getComponentConstructor = component => { - const split = component?.split("/") - const name = split?.[split.length - 1] - if (name === "screenslot" && !insideScreenslot) { - return Router - } - return AppComponents[name] - } - const getSettingsDefinitionMap = settingsDefinition => { let map = {} settingsDefinition?.forEach(setting => { diff --git a/packages/client/src/components/Screen.svelte b/packages/client/src/components/Screen.svelte index 3ec8d1ea52..12e6803aea 100644 --- a/packages/client/src/components/Screen.svelte +++ b/packages/client/src/components/Screen.svelte @@ -13,7 +13,22 @@ $: routeStore.actions.setRouteParams(params || {}) // Get the screen definition for the current route - $: screenDefinition = $screenStore.activeScreen?.props + $: screenDefinition = getScreenDefinition($screenStore.activeScreen?.props) + + const getScreenDefinition = definition => { + const test = { + _component: "test", + _id: "asfdasdfefgerdgrfdg", + _styles: { + normal: {}, + }, + text: "This is a text prop!", + } + return { + ...definition, + _children: [...definition._children, test], + } + } onMount(() => { // Mark the router as loaded whenever the screen mounts diff --git a/packages/client/src/index.js b/packages/client/src/index.js index c88afe59ba..32b242bc69 100644 --- a/packages/client/src/index.js +++ b/packages/client/src/index.js @@ -1,5 +1,5 @@ import ClientApp from "./components/ClientApp.svelte" -import { builderStore, appStore, devToolsStore } from "./stores" +import { componentStore, builderStore, appStore, devToolsStore } from "./stores" import loadSpectrumIcons from "@budibase/bbui/spectrum-icons-rollup.js" import { get } from "svelte/store" @@ -38,6 +38,13 @@ const loadBudibase = () => { const enableDevTools = !get(builderStore).inBuilder && get(appStore).isDevApp devToolsStore.actions.setEnabled(enableDevTools) + // Register any custom components + if (window["##BUDIBASE_CUSTOM_COMPONENTS##"]) { + window["##BUDIBASE_CUSTOM_COMPONENTS##"].forEach(component => { + componentStore.actions.registerCustomComponent(component) + }) + } + // Create app if one hasn't been created yet if (!app) { app = new ClientApp({ diff --git a/packages/client/src/stores/components.js b/packages/client/src/stores/components.js index a7426113e2..2500ea2a41 100644 --- a/packages/client/src/stores/components.js +++ b/packages/client/src/stores/components.js @@ -4,6 +4,10 @@ import { findComponentById, findComponentPathById } from "../utils/components" import { devToolsStore } from "./devTools" import { screenStore } from "./screens" import { builderStore } from "./builder" +import Router from "../components/Router.svelte" +import * as AppComponents from "../components/app/index.js" + +const budibasePrefix = "@budibase/standard-components/" const createComponentStore = () => { const store = writable({}) @@ -34,6 +38,7 @@ const createComponentStore = () => { findComponentPathById(asset?.props, selectedComponentId) || [] return { + customComponentManifest: $store.customComponentManifest, selectedComponentInstance: $store[selectedComponentId], selectedComponent: component, selectedComponentDefinition: definition, @@ -68,9 +73,60 @@ const createComponentStore = () => { } const getComponentDefinition = type => { - const prefix = "@budibase/standard-components/" - type = type?.replace(prefix, "") - return type ? Manifest[type] : null + if (!type) { + return null + } + + // Screenslot is an edge case + if (type === "screenslot") { + type = `${budibasePrefix}${type}` + } + + // Handle built-in components + if (type.startsWith(budibasePrefix)) { + type = type.replace(budibasePrefix, "") + return type ? Manifest[type] : null + } + + // Handle custom components + const { customComponentManifest } = get(store) + return customComponentManifest?.[type]?.schema?.schema + } + + const getComponentConstructor = type => { + if (!type) { + return null + } + if (type === "screenslot") { + return Router + } + + // Handle budibase components + if (type.startsWith(budibasePrefix)) { + const split = type.split("/") + const name = split[split.length - 1] + return AppComponents[name] + } + + // Handle custom components + const { customComponentManifest } = get(store) + return customComponentManifest?.[type]?.Component + } + + const registerCustomComponent = ({ Component, schema }) => { + if (!Component || !schema?.schema?.name) { + return + } + store.update(state => { + if (!state.customComponentManifest) { + state.customComponentManifest = {} + } + state.customComponentManifest[schema.schema.name] = { + schema, + Component, + } + return state + }) } return { @@ -81,6 +137,8 @@ const createComponentStore = () => { isComponentRegistered, getComponentById, getComponentDefinition, + getComponentConstructor, + registerCustomComponent, }, } } From eb1699381c2eb64148bfff65485cf273b2f9af8e Mon Sep 17 00:00:00 2001 From: Andrew Kingston Date: Wed, 10 Aug 2022 15:52:19 +0100 Subject: [PATCH 004/203] Remove forced custom component from client library --- packages/client/src/components/Screen.svelte | 17 +---------------- 1 file changed, 1 insertion(+), 16 deletions(-) diff --git a/packages/client/src/components/Screen.svelte b/packages/client/src/components/Screen.svelte index 12e6803aea..3ec8d1ea52 100644 --- a/packages/client/src/components/Screen.svelte +++ b/packages/client/src/components/Screen.svelte @@ -13,22 +13,7 @@ $: routeStore.actions.setRouteParams(params || {}) // Get the screen definition for the current route - $: screenDefinition = getScreenDefinition($screenStore.activeScreen?.props) - - const getScreenDefinition = definition => { - const test = { - _component: "test", - _id: "asfdasdfefgerdgrfdg", - _styles: { - normal: {}, - }, - text: "This is a text prop!", - } - return { - ...definition, - _children: [...definition._children, test], - } - } + $: screenDefinition = $screenStore.activeScreen?.props onMount(() => { // Mark the router as loaded whenever the screen mounts From 7dc9abf54b324fc8e07ff3cdbc17625569d99d5b Mon Sep 17 00:00:00 2001 From: mike12345567 Date: Wed, 10 Aug 2022 16:19:08 +0100 Subject: [PATCH 005/203] Validating datasources fully, initial work towards validating components and including the build in the CLI. --- packages/cli/package.json | 6 +- packages/cli/src/exec.js | 25 ++++++ packages/cli/src/plugins/constants.js | 6 ++ packages/cli/src/plugins/index.js | 54 ++++++++++-- packages/cli/src/plugins/validate.js | 87 +++++++++++++++++++ packages/cli/yarn.lock | 45 ++++++++++ packages/server/src/definitions/datasource.ts | 84 ++++-------------- .../types/src/documents/app/datasource.ts | 69 +++++++++++++++ 8 files changed, 297 insertions(+), 79 deletions(-) create mode 100644 packages/cli/src/exec.js create mode 100644 packages/cli/src/plugins/constants.js create mode 100644 packages/cli/src/plugins/validate.js diff --git a/packages/cli/package.json b/packages/cli/package.json index 5a048fb17d..413703af9b 100644 --- a/packages/cli/package.json +++ b/packages/cli/package.json @@ -26,8 +26,9 @@ "outputPath": "build" }, "dependencies": { - "@budibase/backend-core": "1.1.32-alpha.6", - "@budibase/string-templates": "^1.2.28", + "@budibase/backend-core": "1.2.28-alpha.0", + "@budibase/string-templates": "1.2.28-alpha.0", + "@budibase/types": "1.2.28-alpha.0", "axios": "0.21.2", "chalk": "4.1.0", "cli-progress": "3.11.2", @@ -36,6 +37,7 @@ "dotenv": "16.0.1", "download": "^8.0.0", "inquirer": "8.0.0", + "joi": "^17.6.0", "lookpath": "1.1.0", "node-fetch": "2", "pkg": "5.7.0", diff --git a/packages/cli/src/exec.js b/packages/cli/src/exec.js new file mode 100644 index 0000000000..07520336c4 --- /dev/null +++ b/packages/cli/src/exec.js @@ -0,0 +1,25 @@ +const util = require("util") +const exec = util.promisify(require("child_process").exec) + +exports.exec = async command => { + const { stdout } = await exec(command) + return stdout +} + +exports.utilityInstalled = async utilName => { + try { + await exports.exec(`${utilName} --version`) + return true + } catch (err) { + return false + } +} + +exports.runPkgCommand = async command => { + const yarn = await exports.utilityInstalled("yarn") + const npm = await exports.utilityInstalled("npm") + if (!yarn && !npm) { + throw new Error("Must have yarn or npm installed to run build.") + } + await exports.exec(yarn ? `yarn ${command}` : `npm run ${command}`) +} diff --git a/packages/cli/src/plugins/constants.js b/packages/cli/src/plugins/constants.js new file mode 100644 index 0000000000..37d0748979 --- /dev/null +++ b/packages/cli/src/plugins/constants.js @@ -0,0 +1,6 @@ +exports.PluginTypes = { + COMPONENT: "component", + DATASOURCE: "datasource", +} + +exports.PLUGIN_TYPES_ARR = Object.values(exports.PluginTypes) diff --git a/packages/cli/src/plugins/index.js b/packages/cli/src/plugins/index.js index c0d4fa2cfe..6ec99ac7fa 100644 --- a/packages/cli/src/plugins/index.js +++ b/packages/cli/src/plugins/index.js @@ -3,21 +3,28 @@ const { CommandWords } = require("../constants") const { getSkeleton, fleshOutSkeleton } = require("./skeleton") const questions = require("../questions") const fs = require("fs") - -const PLUGIN_TYPES = ["component", "datasource"] +const { PLUGIN_TYPES_ARR } = require("./constants") +const { validate } = require("./validate") +const { runPkgCommand } = require("../exec") +const { join } = require("path") +const { success, error, info } = require("../utils") async function init(opts) { const type = opts["init"] || opts - if (!type || !PLUGIN_TYPES.includes(type)) { - console.error( - "Please provide a type to init, either 'component' or 'datasource'." + if (!type || !PLUGIN_TYPES_ARR.includes(type)) { + console.log( + error( + "Please provide a type to init, either 'component' or 'datasource'." + ) ) return } - console.log("Lets get some details about your new plugin:") + console.log(info("Lets get some details about your new plugin:")) const name = await questions.string("Name", `budibase-${type}`) if (fs.existsSync(name)) { - console.error("Directory by plugin name already exists, pick a new name.") + console.log( + error("Directory by plugin name already exists, pick a new name.") + ) return } const desc = await questions.string( @@ -28,10 +35,39 @@ async function init(opts) { // get the skeleton await getSkeleton(type, name) await fleshOutSkeleton(name, desc, version) - console.log(`Plugin created in directory "${name}"`) + console.log(info(`Plugin created in directory "${name}"`)) } -async function build() {} +async function build() { + console.log(info("Verifying plugin...")) + const schema = fs.readFileSync("schema.json", "utf8") + const pkg = fs.readFileSync("package.json", "utf8") + let name, version + try { + const schemaJson = JSON.parse(schema) + const pkgJson = JSON.parse(pkg) + if (!pkgJson.name || !pkgJson.version || !pkgJson.description) { + throw new Error( + "package.json is missing one of 'name', 'version' or 'description'." + ) + } + name = pkgJson.name + version = pkgJson.version + validate(schemaJson) + } catch (err) { + if (err && err.message && err.message.includes("not valid JSON")) { + console.log(error(`schema.json is not valid JSON: ${err.message}`)) + } else { + console.log(error(`Invalid schema/package.json: ${err.message}`)) + } + return + } + console.log(success("Verified!")) + console.log(info("Building plugin...")) + await runPkgCommand("build") + const output = join("dist", `${name}-${version}.tar.gz`) + console.log(success(`Build complete - output in: ${output}`)) +} const command = new Command(`${CommandWords.PLUGIN}`) .addHelp( diff --git a/packages/cli/src/plugins/validate.js b/packages/cli/src/plugins/validate.js new file mode 100644 index 0000000000..b460670c7f --- /dev/null +++ b/packages/cli/src/plugins/validate.js @@ -0,0 +1,87 @@ +const { PluginTypes } = require("./constants") +const { DatasourceFieldTypes, QueryTypes } = require("@budibase/types") +const joi = require("joi") + +const DATASOURCE_TYPES = [ + "Relational", + "Non-relational", + "Spreadsheet", + "Object store", + "Graph", + "API", +] + +function runJoi(validator, schema) { + const { error } = validator.validate(schema) + if (error) { + throw error + } +} + +function validateComponent(schema) { + const validator = joi.object({ + type: joi.string().allow("component").required(), + metadata: joi.object().unknown(true).required(), + schema: joi + .object({ + name: joi.string().required(), + settings: joi.array().items(joi.object().unknown(true)).required(), + }) + .unknown(true), + }) + runJoi(validator, schema) +} + +function validateDatasource(schema) { + const fieldValidator = joi.object({ + type: joi + .string() + .allow(...Object.values(DatasourceFieldTypes)) + .required(), + required: joi.boolean().required(), + default: joi.any(), + display: joi.string(), + }) + + const queryValidator = joi + .object({ + type: joi.string().allow(...Object.values(QueryTypes)), + fields: joi.object().pattern(joi.string(), fieldValidator), + }) + .required() + + const validator = joi.object({ + type: joi.string().allow("datasource").required(), + metadata: joi.object().unknown(true).required(), + schema: joi.object({ + docs: joi.string(), + friendlyName: joi.string().required(), + type: joi.string().allow(...DATASOURCE_TYPES), + description: joi.string().required(), + datasource: joi.object().pattern(joi.string(), fieldValidator).required(), + query: joi + .object({ + create: queryValidator, + read: queryValidator, + update: queryValidator, + delete: queryValidator, + }) + .unknown(true) + .required(), + }), + }) + runJoi(validator, schema) +} + +exports.validate = schema => { + switch (schema.type) { + case PluginTypes.COMPONENT: + validateComponent(schema) + break + case PluginTypes.DATASOURCE: + validateDatasource(schema) + break + default: + throw new Error(`Unknown plugin type - check schema.json: ${schema.type}`) + } +} diff --git a/packages/cli/yarn.lock b/packages/cli/yarn.lock index 95813f60cf..c17b48e8bb 100644 --- a/packages/cli/yarn.lock +++ b/packages/cli/yarn.lock @@ -118,6 +118,11 @@ resolved "https://registry.yarnpkg.com/@budibase/types/-/types-1.1.32-alpha.6.tgz#95d8d73c7ed6ebc22ff26a44365127a478e19409" integrity sha512-AKKxrzVqGtcSzZZ2fP6i2Vgv6ICN9NEEE1dmzRk9AImZS+XKQ9VgVpdE+4gHgFK7L0gBYAsiaoEpCbbrI/+NoQ== +"@budibase/types@^1.2.31": + version "1.2.31" + resolved "https://registry.yarnpkg.com/@budibase/types/-/types-1.2.31.tgz#4715bca331ecd5eac23f95bfdee2eb147ef57814" + integrity sha512-/R03MleZRMtf6JW/nCKBqd/bBIkbFnwr8EV1Y3t6EySh8fnhM2PdhlWlpf/BrE0zMoiuBn4JMFl2vJ2Mzo/aoA== + "@eslint/eslintrc@^0.4.3": version "0.4.3" resolved "https://registry.yarnpkg.com/@eslint/eslintrc/-/eslintrc-0.4.3.tgz#9e42981ef035beb3dd49add17acb96e8ff6f394c" @@ -133,6 +138,18 @@ minimatch "^3.0.4" strip-json-comments "^3.1.1" +"@hapi/hoek@^9.0.0": + version "9.3.0" + resolved "https://registry.yarnpkg.com/@hapi/hoek/-/hoek-9.3.0.tgz#8368869dcb735be2e7f5cb7647de78e167a251fb" + integrity sha512-/c6rf4UJlmHlC9b5BaNvzAcFv7HZ2QHaV0D4/HNlBdvFnvQq8RI4kYdhyPCl7Xj+oWvTWQ8ujhqS53LIgAe6KQ== + +"@hapi/topo@^5.0.0": + version "5.1.0" + resolved "https://registry.yarnpkg.com/@hapi/topo/-/topo-5.1.0.tgz#dc448e332c6c6e37a4dc02fd84ba8d44b9afb012" + integrity sha512-foQZKJig7Ob0BMAYBfcJk8d77QtOe7Wo4ox7ff1lQYoNNAb6jwcY1ncdoy2e9wQZzvNy7ODZCYJkK8kzmcAnAg== + dependencies: + "@hapi/hoek" "^9.0.0" + "@humanwhocodes/config-array@^0.5.0": version "0.5.0" resolved "https://registry.yarnpkg.com/@humanwhocodes/config-array/-/config-array-0.5.0.tgz#1407967d4c6eecd7388f83acf1eaf4d0c6e58ef9" @@ -183,6 +200,23 @@ "@nodelib/fs.scandir" "2.1.5" fastq "^1.6.0" +"@sideway/address@^4.1.3": + version "4.1.4" + resolved "https://registry.yarnpkg.com/@sideway/address/-/address-4.1.4.tgz#03dccebc6ea47fdc226f7d3d1ad512955d4783f0" + integrity sha512-7vwq+rOHVWjyXxVlR76Agnvhy8I9rpzjosTESvmhNeXOXdZZB15Fl+TI9x1SiHZH5Jv2wTGduSxFDIaq0m3DUw== + dependencies: + "@hapi/hoek" "^9.0.0" + +"@sideway/formula@^3.0.0": + version "3.0.0" + resolved "https://registry.yarnpkg.com/@sideway/formula/-/formula-3.0.0.tgz#fe158aee32e6bd5de85044be615bc08478a0a13c" + integrity sha512-vHe7wZ4NOXVfkoRb8T5otiENVlT7a3IAiw7H5M2+GO+9CDgcVUUsX1zalAztCmwyOr2RUTGJdgB+ZvSVqmdHmg== + +"@sideway/pinpoint@^2.0.0": + version "2.0.0" + resolved "https://registry.yarnpkg.com/@sideway/pinpoint/-/pinpoint-2.0.0.tgz#cff8ffadc372ad29fd3f78277aeb29e632cc70df" + integrity sha512-RNiOoTPkptFtSVzQevY/yWtZwf/RxyVnPy/OcA9HBM3MlGDnBEYL5B41H0MTn0Uec8Hi+2qUtTfG2WWZBmMejQ== + "@sindresorhus/is@^0.7.0": version "0.7.0" resolved "https://registry.yarnpkg.com/@sindresorhus/is/-/is-0.7.0.tgz#9a06f4f137ee84d7df0460c1fdb1135ffa6c50fd" @@ -2455,6 +2489,17 @@ jmespath@0.15.0: resolved "https://registry.yarnpkg.com/jmespath/-/jmespath-0.15.0.tgz#a3f222a9aae9f966f5d27c796510e28091764217" integrity sha512-+kHj8HXArPfpPEKGLZ+kB5ONRTCiGQXo8RQYL0hH8t6pWXUBBK5KkkQmTNOwKK4LEsd0yTsgtjJVm4UBSZea4w== +joi@^17.6.0: + version "17.6.0" + resolved "https://registry.yarnpkg.com/joi/-/joi-17.6.0.tgz#0bb54f2f006c09a96e75ce687957bd04290054b2" + integrity sha512-OX5dG6DTbcr/kbMFj0KGYxuew69HPcAE3K/sZpEV2nP6e/j/C0HV+HNiBPCASxdx5T7DMoa0s8UeHWMnb6n2zw== + dependencies: + "@hapi/hoek" "^9.0.0" + "@hapi/topo" "^5.0.0" + "@sideway/address" "^4.1.3" + "@sideway/formula" "^3.0.0" + "@sideway/pinpoint" "^2.0.0" + join-component@^1.1.0: version "1.1.0" resolved "https://registry.yarnpkg.com/join-component/-/join-component-1.1.0.tgz#b8417b750661a392bee2c2537c68b2a9d4977cd5" diff --git a/packages/server/src/definitions/datasource.ts b/packages/server/src/definitions/datasource.ts index 9752fc947a..604dae50c3 100644 --- a/packages/server/src/definitions/datasource.ts +++ b/packages/server/src/definitions/datasource.ts @@ -1,73 +1,21 @@ import { Row, Table, Base } from "./common" +import { + Operation, + QueryTypes, + SortDirection, + SourceNames, +} from "@budibase/types" -export enum Operation { - CREATE = "CREATE", - READ = "READ", - UPDATE = "UPDATE", - DELETE = "DELETE", - BULK_CREATE = "BULK_CREATE", - CREATE_TABLE = "CREATE_TABLE", - UPDATE_TABLE = "UPDATE_TABLE", - DELETE_TABLE = "DELETE_TABLE", -} - -export enum SortDirection { - ASCENDING = "ASCENDING", - DESCENDING = "DESCENDING", -} - -export enum QueryTypes { - SQL = "sql", - JSON = "json", - FIELDS = "fields", -} - -export enum DatasourceFieldTypes { - STRING = "string", - LONGFORM = "longForm", - BOOLEAN = "boolean", - NUMBER = "number", - PASSWORD = "password", - LIST = "list", - OBJECT = "object", - JSON = "json", - FILE = "file", -} - -export enum SourceNames { - POSTGRES = "POSTGRES", - DYNAMODB = "DYNAMODB", - MONGODB = "MONGODB", - ELASTICSEARCH = "ELASTICSEARCH", - COUCHDB = "COUCHDB", - SQL_SERVER = "SQL_SERVER", - S3 = "S3", - AIRTABLE = "AIRTABLE", - MYSQL = "MYSQL", - ARANGODB = "ARANGODB", - REST = "REST", - ORACLE = "ORACLE", - GOOGLE_SHEETS = "GOOGLE_SHEETS", - FIRESTORE = "FIRESTORE", - REDIS = "REDIS", - SNOWFLAKE = "SNOWFLAKE", -} - -export enum IncludeRelationships { - INCLUDE = 1, - EXCLUDE = 0, -} - -export enum FilterTypes { - STRING = "string", - FUZZY = "fuzzy", - RANGE = "range", - EQUAL = "equal", - NOT_EQUAL = "notEqual", - EMPTY = "empty", - NOT_EMPTY = "notEmpty", - ONE_OF = "oneOf", -} +// these were previously exported here - moved to types for re-use +export { + Operation, + SortDirection, + QueryTypes, + DatasourceFieldTypes, + SourceNames, + IncludeRelationships, + FilterTypes, +} from "@budibase/types" export interface QueryDefinition { type: QueryTypes diff --git a/packages/types/src/documents/app/datasource.ts b/packages/types/src/documents/app/datasource.ts index 3a8704a0a9..6a5dd054da 100644 --- a/packages/types/src/documents/app/datasource.ts +++ b/packages/types/src/documents/app/datasource.ts @@ -1,5 +1,74 @@ import { Document } from "../document" +export enum Operation { + CREATE = "CREATE", + READ = "READ", + UPDATE = "UPDATE", + DELETE = "DELETE", + BULK_CREATE = "BULK_CREATE", + CREATE_TABLE = "CREATE_TABLE", + UPDATE_TABLE = "UPDATE_TABLE", + DELETE_TABLE = "DELETE_TABLE", +} + +export enum SortDirection { + ASCENDING = "ASCENDING", + DESCENDING = "DESCENDING", +} + +export enum QueryTypes { + SQL = "sql", + JSON = "json", + FIELDS = "fields", +} + +export enum DatasourceFieldTypes { + STRING = "string", + LONGFORM = "longForm", + BOOLEAN = "boolean", + NUMBER = "number", + PASSWORD = "password", + LIST = "list", + OBJECT = "object", + JSON = "json", + FILE = "file", +} + +export enum SourceNames { + POSTGRES = "POSTGRES", + DYNAMODB = "DYNAMODB", + MONGODB = "MONGODB", + ELASTICSEARCH = "ELASTICSEARCH", + COUCHDB = "COUCHDB", + SQL_SERVER = "SQL_SERVER", + S3 = "S3", + AIRTABLE = "AIRTABLE", + MYSQL = "MYSQL", + ARANGODB = "ARANGODB", + REST = "REST", + ORACLE = "ORACLE", + GOOGLE_SHEETS = "GOOGLE_SHEETS", + FIRESTORE = "FIRESTORE", + REDIS = "REDIS", + SNOWFLAKE = "SNOWFLAKE", +} + +export enum IncludeRelationships { + INCLUDE = 1, + EXCLUDE = 0, +} + +export enum FilterTypes { + STRING = "string", + FUZZY = "fuzzy", + RANGE = "range", + EQUAL = "equal", + NOT_EQUAL = "notEqual", + EMPTY = "empty", + NOT_EMPTY = "notEmpty", + ONE_OF = "oneOf", +} + export interface Datasource extends Document { source: string } From 737d5e1ef335c7adadc54e5ac88afe9b431f9842 Mon Sep 17 00:00:00 2001 From: Andrew Kingston Date: Wed, 10 Aug 2022 16:54:13 +0100 Subject: [PATCH 006/203] Add full PoC of using a custom component inside the builder, with children and bindings --- .../src/builderStore/store/frontend.js | 33 +++++++++++++++++-- .../[screenId]/_components/iframeTemplate.js | 3 ++ .../new/_components/NewComponentPanel.svelte | 21 ++++++++++-- 3 files changed, 51 insertions(+), 6 deletions(-) diff --git a/packages/builder/src/builderStore/store/frontend.js b/packages/builder/src/builderStore/store/frontend.js index 58d803aa03..7903210f53 100644 --- a/packages/builder/src/builderStore/store/frontend.js +++ b/packages/builder/src/builderStore/store/frontend.js @@ -92,11 +92,41 @@ export const getFrontendStore = () => { // Allow errors to propagate. let components = await API.fetchComponentLibDefinitions(application.appId) + // Extend definitions with custom components + components["test"] = { + component: "test", + name: "Super cool component", + icon: "Text", + description: "A custom component", + showSettingsBar: false, + hasChildren: true, + settings: [ + { + type: "text", + key: "text", + label: "Text", + }, + ], + context: { + type: "static", + values: [ + { + label: "Text prop", + key: "text", + }, + ], + }, + } + + // Filter out custom component keys so we can flag them + let customComponents = ["test"] + // Reset store state store.update(state => ({ ...state, libraries: application.componentLibraries, components, + customComponents, clientFeatures: { ...INITIAL_FRONTEND_STATE.clientFeatures, ...components.features, @@ -397,9 +427,6 @@ export const getFrontendStore = () => { if (!componentName) { return null } - if (!componentName.startsWith("@budibase")) { - componentName = `@budibase/standard-components/${componentName}` - } return get(store).components[componentName] }, createInstance: (componentName, presetProps) => { diff --git a/packages/builder/src/pages/builder/app/[application]/design/[screenId]/_components/iframeTemplate.js b/packages/builder/src/pages/builder/app/[application]/design/[screenId]/_components/iframeTemplate.js index 1c789d858e..64a05c7246 100644 --- a/packages/builder/src/pages/builder/app/[application]/design/[screenId]/_components/iframeTemplate.js +++ b/packages/builder/src/pages/builder/app/[application]/design/[screenId]/_components/iframeTemplate.js @@ -37,6 +37,9 @@ export default ` } + - + {{ PLUGINS }} @@ -85,9 +86,13 @@ - + {#if usedPlugins?.length} + {#each usedPlugins as plugin} + + {/each} + {/if} - {{ PLUGINS }} {#if $auth.isAdmin} @@ -106,6 +112,7 @@ } }} /> +
diff --git a/packages/client/src/components/ClientApp.svelte b/packages/client/src/components/ClientApp.svelte index 64b1712b89..86fd56feb1 100644 --- a/packages/client/src/components/ClientApp.svelte +++ b/packages/client/src/components/ClientApp.svelte @@ -87,6 +87,14 @@ }) + + {#if $builderStore.usedPlugins?.length} + {#each $builderStore.usedPlugins as plugin} + + {/each} + {/if} + + {#if dataLoaded}
{ + const initialise = (instance, force = false) => { if (instance == null) { return } // Ensure we're processing a new instance const instanceKey = Helpers.hashString(JSON.stringify(instance)) - if (instanceKey === lastInstanceKey) { + if (instanceKey === lastInstanceKey && !force) { return } else { lastInstanceKey = instanceKey @@ -407,9 +407,11 @@ !componentStore.actions.isComponentRegistered(id) ) { componentStore.actions.registerInstance(id, { + component: instance._component, getSettings: () => cachedSettings, getRawSettings: () => ({ ...staticSettings, ...dynamicSettings }), getDataContext: () => get(context), + reload: () => initialise(instance, true), }) } }) diff --git a/packages/client/src/components/devtools/DevToolsStatsTab.svelte b/packages/client/src/components/devtools/DevToolsStatsTab.svelte index b20b9fafa0..24f587332c 100644 --- a/packages/client/src/components/devtools/DevToolsStatsTab.svelte +++ b/packages/client/src/components/devtools/DevToolsStatsTab.svelte @@ -19,7 +19,10 @@ label="Active screen" value={$screenStore.activeScreen?.routing.route} /> - + diff --git a/packages/client/src/index.js b/packages/client/src/index.js index 32b242bc69..bef3ab9c12 100644 --- a/packages/client/src/index.js +++ b/packages/client/src/index.js @@ -27,6 +27,7 @@ const loadBudibase = () => { previewDevice: window["##BUDIBASE_PREVIEW_DEVICE##"], navigation: window["##BUDIBASE_PREVIEW_NAVIGATION##"], hiddenComponentIds: window["##BUDIBASE_HIDDEN_COMPONENT_IDS##"], + usedPlugins: window["##BUDIBASE_USED_PLUGINS##"], }) // Set app ID - this window flag is set by both the preview and the real @@ -39,6 +40,11 @@ const loadBudibase = () => { devToolsStore.actions.setEnabled(enableDevTools) // Register any custom components + window.registerCustomComponent = plugin => { + componentStore.actions.registerCustomComponent(plugin) + console.log("registered!") + loadBudibase() + } if (window["##BUDIBASE_CUSTOM_COMPONENTS##"]) { window["##BUDIBASE_CUSTOM_COMPONENTS##"].forEach(component => { componentStore.actions.registerCustomComponent(component) diff --git a/packages/client/src/stores/components.js b/packages/client/src/stores/components.js index a07c9da996..94dd16a957 100644 --- a/packages/client/src/stores/components.js +++ b/packages/client/src/stores/components.js @@ -10,7 +10,11 @@ import * as AppComponents from "../components/app/index.js" const budibasePrefix = "@budibase/standard-components/" const createComponentStore = () => { - const store = writable({}) + const store = writable({ + customComponentManifest: {}, + componentsAwaitingConstructors: {}, + mountedComponents: {}, + }) const derivedStore = derived( [store, builderStore, devToolsStore, screenStore], @@ -29,9 +33,7 @@ const createComponentStore = () => { asset = $screenState.activeScreen } const component = findComponentById(asset?.props, selectedComponentId) - const prefix = "@budibase/standard-components/" - const type = component?._component?.replace(prefix, "") - const definition = type ? Manifest[type] : null + const definition = getComponentDefinition(component?._component) // Derive the selected component path const path = @@ -39,32 +41,50 @@ const createComponentStore = () => { return { customComponentManifest: $store.customComponentManifest, - selectedComponentInstance: $store[selectedComponentId], + selectedComponentInstance: + $store.mountedComponents[selectedComponentId], selectedComponent: component, selectedComponentDefinition: definition, selectedComponentPath: path?.map(component => component._id), - mountedComponents: Object.keys($store).length, + mountedComponentCount: Object.keys($store.mountedComponents).length, currentAsset: asset, } } ) const registerInstance = (id, instance) => { - store.update(state => ({ - ...state, - [id]: instance, - })) + store.update(state => { + // If this is a custom component and does not have an implementation yet, + // store so we can reload this component later + const component = instance.component + let cac = state.componentsAwaitingConstructors + if (!getComponentConstructor(component)) { + if (!cac[component]) { + cac[component] = [] + } + cac[component].push(id) + } + + return { + ...state, + componentsAwaitingConstructors: cac, + mountedComponents: { + ...state.mountedComponents, + [id]: instance, + }, + } + }) } const unregisterInstance = id => { store.update(state => { - delete state[id] + delete state.mountedComponents[id] return state }) } const isComponentRegistered = id => { - return get(store)[id] != null + return get(store).mountedComponents[id] != null } const getComponentById = id => { @@ -117,17 +137,32 @@ const createComponentStore = () => { if (!Component || !schema?.schema?.name) { return } + const componentName = `plugin/${schema.schema.name}/1.0.0` store.update(state => { if (!state.customComponentManifest) { state.customComponentManifest = {} } - const componentName = `plugin/${schema.schema.name}/1.0.0` state.customComponentManifest[componentName] = { schema, Component, } return state }) + + // Reload any mounted components which depend on this definition + const state = get(store) + if (state.componentsAwaitingConstructors[componentName]?.length) { + state.componentsAwaitingConstructors[componentName].forEach(id => { + const instance = state.mountedComponents[id] + if (instance) { + instance.reload() + } + }) + store.update(state => { + delete state.componentsAwaitingConstructors[componentName] + return state + }) + } } return { From 22ce84f3848ca17fe83d5eecf5a835286eb96979 Mon Sep 17 00:00:00 2001 From: mike12345567 Date: Thu, 11 Aug 2022 17:29:07 +0100 Subject: [PATCH 023/203] Getting dependency installation working correctly. --- .gitignore | 4 +++- packages/cli/src/exec.js | 9 +++++---- packages/cli/src/plugins/index.js | 2 +- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/.gitignore b/.gitignore index f063e2224f..32c6faf980 100644 --- a/.gitignore +++ b/.gitignore @@ -102,4 +102,6 @@ packages/builder/cypress/reports stats.html # TypeScript cache -*.tsbuildinfo \ No newline at end of file +*.tsbuildinfo +budibase-component +budibase-datasource diff --git a/packages/cli/src/exec.js b/packages/cli/src/exec.js index 8b1134c897..72fd8e00eb 100644 --- a/packages/cli/src/exec.js +++ b/packages/cli/src/exec.js @@ -1,8 +1,8 @@ const util = require("util") const exec = util.promisify(require("child_process").exec) -exports.exec = async command => { - const { stdout } = await exec(command) +exports.exec = async (command, dir = "./") => { + const { stdout } = await exec(command, { cwd: dir }) return stdout } @@ -15,12 +15,13 @@ exports.utilityInstalled = async utilName => { } } -exports.runPkgCommand = async command => { +exports.runPkgCommand = async (command, dir = "./") => { const yarn = await exports.utilityInstalled("yarn") const npm = await exports.utilityInstalled("npm") if (!yarn && !npm) { throw new Error("Must have yarn or npm installed to run build.") } const npmCmd = command === "install" ? `npm ${command}` : `npm run ${command}` - await exports.exec(yarn ? `yarn ${command}` : npmCmd) + const cmd = yarn ? `yarn ${command}` : npmCmd + await exports.exec(cmd, dir) } diff --git a/packages/cli/src/plugins/index.js b/packages/cli/src/plugins/index.js index 6ce2d47e63..e6de624b63 100644 --- a/packages/cli/src/plugins/index.js +++ b/packages/cli/src/plugins/index.js @@ -37,7 +37,7 @@ async function init(opts) { await getSkeleton(type, name) await fleshOutSkeleton(name, desc, version) console.log(info("Installing dependencies...")) - await runPkgCommand("install") + await runPkgCommand("install", join(process.cwd(), name)) console.log(info(`Plugin created in directory "${name}"`)) } From d9a860499478e6d38035df32977b5db02770d028 Mon Sep 17 00:00:00 2001 From: mike12345567 Date: Thu, 11 Aug 2022 18:29:49 +0100 Subject: [PATCH 024/203] Fixing validation for datasource plugins. --- packages/cli/package.json | 6 +++--- packages/cli/src/plugins/validate.js | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/packages/cli/package.json b/packages/cli/package.json index 4f1cc8d4cd..7ea6111662 100644 --- a/packages/cli/package.json +++ b/packages/cli/package.json @@ -26,9 +26,9 @@ "outputPath": "build" }, "dependencies": { - "@budibase/backend-core": "1.2.28-alpha.0", - "@budibase/string-templates": "1.2.28-alpha.0", - "@budibase/types": "1.2.28-alpha.0", + "@budibase/backend-core": "^1.2.38", + "@budibase/string-templates": "^1.2.38", + "@budibase/types": "^1.2.38", "axios": "0.21.2", "chalk": "4.1.0", "cli-progress": "3.11.2", diff --git a/packages/cli/src/plugins/validate.js b/packages/cli/src/plugins/validate.js index b460670c7f..4c2fa6ba53 100644 --- a/packages/cli/src/plugins/validate.js +++ b/packages/cli/src/plugins/validate.js @@ -1,5 +1,5 @@ const { PluginTypes } = require("./constants") -const { DatasourceFieldTypes, QueryTypes } = require("@budibase/types") +const { DatasourceFieldType, QueryType } = require("@budibase/types") const joi = require("joi") const DATASOURCE_TYPES = [ @@ -36,7 +36,7 @@ function validateDatasource(schema) { const fieldValidator = joi.object({ type: joi .string() - .allow(...Object.values(DatasourceFieldTypes)) + .allow(...Object.values(DatasourceFieldType)) .required(), required: joi.boolean().required(), default: joi.any(), @@ -45,7 +45,7 @@ function validateDatasource(schema) { const queryValidator = joi .object({ - type: joi.string().allow(...Object.values(QueryTypes)), + type: joi.string().allow(...Object.values(QueryType)), fields: joi.object().pattern(joi.string(), fieldValidator), }) .required() From 67298ff44d7b0bedcfbb49c1b32e65712653dd60 Mon Sep 17 00:00:00 2001 From: mike12345567 Date: Fri, 12 Aug 2022 13:18:21 +0100 Subject: [PATCH 025/203] Fixing types. --- packages/cli/yarn.lock | 29 +- packages/server/yarn.lock | 634 +----------------- .../types/src/documents/app/datasource.ts | 69 -- packages/types/src/index.ts | 2 - 4 files changed, 38 insertions(+), 696 deletions(-) diff --git a/packages/cli/yarn.lock b/packages/cli/yarn.lock index 93157892dd..43c219fcd7 100644 --- a/packages/cli/yarn.lock +++ b/packages/cli/yarn.lock @@ -43,19 +43,18 @@ "@babel/helper-validator-identifier" "^7.16.7" to-fast-properties "^2.0.0" -"@budibase/backend-core@1.2.28-alpha.0": - version "1.2.28-alpha.0" - resolved "https://registry.yarnpkg.com/@budibase/backend-core/-/backend-core-1.2.28-alpha.0.tgz#f4253825724327e6552000f8c7575134bfaa05cd" - integrity sha512-ueu+NZgkiKrX49E0Zy2rrNE4NLe2HAyl3VolTrZfVxOzu1IvtQ/wJBcGDG84VvSliP+0bOOVO9TiGMY3bvZ/Hw== +"@budibase/backend-core@^1.2.38": + version "1.2.38" + resolved "https://registry.yarnpkg.com/@budibase/backend-core/-/backend-core-1.2.38.tgz#9451ae72f6af8cff3aa0a57dc61fc8d3505a77a0" + integrity sha512-g7m4fHG1tLqNsSvdSltqRHLASOH5n3QBbN5DD7cmSBIVpUtDCA0EMx/L0vkDDhTmbOQApXAW3cyJs6H3QiWtOw== dependencies: - "@budibase/types" "1.2.28-alpha.0" + "@budibase/types" "^1.2.38" "@techpass/passport-openidconnect" "0.3.2" aws-sdk "2.1030.0" bcrypt "5.0.1" dotenv "16.0.1" emitter-listener "1.1.2" ioredis "4.28.0" - joi "17.6.0" jsonwebtoken "8.5.1" koa-passport "4.1.4" lodash "4.17.21" @@ -102,10 +101,10 @@ to-gfm-code-block "^0.1.1" year "^0.2.1" -"@budibase/string-templates@1.2.28-alpha.0": - version "1.2.28-alpha.0" - resolved "https://registry.yarnpkg.com/@budibase/string-templates/-/string-templates-1.2.28-alpha.0.tgz#895571c142bcd68852f87e06a395232b3eb5516a" - integrity sha512-nXqa0IlSVW0og8NAJUW+ihUhdW8+rK0tskGWIwF+gEfAKd9NMyxoLswIAb7aYLmwdRRJFwhrpMEuF7ed8AojSQ== +"@budibase/string-templates@^1.2.38": + version "1.2.38" + resolved "https://registry.yarnpkg.com/@budibase/string-templates/-/string-templates-1.2.38.tgz#404804df516fb981b4f073f09bab64c9111cecb0" + integrity sha512-JRIAZVuuBECxDBcbx5FOYRRKi1ZyW7//LwKL5U1r9sIVCIxCW1t5b175oTnR9/bkktNs7X2ziynH/tsT5GVC0g== dependencies: "@budibase/handlebars-helpers" "^0.11.8" dayjs "^1.10.4" @@ -114,10 +113,10 @@ lodash "^4.17.20" vm2 "^3.9.4" -"@budibase/types@1.2.28-alpha.0": - version "1.2.28-alpha.0" - resolved "https://registry.yarnpkg.com/@budibase/types/-/types-1.2.28-alpha.0.tgz#61668b7d5d9b1f85c09d658deed87ec3dc28e290" - integrity sha512-tYhdUl1+dEtG8h2xoGUl0NXZC5BZYQIhgPK7JkYrqFHuNx+1f6EoHPQ9MMb/WyOxIDZv4gY7QJLg0KeVflofbw== +"@budibase/types@^1.2.38": + version "1.2.38" + resolved "https://registry.yarnpkg.com/@budibase/types/-/types-1.2.38.tgz#472f4ec891242488561a8cfc175961664bc7ac88" + integrity sha512-pMKh4FKhPoa1pge4FKqPi3gbzZp3HJ1RuhM5naKFqC1yompIn/Es+YNft39VC2bTW5tiGbucMcjWzdpMwTSTVw== "@eslint/eslintrc@^0.4.3": version "0.4.3" @@ -2485,7 +2484,7 @@ jmespath@0.15.0: resolved "https://registry.yarnpkg.com/jmespath/-/jmespath-0.15.0.tgz#a3f222a9aae9f966f5d27c796510e28091764217" integrity sha512-+kHj8HXArPfpPEKGLZ+kB5ONRTCiGQXo8RQYL0hH8t6pWXUBBK5KkkQmTNOwKK4LEsd0yTsgtjJVm4UBSZea4w== -joi@17.6.0, joi@^17.6.0: +joi@^17.6.0: version "17.6.0" resolved "https://registry.yarnpkg.com/joi/-/joi-17.6.0.tgz#0bb54f2f006c09a96e75ce687957bd04290054b2" integrity sha512-OX5dG6DTbcr/kbMFj0KGYxuew69HPcAE3K/sZpEV2nP6e/j/C0HV+HNiBPCASxdx5T7DMoa0s8UeHWMnb6n2zw== diff --git a/packages/server/yarn.lock b/packages/server/yarn.lock index 8545343645..a8dea20e95 100644 --- a/packages/server/yarn.lock +++ b/packages/server/yarn.lock @@ -1094,12 +1094,12 @@ resolved "https://registry.yarnpkg.com/@bcoe/v8-coverage/-/v8-coverage-0.2.3.tgz#75a2e8b51cb758a7553d6804a5932d7aace75c39" integrity sha512-0hYQ8SB4Db5zvZB4axdMHGwEaQjkZzFjQiN9LVYvIFB2nSUHW9tYpxWriPrWDASIxiaXax83REcLxuSdnGPZtw== -"@budibase/backend-core@1.2.28-alpha.0": - version "1.2.28-alpha.0" - resolved "https://registry.yarnpkg.com/@budibase/backend-core/-/backend-core-1.2.28-alpha.0.tgz#f4253825724327e6552000f8c7575134bfaa05cd" - integrity sha512-ueu+NZgkiKrX49E0Zy2rrNE4NLe2HAyl3VolTrZfVxOzu1IvtQ/wJBcGDG84VvSliP+0bOOVO9TiGMY3bvZ/Hw== +"@budibase/backend-core@1.2.39-alpha.0": + version "1.2.39-alpha.0" + resolved "https://registry.yarnpkg.com/@budibase/backend-core/-/backend-core-1.2.39-alpha.0.tgz#52a1d340d28fa714822827aeb843e1f097ad8f60" + integrity sha512-yHvWAUH1j8+UJx8hYl11iAGOpxmkxSbzf7qVCJ8a84Ms46Clmwp+qxtnDzKxMit2KJW72dJM9+PvI+OUG0Bixg== dependencies: - "@budibase/types" "1.2.28-alpha.0" + "@budibase/types" "1.2.39-alpha.0" "@techpass/passport-openidconnect" "0.3.2" aws-sdk "2.1030.0" bcrypt "5.0.1" @@ -1128,59 +1128,6 @@ uuid "8.3.2" zlib "1.0.5" -"@budibase/bbui@1.2.28-alpha.0": - version "1.2.28-alpha.0" - resolved "https://registry.yarnpkg.com/@budibase/bbui/-/bbui-1.2.28-alpha.0.tgz#579afbccb824a2ade16a6632d82615dfc90fcfc8" - integrity sha512-61xgvHMJM5xWSNo6mva2toywXLM7KuF8Ly4mOgH/coKsS5DQj6v+8NXXbRTVtVy7i6rbeFjCs2fzTeEC6bW/ig== - dependencies: - "@adobe/spectrum-css-workflow-icons" "^1.2.1" - "@budibase/string-templates" "1.2.28-alpha.0" - "@spectrum-css/actionbutton" "^1.0.1" - "@spectrum-css/actiongroup" "^1.0.1" - "@spectrum-css/avatar" "^3.0.2" - "@spectrum-css/button" "^3.0.1" - "@spectrum-css/buttongroup" "^3.0.2" - "@spectrum-css/checkbox" "^3.0.2" - "@spectrum-css/dialog" "^3.0.1" - "@spectrum-css/divider" "^1.0.3" - "@spectrum-css/dropzone" "^3.0.2" - "@spectrum-css/fieldgroup" "^3.0.2" - "@spectrum-css/fieldlabel" "^3.0.1" - "@spectrum-css/icon" "^3.0.1" - "@spectrum-css/illustratedmessage" "^3.0.2" - "@spectrum-css/inlinealert" "^2.0.1" - "@spectrum-css/inputgroup" "^3.0.2" - "@spectrum-css/label" "^2.0.10" - "@spectrum-css/link" "^3.1.1" - "@spectrum-css/menu" "^3.0.1" - "@spectrum-css/modal" "^3.0.1" - "@spectrum-css/pagination" "^3.0.3" - "@spectrum-css/picker" "^1.0.1" - "@spectrum-css/popover" "^3.0.1" - "@spectrum-css/progressbar" "^1.0.2" - "@spectrum-css/progresscircle" "^1.0.2" - "@spectrum-css/radio" "^3.0.2" - "@spectrum-css/search" "^3.0.2" - "@spectrum-css/sidenav" "^3.0.2" - "@spectrum-css/slider" "3.0.1" - "@spectrum-css/statuslight" "^3.0.2" - "@spectrum-css/stepper" "^3.0.3" - "@spectrum-css/switch" "^1.0.2" - "@spectrum-css/table" "^3.0.1" - "@spectrum-css/tabs" "^3.2.12" - "@spectrum-css/tags" "^3.0.2" - "@spectrum-css/textfield" "^3.0.1" - "@spectrum-css/toast" "^3.0.1" - "@spectrum-css/tooltip" "^3.0.3" - "@spectrum-css/treeview" "^3.0.2" - "@spectrum-css/typography" "^3.0.1" - "@spectrum-css/underlay" "^2.0.9" - "@spectrum-css/vars" "^3.0.1" - dayjs "^1.10.4" - easymde "^2.16.1" - svelte-flatpickr "^3.2.3" - svelte-portal "^1.0.0" - "@budibase/bbui@^0.9.139": version "0.9.190" resolved "https://registry.yarnpkg.com/@budibase/bbui/-/bbui-0.9.190.tgz#e1ec400ac90f556bfbc80fc23a04506f1585ea81" @@ -1231,77 +1178,13 @@ svelte-flatpickr "^3.2.3" svelte-portal "^1.0.0" -"@budibase/client@1.2.28-alpha.0": - version "1.2.28-alpha.0" - resolved "https://registry.yarnpkg.com/@budibase/client/-/client-1.2.28-alpha.0.tgz#5f166cfc619848d308f0f7ba90d291220bb38ed8" - integrity sha512-DjMIafaBeDmL/tOmTCFSNOowcP33E+a3e02g7Y1oDzRei9o7zpsxSLXEUVNvLl+XtvR9PNe4krXrsv4MDPoQ6Q== +"@budibase/pro@1.2.39-alpha.0": + version "1.2.39-alpha.0" + resolved "https://registry.yarnpkg.com/@budibase/pro/-/pro-1.2.39-alpha.0.tgz#272e3ffd5e2189c787df6b6fbe22b7084832ade7" + integrity sha512-B0XakaUHW2Y1RtkEcrPEBcp8CDFJ8/fC9agLI3WK0ARnTGx9ROd8Liokq3/pW3vmlOgsfijzNHL3LUYcPTMEXw== dependencies: - "@budibase/bbui" "1.2.28-alpha.0" - "@budibase/frontend-core" "1.2.28-alpha.0" - "@budibase/string-templates" "1.2.28-alpha.0" - "@spectrum-css/button" "^3.0.3" - "@spectrum-css/card" "^3.0.3" - "@spectrum-css/divider" "^1.0.3" - "@spectrum-css/link" "^3.1.3" - "@spectrum-css/page" "^3.0.1" - "@spectrum-css/tag" "^3.1.4" - "@spectrum-css/typography" "^3.0.2" - "@spectrum-css/vars" "^3.0.1" - apexcharts "^3.22.1" - dayjs "^1.10.5" - downloadjs "1.4.7" - leaflet "^1.7.1" - regexparam "^1.3.0" - rollup-plugin-polyfill-node "^0.8.0" - sanitize-html "^2.7.0" - screenfull "^6.0.1" - shortid "^2.2.15" - svelte "^3.49.0" - svelte-apexcharts "^1.0.2" - svelte-flatpickr "^3.1.0" - svelte-spa-router "^3.0.5" - -"@budibase/frontend-core@1.2.28-alpha.0": - version "1.2.28-alpha.0" - resolved "https://registry.yarnpkg.com/@budibase/frontend-core/-/frontend-core-1.2.28-alpha.0.tgz#dfe135acfce25fcdff4e4c7ed88c4d974c674858" - integrity sha512-uPZuVpJrJr9aX0QdrwkL+m78X46RUpcKg04KtcETvdvyUmPndz5Z7zr9j2Fo02Kt8c4lKRrpQgHL8gnDwwHSeg== - dependencies: - "@budibase/bbui" "1.2.28-alpha.0" - lodash "^4.17.21" - svelte "^3.46.2" - -"@budibase/handlebars-helpers@^0.11.8": - version "0.11.8" - resolved "https://registry.yarnpkg.com/@budibase/handlebars-helpers/-/handlebars-helpers-0.11.8.tgz#6953d29673a8c5c407e096c0a84890465c7ce841" - integrity sha512-ggWJUt0GqsHFAEup5tlWlcrmYML57nKhpNGGLzVsqXVYN8eVmf3xluYmmMe7fDYhQH0leSprrdEXmsdFQF3HAQ== - dependencies: - array-sort "^1.0.0" - define-property "^2.0.2" - extend-shallow "^3.0.2" - for-in "^1.0.2" - get-object "^0.2.0" - get-value "^3.0.1" - handlebars "^4.7.7" - handlebars-utils "^1.0.6" - has-value "^2.0.2" - helper-md "^0.2.2" - html-tag "^2.0.0" - is-even "^1.0.0" - is-glob "^4.0.1" - kind-of "^6.0.3" - micromatch "^3.1.5" - relative "^3.0.2" - striptags "^3.1.1" - to-gfm-code-block "^0.1.1" - year "^0.2.1" - -"@budibase/pro@1.2.28-alpha.0": - version "1.2.28-alpha.0" - resolved "https://registry.yarnpkg.com/@budibase/pro/-/pro-1.2.28-alpha.0.tgz#f372dcbac55634a1f0e7ff8125ffb0a0aeea086c" - integrity sha512-YxElWs5gwpe1JmHgpB52YeRkyeWPoBiUIt8EshyW90EFVUXP7FOy3LsjvKMNJXAZs1mI4ttkZfuWva8HjrGaKA== - dependencies: - "@budibase/backend-core" "1.2.28-alpha.0" - "@budibase/types" "1.2.28-alpha.0" + "@budibase/backend-core" "1.2.39-alpha.0" + "@budibase/types" "1.2.39-alpha.0" "@koa/router" "8.0.8" joi "17.6.0" node-fetch "^2.6.1" @@ -1324,22 +1207,10 @@ svelte-apexcharts "^1.0.2" svelte-flatpickr "^3.1.0" -"@budibase/string-templates@1.2.28-alpha.0": - version "1.2.28-alpha.0" - resolved "https://registry.yarnpkg.com/@budibase/string-templates/-/string-templates-1.2.28-alpha.0.tgz#895571c142bcd68852f87e06a395232b3eb5516a" - integrity sha512-nXqa0IlSVW0og8NAJUW+ihUhdW8+rK0tskGWIwF+gEfAKd9NMyxoLswIAb7aYLmwdRRJFwhrpMEuF7ed8AojSQ== - dependencies: - "@budibase/handlebars-helpers" "^0.11.8" - dayjs "^1.10.4" - handlebars "^4.7.6" - handlebars-utils "^1.0.6" - lodash "^4.17.20" - vm2 "^3.9.4" - -"@budibase/types@1.2.28-alpha.0": - version "1.2.28-alpha.0" - resolved "https://registry.yarnpkg.com/@budibase/types/-/types-1.2.28-alpha.0.tgz#61668b7d5d9b1f85c09d658deed87ec3dc28e290" - integrity sha512-tYhdUl1+dEtG8h2xoGUl0NXZC5BZYQIhgPK7JkYrqFHuNx+1f6EoHPQ9MMb/WyOxIDZv4gY7QJLg0KeVflofbw== +"@budibase/types@1.2.39-alpha.0": + version "1.2.39-alpha.0" + resolved "https://registry.yarnpkg.com/@budibase/types/-/types-1.2.39-alpha.0.tgz#d0d48e4da36a93a4a9354cc49663f38d0181b6c0" + integrity sha512-i+lQeqlKmFORLuKdwmKnlmCCCEXZH6NdXHrOqNcebJzcNlx3Gx342+cHe4ZGYu0L+wCkWWelD5XHFuNMVMcuHg== "@bull-board/api@3.7.0": version "3.7.0" @@ -2268,24 +2139,6 @@ resolved "https://registry.yarnpkg.com/@redis/time-series/-/time-series-1.0.3.tgz#4cfca8e564228c0bddcdf4418cba60c20b224ac4" integrity sha512-OFp0q4SGrTH0Mruf6oFsHGea58u8vS/iI5+NpYdicaM+7BgqBZH8FFvNZ8rYYLrUO/QRqMq72NpXmxLVNcdmjA== -"@rollup/plugin-inject@^4.0.0": - version "4.0.4" - resolved "https://registry.yarnpkg.com/@rollup/plugin-inject/-/plugin-inject-4.0.4.tgz#fbeee66e9a700782c4f65c8b0edbafe58678fbc2" - integrity sha512-4pbcU4J/nS+zuHk+c+OL3WtmEQhqxlZ9uqfjQMQDOHOPld7PsCd8k5LWs8h5wjwJN7MgnAn768F2sDxEP4eNFQ== - dependencies: - "@rollup/pluginutils" "^3.1.0" - estree-walker "^2.0.1" - magic-string "^0.25.7" - -"@rollup/pluginutils@^3.1.0": - version "3.1.0" - resolved "https://registry.yarnpkg.com/@rollup/pluginutils/-/pluginutils-3.1.0.tgz#706b4524ee6dc8b103b3c995533e5ad680c02b9b" - integrity sha512-GksZ6pr6TpIjHm8h9lSQ8pi8BE9VeubNT0OMJ3B5uZJ8pz73NPiqOtCog/x2/QzM1ENChPKxMDhiQuRHsqc+lg== - dependencies: - "@types/estree" "0.0.39" - estree-walker "^1.0.1" - picomatch "^2.2.2" - "@sendgrid/client@^7.1.1": version "7.7.0" resolved "https://registry.yarnpkg.com/@sendgrid/client/-/client-7.7.0.tgz#f8f67abd604205a0d0b1af091b61517ef465fdbf" @@ -2567,11 +2420,6 @@ resolved "https://registry.yarnpkg.com/@spectrum-css/sidenav/-/sidenav-3.0.23.tgz#c218560d472e13a3e0d1499b762df1206dcffbfd" integrity sha512-4IFw2/HMQJRzM0M2c5na/HeY7y5vJoGpMFBkXNpQyhW4TRo7N1rGwYQ5dRD3s4OVEWV4/rjfGV0d/qhfwKUTog== -"@spectrum-css/slider@3.0.1": - version "3.0.1" - resolved "https://registry.yarnpkg.com/@spectrum-css/slider/-/slider-3.0.1.tgz#5281e6f47eb5a4fd3d1816c138bf66d01d7f2e49" - integrity sha512-DI2dtMRnQuDM1miVzl3SGyR1khUEKnwdXfO5EHDFwkC3yav43F5QogkfjmjFmWWobMVovdJlAuiaaJ/IHejD0Q== - "@spectrum-css/statuslight@^3.0.2": version "3.0.8" resolved "https://registry.yarnpkg.com/@spectrum-css/statuslight/-/statuslight-3.0.8.tgz#3b0ea80712573679870a85d469850230e794a0f7" @@ -2597,16 +2445,6 @@ resolved "https://registry.yarnpkg.com/@spectrum-css/tabs/-/tabs-3.2.16.tgz#c3f7800d8d6f7c9930c28cd01354816328bf72b1" integrity sha512-JUcMB/fiDG/KoyrVstlUMacFJUY4OHKqhMRuPtu9ggUXWCRbSkY8he92v6u0HwY3DuhDoOxNTK8d/PLjk/fsbg== -"@spectrum-css/tabs@^3.2.12": - version "3.2.19" - resolved "https://registry.yarnpkg.com/@spectrum-css/tabs/-/tabs-3.2.19.tgz#2eae3a2c4760466882db08281365d502c3f22ebf" - integrity sha512-SNGFf/karBr/GNz5GNWnbppFz6uEOGecv6D8WA1ZLeWkjg4gG5e4M9XmPcB32v350e1PTRG7KwWDce48qWAKCQ== - -"@spectrum-css/tag@^3.1.4": - version "3.3.14" - resolved "https://registry.yarnpkg.com/@spectrum-css/tag/-/tag-3.3.14.tgz#2d1ca0759da6a3a2970d14bcabf33bd4a8f63a5f" - integrity sha512-S4RUaxN/83Pr/SYkQHeZNh2NXmtumUEzhrsrrliI6bAt3bjs+mLresTGd9qkIX2+Ycq1JHWTr0HTga4ti1YYyA== - "@spectrum-css/tags@^3.0.2": version "3.0.3" resolved "https://registry.yarnpkg.com/@spectrum-css/tags/-/tags-3.0.3.tgz#fc76d2735cdc442de91b7eb3bee49a928c0767ac" @@ -2784,13 +2622,6 @@ resolved "https://registry.yarnpkg.com/@types/caseless/-/caseless-0.12.2.tgz#f65d3d6389e01eeb458bd54dc8f52b95a9463bc8" integrity sha512-6ckxMjBBD8URvjB6J3NcnuAn5Pkl7t3TizAg+xdlzzQGSPSmBcXf8KoIH0ua/i+tio+ZRUHEXp0HEmvaR4kt0w== -"@types/codemirror@^5.60.4": - version "5.60.5" - resolved "https://registry.yarnpkg.com/@types/codemirror/-/codemirror-5.60.5.tgz#5b989a3b4bbe657458cf372c92b6bfda6061a2b7" - integrity sha512-TiECZmm8St5YxjFUp64LK0c8WU5bxMDt9YaAek1UqUb9swrSCoJhh92fWu1p3mTEqlHjhB5sY7OFBhWroJXZVg== - dependencies: - "@types/tern" "*" - "@types/connect@*": version "3.4.35" resolved "https://registry.yarnpkg.com/@types/connect/-/connect-3.4.35.tgz#5fcf6ae445e4021d1fc2219a4873cc73a3bb2ad1" @@ -2839,11 +2670,6 @@ resolved "https://registry.yarnpkg.com/@types/estree/-/estree-0.0.51.tgz#cfd70924a25a3fd32b218e5e420e6897e1ac4f40" integrity sha512-CuPgU6f3eT/XgKKPqKd/gLZV1Xmvf1a2R5POBOGQa6uv82xpls89HU5zKeVoyR8XzHd1RGNOlQlvUe3CFkjWNQ== -"@types/estree@0.0.39": - version "0.0.39" - resolved "https://registry.yarnpkg.com/@types/estree/-/estree-0.0.39.tgz#e177e699ee1b8c22d23174caaa7422644389509f" - integrity sha512-EYNwp3bU+98cpU4lAWYYL7Zz+2gryWH1qbdDTidVd6hkiR6weksdbMadyXKXNPEkQFhXM+hVO9ZygomHXp+AIw== - "@types/express-serve-static-core@^4.17.18": version "4.17.28" resolved "https://registry.yarnpkg.com/@types/express-serve-static-core/-/express-serve-static-core-4.17.28.tgz#c47def9f34ec81dc6328d0b1b5303d1ec98d86b8" @@ -2987,11 +2813,6 @@ resolved "https://registry.yarnpkg.com/@types/long/-/long-4.0.2.tgz#b74129719fc8d11c01868010082d483b7545591a" integrity sha512-MqTGEo5bj5t157U6fA/BiDynNkn0YknVdh48CMPkTSpFTVmvao5UQmm7uEF6xBEo7qIMAlY/JSleYaE6VOdpaA== -"@types/marked@^4.0.1": - version "4.0.3" - resolved "https://registry.yarnpkg.com/@types/marked/-/marked-4.0.3.tgz#2098f4a77adaba9ce881c9e0b6baf29116e5acc4" - integrity sha512-HnMWQkLJEf/PnxZIfbm0yGJRRZYYMhb++O9M36UCTA9z53uPvVoSlAwJr3XOpDEryb7Hwl1qAx/MV6YIW1RXxg== - "@types/mime@^1": version "1.3.2" resolved "https://registry.yarnpkg.com/@types/mime/-/mime-1.3.2.tgz#93e25bf9ee75fe0fd80b594bc4feb0e862111b5a" @@ -3127,13 +2948,6 @@ "@types/cookiejar" "*" "@types/node" "*" -"@types/tern@*": - version "0.23.4" - resolved "https://registry.yarnpkg.com/@types/tern/-/tern-0.23.4.tgz#03926eb13dbeaf3ae0d390caf706b2643a0127fb" - integrity sha512-JAUw1iXGO1qaWwEOzxTKJZ/5JxVeON9kvGZ/osgZaJImBnyjyn0cjovPsf6FNLmyGY8Vw9DoXZCMlfMkMwHRWg== - dependencies: - "@types/estree" "*" - "@types/tough-cookie@*": version "4.0.2" resolved "https://registry.yarnpkg.com/@types/tough-cookie/-/tough-cookie-4.0.2.tgz#6286b4c7228d58ab7866d19716f3696e03a09397" @@ -3718,7 +3532,7 @@ arg@^4.1.0: resolved "https://registry.yarnpkg.com/arg/-/arg-4.1.3.tgz#269fc7ad5b8e42cb63c896d5666017261c144089" integrity sha512-58S9QDqG0Xx27YwPSt9fJxivjYl432YCwfDMfZ+71RAqUrZef7LrKQZ3LHLOwCS4FLNBplP533Zx895SeOCHvA== -argparse@^1.0.10, argparse@^1.0.7: +argparse@^1.0.7: version "1.0.10" resolved "https://registry.yarnpkg.com/argparse/-/argparse-1.0.10.tgz#bcd6791ea5ae09725e17e5ad988134cd40b3d911" integrity sha512-o5Roy6tNG4SL/FOkCAN6RzjiakZS25RLYFrcMttJqbdd8BWrnA+fGz57iN5Pb06pvBGvl5gQ0B48dJlslXvoTg== @@ -3765,15 +3579,6 @@ array-equal@^1.0.0: resolved "https://registry.yarnpkg.com/array-equal/-/array-equal-1.0.0.tgz#8c2a5ef2472fd9ea742b04c77a75093ba2757c93" integrity sha512-H3LU5RLiSsGXPhN+Nipar0iR0IofH+8r89G2y1tBKxQ/agagKyAjhkAFDRBfodP2caPrNKHpAWNIM/c9yeL7uA== -array-sort@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/array-sort/-/array-sort-1.0.0.tgz#e4c05356453f56f53512a7d1d6123f2c54c0a88a" - integrity sha512-ihLeJkonmdiAsD7vpgN3CRcx2J2S0TiYW+IS/5zHBI7mKUq3ySvBdzzBfD236ubDBQFiiyG3SWCPc+msQ9KoYg== - dependencies: - default-compare "^1.0.0" - get-value "^2.0.6" - kind-of "^5.0.2" - array-union@^2.1.0: version "2.1.0" resolved "https://registry.yarnpkg.com/array-union/-/array-union-2.1.0.tgz#b798420adbeb1de828d84acd8a2e23d3efe85e8d" @@ -3905,13 +3710,6 @@ atomic-sleep@^1.0.0: resolved "https://registry.yarnpkg.com/atomic-sleep/-/atomic-sleep-1.0.0.tgz#eb85b77a601fc932cfe432c5acd364a9e2c9075b" integrity sha512-kNOjDqAh7px0XWNI+4QbzoiR/nTkHAWNud2uvnJquD1/x5a7EQZMJT0AczqK0Qn67oY/TTQ1LbUKajZpp3I9tQ== -autolinker@~0.28.0: - version "0.28.1" - resolved "https://registry.yarnpkg.com/autolinker/-/autolinker-0.28.1.tgz#0652b491881879f0775dace0cdca3233942a4e47" - integrity sha512-zQAFO1Dlsn69eXaO6+7YZc+v84aquQKbwpzCE3L0stj56ERn9hutFxPopViLjo9G+rWwjozRhgS5KJ25Xy19cQ== - dependencies: - gulp-header "^1.7.1" - available-typed-arrays@^1.0.5: version "1.0.5" resolved "https://registry.yarnpkg.com/available-typed-arrays/-/available-typed-arrays-1.0.5.tgz#92f95616501069d07d10edb2fc37d3e1c65123b7" @@ -4744,18 +4542,6 @@ co@^4.6.0: resolved "https://registry.yarnpkg.com/co/-/co-4.6.0.tgz#6ea6bdf3d853ae54ccb8e47bfa0bf3f9031fb184" integrity sha512-QVb0dM5HvG+uaxitm8wONl7jltx8dqhfU33DcqtOZcLSVIKSDDLDi7+0LbAKiyI8hD9u42m2YxXSkMGWThaecQ== -codemirror-spell-checker@1.1.2: - version "1.1.2" - resolved "https://registry.yarnpkg.com/codemirror-spell-checker/-/codemirror-spell-checker-1.1.2.tgz#1c660f9089483ccb5113b9ba9ca19c3f4993371e" - integrity sha512-2Tl6n0v+GJRsC9K3MLCdLaMOmvWL0uukajNJseorZJsslaxZyZMgENocPU8R0DyoTAiKsyqiemSOZo7kjGV0LQ== - dependencies: - typo-js "*" - -codemirror@^5.63.1: - version "5.65.7" - resolved "https://registry.yarnpkg.com/codemirror/-/codemirror-5.65.7.tgz#29af41ce5f4c2b8f1c1e16f4e645ff392823716a" - integrity sha512-zb67cXzgugIQmb6tfD4G11ILjYoMfTjwcjn+cWsa4GewlI2adhR/h3kolkoCQTm1msD/1BuqVTKuO09ELsS++A== - collect-v8-coverage@^1.0.0: version "1.0.1" resolved "https://registry.yarnpkg.com/collect-v8-coverage/-/collect-v8-coverage-1.0.1.tgz#cc2c8e94fc18bbdffe64d6534570c8a673b27f59" @@ -4906,13 +4692,6 @@ concat-map@0.0.1: resolved "https://registry.yarnpkg.com/concat-map/-/concat-map-0.0.1.tgz#d8a96bd77fd68df7793a73036a3ba0d5405d477b" integrity sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg== -concat-with-sourcemaps@*: - version "1.1.0" - resolved "https://registry.yarnpkg.com/concat-with-sourcemaps/-/concat-with-sourcemaps-1.1.0.tgz#d4ea93f05ae25790951b99e7b3b09e3908a4082e" - integrity sha512-4gEjHJFT9e+2W/77h/DS5SGUgwDaOwprX8L/gl5+3ixnzkVJJsZWDSelmN3Oilw3LNDZjZV0yqH1hLG3k6nghg== - dependencies: - source-map "^0.6.1" - condense-newlines@^0.2.1: version "0.2.1" resolved "https://registry.yarnpkg.com/condense-newlines/-/condense-newlines-0.2.1.tgz#3de985553139475d32502c83b02f60684d24c55f" @@ -5319,13 +5098,6 @@ deepmerge@^4.2.2: resolved "https://registry.yarnpkg.com/deepmerge/-/deepmerge-4.2.2.tgz#44d2ea3679b8f4d4ffba33f03d865fc1e7bf4955" integrity sha512-FJ3UgI4gIl+PHZm53knsuSFpE+nESMr7M4v9QcgB7S63Kj/6WqMiFQJpBBYz1Pt+66bZpP3Q7Lye0Oo9MPKEdg== -default-compare@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/default-compare/-/default-compare-1.0.0.tgz#cb61131844ad84d84788fb68fd01681ca7781a2f" - integrity sha512-QWfXlM0EkAbqOCbD/6HjdwT19j7WCkMyiRhWilc4H9/5h/RzTF9gv5LYh1+CmDV5d1rki6KAWLtQale0xt20eQ== - dependencies: - kind-of "^5.0.2" - default-shell@^1.0.0: version "1.0.1" resolved "https://registry.yarnpkg.com/default-shell/-/default-shell-1.0.1.tgz#752304bddc6174f49eb29cb988feea0b8813c8bc" @@ -5493,25 +5265,11 @@ doctrine@3.0.0, doctrine@^3.0.0: dependencies: esutils "^2.0.2" -dom-serializer@^1.0.1: - version "1.4.1" - resolved "https://registry.yarnpkg.com/dom-serializer/-/dom-serializer-1.4.1.tgz#de5d41b1aea290215dc45a6dae8adcf1d32e2d30" - integrity sha512-VHwB3KfrcOOkelEG2ZOfxqLZdfkil8PtJi4P8N2MMXucZq2yLp75ClViUlOVwyoHEDjYU433Aq+5zWP61+RGag== - dependencies: - domelementtype "^2.0.1" - domhandler "^4.2.0" - entities "^2.0.0" - dom-walk@^0.1.0: version "0.1.2" resolved "https://registry.yarnpkg.com/dom-walk/-/dom-walk-0.1.2.tgz#0c548bef048f4d1f2a97249002236060daa3fd84" integrity sha512-6QvTW9mrGeIegrFXdtQi9pk7O/nSK6lSdXW2eqUspN5LWD7UTji2Fqw5V2YLjBpHEoU9Xl/eUWNpDeZvoyOv2w== -domelementtype@^2.0.1, domelementtype@^2.2.0: - version "2.3.0" - resolved "https://registry.yarnpkg.com/domelementtype/-/domelementtype-2.3.0.tgz#5c45e8e869952626331d7aab326d01daf65d589d" - integrity sha512-OLETBj6w0OsagBwdXnPdN0cnMfF9opN69co+7ZrbfPGrdpPVNBUj02spi6B1N7wChLQiPn4CSH/zJvXw56gmHw== - domexception@^1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/domexception/-/domexception-1.0.1.tgz#937442644ca6a31261ef36e3ec677fe805582c90" @@ -5526,22 +5284,6 @@ domexception@^2.0.1: dependencies: webidl-conversions "^5.0.0" -domhandler@^4.0.0, domhandler@^4.2.0: - version "4.3.1" - resolved "https://registry.yarnpkg.com/domhandler/-/domhandler-4.3.1.tgz#8d792033416f59d68bc03a5aa7b018c1ca89279c" - integrity sha512-GrwoxYN+uWlzO8uhUXRl0P+kHE4GtVPfYzVLcUxPL7KNdHKj66vvlhiweIHqYYXWlw+T8iLMp42Lm67ghw4WMQ== - dependencies: - domelementtype "^2.2.0" - -domutils@^2.5.2: - version "2.8.0" - resolved "https://registry.yarnpkg.com/domutils/-/domutils-2.8.0.tgz#4437def5db6e2d1f5d6ee859bd95ca7d02048135" - integrity sha512-w96Cjofp72M5IIhpjgobBimYEfoPjx1Vx0BSX9P30WBdZW2WIKU0T1Bd0kz2eNZ9ikjKgHbEyKx8BB6H1L3h3A== - dependencies: - dom-serializer "^1.0.1" - domelementtype "^2.2.0" - domhandler "^4.2.0" - dot-prop@^5.2.0: version "5.3.0" resolved "https://registry.yarnpkg.com/dot-prop/-/dot-prop-5.3.0.tgz#90ccce708cd9cd82cc4dc8c3ddd9abdd55b20e88" @@ -5586,11 +5328,6 @@ download@8.0.0: p-event "^2.1.0" pify "^4.0.1" -downloadjs@1.4.7: - version "1.4.7" - resolved "https://registry.yarnpkg.com/downloadjs/-/downloadjs-1.4.7.tgz#f69f96f940e0d0553dac291139865a3cd0101e3c" - integrity sha512-LN1gO7+u9xjU5oEScGFKvXhYf7Y/empUIIEAGBs1LzUq/rg5duiDrkuH5A2lQGd5jfMOb9X9usDa2oVXwJ0U/Q== - duplexer3@^0.1.4: version "0.1.4" resolved "https://registry.yarnpkg.com/duplexer3/-/duplexer3-0.1.4.tgz#ee01dd1cac0ed3cbc7fdbea37dc0a8f1ce002ce2" @@ -5606,17 +5343,6 @@ duplexify@^4.0.0: readable-stream "^3.1.1" stream-shift "^1.0.0" -easymde@^2.16.1: - version "2.16.1" - resolved "https://registry.yarnpkg.com/easymde/-/easymde-2.16.1.tgz#f4c2380312615cb33826f1a1fecfaa4022ff551a" - integrity sha512-FihYgjRsKfhGNk89SHSqxKLC4aJ1kfybPWW6iAmtb5GnXu+tnFPSzSaGBmk1RRlCuhFSjhF0SnIMGVPjEzkr6g== - dependencies: - "@types/codemirror" "^5.60.4" - "@types/marked" "^4.0.1" - codemirror "^5.63.1" - codemirror-spell-checker "1.1.2" - marked "^4.0.10" - ecc-jsbn@~0.1.1: version "0.1.2" resolved "https://registry.yarnpkg.com/ecc-jsbn/-/ecc-jsbn-0.1.2.tgz#3a83a904e54353287874c564b7549386849a98c9" @@ -5728,16 +5454,6 @@ enhanced-resolve@^5.9.3: graceful-fs "^4.2.4" tapable "^2.2.0" -ent@^2.2.0: - version "2.2.0" - resolved "https://registry.yarnpkg.com/ent/-/ent-2.2.0.tgz#e964219325a21d05f44466a2f686ed6ce5f5dd1d" - integrity sha512-GHrMyVZQWvTIdDtpiEXdHZnFQKzeO09apj8Cbl4pKWy4i0Oprcq17usfDt5aO63swf0JOeMWjWQE/LzgSRuWpA== - -entities@^2.0.0: - version "2.2.0" - resolved "https://registry.yarnpkg.com/entities/-/entities-2.2.0.tgz#098dc90ebb83d8dffa089d55256b351d34c4da55" - integrity sha512-p92if5Nz619I0w+akJrLZH0MX0Pb5DX39XOwQTtXSdQQOaYH03S1uIQp4mhOZtAXrxq4ViO67YTiLBo2638o9A== - entities@~2.1.0: version "2.1.0" resolved "https://registry.yarnpkg.com/entities/-/entities-2.1.0.tgz#992d3129cf7df6870b96c57858c249a120f8b8b5" @@ -6171,16 +5887,6 @@ estraverse@^5.1.0, estraverse@^5.2.0: resolved "https://registry.yarnpkg.com/estraverse/-/estraverse-5.3.0.tgz#2eea5290702f26ab8fe5370370ff86c965d21123" integrity sha512-MMdARuVEQziNTeJD8DgMqmhwR11BRQ/cBP+pLtYdSTnf3MIO8fFeiINEbX36ZdNlfU/7A9f3gUw49B3oQsvwBA== -estree-walker@^1.0.1: - version "1.0.1" - resolved "https://registry.yarnpkg.com/estree-walker/-/estree-walker-1.0.1.tgz#31bc5d612c96b704106b477e6dd5d8aa138cb700" - integrity sha512-1fMXF3YP4pZZVozF8j/ZLfvnR8NSIljt56UhbZ5PeeDmmGHpgpdwQt7ITlGvYaQukCvuBRMLEiKiYC+oeIg4cg== - -estree-walker@^2.0.1: - version "2.0.2" - resolved "https://registry.yarnpkg.com/estree-walker/-/estree-walker-2.0.2.tgz#52f010178c2a4c117a7757cfe942adb7d2da4cac" - integrity sha512-Rfkk/Mp/DL7JVje3u18FxFujQlTNR2q6QfMSMB7AvCBx91NGj/ba3kCfza0f6dVDbw7YlRf/nDrn7pQrCCyQ/w== - esutils@^2.0.2: version "2.0.3" resolved "https://registry.yarnpkg.com/esutils/-/esutils-2.0.3.tgz#74d2eb4de0b8da1293711910d50775b9b710ef64" @@ -6730,11 +6436,6 @@ fs-constants@^1.0.0: resolved "https://registry.yarnpkg.com/fs-constants/-/fs-constants-1.0.0.tgz#6be0de9be998ce16af8afc24497b9ee9b7ccd9ad" integrity sha512-y6OAwoSIf7FyjMIv94u+b5rdheZEjzR63GTyZJm5qh4Bi+2YgwLCcI/fPFZkL5PSixOt6ZNKm+w+Hfp/Bciwow== -fs-exists-sync@^0.1.0: - version "0.1.0" - resolved "https://registry.yarnpkg.com/fs-exists-sync/-/fs-exists-sync-0.1.0.tgz#982d6893af918e72d08dec9e8673ff2b5a8d6add" - integrity sha512-cR/vflFyPZtrN6b38ZyWxpWdhlXrzZEBawlpBQMq7033xVY7/kg0GDMBK5jg8lDYQckdJ5x/YC88lM3C7VMsLg== - fs-extra@8.1.0: version "8.1.0" resolved "https://registry.yarnpkg.com/fs-extra/-/fs-extra-8.1.0.tgz#49d43c45a88cd9677668cb7be1b46efdb8d2e1c0" @@ -6883,14 +6584,6 @@ get-intrinsic@^1.0.2, get-intrinsic@^1.1.0, get-intrinsic@^1.1.1: has "^1.0.3" has-symbols "^1.0.3" -get-object@^0.2.0: - version "0.2.0" - resolved "https://registry.yarnpkg.com/get-object/-/get-object-0.2.0.tgz#d92ff7d5190c64530cda0543dac63a3d47fe8c0c" - integrity sha512-7P6y6k6EzEFmO/XyUyFlXm1YLJy9xeA1x/grNV8276abX5GuwUtYgKFkRFkLixw4hf4Pz9q2vgv/8Ar42R0HuQ== - dependencies: - is-number "^2.0.2" - isobject "^0.2.0" - get-package-type@^0.1.0: version "0.1.0" resolved "https://registry.yarnpkg.com/get-package-type/-/get-package-type-0.1.0.tgz#8de2d803cff44df3bc6c456e6668b36c3926e11a" @@ -6953,13 +6646,6 @@ get-value@^2.0.3, get-value@^2.0.6: resolved "https://registry.yarnpkg.com/get-value/-/get-value-2.0.6.tgz#dc15ca1c672387ca76bd37ac0a395ba2042a2c28" integrity sha512-Ln0UQDlxH1BapMu3GPtf7CuYNwRZf2gwCuPqbyG6pB8WfmFpzqcy4xtAaAMUhnNqjMKTiCPZG2oMT3YSx8U2NA== -get-value@^3.0.0, get-value@^3.0.1: - version "3.0.1" - resolved "https://registry.yarnpkg.com/get-value/-/get-value-3.0.1.tgz#5efd2a157f1d6a516d7524e124ac52d0a39ef5a8" - integrity sha512-mKZj9JLQrwMBtj5wxi6MH8Z5eSKaERpAwjg43dPtlGI1ZVEgH/qC7T8/6R2OBSUA+zzHBZgICsVJaEIV2tKTDA== - dependencies: - isobject "^3.0.1" - getopts@2.2.5: version "2.2.5" resolved "https://registry.yarnpkg.com/getopts/-/getopts-2.2.5.tgz#67a0fe471cacb9c687d817cab6450b96dde8313b" @@ -7265,24 +6951,7 @@ gtoken@^5.0.4: google-p12-pem "^3.1.3" jws "^4.0.0" -gulp-header@^1.7.1: - version "1.8.12" - resolved "https://registry.yarnpkg.com/gulp-header/-/gulp-header-1.8.12.tgz#ad306be0066599127281c4f8786660e705080a84" - integrity sha512-lh9HLdb53sC7XIZOYzTXM4lFuXElv3EVkSDhsd7DoJBj7hm+Ni7D3qYbb+Rr8DuM8nRanBvkVO9d7askreXGnQ== - dependencies: - concat-with-sourcemaps "*" - lodash.template "^4.4.0" - through2 "^2.0.0" - -handlebars-utils@^1.0.6: - version "1.0.6" - resolved "https://registry.yarnpkg.com/handlebars-utils/-/handlebars-utils-1.0.6.tgz#cb9db43362479054782d86ffe10f47abc76357f9" - integrity sha512-d5mmoQXdeEqSKMtQQZ9WkiUcO1E3tPbWxluCK9hVgIDPzQa9WsKo3Lbe/sGflTe7TomHEeZaOgwIkyIr1kfzkw== - dependencies: - kind-of "^6.0.0" - typeof-article "^0.1.1" - -handlebars@^4.7.6, handlebars@^4.7.7: +handlebars@^4.7.7: version "4.7.7" resolved "https://registry.yarnpkg.com/handlebars/-/handlebars-4.7.7.tgz#9ce33416aad02dbd6c8fafa8240d5d98004945a1" integrity sha512-aAcXm5OAfE/8IXkcZvCepKU3VzW1/39Fb5ZuqMtgI/hT8X2YgoMvBY5dLhq/cpOvw7Lk1nK/UF71aLG/ZnVYRA== @@ -7376,14 +7045,6 @@ has-value@^1.0.0: has-values "^1.0.0" isobject "^3.0.0" -has-value@^2.0.2: - version "2.0.2" - resolved "https://registry.yarnpkg.com/has-value/-/has-value-2.0.2.tgz#d0f12e8780ba8e90e66ad1a21c707fdb67c25658" - integrity sha512-ybKOlcRsK2MqrM3Hmz/lQxXHZ6ejzSPzpNabKB45jb5qDgJvKPa3SdapTsTLwEb9WltgWpOmNax7i+DzNOk4TA== - dependencies: - get-value "^3.0.0" - has-values "^2.0.1" - has-values@^0.1.4: version "0.1.4" resolved "https://registry.yarnpkg.com/has-values/-/has-values-0.1.4.tgz#6d61de95d91dfca9b9a02089ad384bff8f62b771" @@ -7397,13 +7058,6 @@ has-values@^1.0.0: is-number "^3.0.0" kind-of "^4.0.0" -has-values@^2.0.1: - version "2.0.1" - resolved "https://registry.yarnpkg.com/has-values/-/has-values-2.0.1.tgz#3876200ff86d8a8546a9264a952c17d5fc17579d" - integrity sha512-+QdH3jOmq9P8GfdjFg0eJudqx1FqU62NQJ4P16rOEHeRdl7ckgwn6uqQjzYE0ZoHVV/e5E2esuJ5Gl5+HUW19w== - dependencies: - kind-of "^6.0.2" - has-yarn@^2.1.0: version "2.1.0" resolved "https://registry.yarnpkg.com/has-yarn/-/has-yarn-2.1.0.tgz#137e11354a7b5bf11aa5cb649cf0c6f3ff2b2e77" @@ -7416,16 +7070,6 @@ has@^1.0.3: dependencies: function-bind "^1.1.1" -helper-md@^0.2.2: - version "0.2.2" - resolved "https://registry.yarnpkg.com/helper-md/-/helper-md-0.2.2.tgz#c1f59d7e55bbae23362fd8a0e971607aec69d41f" - integrity sha512-49TaQzK+Ic7ZVTq4i1UZxRUJEmAilTk8hz7q4I0WNUaTclLR8ArJV5B3A1fe1xF2HtsDTr2gYKLaVTof/Lt84Q== - dependencies: - ent "^2.2.0" - extend-shallow "^2.0.1" - fs-exists-sync "^0.1.0" - remarkable "^1.6.2" - homedir-polyfill@^1.0.1: version "1.0.3" resolved "https://registry.yarnpkg.com/homedir-polyfill/-/homedir-polyfill-1.0.3.tgz#743298cef4e5af3e194161fbadcc2151d3a058e8" @@ -7462,24 +7106,6 @@ html-escaper@^2.0.0: resolved "https://registry.yarnpkg.com/html-escaper/-/html-escaper-2.0.2.tgz#dfd60027da36a36dfcbe236262c00a5822681453" integrity sha512-H2iMtd0I4Mt5eYiapRdIDjp+XzelXQ0tFE4JS7YFwFevXXMmOp9myNrUvCg0D6ws8iqkRPBfKHgbwig1SmlLfg== -html-tag@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/html-tag/-/html-tag-2.0.0.tgz#36c3bc8d816fd30b570d5764a497a641640c2fed" - integrity sha512-XxzooSo6oBoxBEUazgjdXj7VwTn/iSTSZzTYKzYY6I916tkaYzypHxy+pbVU1h+0UQ9JlVf5XkNQyxOAiiQO1g== - dependencies: - is-self-closing "^1.0.1" - kind-of "^6.0.0" - -htmlparser2@^6.0.0: - version "6.1.0" - resolved "https://registry.yarnpkg.com/htmlparser2/-/htmlparser2-6.1.0.tgz#c4d762b6c3371a05dbe65e94ae43a9f845fb8fb7" - integrity sha512-gyyPk6rgonLFEDGoeRgQNaEUvdJ4ktTmmUh/h2t7s+M8oPpIPxgNACWa+6ESR57kXstwqPiCut0V8NRpcwgU7A== - dependencies: - domelementtype "^2.0.1" - domhandler "^4.0.0" - domutils "^2.5.2" - entities "^2.0.0" - http-assert@^1.3.0: version "1.5.0" resolved "https://registry.yarnpkg.com/http-assert/-/http-assert-1.5.0.tgz#c389ccd87ac16ed2dfa6246fd73b926aa00e6b8f" @@ -7920,13 +7546,6 @@ is-docker@^2.0.0, is-docker@^2.1.1: resolved "https://registry.yarnpkg.com/is-docker/-/is-docker-2.2.1.tgz#33eeabe23cfe86f14bde4408a02c0cfb853acdaa" integrity sha512-F+i2BKsFrH66iaUFc0woD8sLy8getkwTwtOBjvs56Cx4CgJDeKQeqfz8wAYiSb8JOprWhHH5p77PbmYCvvUuXQ== -is-even@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/is-even/-/is-even-1.0.0.tgz#76b5055fbad8d294a86b6a949015e1c97b717c06" - integrity sha512-LEhnkAdJqic4Dbqn58A0y52IXoHWlsueqQkKfMfdEnIYG8A1sm/GHidKkS6yvXlMoRrkM34csHnXQtOqcb+Jzg== - dependencies: - is-odd "^0.1.2" - is-extendable@^0.1.0, is-extendable@^0.1.1: version "0.1.1" resolved "https://registry.yarnpkg.com/is-extendable/-/is-extendable-0.1.1.tgz#62b110e289a471418e3ec36a617d472e301dfc89" @@ -8016,13 +7635,6 @@ is-number-object@^1.0.4: dependencies: has-tostringtag "^1.0.0" -is-number@^2.0.2: - version "2.1.0" - resolved "https://registry.yarnpkg.com/is-number/-/is-number-2.1.0.tgz#01fcbbb393463a548f2f466cce16dece49db908f" - integrity sha512-QUzH43Gfb9+5yckcrSA0VBDwEtDUchrk4F6tfJZQuNzDJbEDB9cZNzSfXGQ1jqmdDY/kl41lUOWM9syA8z8jlg== - dependencies: - kind-of "^3.0.2" - is-number@^3.0.0: version "3.0.0" resolved "https://registry.yarnpkg.com/is-number/-/is-number-3.0.0.tgz#24fd6201a4782cf50561c810276afc7d12d71195" @@ -8045,13 +7657,6 @@ is-object@^1.0.1: resolved "https://registry.yarnpkg.com/is-object/-/is-object-1.0.2.tgz#a56552e1c665c9e950b4a025461da87e72f86fcf" integrity sha512-2rRIahhZr2UWb45fIOuvZGpFtz0TyOZLf32KxBbSoUCeZR495zCKlWUKKUByk3geS2eAs7ZAABt0Y/Rx0GiQGA== -is-odd@^0.1.2: - version "0.1.2" - resolved "https://registry.yarnpkg.com/is-odd/-/is-odd-0.1.2.tgz#bc573b5ce371ef2aad6e6f49799b72bef13978a7" - integrity sha512-Ri7C2K7o5IrUU9UEI8losXJCCD/UtsaIrkR5sxIcFg4xQ9cRJXlWA5DQvTE0yDc0krvSNLsRGXN11UPS6KyfBw== - dependencies: - is-number "^3.0.0" - is-path-inside@^3.0.2: version "3.0.3" resolved "https://registry.yarnpkg.com/is-path-inside/-/is-path-inside-3.0.3.tgz#d231362e53a07ff2b0e0ea7fed049161ffd16283" @@ -8069,11 +7674,6 @@ is-plain-object@^2.0.3, is-plain-object@^2.0.4: dependencies: isobject "^3.0.1" -is-plain-object@^5.0.0: - version "5.0.0" - resolved "https://registry.yarnpkg.com/is-plain-object/-/is-plain-object-5.0.0.tgz#4427f50ab3429e9025ea7d52e9043a9ef4159344" - integrity sha512-VRSzKkbMm5jMDoKLbltAkFQ5Qr7VDiTFGXxYFXXowVj387GeGNOCsOH6Msy00SGZ3Fp84b1Naa1psqgcCIEP5Q== - is-potential-custom-element-name@^1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/is-potential-custom-element-name/-/is-potential-custom-element-name-1.0.1.tgz#171ed6f19e3ac554394edf78caa05784a45bebb5" @@ -8102,13 +7702,6 @@ is-retry-allowed@^2.2.0: resolved "https://registry.yarnpkg.com/is-retry-allowed/-/is-retry-allowed-2.2.0.tgz#88f34cbd236e043e71b6932d09b0c65fb7b4d71d" integrity sha512-XVm7LOeLpTW4jV19QSH38vkswxoLud8sQ57YwJVTPWdiaI9I8keEhGFpBlslyVsgdQy4Opg8QOLb8YRgsyZiQg== -is-self-closing@^1.0.1: - version "1.0.1" - resolved "https://registry.yarnpkg.com/is-self-closing/-/is-self-closing-1.0.1.tgz#5f406b527c7b12610176320338af0fa3896416e4" - integrity sha512-E+60FomW7Blv5GXTlYee2KDrnG6srxF7Xt1SjrhWUGUEsTFIqY/nq2y3DaftCsgUMdh89V07IVfhY9KIJhLezg== - dependencies: - self-closing-tags "^1.0.1" - is-shared-array-buffer@^1.0.2: version "1.0.2" resolved "https://registry.yarnpkg.com/is-shared-array-buffer/-/is-shared-array-buffer-1.0.2.tgz#8f259c573b60b6a32d4058a1a07430c0a7344c79" @@ -8219,11 +7812,6 @@ isexe@^2.0.0: resolved "https://registry.yarnpkg.com/isexe/-/isexe-2.0.0.tgz#e8fbf374dc556ff8947a10dcb0572d633f2cfa10" integrity sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw== -isobject@^0.2.0: - version "0.2.0" - resolved "https://registry.yarnpkg.com/isobject/-/isobject-0.2.0.tgz#a3432192f39b910b5f02cc989487836ec70aa85e" - integrity sha512-VaWq6XYAsbvM0wf4dyBO7WH9D7GosB7ZZlqrawI9BBiTMINBeCyqSKBa35m870MY3O4aM31pYyZi9DfGrYMJrQ== - isobject@^2.0.0: version "2.1.0" resolved "https://registry.yarnpkg.com/isobject/-/isobject-2.1.0.tgz#f065561096a3f1da2ef46272f815c840d87e0c89" @@ -9404,7 +8992,7 @@ keyv@^3.0.0: dependencies: json-buffer "3.0.0" -kind-of@^3.0.2, kind-of@^3.0.3, kind-of@^3.1.0, kind-of@^3.2.0: +kind-of@^3.0.2, kind-of@^3.0.3, kind-of@^3.2.0: version "3.2.2" resolved "https://registry.yarnpkg.com/kind-of/-/kind-of-3.2.2.tgz#31ea21a734bab9bbb0f32466d893aea51e4a3c64" integrity sha512-NOW9QQXMoZGg/oqnVNoNTTIFEIid1627WCffUBJEdMxYApq7mNE7CpzucIPc+ZQg25Phej7IJSmX3hO+oblOtQ== @@ -9418,12 +9006,12 @@ kind-of@^4.0.0: dependencies: is-buffer "^1.1.5" -kind-of@^5.0.0, kind-of@^5.0.2: +kind-of@^5.0.0: version "5.1.0" resolved "https://registry.yarnpkg.com/kind-of/-/kind-of-5.1.0.tgz#729c91e2d857b7a419a1f9aa65685c4c33f5845d" integrity sha512-NGEErnH6F2vUuXDh+OlbcKW7/wOcfdRHaZ7VWtqCztfHri/++YKmP51OdWeGPuqCOba6kk2OTe5d02VmTB80Pw== -kind-of@^6.0.0, kind-of@^6.0.2, kind-of@^6.0.3: +kind-of@^6.0.0, kind-of@^6.0.2: version "6.0.3" resolved "https://registry.yarnpkg.com/kind-of/-/kind-of-6.0.3.tgz#07c05034a6c349fa06e24fa35aa76db4580ce4dd" integrity sha512-dcS1ul+9tmeD95T+x28/ehLgd9mENa3LsvDTtzm3vyBEO7RPptvAD+t44WVXaUjTBRcrpFeFlC8WCruUR456hw== @@ -9683,11 +9271,6 @@ lcid@^2.0.0: dependencies: invert-kv "^2.0.0" -leaflet@^1.7.1: - version "1.8.0" - resolved "https://registry.yarnpkg.com/leaflet/-/leaflet-1.8.0.tgz#4615db4a22a304e8e692cae9270b983b38a2055e" - integrity sha512-gwhMjFCQiYs3x/Sf+d49f10ERXaEFCPr+nVTryhAW8DWbMGqJqt9G4XuIaHmFW08zYvhgdzqXGr8AlW8v8dQkA== - left-pad@^1.3.0: version "1.3.0" resolved "https://registry.yarnpkg.com/left-pad/-/left-pad-1.3.0.tgz#5b8a3a7765dfe001261dde915589e782f8c94d1e" @@ -9882,11 +9465,6 @@ locate-path@^5.0.0: dependencies: p-locate "^4.1.0" -lodash._reinterpolate@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/lodash._reinterpolate/-/lodash._reinterpolate-3.0.0.tgz#0ccf2d89166af03b3663c796538b75ac6e114d9d" - integrity sha512-xYHt68QRoYGjeeM/XOE1uJtvXQAgvszfBhjV4yvsQH0u2i9I6cI6c6/eG4Hh3UAOVn0y/xAXwmTzEay49Q//HA== - lodash.camelcase@^4.3.0: version "4.3.0" resolved "https://registry.yarnpkg.com/lodash.camelcase/-/lodash.camelcase-4.3.0.tgz#b28aa6288a2b9fc651035c7711f65ab6190331a6" @@ -9997,21 +9575,6 @@ lodash.sortby@^4.7.0: resolved "https://registry.yarnpkg.com/lodash.sortby/-/lodash.sortby-4.7.0.tgz#edd14c824e2cc9c1e0b0a1b42bb5210516a42438" integrity sha512-HDWXG8isMntAyRF5vZ7xKuEvOhT4AhlRt/3czTSjvGUxjYCBVRQY48ViDHyfYz9VIoBkW4TMGQNapx+l3RUwdA== -lodash.template@^4.4.0: - version "4.5.0" - resolved "https://registry.yarnpkg.com/lodash.template/-/lodash.template-4.5.0.tgz#f976195cf3f347d0d5f52483569fe8031ccce8ab" - integrity sha512-84vYFxIkmidUiFxidA/KjjH9pAycqW+h980j7Fuz5qxRtO9pgB7MDFTdys1N7A5mcucRiDyEq4fusljItR1T/A== - dependencies: - lodash._reinterpolate "^3.0.0" - lodash.templatesettings "^4.0.0" - -lodash.templatesettings@^4.0.0: - version "4.2.0" - resolved "https://registry.yarnpkg.com/lodash.templatesettings/-/lodash.templatesettings-4.2.0.tgz#e481310f049d3cf6d47e912ad09313b154f0fb33" - integrity sha512-stgLz+i3Aa9mZgnjr/O+v9ruKZsPsndy7qPZOchbqk2cnTU1ZaldKK+v7m54WoKIyxiuMZTKT2H81F8BeAc3ZQ== - dependencies: - lodash._reinterpolate "^3.0.0" - lodash.without@^4.4.0: version "4.4.0" resolved "https://registry.yarnpkg.com/lodash.without/-/lodash.without-4.4.0.tgz#3cd4574a00b67bae373a94b748772640507b7aac" @@ -10022,7 +9585,7 @@ lodash.xor@^4.5.0: resolved "https://registry.yarnpkg.com/lodash.xor/-/lodash.xor-4.5.0.tgz#4d48ed7e98095b0632582ba714d3ff8ae8fb1db6" integrity sha512-sVN2zimthq7aZ5sPGXnSz32rZPuqcparVW50chJQe+mzTYV+IsxSsl/2gnkWWE2Of7K3myBQBqtLKOUEHJKRsQ== -lodash@4.17.21, lodash@^4.14.0, lodash@^4.17.11, lodash@^4.17.14, lodash@^4.17.15, lodash@^4.17.19, lodash@^4.17.20, lodash@^4.17.21, lodash@^4.17.3, lodash@^4.7.0: +lodash@4.17.21, lodash@^4.14.0, lodash@^4.17.11, lodash@^4.17.14, lodash@^4.17.15, lodash@^4.17.19, lodash@^4.17.21, lodash@^4.17.3, lodash@^4.7.0: version "4.17.21" resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.21.tgz#679591c564c3bffaae8454cf0b3df370c3d6911c" integrity sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg== @@ -10090,13 +9653,6 @@ ltgt@2.2.1, ltgt@^2.1.2, ltgt@~2.2.0: resolved "https://registry.yarnpkg.com/ltgt/-/ltgt-2.2.1.tgz#f35ca91c493f7b73da0e07495304f17b31f87ee5" integrity sha512-AI2r85+4MquTw9ZYqabu4nMwy9Oftlfa/e/52t9IjtfG+mGBbTNdAoZ3RQKLHR6r0wQnwZnPIEh/Ya6XTWAKNA== -magic-string@^0.25.7: - version "0.25.9" - resolved "https://registry.yarnpkg.com/magic-string/-/magic-string-0.25.9.tgz#de7f9faf91ef8a1c91d02c2e5314c8277dbcdd1c" - integrity sha512-RmF0AsMzgt25qzqqLc1+MbHmhdx0ojF2Fvs4XnOqz2ZOBXzzkEwc/dJQZCYHAn7v1jbVOjAZfK8msRn4BxO4VQ== - dependencies: - sourcemap-codec "^1.4.8" - make-dir@^1.0.0: version "1.3.0" resolved "https://registry.yarnpkg.com/make-dir/-/make-dir-1.3.0.tgz#79c1033b80515bd6d24ec9933e860ca75ee27f0c" @@ -10161,11 +9717,6 @@ markdown-it@^12.2.0: mdurl "^1.0.1" uc.micro "^1.0.5" -marked@^4.0.10: - version "4.0.18" - resolved "https://registry.yarnpkg.com/marked/-/marked-4.0.18.tgz#cd0ac54b2e5610cfb90e8fd46ccaa8292c9ed569" - integrity sha512-wbLDJ7Zh0sqA0Vdg6aqlbT+yPxqLblpAZh1mK2+AO2twQkPywvvqQNfEPVwSSRjZ7dZcdeVBIAgiO7MMp3Dszw== - matcher@^3.0.0: version "3.0.0" resolved "https://registry.yarnpkg.com/matcher/-/matcher-3.0.0.tgz#bd9060f4c5b70aa8041ccc6f80368760994f30ca" @@ -10238,7 +9789,7 @@ methods@^1.0.1, methods@^1.1.1, methods@^1.1.2: resolved "https://registry.yarnpkg.com/methods/-/methods-1.1.2.tgz#5529a4d67654134edcc5266656835b0f851afcee" integrity sha512-iclAHeNqNm68zFtnZ0e+1L2yUIdvzNoauKU4WBA3VvH/vPFieF7qfRlwUZU+DA9P9bPXIS90ulxoUoCH23sV2w== -micromatch@^3.1.10, micromatch@^3.1.4, micromatch@^3.1.5: +micromatch@^3.1.10, micromatch@^3.1.4: version "3.1.10" resolved "https://registry.yarnpkg.com/micromatch/-/micromatch-3.1.10.tgz#70859bc95c9840952f359a068a3fc49f9ecfac23" integrity sha512-MWikgl9n9M3w+bpsY3He8L+w9eF9338xRl8IAO5viDizwSzziFEyUzo2xrrloB64ADbTf8uA8vRqqttDTOmccg== @@ -10496,16 +10047,6 @@ nan@^2.12.1: resolved "https://registry.yarnpkg.com/nan/-/nan-2.16.0.tgz#664f43e45460fb98faf00edca0bb0d7b8dce7916" integrity sha512-UdAqHyFngu7TfQKsCBgAA6pWDkT8MAO7d0jyOecVhN5354xbLqdn8mV9Tat9gepAupm0bt2DbeaSC8vS52MuFA== -nanoid@^2.1.0: - version "2.1.11" - resolved "https://registry.yarnpkg.com/nanoid/-/nanoid-2.1.11.tgz#ec24b8a758d591561531b4176a01e3ab4f0f0280" - integrity sha512-s/snB+WGm6uwi0WjsZdaVcuf3KJXlfGl2LcxgwkEwJF0D/BWzVWAZW/XY4bFaiR7s0Jk3FPvlnepg1H1b1UwlA== - -nanoid@^3.3.4: - version "3.3.4" - resolved "https://registry.yarnpkg.com/nanoid/-/nanoid-3.3.4.tgz#730b67e3cd09e2deacf03c027c81c9d9dbc5e8ab" - integrity sha512-MqBkQh/OHTS2egovRtLk45wEyNXwF+cokD+1YPf9u5VfJiRdAiRwB2froX5Co9Rh20xs4siNPm8naNotSD6RBw== - nanomatch@^1.2.9: version "1.2.13" resolved "https://registry.yarnpkg.com/nanomatch/-/nanomatch-1.2.13.tgz#b87a8aa4fc0de8fe6be88895b38983ff265bd119" @@ -11103,11 +10644,6 @@ parse-passwd@^1.0.0: resolved "https://registry.yarnpkg.com/parse-passwd/-/parse-passwd-1.0.0.tgz#6d5b934a456993b23d37f40a382d6f1666a8e5c6" integrity sha512-1Y1A//QUXEZK7YKz+rD9WydcE1+EuPr6ZBgKecAB8tmoW6UFv0NREVJe1p+jRxtThkcbbKkfwIbWJe/IeE6m2Q== -parse-srcset@^1.0.2: - version "1.0.2" - resolved "https://registry.yarnpkg.com/parse-srcset/-/parse-srcset-1.0.2.tgz#f2bd221f6cc970a938d88556abc589caaaa2bde1" - integrity sha512-/2qh0lav6CmI15FzA3i/2Bzk2zCgQhGMkvhOhKNcBVQ1ldgpbfiNTVslmooUmWJcADi1f1kIeynbDRVzNlfR6Q== - parse5@4.0.0: version "4.0.0" resolved "https://registry.yarnpkg.com/parse5/-/parse5-4.0.0.tgz#6d78656e3da8d78b4ec0b906f7c08ef1dfe3f608" @@ -11354,7 +10890,7 @@ picocolors@^1.0.0: resolved "https://registry.yarnpkg.com/picocolors/-/picocolors-1.0.0.tgz#cb5bdc74ff3f51892236eaf79d68bc44564ab81c" integrity sha512-1fygroTLlHu66zi26VoTDv8yRgm0Fccecssto+MhsZ0D/DGW2sm8E8AjW7NU5VVTRt5GxbeZ5qBuJr+HyLYkjQ== -picomatch@^2.0.4, picomatch@^2.2.1, picomatch@^2.2.2, picomatch@^2.2.3, picomatch@^2.3.1: +picomatch@^2.0.4, picomatch@^2.2.1, picomatch@^2.2.3, picomatch@^2.3.1: version "2.3.1" resolved "https://registry.yarnpkg.com/picomatch/-/picomatch-2.3.1.tgz#3ba3833733646d9d3e4995946c1365a67fb07a42" integrity sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA== @@ -11469,15 +11005,6 @@ posix-character-classes@^0.1.0: resolved "https://registry.yarnpkg.com/posix-character-classes/-/posix-character-classes-0.1.1.tgz#01eac0fe3b5af71a2a6c02feabb8c1fef7e00eab" integrity sha512-xTgYBc3fuo7Yt7JbiuFxSYGToMoz8fLoE6TC9Wx1P/u+LfeThMOAqmuyECnlBaaJb+u1m9hHiXUEtwW4OzfUJg== -postcss@^8.3.11: - version "8.4.16" - resolved "https://registry.yarnpkg.com/postcss/-/postcss-8.4.16.tgz#33a1d675fac39941f5f445db0de4db2b6e01d43c" - integrity sha512-ipHE1XBvKzm5xI7hiHCZJCSugxvsdq2mPnsq5+UF+VHCjiBvtDrlxJfMBToWaP9D5XlgNmcFGqoHmUn0EYEaRQ== - dependencies: - nanoid "^3.3.4" - picocolors "^1.0.0" - source-map-js "^1.0.2" - postgres-array@~2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/postgres-array/-/postgres-array-2.0.0.tgz#48f8fce054fbc69671999329b8834b772652d82e" @@ -12226,16 +11753,6 @@ regexp.prototype.flags@^1.4.3: define-properties "^1.1.3" functions-have-names "^1.2.2" -regexparam@2.0.1: - version "2.0.1" - resolved "https://registry.yarnpkg.com/regexparam/-/regexparam-2.0.1.tgz#c912f5dae371e3798100b3c9ce22b7414d0889fa" - integrity sha512-zRgSaYemnNYxUv+/5SeoHI0eJIgTL/A2pUtXUPLHQxUldagouJ9p+K6IbIZ/JiQuCEv2E2B1O11SjVQy3aMCkw== - -regexparam@^1.3.0: - version "1.3.0" - resolved "https://registry.yarnpkg.com/regexparam/-/regexparam-1.3.0.tgz#2fe42c93e32a40eff6235d635e0ffa344b92965f" - integrity sha512-6IQpFBv6e5vz1QAqI+V4k8P2e/3gRrqfCJ9FI+O1FLQTO+Uz6RXZEZOPmTJ6hlGj7gkERzY5BRCv09whKP96/g== - regexpp@^2.0.1: version "2.0.1" resolved "https://registry.yarnpkg.com/regexpp/-/regexpp-2.0.1.tgz#8d19d31cf632482b589049f8281f93dbcba4d07f" @@ -12279,21 +11796,6 @@ regjsparser@^0.8.2: dependencies: jsesc "~0.5.0" -relative@^3.0.2: - version "3.0.2" - resolved "https://registry.yarnpkg.com/relative/-/relative-3.0.2.tgz#0dcd8ec54a5d35a3c15e104503d65375b5a5367f" - integrity sha512-Q5W2qeYtY9GbiR8z1yHNZ1DGhyjb4AnLEjt8iE6XfcC1QIu+FAtj3HQaO0wH28H1mX6cqNLvAqWhP402dxJGyA== - dependencies: - isobject "^2.0.0" - -remarkable@^1.6.2: - version "1.7.4" - resolved "https://registry.yarnpkg.com/remarkable/-/remarkable-1.7.4.tgz#19073cb960398c87a7d6546eaa5e50d2022fcd00" - integrity sha512-e6NKUXgX95whv7IgddywbeN/ItCkWbISmc2DiqHJb0wTrqZIexqdco5b8Z3XZoo/48IdNVKM9ZCvTPJ4F5uvhg== - dependencies: - argparse "^1.0.10" - autolinker "~0.28.0" - remove-trailing-separator@^1.0.1: version "1.1.0" resolved "https://registry.yarnpkg.com/remove-trailing-separator/-/remove-trailing-separator-1.1.0.tgz#c24bce2a283adad5bc3f58e0d48249b92379d8ef" @@ -12505,13 +12007,6 @@ roarr@^2.15.3: semver-compare "^1.0.0" sprintf-js "^1.1.2" -rollup-plugin-polyfill-node@^0.8.0: - version "0.8.0" - resolved "https://registry.yarnpkg.com/rollup-plugin-polyfill-node/-/rollup-plugin-polyfill-node-0.8.0.tgz#859c070822f5e38d221e5b4238cb34aa894c2b19" - integrity sha512-C4UeKedOmOBkB3FgR+z/v9kzRwV1Q/H8xWs1u1+CNe4XOV6hINfOrcO+TredKxYvopCmr+WKUSNsFUnD1RLHgQ== - dependencies: - "@rollup/plugin-inject" "^4.0.0" - rsvp@^4.8.4: version "4.8.5" resolved "https://registry.yarnpkg.com/rsvp/-/rsvp-4.8.5.tgz#c8f155311d167f68f21e168df71ec5b083113734" @@ -12578,18 +12073,6 @@ sane@^4.0.3: minimist "^1.1.1" walker "~1.0.5" -sanitize-html@^2.7.0: - version "2.7.1" - resolved "https://registry.yarnpkg.com/sanitize-html/-/sanitize-html-2.7.1.tgz#a6c2c1a88054a79eeacfac9b0a43f1b393476901" - integrity sha512-oOpe8l4J8CaBk++2haoN5yNI5beekjuHv3JRPKUx/7h40Rdr85pemn4NkvUB3TcBP7yjat574sPlcMAyv4UQig== - dependencies: - deepmerge "^4.2.2" - escape-string-regexp "^4.0.0" - htmlparser2 "^6.0.0" - is-plain-object "^5.0.0" - parse-srcset "^1.0.2" - postcss "^8.3.11" - sanitize-s3-objectkey@0.0.1: version "0.0.1" resolved "https://registry.yarnpkg.com/sanitize-s3-objectkey/-/sanitize-s3-objectkey-0.0.1.tgz#efa9887cd45275b40234fb4bb12fc5754fe64e7e" @@ -12628,11 +12111,6 @@ schema-utils@^3.1.0, schema-utils@^3.1.1: ajv "^6.12.5" ajv-keywords "^3.5.2" -screenfull@^6.0.1: - version "6.0.2" - resolved "https://registry.yarnpkg.com/screenfull/-/screenfull-6.0.2.tgz#3dbe4b8c4f8f49fb8e33caa8f69d0bca730ab238" - integrity sha512-AQdy8s4WhNvUZ6P8F6PB21tSPIYKniic+Ogx0AacBMjKP1GUHN2E9URxQHtCusiwxudnCKkdy4GrHXPPJSkCCw== - search-params@3.0.0: version "3.0.0" resolved "https://registry.yarnpkg.com/search-params/-/search-params-3.0.0.tgz#dbc7c243058e5a33ae1e9870be91f5aced4100d8" @@ -12650,11 +12128,6 @@ seek-bzip@^1.0.5: dependencies: commander "^2.8.1" -self-closing-tags@^1.0.1: - version "1.0.1" - resolved "https://registry.yarnpkg.com/self-closing-tags/-/self-closing-tags-1.0.1.tgz#6c5fa497994bb826b484216916371accee490a5d" - integrity sha512-7t6hNbYMxM+VHXTgJmxwgZgLGktuXtVVD5AivWzNTdJBM4DBjnDKDzkf2SrNjihaArpeJYNjxkELBu1evI4lQA== - semver-compare@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/semver-compare/-/semver-compare-1.0.0.tgz#0dee216a1c941ab37e9efb1788f6afc5ff5537fc" @@ -12790,13 +12263,6 @@ shimmer@^1.2.0: resolved "https://registry.yarnpkg.com/shimmer/-/shimmer-1.2.1.tgz#610859f7de327b587efebf501fb43117f9aff337" integrity sha512-sQTKC1Re/rM6XyFM6fIAGHRPVGvyXfgzIDvzoq608vM+jeyVD0Tu1E6Np0Kc2zAIFWIj963V2800iF/9LPieQw== -shortid@^2.2.15: - version "2.2.16" - resolved "https://registry.yarnpkg.com/shortid/-/shortid-2.2.16.tgz#b742b8f0cb96406fd391c76bfc18a67a57fe5608" - integrity sha512-Ugt+GIZqvGXCIItnsL+lvFJOiN7RYqlGy7QE41O3YC1xbNSeDGIRO7xg2JJXIAj1cAGnOeC1r7/T9pgrtQbv4g== - dependencies: - nanoid "^2.1.0" - side-channel@^1.0.4: version "1.0.4" resolved "https://registry.yarnpkg.com/side-channel/-/side-channel-1.0.4.tgz#efce5c8fdc104ee751b25c58d4290011fa5ea2cf" @@ -12961,11 +12427,6 @@ source-list-map@^2.0.1: resolved "https://registry.yarnpkg.com/source-list-map/-/source-list-map-2.0.1.tgz#3993bd873bfc48479cca9ea3a547835c7c154b34" integrity sha512-qnQ7gVMxGNxsiL4lEuJwe/To8UnK7fAnmbGEEH8RpLouuKbeEm0lhbQVFIrNSuB+G7tVrAlVsZgETT5nljf+Iw== -source-map-js@^1.0.2: - version "1.0.2" - resolved "https://registry.yarnpkg.com/source-map-js/-/source-map-js-1.0.2.tgz#adbc361d9c62df380125e7f161f71c826f1e490c" - integrity sha512-R0XvVJ9WusLiqTCEiGCmICCMplcCkIwwR11mOSD9CR5u+IXYdiseeEuXCVAjS54zqwkLcPNnmU4OeJ6tUrWhDw== - source-map-resolve@^0.5.0: version "0.5.3" resolved "https://registry.yarnpkg.com/source-map-resolve/-/source-map-resolve-0.5.3.tgz#190866bece7553e1f8f267a2ee82c606b5509a1a" @@ -13019,11 +12480,6 @@ source-map@^0.7.3: resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.7.4.tgz#a9bbe705c9d8846f4e08ff6765acf0f1b0898656" integrity sha512-l3BikUxvPOcn5E74dZiq5BGsTb5yEwhaTSzccU6t4sDOH8NWJCstKO5QT2CvtFoK6F0saL7p9xHAqHOlCPJygA== -sourcemap-codec@^1.4.8: - version "1.4.8" - resolved "https://registry.yarnpkg.com/sourcemap-codec/-/sourcemap-codec-1.4.8.tgz#ea804bd94857402e6992d05a38ef1ae35a9ab4c4" - integrity sha512-9NykojV5Uih4lgo5So5dtw+f0JgJX30KCNI8gwhz2J9A15wD0Ml6tjHKwf6fTSa6fAdVBdZeNOs9eJ71qCk8vA== - spark-md5@3.0.1: version "3.0.1" resolved "https://registry.yarnpkg.com/spark-md5/-/spark-md5-3.0.1.tgz#83a0e255734f2ab4e5c466e5a2cfc9ba2aa2124d" @@ -13348,11 +12804,6 @@ strip-outer@^1.0.0: dependencies: escape-string-regexp "^1.0.2" -striptags@^3.1.1: - version "3.2.0" - resolved "https://registry.yarnpkg.com/striptags/-/striptags-3.2.0.tgz#cc74a137db2de8b0b9a370006334161f7dd67052" - integrity sha512-g45ZOGzHDMe2bdYMdIvdAfCQkCTDMGBazSw1ypMowwGIee7ZQ5dU0rBJ8Jqgl+jAKIv4dbeE1jscZq9wid1Tkw== - style-loader@^3.3.1: version "3.3.1" resolved "https://registry.yarnpkg.com/style-loader/-/style-loader-3.3.1.tgz#057dfa6b3d4d7c7064462830f9113ed417d38575" @@ -13452,14 +12903,7 @@ svelte-portal@^1.0.0: resolved "https://registry.yarnpkg.com/svelte-portal/-/svelte-portal-1.0.0.tgz#36a47c5578b1a4d9b4dc60fa32a904640ec4cdd3" integrity sha512-nHf+DS/jZ6jjnZSleBMSaZua9JlG5rZv9lOGKgJuaZStfevtjIlUJrkLc3vbV8QdBvPPVmvcjTlazAzfKu0v3Q== -svelte-spa-router@^3.0.5: - version "3.3.0" - resolved "https://registry.yarnpkg.com/svelte-spa-router/-/svelte-spa-router-3.3.0.tgz#2fc0967a49dc361dfe4d38dddad6e662eed5b42c" - integrity sha512-cwRNe7cxD43sCvSfEeaKiNZg3FCizGxeMcf7CPiWRP3jKXjEma3vxyyuDtPOam6nWbVxl9TNM3hlE/i87ZlqcQ== - dependencies: - regexparam "2.0.1" - -svelte@3.49.0, svelte@^3.46.2, svelte@^3.49.0: +svelte@3.49.0: version "3.49.0" resolved "https://registry.yarnpkg.com/svelte/-/svelte-3.49.0.tgz#5baee3c672306de1070c3b7888fc2204e36a4029" integrity sha512-+lmjic1pApJWDfPCpUUTc1m8azDqYCG1JN9YEngrx/hUyIcFJo6VZhj0A1Ai0wqoHcEIuQy+e9tk+4uDgdtsFA== @@ -13821,11 +13265,6 @@ to-fast-properties@^2.0.0: resolved "https://registry.yarnpkg.com/to-fast-properties/-/to-fast-properties-2.0.0.tgz#dc5e698cbd079265bc73e0377681a4e4e83f616e" integrity sha1-3F5pjL0HkmW8c+A3doGk5Og/YW4= -to-gfm-code-block@^0.1.1: - version "0.1.1" - resolved "https://registry.yarnpkg.com/to-gfm-code-block/-/to-gfm-code-block-0.1.1.tgz#25d045a5fae553189e9637b590900da732d8aa82" - integrity sha512-LQRZWyn8d5amUKnfR9A9Uu7x9ss7Re8peuWR2gkh1E+ildOfv2aF26JpuDg8JtvCduu5+hOrMIH+XstZtnagqg== - to-json-schema@0.2.5: version "0.2.5" resolved "https://registry.yarnpkg.com/to-json-schema/-/to-json-schema-0.2.5.tgz#ef3c3f11ad64460dcfbdbafd0fd525d69d62a98f" @@ -14072,13 +13511,6 @@ typedarray-to-buffer@^3.1.5: dependencies: is-typedarray "^1.0.0" -typeof-article@^0.1.1: - version "0.1.1" - resolved "https://registry.yarnpkg.com/typeof-article/-/typeof-article-0.1.1.tgz#9f07e733c3fbb646ffa9e61c08debacd460e06af" - integrity sha512-Vn42zdX3FhmUrzEmitX3iYyLb+Umwpmv8fkZRIknYh84lmdrwqZA5xYaoKiIj2Rc5i/5wcDrpUmZcbk1U51vTw== - dependencies: - kind-of "^3.1.0" - typeof@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/typeof/-/typeof-1.0.0.tgz#9c84403f2323ae5399167275497638ea1d2f2440" @@ -14089,11 +13521,6 @@ typescript@4.6.2: resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.6.2.tgz#fe12d2727b708f4eef40f51598b3398baa9611d4" integrity sha512-HM/hFigTBHZhLXshn9sN37H085+hQGeJHJ/X7LpBWLID/fbc2acUMfU+lGD98X81sKP+pFa9f0DZmCwB9GnbAg== -typo-js@*: - version "1.2.2" - resolved "https://registry.yarnpkg.com/typo-js/-/typo-js-1.2.2.tgz#340484d81fe518e77c81a5a770162b14492f183b" - integrity sha512-C7pYBQK17EjSg8tVNY91KHdUt5Nf6FMJ+c3js076quPmBML57PmNMzAcIq/2kf/hSYtFABNDIYNYlJRl5BJhGw== - uc.micro@^1.0.1, uc.micro@^1.0.5: version "1.0.6" resolved "https://registry.yarnpkg.com/uc.micro/-/uc.micro-1.0.6.tgz#9c411a802a409a91fc6cf74081baba34b24499ac" @@ -14418,14 +13845,6 @@ vm2@3.9.6: acorn "^8.7.0" acorn-walk "^8.2.0" -vm2@^3.9.4: - version "3.9.10" - resolved "https://registry.yarnpkg.com/vm2/-/vm2-3.9.10.tgz#c66543096b5c44c8861a6465805c23c7cc996a44" - integrity sha512-AuECTSvwu2OHLAZYhG716YzwodKCIJxB6u1zG7PgSQwIgAlEaoXH52bxdcvT8GkGjnYK7r7yWDW0m0sOsPuBjQ== - dependencies: - acorn "^8.7.0" - acorn-walk "^8.2.0" - vuvuzela@1.0.3: version "1.0.3" resolved "https://registry.yarnpkg.com/vuvuzela/-/vuvuzela-1.0.3.tgz#3be145e58271c73ca55279dd851f12a682114b0b" @@ -14979,11 +14398,6 @@ yauzl@^2.4.2: buffer-crc32 "~0.2.3" fd-slicer "~1.1.0" -year@^0.2.1: - version "0.2.1" - resolved "https://registry.yarnpkg.com/year/-/year-0.2.1.tgz#4083ae520a318b23ec86037f3000cb892bdf9bb0" - integrity sha512-9GnJUZ0QM4OgXuOzsKNzTJ5EOkums1Xc+3YQXp+Q+UxFjf7zLucp9dQ8QMIft0Szs1E1hUiXFim1OYfEKFq97w== - ylru@^1.2.0: version "1.3.2" resolved "https://registry.yarnpkg.com/ylru/-/ylru-1.3.2.tgz#0de48017473275a4cbdfc83a1eaf67c01af8a785" diff --git a/packages/types/src/documents/app/datasource.ts b/packages/types/src/documents/app/datasource.ts index 8a8419c7f5..efdc2ca1bd 100644 --- a/packages/types/src/documents/app/datasource.ts +++ b/packages/types/src/documents/app/datasource.ts @@ -2,75 +2,6 @@ import { Document } from "../document" import { SourceName } from "../../sdk" import { Table } from "./table" -export enum Operation { - CREATE = "CREATE", - READ = "READ", - UPDATE = "UPDATE", - DELETE = "DELETE", - BULK_CREATE = "BULK_CREATE", - CREATE_TABLE = "CREATE_TABLE", - UPDATE_TABLE = "UPDATE_TABLE", - DELETE_TABLE = "DELETE_TABLE", -} - -export enum SortDirection { - ASCENDING = "ASCENDING", - DESCENDING = "DESCENDING", -} - -export enum QueryTypes { - SQL = "sql", - JSON = "json", - FIELDS = "fields", -} - -export enum DatasourceFieldTypes { - STRING = "string", - LONGFORM = "longForm", - BOOLEAN = "boolean", - NUMBER = "number", - PASSWORD = "password", - LIST = "list", - OBJECT = "object", - JSON = "json", - FILE = "file", -} - -export enum SourceNames { - POSTGRES = "POSTGRES", - DYNAMODB = "DYNAMODB", - MONGODB = "MONGODB", - ELASTICSEARCH = "ELASTICSEARCH", - COUCHDB = "COUCHDB", - SQL_SERVER = "SQL_SERVER", - S3 = "S3", - AIRTABLE = "AIRTABLE", - MYSQL = "MYSQL", - ARANGODB = "ARANGODB", - REST = "REST", - ORACLE = "ORACLE", - GOOGLE_SHEETS = "GOOGLE_SHEETS", - FIRESTORE = "FIRESTORE", - REDIS = "REDIS", - SNOWFLAKE = "SNOWFLAKE", -} - -export enum IncludeRelationships { - INCLUDE = 1, - EXCLUDE = 0, -} - -export enum FilterTypes { - STRING = "string", - FUZZY = "fuzzy", - RANGE = "range", - EQUAL = "equal", - NOT_EQUAL = "notEqual", - EMPTY = "empty", - NOT_EMPTY = "notEmpty", - ONE_OF = "oneOf", -} - export interface Datasource extends Document { type: string name?: string diff --git a/packages/types/src/index.ts b/packages/types/src/index.ts index 4a645c5266..4adb2fda97 100644 --- a/packages/types/src/index.ts +++ b/packages/types/src/index.ts @@ -1,5 +1,3 @@ export * from "./documents" -export * from "./sdk/events" -export * from "./sdk/licensing" export * from "./sdk" export * from "./api" From 860c75c0bc4e1478fca2514628923014d0cf1a55 Mon Sep 17 00:00:00 2001 From: Andrew Kingston Date: Fri, 12 Aug 2022 14:01:56 +0100 Subject: [PATCH 026/203] Update name of types constant --- packages/server/src/api/controllers/screen.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/server/src/api/controllers/screen.js b/packages/server/src/api/controllers/screen.js index 1d5d876dc4..99d12d064c 100644 --- a/packages/server/src/api/controllers/screen.js +++ b/packages/server/src/api/controllers/screen.js @@ -2,7 +2,7 @@ const { getScreenParams, generateScreenID, getPluginParams, - DocumentTypes, + DocumentType, } = require("../../db/utils") const { AccessController } = require("@budibase/backend-core/roles") const { getAppDB } = require("@budibase/backend-core/context") @@ -60,7 +60,7 @@ exports.save = async ctx => { }) // Update the app metadata - const application = await db.get(DocumentTypes.APP_METADATA) + const application = await db.get(DocumentType.APP_METADATA) let usedPlugins = application.usedPlugins || [] requiredPlugins.forEach(plugin => { From a7c424550c75bb42f525d9c6d8395b946c8a6442 Mon Sep 17 00:00:00 2001 From: Andrew Kingston Date: Fri, 12 Aug 2022 14:02:11 +0100 Subject: [PATCH 027/203] Simply logic around handling runtime reloading of custom components --- packages/client/src/stores/components.js | 66 ++++++++++++------------ 1 file changed, 32 insertions(+), 34 deletions(-) diff --git a/packages/client/src/stores/components.js b/packages/client/src/stores/components.js index 94dd16a957..8512a371d8 100644 --- a/packages/client/src/stores/components.js +++ b/packages/client/src/stores/components.js @@ -12,7 +12,7 @@ const budibasePrefix = "@budibase/standard-components/" const createComponentStore = () => { const store = writable({ customComponentManifest: {}, - componentsAwaitingConstructors: {}, + customComponentMap: {}, mountedComponents: {}, }) @@ -54,30 +54,37 @@ const createComponentStore = () => { const registerInstance = (id, instance) => { store.update(state => { - // If this is a custom component and does not have an implementation yet, - // store so we can reload this component later + // If this is a custom component, flag it so we can reload this component + // later if required const component = instance.component - let cac = state.componentsAwaitingConstructors - if (!getComponentConstructor(component)) { - if (!cac[component]) { - cac[component] = [] + if (component?.startsWith("plugin")) { + if (!state.customComponentMap[component]) { + state.customComponentMap[component] = [id] + } else { + state.customComponentMap[component].push(id) } - cac[component].push(id) } - return { - ...state, - componentsAwaitingConstructors: cac, - mountedComponents: { - ...state.mountedComponents, - [id]: instance, - }, - } + // Register to mounted components + state.mountedComponents[id] = instance + return state }) } const unregisterInstance = id => { store.update(state => { + // Remove from custom component map if required + const component = state.mountedComponents[id]?.instance?.component + let customComponentMap = state.customComponentMap + if (component?.startsWith("plugin")) { + customComponentMap[component] = customComponentMap[component].filter( + x => { + return x !== id + } + ) + } + + // Remove from mounted components delete state.mountedComponents[id] return state }) @@ -133,34 +140,25 @@ const createComponentStore = () => { return customComponentManifest?.[type]?.Component } - const registerCustomComponent = ({ Component, schema }) => { + const registerCustomComponent = ({ Component, schema, version }) => { if (!Component || !schema?.schema?.name) { return } - const componentName = `plugin/${schema.schema.name}/1.0.0` + const component = `plugin/${schema.schema.name}/${version}` store.update(state => { - if (!state.customComponentManifest) { - state.customComponentManifest = {} - } - state.customComponentManifest[componentName] = { - schema, + state.customComponentManifest[component] = { Component, + schema, + version, } return state }) - // Reload any mounted components which depend on this definition + // Reload any mounted instances of this custom component const state = get(store) - if (state.componentsAwaitingConstructors[componentName]?.length) { - state.componentsAwaitingConstructors[componentName].forEach(id => { - const instance = state.mountedComponents[id] - if (instance) { - instance.reload() - } - }) - store.update(state => { - delete state.componentsAwaitingConstructors[componentName] - return state + if (state.customComponentMap[component]?.length) { + state.customComponentMap[component].forEach(id => { + state.mountedComponents[id]?.reload() }) } } From 233d5e190c2c27a91e8c0d97cda3dacabd115e20 Mon Sep 17 00:00:00 2001 From: Andrew Kingston Date: Fri, 12 Aug 2022 14:34:02 +0100 Subject: [PATCH 028/203] Use friendly name in new component panel if available --- .../[componentId]/new/_components/NewComponentPanel.svelte | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/packages/builder/src/pages/builder/app/[application]/design/[screenId]/components/[componentId]/new/_components/NewComponentPanel.svelte b/packages/builder/src/pages/builder/app/[application]/design/[screenId]/components/[componentId]/new/_components/NewComponentPanel.svelte index a5d77c32ca..b0cd544977 100644 --- a/packages/builder/src/pages/builder/app/[application]/design/[screenId]/components/[componentId]/new/_components/NewComponentPanel.svelte +++ b/packages/builder/src/pages/builder/app/[application]/design/[screenId]/components/[componentId]/new/_components/NewComponentPanel.svelte @@ -58,7 +58,10 @@ enrichedStructure.push({ name: "Custom components", isCategory: true, - children: customComponents.map(x => definitions[x]), + children: customComponents.map(x => ({ + ...definitions[x], + name: definitions[x].friendlyName || definitions[x].name, + })), }) } From 83c072fe48b6e63bc0bb41c48a39b48bba86ca3d Mon Sep 17 00:00:00 2001 From: Andrew Kingston Date: Fri, 12 Aug 2022 14:34:16 +0100 Subject: [PATCH 029/203] Show success after uploading plugin --- .../src/pages/builder/portal/settings/organisation.svelte | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/builder/src/pages/builder/portal/settings/organisation.svelte b/packages/builder/src/pages/builder/portal/settings/organisation.svelte index d34442f886..d52bd66d47 100644 --- a/packages/builder/src/pages/builder/portal/settings/organisation.svelte +++ b/packages/builder/src/pages/builder/portal/settings/organisation.svelte @@ -39,6 +39,7 @@ let data = new FormData() data.append("file", $values.logo) await API.uploadPlugin(data) + notifications.success("Plugin uploaded successfully") } catch (error) { notifications.error("Error uploading logo") } From b549fe114b5fcc3f1394006e4b0ebdf88fe57951 Mon Sep 17 00:00:00 2001 From: Andrew Kingston Date: Fri, 12 Aug 2022 14:34:44 +0100 Subject: [PATCH 030/203] Remove uncecessary calls to loadBudibase when registering a plugin at runtime --- packages/client/src/index.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/packages/client/src/index.js b/packages/client/src/index.js index bef3ab9c12..a795d8d2d9 100644 --- a/packages/client/src/index.js +++ b/packages/client/src/index.js @@ -40,17 +40,17 @@ const loadBudibase = () => { devToolsStore.actions.setEnabled(enableDevTools) // Register any custom components - window.registerCustomComponent = plugin => { - componentStore.actions.registerCustomComponent(plugin) - console.log("registered!") - loadBudibase() - } if (window["##BUDIBASE_CUSTOM_COMPONENTS##"]) { window["##BUDIBASE_CUSTOM_COMPONENTS##"].forEach(component => { componentStore.actions.registerCustomComponent(component) }) } + // Make a callback available for custom component bundles to register + // themselves at runtime + window.registerCustomComponent = + componentStore.actions.registerCustomComponent + // Create app if one hasn't been created yet if (!app) { app = new ClientApp({ From e9fc30afda1d2975eccc45495c4c4c401e53dbcb Mon Sep 17 00:00:00 2001 From: Andrew Kingston Date: Fri, 12 Aug 2022 14:41:37 +0100 Subject: [PATCH 031/203] Overwrite existing plugins of the same name and version --- packages/server/src/api/controllers/plugin.ts | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/packages/server/src/api/controllers/plugin.ts b/packages/server/src/api/controllers/plugin.ts index f76d2871b0..4afa59cd3a 100644 --- a/packages/server/src/api/controllers/plugin.ts +++ b/packages/server/src/api/controllers/plugin.ts @@ -32,19 +32,18 @@ export async function upload(ctx: any) { } const jsFileName = jsFile.name const pluginId = generatePluginID(name, version) - let existing + + // overwrite existing docs entirely if they exist + let rev try { - existing = await db.get(pluginId) + const existing = await db.get(pluginId) + rev = existing._rev } catch (err) { - existing = null - } - if (existing) { - throw new Error( - `Plugin already exists: name: ${name}, version: ${version}` - ) + rev = null } const doc = { _id: pluginId, + _rev: rev, name, version, description, From 449905116eeb0eb10622e1ab5e65e64d8285661d Mon Sep 17 00:00:00 2001 From: Andrew Kingston Date: Fri, 12 Aug 2022 16:19:29 +0100 Subject: [PATCH 032/203] Fix rev when uploading a new plugin --- packages/server/src/api/controllers/plugin.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/server/src/api/controllers/plugin.ts b/packages/server/src/api/controllers/plugin.ts index 4afa59cd3a..6b9a2f8803 100644 --- a/packages/server/src/api/controllers/plugin.ts +++ b/packages/server/src/api/controllers/plugin.ts @@ -39,7 +39,7 @@ export async function upload(ctx: any) { const existing = await db.get(pluginId) rev = existing._rev } catch (err) { - rev = null + rev = undefined } const doc = { _id: pluginId, From 97466f183bb171f8f832c7a30cd2a7aeadef4aee Mon Sep 17 00:00:00 2001 From: mike12345567 Date: Fri, 12 Aug 2022 17:03:06 +0100 Subject: [PATCH 033/203] Making integrations more like what custom integrations look like (to simplify integration). --- .../server/src/api/controllers/integration.js | 8 +- packages/server/src/api/controllers/plugin.ts | 24 +- packages/server/src/integrations/airtable.ts | 250 +++--- packages/server/src/integrations/arangodb.ts | 182 ++-- packages/server/src/integrations/couchdb.ts | 180 ++-- packages/server/src/integrations/dynamodb.ts | 424 +++++----- .../server/src/integrations/elasticsearch.ts | 266 +++--- packages/server/src/integrations/firebase.ts | 328 ++++---- .../server/src/integrations/googlesheets.ts | 735 ++++++++--------- packages/server/src/integrations/index.ts | 45 +- .../src/integrations/microsoftSqlServer.ts | 548 ++++++------ packages/server/src/integrations/mongodb.ts | 574 +++++++------ packages/server/src/integrations/mysql.ts | 487 ++++++----- packages/server/src/integrations/oracle.ts | 779 +++++++++--------- packages/server/src/integrations/postgres.ts | 574 +++++++------ packages/server/src/integrations/redis.ts | 258 +++--- packages/server/src/integrations/rest.ts | 657 ++++++++------- packages/server/src/integrations/s3.ts | 139 ++-- packages/server/src/integrations/snowflake.ts | 170 ++-- packages/types/src/documents/index.ts | 1 + packages/types/src/documents/plugin/index.ts | 4 + 21 files changed, 3297 insertions(+), 3336 deletions(-) create mode 100644 packages/types/src/documents/plugin/index.ts diff --git a/packages/server/src/api/controllers/integration.js b/packages/server/src/api/controllers/integration.js index cc9efac93a..ae9be7e6fe 100644 --- a/packages/server/src/api/controllers/integration.js +++ b/packages/server/src/api/controllers/integration.js @@ -1,12 +1,11 @@ -const { cloneDeep } = require("lodash") -const { definitions } = require("../../integrations") +const { getDefinitions } = require("../../integrations") const { SourceName } = require("@budibase/types") const googlesheets = require("../../integrations/googlesheets") const { featureFlags } = require("@budibase/backend-core") exports.fetch = async function (ctx) { ctx.status = 200 - const defs = cloneDeep(definitions) + const defs = await getDefinitions() // for google sheets integration google verification if (featureFlags.isEnabled(featureFlags.FeatureFlag.GOOGLE_SHEETS)) { @@ -17,6 +16,7 @@ exports.fetch = async function (ctx) { } exports.find = async function (ctx) { + const defs = await getDefinitions() ctx.status = 200 - ctx.body = definitions[ctx.params.type] + ctx.body = defs[ctx.params.type] } diff --git a/packages/server/src/api/controllers/plugin.ts b/packages/server/src/api/controllers/plugin.ts index f76d2871b0..218d59127c 100644 --- a/packages/server/src/api/controllers/plugin.ts +++ b/packages/server/src/api/controllers/plugin.ts @@ -3,6 +3,22 @@ import { extractPluginTarball } from "../../utilities/fileSystem" import { getGlobalDB } from "@budibase/backend-core/tenancy" import { generatePluginID, getPluginParams } from "../../db/utils" import { uploadDirectory } from "@budibase/backend-core/objectStore" +import { PluginType } from "@budibase/types" + +export async function getPlugins(type?: PluginType) { + const db = getGlobalDB() + const response = await db.allDocs( + getPluginParams(null, { + include_docs: true, + }) + ) + const plugins = response.rows.map((row: any) => row.doc) + if (type) { + return plugins.filter((plugin: any) => plugin.schema?.type === type) + } else { + return plugins + } +} export async function upload(ctx: any) { const plugins = @@ -68,13 +84,7 @@ export async function upload(ctx: any) { } export async function fetch(ctx: any) { - const db = getGlobalDB() - const response = await db.allDocs( - getPluginParams(null, { - include_docs: true, - }) - ) - ctx.body = response.rows.map((row: any) => row.doc) + ctx.body = await getPlugins() } export async function destroy(ctx: any) {} diff --git a/packages/server/src/integrations/airtable.ts b/packages/server/src/integrations/airtable.ts index e4c941b21c..1f56f0619b 100644 --- a/packages/server/src/integrations/airtable.ts +++ b/packages/server/src/integrations/airtable.ts @@ -5,146 +5,144 @@ import { IntegrationBase, } from "@budibase/types" -module AirtableModule { - const Airtable = require("airtable") +const Airtable = require("airtable") - interface AirtableConfig { - apiKey: string - base: string - } +interface AirtableConfig { + apiKey: string + base: string +} - const SCHEMA: Integration = { - docs: "https://airtable.com/api", - description: - "Airtable is a spreadsheet-database hybrid, with the features of a database but applied to a spreadsheet.", - friendlyName: "Airtable", - type: "Spreadsheet", - datasource: { - apiKey: { - type: DatasourceFieldType.PASSWORD, - default: "enter api key", - required: true, - }, - base: { - type: DatasourceFieldType.STRING, - default: "mybase", - required: true, +const SCHEMA: Integration = { + docs: "https://airtable.com/api", + description: + "Airtable is a spreadsheet-database hybrid, with the features of a database but applied to a spreadsheet.", + friendlyName: "Airtable", + type: "Spreadsheet", + datasource: { + apiKey: { + type: DatasourceFieldType.PASSWORD, + default: "enter api key", + required: true, + }, + base: { + type: DatasourceFieldType.STRING, + default: "mybase", + required: true, + }, + }, + query: { + create: { + type: QueryType.FIELDS, + customisable: true, + fields: { + table: { + type: DatasourceFieldType.STRING, + required: true, + }, }, }, - query: { - create: { - type: QueryType.FIELDS, - customisable: true, - fields: { - table: { - type: DatasourceFieldType.STRING, - required: true, - }, + read: { + type: QueryType.FIELDS, + fields: { + table: { + type: DatasourceFieldType.STRING, + required: true, }, - }, - read: { - type: QueryType.FIELDS, - fields: { - table: { - type: DatasourceFieldType.STRING, - required: true, - }, - view: { - type: DatasourceFieldType.STRING, - required: true, - }, - numRecords: { - type: DatasourceFieldType.NUMBER, - default: 10, - }, + view: { + type: DatasourceFieldType.STRING, + required: true, }, - }, - update: { - type: QueryType.FIELDS, - customisable: true, - fields: { - id: { - display: "Record ID", - type: DatasourceFieldType.STRING, - required: true, - }, - table: { - type: DatasourceFieldType.STRING, - required: true, - }, + numRecords: { + type: DatasourceFieldType.NUMBER, + default: 10, }, }, - delete: { - type: QueryType.JSON, - }, }, + update: { + type: QueryType.FIELDS, + customisable: true, + fields: { + id: { + display: "Record ID", + type: DatasourceFieldType.STRING, + required: true, + }, + table: { + type: DatasourceFieldType.STRING, + required: true, + }, + }, + }, + delete: { + type: QueryType.JSON, + }, + }, +} + +class AirtableIntegration implements IntegrationBase { + private config: AirtableConfig + private client: any + + constructor(config: AirtableConfig) { + this.config = config + this.client = new Airtable(config).base(config.base) } - class AirtableIntegration implements IntegrationBase { - private config: AirtableConfig - private client: any + async create(query: { table: any; json: any }) { + const { table, json } = query - constructor(config: AirtableConfig) { - this.config = config - this.client = new Airtable(config).base(config.base) - } - - async create(query: { table: any; json: any }) { - const { table, json } = query - - try { - return await this.client(table).create([ - { - fields: json, - }, - ]) - } catch (err) { - console.error("Error writing to airtable", err) - throw err - } - } - - async read(query: { table: any; numRecords: any; view: any }) { - try { - const records = await this.client(query.table) - .select({ maxRecords: query.numRecords || 10, view: query.view }) - .firstPage() - // @ts-ignore - return records.map(({ fields }) => fields) - } catch (err) { - console.error("Error writing to airtable", err) - return [] - } - } - - async update(query: { table: any; id: any; json: any }) { - const { table, id, json } = query - - try { - return await this.client(table).update([ - { - id, - fields: json, - }, - ]) - } catch (err) { - console.error("Error writing to airtable", err) - throw err - } - } - - async delete(query: { table: any; ids: any }) { - try { - return await this.client(query.table).destroy(query.ids) - } catch (err) { - console.error("Error writing to airtable", err) - throw err - } + try { + return await this.client(table).create([ + { + fields: json, + }, + ]) + } catch (err) { + console.error("Error writing to airtable", err) + throw err } } - module.exports = { - schema: SCHEMA, - integration: AirtableIntegration, + async read(query: { table: any; numRecords: any; view: any }) { + try { + const records = await this.client(query.table) + .select({ maxRecords: query.numRecords || 10, view: query.view }) + .firstPage() + // @ts-ignore + return records.map(({ fields }) => fields) + } catch (err) { + console.error("Error writing to airtable", err) + return [] + } + } + + async update(query: { table: any; id: any; json: any }) { + const { table, id, json } = query + + try { + return await this.client(table).update([ + { + id, + fields: json, + }, + ]) + } catch (err) { + console.error("Error writing to airtable", err) + throw err + } + } + + async delete(query: { table: any; ids: any }) { + try { + return await this.client(query.table).destroy(query.ids) + } catch (err) { + console.error("Error writing to airtable", err) + throw err + } } } + +export default { + schema: SCHEMA, + integration: AirtableIntegration, +} diff --git a/packages/server/src/integrations/arangodb.ts b/packages/server/src/integrations/arangodb.ts index 968197474a..6df96501a4 100644 --- a/packages/server/src/integrations/arangodb.ts +++ b/packages/server/src/integrations/arangodb.ts @@ -5,106 +5,104 @@ import { IntegrationBase, } from "@budibase/types" -module ArangoModule { - const { Database, aql } = require("arangojs") +const { Database, aql } = require("arangojs") - interface ArangodbConfig { - url: string - username: string - password: string - databaseName: string - collection: string - } +interface ArangodbConfig { + url: string + username: string + password: string + databaseName: string + collection: string +} - const SCHEMA: Integration = { - docs: "https://github.com/arangodb/arangojs", - friendlyName: "ArangoDB", - type: "Non-relational", - description: - "ArangoDB is a scalable open-source multi-model database natively supporting graph, document and search. All supported data models & access patterns can be combined in queries allowing for maximal flexibility. ", - datasource: { - url: { - type: DatasourceFieldType.STRING, - default: "http://localhost:8529", - required: true, - }, - username: { - type: DatasourceFieldType.STRING, - default: "root", - required: true, - }, - password: { - type: DatasourceFieldType.PASSWORD, - required: true, - }, - databaseName: { - type: DatasourceFieldType.STRING, - default: "_system", - required: true, - }, - collection: { - type: DatasourceFieldType.STRING, - required: true, - }, +const SCHEMA: Integration = { + docs: "https://github.com/arangodb/arangojs", + friendlyName: "ArangoDB", + type: "Non-relational", + description: + "ArangoDB is a scalable open-source multi-model database natively supporting graph, document and search. All supported data models & access patterns can be combined in queries allowing for maximal flexibility. ", + datasource: { + url: { + type: DatasourceFieldType.STRING, + default: "http://localhost:8529", + required: true, }, - query: { - read: { - type: QueryType.SQL, - }, - create: { - type: QueryType.JSON, - }, + username: { + type: DatasourceFieldType.STRING, + default: "root", + required: true, }, + password: { + type: DatasourceFieldType.PASSWORD, + required: true, + }, + databaseName: { + type: DatasourceFieldType.STRING, + default: "_system", + required: true, + }, + collection: { + type: DatasourceFieldType.STRING, + required: true, + }, + }, + query: { + read: { + type: QueryType.SQL, + }, + create: { + type: QueryType.JSON, + }, + }, +} + +class ArangoDBIntegration implements IntegrationBase { + private config: ArangodbConfig + private client: any + + constructor(config: ArangodbConfig) { + const newConfig = { + auth: { + username: config.username, + password: config.password, + }, + } + + this.config = config + this.client = new Database(newConfig) } - class ArangoDBIntegration implements IntegrationBase { - private config: ArangodbConfig - private client: any - - constructor(config: ArangodbConfig) { - const newConfig = { - auth: { - username: config.username, - password: config.password, - }, - } - - this.config = config - this.client = new Database(newConfig) - } - - async read(query: { sql: any }) { - try { - const result = await this.client.query(query.sql) - return result.all() - } catch (err) { - // @ts-ignore - console.error("Error querying arangodb", err.message) - throw err - } finally { - this.client.close() - } - } - - async create(query: { json: any }) { - const clc = this.client.collection(this.config.collection) - try { - const result = await this.client.query( - aql`INSERT ${query.json} INTO ${clc} RETURN NEW` - ) - return result.all() - } catch (err) { - // @ts-ignore - console.error("Error querying arangodb", err.message) - throw err - } finally { - this.client.close() - } + async read(query: { sql: any }) { + try { + const result = await this.client.query(query.sql) + return result.all() + } catch (err) { + // @ts-ignore + console.error("Error querying arangodb", err.message) + throw err + } finally { + this.client.close() } } - module.exports = { - schema: SCHEMA, - integration: ArangoDBIntegration, + async create(query: { json: any }) { + const clc = this.client.collection(this.config.collection) + try { + const result = await this.client.query( + aql`INSERT ${query.json} INTO ${clc} RETURN NEW` + ) + return result.all() + } catch (err) { + // @ts-ignore + console.error("Error querying arangodb", err.message) + throw err + } finally { + this.client.close() + } } } + +export default { + schema: SCHEMA, + integration: ArangoDBIntegration, +} diff --git a/packages/server/src/integrations/couchdb.ts b/packages/server/src/integrations/couchdb.ts index c23593dbd4..67be21c9d1 100644 --- a/packages/server/src/integrations/couchdb.ts +++ b/packages/server/src/integrations/couchdb.ts @@ -5,109 +5,103 @@ import { IntegrationBase, } from "@budibase/types" -module CouchDBModule { - const PouchDB = require("pouchdb") +const PouchDB = require("pouchdb") - interface CouchDBConfig { - url: string - database: string - } +interface CouchDBConfig { + url: string + database: string +} - const SCHEMA: Integration = { - docs: "https://docs.couchdb.org/en/stable/", - friendlyName: "CouchDB", - type: "Non-relational", - description: - "Apache CouchDB is an open-source document-oriented NoSQL database, implemented in Erlang.", - datasource: { - url: { - type: DatasourceFieldType.STRING, - required: true, - default: "http://localhost:5984", - }, - database: { - type: DatasourceFieldType.STRING, - required: true, - }, +const SCHEMA: Integration = { + docs: "https://docs.couchdb.org/en/stable/", + friendlyName: "CouchDB", + type: "Non-relational", + description: + "Apache CouchDB is an open-source document-oriented NoSQL database, implemented in Erlang.", + datasource: { + url: { + type: DatasourceFieldType.STRING, + required: true, + default: "http://localhost:5984", }, - query: { - create: { - type: QueryType.JSON, - }, - read: { - type: QueryType.JSON, - }, - update: { - type: QueryType.JSON, - }, - delete: { - type: QueryType.FIELDS, - fields: { - id: { - type: DatasourceFieldType.STRING, - required: true, - }, + database: { + type: DatasourceFieldType.STRING, + required: true, + }, + }, + query: { + create: { + type: QueryType.JSON, + }, + read: { + type: QueryType.JSON, + }, + update: { + type: QueryType.JSON, + }, + delete: { + type: QueryType.FIELDS, + fields: { + id: { + type: DatasourceFieldType.STRING, + required: true, }, }, }, + }, +} + +class CouchDBIntegration implements IntegrationBase { + private config: CouchDBConfig + private readonly client: any + + constructor(config: CouchDBConfig) { + this.config = config + this.client = new PouchDB(`${config.url}/${config.database}`) } - class CouchDBIntegration implements IntegrationBase { - private config: CouchDBConfig - private readonly client: any - - constructor(config: CouchDBConfig) { - this.config = config - this.client = new PouchDB(`${config.url}/${config.database}`) - } - - async query( - command: string, - errorMsg: string, - query: { json?: object; id?: string } - ) { - try { - const response = await this.client[command](query.id || query.json) - await this.client.close() - return response - } catch (err) { - console.error(errorMsg, err) - throw err - } - } - - async create(query: { json: object }) { - return this.query("post", "Error writing to couchDB", query) - } - - async read(query: { json: object }) { - const result = await this.query("allDocs", "Error querying couchDB", { - json: { - include_docs: true, - ...query.json, - }, - }) - return result.rows.map((row: { doc: object }) => row.doc) - } - - async update(query: { json: object }) { - return this.query("put", "Error updating couchDB document", query) - } - - async delete(query: { id: string }) { - const doc = await this.query( - "get", - "Cannot find doc to be deleted", - query - ) - return this.query("remove", "Error deleting couchDB document", { - json: doc, - }) + async query( + command: string, + errorMsg: string, + query: { json?: object; id?: string } + ) { + try { + const response = await this.client[command](query.id || query.json) + await this.client.close() + return response + } catch (err) { + console.error(errorMsg, err) + throw err } } - module.exports = { - schema: SCHEMA, - integration: CouchDBIntegration, + async create(query: { json: object }) { + return this.query("post", "Error writing to couchDB", query) + } + + async read(query: { json: object }) { + const result = await this.query("allDocs", "Error querying couchDB", { + json: { + include_docs: true, + ...query.json, + }, + }) + return result.rows.map((row: { doc: object }) => row.doc) + } + + async update(query: { json: object }) { + return this.query("put", "Error updating couchDB document", query) + } + + async delete(query: { id: string }) { + const doc = await this.query("get", "Cannot find doc to be deleted", query) + return this.query("remove", "Error deleting couchDB document", { + json: doc, + }) } } + +export default { + schema: SCHEMA, + integration: CouchDBIntegration, +} diff --git a/packages/server/src/integrations/dynamodb.ts b/packages/server/src/integrations/dynamodb.ts index 5321da4791..8dea6c6213 100644 --- a/packages/server/src/integrations/dynamodb.ts +++ b/packages/server/src/integrations/dynamodb.ts @@ -5,228 +5,226 @@ import { IntegrationBase, } from "@budibase/types" -module DynamoModule { - const AWS = require("aws-sdk") - const { AWS_REGION } = require("../db/dynamoClient") +const AWS = require("aws-sdk") +const { AWS_REGION } = require("../db/dynamoClient") - interface DynamoDBConfig { - region: string - accessKeyId: string - secretAccessKey: string - endpoint: string - } +interface DynamoDBConfig { + region: string + accessKeyId: string + secretAccessKey: string + endpoint: string +} - const SCHEMA: Integration = { - docs: "https://github.com/dabit3/dynamodb-documentclient-cheat-sheet", - description: - "Amazon DynamoDB is a key-value and document database that delivers single-digit millisecond performance at any scale.", - friendlyName: "DynamoDB", - type: "Non-relational", - datasource: { - region: { - type: DatasourceFieldType.STRING, - required: true, - default: "us-east-1", - }, - accessKeyId: { - type: DatasourceFieldType.PASSWORD, - required: true, - }, - secretAccessKey: { - type: DatasourceFieldType.PASSWORD, - required: true, - }, - endpoint: { - type: DatasourceFieldType.STRING, - required: false, - default: "https://dynamodb.us-east-1.amazonaws.com", - }, +const SCHEMA: Integration = { + docs: "https://github.com/dabit3/dynamodb-documentclient-cheat-sheet", + description: + "Amazon DynamoDB is a key-value and document database that delivers single-digit millisecond performance at any scale.", + friendlyName: "DynamoDB", + type: "Non-relational", + datasource: { + region: { + type: DatasourceFieldType.STRING, + required: true, + default: "us-east-1", }, - query: { - create: { - type: QueryType.FIELDS, - customisable: true, - fields: { - table: { - type: DatasourceFieldType.STRING, - required: true, - }, - }, - }, - read: { - type: QueryType.FIELDS, - customisable: true, - readable: true, - fields: { - table: { - type: DatasourceFieldType.STRING, - required: true, - }, - index: { - type: DatasourceFieldType.STRING, - }, - }, - }, - scan: { - type: QueryType.FIELDS, - customisable: true, - readable: true, - fields: { - table: { - type: DatasourceFieldType.STRING, - required: true, - }, - index: { - type: DatasourceFieldType.STRING, - }, - }, - }, - describe: { - type: QueryType.FIELDS, - customisable: true, - readable: true, - fields: { - table: { - type: DatasourceFieldType.STRING, - required: true, - }, - }, - }, - get: { - type: QueryType.FIELDS, - customisable: true, - readable: true, - fields: { - table: { - type: DatasourceFieldType.STRING, - required: true, - }, - }, - }, - update: { - type: QueryType.FIELDS, - customisable: true, - fields: { - table: { - type: DatasourceFieldType.STRING, - required: true, - }, - }, - }, - delete: { - type: QueryType.FIELDS, - customisable: true, - fields: { - table: { - type: DatasourceFieldType.STRING, - required: true, - }, + accessKeyId: { + type: DatasourceFieldType.PASSWORD, + required: true, + }, + secretAccessKey: { + type: DatasourceFieldType.PASSWORD, + required: true, + }, + endpoint: { + type: DatasourceFieldType.STRING, + required: false, + default: "https://dynamodb.us-east-1.amazonaws.com", + }, + }, + query: { + create: { + type: QueryType.FIELDS, + customisable: true, + fields: { + table: { + type: DatasourceFieldType.STRING, + required: true, }, }, }, + read: { + type: QueryType.FIELDS, + customisable: true, + readable: true, + fields: { + table: { + type: DatasourceFieldType.STRING, + required: true, + }, + index: { + type: DatasourceFieldType.STRING, + }, + }, + }, + scan: { + type: QueryType.FIELDS, + customisable: true, + readable: true, + fields: { + table: { + type: DatasourceFieldType.STRING, + required: true, + }, + index: { + type: DatasourceFieldType.STRING, + }, + }, + }, + describe: { + type: QueryType.FIELDS, + customisable: true, + readable: true, + fields: { + table: { + type: DatasourceFieldType.STRING, + required: true, + }, + }, + }, + get: { + type: QueryType.FIELDS, + customisable: true, + readable: true, + fields: { + table: { + type: DatasourceFieldType.STRING, + required: true, + }, + }, + }, + update: { + type: QueryType.FIELDS, + customisable: true, + fields: { + table: { + type: DatasourceFieldType.STRING, + required: true, + }, + }, + }, + delete: { + type: QueryType.FIELDS, + customisable: true, + fields: { + table: { + type: DatasourceFieldType.STRING, + required: true, + }, + }, + }, + }, +} + +class DynamoDBIntegration implements IntegrationBase { + private config: DynamoDBConfig + private client: any + + constructor(config: DynamoDBConfig) { + this.config = config + if (this.config.endpoint && !this.config.endpoint.includes("localhost")) { + this.connect() + } + let options = { + correctClockSkew: true, + region: this.config.region || AWS_REGION, + endpoint: config.endpoint ? config.endpoint : undefined, + } + this.client = new AWS.DynamoDB.DocumentClient(options) } - class DynamoDBIntegration implements IntegrationBase { - private config: DynamoDBConfig - private client: any - - constructor(config: DynamoDBConfig) { - this.config = config - if (this.config.endpoint && !this.config.endpoint.includes("localhost")) { - this.connect() - } - let options = { - correctClockSkew: true, - region: this.config.region || AWS_REGION, - endpoint: config.endpoint ? config.endpoint : undefined, - } - this.client = new AWS.DynamoDB.DocumentClient(options) - } - - end() { - this.disconnect() - } - - connect() { - AWS.config.update(this.config) - } - - disconnect() { - AWS.config.update({ - secretAccessKey: undefined, - accessKeyId: undefined, - region: AWS_REGION, - }) - } - - async create(query: { table: string; json: object }) { - const params = { - TableName: query.table, - ...query.json, - } - return this.client.put(params).promise() - } - - async read(query: { table: string; json: object; index: null | string }) { - const params = { - TableName: query.table, - IndexName: query.index ? query.index : undefined, - ...query.json, - } - const response = await this.client.query(params).promise() - if (response.Items) { - return response.Items - } - return response - } - - async scan(query: { table: string; json: object; index: null | string }) { - const params = { - TableName: query.table, - IndexName: query.index ? query.index : undefined, - ...query.json, - } - const response = await this.client.scan(params).promise() - if (response.Items) { - return response.Items - } - return response - } - - async describe(query: { table: string }) { - const params = { - TableName: query.table, - } - return new AWS.DynamoDB().describeTable(params).promise() - } - - async get(query: { table: string; json: object }) { - const params = { - TableName: query.table, - ...query.json, - } - return this.client.get(params).promise() - } - - async update(query: { table: string; json: object }) { - const params = { - TableName: query.table, - ...query.json, - } - return this.client.update(params).promise() - } - - async delete(query: { table: string; json: object }) { - const params = { - TableName: query.table, - ...query.json, - } - return this.client.delete(params).promise() - } + end() { + this.disconnect() } - module.exports = { - schema: SCHEMA, - integration: DynamoDBIntegration, + connect() { + AWS.config.update(this.config) + } + + disconnect() { + AWS.config.update({ + secretAccessKey: undefined, + accessKeyId: undefined, + region: AWS_REGION, + }) + } + + async create(query: { table: string; json: object }) { + const params = { + TableName: query.table, + ...query.json, + } + return this.client.put(params).promise() + } + + async read(query: { table: string; json: object; index: null | string }) { + const params = { + TableName: query.table, + IndexName: query.index ? query.index : undefined, + ...query.json, + } + const response = await this.client.query(params).promise() + if (response.Items) { + return response.Items + } + return response + } + + async scan(query: { table: string; json: object; index: null | string }) { + const params = { + TableName: query.table, + IndexName: query.index ? query.index : undefined, + ...query.json, + } + const response = await this.client.scan(params).promise() + if (response.Items) { + return response.Items + } + return response + } + + async describe(query: { table: string }) { + const params = { + TableName: query.table, + } + return new AWS.DynamoDB().describeTable(params).promise() + } + + async get(query: { table: string; json: object }) { + const params = { + TableName: query.table, + ...query.json, + } + return this.client.get(params).promise() + } + + async update(query: { table: string; json: object }) { + const params = { + TableName: query.table, + ...query.json, + } + return this.client.update(params).promise() + } + + async delete(query: { table: string; json: object }) { + const params = { + TableName: query.table, + ...query.json, + } + return this.client.delete(params).promise() } } + +export default { + schema: SCHEMA, + integration: DynamoDBIntegration, +} diff --git a/packages/server/src/integrations/elasticsearch.ts b/packages/server/src/integrations/elasticsearch.ts index 5c61545ecd..14887a743d 100644 --- a/packages/server/src/integrations/elasticsearch.ts +++ b/packages/server/src/integrations/elasticsearch.ts @@ -5,151 +5,149 @@ import { IntegrationBase, } from "@budibase/types" -module ElasticsearchModule { - const { Client } = require("@elastic/elasticsearch") +const { Client } = require("@elastic/elasticsearch") - interface ElasticsearchConfig { - url: string - } +interface ElasticsearchConfig { + url: string +} - const SCHEMA: Integration = { - docs: "https://www.elastic.co/guide/en/elasticsearch/client/javascript-api/current/index.html", - description: - "Elasticsearch is a search engine based on the Lucene library. It provides a distributed, multitenant-capable full-text search engine with an HTTP web interface and schema-free JSON documents.", - friendlyName: "ElasticSearch", - type: "Non-relational", - datasource: { - url: { - type: DatasourceFieldType.STRING, - required: true, - default: "http://localhost:9200", - }, +const SCHEMA: Integration = { + docs: "https://www.elastic.co/guide/en/elasticsearch/client/javascript-api/current/index.html", + description: + "Elasticsearch is a search engine based on the Lucene library. It provides a distributed, multitenant-capable full-text search engine with an HTTP web interface and schema-free JSON documents.", + friendlyName: "ElasticSearch", + type: "Non-relational", + datasource: { + url: { + type: DatasourceFieldType.STRING, + required: true, + default: "http://localhost:9200", }, - query: { - create: { - type: QueryType.FIELDS, - customisable: true, - fields: { - index: { - type: DatasourceFieldType.STRING, - required: true, - }, - }, - }, - read: { - type: QueryType.FIELDS, - customisable: true, - fields: { - index: { - type: DatasourceFieldType.STRING, - required: true, - }, - }, - }, - update: { - type: QueryType.FIELDS, - customisable: true, - fields: { - id: { - type: DatasourceFieldType.STRING, - required: true, - }, - index: { - type: DatasourceFieldType.STRING, - required: true, - }, - }, - }, - delete: { - type: QueryType.FIELDS, - fields: { - index: { - type: DatasourceFieldType.STRING, - required: true, - }, - id: { - type: DatasourceFieldType.STRING, - required: true, - }, + }, + query: { + create: { + type: QueryType.FIELDS, + customisable: true, + fields: { + index: { + type: DatasourceFieldType.STRING, + required: true, }, }, }, + read: { + type: QueryType.FIELDS, + customisable: true, + fields: { + index: { + type: DatasourceFieldType.STRING, + required: true, + }, + }, + }, + update: { + type: QueryType.FIELDS, + customisable: true, + fields: { + id: { + type: DatasourceFieldType.STRING, + required: true, + }, + index: { + type: DatasourceFieldType.STRING, + required: true, + }, + }, + }, + delete: { + type: QueryType.FIELDS, + fields: { + index: { + type: DatasourceFieldType.STRING, + required: true, + }, + id: { + type: DatasourceFieldType.STRING, + required: true, + }, + }, + }, + }, +} + +class ElasticSearchIntegration implements IntegrationBase { + private config: ElasticsearchConfig + private client: any + + constructor(config: ElasticsearchConfig) { + this.config = config + this.client = new Client({ node: config.url }) } - class ElasticSearchIntegration implements IntegrationBase { - private config: ElasticsearchConfig - private client: any + async create(query: { index: string; json: object }) { + const { index, json } = query - constructor(config: ElasticsearchConfig) { - this.config = config - this.client = new Client({ node: config.url }) - } - - async create(query: { index: string; json: object }) { - const { index, json } = query - - try { - const result = await this.client.index({ - index, - body: json, - }) - return result.body - } catch (err) { - console.error("Error writing to elasticsearch", err) - throw err - } finally { - await this.client.close() - } - } - - async read(query: { index: string; json: object }) { - const { index, json } = query - try { - const result = await this.client.search({ - index: index, - body: json, - }) - return result.body.hits.hits.map(({ _source }: any) => _source) - } catch (err) { - console.error("Error querying elasticsearch", err) - throw err - } finally { - await this.client.close() - } - } - - async update(query: { id: string; index: string; json: object }) { - const { id, index, json } = query - try { - const result = await this.client.update({ - id, - index, - body: json, - }) - return result.body - } catch (err) { - console.error("Error querying elasticsearch", err) - throw err - } finally { - await this.client.close() - } - } - - async delete(query: object) { - try { - const result = await this.client.delete(query) - return result.body - } catch (err) { - console.error("Error deleting from elasticsearch", err) - throw err - } finally { - await this.client.close() - } + try { + const result = await this.client.index({ + index, + body: json, + }) + return result.body + } catch (err) { + console.error("Error writing to elasticsearch", err) + throw err + } finally { + await this.client.close() } } - module.exports = { - schema: SCHEMA, - integration: ElasticSearchIntegration, + async read(query: { index: string; json: object }) { + const { index, json } = query + try { + const result = await this.client.search({ + index: index, + body: json, + }) + return result.body.hits.hits.map(({ _source }: any) => _source) + } catch (err) { + console.error("Error querying elasticsearch", err) + throw err + } finally { + await this.client.close() + } + } + + async update(query: { id: string; index: string; json: object }) { + const { id, index, json } = query + try { + const result = await this.client.update({ + id, + index, + body: json, + }) + return result.body + } catch (err) { + console.error("Error querying elasticsearch", err) + throw err + } finally { + await this.client.close() + } + } + + async delete(query: object) { + try { + const result = await this.client.delete(query) + return result.body + } catch (err) { + console.error("Error deleting from elasticsearch", err) + throw err + } finally { + await this.client.close() + } } } + +export default { + schema: SCHEMA, + integration: ElasticSearchIntegration, +} diff --git a/packages/server/src/integrations/firebase.ts b/packages/server/src/integrations/firebase.ts index 1f82e9dafe..a82b3be782 100644 --- a/packages/server/src/integrations/firebase.ts +++ b/packages/server/src/integrations/firebase.ts @@ -6,184 +6,182 @@ import { } from "@budibase/types" import { Firestore, WhereFilterOp } from "@google-cloud/firestore" -module Firebase { - interface FirebaseConfig { - email: string - privateKey: string - projectId: string +interface FirebaseConfig { + email: string + privateKey: string + projectId: string +} + +const SCHEMA: Integration = { + docs: "https://firebase.google.com/docs/firestore/quickstart", + friendlyName: "Firestore", + type: "Non-relational", + description: + "Cloud Firestore is a flexible, scalable database for mobile, web, and server development from Firebase and Google Cloud.", + datasource: { + email: { + type: DatasourceFieldType.STRING, + required: true, + }, + privateKey: { + type: DatasourceFieldType.STRING, + required: true, + }, + projectId: { + type: DatasourceFieldType.STRING, + required: true, + }, + }, + query: { + create: { + type: QueryType.JSON, + }, + read: { + type: QueryType.JSON, + }, + update: { + type: QueryType.JSON, + }, + delete: { + type: QueryType.JSON, + }, + }, + extra: { + collection: { + displayName: "Collection", + type: DatasourceFieldType.STRING, + required: true, + }, + filterField: { + displayName: "Filter field", + type: DatasourceFieldType.STRING, + required: false, + }, + filter: { + displayName: "Filter comparison", + type: DatasourceFieldType.LIST, + required: false, + data: { + read: [ + "==", + "<", + "<=", + "!=", + ">=", + ">", + "array-contains", + "in", + "not-in", + "array-contains-any", + ], + }, + }, + filterValue: { + displayName: "Filter value", + type: DatasourceFieldType.STRING, + required: false, + }, + }, +} + +class FirebaseIntegration implements IntegrationBase { + private config: FirebaseConfig + private client: Firestore + + constructor(config: FirebaseConfig) { + this.config = config + this.client = new Firestore({ + projectId: config.projectId, + credentials: { + client_email: config.email, + private_key: config.privateKey?.replace(/\\n/g, "\n"), + }, + }) } - const SCHEMA: Integration = { - docs: "https://firebase.google.com/docs/firestore/quickstart", - friendlyName: "Firestore", - type: "Non-relational", - description: - "Cloud Firestore is a flexible, scalable database for mobile, web, and server development from Firebase and Google Cloud.", - datasource: { - email: { - type: DatasourceFieldType.STRING, - required: true, - }, - privateKey: { - type: DatasourceFieldType.STRING, - required: true, - }, - projectId: { - type: DatasourceFieldType.STRING, - required: true, - }, - }, - query: { - create: { - type: QueryType.JSON, - }, - read: { - type: QueryType.JSON, - }, - update: { - type: QueryType.JSON, - }, - delete: { - type: QueryType.JSON, - }, - }, - extra: { - collection: { - displayName: "Collection", - type: DatasourceFieldType.STRING, - required: true, - }, - filterField: { - displayName: "Filter field", - type: DatasourceFieldType.STRING, - required: false, - }, - filter: { - displayName: "Filter comparison", - type: DatasourceFieldType.LIST, - required: false, - data: { - read: [ - "==", - "<", - "<=", - "!=", - ">=", - ">", - "array-contains", - "in", - "not-in", - "array-contains-any", - ], - }, - }, - filterValue: { - displayName: "Filter value", - type: DatasourceFieldType.STRING, - required: false, - }, - }, + async create(query: { json: object; extra: { [key: string]: string } }) { + try { + const documentReference = this.client + .collection(query.extra.collection) + .doc() + await documentReference.set({ ...query.json, id: documentReference.id }) + const snapshot = await documentReference.get() + return snapshot.data() + } catch (err) { + console.error("Error writing to Firestore", err) + throw err + } } - class FirebaseIntegration implements IntegrationBase { - private config: FirebaseConfig - private client: Firestore - - constructor(config: FirebaseConfig) { - this.config = config - this.client = new Firestore({ - projectId: config.projectId, - credentials: { - client_email: config.email, - private_key: config.privateKey?.replace(/\\n/g, "\n"), - }, - }) - } - - async create(query: { json: object; extra: { [key: string]: string } }) { - try { - const documentReference = this.client - .collection(query.extra.collection) - .doc() - await documentReference.set({ ...query.json, id: documentReference.id }) - const snapshot = await documentReference.get() - return snapshot.data() - } catch (err) { - console.error("Error writing to Firestore", err) - throw err + async read(query: { json: object; extra: { [key: string]: string } }) { + try { + let snapshot + const collectionRef = this.client.collection(query.extra.collection) + if ( + query.extra.filterField && + query.extra.filter && + query.extra.filterValue + ) { + snapshot = await collectionRef + .where( + query.extra.filterField, + query.extra.filter as WhereFilterOp, + query.extra.filterValue + ) + .get() + } else { + snapshot = await collectionRef.get() } + const result: any[] = [] + snapshot.forEach(doc => result.push(doc.data())) + + return result + } catch (err) { + console.error("Error querying Firestore", err) + throw err } + } - async read(query: { json: object; extra: { [key: string]: string } }) { - try { - let snapshot - const collectionRef = this.client.collection(query.extra.collection) - if ( - query.extra.filterField && - query.extra.filter && - query.extra.filterValue - ) { - snapshot = await collectionRef - .where( - query.extra.filterField, - query.extra.filter as WhereFilterOp, - query.extra.filterValue - ) - .get() - } else { - snapshot = await collectionRef.get() - } - const result: any[] = [] - snapshot.forEach(doc => result.push(doc.data())) + async update(query: { + json: Record + extra: { [key: string]: string } + }) { + try { + await this.client + .collection(query.extra.collection) + .doc(query.json.id) + .update(query.json) - return result - } catch (err) { - console.error("Error querying Firestore", err) - throw err - } - } - - async update(query: { - json: Record - extra: { [key: string]: string } - }) { - try { + return ( await this.client .collection(query.extra.collection) .doc(query.json.id) - .update(query.json) - - return ( - await this.client - .collection(query.extra.collection) - .doc(query.json.id) - .get() - ).data() - } catch (err) { - console.error("Error writing to Firestore", err) - throw err - } - } - - async delete(query: { - json: { id: string } - extra: { [key: string]: string } - }) { - try { - await this.client - .collection(query.extra.collection) - .doc(query.json.id) - .delete() - return true - } catch (err) { - console.error("Error deleting from Firestore", err) - throw err - } + .get() + ).data() + } catch (err) { + console.error("Error writing to Firestore", err) + throw err } } - module.exports = { - schema: SCHEMA, - integration: FirebaseIntegration, + async delete(query: { + json: { id: string } + extra: { [key: string]: string } + }) { + try { + await this.client + .collection(query.extra.collection) + .doc(query.json.id) + .delete() + return true + } catch (err) { + console.error("Error deleting from Firestore", err) + throw err + } } } + +export default { + schema: SCHEMA, + integration: FirebaseIntegration, +} diff --git a/packages/server/src/integrations/googlesheets.ts b/packages/server/src/integrations/googlesheets.ts index 129ab485cd..675e28e159 100644 --- a/packages/server/src/integrations/googlesheets.ts +++ b/packages/server/src/integrations/googlesheets.ts @@ -13,409 +13,400 @@ import { DataSourceOperation, FieldTypes } from "../constants" import { GoogleSpreadsheet } from "google-spreadsheet" import env from "../environment" -module GoogleSheetsModule { - const { getGlobalDB } = require("@budibase/backend-core/tenancy") - const { getScopedConfig } = require("@budibase/backend-core/db") - const { Configs } = require("@budibase/backend-core/constants") - const fetch = require("node-fetch") +const { getGlobalDB } = require("@budibase/backend-core/tenancy") +const { getScopedConfig } = require("@budibase/backend-core/db") +const { Configs } = require("@budibase/backend-core/constants") +const fetch = require("node-fetch") - interface GoogleSheetsConfig { - spreadsheetId: string - auth: OAuthClientConfig - } +interface GoogleSheetsConfig { + spreadsheetId: string + auth: OAuthClientConfig +} - interface OAuthClientConfig { - appId: string - accessToken: string - refreshToken: string - } +interface OAuthClientConfig { + appId: string + accessToken: string + refreshToken: string +} - interface AuthTokenRequest { - client_id: string - client_secret: string - refresh_token: string - } +interface AuthTokenRequest { + client_id: string + client_secret: string + refresh_token: string +} - interface AuthTokenResponse { - access_token: string - } +interface AuthTokenResponse { + access_token: string +} - const SCHEMA: Integration = { - plus: true, - auth: { - type: "google", +const SCHEMA: Integration = { + plus: true, + auth: { + type: "google", + }, + relationships: false, + docs: "https://developers.google.com/sheets/api/quickstart/nodejs", + description: + "Create and collaborate on online spreadsheets in real-time and from any device. ", + friendlyName: "Google Sheets", + type: "Spreadsheet", + datasource: { + spreadsheetId: { + display: "Google Sheet URL", + type: DatasourceFieldType.STRING, + required: true, }, - relationships: false, - docs: "https://developers.google.com/sheets/api/quickstart/nodejs", - description: - "Create and collaborate on online spreadsheets in real-time and from any device. ", - friendlyName: "Google Sheets", - type: "Spreadsheet", - datasource: { - spreadsheetId: { - display: "Google Sheet URL", - type: DatasourceFieldType.STRING, - required: true, - }, - }, - query: { - create: { - type: QueryType.FIELDS, - fields: { - sheet: { - type: DatasourceFieldType.STRING, - required: true, - }, - row: { - type: QueryType.JSON, - required: true, - }, + }, + query: { + create: { + type: QueryType.FIELDS, + fields: { + sheet: { + type: DatasourceFieldType.STRING, + required: true, }, - }, - read: { - type: QueryType.FIELDS, - fields: { - sheet: { - type: DatasourceFieldType.STRING, - required: true, - }, - }, - }, - update: { - type: QueryType.FIELDS, - fields: { - sheet: { - type: DatasourceFieldType.STRING, - required: true, - }, - rowIndex: { - type: DatasourceFieldType.STRING, - required: true, - }, - row: { - type: QueryType.JSON, - required: true, - }, - }, - }, - delete: { - type: QueryType.FIELDS, - fields: { - sheet: { - type: DatasourceFieldType.STRING, - required: true, - }, - rowIndex: { - type: DatasourceFieldType.NUMBER, - required: true, - }, + row: { + type: QueryType.JSON, + required: true, }, }, }, + read: { + type: QueryType.FIELDS, + fields: { + sheet: { + type: DatasourceFieldType.STRING, + required: true, + }, + }, + }, + update: { + type: QueryType.FIELDS, + fields: { + sheet: { + type: DatasourceFieldType.STRING, + required: true, + }, + rowIndex: { + type: DatasourceFieldType.STRING, + required: true, + }, + row: { + type: QueryType.JSON, + required: true, + }, + }, + }, + delete: { + type: QueryType.FIELDS, + fields: { + sheet: { + type: DatasourceFieldType.STRING, + required: true, + }, + rowIndex: { + type: DatasourceFieldType.NUMBER, + required: true, + }, + }, + }, + }, +} + +class GoogleSheetsIntegration implements DatasourcePlus { + private readonly config: GoogleSheetsConfig + private client: any + public tables: Record = {} + public schemaErrors: Record = {} + + constructor(config: GoogleSheetsConfig) { + this.config = config + const spreadsheetId = this.cleanSpreadsheetUrl(this.config.spreadsheetId) + this.client = new GoogleSpreadsheet(spreadsheetId) } - class GoogleSheetsIntegration implements DatasourcePlus { - private readonly config: GoogleSheetsConfig - private client: any - public tables: Record = {} - public schemaErrors: Record = {} + getBindingIdentifier() { + return "" + } - constructor(config: GoogleSheetsConfig) { - this.config = config - const spreadsheetId = this.cleanSpreadsheetUrl(this.config.spreadsheetId) - this.client = new GoogleSpreadsheet(spreadsheetId) - } + getStringConcat(parts: string[]) { + return "" + } - getBindingIdentifier() { - return "" - } - - getStringConcat(parts: string[]) { - return "" - } - - /** - * Pull the spreadsheet ID out from a valid google sheets URL - * @param spreadsheetId - the URL or standard spreadsheetId of the google sheet - * @returns spreadsheet Id of the google sheet - */ - cleanSpreadsheetUrl(spreadsheetId: string) { - if (!spreadsheetId) { - throw new Error( - "You must set a spreadsheet ID in your configuration to fetch tables." - ) - } - const parts = spreadsheetId.split("/") - return parts.length > 5 ? parts[5] : spreadsheetId - } - - async fetchAccessToken( - payload: AuthTokenRequest - ): Promise { - const response = await fetch( - "https://www.googleapis.com/oauth2/v4/token", - { - method: "POST", - body: JSON.stringify({ - ...payload, - grant_type: "refresh_token", - }), - headers: { - "Content-Type": "application/json", - }, - } + /** + * Pull the spreadsheet ID out from a valid google sheets URL + * @param spreadsheetId - the URL or standard spreadsheetId of the google sheet + * @returns spreadsheet Id of the google sheet + */ + cleanSpreadsheetUrl(spreadsheetId: string) { + if (!spreadsheetId) { + throw new Error( + "You must set a spreadsheet ID in your configuration to fetch tables." ) + } + const parts = spreadsheetId.split("/") + return parts.length > 5 ? parts[5] : spreadsheetId + } - const json = await response.json() + async fetchAccessToken( + payload: AuthTokenRequest + ): Promise { + const response = await fetch("https://www.googleapis.com/oauth2/v4/token", { + method: "POST", + body: JSON.stringify({ + ...payload, + grant_type: "refresh_token", + }), + headers: { + "Content-Type": "application/json", + }, + }) - if (response.status !== 200) { - throw new Error( - `Error authenticating with google sheets. ${json.error_description}` + const json = await response.json() + + if (response.status !== 200) { + throw new Error( + `Error authenticating with google sheets. ${json.error_description}` + ) + } + + return json + } + + async connect() { + try { + // Initialise oAuth client + const db = getGlobalDB() + let googleConfig = await getScopedConfig(db, { + type: Configs.GOOGLE, + }) + + if (!googleConfig) { + googleConfig = { + clientID: env.GOOGLE_CLIENT_ID, + clientSecret: env.GOOGLE_CLIENT_SECRET, + } + } + + const oauthClient = new OAuth2Client({ + clientId: googleConfig.clientID, + clientSecret: googleConfig.clientSecret, + }) + + const tokenResponse = await this.fetchAccessToken({ + client_id: googleConfig.clientID, + client_secret: googleConfig.clientSecret, + refresh_token: this.config.auth.refreshToken, + }) + + oauthClient.setCredentials({ + refresh_token: this.config.auth.refreshToken, + access_token: tokenResponse.access_token, + }) + + this.client.useOAuth2Client(oauthClient) + await this.client.loadInfo() + } catch (err) { + console.error("Error connecting to google sheets", err) + throw err + } + } + + async buildSchema(datasourceId: string) { + await this.connect() + const sheets = await this.client.sheetsByIndex + const tables: Record = {} + for (let sheet of sheets) { + // must fetch rows to determine schema + await sheet.getRows() + // build schema + const schema: TableSchema = {} + + // build schema from headers + for (let header of sheet.headerValues) { + schema[header] = { + name: header, + type: FieldTypes.STRING, + } + } + + // create tables + tables[sheet.title] = { + _id: buildExternalTableId(datasourceId, sheet.title), + name: sheet.title, + primary: ["rowNumber"], + schema, + } + } + + this.tables = tables + } + + async query(json: QueryJson) { + const sheet = json.endpoint.entityId + + const handlers = { + [DataSourceOperation.CREATE]: () => + this.create({ sheet, row: json.body }), + [DataSourceOperation.READ]: () => this.read({ sheet }), + [DataSourceOperation.UPDATE]: () => + this.update({ + // exclude the header row and zero index + rowIndex: json.extra?.idFilter?.equal?.rowNumber - 2, + sheet, + row: json.body, + }), + [DataSourceOperation.DELETE]: () => + this.delete({ + // exclude the header row and zero index + rowIndex: json.extra?.idFilter?.equal?.rowNumber - 2, + sheet, + }), + [DataSourceOperation.CREATE_TABLE]: () => + this.createTable(json?.table?.name), + [DataSourceOperation.UPDATE_TABLE]: () => this.updateTable(json.table), + [DataSourceOperation.DELETE_TABLE]: () => + this.deleteTable(json?.table?.name), + } + + const internalQueryMethod = handlers[json.endpoint.operation] + + return await internalQueryMethod() + } + + buildRowObject(headers: string[], values: string[], rowNumber: number) { + const rowObject: { rowNumber: number; [key: string]: any } = { rowNumber } + for (let i = 0; i < headers.length; i++) { + rowObject._id = rowNumber + rowObject[headers[i]] = values[i] + } + return rowObject + } + + async createTable(name?: string) { + try { + await this.connect() + const sheet = await this.client.addSheet({ title: name }) + return sheet + } catch (err) { + console.error("Error creating new table in google sheets", err) + throw err + } + } + + async updateTable(table?: any) { + try { + await this.connect() + const sheet = await this.client.sheetsByTitle[table.name] + await sheet.loadHeaderRow() + + if (table._rename) { + const headers = [] + for (let header of sheet.headerValues) { + if (header === table._rename.old) { + headers.push(table._rename.updated) + } else { + headers.push(header) + } + } + await sheet.setHeaderRow(headers) + } else { + let newField = Object.keys(table.schema).find( + key => !sheet.headerValues.includes(key) + ) + await sheet.setHeaderRow([...sheet.headerValues, newField]) + } + } catch (err) { + console.error("Error updating table in google sheets", err) + throw err + } + } + + async deleteTable(sheet: any) { + try { + await this.connect() + const sheetToDelete = await this.client.sheetsByTitle[sheet] + return await sheetToDelete.delete() + } catch (err) { + console.error("Error deleting table in google sheets", err) + throw err + } + } + + async create(query: { sheet: string; row: any }) { + try { + await this.connect() + const sheet = await this.client.sheetsByTitle[query.sheet] + const rowToInsert = + typeof query.row === "string" ? JSON.parse(query.row) : query.row + const row = await sheet.addRow(rowToInsert) + return [ + this.buildRowObject(sheet.headerValues, row._rawData, row._rowNumber), + ] + } catch (err) { + console.error("Error writing to google sheets", err) + throw err + } + } + + async read(query: { sheet: string }) { + try { + await this.connect() + const sheet = await this.client.sheetsByTitle[query.sheet] + const rows = await sheet.getRows() + const headerValues = sheet.headerValues + const response = [] + for (let row of rows) { + response.push( + this.buildRowObject(headerValues, row._rawData, row._rowNumber) ) } - - return json + return response + } catch (err) { + console.error("Error reading from google sheets", err) + throw err } + } - async connect() { - try { - // Initialise oAuth client - const db = getGlobalDB() - let googleConfig = await getScopedConfig(db, { - type: Configs.GOOGLE, - }) - - if (!googleConfig) { - googleConfig = { - clientID: env.GOOGLE_CLIENT_ID, - clientSecret: env.GOOGLE_CLIENT_SECRET, - } - } - - const oauthClient = new OAuth2Client({ - clientId: googleConfig.clientID, - clientSecret: googleConfig.clientSecret, - }) - - const tokenResponse = await this.fetchAccessToken({ - client_id: googleConfig.clientID, - client_secret: googleConfig.clientSecret, - refresh_token: this.config.auth.refreshToken, - }) - - oauthClient.setCredentials({ - refresh_token: this.config.auth.refreshToken, - access_token: tokenResponse.access_token, - }) - - this.client.useOAuth2Client(oauthClient) - await this.client.loadInfo() - } catch (err) { - console.error("Error connecting to google sheets", err) - throw err - } - } - - async buildSchema(datasourceId: string) { - await this.connect() - const sheets = await this.client.sheetsByIndex - const tables: Record = {} - for (let sheet of sheets) { - // must fetch rows to determine schema - await sheet.getRows() - // build schema - const schema: TableSchema = {} - - // build schema from headers - for (let header of sheet.headerValues) { - schema[header] = { - name: header, - type: FieldTypes.STRING, - } - } - - // create tables - tables[sheet.title] = { - _id: buildExternalTableId(datasourceId, sheet.title), - name: sheet.title, - primary: ["rowNumber"], - schema, - } - } - - this.tables = tables - } - - async query(json: QueryJson) { - const sheet = json.endpoint.entityId - - const handlers = { - [DataSourceOperation.CREATE]: () => - this.create({ sheet, row: json.body }), - [DataSourceOperation.READ]: () => this.read({ sheet }), - [DataSourceOperation.UPDATE]: () => - this.update({ - // exclude the header row and zero index - rowIndex: json.extra?.idFilter?.equal?.rowNumber - 2, - sheet, - row: json.body, - }), - [DataSourceOperation.DELETE]: () => - this.delete({ - // exclude the header row and zero index - rowIndex: json.extra?.idFilter?.equal?.rowNumber - 2, - sheet, - }), - [DataSourceOperation.CREATE_TABLE]: () => - this.createTable(json?.table?.name), - [DataSourceOperation.UPDATE_TABLE]: () => this.updateTable(json.table), - [DataSourceOperation.DELETE_TABLE]: () => - this.deleteTable(json?.table?.name), - } - - const internalQueryMethod = handlers[json.endpoint.operation] - - return await internalQueryMethod() - } - - buildRowObject(headers: string[], values: string[], rowNumber: number) { - const rowObject: { rowNumber: number; [key: string]: any } = { rowNumber } - for (let i = 0; i < headers.length; i++) { - rowObject._id = rowNumber - rowObject[headers[i]] = values[i] - } - return rowObject - } - - async createTable(name?: string) { - try { - await this.connect() - const sheet = await this.client.addSheet({ title: name }) - return sheet - } catch (err) { - console.error("Error creating new table in google sheets", err) - throw err - } - } - - async updateTable(table?: any) { - try { - await this.connect() - const sheet = await this.client.sheetsByTitle[table.name] - await sheet.loadHeaderRow() - - if (table._rename) { - const headers = [] - for (let header of sheet.headerValues) { - if (header === table._rename.old) { - headers.push(table._rename.updated) - } else { - headers.push(header) - } - } - await sheet.setHeaderRow(headers) - } else { - let newField = Object.keys(table.schema).find( - key => !sheet.headerValues.includes(key) - ) - await sheet.setHeaderRow([...sheet.headerValues, newField]) - } - } catch (err) { - console.error("Error updating table in google sheets", err) - throw err - } - } - - async deleteTable(sheet: any) { - try { - await this.connect() - const sheetToDelete = await this.client.sheetsByTitle[sheet] - return await sheetToDelete.delete() - } catch (err) { - console.error("Error deleting table in google sheets", err) - throw err - } - } - - async create(query: { sheet: string; row: any }) { - try { - await this.connect() - const sheet = await this.client.sheetsByTitle[query.sheet] - const rowToInsert = - typeof query.row === "string" ? JSON.parse(query.row) : query.row - const row = await sheet.addRow(rowToInsert) - return [ - this.buildRowObject(sheet.headerValues, row._rawData, row._rowNumber), - ] - } catch (err) { - console.error("Error writing to google sheets", err) - throw err - } - } - - async read(query: { sheet: string }) { - try { - await this.connect() - const sheet = await this.client.sheetsByTitle[query.sheet] - const rows = await sheet.getRows() - const headerValues = sheet.headerValues - const response = [] - for (let row of rows) { - response.push( - this.buildRowObject(headerValues, row._rawData, row._rowNumber) - ) - } - return response - } catch (err) { - console.error("Error reading from google sheets", err) - throw err - } - } - - async update(query: { sheet: string; rowIndex: number; row: any }) { - try { - await this.connect() - const sheet = await this.client.sheetsByTitle[query.sheet] - const rows = await sheet.getRows() - const row = rows[query.rowIndex] - if (row) { - const updateValues = query.row - for (let key in updateValues) { - row[key] = updateValues[key] - } - await row.save() - return [ - this.buildRowObject( - sheet.headerValues, - row._rawData, - row._rowNumber - ), - ] - } else { - throw new Error("Row does not exist.") - } - } catch (err) { - console.error("Error reading from google sheets", err) - throw err - } - } - - async delete(query: { sheet: string; rowIndex: number }) { + async update(query: { sheet: string; rowIndex: number; row: any }) { + try { await this.connect() const sheet = await this.client.sheetsByTitle[query.sheet] const rows = await sheet.getRows() const row = rows[query.rowIndex] if (row) { - await row.delete() - return [{ deleted: query.rowIndex }] + const updateValues = query.row + for (let key in updateValues) { + row[key] = updateValues[key] + } + await row.save() + return [ + this.buildRowObject(sheet.headerValues, row._rawData, row._rowNumber), + ] } else { throw new Error("Row does not exist.") } + } catch (err) { + console.error("Error reading from google sheets", err) + throw err } } - module.exports = { - schema: SCHEMA, - integration: GoogleSheetsIntegration, + async delete(query: { sheet: string; rowIndex: number }) { + await this.connect() + const sheet = await this.client.sheetsByTitle[query.sheet] + const rows = await sheet.getRows() + const row = rows[query.rowIndex] + if (row) { + await row.delete() + return [{ deleted: query.rowIndex }] + } else { + throw new Error("Row does not exist.") + } } } + +export default { + schema: SCHEMA, + integration: GoogleSheetsIntegration, +} diff --git a/packages/server/src/integrations/index.ts b/packages/server/src/integrations/index.ts index fd2ce75391..bde7235ac8 100644 --- a/packages/server/src/integrations/index.ts +++ b/packages/server/src/integrations/index.ts @@ -1,22 +1,24 @@ -const postgres = require("./postgres") -const dynamodb = require("./dynamodb") -const mongodb = require("./mongodb") -const elasticsearch = require("./elasticsearch") -const couchdb = require("./couchdb") -const sqlServer = require("./microsoftSqlServer") -const s3 = require("./s3") -const airtable = require("./airtable") -const mysql = require("./mysql") -const arangodb = require("./arangodb") -const rest = require("./rest") -const googlesheets = require("./googlesheets") -const firebase = require("./firebase") -const redis = require("./redis") -const snowflake = require("./snowflake") -const { SourceName } = require("@budibase/types") +import postgres from "./postgres" +import dynamodb from "./dynamodb" +import mongodb from "./mongodb" +import elasticsearch from "./elasticsearch" +import couchdb from "./couchdb" +import sqlServer from "./microsoftSqlServer" +import s3 from "./s3" +import airtable from "./airtable" +import mysql from "./mysql" +import arangodb from "./arangodb" +import rest from "./rest" +import googlesheets from "./googlesheets" +import firebase from "./firebase" +import redis from "./redis" +import snowflake from "./snowflake" +import { getPlugins } from "../api/controllers/plugin" +import { SourceName, Integration, PluginType } from "@budibase/types" const environment = require("../environment") +const { cloneDeep } = require("lodash") -const DEFINITIONS = { +const DEFINITIONS: { [key: string]: Integration } = { [SourceName.POSTGRES]: postgres.schema, [SourceName.DYNAMODB]: dynamodb.schema, [SourceName.MONGODB]: mongodb.schema, @@ -33,7 +35,7 @@ const DEFINITIONS = { [SourceName.SNOWFLAKE]: snowflake.schema, } -const INTEGRATIONS = { +const INTEGRATIONS: { [key: string]: any } = { [SourceName.POSTGRES]: postgres.integration, [SourceName.DYNAMODB]: dynamodb.integration, [SourceName.MONGODB]: mongodb.integration, @@ -48,7 +50,7 @@ const INTEGRATIONS = { [SourceName.FIRESTORE]: firebase.integration, [SourceName.GOOGLE_SHEETS]: googlesheets.integration, [SourceName.REDIS]: redis.integration, - [SourceName.FIREBASE]: firebase.integration, + [SourceName.FIRESTORE]: firebase.integration, [SourceName.SNOWFLAKE]: snowflake.integration, } @@ -64,6 +66,9 @@ if (environment.SELF_HOSTED) { } module.exports = { - definitions: DEFINITIONS, + getDefinitions: async () => { + const custom = await getPlugins(PluginType.DATASOURCE) + return cloneDeep(DEFINITIONS) + }, integrations: INTEGRATIONS, } diff --git a/packages/server/src/integrations/microsoftSqlServer.ts b/packages/server/src/integrations/microsoftSqlServer.ts index 6103fd90ce..0746d0e3bc 100644 --- a/packages/server/src/integrations/microsoftSqlServer.ts +++ b/packages/server/src/integrations/microsoftSqlServer.ts @@ -18,292 +18,290 @@ import { } from "./utils" import Sql from "./base/sql" -module MSSQLModule { - const sqlServer = require("mssql") - const DEFAULT_SCHEMA = "dbo" +const sqlServer = require("mssql") +const DEFAULT_SCHEMA = "dbo" - interface MSSQLConfig { - user: string - password: string - server: string - port: number - database: string - schema: string - encrypt?: boolean - } +interface MSSQLConfig { + user: string + password: string + server: string + port: number + database: string + schema: string + encrypt?: boolean +} - interface TablesResponse { - TABLE_CATALOG: string - TABLE_SCHEMA: string - TABLE_NAME: string - TABLE_TYPE: string - } +interface TablesResponse { + TABLE_CATALOG: string + TABLE_SCHEMA: string + TABLE_NAME: string + TABLE_TYPE: string +} - const SCHEMA: Integration = { - docs: "https://github.com/tediousjs/node-mssql", - plus: true, - description: - "Microsoft SQL Server is a relational database management system developed by Microsoft. ", - friendlyName: "MS SQL Server", - type: "Relational", - datasource: { - user: { - type: DatasourceFieldType.STRING, - required: true, - default: "localhost", - }, - password: { - type: DatasourceFieldType.PASSWORD, - required: true, - }, - server: { - type: DatasourceFieldType.STRING, - default: "localhost", - }, - port: { - type: DatasourceFieldType.NUMBER, - required: false, - default: 1433, - }, - database: { - type: DatasourceFieldType.STRING, - default: "root", - }, - schema: { - type: DatasourceFieldType.STRING, - default: DEFAULT_SCHEMA, - }, - encrypt: { - type: DatasourceFieldType.BOOLEAN, - default: true, - }, +const SCHEMA: Integration = { + docs: "https://github.com/tediousjs/node-mssql", + plus: true, + description: + "Microsoft SQL Server is a relational database management system developed by Microsoft. ", + friendlyName: "MS SQL Server", + type: "Relational", + datasource: { + user: { + type: DatasourceFieldType.STRING, + required: true, + default: "localhost", }, - query: { - create: { - type: QueryType.SQL, - }, - read: { - type: QueryType.SQL, - }, - update: { - type: QueryType.SQL, - }, - delete: { - type: QueryType.SQL, - }, + password: { + type: DatasourceFieldType.PASSWORD, + required: true, }, - } + server: { + type: DatasourceFieldType.STRING, + default: "localhost", + }, + port: { + type: DatasourceFieldType.NUMBER, + required: false, + default: 1433, + }, + database: { + type: DatasourceFieldType.STRING, + default: "root", + }, + schema: { + type: DatasourceFieldType.STRING, + default: DEFAULT_SCHEMA, + }, + encrypt: { + type: DatasourceFieldType.BOOLEAN, + default: true, + }, + }, + query: { + create: { + type: QueryType.SQL, + }, + read: { + type: QueryType.SQL, + }, + update: { + type: QueryType.SQL, + }, + delete: { + type: QueryType.SQL, + }, + }, +} - class SqlServerIntegration extends Sql implements DatasourcePlus { - private readonly config: MSSQLConfig - private index: number = 0 - private readonly pool: any - private client: any - public tables: Record = {} - public schemaErrors: Record = {} +class SqlServerIntegration extends Sql implements DatasourcePlus { + private readonly config: MSSQLConfig + private index: number = 0 + private readonly pool: any + private client: any + public tables: Record = {} + public schemaErrors: Record = {} - MASTER_TABLES = [ - "spt_fallback_db", - "spt_fallback_dev", - "spt_fallback_usg", - "spt_monitor", - "MSreplication_options", - ] - TABLES_SQL = - "SELECT * FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_TYPE='BASE TABLE'" + MASTER_TABLES = [ + "spt_fallback_db", + "spt_fallback_dev", + "spt_fallback_usg", + "spt_monitor", + "MSreplication_options", + ] + TABLES_SQL = + "SELECT * FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_TYPE='BASE TABLE'" - constructor(config: MSSQLConfig) { - super(SqlClient.MS_SQL) - this.config = config - const clientCfg = { - ...this.config, - options: { - encrypt: this.config.encrypt, - enableArithAbort: true, - }, - } - delete clientCfg.encrypt - if (!this.pool) { - this.pool = new sqlServer.ConnectionPool(clientCfg) - } + constructor(config: MSSQLConfig) { + super(SqlClient.MS_SQL) + this.config = config + const clientCfg = { + ...this.config, + options: { + encrypt: this.config.encrypt, + enableArithAbort: true, + }, } - - getBindingIdentifier(): string { - return `@p${this.index++}` - } - - getStringConcat(parts: string[]): string { - return `concat(${parts.join(", ")})` - } - - async connect() { - try { - this.client = await this.pool.connect() - } catch (err) { - // @ts-ignore - throw new Error(err) - } - } - - async internalQuery( - query: SqlQuery, - operation: string | undefined = undefined - ) { - const client = this.client - const request = client.request() - this.index = 0 - try { - if (Array.isArray(query.bindings)) { - let count = 0 - for (let binding of query.bindings) { - request.input(`p${count++}`, binding) - } - } - // this is a hack to get the inserted ID back, - // no way to do this with Knex nicely - const sql = - operation === Operation.CREATE - ? `${query.sql}; SELECT SCOPE_IDENTITY() AS id;` - : query.sql - return await request.query(sql) - } catch (err) { - // @ts-ignore - throw new Error(err) - } - } - - getDefinitionSQL(tableName: string) { - return `select * - from INFORMATION_SCHEMA.COLUMNS - where TABLE_NAME='${tableName}'` - } - - getConstraintsSQL(tableName: string) { - return `SELECT * FROM INFORMATION_SCHEMA.TABLE_CONSTRAINTS AS TC - INNER JOIN INFORMATION_SCHEMA.KEY_COLUMN_USAGE AS KU - ON TC.CONSTRAINT_TYPE = 'PRIMARY KEY' - AND TC.CONSTRAINT_NAME = KU.CONSTRAINT_NAME - AND KU.table_name='${tableName}' - ORDER BY - KU.TABLE_NAME, - KU.ORDINAL_POSITION;` - } - - getAutoColumnsSQL(tableName: string) { - return `SELECT - COLUMNPROPERTY(OBJECT_ID(TABLE_SCHEMA+'.'+TABLE_NAME),COLUMN_NAME,'IsComputed') - AS IS_COMPUTED, - COLUMNPROPERTY(object_id(TABLE_SCHEMA+'.'+TABLE_NAME), COLUMN_NAME, 'IsIdentity') - AS IS_IDENTITY, - * - FROM INFORMATION_SCHEMA.COLUMNS - WHERE TABLE_NAME='${tableName}'` - } - - async runSQL(sql: string) { - return (await this.internalQuery(getSqlQuery(sql))).recordset - } - - /** - * Fetches the tables from the sql server database and assigns them to the datasource. - * @param {*} datasourceId - datasourceId to fetch - * @param entities - the tables that are to be built - */ - async buildSchema(datasourceId: string, entities: Record) { - await this.connect() - let tableInfo: TablesResponse[] = await this.runSQL(this.TABLES_SQL) - if (tableInfo == null || !Array.isArray(tableInfo)) { - throw "Unable to get list of tables in database" - } - - const schema = this.config.schema || DEFAULT_SCHEMA - const tableNames = tableInfo - .filter((record: any) => record.TABLE_SCHEMA === schema) - .map((record: any) => record.TABLE_NAME) - .filter((name: string) => this.MASTER_TABLES.indexOf(name) === -1) - - const tables: Record = {} - for (let tableName of tableNames) { - // get the column definition (type) - const definition = await this.runSQL(this.getDefinitionSQL(tableName)) - // find primary key constraints - const constraints = await this.runSQL(this.getConstraintsSQL(tableName)) - // find the computed and identity columns (auto columns) - const columns = await this.runSQL(this.getAutoColumnsSQL(tableName)) - const primaryKeys = constraints - .filter( - (constraint: any) => constraint.CONSTRAINT_TYPE === "PRIMARY KEY" - ) - .map((constraint: any) => constraint.COLUMN_NAME) - const autoColumns = columns - .filter((col: any) => col.IS_COMPUTED || col.IS_IDENTITY) - .map((col: any) => col.COLUMN_NAME) - - let schema: TableSchema = {} - for (let def of definition) { - const name = def.COLUMN_NAME - if (typeof name !== "string") { - continue - } - schema[name] = { - autocolumn: !!autoColumns.find((col: string) => col === name), - name: name, - ...convertSqlType(def.DATA_TYPE), - externalType: def.DATA_TYPE, - } - } - tables[tableName] = { - _id: buildExternalTableId(datasourceId, tableName), - primary: primaryKeys, - name: tableName, - schema, - } - } - const final = finaliseExternalTables(tables, entities) - this.tables = final.tables - this.schemaErrors = final.errors - } - - async read(query: SqlQuery | string) { - await this.connect() - const response = await this.internalQuery(getSqlQuery(query)) - return response.recordset - } - - async create(query: SqlQuery | string) { - await this.connect() - const response = await this.internalQuery(getSqlQuery(query)) - return response.recordset || [{ created: true }] - } - - async update(query: SqlQuery | string) { - await this.connect() - const response = await this.internalQuery(getSqlQuery(query)) - return response.recordset || [{ updated: true }] - } - - async delete(query: SqlQuery | string) { - await this.connect() - const response = await this.internalQuery(getSqlQuery(query)) - return response.recordset || [{ deleted: true }] - } - - async query(json: QueryJson) { - const schema = this.config.schema - await this.connect() - if (schema && schema !== DEFAULT_SCHEMA && json?.endpoint) { - json.endpoint.schema = schema - } - const operation = this._operation(json) - const queryFn = (query: any, op: string) => this.internalQuery(query, op) - const processFn = (result: any) => - result.recordset ? result.recordset : [{ [operation]: true }] - return this.queryWithReturning(json, queryFn, processFn) + delete clientCfg.encrypt + if (!this.pool) { + this.pool = new sqlServer.ConnectionPool(clientCfg) } } - module.exports = { - schema: SCHEMA, - integration: SqlServerIntegration, + getBindingIdentifier(): string { + return `@p${this.index++}` + } + + getStringConcat(parts: string[]): string { + return `concat(${parts.join(", ")})` + } + + async connect() { + try { + this.client = await this.pool.connect() + } catch (err) { + // @ts-ignore + throw new Error(err) + } + } + + async internalQuery( + query: SqlQuery, + operation: string | undefined = undefined + ) { + const client = this.client + const request = client.request() + this.index = 0 + try { + if (Array.isArray(query.bindings)) { + let count = 0 + for (let binding of query.bindings) { + request.input(`p${count++}`, binding) + } + } + // this is a hack to get the inserted ID back, + // no way to do this with Knex nicely + const sql = + operation === Operation.CREATE + ? `${query.sql}; SELECT SCOPE_IDENTITY() AS id;` + : query.sql + return await request.query(sql) + } catch (err) { + // @ts-ignore + throw new Error(err) + } + } + + getDefinitionSQL(tableName: string) { + return `select * + from INFORMATION_SCHEMA.COLUMNS + where TABLE_NAME='${tableName}'` + } + + getConstraintsSQL(tableName: string) { + return `SELECT * FROM INFORMATION_SCHEMA.TABLE_CONSTRAINTS AS TC + INNER JOIN INFORMATION_SCHEMA.KEY_COLUMN_USAGE AS KU + ON TC.CONSTRAINT_TYPE = 'PRIMARY KEY' + AND TC.CONSTRAINT_NAME = KU.CONSTRAINT_NAME + AND KU.table_name='${tableName}' + ORDER BY + KU.TABLE_NAME, + KU.ORDINAL_POSITION;` + } + + getAutoColumnsSQL(tableName: string) { + return `SELECT + COLUMNPROPERTY(OBJECT_ID(TABLE_SCHEMA+'.'+TABLE_NAME),COLUMN_NAME,'IsComputed') + AS IS_COMPUTED, + COLUMNPROPERTY(object_id(TABLE_SCHEMA+'.'+TABLE_NAME), COLUMN_NAME, 'IsIdentity') + AS IS_IDENTITY, + * + FROM INFORMATION_SCHEMA.COLUMNS + WHERE TABLE_NAME='${tableName}'` + } + + async runSQL(sql: string) { + return (await this.internalQuery(getSqlQuery(sql))).recordset + } + + /** + * Fetches the tables from the sql server database and assigns them to the datasource. + * @param {*} datasourceId - datasourceId to fetch + * @param entities - the tables that are to be built + */ + async buildSchema(datasourceId: string, entities: Record) { + await this.connect() + let tableInfo: TablesResponse[] = await this.runSQL(this.TABLES_SQL) + if (tableInfo == null || !Array.isArray(tableInfo)) { + throw "Unable to get list of tables in database" + } + + const schema = this.config.schema || DEFAULT_SCHEMA + const tableNames = tableInfo + .filter((record: any) => record.TABLE_SCHEMA === schema) + .map((record: any) => record.TABLE_NAME) + .filter((name: string) => this.MASTER_TABLES.indexOf(name) === -1) + + const tables: Record = {} + for (let tableName of tableNames) { + // get the column definition (type) + const definition = await this.runSQL(this.getDefinitionSQL(tableName)) + // find primary key constraints + const constraints = await this.runSQL(this.getConstraintsSQL(tableName)) + // find the computed and identity columns (auto columns) + const columns = await this.runSQL(this.getAutoColumnsSQL(tableName)) + const primaryKeys = constraints + .filter( + (constraint: any) => constraint.CONSTRAINT_TYPE === "PRIMARY KEY" + ) + .map((constraint: any) => constraint.COLUMN_NAME) + const autoColumns = columns + .filter((col: any) => col.IS_COMPUTED || col.IS_IDENTITY) + .map((col: any) => col.COLUMN_NAME) + + let schema: TableSchema = {} + for (let def of definition) { + const name = def.COLUMN_NAME + if (typeof name !== "string") { + continue + } + schema[name] = { + autocolumn: !!autoColumns.find((col: string) => col === name), + name: name, + ...convertSqlType(def.DATA_TYPE), + externalType: def.DATA_TYPE, + } + } + tables[tableName] = { + _id: buildExternalTableId(datasourceId, tableName), + primary: primaryKeys, + name: tableName, + schema, + } + } + const final = finaliseExternalTables(tables, entities) + this.tables = final.tables + this.schemaErrors = final.errors + } + + async read(query: SqlQuery | string) { + await this.connect() + const response = await this.internalQuery(getSqlQuery(query)) + return response.recordset + } + + async create(query: SqlQuery | string) { + await this.connect() + const response = await this.internalQuery(getSqlQuery(query)) + return response.recordset || [{ created: true }] + } + + async update(query: SqlQuery | string) { + await this.connect() + const response = await this.internalQuery(getSqlQuery(query)) + return response.recordset || [{ updated: true }] + } + + async delete(query: SqlQuery | string) { + await this.connect() + const response = await this.internalQuery(getSqlQuery(query)) + return response.recordset || [{ deleted: true }] + } + + async query(json: QueryJson) { + const schema = this.config.schema + await this.connect() + if (schema && schema !== DEFAULT_SCHEMA && json?.endpoint) { + json.endpoint.schema = schema + } + const operation = this._operation(json) + const queryFn = (query: any, op: string) => this.internalQuery(query, op) + const processFn = (result: any) => + result.recordset ? result.recordset : [{ [operation]: true }] + return this.queryWithReturning(json, queryFn, processFn) } } + +export default { + schema: SCHEMA, + integration: SqlServerIntegration, +} diff --git a/packages/server/src/integrations/mongodb.ts b/packages/server/src/integrations/mongodb.ts index 4f2a901259..3b11348368 100644 --- a/packages/server/src/integrations/mongodb.ts +++ b/packages/server/src/integrations/mongodb.ts @@ -15,313 +15,309 @@ import { CommonOptions, } from "mongodb" -module MongoDBModule { - interface MongoDBConfig { - connectionString: string - db: string +interface MongoDBConfig { + connectionString: string + db: string +} + +const SCHEMA: Integration = { + docs: "https://github.com/mongodb/node-mongodb-native", + friendlyName: "MongoDB", + type: "Non-relational", + description: + "MongoDB is a general purpose, document-based, distributed database built for modern application developers and for the cloud era.", + datasource: { + connectionString: { + type: DatasourceFieldType.STRING, + required: true, + default: "mongodb://localhost:27017", + }, + db: { + type: DatasourceFieldType.STRING, + required: true, + }, + }, + query: { + create: { + type: QueryType.JSON, + }, + read: { + type: QueryType.JSON, + }, + update: { + type: QueryType.JSON, + }, + delete: { + type: QueryType.JSON, + }, + }, + extra: { + collection: { + displayName: "Collection", + type: DatasourceFieldType.STRING, + required: true, + }, + actionTypes: { + displayName: "Action Types", + type: DatasourceFieldType.LIST, + required: true, + data: { + read: ["find", "findOne", "findOneAndUpdate", "count", "distinct"], + create: ["insertOne", "insertMany"], + update: ["updateOne", "updateMany"], + delete: ["deleteOne", "deleteMany"], + }, + }, + }, +} + +class MongoIntegration implements IntegrationBase { + private config: MongoDBConfig + private client: any + + constructor(config: MongoDBConfig) { + this.config = config + this.client = new MongoClient(config.connectionString) } - const SCHEMA: Integration = { - docs: "https://github.com/mongodb/node-mongodb-native", - friendlyName: "MongoDB", - type: "Non-relational", - description: - "MongoDB is a general purpose, document-based, distributed database built for modern application developers and for the cloud era.", - datasource: { - connectionString: { - type: DatasourceFieldType.STRING, - required: true, - default: "mongodb://localhost:27017", - }, - db: { - type: DatasourceFieldType.STRING, - required: true, - }, - }, - query: { - create: { - type: QueryType.JSON, - }, - read: { - type: QueryType.JSON, - }, - update: { - type: QueryType.JSON, - }, - delete: { - type: QueryType.JSON, - }, - }, - extra: { - collection: { - displayName: "Collection", - type: DatasourceFieldType.STRING, - required: true, - }, - actionTypes: { - displayName: "Action Types", - type: DatasourceFieldType.LIST, - required: true, - data: { - read: ["find", "findOne", "findOneAndUpdate", "count", "distinct"], - create: ["insertOne", "insertMany"], - update: ["updateOne", "updateMany"], - delete: ["deleteOne", "deleteMany"], - }, - }, - }, + async connect() { + return this.client.connect() } - class MongoIntegration implements IntegrationBase { - private config: MongoDBConfig - private client: any - - constructor(config: MongoDBConfig) { - this.config = config - this.client = new MongoClient(config.connectionString) + createObjectIds(json: any): object { + const self = this + function interpolateObjectIds(json: any) { + for (let field of Object.keys(json)) { + if (json[field] instanceof Object) { + json[field] = self.createObjectIds(json[field]) + } + if ( + (field === "_id" || field?.startsWith("$")) && + typeof json[field] === "string" + ) { + const id = json[field].match(/(?<=objectid\(['"]).*(?=['"]\))/gi)?.[0] + if (id) { + json[field] = ObjectID.createFromHexString(id) + } + } + } + return json } - async connect() { - return this.client.connect() + if (Array.isArray(json)) { + for (let i = 0; i < json.length; i++) { + json[i] = interpolateObjectIds(json[i]) + } + return json } + return interpolateObjectIds(json) + } - createObjectIds(json: any): object { - const self = this - function interpolateObjectIds(json: any) { - for (let field of Object.keys(json)) { - if (json[field] instanceof Object) { - json[field] = self.createObjectIds(json[field]) - } - if ( - (field === "_id" || field?.startsWith("$")) && - typeof json[field] === "string" - ) { - const id = json[field].match( - /(?<=objectid\(['"]).*(?=['"]\))/gi - )?.[0] - if (id) { - json[field] = ObjectID.createFromHexString(id) - } - } - } - return json + parseQueryParams(params: string, mode: string) { + let queryParams = [] + let openCount = 0 + let inQuotes = false + let i = 0 + let startIndex = 0 + for (let c of params) { + if (c === '"' && i > 0 && params[i - 1] !== "\\") { + inQuotes = !inQuotes } - - if (Array.isArray(json)) { - for (let i = 0; i < json.length; i++) { - json[i] = interpolateObjectIds(json[i]) + if (c === "{" && !inQuotes) { + openCount++ + if (openCount === 1) { + startIndex = i } - return json + } else if (c === "}" && !inQuotes) { + if (openCount === 1) { + queryParams.push(JSON.parse(params.substring(startIndex, i + 1))) + } + openCount-- } - return interpolateObjectIds(json) + i++ } - - parseQueryParams(params: string, mode: string) { - let queryParams = [] - let openCount = 0 - let inQuotes = false - let i = 0 - let startIndex = 0 - for (let c of params) { - if (c === '"' && i > 0 && params[i - 1] !== "\\") { - inQuotes = !inQuotes - } - if (c === "{" && !inQuotes) { - openCount++ - if (openCount === 1) { - startIndex = i - } - } else if (c === "}" && !inQuotes) { - if (openCount === 1) { - queryParams.push(JSON.parse(params.substring(startIndex, i + 1))) - } - openCount-- - } - i++ - } - let group1 = queryParams[0] ?? {} - let group2 = queryParams[1] ?? {} - let group3 = queryParams[2] ?? {} - if (mode === "update") { - return { - filter: group1, - update: group2, - options: group3, - } - } + let group1 = queryParams[0] ?? {} + let group2 = queryParams[1] ?? {} + let group3 = queryParams[2] ?? {} + if (mode === "update") { return { filter: group1, - options: group2, + update: group2, + options: group3, } } - - async create(query: { json: object; extra: { [key: string]: string } }) { - try { - await this.connect() - const db = this.client.db(this.config.db) - const collection = db.collection(query.extra.collection) - let json = this.createObjectIds(query.json) - - // For mongodb we add an extra actionType to specify - // which method we want to call on the collection - switch (query.extra.actionTypes) { - case "insertOne": { - return await collection.insertOne(json) - } - case "insertMany": { - return await collection.insertMany(json) - } - default: { - throw new Error( - `actionType ${query.extra.actionTypes} does not exist on DB for create` - ) - } - } - } catch (err) { - console.error("Error writing to mongodb", err) - throw err - } finally { - await this.client.close() - } - } - - async read(query: { json: object; extra: { [key: string]: string } }) { - try { - await this.connect() - const db = this.client.db(this.config.db) - const collection = db.collection(query.extra.collection) - let json = this.createObjectIds(query.json) - - switch (query.extra.actionTypes) { - case "find": { - return await collection.find(json).toArray() - } - case "findOne": { - return await collection.findOne(json) - } - case "findOneAndUpdate": { - if (typeof query.json === "string") { - json = this.parseQueryParams(query.json, "update") - } - let findAndUpdateJson = this.createObjectIds(json) as { - filter: FilterQuery - update: UpdateQuery - options: FindOneAndUpdateOption - } - return await collection.findOneAndUpdate( - findAndUpdateJson.filter, - findAndUpdateJson.update, - findAndUpdateJson.options - ) - } - case "count": { - return await collection.countDocuments(json) - } - case "distinct": { - return await collection.distinct(json) - } - default: { - throw new Error( - `actionType ${query.extra.actionTypes} does not exist on DB for read` - ) - } - } - } catch (err) { - console.error("Error querying mongodb", err) - throw err - } finally { - await this.client.close() - } - } - - async update(query: { json: object; extra: { [key: string]: string } }) { - try { - await this.connect() - const db = this.client.db(this.config.db) - const collection = db.collection(query.extra.collection) - let queryJson = query.json - if (typeof queryJson === "string") { - queryJson = this.parseQueryParams(queryJson, "update") - } - let json = this.createObjectIds(queryJson) as { - filter: FilterQuery - update: UpdateQuery - options: object - } - - switch (query.extra.actionTypes) { - case "updateOne": { - return await collection.updateOne( - json.filter, - json.update, - json.options as UpdateOneOptions - ) - } - case "updateMany": { - return await collection.updateMany( - json.filter, - json.update, - json.options as UpdateManyOptions - ) - } - default: { - throw new Error( - `actionType ${query.extra.actionTypes} does not exist on DB for update` - ) - } - } - } catch (err) { - console.error("Error writing to mongodb", err) - throw err - } finally { - await this.client.close() - } - } - - async delete(query: { json: object; extra: { [key: string]: string } }) { - try { - await this.connect() - const db = this.client.db(this.config.db) - const collection = db.collection(query.extra.collection) - let queryJson = query.json - if (typeof queryJson === "string") { - queryJson = this.parseQueryParams(queryJson, "delete") - } - let json = this.createObjectIds(queryJson) as { - filter: FilterQuery - options: CommonOptions - } - if (!json.options) { - json = { - filter: json, - options: {}, - } - } - - switch (query.extra.actionTypes) { - case "deleteOne": { - return await collection.deleteOne(json.filter, json.options) - } - case "deleteMany": { - return await collection.deleteMany(json.filter, json.options) - } - default: { - throw new Error( - `actionType ${query.extra.actionTypes} does not exist on DB for delete` - ) - } - } - } catch (err) { - console.error("Error writing to mongodb", err) - throw err - } finally { - await this.client.close() - } + return { + filter: group1, + options: group2, } } - module.exports = { - schema: SCHEMA, - integration: MongoIntegration, + async create(query: { json: object; extra: { [key: string]: string } }) { + try { + await this.connect() + const db = this.client.db(this.config.db) + const collection = db.collection(query.extra.collection) + let json = this.createObjectIds(query.json) + + // For mongodb we add an extra actionType to specify + // which method we want to call on the collection + switch (query.extra.actionTypes) { + case "insertOne": { + return await collection.insertOne(json) + } + case "insertMany": { + return await collection.insertMany(json) + } + default: { + throw new Error( + `actionType ${query.extra.actionTypes} does not exist on DB for create` + ) + } + } + } catch (err) { + console.error("Error writing to mongodb", err) + throw err + } finally { + await this.client.close() + } + } + + async read(query: { json: object; extra: { [key: string]: string } }) { + try { + await this.connect() + const db = this.client.db(this.config.db) + const collection = db.collection(query.extra.collection) + let json = this.createObjectIds(query.json) + + switch (query.extra.actionTypes) { + case "find": { + return await collection.find(json).toArray() + } + case "findOne": { + return await collection.findOne(json) + } + case "findOneAndUpdate": { + if (typeof query.json === "string") { + json = this.parseQueryParams(query.json, "update") + } + let findAndUpdateJson = this.createObjectIds(json) as { + filter: FilterQuery + update: UpdateQuery + options: FindOneAndUpdateOption + } + return await collection.findOneAndUpdate( + findAndUpdateJson.filter, + findAndUpdateJson.update, + findAndUpdateJson.options + ) + } + case "count": { + return await collection.countDocuments(json) + } + case "distinct": { + return await collection.distinct(json) + } + default: { + throw new Error( + `actionType ${query.extra.actionTypes} does not exist on DB for read` + ) + } + } + } catch (err) { + console.error("Error querying mongodb", err) + throw err + } finally { + await this.client.close() + } + } + + async update(query: { json: object; extra: { [key: string]: string } }) { + try { + await this.connect() + const db = this.client.db(this.config.db) + const collection = db.collection(query.extra.collection) + let queryJson = query.json + if (typeof queryJson === "string") { + queryJson = this.parseQueryParams(queryJson, "update") + } + let json = this.createObjectIds(queryJson) as { + filter: FilterQuery + update: UpdateQuery + options: object + } + + switch (query.extra.actionTypes) { + case "updateOne": { + return await collection.updateOne( + json.filter, + json.update, + json.options as UpdateOneOptions + ) + } + case "updateMany": { + return await collection.updateMany( + json.filter, + json.update, + json.options as UpdateManyOptions + ) + } + default: { + throw new Error( + `actionType ${query.extra.actionTypes} does not exist on DB for update` + ) + } + } + } catch (err) { + console.error("Error writing to mongodb", err) + throw err + } finally { + await this.client.close() + } + } + + async delete(query: { json: object; extra: { [key: string]: string } }) { + try { + await this.connect() + const db = this.client.db(this.config.db) + const collection = db.collection(query.extra.collection) + let queryJson = query.json + if (typeof queryJson === "string") { + queryJson = this.parseQueryParams(queryJson, "delete") + } + let json = this.createObjectIds(queryJson) as { + filter: FilterQuery + options: CommonOptions + } + if (!json.options) { + json = { + filter: json, + options: {}, + } + } + + switch (query.extra.actionTypes) { + case "deleteOne": { + return await collection.deleteOne(json.filter, json.options) + } + case "deleteMany": { + return await collection.deleteMany(json.filter, json.options) + } + default: { + throw new Error( + `actionType ${query.extra.actionTypes} does not exist on DB for delete` + ) + } + } + } catch (err) { + console.error("Error writing to mongodb", err) + throw err + } finally { + await this.client.close() + } } } + +export default { + schema: SCHEMA, + integration: MongoIntegration, +} diff --git a/packages/server/src/integrations/mysql.ts b/packages/server/src/integrations/mysql.ts index 466f2e6494..0f236935c8 100644 --- a/packages/server/src/integrations/mysql.ts +++ b/packages/server/src/integrations/mysql.ts @@ -19,274 +19,269 @@ import dayjs from "dayjs" const { NUMBER_REGEX } = require("../utilities") import Sql from "./base/sql" -module MySQLModule { - const mysql = require("mysql2/promise") +const mysql = require("mysql2/promise") - interface MySQLConfig { - host: string - port: number - user: string - password: string - database: string - ssl?: { [key: string]: any } - rejectUnauthorized: boolean - typeCast: Function - } +interface MySQLConfig { + host: string + port: number + user: string + password: string + database: string + ssl?: { [key: string]: any } + rejectUnauthorized: boolean + typeCast: Function +} - const SCHEMA: Integration = { - docs: "https://github.com/sidorares/node-mysql2", - plus: true, - friendlyName: "MySQL", - type: "Relational", - description: - "MySQL Database Service is a fully managed database service to deploy cloud-native applications. ", - datasource: { - host: { - type: DatasourceFieldType.STRING, - default: "localhost", - required: true, - }, - port: { - type: DatasourceFieldType.NUMBER, - default: 3306, - required: false, - }, - user: { - type: DatasourceFieldType.STRING, - default: "root", - required: true, - }, - password: { - type: DatasourceFieldType.PASSWORD, - default: "root", - required: true, - }, - database: { - type: DatasourceFieldType.STRING, - required: true, - }, - ssl: { - type: DatasourceFieldType.OBJECT, - required: false, - }, - rejectUnauthorized: { - type: DatasourceFieldType.BOOLEAN, - default: true, - required: false, - }, +const SCHEMA: Integration = { + docs: "https://github.com/sidorares/node-mysql2", + plus: true, + friendlyName: "MySQL", + type: "Relational", + description: + "MySQL Database Service is a fully managed database service to deploy cloud-native applications. ", + datasource: { + host: { + type: DatasourceFieldType.STRING, + default: "localhost", + required: true, }, - query: { - create: { - type: QueryType.SQL, - }, - read: { - type: QueryType.SQL, - }, - update: { - type: QueryType.SQL, - }, - delete: { - type: QueryType.SQL, - }, + port: { + type: DatasourceFieldType.NUMBER, + default: 3306, + required: false, }, + user: { + type: DatasourceFieldType.STRING, + default: "root", + required: true, + }, + password: { + type: DatasourceFieldType.PASSWORD, + default: "root", + required: true, + }, + database: { + type: DatasourceFieldType.STRING, + required: true, + }, + ssl: { + type: DatasourceFieldType.OBJECT, + required: false, + }, + rejectUnauthorized: { + type: DatasourceFieldType.BOOLEAN, + default: true, + required: false, + }, + }, + query: { + create: { + type: QueryType.SQL, + }, + read: { + type: QueryType.SQL, + }, + update: { + type: QueryType.SQL, + }, + delete: { + type: QueryType.SQL, + }, + }, +} + +const TimezoneAwareDateTypes = ["timestamp"] + +function bindingTypeCoerce(bindings: any[]) { + for (let i = 0; i < bindings.length; i++) { + const binding = bindings[i] + if (typeof binding !== "string") { + continue + } + const matches = binding.match(NUMBER_REGEX) + // check if number first + if (matches && matches[0] !== "" && !isNaN(Number(matches[0]))) { + bindings[i] = parseFloat(binding) + } + // if not a number, see if it is a date - important to do in this order as any + // integer will be considered a valid date + else if (/^\d/.test(binding) && dayjs(binding).isValid()) { + bindings[i] = dayjs(binding).toDate() + } + } + return bindings +} + +class MySQLIntegration extends Sql implements DatasourcePlus { + private config: MySQLConfig + private client: any + public tables: Record = {} + public schemaErrors: Record = {} + + constructor(config: MySQLConfig) { + super(SqlClient.MY_SQL) + this.config = config + if (config.ssl && Object.keys(config.ssl).length === 0) { + delete config.ssl + } + // make sure this defaults to true + if ( + config.rejectUnauthorized != null && + !config.rejectUnauthorized && + config.ssl + ) { + config.ssl.rejectUnauthorized = config.rejectUnauthorized + } + // @ts-ignore + delete config.rejectUnauthorized + this.config = { + ...config, + typeCast: function (field: any, next: any) { + if ( + field.type == "DATETIME" || + field.type === "DATE" || + field.type === "TIMESTAMP" + ) { + return field.string() + } + return next() + }, + } } - const TimezoneAwareDateTypes = ["timestamp"] - - function bindingTypeCoerce(bindings: any[]) { - for (let i = 0; i < bindings.length; i++) { - const binding = bindings[i] - if (typeof binding !== "string") { - continue - } - const matches = binding.match(NUMBER_REGEX) - // check if number first - if (matches && matches[0] !== "" && !isNaN(Number(matches[0]))) { - bindings[i] = parseFloat(binding) - } - // if not a number, see if it is a date - important to do in this order as any - // integer will be considered a valid date - else if (/^\d/.test(binding) && dayjs(binding).isValid()) { - bindings[i] = dayjs(binding).toDate() - } - } - return bindings + getBindingIdentifier(): string { + return "?" } - class MySQLIntegration extends Sql implements DatasourcePlus { - private config: MySQLConfig - private client: any - public tables: Record = {} - public schemaErrors: Record = {} + getStringConcat(parts: string[]): string { + return `concat(${parts.join(", ")})` + } - constructor(config: MySQLConfig) { - super(SqlClient.MY_SQL) - this.config = config - if (config.ssl && Object.keys(config.ssl).length === 0) { - delete config.ssl + async connect() { + this.client = await mysql.createConnection(this.config) + } + + async disconnect() { + await this.client.end() + } + + async internalQuery( + query: SqlQuery, + opts: { connect?: boolean; disableCoercion?: boolean } = { + connect: true, + disableCoercion: false, + } + ): Promise { + try { + if (opts?.connect) { + await this.connect() } - // make sure this defaults to true - if ( - config.rejectUnauthorized != null && - !config.rejectUnauthorized && - config.ssl - ) { - config.ssl.rejectUnauthorized = config.rejectUnauthorized - } - // @ts-ignore - delete config.rejectUnauthorized - this.config = { - ...config, - typeCast: function (field: any, next: any) { - if ( - field.type == "DATETIME" || - field.type === "DATE" || - field.type === "TIMESTAMP" - ) { - return field.string() - } - return next() - }, + const baseBindings = query.bindings || [] + const bindings = opts?.disableCoercion + ? baseBindings + : bindingTypeCoerce(baseBindings) + // Node MySQL is callback based, so we must wrap our call in a promise + const response = await this.client.query(query.sql, bindings) + return response[0] + } finally { + if (opts?.connect) { + await this.disconnect() } } + } - getBindingIdentifier(): string { - return "?" - } + async buildSchema(datasourceId: string, entities: Record) { + const tables: { [key: string]: Table } = {} + const database = this.config.database + await this.connect() - getStringConcat(parts: string[]): string { - return `concat(${parts.join(", ")})` - } - - async connect() { - this.client = await mysql.createConnection(this.config) - } - - async disconnect() { - await this.client.end() - } - - async internalQuery( - query: SqlQuery, - opts: { connect?: boolean; disableCoercion?: boolean } = { - connect: true, - disableCoercion: false, - } - ): Promise { - try { - if (opts?.connect) { - await this.connect() - } - const baseBindings = query.bindings || [] - const bindings = opts?.disableCoercion - ? baseBindings - : bindingTypeCoerce(baseBindings) - // Node MySQL is callback based, so we must wrap our call in a promise - const response = await this.client.query(query.sql, bindings) - return response[0] - } finally { - if (opts?.connect) { - await this.disconnect() - } - } - } - - async buildSchema(datasourceId: string, entities: Record) { - const tables: { [key: string]: Table } = {} - const database = this.config.database - await this.connect() - - try { - // get the tables first - const tablesResp = await this.internalQuery( - { sql: "SHOW TABLES;" }, + try { + // get the tables first + const tablesResp = await this.internalQuery( + { sql: "SHOW TABLES;" }, + { connect: false } + ) + const tableNames = tablesResp.map( + (obj: any) => + obj[`Tables_in_${database}`] || + obj[`Tables_in_${database.toLowerCase()}`] + ) + for (let tableName of tableNames) { + const primaryKeys = [] + const schema: TableSchema = {} + const descResp = await this.internalQuery( + { sql: `DESCRIBE \`${tableName}\`;` }, { connect: false } ) - const tableNames = tablesResp.map( - (obj: any) => - obj[`Tables_in_${database}`] || - obj[`Tables_in_${database.toLowerCase()}`] - ) - for (let tableName of tableNames) { - const primaryKeys = [] - const schema: TableSchema = {} - const descResp = await this.internalQuery( - { sql: `DESCRIBE \`${tableName}\`;` }, - { connect: false } - ) - for (let column of descResp) { - const columnName = column.Field - if ( - column.Key === "PRI" && - primaryKeys.indexOf(column.Key) === -1 - ) { - primaryKeys.push(columnName) - } - const constraints = { - presence: column.Null !== "YES", - } - const isAuto: boolean = - typeof column.Extra === "string" && - (column.Extra === "auto_increment" || - column.Extra.toLowerCase().includes("generated")) - schema[columnName] = { - name: columnName, - autocolumn: isAuto, - constraints, - ...convertSqlType(column.Type), - externalType: column.Type, - } + for (let column of descResp) { + const columnName = column.Field + if (column.Key === "PRI" && primaryKeys.indexOf(column.Key) === -1) { + primaryKeys.push(columnName) } - if (!tables[tableName]) { - tables[tableName] = { - _id: buildExternalTableId(datasourceId, tableName), - primary: primaryKeys, - name: tableName, - schema, - } + const constraints = { + presence: column.Null !== "YES", + } + const isAuto: boolean = + typeof column.Extra === "string" && + (column.Extra === "auto_increment" || + column.Extra.toLowerCase().includes("generated")) + schema[columnName] = { + name: columnName, + autocolumn: isAuto, + constraints, + ...convertSqlType(column.Type), + externalType: column.Type, + } + } + if (!tables[tableName]) { + tables[tableName] = { + _id: buildExternalTableId(datasourceId, tableName), + primary: primaryKeys, + name: tableName, + schema, } } - } finally { - await this.disconnect() - } - const final = finaliseExternalTables(tables, entities) - this.tables = final.tables - this.schemaErrors = final.errors - } - - async create(query: SqlQuery | string) { - const results = await this.internalQuery(getSqlQuery(query)) - return results.length ? results : [{ created: true }] - } - - async read(query: SqlQuery | string) { - return this.internalQuery(getSqlQuery(query)) - } - - async update(query: SqlQuery | string) { - const results = await this.internalQuery(getSqlQuery(query)) - return results.length ? results : [{ updated: true }] - } - - async delete(query: SqlQuery | string) { - const results = await this.internalQuery(getSqlQuery(query)) - return results.length ? results : [{ deleted: true }] - } - - async query(json: QueryJson) { - await this.connect() - try { - const queryFn = (query: any) => - this.internalQuery(query, { connect: false, disableCoercion: true }) - return await this.queryWithReturning(json, queryFn) - } finally { - await this.disconnect() } + } finally { + await this.disconnect() } + const final = finaliseExternalTables(tables, entities) + this.tables = final.tables + this.schemaErrors = final.errors } - module.exports = { - schema: SCHEMA, - integration: MySQLIntegration, + async create(query: SqlQuery | string) { + const results = await this.internalQuery(getSqlQuery(query)) + return results.length ? results : [{ created: true }] + } + + async read(query: SqlQuery | string) { + return this.internalQuery(getSqlQuery(query)) + } + + async update(query: SqlQuery | string) { + const results = await this.internalQuery(getSqlQuery(query)) + return results.length ? results : [{ updated: true }] + } + + async delete(query: SqlQuery | string) { + const results = await this.internalQuery(getSqlQuery(query)) + return results.length ? results : [{ deleted: true }] + } + + async query(json: QueryJson) { + await this.connect() + try { + const queryFn = (query: any) => + this.internalQuery(query, { connect: false, disableCoercion: true }) + return await this.queryWithReturning(json, queryFn) + } finally { + await this.disconnect() + } } } + +export default { + schema: SCHEMA, + integration: MySQLIntegration, +} diff --git a/packages/server/src/integrations/oracle.ts b/packages/server/src/integrations/oracle.ts index fa8a3837b2..5f35935e12 100644 --- a/packages/server/src/integrations/oracle.ts +++ b/packages/server/src/integrations/oracle.ts @@ -25,437 +25,430 @@ import oracledb, { import Sql from "./base/sql" import { FieldTypes } from "../constants" -module OracleModule { - oracledb.outFormat = oracledb.OUT_FORMAT_OBJECT +oracledb.outFormat = oracledb.OUT_FORMAT_OBJECT - interface OracleConfig { - host: string - port: number - database: string - user: string - password: string - } +interface OracleConfig { + host: string + port: number + database: string + user: string + password: string +} - const SCHEMA: Integration = { - docs: "https://github.com/oracle/node-oracledb", - plus: true, - friendlyName: "Oracle", - type: "Relational", - description: - "Oracle Database is an object-relational database management system developed by Oracle Corporation", - datasource: { - host: { - type: DatasourceFieldType.STRING, - default: "localhost", - required: true, - }, - port: { - type: DatasourceFieldType.NUMBER, - required: true, - default: 1521, - }, - database: { - type: DatasourceFieldType.STRING, - required: true, - }, - user: { - type: DatasourceFieldType.STRING, - required: true, - }, - password: { - type: DatasourceFieldType.PASSWORD, - required: true, - }, +const SCHEMA: Integration = { + docs: "https://github.com/oracle/node-oracledb", + plus: true, + friendlyName: "Oracle", + type: "Relational", + description: + "Oracle Database is an object-relational database management system developed by Oracle Corporation", + datasource: { + host: { + type: DatasourceFieldType.STRING, + default: "localhost", + required: true, }, - query: { - create: { - type: QueryType.SQL, - }, - read: { - type: QueryType.SQL, - }, - update: { - type: QueryType.SQL, - }, - delete: { - type: QueryType.SQL, - }, + port: { + type: DatasourceFieldType.NUMBER, + required: true, + default: 1521, }, + database: { + type: DatasourceFieldType.STRING, + required: true, + }, + user: { + type: DatasourceFieldType.STRING, + required: true, + }, + password: { + type: DatasourceFieldType.PASSWORD, + required: true, + }, + }, + query: { + create: { + type: QueryType.SQL, + }, + read: { + type: QueryType.SQL, + }, + update: { + type: QueryType.SQL, + }, + delete: { + type: QueryType.SQL, + }, + }, +} + +const UNSUPPORTED_TYPES = ["BLOB", "CLOB", "NCLOB"] + +/** + * Raw query response + */ +interface ColumnsResponse { + TABLE_NAME: string + COLUMN_NAME: string + DATA_TYPE: string + DATA_DEFAULT: string | null + COLUMN_ID: number + CONSTRAINT_NAME: string | null + CONSTRAINT_TYPE: string | null + R_CONSTRAINT_NAME: string | null + SEARCH_CONDITION: string | null +} + +/** + * An oracle constraint + */ +interface OracleConstraint { + name: string + type: string + relatedConstraintName: string | null + searchCondition: string | null +} + +/** + * An oracle column and it's related constraints + */ +interface OracleColumn { + name: string + type: string + default: string | null + id: number + constraints: { [key: string]: OracleConstraint } +} + +/** + * An oracle table and it's related columns + */ +interface OracleTable { + name: string + columns: { [key: string]: OracleColumn } +} + +const OracleContraintTypes = { + PRIMARY: "P", + NOT_NULL_OR_CHECK: "C", + FOREIGN_KEY: "R", + UNIQUE: "U", +} + +class OracleIntegration extends Sql implements DatasourcePlus { + private readonly config: OracleConfig + private index: number = 1 + + public tables: Record = {} + public schemaErrors: Record = {} + + private readonly COLUMNS_SQL = ` + SELECT + tabs.table_name, + cols.column_name, + cols.data_type, + cols.data_default, + cols.column_id, + cons.constraint_name, + cons.constraint_type, + cons.r_constraint_name, + cons.search_condition + FROM + user_tables tabs + JOIN + user_tab_columns cols + ON tabs.table_name = cols.table_name + LEFT JOIN + user_cons_columns col_cons + ON cols.column_name = col_cons.column_name + AND cols.table_name = col_cons.table_name + LEFT JOIN + user_constraints cons + ON col_cons.constraint_name = cons.constraint_name + AND cons.table_name = cols.table_name + WHERE + (cons.status = 'ENABLED' + OR cons.status IS NULL) + ` + constructor(config: OracleConfig) { + super(SqlClient.ORACLE) + this.config = config } - const UNSUPPORTED_TYPES = ["BLOB", "CLOB", "NCLOB"] + getBindingIdentifier(): string { + return `:${this.index++}` + } - /** - * Raw query response - */ - interface ColumnsResponse { - TABLE_NAME: string - COLUMN_NAME: string - DATA_TYPE: string - DATA_DEFAULT: string | null - COLUMN_ID: number - CONSTRAINT_NAME: string | null - CONSTRAINT_TYPE: string | null - R_CONSTRAINT_NAME: string | null - SEARCH_CONDITION: string | null + getStringConcat(parts: string[]): string { + return parts.join(" || ") } /** - * An oracle constraint + * Map the flat tabular columns and constraints data into a nested object */ - interface OracleConstraint { - name: string - type: string - relatedConstraintName: string | null - searchCondition: string | null - } + private mapColumns(result: Result): { + [key: string]: OracleTable + } { + const oracleTables: { [key: string]: OracleTable } = {} - /** - * An oracle column and it's related constraints - */ - interface OracleColumn { - name: string - type: string - default: string | null - id: number - constraints: { [key: string]: OracleConstraint } - } + if (result.rows) { + result.rows.forEach(row => { + const tableName = row.TABLE_NAME + const columnName = row.COLUMN_NAME + const dataType = row.DATA_TYPE + const dataDefault = row.DATA_DEFAULT + const columnId = row.COLUMN_ID + const constraintName = row.CONSTRAINT_NAME + const constraintType = row.CONSTRAINT_TYPE + const relatedConstraintName = row.R_CONSTRAINT_NAME + const searchCondition = row.SEARCH_CONDITION - /** - * An oracle table and it's related columns - */ - interface OracleTable { - name: string - columns: { [key: string]: OracleColumn } - } - - const OracleContraintTypes = { - PRIMARY: "P", - NOT_NULL_OR_CHECK: "C", - FOREIGN_KEY: "R", - UNIQUE: "U", - } - - class OracleIntegration extends Sql implements DatasourcePlus { - private readonly config: OracleConfig - private index: number = 1 - - public tables: Record = {} - public schemaErrors: Record = {} - - private readonly COLUMNS_SQL = ` - SELECT - tabs.table_name, - cols.column_name, - cols.data_type, - cols.data_default, - cols.column_id, - cons.constraint_name, - cons.constraint_type, - cons.r_constraint_name, - cons.search_condition - FROM - user_tables tabs - JOIN - user_tab_columns cols - ON tabs.table_name = cols.table_name - LEFT JOIN - user_cons_columns col_cons - ON cols.column_name = col_cons.column_name - AND cols.table_name = col_cons.table_name - LEFT JOIN - user_constraints cons - ON col_cons.constraint_name = cons.constraint_name - AND cons.table_name = cols.table_name - WHERE - (cons.status = 'ENABLED' - OR cons.status IS NULL) - ` - constructor(config: OracleConfig) { - super(SqlClient.ORACLE) - this.config = config - } - - getBindingIdentifier(): string { - return `:${this.index++}` - } - - getStringConcat(parts: string[]): string { - return parts.join(" || ") - } - - /** - * Map the flat tabular columns and constraints data into a nested object - */ - private mapColumns(result: Result): { - [key: string]: OracleTable - } { - const oracleTables: { [key: string]: OracleTable } = {} - - if (result.rows) { - result.rows.forEach(row => { - const tableName = row.TABLE_NAME - const columnName = row.COLUMN_NAME - const dataType = row.DATA_TYPE - const dataDefault = row.DATA_DEFAULT - const columnId = row.COLUMN_ID - const constraintName = row.CONSTRAINT_NAME - const constraintType = row.CONSTRAINT_TYPE - const relatedConstraintName = row.R_CONSTRAINT_NAME - const searchCondition = row.SEARCH_CONDITION - - let table = oracleTables[tableName] - if (!table) { - table = { - name: tableName, - columns: {}, - } - oracleTables[tableName] = table - } - - let column = table.columns[columnName] - if (!column) { - column = { - name: columnName, - type: dataType, - default: dataDefault, - id: columnId, - constraints: {}, - } - table.columns[columnName] = column - } - - if (constraintName && constraintType) { - let constraint = column.constraints[constraintName] - if (!constraint) { - constraint = { - name: constraintName, - type: constraintType, - relatedConstraintName: relatedConstraintName, - searchCondition: searchCondition, - } - } - column.constraints[constraintName] = constraint - } - }) - } - - return oracleTables - } - - private static isSupportedColumn(column: OracleColumn) { - return !UNSUPPORTED_TYPES.includes(column.type) - } - - private static isAutoColumn(column: OracleColumn) { - return !!( - column.default && column.default.toLowerCase().includes("nextval") - ) - } - - /** - * No native boolean in oracle. Best we can do is to check if a manual 1 or 0 number constraint has been set up - * This matches the default behaviour for generating DDL used in knex. - */ - private isBooleanType(column: OracleColumn): boolean { - return ( - column.type.toLowerCase() === "number" && - Object.values(column.constraints).filter(c => { - if ( - c.type === OracleContraintTypes.NOT_NULL_OR_CHECK && - c.searchCondition - ) { - const condition = c.searchCondition - .replace(/\s/g, "") // remove spaces - .replace(/[']+/g, "") // remove quotes - if ( - condition.includes("in(0,1)") || - condition.includes("in(1,0)") - ) { - return true - } - } - return false - }).length > 0 - ) - } - - private internalConvertType(column: OracleColumn): { type: string } { - if (this.isBooleanType(column)) { - return { type: FieldTypes.BOOLEAN } - } - - return convertSqlType(column.type) - } - - /** - * Fetches the tables from the oracle table and assigns them to the datasource. - * @param {*} datasourceId - datasourceId to fetch - * @param entities - the tables that are to be built - */ - async buildSchema(datasourceId: string, entities: Record) { - const columnsResponse = await this.internalQuery({ - sql: this.COLUMNS_SQL, - }) - const oracleTables = this.mapColumns(columnsResponse) - - const tables: { [key: string]: Table } = {} - - // iterate each table - Object.values(oracleTables).forEach(oracleTable => { - let table = tables[oracleTable.name] + let table = oracleTables[tableName] if (!table) { table = { - _id: buildExternalTableId(datasourceId, oracleTable.name), - primary: [], - name: oracleTable.name, - schema: {}, + name: tableName, + columns: {}, } - tables[oracleTable.name] = table + oracleTables[tableName] = table } - // iterate each column on the table - Object.values(oracleTable.columns) - // remove columns that we can't read / save - .filter(oracleColumn => - OracleIntegration.isSupportedColumn(oracleColumn) - ) - // match the order of the columns in the db - .sort((c1, c2) => c1.id - c2.id) - .forEach(oracleColumn => { - const columnName = oracleColumn.name - let fieldSchema = table.schema[columnName] - if (!fieldSchema) { - fieldSchema = { - autocolumn: OracleIntegration.isAutoColumn(oracleColumn), - name: columnName, - ...this.internalConvertType(oracleColumn), - } - table.schema[columnName] = fieldSchema + let column = table.columns[columnName] + if (!column) { + column = { + name: columnName, + type: dataType, + default: dataDefault, + id: columnId, + constraints: {}, + } + table.columns[columnName] = column + } + + if (constraintName && constraintType) { + let constraint = column.constraints[constraintName] + if (!constraint) { + constraint = { + name: constraintName, + type: constraintType, + relatedConstraintName: relatedConstraintName, + searchCondition: searchCondition, } - - // iterate each constraint on the column - Object.values(oracleColumn.constraints).forEach( - oracleConstraint => { - if (oracleConstraint.type === OracleContraintTypes.PRIMARY) { - table.primary!.push(columnName) - } - } - ) - }) + } + column.constraints[constraintName] = constraint + } }) - - const final = finaliseExternalTables(tables, entities) - this.tables = final.tables - this.schemaErrors = final.errors } - private async internalQuery(query: SqlQuery): Promise> { - let connection - try { - this.index = 1 - connection = await this.getConnection() + return oracleTables + } - const options: ExecuteOptions = { autoCommit: true } - const bindings: BindParameters = query.bindings || [] + private static isSupportedColumn(column: OracleColumn) { + return !UNSUPPORTED_TYPES.includes(column.type) + } - return await connection.execute(query.sql, bindings, options) - } finally { - if (connection) { - try { - await connection.close() - } catch (err) { - console.error(err) + private static isAutoColumn(column: OracleColumn) { + return !!( + column.default && column.default.toLowerCase().includes("nextval") + ) + } + + /** + * No native boolean in oracle. Best we can do is to check if a manual 1 or 0 number constraint has been set up + * This matches the default behaviour for generating DDL used in knex. + */ + private isBooleanType(column: OracleColumn): boolean { + return ( + column.type.toLowerCase() === "number" && + Object.values(column.constraints).filter(c => { + if ( + c.type === OracleContraintTypes.NOT_NULL_OR_CHECK && + c.searchCondition + ) { + const condition = c.searchCondition + .replace(/\s/g, "") // remove spaces + .replace(/[']+/g, "") // remove quotes + if (condition.includes("in(0,1)") || condition.includes("in(1,0)")) { + return true } } - } + return false + }).length > 0 + ) + } + + private internalConvertType(column: OracleColumn): { type: string } { + if (this.isBooleanType(column)) { + return { type: FieldTypes.BOOLEAN } } - private getConnection = async (): Promise => { - //connectString : "(DESCRIPTION =(ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521))(CONNECT_DATA =(SID= ORCL)))" - const connectString = `${this.config.host}:${this.config.port || 1521}/${ - this.config.database - }` - const attributes: ConnectionAttributes = { - user: this.config.user, - password: this.config.password, - connectString, - } - return oracledb.getConnection(attributes) - } + return convertSqlType(column.type) + } - async create(query: SqlQuery | string): Promise { - const response = await this.internalQuery(getSqlQuery(query)) - return response.rows && response.rows.length - ? response.rows - : [{ created: true }] - } + /** + * Fetches the tables from the oracle table and assigns them to the datasource. + * @param {*} datasourceId - datasourceId to fetch + * @param entities - the tables that are to be built + */ + async buildSchema(datasourceId: string, entities: Record) { + const columnsResponse = await this.internalQuery({ + sql: this.COLUMNS_SQL, + }) + const oracleTables = this.mapColumns(columnsResponse) - async read(query: SqlQuery | string): Promise { - const response = await this.internalQuery(getSqlQuery(query)) - return response.rows ? response.rows : [] - } + const tables: { [key: string]: Table } = {} - async update(query: SqlQuery | string): Promise { - const response = await this.internalQuery(getSqlQuery(query)) - return response.rows && response.rows.length - ? response.rows - : [{ updated: true }] - } - - async delete(query: SqlQuery | string): Promise { - const response = await this.internalQuery(getSqlQuery(query)) - return response.rows && response.rows.length - ? response.rows - : [{ deleted: true }] - } - - async query(json: QueryJson) { - const operation = this._operation(json) - const input = this._query(json, { disableReturning: true }) - if (Array.isArray(input)) { - const responses = [] - for (let query of input) { - responses.push(await this.internalQuery(query)) - } - return responses - } else { - // read the row to be deleted up front for the return - let deletedRows - if (operation === Operation.DELETE) { - const queryFn = (query: any) => this.internalQuery(query) - deletedRows = await this.getReturningRow(queryFn, json) + // iterate each table + Object.values(oracleTables).forEach(oracleTable => { + let table = tables[oracleTable.name] + if (!table) { + table = { + _id: buildExternalTableId(datasourceId, oracleTable.name), + primary: [], + name: oracleTable.name, + schema: {}, } + tables[oracleTable.name] = table + } - // run the query - const response = await this.internalQuery(input) - - // get the results or return the created / updated / deleted row - if (deletedRows?.rows?.length) { - return deletedRows.rows - } else if (response.rows?.length) { - return response.rows - } else { - // get the last row that was updated - if ( - response.lastRowid && - json.endpoint?.entityId && - operation !== Operation.DELETE - ) { - const lastRow = await this.internalQuery({ - sql: `SELECT * FROM \"${json.endpoint.entityId}\" WHERE ROWID = '${response.lastRowid}'`, - }) - return lastRow.rows - } else { - return [{ [operation.toLowerCase()]: true }] + // iterate each column on the table + Object.values(oracleTable.columns) + // remove columns that we can't read / save + .filter(oracleColumn => + OracleIntegration.isSupportedColumn(oracleColumn) + ) + // match the order of the columns in the db + .sort((c1, c2) => c1.id - c2.id) + .forEach(oracleColumn => { + const columnName = oracleColumn.name + let fieldSchema = table.schema[columnName] + if (!fieldSchema) { + fieldSchema = { + autocolumn: OracleIntegration.isAutoColumn(oracleColumn), + name: columnName, + ...this.internalConvertType(oracleColumn), + } + table.schema[columnName] = fieldSchema } + + // iterate each constraint on the column + Object.values(oracleColumn.constraints).forEach(oracleConstraint => { + if (oracleConstraint.type === OracleContraintTypes.PRIMARY) { + table.primary!.push(columnName) + } + }) + }) + }) + + const final = finaliseExternalTables(tables, entities) + this.tables = final.tables + this.schemaErrors = final.errors + } + + private async internalQuery(query: SqlQuery): Promise> { + let connection + try { + this.index = 1 + connection = await this.getConnection() + + const options: ExecuteOptions = { autoCommit: true } + const bindings: BindParameters = query.bindings || [] + + return await connection.execute(query.sql, bindings, options) + } finally { + if (connection) { + try { + await connection.close() + } catch (err) { + console.error(err) } } } } - module.exports = { - schema: SCHEMA, - integration: OracleIntegration, + private getConnection = async (): Promise => { + //connectString : "(DESCRIPTION =(ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521))(CONNECT_DATA =(SID= ORCL)))" + const connectString = `${this.config.host}:${this.config.port || 1521}/${ + this.config.database + }` + const attributes: ConnectionAttributes = { + user: this.config.user, + password: this.config.password, + connectString, + } + return oracledb.getConnection(attributes) + } + + async create(query: SqlQuery | string): Promise { + const response = await this.internalQuery(getSqlQuery(query)) + return response.rows && response.rows.length + ? response.rows + : [{ created: true }] + } + + async read(query: SqlQuery | string): Promise { + const response = await this.internalQuery(getSqlQuery(query)) + return response.rows ? response.rows : [] + } + + async update(query: SqlQuery | string): Promise { + const response = await this.internalQuery(getSqlQuery(query)) + return response.rows && response.rows.length + ? response.rows + : [{ updated: true }] + } + + async delete(query: SqlQuery | string): Promise { + const response = await this.internalQuery(getSqlQuery(query)) + return response.rows && response.rows.length + ? response.rows + : [{ deleted: true }] + } + + async query(json: QueryJson) { + const operation = this._operation(json) + const input = this._query(json, { disableReturning: true }) + if (Array.isArray(input)) { + const responses = [] + for (let query of input) { + responses.push(await this.internalQuery(query)) + } + return responses + } else { + // read the row to be deleted up front for the return + let deletedRows + if (operation === Operation.DELETE) { + const queryFn = (query: any) => this.internalQuery(query) + deletedRows = await this.getReturningRow(queryFn, json) + } + + // run the query + const response = await this.internalQuery(input) + + // get the results or return the created / updated / deleted row + if (deletedRows?.rows?.length) { + return deletedRows.rows + } else if (response.rows?.length) { + return response.rows + } else { + // get the last row that was updated + if ( + response.lastRowid && + json.endpoint?.entityId && + operation !== Operation.DELETE + ) { + const lastRow = await this.internalQuery({ + sql: `SELECT * FROM \"${json.endpoint.entityId}\" WHERE ROWID = '${response.lastRowid}'`, + }) + return lastRow.rows + } else { + return [{ [operation.toLowerCase()]: true }] + } + } + } } } + +export default { + schema: SCHEMA, + integration: OracleIntegration, +} diff --git a/packages/server/src/integrations/postgres.ts b/packages/server/src/integrations/postgres.ts index 316311e193..da1124f421 100644 --- a/packages/server/src/integrations/postgres.ts +++ b/packages/server/src/integrations/postgres.ts @@ -16,317 +16,313 @@ import { } from "./utils" import Sql from "./base/sql" -module PostgresModule { - const { Client, types } = require("pg") - const { escapeDangerousCharacters } = require("../utilities") +const { Client, types } = require("pg") +const { escapeDangerousCharacters } = require("../utilities") - // Return "date" and "timestamp" types as plain strings. - // This lets us reference the original stored timezone. - // types is undefined when running in a test env for some reason. - if (types) { - types.setTypeParser(1114, (val: any) => val) // timestamp - types.setTypeParser(1082, (val: any) => val) // date - types.setTypeParser(1184, (val: any) => val) // timestampz - } +// Return "date" and "timestamp" types as plain strings. +// This lets us reference the original stored timezone. +// types is undefined when running in a test env for some reason. +if (types) { + types.setTypeParser(1114, (val: any) => val) // timestamp + types.setTypeParser(1082, (val: any) => val) // date + types.setTypeParser(1184, (val: any) => val) // timestampz +} - const JSON_REGEX = /'{.*}'::json/s +const JSON_REGEX = /'{.*}'::json/s - interface PostgresConfig { - host: string - port: number - database: string - user: string - password: string - schema: string - ssl?: boolean - ca?: string - rejectUnauthorized?: boolean - } +interface PostgresConfig { + host: string + port: number + database: string + user: string + password: string + schema: string + ssl?: boolean + ca?: string + rejectUnauthorized?: boolean +} - const SCHEMA: Integration = { - docs: "https://node-postgres.com", - plus: true, - friendlyName: "PostgreSQL", - type: "Relational", - description: - "PostgreSQL, also known as Postgres, is a free and open-source relational database management system emphasizing extensibility and SQL compliance.", - datasource: { - host: { - type: DatasourceFieldType.STRING, - default: "localhost", - required: true, - }, - port: { - type: DatasourceFieldType.NUMBER, - required: true, - default: 5432, - }, - database: { - type: DatasourceFieldType.STRING, - default: "postgres", - required: true, - }, - user: { - type: DatasourceFieldType.STRING, - default: "root", - required: true, - }, - password: { - type: DatasourceFieldType.PASSWORD, - default: "root", - required: true, - }, - schema: { - type: DatasourceFieldType.STRING, - default: "public", - required: true, - }, - ssl: { - type: DatasourceFieldType.BOOLEAN, - default: false, - required: false, - }, - rejectUnauthorized: { - type: DatasourceFieldType.BOOLEAN, - default: false, - required: false, - }, - ca: { - type: DatasourceFieldType.LONGFORM, - default: false, - required: false, - }, +const SCHEMA: Integration = { + docs: "https://node-postgres.com", + plus: true, + friendlyName: "PostgreSQL", + type: "Relational", + description: + "PostgreSQL, also known as Postgres, is a free and open-source relational database management system emphasizing extensibility and SQL compliance.", + datasource: { + host: { + type: DatasourceFieldType.STRING, + default: "localhost", + required: true, }, - query: { - create: { - type: QueryType.SQL, - }, - read: { - type: QueryType.SQL, - }, - update: { - type: QueryType.SQL, - }, - delete: { - type: QueryType.SQL, - }, + port: { + type: DatasourceFieldType.NUMBER, + required: true, + default: 5432, }, - } + database: { + type: DatasourceFieldType.STRING, + default: "postgres", + required: true, + }, + user: { + type: DatasourceFieldType.STRING, + default: "root", + required: true, + }, + password: { + type: DatasourceFieldType.PASSWORD, + default: "root", + required: true, + }, + schema: { + type: DatasourceFieldType.STRING, + default: "public", + required: true, + }, + ssl: { + type: DatasourceFieldType.BOOLEAN, + default: false, + required: false, + }, + rejectUnauthorized: { + type: DatasourceFieldType.BOOLEAN, + default: false, + required: false, + }, + ca: { + type: DatasourceFieldType.LONGFORM, + default: false, + required: false, + }, + }, + query: { + create: { + type: QueryType.SQL, + }, + read: { + type: QueryType.SQL, + }, + update: { + type: QueryType.SQL, + }, + delete: { + type: QueryType.SQL, + }, + }, +} - class PostgresIntegration extends Sql implements DatasourcePlus { - private readonly client: any - private readonly config: PostgresConfig - private index: number = 1 - private open: boolean - public tables: Record = {} - public schemaErrors: Record = {} +class PostgresIntegration extends Sql implements DatasourcePlus { + private readonly client: any + private readonly config: PostgresConfig + private index: number = 1 + private open: boolean + public tables: Record = {} + public schemaErrors: Record = {} - COLUMNS_SQL!: string + COLUMNS_SQL!: string - PRIMARY_KEYS_SQL = ` - select tc.table_schema, tc.table_name, kc.column_name as primary_key - from information_schema.table_constraints tc - join - information_schema.key_column_usage kc on kc.table_name = tc.table_name - and kc.table_schema = tc.table_schema - and kc.constraint_name = tc.constraint_name - where tc.constraint_type = 'PRIMARY KEY'; - ` + PRIMARY_KEYS_SQL = ` + select tc.table_schema, tc.table_name, kc.column_name as primary_key + from information_schema.table_constraints tc + join + information_schema.key_column_usage kc on kc.table_name = tc.table_name + and kc.table_schema = tc.table_schema + and kc.constraint_name = tc.constraint_name + where tc.constraint_type = 'PRIMARY KEY'; + ` - constructor(config: PostgresConfig) { - super(SqlClient.POSTGRES) - this.config = config + constructor(config: PostgresConfig) { + super(SqlClient.POSTGRES) + this.config = config - let newConfig = { - ...this.config, - ssl: this.config.ssl - ? { - rejectUnauthorized: this.config.rejectUnauthorized, - ca: this.config.ca, - } - : undefined, - } - this.client = new Client(newConfig) - this.open = false - } - - getBindingIdentifier(): string { - return `$${this.index++}` - } - - getStringConcat(parts: string[]): string { - return parts.join(" || ") - } - - async openConnection() { - await this.client.connect() - if (!this.config.schema) { - this.config.schema = "public" - } - this.client.query(`SET search_path TO ${this.config.schema}`) - this.COLUMNS_SQL = `select * from information_schema.columns where table_schema = '${this.config.schema}'` - this.open = true - } - - closeConnection() { - const pg = this - return new Promise((resolve, reject) => { - this.client.end((err: any) => { - pg.open = false - if (err) { - reject(err) - } else { - resolve() + let newConfig = { + ...this.config, + ssl: this.config.ssl + ? { + rejectUnauthorized: this.config.rejectUnauthorized, + ca: this.config.ca, } - }) + : undefined, + } + this.client = new Client(newConfig) + this.open = false + } + + getBindingIdentifier(): string { + return `$${this.index++}` + } + + getStringConcat(parts: string[]): string { + return parts.join(" || ") + } + + async openConnection() { + await this.client.connect() + if (!this.config.schema) { + this.config.schema = "public" + } + this.client.query(`SET search_path TO ${this.config.schema}`) + this.COLUMNS_SQL = `select * from information_schema.columns where table_schema = '${this.config.schema}'` + this.open = true + } + + closeConnection() { + const pg = this + return new Promise((resolve, reject) => { + this.client.end((err: any) => { + pg.open = false + if (err) { + reject(err) + } else { + resolve() + } }) - } + }) + } - async internalQuery(query: SqlQuery, close: boolean = true) { - if (!this.open) { - await this.openConnection() - } - const client = this.client - this.index = 1 - // need to handle a specific issue with json data types in postgres, - // new lines inside the JSON data will break it - if (query && query.sql) { - const matches = query.sql.match(JSON_REGEX) - if (matches && matches.length > 0) { - for (let match of matches) { - const escaped = escapeDangerousCharacters(match) - query.sql = query.sql.replace(match, escaped) - } - } - } - try { - return await client.query(query.sql, query.bindings || []) - } catch (err) { - await this.closeConnection() - // @ts-ignore - throw new Error(err) - } finally { - if (close) { - await this.closeConnection() - } - } - } - - /** - * Fetches the tables from the postgres table and assigns them to the datasource. - * @param {*} datasourceId - datasourceId to fetch - * @param entities - the tables that are to be built - */ - async buildSchema(datasourceId: string, entities: Record) { - let tableKeys: { [key: string]: string[] } = {} + async internalQuery(query: SqlQuery, close: boolean = true) { + if (!this.open) { await this.openConnection() - try { - const primaryKeysResponse = await this.client.query( - this.PRIMARY_KEYS_SQL - ) - for (let table of primaryKeysResponse.rows) { - const tableName = table.table_name - if (!tableKeys[tableName]) { - tableKeys[tableName] = [] - } - const key = table.column_name || table.primary_key - // only add the unique keys - if (key && tableKeys[tableName].indexOf(key) === -1) { - tableKeys[tableName].push(key) - } + } + const client = this.client + this.index = 1 + // need to handle a specific issue with json data types in postgres, + // new lines inside the JSON data will break it + if (query && query.sql) { + const matches = query.sql.match(JSON_REGEX) + if (matches && matches.length > 0) { + for (let match of matches) { + const escaped = escapeDangerousCharacters(match) + query.sql = query.sql.replace(match, escaped) } - } catch (err) { - tableKeys = {} - } - - try { - const columnsResponse = await this.client.query(this.COLUMNS_SQL) - - const tables: { [key: string]: Table } = {} - - for (let column of columnsResponse.rows) { - const tableName: string = column.table_name - const columnName: string = column.column_name - - // table key doesn't exist yet - if (!tables[tableName] || !tables[tableName].schema) { - tables[tableName] = { - _id: buildExternalTableId(datasourceId, tableName), - primary: tableKeys[tableName] || [], - name: tableName, - schema: {}, - } - } - - const identity = !!( - column.identity_generation || - column.identity_start || - column.identity_increment - ) - const hasDefault = - typeof column.column_default === "string" && - column.column_default.startsWith("nextval") - const isGenerated = - column.is_generated && column.is_generated !== "NEVER" - const isAuto: boolean = hasDefault || identity || isGenerated - tables[tableName].schema[columnName] = { - autocolumn: isAuto, - name: columnName, - ...convertSqlType(column.data_type), - externalType: column.data_type, - } - } - - const final = finaliseExternalTables(tables, entities) - this.tables = final.tables - this.schemaErrors = final.errors - } catch (err) { - // @ts-ignore - throw new Error(err) - } finally { - await this.closeConnection() } } - - async create(query: SqlQuery | string) { - const response = await this.internalQuery(getSqlQuery(query)) - return response.rows.length ? response.rows : [{ created: true }] - } - - async read(query: SqlQuery | string) { - const response = await this.internalQuery(getSqlQuery(query)) - return response.rows - } - - async update(query: SqlQuery | string) { - const response = await this.internalQuery(getSqlQuery(query)) - return response.rows.length ? response.rows : [{ updated: true }] - } - - async delete(query: SqlQuery | string) { - const response = await this.internalQuery(getSqlQuery(query)) - return response.rows.length ? response.rows : [{ deleted: true }] - } - - async query(json: QueryJson) { - const operation = this._operation(json).toLowerCase() - const input = this._query(json) - if (Array.isArray(input)) { - const responses = [] - for (let query of input) { - responses.push(await this.internalQuery(query, false)) - } + try { + return await client.query(query.sql, query.bindings || []) + } catch (err) { + await this.closeConnection() + // @ts-ignore + throw new Error(err) + } finally { + if (close) { await this.closeConnection() - return responses - } else { - const response = await this.internalQuery(input) - return response.rows.length ? response.rows : [{ [operation]: true }] } } } - module.exports = { - schema: SCHEMA, - integration: PostgresIntegration, + /** + * Fetches the tables from the postgres table and assigns them to the datasource. + * @param {*} datasourceId - datasourceId to fetch + * @param entities - the tables that are to be built + */ + async buildSchema(datasourceId: string, entities: Record) { + let tableKeys: { [key: string]: string[] } = {} + await this.openConnection() + try { + const primaryKeysResponse = await this.client.query(this.PRIMARY_KEYS_SQL) + for (let table of primaryKeysResponse.rows) { + const tableName = table.table_name + if (!tableKeys[tableName]) { + tableKeys[tableName] = [] + } + const key = table.column_name || table.primary_key + // only add the unique keys + if (key && tableKeys[tableName].indexOf(key) === -1) { + tableKeys[tableName].push(key) + } + } + } catch (err) { + tableKeys = {} + } + + try { + const columnsResponse = await this.client.query(this.COLUMNS_SQL) + + const tables: { [key: string]: Table } = {} + + for (let column of columnsResponse.rows) { + const tableName: string = column.table_name + const columnName: string = column.column_name + + // table key doesn't exist yet + if (!tables[tableName] || !tables[tableName].schema) { + tables[tableName] = { + _id: buildExternalTableId(datasourceId, tableName), + primary: tableKeys[tableName] || [], + name: tableName, + schema: {}, + } + } + + const identity = !!( + column.identity_generation || + column.identity_start || + column.identity_increment + ) + const hasDefault = + typeof column.column_default === "string" && + column.column_default.startsWith("nextval") + const isGenerated = + column.is_generated && column.is_generated !== "NEVER" + const isAuto: boolean = hasDefault || identity || isGenerated + tables[tableName].schema[columnName] = { + autocolumn: isAuto, + name: columnName, + ...convertSqlType(column.data_type), + externalType: column.data_type, + } + } + + const final = finaliseExternalTables(tables, entities) + this.tables = final.tables + this.schemaErrors = final.errors + } catch (err) { + // @ts-ignore + throw new Error(err) + } finally { + await this.closeConnection() + } + } + + async create(query: SqlQuery | string) { + const response = await this.internalQuery(getSqlQuery(query)) + return response.rows.length ? response.rows : [{ created: true }] + } + + async read(query: SqlQuery | string) { + const response = await this.internalQuery(getSqlQuery(query)) + return response.rows + } + + async update(query: SqlQuery | string) { + const response = await this.internalQuery(getSqlQuery(query)) + return response.rows.length ? response.rows : [{ updated: true }] + } + + async delete(query: SqlQuery | string) { + const response = await this.internalQuery(getSqlQuery(query)) + return response.rows.length ? response.rows : [{ deleted: true }] + } + + async query(json: QueryJson) { + const operation = this._operation(json).toLowerCase() + const input = this._query(json) + if (Array.isArray(input)) { + const responses = [] + for (let query of input) { + responses.push(await this.internalQuery(query, false)) + } + await this.closeConnection() + return responses + } else { + const response = await this.internalQuery(input) + return response.rows.length ? response.rows : [{ [operation]: true }] + } } } + +export default { + schema: SCHEMA, + integration: PostgresIntegration, +} diff --git a/packages/server/src/integrations/redis.ts b/packages/server/src/integrations/redis.ts index e8aa13560c..ebf7d2a82a 100644 --- a/packages/server/src/integrations/redis.ts +++ b/packages/server/src/integrations/redis.ts @@ -1,149 +1,147 @@ import { DatasourceFieldType, Integration, QueryType } from "@budibase/types" import Redis from "ioredis" -module RedisModule { - interface RedisConfig { - host: string - port: number - username: string - password?: string - } +interface RedisConfig { + host: string + port: number + username: string + password?: string +} - const SCHEMA: Integration = { - docs: "https://redis.io/docs/", - description: "", - friendlyName: "Redis", - type: "Non-relational", - datasource: { - host: { - type: "string", - required: true, - default: "localhost", - }, - port: { - type: "number", - required: true, - default: 6379, - }, - username: { - type: "string", - required: false, - }, - password: { - type: "password", - required: false, +const SCHEMA: Integration = { + docs: "https://redis.io/docs/", + description: "", + friendlyName: "Redis", + type: "Non-relational", + datasource: { + host: { + type: "string", + required: true, + default: "localhost", + }, + port: { + type: "number", + required: true, + default: 6379, + }, + username: { + type: "string", + required: false, + }, + password: { + type: "password", + required: false, + }, + }, + query: { + create: { + type: QueryType.FIELDS, + fields: { + key: { + type: DatasourceFieldType.STRING, + required: true, + }, + value: { + type: DatasourceFieldType.STRING, + required: true, + }, + ttl: { + type: DatasourceFieldType.NUMBER, + }, }, }, - query: { - create: { - type: QueryType.FIELDS, - fields: { - key: { - type: DatasourceFieldType.STRING, - required: true, - }, - value: { - type: DatasourceFieldType.STRING, - required: true, - }, - ttl: { - type: DatasourceFieldType.NUMBER, - }, + read: { + readable: true, + type: QueryType.FIELDS, + fields: { + key: { + type: DatasourceFieldType.STRING, + required: true, }, }, - read: { - readable: true, - type: QueryType.FIELDS, - fields: { - key: { - type: DatasourceFieldType.STRING, - required: true, - }, - }, - }, - delete: { - type: QueryType.FIELDS, - fields: { - key: { - type: DatasourceFieldType.STRING, - required: true, - }, - }, - }, - command: { - readable: true, - displayName: "Redis Command", - type: QueryType.JSON, - }, }, + delete: { + type: QueryType.FIELDS, + fields: { + key: { + type: DatasourceFieldType.STRING, + required: true, + }, + }, + }, + command: { + readable: true, + displayName: "Redis Command", + type: QueryType.JSON, + }, + }, +} + +class RedisIntegration { + private readonly config: RedisConfig + private client: any + + constructor(config: RedisConfig) { + this.config = config + this.client = new Redis({ + host: this.config.host, + port: this.config.port, + username: this.config.username, + password: this.config.password, + }) } - class RedisIntegration { - private readonly config: RedisConfig - private client: any + async disconnect() { + this.client.disconnect() + } - constructor(config: RedisConfig) { - this.config = config - this.client = new Redis({ - host: this.config.host, - port: this.config.port, - username: this.config.username, - password: this.config.password, - }) + async redisContext(query: Function) { + try { + return await query() + } catch (err) { + throw new Error(`Redis error: ${err}`) + } finally { + this.disconnect() } + } - async disconnect() { - this.client.disconnect() - } - - async redisContext(query: Function) { - try { - return await query() - } catch (err) { - throw new Error(`Redis error: ${err}`) - } finally { - this.disconnect() + async create(query: { key: string; value: string; ttl: number }) { + return this.redisContext(async () => { + const response = await this.client.set(query.key, query.value) + if (query.ttl) { + await this.client.expire(query.key, query.ttl) } - } - - async create(query: { key: string; value: string; ttl: number }) { - return this.redisContext(async () => { - const response = await this.client.set(query.key, query.value) - if (query.ttl) { - await this.client.expire(query.key, query.ttl) - } - return response - }) - } - - async read(query: { key: string }) { - return this.redisContext(async () => { - const response = await this.client.get(query.key) - return response - }) - } - - async delete(query: { key: string }) { - return this.redisContext(async () => { - const response = await this.client.del(query.key) - return response - }) - } - - async command(query: { json: string }) { - return this.redisContext(async () => { - const commands = query.json.trim().split(" ") - const pipeline = this.client.pipeline([commands]) - const result = await pipeline.exec() - return { - response: result[0][1], - } - }) - } + return response + }) } - module.exports = { - schema: SCHEMA, - integration: RedisIntegration, + async read(query: { key: string }) { + return this.redisContext(async () => { + const response = await this.client.get(query.key) + return response + }) + } + + async delete(query: { key: string }) { + return this.redisContext(async () => { + const response = await this.client.del(query.key) + return response + }) + } + + async command(query: { json: string }) { + return this.redisContext(async () => { + const commands = query.json.trim().split(" ") + const pipeline = this.client.pipeline([commands]) + const result = await pipeline.exec() + return { + response: result[0][1], + } + }) } } + +export default { + schema: SCHEMA, + integration: RedisIntegration, +} diff --git a/packages/server/src/integrations/rest.ts b/packages/server/src/integrations/rest.ts index 284d2a921a..5126e0100e 100644 --- a/packages/server/src/integrations/rest.ts +++ b/packages/server/src/integrations/rest.ts @@ -14,6 +14,11 @@ import { BearerAuthConfig, } from "../definitions/datasource" import { get } from "lodash" +const fetch = require("node-fetch") +const { formatBytes } = require("../utilities") +const { performance } = require("perf_hooks") +const FormData = require("form-data") +const { URLSearchParams } = require("url") const BodyTypes = { NONE: "none", @@ -50,363 +55,353 @@ const coreFields = { }, } -module RestModule { - const fetch = require("node-fetch") - const { formatBytes } = require("../utilities") - const { performance } = require("perf_hooks") - const FormData = require("form-data") - const { URLSearchParams } = require("url") - const { - parseStringPromise: xmlParser, - Builder: XmlBuilder, - } = require("xml2js") +const { parseStringPromise: xmlParser, Builder: XmlBuilder } = require("xml2js") - const SCHEMA: Integration = { - docs: "https://github.com/node-fetch/node-fetch", - description: - "With the REST API datasource, you can connect, query and pull data from multiple REST APIs. You can then use the retrieved data to build apps.", - friendlyName: "REST API", - type: "API", - datasource: { - url: { - type: DatasourceFieldType.STRING, - default: "", - required: false, - deprecated: true, - }, - defaultHeaders: { - type: DatasourceFieldType.OBJECT, - required: false, - default: {}, - }, +const SCHEMA: Integration = { + docs: "https://github.com/node-fetch/node-fetch", + description: + "With the REST API datasource, you can connect, query and pull data from multiple REST APIs. You can then use the retrieved data to build apps.", + friendlyName: "REST API", + type: "API", + datasource: { + url: { + type: DatasourceFieldType.STRING, + default: "", + required: false, + deprecated: true, }, - query: { - create: { - readable: true, - displayName: "POST", - type: QueryType.FIELDS, - fields: coreFields, - }, - read: { - displayName: "GET", - readable: true, - type: QueryType.FIELDS, - fields: coreFields, - }, - update: { - displayName: "PUT", - readable: true, - type: QueryType.FIELDS, - fields: coreFields, - }, - patch: { - displayName: "PATCH", - readable: true, - type: QueryType.FIELDS, - fields: coreFields, - }, - delete: { - displayName: "DELETE", - type: QueryType.FIELDS, - fields: coreFields, - }, + defaultHeaders: { + type: DatasourceFieldType.OBJECT, + required: false, + default: {}, }, + }, + query: { + create: { + readable: true, + displayName: "POST", + type: QueryType.FIELDS, + fields: coreFields, + }, + read: { + displayName: "GET", + readable: true, + type: QueryType.FIELDS, + fields: coreFields, + }, + update: { + displayName: "PUT", + readable: true, + type: QueryType.FIELDS, + fields: coreFields, + }, + patch: { + displayName: "PATCH", + readable: true, + type: QueryType.FIELDS, + fields: coreFields, + }, + delete: { + displayName: "DELETE", + type: QueryType.FIELDS, + fields: coreFields, + }, + }, +} + +class RestIntegration implements IntegrationBase { + private config: RestConfig + private headers: { + [key: string]: string + } = {} + private startTimeMs: number = performance.now() + + constructor(config: RestConfig) { + this.config = config } - class RestIntegration implements IntegrationBase { - private config: RestConfig - private headers: { - [key: string]: string - } = {} - private startTimeMs: number = performance.now() - - constructor(config: RestConfig) { - this.config = config + async parseResponse(response: any, pagination: PaginationConfig | null) { + let data, raw, headers + const contentType = response.headers.get("content-type") || "" + try { + if (contentType.includes("application/json")) { + data = await response.json() + raw = JSON.stringify(data) + } else if ( + contentType.includes("text/xml") || + contentType.includes("application/xml") + ) { + const rawXml = await response.text() + data = + (await xmlParser(rawXml, { + explicitArray: false, + trim: true, + explicitRoot: false, + })) || {} + // there is only one structure, its an array, return the array so it appears as rows + const keys = Object.keys(data) + if (keys.length === 1 && Array.isArray(data[keys[0]])) { + data = data[keys[0]] + } + raw = rawXml + } else { + data = await response.text() + raw = data + } + } catch (err) { + throw "Failed to parse response body." + } + const size = formatBytes( + response.headers.get("content-length") || Buffer.byteLength(raw, "utf8") + ) + const time = `${Math.round(performance.now() - this.startTimeMs)}ms` + headers = response.headers.raw() + for (let [key, value] of Object.entries(headers)) { + headers[key] = Array.isArray(value) ? value[0] : value } - async parseResponse(response: any, pagination: PaginationConfig | null) { - let data, raw, headers - const contentType = response.headers.get("content-type") || "" - try { - if (contentType.includes("application/json")) { - data = await response.json() - raw = JSON.stringify(data) - } else if ( - contentType.includes("text/xml") || - contentType.includes("application/xml") - ) { - const rawXml = await response.text() - data = - (await xmlParser(rawXml, { - explicitArray: false, - trim: true, - explicitRoot: false, - })) || {} - // there is only one structure, its an array, return the array so it appears as rows - const keys = Object.keys(data) - if (keys.length === 1 && Array.isArray(data[keys[0]])) { - data = data[keys[0]] - } - raw = rawXml - } else { - data = await response.text() - raw = data - } - } catch (err) { - throw "Failed to parse response body." - } - const size = formatBytes( - response.headers.get("content-length") || Buffer.byteLength(raw, "utf8") - ) - const time = `${Math.round(performance.now() - this.startTimeMs)}ms` - headers = response.headers.raw() - for (let [key, value] of Object.entries(headers)) { - headers[key] = Array.isArray(value) ? value[0] : value + // Check if a pagination cursor exists in the response + let nextCursor = null + if (pagination?.responseParam) { + nextCursor = get(data, pagination.responseParam) + } + + return { + data, + info: { + code: response.status, + size, + time, + }, + extra: { + raw, + headers, + }, + pagination: { + cursor: nextCursor, + }, + } + } + + getUrl( + path: string, + queryString: string, + pagination: PaginationConfig | null, + paginationValues: PaginationValues | null + ): string { + // Add pagination params to query string if required + if (pagination?.location === "query" && paginationValues) { + const { pageParam, sizeParam } = pagination + const params = new URLSearchParams() + + // Append page number or cursor param if configured + if (pageParam && paginationValues.page != null) { + params.append(pageParam, paginationValues.page) } - // Check if a pagination cursor exists in the response - let nextCursor = null - if (pagination?.responseParam) { - nextCursor = get(data, pagination.responseParam) + // Append page size param if configured + if (sizeParam && paginationValues.limit != null) { + params.append(sizeParam, paginationValues.limit) } - return { - data, - info: { - code: response.status, - size, - time, - }, - extra: { - raw, - headers, - }, - pagination: { - cursor: nextCursor, - }, + // Prepend query string with pagination params + let paginationString = params.toString() + if (paginationString) { + queryString = `${paginationString}&${queryString}` } } - getUrl( - path: string, - queryString: string, - pagination: PaginationConfig | null, - paginationValues: PaginationValues | null - ): string { - // Add pagination params to query string if required - if (pagination?.location === "query" && paginationValues) { - const { pageParam, sizeParam } = pagination - const params = new URLSearchParams() - - // Append page number or cursor param if configured - if (pageParam && paginationValues.page != null) { - params.append(pageParam, paginationValues.page) - } - - // Append page size param if configured - if (sizeParam && paginationValues.limit != null) { - params.append(sizeParam, paginationValues.limit) - } - - // Prepend query string with pagination params - let paginationString = params.toString() - if (paginationString) { - queryString = `${paginationString}&${queryString}` - } - } - - const main = `${path}?${queryString}` - let complete = main - if (this.config.url && !main.startsWith("http")) { - complete = !this.config.url ? main : `${this.config.url}/${main}` - } - if (!complete.startsWith("http")) { - complete = `http://${complete}` - } - return complete + const main = `${path}?${queryString}` + let complete = main + if (this.config.url && !main.startsWith("http")) { + complete = !this.config.url ? main : `${this.config.url}/${main}` } + if (!complete.startsWith("http")) { + complete = `http://${complete}` + } + return complete + } - addBody( - bodyType: string, - body: string | any, - input: any, - pagination: PaginationConfig | null, - paginationValues: PaginationValues | null - ) { - if (!input.headers) { - input.headers = {} - } - if (bodyType === BodyTypes.NONE) { - return input - } - let error, - object: any = {}, - string = "" - try { - if (body) { - string = typeof body !== "string" ? JSON.stringify(body) : body - object = typeof body === "object" ? body : JSON.parse(body) - } - } catch (err) { - error = err - } - - // Util to add pagination values to a certain body type - const addPaginationToBody = (insertFn: Function) => { - if (pagination?.location === "body") { - if (pagination?.pageParam && paginationValues?.page != null) { - insertFn(pagination.pageParam, paginationValues.page) - } - if (pagination?.sizeParam && paginationValues?.limit != null) { - insertFn(pagination.sizeParam, paginationValues.limit) - } - } - } - - switch (bodyType) { - case BodyTypes.TEXT: - // content type defaults to plaintext - input.body = string - break - case BodyTypes.ENCODED: - const params = new URLSearchParams() - for (let [key, value] of Object.entries(object)) { - params.append(key, value) - } - addPaginationToBody((key: string, value: any) => { - params.append(key, value) - }) - input.body = params - break - case BodyTypes.FORM_DATA: - const form = new FormData() - for (let [key, value] of Object.entries(object)) { - form.append(key, value) - } - addPaginationToBody((key: string, value: any) => { - form.append(key, value) - }) - input.body = form - break - case BodyTypes.XML: - if (object != null && Object.keys(object).length) { - string = new XmlBuilder().buildObject(object) - } - input.body = string - input.headers["Content-Type"] = "application/xml" - break - case BodyTypes.JSON: - // if JSON error, throw it - if (error) { - throw "Invalid JSON for request body" - } - addPaginationToBody((key: string, value: any) => { - object[key] = value - }) - input.body = JSON.stringify(object) - input.headers["Content-Type"] = "application/json" - break - } + addBody( + bodyType: string, + body: string | any, + input: any, + pagination: PaginationConfig | null, + paginationValues: PaginationValues | null + ) { + if (!input.headers) { + input.headers = {} + } + if (bodyType === BodyTypes.NONE) { return input } + let error, + object: any = {}, + string = "" + try { + if (body) { + string = typeof body !== "string" ? JSON.stringify(body) : body + object = typeof body === "object" ? body : JSON.parse(body) + } + } catch (err) { + error = err + } - getAuthHeaders(authConfigId: string): { [key: string]: any } { - let headers: any = {} - - if (this.config.authConfigs && authConfigId) { - const authConfig = this.config.authConfigs.filter( - c => c._id === authConfigId - )[0] - // check the config still exists before proceeding - // if not - do nothing - if (authConfig) { - let config - switch (authConfig.type) { - case AuthType.BASIC: - config = authConfig.config as BasicAuthConfig - headers.Authorization = `Basic ${Buffer.from( - `${config.username}:${config.password}` - ).toString("base64")}` - break - case AuthType.BEARER: - config = authConfig.config as BearerAuthConfig - headers.Authorization = `Bearer ${config.token}` - break - } + // Util to add pagination values to a certain body type + const addPaginationToBody = (insertFn: Function) => { + if (pagination?.location === "body") { + if (pagination?.pageParam && paginationValues?.page != null) { + insertFn(pagination.pageParam, paginationValues.page) + } + if (pagination?.sizeParam && paginationValues?.limit != null) { + insertFn(pagination.sizeParam, paginationValues.limit) } } - - return headers } - async _req(query: RestQuery) { - const { - path = "", - queryString = "", - headers = {}, - method = "GET", - disabledHeaders, - bodyType, - requestBody, - authConfigId, - pagination, - paginationValues, - } = query - const authHeaders = this.getAuthHeaders(authConfigId) - - this.headers = { - ...this.config.defaultHeaders, - ...headers, - ...authHeaders, - } - - if (disabledHeaders) { - for (let headerKey of Object.keys(this.headers)) { - if (disabledHeaders[headerKey]) { - delete this.headers[headerKey] - } + switch (bodyType) { + case BodyTypes.TEXT: + // content type defaults to plaintext + input.body = string + break + case BodyTypes.ENCODED: + const params = new URLSearchParams() + for (let [key, value] of Object.entries(object)) { + params.append(key, value) } - } - - let input: any = { method, headers: this.headers } - input = this.addBody( - bodyType, - requestBody, - input, - pagination, - paginationValues - ) - - this.startTimeMs = performance.now() - const url = this.getUrl(path, queryString, pagination, paginationValues) - const response = await fetch(url, input) - return await this.parseResponse(response, pagination) - } - - async create(opts: RestQuery) { - return this._req({ ...opts, method: "POST" }) - } - - async read(opts: RestQuery) { - return this._req({ ...opts, method: "GET" }) - } - - async update(opts: RestQuery) { - return this._req({ ...opts, method: "PUT" }) - } - - async patch(opts: RestQuery) { - return this._req({ ...opts, method: "PATCH" }) - } - - async delete(opts: RestQuery) { - return this._req({ ...opts, method: "DELETE" }) + addPaginationToBody((key: string, value: any) => { + params.append(key, value) + }) + input.body = params + break + case BodyTypes.FORM_DATA: + const form = new FormData() + for (let [key, value] of Object.entries(object)) { + form.append(key, value) + } + addPaginationToBody((key: string, value: any) => { + form.append(key, value) + }) + input.body = form + break + case BodyTypes.XML: + if (object != null && Object.keys(object).length) { + string = new XmlBuilder().buildObject(object) + } + input.body = string + input.headers["Content-Type"] = "application/xml" + break + case BodyTypes.JSON: + // if JSON error, throw it + if (error) { + throw "Invalid JSON for request body" + } + addPaginationToBody((key: string, value: any) => { + object[key] = value + }) + input.body = JSON.stringify(object) + input.headers["Content-Type"] = "application/json" + break } + return input } - module.exports = { - schema: SCHEMA, - integration: RestIntegration, - AuthType, + getAuthHeaders(authConfigId: string): { [key: string]: any } { + let headers: any = {} + + if (this.config.authConfigs && authConfigId) { + const authConfig = this.config.authConfigs.filter( + c => c._id === authConfigId + )[0] + // check the config still exists before proceeding + // if not - do nothing + if (authConfig) { + let config + switch (authConfig.type) { + case AuthType.BASIC: + config = authConfig.config as BasicAuthConfig + headers.Authorization = `Basic ${Buffer.from( + `${config.username}:${config.password}` + ).toString("base64")}` + break + case AuthType.BEARER: + config = authConfig.config as BearerAuthConfig + headers.Authorization = `Bearer ${config.token}` + break + } + } + } + + return headers + } + + async _req(query: RestQuery) { + const { + path = "", + queryString = "", + headers = {}, + method = "GET", + disabledHeaders, + bodyType, + requestBody, + authConfigId, + pagination, + paginationValues, + } = query + const authHeaders = this.getAuthHeaders(authConfigId) + + this.headers = { + ...this.config.defaultHeaders, + ...headers, + ...authHeaders, + } + + if (disabledHeaders) { + for (let headerKey of Object.keys(this.headers)) { + if (disabledHeaders[headerKey]) { + delete this.headers[headerKey] + } + } + } + + let input: any = { method, headers: this.headers } + input = this.addBody( + bodyType, + requestBody, + input, + pagination, + paginationValues + ) + + this.startTimeMs = performance.now() + const url = this.getUrl(path, queryString, pagination, paginationValues) + const response = await fetch(url, input) + return await this.parseResponse(response, pagination) + } + + async create(opts: RestQuery) { + return this._req({ ...opts, method: "POST" }) + } + + async read(opts: RestQuery) { + return this._req({ ...opts, method: "GET" }) + } + + async update(opts: RestQuery) { + return this._req({ ...opts, method: "PUT" }) + } + + async patch(opts: RestQuery) { + return this._req({ ...opts, method: "PATCH" }) + } + + async delete(opts: RestQuery) { + return this._req({ ...opts, method: "DELETE" }) } } + +export default { + schema: SCHEMA, + integration: RestIntegration, + AuthType, +} diff --git a/packages/server/src/integrations/s3.ts b/packages/server/src/integrations/s3.ts index e8da696424..f92124082e 100644 --- a/packages/server/src/integrations/s3.ts +++ b/packages/server/src/integrations/s3.ts @@ -1,86 +1,83 @@ import { Integration, QueryType, IntegrationBase } from "@budibase/types" +const AWS = require("aws-sdk") -module S3Module { - const AWS = require("aws-sdk") +interface S3Config { + region: string + accessKeyId: string + secretAccessKey: string + s3ForcePathStyle: boolean + endpoint?: string +} - interface S3Config { - region: string - accessKeyId: string - secretAccessKey: string - s3ForcePathStyle: boolean - endpoint?: string - } - - const SCHEMA: Integration = { - docs: "https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/S3.html", - description: - "Amazon Simple Storage Service (Amazon S3) is an object storage service that offers industry-leading scalability, data availability, security, and performance.", - friendlyName: "Amazon S3", - type: "Object store", - datasource: { - region: { - type: "string", - required: false, - default: "us-east-1", - }, - accessKeyId: { - type: "password", - required: true, - }, - secretAccessKey: { - type: "password", - required: true, - }, - endpoint: { - type: "string", - required: false, - }, - signatureVersion: { - type: "string", - required: false, - default: "v4", - }, +const SCHEMA: Integration = { + docs: "https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/S3.html", + description: + "Amazon Simple Storage Service (Amazon S3) is an object storage service that offers industry-leading scalability, data availability, security, and performance.", + friendlyName: "Amazon S3", + type: "Object store", + datasource: { + region: { + type: "string", + required: false, + default: "us-east-1", }, - query: { - read: { - type: QueryType.FIELDS, - fields: { - bucket: { - type: "string", - required: true, - }, + accessKeyId: { + type: "password", + required: true, + }, + secretAccessKey: { + type: "password", + required: true, + }, + endpoint: { + type: "string", + required: false, + }, + signatureVersion: { + type: "string", + required: false, + default: "v4", + }, + }, + query: { + read: { + type: QueryType.FIELDS, + fields: { + bucket: { + type: "string", + required: true, }, }, }, - } + }, +} - class S3Integration implements IntegrationBase { - private readonly config: S3Config - private client: any +class S3Integration implements IntegrationBase { + private readonly config: S3Config + private client: any - constructor(config: S3Config) { - this.config = config - if (this.config.endpoint) { - this.config.s3ForcePathStyle = true - } else { - delete this.config.endpoint - } - - this.client = new AWS.S3(this.config) + constructor(config: S3Config) { + this.config = config + if (this.config.endpoint) { + this.config.s3ForcePathStyle = true + } else { + delete this.config.endpoint } - async read(query: { bucket: string }) { - const response = await this.client - .listObjects({ - Bucket: query.bucket, - }) - .promise() - return response.Contents - } + this.client = new AWS.S3(this.config) } - module.exports = { - schema: SCHEMA, - integration: S3Integration, + async read(query: { bucket: string }) { + const response = await this.client + .listObjects({ + Bucket: query.bucket, + }) + .promise() + return response.Contents } } + +export default { + schema: SCHEMA, + integration: S3Integration, +} diff --git a/packages/server/src/integrations/snowflake.ts b/packages/server/src/integrations/snowflake.ts index 7155d27b66..db702520f9 100644 --- a/packages/server/src/integrations/snowflake.ts +++ b/packages/server/src/integrations/snowflake.ts @@ -1,99 +1,97 @@ import { Integration, QueryType, SqlQuery } from "@budibase/types" import { Snowflake } from "snowflake-promise" -module SnowflakeModule { - interface SnowflakeConfig { - account: string - username: string - password: string - warehouse: string - database: string - schema: string - } +interface SnowflakeConfig { + account: string + username: string + password: string + warehouse: string + database: string + schema: string +} - const SCHEMA: Integration = { - docs: "https://developers.snowflake.com/", - description: - "Snowflake is a solution for data warehousing, data lakes, data engineering, data science, data application development, and securely sharing and consuming shared data.", - friendlyName: "Snowflake", - type: "Relational", - datasource: { - account: { - type: "string", - required: true, - }, - username: { - type: "string", - required: true, - }, - password: { - type: "password", - required: true, - }, - warehouse: { - type: "string", - required: true, - }, - database: { - type: "string", - required: true, - }, - schema: { - type: "string", - required: true, - }, +const SCHEMA: Integration = { + docs: "https://developers.snowflake.com/", + description: + "Snowflake is a solution for data warehousing, data lakes, data engineering, data science, data application development, and securely sharing and consuming shared data.", + friendlyName: "Snowflake", + type: "Relational", + datasource: { + account: { + type: "string", + required: true, }, - query: { - create: { - type: QueryType.SQL, - }, - read: { - type: QueryType.SQL, - }, - update: { - type: QueryType.SQL, - }, - delete: { - type: QueryType.SQL, - }, + username: { + type: "string", + required: true, }, + password: { + type: "password", + required: true, + }, + warehouse: { + type: "string", + required: true, + }, + database: { + type: "string", + required: true, + }, + schema: { + type: "string", + required: true, + }, + }, + query: { + create: { + type: QueryType.SQL, + }, + read: { + type: QueryType.SQL, + }, + update: { + type: QueryType.SQL, + }, + delete: { + type: QueryType.SQL, + }, + }, +} + +class SnowflakeIntegration { + private client: Snowflake + + constructor(config: SnowflakeConfig) { + this.client = new Snowflake(config) } - class SnowflakeIntegration { - private client: Snowflake - - constructor(config: SnowflakeConfig) { - this.client = new Snowflake(config) - } - - async internalQuery(query: SqlQuery) { - await this.client.connect() - try { - return await this.client.execute(query.sql) - } catch (err: any) { - throw err?.message.split(":")[1] || err?.message - } - } - - async create(query: SqlQuery) { - return this.internalQuery(query) - } - - async read(query: SqlQuery) { - return this.internalQuery(query) - } - - async update(query: SqlQuery) { - return this.internalQuery(query) - } - - async delete(query: SqlQuery) { - return this.internalQuery(query) + async internalQuery(query: SqlQuery) { + await this.client.connect() + try { + return await this.client.execute(query.sql) + } catch (err: any) { + throw err?.message.split(":")[1] || err?.message } } - module.exports = { - schema: SCHEMA, - integration: SnowflakeIntegration, + async create(query: SqlQuery) { + return this.internalQuery(query) + } + + async read(query: SqlQuery) { + return this.internalQuery(query) + } + + async update(query: SqlQuery) { + return this.internalQuery(query) + } + + async delete(query: SqlQuery) { + return this.internalQuery(query) } } + +export default { + schema: SCHEMA, + integration: SnowflakeIntegration, +} diff --git a/packages/types/src/documents/index.ts b/packages/types/src/documents/index.ts index 4f5b278a4b..1afee41599 100644 --- a/packages/types/src/documents/index.ts +++ b/packages/types/src/documents/index.ts @@ -1,5 +1,6 @@ export * from "./account" export * from "./app" export * from "./global" +export * from "./plugin" export * from "./platform" export * from "./document" diff --git a/packages/types/src/documents/plugin/index.ts b/packages/types/src/documents/plugin/index.ts new file mode 100644 index 0000000000..03a239a6c9 --- /dev/null +++ b/packages/types/src/documents/plugin/index.ts @@ -0,0 +1,4 @@ +export enum PluginType { + DATASOURCE = "datasource", + COMPONENT = "component", +} From 08145869cc60d81e3e942d9514dfbce48fe7af64 Mon Sep 17 00:00:00 2001 From: Andrew Kingston Date: Mon, 15 Aug 2022 11:23:27 +0100 Subject: [PATCH 034/203] Rename custom components to plugins in the new component panel --- .../[componentId]/new/_components/NewComponentPanel.svelte | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/builder/src/pages/builder/app/[application]/design/[screenId]/components/[componentId]/new/_components/NewComponentPanel.svelte b/packages/builder/src/pages/builder/app/[application]/design/[screenId]/components/[componentId]/new/_components/NewComponentPanel.svelte index b0cd544977..c18df34556 100644 --- a/packages/builder/src/pages/builder/app/[application]/design/[screenId]/components/[componentId]/new/_components/NewComponentPanel.svelte +++ b/packages/builder/src/pages/builder/app/[application]/design/[screenId]/components/[componentId]/new/_components/NewComponentPanel.svelte @@ -56,7 +56,7 @@ // Add custom components category if (customComponents?.length) { enrichedStructure.push({ - name: "Custom components", + name: "Plugins", isCategory: true, children: customComponents.map(x => ({ ...definitions[x], From 3388008f0b27c10b902fcc7b99d0f2eebe073176 Mon Sep 17 00:00:00 2001 From: mike12345567 Date: Mon, 15 Aug 2022 18:38:09 +0100 Subject: [PATCH 035/203] Adding custom datasources to UI. --- .../DatasourceNavigator/icons/Custom.svelte | 39 +++++++++++++++++++ .../DatasourceNavigator/icons/index.js | 2 + .../modals/CreateDatasourceModal.svelte | 10 ++++- .../server/src/api/controllers/datasource.js | 8 ++-- .../server/src/integrations/base/query.ts | 4 +- packages/server/src/integrations/index.ts | 20 ++++++++-- packages/server/src/threads/query.ts | 4 +- 7 files changed, 75 insertions(+), 12 deletions(-) create mode 100644 packages/builder/src/components/backend/DatasourceNavigator/icons/Custom.svelte diff --git a/packages/builder/src/components/backend/DatasourceNavigator/icons/Custom.svelte b/packages/builder/src/components/backend/DatasourceNavigator/icons/Custom.svelte new file mode 100644 index 0000000000..354b7a3358 --- /dev/null +++ b/packages/builder/src/components/backend/DatasourceNavigator/icons/Custom.svelte @@ -0,0 +1,39 @@ + + + + + + + + + + diff --git a/packages/builder/src/components/backend/DatasourceNavigator/icons/index.js b/packages/builder/src/components/backend/DatasourceNavigator/icons/index.js index 404895f05a..267ed32b6e 100644 --- a/packages/builder/src/components/backend/DatasourceNavigator/icons/index.js +++ b/packages/builder/src/components/backend/DatasourceNavigator/icons/index.js @@ -15,6 +15,7 @@ import GoogleSheets from "./GoogleSheets.svelte" import Firebase from "./Firebase.svelte" import Redis from "./Redis.svelte" import Snowflake from "./Snowflake.svelte" +import Custom from "./Custom.svelte" export default { BUDIBASE: Budibase, @@ -34,4 +35,5 @@ export default { FIRESTORE: Firebase, REDIS: Redis, SNOWFLAKE: Snowflake, + CUSTOM: Custom, } diff --git a/packages/builder/src/components/backend/DatasourceNavigator/modals/CreateDatasourceModal.svelte b/packages/builder/src/components/backend/DatasourceNavigator/modals/CreateDatasourceModal.svelte index 8d34c292f3..2d5e6976bf 100644 --- a/packages/builder/src/components/backend/DatasourceNavigator/modals/CreateDatasourceModal.svelte +++ b/packages/builder/src/components/backend/DatasourceNavigator/modals/CreateDatasourceModal.svelte @@ -92,6 +92,14 @@ } integrations = newIntegrations } + + function getIcon(integrationType, schema) { + if (schema.custom) { + return ICONS.CUSTOM + } else { + return ICONS[integrationType] + } + } @@ -158,7 +166,7 @@ >
diff --git a/packages/server/src/api/controllers/datasource.js b/packages/server/src/api/controllers/datasource.js index 8b9b765a5f..36d345912e 100644 --- a/packages/server/src/api/controllers/datasource.js +++ b/packages/server/src/api/controllers/datasource.js @@ -7,7 +7,7 @@ const { getTableParams, } = require("../../db/utils") const { BuildSchemaErrors, InvalidColumns } = require("../../constants") -const { integrations } = require("../../integrations") +const { getIntegration } = require("../../integrations") const { getDatasourceAndQuery } = require("./row/utils") const { invalidateDynamicVariables } = require("../../threads/utils") const { getAppDB } = require("@budibase/backend-core/context") @@ -114,7 +114,7 @@ exports.update = async function (ctx) { // Drain connection pools when configuration is changed if (datasource.source) { - const source = integrations[datasource.source] + const source = await getIntegration(datasource.source) if (source && source.pool) { await source.pool.end() } @@ -149,7 +149,7 @@ exports.save = async function (ctx) { // Drain connection pools when configuration is changed if (datasource.source) { - const source = integrations[datasource.source] + const source = await getIntegration(datasource.source) if (source && source.pool) { await source.pool.end() } @@ -218,7 +218,7 @@ function updateError(error, newError, tables) { } const buildSchemaHelper = async datasource => { - const Connector = integrations[datasource.source] + const Connector = await getIntegration(datasource.source) // Connect to the DB and build the schema const connector = new Connector(datasource.config) diff --git a/packages/server/src/integrations/base/query.ts b/packages/server/src/integrations/base/query.ts index 1f3ed3dd74..7435b28141 100644 --- a/packages/server/src/integrations/base/query.ts +++ b/packages/server/src/integrations/base/query.ts @@ -1,11 +1,11 @@ import { QueryJson, Datasource } from "@budibase/types" -const { integrations } = require("../index") +const { getIntegration } = require("../index") export async function makeExternalQuery( datasource: Datasource, json: QueryJson ) { - const Integration = integrations[datasource.source] + const Integration = await getIntegration(datasource.source) // query is the opinionated function if (Integration.prototype.query) { const integration = new Integration(datasource.config) diff --git a/packages/server/src/integrations/index.ts b/packages/server/src/integrations/index.ts index bde7235ac8..bf267e46cc 100644 --- a/packages/server/src/integrations/index.ts +++ b/packages/server/src/integrations/index.ts @@ -67,8 +67,22 @@ if (environment.SELF_HOSTED) { module.exports = { getDefinitions: async () => { - const custom = await getPlugins(PluginType.DATASOURCE) - return cloneDeep(DEFINITIONS) + const plugins = await getPlugins(PluginType.DATASOURCE) + // extract the actual schema from each custom + const pluginSchemas: { [key: string]: Integration } = {} + for (let plugin of plugins) { + const sourceId = plugin.name + pluginSchemas[sourceId] = { + ...plugin.schema["schema"], + custom: true, + } + } + return { + ...cloneDeep(DEFINITIONS), + ...pluginSchemas, + } + }, + getIntegration: async () => { + return INTEGRATIONS }, - integrations: INTEGRATIONS, } diff --git a/packages/server/src/threads/query.ts b/packages/server/src/threads/query.ts index 6b93a00200..86cbf89c87 100644 --- a/packages/server/src/threads/query.ts +++ b/packages/server/src/threads/query.ts @@ -2,7 +2,7 @@ import { default as threadUtils } from "./utils" threadUtils.threadSetup() import { WorkerCallback, QueryEvent, QueryVariable } from "./definitions" const ScriptRunner = require("../utilities/scriptRunner") -const { integrations } = require("../integrations") +const { getIntegration } = require("../integrations") const { processStringSync } = require("@budibase/string-templates") const { doInAppContext, getAppDB } = require("@budibase/backend-core/context") const { @@ -62,7 +62,7 @@ class QueryRunner { let datasourceClone = cloneDeep(datasource) let fieldsClone = cloneDeep(fields) - const Integration = integrations[datasourceClone.source] + const Integration = await getIntegration(datasourceClone.source) if (!Integration) { throw "Integration type does not exist." } From 54907ad7b0ac41a232daaf1ffd81d29507e6b4da Mon Sep 17 00:00:00 2001 From: Andrew Kingston Date: Mon, 15 Aug 2022 22:23:45 +0100 Subject: [PATCH 036/203] Add hot reloading for component plugins via watched plugin directory --- .../templates/app-service-deployment.yaml | 8 +- hosting/.env | 5 +- hosting/hosting.properties | 5 +- packages/server/package.json | 1 + packages/server/scripts/dev/manage.js | 1 + packages/server/src/api/controllers/plugin.ts | 93 +-- packages/server/src/app.ts | 28 + packages/server/src/environment.js | 1 + packages/server/yarn.lock | 645 +++++++++++++++++- packages/types/src/documents/plugin/index.ts | 5 + 10 files changed, 734 insertions(+), 58 deletions(-) diff --git a/charts/budibase/templates/app-service-deployment.yaml b/charts/budibase/templates/app-service-deployment.yaml index fd46e77647..332637d971 100644 --- a/charts/budibase/templates/app-service-deployment.yaml +++ b/charts/budibase/templates/app-service-deployment.yaml @@ -124,11 +124,15 @@ spec: value: {{ .Values.globals.tenantFeatureFlags | quote }} {{ if .Values.globals.bbAdminUserEmail }} - name: BB_ADMIN_USER_EMAIL - value: { { .Values.globals.bbAdminUserEmail | quote } } + value: {{ .Values.globals.bbAdminUserEmail | quote }} {{ end }} {{ if .Values.globals.bbAdminUserPassword }} - name: BB_ADMIN_USER_PASSWORD - value: { { .Values.globals.bbAdminUserPassword | quote } } + value: {{ .Values.globals.bbAdminUserPassword | quote }} + {{ end }} + {{ if .Values.globals.pluginsDir }} + - name: PLUGINS_DIR + value: { { .Values.globals.pluginsDir | quote }} {{ end }} image: budibase/apps:{{ .Values.globals.appVersion }} diff --git a/hosting/.env b/hosting/.env index 11dd661bf1..c5638a266f 100644 --- a/hosting/.env +++ b/hosting/.env @@ -22,4 +22,7 @@ BUDIBASE_ENVIRONMENT=PRODUCTION # An admin user can be automatically created initially if these are set BB_ADMIN_USER_EMAIL= -BB_ADMIN_USER_PASSWORD= \ No newline at end of file +BB_ADMIN_USER_PASSWORD= + +# A path that is watched for plugin bundles. Any bundles found are imported automatically/ +PLUGINS_DIR= \ No newline at end of file diff --git a/hosting/hosting.properties b/hosting/hosting.properties index 11dd661bf1..c5638a266f 100644 --- a/hosting/hosting.properties +++ b/hosting/hosting.properties @@ -22,4 +22,7 @@ BUDIBASE_ENVIRONMENT=PRODUCTION # An admin user can be automatically created initially if these are set BB_ADMIN_USER_EMAIL= -BB_ADMIN_USER_PASSWORD= \ No newline at end of file +BB_ADMIN_USER_PASSWORD= + +# A path that is watched for plugin bundles. Any bundles found are imported automatically/ +PLUGINS_DIR= \ No newline at end of file diff --git a/packages/server/package.json b/packages/server/package.json index 2bea771ad7..0a24f767e0 100644 --- a/packages/server/package.json +++ b/packages/server/package.json @@ -95,6 +95,7 @@ "bcryptjs": "2.4.3", "bull": "3.29.3", "chmodr": "1.2.0", + "chokidar": "^3.5.3", "csvtojson": "2.0.10", "curlconverter": "3.21.0", "dotenv": "8.2.0", diff --git a/packages/server/scripts/dev/manage.js b/packages/server/scripts/dev/manage.js index fc9fde0a02..8a5f8e9477 100644 --- a/packages/server/scripts/dev/manage.js +++ b/packages/server/scripts/dev/manage.js @@ -58,6 +58,7 @@ async function init() { DEPLOYMENT_ENVIRONMENT: "development", BB_ADMIN_USER_EMAIL: "", BB_ADMIN_USER_PASSWORD: "", + PLUGINS_DIR: "", } let envFile = "" Object.keys(envFileJson).forEach(key => { diff --git a/packages/server/src/api/controllers/plugin.ts b/packages/server/src/api/controllers/plugin.ts index 48104f24b9..93e569e0c8 100644 --- a/packages/server/src/api/controllers/plugin.ts +++ b/packages/server/src/api/controllers/plugin.ts @@ -3,7 +3,7 @@ import { extractPluginTarball } from "../../utilities/fileSystem" import { getGlobalDB } from "@budibase/backend-core/tenancy" import { generatePluginID, getPluginParams } from "../../db/utils" import { uploadDirectory } from "@budibase/backend-core/objectStore" -import { PluginType } from "@budibase/types" +import { PluginType, FileType } from "@budibase/types" export async function getPlugins(type?: PluginType) { const db = getGlobalDB() @@ -21,56 +21,16 @@ export async function getPlugins(type?: PluginType) { } export async function upload(ctx: any) { - const plugins = + const plugins: FileType[] = ctx.request.files.file.length > 1 ? Array.from(ctx.request.files.file) : [ctx.request.files.file] - const db = getGlobalDB() try { let docs = [] // can do single or multiple plugins for (let plugin of plugins) { - const { metadata, directory } = await extractPluginTarball(plugin) - const version = metadata.package.version, - name = metadata.package.name, - description = metadata.package.description - - // first open the tarball into tmp directory - const bucketPath = `${name}/${version}/` - const files = await uploadDirectory( - ObjectStoreBuckets.PLUGINS, - directory, - bucketPath - ) - const jsFile = files.find((file: any) => file.name.endsWith(".js")) - if (!jsFile) { - throw new Error(`Plugin missing .js file.`) - } - const jsFileName = jsFile.name - const pluginId = generatePluginID(name, version) - - // overwrite existing docs entirely if they exist - let rev - try { - const existing = await db.get(pluginId) - rev = existing._rev - } catch (err) { - rev = undefined - } - const doc = { - _id: pluginId, - _rev: rev, - name, - version, - description, - ...metadata, - jsUrl: `${bucketPath}${jsFileName}`, - } - const response = await db.put(doc) - docs.push({ - ...doc, - _rev: response.rev, - }) + const doc = await processPlugin(plugin) + docs.push(doc) } ctx.body = { message: "Plugin(s) uploaded successfully", @@ -87,3 +47,48 @@ export async function fetch(ctx: any) { } export async function destroy(ctx: any) {} + +export async function processPlugin(plugin: FileType) { + const db = getGlobalDB() + const { metadata, directory } = await extractPluginTarball(plugin) + const version = metadata.package.version, + name = metadata.package.name, + description = metadata.package.description + + // first open the tarball into tmp directory + const bucketPath = `${name}/${version}/` + const files = await uploadDirectory( + ObjectStoreBuckets.PLUGINS, + directory, + bucketPath + ) + const jsFile = files.find((file: any) => file.name.endsWith(".js")) + if (!jsFile) { + throw new Error(`Plugin missing .js file.`) + } + const jsFileName = jsFile.name + const pluginId = generatePluginID(name, version) + + // overwrite existing docs entirely if they exist + let rev + try { + const existing = await db.get(pluginId) + rev = existing._rev + } catch (err) { + rev = undefined + } + const doc = { + _id: pluginId, + _rev: rev, + name, + version, + description, + ...metadata, + jsUrl: `${bucketPath}${jsFileName}`, + } + const response = await db.put(doc) + return { + ...doc, + _rev: response.rev, + } +} diff --git a/packages/server/src/app.ts b/packages/server/src/app.ts index 62301d57ca..2f8adc879d 100644 --- a/packages/server/src/app.ts +++ b/packages/server/src/app.ts @@ -17,10 +17,15 @@ const bullboard = require("./automations/bullboard") const { logAlert } = require("@budibase/backend-core/logging") const { pinoSettings } = require("@budibase/backend-core") const { Thread } = require("./threads") +const chokidar = require("chokidar") +const fs = require("fs") +const path = require("path") import redis from "./utilities/redis" import * as migrations from "./migrations" import { events, installation, tenancy } from "@budibase/backend-core" import { createAdminUser, getChecklist } from "./utilities/workerRequests" +import { processPlugin } from "./api/controllers/plugin" +import { getGlobalDB } from "@budibase/backend-core/tenancy" const app = new Koa() @@ -132,6 +137,29 @@ module.exports = server.listen(env.PORT || 0, async () => { } } + // monitor plugin directory if required + if (env.SELF_HOSTED && env.PLUGINS_DIR && fs.existsSync(env.PLUGINS_DIR)) { + const watchPath = path.join(env.PLUGINS_DIR, "./**/dist/*.tar.gz") + chokidar + .watch(watchPath, { + ignored: "**/node_modules", + awaitWriteFinish: true, + }) + .on("all", async (event: string, path: string) => { + const tenantId = tenancy.getTenantId() + await tenancy.doInTenant(tenantId, async () => { + try { + const split = path.split("/") + const name = split[split.length - 1] + console.log("Importing plugin:", path) + await processPlugin({ name, path }) + } catch (err) { + console.log("Failed to import plugin:", err) + } + }) + }) + } + // check for version updates await installation.checkInstallVersion() diff --git a/packages/server/src/environment.js b/packages/server/src/environment.js index c2e2815e00..5a7aa61b9d 100644 --- a/packages/server/src/environment.js +++ b/packages/server/src/environment.js @@ -77,6 +77,7 @@ module.exports = { SQL_MAX_ROWS: process.env.SQL_MAX_ROWS, BB_ADMIN_USER_EMAIL: process.env.BB_ADMIN_USER_EMAIL, BB_ADMIN_USER_PASSWORD: process.env.BB_ADMIN_USER_PASSWORD, + PLUGINS_DIR: process.env.PLUGINS_DIR, // flags ALLOW_DEV_AUTOMATIONS: process.env.ALLOW_DEV_AUTOMATIONS, DISABLE_THREADING: process.env.DISABLE_THREADING, diff --git a/packages/server/yarn.lock b/packages/server/yarn.lock index a8dea20e95..ac01381814 100644 --- a/packages/server/yarn.lock +++ b/packages/server/yarn.lock @@ -1128,6 +1128,93 @@ uuid "8.3.2" zlib "1.0.5" +"@budibase/backend-core@1.2.39-alpha.1": + version "1.2.39-alpha.1" + resolved "https://registry.yarnpkg.com/@budibase/backend-core/-/backend-core-1.2.39-alpha.1.tgz#7e5293670cf39f05e31eaaabbc3d7abc7f9837ca" + integrity sha512-mfHGyLc2FZ63cF8f4VX8GdJe7ciLCX4kZ+NK1yzBG0rRzHSTWJb2CVRq0rXNsZbwAVt9llHH58ysSHd+ggw9hg== + dependencies: + "@budibase/types" "1.2.39-alpha.1" + "@techpass/passport-openidconnect" "0.3.2" + aws-sdk "2.1030.0" + bcrypt "5.0.1" + dotenv "16.0.1" + emitter-listener "1.1.2" + ioredis "4.28.0" + joi "17.6.0" + jsonwebtoken "8.5.1" + koa-passport "4.1.4" + lodash "4.17.21" + lodash.isarguments "3.1.0" + node-fetch "2.6.7" + passport-google-auth "1.0.2" + passport-google-oauth "2.0.0" + passport-jwt "4.0.0" + passport-local "1.0.0" + passport-oauth2-refresh "^2.1.0" + posthog-node "1.3.0" + pouchdb "7.3.0" + pouchdb-find "7.2.2" + pouchdb-replication-stream "1.2.9" + redlock "4.2.0" + sanitize-s3-objectkey "0.0.1" + semver "7.3.7" + tar-fs "2.1.1" + uuid "8.3.2" + zlib "1.0.5" + +"@budibase/bbui@1.2.39-alpha.1": + version "1.2.39-alpha.1" + resolved "https://registry.yarnpkg.com/@budibase/bbui/-/bbui-1.2.39-alpha.1.tgz#6c4698e86540ae547b4569b077da1a3d7637809a" + integrity sha512-wZbe/G/jUxQwhpkqdnJyMQObRTT9eY0vowHkLrplAAVfG84tPYsWDMKqLmauJOXv8Fl3G24I2Jj1kzWFKjYieA== + dependencies: + "@adobe/spectrum-css-workflow-icons" "^1.2.1" + "@budibase/string-templates" "1.2.39-alpha.1" + "@spectrum-css/actionbutton" "^1.0.1" + "@spectrum-css/actiongroup" "^1.0.1" + "@spectrum-css/avatar" "^3.0.2" + "@spectrum-css/button" "^3.0.1" + "@spectrum-css/buttongroup" "^3.0.2" + "@spectrum-css/checkbox" "^3.0.2" + "@spectrum-css/dialog" "^3.0.1" + "@spectrum-css/divider" "^1.0.3" + "@spectrum-css/dropzone" "^3.0.2" + "@spectrum-css/fieldgroup" "^3.0.2" + "@spectrum-css/fieldlabel" "^3.0.1" + "@spectrum-css/icon" "^3.0.1" + "@spectrum-css/illustratedmessage" "^3.0.2" + "@spectrum-css/inlinealert" "^2.0.1" + "@spectrum-css/inputgroup" "^3.0.2" + "@spectrum-css/label" "^2.0.10" + "@spectrum-css/link" "^3.1.1" + "@spectrum-css/menu" "^3.0.1" + "@spectrum-css/modal" "^3.0.1" + "@spectrum-css/pagination" "^3.0.3" + "@spectrum-css/picker" "^1.0.1" + "@spectrum-css/popover" "^3.0.1" + "@spectrum-css/progressbar" "^1.0.2" + "@spectrum-css/progresscircle" "^1.0.2" + "@spectrum-css/radio" "^3.0.2" + "@spectrum-css/search" "^3.0.2" + "@spectrum-css/sidenav" "^3.0.2" + "@spectrum-css/slider" "3.0.1" + "@spectrum-css/statuslight" "^3.0.2" + "@spectrum-css/stepper" "^3.0.3" + "@spectrum-css/switch" "^1.0.2" + "@spectrum-css/table" "^3.0.1" + "@spectrum-css/tabs" "^3.2.12" + "@spectrum-css/tags" "^3.0.2" + "@spectrum-css/textfield" "^3.0.1" + "@spectrum-css/toast" "^3.0.1" + "@spectrum-css/tooltip" "^3.0.3" + "@spectrum-css/treeview" "^3.0.2" + "@spectrum-css/typography" "^3.0.1" + "@spectrum-css/underlay" "^2.0.9" + "@spectrum-css/vars" "^3.0.1" + dayjs "^1.10.4" + easymde "^2.16.1" + svelte-flatpickr "^3.2.3" + svelte-portal "^1.0.0" + "@budibase/bbui@^0.9.139": version "0.9.190" resolved "https://registry.yarnpkg.com/@budibase/bbui/-/bbui-0.9.190.tgz#e1ec400ac90f556bfbc80fc23a04506f1585ea81" @@ -1178,6 +1265,70 @@ svelte-flatpickr "^3.2.3" svelte-portal "^1.0.0" +"@budibase/client@1.2.39-alpha.1": + version "1.2.39-alpha.1" + resolved "https://registry.yarnpkg.com/@budibase/client/-/client-1.2.39-alpha.1.tgz#a9a727d0843d7e610d224d2b1b0a15d336c0199c" + integrity sha512-qAzbpIgAoLll56xq6pVmOMI05KdcO/Dp/4aAzYKxKteRq+fcBeNIb9WPlP3NKYhYFE/HJegkiwqTt+B3UKA/gQ== + dependencies: + "@budibase/bbui" "1.2.39-alpha.1" + "@budibase/frontend-core" "1.2.39-alpha.1" + "@budibase/string-templates" "1.2.39-alpha.1" + "@spectrum-css/button" "^3.0.3" + "@spectrum-css/card" "^3.0.3" + "@spectrum-css/divider" "^1.0.3" + "@spectrum-css/link" "^3.1.3" + "@spectrum-css/page" "^3.0.1" + "@spectrum-css/tag" "^3.1.4" + "@spectrum-css/typography" "^3.0.2" + "@spectrum-css/vars" "^3.0.1" + apexcharts "^3.22.1" + dayjs "^1.10.5" + downloadjs "1.4.7" + leaflet "^1.7.1" + regexparam "^1.3.0" + rollup-plugin-polyfill-node "^0.8.0" + sanitize-html "^2.7.0" + screenfull "^6.0.1" + shortid "^2.2.15" + svelte "^3.49.0" + svelte-apexcharts "^1.0.2" + svelte-flatpickr "^3.1.0" + svelte-spa-router "^3.0.5" + +"@budibase/frontend-core@1.2.39-alpha.1": + version "1.2.39-alpha.1" + resolved "https://registry.yarnpkg.com/@budibase/frontend-core/-/frontend-core-1.2.39-alpha.1.tgz#8ba142af58fdb5226254001f0360d048a31cc60f" + integrity sha512-WsQCrVGKeWhFTAxjmakkVEcCzxAaRwxoBIze97psupq0a4EUKLOqblFzrlL9Y+1SvVHyUQQz0bqjXfDzAlv7TQ== + dependencies: + "@budibase/bbui" "1.2.39-alpha.1" + lodash "^4.17.21" + svelte "^3.46.2" + +"@budibase/handlebars-helpers@^0.11.8": + version "0.11.8" + resolved "https://registry.yarnpkg.com/@budibase/handlebars-helpers/-/handlebars-helpers-0.11.8.tgz#6953d29673a8c5c407e096c0a84890465c7ce841" + integrity sha512-ggWJUt0GqsHFAEup5tlWlcrmYML57nKhpNGGLzVsqXVYN8eVmf3xluYmmMe7fDYhQH0leSprrdEXmsdFQF3HAQ== + dependencies: + array-sort "^1.0.0" + define-property "^2.0.2" + extend-shallow "^3.0.2" + for-in "^1.0.2" + get-object "^0.2.0" + get-value "^3.0.1" + handlebars "^4.7.7" + handlebars-utils "^1.0.6" + has-value "^2.0.2" + helper-md "^0.2.2" + html-tag "^2.0.0" + is-even "^1.0.0" + is-glob "^4.0.1" + kind-of "^6.0.3" + micromatch "^3.1.5" + relative "^3.0.2" + striptags "^3.1.1" + to-gfm-code-block "^0.1.1" + year "^0.2.1" + "@budibase/pro@1.2.39-alpha.0": version "1.2.39-alpha.0" resolved "https://registry.yarnpkg.com/@budibase/pro/-/pro-1.2.39-alpha.0.tgz#272e3ffd5e2189c787df6b6fbe22b7084832ade7" @@ -1207,11 +1358,28 @@ svelte-apexcharts "^1.0.2" svelte-flatpickr "^3.1.0" +"@budibase/string-templates@1.2.39-alpha.1": + version "1.2.39-alpha.1" + resolved "https://registry.yarnpkg.com/@budibase/string-templates/-/string-templates-1.2.39-alpha.1.tgz#2cef89a75b85289742588f067e426046039b67a5" + integrity sha512-puWejjG6+Yz8jmKxi7j2rMwuilNXC9cmIH4dNHfAowvq3Cn2w31SjR5Qd79cmJe2wb8B1snXMqti0uzSHWGmhQ== + dependencies: + "@budibase/handlebars-helpers" "^0.11.8" + dayjs "^1.10.4" + handlebars "^4.7.6" + handlebars-utils "^1.0.6" + lodash "^4.17.20" + vm2 "^3.9.4" + "@budibase/types@1.2.39-alpha.0": version "1.2.39-alpha.0" resolved "https://registry.yarnpkg.com/@budibase/types/-/types-1.2.39-alpha.0.tgz#d0d48e4da36a93a4a9354cc49663f38d0181b6c0" integrity sha512-i+lQeqlKmFORLuKdwmKnlmCCCEXZH6NdXHrOqNcebJzcNlx3Gx342+cHe4ZGYu0L+wCkWWelD5XHFuNMVMcuHg== +"@budibase/types@1.2.39-alpha.1": + version "1.2.39-alpha.1" + resolved "https://registry.yarnpkg.com/@budibase/types/-/types-1.2.39-alpha.1.tgz#1758c5c7b8a1d754b4c391fc2dc699d6e249980b" + integrity sha512-b3YKkNf0+ImO/HvNbDS0biaMY2uu5ClphBLtA34hOd1I8hjjNj1kguuiQvgW7zqTYvMRK0hBNtTCnSa90uI7Fg== + "@bull-board/api@3.7.0": version "3.7.0" resolved "https://registry.yarnpkg.com/@bull-board/api/-/api-3.7.0.tgz#231f687187c0cb34e0b97f463917b6aaeb4ef6af" @@ -2139,6 +2307,24 @@ resolved "https://registry.yarnpkg.com/@redis/time-series/-/time-series-1.0.3.tgz#4cfca8e564228c0bddcdf4418cba60c20b224ac4" integrity sha512-OFp0q4SGrTH0Mruf6oFsHGea58u8vS/iI5+NpYdicaM+7BgqBZH8FFvNZ8rYYLrUO/QRqMq72NpXmxLVNcdmjA== +"@rollup/plugin-inject@^4.0.0": + version "4.0.4" + resolved "https://registry.yarnpkg.com/@rollup/plugin-inject/-/plugin-inject-4.0.4.tgz#fbeee66e9a700782c4f65c8b0edbafe58678fbc2" + integrity sha512-4pbcU4J/nS+zuHk+c+OL3WtmEQhqxlZ9uqfjQMQDOHOPld7PsCd8k5LWs8h5wjwJN7MgnAn768F2sDxEP4eNFQ== + dependencies: + "@rollup/pluginutils" "^3.1.0" + estree-walker "^2.0.1" + magic-string "^0.25.7" + +"@rollup/pluginutils@^3.1.0": + version "3.1.0" + resolved "https://registry.yarnpkg.com/@rollup/pluginutils/-/pluginutils-3.1.0.tgz#706b4524ee6dc8b103b3c995533e5ad680c02b9b" + integrity sha512-GksZ6pr6TpIjHm8h9lSQ8pi8BE9VeubNT0OMJ3B5uZJ8pz73NPiqOtCog/x2/QzM1ENChPKxMDhiQuRHsqc+lg== + dependencies: + "@types/estree" "0.0.39" + estree-walker "^1.0.1" + picomatch "^2.2.2" + "@sendgrid/client@^7.1.1": version "7.7.0" resolved "https://registry.yarnpkg.com/@sendgrid/client/-/client-7.7.0.tgz#f8f67abd604205a0d0b1af091b61517ef465fdbf" @@ -2420,6 +2606,11 @@ resolved "https://registry.yarnpkg.com/@spectrum-css/sidenav/-/sidenav-3.0.23.tgz#c218560d472e13a3e0d1499b762df1206dcffbfd" integrity sha512-4IFw2/HMQJRzM0M2c5na/HeY7y5vJoGpMFBkXNpQyhW4TRo7N1rGwYQ5dRD3s4OVEWV4/rjfGV0d/qhfwKUTog== +"@spectrum-css/slider@3.0.1": + version "3.0.1" + resolved "https://registry.yarnpkg.com/@spectrum-css/slider/-/slider-3.0.1.tgz#5281e6f47eb5a4fd3d1816c138bf66d01d7f2e49" + integrity sha512-DI2dtMRnQuDM1miVzl3SGyR1khUEKnwdXfO5EHDFwkC3yav43F5QogkfjmjFmWWobMVovdJlAuiaaJ/IHejD0Q== + "@spectrum-css/statuslight@^3.0.2": version "3.0.8" resolved "https://registry.yarnpkg.com/@spectrum-css/statuslight/-/statuslight-3.0.8.tgz#3b0ea80712573679870a85d469850230e794a0f7" @@ -2445,6 +2636,16 @@ resolved "https://registry.yarnpkg.com/@spectrum-css/tabs/-/tabs-3.2.16.tgz#c3f7800d8d6f7c9930c28cd01354816328bf72b1" integrity sha512-JUcMB/fiDG/KoyrVstlUMacFJUY4OHKqhMRuPtu9ggUXWCRbSkY8he92v6u0HwY3DuhDoOxNTK8d/PLjk/fsbg== +"@spectrum-css/tabs@^3.2.12": + version "3.2.19" + resolved "https://registry.yarnpkg.com/@spectrum-css/tabs/-/tabs-3.2.19.tgz#2eae3a2c4760466882db08281365d502c3f22ebf" + integrity sha512-SNGFf/karBr/GNz5GNWnbppFz6uEOGecv6D8WA1ZLeWkjg4gG5e4M9XmPcB32v350e1PTRG7KwWDce48qWAKCQ== + +"@spectrum-css/tag@^3.1.4": + version "3.3.14" + resolved "https://registry.yarnpkg.com/@spectrum-css/tag/-/tag-3.3.14.tgz#2d1ca0759da6a3a2970d14bcabf33bd4a8f63a5f" + integrity sha512-S4RUaxN/83Pr/SYkQHeZNh2NXmtumUEzhrsrrliI6bAt3bjs+mLresTGd9qkIX2+Ycq1JHWTr0HTga4ti1YYyA== + "@spectrum-css/tags@^3.0.2": version "3.0.3" resolved "https://registry.yarnpkg.com/@spectrum-css/tags/-/tags-3.0.3.tgz#fc76d2735cdc442de91b7eb3bee49a928c0767ac" @@ -2622,6 +2823,13 @@ resolved "https://registry.yarnpkg.com/@types/caseless/-/caseless-0.12.2.tgz#f65d3d6389e01eeb458bd54dc8f52b95a9463bc8" integrity sha512-6ckxMjBBD8URvjB6J3NcnuAn5Pkl7t3TizAg+xdlzzQGSPSmBcXf8KoIH0ua/i+tio+ZRUHEXp0HEmvaR4kt0w== +"@types/codemirror@^5.60.4": + version "5.60.5" + resolved "https://registry.yarnpkg.com/@types/codemirror/-/codemirror-5.60.5.tgz#5b989a3b4bbe657458cf372c92b6bfda6061a2b7" + integrity sha512-TiECZmm8St5YxjFUp64LK0c8WU5bxMDt9YaAek1UqUb9swrSCoJhh92fWu1p3mTEqlHjhB5sY7OFBhWroJXZVg== + dependencies: + "@types/tern" "*" + "@types/connect@*": version "3.4.35" resolved "https://registry.yarnpkg.com/@types/connect/-/connect-3.4.35.tgz#5fcf6ae445e4021d1fc2219a4873cc73a3bb2ad1" @@ -2670,6 +2878,11 @@ resolved "https://registry.yarnpkg.com/@types/estree/-/estree-0.0.51.tgz#cfd70924a25a3fd32b218e5e420e6897e1ac4f40" integrity sha512-CuPgU6f3eT/XgKKPqKd/gLZV1Xmvf1a2R5POBOGQa6uv82xpls89HU5zKeVoyR8XzHd1RGNOlQlvUe3CFkjWNQ== +"@types/estree@0.0.39": + version "0.0.39" + resolved "https://registry.yarnpkg.com/@types/estree/-/estree-0.0.39.tgz#e177e699ee1b8c22d23174caaa7422644389509f" + integrity sha512-EYNwp3bU+98cpU4lAWYYL7Zz+2gryWH1qbdDTidVd6hkiR6weksdbMadyXKXNPEkQFhXM+hVO9ZygomHXp+AIw== + "@types/express-serve-static-core@^4.17.18": version "4.17.28" resolved "https://registry.yarnpkg.com/@types/express-serve-static-core/-/express-serve-static-core-4.17.28.tgz#c47def9f34ec81dc6328d0b1b5303d1ec98d86b8" @@ -2813,6 +3026,11 @@ resolved "https://registry.yarnpkg.com/@types/long/-/long-4.0.2.tgz#b74129719fc8d11c01868010082d483b7545591a" integrity sha512-MqTGEo5bj5t157U6fA/BiDynNkn0YknVdh48CMPkTSpFTVmvao5UQmm7uEF6xBEo7qIMAlY/JSleYaE6VOdpaA== +"@types/marked@^4.0.1": + version "4.0.3" + resolved "https://registry.yarnpkg.com/@types/marked/-/marked-4.0.3.tgz#2098f4a77adaba9ce881c9e0b6baf29116e5acc4" + integrity sha512-HnMWQkLJEf/PnxZIfbm0yGJRRZYYMhb++O9M36UCTA9z53uPvVoSlAwJr3XOpDEryb7Hwl1qAx/MV6YIW1RXxg== + "@types/mime@^1": version "1.3.2" resolved "https://registry.yarnpkg.com/@types/mime/-/mime-1.3.2.tgz#93e25bf9ee75fe0fd80b594bc4feb0e862111b5a" @@ -2948,6 +3166,13 @@ "@types/cookiejar" "*" "@types/node" "*" +"@types/tern@*": + version "0.23.4" + resolved "https://registry.yarnpkg.com/@types/tern/-/tern-0.23.4.tgz#03926eb13dbeaf3ae0d390caf706b2643a0127fb" + integrity sha512-JAUw1iXGO1qaWwEOzxTKJZ/5JxVeON9kvGZ/osgZaJImBnyjyn0cjovPsf6FNLmyGY8Vw9DoXZCMlfMkMwHRWg== + dependencies: + "@types/estree" "*" + "@types/tough-cookie@*": version "4.0.2" resolved "https://registry.yarnpkg.com/@types/tough-cookie/-/tough-cookie-4.0.2.tgz#6286b4c7228d58ab7866d19716f3696e03a09397" @@ -3532,7 +3757,7 @@ arg@^4.1.0: resolved "https://registry.yarnpkg.com/arg/-/arg-4.1.3.tgz#269fc7ad5b8e42cb63c896d5666017261c144089" integrity sha512-58S9QDqG0Xx27YwPSt9fJxivjYl432YCwfDMfZ+71RAqUrZef7LrKQZ3LHLOwCS4FLNBplP533Zx895SeOCHvA== -argparse@^1.0.7: +argparse@^1.0.10, argparse@^1.0.7: version "1.0.10" resolved "https://registry.yarnpkg.com/argparse/-/argparse-1.0.10.tgz#bcd6791ea5ae09725e17e5ad988134cd40b3d911" integrity sha512-o5Roy6tNG4SL/FOkCAN6RzjiakZS25RLYFrcMttJqbdd8BWrnA+fGz57iN5Pb06pvBGvl5gQ0B48dJlslXvoTg== @@ -3579,6 +3804,15 @@ array-equal@^1.0.0: resolved "https://registry.yarnpkg.com/array-equal/-/array-equal-1.0.0.tgz#8c2a5ef2472fd9ea742b04c77a75093ba2757c93" integrity sha512-H3LU5RLiSsGXPhN+Nipar0iR0IofH+8r89G2y1tBKxQ/agagKyAjhkAFDRBfodP2caPrNKHpAWNIM/c9yeL7uA== +array-sort@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/array-sort/-/array-sort-1.0.0.tgz#e4c05356453f56f53512a7d1d6123f2c54c0a88a" + integrity sha512-ihLeJkonmdiAsD7vpgN3CRcx2J2S0TiYW+IS/5zHBI7mKUq3ySvBdzzBfD236ubDBQFiiyG3SWCPc+msQ9KoYg== + dependencies: + default-compare "^1.0.0" + get-value "^2.0.6" + kind-of "^5.0.2" + array-union@^2.1.0: version "2.1.0" resolved "https://registry.yarnpkg.com/array-union/-/array-union-2.1.0.tgz#b798420adbeb1de828d84acd8a2e23d3efe85e8d" @@ -3710,6 +3944,13 @@ atomic-sleep@^1.0.0: resolved "https://registry.yarnpkg.com/atomic-sleep/-/atomic-sleep-1.0.0.tgz#eb85b77a601fc932cfe432c5acd364a9e2c9075b" integrity sha512-kNOjDqAh7px0XWNI+4QbzoiR/nTkHAWNud2uvnJquD1/x5a7EQZMJT0AczqK0Qn67oY/TTQ1LbUKajZpp3I9tQ== +autolinker@~0.28.0: + version "0.28.1" + resolved "https://registry.yarnpkg.com/autolinker/-/autolinker-0.28.1.tgz#0652b491881879f0775dace0cdca3233942a4e47" + integrity sha512-zQAFO1Dlsn69eXaO6+7YZc+v84aquQKbwpzCE3L0stj56ERn9hutFxPopViLjo9G+rWwjozRhgS5KJ25Xy19cQ== + dependencies: + gulp-header "^1.7.1" + available-typed-arrays@^1.0.5: version "1.0.5" resolved "https://registry.yarnpkg.com/available-typed-arrays/-/available-typed-arrays-1.0.5.tgz#92f95616501069d07d10edb2fc37d3e1c65123b7" @@ -4411,7 +4652,7 @@ chmodr@1.2.0: resolved "https://registry.yarnpkg.com/chmodr/-/chmodr-1.2.0.tgz#720e96caa09b7f1cdbb01529b7d0ab6bc5e118b9" integrity sha512-Y5uI7Iq/Az6HgJEL6pdw7THVd7jbVOTPwsmcPOBjQL8e3N+pz872kzK5QxYGEy21iRys+iHWV0UZQXDFJo1hyA== -chokidar@^3.5.2: +chokidar@^3.5.2, chokidar@^3.5.3: version "3.5.3" resolved "https://registry.yarnpkg.com/chokidar/-/chokidar-3.5.3.tgz#1cf37c8707b932bd1af1ae22c0432e2acd1903bd" integrity sha512-Dr3sfKRP6oTcjf2JmUmFJfeVMvXBdegxB0iVQ5eb2V10uFJUCAS8OByZdVAyVb8xXNz3GjjTgj9kLWsZTqE6kw== @@ -4542,6 +4783,18 @@ co@^4.6.0: resolved "https://registry.yarnpkg.com/co/-/co-4.6.0.tgz#6ea6bdf3d853ae54ccb8e47bfa0bf3f9031fb184" integrity sha512-QVb0dM5HvG+uaxitm8wONl7jltx8dqhfU33DcqtOZcLSVIKSDDLDi7+0LbAKiyI8hD9u42m2YxXSkMGWThaecQ== +codemirror-spell-checker@1.1.2: + version "1.1.2" + resolved "https://registry.yarnpkg.com/codemirror-spell-checker/-/codemirror-spell-checker-1.1.2.tgz#1c660f9089483ccb5113b9ba9ca19c3f4993371e" + integrity sha512-2Tl6n0v+GJRsC9K3MLCdLaMOmvWL0uukajNJseorZJsslaxZyZMgENocPU8R0DyoTAiKsyqiemSOZo7kjGV0LQ== + dependencies: + typo-js "*" + +codemirror@^5.63.1: + version "5.65.7" + resolved "https://registry.yarnpkg.com/codemirror/-/codemirror-5.65.7.tgz#29af41ce5f4c2b8f1c1e16f4e645ff392823716a" + integrity sha512-zb67cXzgugIQmb6tfD4G11ILjYoMfTjwcjn+cWsa4GewlI2adhR/h3kolkoCQTm1msD/1BuqVTKuO09ELsS++A== + collect-v8-coverage@^1.0.0: version "1.0.1" resolved "https://registry.yarnpkg.com/collect-v8-coverage/-/collect-v8-coverage-1.0.1.tgz#cc2c8e94fc18bbdffe64d6534570c8a673b27f59" @@ -4692,6 +4945,13 @@ concat-map@0.0.1: resolved "https://registry.yarnpkg.com/concat-map/-/concat-map-0.0.1.tgz#d8a96bd77fd68df7793a73036a3ba0d5405d477b" integrity sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg== +concat-with-sourcemaps@*: + version "1.1.0" + resolved "https://registry.yarnpkg.com/concat-with-sourcemaps/-/concat-with-sourcemaps-1.1.0.tgz#d4ea93f05ae25790951b99e7b3b09e3908a4082e" + integrity sha512-4gEjHJFT9e+2W/77h/DS5SGUgwDaOwprX8L/gl5+3ixnzkVJJsZWDSelmN3Oilw3LNDZjZV0yqH1hLG3k6nghg== + dependencies: + source-map "^0.6.1" + condense-newlines@^0.2.1: version "0.2.1" resolved "https://registry.yarnpkg.com/condense-newlines/-/condense-newlines-0.2.1.tgz#3de985553139475d32502c83b02f60684d24c55f" @@ -5098,6 +5358,13 @@ deepmerge@^4.2.2: resolved "https://registry.yarnpkg.com/deepmerge/-/deepmerge-4.2.2.tgz#44d2ea3679b8f4d4ffba33f03d865fc1e7bf4955" integrity sha512-FJ3UgI4gIl+PHZm53knsuSFpE+nESMr7M4v9QcgB7S63Kj/6WqMiFQJpBBYz1Pt+66bZpP3Q7Lye0Oo9MPKEdg== +default-compare@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/default-compare/-/default-compare-1.0.0.tgz#cb61131844ad84d84788fb68fd01681ca7781a2f" + integrity sha512-QWfXlM0EkAbqOCbD/6HjdwT19j7WCkMyiRhWilc4H9/5h/RzTF9gv5LYh1+CmDV5d1rki6KAWLtQale0xt20eQ== + dependencies: + kind-of "^5.0.2" + default-shell@^1.0.0: version "1.0.1" resolved "https://registry.yarnpkg.com/default-shell/-/default-shell-1.0.1.tgz#752304bddc6174f49eb29cb988feea0b8813c8bc" @@ -5265,11 +5532,25 @@ doctrine@3.0.0, doctrine@^3.0.0: dependencies: esutils "^2.0.2" +dom-serializer@^1.0.1: + version "1.4.1" + resolved "https://registry.yarnpkg.com/dom-serializer/-/dom-serializer-1.4.1.tgz#de5d41b1aea290215dc45a6dae8adcf1d32e2d30" + integrity sha512-VHwB3KfrcOOkelEG2ZOfxqLZdfkil8PtJi4P8N2MMXucZq2yLp75ClViUlOVwyoHEDjYU433Aq+5zWP61+RGag== + dependencies: + domelementtype "^2.0.1" + domhandler "^4.2.0" + entities "^2.0.0" + dom-walk@^0.1.0: version "0.1.2" resolved "https://registry.yarnpkg.com/dom-walk/-/dom-walk-0.1.2.tgz#0c548bef048f4d1f2a97249002236060daa3fd84" integrity sha512-6QvTW9mrGeIegrFXdtQi9pk7O/nSK6lSdXW2eqUspN5LWD7UTji2Fqw5V2YLjBpHEoU9Xl/eUWNpDeZvoyOv2w== +domelementtype@^2.0.1, domelementtype@^2.2.0: + version "2.3.0" + resolved "https://registry.yarnpkg.com/domelementtype/-/domelementtype-2.3.0.tgz#5c45e8e869952626331d7aab326d01daf65d589d" + integrity sha512-OLETBj6w0OsagBwdXnPdN0cnMfF9opN69co+7ZrbfPGrdpPVNBUj02spi6B1N7wChLQiPn4CSH/zJvXw56gmHw== + domexception@^1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/domexception/-/domexception-1.0.1.tgz#937442644ca6a31261ef36e3ec677fe805582c90" @@ -5284,6 +5565,22 @@ domexception@^2.0.1: dependencies: webidl-conversions "^5.0.0" +domhandler@^4.0.0, domhandler@^4.2.0: + version "4.3.1" + resolved "https://registry.yarnpkg.com/domhandler/-/domhandler-4.3.1.tgz#8d792033416f59d68bc03a5aa7b018c1ca89279c" + integrity sha512-GrwoxYN+uWlzO8uhUXRl0P+kHE4GtVPfYzVLcUxPL7KNdHKj66vvlhiweIHqYYXWlw+T8iLMp42Lm67ghw4WMQ== + dependencies: + domelementtype "^2.2.0" + +domutils@^2.5.2: + version "2.8.0" + resolved "https://registry.yarnpkg.com/domutils/-/domutils-2.8.0.tgz#4437def5db6e2d1f5d6ee859bd95ca7d02048135" + integrity sha512-w96Cjofp72M5IIhpjgobBimYEfoPjx1Vx0BSX9P30WBdZW2WIKU0T1Bd0kz2eNZ9ikjKgHbEyKx8BB6H1L3h3A== + dependencies: + dom-serializer "^1.0.1" + domelementtype "^2.2.0" + domhandler "^4.2.0" + dot-prop@^5.2.0: version "5.3.0" resolved "https://registry.yarnpkg.com/dot-prop/-/dot-prop-5.3.0.tgz#90ccce708cd9cd82cc4dc8c3ddd9abdd55b20e88" @@ -5328,6 +5625,11 @@ download@8.0.0: p-event "^2.1.0" pify "^4.0.1" +downloadjs@1.4.7: + version "1.4.7" + resolved "https://registry.yarnpkg.com/downloadjs/-/downloadjs-1.4.7.tgz#f69f96f940e0d0553dac291139865a3cd0101e3c" + integrity sha512-LN1gO7+u9xjU5oEScGFKvXhYf7Y/empUIIEAGBs1LzUq/rg5duiDrkuH5A2lQGd5jfMOb9X9usDa2oVXwJ0U/Q== + duplexer3@^0.1.4: version "0.1.4" resolved "https://registry.yarnpkg.com/duplexer3/-/duplexer3-0.1.4.tgz#ee01dd1cac0ed3cbc7fdbea37dc0a8f1ce002ce2" @@ -5343,6 +5645,17 @@ duplexify@^4.0.0: readable-stream "^3.1.1" stream-shift "^1.0.0" +easymde@^2.16.1: + version "2.16.1" + resolved "https://registry.yarnpkg.com/easymde/-/easymde-2.16.1.tgz#f4c2380312615cb33826f1a1fecfaa4022ff551a" + integrity sha512-FihYgjRsKfhGNk89SHSqxKLC4aJ1kfybPWW6iAmtb5GnXu+tnFPSzSaGBmk1RRlCuhFSjhF0SnIMGVPjEzkr6g== + dependencies: + "@types/codemirror" "^5.60.4" + "@types/marked" "^4.0.1" + codemirror "^5.63.1" + codemirror-spell-checker "1.1.2" + marked "^4.0.10" + ecc-jsbn@~0.1.1: version "0.1.2" resolved "https://registry.yarnpkg.com/ecc-jsbn/-/ecc-jsbn-0.1.2.tgz#3a83a904e54353287874c564b7549386849a98c9" @@ -5454,6 +5767,16 @@ enhanced-resolve@^5.9.3: graceful-fs "^4.2.4" tapable "^2.2.0" +ent@^2.2.0: + version "2.2.0" + resolved "https://registry.yarnpkg.com/ent/-/ent-2.2.0.tgz#e964219325a21d05f44466a2f686ed6ce5f5dd1d" + integrity sha512-GHrMyVZQWvTIdDtpiEXdHZnFQKzeO09apj8Cbl4pKWy4i0Oprcq17usfDt5aO63swf0JOeMWjWQE/LzgSRuWpA== + +entities@^2.0.0: + version "2.2.0" + resolved "https://registry.yarnpkg.com/entities/-/entities-2.2.0.tgz#098dc90ebb83d8dffa089d55256b351d34c4da55" + integrity sha512-p92if5Nz619I0w+akJrLZH0MX0Pb5DX39XOwQTtXSdQQOaYH03S1uIQp4mhOZtAXrxq4ViO67YTiLBo2638o9A== + entities@~2.1.0: version "2.1.0" resolved "https://registry.yarnpkg.com/entities/-/entities-2.1.0.tgz#992d3129cf7df6870b96c57858c249a120f8b8b5" @@ -5887,6 +6210,16 @@ estraverse@^5.1.0, estraverse@^5.2.0: resolved "https://registry.yarnpkg.com/estraverse/-/estraverse-5.3.0.tgz#2eea5290702f26ab8fe5370370ff86c965d21123" integrity sha512-MMdARuVEQziNTeJD8DgMqmhwR11BRQ/cBP+pLtYdSTnf3MIO8fFeiINEbX36ZdNlfU/7A9f3gUw49B3oQsvwBA== +estree-walker@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/estree-walker/-/estree-walker-1.0.1.tgz#31bc5d612c96b704106b477e6dd5d8aa138cb700" + integrity sha512-1fMXF3YP4pZZVozF8j/ZLfvnR8NSIljt56UhbZ5PeeDmmGHpgpdwQt7ITlGvYaQukCvuBRMLEiKiYC+oeIg4cg== + +estree-walker@^2.0.1: + version "2.0.2" + resolved "https://registry.yarnpkg.com/estree-walker/-/estree-walker-2.0.2.tgz#52f010178c2a4c117a7757cfe942adb7d2da4cac" + integrity sha512-Rfkk/Mp/DL7JVje3u18FxFujQlTNR2q6QfMSMB7AvCBx91NGj/ba3kCfza0f6dVDbw7YlRf/nDrn7pQrCCyQ/w== + esutils@^2.0.2: version "2.0.3" resolved "https://registry.yarnpkg.com/esutils/-/esutils-2.0.3.tgz#74d2eb4de0b8da1293711910d50775b9b710ef64" @@ -6436,6 +6769,11 @@ fs-constants@^1.0.0: resolved "https://registry.yarnpkg.com/fs-constants/-/fs-constants-1.0.0.tgz#6be0de9be998ce16af8afc24497b9ee9b7ccd9ad" integrity sha512-y6OAwoSIf7FyjMIv94u+b5rdheZEjzR63GTyZJm5qh4Bi+2YgwLCcI/fPFZkL5PSixOt6ZNKm+w+Hfp/Bciwow== +fs-exists-sync@^0.1.0: + version "0.1.0" + resolved "https://registry.yarnpkg.com/fs-exists-sync/-/fs-exists-sync-0.1.0.tgz#982d6893af918e72d08dec9e8673ff2b5a8d6add" + integrity sha512-cR/vflFyPZtrN6b38ZyWxpWdhlXrzZEBawlpBQMq7033xVY7/kg0GDMBK5jg8lDYQckdJ5x/YC88lM3C7VMsLg== + fs-extra@8.1.0: version "8.1.0" resolved "https://registry.yarnpkg.com/fs-extra/-/fs-extra-8.1.0.tgz#49d43c45a88cd9677668cb7be1b46efdb8d2e1c0" @@ -6584,6 +6922,14 @@ get-intrinsic@^1.0.2, get-intrinsic@^1.1.0, get-intrinsic@^1.1.1: has "^1.0.3" has-symbols "^1.0.3" +get-object@^0.2.0: + version "0.2.0" + resolved "https://registry.yarnpkg.com/get-object/-/get-object-0.2.0.tgz#d92ff7d5190c64530cda0543dac63a3d47fe8c0c" + integrity sha512-7P6y6k6EzEFmO/XyUyFlXm1YLJy9xeA1x/grNV8276abX5GuwUtYgKFkRFkLixw4hf4Pz9q2vgv/8Ar42R0HuQ== + dependencies: + is-number "^2.0.2" + isobject "^0.2.0" + get-package-type@^0.1.0: version "0.1.0" resolved "https://registry.yarnpkg.com/get-package-type/-/get-package-type-0.1.0.tgz#8de2d803cff44df3bc6c456e6668b36c3926e11a" @@ -6646,6 +6992,13 @@ get-value@^2.0.3, get-value@^2.0.6: resolved "https://registry.yarnpkg.com/get-value/-/get-value-2.0.6.tgz#dc15ca1c672387ca76bd37ac0a395ba2042a2c28" integrity sha512-Ln0UQDlxH1BapMu3GPtf7CuYNwRZf2gwCuPqbyG6pB8WfmFpzqcy4xtAaAMUhnNqjMKTiCPZG2oMT3YSx8U2NA== +get-value@^3.0.0, get-value@^3.0.1: + version "3.0.1" + resolved "https://registry.yarnpkg.com/get-value/-/get-value-3.0.1.tgz#5efd2a157f1d6a516d7524e124ac52d0a39ef5a8" + integrity sha512-mKZj9JLQrwMBtj5wxi6MH8Z5eSKaERpAwjg43dPtlGI1ZVEgH/qC7T8/6R2OBSUA+zzHBZgICsVJaEIV2tKTDA== + dependencies: + isobject "^3.0.1" + getopts@2.2.5: version "2.2.5" resolved "https://registry.yarnpkg.com/getopts/-/getopts-2.2.5.tgz#67a0fe471cacb9c687d817cab6450b96dde8313b" @@ -6951,7 +7304,24 @@ gtoken@^5.0.4: google-p12-pem "^3.1.3" jws "^4.0.0" -handlebars@^4.7.7: +gulp-header@^1.7.1: + version "1.8.12" + resolved "https://registry.yarnpkg.com/gulp-header/-/gulp-header-1.8.12.tgz#ad306be0066599127281c4f8786660e705080a84" + integrity sha512-lh9HLdb53sC7XIZOYzTXM4lFuXElv3EVkSDhsd7DoJBj7hm+Ni7D3qYbb+Rr8DuM8nRanBvkVO9d7askreXGnQ== + dependencies: + concat-with-sourcemaps "*" + lodash.template "^4.4.0" + through2 "^2.0.0" + +handlebars-utils@^1.0.6: + version "1.0.6" + resolved "https://registry.yarnpkg.com/handlebars-utils/-/handlebars-utils-1.0.6.tgz#cb9db43362479054782d86ffe10f47abc76357f9" + integrity sha512-d5mmoQXdeEqSKMtQQZ9WkiUcO1E3tPbWxluCK9hVgIDPzQa9WsKo3Lbe/sGflTe7TomHEeZaOgwIkyIr1kfzkw== + dependencies: + kind-of "^6.0.0" + typeof-article "^0.1.1" + +handlebars@^4.7.6, handlebars@^4.7.7: version "4.7.7" resolved "https://registry.yarnpkg.com/handlebars/-/handlebars-4.7.7.tgz#9ce33416aad02dbd6c8fafa8240d5d98004945a1" integrity sha512-aAcXm5OAfE/8IXkcZvCepKU3VzW1/39Fb5ZuqMtgI/hT8X2YgoMvBY5dLhq/cpOvw7Lk1nK/UF71aLG/ZnVYRA== @@ -7045,6 +7415,14 @@ has-value@^1.0.0: has-values "^1.0.0" isobject "^3.0.0" +has-value@^2.0.2: + version "2.0.2" + resolved "https://registry.yarnpkg.com/has-value/-/has-value-2.0.2.tgz#d0f12e8780ba8e90e66ad1a21c707fdb67c25658" + integrity sha512-ybKOlcRsK2MqrM3Hmz/lQxXHZ6ejzSPzpNabKB45jb5qDgJvKPa3SdapTsTLwEb9WltgWpOmNax7i+DzNOk4TA== + dependencies: + get-value "^3.0.0" + has-values "^2.0.1" + has-values@^0.1.4: version "0.1.4" resolved "https://registry.yarnpkg.com/has-values/-/has-values-0.1.4.tgz#6d61de95d91dfca9b9a02089ad384bff8f62b771" @@ -7058,6 +7436,13 @@ has-values@^1.0.0: is-number "^3.0.0" kind-of "^4.0.0" +has-values@^2.0.1: + version "2.0.1" + resolved "https://registry.yarnpkg.com/has-values/-/has-values-2.0.1.tgz#3876200ff86d8a8546a9264a952c17d5fc17579d" + integrity sha512-+QdH3jOmq9P8GfdjFg0eJudqx1FqU62NQJ4P16rOEHeRdl7ckgwn6uqQjzYE0ZoHVV/e5E2esuJ5Gl5+HUW19w== + dependencies: + kind-of "^6.0.2" + has-yarn@^2.1.0: version "2.1.0" resolved "https://registry.yarnpkg.com/has-yarn/-/has-yarn-2.1.0.tgz#137e11354a7b5bf11aa5cb649cf0c6f3ff2b2e77" @@ -7070,6 +7455,16 @@ has@^1.0.3: dependencies: function-bind "^1.1.1" +helper-md@^0.2.2: + version "0.2.2" + resolved "https://registry.yarnpkg.com/helper-md/-/helper-md-0.2.2.tgz#c1f59d7e55bbae23362fd8a0e971607aec69d41f" + integrity sha512-49TaQzK+Ic7ZVTq4i1UZxRUJEmAilTk8hz7q4I0WNUaTclLR8ArJV5B3A1fe1xF2HtsDTr2gYKLaVTof/Lt84Q== + dependencies: + ent "^2.2.0" + extend-shallow "^2.0.1" + fs-exists-sync "^0.1.0" + remarkable "^1.6.2" + homedir-polyfill@^1.0.1: version "1.0.3" resolved "https://registry.yarnpkg.com/homedir-polyfill/-/homedir-polyfill-1.0.3.tgz#743298cef4e5af3e194161fbadcc2151d3a058e8" @@ -7106,6 +7501,24 @@ html-escaper@^2.0.0: resolved "https://registry.yarnpkg.com/html-escaper/-/html-escaper-2.0.2.tgz#dfd60027da36a36dfcbe236262c00a5822681453" integrity sha512-H2iMtd0I4Mt5eYiapRdIDjp+XzelXQ0tFE4JS7YFwFevXXMmOp9myNrUvCg0D6ws8iqkRPBfKHgbwig1SmlLfg== +html-tag@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/html-tag/-/html-tag-2.0.0.tgz#36c3bc8d816fd30b570d5764a497a641640c2fed" + integrity sha512-XxzooSo6oBoxBEUazgjdXj7VwTn/iSTSZzTYKzYY6I916tkaYzypHxy+pbVU1h+0UQ9JlVf5XkNQyxOAiiQO1g== + dependencies: + is-self-closing "^1.0.1" + kind-of "^6.0.0" + +htmlparser2@^6.0.0: + version "6.1.0" + resolved "https://registry.yarnpkg.com/htmlparser2/-/htmlparser2-6.1.0.tgz#c4d762b6c3371a05dbe65e94ae43a9f845fb8fb7" + integrity sha512-gyyPk6rgonLFEDGoeRgQNaEUvdJ4ktTmmUh/h2t7s+M8oPpIPxgNACWa+6ESR57kXstwqPiCut0V8NRpcwgU7A== + dependencies: + domelementtype "^2.0.1" + domhandler "^4.0.0" + domutils "^2.5.2" + entities "^2.0.0" + http-assert@^1.3.0: version "1.5.0" resolved "https://registry.yarnpkg.com/http-assert/-/http-assert-1.5.0.tgz#c389ccd87ac16ed2dfa6246fd73b926aa00e6b8f" @@ -7546,6 +7959,13 @@ is-docker@^2.0.0, is-docker@^2.1.1: resolved "https://registry.yarnpkg.com/is-docker/-/is-docker-2.2.1.tgz#33eeabe23cfe86f14bde4408a02c0cfb853acdaa" integrity sha512-F+i2BKsFrH66iaUFc0woD8sLy8getkwTwtOBjvs56Cx4CgJDeKQeqfz8wAYiSb8JOprWhHH5p77PbmYCvvUuXQ== +is-even@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/is-even/-/is-even-1.0.0.tgz#76b5055fbad8d294a86b6a949015e1c97b717c06" + integrity sha512-LEhnkAdJqic4Dbqn58A0y52IXoHWlsueqQkKfMfdEnIYG8A1sm/GHidKkS6yvXlMoRrkM34csHnXQtOqcb+Jzg== + dependencies: + is-odd "^0.1.2" + is-extendable@^0.1.0, is-extendable@^0.1.1: version "0.1.1" resolved "https://registry.yarnpkg.com/is-extendable/-/is-extendable-0.1.1.tgz#62b110e289a471418e3ec36a617d472e301dfc89" @@ -7635,6 +8055,13 @@ is-number-object@^1.0.4: dependencies: has-tostringtag "^1.0.0" +is-number@^2.0.2: + version "2.1.0" + resolved "https://registry.yarnpkg.com/is-number/-/is-number-2.1.0.tgz#01fcbbb393463a548f2f466cce16dece49db908f" + integrity sha512-QUzH43Gfb9+5yckcrSA0VBDwEtDUchrk4F6tfJZQuNzDJbEDB9cZNzSfXGQ1jqmdDY/kl41lUOWM9syA8z8jlg== + dependencies: + kind-of "^3.0.2" + is-number@^3.0.0: version "3.0.0" resolved "https://registry.yarnpkg.com/is-number/-/is-number-3.0.0.tgz#24fd6201a4782cf50561c810276afc7d12d71195" @@ -7657,6 +8084,13 @@ is-object@^1.0.1: resolved "https://registry.yarnpkg.com/is-object/-/is-object-1.0.2.tgz#a56552e1c665c9e950b4a025461da87e72f86fcf" integrity sha512-2rRIahhZr2UWb45fIOuvZGpFtz0TyOZLf32KxBbSoUCeZR495zCKlWUKKUByk3geS2eAs7ZAABt0Y/Rx0GiQGA== +is-odd@^0.1.2: + version "0.1.2" + resolved "https://registry.yarnpkg.com/is-odd/-/is-odd-0.1.2.tgz#bc573b5ce371ef2aad6e6f49799b72bef13978a7" + integrity sha512-Ri7C2K7o5IrUU9UEI8losXJCCD/UtsaIrkR5sxIcFg4xQ9cRJXlWA5DQvTE0yDc0krvSNLsRGXN11UPS6KyfBw== + dependencies: + is-number "^3.0.0" + is-path-inside@^3.0.2: version "3.0.3" resolved "https://registry.yarnpkg.com/is-path-inside/-/is-path-inside-3.0.3.tgz#d231362e53a07ff2b0e0ea7fed049161ffd16283" @@ -7674,6 +8108,11 @@ is-plain-object@^2.0.3, is-plain-object@^2.0.4: dependencies: isobject "^3.0.1" +is-plain-object@^5.0.0: + version "5.0.0" + resolved "https://registry.yarnpkg.com/is-plain-object/-/is-plain-object-5.0.0.tgz#4427f50ab3429e9025ea7d52e9043a9ef4159344" + integrity sha512-VRSzKkbMm5jMDoKLbltAkFQ5Qr7VDiTFGXxYFXXowVj387GeGNOCsOH6Msy00SGZ3Fp84b1Naa1psqgcCIEP5Q== + is-potential-custom-element-name@^1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/is-potential-custom-element-name/-/is-potential-custom-element-name-1.0.1.tgz#171ed6f19e3ac554394edf78caa05784a45bebb5" @@ -7702,6 +8141,13 @@ is-retry-allowed@^2.2.0: resolved "https://registry.yarnpkg.com/is-retry-allowed/-/is-retry-allowed-2.2.0.tgz#88f34cbd236e043e71b6932d09b0c65fb7b4d71d" integrity sha512-XVm7LOeLpTW4jV19QSH38vkswxoLud8sQ57YwJVTPWdiaI9I8keEhGFpBlslyVsgdQy4Opg8QOLb8YRgsyZiQg== +is-self-closing@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/is-self-closing/-/is-self-closing-1.0.1.tgz#5f406b527c7b12610176320338af0fa3896416e4" + integrity sha512-E+60FomW7Blv5GXTlYee2KDrnG6srxF7Xt1SjrhWUGUEsTFIqY/nq2y3DaftCsgUMdh89V07IVfhY9KIJhLezg== + dependencies: + self-closing-tags "^1.0.1" + is-shared-array-buffer@^1.0.2: version "1.0.2" resolved "https://registry.yarnpkg.com/is-shared-array-buffer/-/is-shared-array-buffer-1.0.2.tgz#8f259c573b60b6a32d4058a1a07430c0a7344c79" @@ -7812,6 +8258,11 @@ isexe@^2.0.0: resolved "https://registry.yarnpkg.com/isexe/-/isexe-2.0.0.tgz#e8fbf374dc556ff8947a10dcb0572d633f2cfa10" integrity sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw== +isobject@^0.2.0: + version "0.2.0" + resolved "https://registry.yarnpkg.com/isobject/-/isobject-0.2.0.tgz#a3432192f39b910b5f02cc989487836ec70aa85e" + integrity sha512-VaWq6XYAsbvM0wf4dyBO7WH9D7GosB7ZZlqrawI9BBiTMINBeCyqSKBa35m870MY3O4aM31pYyZi9DfGrYMJrQ== + isobject@^2.0.0: version "2.1.0" resolved "https://registry.yarnpkg.com/isobject/-/isobject-2.1.0.tgz#f065561096a3f1da2ef46272f815c840d87e0c89" @@ -8992,7 +9443,7 @@ keyv@^3.0.0: dependencies: json-buffer "3.0.0" -kind-of@^3.0.2, kind-of@^3.0.3, kind-of@^3.2.0: +kind-of@^3.0.2, kind-of@^3.0.3, kind-of@^3.1.0, kind-of@^3.2.0: version "3.2.2" resolved "https://registry.yarnpkg.com/kind-of/-/kind-of-3.2.2.tgz#31ea21a734bab9bbb0f32466d893aea51e4a3c64" integrity sha512-NOW9QQXMoZGg/oqnVNoNTTIFEIid1627WCffUBJEdMxYApq7mNE7CpzucIPc+ZQg25Phej7IJSmX3hO+oblOtQ== @@ -9006,12 +9457,12 @@ kind-of@^4.0.0: dependencies: is-buffer "^1.1.5" -kind-of@^5.0.0: +kind-of@^5.0.0, kind-of@^5.0.2: version "5.1.0" resolved "https://registry.yarnpkg.com/kind-of/-/kind-of-5.1.0.tgz#729c91e2d857b7a419a1f9aa65685c4c33f5845d" integrity sha512-NGEErnH6F2vUuXDh+OlbcKW7/wOcfdRHaZ7VWtqCztfHri/++YKmP51OdWeGPuqCOba6kk2OTe5d02VmTB80Pw== -kind-of@^6.0.0, kind-of@^6.0.2: +kind-of@^6.0.0, kind-of@^6.0.2, kind-of@^6.0.3: version "6.0.3" resolved "https://registry.yarnpkg.com/kind-of/-/kind-of-6.0.3.tgz#07c05034a6c349fa06e24fa35aa76db4580ce4dd" integrity sha512-dcS1ul+9tmeD95T+x28/ehLgd9mENa3LsvDTtzm3vyBEO7RPptvAD+t44WVXaUjTBRcrpFeFlC8WCruUR456hw== @@ -9271,6 +9722,11 @@ lcid@^2.0.0: dependencies: invert-kv "^2.0.0" +leaflet@^1.7.1: + version "1.8.0" + resolved "https://registry.yarnpkg.com/leaflet/-/leaflet-1.8.0.tgz#4615db4a22a304e8e692cae9270b983b38a2055e" + integrity sha512-gwhMjFCQiYs3x/Sf+d49f10ERXaEFCPr+nVTryhAW8DWbMGqJqt9G4XuIaHmFW08zYvhgdzqXGr8AlW8v8dQkA== + left-pad@^1.3.0: version "1.3.0" resolved "https://registry.yarnpkg.com/left-pad/-/left-pad-1.3.0.tgz#5b8a3a7765dfe001261dde915589e782f8c94d1e" @@ -9465,6 +9921,11 @@ locate-path@^5.0.0: dependencies: p-locate "^4.1.0" +lodash._reinterpolate@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/lodash._reinterpolate/-/lodash._reinterpolate-3.0.0.tgz#0ccf2d89166af03b3663c796538b75ac6e114d9d" + integrity sha512-xYHt68QRoYGjeeM/XOE1uJtvXQAgvszfBhjV4yvsQH0u2i9I6cI6c6/eG4Hh3UAOVn0y/xAXwmTzEay49Q//HA== + lodash.camelcase@^4.3.0: version "4.3.0" resolved "https://registry.yarnpkg.com/lodash.camelcase/-/lodash.camelcase-4.3.0.tgz#b28aa6288a2b9fc651035c7711f65ab6190331a6" @@ -9575,6 +10036,21 @@ lodash.sortby@^4.7.0: resolved "https://registry.yarnpkg.com/lodash.sortby/-/lodash.sortby-4.7.0.tgz#edd14c824e2cc9c1e0b0a1b42bb5210516a42438" integrity sha512-HDWXG8isMntAyRF5vZ7xKuEvOhT4AhlRt/3czTSjvGUxjYCBVRQY48ViDHyfYz9VIoBkW4TMGQNapx+l3RUwdA== +lodash.template@^4.4.0: + version "4.5.0" + resolved "https://registry.yarnpkg.com/lodash.template/-/lodash.template-4.5.0.tgz#f976195cf3f347d0d5f52483569fe8031ccce8ab" + integrity sha512-84vYFxIkmidUiFxidA/KjjH9pAycqW+h980j7Fuz5qxRtO9pgB7MDFTdys1N7A5mcucRiDyEq4fusljItR1T/A== + dependencies: + lodash._reinterpolate "^3.0.0" + lodash.templatesettings "^4.0.0" + +lodash.templatesettings@^4.0.0: + version "4.2.0" + resolved "https://registry.yarnpkg.com/lodash.templatesettings/-/lodash.templatesettings-4.2.0.tgz#e481310f049d3cf6d47e912ad09313b154f0fb33" + integrity sha512-stgLz+i3Aa9mZgnjr/O+v9ruKZsPsndy7qPZOchbqk2cnTU1ZaldKK+v7m54WoKIyxiuMZTKT2H81F8BeAc3ZQ== + dependencies: + lodash._reinterpolate "^3.0.0" + lodash.without@^4.4.0: version "4.4.0" resolved "https://registry.yarnpkg.com/lodash.without/-/lodash.without-4.4.0.tgz#3cd4574a00b67bae373a94b748772640507b7aac" @@ -9585,7 +10061,7 @@ lodash.xor@^4.5.0: resolved "https://registry.yarnpkg.com/lodash.xor/-/lodash.xor-4.5.0.tgz#4d48ed7e98095b0632582ba714d3ff8ae8fb1db6" integrity sha512-sVN2zimthq7aZ5sPGXnSz32rZPuqcparVW50chJQe+mzTYV+IsxSsl/2gnkWWE2Of7K3myBQBqtLKOUEHJKRsQ== -lodash@4.17.21, lodash@^4.14.0, lodash@^4.17.11, lodash@^4.17.14, lodash@^4.17.15, lodash@^4.17.19, lodash@^4.17.21, lodash@^4.17.3, lodash@^4.7.0: +lodash@4.17.21, lodash@^4.14.0, lodash@^4.17.11, lodash@^4.17.14, lodash@^4.17.15, lodash@^4.17.19, lodash@^4.17.20, lodash@^4.17.21, lodash@^4.17.3, lodash@^4.7.0: version "4.17.21" resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.21.tgz#679591c564c3bffaae8454cf0b3df370c3d6911c" integrity sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg== @@ -9653,6 +10129,13 @@ ltgt@2.2.1, ltgt@^2.1.2, ltgt@~2.2.0: resolved "https://registry.yarnpkg.com/ltgt/-/ltgt-2.2.1.tgz#f35ca91c493f7b73da0e07495304f17b31f87ee5" integrity sha512-AI2r85+4MquTw9ZYqabu4nMwy9Oftlfa/e/52t9IjtfG+mGBbTNdAoZ3RQKLHR6r0wQnwZnPIEh/Ya6XTWAKNA== +magic-string@^0.25.7: + version "0.25.9" + resolved "https://registry.yarnpkg.com/magic-string/-/magic-string-0.25.9.tgz#de7f9faf91ef8a1c91d02c2e5314c8277dbcdd1c" + integrity sha512-RmF0AsMzgt25qzqqLc1+MbHmhdx0ojF2Fvs4XnOqz2ZOBXzzkEwc/dJQZCYHAn7v1jbVOjAZfK8msRn4BxO4VQ== + dependencies: + sourcemap-codec "^1.4.8" + make-dir@^1.0.0: version "1.3.0" resolved "https://registry.yarnpkg.com/make-dir/-/make-dir-1.3.0.tgz#79c1033b80515bd6d24ec9933e860ca75ee27f0c" @@ -9717,6 +10200,11 @@ markdown-it@^12.2.0: mdurl "^1.0.1" uc.micro "^1.0.5" +marked@^4.0.10: + version "4.0.18" + resolved "https://registry.yarnpkg.com/marked/-/marked-4.0.18.tgz#cd0ac54b2e5610cfb90e8fd46ccaa8292c9ed569" + integrity sha512-wbLDJ7Zh0sqA0Vdg6aqlbT+yPxqLblpAZh1mK2+AO2twQkPywvvqQNfEPVwSSRjZ7dZcdeVBIAgiO7MMp3Dszw== + matcher@^3.0.0: version "3.0.0" resolved "https://registry.yarnpkg.com/matcher/-/matcher-3.0.0.tgz#bd9060f4c5b70aa8041ccc6f80368760994f30ca" @@ -9789,7 +10277,7 @@ methods@^1.0.1, methods@^1.1.1, methods@^1.1.2: resolved "https://registry.yarnpkg.com/methods/-/methods-1.1.2.tgz#5529a4d67654134edcc5266656835b0f851afcee" integrity sha512-iclAHeNqNm68zFtnZ0e+1L2yUIdvzNoauKU4WBA3VvH/vPFieF7qfRlwUZU+DA9P9bPXIS90ulxoUoCH23sV2w== -micromatch@^3.1.10, micromatch@^3.1.4: +micromatch@^3.1.10, micromatch@^3.1.4, micromatch@^3.1.5: version "3.1.10" resolved "https://registry.yarnpkg.com/micromatch/-/micromatch-3.1.10.tgz#70859bc95c9840952f359a068a3fc49f9ecfac23" integrity sha512-MWikgl9n9M3w+bpsY3He8L+w9eF9338xRl8IAO5viDizwSzziFEyUzo2xrrloB64ADbTf8uA8vRqqttDTOmccg== @@ -10047,6 +10535,16 @@ nan@^2.12.1: resolved "https://registry.yarnpkg.com/nan/-/nan-2.16.0.tgz#664f43e45460fb98faf00edca0bb0d7b8dce7916" integrity sha512-UdAqHyFngu7TfQKsCBgAA6pWDkT8MAO7d0jyOecVhN5354xbLqdn8mV9Tat9gepAupm0bt2DbeaSC8vS52MuFA== +nanoid@^2.1.0: + version "2.1.11" + resolved "https://registry.yarnpkg.com/nanoid/-/nanoid-2.1.11.tgz#ec24b8a758d591561531b4176a01e3ab4f0f0280" + integrity sha512-s/snB+WGm6uwi0WjsZdaVcuf3KJXlfGl2LcxgwkEwJF0D/BWzVWAZW/XY4bFaiR7s0Jk3FPvlnepg1H1b1UwlA== + +nanoid@^3.3.4: + version "3.3.4" + resolved "https://registry.yarnpkg.com/nanoid/-/nanoid-3.3.4.tgz#730b67e3cd09e2deacf03c027c81c9d9dbc5e8ab" + integrity sha512-MqBkQh/OHTS2egovRtLk45wEyNXwF+cokD+1YPf9u5VfJiRdAiRwB2froX5Co9Rh20xs4siNPm8naNotSD6RBw== + nanomatch@^1.2.9: version "1.2.13" resolved "https://registry.yarnpkg.com/nanomatch/-/nanomatch-1.2.13.tgz#b87a8aa4fc0de8fe6be88895b38983ff265bd119" @@ -10644,6 +11142,11 @@ parse-passwd@^1.0.0: resolved "https://registry.yarnpkg.com/parse-passwd/-/parse-passwd-1.0.0.tgz#6d5b934a456993b23d37f40a382d6f1666a8e5c6" integrity sha512-1Y1A//QUXEZK7YKz+rD9WydcE1+EuPr6ZBgKecAB8tmoW6UFv0NREVJe1p+jRxtThkcbbKkfwIbWJe/IeE6m2Q== +parse-srcset@^1.0.2: + version "1.0.2" + resolved "https://registry.yarnpkg.com/parse-srcset/-/parse-srcset-1.0.2.tgz#f2bd221f6cc970a938d88556abc589caaaa2bde1" + integrity sha512-/2qh0lav6CmI15FzA3i/2Bzk2zCgQhGMkvhOhKNcBVQ1ldgpbfiNTVslmooUmWJcADi1f1kIeynbDRVzNlfR6Q== + parse5@4.0.0: version "4.0.0" resolved "https://registry.yarnpkg.com/parse5/-/parse5-4.0.0.tgz#6d78656e3da8d78b4ec0b906f7c08ef1dfe3f608" @@ -10890,7 +11393,7 @@ picocolors@^1.0.0: resolved "https://registry.yarnpkg.com/picocolors/-/picocolors-1.0.0.tgz#cb5bdc74ff3f51892236eaf79d68bc44564ab81c" integrity sha512-1fygroTLlHu66zi26VoTDv8yRgm0Fccecssto+MhsZ0D/DGW2sm8E8AjW7NU5VVTRt5GxbeZ5qBuJr+HyLYkjQ== -picomatch@^2.0.4, picomatch@^2.2.1, picomatch@^2.2.3, picomatch@^2.3.1: +picomatch@^2.0.4, picomatch@^2.2.1, picomatch@^2.2.2, picomatch@^2.2.3, picomatch@^2.3.1: version "2.3.1" resolved "https://registry.yarnpkg.com/picomatch/-/picomatch-2.3.1.tgz#3ba3833733646d9d3e4995946c1365a67fb07a42" integrity sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA== @@ -11005,6 +11508,15 @@ posix-character-classes@^0.1.0: resolved "https://registry.yarnpkg.com/posix-character-classes/-/posix-character-classes-0.1.1.tgz#01eac0fe3b5af71a2a6c02feabb8c1fef7e00eab" integrity sha512-xTgYBc3fuo7Yt7JbiuFxSYGToMoz8fLoE6TC9Wx1P/u+LfeThMOAqmuyECnlBaaJb+u1m9hHiXUEtwW4OzfUJg== +postcss@^8.3.11: + version "8.4.16" + resolved "https://registry.yarnpkg.com/postcss/-/postcss-8.4.16.tgz#33a1d675fac39941f5f445db0de4db2b6e01d43c" + integrity sha512-ipHE1XBvKzm5xI7hiHCZJCSugxvsdq2mPnsq5+UF+VHCjiBvtDrlxJfMBToWaP9D5XlgNmcFGqoHmUn0EYEaRQ== + dependencies: + nanoid "^3.3.4" + picocolors "^1.0.0" + source-map-js "^1.0.2" + postgres-array@~2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/postgres-array/-/postgres-array-2.0.0.tgz#48f8fce054fbc69671999329b8834b772652d82e" @@ -11753,6 +12265,16 @@ regexp.prototype.flags@^1.4.3: define-properties "^1.1.3" functions-have-names "^1.2.2" +regexparam@2.0.1: + version "2.0.1" + resolved "https://registry.yarnpkg.com/regexparam/-/regexparam-2.0.1.tgz#c912f5dae371e3798100b3c9ce22b7414d0889fa" + integrity sha512-zRgSaYemnNYxUv+/5SeoHI0eJIgTL/A2pUtXUPLHQxUldagouJ9p+K6IbIZ/JiQuCEv2E2B1O11SjVQy3aMCkw== + +regexparam@^1.3.0: + version "1.3.0" + resolved "https://registry.yarnpkg.com/regexparam/-/regexparam-1.3.0.tgz#2fe42c93e32a40eff6235d635e0ffa344b92965f" + integrity sha512-6IQpFBv6e5vz1QAqI+V4k8P2e/3gRrqfCJ9FI+O1FLQTO+Uz6RXZEZOPmTJ6hlGj7gkERzY5BRCv09whKP96/g== + regexpp@^2.0.1: version "2.0.1" resolved "https://registry.yarnpkg.com/regexpp/-/regexpp-2.0.1.tgz#8d19d31cf632482b589049f8281f93dbcba4d07f" @@ -11796,6 +12318,21 @@ regjsparser@^0.8.2: dependencies: jsesc "~0.5.0" +relative@^3.0.2: + version "3.0.2" + resolved "https://registry.yarnpkg.com/relative/-/relative-3.0.2.tgz#0dcd8ec54a5d35a3c15e104503d65375b5a5367f" + integrity sha512-Q5W2qeYtY9GbiR8z1yHNZ1DGhyjb4AnLEjt8iE6XfcC1QIu+FAtj3HQaO0wH28H1mX6cqNLvAqWhP402dxJGyA== + dependencies: + isobject "^2.0.0" + +remarkable@^1.6.2: + version "1.7.4" + resolved "https://registry.yarnpkg.com/remarkable/-/remarkable-1.7.4.tgz#19073cb960398c87a7d6546eaa5e50d2022fcd00" + integrity sha512-e6NKUXgX95whv7IgddywbeN/ItCkWbISmc2DiqHJb0wTrqZIexqdco5b8Z3XZoo/48IdNVKM9ZCvTPJ4F5uvhg== + dependencies: + argparse "^1.0.10" + autolinker "~0.28.0" + remove-trailing-separator@^1.0.1: version "1.1.0" resolved "https://registry.yarnpkg.com/remove-trailing-separator/-/remove-trailing-separator-1.1.0.tgz#c24bce2a283adad5bc3f58e0d48249b92379d8ef" @@ -12007,6 +12544,13 @@ roarr@^2.15.3: semver-compare "^1.0.0" sprintf-js "^1.1.2" +rollup-plugin-polyfill-node@^0.8.0: + version "0.8.0" + resolved "https://registry.yarnpkg.com/rollup-plugin-polyfill-node/-/rollup-plugin-polyfill-node-0.8.0.tgz#859c070822f5e38d221e5b4238cb34aa894c2b19" + integrity sha512-C4UeKedOmOBkB3FgR+z/v9kzRwV1Q/H8xWs1u1+CNe4XOV6hINfOrcO+TredKxYvopCmr+WKUSNsFUnD1RLHgQ== + dependencies: + "@rollup/plugin-inject" "^4.0.0" + rsvp@^4.8.4: version "4.8.5" resolved "https://registry.yarnpkg.com/rsvp/-/rsvp-4.8.5.tgz#c8f155311d167f68f21e168df71ec5b083113734" @@ -12073,6 +12617,18 @@ sane@^4.0.3: minimist "^1.1.1" walker "~1.0.5" +sanitize-html@^2.7.0: + version "2.7.1" + resolved "https://registry.yarnpkg.com/sanitize-html/-/sanitize-html-2.7.1.tgz#a6c2c1a88054a79eeacfac9b0a43f1b393476901" + integrity sha512-oOpe8l4J8CaBk++2haoN5yNI5beekjuHv3JRPKUx/7h40Rdr85pemn4NkvUB3TcBP7yjat574sPlcMAyv4UQig== + dependencies: + deepmerge "^4.2.2" + escape-string-regexp "^4.0.0" + htmlparser2 "^6.0.0" + is-plain-object "^5.0.0" + parse-srcset "^1.0.2" + postcss "^8.3.11" + sanitize-s3-objectkey@0.0.1: version "0.0.1" resolved "https://registry.yarnpkg.com/sanitize-s3-objectkey/-/sanitize-s3-objectkey-0.0.1.tgz#efa9887cd45275b40234fb4bb12fc5754fe64e7e" @@ -12111,6 +12667,11 @@ schema-utils@^3.1.0, schema-utils@^3.1.1: ajv "^6.12.5" ajv-keywords "^3.5.2" +screenfull@^6.0.1: + version "6.0.2" + resolved "https://registry.yarnpkg.com/screenfull/-/screenfull-6.0.2.tgz#3dbe4b8c4f8f49fb8e33caa8f69d0bca730ab238" + integrity sha512-AQdy8s4WhNvUZ6P8F6PB21tSPIYKniic+Ogx0AacBMjKP1GUHN2E9URxQHtCusiwxudnCKkdy4GrHXPPJSkCCw== + search-params@3.0.0: version "3.0.0" resolved "https://registry.yarnpkg.com/search-params/-/search-params-3.0.0.tgz#dbc7c243058e5a33ae1e9870be91f5aced4100d8" @@ -12128,6 +12689,11 @@ seek-bzip@^1.0.5: dependencies: commander "^2.8.1" +self-closing-tags@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/self-closing-tags/-/self-closing-tags-1.0.1.tgz#6c5fa497994bb826b484216916371accee490a5d" + integrity sha512-7t6hNbYMxM+VHXTgJmxwgZgLGktuXtVVD5AivWzNTdJBM4DBjnDKDzkf2SrNjihaArpeJYNjxkELBu1evI4lQA== + semver-compare@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/semver-compare/-/semver-compare-1.0.0.tgz#0dee216a1c941ab37e9efb1788f6afc5ff5537fc" @@ -12263,6 +12829,13 @@ shimmer@^1.2.0: resolved "https://registry.yarnpkg.com/shimmer/-/shimmer-1.2.1.tgz#610859f7de327b587efebf501fb43117f9aff337" integrity sha512-sQTKC1Re/rM6XyFM6fIAGHRPVGvyXfgzIDvzoq608vM+jeyVD0Tu1E6Np0Kc2zAIFWIj963V2800iF/9LPieQw== +shortid@^2.2.15: + version "2.2.16" + resolved "https://registry.yarnpkg.com/shortid/-/shortid-2.2.16.tgz#b742b8f0cb96406fd391c76bfc18a67a57fe5608" + integrity sha512-Ugt+GIZqvGXCIItnsL+lvFJOiN7RYqlGy7QE41O3YC1xbNSeDGIRO7xg2JJXIAj1cAGnOeC1r7/T9pgrtQbv4g== + dependencies: + nanoid "^2.1.0" + side-channel@^1.0.4: version "1.0.4" resolved "https://registry.yarnpkg.com/side-channel/-/side-channel-1.0.4.tgz#efce5c8fdc104ee751b25c58d4290011fa5ea2cf" @@ -12427,6 +13000,11 @@ source-list-map@^2.0.1: resolved "https://registry.yarnpkg.com/source-list-map/-/source-list-map-2.0.1.tgz#3993bd873bfc48479cca9ea3a547835c7c154b34" integrity sha512-qnQ7gVMxGNxsiL4lEuJwe/To8UnK7fAnmbGEEH8RpLouuKbeEm0lhbQVFIrNSuB+G7tVrAlVsZgETT5nljf+Iw== +source-map-js@^1.0.2: + version "1.0.2" + resolved "https://registry.yarnpkg.com/source-map-js/-/source-map-js-1.0.2.tgz#adbc361d9c62df380125e7f161f71c826f1e490c" + integrity sha512-R0XvVJ9WusLiqTCEiGCmICCMplcCkIwwR11mOSD9CR5u+IXYdiseeEuXCVAjS54zqwkLcPNnmU4OeJ6tUrWhDw== + source-map-resolve@^0.5.0: version "0.5.3" resolved "https://registry.yarnpkg.com/source-map-resolve/-/source-map-resolve-0.5.3.tgz#190866bece7553e1f8f267a2ee82c606b5509a1a" @@ -12480,6 +13058,11 @@ source-map@^0.7.3: resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.7.4.tgz#a9bbe705c9d8846f4e08ff6765acf0f1b0898656" integrity sha512-l3BikUxvPOcn5E74dZiq5BGsTb5yEwhaTSzccU6t4sDOH8NWJCstKO5QT2CvtFoK6F0saL7p9xHAqHOlCPJygA== +sourcemap-codec@^1.4.8: + version "1.4.8" + resolved "https://registry.yarnpkg.com/sourcemap-codec/-/sourcemap-codec-1.4.8.tgz#ea804bd94857402e6992d05a38ef1ae35a9ab4c4" + integrity sha512-9NykojV5Uih4lgo5So5dtw+f0JgJX30KCNI8gwhz2J9A15wD0Ml6tjHKwf6fTSa6fAdVBdZeNOs9eJ71qCk8vA== + spark-md5@3.0.1: version "3.0.1" resolved "https://registry.yarnpkg.com/spark-md5/-/spark-md5-3.0.1.tgz#83a0e255734f2ab4e5c466e5a2cfc9ba2aa2124d" @@ -12804,6 +13387,11 @@ strip-outer@^1.0.0: dependencies: escape-string-regexp "^1.0.2" +striptags@^3.1.1: + version "3.2.0" + resolved "https://registry.yarnpkg.com/striptags/-/striptags-3.2.0.tgz#cc74a137db2de8b0b9a370006334161f7dd67052" + integrity sha512-g45ZOGzHDMe2bdYMdIvdAfCQkCTDMGBazSw1ypMowwGIee7ZQ5dU0rBJ8Jqgl+jAKIv4dbeE1jscZq9wid1Tkw== + style-loader@^3.3.1: version "3.3.1" resolved "https://registry.yarnpkg.com/style-loader/-/style-loader-3.3.1.tgz#057dfa6b3d4d7c7064462830f9113ed417d38575" @@ -12903,7 +13491,14 @@ svelte-portal@^1.0.0: resolved "https://registry.yarnpkg.com/svelte-portal/-/svelte-portal-1.0.0.tgz#36a47c5578b1a4d9b4dc60fa32a904640ec4cdd3" integrity sha512-nHf+DS/jZ6jjnZSleBMSaZua9JlG5rZv9lOGKgJuaZStfevtjIlUJrkLc3vbV8QdBvPPVmvcjTlazAzfKu0v3Q== -svelte@3.49.0: +svelte-spa-router@^3.0.5: + version "3.3.0" + resolved "https://registry.yarnpkg.com/svelte-spa-router/-/svelte-spa-router-3.3.0.tgz#2fc0967a49dc361dfe4d38dddad6e662eed5b42c" + integrity sha512-cwRNe7cxD43sCvSfEeaKiNZg3FCizGxeMcf7CPiWRP3jKXjEma3vxyyuDtPOam6nWbVxl9TNM3hlE/i87ZlqcQ== + dependencies: + regexparam "2.0.1" + +svelte@3.49.0, svelte@^3.46.2, svelte@^3.49.0: version "3.49.0" resolved "https://registry.yarnpkg.com/svelte/-/svelte-3.49.0.tgz#5baee3c672306de1070c3b7888fc2204e36a4029" integrity sha512-+lmjic1pApJWDfPCpUUTc1m8azDqYCG1JN9YEngrx/hUyIcFJo6VZhj0A1Ai0wqoHcEIuQy+e9tk+4uDgdtsFA== @@ -13265,6 +13860,11 @@ to-fast-properties@^2.0.0: resolved "https://registry.yarnpkg.com/to-fast-properties/-/to-fast-properties-2.0.0.tgz#dc5e698cbd079265bc73e0377681a4e4e83f616e" integrity sha1-3F5pjL0HkmW8c+A3doGk5Og/YW4= +to-gfm-code-block@^0.1.1: + version "0.1.1" + resolved "https://registry.yarnpkg.com/to-gfm-code-block/-/to-gfm-code-block-0.1.1.tgz#25d045a5fae553189e9637b590900da732d8aa82" + integrity sha512-LQRZWyn8d5amUKnfR9A9Uu7x9ss7Re8peuWR2gkh1E+ildOfv2aF26JpuDg8JtvCduu5+hOrMIH+XstZtnagqg== + to-json-schema@0.2.5: version "0.2.5" resolved "https://registry.yarnpkg.com/to-json-schema/-/to-json-schema-0.2.5.tgz#ef3c3f11ad64460dcfbdbafd0fd525d69d62a98f" @@ -13511,6 +14111,13 @@ typedarray-to-buffer@^3.1.5: dependencies: is-typedarray "^1.0.0" +typeof-article@^0.1.1: + version "0.1.1" + resolved "https://registry.yarnpkg.com/typeof-article/-/typeof-article-0.1.1.tgz#9f07e733c3fbb646ffa9e61c08debacd460e06af" + integrity sha512-Vn42zdX3FhmUrzEmitX3iYyLb+Umwpmv8fkZRIknYh84lmdrwqZA5xYaoKiIj2Rc5i/5wcDrpUmZcbk1U51vTw== + dependencies: + kind-of "^3.1.0" + typeof@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/typeof/-/typeof-1.0.0.tgz#9c84403f2323ae5399167275497638ea1d2f2440" @@ -13521,6 +14128,11 @@ typescript@4.6.2: resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.6.2.tgz#fe12d2727b708f4eef40f51598b3398baa9611d4" integrity sha512-HM/hFigTBHZhLXshn9sN37H085+hQGeJHJ/X7LpBWLID/fbc2acUMfU+lGD98X81sKP+pFa9f0DZmCwB9GnbAg== +typo-js@*: + version "1.2.2" + resolved "https://registry.yarnpkg.com/typo-js/-/typo-js-1.2.2.tgz#340484d81fe518e77c81a5a770162b14492f183b" + integrity sha512-C7pYBQK17EjSg8tVNY91KHdUt5Nf6FMJ+c3js076quPmBML57PmNMzAcIq/2kf/hSYtFABNDIYNYlJRl5BJhGw== + uc.micro@^1.0.1, uc.micro@^1.0.5: version "1.0.6" resolved "https://registry.yarnpkg.com/uc.micro/-/uc.micro-1.0.6.tgz#9c411a802a409a91fc6cf74081baba34b24499ac" @@ -13845,6 +14457,14 @@ vm2@3.9.6: acorn "^8.7.0" acorn-walk "^8.2.0" +vm2@^3.9.4: + version "3.9.10" + resolved "https://registry.yarnpkg.com/vm2/-/vm2-3.9.10.tgz#c66543096b5c44c8861a6465805c23c7cc996a44" + integrity sha512-AuECTSvwu2OHLAZYhG716YzwodKCIJxB6u1zG7PgSQwIgAlEaoXH52bxdcvT8GkGjnYK7r7yWDW0m0sOsPuBjQ== + dependencies: + acorn "^8.7.0" + acorn-walk "^8.2.0" + vuvuzela@1.0.3: version "1.0.3" resolved "https://registry.yarnpkg.com/vuvuzela/-/vuvuzela-1.0.3.tgz#3be145e58271c73ca55279dd851f12a682114b0b" @@ -14398,6 +15018,11 @@ yauzl@^2.4.2: buffer-crc32 "~0.2.3" fd-slicer "~1.1.0" +year@^0.2.1: + version "0.2.1" + resolved "https://registry.yarnpkg.com/year/-/year-0.2.1.tgz#4083ae520a318b23ec86037f3000cb892bdf9bb0" + integrity sha512-9GnJUZ0QM4OgXuOzsKNzTJ5EOkums1Xc+3YQXp+Q+UxFjf7zLucp9dQ8QMIft0Szs1E1hUiXFim1OYfEKFq97w== + ylru@^1.2.0: version "1.3.2" resolved "https://registry.yarnpkg.com/ylru/-/ylru-1.3.2.tgz#0de48017473275a4cbdfc83a1eaf67c01af8a785" diff --git a/packages/types/src/documents/plugin/index.ts b/packages/types/src/documents/plugin/index.ts index 03a239a6c9..8133e91523 100644 --- a/packages/types/src/documents/plugin/index.ts +++ b/packages/types/src/documents/plugin/index.ts @@ -2,3 +2,8 @@ export enum PluginType { DATASOURCE = "datasource", COMPONENT = "component", } + +export interface FileType { + path: string + name: string +} From 04f49fd7b936a5d10db2b300483d974a2af23b5c Mon Sep 17 00:00:00 2001 From: Andrew Kingston Date: Tue, 16 Aug 2022 09:25:16 +0000 Subject: [PATCH 037/203] Proxy vite HMR websocket in dev --- hosting/nginx.dev.conf.hbs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/hosting/nginx.dev.conf.hbs b/hosting/nginx.dev.conf.hbs index 9398b7e719..91f495cfac 100644 --- a/hosting/nginx.dev.conf.hbs +++ b/hosting/nginx.dev.conf.hbs @@ -77,6 +77,11 @@ http { proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; } + location /ws { + proxy_pass http://{{ address }}:3000; + rewrite ^/ws(.*)$ /$1 break; + } + location / { proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; From 4645901309b7bb2a4bb465cf75b9baf841980a45 Mon Sep 17 00:00:00 2001 From: Andrew Kingston Date: Tue, 16 Aug 2022 09:26:23 +0000 Subject: [PATCH 038/203] Support env variables for vite config --- packages/builder/vite.config.js | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/packages/builder/vite.config.js b/packages/builder/vite.config.js index 56ffbf20f5..9859e1dbb9 100644 --- a/packages/builder/vite.config.js +++ b/packages/builder/vite.config.js @@ -1,15 +1,22 @@ import { svelte } from "@sveltejs/vite-plugin-svelte" import replace from "@rollup/plugin-replace" +import { defineConfig, loadEnv } from "vite" import path from "path" -export default ({ mode }) => { +export default defineConfig(({ mode }) => { const isProduction = mode === "production" + const env = loadEnv(mode, process.cwd()) return { server: { fs: { strict: false, }, + hmr: { + protocol: "wss", + clientPort: env.VITE_HMR_CLIENT_PORT || 3000, + path: env.VITE_HMR_PATH || "/" + } }, base: "/builder/", build: { @@ -79,4 +86,4 @@ export default ({ mode }) => { ], }, } -} +}) From 2a6719d3acb40ece69f88961e912de4c03ce81f4 Mon Sep 17 00:00:00 2001 From: Andrew Kingston Date: Tue, 16 Aug 2022 14:02:51 +0000 Subject: [PATCH 039/203] Only watch plugins in single tenant envs --- packages/server/src/app.ts | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/packages/server/src/app.ts b/packages/server/src/app.ts index 2f8adc879d..6f63715cfb 100644 --- a/packages/server/src/app.ts +++ b/packages/server/src/app.ts @@ -25,7 +25,7 @@ import * as migrations from "./migrations" import { events, installation, tenancy } from "@budibase/backend-core" import { createAdminUser, getChecklist } from "./utilities/workerRequests" import { processPlugin } from "./api/controllers/plugin" -import { getGlobalDB } from "@budibase/backend-core/tenancy" +import { DEFAULT_TENANT_ID } from "@budibase/backend-core/constants" const app = new Koa() @@ -138,7 +138,7 @@ module.exports = server.listen(env.PORT || 0, async () => { } // monitor plugin directory if required - if (env.SELF_HOSTED && env.PLUGINS_DIR && fs.existsSync(env.PLUGINS_DIR)) { + if (env.SELF_HOSTED && !env.MULTI_TENANCY && env.PLUGINS_DIR && fs.existsSync(env.PLUGINS_DIR)) { const watchPath = path.join(env.PLUGINS_DIR, "./**/dist/*.tar.gz") chokidar .watch(watchPath, { @@ -146,8 +146,7 @@ module.exports = server.listen(env.PORT || 0, async () => { awaitWriteFinish: true, }) .on("all", async (event: string, path: string) => { - const tenantId = tenancy.getTenantId() - await tenancy.doInTenant(tenantId, async () => { + await tenancy.doInTenant(DEFAULT_TENANT_ID, async () => { try { const split = path.split("/") const name = split[split.length - 1] From bb19810e361cee0714698f6a11c585fbdd20c09e Mon Sep 17 00:00:00 2001 From: Andrew Kingston Date: Tue, 16 Aug 2022 14:42:32 +0000 Subject: [PATCH 040/203] Add missing declaration of objectstore module --- packages/server/src/module.d.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/server/src/module.d.ts b/packages/server/src/module.d.ts index 4c0e13586a..eb1d1feb48 100644 --- a/packages/server/src/module.d.ts +++ b/packages/server/src/module.d.ts @@ -10,3 +10,4 @@ declare module "@budibase/backend-core/sessions" declare module "@budibase/backend-core/encryption" declare module "@budibase/backend-core/utils" declare module "@budibase/backend-core/redis" +declare module "@budibase/backend-core/objectStore" From 55eef09204a0274ef6f47d0081e67d9d4f740bb9 Mon Sep 17 00:00:00 2001 From: Andrew Kingston Date: Tue, 16 Aug 2022 15:14:47 +0000 Subject: [PATCH 041/203] Add PLUGINS_DIR env var and show example mount for HMR of plugins --- hosting/docker-compose.yaml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/hosting/docker-compose.yaml b/hosting/docker-compose.yaml index 7d3e6960dc..4506467791 100644 --- a/hosting/docker-compose.yaml +++ b/hosting/docker-compose.yaml @@ -25,9 +25,12 @@ services: REDIS_PASSWORD: ${REDIS_PASSWORD} BB_ADMIN_USER_EMAIL: ${BB_ADMIN_USER_EMAIL} BB_ADMIN_USER_PASSWORD: ${BB_ADMIN_USER_PASSWORD} + PLUGINS_DIR: ${PLUGINS_DIR} depends_on: - worker-service - redis-service +# volumes: +# - /some/path/to/plugins:/plugins worker-service: restart: unless-stopped From 623a5ee563649e6cf0802e1460d63f66c22a8ea3 Mon Sep 17 00:00:00 2001 From: Andrew Kingston Date: Tue, 16 Aug 2022 15:16:46 +0000 Subject: [PATCH 042/203] Default plugins dir to /plugins --- packages/server/src/app.ts | 7 ++++++- packages/server/src/environment.js | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/packages/server/src/app.ts b/packages/server/src/app.ts index 6f63715cfb..e9a5661093 100644 --- a/packages/server/src/app.ts +++ b/packages/server/src/app.ts @@ -138,7 +138,12 @@ module.exports = server.listen(env.PORT || 0, async () => { } // monitor plugin directory if required - if (env.SELF_HOSTED && !env.MULTI_TENANCY && env.PLUGINS_DIR && fs.existsSync(env.PLUGINS_DIR)) { + if ( + env.SELF_HOSTED && + !env.MULTI_TENANCY && + env.PLUGINS_DIR && + fs.existsSync(env.PLUGINS_DIR) + ) { const watchPath = path.join(env.PLUGINS_DIR, "./**/dist/*.tar.gz") chokidar .watch(watchPath, { diff --git a/packages/server/src/environment.js b/packages/server/src/environment.js index 5a7aa61b9d..5524159a78 100644 --- a/packages/server/src/environment.js +++ b/packages/server/src/environment.js @@ -77,7 +77,7 @@ module.exports = { SQL_MAX_ROWS: process.env.SQL_MAX_ROWS, BB_ADMIN_USER_EMAIL: process.env.BB_ADMIN_USER_EMAIL, BB_ADMIN_USER_PASSWORD: process.env.BB_ADMIN_USER_PASSWORD, - PLUGINS_DIR: process.env.PLUGINS_DIR, + PLUGINS_DIR: process.env.PLUGINS_DIR || "/plugins", // flags ALLOW_DEV_AUTOMATIONS: process.env.ALLOW_DEV_AUTOMATIONS, DISABLE_THREADING: process.env.DISABLE_THREADING, From 45594e442a8c17b7a1439c02ef6983382096950a Mon Sep 17 00:00:00 2001 From: Michael Drury Date: Tue, 16 Aug 2022 16:27:03 +0100 Subject: [PATCH 043/203] Adding watch command to CLI. --- packages/builder/vite.config.js | 4 ++-- packages/cli/src/plugins/index.js | 31 +++++++++++++++++++++++++++++-- packages/cli/src/prebuilds.js | 5 ++++- packages/cli/yarn.lock | 26 +++++++++++++------------- packages/server/src/app.ts | 7 ++++++- packages/server/yarn.lock | 31 +++++++++++++++---------------- packages/worker/yarn.lock | 31 +++++++++++++++---------------- 7 files changed, 84 insertions(+), 51 deletions(-) diff --git a/packages/builder/vite.config.js b/packages/builder/vite.config.js index 9859e1dbb9..20ff93831c 100644 --- a/packages/builder/vite.config.js +++ b/packages/builder/vite.config.js @@ -15,8 +15,8 @@ export default defineConfig(({ mode }) => { hmr: { protocol: "wss", clientPort: env.VITE_HMR_CLIENT_PORT || 3000, - path: env.VITE_HMR_PATH || "/" - } + path: env.VITE_HMR_PATH || "/", + }, }, base: "/builder/", build: { diff --git a/packages/cli/src/plugins/index.js b/packages/cli/src/plugins/index.js index e6de624b63..3ee2463a31 100644 --- a/packages/cli/src/plugins/index.js +++ b/packages/cli/src/plugins/index.js @@ -41,7 +41,7 @@ async function init(opts) { console.log(info(`Plugin created in directory "${name}"`)) } -async function build() { +async function verify() { console.log(info("Verifying plugin...")) const schema = fs.readFileSync("schema.json", "utf8") const pkg = fs.readFileSync("package.json", "utf8") @@ -57,21 +57,43 @@ async function build() { name = pkgJson.name version = pkgJson.version validate(schemaJson) + return { name, version } } catch (err) { if (err && err.message && err.message.includes("not valid JSON")) { console.log(error(`schema.json is not valid JSON: ${err.message}`)) } else { console.log(error(`Invalid schema/package.json: ${err.message}`)) } + } +} + +async function build() { + const verified = await verify() + if (!verified.name) { return } console.log(success("Verified!")) console.log(info("Building plugin...")) await runPkgCommand("build") - const output = join("dist", `${name}-${version}.tar.gz`) + const output = join("dist", `${verified.name}-${verified.version}.tar.gz`) console.log(success(`Build complete - output in: ${output}`)) } +async function watch() { + const verified = await verify() + if (!verified.name) { + return + } + const output = join("dist", `${verified.name}-${verified.version}.tar.gz`) + console.log(info(`Watching - build in: ${output}`)) + try { + await runPkgCommand("watch") + } catch (err) { + // always errors when user escapes + console.log(success("Watch exited.")) + } +} + const command = new Command(`${CommandWords.PLUGIN}`) .addHelp( "Custom plugins for Budibase, init, build and verify your components and datasources with this tool." @@ -86,5 +108,10 @@ const command = new Command(`${CommandWords.PLUGIN}`) "Build your plugin, this will verify and produce a final tarball for your project.", build ) + .addSubOption( + "--watch", + "Automatically build any changes to your plugin.", + watch + ) exports.command = command diff --git a/packages/cli/src/prebuilds.js b/packages/cli/src/prebuilds.js index ecc59f964a..b8f380a937 100644 --- a/packages/cli/src/prebuilds.js +++ b/packages/cli/src/prebuilds.js @@ -5,7 +5,10 @@ const PREBUILDS = "prebuilds" const ARCH = `${os.platform()}-${os.arch()}` const PREBUILD_DIR = join(process.execPath, "..", PREBUILDS, ARCH) -checkForBinaries() +// running as built CLI pkg bundle +if (!process.argv[0].includes("node")) { + checkForBinaries() +} function checkForBinaries() { const readDir = join(__filename, "..", "..", PREBUILDS, ARCH) diff --git a/packages/cli/yarn.lock b/packages/cli/yarn.lock index 43c219fcd7..72b4bb328e 100644 --- a/packages/cli/yarn.lock +++ b/packages/cli/yarn.lock @@ -43,12 +43,12 @@ "@babel/helper-validator-identifier" "^7.16.7" to-fast-properties "^2.0.0" -"@budibase/backend-core@^1.2.38": - version "1.2.38" - resolved "https://registry.yarnpkg.com/@budibase/backend-core/-/backend-core-1.2.38.tgz#9451ae72f6af8cff3aa0a57dc61fc8d3505a77a0" - integrity sha512-g7m4fHG1tLqNsSvdSltqRHLASOH5n3QBbN5DD7cmSBIVpUtDCA0EMx/L0vkDDhTmbOQApXAW3cyJs6H3QiWtOw== +"@budibase/backend-core@1.2.40": + version "1.2.40" + resolved "https://registry.yarnpkg.com/@budibase/backend-core/-/backend-core-1.2.40.tgz#692062478f310eaee780adbc55e266fc3b6649b6" + integrity sha512-HUw6IQgKkP345vnQcTok6X+inqYe0WpUL7uFJnm3XERvsAWX4FYWbgDoGJGS0+jZjdPjvARkt4+uZuTAEUFLiQ== dependencies: - "@budibase/types" "^1.2.38" + "@budibase/types" "^1.2.40" "@techpass/passport-openidconnect" "0.3.2" aws-sdk "2.1030.0" bcrypt "5.0.1" @@ -101,10 +101,10 @@ to-gfm-code-block "^0.1.1" year "^0.2.1" -"@budibase/string-templates@^1.2.38": - version "1.2.38" - resolved "https://registry.yarnpkg.com/@budibase/string-templates/-/string-templates-1.2.38.tgz#404804df516fb981b4f073f09bab64c9111cecb0" - integrity sha512-JRIAZVuuBECxDBcbx5FOYRRKi1ZyW7//LwKL5U1r9sIVCIxCW1t5b175oTnR9/bkktNs7X2ziynH/tsT5GVC0g== +"@budibase/string-templates@1.2.40": + version "1.2.40" + resolved "https://registry.yarnpkg.com/@budibase/string-templates/-/string-templates-1.2.40.tgz#d7012b415a51e0119ac098e77d052f96bc04e742" + integrity sha512-Vc/DrmJ//kpT+QoIGqloVnomBJgHVPNIiCOXc+2XSsN5HyR18S8uO7lc77cpln3dTlvNcd7bQqXO1UIx8oebUQ== dependencies: "@budibase/handlebars-helpers" "^0.11.8" dayjs "^1.10.4" @@ -113,10 +113,10 @@ lodash "^4.17.20" vm2 "^3.9.4" -"@budibase/types@^1.2.38": - version "1.2.38" - resolved "https://registry.yarnpkg.com/@budibase/types/-/types-1.2.38.tgz#472f4ec891242488561a8cfc175961664bc7ac88" - integrity sha512-pMKh4FKhPoa1pge4FKqPi3gbzZp3HJ1RuhM5naKFqC1yompIn/Es+YNft39VC2bTW5tiGbucMcjWzdpMwTSTVw== +"@budibase/types@1.2.40", "@budibase/types@^1.2.40": + version "1.2.40" + resolved "https://registry.yarnpkg.com/@budibase/types/-/types-1.2.40.tgz#c1456728b61966cab7fe3689bd044bf415faa138" + integrity sha512-eNZFG0C/GBog87y6StKBjdF/aDJJtUHbAM8NWLUNNqTAiMxO2s3XhDN1dE6t74NBCRFzJo2sAD+34pJHhKFanQ== "@eslint/eslintrc@^0.4.3": version "0.4.3" diff --git a/packages/server/src/app.ts b/packages/server/src/app.ts index 6f63715cfb..e9a5661093 100644 --- a/packages/server/src/app.ts +++ b/packages/server/src/app.ts @@ -138,7 +138,12 @@ module.exports = server.listen(env.PORT || 0, async () => { } // monitor plugin directory if required - if (env.SELF_HOSTED && !env.MULTI_TENANCY && env.PLUGINS_DIR && fs.existsSync(env.PLUGINS_DIR)) { + if ( + env.SELF_HOSTED && + !env.MULTI_TENANCY && + env.PLUGINS_DIR && + fs.existsSync(env.PLUGINS_DIR) + ) { const watchPath = path.join(env.PLUGINS_DIR, "./**/dist/*.tar.gz") chokidar .watch(watchPath, { diff --git a/packages/server/yarn.lock b/packages/server/yarn.lock index ebfd49ce8b..e39b0b97c4 100644 --- a/packages/server/yarn.lock +++ b/packages/server/yarn.lock @@ -1094,19 +1094,18 @@ resolved "https://registry.yarnpkg.com/@bcoe/v8-coverage/-/v8-coverage-0.2.3.tgz#75a2e8b51cb758a7553d6804a5932d7aace75c39" integrity sha512-0hYQ8SB4Db5zvZB4axdMHGwEaQjkZzFjQiN9LVYvIFB2nSUHW9tYpxWriPrWDASIxiaXax83REcLxuSdnGPZtw== -"@budibase/backend-core@1.2.39-alpha.8": - version "1.2.39-alpha.8" - resolved "https://registry.yarnpkg.com/@budibase/backend-core/-/backend-core-1.2.39-alpha.8.tgz#70c4d3de7c68feaa3d7b183e4c9cfb1baf3d3d47" - integrity sha512-vBGPIei1qVPmbrHKGD4Swf7ECOWGXV+2buRIOkr0gRawK8oLOXc2xYV1zsDM7jd7rTMwtyF86fL/lhaSkXWwKA== +"@budibase/backend-core@1.2.40": + version "1.2.40" + resolved "https://registry.yarnpkg.com/@budibase/backend-core/-/backend-core-1.2.40.tgz#692062478f310eaee780adbc55e266fc3b6649b6" + integrity sha512-HUw6IQgKkP345vnQcTok6X+inqYe0WpUL7uFJnm3XERvsAWX4FYWbgDoGJGS0+jZjdPjvARkt4+uZuTAEUFLiQ== dependencies: - "@budibase/types" "1.2.39-alpha.8" + "@budibase/types" "^1.2.40" "@techpass/passport-openidconnect" "0.3.2" aws-sdk "2.1030.0" bcrypt "5.0.1" dotenv "16.0.1" emitter-listener "1.1.2" ioredis "4.28.0" - joi "17.6.0" jsonwebtoken "8.5.1" koa-passport "4.1.4" lodash "4.17.21" @@ -1178,13 +1177,13 @@ svelte-flatpickr "^3.2.3" svelte-portal "^1.0.0" -"@budibase/pro@1.2.39-alpha.8": - version "1.2.39-alpha.8" - resolved "https://registry.yarnpkg.com/@budibase/pro/-/pro-1.2.39-alpha.8.tgz#11433da0dba0e6c81ad93d6cabc5ce165db94e0f" - integrity sha512-1N3FnVPhUwh2KR0IGiN+EjbY3LpF563Ac2FyT/JgyS9wG6NTP0hV/ugA7TZIvkv2XaYroYMYSPBa/wYtWh4xBQ== +"@budibase/pro@1.2.40": + version "1.2.40" + resolved "https://registry.yarnpkg.com/@budibase/pro/-/pro-1.2.40.tgz#007cad4d8341698104498ae7d1578a7e26760dd7" + integrity sha512-lGB0/O8l63FtpP1dOzxowFUjgj7SrRSVsODygPB7oScfUBtbqHyZKC4EafrVpJT4A8hbdh1ijQZ8PLJE/YdRkQ== dependencies: - "@budibase/backend-core" "1.2.39-alpha.8" - "@budibase/types" "1.2.39-alpha.8" + "@budibase/backend-core" "1.2.40" + "@budibase/types" "1.2.40" "@koa/router" "8.0.8" joi "17.6.0" node-fetch "^2.6.1" @@ -1207,10 +1206,10 @@ svelte-apexcharts "^1.0.2" svelte-flatpickr "^3.1.0" -"@budibase/types@1.2.39-alpha.8": - version "1.2.39-alpha.8" - resolved "https://registry.yarnpkg.com/@budibase/types/-/types-1.2.39-alpha.8.tgz#2999dac33da64b41f222d0fe73cfd387957952d9" - integrity sha512-UbknZ3Pnl8tdCPy5XKkuW3OQb1T/L+n1slY8/orm8KpR/TOEhK4Q20JRxENqQo5f9Za8bX4COesLjwAmae426Q== +"@budibase/types@1.2.40", "@budibase/types@^1.2.40": + version "1.2.40" + resolved "https://registry.yarnpkg.com/@budibase/types/-/types-1.2.40.tgz#c1456728b61966cab7fe3689bd044bf415faa138" + integrity sha512-eNZFG0C/GBog87y6StKBjdF/aDJJtUHbAM8NWLUNNqTAiMxO2s3XhDN1dE6t74NBCRFzJo2sAD+34pJHhKFanQ== "@bull-board/api@3.7.0": version "3.7.0" diff --git a/packages/worker/yarn.lock b/packages/worker/yarn.lock index 9b29ca8dc7..9806952df8 100644 --- a/packages/worker/yarn.lock +++ b/packages/worker/yarn.lock @@ -291,19 +291,18 @@ resolved "https://registry.yarnpkg.com/@bcoe/v8-coverage/-/v8-coverage-0.2.3.tgz#75a2e8b51cb758a7553d6804a5932d7aace75c39" integrity sha512-0hYQ8SB4Db5zvZB4axdMHGwEaQjkZzFjQiN9LVYvIFB2nSUHW9tYpxWriPrWDASIxiaXax83REcLxuSdnGPZtw== -"@budibase/backend-core@1.2.39-alpha.8": - version "1.2.39-alpha.8" - resolved "https://registry.yarnpkg.com/@budibase/backend-core/-/backend-core-1.2.39-alpha.8.tgz#70c4d3de7c68feaa3d7b183e4c9cfb1baf3d3d47" - integrity sha512-vBGPIei1qVPmbrHKGD4Swf7ECOWGXV+2buRIOkr0gRawK8oLOXc2xYV1zsDM7jd7rTMwtyF86fL/lhaSkXWwKA== +"@budibase/backend-core@1.2.40": + version "1.2.40" + resolved "https://registry.yarnpkg.com/@budibase/backend-core/-/backend-core-1.2.40.tgz#692062478f310eaee780adbc55e266fc3b6649b6" + integrity sha512-HUw6IQgKkP345vnQcTok6X+inqYe0WpUL7uFJnm3XERvsAWX4FYWbgDoGJGS0+jZjdPjvARkt4+uZuTAEUFLiQ== dependencies: - "@budibase/types" "1.2.39-alpha.8" + "@budibase/types" "^1.2.40" "@techpass/passport-openidconnect" "0.3.2" aws-sdk "2.1030.0" bcrypt "5.0.1" dotenv "16.0.1" emitter-listener "1.1.2" ioredis "4.28.0" - joi "17.6.0" jsonwebtoken "8.5.1" koa-passport "4.1.4" lodash "4.17.21" @@ -325,21 +324,21 @@ uuid "8.3.2" zlib "1.0.5" -"@budibase/pro@1.2.39-alpha.8": - version "1.2.39-alpha.8" - resolved "https://registry.yarnpkg.com/@budibase/pro/-/pro-1.2.39-alpha.8.tgz#11433da0dba0e6c81ad93d6cabc5ce165db94e0f" - integrity sha512-1N3FnVPhUwh2KR0IGiN+EjbY3LpF563Ac2FyT/JgyS9wG6NTP0hV/ugA7TZIvkv2XaYroYMYSPBa/wYtWh4xBQ== +"@budibase/pro@1.2.40": + version "1.2.40" + resolved "https://registry.yarnpkg.com/@budibase/pro/-/pro-1.2.40.tgz#007cad4d8341698104498ae7d1578a7e26760dd7" + integrity sha512-lGB0/O8l63FtpP1dOzxowFUjgj7SrRSVsODygPB7oScfUBtbqHyZKC4EafrVpJT4A8hbdh1ijQZ8PLJE/YdRkQ== dependencies: - "@budibase/backend-core" "1.2.39-alpha.8" - "@budibase/types" "1.2.39-alpha.8" + "@budibase/backend-core" "1.2.40" + "@budibase/types" "1.2.40" "@koa/router" "8.0.8" joi "17.6.0" node-fetch "^2.6.1" -"@budibase/types@1.2.39-alpha.8": - version "1.2.39-alpha.8" - resolved "https://registry.yarnpkg.com/@budibase/types/-/types-1.2.39-alpha.8.tgz#2999dac33da64b41f222d0fe73cfd387957952d9" - integrity sha512-UbknZ3Pnl8tdCPy5XKkuW3OQb1T/L+n1slY8/orm8KpR/TOEhK4Q20JRxENqQo5f9Za8bX4COesLjwAmae426Q== +"@budibase/types@1.2.40", "@budibase/types@^1.2.40": + version "1.2.40" + resolved "https://registry.yarnpkg.com/@budibase/types/-/types-1.2.40.tgz#c1456728b61966cab7fe3689bd044bf415faa138" + integrity sha512-eNZFG0C/GBog87y6StKBjdF/aDJJtUHbAM8NWLUNNqTAiMxO2s3XhDN1dE6t74NBCRFzJo2sAD+34pJHhKFanQ== "@cspotcode/source-map-consumer@0.8.0": version "0.8.0" From 39188c6af4c7f2b5d385492ced798e2be7f8ea2b Mon Sep 17 00:00:00 2001 From: Andrew Kingston Date: Wed, 17 Aug 2022 09:21:36 +0100 Subject: [PATCH 044/203] Update vite config to work properly with all defaults --- packages/builder/vite.config.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/builder/vite.config.js b/packages/builder/vite.config.js index 20ff93831c..ad58b472dd 100644 --- a/packages/builder/vite.config.js +++ b/packages/builder/vite.config.js @@ -13,7 +13,7 @@ export default defineConfig(({ mode }) => { strict: false, }, hmr: { - protocol: "wss", + protocol: env.VITE_HMR_PROTOCOL || "ws", clientPort: env.VITE_HMR_CLIENT_PORT || 3000, path: env.VITE_HMR_PATH || "/", }, From 9a49f58a88f14dcb08b1c8b52c844abc43a207c6 Mon Sep 17 00:00:00 2001 From: mike12345567 Date: Wed, 17 Aug 2022 10:05:13 +0100 Subject: [PATCH 045/203] Adding full flow for creating custom datasource. --- .../modals/CreateDatasourceModal.svelte | 3 +++ .../modals/DatasourceConfigModal.svelte | 5 ++++- packages/server/src/integrations/index.ts | 16 ++++++++++++-- .../server/src/utilities/fileSystem/index.js | 22 +++++++++++++++++++ 4 files changed, 43 insertions(+), 3 deletions(-) diff --git a/packages/builder/src/components/backend/DatasourceNavigator/modals/CreateDatasourceModal.svelte b/packages/builder/src/components/backend/DatasourceNavigator/modals/CreateDatasourceModal.svelte index 2d5e6976bf..33953493f6 100644 --- a/packages/builder/src/components/backend/DatasourceNavigator/modals/CreateDatasourceModal.svelte +++ b/packages/builder/src/components/backend/DatasourceNavigator/modals/CreateDatasourceModal.svelte @@ -49,6 +49,9 @@ schema: selected.datasource, auth: selected.auth, } + if (selected.friendlyName) { + integration.name = selected.friendlyName + } checkShowImport() } diff --git a/packages/builder/src/components/backend/DatasourceNavigator/modals/DatasourceConfigModal.svelte b/packages/builder/src/components/backend/DatasourceNavigator/modals/DatasourceConfigModal.svelte index 0aaa2b201d..ecfd838b16 100644 --- a/packages/builder/src/components/backend/DatasourceNavigator/modals/DatasourceConfigModal.svelte +++ b/packages/builder/src/components/backend/DatasourceNavigator/modals/DatasourceConfigModal.svelte @@ -14,6 +14,9 @@ let datasource = cloneDeep(integration) let skipFetch = false + $: name = + IntegrationNames[datasource.type] || datasource.name || datasource.type + async function saveDatasource() { try { const resp = await save(datasource, skipFetch) @@ -32,7 +35,7 @@ saveDatasource()} onCancel={() => modal.show()} confirmText={datasource.plus diff --git a/packages/server/src/integrations/index.ts b/packages/server/src/integrations/index.ts index bf267e46cc..b9523061a4 100644 --- a/packages/server/src/integrations/index.ts +++ b/packages/server/src/integrations/index.ts @@ -15,6 +15,7 @@ import redis from "./redis" import snowflake from "./snowflake" import { getPlugins } from "../api/controllers/plugin" import { SourceName, Integration, PluginType } from "@budibase/types" +import { getDatasourcePlugin } from "../utilities/fileSystem" const environment = require("../environment") const { cloneDeep } = require("lodash") @@ -65,6 +66,8 @@ if (environment.SELF_HOSTED) { DEFINITIONS[SourceName.GOOGLE_SHEETS] = googlesheets.schema } +function isIntegrationAvailable(integration: string) {} + module.exports = { getDefinitions: async () => { const plugins = await getPlugins(PluginType.DATASOURCE) @@ -82,7 +85,16 @@ module.exports = { ...pluginSchemas, } }, - getIntegration: async () => { - return INTEGRATIONS + getIntegration: async (integration: string) => { + if (INTEGRATIONS[integration]) { + return INTEGRATIONS[integration] + } + const plugins = await getPlugins(PluginType.DATASOURCE) + for (let plugin of plugins) { + if (plugin.name === integration) { + // need to use commonJS require due to its dynamic runtime nature + return getDatasourcePlugin(plugin.name, plugin.jsUrl) + } + } }, } diff --git a/packages/server/src/utilities/fileSystem/index.js b/packages/server/src/utilities/fileSystem/index.js index 94c5a92375..9b124d6c29 100644 --- a/packages/server/src/utilities/fileSystem/index.js +++ b/packages/server/src/utilities/fileSystem/index.js @@ -26,9 +26,11 @@ const { const MemoryStream = require("memorystream") const { getAppId } = require("@budibase/backend-core/context") const tar = require("tar") +const fetch = require("node-fetch") const TOP_LEVEL_PATH = join(__dirname, "..", "..", "..") const NODE_MODULES_PATH = join(TOP_LEVEL_PATH, "node_modules") +const DATASOURCE_PATH = join(budibaseTempDir(), "datasource") /** * The single stack system (Cloud and Builder) should not make use of the file system where possible, @@ -348,6 +350,26 @@ exports.extractPluginTarball = async file => { return { metadata, directory: path } } +exports.getDatasourcePlugin = async (name, url) => { + if (!fs.existsSync(DATASOURCE_PATH)) { + fs.mkdirSync(DATASOURCE_PATH) + } + const filename = join(DATASOURCE_PATH, name) + if (fs.existsSync(filename)) { + return require(filename) + } + const response = fetch(url) + if (response.status === 200) { + const content = await response.text() + fs.writeFileSync(filename, content) + require(filename) + } else { + throw new Error( + `Unable to retrieve plugin - reason: ${await response.text()}` + ) + } +} + /** * Full function definition for below can be found in the utilities. */ From ecf1fbffa5578bc924156a2ab1945749287349f4 Mon Sep 17 00:00:00 2001 From: mike12345567 Date: Wed, 17 Aug 2022 10:46:17 +0100 Subject: [PATCH 046/203] Updating custom datasource SVG - splitting out in UI. --- .../_components/DatasourceCard.svelte | 73 +++++++++++++++++++ .../DatasourceNavigator/icons/Custom.svelte | 57 ++++++++------- .../modals/CreateDatasourceModal.svelte | 45 +++++------- 3 files changed, 122 insertions(+), 53 deletions(-) create mode 100644 packages/builder/src/components/backend/DatasourceNavigator/_components/DatasourceCard.svelte diff --git a/packages/builder/src/components/backend/DatasourceNavigator/_components/DatasourceCard.svelte b/packages/builder/src/components/backend/DatasourceNavigator/_components/DatasourceCard.svelte new file mode 100644 index 0000000000..2dac2fec79 --- /dev/null +++ b/packages/builder/src/components/backend/DatasourceNavigator/_components/DatasourceCard.svelte @@ -0,0 +1,73 @@ + + +
dispatcher("selected", integrationType)} + class="item hoverable" +> +
+ +
+ {schema.friendlyName} + {#if schema.type} + {schema.type || ""} + {/if} +
+
+
+ + diff --git a/packages/builder/src/components/backend/DatasourceNavigator/icons/Custom.svelte b/packages/builder/src/components/backend/DatasourceNavigator/icons/Custom.svelte index 354b7a3358..0d4b7219aa 100644 --- a/packages/builder/src/components/backend/DatasourceNavigator/icons/Custom.svelte +++ b/packages/builder/src/components/backend/DatasourceNavigator/icons/Custom.svelte @@ -1,8 +1,6 @@ - - - - - - + + + + + diff --git a/packages/builder/src/components/backend/DatasourceNavigator/modals/CreateDatasourceModal.svelte b/packages/builder/src/components/backend/DatasourceNavigator/modals/CreateDatasourceModal.svelte index 33953493f6..945cd574d8 100644 --- a/packages/builder/src/components/backend/DatasourceNavigator/modals/CreateDatasourceModal.svelte +++ b/packages/builder/src/components/backend/DatasourceNavigator/modals/CreateDatasourceModal.svelte @@ -18,6 +18,7 @@ import { createRestDatasource } from "builderStore/datasource" import { goto } from "@roxi/routify" import ImportRestQueriesModal from "./ImportRestQueriesModal.svelte" + import DatasourceCard from "../_components/DatasourceCard.svelte" export let modal let integrations = {} @@ -95,14 +96,6 @@ } integrations = newIntegrations } - - function getIcon(integrationType, schema) { - if (schema.custom) { - return ICONS.CUSTOM - } else { - return ICONS[integrationType] - } - } @@ -161,28 +154,24 @@ Connect to an external data source
- {#each Object.entries(integrations).filter(([key]) => key !== IntegrationTypes.INTERNAL) as [integrationType, schema]} -
selectIntegration(integrationType)} - class="item hoverable" - > -
- -
- {schema.friendlyName} - {#if schema.type} - {schema.type || ""} - {/if} -
-
-
+ {#each Object.entries(integrations).filter(([key, val]) => key !== IntegrationTypes.INTERNAL && !val.custom) as [integrationType, schema]} + selectIntegration(evt.detail)} + {schema} + bind:integrationType + {integration} + /> {/each}
+ Custom data source + {#each Object.entries(integrations).filter(entry => entry[1].custom) as [integrationType, schema]} + selectIntegration(evt.detail)} + {schema} + bind:integrationType + {integration} + /> + {/each}
From ffb4ba48e7b560d361919ad33f016ed26c97ed6e Mon Sep 17 00:00:00 2001 From: mike12345567 Date: Wed, 17 Aug 2022 11:01:25 +0100 Subject: [PATCH 047/203] Adding some controls around datasource config creation and updating minio fetch. --- .../DatasourceNavigator/modals/DatasourceConfigModal.svelte | 3 +++ packages/server/src/utilities/fileSystem/index.js | 3 ++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/packages/builder/src/components/backend/DatasourceNavigator/modals/DatasourceConfigModal.svelte b/packages/builder/src/components/backend/DatasourceNavigator/modals/DatasourceConfigModal.svelte index ecfd838b16..c8a5bc96eb 100644 --- a/packages/builder/src/components/backend/DatasourceNavigator/modals/DatasourceConfigModal.svelte +++ b/packages/builder/src/components/backend/DatasourceNavigator/modals/DatasourceConfigModal.svelte @@ -19,6 +19,9 @@ async function saveDatasource() { try { + if (!datasource.name) { + datasource.name = name + } const resp = await save(datasource, skipFetch) $goto(`./datasource/${resp._id}`) notifications.success(`Datasource updated successfully.`) diff --git a/packages/server/src/utilities/fileSystem/index.js b/packages/server/src/utilities/fileSystem/index.js index 9b124d6c29..d65ee48f05 100644 --- a/packages/server/src/utilities/fileSystem/index.js +++ b/packages/server/src/utilities/fileSystem/index.js @@ -17,6 +17,7 @@ const { downloadTarball, } = require("./utilities") const { updateClientLibrary } = require("./clientLibrary") +const { checkSlashesInUrl } = require("../") const env = require("../../environment") const { USER_METDATA_PREFIX, @@ -358,7 +359,7 @@ exports.getDatasourcePlugin = async (name, url) => { if (fs.existsSync(filename)) { return require(filename) } - const response = fetch(url) + const response = await fetch(checkSlashesInUrl(`${env.MINIO_URL}/${url}`)) if (response.status === 200) { const content = await response.text() fs.writeFileSync(filename, content) From 99c2a043b84f99047307b377ea66aba3ed0cec88 Mon Sep 17 00:00:00 2001 From: Mel O'Hagan Date: Wed, 17 Aug 2022 18:16:11 +0100 Subject: [PATCH 048/203] Allow list of named tables to be fetched --- .../PlusConfigForm.svelte | 19 ++++++++++++++++++- .../builder/src/stores/backend/datasources.js | 7 +++++-- packages/frontend-core/src/api/datasources.js | 6 +++++- .../server/src/api/controllers/datasource.js | 17 ++++++++++++++--- 4 files changed, 42 insertions(+), 7 deletions(-) diff --git a/packages/builder/src/components/backend/DatasourceNavigator/TableIntegrationMenu/PlusConfigForm.svelte b/packages/builder/src/components/backend/DatasourceNavigator/TableIntegrationMenu/PlusConfigForm.svelte index cd19523476..b81e818d5f 100644 --- a/packages/builder/src/components/backend/DatasourceNavigator/TableIntegrationMenu/PlusConfigForm.svelte +++ b/packages/builder/src/components/backend/DatasourceNavigator/TableIntegrationMenu/PlusConfigForm.svelte @@ -8,6 +8,7 @@ notifications, Modal, Table, + Toggle, } from "@budibase/bbui" import { datasources, integrations, tables } from "stores/backend" import CreateEditRelationship from "components/backend/Datasources/CreateEditRelationship.svelte" @@ -15,6 +16,7 @@ import ArrayRenderer from "components/common/renderers/ArrayRenderer.svelte" import ConfirmDialog from "components/common/ConfirmDialog.svelte" import { goto } from "@roxi/routify" + import ValuesList from "components/common/ValuesList.svelte" export let datasource export let save @@ -31,6 +33,8 @@ let createExternalTableModal let selectedFromRelationship, selectedToRelationship let confirmDialog + let specificTables = null + let requireSpecificTables = false $: integration = datasource && $integrations[datasource.source] $: plusTables = datasource?.plus @@ -87,7 +91,7 @@ async function updateDatasourceSchema() { try { - await datasources.updateSchema(datasource) + await datasources.updateSchema(datasource, specificTables) notifications.success(`Datasource ${name} tables updated successfully.`) await tables.fetch() } catch (error) { @@ -150,6 +154,19 @@ warning={false} title="Confirm table fetch" > + { + requireSpecificTables = e.detail + specificTables = null + }} + thin + text="Fetch listed tables only (one per line)" + /> + {#if requireSpecificTables} + + {/if} +
If you have fetched tables from this database before, this action may overwrite any changes you made after your initial fetch. diff --git a/packages/builder/src/stores/backend/datasources.js b/packages/builder/src/stores/backend/datasources.js index 2423394c6a..07aeab1921 100644 --- a/packages/builder/src/stores/backend/datasources.js +++ b/packages/builder/src/stores/backend/datasources.js @@ -62,8 +62,11 @@ export function createDatasourcesStore() { unselect: () => { update(state => ({ ...state, selected: null })) }, - updateSchema: async datasource => { - const response = await API.buildDatasourceSchema(datasource?._id) + updateSchema: async (datasource, tablesFilter) => { + const response = await API.buildDatasourceSchema({ + datasourceId: datasource?._id, + tablesFilter, + }) return await updateDatasource(response) }, save: async (body, fetchSchema = false) => { diff --git a/packages/frontend-core/src/api/datasources.js b/packages/frontend-core/src/api/datasources.js index ff72fbf25b..eda7b3c860 100644 --- a/packages/frontend-core/src/api/datasources.js +++ b/packages/frontend-core/src/api/datasources.js @@ -11,10 +11,14 @@ export const buildDatasourceEndpoints = API => ({ /** * Prompts the server to build the schema for a datasource. * @param datasourceId the datasource ID to build the schema for + * @param tablesFilter list of specific table names to be build the schema */ - buildDatasourceSchema: async datasourceId => { + buildDatasourceSchema: async ({ datasourceId, tablesFilter }) => { return await API.post({ url: `/api/datasources/${datasourceId}/schema`, + body: { + tablesFilter, + }, }) }, diff --git a/packages/server/src/api/controllers/datasource.js b/packages/server/src/api/controllers/datasource.js index 8b9b765a5f..75fd1db02a 100644 --- a/packages/server/src/api/controllers/datasource.js +++ b/packages/server/src/api/controllers/datasource.js @@ -50,9 +50,21 @@ exports.fetch = async function (ctx) { exports.buildSchemaFromDb = async function (ctx) { const db = getAppDB() const datasource = await db.get(ctx.params.datasourceId) + const tablesFilter = ctx.request.body.tablesFilter - const { tables, error } = await buildSchemaHelper(datasource) - datasource.entities = tables + let { tables, error } = await buildSchemaHelper(datasource) + if (tablesFilter) { + if (!datasource.entities) { + datasource.entities = {} + } + for (let key in tables) { + if (tablesFilter.includes(key)) { + datasource.entities[key] = tables[key] + } + } + } else { + datasource.entities = tables + } const dbResp = await db.put(datasource) datasource._rev = dbResp.rev @@ -223,7 +235,6 @@ const buildSchemaHelper = async datasource => { // Connect to the DB and build the schema const connector = new Connector(datasource.config) await connector.buildSchema(datasource._id, datasource.entities) - datasource.entities = connector.tables // make sure they all have a display name selected for (let entity of Object.values(datasource.entities)) { From 0db9a4ec6ee37ddeff7065d466d23e61597923ae Mon Sep 17 00:00:00 2001 From: mike12345567 Date: Wed, 17 Aug 2022 23:13:51 +0100 Subject: [PATCH 049/203] Adding full builder integration of custom components - splitting into own section properly - fixing some issues with SVG class overlap. --- .../builder/src/builderStore/datasource.js | 2 +- .../DatasourceNavigator.svelte | 4 ++-- .../_components/DatasourceCard.svelte | 10 +--------- .../DatasourceNavigator/icons/Custom.svelte | 18 ++++++++++++------ .../backend/DatasourceNavigator/icons/index.js | 12 +++++++++++- .../app/[application]/data/_layout.svelte | 4 +++- .../server/src/utilities/fileSystem/index.js | 5 ++++- 7 files changed, 34 insertions(+), 21 deletions(-) diff --git a/packages/builder/src/builderStore/datasource.js b/packages/builder/src/builderStore/datasource.js index 804d88bad6..84edcdd6ad 100644 --- a/packages/builder/src/builderStore/datasource.js +++ b/packages/builder/src/builderStore/datasource.js @@ -9,7 +9,7 @@ function prepareData(config) { ds => ds.source === config.type ).length - let baseName = IntegrationNames[config.type] + let baseName = IntegrationNames[config.type] || config.name let name = existingTypeCount === 0 ? baseName : `${baseName}-${existingTypeCount + 1}` diff --git a/packages/builder/src/components/backend/DatasourceNavigator/DatasourceNavigator.svelte b/packages/builder/src/components/backend/DatasourceNavigator/DatasourceNavigator.svelte index 9faf00a199..6235e52916 100644 --- a/packages/builder/src/components/backend/DatasourceNavigator/DatasourceNavigator.svelte +++ b/packages/builder/src/components/backend/DatasourceNavigator/DatasourceNavigator.svelte @@ -13,7 +13,7 @@ customQueryIconColor, customQueryText, } from "helpers/data/utils" - import ICONS from "./icons" + import { getIcon } from "./icons" import { notifications } from "@budibase/bbui" let openDataSources = [] @@ -124,7 +124,7 @@ >
diff --git a/packages/builder/src/components/backend/DatasourceNavigator/_components/DatasourceCard.svelte b/packages/builder/src/components/backend/DatasourceNavigator/_components/DatasourceCard.svelte index 2dac2fec79..6dffc70a63 100644 --- a/packages/builder/src/components/backend/DatasourceNavigator/_components/DatasourceCard.svelte +++ b/packages/builder/src/components/backend/DatasourceNavigator/_components/DatasourceCard.svelte @@ -1,21 +1,13 @@
- + - + {#if modal} + + {/if}
diff --git a/packages/server/src/utilities/fileSystem/index.js b/packages/server/src/utilities/fileSystem/index.js index d65ee48f05..f937f172b5 100644 --- a/packages/server/src/utilities/fileSystem/index.js +++ b/packages/server/src/utilities/fileSystem/index.js @@ -359,7 +359,10 @@ exports.getDatasourcePlugin = async (name, url) => { if (fs.existsSync(filename)) { return require(filename) } - const response = await fetch(checkSlashesInUrl(`${env.MINIO_URL}/${url}`)) + const fullUrl = checkSlashesInUrl( + `${env.MINIO_URL}/${ObjectStoreBuckets.PLUGINS}/${url}` + ) + const response = await fetch(fullUrl) if (response.status === 200) { const content = await response.text() fs.writeFileSync(filename, content) From ebb622097b173800a5428ff7576c8cf7c2dcc8e7 Mon Sep 17 00:00:00 2001 From: mike12345567 Date: Wed, 17 Aug 2022 23:17:10 +0100 Subject: [PATCH 050/203] Fixing issue with single custom datasource being full width in creation modal. --- .../modals/CreateDatasourceModal.svelte | 20 ++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/packages/builder/src/components/backend/DatasourceNavigator/modals/CreateDatasourceModal.svelte b/packages/builder/src/components/backend/DatasourceNavigator/modals/CreateDatasourceModal.svelte index 945cd574d8..a500c6a5b3 100644 --- a/packages/builder/src/components/backend/DatasourceNavigator/modals/CreateDatasourceModal.svelte +++ b/packages/builder/src/components/backend/DatasourceNavigator/modals/CreateDatasourceModal.svelte @@ -164,14 +164,16 @@ {/each}
Custom data source - {#each Object.entries(integrations).filter(entry => entry[1].custom) as [integrationType, schema]} - selectIntegration(evt.detail)} - {schema} - bind:integrationType - {integration} - /> - {/each} +
+ {#each Object.entries(integrations).filter(entry => entry[1].custom) as [integrationType, schema]} + selectIntegration(evt.detail)} + {schema} + bind:integrationType + {integration} + /> + {/each} +
@@ -179,7 +181,7 @@ diff --git a/packages/builder/src/pages/builder/portal/manage/plugins/_components/PluginRow.svelte b/packages/builder/src/pages/builder/portal/manage/plugins/_components/PluginRow.svelte new file mode 100644 index 0000000000..3a92a699e6 --- /dev/null +++ b/packages/builder/src/pages/builder/portal/manage/plugins/_components/PluginRow.svelte @@ -0,0 +1,81 @@ + + +
+
+
+
+ +
+
+ + {plugin.name} + + +
{plugin.schema.type}
+
+
+
+
+
{plugin.source || "-"}
+
{plugin.author || "-"}
+
{plugin.version}
+ +
+
+ + + + + plugins.deletePlugin(plugin._id, plugin._rev)} + icon="Delete">Delete + editGroup(plugin)} icon="Edit">Edit + +
+
+
+ + diff --git a/packages/builder/src/pages/builder/portal/manage/plugins/index.svelte b/packages/builder/src/pages/builder/portal/manage/plugins/index.svelte new file mode 100644 index 0000000000..61227786b0 --- /dev/null +++ b/packages/builder/src/pages/builder/portal/manage/plugins/index.svelte @@ -0,0 +1,94 @@ + + + + +
+ Plugins +
+ Add your own custom datasources and components + +
+ +
+
+ +
+
+
+ @@ -61,7 +98,7 @@
- +
{#each authOptions[sourceValue] as option} {#if option === "Upload"} @@ -82,7 +119,7 @@ {:else}
- +
{/if} {/each} diff --git a/packages/builder/src/stores/portal/plugins.js b/packages/builder/src/stores/portal/plugins.js index 6a1d7cc2cb..531ac1c396 100644 --- a/packages/builder/src/stores/portal/plugins.js +++ b/packages/builder/src/stores/portal/plugins.js @@ -17,6 +17,41 @@ export function createPluginsStore() { }) } + async function createPlugin(type, source, name, url, auth) { + let pluginData = { + type, + source, + name, + url, + } + + switch (source) { + case "github": + pluginData.githubToken = auth + break + case "url": + pluginData.header = auth + break + case "npm": + pluginData.npmToken = auth + break + } + + let resp = await API.createPlugin(pluginData) + console.log(resp) + // TODO_RIC + // let newPlugin = resp.plugins[0] + // update(state => { + // const currentIdx = state.findIndex(plugin => plugin._id === newPlugin._id) + // if (currentIdx >= 0) { + // state.splice(currentIdx, 1, newPlugin) + // } else { + // state.push(newPlugin) + // } + // return state + // }) + } + async function uploadPlugin(file, source) { let data = new FormData() data.append("file", file) @@ -35,6 +70,7 @@ export function createPluginsStore() { return { subscribe, load, + createPlugin, deletePlugin, uploadPlugin, } diff --git a/packages/frontend-core/src/api/plugins.js b/packages/frontend-core/src/api/plugins.js index 108e1b50a7..484cf763bb 100644 --- a/packages/frontend-core/src/api/plugins.js +++ b/packages/frontend-core/src/api/plugins.js @@ -11,6 +11,16 @@ export const buildPluginEndpoints = API => ({ }) }, + /** + * Creates a plugin from URL, Github or NPM + */ + createPlugin: async data => { + return await API.post({ + url: `/api/plugin`, + body: data, + }) + }, + /** * Gets a list of all plugins */ diff --git a/packages/server/src/api/controllers/plugin.ts b/packages/server/src/api/controllers/plugin.ts index e8a2dd1746..b6d3d31354 100644 --- a/packages/server/src/api/controllers/plugin.ts +++ b/packages/server/src/api/controllers/plugin.ts @@ -1,5 +1,9 @@ import { ObjectStoreBuckets } from "../../constants" -import { extractPluginTarball } from "../../utilities/fileSystem" +import { + extractPluginTarball, + npmPlugin, + getPluginMetadata, +} from "../../utilities/fileSystem" import { getGlobalDB } from "@budibase/backend-core/tenancy" import { generatePluginID, getPluginParams } from "../../db/utils" import { uploadDirectory } from "@budibase/backend-core/objectStore" @@ -39,10 +43,48 @@ export async function upload(ctx: any) { } } catch (err: any) { const errMsg = err?.message ? err?.message : err + ctx.throw(400, `Failed to import plugin: ${errMsg}`) } } +export async function create(ctx: any) { + const { type, source, name, url, header, githubToken, npmToken } = + ctx.request.body + let metadata + let directory + + switch (source) { + case "npm": + // const { metadata: metadataNpm, directory: directoryNpm } = await npmPlugin(url, name) + // metadata = metadataNpm + // directory = directoryNpm + + console.log(22222, await getPluginMetadata(await npmPlugin(url, name))) + break + case "github": + console.log("github") + break + case "url": + console.log("url") + break + } + + // try { + // const doc = storePlugin(metadata, directory, source) + // + // ctx.body = { + // message: "Plugin uploaded successfully", + // plugins: doc, + // } + // } catch (err: any) { + // const errMsg = err?.message ? err?.message : err + // + // ctx.throw(400, `Failed to import plugin: ${errMsg}`) + // } + ctx.status = 200 +} + export async function fetch(ctx: any) { ctx.body = await getPlugins() } @@ -54,9 +96,12 @@ export async function destroy(ctx: any) { ctx.status = 200 } -export async function processPlugin(plugin: FileType, source?: string) { +export async function storePlugin( + metadata: any, + directory: any, + source?: string +) { const db = getGlobalDB() - const { metadata, directory } = await extractPluginTarball(plugin) const version = metadata.package.version, name = metadata.package.name, description = metadata.package.description @@ -99,3 +144,8 @@ export async function processPlugin(plugin: FileType, source?: string) { _rev: response.rev, } } + +export async function processPlugin(plugin: FileType, source?: string) { + const { metadata, directory } = await extractPluginTarball(plugin) + return await storePlugin(metadata, directory, source) +} diff --git a/packages/server/src/api/routes/plugin.ts b/packages/server/src/api/routes/plugin.ts index 1ca49cf300..2508115a29 100644 --- a/packages/server/src/api/routes/plugin.ts +++ b/packages/server/src/api/routes/plugin.ts @@ -7,6 +7,7 @@ const router = new Router() router .post("/api/plugin/upload/:source", authorized(BUILDER), controller.upload) + .post("/api/plugin", authorized(BUILDER), controller.create) .get("/api/plugin", authorized(BUILDER), controller.fetch) .delete( "/api/plugin/:pluginId/:pluginRev", diff --git a/packages/server/src/utilities/fileSystem/index.js b/packages/server/src/utilities/fileSystem/index.js index 821e905fbc..9c70edf8a6 100644 --- a/packages/server/src/utilities/fileSystem/index.js +++ b/packages/server/src/utilities/fileSystem/index.js @@ -1,6 +1,9 @@ const { budibaseTempDir } = require("../budibaseDir") const fs = require("fs") const { join } = require("path") +// const { promisify } = require("util") +// const exec = promisify(require("child_process").exec) +// const streamPipeline = promisify(require("stream")) const uuid = require("uuid/v4") const { doWithDB, @@ -29,6 +32,7 @@ const MemoryStream = require("memorystream") const { getAppId } = require("@budibase/backend-core/context") const tar = require("tar") const fetch = require("node-fetch") +// const fileType = require("file-type") const TOP_LEVEL_PATH = join(__dirname, "..", "..", "..") const NODE_MODULES_PATH = join(TOP_LEVEL_PATH, "node_modules") @@ -326,11 +330,11 @@ exports.cleanup = appIds => { } } -exports.extractPluginTarball = async file => { - if (!file.name.endsWith(".tar.gz")) { +const extractPluginTarball = async (file, ext = ".tar.gz") => { + if (!file.name.endsWith(ext)) { throw new Error("Plugin must be compressed into a gzipped tarball.") } - const path = join(budibaseTempDir(), file.name.split(".tar.gz")[0]) + const path = join(budibaseTempDir(), file.name.split(ext)[0]) // remove old tmp directories automatically - don't combine if (fs.existsSync(path)) { fs.rmSync(path, { recursive: true, force: true }) @@ -340,6 +344,63 @@ exports.extractPluginTarball = async file => { file: file.path, C: path, }) + + return await getPluginMetadata(path) +} +exports.extractPluginTarball = extractPluginTarball + +exports.npmPlugin = async (url, name = "") => { + let npmTarball = url + let filename = name + let path = join(budibaseTempDir(), name) + + if (!npmTarball.includes(".tgz")) { + const npmPackageURl = url.replace( + "https://www.npmjs.com/package/", + "https://registry.npmjs.org/" + ) + const response = await fetch(npmPackageURl) + if (response.status === 200) { + let npmDetails = await response.json() + filename = npmDetails.name + path = join(budibaseTempDir(), filename) + const npmVersion = npmDetails["dist-tags"].latest + npmTarball = npmDetails.versions[npmVersion].dist.tarball + } else { + throw "Cannot get package details" + } + } + + try { + if (fs.existsSync(path)) { + fs.rmSync(path, { recursive: true, force: true }) + } + fs.mkdirSync(path) + + const response = await fetch(npmTarball) + if (!response.ok) + throw new Error(`Loading NPM plugin failed ${response.statusText}`) + + // const dest = fs.createWriteStream(`${path}/${filename}.tgz`) + await response.body.pipe( + await tar.x({ + strip: 1, + C: path, + }) + ) + + // const readStream = fs.createReadStream(`${path}/${filename}.tgz`) + // readStream.pipe( + + // ) + } catch (e) { + throw `Cannot store package locally: ${e.message}` + } + + return path +} + +const getPluginMetadata = async path => { let metadata = {} try { const pkg = fs.readFileSync(join(path, "package.json"), "utf8") @@ -349,8 +410,10 @@ exports.extractPluginTarball = async file => { } catch (err) { throw new Error("Unable to process schema.json/package.json in plugin.") } + return { metadata, directory: path } } +exports.getPluginMetadata = getPluginMetadata exports.getDatasourcePlugin = async (name, url, hash) => { if (!fs.existsSync(DATASOURCE_PATH)) { From ac33190ff0c4104d1214f0856acc6ad657d184e7 Mon Sep 17 00:00:00 2001 From: NEOLPAR Date: Wed, 31 Aug 2022 16:09:47 +0100 Subject: [PATCH 066/203] uploading npm and url plugins --- .../plugins/_components/AddPluginModal.svelte | 16 ++---- packages/builder/src/stores/portal/plugins.js | 11 ++--- packages/server/src/api/controllers/plugin.ts | 45 ++++++++--------- .../server/src/utilities/fileSystem/index.js | 49 +++++++++++-------- 4 files changed, 60 insertions(+), 61 deletions(-) diff --git a/packages/builder/src/pages/builder/portal/manage/plugins/_components/AddPluginModal.svelte b/packages/builder/src/pages/builder/portal/manage/plugins/_components/AddPluginModal.svelte index e45655d20d..1fce6746ad 100644 --- a/packages/builder/src/pages/builder/portal/manage/plugins/_components/AddPluginModal.svelte +++ b/packages/builder/src/pages/builder/portal/manage/plugins/_components/AddPluginModal.svelte @@ -11,10 +11,10 @@ import { plugins } from "stores/portal" let authOptions = { - NPM: ["NPM Token", "URL"], + NPM: ["URL"], Github: ["Github Token", "URL"], - URL: ["Header", "URL"], - File: ["Path", "Header"], + URL: ["Headers", "URL"], + File: ["Path", "Headers"], Upload: ["Upload"], } let file @@ -50,17 +50,11 @@ source, nameValue, url, - dynamicValues["Header"] + dynamicValues["Headers"] ) break case "npm": - await plugins.createPlugin( - typeValue, - source, - nameValue, - url, - dynamicValues["NPM Token"] - ) + await plugins.createPlugin(typeValue, source, nameValue, url) break } } diff --git a/packages/builder/src/stores/portal/plugins.js b/packages/builder/src/stores/portal/plugins.js index 531ac1c396..4e3d952fe3 100644 --- a/packages/builder/src/stores/portal/plugins.js +++ b/packages/builder/src/stores/portal/plugins.js @@ -17,7 +17,7 @@ export function createPluginsStore() { }) } - async function createPlugin(type, source, name, url, auth) { + async function createPlugin(type, source, name, url, auth = null) { let pluginData = { type, source, @@ -26,19 +26,16 @@ export function createPluginsStore() { } switch (source) { - case "github": - pluginData.githubToken = auth - break case "url": - pluginData.header = auth + pluginData.headers = auth break case "npm": pluginData.npmToken = auth break } - let resp = await API.createPlugin(pluginData) - console.log(resp) + let res = await API.createPlugin(pluginData) + console.log("RESP", res) // TODO_RIC // let newPlugin = resp.plugins[0] // update(state => { diff --git a/packages/server/src/api/controllers/plugin.ts b/packages/server/src/api/controllers/plugin.ts index b6d3d31354..dc70ea8b62 100644 --- a/packages/server/src/api/controllers/plugin.ts +++ b/packages/server/src/api/controllers/plugin.ts @@ -1,8 +1,8 @@ import { ObjectStoreBuckets } from "../../constants" import { extractPluginTarball, - npmPlugin, - getPluginMetadata, + createNpmPlugin, + createUrlPlugin, } from "../../utilities/fileSystem" import { getGlobalDB } from "@budibase/backend-core/tenancy" import { generatePluginID, getPluginParams } from "../../db/utils" @@ -49,39 +49,40 @@ export async function upload(ctx: any) { } export async function create(ctx: any) { - const { type, source, name, url, header, githubToken, npmToken } = - ctx.request.body + const { type, source, name, url, headers, githubToken } = ctx.request.body let metadata let directory switch (source) { case "npm": - // const { metadata: metadataNpm, directory: directoryNpm } = await npmPlugin(url, name) - // metadata = metadataNpm - // directory = directoryNpm - - console.log(22222, await getPluginMetadata(await npmPlugin(url, name))) + const { metadata: metadataNpm, directory: directoryNpm } = + await createNpmPlugin(url, name) + metadata = metadataNpm + directory = directoryNpm break case "github": console.log("github") break case "url": - console.log("url") + const { metadata: metadataUrl, directory: directoryUrl } = + await createUrlPlugin(url, name, headers) + metadata = metadataUrl + directory = directoryUrl break } - // try { - // const doc = storePlugin(metadata, directory, source) - // - // ctx.body = { - // message: "Plugin uploaded successfully", - // plugins: doc, - // } - // } catch (err: any) { - // const errMsg = err?.message ? err?.message : err - // - // ctx.throw(400, `Failed to import plugin: ${errMsg}`) - // } + try { + const doc = storePlugin(metadata, directory, source) + + ctx.body = { + message: "Plugin uploaded successfully", + plugins: doc, + } + } catch (err: any) { + const errMsg = err?.message ? err?.message : err + + ctx.throw(400, `Failed to import plugin: ${errMsg}`) + } ctx.status = 200 } diff --git a/packages/server/src/utilities/fileSystem/index.js b/packages/server/src/utilities/fileSystem/index.js index 9c70edf8a6..710e3c0294 100644 --- a/packages/server/src/utilities/fileSystem/index.js +++ b/packages/server/src/utilities/fileSystem/index.js @@ -1,9 +1,8 @@ const { budibaseTempDir } = require("../budibaseDir") const fs = require("fs") const { join } = require("path") -// const { promisify } = require("util") -// const exec = promisify(require("child_process").exec) -// const streamPipeline = promisify(require("stream")) +const { promisify } = require("util") +const streamPipeline = promisify(require("stream").pipeline) const uuid = require("uuid/v4") const { doWithDB, @@ -32,7 +31,6 @@ const MemoryStream = require("memorystream") const { getAppId } = require("@budibase/backend-core/context") const tar = require("tar") const fetch = require("node-fetch") -// const fileType = require("file-type") const TOP_LEVEL_PATH = join(__dirname, "..", "..", "..") const NODE_MODULES_PATH = join(TOP_LEVEL_PATH, "node_modules") @@ -349,10 +347,9 @@ const extractPluginTarball = async (file, ext = ".tar.gz") => { } exports.extractPluginTarball = extractPluginTarball -exports.npmPlugin = async (url, name = "") => { +exports.createNpmPlugin = async (url, name = "") => { let npmTarball = url - let filename = name - let path = join(budibaseTempDir(), name) + let pluginName = name if (!npmTarball.includes(".tgz")) { const npmPackageURl = url.replace( @@ -362,8 +359,7 @@ exports.npmPlugin = async (url, name = "") => { const response = await fetch(npmPackageURl) if (response.status === 200) { let npmDetails = await response.json() - filename = npmDetails.name - path = join(budibaseTempDir(), filename) + pluginName = npmDetails.name const npmVersion = npmDetails["dist-tags"].latest npmTarball = npmDetails.versions[npmVersion].dist.tarball } else { @@ -371,36 +367,47 @@ exports.npmPlugin = async (url, name = "") => { } } + return await downloadUnzipPlugin(pluginName, npmTarball) +} + +exports.createUrlPlugin = async (url, name = "", headers = {}) => { + if (!url.includes(".tgz") && !url.includes(".tar.gz")) { + throw new Error("Plugin must be compressed into a gzipped tarball.") + } + + return await downloadUnzipPlugin(name, url, headers) +} + +const downloadUnzipPlugin = async (name, url, headers = {}) => { + console.log(name, url, headers) + const path = join(budibaseTempDir(), name) try { + // Remove first if exists if (fs.existsSync(path)) { fs.rmSync(path, { recursive: true, force: true }) } fs.mkdirSync(path) - const response = await fetch(npmTarball) + const response = await fetch(url, { headers }) if (!response.ok) throw new Error(`Loading NPM plugin failed ${response.statusText}`) - // const dest = fs.createWriteStream(`${path}/${filename}.tgz`) - await response.body.pipe( - await tar.x({ + await streamPipeline( + response.body, + tar.x({ strip: 1, C: path, }) ) - - // const readStream = fs.createReadStream(`${path}/${filename}.tgz`) - // readStream.pipe( - - // ) + return await getPluginMetadata(path) } catch (e) { - throw `Cannot store package locally: ${e.message}` + throw `Cannot store plugin locally: ${e.message}` } - - return path } +exports.downloadUnzipPlugin = downloadUnzipPlugin const getPluginMetadata = async path => { + console.log(path) let metadata = {} try { const pkg = fs.readFileSync(join(path, "package.json"), "utf8") From 1c67772973d4faadbc8c2c552d601c11ea52acef Mon Sep 17 00:00:00 2001 From: NEOLPAR Date: Wed, 31 Aug 2022 17:53:00 +0100 Subject: [PATCH 067/203] plugins npm and url working --- packages/builder/src/stores/portal/plugins.js | 22 +++++++++---------- packages/server/src/api/controllers/plugin.ts | 4 ++-- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/packages/builder/src/stores/portal/plugins.js b/packages/builder/src/stores/portal/plugins.js index 4e3d952fe3..a498bf663a 100644 --- a/packages/builder/src/stores/portal/plugins.js +++ b/packages/builder/src/stores/portal/plugins.js @@ -36,17 +36,17 @@ export function createPluginsStore() { let res = await API.createPlugin(pluginData) console.log("RESP", res) - // TODO_RIC - // let newPlugin = resp.plugins[0] - // update(state => { - // const currentIdx = state.findIndex(plugin => plugin._id === newPlugin._id) - // if (currentIdx >= 0) { - // state.splice(currentIdx, 1, newPlugin) - // } else { - // state.push(newPlugin) - // } - // return state - // }) + + let newPlugin = res.plugins[0] + update(state => { + const currentIdx = state.findIndex(plugin => plugin._id === newPlugin._id) + if (currentIdx >= 0) { + state.splice(currentIdx, 1, newPlugin) + } else { + state.push(newPlugin) + } + return state + }) } async function uploadPlugin(file, source) { diff --git a/packages/server/src/api/controllers/plugin.ts b/packages/server/src/api/controllers/plugin.ts index dc70ea8b62..26caf38806 100644 --- a/packages/server/src/api/controllers/plugin.ts +++ b/packages/server/src/api/controllers/plugin.ts @@ -72,11 +72,11 @@ export async function create(ctx: any) { } try { - const doc = storePlugin(metadata, directory, source) + const doc = await storePlugin(metadata, directory, source) ctx.body = { message: "Plugin uploaded successfully", - plugins: doc, + plugins: [doc], } } catch (err: any) { const errMsg = err?.message ? err?.message : err From 4a71252731f30a4912355659c242c14d0fe0fc13 Mon Sep 17 00:00:00 2001 From: mike12345567 Date: Wed, 31 Aug 2022 19:21:45 +0100 Subject: [PATCH 068/203] Updating test cases to TS to get them working properly with the full TS implementations. --- packages/server/__mocks__/mongodb.ts | 2 +- packages/server/src/api/controllers/screen.js | 2 +- .../{airtable.spec.js => airtable.spec.ts} | 39 +- .../{arangodb.spec.js => arangodb.spec.ts} | 21 +- .../{couchdb.spec.js => couchdb.spec.ts} | 60 +-- .../{dynamodb.spec.js => dynamodb.spec.ts} | 86 ++-- ...icsearch.spec.js => elasticsearch.spec.ts} | 43 +- .../{firebase.spec.js => firebase.spec.ts} | 61 +-- ...ver.spec.js => microsoftSqlServer.spec.ts} | 23 +- .../tests/{mongo.spec.js => mongo.spec.ts} | 81 ++-- .../tests/{mysql.spec.js => mysql.spec.ts} | 32 +- .../tests/{oracle.spec.js => oracle.spec.ts} | 36 +- .../{postgres.spec.js => postgres.spec.ts} | 36 +- .../tests/{redis.spec.js => redis.spec.ts} | 33 +- .../tests/{rest.spec.js => rest.spec.ts} | 30 +- .../tests/{s3.spec.js => s3.spec.ts} | 18 +- .../tests/{sql.spec.js => sql.spec.ts} | 405 ++++++++++-------- 17 files changed, 558 insertions(+), 450 deletions(-) rename packages/server/src/integrations/tests/{airtable.spec.js => airtable.spec.ts} (75%) rename packages/server/src/integrations/tests/{arangodb.spec.js => arangodb.spec.ts} (75%) rename packages/server/src/integrations/tests/{couchdb.spec.js => couchdb.spec.ts} (58%) rename packages/server/src/integrations/tests/{dynamodb.spec.js => dynamodb.spec.ts} (68%) rename packages/server/src/integrations/tests/{elasticsearch.spec.js => elasticsearch.spec.ts} (72%) rename packages/server/src/integrations/tests/{firebase.spec.js => firebase.spec.ts} (70%) rename packages/server/src/integrations/tests/{microsoftSqlServer.spec.js => microsoftSqlServer.spec.ts} (75%) rename packages/server/src/integrations/tests/{mongo.spec.js => mongo.spec.ts} (90%) rename packages/server/src/integrations/tests/{mysql.spec.js => mysql.spec.ts} (80%) rename packages/server/src/integrations/tests/{oracle.spec.js => oracle.spec.ts} (83%) rename packages/server/src/integrations/tests/{postgres.spec.js => postgres.spec.ts} (78%) rename packages/server/src/integrations/tests/{redis.spec.js => redis.spec.ts} (71%) rename packages/server/src/integrations/tests/{rest.spec.js => rest.spec.ts} (96%) rename packages/server/src/integrations/tests/{s3.spec.js => s3.spec.ts} (55%) rename packages/server/src/integrations/tests/{sql.spec.js => sql.spec.ts} (60%) diff --git a/packages/server/__mocks__/mongodb.ts b/packages/server/__mocks__/mongodb.ts index 92ec89227f..4a1867f6f9 100644 --- a/packages/server/__mocks__/mongodb.ts +++ b/packages/server/__mocks__/mongodb.ts @@ -33,7 +33,7 @@ module MongoMock { }) } - mongodb.ObjectID = require("mongodb").ObjectID + mongodb.ObjectID = jest.requireActual("mongodb").ObjectID module.exports = mongodb } diff --git a/packages/server/src/api/controllers/screen.js b/packages/server/src/api/controllers/screen.js index 99d12d064c..07b15dd8a1 100644 --- a/packages/server/src/api/controllers/screen.js +++ b/packages/server/src/api/controllers/screen.js @@ -8,7 +8,7 @@ const { AccessController } = require("@budibase/backend-core/roles") const { getAppDB } = require("@budibase/backend-core/context") const { events } = require("@budibase/backend-core") const { getGlobalDB } = require("@budibase/backend-core/tenancy") -import { updateAppPackage } from "./application" +const { updateAppPackage } = require("./application") exports.fetch = async ctx => { const db = getAppDB() diff --git a/packages/server/src/integrations/tests/airtable.spec.js b/packages/server/src/integrations/tests/airtable.spec.ts similarity index 75% rename from packages/server/src/integrations/tests/airtable.spec.js rename to packages/server/src/integrations/tests/airtable.spec.ts index df676a1397..26a389456f 100644 --- a/packages/server/src/integrations/tests/airtable.spec.js +++ b/packages/server/src/integrations/tests/airtable.spec.ts @@ -1,10 +1,12 @@ -const Airtable = require("airtable") -const AirtableIntegration = require("../airtable") +import { default as AirtableIntegration } from "../airtable" jest.mock("airtable") class TestConfiguration { - constructor(config = {}) { - this.integration = new AirtableIntegration.integration(config) + integration: any + client: any + + constructor(config: any = {}) { + this.integration = new AirtableIntegration.integration(config) this.client = { create: jest.fn(), select: jest.fn(() => ({ @@ -13,12 +15,12 @@ class TestConfiguration { update: jest.fn(), destroy: jest.fn(), } - this.integration.client = () => this.client + this.integration.client = () => this.client } } describe("Airtable Integration", () => { - let config + let config: any beforeEach(() => { config = new TestConfiguration() @@ -27,22 +29,23 @@ describe("Airtable Integration", () => { it("calls the create method with the correct params", async () => { const response = await config.integration.create({ table: "test", - json: {} + json: {}, }) expect(config.client.create).toHaveBeenCalledWith([ { - fields: {} - } + fields: {}, + }, ]) }) it("calls the read method with the correct params", async () => { const response = await config.integration.read({ table: "test", - view: "Grid view" + view: "Grid view", }) expect(config.client.select).toHaveBeenCalledWith({ - maxRecords: 10, view: "Grid view" + maxRecords: 10, + view: "Grid view", }) }) @@ -51,22 +54,22 @@ describe("Airtable Integration", () => { table: "table", id: "123", json: { - name: "test" - } + name: "test", + }, }) expect(config.client.update).toHaveBeenCalledWith([ { id: "123", - fields: { name: "test" } - } + fields: { name: "test" }, + }, ]) }) it("calls the delete method with the correct params", async () => { - const ids = [1,2,3,4] + const ids = [1, 2, 3, 4] const response = await config.integration.delete({ - ids + ids, }) expect(config.client.destroy).toHaveBeenCalledWith(ids) }) -}) \ No newline at end of file +}) diff --git a/packages/server/src/integrations/tests/arangodb.spec.js b/packages/server/src/integrations/tests/arangodb.spec.ts similarity index 75% rename from packages/server/src/integrations/tests/arangodb.spec.js rename to packages/server/src/integrations/tests/arangodb.spec.ts index 437a7fd3ec..401b2ec707 100644 --- a/packages/server/src/integrations/tests/arangodb.spec.js +++ b/packages/server/src/integrations/tests/arangodb.spec.ts @@ -1,15 +1,16 @@ -const arangodb = require("arangojs") -const ArangoDBIntegration = require("../arangodb") +import { default as ArangoDBIntegration } from "../arangodb" jest.mock("arangojs") class TestConfiguration { - constructor(config = {}) { - this.integration = new ArangoDBIntegration.integration(config) + integration: any + + constructor(config: any = {}) { + this.integration = new ArangoDBIntegration.integration(config) } } describe("ArangoDB Integration", () => { - let config + let config: any let indexName = "Users" beforeEach(() => { @@ -18,18 +19,20 @@ describe("ArangoDB Integration", () => { it("calls the create method with the correct params", async () => { const body = { - json: "Hello" + json: "Hello", } const response = await config.integration.create(body) - expect(config.integration.client.query).toHaveBeenCalledWith(`INSERT Hello INTO collection RETURN NEW`) + expect(config.integration.client.query).toHaveBeenCalledWith( + `INSERT Hello INTO collection RETURN NEW` + ) }) it("calls the read method with the correct params", async () => { const query = { - json: `test`, + sql: `test`, } const response = await config.integration.read(query) expect(config.integration.client.query).toHaveBeenCalledWith(query.sql) }) -}) \ No newline at end of file +}) diff --git a/packages/server/src/integrations/tests/couchdb.spec.js b/packages/server/src/integrations/tests/couchdb.spec.ts similarity index 58% rename from packages/server/src/integrations/tests/couchdb.spec.js rename to packages/server/src/integrations/tests/couchdb.spec.ts index 65c9c83ad2..e05a2bd247 100644 --- a/packages/server/src/integrations/tests/couchdb.spec.js +++ b/packages/server/src/integrations/tests/couchdb.spec.ts @@ -1,23 +1,29 @@ -jest.mock("pouchdb", () => function CouchDBMock() { - this.post = jest.fn() - this.allDocs = jest.fn(() => ({ rows: [] })) - this.put = jest.fn() - this.get = jest.fn() - this.remove = jest.fn() - this.plugin = jest.fn() - this.close = jest.fn() -}) +jest.mock( + "pouchdb", + () => + function CouchDBMock(this: any) { + this.post = jest.fn() + this.allDocs = jest.fn(() => ({ rows: [] })) + this.put = jest.fn() + this.get = jest.fn() + this.remove = jest.fn() + this.plugin = jest.fn() + this.close = jest.fn() + } +) -const CouchDBIntegration = require("../couchdb") +import { default as CouchDBIntegration } from "../couchdb" class TestConfiguration { - constructor(config = {}) { - this.integration = new CouchDBIntegration.integration(config) + integration: any + + constructor(config: any = {}) { + this.integration = new CouchDBIntegration.integration(config) } } describe("CouchDB Integration", () => { - let config + let config: any beforeEach(() => { config = new TestConfiguration() @@ -25,37 +31,37 @@ describe("CouchDB Integration", () => { it("calls the create method with the correct params", async () => { const doc = { - test: 1 - } - const response = await config.integration.create({ - json: doc + test: 1, + } + const response = await config.integration.create({ + json: doc, }) expect(config.integration.client.post).toHaveBeenCalledWith(doc) }) it("calls the read method with the correct params", async () => { const doc = { - name: "search" - } + name: "search", + } - const response = await config.integration.read({ - json: doc + const response = await config.integration.read({ + json: doc, }) expect(config.integration.client.allDocs).toHaveBeenCalledWith({ include_docs: true, - name: "search" + name: "search", }) }) it("calls the update method with the correct params", async () => { const doc = { _id: "1234", - name: "search" - } + name: "search", + } - const response = await config.integration.update({ - json: doc + const response = await config.integration.update({ + json: doc, }) expect(config.integration.client.put).toHaveBeenCalledWith(doc) @@ -67,4 +73,4 @@ describe("CouchDB Integration", () => { expect(config.integration.client.get).toHaveBeenCalledWith(id) expect(config.integration.client.remove).toHaveBeenCalled() }) -}) \ No newline at end of file +}) diff --git a/packages/server/src/integrations/tests/dynamodb.spec.js b/packages/server/src/integrations/tests/dynamodb.spec.ts similarity index 68% rename from packages/server/src/integrations/tests/dynamodb.spec.js rename to packages/server/src/integrations/tests/dynamodb.spec.ts index 198ed6a4b4..d245875173 100644 --- a/packages/server/src/integrations/tests/dynamodb.spec.js +++ b/packages/server/src/integrations/tests/dynamodb.spec.ts @@ -1,15 +1,16 @@ -const AWS = require("aws-sdk") -const DynamoDBIntegration = require("../dynamodb") +import { default as DynamoDBIntegration } from "../dynamodb" jest.mock("aws-sdk") class TestConfiguration { - constructor(config = {}) { - this.integration = new DynamoDBIntegration.integration(config) + integration: any + + constructor(config: any = {}) { + this.integration = new DynamoDBIntegration.integration(config) } } describe("DynamoDB Integration", () => { - let config + let config: any let tableName = "Users" beforeEach(() => { @@ -17,25 +18,25 @@ describe("DynamoDB Integration", () => { }) it("calls the create method with the correct params", async () => { - const response = await config.integration.create({ + const response = await config.integration.create({ table: tableName, json: { - Name: "John" - } + Name: "John", + }, }) expect(config.integration.client.put).toHaveBeenCalledWith({ TableName: tableName, - Name: "John" + Name: "John", }) }) it("calls the read method with the correct params", async () => { const indexName = "Test" - const response = await config.integration.read({ + const response = await config.integration.read({ table: tableName, - index: indexName, - json: {} + index: indexName, + json: {}, }) expect(config.integration.client.query).toHaveBeenCalledWith({ TableName: tableName, @@ -47,57 +48,59 @@ describe("DynamoDB Integration", () => { it("calls the scan method with the correct params", async () => { const indexName = "Test" - const response = await config.integration.scan({ + const response = await config.integration.scan({ table: tableName, - index: indexName, - json: {} + index: indexName, + json: {}, }) expect(config.integration.client.scan).toHaveBeenCalledWith({ TableName: tableName, IndexName: indexName, }) - expect(response).toEqual([{ - Name: "test" - }]) + expect(response).toEqual([ + { + Name: "test", + }, + ]) }) it("calls the get method with the correct params", async () => { - const response = await config.integration.get({ + const response = await config.integration.get({ table: tableName, json: { - Id: 123 - } + Id: 123, + }, }) expect(config.integration.client.get).toHaveBeenCalledWith({ TableName: tableName, - Id: 123 + Id: 123, }) }) it("calls the update method with the correct params", async () => { - const response = await config.integration.update({ + const response = await config.integration.update({ table: tableName, json: { - Name: "John" - } + Name: "John", + }, }) expect(config.integration.client.update).toHaveBeenCalledWith({ TableName: tableName, - Name: "John" + Name: "John", }) }) it("calls the delete method with the correct params", async () => { - const response = await config.integration.delete({ + const response = await config.integration.delete({ table: tableName, json: { - Name: "John" - } + Name: "John", + }, }) expect(config.integration.client.delete).toHaveBeenCalledWith({ TableName: tableName, - Name: "John" + Name: "John", }) }) @@ -105,14 +108,14 @@ describe("DynamoDB Integration", () => { const config = { region: "us-east-1", accessKeyId: "test", - secretAccessKeyId: "test" + secretAccessKey: "test", } - const integration = new DynamoDBIntegration.integration(config) + const integration: any = new DynamoDBIntegration.integration(config) expect(integration.config).toEqual({ currentClockSkew: true, - ...config + ...config, }) }) @@ -120,16 +123,16 @@ describe("DynamoDB Integration", () => { const config = { region: "us-east-1", accessKeyId: "test", - secretAccessKeyId: "test", - endpoint: "localhost:8080" + secretAccessKey: "test", + endpoint: "localhost:8080", } - const integration = new DynamoDBIntegration.integration(config) + const integration: any = new DynamoDBIntegration.integration(config) expect(integration.config).toEqual({ region: "us-east-1", currentClockSkew: true, - endpoint: "localhost:8080" + endpoint: "localhost:8080", }) }) @@ -137,15 +140,16 @@ describe("DynamoDB Integration", () => { const config = { region: "us-east-1", accessKeyId: "test", - secretAccessKeyId: "test", - endpoint: "dynamodb.aws.foo.net" + secretAccessKey: "test", + endpoint: "dynamodb.aws.foo.net", } const integration = new DynamoDBIntegration.integration(config) + // @ts-ignore expect(integration.config).toEqual({ currentClockSkew: true, - ...config + ...config, }) }) -}) \ No newline at end of file +}) diff --git a/packages/server/src/integrations/tests/elasticsearch.spec.js b/packages/server/src/integrations/tests/elasticsearch.spec.ts similarity index 72% rename from packages/server/src/integrations/tests/elasticsearch.spec.js rename to packages/server/src/integrations/tests/elasticsearch.spec.ts index fc97e04bcc..c839b9b2d4 100644 --- a/packages/server/src/integrations/tests/elasticsearch.spec.js +++ b/packages/server/src/integrations/tests/elasticsearch.spec.ts @@ -1,15 +1,16 @@ -const elasticsearch = require("@elastic/elasticsearch") -const ElasticSearchIntegration = require("../elasticsearch") +import { default as ElasticSearchIntegration } from "../elasticsearch" jest.mock("@elastic/elasticsearch") class TestConfiguration { - constructor(config = {}) { - this.integration = new ElasticSearchIntegration.integration(config) + integration: any + + constructor(config: any = {}) { + this.integration = new ElasticSearchIntegration.integration(config) } } describe("Elasticsearch Integration", () => { - let config + let config: any let indexName = "Users" beforeEach(() => { @@ -18,15 +19,15 @@ describe("Elasticsearch Integration", () => { it("calls the create method with the correct params", async () => { const body = { - name: "Hello" + name: "Hello", } - const response = await config.integration.create({ + const response = await config.integration.create({ index: indexName, - json: body + json: body, }) expect(config.integration.client.index).toHaveBeenCalledWith({ index: indexName, - body + body, }) }) @@ -34,43 +35,43 @@ describe("Elasticsearch Integration", () => { const body = { query: { term: { - name: "kimchy" - } - } + name: "kimchy", + }, + }, } - const response = await config.integration.read({ + const response = await config.integration.read({ index: indexName, - json: body + json: body, }) expect(config.integration.client.search).toHaveBeenCalledWith({ index: indexName, - body + body, }) expect(response).toEqual(expect.any(Array)) }) it("calls the update method with the correct params", async () => { const body = { - name: "updated" + name: "updated", } - const response = await config.integration.update({ + const response = await config.integration.update({ id: "1234", index: indexName, - json: body + json: body, }) expect(config.integration.client.update).toHaveBeenCalledWith({ id: "1234", index: indexName, - body + body, }) expect(response).toEqual(expect.any(Array)) }) it("calls the delete method with the correct params", async () => { const body = { - id: "1234" + id: "1234", } const response = await config.integration.delete(body) @@ -78,4 +79,4 @@ describe("Elasticsearch Integration", () => { expect(config.integration.client.delete).toHaveBeenCalledWith(body) expect(response).toEqual(expect.any(Array)) }) -}) \ No newline at end of file +}) diff --git a/packages/server/src/integrations/tests/firebase.spec.js b/packages/server/src/integrations/tests/firebase.spec.ts similarity index 70% rename from packages/server/src/integrations/tests/firebase.spec.js rename to packages/server/src/integrations/tests/firebase.spec.ts index 97d3b2c0d7..befbb80ccb 100644 --- a/packages/server/src/integrations/tests/firebase.spec.js +++ b/packages/server/src/integrations/tests/firebase.spec.ts @@ -1,92 +1,97 @@ -const firebase = require("@google-cloud/firestore") -const FirebaseIntegration = require("../firebase") +import { default as FirebaseIntegration } from "../firebase" jest.mock("@google-cloud/firestore") class TestConfiguration { - constructor(config = {}) { - this.integration = new FirebaseIntegration.integration(config) + integration: any + + constructor(config: any = {}) { + this.integration = new FirebaseIntegration.integration(config) } } describe("Firebase Integration", () => { - let config + let config: any let tableName = "Users" beforeEach(() => { config = new TestConfiguration({ - serviceAccount: "{}" + serviceAccount: "{}", }) }) it("calls the create method with the correct params", async () => { - await config.integration.create({ + await config.integration.create({ table: tableName, json: { - Name: "Test Name" + Name: "Test Name", }, extra: { - collection: "test" - } + collection: "test", + }, }) expect(config.integration.client.collection).toHaveBeenCalledWith("test") - expect(config.integration.client.set).toHaveBeenCalledWith({ + expect(config.integration.client.set).toHaveBeenCalledWith({ Name: "Test Name", - id: "test_id" + id: "test_id", }) }) it("calls the read method with the correct params", async () => { - const response = await config.integration.read({ + const response = await config.integration.read({ table: tableName, json: { - Name: "Test" + Name: "Test", }, extra: { collection: "test", filterField: "field", filter: "==", filterValue: "value", - } + }, }) expect(config.integration.client.collection).toHaveBeenCalledWith("test") - expect(config.integration.client.where).toHaveBeenCalledWith("field", "==", "value") - expect(response).toEqual([{ result: "test"}]) + expect(config.integration.client.where).toHaveBeenCalledWith( + "field", + "==", + "value" + ) + expect(response).toEqual([{ result: "test" }]) }) it("calls the update method with the correct params", async () => { - const response = await config.integration.update({ + const response = await config.integration.update({ table: tableName, json: { id: "test", - Name: "Test" + Name: "Test", }, extra: { - collection: "test" - } + collection: "test", + }, }) expect(config.integration.client.collection).toHaveBeenCalledWith("test") expect(config.integration.client.update).toHaveBeenCalledWith({ Name: "Test", - id: "test" + id: "test", }) expect(response).toEqual({ - result: "test" + result: "test", }) }) it("calls the delete method with the correct params", async () => { - const response = await config.integration.delete({ + const response = await config.integration.delete({ table: tableName, json: { id: "test", - Name: "Test" + Name: "Test", }, extra: { - collection: "test" - } + collection: "test", + }, }) expect(config.integration.client.collection).toHaveBeenCalledWith("test") expect(config.integration.client.doc).toHaveBeenCalledWith("test") expect(config.integration.client.delete).toHaveBeenCalled() }) -}) \ No newline at end of file +}) diff --git a/packages/server/src/integrations/tests/microsoftSqlServer.spec.js b/packages/server/src/integrations/tests/microsoftSqlServer.spec.ts similarity index 75% rename from packages/server/src/integrations/tests/microsoftSqlServer.spec.js rename to packages/server/src/integrations/tests/microsoftSqlServer.spec.ts index 19a99ad54b..8484e759a9 100644 --- a/packages/server/src/integrations/tests/microsoftSqlServer.spec.js +++ b/packages/server/src/integrations/tests/microsoftSqlServer.spec.ts @@ -1,15 +1,16 @@ -const sqlServer = require("mssql") -const MSSQLIntegration = require("../microsoftSqlServer") +import { default as MSSQLIntegration } from "../microsoftSqlServer" jest.mock("mssql") class TestConfiguration { - constructor(config = {}) { - this.integration = new MSSQLIntegration.integration(config) + integration: any + + constructor(config: any = {}) { + this.integration = new MSSQLIntegration.integration(config) } } describe("MS SQL Server Integration", () => { - let config + let config: any beforeEach(async () => { config = new TestConfiguration() @@ -23,7 +24,7 @@ describe("MS SQL Server Integration", () => { it("calls the create method with the correct params", async () => { const sql = "insert into users (name, age) values ('Joe', 123);" const response = await config.integration.create({ - sql + sql, }) expect(config.integration.client.request).toHaveBeenCalledWith() expect(response[0]).toEqual(sql) @@ -32,7 +33,7 @@ describe("MS SQL Server Integration", () => { it("calls the read method with the correct params", async () => { const sql = "select * from users;" const response = await config.integration.read({ - sql + sql, }) expect(config.integration.client.request).toHaveBeenCalledWith() expect(response[0]).toEqual(sql) @@ -45,11 +46,11 @@ describe("MS SQL Server Integration", () => { }) it("returns the correct response when the create response has no rows", async () => { - const sql = "insert into users (name, age) values ('Joe', 123);" - const response = await config.integration.create({ - sql + const sql = "insert into users (name, age) values ('Joe', 123);" + const response = await config.integration.create({ + sql, }) expect(response[0]).toEqual(sql) }) }) -}) \ No newline at end of file +}) diff --git a/packages/server/src/integrations/tests/mongo.spec.js b/packages/server/src/integrations/tests/mongo.spec.ts similarity index 90% rename from packages/server/src/integrations/tests/mongo.spec.js rename to packages/server/src/integrations/tests/mongo.spec.ts index 40aa6dbb58..a326d3ac2a 100644 --- a/packages/server/src/integrations/tests/mongo.spec.js +++ b/packages/server/src/integrations/tests/mongo.spec.ts @@ -1,22 +1,26 @@ const mongo = require("mongodb") -const MongoDBIntegration = require("../mongodb") +import { default as MongoDBIntegration } from "../mongodb" jest.mock("mongodb") class TestConfiguration { - constructor(config = {}) { + integration: any + + constructor(config: any = {}) { this.integration = new MongoDBIntegration.integration(config) } } function disableConsole() { jest.spyOn(console, "error") + // @ts-ignore console.error.mockImplementation(() => {}) + // @ts-ignore return console.error.mockRestore } describe("MongoDB Integration", () => { - let config + let config: any let indexName = "Users" beforeEach(() => { @@ -54,13 +58,16 @@ describe("MongoDB Integration", () => { id: "test", }, options: { - opt: "option" - } + opt: "option", + }, }, extra: { collection: "testCollection", actionTypes: "deleteOne" }, } await config.integration.delete(query) - expect(config.integration.client.deleteOne).toHaveBeenCalledWith(query.json.filter, query.json.options) + expect(config.integration.client.deleteOne).toHaveBeenCalledWith( + query.json.filter, + query.json.options + ) }) it("calls the update method with the correct params", async () => { @@ -108,7 +115,7 @@ describe("MongoDB Integration", () => { json: { filter: { _id: "ObjectId('ACBD12345678ABCD12345678')", - name: "ObjectId('BBBB12345678ABCD12345678')" + name: "ObjectId('BBBB12345678ABCD12345678')", }, update: { _id: "ObjectId('FFFF12345678ABCD12345678')", @@ -122,7 +129,7 @@ describe("MongoDB Integration", () => { } await config.integration.update(query) expect(config.integration.client.updateOne).toHaveBeenCalled() - + const args = config.integration.client.updateOne.mock.calls[0] expect(args[0]).toEqual({ _id: mongo.ObjectID.createFromHexString("ACBD12345678ABCD12345678"), @@ -133,7 +140,7 @@ describe("MongoDB Integration", () => { name: mongo.ObjectID.createFromHexString("CCCC12345678ABCD12345678"), }) expect(args[2]).toEqual({ - upsert: false + upsert: false, }) }) @@ -143,7 +150,7 @@ describe("MongoDB Integration", () => { filter: { _id: { $eq: "ObjectId('ACBD12345678ABCD12345678')", - } + }, }, update: { $set: { @@ -158,20 +165,20 @@ describe("MongoDB Integration", () => { } await config.integration.update(query) expect(config.integration.client.updateOne).toHaveBeenCalled() - + const args = config.integration.client.updateOne.mock.calls[0] expect(args[0]).toEqual({ _id: { $eq: mongo.ObjectID.createFromHexString("ACBD12345678ABCD12345678"), - } + }, }) expect(args[1]).toEqual({ $set: { _id: mongo.ObjectID.createFromHexString("FFFF12345678ABCD12345678"), - } + }, }) expect(args[2]).toEqual({ - upsert: true + upsert: true, }) }) @@ -181,12 +188,12 @@ describe("MongoDB Integration", () => { filter: { _id: { $eq: "ObjectId('ACBD12345678ABCD12345678')", - } + }, }, update: { $set: { name: "UPDATED", - age: 99 + age: 99, }, }, options: { @@ -197,21 +204,21 @@ describe("MongoDB Integration", () => { } await config.integration.read(query) expect(config.integration.client.findOneAndUpdate).toHaveBeenCalled() - + const args = config.integration.client.findOneAndUpdate.mock.calls[0] expect(args[0]).toEqual({ _id: { $eq: mongo.ObjectID.createFromHexString("ACBD12345678ABCD12345678"), - } + }, }) expect(args[1]).toEqual({ $set: { name: "UPDATED", - age: 99 - } + age: 99, + }, }) expect(args[2]).toEqual({ - upsert: false + upsert: false, }) }) @@ -242,12 +249,12 @@ describe("MongoDB Integration", () => { } await config.integration.update(query) expect(config.integration.client.updateOne).toHaveBeenCalled() - + const args = config.integration.client.updateOne.mock.calls[0] expect(args[0]).toEqual({ _id: { $eq: mongo.ObjectID.createFromHexString("ACBD12345678ABCD12345678"), - } + }, }) expect(args[1]).toEqual({ $set: { @@ -255,15 +262,17 @@ describe("MongoDB Integration", () => { data: [ { cid: 1 }, { cid: 2 }, - { nested: { - name: "test" - }} - ] + { + nested: { + name: "test", + }, + }, + ], }, }, }) expect(args[2]).toEqual({ - upsert: true + upsert: true, }) }) @@ -295,12 +304,12 @@ describe("MongoDB Integration", () => { } await config.integration.update(query) expect(config.integration.client.updateOne).toHaveBeenCalled() - + const args = config.integration.client.updateOne.mock.calls[0] expect(args[0]).toEqual({ _id: { $eq: mongo.ObjectID.createFromHexString("ACBD12345678ABCD12345678"), - } + }, }) expect(args[1]).toEqual({ $set: { @@ -308,16 +317,18 @@ describe("MongoDB Integration", () => { data: [ { cid: 1 }, { cid: 2 }, - { nested: { - name: "te}st" - }} - ] + { + nested: { + name: "te}st", + }, + }, + ], }, }, }) expect(args[2]).toEqual({ upsert: true, - extra: "ad\"{\"d" + extra: 'ad"{"d', }) }) }) diff --git a/packages/server/src/integrations/tests/mysql.spec.js b/packages/server/src/integrations/tests/mysql.spec.ts similarity index 80% rename from packages/server/src/integrations/tests/mysql.spec.js rename to packages/server/src/integrations/tests/mysql.spec.ts index 8304771d5d..a70eb73857 100644 --- a/packages/server/src/integrations/tests/mysql.spec.js +++ b/packages/server/src/integrations/tests/mysql.spec.ts @@ -1,14 +1,16 @@ -const MySQLIntegration = require("../mysql") +import { default as MySQLIntegration } from "../mysql" jest.mock("mysql2") class TestConfiguration { - constructor(config = { ssl: {} }) { + integration: any + + constructor(config: any = { ssl: {} }) { this.integration = new MySQLIntegration.integration(config) } } describe("MySQL Integration", () => { - let config + let config: any beforeEach(() => { config = new TestConfiguration() @@ -17,7 +19,7 @@ describe("MySQL Integration", () => { it("calls the create method with the correct params", async () => { const sql = "insert into users (name, age) values ('Joe', 123);" await config.integration.create({ - sql + sql, }) expect(config.integration.client.query).toHaveBeenCalledWith(sql, []) }) @@ -25,7 +27,7 @@ describe("MySQL Integration", () => { it("calls the read method with the correct params", async () => { const sql = "select * from users;" await config.integration.read({ - sql + sql, }) expect(config.integration.client.query).toHaveBeenCalledWith(sql, []) }) @@ -33,7 +35,7 @@ describe("MySQL Integration", () => { it("calls the update method with the correct params", async () => { const sql = "update table users set name = 'test';" await config.integration.update({ - sql + sql, }) expect(config.integration.client.query).toHaveBeenCalledWith(sql, []) }) @@ -41,34 +43,34 @@ describe("MySQL Integration", () => { it("calls the delete method with the correct params", async () => { const sql = "delete from users where name = 'todelete';" await config.integration.delete({ - sql + sql, }) expect(config.integration.client.query).toHaveBeenCalledWith(sql, []) }) describe("no rows returned", () => { it("returns the correct response when the create response has no rows", async () => { - const sql = "insert into users (name, age) values ('Joe', 123);" - const response = await config.integration.create({ - sql + const sql = "insert into users (name, age) values ('Joe', 123);" + const response = await config.integration.create({ + sql, }) expect(response).toEqual([{ created: true }]) }) it("returns the correct response when the update response has no rows", async () => { const sql = "update table users set name = 'test';" - const response = await config.integration.update({ - sql + const response = await config.integration.update({ + sql, }) expect(response).toEqual([{ updated: true }]) }) it("returns the correct response when the delete response has no rows", async () => { const sql = "delete from users where name = 'todelete';" - const response = await config.integration.delete({ - sql + const response = await config.integration.delete({ + sql, }) expect(response).toEqual([{ deleted: true }]) }) }) -}) \ No newline at end of file +}) diff --git a/packages/server/src/integrations/tests/oracle.spec.js b/packages/server/src/integrations/tests/oracle.spec.ts similarity index 83% rename from packages/server/src/integrations/tests/oracle.spec.js rename to packages/server/src/integrations/tests/oracle.spec.ts index 77f0525090..57dad48820 100644 --- a/packages/server/src/integrations/tests/oracle.spec.js +++ b/packages/server/src/integrations/tests/oracle.spec.ts @@ -1,17 +1,19 @@ const oracledb = require("oracledb") -const OracleIntegration = require("../oracle") +import { default as OracleIntegration } from "../oracle" jest.mock("oracledb") class TestConfiguration { - constructor(config = {}) { - this.integration = new OracleIntegration.integration(config) + integration: any + + constructor(config: any = {}) { + this.integration = new OracleIntegration.integration(config) } } const options = { autoCommit: true } describe("Oracle Integration", () => { - let config + let config: any beforeEach(() => { jest.clearAllMocks() @@ -26,7 +28,7 @@ describe("Oracle Integration", () => { it("calls the create method with the correct params", async () => { const sql = "insert into users (name, age) values ('Joe', 123);" await config.integration.create({ - sql + sql, }) expect(oracledb.executeMock).toHaveBeenCalledWith(sql, [], options) expect(oracledb.executeMock).toHaveBeenCalledTimes(1) @@ -35,7 +37,7 @@ describe("Oracle Integration", () => { it("calls the read method with the correct params", async () => { const sql = "select * from users;" await config.integration.read({ - sql + sql, }) expect(oracledb.executeMock).toHaveBeenCalledWith(sql, [], options) expect(oracledb.executeMock).toHaveBeenCalledTimes(1) @@ -43,8 +45,8 @@ 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({ - sql + const response = await config.integration.update({ + sql, }) expect(oracledb.executeMock).toHaveBeenCalledWith(sql, [], options) expect(oracledb.executeMock).toHaveBeenCalledTimes(1) @@ -53,7 +55,7 @@ describe("Oracle Integration", () => { it("calls the delete method with the correct params", async () => { const sql = "delete from users where name = 'todelete';" await config.integration.delete({ - sql + sql, }) expect(oracledb.executeMock).toHaveBeenCalledWith(sql, [], options) expect(oracledb.executeMock).toHaveBeenCalledTimes(1) @@ -65,9 +67,9 @@ describe("Oracle Integration", () => { }) it("returns the correct response when the create response has no rows", async () => { - const sql = "insert into users (name, age) values ('Joe', 123);" - const response = await config.integration.create({ - sql + const sql = "insert into users (name, age) values ('Joe', 123);" + const response = await config.integration.create({ + sql, }) expect(response).toEqual([{ created: true }]) expect(oracledb.executeMock).toHaveBeenCalledTimes(1) @@ -75,8 +77,8 @@ describe("Oracle Integration", () => { it("returns the correct response when the update response has no rows", async () => { const sql = "update table users set name = 'test';" - const response = await config.integration.update({ - sql + const response = await config.integration.update({ + sql, }) expect(response).toEqual([{ updated: true }]) expect(oracledb.executeMock).toHaveBeenCalledTimes(1) @@ -84,11 +86,11 @@ describe("Oracle Integration", () => { it("returns the correct response when the delete response has no rows", async () => { const sql = "delete from users where name = 'todelete';" - const response = await config.integration.delete({ - sql + const response = await config.integration.delete({ + sql, }) expect(response).toEqual([{ deleted: true }]) expect(oracledb.executeMock).toHaveBeenCalledTimes(1) }) }) -}) \ No newline at end of file +}) diff --git a/packages/server/src/integrations/tests/postgres.spec.js b/packages/server/src/integrations/tests/postgres.spec.ts similarity index 78% rename from packages/server/src/integrations/tests/postgres.spec.js rename to packages/server/src/integrations/tests/postgres.spec.ts index 4ce5f12e96..a6be3aa623 100644 --- a/packages/server/src/integrations/tests/postgres.spec.js +++ b/packages/server/src/integrations/tests/postgres.spec.ts @@ -1,15 +1,17 @@ const pg = require("pg") -const PostgresIntegration = require("../postgres") +import { default as PostgresIntegration } from "../postgres" jest.mock("pg") class TestConfiguration { - constructor(config = {}) { - this.integration = new PostgresIntegration.integration(config) + integration: any + + constructor(config: any = {}) { + this.integration = new PostgresIntegration.integration(config) } } describe("Postgres Integration", () => { - let config + let config: any beforeEach(() => { config = new TestConfiguration() @@ -18,7 +20,7 @@ describe("Postgres Integration", () => { it("calls the create method with the correct params", async () => { const sql = "insert into users (name, age) values ('Joe', 123);" await config.integration.create({ - sql + sql, }) expect(pg.queryMock).toHaveBeenCalledWith(sql, []) }) @@ -26,15 +28,15 @@ describe("Postgres Integration", () => { it("calls the read method with the correct params", async () => { const sql = "select * from users;" await config.integration.read({ - sql + sql, }) expect(pg.queryMock).toHaveBeenCalledWith(sql, []) }) it("calls the update method with the correct params", async () => { const sql = "update table users set name = 'test';" - const response = await config.integration.update({ - sql + const response = await config.integration.update({ + sql, }) expect(pg.queryMock).toHaveBeenCalledWith(sql, []) }) @@ -42,7 +44,7 @@ describe("Postgres Integration", () => { it("calls the delete method with the correct params", async () => { const sql = "delete from users where name = 'todelete';" await config.integration.delete({ - sql + sql, }) expect(pg.queryMock).toHaveBeenCalledWith(sql, []) }) @@ -53,27 +55,27 @@ describe("Postgres Integration", () => { }) it("returns the correct response when the create response has no rows", async () => { - const sql = "insert into users (name, age) values ('Joe', 123);" - const response = await config.integration.create({ - sql + const sql = "insert into users (name, age) values ('Joe', 123);" + const response = await config.integration.create({ + sql, }) expect(response).toEqual([{ created: true }]) }) it("returns the correct response when the update response has no rows", async () => { const sql = "update table users set name = 'test';" - const response = await config.integration.update({ - sql + const response = await config.integration.update({ + sql, }) expect(response).toEqual([{ updated: true }]) }) it("returns the correct response when the delete response has no rows", async () => { const sql = "delete from users where name = 'todelete';" - const response = await config.integration.delete({ - sql + const response = await config.integration.delete({ + sql, }) expect(response).toEqual([{ deleted: true }]) }) }) -}) \ No newline at end of file +}) diff --git a/packages/server/src/integrations/tests/redis.spec.js b/packages/server/src/integrations/tests/redis.spec.ts similarity index 71% rename from packages/server/src/integrations/tests/redis.spec.js rename to packages/server/src/integrations/tests/redis.spec.ts index 219584bdb2..d2e5ac819d 100644 --- a/packages/server/src/integrations/tests/redis.spec.js +++ b/packages/server/src/integrations/tests/redis.spec.ts @@ -1,13 +1,16 @@ const Redis = require("ioredis-mock") -const RedisIntegration = require("../redis") +import { default as RedisIntegration } from "../redis" class TestConfiguration { - constructor(config = {}) { - this.integration = new RedisIntegration.integration(config) + integration: any + redis: any + + constructor(config: any = {}) { + this.integration = new RedisIntegration.integration(config) this.redis = new Redis({ data: { - test: 'test', - result: "1" + test: "test", + result: "1", }, }) this.integration.client = this.redis @@ -15,7 +18,7 @@ class TestConfiguration { } describe("Redis Integration", () => { - let config + let config: any beforeEach(() => { config = new TestConfiguration() @@ -24,7 +27,7 @@ describe("Redis Integration", () => { it("calls the create method with the correct params", async () => { const body = { key: "key", - value: "value" + value: "value", } const response = await config.integration.create(body) expect(await config.redis.get("key")).toEqual("value") @@ -32,7 +35,7 @@ describe("Redis Integration", () => { it("calls the read method with the correct params", async () => { const body = { - key: "test" + key: "test", } const response = await config.integration.read(body) expect(response).toEqual("test") @@ -40,7 +43,7 @@ describe("Redis Integration", () => { it("calls the delete method with the correct params", async () => { const body = { - key: "test" + key: "test", } await config.integration.delete(body) expect(await config.redis.get(body.key)).toEqual(null) @@ -48,13 +51,17 @@ describe("Redis Integration", () => { it("calls the command method with the correct params", async () => { const body = { - json: "KEYS *" + json: "KEYS *", } // ioredis-mock doesn't support pipelines - config.integration.client.pipeline = jest.fn(() => ({ exec: jest.fn(() => [[]]) })) + config.integration.client.pipeline = jest.fn(() => ({ + exec: jest.fn(() => [[]]), + })) await config.integration.command(body) - expect(config.integration.client.pipeline).toHaveBeenCalledWith([["KEYS", "*"]]) + expect(config.integration.client.pipeline).toHaveBeenCalledWith([ + ["KEYS", "*"], + ]) }) -}) \ No newline at end of file +}) diff --git a/packages/server/src/integrations/tests/rest.spec.js b/packages/server/src/integrations/tests/rest.spec.ts similarity index 96% rename from packages/server/src/integrations/tests/rest.spec.js rename to packages/server/src/integrations/tests/rest.spec.ts index 0bb1e3a75d..96f87c2355 100644 --- a/packages/server/src/integrations/tests/rest.spec.js +++ b/packages/server/src/integrations/tests/rest.spec.ts @@ -12,9 +12,8 @@ jest.mock("node-fetch", () => text: jest.fn(), })) ) -const fetch = require("node-fetch") -const RestIntegration = require("../rest") -const { AuthType } = require("../rest") +import fetch from "node-fetch" +import { default as RestIntegration } from "../rest" const FormData = require("form-data") const { URLSearchParams } = require("url") @@ -24,14 +23,16 @@ const HEADERS = { } class TestConfiguration { - constructor(config = {}) { + integration: any + + constructor(config: any = {}) { this.integration = new RestIntegration.integration(config) } } describe("REST Integration", () => { const BASE_URL = "https://myapi.com" - let config + let config: any beforeEach(() => { config = new TestConfiguration({ @@ -170,22 +171,25 @@ describe("REST Integration", () => { }) it("should allow a valid json string and parse the contents to xml", () => { - const output = config.integration.addBody("xml", JSON.stringify(input), {}) + const output = config.integration.addBody( + "xml", + JSON.stringify(input), + {} + ) expect(output.body.includes("1")).toEqual(true) expect(output.body.includes("2")).toEqual(true) expect(output.headers["Content-Type"]).toEqual("application/xml") }) - }) describe("response", () => { - function buildInput(json, text, header) { + function buildInput(json: any, text: any, header: any) { return { status: 200, json: json ? async () => json : undefined, text: text ? async () => text : undefined, headers: { - get: key => (key === "content-length" ? 100 : header), + get: (key: any) => (key === "content-length" ? 100 : header), raw: () => ({ "content-type": header }), }, } @@ -224,7 +228,7 @@ describe("REST Integration", () => { const basicAuth = { _id: "c59c14bd1898a43baa08da68959b24686", name: "basic-1", - type: AuthType.BASIC, + type: RestIntegration.AuthType.BASIC, config: { username: "user", password: "password", @@ -234,7 +238,7 @@ describe("REST Integration", () => { const bearerAuth = { _id: "0d91d732f34e4befabeff50b392a8ff3", name: "bearer-1", - type: AuthType.BEARER, + type: RestIntegration.AuthType.BEARER, config: { token: "mytoken", }, @@ -360,6 +364,7 @@ describe("REST Integration", () => { headers: {}, method: "POST", }) + // @ts-ignore const sentData = JSON.stringify(fetch.mock.calls[0][1].body) expect(sentData).toContain(pageParam) expect(sentData).toContain(sizeParam) @@ -390,6 +395,7 @@ describe("REST Integration", () => { headers: {}, method: "POST", }) + // @ts-ignore const sentData = fetch.mock.calls[0][1].body expect(sentData.has(pageParam)) expect(sentData.get(pageParam)).toEqual(pageValue.toString()) @@ -489,6 +495,7 @@ describe("REST Integration", () => { headers: {}, method: "POST", }) + // @ts-ignore const sentData = JSON.stringify(fetch.mock.calls[0][1].body) expect(sentData).toContain(pageParam) expect(sentData).toContain(sizeParam) @@ -521,6 +528,7 @@ describe("REST Integration", () => { headers: {}, method: "POST", }) + // @ts-ignore const sentData = fetch.mock.calls[0][1].body expect(sentData.has(pageParam)) expect(sentData.get(pageParam)).toEqual(pageValue.toString()) diff --git a/packages/server/src/integrations/tests/s3.spec.js b/packages/server/src/integrations/tests/s3.spec.ts similarity index 55% rename from packages/server/src/integrations/tests/s3.spec.js rename to packages/server/src/integrations/tests/s3.spec.ts index 7ac403dbd4..503702c042 100644 --- a/packages/server/src/integrations/tests/s3.spec.js +++ b/packages/server/src/integrations/tests/s3.spec.ts @@ -1,26 +1,28 @@ const AWS = require("aws-sdk") -const S3Integration = require("../s3") +import { default as S3Integration } from "../s3" jest.mock("aws-sdk") class TestConfiguration { - constructor(config = {}) { - this.integration = new S3Integration.integration(config) + integration: any + + constructor(config: any = {}) { + this.integration = new S3Integration.integration(config) } } describe("S3 Integration", () => { - let config + let config: any beforeEach(() => { config = new TestConfiguration() }) it("calls the read method with the correct params", async () => { - const response = await config.integration.read({ - bucket: "test" + const response = await config.integration.read({ + bucket: "test", }) expect(config.integration.client.listObjects).toHaveBeenCalledWith({ - Bucket: "test" + Bucket: "test", }) }) -}) \ No newline at end of file +}) diff --git a/packages/server/src/integrations/tests/sql.spec.js b/packages/server/src/integrations/tests/sql.spec.ts similarity index 60% rename from packages/server/src/integrations/tests/sql.spec.js rename to packages/server/src/integrations/tests/sql.spec.ts index 3cc9f0fb3e..421b8535d4 100644 --- a/packages/server/src/integrations/tests/sql.spec.js +++ b/packages/server/src/integrations/tests/sql.spec.ts @@ -3,7 +3,7 @@ const { SqlClient } = require("../utils") const TABLE_NAME = "test" -function endpoint(table, operation) { +function endpoint(table: any, operation: any) { return { datasourceId: "Postgres", operation: operation, @@ -11,7 +11,13 @@ function endpoint(table, operation) { } } -function generateReadJson({ table, fields, filters, sort, paginate} = {}) { +function generateReadJson({ + table, + fields, + filters, + sort, + paginate, +}: any = {}) { return { endpoint: endpoint(table || TABLE_NAME, "READ"), resource: { @@ -48,7 +54,7 @@ function generateDeleteJson(table = TABLE_NAME, filters = {}) { describe("SQL query builder", () => { const limit = 500 const client = SqlClient.POSTGRES - let sql + let sql: any beforeEach(() => { sql = new Sql(client, limit) @@ -58,118 +64,139 @@ describe("SQL query builder", () => { const query = sql._query(generateReadJson()) expect(query).toEqual({ bindings: [limit], - sql: `select * from (select * from "${TABLE_NAME}" limit $1) as "${TABLE_NAME}"` + sql: `select * from (select * from "${TABLE_NAME}" limit $1) as "${TABLE_NAME}"`, }) }) it("should test a read with specific columns", () => { - const nameProp = `${TABLE_NAME}.name`, ageProp = `${TABLE_NAME}.age` - const query = sql._query(generateReadJson({ - fields: [nameProp, ageProp] - })) + const nameProp = `${TABLE_NAME}.name`, + ageProp = `${TABLE_NAME}.age` + const query = sql._query( + generateReadJson({ + fields: [nameProp, ageProp], + }) + ) expect(query).toEqual({ bindings: [limit], - sql: `select "${TABLE_NAME}"."name" as "${nameProp}", "${TABLE_NAME}"."age" as "${ageProp}" from (select * from "${TABLE_NAME}" limit $1) as "${TABLE_NAME}"` + sql: `select "${TABLE_NAME}"."name" as "${nameProp}", "${TABLE_NAME}"."age" as "${ageProp}" from (select * from "${TABLE_NAME}" limit $1) as "${TABLE_NAME}"`, }) }) it("should test a where string starts with read", () => { - const query = sql._query(generateReadJson({ - filters: { - string: { - name: "John", - } - } - })) + const query = sql._query( + generateReadJson({ + filters: { + string: { + name: "John", + }, + }, + }) + ) expect(query).toEqual({ bindings: ["John%", limit], - sql: `select * from (select * from "${TABLE_NAME}" where "${TABLE_NAME}"."name" ilike $1 limit $2) as "${TABLE_NAME}"` + sql: `select * from (select * from "${TABLE_NAME}" where "${TABLE_NAME}"."name" ilike $1 limit $2) as "${TABLE_NAME}"`, }) }) it("should test a where range read", () => { - const query = sql._query(generateReadJson({ - filters: { - range: { - age: { - low: 2, - high: 10, - } - } - } - })) + const query = sql._query( + generateReadJson({ + filters: { + range: { + age: { + low: 2, + high: 10, + }, + }, + }, + }) + ) expect(query).toEqual({ bindings: [2, 10, limit], - sql: `select * from (select * from "${TABLE_NAME}" where "${TABLE_NAME}"."age" between $1 and $2 limit $3) as "${TABLE_NAME}"` + sql: `select * from (select * from "${TABLE_NAME}" where "${TABLE_NAME}"."age" between $1 and $2 limit $3) as "${TABLE_NAME}"`, }) }) it("should test for multiple IDs with OR", () => { - const query = sql._query(generateReadJson({ - filters: { - equal: { - age: 10, - name: "John", + const query = sql._query( + generateReadJson({ + filters: { + equal: { + age: 10, + name: "John", + }, + allOr: true, }, - allOr: true, - } - })) + }) + ) expect(query).toEqual({ bindings: [10, "John", limit], - sql: `select * from (select * from "${TABLE_NAME}" where ("${TABLE_NAME}"."age" = $1) or ("${TABLE_NAME}"."name" = $2) limit $3) as "${TABLE_NAME}"` + sql: `select * from (select * from "${TABLE_NAME}" where ("${TABLE_NAME}"."age" = $1) or ("${TABLE_NAME}"."name" = $2) limit $3) as "${TABLE_NAME}"`, }) }) it("should allow filtering on a related field", () => { - const query = sql._query(generateReadJson({ - filters: { - equal: { - age: 10, - "task.name": "task 1", + const query = sql._query( + generateReadJson({ + filters: { + equal: { + age: 10, + "task.name": "task 1", + }, }, - }, - })) + }) + ) // order of bindings changes because relationship filters occur outside inner query expect(query).toEqual({ bindings: [10, limit, "task 1"], - sql: `select * from (select * from "${TABLE_NAME}" where "${TABLE_NAME}"."age" = $1 limit $2) as "${TABLE_NAME}" where "task"."name" = $3` + sql: `select * from (select * from "${TABLE_NAME}" where "${TABLE_NAME}"."age" = $1 limit $2) as "${TABLE_NAME}" where "task"."name" = $3`, }) }) it("should test an create statement", () => { - const query = sql._query(generateCreateJson(TABLE_NAME, { - name: "Michael", - age: 45, - })) + const query = sql._query( + generateCreateJson(TABLE_NAME, { + name: "Michael", + age: 45, + }) + ) expect(query).toEqual({ bindings: [45, "Michael"], - sql: `insert into "${TABLE_NAME}" ("age", "name") values ($1, $2) returning *` + sql: `insert into "${TABLE_NAME}" ("age", "name") values ($1, $2) returning *`, }) }) it("should test an update statement", () => { - const query = sql._query(generateUpdateJson(TABLE_NAME, { - name: "John" - }, { - equal: { - id: 1001, - } - })) + const query = sql._query( + generateUpdateJson( + TABLE_NAME, + { + name: "John", + }, + { + equal: { + id: 1001, + }, + } + ) + ) expect(query).toEqual({ bindings: ["John", 1001], - sql: `update "${TABLE_NAME}" set "name" = $1 where "${TABLE_NAME}"."id" = $2 returning *` + sql: `update "${TABLE_NAME}" set "name" = $1 where "${TABLE_NAME}"."id" = $2 returning *`, }) }) it("should test a delete statement", () => { - const query = sql._query(generateDeleteJson(TABLE_NAME, { - equal: { - id: 1001, - } - })) + const query = sql._query( + generateDeleteJson(TABLE_NAME, { + equal: { + id: 1001, + }, + }) + ) expect(query).toEqual({ bindings: [1001], - sql: `delete from "${TABLE_NAME}" where "${TABLE_NAME}"."id" = $1 returning *` + sql: `delete from "${TABLE_NAME}" where "${TABLE_NAME}"."id" = $1 returning *`, }) }) @@ -177,7 +204,7 @@ describe("SQL query builder", () => { const query = new Sql(SqlClient.MS_SQL, 10)._query(generateReadJson()) expect(query).toEqual({ bindings: [10], - sql: `select * from (select top (@p0) * from [${TABLE_NAME}]) as [${TABLE_NAME}]` + sql: `select * from (select top (@p0) * from [${TABLE_NAME}]) as [${TABLE_NAME}]`, }) }) @@ -185,193 +212,217 @@ describe("SQL query builder", () => { const query = new Sql(SqlClient.MY_SQL, 10)._query(generateReadJson()) expect(query).toEqual({ bindings: [10], - sql: `select * from (select * from \`${TABLE_NAME}\` limit ?) as \`${TABLE_NAME}\`` + sql: `select * from (select * from \`${TABLE_NAME}\` limit ?) as \`${TABLE_NAME}\``, }) }) it("should use greater than when only low range specified", () => { const date = new Date() - const query = sql._query(generateReadJson({ - filters: { - range: { - property: { - low: date, - } - } - } - })) + const query = sql._query( + generateReadJson({ + filters: { + range: { + property: { + low: date, + }, + }, + }, + }) + ) expect(query).toEqual({ bindings: [date, limit], - sql: `select * from (select * from "${TABLE_NAME}" where "${TABLE_NAME}"."property" > $1 limit $2) as "${TABLE_NAME}"` + sql: `select * from (select * from "${TABLE_NAME}" where "${TABLE_NAME}"."property" > $1 limit $2) as "${TABLE_NAME}"`, }) }) it("should use less than when only high range specified", () => { const date = new Date() - const query = sql._query(generateReadJson({ - filters: { - range: { - property: { - high: date, - } - } - } - })) + const query = sql._query( + generateReadJson({ + filters: { + range: { + property: { + high: date, + }, + }, + }, + }) + ) expect(query).toEqual({ bindings: [date, limit], - sql: `select * from (select * from "${TABLE_NAME}" where "${TABLE_NAME}"."property" < $1 limit $2) as "${TABLE_NAME}"` + sql: `select * from (select * from "${TABLE_NAME}" where "${TABLE_NAME}"."property" < $1 limit $2) as "${TABLE_NAME}"`, }) }) it("should use greater than when only low range specified", () => { const date = new Date() - const query = sql._query(generateReadJson({ - filters: { - range: { - property: { - low: date, - } - } - } - })) + const query = sql._query( + generateReadJson({ + filters: { + range: { + property: { + low: date, + }, + }, + }, + }) + ) expect(query).toEqual({ bindings: [date, limit], - sql: `select * from (select * from "${TABLE_NAME}" where "${TABLE_NAME}"."property" > $1 limit $2) as "${TABLE_NAME}"` + sql: `select * from (select * from "${TABLE_NAME}" where "${TABLE_NAME}"."property" > $1 limit $2) as "${TABLE_NAME}"`, }) }) it("should use AND like expression for MS-SQL when filter is contains", () => { - const query = new Sql(SqlClient.MS_SQL, 10)._query(generateReadJson({ - filters: { - contains: { - age: [20, 25], - name: ["John", "Mary"] - } - } - })) + const query = new Sql(SqlClient.MS_SQL, 10)._query( + generateReadJson({ + filters: { + contains: { + age: [20, 25], + name: ["John", "Mary"], + }, + }, + }) + ) expect(query).toEqual({ bindings: [10, "%20%", "%25%", `%"John"%`, `%"Mary"%`], - sql: `select * from (select top (@p0) * from [${TABLE_NAME}] where (LOWER(${TABLE_NAME}.age) LIKE @p1 AND LOWER(${TABLE_NAME}.age) LIKE @p2) and (LOWER(${TABLE_NAME}.name) LIKE @p3 AND LOWER(${TABLE_NAME}.name) LIKE @p4)) as [${TABLE_NAME}]` + sql: `select * from (select top (@p0) * from [${TABLE_NAME}] where (LOWER(${TABLE_NAME}.age) LIKE @p1 AND LOWER(${TABLE_NAME}.age) LIKE @p2) and (LOWER(${TABLE_NAME}.name) LIKE @p3 AND LOWER(${TABLE_NAME}.name) LIKE @p4)) as [${TABLE_NAME}]`, }) }) it("should use JSON_CONTAINS expression for MySQL when filter is contains", () => { - const query = new Sql(SqlClient.MY_SQL, 10)._query(generateReadJson({ - filters: { - contains: { - age: [20], - name: ["John"] - } - } - })) + const query = new Sql(SqlClient.MY_SQL, 10)._query( + generateReadJson({ + filters: { + contains: { + age: [20], + name: ["John"], + }, + }, + }) + ) expect(query).toEqual({ bindings: [10], - sql: `select * from (select * from \`${TABLE_NAME}\` where JSON_CONTAINS(${TABLE_NAME}.age, '[20]') and JSON_CONTAINS(${TABLE_NAME}.name, '["John"]') limit ?) as \`${TABLE_NAME}\`` + sql: `select * from (select * from \`${TABLE_NAME}\` where JSON_CONTAINS(${TABLE_NAME}.age, '[20]') and JSON_CONTAINS(${TABLE_NAME}.name, '["John"]') limit ?) as \`${TABLE_NAME}\``, }) }) it("should use jsonb operator expression for PostgreSQL when filter is contains", () => { - const query = new Sql(SqlClient.POSTGRES, 10)._query(generateReadJson({ - filters: { - contains: { - age: [20], - name: ["John"] - } - } - })) + const query = new Sql(SqlClient.POSTGRES, 10)._query( + generateReadJson({ + filters: { + contains: { + age: [20], + name: ["John"], + }, + }, + }) + ) expect(query).toEqual({ bindings: [10], - sql: `select * from (select * from \"${TABLE_NAME}\" where \"${TABLE_NAME}\".\"age\"::jsonb @> '[20]' and \"${TABLE_NAME}\".\"name\"::jsonb @> '["John"]' limit $1) as \"${TABLE_NAME}\"` + sql: `select * from (select * from \"${TABLE_NAME}\" where \"${TABLE_NAME}\".\"age\"::jsonb @> '[20]' and \"${TABLE_NAME}\".\"name\"::jsonb @> '["John"]' limit $1) as \"${TABLE_NAME}\"`, }) }) it("should use NOT like expression for MS-SQL when filter is notContains", () => { - const query = new Sql(SqlClient.MS_SQL, 10)._query(generateReadJson({ - filters: { - notContains: { - age: [20], - name: ["John"] - } - } - })) + const query = new Sql(SqlClient.MS_SQL, 10)._query( + generateReadJson({ + filters: { + notContains: { + age: [20], + name: ["John"], + }, + }, + }) + ) expect(query).toEqual({ bindings: [10, "%20%", `%"John"%`], - sql: `select * from (select top (@p0) * from [${TABLE_NAME}] where NOT (LOWER(${TABLE_NAME}.age) LIKE @p1) and NOT (LOWER(${TABLE_NAME}.name) LIKE @p2)) as [${TABLE_NAME}]` + sql: `select * from (select top (@p0) * from [${TABLE_NAME}] where NOT (LOWER(${TABLE_NAME}.age) LIKE @p1) and NOT (LOWER(${TABLE_NAME}.name) LIKE @p2)) as [${TABLE_NAME}]`, }) }) it("should use NOT JSON_CONTAINS expression for MySQL when filter is notContains", () => { - const query = new Sql(SqlClient.MY_SQL, 10)._query(generateReadJson({ - filters: { - notContains: { - age: [20], - name: ["John"] - } - } - })) + const query = new Sql(SqlClient.MY_SQL, 10)._query( + generateReadJson({ + filters: { + notContains: { + age: [20], + name: ["John"], + }, + }, + }) + ) expect(query).toEqual({ bindings: [10], - sql: `select * from (select * from \`${TABLE_NAME}\` where NOT JSON_CONTAINS(${TABLE_NAME}.age, '[20]') and NOT JSON_CONTAINS(${TABLE_NAME}.name, '["John"]') limit ?) as \`${TABLE_NAME}\`` + sql: `select * from (select * from \`${TABLE_NAME}\` where NOT JSON_CONTAINS(${TABLE_NAME}.age, '[20]') and NOT JSON_CONTAINS(${TABLE_NAME}.name, '["John"]') limit ?) as \`${TABLE_NAME}\``, }) }) it("should use jsonb operator NOT expression for PostgreSQL when filter is notContains", () => { - const query = new Sql(SqlClient.POSTGRES, 10)._query(generateReadJson({ - filters: { - notContains: { - age: [20], - name: ["John"] - } - } - })) + const query = new Sql(SqlClient.POSTGRES, 10)._query( + generateReadJson({ + filters: { + notContains: { + age: [20], + name: ["John"], + }, + }, + }) + ) expect(query).toEqual({ bindings: [10], - sql: `select * from (select * from \"${TABLE_NAME}\" where NOT \"${TABLE_NAME}\".\"age\"::jsonb @> '[20]' and NOT \"${TABLE_NAME}\".\"name\"::jsonb @> '["John"]' limit $1) as \"${TABLE_NAME}\"` + sql: `select * from (select * from \"${TABLE_NAME}\" where NOT \"${TABLE_NAME}\".\"age\"::jsonb @> '[20]' and NOT \"${TABLE_NAME}\".\"name\"::jsonb @> '["John"]' limit $1) as \"${TABLE_NAME}\"`, }) }) it("should use OR like expression for MS-SQL when filter is containsAny", () => { - const query = new Sql(SqlClient.MS_SQL, 10)._query(generateReadJson({ - filters: { - containsAny: { - age: [20, 25], - name: ["John", "Mary"] - } - } - })) + const query = new Sql(SqlClient.MS_SQL, 10)._query( + generateReadJson({ + filters: { + containsAny: { + age: [20, 25], + name: ["John", "Mary"], + }, + }, + }) + ) expect(query).toEqual({ bindings: [10, "%20%", "%25%", `%"John"%`, `%"Mary"%`], - sql: `select * from (select top (@p0) * from [${TABLE_NAME}] where (LOWER(${TABLE_NAME}.age) LIKE @p1 OR LOWER(${TABLE_NAME}.age) LIKE @p2) and (LOWER(${TABLE_NAME}.name) LIKE @p3 OR LOWER(${TABLE_NAME}.name) LIKE @p4)) as [${TABLE_NAME}]` + sql: `select * from (select top (@p0) * from [${TABLE_NAME}] where (LOWER(${TABLE_NAME}.age) LIKE @p1 OR LOWER(${TABLE_NAME}.age) LIKE @p2) and (LOWER(${TABLE_NAME}.name) LIKE @p3 OR LOWER(${TABLE_NAME}.name) LIKE @p4)) as [${TABLE_NAME}]`, }) }) it("should use JSON_OVERLAPS expression for MySQL when filter is containsAny", () => { - const query = new Sql(SqlClient.MY_SQL, 10)._query(generateReadJson({ - filters: { - containsAny: { - age: [20, 25], - name: ["John", "Mary"] - } - } - })) + const query = new Sql(SqlClient.MY_SQL, 10)._query( + generateReadJson({ + filters: { + containsAny: { + age: [20, 25], + name: ["John", "Mary"], + }, + }, + }) + ) expect(query).toEqual({ bindings: [10], - sql: `select * from (select * from \`${TABLE_NAME}\` where JSON_OVERLAPS(${TABLE_NAME}.age, '[20,25]') and JSON_OVERLAPS(${TABLE_NAME}.name, '["John","Mary"]') limit ?) as \`${TABLE_NAME}\`` + sql: `select * from (select * from \`${TABLE_NAME}\` where JSON_OVERLAPS(${TABLE_NAME}.age, '[20,25]') and JSON_OVERLAPS(${TABLE_NAME}.name, '["John","Mary"]') limit ?) as \`${TABLE_NAME}\``, }) }) it("should use ?| operator expression for PostgreSQL when filter is containsAny", () => { - const query = new Sql(SqlClient.POSTGRES, 10)._query(generateReadJson({ - filters: { - containsAny: { - age: [20, 25], - name: ["John", "Mary"] - } - } - })) + const query = new Sql(SqlClient.POSTGRES, 10)._query( + generateReadJson({ + filters: { + containsAny: { + age: [20, 25], + name: ["John", "Mary"], + }, + }, + }) + ) expect(query).toEqual({ bindings: [10], - sql: `select * from (select * from \"${TABLE_NAME}\" where \"${TABLE_NAME}\".\"age\"::jsonb ?| array [20,25] and \"${TABLE_NAME}\".\"name\"::jsonb ?| array ['John','Mary'] limit $1) as \"${TABLE_NAME}\"` + sql: `select * from (select * from \"${TABLE_NAME}\" where \"${TABLE_NAME}\".\"age\"::jsonb ?| array [20,25] and \"${TABLE_NAME}\".\"name\"::jsonb ?| array ['John','Mary'] limit $1) as \"${TABLE_NAME}\"`, }) }) }) From 96631e9e8496dc8e20d8895387f8463843994937 Mon Sep 17 00:00:00 2001 From: Andrew Kingston Date: Thu, 1 Sep 2022 12:51:28 +0100 Subject: [PATCH 069/203] Update watch params to use polling and improve speed --- packages/server/src/watch.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/packages/server/src/watch.ts b/packages/server/src/watch.ts index 3d3f4280da..9821d1127b 100644 --- a/packages/server/src/watch.ts +++ b/packages/server/src/watch.ts @@ -11,7 +11,12 @@ export function watch() { chokidar .watch(watchPath, { ignored: "**/node_modules", - awaitWriteFinish: true, + awaitWriteFinish: { + pollInterval: 100, + stabilityThreshold: 250, + }, + usePolling: true, + interval: 250, }) .on("all", async (event: string, path: string) => { // Sanity checks From e03c48bd6e78d8d8e89a4d2e5963169fef3d1635 Mon Sep 17 00:00:00 2001 From: Andrew Kingston Date: Thu, 1 Sep 2022 14:10:29 +0100 Subject: [PATCH 070/203] Remove extra space --- charts/budibase/templates/app-service-deployment.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/charts/budibase/templates/app-service-deployment.yaml b/charts/budibase/templates/app-service-deployment.yaml index 89bc2e578d..a9bf714c45 100644 --- a/charts/budibase/templates/app-service-deployment.yaml +++ b/charts/budibase/templates/app-service-deployment.yaml @@ -132,7 +132,7 @@ spec: {{ end }} {{ if .Values.globals.pluginsDir }} - name: PLUGINS_DIR - value: { { .Values.globals.pluginsDir | quote }} + value: {{ .Values.globals.pluginsDir | quote }} {{ end }} {{ if .Values.services.apps.nodeDebug }} - name: NODE_DEBUG From 52947e4417a3f60b8f0908f794fe69596e966718 Mon Sep 17 00:00:00 2001 From: Mel O'Hagan Date: Thu, 1 Sep 2022 17:21:42 +0100 Subject: [PATCH 071/203] Exclude formula columns from Sql drop column --- packages/server/src/integrations/base/sqlTable.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/server/src/integrations/base/sqlTable.ts b/packages/server/src/integrations/base/sqlTable.ts index 4b715e5f3a..af561e81c5 100644 --- a/packages/server/src/integrations/base/sqlTable.ts +++ b/packages/server/src/integrations/base/sqlTable.ts @@ -96,7 +96,9 @@ function generateSchema( const deletedColumns = Object.entries(oldTable.schema) .filter( ([key, schema]) => - schema.type !== FieldTypes.LINK && table.schema[key] == null + schema.type !== FieldTypes.LINK && + schema.type !== FieldTypes.FORMULA && + table.schema[key] == null ) .map(([key]) => key) deletedColumns.forEach(key => { From 4de090b4c661708826909582466b819b16e74136 Mon Sep 17 00:00:00 2001 From: NEOLPAR Date: Thu, 1 Sep 2022 20:04:45 +0100 Subject: [PATCH 072/203] create plugin github public and private --- packages/builder/src/stores/portal/plugins.js | 4 +- packages/server/src/api/controllers/plugin.ts | 6 +- .../server/src/utilities/fileSystem/index.js | 65 ++++++++++++++++++- 3 files changed, 71 insertions(+), 4 deletions(-) diff --git a/packages/builder/src/stores/portal/plugins.js b/packages/builder/src/stores/portal/plugins.js index a498bf663a..821934307d 100644 --- a/packages/builder/src/stores/portal/plugins.js +++ b/packages/builder/src/stores/portal/plugins.js @@ -32,10 +32,12 @@ export function createPluginsStore() { case "npm": pluginData.npmToken = auth break + case "github": + pluginData.githubToken = auth + break } let res = await API.createPlugin(pluginData) - console.log("RESP", res) let newPlugin = res.plugins[0] update(state => { diff --git a/packages/server/src/api/controllers/plugin.ts b/packages/server/src/api/controllers/plugin.ts index 26caf38806..1159b08dce 100644 --- a/packages/server/src/api/controllers/plugin.ts +++ b/packages/server/src/api/controllers/plugin.ts @@ -3,6 +3,7 @@ import { extractPluginTarball, createNpmPlugin, createUrlPlugin, + createGithubPlugin, } from "../../utilities/fileSystem" import { getGlobalDB } from "@budibase/backend-core/tenancy" import { generatePluginID, getPluginParams } from "../../db/utils" @@ -61,7 +62,10 @@ export async function create(ctx: any) { directory = directoryNpm break case "github": - console.log("github") + const { metadata: metadataGithub, directory: directoryGithub } = + await createGithubPlugin(ctx, url, name, githubToken) + metadata = metadataGithub + directory = directoryGithub break case "url": const { metadata: metadataUrl, directory: directoryUrl } = diff --git a/packages/server/src/utilities/fileSystem/index.js b/packages/server/src/utilities/fileSystem/index.js index 710e3c0294..d8c201a380 100644 --- a/packages/server/src/utilities/fileSystem/index.js +++ b/packages/server/src/utilities/fileSystem/index.js @@ -31,6 +31,7 @@ const MemoryStream = require("memorystream") const { getAppId } = require("@budibase/backend-core/context") const tar = require("tar") const fetch = require("node-fetch") +const { NodeVM } = require("vm2") const TOP_LEVEL_PATH = join(__dirname, "..", "..", "..") const NODE_MODULES_PATH = join(TOP_LEVEL_PATH, "node_modules") @@ -378,8 +379,69 @@ exports.createUrlPlugin = async (url, name = "", headers = {}) => { return await downloadUnzipPlugin(name, url, headers) } +exports.createGithubPlugin = async (ctx, url, name = "", token = "") => { + let githubRepositoryUrl + let githubUrl + + if (url.includes(".git")) { + githubRepositoryUrl = token + ? url.replace("https://", `https://${token}@`) + : url + githubUrl = url.replace(".git", "") + } else { + githubRepositoryUrl = token + ? `${url}.git`.replace("https://", `https://${token}@`) + : `${url}.git` + githubUrl = url + } + + const githubApiUrl = githubUrl.replace( + "https://github.com/", + "https://api.github.com/repos/" + ) + const headers = token ? { Authorization: `Bearer ${token}` } : {} + try { + const pluginRaw = await fetch(githubApiUrl, { headers }) + if (pluginRaw.status !== 200) { + throw `Repository not found` + } + + let pluginDetails = await pluginRaw.json() + const pluginName = pluginDetails.name || name + + const path = join(budibaseTempDir(), pluginName) + // Remove first if exists + if (fs.existsSync(path)) { + fs.rmSync(path, { recursive: true, force: true }) + } + fs.mkdirSync(path) + + const script = ` +module.exports = async () => { + const child_process = require('child_process') + child_process.execSync(\`git clone ${githubRepositoryUrl} ${join( + budibaseTempDir(), + pluginName + )}\`); +} +` + const scriptRunner = new NodeVM({ + require: { + external: true, + builtin: ["child_process"], + root: "./", + }, + }).run(script) + + await scriptRunner() + + return await getPluginMetadata(path) + } catch (e) { + throw e.message + } +} + const downloadUnzipPlugin = async (name, url, headers = {}) => { - console.log(name, url, headers) const path = join(budibaseTempDir(), name) try { // Remove first if exists @@ -407,7 +469,6 @@ const downloadUnzipPlugin = async (name, url, headers = {}) => { exports.downloadUnzipPlugin = downloadUnzipPlugin const getPluginMetadata = async path => { - console.log(path) let metadata = {} try { const pkg = fs.readFileSync(join(path, "package.json"), "utf8") From 9c49a2195347eada0f80045e45519c29eeb565a1 Mon Sep 17 00:00:00 2001 From: Andrew Kingston Date: Fri, 2 Sep 2022 11:48:45 +0100 Subject: [PATCH 073/203] Update vite path for proxying websocket to be /vite --- hosting/nginx.dev.conf.hbs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hosting/nginx.dev.conf.hbs b/hosting/nginx.dev.conf.hbs index ecf73c4fb1..430ea75398 100644 --- a/hosting/nginx.dev.conf.hbs +++ b/hosting/nginx.dev.conf.hbs @@ -84,9 +84,9 @@ http { proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; } - location /ws { + location /vite { proxy_pass http://{{ address }}:3000; - rewrite ^/ws(.*)$ /$1 break; + rewrite ^/vite(.*)$ /$1 break; } location / { From 5a8713869c26524113f0b1db4d491d31d3e3b2e4 Mon Sep 17 00:00:00 2001 From: Andrew Kingston Date: Fri, 2 Sep 2022 12:04:18 +0100 Subject: [PATCH 074/203] Remove logs --- packages/client/src/websocket.js | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/client/src/websocket.js b/packages/client/src/websocket.js index 1a4ee49a92..eb859933f7 100644 --- a/packages/client/src/websocket.js +++ b/packages/client/src/websocket.js @@ -15,7 +15,6 @@ export const initWebsocket = () => { const proto = tls ? "wss:" : "ws:" const host = location.hostname const port = location.port || (tls ? 443 : 80) - console.log(`${proto}//${host}:${port}`) const socket = io(`${proto}//${host}:${port}`, { path: "/socket/client", }) From 171ec2d0207a78a1224c79de9a85d858d8748df8 Mon Sep 17 00:00:00 2001 From: Andrew Kingston Date: Fri, 2 Sep 2022 12:26:30 +0100 Subject: [PATCH 075/203] Update nginx confs and add to single image --- hosting/nginx.dev.conf.hbs | 3 +-- hosting/nginx.prod.conf.hbs | 9 +++++++++ hosting/single/nginx/nginx-default-site.conf | 9 +++++++++ 3 files changed, 19 insertions(+), 2 deletions(-) diff --git a/hosting/nginx.dev.conf.hbs b/hosting/nginx.dev.conf.hbs index 778dc9dacd..7faa92e38a 100644 --- a/hosting/nginx.dev.conf.hbs +++ b/hosting/nginx.dev.conf.hbs @@ -90,13 +90,12 @@ http { } location /socket/ { - proxy_pass http://{{ address }}:4001; - proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection 'upgrade'; proxy_set_header Host $host; proxy_cache_bypass $http_upgrade; + proxy_pass http://{{ address }}:4001; } location / { diff --git a/hosting/nginx.prod.conf.hbs b/hosting/nginx.prod.conf.hbs index 5ecea67c42..5b69d2ab5c 100644 --- a/hosting/nginx.prod.conf.hbs +++ b/hosting/nginx.prod.conf.hbs @@ -162,6 +162,15 @@ http { rewrite ^/db/(.*)$ /$1 break; } + location /socket/ { + proxy_http_version 1.1; + proxy_set_header Upgrade $http_upgrade; + proxy_set_header Connection 'upgrade'; + proxy_set_header Host $host; + proxy_cache_bypass $http_upgrade; + proxy_pass http://$apps:4002; + } + location / { proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; diff --git a/hosting/single/nginx/nginx-default-site.conf b/hosting/single/nginx/nginx-default-site.conf index c0d80a0185..bd89e21251 100644 --- a/hosting/single/nginx/nginx-default-site.conf +++ b/hosting/single/nginx/nginx-default-site.conf @@ -66,6 +66,15 @@ server { rewrite ^/db/(.*)$ /$1 break; } + location /socket/ { + proxy_http_version 1.1; + proxy_set_header Upgrade $http_upgrade; + proxy_set_header Connection 'upgrade'; + proxy_set_header Host $host; + proxy_cache_bypass $http_upgrade; + proxy_pass http://127.0.0.1:4001; + } + location / { proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; From 2b342a60fcbb30a0ae4dc1bb3bd8d83b7ba85ef0 Mon Sep 17 00:00:00 2001 From: Martin McKeaveney Date: Fri, 2 Sep 2022 18:35:06 +0100 Subject: [PATCH 076/203] improvements to redis connector - multi line pipelines and lowercase commands --- packages/server/src/integrations/redis.ts | 20 ++++++++++++++----- .../src/integrations/tests/redis.spec.js | 19 ++++++++++++++++-- 2 files changed, 32 insertions(+), 7 deletions(-) diff --git a/packages/server/src/integrations/redis.ts b/packages/server/src/integrations/redis.ts index e8aa13560c..6764e20dca 100644 --- a/packages/server/src/integrations/redis.ts +++ b/packages/server/src/integrations/redis.ts @@ -132,12 +132,22 @@ module RedisModule { async command(query: { json: string }) { return this.redisContext(async () => { - const commands = query.json.trim().split(" ") - const pipeline = this.client.pipeline([commands]) - const result = await pipeline.exec() - return { - response: result[0][1], + // commands split line by line + const commands = query.json.trim().split("\n") + let pipelineCommands = [] + + // process each command separately + for (let command of commands) { + const tokenised = command.trim().split(" ") + // Pipeline only accepts lower case commands + tokenised[0] = tokenised[0].toLowerCase() + pipelineCommands.push(tokenised) } + + const pipeline = this.client.pipeline(pipelineCommands) + const result = await pipeline.exec() + + return result.map((output: string | string[]) => output[1]) }) } } diff --git a/packages/server/src/integrations/tests/redis.spec.js b/packages/server/src/integrations/tests/redis.spec.js index 219584bdb2..2483ccc382 100644 --- a/packages/server/src/integrations/tests/redis.spec.js +++ b/packages/server/src/integrations/tests/redis.spec.js @@ -46,7 +46,7 @@ describe("Redis Integration", () => { expect(await config.redis.get(body.key)).toEqual(null) }) - it("calls the command method with the correct params", async () => { + it("calls the pipeline method with the correct params", async () => { const body = { json: "KEYS *" } @@ -55,6 +55,21 @@ describe("Redis Integration", () => { config.integration.client.pipeline = jest.fn(() => ({ exec: jest.fn(() => [[]]) })) await config.integration.command(body) - expect(config.integration.client.pipeline).toHaveBeenCalledWith([["KEYS", "*"]]) + expect(config.integration.client.pipeline).toHaveBeenCalledWith([["keys", "*"]]) + }) + + it("calls the pipeline method with several separated commands when there are newlines", async () => { + const body = { + json: 'SET foo "bar"\nGET foo' + } + + // ioredis-mock doesn't support pipelines + config.integration.client.pipeline = jest.fn(() => ({ exec: jest.fn(() => [[]]) })) + + await config.integration.command(body) + expect(config.integration.client.pipeline).toHaveBeenCalledWith([ + ["set", 'foo', '"bar"'], + ["get", 'foo'] + ]) }) }) \ No newline at end of file From 60c337fe95d591ebeef5f46887898c4743279e6c Mon Sep 17 00:00:00 2001 From: NEOLPAR Date: Fri, 2 Sep 2022 19:16:13 +0100 Subject: [PATCH 077/203] delete plugin through modal confirmation --- .../_components/DeletePluginModal.svelte | 31 +++++++++++++++++++ .../plugins/_components/PluginRow.svelte | 16 +++++++--- .../portal/manage/plugins/index.svelte | 16 +++++++++- 3 files changed, 58 insertions(+), 5 deletions(-) create mode 100644 packages/builder/src/pages/builder/portal/manage/plugins/_components/DeletePluginModal.svelte diff --git a/packages/builder/src/pages/builder/portal/manage/plugins/_components/DeletePluginModal.svelte b/packages/builder/src/pages/builder/portal/manage/plugins/_components/DeletePluginModal.svelte new file mode 100644 index 0000000000..3907c1a0a2 --- /dev/null +++ b/packages/builder/src/pages/builder/portal/manage/plugins/_components/DeletePluginModal.svelte @@ -0,0 +1,31 @@ + + + + + Are you sure you want to delete {plugin?.name} + + diff --git a/packages/builder/src/pages/builder/portal/manage/plugins/_components/PluginRow.svelte b/packages/builder/src/pages/builder/portal/manage/plugins/_components/PluginRow.svelte index 3a92a699e6..9c166b8b1b 100644 --- a/packages/builder/src/pages/builder/portal/manage/plugins/_components/PluginRow.svelte +++ b/packages/builder/src/pages/builder/portal/manage/plugins/_components/PluginRow.svelte @@ -1,6 +1,8 @@
@@ -41,9 +51,7 @@ - plugins.deletePlugin(plugin._id, plugin._rev)} - icon="Delete">Delete remove(plugin)} icon="Delete">Delete editGroup(plugin)} icon="Edit">Edit diff --git a/packages/builder/src/pages/builder/portal/manage/plugins/index.svelte b/packages/builder/src/pages/builder/portal/manage/plugins/index.svelte index 61227786b0..489333b095 100644 --- a/packages/builder/src/pages/builder/portal/manage/plugins/index.svelte +++ b/packages/builder/src/pages/builder/portal/manage/plugins/index.svelte @@ -13,9 +13,12 @@ import { plugins } from "stores/portal" import PluginRow from "./_components/PluginRow.svelte" import AddPluginModal from "./_components/AddPluginModal.svelte" + import DeletePluginModal from "./_components/DeletePluginModal.svelte" let modal + let deleteModal let searchTerm = "" + let removePlugin let filterOptions = [ { label: "All Plugins", value: "all" }, @@ -31,6 +34,14 @@ .filter(plugin => plugin?.name?.toLowerCase().includes(searchTerm.toLowerCase()) ) + + const deletePlugin = evt => { + const { detail } = evt + + deleteModal.show() + removePlugin = detail + } + onMount(async () => { await plugins.load() }) @@ -66,7 +77,7 @@ {#if $plugins} {#each filteredPlugins as plugin} - + {/each} {/if} @@ -75,6 +86,9 @@ + + + From bc1586761d4f5173b5e1f80abba64c8b61151ef0 Mon Sep 17 00:00:00 2001 From: Rory Powell Date: Mon, 5 Sep 2022 09:46:54 +0100 Subject: [PATCH 086/203] Fix auto user creation for OIDC auth --- packages/worker/src/sdk/users/users.ts | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/packages/worker/src/sdk/users/users.ts b/packages/worker/src/sdk/users/users.ts index 0ea16bf670..a8944b936a 100644 --- a/packages/worker/src/sdk/users/users.ts +++ b/packages/worker/src/sdk/users/users.ts @@ -189,23 +189,34 @@ export const save = async ( const tenantId = tenancy.getTenantId() const db = tenancy.getGlobalDB() let { email, _id } = user + if (!email && !_id) { + throw new Error("_id or email is required") + } let dbUser: User | undefined if (_id) { // try to get existing user from db - dbUser = (await db.get(_id)) as User - if (email && dbUser.email !== email) { - throw "Email address cannot be changed" + try { + dbUser = (await db.get(_id)) as User + if (email && dbUser.email !== email) { + throw "Email address cannot be changed" + } + email = dbUser.email + } catch (e: any) { + if (e.status === 404) { + // do nothing, save this new user with the id specified - required for SSO auth + } else { + throw e + } } - email = dbUser.email - } else if (email) { + } + + if (!dbUser && email) { // no id was specified - load from email instead dbUser = await usersCore.getGlobalUserByEmail(email) if (dbUser && dbUser._id !== _id) { throw `Unavailable` } - } else { - throw new Error("_id or email is required") } await validateUniqueUser(email, tenantId) From c03ac3f23243c544e5cd50950df19680609bfa04 Mon Sep 17 00:00:00 2001 From: Rory Powell Date: Mon, 5 Sep 2022 09:09:43 +0100 Subject: [PATCH 087/203] Configurable api rate limit through nginx --- hosting/docker-compose.yaml | 1 + hosting/nginx.prod.conf.hbs | 2 +- hosting/proxy/Dockerfile | 3 ++- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/hosting/docker-compose.yaml b/hosting/docker-compose.yaml index 7d3e6960dc..c55ca34547 100644 --- a/hosting/docker-compose.yaml +++ b/hosting/docker-compose.yaml @@ -78,6 +78,7 @@ services: image: budibase/proxy environment: - PROXY_RATE_LIMIT_WEBHOOKS_PER_SECOND=10 + - PROXY_RATE_LIMIT_API_PER_SECOND=20 depends_on: - minio-service - worker-service diff --git a/hosting/nginx.prod.conf.hbs b/hosting/nginx.prod.conf.hbs index 5ecea67c42..0ff986d0a7 100644 --- a/hosting/nginx.prod.conf.hbs +++ b/hosting/nginx.prod.conf.hbs @@ -11,7 +11,7 @@ events { http { # rate limiting limit_req_status 429; - limit_req_zone $binary_remote_addr zone=ratelimit:10m rate=20r/s; + limit_req_zone $binary_remote_addr zone=ratelimit:10m rate=${PROXY_RATE_LIMIT_API_PER_SECOND}r/s; limit_req_zone $binary_remote_addr zone=webhooks:10m rate=${PROXY_RATE_LIMIT_WEBHOOKS_PER_SECOND}r/s; include /etc/nginx/mime.types; diff --git a/hosting/proxy/Dockerfile b/hosting/proxy/Dockerfile index d9b33e3e9a..298762aaf1 100644 --- a/hosting/proxy/Dockerfile +++ b/hosting/proxy/Dockerfile @@ -10,4 +10,5 @@ COPY .generated-nginx.prod.conf /etc/nginx/templates/nginx.conf.template COPY error.html /usr/share/nginx/html/error.html # Default environment -ENV PROXY_RATE_LIMIT_WEBHOOKS_PER_SECOND=10 \ No newline at end of file +ENV PROXY_RATE_LIMIT_WEBHOOKS_PER_SECOND=10 +ENV PROXY_RATE_LIMIT_API_PER_SECOND=20 \ No newline at end of file From 79d2ea0c607f745fbb8a0d7d264b216acb277e06 Mon Sep 17 00:00:00 2001 From: NEOLPAR Date: Mon, 5 Sep 2022 10:13:55 +0100 Subject: [PATCH 088/203] cleaning minio folder when deleting plugin --- packages/server/src/api/controllers/plugin.ts | 22 ++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/packages/server/src/api/controllers/plugin.ts b/packages/server/src/api/controllers/plugin.ts index 337df0fc9e..8ec898d67d 100644 --- a/packages/server/src/api/controllers/plugin.ts +++ b/packages/server/src/api/controllers/plugin.ts @@ -4,11 +4,14 @@ import { createNpmPlugin, createUrlPlugin, createGithubPlugin, - loadJSFile + loadJSFile, } from "../../utilities/fileSystem" import { getGlobalDB } from "@budibase/backend-core/tenancy" import { generatePluginID, getPluginParams } from "../../db/utils" -import { uploadDirectory } from "@budibase/backend-core/objectStore" +import { + uploadDirectory, + deleteFolder, +} from "@budibase/backend-core/objectStore" import { PluginType, FileType } from "@budibase/types" import env from "../../environment" @@ -98,7 +101,20 @@ export async function fetch(ctx: any) { export async function destroy(ctx: any) { const db = getGlobalDB() - await db.remove(ctx.params.pluginId, ctx.params.pluginRev) + const { pluginId, pluginRev } = ctx.params + + try { + const plugin = await db.get(pluginId) + const bucketPath = `${plugin.name}/` + await deleteFolder(ObjectStoreBuckets.PLUGINS, bucketPath) + + await db.remove(pluginId, pluginRev) + } catch (err: any) { + const errMsg = err?.message ? err?.message : err + + ctx.throw(400, `Failed to delete plugin: ${errMsg}`) + } + ctx.message = `Plugin ${ctx.params.pluginId} deleted.` ctx.status = 200 } From c83967042e0203f4f50ff661e6888778e11e6aa4 Mon Sep 17 00:00:00 2001 From: NEOLPAR Date: Mon, 5 Sep 2022 10:28:09 +0100 Subject: [PATCH 089/203] random name in case it is needed --- packages/server/src/api/controllers/plugin.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/server/src/api/controllers/plugin.ts b/packages/server/src/api/controllers/plugin.ts index 8ec898d67d..254a008781 100644 --- a/packages/server/src/api/controllers/plugin.ts +++ b/packages/server/src/api/controllers/plugin.ts @@ -55,9 +55,11 @@ export async function upload(ctx: any) { } export async function create(ctx: any) { - const { type, source, name, url, headers, githubToken } = ctx.request.body + const { type, source, url, headers, githubToken } = ctx.request.body let metadata let directory + // Generating random name as a backup and needed for url + let name = "PLUGIN_" + Math.floor(100000 + Math.random() * 900000) switch (source) { case "npm": From 43893d9fe4e9517b138ba6f3ac2600b140a8b208 Mon Sep 17 00:00:00 2001 From: Peter Clement Date: Mon, 5 Sep 2022 11:27:43 +0100 Subject: [PATCH 090/203] remove name selection from UI --- packages/bbui/src/Modal/ModalContent.svelte | 2 +- .../plugins/_components/AddPluginModal.svelte | 1 + .../manage/plugins/_components/PluginRow.svelte | 14 ++++---------- packages/builder/src/stores/portal/plugins.js | 3 +-- 4 files changed, 7 insertions(+), 13 deletions(-) diff --git a/packages/bbui/src/Modal/ModalContent.svelte b/packages/bbui/src/Modal/ModalContent.svelte index 4c70f2390a..d946268da6 100644 --- a/packages/bbui/src/Modal/ModalContent.svelte +++ b/packages/bbui/src/Modal/ModalContent.svelte @@ -88,7 +88,7 @@
- {#if showCancelButton || showConfirmButton} + {#if showCancelButton || showConfirmButton || $$slots.footer}
diff --git a/packages/builder/src/pages/builder/portal/manage/plugins/_components/AddPluginModal.svelte b/packages/builder/src/pages/builder/portal/manage/plugins/_components/AddPluginModal.svelte index 7149136dec..2ccc9283e9 100644 --- a/packages/builder/src/pages/builder/portal/manage/plugins/_components/AddPluginModal.svelte +++ b/packages/builder/src/pages/builder/portal/manage/plugins/_components/AddPluginModal.svelte @@ -92,6 +92,7 @@ { if (!e.detail || e.detail.length === 0) { diff --git a/packages/builder/src/pages/builder/portal/manage/plugins/_components/PluginRow.svelte b/packages/builder/src/pages/builder/portal/manage/plugins/_components/PluginRow.svelte index 0eabad111a..30fddb2f76 100644 --- a/packages/builder/src/pages/builder/portal/manage/plugins/_components/PluginRow.svelte +++ b/packages/builder/src/pages/builder/portal/manage/plugins/_components/PluginRow.svelte @@ -8,9 +8,9 @@ Label, Input, } from "@budibase/bbui" - import { plugins } from "stores/portal" export let plugin + export let deletePlugin let detailsModal @@ -74,17 +74,11 @@
diff --git a/packages/builder/src/stores/portal/plugins.js b/packages/builder/src/stores/portal/plugins.js index 821934307d..9d558561b6 100644 --- a/packages/builder/src/stores/portal/plugins.js +++ b/packages/builder/src/stores/portal/plugins.js @@ -17,11 +17,10 @@ export function createPluginsStore() { }) } - async function createPlugin(type, source, name, url, auth = null) { + async function createPlugin(type, source, url, auth = null) { let pluginData = { type, source, - name, url, } From e3ac6893b3d1b008fb89373c1b8759475f22aabd Mon Sep 17 00:00:00 2001 From: Budibase Release Bot <> Date: Mon, 5 Sep 2022 10:40:03 +0000 Subject: [PATCH 091/203] v1.3.5 --- lerna.json | 2 +- packages/backend-core/package.json | 4 ++-- packages/bbui/package.json | 4 ++-- packages/builder/package.json | 10 +++++----- packages/cli/package.json | 4 ++-- packages/client/package.json | 8 ++++---- packages/frontend-core/package.json | 4 ++-- packages/server/package.json | 10 +++++----- packages/string-templates/package.json | 2 +- packages/types/package.json | 2 +- packages/worker/package.json | 8 ++++---- 11 files changed, 29 insertions(+), 29 deletions(-) diff --git a/lerna.json b/lerna.json index bffcb4a06c..9e1ede8e2d 100644 --- a/lerna.json +++ b/lerna.json @@ -1,5 +1,5 @@ { - "version": "1.3.4", + "version": "1.3.5", "npmClient": "yarn", "packages": [ "packages/*" diff --git a/packages/backend-core/package.json b/packages/backend-core/package.json index a338fc950d..6e5e8ab92a 100644 --- a/packages/backend-core/package.json +++ b/packages/backend-core/package.json @@ -1,6 +1,6 @@ { "name": "@budibase/backend-core", - "version": "1.3.4", + "version": "1.3.5", "description": "Budibase backend core libraries used in server and worker", "main": "dist/src/index.js", "types": "dist/src/index.d.ts", @@ -20,7 +20,7 @@ "test:watch": "jest --watchAll" }, "dependencies": { - "@budibase/types": "^1.3.4", + "@budibase/types": "^1.3.5", "@techpass/passport-openidconnect": "0.3.2", "aws-sdk": "2.1030.0", "bcrypt": "5.0.1", diff --git a/packages/bbui/package.json b/packages/bbui/package.json index 68aaf95155..b5a4e35683 100644 --- a/packages/bbui/package.json +++ b/packages/bbui/package.json @@ -1,7 +1,7 @@ { "name": "@budibase/bbui", "description": "A UI solution used in the different Budibase projects.", - "version": "1.3.4", + "version": "1.3.5", "license": "MPL-2.0", "svelte": "src/index.js", "module": "dist/bbui.es.js", @@ -38,7 +38,7 @@ ], "dependencies": { "@adobe/spectrum-css-workflow-icons": "^1.2.1", - "@budibase/string-templates": "^1.3.4", + "@budibase/string-templates": "^1.3.5", "@spectrum-css/actionbutton": "^1.0.1", "@spectrum-css/actiongroup": "^1.0.1", "@spectrum-css/avatar": "^3.0.2", diff --git a/packages/builder/package.json b/packages/builder/package.json index 046fbda883..007d8aae6b 100644 --- a/packages/builder/package.json +++ b/packages/builder/package.json @@ -1,6 +1,6 @@ { "name": "@budibase/builder", - "version": "1.3.4", + "version": "1.3.5", "license": "GPL-3.0", "private": true, "scripts": { @@ -69,10 +69,10 @@ } }, "dependencies": { - "@budibase/bbui": "^1.3.4", - "@budibase/client": "^1.3.4", - "@budibase/frontend-core": "^1.3.4", - "@budibase/string-templates": "^1.3.4", + "@budibase/bbui": "^1.3.5", + "@budibase/client": "^1.3.5", + "@budibase/frontend-core": "^1.3.5", + "@budibase/string-templates": "^1.3.5", "@sentry/browser": "5.19.1", "@spectrum-css/page": "^3.0.1", "@spectrum-css/vars": "^3.0.1", diff --git a/packages/cli/package.json b/packages/cli/package.json index 8a8962820f..a86c0b04f9 100644 --- a/packages/cli/package.json +++ b/packages/cli/package.json @@ -1,6 +1,6 @@ { "name": "@budibase/cli", - "version": "1.3.4", + "version": "1.3.5", "description": "Budibase CLI, for developers, self hosting and migrations.", "main": "src/index.js", "bin": { @@ -26,7 +26,7 @@ "outputPath": "build" }, "dependencies": { - "@budibase/backend-core": "^1.3.4", + "@budibase/backend-core": "^1.3.5", "axios": "0.21.2", "chalk": "4.1.0", "cli-progress": "3.11.2", diff --git a/packages/client/package.json b/packages/client/package.json index 317f84b1c5..5f930aee94 100644 --- a/packages/client/package.json +++ b/packages/client/package.json @@ -1,6 +1,6 @@ { "name": "@budibase/client", - "version": "1.3.4", + "version": "1.3.5", "license": "MPL-2.0", "module": "dist/budibase-client.js", "main": "dist/budibase-client.js", @@ -19,9 +19,9 @@ "dev:builder": "rollup -cw" }, "dependencies": { - "@budibase/bbui": "^1.3.4", - "@budibase/frontend-core": "^1.3.4", - "@budibase/string-templates": "^1.3.4", + "@budibase/bbui": "^1.3.5", + "@budibase/frontend-core": "^1.3.5", + "@budibase/string-templates": "^1.3.5", "@spectrum-css/button": "^3.0.3", "@spectrum-css/card": "^3.0.3", "@spectrum-css/divider": "^1.0.3", diff --git a/packages/frontend-core/package.json b/packages/frontend-core/package.json index 2b268900bf..65729b54ed 100644 --- a/packages/frontend-core/package.json +++ b/packages/frontend-core/package.json @@ -1,12 +1,12 @@ { "name": "@budibase/frontend-core", - "version": "1.3.4", + "version": "1.3.5", "description": "Budibase frontend core libraries used in builder and client", "author": "Budibase", "license": "MPL-2.0", "svelte": "src/index.js", "dependencies": { - "@budibase/bbui": "^1.3.4", + "@budibase/bbui": "^1.3.5", "lodash": "^4.17.21", "svelte": "^3.46.2" } diff --git a/packages/server/package.json b/packages/server/package.json index a104c56c9c..06fc5dd0be 100644 --- a/packages/server/package.json +++ b/packages/server/package.json @@ -1,7 +1,7 @@ { "name": "@budibase/server", "email": "hi@budibase.com", - "version": "1.3.4", + "version": "1.3.5", "description": "Budibase Web Server", "main": "src/index.ts", "repository": { @@ -77,11 +77,11 @@ "license": "GPL-3.0", "dependencies": { "@apidevtools/swagger-parser": "10.0.3", - "@budibase/backend-core": "^1.3.4", - "@budibase/client": "^1.3.4", + "@budibase/backend-core": "^1.3.5", + "@budibase/client": "^1.3.5", "@budibase/pro": "1.3.4", - "@budibase/string-templates": "^1.3.4", - "@budibase/types": "^1.3.4", + "@budibase/string-templates": "^1.3.5", + "@budibase/types": "^1.3.5", "@bull-board/api": "3.7.0", "@bull-board/koa": "3.9.4", "@elastic/elasticsearch": "7.10.0", diff --git a/packages/string-templates/package.json b/packages/string-templates/package.json index 28d68cdd09..126ad55d19 100644 --- a/packages/string-templates/package.json +++ b/packages/string-templates/package.json @@ -1,6 +1,6 @@ { "name": "@budibase/string-templates", - "version": "1.3.4", + "version": "1.3.5", "description": "Handlebars wrapper for Budibase templating.", "main": "src/index.cjs", "module": "dist/bundle.mjs", diff --git a/packages/types/package.json b/packages/types/package.json index 920c394d0d..38c8754f91 100644 --- a/packages/types/package.json +++ b/packages/types/package.json @@ -1,6 +1,6 @@ { "name": "@budibase/types", - "version": "1.3.4", + "version": "1.3.5", "description": "Budibase types", "main": "dist/index.js", "types": "dist/index.d.ts", diff --git a/packages/worker/package.json b/packages/worker/package.json index 0c89053da1..869e296438 100644 --- a/packages/worker/package.json +++ b/packages/worker/package.json @@ -1,7 +1,7 @@ { "name": "@budibase/worker", "email": "hi@budibase.com", - "version": "1.3.4", + "version": "1.3.5", "description": "Budibase background service", "main": "src/index.ts", "repository": { @@ -35,10 +35,10 @@ "author": "Budibase", "license": "GPL-3.0", "dependencies": { - "@budibase/backend-core": "^1.3.4", + "@budibase/backend-core": "^1.3.5", "@budibase/pro": "1.3.4", - "@budibase/string-templates": "^1.3.4", - "@budibase/types": "^1.3.4", + "@budibase/string-templates": "^1.3.5", + "@budibase/types": "^1.3.5", "@koa/router": "8.0.8", "@sentry/node": "6.17.7", "@techpass/passport-openidconnect": "0.3.2", From e8e4d605e956d9c764460f0f305c1ee9a63dd2b7 Mon Sep 17 00:00:00 2001 From: Budibase Release Bot <> Date: Mon, 5 Sep 2022 10:43:12 +0000 Subject: [PATCH 092/203] Update pro version to 1.3.5 --- packages/server/package.json | 2 +- packages/server/yarn.lock | 30 +++++++++++++++--------------- packages/worker/package.json | 2 +- packages/worker/yarn.lock | 30 +++++++++++++++--------------- 4 files changed, 32 insertions(+), 32 deletions(-) diff --git a/packages/server/package.json b/packages/server/package.json index 06fc5dd0be..6dbb7e0d5b 100644 --- a/packages/server/package.json +++ b/packages/server/package.json @@ -79,7 +79,7 @@ "@apidevtools/swagger-parser": "10.0.3", "@budibase/backend-core": "^1.3.5", "@budibase/client": "^1.3.5", - "@budibase/pro": "1.3.4", + "@budibase/pro": "1.3.5", "@budibase/string-templates": "^1.3.5", "@budibase/types": "^1.3.5", "@bull-board/api": "3.7.0", diff --git a/packages/server/yarn.lock b/packages/server/yarn.lock index bd258ea6d6..38754c99e4 100644 --- a/packages/server/yarn.lock +++ b/packages/server/yarn.lock @@ -1094,12 +1094,12 @@ resolved "https://registry.yarnpkg.com/@bcoe/v8-coverage/-/v8-coverage-0.2.3.tgz#75a2e8b51cb758a7553d6804a5932d7aace75c39" integrity sha512-0hYQ8SB4Db5zvZB4axdMHGwEaQjkZzFjQiN9LVYvIFB2nSUHW9tYpxWriPrWDASIxiaXax83REcLxuSdnGPZtw== -"@budibase/backend-core@1.3.4": - version "1.3.4" - resolved "https://registry.yarnpkg.com/@budibase/backend-core/-/backend-core-1.3.4.tgz#91de405d2eff963cabe58b286b73711239ffea52" - integrity sha512-csKHVM9H+7s26k0h+kQm1u6qz7A5/TgOUCSyuysR9aUak5rb5klC2/84AUlpRS4RJWQ37/X0QpovbrakAdXzsw== +"@budibase/backend-core@1.3.5": + version "1.3.5" + resolved "https://registry.yarnpkg.com/@budibase/backend-core/-/backend-core-1.3.5.tgz#67f437bfe19f7c8db03f2d64a78be561cd827df5" + integrity sha512-hhEIb1rTOQxE3aj6O2UqklHWd0dcGUBdeoNJrtmWmwSUkqjk+WBZ9WZgzeVUUtSgTUFCjMe7aup6QV+NpEteWg== dependencies: - "@budibase/types" "^1.3.4" + "@budibase/types" "^1.3.5" "@techpass/passport-openidconnect" "0.3.2" aws-sdk "2.1030.0" bcrypt "5.0.1" @@ -1178,13 +1178,13 @@ svelte-flatpickr "^3.2.3" svelte-portal "^1.0.0" -"@budibase/pro@1.3.4": - version "1.3.4" - resolved "https://registry.yarnpkg.com/@budibase/pro/-/pro-1.3.4.tgz#f21c23dcac5dce23d33fb09bc769447a960fc481" - integrity sha512-jOMRYu+7R8Dpn2l1BdwiaXkxQZb78jFEZIF2XJYUBSjKscgAZGgU+OyYYozRWQip563hTU3eZcqAtQKgfchEZg== +"@budibase/pro@1.3.5": + version "1.3.5" + resolved "https://registry.yarnpkg.com/@budibase/pro/-/pro-1.3.5.tgz#e828f5f5bbb8db69388df32fa6e7fb4de999a49b" + integrity sha512-3Pn1IW6R6DZ9J+6n2R/F0m357vjrnm/lonXpb6JcpWwSPLI5KtPIVSrKQaRxsSqc76355HSCoryGKorQIRq2Lg== dependencies: - "@budibase/backend-core" "1.3.4" - "@budibase/types" "1.3.4" + "@budibase/backend-core" "1.3.5" + "@budibase/types" "1.3.5" "@koa/router" "8.0.8" joi "17.6.0" node-fetch "^2.6.1" @@ -1207,10 +1207,10 @@ svelte-apexcharts "^1.0.2" svelte-flatpickr "^3.1.0" -"@budibase/types@1.3.4", "@budibase/types@^1.3.4": - version "1.3.4" - resolved "https://registry.yarnpkg.com/@budibase/types/-/types-1.3.4.tgz#25f087b024e843eb372e50c81f8f925fb39f1dfd" - integrity sha512-ndyWs8yeCS7cpZjApDB1HhY6UUM2SRBUgAMCZOZaWABG9JHeCbx7x0e/pA2SZjswdMXqS5WmnEd3br5wuvUzJw== +"@budibase/types@1.3.5", "@budibase/types@^1.3.5": + version "1.3.5" + resolved "https://registry.yarnpkg.com/@budibase/types/-/types-1.3.5.tgz#55cb770527085ab573f15ef0e7b28b9cae2d76ba" + integrity sha512-SSqe8ojEbSNzQHTw2OeXmVWimb/C9Hclcxif0NCCPsan2btx84yMZLO+A3GXanTqzmvSz4ZbkS7/33xwDiOHIA== "@bull-board/api@3.7.0": version "3.7.0" diff --git a/packages/worker/package.json b/packages/worker/package.json index 869e296438..45fb2336a2 100644 --- a/packages/worker/package.json +++ b/packages/worker/package.json @@ -36,7 +36,7 @@ "license": "GPL-3.0", "dependencies": { "@budibase/backend-core": "^1.3.5", - "@budibase/pro": "1.3.4", + "@budibase/pro": "1.3.5", "@budibase/string-templates": "^1.3.5", "@budibase/types": "^1.3.5", "@koa/router": "8.0.8", diff --git a/packages/worker/yarn.lock b/packages/worker/yarn.lock index e7e258efe6..8f339d2ab1 100644 --- a/packages/worker/yarn.lock +++ b/packages/worker/yarn.lock @@ -291,12 +291,12 @@ resolved "https://registry.yarnpkg.com/@bcoe/v8-coverage/-/v8-coverage-0.2.3.tgz#75a2e8b51cb758a7553d6804a5932d7aace75c39" integrity sha512-0hYQ8SB4Db5zvZB4axdMHGwEaQjkZzFjQiN9LVYvIFB2nSUHW9tYpxWriPrWDASIxiaXax83REcLxuSdnGPZtw== -"@budibase/backend-core@1.3.4": - version "1.3.4" - resolved "https://registry.yarnpkg.com/@budibase/backend-core/-/backend-core-1.3.4.tgz#91de405d2eff963cabe58b286b73711239ffea52" - integrity sha512-csKHVM9H+7s26k0h+kQm1u6qz7A5/TgOUCSyuysR9aUak5rb5klC2/84AUlpRS4RJWQ37/X0QpovbrakAdXzsw== +"@budibase/backend-core@1.3.5": + version "1.3.5" + resolved "https://registry.yarnpkg.com/@budibase/backend-core/-/backend-core-1.3.5.tgz#67f437bfe19f7c8db03f2d64a78be561cd827df5" + integrity sha512-hhEIb1rTOQxE3aj6O2UqklHWd0dcGUBdeoNJrtmWmwSUkqjk+WBZ9WZgzeVUUtSgTUFCjMe7aup6QV+NpEteWg== dependencies: - "@budibase/types" "^1.3.4" + "@budibase/types" "^1.3.5" "@techpass/passport-openidconnect" "0.3.2" aws-sdk "2.1030.0" bcrypt "5.0.1" @@ -325,21 +325,21 @@ uuid "8.3.2" zlib "1.0.5" -"@budibase/pro@1.3.4": - version "1.3.4" - resolved "https://registry.yarnpkg.com/@budibase/pro/-/pro-1.3.4.tgz#f21c23dcac5dce23d33fb09bc769447a960fc481" - integrity sha512-jOMRYu+7R8Dpn2l1BdwiaXkxQZb78jFEZIF2XJYUBSjKscgAZGgU+OyYYozRWQip563hTU3eZcqAtQKgfchEZg== +"@budibase/pro@1.3.5": + version "1.3.5" + resolved "https://registry.yarnpkg.com/@budibase/pro/-/pro-1.3.5.tgz#e828f5f5bbb8db69388df32fa6e7fb4de999a49b" + integrity sha512-3Pn1IW6R6DZ9J+6n2R/F0m357vjrnm/lonXpb6JcpWwSPLI5KtPIVSrKQaRxsSqc76355HSCoryGKorQIRq2Lg== dependencies: - "@budibase/backend-core" "1.3.4" - "@budibase/types" "1.3.4" + "@budibase/backend-core" "1.3.5" + "@budibase/types" "1.3.5" "@koa/router" "8.0.8" joi "17.6.0" node-fetch "^2.6.1" -"@budibase/types@1.3.4", "@budibase/types@^1.3.4": - version "1.3.4" - resolved "https://registry.yarnpkg.com/@budibase/types/-/types-1.3.4.tgz#25f087b024e843eb372e50c81f8f925fb39f1dfd" - integrity sha512-ndyWs8yeCS7cpZjApDB1HhY6UUM2SRBUgAMCZOZaWABG9JHeCbx7x0e/pA2SZjswdMXqS5WmnEd3br5wuvUzJw== +"@budibase/types@1.3.5", "@budibase/types@^1.3.5": + version "1.3.5" + resolved "https://registry.yarnpkg.com/@budibase/types/-/types-1.3.5.tgz#55cb770527085ab573f15ef0e7b28b9cae2d76ba" + integrity sha512-SSqe8ojEbSNzQHTw2OeXmVWimb/C9Hclcxif0NCCPsan2btx84yMZLO+A3GXanTqzmvSz4ZbkS7/33xwDiOHIA== "@cspotcode/source-map-consumer@0.8.0": version "0.8.0" From 8e49ad5e24ddbcd32da0e062e71014d493f3d0a2 Mon Sep 17 00:00:00 2001 From: Andrew Kingston Date: Mon, 5 Sep 2022 12:28:01 +0100 Subject: [PATCH 093/203] Prevent default browser events from firing when using keyboard shortcuts --- .../_components/navigation/ComponentKeyHandler.svelte | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/packages/builder/src/pages/builder/app/[application]/design/[screenId]/components/[componentId]/_components/navigation/ComponentKeyHandler.svelte b/packages/builder/src/pages/builder/app/[application]/design/[screenId]/components/[componentId]/_components/navigation/ComponentKeyHandler.svelte index 467d9a5a2f..77147d0f9a 100644 --- a/packages/builder/src/pages/builder/app/[application]/design/[screenId]/components/[componentId]/_components/navigation/ComponentKeyHandler.svelte +++ b/packages/builder/src/pages/builder/app/[application]/design/[screenId]/components/[componentId]/_components/navigation/ComponentKeyHandler.svelte @@ -54,7 +54,7 @@ }, } - const handleKeyAction = async (component, key, ctrlKey = false) => { + const handleKeyAction = async (event, component, key, ctrlKey = false) => { if (!component || !key) { return false } @@ -70,6 +70,9 @@ const handler = keyHandlers[key] if (!handler) { return false + } else if (event) { + event.preventDefault() + event.stopPropagation() } return handler(component) } catch (error) { @@ -89,14 +92,14 @@ return } // Key events are always for the selected component - return handleKeyAction($selectedComponent, e.key, e.ctrlKey || e.metaKey) + return handleKeyAction(e, $selectedComponent, e.key, e.ctrlKey || e.metaKey) } const handleComponentMenu = async e => { // Menu events can be for any component const { id, key, ctrlKey } = e.detail const component = findComponent($selectedScreen.props, id) - return await handleKeyAction(component, key, ctrlKey) + return await handleKeyAction(null, component, key, ctrlKey) } onMount(() => { From e1e4f2cc874b0f28c6a7063ae3f3c90a9e84fe2c Mon Sep 17 00:00:00 2001 From: mike12345567 Date: Mon, 5 Sep 2022 13:07:27 +0100 Subject: [PATCH 094/203] Fixing backend-core build, as raised in #7603. --- packages/backend-core/package.json | 2 +- packages/backend-core/tsconfig.build.json | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/backend-core/package.json b/packages/backend-core/package.json index a338fc950d..ce3dd11a7c 100644 --- a/packages/backend-core/package.json +++ b/packages/backend-core/package.json @@ -60,7 +60,7 @@ ] }, "devDependencies": { - "@shopify/jest-koa-mocks": "3.1.5", + "@shopify/jest-koa-mocks": "^5.0.1", "@types/jest": "27.5.1", "@types/koa": "2.0.52", "@types/lodash": "4.14.180", diff --git a/packages/backend-core/tsconfig.build.json b/packages/backend-core/tsconfig.build.json index 40ffe6b827..acf93df89e 100644 --- a/packages/backend-core/tsconfig.build.json +++ b/packages/backend-core/tsconfig.build.json @@ -20,6 +20,8 @@ "package.json" ], "exclude": [ + "scripts", + "tests", "node_modules", "dist", "**/*.spec.ts", From b3eb26dfd886763893b704dd9cb709e0d7816e14 Mon Sep 17 00:00:00 2001 From: mike12345567 Date: Mon, 5 Sep 2022 13:26:35 +0100 Subject: [PATCH 095/203] Pinning. --- packages/backend-core/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/backend-core/package.json b/packages/backend-core/package.json index ce3dd11a7c..01be6a2bcd 100644 --- a/packages/backend-core/package.json +++ b/packages/backend-core/package.json @@ -60,7 +60,7 @@ ] }, "devDependencies": { - "@shopify/jest-koa-mocks": "^5.0.1", + "@shopify/jest-koa-mocks": "5.0.1", "@types/jest": "27.5.1", "@types/koa": "2.0.52", "@types/lodash": "4.14.180", From 7f250766639becde009208a86470e6b68fe436d5 Mon Sep 17 00:00:00 2001 From: mike12345567 Date: Mon, 5 Sep 2022 14:06:35 +0100 Subject: [PATCH 096/203] Updating backend-core lockfile. --- packages/backend-core/yarn.lock | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/packages/backend-core/yarn.lock b/packages/backend-core/yarn.lock index 9f71691f44..22c17a9444 100644 --- a/packages/backend-core/yarn.lock +++ b/packages/backend-core/yarn.lock @@ -543,13 +543,13 @@ semver "^7.3.5" tar "^6.1.11" -"@shopify/jest-koa-mocks@3.1.5": - version "3.1.5" - resolved "https://registry.yarnpkg.com/@shopify/jest-koa-mocks/-/jest-koa-mocks-3.1.5.tgz#11f77ccfbcaf35cf5ee2c6108a286e61e6bea084" - integrity sha512-gQ3/7ELerv00TWO37AGFX5mT9CsFCS+3/UbKMuoIlKEU0QH2OX8BV9WBf/EKw7adCDNlxss0lqV6J8kf5pgr4A== +"@shopify/jest-koa-mocks@5.0.1": + version "5.0.1" + resolved "https://registry.yarnpkg.com/@shopify/jest-koa-mocks/-/jest-koa-mocks-5.0.1.tgz#fba490b6b7985fbb571eb9974897d396a3642e94" + integrity sha512-4YskS9q8+TEHNoyopmuoy2XyhInyqeOl7CF5ShJs19sm6m0EA/jGGvgf/osv2PeTfuf42/L2G9CzWUSg49yTSg== dependencies: koa "^2.13.4" - node-mocks-http "^1.5.8" + node-mocks-http "^1.11.0" "@sideway/address@^4.1.3": version "4.1.4" @@ -3914,7 +3914,7 @@ node-int64@^0.4.0: resolved "https://registry.yarnpkg.com/node-int64/-/node-int64-0.4.0.tgz#87a9065cdb355d3182d8f94ce11188b825c68a3b" integrity sha512-O5lz91xSOeoXP6DulyHfllpq+Eg00MWitZIbtPfoSEvqIHdl5gfcY6hYzDWnj0qD5tz52PI08u9qUvSVeUBeHw== -node-mocks-http@^1.5.8: +node-mocks-http@^1.11.0: version "1.11.0" resolved "https://registry.yarnpkg.com/node-mocks-http/-/node-mocks-http-1.11.0.tgz#defc0febf6b935f08245397d47534a8de592996e" integrity sha512-jS/WzSOcKbOeGrcgKbenZeNhxUNnP36Yw11+hL4TTxQXErGfqYZ+MaYNNvhaTiGIJlzNSqgQkk9j8dSu1YWSuw== From 6f9f6b54acf28819286ce19e48823b1cd96cea92 Mon Sep 17 00:00:00 2001 From: Budibase Release Bot <> Date: Mon, 5 Sep 2022 13:19:34 +0000 Subject: [PATCH 097/203] v1.3.6 --- lerna.json | 2 +- packages/backend-core/package.json | 4 ++-- packages/bbui/package.json | 4 ++-- packages/builder/package.json | 10 +++++----- packages/cli/package.json | 4 ++-- packages/client/package.json | 8 ++++---- packages/frontend-core/package.json | 4 ++-- packages/server/package.json | 10 +++++----- packages/string-templates/package.json | 2 +- packages/types/package.json | 2 +- packages/worker/package.json | 8 ++++---- 11 files changed, 29 insertions(+), 29 deletions(-) diff --git a/lerna.json b/lerna.json index 9e1ede8e2d..721ceba47f 100644 --- a/lerna.json +++ b/lerna.json @@ -1,5 +1,5 @@ { - "version": "1.3.5", + "version": "1.3.6", "npmClient": "yarn", "packages": [ "packages/*" diff --git a/packages/backend-core/package.json b/packages/backend-core/package.json index e9e242369e..dbfecf37bd 100644 --- a/packages/backend-core/package.json +++ b/packages/backend-core/package.json @@ -1,6 +1,6 @@ { "name": "@budibase/backend-core", - "version": "1.3.5", + "version": "1.3.6", "description": "Budibase backend core libraries used in server and worker", "main": "dist/src/index.js", "types": "dist/src/index.d.ts", @@ -20,7 +20,7 @@ "test:watch": "jest --watchAll" }, "dependencies": { - "@budibase/types": "^1.3.5", + "@budibase/types": "^1.3.6", "@techpass/passport-openidconnect": "0.3.2", "aws-sdk": "2.1030.0", "bcrypt": "5.0.1", diff --git a/packages/bbui/package.json b/packages/bbui/package.json index b5a4e35683..a23285b479 100644 --- a/packages/bbui/package.json +++ b/packages/bbui/package.json @@ -1,7 +1,7 @@ { "name": "@budibase/bbui", "description": "A UI solution used in the different Budibase projects.", - "version": "1.3.5", + "version": "1.3.6", "license": "MPL-2.0", "svelte": "src/index.js", "module": "dist/bbui.es.js", @@ -38,7 +38,7 @@ ], "dependencies": { "@adobe/spectrum-css-workflow-icons": "^1.2.1", - "@budibase/string-templates": "^1.3.5", + "@budibase/string-templates": "^1.3.6", "@spectrum-css/actionbutton": "^1.0.1", "@spectrum-css/actiongroup": "^1.0.1", "@spectrum-css/avatar": "^3.0.2", diff --git a/packages/builder/package.json b/packages/builder/package.json index 007d8aae6b..78cfa9c4c6 100644 --- a/packages/builder/package.json +++ b/packages/builder/package.json @@ -1,6 +1,6 @@ { "name": "@budibase/builder", - "version": "1.3.5", + "version": "1.3.6", "license": "GPL-3.0", "private": true, "scripts": { @@ -69,10 +69,10 @@ } }, "dependencies": { - "@budibase/bbui": "^1.3.5", - "@budibase/client": "^1.3.5", - "@budibase/frontend-core": "^1.3.5", - "@budibase/string-templates": "^1.3.5", + "@budibase/bbui": "^1.3.6", + "@budibase/client": "^1.3.6", + "@budibase/frontend-core": "^1.3.6", + "@budibase/string-templates": "^1.3.6", "@sentry/browser": "5.19.1", "@spectrum-css/page": "^3.0.1", "@spectrum-css/vars": "^3.0.1", diff --git a/packages/cli/package.json b/packages/cli/package.json index a86c0b04f9..ea1938256c 100644 --- a/packages/cli/package.json +++ b/packages/cli/package.json @@ -1,6 +1,6 @@ { "name": "@budibase/cli", - "version": "1.3.5", + "version": "1.3.6", "description": "Budibase CLI, for developers, self hosting and migrations.", "main": "src/index.js", "bin": { @@ -26,7 +26,7 @@ "outputPath": "build" }, "dependencies": { - "@budibase/backend-core": "^1.3.5", + "@budibase/backend-core": "^1.3.6", "axios": "0.21.2", "chalk": "4.1.0", "cli-progress": "3.11.2", diff --git a/packages/client/package.json b/packages/client/package.json index 5f930aee94..05a6a81770 100644 --- a/packages/client/package.json +++ b/packages/client/package.json @@ -1,6 +1,6 @@ { "name": "@budibase/client", - "version": "1.3.5", + "version": "1.3.6", "license": "MPL-2.0", "module": "dist/budibase-client.js", "main": "dist/budibase-client.js", @@ -19,9 +19,9 @@ "dev:builder": "rollup -cw" }, "dependencies": { - "@budibase/bbui": "^1.3.5", - "@budibase/frontend-core": "^1.3.5", - "@budibase/string-templates": "^1.3.5", + "@budibase/bbui": "^1.3.6", + "@budibase/frontend-core": "^1.3.6", + "@budibase/string-templates": "^1.3.6", "@spectrum-css/button": "^3.0.3", "@spectrum-css/card": "^3.0.3", "@spectrum-css/divider": "^1.0.3", diff --git a/packages/frontend-core/package.json b/packages/frontend-core/package.json index 65729b54ed..0dfe6b190c 100644 --- a/packages/frontend-core/package.json +++ b/packages/frontend-core/package.json @@ -1,12 +1,12 @@ { "name": "@budibase/frontend-core", - "version": "1.3.5", + "version": "1.3.6", "description": "Budibase frontend core libraries used in builder and client", "author": "Budibase", "license": "MPL-2.0", "svelte": "src/index.js", "dependencies": { - "@budibase/bbui": "^1.3.5", + "@budibase/bbui": "^1.3.6", "lodash": "^4.17.21", "svelte": "^3.46.2" } diff --git a/packages/server/package.json b/packages/server/package.json index 6dbb7e0d5b..2b0c0eb6f1 100644 --- a/packages/server/package.json +++ b/packages/server/package.json @@ -1,7 +1,7 @@ { "name": "@budibase/server", "email": "hi@budibase.com", - "version": "1.3.5", + "version": "1.3.6", "description": "Budibase Web Server", "main": "src/index.ts", "repository": { @@ -77,11 +77,11 @@ "license": "GPL-3.0", "dependencies": { "@apidevtools/swagger-parser": "10.0.3", - "@budibase/backend-core": "^1.3.5", - "@budibase/client": "^1.3.5", + "@budibase/backend-core": "^1.3.6", + "@budibase/client": "^1.3.6", "@budibase/pro": "1.3.5", - "@budibase/string-templates": "^1.3.5", - "@budibase/types": "^1.3.5", + "@budibase/string-templates": "^1.3.6", + "@budibase/types": "^1.3.6", "@bull-board/api": "3.7.0", "@bull-board/koa": "3.9.4", "@elastic/elasticsearch": "7.10.0", diff --git a/packages/string-templates/package.json b/packages/string-templates/package.json index 126ad55d19..817c442e01 100644 --- a/packages/string-templates/package.json +++ b/packages/string-templates/package.json @@ -1,6 +1,6 @@ { "name": "@budibase/string-templates", - "version": "1.3.5", + "version": "1.3.6", "description": "Handlebars wrapper for Budibase templating.", "main": "src/index.cjs", "module": "dist/bundle.mjs", diff --git a/packages/types/package.json b/packages/types/package.json index 38c8754f91..a5684d2502 100644 --- a/packages/types/package.json +++ b/packages/types/package.json @@ -1,6 +1,6 @@ { "name": "@budibase/types", - "version": "1.3.5", + "version": "1.3.6", "description": "Budibase types", "main": "dist/index.js", "types": "dist/index.d.ts", diff --git a/packages/worker/package.json b/packages/worker/package.json index 45fb2336a2..35994a67f7 100644 --- a/packages/worker/package.json +++ b/packages/worker/package.json @@ -1,7 +1,7 @@ { "name": "@budibase/worker", "email": "hi@budibase.com", - "version": "1.3.5", + "version": "1.3.6", "description": "Budibase background service", "main": "src/index.ts", "repository": { @@ -35,10 +35,10 @@ "author": "Budibase", "license": "GPL-3.0", "dependencies": { - "@budibase/backend-core": "^1.3.5", + "@budibase/backend-core": "^1.3.6", "@budibase/pro": "1.3.5", - "@budibase/string-templates": "^1.3.5", - "@budibase/types": "^1.3.5", + "@budibase/string-templates": "^1.3.6", + "@budibase/types": "^1.3.6", "@koa/router": "8.0.8", "@sentry/node": "6.17.7", "@techpass/passport-openidconnect": "0.3.2", From 3150d86710f859d2535b25d538498f5a810c61e6 Mon Sep 17 00:00:00 2001 From: Budibase Release Bot <> Date: Mon, 5 Sep 2022 13:22:34 +0000 Subject: [PATCH 098/203] Update pro version to 1.3.6 --- packages/server/package.json | 2 +- packages/server/yarn.lock | 30 +++++++++++++++--------------- packages/worker/package.json | 2 +- packages/worker/yarn.lock | 30 +++++++++++++++--------------- 4 files changed, 32 insertions(+), 32 deletions(-) diff --git a/packages/server/package.json b/packages/server/package.json index 2b0c0eb6f1..392a1d8b93 100644 --- a/packages/server/package.json +++ b/packages/server/package.json @@ -79,7 +79,7 @@ "@apidevtools/swagger-parser": "10.0.3", "@budibase/backend-core": "^1.3.6", "@budibase/client": "^1.3.6", - "@budibase/pro": "1.3.5", + "@budibase/pro": "1.3.6", "@budibase/string-templates": "^1.3.6", "@budibase/types": "^1.3.6", "@bull-board/api": "3.7.0", diff --git a/packages/server/yarn.lock b/packages/server/yarn.lock index 38754c99e4..f91e3a5442 100644 --- a/packages/server/yarn.lock +++ b/packages/server/yarn.lock @@ -1094,12 +1094,12 @@ resolved "https://registry.yarnpkg.com/@bcoe/v8-coverage/-/v8-coverage-0.2.3.tgz#75a2e8b51cb758a7553d6804a5932d7aace75c39" integrity sha512-0hYQ8SB4Db5zvZB4axdMHGwEaQjkZzFjQiN9LVYvIFB2nSUHW9tYpxWriPrWDASIxiaXax83REcLxuSdnGPZtw== -"@budibase/backend-core@1.3.5": - version "1.3.5" - resolved "https://registry.yarnpkg.com/@budibase/backend-core/-/backend-core-1.3.5.tgz#67f437bfe19f7c8db03f2d64a78be561cd827df5" - integrity sha512-hhEIb1rTOQxE3aj6O2UqklHWd0dcGUBdeoNJrtmWmwSUkqjk+WBZ9WZgzeVUUtSgTUFCjMe7aup6QV+NpEteWg== +"@budibase/backend-core@1.3.6": + version "1.3.6" + resolved "https://registry.yarnpkg.com/@budibase/backend-core/-/backend-core-1.3.6.tgz#340b55a71eba228d44c8dd6107e28872a6f432d6" + integrity sha512-WIGseaoUrUWpqlbKadNuusQa1y9Ucm34AVei6oWRK1czJtLddaEt2zaMlD/qikcBB6XBJE3UML0Z82EvvdZPBQ== dependencies: - "@budibase/types" "^1.3.5" + "@budibase/types" "^1.3.6" "@techpass/passport-openidconnect" "0.3.2" aws-sdk "2.1030.0" bcrypt "5.0.1" @@ -1178,13 +1178,13 @@ svelte-flatpickr "^3.2.3" svelte-portal "^1.0.0" -"@budibase/pro@1.3.5": - version "1.3.5" - resolved "https://registry.yarnpkg.com/@budibase/pro/-/pro-1.3.5.tgz#e828f5f5bbb8db69388df32fa6e7fb4de999a49b" - integrity sha512-3Pn1IW6R6DZ9J+6n2R/F0m357vjrnm/lonXpb6JcpWwSPLI5KtPIVSrKQaRxsSqc76355HSCoryGKorQIRq2Lg== +"@budibase/pro@1.3.6": + version "1.3.6" + resolved "https://registry.yarnpkg.com/@budibase/pro/-/pro-1.3.6.tgz#2ac68b341401003a25619c36137a1960b97ac01d" + integrity sha512-5QFkeR/6DdvXdIgufmqACIEEGvqXlinQrXVV45C0n95gKEXvRybv5eiWR9OO7UyYeJzQOv0PTY8O7ZtOSQrdwg== dependencies: - "@budibase/backend-core" "1.3.5" - "@budibase/types" "1.3.5" + "@budibase/backend-core" "1.3.6" + "@budibase/types" "1.3.6" "@koa/router" "8.0.8" joi "17.6.0" node-fetch "^2.6.1" @@ -1207,10 +1207,10 @@ svelte-apexcharts "^1.0.2" svelte-flatpickr "^3.1.0" -"@budibase/types@1.3.5", "@budibase/types@^1.3.5": - version "1.3.5" - resolved "https://registry.yarnpkg.com/@budibase/types/-/types-1.3.5.tgz#55cb770527085ab573f15ef0e7b28b9cae2d76ba" - integrity sha512-SSqe8ojEbSNzQHTw2OeXmVWimb/C9Hclcxif0NCCPsan2btx84yMZLO+A3GXanTqzmvSz4ZbkS7/33xwDiOHIA== +"@budibase/types@1.3.6", "@budibase/types@^1.3.6": + version "1.3.6" + resolved "https://registry.yarnpkg.com/@budibase/types/-/types-1.3.6.tgz#b2c8b2cfd7ef37c7803c07499887dfc0a716c2dc" + integrity sha512-gu+G9E04Bumc0oRdXjjKj+FgPGDj/r38iLx7yiHfWIFwaXqn+Lvmljb20nfYTVF49LDVz2jowzACRzVX4rq6kA== "@bull-board/api@3.7.0": version "3.7.0" diff --git a/packages/worker/package.json b/packages/worker/package.json index 35994a67f7..9c3a03a675 100644 --- a/packages/worker/package.json +++ b/packages/worker/package.json @@ -36,7 +36,7 @@ "license": "GPL-3.0", "dependencies": { "@budibase/backend-core": "^1.3.6", - "@budibase/pro": "1.3.5", + "@budibase/pro": "1.3.6", "@budibase/string-templates": "^1.3.6", "@budibase/types": "^1.3.6", "@koa/router": "8.0.8", diff --git a/packages/worker/yarn.lock b/packages/worker/yarn.lock index 8f339d2ab1..9647129caf 100644 --- a/packages/worker/yarn.lock +++ b/packages/worker/yarn.lock @@ -291,12 +291,12 @@ resolved "https://registry.yarnpkg.com/@bcoe/v8-coverage/-/v8-coverage-0.2.3.tgz#75a2e8b51cb758a7553d6804a5932d7aace75c39" integrity sha512-0hYQ8SB4Db5zvZB4axdMHGwEaQjkZzFjQiN9LVYvIFB2nSUHW9tYpxWriPrWDASIxiaXax83REcLxuSdnGPZtw== -"@budibase/backend-core@1.3.5": - version "1.3.5" - resolved "https://registry.yarnpkg.com/@budibase/backend-core/-/backend-core-1.3.5.tgz#67f437bfe19f7c8db03f2d64a78be561cd827df5" - integrity sha512-hhEIb1rTOQxE3aj6O2UqklHWd0dcGUBdeoNJrtmWmwSUkqjk+WBZ9WZgzeVUUtSgTUFCjMe7aup6QV+NpEteWg== +"@budibase/backend-core@1.3.6": + version "1.3.6" + resolved "https://registry.yarnpkg.com/@budibase/backend-core/-/backend-core-1.3.6.tgz#340b55a71eba228d44c8dd6107e28872a6f432d6" + integrity sha512-WIGseaoUrUWpqlbKadNuusQa1y9Ucm34AVei6oWRK1czJtLddaEt2zaMlD/qikcBB6XBJE3UML0Z82EvvdZPBQ== dependencies: - "@budibase/types" "^1.3.5" + "@budibase/types" "^1.3.6" "@techpass/passport-openidconnect" "0.3.2" aws-sdk "2.1030.0" bcrypt "5.0.1" @@ -325,21 +325,21 @@ uuid "8.3.2" zlib "1.0.5" -"@budibase/pro@1.3.5": - version "1.3.5" - resolved "https://registry.yarnpkg.com/@budibase/pro/-/pro-1.3.5.tgz#e828f5f5bbb8db69388df32fa6e7fb4de999a49b" - integrity sha512-3Pn1IW6R6DZ9J+6n2R/F0m357vjrnm/lonXpb6JcpWwSPLI5KtPIVSrKQaRxsSqc76355HSCoryGKorQIRq2Lg== +"@budibase/pro@1.3.6": + version "1.3.6" + resolved "https://registry.yarnpkg.com/@budibase/pro/-/pro-1.3.6.tgz#2ac68b341401003a25619c36137a1960b97ac01d" + integrity sha512-5QFkeR/6DdvXdIgufmqACIEEGvqXlinQrXVV45C0n95gKEXvRybv5eiWR9OO7UyYeJzQOv0PTY8O7ZtOSQrdwg== dependencies: - "@budibase/backend-core" "1.3.5" - "@budibase/types" "1.3.5" + "@budibase/backend-core" "1.3.6" + "@budibase/types" "1.3.6" "@koa/router" "8.0.8" joi "17.6.0" node-fetch "^2.6.1" -"@budibase/types@1.3.5", "@budibase/types@^1.3.5": - version "1.3.5" - resolved "https://registry.yarnpkg.com/@budibase/types/-/types-1.3.5.tgz#55cb770527085ab573f15ef0e7b28b9cae2d76ba" - integrity sha512-SSqe8ojEbSNzQHTw2OeXmVWimb/C9Hclcxif0NCCPsan2btx84yMZLO+A3GXanTqzmvSz4ZbkS7/33xwDiOHIA== +"@budibase/types@1.3.6", "@budibase/types@^1.3.6": + version "1.3.6" + resolved "https://registry.yarnpkg.com/@budibase/types/-/types-1.3.6.tgz#b2c8b2cfd7ef37c7803c07499887dfc0a716c2dc" + integrity sha512-gu+G9E04Bumc0oRdXjjKj+FgPGDj/r38iLx7yiHfWIFwaXqn+Lvmljb20nfYTVF49LDVz2jowzACRzVX4rq6kA== "@cspotcode/source-map-consumer@0.8.0": version "0.8.0" From 4a5d1b97c898d59c943bd6c477be807e0c5e5029 Mon Sep 17 00:00:00 2001 From: Peter Clement Date: Mon, 5 Sep 2022 14:39:19 +0100 Subject: [PATCH 099/203] improve responsiveness of plugins ui --- .../plugins/_components/PluginRow.svelte | 27 +++++++++++++------ packages/server/src/api/controllers/plugin.ts | 2 +- 2 files changed, 20 insertions(+), 9 deletions(-) diff --git a/packages/builder/src/pages/builder/portal/manage/plugins/_components/PluginRow.svelte b/packages/builder/src/pages/builder/portal/manage/plugins/_components/PluginRow.svelte index 30fddb2f76..848611c248 100644 --- a/packages/builder/src/pages/builder/portal/manage/plugins/_components/PluginRow.svelte +++ b/packages/builder/src/pages/builder/portal/manage/plugins/_components/PluginRow.svelte @@ -12,6 +12,11 @@ export let plugin export let deletePlugin + let icon = + plugin.schema.type === "component" + ? plugin.schema.schema.icon || "Book" + : plugin.schema.schema.icon || "Beaker" + let detailsModal @@ -19,7 +24,7 @@
- +
-
+
+ + +
+ +
-
+
-
+
-
+
-
+
@@ -88,7 +99,7 @@ diff --git a/packages/builder/src/stores/portal/plugins.js b/packages/builder/src/stores/portal/plugins.js index a3d62ca6e3..9703b30cb7 100644 --- a/packages/builder/src/stores/portal/plugins.js +++ b/packages/builder/src/stores/portal/plugins.js @@ -50,11 +50,11 @@ export function createPluginsStore() { }) } - async function uploadPlugin(file, source) { + async function uploadPlugin(file, source, updatePlugin) { let data = new FormData() data.append("file", file) data.append("source", source) - + data.append("update", updatePlugin) let resp = await API.uploadPlugin(data) let newPlugin = resp.plugins[0] update(state => { diff --git a/packages/server/src/api/controllers/plugin.ts b/packages/server/src/api/controllers/plugin.ts index ce35d2fad5..a84a077b33 100644 --- a/packages/server/src/api/controllers/plugin.ts +++ b/packages/server/src/api/controllers/plugin.ts @@ -39,7 +39,11 @@ export async function upload(ctx: any) { let docs = [] // can do single or multiple plugins for (let plugin of plugins) { - const doc = await processPlugin(plugin, ctx.request.body.source) + const doc = await processPlugin( + plugin, + ctx.request.body.source, + ctx.request.body.update + ) docs.push(doc) } ctx.body = { @@ -128,7 +132,8 @@ export async function destroy(ctx: any) { export async function storePlugin( metadata: any, directory: any, - source?: string + source?: string, + update?: boolean ) { const db = getGlobalDB() const version = metadata.package.version, @@ -167,6 +172,9 @@ export async function storePlugin( const existing = await db.get(pluginId) rev = existing._rev } catch (err) { + if (update) { + throw new Error("Unable to update. Plugin does not exist") + } rev = undefined } let doc = { @@ -185,6 +193,7 @@ export async function storePlugin( source, } } + const response = await db.put(doc) return { ...doc, @@ -192,11 +201,15 @@ export async function storePlugin( } } -export async function processPlugin(plugin: FileType, source?: string) { +export async function processPlugin( + plugin: FileType, + source?: string, + update?: boolean +) { if (!env.SELF_HOSTED) { throw new Error("Plugins not supported outside of self-host.") } const { metadata, directory } = await uploadedFilePlugin(plugin) - return await storePlugin(metadata, directory, source) + return await storePlugin(metadata, directory, source, update) } From 524669082e217d108b5c4a1586de74cb6f9d7a5f Mon Sep 17 00:00:00 2001 From: Mitch-Budibase Date: Wed, 7 Sep 2022 13:52:05 +0100 Subject: [PATCH 147/203] Update createDatasourceScreen Adding a manual wait this time go better determine the timing issue occurring against the CI runs --- packages/builder/cypress/support/commands.js | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/builder/cypress/support/commands.js b/packages/builder/cypress/support/commands.js index bb26e53d80..a07a22188f 100644 --- a/packages/builder/cypress/support/commands.js +++ b/packages/builder/cypress/support/commands.js @@ -642,6 +642,7 @@ Cypress.Commands.add( cy.intercept("**/api/datasources").as("autoScreens") cy.get(".spectrum-Button").contains("Continue").click({ force: true }) cy.wait("@autoScreens") + cy.wait(5000) }) cy.get("[data-cy='autogenerated-screens']").should("not.exist") cy.get("[data-cy='data-source-modal']", { timeout: 10000 }).within(() => { From 76870217376710fa1a8bf554fdfcc5f446dbde6c Mon Sep 17 00:00:00 2001 From: Budibase Staging Release Bot <> Date: Wed, 7 Sep 2022 13:27:13 +0000 Subject: [PATCH 148/203] v1.3.12-alpha.2 --- lerna.json | 2 +- packages/backend-core/package.json | 4 ++-- packages/bbui/package.json | 4 ++-- packages/builder/package.json | 10 +++++----- packages/cli/package.json | 8 ++++---- packages/client/package.json | 8 ++++---- packages/frontend-core/package.json | 4 ++-- packages/server/package.json | 10 +++++----- packages/string-templates/package.json | 2 +- packages/types/package.json | 2 +- packages/worker/package.json | 8 ++++---- 11 files changed, 31 insertions(+), 31 deletions(-) diff --git a/lerna.json b/lerna.json index efbd4520e1..a74e653725 100644 --- a/lerna.json +++ b/lerna.json @@ -1,5 +1,5 @@ { - "version": "1.3.12-alpha.1", + "version": "1.3.12-alpha.2", "npmClient": "yarn", "packages": [ "packages/*" diff --git a/packages/backend-core/package.json b/packages/backend-core/package.json index 0b58e3497e..5f3414bab9 100644 --- a/packages/backend-core/package.json +++ b/packages/backend-core/package.json @@ -1,6 +1,6 @@ { "name": "@budibase/backend-core", - "version": "1.3.12-alpha.1", + "version": "1.3.12-alpha.2", "description": "Budibase backend core libraries used in server and worker", "main": "dist/src/index.js", "types": "dist/src/index.d.ts", @@ -20,7 +20,7 @@ "test:watch": "jest --watchAll" }, "dependencies": { - "@budibase/types": "1.3.12-alpha.1", + "@budibase/types": "1.3.12-alpha.2", "@shopify/jest-koa-mocks": "5.0.1", "@techpass/passport-openidconnect": "0.3.2", "aws-sdk": "2.1030.0", diff --git a/packages/bbui/package.json b/packages/bbui/package.json index ee0b00a2b5..95fb5c855b 100644 --- a/packages/bbui/package.json +++ b/packages/bbui/package.json @@ -1,7 +1,7 @@ { "name": "@budibase/bbui", "description": "A UI solution used in the different Budibase projects.", - "version": "1.3.12-alpha.1", + "version": "1.3.12-alpha.2", "license": "MPL-2.0", "svelte": "src/index.js", "module": "dist/bbui.es.js", @@ -38,7 +38,7 @@ ], "dependencies": { "@adobe/spectrum-css-workflow-icons": "^1.2.1", - "@budibase/string-templates": "1.3.12-alpha.1", + "@budibase/string-templates": "1.3.12-alpha.2", "@spectrum-css/actionbutton": "^1.0.1", "@spectrum-css/actiongroup": "^1.0.1", "@spectrum-css/avatar": "^3.0.2", diff --git a/packages/builder/package.json b/packages/builder/package.json index c596412bc7..3d7e34b8d7 100644 --- a/packages/builder/package.json +++ b/packages/builder/package.json @@ -1,6 +1,6 @@ { "name": "@budibase/builder", - "version": "1.3.12-alpha.1", + "version": "1.3.12-alpha.2", "license": "GPL-3.0", "private": true, "scripts": { @@ -69,10 +69,10 @@ } }, "dependencies": { - "@budibase/bbui": "1.3.12-alpha.1", - "@budibase/client": "1.3.12-alpha.1", - "@budibase/frontend-core": "1.3.12-alpha.1", - "@budibase/string-templates": "1.3.12-alpha.1", + "@budibase/bbui": "1.3.12-alpha.2", + "@budibase/client": "1.3.12-alpha.2", + "@budibase/frontend-core": "1.3.12-alpha.2", + "@budibase/string-templates": "1.3.12-alpha.2", "@sentry/browser": "5.19.1", "@spectrum-css/page": "^3.0.1", "@spectrum-css/vars": "^3.0.1", diff --git a/packages/cli/package.json b/packages/cli/package.json index cef8ddfd72..3c11d7d624 100644 --- a/packages/cli/package.json +++ b/packages/cli/package.json @@ -1,6 +1,6 @@ { "name": "@budibase/cli", - "version": "1.3.12-alpha.1", + "version": "1.3.12-alpha.2", "description": "Budibase CLI, for developers, self hosting and migrations.", "main": "src/index.js", "bin": { @@ -26,9 +26,9 @@ "outputPath": "build" }, "dependencies": { - "@budibase/backend-core": "^1.3.12-alpha.1", - "@budibase/string-templates": "^1.3.12-alpha.1", - "@budibase/types": "^1.3.12-alpha.1", + "@budibase/backend-core": "1.3.12-alpha.2", + "@budibase/string-templates": "1.3.12-alpha.2", + "@budibase/types": "1.3.12-alpha.2", "axios": "0.21.2", "chalk": "4.1.0", "cli-progress": "3.11.2", diff --git a/packages/client/package.json b/packages/client/package.json index 139ee20c9c..1df066dbdb 100644 --- a/packages/client/package.json +++ b/packages/client/package.json @@ -1,6 +1,6 @@ { "name": "@budibase/client", - "version": "1.3.12-alpha.1", + "version": "1.3.12-alpha.2", "license": "MPL-2.0", "module": "dist/budibase-client.js", "main": "dist/budibase-client.js", @@ -19,9 +19,9 @@ "dev:builder": "rollup -cw" }, "dependencies": { - "@budibase/bbui": "1.3.12-alpha.1", - "@budibase/frontend-core": "1.3.12-alpha.1", - "@budibase/string-templates": "1.3.12-alpha.1", + "@budibase/bbui": "1.3.12-alpha.2", + "@budibase/frontend-core": "1.3.12-alpha.2", + "@budibase/string-templates": "1.3.12-alpha.2", "@spectrum-css/button": "^3.0.3", "@spectrum-css/card": "^3.0.3", "@spectrum-css/divider": "^1.0.3", diff --git a/packages/frontend-core/package.json b/packages/frontend-core/package.json index e3a888a4e4..b686e3cea5 100644 --- a/packages/frontend-core/package.json +++ b/packages/frontend-core/package.json @@ -1,12 +1,12 @@ { "name": "@budibase/frontend-core", - "version": "1.3.12-alpha.1", + "version": "1.3.12-alpha.2", "description": "Budibase frontend core libraries used in builder and client", "author": "Budibase", "license": "MPL-2.0", "svelte": "src/index.js", "dependencies": { - "@budibase/bbui": "1.3.12-alpha.1", + "@budibase/bbui": "1.3.12-alpha.2", "lodash": "^4.17.21", "svelte": "^3.46.2" } diff --git a/packages/server/package.json b/packages/server/package.json index 127945266f..5c0b41c805 100644 --- a/packages/server/package.json +++ b/packages/server/package.json @@ -1,7 +1,7 @@ { "name": "@budibase/server", "email": "hi@budibase.com", - "version": "1.3.12-alpha.1", + "version": "1.3.12-alpha.2", "description": "Budibase Web Server", "main": "src/index.ts", "repository": { @@ -77,11 +77,11 @@ "license": "GPL-3.0", "dependencies": { "@apidevtools/swagger-parser": "10.0.3", - "@budibase/backend-core": "1.3.12-alpha.1", - "@budibase/client": "1.3.12-alpha.1", + "@budibase/backend-core": "1.3.12-alpha.2", + "@budibase/client": "1.3.12-alpha.2", "@budibase/pro": "1.3.12-alpha.1", - "@budibase/string-templates": "1.3.12-alpha.1", - "@budibase/types": "1.3.12-alpha.1", + "@budibase/string-templates": "1.3.12-alpha.2", + "@budibase/types": "1.3.12-alpha.2", "@bull-board/api": "3.7.0", "@bull-board/koa": "3.9.4", "@elastic/elasticsearch": "7.10.0", diff --git a/packages/string-templates/package.json b/packages/string-templates/package.json index fa20295974..3c2e35aba6 100644 --- a/packages/string-templates/package.json +++ b/packages/string-templates/package.json @@ -1,6 +1,6 @@ { "name": "@budibase/string-templates", - "version": "1.3.12-alpha.1", + "version": "1.3.12-alpha.2", "description": "Handlebars wrapper for Budibase templating.", "main": "src/index.cjs", "module": "dist/bundle.mjs", diff --git a/packages/types/package.json b/packages/types/package.json index 6af650da47..c5164852ed 100644 --- a/packages/types/package.json +++ b/packages/types/package.json @@ -1,6 +1,6 @@ { "name": "@budibase/types", - "version": "1.3.12-alpha.1", + "version": "1.3.12-alpha.2", "description": "Budibase types", "main": "dist/index.js", "types": "dist/index.d.ts", diff --git a/packages/worker/package.json b/packages/worker/package.json index d0f391ed41..1547f24b30 100644 --- a/packages/worker/package.json +++ b/packages/worker/package.json @@ -1,7 +1,7 @@ { "name": "@budibase/worker", "email": "hi@budibase.com", - "version": "1.3.12-alpha.1", + "version": "1.3.12-alpha.2", "description": "Budibase background service", "main": "src/index.ts", "repository": { @@ -35,10 +35,10 @@ "author": "Budibase", "license": "GPL-3.0", "dependencies": { - "@budibase/backend-core": "1.3.12-alpha.1", + "@budibase/backend-core": "1.3.12-alpha.2", "@budibase/pro": "1.3.12-alpha.1", - "@budibase/string-templates": "1.3.12-alpha.1", - "@budibase/types": "1.3.12-alpha.1", + "@budibase/string-templates": "1.3.12-alpha.2", + "@budibase/types": "1.3.12-alpha.2", "@koa/router": "8.0.8", "@sentry/node": "6.17.7", "@techpass/passport-openidconnect": "0.3.2", From b0ed4970fc5537c933887b560f569eb9925b2f8c Mon Sep 17 00:00:00 2001 From: Budibase Staging Release Bot <> Date: Wed, 7 Sep 2022 13:30:26 +0000 Subject: [PATCH 149/203] Update pro version to 1.3.12-alpha.2 --- packages/server/package.json | 2 +- packages/server/yarn.lock | 30 +++++++++++++++--------------- packages/worker/package.json | 2 +- packages/worker/yarn.lock | 30 +++++++++++++++--------------- 4 files changed, 32 insertions(+), 32 deletions(-) diff --git a/packages/server/package.json b/packages/server/package.json index 5c0b41c805..c72c68817d 100644 --- a/packages/server/package.json +++ b/packages/server/package.json @@ -79,7 +79,7 @@ "@apidevtools/swagger-parser": "10.0.3", "@budibase/backend-core": "1.3.12-alpha.2", "@budibase/client": "1.3.12-alpha.2", - "@budibase/pro": "1.3.12-alpha.1", + "@budibase/pro": "1.3.12-alpha.2", "@budibase/string-templates": "1.3.12-alpha.2", "@budibase/types": "1.3.12-alpha.2", "@bull-board/api": "3.7.0", diff --git a/packages/server/yarn.lock b/packages/server/yarn.lock index ff811617dc..2a3db0f037 100644 --- a/packages/server/yarn.lock +++ b/packages/server/yarn.lock @@ -1094,12 +1094,12 @@ resolved "https://registry.yarnpkg.com/@bcoe/v8-coverage/-/v8-coverage-0.2.3.tgz#75a2e8b51cb758a7553d6804a5932d7aace75c39" integrity sha512-0hYQ8SB4Db5zvZB4axdMHGwEaQjkZzFjQiN9LVYvIFB2nSUHW9tYpxWriPrWDASIxiaXax83REcLxuSdnGPZtw== -"@budibase/backend-core@1.3.12-alpha.1": - version "1.3.12-alpha.1" - resolved "https://registry.yarnpkg.com/@budibase/backend-core/-/backend-core-1.3.12-alpha.1.tgz#a38f36610a4880b5f8c18192d82244a431c28a86" - integrity sha512-V1rtNBMob3BJjOGeMyvro2tqYoC85TSIO8wyJf1c4DRpPN0rW3s6MjSmVItqtZlbrcnHmxKFr4PDFDIBJaHnbg== +"@budibase/backend-core@1.3.12-alpha.2": + version "1.3.12-alpha.2" + resolved "https://registry.yarnpkg.com/@budibase/backend-core/-/backend-core-1.3.12-alpha.2.tgz#cab9edd5bde68c245c1b01e29bdd1468cfb10031" + integrity sha512-8NEGk71xnctP9xHGhC9Y5Dy3ilBE8HAW6WtWueOv7SZupa6Y5x0hdtzaJJY1/6oEqnhW/eGYXvPQpffOtfpgYg== dependencies: - "@budibase/types" "1.3.12-alpha.1" + "@budibase/types" "1.3.12-alpha.2" "@shopify/jest-koa-mocks" "5.0.1" "@techpass/passport-openidconnect" "0.3.2" aws-sdk "2.1030.0" @@ -1179,13 +1179,13 @@ svelte-flatpickr "^3.2.3" svelte-portal "^1.0.0" -"@budibase/pro@1.3.12-alpha.1": - version "1.3.12-alpha.1" - resolved "https://registry.yarnpkg.com/@budibase/pro/-/pro-1.3.12-alpha.1.tgz#5161f3c646e275fd7f9a72abf817fb407cfd6efe" - integrity sha512-lzsZeZuUGqs8eRsCB3T7yBo4yS7z7L3N2qW9Pzh7/VBwFv4NdQH56tniXCf3oFfxsQ+6xH++vklfRxddID/Dfg== +"@budibase/pro@1.3.12-alpha.2": + version "1.3.12-alpha.2" + resolved "https://registry.yarnpkg.com/@budibase/pro/-/pro-1.3.12-alpha.2.tgz#d49accc3c6258e4a258ed60046aa8756f2993895" + integrity sha512-gu/nKTKtHIhqeLrvQfB1z6sIEePWN3453TtVldPgDdl4luVcax4RhktWAw4/Bxyn/NyU80rNjcmBTlMh59Hj0A== dependencies: - "@budibase/backend-core" "1.3.12-alpha.1" - "@budibase/types" "1.3.12-alpha.1" + "@budibase/backend-core" "1.3.12-alpha.2" + "@budibase/types" "1.3.12-alpha.2" "@koa/router" "8.0.8" joi "17.6.0" node-fetch "^2.6.1" @@ -1208,10 +1208,10 @@ svelte-apexcharts "^1.0.2" svelte-flatpickr "^3.1.0" -"@budibase/types@1.3.12-alpha.1": - version "1.3.12-alpha.1" - resolved "https://registry.yarnpkg.com/@budibase/types/-/types-1.3.12-alpha.1.tgz#18fda1652a757479be45fe096235af1b966ca49c" - integrity sha512-dNP+9zRKX7cYjwL+0/zdlYnMGMUWSyw3Vi+YmWNdXVcQnMXsc9gSbODBQMNv4YNqXBBC+0xgo/A5wRqWhZFL6g== +"@budibase/types@1.3.12-alpha.2": + version "1.3.12-alpha.2" + resolved "https://registry.yarnpkg.com/@budibase/types/-/types-1.3.12-alpha.2.tgz#e95c6d963000c5b561e8c3007df02ae8fd2a4869" + integrity sha512-pyw10xOPb78deK3aZzhpYuXMGBVrUzAb7Z5AANzDFvi4ggInY6c2GGjrzL/PfHy3DeLZkYnPDxkvaF6GNF6Txw== "@bull-board/api@3.7.0": version "3.7.0" diff --git a/packages/worker/package.json b/packages/worker/package.json index 1547f24b30..85b7e4be7e 100644 --- a/packages/worker/package.json +++ b/packages/worker/package.json @@ -36,7 +36,7 @@ "license": "GPL-3.0", "dependencies": { "@budibase/backend-core": "1.3.12-alpha.2", - "@budibase/pro": "1.3.12-alpha.1", + "@budibase/pro": "1.3.12-alpha.2", "@budibase/string-templates": "1.3.12-alpha.2", "@budibase/types": "1.3.12-alpha.2", "@koa/router": "8.0.8", diff --git a/packages/worker/yarn.lock b/packages/worker/yarn.lock index 431c655d1f..52ab196d8f 100644 --- a/packages/worker/yarn.lock +++ b/packages/worker/yarn.lock @@ -291,12 +291,12 @@ resolved "https://registry.yarnpkg.com/@bcoe/v8-coverage/-/v8-coverage-0.2.3.tgz#75a2e8b51cb758a7553d6804a5932d7aace75c39" integrity sha512-0hYQ8SB4Db5zvZB4axdMHGwEaQjkZzFjQiN9LVYvIFB2nSUHW9tYpxWriPrWDASIxiaXax83REcLxuSdnGPZtw== -"@budibase/backend-core@1.3.12-alpha.1": - version "1.3.12-alpha.1" - resolved "https://registry.yarnpkg.com/@budibase/backend-core/-/backend-core-1.3.12-alpha.1.tgz#a38f36610a4880b5f8c18192d82244a431c28a86" - integrity sha512-V1rtNBMob3BJjOGeMyvro2tqYoC85TSIO8wyJf1c4DRpPN0rW3s6MjSmVItqtZlbrcnHmxKFr4PDFDIBJaHnbg== +"@budibase/backend-core@1.3.12-alpha.2": + version "1.3.12-alpha.2" + resolved "https://registry.yarnpkg.com/@budibase/backend-core/-/backend-core-1.3.12-alpha.2.tgz#cab9edd5bde68c245c1b01e29bdd1468cfb10031" + integrity sha512-8NEGk71xnctP9xHGhC9Y5Dy3ilBE8HAW6WtWueOv7SZupa6Y5x0hdtzaJJY1/6oEqnhW/eGYXvPQpffOtfpgYg== dependencies: - "@budibase/types" "1.3.12-alpha.1" + "@budibase/types" "1.3.12-alpha.2" "@shopify/jest-koa-mocks" "5.0.1" "@techpass/passport-openidconnect" "0.3.2" aws-sdk "2.1030.0" @@ -326,21 +326,21 @@ uuid "8.3.2" zlib "1.0.5" -"@budibase/pro@1.3.12-alpha.1": - version "1.3.12-alpha.1" - resolved "https://registry.yarnpkg.com/@budibase/pro/-/pro-1.3.12-alpha.1.tgz#5161f3c646e275fd7f9a72abf817fb407cfd6efe" - integrity sha512-lzsZeZuUGqs8eRsCB3T7yBo4yS7z7L3N2qW9Pzh7/VBwFv4NdQH56tniXCf3oFfxsQ+6xH++vklfRxddID/Dfg== +"@budibase/pro@1.3.12-alpha.2": + version "1.3.12-alpha.2" + resolved "https://registry.yarnpkg.com/@budibase/pro/-/pro-1.3.12-alpha.2.tgz#d49accc3c6258e4a258ed60046aa8756f2993895" + integrity sha512-gu/nKTKtHIhqeLrvQfB1z6sIEePWN3453TtVldPgDdl4luVcax4RhktWAw4/Bxyn/NyU80rNjcmBTlMh59Hj0A== dependencies: - "@budibase/backend-core" "1.3.12-alpha.1" - "@budibase/types" "1.3.12-alpha.1" + "@budibase/backend-core" "1.3.12-alpha.2" + "@budibase/types" "1.3.12-alpha.2" "@koa/router" "8.0.8" joi "17.6.0" node-fetch "^2.6.1" -"@budibase/types@1.3.12-alpha.1": - version "1.3.12-alpha.1" - resolved "https://registry.yarnpkg.com/@budibase/types/-/types-1.3.12-alpha.1.tgz#18fda1652a757479be45fe096235af1b966ca49c" - integrity sha512-dNP+9zRKX7cYjwL+0/zdlYnMGMUWSyw3Vi+YmWNdXVcQnMXsc9gSbODBQMNv4YNqXBBC+0xgo/A5wRqWhZFL6g== +"@budibase/types@1.3.12-alpha.2": + version "1.3.12-alpha.2" + resolved "https://registry.yarnpkg.com/@budibase/types/-/types-1.3.12-alpha.2.tgz#e95c6d963000c5b561e8c3007df02ae8fd2a4869" + integrity sha512-pyw10xOPb78deK3aZzhpYuXMGBVrUzAb7Z5AANzDFvi4ggInY6c2GGjrzL/PfHy3DeLZkYnPDxkvaF6GNF6Txw== "@cspotcode/source-map-consumer@0.8.0": version "0.8.0" From ae3463fc7b3e4a887d3621cf7fe2ebf0bbb100bd Mon Sep 17 00:00:00 2001 From: Mitch-Budibase Date: Wed, 7 Sep 2022 15:42:45 +0100 Subject: [PATCH 150/203] Oracle + datasource Wizard Test skips Skipping tests for Oracle & datasourceWizard Both are covered during general regressions There are timing issues associated with the CI Smoke run This will help reduce the smoke build run time The oracle test file was only covering a basic check of invalid configuration (Not essential for the smoke run) --- .../cypress/integration/datasources/datasourceWizard.spec.js | 2 +- packages/builder/cypress/integration/datasources/oracle.spec.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/builder/cypress/integration/datasources/datasourceWizard.spec.js b/packages/builder/cypress/integration/datasources/datasourceWizard.spec.js index 14653d8286..837a433951 100644 --- a/packages/builder/cypress/integration/datasources/datasourceWizard.spec.js +++ b/packages/builder/cypress/integration/datasources/datasourceWizard.spec.js @@ -1,7 +1,7 @@ import filterTests from "../../support/filterTests" filterTests(['all'], () => { - context("Datasource Wizard", () => { + xcontext("Datasource Wizard", () => { if (Cypress.env("TEST_ENV")) { before(() => { cy.login() diff --git a/packages/builder/cypress/integration/datasources/oracle.spec.js b/packages/builder/cypress/integration/datasources/oracle.spec.js index 92a5737ff9..5d92d6b217 100644 --- a/packages/builder/cypress/integration/datasources/oracle.spec.js +++ b/packages/builder/cypress/integration/datasources/oracle.spec.js @@ -1,7 +1,7 @@ import filterTests from "../../support/filterTests" filterTests(["all"], () => { - context("Oracle Datasource Testing", () => { + xcontext("Oracle Datasource Testing", () => { if (Cypress.env("TEST_ENV")) { before(() => { cy.login() From 1e75e7c1e3f37d67972d06b6aae505f755683f8d Mon Sep 17 00:00:00 2001 From: Peter Clement Date: Wed, 7 Sep 2022 16:08:29 +0100 Subject: [PATCH 151/203] remove verify and fix deletion bug --- packages/bbui/src/Modal/ModalContent.svelte | 3 +- .../plugins/_components/AddPluginModal.svelte | 49 ++-------------- .../_components/DeletePluginModal.svelte | 5 +- .../plugins/_components/PluginRow.svelte | 58 +------------------ packages/builder/src/stores/portal/plugins.js | 3 +- packages/server/src/api/controllers/plugin.ts | 20 ++----- 6 files changed, 15 insertions(+), 123 deletions(-) diff --git a/packages/bbui/src/Modal/ModalContent.svelte b/packages/bbui/src/Modal/ModalContent.svelte index d946268da6..25fac63ec8 100644 --- a/packages/bbui/src/Modal/ModalContent.svelte +++ b/packages/bbui/src/Modal/ModalContent.svelte @@ -24,7 +24,6 @@ export let secondaryAction = undefined export let secondaryButtonWarning = false export let dataCy = null - export let buttonCta = true const { hide, cancel } = getContext(Context.Modal) let loading = false $: confirmDisabled = disabled || loading @@ -113,7 +112,7 @@
{/if} {/each} - -
-
- -
-
- {#if verificationSuccessful} - Verification Successful - {:else} - Verify your source - {/if} -
-
diff --git a/packages/builder/src/stores/portal/plugins.js b/packages/builder/src/stores/portal/plugins.js index 9703b30cb7..28f9bfc42d 100644 --- a/packages/builder/src/stores/portal/plugins.js +++ b/packages/builder/src/stores/portal/plugins.js @@ -50,11 +50,10 @@ export function createPluginsStore() { }) } - async function uploadPlugin(file, source, updatePlugin) { + async function uploadPlugin(file, source) { let data = new FormData() data.append("file", file) data.append("source", source) - data.append("update", updatePlugin) let resp = await API.uploadPlugin(data) let newPlugin = resp.plugins[0] update(state => { diff --git a/packages/server/src/api/controllers/plugin.ts b/packages/server/src/api/controllers/plugin.ts index a84a077b33..cb4d592812 100644 --- a/packages/server/src/api/controllers/plugin.ts +++ b/packages/server/src/api/controllers/plugin.ts @@ -39,11 +39,7 @@ export async function upload(ctx: any) { let docs = [] // can do single or multiple plugins for (let plugin of plugins) { - const doc = await processPlugin( - plugin, - ctx.request.body.source, - ctx.request.body.update - ) + const doc = await processPlugin(plugin, ctx.request.body.source) docs.push(doc) } ctx.body = { @@ -132,8 +128,7 @@ export async function destroy(ctx: any) { export async function storePlugin( metadata: any, directory: any, - source?: string, - update?: boolean + source?: string ) { const db = getGlobalDB() const version = metadata.package.version, @@ -172,9 +167,6 @@ export async function storePlugin( const existing = await db.get(pluginId) rev = existing._rev } catch (err) { - if (update) { - throw new Error("Unable to update. Plugin does not exist") - } rev = undefined } let doc = { @@ -201,15 +193,11 @@ export async function storePlugin( } } -export async function processPlugin( - plugin: FileType, - source?: string, - update?: boolean -) { +export async function processPlugin(plugin: FileType, source?: string) { if (!env.SELF_HOSTED) { throw new Error("Plugins not supported outside of self-host.") } const { metadata, directory } = await uploadedFilePlugin(plugin) - return await storePlugin(metadata, directory, source, update) + return await storePlugin(metadata, directory, source) } From ae578a3a01f5f2b190daa56f90836f3fe674d4e5 Mon Sep 17 00:00:00 2001 From: Budibase Staging Release Bot <> Date: Wed, 7 Sep 2022 15:10:29 +0000 Subject: [PATCH 152/203] v1.3.12-alpha.3 --- lerna.json | 2 +- packages/backend-core/package.json | 4 ++-- packages/bbui/package.json | 4 ++-- packages/builder/package.json | 10 +++++----- packages/cli/package.json | 8 ++++---- packages/client/package.json | 8 ++++---- packages/frontend-core/package.json | 4 ++-- packages/server/package.json | 10 +++++----- packages/string-templates/package.json | 2 +- packages/types/package.json | 2 +- packages/worker/package.json | 8 ++++---- 11 files changed, 31 insertions(+), 31 deletions(-) diff --git a/lerna.json b/lerna.json index a74e653725..bee30cbc57 100644 --- a/lerna.json +++ b/lerna.json @@ -1,5 +1,5 @@ { - "version": "1.3.12-alpha.2", + "version": "1.3.12-alpha.3", "npmClient": "yarn", "packages": [ "packages/*" diff --git a/packages/backend-core/package.json b/packages/backend-core/package.json index 5f3414bab9..3f5cb33241 100644 --- a/packages/backend-core/package.json +++ b/packages/backend-core/package.json @@ -1,6 +1,6 @@ { "name": "@budibase/backend-core", - "version": "1.3.12-alpha.2", + "version": "1.3.12-alpha.3", "description": "Budibase backend core libraries used in server and worker", "main": "dist/src/index.js", "types": "dist/src/index.d.ts", @@ -20,7 +20,7 @@ "test:watch": "jest --watchAll" }, "dependencies": { - "@budibase/types": "1.3.12-alpha.2", + "@budibase/types": "1.3.12-alpha.3", "@shopify/jest-koa-mocks": "5.0.1", "@techpass/passport-openidconnect": "0.3.2", "aws-sdk": "2.1030.0", diff --git a/packages/bbui/package.json b/packages/bbui/package.json index 95fb5c855b..c9e35848f3 100644 --- a/packages/bbui/package.json +++ b/packages/bbui/package.json @@ -1,7 +1,7 @@ { "name": "@budibase/bbui", "description": "A UI solution used in the different Budibase projects.", - "version": "1.3.12-alpha.2", + "version": "1.3.12-alpha.3", "license": "MPL-2.0", "svelte": "src/index.js", "module": "dist/bbui.es.js", @@ -38,7 +38,7 @@ ], "dependencies": { "@adobe/spectrum-css-workflow-icons": "^1.2.1", - "@budibase/string-templates": "1.3.12-alpha.2", + "@budibase/string-templates": "1.3.12-alpha.3", "@spectrum-css/actionbutton": "^1.0.1", "@spectrum-css/actiongroup": "^1.0.1", "@spectrum-css/avatar": "^3.0.2", diff --git a/packages/builder/package.json b/packages/builder/package.json index 3d7e34b8d7..fb5a3d2244 100644 --- a/packages/builder/package.json +++ b/packages/builder/package.json @@ -1,6 +1,6 @@ { "name": "@budibase/builder", - "version": "1.3.12-alpha.2", + "version": "1.3.12-alpha.3", "license": "GPL-3.0", "private": true, "scripts": { @@ -69,10 +69,10 @@ } }, "dependencies": { - "@budibase/bbui": "1.3.12-alpha.2", - "@budibase/client": "1.3.12-alpha.2", - "@budibase/frontend-core": "1.3.12-alpha.2", - "@budibase/string-templates": "1.3.12-alpha.2", + "@budibase/bbui": "1.3.12-alpha.3", + "@budibase/client": "1.3.12-alpha.3", + "@budibase/frontend-core": "1.3.12-alpha.3", + "@budibase/string-templates": "1.3.12-alpha.3", "@sentry/browser": "5.19.1", "@spectrum-css/page": "^3.0.1", "@spectrum-css/vars": "^3.0.1", diff --git a/packages/cli/package.json b/packages/cli/package.json index 3c11d7d624..497933ea76 100644 --- a/packages/cli/package.json +++ b/packages/cli/package.json @@ -1,6 +1,6 @@ { "name": "@budibase/cli", - "version": "1.3.12-alpha.2", + "version": "1.3.12-alpha.3", "description": "Budibase CLI, for developers, self hosting and migrations.", "main": "src/index.js", "bin": { @@ -26,9 +26,9 @@ "outputPath": "build" }, "dependencies": { - "@budibase/backend-core": "1.3.12-alpha.2", - "@budibase/string-templates": "1.3.12-alpha.2", - "@budibase/types": "1.3.12-alpha.2", + "@budibase/backend-core": "1.3.12-alpha.3", + "@budibase/string-templates": "1.3.12-alpha.3", + "@budibase/types": "1.3.12-alpha.3", "axios": "0.21.2", "chalk": "4.1.0", "cli-progress": "3.11.2", diff --git a/packages/client/package.json b/packages/client/package.json index 1df066dbdb..9166a8ead2 100644 --- a/packages/client/package.json +++ b/packages/client/package.json @@ -1,6 +1,6 @@ { "name": "@budibase/client", - "version": "1.3.12-alpha.2", + "version": "1.3.12-alpha.3", "license": "MPL-2.0", "module": "dist/budibase-client.js", "main": "dist/budibase-client.js", @@ -19,9 +19,9 @@ "dev:builder": "rollup -cw" }, "dependencies": { - "@budibase/bbui": "1.3.12-alpha.2", - "@budibase/frontend-core": "1.3.12-alpha.2", - "@budibase/string-templates": "1.3.12-alpha.2", + "@budibase/bbui": "1.3.12-alpha.3", + "@budibase/frontend-core": "1.3.12-alpha.3", + "@budibase/string-templates": "1.3.12-alpha.3", "@spectrum-css/button": "^3.0.3", "@spectrum-css/card": "^3.0.3", "@spectrum-css/divider": "^1.0.3", diff --git a/packages/frontend-core/package.json b/packages/frontend-core/package.json index b686e3cea5..823a6a7458 100644 --- a/packages/frontend-core/package.json +++ b/packages/frontend-core/package.json @@ -1,12 +1,12 @@ { "name": "@budibase/frontend-core", - "version": "1.3.12-alpha.2", + "version": "1.3.12-alpha.3", "description": "Budibase frontend core libraries used in builder and client", "author": "Budibase", "license": "MPL-2.0", "svelte": "src/index.js", "dependencies": { - "@budibase/bbui": "1.3.12-alpha.2", + "@budibase/bbui": "1.3.12-alpha.3", "lodash": "^4.17.21", "svelte": "^3.46.2" } diff --git a/packages/server/package.json b/packages/server/package.json index c72c68817d..8524eebe27 100644 --- a/packages/server/package.json +++ b/packages/server/package.json @@ -1,7 +1,7 @@ { "name": "@budibase/server", "email": "hi@budibase.com", - "version": "1.3.12-alpha.2", + "version": "1.3.12-alpha.3", "description": "Budibase Web Server", "main": "src/index.ts", "repository": { @@ -77,11 +77,11 @@ "license": "GPL-3.0", "dependencies": { "@apidevtools/swagger-parser": "10.0.3", - "@budibase/backend-core": "1.3.12-alpha.2", - "@budibase/client": "1.3.12-alpha.2", + "@budibase/backend-core": "1.3.12-alpha.3", + "@budibase/client": "1.3.12-alpha.3", "@budibase/pro": "1.3.12-alpha.2", - "@budibase/string-templates": "1.3.12-alpha.2", - "@budibase/types": "1.3.12-alpha.2", + "@budibase/string-templates": "1.3.12-alpha.3", + "@budibase/types": "1.3.12-alpha.3", "@bull-board/api": "3.7.0", "@bull-board/koa": "3.9.4", "@elastic/elasticsearch": "7.10.0", diff --git a/packages/string-templates/package.json b/packages/string-templates/package.json index 3c2e35aba6..da6ace54e7 100644 --- a/packages/string-templates/package.json +++ b/packages/string-templates/package.json @@ -1,6 +1,6 @@ { "name": "@budibase/string-templates", - "version": "1.3.12-alpha.2", + "version": "1.3.12-alpha.3", "description": "Handlebars wrapper for Budibase templating.", "main": "src/index.cjs", "module": "dist/bundle.mjs", diff --git a/packages/types/package.json b/packages/types/package.json index c5164852ed..84f7431d7d 100644 --- a/packages/types/package.json +++ b/packages/types/package.json @@ -1,6 +1,6 @@ { "name": "@budibase/types", - "version": "1.3.12-alpha.2", + "version": "1.3.12-alpha.3", "description": "Budibase types", "main": "dist/index.js", "types": "dist/index.d.ts", diff --git a/packages/worker/package.json b/packages/worker/package.json index 85b7e4be7e..e5a5968084 100644 --- a/packages/worker/package.json +++ b/packages/worker/package.json @@ -1,7 +1,7 @@ { "name": "@budibase/worker", "email": "hi@budibase.com", - "version": "1.3.12-alpha.2", + "version": "1.3.12-alpha.3", "description": "Budibase background service", "main": "src/index.ts", "repository": { @@ -35,10 +35,10 @@ "author": "Budibase", "license": "GPL-3.0", "dependencies": { - "@budibase/backend-core": "1.3.12-alpha.2", + "@budibase/backend-core": "1.3.12-alpha.3", "@budibase/pro": "1.3.12-alpha.2", - "@budibase/string-templates": "1.3.12-alpha.2", - "@budibase/types": "1.3.12-alpha.2", + "@budibase/string-templates": "1.3.12-alpha.3", + "@budibase/types": "1.3.12-alpha.3", "@koa/router": "8.0.8", "@sentry/node": "6.17.7", "@techpass/passport-openidconnect": "0.3.2", From c737168718ca4d3599afec93fb5748b17f93786a Mon Sep 17 00:00:00 2001 From: Budibase Staging Release Bot <> Date: Wed, 7 Sep 2022 15:13:50 +0000 Subject: [PATCH 153/203] Update pro version to 1.3.12-alpha.3 --- packages/server/package.json | 2 +- packages/server/yarn.lock | 30 +++++++++++++++--------------- packages/worker/package.json | 2 +- packages/worker/yarn.lock | 30 +++++++++++++++--------------- 4 files changed, 32 insertions(+), 32 deletions(-) diff --git a/packages/server/package.json b/packages/server/package.json index 8524eebe27..896d920045 100644 --- a/packages/server/package.json +++ b/packages/server/package.json @@ -79,7 +79,7 @@ "@apidevtools/swagger-parser": "10.0.3", "@budibase/backend-core": "1.3.12-alpha.3", "@budibase/client": "1.3.12-alpha.3", - "@budibase/pro": "1.3.12-alpha.2", + "@budibase/pro": "1.3.12-alpha.3", "@budibase/string-templates": "1.3.12-alpha.3", "@budibase/types": "1.3.12-alpha.3", "@bull-board/api": "3.7.0", diff --git a/packages/server/yarn.lock b/packages/server/yarn.lock index 2a3db0f037..d89a21f0d3 100644 --- a/packages/server/yarn.lock +++ b/packages/server/yarn.lock @@ -1094,12 +1094,12 @@ resolved "https://registry.yarnpkg.com/@bcoe/v8-coverage/-/v8-coverage-0.2.3.tgz#75a2e8b51cb758a7553d6804a5932d7aace75c39" integrity sha512-0hYQ8SB4Db5zvZB4axdMHGwEaQjkZzFjQiN9LVYvIFB2nSUHW9tYpxWriPrWDASIxiaXax83REcLxuSdnGPZtw== -"@budibase/backend-core@1.3.12-alpha.2": - version "1.3.12-alpha.2" - resolved "https://registry.yarnpkg.com/@budibase/backend-core/-/backend-core-1.3.12-alpha.2.tgz#cab9edd5bde68c245c1b01e29bdd1468cfb10031" - integrity sha512-8NEGk71xnctP9xHGhC9Y5Dy3ilBE8HAW6WtWueOv7SZupa6Y5x0hdtzaJJY1/6oEqnhW/eGYXvPQpffOtfpgYg== +"@budibase/backend-core@1.3.12-alpha.3": + version "1.3.12-alpha.3" + resolved "https://registry.yarnpkg.com/@budibase/backend-core/-/backend-core-1.3.12-alpha.3.tgz#baf7ea0590db9e49db08e4e05b7d374a2ed05f20" + integrity sha512-8xkaJX2kA2n7LKNXJ9SSyQnvOYRPDxiZ6BKDEPNoOa0WjYZ/htCnUJxgjdnSSzSojqfdDf8eqxa+pGXA87ZU6Q== dependencies: - "@budibase/types" "1.3.12-alpha.2" + "@budibase/types" "1.3.12-alpha.3" "@shopify/jest-koa-mocks" "5.0.1" "@techpass/passport-openidconnect" "0.3.2" aws-sdk "2.1030.0" @@ -1179,13 +1179,13 @@ svelte-flatpickr "^3.2.3" svelte-portal "^1.0.0" -"@budibase/pro@1.3.12-alpha.2": - version "1.3.12-alpha.2" - resolved "https://registry.yarnpkg.com/@budibase/pro/-/pro-1.3.12-alpha.2.tgz#d49accc3c6258e4a258ed60046aa8756f2993895" - integrity sha512-gu/nKTKtHIhqeLrvQfB1z6sIEePWN3453TtVldPgDdl4luVcax4RhktWAw4/Bxyn/NyU80rNjcmBTlMh59Hj0A== +"@budibase/pro@1.3.12-alpha.3": + version "1.3.12-alpha.3" + resolved "https://registry.yarnpkg.com/@budibase/pro/-/pro-1.3.12-alpha.3.tgz#30dce4ba54aa7c19b60d6faf2852e3402c81ee50" + integrity sha512-qDddYE6XNbiNIpADUIhXWvgBjJMNxWhHdCpS7Qoci2tmoS4ofLlh5C8qKJuddg3RaLkWIQmII/p/ZnZ0uQ3E9A== dependencies: - "@budibase/backend-core" "1.3.12-alpha.2" - "@budibase/types" "1.3.12-alpha.2" + "@budibase/backend-core" "1.3.12-alpha.3" + "@budibase/types" "1.3.12-alpha.3" "@koa/router" "8.0.8" joi "17.6.0" node-fetch "^2.6.1" @@ -1208,10 +1208,10 @@ svelte-apexcharts "^1.0.2" svelte-flatpickr "^3.1.0" -"@budibase/types@1.3.12-alpha.2": - version "1.3.12-alpha.2" - resolved "https://registry.yarnpkg.com/@budibase/types/-/types-1.3.12-alpha.2.tgz#e95c6d963000c5b561e8c3007df02ae8fd2a4869" - integrity sha512-pyw10xOPb78deK3aZzhpYuXMGBVrUzAb7Z5AANzDFvi4ggInY6c2GGjrzL/PfHy3DeLZkYnPDxkvaF6GNF6Txw== +"@budibase/types@1.3.12-alpha.3": + version "1.3.12-alpha.3" + resolved "https://registry.yarnpkg.com/@budibase/types/-/types-1.3.12-alpha.3.tgz#26c5f168281f5ead4a108af2918ce9810d92d239" + integrity sha512-dvs+KWlu+DdaVKAA6vU2qTZJmS4ACIllBSSjDeG0sGOBkIlGJSi5aC6zvkPXpaaZlbDQpDwao/9xNP+Ub8wj1g== "@bull-board/api@3.7.0": version "3.7.0" diff --git a/packages/worker/package.json b/packages/worker/package.json index e5a5968084..79754d4ee0 100644 --- a/packages/worker/package.json +++ b/packages/worker/package.json @@ -36,7 +36,7 @@ "license": "GPL-3.0", "dependencies": { "@budibase/backend-core": "1.3.12-alpha.3", - "@budibase/pro": "1.3.12-alpha.2", + "@budibase/pro": "1.3.12-alpha.3", "@budibase/string-templates": "1.3.12-alpha.3", "@budibase/types": "1.3.12-alpha.3", "@koa/router": "8.0.8", diff --git a/packages/worker/yarn.lock b/packages/worker/yarn.lock index 52ab196d8f..02d5bc0e3a 100644 --- a/packages/worker/yarn.lock +++ b/packages/worker/yarn.lock @@ -291,12 +291,12 @@ resolved "https://registry.yarnpkg.com/@bcoe/v8-coverage/-/v8-coverage-0.2.3.tgz#75a2e8b51cb758a7553d6804a5932d7aace75c39" integrity sha512-0hYQ8SB4Db5zvZB4axdMHGwEaQjkZzFjQiN9LVYvIFB2nSUHW9tYpxWriPrWDASIxiaXax83REcLxuSdnGPZtw== -"@budibase/backend-core@1.3.12-alpha.2": - version "1.3.12-alpha.2" - resolved "https://registry.yarnpkg.com/@budibase/backend-core/-/backend-core-1.3.12-alpha.2.tgz#cab9edd5bde68c245c1b01e29bdd1468cfb10031" - integrity sha512-8NEGk71xnctP9xHGhC9Y5Dy3ilBE8HAW6WtWueOv7SZupa6Y5x0hdtzaJJY1/6oEqnhW/eGYXvPQpffOtfpgYg== +"@budibase/backend-core@1.3.12-alpha.3": + version "1.3.12-alpha.3" + resolved "https://registry.yarnpkg.com/@budibase/backend-core/-/backend-core-1.3.12-alpha.3.tgz#baf7ea0590db9e49db08e4e05b7d374a2ed05f20" + integrity sha512-8xkaJX2kA2n7LKNXJ9SSyQnvOYRPDxiZ6BKDEPNoOa0WjYZ/htCnUJxgjdnSSzSojqfdDf8eqxa+pGXA87ZU6Q== dependencies: - "@budibase/types" "1.3.12-alpha.2" + "@budibase/types" "1.3.12-alpha.3" "@shopify/jest-koa-mocks" "5.0.1" "@techpass/passport-openidconnect" "0.3.2" aws-sdk "2.1030.0" @@ -326,21 +326,21 @@ uuid "8.3.2" zlib "1.0.5" -"@budibase/pro@1.3.12-alpha.2": - version "1.3.12-alpha.2" - resolved "https://registry.yarnpkg.com/@budibase/pro/-/pro-1.3.12-alpha.2.tgz#d49accc3c6258e4a258ed60046aa8756f2993895" - integrity sha512-gu/nKTKtHIhqeLrvQfB1z6sIEePWN3453TtVldPgDdl4luVcax4RhktWAw4/Bxyn/NyU80rNjcmBTlMh59Hj0A== +"@budibase/pro@1.3.12-alpha.3": + version "1.3.12-alpha.3" + resolved "https://registry.yarnpkg.com/@budibase/pro/-/pro-1.3.12-alpha.3.tgz#30dce4ba54aa7c19b60d6faf2852e3402c81ee50" + integrity sha512-qDddYE6XNbiNIpADUIhXWvgBjJMNxWhHdCpS7Qoci2tmoS4ofLlh5C8qKJuddg3RaLkWIQmII/p/ZnZ0uQ3E9A== dependencies: - "@budibase/backend-core" "1.3.12-alpha.2" - "@budibase/types" "1.3.12-alpha.2" + "@budibase/backend-core" "1.3.12-alpha.3" + "@budibase/types" "1.3.12-alpha.3" "@koa/router" "8.0.8" joi "17.6.0" node-fetch "^2.6.1" -"@budibase/types@1.3.12-alpha.2": - version "1.3.12-alpha.2" - resolved "https://registry.yarnpkg.com/@budibase/types/-/types-1.3.12-alpha.2.tgz#e95c6d963000c5b561e8c3007df02ae8fd2a4869" - integrity sha512-pyw10xOPb78deK3aZzhpYuXMGBVrUzAb7Z5AANzDFvi4ggInY6c2GGjrzL/PfHy3DeLZkYnPDxkvaF6GNF6Txw== +"@budibase/types@1.3.12-alpha.3": + version "1.3.12-alpha.3" + resolved "https://registry.yarnpkg.com/@budibase/types/-/types-1.3.12-alpha.3.tgz#26c5f168281f5ead4a108af2918ce9810d92d239" + integrity sha512-dvs+KWlu+DdaVKAA6vU2qTZJmS4ACIllBSSjDeG0sGOBkIlGJSi5aC6zvkPXpaaZlbDQpDwao/9xNP+Ub8wj1g== "@cspotcode/source-map-consumer@0.8.0": version "0.8.0" From dcada36111d373d2c13bbfddc3f399adfa4bb632 Mon Sep 17 00:00:00 2001 From: mike12345567 Date: Wed, 7 Sep 2022 17:05:17 +0100 Subject: [PATCH 154/203] Fix for #7431 - reboot didn't work at all previously which is why apps couldn't be published with it enabled, this is now a self host only feature, I've removed the ability to enable a reboot cron in the Cloud and it will not run the lookup/execution. --- packages/backend-core/src/db/utils.ts | 11 +++- .../automation/SetupPanel/CronBuilder.svelte | 16 ++++-- .../src/api/controllers/deploy/index.ts | 2 +- packages/server/src/automations/index.js | 9 ++-- packages/server/src/automations/triggers.js | 54 +++++++++++++++---- packages/server/src/automations/utils.ts | 30 +++++++---- packages/server/src/threads/automation.ts | 6 +++ .../types/src/documents/app/automation.ts | 4 ++ 8 files changed, 103 insertions(+), 29 deletions(-) diff --git a/packages/backend-core/src/db/utils.ts b/packages/backend-core/src/db/utils.ts index 321ebd7f58..4926a60150 100644 --- a/packages/backend-core/src/db/utils.ts +++ b/packages/backend-core/src/db/utils.ts @@ -254,7 +254,16 @@ export async function getAllApps({ dev, all, idsOnly, efficient }: any = {}) { return false }) if (idsOnly) { - return appDbNames + const devAppIds = appDbNames.filter(appId => isDevAppID(appId)) + const prodAppIds = appDbNames.filter(appId => !isDevAppID(appId)) + switch (dev) { + case true: + return devAppIds + case false: + return prodAppIds + default: + return appDbNames + } } const appPromises = appDbNames.map((app: any) => // skip setup otherwise databases could be re-created diff --git a/packages/builder/src/components/automation/SetupPanel/CronBuilder.svelte b/packages/builder/src/components/automation/SetupPanel/CronBuilder.svelte index 93b8394b49..f2da863424 100644 --- a/packages/builder/src/components/automation/SetupPanel/CronBuilder.svelte +++ b/packages/builder/src/components/automation/SetupPanel/CronBuilder.svelte @@ -1,6 +1,7 @@
diff --git a/packages/server/src/api/controllers/deploy/index.ts b/packages/server/src/api/controllers/deploy/index.ts index 86718294de..2ac6c8a15c 100644 --- a/packages/server/src/api/controllers/deploy/index.ts +++ b/packages/server/src/api/controllers/deploy/index.ts @@ -125,7 +125,7 @@ async function deployApp(deployment: any) { const prodAppDoc = await db.get(DocumentType.APP_METADATA) appDoc._rev = prodAppDoc._rev } catch (err) { - // ignore the error - doesn't exist + delete appDoc._rev } // switch to production app ID diff --git a/packages/server/src/automations/index.js b/packages/server/src/automations/index.js index 9c23e35d1c..2baa868890 100644 --- a/packages/server/src/automations/index.js +++ b/packages/server/src/automations/index.js @@ -1,16 +1,19 @@ const { processEvent } = require("./utils") const { queue, shutdown } = require("./bullboard") -const { TRIGGER_DEFINITIONS } = require("./triggers") +const { TRIGGER_DEFINITIONS, rebootTrigger } = require("./triggers") const { ACTION_DEFINITIONS } = require("./actions") /** * This module is built purely to kick off the worker farm and manage the inputs/outputs */ -exports.init = function () { +exports.init = async function () { // this promise will not complete - return queue.process(async job => { + const promise = queue.process(async job => { await processEvent(job) }) + // on init we need to trigger any reboot automations + await rebootTrigger() + return promise } exports.getQueues = () => { diff --git a/packages/server/src/automations/triggers.js b/packages/server/src/automations/triggers.js index 216f24be02..395390113a 100644 --- a/packages/server/src/automations/triggers.js +++ b/packages/server/src/automations/triggers.js @@ -9,6 +9,7 @@ const { checkTestFlag } = require("../utilities/redis") const utils = require("./utils") const env = require("../environment") const { doInAppContext, getAppDB } = require("@budibase/backend-core/context") +const { getAllApps } = require("@budibase/backend-core/db") const TRIGGER_DEFINITIONS = definitions const JOB_OPTS = { @@ -16,24 +17,27 @@ const JOB_OPTS = { removeOnFail: true, } +async function getAllAutomations() { + const db = getAppDB() + let automations = await db.allDocs( + getAutomationParams(null, { include_docs: true }) + ) + return automations.rows.map(row => row.doc) +} + async function queueRelevantRowAutomations(event, eventType) { if (event.appId == null) { throw `No appId specified for ${eventType} - check event emitters.` } doInAppContext(event.appId, async () => { - const db = getAppDB() - let automations = await db.allDocs( - getAutomationParams(null, { include_docs: true }) - ) + let automations = await getAllAutomations() // filter down to the correct event type - automations = automations.rows - .map(automation => automation.doc) - .filter(automation => { - const trigger = automation.definition.trigger - return trigger && trigger.event === eventType - }) + automations = automations.filter(automation => { + const trigger = automation.definition.trigger + return trigger && trigger.event === eventType + }) for (let automation of automations) { let automationDef = automation.definition @@ -110,4 +114,34 @@ exports.externalTrigger = async function ( } } +exports.rebootTrigger = async () => { + // reboot cron option is only available on the main thread at + // startup and only usable in self host + if (env.isInThread() || !env.SELF_HOSTED) { + return + } + // iterate through all production apps, find the reboot crons + // and trigger events for them + const appIds = await getAllApps({ dev: false, idsOnly: true }) + for (let prodAppId of appIds) { + await doInAppContext(prodAppId, async () => { + let automations = await getAllAutomations() + let rebootEvents = [] + for (let automation of automations) { + if (utils.isRebootTrigger(automation)) { + const job = { + automation, + event: { + appId: prodAppId, + timestamp: Date.now(), + }, + } + rebootEvents.push(queue.add(job, JOB_OPTS)) + } + } + await Promise.all(rebootEvents) + }) + } +} + exports.TRIGGER_DEFINITIONS = TRIGGER_DEFINITIONS diff --git a/packages/server/src/automations/utils.ts b/packages/server/src/automations/utils.ts index e0979ac0d9..3093f147dc 100644 --- a/packages/server/src/automations/utils.ts +++ b/packages/server/src/automations/utils.ts @@ -17,6 +17,7 @@ import { tenancy } from "@budibase/backend-core" import { quotas } from "@budibase/pro" import { Automation } from "@budibase/types" +const REBOOT_CRON = "@reboot" const WH_STEP_ID = definitions.WEBHOOK.stepId const CRON_STEP_ID = definitions.CRON.stepId const Runner = new Thread(ThreadType.AUTOMATION) @@ -109,22 +110,33 @@ export async function clearMetadata() { await db.bulkDocs(automationMetadata) } +export function isCronTrigger(auto: Automation) { + return ( + auto && + auto.definition.trigger && + auto.definition.trigger.stepId === CRON_STEP_ID + ) +} + +export function isRebootTrigger(auto: Automation) { + const trigger = auto ? auto.definition.trigger : null + return isCronTrigger(auto) && trigger?.inputs.cron === REBOOT_CRON +} + /** * This function handles checking of any cron jobs that need to be enabled/updated. * @param {string} appId The ID of the app in which we are checking for webhooks * @param {object|undefined} automation The automation object to be updated. */ -export async function enableCronTrigger(appId: any, automation: any) { +export async function enableCronTrigger(appId: any, automation: Automation) { const trigger = automation ? automation.definition.trigger : null - function isCronTrigger(auto: any) { - return ( - auto && - auto.definition.trigger && - auto.definition.trigger.stepId === CRON_STEP_ID - ) - } + // need to create cron job - if (isCronTrigger(automation) && trigger?.inputs.cron) { + if ( + isCronTrigger(automation) && + !isRebootTrigger(automation) && + trigger?.inputs.cron + ) { // make a job id rather than letting Bull decide, makes it easier to handle on way out const jobId = `${appId}_cron_${newid()}` const job: any = await queue.add( diff --git a/packages/server/src/threads/automation.ts b/packages/server/src/threads/automation.ts index 3136155869..f64552a92f 100644 --- a/packages/server/src/threads/automation.ts +++ b/packages/server/src/threads/automation.ts @@ -458,6 +458,9 @@ class Orchestrator { export function execute(input: AutomationEvent, callback: WorkerCallback) { const appId = input.data.event.appId + if (!appId) { + throw new Error("Unable to execute, event doesn't contain app ID.") + } doInAppContext(appId, async () => { const automationOrchestrator = new Orchestrator( input.data.automation, @@ -475,6 +478,9 @@ export function execute(input: AutomationEvent, callback: WorkerCallback) { export const removeStalled = async (input: AutomationEvent) => { const appId = input.data.event.appId + if (!appId) { + throw new Error("Unable to execute, event doesn't contain app ID.") + } await doInAppContext(appId, async () => { const automationOrchestrator = new Orchestrator( input.data.automation, diff --git a/packages/types/src/documents/app/automation.ts b/packages/types/src/documents/app/automation.ts index 50562461e4..a038e73d11 100644 --- a/packages/types/src/documents/app/automation.ts +++ b/packages/types/src/documents/app/automation.ts @@ -25,6 +25,10 @@ export interface AutomationStep { export interface AutomationTrigger { id: string stepId: string + inputs: { + [key: string]: any + } + cronJobId?: string } export enum AutomationStatus { From 6cebd08aeceb7856ddc7cccb852fe6a8a8464a49 Mon Sep 17 00:00:00 2001 From: mike12345567 Date: Wed, 7 Sep 2022 17:31:15 +0100 Subject: [PATCH 155/203] Encoding query string URI parameters for REST requests - #7683. --- packages/builder/src/helpers/data/utils.js | 2 +- packages/server/src/integrations/rest.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/builder/src/helpers/data/utils.js b/packages/builder/src/helpers/data/utils.js index 647c2be33e..cd6a8cf481 100644 --- a/packages/builder/src/helpers/data/utils.js +++ b/packages/builder/src/helpers/data/utils.js @@ -46,7 +46,7 @@ export function buildQueryString(obj) { if (str !== "") { str += "&" } - str += `${key}=${value || ""}` + str += `${key}=${encodeURIComponent(value || "")}` } } return str diff --git a/packages/server/src/integrations/rest.ts b/packages/server/src/integrations/rest.ts index 284d2a921a..59eb1e9941 100644 --- a/packages/server/src/integrations/rest.ts +++ b/packages/server/src/integrations/rest.ts @@ -215,7 +215,7 @@ module RestModule { } } - const main = `${path}?${queryString}` + const main = `${path}?${encodeURIComponent(queryString)}` let complete = main if (this.config.url && !main.startsWith("http")) { complete = !this.config.url ? main : `${this.config.url}/${main}` From 758514a0188bc43d53a2e7b8f3a8959bbb91c46f Mon Sep 17 00:00:00 2001 From: mike12345567 Date: Wed, 7 Sep 2022 17:45:14 +0100 Subject: [PATCH 156/203] Adding onTop attribute to tabs which allows setting the z-index for the container - #7679. --- packages/bbui/src/Tabs/Tabs.svelte | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/packages/bbui/src/Tabs/Tabs.svelte b/packages/bbui/src/Tabs/Tabs.svelte index 74edc9cd02..7184aedbaf 100644 --- a/packages/bbui/src/Tabs/Tabs.svelte +++ b/packages/bbui/src/Tabs/Tabs.svelte @@ -10,6 +10,7 @@ export let noHorizPadding = false export let quiet = false export let emphasized = false + export let onTop = false export let size = "M" let thisSelected = undefined @@ -75,6 +76,7 @@ bind:this={container} class:spectrum-Tabs--quiet={quiet} class:noHorizPadding + class:onTop class:spectrum-Tabs--vertical={vertical} class:spectrum-Tabs--horizontal={!vertical} class="spectrum-Tabs spectrum-Tabs--size{size}" @@ -122,4 +124,7 @@ .noPadding { margin: 0; } + .onTop { + z-index: 100; + } From e783d667a5e06279d8ff7024383155325cf2f932 Mon Sep 17 00:00:00 2001 From: Peter Clement Date: Wed, 7 Sep 2022 17:49:29 +0100 Subject: [PATCH 157/203] fix build --- .../portal/manage/plugins/_components/AddPluginModal.svelte | 6 +++--- packages/server/src/api/controllers/plugin/utils.js | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/builder/src/pages/builder/portal/manage/plugins/_components/AddPluginModal.svelte b/packages/builder/src/pages/builder/portal/manage/plugins/_components/AddPluginModal.svelte index f45eea9dc9..3520c18991 100644 --- a/packages/builder/src/pages/builder/portal/manage/plugins/_components/AddPluginModal.svelte +++ b/packages/builder/src/pages/builder/portal/manage/plugins/_components/AddPluginModal.svelte @@ -3,14 +3,14 @@ import { plugins } from "stores/portal" let authOptions = { + URL: ["Headers", "URL"], NPM: ["URL"], Github: ["Github Token", "URL"], - URL: ["Headers", "URL"], "File Upload": ["File Upload"], } let file - let sourceValue = "NPM" - let typeValue = "Datasource" + let sourceValue = "URL" + let typeValue = "Component" let dynamicValues = {} let validation diff --git a/packages/server/src/api/controllers/plugin/utils.js b/packages/server/src/api/controllers/plugin/utils.js index 86f8754a7a..df76ebc121 100644 --- a/packages/server/src/api/controllers/plugin/utils.js +++ b/packages/server/src/api/controllers/plugin/utils.js @@ -1,4 +1,3 @@ -import fetch from "node-fetch" import { createTempFolder, getPluginMetadata, @@ -8,6 +7,7 @@ import { deleteFolderFileSystem, } from "../../../utilities/fileSystem" import { join } from "path" +const fetch = require("node-fetch") export const uploadedFilePlugin = async file => { if (!file.name.endsWith(".tar.gz")) { From 673c3759345bf83a9fe32241baada8d25b4c2397 Mon Sep 17 00:00:00 2001 From: mike12345567 Date: Wed, 7 Sep 2022 17:57:02 +0100 Subject: [PATCH 158/203] Fixing an issue with external tables containing time only fields. --- packages/server/src/utilities/rowProcessor/utils.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/server/src/utilities/rowProcessor/utils.js b/packages/server/src/utilities/rowProcessor/utils.js index c80dae497c..d659cb6822 100644 --- a/packages/server/src/utilities/rowProcessor/utils.js +++ b/packages/server/src/utilities/rowProcessor/utils.js @@ -76,7 +76,7 @@ exports.processDates = (table, rows) => { if (schema.type !== FieldTypes.DATETIME) { continue } - if (!schema.ignoreTimezones) { + if (!schema.timeOnly && !schema.ignoreTimezones) { datesWithTZ.push(column) } } From 0e9dfc92275e543d43de4784e753d5b756f1e9e4 Mon Sep 17 00:00:00 2001 From: Peter Clement Date: Wed, 7 Sep 2022 18:11:17 +0100 Subject: [PATCH 159/203] fix build again --- packages/server/src/api/controllers/plugin/utils.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/server/src/api/controllers/plugin/utils.js b/packages/server/src/api/controllers/plugin/utils.js index df76ebc121..e15a72789e 100644 --- a/packages/server/src/api/controllers/plugin/utils.js +++ b/packages/server/src/api/controllers/plugin/utils.js @@ -1,12 +1,12 @@ -import { +const { createTempFolder, getPluginMetadata, findFileRec, downloadTarballDirect, extractTarball, deleteFolderFileSystem, -} from "../../../utilities/fileSystem" -import { join } from "path" +} = require("../../../utilities/fileSystem") +const join = require("path") const fetch = require("node-fetch") export const uploadedFilePlugin = async file => { From c8468c39ea580222d8ad70040d58b24d6df64bb3 Mon Sep 17 00:00:00 2001 From: mike12345567 Date: Wed, 7 Sep 2022 18:30:17 +0100 Subject: [PATCH 160/203] Fixing #6980 - fixing choice of relational foreign key field name when working with fields named differently to the primary key. --- packages/server/src/api/controllers/row/ExternalRequest.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/server/src/api/controllers/row/ExternalRequest.ts b/packages/server/src/api/controllers/row/ExternalRequest.ts index a1aecdb0f2..dd5778b9d9 100644 --- a/packages/server/src/api/controllers/row/ExternalRequest.ts +++ b/packages/server/src/api/controllers/row/ExternalRequest.ts @@ -534,7 +534,7 @@ module External { }) // this is the response from knex if no rows found const rows = !response[0].read ? response : [] - const storeTo = isMany ? field.throughFrom || linkPrimaryKey : manyKey + const storeTo = isMany ? field.throughFrom || linkPrimaryKey : fieldName related[storeTo] = { rows, isMany, tableId } } return related From c61a4df998c9fae069bda4db955fac4a4e51551a Mon Sep 17 00:00:00 2001 From: mike12345567 Date: Wed, 7 Sep 2022 19:15:05 +0100 Subject: [PATCH 161/203] Updating params in the REST interface so that they can be used in and out of the URL - meaning that updating in one place affects the other. Reduces a bit of the confusing UX around this - discussed in #7683. --- .../bindings/DrawerBindableInput.svelte | 10 ++- .../integration/KeyValueBuilder.svelte | 9 ++- .../rest/[query]/index.svelte | 66 +++++++++++++------ 3 files changed, 62 insertions(+), 23 deletions(-) diff --git a/packages/builder/src/components/common/bindings/DrawerBindableInput.svelte b/packages/builder/src/components/common/bindings/DrawerBindableInput.svelte index b8d418c62b..22d322985d 100644 --- a/packages/builder/src/components/common/bindings/DrawerBindableInput.svelte +++ b/packages/builder/src/components/common/bindings/DrawerBindableInput.svelte @@ -23,6 +23,7 @@ const dispatch = createEventDispatcher() let bindingDrawer let valid = true + let currentVal = value $: readableValue = runtimeToReadableBinding(bindings, value) $: tempValue = readableValue @@ -30,11 +31,17 @@ const saveBinding = () => { onChange(tempValue) + onBlur() bindingDrawer.hide() } const onChange = value => { - dispatch("change", readableToRuntimeBinding(bindings, value)) + currentVal = readableToRuntimeBinding(bindings, value) + dispatch("change", currentVal) + } + + const onBlur = () => { + dispatch("blur", currentVal) } @@ -45,6 +52,7 @@ readonly={isJS} value={isJS ? "(JavaScript function)" : readableValue} on:change={event => onChange(event.detail)} + on:blur={onBlur} {placeholder} {updateOnChange} /> diff --git a/packages/builder/src/components/integration/KeyValueBuilder.svelte b/packages/builder/src/components/integration/KeyValueBuilder.svelte index 4ffb380aa4..28db6b61c6 100644 --- a/packages/builder/src/components/integration/KeyValueBuilder.svelte +++ b/packages/builder/src/components/integration/KeyValueBuilder.svelte @@ -107,7 +107,7 @@ placeholder={keyPlaceholder} readonly={readOnly} bind:value={field.name} - on:change={changed} + on:blur={changed} /> {#if options} +
@@ -123,8 +115,8 @@ Platform Here you can set up general platform settings. -
-
+
+
- + {infoMessage(source)} {#each authOptions[source] as option} - {#if option === "File Upload"} + {#if option.name === PluginSource.FILE}
- + {:else}
- - +
+ + {#if option.optional} + + {/if} +
+ {#if option.name === "Headers"} + + {:else} + + {/if}
{/if} {/each} diff --git a/packages/builder/src/stores/portal/plugins.js b/packages/builder/src/stores/portal/plugins.js index bfdec9ae6b..8997e8f49d 100644 --- a/packages/builder/src/stores/portal/plugins.js +++ b/packages/builder/src/stores/portal/plugins.js @@ -1,5 +1,6 @@ import { writable } from "svelte/store" import { API } from "api" +import { PluginSource } from "constants" export function createPluginsStore() { const { subscribe, set, update } = writable([]) @@ -24,13 +25,10 @@ export function createPluginsStore() { } switch (source) { - case "url": + case PluginSource.URL: pluginData.headers = auth break - case "npm": - pluginData.npmToken = auth - break - case "github": + case PluginSource.GITHUB: pluginData.githubToken = auth break } diff --git a/packages/server/src/api/controllers/plugin/file.ts b/packages/server/src/api/controllers/plugin/file.ts new file mode 100644 index 0000000000..3b21f08387 --- /dev/null +++ b/packages/server/src/api/controllers/plugin/file.ts @@ -0,0 +1,15 @@ +import { + createTempFolder, + getPluginMetadata, + extractTarball, +} from "../../../utilities/fileSystem" + +export async function fileUpload(file: { name: string; path: string }) { + if (!file.name.endsWith(".tar.gz")) { + throw new Error("Plugin must be compressed into a gzipped tarball.") + } + const path = createTempFolder(file.name.split(".tar.gz")[0]) + await extractTarball(file.path, path) + + return await getPluginMetadata(path) +} diff --git a/packages/server/src/api/controllers/plugin/github.ts b/packages/server/src/api/controllers/plugin/github.ts new file mode 100644 index 0000000000..cbd16f2386 --- /dev/null +++ b/packages/server/src/api/controllers/plugin/github.ts @@ -0,0 +1,75 @@ +import { getPluginMetadata } from "../../../utilities/fileSystem" +import fetch from "node-fetch" +import { downloadUnzipTarball } from "./utils" + +export async function request( + url: string, + headers: { [key: string]: string }, + err: string +) { + const response = await fetch(url, { headers }) + if (response.status >= 300) { + const respErr = await response.text() + throw new Error(`Error: ${err} - ${respErr}`) + } + return response.json() +} + +export async function githubUpload(url: string, name = "", token = "") { + let githubUrl = url + + if (!githubUrl.includes("https://github.com/")) { + throw new Error("The plugin origin must be from Github") + } + + if (url.includes(".git")) { + githubUrl = url.replace(".git", "") + } + + const githubApiUrl = githubUrl.replace( + "https://github.com/", + "https://api.github.com/repos/" + ) + const headers: any = token ? { Authorization: `Bearer ${token}` } : {} + const pluginDetails = await request( + githubApiUrl, + headers, + "Repository not found" + ) + const pluginName = pluginDetails.name || name + const pluginLatestReleaseUrl = pluginDetails?.["releases_url"] + ? pluginDetails?.["releases_url"].replace("{/id}", "/latest") + : undefined + if (!pluginLatestReleaseUrl) { + throw new Error("Github release not found") + } + + const pluginReleaseDetails = await request( + pluginLatestReleaseUrl, + headers, + "Github latest release not found" + ) + const pluginReleaseTarballAsset = pluginReleaseDetails?.assets?.find( + (x: any) => x?.["content_type"] === "application/gzip" + ) + const pluginLastReleaseTarballUrl = + pluginReleaseTarballAsset?.["browser_download_url"] + if (!pluginLastReleaseTarballUrl) { + throw new Error("Github latest release url not found") + } + + try { + const path = await downloadUnzipTarball( + pluginLastReleaseTarballUrl, + pluginName, + headers + ) + return await getPluginMetadata(path) + } catch (err: any) { + let errMsg = err?.message || err + if (errMsg === "unexpected response Not Found") { + errMsg = "Github release tarball not found" + } + throw new Error(errMsg) + } +} diff --git a/packages/server/src/api/controllers/plugin/index.ts b/packages/server/src/api/controllers/plugin/index.ts index 3f3914f5ef..18a64d23a5 100644 --- a/packages/server/src/api/controllers/plugin/index.ts +++ b/packages/server/src/api/controllers/plugin/index.ts @@ -1,11 +1,6 @@ import { ObjectStoreBuckets } from "../../../constants" import { loadJSFile } from "../../../utilities/fileSystem" -import { - uploadedNpmPlugin, - uploadedUrlPlugin, - uploadedGithubPlugin, - uploadedFilePlugin, -} from "./utils" +import { npmUpload, urlUpload, githubUpload, fileUpload } from "./uploaders" import { getGlobalDB } from "@budibase/backend-core/tenancy" import { validate } from "@budibase/backend-core/plugins" import { generatePluginID, getPluginParams } from "../../../db/utils" @@ -70,20 +65,20 @@ export async function create(ctx: any) { switch (source) { case PluginSource.NPM: const { metadata: metadataNpm, directory: directoryNpm } = - await uploadedNpmPlugin(url, name) + await npmUpload(url, name) metadata = metadataNpm directory = directoryNpm break case PluginSource.GITHUB: const { metadata: metadataGithub, directory: directoryGithub } = - await uploadedGithubPlugin(ctx, url, name, githubToken) + await githubUpload(url, name, githubToken) metadata = metadataGithub directory = directoryGithub break case PluginSource.URL: - const headersObj = JSON.parse(headers || null) || {} + const headersObj = headers || {} const { metadata: metadataUrl, directory: directoryUrl } = - await uploadedUrlPlugin(url, name, headersObj) + await urlUpload(url, name, headersObj) metadata = metadataUrl directory = directoryUrl break @@ -202,6 +197,6 @@ export async function processPlugin(plugin: FileType, source?: string) { throw new Error("Plugins not supported outside of self-host.") } - const { metadata, directory } = await uploadedFilePlugin(plugin) + const { metadata, directory } = await fileUpload(plugin) return await storePlugin(metadata, directory, source) } diff --git a/packages/server/src/api/controllers/plugin/npm.ts b/packages/server/src/api/controllers/plugin/npm.ts new file mode 100644 index 0000000000..9463fad44a --- /dev/null +++ b/packages/server/src/api/controllers/plugin/npm.ts @@ -0,0 +1,56 @@ +import { + getPluginMetadata, + findFileRec, + extractTarball, + deleteFolderFileSystem, +} from "../../../utilities/fileSystem" +import fetch from "node-fetch" +import { join } from "path" +import { downloadUnzipTarball } from "./utils" + +export async function npmUpload(url: string, name: string, headers = {}) { + let npmTarballUrl = url + let pluginName = name + + if ( + !npmTarballUrl.includes("https://www.npmjs.com") && + !npmTarballUrl.includes("https://registry.npmjs.org") + ) { + throw new Error("The plugin origin must be from NPM") + } + + if (!npmTarballUrl.includes(".tgz")) { + const npmPackageURl = url.replace( + "https://www.npmjs.com/package/", + "https://registry.npmjs.org/" + ) + const response = await fetch(npmPackageURl) + if (response.status !== 200) { + throw new Error("NPM Package not found") + } + + let npmDetails = await response.json() + pluginName = npmDetails.name + const npmVersion = npmDetails["dist-tags"].latest + npmTarballUrl = npmDetails?.versions?.[npmVersion]?.dist?.tarball + + if (!npmTarballUrl) { + throw new Error("NPM tarball url not found") + } + } + + const path = await downloadUnzipTarball(npmTarballUrl, pluginName, headers) + const tarballPluginFile = findFileRec(path, ".tar.gz") + if (!tarballPluginFile) { + throw new Error("Tarball plugin file not found") + } + + try { + await extractTarball(tarballPluginFile, path) + deleteFolderFileSystem(join(path, "package")) + } catch (err: any) { + throw new Error(err) + } + + return await getPluginMetadata(path) +} diff --git a/packages/server/src/api/controllers/plugin/uploaders.ts b/packages/server/src/api/controllers/plugin/uploaders.ts new file mode 100644 index 0000000000..90b3ab2e64 --- /dev/null +++ b/packages/server/src/api/controllers/plugin/uploaders.ts @@ -0,0 +1,4 @@ +export { fileUpload } from "./file" +export { githubUpload } from "./github" +export { npmUpload } from "./npm" +export { urlUpload } from "./url" diff --git a/packages/server/src/api/controllers/plugin/url.ts b/packages/server/src/api/controllers/plugin/url.ts new file mode 100644 index 0000000000..489631e114 --- /dev/null +++ b/packages/server/src/api/controllers/plugin/url.ts @@ -0,0 +1,12 @@ +import { downloadUnzipTarball } from "./utils" +import { getPluginMetadata } from "../../../utilities/fileSystem" + +export async function urlUpload(url: string, name = "", headers = {}) { + if (!url.includes(".tar.gz")) { + throw new Error("Plugin must be compressed into a gzipped tarball.") + } + + const path = await downloadUnzipTarball(url, name, headers) + + return await getPluginMetadata(path) +} diff --git a/packages/server/src/api/controllers/plugin/utils.js b/packages/server/src/api/controllers/plugin/utils.js deleted file mode 100644 index 37d8ad6c3d..0000000000 --- a/packages/server/src/api/controllers/plugin/utils.js +++ /dev/null @@ -1,153 +0,0 @@ -const { - createTempFolder, - getPluginMetadata, - findFileRec, - downloadTarballDirect, - extractTarball, - deleteFolderFileSystem, -} = require("../../../utilities/fileSystem") -const { join } = require("path") -const fetch = require("node-fetch") - -exports.uploadedFilePlugin = async file => { - if (!file.name.endsWith(".tar.gz")) { - throw new Error("Plugin must be compressed into a gzipped tarball.") - } - const path = createTempFolder(file.name.split(".tar.gz")[0]) - await extractTarball(file.path, path) - - return await getPluginMetadata(path) -} - -exports.uploadedNpmPlugin = async (url, name, headers = {}) => { - let npmTarballUrl = url - let pluginName = name - - if ( - !npmTarballUrl.includes("https://www.npmjs.com") && - !npmTarballUrl.includes("https://registry.npmjs.org") - ) { - throw new Error("The plugin origin must be from NPM") - } - - if (!npmTarballUrl.includes(".tgz")) { - const npmPackageURl = url.replace( - "https://www.npmjs.com/package/", - "https://registry.npmjs.org/" - ) - const response = await fetch(npmPackageURl) - if (response.status !== 200) { - throw new Error("NPM Package not found") - } - - let npmDetails = await response.json() - pluginName = npmDetails.name - const npmVersion = npmDetails["dist-tags"].latest - npmTarballUrl = npmDetails?.versions?.[npmVersion]?.dist?.tarball - - if (!npmTarballUrl) { - throw new Error("NPM tarball url not found") - } - } - - const path = await downloadUnzipTarball(npmTarballUrl, pluginName, headers) - const tarballPluginFile = findFileRec(path, ".tar.gz") - if (!tarballPluginFile) { - throw new Error("Tarball plugin file not found") - } - - try { - await extractTarball(tarballPluginFile, path) - deleteFolderFileSystem(join(path, "package")) - } catch (err) { - throw new Error(err) - } - - return await getPluginMetadata(path) -} - -exports.uploadedUrlPlugin = async (url, name = "", headers = {}) => { - if (!url.includes(".tar.gz")) { - throw new Error("Plugin must be compressed into a gzipped tarball.") - } - - const path = await downloadUnzipTarball(url, name, headers) - - return await getPluginMetadata(path) -} - -exports.uploadedGithubPlugin = async (ctx, url, name = "", token = "") => { - let githubUrl = url - - if (!githubUrl.includes("https://github.com/")) { - throw new Error("The plugin origin must be from Github") - } - - if (url.includes(".git")) { - githubUrl = url.replace(".git", "") - } - - const githubApiUrl = githubUrl.replace( - "https://github.com/", - "https://api.github.com/repos/" - ) - const headers = token ? { Authorization: `Bearer ${token}` } : {} - try { - const pluginRaw = await fetch(githubApiUrl, { headers }) - if (pluginRaw.status !== 200) { - throw new Error(`Repository not found`) - } - - let pluginDetails = await pluginRaw.json() - const pluginName = pluginDetails.name || name - - const pluginLatestReleaseUrl = pluginDetails?.["releases_url"] - ? pluginDetails?.["releases_url"].replace("{/id}", "/latest") - : undefined - if (!pluginLatestReleaseUrl) { - throw new Error("Github release not found") - } - - const pluginReleaseRaw = await fetch(pluginLatestReleaseUrl, { headers }) - if (pluginReleaseRaw.status !== 200) { - throw new Error("Github latest release not found") - } - const pluginReleaseDetails = await pluginReleaseRaw.json() - const pluginReleaseTarballAsset = pluginReleaseDetails?.assets?.find( - x => x?.content_type === "application/gzip" - ) - const pluginLastReleaseTarballUrl = - pluginReleaseTarballAsset?.browser_download_url - if (!pluginLastReleaseTarballUrl) { - throw new Error("Github latest release url not found") - } - - const path = await downloadUnzipTarball( - pluginLastReleaseTarballUrl, - pluginName, - headers - ) - - return await getPluginMetadata(path) - } catch (err) { - let errMsg = err?.message || err - - if (errMsg === "unexpected response Not Found") { - errMsg = "Github release tarbal not found" - } - - throw new Error(errMsg) - } -} - -const downloadUnzipTarball = async (url, name, headers = {}) => { - try { - const path = createTempFolder(name) - - await downloadTarballDirect(url, path, headers) - - return path - } catch (e) { - throw new Error(e.message) - } -} diff --git a/packages/server/src/api/controllers/plugin/utils.ts b/packages/server/src/api/controllers/plugin/utils.ts new file mode 100644 index 0000000000..0e92fbb987 --- /dev/null +++ b/packages/server/src/api/controllers/plugin/utils.ts @@ -0,0 +1,19 @@ +import { + createTempFolder, + downloadTarballDirect, +} from "../../../utilities/fileSystem" + +export async function downloadUnzipTarball( + url: string, + name: string, + headers = {} +) { + try { + const path = createTempFolder(name) + await downloadTarballDirect(url, path, headers) + + return path + } catch (e: any) { + throw new Error(e.message) + } +} From 6fae59a608e1c3182d3521412f31b8990b8cf9ff Mon Sep 17 00:00:00 2001 From: Andrew Kingston Date: Mon, 12 Sep 2022 19:47:27 +0100 Subject: [PATCH 194/203] Update plugin description text --- .../portal/manage/plugins/_components/AddPluginModal.svelte | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/builder/src/pages/builder/portal/manage/plugins/_components/AddPluginModal.svelte b/packages/builder/src/pages/builder/portal/manage/plugins/_components/AddPluginModal.svelte index 7df0ca2a8d..9e88cdacb8 100644 --- a/packages/builder/src/pages/builder/portal/manage/plugins/_components/AddPluginModal.svelte +++ b/packages/builder/src/pages/builder/portal/manage/plugins/_components/AddPluginModal.svelte @@ -35,13 +35,13 @@ function infoMessage(optionName) { switch (optionName) { case PluginSource.URL: - return "Please specify a URL which directs to a built plugin TAR archive, you can provide headers if authentication is required." + return "Please specify a URL which directs to a built plugin TAR archive. You can provide headers if authentication is required." case PluginSource.NPM: return "Please specify the URL to a public NPM package which contains the built version of the plugin you wish to install." case PluginSource.GITHUB: return "Please specify the URL to a Github repository which contains built plugin releases. If this is a private repo you can provide a token to access it." case PluginSource.FILE: - return "Please provide a built plugin TAR archive, you can build a plugin locally using the Budibase CLI." + return "Please provide a built plugin TAR archive. You can build a plugin locally using the Budibase CLI." } } From bdcf717305c0a775f7ba281202385fe8ebab27ae Mon Sep 17 00:00:00 2001 From: Andrew Kingston Date: Mon, 12 Sep 2022 19:50:04 +0100 Subject: [PATCH 195/203] Fix plugin rows not being keyed properly, causing incorrect notifications --- .../portal/manage/plugins/_components/DeletePluginModal.svelte | 2 +- .../src/pages/builder/portal/manage/plugins/index.svelte | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/builder/src/pages/builder/portal/manage/plugins/_components/DeletePluginModal.svelte b/packages/builder/src/pages/builder/portal/manage/plugins/_components/DeletePluginModal.svelte index aed51e949e..6b09e7b276 100644 --- a/packages/builder/src/pages/builder/portal/manage/plugins/_components/DeletePluginModal.svelte +++ b/packages/builder/src/pages/builder/portal/manage/plugins/_components/DeletePluginModal.svelte @@ -10,7 +10,7 @@ async function deletePlugin() { try { await plugins.deletePlugin(plugin._id) - notifications.success(`Plugin ${plugin?.name} deleted.`) + notifications.success(`Plugin ${plugin?.name} deleted`) dispatch("deleted") } catch (error) { const msg = error?.message ? error.message : JSON.stringify(error) diff --git a/packages/builder/src/pages/builder/portal/manage/plugins/index.svelte b/packages/builder/src/pages/builder/portal/manage/plugins/index.svelte index 2602f4a034..5d73447710 100644 --- a/packages/builder/src/pages/builder/portal/manage/plugins/index.svelte +++ b/packages/builder/src/pages/builder/portal/manage/plugins/index.svelte @@ -67,7 +67,7 @@
{#if filteredPlugins?.length} - {#each filteredPlugins as plugin} + {#each filteredPlugins as plugin (plugin._id)} {/each} From a92a8ed882cde62db5903d495112e202173defc7 Mon Sep 17 00:00:00 2001 From: Budibase Staging Release Bot <> Date: Mon, 12 Sep 2022 19:09:31 +0000 Subject: [PATCH 196/203] v1.3.15-alpha.1 --- lerna.json | 2 +- packages/backend-core/package.json | 4 ++-- packages/bbui/package.json | 4 ++-- packages/builder/package.json | 10 +++++----- packages/cli/package.json | 8 ++++---- packages/client/package.json | 8 ++++---- packages/frontend-core/package.json | 4 ++-- packages/server/package.json | 10 +++++----- packages/string-templates/package.json | 2 +- packages/types/package.json | 2 +- packages/worker/package.json | 8 ++++---- 11 files changed, 31 insertions(+), 31 deletions(-) diff --git a/lerna.json b/lerna.json index a276af2caf..76ba90b81c 100644 --- a/lerna.json +++ b/lerna.json @@ -1,5 +1,5 @@ { - "version": "1.3.15-alpha.0", + "version": "1.3.15-alpha.1", "npmClient": "yarn", "packages": [ "packages/*" diff --git a/packages/backend-core/package.json b/packages/backend-core/package.json index 32c8d3e1f2..bb94eaeaef 100644 --- a/packages/backend-core/package.json +++ b/packages/backend-core/package.json @@ -1,6 +1,6 @@ { "name": "@budibase/backend-core", - "version": "1.3.15-alpha.0", + "version": "1.3.15-alpha.1", "description": "Budibase backend core libraries used in server and worker", "main": "dist/src/index.js", "types": "dist/src/index.d.ts", @@ -20,7 +20,7 @@ "test:watch": "jest --watchAll" }, "dependencies": { - "@budibase/types": "1.3.15-alpha.0", + "@budibase/types": "1.3.15-alpha.1", "@shopify/jest-koa-mocks": "5.0.1", "@techpass/passport-openidconnect": "0.3.2", "aws-sdk": "2.1030.0", diff --git a/packages/bbui/package.json b/packages/bbui/package.json index 081f6471af..525431c5c3 100644 --- a/packages/bbui/package.json +++ b/packages/bbui/package.json @@ -1,7 +1,7 @@ { "name": "@budibase/bbui", "description": "A UI solution used in the different Budibase projects.", - "version": "1.3.15-alpha.0", + "version": "1.3.15-alpha.1", "license": "MPL-2.0", "svelte": "src/index.js", "module": "dist/bbui.es.js", @@ -38,7 +38,7 @@ ], "dependencies": { "@adobe/spectrum-css-workflow-icons": "^1.2.1", - "@budibase/string-templates": "1.3.15-alpha.0", + "@budibase/string-templates": "1.3.15-alpha.1", "@spectrum-css/actionbutton": "^1.0.1", "@spectrum-css/actiongroup": "^1.0.1", "@spectrum-css/avatar": "^3.0.2", diff --git a/packages/builder/package.json b/packages/builder/package.json index 862fd2d333..246f1862e5 100644 --- a/packages/builder/package.json +++ b/packages/builder/package.json @@ -1,6 +1,6 @@ { "name": "@budibase/builder", - "version": "1.3.15-alpha.0", + "version": "1.3.15-alpha.1", "license": "GPL-3.0", "private": true, "scripts": { @@ -69,10 +69,10 @@ } }, "dependencies": { - "@budibase/bbui": "1.3.15-alpha.0", - "@budibase/client": "1.3.15-alpha.0", - "@budibase/frontend-core": "1.3.15-alpha.0", - "@budibase/string-templates": "1.3.15-alpha.0", + "@budibase/bbui": "1.3.15-alpha.1", + "@budibase/client": "1.3.15-alpha.1", + "@budibase/frontend-core": "1.3.15-alpha.1", + "@budibase/string-templates": "1.3.15-alpha.1", "@sentry/browser": "5.19.1", "@spectrum-css/page": "^3.0.1", "@spectrum-css/vars": "^3.0.1", diff --git a/packages/cli/package.json b/packages/cli/package.json index f073a7913d..9ec1843c8f 100644 --- a/packages/cli/package.json +++ b/packages/cli/package.json @@ -1,6 +1,6 @@ { "name": "@budibase/cli", - "version": "1.3.15-alpha.0", + "version": "1.3.15-alpha.1", "description": "Budibase CLI, for developers, self hosting and migrations.", "main": "src/index.js", "bin": { @@ -26,9 +26,9 @@ "outputPath": "build" }, "dependencies": { - "@budibase/backend-core": "1.3.15-alpha.0", - "@budibase/string-templates": "1.3.15-alpha.0", - "@budibase/types": "1.3.15-alpha.0", + "@budibase/backend-core": "1.3.15-alpha.1", + "@budibase/string-templates": "1.3.15-alpha.1", + "@budibase/types": "1.3.15-alpha.1", "axios": "0.21.2", "chalk": "4.1.0", "cli-progress": "3.11.2", diff --git a/packages/client/package.json b/packages/client/package.json index 370920f42b..2b227bce1b 100644 --- a/packages/client/package.json +++ b/packages/client/package.json @@ -1,6 +1,6 @@ { "name": "@budibase/client", - "version": "1.3.15-alpha.0", + "version": "1.3.15-alpha.1", "license": "MPL-2.0", "module": "dist/budibase-client.js", "main": "dist/budibase-client.js", @@ -19,9 +19,9 @@ "dev:builder": "rollup -cw" }, "dependencies": { - "@budibase/bbui": "1.3.15-alpha.0", - "@budibase/frontend-core": "1.3.15-alpha.0", - "@budibase/string-templates": "1.3.15-alpha.0", + "@budibase/bbui": "1.3.15-alpha.1", + "@budibase/frontend-core": "1.3.15-alpha.1", + "@budibase/string-templates": "1.3.15-alpha.1", "@spectrum-css/button": "^3.0.3", "@spectrum-css/card": "^3.0.3", "@spectrum-css/divider": "^1.0.3", diff --git a/packages/frontend-core/package.json b/packages/frontend-core/package.json index d6963ed5f4..9c7940dd45 100644 --- a/packages/frontend-core/package.json +++ b/packages/frontend-core/package.json @@ -1,12 +1,12 @@ { "name": "@budibase/frontend-core", - "version": "1.3.15-alpha.0", + "version": "1.3.15-alpha.1", "description": "Budibase frontend core libraries used in builder and client", "author": "Budibase", "license": "MPL-2.0", "svelte": "src/index.js", "dependencies": { - "@budibase/bbui": "1.3.15-alpha.0", + "@budibase/bbui": "1.3.15-alpha.1", "lodash": "^4.17.21", "svelte": "^3.46.2" } diff --git a/packages/server/package.json b/packages/server/package.json index 77890b483c..fdf5056cab 100644 --- a/packages/server/package.json +++ b/packages/server/package.json @@ -1,7 +1,7 @@ { "name": "@budibase/server", "email": "hi@budibase.com", - "version": "1.3.15-alpha.0", + "version": "1.3.15-alpha.1", "description": "Budibase Web Server", "main": "src/index.ts", "repository": { @@ -77,11 +77,11 @@ "license": "GPL-3.0", "dependencies": { "@apidevtools/swagger-parser": "10.0.3", - "@budibase/backend-core": "1.3.15-alpha.0", - "@budibase/client": "1.3.15-alpha.0", + "@budibase/backend-core": "1.3.15-alpha.1", + "@budibase/client": "1.3.15-alpha.1", "@budibase/pro": "1.3.15-alpha.0", - "@budibase/string-templates": "1.3.15-alpha.0", - "@budibase/types": "1.3.15-alpha.0", + "@budibase/string-templates": "1.3.15-alpha.1", + "@budibase/types": "1.3.15-alpha.1", "@bull-board/api": "3.7.0", "@bull-board/koa": "3.9.4", "@elastic/elasticsearch": "7.10.0", diff --git a/packages/string-templates/package.json b/packages/string-templates/package.json index 6b21c143a8..ff75e71129 100644 --- a/packages/string-templates/package.json +++ b/packages/string-templates/package.json @@ -1,6 +1,6 @@ { "name": "@budibase/string-templates", - "version": "1.3.15-alpha.0", + "version": "1.3.15-alpha.1", "description": "Handlebars wrapper for Budibase templating.", "main": "src/index.cjs", "module": "dist/bundle.mjs", diff --git a/packages/types/package.json b/packages/types/package.json index e2ff347691..1737ff69a2 100644 --- a/packages/types/package.json +++ b/packages/types/package.json @@ -1,6 +1,6 @@ { "name": "@budibase/types", - "version": "1.3.15-alpha.0", + "version": "1.3.15-alpha.1", "description": "Budibase types", "main": "dist/index.js", "types": "dist/index.d.ts", diff --git a/packages/worker/package.json b/packages/worker/package.json index db818fed8d..0a7221b7d9 100644 --- a/packages/worker/package.json +++ b/packages/worker/package.json @@ -1,7 +1,7 @@ { "name": "@budibase/worker", "email": "hi@budibase.com", - "version": "1.3.15-alpha.0", + "version": "1.3.15-alpha.1", "description": "Budibase background service", "main": "src/index.ts", "repository": { @@ -35,10 +35,10 @@ "author": "Budibase", "license": "GPL-3.0", "dependencies": { - "@budibase/backend-core": "1.3.15-alpha.0", + "@budibase/backend-core": "1.3.15-alpha.1", "@budibase/pro": "1.3.15-alpha.0", - "@budibase/string-templates": "1.3.15-alpha.0", - "@budibase/types": "1.3.15-alpha.0", + "@budibase/string-templates": "1.3.15-alpha.1", + "@budibase/types": "1.3.15-alpha.1", "@koa/router": "8.0.8", "@sentry/node": "6.17.7", "@techpass/passport-openidconnect": "0.3.2", From 66092e7742344d58b1224eff42e48100a39f46b7 Mon Sep 17 00:00:00 2001 From: Budibase Staging Release Bot <> Date: Mon, 12 Sep 2022 19:12:42 +0000 Subject: [PATCH 197/203] Update pro version to 1.3.15-alpha.1 --- packages/server/package.json | 2 +- packages/server/yarn.lock | 30 +++++++++++++++--------------- packages/worker/package.json | 2 +- packages/worker/yarn.lock | 30 +++++++++++++++--------------- 4 files changed, 32 insertions(+), 32 deletions(-) diff --git a/packages/server/package.json b/packages/server/package.json index fdf5056cab..997646c583 100644 --- a/packages/server/package.json +++ b/packages/server/package.json @@ -79,7 +79,7 @@ "@apidevtools/swagger-parser": "10.0.3", "@budibase/backend-core": "1.3.15-alpha.1", "@budibase/client": "1.3.15-alpha.1", - "@budibase/pro": "1.3.15-alpha.0", + "@budibase/pro": "1.3.15-alpha.1", "@budibase/string-templates": "1.3.15-alpha.1", "@budibase/types": "1.3.15-alpha.1", "@bull-board/api": "3.7.0", diff --git a/packages/server/yarn.lock b/packages/server/yarn.lock index 63730ebd4c..4ec39fca77 100644 --- a/packages/server/yarn.lock +++ b/packages/server/yarn.lock @@ -1094,12 +1094,12 @@ resolved "https://registry.yarnpkg.com/@bcoe/v8-coverage/-/v8-coverage-0.2.3.tgz#75a2e8b51cb758a7553d6804a5932d7aace75c39" integrity sha512-0hYQ8SB4Db5zvZB4axdMHGwEaQjkZzFjQiN9LVYvIFB2nSUHW9tYpxWriPrWDASIxiaXax83REcLxuSdnGPZtw== -"@budibase/backend-core@1.3.15-alpha.0": - version "1.3.15-alpha.0" - resolved "https://registry.yarnpkg.com/@budibase/backend-core/-/backend-core-1.3.15-alpha.0.tgz#d4fd3a00008c3d5018c57bb5b4f04360d60f9807" - integrity sha512-3X7K3rHPBs065y1nihZdT45twPNiK5FGoi82DQc7z2ub6nuD7hfn+A8WpEGEpofFwNQHme1XTVrJJjyBDME/ZQ== +"@budibase/backend-core@1.3.15-alpha.1": + version "1.3.15-alpha.1" + resolved "https://registry.yarnpkg.com/@budibase/backend-core/-/backend-core-1.3.15-alpha.1.tgz#75f04e61374b00e507cad790f584b3a686f45533" + integrity sha512-ebkthJl0YMqpZAS+lm/OjX6TakAOnf0E1mBrxrPrlvq33Z8Imp5qrWq+UJswh/ltTUFd1Zxm21lMKweCdV2kOg== dependencies: - "@budibase/types" "1.3.15-alpha.0" + "@budibase/types" "1.3.15-alpha.1" "@shopify/jest-koa-mocks" "5.0.1" "@techpass/passport-openidconnect" "0.3.2" aws-sdk "2.1030.0" @@ -1179,13 +1179,13 @@ svelte-flatpickr "^3.2.3" svelte-portal "^1.0.0" -"@budibase/pro@1.3.15-alpha.0": - version "1.3.15-alpha.0" - resolved "https://registry.yarnpkg.com/@budibase/pro/-/pro-1.3.15-alpha.0.tgz#92d0a74c5aa31c22020aeb584e05c90a9ca210a0" - integrity sha512-mNdwrtJt++WNKttizfvD1mpDZqQHhUAsY5SvlKAL6EiOJVYpJzW/p7m4fxn8hjhLtTrKdDThmb7nTyxE43Scdw== +"@budibase/pro@1.3.15-alpha.1": + version "1.3.15-alpha.1" + resolved "https://registry.yarnpkg.com/@budibase/pro/-/pro-1.3.15-alpha.1.tgz#0575016bf9bed5c36b6ebbb6b98a999f1d365522" + integrity sha512-8cxkEZcuvmoor8zVTFz6X+oeYXEdYmPUrXCBmya6IwqmhtIk/rJ7Ps4S7JNgdndeEQsxQc8Ch8ur/KaA/tb94Q== dependencies: - "@budibase/backend-core" "1.3.15-alpha.0" - "@budibase/types" "1.3.15-alpha.0" + "@budibase/backend-core" "1.3.15-alpha.1" + "@budibase/types" "1.3.15-alpha.1" "@koa/router" "8.0.8" joi "17.6.0" node-fetch "^2.6.1" @@ -1208,10 +1208,10 @@ svelte-apexcharts "^1.0.2" svelte-flatpickr "^3.1.0" -"@budibase/types@1.3.15-alpha.0": - version "1.3.15-alpha.0" - resolved "https://registry.yarnpkg.com/@budibase/types/-/types-1.3.15-alpha.0.tgz#813eb8415fc2df926572dd96d67467292fd692f4" - integrity sha512-rQ52X2v9xIbWfB9aUpiNfHsByg2OpAtUOrPkj/JQopyRdfTXuHC/IJiHvVBkYmappXo6D0p9VdcCvgeSPn/RMQ== +"@budibase/types@1.3.15-alpha.1": + version "1.3.15-alpha.1" + resolved "https://registry.yarnpkg.com/@budibase/types/-/types-1.3.15-alpha.1.tgz#28dc4457de6bfe3c673421fa4cae728d3a4d87b8" + integrity sha512-318QMe3RI0UX47FpOxcM7BQU+TSexMkTBaH6G/BAHhZr/dWTP6I9MITuWpVKUxZgdJHvhZdbUeknHXUgR7Wjcw== "@bull-board/api@3.7.0": version "3.7.0" diff --git a/packages/worker/package.json b/packages/worker/package.json index 0a7221b7d9..9bb3db51f7 100644 --- a/packages/worker/package.json +++ b/packages/worker/package.json @@ -36,7 +36,7 @@ "license": "GPL-3.0", "dependencies": { "@budibase/backend-core": "1.3.15-alpha.1", - "@budibase/pro": "1.3.15-alpha.0", + "@budibase/pro": "1.3.15-alpha.1", "@budibase/string-templates": "1.3.15-alpha.1", "@budibase/types": "1.3.15-alpha.1", "@koa/router": "8.0.8", diff --git a/packages/worker/yarn.lock b/packages/worker/yarn.lock index 6d8559052a..959d6bf5e7 100644 --- a/packages/worker/yarn.lock +++ b/packages/worker/yarn.lock @@ -291,12 +291,12 @@ resolved "https://registry.yarnpkg.com/@bcoe/v8-coverage/-/v8-coverage-0.2.3.tgz#75a2e8b51cb758a7553d6804a5932d7aace75c39" integrity sha512-0hYQ8SB4Db5zvZB4axdMHGwEaQjkZzFjQiN9LVYvIFB2nSUHW9tYpxWriPrWDASIxiaXax83REcLxuSdnGPZtw== -"@budibase/backend-core@1.3.15-alpha.0": - version "1.3.15-alpha.0" - resolved "https://registry.yarnpkg.com/@budibase/backend-core/-/backend-core-1.3.15-alpha.0.tgz#d4fd3a00008c3d5018c57bb5b4f04360d60f9807" - integrity sha512-3X7K3rHPBs065y1nihZdT45twPNiK5FGoi82DQc7z2ub6nuD7hfn+A8WpEGEpofFwNQHme1XTVrJJjyBDME/ZQ== +"@budibase/backend-core@1.3.15-alpha.1": + version "1.3.15-alpha.1" + resolved "https://registry.yarnpkg.com/@budibase/backend-core/-/backend-core-1.3.15-alpha.1.tgz#75f04e61374b00e507cad790f584b3a686f45533" + integrity sha512-ebkthJl0YMqpZAS+lm/OjX6TakAOnf0E1mBrxrPrlvq33Z8Imp5qrWq+UJswh/ltTUFd1Zxm21lMKweCdV2kOg== dependencies: - "@budibase/types" "1.3.15-alpha.0" + "@budibase/types" "1.3.15-alpha.1" "@shopify/jest-koa-mocks" "5.0.1" "@techpass/passport-openidconnect" "0.3.2" aws-sdk "2.1030.0" @@ -326,21 +326,21 @@ uuid "8.3.2" zlib "1.0.5" -"@budibase/pro@1.3.15-alpha.0": - version "1.3.15-alpha.0" - resolved "https://registry.yarnpkg.com/@budibase/pro/-/pro-1.3.15-alpha.0.tgz#92d0a74c5aa31c22020aeb584e05c90a9ca210a0" - integrity sha512-mNdwrtJt++WNKttizfvD1mpDZqQHhUAsY5SvlKAL6EiOJVYpJzW/p7m4fxn8hjhLtTrKdDThmb7nTyxE43Scdw== +"@budibase/pro@1.3.15-alpha.1": + version "1.3.15-alpha.1" + resolved "https://registry.yarnpkg.com/@budibase/pro/-/pro-1.3.15-alpha.1.tgz#0575016bf9bed5c36b6ebbb6b98a999f1d365522" + integrity sha512-8cxkEZcuvmoor8zVTFz6X+oeYXEdYmPUrXCBmya6IwqmhtIk/rJ7Ps4S7JNgdndeEQsxQc8Ch8ur/KaA/tb94Q== dependencies: - "@budibase/backend-core" "1.3.15-alpha.0" - "@budibase/types" "1.3.15-alpha.0" + "@budibase/backend-core" "1.3.15-alpha.1" + "@budibase/types" "1.3.15-alpha.1" "@koa/router" "8.0.8" joi "17.6.0" node-fetch "^2.6.1" -"@budibase/types@1.3.15-alpha.0": - version "1.3.15-alpha.0" - resolved "https://registry.yarnpkg.com/@budibase/types/-/types-1.3.15-alpha.0.tgz#813eb8415fc2df926572dd96d67467292fd692f4" - integrity sha512-rQ52X2v9xIbWfB9aUpiNfHsByg2OpAtUOrPkj/JQopyRdfTXuHC/IJiHvVBkYmappXo6D0p9VdcCvgeSPn/RMQ== +"@budibase/types@1.3.15-alpha.1": + version "1.3.15-alpha.1" + resolved "https://registry.yarnpkg.com/@budibase/types/-/types-1.3.15-alpha.1.tgz#28dc4457de6bfe3c673421fa4cae728d3a4d87b8" + integrity sha512-318QMe3RI0UX47FpOxcM7BQU+TSexMkTBaH6G/BAHhZr/dWTP6I9MITuWpVKUxZgdJHvhZdbUeknHXUgR7Wjcw== "@cspotcode/source-map-consumer@0.8.0": version "0.8.0" From 00cbf6cf37e5afed1a3e1cdbd6659d1753355c78 Mon Sep 17 00:00:00 2001 From: Andrew Kingston Date: Tue, 13 Sep 2022 09:54:25 +0100 Subject: [PATCH 198/203] Refactor server websocket dependency tree to fix jest tests --- packages/server/src/api/controllers/plugin/index.ts | 2 +- packages/server/src/app.ts | 6 ++---- packages/server/src/websocket.ts | 11 ++++++++++- 3 files changed, 13 insertions(+), 6 deletions(-) diff --git a/packages/server/src/api/controllers/plugin/index.ts b/packages/server/src/api/controllers/plugin/index.ts index d0c23c4e32..99a9e7db66 100644 --- a/packages/server/src/api/controllers/plugin/index.ts +++ b/packages/server/src/api/controllers/plugin/index.ts @@ -10,7 +10,7 @@ import { } from "@budibase/backend-core/objectStore" import { PluginType, FileType, PluginSource } from "@budibase/types" import env from "../../../environment" -import { ClientAppSocket } from "../../../app" +import { ClientAppSocket } from "../../../websocket" export async function getPlugins(type?: PluginType) { const db = getGlobalDB() diff --git a/packages/server/src/app.ts b/packages/server/src/app.ts index f9dce0c867..e001b77aba 100644 --- a/packages/server/src/app.ts +++ b/packages/server/src/app.ts @@ -32,7 +32,7 @@ import * as migrations from "./migrations" import { events, installation, tenancy } from "@budibase/backend-core" import { createAdminUser, getChecklist } from "./utilities/workerRequests" import { watch } from "./watch" -import { Websocket } from "./websocket" +import { initialise as initialiseWebsockets } from "./websocket" const app = new Koa() @@ -77,9 +77,7 @@ if (env.isProd()) { const server = http.createServer(app.callback()) destroyable(server) - -// initialise websockets -export const ClientAppSocket = new Websocket(server, "/socket/client") +initialiseWebsockets(server) let shuttingDown = false, errCode = 0 diff --git a/packages/server/src/websocket.ts b/packages/server/src/websocket.ts index 52942ab795..d6d91b0ca0 100644 --- a/packages/server/src/websocket.ts +++ b/packages/server/src/websocket.ts @@ -1,7 +1,7 @@ import { Server } from "socket.io" import http from "http" -export class Websocket { +class Websocket { socketServer: Server constructor(server: http.Server, path: string) { @@ -15,3 +15,12 @@ export class Websocket { this.socketServer.sockets.emit(event, payload) } } + +// Likely to be more socket instances in future +let ClientAppSocket: Websocket + +export const initialise = (server: http.Server) => { + ClientAppSocket = new Websocket(server, "/socket/client") +} + +export { ClientAppSocket } From 223362f2e2ec572aaed18507ebfeceefdc9efaf6 Mon Sep 17 00:00:00 2001 From: Budibase Staging Release Bot <> Date: Tue, 13 Sep 2022 09:24:01 +0000 Subject: [PATCH 199/203] v1.3.15-alpha.2 --- lerna.json | 2 +- packages/backend-core/package.json | 4 ++-- packages/bbui/package.json | 4 ++-- packages/builder/package.json | 10 +++++----- packages/cli/package.json | 8 ++++---- packages/client/package.json | 8 ++++---- packages/frontend-core/package.json | 4 ++-- packages/server/package.json | 10 +++++----- packages/string-templates/package.json | 2 +- packages/types/package.json | 2 +- packages/worker/package.json | 8 ++++---- 11 files changed, 31 insertions(+), 31 deletions(-) diff --git a/lerna.json b/lerna.json index 76ba90b81c..d004e68e33 100644 --- a/lerna.json +++ b/lerna.json @@ -1,5 +1,5 @@ { - "version": "1.3.15-alpha.1", + "version": "1.3.15-alpha.2", "npmClient": "yarn", "packages": [ "packages/*" diff --git a/packages/backend-core/package.json b/packages/backend-core/package.json index bb94eaeaef..0c1ad0c7e8 100644 --- a/packages/backend-core/package.json +++ b/packages/backend-core/package.json @@ -1,6 +1,6 @@ { "name": "@budibase/backend-core", - "version": "1.3.15-alpha.1", + "version": "1.3.15-alpha.2", "description": "Budibase backend core libraries used in server and worker", "main": "dist/src/index.js", "types": "dist/src/index.d.ts", @@ -20,7 +20,7 @@ "test:watch": "jest --watchAll" }, "dependencies": { - "@budibase/types": "1.3.15-alpha.1", + "@budibase/types": "1.3.15-alpha.2", "@shopify/jest-koa-mocks": "5.0.1", "@techpass/passport-openidconnect": "0.3.2", "aws-sdk": "2.1030.0", diff --git a/packages/bbui/package.json b/packages/bbui/package.json index 525431c5c3..4cdea18b36 100644 --- a/packages/bbui/package.json +++ b/packages/bbui/package.json @@ -1,7 +1,7 @@ { "name": "@budibase/bbui", "description": "A UI solution used in the different Budibase projects.", - "version": "1.3.15-alpha.1", + "version": "1.3.15-alpha.2", "license": "MPL-2.0", "svelte": "src/index.js", "module": "dist/bbui.es.js", @@ -38,7 +38,7 @@ ], "dependencies": { "@adobe/spectrum-css-workflow-icons": "^1.2.1", - "@budibase/string-templates": "1.3.15-alpha.1", + "@budibase/string-templates": "1.3.15-alpha.2", "@spectrum-css/actionbutton": "^1.0.1", "@spectrum-css/actiongroup": "^1.0.1", "@spectrum-css/avatar": "^3.0.2", diff --git a/packages/builder/package.json b/packages/builder/package.json index 246f1862e5..f6f1d04ef8 100644 --- a/packages/builder/package.json +++ b/packages/builder/package.json @@ -1,6 +1,6 @@ { "name": "@budibase/builder", - "version": "1.3.15-alpha.1", + "version": "1.3.15-alpha.2", "license": "GPL-3.0", "private": true, "scripts": { @@ -69,10 +69,10 @@ } }, "dependencies": { - "@budibase/bbui": "1.3.15-alpha.1", - "@budibase/client": "1.3.15-alpha.1", - "@budibase/frontend-core": "1.3.15-alpha.1", - "@budibase/string-templates": "1.3.15-alpha.1", + "@budibase/bbui": "1.3.15-alpha.2", + "@budibase/client": "1.3.15-alpha.2", + "@budibase/frontend-core": "1.3.15-alpha.2", + "@budibase/string-templates": "1.3.15-alpha.2", "@sentry/browser": "5.19.1", "@spectrum-css/page": "^3.0.1", "@spectrum-css/vars": "^3.0.1", diff --git a/packages/cli/package.json b/packages/cli/package.json index 9ec1843c8f..1e94041311 100644 --- a/packages/cli/package.json +++ b/packages/cli/package.json @@ -1,6 +1,6 @@ { "name": "@budibase/cli", - "version": "1.3.15-alpha.1", + "version": "1.3.15-alpha.2", "description": "Budibase CLI, for developers, self hosting and migrations.", "main": "src/index.js", "bin": { @@ -26,9 +26,9 @@ "outputPath": "build" }, "dependencies": { - "@budibase/backend-core": "1.3.15-alpha.1", - "@budibase/string-templates": "1.3.15-alpha.1", - "@budibase/types": "1.3.15-alpha.1", + "@budibase/backend-core": "1.3.15-alpha.2", + "@budibase/string-templates": "1.3.15-alpha.2", + "@budibase/types": "1.3.15-alpha.2", "axios": "0.21.2", "chalk": "4.1.0", "cli-progress": "3.11.2", diff --git a/packages/client/package.json b/packages/client/package.json index 090f1e8f00..318b246c9d 100644 --- a/packages/client/package.json +++ b/packages/client/package.json @@ -1,6 +1,6 @@ { "name": "@budibase/client", - "version": "1.3.15-alpha.1", + "version": "1.3.15-alpha.2", "license": "MPL-2.0", "module": "dist/budibase-client.js", "main": "dist/budibase-client.js", @@ -19,9 +19,9 @@ "dev:builder": "rollup -cw" }, "dependencies": { - "@budibase/bbui": "1.3.15-alpha.1", - "@budibase/frontend-core": "1.3.15-alpha.1", - "@budibase/string-templates": "1.3.15-alpha.1", + "@budibase/bbui": "1.3.15-alpha.2", + "@budibase/frontend-core": "1.3.15-alpha.2", + "@budibase/string-templates": "1.3.15-alpha.2", "@spectrum-css/button": "^3.0.3", "@spectrum-css/card": "^3.0.3", "@spectrum-css/divider": "^1.0.3", diff --git a/packages/frontend-core/package.json b/packages/frontend-core/package.json index 9c7940dd45..f33aa5d7d9 100644 --- a/packages/frontend-core/package.json +++ b/packages/frontend-core/package.json @@ -1,12 +1,12 @@ { "name": "@budibase/frontend-core", - "version": "1.3.15-alpha.1", + "version": "1.3.15-alpha.2", "description": "Budibase frontend core libraries used in builder and client", "author": "Budibase", "license": "MPL-2.0", "svelte": "src/index.js", "dependencies": { - "@budibase/bbui": "1.3.15-alpha.1", + "@budibase/bbui": "1.3.15-alpha.2", "lodash": "^4.17.21", "svelte": "^3.46.2" } diff --git a/packages/server/package.json b/packages/server/package.json index 6b9d04f0f7..de301ce0ca 100644 --- a/packages/server/package.json +++ b/packages/server/package.json @@ -1,7 +1,7 @@ { "name": "@budibase/server", "email": "hi@budibase.com", - "version": "1.3.15-alpha.1", + "version": "1.3.15-alpha.2", "description": "Budibase Web Server", "main": "src/index.ts", "repository": { @@ -77,11 +77,11 @@ "license": "GPL-3.0", "dependencies": { "@apidevtools/swagger-parser": "10.0.3", - "@budibase/backend-core": "1.3.15-alpha.1", - "@budibase/client": "1.3.15-alpha.1", + "@budibase/backend-core": "1.3.15-alpha.2", + "@budibase/client": "1.3.15-alpha.2", "@budibase/pro": "1.3.15-alpha.1", - "@budibase/string-templates": "1.3.15-alpha.1", - "@budibase/types": "1.3.15-alpha.1", + "@budibase/string-templates": "1.3.15-alpha.2", + "@budibase/types": "1.3.15-alpha.2", "@bull-board/api": "3.7.0", "@bull-board/koa": "3.9.4", "@elastic/elasticsearch": "7.10.0", diff --git a/packages/string-templates/package.json b/packages/string-templates/package.json index ff75e71129..b2e7a81eeb 100644 --- a/packages/string-templates/package.json +++ b/packages/string-templates/package.json @@ -1,6 +1,6 @@ { "name": "@budibase/string-templates", - "version": "1.3.15-alpha.1", + "version": "1.3.15-alpha.2", "description": "Handlebars wrapper for Budibase templating.", "main": "src/index.cjs", "module": "dist/bundle.mjs", diff --git a/packages/types/package.json b/packages/types/package.json index 1737ff69a2..19010a7d1d 100644 --- a/packages/types/package.json +++ b/packages/types/package.json @@ -1,6 +1,6 @@ { "name": "@budibase/types", - "version": "1.3.15-alpha.1", + "version": "1.3.15-alpha.2", "description": "Budibase types", "main": "dist/index.js", "types": "dist/index.d.ts", diff --git a/packages/worker/package.json b/packages/worker/package.json index 9bb3db51f7..b45fbf87b0 100644 --- a/packages/worker/package.json +++ b/packages/worker/package.json @@ -1,7 +1,7 @@ { "name": "@budibase/worker", "email": "hi@budibase.com", - "version": "1.3.15-alpha.1", + "version": "1.3.15-alpha.2", "description": "Budibase background service", "main": "src/index.ts", "repository": { @@ -35,10 +35,10 @@ "author": "Budibase", "license": "GPL-3.0", "dependencies": { - "@budibase/backend-core": "1.3.15-alpha.1", + "@budibase/backend-core": "1.3.15-alpha.2", "@budibase/pro": "1.3.15-alpha.1", - "@budibase/string-templates": "1.3.15-alpha.1", - "@budibase/types": "1.3.15-alpha.1", + "@budibase/string-templates": "1.3.15-alpha.2", + "@budibase/types": "1.3.15-alpha.2", "@koa/router": "8.0.8", "@sentry/node": "6.17.7", "@techpass/passport-openidconnect": "0.3.2", From 96ae0fa7c53bee716cff7437baafa6049d75ef2e Mon Sep 17 00:00:00 2001 From: Budibase Staging Release Bot <> Date: Tue, 13 Sep 2022 09:26:58 +0000 Subject: [PATCH 200/203] Update pro version to 1.3.15-alpha.2 --- packages/server/package.json | 2 +- packages/server/yarn.lock | 30 +++++++++++++++--------------- packages/worker/package.json | 2 +- packages/worker/yarn.lock | 30 +++++++++++++++--------------- 4 files changed, 32 insertions(+), 32 deletions(-) diff --git a/packages/server/package.json b/packages/server/package.json index de301ce0ca..6d48c0471e 100644 --- a/packages/server/package.json +++ b/packages/server/package.json @@ -79,7 +79,7 @@ "@apidevtools/swagger-parser": "10.0.3", "@budibase/backend-core": "1.3.15-alpha.2", "@budibase/client": "1.3.15-alpha.2", - "@budibase/pro": "1.3.15-alpha.1", + "@budibase/pro": "1.3.15-alpha.2", "@budibase/string-templates": "1.3.15-alpha.2", "@budibase/types": "1.3.15-alpha.2", "@bull-board/api": "3.7.0", diff --git a/packages/server/yarn.lock b/packages/server/yarn.lock index 3c2eda8ba1..77b6daae57 100644 --- a/packages/server/yarn.lock +++ b/packages/server/yarn.lock @@ -1094,12 +1094,12 @@ resolved "https://registry.yarnpkg.com/@bcoe/v8-coverage/-/v8-coverage-0.2.3.tgz#75a2e8b51cb758a7553d6804a5932d7aace75c39" integrity sha512-0hYQ8SB4Db5zvZB4axdMHGwEaQjkZzFjQiN9LVYvIFB2nSUHW9tYpxWriPrWDASIxiaXax83REcLxuSdnGPZtw== -"@budibase/backend-core@1.3.15-alpha.1": - version "1.3.15-alpha.1" - resolved "https://registry.yarnpkg.com/@budibase/backend-core/-/backend-core-1.3.15-alpha.1.tgz#75f04e61374b00e507cad790f584b3a686f45533" - integrity sha512-ebkthJl0YMqpZAS+lm/OjX6TakAOnf0E1mBrxrPrlvq33Z8Imp5qrWq+UJswh/ltTUFd1Zxm21lMKweCdV2kOg== +"@budibase/backend-core@1.3.15-alpha.2": + version "1.3.15-alpha.2" + resolved "https://registry.yarnpkg.com/@budibase/backend-core/-/backend-core-1.3.15-alpha.2.tgz#ed3c7cc270147f660553b9f2972ef7cdc544fd21" + integrity sha512-voJFjd78CCdsINk+e1CYyXhGx4ubWJ9k2ILVUWooWgUAaYfjlJHKLH5yjNhVOdXGd0NVebLgMoTIgIHk5lPoFw== dependencies: - "@budibase/types" "1.3.15-alpha.1" + "@budibase/types" "1.3.15-alpha.2" "@shopify/jest-koa-mocks" "5.0.1" "@techpass/passport-openidconnect" "0.3.2" aws-sdk "2.1030.0" @@ -1179,13 +1179,13 @@ svelte-flatpickr "^3.2.3" svelte-portal "^1.0.0" -"@budibase/pro@1.3.15-alpha.1": - version "1.3.15-alpha.1" - resolved "https://registry.yarnpkg.com/@budibase/pro/-/pro-1.3.15-alpha.1.tgz#0575016bf9bed5c36b6ebbb6b98a999f1d365522" - integrity sha512-8cxkEZcuvmoor8zVTFz6X+oeYXEdYmPUrXCBmya6IwqmhtIk/rJ7Ps4S7JNgdndeEQsxQc8Ch8ur/KaA/tb94Q== +"@budibase/pro@1.3.15-alpha.2": + version "1.3.15-alpha.2" + resolved "https://registry.yarnpkg.com/@budibase/pro/-/pro-1.3.15-alpha.2.tgz#c6b0586ba2775fb7dd8bab7bebae49f38154056b" + integrity sha512-oaxt5fCpzaBHRkRwGxYt6zXTM9Mn1+niCBXCSA+weTNMqpCg9VlfE+XIvkwBTs0ehpnJsJsseZ/j49fHQ4TqGg== dependencies: - "@budibase/backend-core" "1.3.15-alpha.1" - "@budibase/types" "1.3.15-alpha.1" + "@budibase/backend-core" "1.3.15-alpha.2" + "@budibase/types" "1.3.15-alpha.2" "@koa/router" "8.0.8" joi "17.6.0" node-fetch "^2.6.1" @@ -1208,10 +1208,10 @@ svelte-apexcharts "^1.0.2" svelte-flatpickr "^3.1.0" -"@budibase/types@1.3.15-alpha.1": - version "1.3.15-alpha.1" - resolved "https://registry.yarnpkg.com/@budibase/types/-/types-1.3.15-alpha.1.tgz#28dc4457de6bfe3c673421fa4cae728d3a4d87b8" - integrity sha512-318QMe3RI0UX47FpOxcM7BQU+TSexMkTBaH6G/BAHhZr/dWTP6I9MITuWpVKUxZgdJHvhZdbUeknHXUgR7Wjcw== +"@budibase/types@1.3.15-alpha.2": + version "1.3.15-alpha.2" + resolved "https://registry.yarnpkg.com/@budibase/types/-/types-1.3.15-alpha.2.tgz#e05d150327802940170b53d2a6ea8a17a1d597e6" + integrity sha512-zvOyOkTlSHAgV+e8xr9hR+E/M6gMXD6qxJGYyateBpIY/SPt+AoGUC5kn2YMD6ewlH+tNBQ6lahfU2pqPMPrxA== "@bull-board/api@3.7.0": version "3.7.0" diff --git a/packages/worker/package.json b/packages/worker/package.json index b45fbf87b0..ffb7057921 100644 --- a/packages/worker/package.json +++ b/packages/worker/package.json @@ -36,7 +36,7 @@ "license": "GPL-3.0", "dependencies": { "@budibase/backend-core": "1.3.15-alpha.2", - "@budibase/pro": "1.3.15-alpha.1", + "@budibase/pro": "1.3.15-alpha.2", "@budibase/string-templates": "1.3.15-alpha.2", "@budibase/types": "1.3.15-alpha.2", "@koa/router": "8.0.8", diff --git a/packages/worker/yarn.lock b/packages/worker/yarn.lock index 959d6bf5e7..32f0b55f70 100644 --- a/packages/worker/yarn.lock +++ b/packages/worker/yarn.lock @@ -291,12 +291,12 @@ resolved "https://registry.yarnpkg.com/@bcoe/v8-coverage/-/v8-coverage-0.2.3.tgz#75a2e8b51cb758a7553d6804a5932d7aace75c39" integrity sha512-0hYQ8SB4Db5zvZB4axdMHGwEaQjkZzFjQiN9LVYvIFB2nSUHW9tYpxWriPrWDASIxiaXax83REcLxuSdnGPZtw== -"@budibase/backend-core@1.3.15-alpha.1": - version "1.3.15-alpha.1" - resolved "https://registry.yarnpkg.com/@budibase/backend-core/-/backend-core-1.3.15-alpha.1.tgz#75f04e61374b00e507cad790f584b3a686f45533" - integrity sha512-ebkthJl0YMqpZAS+lm/OjX6TakAOnf0E1mBrxrPrlvq33Z8Imp5qrWq+UJswh/ltTUFd1Zxm21lMKweCdV2kOg== +"@budibase/backend-core@1.3.15-alpha.2": + version "1.3.15-alpha.2" + resolved "https://registry.yarnpkg.com/@budibase/backend-core/-/backend-core-1.3.15-alpha.2.tgz#ed3c7cc270147f660553b9f2972ef7cdc544fd21" + integrity sha512-voJFjd78CCdsINk+e1CYyXhGx4ubWJ9k2ILVUWooWgUAaYfjlJHKLH5yjNhVOdXGd0NVebLgMoTIgIHk5lPoFw== dependencies: - "@budibase/types" "1.3.15-alpha.1" + "@budibase/types" "1.3.15-alpha.2" "@shopify/jest-koa-mocks" "5.0.1" "@techpass/passport-openidconnect" "0.3.2" aws-sdk "2.1030.0" @@ -326,21 +326,21 @@ uuid "8.3.2" zlib "1.0.5" -"@budibase/pro@1.3.15-alpha.1": - version "1.3.15-alpha.1" - resolved "https://registry.yarnpkg.com/@budibase/pro/-/pro-1.3.15-alpha.1.tgz#0575016bf9bed5c36b6ebbb6b98a999f1d365522" - integrity sha512-8cxkEZcuvmoor8zVTFz6X+oeYXEdYmPUrXCBmya6IwqmhtIk/rJ7Ps4S7JNgdndeEQsxQc8Ch8ur/KaA/tb94Q== +"@budibase/pro@1.3.15-alpha.2": + version "1.3.15-alpha.2" + resolved "https://registry.yarnpkg.com/@budibase/pro/-/pro-1.3.15-alpha.2.tgz#c6b0586ba2775fb7dd8bab7bebae49f38154056b" + integrity sha512-oaxt5fCpzaBHRkRwGxYt6zXTM9Mn1+niCBXCSA+weTNMqpCg9VlfE+XIvkwBTs0ehpnJsJsseZ/j49fHQ4TqGg== dependencies: - "@budibase/backend-core" "1.3.15-alpha.1" - "@budibase/types" "1.3.15-alpha.1" + "@budibase/backend-core" "1.3.15-alpha.2" + "@budibase/types" "1.3.15-alpha.2" "@koa/router" "8.0.8" joi "17.6.0" node-fetch "^2.6.1" -"@budibase/types@1.3.15-alpha.1": - version "1.3.15-alpha.1" - resolved "https://registry.yarnpkg.com/@budibase/types/-/types-1.3.15-alpha.1.tgz#28dc4457de6bfe3c673421fa4cae728d3a4d87b8" - integrity sha512-318QMe3RI0UX47FpOxcM7BQU+TSexMkTBaH6G/BAHhZr/dWTP6I9MITuWpVKUxZgdJHvhZdbUeknHXUgR7Wjcw== +"@budibase/types@1.3.15-alpha.2": + version "1.3.15-alpha.2" + resolved "https://registry.yarnpkg.com/@budibase/types/-/types-1.3.15-alpha.2.tgz#e05d150327802940170b53d2a6ea8a17a1d597e6" + integrity sha512-zvOyOkTlSHAgV+e8xr9hR+E/M6gMXD6qxJGYyateBpIY/SPt+AoGUC5kn2YMD6ewlH+tNBQ6lahfU2pqPMPrxA== "@cspotcode/source-map-consumer@0.8.0": version "0.8.0" From a1eafcef980f6ed36933a6d2953e35b0de82be51 Mon Sep 17 00:00:00 2001 From: Budibase Staging Release Bot <> Date: Tue, 13 Sep 2022 09:48:22 +0000 Subject: [PATCH 201/203] v1.3.15-alpha.3 --- lerna.json | 2 +- packages/backend-core/package.json | 4 ++-- packages/bbui/package.json | 4 ++-- packages/builder/package.json | 10 +++++----- packages/cli/package.json | 8 ++++---- packages/client/package.json | 8 ++++---- packages/frontend-core/package.json | 4 ++-- packages/server/package.json | 10 +++++----- packages/string-templates/package.json | 2 +- packages/types/package.json | 2 +- packages/worker/package.json | 8 ++++---- 11 files changed, 31 insertions(+), 31 deletions(-) diff --git a/lerna.json b/lerna.json index d004e68e33..1089acf87a 100644 --- a/lerna.json +++ b/lerna.json @@ -1,5 +1,5 @@ { - "version": "1.3.15-alpha.2", + "version": "1.3.15-alpha.3", "npmClient": "yarn", "packages": [ "packages/*" diff --git a/packages/backend-core/package.json b/packages/backend-core/package.json index 0c1ad0c7e8..9a770d3887 100644 --- a/packages/backend-core/package.json +++ b/packages/backend-core/package.json @@ -1,6 +1,6 @@ { "name": "@budibase/backend-core", - "version": "1.3.15-alpha.2", + "version": "1.3.15-alpha.3", "description": "Budibase backend core libraries used in server and worker", "main": "dist/src/index.js", "types": "dist/src/index.d.ts", @@ -20,7 +20,7 @@ "test:watch": "jest --watchAll" }, "dependencies": { - "@budibase/types": "1.3.15-alpha.2", + "@budibase/types": "1.3.15-alpha.3", "@shopify/jest-koa-mocks": "5.0.1", "@techpass/passport-openidconnect": "0.3.2", "aws-sdk": "2.1030.0", diff --git a/packages/bbui/package.json b/packages/bbui/package.json index 4cdea18b36..41ca994b87 100644 --- a/packages/bbui/package.json +++ b/packages/bbui/package.json @@ -1,7 +1,7 @@ { "name": "@budibase/bbui", "description": "A UI solution used in the different Budibase projects.", - "version": "1.3.15-alpha.2", + "version": "1.3.15-alpha.3", "license": "MPL-2.0", "svelte": "src/index.js", "module": "dist/bbui.es.js", @@ -38,7 +38,7 @@ ], "dependencies": { "@adobe/spectrum-css-workflow-icons": "^1.2.1", - "@budibase/string-templates": "1.3.15-alpha.2", + "@budibase/string-templates": "1.3.15-alpha.3", "@spectrum-css/actionbutton": "^1.0.1", "@spectrum-css/actiongroup": "^1.0.1", "@spectrum-css/avatar": "^3.0.2", diff --git a/packages/builder/package.json b/packages/builder/package.json index f6f1d04ef8..dd918132d7 100644 --- a/packages/builder/package.json +++ b/packages/builder/package.json @@ -1,6 +1,6 @@ { "name": "@budibase/builder", - "version": "1.3.15-alpha.2", + "version": "1.3.15-alpha.3", "license": "GPL-3.0", "private": true, "scripts": { @@ -69,10 +69,10 @@ } }, "dependencies": { - "@budibase/bbui": "1.3.15-alpha.2", - "@budibase/client": "1.3.15-alpha.2", - "@budibase/frontend-core": "1.3.15-alpha.2", - "@budibase/string-templates": "1.3.15-alpha.2", + "@budibase/bbui": "1.3.15-alpha.3", + "@budibase/client": "1.3.15-alpha.3", + "@budibase/frontend-core": "1.3.15-alpha.3", + "@budibase/string-templates": "1.3.15-alpha.3", "@sentry/browser": "5.19.1", "@spectrum-css/page": "^3.0.1", "@spectrum-css/vars": "^3.0.1", diff --git a/packages/cli/package.json b/packages/cli/package.json index 1e94041311..42499a3c00 100644 --- a/packages/cli/package.json +++ b/packages/cli/package.json @@ -1,6 +1,6 @@ { "name": "@budibase/cli", - "version": "1.3.15-alpha.2", + "version": "1.3.15-alpha.3", "description": "Budibase CLI, for developers, self hosting and migrations.", "main": "src/index.js", "bin": { @@ -26,9 +26,9 @@ "outputPath": "build" }, "dependencies": { - "@budibase/backend-core": "1.3.15-alpha.2", - "@budibase/string-templates": "1.3.15-alpha.2", - "@budibase/types": "1.3.15-alpha.2", + "@budibase/backend-core": "1.3.15-alpha.3", + "@budibase/string-templates": "1.3.15-alpha.3", + "@budibase/types": "1.3.15-alpha.3", "axios": "0.21.2", "chalk": "4.1.0", "cli-progress": "3.11.2", diff --git a/packages/client/package.json b/packages/client/package.json index 318b246c9d..f20fda52f8 100644 --- a/packages/client/package.json +++ b/packages/client/package.json @@ -1,6 +1,6 @@ { "name": "@budibase/client", - "version": "1.3.15-alpha.2", + "version": "1.3.15-alpha.3", "license": "MPL-2.0", "module": "dist/budibase-client.js", "main": "dist/budibase-client.js", @@ -19,9 +19,9 @@ "dev:builder": "rollup -cw" }, "dependencies": { - "@budibase/bbui": "1.3.15-alpha.2", - "@budibase/frontend-core": "1.3.15-alpha.2", - "@budibase/string-templates": "1.3.15-alpha.2", + "@budibase/bbui": "1.3.15-alpha.3", + "@budibase/frontend-core": "1.3.15-alpha.3", + "@budibase/string-templates": "1.3.15-alpha.3", "@spectrum-css/button": "^3.0.3", "@spectrum-css/card": "^3.0.3", "@spectrum-css/divider": "^1.0.3", diff --git a/packages/frontend-core/package.json b/packages/frontend-core/package.json index f33aa5d7d9..8621675d2c 100644 --- a/packages/frontend-core/package.json +++ b/packages/frontend-core/package.json @@ -1,12 +1,12 @@ { "name": "@budibase/frontend-core", - "version": "1.3.15-alpha.2", + "version": "1.3.15-alpha.3", "description": "Budibase frontend core libraries used in builder and client", "author": "Budibase", "license": "MPL-2.0", "svelte": "src/index.js", "dependencies": { - "@budibase/bbui": "1.3.15-alpha.2", + "@budibase/bbui": "1.3.15-alpha.3", "lodash": "^4.17.21", "svelte": "^3.46.2" } diff --git a/packages/server/package.json b/packages/server/package.json index 6d48c0471e..3b1e4fd849 100644 --- a/packages/server/package.json +++ b/packages/server/package.json @@ -1,7 +1,7 @@ { "name": "@budibase/server", "email": "hi@budibase.com", - "version": "1.3.15-alpha.2", + "version": "1.3.15-alpha.3", "description": "Budibase Web Server", "main": "src/index.ts", "repository": { @@ -77,11 +77,11 @@ "license": "GPL-3.0", "dependencies": { "@apidevtools/swagger-parser": "10.0.3", - "@budibase/backend-core": "1.3.15-alpha.2", - "@budibase/client": "1.3.15-alpha.2", + "@budibase/backend-core": "1.3.15-alpha.3", + "@budibase/client": "1.3.15-alpha.3", "@budibase/pro": "1.3.15-alpha.2", - "@budibase/string-templates": "1.3.15-alpha.2", - "@budibase/types": "1.3.15-alpha.2", + "@budibase/string-templates": "1.3.15-alpha.3", + "@budibase/types": "1.3.15-alpha.3", "@bull-board/api": "3.7.0", "@bull-board/koa": "3.9.4", "@elastic/elasticsearch": "7.10.0", diff --git a/packages/string-templates/package.json b/packages/string-templates/package.json index b2e7a81eeb..a3774ab480 100644 --- a/packages/string-templates/package.json +++ b/packages/string-templates/package.json @@ -1,6 +1,6 @@ { "name": "@budibase/string-templates", - "version": "1.3.15-alpha.2", + "version": "1.3.15-alpha.3", "description": "Handlebars wrapper for Budibase templating.", "main": "src/index.cjs", "module": "dist/bundle.mjs", diff --git a/packages/types/package.json b/packages/types/package.json index 19010a7d1d..cd291963c6 100644 --- a/packages/types/package.json +++ b/packages/types/package.json @@ -1,6 +1,6 @@ { "name": "@budibase/types", - "version": "1.3.15-alpha.2", + "version": "1.3.15-alpha.3", "description": "Budibase types", "main": "dist/index.js", "types": "dist/index.d.ts", diff --git a/packages/worker/package.json b/packages/worker/package.json index ffb7057921..3ea66bf60d 100644 --- a/packages/worker/package.json +++ b/packages/worker/package.json @@ -1,7 +1,7 @@ { "name": "@budibase/worker", "email": "hi@budibase.com", - "version": "1.3.15-alpha.2", + "version": "1.3.15-alpha.3", "description": "Budibase background service", "main": "src/index.ts", "repository": { @@ -35,10 +35,10 @@ "author": "Budibase", "license": "GPL-3.0", "dependencies": { - "@budibase/backend-core": "1.3.15-alpha.2", + "@budibase/backend-core": "1.3.15-alpha.3", "@budibase/pro": "1.3.15-alpha.2", - "@budibase/string-templates": "1.3.15-alpha.2", - "@budibase/types": "1.3.15-alpha.2", + "@budibase/string-templates": "1.3.15-alpha.3", + "@budibase/types": "1.3.15-alpha.3", "@koa/router": "8.0.8", "@sentry/node": "6.17.7", "@techpass/passport-openidconnect": "0.3.2", From ac6a81ca40ccf0eb4cae0e9dcd154959ea0a1c83 Mon Sep 17 00:00:00 2001 From: Budibase Staging Release Bot <> Date: Tue, 13 Sep 2022 09:52:08 +0000 Subject: [PATCH 202/203] Update pro version to 1.3.15-alpha.3 --- packages/server/package.json | 2 +- packages/server/yarn.lock | 30 +++++++++++++++--------------- packages/worker/package.json | 2 +- packages/worker/yarn.lock | 30 +++++++++++++++--------------- 4 files changed, 32 insertions(+), 32 deletions(-) diff --git a/packages/server/package.json b/packages/server/package.json index 3b1e4fd849..8a9281f47b 100644 --- a/packages/server/package.json +++ b/packages/server/package.json @@ -79,7 +79,7 @@ "@apidevtools/swagger-parser": "10.0.3", "@budibase/backend-core": "1.3.15-alpha.3", "@budibase/client": "1.3.15-alpha.3", - "@budibase/pro": "1.3.15-alpha.2", + "@budibase/pro": "1.3.15-alpha.3", "@budibase/string-templates": "1.3.15-alpha.3", "@budibase/types": "1.3.15-alpha.3", "@bull-board/api": "3.7.0", diff --git a/packages/server/yarn.lock b/packages/server/yarn.lock index 77b6daae57..e16d25abd2 100644 --- a/packages/server/yarn.lock +++ b/packages/server/yarn.lock @@ -1094,12 +1094,12 @@ resolved "https://registry.yarnpkg.com/@bcoe/v8-coverage/-/v8-coverage-0.2.3.tgz#75a2e8b51cb758a7553d6804a5932d7aace75c39" integrity sha512-0hYQ8SB4Db5zvZB4axdMHGwEaQjkZzFjQiN9LVYvIFB2nSUHW9tYpxWriPrWDASIxiaXax83REcLxuSdnGPZtw== -"@budibase/backend-core@1.3.15-alpha.2": - version "1.3.15-alpha.2" - resolved "https://registry.yarnpkg.com/@budibase/backend-core/-/backend-core-1.3.15-alpha.2.tgz#ed3c7cc270147f660553b9f2972ef7cdc544fd21" - integrity sha512-voJFjd78CCdsINk+e1CYyXhGx4ubWJ9k2ILVUWooWgUAaYfjlJHKLH5yjNhVOdXGd0NVebLgMoTIgIHk5lPoFw== +"@budibase/backend-core@1.3.15-alpha.3": + version "1.3.15-alpha.3" + resolved "https://registry.yarnpkg.com/@budibase/backend-core/-/backend-core-1.3.15-alpha.3.tgz#d7727555829511ac0abc5a95f791067bf7e316d5" + integrity sha512-4buol+Dz4oLOnwij/SepNV4tP1o2HGIPGUxnWYH4idLpnDFeNXLPZ+eh0Kmj3sEmkKm/Yb5MNcPl2gr+62Grfw== dependencies: - "@budibase/types" "1.3.15-alpha.2" + "@budibase/types" "1.3.15-alpha.3" "@shopify/jest-koa-mocks" "5.0.1" "@techpass/passport-openidconnect" "0.3.2" aws-sdk "2.1030.0" @@ -1179,13 +1179,13 @@ svelte-flatpickr "^3.2.3" svelte-portal "^1.0.0" -"@budibase/pro@1.3.15-alpha.2": - version "1.3.15-alpha.2" - resolved "https://registry.yarnpkg.com/@budibase/pro/-/pro-1.3.15-alpha.2.tgz#c6b0586ba2775fb7dd8bab7bebae49f38154056b" - integrity sha512-oaxt5fCpzaBHRkRwGxYt6zXTM9Mn1+niCBXCSA+weTNMqpCg9VlfE+XIvkwBTs0ehpnJsJsseZ/j49fHQ4TqGg== +"@budibase/pro@1.3.15-alpha.3": + version "1.3.15-alpha.3" + resolved "https://registry.yarnpkg.com/@budibase/pro/-/pro-1.3.15-alpha.3.tgz#d062351202f544bdfd11e1364dd36791c156e7be" + integrity sha512-6ndItwEEZxOgJayIqawbG6VYOO49hrlP1UrWAAW+X7ykFCZNi4KC4Qaa4AFaF6PRttvMHfvtjQ3Mlc9fr2CCmA== dependencies: - "@budibase/backend-core" "1.3.15-alpha.2" - "@budibase/types" "1.3.15-alpha.2" + "@budibase/backend-core" "1.3.15-alpha.3" + "@budibase/types" "1.3.15-alpha.3" "@koa/router" "8.0.8" joi "17.6.0" node-fetch "^2.6.1" @@ -1208,10 +1208,10 @@ svelte-apexcharts "^1.0.2" svelte-flatpickr "^3.1.0" -"@budibase/types@1.3.15-alpha.2": - version "1.3.15-alpha.2" - resolved "https://registry.yarnpkg.com/@budibase/types/-/types-1.3.15-alpha.2.tgz#e05d150327802940170b53d2a6ea8a17a1d597e6" - integrity sha512-zvOyOkTlSHAgV+e8xr9hR+E/M6gMXD6qxJGYyateBpIY/SPt+AoGUC5kn2YMD6ewlH+tNBQ6lahfU2pqPMPrxA== +"@budibase/types@1.3.15-alpha.3": + version "1.3.15-alpha.3" + resolved "https://registry.yarnpkg.com/@budibase/types/-/types-1.3.15-alpha.3.tgz#d4fb023e68c0980b8cb54305a5ab31c5c34a20ee" + integrity sha512-geAkfvu1zaA0tf2Rn+sGnKTrZ9J9UkzqtrqffLKNVHdlWrOfCGrLtOufjFo5H7CfTMG/1ysvmSb4QaU/dPf3Ag== "@bull-board/api@3.7.0": version "3.7.0" diff --git a/packages/worker/package.json b/packages/worker/package.json index 3ea66bf60d..aa5b04f4ab 100644 --- a/packages/worker/package.json +++ b/packages/worker/package.json @@ -36,7 +36,7 @@ "license": "GPL-3.0", "dependencies": { "@budibase/backend-core": "1.3.15-alpha.3", - "@budibase/pro": "1.3.15-alpha.2", + "@budibase/pro": "1.3.15-alpha.3", "@budibase/string-templates": "1.3.15-alpha.3", "@budibase/types": "1.3.15-alpha.3", "@koa/router": "8.0.8", diff --git a/packages/worker/yarn.lock b/packages/worker/yarn.lock index 32f0b55f70..ba66cab653 100644 --- a/packages/worker/yarn.lock +++ b/packages/worker/yarn.lock @@ -291,12 +291,12 @@ resolved "https://registry.yarnpkg.com/@bcoe/v8-coverage/-/v8-coverage-0.2.3.tgz#75a2e8b51cb758a7553d6804a5932d7aace75c39" integrity sha512-0hYQ8SB4Db5zvZB4axdMHGwEaQjkZzFjQiN9LVYvIFB2nSUHW9tYpxWriPrWDASIxiaXax83REcLxuSdnGPZtw== -"@budibase/backend-core@1.3.15-alpha.2": - version "1.3.15-alpha.2" - resolved "https://registry.yarnpkg.com/@budibase/backend-core/-/backend-core-1.3.15-alpha.2.tgz#ed3c7cc270147f660553b9f2972ef7cdc544fd21" - integrity sha512-voJFjd78CCdsINk+e1CYyXhGx4ubWJ9k2ILVUWooWgUAaYfjlJHKLH5yjNhVOdXGd0NVebLgMoTIgIHk5lPoFw== +"@budibase/backend-core@1.3.15-alpha.3": + version "1.3.15-alpha.3" + resolved "https://registry.yarnpkg.com/@budibase/backend-core/-/backend-core-1.3.15-alpha.3.tgz#d7727555829511ac0abc5a95f791067bf7e316d5" + integrity sha512-4buol+Dz4oLOnwij/SepNV4tP1o2HGIPGUxnWYH4idLpnDFeNXLPZ+eh0Kmj3sEmkKm/Yb5MNcPl2gr+62Grfw== dependencies: - "@budibase/types" "1.3.15-alpha.2" + "@budibase/types" "1.3.15-alpha.3" "@shopify/jest-koa-mocks" "5.0.1" "@techpass/passport-openidconnect" "0.3.2" aws-sdk "2.1030.0" @@ -326,21 +326,21 @@ uuid "8.3.2" zlib "1.0.5" -"@budibase/pro@1.3.15-alpha.2": - version "1.3.15-alpha.2" - resolved "https://registry.yarnpkg.com/@budibase/pro/-/pro-1.3.15-alpha.2.tgz#c6b0586ba2775fb7dd8bab7bebae49f38154056b" - integrity sha512-oaxt5fCpzaBHRkRwGxYt6zXTM9Mn1+niCBXCSA+weTNMqpCg9VlfE+XIvkwBTs0ehpnJsJsseZ/j49fHQ4TqGg== +"@budibase/pro@1.3.15-alpha.3": + version "1.3.15-alpha.3" + resolved "https://registry.yarnpkg.com/@budibase/pro/-/pro-1.3.15-alpha.3.tgz#d062351202f544bdfd11e1364dd36791c156e7be" + integrity sha512-6ndItwEEZxOgJayIqawbG6VYOO49hrlP1UrWAAW+X7ykFCZNi4KC4Qaa4AFaF6PRttvMHfvtjQ3Mlc9fr2CCmA== dependencies: - "@budibase/backend-core" "1.3.15-alpha.2" - "@budibase/types" "1.3.15-alpha.2" + "@budibase/backend-core" "1.3.15-alpha.3" + "@budibase/types" "1.3.15-alpha.3" "@koa/router" "8.0.8" joi "17.6.0" node-fetch "^2.6.1" -"@budibase/types@1.3.15-alpha.2": - version "1.3.15-alpha.2" - resolved "https://registry.yarnpkg.com/@budibase/types/-/types-1.3.15-alpha.2.tgz#e05d150327802940170b53d2a6ea8a17a1d597e6" - integrity sha512-zvOyOkTlSHAgV+e8xr9hR+E/M6gMXD6qxJGYyateBpIY/SPt+AoGUC5kn2YMD6ewlH+tNBQ6lahfU2pqPMPrxA== +"@budibase/types@1.3.15-alpha.3": + version "1.3.15-alpha.3" + resolved "https://registry.yarnpkg.com/@budibase/types/-/types-1.3.15-alpha.3.tgz#d4fb023e68c0980b8cb54305a5ab31c5c34a20ee" + integrity sha512-geAkfvu1zaA0tf2Rn+sGnKTrZ9J9UkzqtrqffLKNVHdlWrOfCGrLtOufjFo5H7CfTMG/1ysvmSb4QaU/dPf3Ag== "@cspotcode/source-map-consumer@0.8.0": version "0.8.0" From e53f7a1d286c2b5568fbfefa06820f0cd2798a32 Mon Sep 17 00:00:00 2001 From: Mel O'Hagan Date: Tue, 13 Sep 2022 10:55:38 +0100 Subject: [PATCH 203/203] Case insensitive table fetch --- packages/server/src/api/controllers/datasource.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/packages/server/src/api/controllers/datasource.js b/packages/server/src/api/controllers/datasource.js index 75fd1db02a..f7784d31d6 100644 --- a/packages/server/src/api/controllers/datasource.js +++ b/packages/server/src/api/controllers/datasource.js @@ -58,7 +58,9 @@ exports.buildSchemaFromDb = async function (ctx) { datasource.entities = {} } for (let key in tables) { - if (tablesFilter.includes(key)) { + if ( + tablesFilter.some(filter => filter.toLowerCase() === key.toLowerCase()) + ) { datasource.entities[key] = tables[key] } } @@ -237,7 +239,7 @@ const buildSchemaHelper = async datasource => { await connector.buildSchema(datasource._id, datasource.entities) // make sure they all have a display name selected - for (let entity of Object.values(datasource.entities)) { + for (let entity of Object.values(datasource.entities ?? {})) { if (entity.primaryDisplay) { continue }