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,176 @@
|
|
|
1
|
+
import { createHash } from 'node:crypto';
|
|
2
|
+
import { readFile } from 'node:fs/promises';
|
|
3
|
+
import { LineCounter, parseDocument } from 'yaml';
|
|
4
|
+
const HTTP_METHODS = new Set(['delete', 'get', 'head', 'options', 'patch', 'post', 'put', 'trace']);
|
|
5
|
+
export class OpenApiIntakeError extends Error {
|
|
6
|
+
constructor(message) {
|
|
7
|
+
super(message);
|
|
8
|
+
this.name = 'OpenApiIntakeError';
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
function formatYamlDiagnostic(source, diagnostic, lineCounter) {
|
|
12
|
+
const position = diagnostic.pos?.[0];
|
|
13
|
+
const location = position === undefined
|
|
14
|
+
? ''
|
|
15
|
+
: (() => {
|
|
16
|
+
const { line, col } = lineCounter.linePos(position);
|
|
17
|
+
return `:${line}:${col}`;
|
|
18
|
+
})();
|
|
19
|
+
const code = diagnostic.code ? ` [${diagnostic.code}]` : '';
|
|
20
|
+
return `${source}${location}${code}: ${diagnostic.message.replaceAll(/\s+/g, ' ').trim()}`;
|
|
21
|
+
}
|
|
22
|
+
function isRecord(value) {
|
|
23
|
+
return typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
24
|
+
}
|
|
25
|
+
function decodePointerToken(token, reference) {
|
|
26
|
+
if (/%[0-9a-f]{2}/iu.test(token)) {
|
|
27
|
+
throw new OpenApiIntakeError(`escaped ref is forbidden: ${reference}`);
|
|
28
|
+
}
|
|
29
|
+
if (/~(?![01])/u.test(token)) {
|
|
30
|
+
throw new OpenApiIntakeError(`malformed JSON Pointer escape in ref: ${reference}`);
|
|
31
|
+
}
|
|
32
|
+
return token.replaceAll('~1', '/').replaceAll('~0', '~');
|
|
33
|
+
}
|
|
34
|
+
export function resolveInternalRef(root, reference) {
|
|
35
|
+
if (!reference.startsWith('#/')) {
|
|
36
|
+
throw new OpenApiIntakeError(`only canonical internal refs beginning #/ are allowed: ${reference}`);
|
|
37
|
+
}
|
|
38
|
+
if (reference.includes('\\') || reference.includes('?')) {
|
|
39
|
+
throw new OpenApiIntakeError(`malformed internal ref: ${reference}`);
|
|
40
|
+
}
|
|
41
|
+
let current = root;
|
|
42
|
+
const tokens = reference
|
|
43
|
+
.slice(2)
|
|
44
|
+
.split('/')
|
|
45
|
+
.map((token) => decodePointerToken(token, reference));
|
|
46
|
+
for (const [index, token] of tokens.entries()) {
|
|
47
|
+
if (Array.isArray(current)) {
|
|
48
|
+
if (!/^(0|[1-9]\d*)$/u.test(token) || Number(token) >= current.length) {
|
|
49
|
+
throw new OpenApiIntakeError(`unresolved internal ref ${reference} at segment ${index + 1} (${JSON.stringify(token)})`);
|
|
50
|
+
}
|
|
51
|
+
current = current[Number(token)];
|
|
52
|
+
}
|
|
53
|
+
else if (isRecord(current) && Object.hasOwn(current, token)) {
|
|
54
|
+
current = current[token];
|
|
55
|
+
}
|
|
56
|
+
else {
|
|
57
|
+
throw new OpenApiIntakeError(`unresolved internal ref ${reference} at segment ${index + 1} (${JSON.stringify(token)})`);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
return current;
|
|
61
|
+
}
|
|
62
|
+
function validateRefs(root) {
|
|
63
|
+
const visitedObjects = new WeakSet();
|
|
64
|
+
const resolvedRefs = new Map();
|
|
65
|
+
let refCount = 0;
|
|
66
|
+
const visit = (value, refStack) => {
|
|
67
|
+
if (Array.isArray(value)) {
|
|
68
|
+
if (visitedObjects.has(value))
|
|
69
|
+
return;
|
|
70
|
+
visitedObjects.add(value);
|
|
71
|
+
for (const item of value)
|
|
72
|
+
visit(item, refStack);
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
75
|
+
if (!isRecord(value))
|
|
76
|
+
return;
|
|
77
|
+
if (visitedObjects.has(value))
|
|
78
|
+
return;
|
|
79
|
+
visitedObjects.add(value);
|
|
80
|
+
const reference = value.$ref;
|
|
81
|
+
if (reference !== undefined) {
|
|
82
|
+
if (typeof reference !== 'string' || reference.length === 0) {
|
|
83
|
+
throw new OpenApiIntakeError('$ref must be a non-empty string');
|
|
84
|
+
}
|
|
85
|
+
refCount += 1;
|
|
86
|
+
const target = resolvedRefs.has(reference)
|
|
87
|
+
? resolvedRefs.get(reference)
|
|
88
|
+
: resolveInternalRef(root, reference);
|
|
89
|
+
resolvedRefs.set(reference, target);
|
|
90
|
+
if (!refStack.has(reference)) {
|
|
91
|
+
visit(target, new Set([...refStack, reference]));
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
for (const [key, child] of Object.entries(value)) {
|
|
95
|
+
if (key !== '$ref')
|
|
96
|
+
visit(child, refStack);
|
|
97
|
+
}
|
|
98
|
+
};
|
|
99
|
+
visit(root, new Set());
|
|
100
|
+
return refCount;
|
|
101
|
+
}
|
|
102
|
+
function validateOperations(root) {
|
|
103
|
+
if (root.openapi !== '3.0.3') {
|
|
104
|
+
throw new OpenApiIntakeError(`expected OpenAPI 3.0.3, received ${JSON.stringify(root.openapi)}`);
|
|
105
|
+
}
|
|
106
|
+
const info = root.info;
|
|
107
|
+
if (!isRecord(info) || info.title !== 'CMS Connect REST API' || info.version !== 'v67.0') {
|
|
108
|
+
throw new OpenApiIntakeError('expected CMS Connect REST API document version v67.0');
|
|
109
|
+
}
|
|
110
|
+
if (!isRecord(root.paths))
|
|
111
|
+
throw new OpenApiIntakeError('OpenAPI paths must be an object');
|
|
112
|
+
const operationIds = new Set();
|
|
113
|
+
const identities = new Set();
|
|
114
|
+
const operations = [];
|
|
115
|
+
for (const path of Object.keys(root.paths).toSorted()) {
|
|
116
|
+
if (!path.startsWith('/'))
|
|
117
|
+
throw new OpenApiIntakeError(`invalid OpenAPI path: ${path}`);
|
|
118
|
+
const pathItem = root.paths[path];
|
|
119
|
+
if (!isRecord(pathItem))
|
|
120
|
+
throw new OpenApiIntakeError(`path item must be an object: ${path}`);
|
|
121
|
+
for (const method of Object.keys(pathItem).toSorted()) {
|
|
122
|
+
if (!HTTP_METHODS.has(method.toLowerCase()))
|
|
123
|
+
continue;
|
|
124
|
+
const operation = pathItem[method];
|
|
125
|
+
if (!isRecord(operation))
|
|
126
|
+
throw new OpenApiIntakeError(`operation must be an object: ${method} ${path}`);
|
|
127
|
+
if (typeof operation.operationId !== 'string' || operation.operationId.trim() === '') {
|
|
128
|
+
throw new OpenApiIntakeError(`missing operationId: ${method.toUpperCase()} ${path}`);
|
|
129
|
+
}
|
|
130
|
+
const operationId = operation.operationId.trim();
|
|
131
|
+
const identity = `${method.toUpperCase()} ${path}`;
|
|
132
|
+
if (identities.has(identity))
|
|
133
|
+
throw new OpenApiIntakeError(`duplicate operation identity: ${identity}`);
|
|
134
|
+
if (operationIds.has(operationId))
|
|
135
|
+
throw new OpenApiIntakeError(`duplicate operationId: ${operationId}`);
|
|
136
|
+
identities.add(identity);
|
|
137
|
+
operationIds.add(operationId);
|
|
138
|
+
operations.push({ method: method.toUpperCase(), operationId, path });
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
return operations.toSorted((left, right) => left.path.localeCompare(right.path) || left.method.localeCompare(right.method));
|
|
142
|
+
}
|
|
143
|
+
export async function intakeOpenApi(sourcePath) {
|
|
144
|
+
const bytes = await readFile(sourcePath);
|
|
145
|
+
const text = bytes.toString('utf8');
|
|
146
|
+
if (text.startsWith('\uFEFF'))
|
|
147
|
+
throw new OpenApiIntakeError(`${sourcePath}: UTF-8 BOM is forbidden`);
|
|
148
|
+
const lineCounter = new LineCounter();
|
|
149
|
+
const yamlDocument = parseDocument(text, {
|
|
150
|
+
customTags: [],
|
|
151
|
+
lineCounter,
|
|
152
|
+
uniqueKeys: true,
|
|
153
|
+
version: '1.2',
|
|
154
|
+
});
|
|
155
|
+
const diagnostics = [...yamlDocument.errors, ...yamlDocument.warnings];
|
|
156
|
+
if (diagnostics.length > 0) {
|
|
157
|
+
throw new OpenApiIntakeError(diagnostics
|
|
158
|
+
.map((diagnostic) => formatYamlDiagnostic(sourcePath, diagnostic, lineCounter))
|
|
159
|
+
.join('\n'));
|
|
160
|
+
}
|
|
161
|
+
const document = yamlDocument.toJS({ maxAliasCount: 100 });
|
|
162
|
+
if (!isRecord(document))
|
|
163
|
+
throw new OpenApiIntakeError('OpenAPI document root must be an object');
|
|
164
|
+
const operations = validateOperations(document);
|
|
165
|
+
const refCount = validateRefs(document);
|
|
166
|
+
return {
|
|
167
|
+
byteSize: bytes.byteLength,
|
|
168
|
+
document: document,
|
|
169
|
+
operationCount: operations.length,
|
|
170
|
+
operations,
|
|
171
|
+
refCount,
|
|
172
|
+
sha256: createHash('sha256').update(bytes).digest('hex'),
|
|
173
|
+
source: sourcePath,
|
|
174
|
+
};
|
|
175
|
+
}
|
|
176
|
+
//# sourceMappingURL=intake.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"intake.js","sourceRoot":"","sources":["../../src/openapi/intake.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,WAAW,EAAE,aAAa,EAAyC,MAAM,MAAM,CAAC;AAEzF,MAAM,YAAY,GAAG,IAAI,GAAG,CAAC,CAAC,QAAQ,EAAE,KAAK,EAAE,MAAM,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,CAAC,CAAC,CAAC;AAqBpG,MAAM,OAAO,kBAAmB,SAAQ,KAAK;IAC3C,YAAmB,OAAe;QAChC,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,oBAAoB,CAAC;IACnC,CAAC;CACF;AAED,SAAS,oBAAoB,CAC3B,MAAc,EACd,UAAwC,EACxC,WAAwB;IAExB,MAAM,QAAQ,GAAG,UAAU,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC,CAAC;IACrC,MAAM,QAAQ,GACZ,QAAQ,KAAK,SAAS;QACpB,CAAC,CAAC,EAAE;QACJ,CAAC,CAAC,CAAC,GAAG,EAAE;YACJ,MAAM,EAAE,IAAI,EAAE,GAAG,EAAE,GAAG,WAAW,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;YACpD,OAAO,IAAI,IAAI,IAAI,GAAG,EAAE,CAAC;QAC3B,CAAC,CAAC,EAAE,CAAC;IACX,MAAM,IAAI,GAAG,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,UAAU,CAAC,IAAI,GAAG,CAAC,CA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AAC;IACpE,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC;QAAE,MAAM,IAAI,kBAAkB,CAAC,yCAAyC,CAAC,CAAC;IACjG,MAAM,UAAU,GAAG,kBAAkB,CAAC,QAAQ,CAAC,CAAC;IAChD,MAAM,QAAQ,GAAG,YAAY,CAAC,QAAQ,CAAC,CAAC;IAExC,OAAO;QACL,QAAQ,EAAE,KAAK,CAAC,UAAU;QAC1B,QAAQ,EAAE,QAAwC;QAClD,cAAc,EAAE,UAAU,CAAC,MAAM;QACjC,UAAU;QACV,QAAQ;QACR,MAAM,EAAE,UAAU,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC;QACxD,MAAM,EAAE,UAAU;KACnB,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export type SelectedOperationConfig = {
|
|
2
|
+
localKey: string;
|
|
3
|
+
operationId: string;
|
|
4
|
+
};
|
|
5
|
+
export declare const SELECTED_OPERATION_CONFIG: readonly SelectedOperationConfig[];
|
|
6
|
+
export declare const DEFERRED_STAGE_1_CAPABILITIES: {
|
|
7
|
+
readonly 'content.list': "No bounded unfiltered enhanced-workspace content enumeration is evidenced.";
|
|
8
|
+
readonly 'delivery.get': "Delivery is not clearly required for the Stage 1 workspace, channel, content, and variant read slice.";
|
|
9
|
+
readonly 'delivery.media.get': "Media delivery is not clearly required for the Stage 1 read slice.";
|
|
10
|
+
readonly 'variant.list': "No independent or stable embedded variant collection is evidenced.";
|
|
11
|
+
};
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
export const SELECTED_OPERATION_CONFIG = [
|
|
2
|
+
{
|
|
3
|
+
localKey: 'channel.get',
|
|
4
|
+
operationId: 'getManagedContentChannel',
|
|
5
|
+
},
|
|
6
|
+
{
|
|
7
|
+
localKey: 'content.create',
|
|
8
|
+
operationId: 'postManagedContentDocumentCreate',
|
|
9
|
+
},
|
|
10
|
+
{
|
|
11
|
+
localKey: 'content.get',
|
|
12
|
+
operationId: 'getManagedContentDocument',
|
|
13
|
+
},
|
|
14
|
+
{
|
|
15
|
+
localKey: 'variant.create',
|
|
16
|
+
operationId: 'postManagedContentVariantCreate',
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
localKey: 'variant.delete',
|
|
20
|
+
operationId: 'deleteManagedContentVariant',
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
localKey: 'variant.get',
|
|
24
|
+
operationId: 'getManagedContentVariant',
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
localKey: 'workspace.channel.list',
|
|
28
|
+
operationId: 'getManagedContentSpaceChannels',
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
localKey: 'workspace.get',
|
|
32
|
+
operationId: 'getManagedContentSpace',
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
localKey: 'workspace.list',
|
|
36
|
+
operationId: 'getManagedContentSpaceCollection',
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
localKey: 'workspace.variant.search',
|
|
40
|
+
operationId: 'getManagedContentSearchItems',
|
|
41
|
+
},
|
|
42
|
+
];
|
|
43
|
+
export const DEFERRED_STAGE_1_CAPABILITIES = {
|
|
44
|
+
'content.list': 'No bounded unfiltered enhanced-workspace content enumeration is evidenced.',
|
|
45
|
+
'delivery.get': 'Delivery is not clearly required for the Stage 1 workspace, channel, content, and variant read slice.',
|
|
46
|
+
'delivery.media.get': 'Media delivery is not clearly required for the Stage 1 read slice.',
|
|
47
|
+
'variant.list': 'No independent or stable embedded variant collection is evidenced.',
|
|
48
|
+
};
|
|
49
|
+
//# sourceMappingURL=selected.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"selected.js","sourceRoot":"","sources":["../../src/openapi/selected.ts"],"names":[],"mappings":"AAKA,MAAM,CAAC,MAAM,yBAAyB,GAAuC;IAC3E;QACE,QAAQ,EAAE,aAAa;QACvB,WAAW,EAAE,0BAA0B;KACxC;IACD;QACE,QAAQ,EAAE,gBAAgB;QAC1B,WAAW,EAAE,kCAAkC;KAChD;IACD;QACE,QAAQ,EAAE,aAAa;QACvB,WAAW,EAAE,2BAA2B;KACzC;IACD;QACE,QAAQ,EAAE,gBAAgB;QAC1B,WAAW,EAAE,iCAAiC;KAC/C;IACD;QACE,QAAQ,EAAE,gBAAgB;QAC1B,WAAW,EAAE,6BAA6B;KAC3C;IACD;QACE,QAAQ,EAAE,aAAa;QACvB,WAAW,EAAE,0BAA0B;KACxC;IACD;QACE,QAAQ,EAAE,wBAAwB;QAClC,WAAW,EAAE,gCAAgC;KAC9C;IACD;QACE,QAAQ,EAAE,eAAe;QACzB,WAAW,EAAE,wBAAwB;KACtC;IACD;QACE,QAAQ,EAAE,gBAAgB;QAC1B,WAAW,EAAE,kCAAkC;KAChD;IACD;QACE,QAAQ,EAAE,0BAA0B;QACpC,WAAW,EAAE,8BAA8B;KAC5C;CACF,CAAC;AAEF,MAAM,CAAC,MAAM,6BAA6B,GAAG;IAC3C,cAAc,EAAE,4EAA4E;IAC5F,cAAc,EACZ,uGAAuG;IACzG,oBAAoB,EAAE,oEAAoE;IAC1F,cAAc,EAAE,oEAAoE;CAC5E,CAAC"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import type { Connection } from '@salesforce/core';
|
|
2
|
+
import { type JsonRequestOptions } from '../transport/json-request.js';
|
|
3
|
+
export type WorkspaceExportWarning = {
|
|
4
|
+
code: 'COUNT_MISMATCH' | 'DETAIL_FAILED' | 'DUPLICATE_VARIANTS' | 'OWNERSHIP_MISMATCH' | 'PREMATURE_EMPTY_PAGE' | 'UNSUPPORTED_WILDCARD';
|
|
5
|
+
message: string;
|
|
6
|
+
variantIds?: string[];
|
|
7
|
+
};
|
|
8
|
+
export type WorkspaceExportEntry = {
|
|
9
|
+
file: string;
|
|
10
|
+
variantId: string;
|
|
11
|
+
};
|
|
12
|
+
export type WorkspaceExportManifest = {
|
|
13
|
+
schemaVersion: 1;
|
|
14
|
+
mode: 'experimental-best-effort';
|
|
15
|
+
workspaceId: string;
|
|
16
|
+
search: {
|
|
17
|
+
contentSpaceOrFolderIds: [string];
|
|
18
|
+
languages: ['All'];
|
|
19
|
+
pageSize: 250;
|
|
20
|
+
queryTerm: '*';
|
|
21
|
+
};
|
|
22
|
+
expectedCount: number;
|
|
23
|
+
foundCount: number;
|
|
24
|
+
exportedCount: number;
|
|
25
|
+
pagesRequested: number;
|
|
26
|
+
entries: WorkspaceExportEntry[];
|
|
27
|
+
rejectedVariantIds: string[];
|
|
28
|
+
failedVariantIds: string[];
|
|
29
|
+
warnings: WorkspaceExportWarning[];
|
|
30
|
+
};
|
|
31
|
+
export type ExportWorkspaceResult = {
|
|
32
|
+
destination: string;
|
|
33
|
+
manifest: WorkspaceExportManifest;
|
|
34
|
+
};
|
|
35
|
+
type RequestConnection = Pick<Connection, 'request'>;
|
|
36
|
+
export declare function exportWorkspace(connection: RequestConnection, workspaceId: string, destination: string, options?: JsonRequestOptions): Promise<ExportWorkspaceResult>;
|
|
37
|
+
export {};
|
|
@@ -0,0 +1,214 @@
|
|
|
1
|
+
import { mkdir, open, rename, rm, stat } from 'node:fs/promises';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
import { getSelectedOperation, requestJson, } from '../transport/json-request.js';
|
|
4
|
+
import { getVariant } from './read.js';
|
|
5
|
+
const PAGE_SIZE = 250;
|
|
6
|
+
const ABSOLUTE_PAGE_CAP = 1000;
|
|
7
|
+
function isRecord(value) {
|
|
8
|
+
return typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
9
|
+
}
|
|
10
|
+
function nonemptyString(value) {
|
|
11
|
+
return typeof value === 'string' && value.length > 0;
|
|
12
|
+
}
|
|
13
|
+
function responseItems(value) {
|
|
14
|
+
return isRecord(value) && Array.isArray(value.items) ? value.items : [];
|
|
15
|
+
}
|
|
16
|
+
function responseCount(value) {
|
|
17
|
+
if (!isRecord(value))
|
|
18
|
+
return 0;
|
|
19
|
+
for (const key of ['total', 'totalCount', 'count']) {
|
|
20
|
+
const count = value[key];
|
|
21
|
+
if (typeof count === 'number' && Number.isInteger(count) && count >= 0)
|
|
22
|
+
return count;
|
|
23
|
+
}
|
|
24
|
+
return 0;
|
|
25
|
+
}
|
|
26
|
+
function searchRow(value) {
|
|
27
|
+
if (!isRecord(value))
|
|
28
|
+
return undefined;
|
|
29
|
+
return value.type === 'ManagedContentVariantSearchResultRepresentation' &&
|
|
30
|
+
nonemptyString(value.id) &&
|
|
31
|
+
nonemptyString(value.managedContentSpaceId)
|
|
32
|
+
? { id: value.id, managedContentSpaceId: value.managedContentSpaceId }
|
|
33
|
+
: undefined;
|
|
34
|
+
}
|
|
35
|
+
function detailWorkspaceId(detail) {
|
|
36
|
+
const contentSpace = detail.contentSpace;
|
|
37
|
+
return isRecord(contentSpace) && nonemptyString(contentSpace.id) ? contentSpace.id : undefined;
|
|
38
|
+
}
|
|
39
|
+
function jsonBytes(value) {
|
|
40
|
+
return `${JSON.stringify(value, null, 2)}\n`;
|
|
41
|
+
}
|
|
42
|
+
async function exists(path) {
|
|
43
|
+
try {
|
|
44
|
+
await stat(path);
|
|
45
|
+
return true;
|
|
46
|
+
}
|
|
47
|
+
catch (error) {
|
|
48
|
+
if (isRecord(error) && error.code === 'ENOENT')
|
|
49
|
+
return false;
|
|
50
|
+
throw error;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
async function writeExclusive(path, value) {
|
|
54
|
+
const handle = await open(path, 'wx');
|
|
55
|
+
try {
|
|
56
|
+
await handle.writeFile(jsonBytes(value), 'utf8');
|
|
57
|
+
}
|
|
58
|
+
finally {
|
|
59
|
+
await handle.close();
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
export async function exportWorkspace(connection, workspaceId, destination, options = {}) {
|
|
63
|
+
if (!nonemptyString(workspaceId))
|
|
64
|
+
throw new TypeError('workspaceId must be a nonempty string');
|
|
65
|
+
if (!nonemptyString(destination))
|
|
66
|
+
throw new TypeError('destination must be a nonempty string');
|
|
67
|
+
if (await exists(destination))
|
|
68
|
+
throw new Error(`Export destination already exists: ${destination}`);
|
|
69
|
+
const warnings = [
|
|
70
|
+
{
|
|
71
|
+
code: 'UNSUPPORTED_WILDCARD',
|
|
72
|
+
message: 'Wildcard search is unsupported and this export is experimental best-effort.',
|
|
73
|
+
},
|
|
74
|
+
];
|
|
75
|
+
const rejected = new Set();
|
|
76
|
+
const ownershipMismatchIds = new Set();
|
|
77
|
+
const duplicateIds = new Set();
|
|
78
|
+
const candidates = new Map();
|
|
79
|
+
let expectedCount = 0;
|
|
80
|
+
let pagesRequested = 0;
|
|
81
|
+
let page = 0;
|
|
82
|
+
let pageLimit = 1;
|
|
83
|
+
while (page < pageLimit) {
|
|
84
|
+
const response = await requestJson(connection, getSelectedOperation('workspace.variant.search'), {
|
|
85
|
+
query: {
|
|
86
|
+
contentSpaceOrFolderIds: [workspaceId],
|
|
87
|
+
languages: ['All'],
|
|
88
|
+
page,
|
|
89
|
+
pageSize: PAGE_SIZE,
|
|
90
|
+
queryTerm: '*',
|
|
91
|
+
},
|
|
92
|
+
}, options);
|
|
93
|
+
pagesRequested += 1;
|
|
94
|
+
const items = responseItems(response.data);
|
|
95
|
+
if (page === 0) {
|
|
96
|
+
expectedCount = responseCount(response.data);
|
|
97
|
+
pageLimit = Math.min(ABSOLUTE_PAGE_CAP, Math.max(1, Math.ceil(expectedCount / PAGE_SIZE) + 2));
|
|
98
|
+
}
|
|
99
|
+
let additions = 0;
|
|
100
|
+
for (const item of items) {
|
|
101
|
+
const row = searchRow(item);
|
|
102
|
+
if (!row)
|
|
103
|
+
continue;
|
|
104
|
+
if (row.managedContentSpaceId !== workspaceId) {
|
|
105
|
+
rejected.add(row.id);
|
|
106
|
+
ownershipMismatchIds.add(row.id);
|
|
107
|
+
continue;
|
|
108
|
+
}
|
|
109
|
+
if (candidates.has(row.id)) {
|
|
110
|
+
duplicateIds.add(row.id);
|
|
111
|
+
}
|
|
112
|
+
else {
|
|
113
|
+
candidates.set(row.id, row);
|
|
114
|
+
additions += 1;
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
if (candidates.size >= expectedCount)
|
|
118
|
+
break;
|
|
119
|
+
if (items.length === 0) {
|
|
120
|
+
if (candidates.size < expectedCount) {
|
|
121
|
+
warnings.push({
|
|
122
|
+
code: 'PREMATURE_EMPTY_PAGE',
|
|
123
|
+
message: `Search returned an empty page before the advertised count was satisfied.`,
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
break;
|
|
127
|
+
}
|
|
128
|
+
if (additions === 0)
|
|
129
|
+
break;
|
|
130
|
+
page += 1;
|
|
131
|
+
}
|
|
132
|
+
if (duplicateIds.size > 0) {
|
|
133
|
+
warnings.push({
|
|
134
|
+
code: 'DUPLICATE_VARIANTS',
|
|
135
|
+
message: 'Duplicate variant IDs were ignored.',
|
|
136
|
+
variantIds: [...duplicateIds].toSorted(),
|
|
137
|
+
});
|
|
138
|
+
}
|
|
139
|
+
if (candidates.size !== expectedCount) {
|
|
140
|
+
warnings.push({
|
|
141
|
+
code: 'COUNT_MISMATCH',
|
|
142
|
+
message: `Advertised ${expectedCount} variants but found ${candidates.size}.`,
|
|
143
|
+
});
|
|
144
|
+
}
|
|
145
|
+
const details = new Map();
|
|
146
|
+
const failedIds = [];
|
|
147
|
+
for (const variantId of [...candidates.keys()].toSorted()) {
|
|
148
|
+
try {
|
|
149
|
+
const detail = await getVariant(connection, variantId, options);
|
|
150
|
+
if (detailWorkspaceId(detail) === workspaceId) {
|
|
151
|
+
details.set(variantId, detail);
|
|
152
|
+
}
|
|
153
|
+
else {
|
|
154
|
+
rejected.add(variantId);
|
|
155
|
+
ownershipMismatchIds.add(variantId);
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
catch {
|
|
159
|
+
failedIds.push(variantId);
|
|
160
|
+
warnings.push({
|
|
161
|
+
code: 'DETAIL_FAILED',
|
|
162
|
+
message: `Variant detail request failed for ${variantId}.`,
|
|
163
|
+
variantIds: [variantId],
|
|
164
|
+
});
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
if (ownershipMismatchIds.size > 0) {
|
|
168
|
+
warnings.push({
|
|
169
|
+
code: 'OWNERSHIP_MISMATCH',
|
|
170
|
+
message: 'Variants outside the requested workspace were rejected.',
|
|
171
|
+
variantIds: [...ownershipMismatchIds].toSorted(),
|
|
172
|
+
});
|
|
173
|
+
}
|
|
174
|
+
const entries = [...details.keys()].toSorted().map((variantId) => ({
|
|
175
|
+
file: `items/${variantId}.json`,
|
|
176
|
+
variantId,
|
|
177
|
+
}));
|
|
178
|
+
const manifest = {
|
|
179
|
+
schemaVersion: 1,
|
|
180
|
+
mode: 'experimental-best-effort',
|
|
181
|
+
workspaceId,
|
|
182
|
+
search: {
|
|
183
|
+
contentSpaceOrFolderIds: [workspaceId],
|
|
184
|
+
languages: ['All'],
|
|
185
|
+
pageSize: PAGE_SIZE,
|
|
186
|
+
queryTerm: '*',
|
|
187
|
+
},
|
|
188
|
+
expectedCount,
|
|
189
|
+
foundCount: candidates.size,
|
|
190
|
+
exportedCount: entries.length,
|
|
191
|
+
pagesRequested,
|
|
192
|
+
entries,
|
|
193
|
+
rejectedVariantIds: [...rejected].toSorted(),
|
|
194
|
+
failedVariantIds: failedIds.toSorted(),
|
|
195
|
+
warnings,
|
|
196
|
+
};
|
|
197
|
+
const parent = path.dirname(destination);
|
|
198
|
+
const temporary = path.join(parent, `.${path.basename(destination)}.tmp-${process.pid}-${Date.now()}`);
|
|
199
|
+
try {
|
|
200
|
+
await mkdir(temporary);
|
|
201
|
+
await mkdir(path.join(temporary, 'items'));
|
|
202
|
+
for (const entry of entries) {
|
|
203
|
+
await writeExclusive(path.join(temporary, entry.file), details.get(entry.variantId));
|
|
204
|
+
}
|
|
205
|
+
await writeExclusive(path.join(temporary, 'manifest.json'), manifest);
|
|
206
|
+
await rename(temporary, destination);
|
|
207
|
+
}
|
|
208
|
+
catch (error) {
|
|
209
|
+
await rm(temporary, { force: true, recursive: true });
|
|
210
|
+
throw error;
|
|
211
|
+
}
|
|
212
|
+
return { destination, manifest };
|
|
213
|
+
}
|
|
214
|
+
//# sourceMappingURL=export-workspace.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"export-workspace.js","sourceRoot":"","sources":["../../src/services/export-workspace.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AACjE,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EACL,oBAAoB,EACpB,WAAW,GAEZ,MAAM,8BAA8B,CAAC;AACtC,OAAO,EAAE,UAAU,EAAkB,MAAM,WAAW,CAAC;AAEvD,MAAM,SAAS,GAAG,GAAG,CAAC;AACtB,MAAM,iBAAiB,GAAG,IAAI,CAAC;AA+C/B,SAAS,QAAQ,CAAC,KAAc;IAC9B,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;AAC9E,CAAC;AAED,SAAS,cAAc,CAAC,KAAc;IACpC,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC;AACvD,CAAC;AAED,SAAS,aAAa,CAAC,KAAc;IACnC,OAAO,QAAQ,CAAC,KAAK,CAAC,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC;AAC1E,CAAC;AAED,SAAS,aAAa,CAAC,KAAc;IACnC,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC;QAAE,OAAO,CAAC,CAAC;IAC/B,KAAK,MAAM,GAAG,IAAI,CAAC,OAAO,EAAE,YAAY,EAAE,OAAO,CAAC,EAA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ce/core';
|
|
2
|
+
import type { JsonRequestOptions } from '../transport/json-request.js';
|
|
3
|
+
import type { WorkspaceExportManifest } from './export-workspace.js';
|
|
4
|
+
type RequestConnection = Pick<Connection, 'request'>;
|
|
5
|
+
type JsonObject = {
|
|
6
|
+
readonly [key: string]: JsonValue;
|
|
7
|
+
};
|
|
8
|
+
type JsonValue = boolean | JsonObject | readonly JsonValue[] | null | number | string;
|
|
9
|
+
export type WorkspaceImportItem = JsonObject & {
|
|
10
|
+
readonly apiName?: string;
|
|
11
|
+
readonly contentBody: JsonObject;
|
|
12
|
+
readonly contentKey: string;
|
|
13
|
+
readonly contentSpace: JsonObject & {
|
|
14
|
+
readonly id: string;
|
|
15
|
+
};
|
|
16
|
+
readonly contentType: string;
|
|
17
|
+
readonly externalId?: string;
|
|
18
|
+
readonly externalSource?: JsonObject;
|
|
19
|
+
readonly id: string;
|
|
20
|
+
readonly language: string;
|
|
21
|
+
readonly title: string;
|
|
22
|
+
readonly urlName?: string;
|
|
23
|
+
};
|
|
24
|
+
export type LoadedWorkspaceExport = {
|
|
25
|
+
readonly isPartial: boolean;
|
|
26
|
+
readonly items: readonly WorkspaceImportItem[];
|
|
27
|
+
readonly manifest: WorkspaceExportManifest;
|
|
28
|
+
readonly manifestSha256: string;
|
|
29
|
+
readonly sourceDirectory: string;
|
|
30
|
+
};
|
|
31
|
+
export type DestinationWorkspace = JsonObject & {
|
|
32
|
+
readonly defaultLanguage: string;
|
|
33
|
+
readonly id: string;
|
|
34
|
+
readonly rootFolderId: string;
|
|
35
|
+
};
|
|
36
|
+
export type WorkspaceImportGroupPlan = {
|
|
37
|
+
readonly contentKey: string;
|
|
38
|
+
readonly primary: WorkspaceImportItem;
|
|
39
|
+
readonly variants: readonly WorkspaceImportItem[];
|
|
40
|
+
};
|
|
41
|
+
export type WorkspaceImportPlan = {
|
|
42
|
+
readonly destinationWorkspaceId: string;
|
|
43
|
+
readonly groups: readonly WorkspaceImportGroupPlan[];
|
|
44
|
+
readonly rootFolderId: string;
|
|
45
|
+
readonly source: LoadedWorkspaceExport;
|
|
46
|
+
};
|
|
47
|
+
export type CreatedParentRecord = {
|
|
48
|
+
readonly childVariantIds: string[];
|
|
49
|
+
readonly contentId: string;
|
|
50
|
+
readonly contentKey: string;
|
|
51
|
+
readonly primaryVariantId: string;
|
|
52
|
+
};
|
|
53
|
+
export type WorkspaceImportOperation = {
|
|
54
|
+
readonly contentKey: string;
|
|
55
|
+
readonly destinationOrgId: string;
|
|
56
|
+
readonly destinationWorkspaceId: string;
|
|
57
|
+
readonly language: string;
|
|
58
|
+
readonly operationId: string;
|
|
59
|
+
readonly operationKind: 'create-parent' | 'create-child';
|
|
60
|
+
readonly requestIdentity: string;
|
|
61
|
+
readonly requestSha256: string;
|
|
62
|
+
readonly runId: string;
|
|
63
|
+
error?: string;
|
|
64
|
+
result?: {
|
|
65
|
+
readonly contentId?: string;
|
|
66
|
+
readonly primaryVariantId?: string;
|
|
67
|
+
readonly variantId?: string;
|
|
68
|
+
};
|
|
69
|
+
state: 'pending' | 'succeeded' | 'failed';
|
|
70
|
+
};
|
|
71
|
+
export type WorkspaceImportRunReport = {
|
|
72
|
+
readonly createdParents: CreatedParentRecord[];
|
|
73
|
+
readonly destinationOrgId: string;
|
|
74
|
+
readonly destinationWorkspaceId: string;
|
|
75
|
+
readonly operations: WorkspaceImportOperation[];
|
|
76
|
+
readonly runId: string;
|
|
77
|
+
readonly sourceDirectory: string;
|
|
78
|
+
readonly sourceManifestSha256: string;
|
|
79
|
+
state: 'applying' | 'completed' | 'failed' | 'ownership-uncertain';
|
|
80
|
+
};
|
|
81
|
+
export declare class WorkspaceImportOwnershipUncertainError extends Error {
|
|
82
|
+
readonly operation: WorkspaceImportOperation;
|
|
83
|
+
readonly state: "ownership-uncertain";
|
|
84
|
+
constructor(operation: WorkspaceImportOperation, cause: unknown);
|
|
85
|
+
}
|
|
86
|
+
export type WorkspaceImportReportPersistence = {
|
|
87
|
+
readonly rewrite: (file: string, report: WorkspaceImportRunReport) => Promise<void>;
|
|
88
|
+
};
|
|
89
|
+
export type ExecuteWorkspaceImportOptions = {
|
|
90
|
+
readonly allowPartial?: boolean;
|
|
91
|
+
readonly connection: RequestConnection;
|
|
92
|
+
readonly destinationOrgId: string;
|
|
93
|
+
readonly destinationWorkspace: unknown;
|
|
94
|
+
readonly dryRun?: boolean;
|
|
95
|
+
readonly reportDirectory?: string;
|
|
96
|
+
readonly reportPersistence?: WorkspaceImportReportPersistence;
|
|
97
|
+
readonly requestOptions?: JsonRequestOptions;
|
|
98
|
+
readonly sourceDirectory: string;
|
|
99
|
+
readonly workspaceId: string;
|
|
100
|
+
};
|
|
101
|
+
export type WorkspaceImportResult = {
|
|
102
|
+
readonly dryRun: boolean;
|
|
103
|
+
readonly plan: WorkspaceImportPlan;
|
|
104
|
+
readonly report?: WorkspaceImportRunReport;
|
|
105
|
+
readonly reportFile?: string;
|
|
106
|
+
};
|
|
107
|
+
export declare function loadWorkspaceExport(sourceDirectory: string, options?: {
|
|
108
|
+
readonly allowPartial?: boolean;
|
|
109
|
+
}): Promise<LoadedWorkspaceExport>;
|
|
110
|
+
export declare function planWorkspaceImport(source: LoadedWorkspaceExport, workspace: unknown, expectedWorkspaceId: string): WorkspaceImportPlan;
|
|
111
|
+
export declare function executeWorkspaceImport(options: ExecuteWorkspaceImportOptions): Promise<WorkspaceImportResult>;
|
|
112
|
+
export {};
|