@builder.io/ai-utils 0.17.3 → 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/package.json +1 -1
- package/src/codegen.d.ts +1 -0
- package/src/completion.d.ts +151 -147
- package/src/events.d.ts +333 -281
- package/src/mapping.d.ts +66 -66
- package/src/messages.d.ts +283 -214
- package/src/messages.js +12 -12
- package/src/organization.d.ts +351 -334
- package/src/projects.d.ts +571 -422
- package/src/projects.js +18 -17
- package/src/repo-indexing.d.ts +114 -96
- package/src/repo-indexing.js +5 -5
- package/src/settings.d.ts +15 -13
- package/src/settings.js +27 -26
- package/src/vscode-tunnel.d.ts +23 -8
- package/src/vscode-tunnel.js +36 -22
package/src/projects.js
CHANGED
|
@@ -1,49 +1,50 @@
|
|
|
1
1
|
export const EXAMPLE_REPOS = [
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
2
|
+
"steve8708/mui-vite",
|
|
3
|
+
"steve8708/carbon-vite",
|
|
4
|
+
"steve8708/vite-react-shopify-polaris",
|
|
5
|
+
"steve8708/cloudscape-demos",
|
|
6
|
+
"BuilderIO/fusion-angular-tailwind-starter",
|
|
7
|
+
"BuilderIO/fusion-svelte-tailwind-starter",
|
|
8
|
+
"BuilderIO/fusion-vue-tailwind-starter",
|
|
9
9
|
];
|
|
10
10
|
export const STARTER_REPO = "BuilderIO/fusion-starter";
|
|
11
11
|
export const EXAMPLE_OR_STARTER_REPOS = [...EXAMPLE_REPOS, STARTER_REPO];
|
|
12
|
-
export const EXAMPLE_OR_STARTER_REPOS_URLS = EXAMPLE_OR_STARTER_REPOS.map(
|
|
12
|
+
export const EXAMPLE_OR_STARTER_REPOS_URLS = EXAMPLE_OR_STARTER_REPOS.map(
|
|
13
|
+
(repo) => `https://github.com/${repo}`,
|
|
14
|
+
);
|
|
13
15
|
export const checkIsNewBranch = (branch) => {
|
|
14
|
-
|
|
16
|
+
return "projectId" in branch;
|
|
15
17
|
};
|
|
16
18
|
/**
|
|
17
19
|
* Get the state of a branch, checking `state` first and falling back to `deleted` for backwards compatibility.
|
|
18
20
|
*/
|
|
19
21
|
export const getBranchState = (branch) => {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
return branch.deleted ? "deleted" : "active";
|
|
22
|
+
if (branch.state) return branch.state;
|
|
23
|
+
return branch.deleted ? "deleted" : "active";
|
|
23
24
|
};
|
|
24
25
|
/**
|
|
25
26
|
* Get the state of a project, checking `state` first and falling back to `deleted` for backwards compatibility.
|
|
26
27
|
*/
|
|
27
28
|
export const getProjectState = (project) => {
|
|
28
|
-
|
|
29
|
-
|
|
29
|
+
var _a;
|
|
30
|
+
return (_a = project.state) !== null && _a !== void 0 ? _a : "active";
|
|
30
31
|
};
|
|
31
32
|
/**
|
|
32
33
|
* Check if a branch is deleted, supporting both `state` and legacy `deleted` fields.
|
|
33
34
|
* Note: Archived branches are NOT considered deleted.
|
|
34
35
|
*/
|
|
35
36
|
export const isBranchDeleted = (branch) => {
|
|
36
|
-
|
|
37
|
+
return getBranchState(branch) === "deleted";
|
|
37
38
|
};
|
|
38
39
|
/**
|
|
39
40
|
* Check if a branch is archived.
|
|
40
41
|
*/
|
|
41
42
|
export const isBranchArchived = (branch) => {
|
|
42
|
-
|
|
43
|
+
return getBranchState(branch) === "archived";
|
|
43
44
|
};
|
|
44
45
|
/**
|
|
45
46
|
* Check if a project is deleted, supporting both `state` and legacy `deleted` fields.
|
|
46
47
|
*/
|
|
47
48
|
export const isProjectDeleted = (project) => {
|
|
48
|
-
|
|
49
|
+
return getProjectState(project) === "deleted";
|
|
49
50
|
};
|
package/src/repo-indexing.d.ts
CHANGED
|
@@ -1,132 +1,150 @@
|
|
|
1
|
-
export type StoreComponentDocsInput =
|
|
1
|
+
export type StoreComponentDocsInput =
|
|
2
|
+
| StoreComponentDocsInputV1
|
|
3
|
+
| StoreComponentDocsInputV2
|
|
4
|
+
| IndexDocumentV1;
|
|
2
5
|
export interface ManualDocumentV1 {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
6
|
+
document: IndexDocumentV1;
|
|
7
|
+
filePath: string;
|
|
8
|
+
frontmatter: Record<string, any>;
|
|
9
|
+
body: string;
|
|
7
10
|
}
|
|
8
|
-
export type IndexDocumentV1 =
|
|
11
|
+
export type IndexDocumentV1 =
|
|
12
|
+
| ComponentDocument
|
|
13
|
+
| TokenDocument
|
|
14
|
+
| IconDocument
|
|
15
|
+
| AgentDocument
|
|
16
|
+
| InstallationDocument;
|
|
9
17
|
export interface ComponentDocument extends DocumentBase {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
18
|
+
type: "component";
|
|
19
|
+
relatedComponents: string[];
|
|
20
|
+
relevantFiles: string[];
|
|
21
|
+
hash: string;
|
|
14
22
|
}
|
|
15
23
|
export interface TokenDocument extends DocumentBase {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
24
|
+
type: "token";
|
|
25
|
+
hash: string;
|
|
26
|
+
relevantFiles: string[];
|
|
19
27
|
}
|
|
20
28
|
export interface IconDocument extends DocumentBase {
|
|
21
|
-
|
|
22
|
-
|
|
29
|
+
type: "icon";
|
|
30
|
+
hash: string;
|
|
23
31
|
}
|
|
24
32
|
export interface AgentDocument extends DocumentBase {
|
|
25
|
-
|
|
33
|
+
type: "agent";
|
|
26
34
|
}
|
|
27
35
|
export interface InstallationDocument extends DocumentBase {
|
|
28
|
-
|
|
29
|
-
|
|
36
|
+
type: "installation";
|
|
37
|
+
hash: string;
|
|
30
38
|
}
|
|
31
39
|
export interface DocumentBase {
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
40
|
+
id?: string;
|
|
41
|
+
name: string;
|
|
42
|
+
description: string;
|
|
43
|
+
content: string;
|
|
44
|
+
designSystemId: string;
|
|
45
|
+
designSystemPackage?: string;
|
|
46
|
+
designSystemVersion?: string;
|
|
47
|
+
tokens?: number;
|
|
48
|
+
sessionId?: string;
|
|
41
49
|
}
|
|
42
|
-
export declare const isAgentDocument: (
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
export declare const
|
|
46
|
-
|
|
50
|
+
export declare const isAgentDocument: (
|
|
51
|
+
doc: IndexDocumentV1,
|
|
52
|
+
) => doc is AgentDocument;
|
|
53
|
+
export declare const isIconDocument: (
|
|
54
|
+
doc: IndexDocumentV1,
|
|
55
|
+
) => doc is IconDocument;
|
|
56
|
+
export declare const isTokenDocument: (
|
|
57
|
+
doc: IndexDocumentV1,
|
|
58
|
+
) => doc is TokenDocument;
|
|
59
|
+
export declare const isComponentDocument: (
|
|
60
|
+
doc: IndexDocumentV1,
|
|
61
|
+
) => doc is ComponentDocument;
|
|
62
|
+
export declare const isInstallationDocument: (
|
|
63
|
+
doc: IndexDocumentV1,
|
|
64
|
+
) => doc is InstallationDocument;
|
|
47
65
|
/**
|
|
48
66
|
* @deprecated
|
|
49
67
|
* While some documents may still use this format, new documents should use the
|
|
50
68
|
* latest interface.
|
|
51
69
|
*/
|
|
52
70
|
interface StoreComponentDocsInputV1 {
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
71
|
+
id?: string;
|
|
72
|
+
ownerId?: string;
|
|
73
|
+
userId?: string;
|
|
74
|
+
createdDate?: Date;
|
|
75
|
+
deprecated?: boolean;
|
|
76
|
+
description: string;
|
|
77
|
+
name: string;
|
|
78
|
+
relatedComponents: string[];
|
|
79
|
+
relevantFiles: string[];
|
|
80
|
+
content: string;
|
|
81
|
+
sessionId: string;
|
|
82
|
+
designSystemPackage?: string;
|
|
83
|
+
designSystemVersion?: string;
|
|
84
|
+
hash?: string;
|
|
85
|
+
designSystemId?: string;
|
|
68
86
|
}
|
|
69
87
|
/**
|
|
70
88
|
* @deprecated
|
|
71
89
|
*/
|
|
72
90
|
interface StoreComponentDocsInputV2 {
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
91
|
+
id?: string;
|
|
92
|
+
ownerId?: string;
|
|
93
|
+
userId?: string;
|
|
94
|
+
createdDate?: Date;
|
|
95
|
+
deprecated?: boolean;
|
|
96
|
+
description: string;
|
|
97
|
+
name: string;
|
|
98
|
+
relatedComponents: string[];
|
|
99
|
+
relevantFiles: string[];
|
|
100
|
+
content: string;
|
|
101
|
+
sessionId: string;
|
|
102
|
+
hash?: string;
|
|
103
|
+
designSystemId?: string;
|
|
104
|
+
tokens?: number;
|
|
87
105
|
}
|
|
88
106
|
export type DesignSystemScope = "space" | "organization" | "global";
|
|
89
107
|
export interface AddDesignSystemInput {
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
108
|
+
designSystemName: string;
|
|
109
|
+
designSystemPackage?: string;
|
|
110
|
+
designSystemVersion?: string;
|
|
111
|
+
status: string;
|
|
112
|
+
spaceId: string;
|
|
113
|
+
rootOrgId: string;
|
|
114
|
+
scope: DesignSystemScope;
|
|
115
|
+
gitOriginUrl: string | undefined;
|
|
116
|
+
gitRelativePath: string | undefined;
|
|
117
|
+
cliArgs: string[];
|
|
100
118
|
}
|
|
101
119
|
export interface UpdateDesignSystemInput {
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
120
|
+
id: string;
|
|
121
|
+
designSystemName?: string;
|
|
122
|
+
scope?: DesignSystemScope;
|
|
123
|
+
designSystemPackage?: string;
|
|
124
|
+
designSystemVersion?: string;
|
|
125
|
+
status?: "in-progress" | "completed" | "failed";
|
|
126
|
+
source?: "auto" | "custom";
|
|
109
127
|
}
|
|
110
128
|
export interface DesignSystem {
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
129
|
+
id: string;
|
|
130
|
+
spaceId: string;
|
|
131
|
+
rootOrgId: string;
|
|
132
|
+
createdDate: Date;
|
|
133
|
+
createdByUserId: string;
|
|
134
|
+
lastUpdatedDate?: string;
|
|
135
|
+
lastUpdatedByUserId?: string;
|
|
136
|
+
designSystemName: string;
|
|
137
|
+
designSystemVersion?: string;
|
|
138
|
+
designSystemPackage?: string;
|
|
139
|
+
status: "in-progress" | "completed" | "failed";
|
|
140
|
+
scope: DesignSystemScope;
|
|
141
|
+
deprecated: boolean;
|
|
142
|
+
gitOriginUrl: string | undefined;
|
|
143
|
+
gitRelativePath: string | undefined;
|
|
144
|
+
cliArgs: string[];
|
|
145
|
+
source: "custom" | "auto";
|
|
128
146
|
}
|
|
129
147
|
export interface DisplayDesignSystem extends DesignSystem {
|
|
130
|
-
|
|
148
|
+
docCount: number;
|
|
131
149
|
}
|
|
132
150
|
export {};
|
package/src/repo-indexing.js
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
export const isAgentDocument = (doc) => {
|
|
2
|
-
|
|
2
|
+
return doc.type === "agent";
|
|
3
3
|
};
|
|
4
4
|
export const isIconDocument = (doc) => {
|
|
5
|
-
|
|
5
|
+
return doc.type === "icon";
|
|
6
6
|
};
|
|
7
7
|
export const isTokenDocument = (doc) => {
|
|
8
|
-
|
|
8
|
+
return doc.type === "token";
|
|
9
9
|
};
|
|
10
10
|
export const isComponentDocument = (doc) => {
|
|
11
|
-
|
|
11
|
+
return doc.type === "component";
|
|
12
12
|
};
|
|
13
13
|
export const isInstallationDocument = (doc) => {
|
|
14
|
-
|
|
14
|
+
return doc.type === "installation";
|
|
15
15
|
};
|
package/src/settings.d.ts
CHANGED
|
@@ -1,21 +1,23 @@
|
|
|
1
1
|
export interface AssistantSettings {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
2
|
+
assistantType?: string;
|
|
3
|
+
viewId?: string;
|
|
4
|
+
theme?: "dark" | "light";
|
|
5
|
+
allowNoStyleInspiration?: boolean;
|
|
6
6
|
}
|
|
7
7
|
interface IframeSettings extends Partial<AssistantSettings> {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
8
|
+
local?: boolean;
|
|
9
|
+
/**
|
|
10
|
+
* The URL of the assistant.
|
|
11
|
+
*/
|
|
12
|
+
baseUrl?: string;
|
|
13
13
|
}
|
|
14
14
|
export declare function getAssistantUrl(opts?: IframeSettings): string;
|
|
15
|
-
export declare function parseAssistantUrlSettings(
|
|
15
|
+
export declare function parseAssistantUrlSettings(
|
|
16
|
+
url: string,
|
|
17
|
+
): Partial<AssistantSettings>;
|
|
16
18
|
export interface BuilderEditorAuth {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
19
|
+
spaceId: string;
|
|
20
|
+
userId: string;
|
|
21
|
+
authToken: string;
|
|
20
22
|
}
|
|
21
23
|
export {};
|
package/src/settings.js
CHANGED
|
@@ -1,30 +1,31 @@
|
|
|
1
|
-
const urlParamSettings = [
|
|
2
|
-
"assistantType",
|
|
3
|
-
"theme",
|
|
4
|
-
"viewId",
|
|
5
|
-
];
|
|
1
|
+
const urlParamSettings = ["assistantType", "theme", "viewId"];
|
|
6
2
|
export function getAssistantUrl(opts = {}) {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
3
|
+
var _a;
|
|
4
|
+
const url = new URL(
|
|
5
|
+
(_a = opts.baseUrl) !== null && _a !== void 0
|
|
6
|
+
? _a
|
|
7
|
+
: opts.local
|
|
8
|
+
? "http://localhost:7242"
|
|
9
|
+
: "https://assistant.builder.io",
|
|
10
|
+
);
|
|
11
|
+
urlParamSettings.forEach((key) => {
|
|
12
|
+
const value = opts[key];
|
|
13
|
+
if (typeof value === "string" || typeof value === "boolean") {
|
|
14
|
+
url.searchParams.set(key, String(value));
|
|
15
|
+
}
|
|
16
|
+
});
|
|
17
|
+
return url.href;
|
|
16
18
|
}
|
|
17
19
|
export function parseAssistantUrlSettings(url) {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
return settings;
|
|
20
|
+
const parsed = new URL(url);
|
|
21
|
+
const settings = {};
|
|
22
|
+
urlParamSettings.forEach((key) => {
|
|
23
|
+
const value = parsed.searchParams.get(key);
|
|
24
|
+
if (value === "true" || value === "false") {
|
|
25
|
+
settings[key] = value === "true";
|
|
26
|
+
} else if (value) {
|
|
27
|
+
settings[key] = value;
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
return settings;
|
|
30
31
|
}
|
package/src/vscode-tunnel.d.ts
CHANGED
|
@@ -19,7 +19,10 @@ export declare const DEFAULT_WORKSPACE_PATH = "/root/app/code";
|
|
|
19
19
|
* generateVSCodeDeepLink("my-project-main")
|
|
20
20
|
* // Returns: "vscode://vscode-remote/tunnel+my-project-main/root/app/code"
|
|
21
21
|
*/
|
|
22
|
-
export declare function generateVSCodeDeepLink(
|
|
22
|
+
export declare function generateVSCodeDeepLink(
|
|
23
|
+
tunnelName: string,
|
|
24
|
+
workspacePath?: string,
|
|
25
|
+
): string;
|
|
23
26
|
/**
|
|
24
27
|
* Generate a Cursor deep link for a tunnel
|
|
25
28
|
*
|
|
@@ -31,7 +34,10 @@ export declare function generateVSCodeDeepLink(tunnelName: string, workspacePath
|
|
|
31
34
|
* generateCursorDeepLink("my-project-main")
|
|
32
35
|
* // Returns: "cursor://cursor-remote/tunnel+my-project-main/root/app/code"
|
|
33
36
|
*/
|
|
34
|
-
export declare function generateCursorDeepLink(
|
|
37
|
+
export declare function generateCursorDeepLink(
|
|
38
|
+
tunnelName: string,
|
|
39
|
+
workspacePath?: string,
|
|
40
|
+
): string;
|
|
35
41
|
/**
|
|
36
42
|
* Generate a web editor (vscode.dev) link for a tunnel
|
|
37
43
|
*
|
|
@@ -43,7 +49,10 @@ export declare function generateCursorDeepLink(tunnelName: string, workspacePath
|
|
|
43
49
|
* generateWebEditorLink("my-project-main")
|
|
44
50
|
* // Returns: "https://vscode.dev/tunnel/my-project-main/root/app/code"
|
|
45
51
|
*/
|
|
46
|
-
export declare function generateWebEditorLink(
|
|
52
|
+
export declare function generateWebEditorLink(
|
|
53
|
+
tunnelName: string,
|
|
54
|
+
workspacePath?: string,
|
|
55
|
+
): string;
|
|
47
56
|
/**
|
|
48
57
|
* Generate all deep links for a tunnel
|
|
49
58
|
*
|
|
@@ -59,10 +68,13 @@ export declare function generateWebEditorLink(tunnelName: string, workspacePath?
|
|
|
59
68
|
* // web: "https://vscode.dev/tunnel/my-project-main/root/app/code"
|
|
60
69
|
* // }
|
|
61
70
|
*/
|
|
62
|
-
export declare function generateAllEditorLinks(
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
71
|
+
export declare function generateAllEditorLinks(
|
|
72
|
+
tunnelName: string,
|
|
73
|
+
workspacePath?: string,
|
|
74
|
+
): {
|
|
75
|
+
vscode: string;
|
|
76
|
+
cursor: string;
|
|
77
|
+
web: string;
|
|
66
78
|
};
|
|
67
79
|
/**
|
|
68
80
|
* Generate a sanitized tunnel name from project and branch identifiers
|
|
@@ -75,7 +87,10 @@ export declare function generateAllEditorLinks(tunnelName: string, workspacePath
|
|
|
75
87
|
* generateTunnelName("abc123", "feature/my-branch")
|
|
76
88
|
* // Returns: "abc123-feature-my-branch"
|
|
77
89
|
*/
|
|
78
|
-
export declare function generateTunnelName(
|
|
90
|
+
export declare function generateTunnelName(
|
|
91
|
+
projectId: string,
|
|
92
|
+
branchName: string,
|
|
93
|
+
): string;
|
|
79
94
|
/**
|
|
80
95
|
* Parse a tunnel URL to extract the tunnel name
|
|
81
96
|
*
|
package/src/vscode-tunnel.js
CHANGED
|
@@ -19,8 +19,11 @@ export const DEFAULT_WORKSPACE_PATH = "/root/app/code";
|
|
|
19
19
|
* generateVSCodeDeepLink("my-project-main")
|
|
20
20
|
* // Returns: "vscode://vscode-remote/tunnel+my-project-main/root/app/code"
|
|
21
21
|
*/
|
|
22
|
-
export function generateVSCodeDeepLink(
|
|
23
|
-
|
|
22
|
+
export function generateVSCodeDeepLink(
|
|
23
|
+
tunnelName,
|
|
24
|
+
workspacePath = DEFAULT_WORKSPACE_PATH,
|
|
25
|
+
) {
|
|
26
|
+
return `vscode://vscode-remote/tunnel+${tunnelName}${workspacePath}`;
|
|
24
27
|
}
|
|
25
28
|
/**
|
|
26
29
|
* Generate a Cursor deep link for a tunnel
|
|
@@ -33,8 +36,11 @@ export function generateVSCodeDeepLink(tunnelName, workspacePath = DEFAULT_WORKS
|
|
|
33
36
|
* generateCursorDeepLink("my-project-main")
|
|
34
37
|
* // Returns: "cursor://cursor-remote/tunnel+my-project-main/root/app/code"
|
|
35
38
|
*/
|
|
36
|
-
export function generateCursorDeepLink(
|
|
37
|
-
|
|
39
|
+
export function generateCursorDeepLink(
|
|
40
|
+
tunnelName,
|
|
41
|
+
workspacePath = DEFAULT_WORKSPACE_PATH,
|
|
42
|
+
) {
|
|
43
|
+
return `cursor://cursor-remote/tunnel+${tunnelName}${workspacePath}`;
|
|
38
44
|
}
|
|
39
45
|
/**
|
|
40
46
|
* Generate a web editor (vscode.dev) link for a tunnel
|
|
@@ -47,8 +53,11 @@ export function generateCursorDeepLink(tunnelName, workspacePath = DEFAULT_WORKS
|
|
|
47
53
|
* generateWebEditorLink("my-project-main")
|
|
48
54
|
* // Returns: "https://vscode.dev/tunnel/my-project-main/root/app/code"
|
|
49
55
|
*/
|
|
50
|
-
export function generateWebEditorLink(
|
|
51
|
-
|
|
56
|
+
export function generateWebEditorLink(
|
|
57
|
+
tunnelName,
|
|
58
|
+
workspacePath = DEFAULT_WORKSPACE_PATH,
|
|
59
|
+
) {
|
|
60
|
+
return `https://vscode.dev/tunnel/${tunnelName}${workspacePath}`;
|
|
52
61
|
}
|
|
53
62
|
/**
|
|
54
63
|
* Generate all deep links for a tunnel
|
|
@@ -65,12 +74,15 @@ export function generateWebEditorLink(tunnelName, workspacePath = DEFAULT_WORKSP
|
|
|
65
74
|
* // web: "https://vscode.dev/tunnel/my-project-main/root/app/code"
|
|
66
75
|
* // }
|
|
67
76
|
*/
|
|
68
|
-
export function generateAllEditorLinks(
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
77
|
+
export function generateAllEditorLinks(
|
|
78
|
+
tunnelName,
|
|
79
|
+
workspacePath = DEFAULT_WORKSPACE_PATH,
|
|
80
|
+
) {
|
|
81
|
+
return {
|
|
82
|
+
vscode: generateVSCodeDeepLink(tunnelName, workspacePath),
|
|
83
|
+
cursor: generateCursorDeepLink(tunnelName, workspacePath),
|
|
84
|
+
web: generateWebEditorLink(tunnelName, workspacePath),
|
|
85
|
+
};
|
|
74
86
|
}
|
|
75
87
|
/**
|
|
76
88
|
* Generate a sanitized tunnel name from project and branch identifiers
|
|
@@ -84,14 +96,14 @@ export function generateAllEditorLinks(tunnelName, workspacePath = DEFAULT_WORKS
|
|
|
84
96
|
* // Returns: "abc123-feature-my-branch"
|
|
85
97
|
*/
|
|
86
98
|
export function generateTunnelName(projectId, branchName) {
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
99
|
+
const combined = `${projectId}-${branchName}`;
|
|
100
|
+
const sanitized = combined
|
|
101
|
+
.toLowerCase()
|
|
102
|
+
.replace(/[^a-z0-9-]/g, "-")
|
|
103
|
+
.replace(/-+/g, "-")
|
|
104
|
+
.replace(/^-|-$/g, "")
|
|
105
|
+
.substring(0, 63);
|
|
106
|
+
return sanitized || "builder-tunnel";
|
|
95
107
|
}
|
|
96
108
|
/**
|
|
97
109
|
* Parse a tunnel URL to extract the tunnel name
|
|
@@ -104,6 +116,8 @@ export function generateTunnelName(projectId, branchName) {
|
|
|
104
116
|
* // Returns: "my-project-main"
|
|
105
117
|
*/
|
|
106
118
|
export function parseTunnelUrl(tunnelUrl) {
|
|
107
|
-
|
|
108
|
-
|
|
119
|
+
const match = tunnelUrl.match(
|
|
120
|
+
/(?:vscode\.dev\/tunnel\/|tunnel\+)([a-zA-Z0-9_-]+)/,
|
|
121
|
+
);
|
|
122
|
+
return match ? match[1] : null;
|
|
109
123
|
}
|