@superdoc/mcp 1.10.0-next.14 → 1.10.0-next.15
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/dist/index.js +268 -66
- package/package.json +4 -4
package/dist/index.js
CHANGED
|
@@ -31630,7 +31630,7 @@ var init_host = __esm(() => {
|
|
|
31630
31630
|
});
|
|
31631
31631
|
|
|
31632
31632
|
// ../../packages/sdk/langs/node/src/runtime/sdk-version.generated.ts
|
|
31633
|
-
var SDK_VERSION = "2.23.0-next.
|
|
31633
|
+
var SDK_VERSION = "2.23.0-next.15";
|
|
31634
31634
|
|
|
31635
31635
|
// ../../packages/sdk/langs/node/src/runtime/embedded-platform.ts
|
|
31636
31636
|
import { accessSync, chmodSync, constants, existsSync, statSync } from "node:fs";
|
|
@@ -89618,9 +89618,9 @@ class ExecutionContext {
|
|
|
89618
89618
|
{ ...options, expectedRevision: options?.expectedRevision ?? revision }
|
|
89619
89619
|
] : [args, options]);
|
|
89620
89620
|
this.executedOperations.push({ operationId, result });
|
|
89621
|
-
if (result
|
|
89621
|
+
if (isRecord(result) && result.success === false)
|
|
89622
89622
|
throw new SuperDocCliError("Document operation did not apply.", {
|
|
89623
|
-
code: result.failure
|
|
89623
|
+
code: isRecord(result.failure) && typeof result.failure.code === "string" ? result.failure.code : "APPLY_FAILED",
|
|
89624
89624
|
details: result
|
|
89625
89625
|
});
|
|
89626
89626
|
if (supportsDocumentFacts(this.source)) {
|
|
@@ -327442,6 +327442,50 @@ function paragraphStyleId(xml) {
|
|
|
327442
327442
|
const attrs = directChildElementAttrs(pPrXml, "pStyle");
|
|
327443
327443
|
return attrs == null ? null : xmlAttribute2(attrs, "val");
|
|
327444
327444
|
}
|
|
327445
|
+
function readPartParagraphStyleReferences(context, partUri) {
|
|
327446
|
+
const bytes = getSDDocumentSessionInternalPartBytes(context.session, partUri);
|
|
327447
|
+
if (!bytes)
|
|
327448
|
+
return null;
|
|
327449
|
+
const xml = TD91.decode(bytes);
|
|
327450
|
+
const parsed = collectXmlElementRanges(xml);
|
|
327451
|
+
if (parsed.errors.length)
|
|
327452
|
+
return null;
|
|
327453
|
+
const ranges = parsed.ranges.sort((left, right) => left.start - right.start);
|
|
327454
|
+
const references = [];
|
|
327455
|
+
const paragraphs2 = [];
|
|
327456
|
+
const wordNamespaces = new Set([
|
|
327457
|
+
"http://schemas.openxmlformats.org/wordprocessingml/2006/main",
|
|
327458
|
+
"http://purl.oclc.org/ooxml/wordprocessingml/main"
|
|
327459
|
+
]);
|
|
327460
|
+
for (const range of ranges) {
|
|
327461
|
+
while (paragraphs2.length && range.start >= paragraphs2.at(-1).range.end)
|
|
327462
|
+
paragraphs2.pop();
|
|
327463
|
+
if (!wordNamespaces.has(range.tag.namespaceUri))
|
|
327464
|
+
continue;
|
|
327465
|
+
if (range.tag.localName === "p") {
|
|
327466
|
+
const reference = {
|
|
327467
|
+
xmlStart: range.start,
|
|
327468
|
+
rawXml: xml.slice(range.start, range.end),
|
|
327469
|
+
namespaceBindings: range.namespaceBindings,
|
|
327470
|
+
styleIds: new Set,
|
|
327471
|
+
unresolved: false
|
|
327472
|
+
};
|
|
327473
|
+
references.push(reference);
|
|
327474
|
+
paragraphs2.push({ range, reference });
|
|
327475
|
+
} else if (range.tag.localName === "pStyle") {
|
|
327476
|
+
const paragraph2 = paragraphs2.at(-1);
|
|
327477
|
+
if (!paragraph2)
|
|
327478
|
+
return null;
|
|
327479
|
+
const values = range.tag.attributes.filter((attribute2) => attribute2.localName === "val");
|
|
327480
|
+
if (range.tag.namespaceUri !== paragraph2.range.tag.namespaceUri || values.length !== 1 || values[0].namespaceUri !== range.tag.namespaceUri || !values[0].value) {
|
|
327481
|
+
paragraph2.reference.unresolved = true;
|
|
327482
|
+
} else {
|
|
327483
|
+
paragraph2.reference.styleIds.add(values[0].value);
|
|
327484
|
+
}
|
|
327485
|
+
}
|
|
327486
|
+
}
|
|
327487
|
+
return references;
|
|
327488
|
+
}
|
|
327445
327489
|
function currentRevisionString(context) {
|
|
327446
327490
|
return context.currentPublicRevision();
|
|
327447
327491
|
}
|
|
@@ -337139,6 +337183,41 @@ var init_adapter5 = __esm(() => {
|
|
|
337139
337183
|
});
|
|
337140
337184
|
|
|
337141
337185
|
// ../../../v2/document-api-v2-adapter/dist/protection/mutation-guard.js
|
|
337186
|
+
function isDocumentProtectionEnforced(context) {
|
|
337187
|
+
return new V2ProtectionAdapter(context).get().editingRestriction.runtimeEnforced;
|
|
337188
|
+
}
|
|
337189
|
+
function paragraphProtectionAllows(context, snapshot2) {
|
|
337190
|
+
if (!isDocumentProtectionEnforced(context))
|
|
337191
|
+
return true;
|
|
337192
|
+
const bytes = getSDDocumentSessionInternalPartBytes(context.session, snapshot2.partUri);
|
|
337193
|
+
if (!bytes || new TextDecoder().decode(bytes.subarray(snapshot2.byteStart, snapshot2.byteEnd)) !== snapshot2.rawXml)
|
|
337194
|
+
return false;
|
|
337195
|
+
const start = new TextDecoder().decode(bytes.subarray(0, snapshot2.byteStart)).length;
|
|
337196
|
+
return paragraphXmlProtectionAllows(context, snapshot2.partUri, start, snapshot2.rawXml, snapshot2.namespaceBindings);
|
|
337197
|
+
}
|
|
337198
|
+
function paragraphXmlProtectionAllows(context, partUri, start, rawXml, namespaceBindings) {
|
|
337199
|
+
if (documentProtectionAllowsXmlRange(context, partUri, start, start + rawXml.length))
|
|
337200
|
+
return true;
|
|
337201
|
+
const parsed = collectXmlElementRanges(rawXml, { fragment: true, additionalNamespaces: namespaceBindings });
|
|
337202
|
+
if (parsed.errors.length)
|
|
337203
|
+
return false;
|
|
337204
|
+
const root = parsed.ranges.find((range) => range.start === 0 && range.end === rawXml.length);
|
|
337205
|
+
if (!root || root.tag.localName !== "p" || !["http://schemas.openxmlformats.org/wordprocessingml/2006/main", "http://purl.oclc.org/ooxml/wordprocessingml/main"].includes(root.tag.namespaceUri))
|
|
337206
|
+
return false;
|
|
337207
|
+
const children2 = [];
|
|
337208
|
+
let cursor = root.openEnd;
|
|
337209
|
+
for (const range of parsed.ranges.sort((a, b) => a.start - b.start)) {
|
|
337210
|
+
if (range === root || range.start < cursor || range.end > root.closeStart)
|
|
337211
|
+
continue;
|
|
337212
|
+
children2.push(range);
|
|
337213
|
+
cursor = range.end;
|
|
337214
|
+
}
|
|
337215
|
+
const content = children2.filter((range) => range.tag.namespaceUri !== root.tag.namespaceUri || !["pPr", "permStart", "permEnd", "bookmarkStart", "bookmarkEnd", "proofErr", "commentRangeStart", "commentRangeEnd"].includes(range.tag.localName));
|
|
337216
|
+
if (!content.length) {
|
|
337217
|
+
return children2.some((range) => range.tag.namespaceUri === root.tag.namespaceUri && range.tag.localName === "permStart" && documentProtectionAllowsXmlRange(context, partUri, start + range.end, start + range.end));
|
|
337218
|
+
}
|
|
337219
|
+
return documentProtectionAllowsXmlRange(context, partUri, start + content[0].start, start + content.at(-1).end);
|
|
337220
|
+
}
|
|
337142
337221
|
function permissionRangeAllowsCurrentUser(context, range) {
|
|
337143
337222
|
if (range.malformed || !range.principalSupported)
|
|
337144
337223
|
return false;
|
|
@@ -337151,7 +337230,7 @@ function permissionRangeAllowsCurrentUser(context, range) {
|
|
|
337151
337230
|
return typeof user.id === "string" && user.id.length > 0 && principal === user.id || typeof user.email === "string" && user.email.trim().length > 0 && principal.toLowerCase() === user.email.trim().toLowerCase();
|
|
337152
337231
|
}
|
|
337153
337232
|
function documentProtectionAllowsXmlRange(context, partUri, start, end) {
|
|
337154
|
-
if (!
|
|
337233
|
+
if (!isDocumentProtectionEnforced(context))
|
|
337155
337234
|
return true;
|
|
337156
337235
|
if (start < 0 || end < start)
|
|
337157
337236
|
return false;
|
|
@@ -337167,7 +337246,7 @@ function requireDocumentProtectionXmlRange(context, partUri, start, end) {
|
|
|
337167
337246
|
}
|
|
337168
337247
|
}
|
|
337169
337248
|
function documentProtectionAllowsXmlRewrite(context, partUri, before, after) {
|
|
337170
|
-
if (!
|
|
337249
|
+
if (!isDocumentProtectionEnforced(context) || before === after)
|
|
337171
337250
|
return true;
|
|
337172
337251
|
let start = 0;
|
|
337173
337252
|
while (start < before.length && start < after.length && before[start] === after[start])
|
|
@@ -337182,6 +337261,7 @@ function documentProtectionAllowsXmlRewrite(context, partUri, before, after) {
|
|
|
337182
337261
|
}
|
|
337183
337262
|
var DOCUMENT_PROTECTION_MESSAGE = "document protection permits edits only within a permission range granted to the current user or everyone.";
|
|
337184
337263
|
var init_mutation_guard = __esm(() => {
|
|
337264
|
+
init_sd_document_session_internal();
|
|
337185
337265
|
init_shared();
|
|
337186
337266
|
init_adapter4();
|
|
337187
337267
|
init_adapter5();
|
|
@@ -394279,6 +394359,9 @@ class V2SectionsAdapter {
|
|
|
394279
394359
|
return this.commitSectionMutation(input.target.sectionId, "sections-title-page", options, (xml) => setToggleChildXml(xml, "titlePg", input.enabled));
|
|
394280
394360
|
}
|
|
394281
394361
|
setOddEvenHeadersFooters(input, options) {
|
|
394362
|
+
const protectionFailure = sectionProtectionFailure(this.context);
|
|
394363
|
+
if (protectionFailure)
|
|
394364
|
+
return documentFailure(protectionFailure.message, protectionFailure.code);
|
|
394282
394365
|
const trackedFailure = sectionTrackedModeFailure(options);
|
|
394283
394366
|
if (trackedFailure)
|
|
394284
394367
|
return documentFailure(trackedFailure.message, trackedFailure.code);
|
|
@@ -394303,6 +394386,9 @@ class V2SectionsAdapter {
|
|
|
394303
394386
|
return this.commitSectionMutation(input.target.sectionId, "sections-clear-header-footer-ref", options, (xml) => removeHeaderFooterRefXml(xml, input.kind, input.variant), { reportChangeMode: false });
|
|
394304
394387
|
}
|
|
394305
394388
|
setLinkToPrevious(input, options) {
|
|
394389
|
+
const protectionFailure = sectionProtectionFailure(this.context);
|
|
394390
|
+
if (protectionFailure)
|
|
394391
|
+
return sectionFailure(protectionFailure.message, protectionFailure.code);
|
|
394306
394392
|
if (input.linked) {
|
|
394307
394393
|
const currentRefId = readExplicitHeaderFooterRefId(this.context, {
|
|
394308
394394
|
kind: "headerFooterSlot",
|
|
@@ -394340,6 +394426,9 @@ class V2SectionsAdapter {
|
|
|
394340
394426
|
});
|
|
394341
394427
|
}
|
|
394342
394428
|
commitSetHeaderFooterRef(input, options) {
|
|
394429
|
+
const protectionFailure = sectionProtectionFailure(this.context);
|
|
394430
|
+
if (protectionFailure)
|
|
394431
|
+
return sectionFailure(protectionFailure.message, protectionFailure.code);
|
|
394343
394432
|
const resolution = createHeaderFooterPartRefExists(this.context, input.refId, input.kind);
|
|
394344
394433
|
if (!resolution.ok)
|
|
394345
394434
|
return sectionFailure(resolution.failure.message, resolution.failure.code);
|
|
@@ -394390,6 +394479,9 @@ class V2SectionsAdapter {
|
|
|
394390
394479
|
return result;
|
|
394391
394480
|
}
|
|
394392
394481
|
commitSectionMutation(sectionId, txIdPrefix, options, mutate, mutationOptions) {
|
|
394482
|
+
const protectionFailure = sectionProtectionFailure(this.context);
|
|
394483
|
+
if (protectionFailure)
|
|
394484
|
+
return sectionFailure(protectionFailure.message, protectionFailure.code);
|
|
394393
394485
|
const begun = this.context.beginMutation({ expectedRevision: options?.expectedRevision });
|
|
394394
394486
|
if ("failure" in begun)
|
|
394395
394487
|
return sectionFailure(begun.failure.message, begun.failure.code);
|
|
@@ -394420,6 +394512,9 @@ class V2SectionsAdapter {
|
|
|
394420
394512
|
};
|
|
394421
394513
|
}
|
|
394422
394514
|
}
|
|
394515
|
+
function sectionProtectionFailure(context) {
|
|
394516
|
+
return isDocumentProtectionEnforced(context) ? { code: "PERMISSION_DENIED", message: DOCUMENT_PROTECTION_MESSAGE } : null;
|
|
394517
|
+
}
|
|
394423
394518
|
function materializeTrailingFinalSectionInheritedRef(context, input, options) {
|
|
394424
394519
|
const sections = readLiveSectionSignals(context);
|
|
394425
394520
|
const targetIndex = sections.findIndex((section) => section.sectionId === input.target.sectionId);
|
|
@@ -394739,6 +394834,8 @@ function documentFailure(message, code2 = "CAPABILITY_UNAVAILABLE") {
|
|
|
394739
394834
|
}
|
|
394740
394835
|
var VALID_BREAK_TYPES, VALID_PAGE_NUMBER_FORMATS, VALID_LINE_NUMBER_RESTARTS, VALID_VERTICAL_ALIGNS, VALID_PAGE_BORDER_DISPLAYS, VALID_PAGE_BORDER_OFFSETS, VALID_PAGE_BORDER_Z_ORDERS;
|
|
394741
394836
|
var init_adapter13 = __esm(() => {
|
|
394837
|
+
init_mutation_guard();
|
|
394838
|
+
init_mutation_guard();
|
|
394742
394839
|
init_src3();
|
|
394743
394840
|
init_sd_document_session_internal();
|
|
394744
394841
|
init_document_reader();
|
|
@@ -395083,6 +395180,8 @@ class V2CreateAdapter {
|
|
|
395083
395180
|
const invalid4 = this.context.validateMutation(options);
|
|
395084
395181
|
if (invalid4)
|
|
395085
395182
|
return createFailure(invalid4.code, invalid4.message);
|
|
395183
|
+
if (isDocumentProtectionEnforced(this.context))
|
|
395184
|
+
return createFailure("PERMISSION_DENIED", DOCUMENT_PROTECTION_MESSAGE);
|
|
395086
395185
|
const publicSectionId = "(dry-run)";
|
|
395087
395186
|
const begun = this.context.beginMutation({ expectedRevision: options?.expectedRevision });
|
|
395088
395187
|
if ("failure" in begun)
|
|
@@ -395981,6 +396080,7 @@ function storyErrorMessage2(error48) {
|
|
|
395981
396080
|
var VALUED_TOC_SWITCHES;
|
|
395982
396081
|
var init_adapter14 = __esm(() => {
|
|
395983
396082
|
init_sd_document_session_internal();
|
|
396083
|
+
init_mutation_guard();
|
|
395984
396084
|
init_sd_document_session_internal();
|
|
395985
396085
|
init_materialize_slot();
|
|
395986
396086
|
init_adapter10();
|
|
@@ -405412,6 +405512,9 @@ class V2ListsAdapter {
|
|
|
405412
405512
|
const adjacentReuse = compatibleAdjacentListReuse(this.context, storyId, input.reuseNumId == null ? findImmediatelyAdjacentCompatibleListReuse(this.context, storyId, [target.nodeId], input.seed, input.ilvl) : undefined, options);
|
|
405413
405513
|
const reuseNumId = input.reuseNumId ?? adjacentReuse?.numId;
|
|
405414
405514
|
const mergeParaIds = adjacentReuse?.mergeParaIds ?? [];
|
|
405515
|
+
const protectionFailure = listParagraphProtectionFailure(this.context, storyId, [target.nodeId, ...mergeParaIds]);
|
|
405516
|
+
if (protectionFailure)
|
|
405517
|
+
return protectionFailure;
|
|
405415
405518
|
const existingTrackedListFormattingIds = readTrackedListFormattingIdsForTrackedMutation(this.context, options);
|
|
405416
405519
|
const begun = this.context.beginMutation({
|
|
405417
405520
|
expectedRevision: options?.expectedRevision
|
|
@@ -406094,6 +406197,19 @@ class V2ListsAdapter {
|
|
|
406094
406197
|
if (!storyId) {
|
|
406095
406198
|
return failure8("TARGET_NOT_FOUND", `paragraph ${paraIds[0]} was not found.`);
|
|
406096
406199
|
}
|
|
406200
|
+
if (mode === "empty" && isDocumentProtectionEnforced(this.context)) {
|
|
406201
|
+
const anchor = readStoryParagraphByBlockId(this.context, storyId, paraIds[0]);
|
|
406202
|
+
const bytes = anchor && getSDDocumentSessionInternalPartBytes(this.context.session, anchor.partUri);
|
|
406203
|
+
if (!anchor || !bytes)
|
|
406204
|
+
return failure8("PERMISSION_DENIED", DOCUMENT_PROTECTION_MESSAGE);
|
|
406205
|
+
const point3 = new TextDecoder().decode(bytes.subarray(0, anchor.byteEnd)).length;
|
|
406206
|
+
if (!documentProtectionAllowsXmlRange(this.context, anchor.partUri, point3, point3)) {
|
|
406207
|
+
return failure8("PERMISSION_DENIED", DOCUMENT_PROTECTION_MESSAGE);
|
|
406208
|
+
}
|
|
406209
|
+
}
|
|
406210
|
+
const protectionFailure = mode === "empty" ? null : listParagraphProtectionFailure(this.context, storyId, paraIds);
|
|
406211
|
+
if (protectionFailure)
|
|
406212
|
+
return protectionFailure;
|
|
406097
406213
|
if (mode === "fromParagraphs" && compatibleMergeParaIds(this.context, storyId, paraIds, options).length !== paraIds.length) {
|
|
406098
406214
|
return failure8("CAPABILITY_UNAVAILABLE", "List creation cannot overwrite an existing paragraph-property proposal.");
|
|
406099
406215
|
}
|
|
@@ -406234,6 +406350,9 @@ class V2ListsAdapter {
|
|
|
406234
406350
|
reuseNumId = adjacentReuse?.numId;
|
|
406235
406351
|
mergeParaIds = adjacentReuse?.mergeParaIds ?? [];
|
|
406236
406352
|
}
|
|
406353
|
+
const protectionFailure = listParagraphProtectionFailure(this.context, storyId, [...paraIds, ...mergeParaIds]);
|
|
406354
|
+
if (protectionFailure)
|
|
406355
|
+
return protectionFailure;
|
|
406237
406356
|
const begun = this.context.beginMutation({
|
|
406238
406357
|
expectedRevision: options?.expectedRevision
|
|
406239
406358
|
});
|
|
@@ -408140,10 +408259,23 @@ function readCreatedParagraphRefId(createdRefs, provisionalToFinal) {
|
|
|
408140
408259
|
}
|
|
408141
408260
|
return null;
|
|
408142
408261
|
}
|
|
408262
|
+
function listParagraphProtectionFailure(context, storyId, paraIds) {
|
|
408263
|
+
if (!isDocumentProtectionEnforced(context))
|
|
408264
|
+
return null;
|
|
408265
|
+
for (const paraId of paraIds) {
|
|
408266
|
+
const snapshot2 = readStoryParagraphByBlockId(context, storyId, paraId);
|
|
408267
|
+
if (!snapshot2 || !paragraphProtectionAllows(context, snapshot2)) {
|
|
408268
|
+
return failure8("PERMISSION_DENIED", DOCUMENT_PROTECTION_MESSAGE);
|
|
408269
|
+
}
|
|
408270
|
+
}
|
|
408271
|
+
return null;
|
|
408272
|
+
}
|
|
408143
408273
|
var LISTS_XML_DECODER, BULLET_GLYPH_BY_LEVEL;
|
|
408144
408274
|
var init_adapter16 = __esm(() => {
|
|
408145
408275
|
init_src3();
|
|
408146
408276
|
init_sd_document_session_internal();
|
|
408277
|
+
init_document_reader();
|
|
408278
|
+
init_mutation_guard();
|
|
408147
408279
|
init_adapter();
|
|
408148
408280
|
init_composite();
|
|
408149
408281
|
init_stories();
|
|
@@ -408177,17 +408309,12 @@ class V2ParagraphsAdapter {
|
|
|
408177
408309
|
if (!input.paraIds.length || !["indent", "outdent"].includes(input.direction)) {
|
|
408178
408310
|
return fail6("INVALID_INPUT", "A nonempty paragraph range and indent direction are required.");
|
|
408179
408311
|
}
|
|
408180
|
-
if (
|
|
408312
|
+
if (isDocumentProtectionEnforced(this.context)) {
|
|
408181
408313
|
for (const nodeId of new Set(input.paraIds)) {
|
|
408182
408314
|
const resolved = resolveParagraphSnapshot(this.context, { kind: "block", nodeType: "paragraph", nodeId });
|
|
408183
408315
|
if ("failure" in resolved)
|
|
408184
408316
|
return fail6(resolved.failure.code, resolved.failure.message);
|
|
408185
|
-
|
|
408186
|
-
const bytes = getSDDocumentSessionInternalPartBytes(this.context.session, snapshot2.partUri);
|
|
408187
|
-
if (!bytes)
|
|
408188
|
-
return fail6("PRECONDITION_FAILED", `Part bytes are unavailable for ${snapshot2.partUri}.`);
|
|
408189
|
-
const start = TD112.decode(bytes.subarray(0, snapshot2.byteStart)).length;
|
|
408190
|
-
if (!documentProtectionAllowsXmlRange(this.context, snapshot2.partUri, start, start + snapshot2.rawXml.length)) {
|
|
408317
|
+
if (!paragraphProtectionAllows(this.context, resolved.snapshot)) {
|
|
408191
408318
|
return fail6("PERMISSION_DENIED", DOCUMENT_PROTECTION_MESSAGE);
|
|
408192
408319
|
}
|
|
408193
408320
|
}
|
|
@@ -408510,6 +408637,14 @@ class V2ParagraphsAdapter {
|
|
|
408510
408637
|
return this.commitParagraphRewrite(snapshot2, target, options, txIdPrefix, nextParagraphXml, currentBytes, undefined, mutation.extraPerPart, mutation.semanticStyleDependencies, mutation.renderImpact, mutation.trackedProperty);
|
|
408511
408638
|
}
|
|
408512
408639
|
commitParagraphRewrite(snapshot2, target, options, txIdPrefix, nextParagraphXml, currentBytes = getSDDocumentSessionInternalPartBytes(this.context.session, snapshot2.partUri), trackedOverride, extraPerPart, semanticStyleDependencies, renderImpact, trackedProperty) {
|
|
408640
|
+
if (isDocumentProtectionEnforced(this.context)) {
|
|
408641
|
+
if (!currentBytes) {
|
|
408642
|
+
return paragraphFailure("PRECONDITION_FAILED", `Part bytes are unavailable for ${snapshot2.partUri}.`, target);
|
|
408643
|
+
}
|
|
408644
|
+
if (Object.keys(extraPerPart ?? {}).length > 0 && !semanticStyleDependencies?.length || !paragraphProtectionAllows(this.context, snapshot2)) {
|
|
408645
|
+
return paragraphFailure("PERMISSION_DENIED", DOCUMENT_PROTECTION_MESSAGE, target);
|
|
408646
|
+
}
|
|
408647
|
+
}
|
|
408513
408648
|
if (nextParagraphXml === snapshot2.rawXml && Object.keys(extraPerPart ?? {}).length === 0) {
|
|
408514
408649
|
return options?.dryRun ? paragraphSuccess(target) : paragraphNoOp(`${txIdPrefixToOperation(txIdPrefix)} produced no changes.`, target);
|
|
408515
408650
|
}
|
|
@@ -408687,6 +408822,29 @@ function resolveParagraphStylePlan(context, input, currentStyleId) {
|
|
|
408687
408822
|
message: "semantic-style-resolution-drift"
|
|
408688
408823
|
};
|
|
408689
408824
|
}
|
|
408825
|
+
if (compiled.value.changedStylesPart && isDocumentProtectionEnforced(context)) {
|
|
408826
|
+
const styles = Object.entries(compileWordStyleModel({
|
|
408827
|
+
stylesXml: readStyleDefinitionsPartBytes(context)
|
|
408828
|
+
}).translatedLinkedStyles.styles);
|
|
408829
|
+
const dependentStyleIds = new Set([styleId]);
|
|
408830
|
+
const pendingStyleIds = [styleId];
|
|
408831
|
+
while (pendingStyleIds.length) {
|
|
408832
|
+
const parentStyleId = pendingStyleIds.pop();
|
|
408833
|
+
for (const [id, definition2] of styles) {
|
|
408834
|
+
if (definition2.basedOn === parentStyleId && !dependentStyleIds.has(id)) {
|
|
408835
|
+
dependentStyleIds.add(id);
|
|
408836
|
+
pendingStyleIds.push(id);
|
|
408837
|
+
}
|
|
408838
|
+
}
|
|
408839
|
+
}
|
|
408840
|
+
const partUris = new Set(listSDDocumentSessionInternalStories(context.session).map((story) => story.partUri));
|
|
408841
|
+
for (const partUri of partUris) {
|
|
408842
|
+
const paragraphs2 = readPartParagraphStyleReferences(context, partUri);
|
|
408843
|
+
if (!paragraphs2 || paragraphs2.some((paragraph4) => (paragraph4.unresolved || role === "default-paragraph" || [...paragraph4.styleIds].some((id) => dependentStyleIds.has(id))) && !paragraphXmlProtectionAllows(context, partUri, paragraph4.xmlStart, paragraph4.rawXml, paragraph4.namespaceBindings))) {
|
|
408844
|
+
return { ok: false, code: "PERMISSION_DENIED", message: DOCUMENT_PROTECTION_MESSAGE };
|
|
408845
|
+
}
|
|
408846
|
+
}
|
|
408847
|
+
}
|
|
408690
408848
|
return {
|
|
408691
408849
|
ok: true,
|
|
408692
408850
|
styleId,
|
|
@@ -408714,6 +408872,9 @@ function resolveParagraphSnapshot(context, target) {
|
|
|
408714
408872
|
if ("error" in initial) {
|
|
408715
408873
|
return { failure: { code: storyErrorCode3(initial.error), message: storyErrorMessage3(initial.error) } };
|
|
408716
408874
|
}
|
|
408875
|
+
if (initial.materialization && isDocumentProtectionEnforced(context)) {
|
|
408876
|
+
return { failure: { code: "PERMISSION_DENIED", message: DOCUMENT_PROTECTION_MESSAGE } };
|
|
408877
|
+
}
|
|
408717
408878
|
const materialized = materializeHeaderFooterSlotIfInherited(context, initial, target.story);
|
|
408718
408879
|
if (!materialized.ok)
|
|
408719
408880
|
return { failure: materialized.failure };
|
|
@@ -408873,7 +409034,6 @@ var init_adapter17 = __esm(() => {
|
|
|
408873
409034
|
init_composite();
|
|
408874
409035
|
init_stories();
|
|
408875
409036
|
init_text_range_shifts();
|
|
408876
|
-
init_adapter5();
|
|
408877
409037
|
init_mutation_guard();
|
|
408878
409038
|
TD112 = new TextDecoder;
|
|
408879
409039
|
TE63 = new TextEncoder;
|
|
@@ -422153,7 +422313,7 @@ class V2ImagesAdapter {
|
|
|
422153
422313
|
const blocked = guardCanonicalMutation2(this.context, options, "create.image");
|
|
422154
422314
|
if (blocked)
|
|
422155
422315
|
return blocked;
|
|
422156
|
-
if (
|
|
422316
|
+
if (isDocumentProtectionEnforced(this.context)) {
|
|
422157
422317
|
const at = input.at;
|
|
422158
422318
|
const locator = (at && "target" in at ? at.target.story : undefined) ?? input.in ?? { kind: "story", storyType: "body" };
|
|
422159
422319
|
const story = this.context.resolveFullStoryLocator(locator);
|
|
@@ -422309,10 +422469,10 @@ class V2ImagesAdapter {
|
|
|
422309
422469
|
}
|
|
422310
422470
|
delete(input, options = {}) {
|
|
422311
422471
|
options = mergeInputDryRun(input, options);
|
|
422312
|
-
const
|
|
422472
|
+
const entry = readBodyImageEntryById(this.context, input.imageId);
|
|
422473
|
+
const blocked = guardCanonicalMutation2(this.context, options, "images.delete", { id: input.imageId, entry, ownership: "carrier" });
|
|
422313
422474
|
if (blocked)
|
|
422314
422475
|
return blocked;
|
|
422315
|
-
const entry = readBodyImageEntryById(this.context, input.imageId);
|
|
422316
422476
|
if (!entry)
|
|
422317
422477
|
return mutationFailure4("TARGET_NOT_FOUND", `images.delete: image "${input.imageId}" was not found.`);
|
|
422318
422478
|
const unsupported5 = validateImageDeleteTarget(this.context, entry);
|
|
@@ -422859,10 +423019,10 @@ class V2ImagesAdapter {
|
|
|
422859
423019
|
}
|
|
422860
423020
|
move(input, options = {}) {
|
|
422861
423021
|
options = mergeInputDryRun(input, options);
|
|
422862
|
-
const
|
|
423022
|
+
const entry = readBodyImageEntryById(this.context, input.imageId);
|
|
423023
|
+
const blocked = guardCanonicalMutation2(this.context, options, "images.move", { id: input.imageId, entry, ownership: "closed" });
|
|
422863
423024
|
if (blocked)
|
|
422864
423025
|
return blocked;
|
|
422865
|
-
const entry = readBodyImageEntryById(this.context, input.imageId);
|
|
422866
423026
|
if (!entry)
|
|
422867
423027
|
return mutationFailure4("TARGET_NOT_FOUND", `images.move: image "${input.imageId}" was not found.`);
|
|
422868
423028
|
if (!entry.paragraph) {
|
|
@@ -423157,10 +423317,10 @@ class V2ImagesAdapter {
|
|
|
423157
423317
|
}
|
|
423158
423318
|
convertToInline(input, options = {}) {
|
|
423159
423319
|
options = mergeInputDryRun(input, options);
|
|
423160
|
-
const
|
|
423320
|
+
const entry = readBodyImageEntryById(this.context, input.imageId);
|
|
423321
|
+
const blocked = guardCanonicalMutation2(this.context, options, "images.convertToInline", { id: input.imageId, entry, ownership: "drawing" });
|
|
423161
423322
|
if (blocked)
|
|
423162
423323
|
return blocked;
|
|
423163
|
-
const entry = readBodyImageEntryById(this.context, input.imageId);
|
|
423164
423324
|
if (!entry)
|
|
423165
423325
|
return mutationFailure4("TARGET_NOT_FOUND", `images.convertToInline: image "${input.imageId}" was not found.`);
|
|
423166
423326
|
if (entry.properties.placement === "inline") {
|
|
@@ -423186,10 +423346,10 @@ class V2ImagesAdapter {
|
|
|
423186
423346
|
}
|
|
423187
423347
|
convertToFloating(input, options = {}) {
|
|
423188
423348
|
options = mergeInputDryRun(input, options);
|
|
423189
|
-
const
|
|
423349
|
+
const entry = readBodyImageEntryById(this.context, input.imageId);
|
|
423350
|
+
const blocked = guardCanonicalMutation2(this.context, options, "images.convertToFloating", { id: input.imageId, entry, ownership: "drawing" });
|
|
423190
423351
|
if (blocked)
|
|
423191
423352
|
return blocked;
|
|
423192
|
-
const entry = readBodyImageEntryById(this.context, input.imageId);
|
|
423193
423353
|
if (!entry)
|
|
423194
423354
|
return mutationFailure4("TARGET_NOT_FOUND", `images.convertToFloating: image "${input.imageId}" was not found.`);
|
|
423195
423355
|
if (entry.properties.placement === "floating") {
|
|
@@ -423214,10 +423374,10 @@ class V2ImagesAdapter {
|
|
|
423214
423374
|
}
|
|
423215
423375
|
setSize(input, options = {}) {
|
|
423216
423376
|
options = mergeInputDryRun(input, options);
|
|
423217
|
-
const
|
|
423377
|
+
const entry = readBodyImageMutationEntryById(this.context, input.imageId);
|
|
423378
|
+
const blocked = guardCanonicalMutation2(this.context, options, "images.setSize", { id: input.imageId, entry, ownership: "drawing" });
|
|
423218
423379
|
if (blocked)
|
|
423219
423380
|
return blocked;
|
|
423220
|
-
const entry = readBodyImageMutationEntryById(this.context, input.imageId);
|
|
423221
423381
|
if (!entry)
|
|
423222
423382
|
return mutationFailure4("TARGET_NOT_FOUND", `images.setSize: image "${input.imageId}" was not found.`);
|
|
423223
423383
|
const size = sizeToPx(input.size);
|
|
@@ -423239,10 +423399,10 @@ class V2ImagesAdapter {
|
|
|
423239
423399
|
if (input.type === "Inline") {
|
|
423240
423400
|
return this.convertToInline({ imageId: input.imageId }, options);
|
|
423241
423401
|
}
|
|
423242
|
-
const
|
|
423402
|
+
const entry = readBodyImageEntryById(this.context, input.imageId);
|
|
423403
|
+
const blocked = guardCanonicalMutation2(this.context, options, "images.setWrapType", { id: input.imageId, entry, ownership: "drawing" });
|
|
423243
423404
|
if (blocked)
|
|
423244
423405
|
return blocked;
|
|
423245
|
-
const entry = readBodyImageEntryById(this.context, input.imageId);
|
|
423246
423406
|
if (!entry)
|
|
423247
423407
|
return mutationFailure4("TARGET_NOT_FOUND", `images.setWrapType: image "${input.imageId}" was not found.`);
|
|
423248
423408
|
if (entry.properties.placement !== "floating") {
|
|
@@ -423262,10 +423422,10 @@ class V2ImagesAdapter {
|
|
|
423262
423422
|
}
|
|
423263
423423
|
setWrapSide(input, options = {}) {
|
|
423264
423424
|
options = mergeInputDryRun(input, options);
|
|
423265
|
-
const
|
|
423425
|
+
const entry = readBodyImageEntryById(this.context, input.imageId);
|
|
423426
|
+
const blocked = guardCanonicalMutation2(this.context, options, "images.setWrapSide", { id: input.imageId, entry, ownership: "drawing" });
|
|
423266
423427
|
if (blocked)
|
|
423267
423428
|
return blocked;
|
|
423268
|
-
const entry = readBodyImageEntryById(this.context, input.imageId);
|
|
423269
423429
|
if (!entry)
|
|
423270
423430
|
return mutationFailure4("TARGET_NOT_FOUND", `images.setWrapSide: image "${input.imageId}" was not found.`);
|
|
423271
423431
|
if (entry.properties.placement !== "floating") {
|
|
@@ -423293,10 +423453,10 @@ class V2ImagesAdapter {
|
|
|
423293
423453
|
}
|
|
423294
423454
|
setWrapDistances(input, options = {}) {
|
|
423295
423455
|
options = mergeInputDryRun(input, options);
|
|
423296
|
-
const
|
|
423456
|
+
const entry = readBodyImageEntryById(this.context, input.imageId);
|
|
423457
|
+
const blocked = guardCanonicalMutation2(this.context, options, "images.setWrapDistances", { id: input.imageId, entry, ownership: "drawing" });
|
|
423297
423458
|
if (blocked)
|
|
423298
423459
|
return blocked;
|
|
423299
|
-
const entry = readBodyImageEntryById(this.context, input.imageId);
|
|
423300
423460
|
if (!entry)
|
|
423301
423461
|
return mutationFailure4("TARGET_NOT_FOUND", `images.setWrapDistances: image "${input.imageId}" was not found.`);
|
|
423302
423462
|
if (entry.properties.placement !== "floating") {
|
|
@@ -423320,10 +423480,10 @@ class V2ImagesAdapter {
|
|
|
423320
423480
|
}
|
|
423321
423481
|
setPosition(input, options = {}) {
|
|
423322
423482
|
options = mergeInputDryRun(input, options);
|
|
423323
|
-
const
|
|
423483
|
+
const entry = readBodyImageEntryById(this.context, input.imageId);
|
|
423484
|
+
const blocked = guardCanonicalMutation2(this.context, options, "images.setPosition", { id: input.imageId, entry, ownership: "drawing" });
|
|
423324
423485
|
if (blocked)
|
|
423325
423486
|
return blocked;
|
|
423326
|
-
const entry = readBodyImageEntryById(this.context, input.imageId);
|
|
423327
423487
|
if (!entry)
|
|
423328
423488
|
return mutationFailure4("TARGET_NOT_FOUND", `images.setPosition: image "${input.imageId}" was not found.`);
|
|
423329
423489
|
if (entry.properties.placement !== "floating") {
|
|
@@ -423346,10 +423506,10 @@ class V2ImagesAdapter {
|
|
|
423346
423506
|
}
|
|
423347
423507
|
setAnchorOptions(input, options = {}) {
|
|
423348
423508
|
options = mergeInputDryRun(input, options);
|
|
423349
|
-
const
|
|
423509
|
+
const entry = readBodyImageEntryById(this.context, input.imageId);
|
|
423510
|
+
const blocked = guardCanonicalMutation2(this.context, options, "images.setAnchorOptions", { id: input.imageId, entry, ownership: "drawing" });
|
|
423350
423511
|
if (blocked)
|
|
423351
423512
|
return blocked;
|
|
423352
|
-
const entry = readBodyImageEntryById(this.context, input.imageId);
|
|
423353
423513
|
if (!entry)
|
|
423354
423514
|
return mutationFailure4("TARGET_NOT_FOUND", `images.setAnchorOptions: image "${input.imageId}" was not found.`);
|
|
423355
423515
|
if (entry.properties.placement !== "floating") {
|
|
@@ -423369,10 +423529,10 @@ class V2ImagesAdapter {
|
|
|
423369
423529
|
}
|
|
423370
423530
|
setZOrder(input, options = {}) {
|
|
423371
423531
|
options = mergeInputDryRun(input, options);
|
|
423372
|
-
const
|
|
423532
|
+
const entry = readBodyImageEntryById(this.context, input.imageId);
|
|
423533
|
+
const blocked = guardCanonicalMutation2(this.context, options, "images.setZOrder", { id: input.imageId, entry, ownership: "drawing" });
|
|
423373
423534
|
if (blocked)
|
|
423374
423535
|
return blocked;
|
|
423375
|
-
const entry = readBodyImageEntryById(this.context, input.imageId);
|
|
423376
423536
|
if (!entry)
|
|
423377
423537
|
return mutationFailure4("TARGET_NOT_FOUND", `images.setZOrder: image "${input.imageId}" was not found.`);
|
|
423378
423538
|
if (entry.properties.placement !== "floating") {
|
|
@@ -423394,10 +423554,10 @@ class V2ImagesAdapter {
|
|
|
423394
423554
|
}
|
|
423395
423555
|
scale(input, options = {}) {
|
|
423396
423556
|
options = mergeInputDryRun(input, options);
|
|
423397
|
-
const
|
|
423557
|
+
const entry = readBodyImageEntryById(this.context, input.imageId);
|
|
423558
|
+
const blocked = guardCanonicalMutation2(this.context, options, "images.scale", { id: input.imageId, entry, ownership: "drawing" });
|
|
423398
423559
|
if (blocked)
|
|
423399
423560
|
return blocked;
|
|
423400
|
-
const entry = readBodyImageEntryById(this.context, input.imageId);
|
|
423401
423561
|
if (!entry)
|
|
423402
423562
|
return mutationFailure4("TARGET_NOT_FOUND", `images.scale: image "${input.imageId}" was not found.`);
|
|
423403
423563
|
const currentWidth = entry.properties.size?.width;
|
|
@@ -423421,10 +423581,10 @@ class V2ImagesAdapter {
|
|
|
423421
423581
|
}
|
|
423422
423582
|
setLockAspectRatio(input, options = {}) {
|
|
423423
423583
|
options = mergeInputDryRun(input, options);
|
|
423424
|
-
const
|
|
423584
|
+
const entry = readBodyImageEntryById(this.context, input.imageId);
|
|
423585
|
+
const blocked = guardCanonicalMutation2(this.context, options, "images.setLockAspectRatio", { id: input.imageId, entry, ownership: "drawing" });
|
|
423425
423586
|
if (blocked)
|
|
423426
423587
|
return blocked;
|
|
423427
|
-
const entry = readBodyImageEntryById(this.context, input.imageId);
|
|
423428
423588
|
if (!entry) {
|
|
423429
423589
|
return mutationFailure4("TARGET_NOT_FOUND", `images.setLockAspectRatio: image "${input.imageId}" was not found.`);
|
|
423430
423590
|
}
|
|
@@ -423442,10 +423602,10 @@ class V2ImagesAdapter {
|
|
|
423442
423602
|
}
|
|
423443
423603
|
rotate(input, options = {}) {
|
|
423444
423604
|
options = mergeInputDryRun(input, options);
|
|
423445
|
-
const
|
|
423605
|
+
const entry = readBodyImageEntryById(this.context, input.imageId);
|
|
423606
|
+
const blocked = guardCanonicalMutation2(this.context, options, "images.rotate", { id: input.imageId, entry, ownership: "drawing" });
|
|
423446
423607
|
if (blocked)
|
|
423447
423608
|
return blocked;
|
|
423448
|
-
const entry = readBodyImageEntryById(this.context, input.imageId);
|
|
423449
423609
|
if (!entry)
|
|
423450
423610
|
return mutationFailure4("TARGET_NOT_FOUND", `images.rotate: image "${input.imageId}" was not found.`);
|
|
423451
423611
|
const nextDrawingXml = rewriteTransform(entry.drawingXml, {
|
|
@@ -423466,10 +423626,10 @@ class V2ImagesAdapter {
|
|
|
423466
423626
|
}
|
|
423467
423627
|
flip(input, options = {}) {
|
|
423468
423628
|
options = mergeInputDryRun(input, options);
|
|
423469
|
-
const
|
|
423629
|
+
const entry = readBodyImageEntryById(this.context, input.imageId);
|
|
423630
|
+
const blocked = guardCanonicalMutation2(this.context, options, "images.flip", { id: input.imageId, entry, ownership: "drawing" });
|
|
423470
423631
|
if (blocked)
|
|
423471
423632
|
return blocked;
|
|
423472
|
-
const entry = readBodyImageEntryById(this.context, input.imageId);
|
|
423473
423633
|
if (!entry)
|
|
423474
423634
|
return mutationFailure4("TARGET_NOT_FOUND", `images.flip: image "${input.imageId}" was not found.`);
|
|
423475
423635
|
const nextDrawingXml = rewriteTransform(entry.drawingXml, {
|
|
@@ -423490,10 +423650,10 @@ class V2ImagesAdapter {
|
|
|
423490
423650
|
}
|
|
423491
423651
|
crop(input, options = {}) {
|
|
423492
423652
|
options = mergeInputDryRun(input, options);
|
|
423493
|
-
const
|
|
423653
|
+
const entry = readBodyImageEntryById(this.context, input.imageId);
|
|
423654
|
+
const blocked = guardCanonicalMutation2(this.context, options, "images.crop", { id: input.imageId, entry, ownership: "drawing" });
|
|
423494
423655
|
if (blocked)
|
|
423495
423656
|
return blocked;
|
|
423496
|
-
const entry = readBodyImageEntryById(this.context, input.imageId);
|
|
423497
423657
|
if (!entry)
|
|
423498
423658
|
return mutationFailure4("TARGET_NOT_FOUND", `images.crop: image "${input.imageId}" was not found.`);
|
|
423499
423659
|
const nextDrawingXml = rewriteCrop(entry.drawingXml, input.crop);
|
|
@@ -423510,10 +423670,10 @@ class V2ImagesAdapter {
|
|
|
423510
423670
|
}
|
|
423511
423671
|
resetCrop(input, options = {}) {
|
|
423512
423672
|
options = mergeInputDryRun(input, options);
|
|
423513
|
-
const
|
|
423673
|
+
const entry = readBodyImageEntryById(this.context, input.imageId);
|
|
423674
|
+
const blocked = guardCanonicalMutation2(this.context, options, "images.resetCrop", { id: input.imageId, entry, ownership: "drawing" });
|
|
423514
423675
|
if (blocked)
|
|
423515
423676
|
return blocked;
|
|
423516
|
-
const entry = readBodyImageEntryById(this.context, input.imageId);
|
|
423517
423677
|
if (!entry)
|
|
423518
423678
|
return mutationFailure4("TARGET_NOT_FOUND", `images.resetCrop: image "${input.imageId}" was not found.`);
|
|
423519
423679
|
const nextDrawingXml = clearCrop(entry.drawingXml);
|
|
@@ -423528,10 +423688,10 @@ class V2ImagesAdapter {
|
|
|
423528
423688
|
}
|
|
423529
423689
|
replaceSource(input, options = {}) {
|
|
423530
423690
|
options = mergeInputDryRun(input, options);
|
|
423531
|
-
const
|
|
423691
|
+
const entry = readBodyImageEntryById(this.context, input.imageId);
|
|
423692
|
+
const blocked = guardCanonicalMutation2(this.context, options, "images.replaceSource", { id: input.imageId, entry, ownership: "drawing" });
|
|
423532
423693
|
if (blocked)
|
|
423533
423694
|
return blocked;
|
|
423534
|
-
const entry = readBodyImageEntryById(this.context, input.imageId);
|
|
423535
423695
|
if (!entry)
|
|
423536
423696
|
return mutationFailure4("TARGET_NOT_FOUND", `images.replaceSource: image "${input.imageId}" was not found.`);
|
|
423537
423697
|
if (!entry.descriptor.rId)
|
|
@@ -423732,10 +423892,10 @@ class V2ImagesAdapter {
|
|
|
423732
423892
|
}
|
|
423733
423893
|
setAltText(input, options = {}) {
|
|
423734
423894
|
options = mergeInputDryRun(input, options);
|
|
423735
|
-
const
|
|
423895
|
+
const entry = readBodyImageEntryById(this.context, input.imageId);
|
|
423896
|
+
const blocked = guardCanonicalMutation2(this.context, options, "images.setAltText", { id: input.imageId, entry, ownership: "drawing" });
|
|
423736
423897
|
if (blocked)
|
|
423737
423898
|
return blocked;
|
|
423738
|
-
const entry = readBodyImageEntryById(this.context, input.imageId);
|
|
423739
423899
|
if (!entry)
|
|
423740
423900
|
return mutationFailure4("TARGET_NOT_FOUND", `images.setAltText: image "${input.imageId}" was not found.`);
|
|
423741
423901
|
const nextDrawingXml = rewriteMetadata(entry.drawingXml, {
|
|
@@ -423755,10 +423915,10 @@ class V2ImagesAdapter {
|
|
|
423755
423915
|
}
|
|
423756
423916
|
setDecorative(input, options = {}) {
|
|
423757
423917
|
options = mergeInputDryRun(input, options);
|
|
423758
|
-
const
|
|
423918
|
+
const entry = readBodyImageEntryById(this.context, input.imageId);
|
|
423919
|
+
const blocked = guardCanonicalMutation2(this.context, options, "images.setDecorative", { id: input.imageId, entry, ownership: "drawing" });
|
|
423759
423920
|
if (blocked)
|
|
423760
423921
|
return blocked;
|
|
423761
|
-
const entry = readBodyImageEntryById(this.context, input.imageId);
|
|
423762
423922
|
if (!entry)
|
|
423763
423923
|
return mutationFailure4("TARGET_NOT_FOUND", `images.setDecorative: image "${input.imageId}" was not found.`);
|
|
423764
423924
|
const nextDrawingXml = rewriteMetadata(entry.drawingXml, {
|
|
@@ -423782,10 +423942,10 @@ class V2ImagesAdapter {
|
|
|
423782
423942
|
}
|
|
423783
423943
|
setName(input, options = {}) {
|
|
423784
423944
|
options = mergeInputDryRun(input, options);
|
|
423785
|
-
const
|
|
423945
|
+
const entry = readBodyImageEntryById(this.context, input.imageId);
|
|
423946
|
+
const blocked = guardCanonicalMutation2(this.context, options, "images.setName", { id: input.imageId, entry, ownership: "drawing" });
|
|
423786
423947
|
if (blocked)
|
|
423787
423948
|
return blocked;
|
|
423788
|
-
const entry = readBodyImageEntryById(this.context, input.imageId);
|
|
423789
423949
|
if (!entry)
|
|
423790
423950
|
return mutationFailure4("TARGET_NOT_FOUND", `images.setName: image "${input.imageId}" was not found.`);
|
|
423791
423951
|
const nextDrawingXml = rewriteMetadata(entry.drawingXml, {
|
|
@@ -423804,10 +423964,10 @@ class V2ImagesAdapter {
|
|
|
423804
423964
|
}
|
|
423805
423965
|
setHyperlink(input, options = {}) {
|
|
423806
423966
|
options = mergeInputDryRun(input, options);
|
|
423807
|
-
const
|
|
423967
|
+
const entry = readBodyImageEntryById(this.context, input.imageId);
|
|
423968
|
+
const blocked = guardCanonicalMutation2(this.context, options, "images.setHyperlink", { id: input.imageId, entry, ownership: "drawing" });
|
|
423808
423969
|
if (blocked)
|
|
423809
423970
|
return blocked;
|
|
423810
|
-
const entry = readBodyImageEntryById(this.context, input.imageId);
|
|
423811
423971
|
if (!entry)
|
|
423812
423972
|
return mutationFailure4("TARGET_NOT_FOUND", `images.setHyperlink: image "${input.imageId}" was not found.`);
|
|
423813
423973
|
const partXml = readPartXml2(this.context, entry.partUri);
|
|
@@ -423864,10 +424024,10 @@ class V2ImagesAdapter {
|
|
|
423864
424024
|
}
|
|
423865
424025
|
insertCaption(input, options = {}) {
|
|
423866
424026
|
options = mergeInputDryRun(input, options);
|
|
423867
|
-
const
|
|
424027
|
+
const entry = readBodyImageEntryById(this.context, input.imageId);
|
|
424028
|
+
const blocked = guardCanonicalMutation2(this.context, options, "images.insertCaption", { id: input.imageId, entry, ownership: "closed" });
|
|
423868
424029
|
if (blocked)
|
|
423869
424030
|
return blocked;
|
|
423870
|
-
const entry = readBodyImageEntryById(this.context, input.imageId);
|
|
423871
424031
|
if (!entry)
|
|
423872
424032
|
return mutationFailure4("TARGET_NOT_FOUND", `images.insertCaption: image "${input.imageId}" was not found.`);
|
|
423873
424033
|
if (!entry.paragraph) {
|
|
@@ -423915,10 +424075,10 @@ class V2ImagesAdapter {
|
|
|
423915
424075
|
}
|
|
423916
424076
|
updateCaption(input, options = {}) {
|
|
423917
424077
|
options = mergeInputDryRun(input, options);
|
|
423918
|
-
const
|
|
424078
|
+
const entry = readBodyImageEntryById(this.context, input.imageId);
|
|
424079
|
+
const blocked = guardCanonicalMutation2(this.context, options, "images.updateCaption", { id: input.imageId, entry, ownership: "closed" });
|
|
423919
424080
|
if (blocked)
|
|
423920
424081
|
return blocked;
|
|
423921
|
-
const entry = readBodyImageEntryById(this.context, input.imageId);
|
|
423922
424082
|
if (!entry)
|
|
423923
424083
|
return mutationFailure4("TARGET_NOT_FOUND", `images.updateCaption: image "${input.imageId}" was not found.`);
|
|
423924
424084
|
if (!entry.paragraph) {
|
|
@@ -423966,10 +424126,10 @@ class V2ImagesAdapter {
|
|
|
423966
424126
|
}
|
|
423967
424127
|
removeCaption(input, options = {}) {
|
|
423968
424128
|
options = mergeInputDryRun(input, options);
|
|
423969
|
-
const
|
|
424129
|
+
const entry = readBodyImageEntryById(this.context, input.imageId);
|
|
424130
|
+
const blocked = guardCanonicalMutation2(this.context, options, "images.removeCaption", { id: input.imageId, entry, ownership: "closed" });
|
|
423970
424131
|
if (blocked)
|
|
423971
424132
|
return blocked;
|
|
423972
|
-
const entry = readBodyImageEntryById(this.context, input.imageId);
|
|
423973
424133
|
if (!entry)
|
|
423974
424134
|
return mutationFailure4("TARGET_NOT_FOUND", `images.removeCaption: image "${input.imageId}" was not found.`);
|
|
423975
424135
|
if (!entry.paragraph) {
|
|
@@ -424092,6 +424252,9 @@ class V2ImagesAdapter {
|
|
|
424092
424252
|
attachSDRenderCommitEnvelope(result, renderCommit);
|
|
424093
424253
|
return result;
|
|
424094
424254
|
}
|
|
424255
|
+
if (isDocumentProtectionEnforced(this.context)) {
|
|
424256
|
+
return projectReceiptFailure2({ code: "PERMISSION_DENIED", message: DOCUMENT_PROTECTION_MESSAGE });
|
|
424257
|
+
}
|
|
424095
424258
|
if (options.changeMode === "tracked") {
|
|
424096
424259
|
return projectReceiptFailure2({ code: "TARGET_NOT_FOUND", message: "image-target-not-found" });
|
|
424097
424260
|
}
|
|
@@ -424121,6 +424284,14 @@ class V2ImagesAdapter {
|
|
|
424121
424284
|
options = narrowImageMutationOptions(input, options);
|
|
424122
424285
|
if (!validNarrowImageMutationOptions(options))
|
|
424123
424286
|
return projectReceiptFailure2({ code: "INVALID_INPUT", message: "Invalid image mutation options." });
|
|
424287
|
+
if (isDocumentProtectionEnforced(this.context)) {
|
|
424288
|
+
const entry = readBodyImageEntries(this.context).find((candidate2) => candidate2.storyId === input.storyId && candidate2.descriptor.imageNodeId === input.imageNodeId);
|
|
424289
|
+
if (!entry)
|
|
424290
|
+
return projectReceiptFailure2({ code: "PERMISSION_DENIED", message: DOCUMENT_PROTECTION_MESSAGE });
|
|
424291
|
+
const failure11 = imageProtectionFailure(this.context, entry, true);
|
|
424292
|
+
if (failure11)
|
|
424293
|
+
return projectReceiptFailure2(failure11);
|
|
424294
|
+
}
|
|
424124
424295
|
const begun = this.context.beginMutation({
|
|
424125
424296
|
expectedRevision: options.expectedRevision
|
|
424126
424297
|
});
|
|
@@ -424774,10 +424945,36 @@ function replaceImageEmbedRelationshipId(drawingXml, nextRId) {
|
|
|
424774
424945
|
xml: drawingXml.slice(0, match.index) + `r:embed="${escapeXmlAttribute3(nextRId)}"` + drawingXml.slice(match.index + match[0].length)
|
|
424775
424946
|
};
|
|
424776
424947
|
}
|
|
424777
|
-
function
|
|
424948
|
+
function imageProtectionFailure(context, entry, ownsCarrier) {
|
|
424949
|
+
const xml = readPartXml2(context, entry.partUri);
|
|
424950
|
+
if (!xml)
|
|
424951
|
+
return { code: "PRECONDITION_FAILED", message: `Part bytes are unavailable for ${entry.partUri}.` };
|
|
424952
|
+
const offsets = buildUtf8OffsetMap5(xml);
|
|
424953
|
+
const start = codeUnitIndexForByteOffset2(offsets, entry.descriptor.byteStart);
|
|
424954
|
+
const end = codeUnitIndexForByteOffset2(offsets, entry.descriptor.byteEnd);
|
|
424955
|
+
const denied = { code: "PERMISSION_DENIED", message: DOCUMENT_PROTECTION_MESSAGE };
|
|
424956
|
+
if (start >= end || offsets[start] !== entry.descriptor.byteStart || offsets[end] !== entry.descriptor.byteEnd) {
|
|
424957
|
+
return denied;
|
|
424958
|
+
}
|
|
424959
|
+
const drawing = expandToEnclosingDrawingRange(xml, start, end);
|
|
424960
|
+
if (!drawing || xml.slice(drawing.start, drawing.end) !== entry.drawingXml)
|
|
424961
|
+
return denied;
|
|
424962
|
+
const range = ownsCarrier ? expandToEnclosingRunIfSoleChild2(xml, drawing.start, drawing.end) : drawing;
|
|
424963
|
+
return documentProtectionAllowsXmlRange(context, entry.partUri, range.start, range.end) ? null : denied;
|
|
424964
|
+
}
|
|
424965
|
+
function guardCanonicalMutation2(context, options, operationId, image) {
|
|
424778
424966
|
const policy = context.getMutationPolicyFailure();
|
|
424779
424967
|
if (policy)
|
|
424780
424968
|
return mutationFailure4(policy.code, policy.message);
|
|
424969
|
+
if (image && isDocumentProtectionEnforced(context)) {
|
|
424970
|
+
if (image.ownership === "closed")
|
|
424971
|
+
return mutationFailure4("PERMISSION_DENIED", DOCUMENT_PROTECTION_MESSAGE);
|
|
424972
|
+
if (!image.entry)
|
|
424973
|
+
return mutationFailure4("TARGET_NOT_FOUND", `${operationId}: image "${image.id}" was not found.`);
|
|
424974
|
+
const failure11 = imageProtectionFailure(context, image.entry, image.ownership === "carrier" || options?.changeMode === "tracked");
|
|
424975
|
+
if (failure11)
|
|
424976
|
+
return mutationFailure4(failure11.code, failure11.message);
|
|
424977
|
+
}
|
|
424781
424978
|
if (options?.changeMode === "tracked") {
|
|
424782
424979
|
if (!isV2TrackedOperation(context, operationId)) {
|
|
424783
424980
|
return mutationFailure4("CAPABILITY_UNAVAILABLE", `${operationId} does not support tracked mode on v2 yet.`);
|
|
@@ -425746,6 +425943,8 @@ function buildUtf8OffsetMap5(xml) {
|
|
|
425746
425943
|
for (const ch of xml) {
|
|
425747
425944
|
codeUnitIndex += ch.length;
|
|
425748
425945
|
const cp = ch.codePointAt(0);
|
|
425946
|
+
if (ch.length === 2)
|
|
425947
|
+
offsets[codeUnitIndex - 1] = byteOffset + 2;
|
|
425749
425948
|
byteOffset += cp < 128 ? 1 : cp < 2048 ? 2 : cp < 65536 ? 3 : 4;
|
|
425750
425949
|
offsets[codeUnitIndex] = byteOffset;
|
|
425751
425950
|
}
|
|
@@ -426120,7 +426319,6 @@ var IMAGE_HYPERLINK_REL_TYPE = "http://schemas.openxmlformats.org/officeDocument
|
|
|
426120
426319
|
var init_adapter22 = __esm(() => {
|
|
426121
426320
|
init_mutation_guard();
|
|
426122
426321
|
init_adapter4();
|
|
426123
|
-
init_adapter5();
|
|
426124
426322
|
init_pending_image_insertion();
|
|
426125
426323
|
init_src3();
|
|
426126
426324
|
init_sd_document_session_internal();
|
|
@@ -450635,6 +450833,9 @@ class V2StylesAdapter {
|
|
|
450635
450833
|
if (policy) {
|
|
450636
450834
|
return { success: false, resolution, failure: policy };
|
|
450637
450835
|
}
|
|
450836
|
+
if (isDocumentProtectionEnforced(this.context)) {
|
|
450837
|
+
return { success: false, resolution, failure: { code: "PERMISSION_DENIED", message: DOCUMENT_PROTECTION_MESSAGE } };
|
|
450838
|
+
}
|
|
450638
450839
|
const bytes = readStyleDefinitionsPartBytes(this.context);
|
|
450639
450840
|
if (!partUri || !bytes) {
|
|
450640
450841
|
return {
|
|
@@ -450773,6 +450974,7 @@ function stylesMutationGuardFailure(context, options) {
|
|
|
450773
450974
|
}
|
|
450774
450975
|
var init_adapter39 = __esm(() => {
|
|
450775
450976
|
init_src3();
|
|
450977
|
+
init_mutation_guard();
|
|
450776
450978
|
init_apply5();
|
|
450777
450979
|
init_styles3();
|
|
450778
450980
|
init_catalog5();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@superdoc/mcp",
|
|
3
|
-
"version": "1.10.0-next.
|
|
3
|
+
"version": "1.10.0-next.15",
|
|
4
4
|
"description": "Model Context Protocol server for SuperDoc, giving an AI agent tools to read and edit .docx files.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "AGPL-3.0",
|
|
@@ -24,13 +24,13 @@
|
|
|
24
24
|
],
|
|
25
25
|
"dependencies": {
|
|
26
26
|
"@modelcontextprotocol/sdk": "^1.26.0",
|
|
27
|
-
"@superdoc/sdk": "2.23.0-next.
|
|
27
|
+
"@superdoc/sdk": "2.23.0-next.15",
|
|
28
28
|
"debug": "^4.4.3",
|
|
29
29
|
"zod": "^4.3.6"
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {
|
|
32
|
-
"superdoc": "2.26.0-next.
|
|
33
|
-
"@superdoc/docx-engine": "0.25.0-next.
|
|
32
|
+
"superdoc": "2.26.0-next.15",
|
|
33
|
+
"@superdoc/docx-engine": "0.25.0-next.15",
|
|
34
34
|
"@superdoc/document-api": "0.1.0-alpha.0",
|
|
35
35
|
"@types/bun": "^1.3.8",
|
|
36
36
|
"@types/node": "22.19.2",
|