@artinstack/migrator 0.1.0
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/LICENSE +21 -0
- package/README.md +71 -0
- package/dist/bundle-BfZqiKV_.d.ts +153 -0
- package/dist/chunk-2RWAXT6O.js +1 -0
- package/dist/chunk-2RWAXT6O.js.map +1 -0
- package/dist/chunk-FXXKLYO5.js +1076 -0
- package/dist/chunk-FXXKLYO5.js.map +1 -0
- package/dist/chunk-JKDRTL24.js +102 -0
- package/dist/chunk-JKDRTL24.js.map +1 -0
- package/dist/chunk-LKNIQQJO.js +1579 -0
- package/dist/chunk-LKNIQQJO.js.map +1 -0
- package/dist/cli/index.d.ts +1 -0
- package/dist/cli/index.js +242 -0
- package/dist/cli/index.js.map +1 -0
- package/dist/index-DQNzrygx.d.ts +279 -0
- package/dist/index.d.ts +336 -0
- package/dist/index.js +376 -0
- package/dist/index.js.map +1 -0
- package/dist/normalizer/index.d.ts +23 -0
- package/dist/normalizer/index.js +20 -0
- package/dist/normalizer/index.js.map +1 -0
- package/dist/sinks/index.d.ts +3 -0
- package/dist/sinks/index.js +46 -0
- package/dist/sinks/index.js.map +1 -0
- package/package.json +80 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Prashant Naik
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
# @artinstack/migrator
|
|
2
|
+
|
|
3
|
+
Stateless content normalizer and migration framework for transforming **WordPress**, **SmugMug**, **Squarespace**, and similar sources into a platform-agnostic schema.
|
|
4
|
+
|
|
5
|
+
**Public from day one.** Portable parsers and JSON export are useful without any specific host. Job orchestration, credentials, and UI are implemented separately via `MigrationSink`.
|
|
6
|
+
|
|
7
|
+
See [docs/architecture.md](./docs/architecture.md) for the high-level blueprint: data flow, DTOs, sink contract, and source mappings.
|
|
8
|
+
|
|
9
|
+
## Package layout
|
|
10
|
+
|
|
11
|
+
```
|
|
12
|
+
src/
|
|
13
|
+
parsers/ WordPress, SmugMug, Squarespace → normalizer DTOs
|
|
14
|
+
normalizer/ Canonical DTOs + portable idempotency types
|
|
15
|
+
sinks/ filesystem export, MigrationSink interface
|
|
16
|
+
cli/ artinstack-migrate
|
|
17
|
+
transformers/ HtmlToGrapes, css-to-styles, rewrite-inline-images
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
## Install
|
|
21
|
+
|
|
22
|
+
**From npm** (after publish):
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
pnpm add @artinstack/migrator
|
|
26
|
+
# or: npm install @artinstack/migrator
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
**From source** (development):
|
|
30
|
+
|
|
31
|
+
```bash
|
|
32
|
+
pnpm install
|
|
33
|
+
pnpm build
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
Requires **Node.js 20+**.
|
|
37
|
+
|
|
38
|
+
## CLI
|
|
39
|
+
|
|
40
|
+
```bash
|
|
41
|
+
pnpm build
|
|
42
|
+
|
|
43
|
+
# Installed / linked binary
|
|
44
|
+
artinstack-migrate wordpress export.xml --out ./output
|
|
45
|
+
artinstack-migrate validate wordpress ./export.xml
|
|
46
|
+
|
|
47
|
+
# Local clone — no global install
|
|
48
|
+
pnpm cli wordpress export.xml --dry-run
|
|
49
|
+
node dist/cli/index.js wordpress export.xml --dry-run
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
## Development
|
|
53
|
+
|
|
54
|
+
```bash
|
|
55
|
+
pnpm typecheck
|
|
56
|
+
pnpm test
|
|
57
|
+
pnpm dev # watch build
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
## What lives here vs the host
|
|
61
|
+
|
|
62
|
+
| Piece | `@artinstack/migrator` | Host application |
|
|
63
|
+
|-------|------------------------|------------------|
|
|
64
|
+
| Parsers + normalizer DTOs | Yes | No |
|
|
65
|
+
| CLI + filesystem JSON export | Yes | No |
|
|
66
|
+
| `MigrationSink` interface | Yes | Implementation |
|
|
67
|
+
| Jobs, worker, credentials, UI | No | Yes |
|
|
68
|
+
|
|
69
|
+
## License
|
|
70
|
+
|
|
71
|
+
MIT — see [LICENSE](./LICENSE).
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
type MigrationPlatform = "wordpress" | "smugmug" | "squarespace";
|
|
2
|
+
type EntityType = "post" | "page" | "asset" | "portfolio" | "category" | "tag";
|
|
3
|
+
type PublishStatus = "draft" | "published" | "archived";
|
|
4
|
+
interface SourceMetadata {
|
|
5
|
+
platform: MigrationPlatform;
|
|
6
|
+
id: string;
|
|
7
|
+
url?: string;
|
|
8
|
+
path?: string;
|
|
9
|
+
exportedAt?: string;
|
|
10
|
+
}
|
|
11
|
+
/** Canonical post DTO — raw HTML; sanitize at host sink. */
|
|
12
|
+
interface NormalizedPost {
|
|
13
|
+
type: "post";
|
|
14
|
+
source: SourceMetadata;
|
|
15
|
+
sourceId: string;
|
|
16
|
+
title: string;
|
|
17
|
+
slug: string;
|
|
18
|
+
excerpt?: string;
|
|
19
|
+
contentHtml: string;
|
|
20
|
+
publishedAt?: string;
|
|
21
|
+
status: PublishStatus;
|
|
22
|
+
categorySlugs?: string[];
|
|
23
|
+
tagSlugs?: string[];
|
|
24
|
+
/** WordPress attachment id before two-pass resolution. */
|
|
25
|
+
sourceFeaturedMediaId?: string;
|
|
26
|
+
featuredAssetSourceId?: string;
|
|
27
|
+
seoTitle?: string;
|
|
28
|
+
seoDescription?: string;
|
|
29
|
+
}
|
|
30
|
+
/** Canonical page DTO — raw HTML snapshot. */
|
|
31
|
+
interface NormalizedPage {
|
|
32
|
+
type: "page";
|
|
33
|
+
source: SourceMetadata;
|
|
34
|
+
sourceId: string;
|
|
35
|
+
title: string;
|
|
36
|
+
slug: string;
|
|
37
|
+
contentHtml: string;
|
|
38
|
+
contentCss?: string;
|
|
39
|
+
isHomePage?: boolean;
|
|
40
|
+
status: PublishStatus;
|
|
41
|
+
seoTitle?: string;
|
|
42
|
+
seoDescription?: string;
|
|
43
|
+
}
|
|
44
|
+
/** EXIF fields preserved from SmugMug / camera metadata when present. */
|
|
45
|
+
interface NormalizedAssetExif {
|
|
46
|
+
iso?: number;
|
|
47
|
+
aperture?: number;
|
|
48
|
+
shutter?: string;
|
|
49
|
+
focalLength?: number;
|
|
50
|
+
}
|
|
51
|
+
/** Remote asset to stream into the host sink. */
|
|
52
|
+
interface NormalizedAsset {
|
|
53
|
+
type: "asset";
|
|
54
|
+
source: SourceMetadata;
|
|
55
|
+
sourceId: string;
|
|
56
|
+
sourceUrl: string;
|
|
57
|
+
filename: string;
|
|
58
|
+
mimeType?: string;
|
|
59
|
+
caption?: string;
|
|
60
|
+
altText?: string;
|
|
61
|
+
keywords?: string[];
|
|
62
|
+
exif?: NormalizedAssetExif;
|
|
63
|
+
portfolioSourceId?: string;
|
|
64
|
+
sort?: number;
|
|
65
|
+
}
|
|
66
|
+
/** M2M index: portfolio ↔ asset membership and sort order. */
|
|
67
|
+
interface PortfolioMediaLink {
|
|
68
|
+
portfolioSourceId: string;
|
|
69
|
+
assetSourceId: string;
|
|
70
|
+
sort: number;
|
|
71
|
+
}
|
|
72
|
+
interface NormalizedPortfolio {
|
|
73
|
+
type: "portfolio";
|
|
74
|
+
source: SourceMetadata;
|
|
75
|
+
sourceId: string;
|
|
76
|
+
title: string;
|
|
77
|
+
slug: string;
|
|
78
|
+
description?: string;
|
|
79
|
+
parentSourceId?: string;
|
|
80
|
+
}
|
|
81
|
+
interface NormalizedCategory {
|
|
82
|
+
type: "category";
|
|
83
|
+
source: SourceMetadata;
|
|
84
|
+
sourceId: string;
|
|
85
|
+
name: string;
|
|
86
|
+
slug: string;
|
|
87
|
+
}
|
|
88
|
+
interface NormalizedTag {
|
|
89
|
+
type: "tag";
|
|
90
|
+
source: SourceMetadata;
|
|
91
|
+
sourceId: string;
|
|
92
|
+
name: string;
|
|
93
|
+
slug: string;
|
|
94
|
+
}
|
|
95
|
+
type NormalizedEntity = NormalizedPost | NormalizedPage | NormalizedAsset | NormalizedPortfolio | NormalizedCategory | NormalizedTag;
|
|
96
|
+
interface ValidationIssue {
|
|
97
|
+
code: string;
|
|
98
|
+
message: string;
|
|
99
|
+
path?: string;
|
|
100
|
+
}
|
|
101
|
+
interface ValidationResult {
|
|
102
|
+
ok: boolean;
|
|
103
|
+
issues: ValidationIssue[];
|
|
104
|
+
summary?: {
|
|
105
|
+
posts?: number;
|
|
106
|
+
pages?: number;
|
|
107
|
+
assets?: number;
|
|
108
|
+
portfolios?: number;
|
|
109
|
+
categories?: number;
|
|
110
|
+
tags?: number;
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
interface AdapterContext {
|
|
114
|
+
input: unknown;
|
|
115
|
+
cursor?: MigrationCursor;
|
|
116
|
+
}
|
|
117
|
+
interface MigrationAdapter {
|
|
118
|
+
platform: MigrationPlatform;
|
|
119
|
+
validateInput(input: unknown): ValidationResult | Promise<ValidationResult>;
|
|
120
|
+
enumerateEntities(ctx: AdapterContext): AsyncIterable<NormalizedEntity>;
|
|
121
|
+
}
|
|
122
|
+
interface MigrationCursor {
|
|
123
|
+
lastEntityKey?: EntityKey;
|
|
124
|
+
state?: Record<string, unknown>;
|
|
125
|
+
}
|
|
126
|
+
interface EntityKey {
|
|
127
|
+
platform: MigrationPlatform;
|
|
128
|
+
entityType: EntityType;
|
|
129
|
+
sourceId: string;
|
|
130
|
+
}
|
|
131
|
+
declare function entityKey(entity: NormalizedEntity, platform: MigrationPlatform): EntityKey;
|
|
132
|
+
|
|
133
|
+
interface EntityBundle {
|
|
134
|
+
posts: NormalizedPost[];
|
|
135
|
+
pages: NormalizedPage[];
|
|
136
|
+
media: NormalizedAsset[];
|
|
137
|
+
portfolios: NormalizedPortfolio[];
|
|
138
|
+
categories: NormalizedCategory[];
|
|
139
|
+
tags: NormalizedTag[];
|
|
140
|
+
}
|
|
141
|
+
declare function emptyBundle(): EntityBundle;
|
|
142
|
+
declare function collectEntities(entities: AsyncIterable<NormalizedEntity>): Promise<EntityBundle>;
|
|
143
|
+
interface BundleCounts {
|
|
144
|
+
posts: number;
|
|
145
|
+
pages: number;
|
|
146
|
+
assets: number;
|
|
147
|
+
portfolios: number;
|
|
148
|
+
categories: number;
|
|
149
|
+
tags: number;
|
|
150
|
+
}
|
|
151
|
+
declare function bundleCounts(bundle: EntityBundle): BundleCounts;
|
|
152
|
+
|
|
153
|
+
export { type AdapterContext as A, type BundleCounts as B, type EntityBundle as E, type MigrationAdapter as M, type NormalizedAsset as N, type PortfolioMediaLink as P, type SourceMetadata as S, type ValidationIssue as V, type MigrationPlatform as a, type EntityKey as b, type EntityType as c, type MigrationCursor as d, type NormalizedAssetExif as e, type NormalizedCategory as f, type NormalizedEntity as g, type NormalizedPage as h, type NormalizedPortfolio as i, type NormalizedPost as j, type NormalizedTag as k, type PublishStatus as l, type ValidationResult as m, bundleCounts as n, collectEntities as o, emptyBundle as p, entityKey as q };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
//# sourceMappingURL=chunk-2RWAXT6O.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|