@umbraco-cms/mcp-dev 17.6.9 → 17.6.10

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.
@@ -16525,6 +16525,8 @@ function discoverAllBlockArrays(value, path3 = "root") {
16525
16525
  results.push({
16526
16526
  contentData: value.contentData,
16527
16527
  settingsData: value.settingsData,
16528
+ layout: value.layout && typeof value.layout === "object" ? value.layout : void 0,
16529
+ expose: Array.isArray(value.expose) ? value.expose : void 0,
16528
16530
  path: path3
16529
16531
  });
16530
16532
  value.contentData.forEach((block, index) => {
@@ -16804,6 +16806,726 @@ var UpdateBlockPropertyTool = {
16804
16806
  };
16805
16807
  var update_block_property_default = _mcpserversdk.withStandardDecorators.call(void 0, UpdateBlockPropertyTool);
16806
16808
 
16809
+ // src/umbraco-api/tools/document/put/create-document-block.ts
16810
+
16811
+
16812
+
16813
+ // src/umbraco-api/tools/document/put/helpers/block-builder.ts
16814
+
16815
+ var BLOCK_EDITOR_ALIASES = {
16816
+ BlockList: "Umbraco.BlockList",
16817
+ BlockGrid: "Umbraco.BlockGrid",
16818
+ RichText: "Umbraco.RichText"
16819
+ };
16820
+ var DEFAULT_GRID_COLUMN_SPAN = 12;
16821
+ var DEFAULT_GRID_ROW_SPAN = 1;
16822
+ function getBlockEditorKind(editorAlias) {
16823
+ switch (editorAlias) {
16824
+ case BLOCK_EDITOR_ALIASES.BlockList:
16825
+ return "BlockList";
16826
+ case BLOCK_EDITOR_ALIASES.BlockGrid:
16827
+ return "BlockGrid";
16828
+ case BLOCK_EDITOR_ALIASES.RichText:
16829
+ return "RichText";
16830
+ default:
16831
+ return null;
16832
+ }
16833
+ }
16834
+ function isBlockListOrGridValue(value) {
16835
+ return isBlockStructure(value) && !isRichTextValue(value);
16836
+ }
16837
+ function isRteWithBlocks(value) {
16838
+ return isRichTextValue(value);
16839
+ }
16840
+ function createEmptyBlockValue(kind) {
16841
+ const blocks = {
16842
+ layout: { [BLOCK_EDITOR_ALIASES[kind]]: [] },
16843
+ contentData: [],
16844
+ settingsData: [],
16845
+ expose: []
16846
+ };
16847
+ return kind === "RichText" ? { markup: "", blocks } : blocks;
16848
+ }
16849
+ function isPlainObject(value) {
16850
+ return typeof value === "object" && value !== null && !Array.isArray(value);
16851
+ }
16852
+ function malformedBlockStructureError(field, expected) {
16853
+ return new (0, _mcpserversdk.ToolValidationError)({
16854
+ title: "Malformed block structure",
16855
+ detail: `Property has a malformed block structure and cannot be safely modified: '${field}' is present but is not ${expected}`
16856
+ });
16857
+ }
16858
+ function ensureField(target, key, expected, isValid, createDefault, fieldLabel = key) {
16859
+ const current = target[key];
16860
+ if (current === void 0 || current === null) {
16861
+ target[key] = createDefault();
16862
+ } else if (!isValid(current)) {
16863
+ throw malformedBlockStructureError(fieldLabel, expected);
16864
+ }
16865
+ }
16866
+ function normaliseRichTextBlockValue(rte) {
16867
+ ensureField(rte, "markup", "a string", (v) => typeof v === "string", () => "");
16868
+ ensureField(rte, "blocks", "an object", isPlainObject, () => createEmptyBlockValue("RichText").blocks);
16869
+ ensureField(rte.blocks, "contentData", "an array", Array.isArray, () => [], "blocks.contentData");
16870
+ ensureField(rte.blocks, "settingsData", "an array", Array.isArray, () => [], "blocks.settingsData");
16871
+ }
16872
+ function getTopLevelBlockContainer(value, kind) {
16873
+ const matches = kind === "RichText" ? isRteWithBlocks(value) : isBlockListOrGridValue(value);
16874
+ if (!matches) {
16875
+ return null;
16876
+ }
16877
+ const raw = kind === "RichText" ? value.blocks : value;
16878
+ const layoutAlias = BLOCK_EDITOR_ALIASES[kind];
16879
+ ensureField(raw, "layout", "an object", isPlainObject, () => ({}));
16880
+ ensureField(raw.layout, layoutAlias, "an array", Array.isArray, () => [], `layout['${layoutAlias}']`);
16881
+ ensureField(raw, "expose", "an array", Array.isArray, () => []);
16882
+ const [topLevel] = discoverAllBlockArrays(value, "root");
16883
+ return {
16884
+ ...topLevel,
16885
+ layout: raw.layout,
16886
+ expose: raw.expose,
16887
+ layoutItems: raw.layout[layoutAlias]
16888
+ };
16889
+ }
16890
+ function buildBlockEntry(key, contentTypeKey, properties) {
16891
+ return {
16892
+ key,
16893
+ contentTypeKey,
16894
+ values: properties.map((p) => ({
16895
+ alias: p.alias,
16896
+ culture: _nullishCoalesce(p.culture, () => ( null)),
16897
+ segment: _nullishCoalesce(p.segment, () => ( null)),
16898
+ value: p.value
16899
+ }))
16900
+ };
16901
+ }
16902
+ function buildLayoutEntry(kind, options) {
16903
+ const entry = { contentKey: options.contentKey };
16904
+ if (options.settingsKey) {
16905
+ entry.settingsKey = options.settingsKey;
16906
+ }
16907
+ if (kind === "BlockGrid") {
16908
+ entry.columnSpan = _nullishCoalesce(options.columnSpan, () => ( DEFAULT_GRID_COLUMN_SPAN));
16909
+ entry.rowSpan = _nullishCoalesce(options.rowSpan, () => ( DEFAULT_GRID_ROW_SPAN));
16910
+ entry.areas = (_nullishCoalesce(options.areaKeys, () => ( []))).map((key) => ({ key, items: [] }));
16911
+ }
16912
+ return entry;
16913
+ }
16914
+ function buildExposeEntries(contentKey, cultures, segment = null) {
16915
+ const unique = Array.from(new Set(cultures.length > 0 ? cultures : [null]));
16916
+ return unique.map((culture) => ({ contentKey, culture, segment }));
16917
+ }
16918
+ function insertAtPosition(items, item, placement, keyOf) {
16919
+ switch (placement.position) {
16920
+ case "prepend":
16921
+ items.unshift(item);
16922
+ return true;
16923
+ case "append":
16924
+ items.push(item);
16925
+ return true;
16926
+ case "before":
16927
+ case "after": {
16928
+ const index = items.findIndex((i) => keyOf(i) === placement.contentKey);
16929
+ if (index === -1) {
16930
+ return false;
16931
+ }
16932
+ items.splice(placement.position === "before" ? index : index + 1, 0, item);
16933
+ return true;
16934
+ }
16935
+ }
16936
+ }
16937
+ function findLayoutLocation(items, contentKey, parent, areaKey) {
16938
+ for (let index = 0; index < items.length; index++) {
16939
+ const entry = items[index];
16940
+ if (entry.contentKey === contentKey) {
16941
+ return { items, index, entry, parent, areaKey };
16942
+ }
16943
+ for (const area of _nullishCoalesce(entry.areas, () => ( []))) {
16944
+ const found = findLayoutLocation(_nullishCoalesce(area.items, () => ( [])), contentKey, entry, area.key);
16945
+ if (found) {
16946
+ return found;
16947
+ }
16948
+ }
16949
+ }
16950
+ return null;
16951
+ }
16952
+ function collectNestedAreaContentKeys(entry) {
16953
+ const keys = [];
16954
+ for (const area of _nullishCoalesce(entry.areas, () => ( []))) {
16955
+ for (const child of _nullishCoalesce(area.items, () => ( []))) {
16956
+ keys.push(child.contentKey, ...collectNestedAreaContentKeys(child));
16957
+ }
16958
+ }
16959
+ return keys;
16960
+ }
16961
+ function removeBlockFromContainer(container, location) {
16962
+ const contentKey = location.entry.contentKey;
16963
+ const contentIndex = container.contentData.findIndex((b) => b.key === contentKey);
16964
+ if (contentIndex === -1) {
16965
+ return null;
16966
+ }
16967
+ const settingsKey = _nullishCoalesce(location.entry.settingsKey, () => ( null));
16968
+ location.items.splice(location.index, 1);
16969
+ container.contentData.splice(contentIndex, 1);
16970
+ if (settingsKey) {
16971
+ const settingsIndex = container.settingsData.findIndex((b) => b.key === settingsKey);
16972
+ if (settingsIndex !== -1) {
16973
+ container.settingsData.splice(settingsIndex, 1);
16974
+ }
16975
+ }
16976
+ for (let i = container.expose.length - 1; i >= 0; i--) {
16977
+ if (container.expose[i].contentKey === contentKey) {
16978
+ container.expose.splice(i, 1);
16979
+ }
16980
+ }
16981
+ return { layoutEntry: location.entry, settingsKey };
16982
+ }
16983
+ function escapeRegExp(value) {
16984
+ return value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
16985
+ }
16986
+ function rteBlockElementPattern(contentKey) {
16987
+ const key = escapeRegExp(contentKey);
16988
+ return new RegExp(
16989
+ `<(umb-rte-block(?:-inline)?)\\b[^>]*\\bdata-content-key=["']${key}["'][^>]*?(?:/>|>[\\s\\S]*?</\\1>)`,
16990
+ "i"
16991
+ );
16992
+ }
16993
+ function buildRteBlockElement(contentKey, inline = false) {
16994
+ const tag = inline ? "umb-rte-block-inline" : "umb-rte-block";
16995
+ return `<${tag} data-content-key="${contentKey}"><!--Umbraco-Block--></${tag}>`;
16996
+ }
16997
+ function findRteBlockElement(markup, contentKey) {
16998
+ const match = rteBlockElementPattern(contentKey).exec(_nullishCoalesce(markup, () => ( "")));
16999
+ if (!match) {
17000
+ return null;
17001
+ }
17002
+ return { start: match.index, end: match.index + match[0].length };
17003
+ }
17004
+ function insertRteBlockElement(markup, element, placement, inline = false) {
17005
+ const current = _nullishCoalesce(markup, () => ( ""));
17006
+ const standalone = inline ? `<p>${element}</p>` : element;
17007
+ switch (placement.position) {
17008
+ case "prepend":
17009
+ return standalone + current;
17010
+ case "append":
17011
+ return current + standalone;
17012
+ case "before":
17013
+ case "after": {
17014
+ const sibling = findRteBlockElement(current, placement.contentKey);
17015
+ if (!sibling) {
17016
+ return null;
17017
+ }
17018
+ const at = placement.position === "before" ? sibling.start : sibling.end;
17019
+ return current.slice(0, at) + element + current.slice(at);
17020
+ }
17021
+ }
17022
+ }
17023
+ function removeRteBlockElement(markup, contentKey) {
17024
+ const found = findRteBlockElement(markup, contentKey);
17025
+ if (!found) {
17026
+ return null;
17027
+ }
17028
+ let { start, end } = found;
17029
+ const openingParagraph = /<p\b[^>]*>\s*$/i.exec(markup.slice(0, start));
17030
+ const closingParagraph = /^\s*<\/p>/i.exec(markup.slice(end));
17031
+ if (openingParagraph && closingParagraph) {
17032
+ start -= openingParagraph[0].length;
17033
+ end += closingParagraph[0].length;
17034
+ }
17035
+ return markup.slice(0, start) + markup.slice(end);
17036
+ }
17037
+ function getBlockTypeConfigurations(dataTypeValues) {
17038
+ const blocks = _optionalChain([dataTypeValues, 'optionalAccess', _32 => _32.find, 'call', _33 => _33((v) => v.alias === "blocks"), 'optionalAccess', _34 => _34.value]);
17039
+ return Array.isArray(blocks) ? blocks : [];
17040
+ }
17041
+ function findBlockTypeConfiguration(configs, contentElementTypeKey) {
17042
+ return configs.find((c) => c.contentElementTypeKey === contentElementTypeKey);
17043
+ }
17044
+ function findAreaConfiguration(configs, parentContentTypeKey, areaKey) {
17045
+ return _optionalChain([findBlockTypeConfiguration, 'call', _35 => _35(configs, parentContentTypeKey), 'optionalAccess', _36 => _36.areas, 'optionalAccess', _37 => _37.find, 'call', _38 => _38((a) => a.key === areaKey)]);
17046
+ }
17047
+ function checkAllowedInArea(blockConfig, area) {
17048
+ if (blockConfig.allowInAreas === false) {
17049
+ return `Element type '${blockConfig.contentElementTypeKey}' is not allowed in areas`;
17050
+ }
17051
+ const allowance = _nullishCoalesce(area.specifiedAllowance, () => ( []));
17052
+ if (allowance.length === 0) {
17053
+ return null;
17054
+ }
17055
+ const allowed = allowance.some(
17056
+ (a) => a.elementTypeKey && a.elementTypeKey === blockConfig.contentElementTypeKey || a.groupKey && blockConfig.groupKey && a.groupKey === blockConfig.groupKey
17057
+ );
17058
+ return allowed ? null : `Element type '${blockConfig.contentElementTypeKey}' is not allowed in area '${_nullishCoalesce(area.alias, () => ( area.key))}'`;
17059
+ }
17060
+
17061
+ // src/umbraco-api/tools/document/put/helpers/document-block-context.ts
17062
+
17063
+ async function loadDocumentBlockContext(model) {
17064
+ const client = UmbracoManagementClient3.getClient();
17065
+ const document = await client.getDocumentById(model.documentId);
17066
+ const documentTypeProperties = await getAllDocumentTypeProperties(document.documentType.id);
17067
+ const propertyDefinition = documentTypeProperties.find((p) => p.alias === model.propertyAlias);
17068
+ if (!propertyDefinition) {
17069
+ throw new (0, _mcpserversdk.ToolValidationError)({
17070
+ title: "Property not found",
17071
+ detail: `Property '${model.propertyAlias}' does not exist on this document's type`,
17072
+ extensions: {
17073
+ availableProperties: documentTypeProperties.map((p) => p.alias)
17074
+ }
17075
+ });
17076
+ }
17077
+ const varianceError = validateCultureSegment(
17078
+ { alias: model.propertyAlias, culture: model.culture, segment: model.segment },
17079
+ propertyDefinition
17080
+ );
17081
+ if (varianceError) {
17082
+ throw new (0, _mcpserversdk.ToolValidationError)({ title: "Invalid culture/segment", detail: varianceError });
17083
+ }
17084
+ const dataType = await client.getDataTypeById(propertyDefinition.dataTypeId);
17085
+ const kind = getBlockEditorKind(dataType.editorAlias);
17086
+ if (!kind) {
17087
+ throw new (0, _mcpserversdk.ToolValidationError)({
17088
+ title: "Not a block property",
17089
+ detail: `Property '${model.propertyAlias}' uses editor '${dataType.editorAlias}', not a BlockList, BlockGrid, or RichText editor`
17090
+ });
17091
+ }
17092
+ let valueEntry = document.values.find(
17093
+ (v) => matchesProperty(v, model.propertyAlias, model.culture, model.segment)
17094
+ );
17095
+ if (!valueEntry) {
17096
+ valueEntry = {
17097
+ alias: model.propertyAlias,
17098
+ culture: _nullishCoalesce(model.culture, () => ( null)),
17099
+ segment: _nullishCoalesce(model.segment, () => ( null)),
17100
+ editorAlias: dataType.editorAlias,
17101
+ value: null
17102
+ };
17103
+ document.values.push(valueEntry);
17104
+ }
17105
+ if (valueEntry.value === null || valueEntry.value === void 0 || valueEntry.value === "") {
17106
+ valueEntry.value = createEmptyBlockValue(kind);
17107
+ } else if (kind === "RichText" && typeof valueEntry.value === "object") {
17108
+ normaliseRichTextBlockValue(valueEntry.value);
17109
+ }
17110
+ const propertyValue = valueEntry.value;
17111
+ const container = getTopLevelBlockContainer(propertyValue, kind);
17112
+ if (!container) {
17113
+ throw new (0, _mcpserversdk.ToolValidationError)({
17114
+ title: "No block structure found",
17115
+ detail: `Property '${getPropertyKey(model.propertyAlias, model.culture, model.segment)}' does not contain a ${kind} block structure`,
17116
+ extensions: { propertyValue }
17117
+ });
17118
+ }
17119
+ return {
17120
+ document,
17121
+ propertyDefinition,
17122
+ kind,
17123
+ propertyValue,
17124
+ container,
17125
+ blockConfigs: getBlockTypeConfigurations(dataType.values)
17126
+ };
17127
+ }
17128
+ async function saveDocumentValues(documentId, document) {
17129
+ const client = UmbracoManagementClient3.getClient();
17130
+ const values = document.values.map((v) => ({
17131
+ alias: v.alias,
17132
+ culture: v.culture,
17133
+ segment: v.segment,
17134
+ value: v.value
17135
+ }));
17136
+ const variants = document.variants.map((v) => ({
17137
+ culture: v.culture,
17138
+ segment: v.segment,
17139
+ name: v.name
17140
+ }));
17141
+ const payload = {
17142
+ values,
17143
+ variants,
17144
+ template: document.template
17145
+ };
17146
+ await client.putDocumentById(documentId, payload);
17147
+ }
17148
+
17149
+ // src/umbraco-api/tools/document/put/create-document-block.ts
17150
+
17151
+
17152
+
17153
+
17154
+
17155
+ var createDocumentBlockOutputSchema = updateBlockPropertyOutputSchema;
17156
+ var blockPropertyValueSchema = _zod.z.object({
17157
+ alias: _zod.z.string().min(1).describe("The property alias on the block's element type"),
17158
+ value: _zod.z.any().nullish().describe("The property value"),
17159
+ culture: _zod.z.string().nullish().describe("Culture code, only for culture-variant element type properties"),
17160
+ segment: _zod.z.string().nullish().describe("Segment, only for segment-variant element type properties")
17161
+ });
17162
+ var placementSchema = _zod.z.object({
17163
+ position: _zod.z.enum(["before", "after", "append", "prepend"]).describe("'before'/'after' an existing sibling block (requires contentKey), or 'append'/'prepend' to the target container"),
17164
+ contentKey: _zod.z.string().uuid().nullish().describe("contentKey of the existing sibling block, required for 'before'/'after'")
17165
+ }).refine(
17166
+ (p) => p.position !== "before" && p.position !== "after" || !!p.contentKey,
17167
+ { message: "contentKey is required when position is 'before' or 'after'", path: ["contentKey"] }
17168
+ );
17169
+ var gridSchema = _zod.z.object({
17170
+ columnSpan: _zod.z.number().int().positive().optional().describe("BlockGrid column span (default 12)"),
17171
+ rowSpan: _zod.z.number().int().positive().optional().describe("BlockGrid row span (default 1)"),
17172
+ areaKey: _zod.z.string().uuid().optional().describe("Key of the named area to insert into (requires parentContentKey)"),
17173
+ parentContentKey: _zod.z.string().uuid().optional().describe("contentKey of the block that owns the area (requires areaKey)")
17174
+ }).refine(
17175
+ (g) => !!g.areaKey === !!g.parentContentKey,
17176
+ { message: "areaKey and parentContentKey must be provided together", path: ["parentContentKey"] }
17177
+ );
17178
+ var createDocumentBlockSchema = {
17179
+ documentId: _zod.z.string().uuid().describe("The document to add the block to"),
17180
+ propertyAlias: _zod.z.string().min(1).describe("Document property alias of the BlockList, BlockGrid, or RichText property"),
17181
+ culture: _zod.z.string().nullish().describe("Culture, only for culture-variant document properties"),
17182
+ segment: _zod.z.string().nullish().describe("Segment, only for segment-variant document properties"),
17183
+ contentTypeKey: _zod.z.string().uuid().describe("Element type key of the new block; must be allowed by the property's data type"),
17184
+ properties: _zod.z.array(blockPropertyValueSchema).optional().describe("Content property values for the new block"),
17185
+ settings: _zod.z.object({
17186
+ properties: _zod.z.array(blockPropertyValueSchema).describe("Settings property values")
17187
+ }).optional().describe("Settings for the new block; the settings element type comes from the data type configuration"),
17188
+ placement: placementSchema.optional().describe("Where to place the block relative to siblings (default: append)"),
17189
+ grid: gridSchema.optional().describe("BlockGrid-only layout options. Rejected for BlockList/RichText properties")
17190
+ };
17191
+ async function validateBlockProperties(elementTypeKey, properties, label) {
17192
+ if (properties.length === 0) {
17193
+ return [];
17194
+ }
17195
+ const definitions = await getAllDocumentTypeProperties(elementTypeKey);
17196
+ const errors = [];
17197
+ for (const prop of properties) {
17198
+ const def = definitions.find((d) => d.alias === prop.alias);
17199
+ if (!def) {
17200
+ errors.push(`${label} property '${getPropertyKey(prop.alias, prop.culture, prop.segment)}' does not exist on element type '${elementTypeKey}'`);
17201
+ continue;
17202
+ }
17203
+ const varianceError = validateCultureSegment(prop, def);
17204
+ if (varianceError) {
17205
+ errors.push(`${label}: ${varianceError}`);
17206
+ }
17207
+ }
17208
+ if (!isUmbracoAtLeast(17, 4) && definitions.length > 0) {
17209
+ const propsToValidate = properties.map((p) => {
17210
+ const def = definitions.find((d) => d.alias === p.alias);
17211
+ return { alias: p.alias, value: p.value, dataTypeId: _nullishCoalesce(_optionalChain([def, 'optionalAccess', _39 => _39.dataTypeId]), () => ( "")) };
17212
+ }).filter((p) => p.dataTypeId);
17213
+ if (propsToValidate.length > 0) {
17214
+ const valueValidation = await validatePropertiesBeforeSave(propsToValidate);
17215
+ if (!valueValidation.isValid) {
17216
+ errors.push(...valueValidation.errors.map((e) => `${label}: ${e}`));
17217
+ }
17218
+ }
17219
+ }
17220
+ return errors;
17221
+ }
17222
+ var CreateDocumentBlockTool = {
17223
+ name: "create-document-block",
17224
+ description: `Creates (inserts) one new block in a document's BlockList, BlockGrid, or RichText property.
17225
+
17226
+ Writes the block's contentData (and settingsData), its expose entries, and its layout entry
17227
+ (and, for RichText, the <umb-rte-block> markup element) together in a single document update,
17228
+ so the block renders without any hand-assembled JSON. Acts on the property's top-level blocks only.
17229
+
17230
+ - contentTypeKey must be an element type allowed by the property's data type (and by the target area for BlockGrid).
17231
+ - placement is sibling-relative: { position: "before" | "after", contentKey: "<existing block>" }, or
17232
+ { position: "append" | "prepend" } (default append). For BlockGrid, append/prepend targets the root,
17233
+ or the named area given in grid.
17234
+ - grid (BlockGrid only): columnSpan (default 12), rowSpan (default 1), and areaKey + parentContentKey
17235
+ to insert into a named area of an existing block.
17236
+ - New block keys are generated; the result returns the new contentKey.
17237
+ - The document is saved, not published.
17238
+
17239
+ Example: { documentId: "...", propertyAlias: "mainContent", contentTypeKey: "...",
17240
+ properties: [{ alias: "title", value: "Hello" }], placement: { position: "after", contentKey: "..." } }`,
17241
+ inputSchema: createDocumentBlockSchema,
17242
+ outputSchema: createDocumentBlockOutputSchema.shape,
17243
+ annotations: {
17244
+ idempotentHint: false
17245
+ },
17246
+ slices: ["update"],
17247
+ enabled: (user) => user.fallbackPermissions.includes(UmbracoDocumentPermissions.Update),
17248
+ handler: (async (model) => {
17249
+ const client = UmbracoManagementClient3.getClient();
17250
+ const ctx = await loadDocumentBlockContext(model);
17251
+ const { kind, container, blockConfigs } = ctx;
17252
+ const placement = _nullishCoalesce(model.placement, () => ( { position: "append" }));
17253
+ const contentProperties = _nullishCoalesce(model.properties, () => ( []));
17254
+ const settingsProperties = _nullishCoalesce(_optionalChain([model, 'access', _40 => _40.settings, 'optionalAccess', _41 => _41.properties]), () => ( []));
17255
+ if (model.grid && kind !== "BlockGrid") {
17256
+ throw new (0, _mcpserversdk.ToolValidationError)({
17257
+ title: "grid options not supported",
17258
+ detail: `'grid' only applies to BlockGrid properties; '${model.propertyAlias}' is a ${kind} property`
17259
+ });
17260
+ }
17261
+ const areaKey = _optionalChain([model, 'access', _42 => _42.grid, 'optionalAccess', _43 => _43.areaKey]);
17262
+ const parentContentKey = _optionalChain([model, 'access', _44 => _44.grid, 'optionalAccess', _45 => _45.parentContentKey]);
17263
+ if (!!areaKey !== !!parentContentKey) {
17264
+ throw new (0, _mcpserversdk.ToolValidationError)({
17265
+ title: "Incomplete area target",
17266
+ detail: "grid.areaKey and grid.parentContentKey must be provided together"
17267
+ });
17268
+ }
17269
+ const blockConfig = findBlockTypeConfiguration(blockConfigs, model.contentTypeKey);
17270
+ if (!blockConfig) {
17271
+ throw new (0, _mcpserversdk.ToolValidationError)({
17272
+ title: "Element type not allowed",
17273
+ detail: `Element type '${model.contentTypeKey}' is not configured as a block on property '${model.propertyAlias}'`,
17274
+ extensions: {
17275
+ allowedBlocks: blockConfigs.map((c) => ({ contentTypeKey: c.contentElementTypeKey, label: _nullishCoalesce(c.label, () => ( null)) }))
17276
+ }
17277
+ });
17278
+ }
17279
+ if (model.settings && !blockConfig.settingsElementTypeKey) {
17280
+ throw new (0, _mcpserversdk.ToolValidationError)({
17281
+ title: "Settings not supported",
17282
+ detail: `Block type '${model.contentTypeKey}' has no settings element type configured`
17283
+ });
17284
+ }
17285
+ const propertyErrors = [
17286
+ ...await validateBlockProperties(model.contentTypeKey, contentProperties, "Content"),
17287
+ ...blockConfig.settingsElementTypeKey ? await validateBlockProperties(blockConfig.settingsElementTypeKey, settingsProperties, "Settings") : []
17288
+ ];
17289
+ if (propertyErrors.length > 0) {
17290
+ throw new (0, _mcpserversdk.ToolValidationError)({
17291
+ title: "Invalid block properties",
17292
+ detail: propertyErrors.join("; "),
17293
+ extensions: { errors: propertyErrors }
17294
+ });
17295
+ }
17296
+ let targetItems = container.layoutItems;
17297
+ let targetArea = null;
17298
+ const resolveArea = (parent, key) => {
17299
+ const parentBlock = container.contentData.find((b) => b.key === parent.contentKey);
17300
+ if (!parentBlock) {
17301
+ throw new (0, _mcpserversdk.ToolValidationError)({
17302
+ title: "Parent block not found",
17303
+ detail: `Block '${parent.contentKey}' is in the layout but has no contentData entry`
17304
+ });
17305
+ }
17306
+ const config = findAreaConfiguration(blockConfigs, parentBlock.contentTypeKey, key);
17307
+ if (!config) {
17308
+ throw new (0, _mcpserversdk.ToolValidationError)({
17309
+ title: "Area not found",
17310
+ detail: `Area '${key}' is not configured for block type '${parentBlock.contentTypeKey}'`,
17311
+ extensions: {
17312
+ availableAreas: (_nullishCoalesce(_optionalChain([findBlockTypeConfiguration, 'call', _46 => _46(blockConfigs, parentBlock.contentTypeKey), 'optionalAccess', _47 => _47.areas]), () => ( []))).map((a) => ({ key: a.key, alias: _nullishCoalesce(a.alias, () => ( null)) }))
17313
+ }
17314
+ });
17315
+ }
17316
+ parent.areas = Array.isArray(parent.areas) ? parent.areas : [];
17317
+ let area = parent.areas.find((a) => a.key === key);
17318
+ if (!area) {
17319
+ area = { key, items: [] };
17320
+ parent.areas.push(area);
17321
+ }
17322
+ area.items = Array.isArray(area.items) ? area.items : [];
17323
+ return { items: area.items, config };
17324
+ };
17325
+ if (kind === "BlockGrid") {
17326
+ if (placement.position === "before" || placement.position === "after") {
17327
+ const sibling = findLayoutLocation(container.layoutItems, placement.contentKey);
17328
+ if (!sibling) {
17329
+ throw new (0, _mcpserversdk.ToolValidationError)({
17330
+ title: "Sibling block not found",
17331
+ detail: `No block with contentKey '${placement.contentKey}' exists in property '${model.propertyAlias}'`
17332
+ });
17333
+ }
17334
+ if (areaKey && (sibling.areaKey !== areaKey || _optionalChain([sibling, 'access', _48 => _48.parent, 'optionalAccess', _49 => _49.contentKey]) !== parentContentKey)) {
17335
+ throw new (0, _mcpserversdk.ToolValidationError)({
17336
+ title: "Sibling not in target area",
17337
+ detail: `Block '${placement.contentKey}' is not in area '${areaKey}' of block '${parentContentKey}'`
17338
+ });
17339
+ }
17340
+ targetItems = sibling.items;
17341
+ if (sibling.parent && sibling.areaKey) {
17342
+ targetArea = resolveArea(sibling.parent, sibling.areaKey).config;
17343
+ }
17344
+ } else if (areaKey && parentContentKey) {
17345
+ const parent = findLayoutLocation(container.layoutItems, parentContentKey);
17346
+ if (!parent) {
17347
+ throw new (0, _mcpserversdk.ToolValidationError)({
17348
+ title: "Parent block not found",
17349
+ detail: `No block with contentKey '${parentContentKey}' exists in property '${model.propertyAlias}'`
17350
+ });
17351
+ }
17352
+ const resolved = resolveArea(parent.entry, areaKey);
17353
+ targetItems = resolved.items;
17354
+ targetArea = resolved.config;
17355
+ }
17356
+ if (targetArea) {
17357
+ const notAllowed = checkAllowedInArea(blockConfig, targetArea);
17358
+ if (notAllowed) {
17359
+ throw new (0, _mcpserversdk.ToolValidationError)({ title: "Element type not allowed in area", detail: notAllowed });
17360
+ }
17361
+ if (targetArea.maxAllowed != null && targetItems.length >= targetArea.maxAllowed) {
17362
+ throw new (0, _mcpserversdk.ToolValidationError)({
17363
+ title: "Area is full",
17364
+ detail: `Area '${_nullishCoalesce(targetArea.alias, () => ( targetArea.key))}' allows at most ${targetArea.maxAllowed} block(s)`
17365
+ });
17366
+ }
17367
+ } else if (blockConfig.allowAtRoot === false) {
17368
+ throw new (0, _mcpserversdk.ToolValidationError)({
17369
+ title: "Element type not allowed at root",
17370
+ detail: `Element type '${model.contentTypeKey}' is not allowed at the root of this BlockGrid; insert it into an area instead`
17371
+ });
17372
+ }
17373
+ }
17374
+ const contentKey = _uuid.v4.call(void 0, );
17375
+ const settingsKey = model.settings ? _uuid.v4.call(void 0, ) : null;
17376
+ const layoutEntry = buildLayoutEntry(kind, {
17377
+ contentKey,
17378
+ settingsKey,
17379
+ columnSpan: _optionalChain([model, 'access', _50 => _50.grid, 'optionalAccess', _51 => _51.columnSpan]),
17380
+ rowSpan: _optionalChain([model, 'access', _52 => _52.grid, 'optionalAccess', _53 => _53.rowSpan]),
17381
+ areaKeys: (_nullishCoalesce(blockConfig.areas, () => ( []))).map((a) => a.key)
17382
+ });
17383
+ const elementType = await client.getDocumentTypeById(model.contentTypeKey);
17384
+ let exposeCultures = [null];
17385
+ if (elementType.variesByCulture) {
17386
+ if (model.culture) {
17387
+ exposeCultures = [model.culture];
17388
+ } else {
17389
+ const valueCultures = contentProperties.map((p) => p.culture).filter((c) => !!c);
17390
+ const documentCultures = ctx.document.variants.map((v) => v.culture).filter((c) => !!c);
17391
+ exposeCultures = valueCultures.length > 0 ? valueCultures : documentCultures.length > 0 ? documentCultures : [null];
17392
+ }
17393
+ }
17394
+ const exposeSegment = elementType.variesBySegment ? _nullishCoalesce(model.segment, () => ( null)) : null;
17395
+ let newMarkup = null;
17396
+ if (kind === "RichText") {
17397
+ const inline = blockConfig.displayInline === true;
17398
+ newMarkup = insertRteBlockElement(
17399
+ _nullishCoalesce(ctx.propertyValue.markup, () => ( "")),
17400
+ buildRteBlockElement(contentKey, inline),
17401
+ placement,
17402
+ inline
17403
+ );
17404
+ if (newMarkup === null) {
17405
+ throw new (0, _mcpserversdk.ToolValidationError)({
17406
+ title: "Sibling block not found",
17407
+ detail: `No block element with contentKey '${placement.contentKey}' exists in the RichText markup`
17408
+ });
17409
+ }
17410
+ }
17411
+ if (!insertAtPosition(targetItems, layoutEntry, placement, (i) => i.contentKey)) {
17412
+ throw new (0, _mcpserversdk.ToolValidationError)({
17413
+ title: "Sibling block not found",
17414
+ detail: `No block with contentKey '${placement.contentKey}' exists in property '${model.propertyAlias}'`
17415
+ });
17416
+ }
17417
+ container.contentData.push(buildBlockEntry(contentKey, model.contentTypeKey, contentProperties));
17418
+ if (settingsKey && blockConfig.settingsElementTypeKey) {
17419
+ container.settingsData.push(buildBlockEntry(settingsKey, blockConfig.settingsElementTypeKey, settingsProperties));
17420
+ }
17421
+ container.expose.push(...buildExposeEntries(contentKey, exposeCultures, exposeSegment));
17422
+ if (newMarkup !== null) {
17423
+ ctx.propertyValue.markup = newMarkup;
17424
+ }
17425
+ await saveDocumentValues(model.documentId, ctx.document);
17426
+ return _mcpserversdk.createToolResult.call(void 0, {
17427
+ success: true,
17428
+ message: `Created 1 block in ${kind} property '${getPropertyKey(model.propertyAlias, model.culture, model.segment)}'`,
17429
+ results: [{
17430
+ success: true,
17431
+ contentKey,
17432
+ message: settingsKey ? "Created block with settings" : "Created block"
17433
+ }]
17434
+ });
17435
+ })
17436
+ };
17437
+ var create_document_block_default = _mcpserversdk.withStandardDecorators.call(void 0, CreateDocumentBlockTool);
17438
+
17439
+ // src/umbraco-api/tools/document/put/delete-document-block.ts
17440
+
17441
+
17442
+
17443
+
17444
+
17445
+
17446
+ var deleteDocumentBlockOutputSchema = updateBlockPropertyOutputSchema;
17447
+ var deleteDocumentBlockSchema = {
17448
+ documentId: _zod.z.string().uuid().describe("The document containing the block"),
17449
+ propertyAlias: _zod.z.string().min(1).describe("Document property alias of the BlockList, BlockGrid, or RichText property"),
17450
+ culture: _zod.z.string().nullish().describe("Culture, only for culture-variant document properties"),
17451
+ segment: _zod.z.string().nullish().describe("Segment, only for segment-variant document properties"),
17452
+ contentKey: _zod.z.string().uuid().describe("contentKey of the block to delete")
17453
+ };
17454
+ var DeleteDocumentBlockTool = {
17455
+ name: "delete-document-block",
17456
+ description: `Deletes one block from a document's BlockList, BlockGrid, or RichText property.
17457
+
17458
+ Removes the block's contentData entry, its settingsData entry (via the layout settingsKey),
17459
+ its expose entries, and its layout entry (and, for RichText, its <umb-rte-block> markup element)
17460
+ together in a single document update. Acts on the property's top-level blocks only; BlockGrid
17461
+ blocks inside named areas can be deleted too.
17462
+
17463
+ A BlockGrid block whose areas still contain blocks is refused \u2014 delete the nested blocks first.
17464
+ The document is saved, not published.
17465
+
17466
+ Example: { documentId: "...", propertyAlias: "mainContent", contentKey: "..." }`,
17467
+ inputSchema: deleteDocumentBlockSchema,
17468
+ outputSchema: deleteDocumentBlockOutputSchema.shape,
17469
+ annotations: {
17470
+ destructiveHint: true
17471
+ },
17472
+ slices: ["update"],
17473
+ enabled: (user) => user.fallbackPermissions.includes(UmbracoDocumentPermissions.Update),
17474
+ handler: (async (model) => {
17475
+ const ctx = await loadDocumentBlockContext(model);
17476
+ const { kind, container } = ctx;
17477
+ const location = findLayoutLocation(container.layoutItems, model.contentKey);
17478
+ if (!location) {
17479
+ throw new (0, _mcpserversdk.ToolValidationError)({
17480
+ title: "Block not found",
17481
+ detail: `No block with contentKey '${model.contentKey}' exists in property '${getPropertyKey(model.propertyAlias, model.culture, model.segment)}'`,
17482
+ extensions: {
17483
+ availableBlocks: container.contentData.map((b) => ({ contentKey: b.key, contentTypeKey: b.contentTypeKey }))
17484
+ }
17485
+ });
17486
+ }
17487
+ const nestedKeys = collectNestedAreaContentKeys(location.entry);
17488
+ if (nestedKeys.length > 0) {
17489
+ throw new (0, _mcpserversdk.ToolValidationError)({
17490
+ title: "Block has nested blocks",
17491
+ detail: `Block '${model.contentKey}' still contains ${nestedKeys.length} block(s) in its areas: ${nestedKeys.join(", ")}. Delete them first.`,
17492
+ extensions: { nestedContentKeys: nestedKeys }
17493
+ });
17494
+ }
17495
+ let newMarkup = null;
17496
+ if (kind === "RichText") {
17497
+ newMarkup = removeRteBlockElement(_nullishCoalesce(ctx.propertyValue.markup, () => ( "")), model.contentKey);
17498
+ if (newMarkup === null) {
17499
+ throw new (0, _mcpserversdk.ToolValidationError)({
17500
+ title: "Block markup not found",
17501
+ detail: `Block '${model.contentKey}' has a layout entry but no <umb-rte-block> element in the markup`
17502
+ });
17503
+ }
17504
+ }
17505
+ const removed = removeBlockFromContainer(container, location);
17506
+ if (!removed) {
17507
+ throw new (0, _mcpserversdk.ToolValidationError)({
17508
+ title: "Block data not found",
17509
+ detail: `Block '${model.contentKey}' has a layout entry but no contentData entry`
17510
+ });
17511
+ }
17512
+ if (newMarkup !== null) {
17513
+ ctx.propertyValue.markup = newMarkup;
17514
+ }
17515
+ await saveDocumentValues(model.documentId, ctx.document);
17516
+ return _mcpserversdk.createToolResult.call(void 0, {
17517
+ success: true,
17518
+ message: `Deleted 1 block from ${kind} property '${getPropertyKey(model.propertyAlias, model.culture, model.segment)}'`,
17519
+ results: [{
17520
+ success: true,
17521
+ contentKey: model.contentKey,
17522
+ message: removed.settingsKey ? "Deleted block and its settings" : "Deleted block"
17523
+ }]
17524
+ });
17525
+ })
17526
+ };
17527
+ var delete_document_block_default = _mcpserversdk.withStandardDecorators.call(void 0, DeleteDocumentBlockTool);
17528
+
16807
17529
  // src/umbraco-api/tools/document/items/get/get-root.ts
16808
17530
 
16809
17531
 
@@ -17044,6 +17766,8 @@ var DocumentCollection = {
17044
17766
  tools.push(update_document_properties_default);
17045
17767
  tools.push(update_document_name_default);
17046
17768
  tools.push(update_block_property_default);
17769
+ tools.push(create_document_block_default);
17770
+ tools.push(delete_document_block_default);
17047
17771
  tools.push(put_document_domains_default);
17048
17772
  tools.push(put_document_notifications_default);
17049
17773
  tools.push(put_document_public_access_default);
@@ -17372,7 +18096,7 @@ var CopyDocumentTypeTool = {
17372
18096
  validateStatus: () => true
17373
18097
  });
17374
18098
  if (response.status === 201) {
17375
- const location = _optionalChain([response, 'access', _32 => _32.headers, 'optionalAccess', _33 => _33.location]) || "";
18099
+ const location = _optionalChain([response, 'access', _54 => _54.headers, 'optionalAccess', _55 => _55.location]) || "";
17376
18100
  const newId = location.split("/").pop() || "";
17377
18101
  const output = { id: newId };
17378
18102
  return _mcpserversdk.createToolResult.call(void 0, output);
@@ -19578,7 +20302,7 @@ function getExtensionFromMimeType(mimeType) {
19578
20302
  return extension ? `.${extension}` : void 0;
19579
20303
  }
19580
20304
  function validateMediaTypeForSvg(filePath, fileUrl, fileName, mediaTypeName) {
19581
- const isSvg = _optionalChain([filePath, 'optionalAccess', _34 => _34.toLowerCase, 'call', _35 => _35(), 'access', _36 => _36.endsWith, 'call', _37 => _37(".svg")]) || _optionalChain([fileUrl, 'optionalAccess', _38 => _38.toLowerCase, 'call', _39 => _39(), 'access', _40 => _40.endsWith, 'call', _41 => _41(".svg")]) || fileName.toLowerCase().endsWith(".svg");
20305
+ const isSvg = _optionalChain([filePath, 'optionalAccess', _56 => _56.toLowerCase, 'call', _57 => _57(), 'access', _58 => _58.endsWith, 'call', _59 => _59(".svg")]) || _optionalChain([fileUrl, 'optionalAccess', _60 => _60.toLowerCase, 'call', _61 => _61(), 'access', _62 => _62.endsWith, 'call', _63 => _63(".svg")]) || fileName.toLowerCase().endsWith(".svg");
19582
20306
  if (isSvg && mediaTypeName === _mcpserversdk.MEDIA_TYPE_IMAGE) {
19583
20307
  console.warn(`SVG detected - using ${_mcpserversdk.MEDIA_TYPE_VECTOR_GRAPHICS} media type instead of ${_mcpserversdk.MEDIA_TYPE_IMAGE}`);
19584
20308
  return _mcpserversdk.MEDIA_TYPE_VECTOR_GRAPHICS;
@@ -19732,8 +20456,8 @@ async function uploadMediaFile(client, params) {
19732
20456
  });
19733
20457
  } catch (error) {
19734
20458
  const err = error;
19735
- const errorData = _optionalChain([err, 'access', _42 => _42.response, 'optionalAccess', _43 => _43.data]) ? typeof err.response.data === "string" ? err.response.data : JSON.stringify(err.response.data) : err.message;
19736
- throw new Error(`Failed to upload temporary file: ${_optionalChain([err, 'access', _44 => _44.response, 'optionalAccess', _45 => _45.status]) || "Unknown error"} - ${errorData}`);
20459
+ const errorData = _optionalChain([err, 'access', _64 => _64.response, 'optionalAccess', _65 => _65.data]) ? typeof err.response.data === "string" ? err.response.data : JSON.stringify(err.response.data) : err.message;
20460
+ throw new Error(`Failed to upload temporary file: ${_optionalChain([err, 'access', _66 => _66.response, 'optionalAccess', _67 => _67.status]) || "Unknown error"} - ${errorData}`);
19737
20461
  }
19738
20462
  const valueStructure = buildValueStructure(validatedMediaTypeName, params.temporaryFileId);
19739
20463
  let response;
@@ -19753,12 +20477,12 @@ async function uploadMediaFile(client, params) {
19753
20477
  }, _mcpserversdk.CAPTURE_RAW_HTTP_RESPONSE);
19754
20478
  } catch (error) {
19755
20479
  const err = error;
19756
- throw new Error(`Failed to create media item: ${_optionalChain([err, 'access', _46 => _46.response, 'optionalAccess', _47 => _47.status]) || "Unknown error"} - ${JSON.stringify(_optionalChain([err, 'access', _48 => _48.response, 'optionalAccess', _49 => _49.data])) || err.message}`);
20480
+ throw new Error(`Failed to create media item: ${_optionalChain([err, 'access', _68 => _68.response, 'optionalAccess', _69 => _69.status]) || "Unknown error"} - ${JSON.stringify(_optionalChain([err, 'access', _70 => _70.response, 'optionalAccess', _71 => _71.data])) || err.message}`);
19757
20481
  }
19758
20482
  if (response.status < 200 || response.status >= 300) {
19759
20483
  throw new Error(`Request failed with status code ${response.status}`);
19760
20484
  }
19761
- const locationHeader = _optionalChain([response, 'access', _50 => _50.headers, 'optionalAccess', _51 => _51.location]) || _optionalChain([response, 'access', _52 => _52.headers, 'optionalAccess', _53 => _53.Location]);
20485
+ const locationHeader = _optionalChain([response, 'access', _72 => _72.headers, 'optionalAccess', _73 => _73.location]) || _optionalChain([response, 'access', _74 => _74.headers, 'optionalAccess', _75 => _75.Location]);
19762
20486
  if (!locationHeader) {
19763
20487
  throw new Error("No Location header in response - cannot determine created media ID");
19764
20488
  }
@@ -19801,10 +20525,10 @@ async function resolveAuth() {
19801
20525
  );
19802
20526
  }
19803
20527
  const entry = await _mcphosted.getStoredUmbracoToken.call(void 0, authContext.env.OAUTH_KV, authContext.tokenKey);
19804
- if (!_optionalChain([entry, 'optionalAccess', _54 => _54.tokens, 'optionalAccess', _55 => _55.access_token])) {
20528
+ if (!_optionalChain([entry, 'optionalAccess', _76 => _76.tokens, 'optionalAccess', _77 => _77.access_token])) {
19805
20529
  throw new Error("No Umbraco access token in KV. Reconnect the MCP connector.");
19806
20530
  }
19807
- const baseUrl = _nullishCoalesce(_nullishCoalesce(_nullishCoalesce(_optionalChain([entry, 'access', _56 => _56.site, 'optionalAccess', _57 => _57.serverUrl]), () => ( _optionalChain([entry, 'access', _58 => _58.site, 'optionalAccess', _59 => _59.baseUrl]))), () => ( authContext.env.UMBRACO_SERVER_URL)), () => ( authContext.env.UMBRACO_BASE_URL));
20531
+ const baseUrl = _nullishCoalesce(_nullishCoalesce(_nullishCoalesce(_optionalChain([entry, 'access', _78 => _78.site, 'optionalAccess', _79 => _79.serverUrl]), () => ( _optionalChain([entry, 'access', _80 => _80.site, 'optionalAccess', _81 => _81.baseUrl]))), () => ( authContext.env.UMBRACO_SERVER_URL)), () => ( authContext.env.UMBRACO_BASE_URL));
19808
20532
  if (!baseUrl) {
19809
20533
  throw new Error("No Umbraco base URL resolvable from site or env.");
19810
20534
  }
@@ -19812,7 +20536,7 @@ async function resolveAuth() {
19812
20536
  }
19813
20537
  function ensureExtension(name, contentType, urlPath) {
19814
20538
  if (name.includes(".")) return name;
19815
- const fromUrl = _optionalChain([urlPath, 'access', _60 => _60.match, 'call', _61 => _61(/\.([a-z0-9]{1,8})$/i), 'optionalAccess', _62 => _62[0]]);
20539
+ const fromUrl = _optionalChain([urlPath, 'access', _82 => _82.match, 'call', _83 => _83(/\.([a-z0-9]{1,8})$/i), 'optionalAccess', _84 => _84[0]]);
19816
20540
  if (fromUrl) return `${name}${fromUrl}`;
19817
20541
  if (contentType) {
19818
20542
  const subtype = contentType.split(";")[0].split("/")[1];
@@ -19921,8 +20645,8 @@ Content-Type: ${sourceContentType}\r
19921
20645
  if (response.status < 200 || response.status >= 300) {
19922
20646
  throw new Error(`postMedia failed with status ${response.status}`);
19923
20647
  }
19924
- const locationHeader = _nullishCoalesce(_optionalChain([response, 'access', _63 => _63.headers, 'optionalAccess', _64 => _64.location]), () => ( _optionalChain([response, 'access', _65 => _65.headers, 'optionalAccess', _66 => _66.Location])));
19925
- const idMatch = _optionalChain([locationHeader, 'optionalAccess', _67 => _67.match, 'call', _68 => _68(/\/([a-f0-9-]{36})$/i)]);
20648
+ const locationHeader = _nullishCoalesce(_optionalChain([response, 'access', _85 => _85.headers, 'optionalAccess', _86 => _86.location]), () => ( _optionalChain([response, 'access', _87 => _87.headers, 'optionalAccess', _88 => _88.Location])));
20649
+ const idMatch = _optionalChain([locationHeader, 'optionalAccess', _89 => _89.match, 'call', _90 => _90(/\/([a-f0-9-]{36})$/i)]);
19926
20650
  if (!idMatch) {
19927
20651
  throw new Error(
19928
20652
  `Could not extract media id from Location header: ${_nullishCoalesce(locationHeader, () => ( "(missing)"))}`
@@ -20027,7 +20751,7 @@ ${filePathSection}
20027
20751
  let effectiveSourceType;
20028
20752
  let effectiveFileUrl = model.fileUrl;
20029
20753
  if (model.sourceType === "file") {
20030
- if (!_optionalChain([model, 'access', _69 => _69.file, 'optionalAccess', _70 => _70.download_url])) {
20754
+ if (!_optionalChain([model, 'access', _91 => _91.file, 'optionalAccess', _92 => _92.download_url])) {
20031
20755
  return _mcpserversdk.createToolResultError.call(void 0, {
20032
20756
  detail: "Error creating media: sourceType is 'file' but no file object was provided. ChatGPT's connector should inject this automatically when a file is attached \u2014 if it didn't, the user has nothing attached or your client doesn't support openai/fileParams."
20033
20757
  });
@@ -20176,7 +20900,7 @@ ${filePathSection}
20176
20900
  let effectiveSourceType;
20177
20901
  let effectiveFileUrl = file.fileUrl;
20178
20902
  if (model.sourceType === "file") {
20179
- if (!_optionalChain([file, 'access', _71 => _71.file, 'optionalAccess', _72 => _72.download_url])) {
20903
+ if (!_optionalChain([file, 'access', _93 => _93.file, 'optionalAccess', _94 => _94.download_url])) {
20180
20904
  return {
20181
20905
  success: false,
20182
20906
  name: file.name,
@@ -20275,7 +20999,7 @@ var CreateMediaFolderTool = {
20275
20999
  if (response.status < 200 || response.status >= 300) {
20276
21000
  throw new Error(`Request failed with status code ${response.status}`);
20277
21001
  }
20278
- const locationHeader = _optionalChain([response, 'access', _73 => _73.headers, 'optionalAccess', _74 => _74.location]) || _optionalChain([response, 'access', _75 => _75.headers, 'optionalAccess', _76 => _76.Location]);
21002
+ const locationHeader = _optionalChain([response, 'access', _95 => _95.headers, 'optionalAccess', _96 => _96.location]) || _optionalChain([response, 'access', _97 => _97.headers, 'optionalAccess', _98 => _98.Location]);
20279
21003
  if (!locationHeader) {
20280
21004
  throw new Error("No Location header in response - cannot determine created folder ID");
20281
21005
  }
@@ -21565,7 +22289,7 @@ var CreateMediaTypeFolderTool = {
21565
22289
  validateStatus: () => true
21566
22290
  });
21567
22291
  if (response.status === 201) {
21568
- const locationHeader = _optionalChain([response, 'access', _77 => _77.headers, 'optionalAccess', _78 => _78["location"]]) || _optionalChain([response, 'access', _79 => _79.headers, 'optionalAccess', _80 => _80["Location"]]);
22292
+ const locationHeader = _optionalChain([response, 'access', _99 => _99.headers, 'optionalAccess', _100 => _100["location"]]) || _optionalChain([response, 'access', _101 => _101.headers, 'optionalAccess', _102 => _102["Location"]]);
21569
22293
  let createdId = model.id || "";
21570
22294
  if (locationHeader) {
21571
22295
  const idMatch = locationHeader.match(/([0-9a-f-]{36})$/i);
@@ -21699,7 +22423,7 @@ var CreateMediaTypeTool = {
21699
22423
  validateStatus: () => true
21700
22424
  });
21701
22425
  if (response.status === 201) {
21702
- const locationHeader = _optionalChain([response, 'access', _81 => _81.headers, 'optionalAccess', _82 => _82["location"]]) || _optionalChain([response, 'access', _83 => _83.headers, 'optionalAccess', _84 => _84["Location"]]);
22426
+ const locationHeader = _optionalChain([response, 'access', _103 => _103.headers, 'optionalAccess', _104 => _104["location"]]) || _optionalChain([response, 'access', _105 => _105.headers, 'optionalAccess', _106 => _106["Location"]]);
21703
22427
  let createdId = model.id || "";
21704
22428
  if (locationHeader) {
21705
22429
  const idMatch = locationHeader.match(/([0-9a-f-]{36})$/i);
@@ -21750,7 +22474,7 @@ var CopyMediaTypeTool = {
21750
22474
  validateStatus: () => true
21751
22475
  });
21752
22476
  if (response.status === 201) {
21753
- const locationHeader = _optionalChain([response, 'access', _85 => _85.headers, 'optionalAccess', _86 => _86["location"]]) || _optionalChain([response, 'access', _87 => _87.headers, 'optionalAccess', _88 => _88["Location"]]);
22477
+ const locationHeader = _optionalChain([response, 'access', _107 => _107.headers, 'optionalAccess', _108 => _108["location"]]) || _optionalChain([response, 'access', _109 => _109.headers, 'optionalAccess', _110 => _110["Location"]]);
21754
22478
  let createdId = "";
21755
22479
  if (locationHeader) {
21756
22480
  const idMatch = locationHeader.match(/([0-9a-f-]{36})$/i);
@@ -21960,7 +22684,7 @@ var CreateMemberTool = {
21960
22684
  validateStatus: () => true
21961
22685
  });
21962
22686
  if (response.status === 201) {
21963
- const locationHeader = _optionalChain([response, 'access', _89 => _89.headers, 'optionalAccess', _90 => _90["location"]]) || _optionalChain([response, 'access', _91 => _91.headers, 'optionalAccess', _92 => _92["Location"]]);
22687
+ const locationHeader = _optionalChain([response, 'access', _111 => _111.headers, 'optionalAccess', _112 => _112["location"]]) || _optionalChain([response, 'access', _113 => _113.headers, 'optionalAccess', _114 => _114["Location"]]);
21964
22688
  let createdId = model.id || "";
21965
22689
  if (locationHeader) {
21966
22690
  const idMatch = locationHeader.match(/([0-9a-f-]{36})$/i);
@@ -22511,7 +23235,7 @@ var CreateMemberTypeTool = {
22511
23235
  validateStatus: () => true
22512
23236
  });
22513
23237
  if (response.status === 201) {
22514
- const locationHeader = _optionalChain([response, 'access', _93 => _93.headers, 'optionalAccess', _94 => _94["location"]]) || _optionalChain([response, 'access', _95 => _95.headers, 'optionalAccess', _96 => _96["Location"]]);
23238
+ const locationHeader = _optionalChain([response, 'access', _115 => _115.headers, 'optionalAccess', _116 => _116["location"]]) || _optionalChain([response, 'access', _117 => _117.headers, 'optionalAccess', _118 => _118["Location"]]);
22515
23239
  let createdId = model.id || "";
22516
23240
  if (locationHeader) {
22517
23241
  const idMatch = locationHeader.match(/([0-9a-f-]{36})$/i);
@@ -22681,7 +23405,7 @@ var CopyMemberTypeTool = {
22681
23405
  validateStatus: () => true
22682
23406
  });
22683
23407
  if (response.status === 201) {
22684
- const locationHeader = _optionalChain([response, 'access', _97 => _97.headers, 'optionalAccess', _98 => _98["location"]]) || _optionalChain([response, 'access', _99 => _99.headers, 'optionalAccess', _100 => _100["Location"]]);
23408
+ const locationHeader = _optionalChain([response, 'access', _119 => _119.headers, 'optionalAccess', _120 => _120["location"]]) || _optionalChain([response, 'access', _121 => _121.headers, 'optionalAccess', _122 => _122["Location"]]);
22685
23409
  let createdId = "";
22686
23410
  if (locationHeader) {
22687
23411
  const idMatch = locationHeader.match(/([0-9a-f-]{36})$/i);
@@ -23041,7 +23765,7 @@ var CreatePartialViewTool = {
23041
23765
  validateStatus: () => true
23042
23766
  });
23043
23767
  if (response.status === 201) {
23044
- const locationHeader = _optionalChain([response, 'access', _101 => _101.headers, 'optionalAccess', _102 => _102["location"]]) || _optionalChain([response, 'access', _103 => _103.headers, 'optionalAccess', _104 => _104["Location"]]);
23768
+ const locationHeader = _optionalChain([response, 'access', _123 => _123.headers, 'optionalAccess', _124 => _124["location"]]) || _optionalChain([response, 'access', _125 => _125.headers, 'optionalAccess', _126 => _126["Location"]]);
23045
23769
  let createdPath = "";
23046
23770
  if (locationHeader) {
23047
23771
  const pathMatch = locationHeader.match(/partial-view\/(.+)$/);
@@ -23088,7 +23812,7 @@ var CreatePartialViewFolderTool = {
23088
23812
  validateStatus: () => true
23089
23813
  });
23090
23814
  if (response.status === 201) {
23091
- const locationHeader = _optionalChain([response, 'access', _105 => _105.headers, 'optionalAccess', _106 => _106["location"]]) || _optionalChain([response, 'access', _107 => _107.headers, 'optionalAccess', _108 => _108["Location"]]);
23815
+ const locationHeader = _optionalChain([response, 'access', _127 => _127.headers, 'optionalAccess', _128 => _128["location"]]) || _optionalChain([response, 'access', _129 => _129.headers, 'optionalAccess', _130 => _130["Location"]]);
23092
23816
  let createdPath = "";
23093
23817
  if (locationHeader) {
23094
23818
  const pathMatch = locationHeader.match(/partial-view\/folder\/(.+)$/);
@@ -23915,7 +24639,7 @@ var CreateScriptTool = {
23915
24639
  validateStatus: () => true
23916
24640
  });
23917
24641
  if (response.status === 201) {
23918
- const locationHeader = _optionalChain([response, 'access', _109 => _109.headers, 'optionalAccess', _110 => _110["location"]]) || _optionalChain([response, 'access', _111 => _111.headers, 'optionalAccess', _112 => _112["Location"]]);
24642
+ const locationHeader = _optionalChain([response, 'access', _131 => _131.headers, 'optionalAccess', _132 => _132["location"]]) || _optionalChain([response, 'access', _133 => _133.headers, 'optionalAccess', _134 => _134["Location"]]);
23919
24643
  let createdPath = "";
23920
24644
  if (locationHeader) {
23921
24645
  const pathMatch = locationHeader.match(/script\/(.+)$/);
@@ -23962,7 +24686,7 @@ var CreateScriptFolderTool = {
23962
24686
  validateStatus: () => true
23963
24687
  });
23964
24688
  if (response.status === 201) {
23965
- const locationHeader = _optionalChain([response, 'access', _113 => _113.headers, 'optionalAccess', _114 => _114["location"]]) || _optionalChain([response, 'access', _115 => _115.headers, 'optionalAccess', _116 => _116["Location"]]);
24689
+ const locationHeader = _optionalChain([response, 'access', _135 => _135.headers, 'optionalAccess', _136 => _136["location"]]) || _optionalChain([response, 'access', _137 => _137.headers, 'optionalAccess', _138 => _138["Location"]]);
23966
24690
  let createdPath = "";
23967
24691
  if (locationHeader) {
23968
24692
  const pathMatch = locationHeader.match(/script\/folder\/(.+)$/);
@@ -24559,7 +25283,7 @@ var CreateStylesheetTool = {
24559
25283
  validateStatus: () => true
24560
25284
  });
24561
25285
  if (response.status === 201) {
24562
- const locationHeader = _optionalChain([response, 'access', _117 => _117.headers, 'optionalAccess', _118 => _118["location"]]) || _optionalChain([response, 'access', _119 => _119.headers, 'optionalAccess', _120 => _120["Location"]]);
25286
+ const locationHeader = _optionalChain([response, 'access', _139 => _139.headers, 'optionalAccess', _140 => _140["location"]]) || _optionalChain([response, 'access', _141 => _141.headers, 'optionalAccess', _142 => _142["Location"]]);
24563
25287
  let createdPath = "";
24564
25288
  if (locationHeader) {
24565
25289
  const pathMatch = locationHeader.match(/stylesheet\/(.+)$/);
@@ -24606,7 +25330,7 @@ var CreateStylesheetFolderTool = {
24606
25330
  validateStatus: () => true
24607
25331
  });
24608
25332
  if (response.status === 201) {
24609
- const locationHeader = _optionalChain([response, 'access', _121 => _121.headers, 'optionalAccess', _122 => _122["location"]]) || _optionalChain([response, 'access', _123 => _123.headers, 'optionalAccess', _124 => _124["Location"]]);
25333
+ const locationHeader = _optionalChain([response, 'access', _143 => _143.headers, 'optionalAccess', _144 => _144["location"]]) || _optionalChain([response, 'access', _145 => _145.headers, 'optionalAccess', _146 => _146["Location"]]);
24610
25334
  let createdPath = "";
24611
25335
  if (locationHeader) {
24612
25336
  const pathMatch = locationHeader.match(/stylesheet\/folder\/(.+)$/);
@@ -24970,7 +25694,7 @@ var CreateTemplateTool = {
24970
25694
  validateStatus: () => true
24971
25695
  });
24972
25696
  if (response.status === 201) {
24973
- const locationHeader = _optionalChain([response, 'access', _125 => _125.headers, 'optionalAccess', _126 => _126["location"]]) || _optionalChain([response, 'access', _127 => _127.headers, 'optionalAccess', _128 => _128["Location"]]);
25697
+ const locationHeader = _optionalChain([response, 'access', _147 => _147.headers, 'optionalAccess', _148 => _148["location"]]) || _optionalChain([response, 'access', _149 => _149.headers, 'optionalAccess', _150 => _150["Location"]]);
24974
25698
  let createdId = "";
24975
25699
  if (locationHeader) {
24976
25700
  const idMatch = locationHeader.match(/template\/([a-f0-9-]+)$/i);
@@ -25950,7 +26674,7 @@ var CreateUserDataTool = {
25950
26674
  validateStatus: () => true
25951
26675
  });
25952
26676
  if (response.status === 201) {
25953
- const locationHeader = _optionalChain([response, 'access', _129 => _129.headers, 'optionalAccess', _130 => _130["location"]]) || _optionalChain([response, 'access', _131 => _131.headers, 'optionalAccess', _132 => _132["Location"]]);
26677
+ const locationHeader = _optionalChain([response, 'access', _151 => _151.headers, 'optionalAccess', _152 => _152["location"]]) || _optionalChain([response, 'access', _153 => _153.headers, 'optionalAccess', _154 => _154["Location"]]);
25954
26678
  let createdId = "";
25955
26679
  if (locationHeader) {
25956
26680
  const idMatch = locationHeader.match(/user-data\/([a-f0-9-]+)$/i);
@@ -26188,7 +26912,7 @@ var CreateUserGroupTool = {
26188
26912
  validateStatus: () => true
26189
26913
  });
26190
26914
  if (response.status === 201) {
26191
- const locationHeader = _optionalChain([response, 'access', _133 => _133.headers, 'optionalAccess', _134 => _134["location"]]) || _optionalChain([response, 'access', _135 => _135.headers, 'optionalAccess', _136 => _136["Location"]]);
26915
+ const locationHeader = _optionalChain([response, 'access', _155 => _155.headers, 'optionalAccess', _156 => _156["location"]]) || _optionalChain([response, 'access', _157 => _157.headers, 'optionalAccess', _158 => _158["Location"]]);
26192
26916
  let createdId = "";
26193
26917
  if (locationHeader) {
26194
26918
  const idMatch = locationHeader.match(/user-group\/([a-f0-9-]+)$/i);
@@ -26486,7 +27210,7 @@ var CreateWebhookTool = {
26486
27210
  validateStatus: () => true
26487
27211
  });
26488
27212
  if (response.status === 201) {
26489
- const locationHeader = _optionalChain([response, 'access', _137 => _137.headers, 'optionalAccess', _138 => _138["location"]]) || _optionalChain([response, 'access', _139 => _139.headers, 'optionalAccess', _140 => _140["Location"]]);
27213
+ const locationHeader = _optionalChain([response, 'access', _159 => _159.headers, 'optionalAccess', _160 => _160["location"]]) || _optionalChain([response, 'access', _161 => _161.headers, 'optionalAccess', _162 => _162["Location"]]);
26490
27214
  let createdId = "";
26491
27215
  if (locationHeader) {
26492
27216
  const idMatch = locationHeader.match(/webhook\/([a-f0-9-]+)$/i);
@@ -26722,4 +27446,4 @@ var allSliceNames = [...toolSliceNames, "other"];
26722
27446
 
26723
27447
 
26724
27448
  exports.__commonJS = __commonJS; exports.__toESM = __toESM; exports.UmbracoManagementClient = UmbracoManagementClient3; exports.setAllowFilePathUploads = setAllowFilePathUploads; exports.setUmbracoVersion = setUmbracoVersion; exports.availableCollections = availableCollections; exports.allModes = allModes; exports.allModeNames = allModeNames; exports.allSliceNames = allSliceNames;
26725
- //# sourceMappingURL=chunk-4MRMRMFC.cjs.map
27449
+ //# sourceMappingURL=chunk-3FBX4NTJ.cjs.map