github-issue-tower-defence-management 1.88.0 → 1.89.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +14 -0
- package/README.md +20 -1
- package/bin/adapter/entry-points/cli/index.js +56 -0
- package/bin/adapter/entry-points/cli/index.js.map +1 -1
- package/bin/adapter/entry-points/console/consoleDataDelivery.js +155 -0
- package/bin/adapter/entry-points/console/consoleDataDelivery.js.map +1 -0
- package/bin/adapter/entry-points/console/consoleDoneStore.js +100 -0
- package/bin/adapter/entry-points/console/consoleDoneStore.js.map +1 -0
- package/bin/adapter/entry-points/console/consoleOperationApi.js +178 -0
- package/bin/adapter/entry-points/console/consoleOperationApi.js.map +1 -0
- package/bin/adapter/entry-points/console/consoleReadApi.js +119 -0
- package/bin/adapter/entry-points/console/consoleReadApi.js.map +1 -0
- package/bin/adapter/entry-points/console/consoleServer.js +147 -3
- package/bin/adapter/entry-points/console/consoleServer.js.map +1 -1
- package/bin/adapter/entry-points/handlers/OauthTokenSelectHandler.js +97 -0
- package/bin/adapter/entry-points/handlers/OauthTokenSelectHandler.js.map +1 -0
- package/bin/adapter/proxy/RateLimitCache.js +3 -3
- package/bin/adapter/proxy/RateLimitCache.js.map +1 -1
- package/bin/domain/usecases/NotifyFinishedIssuePreparationUseCase.js +3 -0
- package/bin/domain/usecases/NotifyFinishedIssuePreparationUseCase.js.map +1 -1
- package/bin/domain/usecases/OauthTokenSelectUseCase.js +87 -0
- package/bin/domain/usecases/OauthTokenSelectUseCase.js.map +1 -0
- package/package.json +1 -1
- package/src/adapter/entry-points/cli/index.test.ts +94 -0
- package/src/adapter/entry-points/cli/index.ts +99 -0
- package/src/adapter/entry-points/console/consoleDataDelivery.test.ts +184 -0
- package/src/adapter/entry-points/console/consoleDataDelivery.ts +169 -0
- package/src/adapter/entry-points/console/consoleDoneStore.test.ts +98 -0
- package/src/adapter/entry-points/console/consoleDoneStore.ts +91 -0
- package/src/adapter/entry-points/console/consoleOperationApi.test.ts +444 -0
- package/src/adapter/entry-points/console/consoleOperationApi.ts +280 -0
- package/src/adapter/entry-points/console/consoleReadApi.test.ts +297 -0
- package/src/adapter/entry-points/console/consoleReadApi.ts +192 -0
- package/src/adapter/entry-points/console/consoleServer.test.ts +269 -0
- package/src/adapter/entry-points/console/consoleServer.ts +228 -4
- package/src/adapter/entry-points/handlers/OauthTokenSelectHandler.test.ts +204 -0
- package/src/adapter/entry-points/handlers/OauthTokenSelectHandler.ts +132 -0
- package/src/adapter/proxy/RateLimitCache.ts +9 -4
- package/src/domain/usecases/NotifyFinishedIssuePreparationUseCase.test.ts +34 -0
- package/src/domain/usecases/NotifyFinishedIssuePreparationUseCase.ts +3 -0
- package/src/domain/usecases/OauthTokenSelectUseCase.test.ts +179 -0
- package/src/domain/usecases/OauthTokenSelectUseCase.ts +158 -0
- package/types/adapter/entry-points/cli/index.d.ts.map +1 -1
- package/types/adapter/entry-points/console/consoleDataDelivery.d.ts +23 -0
- package/types/adapter/entry-points/console/consoleDataDelivery.d.ts.map +1 -0
- package/types/adapter/entry-points/console/consoleDoneStore.d.ts +10 -0
- package/types/adapter/entry-points/console/consoleDoneStore.d.ts.map +1 -0
- package/types/adapter/entry-points/console/consoleOperationApi.d.ts +18 -0
- package/types/adapter/entry-points/console/consoleOperationApi.d.ts.map +1 -0
- package/types/adapter/entry-points/console/consoleReadApi.d.ts +44 -0
- package/types/adapter/entry-points/console/consoleReadApi.d.ts.map +1 -0
- package/types/adapter/entry-points/console/consoleServer.d.ts +8 -1
- package/types/adapter/entry-points/console/consoleServer.d.ts.map +1 -1
- package/types/adapter/entry-points/handlers/OauthTokenSelectHandler.d.ts +20 -0
- package/types/adapter/entry-points/handlers/OauthTokenSelectHandler.d.ts.map +1 -0
- package/types/adapter/proxy/RateLimitCache.d.ts +2 -2
- package/types/adapter/proxy/RateLimitCache.d.ts.map +1 -1
- package/types/domain/usecases/NotifyFinishedIssuePreparationUseCase.d.ts.map +1 -1
- package/types/domain/usecases/OauthTokenSelectUseCase.d.ts +35 -0
- package/types/domain/usecases/OauthTokenSelectUseCase.d.ts.map +1 -0
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
import {
|
|
2
|
+
OauthTokenCandidate,
|
|
3
|
+
OauthTokenSelectUseCase,
|
|
4
|
+
OauthTokenWindowSnapshot,
|
|
5
|
+
} from './OauthTokenSelectUseCase';
|
|
6
|
+
|
|
7
|
+
const NOW = 1_000_000;
|
|
8
|
+
const HOUR = 3600;
|
|
9
|
+
const DAY = 86400;
|
|
10
|
+
|
|
11
|
+
const snapshot = (
|
|
12
|
+
overrides: Partial<OauthTokenWindowSnapshot>,
|
|
13
|
+
): OauthTokenWindowSnapshot => ({
|
|
14
|
+
fiveHourUtilization: 0,
|
|
15
|
+
fiveHourReset: NOW + HOUR,
|
|
16
|
+
sevenDayUtilization: 0,
|
|
17
|
+
sevenDayReset: NOW + DAY,
|
|
18
|
+
...overrides,
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
const candidate = (
|
|
22
|
+
name: string,
|
|
23
|
+
snapshotValue: OauthTokenWindowSnapshot | null,
|
|
24
|
+
): OauthTokenCandidate => ({
|
|
25
|
+
name,
|
|
26
|
+
token: `fake-token-${name}`,
|
|
27
|
+
snapshot: snapshotValue,
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
describe('OauthTokenSelectUseCase', () => {
|
|
31
|
+
const useCase = new OauthTokenSelectUseCase();
|
|
32
|
+
|
|
33
|
+
it('selects the eligible token whose 7d window resets soonest', () => {
|
|
34
|
+
const result = useCase.run(
|
|
35
|
+
[
|
|
36
|
+
candidate(
|
|
37
|
+
'far',
|
|
38
|
+
snapshot({ sevenDayUtilization: 0.1, sevenDayReset: NOW + 6 * DAY }),
|
|
39
|
+
),
|
|
40
|
+
candidate(
|
|
41
|
+
'soon',
|
|
42
|
+
snapshot({ sevenDayUtilization: 0.1, sevenDayReset: NOW + 2 * DAY }),
|
|
43
|
+
),
|
|
44
|
+
candidate(
|
|
45
|
+
'middle',
|
|
46
|
+
snapshot({ sevenDayUtilization: 0.1, sevenDayReset: NOW + 4 * DAY }),
|
|
47
|
+
),
|
|
48
|
+
],
|
|
49
|
+
NOW,
|
|
50
|
+
);
|
|
51
|
+
|
|
52
|
+
expect(result.selected?.name).toBe('soon');
|
|
53
|
+
expect(result.selected?.token).toBe('fake-token-soon');
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
it('excludes a token whose 5h window is less than 60% free', () => {
|
|
57
|
+
const result = useCase.run(
|
|
58
|
+
[
|
|
59
|
+
candidate('busy5h', snapshot({ fiveHourUtilization: 0.41 })),
|
|
60
|
+
candidate('ok', snapshot({ fiveHourUtilization: 0.4 })),
|
|
61
|
+
],
|
|
62
|
+
NOW,
|
|
63
|
+
);
|
|
64
|
+
|
|
65
|
+
expect(result.selected?.name).toBe('ok');
|
|
66
|
+
const busy = result.metrics.find((m) => m.name === 'busy5h');
|
|
67
|
+
expect(busy?.eligible).toBe(false);
|
|
68
|
+
expect(busy?.exclusionReason).toContain('5h window');
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
it('treats exactly 40% used 5h utilization as eligible (boundary)', () => {
|
|
72
|
+
const result = useCase.run(
|
|
73
|
+
[candidate('boundary', snapshot({ fiveHourUtilization: 0.4 }))],
|
|
74
|
+
NOW,
|
|
75
|
+
);
|
|
76
|
+
|
|
77
|
+
expect(result.selected?.name).toBe('boundary');
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
it('excludes a token whose 7d window is less than 30% free', () => {
|
|
81
|
+
const result = useCase.run(
|
|
82
|
+
[
|
|
83
|
+
candidate('busy7d', snapshot({ sevenDayUtilization: 0.71 })),
|
|
84
|
+
candidate('ok', snapshot({ sevenDayUtilization: 0.7 })),
|
|
85
|
+
],
|
|
86
|
+
NOW,
|
|
87
|
+
);
|
|
88
|
+
|
|
89
|
+
expect(result.selected?.name).toBe('ok');
|
|
90
|
+
const busy = result.metrics.find((m) => m.name === 'busy7d');
|
|
91
|
+
expect(busy?.eligible).toBe(false);
|
|
92
|
+
expect(busy?.exclusionReason).toContain('7d window');
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
it('treats a token with no snapshot as fully free', () => {
|
|
96
|
+
const result = useCase.run([candidate('fresh', null)], NOW);
|
|
97
|
+
|
|
98
|
+
expect(result.selected?.name).toBe('fresh');
|
|
99
|
+
const fresh = result.metrics.find((m) => m.name === 'fresh');
|
|
100
|
+
expect(fresh?.fiveHourFreeRatio).toBe(1);
|
|
101
|
+
expect(fresh?.sevenDayFreeRatio).toBe(1);
|
|
102
|
+
});
|
|
103
|
+
|
|
104
|
+
it('treats an expired window as fully free', () => {
|
|
105
|
+
const result = useCase.run(
|
|
106
|
+
[
|
|
107
|
+
candidate(
|
|
108
|
+
'expired',
|
|
109
|
+
snapshot({
|
|
110
|
+
fiveHourUtilization: 0.99,
|
|
111
|
+
fiveHourReset: NOW - HOUR,
|
|
112
|
+
sevenDayUtilization: 0.99,
|
|
113
|
+
sevenDayReset: NOW - DAY,
|
|
114
|
+
}),
|
|
115
|
+
),
|
|
116
|
+
],
|
|
117
|
+
NOW,
|
|
118
|
+
);
|
|
119
|
+
|
|
120
|
+
expect(result.selected?.name).toBe('expired');
|
|
121
|
+
const expired = result.metrics.find((m) => m.name === 'expired');
|
|
122
|
+
expect(expired?.fiveHourFreeRatio).toBe(1);
|
|
123
|
+
expect(expired?.sevenDayFreeRatio).toBe(1);
|
|
124
|
+
});
|
|
125
|
+
|
|
126
|
+
it('treats a token with no active 7d window as having the farthest 7d end', () => {
|
|
127
|
+
const result = useCase.run(
|
|
128
|
+
[
|
|
129
|
+
candidate(
|
|
130
|
+
'noSevenDay',
|
|
131
|
+
snapshot({ sevenDayReset: 0, sevenDayUtilization: 0 }),
|
|
132
|
+
),
|
|
133
|
+
candidate(
|
|
134
|
+
'activeSoon',
|
|
135
|
+
snapshot({
|
|
136
|
+
sevenDayUtilization: 0.1,
|
|
137
|
+
sevenDayReset: NOW + 3 * DAY,
|
|
138
|
+
}),
|
|
139
|
+
),
|
|
140
|
+
],
|
|
141
|
+
NOW,
|
|
142
|
+
);
|
|
143
|
+
|
|
144
|
+
expect(result.selected?.name).toBe('activeSoon');
|
|
145
|
+
const noSevenDay = result.metrics.find((m) => m.name === 'noSevenDay');
|
|
146
|
+
expect(noSevenDay?.sevenDayEndEpoch).toBe(NOW + 7 * DAY);
|
|
147
|
+
});
|
|
148
|
+
|
|
149
|
+
it('returns null selection when no token passes the filter', () => {
|
|
150
|
+
const result = useCase.run(
|
|
151
|
+
[
|
|
152
|
+
candidate('busy', snapshot({ fiveHourUtilization: 0.9 })),
|
|
153
|
+
candidate('alsoBusy', snapshot({ sevenDayUtilization: 0.9 })),
|
|
154
|
+
],
|
|
155
|
+
NOW,
|
|
156
|
+
);
|
|
157
|
+
|
|
158
|
+
expect(result.selected).toBeNull();
|
|
159
|
+
});
|
|
160
|
+
|
|
161
|
+
it('returns null selection for an empty candidate list', () => {
|
|
162
|
+
const result = useCase.run([], NOW);
|
|
163
|
+
|
|
164
|
+
expect(result.selected).toBeNull();
|
|
165
|
+
expect(result.metrics).toEqual([]);
|
|
166
|
+
});
|
|
167
|
+
|
|
168
|
+
it('reports per-candidate metrics for every input token', () => {
|
|
169
|
+
const result = useCase.run(
|
|
170
|
+
[
|
|
171
|
+
candidate('a', snapshot({ fiveHourUtilization: 0.2 })),
|
|
172
|
+
candidate('b', snapshot({ fiveHourUtilization: 0.95 })),
|
|
173
|
+
],
|
|
174
|
+
NOW,
|
|
175
|
+
);
|
|
176
|
+
|
|
177
|
+
expect(result.metrics.map((m) => m.name)).toEqual(['a', 'b']);
|
|
178
|
+
});
|
|
179
|
+
});
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
export type OauthTokenWindowSnapshot = {
|
|
2
|
+
fiveHourUtilization: number;
|
|
3
|
+
fiveHourReset: number;
|
|
4
|
+
sevenDayUtilization: number;
|
|
5
|
+
sevenDayReset: number;
|
|
6
|
+
};
|
|
7
|
+
|
|
8
|
+
export type OauthTokenCandidate = {
|
|
9
|
+
name: string;
|
|
10
|
+
token: string;
|
|
11
|
+
snapshot: OauthTokenWindowSnapshot | null;
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
export type OauthTokenCandidateMetrics = {
|
|
15
|
+
name: string;
|
|
16
|
+
fiveHourFreeRatio: number;
|
|
17
|
+
sevenDayFreeRatio: number;
|
|
18
|
+
sevenDayEndEpoch: number;
|
|
19
|
+
eligible: boolean;
|
|
20
|
+
exclusionReason: string | null;
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
export type OauthTokenSelectResult = {
|
|
24
|
+
selected: OauthTokenCandidate | null;
|
|
25
|
+
metrics: OauthTokenCandidateMetrics[];
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
const SECONDS_PER_DAY = 86400;
|
|
29
|
+
const SEVEN_DAYS_IN_SECONDS = 7 * SECONDS_PER_DAY;
|
|
30
|
+
|
|
31
|
+
const FIVE_HOUR_MIN_FREE_RATIO = 0.6;
|
|
32
|
+
const SEVEN_DAY_MIN_FREE_RATIO = 0.3;
|
|
33
|
+
|
|
34
|
+
export class OauthTokenSelectUseCase {
|
|
35
|
+
run = (
|
|
36
|
+
candidates: OauthTokenCandidate[],
|
|
37
|
+
nowEpochSeconds: number,
|
|
38
|
+
): OauthTokenSelectResult => {
|
|
39
|
+
const evaluated = candidates.map((candidate) => ({
|
|
40
|
+
candidate,
|
|
41
|
+
metric: this.evaluate(candidate, nowEpochSeconds),
|
|
42
|
+
}));
|
|
43
|
+
|
|
44
|
+
const metrics = evaluated.map((entry) => entry.metric);
|
|
45
|
+
const eligible = evaluated.filter((entry) => entry.metric.eligible);
|
|
46
|
+
|
|
47
|
+
if (eligible.length === 0) {
|
|
48
|
+
return { selected: null, metrics };
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
const best = eligible.reduce((bestEntry, currentEntry) =>
|
|
52
|
+
currentEntry.metric.sevenDayEndEpoch < bestEntry.metric.sevenDayEndEpoch
|
|
53
|
+
? currentEntry
|
|
54
|
+
: bestEntry,
|
|
55
|
+
);
|
|
56
|
+
|
|
57
|
+
return { selected: best.candidate, metrics };
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
private evaluate = (
|
|
61
|
+
candidate: OauthTokenCandidate,
|
|
62
|
+
nowEpochSeconds: number,
|
|
63
|
+
): OauthTokenCandidateMetrics => {
|
|
64
|
+
const fiveHourFreeRatio = this.fiveHourFreeRatio(
|
|
65
|
+
candidate.snapshot,
|
|
66
|
+
nowEpochSeconds,
|
|
67
|
+
);
|
|
68
|
+
const sevenDayFreeRatio = this.sevenDayFreeRatio(
|
|
69
|
+
candidate.snapshot,
|
|
70
|
+
nowEpochSeconds,
|
|
71
|
+
);
|
|
72
|
+
const sevenDayEndEpoch = this.sevenDayEndEpoch(
|
|
73
|
+
candidate.snapshot,
|
|
74
|
+
nowEpochSeconds,
|
|
75
|
+
);
|
|
76
|
+
|
|
77
|
+
const exclusionReason = this.exclusionReason(
|
|
78
|
+
fiveHourFreeRatio,
|
|
79
|
+
sevenDayFreeRatio,
|
|
80
|
+
);
|
|
81
|
+
|
|
82
|
+
return {
|
|
83
|
+
name: candidate.name,
|
|
84
|
+
fiveHourFreeRatio,
|
|
85
|
+
sevenDayFreeRatio,
|
|
86
|
+
sevenDayEndEpoch,
|
|
87
|
+
eligible: exclusionReason === null,
|
|
88
|
+
exclusionReason,
|
|
89
|
+
};
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
private exclusionReason = (
|
|
93
|
+
fiveHourFreeRatio: number,
|
|
94
|
+
sevenDayFreeRatio: number,
|
|
95
|
+
): string | null => {
|
|
96
|
+
if (fiveHourFreeRatio < FIVE_HOUR_MIN_FREE_RATIO) {
|
|
97
|
+
return `5h window only ${this.toPercent(fiveHourFreeRatio)}% free (requires >= ${this.toPercent(FIVE_HOUR_MIN_FREE_RATIO)}%)`;
|
|
98
|
+
}
|
|
99
|
+
if (sevenDayFreeRatio < SEVEN_DAY_MIN_FREE_RATIO) {
|
|
100
|
+
return `7d window only ${this.toPercent(sevenDayFreeRatio)}% free (requires >= ${this.toPercent(SEVEN_DAY_MIN_FREE_RATIO)}%)`;
|
|
101
|
+
}
|
|
102
|
+
return null;
|
|
103
|
+
};
|
|
104
|
+
|
|
105
|
+
private fiveHourFreeRatio = (
|
|
106
|
+
snapshot: OauthTokenWindowSnapshot | null,
|
|
107
|
+
nowEpochSeconds: number,
|
|
108
|
+
): number => {
|
|
109
|
+
if (snapshot === null) {
|
|
110
|
+
return 1;
|
|
111
|
+
}
|
|
112
|
+
if (this.windowExpired(snapshot.fiveHourReset, nowEpochSeconds)) {
|
|
113
|
+
return 1;
|
|
114
|
+
}
|
|
115
|
+
return this.freeRatioFromUtilization(snapshot.fiveHourUtilization);
|
|
116
|
+
};
|
|
117
|
+
|
|
118
|
+
private sevenDayFreeRatio = (
|
|
119
|
+
snapshot: OauthTokenWindowSnapshot | null,
|
|
120
|
+
nowEpochSeconds: number,
|
|
121
|
+
): number => {
|
|
122
|
+
if (snapshot === null) {
|
|
123
|
+
return 1;
|
|
124
|
+
}
|
|
125
|
+
if (this.windowExpired(snapshot.sevenDayReset, nowEpochSeconds)) {
|
|
126
|
+
return 1;
|
|
127
|
+
}
|
|
128
|
+
return this.freeRatioFromUtilization(snapshot.sevenDayUtilization);
|
|
129
|
+
};
|
|
130
|
+
|
|
131
|
+
private sevenDayEndEpoch = (
|
|
132
|
+
snapshot: OauthTokenWindowSnapshot | null,
|
|
133
|
+
nowEpochSeconds: number,
|
|
134
|
+
): number => {
|
|
135
|
+
if (snapshot === null) {
|
|
136
|
+
return nowEpochSeconds + SEVEN_DAYS_IN_SECONDS;
|
|
137
|
+
}
|
|
138
|
+
if (snapshot.sevenDayReset <= 0) {
|
|
139
|
+
return nowEpochSeconds + SEVEN_DAYS_IN_SECONDS;
|
|
140
|
+
}
|
|
141
|
+
if (this.windowExpired(snapshot.sevenDayReset, nowEpochSeconds)) {
|
|
142
|
+
return nowEpochSeconds + SEVEN_DAYS_IN_SECONDS;
|
|
143
|
+
}
|
|
144
|
+
return snapshot.sevenDayReset;
|
|
145
|
+
};
|
|
146
|
+
|
|
147
|
+
private windowExpired = (
|
|
148
|
+
resetEpoch: number,
|
|
149
|
+
nowEpochSeconds: number,
|
|
150
|
+
): boolean => resetEpoch > 0 && nowEpochSeconds > resetEpoch;
|
|
151
|
+
|
|
152
|
+
private freeRatioFromUtilization = (utilization: number): number => {
|
|
153
|
+
const bounded = Math.min(Math.max(utilization, 0), 1);
|
|
154
|
+
return 1 - bounded;
|
|
155
|
+
};
|
|
156
|
+
|
|
157
|
+
private toPercent = (ratio: number): number => Math.round(ratio * 100);
|
|
158
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/adapter/entry-points/cli/index.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EACL,UAAU,EACV,cAAc,EACd,wBAAwB,EACxB,YAAY,EACZ,kBAAkB,GACnB,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/adapter/entry-points/cli/index.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EACL,UAAU,EACV,cAAc,EACd,wBAAwB,EACxB,YAAY,EACZ,kBAAkB,GACnB,MAAM,iBAAiB,CAAC;AAuFzB,eAAO,MAAM,OAAO,SAAgB,CAAC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export declare const CONSOLE_LIST_TAB_NAMES: string[];
|
|
2
|
+
export type ConsoleDataRoute = {
|
|
3
|
+
kind: 'list';
|
|
4
|
+
pjcode: string;
|
|
5
|
+
tab: string;
|
|
6
|
+
} | {
|
|
7
|
+
kind: 'detail';
|
|
8
|
+
pjcode: string;
|
|
9
|
+
tab: string;
|
|
10
|
+
key: string;
|
|
11
|
+
} | {
|
|
12
|
+
kind: 'in-tmux';
|
|
13
|
+
pjcode: string;
|
|
14
|
+
relativePath: string;
|
|
15
|
+
};
|
|
16
|
+
export declare const parseConsoleDataRoute: (requestPath: string) => ConsoleDataRoute | null;
|
|
17
|
+
export type ConsoleDataResponse = {
|
|
18
|
+
statusCode: number;
|
|
19
|
+
contentType: string;
|
|
20
|
+
body: string;
|
|
21
|
+
};
|
|
22
|
+
export declare const buildConsoleDataResponse: (consoleDataOutputDir: string, route: ConsoleDataRoute) => ConsoleDataResponse;
|
|
23
|
+
//# sourceMappingURL=consoleDataDelivery.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"consoleDataDelivery.d.ts","sourceRoot":"","sources":["../../../../src/adapter/entry-points/console/consoleDataDelivery.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,sBAAsB,EAAE,MAAM,EAM1C,CAAC;AAEF,MAAM,MAAM,gBAAgB,GACxB;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAA;CAAE,GAC7C;IAAE,IAAI,EAAE,QAAQ,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAA;CAAE,GAC5D;IAAE,IAAI,EAAE,SAAS,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,YAAY,EAAE,MAAM,CAAA;CAAE,CAAC;AAO9D,eAAO,MAAM,qBAAqB,GAChC,aAAa,MAAM,KAClB,gBAAgB,GAAG,IAoCrB,CAAC;AA0CF,MAAM,MAAM,mBAAmB,GAAG;IAChC,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,EAAE,MAAM,CAAC;IACpB,IAAI,EAAE,MAAM,CAAC;CACd,CAAC;AAEF,eAAO,MAAM,wBAAwB,GACnC,sBAAsB,MAAM,EAC5B,OAAO,gBAAgB,KACtB,mBA6CF,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export declare const CONSOLE_DONE_FILE_NAME = ".done.json";
|
|
2
|
+
export type ConsoleDoneRecord = {
|
|
3
|
+
projectItemIds: string[];
|
|
4
|
+
};
|
|
5
|
+
export declare const doneFilePathForTab: (consoleDataOutputDir: string, pjcode: string, tab: string) => string;
|
|
6
|
+
export declare const readDoneProjectItemIds: (consoleDataOutputDir: string, pjcode: string, tab: string) => string[];
|
|
7
|
+
export declare const recordDoneProjectItemId: (consoleDataOutputDir: string, pjcode: string, tab: string, projectItemId: string) => void;
|
|
8
|
+
export declare const CONSOLE_DONE_TAB_NAMES: string[];
|
|
9
|
+
export declare const recordDoneProjectItemIdAcrossTabs: (consoleDataOutputDir: string, pjcode: string, projectItemId: string) => void;
|
|
10
|
+
//# sourceMappingURL=consoleDoneStore.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"consoleDoneStore.d.ts","sourceRoot":"","sources":["../../../../src/adapter/entry-points/console/consoleDoneStore.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,sBAAsB,eAAe,CAAC;AAEnD,MAAM,MAAM,iBAAiB,GAAG;IAC9B,cAAc,EAAE,MAAM,EAAE,CAAC;CAC1B,CAAC;AAqBF,eAAO,MAAM,kBAAkB,GAC7B,sBAAsB,MAAM,EAC5B,QAAQ,MAAM,EACd,KAAK,MAAM,KACV,MACmE,CAAC;AAEvE,eAAO,MAAM,sBAAsB,GACjC,sBAAsB,MAAM,EAC5B,QAAQ,MAAM,EACd,KAAK,MAAM,KACV,MAAM,EASR,CAAC;AAEF,eAAO,MAAM,uBAAuB,GAClC,sBAAsB,MAAM,EAC5B,QAAQ,MAAM,EACd,KAAK,MAAM,EACX,eAAe,MAAM,KACpB,IAgBF,CAAC;AAEF,eAAO,MAAM,sBAAsB,EAAE,MAAM,EAO1C,CAAC;AAEF,eAAO,MAAM,iCAAiC,GAC5C,sBAAsB,MAAM,EAC5B,QAAQ,MAAM,EACd,eAAe,MAAM,KACpB,IAIF,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { IssueRepository } from '../../../domain/usecases/adapter-interfaces/IssueRepository';
|
|
2
|
+
import { Project } from '../../../domain/entities/Project';
|
|
3
|
+
export declare const AWAITING_WORKSPACE_STATUS_NAME = "awaiting workspace";
|
|
4
|
+
export declare const IN_TMUX_BY_HUMAN_STATUS_NAME = "in tmux by human";
|
|
5
|
+
export type ConsoleOperationContext = {
|
|
6
|
+
issueRepository: IssueRepository;
|
|
7
|
+
project: Project;
|
|
8
|
+
consoleDataOutputDir: string | null;
|
|
9
|
+
pjcode: string | null;
|
|
10
|
+
};
|
|
11
|
+
export type ConsoleOperationResponse = {
|
|
12
|
+
statusCode: number;
|
|
13
|
+
body: unknown;
|
|
14
|
+
};
|
|
15
|
+
export declare const handleReview: (context: ConsoleOperationContext, body: Record<string, unknown>) => Promise<ConsoleOperationResponse>;
|
|
16
|
+
export declare const handleTriage: (context: ConsoleOperationContext, body: Record<string, unknown>) => Promise<ConsoleOperationResponse>;
|
|
17
|
+
export declare const handleIntmux: (context: ConsoleOperationContext, body: Record<string, unknown>) => Promise<ConsoleOperationResponse>;
|
|
18
|
+
//# sourceMappingURL=consoleOperationApi.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"consoleOperationApi.d.ts","sourceRoot":"","sources":["../../../../src/adapter/entry-points/console/consoleOperationApi.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,6DAA6D,CAAC;AAC9F,OAAO,EAAE,OAAO,EAAE,MAAM,kCAAkC,CAAC;AAI3D,eAAO,MAAM,8BAA8B,uBAAuB,CAAC;AACnE,eAAO,MAAM,4BAA4B,qBAAqB,CAAC;AAE/D,MAAM,MAAM,uBAAuB,GAAG;IACpC,eAAe,EAAE,eAAe,CAAC;IACjC,OAAO,EAAE,OAAO,CAAC;IACjB,oBAAoB,EAAE,MAAM,GAAG,IAAI,CAAC;IACpC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;CACvB,CAAC;AAEF,MAAM,MAAM,wBAAwB,GAAG;IACrC,UAAU,EAAE,MAAM,CAAC;IACnB,IAAI,EAAE,OAAO,CAAC;CACf,CAAC;AA0EF,eAAO,MAAM,YAAY,GACvB,SAAS,uBAAuB,EAChC,MAAM,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAC5B,OAAO,CAAC,wBAAwB,CAiElC,CAAC;AAEF,eAAO,MAAM,YAAY,GACvB,SAAS,uBAAuB,EAChC,MAAM,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAC5B,OAAO,CAAC,wBAAwB,CAkFlC,CAAC;AAEF,eAAO,MAAM,YAAY,GACvB,SAAS,uBAAuB,EAChC,MAAM,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAC5B,OAAO,CAAC,wBAAwB,CA2BlC,CAAC"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { IssueRepository } from '../../../domain/usecases/adapter-interfaces/IssueRepository';
|
|
2
|
+
export declare const ISSUE_TITLE_CACHE_TTL_MS: number;
|
|
3
|
+
export type IssueOrPullRequestState = {
|
|
4
|
+
state: string;
|
|
5
|
+
merged: boolean;
|
|
6
|
+
isPullRequest: boolean;
|
|
7
|
+
};
|
|
8
|
+
export declare class IssueTitleStateCache {
|
|
9
|
+
private readonly nowMs;
|
|
10
|
+
private readonly entries;
|
|
11
|
+
constructor(nowMs?: () => number);
|
|
12
|
+
get: (url: string) => IssueOrPullRequestState | null;
|
|
13
|
+
set: (url: string, state: IssueOrPullRequestState) => void;
|
|
14
|
+
}
|
|
15
|
+
export type ConsoleReadApiResponse = {
|
|
16
|
+
statusCode: number;
|
|
17
|
+
body: unknown;
|
|
18
|
+
};
|
|
19
|
+
export type RelatedPullRequestWithSummary = {
|
|
20
|
+
url: string;
|
|
21
|
+
branchName: string | null;
|
|
22
|
+
createdAt: string;
|
|
23
|
+
isDraft: boolean;
|
|
24
|
+
isConflicted: boolean;
|
|
25
|
+
isPassedAllCiJob: boolean;
|
|
26
|
+
isCiStateSuccess: boolean;
|
|
27
|
+
isResolvedAllReviewComments: boolean;
|
|
28
|
+
isBranchOutOfDate: boolean;
|
|
29
|
+
missingRequiredCheckNames: string[];
|
|
30
|
+
summary: {
|
|
31
|
+
title: string;
|
|
32
|
+
body: string;
|
|
33
|
+
additions: number;
|
|
34
|
+
deletions: number;
|
|
35
|
+
changedFiles: number;
|
|
36
|
+
} | null;
|
|
37
|
+
};
|
|
38
|
+
export declare const handleItemBody: (issueRepository: IssueRepository, url: string | null) => Promise<ConsoleReadApiResponse>;
|
|
39
|
+
export declare const handleComments: (issueRepository: IssueRepository, url: string | null) => Promise<ConsoleReadApiResponse>;
|
|
40
|
+
export declare const handlePrFiles: (issueRepository: IssueRepository, url: string | null) => Promise<ConsoleReadApiResponse>;
|
|
41
|
+
export declare const handlePrCommits: (issueRepository: IssueRepository, url: string | null) => Promise<ConsoleReadApiResponse>;
|
|
42
|
+
export declare const handleRelatedPrs: (issueRepository: IssueRepository, url: string | null) => Promise<ConsoleReadApiResponse>;
|
|
43
|
+
export declare const handleIssueTitle: (issueRepository: IssueRepository, cache: IssueTitleStateCache, url: string | null) => Promise<ConsoleReadApiResponse>;
|
|
44
|
+
//# sourceMappingURL=consoleReadApi.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"consoleReadApi.d.ts","sourceRoot":"","sources":["../../../../src/adapter/entry-points/console/consoleReadApi.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,eAAe,EAGhB,MAAM,6DAA6D,CAAC;AAErE,eAAO,MAAM,wBAAwB,QAAa,CAAC;AAEnD,MAAM,MAAM,uBAAuB,GAAG;IACpC,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,OAAO,CAAC;IAChB,aAAa,EAAE,OAAO,CAAC;CACxB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EAChC,KAAK,MAAM,GAAG,IAAI,KACjB,OAAO,CAAC,sBAAsB,CAShC,CAAC;AAEF,eAAO,MAAM,eAAe,GAC1B,iBAAiB,eAAe,EAChC,KAAK,MAAM,GAAG,IAAI,KACjB,OAAO,CAAC,sBAAsB,CAMhC,CAAC;AAEF,eAAO,MAAM,gBAAgB,GAC3B,iBAAiB,eAAe,EAChC,KAAK,MAAM,GAAG,IAAI,KACjB,OAAO,CAAC,sBAAsB,CA2BhC,CAAC;AAEF,eAAO,MAAM,gBAAgB,GAC3B,iBAAiB,eAAe,EAChC,OAAO,oBAAoB,EAC3B,KAAK,MAAM,GAAG,IAAI,KACjB,OAAO,CAAC,sBAAsB,CAWhC,CAAC"}
|
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
import * as http from 'http';
|
|
2
|
+
import { IssueRepository } from '../../../domain/usecases/adapter-interfaces/IssueRepository';
|
|
3
|
+
import { Project } from '../../../domain/entities/Project';
|
|
4
|
+
import { IssueTitleStateCache } from './consoleReadApi';
|
|
2
5
|
export declare const DEFAULT_CONSOLE_PORT = 9981;
|
|
3
6
|
export declare const CONSOLE_TOKEN_HEADER = "x-pv-token";
|
|
4
7
|
export declare const hasDotSegment: (requestPath: string) => boolean;
|
|
@@ -9,8 +12,12 @@ export type ConsoleServerOptions = {
|
|
|
9
12
|
accessToken: string;
|
|
10
13
|
uiDistDir: string;
|
|
11
14
|
consoleDataOutputDir: string | null;
|
|
15
|
+
pjcode?: string | null;
|
|
16
|
+
issueRepository?: IssueRepository | null;
|
|
17
|
+
project?: Project | null;
|
|
18
|
+
issueTitleStateCache?: IssueTitleStateCache | null;
|
|
12
19
|
};
|
|
13
|
-
export declare const handleConsoleRequest: (options: ConsoleServerOptions, request: http.IncomingMessage, response: http.ServerResponse) => void
|
|
20
|
+
export declare const handleConsoleRequest: (options: ConsoleServerOptions, request: http.IncomingMessage, response: http.ServerResponse) => Promise<void>;
|
|
14
21
|
export declare const createConsoleServer: (options: ConsoleServerOptions) => http.Server;
|
|
15
22
|
export type StartConsoleServerOptions = ConsoleServerOptions & {
|
|
16
23
|
port: number;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"consoleServer.d.ts","sourceRoot":"","sources":["../../../../src/adapter/entry-points/console/consoleServer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"consoleServer.d.ts","sourceRoot":"","sources":["../../../../src/adapter/entry-points/console/consoleServer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAG7B,OAAO,EAAE,eAAe,EAAE,MAAM,6DAA6D,CAAC;AAC9F,OAAO,EAAE,OAAO,EAAE,MAAM,kCAAkC,CAAC;AAK3D,OAAO,EACL,oBAAoB,EAOrB,MAAM,kBAAkB,CAAC;AAQ1B,eAAO,MAAM,oBAAoB,OAAO,CAAC;AAEzC,eAAO,MAAM,oBAAoB,eAAe,CAAC;AAmCjD,eAAO,MAAM,aAAa,GAAI,aAAa,MAAM,KAAG,OAGiB,CAAC;AAEtE,eAAO,MAAM,aAAa,GAAI,aAAa,MAAM,KAAG,OAGrB,CAAC;AAEhC,eAAO,MAAM,YAAY,GACvB,eAAe,MAAM,EACrB,eAAe,MAAM,GAAG,IAAI,KAC3B,OAAoE,CAAC;AAExE,eAAO,MAAM,oBAAoB,GAC/B,YAAY,MAAM,GAAG,MAAM,EAAE,GAAG,IAAI,EACpC,aAAa,MAAM,GAAG,MAAM,EAAE,GAAG,SAAS,KACzC,MAAM,GAAG,IAQX,CAAC;AAuCF,MAAM,MAAM,oBAAoB,GAAG;IACjC,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;IAClB,oBAAoB,EAAE,MAAM,GAAG,IAAI,CAAC;IACpC,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACvB,eAAe,CAAC,EAAE,eAAe,GAAG,IAAI,CAAC;IACzC,OAAO,CAAC,EAAE,OAAO,GAAG,IAAI,CAAC;IACzB,oBAAoB,CAAC,EAAE,oBAAoB,GAAG,IAAI,CAAC;CACpD,CAAC;AA4MF,eAAO,MAAM,oBAAoB,GAC/B,SAAS,oBAAoB,EAC7B,SAAS,IAAI,CAAC,eAAe,EAC7B,UAAU,IAAI,CAAC,cAAc,KAC5B,OAAO,CAAC,IAAI,CA8Dd,CAAC;AAcF,eAAO,MAAM,mBAAmB,GAC9B,SAAS,oBAAoB,KAC5B,IAAI,CAAC,MAMJ,CAAC;AAEL,MAAM,MAAM,yBAAyB,GAAG,oBAAoB,GAAG;IAC7D,IAAI,EAAE,MAAM,CAAC;CACd,CAAC;AAEF,eAAO,MAAM,kBAAkB,GAC7B,SAAS,yBAAyB,KACjC,OAAO,CAAC,IAAI,CAAC,MAAM,CAQlB,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { OauthTokenSelectUseCase } from '../../../domain/usecases/OauthTokenSelectUseCase';
|
|
2
|
+
export type OauthTokenSelectHandlerInput = {
|
|
3
|
+
tokenListJsonPath: string | null;
|
|
4
|
+
cacheDirectory: string | null;
|
|
5
|
+
nowEpochSeconds: number;
|
|
6
|
+
};
|
|
7
|
+
export type OauthTokenSelectHandlerOutput = {
|
|
8
|
+
selectedToken: string | null;
|
|
9
|
+
selectedName: string | null;
|
|
10
|
+
diagnostics: string[];
|
|
11
|
+
};
|
|
12
|
+
export declare const resolveTokenListJsonPath: (explicitPath: string | null) => string | null;
|
|
13
|
+
export declare const resolveCacheDirectory: (explicitDirectory: string | null) => string;
|
|
14
|
+
export declare class OauthTokenSelectHandler {
|
|
15
|
+
private readonly useCase;
|
|
16
|
+
constructor(useCase?: OauthTokenSelectUseCase);
|
|
17
|
+
handle: (input: OauthTokenSelectHandlerInput) => OauthTokenSelectHandlerOutput;
|
|
18
|
+
private formatDiagnostics;
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=OauthTokenSelectHandler.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"OauthTokenSelectHandler.d.ts","sourceRoot":"","sources":["../../../../src/adapter/entry-points/handlers/OauthTokenSelectHandler.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,uBAAuB,EACxB,MAAM,kDAAkD,CAAC;AAI1D,MAAM,MAAM,4BAA4B,GAAG;IACzC,iBAAiB,EAAE,MAAM,GAAG,IAAI,CAAC;IACjC,cAAc,EAAE,MAAM,GAAG,IAAI,CAAC;IAC9B,eAAe,EAAE,MAAM,CAAC;CACzB,CAAC;AAEF,MAAM,MAAM,6BAA6B,GAAG;IAC1C,aAAa,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,YAAY,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B,WAAW,EAAE,MAAM,EAAE,CAAC;CACvB,CAAC;AAKF,eAAO,MAAM,wBAAwB,GACnC,cAAc,MAAM,GAAG,IAAI,KAC1B,MAAM,GAAG,IASX,CAAC;AAEF,eAAO,MAAM,qBAAqB,GAChC,mBAAmB,MAAM,GAAG,IAAI,KAC/B,MASF,CAAC;AAEF,qBAAa,uBAAuB;IAEhC,OAAO,CAAC,QAAQ,CAAC,OAAO;gBAAP,OAAO,GAAE,uBAAuD;IAGnF,MAAM,GACJ,OAAO,4BAA4B,KAClC,6BAA6B,CAiD9B;IAEF,OAAO,CAAC,iBAAiB,CAuBvB;CACH"}
|
|
@@ -21,10 +21,10 @@ export declare const HEADERLESS_429_DEFAULT_COOLDOWN_SECONDS = 90;
|
|
|
21
21
|
export declare const HEADERLESS_429_MAX_COOLDOWN_SECONDS = 600;
|
|
22
22
|
export declare const cacheDir: () => string;
|
|
23
23
|
export declare const hashToken: (token: string) => string;
|
|
24
|
-
export declare const cachePathForToken: (token: string) => string;
|
|
24
|
+
export declare const cachePathForToken: (token: string, baseDir?: string) => string;
|
|
25
25
|
export declare const writeRateLimit: (token: string, headers: Record<string, string | string[] | undefined>, statusCode?: number | null) => void;
|
|
26
26
|
export declare const writeModelRateLimit: (token: string, limits: Record<string, ModelWeeklyLimit>) => void;
|
|
27
27
|
export declare const parseModelRateLimitsFromBody: (body: string) => Record<string, ModelWeeklyLimit>;
|
|
28
28
|
export declare const parseModelRateLimitsFromHeaders: (headers: Record<string, string>) => Record<string, ModelWeeklyLimit>;
|
|
29
|
-
export declare const readRateLimit: (token: string) => RateLimitSnapshot | null;
|
|
29
|
+
export declare const readRateLimit: (token: string, baseDir?: string) => RateLimitSnapshot | null;
|
|
30
30
|
//# sourceMappingURL=RateLimitCache.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RateLimitCache.d.ts","sourceRoot":"","sources":["../../../src/adapter/proxy/RateLimitCache.ts"],"names":[],"mappings":"AAKA,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,EAAE,OAAO,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,iBAAiB;IAChC,mBAAmB,EAAE,MAAM,CAAC;IAC5B,aAAa,EAAE,MAAM,CAAC;IACtB,mBAAmB,EAAE,MAAM,CAAC;IAC5B,aAAa,EAAE,MAAM,CAAC;IACtB,OAAO,EAAE,OAAO,CAAC;IACjB,QAAQ,EAAE,OAAO,CAAC;IAClB,eAAe,EAAE,OAAO,CAAC;IACzB,gBAAgB,EAAE,OAAO,CAAC;IAC1B,gBAAgB,EAAE,OAAO,CAAC;IAC1B,iBAAiB,EAAE,MAAM,CAAC,MAAM,EAAE,gBAAgB,CAAC,CAAC;IACpD,gBAAgB,EAAE,MAAM,CAAC;IACzB,iBAAiB,EAAE,MAAM,CAAC;CAC3B;AAED,eAAO,MAAM,UAAU,OAAO,CAAC;AAI/B,eAAO,MAAM,uCAAuC,KAAK,CAAC;AAE1D,eAAO,MAAM,mCAAmC,MAAM,CAAC;AAEvD,eAAO,MAAM,QAAQ,QAAO,MAG3B,CAAC;AAEF,eAAO,MAAM,SAAS,GAAI,OAAO,MAAM,KAAG,MACqB,CAAC;A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I,CAAC,iBAAiB,EAAE,UAAU,CAAC,EACtD,eAAe,EAAE,IAAI,CACpC,eAAe,EACb,KAAK,GACL,QAAQ,GACR,cAAc,GACd,oBAAoB,GACpB,mBAAmB,GACnB,oBAAoB,GACpB,gCAAgC,GAChC,oBAAoB,GACpB,iCAAiC,GACjC,qBAAqB,CACxB,EACgB,sBAAsB,EAAE,IAAI,CAC3C,sBAAsB,EACtB,sBAAsB,GAAG,eAAe,CACzC,EACgB,iBAAiB,EAAE,IAAI,CACtC,iBAAiB,EACjB,gBAAgB,CACjB;IAQH,GAAG,GAAU,QAAQ;QACnB,UAAU,EAAE,MAAM,CAAC;QACnB,QAAQ,EAAE,MAAM,CAAC;QACjB,sBAAsB,EAAE,MAAM,CAAC;QAC/B,iCAAiC,EAAE,MAAM,GAAG,IAAI,CAAC;QACjD,mBAAmB,CAAC,EAAE,MAAM,EAAE,GAAG,IAAI,CAAC;QACtC,oBAAoB,CAAC,EAAE,MAAM,EAAE,GAAG,IAAI,CAAC;QACvC,uBAAuB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,IAAI,CAAC;KACzD,KAAG,OAAO,CAAC,IAAI,CAAC,CAwMf;IAEF,OAAO,CAAC,eAAe,CAIgD;IAEvE,OAAO,CAAC,iBAAiB,CA+BvB;IAEF,OAAO,CAAC,qBAAqB,CAuB3B;IAEF,OAAO,CAAC,gCAAgC,
|
|
1
|
+
{"version":3,"file":"NotifyFinishedIssuePreparationUseCase.d.ts","sourceRoot":"","sources":["../../../src/domain/usecases/NotifyFinishedIssuePreparationUseCase.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,sCAAsC,CAAC;AACvE,OAAO,EAAE,iBAAiB,EAAE,MAAM,wCAAwC,CAAC;AAC3E,OAAO,EAAE,sBAAsB,EAAE,MAAM,6CAA6C,CAAC;AACrF,OAAO,EAAE,iBAAiB,EAAE,MAAM,wCAAwC,CAAC;AAa3E,qBAAa,kB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I,CAAC,CAwMf;IAEF,OAAO,CAAC,eAAe,CAIgD;IAEvE,OAAO,CAAC,iBAAiB,CA+BvB;IAEF,OAAO,CAAC,qBAAqB,CAuB3B;IAEF,OAAO,CAAC,gCAAgC,CAoBtC;IAEF,OAAO,CAAC,uBAAuB,CAQ7B;IAEF,OAAO,CAAC,+BAA+B,CAkCrC;CACH"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
export type OauthTokenWindowSnapshot = {
|
|
2
|
+
fiveHourUtilization: number;
|
|
3
|
+
fiveHourReset: number;
|
|
4
|
+
sevenDayUtilization: number;
|
|
5
|
+
sevenDayReset: number;
|
|
6
|
+
};
|
|
7
|
+
export type OauthTokenCandidate = {
|
|
8
|
+
name: string;
|
|
9
|
+
token: string;
|
|
10
|
+
snapshot: OauthTokenWindowSnapshot | null;
|
|
11
|
+
};
|
|
12
|
+
export type OauthTokenCandidateMetrics = {
|
|
13
|
+
name: string;
|
|
14
|
+
fiveHourFreeRatio: number;
|
|
15
|
+
sevenDayFreeRatio: number;
|
|
16
|
+
sevenDayEndEpoch: number;
|
|
17
|
+
eligible: boolean;
|
|
18
|
+
exclusionReason: string | null;
|
|
19
|
+
};
|
|
20
|
+
export type OauthTokenSelectResult = {
|
|
21
|
+
selected: OauthTokenCandidate | null;
|
|
22
|
+
metrics: OauthTokenCandidateMetrics[];
|
|
23
|
+
};
|
|
24
|
+
export declare class OauthTokenSelectUseCase {
|
|
25
|
+
run: (candidates: OauthTokenCandidate[], nowEpochSeconds: number) => OauthTokenSelectResult;
|
|
26
|
+
private evaluate;
|
|
27
|
+
private exclusionReason;
|
|
28
|
+
private fiveHourFreeRatio;
|
|
29
|
+
private sevenDayFreeRatio;
|
|
30
|
+
private sevenDayEndEpoch;
|
|
31
|
+
private windowExpired;
|
|
32
|
+
private freeRatioFromUtilization;
|
|
33
|
+
private toPercent;
|
|
34
|
+
}
|
|
35
|
+
//# sourceMappingURL=OauthTokenSelectUseCase.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"OauthTokenSelectUseCase.d.ts","sourceRoot":"","sources":["../../../src/domain/usecases/OauthTokenSelectUseCase.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,wBAAwB,GAAG;IACrC,mBAAmB,EAAE,MAAM,CAAC;IAC5B,aAAa,EAAE,MAAM,CAAC;IACtB,mBAAmB,EAAE,MAAM,CAAC;IAC5B,aAAa,EAAE,MAAM,CAAC;CACvB,CAAC;AAEF,MAAM,MAAM,mBAAmB,GAAG;IAChC,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,wBAAwB,GAAG,IAAI,CAAC;CAC3C,CAAC;AAEF,MAAM,MAAM,0BAA0B,GAAG;IACvC,IAAI,EAAE,MAAM,CAAC;IACb,iBAAiB,EAAE,MAAM,CAAC;IAC1B,iBAAiB,EAAE,MAAM,CAAC;IAC1B,gBAAgB,EAAE,MAAM,CAAC;IACzB,QAAQ,EAAE,OAAO,CAAC;IAClB,eAAe,EAAE,MAAM,GAAG,IAAI,CAAC;CAChC,CAAC;AAEF,MAAM,MAAM,sBAAsB,GAAG;IACnC,QAAQ,EAAE,mBAAmB,GAAG,IAAI,CAAC;IACrC,OAAO,EAAE,0BAA0B,EAAE,CAAC;CACvC,CAAC;AAQF,qBAAa,uBAAuB;IAClC,GAAG,GACD,YAAY,mBAAmB,EAAE,EACjC,iBAAiB,MAAM,KACtB,sBAAsB,CAoBvB;IAEF,OAAO,CAAC,QAAQ,CA8Bd;IAEF,OAAO,CAAC,eAAe,CAWrB;IAEF,OAAO,CAAC,iBAAiB,CAWvB;IAEF,OAAO,CAAC,iBAAiB,CAWvB;IAEF,OAAO,CAAC,gBAAgB,CActB;IAEF,OAAO,CAAC,aAAa,CAGwC;IAE7D,OAAO,CAAC,wBAAwB,CAG9B;IAEF,OAAO,CAAC,SAAS,CAAsD;CACxE"}
|