@oktis-works/cms 0.14.5 → 0.15.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/dist/command-registry.d.ts.map +1 -1
- package/dist/command-registry.js +4 -0
- package/dist/command-registry.js.map +1 -1
- package/dist/commands.d.ts.map +1 -1
- package/dist/commands.js +36 -0
- package/dist/commands.js.map +1 -1
- package/dist/generated/app-versions.js +2 -2
- package/dist/generated/theme-assets.js +1 -1
- package/dist/themes/default/theme.json +1 -1
- package/dist/utils/strings.d.ts +55 -0
- package/dist/utils/strings.d.ts.map +1 -0
- package/dist/utils/strings.js +136 -0
- package/dist/utils/strings.js.map +1 -0
- package/dist/wp-migrate/connectors/index.d.ts +6 -0
- package/dist/wp-migrate/connectors/index.d.ts.map +1 -0
- package/dist/wp-migrate/connectors/index.js +6 -0
- package/dist/wp-migrate/connectors/index.js.map +1 -0
- package/dist/wp-migrate/connectors/mysql.d.ts +193 -0
- package/dist/wp-migrate/connectors/mysql.d.ts.map +1 -0
- package/dist/wp-migrate/connectors/mysql.js +427 -0
- package/dist/wp-migrate/connectors/mysql.js.map +1 -0
- package/dist/wp-migrate/connectors/wp-schema.d.ts +88 -0
- package/dist/wp-migrate/connectors/wp-schema.d.ts.map +1 -0
- package/dist/wp-migrate/connectors/wp-schema.js +441 -0
- package/dist/wp-migrate/connectors/wp-schema.js.map +1 -0
- package/dist/wp-migrate/index.d.ts +53 -0
- package/dist/wp-migrate/index.d.ts.map +1 -0
- package/dist/wp-migrate/index.js +362 -0
- package/dist/wp-migrate/index.js.map +1 -0
- package/dist/wp-migrate/mappers/comments.d.ts +41 -0
- package/dist/wp-migrate/mappers/comments.d.ts.map +1 -0
- package/dist/wp-migrate/mappers/comments.js +215 -0
- package/dist/wp-migrate/mappers/comments.js.map +1 -0
- package/dist/wp-migrate/mappers/content-taxonomy.d.ts +35 -0
- package/dist/wp-migrate/mappers/content-taxonomy.d.ts.map +1 -0
- package/dist/wp-migrate/mappers/content-taxonomy.js +90 -0
- package/dist/wp-migrate/mappers/content-taxonomy.js.map +1 -0
- package/dist/wp-migrate/mappers/content-types.d.ts +68 -0
- package/dist/wp-migrate/mappers/content-types.d.ts.map +1 -0
- package/dist/wp-migrate/mappers/content-types.js +342 -0
- package/dist/wp-migrate/mappers/content-types.js.map +1 -0
- package/dist/wp-migrate/mappers/content.d.ts +65 -0
- package/dist/wp-migrate/mappers/content.d.ts.map +1 -0
- package/dist/wp-migrate/mappers/content.js +374 -0
- package/dist/wp-migrate/mappers/content.js.map +1 -0
- package/dist/wp-migrate/mappers/index.d.ts +14 -0
- package/dist/wp-migrate/mappers/index.d.ts.map +1 -0
- package/dist/wp-migrate/mappers/index.js +14 -0
- package/dist/wp-migrate/mappers/index.js.map +1 -0
- package/dist/wp-migrate/mappers/media.d.ts +41 -0
- package/dist/wp-migrate/mappers/media.d.ts.map +1 -0
- package/dist/wp-migrate/mappers/media.js +204 -0
- package/dist/wp-migrate/mappers/media.js.map +1 -0
- package/dist/wp-migrate/mappers/menus.d.ts +52 -0
- package/dist/wp-migrate/mappers/menus.d.ts.map +1 -0
- package/dist/wp-migrate/mappers/menus.js +244 -0
- package/dist/wp-migrate/mappers/menus.js.map +1 -0
- package/dist/wp-migrate/mappers/options.d.ts +44 -0
- package/dist/wp-migrate/mappers/options.d.ts.map +1 -0
- package/dist/wp-migrate/mappers/options.js +187 -0
- package/dist/wp-migrate/mappers/options.js.map +1 -0
- package/dist/wp-migrate/mappers/postmeta.d.ts +66 -0
- package/dist/wp-migrate/mappers/postmeta.d.ts.map +1 -0
- package/dist/wp-migrate/mappers/postmeta.js +278 -0
- package/dist/wp-migrate/mappers/postmeta.js.map +1 -0
- package/dist/wp-migrate/mappers/taxonomies.d.ts +59 -0
- package/dist/wp-migrate/mappers/taxonomies.d.ts.map +1 -0
- package/dist/wp-migrate/mappers/taxonomies.js +246 -0
- package/dist/wp-migrate/mappers/taxonomies.js.map +1 -0
- package/dist/wp-migrate/mappers/termmeta.d.ts +35 -0
- package/dist/wp-migrate/mappers/termmeta.d.ts.map +1 -0
- package/dist/wp-migrate/mappers/termmeta.js +77 -0
- package/dist/wp-migrate/mappers/termmeta.js.map +1 -0
- package/dist/wp-migrate/mappers/users.d.ts +53 -0
- package/dist/wp-migrate/mappers/users.d.ts.map +1 -0
- package/dist/wp-migrate/mappers/users.js +280 -0
- package/dist/wp-migrate/mappers/users.js.map +1 -0
- package/dist/wp-migrate/reporters/console.d.ts +49 -0
- package/dist/wp-migrate/reporters/console.d.ts.map +1 -0
- package/dist/wp-migrate/reporters/console.js +220 -0
- package/dist/wp-migrate/reporters/console.js.map +1 -0
- package/dist/wp-migrate/reporters/index.d.ts +7 -0
- package/dist/wp-migrate/reporters/index.d.ts.map +1 -0
- package/dist/wp-migrate/reporters/index.js +7 -0
- package/dist/wp-migrate/reporters/index.js.map +1 -0
- package/dist/wp-migrate/reporters/json.d.ts +26 -0
- package/dist/wp-migrate/reporters/json.d.ts.map +1 -0
- package/dist/wp-migrate/reporters/json.js +134 -0
- package/dist/wp-migrate/reporters/json.js.map +1 -0
- package/dist/wp-migrate/reporters/summary.d.ts +22 -0
- package/dist/wp-migrate/reporters/summary.d.ts.map +1 -0
- package/dist/wp-migrate/reporters/summary.js +174 -0
- package/dist/wp-migrate/reporters/summary.js.map +1 -0
- package/dist/wp-migrate/runners/checkpoint.d.ts +22 -0
- package/dist/wp-migrate/runners/checkpoint.d.ts.map +1 -0
- package/dist/wp-migrate/runners/checkpoint.js +106 -0
- package/dist/wp-migrate/runners/checkpoint.js.map +1 -0
- package/dist/wp-migrate/runners/index.d.ts +6 -0
- package/dist/wp-migrate/runners/index.d.ts.map +1 -0
- package/dist/wp-migrate/runners/index.js +6 -0
- package/dist/wp-migrate/runners/index.js.map +1 -0
- package/dist/wp-migrate/runners/sequential.d.ts +66 -0
- package/dist/wp-migrate/runners/sequential.d.ts.map +1 -0
- package/dist/wp-migrate/runners/sequential.js +306 -0
- package/dist/wp-migrate/runners/sequential.js.map +1 -0
- package/dist/wp-migrate/transformers/dates.d.ts +61 -0
- package/dist/wp-migrate/transformers/dates.d.ts.map +1 -0
- package/dist/wp-migrate/transformers/dates.js +161 -0
- package/dist/wp-migrate/transformers/dates.js.map +1 -0
- package/dist/wp-migrate/transformers/html-to-json.d.ts +61 -0
- package/dist/wp-migrate/transformers/html-to-json.d.ts.map +1 -0
- package/dist/wp-migrate/transformers/html-to-json.js +361 -0
- package/dist/wp-migrate/transformers/html-to-json.js.map +1 -0
- package/dist/wp-migrate/transformers/index.d.ts +8 -0
- package/dist/wp-migrate/transformers/index.d.ts.map +1 -0
- package/dist/wp-migrate/transformers/index.js +8 -0
- package/dist/wp-migrate/transformers/index.js.map +1 -0
- package/dist/wp-migrate/transformers/serialized-php.d.ts +39 -0
- package/dist/wp-migrate/transformers/serialized-php.d.ts.map +1 -0
- package/dist/wp-migrate/transformers/serialized-php.js +335 -0
- package/dist/wp-migrate/transformers/serialized-php.js.map +1 -0
- package/dist/wp-migrate/transformers/slugs.d.ts +77 -0
- package/dist/wp-migrate/transformers/slugs.d.ts.map +1 -0
- package/dist/wp-migrate/transformers/slugs.js +221 -0
- package/dist/wp-migrate/transformers/slugs.js.map +1 -0
- package/dist/wp-migrate/types.d.ts +484 -0
- package/dist/wp-migrate/types.d.ts.map +1 -0
- package/dist/wp-migrate/types.js +6 -0
- package/dist/wp-migrate/types.js.map +1 -0
- package/dist/wp-migrate/validators/content.d.ts +44 -0
- package/dist/wp-migrate/validators/content.d.ts.map +1 -0
- package/dist/wp-migrate/validators/content.js +92 -0
- package/dist/wp-migrate/validators/content.js.map +1 -0
- package/dist/wp-migrate/validators/field-values.d.ts +44 -0
- package/dist/wp-migrate/validators/field-values.d.ts.map +1 -0
- package/dist/wp-migrate/validators/field-values.js +182 -0
- package/dist/wp-migrate/validators/field-values.js.map +1 -0
- package/dist/wp-migrate/validators/index.d.ts +6 -0
- package/dist/wp-migrate/validators/index.d.ts.map +1 -0
- package/dist/wp-migrate/validators/index.js +6 -0
- package/dist/wp-migrate/validators/index.js.map +1 -0
- package/package.json +6 -3
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Content Taxonomy Mapper
|
|
3
|
+
* Maps wp_term_relationships → OkCMS content_taxonomy_terms
|
|
4
|
+
*/
|
|
5
|
+
import { WPMySQLConnector } from '../connectors/mysql';
|
|
6
|
+
import { WPMigrationConfig, MigrationPhase, PhaseStats, IDMaps, MigrationError } from '../types';
|
|
7
|
+
export interface ContentTaxonomyMapperDeps {
|
|
8
|
+
connector: WPMySQLConnector;
|
|
9
|
+
config: WPMigrationConfig;
|
|
10
|
+
idMaps: IDMaps;
|
|
11
|
+
stats: Record<MigrationPhase, PhaseStats>;
|
|
12
|
+
errors: MigrationError[];
|
|
13
|
+
reportProgress: (phase: MigrationPhase, current: number, total: number) => void;
|
|
14
|
+
}
|
|
15
|
+
export declare class ContentTaxonomyMapper {
|
|
16
|
+
private deps;
|
|
17
|
+
constructor(deps: ContentTaxonomyMapperDeps);
|
|
18
|
+
/**
|
|
19
|
+
* Main entry point: migrate content-taxonomy relationships
|
|
20
|
+
*/
|
|
21
|
+
migrate(): Promise<void>;
|
|
22
|
+
/**
|
|
23
|
+
* Process a batch of relationships
|
|
24
|
+
*/
|
|
25
|
+
private processBatch;
|
|
26
|
+
/**
|
|
27
|
+
* Add error to collection
|
|
28
|
+
*/
|
|
29
|
+
private addError;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Factory function
|
|
33
|
+
*/
|
|
34
|
+
export declare function migrateContentTaxonomy(connector: WPMySQLConnector, config: WPMigrationConfig, idMaps: IDMaps, stats: Record<MigrationPhase, PhaseStats>, errors: MigrationError[], reportProgress: (phase: MigrationPhase, current: number, total: number) => void): Promise<void>;
|
|
35
|
+
//# sourceMappingURL=content-taxonomy.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"content-taxonomy.d.ts","sourceRoot":"","sources":["../../../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
export class ContentTaxonomyMapper {
|
|
6
|
+
deps;
|
|
7
|
+
constructor(deps) {
|
|
8
|
+
this.deps = deps;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Main entry point: migrate content-taxonomy relationships
|
|
12
|
+
*/
|
|
13
|
+
async migrate() {
|
|
14
|
+
const phase = 'content-taxonomy';
|
|
15
|
+
this.deps.stats[phase] = { created: 0, updated: 0, skipped: 0, errors: 0, durationMs: 0 };
|
|
16
|
+
const startTime = Date.now();
|
|
17
|
+
try {
|
|
18
|
+
// Get all term relationships
|
|
19
|
+
const relationships = await this.deps.connector.getTermRelationships();
|
|
20
|
+
let processed = 0;
|
|
21
|
+
const batchSize = 1000;
|
|
22
|
+
for (let i = 0; i < relationships.length; i += batchSize) {
|
|
23
|
+
const batch = relationships.slice(i, i + batchSize);
|
|
24
|
+
await this.processBatch(batch);
|
|
25
|
+
processed += batch.length;
|
|
26
|
+
this.deps.reportProgress(phase, processed, relationships.length);
|
|
27
|
+
}
|
|
28
|
+
this.deps.stats[phase].durationMs = Date.now() - startTime;
|
|
29
|
+
}
|
|
30
|
+
catch (error) {
|
|
31
|
+
this.deps.stats[phase].errors++;
|
|
32
|
+
this.addError(phase, 'term_relationships', 0, 'migrate', error instanceof Error ? error.message : 'Unknown error');
|
|
33
|
+
throw error;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Process a batch of relationships
|
|
38
|
+
*/
|
|
39
|
+
async processBatch(relationships) {
|
|
40
|
+
const { connector, idMaps, stats } = this.deps;
|
|
41
|
+
for (const rel of relationships) {
|
|
42
|
+
try {
|
|
43
|
+
// Map object_id (WP post ID) to OkCMS content UUID
|
|
44
|
+
const contentId = idMaps.content.get(rel.object_id);
|
|
45
|
+
if (!contentId) {
|
|
46
|
+
// Content not migrated (maybe revision, attachment, etc.)
|
|
47
|
+
stats['content-taxonomy'].skipped++;
|
|
48
|
+
continue;
|
|
49
|
+
}
|
|
50
|
+
// Map term_taxonomy_id to OkCMS term UUID
|
|
51
|
+
const termId = idMaps.term.get(rel.term_taxonomy_id);
|
|
52
|
+
if (!termId) {
|
|
53
|
+
stats['content-taxonomy'].skipped++;
|
|
54
|
+
continue;
|
|
55
|
+
}
|
|
56
|
+
// Insert into content_taxonomy_terms
|
|
57
|
+
await connector.query(`INSERT INTO content_taxonomy_terms (content_id, term_id)
|
|
58
|
+
VALUES (?, ?)
|
|
59
|
+
ON DUPLICATE KEY UPDATE content_id = content_id`, [contentId, termId]);
|
|
60
|
+
stats['content-taxonomy'].created++;
|
|
61
|
+
}
|
|
62
|
+
catch (error) {
|
|
63
|
+
stats['content-taxonomy'].errors++;
|
|
64
|
+
this.addError('content-taxonomy', 'term_relationships', rel.object_id, 'insert', error instanceof Error ? error.message : 'Unknown error');
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Add error to collection
|
|
70
|
+
*/
|
|
71
|
+
addError(phase, wpTable, wpId, field, message) {
|
|
72
|
+
this.deps.errors.push({
|
|
73
|
+
phase,
|
|
74
|
+
wpTable,
|
|
75
|
+
wpId,
|
|
76
|
+
field,
|
|
77
|
+
message,
|
|
78
|
+
severity: 'error',
|
|
79
|
+
timestamp: new Date().toISOString(),
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Factory function
|
|
85
|
+
*/
|
|
86
|
+
export async function migrateContentTaxonomy(connector, config, idMaps, stats, errors, reportProgress) {
|
|
87
|
+
const mapper = new ContentTaxonomyMapper({ connector, config, idMaps, stats, errors, reportProgress });
|
|
88
|
+
await mapper.migrate();
|
|
89
|
+
}
|
|
90
|
+
//# sourceMappingURL=content-taxonomy.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"content-taxonomy.js","sourceRoot":"","sources":["../../../src/wp-migrate/mappers/content-taxonomy.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAqBH,M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AkB,EAAE,oBAAoB,EAAE,GAAG,CAAC,SAAS,EAAE,QAAQ,EAAE,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,eAAe,CAAC,CAAC;YAC7I,CAAC;QACH,CAAC;IACH,CAAC;IAED;;OAEG;IACK,QAAQ,CACd,KAAqB,EACrB,OAAe,EACf,IAAqB,EACrB,KAAa,EACb,OAAe;QAEf,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC;YACpB,KAAK;YACL,OAAO;YACP,IAAI;YACJ,KAAK;YACL,OAAO;YACP,QAAQ,EAAE,OAAO;YACjB,SAAS,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;SACpC,CAAC,CAAC;IACL,CAAC;CACF;AAED;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,sBAAsB,CAC1C,SAA2B,EAC3B,MAAyB,EACzB,MAAc,EACd,KAAyC,EACzC,MAAwB,EACxB,cAA+E;IAE/E,MAAM,MAAM,GAAG,IAAI,qBAAqB,CAAC,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,cAAc,EAAE,CAAC,CAAC;IACvG,MAAM,MAAM,CAAC,OAAO,EAAE,CAAC;AACzB,CAAC"}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Content Types Mapper
|
|
3
|
+
* Maps WP post_types → OkCMS content_types registry
|
|
4
|
+
*/
|
|
5
|
+
import { WPMySQLConnector } from '../connectors/mysql';
|
|
6
|
+
import { WPMigrationConfig, MigrationPhase, PhaseStats, IDMaps, MigrationError } from '../types';
|
|
7
|
+
export interface ContentTypesMapperDeps {
|
|
8
|
+
connector: WPMySQLConnector;
|
|
9
|
+
config: WPMigrationConfig;
|
|
10
|
+
idMaps: IDMaps;
|
|
11
|
+
stats: Record<MigrationPhase, PhaseStats>;
|
|
12
|
+
errors: MigrationError[];
|
|
13
|
+
reportProgress: (phase: MigrationPhase, current: number, total: number) => void;
|
|
14
|
+
}
|
|
15
|
+
export declare class ContentTypesMapper {
|
|
16
|
+
private deps;
|
|
17
|
+
private contentTypeIdMap;
|
|
18
|
+
constructor(deps: ContentTypesMapperDeps);
|
|
19
|
+
/**
|
|
20
|
+
* Main entry point: migrate content types
|
|
21
|
+
*/
|
|
22
|
+
migrate(): Promise<void>;
|
|
23
|
+
/**
|
|
24
|
+
* Get all WP content types with analysis
|
|
25
|
+
*/
|
|
26
|
+
private getWPContentTypes;
|
|
27
|
+
/**
|
|
28
|
+
* Infer supports from meta keys
|
|
29
|
+
*/
|
|
30
|
+
private inferSupports;
|
|
31
|
+
/**
|
|
32
|
+
* Register core post types (post, page, attachment, revision, nav_menu_item)
|
|
33
|
+
*/
|
|
34
|
+
private registerCorePostTypes;
|
|
35
|
+
/**
|
|
36
|
+
* Register custom post types
|
|
37
|
+
*/
|
|
38
|
+
private registerCustomPostTypes;
|
|
39
|
+
/**
|
|
40
|
+
* Register a single content type
|
|
41
|
+
*/
|
|
42
|
+
private registerContentType;
|
|
43
|
+
/**
|
|
44
|
+
* Build JSON schema from meta keys and supports
|
|
45
|
+
*/
|
|
46
|
+
private buildSchemaFromMetaKeys;
|
|
47
|
+
/**
|
|
48
|
+
* Build default fields array from supports
|
|
49
|
+
*/
|
|
50
|
+
private buildDefaultFields;
|
|
51
|
+
/**
|
|
52
|
+
* Humanize post type (e.g., 'my_custom_post' → 'My Custom Post')
|
|
53
|
+
*/
|
|
54
|
+
private humanizePostType;
|
|
55
|
+
/**
|
|
56
|
+
* Simple pluralization
|
|
57
|
+
*/
|
|
58
|
+
private pluralize;
|
|
59
|
+
/**
|
|
60
|
+
* Add error to collection
|
|
61
|
+
*/
|
|
62
|
+
private addError;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Factory function
|
|
66
|
+
*/
|
|
67
|
+
export declare function migrateContentTypes(connector: WPMySQLConnector, config: WPMigrationConfig, idMaps: IDMaps, stats: Record<MigrationPhase, PhaseStats>, errors: MigrationError[], reportProgress: (phase: MigrationPhase, current: number, total: number) => void): Promise<void>;
|
|
68
|
+
//# sourceMappingURL=content-types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"content-types.d.ts","sourceRoot":"","sources":["../../../src/wp-migrate/mappers/content-types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AACvD,OAAO,EAAE,iBAAiB,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,EAAE,cAAc,EAA6B,MAAM,UAAU,CAAC;AAE5H,MAAM,WAAW,sBAAsB;IACrC,SAAS,EAAE,gBAAgB,CAAC;IAC5B,MAAM,EAAE,iBAAiB,CAAC;IAC1B,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC,cAAc,EAAE,UAAU,CAAC,CAAC;IAC1C,MAAM,EAAE,cAAc,EAAE,CAAC;IACzB,cAAc,EAAE,CAAC,KAAK,EAAE,cAAc,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;CACjF;AAwED,qBAAa,kBAAkB;IAC7B,OAAO,CAAC,IAAI,CAAyB;IACrC,OAAO,CAAC,gBAAgB,CAAkC;gBAE9C,IAAI,EAAE,sBAAsB;IAIxC;;OAEG;IACG,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;IAuB9B;;OAEG;YACW,iBAAiB;IAwD/B;;OAEG;IACH,OAAO,CAAC,aAAa;IAsBrB;;OAEG;YACW,qBAAqB;IA2BnC;;OAEG;YACW,uBAAuB;IAmCrC;;OAEG;YACW,mBAAmB;IA+CjC;;OAEG;IACH,OAAO,CAAC,uBAAuB;IAiC/B;;OAEG;IACH,OAAO,CAAC,kBAAkB;IAa1B;;OAEG;IACH,OAAO,CAAC,gBAAgB;IAOxB;;OAEG;IACH,OAAO,CAAC,SAAS;IAQjB;;OAEG;IACH,OAAO,CAAC,QAAQ;CAiBjB;AAED;;GAEG;AACH,wBAAsB,mBAAmB,CACvC,SAAS,EAAE,gBAAgB,EAC3B,MAAM,EAAE,iBAAiB,EACzB,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,MAAM,CAAC,cAAc,EAAE,UAAU,CAAC,EACzC,MAAM,EAAE,cAAc,EAAE,EACxB,cAAc,EAAE,CAAC,KAAK,EAAE,cAAc,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,KAAK,IAAI,GAC9E,OAAO,CAAC,IAAI,CAAC,CAGf"}
|
|
@@ -0,0 +1,342 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Content Types Mapper
|
|
3
|
+
* Maps WP post_types → OkCMS content_types registry
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Core post types that exist in every WP installation
|
|
7
|
+
*/
|
|
8
|
+
const CORE_POST_TYPES = new Set(['post', 'page', 'attachment', 'revision', 'nav_menu_item']);
|
|
9
|
+
/**
|
|
10
|
+
* Default schema for core post types
|
|
11
|
+
*/
|
|
12
|
+
const CORE_CONTENT_TYPE_SCHEMAS = {
|
|
13
|
+
post: {
|
|
14
|
+
type: 'object',
|
|
15
|
+
properties: {
|
|
16
|
+
title: { type: 'string' },
|
|
17
|
+
slug: { type: 'string' },
|
|
18
|
+
content: { type: 'string', format: 'html' },
|
|
19
|
+
excerpt: { type: 'string' },
|
|
20
|
+
featured_image: { type: 'string', format: 'uuid' },
|
|
21
|
+
seo_title: { type: 'string' },
|
|
22
|
+
seo_description: { type: 'string' },
|
|
23
|
+
status: { type: 'string', enum: ['DRAFT', 'PUBLISHED', 'ARCHIVED', 'TRASHED'] },
|
|
24
|
+
author: { type: 'string', format: 'uuid' },
|
|
25
|
+
categories: { type: 'array', items: { type: 'string', format: 'uuid' } },
|
|
26
|
+
tags: { type: 'array', items: { type: 'string', format: 'uuid' } },
|
|
27
|
+
},
|
|
28
|
+
required: ['title', 'slug'],
|
|
29
|
+
},
|
|
30
|
+
page: {
|
|
31
|
+
type: 'object',
|
|
32
|
+
properties: {
|
|
33
|
+
title: { type: 'string' },
|
|
34
|
+
slug: { type: 'string' },
|
|
35
|
+
content: { type: 'string', format: 'html' },
|
|
36
|
+
excerpt: { type: 'string' },
|
|
37
|
+
featured_image: { type: 'string', format: 'uuid' },
|
|
38
|
+
seo_title: { type: 'string' },
|
|
39
|
+
seo_description: { type: 'string' },
|
|
40
|
+
status: { type: 'string', enum: ['DRAFT', 'PUBLISHED', 'ARCHIVED', 'TRASHED'] },
|
|
41
|
+
author: { type: 'string', format: 'uuid' },
|
|
42
|
+
parent: { type: 'string', format: 'uuid' },
|
|
43
|
+
template: { type: 'string' },
|
|
44
|
+
},
|
|
45
|
+
required: ['title', 'slug'],
|
|
46
|
+
},
|
|
47
|
+
attachment: {
|
|
48
|
+
type: 'object',
|
|
49
|
+
properties: {
|
|
50
|
+
title: { type: 'string' },
|
|
51
|
+
slug: { type: 'string' },
|
|
52
|
+
description: { type: 'string' },
|
|
53
|
+
caption: { type: 'string' },
|
|
54
|
+
alt: { type: 'string' },
|
|
55
|
+
mime_type: { type: 'string' },
|
|
56
|
+
file_size: { type: 'number' },
|
|
57
|
+
metadata: { type: 'object' },
|
|
58
|
+
},
|
|
59
|
+
required: ['title', 'slug'],
|
|
60
|
+
},
|
|
61
|
+
};
|
|
62
|
+
/**
|
|
63
|
+
* Default fields for each core post type
|
|
64
|
+
*/
|
|
65
|
+
const CORE_DEFAULT_FIELDS = {
|
|
66
|
+
post: ['title', 'slug', 'content', 'excerpt', 'featured_image', 'seo_title', 'seo_description', 'status', 'author', 'categories', 'tags'],
|
|
67
|
+
page: ['title', 'slug', 'content', 'excerpt', 'featured_image', 'seo_title', 'seo_description', 'status', 'author', 'parent', 'template'],
|
|
68
|
+
attachment: ['title', 'slug', 'description', 'caption', 'alt', 'mime_type', 'file_size', 'metadata'],
|
|
69
|
+
revision: ['title', 'slug', 'content', 'excerpt', 'featured_image', 'seo_title', 'seo_description', 'status', 'author'],
|
|
70
|
+
nav_menu_item: ['title', 'slug', 'url', 'target', 'classes', 'xfn'],
|
|
71
|
+
};
|
|
72
|
+
export class ContentTypesMapper {
|
|
73
|
+
deps;
|
|
74
|
+
contentTypeIdMap = new Map(); // WP post_type -> OkCMS content_type UUID
|
|
75
|
+
constructor(deps) {
|
|
76
|
+
this.deps = deps;
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Main entry point: migrate content types
|
|
80
|
+
*/
|
|
81
|
+
async migrate() {
|
|
82
|
+
const phase = 'content-types';
|
|
83
|
+
this.deps.stats[phase] = { created: 0, updated: 0, skipped: 0, errors: 0, durationMs: 0 };
|
|
84
|
+
const startTime = Date.now();
|
|
85
|
+
try {
|
|
86
|
+
// 1. Get all distinct post types from WP
|
|
87
|
+
const wpContentTypes = await this.getWPContentTypes();
|
|
88
|
+
// 2. Register core post types first
|
|
89
|
+
await this.registerCorePostTypes();
|
|
90
|
+
// 3. Register custom post types
|
|
91
|
+
await this.registerCustomPostTypes(wpContentTypes);
|
|
92
|
+
this.deps.stats[phase].durationMs = Date.now() - startTime;
|
|
93
|
+
}
|
|
94
|
+
catch (error) {
|
|
95
|
+
this.deps.stats[phase].errors++;
|
|
96
|
+
this.addError(phase, 'content_types', 0, 'migrate', error instanceof Error ? error.message : 'Unknown error');
|
|
97
|
+
throw error;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Get all WP content types with analysis
|
|
102
|
+
*/
|
|
103
|
+
async getWPContentTypes() {
|
|
104
|
+
const { connector } = this.deps;
|
|
105
|
+
const types = new Map();
|
|
106
|
+
// Get all distinct post types with counts
|
|
107
|
+
const rows = await connector.query(`SELECT post_type, COUNT(*) as count
|
|
108
|
+
FROM ${connector.table('posts')}
|
|
109
|
+
GROUP BY post_type
|
|
110
|
+
ORDER BY count DESC`);
|
|
111
|
+
for (const row of rows) {
|
|
112
|
+
const postType = String(row['post_type']);
|
|
113
|
+
const count = Number(row['count']);
|
|
114
|
+
// Get sample post
|
|
115
|
+
const sample = await connector.queryOne(`SELECT * FROM ${connector.table('posts')}
|
|
116
|
+
WHERE post_type = ?
|
|
117
|
+
ORDER BY ID DESC
|
|
118
|
+
LIMIT 1`, [postType]);
|
|
119
|
+
// Get meta keys
|
|
120
|
+
const metaKeys = new Set();
|
|
121
|
+
const metaRows = await connector.query(`SELECT DISTINCT pm.meta_key
|
|
122
|
+
FROM ${connector.table('postmeta')} pm
|
|
123
|
+
JOIN ${connector.table('posts')} p ON pm.post_id = p.ID
|
|
124
|
+
WHERE p.post_type = ?`, [postType]);
|
|
125
|
+
for (const m of metaRows)
|
|
126
|
+
metaKeys.add(String(m['meta_key']));
|
|
127
|
+
// Check hierarchical
|
|
128
|
+
const hasParent = await connector.queryScalar(`SELECT COUNT(*) FROM ${connector.table('posts')}
|
|
129
|
+
WHERE post_type = ? AND post_parent > 0`, [postType]);
|
|
130
|
+
types.set(postType, {
|
|
131
|
+
postType,
|
|
132
|
+
count,
|
|
133
|
+
samplePost: sample ?? undefined,
|
|
134
|
+
metaKeys,
|
|
135
|
+
hasHierarchical: hasParent > 0,
|
|
136
|
+
supports: this.inferSupports(postType, metaKeys),
|
|
137
|
+
});
|
|
138
|
+
}
|
|
139
|
+
return types;
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* Infer supports from meta keys
|
|
143
|
+
*/
|
|
144
|
+
inferSupports(postType, metaKeys) {
|
|
145
|
+
const supports = ['title', 'editor'];
|
|
146
|
+
if (CORE_POST_TYPES.has(postType)) {
|
|
147
|
+
const coreSupports = {
|
|
148
|
+
post: ['title', 'editor', 'author', 'thumbnail', 'excerpt', 'trackbacks', 'custom-fields', 'comments', 'revisions', 'post-formats'],
|
|
149
|
+
page: ['title', 'editor', 'author', 'thumbnail', 'excerpt', 'custom-fields', 'comments', 'revisions', 'page-attributes'],
|
|
150
|
+
attachment: ['title', 'author'],
|
|
151
|
+
revision: ['author'],
|
|
152
|
+
nav_menu_item: ['title'],
|
|
153
|
+
};
|
|
154
|
+
return coreSupports[postType] ?? supports;
|
|
155
|
+
}
|
|
156
|
+
if (metaKeys.has('_thumbnail_id'))
|
|
157
|
+
supports.push('thumbnail');
|
|
158
|
+
if (metaKeys.has('_wp_page_template'))
|
|
159
|
+
supports.push('page-attributes');
|
|
160
|
+
if (metaKeys.has('_edit_lock') || metaKeys.has('_edit_last'))
|
|
161
|
+
supports.push('revisions');
|
|
162
|
+
supports.push('custom-fields');
|
|
163
|
+
return supports;
|
|
164
|
+
}
|
|
165
|
+
/**
|
|
166
|
+
* Register core post types (post, page, attachment, revision, nav_menu_item)
|
|
167
|
+
*/
|
|
168
|
+
async registerCorePostTypes() {
|
|
169
|
+
const { stats } = this.deps;
|
|
170
|
+
const coreTypes = [
|
|
171
|
+
{ slug: 'post', name: 'Post', plural: 'Posts', singular: 'Post', hierarchical: false },
|
|
172
|
+
{ slug: 'page', name: 'Page', plural: 'Pages', singular: 'Page', hierarchical: true },
|
|
173
|
+
{ slug: 'attachment', name: 'Media', plural: 'Media', singular: 'Media', hierarchical: false },
|
|
174
|
+
{ slug: 'revision', name: 'Revision', plural: 'Revisions', singular: 'Revision', hierarchical: false },
|
|
175
|
+
{ slug: 'nav_menu_item', name: 'Menu Item', plural: 'Menu Items', singular: 'Menu Item', hierarchical: false },
|
|
176
|
+
];
|
|
177
|
+
for (const ct of coreTypes) {
|
|
178
|
+
await this.registerContentType({
|
|
179
|
+
slug: ct.slug,
|
|
180
|
+
name: ct.name,
|
|
181
|
+
pluralLabel: ct.plural,
|
|
182
|
+
singularLabel: ct.singular,
|
|
183
|
+
source: 'CORE',
|
|
184
|
+
schema: CORE_CONTENT_TYPE_SCHEMAS[ct.slug] ?? { type: 'object', properties: {} },
|
|
185
|
+
defaultFields: CORE_DEFAULT_FIELDS[ct.slug] ?? ['title', 'slug', 'content'],
|
|
186
|
+
hierarchical: ct.hierarchical,
|
|
187
|
+
});
|
|
188
|
+
stats['content-types'].created++;
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
/**
|
|
192
|
+
* Register custom post types
|
|
193
|
+
*/
|
|
194
|
+
async registerCustomPostTypes(wpContentTypes) {
|
|
195
|
+
const { config, stats, reportProgress } = this.deps;
|
|
196
|
+
const customTypes = Array.from(wpContentTypes.entries())
|
|
197
|
+
.filter(([type]) => !CORE_POST_TYPES.has(type))
|
|
198
|
+
.map(([type, info]) => ({ type, info }));
|
|
199
|
+
let index = 0;
|
|
200
|
+
for (const { type, info } of customTypes) {
|
|
201
|
+
try {
|
|
202
|
+
// Check if user wants to map this to a different slug
|
|
203
|
+
const mappedSlug = config.tenantSlug ? type : type; // Could add mapping config later
|
|
204
|
+
await this.registerContentType({
|
|
205
|
+
slug: mappedSlug,
|
|
206
|
+
name: this.humanizePostType(type),
|
|
207
|
+
pluralLabel: this.pluralize(this.humanizePostType(type)),
|
|
208
|
+
singularLabel: this.humanizePostType(type),
|
|
209
|
+
source: 'ADMIN',
|
|
210
|
+
schema: this.buildSchemaFromMetaKeys(info.metaKeys, info.supports),
|
|
211
|
+
defaultFields: this.buildDefaultFields(info.supports),
|
|
212
|
+
hierarchical: info.hasHierarchical,
|
|
213
|
+
});
|
|
214
|
+
stats['content-types'].created++;
|
|
215
|
+
}
|
|
216
|
+
catch (error) {
|
|
217
|
+
stats['content-types'].errors++;
|
|
218
|
+
this.addError('content-types', 'posts', type, 'register', error instanceof Error ? error.message : 'Unknown error');
|
|
219
|
+
}
|
|
220
|
+
reportProgress('content-types', index + 1, customTypes.length);
|
|
221
|
+
index++;
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
/**
|
|
225
|
+
* Register a single content type
|
|
226
|
+
*/
|
|
227
|
+
async registerContentType(params) {
|
|
228
|
+
const { connector } = this.deps;
|
|
229
|
+
// Check if already exists
|
|
230
|
+
const existing = await connector.queryOne(`SELECT id FROM content_types WHERE slug = ?`, [params.slug]);
|
|
231
|
+
if (existing) {
|
|
232
|
+
this.contentTypeIdMap.set(params.slug, existing.id);
|
|
233
|
+
this.deps.stats['content-types'].updated++;
|
|
234
|
+
return existing.id;
|
|
235
|
+
}
|
|
236
|
+
const id = crypto.randomUUID();
|
|
237
|
+
const sourceId = params.source === 'ADMIN' ? id : null;
|
|
238
|
+
await connector.query(`INSERT INTO content_types (id, name, slug, source, source_id, schema, plural_label, singular_label, default_fields, created_at, updated_at)
|
|
239
|
+
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, NOW(), NOW())`, [
|
|
240
|
+
id,
|
|
241
|
+
params.name,
|
|
242
|
+
params.slug,
|
|
243
|
+
params.source,
|
|
244
|
+
sourceId,
|
|
245
|
+
JSON.stringify(params.schema),
|
|
246
|
+
params.pluralLabel,
|
|
247
|
+
params.singularLabel,
|
|
248
|
+
JSON.stringify(params.defaultFields),
|
|
249
|
+
]);
|
|
250
|
+
this.contentTypeIdMap.set(params.slug, id);
|
|
251
|
+
return id;
|
|
252
|
+
}
|
|
253
|
+
/**
|
|
254
|
+
* Build JSON schema from meta keys and supports
|
|
255
|
+
*/
|
|
256
|
+
buildSchemaFromMetaKeys(metaKeys, supports) {
|
|
257
|
+
const properties = {
|
|
258
|
+
title: { type: 'string' },
|
|
259
|
+
slug: { type: 'string' },
|
|
260
|
+
content: { type: 'string', format: 'html' },
|
|
261
|
+
excerpt: { type: 'string' },
|
|
262
|
+
featured_image: { type: 'string', format: 'uuid' },
|
|
263
|
+
seo_title: { type: 'string' },
|
|
264
|
+
seo_description: { type: 'string' },
|
|
265
|
+
status: { type: 'string', enum: ['DRAFT', 'PUBLISHED', 'ARCHIVED', 'TRASHED'] },
|
|
266
|
+
author: { type: 'string', format: 'uuid' },
|
|
267
|
+
};
|
|
268
|
+
if (supports.includes('page-attributes')) {
|
|
269
|
+
properties['parent'] = { type: 'string', format: 'uuid' };
|
|
270
|
+
properties['template'] = { type: 'string' };
|
|
271
|
+
}
|
|
272
|
+
// Add custom fields from meta keys (exclude WP internal)
|
|
273
|
+
for (const key of metaKeys) {
|
|
274
|
+
if (key.startsWith('_') || key.startsWith('wp_'))
|
|
275
|
+
continue;
|
|
276
|
+
if (['title', 'slug', 'content', 'excerpt', 'featured_image', 'seo_title', 'seo_description', 'status', 'author', 'parent', 'template'].includes(key))
|
|
277
|
+
continue;
|
|
278
|
+
properties[key] = { type: 'string' }; // Default to string, could be enhanced
|
|
279
|
+
}
|
|
280
|
+
return {
|
|
281
|
+
type: 'object',
|
|
282
|
+
properties,
|
|
283
|
+
required: ['title', 'slug'],
|
|
284
|
+
};
|
|
285
|
+
}
|
|
286
|
+
/**
|
|
287
|
+
* Build default fields array from supports
|
|
288
|
+
*/
|
|
289
|
+
buildDefaultFields(supports) {
|
|
290
|
+
const fields = ['title', 'slug', 'content', 'excerpt', 'featured_image', 'seo_title', 'seo_description', 'status', 'author'];
|
|
291
|
+
if (supports.includes('page-attributes')) {
|
|
292
|
+
fields.push('parent', 'template');
|
|
293
|
+
}
|
|
294
|
+
if (supports.includes('categories'))
|
|
295
|
+
fields.push('categories');
|
|
296
|
+
if (supports.includes('tags'))
|
|
297
|
+
fields.push('tags');
|
|
298
|
+
return fields;
|
|
299
|
+
}
|
|
300
|
+
/**
|
|
301
|
+
* Humanize post type (e.g., 'my_custom_post' → 'My Custom Post')
|
|
302
|
+
*/
|
|
303
|
+
humanizePostType(type) {
|
|
304
|
+
return type
|
|
305
|
+
.replace(/_/g, ' ')
|
|
306
|
+
.replace(/-/g, ' ')
|
|
307
|
+
.replace(/\b\w/g, c => c.toUpperCase());
|
|
308
|
+
}
|
|
309
|
+
/**
|
|
310
|
+
* Simple pluralization
|
|
311
|
+
*/
|
|
312
|
+
pluralize(word) {
|
|
313
|
+
if (word.endsWith('y'))
|
|
314
|
+
return word.slice(0, -1) + 'ies';
|
|
315
|
+
if (word.endsWith('s') || word.endsWith('x') || word.endsWith('z') || word.endsWith('ch') || word.endsWith('sh')) {
|
|
316
|
+
return word + 'es';
|
|
317
|
+
}
|
|
318
|
+
return word + 's';
|
|
319
|
+
}
|
|
320
|
+
/**
|
|
321
|
+
* Add error to collection
|
|
322
|
+
*/
|
|
323
|
+
addError(phase, wpTable, wpId, field, message) {
|
|
324
|
+
this.deps.errors.push({
|
|
325
|
+
phase,
|
|
326
|
+
wpTable,
|
|
327
|
+
wpId,
|
|
328
|
+
field,
|
|
329
|
+
message,
|
|
330
|
+
severity: 'error',
|
|
331
|
+
timestamp: new Date().toISOString(),
|
|
332
|
+
});
|
|
333
|
+
}
|
|
334
|
+
}
|
|
335
|
+
/**
|
|
336
|
+
* Factory function
|
|
337
|
+
*/
|
|
338
|
+
export async function migrateContentTypes(connector, config, idMaps, stats, errors, reportProgress) {
|
|
339
|
+
const mapper = new ContentTypesMapper({ connector, config, idMaps, stats, errors, reportProgress });
|
|
340
|
+
await mapper.migrate();
|
|
341
|
+
}
|
|
342
|
+
//# sourceMappingURL=content-types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"content-types.js","sourceRoot":"","sources":["../../../src/wp-migrate/mappers/content-types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAcH;;GAEG;AACH,MAAM,eAAe,GAAG,IAAI,GAAG,CAAC,CAAC,MAAM,EAAE,MAAM,EAAE,YAAY,EAAE,UAAU,EAAE,eAAe,CAAC,CAAC,CAAC;AAE7F;;GAEG;AACH,MAAM,yBAAyB,GAA4C;IACzE,IAAI,EAAE;QACJ,IAAI,EAAE,QAAQ;QACd,UAAU,EAAE;YACV,KAAK,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;YACzB,IAAI,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;YACxB,OAAO,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE;YAC3C,OAAO,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;YAC3B,cAAc,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE;YAClD,SAAS,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,OAAe,EACf,IAAqB,EACrB,KAAa,EACb,OAAe;QAEf,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC;YACpB,KAAK;YACL,OAAO;YACP,IAAI;YACJ,KAAK;YACL,OAAO;YACP,QAAQ,EAAE,OAAO;YACjB,SAAS,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;SACpC,CAAC,CAAC;IACL,CAAC;CACF;AAED;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,mBAAmB,CACvC,SAA2B,EAC3B,MAAyB,EACzB,MAAc,EACd,KAAyC,EACzC,MAAwB,EACxB,cAA+E;IAE/E,MAAM,MAAM,GAAG,IAAI,kBAAkB,CAAC,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,cAAc,EAAE,CAAC,CAAC;IACpG,MAAM,MAAM,CAAC,OAAO,EAAE,CAAC;AACzB,CAAC"}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Content Mapper
|
|
3
|
+
* Maps wp_posts → OkCMS content + content_versions
|
|
4
|
+
*/
|
|
5
|
+
import { WPMySQLConnector } from '../connectors/mysql';
|
|
6
|
+
import { WPMigrationConfig, MigrationPhase, PhaseStats, IDMaps, MigrationError } from '../types';
|
|
7
|
+
import { createDateConfig } from '../transformers/dates';
|
|
8
|
+
export interface ContentMapperDeps {
|
|
9
|
+
connector: WPMySQLConnector;
|
|
10
|
+
config: WPMigrationConfig;
|
|
11
|
+
idMaps: IDMaps;
|
|
12
|
+
stats: Record<MigrationPhase, PhaseStats>;
|
|
13
|
+
errors: MigrationError[];
|
|
14
|
+
reportProgress: (phase: MigrationPhase, current: number, total: number) => void;
|
|
15
|
+
tenantId: string;
|
|
16
|
+
dateConfig: ReturnType<typeof createDateConfig>;
|
|
17
|
+
authorIdMap: Map<number, string>;
|
|
18
|
+
}
|
|
19
|
+
export declare class ContentMapper {
|
|
20
|
+
private deps;
|
|
21
|
+
private slugManager;
|
|
22
|
+
private contentTypeIdMap;
|
|
23
|
+
constructor(deps: ContentMapperDeps);
|
|
24
|
+
/**
|
|
25
|
+
* Main entry point: migrate content
|
|
26
|
+
*/
|
|
27
|
+
migrate(): Promise<void>;
|
|
28
|
+
/**
|
|
29
|
+
* Get post types to migrate (exclude revisions, nav_menu_items, attachments handled separately)
|
|
30
|
+
*/
|
|
31
|
+
private getMigratedPostTypes;
|
|
32
|
+
/**
|
|
33
|
+
* Load content type IDs from database
|
|
34
|
+
*/
|
|
35
|
+
private loadContentTypeIds;
|
|
36
|
+
/**
|
|
37
|
+
* Preload existing slugs for collision detection
|
|
38
|
+
*/
|
|
39
|
+
private preloadSlugs;
|
|
40
|
+
/**
|
|
41
|
+
* Process a batch of posts
|
|
42
|
+
*/
|
|
43
|
+
private processBatch;
|
|
44
|
+
/**
|
|
45
|
+
* Migrate a single post
|
|
46
|
+
*/
|
|
47
|
+
private migratePost;
|
|
48
|
+
/**
|
|
49
|
+
* Get parent ID from post_parent mapping
|
|
50
|
+
*/
|
|
51
|
+
private getParentId;
|
|
52
|
+
/**
|
|
53
|
+
* Migrate revisions for a post
|
|
54
|
+
*/
|
|
55
|
+
private migrateRevisions;
|
|
56
|
+
/**
|
|
57
|
+
* Add error to collection
|
|
58
|
+
*/
|
|
59
|
+
private addError;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Factory function
|
|
63
|
+
*/
|
|
64
|
+
export declare function migrateContent(connector: WPMySQLConnector, config: WPMigrationConfig, idMaps: IDMaps, stats: Record<MigrationPhase, PhaseStats>, errors: MigrationError[], reportProgress: (phase: MigrationPhase, current: number, total: number) => void, tenantId: string, authorIdMap: Map<number, string>): Promise<void>;
|
|
65
|
+
//# sourceMappingURL=content.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"content.d.ts","sourceRoot":"","sources":["../../../src/wp-migrate/mappers/content.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAE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