@bridge-ds/core 0.16.0 → 0.18.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/dist/activity.d.ts +207 -0
- package/dist/audit/index.js +3 -3
- package/dist/index.d.ts +2 -0
- package/dist/index.js +780 -346
- package/dist/index.js.map +1 -1
- package/dist/node/index.js +3 -3
- package/dist/{prod-branch-CSM0c2OF.js → prod-branch-DenQkr_e.js} +128 -115
- package/dist/prod-branch-DenQkr_e.js.map +1 -0
- package/dist/{repo-source-73kARDJv.js → repo-source-CRfhLO87.js} +677 -535
- package/dist/repo-source-CRfhLO87.js.map +1 -0
- package/dist/{report-DbE6yJCw.js → report-DVEmUr0p.js} +2 -2
- package/dist/{report-DbE6yJCw.js.map → report-DVEmUr0p.js.map} +1 -1
- package/dist/review-gate.d.ts +17 -6
- package/dist/rights.d.ts +19 -0
- package/dist/suggestions-github.d.ts +52 -4
- package/dist/suggestions.d.ts +25 -1
- package/dist/titles.d.ts +9 -0
- package/package.json +1 -1
- package/dist/prod-branch-CSM0c2OF.js.map +0 -1
- package/dist/repo-source-73kARDJv.js.map +0 -1
|
@@ -0,0 +1,207 @@
|
|
|
1
|
+
import { type FetchLike } from './github-client';
|
|
2
|
+
import type { BridgeConfig } from './config';
|
|
3
|
+
import { type HistoryReport } from './history';
|
|
4
|
+
import { type RequestKind, type RequestStatus } from './requests';
|
|
5
|
+
import type { RiskTier } from './risk';
|
|
6
|
+
import type { SuggestionKind, SuggestionPayloadV1, SuggestionStatus } from './suggestions';
|
|
7
|
+
export declare const ACTIVITY_SCHEMA_VERSION = 1;
|
|
8
|
+
/** Next to snapshot.json on the bridge-data branch. */
|
|
9
|
+
export declare const ACTIVITY_FILE = "activity.json";
|
|
10
|
+
/** Above this, the recorded reads are dropped heaviest first (trees, then older branches) until it fits. */
|
|
11
|
+
export declare const ACTIVITY_MAX_BYTES = 3000000;
|
|
12
|
+
/** A guest reads activity.json while it is younger than this; older, the Studio reads GitHub live. */
|
|
13
|
+
export declare const ACTIVITY_MAX_AGE_MS: number;
|
|
14
|
+
/** How much one activity.json carries. Each is a count of items, newest first. */
|
|
15
|
+
export declare const ACTIVITY_LIMITS: {
|
|
16
|
+
/** Open pull requests recorded in full (the page of each; the list carries every open one). */
|
|
17
|
+
readonly branches: 30;
|
|
18
|
+
/** Open suggestions read with their comments (parsed payload, counted approvals). */
|
|
19
|
+
readonly suggestions: 30;
|
|
20
|
+
/** Request issues listed (open and closed); open ones are read with their comments. */
|
|
21
|
+
readonly requests: 30;
|
|
22
|
+
/** Merged pull requests summarized. */
|
|
23
|
+
readonly merged: 20;
|
|
24
|
+
/** Token history entries (core loadGitHubHistory limit). */
|
|
25
|
+
readonly history: 20;
|
|
26
|
+
/** History entries whose two commits' file lists are recorded, so their before/after opens without the API. */
|
|
27
|
+
readonly historyTrees: 10;
|
|
28
|
+
};
|
|
29
|
+
export type ActivityLimits = {
|
|
30
|
+
[K in keyof typeof ACTIVITY_LIMITS]: number;
|
|
31
|
+
};
|
|
32
|
+
/** One GitHub answer: its status (200, or 404 for a read that finds nothing) and its JSON body, trimmed. */
|
|
33
|
+
export interface ActivityResponse {
|
|
34
|
+
status: number;
|
|
35
|
+
body: unknown;
|
|
36
|
+
}
|
|
37
|
+
export interface ActivityBranch {
|
|
38
|
+
number: number;
|
|
39
|
+
title: string;
|
|
40
|
+
author: string;
|
|
41
|
+
url: string;
|
|
42
|
+
branch: string;
|
|
43
|
+
base: string;
|
|
44
|
+
headSha: string;
|
|
45
|
+
baseSha: string;
|
|
46
|
+
state: 'open' | 'draft';
|
|
47
|
+
labels: string[];
|
|
48
|
+
/** Risk tier from the labels, the body or the files (review-gate effectiveTier); null when none says. */
|
|
49
|
+
tier: RiskTier | null;
|
|
50
|
+
createdAt: string;
|
|
51
|
+
updatedAt: string;
|
|
52
|
+
/** Conversation plus line comments. Null when the branch was not read in full (over the limit). */
|
|
53
|
+
comments: number | null;
|
|
54
|
+
/** Files the branch changes, and the token files among them (the token diff opens from them). Null: not read. */
|
|
55
|
+
files: {
|
|
56
|
+
changed: number;
|
|
57
|
+
tokens: string[];
|
|
58
|
+
} | null;
|
|
59
|
+
/** Previews built for the head commit (commit statuses with a link, success only). */
|
|
60
|
+
previews: {
|
|
61
|
+
context: string;
|
|
62
|
+
url: string;
|
|
63
|
+
}[];
|
|
64
|
+
/** Combined check state of the head commit. */
|
|
65
|
+
checks: 'success' | 'failure' | 'pending' | 'none' | null;
|
|
66
|
+
}
|
|
67
|
+
export interface ActivitySuggestion {
|
|
68
|
+
number: number;
|
|
69
|
+
title: string;
|
|
70
|
+
author: string;
|
|
71
|
+
url: string;
|
|
72
|
+
createdAt: string;
|
|
73
|
+
kind: SuggestionKind | null;
|
|
74
|
+
status: SuggestionStatus;
|
|
75
|
+
labels: string[];
|
|
76
|
+
comments: number | null;
|
|
77
|
+
/** The parsed suggestion (null when its block does not parse). */
|
|
78
|
+
payload: SuggestionPayloadV1 | null;
|
|
79
|
+
approvers: string[];
|
|
80
|
+
}
|
|
81
|
+
export interface ActivityRequest {
|
|
82
|
+
number: number;
|
|
83
|
+
title: string;
|
|
84
|
+
author: string;
|
|
85
|
+
url: string;
|
|
86
|
+
state: 'open' | 'closed';
|
|
87
|
+
status: RequestStatus;
|
|
88
|
+
kind: RequestKind | null;
|
|
89
|
+
component: string | null;
|
|
90
|
+
labels: string[];
|
|
91
|
+
createdAt: string;
|
|
92
|
+
}
|
|
93
|
+
export interface ActivityMerged {
|
|
94
|
+
number: number;
|
|
95
|
+
title: string;
|
|
96
|
+
author: string;
|
|
97
|
+
url: string;
|
|
98
|
+
mergedAt: string;
|
|
99
|
+
labels: string[];
|
|
100
|
+
tier: RiskTier | null;
|
|
101
|
+
}
|
|
102
|
+
export interface RepoActivity {
|
|
103
|
+
kind: 'bridge-activity';
|
|
104
|
+
schemaVersion: typeof ACTIVITY_SCHEMA_VERSION;
|
|
105
|
+
tool: {
|
|
106
|
+
name: 'bridge';
|
|
107
|
+
version: string;
|
|
108
|
+
};
|
|
109
|
+
generatedAt: string;
|
|
110
|
+
repo: {
|
|
111
|
+
owner: string;
|
|
112
|
+
name: string;
|
|
113
|
+
branch: string;
|
|
114
|
+
};
|
|
115
|
+
/** Default branch head when it was written. */
|
|
116
|
+
headSha: string;
|
|
117
|
+
branches: ActivityBranch[];
|
|
118
|
+
suggestions: ActivitySuggestion[];
|
|
119
|
+
requests: ActivityRequest[];
|
|
120
|
+
merged: ActivityMerged[];
|
|
121
|
+
/** Token history of the default branch (core HistoryReport), null when it could not be read. */
|
|
122
|
+
history: HistoryReport | null;
|
|
123
|
+
/** GitHub REST answers by activityKey (path relative to api.github.com, query sorted). */
|
|
124
|
+
responses: Record<string, ActivityResponse>;
|
|
125
|
+
/** What was left out to stay within the limits, in words. */
|
|
126
|
+
truncated: string[];
|
|
127
|
+
/** What could not be read. */
|
|
128
|
+
problems: string[];
|
|
129
|
+
}
|
|
130
|
+
export declare class ActivityError extends Error {
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* The key of a GitHub REST read: the path relative to api.github.com with the query parameters sorted, and the
|
|
134
|
+
* owner and repository (or user) lowercased, since GitHub reads them without case. Null for any other host.
|
|
135
|
+
*/
|
|
136
|
+
export declare function activityKey(url: string): string | null;
|
|
137
|
+
/**
|
|
138
|
+
* A GitHub answer without what no page reads: API links, node ids, diffs, reactions, the repository objects nested in
|
|
139
|
+
* a pull request's head and base (name, owner and fork kept), and user objects beyond login, avatar and type. A tree
|
|
140
|
+
* keeps path, type and sha per entry. Strings longer than 60 000 characters are cut.
|
|
141
|
+
*/
|
|
142
|
+
export declare function trimGitHub(value: unknown, key?: string): unknown;
|
|
143
|
+
/** What a recordingFetch shaper returns for a read it should not keep. */
|
|
144
|
+
export declare const SKIP: unique symbol;
|
|
145
|
+
/**
|
|
146
|
+
* The paths of a tree the Studio reads from a recorded tree: token files and the contrast checks (the branch token
|
|
147
|
+
* diff), bridge.config.json, changesets, and the CHANGELOG.md and package.json the history reads. Every other entry is
|
|
148
|
+
* left out of activity.json, which keeps a tree at a few kilobytes instead of a whole repository listing.
|
|
149
|
+
*/
|
|
150
|
+
export declare function activityTreeFilter(config: BridgeConfig): (path: string) => boolean;
|
|
151
|
+
/** The shaper collectActivity records with: trees filtered (activityTreeFilter), compares to what a branch page reads. */
|
|
152
|
+
export declare function activityShaper(config: BridgeConfig): (key: string, body: unknown) => unknown | typeof SKIP;
|
|
153
|
+
/** Changes listed per history entry; an import of hundreds of tokens keeps its counts and its first changes. */
|
|
154
|
+
export declare const HISTORY_MAX_CHANGES = 100;
|
|
155
|
+
/** A history report with each entry's change and reason lists capped (counts stay whole). */
|
|
156
|
+
export declare function capHistory(report: HistoryReport, max?: number): HistoryReport;
|
|
157
|
+
/**
|
|
158
|
+
* Wraps a fetch and records every GitHub REST GET that answers 200 or 404 with JSON, trimmed, under its activityKey.
|
|
159
|
+
* Reads with another media type (raw file bodies) pass through unrecorded.
|
|
160
|
+
*/
|
|
161
|
+
export declare function recordingFetch(fetchImpl: FetchLike, into: Map<string, ActivityResponse>, shape?: (key: string, body: unknown) => unknown | typeof SKIP): FetchLike;
|
|
162
|
+
export interface CollectActivityInput {
|
|
163
|
+
/** fetch for api.github.com (the token goes in `token`). */
|
|
164
|
+
fetch: FetchLike;
|
|
165
|
+
token: string;
|
|
166
|
+
owner: string;
|
|
167
|
+
repo: string;
|
|
168
|
+
/** The repository's Bridge config (tokens root, governance, changesets): history and suggestion approvals read it. */
|
|
169
|
+
config: BridgeConfig;
|
|
170
|
+
version: string;
|
|
171
|
+
generatedAt?: string;
|
|
172
|
+
/**
|
|
173
|
+
* The activity published last time. Its history (and the file lists recorded for it) is kept when the default
|
|
174
|
+
* branch head has not moved, which saves most of the reads of a run on a schedule or a pull request event.
|
|
175
|
+
*/
|
|
176
|
+
previous?: RepoActivity | null;
|
|
177
|
+
limits?: Partial<ActivityLimits>;
|
|
178
|
+
}
|
|
179
|
+
/**
|
|
180
|
+
* Reads the team's activity from GitHub: the same reads, with the same paths, as the hosted Studio's guest pages
|
|
181
|
+
* (Home, Branches and each open branch, Review, History, suggestions, requests), recorded, plus the summaries. A read
|
|
182
|
+
* that fails is noted in `problems` and the rest goes on; an exhausted hourly limit stops the reading there.
|
|
183
|
+
*/
|
|
184
|
+
export declare function collectActivity(input: CollectActivityInput): Promise<RepoActivity>;
|
|
185
|
+
/** Bytes of the activity as written. */
|
|
186
|
+
export declare const activityBytes: (a: RepoActivity) => number;
|
|
187
|
+
/**
|
|
188
|
+
* Keeps the activity under `max` bytes: drops the recorded file lists (trees) first, then the pages of the least
|
|
189
|
+
* recently updated branches, then every recorded read. The summaries always stay. Says what it dropped in `truncated`.
|
|
190
|
+
*/
|
|
191
|
+
export declare function fitActivity(activity: RepoActivity, max?: number): RepoActivity;
|
|
192
|
+
/** Validates an activity (text or parsed JSON). Throws ActivityError naming the first problem. */
|
|
193
|
+
export declare function parseActivity(input: string | unknown): RepoActivity;
|
|
194
|
+
/** Milliseconds since the activity was written (never negative). */
|
|
195
|
+
export declare const activityAge: (a: Pick<RepoActivity, "generatedAt">, now?: number) => number;
|
|
196
|
+
/** True while a guest should read the activity instead of GitHub: written for this repository, and recently. */
|
|
197
|
+
export declare function activityIsUsable(a: Pick<RepoActivity, 'generatedAt' | 'repo'>, team: {
|
|
198
|
+
owner: string;
|
|
199
|
+
repo: string;
|
|
200
|
+
}, now?: number, maxAge?: number): boolean;
|
|
201
|
+
/**
|
|
202
|
+
* The recorded answer to a GitHub REST GET, or undefined when the activity did not record it (read it live). Only
|
|
203
|
+
* reads of the activity's own repository (and the user accounts it recorded) are answered.
|
|
204
|
+
*/
|
|
205
|
+
export declare function activityAnswer(a: Pick<RepoActivity, 'responses' | 'repo'>, url: string): ActivityResponse | undefined;
|
|
206
|
+
/** "activity.json" on the bridge-data branch of a public repository, on the raw host (no API quota). */
|
|
207
|
+
export declare const activityRawUrl: (owner: string, repo: string) => string;
|
package/dist/audit/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { i as isAuditable, a as auditFile } from "../report-
|
|
2
|
-
import { A, b, c, C, D, d, F, I, L, e, M, N, f, g, h, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z, B, E, G, H, J, K, O, P, Q, R, S, T, U, V, W, X, Y, Z } from "../report-
|
|
3
|
-
import { p as pieceId, a as proposedTokenPath, t as tokenLabel } from "../prod-branch-
|
|
1
|
+
import { i as isAuditable, a as auditFile } from "../report-DVEmUr0p.js";
|
|
2
|
+
import { A, b, c, C, D, d, F, I, L, e, M, N, f, g, h, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z, B, E, G, H, J, K, O, P, Q, R, S, T, U, V, W, X, Y, Z } from "../report-DVEmUr0p.js";
|
|
3
|
+
import { p as pieceId, a as proposedTokenPath, t as tokenLabel } from "../prod-branch-DenQkr_e.js";
|
|
4
4
|
const lines = (text) => text.split(/\r?\n/);
|
|
5
5
|
function lineBag(text) {
|
|
6
6
|
const bag = /* @__PURE__ */ new Map();
|
package/dist/index.d.ts
CHANGED
|
@@ -60,6 +60,7 @@ export * from './token-proposal';
|
|
|
60
60
|
export * from './figma-push';
|
|
61
61
|
export * from './figma-push-github';
|
|
62
62
|
export * from './suggestions';
|
|
63
|
+
export * from './titles';
|
|
63
64
|
export * from './suggestion-review';
|
|
64
65
|
export * from './suggestions-github';
|
|
65
66
|
export * from './suggestion-apply';
|
|
@@ -72,3 +73,4 @@ export * from './repo-model';
|
|
|
72
73
|
export * from './repo-source-github';
|
|
73
74
|
export * from './repo-access';
|
|
74
75
|
export * from './snapshot';
|
|
76
|
+
export * from './activity';
|