diff --git a/packages/backend-core/tests/core/utilities/structures/koa.ts b/packages/backend-core/tests/core/utilities/structures/koa.ts index 102fe029de..f9883dc1b9 100644 --- a/packages/backend-core/tests/core/utilities/structures/koa.ts +++ b/packages/backend-core/tests/core/utilities/structures/koa.ts @@ -2,7 +2,7 @@ import { createMockContext, createMockCookies } from "@shopify/jest-koa-mocks" import { BBContext } from "@budibase/types" export const newContext = (): BBContext => { - const ctx = createMockContext() + const ctx = createMockContext() as any return { ...ctx, path: "/", diff --git a/packages/server/src/sdk/app/automations/crud.ts b/packages/server/src/sdk/app/automations/crud.ts index ee7e3a3506..2b36e32397 100644 --- a/packages/server/src/sdk/app/automations/crud.ts +++ b/packages/server/src/sdk/app/automations/crud.ts @@ -1,5 +1,10 @@ -import { Automation, Webhook, WebhookActionType } from "@budibase/types" import { sdk } from "@budibase/shared-core" +import { + Automation, + RequiredKeys, + Webhook, + WebhookActionType, +} from "@budibase/types" import { generateAutomationID, getAutomationParams } from "../../../db/utils" import { deleteEntityMetadata } from "../../../utilities" import { MetadataTypes } from "../../../constants" @@ -82,17 +87,20 @@ export async function fetch() { include_docs: true, }) ) - return response.rows.map(row => row.doc).filter(doc => !!doc) + return response.rows + .map(row => row.doc) + .filter(doc => !!doc) + .map(trimUnexpectedObjectFields) } export async function get(automationId: string) { const db = getDb() const result = await db.get(automationId) - return result + return trimUnexpectedObjectFields(result) } export async function create(automation: Automation) { - automation = { ...automation } + automation = trimUnexpectedObjectFields(automation) const db = getDb() // Respect existing IDs if recreating a deleted automation @@ -117,7 +125,7 @@ export async function create(automation: Automation) { } export async function update(automation: Automation) { - automation = { ...automation } + automation = trimUnexpectedObjectFields(automation) if (!automation._id || !automation._rev) { throw new HTTPError("_id or _rev fields missing", 400) } @@ -289,3 +297,30 @@ function guardInvalidUpdatesAndThrow( throw new Error("Row actions cannot be renamed") } } + +function trimUnexpectedObjectFields(automation: T): T { + // This will ensure all the automation fields (and nothing else) is mapped to the result + const allRequired: RequiredKeys = { + _id: automation._id, + _rev: automation._rev, + definition: automation.definition, + screenId: automation.screenId, + uiTree: automation.uiTree, + appId: automation.appId, + live: automation.live, + name: automation.name, + internal: automation.internal, + type: automation.type, + disabled: automation.disabled, + testData: automation.testData, + createdAt: automation.createdAt, + updatedAt: automation.updatedAt, + } + const result = { ...allRequired } as T + for (const key in result) { + if (!Object.prototype.hasOwnProperty.call(automation, key)) { + delete result[key] + } + } + return result as T +} diff --git a/scripts/deploy-camunda.sh b/scripts/deploy-camunda.sh index 90400a0449..440de65bb2 100755 --- a/scripts/deploy-camunda.sh +++ b/scripts/deploy-camunda.sh @@ -25,8 +25,10 @@ zbctl deploy resource onboarding.bpmn --insecure zbctl deploy resource free_trial.bpmn --insecure zbctl deploy resource verify_sso_login.bpmn --insecure -cd ../../../../../budibase/packages/account-portal/packages/server +cd ../../../../../budibase/packages/pro +yarn && yarn build +cd ../account-portal/packages/server yarn worker:run & cd ../../../.. && yarn dev:accountportal