@kubuild/core 0.8.1 → 0.8.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/document/artboards.d.cts +113 -0
- package/dist/document/artboards.d.cts.map +1 -0
- package/dist/document/command-tree-utils.d.cts +81 -0
- package/dist/document/command-tree-utils.d.cts.map +1 -0
- package/dist/document/commands.d.cts +204 -0
- package/dist/document/commands.d.cts.map +1 -0
- package/dist/document/document-utils.d.cts +49 -0
- package/dist/document/document-utils.d.cts.map +1 -0
- package/dist/document/document-utils.d.ts +1 -1
- package/dist/document/document-utils.d.ts.map +1 -1
- package/dist/document/history.d.cts +153 -0
- package/dist/document/history.d.cts.map +1 -0
- package/dist/document/history.d.ts +1 -1
- package/dist/document/history.d.ts.map +1 -1
- package/dist/document/index.d.cts +6 -0
- package/dist/document/index.d.cts.map +1 -0
- package/dist/document/index.d.ts +5 -5
- package/dist/document/index.d.ts.map +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +7 -0
- package/dist/index.d.cts.map +1 -0
- package/dist/index.d.ts +6 -6
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/io/exporter.d.cts +89 -0
- package/dist/io/exporter.d.cts.map +1 -0
- package/dist/io/exporter.d.ts +3 -3
- package/dist/io/exporter.d.ts.map +1 -1
- package/dist/io/importer.d.cts +245 -0
- package/dist/io/importer.d.cts.map +1 -0
- package/dist/io/importer.d.ts +3 -3
- package/dist/io/importer.d.ts.map +1 -1
- package/dist/io/index.d.cts +8 -0
- package/dist/io/index.d.cts.map +1 -0
- package/dist/io/index.d.ts +7 -7
- package/dist/io/index.d.ts.map +1 -1
- package/dist/io/load-project.d.cts +42 -0
- package/dist/io/load-project.d.cts.map +1 -0
- package/dist/io/migration.d.cts +112 -0
- package/dist/io/migration.d.cts.map +1 -0
- package/dist/io/round-trip-comparator.d.cts +38 -0
- package/dist/io/round-trip-comparator.d.cts.map +1 -0
- package/dist/io/template-utils.d.cts +129 -0
- package/dist/io/template-utils.d.cts.map +1 -0
- package/dist/io/tracking-sanitizer.d.cts +23 -0
- package/dist/io/tracking-sanitizer.d.cts.map +1 -0
- package/dist/runtime/binding-resolver.d.cts +16 -0
- package/dist/runtime/binding-resolver.d.cts.map +1 -0
- package/dist/runtime/binding-resolver.d.ts +1 -1
- package/dist/runtime/binding-resolver.d.ts.map +1 -1
- package/dist/runtime/conditional-resolver.d.cts +45 -0
- package/dist/runtime/conditional-resolver.d.cts.map +1 -0
- package/dist/runtime/index.d.cts +9 -0
- package/dist/runtime/index.d.cts.map +1 -0
- package/dist/runtime/index.d.ts +8 -8
- package/dist/runtime/index.d.ts.map +1 -1
- package/dist/runtime/interpolator.d.cts +50 -0
- package/dist/runtime/interpolator.d.cts.map +1 -0
- package/dist/runtime/pipeline-executor.d.cts +136 -0
- package/dist/runtime/pipeline-executor.d.cts.map +1 -0
- package/dist/runtime/server-tracking.d.cts +143 -0
- package/dist/runtime/server-tracking.d.cts.map +1 -0
- package/dist/runtime/state-store.d.cts +128 -0
- package/dist/runtime/state-store.d.cts.map +1 -0
- package/dist/runtime/tracking-relay.d.cts +44 -0
- package/dist/runtime/tracking-relay.d.cts.map +1 -0
- package/dist/runtime/tracking-relay.d.ts +1 -1
- package/dist/runtime/tracking-relay.d.ts.map +1 -1
- package/dist/runtime/variable-catalog.d.cts +9 -0
- package/dist/runtime/variable-catalog.d.cts.map +1 -0
- package/dist/runtime/variable-catalog.d.ts +1 -1
- package/dist/runtime/variable-catalog.d.ts.map +1 -1
- package/dist/types/index.d.cts +2 -0
- package/dist/types/index.d.cts.map +1 -0
- package/dist/types/index.d.ts +1 -1
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/interfaces.d.cts +175 -0
- package/dist/types/interfaces.d.cts.map +1 -0
- package/dist/types/interfaces.d.ts +1 -1
- package/dist/types/interfaces.d.ts.map +1 -1
- package/dist/validation/index.d.cts +5 -0
- package/dist/validation/index.d.cts.map +1 -0
- package/dist/validation/index.d.ts +4 -4
- package/dist/validation/index.d.ts.map +1 -1
- package/dist/validation/project-validator.d.cts +38 -0
- package/dist/validation/project-validator.d.cts.map +1 -0
- package/dist/validation/project-validator.d.ts +1 -1
- package/dist/validation/project-validator.d.ts.map +1 -1
- package/dist/validation/security.d.cts +99 -0
- package/dist/validation/security.d.cts.map +1 -0
- package/dist/validation/validation-engine.d.cts +39 -0
- package/dist/validation/validation-engine.d.cts.map +1 -0
- package/dist/validation/validator.d.cts +80 -0
- package/dist/validation/validator.d.cts.map +1 -0
- package/dist/validation/validator.d.ts +1 -1
- package/dist/validation/validator.d.ts.map +1 -1
- package/package.json +11 -6
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import { PageDocument, DocumentMetadata, Manifest } from '@kubuild/schema';
|
|
2
|
+
import { DocumentValidationError, ValidationOptions, ComponentRegistryLike } from '../validation/validator.cjs';
|
|
3
|
+
import { CollectedAssetReference } from '../document/document-utils.cjs';
|
|
4
|
+
import type { AssetProvider } from '../types/interfaces.cjs';
|
|
5
|
+
export interface ExportAssetData {
|
|
6
|
+
data: Uint8Array | ArrayBuffer | Blob | string;
|
|
7
|
+
mimeType?: string;
|
|
8
|
+
filename?: string;
|
|
9
|
+
}
|
|
10
|
+
export type AssetBytesProvider = (assetId: string, assetRef: CollectedAssetReference) => Promise<Uint8Array | ArrayBuffer | Blob | string | ExportAssetData | null | undefined> | Uint8Array | ArrayBuffer | Blob | string | ExportAssetData | null | undefined;
|
|
11
|
+
export interface ExportPackageOptions {
|
|
12
|
+
/**
|
|
13
|
+
* Component registry to validate document components and extract requirements.
|
|
14
|
+
*/
|
|
15
|
+
componentRegistry?: ComponentRegistryLike;
|
|
16
|
+
/**
|
|
17
|
+
* Known component types if registry is not passed.
|
|
18
|
+
*/
|
|
19
|
+
knownComponentTypes?: string[] | Set<string>;
|
|
20
|
+
/**
|
|
21
|
+
* Directly supplied asset binary map (keyed by assetId).
|
|
22
|
+
*/
|
|
23
|
+
assets?: Record<string, Uint8Array | ArrayBuffer | Blob | string | ExportAssetData> | Map<string, Uint8Array | ArrayBuffer | Blob | string | ExportAssetData>;
|
|
24
|
+
/**
|
|
25
|
+
* Host function to retrieve asset binary data dynamically.
|
|
26
|
+
*/
|
|
27
|
+
getAssetBytes?: AssetBytesProvider;
|
|
28
|
+
/**
|
|
29
|
+
* Host AssetProvider instance to resolve assets if bytes provider is not present.
|
|
30
|
+
*/
|
|
31
|
+
assetProvider?: AssetProvider;
|
|
32
|
+
/**
|
|
33
|
+
* Package version to write in manifest (defaults to "1.0.0").
|
|
34
|
+
*/
|
|
35
|
+
packageVersion?: string;
|
|
36
|
+
/**
|
|
37
|
+
* Builder compatibility semver range (defaults to ">=0.1.0").
|
|
38
|
+
*/
|
|
39
|
+
builderCompatibility?: string;
|
|
40
|
+
/**
|
|
41
|
+
* If true, assets that have a fallbackUrl or are externally hosted will not cause export failure if local bytes are missing.
|
|
42
|
+
* If false and a referenced asset has no bytes available, export fails.
|
|
43
|
+
*/
|
|
44
|
+
allowExternalFallback?: boolean;
|
|
45
|
+
/**
|
|
46
|
+
* Additional validation options passed to validateDocument.
|
|
47
|
+
*/
|
|
48
|
+
validationOptions?: ValidationOptions;
|
|
49
|
+
/**
|
|
50
|
+
* Optional metadata overrides (e.g. author, tags).
|
|
51
|
+
*/
|
|
52
|
+
metadata?: Partial<DocumentMetadata>;
|
|
53
|
+
}
|
|
54
|
+
export interface ExportPackageSuccess {
|
|
55
|
+
success: true;
|
|
56
|
+
archive: Uint8Array;
|
|
57
|
+
manifest: Manifest;
|
|
58
|
+
page: PageDocument;
|
|
59
|
+
metadata: DocumentMetadata;
|
|
60
|
+
assetCount: number;
|
|
61
|
+
}
|
|
62
|
+
export interface ExportPackageFailure {
|
|
63
|
+
success: false;
|
|
64
|
+
errors: DocumentValidationError[];
|
|
65
|
+
diagnosticMessage: string;
|
|
66
|
+
}
|
|
67
|
+
export type ExportPackageResult = ExportPackageSuccess | ExportPackageFailure;
|
|
68
|
+
/**
|
|
69
|
+
* Pure TypeScript SHA-256 implementation (zero native dependencies, deterministic).
|
|
70
|
+
*/
|
|
71
|
+
export declare function sha256Sync(data: Uint8Array): string;
|
|
72
|
+
/**
|
|
73
|
+
* Compute SHA-256 checksum with "sha256:" prefix.
|
|
74
|
+
*/
|
|
75
|
+
export declare function calculateChecksum(data: Uint8Array): Promise<string>;
|
|
76
|
+
/**
|
|
77
|
+
* Sanitize asset file names to prevent zip-slip or directory traversal vulnerabilities.
|
|
78
|
+
*/
|
|
79
|
+
export declare function sanitizeFilename(filename: string | undefined, assetId: string, mimeType?: string): string;
|
|
80
|
+
/**
|
|
81
|
+
* Validates document, collects asset references, resolves local asset bytes,
|
|
82
|
+
* writes manifest.json, page.json, metadata.json, and packages everything into a .stora archive.
|
|
83
|
+
*/
|
|
84
|
+
export declare function exportPackage(document: unknown, options?: ExportPackageOptions): Promise<ExportPackageResult>;
|
|
85
|
+
/**
|
|
86
|
+
* Alias for exportPackage.
|
|
87
|
+
*/
|
|
88
|
+
export declare const exportStoraPackage: typeof exportPackage;
|
|
89
|
+
//# sourceMappingURL=exporter.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"exporter.d.cts","sourceRoot":"","sources":["../../src/io/exporter.ts"],"names":[],"mappings":"AACA,OAAO,EACL,YAAY,EACZ,gBAAgB,EAChB,QAAQ,EAIT,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAEL,uBAAuB,EACvB,iBAAiB,EACjB,qBAAqB,EACtB,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAGL,uBAAuB,EACxB,MAAM,+BAA+B,CAAC;AACvC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAG5D,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,UAAU,GAAG,WAAW,GAAG,IAAI,GAAG,MAAM,CAAC;IAC/C,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,M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,CAAC;IAC3B,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,oBAAoB;IACnC,OAAO,EAAE,KAAK,CAAC;IACf,MAAM,EAAE,uBAAuB,EAAE,CAAC;IAClC,iBAAiB,EAAE,MAAM,CAAC;CAC3B;AAED,MAAM,MAAM,mBAAmB,GAAG,oBAAoB,GAAG,oBAAoB,CAAC;AAE9E;;GAEG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,UAAU,GAAG,MAAM,CA4FnD;AAED;;GAEG;AACH,wBAAsB,iBAAiB,CAAC,IAAI,EAAE,UAAU,GAAG,OAAO,CAAC,MAAM,CAAC,CAazE;AAGD;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,MAAM,GAAG,SAAS,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,MAAM,CAczG;AA0DD;;;GAGG;AACH,wBAAsB,aAAa,CACjC,QAAQ,EAAE,OAAO,EACjB,OAAO,GAAE,oBAAyB,GACjC,OAAO,CAAC,mBAAmB,CAAC,CA6M9B;AAED;;GAEG;AACH,eAAO,MAAM,kBAAkB,sBAAgB,CAAC"}
|
package/dist/io/exporter.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { PageDocument, DocumentMetadata, Manifest } from '@kubuild/schema';
|
|
2
|
-
import { DocumentValidationError, ValidationOptions, ComponentRegistryLike } from '../validation/validator';
|
|
3
|
-
import { CollectedAssetReference } from '../document/document-utils';
|
|
4
|
-
import type { AssetProvider } from '../types/interfaces';
|
|
2
|
+
import { DocumentValidationError, ValidationOptions, ComponentRegistryLike } from '../validation/validator.js';
|
|
3
|
+
import { CollectedAssetReference } from '../document/document-utils.js';
|
|
4
|
+
import type { AssetProvider } from '../types/interfaces.js';
|
|
5
5
|
export interface ExportAssetData {
|
|
6
6
|
data: Uint8Array | ArrayBuffer | Blob | string;
|
|
7
7
|
mimeType?: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"exporter.d.ts","sourceRoot":"","sources":["../../src/io/exporter.ts"],"names":[],"mappings":"AACA,OAAO,EACL,YAAY,EACZ,gBAAgB,EAChB,QAAQ,EAIT,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAEL,uBAAuB,EACvB,iBAAiB,EACjB,qBAAqB,EACtB,MAAM,
|
|
1
|
+
{"version":3,"file":"exporter.d.ts","sourceRoot":"","sources":["../../src/io/exporter.ts"],"names":[],"mappings":"AACA,OAAO,EACL,YAAY,EACZ,gBAAgB,EAChB,QAAQ,EAIT,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAEL,uBAAuB,EACvB,iBAAiB,EACjB,qBAAqB,EACtB,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAGL,uBAAuB,EACxB,MAAM,+BAA+B,CAAC;AACvC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAG5D,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,UAAU,GAAG,WAAW,GAAG,IAAI,GAAG,MAAM,CAAC;IAC/C,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,MAAM,kBAAkB,GAAG,CAC/B,OAAO,EAAE,MAAM,EACf,QAAQ,EAAE,uBAAuB,KAE/B,OAAO,CAAC,UAAU,GAAG,WAAW,GAAG,IAAI,GAAG,MAAM,GAAG,eAAe,GAAG,IAAI,GAAG,SAAS,CAAC,GACtF,UAAU,GACV,WAAW,GACX,IAAI,GACJ,MAAM,GACN,eAAe,GACf,IAAI,GACJ,SAAS,CAAC;AAEd,MAAM,WAAW,oBAAoB;IACnC;;OAEG;IACH,iBAAiB,CAAC,EAAE,qBAAqB,CAAC;IAE1C;;OAEG;IACH,mBAAmB,CAAC,EAAE,MAAM,EAAE,GAAG,GAAG,CAAC,MAAM,CAAC,CAAC;IAE7C;;OAEG;IACH,MAAM,CAAC,EACH,MAAM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E,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,MAAM,CAczG;AA0DD;;;GAGG;AACH,wBAAsB,aAAa,CACjC,QAAQ,EAAE,OAAO,EACjB,OAAO,GAAE,oBAAyB,GACjC,OAAO,CAAC,mBAAmB,CAAC,CA6M9B;AAED;;GAEG;AACH,eAAO,MAAM,kBAAkB,sBAAgB,CAAC"}
|
|
@@ -0,0 +1,245 @@
|
|
|
1
|
+
import { PageDocument, DocumentMetadata, Manifest, ManifestAssetItem } from '@kubuild/schema';
|
|
2
|
+
import { ComponentRegistryLike } from '../validation/validator.cjs';
|
|
3
|
+
import { MigrationRegistry } from './migration.cjs';
|
|
4
|
+
import type { AssetProvider, AssetInfo } from '../types/interfaces.cjs';
|
|
5
|
+
export interface SecurityLimits {
|
|
6
|
+
/**
|
|
7
|
+
* Maximum allowed size for the compressed archive in bytes (default: 50MB).
|
|
8
|
+
*/
|
|
9
|
+
maxArchiveSize?: number;
|
|
10
|
+
/**
|
|
11
|
+
* Maximum total uncompressed size across all files in bytes (default: 100MB).
|
|
12
|
+
*/
|
|
13
|
+
maxUncompressedSize?: number;
|
|
14
|
+
/**
|
|
15
|
+
* Maximum number of files in the archive (default: 1000).
|
|
16
|
+
*/
|
|
17
|
+
maxFileCount?: number;
|
|
18
|
+
/**
|
|
19
|
+
* Maximum size for any individual asset in bytes (default: 25MB).
|
|
20
|
+
*/
|
|
21
|
+
maxAssetSize?: number;
|
|
22
|
+
}
|
|
23
|
+
export declare const DEFAULT_SECURITY_LIMITS: Required<SecurityLimits>;
|
|
24
|
+
export type MissingDependencyPolicy = 'cancel' | 'import-with-placeholder' | 'install-or-register-before-import';
|
|
25
|
+
export type AssetCollisionStrategy = 'reject' | 'rename' | 'overwrite' | 'reuse-existing';
|
|
26
|
+
export interface AssetConflict {
|
|
27
|
+
assetId: string;
|
|
28
|
+
path: string;
|
|
29
|
+
mimeType: string;
|
|
30
|
+
size: number;
|
|
31
|
+
existingAsset?: AssetInfo | Record<string, unknown>;
|
|
32
|
+
}
|
|
33
|
+
export interface AssetConflictResolution {
|
|
34
|
+
action: AssetCollisionStrategy;
|
|
35
|
+
newAssetId?: string;
|
|
36
|
+
}
|
|
37
|
+
export type PreflightDiagnosticCode = 'ARCHIVE_EMPTY' | 'ARCHIVE_CORRUPT' | 'SIZE_LIMIT_EXCEEDED' | 'FILE_COUNT_EXCEEDED' | 'ZIP_SLIP_DETECTED' | 'EXECUTABLE_ASSET_DETECTED' | 'PROTOTYPE_POLLUTION_DETECTED' | 'MISSING_MANIFEST' | 'INVALID_MANIFEST' | 'MISSING_PAGE_DOCUMENT' | 'INVALID_PAGE_DOCUMENT' | 'UNSUPPORTED_SCHEMA_VERSION' | 'NO_MIGRATION_PATH' | 'MIGRATION_FAILED' | 'ASSET_FILE_MISSING' | 'ASSET_SIZE_MISMATCH' | 'ASSET_CHECKSUM_MISMATCH' | 'ASSET_LIMIT_EXCEEDED' | 'ASSET_CONFLICT' | 'MISSING_COMPONENTS' | 'MISSING_CAPABILITIES' | 'HOST_ADAPTER_ERROR' | 'TRACKING_SECRET_REMOVED';
|
|
38
|
+
export interface PreflightDiagnostic {
|
|
39
|
+
code: PreflightDiagnosticCode;
|
|
40
|
+
severity: 'error' | 'warning' | 'info';
|
|
41
|
+
message: string;
|
|
42
|
+
path?: string;
|
|
43
|
+
details?: Record<string, unknown>;
|
|
44
|
+
}
|
|
45
|
+
export interface PreflightOptions {
|
|
46
|
+
/**
|
|
47
|
+
* Component registry to check required custom components.
|
|
48
|
+
*/
|
|
49
|
+
componentRegistry?: ComponentRegistryLike;
|
|
50
|
+
/**
|
|
51
|
+
* Allowlist of known component type names (used if componentRegistry is not provided or in combination).
|
|
52
|
+
*/
|
|
53
|
+
knownComponentTypes?: string[] | Set<string>;
|
|
54
|
+
/**
|
|
55
|
+
* Allowlist of capabilities supported by host.
|
|
56
|
+
*/
|
|
57
|
+
supportedCapabilities?: string[] | Set<string>;
|
|
58
|
+
/**
|
|
59
|
+
* Security limits for archive and files.
|
|
60
|
+
*/
|
|
61
|
+
securityLimits?: SecurityLimits;
|
|
62
|
+
/**
|
|
63
|
+
* Custom migration registry.
|
|
64
|
+
*/
|
|
65
|
+
migrationRegistry?: MigrationRegistry;
|
|
66
|
+
/**
|
|
67
|
+
* Target schema version (defaults to CURRENT_SCHEMA_VERSION).
|
|
68
|
+
*/
|
|
69
|
+
targetSchemaVersion?: string;
|
|
70
|
+
/**
|
|
71
|
+
* Policy for handling missing custom components and capabilities.
|
|
72
|
+
* - 'cancel' (default): Abort import with blocking errors when components/capabilities are missing.
|
|
73
|
+
* - 'import-with-placeholder': Allow import, keeping missing component nodes and props intact for placeholder rendering.
|
|
74
|
+
* - 'install-or-register-before-import': Call onMissingDependency to register/install before finalizing import.
|
|
75
|
+
*/
|
|
76
|
+
dependencyPolicy?: MissingDependencyPolicy;
|
|
77
|
+
/**
|
|
78
|
+
* Hook called when dependencyPolicy is 'install-or-register-before-import'.
|
|
79
|
+
*/
|
|
80
|
+
onMissingDependency?: (missing: {
|
|
81
|
+
components: string[];
|
|
82
|
+
capabilities: string[];
|
|
83
|
+
}, preflight: PreflightReport) => Promise<boolean | void> | boolean | void;
|
|
84
|
+
/**
|
|
85
|
+
* If true, missing components are treated as warnings rather than blocking errors.
|
|
86
|
+
* (Equivalent to setting dependencyPolicy: 'import-with-placeholder')
|
|
87
|
+
*/
|
|
88
|
+
allowMissingComponents?: boolean;
|
|
89
|
+
/**
|
|
90
|
+
* If true, missing capabilities are treated as warnings rather than blocking errors.
|
|
91
|
+
* (Equivalent to setting dependencyPolicy: 'import-with-placeholder')
|
|
92
|
+
*/
|
|
93
|
+
allowMissingCapabilities?: boolean;
|
|
94
|
+
/**
|
|
95
|
+
* Strategy for resolving asset collisions with existing host assets.
|
|
96
|
+
* - 'reject' (default): Refuse import if asset collision is detected without an explicit resolution strategy.
|
|
97
|
+
* - 'rename': Rename the incoming asset to avoid overwriting host assets, and automatically remap document asset references.
|
|
98
|
+
* - 'overwrite': Explicitly overwrite host assets with incoming archive assets.
|
|
99
|
+
* - 'reuse-existing': Reuse existing host assets and skip writing archive asset binaries.
|
|
100
|
+
*/
|
|
101
|
+
assetCollisionStrategy?: AssetCollisionStrategy;
|
|
102
|
+
/**
|
|
103
|
+
* Existing host asset IDs or checker function to detect collisions.
|
|
104
|
+
*/
|
|
105
|
+
existingAssetIds?: string[] | Set<string> | ((assetId: string) => boolean | Promise<boolean>);
|
|
106
|
+
/**
|
|
107
|
+
* Custom naming function when renaming colliding assets.
|
|
108
|
+
*/
|
|
109
|
+
renameAssetStrategy?: (incoming: ManifestAssetItem, existingIds: Set<string>) => string;
|
|
110
|
+
/**
|
|
111
|
+
* Host AssetProvider to resolve existing assets or upload extracted local assets.
|
|
112
|
+
*/
|
|
113
|
+
assetProvider?: AssetProvider;
|
|
114
|
+
/**
|
|
115
|
+
* Fine-grained callback for resolving individual asset conflicts.
|
|
116
|
+
*/
|
|
117
|
+
onAssetConflict?: (conflict: AssetConflict) => Promise<AssetConflictResolution | AssetCollisionStrategy> | AssetConflictResolution | AssetCollisionStrategy;
|
|
118
|
+
}
|
|
119
|
+
export interface PreflightReport {
|
|
120
|
+
/**
|
|
121
|
+
* True if archive is completely safe and syntactically valid.
|
|
122
|
+
*/
|
|
123
|
+
valid: boolean;
|
|
124
|
+
/**
|
|
125
|
+
* True if archive can be safely imported given the host's supported components/capabilities and asset policies.
|
|
126
|
+
*/
|
|
127
|
+
canImport: boolean;
|
|
128
|
+
/**
|
|
129
|
+
* Parsed manifest if available.
|
|
130
|
+
*/
|
|
131
|
+
manifest?: Manifest;
|
|
132
|
+
/**
|
|
133
|
+
* Parsed metadata if available.
|
|
134
|
+
*/
|
|
135
|
+
rawMetadata?: DocumentMetadata;
|
|
136
|
+
/**
|
|
137
|
+
* Schema version reported in the document/manifest.
|
|
138
|
+
*/
|
|
139
|
+
sourceVersion?: string;
|
|
140
|
+
/**
|
|
141
|
+
* Target schema version.
|
|
142
|
+
*/
|
|
143
|
+
targetVersion: string;
|
|
144
|
+
/**
|
|
145
|
+
* True if the document version differs from target version and requires migration.
|
|
146
|
+
*/
|
|
147
|
+
requiresMigration: boolean;
|
|
148
|
+
/**
|
|
149
|
+
* Migration path version sequence if migration is needed.
|
|
150
|
+
*/
|
|
151
|
+
migrationPath?: string[];
|
|
152
|
+
/**
|
|
153
|
+
* List of custom component types required by package that are missing in host.
|
|
154
|
+
*/
|
|
155
|
+
missingComponents: string[];
|
|
156
|
+
/**
|
|
157
|
+
* List of capabilities required by package that are missing in host.
|
|
158
|
+
*/
|
|
159
|
+
missingCapabilities: string[];
|
|
160
|
+
/**
|
|
161
|
+
* Active policy for missing dependencies.
|
|
162
|
+
*/
|
|
163
|
+
dependencyPolicy: MissingDependencyPolicy;
|
|
164
|
+
/**
|
|
165
|
+
* Number of valid local assets declared in manifest.
|
|
166
|
+
*/
|
|
167
|
+
assetCount: number;
|
|
168
|
+
/**
|
|
169
|
+
* List of detected asset collisions with existing host assets.
|
|
170
|
+
*/
|
|
171
|
+
assetConflicts: AssetConflict[];
|
|
172
|
+
/**
|
|
173
|
+
* Active strategy for handling asset collisions.
|
|
174
|
+
*/
|
|
175
|
+
assetCollisionStrategy: AssetCollisionStrategy;
|
|
176
|
+
/**
|
|
177
|
+
* Total uncompressed size of all files in archive.
|
|
178
|
+
*/
|
|
179
|
+
totalUncompressedBytes: number;
|
|
180
|
+
/**
|
|
181
|
+
* Diagnostics collected during inspection.
|
|
182
|
+
*/
|
|
183
|
+
diagnostics: PreflightDiagnostic[];
|
|
184
|
+
}
|
|
185
|
+
export interface ImportPackageOptions extends PreflightOptions {
|
|
186
|
+
/**
|
|
187
|
+
* Custom asset importer hook called for each extracted asset.
|
|
188
|
+
*/
|
|
189
|
+
onAssetImport?: (assetId: string, assetBytes: Uint8Array, assetMeta: ManifestAssetItem) => Promise<AssetInfo | string | void> | AssetInfo | string | void;
|
|
190
|
+
}
|
|
191
|
+
export interface ExtractedAsset {
|
|
192
|
+
bytes: Uint8Array;
|
|
193
|
+
meta: ManifestAssetItem;
|
|
194
|
+
hostInfo?: AssetInfo | string;
|
|
195
|
+
}
|
|
196
|
+
export interface ImportPackageSuccess {
|
|
197
|
+
success: true;
|
|
198
|
+
document: PageDocument;
|
|
199
|
+
manifest: Manifest;
|
|
200
|
+
metadata: DocumentMetadata;
|
|
201
|
+
extractedAssets: Map<string, ExtractedAsset>;
|
|
202
|
+
renamedAssets?: Record<string, string>;
|
|
203
|
+
preflight: PreflightReport;
|
|
204
|
+
/** Non-fatal notes produced while importing (e.g. tracking secrets stripped). */
|
|
205
|
+
warnings?: PreflightDiagnostic[];
|
|
206
|
+
}
|
|
207
|
+
export interface ImportPackageFailure {
|
|
208
|
+
success: false;
|
|
209
|
+
errors: PreflightDiagnostic[];
|
|
210
|
+
diagnosticMessage: string;
|
|
211
|
+
preflight?: PreflightReport;
|
|
212
|
+
}
|
|
213
|
+
export type ImportPackageResult = ImportPackageSuccess | ImportPackageFailure;
|
|
214
|
+
/**
|
|
215
|
+
* Checks if a zip entry path contains zip-slip or directory traversal attempts.
|
|
216
|
+
*/
|
|
217
|
+
export declare function isDangerousPath(filepath: string): boolean;
|
|
218
|
+
/**
|
|
219
|
+
* Inspects a .stora archive and runs non-destructive preflight validation.
|
|
220
|
+
* Verifies security limits, path safety, manifest, checksums, component/capability requirements, and migration status.
|
|
221
|
+
*/
|
|
222
|
+
export declare function preflightPackage(archiveData: Uint8Array | ArrayBuffer, options?: PreflightOptions): Promise<PreflightReport>;
|
|
223
|
+
/**
|
|
224
|
+
* Preview a .stora package without mutating host state.
|
|
225
|
+
* Returns missing dependencies, asset conflicts, schema migration status, and diagnostics.
|
|
226
|
+
*/
|
|
227
|
+
export declare const previewImportPackage: typeof preflightPackage;
|
|
228
|
+
/**
|
|
229
|
+
* Alias for preflightPackage.
|
|
230
|
+
*/
|
|
231
|
+
export declare const inspectPackage: typeof preflightPackage;
|
|
232
|
+
/**
|
|
233
|
+
* Default generator for renaming colliding asset IDs.
|
|
234
|
+
*/
|
|
235
|
+
export declare function defaultRenameAssetStrategy(incoming: ManifestAssetItem, existingIds: Set<string>): string;
|
|
236
|
+
/**
|
|
237
|
+
* Imports a .stora package with preflight safety checks, schema migration, missing dependency policy,
|
|
238
|
+
* and host-controlled asset collision handling.
|
|
239
|
+
*/
|
|
240
|
+
export declare function importPackage(archiveData: Uint8Array | ArrayBuffer, options?: ImportPackageOptions): Promise<ImportPackageResult>;
|
|
241
|
+
/**
|
|
242
|
+
* Alias for importPackage.
|
|
243
|
+
*/
|
|
244
|
+
export declare const importStoraPackage: typeof importPackage;
|
|
245
|
+
//# sourceMappingURL=importer.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"importer.d.cts","sourceRoot":"","sources":["../../src/io/importer.ts"],"names":[],"mappings":"AACA,OAAO,EACL,YAAY,EACZ,gBAAgB,EAChB,QAAQ,EACR,iBAAiB,EAIlB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAEL,qBAAqB,EACtB,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAIL,iBAAiB,EAElB,MAAM,gBAAgB,CAAC;AASxB,OAAO,KAAK,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AAEvE,MAAM,WAAW,cAAc;IAC7B;;OAEG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;IAExB;;OAEG;IACH,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAE7B;;OAEG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;IAEtB;;OAEG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAED,eAAO,MAAM,uBAAuB,EAAE,QAAQ,CAAC,cAAc,CAK5D,CAAC;AAEF,MAAM,MAAM,uBAAuB,GAC/B,QAAQ,GACR,yBAAyB,GACzB,mCAAmC,CAAC;AAExC,MAAM,MAAM,sBAAsB,GAC9B,QAAQ,GACR,QAAQ,GACR,WAAW,GACX,gBAAgB,CAAC;AAErB,MAAM,WAA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AC,CAAC;IAC7C,aAAa,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACvC,SAAS,EAAE,eAAe,CAAC;IAC3B,iFAAiF;IACjF,QAAQ,CAAC,EAAE,mBAAmB,EAAE,CAAC;CAClC;AAED,MAAM,WAAW,oBAAoB;IACnC,OAAO,EAAE,KAAK,CAAC;IACf,MAAM,EAAE,mBAAmB,EAAE,CAAC;IAC9B,iBAAiB,EAAE,MAAM,CAAC;IAC1B,SAAS,CAAC,EAAE,eAAe,CAAC;CAC7B;AAED,MAAM,MAAM,mBAAmB,GAAG,oBAAoB,GAAG,oBAAoB,CAAC;AAE9E;;GAEG;AACH,wBAAgB,eAAe,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAuBzD;AAED;;;GAGG;AACH,wBAAsB,gBAAgB,CACpC,WAAW,EAAE,UAAU,GAAG,WAAW,EACrC,OAAO,GAAE,gBAAqB,GAC7B,OAAO,CAAC,eAAe,CAAC,CA2e1B;AAwBD;;;GAGG;AACH,eAAO,MAAM,oBAAoB,yBAAmB,CAAC;AAErD;;GAEG;AACH,eAAO,MAAM,cAAc,yBAAmB,CAAC;AAE/C;;GAEG;AACH,wBAAgB,0BAA0B,CACxC,QAAQ,EAAE,iBAAiB,EAC3B,WAAW,EAAE,GAAG,CAAC,MAAM,CAAC,GACvB,MAAM,CAQR;AAED;;;GAGG;AACH,wBAAsB,aAAa,CACjC,WAAW,EAAE,UAAU,GAAG,WAAW,EACrC,OAAO,GAAE,oBAAyB,GACjC,OAAO,CAAC,mBAAmB,CAAC,CA+R9B;AAED;;GAEG;AACH,eAAO,MAAM,kBAAkB,sBAAgB,CAAC"}
|
package/dist/io/importer.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { PageDocument, DocumentMetadata, Manifest, ManifestAssetItem } from '@kubuild/schema';
|
|
2
|
-
import { ComponentRegistryLike } from '../validation/validator';
|
|
3
|
-
import { MigrationRegistry } from './migration';
|
|
4
|
-
import type { AssetProvider, AssetInfo } from '../types/interfaces';
|
|
2
|
+
import { ComponentRegistryLike } from '../validation/validator.js';
|
|
3
|
+
import { MigrationRegistry } from './migration.js';
|
|
4
|
+
import type { AssetProvider, AssetInfo } from '../types/interfaces.js';
|
|
5
5
|
export interface SecurityLimits {
|
|
6
6
|
/**
|
|
7
7
|
* Maximum allowed size for the compressed archive in bytes (default: 50MB).
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"importer.d.ts","sourceRoot":"","sources":["../../src/io/importer.ts"],"names":[],"mappings":"AACA,OAAO,EACL,YAAY,EACZ,gBAAgB,EAChB,QAAQ,EACR,iBAAiB,EAIlB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAEL,qBAAqB,EACtB,MAAM,
|
|
1
|
+
{"version":3,"file":"importer.d.ts","sourceRoot":"","sources":["../../src/io/importer.ts"],"names":[],"mappings":"AACA,OAAO,EACL,YAAY,EACZ,gBAAgB,EAChB,QAAQ,EACR,iBAAiB,EAIlB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAEL,qBAAqB,EACtB,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAIL,iBAAiB,EAElB,MAAM,gBAAgB,CAAC;AASxB,OAAO,KAAK,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AAEvE,MAAM,WAAW,cAAc;IAC7B;;OAEG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;IAExB;;OAEG;IACH,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAE7B;;OAEG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;IAEtB;;OAEG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAED,eAAO,MAAM,uBAAuB,EAAE,QAAQ,CAAC,cAAc,CAK5D,CAAC;AAEF,MAAM,MAAM,uBAAuB,GAC/B,QAAQ,GACR,yBAAyB,GACzB,mCAAmC,CAAC;AAExC,MAAM,MAAM,sBAAsB,GAC9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from './load-project.cjs';
|
|
5
|
+
export * from './round-trip-comparator.cjs';
|
|
6
|
+
export * from './template-utils.cjs';
|
|
7
|
+
export * from './tracking-sanitizer.cjs';
|
|
8
|
+
//# sourceMappingURL=index.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.cts","sourceRoot":"","sources":["../../src/io/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAC;AAC9B,cAAc,eAAe,CAAC;AAC9B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,mBAAmB,CAAC;AAClC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,qBAAqB,CAAC;AAEpC,cAAc,yBAAyB,CAAC"}
|
package/dist/io/index.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
export * from './exporter';
|
|
2
|
-
export * from './importer';
|
|
3
|
-
export * from './migration';
|
|
4
|
-
export * from './load-project';
|
|
5
|
-
export * from './round-trip-comparator';
|
|
6
|
-
export * from './template-utils';
|
|
7
|
-
export * from './tracking-sanitizer';
|
|
1
|
+
export * from './exporter.js';
|
|
2
|
+
export * from './importer.js';
|
|
3
|
+
export * from './migration.js';
|
|
4
|
+
export * from './load-project.js';
|
|
5
|
+
export * from './round-trip-comparator.js';
|
|
6
|
+
export * from './template-utils.js';
|
|
7
|
+
export * from './tracking-sanitizer.js';
|
|
8
8
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/io/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/io/index.ts"],"names":[],"mappings":"AAAA,cAAc,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/io/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAC;AAC9B,cAAc,eAAe,CAAC;AAC9B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,mBAAmB,CAAC;AAClC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,qBAAqB,CAAC;AAEpC,cAAc,yBAAyB,CAAC"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { PageDocument, ProjectDocument } from '@kubuild/schema';
|
|
2
|
+
export type ProjectLoadErrorCode = 'INVALID_SOURCE' | 'PROJECT_SCHEMA_INVALID' | 'LEGACY_MIGRATION_FAILED';
|
|
3
|
+
export interface ProjectLoadError {
|
|
4
|
+
code: ProjectLoadErrorCode;
|
|
5
|
+
message: string;
|
|
6
|
+
details?: Record<string, unknown>;
|
|
7
|
+
}
|
|
8
|
+
export interface ProjectLoadResult {
|
|
9
|
+
success: boolean;
|
|
10
|
+
project?: ProjectDocument;
|
|
11
|
+
/** True when the payload arrived as a legacy single-page document and was wrapped. */
|
|
12
|
+
wrappedFromLegacyPage: boolean;
|
|
13
|
+
errors: ProjectLoadError[];
|
|
14
|
+
}
|
|
15
|
+
export interface WrapPageAsProjectOptions {
|
|
16
|
+
artboardId?: string;
|
|
17
|
+
name?: string;
|
|
18
|
+
slug?: string;
|
|
19
|
+
width?: number;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Wrap a single PageDocument into a one-artboard ProjectDocument.
|
|
23
|
+
* Used both by the legacy load path and by consumers that still hold a lone page.
|
|
24
|
+
*/
|
|
25
|
+
export declare function wrapPageDocumentAsProject(document: PageDocument, options?: WrapPageAsProjectOptions): ProjectDocument;
|
|
26
|
+
/**
|
|
27
|
+
* Load a raw payload as a ProjectDocument.
|
|
28
|
+
*
|
|
29
|
+
* `PageDocument -> ProjectDocument` is a schema *kind* switch (`document` singular vs.
|
|
30
|
+
* `artboards[]`, different `schema` literal), not a version step, so it cannot be expressed
|
|
31
|
+
* as a MigrationRegistry step. This loader sniffs the shape and routes accordingly:
|
|
32
|
+
*
|
|
33
|
+
* - already a project (`schema === 'stora.project'` or has `artboards[]`) -> parse as a project
|
|
34
|
+
* - anything else -> run the existing page migration pipeline untouched, then wrap the
|
|
35
|
+
* fully-migrated page into a single-artboard project
|
|
36
|
+
*
|
|
37
|
+
* Legacy inline modal/drawer/collapsible nodes are deliberately NOT auto-extracted into
|
|
38
|
+
* component artboards here; that stays an explicit, author-triggered action so no existing
|
|
39
|
+
* document silently changes how it renders.
|
|
40
|
+
*/
|
|
41
|
+
export declare function loadProjectDocument(raw: unknown): ProjectLoadResult;
|
|
42
|
+
//# sourceMappingURL=load-project.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"load-project.d.cts","sourceRoot":"","sources":["../../src/io/load-project.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,YAAY,EACZ,eAAe,EAMhB,MAAM,iBAAiB,CAAC;AAqBzB,MAAM,MAAM,oBAAoB,GAC5B,gBAAgB,GAChB,wBAAwB,GACxB,yBAAyB,CAAC;AAE9B,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE,oBAAoB,CAAC;IAC3B,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACnC;AAED,MAAM,WAAW,iBAAiB;IAChC,OAAO,EAAE,OAAO,CAAC;IACjB,OAAO,CAAC,EAAE,eAAe,CAAC;IAC1B,sFAAsF;IACtF,qBAAqB,EAAE,OAAO,CAAC;IAC/B,MAAM,EAAE,gBAAgB,EAAE,CAAC;CAC5B;AAED,MAAM,WAAW,wBAAwB;IACvC,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAID;;;GAGG;AACH,wBAAgB,yBAAyB,CACvC,QAAQ,EAAE,YAAY,EACtB,OAAO,GAAE,wBAA6B,GACrC,eAAe,CAkBjB;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,mBAAmB,CAAC,GAAG,EAAE,OAAO,GAAG,iBAAiB,CA4DnE"}
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import { PageDocument } from '@kubuild/schema';
|
|
2
|
+
export type MigrationErrorCode = 'NO_MIGRATION_PATH' | 'UNSUPPORTED_SCHEMA_VERSION' | 'INVALID_SOURCE_DOCUMENT' | 'MIGRATION_EXECUTION_FAILED';
|
|
3
|
+
export interface MigrationError {
|
|
4
|
+
code: MigrationErrorCode;
|
|
5
|
+
message: string;
|
|
6
|
+
sourceVersion: string;
|
|
7
|
+
targetVersion: string;
|
|
8
|
+
details?: Record<string, unknown>;
|
|
9
|
+
}
|
|
10
|
+
export type MigrationWarningCode = 'TRACKING_SECRET_REMOVED' | 'PROP_ALIAS_MIGRATED';
|
|
11
|
+
/**
|
|
12
|
+
* Non-fatal note emitted by a migration step (the migration still succeeds).
|
|
13
|
+
*/
|
|
14
|
+
export interface MigrationWarning {
|
|
15
|
+
code: MigrationWarningCode | (string & {});
|
|
16
|
+
message: string;
|
|
17
|
+
/** Step that emitted the warning, e.g. "1.0.0->1.1.0". */
|
|
18
|
+
step?: string;
|
|
19
|
+
/** Dotted document paths affected. */
|
|
20
|
+
paths?: string[];
|
|
21
|
+
}
|
|
22
|
+
export interface MigrationDiagnostic {
|
|
23
|
+
success: boolean;
|
|
24
|
+
sourceVersion: string;
|
|
25
|
+
targetVersion: string;
|
|
26
|
+
migrationPath: string[];
|
|
27
|
+
stepsApplied: number;
|
|
28
|
+
dryRun: boolean;
|
|
29
|
+
errors?: MigrationError[];
|
|
30
|
+
/** Non-fatal notes, e.g. tracking secrets stripped from the document. */
|
|
31
|
+
warnings?: MigrationWarning[];
|
|
32
|
+
}
|
|
33
|
+
export interface MigrationResult {
|
|
34
|
+
success: boolean;
|
|
35
|
+
document?: PageDocument;
|
|
36
|
+
diagnostic: MigrationDiagnostic;
|
|
37
|
+
}
|
|
38
|
+
export interface MigrateOptions {
|
|
39
|
+
/**
|
|
40
|
+
* Target schema version (defaults to CURRENT_SCHEMA_VERSION).
|
|
41
|
+
*/
|
|
42
|
+
targetVersion?: string;
|
|
43
|
+
/**
|
|
44
|
+
* If true, validates path and simulates migration without modifying production data.
|
|
45
|
+
*/
|
|
46
|
+
dryRun?: boolean;
|
|
47
|
+
/**
|
|
48
|
+
* Custom migration registry (defaults to defaultMigrationRegistry).
|
|
49
|
+
*/
|
|
50
|
+
registry?: MigrationRegistry;
|
|
51
|
+
/**
|
|
52
|
+
* Validate document with schema validator after migration (default: true).
|
|
53
|
+
*/
|
|
54
|
+
validate?: boolean;
|
|
55
|
+
}
|
|
56
|
+
/** Context handed to each migration step. */
|
|
57
|
+
export interface MigrationStepContext {
|
|
58
|
+
/** Records a non-fatal warning on the final `MigrationDiagnostic`. */
|
|
59
|
+
warn: (warning: MigrationWarning) => void;
|
|
60
|
+
}
|
|
61
|
+
export type MigrationFunction = (rawDoc: Record<string, unknown>, context: MigrationStepContext) => Record<string, unknown>;
|
|
62
|
+
export interface MigrationStep {
|
|
63
|
+
fromVersion: string;
|
|
64
|
+
toVersion: string;
|
|
65
|
+
migrate: MigrationFunction;
|
|
66
|
+
description?: string;
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Migration Registry to manage version transition steps.
|
|
70
|
+
*/
|
|
71
|
+
export declare class MigrationRegistry {
|
|
72
|
+
private steps;
|
|
73
|
+
/**
|
|
74
|
+
* Register a migration step from one version to another.
|
|
75
|
+
*/
|
|
76
|
+
register(step: MigrationStep): void;
|
|
77
|
+
private getKey;
|
|
78
|
+
/**
|
|
79
|
+
* Find shortest path of versions to migrate from source to target using BFS.
|
|
80
|
+
*/
|
|
81
|
+
findPath(sourceVersion: string, targetVersion: string): string[] | null;
|
|
82
|
+
/**
|
|
83
|
+
* Check if a valid migration path exists between source and target versions.
|
|
84
|
+
*/
|
|
85
|
+
hasPath(sourceVersion: string, targetVersion: string): boolean;
|
|
86
|
+
/**
|
|
87
|
+
* Get the migration step handler for a direct version step.
|
|
88
|
+
*/
|
|
89
|
+
getStep(fromVersion: string, toVersion: string): MigrationStep | undefined;
|
|
90
|
+
}
|
|
91
|
+
export declare const defaultMigrationRegistry: MigrationRegistry;
|
|
92
|
+
/**
|
|
93
|
+
* Moves deprecated text-prop aliases (`content`, `label`, `quote`, ...) onto each
|
|
94
|
+
* component's canonical prop name (STORA-550), in place. The canonical value becomes
|
|
95
|
+
* whatever the pre-1.2.0 renderer actually displayed (its `legacyReadOrder`), so a
|
|
96
|
+
* migrated document renders identically. Returns the dotted paths of rewritten props.
|
|
97
|
+
*/
|
|
98
|
+
export declare function canonicalizeTextPropsInPlace(root: unknown, basePath?: string): string[];
|
|
99
|
+
/**
|
|
100
|
+
* Check whether a migration path exists between source and target versions.
|
|
101
|
+
*/
|
|
102
|
+
export declare function canMigrate(sourceVersion: string, targetVersion?: string, registry?: MigrationRegistry): boolean;
|
|
103
|
+
/**
|
|
104
|
+
* Get the sequence of versions forming the migration path.
|
|
105
|
+
*/
|
|
106
|
+
export declare function getMigrationPath(sourceVersion: string, targetVersion?: string, registry?: MigrationRegistry): string[] | null;
|
|
107
|
+
/**
|
|
108
|
+
* Migrate a page document from an older schema version to current (or specified) schema version.
|
|
109
|
+
* Supports dry-run execution, step diagnostics, and structured error reporting.
|
|
110
|
+
*/
|
|
111
|
+
export declare function migrateDocument(rawDocument: unknown, options?: MigrateOptions): MigrationResult;
|
|
112
|
+
//# sourceMappingURL=migration.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"migration.d.cts","sourceRoot":"","sources":["../../src/io/migration.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,YAAY,EAMb,MAAM,iBAAiB,CAAC;AAKzB,MAAM,MAAM,kBAAkB,GAC1B,mBAAmB,GACnB,4BAA4B,GAC5B,yBAAyB,GACzB,4BAA4B,CAAC;AAEjC,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,kBAAkB,CAAC;IACzB,OAAO,EAAE,MAAM,CAAC;IAChB,aAAa,EAAE,MAAM,CAAC;IACtB,aAAa,EAAE,MAAM,CAAC;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