Skip to content

The open alternative to Salesforce, designed for AI.

1.5 KB
Raw Blame
import { type LogicFunctionDTO } from 'src/engine/metadata-modules/logic-function/dtos/logic-function.dto';
import { type FlatLogicFunction } from 'src/engine/metadata-modules/logic-function/types/flat-logic-function.type';

export const fromFlatLogicFunctionToLogicFunctionDto = ({
  flatLogicFunction,
}: {
  flatLogicFunction: FlatLogicFunction;
}): LogicFunctionDTO => {
  return {
    id: flatLogicFunction.id,
    universalIdentifier: flatLogicFunction.universalIdentifier,
    name: flatLogicFunction.name,
    description: flatLogicFunction.description ?? undefined,
    runtime: flatLogicFunction.runtime,
    timeoutSeconds: flatLogicFunction.timeoutSeconds,
    executionMode: flatLogicFunction.executionMode,
    sourceHandlerPath: flatLogicFunction.sourceHandlerPath,
    handlerName: flatLogicFunction.handlerName,
    applicationId: flatLogicFunction.applicationId ?? undefined,
    workspaceId: flatLogicFunction.workspaceId,
    createdAt: new Date(flatLogicFunction.createdAt),
    updatedAt: new Date(flatLogicFunction.updatedAt),
    cronTriggerSettings: flatLogicFunction.cronTriggerSettings ?? undefined,
    databaseEventTriggerSettings:
      flatLogicFunction.databaseEventTriggerSettings ?? undefined,
    httpRouteTriggerSettings:
      flatLogicFunction.httpRouteTriggerSettings ?? undefined,
    toolTriggerSettings: flatLogicFunction.toolTriggerSettings ?? undefined,
    workflowActionTriggerSettings:
      flatLogicFunction.workflowActionTriggerSettings ?? undefined,
  };
};