await serializeSubGraph()

in libs/designer/src/lib/core/actions/bjsworkflow/serializer.ts [951:1102]


          await serializeSubGraph(
            subGraphs[0],
            [subGraphLocation, ...(subGraphDetail?.location ?? [])],
            [subGraphLocation],
            rootState,
            subGraphDetail
          )
        );
      }
    }
  }

  return result;
};

const serializeSubGraph = async (
  graph: WorkflowNode,
  graphLocation: string[],
  graphInputsLocation: string[],
  rootState: RootState,
  graphDetail?: SubGraphDetail
): Promise<Partial<LogicAppsV2.Action>> => {
  const { id: graphId, children } = graph;
  const result: Partial<LogicAppsV2.Action> = {};

  const nestedNodes = children?.filter(isWorkflowOperationNode) ?? [];
  const nestedActionsPromises = nestedNodes.map((nestedNode) =>
    serializeOperation(rootState, nestedNode.id)
  ) as Promise<LogicAppsV2.OperationDefinition>[];
  const nestedActions = await Promise.all(nestedActionsPromises);
  const idReplacements = rootState.workflow.idReplacements;

  safeSetObjectPropertyValue(
    result,
    graphLocation,
    nestedActions.reduce((actions: LogicAppsV2.Actions, action: LogicAppsV2.OperationDefinition, index: number) => {
      if (!isNullOrEmpty(action)) {
        const actionId = nestedNodes[index].id;
        actions[getRecordEntry(idReplacements, actionId) ?? actionId] = action;
        return actions;
      }

      return actions;
    }, {})
  );

  if (graphDetail?.inputs && graphDetail?.inputsLocation) {
    const inputs = serializeParametersFromManifest(getOperationInputsToSerialize(rootState, graphId), { properties: graphDetail } as any);
    safeSetObjectPropertyValue(result, [...graphInputsLocation, ...graphDetail.inputsLocation], inputs, true);
    if (inputs?.agentParameterSchema?.required) {
      safeSetObjectPropertyValue(
        result,
        [...graphInputsLocation, 'agentParameterSchema', 'required'],
        inputs?.agentParameterSchema?.required
      );
    }
  }

  return result;
};

export const isWorkflowOperationNode = (node: WorkflowNode) =>
  node.type === WORKFLOW_NODE_TYPES.OPERATION_NODE || node.type === WORKFLOW_NODE_TYPES.GRAPH_NODE;
//#endregion

//#region Settings Serialization
const serializeSettings = (
  operationId: string,
  settings: Settings,
  nodeStaticResults: NodeStaticResults,
  isTrigger: boolean,
  rootState: RootState
): Partial<LogicAppsV2.Action | LogicAppsV2.Trigger> => {
  const conditionExpressions = settings.conditionExpressions;
  const conditions = conditionExpressions
    ? conditionExpressions.value?.filter((expression) => !!expression).map((expression) => ({ expression }))
    : undefined;
  const timeout = settings.timeout?.isSupported ? settings.timeout.value : undefined;
  const count = settings.count?.isSupported ? settings.count.value : undefined;
  const limit = timeout || count ? { count, timeout } : undefined;

  const trackedProperties = settings.trackedProperties?.value;

  return {
    ...optional('correlation', settings.correlation?.value),
    ...(settings.invokerConnection?.value?.enabled
      ? optional('isInvokerConnectionEnabled', settings.invokerConnection?.value?.enabled)
      : {}),
    ...optional('conditions', conditions),
    ...optional('limit', limit),
    ...optional('operationOptions', getSerializedOperationOptions(operationId, settings, rootState)),
    ...optional('runtimeConfiguration', getSerializedRuntimeConfiguration(operationId, settings, nodeStaticResults, rootState)),
    ...optional('trackedProperties', trackedProperties),
    ...(getSplitOn(isTrigger, settings) ?? {}),
  };
};

const getSerializedRuntimeConfiguration = (
  operationId: string,
  settings: Settings,
  nodeStaticResults: NodeStaticResults,
  rootState: RootState
): LogicAppsV2.RuntimeConfiguration | undefined => {
  const runtimeConfiguration: LogicAppsV2.RuntimeConfiguration = {};
  const isTrigger = isRootNodeInGraph(operationId, 'root', rootState.workflow.nodesMetadata);

  const transferMode = settings.uploadChunk?.value?.transferMode;
  const uploadChunkSize = settings.uploadChunk?.value?.uploadChunkSize;
  const downloadChunkSize = settings.downloadChunkSize?.value;
  const pagingItemCount = settings.paging?.value?.enabled ? settings.paging.value.value : undefined;

  if (Object.keys(nodeStaticResults).length > 0) {
    safeSetObjectPropertyValue(runtimeConfiguration, [Constants.SETTINGS.PROPERTY_NAMES.STATIC_RESULT], nodeStaticResults);
  }

  if (transferMode) {
    safeSetObjectPropertyValue(
      runtimeConfiguration,
      [Constants.SETTINGS.PROPERTY_NAMES.CONTENT_TRANSFER, Constants.SETTINGS.PROPERTY_NAMES.TRANSFER_MODE],
      transferMode
    );
  }

  if (uploadChunkSize !== undefined) {
    safeSetObjectPropertyValue(
      runtimeConfiguration,
      [Constants.SETTINGS.PROPERTY_NAMES.CONTENT_TRANSFER, Constants.SETTINGS.PROPERTY_NAMES.UPLOAD_CHUNK_SIZE],
      uploadChunkSize
    );
  }

  if (downloadChunkSize !== undefined) {
    safeSetObjectPropertyValue(
      runtimeConfiguration,
      [Constants.SETTINGS.PROPERTY_NAMES.CONTENT_TRANSFER, Constants.SETTINGS.PROPERTY_NAMES.DOWNLOAD_CHUNK_SIZE],
      downloadChunkSize
    );
  }

  if (pagingItemCount !== undefined) {
    safeSetObjectPropertyValue(
      runtimeConfiguration,
      [Constants.SETTINGS.PROPERTY_NAMES.PAGINATION_POLICY, Constants.SETTINGS.PROPERTY_NAMES.MINIMUM_ITEM_COUNT],
      pagingItemCount
    );
  }

  if (!isTrigger) {
    if (!settings.sequential) {
      const repetitions = settings.concurrency?.value?.enabled ? settings.concurrency.value.runs : undefined;

      if (repetitions !== undefined) {