import { createHash } from 'node:crypto';
import { resolve } from 'node:path';
const WORKFLOW_SOURCE_PATH = Symbol('workflowSourcePath');
const WORKFLOW_TRUST_INFO = Symbol('workflowTrustInfo');
const WORKFLOW_OPAQUE_REF = Symbol.for('takt.workflowOpaqueRef');
export function attachWorkflowSourcePath(workflow, sourcePath) {
    Object.defineProperty(workflow, WORKFLOW_SOURCE_PATH, {
        value: resolve(sourcePath),
        writable: true,
        configurable: true,
        enumerable: false,
    });
    return workflow;
}
export function buildOpaqueWorkflowRef(sourcePath, trustInfo) {
    const normalizedPath = resolve(sourcePath);
    const digest = createHash('sha256').update(normalizedPath).digest('hex');
    return `${trustInfo.source}:sha256:${digest}`;
}
export function attachWorkflowOpaqueRef(workflow, opaqueRef) {
    Object.defineProperty(workflow, WORKFLOW_OPAQUE_REF, {
        value: opaqueRef,
        writable: true,
        configurable: true,
        enumerable: false,
    });
    return workflow;
}
export function getAttachedWorkflowOpaqueRef(workflow) {
    return workflow[WORKFLOW_OPAQUE_REF];
}
export function getWorkflowSourcePath(workflow) {
    return workflow[WORKFLOW_SOURCE_PATH];
}
export function attachWorkflowTrustInfo(workflow, trustInfo) {
    Object.defineProperty(workflow, WORKFLOW_TRUST_INFO, {
        value: trustInfo,
        writable: true,
        configurable: true,
        enumerable: false,
    });
    return workflow;
}
export function getAttachedWorkflowTrustInfo(workflow) {
    return workflow[WORKFLOW_TRUST_INFO];
}
//# sourceMappingURL=workflowSourceMetadata.js.map