@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,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Map a single Strapi entity into an Prenta-shaped payload.
|
|
3
|
+
*
|
|
4
|
+
* The mapper does five things in order:
|
|
5
|
+
*
|
|
6
|
+
* 1. **Resolve the collection** from the UID via `typeMap` or
|
|
7
|
+
* the derive-from-segment fallback.
|
|
8
|
+
* 2. **Strip system fields** (`id`, `createdAt`, `updatedAt`,
|
|
9
|
+
* `publishedAt`, `createdBy`, `updatedBy`, `locale`,
|
|
10
|
+
* `localizations`) from `data` — they're either in `sourceId`
|
|
11
|
+
* or covered by the import flow. Operators can keep them
|
|
12
|
+
* with `includeSystemFields: true`.
|
|
13
|
+
* 3. **Resolve inline media** — single-media and multi-media
|
|
14
|
+
* fields turn into `{ url, sourceId, fileName, contentType,
|
|
15
|
+
* ... }` records, or fall back to the asset metadata file
|
|
16
|
+
* when the inline data is sparse.
|
|
17
|
+
* 4. **Weave in sidecar relations** from `links/links.jsonl`.
|
|
18
|
+
* For each link `left=(thisEntity, field)`, emit
|
|
19
|
+
* `{ collection, sourceId }` on `data[field]`. Cardinality
|
|
20
|
+
* follows the link record's `relation` discriminator
|
|
21
|
+
* (`oneToMany` / `manyToMany` → array, `oneToOne` /
|
|
22
|
+
* `manyToOne` → single object). When `relation` is absent
|
|
23
|
+
* (some hand-edited exports skip it), the mapper falls back
|
|
24
|
+
* to "single object for one target, array for many" so the
|
|
25
|
+
* emitted shape stays predictable.
|
|
26
|
+
* 5. **Lift a `slug` string** to the top-level `slug` so
|
|
27
|
+
* Prenta URL helpers can grab it.
|
|
28
|
+
*/
|
|
29
|
+
import type { ImportWarning, UnresolvedField } from '../../types.js';
|
|
30
|
+
import { type AssetEntry } from './asset.js';
|
|
31
|
+
import { type LinksIndex } from './links.js';
|
|
32
|
+
import type { StrapiAdapterConfig, StrapiEntityRecord } from './types.js';
|
|
33
|
+
export interface MappingContext {
|
|
34
|
+
/** Strapi entity (type+ref) → resolved Prenta collection. */
|
|
35
|
+
collectionByEntity: Map<string, string>;
|
|
36
|
+
/** Asset id (stringified) → resolved asset payload. */
|
|
37
|
+
assetsById: Map<string, AssetEntry>;
|
|
38
|
+
/** Sidecar relations index. */
|
|
39
|
+
linksIndex: LinksIndex;
|
|
40
|
+
/** Optional media-base URL for relative media paths. */
|
|
41
|
+
mediaBaseUrl?: string;
|
|
42
|
+
}
|
|
43
|
+
export interface MapResult {
|
|
44
|
+
collection: string;
|
|
45
|
+
slug?: string;
|
|
46
|
+
data: Record<string, unknown>;
|
|
47
|
+
sourceId: string;
|
|
48
|
+
sourceType: string;
|
|
49
|
+
warnings: ImportWarning[];
|
|
50
|
+
unresolved: UnresolvedField[];
|
|
51
|
+
}
|
|
52
|
+
export declare function mapEntity(entity: StrapiEntityRecord, context: MappingContext, config: StrapiAdapterConfig): MapResult;
|
|
53
|
+
//# sourceMappingURL=map.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"map.d.ts","sourceRoot":"","sources":["../../../src/adapters/strapi/map.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAA;AACpE,OAAO,EAAE,KAAK,UAAU,EAAkC,MAAM,YAAY,CAAA;AAC5E,OAAO,EAAmB,KAAK,UAAU,EAAc,MAAM,YAAY,CAAA;AAEzE,OAAO,KAAK,EAAE,mBAAmB,EAAE,kBAAkB,EAA0B,MAAM,YAAY,CAAA;AAajG,MAAM,WAAW,cAAc;IAC7B,6DAA6D;IAC7D,kBAAkB,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IACvC,uDAAuD;IACvD,UAAU,EAAE,GAAG,CAAC,MAAM,EAAE,UAAU,CAAC,CAAA;IACnC,+BAA+B;IAC/B,UAAU,EAAE,UAAU,CAAA;IACtB,wDAAwD;IACxD,YAAY,CAAC,EAAE,MAAM,CAAA;CACtB;AAED,MAAM,WAAW,SAAS;IACxB,UAAU,EAAE,MAAM,CAAA;IAClB,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IAC7B,QAAQ,EAAE,MAAM,CAAA;IAChB,UAAU,EAAE,MAAM,CAAA;IAClB,QAAQ,EAAE,aAAa,EAAE,CAAA;IACzB,UAAU,EAAE,eAAe,EAAE,CAAA;CAC9B;AAID,wBAAgB,SAAS,CACvB,MAAM,EAAE,kBAAkB,EAC1B,OAAO,EAAE,cAAc,EACvB,MAAM,EAAE,mBAAmB,GAC1B,SAAS,CA2DX"}
|
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Map a single Strapi entity into an Prenta-shaped payload.
|
|
3
|
+
*
|
|
4
|
+
* The mapper does five things in order:
|
|
5
|
+
*
|
|
6
|
+
* 1. **Resolve the collection** from the UID via `typeMap` or
|
|
7
|
+
* the derive-from-segment fallback.
|
|
8
|
+
* 2. **Strip system fields** (`id`, `createdAt`, `updatedAt`,
|
|
9
|
+
* `publishedAt`, `createdBy`, `updatedBy`, `locale`,
|
|
10
|
+
* `localizations`) from `data` — they're either in `sourceId`
|
|
11
|
+
* or covered by the import flow. Operators can keep them
|
|
12
|
+
* with `includeSystemFields: true`.
|
|
13
|
+
* 3. **Resolve inline media** — single-media and multi-media
|
|
14
|
+
* fields turn into `{ url, sourceId, fileName, contentType,
|
|
15
|
+
* ... }` records, or fall back to the asset metadata file
|
|
16
|
+
* when the inline data is sparse.
|
|
17
|
+
* 4. **Weave in sidecar relations** from `links/links.jsonl`.
|
|
18
|
+
* For each link `left=(thisEntity, field)`, emit
|
|
19
|
+
* `{ collection, sourceId }` on `data[field]`. Cardinality
|
|
20
|
+
* follows the link record's `relation` discriminator
|
|
21
|
+
* (`oneToMany` / `manyToMany` → array, `oneToOne` /
|
|
22
|
+
* `manyToOne` → single object). When `relation` is absent
|
|
23
|
+
* (some hand-edited exports skip it), the mapper falls back
|
|
24
|
+
* to "single object for one target, array for many" so the
|
|
25
|
+
* emitted shape stays predictable.
|
|
26
|
+
* 5. **Lift a `slug` string** to the top-level `slug` so
|
|
27
|
+
* Prenta URL helpers can grab it.
|
|
28
|
+
*/
|
|
29
|
+
import { isStrapiMedia, liftInlineMedia } from './asset.js';
|
|
30
|
+
import { targetsFor } from './links.js';
|
|
31
|
+
import { resolveCollectionFromUid } from './uid.js';
|
|
32
|
+
const SYSTEM_FIELDS = new Set([
|
|
33
|
+
'id',
|
|
34
|
+
'createdAt',
|
|
35
|
+
'updatedAt',
|
|
36
|
+
'publishedAt',
|
|
37
|
+
'createdBy',
|
|
38
|
+
'updatedBy',
|
|
39
|
+
'locale',
|
|
40
|
+
'localizations',
|
|
41
|
+
]);
|
|
42
|
+
import { keyFor } from './links.js';
|
|
43
|
+
export function mapEntity(entity, context, config) {
|
|
44
|
+
const sourceId = String(entity.id);
|
|
45
|
+
const sourceType = entity.type;
|
|
46
|
+
const { collection, warned: usedFallback } = resolveCollectionFromUid(sourceType, config);
|
|
47
|
+
const warnings = [];
|
|
48
|
+
const unresolved = [];
|
|
49
|
+
const source = { type: sourceType, id: sourceId };
|
|
50
|
+
if (usedFallback) {
|
|
51
|
+
warnings.push({
|
|
52
|
+
source,
|
|
53
|
+
code: 'unmapped-type',
|
|
54
|
+
message: `No typeMap entry for '${sourceType}' — derived collection from UID.`,
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
const data = {};
|
|
58
|
+
let slug;
|
|
59
|
+
for (const [key, rawValue] of Object.entries(entity.data ?? {})) {
|
|
60
|
+
if (!config.includeSystemFields && SYSTEM_FIELDS.has(key))
|
|
61
|
+
continue;
|
|
62
|
+
const mapped = visit(rawValue, {
|
|
63
|
+
context,
|
|
64
|
+
config,
|
|
65
|
+
source,
|
|
66
|
+
path: key,
|
|
67
|
+
warnings,
|
|
68
|
+
unresolved,
|
|
69
|
+
});
|
|
70
|
+
if (slug === undefined && key === 'slug' && typeof mapped === 'string') {
|
|
71
|
+
slug = mapped;
|
|
72
|
+
}
|
|
73
|
+
data[key] = mapped;
|
|
74
|
+
}
|
|
75
|
+
// Weave in sidecar relations.
|
|
76
|
+
const perField = targetsFor(context.linksIndex, sourceType, sourceId);
|
|
77
|
+
if (perField) {
|
|
78
|
+
for (const [field, targets] of perField) {
|
|
79
|
+
// Don't overwrite a field the entity already declared
|
|
80
|
+
// inline; the inline value wins because that's the
|
|
81
|
+
// operator-shaped data.
|
|
82
|
+
if (Object.prototype.hasOwnProperty.call(data, field))
|
|
83
|
+
continue;
|
|
84
|
+
const resolved = resolveLinkTargets(targets, source, field, context, unresolved);
|
|
85
|
+
data[field] = resolved;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
return {
|
|
89
|
+
collection,
|
|
90
|
+
...(slug !== undefined ? { slug } : {}),
|
|
91
|
+
data,
|
|
92
|
+
sourceId,
|
|
93
|
+
sourceType,
|
|
94
|
+
warnings,
|
|
95
|
+
unresolved,
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
function visit(value, ctx) {
|
|
99
|
+
if (value === null || value === undefined)
|
|
100
|
+
return value;
|
|
101
|
+
if (typeof value !== 'object')
|
|
102
|
+
return value;
|
|
103
|
+
if (Array.isArray(value)) {
|
|
104
|
+
// Multi-media field detection: array of Strapi media objects.
|
|
105
|
+
if (value.length > 0 && value.every(isStrapiMedia)) {
|
|
106
|
+
return value.map((m) => resolveMedia(m, ctx));
|
|
107
|
+
}
|
|
108
|
+
return value.map((item, i) => visit(item, { ...ctx, path: `${ctx.path}[${i}]` }));
|
|
109
|
+
}
|
|
110
|
+
if (isStrapiMedia(value)) {
|
|
111
|
+
return resolveMedia(value, ctx);
|
|
112
|
+
}
|
|
113
|
+
// Plain object — recurse.
|
|
114
|
+
const tagged = value;
|
|
115
|
+
const out = {};
|
|
116
|
+
for (const [k, v] of Object.entries(tagged)) {
|
|
117
|
+
out[k] = visit(v, { ...ctx, path: `${ctx.path}.${k}` });
|
|
118
|
+
}
|
|
119
|
+
return out;
|
|
120
|
+
}
|
|
121
|
+
function resolveMedia(media, ctx) {
|
|
122
|
+
const inline = liftInlineMedia(media, { mediaBaseUrl: ctx.context.mediaBaseUrl });
|
|
123
|
+
const manifest = ctx.context.assetsById.get(String(media.id));
|
|
124
|
+
// Inline data is authoritative for whatever it carries; manifest
|
|
125
|
+
// fills in the gaps. If neither has a URL, surface as unresolved.
|
|
126
|
+
const merged = { ...manifest, ...stripEmpty(inline) };
|
|
127
|
+
if (!merged.url) {
|
|
128
|
+
ctx.unresolved.push({
|
|
129
|
+
source: { ...ctx.source, field: ctx.path },
|
|
130
|
+
code: 'media-without-url',
|
|
131
|
+
reason: `Media reference at '${ctx.path}' (id=${media.id}) has no URL inline or in assets/metadata.jsonl.`,
|
|
132
|
+
rawValue: media,
|
|
133
|
+
hint: 'Re-run strapi export including the assets/metadata.jsonl manifest, or set mediaBaseUrl in adapter config.',
|
|
134
|
+
});
|
|
135
|
+
return { sourceId: String(media.id), ...merged };
|
|
136
|
+
}
|
|
137
|
+
return { sourceId: String(media.id), ...merged };
|
|
138
|
+
}
|
|
139
|
+
function stripEmpty(entry) {
|
|
140
|
+
const out = { url: entry.url };
|
|
141
|
+
if (entry.fileName)
|
|
142
|
+
out.fileName = entry.fileName;
|
|
143
|
+
if (entry.contentType)
|
|
144
|
+
out.contentType = entry.contentType;
|
|
145
|
+
if (entry.size !== undefined)
|
|
146
|
+
out.size = entry.size;
|
|
147
|
+
if (entry.width !== undefined)
|
|
148
|
+
out.width = entry.width;
|
|
149
|
+
if (entry.height !== undefined)
|
|
150
|
+
out.height = entry.height;
|
|
151
|
+
if (entry.alternativeText)
|
|
152
|
+
out.alternativeText = entry.alternativeText;
|
|
153
|
+
if (entry.caption)
|
|
154
|
+
out.caption = entry.caption;
|
|
155
|
+
return out;
|
|
156
|
+
}
|
|
157
|
+
/**
|
|
158
|
+
* Resolve a list of sidecar-link targets into Prenta references.
|
|
159
|
+
* Single-vs-array emission respects Strapi's declared relation
|
|
160
|
+
* kind (`oneToOne` / `manyToOne` → single; `oneToMany` /
|
|
161
|
+
* `manyToMany` → array). When the relation kind isn't declared on
|
|
162
|
+
* the link records, we fall back to "single object for one
|
|
163
|
+
* target, array for many" — operators get a meaningful shape
|
|
164
|
+
* either way and can fix the link metadata if they need
|
|
165
|
+
* stricter cardinality.
|
|
166
|
+
*/
|
|
167
|
+
function resolveLinkTargets(targets, source, field, context, unresolved) {
|
|
168
|
+
const mapped = [];
|
|
169
|
+
for (const t of targets) {
|
|
170
|
+
const collection = context.collectionByEntity.get(keyFor(t.type, t.ref));
|
|
171
|
+
if (!collection) {
|
|
172
|
+
unresolved.push({
|
|
173
|
+
source: { type: source.type, id: source.id, field },
|
|
174
|
+
code: 'unresolved-link-target',
|
|
175
|
+
reason: `Relation '${field}' → ${t.type}#${t.ref} is missing from the dataset.`,
|
|
176
|
+
rawValue: t,
|
|
177
|
+
hint: 'Include the target entity in the export, or set publishedOnly=false if it is unpublished.',
|
|
178
|
+
});
|
|
179
|
+
continue;
|
|
180
|
+
}
|
|
181
|
+
mapped.push({ collection, sourceId: String(t.ref) });
|
|
182
|
+
}
|
|
183
|
+
const relation = targets[0]?.relation;
|
|
184
|
+
const isMulti = relation === 'oneToMany' ||
|
|
185
|
+
relation === 'manyToMany' ||
|
|
186
|
+
(relation === undefined && mapped.length > 1);
|
|
187
|
+
if (isMulti)
|
|
188
|
+
return mapped;
|
|
189
|
+
if (mapped.length === 0)
|
|
190
|
+
return undefined;
|
|
191
|
+
return mapped[0];
|
|
192
|
+
}
|
|
193
|
+
//# sourceMappingURL=map.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"map.js","sourceRoot":"","sources":["../../../src/adapters/strapi/map.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAGH,OAAO,EAAmB,aAAa,EAAE,eAAe,EAAE,MAAM,YAAY,CAAA;AAC5E,OAAO,EAAoC,UAAU,EAAE,MAAM,YAAY,CAAA;AACzE,OAAO,EAAE,wBAAwB,EAAE,MAAM,UAAU,CAAA;AAGnD,MAAM,aAAa,GAAG,IAAI,GAAG,CAAC;IAC5B,IAAI;IACJ,WAAW;IACX,WAAW;IACX,aAAa;IACb,WAAW;IACX,WAAW;IACX,QAAQ;IACR,eAAe;CAChB,CAAC,CAAA;AAuBF,OAAO,EAAE,MAAM,EAAE,MAAM,YAAY,CAAA;AAEnC,MAAM,UAAU,SAAS,CACvB,MAA0B,EAC1B,OAAuB,EACvB,MAA2B;IAE3B,MAAM,QAAQ,GAAG,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC,CAAA;IAClC,MAAM,UAAU,GAAG,MAAM,CAAC,IAAI,CAAA;IAC9B,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,YAAY,EAAE,GAAG,wBAAwB,CAAC,UAAU,EAAE,MAAM,CAAC,CAAA;IAEzF,MAAM,QAAQ,GAAoB,EAAE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C,CAAC,CAAA;QACxE,IAAI,CAAC,UAAU,EAAE,CAAC;YAChB,UAAU,CAAC,IAAI,CAAC;gBACd,MAAM,EAAE,EAAE,IAAI,EAAE,MAAM,CAAC,IAAI,EAAE,EAAE,EAAE,MAAM,CAAC,EAAE,EAAE,KAAK,EAAE;gBACnD,IAAI,EAAE,wBAAwB;gBAC9B,MAAM,EAAE,aAAa,KAAK,OAAO,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC,GAAG,+BAA+B;gBAC/E,QAAQ,EAAE,CAAC;gBACX,IAAI,EAAE,2FAA2F;aAClG,CAAC,CAAA;YACF,SAAQ;QACV,CAAC;QACD,MAAM,CAAC,IAAI,CAAC,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,CAAC,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC,CAAA;IACtD,CAAC;IACD,MAAM,QAAQ,GAAG,OAAO,CAAC,CAAC,CAAC,EAAE,QAAQ,CAAA;IACrC,MAAM,OAAO,GACX,QAAQ,KAAK,WAAW;QACxB,QAAQ,KAAK,YAAY;QACzB,CAAC,QAAQ,KAAK,SAAS,IAAI,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC,CAAA;IAC/C,IAAI,OAAO;QAAE,OAAO,MAAM,CAAA;IAC1B,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,SAAS,CAAA;IACzC,OAAO,MAAM,CAAC,CAAC,CAAC,CAAA;AAClB,CAAC"}
|
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Type definitions for the structural shapes the Strapi adapter
|
|
3
|
+
* recognizes in a `strapi export` dataset (post `.tar.gz`
|
|
4
|
+
* extraction). The adapter targets the canonical
|
|
5
|
+
* `@strapi/data-transfer` v4/v5 dataset layout:
|
|
6
|
+
*
|
|
7
|
+
* ```
|
|
8
|
+
* <dataset-root>/
|
|
9
|
+
* entities/<uid>.jsonl # one JSON object per line
|
|
10
|
+
* assets/metadata.jsonl # asset records (no binaries read)
|
|
11
|
+
* links/links.jsonl # cross-entity relations
|
|
12
|
+
* schemas/schemas.jsonl # optional, ignored by this adapter
|
|
13
|
+
* ```
|
|
14
|
+
*
|
|
15
|
+
* Strapi differs from Sanity / Contentful in two ways that drive
|
|
16
|
+
* the design:
|
|
17
|
+
*
|
|
18
|
+
* - **Relations live in a sidecar file.** Each entry in
|
|
19
|
+
* `entities/*.jsonl` has its in-document field values, but
|
|
20
|
+
* one-to-many / many-to-many references aren't inlined — they
|
|
21
|
+
* sit in `links/links.jsonl` and have to be woven back into
|
|
22
|
+
* each entity at mapping time.
|
|
23
|
+
* - **i18n is per-entity, not per-field.** Strapi creates a
|
|
24
|
+
* separate row per locale and joins them via the `links` file
|
|
25
|
+
* with a special `localizations` relation. The adapter exposes
|
|
26
|
+
* a `primaryLocale` filter for the common "import only one
|
|
27
|
+
* language" use case; full per-locale fan-out can land in a
|
|
28
|
+
* follow-up.
|
|
29
|
+
*/
|
|
30
|
+
/**
|
|
31
|
+
* Strapi's content-type UID. Looks like `api::article.article`
|
|
32
|
+
* or `plugin::users-permissions.user`. Parsing turns one of these
|
|
33
|
+
* into an Prenta collection slug (defaults to the last segment).
|
|
34
|
+
*/
|
|
35
|
+
export type StrapiUid = string;
|
|
36
|
+
/**
|
|
37
|
+
* One line of an `entities/<uid>.jsonl` file. The data-transfer
|
|
38
|
+
* format wraps each entity in `{ id, type, data }`; `data` is the
|
|
39
|
+
* entity's fields including non-relational media attachments.
|
|
40
|
+
*/
|
|
41
|
+
export interface StrapiEntityRecord {
|
|
42
|
+
id: number | string;
|
|
43
|
+
type: StrapiUid;
|
|
44
|
+
data: Record<string, unknown>;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Strapi's media-attachment shape. Lives inline on entity `data`
|
|
48
|
+
* under whatever field name the schema declared (e.g. `cover`).
|
|
49
|
+
* Single-media fields point at one of these; multi-media point at
|
|
50
|
+
* an array.
|
|
51
|
+
*/
|
|
52
|
+
export interface StrapiMedia {
|
|
53
|
+
id: number | string;
|
|
54
|
+
url?: string;
|
|
55
|
+
name?: string;
|
|
56
|
+
mime?: string;
|
|
57
|
+
size?: number;
|
|
58
|
+
width?: number;
|
|
59
|
+
height?: number;
|
|
60
|
+
ext?: string;
|
|
61
|
+
formats?: Record<string, unknown>;
|
|
62
|
+
alternativeText?: string | null;
|
|
63
|
+
caption?: string | null;
|
|
64
|
+
hash?: string;
|
|
65
|
+
provider?: string;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* One line of `assets/metadata.jsonl`. The adapter only inspects
|
|
69
|
+
* what it needs to build the asset URL map; the rest passes
|
|
70
|
+
* through.
|
|
71
|
+
*/
|
|
72
|
+
export interface StrapiAssetRecord {
|
|
73
|
+
id: number | string;
|
|
74
|
+
name?: string;
|
|
75
|
+
url?: string;
|
|
76
|
+
mime?: string;
|
|
77
|
+
size?: number;
|
|
78
|
+
width?: number;
|
|
79
|
+
height?: number;
|
|
80
|
+
hash?: string;
|
|
81
|
+
ext?: string;
|
|
82
|
+
alternativeText?: string | null;
|
|
83
|
+
caption?: string | null;
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* One line of `links/links.jsonl`. Strapi's data-transfer engine
|
|
87
|
+
* emits these for every relational join, including i18n's
|
|
88
|
+
* `localizations`. Shape varies a little across v4 / v5; the
|
|
89
|
+
* adapter only inspects the four fields documented here and falls
|
|
90
|
+
* back gracefully when the others are absent.
|
|
91
|
+
*/
|
|
92
|
+
export interface StrapiLinkRecord {
|
|
93
|
+
/** Source side of the relation. */
|
|
94
|
+
left: {
|
|
95
|
+
type: StrapiUid;
|
|
96
|
+
ref: number | string;
|
|
97
|
+
field?: string;
|
|
98
|
+
};
|
|
99
|
+
/** Target side of the relation. */
|
|
100
|
+
right: {
|
|
101
|
+
type: StrapiUid;
|
|
102
|
+
ref: number | string;
|
|
103
|
+
field?: string;
|
|
104
|
+
};
|
|
105
|
+
/** Relation kind (`oneToOne`, `oneToMany`, `manyToOne`, `manyToMany`, etc.). */
|
|
106
|
+
kind?: string;
|
|
107
|
+
/** Strapi's relation strategy label — present in some exports. */
|
|
108
|
+
relation?: string;
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Per-import config. Loaded via
|
|
112
|
+
* `prenta-import strapi <dataset-dir> --config ./strapi.json`.
|
|
113
|
+
*/
|
|
114
|
+
export interface StrapiAdapterConfig {
|
|
115
|
+
/**
|
|
116
|
+
* Strapi UID → Prenta collection slug. Untyped:
|
|
117
|
+
* unmapped UIDs fall back to the last segment of the UID
|
|
118
|
+
* silently. Typed: unmapped UIDs fall back AND warn.
|
|
119
|
+
*
|
|
120
|
+
* Example: `{ 'api::article.article': 'posts' }`.
|
|
121
|
+
*/
|
|
122
|
+
typeMap?: Record<string, string>;
|
|
123
|
+
/**
|
|
124
|
+
* When set, only import entities whose `data.locale` matches
|
|
125
|
+
* (or whose data has no locale field at all — non-i18n
|
|
126
|
+
* content types are always included regardless).
|
|
127
|
+
*/
|
|
128
|
+
primaryLocale?: string;
|
|
129
|
+
/**
|
|
130
|
+
* Skip entities where `data.publishedAt == null`. Default
|
|
131
|
+
* `true` — most migrations want only the live content.
|
|
132
|
+
*/
|
|
133
|
+
publishedOnly?: boolean;
|
|
134
|
+
/**
|
|
135
|
+
* Preserve `id`, `createdAt`, `updatedAt`, `publishedAt`,
|
|
136
|
+
* `createdBy`, `updatedBy`, `locale`, and `localizations` on
|
|
137
|
+
* `data` when `true`. Default `false` — `sourceId` /
|
|
138
|
+
* `sourceType` already carry the operator-relevant bits.
|
|
139
|
+
*/
|
|
140
|
+
includeSystemFields?: boolean;
|
|
141
|
+
/**
|
|
142
|
+
* Skip these UIDs entirely. Useful for excluding
|
|
143
|
+
* `admin::*` / `plugin::*` system types from the output.
|
|
144
|
+
* Defaults: `['admin::user', 'admin::role', 'admin::permission']`
|
|
145
|
+
* plus anything the operator adds.
|
|
146
|
+
*/
|
|
147
|
+
ignoreTypes?: string[];
|
|
148
|
+
/**
|
|
149
|
+
* When `true`, emit asset records as Prenta documents in their
|
|
150
|
+
* own collection (configurable via `assetCollection`). When
|
|
151
|
+
* `false` (default), assets are only used to decorate media
|
|
152
|
+
* fields on entities.
|
|
153
|
+
*/
|
|
154
|
+
importAssets?: boolean;
|
|
155
|
+
/** Collection slug for asset documents when `importAssets: true`. */
|
|
156
|
+
assetCollection?: string;
|
|
157
|
+
/**
|
|
158
|
+
* Override how a Strapi UID becomes a fallback collection slug
|
|
159
|
+
* when no `typeMap` entry exists. Default takes the last
|
|
160
|
+
* segment of the UID (`api::article.article` → `article`).
|
|
161
|
+
*/
|
|
162
|
+
collectionFromUid?: (uid: StrapiUid) => string;
|
|
163
|
+
/**
|
|
164
|
+
* Prefix for relative media URLs. Strapi inline media occasionally
|
|
165
|
+
* stores `/uploads/foo.jpg` instead of a full URL — typically when
|
|
166
|
+
* the project ran behind a self-hosted upload provider. When
|
|
167
|
+
* `mediaBaseUrl` is set, the adapter prepends it (one slash only,
|
|
168
|
+
* trailing slashes on the base are normalized) for any URL that
|
|
169
|
+
* starts with `/`. Absolute, fully-qualified, and protocol-relative
|
|
170
|
+
* URLs pass through unchanged.
|
|
171
|
+
*/
|
|
172
|
+
mediaBaseUrl?: string;
|
|
173
|
+
}
|
|
174
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/adapters/strapi/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AAEH;;;;GAIG;AACH,MAAM,MAAM,SAAS,GAAG,MAAM,CAAA;AAE9B;;;;GAIG;AACH,MAAM,WAAW,kBAAkB;IACjC,EAAE,EAAE,MAAM,GAAG,MAAM,CAAA;IACnB,IAAI,EAAE,SAAS,CAAA;IACf,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;CAC9B;AAED;;;;;GAKG;AACH,MA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KAAK,EAAE;QAAE,IAAI,EAAE,SAAS,CAAC;QAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,CAAA;KAAE,CAAA;IAChE,gFAAgF;IAChF,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,kEAAkE;IAClE,QAAQ,CAAC,EAAE,MAAM,CAAA;CAClB;AAED;;;GAGG;AACH,MAAM,WAAW,mBAAmB;IAClC;;;;;;OAMG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IAChC;;;;OAIG;IACH,aAAa,CAAC,EAAE,MAAM,CAAA;IACtB;;;OAGG;IACH,aAAa,CAAC,EAAE,OAAO,CAAA;IACvB;;;;;OAKG;IACH,mBAAmB,CAAC,EAAE,OAAO,CAAA;IAC7B;;;;;OAKG;IACH,WAAW,CAAC,EAAE,MAAM,EAAE,CAAA;IACtB;;;;;OAKG;IACH,YAAY,CAAC,EAAE,OAAO,CAAA;IACtB,qEAAqE;IACrE,eAAe,CAAC,EAAE,MAAM,CAAA;IACxB;;;;OAIG;IACH,iBAAiB,CAAC,EAAE,CAAC,GAAG,EAAE,SAAS,KAAK,MAAM,CAAA;IAC9C;;;;;;;;OAQG;IACH,YAAY,CAAC,EAAE,MAAM,CAAA;CACtB"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Type definitions for the structural shapes the Strapi adapter
|
|
3
|
+
* recognizes in a `strapi export` dataset (post `.tar.gz`
|
|
4
|
+
* extraction). The adapter targets the canonical
|
|
5
|
+
* `@strapi/data-transfer` v4/v5 dataset layout:
|
|
6
|
+
*
|
|
7
|
+
* ```
|
|
8
|
+
* <dataset-root>/
|
|
9
|
+
* entities/<uid>.jsonl # one JSON object per line
|
|
10
|
+
* assets/metadata.jsonl # asset records (no binaries read)
|
|
11
|
+
* links/links.jsonl # cross-entity relations
|
|
12
|
+
* schemas/schemas.jsonl # optional, ignored by this adapter
|
|
13
|
+
* ```
|
|
14
|
+
*
|
|
15
|
+
* Strapi differs from Sanity / Contentful in two ways that drive
|
|
16
|
+
* the design:
|
|
17
|
+
*
|
|
18
|
+
* - **Relations live in a sidecar file.** Each entry in
|
|
19
|
+
* `entities/*.jsonl` has its in-document field values, but
|
|
20
|
+
* one-to-many / many-to-many references aren't inlined — they
|
|
21
|
+
* sit in `links/links.jsonl` and have to be woven back into
|
|
22
|
+
* each entity at mapping time.
|
|
23
|
+
* - **i18n is per-entity, not per-field.** Strapi creates a
|
|
24
|
+
* separate row per locale and joins them via the `links` file
|
|
25
|
+
* with a special `localizations` relation. The adapter exposes
|
|
26
|
+
* a `primaryLocale` filter for the common "import only one
|
|
27
|
+
* language" use case; full per-locale fan-out can land in a
|
|
28
|
+
* follow-up.
|
|
29
|
+
*/
|
|
30
|
+
export {};
|
|
31
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/adapters/strapi/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Strapi UID → Prenta collection slug.
|
|
3
|
+
*
|
|
4
|
+
* Strapi identifies every content type with a UID like
|
|
5
|
+
* `api::article.article` (api-level) or
|
|
6
|
+
* `plugin::users-permissions.user` (plugin-level) or
|
|
7
|
+
* `admin::user` (admin namespace). The adapter has to turn these
|
|
8
|
+
* into Prenta collection slugs.
|
|
9
|
+
*
|
|
10
|
+
* Strategy:
|
|
11
|
+
*
|
|
12
|
+
* 1. If the operator supplied a `typeMap`, look it up there.
|
|
13
|
+
* `typeMap` set + entry exists → mapped slug.
|
|
14
|
+
* `typeMap` set + entry missing → fall back to derived slug +
|
|
15
|
+
* emit a single `unmapped-type` warning at the call site.
|
|
16
|
+
* `typeMap` not set → derive silently.
|
|
17
|
+
*
|
|
18
|
+
* 2. Derive: take the **last segment** of the UID. For
|
|
19
|
+
* `api::article.article` that's `article`. For
|
|
20
|
+
* `plugin::users-permissions.user` that's `user`. For
|
|
21
|
+
* `admin::role`, also `role`.
|
|
22
|
+
*
|
|
23
|
+
* 3. Operators can override step 2 with a `collectionFromUid`
|
|
24
|
+
* function in config — useful for projects that want
|
|
25
|
+
* `api-article` to become `posts` everywhere without
|
|
26
|
+
* enumerating every content type.
|
|
27
|
+
*/
|
|
28
|
+
import type { StrapiAdapterConfig, StrapiUid } from './types.js';
|
|
29
|
+
/**
|
|
30
|
+
* Default derivation: last segment of the UID after the final dot,
|
|
31
|
+
* or the whole thing after `::` if there's no dot.
|
|
32
|
+
*/
|
|
33
|
+
export declare function defaultCollectionFromUid(uid: StrapiUid): string;
|
|
34
|
+
/**
|
|
35
|
+
* Resolve a Strapi UID to an Prenta collection slug. Returns the
|
|
36
|
+
* slug + a `warned` flag the caller uses to decide whether to
|
|
37
|
+
* emit an `unmapped-type` warning (same model as the Sanity and
|
|
38
|
+
* Contentful adapters).
|
|
39
|
+
*/
|
|
40
|
+
export declare function resolveCollectionFromUid(uid: StrapiUid, config: StrapiAdapterConfig): {
|
|
41
|
+
collection: string;
|
|
42
|
+
warned: boolean;
|
|
43
|
+
};
|
|
44
|
+
//# sourceMappingURL=uid.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"uid.d.ts","sourceRoot":"","sources":["../../../src/adapters/strapi/uid.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAEH,OAAO,KAAK,EAAE,mBAAmB,EAAE,SAAS,EAAE,MAAM,YAAY,CAAA;AAEhE;;;GAGG;AACH,wBAAgB,wBAAwB,CAAC,GAAG,EAAE,SAAS,GAAG,MAAM,CAO/D;AAED;;;;;GAKG;AACH,wBAAgB,wBAAwB,CACtC,GAAG,EAAE,SAAS,EACd,MAAM,EAAE,mBAAmB,GAC1B;IAAE,UAAU,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,OAAO,CAAA;CAAE,CASzC"}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Strapi UID → Prenta collection slug.
|
|
3
|
+
*
|
|
4
|
+
* Strapi identifies every content type with a UID like
|
|
5
|
+
* `api::article.article` (api-level) or
|
|
6
|
+
* `plugin::users-permissions.user` (plugin-level) or
|
|
7
|
+
* `admin::user` (admin namespace). The adapter has to turn these
|
|
8
|
+
* into Prenta collection slugs.
|
|
9
|
+
*
|
|
10
|
+
* Strategy:
|
|
11
|
+
*
|
|
12
|
+
* 1. If the operator supplied a `typeMap`, look it up there.
|
|
13
|
+
* `typeMap` set + entry exists → mapped slug.
|
|
14
|
+
* `typeMap` set + entry missing → fall back to derived slug +
|
|
15
|
+
* emit a single `unmapped-type` warning at the call site.
|
|
16
|
+
* `typeMap` not set → derive silently.
|
|
17
|
+
*
|
|
18
|
+
* 2. Derive: take the **last segment** of the UID. For
|
|
19
|
+
* `api::article.article` that's `article`. For
|
|
20
|
+
* `plugin::users-permissions.user` that's `user`. For
|
|
21
|
+
* `admin::role`, also `role`.
|
|
22
|
+
*
|
|
23
|
+
* 3. Operators can override step 2 with a `collectionFromUid`
|
|
24
|
+
* function in config — useful for projects that want
|
|
25
|
+
* `api-article` to become `posts` everywhere without
|
|
26
|
+
* enumerating every content type.
|
|
27
|
+
*/
|
|
28
|
+
/**
|
|
29
|
+
* Default derivation: last segment of the UID after the final dot,
|
|
30
|
+
* or the whole thing after `::` if there's no dot.
|
|
31
|
+
*/
|
|
32
|
+
export function defaultCollectionFromUid(uid) {
|
|
33
|
+
if (typeof uid !== 'string' || uid.length === 0)
|
|
34
|
+
return 'unknown';
|
|
35
|
+
// Drop the namespace prefix (e.g. `api::`, `plugin::`, `admin::`).
|
|
36
|
+
const afterScope = uid.includes('::') ? (uid.split('::', 2)[1] ?? uid) : uid;
|
|
37
|
+
// The remainder is `<api-name>.<content-type>` (or just one segment).
|
|
38
|
+
const segments = afterScope.split('.');
|
|
39
|
+
return segments[segments.length - 1] || afterScope;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Resolve a Strapi UID to an Prenta collection slug. Returns the
|
|
43
|
+
* slug + a `warned` flag the caller uses to decide whether to
|
|
44
|
+
* emit an `unmapped-type` warning (same model as the Sanity and
|
|
45
|
+
* Contentful adapters).
|
|
46
|
+
*/
|
|
47
|
+
export function resolveCollectionFromUid(uid, config) {
|
|
48
|
+
if (config.typeMap) {
|
|
49
|
+
const mapped = config.typeMap[uid];
|
|
50
|
+
if (mapped)
|
|
51
|
+
return { collection: mapped, warned: false };
|
|
52
|
+
const derived = (config.collectionFromUid ?? defaultCollectionFromUid)(uid);
|
|
53
|
+
return { collection: derived, warned: true };
|
|
54
|
+
}
|
|
55
|
+
const derived = (config.collectionFromUid ?? defaultCollectionFromUid)(uid);
|
|
56
|
+
return { collection: derived, warned: false };
|
|
57
|
+
}
|
|
58
|
+
//# sourceMappingURL=uid.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"uid.js","sourceRoot":"","sources":["../../../src/adapters/strapi/uid.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAIH;;;GAGG;AACH,MAAM,UAAU,wBAAwB,CAAC,GAAc;IACrD,IAAI,OAAO,GAAG,KAAK,QAAQ,IAAI,GAAG,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,SAAS,CAAA;IACjE,mEAAmE;IACnE,MAAM,UAAU,GAAG,GAAG,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAA;IAC5E,sEAAsE;IACtE,MAAM,QAAQ,GAAG,UAAU,CAAC,KAAK,CAAC,GAAG,CAAC,CAAA;IACtC,OAAO,QAAQ,CAAC,QAAQ,CAAC,MAAM,GAAG,CAAC,CAAC,IAAI,UAAU,CAAA;AACpD,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,wBAAwB,CACtC,GAAc,EACd,MAA2B;IAE3B,IAAI,MAAM,CAAC,OAAO,EAAE,CAAC;QACnB,MAAM,MAAM,GAAG,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,CAAA;QAClC,IAAI,MAAM;YAAE,OAAO,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,CAAA;QACxD,MAAM,OAAO,GAAG,CAAC,MAAM,CAAC,iBAAiB,IAAI,wBAAwB,CAAC,CAAC,GAAG,CAAC,CAAA;QAC3E,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,CAAA;IAC9C,CAAC;IACD,MAAM,OAAO,GAAG,CAAC,MAAM,CAAC,iBAAiB,IAAI,wBAAwB,CAAC,CAAC,GAAG,CAAC,CAAA;IAC3E,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,CAAA;AAC/C,CAAC"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Attachment URL map for the WordPress adapter.
|
|
3
|
+
*
|
|
4
|
+
* WP exports attachments as regular `<item>` elements with
|
|
5
|
+
* `<wp:post_type>attachment</wp:post_type>`. The asset URL lives
|
|
6
|
+
* in `<wp:attachment_url>`, mime in `<wp:postmeta>` rows keyed
|
|
7
|
+
* `_wp_attached_file` / `_wp_attachment_metadata`, and image
|
|
8
|
+
* dimensions inside the serialized PHP blob at
|
|
9
|
+
* `_wp_attachment_metadata`.
|
|
10
|
+
*
|
|
11
|
+
* The adapter only needs the URL + mime + a best-effort
|
|
12
|
+
* dimension pair, so we read the JSON-shaped meta values
|
|
13
|
+
* (newer WP installs sometimes emit JSON instead of PHP-serialized
|
|
14
|
+
* data) and gracefully ignore the rest. Operators who need full
|
|
15
|
+
* EXIF-style metadata can post-process the attachment documents
|
|
16
|
+
* when `importAttachments: true`.
|
|
17
|
+
*/
|
|
18
|
+
import type { WxrItem } from './types.js';
|
|
19
|
+
export interface AttachmentEntry {
|
|
20
|
+
/** `wp:post_id` (number). */
|
|
21
|
+
id: number;
|
|
22
|
+
url: string;
|
|
23
|
+
mime?: string;
|
|
24
|
+
width?: number;
|
|
25
|
+
height?: number;
|
|
26
|
+
title?: string;
|
|
27
|
+
/** Parent post id, if the attachment was uploaded inside one. */
|
|
28
|
+
parentId?: number;
|
|
29
|
+
}
|
|
30
|
+
export type AttachmentIndex = Map<number, AttachmentEntry>;
|
|
31
|
+
/**
|
|
32
|
+
* Build the attachment map from the channel's `<item>` array.
|
|
33
|
+
* Only items with `wp:post_type === 'attachment'` are considered;
|
|
34
|
+
* non-attachment items pass through untouched.
|
|
35
|
+
*/
|
|
36
|
+
export declare function buildAttachmentIndex(items: readonly WxrItem[] | undefined): AttachmentIndex;
|
|
37
|
+
//# sourceMappingURL=attachments.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"attachments.d.ts","sourceRoot":"","sources":["../../../src/adapters/wordpress/attachments.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAGH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,YAAY,CAAA;AAEzC,MAAM,WAAW,eAAe;IAC9B,6BAA6B;IAC7B,EAAE,EAAE,MAAM,CAAA;IACV,GAAG,EAAE,MAAM,CAAA;IACX,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,iEAAiE;IACjE,QAAQ,CAAC,EAAE,MAAM,CAAA;CAClB;AAED,MAAM,MAAM,eAAe,GAAG,GAAG,CAAC,MAAM,EAAE,eAAe,CAAC,CAAA;AAU1D;;;;GAIG;AACH,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,SAAS,OAAO,EAAE,GAAG,SAAS,GAAG,eAAe,CA6D3F"}
|