@forumulate/cli 0.4.0 → 0.8.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/README.md +116 -5
- package/dist/api/args.d.ts +21 -0
- package/dist/api/args.d.ts.map +1 -0
- package/dist/api/args.js +81 -0
- package/dist/api/args.js.map +1 -0
- package/dist/api/command.d.ts +17 -0
- package/dist/api/command.d.ts.map +1 -0
- package/dist/api/command.js +182 -0
- package/dist/api/command.js.map +1 -0
- package/dist/api/describe.d.ts +5 -0
- package/dist/api/describe.d.ts.map +1 -0
- package/dist/api/describe.js +121 -0
- package/dist/api/describe.js.map +1 -0
- package/dist/api/http.d.ts +81 -0
- package/dist/api/http.d.ts.map +1 -0
- package/dist/api/http.js +183 -0
- package/dist/api/http.js.map +1 -0
- package/dist/api/operations.json +1 -0
- package/dist/api/output.d.ts +35 -0
- package/dist/api/output.d.ts.map +1 -0
- package/dist/api/output.js +176 -0
- package/dist/api/output.js.map +1 -0
- package/dist/api/request.d.ts +37 -0
- package/dist/api/request.d.ts.map +1 -0
- package/dist/api/request.js +230 -0
- package/dist/api/request.js.map +1 -0
- package/dist/api/send.d.ts +35 -0
- package/dist/api/send.d.ts.map +1 -0
- package/dist/api/send.js +85 -0
- package/dist/api/send.js.map +1 -0
- package/dist/api/spec.d.ts +96 -0
- package/dist/api/spec.d.ts.map +1 -0
- package/dist/api/spec.js +126 -0
- package/dist/api/spec.js.map +1 -0
- package/dist/cli.js +12 -0
- package/dist/cli.js.map +1 -1
- package/dist/commands/completion.d.ts +12 -0
- package/dist/commands/completion.d.ts.map +1 -0
- package/dist/commands/completion.js +153 -0
- package/dist/commands/completion.js.map +1 -0
- package/dist/commands/config.d.ts +33 -0
- package/dist/commands/config.d.ts.map +1 -0
- package/dist/commands/config.js +144 -0
- package/dist/commands/config.js.map +1 -0
- package/dist/commands/context.d.ts +35 -0
- package/dist/commands/context.d.ts.map +1 -0
- package/dist/commands/context.js +59 -0
- package/dist/commands/context.js.map +1 -0
- package/dist/commands/groups-api.d.ts +11 -0
- package/dist/commands/groups-api.d.ts.map +1 -0
- package/dist/commands/groups-api.js +140 -0
- package/dist/commands/groups-api.js.map +1 -0
- package/dist/commands/groups-community.d.ts +15 -0
- package/dist/commands/groups-community.d.ts.map +1 -0
- package/dist/commands/groups-community.js +344 -0
- package/dist/commands/groups-community.js.map +1 -0
- package/dist/commands/groups-content.d.ts +10 -0
- package/dist/commands/groups-content.d.ts.map +1 -0
- package/dist/commands/groups-content.js +331 -0
- package/dist/commands/groups-content.js.map +1 -0
- package/dist/commands/groups-docs.d.ts +12 -0
- package/dist/commands/groups-docs.d.ts.map +1 -0
- package/dist/commands/groups-docs.js +414 -0
- package/dist/commands/groups-docs.js.map +1 -0
- package/dist/commands/groups-org.d.ts +10 -0
- package/dist/commands/groups-org.d.ts.map +1 -0
- package/dist/commands/groups-org.js +405 -0
- package/dist/commands/groups-org.js.map +1 -0
- package/dist/commands/groups-site.d.ts +3 -0
- package/dist/commands/groups-site.d.ts.map +1 -0
- package/dist/commands/groups-site.js +230 -0
- package/dist/commands/groups-site.js.map +1 -0
- package/dist/commands/groups-spaces.d.ts +3 -0
- package/dist/commands/groups-spaces.d.ts.map +1 -0
- package/dist/commands/groups-spaces.js +273 -0
- package/dist/commands/groups-spaces.js.map +1 -0
- package/dist/commands/groups-types.d.ts +3 -0
- package/dist/commands/groups-types.d.ts.map +1 -0
- package/dist/commands/groups-types.js +251 -0
- package/dist/commands/groups-types.js.map +1 -0
- package/dist/commands/groups.d.ts +4 -0
- package/dist/commands/groups.d.ts.map +1 -0
- package/dist/commands/groups.js +71 -0
- package/dist/commands/groups.js.map +1 -0
- package/dist/commands/index.d.ts +25 -0
- package/dist/commands/index.d.ts.map +1 -0
- package/dist/commands/index.js +118 -0
- package/dist/commands/index.js.map +1 -0
- package/dist/commands/resource.d.ts +86 -0
- package/dist/commands/resource.d.ts.map +1 -0
- package/dist/commands/resource.js +314 -0
- package/dist/commands/resource.js.map +1 -0
- package/dist/content/command.d.ts +34 -0
- package/dist/content/command.d.ts.map +1 -0
- package/dist/content/command.js +225 -0
- package/dist/content/command.js.map +1 -0
- package/dist/content/library.d.ts +23 -0
- package/dist/content/library.d.ts.map +1 -0
- package/dist/content/library.js +41 -0
- package/dist/content/library.js.map +1 -0
- package/dist/content/render.d.ts +15 -0
- package/dist/content/render.d.ts.map +1 -0
- package/dist/content/render.js +85 -0
- package/dist/content/render.js.map +1 -0
- package/dist/content/types-gen.d.ts +40 -0
- package/dist/content/types-gen.d.ts.map +1 -0
- package/dist/content/types-gen.js +200 -0
- package/dist/content/types-gen.js.map +1 -0
- package/dist/help.d.ts +3 -0
- package/dist/help.d.ts.map +1 -0
- package/dist/help.js +142 -0
- package/dist/help.js.map +1 -0
- package/dist/import/coerce.d.ts +34 -0
- package/dist/import/coerce.d.ts.map +1 -0
- package/dist/import/coerce.js +134 -0
- package/dist/import/coerce.js.map +1 -0
- package/dist/import/command.d.ts +25 -0
- package/dist/import/command.d.ts.map +1 -0
- package/dist/import/command.js +127 -0
- package/dist/import/command.js.map +1 -0
- package/dist/import/config.d.ts +39 -0
- package/dist/import/config.d.ts.map +1 -0
- package/dist/import/config.js +48 -0
- package/dist/import/config.js.map +1 -0
- package/dist/import/contentful.d.ts +3 -0
- package/dist/import/contentful.d.ts.map +1 -0
- package/dist/import/contentful.js +179 -0
- package/dist/import/contentful.js.map +1 -0
- package/dist/import/disk.d.ts +4 -0
- package/dist/import/disk.d.ts.map +1 -0
- package/dist/import/disk.js +19 -0
- package/dist/import/disk.js.map +1 -0
- package/dist/import/engine-locales.d.ts +35 -0
- package/dist/import/engine-locales.d.ts.map +1 -0
- package/dist/import/engine-locales.js +61 -0
- package/dist/import/engine-locales.js.map +1 -0
- package/dist/import/engine.d.ts +29 -0
- package/dist/import/engine.d.ts.map +1 -0
- package/dist/import/engine.js +248 -0
- package/dist/import/engine.js.map +1 -0
- package/dist/import/media.d.ts +24 -0
- package/dist/import/media.d.ts.map +1 -0
- package/dist/import/media.js +39 -0
- package/dist/import/media.js.map +1 -0
- package/dist/import/model-fields.d.ts +22 -0
- package/dist/import/model-fields.d.ts.map +1 -0
- package/dist/import/model-fields.js +60 -0
- package/dist/import/model-fields.js.map +1 -0
- package/dist/import/payload/index.d.ts +9 -0
- package/dist/import/payload/index.d.ts.map +1 -0
- package/dist/import/payload/index.js +129 -0
- package/dist/import/payload/index.js.map +1 -0
- package/dist/import/report.d.ts +5 -0
- package/dist/import/report.d.ts.map +1 -0
- package/dist/import/report.js +52 -0
- package/dist/import/report.js.map +1 -0
- package/dist/import/richtext-core.d.ts +26 -0
- package/dist/import/richtext-core.d.ts.map +1 -0
- package/dist/import/richtext-core.js +65 -0
- package/dist/import/richtext-core.js.map +1 -0
- package/dist/import/richtext-html.d.ts +5 -0
- package/dist/import/richtext-html.d.ts.map +1 -0
- package/dist/import/richtext-html.js +311 -0
- package/dist/import/richtext-html.js.map +1 -0
- package/dist/import/richtext-json.d.ts +10 -0
- package/dist/import/richtext-json.d.ts.map +1 -0
- package/dist/import/richtext-json.js +250 -0
- package/dist/import/richtext-json.js.map +1 -0
- package/dist/import/sanity.d.ts +8 -0
- package/dist/import/sanity.d.ts.map +1 -0
- package/dist/import/sanity.js +158 -0
- package/dist/import/sanity.js.map +1 -0
- package/dist/import/strapi-archive.d.ts +6 -0
- package/dist/import/strapi-archive.d.ts.map +1 -0
- package/dist/import/strapi-archive.js +127 -0
- package/dist/import/strapi-archive.js.map +1 -0
- package/dist/import/strapi.d.ts +7 -0
- package/dist/import/strapi.d.ts.map +1 -0
- package/dist/import/strapi.js +185 -0
- package/dist/import/strapi.js.map +1 -0
- package/dist/import/tar.d.ts +3 -0
- package/dist/import/tar.d.ts.map +1 -0
- package/dist/import/tar.js +48 -0
- package/dist/import/tar.js.map +1 -0
- package/dist/import/types.d.ts +157 -0
- package/dist/import/types.d.ts.map +1 -0
- package/dist/import/types.js +12 -0
- package/dist/import/types.js.map +1 -0
- package/dist/import/wordpress.d.ts +15 -0
- package/dist/import/wordpress.d.ts.map +1 -0
- package/dist/import/wordpress.js +147 -0
- package/dist/import/wordpress.js.map +1 -0
- package/dist/publish/scan.d.ts +1 -1
- package/dist/publish/scan.d.ts.map +1 -1
- package/dist/publish/scan.js +2 -2
- package/dist/publish/scan.js.map +1 -1
- package/dist/publish-dir.d.ts +54 -0
- package/dist/publish-dir.d.ts.map +1 -0
- package/dist/publish-dir.js +119 -0
- package/dist/publish-dir.js.map +1 -0
- package/dist/run.d.ts +21 -1
- package/dist/run.d.ts.map +1 -1
- package/dist/run.js +70 -65
- package/dist/run.js.map +1 -1
- package/dist/translations/command.d.ts +36 -0
- package/dist/translations/command.d.ts.map +1 -0
- package/dist/translations/command.js +411 -0
- package/dist/translations/command.js.map +1 -0
- package/dist/translations/extras.d.ts +29 -0
- package/dist/translations/extras.d.ts.map +1 -0
- package/dist/translations/extras.js +123 -0
- package/dist/translations/extras.js.map +1 -0
- package/dist/translations/files.d.ts +22 -0
- package/dist/translations/files.d.ts.map +1 -0
- package/dist/translations/files.js +75 -0
- package/dist/translations/files.js.map +1 -0
- package/dist/translations/sync.d.ts +89 -0
- package/dist/translations/sync.d.ts.map +1 -0
- package/dist/translations/sync.js +215 -0
- package/dist/translations/sync.js.map +1 -0
- package/dist/translations/target.d.ts +33 -0
- package/dist/translations/target.d.ts.map +1 -0
- package/dist/translations/target.js +54 -0
- package/dist/translations/target.js.map +1 -0
- package/dist/translations/xliff.d.ts +29 -0
- package/dist/translations/xliff.d.ts.map +1 -0
- package/dist/translations/xliff.js +62 -0
- package/dist/translations/xliff.js.map +1 -0
- package/package.json +6 -4
|
@@ -0,0 +1,248 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.slugOf = slugOf;
|
|
4
|
+
exports.entryKey = entryKey;
|
|
5
|
+
exports.titleOf = titleOf;
|
|
6
|
+
exports.runImport = runImport;
|
|
7
|
+
/**
|
|
8
|
+
* Lands an `ImportSource` in a content library through the public management
|
|
9
|
+
* API, in the order that makes each step safe to repeat:
|
|
10
|
+
*
|
|
11
|
+
* 1. the model (the source's schema, as a Payload-format config the API's
|
|
12
|
+
* own reader maps), refusing to remove types the library already has;
|
|
13
|
+
* 2. the media, each file once;
|
|
14
|
+
* 3. every entry as a draft, with a deterministic `Idempotency-Key` so a
|
|
15
|
+
* re-run returns the entries the first run made instead of duplicating;
|
|
16
|
+
* 4. the references, written once every entry has an id (a reference may
|
|
17
|
+
* point forward, or in a circle);
|
|
18
|
+
* 5. publishing, last, so a strict type that refuses an entry fails that
|
|
19
|
+
* entry alone and the draft stays.
|
|
20
|
+
*
|
|
21
|
+
* Re-running an import UPDATES what an earlier run made: the key in step 3 is
|
|
22
|
+
* derived from the source's own record id and the server remembers key → entry
|
|
23
|
+
* (`POST …/items/lookup`), so a record seen before is patched in place instead
|
|
24
|
+
* of being skipped as a replay. A source with several languages lands its
|
|
25
|
+
* other locales as the entry's locale twins, after the entries exist.
|
|
26
|
+
*
|
|
27
|
+
* A failure is recorded against the record that caused it and the import
|
|
28
|
+
* goes on; the report is how the author finds out, never a half-written
|
|
29
|
+
* silence.
|
|
30
|
+
*/
|
|
31
|
+
const node_crypto_1 = require("node:crypto");
|
|
32
|
+
const coerce_1 = require("./coerce");
|
|
33
|
+
const scan_1 = require("../publish/scan");
|
|
34
|
+
const engine_locales_1 = require("./engine-locales");
|
|
35
|
+
const media_1 = require("./media");
|
|
36
|
+
const model_fields_1 = require("./model-fields");
|
|
37
|
+
const key = (type, id) => `${type}\u0000${id}`;
|
|
38
|
+
const errMessage = (e) => (e instanceof Error ? e.message : String(e));
|
|
39
|
+
function slugOf(s) {
|
|
40
|
+
// The CLI's mirror of the product rule (publish/scan.ts), at this door's old cap of 100.
|
|
41
|
+
return (0, scan_1.slugify)(s ?? '', '', 100) || undefined;
|
|
42
|
+
}
|
|
43
|
+
/** `Idempotency-Key` for one record: the same export record is the same entry on every run. */
|
|
44
|
+
function entryKey(source, library, r) {
|
|
45
|
+
return `imp-${(0, node_crypto_1.createHash)('sha256').update([source, library, r.type, r.id].join('\u0000')).digest('hex').slice(0, 40)}`;
|
|
46
|
+
}
|
|
47
|
+
function titleOf(r, fields) {
|
|
48
|
+
const pick = (k) => (k && typeof r.values[k] === 'string' && r.values[k].trim() ? r.values[k].trim() : undefined);
|
|
49
|
+
return (r.title?.trim() || pick(fields?.titleField) || pick('title') || pick('name') || r.slug || r.id).slice(0, 300);
|
|
50
|
+
}
|
|
51
|
+
async function runImport(source, deps, opts) {
|
|
52
|
+
const { client } = deps;
|
|
53
|
+
const { orgId, libraryId } = opts;
|
|
54
|
+
const sleep = deps.sleep ?? ((ms) => new Promise((r) => setTimeout(r, ms)));
|
|
55
|
+
const pace = () => (opts.pace > 0 ? sleep(opts.pace) : Promise.resolve());
|
|
56
|
+
const report = {
|
|
57
|
+
source: source.name,
|
|
58
|
+
dryRun: opts.dryRun,
|
|
59
|
+
model: { changed: false, version: null, issues: [] },
|
|
60
|
+
entries: { planned: source.records.length, created: 0, updated: 0, translations: 0, published: 0, failed: [] },
|
|
61
|
+
media: { planned: source.media.length, uploaded: 0, failed: [] },
|
|
62
|
+
dropped: [],
|
|
63
|
+
unresolved: [],
|
|
64
|
+
notes: [...source.notes],
|
|
65
|
+
};
|
|
66
|
+
/* 0. which records an earlier run already made (a dry run shows them as updates) */
|
|
67
|
+
const existing = new Map();
|
|
68
|
+
try {
|
|
69
|
+
const keys = source.records.map((r) => entryKey(source.name, libraryId, r));
|
|
70
|
+
for (let i = 0; i < keys.length; i += 200) {
|
|
71
|
+
const { found } = await client.content.entries.lookup(orgId, libraryId, keys.slice(i, i + 200));
|
|
72
|
+
for (const [k, id] of Object.entries(found))
|
|
73
|
+
existing.set(k, id);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
catch (e) {
|
|
77
|
+
report.notes.push(`Could not check for entries an earlier import made (${errMessage(e)}); every record is treated as new.`);
|
|
78
|
+
}
|
|
79
|
+
const known = (r) => existing.get(entryKey(source.name, libraryId, r));
|
|
80
|
+
const nUpdate = source.records.filter((r) => known(r)).length;
|
|
81
|
+
report.plan = { new: source.records.length - nUpdate, update: nUpdate };
|
|
82
|
+
if (opts.dryRun)
|
|
83
|
+
report.entries.translations = source.records.reduce((n, r) => n + Object.keys(r.locales ?? {}).length, 0);
|
|
84
|
+
/* 1. model */
|
|
85
|
+
if (source.modelSource) {
|
|
86
|
+
const body = { format: 'payload', content: source.modelSource };
|
|
87
|
+
const dry = await client.content.model.import(orgId, libraryId, { ...body, dryRun: true });
|
|
88
|
+
report.model = { changed: dry.changed, version: dry.version, issues: dry.issues };
|
|
89
|
+
const removals = dry.diff.filter((c) => c.op === 'remove' && c.target === 'type');
|
|
90
|
+
if (removals.length && !opts.allowModelRemovals) {
|
|
91
|
+
throw new Error(`The model would remove content types the library has (${removals.map((c) => c.type).join(', ')}). ` +
|
|
92
|
+
'Nothing was imported. Pass --allow-model-removals if that is meant, or import into an empty library.');
|
|
93
|
+
}
|
|
94
|
+
if (opts.dryRun)
|
|
95
|
+
return report;
|
|
96
|
+
if (dry.changed) {
|
|
97
|
+
const applied = await client.content.model.import(orgId, libraryId, body);
|
|
98
|
+
report.model.version = applied.version;
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
else if (opts.dryRun)
|
|
102
|
+
return report;
|
|
103
|
+
/* 2. media */
|
|
104
|
+
const mediaDeps = { client, upload: deps.upload, files: deps.files, fetchBytes: deps.fetchBytes, root: deps.root };
|
|
105
|
+
const uploaded = new Map();
|
|
106
|
+
const byAlias = new Map();
|
|
107
|
+
for (const m of source.media) {
|
|
108
|
+
try {
|
|
109
|
+
const up = await (0, media_1.uploadMedia)(mediaDeps, orgId, libraryId, m);
|
|
110
|
+
uploaded.set(m.id, up);
|
|
111
|
+
for (const a of [m.id, m.location, m.filename, ...(m.aliases ?? [])])
|
|
112
|
+
byAlias.set(a, up);
|
|
113
|
+
if (!up.reused) {
|
|
114
|
+
report.media.uploaded++;
|
|
115
|
+
await pace();
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
catch (e) {
|
|
119
|
+
report.media.failed.push({ id: m.id, message: errMessage(e) });
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
/* 3. model as stored, to know what each declared field is */
|
|
123
|
+
const stored = await client.content.model.get(orgId, libraryId);
|
|
124
|
+
const resolved = new Map();
|
|
125
|
+
const typeOf = (t) => {
|
|
126
|
+
if (!resolved.has(t))
|
|
127
|
+
resolved.set(t, (0, model_fields_1.resolveType)(stored.model, t));
|
|
128
|
+
return resolved.get(t) ?? null;
|
|
129
|
+
};
|
|
130
|
+
const exists = new Set(source.records.map((r) => key(r.type, r.id)));
|
|
131
|
+
const typesById = new Map();
|
|
132
|
+
for (const r of source.records)
|
|
133
|
+
(typesById.get(r.id) ?? typesById.set(r.id, new Set()).get(r.id)).add(r.type);
|
|
134
|
+
const created = new Map();
|
|
135
|
+
const dropped = new Map();
|
|
136
|
+
const unresolved = new Map();
|
|
137
|
+
let finalPass = false;
|
|
138
|
+
let from = '';
|
|
139
|
+
const lookup = (t) => {
|
|
140
|
+
let type = t.type;
|
|
141
|
+
if (!type) {
|
|
142
|
+
const types = typesById.get(t.id);
|
|
143
|
+
if (types?.size === 1)
|
|
144
|
+
type = [...types][0];
|
|
145
|
+
}
|
|
146
|
+
if (type && created.has(key(type, t.id)))
|
|
147
|
+
return created.get(key(type, t.id));
|
|
148
|
+
if (finalPass && !(type && exists.has(key(type, t.id))))
|
|
149
|
+
unresolved.set(`${from}\u0000${t.type ?? '?'}:${t.id}`, `${t.type ?? '?'}:${t.id}`);
|
|
150
|
+
return null;
|
|
151
|
+
};
|
|
152
|
+
const image = (src) => byAlias.get(src)?.url ?? src;
|
|
153
|
+
const ctxFor = (fields, pending, sink = dropped) => ({
|
|
154
|
+
source,
|
|
155
|
+
image,
|
|
156
|
+
asset: (id) => {
|
|
157
|
+
const up = uploaded.get(id) ?? byAlias.get(id);
|
|
158
|
+
return up ? { id: up.id, filename: up.filename } : null;
|
|
159
|
+
},
|
|
160
|
+
entry: lookup,
|
|
161
|
+
blocks: fields.blocks,
|
|
162
|
+
dropped: sink,
|
|
163
|
+
pendingRef: pending,
|
|
164
|
+
});
|
|
165
|
+
/* 4. entries (drafts) */
|
|
166
|
+
const needsRefs = [];
|
|
167
|
+
const skippedTypes = new Map();
|
|
168
|
+
for (const r of source.records) {
|
|
169
|
+
const fields = typeOf(r.type);
|
|
170
|
+
if (!fields) {
|
|
171
|
+
// Not a failure of the record: its type was not mapped (an auth collection, a type the
|
|
172
|
+
// model refused), and the model issues above already say why. Counted so it is not silent.
|
|
173
|
+
skippedTypes.set(r.type, (skippedTypes.get(r.type) ?? 0) + 1);
|
|
174
|
+
continue;
|
|
175
|
+
}
|
|
176
|
+
try {
|
|
177
|
+
from = `${r.type}:${r.id}`;
|
|
178
|
+
const pending = { value: false };
|
|
179
|
+
const params = (0, coerce_1.coerceFields)(fields.fields, r.values, ctxFor(fields, pending), r.type);
|
|
180
|
+
const slug = slugOf(r.slug);
|
|
181
|
+
const before = known(r);
|
|
182
|
+
const res = before
|
|
183
|
+
? await client.content.entries.update(orgId, libraryId, before, { title: titleOf(r, fields), ...(slug ? { slug } : {}), params })
|
|
184
|
+
: await client.content.entries.create(orgId, libraryId, { title: titleOf(r, fields), ...(slug ? { slug } : {}), preset: r.type, params }, entryKey(source.name, libraryId, r));
|
|
185
|
+
created.set(key(r.type, r.id), res.item.id);
|
|
186
|
+
if (before)
|
|
187
|
+
report.entries.updated++;
|
|
188
|
+
else
|
|
189
|
+
report.entries.created++;
|
|
190
|
+
if (pending.value)
|
|
191
|
+
needsRefs.push(r);
|
|
192
|
+
await pace();
|
|
193
|
+
}
|
|
194
|
+
catch (e) {
|
|
195
|
+
report.entries.failed.push({ id: r.id, type: r.type, message: errMessage(e) });
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
/* 5. references, now that every entry has an id */
|
|
199
|
+
finalPass = true;
|
|
200
|
+
for (const r of needsRefs) {
|
|
201
|
+
const id = created.get(key(r.type, r.id));
|
|
202
|
+
const fields = typeOf(r.type);
|
|
203
|
+
try {
|
|
204
|
+
from = `${r.type}:${r.id}`;
|
|
205
|
+
const params = (0, coerce_1.coerceFields)(fields.fields, r.values, ctxFor(fields, { value: false }, new Map()), r.type);
|
|
206
|
+
await client.content.entries.setFields(orgId, libraryId, id, params);
|
|
207
|
+
await pace();
|
|
208
|
+
}
|
|
209
|
+
catch (e) {
|
|
210
|
+
report.entries.failed.push({ id: r.id, type: r.type, message: `references: ${errMessage(e)}` });
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
/* 6. locale twins, once every source entry has an id */
|
|
214
|
+
const twinIds = new Map();
|
|
215
|
+
if (source.records.some((r) => r.locales)) {
|
|
216
|
+
const ready = await (0, engine_locales_1.ensureLanguages)(client, orgId, libraryId, source, report);
|
|
217
|
+
await (0, engine_locales_1.writeTwins)({
|
|
218
|
+
client, orgId, libraryId, records: source.records, ready, ids: created, twinIds, report, pace,
|
|
219
|
+
typeOf, coerce: (decls, values, r) => (0, coerce_1.coerceFields)(decls, values, ctxFor(typeOf(r.type), { value: false }, new Map()), r.type),
|
|
220
|
+
keyOf: (r) => key(r.type, r.id),
|
|
221
|
+
});
|
|
222
|
+
}
|
|
223
|
+
/* 7. publish */
|
|
224
|
+
if (opts.publish !== 'none') {
|
|
225
|
+
for (const r of source.records) {
|
|
226
|
+
const id = created.get(key(r.type, r.id));
|
|
227
|
+
if (!id || (opts.publish === 'source' && !r.published))
|
|
228
|
+
continue;
|
|
229
|
+
for (const target of [id, ...(twinIds.get(key(r.type, r.id)) ?? [])]) {
|
|
230
|
+
try {
|
|
231
|
+
const res = await client.content.entries.publish(orgId, libraryId, target);
|
|
232
|
+
if (res.published !== false && target === id)
|
|
233
|
+
report.entries.published++;
|
|
234
|
+
await pace();
|
|
235
|
+
}
|
|
236
|
+
catch (e) {
|
|
237
|
+
report.entries.failed.push({ id: r.id, type: r.type, message: `publish${target === id ? '' : ' (translation)'}: ${errMessage(e)}` });
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
for (const [t, n] of skippedTypes)
|
|
243
|
+
report.notes.push(`${n} record(s) of "${t}" were skipped: the library has no content type of that name (see the model notes above).`);
|
|
244
|
+
report.dropped = [...dropped].map(([field, count]) => ({ field, count })).sort((a, b) => a.field.localeCompare(b.field));
|
|
245
|
+
report.unresolved = [...unresolved].map(([k, to]) => ({ from: k.split('\u0000')[0], to }));
|
|
246
|
+
return report;
|
|
247
|
+
}
|
|
248
|
+
//# sourceMappingURL=engine.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"engine.js","sourceRoot":"","sources":["../../src/import/engine.ts"],"names":[],"mappings":";;AA0DA,wBAGC;AAGD,4BAEC;AAED,0BAGC;AAED,8BAiMC;AA1QD;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,6CAAyC;AAEzC,qCAAwD;AACxD,0CAA2D;AAC3D,qDAA+D;AAC/D,mCAAyE;AACzE,iDAAkE;AAyBlE,MAAM,GAAG,GAAG,CAAC,IAAY,EAAE,EAAU,EAAE,EAAE,CAAC,GAAG,IAAI,SAAS,EAAE,EAAE,CAAC;AAC/D,MAAM,UAAU,GAAG,CAAC,CAAU,EAAE,EAAE,CAAC,CAAC,CAAC,YAAY,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;AAEhF,SAAgB,MAAM,CAAC,CAAqB;IAC1C,yFAAyF;IACzF,OAAO,IAAA,cAAa,EAAC,CAAC,IAAI,EAAE,EAAE,EAAE,EAAE,GAAG,CAAC,IAAI,SAAS,CAAC;AACtD,CAAC;AAED,+FAA+F;AAC/F,SAAgB,QAAQ,CAAC,MAAc,EAAE,OAAe,EAAE,CAAiC;IACzF,OAAO,OAAO,IAAA,wBAA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B,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { ForumulateClient } from '@forumulate/sdk';
|
|
2
|
+
import type { ImportFiles, SourceMedia } from './types';
|
|
3
|
+
export interface UploadedFile {
|
|
4
|
+
id: string;
|
|
5
|
+
url: string;
|
|
6
|
+
filename: string;
|
|
7
|
+
}
|
|
8
|
+
export interface MediaDeps {
|
|
9
|
+
client: ForumulateClient;
|
|
10
|
+
upload?: (path: string, form: FormData) => Promise<unknown>;
|
|
11
|
+
files: ImportFiles;
|
|
12
|
+
/** Bytes of a remote file. */
|
|
13
|
+
fetchBytes: (url: string) => Promise<Uint8Array>;
|
|
14
|
+
/** Folder that relative `location`s are under. */
|
|
15
|
+
root: string;
|
|
16
|
+
}
|
|
17
|
+
export declare function storedName(bytes: Uint8Array, filename: string): {
|
|
18
|
+
hash: string;
|
|
19
|
+
name: string;
|
|
20
|
+
};
|
|
21
|
+
export declare function uploadMedia(deps: MediaDeps, orgId: string, libraryId: string, m: SourceMedia): Promise<UploadedFile & {
|
|
22
|
+
reused: boolean;
|
|
23
|
+
}>;
|
|
24
|
+
//# sourceMappingURL=media.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"media.d.ts","sourceRoot":"","sources":["../../src/import/media.ts"],"names":[],"mappings":"AAWA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AACxD,OAAO,KAAK,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAExD,MAAM,WAAW,YAAY;IAC3B,EAAE,EAAE,MAAM,CAAC;IACX,GAAG,EAAE,MAAM,CAAC;IACZ,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,SAAS;IACxB,MAAM,EAAE,gBAAgB,CAAC;IACzB,MAAM,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,QAAQ,KAAK,OAAO,CAAC,OAAO,CAAC,CAAC;IAC5D,KAAK,EAAE,WAAW,CAAC;IACnB,8BAA8B;IAC9B,UAAU,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,OAAO,CAAC,UAAU,CAAC,CAAC;IACjD,kDAAkD;IAClD,IAAI,EAAE,MAAM,CAAC;CACd;AAID,wBAAgB,UAAU,CAAC,KAAK,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,GAAG;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,CAG9F;AAED,wBAAsB,WAAW,CAC/B,IAAI,EAAE,SAAS,EACf,KAAK,EAAE,MAAM,EACb,SAAS,EAAE,MAAM,EACjB,CAAC,EAAE,WAAW,GACb,OAAO,CAAC,YAAY,GAAG;IAAE,MAAM,EAAE,OAAO,CAAA;CAAE,CAAC,CAc7C"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.storedName = storedName;
|
|
4
|
+
exports.uploadMedia = uploadMedia;
|
|
5
|
+
/**
|
|
6
|
+
* Files of an export into the library's media, once each.
|
|
7
|
+
*
|
|
8
|
+
* Re-running an import must not store every picture again, so the stored name
|
|
9
|
+
* carries a hash of the bytes (the `forumulate publish` convention) and the
|
|
10
|
+
* library is asked for that name first. Source files are addressed three ways
|
|
11
|
+
* (their own id, their file name, the URL a body links them by); all three
|
|
12
|
+
* resolve to the one asset.
|
|
13
|
+
*/
|
|
14
|
+
const node_crypto_1 = require("node:crypto");
|
|
15
|
+
const node_path_1 = require("node:path");
|
|
16
|
+
const REMOTE = /^https?:\/\//i;
|
|
17
|
+
function storedName(bytes, filename) {
|
|
18
|
+
const hash = (0, node_crypto_1.createHash)('sha256').update(bytes).digest('hex').slice(0, 12);
|
|
19
|
+
return { hash, name: `${hash}-${filename.replace(/[^\w.-]+/g, '-')}` };
|
|
20
|
+
}
|
|
21
|
+
async function uploadMedia(deps, orgId, libraryId, m) {
|
|
22
|
+
const bytes = REMOTE.test(m.location)
|
|
23
|
+
? await deps.fetchBytes(m.location)
|
|
24
|
+
: deps.files.readBytes((0, node_path_1.isAbsolute)(m.location) ? m.location : (0, node_path_1.join)(deps.root, m.location));
|
|
25
|
+
const { hash, name } = storedName(bytes, m.filename);
|
|
26
|
+
const found = await deps.client.content.assets.list(orgId, libraryId, { search: hash, limit: 50 });
|
|
27
|
+
const hit = found.assets.find((a) => a.filename === name);
|
|
28
|
+
if (hit)
|
|
29
|
+
return { id: hit.id, url: hit.url, filename: hit.filename, reused: true };
|
|
30
|
+
if (!deps.upload)
|
|
31
|
+
throw new Error('asset upload is not available in this environment');
|
|
32
|
+
const form = new FormData();
|
|
33
|
+
form.set('file', new Blob([Buffer.from(bytes)], m.contentType ? { type: m.contentType } : undefined), name);
|
|
34
|
+
const res = (await deps.upload(`/orgs/${orgId}/content/libraries/${libraryId}/assets`, form));
|
|
35
|
+
if (!res.asset?.id)
|
|
36
|
+
throw new Error(`upload of ${m.filename} answered without an asset`);
|
|
37
|
+
return { id: res.asset.id, url: res.asset.url, filename: res.asset.filename ?? name, reused: false };
|
|
38
|
+
}
|
|
39
|
+
//# sourceMappingURL=media.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"media.js","sourceRoot":"","sources":["../../src/import/media.ts"],"names":[],"mappings":";;AAgCA,gCAGC;AAED,kCAmBC;AAxDD;;;;;;;;GAQG;AACH,6CAAyC;AACzC,yCAA6C;AAoB7C,MAAM,MAAM,GAAG,eAAe,CAAC;AAE/B,SAAgB,UAAU,CAAC,KAAiB,EAAE,QAAgB;IAC5D,MAAM,IAAI,GAAG,IAAA,wBAAU,EAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;IAC3E,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,GAAG,IAAI,IAAI,Q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,GAAG,IAAI,QAAQ,EAAE,CAAC;IAC5B,IAAI,CAAC,GAAG,CAAC,MAAM,EAAE,IAAI,IAAI,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC,EAAE,IAAI,CAAC,CAAC;IAC5G,MAAM,GAAG,GAAG,CAAC,MAAM,IAAI,CAAC,MAAM,CAAC,SAAS,KAAK,sBAAsB,SAAS,SAAS,EAAE,IAAI,CAAC,CAA6B,CAAC;IAC1H,IAAI,CAAC,GAAG,CAAC,KAAK,EAAE,EAAE;QAAE,MAAM,IAAI,KAAK,CAAC,aAAa,CAAC,CAAC,QAAQ,4BAA4B,CAAC,CAAC;IACzF,OAAO,EAAE,EAAE,EAAE,GAAG,CAAC,KAAK,CAAC,EAAE,EAAE,GAAG,EAAE,GAAG,CAAC,KAAK,CAAC,GAAG,EAAE,QAAQ,EAAE,GAAG,CAAC,KAAK,CAAC,QAAQ,IAAI,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC;AACvG,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The fields of a content type, read off the library's STORED model.
|
|
3
|
+
*
|
|
4
|
+
* A stored type is a patch over the library-wide shape (`patch.params` is a
|
|
5
|
+
* list patch: `add`, `omit`, `set`, `order`), so the importer, which needs to
|
|
6
|
+
* know what a field IS to convert a value into it, applies the same four
|
|
7
|
+
* verbs. It reads only what a conversion needs (key, type, nesting, targets),
|
|
8
|
+
* and the API remains the judge of the values: an entry that does not fit is
|
|
9
|
+
* refused there, with the field named.
|
|
10
|
+
*/
|
|
11
|
+
import type { ContentModel } from '@forumulate/sdk';
|
|
12
|
+
import type { FieldDecl } from './types';
|
|
13
|
+
type Obj = Record<string, unknown>;
|
|
14
|
+
export declare function applyListPatch(base: Obj[], patch: unknown): Obj[];
|
|
15
|
+
export interface ResolvedFields {
|
|
16
|
+
fields: FieldDecl[];
|
|
17
|
+
blocks: Map<string, FieldDecl[]>;
|
|
18
|
+
titleField?: string;
|
|
19
|
+
}
|
|
20
|
+
export declare function resolveType(model: Pick<ContentModel, 'shape' | 'types'>, typeKey: string): ResolvedFields | null;
|
|
21
|
+
export {};
|
|
22
|
+
//# sourceMappingURL=model-fields.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"model-fields.d.ts","sourceRoot":"","sources":["../../src/import/model-fields.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AACpD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAEzC,KAAK,GAAG,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAWnC,wBAAgB,cAAc,CAAC,IAAI,EAAE,GAAG,EAAE,EAAE,KAAK,EAAE,OAAO,GAAG,GAAG,EAAE,CAuBjE;AAcD,MAAM,WAAW,cAAc;IAC7B,MAAM,EAAE,SAAS,EAAE,CAAC;IACpB,MAAM,EAAE,GAAG,CAAC,MAAM,EAAE,SAAS,EAAE,CAAC,CAAC;IACjC,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,wBAAgB,WAAW,CAAC,KAAK,EAAE,IAAI,CAAC,YAAY,EAAE,OAAO,GAAG,OAAO,CAAC,EAAE,OAAO,EAAE,MAAM,GAAG,cAAc,GAAG,IAAI,CAWhH"}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.applyListPatch = applyListPatch;
|
|
4
|
+
exports.resolveType = resolveType;
|
|
5
|
+
const isObj = (v) => typeof v === 'object' && v !== null && !Array.isArray(v);
|
|
6
|
+
function applyListPatch(base, patch) {
|
|
7
|
+
if (!isObj(patch))
|
|
8
|
+
return base;
|
|
9
|
+
const p = patch;
|
|
10
|
+
let out = base.filter((f) => !p.omit?.includes(String(f.key)));
|
|
11
|
+
out = out.map((f) => {
|
|
12
|
+
const key = String(f.key);
|
|
13
|
+
let next = f;
|
|
14
|
+
const set = p.set?.[key];
|
|
15
|
+
if (set)
|
|
16
|
+
next = { ...next, ...set };
|
|
17
|
+
const unset = p.unset?.[key];
|
|
18
|
+
if (unset)
|
|
19
|
+
next = Object.fromEntries(Object.entries(next).filter(([k]) => !unset.includes(k)));
|
|
20
|
+
return next;
|
|
21
|
+
});
|
|
22
|
+
for (const add of p.add ?? []) {
|
|
23
|
+
const at = out.findIndex((f) => f.key === add.key);
|
|
24
|
+
if (at >= 0)
|
|
25
|
+
out[at] = add;
|
|
26
|
+
else
|
|
27
|
+
out.push(add);
|
|
28
|
+
}
|
|
29
|
+
if (p.order) {
|
|
30
|
+
const rank = new Map(p.order.map((k, i) => [k, i]));
|
|
31
|
+
out = [...out].sort((a, b) => (rank.get(String(a.key)) ?? 1e9) - (rank.get(String(b.key)) ?? 1e9));
|
|
32
|
+
}
|
|
33
|
+
return out;
|
|
34
|
+
}
|
|
35
|
+
function decl(f) {
|
|
36
|
+
const to = Array.isArray(f.to) ? f.to.filter(isObj).map((t) => ({ kind: String(t.kind), types: Array.isArray(t.types) ? t.types.map(String) : undefined })) : undefined;
|
|
37
|
+
return {
|
|
38
|
+
key: String(f.key),
|
|
39
|
+
type: String(f.type),
|
|
40
|
+
...(f.hasMany ? { hasMany: true } : {}),
|
|
41
|
+
...(f.localized ? { localized: true } : {}),
|
|
42
|
+
...(Array.isArray(f.fields) ? { fields: f.fields.filter(isObj).map(decl) } : {}),
|
|
43
|
+
...(to ? { to } : {}),
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
function resolveType(model, typeKey) {
|
|
47
|
+
const kind = model.types[typeKey];
|
|
48
|
+
if (!isObj(kind))
|
|
49
|
+
return null;
|
|
50
|
+
const patch = isObj(kind.patch) ? kind.patch : {};
|
|
51
|
+
const shape = model.shape;
|
|
52
|
+
const fields = applyListPatch(applyListPatch([], shape.params), patch.params).map(decl);
|
|
53
|
+
const blockList = applyListPatch(applyListPatch([], shape.blockTypes), patch.blockTypes);
|
|
54
|
+
const blocks = new Map();
|
|
55
|
+
for (const b of blockList)
|
|
56
|
+
blocks.set(String(b.key), Array.isArray(b.fields) ? b.fields.filter(isObj).map(decl) : []);
|
|
57
|
+
const settings = isObj(kind.settings) ? kind.settings : {};
|
|
58
|
+
return { fields, blocks, ...(typeof settings.titleField === 'string' ? { titleField: settings.titleField } : {}) };
|
|
59
|
+
}
|
|
60
|
+
//# sourceMappingURL=model-fields.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"model-fields.js","sourceRoot":"","sources":["../../src/import/model-fields.ts"],"names":[],"mappings":";;AAwBA,wCAuBC;AAoBD,kCAWC;AAhED,MAAM,KAAK,GAAG,CAAC,CAAU,EAAY,EAAE,CAAC,OAAO,CAAC,KAAK,QAAQ,IAAI,CAAC,KAAK,IAAI,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;AAUjG,SAAgB,cAAc,CAAC,IAAW,EAAE,KAAc;IACxD,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC;QAAE,OAAO,IAAI,CAAC;IAC/B,MAAM,CAAC,GAAG,KAAkB,CAAC;IAC7B,IAAI,GAAG,GAAG,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;IAC/D,GAAG,GAAG,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE;QAClB,MAAM,GAAG,GAAG,MAAM,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;QAC1B,IAAI,IAAI,GAAG,CAAC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E,GAAG,CAAC,OAAO,QAAQ,CAAC,UAAU,KAAK,QAAQ,CAAC,CAAC,CAAC,EAAE,UAAU,EAAE,QAAQ,CAAC,UAAU,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC;AACrH,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { ImportFiles, ImportSource } from '../types';
|
|
2
|
+
export interface PayloadOptions {
|
|
3
|
+
/** The config file; omitted when the library's model already exists. */
|
|
4
|
+
configPath?: string;
|
|
5
|
+
/** Upload collections' slugs; defaults to `media`. */
|
|
6
|
+
mediaCollections?: string[];
|
|
7
|
+
}
|
|
8
|
+
export declare function readPayloadExport(dir: string, files: ImportFiles, opts?: PayloadOptions): ImportSource;
|
|
9
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/import/payload/index.ts"],"names":[],"mappings":"AAiBA,OAAO,KAAK,EAAa,WAAW,EAAE,YAAY,EAAqC,MAAM,UAAU,CAAC;AAMxG,MAAM,WAAW,cAAc;IAC7B,wEAAwE;IACxE,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,sDAAsD;IACtD,gBAAgB,CAAC,EAAE,MAAM,EAAE,CAAC;CAC7B;AAQD,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,WAAW,EAAE,IAAI,GAAE,cAAmB,GAAG,YAAY,CA2F1G"}
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.readPayloadExport = readPayloadExport;
|
|
4
|
+
/**
|
|
5
|
+
* Payload CMS: `payload.config.ts` + a data export.
|
|
6
|
+
*
|
|
7
|
+
* The CONFIG is handed to the API as it is (`format: 'payload'`): the API's
|
|
8
|
+
* Payload reader owns the config-to-model mapping and the list of what it
|
|
9
|
+
* could not map (hooks, access functions, custom components), so this
|
|
10
|
+
* importer neither has a second mapping nor a second opinion about it.
|
|
11
|
+
*
|
|
12
|
+
* The DATA is what Payload's REST/Local API gives for each collection: one
|
|
13
|
+
* `<slug>.json` per collection (an array, or Payload's `{ docs: [...] }`),
|
|
14
|
+
* one `globals/<slug>.json` per global, and `media.json` (or the upload
|
|
15
|
+
* collection's own `<slug>.json`) for uploaded files, whose bytes are in
|
|
16
|
+
* `media/` or at the doc's `url`. Fetched with `depth=0` the relationships
|
|
17
|
+
* are ids; fetched deeper they are documents, and both are understood.
|
|
18
|
+
*/
|
|
19
|
+
const node_path_1 = require("node:path");
|
|
20
|
+
const richtext_json_1 = require("../richtext-json");
|
|
21
|
+
const isObj = (v) => typeof v === 'object' && v !== null && !Array.isArray(v);
|
|
22
|
+
const idOf = (v) => (typeof v === 'string' || typeof v === 'number' ? String(v) : isObj(v) && (typeof v.id === 'string' || typeof v.id === 'number') ? String(v.id) : null);
|
|
23
|
+
function docsOf(text) {
|
|
24
|
+
const parsed = JSON.parse(text);
|
|
25
|
+
const list = Array.isArray(parsed) ? parsed : isObj(parsed) && Array.isArray(parsed.docs) ? parsed.docs : isObj(parsed) ? [parsed] : [];
|
|
26
|
+
return list.filter(isObj);
|
|
27
|
+
}
|
|
28
|
+
function readPayloadExport(dir, files, opts = {}) {
|
|
29
|
+
const notes = [];
|
|
30
|
+
const mediaSlugs = new Set(opts.mediaCollections ?? ['media']);
|
|
31
|
+
const modelSource = opts.configPath ? files.read(opts.configPath) : undefined;
|
|
32
|
+
const read = (sub, name) => docsOf(files.read((0, node_path_1.join)(dir, sub, name)));
|
|
33
|
+
const collections = files.list(dir).filter((n) => n.endsWith('.json')).map((n) => n.slice(0, -5));
|
|
34
|
+
const globals = files.exists((0, node_path_1.join)(dir, 'globals')) ? files.list((0, node_path_1.join)(dir, 'globals')).filter((n) => n.endsWith('.json')).map((n) => n.slice(0, -5)) : [];
|
|
35
|
+
const media = [];
|
|
36
|
+
const mediaIds = new Set();
|
|
37
|
+
const addMedia = (d) => {
|
|
38
|
+
const id = idOf(d);
|
|
39
|
+
if (!id)
|
|
40
|
+
return null;
|
|
41
|
+
if (mediaIds.has(id))
|
|
42
|
+
return id;
|
|
43
|
+
const filename = typeof d.filename === 'string' ? d.filename : typeof d.url === 'string' ? decodeURIComponent(d.url.split('/').pop() ?? '') : '';
|
|
44
|
+
const url = typeof d.url === 'string' ? d.url : '';
|
|
45
|
+
if (!filename)
|
|
46
|
+
return null;
|
|
47
|
+
const local = (0, node_path_1.join)(dir, 'media', filename);
|
|
48
|
+
const location = files.exists(local) ? local : /^https?:/i.test(url) ? url : local;
|
|
49
|
+
mediaIds.add(id);
|
|
50
|
+
media.push({
|
|
51
|
+
id,
|
|
52
|
+
filename,
|
|
53
|
+
location,
|
|
54
|
+
...(typeof d.alt === 'string' ? { alt: d.alt } : {}),
|
|
55
|
+
...(typeof d.mimeType === 'string' ? { contentType: d.mimeType } : {}),
|
|
56
|
+
aliases: [url, `/api/media/file/${filename}`, `/media/${filename}`].filter(Boolean),
|
|
57
|
+
});
|
|
58
|
+
return id;
|
|
59
|
+
};
|
|
60
|
+
const records = [];
|
|
61
|
+
const addRecords = (slug, docs, global) => {
|
|
62
|
+
docs.forEach((d, i) => {
|
|
63
|
+
const id = global ? slug : idOf(d);
|
|
64
|
+
if (!id)
|
|
65
|
+
return void notes.push(`${slug}[${i}] has no id and was skipped.`);
|
|
66
|
+
const { id: _id, createdAt: _c, updatedAt: _u, _status, ...values } = d;
|
|
67
|
+
records.push({
|
|
68
|
+
type: slug,
|
|
69
|
+
id,
|
|
70
|
+
// A collection without drafts has no `_status`: everything in it is live.
|
|
71
|
+
published: _status === undefined || _status === 'published',
|
|
72
|
+
...(typeof d.slug === 'string' ? { slug: d.slug } : {}),
|
|
73
|
+
...(typeof d.title === 'string' ? { title: d.title } : {}),
|
|
74
|
+
values,
|
|
75
|
+
});
|
|
76
|
+
});
|
|
77
|
+
};
|
|
78
|
+
for (const slug of collections) {
|
|
79
|
+
const docs = read('', `${slug}.json`);
|
|
80
|
+
if (mediaSlugs.has(slug))
|
|
81
|
+
docs.forEach(addMedia);
|
|
82
|
+
else
|
|
83
|
+
addRecords(slug, docs, false);
|
|
84
|
+
}
|
|
85
|
+
for (const slug of globals)
|
|
86
|
+
addRecords(slug, read('globals', `${slug}.json`), true);
|
|
87
|
+
// Files embedded in a record (fetched with depth > 0, or a Lexical upload node) are media too;
|
|
88
|
+
// they must be known before the engine uploads, so they are found now, not when a field is read.
|
|
89
|
+
const scan = (v, depth = 0) => {
|
|
90
|
+
if (depth > 40)
|
|
91
|
+
return;
|
|
92
|
+
if (Array.isArray(v))
|
|
93
|
+
return v.forEach((x) => scan(x, depth + 1));
|
|
94
|
+
if (!isObj(v))
|
|
95
|
+
return;
|
|
96
|
+
if (typeof v.filename === 'string' && typeof v.url === 'string' && idOf(v))
|
|
97
|
+
addMedia(v);
|
|
98
|
+
for (const x of Object.values(v))
|
|
99
|
+
scan(x, depth + 1);
|
|
100
|
+
};
|
|
101
|
+
records.forEach((r) => scan(r.values));
|
|
102
|
+
if (!records.length)
|
|
103
|
+
notes.push(`No collection data found in ${dir} (expected <collection>.json files).`);
|
|
104
|
+
return {
|
|
105
|
+
name: 'payload',
|
|
106
|
+
modelSource,
|
|
107
|
+
records,
|
|
108
|
+
media,
|
|
109
|
+
notes,
|
|
110
|
+
richText: (raw, image) => (0, richtext_json_1.fromLexical)(raw, image, (v) => media.find((m) => m.id === idOf(v))?.aliases?.[0] ?? null),
|
|
111
|
+
mediaId: (raw) => {
|
|
112
|
+
const id = idOf(raw);
|
|
113
|
+
return id && mediaIds.has(id) ? id : null;
|
|
114
|
+
},
|
|
115
|
+
refs: (raw, field) => {
|
|
116
|
+
const only = field.to?.length === 1 && field.to[0].types?.length === 1 ? field.to[0].types[0] : undefined;
|
|
117
|
+
return (Array.isArray(raw) ? raw : [raw]).flatMap((v) => {
|
|
118
|
+
// Polymorphic: { relationTo, value } where value is an id or a document.
|
|
119
|
+
if (isObj(v) && typeof v.relationTo === 'string' && 'value' in v) {
|
|
120
|
+
const id = idOf(v.value);
|
|
121
|
+
return id ? [{ type: v.relationTo, id }] : [];
|
|
122
|
+
}
|
|
123
|
+
const id = idOf(v);
|
|
124
|
+
return id ? [{ ...(only ? { type: only } : {}), id }] : [];
|
|
125
|
+
});
|
|
126
|
+
},
|
|
127
|
+
};
|
|
128
|
+
}
|
|
129
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/import/payload/index.ts"],"names":[],"mappings":";;AAoCA,8CA2FC;AA/HD;;;;;;;;;;;;;;GAcG;AACH,yCAAiC;AACjC,oDAA+C;AAI/C,MAAM,KAAK,GAAG,CAAC,CAAU,EAAY,EAAE,CAAC,OAAO,CAAC,KAAK,QAAQ,IAAI,CAAC,KAAK,IAAI,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;AACjG,MAAM,IAAI,GAAG,CAAC,CAAU,EAAiB,EAAE,CAAC,CAAC,OAAO,CAAC,KAAK,QAAQ,IAAI,OAAO,CAAC,KAAK,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,EAAE,KAAK,QAAQ,IAAI,OAAO,CAAC,CAAC,EAAE,KAAK,QAAQ,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;AASpM,SAAS,MAAM,CAAC,IAAY;IAC1B,MAAM,MAAM,GAAY,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IACzC,MAAM,IAAI,GAAG,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,KAAK,CAAC,MAA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AC3C,MAAM,IAAI,GAAG,KAAK,CAAC,EAAE,EAAE,MAAM,KAAK,CAAC,IAAI,KAAK,CAAC,EAAE,CAAC,CAAC,CAAE,CAAC,KAAK,EAAE,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,CAAE,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;YAC5G,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,EAAe,EAAE;gBACnE,yEAAyE;gBACzE,IAAI,KAAK,CAAC,CAAC,CAAC,IAAI,OAAO,CAAC,CAAC,UAAU,KAAK,QAAQ,IAAI,OAAO,IAAI,CAAC,EAAE,CAAC;oBACjE,MAAM,EAAE,GAAG,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC;oBACzB,OAAO,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,UAAU,EAAE,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;gBAChD,CAAC;gBACD,MAAM,EAAE,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC;gBACnB,OAAO,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;YAC7D,CAAC,CAAC,CAAC;QACL,CAAC;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { ImportReport } from './types';
|
|
2
|
+
export declare function reportLines(r: ImportReport): string[];
|
|
3
|
+
/** Non-zero when anything failed, so a script can tell a clean import from a partial one. */
|
|
4
|
+
export declare const exitCode: (r: ImportReport) => number;
|
|
5
|
+
//# sourceMappingURL=report.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"report.d.ts","sourceRoot":"","sources":["../../src/import/report.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAE5C,wBAAgB,WAAW,CAAC,CAAC,EAAE,YAAY,GAAG,MAAM,EAAE,CA8BrD;AAED,6FAA6F;AAC7F,eAAO,MAAM,QAAQ,GAAI,GAAG,YAAY,KAAG,MAAoE,CAAC"}
|