@structured-world/gitlab-mcp 10.0.1 → 11.0.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.
Files changed (285) hide show
  1. package/README.md +6 -6
  2. package/README.md.in +1 -1
  3. package/dist/src/channel-gateway/format.js +7 -1
  4. package/dist/src/channel-gateway/format.js.map +1 -1
  5. package/dist/src/channel-gateway/forwarding.d.ts +3 -0
  6. package/dist/src/channel-gateway/forwarding.js +8 -1
  7. package/dist/src/channel-gateway/forwarding.js.map +1 -1
  8. package/dist/src/channel-gateway/gateway.d.ts +7 -0
  9. package/dist/src/channel-gateway/gateway.js +80 -16
  10. package/dist/src/channel-gateway/gateway.js.map +1 -1
  11. package/dist/src/cli/docker/container-runtime.d.ts +1 -0
  12. package/dist/src/cli/docker/container-runtime.js +37 -5
  13. package/dist/src/cli/docker/container-runtime.js.map +1 -1
  14. package/dist/src/cli/docker/docker-command.js +11 -2
  15. package/dist/src/cli/docker/docker-command.js.map +1 -1
  16. package/dist/src/cli/docker/docker-utils.d.ts +1 -0
  17. package/dist/src/cli/docker/docker-utils.js +137 -27
  18. package/dist/src/cli/docker/docker-utils.js.map +1 -1
  19. package/dist/src/cli/docker/oauth-issuer-prompt.d.ts +2 -0
  20. package/dist/src/cli/docker/oauth-issuer-prompt.js +47 -0
  21. package/dist/src/cli/docker/oauth-issuer-prompt.js.map +1 -0
  22. package/dist/src/cli/docker/types.d.ts +18 -4
  23. package/dist/src/cli/docker/types.js.map +1 -1
  24. package/dist/src/cli/list-tools.js +14 -35
  25. package/dist/src/cli/list-tools.js.map +1 -1
  26. package/dist/src/cli/setup/flows/server-setup.js +15 -0
  27. package/dist/src/cli/setup/flows/server-setup.js.map +1 -1
  28. package/dist/src/config/instances-loader.js +17 -3
  29. package/dist/src/config/instances-loader.js.map +1 -1
  30. package/dist/src/config/instances-schema.d.ts +6 -3
  31. package/dist/src/config/instances-schema.js +7 -6
  32. package/dist/src/config/instances-schema.js.map +1 -1
  33. package/dist/src/config.js.map +1 -1
  34. package/dist/src/configuration/caller.d.ts +10 -0
  35. package/dist/src/configuration/caller.js +39 -0
  36. package/dist/src/configuration/caller.js.map +1 -0
  37. package/dist/src/configuration/composed-feeds.d.ts +31 -0
  38. package/dist/src/configuration/composed-feeds.js +698 -0
  39. package/dist/src/configuration/composed-feeds.js.map +1 -0
  40. package/dist/src/configuration/composed-listings.d.ts +14 -0
  41. package/dist/src/configuration/composed-listings.js +157 -0
  42. package/dist/src/configuration/composed-listings.js.map +1 -0
  43. package/dist/src/configuration/groups.d.ts +8 -0
  44. package/dist/src/configuration/groups.js +39 -0
  45. package/dist/src/configuration/groups.js.map +1 -0
  46. package/dist/src/configuration/index.d.ts +6 -0
  47. package/dist/src/configuration/index.js +87 -0
  48. package/dist/src/configuration/index.js.map +1 -0
  49. package/dist/src/configuration/policy.d.ts +34 -0
  50. package/dist/src/configuration/policy.js +122 -0
  51. package/dist/src/configuration/policy.js.map +1 -0
  52. package/dist/src/configuration/scope-ids.d.ts +7 -0
  53. package/dist/src/configuration/scope-ids.js +78 -0
  54. package/dist/src/configuration/scope-ids.js.map +1 -0
  55. package/dist/src/configuration/scope-projects.d.ts +5 -0
  56. package/dist/src/configuration/scope-projects.js +76 -0
  57. package/dist/src/configuration/scope-projects.js.map +1 -0
  58. package/dist/src/configuration/scope-targets.d.ts +26 -0
  59. package/dist/src/configuration/scope-targets.js +307 -0
  60. package/dist/src/configuration/scope-targets.js.map +1 -0
  61. package/dist/src/configuration/scoped-execution.d.ts +6 -0
  62. package/dist/src/configuration/scoped-execution.js +577 -0
  63. package/dist/src/configuration/scoped-execution.js.map +1 -0
  64. package/dist/src/configuration/scoped-feeds.d.ts +22 -0
  65. package/dist/src/configuration/scoped-feeds.js +136 -0
  66. package/dist/src/configuration/scoped-feeds.js.map +1 -0
  67. package/dist/src/configuration/service.d.ts +53 -0
  68. package/dist/src/configuration/service.js +186 -0
  69. package/dist/src/configuration/service.js.map +1 -0
  70. package/dist/src/configuration/settings-store.d.ts +20 -0
  71. package/dist/src/configuration/settings-store.js +228 -0
  72. package/dist/src/configuration/settings-store.js.map +1 -0
  73. package/dist/src/configuration/types.d.ts +30 -0
  74. package/dist/src/configuration/types.js +20 -0
  75. package/dist/src/configuration/types.js.map +1 -0
  76. package/dist/src/contracts/storage.d.ts +2 -1
  77. package/dist/src/dashboard/html-template.js +8 -15
  78. package/dist/src/dashboard/html-template.js.map +1 -1
  79. package/dist/src/dashboard/metrics.d.ts +1 -1
  80. package/dist/src/entities/context/connection-check.d.ts +64 -0
  81. package/dist/src/entities/context/connection-check.js +117 -0
  82. package/dist/src/entities/context/connection-check.js.map +1 -0
  83. package/dist/src/entities/context/context-manager.d.ts +10 -22
  84. package/dist/src/entities/context/context-manager.js +108 -207
  85. package/dist/src/entities/context/context-manager.js.map +1 -1
  86. package/dist/src/entities/context/handlers.d.ts +3 -5
  87. package/dist/src/entities/context/handlers.js +2 -14
  88. package/dist/src/entities/context/handlers.js.map +1 -1
  89. package/dist/src/entities/context/output-schema.d.ts +272 -0
  90. package/dist/src/entities/context/output-schema.js +182 -0
  91. package/dist/src/entities/context/output-schema.js.map +1 -0
  92. package/dist/src/entities/context/profile.d.ts +29 -0
  93. package/dist/src/entities/context/profile.js +72 -0
  94. package/dist/src/entities/context/profile.js.map +1 -0
  95. package/dist/src/entities/context/registry.js +140 -3
  96. package/dist/src/entities/context/registry.js.map +1 -1
  97. package/dist/src/entities/context/schema.d.ts +6 -14
  98. package/dist/src/entities/context/schema.js +6 -13
  99. package/dist/src/entities/context/schema.js.map +1 -1
  100. package/dist/src/entities/context/scope-search.d.ts +49 -0
  101. package/dist/src/entities/context/scope-search.js +71 -0
  102. package/dist/src/entities/context/scope-search.js.map +1 -0
  103. package/dist/src/entities/context/settings-panel.d.ts +13 -0
  104. package/dist/src/entities/context/settings-panel.js +508 -0
  105. package/dist/src/entities/context/settings-panel.js.map +1 -0
  106. package/dist/src/entities/context/settings.d.ts +78 -0
  107. package/dist/src/entities/context/settings.js +239 -0
  108. package/dist/src/entities/context/settings.js.map +1 -0
  109. package/dist/src/entities/context/types.d.ts +3 -4
  110. package/dist/src/entities/context/whoami.js +39 -31
  111. package/dist/src/entities/context/whoami.js.map +1 -1
  112. package/dist/src/entities/core/registry.js +34 -33
  113. package/dist/src/entities/core/registry.js.map +1 -1
  114. package/dist/src/entities/environments/schema-readonly.d.ts +3 -3
  115. package/dist/src/entities/files/registry.js +3 -2
  116. package/dist/src/entities/files/registry.js.map +1 -1
  117. package/dist/src/entities/iterations/registry.js +3 -2
  118. package/dist/src/entities/iterations/registry.js.map +1 -1
  119. package/dist/src/entities/mrs/registry.js +11 -5
  120. package/dist/src/entities/mrs/registry.js.map +1 -1
  121. package/dist/src/entities/mrs/schema-readonly.d.ts +8 -2
  122. package/dist/src/entities/mrs/schema-readonly.js +31 -3
  123. package/dist/src/entities/mrs/schema-readonly.js.map +1 -1
  124. package/dist/src/entities/pipelines/registry.js +3 -2
  125. package/dist/src/entities/pipelines/registry.js.map +1 -1
  126. package/dist/src/entities/pipelines/schema-readonly.d.ts +3 -3
  127. package/dist/src/entities/runners/project-access.d.ts +14 -0
  128. package/dist/src/entities/runners/project-access.js +64 -0
  129. package/dist/src/entities/runners/project-access.js.map +1 -0
  130. package/dist/src/entities/runners/registry.js +54 -26
  131. package/dist/src/entities/runners/registry.js.map +1 -1
  132. package/dist/src/entities/search/schema-readonly.d.ts +28 -28
  133. package/dist/src/graphql/runners.d.ts +26 -1
  134. package/dist/src/graphql/runners.js +43 -6
  135. package/dist/src/graphql/runners.js.map +1 -1
  136. package/dist/src/graphql/vulnerabilities.d.ts +3 -0
  137. package/dist/src/graphql/vulnerabilities.js +1 -0
  138. package/dist/src/graphql/vulnerabilities.js.map +1 -1
  139. package/dist/src/handlers.js +218 -142
  140. package/dist/src/handlers.js.map +1 -1
  141. package/dist/src/logger.d.ts +3 -2
  142. package/dist/src/mcp-apps.d.ts +6 -0
  143. package/dist/src/mcp-apps.js +8 -0
  144. package/dist/src/mcp-apps.js.map +1 -0
  145. package/dist/src/middleware/mcp-auth-routes.d.ts +3 -0
  146. package/dist/src/middleware/mcp-auth-routes.js +9 -0
  147. package/dist/src/middleware/mcp-auth-routes.js.map +1 -0
  148. package/dist/src/middleware/oauth-auth.js +83 -23
  149. package/dist/src/middleware/oauth-auth.js.map +1 -1
  150. package/dist/src/middleware/rate-limiter.js +11 -10
  151. package/dist/src/middleware/rate-limiter.js.map +1 -1
  152. package/dist/src/oauth/authorization-response.d.ts +1 -0
  153. package/dist/src/oauth/authorization-response.js +14 -0
  154. package/dist/src/oauth/authorization-response.js.map +1 -0
  155. package/dist/src/oauth/client-auth.d.ts +16 -0
  156. package/dist/src/oauth/client-auth.js +73 -0
  157. package/dist/src/oauth/client-auth.js.map +1 -0
  158. package/dist/src/oauth/config.d.ts +2 -0
  159. package/dist/src/oauth/config.js +37 -0
  160. package/dist/src/oauth/config.js.map +1 -1
  161. package/dist/src/oauth/endpoints/authorize.d.ts +1 -0
  162. package/dist/src/oauth/endpoints/authorize.js +361 -102
  163. package/dist/src/oauth/endpoints/authorize.js.map +1 -1
  164. package/dist/src/oauth/endpoints/callback.js +78 -41
  165. package/dist/src/oauth/endpoints/callback.js.map +1 -1
  166. package/dist/src/oauth/endpoints/index.d.ts +1 -0
  167. package/dist/src/oauth/endpoints/index.js +3 -1
  168. package/dist/src/oauth/endpoints/index.js.map +1 -1
  169. package/dist/src/oauth/endpoints/metadata.d.ts +1 -1
  170. package/dist/src/oauth/endpoints/metadata.js +23 -8
  171. package/dist/src/oauth/endpoints/metadata.js.map +1 -1
  172. package/dist/src/oauth/endpoints/register.d.ts +3 -2
  173. package/dist/src/oauth/endpoints/register.js +70 -19
  174. package/dist/src/oauth/endpoints/register.js.map +1 -1
  175. package/dist/src/oauth/endpoints/revoke.d.ts +2 -0
  176. package/dist/src/oauth/endpoints/revoke.js +97 -0
  177. package/dist/src/oauth/endpoints/revoke.js.map +1 -0
  178. package/dist/src/oauth/endpoints/token.js +136 -62
  179. package/dist/src/oauth/endpoints/token.js.map +1 -1
  180. package/dist/src/oauth/gitlab-device-flow.d.ts +27 -8
  181. package/dist/src/oauth/gitlab-device-flow.js +119 -57
  182. package/dist/src/oauth/gitlab-device-flow.js.map +1 -1
  183. package/dist/src/oauth/gitlab-request-bound.d.ts +1 -0
  184. package/dist/src/oauth/gitlab-request-bound.js +6 -0
  185. package/dist/src/oauth/gitlab-request-bound.js.map +1 -0
  186. package/dist/src/oauth/gitlab-token-refresh.d.ts +6 -0
  187. package/dist/src/oauth/gitlab-token-refresh.js +130 -0
  188. package/dist/src/oauth/gitlab-token-refresh.js.map +1 -0
  189. package/dist/src/oauth/granted-scopes.d.ts +1 -0
  190. package/dist/src/oauth/granted-scopes.js +7 -0
  191. package/dist/src/oauth/granted-scopes.js.map +1 -0
  192. package/dist/src/oauth/index.d.ts +2 -2
  193. package/dist/src/oauth/index.js +4 -2
  194. package/dist/src/oauth/index.js.map +1 -1
  195. package/dist/src/oauth/instance-app.d.ts +4 -0
  196. package/dist/src/oauth/instance-app.js +45 -0
  197. package/dist/src/oauth/instance-app.js.map +1 -0
  198. package/dist/src/oauth/issued-tokens.d.ts +1 -0
  199. package/dist/src/oauth/issued-tokens.js +24 -0
  200. package/dist/src/oauth/issued-tokens.js.map +1 -0
  201. package/dist/src/oauth/oauth-app.d.ts +9 -0
  202. package/dist/src/oauth/oauth-app.js +14 -0
  203. package/dist/src/oauth/oauth-app.js.map +1 -0
  204. package/dist/src/oauth/request-params.d.ts +1 -0
  205. package/dist/src/oauth/request-params.js +17 -0
  206. package/dist/src/oauth/request-params.js.map +1 -0
  207. package/dist/src/oauth/resource.d.ts +12 -0
  208. package/dist/src/oauth/resource.js +66 -0
  209. package/dist/src/oauth/resource.js.map +1 -0
  210. package/dist/src/oauth/routes.d.ts +2 -0
  211. package/dist/src/oauth/routes.js +31 -0
  212. package/dist/src/oauth/routes.js.map +1 -0
  213. package/dist/src/oauth/session-store.d.ts +44 -36
  214. package/dist/src/oauth/session-store.js +125 -253
  215. package/dist/src/oauth/session-store.js.map +1 -1
  216. package/dist/src/oauth/storage/factory.js +1 -1
  217. package/dist/src/oauth/storage/factory.js.map +1 -1
  218. package/dist/src/oauth/storage/file.d.ts +23 -1
  219. package/dist/src/oauth/storage/file.js +168 -36
  220. package/dist/src/oauth/storage/file.js.map +1 -1
  221. package/dist/src/oauth/storage/memory.d.ts +23 -1
  222. package/dist/src/oauth/storage/memory.js +120 -22
  223. package/dist/src/oauth/storage/memory.js.map +1 -1
  224. package/dist/src/oauth/storage/types.d.ts +17 -1
  225. package/dist/src/oauth/storage/types.js.map +1 -1
  226. package/dist/src/oauth/tool-auth.d.ts +12 -0
  227. package/dist/src/oauth/tool-auth.js +108 -0
  228. package/dist/src/oauth/tool-auth.js.map +1 -0
  229. package/dist/src/oauth/types.d.ts +30 -0
  230. package/dist/src/profiles/scope-enforcer.d.ts +8 -0
  231. package/dist/src/profiles/scope-enforcer.js +86 -24
  232. package/dist/src/profiles/scope-enforcer.js.map +1 -1
  233. package/dist/src/profiles/types.js +4 -1
  234. package/dist/src/profiles/types.js.map +1 -1
  235. package/dist/src/registry-manager.d.ts +16 -4
  236. package/dist/src/registry-manager.js +115 -33
  237. package/dist/src/registry-manager.js.map +1 -1
  238. package/dist/src/server.js +66 -39
  239. package/dist/src/server.js.map +1 -1
  240. package/dist/src/services/ConnectionManager.d.ts +2 -1
  241. package/dist/src/services/ConnectionManager.js +26 -19
  242. package/dist/src/services/ConnectionManager.js.map +1 -1
  243. package/dist/src/services/TokenScopeDetector.d.ts +5 -1
  244. package/dist/src/services/TokenScopeDetector.js +19 -0
  245. package/dist/src/services/TokenScopeDetector.js.map +1 -1
  246. package/dist/src/session-manager.d.ts +3 -1
  247. package/dist/src/session-manager.js +35 -10
  248. package/dist/src/session-manager.js.map +1 -1
  249. package/dist/src/types.d.ts +3 -2
  250. package/dist/src/types.js.map +1 -1
  251. package/dist/src/utils/bounded-map.d.ts +1 -0
  252. package/dist/src/utils/bounded-map.js +23 -0
  253. package/dist/src/utils/bounded-map.js.map +1 -0
  254. package/dist/src/utils/fetch.d.ts +0 -1
  255. package/dist/src/utils/fetch.js +2 -12
  256. package/dist/src/utils/fetch.js.map +1 -1
  257. package/dist/src/utils/gitlab-api.js +2 -1
  258. package/dist/src/utils/gitlab-api.js.map +1 -1
  259. package/dist/src/utils/gitlab-base-url.d.ts +2 -0
  260. package/dist/src/utils/gitlab-base-url.js +30 -0
  261. package/dist/src/utils/gitlab-base-url.js.map +1 -0
  262. package/dist/src/utils/html.d.ts +1 -0
  263. package/dist/src/utils/html.js +12 -0
  264. package/dist/src/utils/html.js.map +1 -0
  265. package/dist/src/utils/namespace.d.ts +1 -0
  266. package/dist/src/utils/namespace.js +72 -24
  267. package/dist/src/utils/namespace.js.map +1 -1
  268. package/dist/src/utils/schema-utils.d.ts +5 -3
  269. package/dist/src/utils/schema-utils.js +50 -22
  270. package/dist/src/utils/schema-utils.js.map +1 -1
  271. package/dist/src/utils/smart-user-search.js +2 -1
  272. package/dist/src/utils/smart-user-search.js.map +1 -1
  273. package/dist/src/utils/sync-directory.d.ts +1 -0
  274. package/dist/src/utils/sync-directory.js +49 -0
  275. package/dist/src/utils/sync-directory.js.map +1 -0
  276. package/dist/src/utils/tool-result.d.ts +4 -0
  277. package/dist/src/utils/tool-result.js +41 -0
  278. package/dist/src/utils/tool-result.js.map +1 -0
  279. package/dist/tsconfig.build.tsbuildinfo +1 -1
  280. package/package.json +65 -18
  281. package/skills/gitlab-ci/SKILL.md +16 -0
  282. package/skills/gitlab-discovery/SKILL.md +15 -0
  283. package/skills/gitlab-review/SKILL.md +16 -0
  284. package/skills/gitlab-setup/SKILL.md +16 -0
  285. package/skills/gitlab-work-items/SKILL.md +16 -0
@@ -0,0 +1,698 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.PAGE_SIZE = exports.MAX_REQUESTS = void 0;
4
+ exports.scanScopeConnections = scanScopeConnections;
5
+ exports.multiTargetRunners = multiTargetRunners;
6
+ exports.composedPage = composedPage;
7
+ exports.composedBounds = composedBounds;
8
+ exports.scopeAuditEvents = scopeAuditEvents;
9
+ exports.scopeProjectSnippets = scopeProjectSnippets;
10
+ exports.scopeSnippetTitleSearch = scopeSnippetTitleSearch;
11
+ exports.multiTargetSearch = multiTargetSearch;
12
+ exports.multiTargetVulnerabilities = multiTargetVulnerabilities;
13
+ const scoped_feeds_1 = require("./scoped-feeds");
14
+ const node_crypto_1 = require("node:crypto");
15
+ const error_handler_1 = require("../utils/error-handler");
16
+ const scope_targets_1 = require("./scope-targets");
17
+ const scope_projects_1 = require("./scope-projects");
18
+ exports.MAX_REQUESTS = 10;
19
+ exports.PAGE_SIZE = 100;
20
+ function connectionAction(tool, target) {
21
+ if (tool !== 'browse_runners')
22
+ return 'list';
23
+ return 'group_id' in target ? 'list_group' : 'list_project';
24
+ }
25
+ function nextCursor(nodes, pageInfo, after) {
26
+ if (pageInfo?.hasNextPage === false || (!pageInfo && nodes.length === 0))
27
+ return null;
28
+ const cursor = pageInfo?.endCursor;
29
+ if (pageInfo?.hasNextPage !== true || typeof cursor !== 'string' || !cursor || cursor === after)
30
+ return undefined;
31
+ return cursor;
32
+ }
33
+ async function scanTargetConnection(run, tool, args, budget, visit, wanted) {
34
+ let after;
35
+ let ranked = 0;
36
+ for (;;) {
37
+ if (budget.requests === exports.MAX_REQUESTS)
38
+ return { complete: false };
39
+ budget.requests++;
40
+ const answer = await run(tool, {
41
+ ...args,
42
+ first: exports.PAGE_SIZE,
43
+ ...(after === undefined ? {} : { after }),
44
+ });
45
+ const connection = answer;
46
+ if (!Array.isArray(connection?.nodes))
47
+ return { complete: false, answer };
48
+ if (connection.nodes.length > exports.PAGE_SIZE)
49
+ throw new Error('GitLab returned an oversized scoped connection page');
50
+ ranked += visit(connection.nodes);
51
+ const cursor = nextCursor(connection.nodes, connection.pageInfo, after);
52
+ if (cursor === null)
53
+ return undefined;
54
+ if (ranked >= wanted) {
55
+ budget.more = true;
56
+ return undefined;
57
+ }
58
+ if (cursor === undefined)
59
+ return { complete: false };
60
+ after = cursor;
61
+ }
62
+ }
63
+ async function scanScopeConnections(run, tool, requested, scope, visit, wanted = Number.POSITIVE_INFINITY) {
64
+ const { after: _after, first: _first, ...filters } = requested;
65
+ const seen = new Set();
66
+ const budget = { requests: 0, more: false };
67
+ const result = (scan) => (budget.more ? { ...scan, more: true } : scan);
68
+ for (const configured of (0, scope_targets_1.scopeTargets)(scope)) {
69
+ const target = 'project' in configured ? { project_id: configured.project } : { group_id: configured.group };
70
+ const key = JSON.stringify(target);
71
+ if (seen.has(key))
72
+ continue;
73
+ if (budget.requests === exports.MAX_REQUESTS)
74
+ return result({ complete: false });
75
+ seen.add(key);
76
+ const args = { ...filters, ...target, action: connectionAction(tool, target) };
77
+ const stopped = await scanTargetConnection(run, tool, args, budget, visit, wanted);
78
+ if (stopped)
79
+ return 'answer' in stopped ? stopped : result(stopped);
80
+ }
81
+ return result({ complete: true });
82
+ }
83
+ function runnerKey(row) {
84
+ return typeof row.id === 'string' || typeof row.id === 'number' ? String(row.id) : undefined;
85
+ }
86
+ async function multiTargetRunners(run, requested, scope) {
87
+ if (requested.action === 'list_all')
88
+ return targetRunners(run, requested, scope);
89
+ const ids = new Set();
90
+ const [feed, scan] = await Promise.all([
91
+ run('browse_runners', requested),
92
+ scanScopeConnections(run, 'browse_runners', requested, scope, (rows) => {
93
+ for (const row of rows) {
94
+ const key = runnerKey(row);
95
+ if (key !== undefined)
96
+ ids.add(key);
97
+ }
98
+ return rows.length;
99
+ }),
100
+ ]);
101
+ if ('answer' in scan)
102
+ return scan.answer;
103
+ const result = (0, scoped_feeds_1.keepNodes)(feed, (row) => {
104
+ const key = runnerKey(row);
105
+ return key !== undefined && ids.has(key);
106
+ });
107
+ return scan.complete || result === feed
108
+ ? result
109
+ : {
110
+ ...result,
111
+ partial: true,
112
+ message: 'Runner availability is limited to ten connection requests across the working scope; other usable runners may be omitted.',
113
+ };
114
+ }
115
+ async function targetRunners(run, requested, scope) {
116
+ const { offset, prefix } = composedOffset(requested, scope, 'runner');
117
+ if (offset >= exports.MAX_REQUESTS * exports.PAGE_SIZE)
118
+ return pastReadBound();
119
+ const first = typeof requested.first === 'number' ? requested.first : 20;
120
+ const end = offset + first;
121
+ const rows = [];
122
+ const seen = new Set();
123
+ let ordered = true;
124
+ const scan = await scanScopeConnections(run, 'browse_runners', requested, scope, (batch) => {
125
+ let ranked = 0;
126
+ for (const row of batch) {
127
+ const id = runnerKey(row);
128
+ if (id === undefined)
129
+ continue;
130
+ ranked++;
131
+ if (seen.has(id))
132
+ continue;
133
+ seen.add(id);
134
+ if (!/^\d+$/.test(id))
135
+ ordered = false;
136
+ rows.push({ row, id });
137
+ }
138
+ return ranked;
139
+ }, end);
140
+ if ('answer' in scan)
141
+ return scan.answer;
142
+ if (ordered)
143
+ rows.sort((a, b) => {
144
+ if (a.id.length !== b.id.length)
145
+ return b.id.length - a.id.length;
146
+ return a.id < b.id ? 1 : -1;
147
+ });
148
+ const hasNextPage = rows.length > end || scan.more === true;
149
+ const result = {
150
+ nodes: rows.slice(offset, end).map(({ row }) => row),
151
+ pageInfo: { hasNextPage, endCursor: hasNextPage ? `${prefix}${end}` : null },
152
+ };
153
+ if (scan.complete && ordered)
154
+ return result;
155
+ return {
156
+ ...result,
157
+ partial: true,
158
+ message: ordered
159
+ ? 'Runners cover ten connection requests across the scope; runners of unread targets or pages are not listed. Narrow the scope for a complete listing.'
160
+ : 'GitLab omitted runner IDs needed for ordering; results keep target order.',
161
+ };
162
+ }
163
+ const positiveOr = (value, fallback) => typeof value === 'number' && value > 0 ? value : fallback;
164
+ async function* scopePlaces(run, scope, enforcer) {
165
+ const seen = new Set();
166
+ const fresh = (place) => {
167
+ const key = JSON.stringify(place).toLowerCase();
168
+ if (seen.has(key))
169
+ return false;
170
+ seen.add(key);
171
+ return true;
172
+ };
173
+ const pages = { read: 0 };
174
+ let complete = true;
175
+ for (const target of (0, scope_targets_1.scopeTargets)(scope)) {
176
+ if ('project' in target) {
177
+ if (fresh({ project: target.project }))
178
+ yield { project: target.project };
179
+ continue;
180
+ }
181
+ if (fresh({ group: target.group }))
182
+ yield { group: target.group };
183
+ const listed = yield* groupPlaces(run, target, enforcer, pages, fresh);
184
+ if (listed === false)
185
+ complete = false;
186
+ else if (listed !== true)
187
+ return listed;
188
+ }
189
+ return { complete };
190
+ }
191
+ async function* groupPlaces(run, target, enforcer, pages, fresh) {
192
+ let page = 1;
193
+ while (pages.read < exports.MAX_REQUESTS) {
194
+ pages.read++;
195
+ const rows = await run('browse_projects', {
196
+ action: 'list',
197
+ group_id: target.group,
198
+ include_subgroups: target.subgroups,
199
+ page,
200
+ per_page: exports.PAGE_SIZE,
201
+ });
202
+ if (!Array.isArray(rows))
203
+ return { answer: rows };
204
+ for (const row of rows)
205
+ for (const place of projectPlaces(target.group, row, enforcer))
206
+ if (fresh(place))
207
+ yield place;
208
+ if (rows.length < exports.PAGE_SIZE)
209
+ return true;
210
+ page++;
211
+ }
212
+ return false;
213
+ }
214
+ function projectPlaces(group, row, enforcer) {
215
+ const path = row.path_with_namespace;
216
+ if (typeof path !== 'string' || !enforcer.isAllowed(path))
217
+ return [];
218
+ if (!path.toLowerCase().startsWith(`${group.toLowerCase()}/`))
219
+ return [];
220
+ const segments = path.split('/');
221
+ const places = [];
222
+ for (let end = group.split('/').length + 1; end < segments.length; end++)
223
+ places.push({ group: segments.slice(0, end).join('/') });
224
+ places.push({ project: path });
225
+ return places;
226
+ }
227
+ async function readListing(run, tool, args, wanted, budget) {
228
+ const rows = [];
229
+ let page = 1;
230
+ while (rows.length < wanted) {
231
+ if (budget.requests === exports.MAX_REQUESTS)
232
+ return { rows, bounded: true };
233
+ budget.requests++;
234
+ const answer = await run(tool, { ...args, page, per_page: exports.PAGE_SIZE });
235
+ if (!Array.isArray(answer))
236
+ return { answer };
237
+ rows.push(...answer);
238
+ if (answer.length < exports.PAGE_SIZE)
239
+ break;
240
+ page++;
241
+ }
242
+ return { rows, bounded: false };
243
+ }
244
+ async function readPlaces(run, tool, scope, enforcer, listing, wanted) {
245
+ const rows = [];
246
+ const ids = new Set();
247
+ const budget = { requests: 0 };
248
+ const places = scopePlaces(run, scope, enforcer);
249
+ let next = await places.next();
250
+ while (!next.done) {
251
+ const args = listing(next.value);
252
+ const read = args ? await readListing(run, tool, args, wanted, budget) : undefined;
253
+ if (read && 'answer' in read)
254
+ return read;
255
+ for (const row of read?.rows ?? []) {
256
+ if (row.id !== undefined && ids.has(row.id))
257
+ continue;
258
+ ids.add(row.id);
259
+ rows.push(row);
260
+ }
261
+ if (read?.bounded)
262
+ return { rows, bounded: true, listed: false };
263
+ next = await places.next();
264
+ }
265
+ if ('answer' in next.value)
266
+ return next.value;
267
+ return { rows, bounded: false, listed: next.value.complete };
268
+ }
269
+ function newestFirst(rows, timeField) {
270
+ const keyed = rows.map((row) => {
271
+ const time = timeField === undefined ? 0 : row[timeField];
272
+ return {
273
+ row,
274
+ time: typeof time === 'string' ? Date.parse(time) : time,
275
+ id: row.id,
276
+ };
277
+ });
278
+ if (!keyed.every(({ time, id }) => Number.isFinite(time) && Number.isFinite(id)))
279
+ return undefined;
280
+ keyed.sort((a, b) => b.time - a.time || b.id - a.id);
281
+ return keyed.map(({ row }) => row);
282
+ }
283
+ function composedPage(rows, start, wanted, reasons) {
284
+ const items = rows.slice(start, wanted);
285
+ return reasons.length === 0 ? items : { items, partial: true, message: reasons.join(' ') };
286
+ }
287
+ function composedBounds(requested, what) {
288
+ const perPage = positiveOr(requested.per_page, 20);
289
+ const start = (positiveOr(requested.page, 1) - 1) * perPage;
290
+ const readable = exports.MAX_REQUESTS * exports.PAGE_SIZE;
291
+ if (start < readable)
292
+ return { start, wanted: start + perPage };
293
+ return {
294
+ answer: {
295
+ items: [],
296
+ partial: true,
297
+ message: `The ${what} of the scope are read up to ${readable} rows, and this page starts after them; narrow the listing or the scope.`,
298
+ },
299
+ };
300
+ }
301
+ function placeReasons(read, what) {
302
+ if (read.bounded)
303
+ return [
304
+ `The ${what} of the scope are read with at most ${exports.MAX_REQUESTS} requests; rows of unread projects or groups may belong on this page.`,
305
+ ];
306
+ return read.listed
307
+ ? []
308
+ : [
309
+ `The projects of the scope's groups are listed up to ${exports.MAX_REQUESTS * exports.PAGE_SIZE}; ${what} of the others are not read.`,
310
+ ];
311
+ }
312
+ async function scopeAuditEvents(run, requested, scope, enforcer) {
313
+ const { action: _action, entity_type, entity_id, ...listing } = requested;
314
+ const entity = auditEntity(entity_type, entity_id);
315
+ if (entity && entity.type !== 'Project' && entity.type !== 'Group')
316
+ return [];
317
+ if (entity?.id !== undefined)
318
+ return entityTrail(run, listing, entity.type, entity.id, enforcer);
319
+ const { page: _page, per_page: _perPage, ...filters } = listing;
320
+ const bounds = composedBounds(requested, 'audit trails');
321
+ if ('answer' in bounds)
322
+ return bounds.answer;
323
+ const read = await readPlaces(run, 'browse_audit_events', scope, enforcer, (place) => {
324
+ if ('project' in place)
325
+ return entity?.type === 'Group'
326
+ ? undefined
327
+ : { ...filters, action: 'list_project', project_id: place.project };
328
+ return entity?.type === 'Project'
329
+ ? undefined
330
+ : { ...filters, action: 'list_group', group_id: place.group };
331
+ }, bounds.wanted);
332
+ if ('answer' in read)
333
+ return read.answer;
334
+ const reasons = placeReasons(read, 'audit trails');
335
+ const ordered = newestFirst(read.rows, 'created_at');
336
+ if (!ordered)
337
+ reasons.push('GitLab omitted created_at or id on some events; results keep target order.');
338
+ if (entity?.type !== 'Project' &&
339
+ [...(0, scope_targets_1.scopeTargets)(scope)].some((target) => 'group' in target && target.subgroups))
340
+ reasons.push("Subgroups are found through their projects; the own events of a subgroup that holds no project are not read, list them with action 'list_group'.");
341
+ return composedPage(ordered ?? read.rows, bounds.start, bounds.wanted, reasons);
342
+ }
343
+ const AUDIT_ENTITY_TYPES = [
344
+ 'Project',
345
+ 'User',
346
+ 'Group',
347
+ 'Gitlab::Audit::InstanceScope',
348
+ ];
349
+ function auditEntity(type, id) {
350
+ if (type === undefined) {
351
+ if (id === undefined)
352
+ return undefined;
353
+ throw new Error('entity_type is missing; entity_id filters by the ID of an entity of that type');
354
+ }
355
+ if (typeof type !== 'string' || !AUDIT_ENTITY_TYPES.includes(type))
356
+ throw new Error(`entity_type does not have a valid value; use one of ${AUDIT_ENTITY_TYPES.join(', ')}`);
357
+ return typeof id === 'number' ? { type, id } : { type };
358
+ }
359
+ async function entityTrail(run, listing, type, id, enforcer) {
360
+ const path = await entityPath(run, type, String(id), enforcer);
361
+ if (path === undefined)
362
+ return [];
363
+ return run('browse_audit_events', type === 'Project'
364
+ ? { ...listing, action: 'list_project', project_id: path }
365
+ : { ...listing, action: 'list_group', group_id: path });
366
+ }
367
+ async function entityPath(run, type, id, enforcer) {
368
+ try {
369
+ if (type === 'Project') {
370
+ const project = (await run('browse_projects', { action: 'get', project_id: id }));
371
+ const path = project?.path_with_namespace;
372
+ return typeof path === 'string' && enforcer.isAllowed(path) ? path : undefined;
373
+ }
374
+ const namespace = (await run('browse_namespaces', { action: 'get', namespace_id: id }));
375
+ const path = namespace?.full_path;
376
+ return namespace?.kind === 'group' && typeof path === 'string' && enforcer.isGroupAllowed(path)
377
+ ? path
378
+ : undefined;
379
+ }
380
+ catch (error) {
381
+ const message = error instanceof Error ? error.message : String(error);
382
+ if ((0, error_handler_1.parseGitLabApiError)(message)?.status === 404)
383
+ return undefined;
384
+ throw error;
385
+ }
386
+ }
387
+ async function scopeProjectSnippets(run, requested, scope, enforcer) {
388
+ const { page: _page, per_page: _perPage, projectId: _projectId, ...filters } = requested;
389
+ const bounds = composedBounds(requested, 'project snippets');
390
+ if ('answer' in bounds)
391
+ return bounds.answer;
392
+ const read = await readPlaces(run, 'browse_snippets', scope, enforcer, (place) => ('project' in place ? { ...filters, projectId: place.project } : undefined), bounds.wanted);
393
+ if ('answer' in read)
394
+ return read.answer;
395
+ const reasons = placeReasons(read, 'project snippets');
396
+ const ordered = newestFirst(read.rows);
397
+ if (!ordered)
398
+ reasons.push('GitLab omitted the ID of some snippets; results keep project order.');
399
+ return composedPage(ordered ?? read.rows, bounds.start, bounds.wanted, reasons);
400
+ }
401
+ async function scopeSnippetTitleSearch(run, requested, scope, enforcer) {
402
+ const bounds = composedBounds(requested, 'project snippets');
403
+ if ('answer' in bounds)
404
+ return bounds.answer;
405
+ const read = await readPlaces(run, 'browse_snippets', scope, enforcer, (place) => 'project' in place
406
+ ? { action: 'list', scope: 'project', projectId: place.project }
407
+ : undefined, Number.POSITIVE_INFINITY);
408
+ if ('answer' in read)
409
+ return read.answer;
410
+ const found = read.rows.filter(snippetSearchMatcher(requested.search));
411
+ const reasons = placeReasons(read, 'project snippets');
412
+ const ordered = newestFirst(found, 'updated_at');
413
+ if (!ordered)
414
+ reasons.push('GitLab omitted updated_at or id on some snippets; results keep project order.');
415
+ return composedPage(ordered ?? found, bounds.start, bounds.wanted, reasons);
416
+ }
417
+ const SNIPPET_SEARCH_FIELDS = ['title', 'description', 'file_name'];
418
+ const QUOTED_TERM = /(?<=^| )"[^"]+"(?= |$)/g;
419
+ function snippetSearchMatcher(search) {
420
+ const query = typeof search === 'string' ? search.trim().replaceAll(/\s+/g, ' ') : '';
421
+ if (!query)
422
+ return () => true;
423
+ const quoted = [];
424
+ const rest = query.replace(QUOTED_TERM, (term) => {
425
+ quoted.push(term.slice(1, -1));
426
+ return '';
427
+ });
428
+ const words = [...rest.split(/\s+/), ...quoted]
429
+ .filter((word) => [...word].length >= 3)
430
+ .map((word) => word.toLowerCase());
431
+ const whole = query.toLowerCase();
432
+ const matches = (value) => {
433
+ if (typeof value !== 'string')
434
+ return false;
435
+ const text = value.toLowerCase();
436
+ return words.length > 0 ? words.every((word) => text.includes(word)) : text === whole;
437
+ };
438
+ return (row) => SNIPPET_SEARCH_FIELDS.some((field) => matches(row[field]));
439
+ }
440
+ function searchOrdering(requested) {
441
+ if (requested.scope === 'issues' ||
442
+ requested.scope === 'merge_requests' ||
443
+ requested.scope === 'projects') {
444
+ return {
445
+ field: requested.order_by === 'updated_at' ? 'updated_at' : 'created_at',
446
+ direction: requested.sort === 'asc' ? 1 : -1,
447
+ };
448
+ }
449
+ return requested.scope === 'milestones' ? { field: 'updated_at', direction: -1 } : undefined;
450
+ }
451
+ function orderSearchRows(rows, { field, direction }) {
452
+ const keyed = rows.map((row) => {
453
+ const value = row[field];
454
+ return {
455
+ row,
456
+ time: typeof value === 'string' ? Date.parse(value) : Number.NaN,
457
+ id: typeof row.id === 'number' ? row.id : 0,
458
+ };
459
+ });
460
+ if (!keyed.every(({ time }) => Number.isFinite(time)))
461
+ return undefined;
462
+ keyed.sort((a, b) => (a.time - b.time) * direction || b.id - a.id);
463
+ return keyed.map(({ row }) => row);
464
+ }
465
+ const searchRowKey = (row) => typeof row.id === 'number' || typeof row.id === 'string'
466
+ ? `id:${scalarKey(row.project_id)}:${row.id}`
467
+ : JSON.stringify(row);
468
+ const scalarKey = (value) => typeof value === 'number' || typeof value === 'string' ? String(value) : '';
469
+ async function readSearchTarget(run, args, wanted, budget, keep) {
470
+ const rows = [];
471
+ let page = 1;
472
+ while (rows.length < wanted) {
473
+ if (budget.requests === exports.MAX_REQUESTS)
474
+ return { rows, bounded: true };
475
+ budget.requests++;
476
+ const answer = await run('browse_search', { ...args, page, per_page: exports.PAGE_SIZE });
477
+ const results = answer?.results;
478
+ if (!Array.isArray(results))
479
+ return { answer };
480
+ rows.push(...(keep ? await keep(results) : results));
481
+ if (results.length < exports.PAGE_SIZE)
482
+ break;
483
+ page++;
484
+ }
485
+ return { rows, bounded: false };
486
+ }
487
+ function targetSearchArgs(filters, target) {
488
+ return 'project' in target
489
+ ? { ...filters, action: 'project', project_id: target.project }
490
+ : { ...filters, action: 'group', group_id: target.group };
491
+ }
492
+ async function multiTargetSearch(run, requested, scope, enforcer) {
493
+ const { action: _action, page: _page, per_page: _perPage, ...filters } = requested;
494
+ const perPage = positiveOr(requested.per_page, 20);
495
+ const start = (positiveOr(requested.page, 1) - 1) * perPage;
496
+ const wanted = start + perPage;
497
+ const reasons = [];
498
+ const answer = (results) => ({
499
+ scope: requested.scope,
500
+ count: results.length,
501
+ results,
502
+ ...(reasons.length > 0 ? { partial: true, message: reasons.join(' ') } : {}),
503
+ });
504
+ if (start >= exports.MAX_REQUESTS * exports.PAGE_SIZE) {
505
+ reasons.push(`The searches of the scope read up to ${exports.MAX_REQUESTS * exports.PAGE_SIZE} results, and this page starts after them; narrow the search.`);
506
+ return answer([]);
507
+ }
508
+ const read = await searchTargets(run, scope, filters, wanted, enforcer);
509
+ if ('answer' in read)
510
+ return read.answer;
511
+ reasons.push(...read.reasons);
512
+ const ordering = searchOrdering(requested);
513
+ const ordered = ordering ? orderSearchRows(read.rows, ordering) : undefined;
514
+ if (!ordered && read.contributing > 1)
515
+ reasons.push(ordering
516
+ ? 'GitLab omitted the ordering time on some results; they keep target order.'
517
+ : 'These results have no order shared across projects and groups; they keep target order.');
518
+ return answer((ordered ?? read.rows).slice(start, wanted));
519
+ }
520
+ async function searchTargets(run, scope, filters, wanted, enforcer) {
521
+ const rows = [];
522
+ const reasons = [];
523
+ const seen = new Set();
524
+ const targets = new Set();
525
+ const budget = { requests: 0 };
526
+ const lookups = { requests: 0 };
527
+ let contributing = 0;
528
+ for (const target of (0, scope_targets_1.scopeTargets)(scope)) {
529
+ const key = JSON.stringify(target);
530
+ if (targets.has(key))
531
+ continue;
532
+ targets.add(key);
533
+ const read = await searchTarget(run, target, filters, wanted, { budget, lookups }, enforcer);
534
+ if ('answer' in read)
535
+ return read;
536
+ if (read.reason)
537
+ reasons.push(read.reason);
538
+ if (appendUniqueRows(read.rows, seen, rows) > 0)
539
+ contributing++;
540
+ if (read.bounded) {
541
+ reasons.push(`The searches of the scope are limited to ${exports.MAX_REQUESTS} requests; results of unread projects or groups may belong on this page.`);
542
+ break;
543
+ }
544
+ }
545
+ return { rows, contributing, reasons };
546
+ }
547
+ async function searchTarget(run, target, filters, wanted, { budget, lookups }, enforcer) {
548
+ if ('project' in target && filters.scope === 'projects')
549
+ return projectTargetSearch(run, target.project, filters.search, budget);
550
+ const args = targetSearchArgs(filters, target);
551
+ if (!('group' in target) || target.subgroups)
552
+ return readSearchTarget(run, args, wanted, budget, undefined);
553
+ const direct = await (0, scoped_feeds_1.directGroupSearchRows)(run, target.group, filters.scope, enforcer, lookups);
554
+ const read = await readSearchTarget(run, args, wanted, budget, direct.keep);
555
+ if ('answer' in read || direct.complete)
556
+ return read;
557
+ return {
558
+ ...read,
559
+ reason: `Results of group '${target.group}' are kept to the direct projects read within the lookup bound; results of its other projects are not shown.`,
560
+ };
561
+ }
562
+ async function projectTargetSearch(run, project, search, budget) {
563
+ if (budget.requests === exports.MAX_REQUESTS)
564
+ return { rows: [], bounded: true };
565
+ budget.requests++;
566
+ const found = await (0, scope_projects_1.readScopeProject)(run, project);
567
+ return {
568
+ rows: (0, scope_projects_1.matchesScopeProject)(found, search, 'search') ? [(0, scope_projects_1.simpleProject)(found)] : [],
569
+ bounded: false,
570
+ };
571
+ }
572
+ function appendUniqueRows(found, seen, rows) {
573
+ let added = 0;
574
+ for (const row of found) {
575
+ const key = searchRowKey(row);
576
+ if (seen.has(key))
577
+ continue;
578
+ seen.add(key);
579
+ rows.push(row);
580
+ added++;
581
+ }
582
+ return added;
583
+ }
584
+ const SEVERITY = {
585
+ INFO: 1,
586
+ UNKNOWN: 2,
587
+ LOW: 4,
588
+ MEDIUM: 5,
589
+ HIGH: 6,
590
+ CRITICAL: 7,
591
+ };
592
+ const STATE = {
593
+ DETECTED: 1,
594
+ DISMISSED: 2,
595
+ RESOLVED: 3,
596
+ CONFIRMED: 4,
597
+ };
598
+ function orderingValue(row, field) {
599
+ if (field === 'severity')
600
+ return typeof row.severity === 'string' ? SEVERITY[row.severity] : undefined;
601
+ if (field === 'state')
602
+ return typeof row.state === 'string' ? STATE[row.state] : undefined;
603
+ if (field === 'title')
604
+ return typeof row.title === 'string' ? row.title : undefined;
605
+ if (typeof row.detectedAt !== 'string')
606
+ return undefined;
607
+ const time = Date.parse(row.detectedAt);
608
+ return Number.isFinite(time) ? time : undefined;
609
+ }
610
+ const pastReadBound = () => ({
611
+ nodes: [],
612
+ pageInfo: { hasNextPage: false, endCursor: null },
613
+ partial: true,
614
+ message: 'The composed cursor starts past the 1000-row read bound; narrow the scope.',
615
+ });
616
+ function composedOffset(requested, scope, what) {
617
+ const { first: _first, after, ...filters } = requested;
618
+ const hash = (0, node_crypto_1.createHash)('sha256')
619
+ .update(JSON.stringify(scope))
620
+ .update(JSON.stringify(filters))
621
+ .digest('hex');
622
+ const prefix = `scope:${hash}:`;
623
+ if (after === undefined)
624
+ return { offset: 0, prefix };
625
+ if (typeof after !== 'string' ||
626
+ after.length > 85 ||
627
+ !after.startsWith(prefix) ||
628
+ !/^\d{1,4}$/.test(after.slice(prefix.length))) {
629
+ throw new Error(`Invalid composed ${what} cursor; restart pagination for this scope and query`);
630
+ }
631
+ return { offset: Number(after.slice(prefix.length)), prefix };
632
+ }
633
+ async function multiTargetVulnerabilities(run, requested, scope, enforcer) {
634
+ const { offset, prefix } = composedOffset(requested, scope, 'vulnerability');
635
+ if (offset >= exports.MAX_REQUESTS * exports.PAGE_SIZE)
636
+ return pastReadBound();
637
+ const first = typeof requested.first === 'number' ? requested.first : 20;
638
+ const end = offset + first;
639
+ const sort = typeof requested.sort === 'string' ? requested.sort : 'severity_desc';
640
+ const split = sort.lastIndexOf('_');
641
+ const field = sort.slice(0, split);
642
+ const direction = sort.slice(split + 1) === 'asc' ? 1 : -1;
643
+ const rows = [];
644
+ const seen = new Set();
645
+ const keep = (0, scoped_feeds_1.isScopeVulnerability)(enforcer);
646
+ let ordered = true;
647
+ const scan = await scanScopeConnections(run, 'browse_vulnerabilities', requested, scope, (batch) => {
648
+ let ranked = 0;
649
+ for (const row of batch) {
650
+ if (!keep(row))
651
+ continue;
652
+ const id = String(row.id);
653
+ if (!/^\d+$/.test(id)) {
654
+ ordered = false;
655
+ continue;
656
+ }
657
+ ranked++;
658
+ if (seen.has(id))
659
+ continue;
660
+ seen.add(id);
661
+ const value = orderingValue(row, field);
662
+ if (value === undefined)
663
+ ordered = false;
664
+ rows.push({ row, id, value });
665
+ }
666
+ return ranked;
667
+ }, end);
668
+ if ('answer' in scan)
669
+ return scan.answer;
670
+ if (ordered)
671
+ rows.sort((a, b) => {
672
+ const left = a.value;
673
+ const right = b.value;
674
+ if (left !== right)
675
+ return (left < right ? -1 : 1) * direction;
676
+ if (a.id.length !== b.id.length)
677
+ return b.id.length - a.id.length;
678
+ return a.id < b.id ? 1 : -1;
679
+ });
680
+ const hasNextPage = rows.length > end || scan.more === true;
681
+ const nodes = [];
682
+ for (let index = offset; index < end && index < rows.length; index++)
683
+ nodes.push(rows[index].row);
684
+ const result = {
685
+ nodes,
686
+ pageInfo: { hasNextPage, endCursor: hasNextPage ? `${prefix}${end}` : null },
687
+ };
688
+ return scan.complete && ordered
689
+ ? result
690
+ : {
691
+ ...result,
692
+ partial: true,
693
+ message: ordered
694
+ ? 'Vulnerabilities cover ten connection requests across the scope; unscanned targets or pages may change the sorted result. Narrow the scope for a complete listing.'
695
+ : 'GitLab omitted data needed for ordering; results retain target order and are partial.',
696
+ };
697
+ }
698
+ //# sourceMappingURL=composed-feeds.js.map