@bridge-ds/core 0.17.0 → 0.19.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 (64) hide show
  1. package/bridge.config.schema.json +16 -0
  2. package/dist/activity.d.ts +207 -0
  3. package/dist/audit/index.js +3 -3
  4. package/dist/audit/report.d.ts +17 -2
  5. package/dist/branch-actions.d.ts +7 -1
  6. package/dist/build-requests-github.d.ts +25 -0
  7. package/dist/build-requests.d.ts +403 -0
  8. package/dist/changelog-model.d.ts +102 -0
  9. package/dist/component-spec.d.ts +3 -1
  10. package/dist/config.d.ts +21 -0
  11. package/dist/css-color.d.ts +25 -0
  12. package/dist/docs-proposal.d.ts +1 -0
  13. package/dist/explorations.d.ts +1 -0
  14. package/dist/fidelity-references.d.ts +12 -0
  15. package/dist/figma-fix-loop.d.ts +153 -0
  16. package/dist/figma-fixes.d.ts +169 -0
  17. package/dist/figma-push-github.d.ts +7 -2
  18. package/dist/figma-push.d.ts +15 -2
  19. package/dist/gap-case.d.ts +144 -0
  20. package/dist/github-client.d.ts +31 -0
  21. package/dist/id-map.d.ts +10 -0
  22. package/dist/index.d.ts +14 -0
  23. package/dist/index.js +3944 -774
  24. package/dist/index.js.map +1 -1
  25. package/dist/layered-review.d.ts +2 -0
  26. package/dist/measure-status.d.ts +127 -0
  27. package/dist/measured-only.d.ts +28 -0
  28. package/dist/measured-spec.d.ts +349 -0
  29. package/dist/measured-tokens.d.ts +25 -0
  30. package/dist/motion-docs.d.ts +51 -0
  31. package/dist/node/audit.d.ts +11 -3
  32. package/dist/node/index.d.ts +1 -0
  33. package/dist/node/index.js +1637 -24
  34. package/dist/node/index.js.map +1 -1
  35. package/dist/node/measure-script.d.ts +1 -0
  36. package/dist/node/measure.d.ts +212 -0
  37. package/dist/node/spec-css.d.ts +9 -1
  38. package/dist/node/tokens-script.d.ts +3 -0
  39. package/dist/pr-composer.d.ts +5 -0
  40. package/dist/previews.d.ts +4 -1
  41. package/dist/{prod-branch-DenQkr_e.js → prod-branch-Bdx_2bRQ.js} +197 -159
  42. package/dist/prod-branch-Bdx_2bRQ.js.map +1 -0
  43. package/dist/prod-branch.d.ts +1 -1
  44. package/dist/repo-model.d.ts +5 -1
  45. package/dist/repo-source-github.d.ts +8 -0
  46. package/dist/{repo-source-B4jNZhyC.js → repo-source-m0Tc603o.js} +1406 -629
  47. package/dist/repo-source-m0Tc603o.js.map +1 -0
  48. package/dist/repo-source.d.ts +6 -0
  49. package/dist/{report-DVEmUr0p.js → report-DFPKygfk.js} +17 -6
  50. package/dist/{report-DVEmUr0p.js.map → report-DFPKygfk.js.map} +1 -1
  51. package/dist/requester.d.ts +14 -0
  52. package/dist/requests.d.ts +2 -0
  53. package/dist/review-gate.d.ts +183 -2
  54. package/dist/risk.d.ts +12 -0
  55. package/dist/share-branch.d.ts +1 -1
  56. package/dist/snapshot.d.ts +34 -0
  57. package/dist/suggestion-review.d.ts +2 -0
  58. package/dist/suggestions-github.d.ts +21 -0
  59. package/dist/suggestions.d.ts +6 -0
  60. package/dist/token-proposal.d.ts +7 -0
  61. package/dist/try-in-product.d.ts +9 -0
  62. package/package.json +1 -1
  63. package/dist/prod-branch-DenQkr_e.js.map +0 -1
  64. package/dist/repo-source-B4jNZhyC.js.map +0 -1
@@ -13,6 +13,12 @@
13
13
  "const": 1,
14
14
  "description": "Config format version."
15
15
  },
16
+ "name": {
17
+ "type": "string",
18
+ "minLength": 1,
19
+ "maxLength": 60,
20
+ "description": "The team's display name, shown in Studio, the Library and invitations (\"Acme Design\"). Absent: Bridge names the team after its repository."
21
+ },
16
22
  "repo": {
17
23
  "description": "GitHub repository. Pull requests target defaultBranch; Bridge never writes to it.",
18
24
  "oneOf": [
@@ -700,6 +706,16 @@
700
706
  }
701
707
  }
702
708
  },
709
+ "demo": {
710
+ "type": "object",
711
+ "additionalProperties": false,
712
+ "required": ["viewer"],
713
+ "description": "A public demo's persona, read by Bridge's own demo repositories only: who a visitor without an account stands in for on the demo home (\"Good morning, Dana.\"). Ignored on any other repository.",
714
+ "properties": {
715
+ "viewer": { "type": "string", "minLength": 1, "description": "The persona's first name, for example \"Dana\"." },
716
+ "role": { "type": "string", "description": "What they do, for example \"DS lead\"." }
717
+ }
718
+ },
703
719
  "visualImpact": {
704
720
  "type": "object",
705
721
  "additionalProperties": false,
@@ -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;
@@ -1,6 +1,6 @@
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";
1
+ import { i as isAuditable, a as auditFile } from "../report-DFPKygfk.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-DFPKygfk.js";
3
+ import { p as pieceId, a as proposedTokenPath, t as tokenLabel } from "../prod-branch-Bdx_2bRQ.js";
4
4
  const lines = (text) => text.split(/\r?\n/);
5
5
  function lineBag(text) {
6
6
  const bag = /* @__PURE__ */ new Map();
@@ -44,8 +44,23 @@ export interface CssFixEdit {
44
44
  to: string;
45
45
  token: string;
46
46
  }
47
- /** Safe autofix for a CSS/SCSS/Less file: exact token matches become var(--token). Returns the edits and the new text. */
48
- export declare function planCssFixes(text: string, lang: 'css' | 'scss' | 'less', ds: DesignSystemIndex): {
47
+ /** A value the fix leaves as it is, like the audit leaves it out of the counts: an ignore comment or the allowlist. */
48
+ export interface CssFixKept {
49
+ line: number;
50
+ column: number;
51
+ from: string;
52
+ reason: string;
53
+ via: 'comment' | 'allowlist';
54
+ }
55
+ /**
56
+ * Safe autofix for a CSS/SCSS/Less file: exact token matches become var(--token). Returns the edits and the new text.
57
+ * The same exceptions as the audit: a `bridge-audit-ignore-next-line: reason` comment on the line above, and the
58
+ * allowlist entries of this file, keep the value (listed in `kept`).
59
+ */
60
+ export declare function planCssFixes(text: string, lang: 'css' | 'scss' | 'less', ds: DesignSystemIndex, opts?: {
61
+ allowlist?: AllowlistEntry[] | undefined;
62
+ }): {
49
63
  edits: CssFixEdit[];
50
64
  output: string;
65
+ kept: CssFixKept[];
51
66
  };
@@ -1,10 +1,15 @@
1
1
  import type { GitHubClient, Review } from './github-client';
2
2
  import { type MergeMethod, type MissingApproval } from './review-gate';
3
- /** Merges a branch at the head the person saw (GitHub refuses when it moved meanwhile). Studio's Merge button: squash. */
3
+ /**
4
+ * Merges a branch at the head the person saw (GitHub refuses when it moved meanwhile). Studio's Merge button: squash.
5
+ * `draft`: GitHub still calls it a draft though the gate reads it ready (core isDraft, `drafted-by-claude`), so it is
6
+ * marked ready for review first: GitHub never merges a draft.
7
+ */
4
8
  export declare function mergeOnGitHub(gh: GitHubClient, input: {
5
9
  number: number;
6
10
  headSha: string;
7
11
  method?: MergeMethod | undefined;
12
+ draft?: boolean | undefined;
8
13
  }): Promise<{
9
14
  sha: string;
10
15
  }>;
@@ -28,6 +33,7 @@ export declare function overrideMergeOnGitHub(gh: GitHubClient, input: {
28
33
  reason: string;
29
34
  missing: MissingApproval[];
30
35
  method: MergeMethod;
36
+ draft?: boolean | undefined;
31
37
  }): Promise<{
32
38
  sha: string;
33
39
  commentUrl: string;
@@ -0,0 +1,25 @@
1
+ import { type BuildRequestInput, type BuildRequestView, type LibraryArrival, type PublishOutcome } from './build-requests';
2
+ import type { GitHubClient } from './github-client';
3
+ /**
4
+ * Files a build request: one issue, labeled component-change (the bridge-jira Action mirrors it to Jira when set up),
5
+ * bridge-build, the request kind and the source. `labels` and `assignees` come from integrations.requests. Returns the
6
+ * outcome the plugin shows ("Build request sent").
7
+ */
8
+ export declare function createBuildRequestOnGitHub(gh: GitHubClient, input: BuildRequestInput, opts?: {
9
+ labels?: string[] | undefined;
10
+ assignees?: string[] | undefined;
11
+ componentUrl?: string | undefined;
12
+ }): Promise<PublishOutcome>;
13
+ /**
14
+ * Every build request with its status, read from GitHub: the component-change and bridge-build issues, and the pull
15
+ * requests that close them or are library branches from Figma. Two to three list calls, no per-item reads.
16
+ */
17
+ export declare function listBuildRequestsOnGitHub(gh: GitHubClient, opts?: {
18
+ now?: Date | number | undefined;
19
+ nameOf?: ((login: string) => string) | undefined;
20
+ }): Promise<BuildRequestView[]>;
21
+ /**
22
+ * Where a token push the plugin published as `shipped` stands: poll it until `final` ("In the library", or "Held for a
23
+ * developer" / "Not shipped"). Reads the pull request, its checks and its reviews.
24
+ */
25
+ export declare function libraryArrivalOnGitHub(gh: GitHubClient, n: number): Promise<LibraryArrival>;