diff --git a/package-lock.json b/package-lock.json index 87f964dd82..7ee3aa32c9 100644 --- a/package-lock.json +++ b/package-lock.json @@ -23451,7 +23451,7 @@ } }, "packages/backend": { - "version": "1.29.5", + "version": "1.29.6", "dependencies": { "@apollo/server": "4.9.4", "@aws-sdk/client-dynamodb": "3.460.0", @@ -23551,7 +23551,7 @@ } }, "packages/frontend": { - "version": "1.29.5", + "version": "1.29.6", "hasInstallScript": true, "dependencies": { "@datadog/browser-rum": "^5.2.0", @@ -23762,7 +23762,7 @@ }, "packages/types": { "name": "@plumber/types", - "version": "1.29.5" + "version": "1.29.6" } } } diff --git a/packages/backend/package.json b/packages/backend/package.json index 111df166fd..fadcee4ce7 100644 --- a/packages/backend/package.json +++ b/packages/backend/package.json @@ -105,5 +105,5 @@ "tsconfig-paths": "^4.2.0", "type-fest": "4.10.3" }, - "version": "1.29.5" + "version": "1.29.6" } diff --git a/packages/backend/src/apps/vault-workspace/__tests__/actions/create-row.test.ts b/packages/backend/src/apps/vault-workspace/__tests__/actions/create-row.test.ts deleted file mode 100644 index 469a855c8e..0000000000 --- a/packages/backend/src/apps/vault-workspace/__tests__/actions/create-row.test.ts +++ /dev/null @@ -1,152 +0,0 @@ -import { IGlobalVariable } from '@plumber/types' - -import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest' - -import app from '../..' -import createRowAction from '../../actions/create-row' - -const mocks = vi.hoisted(() => { - return { - createTableRow: vi.fn(), - } -}) - -vi.mock('../../common/create-table-row', () => ({ - default: mocks.createTableRow, -})) - -describe('create row', () => { - let $: IGlobalVariable - - beforeEach(() => { - $ = { - auth: { - set: vi.fn(), - data: {}, - }, - step: { - id: 'herp-derp', - appKey: 'vault-workspace', - position: 1, - parameters: {}, - }, - app, - } - }) - - afterEach(() => { - vi.restoreAllMocks() - }) - - it('creates a row if columns and values have equal length ', async () => { - $.step.parameters.columns = 'column_1, column_2' - $.step.parameters.values = 'value_1, column_2' - await createRowAction.run($) - expect(mocks.createTableRow).toHaveBeenCalledOnce() - }) - - it('errors if columns and values have different lengths', async () => { - $.step.parameters.columns = 'column_1, column_2' - $.step.parameters.values = 'value_1' - // throw partial step error message - await expect(createRowAction.run($)).rejects.toThrowError( - 'Unequal number of columns and values', - ) - }) - - it.each([ - { columns: 'column_1, column_2', values: 'value_1, "value, with, comma"' }, - { - columns: 'column_1, "column, 2, with, comma,"', - values: 'value_1, value_2', - }, - { - columns: 'column_1, "column, 2, with, comma,"', - values: 'value_1, "value, with, comma"', - }, - ])( - 'supports values and columns with commas if properly double-quoted', - async ({ columns, values }) => { - $.step.parameters.columns = columns - $.step.parameters.values = values - await createRowAction.run($) - expect(mocks.createTableRow).toHaveBeenCalledOnce() - }, - ) - - describe('should decode url-encoded commas and double quotes properly', async () => { - it('should decode escaped commas', async () => { - $.step.parameters.columns = 'column_1, column_2' - $.step.parameters.values = 'value_1, value %2Cwith%2C commas' - await expect(createRowAction.run($)).resolves.toBe(undefined) - expect(mocks.createTableRow).toHaveBeenCalledWith($, { - column_1: 'value_1', - column_2: 'value ,with, commas', - }) - }) - it('should decode escaped double quotes', async () => { - $.step.parameters.columns = 'column_1, column_2' - $.step.parameters.values = 'value_1, %22value %22with%22 quotes%22' - await expect(createRowAction.run($)).resolves.toBe(undefined) - expect(mocks.createTableRow).toHaveBeenCalledWith($, { - column_1: 'value_1', - column_2: '"value "with" quotes"', - }) - }) - it('should decode escaped double quotes within double quotes', async () => { - $.step.parameters.columns = 'column_1, column_2' - $.step.parameters.values = 'value_1, "%22value %22with%22 quotes%22"' - await expect(createRowAction.run($)).resolves.toBe(undefined) - expect(mocks.createTableRow).toHaveBeenCalledWith($, { - column_1: 'value_1', - column_2: '"value "with" quotes"', - }) - }) - - it('should decode escaped double quotes within other double quotes', async () => { - $.step.parameters.columns = 'column_1, column_2' - $.step.parameters.values = 'value_1, asas"%22value %22with%22 quotes%22"' - await expect(createRowAction.run($)).resolves.toBe(undefined) - expect(mocks.createTableRow).toHaveBeenCalledWith($, { - column_1: 'value_1', - column_2: 'asas""value "with" quotes""', - }) - }) - - it('should throw step error for invalid usage of double quotes', async () => { - $.step.parameters.columns = 'column_1, "column"2"' - $.step.parameters.values = 'value_1, value_2' - // throw partial step error message - await expect(createRowAction.run($)).rejects.toThrowError( - 'Invalid usage of double quotes', - ) - }) - - it('should throw step error for no closing quotes', async () => { - $.step.parameters.columns = 'column_1, "column_2' - $.step.parameters.values = 'value_1, value_2' - // throw partial step error message - await expect(createRowAction.run($)).rejects.toThrowError( - 'No closing quote', - ) - }) - - it('should throw step error for newline characters in values field', async () => { - $.step.parameters.columns = 'column_1, column_2' - $.step.parameters.values = 'value_1\n, value_2' - // throw partial step error message - await expect(createRowAction.run($)).rejects.toThrowError( - 'Incorrect format for values field', - ) - }) - - it('should throw step error for undefined values field', async () => { - $.step.parameters.columns = 'column_1, column_2' - $.step.parameters.values = undefined - // throw partial step error message - await expect(createRowAction.run($)).rejects.toThrowError( - 'Undefined values field', - ) - }) - }) -}) diff --git a/packages/backend/src/apps/vault-workspace/__tests__/actions/get-data-out-metadata.test.ts b/packages/backend/src/apps/vault-workspace/__tests__/actions/get-data-out-metadata.test.ts deleted file mode 100644 index 293b1f85ac..0000000000 --- a/packages/backend/src/apps/vault-workspace/__tests__/actions/get-data-out-metadata.test.ts +++ /dev/null @@ -1,65 +0,0 @@ -import { IExecutionStep } from '@plumber/types' - -import { describe, expect, it } from 'vitest' - -import getDataOutMetadata from '../../actions/get-table-data/get-data-out-metadata' -import { VAULT_ID } from '../../common/constants' - -function convertKeyToHex(key: string) { - return Buffer.from(key).toString('hex') -} - -describe('Test getDataOutMetadata', () => { - it('vault metadata example that has no dataOut should not occur', async () => { - const testExecutionStep = { - empty: '', - } as unknown as IExecutionStep - const testMetadata = await getDataOutMetadata(testExecutionStep) - expect(testMetadata).toBeNull() - }) - - it('vault metadata example that is not keysEncoded should not occur', async () => { - const testExecutionStep = { - dataOut: { - _metadata: {}, - }, - } as unknown as IExecutionStep - const testMetadata = await getDataOutMetadata(testExecutionStep) - expect(testMetadata).toBeNull() - }) - - it('vault metadata example that is keysEncoded', async () => { - const testLabel1 = 'test label 1' - const testLabel2 = 'test label 2' - const testLabel1InHex = convertKeyToHex(testLabel1) - const testLabel2InHex = convertKeyToHex(testLabel2) - const testExecutionStep = { - dataOut: { - [VAULT_ID]: '123', - [testLabel1InHex]: 'test value 1', - [testLabel2InHex]: 'test value 2', - _metadata: { - success: true, - rowsFound: 2, - keysEncoded: true, - }, - }, - } as unknown as IExecutionStep - const testMetadata = await getDataOutMetadata(testExecutionStep) - const outputMetadata = { - [testLabel1InHex]: { - label: testLabel1, - }, - [testLabel2InHex]: { - label: testLabel2, - }, - _metadata: { - label: '', - }, - '_metadata.keysEncoded': { - isHidden: true, - }, - } - expect(testMetadata).toEqual(outputMetadata) - }) -}) diff --git a/packages/backend/src/apps/vault-workspace/__tests__/actions/get-table-row.test.ts b/packages/backend/src/apps/vault-workspace/__tests__/actions/get-table-row.test.ts deleted file mode 100644 index 37f219bc18..0000000000 --- a/packages/backend/src/apps/vault-workspace/__tests__/actions/get-table-row.test.ts +++ /dev/null @@ -1,168 +0,0 @@ -import { IGlobalVariable } from '@plumber/types' - -import { AxiosError } from 'axios' -import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest' - -import HttpError from '@/errors/http' - -import app from '../..' -import getTableDataAction from '../../actions/get-table-data' -import { VAULT_ID } from '../../common/constants' - -const VAULT_COLUMN_INTERNAL_ID = 'abcxyz' -const VAULT_COLUMN_NAME = 'column 1' -const VAULT_COLUMN_VALUE = 'value 1' - -const mocks = vi.hoisted(() => ({ - httpGet: vi.fn(), - getColumnMapping: vi.fn(), -})) - -vi.mock('../../common/get-column-mapping', async () => { - const actual = await vi.importActual< - typeof import('../../common/get-column-mapping') - >('../../common/get-column-mapping') - return { - ...actual, - getColumnMapping: mocks.getColumnMapping, - } -}) - -describe('get table row', () => { - let $: IGlobalVariable - - beforeEach(() => { - $ = { - auth: { - set: vi.fn(), - data: {}, - }, - step: { - id: '123', - appKey: 'vault-workspace', - position: 2, - parameters: {}, - }, - http: { - get: mocks.httpGet, - } as unknown as IGlobalVariable['http'], - setActionItem: vi.fn(), - app, - } - }) - - afterEach(() => { - vi.restoreAllMocks() - }) - - it('get row if row found', async () => { - $.step.parameters.lookupColumn = VAULT_COLUMN_NAME - $.step.parameters.lookupValue = VAULT_COLUMN_VALUE - const mockHttpResponse = { - data: { - rows: [ - { - [VAULT_COLUMN_INTERNAL_ID]: VAULT_COLUMN_VALUE, - [VAULT_ID]: '123', - }, - ], - }, - } - mocks.httpGet.mockResolvedValueOnce(mockHttpResponse) - - mocks.getColumnMapping.mockImplementationOnce((_$) => { - return { - [VAULT_COLUMN_INTERNAL_ID]: VAULT_COLUMN_NAME, - } - }) - - await getTableDataAction.run($) - expect($.setActionItem).toHaveBeenCalledWith({ - raw: { - [Buffer.from(VAULT_COLUMN_NAME).toString('hex')]: VAULT_COLUMN_VALUE, // convert key to hex - _metadata: { - success: true, - rowsFound: 1, - keysEncoded: true, - }, - [VAULT_ID]: '123', - }, - }) - }) - - it('should throw step error for invalid get request: bad request error', async () => { - $.step.parameters.lookupColumn = VAULT_COLUMN_NAME - $.step.parameters.lookupValue = VAULT_COLUMN_VALUE - const error400 = { - response: { - status: 400, - statusText: 'Bad request', - }, - } as AxiosError - const httpError = new HttpError(error400) - - mocks.httpGet.mockRejectedValueOnce(httpError) - // throw partial step error message - const stepErrorName = 'Missing lookup column' - await expect(getTableDataAction.run($)).rejects.toThrowError(stepErrorName) - }) - - it('should throw step error for invalid get request: internal status error', async () => { - $.step.parameters.lookupColumn = VAULT_COLUMN_NAME - $.step.parameters.lookupValue = VAULT_COLUMN_VALUE - const error500 = { - response: { - status: 500, - statusText: 'Internal Status Error', - }, - } as AxiosError - const httpError = new HttpError(error500) - - mocks.httpGet.mockRejectedValueOnce(httpError) - // throw partial step error message - const stepErrorName = 'Invalid lookup column used' - await expect(getTableDataAction.run($)).rejects.toThrowError(stepErrorName) - }) - - it('return success as false if no rows found', async () => { - $.step.parameters.lookupColumn = VAULT_COLUMN_NAME - $.step.parameters.lookupValue = 'invalid value' - const mockHttpResponse = { - data: { - rows: [] as any[], - }, - } - mocks.httpGet.mockResolvedValueOnce(mockHttpResponse) - await getTableDataAction.run($) - expect($.setActionItem).toHaveBeenCalledWith({ - raw: { - _metadata: { - success: false, - rowsFound: 0, - }, - }, - }) - }) - - it('should throw step error for undefined column bug', async () => { - $.step.parameters.lookupColumn = VAULT_COLUMN_NAME - $.step.parameters.lookupValue = VAULT_COLUMN_VALUE - // getColumnMapping will have no columns at all, so default mock implementation is used - const mockHttpResponse = { - data: { - rows: [ - { - [VAULT_COLUMN_INTERNAL_ID]: VAULT_COLUMN_VALUE, - [VAULT_ID]: '123', - }, - ], - }, - } - mocks.httpGet.mockResolvedValueOnce(mockHttpResponse) - - // throw partial step error message - await expect(getTableDataAction.run($)).rejects.toThrowError( - 'Undefined column name in Vault', - ) - }) -}) diff --git a/packages/backend/src/apps/vault-workspace/__tests__/actions/update-row.test.ts b/packages/backend/src/apps/vault-workspace/__tests__/actions/update-row.test.ts deleted file mode 100644 index 07d528d965..0000000000 --- a/packages/backend/src/apps/vault-workspace/__tests__/actions/update-row.test.ts +++ /dev/null @@ -1,124 +0,0 @@ -import { IGlobalVariable } from '@plumber/types' - -import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest' - -import app from '../..' -import updateTableDataAction from '../../actions/update-table-data' -import { VAULT_ID } from '../../common/constants' - -const mocks = vi.hoisted(() => { - return { - updateTableRow: vi.fn((_$, vaultId, delta) => { - if (vaultId === '123') { - return { - _metadata: { - success: true, - rowsUpdated: 1, - }, - ...delta, - [VAULT_ID]: '123', - } - } - return { - _metadata: { - success: false, - rowsUpdated: 0, - }, - } - }), - filterTableRows: vi.fn((_$, columnName, value) => { - if ( - columnName === 'valid_lookup_column' && - value === 'valid_lookup_value' - ) { - return { - _metadata: { - success: true, - rowsFound: 1, - }, - valid_lookup_column: value, - [VAULT_ID]: '123', - } - } - return { - _metadata: { - success: false, - rowsFound: 0, - }, - } - }), - } -}) - -vi.mock('../../common/update-table-row', () => ({ - default: mocks.updateTableRow, -})) - -vi.mock('../../common/filter-table-rows', () => ({ - default: mocks.filterTableRows, -})) - -describe('update row', () => { - let $: IGlobalVariable - - beforeEach(() => { - $ = { - auth: { - set: vi.fn(), - data: {}, - }, - step: { - id: 'herp-derp', - appKey: 'vault-workspace', - position: 1, - parameters: {}, - }, - app, - setActionItem: vi.fn(), - } - }) - - afterEach(() => { - vi.restoreAllMocks() - }) - - /** - * Success if row found - */ - it('update row if row found', async () => { - $.step.parameters.lookupColumn = 'valid_lookup_column' - $.step.parameters.lookupValue = 'valid_lookup_value' - $.step.parameters.updateColumn = 'update_column' - $.step.parameters.updateValue = 'update_value' - await updateTableDataAction.run($) - expect($.setActionItem).toHaveBeenCalledWith({ - raw: { - _metadata: { - success: true, - rowsUpdated: 1, - }, - update_column: 'update_value', - [VAULT_ID]: '123', - }, - }) - }) - - /** - * Failure if no rows found - */ - it('return success as false if no rows found', async () => { - $.step.parameters.lookupColumn = 'valid_lookup_column' - $.step.parameters.lookupValue = 'wrong_lookup_value' - $.step.parameters.updateColumn = 'update_column' - $.step.parameters.updateValue = 'update_value' - await updateTableDataAction.run($) - expect($.setActionItem).toHaveBeenCalledWith({ - raw: { - _metadata: { - success: false, - rowsUpdated: 0, - }, - }, - }) - }) -}) diff --git a/packages/backend/src/apps/vault-workspace/__tests__/auth/verify-credentials.test.ts b/packages/backend/src/apps/vault-workspace/__tests__/auth/verify-credentials.test.ts deleted file mode 100644 index 6f940031dc..0000000000 --- a/packages/backend/src/apps/vault-workspace/__tests__/auth/verify-credentials.test.ts +++ /dev/null @@ -1,53 +0,0 @@ -import { IGlobalVariable } from '@plumber/types' - -import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest' - -import app from '../..' -import verifyCredentials from '../../auth/verify-credentials' - -const mocks = vi.hoisted(() => { - return { - verifyAPIKey: vi.fn(() => Promise.resolve('vault-workspace-table-id')), - } -}) - -vi.mock('../../common/verify-api-key', () => ({ - default: mocks.verifyAPIKey, -})) - -describe('verifyCredentials', () => { - let $: IGlobalVariable - - beforeEach(() => { - $ = { - auth: { - set: vi.fn(), - data: { - consumerSecret: 'vault-workspace-api-key', - screenName: 'vault-workspace-api-key-label', - }, - }, - app, - } - }) - - afterEach(() => { - vi.restoreAllMocks() - }) - - it('calls verifyAPIKey to obtain the Vault Workspace Table ID', async () => { - await verifyCredentials($) - expect(mocks.verifyAPIKey).toHaveBeenCalledOnce() - expect(mocks.verifyAPIKey).toHaveBeenCalledWith($) - expect(mocks.verifyAPIKey()).resolves.toEqual('vault-workspace-table-id') - }) - - it('sets the Vault Workspace API key and label', async () => { - await verifyCredentials($) - expect($.auth.set).toHaveBeenCalledOnce() - expect($.auth.set).toHaveBeenCalledWith({ - consumerSecret: 'vault-workspace-api-key', - screenName: 'vault-workspace-api-key-label (vault-workspace-table-id)', - }) - }) -}) diff --git a/packages/backend/src/apps/vault-workspace/actions/create-row/index.ts b/packages/backend/src/apps/vault-workspace/actions/create-row/index.ts index dfbb66fb5a..7a0d03d505 100644 --- a/packages/backend/src/apps/vault-workspace/actions/create-row/index.ts +++ b/packages/backend/src/apps/vault-workspace/actions/create-row/index.ts @@ -1,15 +1,6 @@ import { IRawAction } from '@plumber/types' -import { parse as parseAsCsv } from 'csv-parse/sync' - -import StepError from '@/errors/step' - -import createTableRow from '../../common/create-table-row' -import { - escapeSpecialChars, - unescapeSpecialChars, -} from '../../common/escape-characters' -import { throwParseAsCsvError } from '../../common/throw-errors' +import { throwVaultDeprecationError } from '../../common/throw-vault-deprecation-error' const action: IRawAction = { name: 'Create row', @@ -34,61 +25,9 @@ const action: IRawAction = { description: 'Put a comma between each value.', }, ], - preprocessVariable: (key, value) => { - if (key !== 'values') { - return value - } - if (typeof value !== 'string') { - return value - } - // url encode commas and double quotes - return escapeSpecialChars(value) - }, async run($) { - let columns, values - try { - columns = parseAsCsv($.step.parameters.columns as string, { - columns: false, - trim: true, - relaxQuotes: true, - })[0] as string[] - - values = parseAsCsv($.step.parameters.values as string as string, { - columns: false, - trim: true, - relaxQuotes: true, - })[0] as string[] - } catch (err) { - throwParseAsCsvError(err, $.step.position, $.app.name) - } - - if (values === undefined) { - throw new StepError( - 'Undefined values field', - 'Click on set up action and check that the values field is not empty. This is most likely because you are using a single variable that could be empty.', - $.step.position, - $.app.name, - ) - } - - if (columns.length !== values.length) { - throw new StepError( - 'Unequal number of columns and values', - 'Click on set up action and check that every column or value is separated by a comma when intended. Then, verify that the number of columns and values are exactly equal in quantity.', - $.step.position, - $.app.name, - ) - } - - const row: { [key: string]: string } = {} - for (let i = 0; i < columns.length; i++) { - const columnName = columns[i] - const rowValue = unescapeSpecialChars(values[i]) - row[columnName] = rowValue - } - - await createTableRow($, row) + throwVaultDeprecationError($) }, } diff --git a/packages/backend/src/apps/vault-workspace/actions/debug/index.ts b/packages/backend/src/apps/vault-workspace/actions/debug/index.ts deleted file mode 100644 index 1ad713ef95..0000000000 --- a/packages/backend/src/apps/vault-workspace/actions/debug/index.ts +++ /dev/null @@ -1,48 +0,0 @@ -/* eslint-disable no-console */ - -import { IRawAction } from '@plumber/types' - -const action: IRawAction = { - name: 'Debug action', - key: 'debugAction', - description: 'Debug action from the vault workspace.', - arguments: [ - { - label: 'Lookup Column Debugger', - key: 'lookupColumn', - type: 'dropdown' as const, - required: true, - variables: true, - description: - 'Specify a column we should look for cells which match the Lookup Value.', - source: { - type: 'query', - name: 'getDynamicData', - arguments: [ - { - name: 'key', - value: 'listColumns', - }, - ], - }, - }, - { - label: 'Previous Steps Variable Debugger', - key: 'previousStepsVariable', - type: 'string' as const, - required: true, - variables: true, - }, - ], - - async run($) { - const lookupColumn = $.step.parameters.lookupColumn as string - const previousStepsVariable = $.step.parameters - .previousStepsVariable as string - - console.log(lookupColumn) - console.log(previousStepsVariable) - }, -} - -export default action diff --git a/packages/backend/src/apps/vault-workspace/actions/get-table-data/get-data-out-metadata.ts b/packages/backend/src/apps/vault-workspace/actions/get-table-data/get-data-out-metadata.ts deleted file mode 100644 index 41d4bec029..0000000000 --- a/packages/backend/src/apps/vault-workspace/actions/get-table-data/get-data-out-metadata.ts +++ /dev/null @@ -1,36 +0,0 @@ -import { IDataOutMetadata, IExecutionStep, IJSONObject } from '@plumber/types' - -import { VAULT_ID } from '../../common/constants' - -async function getDataOutMetadata( - step: IExecutionStep, -): Promise { - const data = step.dataOut - if (!data) { - return null - } - const _metadata = data?._metadata as IJSONObject - if (!_metadata.keysEncoded) { - return null - } - - const metadata = Object.create(null) - for (const key of Object.keys(data)) { - if (key === VAULT_ID) { - continue - } else if (key === '_metadata') { - metadata['_metadata.keysEncoded'] = { - isHidden: true, - } - } - // the key used for data retrieved from vault workspace are converted to hex - // to be compatible with our policy to only allow alphanumeric in template keys - // hence we need to decode here for display on frontend - metadata[key] = { - label: Buffer.from(key, 'hex').toString(), - } - } - return metadata -} - -export default getDataOutMetadata diff --git a/packages/backend/src/apps/vault-workspace/actions/get-table-data/index.ts b/packages/backend/src/apps/vault-workspace/actions/get-table-data/index.ts index bac19524b3..02b362bad9 100644 --- a/packages/backend/src/apps/vault-workspace/actions/get-table-data/index.ts +++ b/packages/backend/src/apps/vault-workspace/actions/get-table-data/index.ts @@ -1,9 +1,8 @@ import { IRawAction } from '@plumber/types' -import filterTableRows from '../../common/filter-table-rows' - -import getDataOutMetadata from './get-data-out-metadata' +import { throwVaultDeprecationError } from '../../common/throw-vault-deprecation-error' +// Note: column is still kept as dropdown so the db values are preserved const action: IRawAction = { name: 'Get table data', key: 'getTableData', @@ -17,16 +16,6 @@ const action: IRawAction = { variables: true, description: 'Specify a column we should look for cells which match the Lookup Value.', - source: { - type: 'query', - name: 'getDynamicData', - arguments: [ - { - name: 'key', - value: 'listColumns', - }, - ], - }, }, { @@ -37,15 +26,9 @@ const action: IRawAction = { variables: true, }, ], - getDataOutMetadata, async run($) { - const lookupColumn = $.step.parameters.lookupColumn as string - const lookupValue = $.step.parameters.lookupValue as string - const row = await filterTableRows($, lookupColumn, lookupValue) - $.setActionItem({ - raw: row, - }) + throwVaultDeprecationError($) }, } diff --git a/packages/backend/src/apps/vault-workspace/actions/update-table-data/index.ts b/packages/backend/src/apps/vault-workspace/actions/update-table-data/index.ts index 5a9551f6ea..429cfde8d4 100644 --- a/packages/backend/src/apps/vault-workspace/actions/update-table-data/index.ts +++ b/packages/backend/src/apps/vault-workspace/actions/update-table-data/index.ts @@ -1,9 +1,8 @@ import { IRawAction } from '@plumber/types' -import { VAULT_ID } from '../../common/constants' -import filterTableRows from '../../common/filter-table-rows' -import updateTableRow from '../../common/update-table-row' +import { throwVaultDeprecationError } from '../../common/throw-vault-deprecation-error' +// Note: columns are still kept as dropdown so the db values are preserved const action: IRawAction = { name: 'Update table data', key: 'updateTableData', @@ -17,16 +16,6 @@ const action: IRawAction = { variables: true, description: 'Specify a column we should look for cells which match the Lookup Value.', - source: { - type: 'query', - name: 'getDynamicData', - arguments: [ - { - name: 'key', - value: 'listColumns', - }, - ], - }, }, { label: 'Lookup Value', @@ -43,16 +32,6 @@ const action: IRawAction = { variables: true, description: 'Specify a column we should update for cells with the Update Value.', - source: { - type: 'query', - name: 'getDynamicData', - arguments: [ - { - name: 'key', - value: 'listUpdatableColumns', - }, - ], - }, }, { label: 'Update Value', @@ -64,33 +43,7 @@ const action: IRawAction = { ], async run($) { - const lookupColumn = $.step.parameters.lookupColumn as string - const lookupValue = $.step.parameters.lookupValue as string - const updateColumn = $.step.parameters.updateColumn as string - const updateValue = $.step.parameters.updateValue as string - - if (updateColumn === VAULT_ID) { - throw new Error('Cannot update the row id.') - } - - const row = await filterTableRows($, lookupColumn, lookupValue) - if (row._metadata?.rowsFound === 0) { - $.setActionItem({ - raw: { - _metadata: { - success: false, - rowsUpdated: 0, - }, - }, - }) - return - } - // update row - const payload: { [key: string]: string } = { [updateColumn]: updateValue } - const response = await updateTableRow($, row[VAULT_ID], payload) - $.setActionItem({ - raw: response, - }) + throwVaultDeprecationError($) }, } diff --git a/packages/backend/src/apps/vault-workspace/auth/index.ts b/packages/backend/src/apps/vault-workspace/auth/index.ts deleted file mode 100644 index 5868b10c00..0000000000 --- a/packages/backend/src/apps/vault-workspace/auth/index.ts +++ /dev/null @@ -1,36 +0,0 @@ -import type { IUserAddedConnectionAuth } from '@plumber/types' - -import isStillVerified from './is-still-verified' -import verifyCredentials from './verify-credentials' - -const auth: IUserAddedConnectionAuth = { - connectionType: 'user-added' as const, - - fields: [ - { - key: 'screenName', - label: 'Label', - type: 'string' as const, - required: true, - readOnly: false, - value: null, - description: 'Label for your Vault Workspace API Key.', - clickToCopy: false, - }, - { - key: 'apiKey', - label: 'Table API Key', - type: 'string' as const, - required: true, - readOnly: false, - value: null, - description: 'API key which should be retrieved from Vault Workspace.', - clickToCopy: false, - autoComplete: 'off' as const, - }, - ], - verifyCredentials, - isStillVerified, -} - -export default auth diff --git a/packages/backend/src/apps/vault-workspace/auth/is-still-verified.ts b/packages/backend/src/apps/vault-workspace/auth/is-still-verified.ts deleted file mode 100644 index 55da68bb5c..0000000000 --- a/packages/backend/src/apps/vault-workspace/auth/is-still-verified.ts +++ /dev/null @@ -1,10 +0,0 @@ -import { IGlobalVariable } from '@plumber/types' - -import verifyAPIKey from '../common/verify-api-key' - -const isStillVerified = async ($: IGlobalVariable) => { - await verifyAPIKey($) - return true -} - -export default isStillVerified diff --git a/packages/backend/src/apps/vault-workspace/auth/verify-credentials.ts b/packages/backend/src/apps/vault-workspace/auth/verify-credentials.ts deleted file mode 100644 index 0bf51443c9..0000000000 --- a/packages/backend/src/apps/vault-workspace/auth/verify-credentials.ts +++ /dev/null @@ -1,13 +0,0 @@ -import { IGlobalVariable } from '@plumber/types' - -import verifyAPIKey from '../common/verify-api-key' - -const verifyCredentials = async ($: IGlobalVariable) => { - const tableName = await verifyAPIKey($) - await $.auth.set({ - consumerSecret: $.auth.data.consumerSecret, - screenName: `${$.auth.data.screenName} (${tableName})`, - }) -} - -export default verifyCredentials diff --git a/packages/backend/src/apps/vault-workspace/common/add-auth-header.ts b/packages/backend/src/apps/vault-workspace/common/add-auth-header.ts deleted file mode 100644 index 9683a32efb..0000000000 --- a/packages/backend/src/apps/vault-workspace/common/add-auth-header.ts +++ /dev/null @@ -1,11 +0,0 @@ -import { TBeforeRequest } from '@plumber/types' - -const addAuthHeader: TBeforeRequest = async ($, requestConfig) => { - if (requestConfig.headers && $.auth.data?.apiKey) { - requestConfig.headers['Authorization'] = `Bearer ${$.auth.data.apiKey}` - } - - return requestConfig -} - -export default addAuthHeader diff --git a/packages/backend/src/apps/vault-workspace/common/constants.ts b/packages/backend/src/apps/vault-workspace/common/constants.ts deleted file mode 100644 index 719c87c8aa..0000000000 --- a/packages/backend/src/apps/vault-workspace/common/constants.ts +++ /dev/null @@ -1 +0,0 @@ -export const VAULT_ID = 'vault_id' diff --git a/packages/backend/src/apps/vault-workspace/common/create-table-row.ts b/packages/backend/src/apps/vault-workspace/common/create-table-row.ts deleted file mode 100644 index cf03b14dd0..0000000000 --- a/packages/backend/src/apps/vault-workspace/common/create-table-row.ts +++ /dev/null @@ -1,39 +0,0 @@ -import { IGlobalVariable } from '@plumber/types' - -import { getColumnMappingInAlias } from './get-column-mapping' - -const createTableRow = async ( - $: IGlobalVariable, - row: { [key: string]: string }, -): Promise => { - // get column mappings - let columnMapping = await getColumnMappingInAlias($) - const columnAliases = Object.keys(columnMapping) - - // create column if not exists - for (const key in row) { - if (!columnAliases.includes(key)) { - await $.http.post('/api/tables/column', { columnAlias: key }) - } - } - - // get column mappings again (with newly created rows) - columnMapping = await getColumnMappingInAlias($) - - // replace alias with column name - const payload: { [key: string]: string } = {} - for (const key in row) { - payload[columnMapping[key]] = row[key] - } - - // send data - const res = await $.http.post('/api/tables/row', { data: payload }) - $.setActionItem({ - raw: { - success: true, - ...res.data, - }, - }) -} - -export default createTableRow diff --git a/packages/backend/src/apps/vault-workspace/common/escape-characters.ts b/packages/backend/src/apps/vault-workspace/common/escape-characters.ts deleted file mode 100644 index 9bb093894e..0000000000 --- a/packages/backend/src/apps/vault-workspace/common/escape-characters.ts +++ /dev/null @@ -1,7 +0,0 @@ -export function escapeSpecialChars(str: string) { - return str.replace(/,/g, '%2C').replace(/"/g, '%22') -} - -export function unescapeSpecialChars(str: string) { - return str.replace(/%2C/g, ',').replace(/%22/g, '"') -} diff --git a/packages/backend/src/apps/vault-workspace/common/filter-table-rows.ts b/packages/backend/src/apps/vault-workspace/common/filter-table-rows.ts deleted file mode 100644 index e7ddef3f7f..0000000000 --- a/packages/backend/src/apps/vault-workspace/common/filter-table-rows.ts +++ /dev/null @@ -1,79 +0,0 @@ -import { IGlobalVariable } from '@plumber/types' - -import StepError from '@/errors/step' - -import { VAULT_ID } from './constants' -import { getColumnMapping } from './get-column-mapping' -import { throwGetFilteredRowsError } from './throw-errors' - -const filterTableRows = async ( - $: IGlobalVariable, - columnName: string, - value: string, -): Promise<{ [key: string]: any }> => { - const response = await $.http - .get('/api/tables', { - data: { - filter: [ - { - columnName, - type: 'EQ', - value, - }, - ], - }, - }) - .catch((err): never => { - throwGetFilteredRowsError(err, $.step.position, $.app.name) - }) - - if (response.data.rows.length < 1) { - return { - _metadata: { - success: false, - rowsFound: 0, - }, - } - } - // NOTE: if more than 1 row, just first row - const rawData: { [key: string]: string } = response.data.rows[0] - - // to replace column name with alias - const mapping = await getColumnMapping($) - const row: { [key: string]: string } = {} - - try { - for (const name in rawData) { - if (name === VAULT_ID) { - row[name] = rawData[name] - } else { - // keys are converted to hex here to satisfy our requirement for template - // keys to be alphanumeric, and will be decoded by getDataOutMetadata before - // displayed on frontend - const key = Buffer.from(mapping[name]).toString('hex') - row[key] = rawData[name] - } - } - } catch (err) { - if (err instanceof TypeError) { - throw new StepError( - 'Undefined column name in Vault', - 'Your vault table has an undefined column due to a bug. Please create a new vault table to be used.', - $.step.position, - $.app.name, - ) - } - throw err - } - - return { - ...row, - _metadata: { - success: true, - rowsFound: response.data.rows.length, - keysEncoded: true, - }, - } -} - -export default filterTableRows diff --git a/packages/backend/src/apps/vault-workspace/common/get-column-mapping.ts b/packages/backend/src/apps/vault-workspace/common/get-column-mapping.ts deleted file mode 100644 index e397e4e8e9..0000000000 --- a/packages/backend/src/apps/vault-workspace/common/get-column-mapping.ts +++ /dev/null @@ -1,31 +0,0 @@ -import { IGlobalVariable } from '@plumber/types' - -import { throwGetColumnMappingError } from './throw-errors' - -const getColumnMappingInAlias = async ( - $: IGlobalVariable, -): Promise<{ [key: string]: string }> => { - const mapping = await getColumnMapping($) - return swap(mapping) // alias: name -} - -const getColumnMapping = async ( - $: IGlobalVariable, -): Promise<{ [key: string]: string }> => { - const response = await $.http - .get('/api/tables/column-mapping') - .catch((err): never => { - throwGetColumnMappingError(err, $.step.position, $.app.name) - }) - return response.data -} - -const swap = (json: { [key: string]: string }) => { - const reversed: { [key: string]: string } = {} - for (const key in json) { - reversed[json[key]] = key - } - return reversed -} - -export { getColumnMapping, getColumnMappingInAlias } diff --git a/packages/backend/src/apps/vault-workspace/common/get-example-row.ts b/packages/backend/src/apps/vault-workspace/common/get-example-row.ts deleted file mode 100644 index f9ff01cceb..0000000000 --- a/packages/backend/src/apps/vault-workspace/common/get-example-row.ts +++ /dev/null @@ -1,31 +0,0 @@ -import { IGlobalVariable } from '@plumber/types' - -import { VAULT_ID } from './constants' -import { getColumnMapping } from './get-column-mapping' - -const getExampleRow = async ( - $: IGlobalVariable, -): Promise<{ [key: string]: string }> => { - const response = await $.http.get('/api/tables') - - if (response.data.rows.length < 1) { - throw new Error('Row not found') - } - // NOTE: if more than 1 row, just first row - const rawData: { [key: string]: string } = response.data.rows[0] - - // to replace column name with alias - const mapping = await getColumnMapping($) - const row: { [key: string]: string } = {} - for (const name in rawData) { - if (name === VAULT_ID) { - row[name] = rawData[name] - } else { - row[mapping[name]] = rawData[name] - } - } - - return row -} - -export default getExampleRow diff --git a/packages/backend/src/apps/vault-workspace/common/throw-errors.ts b/packages/backend/src/apps/vault-workspace/common/throw-errors.ts deleted file mode 100644 index 17d653437b..0000000000 --- a/packages/backend/src/apps/vault-workspace/common/throw-errors.ts +++ /dev/null @@ -1,87 +0,0 @@ -import { CsvError } from 'csv-parse/.' - -import HttpError from '@/errors/http' -import StepError from '@/errors/step' - -export function throwParseAsCsvError( - err: CsvError, - position: number, - appName: string, -): never { - // only three possible errors caught in DB - switch (err.code) { - case 'CSV_NON_TRIMABLE_CHAR_AFTER_CLOSING_QUOTE': - throw new StepError( - 'Invalid usage of double quotes', - 'Click on set up action and check that double quotes should only be used if column or value contains commas. Use single quotes instead if necessary.', - position, - appName, - ) - case 'CSV_QUOTE_NOT_CLOSED': - throw new StepError( - 'No closing quote', - 'Click on set up action and check if an opening quote is used for a column or value, a closing quote is paired with it.', - position, - appName, - ) - case 'CSV_RECORD_INCONSISTENT_FIELDS_LENGTH': - throw new StepError( - 'Incorrect format for values field', - 'Click on set up action and check that the values field has no newline. Separate each value with a comma on the same line.', - position, - appName, - ) - default: - // return original error since uncaught - throw err - } -} - -export function throwGetFilteredRowsError( - err: HttpError, - position: number, - appName: string, -): never { - switch (err.response.status) { - case 400: - // note this catches two different errors: when user doesn't select a column and when user deletes column on vault - throw new StepError( - 'Missing lookup column', - 'Click on set up action and check that the lookup column is not empty and is present on your vault table. The column could have been accidentally deleted on your vault table, please re-create the column or select another valid lookup column.', - position, - appName, - err, - ) - case 500: - throw new StepError( - 'Invalid lookup column used', - 'Click on set up action and ensure that you have selected a valid column instead.', - position, - appName, - err, - ) - default: - // return original error since uncaught - throw err - } -} - -export function throwGetColumnMappingError( - err: HttpError, - position: number, - appName: string, -): never { - switch (err.response.status) { - case 403: - throw new StepError( - 'Disconnected vault table', - 'Click on choose connection and ensure that your vault table is still connected. If not, please copy the new api key generated on vault and re-establish the connection on Plumber.', - position, - appName, - err, - ) - default: - // return original error since uncaught - throw err - } -} diff --git a/packages/backend/src/apps/vault-workspace/common/throw-vault-deprecation-error.ts b/packages/backend/src/apps/vault-workspace/common/throw-vault-deprecation-error.ts new file mode 100644 index 0000000000..d00eb9d9c1 --- /dev/null +++ b/packages/backend/src/apps/vault-workspace/common/throw-vault-deprecation-error.ts @@ -0,0 +1,12 @@ +import type { IGlobalVariable } from '@plumber/types' + +import StepError from '@/errors/step' + +export function throwVaultDeprecationError($: IGlobalVariable) { + throw new StepError( + 'Vault workspace is deprecated', + 'Please use tiles or M365-excel instead.', + $.step.position, + $.app.name, + ) +} diff --git a/packages/backend/src/apps/vault-workspace/common/update-table-row.ts b/packages/backend/src/apps/vault-workspace/common/update-table-row.ts deleted file mode 100644 index 229b6fe37f..0000000000 --- a/packages/backend/src/apps/vault-workspace/common/update-table-row.ts +++ /dev/null @@ -1,25 +0,0 @@ -import { IGlobalVariable } from '@plumber/types' - -const updateTableRow = async ( - $: IGlobalVariable, - vaultId: string, - update: { [key: string]: string }, // column name: value -): Promise<{ - [key: string]: any & { - _metadata: { - success: boolean - rowsUpdated: number - } - } -}> => { - const res = await $.http.put('/api/tables/row', { id: vaultId, update }) - return { - _metadata: { - success: true, - rowsUpdated: 1, - }, - ...res.data, - } -} - -export default updateTableRow diff --git a/packages/backend/src/apps/vault-workspace/common/verify-api-key.ts b/packages/backend/src/apps/vault-workspace/common/verify-api-key.ts deleted file mode 100644 index 6ce185b1b3..0000000000 --- a/packages/backend/src/apps/vault-workspace/common/verify-api-key.ts +++ /dev/null @@ -1,13 +0,0 @@ -import { IGlobalVariable } from '@plumber/types' - -const verifyAPIKey = async ($: IGlobalVariable): Promise => { - const response = await $.http.get('/api/auth/whoami', { - headers: { - authorization: `Bearer ${$.auth.data.apiKey as string}`, - }, - }) - - return response.data.tableName -} - -export default verifyAPIKey diff --git a/packages/backend/src/apps/vault-workspace/dynamic-data/helpers/get-columns.ts b/packages/backend/src/apps/vault-workspace/dynamic-data/helpers/get-columns.ts deleted file mode 100644 index 7c1c8c1648..0000000000 --- a/packages/backend/src/apps/vault-workspace/dynamic-data/helpers/get-columns.ts +++ /dev/null @@ -1,32 +0,0 @@ -import { DynamicDataOutput, IGlobalVariable } from '@plumber/types' - -import { VAULT_ID } from '../../common/constants' -import { getColumnMappingInAlias } from '../../common/get-column-mapping' - -const PREDEFINED_VAULT_COLUMN = { - name: 'Vault Row ID', - value: VAULT_ID, -} - -export async function getColumns( - $: IGlobalVariable, - updatableOnly = false, -): Promise { - const mapping = await getColumnMappingInAlias($) - const response: DynamicDataOutput = { - data: [], - } - - if (!updatableOnly) { - // NOTE: vault workspace has pre-defined column called vault_id - response.data.push(PREDEFINED_VAULT_COLUMN) - } - - for (const key in mapping) { - response.data.push({ - name: key, - value: mapping[key], - }) - } - return response -} diff --git a/packages/backend/src/apps/vault-workspace/dynamic-data/index.ts b/packages/backend/src/apps/vault-workspace/dynamic-data/index.ts deleted file mode 100644 index 0324636710..0000000000 --- a/packages/backend/src/apps/vault-workspace/dynamic-data/index.ts +++ /dev/null @@ -1,4 +0,0 @@ -import listColumns from './list-columns' -import listUpdatableColumns from './list-updatable-columns' - -export default [listColumns, listUpdatableColumns] diff --git a/packages/backend/src/apps/vault-workspace/dynamic-data/list-columns/index.ts b/packages/backend/src/apps/vault-workspace/dynamic-data/list-columns/index.ts deleted file mode 100644 index cc4050d987..0000000000 --- a/packages/backend/src/apps/vault-workspace/dynamic-data/list-columns/index.ts +++ /dev/null @@ -1,14 +0,0 @@ -import { IDynamicData, IGlobalVariable } from '@plumber/types' - -import { getColumns } from '../helpers/get-columns' - -const dynamicData: IDynamicData = { - name: 'List columns', - key: 'listColumns', - - async run($: IGlobalVariable) { - return await getColumns($) - }, -} - -export default dynamicData diff --git a/packages/backend/src/apps/vault-workspace/dynamic-data/list-updatable-columns/index.ts b/packages/backend/src/apps/vault-workspace/dynamic-data/list-updatable-columns/index.ts deleted file mode 100644 index adc98f909b..0000000000 --- a/packages/backend/src/apps/vault-workspace/dynamic-data/list-updatable-columns/index.ts +++ /dev/null @@ -1,14 +0,0 @@ -import { IDynamicData, IGlobalVariable } from '@plumber/types' - -import { getColumns } from '../helpers/get-columns' - -const dynamicData: IDynamicData = { - name: 'List updatable columns', - key: 'listUpdatableColumns', - - async run($: IGlobalVariable) { - return await getColumns($, true) - }, -} - -export default dynamicData diff --git a/packages/backend/src/apps/vault-workspace/index.ts b/packages/backend/src/apps/vault-workspace/index.ts index 10eeeb9ae2..d78ec3dcf0 100644 --- a/packages/backend/src/apps/vault-workspace/index.ts +++ b/packages/backend/src/apps/vault-workspace/index.ts @@ -1,27 +1,18 @@ import { IApp } from '@plumber/types' -import addAuthHeader from './common/add-auth-header' import actions from './actions' -import auth from './auth' -import dynamicData from './dynamic-data' - -const WORKSPACE_BASEURL = - 'https://jcxk888grj.execute-api.ap-southeast-1.amazonaws.com' const app: IApp = { name: 'Vault Workspace', key: 'vault-workspace', - baseUrl: WORKSPACE_BASEURL, - apiBaseUrl: WORKSPACE_BASEURL, + baseUrl: '', + apiBaseUrl: '', iconUrl: '{BASE_URL}/apps/vault-workspace/assets/favicon.svg', authDocUrl: 'https://guide.plumber.gov.sg/user-guides/actions/vault-workspace', primaryColor: '000000', - beforeRequest: [addAuthHeader], - auth, actions, // disabling triggers from vault workspace - dynamicData, } export default app diff --git a/packages/backend/src/controllers/webhooks/handler.ts b/packages/backend/src/controllers/webhooks/handler.ts index d4bd649224..f600642613 100644 --- a/packages/backend/src/controllers/webhooks/handler.ts +++ b/packages/backend/src/controllers/webhooks/handler.ts @@ -74,10 +74,7 @@ export default async (request: IRequest, response: Response) => { const triggerStep = await flow.getTriggerStep() const triggerCommand = await triggerStep.getTriggerCommand() const app = await triggerStep.getApp() - const isWebhookApp = - app.key === 'webhook' || - app.key === 'formsg' || - app.key === 'vault-workspace' + const isWebhookApp = app.key === 'webhook' || app.key === 'formsg' // Allow all webhook test runs to work if (testRun && !isWebhookApp) { diff --git a/packages/backend/src/helpers/__tests__/compute-parameters.test.ts b/packages/backend/src/helpers/__tests__/compute-parameters.test.ts index 68a0ee117e..0a23df9355 100644 --- a/packages/backend/src/helpers/__tests__/compute-parameters.test.ts +++ b/packages/backend/src/helpers/__tests__/compute-parameters.test.ts @@ -1,7 +1,6 @@ import { randomUUID } from 'crypto' import { describe, expect, it } from 'vitest' -import vaultWorkspace from '@/apps/vault-workspace' import ExecutionStep from '@/models/execution-step' import computeParameters from '../compute-parameters' @@ -278,34 +277,12 @@ describe('compute parameters', () => { ], }) }) - it('can compute on templates with non-hex-encoded param keys using new vault WS objects whose keys hex-encoded', () => { - const vaultWSExecutionStep = [ - { - stepId: randomStepID, - appKey: vaultWorkspace.key, - dataOut: { - '4974732d612d6d65': 'Mario!', // key is hex-encoded `Its a me` - _metadata: { - keysEncoded: true, - }, - }, - } as unknown as ExecutionStep, - ] - const params = { - toSubstitute: `Its a me {{step.${randomStepID}.Its-a-me}}`, - } - const expected = { - toSubstitute: 'Its a me Mario!', - } - const result = computeParameters(params, vaultWSExecutionStep) - expect(result).toEqual(expected) - }) it('should work with space separated keys', () => { - const vaultWSExecutionStep = [ + const executionStep = [ { stepId: randomStepID, - appKey: vaultWorkspace.key, + appKey: 'test-app', dataOut: { ' weopfkweopf ': 'Itsa me', 'weiofjwef wefwe fwe fwefwe f ': 'Mario!', @@ -318,15 +295,15 @@ describe('compute parameters', () => { const expected = { toSubstitute: 'Itsa me Mario!', } - const result = computeParameters(params, vaultWSExecutionStep) + const result = computeParameters(params, executionStep) expect(result).toEqual(expected) }) it('should not replace parameters with tabs or newlines', () => { - const vaultWSExecutionStep = [ + const executionStep = [ { stepId: randomStepID, - appKey: vaultWorkspace.key, + appKey: 'test-app', dataOut: { '\tab tab\t': 'Itsa me', 'newlines\n': 'Mario!', @@ -339,7 +316,7 @@ describe('compute parameters', () => { const expected = { toSubstitute: `{{step.${randomStepID}.\tab tab\t}} {{step.${randomStepID}.newlines\n}}`, } - const result = computeParameters(params, vaultWSExecutionStep) + const result = computeParameters(params, executionStep) expect(result).toEqual(expected) }) }) diff --git a/packages/backend/src/helpers/compute-parameters.ts b/packages/backend/src/helpers/compute-parameters.ts index 3682b9f303..7afc3b3230 100644 --- a/packages/backend/src/helpers/compute-parameters.ts +++ b/packages/backend/src/helpers/compute-parameters.ts @@ -1,8 +1,7 @@ -import { IAction, IJSONObject } from '@plumber/types' +import type { IAction } from '@plumber/types' import get from 'lodash.get' -import vaultWorkspace from '@/apps/vault-workspace' import ExecutionStep from '@/models/execution-step' import Step from '../models/step' @@ -63,24 +62,8 @@ function findAndSubstituteVariables( const data = executionStep?.dataOut const keyPath = keyPaths.join('.') // for lodash get to work - let dataValue = get(data, keyPath) - // custom logic to deal with backward compatibility of key encoding for - // data from vault. Under the new logic, data from vault will always have - // hex-encoded key while the old templates might still used non-encoded - // hence if the value is not defined and keysEncoded flag was set, we - // attempt to convert the template string to use hex-encoded key - // FIXME: Remove this custom logic after we migrate off Vault WS - if ( - dataValue === undefined && - executionStep?.appKey === vaultWorkspace.key && - (data?._metadata as IJSONObject)?.keysEncoded && - keyPaths.length > 0 - ) { - keyPaths[keyPaths.length - 1] = Buffer.from( - keyPaths[keyPaths.length - 1], - ).toString('hex') - dataValue = get(data, keyPaths.join('.')) - } + const dataValue = get(data, keyPath) + // NOTE: dataValue could be an array if it is not processed on variables.ts // which is the case for formSG checkbox only, this is to deal with forEach next time return preprocessVariable diff --git a/packages/frontend/package.json b/packages/frontend/package.json index f972734162..a9d8ec3920 100644 --- a/packages/frontend/package.json +++ b/packages/frontend/package.json @@ -1,6 +1,6 @@ { "name": "frontend", - "version": "1.29.5", + "version": "1.29.6", "scripts": { "dev": "wait-on tcp:3000 && vite --host --force", "build": "tsc && vite build --mode=${VITE_MODE:-prod}", diff --git a/packages/types/package.json b/packages/types/package.json index 5b2102faa7..a72dc0c0bb 100644 --- a/packages/types/package.json +++ b/packages/types/package.json @@ -2,5 +2,5 @@ "name": "@plumber/types", "description": "Shared types for plumber", "types": "./index.d.ts", - "version": "1.29.5" + "version": "1.29.6" }