@mondaydotcomorg/atp-server 0.20.5 → 0.20.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -6955,6 +6955,10 @@ function getRequestToolRules() {
6955
6955
  return asyncLocalStorage.getStore()?.toolRules;
6956
6956
  }
6957
6957
  __name(getRequestToolRules, "getRequestToolRules");
6958
+ function getRequestScope() {
6959
+ return asyncLocalStorage.getStore();
6960
+ }
6961
+ __name(getRequestScope, "getRequestScope");
6958
6962
  function isGroupAllowed(groupName, rules) {
6959
6963
  if (!rules) return true;
6960
6964
  if (rules.allowOnlyApiGroups && rules.allowOnlyApiGroups.length > 0) {
@@ -10357,8 +10361,13 @@ var ExplorerService = class {
10357
10361
  }
10358
10362
  root;
10359
10363
  apiGroups;
10364
+ apiGroupMap;
10360
10365
  constructor(apiGroups) {
10361
10366
  this.apiGroups = apiGroups;
10367
+ this.apiGroupMap = new Map(apiGroups.map((group) => [
10368
+ group.name,
10369
+ group
10370
+ ]));
10362
10371
  this.root = {
10363
10372
  type: "directory",
10364
10373
  name: "/",
@@ -10418,7 +10427,13 @@ var ExplorerService = class {
10418
10427
  buildTree(apiGroups) {
10419
10428
  for (const group of apiGroups) {
10420
10429
  if (!group.functions || group.functions.length === 0) continue;
10421
- const groupFolder = group.type === "graphql" ? this.ensureDirectory(this.root, group.name, group.description) : this.ensureDirectory(this.ensureDirectory(this.root, group.type), group.name, group.description);
10430
+ let groupFolder;
10431
+ if (group.type === "graphql") {
10432
+ groupFolder = this.ensureDirectory(this.root, group.name, group.description);
10433
+ } else {
10434
+ groupFolder = this.ensureDirectory(this.ensureDirectory(this.root, group.type), group.name, group.description);
10435
+ }
10436
+ groupFolder.apiGroupName = group.name;
10422
10437
  for (const func of group.functions) {
10423
10438
  const segments = this.extractSegments(func, group);
10424
10439
  if (segments.length > 1) {
@@ -10580,11 +10595,18 @@ var ExplorerService = class {
10580
10595
  }
10581
10596
  return a.type === "directory" ? -1 : 1;
10582
10597
  });
10583
- return {
10598
+ const result = {
10584
10599
  type: "directory",
10585
10600
  path: currentPath,
10586
10601
  items
10587
10602
  };
10603
+ if (current.apiGroupName) {
10604
+ const apiGroup = this.apiGroupMap.get(current.apiGroupName);
10605
+ if (apiGroup?.documentation) {
10606
+ result.documentation = apiGroup.documentation;
10607
+ }
10608
+ }
10609
+ return result;
10588
10610
  } else {
10589
10611
  if (!current.functionDef) {
10590
10612
  return null;
@@ -11028,10 +11050,19 @@ __name(handleInit, "handleInit");
11028
11050
  // src/handlers/search.handler.ts
11029
11051
  async function handleSearch(ctx, searchEngine, config) {
11030
11052
  const searchOptions = ctx.body;
11031
- const results = await searchEngine.search(searchOptions, ctx.userId, ctx.auth, config.discovery.scopeFiltering);
11032
- return {
11033
- results
11034
- };
11053
+ const { toolRules, ...cleanOptions } = searchOptions;
11054
+ const executeSearch = /* @__PURE__ */ __name(async () => {
11055
+ const results = await searchEngine.search(cleanOptions, ctx.userId, ctx.auth, config.discovery.scopeFiltering);
11056
+ return {
11057
+ results
11058
+ };
11059
+ }, "executeSearch");
11060
+ if (toolRules && !getRequestScope()?.toolRules) {
11061
+ return runInRequestScope({
11062
+ toolRules
11063
+ }, executeSearch);
11064
+ }
11065
+ return executeSearch();
11035
11066
  }
11036
11067
  __name(handleSearch, "handleSearch");
11037
11068
  async function handleSearchQuery(ctx, searchEngine, config) {
@@ -11049,11 +11080,20 @@ __name(handleSearchQuery, "handleSearchQuery");
11049
11080
  async function handleExplore(ctx, explorerService) {
11050
11081
  const body = ctx.body;
11051
11082
  const path = body.path || "/";
11052
- const result = explorerService.explore(path);
11053
- if (!result) {
11054
- ctx.throw(404, `Path not found: ${path}`);
11083
+ const { toolRules } = body;
11084
+ const executeExplore = /* @__PURE__ */ __name(() => {
11085
+ const result = explorerService.explore(path);
11086
+ if (!result) {
11087
+ ctx.throw(404, `Path not found: ${path}`);
11088
+ }
11089
+ return result;
11090
+ }, "executeExplore");
11091
+ if (toolRules && !getRequestScope()?.toolRules) {
11092
+ return runInRequestScope({
11093
+ toolRules
11094
+ }, executeExplore);
11055
11095
  }
11056
- return result;
11096
+ return executeExplore();
11057
11097
  }
11058
11098
  __name(handleExplore, "handleExplore");
11059
11099
  async function emitProvenanceTokens(result, clientId, executionId, provenanceMode, cacheProvider, logger, maxTokens = 5e3, tokenTTL = 3600, provenanceSnapshot) {
@@ -11293,7 +11333,8 @@ async function handleExecute(ctx, executor, stateManager, config, auditSink, ses
11293
11333
  method: ctx.method
11294
11334
  },
11295
11335
  onToolCall,
11296
- eventCallback: requestConfig.eventCallback
11336
+ eventCallback: requestConfig.eventCallback,
11337
+ toolRules: requestConfig.toolRules
11297
11338
  };
11298
11339
  let hintMap;
11299
11340
  const prelimExecutionId = crypto.randomUUID();