chore: change workflow column name (#24349)

chore-change-workflow-column-name
This commit is contained in:
Alex 2025-12-02 14:40:17 -06:00 committed by GitHub
parent f07d1441ea
commit f5df5fa98d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
13 changed files with 93 additions and 66 deletions

View file

@ -23162,13 +23162,13 @@
"actionConfig": { "actionConfig": {
"type": "object" "type": "object"
}, },
"actionId": { "pluginActionId": {
"format": "uuid", "format": "uuid",
"type": "string" "type": "string"
} }
}, },
"required": [ "required": [
"actionId" "pluginActionId"
], ],
"type": "object" "type": "object"
}, },
@ -23178,24 +23178,24 @@
"nullable": true, "nullable": true,
"type": "object" "type": "object"
}, },
"actionId": {
"type": "string"
},
"id": { "id": {
"type": "string" "type": "string"
}, },
"order": { "order": {
"type": "number" "type": "number"
}, },
"pluginActionId": {
"type": "string"
},
"workflowId": { "workflowId": {
"type": "string" "type": "string"
} }
}, },
"required": [ "required": [
"actionConfig", "actionConfig",
"actionId",
"id", "id",
"order", "order",
"pluginActionId",
"workflowId" "workflowId"
], ],
"type": "object" "type": "object"
@ -23244,13 +23244,13 @@
"filterConfig": { "filterConfig": {
"type": "object" "type": "object"
}, },
"filterId": { "pluginFilterId": {
"format": "uuid", "format": "uuid",
"type": "string" "type": "string"
} }
}, },
"required": [ "required": [
"filterId" "pluginFilterId"
], ],
"type": "object" "type": "object"
}, },
@ -23260,24 +23260,24 @@
"nullable": true, "nullable": true,
"type": "object" "type": "object"
}, },
"filterId": {
"type": "string"
},
"id": { "id": {
"type": "string" "type": "string"
}, },
"order": { "order": {
"type": "number" "type": "number"
}, },
"pluginFilterId": {
"type": "string"
},
"workflowId": { "workflowId": {
"type": "string" "type": "string"
} }
}, },
"required": [ "required": [
"filterConfig", "filterConfig",
"filterId",
"id", "id",
"order", "order",
"pluginFilterId",
"workflowId" "workflowId"
], ],
"type": "object" "type": "object"

View file

@ -1729,16 +1729,16 @@ export type CreateProfileImageResponseDto = {
}; };
export type WorkflowActionResponseDto = { export type WorkflowActionResponseDto = {
actionConfig: object | null; actionConfig: object | null;
actionId: string;
id: string; id: string;
order: number; order: number;
pluginActionId: string;
workflowId: string; workflowId: string;
}; };
export type WorkflowFilterResponseDto = { export type WorkflowFilterResponseDto = {
filterConfig: object | null; filterConfig: object | null;
filterId: string;
id: string; id: string;
order: number; order: number;
pluginFilterId: string;
workflowId: string; workflowId: string;
}; };
export type WorkflowResponseDto = { export type WorkflowResponseDto = {
@ -1754,11 +1754,11 @@ export type WorkflowResponseDto = {
}; };
export type WorkflowActionItemDto = { export type WorkflowActionItemDto = {
actionConfig?: object; actionConfig?: object;
actionId: string; pluginActionId: string;
}; };
export type WorkflowFilterItemDto = { export type WorkflowFilterItemDto = {
filterConfig?: object; filterConfig?: object;
filterId: string; pluginFilterId: string;
}; };
export type WorkflowCreateDto = { export type WorkflowCreateDto = {
actions: WorkflowActionItemDto[]; actions: WorkflowActionItemDto[];

View file

@ -301,14 +301,14 @@ export type Workflow = Selectable<WorkflowTable> & {
export type WorkflowFilter = Selectable<WorkflowFilterTable> & { export type WorkflowFilter = Selectable<WorkflowFilterTable> & {
workflowId: string; workflowId: string;
filterId: string; pluginFilterId: string;
filterConfig: FilterConfig | null; filterConfig: FilterConfig | null;
order: number; order: number;
}; };
export type WorkflowAction = Selectable<WorkflowActionTable> & { export type WorkflowAction = Selectable<WorkflowActionTable> & {
workflowId: string; workflowId: string;
actionId: string; pluginActionId: string;
actionConfig: ActionConfig | null; actionConfig: ActionConfig | null;
order: number; order: number;
}; };

View file

@ -7,7 +7,7 @@ import { Optional, ValidateBoolean, ValidateEnum } from 'src/validation';
export class WorkflowFilterItemDto { export class WorkflowFilterItemDto {
@IsUUID() @IsUUID()
filterId!: string; pluginFilterId!: string;
@IsObject() @IsObject()
@Optional() @Optional()
@ -16,7 +16,7 @@ export class WorkflowFilterItemDto {
export class WorkflowActionItemDto { export class WorkflowActionItemDto {
@IsUUID() @IsUUID()
actionId!: string; pluginActionId!: string;
@IsObject() @IsObject()
@Optional() @Optional()
@ -86,7 +86,7 @@ export class WorkflowResponseDto {
export class WorkflowFilterResponseDto { export class WorkflowFilterResponseDto {
id!: string; id!: string;
workflowId!: string; workflowId!: string;
filterId!: string; pluginFilterId!: string;
filterConfig!: FilterConfig | null; filterConfig!: FilterConfig | null;
order!: number; order!: number;
} }
@ -94,7 +94,7 @@ export class WorkflowFilterResponseDto {
export class WorkflowActionResponseDto { export class WorkflowActionResponseDto {
id!: string; id!: string;
workflowId!: string; workflowId!: string;
actionId!: string; pluginActionId!: string;
actionConfig!: ActionConfig | null; actionConfig!: ActionConfig | null;
order!: number; order!: number;
} }
@ -103,7 +103,7 @@ export function mapWorkflowFilter(filter: WorkflowFilter): WorkflowFilterRespons
return { return {
id: filter.id, id: filter.id,
workflowId: filter.workflowId, workflowId: filter.workflowId,
filterId: filter.filterId, pluginFilterId: filter.pluginFilterId,
filterConfig: filter.filterConfig, filterConfig: filter.filterConfig,
order: filter.order, order: filter.order,
}; };
@ -113,7 +113,7 @@ export function mapWorkflowAction(action: WorkflowAction): WorkflowActionRespons
return { return {
id: action.id, id: action.id,
workflowId: action.workflowId, workflowId: action.workflowId,
actionId: action.actionId, pluginActionId: action.pluginActionId,
actionConfig: action.actionConfig, actionConfig: action.actionConfig,
order: action.order, order: action.order,
}; };

View file

@ -0,0 +1,27 @@
import { Kysely, sql } from 'kysely';
export async function up(db: Kysely<any>): Promise<void> {
await sql`DROP INDEX "workflow_filter_filterId_idx";`.execute(db);
await sql`DROP INDEX "workflow_action_actionId_idx";`.execute(db);
await sql`ALTER TABLE "workflow_filter" DROP CONSTRAINT "workflow_filter_filterId_fkey";`.execute(db);
await sql`ALTER TABLE "workflow_action" DROP CONSTRAINT "workflow_action_actionId_fkey";`.execute(db);
await sql`ALTER TABLE "workflow_filter" RENAME COLUMN "filterId" TO "pluginFilterId";`.execute(db);
await sql`ALTER TABLE "workflow_action" RENAME COLUMN "actionId" TO "pluginActionId";`.execute(db);
await sql`ALTER TABLE "workflow_filter" ADD CONSTRAINT "workflow_filter_pluginFilterId_fkey" FOREIGN KEY ("pluginFilterId") REFERENCES "plugin_filter" ("id") ON UPDATE CASCADE ON DELETE CASCADE;`.execute(db);
await sql`ALTER TABLE "workflow_action" ADD CONSTRAINT "workflow_action_pluginActionId_fkey" FOREIGN KEY ("pluginActionId") REFERENCES "plugin_action" ("id") ON UPDATE CASCADE ON DELETE CASCADE;`.execute(db);
await sql`CREATE INDEX "workflow_filter_pluginFilterId_idx" ON "workflow_filter" ("pluginFilterId");`.execute(db);
await sql`CREATE INDEX "workflow_action_pluginActionId_idx" ON "workflow_action" ("pluginActionId");`.execute(db);
}
export async function down(db: Kysely<any>): Promise<void> {
await sql`DROP INDEX "workflow_filter_pluginFilterId_idx";`.execute(db);
await sql`DROP INDEX "workflow_action_pluginActionId_idx";`.execute(db);
await sql`ALTER TABLE "workflow_filter" DROP CONSTRAINT "workflow_filter_pluginFilterId_fkey";`.execute(db);
await sql`ALTER TABLE "workflow_action" DROP CONSTRAINT "workflow_action_pluginActionId_fkey";`.execute(db);
await sql`ALTER TABLE "workflow_filter" RENAME COLUMN "pluginFilterId" TO "filterId";`.execute(db);
await sql`ALTER TABLE "workflow_action" RENAME COLUMN "pluginActionId" TO "actionId";`.execute(db);
await sql`ALTER TABLE "workflow_filter" ADD CONSTRAINT "workflow_filter_filterId_fkey" FOREIGN KEY ("filterId") REFERENCES "plugin_filter" ("id") ON UPDATE CASCADE ON DELETE CASCADE;`.execute(db);
await sql`ALTER TABLE "workflow_action" ADD CONSTRAINT "workflow_action_actionId_fkey" FOREIGN KEY ("actionId") REFERENCES "plugin_action" ("id") ON UPDATE CASCADE ON DELETE CASCADE;`.execute(db);
await sql`CREATE INDEX "workflow_filter_filterId_idx" ON "workflow_filter" ("filterId");`.execute(db);
await sql`CREATE INDEX "workflow_action_actionId_idx" ON "workflow_action" ("actionId");`.execute(db);
}

View file

@ -38,7 +38,7 @@ export class WorkflowTable {
} }
@Index({ columns: ['workflowId', 'order'] }) @Index({ columns: ['workflowId', 'order'] })
@Index({ columns: ['filterId'] }) @Index({ columns: ['pluginFilterId'] })
@Table('workflow_filter') @Table('workflow_filter')
export class WorkflowFilterTable { export class WorkflowFilterTable {
@PrimaryGeneratedColumn('uuid') @PrimaryGeneratedColumn('uuid')
@ -48,7 +48,7 @@ export class WorkflowFilterTable {
workflowId!: Generated<string>; workflowId!: Generated<string>;
@ForeignKeyColumn(() => PluginFilterTable, { onDelete: 'CASCADE', onUpdate: 'CASCADE' }) @ForeignKeyColumn(() => PluginFilterTable, { onDelete: 'CASCADE', onUpdate: 'CASCADE' })
filterId!: string; pluginFilterId!: string;
@Column({ type: 'jsonb', nullable: true }) @Column({ type: 'jsonb', nullable: true })
filterConfig!: FilterConfig | null; filterConfig!: FilterConfig | null;
@ -58,7 +58,7 @@ export class WorkflowFilterTable {
} }
@Index({ columns: ['workflowId', 'order'] }) @Index({ columns: ['workflowId', 'order'] })
@Index({ columns: ['actionId'] }) @Index({ columns: ['pluginActionId'] })
@Table('workflow_action') @Table('workflow_action')
export class WorkflowActionTable { export class WorkflowActionTable {
@PrimaryGeneratedColumn('uuid') @PrimaryGeneratedColumn('uuid')
@ -68,7 +68,7 @@ export class WorkflowActionTable {
workflowId!: Generated<string>; workflowId!: Generated<string>;
@ForeignKeyColumn(() => PluginActionTable, { onDelete: 'CASCADE', onUpdate: 'CASCADE' }) @ForeignKeyColumn(() => PluginActionTable, { onDelete: 'CASCADE', onUpdate: 'CASCADE' })
actionId!: string; pluginActionId!: string;
@Column({ type: 'jsonb', nullable: true }) @Column({ type: 'jsonb', nullable: true })
actionConfig!: ActionConfig | null; actionConfig!: ActionConfig | null;

View file

@ -247,9 +247,9 @@ export class PluginService extends BaseService {
private async executeFilters(workflowFilters: WorkflowFilter[], context: WorkflowContext): Promise<boolean> { private async executeFilters(workflowFilters: WorkflowFilter[], context: WorkflowContext): Promise<boolean> {
for (const workflowFilter of workflowFilters) { for (const workflowFilter of workflowFilters) {
const filter = await this.pluginRepository.getFilter(workflowFilter.filterId); const filter = await this.pluginRepository.getFilter(workflowFilter.pluginFilterId);
if (!filter) { if (!filter) {
this.logger.error(`Filter ${workflowFilter.filterId} not found`); this.logger.error(`Filter ${workflowFilter.pluginFilterId} not found`);
return false; return false;
} }
@ -291,9 +291,9 @@ export class PluginService extends BaseService {
private async executeActions(workflowActions: WorkflowAction[], context: WorkflowContext): Promise<void> { private async executeActions(workflowActions: WorkflowAction[], context: WorkflowContext): Promise<void> {
for (const workflowAction of workflowActions) { for (const workflowAction of workflowActions) {
const action = await this.pluginRepository.getAction(workflowAction.actionId); const action = await this.pluginRepository.getAction(workflowAction.pluginActionId);
if (!action) { if (!action) {
throw new Error(`Action ${workflowAction.actionId} not found`); throw new Error(`Action ${workflowAction.pluginActionId} not found`);
} }
const pluginInstance = this.loadedPlugins.get(action.pluginId); const pluginInstance = this.loadedPlugins.get(action.pluginId);

View file

@ -78,13 +78,13 @@ export class WorkflowService extends BaseService {
} }
private async validateAndMapFilters( private async validateAndMapFilters(
filters: Array<{ filterId: string; filterConfig?: any }>, filters: Array<{ pluginFilterId: string; filterConfig?: any }>,
requiredContext: PluginContext, requiredContext: PluginContext,
) { ) {
for (const dto of filters) { for (const dto of filters) {
const filter = await this.pluginRepository.getFilter(dto.filterId); const filter = await this.pluginRepository.getFilter(dto.pluginFilterId);
if (!filter) { if (!filter) {
throw new BadRequestException(`Invalid filter ID: ${dto.filterId}`); throw new BadRequestException(`Invalid filter ID: ${dto.pluginFilterId}`);
} }
if (!filter.supportedContexts.includes(requiredContext)) { if (!filter.supportedContexts.includes(requiredContext)) {
@ -95,20 +95,20 @@ export class WorkflowService extends BaseService {
} }
return filters.map((dto, index) => ({ return filters.map((dto, index) => ({
filterId: dto.filterId, pluginFilterId: dto.pluginFilterId,
filterConfig: dto.filterConfig || null, filterConfig: dto.filterConfig || null,
order: index, order: index,
})); }));
} }
private async validateAndMapActions( private async validateAndMapActions(
actions: Array<{ actionId: string; actionConfig?: any }>, actions: Array<{ pluginActionId: string; actionConfig?: any }>,
requiredContext: PluginContext, requiredContext: PluginContext,
) { ) {
for (const dto of actions) { for (const dto of actions) {
const action = await this.pluginRepository.getAction(dto.actionId); const action = await this.pluginRepository.getAction(dto.pluginActionId);
if (!action) { if (!action) {
throw new BadRequestException(`Invalid action ID: ${dto.actionId}`); throw new BadRequestException(`Invalid action ID: ${dto.pluginActionId}`);
} }
if (!action.supportedContexts.includes(requiredContext)) { if (!action.supportedContexts.includes(requiredContext)) {
throw new BadRequestException( throw new BadRequestException(
@ -118,7 +118,7 @@ export class WorkflowService extends BaseService {
} }
return actions.map((dto, index) => ({ return actions.map((dto, index) => ({
actionId: dto.actionId, pluginActionId: dto.pluginActionId,
actionConfig: dto.actionConfig || null, actionConfig: dto.actionConfig || null,
order: index, order: index,
})); }));

View file

@ -113,13 +113,13 @@ describe(WorkflowService.name, () => {
enabled: true, enabled: true,
filters: [ filters: [
{ {
filterId: testFilterId, pluginFilterId: testFilterId,
filterConfig: { key: 'value' }, filterConfig: { key: 'value' },
}, },
], ],
actions: [ actions: [
{ {
actionId: testActionId, pluginActionId: testActionId,
actionConfig: { action: 'test' }, actionConfig: { action: 'test' },
}, },
], ],
@ -137,7 +137,7 @@ describe(WorkflowService.name, () => {
expect(workflow.filters[0]).toMatchObject({ expect(workflow.filters[0]).toMatchObject({
id: expect.any(String), id: expect.any(String),
workflowId: workflow.id, workflowId: workflow.id,
filterId: testFilterId, pluginFilterId: testFilterId,
filterConfig: { key: 'value' }, filterConfig: { key: 'value' },
order: 0, order: 0,
}); });
@ -146,7 +146,7 @@ describe(WorkflowService.name, () => {
expect(workflow.actions[0]).toMatchObject({ expect(workflow.actions[0]).toMatchObject({
id: expect.any(String), id: expect.any(String),
workflowId: workflow.id, workflowId: workflow.id,
actionId: testActionId, pluginActionId: testActionId,
actionConfig: { action: 'test' }, actionConfig: { action: 'test' },
order: 0, order: 0,
}); });
@ -163,7 +163,7 @@ describe(WorkflowService.name, () => {
name: 'invalid-workflow', name: 'invalid-workflow',
description: 'A workflow with invalid filter', description: 'A workflow with invalid filter',
enabled: true, enabled: true,
filters: [{ filterId: factory.uuid(), filterConfig: { key: 'value' } }], filters: [{ pluginFilterId: factory.uuid(), filterConfig: { key: 'value' } }],
actions: [], actions: [],
}), }),
).rejects.toThrow('Invalid filter ID'); ).rejects.toThrow('Invalid filter ID');
@ -181,7 +181,7 @@ describe(WorkflowService.name, () => {
description: 'A workflow with invalid action', description: 'A workflow with invalid action',
enabled: true, enabled: true,
filters: [], filters: [],
actions: [{ actionId: factory.uuid(), actionConfig: { action: 'test' } }], actions: [{ pluginActionId: factory.uuid(), actionConfig: { action: 'test' } }],
}), }),
).rejects.toThrow('Invalid action ID'); ).rejects.toThrow('Invalid action ID');
}); });
@ -220,7 +220,7 @@ describe(WorkflowService.name, () => {
name: 'invalid-context-workflow', name: 'invalid-context-workflow',
description: 'A workflow with context mismatch', description: 'A workflow with context mismatch',
enabled: true, enabled: true,
filters: [{ filterId: result.filters[0].id }], filters: [{ pluginFilterId: result.filters[0].id }],
actions: [], actions: [],
}), }),
).rejects.toThrow('does not support asset context'); ).rejects.toThrow('does not support asset context');
@ -261,7 +261,7 @@ describe(WorkflowService.name, () => {
description: 'A workflow with context mismatch', description: 'A workflow with context mismatch',
enabled: true, enabled: true,
filters: [], filters: [],
actions: [{ actionId: result.actions[0].id }], actions: [{ pluginActionId: result.actions[0].id }],
}), }),
).rejects.toThrow('does not support asset context'); ).rejects.toThrow('does not support asset context');
}); });
@ -277,13 +277,13 @@ describe(WorkflowService.name, () => {
description: 'A workflow with multiple filters and actions', description: 'A workflow with multiple filters and actions',
enabled: true, enabled: true,
filters: [ filters: [
{ filterId: testFilterId, filterConfig: { step: 1 } }, { pluginFilterId: testFilterId, filterConfig: { step: 1 } },
{ filterId: testFilterId, filterConfig: { step: 2 } }, { pluginFilterId: testFilterId, filterConfig: { step: 2 } },
], ],
actions: [ actions: [
{ actionId: testActionId, actionConfig: { step: 1 } }, { pluginActionId: testActionId, actionConfig: { step: 1 } },
{ actionId: testActionId, actionConfig: { step: 2 } }, { pluginActionId: testActionId, actionConfig: { step: 2 } },
{ actionId: testActionId, actionConfig: { step: 3 } }, { pluginActionId: testActionId, actionConfig: { step: 3 } },
], ],
}); });
@ -378,8 +378,8 @@ describe(WorkflowService.name, () => {
name: 'test-workflow', name: 'test-workflow',
description: 'A test workflow', description: 'A test workflow',
enabled: true, enabled: true,
filters: [{ filterId: testFilterId, filterConfig: { key: 'value' } }], filters: [{ pluginFilterId: testFilterId, filterConfig: { key: 'value' } }],
actions: [{ actionId: testActionId, actionConfig: { action: 'test' } }], actions: [{ pluginActionId: testActionId, actionConfig: { action: 'test' } }],
}); });
const workflow = await sut.get(auth, created.id); const workflow = await sut.get(auth, created.id);
@ -461,14 +461,14 @@ describe(WorkflowService.name, () => {
name: 'test-workflow', name: 'test-workflow',
description: 'Test', description: 'Test',
enabled: true, enabled: true,
filters: [{ filterId: testFilterId, filterConfig: { old: 'config' } }], filters: [{ pluginFilterId: testFilterId, filterConfig: { old: 'config' } }],
actions: [], actions: [],
}); });
const updated = await sut.update(auth, created.id, { const updated = await sut.update(auth, created.id, {
filters: [ filters: [
{ filterId: testFilterId, filterConfig: { new: 'config' } }, { pluginFilterId: testFilterId, filterConfig: { new: 'config' } },
{ filterId: testFilterId, filterConfig: { second: 'filter' } }, { pluginFilterId: testFilterId, filterConfig: { second: 'filter' } },
], ],
}); });
@ -488,13 +488,13 @@ describe(WorkflowService.name, () => {
description: 'Test', description: 'Test',
enabled: true, enabled: true,
filters: [], filters: [],
actions: [{ actionId: testActionId, actionConfig: { old: 'config' } }], actions: [{ pluginActionId: testActionId, actionConfig: { old: 'config' } }],
}); });
const updated = await sut.update(auth, created.id, { const updated = await sut.update(auth, created.id, {
actions: [ actions: [
{ actionId: testActionId, actionConfig: { new: 'config' } }, { pluginActionId: testActionId, actionConfig: { new: 'config' } },
{ actionId: testActionId, actionConfig: { second: 'action' } }, { pluginActionId: testActionId, actionConfig: { second: 'action' } },
], ],
}); });
@ -513,7 +513,7 @@ describe(WorkflowService.name, () => {
name: 'test-workflow', name: 'test-workflow',
description: 'Test', description: 'Test',
enabled: true, enabled: true,
filters: [{ filterId: testFilterId, filterConfig: { key: 'value' } }], filters: [{ pluginFilterId: testFilterId, filterConfig: { key: 'value' } }],
actions: [], actions: [],
}); });
@ -588,7 +588,7 @@ describe(WorkflowService.name, () => {
await expect( await expect(
sut.update(auth, created.id, { sut.update(auth, created.id, {
filters: [{ filterId: factory.uuid(), filterConfig: {} }], filters: [{ pluginFilterId: factory.uuid(), filterConfig: {} }],
}), }),
).rejects.toThrow(); ).rejects.toThrow();
}); });
@ -608,7 +608,7 @@ describe(WorkflowService.name, () => {
}); });
await expect( await expect(
sut.update(auth, created.id, { actions: [{ actionId: factory.uuid(), actionConfig: {} }] }), sut.update(auth, created.id, { actions: [{ pluginActionId: factory.uuid(), actionConfig: {} }] }),
).rejects.toThrow(); ).rejects.toThrow();
}); });
}); });
@ -643,8 +643,8 @@ describe(WorkflowService.name, () => {
name: 'test-workflow', name: 'test-workflow',
description: 'Test', description: 'Test',
enabled: true, enabled: true,
filters: [{ filterId: testFilterId, filterConfig: {} }], filters: [{ pluginFilterId: testFilterId, filterConfig: {} }],
actions: [{ actionId: testActionId, actionConfig: {} }], actions: [{ pluginActionId: testActionId, actionConfig: {} }],
}); });
await sut.delete(auth, workflow.id); await sut.delete(auth, workflow.id);