@umbraco-cms/mcp-dev 17.6.9 → 17.6.11

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.
@@ -4726,6 +4726,7 @@ var UmbracoManagementClient3 = (_class = class {
4726
4726
  }, _class.__initStatic(), _class);
4727
4727
 
4728
4728
  // src/umbraco-api/runtime-context.ts
4729
+
4729
4730
  var umbracoVersion = null;
4730
4731
  var allowFilePathUploads = false;
4731
4732
  function setAllowFilePathUploads(allow) {
@@ -4737,9 +4738,10 @@ function isFilePathUploadAllowed() {
4737
4738
  function setUmbracoVersion(version) {
4738
4739
  umbracoVersion = _nullishCoalesce(version, () => ( null));
4739
4740
  }
4740
- function isUmbracoAtLeast(major, minor) {
4741
- if (!umbracoVersion) return false;
4742
- const [maj, min] = umbracoVersion.split(".").map((n) => parseInt(n, 10));
4741
+ function isUmbracoAtLeast(major, minor, requestVersion) {
4742
+ const version = _nullishCoalesce(_nullishCoalesce(requestVersion, () => ( _optionalChain([_mcpserversdk.getActiveRequestContext.call(void 0, ), 'optionalAccess', _9 => _9[_mcpserversdk.UMBRACO_VERSION_CONTEXT_KEY]]))), () => ( umbracoVersion));
4743
+ if (!version) return false;
4744
+ const [maj, min] = version.split(".").map((n) => parseInt(n, 10));
4743
4745
  if (Number.isNaN(maj) || Number.isNaN(min)) return false;
4744
4746
  if (maj > major) return true;
4745
4747
  if (maj < major) return false;
@@ -12940,7 +12942,7 @@ async function synthesizeDataTypeSchema(id) {
12940
12942
  const client = UmbracoManagementClient3.getClient();
12941
12943
  const dataType = await client.getDataTypeById(id);
12942
12944
  const template = findTemplateByEditorAlias(dataType.editorAlias);
12943
- const valueTypeName = _nullishCoalesce(VALUE_TYPE_BY_EDITOR_ALIAS[dataType.editorAlias], () => ( (_optionalChain([template, 'optionalAccess', _9 => _9.value]) !== void 0 ? "JSON" : null)));
12945
+ const valueTypeName = _nullishCoalesce(VALUE_TYPE_BY_EDITOR_ALIAS[dataType.editorAlias], () => ( (_optionalChain([template, 'optionalAccess', _10 => _10.value]) !== void 0 ? "JSON" : null)));
12944
12946
  const jsonSchema = {
12945
12947
  $schema: "https://json-schema.org/draft/2020-12/schema",
12946
12948
  title: dataType.name,
@@ -12948,8 +12950,8 @@ async function synthesizeDataTypeSchema(id) {
12948
12950
  dataTypeId: dataType.id,
12949
12951
  editorAlias: dataType.editorAlias,
12950
12952
  editorUiAlias: dataType.editorUiAlias,
12951
- example: _optionalChain([template, 'optionalAccess', _10 => _10.value]),
12952
- notes: _optionalChain([template, 'optionalAccess', _11 => _11._notes])
12953
+ example: _optionalChain([template, 'optionalAccess', _11 => _11.value]),
12954
+ notes: _optionalChain([template, 'optionalAccess', _12 => _12._notes])
12953
12955
  };
12954
12956
  return { valueTypeName, jsonSchema };
12955
12957
  }
@@ -13070,7 +13072,7 @@ var CopyDataTypeTool = {
13070
13072
  validateStatus: () => true
13071
13073
  });
13072
13074
  if (response.status === 201) {
13073
- const location = _optionalChain([response, 'access', _12 => _12.headers, 'optionalAccess', _13 => _13.location]) || "";
13075
+ const location = _optionalChain([response, 'access', _13 => _13.headers, 'optionalAccess', _14 => _14.location]) || "";
13074
13076
  const newId = location.split("/").pop() || "";
13075
13077
  const output = {
13076
13078
  message: "Data type copied successfully",
@@ -13542,7 +13544,7 @@ var DataTypeCollection = {
13542
13544
  description: "Data type definitions and management",
13543
13545
  dependencies: []
13544
13546
  },
13545
- tools: (user) => {
13547
+ tools: (user, options) => {
13546
13548
  const tools = [get_search_default];
13547
13549
  if (AuthorizationPolicies.TreeAccessDocumentsOrMediaOrMembersOrContentTypes(user)) {
13548
13550
  tools.push(get_references_data_type_default);
@@ -13552,7 +13554,7 @@ var DataTypeCollection = {
13552
13554
  tools.push(get_data_type_batch_default);
13553
13555
  tools.push(get_data_type_configuration_default);
13554
13556
  tools.push(get_data_type_schema_default);
13555
- if (isUmbracoAtLeast(17, 4)) {
13557
+ if (isUmbracoAtLeast(17, 4, _optionalChain([options, 'optionalAccess', _15 => _15.umbracoVersion]))) {
13556
13558
  tools.push(get_data_type_schemas_default);
13557
13559
  }
13558
13560
  }
@@ -13711,7 +13713,7 @@ var CreateDictionaryItemTool = {
13711
13713
  validateStatus: () => true
13712
13714
  });
13713
13715
  if (response.status === 201) {
13714
- const locationHeader = _optionalChain([response, 'access', _14 => _14.headers, 'optionalAccess', _15 => _15["location"]]) || _optionalChain([response, 'access', _16 => _16.headers, 'optionalAccess', _17 => _17["Location"]]);
13716
+ const locationHeader = _optionalChain([response, 'access', _16 => _16.headers, 'optionalAccess', _17 => _17["location"]]) || _optionalChain([response, 'access', _18 => _18.headers, 'optionalAccess', _19 => _19["Location"]]);
13715
13717
  let createdId = model.id || "";
13716
13718
  if (locationHeader) {
13717
13719
  const idMatch = locationHeader.match(/([0-9a-f-]{36})$/i);
@@ -14671,8 +14673,8 @@ function buildPropertyEntry(prop, dataType, template) {
14671
14673
  editorAlias: dataType.editorAlias,
14672
14674
  dataTypeId: dataType.id,
14673
14675
  dataTypeName: dataType.name,
14674
- example: _optionalChain([template, 'optionalAccess', _18 => _18.value]),
14675
- notes: _optionalChain([template, 'optionalAccess', _19 => _19._notes])
14676
+ example: _optionalChain([template, 'optionalAccess', _20 => _20.value]),
14677
+ notes: _optionalChain([template, 'optionalAccess', _21 => _21._notes])
14676
14678
  };
14677
14679
  }
14678
14680
  async function synthesizeDocumentTypeSchema(id) {
@@ -15074,7 +15076,7 @@ var CopyDocumentTool = {
15074
15076
  validateStatus: () => true
15075
15077
  });
15076
15078
  if (response.status === 201) {
15077
- const location = _optionalChain([response, 'access', _20 => _20.headers, 'optionalAccess', _21 => _21.location]) || "";
15079
+ const location = _optionalChain([response, 'access', _22 => _22.headers, 'optionalAccess', _23 => _23.location]) || "";
15078
15080
  const newId = location.split("/").pop() || "";
15079
15081
  const output = { id: newId };
15080
15082
  return _mcpserversdk.createToolResult.call(void 0, output);
@@ -15218,7 +15220,7 @@ var CreateDocumentTool = {
15218
15220
  template = { id: model.templateId };
15219
15221
  } else {
15220
15222
  const docType = await client.getDocumentTypeById(model.documentTypeId);
15221
- template = _optionalChain([docType, 'access', _22 => _22.defaultTemplate, 'optionalAccess', _23 => _23.id]) ? { id: docType.defaultTemplate.id } : null;
15223
+ template = _optionalChain([docType, 'access', _24 => _24.defaultTemplate, 'optionalAccess', _25 => _25.id]) ? { id: docType.defaultTemplate.id } : null;
15222
15224
  }
15223
15225
  const payload = {
15224
15226
  id: documentId,
@@ -15396,7 +15398,7 @@ var CreateAndPublishDocumentTool = {
15396
15398
  template = { id: model.templateId };
15397
15399
  } else {
15398
15400
  const docType = await client.getDocumentTypeById(model.documentTypeId);
15399
- template = _optionalChain([docType, 'access', _24 => _24.defaultTemplate, 'optionalAccess', _25 => _25.id]) ? { id: docType.defaultTemplate.id } : null;
15401
+ template = _optionalChain([docType, 'access', _26 => _26.defaultTemplate, 'optionalAccess', _27 => _27.id]) ? { id: docType.defaultTemplate.id } : null;
15400
15402
  }
15401
15403
  const payload = {
15402
15404
  id: documentId,
@@ -15864,14 +15866,14 @@ var UpdateDocumentTool = {
15864
15866
  slices: ["update"],
15865
15867
  enabled: (user) => user.fallbackPermissions.includes(UmbracoDocumentPermissions.Update),
15866
15868
  handler: (async (model) => {
15867
- const incomingValues = _optionalChain([model, 'access', _26 => _26.data, 'optionalAccess', _27 => _27.values]);
15869
+ const incomingValues = _optionalChain([model, 'access', _28 => _28.data, 'optionalAccess', _29 => _29.values]);
15868
15870
  if (Array.isArray(incomingValues) && incomingValues.length === 0 && !model.confirmClearValues) {
15869
15871
  const client = UmbracoManagementClient3.getClient();
15870
15872
  let currentDocument;
15871
15873
  try {
15872
15874
  currentDocument = await client.getDocumentById(model.id);
15873
15875
  } catch (error) {
15874
- const status = _optionalChain([error, 'optionalAccess', _28 => _28.response, 'optionalAccess', _29 => _29.status]);
15876
+ const status = _optionalChain([error, 'optionalAccess', _30 => _30.response, 'optionalAccess', _31 => _31.status]);
15875
15877
  if (status !== 404) {
15876
15878
  throw error;
15877
15879
  }
@@ -16301,7 +16303,7 @@ var UpdateDocumentPropertiesTool = {
16301
16303
  const docTypeProps = await getDocumentTypeProperties();
16302
16304
  const propsToValidate = allPropertiesToValidate.map((p) => {
16303
16305
  const def = docTypeProps.find((d) => d.alias === p.alias);
16304
- return { alias: p.alias, value: p.value, dataTypeId: _nullishCoalesce(_optionalChain([def, 'optionalAccess', _30 => _30.dataTypeId]), () => ( "")) };
16306
+ return { alias: p.alias, value: p.value, dataTypeId: _nullishCoalesce(_optionalChain([def, 'optionalAccess', _32 => _32.dataTypeId]), () => ( "")) };
16305
16307
  }).filter((p) => p.dataTypeId);
16306
16308
  if (propsToValidate.length > 0) {
16307
16309
  const valueValidation = await validatePropertiesBeforeSave(propsToValidate);
@@ -16525,6 +16527,8 @@ function discoverAllBlockArrays(value, path3 = "root") {
16525
16527
  results.push({
16526
16528
  contentData: value.contentData,
16527
16529
  settingsData: value.settingsData,
16530
+ layout: value.layout && typeof value.layout === "object" ? value.layout : void 0,
16531
+ expose: Array.isArray(value.expose) ? value.expose : void 0,
16528
16532
  path: path3
16529
16533
  });
16530
16534
  value.contentData.forEach((block, index) => {
@@ -16701,7 +16705,7 @@ var UpdateBlockPropertyTool = {
16701
16705
  if (!isUmbracoAtLeast(17, 4) && elementTypeProperties.length > 0) {
16702
16706
  const propsToValidate = update.properties.map((p) => {
16703
16707
  const def = elementTypeProperties.find((d) => d.alias === p.alias);
16704
- return { alias: p.alias, value: p.value, dataTypeId: _nullishCoalesce(_optionalChain([def, 'optionalAccess', _31 => _31.dataTypeId]), () => ( "")) };
16708
+ return { alias: p.alias, value: p.value, dataTypeId: _nullishCoalesce(_optionalChain([def, 'optionalAccess', _33 => _33.dataTypeId]), () => ( "")) };
16705
16709
  }).filter((p) => p.dataTypeId);
16706
16710
  if (propsToValidate.length > 0) {
16707
16711
  const valueValidation = await validatePropertiesBeforeSave(propsToValidate);
@@ -16804,6 +16808,726 @@ var UpdateBlockPropertyTool = {
16804
16808
  };
16805
16809
  var update_block_property_default = _mcpserversdk.withStandardDecorators.call(void 0, UpdateBlockPropertyTool);
16806
16810
 
16811
+ // src/umbraco-api/tools/document/put/create-document-block.ts
16812
+
16813
+
16814
+
16815
+ // src/umbraco-api/tools/document/put/helpers/block-builder.ts
16816
+
16817
+ var BLOCK_EDITOR_ALIASES = {
16818
+ BlockList: "Umbraco.BlockList",
16819
+ BlockGrid: "Umbraco.BlockGrid",
16820
+ RichText: "Umbraco.RichText"
16821
+ };
16822
+ var DEFAULT_GRID_COLUMN_SPAN = 12;
16823
+ var DEFAULT_GRID_ROW_SPAN = 1;
16824
+ function getBlockEditorKind(editorAlias) {
16825
+ switch (editorAlias) {
16826
+ case BLOCK_EDITOR_ALIASES.BlockList:
16827
+ return "BlockList";
16828
+ case BLOCK_EDITOR_ALIASES.BlockGrid:
16829
+ return "BlockGrid";
16830
+ case BLOCK_EDITOR_ALIASES.RichText:
16831
+ return "RichText";
16832
+ default:
16833
+ return null;
16834
+ }
16835
+ }
16836
+ function isBlockListOrGridValue(value) {
16837
+ return isBlockStructure(value) && !isRichTextValue(value);
16838
+ }
16839
+ function isRteWithBlocks(value) {
16840
+ return isRichTextValue(value);
16841
+ }
16842
+ function createEmptyBlockValue(kind) {
16843
+ const blocks = {
16844
+ layout: { [BLOCK_EDITOR_ALIASES[kind]]: [] },
16845
+ contentData: [],
16846
+ settingsData: [],
16847
+ expose: []
16848
+ };
16849
+ return kind === "RichText" ? { markup: "", blocks } : blocks;
16850
+ }
16851
+ function isPlainObject(value) {
16852
+ return typeof value === "object" && value !== null && !Array.isArray(value);
16853
+ }
16854
+ function malformedBlockStructureError(field, expected) {
16855
+ return new (0, _mcpserversdk.ToolValidationError)({
16856
+ title: "Malformed block structure",
16857
+ detail: `Property has a malformed block structure and cannot be safely modified: '${field}' is present but is not ${expected}`
16858
+ });
16859
+ }
16860
+ function ensureField(target, key, expected, isValid, createDefault, fieldLabel = key) {
16861
+ const current = target[key];
16862
+ if (current === void 0 || current === null) {
16863
+ target[key] = createDefault();
16864
+ } else if (!isValid(current)) {
16865
+ throw malformedBlockStructureError(fieldLabel, expected);
16866
+ }
16867
+ }
16868
+ function normaliseRichTextBlockValue(rte) {
16869
+ ensureField(rte, "markup", "a string", (v) => typeof v === "string", () => "");
16870
+ ensureField(rte, "blocks", "an object", isPlainObject, () => createEmptyBlockValue("RichText").blocks);
16871
+ ensureField(rte.blocks, "contentData", "an array", Array.isArray, () => [], "blocks.contentData");
16872
+ ensureField(rte.blocks, "settingsData", "an array", Array.isArray, () => [], "blocks.settingsData");
16873
+ }
16874
+ function getTopLevelBlockContainer(value, kind) {
16875
+ const matches = kind === "RichText" ? isRteWithBlocks(value) : isBlockListOrGridValue(value);
16876
+ if (!matches) {
16877
+ return null;
16878
+ }
16879
+ const raw = kind === "RichText" ? value.blocks : value;
16880
+ const layoutAlias = BLOCK_EDITOR_ALIASES[kind];
16881
+ ensureField(raw, "layout", "an object", isPlainObject, () => ({}));
16882
+ ensureField(raw.layout, layoutAlias, "an array", Array.isArray, () => [], `layout['${layoutAlias}']`);
16883
+ ensureField(raw, "expose", "an array", Array.isArray, () => []);
16884
+ const [topLevel] = discoverAllBlockArrays(value, "root");
16885
+ return {
16886
+ ...topLevel,
16887
+ layout: raw.layout,
16888
+ expose: raw.expose,
16889
+ layoutItems: raw.layout[layoutAlias]
16890
+ };
16891
+ }
16892
+ function buildBlockEntry(key, contentTypeKey, properties) {
16893
+ return {
16894
+ key,
16895
+ contentTypeKey,
16896
+ values: properties.map((p) => ({
16897
+ alias: p.alias,
16898
+ culture: _nullishCoalesce(p.culture, () => ( null)),
16899
+ segment: _nullishCoalesce(p.segment, () => ( null)),
16900
+ value: p.value
16901
+ }))
16902
+ };
16903
+ }
16904
+ function buildLayoutEntry(kind, options) {
16905
+ const entry = { contentKey: options.contentKey };
16906
+ if (options.settingsKey) {
16907
+ entry.settingsKey = options.settingsKey;
16908
+ }
16909
+ if (kind === "BlockGrid") {
16910
+ entry.columnSpan = _nullishCoalesce(options.columnSpan, () => ( DEFAULT_GRID_COLUMN_SPAN));
16911
+ entry.rowSpan = _nullishCoalesce(options.rowSpan, () => ( DEFAULT_GRID_ROW_SPAN));
16912
+ entry.areas = (_nullishCoalesce(options.areaKeys, () => ( []))).map((key) => ({ key, items: [] }));
16913
+ }
16914
+ return entry;
16915
+ }
16916
+ function buildExposeEntries(contentKey, cultures, segment = null) {
16917
+ const unique = Array.from(new Set(cultures.length > 0 ? cultures : [null]));
16918
+ return unique.map((culture) => ({ contentKey, culture, segment }));
16919
+ }
16920
+ function insertAtPosition(items, item, placement, keyOf) {
16921
+ switch (placement.position) {
16922
+ case "prepend":
16923
+ items.unshift(item);
16924
+ return true;
16925
+ case "append":
16926
+ items.push(item);
16927
+ return true;
16928
+ case "before":
16929
+ case "after": {
16930
+ const index = items.findIndex((i) => keyOf(i) === placement.contentKey);
16931
+ if (index === -1) {
16932
+ return false;
16933
+ }
16934
+ items.splice(placement.position === "before" ? index : index + 1, 0, item);
16935
+ return true;
16936
+ }
16937
+ }
16938
+ }
16939
+ function findLayoutLocation(items, contentKey, parent, areaKey) {
16940
+ for (let index = 0; index < items.length; index++) {
16941
+ const entry = items[index];
16942
+ if (entry.contentKey === contentKey) {
16943
+ return { items, index, entry, parent, areaKey };
16944
+ }
16945
+ for (const area of _nullishCoalesce(entry.areas, () => ( []))) {
16946
+ const found = findLayoutLocation(_nullishCoalesce(area.items, () => ( [])), contentKey, entry, area.key);
16947
+ if (found) {
16948
+ return found;
16949
+ }
16950
+ }
16951
+ }
16952
+ return null;
16953
+ }
16954
+ function collectNestedAreaContentKeys(entry) {
16955
+ const keys = [];
16956
+ for (const area of _nullishCoalesce(entry.areas, () => ( []))) {
16957
+ for (const child of _nullishCoalesce(area.items, () => ( []))) {
16958
+ keys.push(child.contentKey, ...collectNestedAreaContentKeys(child));
16959
+ }
16960
+ }
16961
+ return keys;
16962
+ }
16963
+ function removeBlockFromContainer(container, location) {
16964
+ const contentKey = location.entry.contentKey;
16965
+ const contentIndex = container.contentData.findIndex((b) => b.key === contentKey);
16966
+ if (contentIndex === -1) {
16967
+ return null;
16968
+ }
16969
+ const settingsKey = _nullishCoalesce(location.entry.settingsKey, () => ( null));
16970
+ location.items.splice(location.index, 1);
16971
+ container.contentData.splice(contentIndex, 1);
16972
+ if (settingsKey) {
16973
+ const settingsIndex = container.settingsData.findIndex((b) => b.key === settingsKey);
16974
+ if (settingsIndex !== -1) {
16975
+ container.settingsData.splice(settingsIndex, 1);
16976
+ }
16977
+ }
16978
+ for (let i = container.expose.length - 1; i >= 0; i--) {
16979
+ if (container.expose[i].contentKey === contentKey) {
16980
+ container.expose.splice(i, 1);
16981
+ }
16982
+ }
16983
+ return { layoutEntry: location.entry, settingsKey };
16984
+ }
16985
+ function escapeRegExp(value) {
16986
+ return value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
16987
+ }
16988
+ function rteBlockElementPattern(contentKey) {
16989
+ const key = escapeRegExp(contentKey);
16990
+ return new RegExp(
16991
+ `<(umb-rte-block(?:-inline)?)\\b[^>]*\\bdata-content-key=["']${key}["'][^>]*?(?:/>|>[\\s\\S]*?</\\1>)`,
16992
+ "i"
16993
+ );
16994
+ }
16995
+ function buildRteBlockElement(contentKey, inline = false) {
16996
+ const tag = inline ? "umb-rte-block-inline" : "umb-rte-block";
16997
+ return `<${tag} data-content-key="${contentKey}"><!--Umbraco-Block--></${tag}>`;
16998
+ }
16999
+ function findRteBlockElement(markup, contentKey) {
17000
+ const match = rteBlockElementPattern(contentKey).exec(_nullishCoalesce(markup, () => ( "")));
17001
+ if (!match) {
17002
+ return null;
17003
+ }
17004
+ return { start: match.index, end: match.index + match[0].length };
17005
+ }
17006
+ function insertRteBlockElement(markup, element, placement, inline = false) {
17007
+ const current = _nullishCoalesce(markup, () => ( ""));
17008
+ const standalone = inline ? `<p>${element}</p>` : element;
17009
+ switch (placement.position) {
17010
+ case "prepend":
17011
+ return standalone + current;
17012
+ case "append":
17013
+ return current + standalone;
17014
+ case "before":
17015
+ case "after": {
17016
+ const sibling = findRteBlockElement(current, placement.contentKey);
17017
+ if (!sibling) {
17018
+ return null;
17019
+ }
17020
+ const at = placement.position === "before" ? sibling.start : sibling.end;
17021
+ return current.slice(0, at) + element + current.slice(at);
17022
+ }
17023
+ }
17024
+ }
17025
+ function removeRteBlockElement(markup, contentKey) {
17026
+ const found = findRteBlockElement(markup, contentKey);
17027
+ if (!found) {
17028
+ return null;
17029
+ }
17030
+ let { start, end } = found;
17031
+ const openingParagraph = /<p\b[^>]*>\s*$/i.exec(markup.slice(0, start));
17032
+ const closingParagraph = /^\s*<\/p>/i.exec(markup.slice(end));
17033
+ if (openingParagraph && closingParagraph) {
17034
+ start -= openingParagraph[0].length;
17035
+ end += closingParagraph[0].length;
17036
+ }
17037
+ return markup.slice(0, start) + markup.slice(end);
17038
+ }
17039
+ function getBlockTypeConfigurations(dataTypeValues) {
17040
+ const blocks = _optionalChain([dataTypeValues, 'optionalAccess', _34 => _34.find, 'call', _35 => _35((v) => v.alias === "blocks"), 'optionalAccess', _36 => _36.value]);
17041
+ return Array.isArray(blocks) ? blocks : [];
17042
+ }
17043
+ function findBlockTypeConfiguration(configs, contentElementTypeKey) {
17044
+ return configs.find((c) => c.contentElementTypeKey === contentElementTypeKey);
17045
+ }
17046
+ function findAreaConfiguration(configs, parentContentTypeKey, areaKey) {
17047
+ return _optionalChain([findBlockTypeConfiguration, 'call', _37 => _37(configs, parentContentTypeKey), 'optionalAccess', _38 => _38.areas, 'optionalAccess', _39 => _39.find, 'call', _40 => _40((a) => a.key === areaKey)]);
17048
+ }
17049
+ function checkAllowedInArea(blockConfig, area) {
17050
+ if (blockConfig.allowInAreas === false) {
17051
+ return `Element type '${blockConfig.contentElementTypeKey}' is not allowed in areas`;
17052
+ }
17053
+ const allowance = _nullishCoalesce(area.specifiedAllowance, () => ( []));
17054
+ if (allowance.length === 0) {
17055
+ return null;
17056
+ }
17057
+ const allowed = allowance.some(
17058
+ (a) => a.elementTypeKey && a.elementTypeKey === blockConfig.contentElementTypeKey || a.groupKey && blockConfig.groupKey && a.groupKey === blockConfig.groupKey
17059
+ );
17060
+ return allowed ? null : `Element type '${blockConfig.contentElementTypeKey}' is not allowed in area '${_nullishCoalesce(area.alias, () => ( area.key))}'`;
17061
+ }
17062
+
17063
+ // src/umbraco-api/tools/document/put/helpers/document-block-context.ts
17064
+
17065
+ async function loadDocumentBlockContext(model) {
17066
+ const client = UmbracoManagementClient3.getClient();
17067
+ const document = await client.getDocumentById(model.documentId);
17068
+ const documentTypeProperties = await getAllDocumentTypeProperties(document.documentType.id);
17069
+ const propertyDefinition = documentTypeProperties.find((p) => p.alias === model.propertyAlias);
17070
+ if (!propertyDefinition) {
17071
+ throw new (0, _mcpserversdk.ToolValidationError)({
17072
+ title: "Property not found",
17073
+ detail: `Property '${model.propertyAlias}' does not exist on this document's type`,
17074
+ extensions: {
17075
+ availableProperties: documentTypeProperties.map((p) => p.alias)
17076
+ }
17077
+ });
17078
+ }
17079
+ const varianceError = validateCultureSegment(
17080
+ { alias: model.propertyAlias, culture: model.culture, segment: model.segment },
17081
+ propertyDefinition
17082
+ );
17083
+ if (varianceError) {
17084
+ throw new (0, _mcpserversdk.ToolValidationError)({ title: "Invalid culture/segment", detail: varianceError });
17085
+ }
17086
+ const dataType = await client.getDataTypeById(propertyDefinition.dataTypeId);
17087
+ const kind = getBlockEditorKind(dataType.editorAlias);
17088
+ if (!kind) {
17089
+ throw new (0, _mcpserversdk.ToolValidationError)({
17090
+ title: "Not a block property",
17091
+ detail: `Property '${model.propertyAlias}' uses editor '${dataType.editorAlias}', not a BlockList, BlockGrid, or RichText editor`
17092
+ });
17093
+ }
17094
+ let valueEntry = document.values.find(
17095
+ (v) => matchesProperty(v, model.propertyAlias, model.culture, model.segment)
17096
+ );
17097
+ if (!valueEntry) {
17098
+ valueEntry = {
17099
+ alias: model.propertyAlias,
17100
+ culture: _nullishCoalesce(model.culture, () => ( null)),
17101
+ segment: _nullishCoalesce(model.segment, () => ( null)),
17102
+ editorAlias: dataType.editorAlias,
17103
+ value: null
17104
+ };
17105
+ document.values.push(valueEntry);
17106
+ }
17107
+ if (valueEntry.value === null || valueEntry.value === void 0 || valueEntry.value === "") {
17108
+ valueEntry.value = createEmptyBlockValue(kind);
17109
+ } else if (kind === "RichText" && typeof valueEntry.value === "object") {
17110
+ normaliseRichTextBlockValue(valueEntry.value);
17111
+ }
17112
+ const propertyValue = valueEntry.value;
17113
+ const container = getTopLevelBlockContainer(propertyValue, kind);
17114
+ if (!container) {
17115
+ throw new (0, _mcpserversdk.ToolValidationError)({
17116
+ title: "No block structure found",
17117
+ detail: `Property '${getPropertyKey(model.propertyAlias, model.culture, model.segment)}' does not contain a ${kind} block structure`,
17118
+ extensions: { propertyValue }
17119
+ });
17120
+ }
17121
+ return {
17122
+ document,
17123
+ propertyDefinition,
17124
+ kind,
17125
+ propertyValue,
17126
+ container,
17127
+ blockConfigs: getBlockTypeConfigurations(dataType.values)
17128
+ };
17129
+ }
17130
+ async function saveDocumentValues(documentId, document) {
17131
+ const client = UmbracoManagementClient3.getClient();
17132
+ const values = document.values.map((v) => ({
17133
+ alias: v.alias,
17134
+ culture: v.culture,
17135
+ segment: v.segment,
17136
+ value: v.value
17137
+ }));
17138
+ const variants = document.variants.map((v) => ({
17139
+ culture: v.culture,
17140
+ segment: v.segment,
17141
+ name: v.name
17142
+ }));
17143
+ const payload = {
17144
+ values,
17145
+ variants,
17146
+ template: document.template
17147
+ };
17148
+ await client.putDocumentById(documentId, payload);
17149
+ }
17150
+
17151
+ // src/umbraco-api/tools/document/put/create-document-block.ts
17152
+
17153
+
17154
+
17155
+
17156
+
17157
+ var createDocumentBlockOutputSchema = updateBlockPropertyOutputSchema;
17158
+ var blockPropertyValueSchema = _zod.z.object({
17159
+ alias: _zod.z.string().min(1).describe("The property alias on the block's element type"),
17160
+ value: _zod.z.any().nullish().describe("The property value"),
17161
+ culture: _zod.z.string().nullish().describe("Culture code, only for culture-variant element type properties"),
17162
+ segment: _zod.z.string().nullish().describe("Segment, only for segment-variant element type properties")
17163
+ });
17164
+ var placementSchema = _zod.z.object({
17165
+ position: _zod.z.enum(["before", "after", "append", "prepend"]).describe("'before'/'after' an existing sibling block (requires contentKey), or 'append'/'prepend' to the target container"),
17166
+ contentKey: _zod.z.string().uuid().nullish().describe("contentKey of the existing sibling block, required for 'before'/'after'")
17167
+ }).refine(
17168
+ (p) => p.position !== "before" && p.position !== "after" || !!p.contentKey,
17169
+ { message: "contentKey is required when position is 'before' or 'after'", path: ["contentKey"] }
17170
+ );
17171
+ var gridSchema = _zod.z.object({
17172
+ columnSpan: _zod.z.number().int().positive().optional().describe("BlockGrid column span (default 12)"),
17173
+ rowSpan: _zod.z.number().int().positive().optional().describe("BlockGrid row span (default 1)"),
17174
+ areaKey: _zod.z.string().uuid().optional().describe("Key of the named area to insert into (requires parentContentKey)"),
17175
+ parentContentKey: _zod.z.string().uuid().optional().describe("contentKey of the block that owns the area (requires areaKey)")
17176
+ }).refine(
17177
+ (g) => !!g.areaKey === !!g.parentContentKey,
17178
+ { message: "areaKey and parentContentKey must be provided together", path: ["parentContentKey"] }
17179
+ );
17180
+ var createDocumentBlockSchema = {
17181
+ documentId: _zod.z.string().uuid().describe("The document to add the block to"),
17182
+ propertyAlias: _zod.z.string().min(1).describe("Document property alias of the BlockList, BlockGrid, or RichText property"),
17183
+ culture: _zod.z.string().nullish().describe("Culture, only for culture-variant document properties"),
17184
+ segment: _zod.z.string().nullish().describe("Segment, only for segment-variant document properties"),
17185
+ contentTypeKey: _zod.z.string().uuid().describe("Element type key of the new block; must be allowed by the property's data type"),
17186
+ properties: _zod.z.array(blockPropertyValueSchema).optional().describe("Content property values for the new block"),
17187
+ settings: _zod.z.object({
17188
+ properties: _zod.z.array(blockPropertyValueSchema).describe("Settings property values")
17189
+ }).optional().describe("Settings for the new block; the settings element type comes from the data type configuration"),
17190
+ placement: placementSchema.optional().describe("Where to place the block relative to siblings (default: append)"),
17191
+ grid: gridSchema.optional().describe("BlockGrid-only layout options. Rejected for BlockList/RichText properties")
17192
+ };
17193
+ async function validateBlockProperties(elementTypeKey, properties, label) {
17194
+ if (properties.length === 0) {
17195
+ return [];
17196
+ }
17197
+ const definitions = await getAllDocumentTypeProperties(elementTypeKey);
17198
+ const errors = [];
17199
+ for (const prop of properties) {
17200
+ const def = definitions.find((d) => d.alias === prop.alias);
17201
+ if (!def) {
17202
+ errors.push(`${label} property '${getPropertyKey(prop.alias, prop.culture, prop.segment)}' does not exist on element type '${elementTypeKey}'`);
17203
+ continue;
17204
+ }
17205
+ const varianceError = validateCultureSegment(prop, def);
17206
+ if (varianceError) {
17207
+ errors.push(`${label}: ${varianceError}`);
17208
+ }
17209
+ }
17210
+ if (!isUmbracoAtLeast(17, 4) && definitions.length > 0) {
17211
+ const propsToValidate = properties.map((p) => {
17212
+ const def = definitions.find((d) => d.alias === p.alias);
17213
+ return { alias: p.alias, value: p.value, dataTypeId: _nullishCoalesce(_optionalChain([def, 'optionalAccess', _41 => _41.dataTypeId]), () => ( "")) };
17214
+ }).filter((p) => p.dataTypeId);
17215
+ if (propsToValidate.length > 0) {
17216
+ const valueValidation = await validatePropertiesBeforeSave(propsToValidate);
17217
+ if (!valueValidation.isValid) {
17218
+ errors.push(...valueValidation.errors.map((e) => `${label}: ${e}`));
17219
+ }
17220
+ }
17221
+ }
17222
+ return errors;
17223
+ }
17224
+ var CreateDocumentBlockTool = {
17225
+ name: "create-document-block",
17226
+ description: `Creates (inserts) one new block in a document's BlockList, BlockGrid, or RichText property.
17227
+
17228
+ Writes the block's contentData (and settingsData), its expose entries, and its layout entry
17229
+ (and, for RichText, the <umb-rte-block> markup element) together in a single document update,
17230
+ so the block renders without any hand-assembled JSON. Acts on the property's top-level blocks only.
17231
+
17232
+ - contentTypeKey must be an element type allowed by the property's data type (and by the target area for BlockGrid).
17233
+ - placement is sibling-relative: { position: "before" | "after", contentKey: "<existing block>" }, or
17234
+ { position: "append" | "prepend" } (default append). For BlockGrid, append/prepend targets the root,
17235
+ or the named area given in grid.
17236
+ - grid (BlockGrid only): columnSpan (default 12), rowSpan (default 1), and areaKey + parentContentKey
17237
+ to insert into a named area of an existing block.
17238
+ - New block keys are generated; the result returns the new contentKey.
17239
+ - The document is saved, not published.
17240
+
17241
+ Example: { documentId: "...", propertyAlias: "mainContent", contentTypeKey: "...",
17242
+ properties: [{ alias: "title", value: "Hello" }], placement: { position: "after", contentKey: "..." } }`,
17243
+ inputSchema: createDocumentBlockSchema,
17244
+ outputSchema: createDocumentBlockOutputSchema.shape,
17245
+ annotations: {
17246
+ idempotentHint: false
17247
+ },
17248
+ slices: ["update"],
17249
+ enabled: (user) => user.fallbackPermissions.includes(UmbracoDocumentPermissions.Update),
17250
+ handler: (async (model) => {
17251
+ const client = UmbracoManagementClient3.getClient();
17252
+ const ctx = await loadDocumentBlockContext(model);
17253
+ const { kind, container, blockConfigs } = ctx;
17254
+ const placement = _nullishCoalesce(model.placement, () => ( { position: "append" }));
17255
+ const contentProperties = _nullishCoalesce(model.properties, () => ( []));
17256
+ const settingsProperties = _nullishCoalesce(_optionalChain([model, 'access', _42 => _42.settings, 'optionalAccess', _43 => _43.properties]), () => ( []));
17257
+ if (model.grid && kind !== "BlockGrid") {
17258
+ throw new (0, _mcpserversdk.ToolValidationError)({
17259
+ title: "grid options not supported",
17260
+ detail: `'grid' only applies to BlockGrid properties; '${model.propertyAlias}' is a ${kind} property`
17261
+ });
17262
+ }
17263
+ const areaKey = _optionalChain([model, 'access', _44 => _44.grid, 'optionalAccess', _45 => _45.areaKey]);
17264
+ const parentContentKey = _optionalChain([model, 'access', _46 => _46.grid, 'optionalAccess', _47 => _47.parentContentKey]);
17265
+ if (!!areaKey !== !!parentContentKey) {
17266
+ throw new (0, _mcpserversdk.ToolValidationError)({
17267
+ title: "Incomplete area target",
17268
+ detail: "grid.areaKey and grid.parentContentKey must be provided together"
17269
+ });
17270
+ }
17271
+ const blockConfig = findBlockTypeConfiguration(blockConfigs, model.contentTypeKey);
17272
+ if (!blockConfig) {
17273
+ throw new (0, _mcpserversdk.ToolValidationError)({
17274
+ title: "Element type not allowed",
17275
+ detail: `Element type '${model.contentTypeKey}' is not configured as a block on property '${model.propertyAlias}'`,
17276
+ extensions: {
17277
+ allowedBlocks: blockConfigs.map((c) => ({ contentTypeKey: c.contentElementTypeKey, label: _nullishCoalesce(c.label, () => ( null)) }))
17278
+ }
17279
+ });
17280
+ }
17281
+ if (model.settings && !blockConfig.settingsElementTypeKey) {
17282
+ throw new (0, _mcpserversdk.ToolValidationError)({
17283
+ title: "Settings not supported",
17284
+ detail: `Block type '${model.contentTypeKey}' has no settings element type configured`
17285
+ });
17286
+ }
17287
+ const propertyErrors = [
17288
+ ...await validateBlockProperties(model.contentTypeKey, contentProperties, "Content"),
17289
+ ...blockConfig.settingsElementTypeKey ? await validateBlockProperties(blockConfig.settingsElementTypeKey, settingsProperties, "Settings") : []
17290
+ ];
17291
+ if (propertyErrors.length > 0) {
17292
+ throw new (0, _mcpserversdk.ToolValidationError)({
17293
+ title: "Invalid block properties",
17294
+ detail: propertyErrors.join("; "),
17295
+ extensions: { errors: propertyErrors }
17296
+ });
17297
+ }
17298
+ let targetItems = container.layoutItems;
17299
+ let targetArea = null;
17300
+ const resolveArea = (parent, key) => {
17301
+ const parentBlock = container.contentData.find((b) => b.key === parent.contentKey);
17302
+ if (!parentBlock) {
17303
+ throw new (0, _mcpserversdk.ToolValidationError)({
17304
+ title: "Parent block not found",
17305
+ detail: `Block '${parent.contentKey}' is in the layout but has no contentData entry`
17306
+ });
17307
+ }
17308
+ const config = findAreaConfiguration(blockConfigs, parentBlock.contentTypeKey, key);
17309
+ if (!config) {
17310
+ throw new (0, _mcpserversdk.ToolValidationError)({
17311
+ title: "Area not found",
17312
+ detail: `Area '${key}' is not configured for block type '${parentBlock.contentTypeKey}'`,
17313
+ extensions: {
17314
+ availableAreas: (_nullishCoalesce(_optionalChain([findBlockTypeConfiguration, 'call', _48 => _48(blockConfigs, parentBlock.contentTypeKey), 'optionalAccess', _49 => _49.areas]), () => ( []))).map((a) => ({ key: a.key, alias: _nullishCoalesce(a.alias, () => ( null)) }))
17315
+ }
17316
+ });
17317
+ }
17318
+ parent.areas = Array.isArray(parent.areas) ? parent.areas : [];
17319
+ let area = parent.areas.find((a) => a.key === key);
17320
+ if (!area) {
17321
+ area = { key, items: [] };
17322
+ parent.areas.push(area);
17323
+ }
17324
+ area.items = Array.isArray(area.items) ? area.items : [];
17325
+ return { items: area.items, config };
17326
+ };
17327
+ if (kind === "BlockGrid") {
17328
+ if (placement.position === "before" || placement.position === "after") {
17329
+ const sibling = findLayoutLocation(container.layoutItems, placement.contentKey);
17330
+ if (!sibling) {
17331
+ throw new (0, _mcpserversdk.ToolValidationError)({
17332
+ title: "Sibling block not found",
17333
+ detail: `No block with contentKey '${placement.contentKey}' exists in property '${model.propertyAlias}'`
17334
+ });
17335
+ }
17336
+ if (areaKey && (sibling.areaKey !== areaKey || _optionalChain([sibling, 'access', _50 => _50.parent, 'optionalAccess', _51 => _51.contentKey]) !== parentContentKey)) {
17337
+ throw new (0, _mcpserversdk.ToolValidationError)({
17338
+ title: "Sibling not in target area",
17339
+ detail: `Block '${placement.contentKey}' is not in area '${areaKey}' of block '${parentContentKey}'`
17340
+ });
17341
+ }
17342
+ targetItems = sibling.items;
17343
+ if (sibling.parent && sibling.areaKey) {
17344
+ targetArea = resolveArea(sibling.parent, sibling.areaKey).config;
17345
+ }
17346
+ } else if (areaKey && parentContentKey) {
17347
+ const parent = findLayoutLocation(container.layoutItems, parentContentKey);
17348
+ if (!parent) {
17349
+ throw new (0, _mcpserversdk.ToolValidationError)({
17350
+ title: "Parent block not found",
17351
+ detail: `No block with contentKey '${parentContentKey}' exists in property '${model.propertyAlias}'`
17352
+ });
17353
+ }
17354
+ const resolved = resolveArea(parent.entry, areaKey);
17355
+ targetItems = resolved.items;
17356
+ targetArea = resolved.config;
17357
+ }
17358
+ if (targetArea) {
17359
+ const notAllowed = checkAllowedInArea(blockConfig, targetArea);
17360
+ if (notAllowed) {
17361
+ throw new (0, _mcpserversdk.ToolValidationError)({ title: "Element type not allowed in area", detail: notAllowed });
17362
+ }
17363
+ if (targetArea.maxAllowed != null && targetItems.length >= targetArea.maxAllowed) {
17364
+ throw new (0, _mcpserversdk.ToolValidationError)({
17365
+ title: "Area is full",
17366
+ detail: `Area '${_nullishCoalesce(targetArea.alias, () => ( targetArea.key))}' allows at most ${targetArea.maxAllowed} block(s)`
17367
+ });
17368
+ }
17369
+ } else if (blockConfig.allowAtRoot === false) {
17370
+ throw new (0, _mcpserversdk.ToolValidationError)({
17371
+ title: "Element type not allowed at root",
17372
+ detail: `Element type '${model.contentTypeKey}' is not allowed at the root of this BlockGrid; insert it into an area instead`
17373
+ });
17374
+ }
17375
+ }
17376
+ const contentKey = _uuid.v4.call(void 0, );
17377
+ const settingsKey = model.settings ? _uuid.v4.call(void 0, ) : null;
17378
+ const layoutEntry = buildLayoutEntry(kind, {
17379
+ contentKey,
17380
+ settingsKey,
17381
+ columnSpan: _optionalChain([model, 'access', _52 => _52.grid, 'optionalAccess', _53 => _53.columnSpan]),
17382
+ rowSpan: _optionalChain([model, 'access', _54 => _54.grid, 'optionalAccess', _55 => _55.rowSpan]),
17383
+ areaKeys: (_nullishCoalesce(blockConfig.areas, () => ( []))).map((a) => a.key)
17384
+ });
17385
+ const elementType = await client.getDocumentTypeById(model.contentTypeKey);
17386
+ let exposeCultures = [null];
17387
+ if (elementType.variesByCulture) {
17388
+ if (model.culture) {
17389
+ exposeCultures = [model.culture];
17390
+ } else {
17391
+ const valueCultures = contentProperties.map((p) => p.culture).filter((c) => !!c);
17392
+ const documentCultures = ctx.document.variants.map((v) => v.culture).filter((c) => !!c);
17393
+ exposeCultures = valueCultures.length > 0 ? valueCultures : documentCultures.length > 0 ? documentCultures : [null];
17394
+ }
17395
+ }
17396
+ const exposeSegment = elementType.variesBySegment ? _nullishCoalesce(model.segment, () => ( null)) : null;
17397
+ let newMarkup = null;
17398
+ if (kind === "RichText") {
17399
+ const inline = blockConfig.displayInline === true;
17400
+ newMarkup = insertRteBlockElement(
17401
+ _nullishCoalesce(ctx.propertyValue.markup, () => ( "")),
17402
+ buildRteBlockElement(contentKey, inline),
17403
+ placement,
17404
+ inline
17405
+ );
17406
+ if (newMarkup === null) {
17407
+ throw new (0, _mcpserversdk.ToolValidationError)({
17408
+ title: "Sibling block not found",
17409
+ detail: `No block element with contentKey '${placement.contentKey}' exists in the RichText markup`
17410
+ });
17411
+ }
17412
+ }
17413
+ if (!insertAtPosition(targetItems, layoutEntry, placement, (i) => i.contentKey)) {
17414
+ throw new (0, _mcpserversdk.ToolValidationError)({
17415
+ title: "Sibling block not found",
17416
+ detail: `No block with contentKey '${placement.contentKey}' exists in property '${model.propertyAlias}'`
17417
+ });
17418
+ }
17419
+ container.contentData.push(buildBlockEntry(contentKey, model.contentTypeKey, contentProperties));
17420
+ if (settingsKey && blockConfig.settingsElementTypeKey) {
17421
+ container.settingsData.push(buildBlockEntry(settingsKey, blockConfig.settingsElementTypeKey, settingsProperties));
17422
+ }
17423
+ container.expose.push(...buildExposeEntries(contentKey, exposeCultures, exposeSegment));
17424
+ if (newMarkup !== null) {
17425
+ ctx.propertyValue.markup = newMarkup;
17426
+ }
17427
+ await saveDocumentValues(model.documentId, ctx.document);
17428
+ return _mcpserversdk.createToolResult.call(void 0, {
17429
+ success: true,
17430
+ message: `Created 1 block in ${kind} property '${getPropertyKey(model.propertyAlias, model.culture, model.segment)}'`,
17431
+ results: [{
17432
+ success: true,
17433
+ contentKey,
17434
+ message: settingsKey ? "Created block with settings" : "Created block"
17435
+ }]
17436
+ });
17437
+ })
17438
+ };
17439
+ var create_document_block_default = _mcpserversdk.withStandardDecorators.call(void 0, CreateDocumentBlockTool);
17440
+
17441
+ // src/umbraco-api/tools/document/put/delete-document-block.ts
17442
+
17443
+
17444
+
17445
+
17446
+
17447
+
17448
+ var deleteDocumentBlockOutputSchema = updateBlockPropertyOutputSchema;
17449
+ var deleteDocumentBlockSchema = {
17450
+ documentId: _zod.z.string().uuid().describe("The document containing the block"),
17451
+ propertyAlias: _zod.z.string().min(1).describe("Document property alias of the BlockList, BlockGrid, or RichText property"),
17452
+ culture: _zod.z.string().nullish().describe("Culture, only for culture-variant document properties"),
17453
+ segment: _zod.z.string().nullish().describe("Segment, only for segment-variant document properties"),
17454
+ contentKey: _zod.z.string().uuid().describe("contentKey of the block to delete")
17455
+ };
17456
+ var DeleteDocumentBlockTool = {
17457
+ name: "delete-document-block",
17458
+ description: `Deletes one block from a document's BlockList, BlockGrid, or RichText property.
17459
+
17460
+ Removes the block's contentData entry, its settingsData entry (via the layout settingsKey),
17461
+ its expose entries, and its layout entry (and, for RichText, its <umb-rte-block> markup element)
17462
+ together in a single document update. Acts on the property's top-level blocks only; BlockGrid
17463
+ blocks inside named areas can be deleted too.
17464
+
17465
+ A BlockGrid block whose areas still contain blocks is refused \u2014 delete the nested blocks first.
17466
+ The document is saved, not published.
17467
+
17468
+ Example: { documentId: "...", propertyAlias: "mainContent", contentKey: "..." }`,
17469
+ inputSchema: deleteDocumentBlockSchema,
17470
+ outputSchema: deleteDocumentBlockOutputSchema.shape,
17471
+ annotations: {
17472
+ destructiveHint: true
17473
+ },
17474
+ slices: ["update"],
17475
+ enabled: (user) => user.fallbackPermissions.includes(UmbracoDocumentPermissions.Update),
17476
+ handler: (async (model) => {
17477
+ const ctx = await loadDocumentBlockContext(model);
17478
+ const { kind, container } = ctx;
17479
+ const location = findLayoutLocation(container.layoutItems, model.contentKey);
17480
+ if (!location) {
17481
+ throw new (0, _mcpserversdk.ToolValidationError)({
17482
+ title: "Block not found",
17483
+ detail: `No block with contentKey '${model.contentKey}' exists in property '${getPropertyKey(model.propertyAlias, model.culture, model.segment)}'`,
17484
+ extensions: {
17485
+ availableBlocks: container.contentData.map((b) => ({ contentKey: b.key, contentTypeKey: b.contentTypeKey }))
17486
+ }
17487
+ });
17488
+ }
17489
+ const nestedKeys = collectNestedAreaContentKeys(location.entry);
17490
+ if (nestedKeys.length > 0) {
17491
+ throw new (0, _mcpserversdk.ToolValidationError)({
17492
+ title: "Block has nested blocks",
17493
+ detail: `Block '${model.contentKey}' still contains ${nestedKeys.length} block(s) in its areas: ${nestedKeys.join(", ")}. Delete them first.`,
17494
+ extensions: { nestedContentKeys: nestedKeys }
17495
+ });
17496
+ }
17497
+ let newMarkup = null;
17498
+ if (kind === "RichText") {
17499
+ newMarkup = removeRteBlockElement(_nullishCoalesce(ctx.propertyValue.markup, () => ( "")), model.contentKey);
17500
+ if (newMarkup === null) {
17501
+ throw new (0, _mcpserversdk.ToolValidationError)({
17502
+ title: "Block markup not found",
17503
+ detail: `Block '${model.contentKey}' has a layout entry but no <umb-rte-block> element in the markup`
17504
+ });
17505
+ }
17506
+ }
17507
+ const removed = removeBlockFromContainer(container, location);
17508
+ if (!removed) {
17509
+ throw new (0, _mcpserversdk.ToolValidationError)({
17510
+ title: "Block data not found",
17511
+ detail: `Block '${model.contentKey}' has a layout entry but no contentData entry`
17512
+ });
17513
+ }
17514
+ if (newMarkup !== null) {
17515
+ ctx.propertyValue.markup = newMarkup;
17516
+ }
17517
+ await saveDocumentValues(model.documentId, ctx.document);
17518
+ return _mcpserversdk.createToolResult.call(void 0, {
17519
+ success: true,
17520
+ message: `Deleted 1 block from ${kind} property '${getPropertyKey(model.propertyAlias, model.culture, model.segment)}'`,
17521
+ results: [{
17522
+ success: true,
17523
+ contentKey: model.contentKey,
17524
+ message: removed.settingsKey ? "Deleted block and its settings" : "Deleted block"
17525
+ }]
17526
+ });
17527
+ })
17528
+ };
17529
+ var delete_document_block_default = _mcpserversdk.withStandardDecorators.call(void 0, DeleteDocumentBlockTool);
17530
+
16807
17531
  // src/umbraco-api/tools/document/items/get/get-root.ts
16808
17532
 
16809
17533
 
@@ -17006,7 +17730,7 @@ var DocumentCollection = {
17006
17730
  description: "Document content management and publishing",
17007
17731
  dependencies: []
17008
17732
  },
17009
- tools: (user) => {
17733
+ tools: (user, options) => {
17010
17734
  const tools = [];
17011
17735
  if (AuthorizationPolicies.TreeAccessDocuments(user)) {
17012
17736
  tools.push(get_document_by_id_default);
@@ -17015,7 +17739,7 @@ var DocumentCollection = {
17015
17739
  tools.push(get_document_type_schema_default);
17016
17740
  tools.push(copy_document_default);
17017
17741
  tools.push(create_document_default);
17018
- if (isUmbracoAtLeast(17, 6)) {
17742
+ if (isUmbracoAtLeast(17, 6, _optionalChain([options, 'optionalAccess', _56 => _56.umbracoVersion]))) {
17019
17743
  tools.push(create_and_publish_document_default);
17020
17744
  }
17021
17745
  tools.push(post_document_public_access_default);
@@ -17032,18 +17756,20 @@ var DocumentCollection = {
17032
17756
  tools.push(publish_document_default);
17033
17757
  tools.push(publish_document_with_descendants_default);
17034
17758
  tools.push(sort_document_default);
17035
- if (isUmbracoAtLeast(17, 6)) {
17759
+ if (isUmbracoAtLeast(17, 6, _optionalChain([options, 'optionalAccess', _57 => _57.umbracoVersion]))) {
17036
17760
  tools.push(sort_document_children_default);
17037
17761
  tools.push(sort_document_root_children_default);
17038
17762
  }
17039
17763
  tools.push(unpublish_document_default);
17040
17764
  tools.push(update_document_default);
17041
- if (isUmbracoAtLeast(17, 6)) {
17765
+ if (isUmbracoAtLeast(17, 6, _optionalChain([options, 'optionalAccess', _58 => _58.umbracoVersion]))) {
17042
17766
  tools.push(update_and_publish_document_default);
17043
17767
  }
17044
17768
  tools.push(update_document_properties_default);
17045
17769
  tools.push(update_document_name_default);
17046
17770
  tools.push(update_block_property_default);
17771
+ tools.push(create_document_block_default);
17772
+ tools.push(delete_document_block_default);
17047
17773
  tools.push(put_document_domains_default);
17048
17774
  tools.push(put_document_notifications_default);
17049
17775
  tools.push(put_document_public_access_default);
@@ -17372,7 +18098,7 @@ var CopyDocumentTypeTool = {
17372
18098
  validateStatus: () => true
17373
18099
  });
17374
18100
  if (response.status === 201) {
17375
- const location = _optionalChain([response, 'access', _32 => _32.headers, 'optionalAccess', _33 => _33.location]) || "";
18101
+ const location = _optionalChain([response, 'access', _59 => _59.headers, 'optionalAccess', _60 => _60.location]) || "";
17376
18102
  const newId = location.split("/").pop() || "";
17377
18103
  const output = { id: newId };
17378
18104
  return _mcpserversdk.createToolResult.call(void 0, output);
@@ -19578,7 +20304,7 @@ function getExtensionFromMimeType(mimeType) {
19578
20304
  return extension ? `.${extension}` : void 0;
19579
20305
  }
19580
20306
  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");
20307
+ const isSvg = _optionalChain([filePath, 'optionalAccess', _61 => _61.toLowerCase, 'call', _62 => _62(), 'access', _63 => _63.endsWith, 'call', _64 => _64(".svg")]) || _optionalChain([fileUrl, 'optionalAccess', _65 => _65.toLowerCase, 'call', _66 => _66(), 'access', _67 => _67.endsWith, 'call', _68 => _68(".svg")]) || fileName.toLowerCase().endsWith(".svg");
19582
20308
  if (isSvg && mediaTypeName === _mcpserversdk.MEDIA_TYPE_IMAGE) {
19583
20309
  console.warn(`SVG detected - using ${_mcpserversdk.MEDIA_TYPE_VECTOR_GRAPHICS} media type instead of ${_mcpserversdk.MEDIA_TYPE_IMAGE}`);
19584
20310
  return _mcpserversdk.MEDIA_TYPE_VECTOR_GRAPHICS;
@@ -19732,8 +20458,8 @@ async function uploadMediaFile(client, params) {
19732
20458
  });
19733
20459
  } catch (error) {
19734
20460
  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}`);
20461
+ const errorData = _optionalChain([err, 'access', _69 => _69.response, 'optionalAccess', _70 => _70.data]) ? typeof err.response.data === "string" ? err.response.data : JSON.stringify(err.response.data) : err.message;
20462
+ throw new Error(`Failed to upload temporary file: ${_optionalChain([err, 'access', _71 => _71.response, 'optionalAccess', _72 => _72.status]) || "Unknown error"} - ${errorData}`);
19737
20463
  }
19738
20464
  const valueStructure = buildValueStructure(validatedMediaTypeName, params.temporaryFileId);
19739
20465
  let response;
@@ -19753,12 +20479,12 @@ async function uploadMediaFile(client, params) {
19753
20479
  }, _mcpserversdk.CAPTURE_RAW_HTTP_RESPONSE);
19754
20480
  } catch (error) {
19755
20481
  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}`);
20482
+ throw new Error(`Failed to create media item: ${_optionalChain([err, 'access', _73 => _73.response, 'optionalAccess', _74 => _74.status]) || "Unknown error"} - ${JSON.stringify(_optionalChain([err, 'access', _75 => _75.response, 'optionalAccess', _76 => _76.data])) || err.message}`);
19757
20483
  }
19758
20484
  if (response.status < 200 || response.status >= 300) {
19759
20485
  throw new Error(`Request failed with status code ${response.status}`);
19760
20486
  }
19761
- const locationHeader = _optionalChain([response, 'access', _50 => _50.headers, 'optionalAccess', _51 => _51.location]) || _optionalChain([response, 'access', _52 => _52.headers, 'optionalAccess', _53 => _53.Location]);
20487
+ const locationHeader = _optionalChain([response, 'access', _77 => _77.headers, 'optionalAccess', _78 => _78.location]) || _optionalChain([response, 'access', _79 => _79.headers, 'optionalAccess', _80 => _80.Location]);
19762
20488
  if (!locationHeader) {
19763
20489
  throw new Error("No Location header in response - cannot determine created media ID");
19764
20490
  }
@@ -19783,36 +20509,22 @@ function buildSourceTypeSection(allowFilePath, otherSources) {
19783
20509
  // src/umbraco-api/tools/media/post/helpers/streaming-upload.ts
19784
20510
 
19785
20511
 
19786
- var _mcphosted = require('@umbraco-cms/mcp-hosted');
19787
20512
 
19788
20513
 
19789
20514
 
19790
20515
 
19791
20516
 
19792
20517
 
19793
- var authContext = null;
19794
- function isStreamingAuthContextConfigured() {
19795
- return authContext !== null;
20518
+ function isStreamingUploadAvailable() {
20519
+ return _optionalChain([_mcpserversdk.getActiveRequestContext.call(void 0, ), 'optionalAccess', _81 => _81.umbracoAuth]) !== void 0;
19796
20520
  }
19797
20521
  async function resolveAuth() {
19798
- if (!authContext) {
19799
- throw new Error(
19800
- "Streaming auth context not configured. setStreamingAuthContext() must be called in worker init()."
19801
- );
19802
- }
19803
- 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])) {
19805
- throw new Error("No Umbraco access token in KV. Reconnect the MCP connector.");
19806
- }
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));
19808
- if (!baseUrl) {
19809
- throw new Error("No Umbraco base URL resolvable from site or env.");
19810
- }
19811
- return { accessToken: entry.tokens.access_token, baseUrl: _mcpserversdk.normalizeBaseUrl.call(void 0, baseUrl) };
20522
+ const { accessToken, baseUrl } = await _mcpserversdk.getSessionUmbracoAuth.call(void 0, );
20523
+ return { accessToken, baseUrl: _mcpserversdk.normalizeBaseUrl.call(void 0, baseUrl) };
19812
20524
  }
19813
20525
  function ensureExtension(name, contentType, urlPath) {
19814
20526
  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]]);
20527
+ const fromUrl = _optionalChain([urlPath, 'access', _82 => _82.match, 'call', _83 => _83(/\.([a-z0-9]{1,8})$/i), 'optionalAccess', _84 => _84[0]]);
19816
20528
  if (fromUrl) return `${name}${fromUrl}`;
19817
20529
  if (contentType) {
19818
20530
  const subtype = contentType.split(";")[0].split("/")[1];
@@ -19832,10 +20544,7 @@ async function streamingUploadFromUrl(params) {
19832
20544
  );
19833
20545
  const [mediaTypeId, auth] = await Promise.all([
19834
20546
  fetchMediaTypeId(client, validatedMediaTypeName),
19835
- (async () => {
19836
- await client.getTemporaryFileConfiguration().catch(() => void 0);
19837
- return resolveAuth();
19838
- })()
20547
+ resolveAuth()
19839
20548
  ]);
19840
20549
  const { accessToken, baseUrl } = auth;
19841
20550
  const ctl = new AbortController();
@@ -19921,8 +20630,8 @@ Content-Type: ${sourceContentType}\r
19921
20630
  if (response.status < 200 || response.status >= 300) {
19922
20631
  throw new Error(`postMedia failed with status ${response.status}`);
19923
20632
  }
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)]);
20633
+ const locationHeader = _nullishCoalesce(_optionalChain([response, 'access', _85 => _85.headers, 'optionalAccess', _86 => _86.location]), () => ( _optionalChain([response, 'access', _87 => _87.headers, 'optionalAccess', _88 => _88.Location])));
20634
+ const idMatch = _optionalChain([locationHeader, 'optionalAccess', _89 => _89.match, 'call', _90 => _90(/\/([a-f0-9-]{36})$/i)]);
19926
20635
  if (!idMatch) {
19927
20636
  throw new Error(
19928
20637
  `Could not extract media id from Location header: ${_nullishCoalesce(locationHeader, () => ( "(missing)"))}`
@@ -20027,7 +20736,7 @@ ${filePathSection}
20027
20736
  let effectiveSourceType;
20028
20737
  let effectiveFileUrl = model.fileUrl;
20029
20738
  if (model.sourceType === "file") {
20030
- if (!_optionalChain([model, 'access', _69 => _69.file, 'optionalAccess', _70 => _70.download_url])) {
20739
+ if (!_optionalChain([model, 'access', _91 => _91.file, 'optionalAccess', _92 => _92.download_url])) {
20031
20740
  return _mcpserversdk.createToolResultError.call(void 0, {
20032
20741
  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
20742
  });
@@ -20037,7 +20746,7 @@ ${filePathSection}
20037
20746
  } else {
20038
20747
  effectiveSourceType = model.sourceType;
20039
20748
  }
20040
- if (effectiveSourceType === "url" && isStreamingAuthContextConfigured()) {
20749
+ if (effectiveSourceType === "url" && isStreamingUploadAvailable()) {
20041
20750
  if (!effectiveFileUrl) {
20042
20751
  return _mcpserversdk.createToolResultError.call(void 0, {
20043
20752
  detail: "Error creating media: fileUrl is required when sourceType is 'url'"
@@ -20166,7 +20875,7 @@ ${filePathSection}
20166
20875
  });
20167
20876
  }
20168
20877
  const client = UmbracoManagementClient3.getClient();
20169
- const streamingAvailable = isStreamingAuthContextConfigured();
20878
+ const streamingAvailable = isStreamingUploadAvailable();
20170
20879
  const results = await mapWithConcurrency(
20171
20880
  model.files,
20172
20881
  UPLOAD_CONCURRENCY,
@@ -20176,7 +20885,7 @@ ${filePathSection}
20176
20885
  let effectiveSourceType;
20177
20886
  let effectiveFileUrl = file.fileUrl;
20178
20887
  if (model.sourceType === "file") {
20179
- if (!_optionalChain([file, 'access', _71 => _71.file, 'optionalAccess', _72 => _72.download_url])) {
20888
+ if (!_optionalChain([file, 'access', _93 => _93.file, 'optionalAccess', _94 => _94.download_url])) {
20180
20889
  return {
20181
20890
  success: false,
20182
20891
  name: file.name,
@@ -20275,7 +20984,7 @@ var CreateMediaFolderTool = {
20275
20984
  if (response.status < 200 || response.status >= 300) {
20276
20985
  throw new Error(`Request failed with status code ${response.status}`);
20277
20986
  }
20278
- const locationHeader = _optionalChain([response, 'access', _73 => _73.headers, 'optionalAccess', _74 => _74.location]) || _optionalChain([response, 'access', _75 => _75.headers, 'optionalAccess', _76 => _76.Location]);
20987
+ const locationHeader = _optionalChain([response, 'access', _95 => _95.headers, 'optionalAccess', _96 => _96.location]) || _optionalChain([response, 'access', _97 => _97.headers, 'optionalAccess', _98 => _98.Location]);
20279
20988
  if (!locationHeader) {
20280
20989
  throw new Error("No Location header in response - cannot determine created folder ID");
20281
20990
  }
@@ -21088,7 +21797,7 @@ var MediaCollection = {
21088
21797
  description: "Media asset management and organization",
21089
21798
  dependencies: ["temporary-file"]
21090
21799
  },
21091
- tools: (user) => {
21800
+ tools: (user, options) => {
21092
21801
  const tools = [];
21093
21802
  tools.push(get_media_by_id_default);
21094
21803
  if (AuthorizationPolicies.SectionAccessForMediaTree(user)) {
@@ -21110,7 +21819,7 @@ var MediaCollection = {
21110
21819
  tools.push(validate_media_default);
21111
21820
  tools.push(validate_media_default2);
21112
21821
  tools.push(sort_media_default);
21113
- if (isUmbracoAtLeast(17, 6)) {
21822
+ if (isUmbracoAtLeast(17, 6, _optionalChain([options, 'optionalAccess', _99 => _99.umbracoVersion]))) {
21114
21823
  tools.push(sort_media_children_default);
21115
21824
  tools.push(sort_media_root_children_default);
21116
21825
  }
@@ -21131,7 +21840,7 @@ var MediaCollection = {
21131
21840
  tools.push(get_collection_media_default);
21132
21841
  tools.push(get_recycle_bin_media_referenced_by_default);
21133
21842
  tools.push(get_recycle_bin_media_original_parent_default);
21134
- if (isUmbracoAtLeast(17, 4)) {
21843
+ if (isUmbracoAtLeast(17, 4, _optionalChain([options, 'optionalAccess', _100 => _100.umbracoVersion]))) {
21135
21844
  tools.push(get_media_type_schema_default);
21136
21845
  }
21137
21846
  }
@@ -21565,7 +22274,7 @@ var CreateMediaTypeFolderTool = {
21565
22274
  validateStatus: () => true
21566
22275
  });
21567
22276
  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"]]);
22277
+ const locationHeader = _optionalChain([response, 'access', _101 => _101.headers, 'optionalAccess', _102 => _102["location"]]) || _optionalChain([response, 'access', _103 => _103.headers, 'optionalAccess', _104 => _104["Location"]]);
21569
22278
  let createdId = model.id || "";
21570
22279
  if (locationHeader) {
21571
22280
  const idMatch = locationHeader.match(/([0-9a-f-]{36})$/i);
@@ -21699,7 +22408,7 @@ var CreateMediaTypeTool = {
21699
22408
  validateStatus: () => true
21700
22409
  });
21701
22410
  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"]]);
22411
+ const locationHeader = _optionalChain([response, 'access', _105 => _105.headers, 'optionalAccess', _106 => _106["location"]]) || _optionalChain([response, 'access', _107 => _107.headers, 'optionalAccess', _108 => _108["Location"]]);
21703
22412
  let createdId = model.id || "";
21704
22413
  if (locationHeader) {
21705
22414
  const idMatch = locationHeader.match(/([0-9a-f-]{36})$/i);
@@ -21750,7 +22459,7 @@ var CopyMediaTypeTool = {
21750
22459
  validateStatus: () => true
21751
22460
  });
21752
22461
  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"]]);
22462
+ const locationHeader = _optionalChain([response, 'access', _109 => _109.headers, 'optionalAccess', _110 => _110["location"]]) || _optionalChain([response, 'access', _111 => _111.headers, 'optionalAccess', _112 => _112["Location"]]);
21754
22463
  let createdId = "";
21755
22464
  if (locationHeader) {
21756
22465
  const idMatch = locationHeader.match(/([0-9a-f-]{36})$/i);
@@ -21960,7 +22669,7 @@ var CreateMemberTool = {
21960
22669
  validateStatus: () => true
21961
22670
  });
21962
22671
  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"]]);
22672
+ const locationHeader = _optionalChain([response, 'access', _113 => _113.headers, 'optionalAccess', _114 => _114["location"]]) || _optionalChain([response, 'access', _115 => _115.headers, 'optionalAccess', _116 => _116["Location"]]);
21964
22673
  let createdId = model.id || "";
21965
22674
  if (locationHeader) {
21966
22675
  const idMatch = locationHeader.match(/([0-9a-f-]{36})$/i);
@@ -22255,7 +22964,7 @@ var MemberCollection = {
22255
22964
  description: "Member account management and administration",
22256
22965
  dependencies: []
22257
22966
  },
22258
- tools: (user) => {
22967
+ tools: (user, options) => {
22259
22968
  const tools = [];
22260
22969
  if (AuthorizationPolicies.SectionAccessMembers(user)) {
22261
22970
  tools.push(get_member_default);
@@ -22267,7 +22976,7 @@ var MemberCollection = {
22267
22976
  tools.push(get_member_are_referenced_default);
22268
22977
  tools.push(get_member_by_id_referenced_by_default);
22269
22978
  tools.push(get_member_by_id_referenced_descendants_default);
22270
- if (isUmbracoAtLeast(17, 4)) {
22979
+ if (isUmbracoAtLeast(17, 4, _optionalChain([options, 'optionalAccess', _117 => _117.umbracoVersion]))) {
22271
22980
  tools.push(get_member_type_schema_default);
22272
22981
  }
22273
22982
  }
@@ -22511,7 +23220,7 @@ var CreateMemberTypeTool = {
22511
23220
  validateStatus: () => true
22512
23221
  });
22513
23222
  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"]]);
23223
+ const locationHeader = _optionalChain([response, 'access', _118 => _118.headers, 'optionalAccess', _119 => _119["location"]]) || _optionalChain([response, 'access', _120 => _120.headers, 'optionalAccess', _121 => _121["Location"]]);
22515
23224
  let createdId = model.id || "";
22516
23225
  if (locationHeader) {
22517
23226
  const idMatch = locationHeader.match(/([0-9a-f-]{36})$/i);
@@ -22681,7 +23390,7 @@ var CopyMemberTypeTool = {
22681
23390
  validateStatus: () => true
22682
23391
  });
22683
23392
  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"]]);
23393
+ const locationHeader = _optionalChain([response, 'access', _122 => _122.headers, 'optionalAccess', _123 => _123["location"]]) || _optionalChain([response, 'access', _124 => _124.headers, 'optionalAccess', _125 => _125["Location"]]);
22685
23394
  let createdId = "";
22686
23395
  if (locationHeader) {
22687
23396
  const idMatch = locationHeader.match(/([0-9a-f-]{36})$/i);
@@ -23041,7 +23750,7 @@ var CreatePartialViewTool = {
23041
23750
  validateStatus: () => true
23042
23751
  });
23043
23752
  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"]]);
23753
+ const locationHeader = _optionalChain([response, 'access', _126 => _126.headers, 'optionalAccess', _127 => _127["location"]]) || _optionalChain([response, 'access', _128 => _128.headers, 'optionalAccess', _129 => _129["Location"]]);
23045
23754
  let createdPath = "";
23046
23755
  if (locationHeader) {
23047
23756
  const pathMatch = locationHeader.match(/partial-view\/(.+)$/);
@@ -23088,7 +23797,7 @@ var CreatePartialViewFolderTool = {
23088
23797
  validateStatus: () => true
23089
23798
  });
23090
23799
  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"]]);
23800
+ const locationHeader = _optionalChain([response, 'access', _130 => _130.headers, 'optionalAccess', _131 => _131["location"]]) || _optionalChain([response, 'access', _132 => _132.headers, 'optionalAccess', _133 => _133["Location"]]);
23092
23801
  let createdPath = "";
23093
23802
  if (locationHeader) {
23094
23803
  const pathMatch = locationHeader.match(/partial-view\/folder\/(.+)$/);
@@ -23915,7 +24624,7 @@ var CreateScriptTool = {
23915
24624
  validateStatus: () => true
23916
24625
  });
23917
24626
  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"]]);
24627
+ const locationHeader = _optionalChain([response, 'access', _134 => _134.headers, 'optionalAccess', _135 => _135["location"]]) || _optionalChain([response, 'access', _136 => _136.headers, 'optionalAccess', _137 => _137["Location"]]);
23919
24628
  let createdPath = "";
23920
24629
  if (locationHeader) {
23921
24630
  const pathMatch = locationHeader.match(/script\/(.+)$/);
@@ -23962,7 +24671,7 @@ var CreateScriptFolderTool = {
23962
24671
  validateStatus: () => true
23963
24672
  });
23964
24673
  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"]]);
24674
+ const locationHeader = _optionalChain([response, 'access', _138 => _138.headers, 'optionalAccess', _139 => _139["location"]]) || _optionalChain([response, 'access', _140 => _140.headers, 'optionalAccess', _141 => _141["Location"]]);
23966
24675
  let createdPath = "";
23967
24676
  if (locationHeader) {
23968
24677
  const pathMatch = locationHeader.match(/script\/folder\/(.+)$/);
@@ -24559,7 +25268,7 @@ var CreateStylesheetTool = {
24559
25268
  validateStatus: () => true
24560
25269
  });
24561
25270
  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"]]);
25271
+ const locationHeader = _optionalChain([response, 'access', _142 => _142.headers, 'optionalAccess', _143 => _143["location"]]) || _optionalChain([response, 'access', _144 => _144.headers, 'optionalAccess', _145 => _145["Location"]]);
24563
25272
  let createdPath = "";
24564
25273
  if (locationHeader) {
24565
25274
  const pathMatch = locationHeader.match(/stylesheet\/(.+)$/);
@@ -24606,7 +25315,7 @@ var CreateStylesheetFolderTool = {
24606
25315
  validateStatus: () => true
24607
25316
  });
24608
25317
  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"]]);
25318
+ const locationHeader = _optionalChain([response, 'access', _146 => _146.headers, 'optionalAccess', _147 => _147["location"]]) || _optionalChain([response, 'access', _148 => _148.headers, 'optionalAccess', _149 => _149["Location"]]);
24610
25319
  let createdPath = "";
24611
25320
  if (locationHeader) {
24612
25321
  const pathMatch = locationHeader.match(/stylesheet\/folder\/(.+)$/);
@@ -24970,7 +25679,7 @@ var CreateTemplateTool = {
24970
25679
  validateStatus: () => true
24971
25680
  });
24972
25681
  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"]]);
25682
+ const locationHeader = _optionalChain([response, 'access', _150 => _150.headers, 'optionalAccess', _151 => _151["location"]]) || _optionalChain([response, 'access', _152 => _152.headers, 'optionalAccess', _153 => _153["Location"]]);
24974
25683
  let createdId = "";
24975
25684
  if (locationHeader) {
24976
25685
  const idMatch = locationHeader.match(/template\/([a-f0-9-]+)$/i);
@@ -25699,15 +26408,11 @@ var get_user_current_permissions_default = _mcpserversdk.withStandardDecorators.
25699
26408
 
25700
26409
 
25701
26410
 
25702
-
25703
- var outputSchema62 = _zod.z.object({
25704
- items: getUserCurrentPermissionsDocumentResponse
25705
- });
25706
26411
  var GetUserCurrentPermissionsDocumentTool = {
25707
26412
  name: "get-user-current-permissions-document",
25708
26413
  description: "Gets the current user's document permissions for specific documents",
25709
26414
  inputSchema: getUserCurrentPermissionsDocumentQueryParams.shape,
25710
- outputSchema: outputSchema62.shape,
26415
+ outputSchema: getUserCurrentPermissionsDocumentResponse.shape,
25711
26416
  annotations: { readOnlyHint: true },
25712
26417
  slices: ["permissions"],
25713
26418
  handler: (async (params) => {
@@ -25898,7 +26603,7 @@ var UserCollection = {
25898
26603
  description: "User account management and administration",
25899
26604
  dependencies: ["temporary-file"]
25900
26605
  },
25901
- tools: (user) => {
26606
+ tools: (user, options) => {
25902
26607
  const tools = [];
25903
26608
  tools.push(get_user_current_default);
25904
26609
  tools.push(get_user_current_configuration_default);
@@ -25916,7 +26621,7 @@ var UserCollection = {
25916
26621
  tools.push(get_item_user_default);
25917
26622
  tools.push(get_user_configuration_default);
25918
26623
  tools.push(get_user_by_id_calculate_start_nodes_default);
25919
- if (isUmbracoAtLeast(17, 6)) {
26624
+ if (isUmbracoAtLeast(17, 6, _optionalChain([options, 'optionalAccess', _154 => _154.umbracoVersion]))) {
25920
26625
  tools.push(get_user_batch_default);
25921
26626
  }
25922
26627
  tools.push(upload_user_avatar_by_id_default);
@@ -25950,7 +26655,7 @@ var CreateUserDataTool = {
25950
26655
  validateStatus: () => true
25951
26656
  });
25952
26657
  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"]]);
26658
+ const locationHeader = _optionalChain([response, 'access', _155 => _155.headers, 'optionalAccess', _156 => _156["location"]]) || _optionalChain([response, 'access', _157 => _157.headers, 'optionalAccess', _158 => _158["Location"]]);
25954
26659
  let createdId = "";
25955
26660
  if (locationHeader) {
25956
26661
  const idMatch = locationHeader.match(/user-data\/([a-f0-9-]+)$/i);
@@ -26104,14 +26809,14 @@ var get_user_group_default = _mcpserversdk.withStandardDecorators.call(void 0, G
26104
26809
 
26105
26810
 
26106
26811
 
26107
- var outputSchema63 = _zod.z.object({
26812
+ var outputSchema62 = _zod.z.object({
26108
26813
  items: getItemUserGroupResponse
26109
26814
  });
26110
26815
  var GetUserGroupByIdArrayTool = {
26111
26816
  name: "get-user-group-by-id-array",
26112
26817
  description: "Gets user groups by an array of IDs",
26113
26818
  inputSchema: getItemUserGroupQueryParams.shape,
26114
- outputSchema: outputSchema63.shape,
26819
+ outputSchema: outputSchema62.shape,
26115
26820
  annotations: { readOnlyHint: true },
26116
26821
  slices: ["list"],
26117
26822
  handler: (async (params) => {
@@ -26188,7 +26893,7 @@ var CreateUserGroupTool = {
26188
26893
  validateStatus: () => true
26189
26894
  });
26190
26895
  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"]]);
26896
+ const locationHeader = _optionalChain([response, 'access', _159 => _159.headers, 'optionalAccess', _160 => _160["location"]]) || _optionalChain([response, 'access', _161 => _161.headers, 'optionalAccess', _162 => _162["Location"]]);
26192
26897
  let createdId = "";
26193
26898
  if (locationHeader) {
26194
26899
  const idMatch = locationHeader.match(/user-group\/([a-f0-9-]+)$/i);
@@ -26332,14 +27037,14 @@ var get_webhook_by_id_default = _mcpserversdk.withStandardDecorators.call(void 0
26332
27037
 
26333
27038
 
26334
27039
 
26335
- var outputSchema64 = _zod.z.object({
27040
+ var outputSchema63 = _zod.z.object({
26336
27041
  items: getItemWebhookResponse
26337
27042
  });
26338
27043
  var GetWebhookItemTool = {
26339
27044
  name: "get-webhook-item",
26340
27045
  description: "Gets webhooks by IDs (or empty array if no IDs are provided)",
26341
27046
  inputSchema: getItemWebhookQueryParams.shape,
26342
- outputSchema: outputSchema64.shape,
27047
+ outputSchema: outputSchema63.shape,
26343
27048
  annotations: { readOnlyHint: true },
26344
27049
  slices: ["list"],
26345
27050
  handler: (async (params) => {
@@ -26486,7 +27191,7 @@ var CreateWebhookTool = {
26486
27191
  validateStatus: () => true
26487
27192
  });
26488
27193
  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"]]);
27194
+ const locationHeader = _optionalChain([response, 'access', _163 => _163.headers, 'optionalAccess', _164 => _164["location"]]) || _optionalChain([response, 'access', _165 => _165.headers, 'optionalAccess', _166 => _166["Location"]]);
26490
27195
  let createdId = "";
26491
27196
  if (locationHeader) {
26492
27197
  const idMatch = locationHeader.match(/webhook\/([a-f0-9-]+)$/i);
@@ -26722,4 +27427,4 @@ var allSliceNames = [...toolSliceNames, "other"];
26722
27427
 
26723
27428
 
26724
27429
  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
27430
+ //# sourceMappingURL=chunk-WAZSHKMB.cjs.map