feat: Add name column to Step model
This commit is contained in:
@@ -11,12 +11,13 @@ export default async (request, response) => {
|
||||
};
|
||||
|
||||
const stepParams = (request) => {
|
||||
const { connectionId, appKey, key, parameters } = request.body;
|
||||
const { connectionId, appKey, key, name, parameters } = request.body;
|
||||
|
||||
return {
|
||||
connectionId,
|
||||
appKey,
|
||||
key,
|
||||
name,
|
||||
parameters,
|
||||
};
|
||||
};
|
||||
|
||||
@@ -35,6 +35,7 @@ describe('PATCH /api/v1/steps/:stepId', () => {
|
||||
connectionId: currentUserConnection.id,
|
||||
appKey: 'deepl',
|
||||
key: 'translateText',
|
||||
name: 'Translate text',
|
||||
});
|
||||
|
||||
await createPermission({
|
||||
@@ -58,6 +59,7 @@ describe('PATCH /api/v1/steps/:stepId', () => {
|
||||
parameters: {
|
||||
text: 'Hello world!',
|
||||
targetLanguage: 'de',
|
||||
name: 'Translate text - Updated step name',
|
||||
},
|
||||
})
|
||||
.expect(200);
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
import toLower from 'lodash/toLower.js';
|
||||
import startCase from 'lodash/startCase.js';
|
||||
import upperFirst from 'lodash/upperFirst.js';
|
||||
|
||||
export async function up(knex) {
|
||||
await knex.schema.table('steps', function (table) {
|
||||
table.string('name');
|
||||
});
|
||||
|
||||
const rows = await knex('steps').select('id', 'key');
|
||||
|
||||
const updates = rows.map((row) => {
|
||||
if (!row.key) return;
|
||||
|
||||
const humanizedKey = upperFirst(toLower(startCase(row.key)));
|
||||
return knex('steps').where({ id: row.id }).update({ name: humanizedKey });
|
||||
});
|
||||
|
||||
return await Promise.all(updates);
|
||||
}
|
||||
|
||||
export async function down(knex) {
|
||||
return knex.schema.table('steps', function (table) {
|
||||
table.dropColumn('name');
|
||||
});
|
||||
}
|
||||
@@ -38,6 +38,14 @@ exports[`Step model > jsonSchema should have correct validations 1`] = `
|
||||
"null",
|
||||
],
|
||||
},
|
||||
"name": {
|
||||
"maxLength": 255,
|
||||
"minLength": 1,
|
||||
"type": [
|
||||
"string",
|
||||
"null",
|
||||
],
|
||||
},
|
||||
"parameters": {
|
||||
"type": "object",
|
||||
},
|
||||
|
||||
@@ -22,6 +22,7 @@ class Step extends Base {
|
||||
id: { type: 'string', format: 'uuid' },
|
||||
flowId: { type: 'string', format: 'uuid' },
|
||||
key: { type: ['string', 'null'] },
|
||||
name: { type: ['string', 'null'], minLength: 1, maxLength: 255 },
|
||||
appKey: { type: ['string', 'null'], minLength: 1, maxLength: 255 },
|
||||
type: { type: 'string', enum: ['action', 'trigger'] },
|
||||
connectionId: { type: ['string', 'null'], format: 'uuid' },
|
||||
@@ -314,7 +315,13 @@ class Step extends Base {
|
||||
}
|
||||
|
||||
async updateFor(user, newStepData) {
|
||||
const { appKey = this.appKey, connectionId, key, parameters } = newStepData;
|
||||
const {
|
||||
appKey = this.appKey,
|
||||
name,
|
||||
connectionId,
|
||||
key,
|
||||
parameters,
|
||||
} = newStepData;
|
||||
|
||||
if (connectionId && appKey) {
|
||||
await user.authorizedConnections
|
||||
@@ -335,6 +342,7 @@ class Step extends Base {
|
||||
|
||||
const updatedStep = await this.$query().patchAndFetch({
|
||||
key,
|
||||
name,
|
||||
appKey,
|
||||
connectionId: connectionId,
|
||||
parameters: parameters,
|
||||
|
||||
@@ -5,6 +5,7 @@ const stepSerializer = (step) => {
|
||||
id: step.id,
|
||||
type: step.type,
|
||||
key: step.key,
|
||||
name: step.name,
|
||||
appKey: step.appKey,
|
||||
iconUrl: step.iconUrl,
|
||||
webhookUrl: step.webhookUrl,
|
||||
|
||||
@@ -16,6 +16,7 @@ describe('stepSerializer', () => {
|
||||
id: step.id,
|
||||
type: step.type,
|
||||
key: step.key,
|
||||
name: step.name,
|
||||
appKey: step.appKey,
|
||||
iconUrl: step.iconUrl,
|
||||
webhookUrl: step.webhookUrl,
|
||||
|
||||
@@ -14,6 +14,7 @@ const getExecutionStepsMock = async (executionSteps, steps) => {
|
||||
id: step.id,
|
||||
type: step.type,
|
||||
key: step.key,
|
||||
name: step.name,
|
||||
appKey: step.appKey,
|
||||
iconUrl: step.iconUrl,
|
||||
webhookUrl: step.webhookUrl,
|
||||
|
||||
@@ -15,6 +15,7 @@ const getExecutionMock = async (execution, flow, steps) => {
|
||||
id: step.id,
|
||||
type: step.type,
|
||||
key: step.key,
|
||||
name: step.name,
|
||||
appKey: step.appKey,
|
||||
iconUrl: step.iconUrl,
|
||||
webhookUrl: step.webhookUrl,
|
||||
|
||||
@@ -16,6 +16,7 @@ const getExecutionsMock = async (executions, flow, steps) => {
|
||||
id: step.id,
|
||||
type: step.type,
|
||||
key: step.key,
|
||||
name: step.name,
|
||||
appKey: step.appKey,
|
||||
iconUrl: step.iconUrl,
|
||||
webhookUrl: step.webhookUrl,
|
||||
|
||||
@@ -14,6 +14,7 @@ const duplicateFlowMock = async (flow, steps = []) => {
|
||||
iconUrl: step.iconUrl,
|
||||
id: step.id,
|
||||
key: step.key,
|
||||
name: step.name,
|
||||
parameters: step.parameters,
|
||||
position: step.position,
|
||||
status: step.status,
|
||||
|
||||
@@ -14,6 +14,7 @@ const getFlowMock = async (flow, steps = []) => {
|
||||
iconUrl: step.iconUrl,
|
||||
id: step.id,
|
||||
key: step.key,
|
||||
name: step.name,
|
||||
parameters: step.parameters,
|
||||
position: step.position,
|
||||
status: step.status,
|
||||
|
||||
@@ -14,6 +14,7 @@ const getFlowsMock = async (flows, steps) => {
|
||||
iconUrl: step.iconUrl,
|
||||
id: step.id,
|
||||
key: step.key,
|
||||
name: step.name,
|
||||
parameters: step.parameters,
|
||||
position: step.position,
|
||||
status: step.status,
|
||||
|
||||
@@ -14,6 +14,7 @@ const updateFlowStatusMock = async (flow, steps = []) => {
|
||||
iconUrl: step.iconUrl,
|
||||
id: step.id,
|
||||
key: step.key,
|
||||
name: step.name,
|
||||
parameters: step.parameters,
|
||||
position: step.position,
|
||||
status: step.status,
|
||||
|
||||
@@ -8,6 +8,7 @@ const getPreviousStepsMock = async (steps, executionSteps) => {
|
||||
id: step.id,
|
||||
type: step.type,
|
||||
key: step.key,
|
||||
name: step.name,
|
||||
appKey: step.appKey,
|
||||
iconUrl: step.iconUrl,
|
||||
webhookUrl: step.webhookUrl,
|
||||
|
||||
@@ -3,6 +3,7 @@ const updateStepMock = (step) => {
|
||||
id: step.id,
|
||||
type: step.type || 'action',
|
||||
key: step.key || null,
|
||||
name: step.name || null,
|
||||
appKey: step.appKey || null,
|
||||
iconUrl: step.iconUrl || null,
|
||||
webhookUrl: step.webhookUrl || null,
|
||||
|
||||
Reference in New Issue
Block a user