Task: SitePack Importer
Goal
Import data from an unpacked SitePack package into the target system.
Input
Path to the unpacked package (directory).
Requirements
- Read
sitepack.manifest.jsonandsitepack.catalog.json. - Determine profile(s) from
manifest.profiles. - Process artifacts from the catalog:
- For known
mediaType, perform import. - Unknown
mediaTypeMUST be skipped and logged.
- For known
- Unknown
entity.typeMUST NOT crash; MAY import as opaque. - Respect
applyPolicyfor config (e.g.,neveris not auto-applied). - If a
Transform Planexists and is supported, MAY apply steps in order. - Enforce path safety (no traversal, no absolute, no null bytes).
- If a
sitepack.volumes.jsondescriptor is provided, validate it, verify each volumesha256/size, and assemble volumes into a temporary directory before importing. - If a volume entry uses
encryption.scheme = "age", the importer MUST use the referenced envelope header to locate the encrypted payload and decrypt before assembly (or fail with a clear error if unsupported).
Chunked assets
- Asset index entries may be single-blob (
path) or chunked (chunks[]). - For chunked assets, reconstruct the asset by concatenating chunks in ascending
indexorder. - Importers MUST validate each chunk
sha256/sizeand the overall assetsha256/size.
Relations
- Importers SHOULD use a two-pass strategy:
- create entities (or placeholders) and build a mapping
sitepackEntityId -> targetSystemId, - resolve and apply relations using the mapping.
- create entities (or placeholders) and build a mapping
- If a Link cannot be resolved, it MUST be recorded as a warning and MUST NOT be fatal.
Output
Create reports/import.json with at least this structure:
{
"packageId": "...",
"profiles": ["..."],
"imported": {
"entities": 0,
"assets": 0,
"config": 0,
"recordsets": 0
},
"skipped": {
"unknownMediaTypes": 0,
"unknownEntityTypes": 0
},
"warnings": [],
"errors": []
}