@devrev/git-sdk 0.11.0 → 0.12.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 (50) hide show
  1. package/dist/adapter/adapter.d.ts +2 -2
  2. package/dist/config/create-config.d.ts +7 -0
  3. package/dist/config/create-config.js +2 -0
  4. package/dist/config/create-config.js.map +1 -1
  5. package/dist/devrev/client.js +1 -1
  6. package/dist/devrev/client.js.map +1 -1
  7. package/dist/devrev/managers/code_change_manager.js +9 -15
  8. package/dist/devrev/managers/code_change_manager.js.map +1 -1
  9. package/dist/devrev/managers/code_change_schema.js +42 -29
  10. package/dist/devrev/managers/code_change_schema.js.map +1 -1
  11. package/dist/devrev/managers/tenant_fragment_manager.d.ts +18 -1
  12. package/dist/devrev/managers/tenant_fragment_manager.js +93 -4
  13. package/dist/devrev/managers/tenant_fragment_manager.js.map +1 -1
  14. package/dist/devrev/types.d.ts +4 -0
  15. package/dist/devrev/types.js.map +1 -1
  16. package/dist/handlers/commit_push_handler.js +6 -3
  17. package/dist/handlers/commit_push_handler.js.map +1 -1
  18. package/dist/handlers/helpers.d.ts +22 -0
  19. package/dist/handlers/helpers.js +36 -2
  20. package/dist/handlers/helpers.js.map +1 -1
  21. package/dist/handlers/index.d.ts +4 -1
  22. package/dist/handlers/index.js +11 -1
  23. package/dist/handlers/index.js.map +1 -1
  24. package/dist/handlers/pr_edit_handler.d.ts +35 -0
  25. package/dist/handlers/pr_edit_handler.js +259 -0
  26. package/dist/handlers/pr_edit_handler.js.map +1 -0
  27. package/dist/handlers/pr_lifecycle_handler.d.ts +19 -0
  28. package/dist/handlers/pr_lifecycle_handler.js +58 -0
  29. package/dist/handlers/pr_lifecycle_handler.js.map +1 -0
  30. package/dist/handlers/pr_merge_handler.js +10 -3
  31. package/dist/handlers/pr_merge_handler.js.map +1 -1
  32. package/dist/handlers/pr_review_handler.d.ts +4 -1
  33. package/dist/handlers/pr_review_handler.js +14 -8
  34. package/dist/handlers/pr_review_handler.js.map +1 -1
  35. package/dist/handlers/registry.d.ts +0 -2
  36. package/dist/handlers/registry.js +4 -2
  37. package/dist/handlers/registry.js.map +1 -1
  38. package/dist/handlers/types.d.ts +6 -0
  39. package/dist/index.d.ts +2 -2
  40. package/dist/index.js +8 -1
  41. package/dist/index.js.map +1 -1
  42. package/dist/orchestrator/event_orchestrator.d.ts +1 -0
  43. package/dist/orchestrator/event_orchestrator.js +3 -0
  44. package/dist/orchestrator/event_orchestrator.js.map +1 -1
  45. package/dist/types/config.d.ts +8 -0
  46. package/dist/types/events.d.ts +13 -2
  47. package/dist/types/events.js +1 -0
  48. package/dist/types/events.js.map +1 -1
  49. package/dist/types/types.d.ts +1 -0
  50. package/package.json +1 -1
@@ -0,0 +1,259 @@
1
+ "use strict";
2
+ /**
3
+ * Handler for pull request edit events.
4
+ *
5
+ * This module handles PR metadata changes — title, description, branch,
6
+ * draft status, and reviewer assignments. It updates the code_change
7
+ * custom object and re-diffs issue links based on the updated PR content.
8
+ *
9
+ * Reviewer updates are handled via three possible inputs:
10
+ * - addRequestedReviewer / removeRequestedReviewer: a single actor to add or remove.
11
+ * - pullRequest.requestedReviewers: the complete set of currently requested reviewers.
12
+ * - A combination of both: the final set is computed by applying the single
13
+ * add/remove to the full list, then diffing against the existing code_change.
14
+ */
15
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
16
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
17
+ return new (P || (P = Promise))(function (resolve, reject) {
18
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
19
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
20
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
21
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
22
+ });
23
+ };
24
+ Object.defineProperty(exports, "__esModule", { value: true });
25
+ exports.handlePREdit = void 0;
26
+ const types_1 = require("../devrev/types");
27
+ const helpers_1 = require("./helpers");
28
+ // =============================================================================
29
+ // Helpers
30
+ // =============================================================================
31
+ function resolveActorsToDevIds(actors, client) {
32
+ return __awaiter(this, void 0, void 0, function* () {
33
+ const ids = [];
34
+ for (const actor of actors) {
35
+ try {
36
+ const devId = yield client.devUser.resolveByExternalId(actor.external_id, actor.email);
37
+ if (devId)
38
+ ids.push(devId);
39
+ }
40
+ catch (error) {
41
+ console.log(`Warning: Could not resolve actor ${actor.username || actor.external_id}: ${error}`);
42
+ }
43
+ }
44
+ return ids;
45
+ });
46
+ }
47
+ // =============================================================================
48
+ // PR Edit Handler
49
+ // =============================================================================
50
+ /**
51
+ * Process a pull request edit event.
52
+ *
53
+ * If the code_change is newly created (isNew=true), no further updates are
54
+ * needed since getOrCreateCodeChangeForPR already sets all initial data and
55
+ * creates issue links.
56
+ *
57
+ * For existing code_changes, the handler will:
58
+ * 1. Update title/description if they differ
59
+ * 2. Handle draft status: draft→ready (WAITING_FOR_REVIEW) or ready→draft (DRAFT)
60
+ * 3. Resolve requested reviewers per the combined logic:
61
+ * - requestedReviewers + add/remove: compute final list, diff vs existing
62
+ * - Only add/remove: use add_requested_reviewer / remove_requested_reviewer
63
+ * - Only requestedReviewers: diff vs existing (add new, remove stale)
64
+ * 4. Re-diff issue links
65
+ *
66
+ * No separate timeline entry is created — attribute changes generate timeline
67
+ * entries via DevRev's change tracking.
68
+ */
69
+ function handlePREdit(input, context) {
70
+ var _a;
71
+ return __awaiter(this, void 0, void 0, function* () {
72
+ const { pullRequest, repository, addRequestedReviewer, removeRequestedReviewer, } = input;
73
+ const repoName = repository.name;
74
+ const { client, adapter } = context;
75
+ try {
76
+ const { codeChange, isNew } = yield (0, helpers_1.getOrCreateCodeChangeForPR)(pullRequest, repoName, context);
77
+ if (isNew) {
78
+ return {
79
+ data: {
80
+ codeChangeId: codeChange.id,
81
+ isNew,
82
+ },
83
+ message: `Created code_change for PR #${pullRequest.number} via edit event`,
84
+ success: true,
85
+ };
86
+ }
87
+ const updateRequest = {
88
+ id: codeChange.id,
89
+ };
90
+ let hasChanges = false;
91
+ // Title
92
+ const codeChangeRecord = codeChange;
93
+ const existingTitle = codeChangeRecord.title;
94
+ if (pullRequest.title !== existingTitle) {
95
+ updateRequest.title = pullRequest.title;
96
+ hasChanges = true;
97
+ }
98
+ // Description
99
+ const existingDescription = codeChangeRecord.description;
100
+ const newDescription = pullRequest.body || '';
101
+ if (newDescription !== (existingDescription || '')) {
102
+ updateRequest.description = newDescription;
103
+ hasChanges = true;
104
+ }
105
+ // If the PR is a draft and not already in DRAFT status, transition to DRAFT;
106
+ // if the PR is no longer a draft but the code_change is still in DRAFT, transition to WAITING_FOR_REVIEW.
107
+ const currentStatus = (0, helpers_1.getCodeChangeCustomField)(codeChange, types_1.CodeChangeFields.STATUS);
108
+ if (pullRequest.isDraft) {
109
+ if (currentStatus !== types_1.CodeChangeStatus.DRAFT) {
110
+ updateRequest.status = types_1.CodeChangeStatus.DRAFT;
111
+ hasChanges = true;
112
+ }
113
+ }
114
+ else {
115
+ if (currentStatus === types_1.CodeChangeStatus.DRAFT) {
116
+ updateRequest.status = types_1.CodeChangeStatus.WAITING_FOR_REVIEW;
117
+ hasChanges = true;
118
+ }
119
+ }
120
+ // Requested reviewers: when both the full list and a single add/remove are present,
121
+ // the final set is computed by applying the add/remove to the list and then diffing
122
+ // against existing reviewers. When only a single add/remove is present, it is applied
123
+ // directly. When only the full list is present, it is diffed against the existing set.
124
+ const hasRequestedReviewers = pullRequest.requestedReviewers &&
125
+ pullRequest.requestedReviewers.length > 0;
126
+ const hasAdd = !!addRequestedReviewer;
127
+ const hasRemove = !!removeRequestedReviewer;
128
+ if (hasRequestedReviewers && (hasAdd || hasRemove)) {
129
+ // Case 1: requestedReviewers + add/remove — compute final list, then diff vs existing
130
+ const baseIds = yield resolveActorsToDevIds(pullRequest.requestedReviewers, client);
131
+ let finalIds = new Set(baseIds);
132
+ if (hasAdd) {
133
+ const addId = yield client.devUser.resolveByExternalId(addRequestedReviewer.external_id, addRequestedReviewer.email);
134
+ if (addId)
135
+ finalIds.add(addId);
136
+ }
137
+ if (hasRemove) {
138
+ const removeId = yield client.devUser.resolveByExternalId(removeRequestedReviewer.external_id, removeRequestedReviewer.email);
139
+ if (removeId)
140
+ finalIds.delete(removeId);
141
+ }
142
+ const existingRequested = (0, helpers_1.getCodeChangeCustomField)(codeChange, types_1.CodeChangeFields.REQUESTED_REVIEWERS) || [];
143
+ const existingApproved = (0, helpers_1.getCodeChangeCustomField)(codeChange, types_1.CodeChangeFields.APPROVED_BY) || [];
144
+ const approvedSet = new Set(existingApproved);
145
+ const existingSet = new Set(existingRequested);
146
+ const toAdd = [];
147
+ const toRemove = [];
148
+ for (const id of finalIds) {
149
+ if (!approvedSet.has(id) && !existingSet.has(id))
150
+ toAdd.push(id);
151
+ }
152
+ for (const id of existingSet) {
153
+ if (!finalIds.has(id))
154
+ toRemove.push(id);
155
+ }
156
+ if (toAdd.length > 0) {
157
+ updateRequest.add_requested_reviewer = toAdd;
158
+ hasChanges = true;
159
+ }
160
+ if (toRemove.length > 0) {
161
+ updateRequest.remove_requested_reviewer = toRemove;
162
+ hasChanges = true;
163
+ }
164
+ }
165
+ else if (!hasRequestedReviewers && (hasAdd || hasRemove)) {
166
+ // Case 2: Only add/remove — use add_requested_reviewer / remove_requested_reviewer directly
167
+ if (hasAdd) {
168
+ const addId = yield client.devUser.resolveByExternalId(addRequestedReviewer.external_id, addRequestedReviewer.email);
169
+ if (addId) {
170
+ updateRequest.add_requested_reviewer = [addId];
171
+ hasChanges = true;
172
+ }
173
+ }
174
+ if (hasRemove) {
175
+ const removeId = yield client.devUser.resolveByExternalId(removeRequestedReviewer.external_id, removeRequestedReviewer.email);
176
+ if (removeId) {
177
+ updateRequest.remove_requested_reviewer = [removeId];
178
+ hasChanges = true;
179
+ }
180
+ }
181
+ }
182
+ else if (hasRequestedReviewers && !hasAdd && !hasRemove) {
183
+ // Case 3: Only requestedReviewers — diff vs existing
184
+ const resolvedIds = yield resolveActorsToDevIds(pullRequest.requestedReviewers, client);
185
+ const existingRequested = (0, helpers_1.getCodeChangeCustomField)(codeChange, types_1.CodeChangeFields.REQUESTED_REVIEWERS) || [];
186
+ const existingApproved = (0, helpers_1.getCodeChangeCustomField)(codeChange, types_1.CodeChangeFields.APPROVED_BY) || [];
187
+ const approvedSet = new Set(existingApproved);
188
+ const newSet = new Set(resolvedIds.filter((id) => !approvedSet.has(id)));
189
+ const existingSet = new Set(existingRequested);
190
+ const toAdd = [];
191
+ const toRemove = [];
192
+ for (const id of newSet) {
193
+ if (!existingSet.has(id))
194
+ toAdd.push(id);
195
+ }
196
+ for (const id of existingSet) {
197
+ if (!newSet.has(id))
198
+ toRemove.push(id);
199
+ }
200
+ if (toAdd.length > 0) {
201
+ updateRequest.add_requested_reviewer = toAdd;
202
+ hasChanges = true;
203
+ }
204
+ if (toRemove.length > 0) {
205
+ updateRequest.remove_requested_reviewer = toRemove;
206
+ hasChanges = true;
207
+ }
208
+ }
209
+ if (hasChanges) {
210
+ yield client.codeChange.update(updateRequest, codeChange);
211
+ }
212
+ // Re-diff issue links
213
+ try {
214
+ const extractedWorkIds = adapter.extractWorkIds(pullRequest);
215
+ const existingLinks = yield client.link.listByObject(codeChange.id);
216
+ const existingWorkIds = new Set(existingLinks
217
+ .map((link) => { var _a; return (_a = link.source) === null || _a === void 0 ? void 0 : _a.display_id; })
218
+ .filter(Boolean));
219
+ for (const workId of extractedWorkIds) {
220
+ if (!existingWorkIds.has(workId)) {
221
+ try {
222
+ yield client.link.createIssueCodeChangeLink(workId, codeChange.id);
223
+ }
224
+ catch (linkError) {
225
+ console.log(`Warning: Could not create link for work item ${workId}: ${linkError}`);
226
+ }
227
+ }
228
+ }
229
+ for (const link of existingLinks) {
230
+ const displayId = (_a = link.source) === null || _a === void 0 ? void 0 : _a.display_id;
231
+ if (displayId && !extractedWorkIds.has(displayId)) {
232
+ try {
233
+ yield client.link.delete(link.id);
234
+ }
235
+ catch (deleteError) {
236
+ console.log(`Warning: Could not delete stale link ${link.id}: ${deleteError}`);
237
+ }
238
+ }
239
+ }
240
+ }
241
+ catch (error) {
242
+ console.log(`Warning: Could not re-diff issue links: ${error}`);
243
+ }
244
+ return {
245
+ data: {
246
+ codeChangeId: codeChange.id,
247
+ isNew,
248
+ },
249
+ message: `Updated code_change for PR #${pullRequest.number}`,
250
+ success: true,
251
+ };
252
+ }
253
+ catch (error) {
254
+ return (0, helpers_1.createPRHandlerErrorResult)('PR edit', pullRequest, error);
255
+ }
256
+ });
257
+ }
258
+ exports.handlePREdit = handlePREdit;
259
+ //# sourceMappingURL=pr_edit_handler.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pr_edit_handler.js","sourceRoot":"","sources":["../../src/handlers/pr_edit_handler.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;GAYG;;;;;;;;;;;;AAEH,2CAIyB;AAIzB,uCAImB;AAGnB,gFAAgF;AAChF,UAAU;AACV,gFAAgF;AAEhF,SAAe,qBAAqB,CAClC,MAAyB,EACzB,MAOC;;QAED,MAAM,GAAG,GAAa,EAAE,CAAC;QACzB,KAAK,MAAM,KAAK,IAAI,MAAM,EAAE;YAC1B,IAAI;gBACF,MAAM,KAAK,GAAG,MAAM,MAAM,CAAC,OAAO,CAAC,mBAAmB,CACpD,KAAK,CAAC,WAAW,EACjB,KAAK,CAAC,KAAK,CACZ,CAAC;gBACF,IAAI,KAAK;oBAAE,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;aAC5B;YAAC,OAAO,KAAK,EAAE;gBACd,OAAO,CAAC,GAAG,CACT,oCACE,KAAK,CAAC,QAAQ,IAAI,KAAK,CAAC,WAC1B,KAAK,KAAK,EAAE,CACb,CAAC;aACH;SACF;QACD,OAAO,GAAG,CAAC;IACb,CAAC;CAAA;AAED,gFAAgF;AAChF,kBAAkB;AAClB,gFAAgF;AAEhF;;;;;;;;;;;;;;;;;;GAkBG;AACH,SAAsB,YAAY,CAChC,KAAq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other lifecycle transitions (converted to draft,
5
+ * ready for review, review requested/removed) are handled by the PR edit handler
6
+ * via NormalizedPullRequestEditEvent with pullRequest.isDraft and
7
+ * addRequestedReviewer/removeRequestedReviewer.
8
+ */
9
+ import { NormalizedPullRequestReopenEvent } from '../types/events';
10
+ import { HandlerContext, HandlerResult } from './types';
11
+ /**
12
+ * Process a pull request reopen event.
13
+ *
14
+ * Sets the code_change status to WAITING_FOR_REVIEW.
15
+ *
16
+ * No separate timeline entry is created — attribute changes on the code_change
17
+ * automatically generate timeline entries via DevRev's change tracking.
18
+ */
19
+ export declare function handlePRLifecycleEvent(input: NormalizedPullRequestReopenEvent, context: HandlerContext): Promise<HandlerResult>;
@@ -0,0 +1,58 @@
1
+ "use strict";
2
+ /**
3
+ * Handler for pull request lifecycle events.
4
+ *
5
+ * Handles PR reopen events. Other lifecycle transitions (converted to draft,
6
+ * ready for review, review requested/removed) are handled by the PR edit handler
7
+ * via NormalizedPullRequestEditEvent with pullRequest.isDraft and
8
+ * addRequestedReviewer/removeRequestedReviewer.
9
+ */
10
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
11
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
12
+ return new (P || (P = Promise))(function (resolve, reject) {
13
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
14
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
15
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
16
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
17
+ });
18
+ };
19
+ Object.defineProperty(exports, "__esModule", { value: true });
20
+ exports.handlePRLifecycleEvent = void 0;
21
+ const types_1 = require("../devrev/types");
22
+ const helpers_1 = require("./helpers");
23
+ /**
24
+ * Process a pull request reopen event.
25
+ *
26
+ * Sets the code_change status to WAITING_FOR_REVIEW.
27
+ *
28
+ * No separate timeline entry is created — attribute changes on the code_change
29
+ * automatically generate timeline entries via DevRev's change tracking.
30
+ */
31
+ function handlePRLifecycleEvent(input, context) {
32
+ return __awaiter(this, void 0, void 0, function* () {
33
+ const { pullRequest, repository } = input;
34
+ const repoName = repository.name;
35
+ const { client } = context;
36
+ try {
37
+ const { codeChange } = yield (0, helpers_1.getOrCreateCodeChangeForPR)(pullRequest, repoName, context);
38
+ const updateRequest = {
39
+ id: codeChange.id,
40
+ status: types_1.CodeChangeStatus.WAITING_FOR_REVIEW,
41
+ };
42
+ yield client.codeChange.update(updateRequest, codeChange);
43
+ return {
44
+ data: {
45
+ codeChangeId: codeChange.id,
46
+ eventType: input.type,
47
+ },
48
+ message: `Processed ${input.type} for PR #${pullRequest.number}`,
49
+ success: true,
50
+ };
51
+ }
52
+ catch (error) {
53
+ return (0, helpers_1.createPRHandlerErrorResult)(`PR lifecycle (${input.type})`, pullRequest, error);
54
+ }
55
+ });
56
+ }
57
+ exports.handlePRLifecycleEvent = handlePRLifecycleEvent;
58
+ //# sourceMappingURL=pr_lifecycle_handler.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pr_lifecycle_handler.js","sourceRoot":"","sources":["../../src/handlers/pr_lifecycle_handler.ts"],"names":[],"mappings":";AAAA;;;;;;;GAOG;;;;;;;;;;;;AAEH,2CAGyB;AAGzB,uCAGmB;AAGnB;;;;;;;GAOG;AACH,SAAsB,sBAAsB,CAC1C,KAAuC,EACvC,OAAuB;;QAEvB,MAAM,EAAE,WAAW,EAAE,UAAU,EAAE,GAAG,KAAK,CAAC;QAC1C,MAAM,QAAQ,GAAG,UAAU,CAAC,IAAI,CAAC;QACjC,MAAM,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC;QAE3B,IAAI;YACF,MAAM,EAAE,UAAU,EAAE,GAAG,MAAM,IAAA,oCAA0B,EACrD,WAAW,EACX,QAAQ,EACR,OAAO,CACR,CAAC;YAEF,MAAM,aAAa,GAAkC;gBACnD,EAAE,EAAE,UAAU,CAAC,EAAE;gBACjB,MAAM,EAAE,wBAAgB,CAAC,kBAAkB;aAC5C,CAAC;YAEF,MAAM,MAAM,CAAC,UAAU,CAAC,MAAM,CAAC,aAAa,EAAE,UAAU,CAAC,CAAC;YAE1D,OAAO;gBACL,IAAI,EAAE;oBACJ,YAAY,EAAE,UAAU,CAAC,EAAE;oBAC3B,SAAS,EAAE,KAAK,CAAC,IAAI;iBACtB;gBACD,OAAO,EAAE,aAAa,KAAK,CAAC,IAAI,YAAY,WAAW,CAAC,MAAM,EAAE;gBAChE,OAAO,EAAE,IAAI;aACd,CAAC;SACH;QAAC,OAAO,KAAK,EAAE;YACd,OAAO,IAAA,oCAA0B,EAAC,iBAAiB,KAAK,CAAC,IAAI,GAAG,EAAE,WAAW,EAAE,KAAK,CAAC,CAAC;SACvF;IACH,CAAC;CAAA;AAjCD,wDAiCC"}
@@ -43,9 +43,16 @@ const helpers_1 = require("./helpers");
43
43
  */
44
44
  function handlePRMerge(input, context) {
45
45
  return __awaiter(this, void 0, void 0, function* () {
46
- const { pullRequest, repository, mergedAt, mergeCommitSha } = input;
46
+ const { pullRequest, repository, mergedAt, mergeCommitSha, mergeCommitShas } = input;
47
47
  const repoName = repository.name;
48
48
  const { client, adapter } = context;
49
+ // Resolve merge commit SHAs: prefer the array (rebase-and-merge produces
50
+ // multiple commits), fall back to wrapping the legacy single-SHA field.
51
+ const resolvedShas = mergeCommitShas && mergeCommitShas.length > 0
52
+ ? mergeCommitShas
53
+ : mergeCommitSha
54
+ ? [mergeCommitSha]
55
+ : undefined;
49
56
  try {
50
57
  // Get or create code_change for this PR
51
58
  const { codeChange } = yield (0, helpers_1.getOrCreateCodeChangeForPR)(pullRequest, repoName, context);
@@ -58,7 +65,7 @@ function handlePRMerge(input, context) {
58
65
  console.log(`Warning: Could not fetch diff stats for PR #${pullRequest.number}: ${error}`);
59
66
  }
60
67
  // Build update request for merge
61
- const updateRequest = Object.assign(Object.assign({ id: codeChange.id, status: types_1.CodeChangeStatus.MERGED, closed_at: mergedAt }, (mergeCommitSha && { target_commits: [mergeCommitSha] })), (diffStats && {
68
+ const updateRequest = Object.assign(Object.assign({ id: codeChange.id, status: types_1.CodeChangeStatus.MERGED, closed_at: mergedAt }, (resolvedShas && { target_commits: resolvedShas })), (diffStats && {
62
69
  lines_added: diffStats.lines_added,
63
70
  lines_deleted: diffStats.lines_deleted,
64
71
  files_changed: diffStats.files_changed,
@@ -68,7 +75,7 @@ function handlePRMerge(input, context) {
68
75
  // The status change to MERGED generates a timeline entry automatically
69
76
  // via the code_change status field change delta.
70
77
  return {
71
- data: Object.assign({ codeChangeId: codeChange.id, mergedAt, mergeCommitSha: mergeCommitSha || null }, (diffStats && {
78
+ data: Object.assign({ codeChangeId: codeChange.id, mergedAt, mergeCommitSha: mergeCommitSha || null, mergeCommitShas: resolvedShas || null }, (diffStats && {
72
79
  linesAdded: diffStats.lines_added,
73
80
  linesDeleted: diffStats.lines_deleted,
74
81
  filesChanged: diffStats.files_changed,
@@ -1 +1 @@
1
- {"version":3,"file":"pr_merge_handler.js","sourceRoot":"","sources":["../../src/handlers/pr_merge_handler.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;;;;;;;;;;;AAEH,2CAGyB;AAIzB,uCAAmF;AAGnF,gFAAgF;AAChF,mBAAmB;AACnB,gFAAgF;AAEhF;;;;;;;;;;;;;;;;;;GAkBG;AACH,SAAsB,aAAa,CACjC,KAAsC,EACtC,OAAuB;;QAEvB,MAAM,EAAE,WAAW,EAAE,UAAU,EAAE,QAAQ,EAAE,cAAc,EAAE,GAAG,KAAK,CAAC;QACpE,MAAM,QAAQ,GAAG,UAAU,CAAC,IAAI,CAAC;QACjC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC;QAEpC,IAAI;YACF,wCAAwC;YACxC,MAAM,EAAE,UAAU,EAAE,GAAG,MAAM,IAAA,oCAA0B,EACrD,WAAW,EACX,QAAQ,EACR,OAAO,CACR,CAAC;YAEF,2EAA2E;YAC3E,IAAI,SAA0C,CAAC;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AAI;gBACf,WAAW,EAAE,SAAS,CAAC,WAAW;gBAClC,aAAa,EAAE,SAAS,CAAC,aAAa;gBACtC,aAAa,EAAE,SAAS,CAAC,aAAa;aACvC,CAAC,CACH,CAAC;YAEF,MAAM,MAAM,CAAC,UAAU,CAAC,MAAM,CAAC,aAAa,EAAE,UAAU,CAAC,CAAC;YAE1D,gEAAgE;YAChE,uEAAuE;YACvE,iDAAiD;YAEjD,OAAO;gBACL,IAAI,kBACF,YAAY,EAAE,UAAU,CAAC,EAAE,EAC3B,QAAQ,EACR,cAAc,EAAE,cAAc,IAAI,IAAI,EACtC,eAAe,EAAE,YAAY,IAAI,IAAI,IAClC,CAAC,SAAS,IAAI;oBACf,UAAU,EAAE,SAAS,CAAC,WAAW;oBACjC,YAAY,EAAE,SAAS,CAAC,aAAa;oBACrC,YAAY,EAAE,SAAS,CAAC,aAAa;iBACtC,CAAC,CACH;gBACD,OAAO,EAAE,2BAA2B,WAAW,CAAC,MAAM,EAAE;gBACxD,OAAO,EAAE,IAAI;aACd,CAAC;SACH;QAAC,OAAO,KAAK,EAAE;YACd,OAAO,IAAA,oCAA0B,EAAC,UAAU,EAAE,WAAW,EAAE,KAAK,CAAC,CAAC;SACnE;IACH,CAAC;CAAA;AAtED,sCAsEC"}
@@ -21,7 +21,10 @@ import { HandlerContext, HandlerResult } from './types';
21
21
  * - CHANGES_REQUESTED → status = CHANGES_REQUESTED, update reviewed_by
22
22
  * 4. Update review timestamps (first_review_at, last_review_at, first_approved_at, last_approved_at)
23
23
  * 5. Remove reviewer from requested_reviewers (they've submitted their review)
24
- * 6. Create a timeline entry for the review event
24
+ *
25
+ * No separate timeline entry is created — attribute changes on the code_change
26
+ * (status, approved_by, reviewed_by, requested_reviewers) automatically generate
27
+ * timeline entries via DevRev's change tracking.
25
28
  *
26
29
  * @param input - The normalized PR review event
27
30
  * @param context - The handler context with DevRev client and adapter
@@ -37,7 +37,10 @@ const helpers_1 = require("./helpers");
37
37
  * - CHANGES_REQUESTED → status = CHANGES_REQUESTED, update reviewed_by
38
38
  * 4. Update review timestamps (first_review_at, last_review_at, first_approved_at, last_approved_at)
39
39
  * 5. Remove reviewer from requested_reviewers (they've submitted their review)
40
- * 6. Create a timeline entry for the review event
40
+ *
41
+ * No separate timeline entry is created — attribute changes on the code_change
42
+ * (status, approved_by, reviewed_by, requested_reviewers) automatically generate
43
+ * timeline entries via DevRev's change tracking.
41
44
  *
42
45
  * @param input - The normalized PR review event
43
46
  * @param context - The handler context with DevRev client and adapter
@@ -82,14 +85,17 @@ function handlePRReview(input, context) {
82
85
  else if (state === events_1.ReviewStateValues.CHANGES_REQUESTED) {
83
86
  updateRequest.status = types_1.CodeChangeStatus.CHANGES_REQUESTED;
84
87
  }
88
+ else if (state === events_1.ReviewStateValues.COMMENTED) {
89
+ // COMMENTED reviews: preserve APPROVED status if already set,
90
+ // otherwise treat as CHANGES_REQUESTED to surface that the PR
91
+ // still needs attention.
92
+ const existingStatus = (0, helpers_1.getCodeChangeCustomField)(codeChange, types_1.CodeChangeFields.STATUS);
93
+ const isAlreadyApproved = existingStatus === types_1.CodeChangeStatus.APPROVED;
94
+ if (!isAlreadyApproved) {
95
+ updateRequest.status = types_1.CodeChangeStatus.CHANGES_REQUESTED;
96
+ }
97
+ }
85
98
  yield client.codeChange.update(updateRequest, codeChange);
86
- // Create timeline entry for the review
87
- // Prefer the resolved DevRev user identity; fall back to provider username
88
- const reviewerName = reviewerDevUserId || reviewer.username || 'A reviewer';
89
- const message = state === events_1.ReviewStateValues.APPROVED
90
- ? `${reviewerName} approved PR #${pullRequest.number}`
91
- : `${reviewerName} requested changes on PR #${pullRequest.number}`;
92
- yield (0, helpers_1.createPRTimelineEntry)(codeChange.id, pullRequest, repoName, reviewedAt, message, context);
93
99
  return {
94
100
  data: {
95
101
  codeChangeId: codeChange.id,
@@ -1 +1 @@
1
- {"version":3,"file":"pr_review_handler.js","sourceRoot":"","sources":["../../src/handlers/pr_review_handler.ts"],"names":[],"mappings":";AAAA;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2
  * Default handler registry for the Git SDK.
3
3
  *
4
4
  * Maps each normalized event type to its corresponding handler function.
5
- * `pull_request_edit` is intentionally not mapped — there is no dedicated
6
- * handler for edit events yet.
7
5
  */
8
6
  import { HandlerRegistry } from './types';
9
7
  export declare const DEFAULT_HANDLER_REGISTRY: HandlerRegistry;
@@ -3,20 +3,22 @@
3
3
  * Default handler registry for the Git SDK.
4
4
  *
5
5
  * Maps each normalized event type to its corresponding handler function.
6
- * `pull_request_edit` is intentionally not mapped — there is no dedicated
7
- * handler for edit events yet.
8
6
  */
9
7
  Object.defineProperty(exports, "__esModule", { value: true });
10
8
  exports.DEFAULT_HANDLER_REGISTRY = void 0;
11
9
  const commit_push_handler_1 = require("./commit_push_handler");
12
10
  const pr_create_handler_1 = require("./pr_create_handler");
11
+ const pr_edit_handler_1 = require("./pr_edit_handler");
12
+ const pr_lifecycle_handler_1 = require("./pr_lifecycle_handler");
13
13
  const pr_review_handler_1 = require("./pr_review_handler");
14
14
  const pr_merge_handler_1 = require("./pr_merge_handler");
15
15
  exports.DEFAULT_HANDLER_REGISTRY = {
16
16
  'push': commit_push_handler_1.handlePushEvent,
17
17
  'pull_request_create': pr_create_handler_1.handlePRCreate,
18
+ 'pull_request_edit': pr_edit_handler_1.handlePREdit,
18
19
  'pull_request_close': pr_create_handler_1.handlePRClose,
19
20
  'pull_request_review': pr_review_handler_1.handlePRReview,
20
21
  'pull_request_merge': pr_merge_handler_1.handlePRMerge,
22
+ 'pull_request_reopen': pr_lifecycle_handler_1.handlePRLifecycleEvent,
21
23
  };
22
24
  //# sourceMappingURL=registry.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"registry.js","sourceRoot":"","sources":["../../src/handlers/registry.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;;AAEH,+DAAwD;AACxD,2DAAoE;AACpE,2DAAqD;AACrD,yDAAmD;AAGtC,QAAA,wBAAwB,GAAoB;IACvD,MAAM,EAAE,qCAA+B;IACvC,qBAAqB,EAAE,kCAA8B;IACrD,oBAAoB,EAAE,iCAA6B;IACnD,qBAAqB,EAAE,kCAA8B;IACrD,oBAAoB,EAAE,gCAA6B;CACpD,CAAC"}
1
+ {"version":3,"file":"registry.js","sourceRoot":"","sources":["../../src/handlers/registry.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;AAEH,+DAAwD;AACxD,2DAAoE;AACpE,uDAAiD;AACjD,iEAAgE;AAChE,2DAAqD;AACrD,yDAAmD;AAGtC,QAAA,wBAAwB,GAAoB;IACvD,MAAM,EAAE,qCAA+B;IACvC,qBAAqB,EAAE,kCAA8B;IACrD,mBAAmB,EAAE,8BAA4B;IACjD,oBAAoB,EAAE,iCAA6B;IACnD,qBAAqB,EAAE,kCAA8B;IACrD,oBAAoB,EAAE,gCAA6B;IACnD,qBAAqB,EAAE,6CAAsC;CAC9D,CAAC"}
@@ -35,6 +35,12 @@ export interface HandlerContext {
35
35
  * The provider adapter for extracting work IDs and fetching commits.
36
36
  */
37
37
  adapter: IProviderAdapter;
38
+ /**
39
+ * Usernames or external IDs of known bot actors.
40
+ * When the event actor matches one of these, handlers replace the actor
41
+ * with the PR author for timeline entries and commit attribution.
42
+ */
43
+ botActors: string[];
38
44
  }
39
45
  /**
40
46
  * A handler function that processes a normalized event.
package/dist/index.d.ts CHANGED
@@ -4,9 +4,9 @@
4
4
  * This SDK provides interfaces that git connectors can implement
5
5
  * to publish events from git tools (GitHub, GitLab, etc.) into DevRev.
6
6
  */
7
- export { type ProviderContext, type DevRevConfig, type SDKConfiguration, type NormalizedActor, type NormalizedCommit, type NormalizedBranch, type NormalizedDiffStats, type NormalizedPullRequest, type NormalizedRepository, type NormalizedEvent, type NormalizedPushEvent, type NormalizedPullRequestCreateEvent, type NormalizedPullRequestEditEvent, type NormalizedPRReviewEvent, type NormalizedPullRequestCloseEvent, type NormalizedPullRequestMergeEvent, ReviewStateValues, type ReviewState, } from './types';
7
+ export { type ProviderContext, type DevRevConfig, type SDKConfiguration, type NormalizedActor, type NormalizedCommit, type NormalizedBranch, type NormalizedDiffStats, type NormalizedPullRequest, type NormalizedRepository, type NormalizedEvent, type NormalizedPushEvent, type NormalizedPullRequestCreateEvent, type NormalizedPullRequestEditEvent, type NormalizedPRReviewEvent, type NormalizedPullRequestCloseEvent, type NormalizedPullRequestMergeEvent, type NormalizedPullRequestReopenEvent, ReviewStateValues, type ReviewState, } from './types';
8
8
  export { createConfig, type CreateConfigOptions } from './config';
9
9
  export { DevRevClient, type DevRevClientConfig, getErrorMessage, getCodeChangeSourceFromProvider, CODE_CHANGE_LEAF_TYPE, TF_PREFIX, tf, ISSUE_CODE_CHANGE_LINK_TYPE_NAME, ISSUE_CODE_CHANGE_LINK_TOOLTIP, ISSUE_CODE_CHANGE_FORWARD_NAME, ISSUE_CODE_CHANGE_BACKWARD_NAME, CodeChangeSource, CodeChangeStatus, CodeChangeFields, GitProviderValues, type GitProvider, type CodeChangeSourceType, type CodeChangeStatusType, type CodeChangeCustomCreateRequest, type CodeChangeCustomUpdateRequest, type TimelineEventMetadata, type ChangeEventBody, type HTTPResponse, type TenantFragmentResult, type CustomLinkTypeInstallResult, type TimelineResult, CodeChangeManager, TenantFragmentManager, CustomLinkTypeManager, LinkManager, TimelineManager, DevUserManager, EventMetadataKeys, postCall, getCall, constructURL, } from './devrev';
10
- export { handlePushEvent, handlePRCreate, handlePRClose, handlePRReview, handlePRMerge, DEFAULT_HANDLER_REGISTRY, type EventHandler, type HandlerContext, type HandlerRegistry, type HandlerResult, } from './handlers';
10
+ export { handlePushEvent, handlePRCreate, handlePRClose, handlePREdit, handlePRLifecycleEvent, handlePRReview, handlePRMerge, isBotActor, resolveActorForAttribution, DEFAULT_HANDLER_REGISTRY, type EventHandler, type HandlerContext, type HandlerRegistry, type HandlerResult, } from './handlers';
11
11
  export { EventOrchestrator, type EventOrchestratorConfig, } from './orchestrator';
12
12
  export { type IProviderAdapter } from './adapter/adapter';
package/dist/index.js CHANGED
@@ -6,7 +6,7 @@
6
6
  * to publish events from git tools (GitHub, GitLab, etc.) into DevRev.
7
7
  */
8
8
  Object.defineProperty(exports, "__esModule", { value: true });
9
- exports.EventOrchestrator = exports.DEFAULT_HANDLER_REGISTRY = exports.handlePRMerge = exports.handlePRReview = exports.handlePRClose = exports.handlePRCreate = exports.handlePushEvent = exports.constructURL = exports.getCall = exports.postCall = exports.EventMetadataKeys = exports.DevUserManager = exports.TimelineManager = exports.LinkManager = exports.CustomLinkTypeManager = exports.TenantFragmentManager = exports.CodeChangeManager = exports.GitProviderValues = exports.CodeChangeFields = exports.CodeChangeStatus = exports.CodeChangeSource = exports.ISSUE_CODE_CHANGE_BACKWARD_NAME = exports.ISSUE_CODE_CHANGE_FORWARD_NAME = exports.ISSUE_CODE_CHANGE_LINK_TOOLTIP = exports.ISSUE_CODE_CHANGE_LINK_TYPE_NAME = exports.tf = exports.TF_PREFIX = exports.CODE_CHANGE_LEAF_TYPE = exports.getCodeChangeSourceFromProvider = exports.getErrorMessage = exports.DevRevClient = exports.createConfig = exports.ReviewStateValues = void 0;
9
+ exports.EventOrchestrator = exports.DEFAULT_HANDLER_REGISTRY = exports.resolveActorForAttribution = exports.isBotActor = exports.handlePRMerge = exports.handlePRReview = exports.handlePRLifecycleEvent = exports.handlePREdit = exports.handlePRClose = exports.handlePRCreate = exports.handlePushEvent = exports.constructURL = exports.getCall = exports.postCall = exports.EventMetadataKeys = exports.DevUserManager = exports.TimelineManager = exports.LinkManager = exports.CustomLinkTypeManager = exports.TenantFragmentManager = exports.CodeChangeManager = exports.GitProviderValues = exports.CodeChangeFields = exports.CodeChangeStatus = exports.CodeChangeSource = exports.ISSUE_CODE_CHANGE_BACKWARD_NAME = exports.ISSUE_CODE_CHANGE_FORWARD_NAME = exports.ISSUE_CODE_CHANGE_LINK_TOOLTIP = exports.ISSUE_CODE_CHANGE_LINK_TYPE_NAME = exports.tf = exports.TF_PREFIX = exports.CODE_CHANGE_LEAF_TYPE = exports.getCodeChangeSourceFromProvider = exports.getErrorMessage = exports.DevRevClient = exports.createConfig = exports.ReviewStateValues = void 0;
10
10
  // Types - re-export from types module
11
11
  var types_1 = require("./types");
12
12
  Object.defineProperty(exports, "ReviewStateValues", { enumerable: true, get: function () { return types_1.ReviewStateValues; } });
@@ -53,10 +53,17 @@ Object.defineProperty(exports, "handlePushEvent", { enumerable: true, get: funct
53
53
  // PR handlers
54
54
  Object.defineProperty(exports, "handlePRCreate", { enumerable: true, get: function () { return handlers_1.handlePRCreate; } });
55
55
  Object.defineProperty(exports, "handlePRClose", { enumerable: true, get: function () { return handlers_1.handlePRClose; } });
56
+ // PR edit handler
57
+ Object.defineProperty(exports, "handlePREdit", { enumerable: true, get: function () { return handlers_1.handlePREdit; } });
58
+ // PR lifecycle handler
59
+ Object.defineProperty(exports, "handlePRLifecycleEvent", { enumerable: true, get: function () { return handlers_1.handlePRLifecycleEvent; } });
56
60
  // PR review handler
57
61
  Object.defineProperty(exports, "handlePRReview", { enumerable: true, get: function () { return handlers_1.handlePRReview; } });
58
62
  // PR merge handler
59
63
  Object.defineProperty(exports, "handlePRMerge", { enumerable: true, get: function () { return handlers_1.handlePRMerge; } });
64
+ // Bot actor utilities
65
+ Object.defineProperty(exports, "isBotActor", { enumerable: true, get: function () { return handlers_1.isBotActor; } });
66
+ Object.defineProperty(exports, "resolveActorForAttribution", { enumerable: true, get: function () { return handlers_1.resolveActorForAttribution; } });
60
67
  // Handler registry
61
68
  Object.defineProperty(exports, "DEFAULT_HANDLER_REGISTRY", { enumerable: true, get: function () { return handlers_1.DEFAULT_HANDLER_REGISTRY; } });
62
69
  // Event Orchestrator
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAEH,sCAAsC;AACtC,iCAqBiB;AAFf,0GAAA,iBAAiB,OAAA;AAInB,SAAS;AACT,mCAAkE;AAAzD,sGAAA,YAAY,OAAA;AAErB,gBAAgB;AAChB,mCA6CkB;AA5ChB,cA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chestrator {
62
62
  private readonly client;
63
63
  private readonly adapter;
64
64
  private readonly source;
65
+ private readonly botActors;
65
66
  /**
66
67
  * Creates a new EventOrchestrator.
67
68
  *
@@ -66,6 +66,7 @@ class EventOrchestrator {
66
66
  * @param config - The orchestrator configuration
67
67
  */
68
68
  constructor(config) {
69
+ var _a;
69
70
  this.client = new client_1.DevRevClient({
70
71
  endpoint: config.sdkConfig.devrev.endpoint,
71
72
  token: config.sdkConfig.devrev.token,
@@ -73,6 +74,7 @@ class EventOrchestrator {
73
74
  });
74
75
  this.adapter = config.adapter;
75
76
  this.source = (0, types_1.getCodeChangeSourceFromProvider)(config.provider);
77
+ this.botActors = (_a = config.sdkConfig.bot_actors) !== null && _a !== void 0 ? _a : [];
76
78
  }
77
79
  /**
78
80
  * Processes a raw event from a Git provider.
@@ -127,6 +129,7 @@ class EventOrchestrator {
127
129
  buildHandlerContext(eventType) {
128
130
  return {
129
131
  adapter: this.adapter,
132
+ botActors: this.botActors,
130
133
  client: this.client,
131
134
  eventType,
132
135
  source: this.source,
@@ -1 +1 @@
1
- {"version":3,"file":"event_orchestrator.js","sourceRoot":"","sources":["../../src/orchestrator/event_orchestrator.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;GAaG;;;;;;;;;;;;AAGH,6CAAgD;AAChD,2CAAyG;AACzG,mDAAgE;AA2BhE,gFAAgF;AAChF,qBAAqB;AACrB,gFAAgF;AAEhF;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,MAAa,iBAAiB;IAO5B;;;;;;OAMG;IACH,YAAY,MAA+B;QACzC,IAAI,CAAC,MAAM,GAAG,IAAI,qBAAY,CAAC;YAC7B,QAAQ,EAAE,MAAM,CAAC,SAAS,CAAC,MAAM,CAAC,QAAQ;YAC1C,KAAK,EAAE,MAAM,CAAC,SAAS,CAAC,MAAM,CAAC,KAAK;YACpC,QAAQ,EAAE,MAAM,CAAC,QAAQ;SAC1B,CAAC,CAAC;QACH,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC,OAAO,CAAC;QAC9B,IAAI,CAAC,MAAM,GAAG,IAAA,uCAA+B,EAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;IACjE,CAAC;IAED;;;;;;;;;;OAUG;IACG,YAAY,CAAC,QAAiB;;YAClC,IAAI;gBACF,MAAM,eAAe,GAAG,IAAI,CAAC,OAAO,CAAC,cAAc,CAAC,QAAQ,CAAC,CAAC;gBAC9D,OAAO,MAAM,IAAI,CAAC,sBAAsB,CAAC,eAAe,CAAC,CAAC;aAC3D;YAAC,OAAO,KAAK,EAAE;gBACd,OAAO;oBACL,OAAO,EAAE,4BAA4B,IAAA,uBAAe,EAAC,KAAK,CAAC,EAAE;oBAC7D,OAAO,EAAE,KAAK;iBACf,CAAC;aACH;QACH,CAAC;KAAA;IAED;;;;;;;;OAQG;IACG,sBAAsB,CAAC,KAAsB;;YACjD,MAAM,OAAO,GAAG,mCAAwB,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;YAErD,IAAI,CAAC,OAAO,EAAE;gBACZ,OAAO;oBACL,OAAO,EAAE,yCAAyC,KAAK,CAAC,IAAI,EAAE;oBAC9D,OAAO,EAAE,KAAK;iBACf,CAAC;aACH;YAED,MAAM,OAAO,GAAG,IAAI,CAAC,mBAAmB,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;YACrD,OAAO,OAAO,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;QACjC,CAAC;KAAA;IAED;;OAEG;IACK,mBAAmB,CAAC,SAAiB;QAC3C,OAAO;YACL,OAAO,EAAE,IAAI,CAAC,OAAO;YACrB,MAAM,EAAE,IAAI,CAAC,MAAM;YACnB,SAAS;YACT,MAAM,EAAE,IAAI,CAAC,MAAM;SACpB,CAAC;IACJ,CAAC;CACF;AAjFD,8CAiFC"}
1
+ {"version":3,"file":"event_orchestrator.js","sourceRoot":"","sources":["../../src/orchestrator/event_orchestrator.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;GAaG;;;;;;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