@firfi/huly-mcp 0.6.2 → 0.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -34077,15 +34077,15 @@ var require_storage = __commonJS({
34077
34077
  var __toCommonJS2 = (mod) => __copyProps2(__defProp2({}, "__esModule", { value: true }), mod);
34078
34078
  var storage_exports = {};
34079
34079
  __export2(storage_exports, {
34080
- SortingOrder: () => SortingOrder26,
34080
+ SortingOrder: () => SortingOrder27,
34081
34081
  shouldShowArchived: () => shouldShowArchived
34082
34082
  });
34083
34083
  module2.exports = __toCommonJS2(storage_exports);
34084
- var SortingOrder26 = /* @__PURE__ */ ((SortingOrder27) => {
34085
- SortingOrder27[SortingOrder27["Ascending"] = 1] = "Ascending";
34086
- SortingOrder27[SortingOrder27["Descending"] = -1] = "Descending";
34087
- return SortingOrder27;
34088
- })(SortingOrder26 || {});
34084
+ var SortingOrder27 = /* @__PURE__ */ ((SortingOrder28) => {
34085
+ SortingOrder28[SortingOrder28["Ascending"] = 1] = "Ascending";
34086
+ SortingOrder28[SortingOrder28["Descending"] = -1] = "Descending";
34087
+ return SortingOrder28;
34088
+ })(SortingOrder27 || {});
34089
34089
  function shouldShowArchived(query, options) {
34090
34090
  if (options?.showArchived !== void 0) {
34091
34091
  return options.showArchived;
@@ -34588,7 +34588,7 @@ var require_client3 = __commonJS({
34588
34588
  getClient: () => getClient
34589
34589
  });
34590
34590
  module2.exports = __toCommonJS2(client_exports);
34591
- var import_core47 = require_lib4();
34591
+ var import_core48 = require_lib4();
34592
34592
  var import_platform2 = __toESM2(require_lib());
34593
34593
  var import_utils14 = require_utils3();
34594
34594
  function getClient(accountsUrl, token, retryTimeoutMs) {
@@ -34624,7 +34624,7 @@ var require_client3 = __commonJS({
34624
34624
  rpc;
34625
34625
  async getProviders() {
34626
34626
  return await withRetryUntilMaxAttempts(async () => {
34627
- const response = await fetch((0, import_core47.concatLink)(this.url, "/providers"));
34627
+ const response = await fetch((0, import_core48.concatLink)(this.url, "/providers"));
34628
34628
  return await response.json();
34629
34629
  })();
34630
34630
  }
@@ -35279,7 +35279,7 @@ var require_client3 = __commonJS({
35279
35279
  await this.rpc(request2);
35280
35280
  }
35281
35281
  async setCookie() {
35282
- const url4 = (0, import_core47.concatLink)(this.url, "/cookie");
35282
+ const url4 = (0, import_core48.concatLink)(this.url, "/cookie");
35283
35283
  const response = await fetch(url4, { ...this.request, method: "PUT" });
35284
35284
  if (!response.ok) {
35285
35285
  const result = await response.json();
@@ -35289,7 +35289,7 @@ var require_client3 = __commonJS({
35289
35289
  }
35290
35290
  }
35291
35291
  async deleteCookie() {
35292
- const url4 = (0, import_core47.concatLink)(this.url, "/cookie");
35292
+ const url4 = (0, import_core48.concatLink)(this.url, "/cookie");
35293
35293
  const response = await fetch(url4, { ...this.request, method: "DELETE" });
35294
35294
  if (!response.ok) {
35295
35295
  const result = await response.json();
@@ -35568,9 +35568,9 @@ var require_config = __commonJS({
35568
35568
  loadServerConfig: () => loadServerConfig4
35569
35569
  });
35570
35570
  module2.exports = __toCommonJS2(config_exports3);
35571
- var import_core47 = require_lib4();
35571
+ var import_core48 = require_lib4();
35572
35572
  async function loadServerConfig4(url4) {
35573
- const configUrl = (0, import_core47.concatLink)(url4, "/config.json");
35573
+ const configUrl = (0, import_core48.concatLink)(url4, "/config.json");
35574
35574
  const res = await fetch(configUrl, { keepalive: true });
35575
35575
  if (res.ok) {
35576
35576
  return await res.json();
@@ -35656,7 +35656,7 @@ var require_client4 = __commonJS({
35656
35656
  getClient: () => getClient
35657
35657
  });
35658
35658
  module2.exports = __toCommonJS2(client_exports);
35659
- var import_core47 = require_lib4();
35659
+ var import_core48 = require_lib4();
35660
35660
  var import_utils14 = require_utils4();
35661
35661
  function getClient(workspaceId, token, collaboratorUrl) {
35662
35662
  const url4 = collaboratorUrl.replaceAll("wss://", "https://").replace("ws://", "http://");
@@ -35675,7 +35675,7 @@ var require_client4 = __commonJS({
35675
35675
  async rpc(document2, method, payload) {
35676
35676
  const workspace = this.workspace;
35677
35677
  const documentId = (0, import_utils14.encodeDocumentId)(workspace, document2);
35678
- const url4 = (0, import_core47.concatLink)(this.collaboratorUrl, `/rpc/${encodeURIComponent(documentId)}`);
35678
+ const url4 = (0, import_core48.concatLink)(this.collaboratorUrl, `/rpc/${encodeURIComponent(documentId)}`);
35679
35679
  const res = await fetch(url4, {
35680
35680
  method: "POST",
35681
35681
  headers: {
@@ -53242,9 +53242,9 @@ var require_image = __commonJS({
53242
53242
  ImageNode: () => ImageNode
53243
53243
  });
53244
53244
  module2.exports = __toCommonJS2(image_exports);
53245
- var import_core47 = require_dist16();
53245
+ var import_core48 = require_dist16();
53246
53246
  var import_utils14 = require_utils5();
53247
- var ImageNode = import_core47.Node.create({
53247
+ var ImageNode = import_core48.Node.create({
53248
53248
  name: "image",
53249
53249
  addOptions() {
53250
53250
  return {
@@ -53303,7 +53303,7 @@ var require_image = __commonJS({
53303
53303
  "data-type": this.name,
53304
53304
  "data-align": node.attrs.align
53305
53305
  };
53306
- const imgAttributes = (0, import_core47.mergeAttributes)(
53306
+ const imgAttributes = (0, import_core48.mergeAttributes)(
53307
53307
  {
53308
53308
  "data-type": this.name
53309
53309
  },
@@ -53347,9 +53347,9 @@ var require_reference = __commonJS({
53347
53347
  ReferenceNode: () => ReferenceNode
53348
53348
  });
53349
53349
  module2.exports = __toCommonJS2(reference_exports);
53350
- var import_core47 = require_dist16();
53350
+ var import_core48 = require_dist16();
53351
53351
  var import_utils14 = require_utils5();
53352
- var ReferenceNode = import_core47.Node.create({
53352
+ var ReferenceNode = import_core48.Node.create({
53353
53353
  name: "reference",
53354
53354
  group: "inline",
53355
53355
  inline: true,
@@ -53384,7 +53384,7 @@ var require_reference = __commonJS({
53384
53384
  renderHTML({ node, HTMLAttributes }) {
53385
53385
  return [
53386
53386
  "span",
53387
- (0, import_core47.mergeAttributes)(
53387
+ (0, import_core48.mergeAttributes)(
53388
53388
  {
53389
53389
  "data-type": this.name,
53390
53390
  "data-id": node.attrs.id,
@@ -53443,8 +53443,8 @@ var require_emoji = __commonJS({
53443
53443
  EmojiNode: () => EmojiNode
53444
53444
  });
53445
53445
  module2.exports = __toCommonJS2(emoji_exports);
53446
- var import_core47 = require_dist16();
53447
- var EmojiNode = import_core47.Node.create({
53446
+ var import_core48 = require_dist16();
53447
+ var EmojiNode = import_core48.Node.create({
53448
53448
  name: "emoji",
53449
53449
  group: "inline",
53450
53450
  inline: true,
@@ -53484,7 +53484,7 @@ var require_emoji = __commonJS({
53484
53484
  addNodeView() {
53485
53485
  return ({ node, HTMLAttributes }) => {
53486
53486
  const container = document.createElement("span");
53487
- const containerAttributes = (0, import_core47.mergeAttributes)(
53487
+ const containerAttributes = (0, import_core48.mergeAttributes)(
53488
53488
  {
53489
53489
  "data-type": this.name,
53490
53490
  class: "emoji"
@@ -53517,7 +53517,7 @@ var require_emoji = __commonJS({
53517
53517
  if (node.attrs.kind === "image") {
53518
53518
  return [
53519
53519
  "span",
53520
- (0, import_core47.mergeAttributes)(
53520
+ (0, import_core48.mergeAttributes)(
53521
53521
  {
53522
53522
  "data-type": this.name,
53523
53523
  class: "emoji"
@@ -53526,7 +53526,7 @@ var require_emoji = __commonJS({
53526
53526
  ),
53527
53527
  [
53528
53528
  "img",
53529
- (0, import_core47.mergeAttributes)({
53529
+ (0, import_core48.mergeAttributes)({
53530
53530
  "data-type": this.name,
53531
53531
  src: node.attrs.image,
53532
53532
  alt: node.attrs.emoji
@@ -53536,7 +53536,7 @@ var require_emoji = __commonJS({
53536
53536
  }
53537
53537
  return [
53538
53538
  "span",
53539
- (0, import_core47.mergeAttributes)(
53539
+ (0, import_core48.mergeAttributes)(
53540
53540
  {
53541
53541
  "data-type": this.name,
53542
53542
  class: "emoji"
@@ -53844,8 +53844,8 @@ var require_file = __commonJS({
53844
53844
  FileNode: () => FileNode
53845
53845
  });
53846
53846
  module2.exports = __toCommonJS2(file_exports);
53847
- var import_core47 = require_dist16();
53848
- var FileNode = import_core47.Node.create({
53847
+ var import_core48 = require_dist16();
53848
+ var FileNode = import_core48.Node.create({
53849
53849
  name: "file",
53850
53850
  addOptions() {
53851
53851
  return {
@@ -54155,7 +54155,7 @@ var require_codeblock = __commonJS({
54155
54155
  tildeInputRegex: () => tildeInputRegex
54156
54156
  });
54157
54157
  module2.exports = __toCommonJS2(codeblock_exports);
54158
- var import_core47 = require_dist16();
54158
+ var import_core48 = require_dist16();
54159
54159
  var import_extension_code_block = __toESM2(require_dist19());
54160
54160
  var codeBlockOptions = {
54161
54161
  defaultLanguage: "plaintext",
@@ -54201,11 +54201,11 @@ var require_codeblock = __commonJS({
54201
54201
  },
54202
54202
  addInputRules() {
54203
54203
  return [
54204
- (0, import_core47.textblockTypeInputRule)({
54204
+ (0, import_core48.textblockTypeInputRule)({
54205
54205
  find: backtickInputRegex,
54206
54206
  type: this.type
54207
54207
  }),
54208
- (0, import_core47.textblockTypeInputRule)({
54208
+ (0, import_core48.textblockTypeInputRule)({
54209
54209
  find: tildeInputRegex,
54210
54210
  type: this.type
54211
54211
  })
@@ -54241,8 +54241,8 @@ var require_comment = __commonJS({
54241
54241
  CommentNode: () => CommentNode
54242
54242
  });
54243
54243
  module2.exports = __toCommonJS2(comment_exports);
54244
- var import_core47 = require_dist16();
54245
- var CommentNode = import_core47.Node.create({
54244
+ var import_core48 = require_dist16();
54245
+ var CommentNode = import_core48.Node.create({
54246
54246
  name: "comment",
54247
54247
  group: "inline",
54248
54248
  inline: true,
@@ -54288,8 +54288,8 @@ var require_markdown = __commonJS({
54288
54288
  MarkdownNode: () => MarkdownNode
54289
54289
  });
54290
54290
  module2.exports = __toCommonJS2(markdown_exports);
54291
- var import_core47 = require_dist16();
54292
- var MarkdownNode = import_core47.Node.create({
54291
+ var import_core48 = require_dist16();
54292
+ var MarkdownNode = import_core48.Node.create({
54293
54293
  name: "markdown",
54294
54294
  group: "block",
54295
54295
  content: "text*",
@@ -54307,7 +54307,7 @@ var require_markdown = __commonJS({
54307
54307
  renderHTML({ node, HTMLAttributes }) {
54308
54308
  return [
54309
54309
  "pre",
54310
- (0, import_core47.mergeAttributes)({ "data-type": this.name }, this.options.HTMLAttributes, HTMLAttributes),
54310
+ (0, import_core48.mergeAttributes)({ "data-type": this.name }, this.options.HTMLAttributes, HTMLAttributes),
54311
54311
  ["code", {}, 0]
54312
54312
  ];
54313
54313
  }
@@ -54341,8 +54341,8 @@ var require_embed = __commonJS({
54341
54341
  EmbedNode: () => EmbedNode
54342
54342
  });
54343
54343
  module2.exports = __toCommonJS2(embed_exports);
54344
- var import_core47 = require_dist16();
54345
- var EmbedNode = import_core47.Node.create({
54344
+ var import_core48 = require_dist16();
54345
+ var EmbedNode = import_core48.Node.create({
54346
54346
  name: "embed",
54347
54347
  addOptions() {
54348
54348
  return {};
@@ -54367,7 +54367,7 @@ var require_embed = __commonJS({
54367
54367
  ];
54368
54368
  },
54369
54369
  renderHTML({ HTMLAttributes }) {
54370
- return ["figure", { "data-type": this.name }, ["iframe", (0, import_core47.mergeAttributes)(HTMLAttributes)]];
54370
+ return ["figure", { "data-type": this.name }, ["iframe", (0, import_core48.mergeAttributes)(HTMLAttributes)]];
54371
54371
  }
54372
54372
  });
54373
54373
  }
@@ -54441,7 +54441,7 @@ var require_noteBase = __commonJS({
54441
54441
  name: () => name
54442
54442
  });
54443
54443
  module2.exports = __toCommonJS2(noteBase_exports);
54444
- var import_core47 = require_dist16();
54444
+ var import_core48 = require_dist16();
54445
54445
  var import_nodes = require_nodes();
54446
54446
  var name = "note";
54447
54447
  var NoteKind = /* @__PURE__ */ ((NoteKind2) => {
@@ -54456,7 +54456,7 @@ var require_noteBase = __commonJS({
54456
54456
  NoteKind2["PrimaryLight"] = "primary-light";
54457
54457
  return NoteKind2;
54458
54458
  })(NoteKind || {});
54459
- var NoteBaseExtension = import_core47.Mark.create({
54459
+ var NoteBaseExtension = import_core48.Mark.create({
54460
54460
  name,
54461
54461
  parseHTML() {
54462
54462
  return [
@@ -54513,9 +54513,9 @@ var require_qmsInlineCommentMark = __commonJS({
54513
54513
  QMSInlineCommentMark: () => QMSInlineCommentMark
54514
54514
  });
54515
54515
  module2.exports = __toCommonJS2(qmsInlineCommentMark_exports);
54516
- var import_core47 = require_dist16();
54516
+ var import_core48 = require_dist16();
54517
54517
  var NAME2 = "node-uuid";
54518
- var QMSInlineCommentMark = import_core47.Mark.create({
54518
+ var QMSInlineCommentMark = import_core48.Mark.create({
54519
54519
  name: NAME2,
54520
54520
  inline: true,
54521
54521
  parseHTML() {
@@ -54560,9 +54560,9 @@ var require_kit = __commonJS({
54560
54560
  mergeKitOptions: () => mergeKitOptions
54561
54561
  });
54562
54562
  module2.exports = __toCommonJS2(kit_exports);
54563
- var import_core47 = require_dist16();
54563
+ var import_core48 = require_dist16();
54564
54564
  function extensionKit(name, fn2) {
54565
- return import_core47.Extension.create({
54565
+ return import_core48.Extension.create({
54566
54566
  name,
54567
54567
  addExtensions() {
54568
54568
  const e = /* @__PURE__ */ __name((extension, options) => {
@@ -61591,9 +61591,9 @@ var require_colors = __commonJS({
61591
61591
  TextColor: () => TextColor
61592
61592
  });
61593
61593
  module2.exports = __toCommonJS2(colors_exports);
61594
- var import_core47 = require_dist16();
61594
+ var import_core48 = require_dist16();
61595
61595
  var import_extension_text_style = require_dist20();
61596
- var BackgroundColor = import_core47.Extension.create({
61596
+ var BackgroundColor = import_core48.Extension.create({
61597
61597
  name: "backgroundColor",
61598
61598
  addOptions() {
61599
61599
  return {
@@ -61634,7 +61634,7 @@ var require_colors = __commonJS({
61634
61634
  };
61635
61635
  }
61636
61636
  });
61637
- var TextColor = import_core47.Extension.create({
61637
+ var TextColor = import_core48.Extension.create({
61638
61638
  name: "textColor",
61639
61639
  addOptions() {
61640
61640
  return {
@@ -61706,10 +61706,10 @@ var require_inlineComment = __commonJS({
61706
61706
  InlineCommentPasteFixPlugin: () => InlineCommentPasteFixPlugin
61707
61707
  });
61708
61708
  module2.exports = __toCommonJS2(inlineComment_exports);
61709
- var import_core47 = require_dist16();
61709
+ var import_core48 = require_dist16();
61710
61710
  var import_model = require_dist10();
61711
61711
  var import_state = require_dist5();
61712
- var InlineCommentMark = import_core47.Mark.create({
61712
+ var InlineCommentMark = import_core48.Mark.create({
61713
61713
  name: "inline-comment",
61714
61714
  excludes: "",
61715
61715
  inclusive: false,
@@ -77233,7 +77233,7 @@ var require_client5 = __commonJS({
77233
77233
  createMarkupOperations: () => createMarkupOperations
77234
77234
  });
77235
77235
  module2.exports = __toCommonJS2(client_exports);
77236
- var import_core47 = require_lib4();
77236
+ var import_core48 = require_lib4();
77237
77237
  var import_collaborator_client2 = require_lib7();
77238
77238
  var import_text4 = require_lib9();
77239
77239
  var import_text_markdown3 = require_lib17();
@@ -77247,8 +77247,8 @@ var require_client5 = __commonJS({
77247
77247
  this.workspace = workspace;
77248
77248
  this.token = token;
77249
77249
  this.config = config3;
77250
- this.refUrl = (0, import_core47.concatLink)(this.url, `/browse?workspace=${workspace}`);
77251
- this.imageUrl = (0, import_core47.concatLink)(this.url, `/files?workspace=${workspace}&file=`);
77250
+ this.refUrl = (0, import_core48.concatLink)(this.url, `/browse?workspace=${workspace}`);
77251
+ this.imageUrl = (0, import_core48.concatLink)(this.url, `/files?workspace=${workspace}&file=`);
77252
77252
  this.collaborator = (0, import_collaborator_client2.getClient)(workspace, token, config3.COLLABORATOR_URL);
77253
77253
  }
77254
77254
  static {
@@ -77258,7 +77258,7 @@ var require_client5 = __commonJS({
77258
77258
  imageUrl;
77259
77259
  refUrl;
77260
77260
  async fetchMarkup(objectClass, objectId, objectAttr, doc, format7) {
77261
- const collabId = (0, import_core47.makeCollabId)(objectClass, objectId, objectAttr);
77261
+ const collabId = (0, import_core48.makeCollabId)(objectClass, objectId, objectAttr);
77262
77262
  const markup = await this.collaborator.getMarkup(collabId, doc);
77263
77263
  const json3 = (0, import_text4.markupToJSON)(markup);
77264
77264
  switch (format7) {
@@ -77287,7 +77287,7 @@ var require_client5 = __commonJS({
77287
77287
  default:
77288
77288
  throw new Error("Unknown content format");
77289
77289
  }
77290
- const collabId = (0, import_core47.makeCollabId)(objectClass, objectId, objectAttr);
77290
+ const collabId = (0, import_core48.makeCollabId)(objectClass, objectId, objectAttr);
77291
77291
  return await this.collaborator.createMarkup(collabId, markup);
77292
77292
  }
77293
77293
  };
@@ -81771,8 +81771,8 @@ var require_connection2 = __commonJS({
81771
81771
  });
81772
81772
  module2.exports = __toCommonJS2(connection_exports);
81773
81773
  var import_analytics = require_lib2();
81774
- var import_client24 = __toESM2(require_lib6());
81775
- var import_core47 = __toESM2(require_lib4());
81774
+ var import_client25 = __toESM2(require_lib6());
81775
+ var import_core48 = __toESM2(require_lib4());
81776
81776
  var import_platform2 = __toESM2(require_lib());
81777
81777
  var import_rpc = require_lib18();
81778
81778
  var import_snappyjs = require_snappyjs();
@@ -81816,7 +81816,7 @@ var require_connection2 = __commonJS({
81816
81816
  const sKey = "session.id." + this.url;
81817
81817
  let sessionId = sessionStorage.getItem(sKey) ?? void 0;
81818
81818
  if (sessionId === void 0) {
81819
- sessionId = (0, import_core47.generateId)();
81819
+ sessionId = (0, import_core48.generateId)();
81820
81820
  console.log("Generate new SessionId", sessionId);
81821
81821
  this.sessionId = sessionId;
81822
81822
  } else {
@@ -81827,7 +81827,7 @@ var require_connection2 = __commonJS({
81827
81827
  sessionStorage.setItem(sKey, sessionId);
81828
81828
  });
81829
81829
  } else {
81830
- this.sessionId = (0, import_core47.generateId)();
81830
+ this.sessionId = (0, import_core48.generateId)();
81831
81831
  }
81832
81832
  this.rpcHandler = opt?.useGlobalRPCHandler === true ? globalRPCHandler : new import_rpc.RPCHandler();
81833
81833
  this.pushHandler(handler);
@@ -81882,7 +81882,7 @@ var require_connection2 = __commonJS({
81882
81882
  }
81883
81883
  if (!this.closed) {
81884
81884
  void this.sendRequest({
81885
- method: import_client24.pingConst,
81885
+ method: import_client25.pingConst,
81886
81886
  params: [],
81887
81887
  once: true,
81888
81888
  handleResult: /* @__PURE__ */ __name(async (result) => {
@@ -81915,7 +81915,7 @@ var require_connection2 = __commonJS({
81915
81915
  }
81916
81916
  }
81917
81917
  isConnected() {
81918
- return this.websocket != null && this.websocket.readyState === import_client24.ClientSocketReadyState.OPEN && this.helloReceived;
81918
+ return this.websocket != null && this.websocket.readyState === import_client25.ClientSocketReadyState.OPEN && this.helloReceived;
81919
81919
  }
81920
81920
  delay = 0;
81921
81921
  onConnectHandlers = [];
@@ -82007,7 +82007,7 @@ var require_connection2 = __commonJS({
82007
82007
  if (resp.id === -1) {
82008
82008
  this.delay = 0;
82009
82009
  if (resp.result?.state === "upgrading") {
82010
- void this.onConnect?.(import_core47.ClientConnectEvent.Maintenance, void 0, resp.result.stats);
82010
+ void this.onConnect?.(import_core48.ClientConnectEvent.Maintenance, void 0, resp.result.stats);
82011
82011
  this.upgrading = true;
82012
82012
  this.delay = 3;
82013
82013
  return;
@@ -82042,7 +82042,7 @@ var require_connection2 = __commonJS({
82042
82042
  v.reconnect?.();
82043
82043
  }
82044
82044
  void this.onConnect?.(
82045
- helloResp.reconnect === true ? import_core47.ClientConnectEvent.Reconnected : import_core47.ClientConnectEvent.Connected,
82045
+ helloResp.reconnect === true ? import_core48.ClientConnectEvent.Reconnected : import_core48.ClientConnectEvent.Connected,
82046
82046
  helloResp.lastTx,
82047
82047
  this.sessionId
82048
82048
  )?.catch((err) => {
@@ -82055,8 +82055,8 @@ var require_connection2 = __commonJS({
82055
82055
  }
82056
82056
  return;
82057
82057
  }
82058
- if (resp.result === import_client24.pingConst) {
82059
- void this.sendRequest({ method: import_client24.pingConst, params: [] }).catch((err) => {
82058
+ if (resp.result === import_client25.pingConst) {
82059
+ void this.sendRequest({ method: import_client25.pingConst, params: [] }).catch((err) => {
82060
82060
  this.ctx.error("failed to send ping", { err });
82061
82061
  });
82062
82062
  return;
@@ -82092,7 +82092,7 @@ var require_connection2 = __commonJS({
82092
82092
  }
82093
82093
  result = result.concat(c.data);
82094
82094
  }
82095
- resp.result = (0, import_core47.toFindResult)(result, total, lookupMap);
82095
+ resp.result = (0, import_core48.toFindResult)(result, total, lookupMap);
82096
82096
  resp.chunk = void 0;
82097
82097
  } else {
82098
82098
  return;
@@ -82136,7 +82136,7 @@ var require_connection2 = __commonJS({
82136
82136
  } else {
82137
82137
  const txArr = Array.isArray(resp.result) ? resp.result : [resp.result];
82138
82138
  for (const tx of txArr) {
82139
- if (tx?._class === import_core47.default.class.TxModelUpgrade) {
82139
+ if (tx?._class === import_core48.default.class.TxModelUpgrade) {
82140
82140
  console.log("Processing upgrade", this.workspace, this.user);
82141
82141
  this.opt?.onUpgrade?.();
82142
82142
  return;
@@ -82148,15 +82148,15 @@ var require_connection2 = __commonJS({
82148
82148
  }
82149
82149
  }
82150
82150
  checkArrayBufferPing(data) {
82151
- if (data.byteLength === import_client24.pingConst.length || data.byteLength === import_client24.pongConst.length) {
82151
+ if (data.byteLength === import_client25.pingConst.length || data.byteLength === import_client25.pongConst.length) {
82152
82152
  const text = new TextDecoder().decode(data);
82153
- if (text === import_client24.pingConst) {
82154
- void this.sendRequest({ method: import_client24.pingConst, params: [] }).catch((err) => {
82153
+ if (text === import_client25.pingConst) {
82154
+ void this.sendRequest({ method: import_client25.pingConst, params: [] }).catch((err) => {
82155
82155
  this.ctx.error("failed to send ping", { err });
82156
82156
  });
82157
82157
  return true;
82158
82158
  }
82159
- if (text === import_client24.pongConst) {
82159
+ if (text === import_client25.pongConst) {
82160
82160
  this.pingResponse = Date.now();
82161
82161
  return true;
82162
82162
  }
@@ -82166,7 +82166,7 @@ var require_connection2 = __commonJS({
82166
82166
  openConnection(ctx, socketId) {
82167
82167
  this.binaryMode = false;
82168
82168
  this.helloReceived = false;
82169
- const clientSocketFactory = this.opt?.socketFactory ?? (0, import_platform2.getMetadata)(import_client24.default.metadata.ClientSocketFactory) ?? ((url4) => {
82169
+ const clientSocketFactory = this.opt?.socketFactory ?? (0, import_platform2.getMetadata)(import_client25.default.metadata.ClientSocketFactory) ?? ((url4) => {
82170
82170
  const s = new WebSocket(url4);
82171
82171
  return s;
82172
82172
  });
@@ -82201,12 +82201,12 @@ var require_connection2 = __commonJS({
82201
82201
  if (this.websocket !== wsocket) {
82202
82202
  return;
82203
82203
  }
82204
- if (event.data === import_client24.pongConst) {
82204
+ if (event.data === import_client25.pongConst) {
82205
82205
  this.pingResponse = Date.now();
82206
82206
  return;
82207
82207
  }
82208
- if (event.data === import_client24.pingConst) {
82209
- void this.sendRequest({ method: import_client24.pingConst, params: [] }).catch((err) => {
82208
+ if (event.data === import_client25.pingConst) {
82209
+ void this.sendRequest({ method: import_client25.pingConst, params: [] }).catch((err) => {
82210
82210
  this.ctx.error("failed to send ping", { err });
82211
82211
  });
82212
82212
  return;
@@ -82271,8 +82271,8 @@ var require_connection2 = __commonJS({
82271
82271
  if (this.websocket !== wsocket) {
82272
82272
  return;
82273
82273
  }
82274
- const useBinary = this.opt?.useBinaryProtocol ?? (0, import_platform2.getMetadata)(import_client24.default.metadata.UseBinaryProtocol) ?? true;
82275
- this.compressionMode = this.opt?.useProtocolCompression ?? (0, import_platform2.getMetadata)(import_client24.default.metadata.UseProtocolCompression) ?? false;
82274
+ const useBinary = this.opt?.useBinaryProtocol ?? (0, import_platform2.getMetadata)(import_client25.default.metadata.UseBinaryProtocol) ?? true;
82275
+ this.compressionMode = this.opt?.useProtocolCompression ?? (0, import_platform2.getMetadata)(import_client25.default.metadata.UseProtocolCompression) ?? false;
82276
82276
  const helloRequest = {
82277
82277
  method: "hello",
82278
82278
  params: [],
@@ -82318,13 +82318,13 @@ var require_connection2 = __commonJS({
82318
82318
  if (w instanceof Promise) {
82319
82319
  await w;
82320
82320
  }
82321
- if (data.method !== import_client24.pingConst) {
82321
+ if (data.method !== import_client25.pingConst) {
82322
82322
  this.requests.set(id, promise4);
82323
82323
  }
82324
82324
  promise4.sendData = () => {
82325
- if (this.websocket?.readyState === import_client24.ClientSocketReadyState.OPEN) {
82325
+ if (this.websocket?.readyState === import_client25.ClientSocketReadyState.OPEN) {
82326
82326
  promise4.startTime = Date.now();
82327
- if (data.method !== import_client24.pingConst) {
82327
+ if (data.method !== import_client25.pingConst) {
82328
82328
  const dta = this.rpcHandler.serialize(
82329
82329
  {
82330
82330
  method: data.method,
@@ -82337,7 +82337,7 @@ var require_connection2 = __commonJS({
82337
82337
  );
82338
82338
  this.websocket?.send(dta);
82339
82339
  } else {
82340
- this.websocket?.send(import_client24.pingConst);
82340
+ this.websocket?.send(import_client25.pingConst);
82341
82341
  }
82342
82342
  }
82343
82343
  };
@@ -82351,7 +82351,7 @@ var require_connection2 = __commonJS({
82351
82351
  };
82352
82352
  }
82353
82353
  promise4.sendData();
82354
- if (data.method !== import_client24.pingConst) {
82354
+ if (data.method !== import_client25.pingConst) {
82355
82355
  return await promise4.promise;
82356
82356
  }
82357
82357
  },
@@ -82366,7 +82366,7 @@ var require_connection2 = __commonJS({
82366
82366
  }
82367
82367
  getAccount() {
82368
82368
  if (this.account !== void 0) {
82369
- return Promise.resolve((0, import_core47.clone)(this.account));
82369
+ return Promise.resolve((0, import_core48.clone)(this.account));
82370
82370
  }
82371
82371
  return this.sendRequest({ method: "getAccount", params: [] });
82372
82372
  }
@@ -82424,10 +82424,10 @@ var require_connection2 = __commonJS({
82424
82424
  method: "tx",
82425
82425
  params: [tx],
82426
82426
  retry: /* @__PURE__ */ __name(async () => {
82427
- if (tx._class === import_core47.default.class.TxApplyIf) {
82428
- return (await this.findAll(import_core47.default.class.Tx, { _id: tx.txes[0]._id }, { limit: 1 })).length === 0;
82427
+ if (tx._class === import_core48.default.class.TxApplyIf) {
82428
+ return (await this.findAll(import_core48.default.class.Tx, { _id: tx.txes[0]._id }, { limit: 1 })).length === 0;
82429
82429
  }
82430
- return (await this.findAll(import_core47.default.class.Tx, { _id: tx._id }, { limit: 1 })).length === 0;
82430
+ return (await this.findAll(import_core48.default.class.Tx, { _id: tx._id }, { limit: 1 })).length === 0;
82431
82431
  }, "retry")
82432
82432
  });
82433
82433
  }
@@ -82467,7 +82467,7 @@ var require_connection2 = __commonJS({
82467
82467
  };
82468
82468
  function connect(url4, handler, workspace, user, opt) {
82469
82469
  return new Connection(
82470
- opt?.ctx?.newChild?.("connection", {}) ?? new import_core47.MeasureMetricsContext("connection", {}),
82470
+ opt?.ctx?.newChild?.("connection", {}) ?? new import_core48.MeasureMetricsContext("connection", {}),
82471
82471
  url4,
82472
82472
  handler,
82473
82473
  workspace,
@@ -82517,14 +82517,14 @@ var require_lib19 = __commonJS({
82517
82517
  default: () => index_default
82518
82518
  });
82519
82519
  module2.exports = __toCommonJS2(index_exports2);
82520
- var import_client24 = __toESM2(require_lib6());
82521
- var import_core47 = __toESM2(require_lib4());
82520
+ var import_client25 = __toESM2(require_lib6());
82521
+ var import_core48 = __toESM2(require_lib4());
82522
82522
  var import_platform2 = __toESM2(require_lib());
82523
82523
  var import_connection = require_connection2();
82524
82524
  var dbRequest;
82525
82525
  var dbPromise = Promise.resolve(void 0);
82526
82526
  if (typeof localStorage !== "undefined") {
82527
- const st = (0, import_core47.platformNow)();
82527
+ const st = (0, import_core48.platformNow)();
82528
82528
  dbPromise = new Promise((resolve2) => {
82529
82529
  dbRequest = indexedDB.open("model.db.persistence", 2);
82530
82530
  dbRequest.onupgradeneeded = function() {
@@ -82535,7 +82535,7 @@ var require_lib19 = __commonJS({
82535
82535
  };
82536
82536
  dbRequest.onsuccess = function() {
82537
82537
  const db = dbRequest.result;
82538
- console.log("init DB complete", (0, import_core47.platformNow)() - st);
82538
+ console.log("init DB complete", (0, import_core48.platformNow)() - st);
82539
82539
  resolve2(db);
82540
82540
  };
82541
82541
  });
@@ -82561,19 +82561,19 @@ var require_lib19 = __commonJS({
82561
82561
  return {
82562
82562
  function: {
82563
82563
  GetClient: /* @__PURE__ */ __name(async (token, endpoint, opt) => {
82564
- const filterModel = (0, import_platform2.getMetadata)(import_client24.default.metadata.FilterModel) ?? "none";
82565
- const extraFilter = (0, import_platform2.getMetadata)(import_client24.default.metadata.ExtraFilter) ?? [];
82564
+ const filterModel = (0, import_platform2.getMetadata)(import_client25.default.metadata.FilterModel) ?? "none";
82565
+ const extraFilter = (0, import_platform2.getMetadata)(import_client25.default.metadata.ExtraFilter) ?? [];
82566
82566
  const handler = /* @__PURE__ */ __name(async (handler2) => {
82567
- const url4 = (0, import_core47.concatLink)(endpoint, `/${token}`);
82567
+ const url4 = (0, import_core48.concatLink)(endpoint, `/${token}`);
82568
82568
  const upgradeHandler = /* @__PURE__ */ __name((...txes) => {
82569
82569
  for (const tx of txes) {
82570
- if (tx?._class === import_core47.default.class.TxModelUpgrade) {
82570
+ if (tx?._class === import_core48.default.class.TxModelUpgrade) {
82571
82571
  opt?.onUpgrade?.();
82572
82572
  return;
82573
82573
  }
82574
- if (tx?._class === import_core47.default.class.TxWorkspaceEvent) {
82574
+ if (tx?._class === import_core48.default.class.TxWorkspaceEvent) {
82575
82575
  const event = tx;
82576
- if (event.event === import_core47.WorkspaceEvent.MaintenanceNotification) {
82576
+ if (event.event === import_core48.WorkspaceEvent.MaintenanceNotification) {
82577
82577
  void (0, import_platform2.setPlatformStatus)(
82578
82578
  new import_platform2.Status(import_platform2.Severity.WARNING, import_platform2.default.status.MaintenanceWarning, {
82579
82579
  time: event.params.timeMinutes,
@@ -82590,7 +82590,7 @@ var require_lib19 = __commonJS({
82590
82590
  throw new Error("Workspace or account not found in token");
82591
82591
  }
82592
82592
  const newOpt = { ...opt };
82593
- const connectTimeout = opt?.connectionTimeout ?? (0, import_platform2.getMetadata)(import_client24.default.metadata.ConnectionTimeout);
82593
+ const connectTimeout = opt?.connectionTimeout ?? (0, import_platform2.getMetadata)(import_client25.default.metadata.ConnectionTimeout);
82594
82594
  let connectPromise;
82595
82595
  if ((connectTimeout ?? 0) > 0) {
82596
82596
  connectPromise = new Promise((resolve2, reject) => {
@@ -82611,7 +82611,7 @@ var require_lib19 = __commonJS({
82611
82611
  reject(error2);
82612
82612
  return;
82613
82613
  }
82614
- if (event !== import_core47.ClientConnectEvent.Maintenance) {
82614
+ if (event !== import_core48.ClientConnectEvent.Maintenance) {
82615
82615
  clearTimeout(connectTO);
82616
82616
  resolve2();
82617
82617
  }
@@ -82633,7 +82633,7 @@ var require_lib19 = __commonJS({
82633
82633
  }
82634
82634
  return txes;
82635
82635
  }, "modelFilter");
82636
- const client = (0, import_core47.createClient)(handler, modelFilter, createModelPersistence(getWSFromToken(token)), opt?.ctx);
82636
+ const client = (0, import_core48.createClient)(handler, modelFilter, createModelPersistence(getWSFromToken(token)), opt?.ctx);
82637
82637
  return await client;
82638
82638
  }, "GetClient")
82639
82639
  }
@@ -82641,17 +82641,17 @@ var require_lib19 = __commonJS({
82641
82641
  }, "default");
82642
82642
  function returnUITxes(txes, extraFilter) {
82643
82643
  const configs = /* @__PURE__ */ new Map();
82644
- (0, import_core47.fillConfiguration)(txes, configs);
82645
- const allowedPlugins = [...(0, import_platform2.getPlugins)(), ...(0, import_platform2.getMetadata)(import_client24.default.metadata.ExtraPlugins) ?? []];
82644
+ (0, import_core48.fillConfiguration)(txes, configs);
82645
+ const allowedPlugins = [...(0, import_platform2.getPlugins)(), ...(0, import_platform2.getMetadata)(import_client25.default.metadata.ExtraPlugins) ?? []];
82646
82646
  const excludedPlugins = Array.from(configs.values()).filter(
82647
82647
  (it) => !it.enabled || !allowedPlugins.includes(it.pluginId) || extraFilter.includes(it.pluginId)
82648
82648
  );
82649
- return (0, import_core47.pluginFilterTx)(excludedPlugins, configs, txes);
82649
+ return (0, import_core48.pluginFilterTx)(excludedPlugins, configs, txes);
82650
82650
  }
82651
82651
  __name(returnUITxes, "returnUITxes");
82652
82652
  function returnClientTxes(txes) {
82653
82653
  const configs = /* @__PURE__ */ new Map();
82654
- (0, import_core47.fillConfiguration)(txes, configs);
82654
+ (0, import_core48.fillConfiguration)(txes, configs);
82655
82655
  const excludedPlugins = Array.from(configs.values()).filter((it) => !it.enabled || it.pluginId.startsWith("server-"));
82656
82656
  const toExclude = /* @__PURE__ */ new Set([
82657
82657
  "workbench:class:Application",
@@ -82677,8 +82677,8 @@ var require_lib19 = __commonJS({
82677
82677
  "setting:class:WorkspaceSettingCategory",
82678
82678
  "notification:class:NotificationProvider"
82679
82679
  ]);
82680
- const result = (0, import_core47.pluginFilterTx)(excludedPlugins, configs, txes).filter((tx) => {
82681
- if (tx?._class === import_core47.default.class.TxCreateDoc || tx?._class === import_core47.default.class.TxUpdateDoc || tx?._class === import_core47.default.class.TxRemoveDoc) {
82680
+ const result = (0, import_core48.pluginFilterTx)(excludedPlugins, configs, txes).filter((tx) => {
82681
+ if (tx?._class === import_core48.default.class.TxCreateDoc || tx?._class === import_core48.default.class.TxUpdateDoc || tx?._class === import_core48.default.class.TxRemoveDoc) {
82682
82682
  const cud = tx;
82683
82683
  if (toExclude.has(cud.objectClass)) {
82684
82684
  return false;
@@ -82690,7 +82690,7 @@ var require_lib19 = __commonJS({
82690
82690
  }
82691
82691
  __name(returnClientTxes, "returnClientTxes");
82692
82692
  function createModelPersistence(workspace) {
82693
- const overrideStore = (0, import_platform2.getMetadata)(import_client24.default.metadata.OverridePersistenceStore);
82693
+ const overrideStore = (0, import_platform2.getMetadata)(import_client25.default.metadata.OverridePersistenceStore);
82694
82694
  if (overrideStore !== void 0) {
82695
82695
  return overrideStore;
82696
82696
  }
@@ -82787,11 +82787,11 @@ var require_client6 = __commonJS({
82787
82787
  });
82788
82788
  module2.exports = __toCommonJS2(client_exports);
82789
82789
  var import_account_client2 = require_lib5();
82790
- var import_client24 = __toESM2(require_lib6());
82791
- var import_core47 = require_lib4();
82790
+ var import_client25 = __toESM2(require_lib6());
82791
+ var import_core48 = require_lib4();
82792
82792
  var import_platform2 = require_lib();
82793
82793
  var import_config8 = require_config();
82794
- var import_markup8 = require_markup();
82794
+ var import_markup9 = require_markup();
82795
82795
  var import_utils14 = require_utils9();
82796
82796
  async function connect(url4, options) {
82797
82797
  const config3 = await (0, import_config8.loadServerConfig)(url4);
@@ -82805,7 +82805,7 @@ var require_client6 = __commonJS({
82805
82805
  const account = {
82806
82806
  uuid: wsLoginInfo.account,
82807
82807
  role: wsLoginInfo.role,
82808
- primarySocialId: (0, import_core47.pickPrimarySocialId)(socialIds)._id,
82808
+ primarySocialId: (0, import_core48.pickPrimarySocialId)(socialIds)._id,
82809
82809
  socialIds: socialIds.map((si) => si._id),
82810
82810
  fullSocialIds: socialIds
82811
82811
  };
@@ -82813,9 +82813,9 @@ var require_client6 = __commonJS({
82813
82813
  }
82814
82814
  __name(connect, "connect");
82815
82815
  async function createClient(url4, endpoint, token, workspaceUuid, account, config3, options) {
82816
- (0, import_platform2.addLocation)(import_client24.clientId, () => Promise.resolve().then(() => __toESM(require_lib19())));
82816
+ (0, import_platform2.addLocation)(import_client25.clientId, () => Promise.resolve().then(() => __toESM(require_lib19())));
82817
82817
  const { socketFactory, connectionTimeout } = options;
82818
- const clientFactory = await (0, import_platform2.getResource)(import_client24.default.function.GetClient);
82818
+ const clientFactory = await (0, import_platform2.getResource)(import_client25.default.function.GetClient);
82819
82819
  const connection = await clientFactory(token, endpoint, {
82820
82820
  socketFactory,
82821
82821
  connectionTimeout
@@ -82831,8 +82831,8 @@ var require_client6 = __commonJS({
82831
82831
  this.config = config3;
82832
82832
  this.connection = connection;
82833
82833
  this.account = account;
82834
- this.client = new import_core47.TxOperations(connection, account.primarySocialId);
82835
- this.markup = (0, import_markup8.createMarkupOperations)(url4, workspace, token, config3);
82834
+ this.client = new import_core48.TxOperations(connection, account.primarySocialId);
82835
+ this.markup = (0, import_markup9.createMarkupOperations)(url4, workspace, token, config3);
82836
82836
  }
82837
82837
  static {
82838
82838
  __name(this, "PlatformClientImpl");
@@ -82861,7 +82861,7 @@ var require_client6 = __commonJS({
82861
82861
  async processMarkup(_class, id, data) {
82862
82862
  const result = {};
82863
82863
  for (const [key, value3] of Object.entries(data)) {
82864
- if (value3 instanceof import_markup8.MarkupContent) {
82864
+ if (value3 instanceof import_markup9.MarkupContent) {
82865
82865
  result[key] = this.markup.uploadMarkup(_class, id, key, value3.content, value3.kind);
82866
82866
  } else {
82867
82867
  result[key] = value3;
@@ -82871,7 +82871,7 @@ var require_client6 = __commonJS({
82871
82871
  }
82872
82872
  // DocOperations
82873
82873
  async createDoc(_class, space, attributes, id) {
82874
- id ??= (0, import_core47.generateId)();
82874
+ id ??= (0, import_core48.generateId)();
82875
82875
  const data = await this.processMarkup(_class, id, attributes);
82876
82876
  return await this.client.createDoc(_class, space, data, id);
82877
82877
  }
@@ -82884,7 +82884,7 @@ var require_client6 = __commonJS({
82884
82884
  }
82885
82885
  // CollectionOperations
82886
82886
  async addCollection(_class, space, attachedTo, attachedToClass, collection, attributes, id) {
82887
- id ??= (0, import_core47.generateId)();
82887
+ id ??= (0, import_core48.generateId)();
82888
82888
  const data = await this.processMarkup(_class, id, attributes);
82889
82889
  return await this.client.addCollection(_class, space, attachedTo, attachedToClass, collection, data, id);
82890
82890
  }
@@ -83211,7 +83211,7 @@ var require_rest = __commonJS({
83211
83211
  createRestClient: () => createRestClient2
83212
83212
  });
83213
83213
  module2.exports = __toCommonJS2(rest_exports);
83214
- var import_core47 = require_lib4();
83214
+ var import_core48 = require_lib4();
83215
83215
  var import_platform2 = require_lib();
83216
83216
  var import_utils14 = require_utils9();
83217
83217
  var import_utils22 = require_utils10();
@@ -83266,7 +83266,7 @@ var require_rest = __commonJS({
83266
83266
  if (options !== void 0 && Object.keys(options).length > 0) {
83267
83267
  params.append("options", JSON.stringify(options));
83268
83268
  }
83269
- const requestUrl = (0, import_core47.concatLink)(this.endpoint, `/api/v1/find-all/${this.workspace}?${params.toString()}`);
83269
+ const requestUrl = (0, import_core48.concatLink)(this.endpoint, `/api/v1/find-all/${this.workspace}?${params.toString()}`);
83270
83270
  const result = await (0, import_utils22.withRetry)(async () => {
83271
83271
  const response = await fetch(requestUrl, this.requestInit());
83272
83272
  if (!response.ok) {
@@ -83340,7 +83340,7 @@ var require_rest = __commonJS({
83340
83340
  }
83341
83341
  }
83342
83342
  async getAccount() {
83343
- const requestUrl = (0, import_core47.concatLink)(this.endpoint, `/api/v1/account/${this.workspace}`);
83343
+ const requestUrl = (0, import_core48.concatLink)(this.endpoint, `/api/v1/account/${this.workspace}`);
83344
83344
  await this.checkRate();
83345
83345
  const result = await (0, import_utils22.withRetry)(async () => {
83346
83346
  const response = await fetch(requestUrl, this.requestInit());
@@ -83357,7 +83357,7 @@ var require_rest = __commonJS({
83357
83357
  return result;
83358
83358
  }
83359
83359
  async getModel(full = false) {
83360
- const requestUrl = new URL((0, import_core47.concatLink)(this.endpoint, `/api/v1/load-model/${this.workspace}`));
83360
+ const requestUrl = new URL((0, import_core48.concatLink)(this.endpoint, `/api/v1/load-model/${this.workspace}`));
83361
83361
  if (full) {
83362
83362
  requestUrl.searchParams.append("full", "true");
83363
83363
  }
@@ -83370,10 +83370,10 @@ var require_rest = __commonJS({
83370
83370
  }
83371
83371
  this.updateRateLimit(response);
83372
83372
  const modelResponse = await (0, import_utils22.extractJson)(response);
83373
- const hierarchy = new import_core47.Hierarchy();
83374
- const model = new import_core47.ModelDb(hierarchy);
83375
- const ctx = new import_core47.MeasureMetricsContext("loadModel", {});
83376
- (0, import_core47.buildModel)(ctx, modelResponse, void 0, hierarchy, model);
83373
+ const hierarchy = new import_core48.Hierarchy();
83374
+ const model = new import_core48.ModelDb(hierarchy);
83375
+ const ctx = new import_core48.MeasureMetricsContext("loadModel", {});
83376
+ (0, import_core48.buildModel)(ctx, modelResponse, void 0, hierarchy, model);
83377
83377
  return { hierarchy, model };
83378
83378
  }, isRLE);
83379
83379
  if (result.error !== void 0) {
@@ -83385,7 +83385,7 @@ var require_rest = __commonJS({
83385
83385
  return (await this.findAll(_class, query, { ...options, limit: 1 })).shift();
83386
83386
  }
83387
83387
  async tx(tx) {
83388
- const requestUrl = (0, import_core47.concatLink)(this.endpoint, `/api/v1/tx/${this.workspace}`);
83388
+ const requestUrl = (0, import_core48.concatLink)(this.endpoint, `/api/v1/tx/${this.workspace}`);
83389
83389
  await this.checkRate();
83390
83390
  const result = await (0, import_utils22.withRetry)(async () => {
83391
83391
  const response = await fetch(requestUrl, {
@@ -83419,7 +83419,7 @@ var require_rest = __commonJS({
83419
83419
  if (options.limit != null) {
83420
83420
  params.append("limit", `${options.limit}`);
83421
83421
  }
83422
- const requestUrl = (0, import_core47.concatLink)(this.endpoint, `/api/v1/search-fulltext/${this.workspace}?${params.toString()}`);
83422
+ const requestUrl = (0, import_core48.concatLink)(this.endpoint, `/api/v1/search-fulltext/${this.workspace}?${params.toString()}`);
83423
83423
  const response = await fetch(requestUrl, {
83424
83424
  method: "GET",
83425
83425
  headers: this.jsonHeaders(),
@@ -83438,7 +83438,7 @@ var require_rest = __commonJS({
83438
83438
  return result;
83439
83439
  }
83440
83440
  async domainRequest(domain3, params, options) {
83441
- const requestUrl = (0, import_core47.concatLink)(this.endpoint, `/api/v1/request/${domain3}/${this.workspace}`);
83441
+ const requestUrl = (0, import_core48.concatLink)(this.endpoint, `/api/v1/request/${domain3}/${this.workspace}`);
83442
83442
  await this.checkRate();
83443
83443
  return await (0, import_utils22.withRetry)(async () => {
83444
83444
  const response = await fetch(requestUrl, {
@@ -83457,7 +83457,7 @@ var require_rest = __commonJS({
83457
83457
  }, isRLE);
83458
83458
  }
83459
83459
  async ensurePerson(socialType, socialValue, firstName, lastName) {
83460
- const requestUrl = (0, import_core47.concatLink)(this.endpoint, `/api/v1/ensure-person/${this.workspace}`);
83460
+ const requestUrl = (0, import_core48.concatLink)(this.endpoint, `/api/v1/ensure-person/${this.workspace}`);
83461
83461
  await this.checkRate();
83462
83462
  const result = await (0, import_utils22.withRetry)(async () => {
83463
83463
  const response = await fetch(requestUrl, {
@@ -83514,13 +83514,13 @@ var require_tx2 = __commonJS({
83514
83514
  createRestTxOperations: () => createRestTxOperations2
83515
83515
  });
83516
83516
  module2.exports = __toCommonJS2(tx_exports);
83517
- var import_core47 = require_lib4();
83517
+ var import_core48 = require_lib4();
83518
83518
  var import_rest = require_rest();
83519
83519
  async function createRestTxOperations2(endpoint, workspaceId, token, fullModel = false) {
83520
83520
  const restClient = new import_rest.RestClientImpl(endpoint, workspaceId, token);
83521
83521
  const account = await restClient.getAccount();
83522
83522
  const { hierarchy, model } = await restClient.getModel(fullModel);
83523
- return new import_core47.TxOperations(new RestTxClient(restClient, hierarchy, model, account), account.socialIds[0]);
83523
+ return new import_core48.TxOperations(new RestTxClient(restClient, hierarchy, model, account), account.socialIds[0]);
83524
83524
  }
83525
83525
  __name(createRestTxOperations2, "createRestTxOperations");
83526
83526
  var RestTxClient = class {
@@ -83541,7 +83541,7 @@ var require_tx2 = __commonJS({
83541
83541
  const result = data.map((v) => {
83542
83542
  return this.hierarchy.updateLookupMixin(_class, v, options);
83543
83543
  });
83544
- return (0, import_core47.toFindResult)(result, data.total);
83544
+ return (0, import_core48.toFindResult)(result, data.total);
83545
83545
  }
83546
83546
  async domainRequest(domain3, params, options) {
83547
83547
  return await this.client.domainRequest(domain3, params, options);
@@ -83723,7 +83723,7 @@ var require_client7 = __commonJS({
83723
83723
  createStorageClient: () => createStorageClient2
83724
83724
  });
83725
83725
  module2.exports = __toCommonJS2(client_exports);
83726
- var import_core47 = __toESM2(require_lib4());
83726
+ var import_core48 = __toESM2(require_lib4());
83727
83727
  var import_stream2 = require("stream");
83728
83728
  var import_config8 = require_config();
83729
83729
  var import_error = require_error3();
@@ -83760,13 +83760,13 @@ var require_client7 = __commonJS({
83760
83760
  const size13 = parseInt(headers.get("Content-Length") ?? "0", 10);
83761
83761
  return {
83762
83762
  provider: "",
83763
- _class: import_core47.default.class.Blob,
83763
+ _class: import_core48.default.class.Blob,
83764
83764
  _id: objectName,
83765
83765
  contentType: headers.get("Content-Type") ?? "",
83766
83766
  size: isNaN(size13) ? 0 : size13 ?? 0,
83767
83767
  etag: headers.get("ETag") ?? "",
83768
- space: import_core47.default.space.Configuration,
83769
- modifiedBy: import_core47.default.account.System,
83768
+ space: import_core48.default.space.Configuration,
83769
+ modifiedBy: import_core48.default.account.System,
83770
83770
  modifiedOn: isNaN(lastModified) ? 0 : lastModified,
83771
83771
  version: null
83772
83772
  };
@@ -83801,11 +83801,11 @@ var require_client7 = __commonJS({
83801
83801
  if (Object.hasOwn(result[0], "id")) {
83802
83802
  const fileResult = result[0];
83803
83803
  return {
83804
- _class: import_core47.default.class.Blob,
83804
+ _class: import_core48.default.class.Blob,
83805
83805
  _id: fileResult.id,
83806
- space: import_core47.default.space.Configuration,
83806
+ space: import_core48.default.space.Configuration,
83807
83807
  modifiedOn: fileResult.metadata.lastModified,
83808
- modifiedBy: import_core47.default.account.System,
83808
+ modifiedBy: import_core48.default.account.System,
83809
83809
  provider: "",
83810
83810
  contentType: fileResult.metadata.contentType,
83811
83811
  etag: fileResult.metadata.etag,
@@ -83879,11 +83879,11 @@ var require_client7 = __commonJS({
83879
83879
  async function connectStorage(url4, options, config3) {
83880
83880
  config3 ??= await (0, import_config8.loadServerConfig)(url4);
83881
83881
  const token = await (0, import_utils14.getWorkspaceToken)(url4, options, config3);
83882
- const filesUrl = (config3.FILES_URL.startsWith("/") ? (0, import_core47.concatLink)(url4, config3.FILES_URL) : config3.FILES_URL).replace(
83882
+ const filesUrl = (config3.FILES_URL.startsWith("/") ? (0, import_core48.concatLink)(url4, config3.FILES_URL) : config3.FILES_URL).replace(
83883
83883
  ":workspace",
83884
83884
  token.workspaceId
83885
83885
  );
83886
- const uploadUrl = (config3.UPLOAD_URL.startsWith("/") ? (0, import_core47.concatLink)(url4, config3.UPLOAD_URL) : config3.UPLOAD_URL).replace(":workspace", token.workspaceId);
83886
+ const uploadUrl = (config3.UPLOAD_URL.startsWith("/") ? (0, import_core48.concatLink)(url4, config3.UPLOAD_URL) : config3.UPLOAD_URL).replace(":workspace", token.workspaceId);
83887
83887
  return new StorageClientImpl(filesUrl, uploadUrl, token.token, token.workspaceId);
83888
83888
  }
83889
83889
  __name(connectStorage, "connectStorage");
@@ -83936,11 +83936,11 @@ var require_storage2 = __commonJS({
83936
83936
  var __toCommonJS2 = (mod) => __copyProps2(__defProp2({}, "__esModule", { value: true }), mod);
83937
83937
  var storage_exports = {};
83938
83938
  __export2(storage_exports, {
83939
- connectStorage: () => import_client24.connectStorage,
83940
- createStorageClient: () => import_client24.createStorageClient
83939
+ connectStorage: () => import_client25.connectStorage,
83940
+ createStorageClient: () => import_client25.createStorageClient
83941
83941
  });
83942
83942
  module2.exports = __toCommonJS2(storage_exports);
83943
- var import_client24 = require_client7();
83943
+ var import_client25 = require_client7();
83944
83944
  __reExport2(storage_exports, require_error3(), module2.exports);
83945
83945
  __reExport2(storage_exports, require_types8(), module2.exports);
83946
83946
  }
@@ -84596,7 +84596,7 @@ var require_utils11 = __commonJS({
84596
84596
  getWeekday: () => getWeekday
84597
84597
  });
84598
84598
  module2.exports = __toCommonJS2(utils_exports);
84599
- var import_core47 = require_lib4();
84599
+ var import_core48 = require_lib4();
84600
84600
  var import__ = __toESM2(require_lib24());
84601
84601
  function getInstance(event, date7) {
84602
84602
  const diff8 = event.dueDate - event.date;
@@ -84608,7 +84608,7 @@ var require_utils11 = __commonJS({
84608
84608
  originalStartTime: date7,
84609
84609
  _class: import__.default.class.ReccuringInstance,
84610
84610
  eventId: generateEventId3(),
84611
- _id: (0, import_core47.generateId)(),
84611
+ _id: (0, import_core48.generateId)(),
84612
84612
  virtual: true
84613
84613
  };
84614
84614
  }
@@ -84921,7 +84921,7 @@ var require_utils11 = __commonJS({
84921
84921
  }
84922
84922
  __name(getAllEvents, "getAllEvents");
84923
84923
  function generateEventId3() {
84924
- const id = (0, import_core47.generateId)();
84924
+ const id = (0, import_core48.generateId)();
84925
84925
  return encodeToBase32Hex(id);
84926
84926
  }
84927
84927
  __name(generateEventId3, "generateEventId");
@@ -85335,7 +85335,7 @@ var require_utils12 = __commonJS({
85335
85335
  });
85336
85336
  module2.exports = __toCommonJS2(utils_exports);
85337
85337
  var import_fast_equals = require_cjs();
85338
- var import_core47 = __toESM2(require_lib4());
85338
+ var import_core48 = __toESM2(require_lib4());
85339
85339
  var import__ = __toESM2(require_lib26());
85340
85340
  async function getDirectChannel(client, me, employeeAccount) {
85341
85341
  const accIds = [me, employeeAccount].sort();
@@ -85345,7 +85345,7 @@ var require_utils12 = __commonJS({
85345
85345
  return dm._id;
85346
85346
  }
85347
85347
  }
85348
- return await client.createDoc(import__.default.class.DirectMessage, import_core47.default.space.Space, {
85348
+ return await client.createDoc(import__.default.class.DirectMessage, import_core48.default.space.Space, {
85349
85349
  name: "",
85350
85350
  description: "",
85351
85351
  private: true,
@@ -85649,18 +85649,18 @@ var require_cache4 = __commonJS({
85649
85649
  default: () => ContactCache
85650
85650
  });
85651
85651
  module2.exports = __toCommonJS2(cache_exports);
85652
- var import_core47 = __toESM2(require_lib4());
85652
+ var import_core48 = __toESM2(require_lib4());
85653
85653
  var import__ = __toESM2(require_lib27());
85654
85654
  function isCreateTx(tx) {
85655
- return tx._class === import_core47.default.class.TxCreateDoc;
85655
+ return tx._class === import_core48.default.class.TxCreateDoc;
85656
85656
  }
85657
85657
  __name(isCreateTx, "isCreateTx");
85658
85658
  function isUpdateTx(tx) {
85659
- return tx._class === import_core47.default.class.TxUpdateDoc;
85659
+ return tx._class === import_core48.default.class.TxUpdateDoc;
85660
85660
  }
85661
85661
  __name(isUpdateTx, "isUpdateTx");
85662
85662
  function isMixinTx(tx) {
85663
- return tx._class === import_core47.default.class.TxMixin;
85663
+ return tx._class === import_core48.default.class.TxMixin;
85664
85664
  }
85665
85665
  __name(isMixinTx, "isMixinTx");
85666
85666
  function isPersonTx(tx) {
@@ -85767,7 +85767,7 @@ var require_cache4 = __commonJS({
85767
85767
  const ref = tx.objectId;
85768
85768
  const person = this._personByRef.get(ref);
85769
85769
  if (person === void 0) return;
85770
- const createdPerson = import_core47.TxProcessor.createDoc2Doc(tx);
85770
+ const createdPerson = import_core48.TxProcessor.createDoc2Doc(tx);
85771
85771
  this._personByRef.set(ref, createdPerson);
85772
85772
  const personIds = Array.from(this._personIdsByPersonRef.get(ref) ?? []);
85773
85773
  for (const personId of personIds) {
@@ -85785,7 +85785,7 @@ var require_cache4 = __commonJS({
85785
85785
  const newPersonRef = tx.attachedTo;
85786
85786
  this._personRefByPersonId.set(personId, newPersonRef);
85787
85787
  this.addPersonIdToPersonRef(newPersonRef, personId);
85788
- const createdSocialId = import_core47.TxProcessor.createDoc2Doc(tx);
85788
+ const createdSocialId = import_core48.TxProcessor.createDoc2Doc(tx);
85789
85789
  this._socialIdByPersonId.set(personId, createdSocialId);
85790
85790
  this.broadcastChange({
85791
85791
  personRef: newPersonRef,
@@ -85796,7 +85796,7 @@ var require_cache4 = __commonJS({
85796
85796
  const ref = tx.objectId;
85797
85797
  const person = this._personByRef.get(ref);
85798
85798
  if (person == null) return;
85799
- const updatedPerson = isUpdateTx(tx) ? import_core47.TxProcessor.updateDoc2Doc(person, tx) : import_core47.TxProcessor.updateMixin4Doc(person, tx);
85799
+ const updatedPerson = isUpdateTx(tx) ? import_core48.TxProcessor.updateDoc2Doc(person, tx) : import_core48.TxProcessor.updateMixin4Doc(person, tx);
85800
85800
  this._personByRef.set(ref, updatedPerson);
85801
85801
  const personIds = Array.from(this._personIdsByPersonRef.get(ref) ?? []);
85802
85802
  for (const personId of personIds) {
@@ -85911,7 +85911,7 @@ var require_utils13 = __commonJS({
85911
85911
  setCurrentEmployeeSpace: () => setCurrentEmployeeSpace
85912
85912
  });
85913
85913
  module2.exports = __toCommonJS2(utils_exports);
85914
- var import_core47 = require_lib4();
85914
+ var import_core48 = require_lib4();
85915
85915
  var import_platform2 = require_lib();
85916
85916
  var import__ = __toESM2(require_lib27());
85917
85917
  var import_types12 = require_types9();
@@ -86115,7 +86115,7 @@ var require_utils13 = __commonJS({
86115
86115
  if (socialIds.length === 0) {
86116
86116
  return;
86117
86117
  }
86118
- return (0, import_core47.pickPrimarySocialId)(socialIds)._id;
86118
+ return (0, import_core48.pickPrimarySocialId)(socialIds)._id;
86119
86119
  }
86120
86120
  __name(getPrimarySocialId, "getPrimarySocialId");
86121
86121
  async function getAllSocialStringsByPersonId(client, personId) {
@@ -86154,12 +86154,12 @@ var require_utils13 = __commonJS({
86154
86154
  __name(getSocialStringsByEmployee, "getSocialStringsByEmployee");
86155
86155
  async function getAllAccounts(client) {
86156
86156
  const employees = await client.findAll(import__.default.mixin.Employee, { active: true });
86157
- return employees.map((it) => it.personUuid).filter(import_core47.notEmpty);
86157
+ return employees.map((it) => it.personUuid).filter(import_core48.notEmpty);
86158
86158
  }
86159
86159
  __name(getAllAccounts, "getAllAccounts");
86160
86160
  async function getAllUserAccounts(client) {
86161
86161
  const employees = await client.findAll(import__.default.mixin.Employee, { active: true });
86162
- return employees.map((it) => it.personUuid).filter(import_core47.notEmpty);
86162
+ return employees.map((it) => it.personUuid).filter(import_core48.notEmpty);
86163
86163
  }
86164
86164
  __name(getAllUserAccounts, "getAllUserAccounts");
86165
86165
  async function ensureEmployee(ctx, me, client, socialIds, getGlobalPerson) {
@@ -86168,7 +86168,7 @@ var require_utils13 = __commonJS({
86168
86168
  }
86169
86169
  __name(ensureEmployee, "ensureEmployee");
86170
86170
  async function ensureEmployeeForPerson(ctx, me, person, client, socialIds, globalPerson) {
86171
- const txFactory = new import_core47.TxFactory(me.primarySocialId);
86171
+ const txFactory = new import_core48.TxFactory(me.primarySocialId);
86172
86172
  const personByUuid = await client.findOne(import__.default.class.Person, { personUuid: person.uuid });
86173
86173
  let personRef = personByUuid?._id;
86174
86174
  if (personRef === void 0) {
@@ -86189,7 +86189,7 @@ var require_utils13 = __commonJS({
86189
86189
  city: globalPerson.city,
86190
86190
  avatarType: import__.AvatarType.COLOR
86191
86191
  };
86192
- personRef = (0, import_core47.generateId)();
86192
+ personRef = (0, import_core48.generateId)();
86193
86193
  const createPersonTx = txFactory.createTxCreateDoc(import__.default.class.Person, import__.default.space.Contacts, data, personRef);
86194
86194
  await client.tx(createPersonTx);
86195
86195
  });
@@ -86199,7 +86199,7 @@ var require_utils13 = __commonJS({
86199
86199
  });
86200
86200
  await client.tx(updatePersonTx);
86201
86201
  }
86202
- const existingIdentifiers = (0, import_core47.toIdMap)(
86202
+ const existingIdentifiers = (0, import_core48.toIdMap)(
86203
86203
  await client.findAll(import__.default.class.SocialIdentity, { _id: { $in: person.socialIds } })
86204
86204
  );
86205
86205
  for (const socialId of socialIds) {
@@ -86224,7 +86224,7 @@ var require_utils13 = __commonJS({
86224
86224
  collection: "socialIds",
86225
86225
  type: socialId.type,
86226
86226
  value: socialId.value,
86227
- key: (0, import_core47.buildSocialIdString)(socialId),
86227
+ key: (0, import_core48.buildSocialIdString)(socialId),
86228
86228
  // TODO: fill it in trigger or on DB level as stored calculated column or smth?
86229
86229
  verifiedOn: socialId.verifiedOn,
86230
86230
  isDeleted: socialId.isDeleted
@@ -86265,9 +86265,9 @@ var require_utils13 = __commonJS({
86265
86265
  }
86266
86266
  }
86267
86267
  }
86268
- const employeeRole = person.role === import_core47.AccountRole.Guest || person.role === import_core47.AccountRole.ReadOnlyGuest ? "GUEST" : "USER";
86268
+ const employeeRole = person.role === import_core48.AccountRole.Guest || person.role === import_core48.AccountRole.ReadOnlyGuest ? "GUEST" : "USER";
86269
86269
  const employee = await client.findOne(import__.default.mixin.Employee, { _id: personRef });
86270
- if (employee === void 0 || !import_core47.Hierarchy.hasMixin(employee, import__.default.mixin.Employee) || !employee.active || employee.role !== employeeRole) {
86270
+ if (employee === void 0 || !import_core48.Hierarchy.hasMixin(employee, import__.default.mixin.Employee) || !employee.active || employee.role !== employeeRole) {
86271
86271
  await ctx.with("create-employee", {}, async () => {
86272
86272
  if (personRef === void 0) {
86273
86273
  console.error("Person not found");
@@ -86307,7 +86307,7 @@ var require_utils13 = __commonJS({
86307
86307
  }
86308
86308
  __name(loadCachesForPersonId, "loadCachesForPersonId");
86309
86309
  async function loadCachesForPersonIds(client, personIds) {
86310
- const sidObjsMap = (0, import_core47.toIdMap)(
86310
+ const sidObjsMap = (0, import_core48.toIdMap)(
86311
86311
  await client.findAll(
86312
86312
  import__.default.class.SocialIdentity,
86313
86313
  {
@@ -86342,7 +86342,7 @@ var require_utils13 = __commonJS({
86342
86342
  }
86343
86343
  __name(loadCachesForPersonRef, "loadCachesForPersonRef");
86344
86344
  async function loadCachesForPersonRefs(client, personRefs) {
86345
- const persons = (0, import_core47.toIdMap)(
86345
+ const persons = (0, import_core48.toIdMap)(
86346
86346
  await client.findAll(
86347
86347
  import__.default.class.Person,
86348
86348
  {
@@ -86385,7 +86385,7 @@ var require_utils13 = __commonJS({
86385
86385
  personIds.map((pid) => {
86386
86386
  const ref = contactCache.personRefByPersonId.get(pid);
86387
86387
  return ref != null ? [pid, ref] : void 0;
86388
- }).filter(import_core47.notEmpty)
86388
+ }).filter(import_core48.notEmpty)
86389
86389
  );
86390
86390
  }
86391
86391
  __name(getPersonRefsByPersonIdsFromCache, "getPersonRefsByPersonIdsFromCache");
@@ -86432,7 +86432,7 @@ var require_utils13 = __commonJS({
86432
86432
  personIds.map((pid) => {
86433
86433
  const person = contactCache.personByPersonId.get(pid);
86434
86434
  return person != null ? [pid, person] : void 0;
86435
- }).filter(import_core47.notEmpty)
86435
+ }).filter(import_core48.notEmpty)
86436
86436
  );
86437
86437
  }
86438
86438
  __name(getPersonsByPersonIdsFromCache, "getPersonsByPersonIdsFromCache");
@@ -86479,7 +86479,7 @@ var require_utils13 = __commonJS({
86479
86479
  personRefs.map((personRef) => {
86480
86480
  const person = contactCache.personByRef.get(personRef);
86481
86481
  return person != null ? [personRef, person] : void 0;
86482
- }).filter(import_core47.notEmpty)
86482
+ }).filter(import_core48.notEmpty)
86483
86483
  );
86484
86484
  }
86485
86485
  __name(getPersonsByPersonRefsFromCache, "getPersonsByPersonRefsFromCache");
@@ -87084,9 +87084,9 @@ var require_utils14 = __commonJS({
87084
87084
  getFirstRank: () => getFirstRank
87085
87085
  });
87086
87086
  module2.exports = __toCommonJS2(utils_exports);
87087
- var import_core47 = require_lib4();
87087
+ var import_core48 = require_lib4();
87088
87088
  var import_plugin = __toESM2(require_plugin2());
87089
- async function getFirstRank(client, space, parent, sort3 = import_core47.SortingOrder.Descending, extra = {}) {
87089
+ async function getFirstRank(client, space, parent, sort3 = import_core48.SortingOrder.Descending, extra = {}) {
87090
87090
  const doc = await client.findOne(
87091
87091
  import_plugin.default.class.Document,
87092
87092
  { space, parent, ...extra },
@@ -88709,7 +88709,7 @@ var require_utils16 = __commonJS({
88709
88709
  updateProjectType: () => updateProjectType
88710
88710
  });
88711
88711
  module2.exports = __toCommonJS2(utils_exports);
88712
- var import_core47 = __toESM2(require_lib4());
88712
+ var import_core48 = __toESM2(require_lib4());
88713
88713
  var import_platform2 = require_lib();
88714
88714
  var import__ = __toESM2(require_lib33());
88715
88715
  var import_rank4 = require_lib32();
@@ -88745,7 +88745,7 @@ var require_utils16 = __commonJS({
88745
88745
  if (exists5 !== void 0) {
88746
88746
  return exists5._id;
88747
88747
  }
88748
- const res = await client.createDoc(_class, import_core47.default.space.Model, data);
88748
+ const res = await client.createDoc(_class, import_core48.default.space.Model, data);
88749
88749
  return res;
88750
88750
  }
88751
88751
  __name(createState, "createState");
@@ -88775,7 +88775,7 @@ var require_utils16 = __commonJS({
88775
88775
  function findStatusAttr(h, _class) {
88776
88776
  const attrs = h.getAllAttributes(_class);
88777
88777
  for (const it of attrs.values()) {
88778
- if (it.type._class === import_core47.default.class.RefTo && h.isDerived(it.type.to, import_core47.default.class.Status)) {
88778
+ if (it.type._class === import_core48.default.class.RefTo && h.isDerived(it.type.to, import_core48.default.class.Status)) {
88779
88779
  return it;
88780
88780
  }
88781
88781
  }
@@ -88807,7 +88807,7 @@ var require_utils16 = __commonJS({
88807
88807
  const targetProjectClassId = `${_id}:type:mixin`;
88808
88808
  const tmpl = await client.createDoc(
88809
88809
  import__.default.class.ProjectType,
88810
- import_core47.default.space.Model,
88810
+ import_core48.default.space.Model,
88811
88811
  {
88812
88812
  description: data.description,
88813
88813
  shortDescription: data.shortDescription,
@@ -88822,17 +88822,17 @@ var require_utils16 = __commonJS({
88822
88822
  _id
88823
88823
  );
88824
88824
  await client.createDoc(
88825
- import_core47.default.class.Mixin,
88826
- import_core47.default.space.Model,
88825
+ import_core48.default.class.Mixin,
88826
+ import_core48.default.space.Model,
88827
88827
  {
88828
88828
  extends: categoryObj.baseClass,
88829
- kind: import_core47.ClassifierKind.MIXIN,
88829
+ kind: import_core48.ClassifierKind.MIXIN,
88830
88830
  label: (0, import_platform2.getEmbeddedLabel)(data.name),
88831
88831
  icon: baseClassClass.icon
88832
88832
  },
88833
88833
  targetProjectClassId
88834
88834
  );
88835
- await client.createMixin(targetProjectClassId, import_core47.default.class.Mixin, import_core47.default.space.Model, import__.default.mixin.ProjectTypeClass, {
88835
+ await client.createMixin(targetProjectClassId, import_core48.default.class.Mixin, import_core48.default.space.Model, import__.default.mixin.ProjectTypeClass, {
88836
88836
  projectType: _id
88837
88837
  });
88838
88838
  return tmpl;
@@ -88891,22 +88891,22 @@ var require_utils16 = __commonJS({
88891
88891
  const targetClassId = `${taskId}:type:mixin`;
88892
88892
  tdata.targetClass = targetClassId;
88893
88893
  await client.createDoc(
88894
- import_core47.default.class.Mixin,
88895
- import_core47.default.space.Model,
88894
+ import_core48.default.class.Mixin,
88895
+ import_core48.default.space.Model,
88896
88896
  {
88897
88897
  extends: data.ofClass,
88898
- kind: import_core47.ClassifierKind.MIXIN,
88898
+ kind: import_core48.ClassifierKind.MIXIN,
88899
88899
  label: ofClassClass.label,
88900
88900
  icon: ofClassClass.icon
88901
88901
  },
88902
88902
  targetClassId
88903
88903
  );
88904
- await client.createMixin(targetClassId, import_core47.default.class.Mixin, import_core47.default.space.Model, import__.default.mixin.TaskTypeClass, {
88904
+ await client.createMixin(targetClassId, import_core48.default.class.Mixin, import_core48.default.space.Model, import__.default.mixin.TaskTypeClass, {
88905
88905
  taskType: taskId,
88906
88906
  projectType: _id
88907
88907
  });
88908
88908
  }
88909
- await client.createDoc(import__.default.class.TaskType, import_core47.default.space.Model, tdata, taskId);
88909
+ await client.createDoc(import__.default.class.TaskType, import_core48.default.space.Model, tdata, taskId);
88910
88910
  tasksData.set(taskId, tdata);
88911
88911
  _tasks.push(taskId);
88912
88912
  }
@@ -150531,8 +150531,118 @@ var HulyConfigService = class _HulyConfigService extends Context_exports.Tag("@h
150531
150531
  var import_api_client = __toESM(require_lib20(), 1);
150532
150532
  var import_collaborator_client = __toESM(require_lib7(), 1);
150533
150533
  var import_core2 = __toESM(require_lib4(), 1);
150534
- var import_text = __toESM(require_lib9(), 1);
150535
- var import_text_markdown = __toESM(require_lib17(), 1);
150534
+ var import_text2 = __toESM(require_lib9(), 1);
150535
+ var import_text_markdown2 = __toESM(require_lib17(), 1);
150536
+
150537
+ // src/domain/schemas/shared.ts
150538
+ var MAX_LIMIT = 200;
150539
+ var NonEmptyString2 = Schema_exports.Trim.pipe(Schema_exports.nonEmptyString());
150540
+ var Timestamp = Schema_exports.NonNegativeInt.annotations({
150541
+ identifier: "Timestamp",
150542
+ title: "Timestamp",
150543
+ description: "Unix timestamp in milliseconds (non-negative integer)"
150544
+ });
150545
+ var LimitParam = Schema_exports.Number.pipe(
150546
+ Schema_exports.int(),
150547
+ Schema_exports.positive(),
150548
+ Schema_exports.lessThanOrEqualTo(MAX_LIMIT)
150549
+ );
150550
+ var EmptyParamsSchema = Schema_exports.Struct({}).annotations({
150551
+ jsonSchema: { type: "object", properties: {}, additionalProperties: false }
150552
+ });
150553
+ var emptyParamsJsonSchema = JSONSchema_exports.make(EmptyParamsSchema);
150554
+ var HulyRef = (tag2) => NonEmptyString2.pipe(Schema_exports.brand(tag2));
150555
+ var PersonId = HulyRef("PersonId");
150556
+ var OrganizationId = HulyRef("OrganizationId");
150557
+ var IssueId = HulyRef("IssueId");
150558
+ var ComponentId = HulyRef("ComponentId");
150559
+ var MilestoneId = HulyRef("MilestoneId");
150560
+ var IssueTemplateId = HulyRef("IssueTemplateId");
150561
+ var IssueTemplateChildId = HulyRef("IssueTemplateChildId");
150562
+ var ChannelId = HulyRef("ChannelId");
150563
+ var MessageId = HulyRef("MessageId");
150564
+ var ThreadReplyId = HulyRef("ThreadReplyId");
150565
+ var ActivityMessageId = HulyRef("ActivityMessageId");
150566
+ var AttachmentId = HulyRef("AttachmentId");
150567
+ var BlobId = HulyRef("BlobId");
150568
+ var CardId = HulyRef("CardId");
150569
+ var CardSpaceId = HulyRef("CardSpaceId");
150570
+ var DocumentId = HulyRef("DocumentId");
150571
+ var MasterTagId = HulyRef("MasterTagId");
150572
+ var TeamspaceId = HulyRef("TeamspaceId");
150573
+ var NotificationId = HulyRef("NotificationId");
150574
+ var NotificationContextId = HulyRef("NotificationContextId");
150575
+ var EventId = HulyRef("EventId");
150576
+ var TodoId = HulyRef("TodoId");
150577
+ var SpaceId = HulyRef("SpaceId");
150578
+ var CommentId = HulyRef("CommentId");
150579
+ var TimeSpendReportId = HulyRef("TimeSpendReportId");
150580
+ var TagElementId = HulyRef("TagElementId");
150581
+ var TagCategoryId = HulyRef("TagCategoryId");
150582
+ var WorkSlotId = HulyRef("WorkSlotId");
150583
+ var CustomFieldId = HulyRef("CustomFieldId");
150584
+ var TestProjectId = HulyRef("TestProjectId");
150585
+ var TestSuiteId = HulyRef("TestSuiteId");
150586
+ var TestCaseId = HulyRef("TestCaseId");
150587
+ var TestPlanId = HulyRef("TestPlanId");
150588
+ var TestPlanItemId = HulyRef("TestPlanItemId");
150589
+ var TestRunId = HulyRef("TestRunId");
150590
+ var TestResultId = HulyRef("TestResultId");
150591
+ var ProjectIdentifier = NonEmptyString2.pipe(Schema_exports.brand("ProjectIdentifier"));
150592
+ var IssueIdentifier = NonEmptyString2.pipe(Schema_exports.brand("IssueIdentifier"));
150593
+ var Email = Schema_exports.NonEmptyString.pipe(
150594
+ Schema_exports.pattern(/^[^@]+@[^@]+$/, {
150595
+ message: () => "must contain exactly one @"
150596
+ }),
150597
+ Schema_exports.brand("Email")
150598
+ );
150599
+ var StatusName = NonEmptyString2.pipe(Schema_exports.brand("StatusName"));
150600
+ var PersonName = NonEmptyString2.pipe(Schema_exports.brand("PersonName"));
150601
+ var ComponentLabel = NonEmptyString2.pipe(Schema_exports.brand("ComponentLabel"));
150602
+ var MilestoneLabel = NonEmptyString2.pipe(Schema_exports.brand("MilestoneLabel"));
150603
+ var ChannelName = NonEmptyString2.pipe(Schema_exports.brand("ChannelName"));
150604
+ var MimeType = NonEmptyString2.pipe(Schema_exports.brand("MimeType"));
150605
+ var ObjectClassName = NonEmptyString2.pipe(Schema_exports.brand("ObjectClassName"));
150606
+ var EmojiCode = NonEmptyString2.pipe(Schema_exports.brand("EmojiCode"));
150607
+ var ContactProvider = NonEmptyString2.pipe(Schema_exports.brand("ContactProvider"));
150608
+ var NotificationProviderId = NonEmptyString2.pipe(Schema_exports.brand("NotificationProviderId"));
150609
+ var NotificationTypeId = NonEmptyString2.pipe(Schema_exports.brand("NotificationTypeId"));
150610
+ var WorkspaceName = NonEmptyString2.pipe(Schema_exports.brand("WorkspaceName"));
150611
+ var UrlString = NonEmptyString2.pipe(Schema_exports.brand("UrlString"));
150612
+ var WorkspaceVersion = NonEmptyString2.pipe(Schema_exports.brand("WorkspaceVersion"));
150613
+ var WorkspaceMode = NonEmptyString2.pipe(Schema_exports.brand("WorkspaceMode"));
150614
+ var WorkspaceUuid = NonEmptyString2.pipe(Schema_exports.brand("WorkspaceUuid"));
150615
+ var PersonUuid = NonEmptyString2.pipe(Schema_exports.brand("PersonUuid"));
150616
+ var AccountId = NonEmptyString2.pipe(Schema_exports.brand("AccountId"));
150617
+ var AccountUuid = Schema_exports.String.pipe(Schema_exports.brand("AccountUuid"));
150618
+ var RegionId = Schema_exports.String.pipe(Schema_exports.brand("RegionId"));
150619
+ var NonNegativeNumber = Schema_exports.Number.pipe(Schema_exports.nonNegative(), Schema_exports.brand("NonNegativeNumber"));
150620
+ var PositiveNumber = NonNegativeNumber.pipe(Schema_exports.positive(), Schema_exports.brand("PositiveNumber"));
150621
+ var ColorCode = Schema_exports.Number.pipe(
150622
+ Schema_exports.int(),
150623
+ Schema_exports.greaterThanOrEqualTo(0),
150624
+ Schema_exports.lessThanOrEqualTo(9),
150625
+ // eslint-disable-line no-magic-numbers -- Huly color palette has 10 colors (0-9)
150626
+ Schema_exports.brand("ColorCode")
150627
+ );
150628
+ var ComponentIdentifier = NonEmptyString2.pipe(Schema_exports.brand("ComponentIdentifier"));
150629
+ var MilestoneIdentifier = NonEmptyString2.pipe(Schema_exports.brand("MilestoneIdentifier"));
150630
+ var TemplateIdentifier = NonEmptyString2.pipe(Schema_exports.brand("TemplateIdentifier"));
150631
+ var ChannelIdentifier = NonEmptyString2.pipe(Schema_exports.brand("ChannelIdentifier"));
150632
+ var TeamspaceIdentifier = NonEmptyString2.pipe(Schema_exports.brand("TeamspaceIdentifier"));
150633
+ var CardIdentifier = NonEmptyString2.pipe(Schema_exports.brand("CardIdentifier"));
150634
+ var CardSpaceIdentifier = NonEmptyString2.pipe(Schema_exports.brand("CardSpaceIdentifier"));
150635
+ var DocumentIdentifier = NonEmptyString2.pipe(Schema_exports.brand("DocumentIdentifier"));
150636
+ var MasterTagIdentifier = NonEmptyString2.pipe(Schema_exports.brand("MasterTagIdentifier"));
150637
+ var TagIdentifier = NonEmptyString2.pipe(Schema_exports.brand("TagIdentifier"));
150638
+ var TagCategoryIdentifier = NonEmptyString2.pipe(Schema_exports.brand("TagCategoryIdentifier"));
150639
+ var MemberReference = NonEmptyString2.pipe(Schema_exports.brand("MemberReference"));
150640
+ var TestProjectIdentifier = NonEmptyString2.pipe(Schema_exports.brand("TestProjectIdentifier"));
150641
+ var TestSuiteIdentifier = NonEmptyString2.pipe(Schema_exports.brand("TestSuiteIdentifier"));
150642
+ var TestCaseIdentifier = NonEmptyString2.pipe(Schema_exports.brand("TestCaseIdentifier"));
150643
+ var TestPlanIdentifier = NonEmptyString2.pipe(Schema_exports.brand("TestPlanIdentifier"));
150644
+ var TestRunIdentifier = NonEmptyString2.pipe(Schema_exports.brand("TestRunIdentifier"));
150645
+ var TestResultIdentifier = NonEmptyString2.pipe(Schema_exports.brand("TestResultIdentifier"));
150536
150646
 
150537
150647
  // src/utils/url.ts
150538
150648
  var concatLink = (host, path2) => {
@@ -150633,6 +150743,37 @@ var PersonNotFoundError = class extends Schema_exports.TaggedError()(
150633
150743
  return `Person '${this.identifier}' not found`;
150634
150744
  }
150635
150745
  };
150746
+ var OrganizationNotFoundError = class extends Schema_exports.TaggedError()(
150747
+ "OrganizationNotFoundError",
150748
+ {
150749
+ identifier: Schema_exports.String
150750
+ }
150751
+ ) {
150752
+ get message() {
150753
+ return `Organization '${this.identifier}' not found`;
150754
+ }
150755
+ };
150756
+ var OrganizationIdentifierAmbiguousError = class extends Schema_exports.TaggedError()(
150757
+ "OrganizationIdentifierAmbiguousError",
150758
+ {
150759
+ identifier: Schema_exports.String,
150760
+ matches: Schema_exports.Number
150761
+ }
150762
+ ) {
150763
+ get message() {
150764
+ return `Organization identifier '${this.identifier}' matched ${this.matches} organizations; use the organization ID instead`;
150765
+ }
150766
+ };
150767
+ var InvalidContactProviderError = class extends Schema_exports.TaggedError()(
150768
+ "InvalidContactProviderError",
150769
+ {
150770
+ provider: Schema_exports.String
150771
+ }
150772
+ ) {
150773
+ get message() {
150774
+ return `Invalid contact provider: '${this.provider}'`;
150775
+ }
150776
+ };
150636
150777
  var InvalidPersonUuidError = class extends Schema_exports.TaggedError()(
150637
150778
  "InvalidPersonUuidError",
150638
150779
  {
@@ -150820,6 +150961,144 @@ var TagCategoryNotFoundError = class extends Schema_exports.TaggedError()(
150820
150961
  }
150821
150962
  };
150822
150963
 
150964
+ // src/domain/schemas/leads.ts
150965
+ var HulyRef2 = (tag2) => Schema_exports.Trim.pipe(Schema_exports.nonEmptyString(), Schema_exports.brand(tag2));
150966
+ var FunnelReference = HulyRef2("FunnelReference");
150967
+ var FunnelIdentifier = HulyRef2("FunnelIdentifier");
150968
+ var CanonicalLeadIdentifier = Schema_exports.Trim.pipe(
150969
+ Schema_exports.pattern(/^LEAD-\d+$/, {
150970
+ message: () => "Expected lead identifier like 'LEAD-1'"
150971
+ }),
150972
+ Schema_exports.brand("LeadIdentifier")
150973
+ );
150974
+ var leadIdentifierPattern = /^(?:LEAD-)?(\d+)$/i;
150975
+ var LeadIdentifier = Schema_exports.transformOrFail(Schema_exports.String, CanonicalLeadIdentifier, {
150976
+ strict: true,
150977
+ decode: (input, _options, ast) => {
150978
+ const match16 = leadIdentifierPattern.exec(input.trim());
150979
+ return match16 !== null ? ParseResult_exports.succeed(`LEAD-${match16[1]}`) : ParseResult_exports.fail(new ParseResult_exports.Type(ast, input, "Expected lead identifier like 'LEAD-1'"));
150980
+ },
150981
+ encode: ParseResult_exports.succeed
150982
+ }).annotations({
150983
+ jsonSchema: {
150984
+ type: "string",
150985
+ pattern: "^LEAD-[0-9]+$"
150986
+ }
150987
+ });
150988
+ var FunnelSummarySchema = Schema_exports.Struct({
150989
+ identifier: FunnelIdentifier,
150990
+ name: Schema_exports.String,
150991
+ description: Schema_exports.optional(Schema_exports.String),
150992
+ archived: Schema_exports.Boolean
150993
+ }).annotations({
150994
+ title: "FunnelSummary",
150995
+ description: "Sales funnel summary"
150996
+ });
150997
+ var LeadSummarySchema = Schema_exports.Struct({
150998
+ identifier: LeadIdentifier,
150999
+ title: Schema_exports.String,
151000
+ status: StatusName,
151001
+ assignee: Schema_exports.optional(PersonName),
151002
+ customer: Schema_exports.optional(Schema_exports.String),
151003
+ modifiedOn: Schema_exports.optional(Timestamp)
151004
+ }).annotations({
151005
+ title: "LeadSummary",
151006
+ description: "Lead summary for list operations"
151007
+ });
151008
+ var LeadDetailSchema = Schema_exports.Struct({
151009
+ identifier: LeadIdentifier,
151010
+ title: Schema_exports.String,
151011
+ description: Schema_exports.optional(Schema_exports.String),
151012
+ status: StatusName,
151013
+ assignee: Schema_exports.optional(PersonName),
151014
+ customer: Schema_exports.optional(Schema_exports.String),
151015
+ funnel: FunnelIdentifier,
151016
+ funnelName: Schema_exports.String,
151017
+ modifiedOn: Schema_exports.optional(Timestamp),
151018
+ createdOn: Schema_exports.optional(Timestamp)
151019
+ }).annotations({
151020
+ title: "LeadDetail",
151021
+ description: "Full lead with all fields"
151022
+ });
151023
+ var ListFunnelsParamsSchema = Schema_exports.Struct({
151024
+ includeArchived: Schema_exports.optional(Schema_exports.Boolean.annotations({
151025
+ description: "Include archived funnels in results (default: false, showing only active)"
151026
+ })),
151027
+ limit: Schema_exports.optional(
151028
+ LimitParam.annotations({
151029
+ description: "Maximum number of funnels to return (default: 50)"
151030
+ })
151031
+ )
151032
+ }).annotations({
151033
+ title: "ListFunnelsParams",
151034
+ description: "Parameters for listing funnels"
151035
+ });
151036
+ var ListLeadsParamsBase = Schema_exports.Struct({
151037
+ funnel: FunnelReference.annotations({
151038
+ description: "Funnel ID returned by list_funnels, or funnel name for convenience lookup."
151039
+ }),
151040
+ status: Schema_exports.optional(StatusName.annotations({
151041
+ description: "Filter by status name"
151042
+ })),
151043
+ assignee: Schema_exports.optional(Email.annotations({
151044
+ description: "Filter by assignee email"
151045
+ })),
151046
+ titleSearch: Schema_exports.optional(Schema_exports.String.annotations({
151047
+ description: "Search leads by title substring (case-insensitive)"
151048
+ })),
151049
+ limit: Schema_exports.optional(
151050
+ LimitParam.annotations({
151051
+ description: "Maximum number of leads to return (default: 50)"
151052
+ })
151053
+ )
151054
+ });
151055
+ var ListLeadsParamsSchema = ListLeadsParamsBase.annotations({
151056
+ title: "ListLeadsParams",
151057
+ description: "Parameters for listing leads in a funnel"
151058
+ });
151059
+ var GetLeadParamsSchema = Schema_exports.Struct({
151060
+ funnel: FunnelReference.annotations({
151061
+ description: "Funnel ID returned by list_funnels, or funnel name for convenience lookup."
151062
+ }),
151063
+ identifier: LeadIdentifier.annotations({
151064
+ description: "Lead identifier (e.g., 'LEAD-1')"
151065
+ })
151066
+ }).annotations({
151067
+ title: "GetLeadParams",
151068
+ description: "Parameters for getting a single lead"
151069
+ });
151070
+ var listFunnelsParamsJsonSchema = JSONSchema_exports.make(ListFunnelsParamsSchema);
151071
+ var listLeadsParamsJsonSchema = JSONSchema_exports.make(ListLeadsParamsSchema);
151072
+ var getLeadParamsJsonSchema = JSONSchema_exports.make(GetLeadParamsSchema);
151073
+ var parseListFunnelsParams = Schema_exports.decodeUnknown(ListFunnelsParamsSchema);
151074
+ var parseListLeadsParams = Schema_exports.decodeUnknown(ListLeadsParamsSchema);
151075
+ var parseGetLeadParams = Schema_exports.decodeUnknown(GetLeadParamsSchema);
151076
+ var parseLeadDetail = Schema_exports.decodeUnknown(LeadDetailSchema);
151077
+ var parseLeadSummary = Schema_exports.decodeUnknown(LeadSummarySchema);
151078
+
151079
+ // src/huly/errors-leads.ts
151080
+ var FunnelNotFoundError = class extends Schema_exports.TaggedError()(
151081
+ "FunnelNotFoundError",
151082
+ {
151083
+ identifier: FunnelReference
151084
+ }
151085
+ ) {
151086
+ get message() {
151087
+ return `Funnel '${this.identifier}' not found`;
151088
+ }
151089
+ };
151090
+ var LeadNotFoundError = class extends Schema_exports.TaggedError()(
151091
+ "LeadNotFoundError",
151092
+ {
151093
+ identifier: LeadIdentifier,
151094
+ funnel: FunnelIdentifier
151095
+ }
151096
+ ) {
151097
+ get message() {
151098
+ return `Lead '${this.identifier}' not found in funnel '${this.funnel}'`;
151099
+ }
151100
+ };
151101
+
150823
151102
  // src/huly/errors-messaging.ts
150824
151103
  var ChannelNotFoundError = class extends Schema_exports.TaggedError()(
150825
151104
  "ChannelNotFoundError",
@@ -151080,6 +151359,9 @@ var HulyDomainError = Schema_exports.Union(
151080
151359
  ProjectNotFoundError,
151081
151360
  InvalidStatusError,
151082
151361
  PersonNotFoundError,
151362
+ OrganizationNotFoundError,
151363
+ OrganizationIdentifierAmbiguousError,
151364
+ InvalidContactProviderError,
151083
151365
  FileUploadError,
151084
151366
  InvalidFileDataError,
151085
151367
  FileNotFoundError,
@@ -151120,6 +151402,8 @@ var HulyDomainError = Schema_exports.Union(
151120
151402
  NotificationNotFoundError,
151121
151403
  NotificationContextNotFoundError,
151122
151404
  InvalidPersonUuidError,
151405
+ FunnelNotFoundError,
151406
+ LeadNotFoundError,
151123
151407
  FileTooLargeError,
151124
151408
  InvalidContentTypeError
151125
151409
  );
@@ -151164,15 +151448,36 @@ var connectWithRetry = (connect, errorPrefix) => withConnectionRetry(
151164
151448
  })
151165
151449
  );
151166
151450
 
151451
+ // src/huly/operations/markup.ts
151452
+ var import_text = __toESM(require_lib9(), 1);
151453
+ var import_text_markdown = __toESM(require_lib17(), 1);
151454
+ var jsonAsMarkup = import_text.jsonToMarkup;
151455
+ var testMarkupUrlConfig = {
151456
+ refUrl: UrlString.make("https://test.invalid/browse?workspace=test"),
151457
+ imageUrl: UrlString.make("https://test.invalid/files?workspace=test&file=")
151458
+ };
151459
+ var markupToMarkdownString = (markup, urls) => {
151460
+ const json3 = (0, import_text.markupToJSON)(markup);
151461
+ return (0, import_text_markdown.markupToMarkdown)(json3, urls);
151462
+ };
151463
+ var markdownToMarkupString = (markdown, urls) => {
151464
+ const json3 = (0, import_text_markdown.markdownToMarkup)(markdown, urls);
151465
+ return jsonAsMarkup(json3);
151466
+ };
151467
+ var optionalMarkdownToMarkup = (md, urls, fallback = "") => md && md.trim() !== "" ? markdownToMarkupString(md, urls) : fallback;
151468
+ function optionalMarkupToMarkdown(markup, urls, fallback = "") {
151469
+ return markup === null || markup === void 0 ? fallback : markupToMarkdownString(markup, urls);
151470
+ }
151471
+
151167
151472
  // src/huly/client.ts
151168
151473
  function toInternalMarkup(value3, format7, opts) {
151169
151474
  switch (format7) {
151170
151475
  case "markup":
151171
151476
  return value3;
151172
151477
  case "html":
151173
- return (0, import_text.jsonToMarkup)((0, import_text.htmlToJSON)(value3));
151478
+ return (0, import_text2.jsonToMarkup)((0, import_text2.htmlToJSON)(value3));
151174
151479
  case "markdown":
151175
- return (0, import_text.jsonToMarkup)((0, import_text_markdown.markdownToMarkup)(value3, opts));
151480
+ return (0, import_text2.jsonToMarkup)((0, import_text_markdown2.markdownToMarkup)(value3, opts));
151176
151481
  default:
151177
151482
  absurd(format7);
151178
151483
  throw new Error(`Invalid format: ${format7}`);
@@ -151183,24 +151488,28 @@ function fromInternalMarkup(markup, format7, opts) {
151183
151488
  case "markup":
151184
151489
  return markup;
151185
151490
  case "html":
151186
- return (0, import_text.jsonToHTML)((0, import_text.markupToJSON)(markup));
151491
+ return (0, import_text2.jsonToHTML)((0, import_text2.markupToJSON)(markup));
151187
151492
  case "markdown":
151188
- return (0, import_text_markdown.markupToMarkdown)((0, import_text.markupToJSON)(markup), opts);
151493
+ return (0, import_text_markdown2.markupToMarkdown)((0, import_text2.markupToJSON)(markup), opts);
151189
151494
  default:
151190
151495
  absurd(format7);
151191
151496
  throw new Error(`Invalid format: ${format7}`);
151192
151497
  }
151193
151498
  }
151194
151499
  var HulyClient = class _HulyClient extends Context_exports.Tag("@hulymcp/HulyClient")() {
151195
- static layer = Layer_exports.scoped(
151500
+ static layer = Layer_exports.effect(
151196
151501
  _HulyClient,
151197
151502
  Effect_exports.gen(function* () {
151198
151503
  const config3 = yield* HulyConfigService;
151199
- const { accountUuid, client, markupOps } = yield* connectRestWithRetry({
151504
+ const { accountUuid, client, imageUrl, markupOps, refUrl } = yield* connectRestWithRetry({
151200
151505
  url: config3.url,
151201
151506
  auth: config3.auth,
151202
151507
  workspace: config3.workspace
151203
151508
  });
151509
+ const markupUrlConfig = {
151510
+ refUrl: UrlString.make(refUrl),
151511
+ imageUrl: UrlString.make(imageUrl)
151512
+ };
151204
151513
  const withClient = (op, errorMsg) => Effect_exports.tryPromise({
151205
151514
  try: () => op(client),
151206
151515
  catch: (e) => new HulyConnectionError({
@@ -151210,6 +151519,7 @@ var HulyClient = class _HulyClient extends Context_exports.Tag("@hulymcp/HulyCli
151210
151519
  });
151211
151520
  const operations = {
151212
151521
  getAccountUuid: () => accountUuid,
151522
+ markupUrlConfig,
151213
151523
  findAll: (_class, query, options) => withClient(
151214
151524
  (client2) => client2.findAll(_class, query, options),
151215
151525
  "findAll failed"
@@ -151242,6 +151552,10 @@ var HulyClient = class _HulyClient extends Context_exports.Tag("@hulymcp/HulyCli
151242
151552
  (client2) => client2.removeDoc(_class, space, objectId),
151243
151553
  "removeDoc failed"
151244
151554
  ),
151555
+ createMixin: (objectId, objectClass, objectSpace, mixin, attributes) => withClient(
151556
+ (client2) => client2.createMixin(objectId, objectClass, objectSpace, mixin, attributes),
151557
+ "createMixin failed"
151558
+ ),
151245
151559
  updateMixin: (objectId, objectClass, objectSpace, mixin, attributes) => withClient(
151246
151560
  (client2) => client2.updateMixin(objectId, objectClass, objectSpace, mixin, attributes),
151247
151561
  "updateMixin failed"
@@ -151284,6 +151598,7 @@ var HulyClient = class _HulyClient extends Context_exports.Tag("@hulymcp/HulyCli
151284
151598
  // AccountUuid is a double-branded string type with no public constructor
151285
151599
  // eslint-disable-next-line no-restricted-syntax -- see above
151286
151600
  getAccountUuid: () => "test-account-uuid",
151601
+ markupUrlConfig: testMarkupUrlConfig,
151287
151602
  findAll: noopFindAll,
151288
151603
  findOne: noopFindOne,
151289
151604
  createDoc: notImplemented("createDoc"),
@@ -151292,6 +151607,7 @@ var HulyClient = class _HulyClient extends Context_exports.Tag("@hulymcp/HulyCli
151292
151607
  removeDoc: notImplemented("removeDoc"),
151293
151608
  uploadMarkup: notImplemented("uploadMarkup"),
151294
151609
  fetchMarkup: noopFetchMarkup,
151610
+ createMixin: notImplemented("createMixin"),
151295
151611
  updateMixin: notImplemented("updateMixin"),
151296
151612
  updateMarkup: notImplemented("updateMarkup"),
151297
151613
  searchFulltext: notImplemented("searchFulltext")
@@ -151304,18 +151620,22 @@ function createMarkupOps(url4, workspace, token, collaboratorUrl) {
151304
151620
  const imageUrl = concatLink(url4, `/files?workspace=${workspace}&file=`);
151305
151621
  const collaborator = (0, import_collaborator_client.getClient)(workspace, token, collaboratorUrl);
151306
151622
  return {
151307
- async fetchMarkup(objectClass, objectId, objectAttr, doc, format7) {
151308
- const collabId = (0, import_core2.makeCollabId)(objectClass, objectId, objectAttr);
151309
- const markup = await collaborator.getMarkup(collabId, doc);
151310
- return fromInternalMarkup(markup, format7, { refUrl, imageUrl });
151311
- },
151312
- async uploadMarkup(objectClass, objectId, objectAttr, value3, format7) {
151313
- const collabId = (0, import_core2.makeCollabId)(objectClass, objectId, objectAttr);
151314
- return await collaborator.createMarkup(collabId, toInternalMarkup(value3, format7, { refUrl, imageUrl }));
151315
- },
151316
- async updateMarkup(objectClass, objectId, objectAttr, value3, format7) {
151317
- const collabId = (0, import_core2.makeCollabId)(objectClass, objectId, objectAttr);
151318
- return await collaborator.updateMarkup(collabId, toInternalMarkup(value3, format7, { refUrl, imageUrl }));
151623
+ refUrl,
151624
+ imageUrl,
151625
+ ops: {
151626
+ async fetchMarkup(objectClass, objectId, objectAttr, doc, format7) {
151627
+ const collabId = (0, import_core2.makeCollabId)(objectClass, objectId, objectAttr);
151628
+ const markup = await collaborator.getMarkup(collabId, doc);
151629
+ return fromInternalMarkup(markup, format7, { refUrl, imageUrl });
151630
+ },
151631
+ async uploadMarkup(objectClass, objectId, objectAttr, value3, format7) {
151632
+ const collabId = (0, import_core2.makeCollabId)(objectClass, objectId, objectAttr);
151633
+ return await collaborator.createMarkup(collabId, toInternalMarkup(value3, format7, { refUrl, imageUrl }));
151634
+ },
151635
+ async updateMarkup(objectClass, objectId, objectAttr, value3, format7) {
151636
+ const collabId = (0, import_core2.makeCollabId)(objectClass, objectId, objectAttr);
151637
+ return await collaborator.updateMarkup(collabId, toInternalMarkup(value3, format7, { refUrl, imageUrl }));
151638
+ }
151319
151639
  }
151320
151640
  };
151321
151641
  }
@@ -151330,13 +151650,13 @@ var connectRest = async (config3) => {
151330
151650
  const restClient = (0, import_api_client.createRestClient)(endpoint, workspaceId, token);
151331
151651
  const account = await restClient.getAccount();
151332
151652
  const client = await (0, import_api_client.createRestTxOperations)(endpoint, workspaceId, token);
151333
- const markupOps = createMarkupOps(
151653
+ const { imageUrl, ops: markupOps, refUrl } = createMarkupOps(
151334
151654
  config3.url,
151335
151655
  workspaceId,
151336
151656
  token,
151337
151657
  serverConfig.COLLABORATOR_URL
151338
151658
  );
151339
- return { client, accountUuid: account.uuid, markupOps };
151659
+ return { client, accountUuid: account.uuid, markupOps, refUrl, imageUrl };
151340
151660
  };
151341
151661
  var connectRestWithRetry = (config3) => connectWithRetry(() => connectRest(config3), "Connection failed");
151342
151662
 
@@ -151349,116 +151669,6 @@ var import_api_client2 = __toESM(require_lib20(), 1);
151349
151669
  var import_core3 = __toESM(require_lib4(), 1);
151350
151670
  var import_tracker = __toESM(require_lib21(), 1);
151351
151671
 
151352
- // src/domain/schemas/shared.ts
151353
- var MAX_LIMIT = 200;
151354
- var NonEmptyString2 = Schema_exports.Trim.pipe(Schema_exports.nonEmptyString());
151355
- var Timestamp = Schema_exports.NonNegativeInt.annotations({
151356
- identifier: "Timestamp",
151357
- title: "Timestamp",
151358
- description: "Unix timestamp in milliseconds (non-negative integer)"
151359
- });
151360
- var LimitParam = Schema_exports.Number.pipe(
151361
- Schema_exports.int(),
151362
- Schema_exports.positive(),
151363
- Schema_exports.lessThanOrEqualTo(MAX_LIMIT)
151364
- );
151365
- var EmptyParamsSchema = Schema_exports.Struct({}).annotations({
151366
- jsonSchema: { type: "object", properties: {}, additionalProperties: false }
151367
- });
151368
- var emptyParamsJsonSchema = JSONSchema_exports.make(EmptyParamsSchema);
151369
- var HulyRef = (tag2) => NonEmptyString2.pipe(Schema_exports.brand(tag2));
151370
- var PersonId = HulyRef("PersonId");
151371
- var OrganizationId = HulyRef("OrganizationId");
151372
- var IssueId = HulyRef("IssueId");
151373
- var ComponentId = HulyRef("ComponentId");
151374
- var MilestoneId = HulyRef("MilestoneId");
151375
- var IssueTemplateId = HulyRef("IssueTemplateId");
151376
- var IssueTemplateChildId = HulyRef("IssueTemplateChildId");
151377
- var ChannelId = HulyRef("ChannelId");
151378
- var MessageId = HulyRef("MessageId");
151379
- var ThreadReplyId = HulyRef("ThreadReplyId");
151380
- var ActivityMessageId = HulyRef("ActivityMessageId");
151381
- var AttachmentId = HulyRef("AttachmentId");
151382
- var BlobId = HulyRef("BlobId");
151383
- var CardId = HulyRef("CardId");
151384
- var CardSpaceId = HulyRef("CardSpaceId");
151385
- var DocumentId = HulyRef("DocumentId");
151386
- var MasterTagId = HulyRef("MasterTagId");
151387
- var TeamspaceId = HulyRef("TeamspaceId");
151388
- var NotificationId = HulyRef("NotificationId");
151389
- var NotificationContextId = HulyRef("NotificationContextId");
151390
- var EventId = HulyRef("EventId");
151391
- var TodoId = HulyRef("TodoId");
151392
- var SpaceId = HulyRef("SpaceId");
151393
- var CommentId = HulyRef("CommentId");
151394
- var TimeSpendReportId = HulyRef("TimeSpendReportId");
151395
- var TagElementId = HulyRef("TagElementId");
151396
- var TagCategoryId = HulyRef("TagCategoryId");
151397
- var WorkSlotId = HulyRef("WorkSlotId");
151398
- var CustomFieldId = HulyRef("CustomFieldId");
151399
- var TestProjectId = HulyRef("TestProjectId");
151400
- var TestSuiteId = HulyRef("TestSuiteId");
151401
- var TestCaseId = HulyRef("TestCaseId");
151402
- var TestPlanId = HulyRef("TestPlanId");
151403
- var TestPlanItemId = HulyRef("TestPlanItemId");
151404
- var TestRunId = HulyRef("TestRunId");
151405
- var TestResultId = HulyRef("TestResultId");
151406
- var ProjectIdentifier = NonEmptyString2.pipe(Schema_exports.brand("ProjectIdentifier"));
151407
- var IssueIdentifier = NonEmptyString2.pipe(Schema_exports.brand("IssueIdentifier"));
151408
- var Email = Schema_exports.NonEmptyString.pipe(
151409
- Schema_exports.pattern(/^[^@]+@[^@]+$/, {
151410
- message: () => "must contain exactly one @"
151411
- }),
151412
- Schema_exports.brand("Email")
151413
- );
151414
- var StatusName = NonEmptyString2.pipe(Schema_exports.brand("StatusName"));
151415
- var PersonName = NonEmptyString2.pipe(Schema_exports.brand("PersonName"));
151416
- var ComponentLabel = NonEmptyString2.pipe(Schema_exports.brand("ComponentLabel"));
151417
- var MilestoneLabel = NonEmptyString2.pipe(Schema_exports.brand("MilestoneLabel"));
151418
- var ChannelName = NonEmptyString2.pipe(Schema_exports.brand("ChannelName"));
151419
- var MimeType = NonEmptyString2.pipe(Schema_exports.brand("MimeType"));
151420
- var ObjectClassName = NonEmptyString2.pipe(Schema_exports.brand("ObjectClassName"));
151421
- var EmojiCode = NonEmptyString2.pipe(Schema_exports.brand("EmojiCode"));
151422
- var ContactProvider = NonEmptyString2.pipe(Schema_exports.brand("ContactProvider"));
151423
- var NotificationProviderId = NonEmptyString2.pipe(Schema_exports.brand("NotificationProviderId"));
151424
- var NotificationTypeId = NonEmptyString2.pipe(Schema_exports.brand("NotificationTypeId"));
151425
- var WorkspaceName = NonEmptyString2.pipe(Schema_exports.brand("WorkspaceName"));
151426
- var UrlString = NonEmptyString2.pipe(Schema_exports.brand("UrlString"));
151427
- var WorkspaceVersion = NonEmptyString2.pipe(Schema_exports.brand("WorkspaceVersion"));
151428
- var WorkspaceMode = NonEmptyString2.pipe(Schema_exports.brand("WorkspaceMode"));
151429
- var WorkspaceUuid = NonEmptyString2.pipe(Schema_exports.brand("WorkspaceUuid"));
151430
- var PersonUuid = NonEmptyString2.pipe(Schema_exports.brand("PersonUuid"));
151431
- var AccountId = NonEmptyString2.pipe(Schema_exports.brand("AccountId"));
151432
- var AccountUuid = Schema_exports.String.pipe(Schema_exports.brand("AccountUuid"));
151433
- var RegionId = Schema_exports.String.pipe(Schema_exports.brand("RegionId"));
151434
- var NonNegativeNumber = Schema_exports.Number.pipe(Schema_exports.nonNegative(), Schema_exports.brand("NonNegativeNumber"));
151435
- var PositiveNumber = NonNegativeNumber.pipe(Schema_exports.positive(), Schema_exports.brand("PositiveNumber"));
151436
- var ColorCode = Schema_exports.Number.pipe(
151437
- Schema_exports.int(),
151438
- Schema_exports.greaterThanOrEqualTo(0),
151439
- Schema_exports.lessThanOrEqualTo(9),
151440
- // eslint-disable-line no-magic-numbers -- Huly color palette has 10 colors (0-9)
151441
- Schema_exports.brand("ColorCode")
151442
- );
151443
- var ComponentIdentifier = NonEmptyString2.pipe(Schema_exports.brand("ComponentIdentifier"));
151444
- var MilestoneIdentifier = NonEmptyString2.pipe(Schema_exports.brand("MilestoneIdentifier"));
151445
- var TemplateIdentifier = NonEmptyString2.pipe(Schema_exports.brand("TemplateIdentifier"));
151446
- var ChannelIdentifier = NonEmptyString2.pipe(Schema_exports.brand("ChannelIdentifier"));
151447
- var TeamspaceIdentifier = NonEmptyString2.pipe(Schema_exports.brand("TeamspaceIdentifier"));
151448
- var CardIdentifier = NonEmptyString2.pipe(Schema_exports.brand("CardIdentifier"));
151449
- var CardSpaceIdentifier = NonEmptyString2.pipe(Schema_exports.brand("CardSpaceIdentifier"));
151450
- var DocumentIdentifier = NonEmptyString2.pipe(Schema_exports.brand("DocumentIdentifier"));
151451
- var MasterTagIdentifier = NonEmptyString2.pipe(Schema_exports.brand("MasterTagIdentifier"));
151452
- var TagIdentifier = NonEmptyString2.pipe(Schema_exports.brand("TagIdentifier"));
151453
- var TagCategoryIdentifier = NonEmptyString2.pipe(Schema_exports.brand("TagCategoryIdentifier"));
151454
- var MemberReference = NonEmptyString2.pipe(Schema_exports.brand("MemberReference"));
151455
- var TestProjectIdentifier = NonEmptyString2.pipe(Schema_exports.brand("TestProjectIdentifier"));
151456
- var TestSuiteIdentifier = NonEmptyString2.pipe(Schema_exports.brand("TestSuiteIdentifier"));
151457
- var TestCaseIdentifier = NonEmptyString2.pipe(Schema_exports.brand("TestCaseIdentifier"));
151458
- var TestPlanIdentifier = NonEmptyString2.pipe(Schema_exports.brand("TestPlanIdentifier"));
151459
- var TestRunIdentifier = NonEmptyString2.pipe(Schema_exports.brand("TestRunIdentifier"));
151460
- var TestResultIdentifier = NonEmptyString2.pipe(Schema_exports.brand("TestResultIdentifier"));
151461
-
151462
151672
  // src/utils/normalize.ts
151463
151673
  var normalizeForComparison = (s) => s.replace(/[-_ ]/g, "").toLowerCase();
151464
151674
 
@@ -161653,7 +161863,7 @@ var createMcpHandlers = (createServer) => {
161653
161863
  const transport = new StreamableHTTPServerTransport({});
161654
161864
  await server.connect(transport);
161655
161865
  await transport.handleRequest(req, res, req.body);
161656
- res.on("close", () => {
161866
+ req.on("close", () => {
161657
161867
  transport.close().catch((err) => {
161658
161868
  process.stderr.write(`Transport cleanup error: ${String(err)}
161659
161869
  `);
@@ -171253,7 +171463,7 @@ var PostHog = class extends PostHogBackendClient {
171253
171463
  };
171254
171464
 
171255
171465
  // src/version.ts
171256
- var VERSION = true ? "0.6.2" : "0.0.0-dev";
171466
+ var VERSION = true ? "0.7.0" : "0.0.0-dev";
171257
171467
 
171258
171468
  // src/telemetry/posthog.ts
171259
171469
  var POSTHOG_API_KEY = "phc_TGfFqCGdnF0p68wuFzd5WSw1IsBvOJW0YgoMJDyZPjm";
@@ -171382,6 +171592,9 @@ var INVALID_PARAMS_TAGS = /* @__PURE__ */ new Set([
171382
171592
  "ProjectNotFoundError",
171383
171593
  "InvalidStatusError",
171384
171594
  "PersonNotFoundError",
171595
+ "OrganizationNotFoundError",
171596
+ "OrganizationIdentifierAmbiguousError",
171597
+ "InvalidContactProviderError",
171385
171598
  "InvalidFileDataError",
171386
171599
  "FileNotFoundError",
171387
171600
  "TeamspaceNotFoundError",
@@ -171415,6 +171628,8 @@ var INVALID_PARAMS_TAGS = /* @__PURE__ */ new Set([
171415
171628
  "NotificationNotFoundError",
171416
171629
  "NotificationContextNotFoundError",
171417
171630
  "InvalidPersonUuidError",
171631
+ "FunnelNotFoundError",
171632
+ "LeadNotFoundError",
171418
171633
  "FileTooLargeError",
171419
171634
  "InvalidContentTypeError"
171420
171635
  ]);
@@ -172206,25 +172421,6 @@ var import_text3 = __toESM(require_lib9(), 1);
172206
172421
 
172207
172422
  // src/huly/operations/channels.ts
172208
172423
  var import_core21 = __toESM(require_lib4(), 1);
172209
-
172210
- // src/huly/operations/markup.ts
172211
- var import_text2 = __toESM(require_lib9(), 1);
172212
- var import_text_markdown2 = __toESM(require_lib17(), 1);
172213
- var jsonAsMarkup = import_text2.jsonToMarkup;
172214
- var markupToMarkdownString = (markup) => {
172215
- const json3 = (0, import_text2.markupToJSON)(markup);
172216
- return (0, import_text_markdown2.markupToMarkdown)(json3, { refUrl: "", imageUrl: "" });
172217
- };
172218
- var markdownToMarkupString = (markdown) => {
172219
- const json3 = (0, import_text_markdown2.markdownToMarkup)(markdown, { refUrl: "", imageUrl: "" });
172220
- return jsonAsMarkup(json3);
172221
- };
172222
- var optionalMarkdownToMarkup = (md, fallback = "") => md && md.trim() !== "" ? markdownToMarkupString(md) : fallback;
172223
- function optionalMarkupToMarkdown(markup, fallback = "") {
172224
- return markup ? markupToMarkdownString(markup) : fallback;
172225
- }
172226
-
172227
- // src/huly/operations/channels.ts
172228
172424
  var personIdsAsSocialIdentityRefs = (ids3) => ids3;
172229
172425
  var findChannel = (identifier2) => Effect_exports.gen(function* () {
172230
172426
  const client = yield* HulyClient;
@@ -172390,6 +172586,7 @@ var deleteChannel = (params) => Effect_exports.gen(function* () {
172390
172586
  });
172391
172587
  var listChannelMessages = (params) => Effect_exports.gen(function* () {
172392
172588
  const { channel, client } = yield* findChannel(params.channel);
172589
+ const markupUrlConfig = client.markupUrlConfig;
172393
172590
  const limit = clampLimit(params.limit);
172394
172591
  const messages = yield* client.findAll(
172395
172592
  chunter.class.ChatMessage,
@@ -172414,7 +172611,7 @@ var listChannelMessages = (params) => Effect_exports.gen(function* () {
172414
172611
  const senderName = socialIdToName.get(msg.modifiedBy);
172415
172612
  return {
172416
172613
  id: MessageId.make(msg._id),
172417
- body: markupToMarkdownString(msg.message),
172614
+ body: markupToMarkdownString(msg.message, markupUrlConfig),
172418
172615
  sender: senderName !== void 0 ? PersonName.make(senderName) : void 0,
172419
172616
  senderId: msg.modifiedBy,
172420
172617
  createdOn: msg.createdOn,
@@ -172427,8 +172624,9 @@ var listChannelMessages = (params) => Effect_exports.gen(function* () {
172427
172624
  });
172428
172625
  var sendChannelMessage = (params) => Effect_exports.gen(function* () {
172429
172626
  const { channel, client } = yield* findChannel(params.channel);
172627
+ const markupUrlConfig = client.markupUrlConfig;
172430
172628
  const messageId = (0, import_core21.generateId)();
172431
- const markup = markdownToMarkupString(params.body);
172629
+ const markup = markdownToMarkupString(params.body, markupUrlConfig);
172432
172630
  const messageData = {
172433
172631
  message: markup,
172434
172632
  attachments: 0
@@ -172502,6 +172700,7 @@ var listInlineComments = (params) => Effect_exports.gen(function* () {
172502
172700
  teamspace: params.teamspace,
172503
172701
  document: params.document
172504
172702
  });
172703
+ const markupUrlConfig = client.markupUrlConfig;
172505
172704
  if (!doc.content) {
172506
172705
  return { comments: [], total: 0 };
172507
172706
  }
@@ -172549,7 +172748,7 @@ var listInlineComments = (params) => Effect_exports.gen(function* () {
172549
172748
  const threadReplies = threadRepliesMap.get(comment.threadId) ?? [];
172550
172749
  const replies = threadReplies.map((r) => ({
172551
172750
  id: r._id,
172552
- body: optionalMarkupToMarkdown(r.message),
172751
+ body: optionalMarkupToMarkdown(r.message, markupUrlConfig, ""),
172553
172752
  sender: r.createdBy !== void 0 ? nameMap.get(r.createdBy) : void 0,
172554
172753
  createdOn: r.createdOn
172555
172754
  }));
@@ -172772,6 +172971,22 @@ var getDocument = (params) => Effect_exports.gen(function* () {
172772
172971
  var createDocument = (params) => Effect_exports.gen(function* () {
172773
172972
  const { client, teamspace } = yield* findTeamspace(params.teamspace);
172774
172973
  const documentId = (0, import_core23.generateId)();
172974
+ const parent = params.parent;
172975
+ const parentRef = parent === void 0 ? documentPlugin.ids.NoParent : yield* Effect_exports.gen(function* () {
172976
+ const parentDoc = yield* findByNameOrId(
172977
+ client,
172978
+ documentPlugin.class.Document,
172979
+ { space: teamspace._id, title: parent },
172980
+ { space: teamspace._id, _id: toRef(parent) }
172981
+ );
172982
+ if (parentDoc === void 0) {
172983
+ return yield* new DocumentNotFoundError({
172984
+ identifier: parent,
172985
+ teamspace: params.teamspace
172986
+ });
172987
+ }
172988
+ return parentDoc._id;
172989
+ });
172775
172990
  const lastDoc = yield* client.findOne(
172776
172991
  documentPlugin.class.Document,
172777
172992
  { space: teamspace._id },
@@ -172788,7 +173003,7 @@ var createDocument = (params) => Effect_exports.gen(function* () {
172788
173003
  const documentData = {
172789
173004
  title: params.title,
172790
173005
  content: contentMarkupRef,
172791
- parent: documentPlugin.ids.NoParent,
173006
+ parent: parentRef,
172792
173007
  rank
172793
173008
  };
172794
173009
  yield* client.createDoc(
@@ -175076,6 +175291,9 @@ var CreateDocumentParamsSchema = Schema_exports.Struct({
175076
175291
  }),
175077
175292
  content: Schema_exports.optional(Schema_exports.String.annotations({
175078
175293
  description: "Document content (markdown supported)"
175294
+ })),
175295
+ parent: Schema_exports.optional(DocumentIdentifier.annotations({
175296
+ description: "Parent document title or ID to nest this document under. If omitted, creates a top-level document."
175079
175297
  }))
175080
175298
  }).annotations({
175081
175299
  title: "CreateDocumentParams",
@@ -175594,6 +175812,114 @@ var CreateOrganizationParamsSchema = Schema_exports.Struct({
175594
175812
  title: "CreateOrganizationParams",
175595
175813
  description: "Parameters for creating an organization"
175596
175814
  });
175815
+ var GetOrganizationParamsSchema = Schema_exports.Struct({
175816
+ identifier: NonEmptyString2.annotations({
175817
+ description: "Organization ID or exact name"
175818
+ })
175819
+ }).annotations({
175820
+ title: "GetOrganizationParams",
175821
+ description: "Parameters for getting a single organization"
175822
+ });
175823
+ var UpdateOrganizationParamsSchema = Schema_exports.Struct({
175824
+ identifier: NonEmptyString2.annotations({
175825
+ description: "Organization ID or exact name"
175826
+ }),
175827
+ name: Schema_exports.optional(NonEmptyString2.annotations({
175828
+ description: "New organization name"
175829
+ })),
175830
+ city: Schema_exports.optional(
175831
+ Schema_exports.NullOr(Schema_exports.String).annotations({
175832
+ description: "New city (null to clear)"
175833
+ })
175834
+ ),
175835
+ description: Schema_exports.optional(
175836
+ Schema_exports.NullOr(Schema_exports.String).annotations({
175837
+ description: "New description/notes (null to clear). Supports multi-line plain text."
175838
+ })
175839
+ )
175840
+ }).annotations({
175841
+ title: "UpdateOrganizationParams",
175842
+ description: "Update fields on an existing organization. Only provided fields are modified."
175843
+ });
175844
+ var DeleteOrganizationParamsSchema = Schema_exports.Struct({
175845
+ identifier: NonEmptyString2.annotations({
175846
+ description: "Organization ID or exact name"
175847
+ })
175848
+ }).annotations({
175849
+ title: "DeleteOrganizationParams",
175850
+ description: "Parameters for deleting an organization"
175851
+ });
175852
+ var ListOrganizationMembersParamsSchema = Schema_exports.Struct({
175853
+ organizationId: NonEmptyString2.annotations({
175854
+ description: "Organization ID or exact name"
175855
+ })
175856
+ }).annotations({
175857
+ title: "ListOrganizationMembersParams",
175858
+ description: "List persons who are members of an organization"
175859
+ });
175860
+ var ListPersonOrganizationsByIdSchema = Schema_exports.Struct({
175861
+ personId: PersonId.annotations({
175862
+ description: "Person ID"
175863
+ })
175864
+ });
175865
+ var ListPersonOrganizationsByEmailSchema = Schema_exports.Struct({
175866
+ email: Email.annotations({
175867
+ description: "Person email address"
175868
+ })
175869
+ });
175870
+ var ListPersonOrganizationsParamsSchema = Schema_exports.Union(
175871
+ ListPersonOrganizationsByIdSchema,
175872
+ ListPersonOrganizationsByEmailSchema
175873
+ ).annotations({
175874
+ title: "ListPersonOrganizationsParams",
175875
+ description: "List organizations a person is a member of (provide personId or email)"
175876
+ });
175877
+ var RemoveOrganizationMemberParamsSchema = Schema_exports.Struct({
175878
+ organizationId: NonEmptyString2.annotations({
175879
+ description: "Organization ID or exact name"
175880
+ }),
175881
+ personIdentifier: NonEmptyString2.annotations({
175882
+ description: "Person ID or email address to unlink from the organization"
175883
+ })
175884
+ }).annotations({
175885
+ title: "RemoveOrganizationMemberParams",
175886
+ description: "Parameters for removing a person from an organization"
175887
+ });
175888
+ var AddOrganizationChannelParamsSchema = Schema_exports.Struct({
175889
+ organizationId: NonEmptyString2.annotations({
175890
+ description: "Organization ID or exact name"
175891
+ }),
175892
+ provider: NonEmptyString2.annotations({
175893
+ description: "Channel type: email, phone, linkedin, twitter, github, facebook, telegram, homepage"
175894
+ }),
175895
+ value: NonEmptyString2.annotations({
175896
+ description: "Channel value (email address, phone number, URL, username)"
175897
+ })
175898
+ }).annotations({
175899
+ title: "AddOrganizationChannelParams",
175900
+ description: "Parameters for adding a contact channel to an organization"
175901
+ });
175902
+ var AddOrganizationMemberParamsSchema = Schema_exports.Struct({
175903
+ organizationId: NonEmptyString2.annotations({
175904
+ description: "Organization ID or exact name"
175905
+ }),
175906
+ personIdentifier: NonEmptyString2.annotations({
175907
+ description: "Person ID or email address"
175908
+ })
175909
+ }).annotations({
175910
+ title: "AddOrganizationMemberParams",
175911
+ description: "Parameters for adding a person as an organization member"
175912
+ });
175913
+ var addOrganizationChannelParamsJsonSchema = JSONSchema_exports.make(AddOrganizationChannelParamsSchema);
175914
+ var addOrganizationMemberParamsJsonSchema = JSONSchema_exports.make(AddOrganizationMemberParamsSchema);
175915
+ var parseAddOrganizationChannelParams = Schema_exports.decodeUnknown(AddOrganizationChannelParamsSchema);
175916
+ var parseAddOrganizationMemberParams = Schema_exports.decodeUnknown(AddOrganizationMemberParamsSchema);
175917
+ var listOrganizationMembersParamsJsonSchema = JSONSchema_exports.make(ListOrganizationMembersParamsSchema);
175918
+ var listPersonOrganizationsParamsJsonSchema = JSONSchema_exports.make(ListPersonOrganizationsParamsSchema);
175919
+ var removeOrganizationMemberParamsJsonSchema = JSONSchema_exports.make(RemoveOrganizationMemberParamsSchema);
175920
+ var parseListOrganizationMembersParams = Schema_exports.decodeUnknown(ListOrganizationMembersParamsSchema);
175921
+ var parseListPersonOrganizationsParams = Schema_exports.decodeUnknown(ListPersonOrganizationsParamsSchema);
175922
+ var parseRemoveOrganizationMemberParams = Schema_exports.decodeUnknown(RemoveOrganizationMemberParamsSchema);
175597
175923
  var listPersonsParamsJsonSchema = JSONSchema_exports.make(ListPersonsParamsSchema);
175598
175924
  var getPersonParamsJsonSchema = JSONSchema_exports.make(GetPersonParamsSchema);
175599
175925
  var createPersonParamsJsonSchema = JSONSchema_exports.make(CreatePersonParamsSchema);
@@ -175602,6 +175928,9 @@ var deletePersonParamsJsonSchema = JSONSchema_exports.make(DeletePersonParamsSch
175602
175928
  var listEmployeesParamsJsonSchema = JSONSchema_exports.make(ListEmployeesParamsSchema);
175603
175929
  var listOrganizationsParamsJsonSchema = JSONSchema_exports.make(ListOrganizationsParamsSchema);
175604
175930
  var createOrganizationParamsJsonSchema = JSONSchema_exports.make(CreateOrganizationParamsSchema);
175931
+ var getOrganizationParamsJsonSchema = JSONSchema_exports.make(GetOrganizationParamsSchema);
175932
+ var updateOrganizationParamsJsonSchema = JSONSchema_exports.make(UpdateOrganizationParamsSchema);
175933
+ var deleteOrganizationParamsJsonSchema = JSONSchema_exports.make(DeleteOrganizationParamsSchema);
175605
175934
  var parseListPersonsParams = Schema_exports.decodeUnknown(ListPersonsParamsSchema);
175606
175935
  var parseGetPersonParams = Schema_exports.decodeUnknown(GetPersonParamsSchema);
175607
175936
  var parseCreatePersonParams = Schema_exports.decodeUnknown(CreatePersonParamsSchema);
@@ -175610,6 +175939,9 @@ var parseDeletePersonParams = Schema_exports.decodeUnknown(DeletePersonParamsSch
175610
175939
  var parseListEmployeesParams = Schema_exports.decodeUnknown(ListEmployeesParamsSchema);
175611
175940
  var parseListOrganizationsParams = Schema_exports.decodeUnknown(ListOrganizationsParamsSchema);
175612
175941
  var parseCreateOrganizationParams = Schema_exports.decodeUnknown(CreateOrganizationParamsSchema);
175942
+ var parseGetOrganizationParams = Schema_exports.decodeUnknown(GetOrganizationParamsSchema);
175943
+ var parseUpdateOrganizationParams = Schema_exports.decodeUnknown(UpdateOrganizationParamsSchema);
175944
+ var parseDeleteOrganizationParams = Schema_exports.decodeUnknown(DeleteOrganizationParamsSchema);
175613
175945
 
175614
175946
  // src/domain/schemas/channels.ts
175615
175947
  var ListChannelsParamsBase = Schema_exports.Struct({
@@ -177265,6 +177597,7 @@ var findReply = (client, channel, message, replyId) => Effect_exports.gen(functi
177265
177597
  });
177266
177598
  var listThreadReplies = (params) => Effect_exports.gen(function* () {
177267
177599
  const { channel, client, message } = yield* findMessage(params.channel, params.messageId);
177600
+ const markupUrlConfig = client.markupUrlConfig;
177268
177601
  const limit = Math.min(params.limit ?? 50, 200);
177269
177602
  const replies = yield* client.findAll(
177270
177603
  chunter.class.ThreadMessage,
@@ -177290,7 +177623,7 @@ var listThreadReplies = (params) => Effect_exports.gen(function* () {
177290
177623
  const senderName = socialIdToName.get(msg.modifiedBy);
177291
177624
  return {
177292
177625
  id: ThreadReplyId.make(msg._id),
177293
- body: markupToMarkdownString(msg.message),
177626
+ body: markupToMarkdownString(msg.message, markupUrlConfig),
177294
177627
  sender: senderName !== void 0 ? PersonName.make(senderName) : void 0,
177295
177628
  senderId: msg.modifiedBy,
177296
177629
  createdOn: msg.createdOn,
@@ -177302,8 +177635,9 @@ var listThreadReplies = (params) => Effect_exports.gen(function* () {
177302
177635
  });
177303
177636
  var addThreadReply = (params) => Effect_exports.gen(function* () {
177304
177637
  const { channel, client, message } = yield* findMessage(params.channel, params.messageId);
177638
+ const markupUrlConfig = client.markupUrlConfig;
177305
177639
  const replyId = (0, import_core28.generateId)();
177306
- const markup = markdownToMarkupString(params.body);
177640
+ const markup = markdownToMarkupString(params.body, markupUrlConfig);
177307
177641
  const replyData = {
177308
177642
  message: markup,
177309
177643
  attachments: 0,
@@ -177328,7 +177662,8 @@ var addThreadReply = (params) => Effect_exports.gen(function* () {
177328
177662
  var updateThreadReply = (params) => Effect_exports.gen(function* () {
177329
177663
  const { channel, client, message } = yield* findMessage(params.channel, params.messageId);
177330
177664
  const reply = yield* findReply(client, channel, message, params.replyId);
177331
- const markup = markdownToMarkupString(params.body);
177665
+ const markupUrlConfig = client.markupUrlConfig;
177666
+ const markup = markdownToMarkupString(params.body, markupUrlConfig);
177332
177667
  const now2 = yield* Clock_exports.currentTimeMillis;
177333
177668
  const updateOps = {
177334
177669
  message: markup,
@@ -177519,6 +177854,7 @@ var listComments = (params) => Effect_exports.gen(function* () {
177519
177854
  project: params.project,
177520
177855
  issueIdentifier: params.issueIdentifier
177521
177856
  });
177857
+ const markupUrlConfig = client.markupUrlConfig;
177522
177858
  const limit = clampLimit(params.limit);
177523
177859
  const messages = yield* client.findAll(
177524
177860
  chunter.class.ChatMessage,
@@ -177536,7 +177872,7 @@ var listComments = (params) => Effect_exports.gen(function* () {
177536
177872
  const validated = yield* Schema_exports.decodeUnknown(Schema_exports.Array(CommentSchema))(
177537
177873
  messages.map((msg) => ({
177538
177874
  id: msg._id,
177539
- body: optionalMarkupToMarkdown(msg.message),
177875
+ body: optionalMarkupToMarkdown(msg.message, markupUrlConfig, ""),
177540
177876
  authorId: msg.modifiedBy,
177541
177877
  createdOn: msg.createdOn,
177542
177878
  modifiedOn: msg.modifiedOn,
@@ -177557,9 +177893,10 @@ var addComment = (params) => Effect_exports.gen(function* () {
177557
177893
  project: params.project,
177558
177894
  issueIdentifier: params.issueIdentifier
177559
177895
  });
177896
+ const markupUrlConfig = client.markupUrlConfig;
177560
177897
  const commentId = (0, import_core29.generateId)();
177561
177898
  const commentData = {
177562
- message: markdownToMarkupString(params.body)
177899
+ message: markdownToMarkupString(params.body, markupUrlConfig)
177563
177900
  };
177564
177901
  yield* client.addCollection(
177565
177902
  chunter.class.ChatMessage,
@@ -177577,7 +177914,8 @@ var addComment = (params) => Effect_exports.gen(function* () {
177577
177914
  });
177578
177915
  var updateComment = (params) => Effect_exports.gen(function* () {
177579
177916
  const { client, comment, issue: issue2, project: project3 } = yield* findComment(params);
177580
- const newMarkup = markdownToMarkupString(params.body);
177917
+ const markupUrlConfig = client.markupUrlConfig;
177918
+ const newMarkup = markdownToMarkupString(params.body, markupUrlConfig);
177581
177919
  if (newMarkup === comment.message) {
177582
177920
  return {
177583
177921
  commentId: CommentId.make(params.commentId),
@@ -177668,6 +178006,21 @@ var commentTools = [
177668
178006
  // src/huly/operations/contacts.ts
177669
178007
  var import_contact = __toESM(require_lib27(), 1);
177670
178008
  var import_core30 = __toESM(require_lib4(), 1);
178009
+
178010
+ // src/huly/lead-plugin.ts
178011
+ var leadRef = (identifier2) => identifier2;
178012
+ var leadMixinRef = (identifier2) => identifier2;
178013
+ var leadClassIds = {
178014
+ class: {
178015
+ Lead: leadRef("lead:class:Lead"),
178016
+ Funnel: leadRef("lead:class:Funnel")
178017
+ },
178018
+ mixin: {
178019
+ Customer: leadMixinRef("lead:mixin:Customer")
178020
+ }
178021
+ };
178022
+
178023
+ // src/huly/operations/contacts.ts
177671
178024
  var formatName = (firstName, lastName) => `${lastName},${firstName}`;
177672
178025
  var parseName = (name) => {
177673
178026
  const parts2 = name.split(",");
@@ -177780,6 +178133,7 @@ var getPerson = (params) => Effect_exports.gen(function* () {
177780
178133
  attachedToClass: contact.class.Person
177781
178134
  }
177782
178135
  );
178136
+ const organizations = yield* findOrganizationsForPerson(client, person._id);
177783
178137
  const { firstName, lastName } = parseName(person.name);
177784
178138
  const emailChannel = channels.find((c) => c.provider === contact.channelProvider.Email);
177785
178139
  return {
@@ -177793,10 +178147,29 @@ var getPerson = (params) => Effect_exports.gen(function* () {
177793
178147
  provider: ContactProvider.make(c.provider),
177794
178148
  value: c.value
177795
178149
  })),
178150
+ organizations: organizations.length > 0 ? organizations : void 0,
177796
178151
  modifiedOn: person.modifiedOn,
177797
178152
  createdOn: person.createdOn
177798
178153
  };
177799
178154
  });
178155
+ var findOrganizationsForPerson = (client, personId) => Effect_exports.gen(function* () {
178156
+ const members = yield* client.findAll(
178157
+ contact.class.Member,
178158
+ { contact: personId }
178159
+ );
178160
+ if (members.length === 0) {
178161
+ return [];
178162
+ }
178163
+ const orgIds = [...new Set(members.map((m) => toRef(m.attachedTo)))];
178164
+ const orgs = yield* client.findAll(
178165
+ contact.class.Organization,
178166
+ { _id: { $in: orgIds } }
178167
+ );
178168
+ return orgs.map((org) => ({
178169
+ id: OrganizationId.make(org._id),
178170
+ name: org.name
178171
+ }));
178172
+ });
177800
178173
  var createPerson = (params) => Effect_exports.gen(function* () {
177801
178174
  const client = yield* HulyClient;
177802
178175
  const personId = (0, import_core30.generateId)();
@@ -177914,6 +178287,7 @@ var listOrganizations = (params) => Effect_exports.gen(function* () {
177914
178287
  var createOrganization = (params) => Effect_exports.gen(function* () {
177915
178288
  const client = yield* HulyClient;
177916
178289
  const orgId = (0, import_core30.generateId)();
178290
+ const memberPersonIds = params.members !== void 0 && params.members.length > 0 ? yield* resolvePersonIdentifiers(client, params.members) : [];
177917
178291
  const orgData = {
177918
178292
  name: params.name,
177919
178293
  city: "",
@@ -177927,23 +178301,279 @@ var createOrganization = (params) => Effect_exports.gen(function* () {
177927
178301
  orgData,
177928
178302
  orgId
177929
178303
  );
177930
- if (params.members !== void 0 && params.members.length > 0) {
177931
- for (const memberRef of params.members) {
177932
- const personId = (yield* findPersonById(client, memberRef))?._id ?? (yield* findPersonByEmail(client, memberRef))?._id;
177933
- if (personId !== void 0) {
177934
- yield* client.addCollection(
177935
- contact.class.Member,
177936
- contact.space.Contacts,
177937
- orgId,
177938
- contact.class.Organization,
177939
- "members",
177940
- { contact: personId }
177941
- );
177942
- }
178304
+ if (memberPersonIds.length > 0) {
178305
+ for (const personId of memberPersonIds) {
178306
+ yield* client.addCollection(
178307
+ contact.class.Member,
178308
+ contact.space.Contacts,
178309
+ orgId,
178310
+ contact.class.Organization,
178311
+ "members",
178312
+ { contact: personId }
178313
+ );
177943
178314
  }
177944
178315
  }
177945
178316
  return { id: OrganizationId.make(orgId) };
177946
178317
  });
178318
+ var findOrganizationByIdentifier = (client, identifier2) => Effect_exports.gen(function* () {
178319
+ const byId = yield* client.findOne(
178320
+ contact.class.Organization,
178321
+ { _id: toRef(identifier2) }
178322
+ );
178323
+ if (byId !== void 0) return byId;
178324
+ const byName = yield* client.findAll(
178325
+ contact.class.Organization,
178326
+ { name: identifier2 }
178327
+ );
178328
+ if (byName.length === 0) {
178329
+ return void 0;
178330
+ }
178331
+ if (byName.length > 1) {
178332
+ return yield* new OrganizationIdentifierAmbiguousError({
178333
+ identifier: identifier2,
178334
+ matches: byName.length
178335
+ });
178336
+ }
178337
+ return byName[0];
178338
+ });
178339
+ var resolvePersonIdentifier = (client, identifier2) => Effect_exports.gen(function* () {
178340
+ const person = (yield* findPersonById(client, identifier2)) ?? (yield* findPersonByEmail(client, identifier2));
178341
+ if (person === void 0) {
178342
+ return yield* new PersonNotFoundError({ identifier: identifier2 });
178343
+ }
178344
+ return person;
178345
+ });
178346
+ var uniqueValues = (values4) => Array.from(new Set(values4));
178347
+ var resolvePersonIdentifiers = (client, identifiers) => Effect_exports.gen(function* () {
178348
+ const resolvedPeople = [];
178349
+ for (const identifier2 of identifiers) {
178350
+ resolvedPeople.push(yield* resolvePersonIdentifier(client, identifier2));
178351
+ }
178352
+ return uniqueValues(resolvedPeople.map((person) => person._id));
178353
+ });
178354
+ var findOrganizationMemberships = (client, organizationId, personId) => client.findAll(
178355
+ contact.class.Member,
178356
+ { attachedTo: organizationId, contact: personId }
178357
+ );
178358
+ var getOrganization = (params) => Effect_exports.gen(function* () {
178359
+ const client = yield* HulyClient;
178360
+ const org = yield* findOrganizationByIdentifier(client, params.identifier);
178361
+ if (org === void 0) {
178362
+ return yield* new OrganizationNotFoundError({ identifier: params.identifier });
178363
+ }
178364
+ const descriptionText = org.description !== null ? yield* client.fetchMarkup(
178365
+ contact.class.Organization,
178366
+ org._id,
178367
+ "description",
178368
+ org.description,
178369
+ "markdown"
178370
+ ) : void 0;
178371
+ return {
178372
+ id: OrganizationId.make(org._id),
178373
+ name: org.name,
178374
+ city: org.city || void 0,
178375
+ description: descriptionText,
178376
+ members: org.members,
178377
+ modifiedOn: org.modifiedOn
178378
+ };
178379
+ });
178380
+ var updateOrganization = (params) => Effect_exports.gen(function* () {
178381
+ const client = yield* HulyClient;
178382
+ const org = yield* findOrganizationByIdentifier(client, params.identifier);
178383
+ if (org === void 0) {
178384
+ return yield* new OrganizationNotFoundError({ identifier: params.identifier });
178385
+ }
178386
+ const updateOps = {};
178387
+ let descriptionUpdatedInPlace = false;
178388
+ if (params.name !== void 0) {
178389
+ updateOps.name = params.name;
178390
+ }
178391
+ if (params.city !== void 0) {
178392
+ updateOps.city = params.city === null ? "" : params.city;
178393
+ }
178394
+ if (params.description !== void 0) {
178395
+ if (params.description === null || params.description === "") {
178396
+ updateOps.description = null;
178397
+ } else if (org.description !== null) {
178398
+ yield* client.updateMarkup(
178399
+ contact.class.Organization,
178400
+ org._id,
178401
+ "description",
178402
+ params.description,
178403
+ "markdown"
178404
+ );
178405
+ descriptionUpdatedInPlace = true;
178406
+ } else {
178407
+ const markupRef = yield* client.uploadMarkup(
178408
+ contact.class.Organization,
178409
+ org._id,
178410
+ "description",
178411
+ params.description,
178412
+ "markdown"
178413
+ );
178414
+ updateOps.description = markupRef;
178415
+ }
178416
+ }
178417
+ if (Object.keys(updateOps).length === 0 && !descriptionUpdatedInPlace) {
178418
+ return { id: OrganizationId.make(org._id), updated: false };
178419
+ }
178420
+ yield* client.updateDoc(
178421
+ contact.class.Organization,
178422
+ contact.space.Contacts,
178423
+ org._id,
178424
+ updateOps
178425
+ );
178426
+ return { id: OrganizationId.make(org._id), updated: true };
178427
+ });
178428
+ var deleteOrganization = (params) => Effect_exports.gen(function* () {
178429
+ const client = yield* HulyClient;
178430
+ const org = yield* findOrganizationByIdentifier(client, params.identifier);
178431
+ if (org === void 0) {
178432
+ return yield* new OrganizationNotFoundError({ identifier: params.identifier });
178433
+ }
178434
+ yield* client.removeDoc(
178435
+ contact.class.Organization,
178436
+ contact.space.Contacts,
178437
+ org._id
178438
+ );
178439
+ return { id: OrganizationId.make(org._id), deleted: true };
178440
+ });
178441
+ var makeOrganizationCustomer = (params) => Effect_exports.gen(function* () {
178442
+ const client = yield* HulyClient;
178443
+ const org = yield* findOrganizationByIdentifier(client, params.identifier);
178444
+ if (org === void 0) {
178445
+ return yield* new OrganizationNotFoundError({ identifier: params.identifier });
178446
+ }
178447
+ const alreadyCustomer = org[leadClassIds.mixin.Customer] !== void 0;
178448
+ if (alreadyCustomer) {
178449
+ return { id: OrganizationId.make(org._id), applied: false };
178450
+ }
178451
+ yield* client.createMixin(
178452
+ org._id,
178453
+ contact.class.Organization,
178454
+ contact.space.Contacts,
178455
+ leadClassIds.mixin.Customer,
178456
+ {}
178457
+ );
178458
+ return { id: OrganizationId.make(org._id), applied: true };
178459
+ });
178460
+ var CHANNEL_PROVIDERS = {
178461
+ email: contact.channelProvider.Email,
178462
+ phone: contact.channelProvider.Phone,
178463
+ linkedin: contact.channelProvider.LinkedIn,
178464
+ twitter: contact.channelProvider.Twitter,
178465
+ github: contact.channelProvider.GitHub,
178466
+ facebook: contact.channelProvider.Facebook,
178467
+ telegram: contact.channelProvider.Telegram,
178468
+ homepage: contact.channelProvider.Homepage
178469
+ };
178470
+ var addOrganizationChannel = (params) => Effect_exports.gen(function* () {
178471
+ const client = yield* HulyClient;
178472
+ const org = yield* findOrganizationByIdentifier(client, params.organizationId);
178473
+ if (org === void 0) {
178474
+ return yield* new OrganizationNotFoundError({ identifier: params.organizationId });
178475
+ }
178476
+ const providerKey = params.provider.toLowerCase();
178477
+ const providerRef = CHANNEL_PROVIDERS[providerKey] ?? void 0;
178478
+ if (providerRef === void 0) {
178479
+ return yield* new InvalidContactProviderError({ provider: params.provider });
178480
+ }
178481
+ yield* client.addCollection(
178482
+ contact.class.Channel,
178483
+ contact.space.Contacts,
178484
+ org._id,
178485
+ contact.class.Organization,
178486
+ "channels",
178487
+ { provider: providerRef, value: params.value }
178488
+ );
178489
+ return { id: OrganizationId.make(org._id), added: true };
178490
+ });
178491
+ var addOrganizationMember = (params) => Effect_exports.gen(function* () {
178492
+ const client = yield* HulyClient;
178493
+ const org = yield* findOrganizationByIdentifier(client, params.organizationId);
178494
+ if (org === void 0) {
178495
+ return yield* new OrganizationNotFoundError({ identifier: params.organizationId });
178496
+ }
178497
+ const person = yield* resolvePersonIdentifier(client, params.personIdentifier);
178498
+ const existingMemberships = yield* findOrganizationMemberships(client, org._id, person._id);
178499
+ if (existingMemberships.length > 0) {
178500
+ return { id: OrganizationId.make(org._id), added: false };
178501
+ }
178502
+ yield* client.addCollection(
178503
+ contact.class.Member,
178504
+ contact.space.Contacts,
178505
+ org._id,
178506
+ contact.class.Organization,
178507
+ "members",
178508
+ { contact: person._id }
178509
+ );
178510
+ return { id: OrganizationId.make(org._id), added: true };
178511
+ });
178512
+ var listOrganizationMembers = (params) => Effect_exports.gen(function* () {
178513
+ const client = yield* HulyClient;
178514
+ const org = yield* findOrganizationByIdentifier(client, params.organizationId);
178515
+ if (org === void 0) {
178516
+ return yield* new OrganizationNotFoundError({ identifier: params.organizationId });
178517
+ }
178518
+ const members = yield* client.findAll(
178519
+ contact.class.Member,
178520
+ { attachedTo: org._id }
178521
+ );
178522
+ if (members.length === 0) {
178523
+ return { organizationId: OrganizationId.make(org._id), members: [] };
178524
+ }
178525
+ const personIds = [...new Set(members.map((m) => toRef(m.contact)))];
178526
+ const persons = yield* client.findAll(
178527
+ contact.class.Person,
178528
+ { _id: { $in: personIds } }
178529
+ );
178530
+ const emails = yield* batchGetEmailsForPersons(client, personIds);
178531
+ const entries2 = persons.map((p) => {
178532
+ const email3 = emails.get(p._id);
178533
+ return {
178534
+ personId: PersonId.make(p._id),
178535
+ name: PersonName.make(p.name),
178536
+ email: email3 !== void 0 ? Email.make(email3) : void 0
178537
+ };
178538
+ });
178539
+ return {
178540
+ organizationId: OrganizationId.make(org._id),
178541
+ members: entries2
178542
+ };
178543
+ });
178544
+ var listPersonOrganizations = (params) => Effect_exports.gen(function* () {
178545
+ const client = yield* HulyClient;
178546
+ const person = "personId" in params ? yield* findPersonById(client, params.personId) : yield* findPersonByEmail(client, params.email);
178547
+ if (person === void 0) {
178548
+ const identifier2 = "personId" in params ? params.personId : params.email;
178549
+ return yield* new PersonNotFoundError({ identifier: identifier2 });
178550
+ }
178551
+ const organizations = yield* findOrganizationsForPerson(client, person._id);
178552
+ return {
178553
+ personId: PersonId.make(person._id),
178554
+ organizations
178555
+ };
178556
+ });
178557
+ var removeOrganizationMember = (params) => Effect_exports.gen(function* () {
178558
+ const client = yield* HulyClient;
178559
+ const org = yield* findOrganizationByIdentifier(client, params.organizationId);
178560
+ if (org === void 0) {
178561
+ return yield* new OrganizationNotFoundError({ identifier: params.organizationId });
178562
+ }
178563
+ const person = yield* resolvePersonIdentifier(client, params.personIdentifier);
178564
+ const memberDocs = yield* findOrganizationMemberships(client, org._id, person._id);
178565
+ if (memberDocs.length === 0) {
178566
+ return { id: OrganizationId.make(org._id), removed: false };
178567
+ }
178568
+ for (const memberDoc of memberDocs) {
178569
+ yield* client.removeDoc(
178570
+ contact.class.Member,
178571
+ contact.space.Contacts,
178572
+ memberDoc._id
178573
+ );
178574
+ }
178575
+ return { id: OrganizationId.make(org._id), removed: true };
178576
+ });
177947
178577
 
177948
178578
  // src/mcp/tools/contacts.ts
177949
178579
  var CATEGORY7 = "contacts";
@@ -178027,7 +178657,7 @@ var contactTools = [
178027
178657
  },
178028
178658
  {
178029
178659
  name: "create_organization",
178030
- description: "Create a new organization in Huly. Optionally add members by person ID or email. Returns the created organization ID.",
178660
+ description: "Create a new organization in Huly. Optionally add members by person ID or email. Fails if any requested member cannot be resolved. Returns the created organization ID.",
178031
178661
  category: CATEGORY7,
178032
178662
  inputSchema: createOrganizationParamsJsonSchema,
178033
178663
  handler: createToolHandler(
@@ -178035,6 +178665,105 @@ var contactTools = [
178035
178665
  parseCreateOrganizationParams,
178036
178666
  createOrganization
178037
178667
  )
178668
+ },
178669
+ {
178670
+ name: "get_organization",
178671
+ description: "Retrieve full details for an organization by ID or exact name when that name is unique - including city, description, member count, and modification timestamp. If multiple organizations share the same name, use the organization ID.",
178672
+ category: CATEGORY7,
178673
+ inputSchema: getOrganizationParamsJsonSchema,
178674
+ handler: createToolHandler(
178675
+ "get_organization",
178676
+ parseGetOrganizationParams,
178677
+ getOrganization
178678
+ )
178679
+ },
178680
+ {
178681
+ name: "update_organization",
178682
+ description: "Update fields on an existing organization identified by ID or exact name when that name is unique. Only provided fields are modified. Description supports multi-line plain text and is the right place to store CRM notes / revenue summaries / context. Pass null to clear city or description. If multiple organizations share the same name, use the organization ID.",
178683
+ category: CATEGORY7,
178684
+ inputSchema: updateOrganizationParamsJsonSchema,
178685
+ handler: createToolHandler(
178686
+ "update_organization",
178687
+ parseUpdateOrganizationParams,
178688
+ updateOrganization
178689
+ )
178690
+ },
178691
+ {
178692
+ name: "delete_organization",
178693
+ description: "Permanently delete an organization identified by ID or exact name when that name is unique. Use with care - this cannot be undone. Useful for cleaning up duplicate organizations after merging their data elsewhere. If multiple organizations share the same name, use the organization ID.",
178694
+ category: CATEGORY7,
178695
+ inputSchema: deleteOrganizationParamsJsonSchema,
178696
+ handler: createToolHandler(
178697
+ "delete_organization",
178698
+ parseDeleteOrganizationParams,
178699
+ deleteOrganization
178700
+ )
178701
+ },
178702
+ {
178703
+ name: "make_organization_customer",
178704
+ description: "Apply the Customer mixin to an organization so it appears in the Huly Leads > Customers view. Idempotent - safe to call on organizations that are already customers. Takes the organization ID or exact name when that name is unique.",
178705
+ category: CATEGORY7,
178706
+ inputSchema: getOrganizationParamsJsonSchema,
178707
+ handler: createToolHandler(
178708
+ "make_organization_customer",
178709
+ parseGetOrganizationParams,
178710
+ makeOrganizationCustomer
178711
+ )
178712
+ },
178713
+ {
178714
+ name: "add_organization_channel",
178715
+ description: "Add a contact channel (phone, email, website/homepage, LinkedIn, Twitter, GitHub, Facebook, Telegram) to an organization identified by ID or exact unique name. Provider names: email, phone, linkedin, twitter, github, facebook, telegram, homepage.",
178716
+ category: CATEGORY7,
178717
+ inputSchema: addOrganizationChannelParamsJsonSchema,
178718
+ handler: createToolHandler(
178719
+ "add_organization_channel",
178720
+ parseAddOrganizationChannelParams,
178721
+ addOrganizationChannel
178722
+ )
178723
+ },
178724
+ {
178725
+ name: "add_organization_member",
178726
+ description: "Link a person as a member of an organization. The person appears under the org's Members tab in Huly. Use person ID or email to identify the person. Idempotent: returns added=false if that person is already a member.",
178727
+ category: CATEGORY7,
178728
+ inputSchema: addOrganizationMemberParamsJsonSchema,
178729
+ handler: createToolHandler(
178730
+ "add_organization_member",
178731
+ parseAddOrganizationMemberParams,
178732
+ addOrganizationMember
178733
+ )
178734
+ },
178735
+ {
178736
+ name: "list_organization_members",
178737
+ description: "List all persons who are members of an organization. Returns each member's person ID, name, and primary email (if any). When using a name instead of an ID, that name must identify exactly one organization.",
178738
+ category: CATEGORY7,
178739
+ inputSchema: listOrganizationMembersParamsJsonSchema,
178740
+ handler: createToolHandler(
178741
+ "list_organization_members",
178742
+ parseListOrganizationMembersParams,
178743
+ listOrganizationMembers
178744
+ )
178745
+ },
178746
+ {
178747
+ name: "list_person_organizations",
178748
+ description: "List all organizations that a person is a member of. Provide personId or email. Returns each organization's ID and name.",
178749
+ category: CATEGORY7,
178750
+ inputSchema: listPersonOrganizationsParamsJsonSchema,
178751
+ handler: createToolHandler(
178752
+ "list_person_organizations",
178753
+ parseListPersonOrganizationsParams,
178754
+ listPersonOrganizations
178755
+ )
178756
+ },
178757
+ {
178758
+ name: "remove_organization_member",
178759
+ description: "Unlink a person from an organization's members. Reverses add_organization_member. Returns removed: false if the person was not a member. When using an organization name instead of an ID, that name must identify exactly one organization.",
178760
+ category: CATEGORY7,
178761
+ inputSchema: removeOrganizationMemberParamsJsonSchema,
178762
+ handler: createToolHandler(
178763
+ "remove_organization_member",
178764
+ parseRemoveOrganizationMemberParams,
178765
+ removeOrganizationMember
178766
+ )
178038
178767
  }
178039
178768
  ];
178040
178769
 
@@ -178345,11 +179074,12 @@ var listComponents = (params) => Effect_exports.gen(function* () {
178345
179074
  });
178346
179075
  var getComponent = (params) => Effect_exports.gen(function* () {
178347
179076
  const { client, component } = yield* findProjectAndComponent(params);
179077
+ const markupUrlConfig = client.markupUrlConfig;
178348
179078
  const leadName = component.lead !== null ? (yield* client.findOne(contact.class.Person, { _id: component.lead }))?.name : void 0;
178349
179079
  const result = {
178350
179080
  id: ComponentId.make(component._id),
178351
179081
  label: ComponentLabel.make(component.label),
178352
- description: optionalMarkupToMarkdown(component.description, void 0),
179082
+ description: optionalMarkupToMarkdown(component.description, markupUrlConfig, void 0),
178353
179083
  lead: leadName !== void 0 ? PersonName.make(leadName) : void 0,
178354
179084
  project: params.project,
178355
179085
  modifiedOn: component.modifiedOn,
@@ -178359,9 +179089,10 @@ var getComponent = (params) => Effect_exports.gen(function* () {
178359
179089
  });
178360
179090
  var createComponent = (params) => Effect_exports.gen(function* () {
178361
179091
  const { client, project: project3 } = yield* findProject(params.project);
179092
+ const markupUrlConfig = client.markupUrlConfig;
178362
179093
  const componentId = (0, import_core32.generateId)();
178363
179094
  const leadParam = params.lead;
178364
- const leadRef = leadParam !== void 0 ? yield* Effect_exports.gen(function* () {
179095
+ const leadRef2 = leadParam !== void 0 ? yield* Effect_exports.gen(function* () {
178365
179096
  const person = yield* findPersonByEmailOrName(client, leadParam);
178366
179097
  if (person === void 0) {
178367
179098
  return yield* new PersonNotFoundError({ identifier: leadParam });
@@ -178370,8 +179101,8 @@ var createComponent = (params) => Effect_exports.gen(function* () {
178370
179101
  }) : null;
178371
179102
  const componentData = {
178372
179103
  label: params.label,
178373
- description: optionalMarkdownToMarkup(params.description),
178374
- lead: leadRef,
179104
+ description: optionalMarkdownToMarkup(params.description, markupUrlConfig, ""),
179105
+ lead: leadRef2,
178375
179106
  comments: 0
178376
179107
  };
178377
179108
  yield* client.createDoc(
@@ -178384,12 +179115,13 @@ var createComponent = (params) => Effect_exports.gen(function* () {
178384
179115
  });
178385
179116
  var updateComponent = (params) => Effect_exports.gen(function* () {
178386
179117
  const { client, component, project: project3 } = yield* findProjectAndComponent(params);
179118
+ const markupUrlConfig = client.markupUrlConfig;
178387
179119
  const updateOps = {};
178388
179120
  if (params.label !== void 0) {
178389
179121
  updateOps.label = params.label;
178390
179122
  }
178391
179123
  if (params.description !== void 0) {
178392
- updateOps.description = optionalMarkdownToMarkup(params.description);
179124
+ updateOps.description = optionalMarkdownToMarkup(params.description, markupUrlConfig, "");
178393
179125
  }
178394
179126
  if (params.lead !== void 0) {
178395
179127
  if (params.lead === null) {
@@ -179552,7 +180284,7 @@ var findProjectAndTemplate = (params) => Effect_exports.gen(function* () {
179552
180284
  }
179553
180285
  return { client, project: project3, template };
179554
180286
  });
179555
- var resolveChild = (client, child) => Effect_exports.gen(function* () {
180287
+ var resolveChild = (client, markupUrlConfig, child) => Effect_exports.gen(function* () {
179556
180288
  const assigneeName = child.assignee !== null ? (yield* client.findOne(contact.class.Person, { _id: child.assignee }))?.name : void 0;
179557
180289
  const componentLabel = child.component !== null ? (yield* client.findOne(tracker.class.Component, { _id: child.component }))?.label : void 0;
179558
180290
  const base = {
@@ -179560,14 +180292,14 @@ var resolveChild = (client, child) => Effect_exports.gen(function* () {
179560
180292
  title: child.title,
179561
180293
  priority: priorityToString(child.priority)
179562
180294
  };
179563
- const withDescription3 = child.description ? { ...base, description: optionalMarkupToMarkdown(child.description) } : base;
180295
+ const withDescription3 = child.description ? { ...base, description: optionalMarkupToMarkdown(child.description, markupUrlConfig, "") } : base;
179564
180296
  const withAssignee = assigneeName !== void 0 ? { ...withDescription3, assignee: PersonName.make(assigneeName) } : withDescription3;
179565
180297
  const withComponent = componentLabel !== void 0 ? { ...withAssignee, component: ComponentLabel.make(componentLabel) } : withAssignee;
179566
180298
  const estimation = zeroAsUnset(NonNegativeNumber.make(child.estimation));
179567
180299
  const result = estimation !== void 0 ? { ...withComponent, estimation } : withComponent;
179568
180300
  return result;
179569
180301
  });
179570
- var buildTemplateChild = (client, projectId, projectIdentifier, input) => Effect_exports.gen(function* () {
180302
+ var buildTemplateChild = (client, markupUrlConfig, projectId, projectIdentifier, input) => Effect_exports.gen(function* () {
179571
180303
  const assigneeParam = input.assignee;
179572
180304
  const assigneeRef = assigneeParam !== void 0 ? yield* Effect_exports.gen(function* () {
179573
180305
  const person = yield* findPersonByEmailOrName(client, assigneeParam);
@@ -179590,7 +180322,7 @@ var buildTemplateChild = (client, projectId, projectIdentifier, input) => Effect
179590
180322
  return {
179591
180323
  id: (0, import_core36.generateId)(),
179592
180324
  title: input.title,
179593
- description: optionalMarkdownToMarkup(input.description),
180325
+ description: optionalMarkdownToMarkup(input.description, markupUrlConfig, ""),
179594
180326
  priority: stringToPriority(input.priority || "no-priority"),
179595
180327
  assignee: assigneeRef,
179596
180328
  component: componentRef,
@@ -179624,16 +180356,17 @@ var listIssueTemplates = (params) => Effect_exports.gen(function* () {
179624
180356
  });
179625
180357
  var getIssueTemplate = (params) => Effect_exports.gen(function* () {
179626
180358
  const { client, template } = yield* findProjectAndTemplate(params);
180359
+ const markupUrlConfig = client.markupUrlConfig;
179627
180360
  const assigneeName = template.assignee !== null ? (yield* client.findOne(contact.class.Person, { _id: template.assignee }))?.name : void 0;
179628
180361
  const componentLabel = template.component !== null ? (yield* client.findOne(tracker.class.Component, { _id: template.component }))?.label : void 0;
179629
180362
  const resolvedChildren = [];
179630
180363
  for (const child of template.children) {
179631
- resolvedChildren.push(yield* resolveChild(client, child));
180364
+ resolvedChildren.push(yield* resolveChild(client, markupUrlConfig, child));
179632
180365
  }
179633
180366
  const result = {
179634
180367
  id: IssueTemplateId.make(template._id),
179635
180368
  title: template.title,
179636
- description: optionalMarkupToMarkdown(template.description),
180369
+ description: optionalMarkupToMarkdown(template.description, markupUrlConfig, ""),
179637
180370
  priority: priorityToString(template.priority),
179638
180371
  assignee: assigneeName !== void 0 ? PersonName.make(assigneeName) : void 0,
179639
180372
  component: componentLabel !== void 0 ? ComponentLabel.make(componentLabel) : void 0,
@@ -179649,6 +180382,7 @@ var getIssueTemplate = (params) => Effect_exports.gen(function* () {
179649
180382
  });
179650
180383
  var createIssueTemplate = (params) => Effect_exports.gen(function* () {
179651
180384
  const { client, project: project3 } = yield* findProject(params.project);
180385
+ const markupUrlConfig = client.markupUrlConfig;
179652
180386
  const templateId = (0, import_core36.generateId)();
179653
180387
  const assigneeParam = params.assignee;
179654
180388
  const assigneeRef = assigneeParam !== void 0 ? yield* Effect_exports.gen(function* () {
@@ -179673,12 +180407,12 @@ var createIssueTemplate = (params) => Effect_exports.gen(function* () {
179673
180407
  const children = [];
179674
180408
  if (params.children !== void 0) {
179675
180409
  for (const childInput of params.children) {
179676
- children.push(yield* buildTemplateChild(client, project3._id, params.project, childInput));
180410
+ children.push(yield* buildTemplateChild(client, markupUrlConfig, project3._id, params.project, childInput));
179677
180411
  }
179678
180412
  }
179679
180413
  const templateData = {
179680
180414
  title: params.title,
179681
- description: optionalMarkdownToMarkup(params.description),
180415
+ description: optionalMarkdownToMarkup(params.description, markupUrlConfig, ""),
179682
180416
  priority,
179683
180417
  assignee: assigneeRef,
179684
180418
  component: componentRef,
@@ -179696,8 +180430,9 @@ var createIssueTemplate = (params) => Effect_exports.gen(function* () {
179696
180430
  });
179697
180431
  var createIssueFromTemplate = (params) => Effect_exports.gen(function* () {
179698
180432
  const { client, project: project3, template } = yield* findProjectAndTemplate(params);
180433
+ const markupUrlConfig = client.markupUrlConfig;
179699
180434
  const title = params.title ?? template.title;
179700
- const description = params.description ?? optionalMarkupToMarkdown(template.description, void 0);
180435
+ const description = params.description ?? optionalMarkupToMarkdown(template.description, markupUrlConfig, void 0);
179701
180436
  const priority = params.priority ?? priorityToString(template.priority);
179702
180437
  const templateAssigneeRef = template.assignee;
179703
180438
  const assignee = params.assignee !== void 0 ? params.assignee : templateAssigneeRef !== null ? yield* Effect_exports.gen(function* () {
@@ -179737,7 +180472,7 @@ var createIssueFromTemplate = (params) => Effect_exports.gen(function* () {
179737
180472
  const includeChildren = params.includeChildren !== false;
179738
180473
  if (includeChildren && template.children.length > 0) {
179739
180474
  for (const child of template.children) {
179740
- const childDescription = optionalMarkupToMarkdown(child.description, void 0);
180475
+ const childDescription = optionalMarkupToMarkdown(child.description, markupUrlConfig, void 0);
179741
180476
  const childResult = yield* createIssue({
179742
180477
  project: params.project,
179743
180478
  title: child.title,
@@ -179776,12 +180511,13 @@ var createIssueFromTemplate = (params) => Effect_exports.gen(function* () {
179776
180511
  });
179777
180512
  var updateIssueTemplate = (params) => Effect_exports.gen(function* () {
179778
180513
  const { client, project: project3, template } = yield* findProjectAndTemplate(params);
180514
+ const markupUrlConfig = client.markupUrlConfig;
179779
180515
  const updateOps = {};
179780
180516
  if (params.title !== void 0) {
179781
180517
  updateOps.title = params.title;
179782
180518
  }
179783
180519
  if (params.description !== void 0) {
179784
- updateOps.description = optionalMarkdownToMarkup(params.description);
180520
+ updateOps.description = optionalMarkdownToMarkup(params.description, markupUrlConfig, "");
179785
180521
  }
179786
180522
  if (params.priority !== void 0) {
179787
180523
  updateOps.priority = stringToPriority(params.priority);
@@ -179836,7 +180572,8 @@ var deleteIssueTemplate = (params) => Effect_exports.gen(function* () {
179836
180572
  });
179837
180573
  var addTemplateChild = (params) => Effect_exports.gen(function* () {
179838
180574
  const { client, project: project3, template } = yield* findProjectAndTemplate(params);
179839
- const child = yield* buildTemplateChild(client, project3._id, params.project, {
180575
+ const markupUrlConfig = client.markupUrlConfig;
180576
+ const child = yield* buildTemplateChild(client, markupUrlConfig, project3._id, params.project, {
179840
180577
  title: params.title,
179841
180578
  description: params.description,
179842
180579
  priority: params.priority,
@@ -180495,8 +181232,266 @@ var labelTools = [
180495
181232
  }
180496
181233
  ];
180497
181234
 
180498
- // src/huly/operations/milestones.ts
181235
+ // src/huly/operations/leads.ts
180499
181236
  var import_core39 = __toESM(require_lib4(), 1);
181237
+ var funnelAsSpace = (funnel) => toRef(funnel._id);
181238
+ var markupBlobRefAsMarkupRef = (value3) => value3;
181239
+ var normalizeLeadIdentifier = (identifier2) => {
181240
+ const match16 = /^(?:LEAD-)?(\d+)$/i.exec(identifier2.trim());
181241
+ return match16 !== null ? `LEAD-${match16[1]}` : identifier2.trim().toUpperCase();
181242
+ };
181243
+ var SORT_LEFT_BEFORE_RIGHT = -1;
181244
+ var SORT_RIGHT_BEFORE_LEFT = 1;
181245
+ var compareFunnelsByRecency = (left3, right3) => {
181246
+ if (left3.archived !== right3.archived) {
181247
+ return left3.archived ? SORT_RIGHT_BEFORE_LEFT : SORT_LEFT_BEFORE_RIGHT;
181248
+ }
181249
+ return right3.modifiedOn - left3.modifiedOn;
181250
+ };
181251
+ var findFunnel = (client, funnelIdentifier) => Effect_exports.gen(function* () {
181252
+ const byId = yield* client.findOne(
181253
+ leadClassIds.class.Funnel,
181254
+ { _id: toRef(funnelIdentifier) }
181255
+ );
181256
+ if (byId !== void 0) return byId;
181257
+ const allFunnels = yield* client.findAll(leadClassIds.class.Funnel, {});
181258
+ const normalized = normalizeForComparison(funnelIdentifier);
181259
+ const matchingFunnels = [...allFunnels].filter((candidate) => normalizeForComparison(candidate.name) === normalized).sort(compareFunnelsByRecency);
181260
+ const funnel = matchingFunnels.at(0);
181261
+ if (funnel === void 0) {
181262
+ return yield* new FunnelNotFoundError({ identifier: funnelIdentifier });
181263
+ }
181264
+ return funnel;
181265
+ });
181266
+ var getFunnelStatuses = (client, funnel) => Effect_exports.gen(function* () {
181267
+ if (funnel.type === void 0) {
181268
+ return yield* Effect_exports.fail(
181269
+ new HulyConnectionError({
181270
+ message: `Funnel '${funnel._id}' is missing its ProjectType reference`
181271
+ })
181272
+ );
181273
+ }
181274
+ const projectType = yield* client.findOne(
181275
+ task.class.ProjectType,
181276
+ { _id: toRef(funnel.type) }
181277
+ );
181278
+ if (projectType?.statuses === void 0) {
181279
+ return yield* Effect_exports.fail(
181280
+ new HulyConnectionError({
181281
+ message: `Funnel '${funnel._id}' references a ProjectType without statuses`
181282
+ })
181283
+ );
181284
+ }
181285
+ const statusRefs = projectType.statuses.map((status) => status._id);
181286
+ if (statusRefs.length === 0) {
181287
+ return yield* Effect_exports.fail(
181288
+ new HulyConnectionError({
181289
+ message: `Funnel '${funnel._id}' ProjectType has no statuses`
181290
+ })
181291
+ );
181292
+ }
181293
+ const statusDocs = yield* client.findAll(
181294
+ core.class.Status,
181295
+ { _id: { $in: [...statusRefs] } }
181296
+ );
181297
+ return statusDocs.map((doc) => ({
181298
+ _id: doc._id,
181299
+ name: doc.name
181300
+ }));
181301
+ });
181302
+ var resolveStatusName2 = (statuses, statusId) => {
181303
+ const statusDoc = statuses.find((status) => status._id === statusId);
181304
+ return statusDoc !== void 0 ? Effect_exports.succeed(StatusName.make(statusDoc.name)) : Effect_exports.fail(
181305
+ new HulyConnectionError({
181306
+ message: `Lead references status '${statusId}', but that status is not defined on the funnel ProjectType`
181307
+ })
181308
+ );
181309
+ };
181310
+ var resolveStatusByName2 = (statuses, statusName, funnel) => {
181311
+ const normalizedInput = normalizeForComparison(statusName);
181312
+ const matchingStatus = statuses.find(
181313
+ (status) => normalizeForComparison(status.name) === normalizedInput
181314
+ );
181315
+ if (matchingStatus === void 0) {
181316
+ return Effect_exports.fail(new InvalidStatusError({ status: statusName, project: funnel }));
181317
+ }
181318
+ return Effect_exports.succeed(matchingStatus._id);
181319
+ };
181320
+ var findCustomer = (client, customerId) => Effect_exports.gen(function* () {
181321
+ const contactCustomer = yield* client.findOne(contact.class.Contact, { _id: customerId });
181322
+ if (contactCustomer !== void 0) {
181323
+ return contactCustomer;
181324
+ }
181325
+ return yield* client.findOne(contact.class.Organization, {
181326
+ _id: toRef(customerId)
181327
+ });
181328
+ });
181329
+ var listFunnels = (params) => Effect_exports.gen(function* () {
181330
+ const client = yield* HulyClient;
181331
+ const query = params.includeArchived !== true ? { archived: false } : {};
181332
+ const limit = clampLimit(params.limit);
181333
+ const funnels = yield* client.findAll(
181334
+ leadClassIds.class.Funnel,
181335
+ query,
181336
+ {
181337
+ limit,
181338
+ sort: { name: import_core39.SortingOrder.Ascending }
181339
+ }
181340
+ );
181341
+ const summaries = funnels.map((funnel) => ({
181342
+ identifier: FunnelIdentifier.make(funnel._id),
181343
+ name: funnel.name,
181344
+ description: funnel.description,
181345
+ archived: funnel.archived
181346
+ }));
181347
+ return { funnels: summaries, total: funnels.total };
181348
+ });
181349
+ var listLeads = (params) => Effect_exports.gen(function* () {
181350
+ const client = yield* HulyClient;
181351
+ const funnel = yield* findFunnel(client, params.funnel);
181352
+ const statuses = yield* getFunnelStatuses(client, funnel);
181353
+ const baseQuery = {
181354
+ space: funnelAsSpace(funnel)
181355
+ };
181356
+ const statusFilter = params.status !== void 0 ? { status: yield* resolveStatusByName2(statuses, params.status, params.funnel) } : {};
181357
+ const assigneeParam = params.assignee;
181358
+ const assigneeFilter = assigneeParam !== void 0 ? yield* Effect_exports.gen(function* () {
181359
+ const assigneePerson = yield* findPersonByEmailOrName(client, assigneeParam);
181360
+ return assigneePerson !== void 0 ? { assignee: assigneePerson._id } : void 0;
181361
+ }) : {};
181362
+ if (assigneeFilter === void 0) return [];
181363
+ const titleFilter = params.titleSearch !== void 0 && params.titleSearch.trim() !== "" ? { title: { $like: `%${escapeLikeWildcards(params.titleSearch)}%` } } : {};
181364
+ const query = {
181365
+ ...baseQuery,
181366
+ ...statusFilter,
181367
+ ...assigneeFilter,
181368
+ ...titleFilter
181369
+ };
181370
+ const limit = clampLimit(params.limit);
181371
+ const leads = yield* client.findAll(
181372
+ leadClassIds.class.Lead,
181373
+ query,
181374
+ {
181375
+ limit,
181376
+ sort: { modifiedOn: import_core39.SortingOrder.Descending },
181377
+ // Upstream lead views resolve attachedTo through the Customer mixin.
181378
+ // Reference:
181379
+ // https://github.com/hcengineering/platform/blob/b9657d53d130a2ed8034c1b71ab0cf8b7a0b4994/models/lead/src/index.ts#L357-L360
181380
+ lookup: {
181381
+ assignee: contact.class.Person,
181382
+ attachedTo: leadClassIds.mixin.Customer
181383
+ }
181384
+ }
181385
+ );
181386
+ const rawSummaries = yield* Effect_exports.forEach(leads, (lead) => Effect_exports.gen(function* () {
181387
+ const status = yield* resolveStatusName2(statuses, lead.status);
181388
+ return {
181389
+ identifier: lead.identifier,
181390
+ title: lead.title,
181391
+ status,
181392
+ assignee: lead.$lookup?.assignee?.name,
181393
+ customer: lead.$lookup?.attachedTo?.name,
181394
+ modifiedOn: lead.modifiedOn
181395
+ };
181396
+ }));
181397
+ const validated = yield* Schema_exports.decodeUnknown(Schema_exports.Array(LeadSummarySchema))(rawSummaries).pipe(
181398
+ Effect_exports.mapError(
181399
+ (parseError2) => new HulyConnectionError({
181400
+ message: `listLeads response failed schema validation: ${parseError2.message}`,
181401
+ cause: parseError2
181402
+ })
181403
+ )
181404
+ );
181405
+ return [...validated];
181406
+ });
181407
+ var getLead = (params) => Effect_exports.gen(function* () {
181408
+ const client = yield* HulyClient;
181409
+ const funnel = yield* findFunnel(client, params.funnel);
181410
+ const statuses = yield* getFunnelStatuses(client, funnel);
181411
+ const leadIdentifier = yield* Schema_exports.decodeUnknown(LeadIdentifier)(normalizeLeadIdentifier(params.identifier)).pipe(
181412
+ Effect_exports.orDie
181413
+ );
181414
+ const lead = yield* client.findOne(
181415
+ leadClassIds.class.Lead,
181416
+ { space: funnelAsSpace(funnel), identifier: leadIdentifier }
181417
+ );
181418
+ if (lead === void 0) {
181419
+ return yield* new LeadNotFoundError({
181420
+ identifier: params.identifier,
181421
+ funnel: FunnelIdentifier.make(funnel._id)
181422
+ });
181423
+ }
181424
+ const status = yield* resolveStatusName2(statuses, lead.status);
181425
+ const person = lead.assignee !== null ? yield* client.findOne(contact.class.Person, { _id: lead.assignee }) : void 0;
181426
+ const customer = yield* findCustomer(client, toRef(lead.attachedTo));
181427
+ const description = lead.description ? yield* client.fetchMarkup(
181428
+ leadClassIds.class.Lead,
181429
+ lead._id,
181430
+ "description",
181431
+ markupBlobRefAsMarkupRef(lead.description),
181432
+ "markdown"
181433
+ ) : void 0;
181434
+ return yield* parseLeadDetail({
181435
+ identifier: lead.identifier,
181436
+ title: lead.title,
181437
+ description,
181438
+ status,
181439
+ assignee: person?.name,
181440
+ customer: customer?.name,
181441
+ funnel: funnel._id,
181442
+ funnelName: funnel.name,
181443
+ modifiedOn: lead.modifiedOn,
181444
+ createdOn: lead.createdOn
181445
+ }).pipe(
181446
+ Effect_exports.mapError(
181447
+ (parseError2) => new HulyConnectionError({
181448
+ message: `getLead response failed schema validation: ${parseError2.message}`,
181449
+ cause: parseError2
181450
+ })
181451
+ )
181452
+ );
181453
+ });
181454
+
181455
+ // src/mcp/tools/leads.ts
181456
+ var CATEGORY13 = "leads";
181457
+ var leadTools = [
181458
+ {
181459
+ name: "list_funnels",
181460
+ description: "List all Huly sales funnels (lead pipelines). Returns each funnel's stable ID and display name, sorted by name. Supports filtering by archived status.",
181461
+ category: CATEGORY13,
181462
+ inputSchema: listFunnelsParamsJsonSchema,
181463
+ handler: createToolHandler(
181464
+ "list_funnels",
181465
+ parseListFunnelsParams,
181466
+ listFunnels
181467
+ )
181468
+ },
181469
+ {
181470
+ name: "list_leads",
181471
+ description: "Query Huly leads in a funnel with optional filters. Pass the funnel ID returned by list_funnels, or a funnel name for convenience lookup. Returns leads sorted by modification date (newest first). Supports filtering by status, assignee, and title search.",
181472
+ category: CATEGORY13,
181473
+ inputSchema: listLeadsParamsJsonSchema,
181474
+ handler: createToolHandler(
181475
+ "list_leads",
181476
+ parseListLeadsParams,
181477
+ listLeads
181478
+ )
181479
+ },
181480
+ {
181481
+ name: "get_lead",
181482
+ description: "Retrieve full details for a Huly lead including markdown description, customer name, funnel ID and funnel name, and status. Lead identifiers follow the upstream Huly format like 'LEAD-1'.",
181483
+ category: CATEGORY13,
181484
+ inputSchema: getLeadParamsJsonSchema,
181485
+ handler: createToolHandler(
181486
+ "get_lead",
181487
+ parseGetLeadParams,
181488
+ getLead
181489
+ )
181490
+ }
181491
+ ];
181492
+
181493
+ // src/huly/operations/milestones.ts
181494
+ var import_core40 = __toESM(require_lib4(), 1);
180500
181495
  var import_tracker5 = __toESM(require_lib21(), 1);
180501
181496
  var milestoneStatusToStringMap = {
180502
181497
  [import_tracker5.MilestoneStatus.Planned]: "planned",
@@ -180540,7 +181535,7 @@ var listMilestones = (params) => Effect_exports.gen(function* () {
180540
181535
  { space: project3._id },
180541
181536
  {
180542
181537
  limit,
180543
- sort: { modifiedOn: import_core39.SortingOrder.Descending }
181538
+ sort: { modifiedOn: import_core40.SortingOrder.Descending }
180544
181539
  }
180545
181540
  );
180546
181541
  const summaries = milestones.map((m) => ({
@@ -180553,11 +181548,12 @@ var listMilestones = (params) => Effect_exports.gen(function* () {
180553
181548
  return summaries;
180554
181549
  });
180555
181550
  var getMilestone = (params) => Effect_exports.gen(function* () {
180556
- const { milestone } = yield* findProjectAndMilestone(params);
181551
+ const { client, milestone } = yield* findProjectAndMilestone(params);
181552
+ const markupUrlConfig = client.markupUrlConfig;
180557
181553
  const result = {
180558
181554
  id: MilestoneId.make(milestone._id),
180559
181555
  label: MilestoneLabel.make(milestone.label),
180560
- description: optionalMarkupToMarkdown(milestone.description),
181556
+ description: optionalMarkupToMarkdown(milestone.description, markupUrlConfig, ""),
180561
181557
  status: milestoneStatusToString(milestone.status),
180562
181558
  targetDate: milestone.targetDate,
180563
181559
  project: params.project,
@@ -180568,10 +181564,11 @@ var getMilestone = (params) => Effect_exports.gen(function* () {
180568
181564
  });
180569
181565
  var createMilestone = (params) => Effect_exports.gen(function* () {
180570
181566
  const { client, project: project3 } = yield* findProject(params.project);
180571
- const milestoneId = (0, import_core39.generateId)();
181567
+ const markupUrlConfig = client.markupUrlConfig;
181568
+ const milestoneId = (0, import_core40.generateId)();
180572
181569
  const milestoneData = {
180573
181570
  label: params.label,
180574
- description: optionalMarkdownToMarkup(params.description),
181571
+ description: optionalMarkdownToMarkup(params.description, markupUrlConfig, ""),
180575
181572
  status: import_tracker5.MilestoneStatus.Planned,
180576
181573
  targetDate: params.targetDate,
180577
181574
  comments: 0
@@ -180595,6 +181592,7 @@ var createMilestone = (params) => Effect_exports.gen(function* () {
180595
181592
  });
180596
181593
  var updateMilestone = (params) => Effect_exports.gen(function* () {
180597
181594
  const { client, milestone, project: project3 } = yield* findProjectAndMilestone(params);
181595
+ const markupUrlConfig = client.markupUrlConfig;
180598
181596
  const updateOps = {};
180599
181597
  if (params.label !== void 0) {
180600
181598
  updateOps.label = params.label;
@@ -180609,7 +181607,7 @@ var updateMilestone = (params) => Effect_exports.gen(function* () {
180609
181607
  "markdown"
180610
181608
  );
180611
181609
  }
180612
- updateOps.description = optionalMarkdownToMarkup(params.description);
181610
+ updateOps.description = optionalMarkdownToMarkup(params.description, markupUrlConfig, "");
180613
181611
  }
180614
181612
  if (params.targetDate !== void 0) {
180615
181613
  updateOps.targetDate = params.targetDate;
@@ -180650,12 +181648,12 @@ var deleteMilestone = (params) => Effect_exports.gen(function* () {
180650
181648
  });
180651
181649
 
180652
181650
  // src/mcp/tools/milestones.ts
180653
- var CATEGORY13 = "milestones";
181651
+ var CATEGORY14 = "milestones";
180654
181652
  var milestoneTools = [
180655
181653
  {
180656
181654
  name: "list_milestones",
180657
181655
  description: "List milestones in a Huly project. Returns milestones sorted by modification date (newest first).",
180658
- category: CATEGORY13,
181656
+ category: CATEGORY14,
180659
181657
  inputSchema: listMilestonesParamsJsonSchema,
180660
181658
  handler: createToolHandler(
180661
181659
  "list_milestones",
@@ -180666,7 +181664,7 @@ var milestoneTools = [
180666
181664
  {
180667
181665
  name: "get_milestone",
180668
181666
  description: "Retrieve full details for a Huly milestone. Use this to view milestone content and metadata.",
180669
- category: CATEGORY13,
181667
+ category: CATEGORY14,
180670
181668
  inputSchema: getMilestoneParamsJsonSchema,
180671
181669
  handler: createToolHandler(
180672
181670
  "get_milestone",
@@ -180677,7 +181675,7 @@ var milestoneTools = [
180677
181675
  {
180678
181676
  name: "create_milestone",
180679
181677
  description: "Create a new milestone in a Huly project. Returns the created milestone ID and label.",
180680
- category: CATEGORY13,
181678
+ category: CATEGORY14,
180681
181679
  inputSchema: createMilestoneParamsJsonSchema,
180682
181680
  handler: createToolHandler(
180683
181681
  "create_milestone",
@@ -180688,7 +181686,7 @@ var milestoneTools = [
180688
181686
  {
180689
181687
  name: "update_milestone",
180690
181688
  description: "Update fields on an existing Huly milestone. Only provided fields are modified.",
180691
- category: CATEGORY13,
181689
+ category: CATEGORY14,
180692
181690
  inputSchema: updateMilestoneParamsJsonSchema,
180693
181691
  handler: createToolHandler(
180694
181692
  "update_milestone",
@@ -180699,7 +181697,7 @@ var milestoneTools = [
180699
181697
  {
180700
181698
  name: "set_issue_milestone",
180701
181699
  description: "Set or clear the milestone on a Huly issue. Pass null for milestone to clear it.",
180702
- category: CATEGORY13,
181700
+ category: CATEGORY14,
180703
181701
  inputSchema: setIssueMilestoneParamsJsonSchema,
180704
181702
  handler: createToolHandler(
180705
181703
  "set_issue_milestone",
@@ -180710,7 +181708,7 @@ var milestoneTools = [
180710
181708
  {
180711
181709
  name: "delete_milestone",
180712
181710
  description: "Permanently delete a Huly milestone. This action cannot be undone.",
180713
- category: CATEGORY13,
181711
+ category: CATEGORY14,
180714
181712
  inputSchema: deleteMilestoneParamsJsonSchema,
180715
181713
  handler: createToolHandler(
180716
181714
  "delete_milestone",
@@ -180721,7 +181719,7 @@ var milestoneTools = [
180721
181719
  ];
180722
181720
 
180723
181721
  // src/huly/operations/notifications.ts
180724
- var import_core40 = __toESM(require_lib4(), 1);
181722
+ var import_core41 = __toESM(require_lib4(), 1);
180725
181723
  var toDocNotifyContextSummary = (ctx) => ({
180726
181724
  id: NotificationContextId.make(ctx._id),
180727
181725
  objectId: ctx.objectId,
@@ -180767,7 +181765,7 @@ var listNotifications = (params) => Effect_exports.gen(function* () {
180767
181765
  {
180768
181766
  limit,
180769
181767
  sort: {
180770
- modifiedOn: import_core40.SortingOrder.Descending
181768
+ modifiedOn: import_core41.SortingOrder.Descending
180771
181769
  }
180772
181770
  }
180773
181771
  );
@@ -180909,7 +181907,7 @@ var listNotificationContexts = (params) => Effect_exports.gen(function* () {
180909
181907
  {
180910
181908
  limit,
180911
181909
  sort: {
180912
- lastUpdateTimestamp: import_core40.SortingOrder.Descending
181910
+ lastUpdateTimestamp: import_core41.SortingOrder.Descending
180913
181911
  }
180914
181912
  }
180915
181913
  );
@@ -180978,12 +181976,12 @@ var getUnreadNotificationCount = () => Effect_exports.gen(function* () {
180978
181976
  });
180979
181977
 
180980
181978
  // src/mcp/tools/notifications.ts
180981
- var CATEGORY14 = "notifications";
181979
+ var CATEGORY15 = "notifications";
180982
181980
  var notificationTools = [
180983
181981
  {
180984
181982
  name: "list_notifications",
180985
181983
  description: "List inbox notifications. Returns notifications sorted by modification date (newest first). Supports filtering by read/archived status.",
180986
- category: CATEGORY14,
181984
+ category: CATEGORY15,
180987
181985
  inputSchema: listNotificationsParamsJsonSchema,
180988
181986
  handler: createToolHandler(
180989
181987
  "list_notifications",
@@ -180994,7 +181992,7 @@ var notificationTools = [
180994
181992
  {
180995
181993
  name: "get_notification",
180996
181994
  description: "Retrieve full details for a notification. Use this to view notification content and metadata.",
180997
- category: CATEGORY14,
181995
+ category: CATEGORY15,
180998
181996
  inputSchema: getNotificationParamsJsonSchema,
180999
181997
  handler: createToolHandler(
181000
181998
  "get_notification",
@@ -181005,7 +182003,7 @@ var notificationTools = [
181005
182003
  {
181006
182004
  name: "mark_notification_read",
181007
182005
  description: "Mark a notification as read.",
181008
- category: CATEGORY14,
182006
+ category: CATEGORY15,
181009
182007
  inputSchema: markNotificationReadParamsJsonSchema,
181010
182008
  handler: createToolHandler(
181011
182009
  "mark_notification_read",
@@ -181016,7 +182014,7 @@ var notificationTools = [
181016
182014
  {
181017
182015
  name: "mark_all_notifications_read",
181018
182016
  description: "Mark all unread notifications as read. Returns the count of notifications marked.",
181019
- category: CATEGORY14,
182017
+ category: CATEGORY15,
181020
182018
  inputSchema: emptyParamsJsonSchema,
181021
182019
  handler: createToolHandler(
181022
182020
  "mark_all_notifications_read",
@@ -181027,7 +182025,7 @@ var notificationTools = [
181027
182025
  {
181028
182026
  name: "archive_notification",
181029
182027
  description: "Archive a notification. Archived notifications are hidden from the main inbox view.",
181030
- category: CATEGORY14,
182028
+ category: CATEGORY15,
181031
182029
  inputSchema: archiveNotificationParamsJsonSchema,
181032
182030
  handler: createToolHandler(
181033
182031
  "archive_notification",
@@ -181038,7 +182036,7 @@ var notificationTools = [
181038
182036
  {
181039
182037
  name: "archive_all_notifications",
181040
182038
  description: "Archive all notifications. Returns the count of notifications archived.",
181041
- category: CATEGORY14,
182039
+ category: CATEGORY15,
181042
182040
  inputSchema: emptyParamsJsonSchema,
181043
182041
  handler: createToolHandler(
181044
182042
  "archive_all_notifications",
@@ -181049,7 +182047,7 @@ var notificationTools = [
181049
182047
  {
181050
182048
  name: "delete_notification",
181051
182049
  description: "Permanently delete a notification. This action cannot be undone.",
181052
- category: CATEGORY14,
182050
+ category: CATEGORY15,
181053
182051
  inputSchema: deleteNotificationParamsJsonSchema,
181054
182052
  handler: createToolHandler(
181055
182053
  "delete_notification",
@@ -181060,7 +182058,7 @@ var notificationTools = [
181060
182058
  {
181061
182059
  name: "get_notification_context",
181062
182060
  description: "Get notification context for an entity. Returns tracking information for a specific object.",
181063
- category: CATEGORY14,
182061
+ category: CATEGORY15,
181064
182062
  inputSchema: getNotificationContextParamsJsonSchema,
181065
182063
  handler: createToolHandler(
181066
182064
  "get_notification_context",
@@ -181071,7 +182069,7 @@ var notificationTools = [
181071
182069
  {
181072
182070
  name: "list_notification_contexts",
181073
182071
  description: "List notification contexts. Returns contexts sorted by last update timestamp (newest first). Supports filtering by pinned status.",
181074
- category: CATEGORY14,
182072
+ category: CATEGORY15,
181075
182073
  inputSchema: listNotificationContextsParamsJsonSchema,
181076
182074
  handler: createToolHandler(
181077
182075
  "list_notification_contexts",
@@ -181082,7 +182080,7 @@ var notificationTools = [
181082
182080
  {
181083
182081
  name: "pin_notification_context",
181084
182082
  description: "Pin or unpin a notification context. Pinned contexts are highlighted in the inbox.",
181085
- category: CATEGORY14,
182083
+ category: CATEGORY15,
181086
182084
  inputSchema: pinNotificationContextParamsJsonSchema,
181087
182085
  handler: createToolHandler(
181088
182086
  "pin_notification_context",
@@ -181093,7 +182091,7 @@ var notificationTools = [
181093
182091
  {
181094
182092
  name: "list_notification_settings",
181095
182093
  description: "List notification provider settings. Returns current notification preferences.",
181096
- category: CATEGORY14,
182094
+ category: CATEGORY15,
181097
182095
  inputSchema: listNotificationSettingsParamsJsonSchema,
181098
182096
  handler: createToolHandler(
181099
182097
  "list_notification_settings",
@@ -181104,7 +182102,7 @@ var notificationTools = [
181104
182102
  {
181105
182103
  name: "update_notification_provider_setting",
181106
182104
  description: "Update notification provider setting. Enable or disable notifications for a specific provider.",
181107
- category: CATEGORY14,
182105
+ category: CATEGORY15,
181108
182106
  inputSchema: updateNotificationProviderSettingParamsJsonSchema,
181109
182107
  handler: createToolHandler(
181110
182108
  "update_notification_provider_setting",
@@ -181115,7 +182113,7 @@ var notificationTools = [
181115
182113
  {
181116
182114
  name: "get_unread_notification_count",
181117
182115
  description: "Get the count of unread notifications.",
181118
- category: CATEGORY14,
182116
+ category: CATEGORY15,
181119
182117
  inputSchema: emptyParamsJsonSchema,
181120
182118
  handler: createToolHandler(
181121
182119
  "get_unread_notification_count",
@@ -181126,7 +182124,7 @@ var notificationTools = [
181126
182124
  ];
181127
182125
 
181128
182126
  // src/huly/operations/projects.ts
181129
- var import_core41 = __toESM(require_lib4(), 1);
182127
+ var import_core42 = __toESM(require_lib4(), 1);
181130
182128
  var import_tracker6 = __toESM(require_lib21(), 1);
181131
182129
  var listProjects = (params) => Effect_exports.gen(function* () {
181132
182130
  const client = yield* HulyClient;
@@ -181141,7 +182139,7 @@ var listProjects = (params) => Effect_exports.gen(function* () {
181141
182139
  {
181142
182140
  limit,
181143
182141
  sort: {
181144
- name: import_core41.SortingOrder.Ascending
182142
+ name: import_core42.SortingOrder.Ascending
181145
182143
  }
181146
182144
  }
181147
182145
  );
@@ -181210,7 +182208,7 @@ var createProject = (params) => Effect_exports.gen(function* () {
181210
182208
  created: false
181211
182209
  };
181212
182210
  }
181213
- const projectId = (0, import_core41.generateId)();
182211
+ const projectId = (0, import_core42.generateId)();
181214
182212
  const projectData = {
181215
182213
  name: params.name,
181216
182214
  description: params.description ?? "",
@@ -181272,12 +182270,12 @@ var deleteProject = (params) => Effect_exports.gen(function* () {
181272
182270
  });
181273
182271
 
181274
182272
  // src/mcp/tools/projects.ts
181275
- var CATEGORY15 = "projects";
182273
+ var CATEGORY16 = "projects";
181276
182274
  var projectTools = [
181277
182275
  {
181278
182276
  name: "list_projects",
181279
182277
  description: "List all Huly projects. Returns projects sorted by name. Supports filtering by archived status.",
181280
- category: CATEGORY15,
182278
+ category: CATEGORY16,
181281
182279
  inputSchema: listProjectsParamsJsonSchema,
181282
182280
  handler: createToolHandler(
181283
182281
  "list_projects",
@@ -181288,7 +182286,7 @@ var projectTools = [
181288
182286
  {
181289
182287
  name: "get_project",
181290
182288
  description: "Get full details of a Huly project including its statuses. Returns project name, description, archived flag, default status, and all available statuses.",
181291
- category: CATEGORY15,
182289
+ category: CATEGORY16,
181292
182290
  inputSchema: getProjectParamsJsonSchema,
181293
182291
  handler: createToolHandler(
181294
182292
  "get_project",
@@ -181299,7 +182297,7 @@ var projectTools = [
181299
182297
  {
181300
182298
  name: "list_statuses",
181301
182299
  description: "List all issue statuses for a Huly project with category info. Returns status name, isDone, isCanceled, and isDefault flags. Use this to discover valid statuses before creating or updating issues.",
181302
- category: CATEGORY15,
182300
+ category: CATEGORY16,
181303
182301
  inputSchema: listStatusesParamsJsonSchema,
181304
182302
  handler: createToolHandler(
181305
182303
  "list_statuses",
@@ -181310,7 +182308,7 @@ var projectTools = [
181310
182308
  {
181311
182309
  name: "create_project",
181312
182310
  description: "Create a new Huly tracker project. Idempotent: returns existing project if one with the same identifier already exists (created=false). Identifier must be 1-5 uppercase alphanumeric chars starting with a letter.",
181313
- category: CATEGORY15,
182311
+ category: CATEGORY16,
181314
182312
  inputSchema: createProjectParamsJsonSchema,
181315
182313
  handler: createToolHandler(
181316
182314
  "create_project",
@@ -181321,7 +182319,7 @@ var projectTools = [
181321
182319
  {
181322
182320
  name: "update_project",
181323
182321
  description: "Update a Huly project. Only provided fields are modified. Set description to null to clear it.",
181324
- category: CATEGORY15,
182322
+ category: CATEGORY16,
181325
182323
  inputSchema: updateProjectParamsJsonSchema,
181326
182324
  handler: createToolHandler(
181327
182325
  "update_project",
@@ -181332,7 +182330,7 @@ var projectTools = [
181332
182330
  {
181333
182331
  name: "delete_project",
181334
182332
  description: "Permanently delete a Huly project. All issues, milestones, and components in this project will be orphaned. This action cannot be undone.",
181335
- category: CATEGORY15,
182333
+ category: CATEGORY16,
181336
182334
  inputSchema: deleteProjectParamsJsonSchema,
181337
182335
  handler: createToolHandler(
181338
182336
  "delete_project",
@@ -181375,12 +182373,12 @@ var fulltextSearch = (params) => Effect_exports.gen(function* () {
181375
182373
  });
181376
182374
 
181377
182375
  // src/mcp/tools/search.ts
181378
- var CATEGORY16 = "search";
182376
+ var CATEGORY17 = "search";
181379
182377
  var searchTools = [
181380
182378
  {
181381
182379
  name: "fulltext_search",
181382
182380
  description: "Perform a global fulltext search across all Huly content. Searches issues, documents, messages, and other indexed content. Returns matching items sorted by relevance (newest first).",
181383
- category: CATEGORY16,
182381
+ category: CATEGORY17,
181384
182382
  inputSchema: fulltextSearchParamsJsonSchema,
181385
182383
  handler: createToolHandler(
181386
182384
  "fulltext_search",
@@ -181403,12 +182401,12 @@ var uploadFile = (params) => Effect_exports.gen(function* () {
181403
182401
  });
181404
182402
 
181405
182403
  // src/mcp/tools/storage.ts
181406
- var CATEGORY17 = "storage";
182404
+ var CATEGORY18 = "storage";
181407
182405
  var storageTools = [
181408
182406
  {
181409
182407
  name: "upload_file",
181410
182408
  description: "Upload a file to Huly storage. Provide ONE of: filePath (local file - preferred), fileUrl (fetch from URL), or data (base64 - for small files only). Returns blob ID and URL for referencing the file.",
181411
- category: CATEGORY17,
182409
+ category: CATEGORY18,
181412
182410
  inputSchema: uploadFileParamsJsonSchema,
181413
182411
  handler: createStorageToolHandler(
181414
182412
  "upload_file",
@@ -181419,12 +182417,12 @@ var storageTools = [
181419
182417
  ];
181420
182418
 
181421
182419
  // src/mcp/tools/tag-categories.ts
181422
- var CATEGORY18 = "tag-categories";
182420
+ var CATEGORY19 = "tag-categories";
181423
182421
  var tagCategoryTools = [
181424
182422
  {
181425
182423
  name: "list_tag_categories",
181426
182424
  description: "List tag/label categories in the workspace. Categories group labels (e.g., 'Priority Labels', 'Type Labels'). Optional targetClass filter (defaults to all).",
181427
- category: CATEGORY18,
182425
+ category: CATEGORY19,
181428
182426
  inputSchema: listTagCategoriesParamsJsonSchema,
181429
182427
  handler: createToolHandler(
181430
182428
  "list_tag_categories",
@@ -181435,7 +182433,7 @@ var tagCategoryTools = [
181435
182433
  {
181436
182434
  name: "create_tag_category",
181437
182435
  description: "Create a new tag/label category. Idempotent: returns existing category if one with the same label and targetClass already exists (created=false). Defaults targetClass to tracker issues.",
181438
- category: CATEGORY18,
182436
+ category: CATEGORY19,
181439
182437
  inputSchema: createTagCategoryParamsJsonSchema,
181440
182438
  handler: createToolHandler(
181441
182439
  "create_tag_category",
@@ -181446,7 +182444,7 @@ var tagCategoryTools = [
181446
182444
  {
181447
182445
  name: "update_tag_category",
181448
182446
  description: "Update a tag/label category. Accepts category ID or label name. Only provided fields are modified.",
181449
- category: CATEGORY18,
182447
+ category: CATEGORY19,
181450
182448
  inputSchema: updateTagCategoryParamsJsonSchema,
181451
182449
  handler: createToolHandler(
181452
182450
  "update_tag_category",
@@ -181457,7 +182455,7 @@ var tagCategoryTools = [
181457
182455
  {
181458
182456
  name: "delete_tag_category",
181459
182457
  description: "Permanently delete a tag/label category. Accepts category ID or label name. Labels in this category will be orphaned (not deleted). This action cannot be undone.",
181460
- category: CATEGORY18,
182458
+ category: CATEGORY19,
181461
182459
  inputSchema: deleteTagCategoryParamsJsonSchema,
181462
182460
  handler: createToolHandler(
181463
182461
  "delete_tag_category",
@@ -181468,7 +182466,7 @@ var tagCategoryTools = [
181468
182466
  ];
181469
182467
 
181470
182468
  // src/huly/operations/test-management-core.ts
181471
- var import_core42 = __toESM(require_lib4(), 1);
182469
+ var import_core43 = __toESM(require_lib4(), 1);
181472
182470
 
181473
182471
  // src/huly/test-management-classes.ts
181474
182472
  var testManagement = {
@@ -181622,7 +182620,7 @@ var listTestProjects = (params) => Effect_exports.gen(function* () {
181622
182620
  {},
181623
182621
  {
181624
182622
  limit,
181625
- sort: { name: import_core42.SortingOrder.Ascending }
182623
+ sort: { name: import_core43.SortingOrder.Ascending }
181626
182624
  }
181627
182625
  );
181628
182626
  return {
@@ -181644,7 +182642,7 @@ var listTestSuites = (params) => Effect_exports.gen(function* () {
181644
182642
  query,
181645
182643
  {
181646
182644
  limit,
181647
- sort: { modifiedOn: import_core42.SortingOrder.Descending }
182645
+ sort: { modifiedOn: import_core43.SortingOrder.Descending }
181648
182646
  }
181649
182647
  );
181650
182648
  return {
@@ -181677,7 +182675,7 @@ var createTestSuite = (params) => Effect_exports.gen(function* () {
181677
182675
  if (existing !== void 0) {
181678
182676
  return { id: TestSuiteId.make(existing._id), name: existing.name, created: false };
181679
182677
  }
181680
- const suiteId = (0, import_core42.generateId)();
182678
+ const suiteId = (0, import_core43.generateId)();
181681
182679
  const suiteData = {
181682
182680
  name: params.name,
181683
182681
  description: params.description ?? "",
@@ -181747,7 +182745,7 @@ var listTestCases = (params) => Effect_exports.gen(function* () {
181747
182745
  query,
181748
182746
  {
181749
182747
  limit,
181750
- sort: { modifiedOn: import_core42.SortingOrder.Descending }
182748
+ sort: { modifiedOn: import_core43.SortingOrder.Descending }
181751
182749
  }
181752
182750
  );
181753
182751
  return {
@@ -181775,7 +182773,7 @@ var createTestCase = (params) => Effect_exports.gen(function* () {
181775
182773
  const client = yield* HulyClient;
181776
182774
  const project3 = yield* findTestProject(client, params.project);
181777
182775
  const suite = yield* findTestSuite(client, project3, params.suite);
181778
- const caseId = (0, import_core42.generateId)();
182776
+ const caseId = (0, import_core43.generateId)();
181779
182777
  const assigneeRef = params.assignee !== void 0 ? toRef((yield* resolveAssignee2(params.assignee))._id) : null;
181780
182778
  const typeEnum = params.type !== void 0 ? stringToTestCaseType(params.type) ?? 0 /* Functional */ : 0 /* Functional */;
181781
182779
  const priorityEnum = params.priority !== void 0 ? stringToTestCasePriority(params.priority) ?? 1 /* Medium */ : 1 /* Medium */;
@@ -181879,12 +182877,12 @@ var deleteTestCase = (params) => Effect_exports.gen(function* () {
181879
182877
  });
181880
182878
 
181881
182879
  // src/mcp/tools/test-management-core.ts
181882
- var CATEGORY19 = "test-management";
182880
+ var CATEGORY20 = "test-management";
181883
182881
  var testManagementCoreTools = [
181884
182882
  {
181885
182883
  name: "list_test_projects",
181886
182884
  description: "List test management projects. Returns test projects sorted by name. These are separate from tracker projects.",
181887
- category: CATEGORY19,
182885
+ category: CATEGORY20,
181888
182886
  inputSchema: listTestProjectsParamsJsonSchema,
181889
182887
  handler: createToolHandler(
181890
182888
  "list_test_projects",
@@ -181895,7 +182893,7 @@ var testManagementCoreTools = [
181895
182893
  {
181896
182894
  name: "list_test_suites",
181897
182895
  description: "List test suites in a test project. Accepts project ID or name. Optional parent filter for nested suites.",
181898
- category: CATEGORY19,
182896
+ category: CATEGORY20,
181899
182897
  inputSchema: listTestSuitesParamsJsonSchema,
181900
182898
  handler: createToolHandler(
181901
182899
  "list_test_suites",
@@ -181906,7 +182904,7 @@ var testManagementCoreTools = [
181906
182904
  {
181907
182905
  name: "get_test_suite",
181908
182906
  description: "Get a single test suite by ID or name within a test project. Returns suite details and test case count.",
181909
- category: CATEGORY19,
182907
+ category: CATEGORY20,
181910
182908
  inputSchema: getTestSuiteParamsJsonSchema,
181911
182909
  handler: createToolHandler(
181912
182910
  "get_test_suite",
@@ -181917,7 +182915,7 @@ var testManagementCoreTools = [
181917
182915
  {
181918
182916
  name: "create_test_suite",
181919
182917
  description: "Create a test suite in a test project. Idempotent: returns existing suite if one with the same name exists (created=false). Optional parent for nesting.",
181920
- category: CATEGORY19,
182918
+ category: CATEGORY20,
181921
182919
  inputSchema: createTestSuiteParamsJsonSchema,
181922
182920
  handler: createToolHandler(
181923
182921
  "create_test_suite",
@@ -181928,7 +182926,7 @@ var testManagementCoreTools = [
181928
182926
  {
181929
182927
  name: "update_test_suite",
181930
182928
  description: "Update a test suite. Accepts suite ID or name. Only provided fields are modified.",
181931
- category: CATEGORY19,
182929
+ category: CATEGORY20,
181932
182930
  inputSchema: updateTestSuiteParamsJsonSchema,
181933
182931
  handler: createToolHandler(
181934
182932
  "update_test_suite",
@@ -181939,7 +182937,7 @@ var testManagementCoreTools = [
181939
182937
  {
181940
182938
  name: "delete_test_suite",
181941
182939
  description: "Permanently delete a test suite. Accepts suite ID or name. This action cannot be undone.",
181942
- category: CATEGORY19,
182940
+ category: CATEGORY20,
181943
182941
  inputSchema: deleteTestSuiteParamsJsonSchema,
181944
182942
  handler: createToolHandler(
181945
182943
  "delete_test_suite",
@@ -181950,7 +182948,7 @@ var testManagementCoreTools = [
181950
182948
  {
181951
182949
  name: "list_test_cases",
181952
182950
  description: "List test cases in a test project. Optional filters: suite (ID or name), assignee (name or email).",
181953
- category: CATEGORY19,
182951
+ category: CATEGORY20,
181954
182952
  inputSchema: listTestCasesParamsJsonSchema,
181955
182953
  handler: createToolHandler(
181956
182954
  "list_test_cases",
@@ -181961,7 +182959,7 @@ var testManagementCoreTools = [
181961
182959
  {
181962
182960
  name: "get_test_case",
181963
182961
  description: "Get a single test case by ID or name within a test project.",
181964
- category: CATEGORY19,
182962
+ category: CATEGORY20,
181965
182963
  inputSchema: getTestCaseParamsJsonSchema,
181966
182964
  handler: createToolHandler(
181967
182965
  "get_test_case",
@@ -181972,7 +182970,7 @@ var testManagementCoreTools = [
181972
182970
  {
181973
182971
  name: "create_test_case",
181974
182972
  description: "Create a test case attached to a suite. Requires project and suite. Defaults: type=functional, priority=medium, status=draft.",
181975
- category: CATEGORY19,
182973
+ category: CATEGORY20,
181976
182974
  inputSchema: createTestCaseParamsJsonSchema,
181977
182975
  handler: createToolHandler(
181978
182976
  "create_test_case",
@@ -181983,7 +182981,7 @@ var testManagementCoreTools = [
181983
182981
  {
181984
182982
  name: "update_test_case",
181985
182983
  description: "Update a test case. Accepts test case ID or name. Only provided fields are modified. Set assignee to null to unassign.",
181986
- category: CATEGORY19,
182984
+ category: CATEGORY20,
181987
182985
  inputSchema: updateTestCaseParamsJsonSchema,
181988
182986
  handler: createToolHandler(
181989
182987
  "update_test_case",
@@ -181994,7 +182992,7 @@ var testManagementCoreTools = [
181994
182992
  {
181995
182993
  name: "delete_test_case",
181996
182994
  description: "Permanently delete a test case. Accepts test case ID or name. This action cannot be undone.",
181997
- category: CATEGORY19,
182995
+ category: CATEGORY20,
181998
182996
  inputSchema: deleteTestCaseParamsJsonSchema,
181999
182997
  handler: createToolHandler(
182000
182998
  "delete_test_case",
@@ -182005,7 +183003,7 @@ var testManagementCoreTools = [
182005
183003
  ];
182006
183004
 
182007
183005
  // src/huly/operations/test-management-plans.ts
182008
- var import_core43 = __toESM(require_lib4(), 1);
183006
+ var import_core44 = __toESM(require_lib4(), 1);
182009
183007
  var toPlanSummary = (p) => ({
182010
183008
  id: TestPlanId.make(p._id),
182011
183009
  name: p.name
@@ -182023,7 +183021,7 @@ var listTestPlans = (params) => Effect_exports.gen(function* () {
182023
183021
  const plans = yield* client.findAll(
182024
183022
  testManagement.class.TestPlan,
182025
183023
  { space: project3._id },
182026
- { limit, sort: { modifiedOn: import_core43.SortingOrder.Descending } }
183024
+ { limit, sort: { modifiedOn: import_core44.SortingOrder.Descending } }
182027
183025
  );
182028
183026
  return { plans: plans.map(toPlanSummary), total: plans.total };
182029
183027
  });
@@ -182058,7 +183056,7 @@ var createTestPlan = (params) => Effect_exports.gen(function* () {
182058
183056
  if (existing !== void 0) {
182059
183057
  return { id: TestPlanId.make(existing._id), name: existing.name, created: false };
182060
183058
  }
182061
- const planId = (0, import_core43.generateId)();
183059
+ const planId = (0, import_core44.generateId)();
182062
183060
  const descRef = params.description !== void 0 && params.description.trim() !== "" ? yield* client.uploadMarkup(
182063
183061
  testManagement.class.TestPlan,
182064
183062
  planId,
@@ -182140,7 +183138,7 @@ var removeTestPlanItem = (params) => Effect_exports.gen(function* () {
182140
183138
  });
182141
183139
 
182142
183140
  // src/huly/operations/test-management-runs.ts
182143
- var import_core44 = __toESM(require_lib4(), 1);
183141
+ var import_core45 = __toESM(require_lib4(), 1);
182144
183142
  var BATCH_CONCURRENCY = 10;
182145
183143
  var toRunSummary = (r) => ({
182146
183144
  id: TestRunId.make(r._id),
@@ -182161,7 +183159,7 @@ var listTestRuns = (params) => Effect_exports.gen(function* () {
182161
183159
  const runs = yield* client.findAll(
182162
183160
  testManagement.class.TestRun,
182163
183161
  { space: project3._id },
182164
- { limit, sort: { modifiedOn: import_core44.SortingOrder.Descending } }
183162
+ { limit, sort: { modifiedOn: import_core45.SortingOrder.Descending } }
182165
183163
  );
182166
183164
  return { runs: runs.map(toRunSummary), total: runs.total };
182167
183165
  });
@@ -182190,7 +183188,7 @@ var getTestRun = (params) => Effect_exports.gen(function* () {
182190
183188
  var createTestRun = (params) => Effect_exports.gen(function* () {
182191
183189
  const client = yield* HulyClient;
182192
183190
  const project3 = yield* findTestProject(client, params.project);
182193
- const runId = (0, import_core44.generateId)();
183191
+ const runId = (0, import_core45.generateId)();
182194
183192
  const descRef = params.description !== void 0 && params.description.trim() !== "" ? yield* client.uploadMarkup(
182195
183193
  testManagement.class.TestRun,
182196
183194
  runId,
@@ -182247,7 +183245,7 @@ var listTestResults = (params) => Effect_exports.gen(function* () {
182247
183245
  const results = yield* client.findAll(
182248
183246
  testManagement.class.TestResult,
182249
183247
  { attachedTo: run3._id },
182250
- { limit, sort: { modifiedOn: import_core44.SortingOrder.Descending } }
183248
+ { limit, sort: { modifiedOn: import_core45.SortingOrder.Descending } }
182251
183249
  );
182252
183250
  return { results: results.map(toResultSummary), total: results.total };
182253
183251
  });
@@ -182348,7 +183346,7 @@ var runTestPlan = (params) => Effect_exports.gen(function* () {
182348
183346
  }
182349
183347
  return { item, tc };
182350
183348
  }), { concurrency: BATCH_CONCURRENCY });
182351
- const runId = (0, import_core44.generateId)();
183349
+ const runId = (0, import_core45.generateId)();
182352
183350
  const runName = params.runName ?? `${plan.name} - Run`;
182353
183351
  yield* client.createDoc(testManagement.class.TestRun, project3._id, {
182354
183352
  name: runName,
@@ -182378,41 +183376,41 @@ var runTestPlan = (params) => Effect_exports.gen(function* () {
182378
183376
  });
182379
183377
 
182380
183378
  // src/mcp/tools/test-management-plans.ts
182381
- var CATEGORY20 = "test-management";
183379
+ var CATEGORY21 = "test-management";
182382
183380
  var testManagementPlansTools = [
182383
183381
  // --- Test Plans ---
182384
183382
  {
182385
183383
  name: "list_test_plans",
182386
183384
  description: "List test plans in a test management project. Returns plan names and IDs. Requires project ID or name.",
182387
- category: CATEGORY20,
183385
+ category: CATEGORY21,
182388
183386
  inputSchema: listTestPlansParamsJsonSchema,
182389
183387
  handler: createToolHandler("list_test_plans", parseListTestPlansParams, listTestPlans)
182390
183388
  },
182391
183389
  {
182392
183390
  name: "get_test_plan",
182393
183391
  description: "Get test plan details including its items (test cases). Accepts plan ID or name within a project.",
182394
- category: CATEGORY20,
183392
+ category: CATEGORY21,
182395
183393
  inputSchema: getTestPlanParamsJsonSchema,
182396
183394
  handler: createToolHandler("get_test_plan", parseGetTestPlanParams, getTestPlan)
182397
183395
  },
182398
183396
  {
182399
183397
  name: "create_test_plan",
182400
183398
  description: "Create a test plan in a project. Idempotent: returns existing plan if one with the same name exists (created=false).",
182401
- category: CATEGORY20,
183399
+ category: CATEGORY21,
182402
183400
  inputSchema: createTestPlanParamsJsonSchema,
182403
183401
  handler: createToolHandler("create_test_plan", parseCreateTestPlanParams, createTestPlan)
182404
183402
  },
182405
183403
  {
182406
183404
  name: "update_test_plan",
182407
183405
  description: "Update a test plan's name or description. Only provided fields are modified. Pass description=null to clear.",
182408
- category: CATEGORY20,
183406
+ category: CATEGORY21,
182409
183407
  inputSchema: updateTestPlanParamsJsonSchema,
182410
183408
  handler: createToolHandler("update_test_plan", parseUpdateTestPlanParams, updateTestPlan)
182411
183409
  },
182412
183410
  {
182413
183411
  name: "delete_test_plan",
182414
183412
  description: "Permanently delete a test plan. This does not delete associated test runs. Cannot be undone.",
182415
- category: CATEGORY20,
183413
+ category: CATEGORY21,
182416
183414
  inputSchema: deleteTestPlanParamsJsonSchema,
182417
183415
  handler: createToolHandler("delete_test_plan", parseDeleteTestPlanParams, deleteTestPlan)
182418
183416
  },
@@ -182420,14 +183418,14 @@ var testManagementPlansTools = [
182420
183418
  {
182421
183419
  name: "add_test_plan_item",
182422
183420
  description: "Add a test case to a test plan. Resolves test case by ID or name. Optionally assign a person by email or name.",
182423
- category: CATEGORY20,
183421
+ category: CATEGORY21,
182424
183422
  inputSchema: addTestPlanItemParamsJsonSchema,
182425
183423
  handler: createToolHandler("add_test_plan_item", parseAddTestPlanItemParams, addTestPlanItem)
182426
183424
  },
182427
183425
  {
182428
183426
  name: "remove_test_plan_item",
182429
183427
  description: "Remove a test case from a test plan by item ID. Get item IDs from get_test_plan.",
182430
- category: CATEGORY20,
183428
+ category: CATEGORY21,
182431
183429
  inputSchema: removeTestPlanItemParamsJsonSchema,
182432
183430
  handler: createToolHandler("remove_test_plan_item", parseRemoveTestPlanItemParams, removeTestPlanItem)
182433
183431
  },
@@ -182435,35 +183433,35 @@ var testManagementPlansTools = [
182435
183433
  {
182436
183434
  name: "list_test_runs",
182437
183435
  description: "List test runs in a test management project. Returns run names, IDs, and due dates.",
182438
- category: CATEGORY20,
183436
+ category: CATEGORY21,
182439
183437
  inputSchema: listTestRunsParamsJsonSchema,
182440
183438
  handler: createToolHandler("list_test_runs", parseListTestRunsParams, listTestRuns)
182441
183439
  },
182442
183440
  {
182443
183441
  name: "get_test_run",
182444
183442
  description: "Get test run details including all results. Accepts run ID or name within a project.",
182445
- category: CATEGORY20,
183443
+ category: CATEGORY21,
182446
183444
  inputSchema: getTestRunParamsJsonSchema,
182447
183445
  handler: createToolHandler("get_test_run", parseGetTestRunParams, getTestRun)
182448
183446
  },
182449
183447
  {
182450
183448
  name: "create_test_run",
182451
183449
  description: "Create a test run in a project. For bulk creation from a plan, use run_test_plan instead.",
182452
- category: CATEGORY20,
183450
+ category: CATEGORY21,
182453
183451
  inputSchema: createTestRunParamsJsonSchema,
182454
183452
  handler: createToolHandler("create_test_run", parseCreateTestRunParams, createTestRun)
182455
183453
  },
182456
183454
  {
182457
183455
  name: "update_test_run",
182458
183456
  description: "Update a test run's name, description, or due date. Only provided fields are modified. Pass null to clear optional fields.",
182459
- category: CATEGORY20,
183457
+ category: CATEGORY21,
182460
183458
  inputSchema: updateTestRunParamsJsonSchema,
182461
183459
  handler: createToolHandler("update_test_run", parseUpdateTestRunParams, updateTestRun)
182462
183460
  },
182463
183461
  {
182464
183462
  name: "delete_test_run",
182465
183463
  description: "Permanently delete a test run. This does not delete associated test results. Cannot be undone.",
182466
- category: CATEGORY20,
183464
+ category: CATEGORY21,
182467
183465
  inputSchema: deleteTestRunParamsJsonSchema,
182468
183466
  handler: createToolHandler("delete_test_run", parseDeleteTestRunParams, deleteTestRun)
182469
183467
  },
@@ -182471,35 +183469,35 @@ var testManagementPlansTools = [
182471
183469
  {
182472
183470
  name: "list_test_results",
182473
183471
  description: "List test results in a test run. Returns result names, statuses, and assignees.",
182474
- category: CATEGORY20,
183472
+ category: CATEGORY21,
182475
183473
  inputSchema: listTestResultsParamsJsonSchema,
182476
183474
  handler: createToolHandler("list_test_results", parseListTestResultsParams, listTestResults)
182477
183475
  },
182478
183476
  {
182479
183477
  name: "get_test_result",
182480
183478
  description: "Get test result details. Accepts result ID or name.",
182481
- category: CATEGORY20,
183479
+ category: CATEGORY21,
182482
183480
  inputSchema: getTestResultParamsJsonSchema,
182483
183481
  handler: createToolHandler("get_test_result", parseGetTestResultParams, getTestResult)
182484
183482
  },
182485
183483
  {
182486
183484
  name: "create_test_result",
182487
183485
  description: "Create a test result in a run. Resolves test case by ID or name. Status defaults to 'untested'.",
182488
- category: CATEGORY20,
183486
+ category: CATEGORY21,
182489
183487
  inputSchema: createTestResultParamsJsonSchema,
182490
183488
  handler: createToolHandler("create_test_result", parseCreateTestResultParams, createTestResult)
182491
183489
  },
182492
183490
  {
182493
183491
  name: "update_test_result",
182494
183492
  description: "Update a test result's status, assignee, or description. Status values: untested, blocked, passed, failed.",
182495
- category: CATEGORY20,
183493
+ category: CATEGORY21,
182496
183494
  inputSchema: updateTestResultParamsJsonSchema,
182497
183495
  handler: createToolHandler("update_test_result", parseUpdateTestResultParams, updateTestResult)
182498
183496
  },
182499
183497
  {
182500
183498
  name: "delete_test_result",
182501
183499
  description: "Permanently delete a test result. Cannot be undone.",
182502
- category: CATEGORY20,
183500
+ category: CATEGORY21,
182503
183501
  inputSchema: deleteTestResultParamsJsonSchema,
182504
183502
  handler: createToolHandler("delete_test_result", parseDeleteTestResultParams, deleteTestResult)
182505
183503
  },
@@ -182507,7 +183505,7 @@ var testManagementPlansTools = [
182507
183505
  {
182508
183506
  name: "run_test_plan",
182509
183507
  description: "Execute a test plan: creates a test run and one test result per plan item. Returns the run ID and count of results created. Optionally name the run and set a due date.",
182510
- category: CATEGORY20,
183508
+ category: CATEGORY21,
182511
183509
  inputSchema: runTestPlanParamsJsonSchema,
182512
183510
  annotations: {
182513
183511
  title: "Run Test Plan",
@@ -182522,7 +183520,7 @@ var testManagementPlansTools = [
182522
183520
 
182523
183521
  // src/huly/operations/time.ts
182524
183522
  var import_calendar6 = __toESM(require_lib24(), 1);
182525
- var import_core45 = __toESM(require_lib4(), 1);
183523
+ var import_core46 = __toESM(require_lib4(), 1);
182526
183524
  var import_tracker7 = __toESM(require_lib21(), 1);
182527
183525
  var serverPopulatedCalendar = toRef("");
182528
183526
  var serverPopulatedPersonId = "";
@@ -182532,7 +183530,7 @@ var logTime = (params) => Effect_exports.gen(function* () {
182532
183530
  project: params.project,
182533
183531
  identifier: params.identifier
182534
183532
  });
182535
- const reportId = (0, import_core45.generateId)();
183533
+ const reportId = (0, import_core46.generateId)();
182536
183534
  const now2 = yield* Clock_exports.currentTimeMillis;
182537
183535
  const reportData = {
182538
183536
  employee: null,
@@ -182572,7 +183570,7 @@ var getTimeReport = (params) => Effect_exports.gen(function* () {
182572
183570
  const reports = yield* client.findAll(
182573
183571
  tracker.class.TimeSpendReport,
182574
183572
  { attachedTo: issue2._id },
182575
- { sort: { date: import_core45.SortingOrder.Descending } }
183573
+ { sort: { date: import_core46.SortingOrder.Descending } }
182576
183574
  );
182577
183575
  const employeeIds = [
182578
183576
  ...new Set(
@@ -182624,7 +183622,7 @@ var listTimeSpendReports = (params) => Effect_exports.gen(function* () {
182624
183622
  tracker.class.TimeSpendReport,
182625
183623
  query,
182626
183624
  withLookup(
182627
- { limit, sort: { date: import_core45.SortingOrder.Descending } },
183625
+ { limit, sort: { date: import_core46.SortingOrder.Descending } },
182628
183626
  {
182629
183627
  attachedTo: tracker.class.Issue,
182630
183628
  employee: contact.class.Person
@@ -182653,7 +183651,7 @@ var getDetailedTimeReport = (params) => Effect_exports.gen(function* () {
182653
183651
  tracker.class.TimeSpendReport,
182654
183652
  query,
182655
183653
  withLookup(
182656
- { sort: { date: import_core45.SortingOrder.Descending } },
183654
+ { sort: { date: import_core46.SortingOrder.Descending } },
182657
183655
  {
182658
183656
  attachedTo: tracker.class.Issue,
182659
183657
  employee: contact.class.Person
@@ -182731,7 +183729,7 @@ var listWorkSlots = (params) => Effect_exports.gen(function* () {
182731
183729
  const slots = yield* client.findAll(
182732
183730
  time.class.WorkSlot,
182733
183731
  query,
182734
- { limit, sort: { date: import_core45.SortingOrder.Descending } }
183732
+ { limit, sort: { date: import_core46.SortingOrder.Descending } }
182735
183733
  );
182736
183734
  return slots.map((s) => ({
182737
183735
  id: WorkSlotId.make(s._id),
@@ -182743,7 +183741,7 @@ var listWorkSlots = (params) => Effect_exports.gen(function* () {
182743
183741
  });
182744
183742
  var createWorkSlot = (params) => Effect_exports.gen(function* () {
182745
183743
  const client = yield* HulyClient;
182746
- const slotId = (0, import_core45.generateId)();
183744
+ const slotId = (0, import_core46.generateId)();
182747
183745
  const slotData = {
182748
183746
  date: params.date,
182749
183747
  dueDate: params.dueDate,
@@ -182794,12 +183792,12 @@ var stopTimer = (params) => Effect_exports.gen(function* () {
182794
183792
  });
182795
183793
 
182796
183794
  // src/mcp/tools/time.ts
182797
- var CATEGORY21 = "time tracking";
183795
+ var CATEGORY22 = "time tracking";
182798
183796
  var timeTools = [
182799
183797
  {
182800
183798
  name: "log_time",
182801
183799
  description: "Log time spent on a Huly issue. Records a time entry with optional description. Time value is in minutes.",
182802
- category: CATEGORY21,
183800
+ category: CATEGORY22,
182803
183801
  inputSchema: logTimeParamsJsonSchema,
182804
183802
  handler: createEncodedToolHandler(
182805
183803
  "log_time",
@@ -182811,7 +183809,7 @@ var timeTools = [
182811
183809
  {
182812
183810
  name: "get_time_report",
182813
183811
  description: "Get time tracking report for a specific Huly issue. Shows total time, estimation, remaining time, and all time entries.",
182814
- category: CATEGORY21,
183812
+ category: CATEGORY22,
182815
183813
  inputSchema: getTimeReportParamsJsonSchema,
182816
183814
  handler: createEncodedToolHandler(
182817
183815
  "get_time_report",
@@ -182823,7 +183821,7 @@ var timeTools = [
182823
183821
  {
182824
183822
  name: "list_time_spend_reports",
182825
183823
  description: "List all time entries across issues. Supports filtering by project and date range. Returns entries sorted by date (newest first).",
182826
- category: CATEGORY21,
183824
+ category: CATEGORY22,
182827
183825
  inputSchema: listTimeSpendReportsParamsJsonSchema,
182828
183826
  handler: createEncodedToolHandler(
182829
183827
  "list_time_spend_reports",
@@ -182835,7 +183833,7 @@ var timeTools = [
182835
183833
  {
182836
183834
  name: "get_detailed_time_report",
182837
183835
  description: "Get detailed time breakdown for a project. Shows total time grouped by issue and by employee. Supports date range filtering.",
182838
- category: CATEGORY21,
183836
+ category: CATEGORY22,
182839
183837
  inputSchema: getDetailedTimeReportParamsJsonSchema,
182840
183838
  handler: createEncodedToolHandler(
182841
183839
  "get_detailed_time_report",
@@ -182847,7 +183845,7 @@ var timeTools = [
182847
183845
  {
182848
183846
  name: "list_work_slots",
182849
183847
  description: "List scheduled work slots. Shows planned time blocks attached to ToDos. Supports filtering by employee and date range.",
182850
- category: CATEGORY21,
183848
+ category: CATEGORY22,
182851
183849
  inputSchema: listWorkSlotsParamsJsonSchema,
182852
183850
  handler: createEncodedToolHandler(
182853
183851
  "list_work_slots",
@@ -182859,7 +183857,7 @@ var timeTools = [
182859
183857
  {
182860
183858
  name: "create_work_slot",
182861
183859
  description: "Create a scheduled work slot. Attaches a time block to a ToDo for planning purposes.",
182862
- category: CATEGORY21,
183860
+ category: CATEGORY22,
182863
183861
  inputSchema: createWorkSlotParamsJsonSchema,
182864
183862
  handler: createEncodedToolHandler(
182865
183863
  "create_work_slot",
@@ -182871,7 +183869,7 @@ var timeTools = [
182871
183869
  {
182872
183870
  name: "start_timer",
182873
183871
  description: "Start a client-side timer on a Huly issue. Validates the issue exists and returns a start timestamp. Use log_time to record the elapsed time when done.",
182874
- category: CATEGORY21,
183872
+ category: CATEGORY22,
182875
183873
  inputSchema: startTimerParamsJsonSchema,
182876
183874
  handler: createEncodedToolHandler(
182877
183875
  "start_timer",
@@ -182883,7 +183881,7 @@ var timeTools = [
182883
183881
  {
182884
183882
  name: "stop_timer",
182885
183883
  description: "Stop a client-side timer on a Huly issue. Returns the stop timestamp. Calculate elapsed time from start/stop timestamps and use log_time to record it.",
182886
- category: CATEGORY21,
183884
+ category: CATEGORY22,
182887
183885
  inputSchema: stopTimerParamsJsonSchema,
182888
183886
  handler: createEncodedToolHandler(
182889
183887
  "stop_timer",
@@ -182895,15 +183893,15 @@ var timeTools = [
182895
183893
  ];
182896
183894
 
182897
183895
  // src/huly/operations/workspace.ts
182898
- var import_core46 = __toESM(require_lib4(), 1);
183896
+ var import_core47 = __toESM(require_lib4(), 1);
182899
183897
  var accountRoleMap = {
182900
- READONLYGUEST: import_core46.AccountRole.ReadOnlyGuest,
182901
- DocGuest: import_core46.AccountRole.DocGuest,
182902
- GUEST: import_core46.AccountRole.Guest,
182903
- USER: import_core46.AccountRole.User,
182904
- MAINTAINER: import_core46.AccountRole.Maintainer,
182905
- OWNER: import_core46.AccountRole.Owner,
182906
- ADMIN: import_core46.AccountRole.Admin
183898
+ READONLYGUEST: import_core47.AccountRole.ReadOnlyGuest,
183899
+ DocGuest: import_core47.AccountRole.DocGuest,
183900
+ GUEST: import_core47.AccountRole.Guest,
183901
+ USER: import_core47.AccountRole.User,
183902
+ MAINTAINER: import_core47.AccountRole.Maintainer,
183903
+ OWNER: import_core47.AccountRole.Owner,
183904
+ ADMIN: import_core47.AccountRole.Admin
182907
183905
  };
182908
183906
  var toHulyAccountRole = (role) => accountRoleMap[role];
182909
183907
  var formatVersion = (info) => `${info.versionMajor}.${info.versionMinor}.${info.versionPatch}`;
@@ -183056,12 +184054,12 @@ var getRegions = () => Effect_exports.gen(function* () {
183056
184054
  });
183057
184055
 
183058
184056
  // src/mcp/tools/workspace.ts
183059
- var CATEGORY22 = "workspace";
184057
+ var CATEGORY23 = "workspace";
183060
184058
  var workspaceTools = [
183061
184059
  {
183062
184060
  name: "list_workspace_members",
183063
184061
  description: "List members in the current Huly workspace with their roles. Returns members with account IDs and roles.",
183064
- category: CATEGORY22,
184062
+ category: CATEGORY23,
183065
184063
  inputSchema: listWorkspaceMembersParamsJsonSchema,
183066
184064
  handler: createEncodedWorkspaceToolHandler(
183067
184065
  "list_workspace_members",
@@ -183073,7 +184071,7 @@ var workspaceTools = [
183073
184071
  {
183074
184072
  name: "update_member_role",
183075
184073
  description: "Update a workspace member's role. Requires appropriate permissions. Valid roles: READONLYGUEST, DocGuest, GUEST, USER, MAINTAINER, OWNER, ADMIN.",
183076
- category: CATEGORY22,
184074
+ category: CATEGORY23,
183077
184075
  inputSchema: updateMemberRoleParamsJsonSchema,
183078
184076
  handler: createEncodedWorkspaceToolHandler(
183079
184077
  "update_member_role",
@@ -183085,7 +184083,7 @@ var workspaceTools = [
183085
184083
  {
183086
184084
  name: "get_workspace_info",
183087
184085
  description: "Get information about the current workspace including name, URL, region, and settings.",
183088
- category: CATEGORY22,
184086
+ category: CATEGORY23,
183089
184087
  inputSchema: emptyParamsJsonSchema,
183090
184088
  handler: createEncodedNoParamsWorkspaceToolHandler(
183091
184089
  "get_workspace_info",
@@ -183096,7 +184094,7 @@ var workspaceTools = [
183096
184094
  {
183097
184095
  name: "list_workspaces",
183098
184096
  description: "List all workspaces accessible to the current user. Returns workspace summaries sorted by last visit.",
183099
- category: CATEGORY22,
184097
+ category: CATEGORY23,
183100
184098
  inputSchema: listWorkspacesParamsJsonSchema,
183101
184099
  handler: createEncodedWorkspaceToolHandler(
183102
184100
  "list_workspaces",
@@ -183108,7 +184106,7 @@ var workspaceTools = [
183108
184106
  {
183109
184107
  name: "create_workspace",
183110
184108
  description: "Create a new Huly workspace. Returns the workspace UUID and URL. Optionally specify a region.",
183111
- category: CATEGORY22,
184109
+ category: CATEGORY23,
183112
184110
  inputSchema: createWorkspaceParamsJsonSchema,
183113
184111
  handler: createEncodedWorkspaceToolHandler(
183114
184112
  "create_workspace",
@@ -183120,7 +184118,7 @@ var workspaceTools = [
183120
184118
  {
183121
184119
  name: "delete_workspace",
183122
184120
  description: "Permanently delete the current workspace. This action cannot be undone. Use with extreme caution.",
183123
- category: CATEGORY22,
184121
+ category: CATEGORY23,
183124
184122
  inputSchema: emptyParamsJsonSchema,
183125
184123
  handler: createEncodedNoParamsWorkspaceToolHandler(
183126
184124
  "delete_workspace",
@@ -183131,7 +184129,7 @@ var workspaceTools = [
183131
184129
  {
183132
184130
  name: "get_user_profile",
183133
184131
  description: "Get the current user's profile information including bio, location, and social links.",
183134
- category: CATEGORY22,
184132
+ category: CATEGORY23,
183135
184133
  inputSchema: emptyParamsJsonSchema,
183136
184134
  handler: createEncodedNoParamsWorkspaceToolHandler(
183137
184135
  "get_user_profile",
@@ -183142,7 +184140,7 @@ var workspaceTools = [
183142
184140
  {
183143
184141
  name: "update_user_profile",
183144
184142
  description: "Update the current user's profile. Supports bio, city, country, website, social links, and public visibility.",
183145
- category: CATEGORY22,
184143
+ category: CATEGORY23,
183146
184144
  inputSchema: updateUserProfileParamsJsonSchema,
183147
184145
  handler: createEncodedWorkspaceToolHandler(
183148
184146
  "update_user_profile",
@@ -183154,7 +184152,7 @@ var workspaceTools = [
183154
184152
  {
183155
184153
  name: "update_guest_settings",
183156
184154
  description: "Update workspace guest settings. Control read-only guest access and guest sign-up permissions.",
183157
- category: CATEGORY22,
184155
+ category: CATEGORY23,
183158
184156
  inputSchema: updateGuestSettingsParamsJsonSchema,
183159
184157
  handler: createEncodedWorkspaceToolHandler(
183160
184158
  "update_guest_settings",
@@ -183166,7 +184164,7 @@ var workspaceTools = [
183166
184164
  {
183167
184165
  name: "get_regions",
183168
184166
  description: "Get available regions for workspace creation. Returns region codes and display names.",
183169
- category: CATEGORY22,
184167
+ category: CATEGORY23,
183170
184168
  inputSchema: getRegionsParamsJsonSchema,
183171
184169
  handler: createEncodedWorkspaceToolHandler(
183172
184170
  "get_regions",
@@ -183192,6 +184190,7 @@ var allTools = [
183192
184190
  ...contactTools,
183193
184191
  ...channelTools,
183194
184192
  ...cardTools,
184193
+ ...leadTools,
183195
184194
  ...customFieldTools,
183196
184195
  ...calendarTools,
183197
184196
  ...timeTools,