@bridge-ds/core 0.5.1 → 0.7.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.
@@ -664,6 +664,75 @@
664
664
  "description": "auto or on-demand."
665
665
  }
666
666
  }
667
+ },
668
+ "products": {
669
+ "type": "array",
670
+ "minItems": 1,
671
+ "description": "The apps that consume the design system. Bridge Studio groups branches by product, and the CLI and MCP server tell which product a folder or a repository is. A branch belongs to the product its pull request label names (product: <key>), else to the first product whose folder holds one of its changed files, else to the default product. Leave it out to keep the Admin demo and the Library.",
672
+ "items": {
673
+ "type": "object",
674
+ "additionalProperties": false,
675
+ "required": [
676
+ "key",
677
+ "name"
678
+ ],
679
+ "properties": {
680
+ "key": {
681
+ "type": "string",
682
+ "pattern": "^[a-z0-9][a-z0-9-]*$",
683
+ "description": "Stable id made of lowercase letters, digits and dashes. The pull request label product: <key> names it."
684
+ },
685
+ "name": {
686
+ "type": "string",
687
+ "minLength": 1,
688
+ "description": "The name people read, such as Admin demo."
689
+ },
690
+ "repo": {
691
+ "type": "string",
692
+ "pattern": "^[\\w.-]+/[\\w.-]+$",
693
+ "description": "owner/name when the product lives in another GitHub repository."
694
+ },
695
+ "path": {
696
+ "type": "string",
697
+ "pattern": "^(?!/)(?!(.*/)?\\.\\.(/|$)).+$",
698
+ "description": "Folder of this repository that holds the product, relative to the root, such as apps/admin. No leading slash and no '..'."
699
+ },
700
+ "preview": {
701
+ "type": "string",
702
+ "pattern": "^https?://",
703
+ "description": "Preview URL pattern, with the same placeholders as previews.apps: {branch}, {rawBranch}, {pr}, {sha} and {sha7}."
704
+ },
705
+ "framework": {
706
+ "type": "string",
707
+ "description": "The framework the product is built with: react, vue, angular, svelte, astro or other.",
708
+ "examples": [
709
+ "react",
710
+ "vue",
711
+ "angular",
712
+ "svelte",
713
+ "astro",
714
+ "other"
715
+ ]
716
+ },
717
+ "default": {
718
+ "type": "boolean",
719
+ "description": "The product a branch belongs to when nothing else matches: the library. At most one. Without one, the last product is the default."
720
+ }
721
+ }
722
+ },
723
+ "default": [
724
+ {
725
+ "key": "admin",
726
+ "name": "Admin demo",
727
+ "path": "apps/admin",
728
+ "framework": "react"
729
+ },
730
+ {
731
+ "key": "library",
732
+ "name": "Library",
733
+ "default": true
734
+ }
735
+ ]
667
736
  }
668
737
  }
669
738
  }
@@ -0,0 +1,70 @@
1
+ import type { GitHubClient, Review } from './github-client';
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. */
4
+ export declare function mergeOnGitHub(gh: GitHubClient, input: {
5
+ number: number;
6
+ headSha: string;
7
+ method?: MergeMethod | undefined;
8
+ }): Promise<{
9
+ sha: string;
10
+ }>;
11
+ /** Where an owner override stopped: GitHub refused the reason comment (nothing merged), or the merge itself. */
12
+ export declare class OverrideMergeError extends Error {
13
+ readonly stage: 'comment' | 'merge';
14
+ readonly cause?: unknown | undefined;
15
+ readonly commentUrl?: string | undefined;
16
+ constructor(stage: 'comment' | 'merge', message: string, cause?: unknown | undefined, commentUrl?: string | undefined);
17
+ }
18
+ /**
19
+ * Merge as owner override: posts the reason on the branch first (the audit trail History reads back), then merges
20
+ * with the first merge method the repository allows. When GitHub refuses the merge, the comment is edited to say
21
+ * "Merge refused by GitHub ... Not merged", so the trail never claims a merge that did not happen. The caller checks
22
+ * the gate first (mergeGate: overridable) and the reason (overrideReasonProblem).
23
+ */
24
+ export declare function overrideMergeOnGitHub(gh: GitHubClient, input: {
25
+ number: number;
26
+ headSha: string;
27
+ login: string;
28
+ reason: string;
29
+ missing: MissingApproval[];
30
+ method: MergeMethod;
31
+ }): Promise<{
32
+ sha: string;
33
+ commentUrl: string;
34
+ comment: string;
35
+ }>;
36
+ export type ReviewEvent = 'APPROVE' | 'REQUEST_CHANGES' | 'COMMENT';
37
+ /** Approve, request changes or comment, on the head the reviewer saw. Changes and comments need a text. */
38
+ export declare function reviewOnGitHub(gh: GitHubClient, input: {
39
+ number: number;
40
+ event: ReviewEvent;
41
+ body?: string | undefined;
42
+ headSha?: string | undefined;
43
+ }): Promise<Review>;
44
+ /** A comment on the branch's conversation. */
45
+ export declare function commentOnGitHub(gh: GitHubClient, n: number, body: string): Promise<{
46
+ id: number;
47
+ url: string;
48
+ }>;
49
+ /**
50
+ * "Ask someone else to review": requests the review from `others` (core reviewersToAsk) and takes the viewer off the
51
+ * requested reviewers when GitHub had them on it. Throws how to fix it when nobody else can.
52
+ */
53
+ export declare function askOthersToReviewOnGitHub(gh: GitHubClient, input: {
54
+ number: number;
55
+ others: string[];
56
+ viewer?: string | null | undefined;
57
+ viewerRequested?: boolean | undefined;
58
+ }): Promise<string[]>;
59
+ /** Closes a branch without merging it. Its work stays on GitHub and it can be reopened. */
60
+ export declare function closeOnGitHub(gh: GitHubClient, n: number): Promise<void>;
61
+ /** Reopens a closed branch (GitHub refuses when its branch was deleted). */
62
+ export declare function reopenOnGitHub(gh: GitHubClient, n: number): Promise<void>;
63
+ /** Only the author or someone with write access to the repository adds to a branch. */
64
+ export declare function canAddTo(p: {
65
+ user: {
66
+ login: string;
67
+ } | null;
68
+ }, viewer: string | null | undefined, write: boolean): boolean;
69
+ /** The comment posted on the branch, so reviewers see what was added and from where. */
70
+ export declare function addedComment(paths: string[], viewer: string | null | undefined, from?: string): string;
@@ -0,0 +1,41 @@
1
+ import type { GitHubClient } from './github-client';
2
+ import { type ChangeEdits, type CombinePicks } from './token-combine';
3
+ export declare const MIN_TOGETHER = 2;
4
+ export declare const MAX_TOGETHER = 4;
5
+ /**
6
+ * Whether a change only edits tokens: token files under the tokens root, the contrast gate and release notes
7
+ * (changesets). Anything else is code. No file read yet (or none) is not a token change.
8
+ */
9
+ export declare function onlyTokens(files: string[], tokensRoot: string): boolean;
10
+ /** Token files a change edits, relative to the tokens root. */
11
+ export declare function tokenFilesOf(files: string[], tokensRoot: string): string[];
12
+ /** A list of changes in an address: "101,118,120" (commas stay readable). */
13
+ export declare const changeList: (numbers: number[]) => string;
14
+ /**
15
+ * The admin demo with the Bridge toolbar on the combination: production (no preview holds all of them), the tokens
16
+ * applied live. `bridge-use` carries the picks.
17
+ */
18
+ export declare function tryTogetherUrl(admin: string, numbers: number[], picks: CombinePicks): string;
19
+ /** GitHub lists at most 300 files per compare: past that, a branch cannot be read whole, so it is not combined. */
20
+ export declare const COMBINE_COMPARE_LIMIT = 300;
21
+ export interface CombineBranch {
22
+ number: number;
23
+ title: string;
24
+ /** Only token files (and release notes): it can be combined. */
25
+ tokens: boolean;
26
+ /** Its own token edits; null for a code change. */
27
+ edits: ChangeEdits | null;
28
+ }
29
+ /**
30
+ * One branch as the combination needs it: one compare against the default branch (the files it edits since it
31
+ * started, and where it started), then its token files at its start and now. Without a token the client reads the
32
+ * public raw host, so visitors spend no API read on file contents.
33
+ */
34
+ export declare function readCombineBranch(gh: GitHubClient, pull: {
35
+ number: number;
36
+ title: string;
37
+ headSha: string;
38
+ }, opts: {
39
+ base: string;
40
+ tokensRoot: string;
41
+ }): Promise<CombineBranch>;