sf-plugin-cms 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +277 -0
- package/lib/commands/cms/command-base.d.ts +16 -0
- package/lib/commands/cms/command-base.js +42 -0
- package/lib/commands/cms/command-base.js.map +1 -0
- package/lib/commands/cms/export/workspace.d.ts +14 -0
- package/lib/commands/cms/export/workspace.js +42 -0
- package/lib/commands/cms/export/workspace.js.map +1 -0
- package/lib/commands/cms/get/channel.d.ts +13 -0
- package/lib/commands/cms/get/channel.js +23 -0
- package/lib/commands/cms/get/channel.js.map +1 -0
- package/lib/commands/cms/get/content.d.ts +17 -0
- package/lib/commands/cms/get/content.js +35 -0
- package/lib/commands/cms/get/content.js.map +1 -0
- package/lib/commands/cms/get/variant.d.ts +13 -0
- package/lib/commands/cms/get/variant.js +23 -0
- package/lib/commands/cms/get/variant.js.map +1 -0
- package/lib/commands/cms/get/workspace.d.ts +13 -0
- package/lib/commands/cms/get/workspace.js +23 -0
- package/lib/commands/cms/get/workspace.js.map +1 -0
- package/lib/commands/cms/import/workspace.d.ts +18 -0
- package/lib/commands/cms/import/workspace.js +77 -0
- package/lib/commands/cms/import/workspace.js.map +1 -0
- package/lib/commands/cms/info.d.ts +12 -0
- package/lib/commands/cms/info.js +13 -0
- package/lib/commands/cms/info.js.map +1 -0
- package/lib/commands/cms/list/channel.d.ts +15 -0
- package/lib/commands/cms/list/channel.js +28 -0
- package/lib/commands/cms/list/channel.js.map +1 -0
- package/lib/commands/cms/list/workspace.d.ts +15 -0
- package/lib/commands/cms/list/workspace.js +27 -0
- package/lib/commands/cms/list/workspace.js.map +1 -0
- package/lib/generated/operations.d.ts +233 -0
- package/lib/generated/operations.js +317 -0
- package/lib/generated/operations.js.map +1 -0
- package/lib/index.d.ts +8 -0
- package/lib/index.js +9 -0
- package/lib/index.js.map +1 -0
- package/lib/openapi/generate.d.ts +30 -0
- package/lib/openapi/generate.js +150 -0
- package/lib/openapi/generate.js.map +1 -0
- package/lib/openapi/intake.d.ts +26 -0
- package/lib/openapi/intake.js +176 -0
- package/lib/openapi/intake.js.map +1 -0
- package/lib/openapi/selected.d.ts +11 -0
- package/lib/openapi/selected.js +49 -0
- package/lib/openapi/selected.js.map +1 -0
- package/lib/services/export-workspace.d.ts +37 -0
- package/lib/services/export-workspace.js +214 -0
- package/lib/services/export-workspace.js.map +1 -0
- package/lib/services/import-workspace.d.ts +112 -0
- package/lib/services/import-workspace.js +570 -0
- package/lib/services/import-workspace.js.map +1 -0
- package/lib/services/read.d.ts +20 -0
- package/lib/services/read.js +73 -0
- package/lib/services/read.js.map +1 -0
- package/lib/services/write.d.ts +27 -0
- package/lib/services/write.js +21 -0
- package/lib/services/write.js.map +1 -0
- package/lib/transport/json-mutation.d.ts +15 -0
- package/lib/transport/json-mutation.js +81 -0
- package/lib/transport/json-mutation.js.map +1 -0
- package/lib/transport/json-request.d.ts +26 -0
- package/lib/transport/json-request.js +135 -0
- package/lib/transport/json-request.js.map +1 -0
- package/lib/transport/redact-secrets.d.ts +6 -0
- package/lib/transport/redact-secrets.js +31 -0
- package/lib/transport/redact-secrets.js.map +1 -0
- package/messages/cms.export.workspace.md +29 -0
- package/messages/cms.get.channel.md +25 -0
- package/messages/cms.get.content.md +41 -0
- package/messages/cms.get.variant.md +25 -0
- package/messages/cms.get.workspace.md +25 -0
- package/messages/cms.import.workspace.md +45 -0
- package/messages/cms.list.channel.md +33 -0
- package/messages/cms.list.workspace.md +32 -0
- package/package.json +98 -0
|
@@ -0,0 +1,570 @@
|
|
|
1
|
+
import { createHash, randomUUID } from 'node:crypto';
|
|
2
|
+
import { lstat, mkdir, open, readFile, readdir, realpath, rename, rm } from 'node:fs/promises';
|
|
3
|
+
import path from 'node:path';
|
|
4
|
+
import { CmsRequestError } from '../transport/json-request.js';
|
|
5
|
+
import { getContent } from './read.js';
|
|
6
|
+
import { createContent, createVariant, } from './write.js';
|
|
7
|
+
export class WorkspaceImportOwnershipUncertainError extends Error {
|
|
8
|
+
operation;
|
|
9
|
+
state = 'ownership-uncertain';
|
|
10
|
+
constructor(operation, cause) {
|
|
11
|
+
super(`CMS mutation may have succeeded, but its result could not be persisted for ${operation.contentKey}/${operation.language}; reconcile operation ${operation.operationId} before any new apply`, { cause });
|
|
12
|
+
this.name = 'WorkspaceImportOwnershipUncertainError';
|
|
13
|
+
this.operation = operation;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
function isRecord(value) {
|
|
17
|
+
return typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
18
|
+
}
|
|
19
|
+
function nonemptyString(value) {
|
|
20
|
+
return typeof value === 'string' && value.length > 0;
|
|
21
|
+
}
|
|
22
|
+
function integerAtLeastZero(value) {
|
|
23
|
+
return typeof value === 'number' && Number.isInteger(value) && value >= 0;
|
|
24
|
+
}
|
|
25
|
+
function assertJsonSafe(value, label) {
|
|
26
|
+
if (value === null || typeof value === 'string' || typeof value === 'boolean')
|
|
27
|
+
return;
|
|
28
|
+
if (typeof value === 'number' && Number.isFinite(value))
|
|
29
|
+
return;
|
|
30
|
+
if (Array.isArray(value)) {
|
|
31
|
+
for (const item of value)
|
|
32
|
+
assertJsonSafe(item, label);
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
if (isRecord(value)) {
|
|
36
|
+
for (const item of Object.values(value))
|
|
37
|
+
assertJsonSafe(item, label);
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
throw new TypeError(`${label} must be JSON-safe`);
|
|
41
|
+
}
|
|
42
|
+
function assertPlainObject(value, label) {
|
|
43
|
+
if (!isRecord(value))
|
|
44
|
+
throw new TypeError(`${label} must be an object`);
|
|
45
|
+
assertJsonSafe(value, label);
|
|
46
|
+
}
|
|
47
|
+
function assertIdentifier(value, label) {
|
|
48
|
+
if (!nonemptyString(value))
|
|
49
|
+
throw new TypeError(`${label} must be a nonempty string`);
|
|
50
|
+
if (value.includes('/') || value.includes('\\')) {
|
|
51
|
+
throw new TypeError(`${label} must not contain path separators`);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
function assertOptionalString(record, key, label) {
|
|
55
|
+
if (record[key] !== undefined && !nonemptyString(record[key])) {
|
|
56
|
+
throw new TypeError(`${label}.${key} must be a nonempty string when present`);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
function parseJson(bytes, label) {
|
|
60
|
+
try {
|
|
61
|
+
return JSON.parse(bytes);
|
|
62
|
+
}
|
|
63
|
+
catch {
|
|
64
|
+
throw new TypeError(`${label} must contain valid JSON`);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
function validateWarning(value, index) {
|
|
68
|
+
if (!isRecord(value) || !nonemptyString(value.code) || !nonemptyString(value.message)) {
|
|
69
|
+
throw new TypeError(`manifest.warnings[${index}] is malformed`);
|
|
70
|
+
}
|
|
71
|
+
const codes = new Set([
|
|
72
|
+
'COUNT_MISMATCH',
|
|
73
|
+
'DETAIL_FAILED',
|
|
74
|
+
'DUPLICATE_VARIANTS',
|
|
75
|
+
'OWNERSHIP_MISMATCH',
|
|
76
|
+
'PREMATURE_EMPTY_PAGE',
|
|
77
|
+
'UNSUPPORTED_WILDCARD',
|
|
78
|
+
]);
|
|
79
|
+
if (!codes.has(value.code))
|
|
80
|
+
throw new TypeError(`manifest.warnings[${index}].code is unsupported`);
|
|
81
|
+
if (value.variantIds !== undefined &&
|
|
82
|
+
(!Array.isArray(value.variantIds) || !value.variantIds.every(nonemptyString))) {
|
|
83
|
+
throw new TypeError(`manifest.warnings[${index}].variantIds is malformed`);
|
|
84
|
+
}
|
|
85
|
+
return value;
|
|
86
|
+
}
|
|
87
|
+
function validateManifest(value) {
|
|
88
|
+
if (!isRecord(value))
|
|
89
|
+
throw new TypeError('manifest.json must contain an object');
|
|
90
|
+
if (value.schemaVersion !== 1)
|
|
91
|
+
throw new TypeError('Only workspace export schemaVersion 1 is supported');
|
|
92
|
+
if (value.mode !== 'experimental-best-effort') {
|
|
93
|
+
throw new TypeError('Only experimental-best-effort workspace exports are supported');
|
|
94
|
+
}
|
|
95
|
+
assertIdentifier(value.workspaceId, 'manifest.workspaceId');
|
|
96
|
+
for (const key of ['expectedCount', 'foundCount', 'exportedCount', 'pagesRequested']) {
|
|
97
|
+
if (!integerAtLeastZero(value[key]))
|
|
98
|
+
throw new TypeError(`manifest.${key} is malformed`);
|
|
99
|
+
}
|
|
100
|
+
if (!isRecord(value.search))
|
|
101
|
+
throw new TypeError('manifest.search is malformed');
|
|
102
|
+
const search = value.search;
|
|
103
|
+
if (!Array.isArray(search.contentSpaceOrFolderIds) ||
|
|
104
|
+
search.contentSpaceOrFolderIds.length !== 1 ||
|
|
105
|
+
search.contentSpaceOrFolderIds[0] !== value.workspaceId ||
|
|
106
|
+
!Array.isArray(search.languages) ||
|
|
107
|
+
search.languages.length !== 1 ||
|
|
108
|
+
search.languages[0] !== 'All' ||
|
|
109
|
+
search.pageSize !== 250 ||
|
|
110
|
+
search.queryTerm !== '*') {
|
|
111
|
+
throw new TypeError('manifest.search does not match the schemaVersion 1 export contract');
|
|
112
|
+
}
|
|
113
|
+
if (!Array.isArray(value.entries))
|
|
114
|
+
throw new TypeError('manifest.entries must be an array');
|
|
115
|
+
if (!Array.isArray(value.rejectedVariantIds) || !value.rejectedVariantIds.every(nonemptyString)) {
|
|
116
|
+
throw new TypeError('manifest.rejectedVariantIds is malformed');
|
|
117
|
+
}
|
|
118
|
+
if (!Array.isArray(value.failedVariantIds) || !value.failedVariantIds.every(nonemptyString)) {
|
|
119
|
+
throw new TypeError('manifest.failedVariantIds is malformed');
|
|
120
|
+
}
|
|
121
|
+
if (!Array.isArray(value.warnings))
|
|
122
|
+
throw new TypeError('manifest.warnings must be an array');
|
|
123
|
+
for (const [index, warning] of value.warnings.entries())
|
|
124
|
+
validateWarning(warning, index);
|
|
125
|
+
return value;
|
|
126
|
+
}
|
|
127
|
+
function safeEntryPath(sourceDirectory, file, variantId) {
|
|
128
|
+
if (!nonemptyString(file))
|
|
129
|
+
throw new TypeError(`Manifest entry ${variantId} has no file`);
|
|
130
|
+
if (path.isAbsolute(file) || file.includes('\\')) {
|
|
131
|
+
throw new TypeError(`Manifest entry ${variantId} has an unsafe file path`);
|
|
132
|
+
}
|
|
133
|
+
const segments = file.split('/');
|
|
134
|
+
if (segments.some((segment) => segment.length === 0 || segment === '.' || segment === '..')) {
|
|
135
|
+
throw new TypeError(`Manifest entry ${variantId} has an unsafe file path`);
|
|
136
|
+
}
|
|
137
|
+
if (segments.length !== 2 || segments[0] !== 'items' || segments[1] !== `${variantId}.json`) {
|
|
138
|
+
throw new TypeError(`Manifest entry ${variantId} has a substituted file mapping`);
|
|
139
|
+
}
|
|
140
|
+
return path.join(sourceDirectory, ...segments);
|
|
141
|
+
}
|
|
142
|
+
async function assertRegularFile(file, label) {
|
|
143
|
+
let metadata;
|
|
144
|
+
try {
|
|
145
|
+
metadata = await lstat(file);
|
|
146
|
+
}
|
|
147
|
+
catch (error) {
|
|
148
|
+
if (isRecord(error) && error.code === 'ENOENT') {
|
|
149
|
+
throw new TypeError(`${label} is missing`, { cause: error });
|
|
150
|
+
}
|
|
151
|
+
throw error;
|
|
152
|
+
}
|
|
153
|
+
if (metadata.isSymbolicLink() || !metadata.isFile()) {
|
|
154
|
+
throw new TypeError(`${label} must be a regular file and not a symlink or reparse point`);
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
async function readStableRegularFile(file, label) {
|
|
158
|
+
await assertRegularFile(file, label);
|
|
159
|
+
const before = await lstat(file);
|
|
160
|
+
const bytes = await readFile(file, 'utf8');
|
|
161
|
+
const after = await lstat(file);
|
|
162
|
+
if (before.size !== after.size || before.mtimeMs !== after.mtimeMs || before.ino !== after.ino) {
|
|
163
|
+
throw new TypeError(`${label} changed while it was being loaded`);
|
|
164
|
+
}
|
|
165
|
+
return bytes;
|
|
166
|
+
}
|
|
167
|
+
function validateItem(value, variantId, workspaceId) {
|
|
168
|
+
if (!isRecord(value))
|
|
169
|
+
throw new TypeError(`Item ${variantId} must contain an object`);
|
|
170
|
+
assertIdentifier(value.id, `Item ${variantId}.id`);
|
|
171
|
+
if (value.id !== variantId)
|
|
172
|
+
throw new TypeError(`Item ${variantId} does not match its manifest variant ID`);
|
|
173
|
+
for (const key of ['contentKey', 'language', 'contentType', 'title']) {
|
|
174
|
+
if (!nonemptyString(value[key]))
|
|
175
|
+
throw new TypeError(`Item ${variantId}.${key} is required`);
|
|
176
|
+
}
|
|
177
|
+
const contentType = value.contentType;
|
|
178
|
+
if (!nonemptyString(contentType) ||
|
|
179
|
+
!/^[A-Za-z][A-Za-z\d_]*__[A-Za-z][A-Za-z\d_]*$/u.test(contentType)) {
|
|
180
|
+
throw new TypeError(`Item ${variantId}.contentType must be a fully qualified API name`);
|
|
181
|
+
}
|
|
182
|
+
assertOptionalString(value, 'apiName', `Item ${variantId}`);
|
|
183
|
+
assertOptionalString(value, 'externalId', `Item ${variantId}`);
|
|
184
|
+
assertOptionalString(value, 'urlName', `Item ${variantId}`);
|
|
185
|
+
assertPlainObject(value.contentBody, `Item ${variantId}.contentBody`);
|
|
186
|
+
if (value.externalSource !== undefined) {
|
|
187
|
+
assertPlainObject(value.externalSource, `Item ${variantId}.externalSource`);
|
|
188
|
+
}
|
|
189
|
+
if (!isRecord(value.contentSpace) || value.contentSpace.id !== workspaceId) {
|
|
190
|
+
throw new TypeError(`Item ${variantId} belongs to a different source contentSpace`);
|
|
191
|
+
}
|
|
192
|
+
assertJsonSafe(value, `Item ${variantId}`);
|
|
193
|
+
return value;
|
|
194
|
+
}
|
|
195
|
+
function partialFromManifest(manifest) {
|
|
196
|
+
const partialWarningCodes = new Set([
|
|
197
|
+
'COUNT_MISMATCH',
|
|
198
|
+
'DETAIL_FAILED',
|
|
199
|
+
'DUPLICATE_VARIANTS',
|
|
200
|
+
'OWNERSHIP_MISMATCH',
|
|
201
|
+
'PREMATURE_EMPTY_PAGE',
|
|
202
|
+
]);
|
|
203
|
+
return (manifest.failedVariantIds.length > 0 ||
|
|
204
|
+
manifest.rejectedVariantIds.length > 0 ||
|
|
205
|
+
manifest.exportedCount !== manifest.expectedCount ||
|
|
206
|
+
manifest.warnings.some(({ code }) => partialWarningCodes.has(code)));
|
|
207
|
+
}
|
|
208
|
+
function validateRelationships(items) {
|
|
209
|
+
const pairIds = new Map();
|
|
210
|
+
const keyToApiName = new Map();
|
|
211
|
+
const apiNameToKey = new Map();
|
|
212
|
+
for (const item of items) {
|
|
213
|
+
const pair = `${item.contentKey}\u0000${item.language}`;
|
|
214
|
+
if (pairIds.has(pair)) {
|
|
215
|
+
throw new TypeError(`Duplicate contentKey/language mapping: ${item.contentKey}/${item.language}`);
|
|
216
|
+
}
|
|
217
|
+
pairIds.set(pair, item.id);
|
|
218
|
+
if (item.apiName === undefined)
|
|
219
|
+
continue;
|
|
220
|
+
const priorApiName = keyToApiName.get(item.contentKey);
|
|
221
|
+
if (priorApiName !== undefined && priorApiName !== item.apiName) {
|
|
222
|
+
throw new TypeError(`Content key ${item.contentKey} has conflicting apiName values`);
|
|
223
|
+
}
|
|
224
|
+
const priorKey = apiNameToKey.get(item.apiName);
|
|
225
|
+
if (priorKey !== undefined && priorKey !== item.contentKey) {
|
|
226
|
+
throw new TypeError(`apiName ${item.apiName} maps to conflicting content keys`);
|
|
227
|
+
}
|
|
228
|
+
keyToApiName.set(item.contentKey, item.apiName);
|
|
229
|
+
apiNameToKey.set(item.apiName, item.contentKey);
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
export async function loadWorkspaceExport(sourceDirectory, options = {}) {
|
|
233
|
+
if (!nonemptyString(sourceDirectory))
|
|
234
|
+
throw new TypeError('sourceDirectory must be a nonempty string');
|
|
235
|
+
const sourceMetadata = await lstat(sourceDirectory);
|
|
236
|
+
if (sourceMetadata.isSymbolicLink() || !sourceMetadata.isDirectory()) {
|
|
237
|
+
throw new TypeError('sourceDirectory must be a directory and not a symlink or reparse point');
|
|
238
|
+
}
|
|
239
|
+
const canonicalSource = await realpath(sourceDirectory);
|
|
240
|
+
const manifestFile = path.join(canonicalSource, 'manifest.json');
|
|
241
|
+
const manifestBytes = await readStableRegularFile(manifestFile, 'manifest.json');
|
|
242
|
+
const manifest = validateManifest(parseJson(manifestBytes, 'manifest.json'));
|
|
243
|
+
const seenFiles = new Set();
|
|
244
|
+
const seenIds = new Set();
|
|
245
|
+
const items = [];
|
|
246
|
+
for (const [index, entry] of manifest.entries.entries()) {
|
|
247
|
+
if (!isRecord(entry))
|
|
248
|
+
throw new TypeError(`manifest.entries[${index}] is malformed`);
|
|
249
|
+
assertIdentifier(entry.variantId, `manifest.entries[${index}].variantId`);
|
|
250
|
+
const itemFile = safeEntryPath(canonicalSource, entry.file, entry.variantId);
|
|
251
|
+
const normalized = path.normalize(itemFile);
|
|
252
|
+
if (!normalized.startsWith(`${canonicalSource}${path.sep}`)) {
|
|
253
|
+
throw new TypeError(`Manifest entry ${entry.variantId} escapes the source directory`);
|
|
254
|
+
}
|
|
255
|
+
if (seenIds.has(entry.variantId) || seenFiles.has(normalized)) {
|
|
256
|
+
throw new TypeError(`Duplicate manifest mapping for ${entry.variantId}`);
|
|
257
|
+
}
|
|
258
|
+
seenIds.add(entry.variantId);
|
|
259
|
+
seenFiles.add(normalized);
|
|
260
|
+
const itemBytes = await readStableRegularFile(itemFile, `Item file for ${entry.variantId}`);
|
|
261
|
+
items.push(validateItem(parseJson(itemBytes, `Item file for ${entry.variantId}`), entry.variantId, manifest.workspaceId));
|
|
262
|
+
}
|
|
263
|
+
if (manifest.exportedCount !== manifest.entries.length) {
|
|
264
|
+
throw new TypeError('manifest.exportedCount does not match manifest.entries.length');
|
|
265
|
+
}
|
|
266
|
+
const itemDirectory = path.join(canonicalSource, 'items');
|
|
267
|
+
const itemDirectoryMetadata = await lstat(itemDirectory);
|
|
268
|
+
if (itemDirectoryMetadata.isSymbolicLink() || !itemDirectoryMetadata.isDirectory()) {
|
|
269
|
+
throw new TypeError('items must be a directory and not a symlink or reparse point');
|
|
270
|
+
}
|
|
271
|
+
const directoryEntries = await readdir(itemDirectory);
|
|
272
|
+
const actualFiles = directoryEntries.toSorted();
|
|
273
|
+
const expectedFiles = manifest.entries.map(({ variantId }) => `${variantId}.json`).toSorted();
|
|
274
|
+
if (JSON.stringify(actualFiles) !== JSON.stringify(expectedFiles)) {
|
|
275
|
+
throw new TypeError('items directory contains missing or substituted files');
|
|
276
|
+
}
|
|
277
|
+
validateRelationships(items);
|
|
278
|
+
const isPartial = partialFromManifest(manifest);
|
|
279
|
+
if (isPartial && options.allowPartial !== true) {
|
|
280
|
+
throw new TypeError('Workspace export is partial; pass allowPartial only to accept recorded omissions');
|
|
281
|
+
}
|
|
282
|
+
return {
|
|
283
|
+
isPartial,
|
|
284
|
+
items,
|
|
285
|
+
manifest,
|
|
286
|
+
manifestSha256: createHash('sha256').update(manifestBytes).digest('hex'),
|
|
287
|
+
sourceDirectory: canonicalSource,
|
|
288
|
+
};
|
|
289
|
+
}
|
|
290
|
+
function destinationWorkspace(value, expectedId) {
|
|
291
|
+
if (!isRecord(value))
|
|
292
|
+
throw new TypeError('Destination workspace must be an object');
|
|
293
|
+
if (value.id !== expectedId) {
|
|
294
|
+
throw new TypeError(`Destination workspace ID must exactly match ${expectedId}`);
|
|
295
|
+
}
|
|
296
|
+
if (!nonemptyString(value.defaultLanguage)) {
|
|
297
|
+
throw new TypeError('Destination workspace defaultLanguage must be a nonempty string');
|
|
298
|
+
}
|
|
299
|
+
if (!nonemptyString(value.rootFolderId)) {
|
|
300
|
+
throw new TypeError('Destination workspace rootFolderId must be a nonempty string');
|
|
301
|
+
}
|
|
302
|
+
assertIdentifier(value.rootFolderId, 'Destination workspace rootFolderId');
|
|
303
|
+
assertJsonSafe(value, 'Destination workspace');
|
|
304
|
+
return value;
|
|
305
|
+
}
|
|
306
|
+
export function planWorkspaceImport(source, workspace, expectedWorkspaceId) {
|
|
307
|
+
assertIdentifier(expectedWorkspaceId, 'workspaceId');
|
|
308
|
+
const destination = destinationWorkspace(workspace, expectedWorkspaceId);
|
|
309
|
+
const grouped = new Map();
|
|
310
|
+
for (const item of source.items) {
|
|
311
|
+
const group = grouped.get(item.contentKey) ?? [];
|
|
312
|
+
group.push(item);
|
|
313
|
+
grouped.set(item.contentKey, group);
|
|
314
|
+
}
|
|
315
|
+
const groups = [...grouped.entries()]
|
|
316
|
+
.toSorted(([left], [right]) => left.localeCompare(right))
|
|
317
|
+
.map(([contentKey, items]) => {
|
|
318
|
+
const primaries = items.filter(({ language }) => language === destination.defaultLanguage);
|
|
319
|
+
if (primaries.length !== 1) {
|
|
320
|
+
throw new TypeError(`Content key ${contentKey} must have exactly one ${destination.defaultLanguage} primary variant`);
|
|
321
|
+
}
|
|
322
|
+
const primary = primaries[0];
|
|
323
|
+
return {
|
|
324
|
+
contentKey,
|
|
325
|
+
primary,
|
|
326
|
+
variants: items
|
|
327
|
+
.filter(({ id }) => id !== primary.id)
|
|
328
|
+
.toSorted((left, right) => left.language.localeCompare(right.language)),
|
|
329
|
+
};
|
|
330
|
+
});
|
|
331
|
+
return {
|
|
332
|
+
destinationWorkspaceId: destination.id,
|
|
333
|
+
groups,
|
|
334
|
+
rootFolderId: destination.rootFolderId,
|
|
335
|
+
source,
|
|
336
|
+
};
|
|
337
|
+
}
|
|
338
|
+
function createPayload(group, rootFolderId) {
|
|
339
|
+
const item = group.primary;
|
|
340
|
+
const payload = {
|
|
341
|
+
contentBody: item.contentBody,
|
|
342
|
+
contentKey: item.contentKey,
|
|
343
|
+
contentSpaceOrFolderId: rootFolderId,
|
|
344
|
+
contentType: item.contentType,
|
|
345
|
+
title: item.title,
|
|
346
|
+
};
|
|
347
|
+
if (item.apiName !== undefined)
|
|
348
|
+
payload.apiName = item.apiName;
|
|
349
|
+
if (item.urlName !== undefined)
|
|
350
|
+
payload.urlName = item.urlName;
|
|
351
|
+
if (item.externalId !== undefined)
|
|
352
|
+
payload.externalId = item.externalId;
|
|
353
|
+
if (item.externalSource !== undefined)
|
|
354
|
+
payload.externalSource = item.externalSource;
|
|
355
|
+
return payload;
|
|
356
|
+
}
|
|
357
|
+
function variantPayload(item, contentKey) {
|
|
358
|
+
const payload = {
|
|
359
|
+
contentBody: item.contentBody,
|
|
360
|
+
language: item.language,
|
|
361
|
+
managedContentKeyOrId: contentKey,
|
|
362
|
+
title: item.title,
|
|
363
|
+
};
|
|
364
|
+
if (item.urlName !== undefined)
|
|
365
|
+
payload.urlName = item.urlName;
|
|
366
|
+
return payload;
|
|
367
|
+
}
|
|
368
|
+
function isProvenNotFound(error) {
|
|
369
|
+
return (error instanceof CmsRequestError && error.operationKey === 'content.get' && error.status === 404);
|
|
370
|
+
}
|
|
371
|
+
async function preflightConflicts(connection, plan, requestOptions) {
|
|
372
|
+
for (const group of plan.groups) {
|
|
373
|
+
try {
|
|
374
|
+
await getContent(connection, group.contentKey, {}, requestOptions);
|
|
375
|
+
throw new Error(`Content key ${group.contentKey} already exists`);
|
|
376
|
+
}
|
|
377
|
+
catch (error) {
|
|
378
|
+
if (isProvenNotFound(error))
|
|
379
|
+
continue;
|
|
380
|
+
throw error;
|
|
381
|
+
}
|
|
382
|
+
}
|
|
383
|
+
}
|
|
384
|
+
function jsonBytes(value) {
|
|
385
|
+
return `${JSON.stringify(value, null, 2)}\n`;
|
|
386
|
+
}
|
|
387
|
+
async function writeExclusive(file, value) {
|
|
388
|
+
const handle = await open(file, 'wx');
|
|
389
|
+
try {
|
|
390
|
+
await handle.writeFile(jsonBytes(value), 'utf8');
|
|
391
|
+
}
|
|
392
|
+
finally {
|
|
393
|
+
await handle.close();
|
|
394
|
+
}
|
|
395
|
+
}
|
|
396
|
+
async function rewriteAtomic(file, value) {
|
|
397
|
+
const temporary = `${file}.tmp-${process.pid}-${randomUUID()}`;
|
|
398
|
+
try {
|
|
399
|
+
await writeExclusive(temporary, value);
|
|
400
|
+
await rename(temporary, file);
|
|
401
|
+
}
|
|
402
|
+
catch (error) {
|
|
403
|
+
await rm(temporary, { force: true });
|
|
404
|
+
throw error;
|
|
405
|
+
}
|
|
406
|
+
}
|
|
407
|
+
function responseIdentifier(record, keys, label) {
|
|
408
|
+
for (const key of keys) {
|
|
409
|
+
if (nonemptyString(record[key]))
|
|
410
|
+
return record[key];
|
|
411
|
+
}
|
|
412
|
+
throw new TypeError(`Create response is missing ${label}`);
|
|
413
|
+
}
|
|
414
|
+
function validateParentResponse(response, expectedContentKey) {
|
|
415
|
+
const contentKey = responseIdentifier(response, ['contentKey'], 'contentKey');
|
|
416
|
+
if (contentKey !== expectedContentKey) {
|
|
417
|
+
throw new TypeError(`Create response contentKey does not match ${expectedContentKey}`);
|
|
418
|
+
}
|
|
419
|
+
return {
|
|
420
|
+
childVariantIds: [],
|
|
421
|
+
contentId: responseIdentifier(response, ['id', 'contentId', 'managedContentId'], 'content ID'),
|
|
422
|
+
contentKey,
|
|
423
|
+
primaryVariantId: responseIdentifier(response, ['primaryVariantId', 'managedContentVariantId', 'variantId'], 'primary variant ID'),
|
|
424
|
+
};
|
|
425
|
+
}
|
|
426
|
+
function validateChildResponse(response) {
|
|
427
|
+
return responseIdentifier(response, ['id', 'variantId', 'managedContentVariantId'], 'variant ID');
|
|
428
|
+
}
|
|
429
|
+
function operationIdentity(runId, kind, contentKey, language, payload) {
|
|
430
|
+
assertJsonSafe(payload, 'Mutation payload');
|
|
431
|
+
const requestIdentity = `${kind}\u0000${contentKey}\u0000${language}\u0000${JSON.stringify(payload)}`;
|
|
432
|
+
const requestSha256 = createHash('sha256').update(requestIdentity).digest('hex');
|
|
433
|
+
return {
|
|
434
|
+
operationId: createHash('sha256').update(`${runId}\u0000${requestSha256}`).digest('hex'),
|
|
435
|
+
requestIdentity,
|
|
436
|
+
requestSha256,
|
|
437
|
+
};
|
|
438
|
+
}
|
|
439
|
+
function pendingOperation(report, kind, contentKey, language, payload) {
|
|
440
|
+
return {
|
|
441
|
+
contentKey,
|
|
442
|
+
destinationOrgId: report.destinationOrgId,
|
|
443
|
+
destinationWorkspaceId: report.destinationWorkspaceId,
|
|
444
|
+
language,
|
|
445
|
+
operationKind: kind,
|
|
446
|
+
runId: report.runId,
|
|
447
|
+
state: 'pending',
|
|
448
|
+
...operationIdentity(report.runId, kind, contentKey, language, payload),
|
|
449
|
+
};
|
|
450
|
+
}
|
|
451
|
+
async function persistOperationResult(reportFile, report, operation, rewrite) {
|
|
452
|
+
try {
|
|
453
|
+
await rewrite(reportFile, report);
|
|
454
|
+
}
|
|
455
|
+
catch (error) {
|
|
456
|
+
operation.state = 'pending';
|
|
457
|
+
delete operation.result;
|
|
458
|
+
report.state = 'ownership-uncertain';
|
|
459
|
+
try {
|
|
460
|
+
await rewrite(reportFile, report);
|
|
461
|
+
}
|
|
462
|
+
catch {
|
|
463
|
+
// The durable pending intent remains the manual-reconciliation source of truth.
|
|
464
|
+
}
|
|
465
|
+
throw new WorkspaceImportOwnershipUncertainError(operation, error);
|
|
466
|
+
}
|
|
467
|
+
}
|
|
468
|
+
export async function executeWorkspaceImport(options) {
|
|
469
|
+
if (!nonemptyString(options.destinationOrgId)) {
|
|
470
|
+
throw new TypeError('destinationOrgId must be the nonempty destination org ID');
|
|
471
|
+
}
|
|
472
|
+
const source = await loadWorkspaceExport(options.sourceDirectory, {
|
|
473
|
+
allowPartial: options.allowPartial,
|
|
474
|
+
});
|
|
475
|
+
const plan = planWorkspaceImport(source, options.destinationWorkspace, options.workspaceId);
|
|
476
|
+
const requestOptions = options.requestOptions ?? {};
|
|
477
|
+
await preflightConflicts(options.connection, plan, requestOptions);
|
|
478
|
+
if (options.dryRun === true)
|
|
479
|
+
return { dryRun: true, plan };
|
|
480
|
+
if (!nonemptyString(options.reportDirectory)) {
|
|
481
|
+
throw new TypeError('reportDirectory is required for an applied import');
|
|
482
|
+
}
|
|
483
|
+
const reportDirectory = path.resolve(options.reportDirectory);
|
|
484
|
+
await mkdir(reportDirectory);
|
|
485
|
+
const reportFile = path.join(reportDirectory, 'workspace-import-run.json');
|
|
486
|
+
const report = {
|
|
487
|
+
createdParents: [],
|
|
488
|
+
destinationOrgId: options.destinationOrgId,
|
|
489
|
+
destinationWorkspaceId: plan.destinationWorkspaceId,
|
|
490
|
+
operations: [],
|
|
491
|
+
runId: randomUUID(),
|
|
492
|
+
sourceDirectory: source.sourceDirectory,
|
|
493
|
+
sourceManifestSha256: source.manifestSha256,
|
|
494
|
+
state: 'applying',
|
|
495
|
+
};
|
|
496
|
+
const rewrite = options.reportPersistence?.rewrite ?? rewriteAtomic;
|
|
497
|
+
await writeExclusive(reportFile, report);
|
|
498
|
+
try {
|
|
499
|
+
for (const group of plan.groups) {
|
|
500
|
+
const parentPayload = createPayload(group, plan.rootFolderId);
|
|
501
|
+
const parentOperation = pendingOperation(report, 'create-parent', group.contentKey, group.primary.language, parentPayload);
|
|
502
|
+
report.operations.push(parentOperation);
|
|
503
|
+
await rewrite(reportFile, report);
|
|
504
|
+
let parentResponse;
|
|
505
|
+
try {
|
|
506
|
+
parentResponse = await createContent(options.connection, parentPayload, requestOptions);
|
|
507
|
+
}
|
|
508
|
+
catch (error) {
|
|
509
|
+
parentOperation.state = 'failed';
|
|
510
|
+
parentOperation.error = error instanceof Error ? error.message : String(error);
|
|
511
|
+
try {
|
|
512
|
+
await rewrite(reportFile, report);
|
|
513
|
+
}
|
|
514
|
+
catch {
|
|
515
|
+
// Preserve the mutation error when recording its failure is unavailable.
|
|
516
|
+
}
|
|
517
|
+
throw error;
|
|
518
|
+
}
|
|
519
|
+
const created = validateParentResponse(parentResponse, group.contentKey);
|
|
520
|
+
report.createdParents.push(created);
|
|
521
|
+
parentOperation.state = 'succeeded';
|
|
522
|
+
parentOperation.result = {
|
|
523
|
+
contentId: created.contentId,
|
|
524
|
+
primaryVariantId: created.primaryVariantId,
|
|
525
|
+
};
|
|
526
|
+
await persistOperationResult(reportFile, report, parentOperation, rewrite);
|
|
527
|
+
for (const variant of group.variants) {
|
|
528
|
+
const childPayload = variantPayload(variant, group.contentKey);
|
|
529
|
+
const childOperation = pendingOperation(report, 'create-child', group.contentKey, variant.language, childPayload);
|
|
530
|
+
report.operations.push(childOperation);
|
|
531
|
+
await rewrite(reportFile, report);
|
|
532
|
+
let childResponse;
|
|
533
|
+
try {
|
|
534
|
+
childResponse = await createVariant(options.connection, childPayload, requestOptions);
|
|
535
|
+
}
|
|
536
|
+
catch (error) {
|
|
537
|
+
childOperation.state = 'failed';
|
|
538
|
+
childOperation.error = error instanceof Error ? error.message : String(error);
|
|
539
|
+
try {
|
|
540
|
+
await rewrite(reportFile, report);
|
|
541
|
+
}
|
|
542
|
+
catch {
|
|
543
|
+
// Preserve the mutation error when recording its failure is unavailable.
|
|
544
|
+
}
|
|
545
|
+
throw error;
|
|
546
|
+
}
|
|
547
|
+
const childVariantId = validateChildResponse(childResponse);
|
|
548
|
+
created.childVariantIds.push(childVariantId);
|
|
549
|
+
childOperation.state = 'succeeded';
|
|
550
|
+
childOperation.result = { variantId: childVariantId };
|
|
551
|
+
await persistOperationResult(reportFile, report, childOperation, rewrite);
|
|
552
|
+
}
|
|
553
|
+
}
|
|
554
|
+
report.state = 'completed';
|
|
555
|
+
await rewrite(reportFile, report);
|
|
556
|
+
}
|
|
557
|
+
catch (error) {
|
|
558
|
+
if (!(error instanceof WorkspaceImportOwnershipUncertainError))
|
|
559
|
+
report.state = 'failed';
|
|
560
|
+
try {
|
|
561
|
+
await rewrite(reportFile, report);
|
|
562
|
+
}
|
|
563
|
+
catch {
|
|
564
|
+
// Preserve the primary error; the last durable report is the source of truth.
|
|
565
|
+
}
|
|
566
|
+
throw error;
|
|
567
|
+
}
|
|
568
|
+
return { dryRun: false, plan, report, reportFile };
|
|
569
|
+
}
|
|
570
|
+
//# sourceMappingURL=import-workspace.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"import-workspace.js","sourceRoot":"","sources":["../../src/services/import-workspace.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACrD,OAAO,EAAE,KAAK,EAAE,KAAK,EAA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AO,CAAC,CAAC;YAC5E,CAAC;QACH,CAAC;QACD,MAAM,CAAC,KAAK,GAAG,WAAW,CAAC;QAC3B,MAAM,OAAO,CAAC,UAAU,EAAE,MAAM,CAAC,CAAC;IACpC,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,IAAI,CAAC,CAAC,KAAK,YAAY,sCAAsC,CAAC;YAAE,MAAM,CAAC,KAAK,GAAG,QAAQ,CAAC;QACxF,IAAI,CAAC;YACH,MAAM,OAAO,CAAC,UAAU,EAAE,MAAM,CAAC,CAAC;QACpC,CAAC;QAAC,MAAM,CAAC;YACP,8EAA8E;QAChF,CAAC;QACD,MAAM,KAAK,CAAC;IACd,CAAC;IACD,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,EAAE,UAAU,EAAE,CAAC;AACrD,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { Connection } from '@salesforce/core';
|
|
2
|
+
import { type JsonRequestOptions, type OperationParameterValues } from '../transport/json-request.js';
|
|
3
|
+
type CmsJsonValue = boolean | CmsJsonValue[] | CmsRecord | null | number | string;
|
|
4
|
+
export type CmsRecord = {
|
|
5
|
+
readonly [key: string]: CmsJsonValue;
|
|
6
|
+
};
|
|
7
|
+
export type CmsPage = {
|
|
8
|
+
items: CmsRecord[];
|
|
9
|
+
page?: number;
|
|
10
|
+
pageSize?: number;
|
|
11
|
+
total?: number;
|
|
12
|
+
};
|
|
13
|
+
type RequestConnection = Pick<Connection, 'request'>;
|
|
14
|
+
export declare function listWorkspaces(connection: RequestConnection, query?: OperationParameterValues, options?: JsonRequestOptions): Promise<CmsPage>;
|
|
15
|
+
export declare function getWorkspace(connection: RequestConnection, contentSpaceId: string, options?: JsonRequestOptions): Promise<CmsRecord>;
|
|
16
|
+
export declare function listWorkspaceChannels(connection: RequestConnection, contentSpaceId: string, query?: OperationParameterValues, options?: JsonRequestOptions): Promise<CmsPage>;
|
|
17
|
+
export declare function getChannel(connection: RequestConnection, channelId: string, options?: JsonRequestOptions): Promise<CmsRecord>;
|
|
18
|
+
export declare function getContent(connection: RequestConnection, contentKeyOrId: string, query?: OperationParameterValues, options?: JsonRequestOptions): Promise<CmsRecord>;
|
|
19
|
+
export declare function getVariant(connection: RequestConnection, variantId: string, options?: JsonRequestOptions): Promise<CmsRecord>;
|
|
20
|
+
export {};
|