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 stepParams = (request) => {
|
||||||
const { connectionId, appKey, key, parameters } = request.body;
|
const { connectionId, appKey, key, name, parameters } = request.body;
|
||||||
|
|
||||||
return {
|
return {
|
||||||
connectionId,
|
connectionId,
|
||||||
appKey,
|
appKey,
|
||||||
key,
|
key,
|
||||||
|
name,
|
||||||
parameters,
|
parameters,
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -35,6 +35,7 @@ describe('PATCH /api/v1/steps/:stepId', () => {
|
|||||||
connectionId: currentUserConnection.id,
|
connectionId: currentUserConnection.id,
|
||||||
appKey: 'deepl',
|
appKey: 'deepl',
|
||||||
key: 'translateText',
|
key: 'translateText',
|
||||||
|
name: 'Translate text',
|
||||||
});
|
});
|
||||||
|
|
||||||
await createPermission({
|
await createPermission({
|
||||||
@@ -58,6 +59,7 @@ describe('PATCH /api/v1/steps/:stepId', () => {
|
|||||||
parameters: {
|
parameters: {
|
||||||
text: 'Hello world!',
|
text: 'Hello world!',
|
||||||
targetLanguage: 'de',
|
targetLanguage: 'de',
|
||||||
|
name: 'Translate text - Updated step name',
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
.expect(200);
|
.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",
|
"null",
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
|
"name": {
|
||||||
|
"maxLength": 255,
|
||||||
|
"minLength": 1,
|
||||||
|
"type": [
|
||||||
|
"string",
|
||||||
|
"null",
|
||||||
|
],
|
||||||
|
},
|
||||||
"parameters": {
|
"parameters": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ class Step extends Base {
|
|||||||
id: { type: 'string', format: 'uuid' },
|
id: { type: 'string', format: 'uuid' },
|
||||||
flowId: { type: 'string', format: 'uuid' },
|
flowId: { type: 'string', format: 'uuid' },
|
||||||
key: { type: ['string', 'null'] },
|
key: { type: ['string', 'null'] },
|
||||||
|
name: { type: ['string', 'null'], minLength: 1, maxLength: 255 },
|
||||||
appKey: { type: ['string', 'null'], minLength: 1, maxLength: 255 },
|
appKey: { type: ['string', 'null'], minLength: 1, maxLength: 255 },
|
||||||
type: { type: 'string', enum: ['action', 'trigger'] },
|
type: { type: 'string', enum: ['action', 'trigger'] },
|
||||||
connectionId: { type: ['string', 'null'], format: 'uuid' },
|
connectionId: { type: ['string', 'null'], format: 'uuid' },
|
||||||
@@ -314,7 +315,13 @@ class Step extends Base {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async updateFor(user, newStepData) {
|
async updateFor(user, newStepData) {
|
||||||
const { appKey = this.appKey, connectionId, key, parameters } = newStepData;
|
const {
|
||||||
|
appKey = this.appKey,
|
||||||
|
name,
|
||||||
|
connectionId,
|
||||||
|
key,
|
||||||
|
parameters,
|
||||||
|
} = newStepData;
|
||||||
|
|
||||||
if (connectionId && appKey) {
|
if (connectionId && appKey) {
|
||||||
await user.authorizedConnections
|
await user.authorizedConnections
|
||||||
@@ -335,6 +342,7 @@ class Step extends Base {
|
|||||||
|
|
||||||
const updatedStep = await this.$query().patchAndFetch({
|
const updatedStep = await this.$query().patchAndFetch({
|
||||||
key,
|
key,
|
||||||
|
name,
|
||||||
appKey,
|
appKey,
|
||||||
connectionId: connectionId,
|
connectionId: connectionId,
|
||||||
parameters: parameters,
|
parameters: parameters,
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ const stepSerializer = (step) => {
|
|||||||
id: step.id,
|
id: step.id,
|
||||||
type: step.type,
|
type: step.type,
|
||||||
key: step.key,
|
key: step.key,
|
||||||
|
name: step.name,
|
||||||
appKey: step.appKey,
|
appKey: step.appKey,
|
||||||
iconUrl: step.iconUrl,
|
iconUrl: step.iconUrl,
|
||||||
webhookUrl: step.webhookUrl,
|
webhookUrl: step.webhookUrl,
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ describe('stepSerializer', () => {
|
|||||||
id: step.id,
|
id: step.id,
|
||||||
type: step.type,
|
type: step.type,
|
||||||
key: step.key,
|
key: step.key,
|
||||||
|
name: step.name,
|
||||||
appKey: step.appKey,
|
appKey: step.appKey,
|
||||||
iconUrl: step.iconUrl,
|
iconUrl: step.iconUrl,
|
||||||
webhookUrl: step.webhookUrl,
|
webhookUrl: step.webhookUrl,
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ const getExecutionStepsMock = async (executionSteps, steps) => {
|
|||||||
id: step.id,
|
id: step.id,
|
||||||
type: step.type,
|
type: step.type,
|
||||||
key: step.key,
|
key: step.key,
|
||||||
|
name: step.name,
|
||||||
appKey: step.appKey,
|
appKey: step.appKey,
|
||||||
iconUrl: step.iconUrl,
|
iconUrl: step.iconUrl,
|
||||||
webhookUrl: step.webhookUrl,
|
webhookUrl: step.webhookUrl,
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ const getExecutionMock = async (execution, flow, steps) => {
|
|||||||
id: step.id,
|
id: step.id,
|
||||||
type: step.type,
|
type: step.type,
|
||||||
key: step.key,
|
key: step.key,
|
||||||
|
name: step.name,
|
||||||
appKey: step.appKey,
|
appKey: step.appKey,
|
||||||
iconUrl: step.iconUrl,
|
iconUrl: step.iconUrl,
|
||||||
webhookUrl: step.webhookUrl,
|
webhookUrl: step.webhookUrl,
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ const getExecutionsMock = async (executions, flow, steps) => {
|
|||||||
id: step.id,
|
id: step.id,
|
||||||
type: step.type,
|
type: step.type,
|
||||||
key: step.key,
|
key: step.key,
|
||||||
|
name: step.name,
|
||||||
appKey: step.appKey,
|
appKey: step.appKey,
|
||||||
iconUrl: step.iconUrl,
|
iconUrl: step.iconUrl,
|
||||||
webhookUrl: step.webhookUrl,
|
webhookUrl: step.webhookUrl,
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ const duplicateFlowMock = async (flow, steps = []) => {
|
|||||||
iconUrl: step.iconUrl,
|
iconUrl: step.iconUrl,
|
||||||
id: step.id,
|
id: step.id,
|
||||||
key: step.key,
|
key: step.key,
|
||||||
|
name: step.name,
|
||||||
parameters: step.parameters,
|
parameters: step.parameters,
|
||||||
position: step.position,
|
position: step.position,
|
||||||
status: step.status,
|
status: step.status,
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ const getFlowMock = async (flow, steps = []) => {
|
|||||||
iconUrl: step.iconUrl,
|
iconUrl: step.iconUrl,
|
||||||
id: step.id,
|
id: step.id,
|
||||||
key: step.key,
|
key: step.key,
|
||||||
|
name: step.name,
|
||||||
parameters: step.parameters,
|
parameters: step.parameters,
|
||||||
position: step.position,
|
position: step.position,
|
||||||
status: step.status,
|
status: step.status,
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ const getFlowsMock = async (flows, steps) => {
|
|||||||
iconUrl: step.iconUrl,
|
iconUrl: step.iconUrl,
|
||||||
id: step.id,
|
id: step.id,
|
||||||
key: step.key,
|
key: step.key,
|
||||||
|
name: step.name,
|
||||||
parameters: step.parameters,
|
parameters: step.parameters,
|
||||||
position: step.position,
|
position: step.position,
|
||||||
status: step.status,
|
status: step.status,
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ const updateFlowStatusMock = async (flow, steps = []) => {
|
|||||||
iconUrl: step.iconUrl,
|
iconUrl: step.iconUrl,
|
||||||
id: step.id,
|
id: step.id,
|
||||||
key: step.key,
|
key: step.key,
|
||||||
|
name: step.name,
|
||||||
parameters: step.parameters,
|
parameters: step.parameters,
|
||||||
position: step.position,
|
position: step.position,
|
||||||
status: step.status,
|
status: step.status,
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ const getPreviousStepsMock = async (steps, executionSteps) => {
|
|||||||
id: step.id,
|
id: step.id,
|
||||||
type: step.type,
|
type: step.type,
|
||||||
key: step.key,
|
key: step.key,
|
||||||
|
name: step.name,
|
||||||
appKey: step.appKey,
|
appKey: step.appKey,
|
||||||
iconUrl: step.iconUrl,
|
iconUrl: step.iconUrl,
|
||||||
webhookUrl: step.webhookUrl,
|
webhookUrl: step.webhookUrl,
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ const updateStepMock = (step) => {
|
|||||||
id: step.id,
|
id: step.id,
|
||||||
type: step.type || 'action',
|
type: step.type || 'action',
|
||||||
key: step.key || null,
|
key: step.key || null,
|
||||||
|
name: step.name || null,
|
||||||
appKey: step.appKey || null,
|
appKey: step.appKey || null,
|
||||||
iconUrl: step.iconUrl || null,
|
iconUrl: step.iconUrl || null,
|
||||||
webhookUrl: step.webhookUrl || null,
|
webhookUrl: step.webhookUrl || null,
|
||||||
|
|||||||
Reference in New Issue
Block a user