@builder.io/ai-utils 0.84.0 → 0.85.0-dev.202607231533.14c8ab346

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.84.0",
3
+ "version": "0.85.0-dev.202607231533.14c8ab346",
4
4
  "description": "Builder.io AI utils",
5
5
  "files": [
6
6
  "src"
@@ -0,0 +1,88 @@
1
+ import { z } from "zod";
2
+ export declare const PermissionSchema: z.ZodEnum<{
3
+ list: "list";
4
+ read: "read";
5
+ write: "write";
6
+ }>;
7
+ export type Permission = z.infer<typeof PermissionSchema>;
8
+ export declare const AclEntrySchema: z.ZodObject<{
9
+ action: z.ZodEnum<{
10
+ allow: "allow";
11
+ deny: "deny";
12
+ }>;
13
+ resource: z.ZodString;
14
+ permissions: z.ZodArray<z.ZodEnum<{
15
+ list: "list";
16
+ read: "read";
17
+ write: "write";
18
+ }>>;
19
+ description: z.ZodOptional<z.ZodString>;
20
+ principals: z.ZodOptional<z.ZodArray<z.ZodString>>;
21
+ }, z.core.$strip>;
22
+ export type AclEntry = z.infer<typeof AclEntrySchema>;
23
+ export declare const AclPolicySchema: z.ZodObject<{
24
+ secrets: z.ZodOptional<z.ZodArray<z.ZodString>>;
25
+ entries: z.ZodOptional<z.ZodArray<z.ZodObject<{
26
+ action: z.ZodEnum<{
27
+ allow: "allow";
28
+ deny: "deny";
29
+ }>;
30
+ resource: z.ZodString;
31
+ permissions: z.ZodArray<z.ZodEnum<{
32
+ list: "list";
33
+ read: "read";
34
+ write: "write";
35
+ }>>;
36
+ description: z.ZodOptional<z.ZodString>;
37
+ principals: z.ZodOptional<z.ZodArray<z.ZodString>>;
38
+ }, z.core.$strip>>>;
39
+ denyDescription: z.ZodOptional<z.ZodString>;
40
+ }, z.core.$strip>;
41
+ export type AclPolicy = z.infer<typeof AclPolicySchema>;
42
+ export declare const AclDenialSchema: z.ZodObject<{
43
+ kind: z.ZodEnum<{
44
+ "command-allowlist": "command-allowlist";
45
+ "command-security": "command-security";
46
+ "file-access": "file-access";
47
+ }>;
48
+ reason: z.ZodEnum<{
49
+ "deny-pattern-matched": "deny-pattern-matched";
50
+ "no-allow-match": "no-allow-match";
51
+ "security-policy": "security-policy";
52
+ "shell-metacharacter": "shell-metacharacter";
53
+ }>;
54
+ resource: z.ZodString;
55
+ command: z.ZodOptional<z.ZodString>;
56
+ permission: z.ZodOptional<z.ZodEnum<{
57
+ list: "list";
58
+ read: "read";
59
+ write: "write";
60
+ }>>;
61
+ policy: z.ZodOptional<z.ZodString>;
62
+ matchedPattern: z.ZodOptional<z.ZodString>;
63
+ matchedEntry: z.ZodOptional<z.ZodObject<{
64
+ action: z.ZodEnum<{
65
+ allow: "allow";
66
+ deny: "deny";
67
+ }>;
68
+ resource: z.ZodString;
69
+ permissions: z.ZodArray<z.ZodEnum<{
70
+ list: "list";
71
+ read: "read";
72
+ write: "write";
73
+ }>>;
74
+ description: z.ZodOptional<z.ZodString>;
75
+ principals: z.ZodOptional<z.ZodArray<z.ZodString>>;
76
+ }, z.core.$strip>>;
77
+ message: z.ZodString;
78
+ }, z.core.$strip>;
79
+ export type AclDenial = z.infer<typeof AclDenialSchema>;
80
+ export interface AccessResult {
81
+ allowed: boolean;
82
+ message: string;
83
+ matchedEntry?: AclEntry;
84
+ matchedPattern?: string;
85
+ reason?: "deny-pattern-matched" | "no-allow-match";
86
+ requestedResource?: string;
87
+ requestedPermission?: Permission;
88
+ }
@@ -0,0 +1,71 @@
1
+ import { z } from "zod";
2
+ export const PermissionSchema = z
3
+ .enum(["read", "write", "list"])
4
+ .meta({ title: "Permission" });
5
+ // One ACL rule
6
+ export const AclEntrySchema = z
7
+ .object({
8
+ action: z
9
+ .enum(["allow", "deny"])
10
+ .meta({ description: "whether this rule allows or denies access" }),
11
+ resource: z
12
+ .string()
13
+ .meta({ description: "what — supports glob patterns like /files/*.txt" }),
14
+ permissions: z
15
+ .array(PermissionSchema)
16
+ .meta({ description: "actions this rule applies to" }),
17
+ description: z.string().optional().meta({
18
+ description: "custom message, in deny case, this is the error message. This will override denyDescription on AclPolicy if defined.",
19
+ }),
20
+ principals: z.array(z.string()).optional().meta({
21
+ description: "array of teams/roles this rule applies to (e.g., ['developer', 'admin'])",
22
+ }),
23
+ })
24
+ .meta({ title: "AclEntry" });
25
+ // A full ACL policy is just a list of rules
26
+ export const AclPolicySchema = z
27
+ .object({
28
+ secrets: z.array(z.string()).optional(),
29
+ entries: z.array(AclEntrySchema).optional(),
30
+ denyDescription: z.string().optional().meta({
31
+ description: "Default message to use when a resource is denied access",
32
+ }),
33
+ })
34
+ .meta({ title: "AclPolicy" });
35
+ // Structured description of an ACL/policy denial. Travels with the tool result
36
+ // so internal tools can show admins exactly which rule blocked a command/file,
37
+ // and both UIs can render a distinct "blocked, did not run" treatment.
38
+ export const AclDenialSchema = z
39
+ .object({
40
+ kind: z
41
+ .enum(["command-security", "command-allowlist", "file-access"])
42
+ .meta({ description: "which gate produced the denial" }),
43
+ reason: z
44
+ .enum([
45
+ "security-policy",
46
+ "deny-pattern-matched",
47
+ "no-allow-match",
48
+ "shell-metacharacter",
49
+ ])
50
+ .meta({ description: "why the denial happened" }),
51
+ resource: z.string().meta({
52
+ description: "the file path or command that was blocked",
53
+ }),
54
+ command: z.string().optional().meta({
55
+ description: "the full command, when the denial is command-related",
56
+ }),
57
+ permission: PermissionSchema.optional().meta({
58
+ description: "the requested permission, for file-access denials",
59
+ }),
60
+ policy: z.string().optional().meta({
61
+ description: "named security policy that matched, when applicable",
62
+ }),
63
+ matchedPattern: z.string().optional().meta({
64
+ description: "the glob/pattern that matched the resource or command",
65
+ }),
66
+ matchedEntry: AclEntrySchema.optional().meta({
67
+ description: "the full ACL entry that matched, for file-access denials",
68
+ }),
69
+ message: z.string().meta({ description: "human-readable explanation" }),
70
+ })
71
+ .meta({ title: "AclDenial" });
package/src/events.d.ts CHANGED
@@ -598,6 +598,8 @@ export type BotMentionGitHubInternalPrV1 = FusionEventVariant<"bot.mention.githu
598
598
  /** Numeric GitHub comment ID (for reaction / reply threading) */
599
599
  commentNumericId?: number;
600
600
  commentType: "issue" | "pr";
601
+ /** Whether the normal bot-mention pipeline should post successful agent text. */
602
+ postSuccessResultComment?: boolean;
601
603
  /** GitHub Enterprise hostname, if applicable */
602
604
  hostname?: string;
603
605
  /** For review comments: the comment being replied to */
@@ -1300,7 +1302,34 @@ export declare const McpPrototypePulledV1: {
1300
1302
  eventName: "mcp.prototype.pulled";
1301
1303
  version: "1";
1302
1304
  };
1303
- export type FusionEvent = ClientDevtoolsSessionStartedEvent | ClientDevtoolsSessionIdleEventV1 | ClientDevtoolsToolCallRequestV1 | ClientDevtoolsToolCallV1 | ClientDevtoolsToolResultV1 | ClientDevtoolsBuildMigratedV1 | 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 | McpPrototypePulledV1;
1305
+ export type HostingCustomDomainCertCheckV1 = FusionEventVariant<"hosting.custom-domain.cert-check", {
1306
+ domain: string;
1307
+ projectId: string;
1308
+ certId: string;
1309
+ attemptId: string;
1310
+ startedAtMs: number;
1311
+ timeoutMs: number;
1312
+ }, {
1313
+ projectId: string;
1314
+ }, 1>;
1315
+ export declare const HostingCustomDomainCertCheckV1: {
1316
+ eventName: "hosting.custom-domain.cert-check";
1317
+ version: "1";
1318
+ };
1319
+ export type HostingCustomDomainDelegationCheckV1 = FusionEventVariant<"hosting.custom-domain.delegation-check", {
1320
+ domain: string;
1321
+ projectId: string;
1322
+ attemptId: string;
1323
+ startedAtMs: number;
1324
+ timeoutMs: number;
1325
+ }, {
1326
+ projectId: string;
1327
+ }, 1>;
1328
+ export declare const HostingCustomDomainDelegationCheckV1: {
1329
+ eventName: "hosting.custom-domain.delegation-check";
1330
+ version: "1";
1331
+ };
1332
+ export type FusionEvent = ClientDevtoolsSessionStartedEvent | ClientDevtoolsSessionIdleEventV1 | ClientDevtoolsToolCallRequestV1 | ClientDevtoolsToolCallV1 | ClientDevtoolsToolResultV1 | ClientDevtoolsBuildMigratedV1 | 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 | McpPrototypePulledV1 | HostingCustomDomainCertCheckV1 | HostingCustomDomainDelegationCheckV1;
1304
1333
  export interface ModelPermissionRequiredEvent {
1305
1334
  type: "assistant.model.permission.required";
1306
1335
  data: {
package/src/events.js CHANGED
@@ -162,3 +162,11 @@ export const McpPrototypePulledV1 = {
162
162
  eventName: "mcp.prototype.pulled",
163
163
  version: "1",
164
164
  };
165
+ export const HostingCustomDomainCertCheckV1 = {
166
+ eventName: "hosting.custom-domain.cert-check",
167
+ version: "1",
168
+ };
169
+ export const HostingCustomDomainDelegationCheckV1 = {
170
+ eventName: "hosting.custom-domain.delegation-check",
171
+ version: "1",
172
+ };
package/src/projects.d.ts CHANGED
@@ -1490,9 +1490,16 @@ export declare const ProjectHostingSchema: z.ZodObject<{
1490
1490
  uploading: "uploading";
1491
1491
  }>>;
1492
1492
  publishedCommit: z.ZodOptional<z.ZodString>;
1493
- customDomain: z.ZodOptional<z.ZodString>;
1494
- customDomainVerified: z.ZodOptional<z.ZodBoolean>;
1495
1493
  autoDeploy: z.ZodOptional<z.ZodBoolean>;
1494
+ unpublishTrigger: z.ZodOptional<z.ZodEnum<{
1495
+ system: "system";
1496
+ user: "user";
1497
+ }>>;
1498
+ systemUnpublishReason: z.ZodOptional<z.ZodEnum<{
1499
+ "bandwidth-cap": "bandwidth-cap";
1500
+ "web-request-cap": "web-request-cap";
1501
+ }>>;
1502
+ domainIds: z.ZodOptional<z.ZodArray<z.ZodString>>;
1496
1503
  }, z.core.$strip>;
1497
1504
  export type ProjectHosting = z.infer<typeof ProjectHostingSchema>;
1498
1505
  /**
@@ -1550,6 +1557,36 @@ export declare const HostingSlugSchema: z.ZodObject<{
1550
1557
  createdBy: z.ZodString;
1551
1558
  }, z.core.$strip>;
1552
1559
  export type HostingSlug = z.infer<typeof HostingSlugSchema>;
1560
+ /**
1561
+ * Per-Neon-project charged-through watermarks inside a space's hosting usage
1562
+ * snapshot. Storage folds root + child branch bytes-month into one field.
1563
+ */
1564
+ export declare const HostingNeonProjectUsageSchema: z.ZodObject<{
1565
+ computeUnitSecondsChargedThrough: z.ZodNumber;
1566
+ storageBytesMonthChargedThrough: z.ZodNumber;
1567
+ transferBytesChargedThrough: z.ZodNumber;
1568
+ }, z.core.$strip>;
1569
+ export type HostingNeonProjectUsage = z.infer<typeof HostingNeonProjectUsageSchema>;
1570
+ /**
1571
+ * Reconciler idempotency watermark for a space's Netlify + Neon hosting costs,
1572
+ * stored at `hostingUsageSnapshots/{spaceId}`. Netlify is one account-level
1573
+ * scalar; Neon is a per-project map. `freeDeployCount` gates the free 5/mo
1574
+ * deploy cap (cost itself is inside Netlify's partner_account_usage total).
1575
+ */
1576
+ export declare const HostingUsageSnapshotSchema: z.ZodObject<{
1577
+ ownerId: z.ZodString;
1578
+ periodKey: z.ZodString;
1579
+ netlifyConsumptionCycleStart: z.ZodString;
1580
+ netlifyCreditsChargedThrough: z.ZodNumber;
1581
+ neonByProject: z.ZodRecord<z.ZodString, z.ZodObject<{
1582
+ computeUnitSecondsChargedThrough: z.ZodNumber;
1583
+ storageBytesMonthChargedThrough: z.ZodNumber;
1584
+ transferBytesChargedThrough: z.ZodNumber;
1585
+ }, z.core.$strip>>;
1586
+ freeDeployCount: z.ZodNumber;
1587
+ updatedAt: z.ZodNumber;
1588
+ }, z.core.$strip>;
1589
+ export type HostingUsageSnapshot = z.infer<typeof HostingUsageSnapshotSchema>;
1553
1590
  /**
1554
1591
  * Deploy lease lock with fencing token, stored at
1555
1592
  * `hosting-locks/{projectId}__{checkoutBranch}` (the key uses the resolved ref
@@ -1711,6 +1748,143 @@ export declare const GetDeploysResponseSchema: z.ZodObject<{
1711
1748
  }, z.core.$strip>>;
1712
1749
  }, z.core.$strip>;
1713
1750
  export type GetDeploysResponse = z.infer<typeof GetDeploysResponseSchema>;
1751
+ export declare const HostingDomainStatusSchema: z.ZodEnum<{
1752
+ active: "active";
1753
+ failed: "failed";
1754
+ pending: "pending";
1755
+ provisioning: "provisioning";
1756
+ verifying: "verifying";
1757
+ }>;
1758
+ export type HostingDomainStatus = z.infer<typeof HostingDomainStatusSchema>;
1759
+ export declare const HostingDomainKindSchema: z.ZodEnum<{
1760
+ apex: "apex";
1761
+ subdomain: "subdomain";
1762
+ }>;
1763
+ export type HostingDomainKind = z.infer<typeof HostingDomainKindSchema>;
1764
+ /**
1765
+ * Custom domain record. The same shape backs two Firestore collections:
1766
+ *
1767
+ * - Lock doc `hosting-domains/{domain}` is the single exclusive owner. It
1768
+ * exists only once a project reaches `provisioning`/`active` (cert + route
1769
+ * created, DNS ownership proven) and is the cross-project serialization
1770
+ * point serving/deploy/unpublish read to answer "is this verified?".
1771
+ * `certId`/`certMapEntryName`/`httpRouteName`/`verifiedAt` are only ever
1772
+ * populated here.
1773
+ * - Claim subdoc `hosting-domains/{domain}/claims/{projectId}` is a
1774
+ * non-exclusive, per-project verification attempt (`pending`/`verifying`/
1775
+ * `failed`). Multiple projects can hold a claim on the same domain at once;
1776
+ * whoever proves DNS ownership first wins the lock and the losers are swept
1777
+ * to `failed`.
1778
+ *
1779
+ * The normalized domain is the doc key — global uniqueness comes for free.
1780
+ */
1781
+ export declare const HostingDomainSchema: z.ZodObject<{
1782
+ domain: z.ZodString;
1783
+ kind: z.ZodEnum<{
1784
+ apex: "apex";
1785
+ subdomain: "subdomain";
1786
+ }>;
1787
+ projectId: z.ZodString;
1788
+ ownerId: z.ZodString;
1789
+ status: z.ZodEnum<{
1790
+ active: "active";
1791
+ failed: "failed";
1792
+ pending: "pending";
1793
+ provisioning: "provisioning";
1794
+ verifying: "verifying";
1795
+ }>;
1796
+ dnsAuthId: z.ZodString;
1797
+ delegationTarget: z.ZodString;
1798
+ trafficTarget: z.ZodOptional<z.ZodString>;
1799
+ certId: z.ZodOptional<z.ZodString>;
1800
+ certMapEntryName: z.ZodOptional<z.ZodString>;
1801
+ httpRouteName: z.ZodOptional<z.ZodString>;
1802
+ createdAt: z.ZodNumber;
1803
+ pendingSince: z.ZodNumber;
1804
+ verifyingSince: z.ZodOptional<z.ZodNumber>;
1805
+ attemptId: z.ZodOptional<z.ZodString>;
1806
+ verifiedAt: z.ZodOptional<z.ZodNumber>;
1807
+ error: z.ZodOptional<z.ZodString>;
1808
+ failedStep: z.ZodOptional<z.ZodEnum<{
1809
+ dns: "dns";
1810
+ https: "https";
1811
+ }>>;
1812
+ routeError: z.ZodOptional<z.ZodString>;
1813
+ routeErrorAt: z.ZodOptional<z.ZodNumber>;
1814
+ createdBy: z.ZodString;
1815
+ }, z.core.$strip>;
1816
+ export type HostingDomain = z.infer<typeof HostingDomainSchema>;
1817
+ export declare const AddDomainRequestSchema: z.ZodObject<{
1818
+ projectId: z.ZodString;
1819
+ domain: z.ZodString;
1820
+ }, z.core.$strip>;
1821
+ export type AddDomainRequest = z.infer<typeof AddDomainRequestSchema>;
1822
+ export declare const AddDomainResponseSchema: z.ZodObject<{
1823
+ domain: z.ZodString;
1824
+ kind: z.ZodEnum<{
1825
+ apex: "apex";
1826
+ subdomain: "subdomain";
1827
+ }>;
1828
+ records: z.ZodObject<{
1829
+ traffic: z.ZodObject<{
1830
+ recordType: z.ZodEnum<{
1831
+ A: "A";
1832
+ CNAME: "CNAME";
1833
+ }>;
1834
+ name: z.ZodString;
1835
+ value: z.ZodString;
1836
+ }, z.core.$strip>;
1837
+ validation: z.ZodObject<{
1838
+ recordType: z.ZodEnum<{
1839
+ A: "A";
1840
+ CNAME: "CNAME";
1841
+ }>;
1842
+ name: z.ZodString;
1843
+ value: z.ZodString;
1844
+ }, z.core.$strip>;
1845
+ }, z.core.$strip>;
1846
+ }, z.core.$strip>;
1847
+ export type AddDomainResponse = z.infer<typeof AddDomainResponseSchema>;
1848
+ export declare const VerifyDomainRequestSchema: z.ZodObject<{
1849
+ projectId: z.ZodString;
1850
+ domain: z.ZodString;
1851
+ }, z.core.$strip>;
1852
+ export type VerifyDomainRequest = z.infer<typeof VerifyDomainRequestSchema>;
1853
+ export declare const VerifyDomainResponseSchema: z.ZodObject<{
1854
+ status: z.ZodEnum<{
1855
+ active: "active";
1856
+ failed: "failed";
1857
+ pending: "pending";
1858
+ provisioning: "provisioning";
1859
+ verifying: "verifying";
1860
+ }>;
1861
+ }, z.core.$strip>;
1862
+ export type VerifyDomainResponse = z.infer<typeof VerifyDomainResponseSchema>;
1863
+ export declare const RemoveDomainRequestSchema: z.ZodObject<{
1864
+ projectId: z.ZodString;
1865
+ domain: z.ZodString;
1866
+ }, z.core.$strip>;
1867
+ export type RemoveDomainRequest = z.infer<typeof RemoveDomainRequestSchema>;
1868
+ export declare const RemoveDomainResponseSchema: z.ZodObject<{
1869
+ success: z.ZodLiteral<true>;
1870
+ }, z.core.$strip>;
1871
+ export type RemoveDomainResponse = z.infer<typeof RemoveDomainResponseSchema>;
1872
+ export declare const RepairDomainRequestSchema: z.ZodObject<{
1873
+ projectId: z.ZodString;
1874
+ domain: z.ZodString;
1875
+ }, z.core.$strip>;
1876
+ export type RepairDomainRequest = z.infer<typeof RepairDomainRequestSchema>;
1877
+ export declare const RepairDomainResponseSchema: z.ZodObject<{
1878
+ status: z.ZodEnum<{
1879
+ active: "active";
1880
+ failed: "failed";
1881
+ pending: "pending";
1882
+ provisioning: "provisioning";
1883
+ verifying: "verifying";
1884
+ }>;
1885
+ routeError: z.ZodOptional<z.ZodString>;
1886
+ }, z.core.$strip>;
1887
+ export type RepairDomainResponse = z.infer<typeof RepairDomainResponseSchema>;
1714
1888
  export declare const CloneProjectOptionsSchema: z.ZodObject<{
1715
1889
  sourceProjectId: z.ZodString;
1716
1890
  sourceBranchName: z.ZodDefault<z.ZodString>;
package/src/projects.js CHANGED
@@ -324,12 +324,33 @@ export const ProjectHostingSchema = z.object({
324
324
  lastDeployStatus: DeployStatusSchema.optional(),
325
325
  /** Git commit currently live at the project's hosting URL (set on go-live). */
326
326
  publishedCommit: z.string().optional(),
327
- customDomain: z.string().optional(),
328
- customDomainVerified: z.boolean().optional(),
329
327
  autoDeploy: z
330
328
  .boolean()
331
329
  .optional()
332
330
  .meta({ description: "auto-deploy on push/merge" }),
331
+ /**
332
+ * Who last drove the site into `publishStatus: "unpublished"`. Absent is
333
+ * treated as `"user"`. `"system"` means free-tier usage-cap enforcement took
334
+ * the site down (deleted the HTTPRoute, kept the Netlify site) and the
335
+ * reconciler **may** auto-restore it — routing-only, no rebuild — once the cap
336
+ * clears. `"user"` (or absent) means the user unpublished, so the reconciler
337
+ * must leave it down. The publish/unpublish hosting lock keeps this honest:
338
+ * whichever operation wins the lock is the one that writes `publishStatus`
339
+ * and this field, so they never disagree.
340
+ */
341
+ unpublishTrigger: z.enum(["system", "user"]).optional().meta({
342
+ description: "Who last unpublished the site. Absent === user. 'system' lets the reconciler auto-restore a usage-cap takedown; 'user' does not.",
343
+ }),
344
+ /**
345
+ * Why the system unpublished the site. Set iff `unpublishTrigger === "system"`;
346
+ * drives the projects-grid "suspended" card and takedown observability.
347
+ */
348
+ systemUnpublishReason: z
349
+ .enum(["bandwidth-cap", "web-request-cap"])
350
+ .optional(),
351
+ domainIds: z.array(z.string()).optional().meta({
352
+ description: "Doc keys (normalized domains) in `hosting-domains` attached to this project. The domain docs are the source of truth; this is only the back-pointer.",
353
+ }),
333
354
  });
334
355
  /**
335
356
  * Canonical "is this project hostable" predicate. Keys off the explicit
@@ -410,6 +431,42 @@ export const HostingSlugSchema = z.object({
410
431
  description: "user ID of the user who first clicked Publish on the project",
411
432
  }),
412
433
  });
434
+ /**
435
+ * Per-Neon-project charged-through watermarks inside a space's hosting usage
436
+ * snapshot. Storage folds root + child branch bytes-month into one field.
437
+ */
438
+ export const HostingNeonProjectUsageSchema = z.object({
439
+ computeUnitSecondsChargedThrough: z.number(),
440
+ storageBytesMonthChargedThrough: z.number().meta({
441
+ description: "root + child branch bytes-month already billed",
442
+ }),
443
+ transferBytesChargedThrough: z.number().meta({
444
+ description: "public network transfer bytes already billed",
445
+ }),
446
+ });
447
+ /**
448
+ * Reconciler idempotency watermark for a space's Netlify + Neon hosting costs,
449
+ * stored at `hostingUsageSnapshots/{spaceId}`. Netlify is one account-level
450
+ * scalar; Neon is a per-project map. `freeDeployCount` gates the free 5/mo
451
+ * deploy cap (cost itself is inside Netlify's partner_account_usage total).
452
+ */
453
+ export const HostingUsageSnapshotSchema = z.object({
454
+ ownerId: z.string(),
455
+ periodKey: z.string().meta({
456
+ description: "Builder billing cycle; resets the Neon watermarks",
457
+ }),
458
+ netlifyConsumptionCycleStart: z.string().meta({
459
+ description: "Netlify consumption_cycle_start_date; watermark resets when this advances",
460
+ }),
461
+ netlifyCreditsChargedThrough: z.number().meta({
462
+ description: "Netlify credits already billed this Netlify cycle",
463
+ }),
464
+ neonByProject: z.record(z.string(), HostingNeonProjectUsageSchema),
465
+ freeDeployCount: z.number().meta({
466
+ description: "Deploys this Builder cycle, for the free 5/mo cap",
467
+ }),
468
+ updatedAt: z.number(),
469
+ });
413
470
  /**
414
471
  * Deploy lease lock with fencing token, stored at
415
472
  * `hosting-locks/{projectId}__{checkoutBranch}` (the key uses the resolved ref
@@ -615,6 +672,116 @@ export const GetDeploysRequestSchema = z.object({
615
672
  export const GetDeploysResponseSchema = z.object({
616
673
  deploys: z.array(DeployListItemSchema),
617
674
  });
675
+ export const HostingDomainStatusSchema = z.enum([
676
+ "pending",
677
+ "verifying",
678
+ "provisioning",
679
+ "active",
680
+ "failed",
681
+ ]);
682
+ export const HostingDomainKindSchema = z.enum(["apex", "subdomain"]);
683
+ /**
684
+ * Custom domain record. The same shape backs two Firestore collections:
685
+ *
686
+ * - Lock doc `hosting-domains/{domain}` is the single exclusive owner. It
687
+ * exists only once a project reaches `provisioning`/`active` (cert + route
688
+ * created, DNS ownership proven) and is the cross-project serialization
689
+ * point serving/deploy/unpublish read to answer "is this verified?".
690
+ * `certId`/`certMapEntryName`/`httpRouteName`/`verifiedAt` are only ever
691
+ * populated here.
692
+ * - Claim subdoc `hosting-domains/{domain}/claims/{projectId}` is a
693
+ * non-exclusive, per-project verification attempt (`pending`/`verifying`/
694
+ * `failed`). Multiple projects can hold a claim on the same domain at once;
695
+ * whoever proves DNS ownership first wins the lock and the losers are swept
696
+ * to `failed`.
697
+ *
698
+ * The normalized domain is the doc key — global uniqueness comes for free.
699
+ */
700
+ export const HostingDomainSchema = z.object({
701
+ domain: z
702
+ .string()
703
+ .meta({ description: "Doc key — normalized (punycode) domain." }),
704
+ kind: HostingDomainKindSchema,
705
+ projectId: z.string(),
706
+ ownerId: z.string(),
707
+ status: HostingDomainStatusSchema,
708
+ dnsAuthId: z
709
+ .string()
710
+ .meta({ description: "GCP DNS authorization resource name." }),
711
+ delegationTarget: z.string().meta({
712
+ description: "_acme-challenge CNAME value the customer must add.",
713
+ }),
714
+ trafficTarget: z.string().optional().meta({
715
+ description: "The traffic record value: ALB anycast IP for apex domains, `cname.builder.cloud` for subdomains. Persisted so the UI can reconstruct both DNS records after page reload.",
716
+ }),
717
+ certId: z
718
+ .string()
719
+ .optional()
720
+ .meta({ description: "Certificate Manager cert resource name." }),
721
+ certMapEntryName: z.string().optional(),
722
+ httpRouteName: z.string().optional(),
723
+ createdAt: z.number(),
724
+ pendingSince: z.number().meta({
725
+ description: "TTL anchor: set on entering `pending`, re-stamped on `failed`→`pending`.",
726
+ }),
727
+ verifyingSince: z.number().optional().meta({
728
+ description: "Set when the delegation-check poll loop starts (on entering `verifying`). Used for the poll timeout and UI. Cleared on promotion to `provisioning` or on failure.",
729
+ }),
730
+ attemptId: z.string().optional().meta({
731
+ description: "Per-verify-attempt nonce, set on entering `verifying`. Delegation-check polls whose attemptId no longer matches are stale (a newer retry superseded them) and stop early.",
732
+ }),
733
+ verifiedAt: z.number().optional(),
734
+ error: z.string().optional(),
735
+ failedStep: z.enum(["dns", "https"]).optional().meta({
736
+ description: "Which setup step failed, set alongside `status: failed` so the UI can attribute the failure. `dns` = delegation verification, `https` = cert/route provisioning.",
737
+ }),
738
+ routeError: z.string().optional().meta({
739
+ description: "Non-fatal health signal on an otherwise verified (`provisioning`/`active`) domain: set when re-creating the Envoy HTTPRoute failed on republish, so the site's cert is valid but the custom domain has no live route (bare 404). `status` stays `active`; this drives a degraded banner + Fix action. Cleared once the route is recreated.",
740
+ }),
741
+ routeErrorAt: z.number().optional().meta({
742
+ description: "When `routeError` was last set.",
743
+ }),
744
+ createdBy: z.string(),
745
+ });
746
+ export const AddDomainRequestSchema = z.object({
747
+ projectId: z.string(),
748
+ domain: z.string(),
749
+ });
750
+ const DnsRecordSchema = z.object({
751
+ recordType: z.enum(["A", "CNAME"]),
752
+ name: z.string(),
753
+ value: z.string(),
754
+ });
755
+ export const AddDomainResponseSchema = z.object({
756
+ domain: z.string(),
757
+ kind: HostingDomainKindSchema,
758
+ records: z.object({
759
+ traffic: DnsRecordSchema,
760
+ validation: DnsRecordSchema,
761
+ }),
762
+ });
763
+ export const VerifyDomainRequestSchema = z.object({
764
+ projectId: z.string(),
765
+ domain: z.string(),
766
+ });
767
+ export const VerifyDomainResponseSchema = z.object({
768
+ status: HostingDomainStatusSchema,
769
+ });
770
+ export const RemoveDomainRequestSchema = z.object({
771
+ projectId: z.string(),
772
+ domain: z.string(),
773
+ });
774
+ export const RemoveDomainResponseSchema = z.object({
775
+ success: z.literal(true),
776
+ });
777
+ export const RepairDomainRequestSchema = z.object({
778
+ projectId: z.string(),
779
+ domain: z.string(),
780
+ });
781
+ export const RepairDomainResponseSchema = z.object({
782
+ status: HostingDomainStatusSchema,
783
+ routeError: z.string().optional(),
784
+ });
618
785
  export const CloneProjectOptionsSchema = z.object({
619
786
  sourceProjectId: z.string().min(1).meta({
620
787
  description: "Project to clone from.",
@@ -0,0 +1,49 @@
1
+ /** Fields common to all VPC connectivity types. */
2
+ interface VpcConnectionBase {
3
+ id: string;
4
+ ownerId: string;
5
+ type: string;
6
+ gcpRegion: string;
7
+ customerDnsServers: string[];
8
+ proxyIp: string;
9
+ enabled: boolean;
10
+ createdAt: number;
11
+ updatedAt: number;
12
+ }
13
+ /** Traditional VPC Peering via bridge VPC. */
14
+ export interface VpcGcpPeering extends VpcConnectionBase {
15
+ type: "gcp-peering";
16
+ gcpProjectId: string;
17
+ gcpNetworkName: string;
18
+ bridgeCidr: string;
19
+ importCustomRoutes: boolean;
20
+ }
21
+ /**
22
+ * PSC Network Attachment — customer creates the network attachment in their VPC,
23
+ * our proxy VM connects to it via a PSC interface on nic1.
24
+ * No bridge VPC or bridge CIDR needed on our side.
25
+ */
26
+ export interface VpcGcpNetworkAttachment extends VpcConnectionBase {
27
+ type: "gcp-network-attachment";
28
+ gcpProjectId: string;
29
+ networkAttachmentName: string;
30
+ }
31
+ /** Discriminated union of all VPC connectivity types. */
32
+ export type VpcPeering = VpcGcpPeering | VpcGcpNetworkAttachment;
33
+ export interface CreateVpcGcpPeeringParams {
34
+ type: "gcp-peering";
35
+ gcpRegion: string;
36
+ gcpProjectId: string;
37
+ gcpNetworkName: string;
38
+ bridgeCidr: string;
39
+ customerDnsServers: string[];
40
+ importCustomRoutes?: boolean;
41
+ }
42
+ export interface CreateVpcGcpNetworkAttachmentParams {
43
+ type: "gcp-network-attachment";
44
+ gcpProjectId: string;
45
+ networkAttachmentName: string;
46
+ customerDnsServers: string[];
47
+ }
48
+ export type CreateVpcPeeringParams = CreateVpcGcpPeeringParams | CreateVpcGcpNetworkAttachmentParams;
49
+ export {};
@@ -0,0 +1 @@
1
+ export {};