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