@builder.io/ai-utils 0.74.0 → 0.74.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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@builder.io/ai-utils",
3
- "version": "0.74.0",
3
+ "version": "0.74.2",
4
4
  "description": "Builder.io AI utils",
5
5
  "files": [
6
6
  "src"
@@ -18,11 +18,36 @@ export declare const BuilderConfigDatabaseSchema: z.ZodObject<{
18
18
  schemaDir: z.ZodDefault<z.ZodString>;
19
19
  }, z.core.$strip>;
20
20
  export type BuilderConfigDatabase = z.infer<typeof BuilderConfigDatabaseSchema>;
21
+ /** `hosting` block in `builder.config.json` — see First Class Hosting spec. */
22
+ export declare const BuilderConfigHostingEnvironmentSchema: z.ZodObject<{
23
+ build: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
24
+ prod: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
25
+ }, z.core.$strip>;
26
+ export type BuilderConfigHostingEnvironment = z.infer<typeof BuilderConfigHostingEnvironmentSchema>;
27
+ export declare const BuilderConfigHostingSchema: z.ZodObject<{
28
+ buildCommand: z.ZodOptional<z.ZodString>;
29
+ nodeVersion: z.ZodOptional<z.ZodString>;
30
+ buildOutputDir: z.ZodOptional<z.ZodString>;
31
+ environment: z.ZodOptional<z.ZodObject<{
32
+ build: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
33
+ prod: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
34
+ }, z.core.$strip>>;
35
+ }, z.core.$strip>;
36
+ export type BuilderConfigHosting = z.infer<typeof BuilderConfigHostingSchema>;
21
37
  export declare const BuilderConfigSchema: z.ZodObject<{
22
38
  database: z.ZodOptional<z.ZodObject<{
23
39
  kind: z.ZodLiteral<"postgres">;
24
40
  migrations: z.ZodLiteral<"drizzle">;
25
41
  schemaDir: z.ZodDefault<z.ZodString>;
26
42
  }, z.core.$strip>>;
43
+ hosting: z.ZodOptional<z.ZodObject<{
44
+ buildCommand: z.ZodOptional<z.ZodString>;
45
+ nodeVersion: z.ZodOptional<z.ZodString>;
46
+ buildOutputDir: z.ZodOptional<z.ZodString>;
47
+ environment: z.ZodOptional<z.ZodObject<{
48
+ build: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
49
+ prod: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
50
+ }, z.core.$strip>>;
51
+ }, z.core.$strip>>;
27
52
  }, z.core.$strip>;
28
53
  export type BuilderConfig = z.infer<typeof BuilderConfigSchema>;
@@ -17,6 +17,18 @@ export const BuilderConfigDatabaseSchema = z.object({
17
17
  migrations: z.literal("drizzle"),
18
18
  schemaDir: z.string().default("drizzle"),
19
19
  });
20
+ /** `hosting` block in `builder.config.json` — see First Class Hosting spec. */
21
+ export const BuilderConfigHostingEnvironmentSchema = z.object({
22
+ build: z.record(z.string(), z.string()).optional(),
23
+ prod: z.record(z.string(), z.string()).optional(),
24
+ });
25
+ export const BuilderConfigHostingSchema = z.object({
26
+ buildCommand: z.string().optional(),
27
+ nodeVersion: z.string().optional(),
28
+ buildOutputDir: z.string().optional(),
29
+ environment: BuilderConfigHostingEnvironmentSchema.optional(),
30
+ });
20
31
  export const BuilderConfigSchema = z.object({
21
32
  database: BuilderConfigDatabaseSchema.optional(),
33
+ hosting: BuilderConfigHostingSchema.optional(),
22
34
  });
package/src/codegen.d.ts CHANGED
@@ -1317,7 +1317,16 @@ export type SubmitPRReviewToolInput = z.infer<typeof SubmitPRReviewToolInputSche
1317
1317
  export declare const AddCommentToolInputSchema: z.ZodObject<{
1318
1318
  type: z.ZodString;
1319
1319
  content: z.ZodString;
1320
- metadata: z.ZodOptional<z.ZodObject<{}, z.core.$loose>>;
1320
+ metadata: z.ZodOptional<z.ZodObject<{
1321
+ filePath: z.ZodOptional<z.ZodString>;
1322
+ startLine: z.ZodOptional<z.ZodNumber>;
1323
+ endLine: z.ZodOptional<z.ZodNumber>;
1324
+ severity: z.ZodOptional<z.ZodEnum<{
1325
+ high: "high";
1326
+ low: "low";
1327
+ medium: "medium";
1328
+ }>>;
1329
+ }, z.core.$loose>>;
1321
1330
  }, z.core.$strip>;
1322
1331
  export type AddCommentToolInput = Omit<z.infer<typeof AddCommentToolInputSchema>, "metadata"> & {
1323
1332
  metadata?: AddedCommentMetadata;
@@ -1669,7 +1678,16 @@ export declare const CodeGenToolMapSchema: z.ZodObject<{
1669
1678
  AddComment: z.ZodObject<{
1670
1679
  type: z.ZodString;
1671
1680
  content: z.ZodString;
1672
- metadata: z.ZodOptional<z.ZodObject<{}, z.core.$loose>>;
1681
+ metadata: z.ZodOptional<z.ZodObject<{
1682
+ filePath: z.ZodOptional<z.ZodString>;
1683
+ startLine: z.ZodOptional<z.ZodNumber>;
1684
+ endLine: z.ZodOptional<z.ZodNumber>;
1685
+ severity: z.ZodOptional<z.ZodEnum<{
1686
+ high: "high";
1687
+ low: "low";
1688
+ medium: "medium";
1689
+ }>>;
1690
+ }, z.core.$loose>>;
1673
1691
  }, z.core.$strip>;
1674
1692
  ProposeConfig: z.ZodObject<{
1675
1693
  config: z.ZodObject<{
@@ -4099,6 +4117,8 @@ export interface FusionConfig {
4099
4117
  checkCommand?: string;
4100
4118
  setupCommand?: string;
4101
4119
  validateCommand?: string;
4120
+ /** Production build command for hosting deploy pods (default: npm run build). */
4121
+ buildCommand?: string;
4102
4122
  fusionServerPort?: number;
4103
4123
  autoPush?: AutoPushMode;
4104
4124
  lockFile?: {
@@ -4584,6 +4604,22 @@ export interface ValidateCommandResultFailure {
4584
4604
  code: number | null;
4585
4605
  output: string;
4586
4606
  }
4607
+ export type BuildCommandState = ValidateCommandState;
4608
+ export type BuildCommandResult = BuildCommandResultSuccess | BuildCommandResultAborted | BuildCommandResultFailure;
4609
+ export interface BuildCommandResultSuccess {
4610
+ status: "success";
4611
+ command: string;
4612
+ }
4613
+ export interface BuildCommandResultAborted {
4614
+ status: "aborted";
4615
+ command: string | undefined;
4616
+ }
4617
+ export interface BuildCommandResultFailure {
4618
+ status: "failure";
4619
+ command: string;
4620
+ code?: number;
4621
+ output: string;
4622
+ }
4587
4623
  export interface ConfigureDevOrchestratorUpdates {
4588
4624
  devCommand: boolean;
4589
4625
  setupCommand: boolean;
package/src/codegen.js CHANGED
@@ -1362,9 +1362,30 @@ export const AddCommentToolInputSchema = z
1362
1362
  }),
1363
1363
  // `looseObject` (not `z.record`) so the JSON schema emits
1364
1364
  // `additionalProperties` rather than `propertyNames`, which OpenAI's strict
1365
- // tool-schema mode rejects.
1366
- metadata: z.looseObject({}).optional().meta({
1367
- description: "Type-specific fields. For 'code-review': filePath (string), startLine (number), endLine (number, optional), severity ('high' | 'medium' | 'low'), and originalSnippet when available",
1365
+ // tool-schema mode rejects. The location fields are declared explicitly
1366
+ // (rather than left to an open object) because typed fields get filled far
1367
+ // more consistently by the model. They are optional in the schema since
1368
+ // `metadata` is shared across comment types; for 'code-review', filePath and
1369
+ // startLine are enforced as required server-side (see AddComment tool).
1370
+ metadata: z
1371
+ .looseObject({
1372
+ filePath: z.string().min(1).optional().meta({
1373
+ description: "Project-relative file path the comment refers to. Required for 'code-review'.",
1374
+ }),
1375
+ startLine: z.number().int().positive().optional().meta({
1376
+ description: "1-indexed start line the comment refers to. Required for 'code-review'. Use the [L:N] markers from the annotated diff.",
1377
+ }),
1378
+ endLine: z.number().int().positive().optional().meta({
1379
+ description: "1-indexed end line; defaults to startLine when omitted.",
1380
+ }),
1381
+ severity: z
1382
+ .enum(["high", "medium", "low"])
1383
+ .optional()
1384
+ .meta({ description: "Finding severity for 'code-review'." }),
1385
+ })
1386
+ .optional()
1387
+ .meta({
1388
+ description: "Type-specific fields. For 'code-review': filePath and startLine are required; endLine and severity are optional. originalSnippet is populated automatically.",
1368
1389
  }),
1369
1390
  })
1370
1391
  .meta({ title: "AddCommentToolInput" });
package/src/events.d.ts CHANGED
@@ -1221,7 +1221,41 @@ export declare const ClientDevtoolsToolResultV1: {
1221
1221
  eventName: "client.devtools.tool.result";
1222
1222
  version: "1";
1223
1223
  };
1224
- export type FusionEvent = ClientDevtoolsSessionStartedEvent | ClientDevtoolsSessionIdleEventV1 | ClientDevtoolsToolCallRequestV1 | ClientDevtoolsToolCallV1 | ClientDevtoolsToolResultV1 | FusionProjectCreatedV1 | SetupAgentCompletedV1 | GitPrMergedV1 | GitPrCreatedV1 | GitPrClosedV1 | ForceSetupAgentV1 | ClawMessageSentV1 | CodegenCompletionV1 | CodegenUserPromptV1 | GitWebhooksRegisterV1 | FusionProjectSettingsUpdatedV1 | VideoRecordingCompletedV1 | TimelineRecordingReadyV1 | FusionBranchCreatedV1 | FusionContainerStartedV1 | FusionContainerFailedV1 | FusionBranchFailedV1 | BotMentionGitHubExternalPrV1 | BotMentionGitHubInternalPrV1 | BotMentionGitLabPrV1 | BotMentionBitbucketPrV1 | BotMentionAzurePrV1 | ReviewSubmittedV1 | PrReviewRequestedV1 | FigmaDecodeJobV1 | ProjectSnapshotRefreshV1 | ProjectSnapshotCapturedV1 | ProjectSnapshotCreatedV1 | ProjectSnapshotFailedV1 | ProjectSnapshotReadyCheckV1 | ProjectSnapshotPodWatchV1;
1224
+ export type ClientDevtoolsBuildCompletedV1 = FusionEventVariant<"client.devtools.build.completed", {
1225
+ deployId: string;
1226
+ projectId: string;
1227
+ }, {
1228
+ projectId: string;
1229
+ deployId: string;
1230
+ }, 1>;
1231
+ export declare const ClientDevtoolsBuildCompletedV1: {
1232
+ eventName: "client.devtools.build.completed";
1233
+ version: "1";
1234
+ };
1235
+ export type ClientDevtoolsBuildUploadedV1 = FusionEventVariant<"client.devtools.build.uploaded", {
1236
+ deployId: string;
1237
+ projectId: string;
1238
+ }, {
1239
+ projectId: string;
1240
+ deployId: string;
1241
+ }, 1>;
1242
+ export declare const ClientDevtoolsBuildUploadedV1: {
1243
+ eventName: "client.devtools.build.uploaded";
1244
+ version: "1";
1245
+ };
1246
+ export type ClientDevtoolsBuildFailedV1 = FusionEventVariant<"client.devtools.build.failed", {
1247
+ deployId: string;
1248
+ projectId: string;
1249
+ error: string;
1250
+ }, {
1251
+ projectId: string;
1252
+ deployId: string;
1253
+ }, 1>;
1254
+ export declare const ClientDevtoolsBuildFailedV1: {
1255
+ eventName: "client.devtools.build.failed";
1256
+ version: "1";
1257
+ };
1258
+ export type FusionEvent = ClientDevtoolsSessionStartedEvent | ClientDevtoolsSessionIdleEventV1 | ClientDevtoolsToolCallRequestV1 | ClientDevtoolsToolCallV1 | ClientDevtoolsToolResultV1 | ClientDevtoolsBuildCompletedV1 | ClientDevtoolsBuildUploadedV1 | ClientDevtoolsBuildFailedV1 | FusionProjectCreatedV1 | SetupAgentCompletedV1 | GitPrMergedV1 | GitPrCreatedV1 | GitPrClosedV1 | ForceSetupAgentV1 | ClawMessageSentV1 | CodegenCompletionV1 | CodegenUserPromptV1 | GitWebhooksRegisterV1 | FusionProjectSettingsUpdatedV1 | VideoRecordingCompletedV1 | TimelineRecordingReadyV1 | FusionBranchCreatedV1 | FusionContainerStartedV1 | FusionContainerFailedV1 | FusionBranchFailedV1 | BotMentionGitHubExternalPrV1 | BotMentionGitHubInternalPrV1 | BotMentionGitLabPrV1 | BotMentionBitbucketPrV1 | BotMentionAzurePrV1 | ReviewSubmittedV1 | PrReviewRequestedV1 | FigmaDecodeJobV1 | ProjectSnapshotRefreshV1 | ProjectSnapshotCapturedV1 | ProjectSnapshotCreatedV1 | ProjectSnapshotFailedV1 | ProjectSnapshotReadyCheckV1 | ProjectSnapshotPodWatchV1;
1225
1259
  export interface ModelPermissionRequiredEvent {
1226
1260
  type: "assistant.model.permission.required";
1227
1261
  data: {
package/src/events.js CHANGED
@@ -142,3 +142,15 @@ export const ClientDevtoolsToolResultV1 = {
142
142
  eventName: "client.devtools.tool.result",
143
143
  version: "1",
144
144
  };
145
+ export const ClientDevtoolsBuildCompletedV1 = {
146
+ eventName: "client.devtools.build.completed",
147
+ version: "1",
148
+ };
149
+ export const ClientDevtoolsBuildUploadedV1 = {
150
+ eventName: "client.devtools.build.uploaded",
151
+ version: "1",
152
+ };
153
+ export const ClientDevtoolsBuildFailedV1 = {
154
+ eventName: "client.devtools.build.failed",
155
+ version: "1",
156
+ };
package/src/projects.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import { z } from "zod";
2
+ import type { BuilderConfigHosting } from "./builder-config.js";
2
3
  import type { ConnectivityErrorCode, CheckType, LikelyCause } from "./connectivity/types.js";
3
4
  import { type EnvironmentVariable, type SetupDependency } from "./common-schemas";
4
5
  import type { FileOverride, LaunchServerState, LaunchServerStatus, BranchBackup, CommitMode, CustomInstruction, CustomAgentDefinition, GitSnapshot, AutoPushMode, GenerateUserMessage, CodeGenToolMap, GenerateCompletionStep, ReviewEffort } from "./codegen";
@@ -1294,8 +1295,11 @@ export declare const DeployStatusSchema: z.ZodEnum<{
1294
1295
  uploading: "uploading";
1295
1296
  }>;
1296
1297
  export type DeployStatus = z.infer<typeof DeployStatusSchema>;
1298
+ /** Deploy statuses that are terminal — never transitioned out of. */
1299
+ export declare const TERMINAL_DEPLOY_STATUSES: Set<"building" | "canceled" | "deploying" | "failed" | "live" | "queued" | "uploading">;
1297
1300
  export declare const ProjectHostingBuildConfigSchema: z.ZodObject<{
1298
1301
  buildCommand: z.ZodOptional<z.ZodString>;
1302
+ buildOutputDir: z.ZodOptional<z.ZodString>;
1299
1303
  nodeVersion: z.ZodOptional<z.ZodString>;
1300
1304
  }, z.core.$strip>;
1301
1305
  export type ProjectHostingBuildConfig = z.infer<typeof ProjectHostingBuildConfigSchema>;
@@ -1310,6 +1314,7 @@ export declare const ProjectHostingSchema: z.ZodObject<{
1310
1314
  url: z.ZodOptional<z.ZodString>;
1311
1315
  buildConfig: z.ZodOptional<z.ZodObject<{
1312
1316
  buildCommand: z.ZodOptional<z.ZodString>;
1317
+ buildOutputDir: z.ZodOptional<z.ZodString>;
1313
1318
  nodeVersion: z.ZodOptional<z.ZodString>;
1314
1319
  }, z.core.$strip>>;
1315
1320
  environment: z.ZodOptional<z.ZodObject<{
@@ -1353,6 +1358,7 @@ export declare const DeploySchema: z.ZodObject<{
1353
1358
  ownerId: z.ZodString;
1354
1359
  checkoutBranch: z.ZodOptional<z.ZodString>;
1355
1360
  deployBranchId: z.ZodOptional<z.ZodString>;
1361
+ deployBranchName: z.ZodOptional<z.ZodString>;
1356
1362
  devBranchId: z.ZodOptional<z.ZodString>;
1357
1363
  status: z.ZodEnum<{
1358
1364
  building: "building";
@@ -1445,4 +1451,142 @@ export declare const DeployArtifactManifestSchema: z.ZodObject<{
1445
1451
  functions: z.ZodRecord<z.ZodString, z.ZodString>;
1446
1452
  }, z.core.$strip>;
1447
1453
  export type DeployArtifactManifest = z.infer<typeof DeployArtifactManifestSchema>;
1454
+ /**
1455
+ * Per-deploy overrides passed from ai-services to the deploy pod's build-and-upload endpoint.
1456
+ */
1457
+ export declare const BuildConfigOverridesSchema: z.ZodObject<{
1458
+ buildCommand: z.ZodOptional<z.ZodString>;
1459
+ buildOutputDir: z.ZodOptional<z.ZodString>;
1460
+ nodeVersion: z.ZodOptional<z.ZodString>;
1461
+ environment: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
1462
+ }, z.core.$strip>;
1463
+ export type BuildConfigOverrides = z.infer<typeof BuildConfigOverridesSchema>;
1464
+ /** Map a repo `builder.config.json` hosting block to deploy-pod overrides (build scope only). */
1465
+ export declare function builderConfigHostingToBuildOverrides(hosting: BuilderConfigHosting | undefined): BuildConfigOverrides;
1466
+ /**
1467
+ * Merge repo file config with Firestore/UI overrides. Firestore wins on key conflicts.
1468
+ */
1469
+ export declare function mergeBuildConfigOverrides(fromFile: BuildConfigOverrides, fromFirestore: BuildConfigOverrides | undefined): BuildConfigOverrides;
1470
+ /** True when merged hosting build config includes at least one build setting. */
1471
+ export declare function hasResolvableHostingBuildConfig(overrides?: BuildConfigOverrides): boolean;
1472
+ /**
1473
+ * Request body for `POST /_builder.io/api/build-and-upload` on the deploy pod.
1474
+ */
1475
+ export declare const BuildAndUploadRequestSchema: z.ZodObject<{
1476
+ projectId: z.ZodString;
1477
+ deployId: z.ZodString;
1478
+ gcsManifestUploadUrl: z.ZodString;
1479
+ gcsArtifactUploadUrl: z.ZodString;
1480
+ buildConfigOverrides: z.ZodOptional<z.ZodObject<{
1481
+ buildCommand: z.ZodOptional<z.ZodString>;
1482
+ buildOutputDir: z.ZodOptional<z.ZodString>;
1483
+ nodeVersion: z.ZodOptional<z.ZodString>;
1484
+ environment: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
1485
+ }, z.core.$strip>>;
1486
+ }, z.core.$strip>;
1487
+ export type BuildAndUploadRequest = z.infer<typeof BuildAndUploadRequestSchema>;
1488
+ export declare const ReserveSlugRequestSchema: z.ZodObject<{
1489
+ projectId: z.ZodString;
1490
+ slug: z.ZodString;
1491
+ }, z.core.$strip>;
1492
+ export type ReserveSlugRequest = z.infer<typeof ReserveSlugRequestSchema>;
1493
+ export declare const ReserveSlugResponseSchema: z.ZodObject<{
1494
+ slug: z.ZodString;
1495
+ }, z.core.$strip>;
1496
+ export type ReserveSlugResponse = z.infer<typeof ReserveSlugResponseSchema>;
1497
+ export declare const DeployRequestSchema: z.ZodObject<{
1498
+ projectId: z.ZodString;
1499
+ checkoutBranch: z.ZodOptional<z.ZodString>;
1500
+ }, z.core.$strip>;
1501
+ export type DeployRequest = z.infer<typeof DeployRequestSchema>;
1502
+ export declare const DeployResponseSchema: z.ZodObject<{
1503
+ deployId: z.ZodString;
1504
+ status: z.ZodEnum<{
1505
+ building: "building";
1506
+ canceled: "canceled";
1507
+ deploying: "deploying";
1508
+ failed: "failed";
1509
+ live: "live";
1510
+ queued: "queued";
1511
+ uploading: "uploading";
1512
+ }>;
1513
+ }, z.core.$strip>;
1514
+ export type DeployResponse = z.infer<typeof DeployResponseSchema>;
1515
+ export declare const GetDeploysRequestSchema: z.ZodObject<{
1516
+ projectId: z.ZodString;
1517
+ deployId: z.ZodOptional<z.ZodString>;
1518
+ }, z.core.$strip>;
1519
+ export type GetDeploysRequest = z.infer<typeof GetDeploysRequestSchema>;
1520
+ export declare const GetDeploysResponseSchema: z.ZodObject<{
1521
+ deploys: z.ZodArray<z.ZodObject<{
1522
+ id: z.ZodString;
1523
+ status: z.ZodEnum<{
1524
+ building: "building";
1525
+ canceled: "canceled";
1526
+ deploying: "deploying";
1527
+ failed: "failed";
1528
+ live: "live";
1529
+ queued: "queued";
1530
+ uploading: "uploading";
1531
+ }>;
1532
+ url: z.ZodOptional<z.ZodString>;
1533
+ error: z.ZodOptional<z.ZodString>;
1534
+ createdAt: z.ZodNumber;
1535
+ completedAt: z.ZodOptional<z.ZodNumber>;
1536
+ }, z.core.$strip>>;
1537
+ }, z.core.$strip>;
1538
+ export type GetDeploysResponse = z.infer<typeof GetDeploysResponseSchema>;
1539
+ export declare const UpdateHostingRequestSchema: z.ZodObject<{
1540
+ projectId: z.ZodString;
1541
+ customDomain: z.ZodOptional<z.ZodString>;
1542
+ buildCommand: z.ZodOptional<z.ZodString>;
1543
+ autoDeploy: z.ZodOptional<z.ZodBoolean>;
1544
+ environment: z.ZodOptional<z.ZodObject<{
1545
+ build: z.ZodOptional<z.ZodArray<z.ZodObject<{
1546
+ key: z.ZodString;
1547
+ value: z.ZodString;
1548
+ isSecret: z.ZodBoolean;
1549
+ placeholder: z.ZodOptional<z.ZodBoolean>;
1550
+ explanation: z.ZodOptional<z.ZodString>;
1551
+ }, z.core.$strip>>>;
1552
+ prod: z.ZodOptional<z.ZodArray<z.ZodObject<{
1553
+ key: z.ZodString;
1554
+ value: z.ZodString;
1555
+ isSecret: z.ZodBoolean;
1556
+ placeholder: z.ZodOptional<z.ZodBoolean>;
1557
+ explanation: z.ZodOptional<z.ZodString>;
1558
+ }, z.core.$strip>>>;
1559
+ }, z.core.$strip>>;
1560
+ deleteEnvironmentVariableKeys: z.ZodOptional<z.ZodObject<{
1561
+ build: z.ZodOptional<z.ZodArray<z.ZodString>>;
1562
+ prod: z.ZodOptional<z.ZodArray<z.ZodString>>;
1563
+ }, z.core.$strip>>;
1564
+ }, z.core.$strip>;
1565
+ export type UpdateHostingRequest = z.infer<typeof UpdateHostingRequestSchema>;
1566
+ export declare const UpdateHostingResponseSchema: z.ZodObject<{
1567
+ slug: z.ZodOptional<z.ZodString>;
1568
+ customDomain: z.ZodOptional<z.ZodString>;
1569
+ buildConfig: z.ZodOptional<z.ZodObject<{
1570
+ buildCommand: z.ZodOptional<z.ZodString>;
1571
+ buildOutputDir: z.ZodOptional<z.ZodString>;
1572
+ nodeVersion: z.ZodOptional<z.ZodString>;
1573
+ }, z.core.$strip>>;
1574
+ environment: z.ZodOptional<z.ZodOptional<z.ZodObject<{
1575
+ build: z.ZodOptional<z.ZodArray<z.ZodObject<{
1576
+ key: z.ZodString;
1577
+ value: z.ZodString;
1578
+ isSecret: z.ZodBoolean;
1579
+ placeholder: z.ZodOptional<z.ZodBoolean>;
1580
+ explanation: z.ZodOptional<z.ZodString>;
1581
+ }, z.core.$strip>>>;
1582
+ prod: z.ZodOptional<z.ZodArray<z.ZodObject<{
1583
+ key: z.ZodString;
1584
+ value: z.ZodString;
1585
+ isSecret: z.ZodBoolean;
1586
+ placeholder: z.ZodOptional<z.ZodBoolean>;
1587
+ explanation: z.ZodOptional<z.ZodString>;
1588
+ }, z.core.$strip>>>;
1589
+ }, z.core.$strip>>>;
1590
+ }, z.core.$strip>;
1591
+ export type UpdateHostingResponse = z.infer<typeof UpdateHostingResponseSchema>;
1448
1592
  export {};
package/src/projects.js CHANGED
@@ -200,8 +200,15 @@ export const DeployStatusSchema = z.enum([
200
200
  "failed",
201
201
  "canceled",
202
202
  ]);
203
+ /** Deploy statuses that are terminal — never transitioned out of. */
204
+ export const TERMINAL_DEPLOY_STATUSES = new Set([
205
+ "live",
206
+ "failed",
207
+ "canceled",
208
+ ]);
203
209
  export const ProjectHostingBuildConfigSchema = z.object({
204
210
  buildCommand: z.string().optional(),
211
+ buildOutputDir: z.string().optional(),
205
212
  nodeVersion: z.string().optional(),
206
213
  });
207
214
  /**
@@ -271,6 +278,9 @@ export const DeploySchema = z.object({
271
278
  deployBranchId: z.string().optional().meta({
272
279
  description: 'Fusion branch id of the ephemeral hidden deploy branch (`type: "deploy"`) that ran the build.',
273
280
  }),
281
+ deployBranchName: z.string().optional().meta({
282
+ description: 'Fusion branch name of the ephemeral hidden deploy branch (`type: "deploy"`) that ran the build.',
283
+ }),
274
284
  devBranchId: z.string().optional().meta({
275
285
  description: "Fusion dev branch's id (unset if we are deploying project default branch)",
276
286
  }),
@@ -357,3 +367,153 @@ export const DeployArtifactManifestSchema = z.object({
357
367
  description: "serverless function name → sha256 hash",
358
368
  }),
359
369
  });
370
+ /**
371
+ * Per-deploy overrides passed from ai-services to the deploy pod's build-and-upload endpoint.
372
+ */
373
+ export const BuildConfigOverridesSchema = z.object({
374
+ buildCommand: z.string().optional(),
375
+ buildOutputDir: z.string().optional(),
376
+ nodeVersion: z.string().optional(),
377
+ /**
378
+ * Flat key-value map for the deploy pod. Firestore/API layers store
379
+ * `EnvironmentVariable[]`; convert at the boundary before building overrides.
380
+ */
381
+ environment: z.record(z.string(), z.string()).optional(),
382
+ });
383
+ function trimOptionalString(value) {
384
+ if (value === undefined) {
385
+ return undefined;
386
+ }
387
+ const trimmed = value.trim();
388
+ return trimmed || undefined;
389
+ }
390
+ /** Pick a string override: Firestore wins when the key is present (including ""). */
391
+ function pickBuildConfigString(firestore, file) {
392
+ if (firestore !== undefined) {
393
+ return trimOptionalString(firestore);
394
+ }
395
+ return trimOptionalString(file);
396
+ }
397
+ /** Map a repo `builder.config.json` hosting block to deploy-pod overrides (build scope only). */
398
+ export function builderConfigHostingToBuildOverrides(hosting) {
399
+ var _a;
400
+ if (!hosting) {
401
+ return {};
402
+ }
403
+ const buildEnv = (_a = hosting.environment) === null || _a === void 0 ? void 0 : _a.build;
404
+ const buildCommand = trimOptionalString(hosting.buildCommand);
405
+ const buildOutputDir = trimOptionalString(hosting.buildOutputDir);
406
+ const nodeVersion = trimOptionalString(hosting.nodeVersion);
407
+ return {
408
+ ...(buildCommand ? { buildCommand } : {}),
409
+ ...(buildOutputDir ? { buildOutputDir } : {}),
410
+ ...(nodeVersion ? { nodeVersion } : {}),
411
+ ...(buildEnv && Object.keys(buildEnv).length > 0
412
+ ? { environment: buildEnv }
413
+ : {}),
414
+ };
415
+ }
416
+ /**
417
+ * Merge repo file config with Firestore/UI overrides. Firestore wins on key conflicts.
418
+ */
419
+ export function mergeBuildConfigOverrides(fromFile, fromFirestore) {
420
+ const firestore = fromFirestore !== null && fromFirestore !== void 0 ? fromFirestore : {};
421
+ const merged = {};
422
+ const buildCommand = pickBuildConfigString(firestore.buildCommand, fromFile.buildCommand);
423
+ if (buildCommand) {
424
+ merged.buildCommand = buildCommand;
425
+ }
426
+ const buildOutputDir = pickBuildConfigString(firestore.buildOutputDir, fromFile.buildOutputDir);
427
+ if (buildOutputDir) {
428
+ merged.buildOutputDir = buildOutputDir;
429
+ }
430
+ const nodeVersion = pickBuildConfigString(firestore.nodeVersion, fromFile.nodeVersion);
431
+ if (nodeVersion) {
432
+ merged.nodeVersion = nodeVersion;
433
+ }
434
+ const fileEnv = fromFile.environment;
435
+ const firestoreEnv = firestore.environment;
436
+ if (fileEnv !== undefined || firestoreEnv !== undefined) {
437
+ const environment = { ...fileEnv, ...firestoreEnv };
438
+ if (Object.keys(environment).length > 0) {
439
+ merged.environment = environment;
440
+ }
441
+ }
442
+ return merged;
443
+ }
444
+ /** True when merged hosting build config includes at least one build setting. */
445
+ export function hasResolvableHostingBuildConfig(overrides) {
446
+ var _a, _b, _c;
447
+ if (!overrides) {
448
+ return false;
449
+ }
450
+ if ((_a = overrides.buildCommand) === null || _a === void 0 ? void 0 : _a.trim()) {
451
+ return true;
452
+ }
453
+ if ((_b = overrides.buildOutputDir) === null || _b === void 0 ? void 0 : _b.trim()) {
454
+ return true;
455
+ }
456
+ if ((_c = overrides.nodeVersion) === null || _c === void 0 ? void 0 : _c.trim()) {
457
+ return true;
458
+ }
459
+ if (overrides.environment && Object.keys(overrides.environment).length > 0) {
460
+ return true;
461
+ }
462
+ return false;
463
+ }
464
+ /**
465
+ * Request body for `POST /_builder.io/api/build-and-upload` on the deploy pod.
466
+ */
467
+ export const BuildAndUploadRequestSchema = z.object({
468
+ projectId: z.string(),
469
+ deployId: z.string(),
470
+ gcsManifestUploadUrl: z.string().url(),
471
+ gcsArtifactUploadUrl: z.string().url(),
472
+ buildConfigOverrides: BuildConfigOverridesSchema.optional(),
473
+ });
474
+ export const ReserveSlugRequestSchema = z.object({
475
+ projectId: z.string(),
476
+ slug: z.string(),
477
+ });
478
+ export const ReserveSlugResponseSchema = z.object({
479
+ slug: z.string(),
480
+ });
481
+ export const DeployRequestSchema = z.object({
482
+ projectId: z.string(),
483
+ checkoutBranch: z.string().optional(),
484
+ });
485
+ export const DeployResponseSchema = z.object({
486
+ deployId: z.string(),
487
+ status: DeployStatusSchema,
488
+ });
489
+ export const GetDeploysRequestSchema = z.object({
490
+ projectId: z.string(),
491
+ deployId: z.string().optional(),
492
+ });
493
+ export const GetDeploysResponseSchema = z.object({
494
+ deploys: z.array(DeployListItemSchema),
495
+ });
496
+ export const UpdateHostingRequestSchema = z.object({
497
+ projectId: z.string(),
498
+ customDomain: z.string().optional(),
499
+ buildCommand: z.string().optional(),
500
+ autoDeploy: z.boolean().optional(),
501
+ environment: z
502
+ .object({
503
+ build: z.array(EnvironmentVariableSchema).optional(),
504
+ prod: z.array(EnvironmentVariableSchema).optional(),
505
+ })
506
+ .optional(),
507
+ deleteEnvironmentVariableKeys: z
508
+ .object({
509
+ build: z.array(z.string()).optional(),
510
+ prod: z.array(z.string()).optional(),
511
+ })
512
+ .optional(),
513
+ });
514
+ export const UpdateHostingResponseSchema = z.object({
515
+ slug: z.string().optional(),
516
+ customDomain: z.string().optional(),
517
+ buildConfig: ProjectHostingBuildConfigSchema.optional(),
518
+ environment: ProjectHostingSchema.shape.environment.optional(),
519
+ });