migrateArtifactPayload
HardKAS SDK / artifacts/src / migrateArtifactPayload
Function: migrateArtifactPayload()
migrateArtifactPayload(
artifact,targetVersion?,options?):MigrationResult
Defined in: packages/artifacts/src/migration.ts:291
Migrates an artifact payload from its current schema version to the specified target version.
Identity Preservation:
- The original
contentHashis preserved asoriginalContentHash - The
lineage.rootArtifactIdis NEVER modified - A new
contentHashis computed after migration usingCURRENT_HASH_VERSION
Non-Destructive:
- The input artifact object is never mutated
- The canonical artifact file on disk is never modified
- Migration produces a new in-memory representation only
Parameters
artifact
The artifact payload to migrate
targetVersion?
string = ARTIFACT_VERSION
The desired target version (defaults to ARTIFACT_VERSION)
options?
strictPolicy?
boolean
Returns
MigrationResult with the migrated artifact and metadata
Throws
Error if no migration path exists
Example
const result = migrateArtifactPayload(legacyArtifact);
if (result.migrated) {
console.log(`Migrated from ${result.appliedSteps[0].fromVersion}`);
console.log(`Original hash preserved: ${result.originalContentHash}`);
}