@builder.io/ai-utils 0.65.0 → 0.66.1
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 +2 -9
- package/src/codegen.js +1 -14
- package/src/common-schemas.d.ts +35 -0
- package/src/common-schemas.js +43 -0
- package/src/connectivity/browser.d.ts +1 -1
- package/src/connectivity/browser.js +1 -1
- package/src/connectivity/environment.js +1 -2
- package/src/connectivity/node.d.ts +1 -1
- package/src/connectivity/node.js +1 -1
- package/src/connectivity/targets.d.ts +13 -1
- package/src/connectivity/targets.js +33 -4
- package/src/connectivity/targets.spec.js +34 -1
- package/src/connectivity/types.d.ts +1 -1
- package/src/index.d.ts +1 -0
- package/src/index.js +1 -0
- package/src/organization.d.ts +2 -1
- package/src/projects.d.ts +106 -27
- package/src/projects.js +122 -22
package/package.json
CHANGED
package/src/codegen.d.ts
CHANGED
|
@@ -2,7 +2,8 @@ import { z } from "zod";
|
|
|
2
2
|
import type { Options as PrettierOptions } from "prettier";
|
|
3
3
|
import type { Attachment, ContentMessageItemToolResult } from "./messages";
|
|
4
4
|
import type { BuilderContent } from "./completion";
|
|
5
|
-
import type
|
|
5
|
+
import { type EnvironmentVariable, type SetupDependency } from "./common-schemas";
|
|
6
|
+
import type { ForcedBackup, GitDiagnostics } from "./projects";
|
|
6
7
|
import type { Feature } from "./features";
|
|
7
8
|
import type { CpuKind, BranchType } from "./projects";
|
|
8
9
|
export declare const GitSnapshotSchema: z.ZodString;
|
|
@@ -816,14 +817,6 @@ export declare const ExitToolInputSchema: z.ZodObject<{
|
|
|
816
817
|
projectDescription: z.ZodOptional<z.ZodString>;
|
|
817
818
|
}, z.core.$strip>;
|
|
818
819
|
export type ExitToolInput = z.infer<typeof ExitToolInputSchema>;
|
|
819
|
-
export declare const EnvironmentVariableSchema: z.ZodObject<{
|
|
820
|
-
key: z.ZodString;
|
|
821
|
-
value: z.ZodString;
|
|
822
|
-
isSecret: z.ZodBoolean;
|
|
823
|
-
placeholder: z.ZodOptional<z.ZodBoolean>;
|
|
824
|
-
explanation: z.ZodOptional<z.ZodString>;
|
|
825
|
-
}, z.core.$strip>;
|
|
826
|
-
export type EnvironmentVariable = z.infer<typeof EnvironmentVariableSchema>;
|
|
827
820
|
export declare const ProposedConfigSchema: z.ZodObject<{
|
|
828
821
|
id: z.ZodString;
|
|
829
822
|
projectId: z.ZodString;
|
package/src/codegen.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
import { AttachmentSchema, ContentMessageItemToolResultSchema, } from "./messages";
|
|
3
3
|
import { UserContextSchema } from "./mapping";
|
|
4
|
-
import { SetupDependencySchema } from "./
|
|
4
|
+
import { EnvironmentVariableSchema, SetupDependencySchema, } from "./common-schemas";
|
|
5
5
|
export const GitSnapshotSchema = z.string().meta({
|
|
6
6
|
title: "GitSnapshot",
|
|
7
7
|
description: "Multi-repo git snapshot. Format: 'folder:hash,folder:hash' " +
|
|
@@ -906,19 +906,6 @@ const ProposedQuestionSchema = z.object({
|
|
|
906
906
|
.meta({ description: "Placeholder text for text-type questions" }),
|
|
907
907
|
options: z.array(LabelOptionSchema).optional(),
|
|
908
908
|
});
|
|
909
|
-
export const EnvironmentVariableSchema = z
|
|
910
|
-
.object({
|
|
911
|
-
key: z.string(),
|
|
912
|
-
value: z.string(),
|
|
913
|
-
isSecret: z.boolean(),
|
|
914
|
-
placeholder: z.boolean().optional().meta({
|
|
915
|
-
description: "If true, indicates this is a placeholder value that needs user replacement",
|
|
916
|
-
}),
|
|
917
|
-
explanation: z.string().optional().meta({
|
|
918
|
-
description: "Explanation of why this env var is needed and what value the user should provide",
|
|
919
|
-
}),
|
|
920
|
-
})
|
|
921
|
-
.meta({ title: "EnvironmentVariable" });
|
|
922
909
|
const ProposedConfigurationSchema = z.object({
|
|
923
910
|
setupCommand: z.object({
|
|
924
911
|
value: z.string().optional(),
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export declare const EnvironmentVariableSchema: z.ZodObject<{
|
|
3
|
+
key: z.ZodString;
|
|
4
|
+
value: z.ZodString;
|
|
5
|
+
isSecret: z.ZodBoolean;
|
|
6
|
+
placeholder: z.ZodOptional<z.ZodBoolean>;
|
|
7
|
+
explanation: z.ZodOptional<z.ZodString>;
|
|
8
|
+
}, z.core.$strip>;
|
|
9
|
+
export type EnvironmentVariable = z.infer<typeof EnvironmentVariableSchema>;
|
|
10
|
+
export declare const SetupMiseDependencySchema: z.ZodObject<{
|
|
11
|
+
key: z.ZodString;
|
|
12
|
+
type: z.ZodLiteral<"mise">;
|
|
13
|
+
tool: z.ZodString;
|
|
14
|
+
version: z.ZodOptional<z.ZodString>;
|
|
15
|
+
}, z.core.$strip>;
|
|
16
|
+
export type SetupMiseDependency = z.infer<typeof SetupMiseDependencySchema>;
|
|
17
|
+
export declare const SetupScriptDependencySchema: z.ZodObject<{
|
|
18
|
+
key: z.ZodString;
|
|
19
|
+
type: z.ZodLiteral<"script">;
|
|
20
|
+
name: z.ZodString;
|
|
21
|
+
script: z.ZodString;
|
|
22
|
+
}, z.core.$strip>;
|
|
23
|
+
export type SetupScriptDependency = z.infer<typeof SetupScriptDependencySchema>;
|
|
24
|
+
export declare const SetupDependencySchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
25
|
+
key: z.ZodString;
|
|
26
|
+
type: z.ZodLiteral<"mise">;
|
|
27
|
+
tool: z.ZodString;
|
|
28
|
+
version: z.ZodOptional<z.ZodString>;
|
|
29
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
30
|
+
key: z.ZodString;
|
|
31
|
+
type: z.ZodLiteral<"script">;
|
|
32
|
+
name: z.ZodString;
|
|
33
|
+
script: z.ZodString;
|
|
34
|
+
}, z.core.$strip>], "type">;
|
|
35
|
+
export type SetupDependency = z.infer<typeof SetupDependencySchema>;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
// ============================================================================
|
|
3
|
+
// Shared leaf schemas
|
|
4
|
+
//
|
|
5
|
+
// These schemas defined here to break runtime dependency cycle which would
|
|
6
|
+
// surface as "Cannot access '<Schema>' before initialization" depending on
|
|
7
|
+
// evaluation order. Keep this module dependency-free (zod only).
|
|
8
|
+
// ============================================================================
|
|
9
|
+
export const EnvironmentVariableSchema = z
|
|
10
|
+
.object({
|
|
11
|
+
key: z.string(),
|
|
12
|
+
value: z.string(),
|
|
13
|
+
isSecret: z.boolean(),
|
|
14
|
+
placeholder: z.boolean().optional().meta({
|
|
15
|
+
description: "If true, indicates this is a placeholder value that needs user replacement",
|
|
16
|
+
}),
|
|
17
|
+
explanation: z.string().optional().meta({
|
|
18
|
+
description: "Explanation of why this env var is needed and what value the user should provide",
|
|
19
|
+
}),
|
|
20
|
+
})
|
|
21
|
+
.meta({ title: "EnvironmentVariable" });
|
|
22
|
+
export const SetupMiseDependencySchema = z
|
|
23
|
+
.object({
|
|
24
|
+
key: z.string(),
|
|
25
|
+
type: z.literal("mise"),
|
|
26
|
+
tool: z.string(),
|
|
27
|
+
version: z.string().optional(),
|
|
28
|
+
})
|
|
29
|
+
.meta({ title: "SetupMiseDependency" });
|
|
30
|
+
export const SetupScriptDependencySchema = z
|
|
31
|
+
.object({
|
|
32
|
+
key: z.string(),
|
|
33
|
+
type: z.literal("script"),
|
|
34
|
+
name: z.string(),
|
|
35
|
+
script: z.string(),
|
|
36
|
+
})
|
|
37
|
+
.meta({ title: "SetupScriptDependency" });
|
|
38
|
+
export const SetupDependencySchema = z
|
|
39
|
+
.discriminatedUnion("type", [
|
|
40
|
+
SetupMiseDependencySchema,
|
|
41
|
+
SetupScriptDependencySchema,
|
|
42
|
+
])
|
|
43
|
+
.meta({ title: "SetupDependency" });
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export type { Source, TestId, Test, RunChecksInput, ProgressEvent, CheckResult, CheckReport, ConnectivityErrorCode, CheckType, Recommendation, LikelyCause, ConnectivityStatus, AnalysisResult, AnalyzeConnectivityInput, } from "./types.js";
|
|
2
2
|
export { runChecks } from "./run-checks.browser.js";
|
|
3
3
|
export { mapNodeErrorToConnectivityCode, mapHttpStatusToErrorCode, mapFetchErrorToConnectivityCode, connectivityErrorCodeToLikelyCause, mapConnectivityErrorMessage, SELF_SIGNED_CERT_ERRORS, CERT_EXPIRED_ERRORS, CERT_NOT_YET_VALID_ERRORS, CERT_INVALID_ERRORS, CERT_HOSTNAME_MISMATCH_ERRORS, SSL_PROTOCOL_ERRORS, SSL_HANDSHAKE_ERRORS, NETWORK_UNREACHABLE_ERRORS, TIMEOUT_ERRORS, PROXY_ERRORS, DNS_ERRORS, } from "./error-codes.js";
|
|
4
|
-
export { BUILDER_TARGETS, DEFAULT_PORTS, resolveTarget, extractHostname, extractPort, } from "./targets.js";
|
|
4
|
+
export { BUILDER_TARGETS, DEFAULT_PORTS, DEFAULT_LOCAL_BUILDER_TESTS, BUILDER_TEST_DISPLAY_NAMES, resolveTarget, extractHostname, extractPort, } from "./targets.js";
|
|
5
5
|
export { isBrowser, isNode, getCheckTypeForTestId, isCheckAvailable, getUnavailabilityReason, } from "./environment.js";
|
|
6
6
|
export { httpCheck } from "./checks/http-check.js";
|
|
7
7
|
export type { HttpCheckOptions } from "./checks/http-check.js";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { runChecks } from "./run-checks.browser.js";
|
|
2
2
|
export { mapNodeErrorToConnectivityCode, mapHttpStatusToErrorCode, mapFetchErrorToConnectivityCode, connectivityErrorCodeToLikelyCause, mapConnectivityErrorMessage, SELF_SIGNED_CERT_ERRORS, CERT_EXPIRED_ERRORS, CERT_NOT_YET_VALID_ERRORS, CERT_INVALID_ERRORS, CERT_HOSTNAME_MISMATCH_ERRORS, SSL_PROTOCOL_ERRORS, SSL_HANDSHAKE_ERRORS, NETWORK_UNREACHABLE_ERRORS, TIMEOUT_ERRORS, PROXY_ERRORS, DNS_ERRORS, } from "./error-codes.js";
|
|
3
|
-
export { BUILDER_TARGETS, DEFAULT_PORTS, resolveTarget, extractHostname, extractPort, } from "./targets.js";
|
|
3
|
+
export { BUILDER_TARGETS, DEFAULT_PORTS, DEFAULT_LOCAL_BUILDER_TESTS, BUILDER_TEST_DISPLAY_NAMES, resolveTarget, extractHostname, extractPort, } from "./targets.js";
|
|
4
4
|
export { isBrowser, isNode, getCheckTypeForTestId, isCheckAvailable, getUnavailabilityReason, } from "./environment.js";
|
|
5
5
|
export { httpCheck } from "./checks/http-check.js";
|
|
@@ -7,8 +7,7 @@ export function isNode() {
|
|
|
7
7
|
process.versions.node != null);
|
|
8
8
|
}
|
|
9
9
|
export function getCheckTypeForTestId(testId) {
|
|
10
|
-
if (testId === "
|
|
11
|
-
testId === "health.builderio.dev:ws") {
|
|
10
|
+
if (testId === "builderio.xyz:ws" || testId === "builderio.dev:ws") {
|
|
12
11
|
return "websocket";
|
|
13
12
|
}
|
|
14
13
|
if (testId.startsWith("git-host:")) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export type { Source, TestId, Test, RunChecksInput, ProgressEvent, CheckResult, CheckReport, ConnectivityErrorCode, CheckType, Recommendation, LikelyCause, ConnectivityStatus, AnalysisResult, AnalyzeConnectivityInput, ConnectivityFetchFn, } from "./types.js";
|
|
2
2
|
export { runChecks } from "./run-checks.js";
|
|
3
3
|
export { mapNodeErrorToConnectivityCode, mapHttpStatusToErrorCode, mapFetchErrorToConnectivityCode, connectivityErrorCodeToLikelyCause, mapConnectivityErrorMessage, SELF_SIGNED_CERT_ERRORS, CERT_EXPIRED_ERRORS, CERT_NOT_YET_VALID_ERRORS, CERT_INVALID_ERRORS, CERT_HOSTNAME_MISMATCH_ERRORS, SSL_PROTOCOL_ERRORS, SSL_HANDSHAKE_ERRORS, NETWORK_UNREACHABLE_ERRORS, TIMEOUT_ERRORS, PROXY_ERRORS, DNS_ERRORS, } from "./error-codes.js";
|
|
4
|
-
export { BUILDER_TARGETS, DEFAULT_PORTS, resolveTarget, extractHostname, extractPort, } from "./targets.js";
|
|
4
|
+
export { BUILDER_TARGETS, DEFAULT_PORTS, DEFAULT_LOCAL_BUILDER_TESTS, BUILDER_TEST_DISPLAY_NAMES, resolveTarget, extractHostname, extractPort, } from "./targets.js";
|
|
5
5
|
export { isBrowser, isNode, getCheckTypeForTestId, isCheckAvailable, getUnavailabilityReason, } from "./environment.js";
|
|
6
6
|
export { httpCheck } from "./checks/http-check.js";
|
|
7
7
|
export type { HttpCheckOptions } from "./checks/http-check.js";
|
package/src/connectivity/node.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export { runChecks } from "./run-checks.js";
|
|
2
2
|
export { mapNodeErrorToConnectivityCode, mapHttpStatusToErrorCode, mapFetchErrorToConnectivityCode, connectivityErrorCodeToLikelyCause, mapConnectivityErrorMessage, SELF_SIGNED_CERT_ERRORS, CERT_EXPIRED_ERRORS, CERT_NOT_YET_VALID_ERRORS, CERT_INVALID_ERRORS, CERT_HOSTNAME_MISMATCH_ERRORS, SSL_PROTOCOL_ERRORS, SSL_HANDSHAKE_ERRORS, NETWORK_UNREACHABLE_ERRORS, TIMEOUT_ERRORS, PROXY_ERRORS, DNS_ERRORS, } from "./error-codes.js";
|
|
3
|
-
export { BUILDER_TARGETS, DEFAULT_PORTS, resolveTarget, extractHostname, extractPort, } from "./targets.js";
|
|
3
|
+
export { BUILDER_TARGETS, DEFAULT_PORTS, DEFAULT_LOCAL_BUILDER_TESTS, BUILDER_TEST_DISPLAY_NAMES, resolveTarget, extractHostname, extractPort, } from "./targets.js";
|
|
4
4
|
export { isBrowser, isNode, getCheckTypeForTestId, isCheckAvailable, getUnavailabilityReason, } from "./environment.js";
|
|
5
5
|
export { httpCheck } from "./checks/http-check.js";
|
|
6
6
|
export { dnsCheck } from "./checks/dns-check.js";
|
|
@@ -1,5 +1,17 @@
|
|
|
1
|
-
import type { TestId } from "./types.js";
|
|
1
|
+
import type { Test, TestId } from "./types.js";
|
|
2
2
|
export declare const BUILDER_TARGETS: Record<string, string>;
|
|
3
|
+
/**
|
|
4
|
+
* Canonical ordered list of Builder-service connectivity tests, matching what
|
|
5
|
+
* the Builder app's ConnectivityService runs locally. Includes the four kube
|
|
6
|
+
* domain health probes (HTTP + WebSocket) for both *.builderio.xyz and
|
|
7
|
+
* *.builderio.dev.
|
|
8
|
+
*/
|
|
9
|
+
export declare const DEFAULT_LOCAL_BUILDER_TESTS: Test[];
|
|
10
|
+
/**
|
|
11
|
+
* Human-readable display names for Builder service testIds. Used by CLI and
|
|
12
|
+
* UI surfaces to show friendly labels instead of raw testId strings.
|
|
13
|
+
*/
|
|
14
|
+
export declare const BUILDER_TEST_DISPLAY_NAMES: Partial<Record<TestId, string>>;
|
|
3
15
|
export declare const DEFAULT_PORTS: Record<string, number>;
|
|
4
16
|
export declare function resolveTarget(testId: TestId, gitHost?: string): string;
|
|
5
17
|
export declare function extractHostname(target: string): string;
|
|
@@ -3,12 +3,41 @@ export const BUILDER_TARGETS = {
|
|
|
3
3
|
"builder.codes": "https://test.projects.builder.codes/proxy-health",
|
|
4
4
|
"api.builder.io": "https://api.builder.io/codegen/health",
|
|
5
5
|
"cdn.builder.io": "https://cdn.builder.io/api/v1/image/assets/TEMP/75a212ab82b6175c9862b125e0e23db8d369a58a?width=100",
|
|
6
|
-
|
|
7
|
-
"health.
|
|
8
|
-
|
|
9
|
-
"
|
|
6
|
+
// Health subdomains — dedicated endpoints for VPN/firewall diagnostics.
|
|
7
|
+
// The testId omits the "health." prefix for readability; the URL still
|
|
8
|
+
// targets health.builderio.* so wildcard allowlists are verified.
|
|
9
|
+
"builderio.xyz": "https://health.builderio.xyz/health",
|
|
10
|
+
"builderio.xyz:ws": "wss://health.builderio.xyz/ws",
|
|
11
|
+
"builderio.dev": "https://health.builderio.dev/health",
|
|
12
|
+
"builderio.dev:ws": "wss://health.builderio.dev/ws",
|
|
10
13
|
"fly.dev": "https://fly.dev",
|
|
11
14
|
};
|
|
15
|
+
/**
|
|
16
|
+
* Canonical ordered list of Builder-service connectivity tests, matching what
|
|
17
|
+
* the Builder app's ConnectivityService runs locally. Includes the four kube
|
|
18
|
+
* domain health probes (HTTP + WebSocket) for both *.builderio.xyz and
|
|
19
|
+
* *.builderio.dev.
|
|
20
|
+
*/
|
|
21
|
+
export const DEFAULT_LOCAL_BUILDER_TESTS = [
|
|
22
|
+
{ source: "local", testId: "builder.io" },
|
|
23
|
+
{ source: "local", testId: "builder.codes" },
|
|
24
|
+
{ source: "local", testId: "api.builder.io" },
|
|
25
|
+
{ source: "local", testId: "cdn.builder.io" },
|
|
26
|
+
{ source: "local", testId: "builderio.xyz" },
|
|
27
|
+
{ source: "local", testId: "builderio.xyz:ws" },
|
|
28
|
+
{ source: "local", testId: "builderio.dev" },
|
|
29
|
+
{ source: "local", testId: "builderio.dev:ws" },
|
|
30
|
+
];
|
|
31
|
+
/**
|
|
32
|
+
* Human-readable display names for Builder service testIds. Used by CLI and
|
|
33
|
+
* UI surfaces to show friendly labels instead of raw testId strings.
|
|
34
|
+
*/
|
|
35
|
+
export const BUILDER_TEST_DISPLAY_NAMES = {
|
|
36
|
+
"builderio.xyz": "*.builderio.xyz",
|
|
37
|
+
"builderio.xyz:ws": "*.builderio.xyz (WebSocket)",
|
|
38
|
+
"builderio.dev": "*.builderio.dev",
|
|
39
|
+
"builderio.dev:ws": "*.builderio.dev (WebSocket)",
|
|
40
|
+
};
|
|
12
41
|
export const DEFAULT_PORTS = {
|
|
13
42
|
http: 443,
|
|
14
43
|
https: 443,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { describe, it, expect } from "vitest";
|
|
2
|
-
import { extractPort, extractExplicitPort } from "./targets";
|
|
2
|
+
import { extractPort, extractExplicitPort, BUILDER_TARGETS, DEFAULT_LOCAL_BUILDER_TESTS, BUILDER_TEST_DISPLAY_NAMES, } from "./targets";
|
|
3
3
|
describe("extractPort", () => {
|
|
4
4
|
it("returns explicit port from URL", () => {
|
|
5
5
|
expect(extractPort("https://git.amazon.com:2222", 443)).toBe(2222);
|
|
@@ -43,3 +43,36 @@ describe("extractExplicitPort", () => {
|
|
|
43
43
|
expect(extractExplicitPort("not-a-url", 22)).toBe(22);
|
|
44
44
|
});
|
|
45
45
|
});
|
|
46
|
+
describe("DEFAULT_LOCAL_BUILDER_TESTS", () => {
|
|
47
|
+
const KUBE_IDS = [
|
|
48
|
+
"builderio.xyz",
|
|
49
|
+
"builderio.xyz:ws",
|
|
50
|
+
"builderio.dev",
|
|
51
|
+
"builderio.dev:ws",
|
|
52
|
+
];
|
|
53
|
+
it("includes all four kube domain test IDs", () => {
|
|
54
|
+
const ids = DEFAULT_LOCAL_BUILDER_TESTS.map((t) => t.testId);
|
|
55
|
+
for (const id of KUBE_IDS) {
|
|
56
|
+
expect(ids).toContain(id);
|
|
57
|
+
}
|
|
58
|
+
});
|
|
59
|
+
it("all tests have source=local", () => {
|
|
60
|
+
for (const t of DEFAULT_LOCAL_BUILDER_TESTS) {
|
|
61
|
+
expect(t.source).toBe("local");
|
|
62
|
+
}
|
|
63
|
+
});
|
|
64
|
+
it("kube testIds resolve to health subdomain URLs (testId omits health. prefix; URL does not)", () => {
|
|
65
|
+
expect(BUILDER_TARGETS["builderio.xyz"]).toBe("https://health.builderio.xyz/health");
|
|
66
|
+
expect(BUILDER_TARGETS["builderio.xyz:ws"]).toBe("wss://health.builderio.xyz/ws");
|
|
67
|
+
expect(BUILDER_TARGETS["builderio.dev"]).toBe("https://health.builderio.dev/health");
|
|
68
|
+
expect(BUILDER_TARGETS["builderio.dev:ws"]).toBe("wss://health.builderio.dev/ws");
|
|
69
|
+
});
|
|
70
|
+
});
|
|
71
|
+
describe("BUILDER_TEST_DISPLAY_NAMES", () => {
|
|
72
|
+
it("maps all four kube testIds to user-friendly labels", () => {
|
|
73
|
+
expect(BUILDER_TEST_DISPLAY_NAMES["builderio.xyz"]).toBe("*.builderio.xyz");
|
|
74
|
+
expect(BUILDER_TEST_DISPLAY_NAMES["builderio.xyz:ws"]).toBe("*.builderio.xyz (WebSocket)");
|
|
75
|
+
expect(BUILDER_TEST_DISPLAY_NAMES["builderio.dev"]).toBe("*.builderio.dev");
|
|
76
|
+
expect(BUILDER_TEST_DISPLAY_NAMES["builderio.dev:ws"]).toBe("*.builderio.dev (WebSocket)");
|
|
77
|
+
});
|
|
78
|
+
});
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export type Source = "local" | "cloud" | "static-ip";
|
|
2
|
-
export type TestId = "builder.io" | "builder.codes" | "api.builder.io" | "cdn.builder.io" | "
|
|
2
|
+
export type TestId = "builder.io" | "builder.codes" | "api.builder.io" | "cdn.builder.io" | "builderio.xyz" | "builderio.xyz:ws" | "builderio.dev" | "builderio.dev:ws" | "fly.dev" | "git-host:http" | "git-host:dns" | "git-host:tcp" | "git-host:tls" | "git-host:ssh";
|
|
3
3
|
export interface Test {
|
|
4
4
|
source: Source;
|
|
5
5
|
testId: TestId;
|
package/src/index.d.ts
CHANGED
package/src/index.js
CHANGED
package/src/organization.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { PrivacyMode, ReviewEffort } from "./codegen";
|
|
2
|
+
import type { EnvironmentVariable } from "./common-schemas";
|
|
2
3
|
export interface GithubEnterpriseSetupValue {
|
|
3
4
|
host: string;
|
|
4
5
|
clientId: string;
|
package/src/projects.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
import type { ConnectivityErrorCode, CheckType, LikelyCause } from "./connectivity/types.js";
|
|
3
|
-
import
|
|
3
|
+
import { type EnvironmentVariable, type SetupDependency } from "./common-schemas";
|
|
4
|
+
import type { FileOverride, LaunchServerState, LaunchServerStatus, BranchBackup, CommitMode, CustomInstruction, CustomAgentDefinition, GitSnapshot, AutoPushMode, GenerateUserMessage, CodeGenToolMap, GenerateCompletionStep, ReviewEffort } from "./codegen";
|
|
4
5
|
import type { FallbackTokensPrivate } from "./organization";
|
|
5
6
|
/**
|
|
6
7
|
* Temporary type for date fields during migration.
|
|
@@ -328,32 +329,6 @@ export type ShutdownResponse = {
|
|
|
328
329
|
export type ShutdownResponseSerialized = Omit<ShutdownResponse, "error"> & {
|
|
329
330
|
error?: string;
|
|
330
331
|
};
|
|
331
|
-
export declare const SetupMiseDependencySchema: z.ZodObject<{
|
|
332
|
-
key: z.ZodString;
|
|
333
|
-
type: z.ZodLiteral<"mise">;
|
|
334
|
-
tool: z.ZodString;
|
|
335
|
-
version: z.ZodOptional<z.ZodString>;
|
|
336
|
-
}, z.core.$strip>;
|
|
337
|
-
export type SetupMiseDependency = z.infer<typeof SetupMiseDependencySchema>;
|
|
338
|
-
export declare const SetupScriptDependencySchema: z.ZodObject<{
|
|
339
|
-
key: z.ZodString;
|
|
340
|
-
type: z.ZodLiteral<"script">;
|
|
341
|
-
name: z.ZodString;
|
|
342
|
-
script: z.ZodString;
|
|
343
|
-
}, z.core.$strip>;
|
|
344
|
-
export type SetupScriptDependency = z.infer<typeof SetupScriptDependencySchema>;
|
|
345
|
-
export declare const SetupDependencySchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
346
|
-
key: z.ZodString;
|
|
347
|
-
type: z.ZodLiteral<"mise">;
|
|
348
|
-
tool: z.ZodString;
|
|
349
|
-
version: z.ZodOptional<z.ZodString>;
|
|
350
|
-
}, z.core.$strip>, z.ZodObject<{
|
|
351
|
-
key: z.ZodString;
|
|
352
|
-
type: z.ZodLiteral<"script">;
|
|
353
|
-
name: z.ZodString;
|
|
354
|
-
script: z.ZodString;
|
|
355
|
-
}, z.core.$strip>], "type">;
|
|
356
|
-
export type SetupDependency = z.infer<typeof SetupDependencySchema>;
|
|
357
332
|
export type FusionExecutionEnvironment = "containerized" | "container-less" | "cloud" | "cloud-v2";
|
|
358
333
|
export type AgentType = "setup-project" | "project-configuration" | "org-agent" | "code-review-orchestrator" | "design-system-indexer" | "builder-publish-integration";
|
|
359
334
|
export interface PartialBranchData {
|
|
@@ -889,6 +864,8 @@ export interface Project {
|
|
|
889
864
|
userInitiatedAutoSetup?: boolean;
|
|
890
865
|
/** When true, automatically apply verified setup configuration when the setup agent completes */
|
|
891
866
|
autoApplySetup?: boolean;
|
|
867
|
+
/** Settings related to Fusion fist class hosting */
|
|
868
|
+
hosting?: ProjectHosting;
|
|
892
869
|
}
|
|
893
870
|
/**
|
|
894
871
|
* Get the state of a branch, checking `state` first and falling back to `deleted` for backwards compatibility.
|
|
@@ -1235,4 +1212,106 @@ export interface ShouldDeletePodResponse {
|
|
|
1235
1212
|
reason: "branch_inactive" | "force_delete_flag" | "project_not_found" | "branch_not_found" | "ok" | "error";
|
|
1236
1213
|
error?: string;
|
|
1237
1214
|
}
|
|
1215
|
+
/**
|
|
1216
|
+
* Deploy lifecycle status:
|
|
1217
|
+
* - queued - inital state although we don't currently queue deploys per se
|
|
1218
|
+
* - building — deploy pod is running `npm run build`
|
|
1219
|
+
* - uploading — build succeeded; artifacts being uploaded to GCS (transient,
|
|
1220
|
+
* between `client.devtools.build.completed` and `client.devtools.build.uploaded`)
|
|
1221
|
+
* - deploying — queue handler is pushing artifacts to Netlify + updating Envoy HTTPRoute
|
|
1222
|
+
* - live — terminal: site is serving traffic
|
|
1223
|
+
* - failed — terminal: see `error` for the one-line reason
|
|
1224
|
+
*/
|
|
1225
|
+
export declare const DeployStatusSchema: z.ZodEnum<{
|
|
1226
|
+
building: "building";
|
|
1227
|
+
deploying: "deploying";
|
|
1228
|
+
failed: "failed";
|
|
1229
|
+
live: "live";
|
|
1230
|
+
queued: "queued";
|
|
1231
|
+
uploading: "uploading";
|
|
1232
|
+
}>;
|
|
1233
|
+
export type DeployStatus = z.infer<typeof DeployStatusSchema>;
|
|
1234
|
+
export declare const ProjectHostingBuildConfigSchema: z.ZodObject<{
|
|
1235
|
+
buildCommand: z.ZodOptional<z.ZodString>;
|
|
1236
|
+
nodeVersion: z.ZodOptional<z.ZodString>;
|
|
1237
|
+
}, z.core.$strip>;
|
|
1238
|
+
export type ProjectHostingBuildConfig = z.infer<typeof ProjectHostingBuildConfigSchema>;
|
|
1239
|
+
/**
|
|
1240
|
+
* Hosting configuration for a project, stored at `projects/{projectId}.hosting`.
|
|
1241
|
+
*/
|
|
1242
|
+
export declare const ProjectHostingSchema: z.ZodObject<{
|
|
1243
|
+
enabled: z.ZodOptional<z.ZodBoolean>;
|
|
1244
|
+
slug: z.ZodOptional<z.ZodString>;
|
|
1245
|
+
netlifySiteId: z.ZodOptional<z.ZodString>;
|
|
1246
|
+
netlifySiteName: z.ZodOptional<z.ZodString>;
|
|
1247
|
+
url: z.ZodOptional<z.ZodString>;
|
|
1248
|
+
buildConfig: z.ZodOptional<z.ZodObject<{
|
|
1249
|
+
buildCommand: z.ZodOptional<z.ZodString>;
|
|
1250
|
+
nodeVersion: z.ZodOptional<z.ZodString>;
|
|
1251
|
+
}, z.core.$strip>>;
|
|
1252
|
+
environment: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
1253
|
+
key: z.ZodString;
|
|
1254
|
+
value: z.ZodString;
|
|
1255
|
+
isSecret: z.ZodBoolean;
|
|
1256
|
+
placeholder: z.ZodOptional<z.ZodBoolean>;
|
|
1257
|
+
explanation: z.ZodOptional<z.ZodString>;
|
|
1258
|
+
}, z.core.$strip>>>;
|
|
1259
|
+
lastDeployId: z.ZodOptional<z.ZodString>;
|
|
1260
|
+
lastDeployAt: z.ZodOptional<z.ZodNumber>;
|
|
1261
|
+
lastDeployStatus: z.ZodOptional<z.ZodEnum<{
|
|
1262
|
+
building: "building";
|
|
1263
|
+
deploying: "deploying";
|
|
1264
|
+
failed: "failed";
|
|
1265
|
+
live: "live";
|
|
1266
|
+
queued: "queued";
|
|
1267
|
+
uploading: "uploading";
|
|
1268
|
+
}>>;
|
|
1269
|
+
customDomain: z.ZodOptional<z.ZodString>;
|
|
1270
|
+
customDomainVerified: z.ZodOptional<z.ZodBoolean>;
|
|
1271
|
+
autoDeploy: z.ZodOptional<z.ZodBoolean>;
|
|
1272
|
+
}, z.core.$strip>;
|
|
1273
|
+
export type ProjectHosting = z.infer<typeof ProjectHostingSchema>;
|
|
1274
|
+
/**
|
|
1275
|
+
* A single deploy record, stored at `deploys/{deployId}`. The Deploy.id is the document key.
|
|
1276
|
+
*/
|
|
1277
|
+
export declare const DeploySchema: z.ZodObject<{
|
|
1278
|
+
id: z.ZodString;
|
|
1279
|
+
projectId: z.ZodString;
|
|
1280
|
+
ownerId: z.ZodString;
|
|
1281
|
+
checkoutBranch: z.ZodOptional<z.ZodString>;
|
|
1282
|
+
deployBranchId: z.ZodOptional<z.ZodString>;
|
|
1283
|
+
status: z.ZodEnum<{
|
|
1284
|
+
building: "building";
|
|
1285
|
+
deploying: "deploying";
|
|
1286
|
+
failed: "failed";
|
|
1287
|
+
live: "live";
|
|
1288
|
+
queued: "queued";
|
|
1289
|
+
uploading: "uploading";
|
|
1290
|
+
}>;
|
|
1291
|
+
netlifyDeployId: z.ZodOptional<z.ZodString>;
|
|
1292
|
+
url: z.ZodOptional<z.ZodString>;
|
|
1293
|
+
error: z.ZodOptional<z.ZodString>;
|
|
1294
|
+
createdAt: z.ZodNumber;
|
|
1295
|
+
completedAt: z.ZodOptional<z.ZodNumber>;
|
|
1296
|
+
triggeredBy: z.ZodString;
|
|
1297
|
+
}, z.core.$strip>;
|
|
1298
|
+
export type Deploy = z.infer<typeof DeploySchema>;
|
|
1299
|
+
/**
|
|
1300
|
+
* Permanent slug reservation, stored at `hosting-slugs/{slug}` (slug is the document key).
|
|
1301
|
+
*
|
|
1302
|
+
* Created on first publish via the atomic Firestore transaction in
|
|
1303
|
+
* `POST /projects/hosting/reserve-slug`. Never deleted (URL hijacking protection).
|
|
1304
|
+
*
|
|
1305
|
+
* "Is this URL currently live?" is NOT a property of this doc. It's answered by the
|
|
1306
|
+
* presence of the per-slug `HTTPRoute` in Envoy Gateway (the source of truth for routing)
|
|
1307
|
+
* and/or by `project.hosting.netlifySiteId` (set on publish, cleared on unpublish). The
|
|
1308
|
+
* slug doc exists purely to enforce uniqueness and own the permanent reservation.
|
|
1309
|
+
*/
|
|
1310
|
+
export declare const HostingSlugSchema: z.ZodObject<{
|
|
1311
|
+
projectId: z.ZodString;
|
|
1312
|
+
ownerId: z.ZodString;
|
|
1313
|
+
createdAt: z.ZodNumber;
|
|
1314
|
+
createdBy: z.ZodString;
|
|
1315
|
+
}, z.core.$strip>;
|
|
1316
|
+
export type HostingSlug = z.infer<typeof HostingSlugSchema>;
|
|
1238
1317
|
export {};
|
package/src/projects.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
+
import { EnvironmentVariableSchema, } from "./common-schemas";
|
|
2
3
|
/**
|
|
3
4
|
* Detect git provider from a repository URL (HTTPS or SSH).
|
|
4
5
|
* Used by both error diagnostics and connectivity checks for consistent provider labeling.
|
|
@@ -37,28 +38,6 @@ export const STARTER_REPO = "BuilderIO/fusion-starter";
|
|
|
37
38
|
export const DSI_PREVIEW_REPO = "BuilderIO/dsi-starter";
|
|
38
39
|
export const EXAMPLE_OR_STARTER_REPOS = [...EXAMPLE_REPOS, STARTER_REPO];
|
|
39
40
|
export const EXAMPLE_OR_STARTER_REPOS_URLS = EXAMPLE_OR_STARTER_REPOS.map((repo) => `https://github.com/${repo}`);
|
|
40
|
-
export const SetupMiseDependencySchema = z
|
|
41
|
-
.object({
|
|
42
|
-
key: z.string(),
|
|
43
|
-
type: z.literal("mise"),
|
|
44
|
-
tool: z.string(),
|
|
45
|
-
version: z.string().optional(),
|
|
46
|
-
})
|
|
47
|
-
.meta({ title: "SetupMiseDependency" });
|
|
48
|
-
export const SetupScriptDependencySchema = z
|
|
49
|
-
.object({
|
|
50
|
-
key: z.string(),
|
|
51
|
-
type: z.literal("script"),
|
|
52
|
-
name: z.string(),
|
|
53
|
-
script: z.string(),
|
|
54
|
-
})
|
|
55
|
-
.meta({ title: "SetupScriptDependency" });
|
|
56
|
-
export const SetupDependencySchema = z
|
|
57
|
-
.discriminatedUnion("type", [
|
|
58
|
-
SetupMiseDependencySchema,
|
|
59
|
-
SetupScriptDependencySchema,
|
|
60
|
-
])
|
|
61
|
-
.meta({ title: "SetupDependency" });
|
|
62
41
|
export const checkIsNewBranch = (branch) => {
|
|
63
42
|
return "projectId" in branch;
|
|
64
43
|
};
|
|
@@ -185,3 +164,124 @@ export function parseExitPlanMode(chunk) {
|
|
|
185
164
|
}
|
|
186
165
|
return null;
|
|
187
166
|
}
|
|
167
|
+
// ============================================================================
|
|
168
|
+
// First-class Hosting
|
|
169
|
+
// ============================================================================
|
|
170
|
+
/**
|
|
171
|
+
* Deploy lifecycle status:
|
|
172
|
+
* - queued - inital state although we don't currently queue deploys per se
|
|
173
|
+
* - building — deploy pod is running `npm run build`
|
|
174
|
+
* - uploading — build succeeded; artifacts being uploaded to GCS (transient,
|
|
175
|
+
* between `client.devtools.build.completed` and `client.devtools.build.uploaded`)
|
|
176
|
+
* - deploying — queue handler is pushing artifacts to Netlify + updating Envoy HTTPRoute
|
|
177
|
+
* - live — terminal: site is serving traffic
|
|
178
|
+
* - failed — terminal: see `error` for the one-line reason
|
|
179
|
+
*/
|
|
180
|
+
export const DeployStatusSchema = z.enum([
|
|
181
|
+
"queued",
|
|
182
|
+
"building",
|
|
183
|
+
"uploading",
|
|
184
|
+
"deploying",
|
|
185
|
+
"live",
|
|
186
|
+
"failed",
|
|
187
|
+
]);
|
|
188
|
+
export const ProjectHostingBuildConfigSchema = z.object({
|
|
189
|
+
buildCommand: z.string().optional(),
|
|
190
|
+
nodeVersion: z.string().optional(),
|
|
191
|
+
});
|
|
192
|
+
/**
|
|
193
|
+
* Hosting configuration for a project, stored at `projects/{projectId}.hosting`.
|
|
194
|
+
*/
|
|
195
|
+
export const ProjectHostingSchema = z.object({
|
|
196
|
+
enabled: z.boolean().optional().meta({
|
|
197
|
+
description: "Whether hosting is enabled for this project or not.",
|
|
198
|
+
}),
|
|
199
|
+
slug: z.string().optional().meta({
|
|
200
|
+
description: 'e.g. "my-cool-app" — set once on first publish, immutable',
|
|
201
|
+
}),
|
|
202
|
+
netlifySiteId: z.string().optional().meta({
|
|
203
|
+
description: "Netlify site ID for management API calls; cleared on unpublish, set again on re-publish",
|
|
204
|
+
}),
|
|
205
|
+
netlifySiteName: z.string().optional().meta({
|
|
206
|
+
description: "<name> in <name>.netlify.app — the upstream the HTTPRoute filter rewrites Host to; cleared on unpublish",
|
|
207
|
+
}),
|
|
208
|
+
url: z.string().optional().meta({
|
|
209
|
+
description: '"https://my-cool-app.builder.cloud" — derived from slug',
|
|
210
|
+
}),
|
|
211
|
+
buildConfig: ProjectHostingBuildConfigSchema.optional(),
|
|
212
|
+
/**
|
|
213
|
+
* Hosting-build environment variables. Separate from `project.settings.environmentVariables`
|
|
214
|
+
* (which feeds the dev pod) so users can set different values for dev vs production —
|
|
215
|
+
* mirrors the Vercel/Netlify split between development and production env scopes.
|
|
216
|
+
*
|
|
217
|
+
* Reuses `EnvironmentVariableSchema`, including the `isSecret: boolean` flag. Stored in
|
|
218
|
+
* plaintext in Firestore, masked on the read path before responses leave ai-services
|
|
219
|
+
* (see "Secret handling" in the hosting spec).
|
|
220
|
+
*/
|
|
221
|
+
environment: z.array(EnvironmentVariableSchema).optional().meta({
|
|
222
|
+
description: "Production environment variables set when we deploy",
|
|
223
|
+
}),
|
|
224
|
+
lastDeployId: z.string().optional(),
|
|
225
|
+
lastDeployAt: z.number().optional(),
|
|
226
|
+
lastDeployStatus: DeployStatusSchema.optional(),
|
|
227
|
+
customDomain: z.string().optional(),
|
|
228
|
+
customDomainVerified: z.boolean().optional(),
|
|
229
|
+
autoDeploy: z
|
|
230
|
+
.boolean()
|
|
231
|
+
.optional()
|
|
232
|
+
.meta({ description: "auto-deploy on push/merge" }),
|
|
233
|
+
});
|
|
234
|
+
/**
|
|
235
|
+
* A single deploy record, stored at `deploys/{deployId}`. The Deploy.id is the document key.
|
|
236
|
+
*/
|
|
237
|
+
export const DeploySchema = z.object({
|
|
238
|
+
id: z.string(),
|
|
239
|
+
projectId: z.string(),
|
|
240
|
+
ownerId: z.string(),
|
|
241
|
+
checkoutBranch: z
|
|
242
|
+
.string()
|
|
243
|
+
.optional()
|
|
244
|
+
.meta({
|
|
245
|
+
description: 'The git ref that was deployed (always "main" in v0/v1; the feature branch ' +
|
|
246
|
+
"for row 2 in v2). This is the value passed as `checkoutBranch` when the " +
|
|
247
|
+
"deploy pod was created.",
|
|
248
|
+
}),
|
|
249
|
+
deployBranchId: z
|
|
250
|
+
.string()
|
|
251
|
+
.optional()
|
|
252
|
+
.meta({
|
|
253
|
+
description: 'ID of the ephemeral hidden deploy branch (`type: "deploy"`) that ran the ' +
|
|
254
|
+
"build. Cleared after the pod terminates so historical Deploy docs don't " +
|
|
255
|
+
"hold references to garbage-collected branch state.",
|
|
256
|
+
}),
|
|
257
|
+
status: DeployStatusSchema,
|
|
258
|
+
netlifyDeployId: z.string().optional(),
|
|
259
|
+
url: z.string().optional(),
|
|
260
|
+
error: z.string().optional().meta({
|
|
261
|
+
description: "Single human-readable line on failure; raw build logs not surfaced in v0",
|
|
262
|
+
}),
|
|
263
|
+
createdAt: z.number(),
|
|
264
|
+
completedAt: z.number().optional(),
|
|
265
|
+
triggeredBy: z.string().meta({
|
|
266
|
+
description: 'user ID for manual publish, or "auto-deploy" (v1)',
|
|
267
|
+
}),
|
|
268
|
+
});
|
|
269
|
+
/**
|
|
270
|
+
* Permanent slug reservation, stored at `hosting-slugs/{slug}` (slug is the document key).
|
|
271
|
+
*
|
|
272
|
+
* Created on first publish via the atomic Firestore transaction in
|
|
273
|
+
* `POST /projects/hosting/reserve-slug`. Never deleted (URL hijacking protection).
|
|
274
|
+
*
|
|
275
|
+
* "Is this URL currently live?" is NOT a property of this doc. It's answered by the
|
|
276
|
+
* presence of the per-slug `HTTPRoute` in Envoy Gateway (the source of truth for routing)
|
|
277
|
+
* and/or by `project.hosting.netlifySiteId` (set on publish, cleared on unpublish). The
|
|
278
|
+
* slug doc exists purely to enforce uniqueness and own the permanent reservation.
|
|
279
|
+
*/
|
|
280
|
+
export const HostingSlugSchema = z.object({
|
|
281
|
+
projectId: z.string(),
|
|
282
|
+
ownerId: z.string(),
|
|
283
|
+
createdAt: z.number(),
|
|
284
|
+
createdBy: z.string().meta({
|
|
285
|
+
description: "user ID of the user who first clicked Publish on the project",
|
|
286
|
+
}),
|
|
287
|
+
});
|