@prenta/import 0.5.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/CHANGELOG.md +686 -0
- package/LICENSE +21 -0
- package/README.md +24 -0
- package/dist/adapter.d.ts +47 -0
- package/dist/adapter.d.ts.map +1 -0
- package/dist/adapter.js +60 -0
- package/dist/adapter.js.map +1 -0
- package/dist/adapters/contentful/asset.d.ts +47 -0
- package/dist/adapters/contentful/asset.d.ts.map +1 -0
- package/dist/adapters/contentful/asset.js +88 -0
- package/dist/adapters/contentful/asset.js.map +1 -0
- package/dist/adapters/contentful/index.d.ts +24 -0
- package/dist/adapters/contentful/index.d.ts.map +1 -0
- package/dist/adapters/contentful/index.js +242 -0
- package/dist/adapters/contentful/index.js.map +1 -0
- package/dist/adapters/contentful/locale.d.ts +66 -0
- package/dist/adapters/contentful/locale.d.ts.map +1 -0
- package/dist/adapters/contentful/locale.js +125 -0
- package/dist/adapters/contentful/locale.js.map +1 -0
- package/dist/adapters/contentful/map.d.ts +69 -0
- package/dist/adapters/contentful/map.d.ts.map +1 -0
- package/dist/adapters/contentful/map.js +174 -0
- package/dist/adapters/contentful/map.js.map +1 -0
- package/dist/adapters/contentful/rich-text.d.ts +52 -0
- package/dist/adapters/contentful/rich-text.d.ts.map +1 -0
- package/dist/adapters/contentful/rich-text.js +95 -0
- package/dist/adapters/contentful/rich-text.js.map +1 -0
- package/dist/adapters/contentful/types.d.ts +189 -0
- package/dist/adapters/contentful/types.d.ts.map +1 -0
- package/dist/adapters/contentful/types.js +26 -0
- package/dist/adapters/contentful/types.js.map +1 -0
- package/dist/adapters/identity.d.ts +27 -0
- package/dist/adapters/identity.d.ts.map +1 -0
- package/dist/adapters/identity.js +116 -0
- package/dist/adapters/identity.js.map +1 -0
- package/dist/adapters/sanity/asset.d.ts +45 -0
- package/dist/adapters/sanity/asset.d.ts.map +1 -0
- package/dist/adapters/sanity/asset.js +79 -0
- package/dist/adapters/sanity/asset.js.map +1 -0
- package/dist/adapters/sanity/index.d.ts +19 -0
- package/dist/adapters/sanity/index.d.ts.map +1 -0
- package/dist/adapters/sanity/index.js +165 -0
- package/dist/adapters/sanity/index.js.map +1 -0
- package/dist/adapters/sanity/map.d.ts +75 -0
- package/dist/adapters/sanity/map.d.ts.map +1 -0
- package/dist/adapters/sanity/map.js +245 -0
- package/dist/adapters/sanity/map.js.map +1 -0
- package/dist/adapters/sanity/parse.d.ts +64 -0
- package/dist/adapters/sanity/parse.d.ts.map +1 -0
- package/dist/adapters/sanity/parse.js +71 -0
- package/dist/adapters/sanity/parse.js.map +1 -0
- package/dist/adapters/sanity/portable-text.d.ts +64 -0
- package/dist/adapters/sanity/portable-text.d.ts.map +1 -0
- package/dist/adapters/sanity/portable-text.js +112 -0
- package/dist/adapters/sanity/portable-text.js.map +1 -0
- package/dist/adapters/sanity/types.d.ts +182 -0
- package/dist/adapters/sanity/types.d.ts.map +1 -0
- package/dist/adapters/sanity/types.js +17 -0
- package/dist/adapters/sanity/types.js.map +1 -0
- package/dist/adapters/strapi/asset.d.ts +56 -0
- package/dist/adapters/strapi/asset.d.ts.map +1 -0
- package/dist/adapters/strapi/asset.js +94 -0
- package/dist/adapters/strapi/asset.js.map +1 -0
- package/dist/adapters/strapi/index.d.ts +20 -0
- package/dist/adapters/strapi/index.d.ts.map +1 -0
- package/dist/adapters/strapi/index.js +205 -0
- package/dist/adapters/strapi/index.js.map +1 -0
- package/dist/adapters/strapi/links.d.ts +79 -0
- package/dist/adapters/strapi/links.d.ts.map +1 -0
- package/dist/adapters/strapi/links.js +98 -0
- package/dist/adapters/strapi/links.js.map +1 -0
- package/dist/adapters/strapi/loader.d.ts +68 -0
- package/dist/adapters/strapi/loader.d.ts.map +1 -0
- package/dist/adapters/strapi/loader.js +177 -0
- package/dist/adapters/strapi/loader.js.map +1 -0
- package/dist/adapters/strapi/map.d.ts +53 -0
- package/dist/adapters/strapi/map.d.ts.map +1 -0
- package/dist/adapters/strapi/map.js +193 -0
- package/dist/adapters/strapi/map.js.map +1 -0
- package/dist/adapters/strapi/types.d.ts +174 -0
- package/dist/adapters/strapi/types.d.ts.map +1 -0
- package/dist/adapters/strapi/types.js +31 -0
- package/dist/adapters/strapi/types.js.map +1 -0
- package/dist/adapters/strapi/uid.d.ts +44 -0
- package/dist/adapters/strapi/uid.d.ts.map +1 -0
- package/dist/adapters/strapi/uid.js +58 -0
- package/dist/adapters/strapi/uid.js.map +1 -0
- package/dist/adapters/wordpress/attachments.d.ts +37 -0
- package/dist/adapters/wordpress/attachments.d.ts.map +1 -0
- package/dist/adapters/wordpress/attachments.js +134 -0
- package/dist/adapters/wordpress/attachments.js.map +1 -0
- package/dist/adapters/wordpress/authors.d.ts +24 -0
- package/dist/adapters/wordpress/authors.d.ts.map +1 -0
- package/dist/adapters/wordpress/authors.js +40 -0
- package/dist/adapters/wordpress/authors.js.map +1 -0
- package/dist/adapters/wordpress/index.d.ts +19 -0
- package/dist/adapters/wordpress/index.d.ts.map +1 -0
- package/dist/adapters/wordpress/index.js +281 -0
- package/dist/adapters/wordpress/index.js.map +1 -0
- package/dist/adapters/wordpress/map.d.ts +61 -0
- package/dist/adapters/wordpress/map.d.ts.map +1 -0
- package/dist/adapters/wordpress/map.js +265 -0
- package/dist/adapters/wordpress/map.js.map +1 -0
- package/dist/adapters/wordpress/parse.d.ts +50 -0
- package/dist/adapters/wordpress/parse.d.ts.map +1 -0
- package/dist/adapters/wordpress/parse.js +141 -0
- package/dist/adapters/wordpress/parse.js.map +1 -0
- package/dist/adapters/wordpress/terms.d.ts +46 -0
- package/dist/adapters/wordpress/terms.d.ts.map +1 -0
- package/dist/adapters/wordpress/terms.js +87 -0
- package/dist/adapters/wordpress/terms.js.map +1 -0
- package/dist/adapters/wordpress/types.d.ts +201 -0
- package/dist/adapters/wordpress/types.d.ts.map +1 -0
- package/dist/adapters/wordpress/types.js +24 -0
- package/dist/adapters/wordpress/types.js.map +1 -0
- package/dist/cli.d.ts +16 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +266 -0
- package/dist/cli.js.map +1 -0
- package/dist/formatter.d.ts +12 -0
- package/dist/formatter.d.ts.map +1 -0
- package/dist/formatter.js +48 -0
- package/dist/formatter.js.map +1 -0
- package/dist/index.d.ts +31 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +25 -0
- package/dist/index.js.map +1 -0
- package/dist/migrate.d.ts +151 -0
- package/dist/migrate.d.ts.map +1 -0
- package/dist/migrate.js +255 -0
- package/dist/migrate.js.map +1 -0
- package/dist/registry.d.ts +39 -0
- package/dist/registry.d.ts.map +1 -0
- package/dist/registry.js +62 -0
- package/dist/registry.js.map +1 -0
- package/dist/runner.d.ts +33 -0
- package/dist/runner.d.ts.map +1 -0
- package/dist/runner.js +61 -0
- package/dist/runner.js.map +1 -0
- package/dist/types.d.ts +173 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +17 -0
- package/dist/types.js.map +1 -0
- package/package.json +59 -0
|
@@ -0,0 +1,265 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Map a single WXR `<item>` into an Prenta-shaped payload.
|
|
3
|
+
*
|
|
4
|
+
* The mapper does five things in order:
|
|
5
|
+
*
|
|
6
|
+
* 1. Resolve the target collection from `wp:post_type` via
|
|
7
|
+
* `typeMap` or pass-through.
|
|
8
|
+
* 2. Pull HTML content (`content:encoded`) and excerpt
|
|
9
|
+
* (`excerpt:encoded`) onto `data.content` / `data.excerpt`.
|
|
10
|
+
* HTML conversion is intentionally out of scope.
|
|
11
|
+
* 3. Resolve the byline — `dc:creator` is a login string. If the
|
|
12
|
+
* authors index has it, emit
|
|
13
|
+
* `{ collection, sourceId, displayName }`; otherwise warn.
|
|
14
|
+
* 4. Resolve per-item `<category>` references into
|
|
15
|
+
* `data.categories` / `data.tags` / `data[<taxonomy>]`
|
|
16
|
+
* arrays of `{ collection, sourceId }` objects. Missing
|
|
17
|
+
* references warn.
|
|
18
|
+
* 5. Fold `<wp:postmeta>` rows in per the configured strategy.
|
|
19
|
+
* Recognize `_thumbnail_id` and resolve it to `data.featuredImage`
|
|
20
|
+
* against the attachment map.
|
|
21
|
+
*/
|
|
22
|
+
import { intOf, textOf } from './parse.js';
|
|
23
|
+
const INTERNAL_META_PREFIX = '_';
|
|
24
|
+
export function resolveCollection(postType, config) {
|
|
25
|
+
if (!config.typeMap)
|
|
26
|
+
return { collection: postType, warned: false };
|
|
27
|
+
const mapped = config.typeMap[postType];
|
|
28
|
+
if (mapped)
|
|
29
|
+
return { collection: mapped, warned: false };
|
|
30
|
+
return { collection: postType, warned: true };
|
|
31
|
+
}
|
|
32
|
+
export function mapItem(item, context, config) {
|
|
33
|
+
const postType = textOf(item['wp:post_type']);
|
|
34
|
+
if (!postType)
|
|
35
|
+
return null;
|
|
36
|
+
const postId = intOf(item['wp:post_id']);
|
|
37
|
+
if (postId === undefined)
|
|
38
|
+
return null;
|
|
39
|
+
const sourceId = String(postId);
|
|
40
|
+
const sourceType = postType;
|
|
41
|
+
const { collection, warned: usedFallback } = resolveCollection(sourceType, config);
|
|
42
|
+
const warnings = [];
|
|
43
|
+
const unresolved = [];
|
|
44
|
+
const source = { type: sourceType, id: sourceId };
|
|
45
|
+
const data = {};
|
|
46
|
+
if (usedFallback) {
|
|
47
|
+
warnings.push({
|
|
48
|
+
source,
|
|
49
|
+
code: 'unmapped-type',
|
|
50
|
+
message: `No typeMap entry for post type '${postType}' — using as-is as the collection slug.`,
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
const title = textOf(item.title);
|
|
54
|
+
if (title)
|
|
55
|
+
data.title = title;
|
|
56
|
+
const content = textOf(item['content:encoded']);
|
|
57
|
+
if (content)
|
|
58
|
+
data.content = content;
|
|
59
|
+
const excerpt = textOf(item['excerpt:encoded']);
|
|
60
|
+
if (excerpt)
|
|
61
|
+
data.excerpt = excerpt;
|
|
62
|
+
const slug = textOf(item['wp:post_name']);
|
|
63
|
+
const description = textOf(item.description);
|
|
64
|
+
if (description)
|
|
65
|
+
data.description = description;
|
|
66
|
+
const link = textOf(item.link);
|
|
67
|
+
if (link)
|
|
68
|
+
data.link = link;
|
|
69
|
+
const pubDate = textOf(item.pubDate) ?? textOf(item['wp:post_date_gmt']);
|
|
70
|
+
if (pubDate)
|
|
71
|
+
data.publishedAt = pubDate;
|
|
72
|
+
// Optionally preserve the sys-ish fields operators sometimes
|
|
73
|
+
// want to keep — post id, modified date, comment status, etc.
|
|
74
|
+
if (config.includeSystemFields) {
|
|
75
|
+
data.wpPostId = postId;
|
|
76
|
+
if (item['wp:post_modified_gmt'])
|
|
77
|
+
data.wpPostModified = textOf(item['wp:post_modified_gmt']);
|
|
78
|
+
if (item['wp:comment_status'])
|
|
79
|
+
data.wpCommentStatus = textOf(item['wp:comment_status']);
|
|
80
|
+
if (item['wp:ping_status'])
|
|
81
|
+
data.wpPingStatus = textOf(item['wp:ping_status']);
|
|
82
|
+
if (item['wp:status'])
|
|
83
|
+
data.wpStatus = textOf(item['wp:status']);
|
|
84
|
+
if (item['wp:menu_order'])
|
|
85
|
+
data.wpMenuOrder = intOf(item['wp:menu_order']);
|
|
86
|
+
if (item['wp:post_parent']) {
|
|
87
|
+
const parent = intOf(item['wp:post_parent']);
|
|
88
|
+
if (parent !== undefined && parent !== 0)
|
|
89
|
+
data.wpPostParent = parent;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
// Byline.
|
|
93
|
+
const creator = textOf(item['dc:creator']);
|
|
94
|
+
if (creator) {
|
|
95
|
+
const authorEntry = context.authors.get(creator);
|
|
96
|
+
data.author = resolveAuthor(creator, authorEntry, context, warnings, source);
|
|
97
|
+
}
|
|
98
|
+
// Terms.
|
|
99
|
+
if (Array.isArray(item.category) && item.category.length > 0) {
|
|
100
|
+
const grouped = groupByTaxonomy(item.category);
|
|
101
|
+
for (const [taxonomy, refs] of grouped) {
|
|
102
|
+
const field = fieldFromTaxonomy(taxonomy);
|
|
103
|
+
const resolvedRefs = resolveTermRefs(taxonomy, refs, context, warnings, source);
|
|
104
|
+
if (resolvedRefs.length > 0)
|
|
105
|
+
data[field] = resolvedRefs;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
// Post meta.
|
|
109
|
+
const strategy = config.postMetaStrategy ?? 'object';
|
|
110
|
+
const includeInternal = config.includeInternalMeta === true;
|
|
111
|
+
const metas = item['wp:postmeta'] ?? [];
|
|
112
|
+
const bucket = {};
|
|
113
|
+
let featuredImage;
|
|
114
|
+
for (const meta of metas) {
|
|
115
|
+
const key = textOf(meta['wp:meta_key']);
|
|
116
|
+
if (!key)
|
|
117
|
+
continue;
|
|
118
|
+
const value = decodeMetaValue(meta);
|
|
119
|
+
if (key === '_thumbnail_id') {
|
|
120
|
+
const refId = intOf(value);
|
|
121
|
+
if (refId !== undefined) {
|
|
122
|
+
const att = context.attachments.get(refId);
|
|
123
|
+
if (att && att.url) {
|
|
124
|
+
featuredImage = {
|
|
125
|
+
url: att.url,
|
|
126
|
+
sourceId: String(att.id),
|
|
127
|
+
...(att.mime ? { mime: att.mime } : {}),
|
|
128
|
+
...(att.width !== undefined ? { width: att.width } : {}),
|
|
129
|
+
...(att.height !== undefined ? { height: att.height } : {}),
|
|
130
|
+
...(att.title ? { title: att.title } : {}),
|
|
131
|
+
};
|
|
132
|
+
}
|
|
133
|
+
else {
|
|
134
|
+
warnings.push({
|
|
135
|
+
source,
|
|
136
|
+
code: 'unresolved-attachment-ref',
|
|
137
|
+
message: `_thumbnail_id ${refId} does not point at an attachment in this export.`,
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
if (strategy === 'none')
|
|
143
|
+
continue;
|
|
144
|
+
if (!includeInternal && key.startsWith(INTERNAL_META_PREFIX))
|
|
145
|
+
continue;
|
|
146
|
+
bucket[key] = value;
|
|
147
|
+
}
|
|
148
|
+
if (featuredImage)
|
|
149
|
+
data.featuredImage = featuredImage;
|
|
150
|
+
if (strategy === 'object') {
|
|
151
|
+
if (Object.keys(bucket).length > 0)
|
|
152
|
+
data.meta = bucket;
|
|
153
|
+
}
|
|
154
|
+
else if (strategy === 'fields') {
|
|
155
|
+
for (const [k, v] of Object.entries(bucket)) {
|
|
156
|
+
if (!Object.prototype.hasOwnProperty.call(data, k))
|
|
157
|
+
data[k] = v;
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
return {
|
|
161
|
+
collection,
|
|
162
|
+
...(slug ? { slug } : {}),
|
|
163
|
+
data,
|
|
164
|
+
sourceId,
|
|
165
|
+
sourceType,
|
|
166
|
+
warnings,
|
|
167
|
+
unresolved,
|
|
168
|
+
};
|
|
169
|
+
}
|
|
170
|
+
function resolveAuthor(creator, entry, context, warnings, source) {
|
|
171
|
+
if (!entry) {
|
|
172
|
+
warnings.push({
|
|
173
|
+
source,
|
|
174
|
+
code: 'unresolved-author-ref',
|
|
175
|
+
message: `dc:creator '${creator}' is not declared in <wp:author>; falling back to login string.`,
|
|
176
|
+
});
|
|
177
|
+
return { sourceId: creator, login: creator };
|
|
178
|
+
}
|
|
179
|
+
return {
|
|
180
|
+
collection: context.authorsCollection,
|
|
181
|
+
sourceId: entry.login,
|
|
182
|
+
...(entry.displayName ? { displayName: entry.displayName } : {}),
|
|
183
|
+
};
|
|
184
|
+
}
|
|
185
|
+
function groupByTaxonomy(refs) {
|
|
186
|
+
const out = new Map();
|
|
187
|
+
for (const ref of refs) {
|
|
188
|
+
const taxonomy = ref['@_domain'] ?? 'category';
|
|
189
|
+
let bucket = out.get(taxonomy);
|
|
190
|
+
if (!bucket) {
|
|
191
|
+
bucket = [];
|
|
192
|
+
out.set(taxonomy, bucket);
|
|
193
|
+
}
|
|
194
|
+
bucket.push(ref);
|
|
195
|
+
}
|
|
196
|
+
return out;
|
|
197
|
+
}
|
|
198
|
+
function fieldFromTaxonomy(taxonomy) {
|
|
199
|
+
if (taxonomy === 'category')
|
|
200
|
+
return 'categories';
|
|
201
|
+
if (taxonomy === 'post_tag')
|
|
202
|
+
return 'tags';
|
|
203
|
+
return taxonomy;
|
|
204
|
+
}
|
|
205
|
+
function resolveTermRefs(taxonomy, refs, context, warnings, source) {
|
|
206
|
+
const collection = taxonomy === 'category'
|
|
207
|
+
? context.categoriesCollection
|
|
208
|
+
: taxonomy === 'post_tag'
|
|
209
|
+
? context.tagsCollection
|
|
210
|
+
: taxonomy;
|
|
211
|
+
const bucket = taxonomy === 'category'
|
|
212
|
+
? context.terms.categories
|
|
213
|
+
: taxonomy === 'post_tag'
|
|
214
|
+
? context.terms.tags
|
|
215
|
+
: context.terms.customByTaxonomy.get(taxonomy);
|
|
216
|
+
const out = [];
|
|
217
|
+
for (const ref of refs) {
|
|
218
|
+
const slug = ref['@_nicename'];
|
|
219
|
+
if (!slug)
|
|
220
|
+
continue;
|
|
221
|
+
if (bucket && bucket.has(slug)) {
|
|
222
|
+
out.push({ collection, sourceId: slug });
|
|
223
|
+
}
|
|
224
|
+
else {
|
|
225
|
+
warnings.push({
|
|
226
|
+
source,
|
|
227
|
+
code: 'unresolved-term-ref',
|
|
228
|
+
message: `Per-item term '${slug}' in taxonomy '${taxonomy}' is not declared at the channel level; including the slug ref anyway.`,
|
|
229
|
+
});
|
|
230
|
+
out.push({ collection, sourceId: slug });
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
return out;
|
|
234
|
+
}
|
|
235
|
+
function decodeMetaValue(meta) {
|
|
236
|
+
const v = meta['wp:meta_value'];
|
|
237
|
+
if (typeof v === 'string')
|
|
238
|
+
return v;
|
|
239
|
+
if (typeof v === 'number' || typeof v === 'boolean')
|
|
240
|
+
return v;
|
|
241
|
+
if (v === null)
|
|
242
|
+
return null;
|
|
243
|
+
return textOf(v);
|
|
244
|
+
}
|
|
245
|
+
/**
|
|
246
|
+
* Build an Prenta document for an attachment, used when
|
|
247
|
+
* `importAttachments: true`. Re-exposed so tests can exercise
|
|
248
|
+
* attachment-doc emission in isolation.
|
|
249
|
+
*/
|
|
250
|
+
export function attachmentToDocument(attachment, collection) {
|
|
251
|
+
return {
|
|
252
|
+
collection,
|
|
253
|
+
sourceId: String(attachment.id),
|
|
254
|
+
sourceType: 'attachment',
|
|
255
|
+
data: {
|
|
256
|
+
url: attachment.url,
|
|
257
|
+
...(attachment.mime ? { mime: attachment.mime } : {}),
|
|
258
|
+
...(attachment.width !== undefined ? { width: attachment.width } : {}),
|
|
259
|
+
...(attachment.height !== undefined ? { height: attachment.height } : {}),
|
|
260
|
+
...(attachment.title ? { title: attachment.title } : {}),
|
|
261
|
+
...(attachment.parentId !== undefined ? { parentId: attachment.parentId } : {}),
|
|
262
|
+
},
|
|
263
|
+
};
|
|
264
|
+
}
|
|
265
|
+
//# sourceMappingURL=map.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"map.js","sourceRoot":"","sources":["../../../src/adapters/wordpress/map.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAKH,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,YAAY,CAAA;AAuB1C,MAAM,oBAAoB,GAAG,GAAG,CAAA;AAEhC,MAAM,UAAU,iBAAiB,CAC/B,QAAgB,EAChB,MAA8B;IAE9B,IAAI,CAAC,MAAM,CAAC,OAAO;QAAE,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,CAAA;IACnE,MAAM,MAAM,GAAG,MAAM,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAA;IACvC,IAAI,MAAM;QAAE,OAAO,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,CAAA;IACxD,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,CAAA;AAC/C,CAAC;AAED,MAAM,UAAU,OAAO,CACrB,IAAa,EACb,OAAuB,EACvB,MAA8B;IAE9B,MAAM,QAAQ,GAAG,MAAM,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC,CAAA;IAC7C,IAAI,CAAC,QAAQ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way WXR wants — preserve CDATA
|
|
7
|
+
* contents as text, parse `wp:*` attribute names verbatim,
|
|
8
|
+
* force-array known repeating elements so downstream code
|
|
9
|
+
* doesn't have to test `Array.isArray` on every access.
|
|
10
|
+
* 2. Locates the `<channel>` block inside the parsed document
|
|
11
|
+
* and returns it as a typed `WxrChannel`, surfacing
|
|
12
|
+
* `unsupported-format` if the document doesn't look like WXR.
|
|
13
|
+
*
|
|
14
|
+
* The parser is configured to be **lenient about HTML inside
|
|
15
|
+
* post content** — CDATA-wrapped HTML comes through as a string,
|
|
16
|
+
* not parsed as nested XML.
|
|
17
|
+
*/
|
|
18
|
+
import type { WxrChannel } from './types.js';
|
|
19
|
+
export interface ParseOk {
|
|
20
|
+
ok: true;
|
|
21
|
+
channel: WxrChannel;
|
|
22
|
+
}
|
|
23
|
+
export interface ParseError {
|
|
24
|
+
ok: false;
|
|
25
|
+
code: 'parse-error' | 'unsupported-format';
|
|
26
|
+
reason: string;
|
|
27
|
+
}
|
|
28
|
+
export type ParseResult = ParseOk | ParseError;
|
|
29
|
+
/**
|
|
30
|
+
* Parse a WXR document. Returns either the channel block (on
|
|
31
|
+
* success) or a structured error code the adapter can lift into
|
|
32
|
+
* an `UnresolvedField`. Never throws.
|
|
33
|
+
*/
|
|
34
|
+
export declare function parseWxr(xml: string): ParseResult;
|
|
35
|
+
/**
|
|
36
|
+
* Coerce a value that might be a string, number, or `{ '#text': ... }`
|
|
37
|
+
* object back into a plain string. WXR fields show up in different
|
|
38
|
+
* shapes depending on whether the XML had attributes — e.g.
|
|
39
|
+
* `<guid isPermaLink="false">https://…</guid>` parses as
|
|
40
|
+
* `{ '#text': 'https://…', '@_isPermaLink': 'false' }`.
|
|
41
|
+
*/
|
|
42
|
+
export declare function textOf(value: unknown): string | undefined;
|
|
43
|
+
/**
|
|
44
|
+
* Coerce a possibly-stringified integer into a number. Returns
|
|
45
|
+
* `undefined` for non-integers / non-strings. Used for things
|
|
46
|
+
* like `wp:post_id` and `wp:term_id` which can be either
|
|
47
|
+
* depending on parser config.
|
|
48
|
+
*/
|
|
49
|
+
export declare function intOf(value: unknown): number | undefined;
|
|
50
|
+
//# sourceMappingURL=parse.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parse.d.ts","sourceRoot":"","sources":["../../../src/adapters/wordpress/parse.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAIH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAA;AAiD5C,MAAM,WAAW,OAAO;IACtB,EAAE,EAAE,IAAI,CAAA;IACR,OAAO,EAAE,UAAU,CAAA;CACpB;AAED,MAAM,WAAW,UAAU;IACzB,EAAE,EAAE,KAAK,CAAA;IACT,IAAI,EAAE,aAAa,GAAG,oBAAoB,CAAA;IAC1C,MAAM,EAAE,MAAM,CAAA;CACf;AAED,MAAM,MAAM,WAAW,GAAG,OAAO,GAAG,UAAU,CAAA;AAE9C;;;;GAIG;AACH,wBAAgB,QAAQ,CAAC,GAAG,EAAE,MAAM,GAAG,WAAW,CAuCjD;AAED;;;;;;GAMG;AACH,wBAAgB,MAAM,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,GAAG,SAAS,CASzD;AAED;;;;;GAKG;AACH,wBAAgB,KAAK,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,GAAG,SAAS,CAIxD"}
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WXR XML parser wrapper.
|
|
3
|
+
*
|
|
4
|
+
* Thin layer over `fast-xml-parser` that does two things:
|
|
5
|
+
*
|
|
6
|
+
* 1. Configures the parser the way WXR wants — preserve CDATA
|
|
7
|
+
* contents as text, parse `wp:*` attribute names verbatim,
|
|
8
|
+
* force-array known repeating elements so downstream code
|
|
9
|
+
* doesn't have to test `Array.isArray` on every access.
|
|
10
|
+
* 2. Locates the `<channel>` block inside the parsed document
|
|
11
|
+
* and returns it as a typed `WxrChannel`, surfacing
|
|
12
|
+
* `unsupported-format` if the document doesn't look like WXR.
|
|
13
|
+
*
|
|
14
|
+
* The parser is configured to be **lenient about HTML inside
|
|
15
|
+
* post content** — CDATA-wrapped HTML comes through as a string,
|
|
16
|
+
* not parsed as nested XML.
|
|
17
|
+
*/
|
|
18
|
+
import { XMLParser } from 'fast-xml-parser';
|
|
19
|
+
/**
|
|
20
|
+
* Names of the WXR elements we know can appear more than once
|
|
21
|
+
* inside the channel. fast-xml-parser collapses single-element
|
|
22
|
+
* arrays to bare values by default; forcing arrays here means
|
|
23
|
+
* downstream code can iterate without defensive `?? []`.
|
|
24
|
+
*/
|
|
25
|
+
const ARRAY_PATHS = new Set([
|
|
26
|
+
'rss.channel.item',
|
|
27
|
+
'rss.channel.wp:author',
|
|
28
|
+
'rss.channel.wp:category',
|
|
29
|
+
'rss.channel.wp:tag',
|
|
30
|
+
'rss.channel.wp:term',
|
|
31
|
+
'rss.channel.item.category',
|
|
32
|
+
'rss.channel.item.wp:postmeta',
|
|
33
|
+
]);
|
|
34
|
+
const parser = new XMLParser({
|
|
35
|
+
ignoreAttributes: false,
|
|
36
|
+
attributeNamePrefix: '@_',
|
|
37
|
+
parseAttributeValue: false,
|
|
38
|
+
parseTagValue: false,
|
|
39
|
+
// `trimValues: true` strips leading/trailing whitespace from every
|
|
40
|
+
// text node, *including CDATA*. We accept that trade for WXR
|
|
41
|
+
// because:
|
|
42
|
+
// - Short fields (`wp:post_name`, `wp:status`, `wp:meta_key`)
|
|
43
|
+
// are routinely emitted with leading newlines after the
|
|
44
|
+
// CDATA opener; trimming is what we want there.
|
|
45
|
+
// - HTML in `content:encoded` / `excerpt:encoded` is passed
|
|
46
|
+
// verbatim downstream, where leading/trailing whitespace is
|
|
47
|
+
// not semantically meaningful (browsers collapse it).
|
|
48
|
+
// - Embedded `<pre>` blocks live *inside* the HTML, so they're
|
|
49
|
+
// not at the leading/trailing position the trimmer touches.
|
|
50
|
+
// If a downstream consumer ever needs whitespace-fidelity on
|
|
51
|
+
// `content:encoded`, the right move is to read that field via a
|
|
52
|
+
// CDATA-preserving custom hook rather than flipping trimValues
|
|
53
|
+
// off globally (which would corrupt every short text field).
|
|
54
|
+
trimValues: true,
|
|
55
|
+
cdataPropName: false, // emit CDATA inline as the element's text content
|
|
56
|
+
processEntities: true,
|
|
57
|
+
htmlEntities: true,
|
|
58
|
+
// `jPath: true` makes the isArray callback receive jPath as a plain
|
|
59
|
+
// string (the backward-compatible shape). Without it, v5 passes a
|
|
60
|
+
// `MatcherView` object that we'd have to .toString() everywhere.
|
|
61
|
+
jPath: true,
|
|
62
|
+
isArray: (_name, jpath) => (typeof jpath === 'string' ? ARRAY_PATHS.has(jpath) : false),
|
|
63
|
+
});
|
|
64
|
+
/**
|
|
65
|
+
* Parse a WXR document. Returns either the channel block (on
|
|
66
|
+
* success) or a structured error code the adapter can lift into
|
|
67
|
+
* an `UnresolvedField`. Never throws.
|
|
68
|
+
*/
|
|
69
|
+
export function parseWxr(xml) {
|
|
70
|
+
let raw;
|
|
71
|
+
try {
|
|
72
|
+
raw = parser.parse(xml);
|
|
73
|
+
}
|
|
74
|
+
catch (err) {
|
|
75
|
+
return {
|
|
76
|
+
ok: false,
|
|
77
|
+
code: 'parse-error',
|
|
78
|
+
reason: `XML failed to parse: ${err.message}`,
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
if (raw === null || typeof raw !== 'object' || Array.isArray(raw)) {
|
|
82
|
+
return {
|
|
83
|
+
ok: false,
|
|
84
|
+
code: 'unsupported-format',
|
|
85
|
+
reason: 'XML root is not an object.',
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
const rss = raw.rss;
|
|
89
|
+
if (rss === null || typeof rss !== 'object' || Array.isArray(rss)) {
|
|
90
|
+
return {
|
|
91
|
+
ok: false,
|
|
92
|
+
code: 'unsupported-format',
|
|
93
|
+
reason: 'XML root must be <rss>. Is this really a WordPress WXR export?',
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
const channel = rss.channel;
|
|
97
|
+
if (channel === null || typeof channel !== 'object' || Array.isArray(channel)) {
|
|
98
|
+
return {
|
|
99
|
+
ok: false,
|
|
100
|
+
code: 'unsupported-format',
|
|
101
|
+
reason: 'WXR <rss> is missing a <channel> element.',
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
return { ok: true, channel: channel };
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Coerce a value that might be a string, number, or `{ '#text': ... }`
|
|
108
|
+
* object back into a plain string. WXR fields show up in different
|
|
109
|
+
* shapes depending on whether the XML had attributes — e.g.
|
|
110
|
+
* `<guid isPermaLink="false">https://…</guid>` parses as
|
|
111
|
+
* `{ '#text': 'https://…', '@_isPermaLink': 'false' }`.
|
|
112
|
+
*/
|
|
113
|
+
export function textOf(value) {
|
|
114
|
+
if (typeof value === 'string')
|
|
115
|
+
return value;
|
|
116
|
+
if (typeof value === 'number')
|
|
117
|
+
return String(value);
|
|
118
|
+
if (value === null || typeof value !== 'object' || Array.isArray(value))
|
|
119
|
+
return undefined;
|
|
120
|
+
const v = value;
|
|
121
|
+
const t = v['#text'];
|
|
122
|
+
if (typeof t === 'string')
|
|
123
|
+
return t;
|
|
124
|
+
if (typeof t === 'number')
|
|
125
|
+
return String(t);
|
|
126
|
+
return undefined;
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* Coerce a possibly-stringified integer into a number. Returns
|
|
130
|
+
* `undefined` for non-integers / non-strings. Used for things
|
|
131
|
+
* like `wp:post_id` and `wp:term_id` which can be either
|
|
132
|
+
* depending on parser config.
|
|
133
|
+
*/
|
|
134
|
+
export function intOf(value) {
|
|
135
|
+
if (typeof value === 'number' && Number.isFinite(value))
|
|
136
|
+
return Math.trunc(value);
|
|
137
|
+
if (typeof value === 'string' && /^\d+$/.test(value))
|
|
138
|
+
return Number.parseInt(value, 10);
|
|
139
|
+
return undefined;
|
|
140
|
+
}
|
|
141
|
+
//# sourceMappingURL=parse.js.map
|
|
@@ -0,0 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AAC,CAAA;IACnD,IAAI,KAAK,KAAK,IAAI,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC;QAAE,OAAO,SAAS,CAAA;IACzF,MAAM,CAAC,GAAG,KAAgC,CAAA;IAC1C,MAAM,CAAC,GAAG,CAAC,CAAC,OAAO,CAAC,CAAA;IACpB,IAAI,OAAO,CAAC,KAAK,QAAQ;QAAE,OAAO,CAAC,CAAA;IACnC,IAAI,OAAO,CAAC,KAAK,QAAQ;QAAE,OAAO,MAAM,CAAC,CAAC,CAAC,CAAA;IAC3C,OAAO,SAAS,CAAA;AAClB,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,KAAK,CAAC,KAAc;IAClC,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC;QAAE,OAAO,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAA;IACjF,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC;QAAE,OAAO,MAAM,CAAC,QAAQ,CAAC,KAAK,EAAE,EAAE,CAAC,CAAA;IACvF,OAAO,SAAS,CAAA;AAClB,CAAC"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Term (category + tag + custom taxonomy) indexing for the
|
|
3
|
+
* WordPress adapter.
|
|
4
|
+
*
|
|
5
|
+
* WXR carries terms in three places:
|
|
6
|
+
*
|
|
7
|
+
* - `<wp:category>` for categories.
|
|
8
|
+
* - `<wp:tag>` for tags.
|
|
9
|
+
* - `<wp:term>` for custom taxonomies (e.g. `post_format`,
|
|
10
|
+
* project-specific taxonomies).
|
|
11
|
+
*
|
|
12
|
+
* Posts then reference terms via per-item `<category
|
|
13
|
+
* domain="category|post_tag|<taxonomy>" nicename="<slug>">`
|
|
14
|
+
* elements.
|
|
15
|
+
*
|
|
16
|
+
* The adapter builds three lookups, all keyed on the `nicename`
|
|
17
|
+
* slug because that's what the per-item references carry:
|
|
18
|
+
*
|
|
19
|
+
* - `categories: Map<slug, TermEntry>`
|
|
20
|
+
* - `tags: Map<slug, TermEntry>`
|
|
21
|
+
* - `customByTaxonomy: Map<taxonomy, Map<slug, TermEntry>>`
|
|
22
|
+
*
|
|
23
|
+
* Each `TermEntry` records its display name + (for categories) the
|
|
24
|
+
* parent's slug so downstream consumers can rebuild the taxonomy
|
|
25
|
+
* tree without reparsing the WXR.
|
|
26
|
+
*/
|
|
27
|
+
import type { WxrCustomTerm, WxrTerm } from './types.js';
|
|
28
|
+
export interface TermEntry {
|
|
29
|
+
/** `wp:category_nicename` / `wp:tag_slug` / `wp:term_slug`. */
|
|
30
|
+
slug: string;
|
|
31
|
+
/** `wp:cat_name` / `wp:tag_name` / `wp:term_name`. */
|
|
32
|
+
name: string;
|
|
33
|
+
/** Parent slug (categories only — tags don't have hierarchy in WP). */
|
|
34
|
+
parentSlug?: string;
|
|
35
|
+
/** WP's numeric `wp:term_id`. Useful for downstream join tables. */
|
|
36
|
+
numericId?: number | string;
|
|
37
|
+
/** Taxonomy name (`category`, `post_tag`, or custom). */
|
|
38
|
+
taxonomy: string;
|
|
39
|
+
}
|
|
40
|
+
export interface TermsIndex {
|
|
41
|
+
categories: Map<string, TermEntry>;
|
|
42
|
+
tags: Map<string, TermEntry>;
|
|
43
|
+
customByTaxonomy: Map<string, Map<string, TermEntry>>;
|
|
44
|
+
}
|
|
45
|
+
export declare function buildTermsIndex(categories: readonly WxrTerm[] | undefined, tags: readonly WxrTerm[] | undefined, custom: readonly WxrCustomTerm[] | undefined): TermsIndex;
|
|
46
|
+
//# sourceMappingURL=terms.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"terms.d.ts","sourceRoot":"","sources":["../../../src/adapters/wordpress/terms.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAGH,OAAO,KAAK,EAAE,aAAa,EAAE,OAAO,EAAE,MAAM,YAAY,CAAA;AAExD,MAAM,WAAW,SAAS;IACxB,+DAA+D;IAC/D,IAAI,EAAE,MAAM,CAAA;IACZ,sDAAsD;IACtD,IAAI,EAAE,MAAM,CAAA;IACZ,uEAAuE;IACvE,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,oEAAoE;IACpE,SAAS,CAAC,EAAE,MAAM,GAAG,MAAM,CAAA;IAC3B,yDAAyD;IACzD,QAAQ,EAAE,MAAM,CAAA;CACjB;AAED,MAAM,WAAW,UAAU;IACzB,UAAU,EAAE,GAAG,CAAC,MAAM,EAAE,SAAS,CAAC,CAAA;IAClC,IAAI,EAAE,GAAG,CAAC,MAAM,EAAE,SAAS,CAAC,CAAA;IAC5B,gBAAgB,EAAE,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC,CAAA;CACtD;AAED,wBAAgB,eAAe,CAC7B,UAAU,EAAE,SAAS,OAAO,EAAE,GAAG,SAAS,EAC1C,IAAI,EAAE,SAAS,OAAO,EAAE,GAAG,SAAS,EACpC,MAAM,EAAE,SAAS,aAAa,EAAE,GAAG,SAAS,GAC3C,UAAU,CAyDZ"}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Term (category + tag + custom taxonomy) indexing for the
|
|
3
|
+
* WordPress adapter.
|
|
4
|
+
*
|
|
5
|
+
* WXR carries terms in three places:
|
|
6
|
+
*
|
|
7
|
+
* - `<wp:category>` for categories.
|
|
8
|
+
* - `<wp:tag>` for tags.
|
|
9
|
+
* - `<wp:term>` for custom taxonomies (e.g. `post_format`,
|
|
10
|
+
* project-specific taxonomies).
|
|
11
|
+
*
|
|
12
|
+
* Posts then reference terms via per-item `<category
|
|
13
|
+
* domain="category|post_tag|<taxonomy>" nicename="<slug>">`
|
|
14
|
+
* elements.
|
|
15
|
+
*
|
|
16
|
+
* The adapter builds three lookups, all keyed on the `nicename`
|
|
17
|
+
* slug because that's what the per-item references carry:
|
|
18
|
+
*
|
|
19
|
+
* - `categories: Map<slug, TermEntry>`
|
|
20
|
+
* - `tags: Map<slug, TermEntry>`
|
|
21
|
+
* - `customByTaxonomy: Map<taxonomy, Map<slug, TermEntry>>`
|
|
22
|
+
*
|
|
23
|
+
* Each `TermEntry` records its display name + (for categories) the
|
|
24
|
+
* parent's slug so downstream consumers can rebuild the taxonomy
|
|
25
|
+
* tree without reparsing the WXR.
|
|
26
|
+
*/
|
|
27
|
+
import { textOf } from './parse.js';
|
|
28
|
+
export function buildTermsIndex(categories, tags, custom) {
|
|
29
|
+
const out = {
|
|
30
|
+
categories: new Map(),
|
|
31
|
+
tags: new Map(),
|
|
32
|
+
customByTaxonomy: new Map(),
|
|
33
|
+
};
|
|
34
|
+
if (categories) {
|
|
35
|
+
for (const c of categories) {
|
|
36
|
+
const slug = textOf(c['wp:category_nicename']);
|
|
37
|
+
const name = textOf(c['wp:cat_name']);
|
|
38
|
+
if (!slug || !name)
|
|
39
|
+
continue;
|
|
40
|
+
const entry = { slug, name, taxonomy: 'category' };
|
|
41
|
+
const parent = textOf(c['wp:category_parent']);
|
|
42
|
+
if (parent)
|
|
43
|
+
entry.parentSlug = parent;
|
|
44
|
+
if (c['wp:term_id'] !== undefined && c['wp:term_id'] !== null) {
|
|
45
|
+
entry.numericId = c['wp:term_id'];
|
|
46
|
+
}
|
|
47
|
+
out.categories.set(slug, entry);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
if (tags) {
|
|
51
|
+
for (const t of tags) {
|
|
52
|
+
const slug = textOf(t['wp:tag_slug']);
|
|
53
|
+
const name = textOf(t['wp:tag_name']);
|
|
54
|
+
if (!slug || !name)
|
|
55
|
+
continue;
|
|
56
|
+
const entry = { slug, name, taxonomy: 'post_tag' };
|
|
57
|
+
if (t['wp:term_id'] !== undefined && t['wp:term_id'] !== null) {
|
|
58
|
+
entry.numericId = t['wp:term_id'];
|
|
59
|
+
}
|
|
60
|
+
out.tags.set(slug, entry);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
if (custom) {
|
|
64
|
+
for (const ct of custom) {
|
|
65
|
+
const taxonomy = textOf(ct['wp:term_taxonomy']);
|
|
66
|
+
const slug = textOf(ct['wp:term_slug']);
|
|
67
|
+
const name = textOf(ct['wp:term_name']);
|
|
68
|
+
if (!taxonomy || !slug || !name)
|
|
69
|
+
continue;
|
|
70
|
+
const entry = { slug, name, taxonomy };
|
|
71
|
+
const parent = textOf(ct['wp:term_parent']);
|
|
72
|
+
if (parent)
|
|
73
|
+
entry.parentSlug = parent;
|
|
74
|
+
if (ct['wp:term_id'] !== undefined && ct['wp:term_id'] !== null) {
|
|
75
|
+
entry.numericId = ct['wp:term_id'];
|
|
76
|
+
}
|
|
77
|
+
let bucket = out.customByTaxonomy.get(taxonomy);
|
|
78
|
+
if (!bucket) {
|
|
79
|
+
bucket = new Map();
|
|
80
|
+
out.customByTaxonomy.set(taxonomy, bucket);
|
|
81
|
+
}
|
|
82
|
+
bucket.set(slug, entry);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
return out;
|
|
86
|
+
}
|
|
87
|
+
//# sourceMappingURL=terms.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"terms.js","sourceRoot":"","sources":["../../../src/adapters/wordpress/terms.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,YAAY,CAAA;AAsBnC,MAAM,UAAU,eAAe,CAC7B,UAA0C,EAC1C,IAAoC,EACpC,MAA4C;IAE5C,MAAM,GAAG,GAAe;QACtB,UAAU,EAAE,IAAI,GAAG,EAAE;QACrB,IAAI,EAAE,IAAI,GAAG,EAAE;QACf,gBAAgB,EAAE,IAAI,GAAG,EAAE;KAC5B,CAAA;IAED,IAAI,UAAU,EAAE,CAAC;QACf,KAAK,MAAM,CAAC,IAAI,UAAU,EAAE,C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