Merge branch 'develop' into budi-7352-query-parameter-fields-dont-save-in-external-data-connector

This commit is contained in:
Andrew Kingston 2023-08-02 16:38:23 +01:00 committed by GitHub
commit a853e32ede
37 changed files with 221 additions and 232 deletions

View File

@ -154,7 +154,7 @@ jobs:
node-version: 14.x
cache: "yarn"
- run: yarn
- run: yarn build
- run: yarn build --projects=@budibase/server,@budibase/worker,@budibase/client
- name: Run tests
run: |
cd qa-core

2
.gitignore vendored
View File

@ -101,8 +101,6 @@ packages/builder/cypress.env.json
packages/builder/cypress/reports
stats.html
# TypeScript cache
*.tsbuildinfo
# plugins
budibase-component

View File

@ -1,5 +1,5 @@
{
"version": "2.8.29-alpha.12",
"version": "2.8.29-alpha.15",
"npmClient": "yarn",
"packages": [
"packages/*"

11
nx.json
View File

@ -8,14 +8,5 @@
}
}
},
"targetDefaults": {
"dev:builder": {
"dependsOn": [
{
"projects": ["@budibase/string-templates"],
"target": "build"
}
]
}
}
"targetDefaults": {}
}

View File

@ -51,9 +51,9 @@
"kill-builder": "kill-port 3000",
"kill-server": "kill-port 4001 4002",
"kill-all": "yarn run kill-builder && yarn run kill-server",
"dev": "yarn run kill-all && lerna run --stream --parallel dev:builder",
"dev:noserver": "yarn run kill-builder && lerna run --stream dev:stack:up && lerna run --stream --parallel dev:builder --ignore @budibase/backend-core --ignore @budibase/server --ignore @budibase/worker",
"dev:server": "yarn run kill-server && lerna run --stream --parallel dev:builder --scope @budibase/worker --scope @budibase/server",
"dev": "yarn run kill-all && lerna run --stream dev:builder",
"dev:noserver": "yarn run kill-builder && lerna run --stream dev:stack:up && lerna run --stream dev:builder --ignore @budibase/backend-core --ignore @budibase/server --ignore @budibase/worker",
"dev:server": "yarn run kill-server && lerna run --stream dev:builder --scope @budibase/worker --scope @budibase/server",
"dev:built": "yarn run kill-all && cd packages/server && yarn dev:stack:up && cd ../../ && lerna run --stream dev:built",
"dev:docker": "yarn build:docker:pre && docker-compose -f hosting/docker-compose.build.yaml -f hosting/docker-compose.dev.yaml --env-file hosting/.env up --build --scale proxy-service=0",
"test": "lerna run --stream test --stream",

View File

@ -9,6 +9,7 @@ const baseConfig: Config.InitialProjectOptions = {
},
moduleNameMapper: {
"@budibase/types": "<rootDir>/../types/src",
"@budibase/shared-core": ["<rootDir>/../shared-core/src"],
},
}

View File

@ -88,20 +88,5 @@
"ts-node": "10.8.1",
"tsconfig-paths": "4.0.0",
"typescript": "4.7.3"
},
"nx": {
"targets": {
"build": {
"dependsOn": [
{
"projects": [
"@budibase/types"
],
"target": "build"
}
]
}
}
},
"gitHead": "d1836a898cab3f8ab80ee6d8f42be1a9eed7dcdc"
}

View File

@ -4,7 +4,8 @@
"composite": true,
"baseUrl": ".",
"paths": {
"@budibase/types": ["../types/src"]
"@budibase/types": ["../types/src"],
"@budibase/shared-core": ["../shared-core/src"]
}
},
"exclude": ["node_modules", "dist"]

View File

@ -98,13 +98,13 @@
{
"projects": [
"@budibase/string-templates",
"@budibase/shared-core"
"@budibase/shared-core",
"@budibase/types"
],
"target": "build"
}
]
}
}
},
"gitHead": "d1836a898cab3f8ab80ee6d8f42be1a9eed7dcdc"
}
}

View File

@ -133,8 +133,9 @@
"dependsOn": [
{
"projects": [
"@budibase/shared-core",
"@budibase/string-templates",
"@budibase/shared-core"
"@budibase/types"
],
"target": "build"
}
@ -144,8 +145,8 @@
"dependsOn": [
{
"projects": [
"@budibase/string-templates",
"@budibase/shared-core",
"@budibase/string-templates",
"@budibase/types"
],
"target": "build"
@ -157,13 +158,13 @@
{
"projects": [
"@budibase/shared-core",
"@budibase/string-templates"
"@budibase/string-templates",
"@budibase/types"
],
"target": "build"
}
]
}
}
},
"gitHead": "115189f72a850bfb52b65ec61d932531bf327072"
}
}

View File

@ -71,7 +71,8 @@
"dependsOn": [
{
"projects": [
"@budibase/backend-core"
"@budibase/backend-core",
"@budibase/string-templates"
],
"target": "build"
}

View File

@ -16,7 +16,6 @@
"require": ["tsconfig-paths/register"],
"swc": true
},
"references": [{ "path": "../types" }, { "path": "../backend-core" }],
"include": ["src/**/*", "package.json"],
"exclude": ["node_modules", "dist"]
}

View File

@ -70,14 +70,26 @@
"dependsOn": [
{
"projects": [
"@budibase/shared-core",
"@budibase/string-templates",
"@budibase/shared-core"
"@budibase/types"
],
"target": "build"
}
]
},
"dev:builder": {
"dependsOn": [
{
"projects": [
"@budibase/shared-core",
"@budibase/string-templates",
"@budibase/types"
],
"target": "build"
}
]
}
}
},
"gitHead": "d1836a898cab3f8ab80ee6d8f42be1a9eed7dcdc"
}
}

View File

@ -25,11 +25,11 @@ const devPaths = production
: [
{
find: "@budibase/shared-core",
replacement: path.resolve("../shared-core/dist/mjs/src/index"),
replacement: path.resolve("../shared-core/dist/index"),
},
{
find: "@budibase/types",
replacement: path.resolve("../types/dist/mjs/index"),
replacement: path.resolve("../types/dist/index"),
},
]

View File

@ -26,9 +26,9 @@
$: parentId = $component?.id
$: inBuilder = $builderStore.inBuilder
$: instance = {
_component: `@budibase/standard-components/${type}`,
_component: getComponent(type),
_id: id,
_instanceName: name || type[0].toUpperCase() + type.slice(1),
_instanceName: getInstanceName(name, type),
_styles: {
...styles,
normal: styles?.normal || {},
@ -45,6 +45,30 @@
}
}
const getComponent = type => {
if (!type) {
return null
}
if (type.startsWith("plugin/")) {
return type
} else {
return `@budibase/standard-components/${type}`
}
}
const getInstanceName = (name, type) => {
if (name) {
return name
}
if (!type) {
return "New component"
}
if (type.startsWith("plugin/")) {
type = type.split("plugin/")[1]
}
return type[0].toUpperCase() + type.slice(1)
}
onDestroy(() => {
if (inBuilder) {
block.unregisterComponent(id, parentId)

View File

@ -18,6 +18,8 @@ import { styleable } from "utils/styleable"
import { linkable } from "utils/linkable"
import { getAction } from "utils/getAction"
import Provider from "components/context/Provider.svelte"
import Block from "components/Block.svelte"
import BlockComponent from "components/BlockComponent.svelte"
import { ActionTypes } from "./constants"
import { fetchDatasourceSchema } from "./utils/schema.js"
import { getAPIKey } from "./utils/api.js"
@ -44,4 +46,6 @@ export default {
Provider,
ActionTypes,
getAPIKey,
Block,
BlockComponent,
}

View File

@ -1,10 +1,13 @@
{
"watch": ["src", "../backend-core", "../pro"],
"ext": "js,ts,json",
"ignore": [
"src/**/*.spec.ts",
"src/**/*.spec.js",
"../backend-core/dist/**/*"
"watch": [
"src",
"../backend-core",
"../pro",
"../types",
"../shared-core",
"../string-templates"
],
"ext": "js,ts,json",
"ignore": ["src/**/*.spec.ts", "src/**/*.spec.js", "../*/dist/**/*"],
"exec": "yarn build && node ./dist/index.js"
}

View File

@ -179,31 +179,5 @@
},
"optionalDependencies": {
"oracledb": "5.3.0"
},
"nx": {
"targets": {
"dev:builder": {
"dependsOn": [
{
"projects": [
"@budibase/backend-core"
],
"target": "build"
}
]
},
"test": {
"dependsOn": [
{
"projects": [
"@budibase/string-templates",
"@budibase/shared-core"
],
"target": "build"
}
]
}
}
},
"gitHead": "d1836a898cab3f8ab80ee6d8f42be1a9eed7dcdc"
}

View File

@ -5,8 +5,8 @@ if [[ -n $CI ]]
then
# --runInBand performs better in ci where resources are limited
export NODE_OPTIONS="--max-old-space-size=4096"
echo "jest --coverage --runInBand --forceExit"
jest --coverage --runInBand --forceExit
echo "jest --coverage --runInBand --forceExit --bail"
jest --coverage --runInBand --forceExit --bail
else
# --maxWorkers performs better in development
echo "jest --coverage --maxWorkers=2 --forceExit"

View File

@ -49,12 +49,18 @@ async function parseSchemaUI(ctx: Ctx, view: CreateViewRequest) {
const schemaUI =
view.schema &&
Object.entries(view.schema).reduce((p, [fieldName, schemaValue]) => {
p[fieldName] = {
const fieldSchema: RequiredKeys<UIFieldMetadata> = {
order: schemaValue.order,
width: schemaValue.width,
visible: schemaValue.visible,
icon: schemaValue.icon,
}
Object.entries(fieldSchema)
.filter(([_, val]) => val === undefined)
.forEach(([key]) => {
delete fieldSchema[key as keyof UIFieldMetadata]
})
p[fieldName] = fieldSchema
return p
}, {} as Record<string, RequiredKeys<UIFieldMetadata>>)
return schemaUI
@ -66,13 +72,14 @@ export async function create(ctx: Ctx<CreateViewRequest, ViewResponse>) {
const schemaUI = await parseSchemaUI(ctx, view)
const parsedView: Omit<ViewV2, "id" | "version"> = {
const parsedView: Omit<RequiredKeys<ViewV2>, "id" | "version"> = {
name: view.name,
tableId: view.tableId,
query: view.query,
sort: view.sort,
columns: view.schema && Object.keys(view.schema),
schemaUI,
primaryDisplay: view.primaryDisplay,
}
const result = await sdk.views.create(tableId, parsedView)
ctx.status = 201
@ -95,7 +102,7 @@ export async function update(ctx: Ctx<UpdateViewRequest, ViewResponse>) {
const { tableId } = view
const schemaUI = await parseSchemaUI(ctx, view)
const parsedView: ViewV2 = {
const parsedView: RequiredKeys<ViewV2> = {
id: view.id,
name: view.name,
version: view.version,
@ -104,6 +111,7 @@ export async function update(ctx: Ctx<UpdateViewRequest, ViewResponse>) {
sort: view.sort,
columns: view.schema && Object.keys(view.schema),
schemaUI,
primaryDisplay: view.primaryDisplay,
}
const result = await sdk.views.update(tableId, parsedView)

View File

@ -6,6 +6,7 @@ import {
SortOrder,
SortType,
Table,
UpdateViewRequest,
ViewV2,
} from "@budibase/types"
import { generator } from "@budibase/backend-core/tests"
@ -34,20 +35,6 @@ function priceTable(): Table {
describe("/v2/views", () => {
const config = setup.getConfig()
const viewFilters: Omit<CreateViewRequest, "name" | "tableId"> = {
query: { allOr: false, equal: { field: "value" } },
sort: {
field: "fieldToSort",
order: SortOrder.DESCENDING,
type: SortType.STRING,
},
schema: {
name: {
visible: true,
},
},
}
afterAll(setup.afterAll)
beforeAll(async () => {
@ -70,20 +57,30 @@ describe("/v2/views", () => {
})
})
it("can persist views with queries", async () => {
const newView: CreateViewRequest = {
it("can persist views with all fields", async () => {
const newView: Required<CreateViewRequest> = {
name: generator.name(),
tableId: config.table!._id!,
query: viewFilters.query,
sort: viewFilters.sort,
primaryDisplay: generator.word(),
query: { allOr: false, equal: { field: "value" } },
sort: {
field: "fieldToSort",
order: SortOrder.DESCENDING,
type: SortType.STRING,
},
schema: {
name: {
visible: true,
},
},
}
delete newView.schema
const res = await config.api.viewV2.create(newView)
expect(res).toEqual({
...newView,
query: viewFilters.query,
sort: viewFilters.sort,
schema: undefined,
columns: ["name"],
schemaUI: newView.schema,
id: expect.any(String),
version: 2,
})
@ -210,6 +207,46 @@ describe("/v2/views", () => {
})
})
it("can update all fields", async () => {
const tableId = config.table!._id!
const updatedData: Required<UpdateViewRequest> = {
version: view.version,
id: view.id,
tableId,
name: view.name,
primaryDisplay: generator.word(),
query: { equal: { [generator.word()]: generator.word() } },
sort: {
field: generator.word(),
order: SortOrder.DESCENDING,
type: SortType.STRING,
},
schema: {
Category: {
visible: false,
},
},
}
await config.api.viewV2.update(updatedData)
expect(await config.api.table.get(tableId)).toEqual({
...config.table,
views: {
[view.name]: {
...updatedData,
schema: {
Category: expect.objectContaining({
visible: false,
}),
},
},
},
_rev: expect.any(String),
updatedAt: expect.any(String),
})
})
it("can update an existing view name", async () => {
const tableId = config.table!._id!
await config.api.viewV2.update({ ...view, name: "View B" })

View File

@ -86,6 +86,7 @@ export function enrichSchema(view: View | ViewV2, tableSchema: TableSchema) {
: schema[fieldName].order,
}
}
delete view.schemaUI
}
if (view?.columns?.length) {
@ -97,6 +98,7 @@ export function enrichSchema(view: View | ViewV2, tableSchema: TableSchema) {
pickedSchema[fieldName] = { ...schema[fieldName] }
}
schema = pickedSchema
delete view.columns
}
return {

View File

@ -2,22 +2,21 @@
"name": "@budibase/shared-core",
"version": "0.0.0",
"description": "Shared data utils",
"main": "dist/cjs/src/index.js",
"types": "dist/mjs/src/index.d.ts",
"main": "src/index.ts",
"types": "src/index.ts",
"exports": {
".": {
"import": "./dist/mjs/src/index.js",
"require": "./dist/cjs/src/index.js"
},
"./package.json": "./dist/mjs/package.json"
"import": "./dist/index.js",
"require": "./src/index.ts"
}
},
"author": "Budibase",
"license": "GPL-3.0",
"scripts": {
"prebuild": "rimraf dist/",
"build": "tsc -p tsconfig.build.json && tsc -p tsconfig-cjs.build.json",
"build": "tsc -p tsconfig.build.json",
"build:dev": "yarn prebuild && tsc --build --watch --preserveWatchOutput",
"dev:builder": "yarn prebuild && concurrently \"tsc -p tsconfig.build.json --watch\" \"tsc -p tsconfig-cjs.build.json --watch\"",
"dev:builder": "yarn prebuild && tsc -p tsconfig.json --watch --preserveWatchOutput",
"check:types": "tsc -p tsconfig.json --noEmit --paths null"
},
"dependencies": {
@ -27,19 +26,5 @@
"concurrently": "^7.6.0",
"rimraf": "3.0.2",
"typescript": "4.7.3"
},
"nx": {
"targets": {
"build": {
"dependsOn": [
{
"projects": [
"@budibase/types"
],
"target": "build"
}
]
}
}
}
}

View File

@ -1,25 +0,0 @@
{
"compilerOptions": {
"target": "es6",
"moduleResolution": "node",
"lib": ["es2020"],
"strict": true,
"noImplicitAny": true,
"esModuleInterop": true,
"resolveJsonModule": true,
"incremental": true,
"sourceMap": true,
"declaration": true,
"types": ["node"],
"outDir": "dist",
"skipLibCheck": true
},
"include": ["**/*.js", "**/*.ts"],
"exclude": [
"node_modules",
"dist",
"**/*.spec.ts",
"**/*.spec.js",
"__mocks__"
]
}

View File

@ -1,8 +0,0 @@
{
"extends": "./tsconfig-base.build.json",
"compilerOptions": {
"module": "commonjs",
"outDir": "dist/cjs/src",
"target": "es2015"
}
}

View File

@ -1,8 +1,25 @@
{
"extends": "./tsconfig-base.build.json",
"compilerOptions": {
"module": "esnext",
"outDir": "dist/mjs/src",
"target": "esnext"
}
"target": "es6",
"moduleResolution": "node",
"lib": ["es2020"],
"strict": true,
"noImplicitAny": true,
"esModuleInterop": true,
"resolveJsonModule": true,
"incremental": true,
"sourceMap": true,
"declaration": true,
"types": ["node"],
"outDir": "dist",
"skipLibCheck": true
},
"include": ["**/*.js", "**/*.ts"],
"exclude": [
"node_modules",
"dist",
"**/*.spec.ts",
"**/*.spec.js",
"__mocks__"
]
}

View File

@ -1,12 +1,13 @@
{
"extends": "./tsconfig.build.json",
"compilerOptions": {
"composite": true,
"baseUrl": ".",
"rootDir": "./src",
"composite": true,
"tsBuildInfoFile": "dist/tsconfig.tsbuildinfo",
"paths": {
"@budibase/types": ["../types/src"]
"@budibase/types": ["../../types/src"]
}
},
"include": ["**/*.js", "**/*.ts"],
"exclude": ["node_modules", "dist"]
}

View File

@ -46,6 +46,5 @@
"rollup-plugin-node-resolve": "^5.2.0",
"rollup-plugin-terser": "^7.0.2",
"typescript": "4.7.3"
},
"gitHead": "d1836a898cab3f8ab80ee6d8f42be1a9eed7dcdc"
}
}

View File

@ -2,21 +2,21 @@
"name": "@budibase/types",
"version": "0.0.0",
"description": "Budibase types",
"main": "dist/cjs/index.js",
"types": "dist/mjs/index.d.ts",
"main": "src/index.ts",
"types": "src/index.ts",
"exports": {
".": {
"import": "./dist/mjs/index.js",
"require": "./dist/cjs/index.js"
"import": "./dist/index.js",
"require": "./src/index.ts"
}
},
"author": "Budibase",
"license": "GPL-3.0",
"scripts": {
"prebuild": "rimraf dist/",
"build": "tsc -p tsconfig.build.json && tsc -p tsconfig-cjs.build.json",
"build": "tsc -p tsconfig.build.json",
"build:dev": "yarn prebuild && tsc --build --watch --preserveWatchOutput",
"dev:builder": "yarn prebuild && concurrently \"tsc -p tsconfig.build.json --watch\" \"tsc -p tsconfig-cjs.build.json --watch\"",
"dev:builder": "yarn prebuild && tsc -p tsconfig.json --watch --preserveWatchOutput",
"check:types": "tsc -p tsconfig.json --noEmit --paths null"
},
"jest": {},

View File

@ -18,6 +18,7 @@ export interface ViewV2 {
version: 2
id: string
name: string
primaryDisplay?: string
tableId: string
query?: SearchFilters
sort?: {

View File

@ -1,15 +0,0 @@
{
"compilerOptions": {
"lib": ["es2020"],
"strict": true,
"noImplicitAny": true,
"esModuleInterop": true,
"resolveJsonModule": true,
"incremental": true,
"sourceMap": true,
"declaration": true,
"skipLibCheck": true
},
"include": ["src/**/*"],
"exclude": ["node_modules", "dist", "**/*.spec.ts", "**/*.spec.js"]
}

View File

@ -1,8 +0,0 @@
{
"extends": "./tsconfig-base.build.json",
"compilerOptions": {
"module": "commonjs",
"outDir": "dist/cjs",
"target": "es2015"
}
}

View File

@ -1,8 +1,18 @@
{
"extends": "./tsconfig-base.build.json",
"compilerOptions": {
"target": "es6",
"moduleResolution": "node",
"outDir": "dist/mjs"
}
"lib": ["es2020"],
"strict": true,
"noImplicitAny": true,
"esModuleInterop": true,
"resolveJsonModule": true,
"incremental": true,
"sourceMap": true,
"declaration": true,
"skipLibCheck": true,
"outDir": "dist"
},
"include": ["src/**/*"],
"exclude": ["node_modules", "dist", "**/*.spec.ts", "**/*.spec.js"]
}

View File

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

View File

@ -1,10 +1,13 @@
{
"watch": ["src", "../backend-core", "../pro"],
"ext": "js,ts,json",
"ignore": [
"src/**/*.spec.ts",
"src/**/*.spec.js",
"../backend-core/dist/**/*"
"watch": [
"src",
"../backend-core",
"../pro",
"../types",
"../shared-core",
"../string-templates"
],
"ext": "js,ts,json",
"ignore": ["src/**/*.spec.ts", "src/**/*.spec.js", "../*/dist/**/*"],
"exec": "yarn build && node dist/index.js"
}

View File

@ -102,20 +102,5 @@
"tsconfig-paths": "4.0.0",
"typescript": "4.7.3",
"update-dotenv": "1.1.1"
},
"nx": {
"targets": {
"dev:builder": {
"dependsOn": [
{
"projects": [
"@budibase/backend-core"
],
"target": "build"
}
]
}
}
},
"gitHead": "d1836a898cab3f8ab80ee6d8f42be1a9eed7dcdc"
}

View File

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