Refactor workflow-logic-function-interaction (#17699)

# Refactor workflow–logic function interaction

## Why

Workflow code steps and standalone logic functions shared the same build
layer and DB layer, which blurred two use cases: code steps belong to a
workflow version; standalone functions are deployable units. That made
workflow code steps harder to own and evolve.

## Goal

Treat code steps as **workflow-owned**: build and run them in workflow
context, and expose workflow-scoped APIs so the editor can load, test,
and save code step source without going through the generic
logic-function layer.
This commit is contained in:
Charles Bochet
2026-02-05 01:46:55 +01:00
committed by GitHub
parent 752359335e
commit 67a98f77e3
77 changed files with 1750 additions and 1336 deletions
@@ -3,29 +3,34 @@ import { Injectable } from '@nestjs/common';
import { ALL_FLAT_ENTITY_MAPS_PROPERTIES } from 'src/engine/metadata-modules/flat-entity/constant/all-flat-entity-maps-properties.constant';
import { AllFlatEntityMaps } from 'src/engine/metadata-modules/flat-entity/types/all-flat-entity-maps.type';
import { WorkspaceCacheService } from 'src/engine/workspace-cache/services/workspace-cache.service';
import { type WorkspaceCacheDataMap } from 'src/engine/workspace-cache/types/workspace-cache-key.type';
export type FlatEntityMapsCacheKeyName =
| keyof AllFlatEntityMaps
| 'flatApplicationMaps';
@Injectable()
export class WorkspaceManyOrAllFlatEntityMapsCacheService {
constructor(private readonly workspaceCacheService: WorkspaceCacheService) {}
public async getOrRecomputeManyOrAllFlatEntityMaps<
T extends (keyof AllFlatEntityMaps)[] = (keyof AllFlatEntityMaps)[],
TWithCustomMapsProperties extends boolean = true,
T extends FlatEntityMapsCacheKeyName[] = (keyof AllFlatEntityMaps)[],
>({
flatMapsKeys,
workspaceId,
}: {
workspaceId: string;
flatMapsKeys?: T;
}): Promise<Pick<AllFlatEntityMaps<TWithCustomMapsProperties>, T[number]>> {
}): Promise<Pick<WorkspaceCacheDataMap, T[number]>> {
return await this.workspaceCacheService.getOrRecompute(
workspaceId,
flatMapsKeys ?? ALL_FLAT_ENTITY_MAPS_PROPERTIES,
(flatMapsKeys ??
ALL_FLAT_ENTITY_MAPS_PROPERTIES) as (keyof WorkspaceCacheDataMap)[],
);
}
public async invalidateFlatEntityMaps<
T extends (keyof AllFlatEntityMaps)[] = (keyof AllFlatEntityMaps)[],
T extends FlatEntityMapsCacheKeyName[] = (keyof AllFlatEntityMaps)[],
>({
flatMapsKeys,
workspaceId,
@@ -35,12 +40,13 @@ export class WorkspaceManyOrAllFlatEntityMapsCacheService {
}): Promise<void> {
await this.workspaceCacheService.invalidateAndRecompute(
workspaceId,
flatMapsKeys ?? ALL_FLAT_ENTITY_MAPS_PROPERTIES,
(flatMapsKeys ??
ALL_FLAT_ENTITY_MAPS_PROPERTIES) as (keyof WorkspaceCacheDataMap)[],
);
}
public async flushFlatEntityMaps<
T extends (keyof AllFlatEntityMaps)[] = (keyof AllFlatEntityMaps)[],
T extends FlatEntityMapsCacheKeyName[] = (keyof AllFlatEntityMaps)[],
>({
flatMapsKeys,
workspaceId,
@@ -50,7 +56,8 @@ export class WorkspaceManyOrAllFlatEntityMapsCacheService {
}): Promise<void> {
await this.workspaceCacheService.flush(
workspaceId,
flatMapsKeys ?? ALL_FLAT_ENTITY_MAPS_PROPERTIES,
(flatMapsKeys ??
ALL_FLAT_ENTITY_MAPS_PROPERTIES) as (keyof WorkspaceCacheDataMap)[],
);
}
}