@h-rig/rig-extension 0.0.6-alpha.100
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/README.md +1 -0
- package/dist/src/board-theme.js +150 -0
- package/dist/src/board-views.js +475 -0
- package/dist/src/extension.js +3757 -0
- package/dist/src/workflow/identity.js +429 -0
- package/dist/src/workflow/projections.js +389 -0
- package/package.json +36 -0
|
@@ -0,0 +1,429 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
// packages/rig-extension/src/workflow/projections.ts
|
|
3
|
+
var RIG_WORKFLOW_STARTED = "rig.workflow.started";
|
|
4
|
+
var RIG_WORKFLOW_TARGET_SELECTED = "rig.workflow.target.selected";
|
|
5
|
+
var RIG_WORKFLOW_TASK_SELECTED = "rig.workflow.task.selected";
|
|
6
|
+
var RIG_WORKFLOW_STATUS_CHANGED = "rig.workflow.status.changed";
|
|
7
|
+
var RIG_WORKFLOW_OPERATOR_NOTE = "rig.workflow.operator.note";
|
|
8
|
+
var RIG_WORKFLOW_INBOX_REQUESTED = "rig.workflow.inbox.requested";
|
|
9
|
+
var RIG_WORKFLOW_INBOX_RESOLVED = "rig.workflow.inbox.resolved";
|
|
10
|
+
var EMPTY_PROJECTION = {
|
|
11
|
+
started: null,
|
|
12
|
+
target: null,
|
|
13
|
+
task: null,
|
|
14
|
+
status: null,
|
|
15
|
+
notes: [],
|
|
16
|
+
inbox: [],
|
|
17
|
+
resolvedInbox: [],
|
|
18
|
+
updatedAt: null
|
|
19
|
+
};
|
|
20
|
+
function asRecord(value) {
|
|
21
|
+
return value && typeof value === "object" && !Array.isArray(value) ? value : null;
|
|
22
|
+
}
|
|
23
|
+
function optionalString(value) {
|
|
24
|
+
return typeof value === "string" && value.trim().length > 0 ? value.trim() : undefined;
|
|
25
|
+
}
|
|
26
|
+
function requiredString(value) {
|
|
27
|
+
const text = optionalString(value);
|
|
28
|
+
return text ?? null;
|
|
29
|
+
}
|
|
30
|
+
function timestamp(value) {
|
|
31
|
+
const text = requiredString(value);
|
|
32
|
+
if (!text)
|
|
33
|
+
return null;
|
|
34
|
+
const millis = Date.parse(text);
|
|
35
|
+
return Number.isFinite(millis) ? text : null;
|
|
36
|
+
}
|
|
37
|
+
function newer(left, right) {
|
|
38
|
+
if (!right)
|
|
39
|
+
return false;
|
|
40
|
+
if (!left)
|
|
41
|
+
return true;
|
|
42
|
+
return Date.parse(right) >= Date.parse(left);
|
|
43
|
+
}
|
|
44
|
+
function isWorkflowTarget(value) {
|
|
45
|
+
return value === "local" || value === "remote";
|
|
46
|
+
}
|
|
47
|
+
function isWorkflowStatus(value) {
|
|
48
|
+
return value === "starting" || value === "running" || value === "waiting-approval" || value === "waiting-input" || value === "completed" || value === "failed" || value === "stopped";
|
|
49
|
+
}
|
|
50
|
+
function isInboxKind(value) {
|
|
51
|
+
return value === "approval" || value === "input";
|
|
52
|
+
}
|
|
53
|
+
function isInboxDecision(value) {
|
|
54
|
+
return value === "approved" || value === "rejected" || value === "answered";
|
|
55
|
+
}
|
|
56
|
+
function parseOwner(value) {
|
|
57
|
+
const record = asRecord(value);
|
|
58
|
+
if (!record)
|
|
59
|
+
return null;
|
|
60
|
+
const githubUserId = requiredString(record.githubUserId);
|
|
61
|
+
const login = requiredString(record.login);
|
|
62
|
+
const namespaceKey = requiredString(record.namespaceKey);
|
|
63
|
+
return githubUserId && login && namespaceKey ? { githubUserId, login, namespaceKey } : null;
|
|
64
|
+
}
|
|
65
|
+
function parseStringArray(value) {
|
|
66
|
+
if (!Array.isArray(value))
|
|
67
|
+
return;
|
|
68
|
+
const options = value.map(optionalString).filter((option) => option !== undefined);
|
|
69
|
+
return options.length > 0 ? options : undefined;
|
|
70
|
+
}
|
|
71
|
+
function hasOwn(record, key) {
|
|
72
|
+
return Object.prototype.hasOwnProperty.call(record, key);
|
|
73
|
+
}
|
|
74
|
+
function entryUpdatedAt(entry) {
|
|
75
|
+
if ("createdAt" in entry)
|
|
76
|
+
return entry.createdAt;
|
|
77
|
+
if ("selectedAt" in entry)
|
|
78
|
+
return entry.selectedAt;
|
|
79
|
+
if ("changedAt" in entry)
|
|
80
|
+
return entry.changedAt;
|
|
81
|
+
if ("notedAt" in entry)
|
|
82
|
+
return entry.notedAt;
|
|
83
|
+
if ("requestedAt" in entry)
|
|
84
|
+
return entry.requestedAt;
|
|
85
|
+
return entry.resolvedAt;
|
|
86
|
+
}
|
|
87
|
+
function parseWorkflowStarted(data) {
|
|
88
|
+
const record = asRecord(data);
|
|
89
|
+
if (!record || record.schemaVersion !== 1)
|
|
90
|
+
return null;
|
|
91
|
+
const workflowId = requiredString(record.workflowId);
|
|
92
|
+
const target = optionalString(record.target);
|
|
93
|
+
const selectedRepo = requiredString(record.selectedRepo);
|
|
94
|
+
const owner = parseOwner(record.owner);
|
|
95
|
+
const createdAt = timestamp(record.createdAt);
|
|
96
|
+
if (!workflowId || !isWorkflowTarget(target) || !selectedRepo || !owner || !createdAt)
|
|
97
|
+
return null;
|
|
98
|
+
return {
|
|
99
|
+
schemaVersion: 1,
|
|
100
|
+
workflowId,
|
|
101
|
+
target,
|
|
102
|
+
selectedRepo,
|
|
103
|
+
owner,
|
|
104
|
+
createdAt
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
function parseWorkflowTargetSelected(data) {
|
|
108
|
+
const record = asRecord(data);
|
|
109
|
+
if (!record || record.schemaVersion !== 1)
|
|
110
|
+
return null;
|
|
111
|
+
const target = optionalString(record.target);
|
|
112
|
+
const selectedAt = timestamp(record.selectedAt);
|
|
113
|
+
if (!isWorkflowTarget(target) || !selectedAt)
|
|
114
|
+
return null;
|
|
115
|
+
const reason = optionalString(record.reason);
|
|
116
|
+
return {
|
|
117
|
+
schemaVersion: 1,
|
|
118
|
+
target,
|
|
119
|
+
...reason ? { reason } : {},
|
|
120
|
+
selectedAt
|
|
121
|
+
};
|
|
122
|
+
}
|
|
123
|
+
function parseWorkflowTaskSelected(data) {
|
|
124
|
+
const record = asRecord(data);
|
|
125
|
+
if (!record || record.schemaVersion !== 1)
|
|
126
|
+
return null;
|
|
127
|
+
const taskId = requiredString(record.taskId);
|
|
128
|
+
const selectedAt = timestamp(record.selectedAt);
|
|
129
|
+
if (!taskId || !selectedAt)
|
|
130
|
+
return null;
|
|
131
|
+
const title = optionalString(record.title);
|
|
132
|
+
return { schemaVersion: 1, taskId, ...title ? { title } : {}, selectedAt };
|
|
133
|
+
}
|
|
134
|
+
function parseWorkflowStatusChanged(data) {
|
|
135
|
+
const record = asRecord(data);
|
|
136
|
+
if (!record || record.schemaVersion !== 1)
|
|
137
|
+
return null;
|
|
138
|
+
const status = optionalString(record.status);
|
|
139
|
+
const changedAt = timestamp(record.changedAt);
|
|
140
|
+
if (!changedAt || !isWorkflowStatus(status))
|
|
141
|
+
return null;
|
|
142
|
+
const detail = optionalString(record.detail);
|
|
143
|
+
return { schemaVersion: 1, status, ...detail ? { detail } : {}, changedAt };
|
|
144
|
+
}
|
|
145
|
+
function parseWorkflowOperatorNote(data) {
|
|
146
|
+
const record = asRecord(data);
|
|
147
|
+
if (!record || record.schemaVersion !== 1)
|
|
148
|
+
return null;
|
|
149
|
+
const note = requiredString(record.note);
|
|
150
|
+
const notedAt = timestamp(record.notedAt);
|
|
151
|
+
if (!note || !notedAt)
|
|
152
|
+
return null;
|
|
153
|
+
const noteId = optionalString(record.noteId);
|
|
154
|
+
return { schemaVersion: 1, ...noteId ? { noteId } : {}, note, notedAt };
|
|
155
|
+
}
|
|
156
|
+
function parseWorkflowInboxRequested(data) {
|
|
157
|
+
const record = asRecord(data);
|
|
158
|
+
if (!record || record.schemaVersion !== 1)
|
|
159
|
+
return null;
|
|
160
|
+
const requestId = requiredString(record.requestId);
|
|
161
|
+
const kind = optionalString(record.kind);
|
|
162
|
+
const title = requiredString(record.title);
|
|
163
|
+
const requestedAt = timestamp(record.requestedAt);
|
|
164
|
+
if (!requestId || !isInboxKind(kind) || !title || !requestedAt)
|
|
165
|
+
return null;
|
|
166
|
+
const body = optionalString(record.body);
|
|
167
|
+
const options = parseStringArray(record.options);
|
|
168
|
+
return {
|
|
169
|
+
schemaVersion: 1,
|
|
170
|
+
requestId,
|
|
171
|
+
kind,
|
|
172
|
+
title,
|
|
173
|
+
...body ? { body } : {},
|
|
174
|
+
...options ? { options } : {},
|
|
175
|
+
requestedAt
|
|
176
|
+
};
|
|
177
|
+
}
|
|
178
|
+
function parseWorkflowInboxResolved(data) {
|
|
179
|
+
const record = asRecord(data);
|
|
180
|
+
if (!record || record.schemaVersion !== 1)
|
|
181
|
+
return null;
|
|
182
|
+
const requestId = requiredString(record.requestId);
|
|
183
|
+
const decision = optionalString(record.decision);
|
|
184
|
+
const resolvedAt = timestamp(record.resolvedAt);
|
|
185
|
+
if (!requestId || !isInboxDecision(decision) || !resolvedAt)
|
|
186
|
+
return null;
|
|
187
|
+
const base = { schemaVersion: 1, requestId, decision, resolvedAt };
|
|
188
|
+
return hasOwn(record, "answer") ? { ...base, answer: record.answer } : base;
|
|
189
|
+
}
|
|
190
|
+
function collectPendingInboxRequests(entries) {
|
|
191
|
+
const requested = new Map;
|
|
192
|
+
const resolved = new Map;
|
|
193
|
+
for (const entry of entries) {
|
|
194
|
+
if (entry.type !== "custom")
|
|
195
|
+
continue;
|
|
196
|
+
if (entry.customType === RIG_WORKFLOW_INBOX_REQUESTED) {
|
|
197
|
+
const request = parseWorkflowInboxRequested(entry.data);
|
|
198
|
+
if (request && newer(requested.get(request.requestId)?.requestedAt, request.requestedAt))
|
|
199
|
+
requested.set(request.requestId, request);
|
|
200
|
+
} else if (entry.customType === RIG_WORKFLOW_INBOX_RESOLVED) {
|
|
201
|
+
const resolution = parseWorkflowInboxResolved(entry.data);
|
|
202
|
+
if (resolution && newer(resolved.get(resolution.requestId), resolution.resolvedAt))
|
|
203
|
+
resolved.set(resolution.requestId, resolution.resolvedAt);
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
for (const [requestId, request] of requested) {
|
|
207
|
+
const resolvedAt = resolved.get(requestId);
|
|
208
|
+
if (resolvedAt && Date.parse(resolvedAt) >= Date.parse(request.requestedAt))
|
|
209
|
+
requested.delete(requestId);
|
|
210
|
+
}
|
|
211
|
+
return Array.from(requested.values()).sort((a, b) => Date.parse(b.requestedAt) - Date.parse(a.requestedAt));
|
|
212
|
+
}
|
|
213
|
+
function collectResolvedInboxRequests(entries) {
|
|
214
|
+
const requested = new Map;
|
|
215
|
+
const resolved = new Map;
|
|
216
|
+
for (const entry of entries) {
|
|
217
|
+
if (entry.type !== "custom")
|
|
218
|
+
continue;
|
|
219
|
+
if (entry.customType === RIG_WORKFLOW_INBOX_REQUESTED) {
|
|
220
|
+
const request = parseWorkflowInboxRequested(entry.data);
|
|
221
|
+
if (request && newer(requested.get(request.requestId), request.requestedAt))
|
|
222
|
+
requested.set(request.requestId, request.requestedAt);
|
|
223
|
+
} else if (entry.customType === RIG_WORKFLOW_INBOX_RESOLVED) {
|
|
224
|
+
const resolution = parseWorkflowInboxResolved(entry.data);
|
|
225
|
+
if (resolution && newer(resolved.get(resolution.requestId)?.resolvedAt, resolution.resolvedAt)) {
|
|
226
|
+
resolved.set(resolution.requestId, resolution);
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
for (const [requestId, resolution] of resolved) {
|
|
231
|
+
const requestedAt = requested.get(requestId);
|
|
232
|
+
if (requestedAt && Date.parse(requestedAt) > Date.parse(resolution.resolvedAt))
|
|
233
|
+
resolved.delete(requestId);
|
|
234
|
+
}
|
|
235
|
+
return Array.from(resolved.values()).sort((a, b) => Date.parse(b.resolvedAt) - Date.parse(a.resolvedAt));
|
|
236
|
+
}
|
|
237
|
+
function projectWorkflowEntries(entries) {
|
|
238
|
+
let started = null;
|
|
239
|
+
let target = null;
|
|
240
|
+
let task = null;
|
|
241
|
+
let status = null;
|
|
242
|
+
const notes = [];
|
|
243
|
+
let updatedAt = null;
|
|
244
|
+
for (const entry of entries) {
|
|
245
|
+
if (entry.type !== "custom")
|
|
246
|
+
continue;
|
|
247
|
+
if (entry.customType === RIG_WORKFLOW_STARTED) {
|
|
248
|
+
const parsed = parseWorkflowStarted(entry.data);
|
|
249
|
+
if (parsed && newer(started?.createdAt, parsed.createdAt))
|
|
250
|
+
started = parsed;
|
|
251
|
+
} else if (entry.customType === RIG_WORKFLOW_TARGET_SELECTED) {
|
|
252
|
+
const parsed = parseWorkflowTargetSelected(entry.data);
|
|
253
|
+
if (parsed && newer(target?.selectedAt, parsed.selectedAt))
|
|
254
|
+
target = parsed;
|
|
255
|
+
} else if (entry.customType === RIG_WORKFLOW_TASK_SELECTED) {
|
|
256
|
+
const parsed = parseWorkflowTaskSelected(entry.data);
|
|
257
|
+
if (parsed && newer(task?.selectedAt, parsed.selectedAt))
|
|
258
|
+
task = parsed;
|
|
259
|
+
} else if (entry.customType === RIG_WORKFLOW_STATUS_CHANGED) {
|
|
260
|
+
const parsed = parseWorkflowStatusChanged(entry.data);
|
|
261
|
+
if (parsed && newer(status?.changedAt, parsed.changedAt))
|
|
262
|
+
status = parsed;
|
|
263
|
+
} else if (entry.customType === RIG_WORKFLOW_OPERATOR_NOTE) {
|
|
264
|
+
const parsed = parseWorkflowOperatorNote(entry.data);
|
|
265
|
+
if (parsed)
|
|
266
|
+
notes.push(parsed);
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
notes.sort((a, b) => Date.parse(b.notedAt) - Date.parse(a.notedAt));
|
|
270
|
+
for (const value of [started, target, task, status, ...notes].map((entry) => entry ? entryUpdatedAt(entry) : null)) {
|
|
271
|
+
if (newer(updatedAt, value))
|
|
272
|
+
updatedAt = value;
|
|
273
|
+
}
|
|
274
|
+
const inbox = collectPendingInboxRequests(entries);
|
|
275
|
+
const resolvedInbox = collectResolvedInboxRequests(entries);
|
|
276
|
+
for (const entry of [...inbox, ...resolvedInbox]) {
|
|
277
|
+
if (newer(updatedAt, entryUpdatedAt(entry)))
|
|
278
|
+
updatedAt = entryUpdatedAt(entry);
|
|
279
|
+
}
|
|
280
|
+
if (!started && !target && !task && !status && notes.length === 0 && inbox.length === 0 && resolvedInbox.length === 0 && !updatedAt)
|
|
281
|
+
return EMPTY_PROJECTION;
|
|
282
|
+
return { started, target, task, status, notes, inbox, resolvedInbox, updatedAt };
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
// packages/rig-extension/src/workflow/identity.ts
|
|
286
|
+
function stringField(value) {
|
|
287
|
+
return typeof value === "string" && value.trim().length > 0 ? value.trim() : undefined;
|
|
288
|
+
}
|
|
289
|
+
function numericStringField(value) {
|
|
290
|
+
return typeof value === "number" && Number.isInteger(value) ? String(value) : stringField(value);
|
|
291
|
+
}
|
|
292
|
+
function asRecord2(value) {
|
|
293
|
+
return value && typeof value === "object" && !Array.isArray(value) ? value : null;
|
|
294
|
+
}
|
|
295
|
+
function customEntries(entries) {
|
|
296
|
+
const customs = [];
|
|
297
|
+
for (const entry of entries) {
|
|
298
|
+
if (entry.type === "custom")
|
|
299
|
+
customs.push(entry);
|
|
300
|
+
}
|
|
301
|
+
return customs;
|
|
302
|
+
}
|
|
303
|
+
function candidateFromStartedProjection(workflow) {
|
|
304
|
+
const started = workflow.started;
|
|
305
|
+
if (!started)
|
|
306
|
+
return null;
|
|
307
|
+
return {
|
|
308
|
+
selectedRepo: started.selectedRepo,
|
|
309
|
+
githubUserId: started.owner.githubUserId,
|
|
310
|
+
login: started.owner.login,
|
|
311
|
+
namespaceKey: started.owner.namespaceKey,
|
|
312
|
+
source: "workflow-metadata"
|
|
313
|
+
};
|
|
314
|
+
}
|
|
315
|
+
function candidateFromStartedData(data) {
|
|
316
|
+
const record = asRecord2(data);
|
|
317
|
+
if (!record)
|
|
318
|
+
return null;
|
|
319
|
+
const owner = asRecord2(record.owner);
|
|
320
|
+
const selectedRepo = stringField(record.selectedRepo);
|
|
321
|
+
const githubUserId = stringField(owner?.githubUserId) ?? numericStringField(record.githubUserId) ?? numericStringField(record.userId);
|
|
322
|
+
const login = stringField(owner?.login) ?? stringField(record.login);
|
|
323
|
+
const namespaceKey = stringField(owner?.namespaceKey) ?? stringField(record.namespaceKey) ?? stringField(record.userNamespaceKey);
|
|
324
|
+
if (!selectedRepo && !githubUserId && !login && !namespaceKey)
|
|
325
|
+
return null;
|
|
326
|
+
return { selectedRepo, githubUserId, login, namespaceKey, source: "workflow-metadata" };
|
|
327
|
+
}
|
|
328
|
+
function workflowIdentityCandidate(entries) {
|
|
329
|
+
const customs = customEntries(entries);
|
|
330
|
+
const projected = candidateFromStartedProjection(projectWorkflowEntries(customs));
|
|
331
|
+
if (projected)
|
|
332
|
+
return projected;
|
|
333
|
+
for (let index = customs.length - 1;index >= 0; index -= 1) {
|
|
334
|
+
const entry = customs[index];
|
|
335
|
+
if (entry?.customType !== RIG_WORKFLOW_STARTED)
|
|
336
|
+
continue;
|
|
337
|
+
const candidate = candidateFromStartedData(entry.data);
|
|
338
|
+
if (candidate)
|
|
339
|
+
return candidate;
|
|
340
|
+
}
|
|
341
|
+
return null;
|
|
342
|
+
}
|
|
343
|
+
function ompGitHubIdentityCandidate(ctx) {
|
|
344
|
+
const account = asRecord2(ctx.modelRegistry?.authStorage?.getOAuthAccountIdentity?.("github-copilot", ctx.sessionManager.getSessionId()));
|
|
345
|
+
if (!account)
|
|
346
|
+
return null;
|
|
347
|
+
const githubUserId = stringField(account.accountId);
|
|
348
|
+
const login = stringField(account.login) ?? stringField(account.email);
|
|
349
|
+
if (!githubUserId && !login)
|
|
350
|
+
return null;
|
|
351
|
+
return {
|
|
352
|
+
githubUserId,
|
|
353
|
+
login,
|
|
354
|
+
namespaceKey: githubUserId ? `gh:${githubUserId}` : undefined,
|
|
355
|
+
source: "omp-github-copilot-auth"
|
|
356
|
+
};
|
|
357
|
+
}
|
|
358
|
+
function envField(name) {
|
|
359
|
+
return stringField(process.env[name]);
|
|
360
|
+
}
|
|
361
|
+
function envIdentityCandidate() {
|
|
362
|
+
const selectedRepo = envField("RIG_SELECTED_REPO");
|
|
363
|
+
const githubUserId = envField("RIG_GITHUB_USER_ID");
|
|
364
|
+
const login = envField("RIG_GITHUB_LOGIN");
|
|
365
|
+
const namespaceKey = envField("RIG_GITHUB_NAMESPACE_KEY") ?? (githubUserId ? `gh:${githubUserId}` : undefined);
|
|
366
|
+
if (!selectedRepo && !githubUserId && !login && !namespaceKey)
|
|
367
|
+
return null;
|
|
368
|
+
return {
|
|
369
|
+
selectedRepo,
|
|
370
|
+
githubUserId,
|
|
371
|
+
login,
|
|
372
|
+
namespaceKey,
|
|
373
|
+
source: "rig-public-identity-env"
|
|
374
|
+
};
|
|
375
|
+
}
|
|
376
|
+
function mergeSource(sources, source) {
|
|
377
|
+
if (source && !sources.includes(source))
|
|
378
|
+
sources.push(source);
|
|
379
|
+
}
|
|
380
|
+
function completeIdentity(candidate, sources) {
|
|
381
|
+
const selectedRepo = stringField(candidate.selectedRepo);
|
|
382
|
+
const githubUserId = stringField(candidate.githubUserId);
|
|
383
|
+
const login = stringField(candidate.login);
|
|
384
|
+
const namespaceKey = stringField(candidate.namespaceKey);
|
|
385
|
+
if (!selectedRepo || !githubUserId || !login || !namespaceKey)
|
|
386
|
+
return null;
|
|
387
|
+
const uniqueSources = [];
|
|
388
|
+
for (const value of sources) {
|
|
389
|
+
if (!uniqueSources.includes(value))
|
|
390
|
+
uniqueSources.push(value);
|
|
391
|
+
}
|
|
392
|
+
return {
|
|
393
|
+
selectedRepo,
|
|
394
|
+
owner: { githubUserId, login, namespaceKey },
|
|
395
|
+
source: uniqueSources.join("+")
|
|
396
|
+
};
|
|
397
|
+
}
|
|
398
|
+
function resolveRigIdentity(ctx) {
|
|
399
|
+
const workflow = workflowIdentityCandidate(ctx.sessionManager.getBranch());
|
|
400
|
+
const omp = ompGitHubIdentityCandidate(ctx);
|
|
401
|
+
const env = envIdentityCandidate();
|
|
402
|
+
const sources = [];
|
|
403
|
+
const selectedRepo = workflow?.selectedRepo ?? env?.selectedRepo;
|
|
404
|
+
const githubUserId = workflow?.githubUserId ?? omp?.githubUserId ?? env?.githubUserId;
|
|
405
|
+
const login = workflow?.login ?? omp?.login ?? env?.login;
|
|
406
|
+
const namespaceKey = workflow?.namespaceKey ?? omp?.namespaceKey ?? env?.namespaceKey;
|
|
407
|
+
if (workflow && (workflow.selectedRepo || workflow.githubUserId || workflow.login || workflow.namespaceKey))
|
|
408
|
+
mergeSource(sources, workflow.source);
|
|
409
|
+
if (omp && (!workflow?.githubUserId || !workflow?.login || !workflow?.namespaceKey))
|
|
410
|
+
mergeSource(sources, omp.source);
|
|
411
|
+
if (env && (!workflow?.selectedRepo && env.selectedRepo || !workflow?.githubUserId && !omp?.githubUserId && env.githubUserId || !workflow?.login && !omp?.login && env.login || !workflow?.namespaceKey && !omp?.namespaceKey && env.namespaceKey))
|
|
412
|
+
mergeSource(sources, env.source);
|
|
413
|
+
return completeIdentity({ selectedRepo, githubUserId, login, namespaceKey, source: sources.join("+") }, sources);
|
|
414
|
+
}
|
|
415
|
+
function resolveRigIdentityFilter(ctx) {
|
|
416
|
+
const identity = resolveRigIdentity(ctx);
|
|
417
|
+
if (!identity)
|
|
418
|
+
return null;
|
|
419
|
+
return {
|
|
420
|
+
cwd: ctx.sessionManager.getCwd(),
|
|
421
|
+
selectedRepo: identity.selectedRepo,
|
|
422
|
+
githubUserId: identity.owner.githubUserId,
|
|
423
|
+
namespaceKey: identity.owner.namespaceKey
|
|
424
|
+
};
|
|
425
|
+
}
|
|
426
|
+
export {
|
|
427
|
+
resolveRigIdentityFilter,
|
|
428
|
+
resolveRigIdentity
|
|
429
|
+
};
|