29 lines
1.0 KiB
TypeScript
29 lines
1.0 KiB
TypeScript
import type { CallStatus, NodeStatus, EdgeType } from "../schema/enums.js";
|
|
import type { OperationNodeAttrs } from "../schema/node.js";
|
|
|
|
export const defaultCallStatus: CallStatus = "pending";
|
|
|
|
export const defaultNodeStatus: NodeStatus = "idle";
|
|
|
|
export function defaultEdgeType(edgeType?: string): EdgeType {
|
|
if (edgeType !== undefined && edgeType !== null) {
|
|
return edgeType as EdgeType;
|
|
}
|
|
return "typed";
|
|
}
|
|
|
|
export function resolveDefaultNodeAttrs(
|
|
attrs: Partial<OperationNodeAttrs>,
|
|
defaults: Partial<OperationNodeAttrs> = {},
|
|
): OperationNodeAttrs {
|
|
return {
|
|
name: attrs.name ?? defaults.name ?? "",
|
|
namespace: attrs.namespace ?? defaults.namespace ?? "",
|
|
version: attrs.version ?? defaults.version ?? "",
|
|
type: attrs.type ?? defaults.type ?? "query",
|
|
inputSchema: attrs.inputSchema ?? defaults.inputSchema ?? {},
|
|
outputSchema: attrs.outputSchema ?? defaults.outputSchema ?? {},
|
|
description: attrs.description ?? defaults.description,
|
|
tags: attrs.tags ?? defaults.tags,
|
|
};
|
|
} |