@builder.io/ai-utils 0.87.0 → 0.87.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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@builder.io/ai-utils",
3
- "version": "0.87.0",
3
+ "version": "0.87.1",
4
4
  "description": "Builder.io AI utils",
5
5
  "files": [
6
6
  "src"
package/src/codegen.d.ts CHANGED
@@ -4122,6 +4122,12 @@ export interface BranchBackup {
4122
4122
  forced: ForcedBackup;
4123
4123
  commitInRepoVerified?: "verified" | "not-found" | "unverified";
4124
4124
  metadata?: Record<string, any>;
4125
+ /**
4126
+ * Paths of submodules / embedded git repos whose state the bundle cannot
4127
+ * reproduce. When non-empty the backup is restorable for the outer repo
4128
+ * but must not be treated as deletion-safe.
4129
+ */
4130
+ changedSubmodules?: string[];
4125
4131
  }
4126
4132
  export interface CheckBackupDataResultValid {
4127
4133
  state: "valid";
@@ -4141,15 +4147,26 @@ export interface CheckBackupDataResultStale {
4141
4147
  message: string;
4142
4148
  backup: BranchBackup;
4143
4149
  }
4150
+ /**
4151
+ * The backup is otherwise valid but includes submodule changes the bundle
4152
+ * cannot reproduce (see BranchBackup.changedSubmodules). It can still be
4153
+ * restored, but the volume must be retained.
4154
+ */
4155
+ export interface CheckBackupDataResultSubmoduleChanges {
4156
+ state: "submodule-changes";
4157
+ outcome: "submodule-changes";
4158
+ message: string;
4159
+ backup: BranchBackup;
4160
+ }
4144
4161
  export interface CheckBackupDataResultInvalid {
4145
4162
  state: "invalid";
4146
4163
  outcome: "no-backup" | "error" | "not-completed" | "no-session-id" | "no-last-commit-hash" | "no-backup-file" | "empty-full-backup" | "no-vcpCodeGenEvent" | "commits-not-in-repo" | "no-after-commit" | "no-signed-url" | "no-git-branch-name" | "repo-url-mismatch" | "branch-uninitialized" | "unexpected-partial-backup" | "unexpected-full-backup" | "no-backup-keys";
4147
4164
  message: string;
4148
4165
  backup: BranchBackup | undefined;
4149
4166
  }
4150
- export type CheckBackupDataResult = CheckBackupDataResultValid | CheckBackupDataResultForcedBackup | CheckBackupDataResultStale | CheckBackupDataResultInvalid;
4167
+ export type CheckBackupDataResult = CheckBackupDataResultValid | CheckBackupDataResultForcedBackup | CheckBackupDataResultStale | CheckBackupDataResultSubmoduleChanges | CheckBackupDataResultInvalid;
4151
4168
  export interface BackupMetadata {
4152
- check: CheckBackupDataResultValid | CheckBackupDataResultStale | CheckBackupDataResultForcedBackup;
4169
+ check: CheckBackupDataResultValid | CheckBackupDataResultStale | CheckBackupDataResultForcedBackup | CheckBackupDataResultSubmoduleChanges;
4153
4170
  downloadUrl: GitBackupDownloadUrlResult | undefined;
4154
4171
  downloadUrlError?: string;
4155
4172
  }
@@ -0,0 +1,5 @@
1
+ import type { Branch, FusionExecutionEnvironment } from "./projects.js";
2
+ /** Upgrade legacy `cloud` to `cloud-v2` when kube is enabled. */
3
+ export declare function upgradeCloudForKube(environment: FusionExecutionEnvironment, useKube: boolean): FusionExecutionEnvironment;
4
+ /** Work branch whose fusion environment a new sibling branch should inherit. */
5
+ export declare function pickReferenceWorkBranch(branches: Branch[]): Branch | undefined;
@@ -0,0 +1,16 @@
1
+ import { getBranchState } from "./projects.js";
2
+ /** Upgrade legacy `cloud` to `cloud-v2` when kube is enabled. */
3
+ export function upgradeCloudForKube(environment, useKube) {
4
+ return environment === "cloud" && useKube ? "cloud-v2" : environment;
5
+ }
6
+ /** Work branch whose fusion environment a new sibling branch should inherit. */
7
+ export function pickReferenceWorkBranch(branches) {
8
+ var _a, _b;
9
+ const activeWorkBranches = branches.filter((branch) => {
10
+ if (branch.type === "deploy" || branch.hidden) {
11
+ return false;
12
+ }
13
+ return getBranchState(branch) === "active";
14
+ });
15
+ return ((_b = (_a = activeWorkBranches.find((branch) => branch.name === "development")) !== null && _a !== void 0 ? _a : activeWorkBranches.find((branch) => branch.isDefault)) !== null && _b !== void 0 ? _b : activeWorkBranches[0]);
16
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,40 @@
1
+ import { describe, it, expect } from "vitest";
2
+ import { pickReferenceWorkBranch, upgradeCloudForKube, } from "./fusion-environment.js";
3
+ function branch(overrides) {
4
+ return {
5
+ id: `br-${overrides.name}`,
6
+ projectId: "project-1",
7
+ ownerId: "org-1",
8
+ isPublic: true,
9
+ ...overrides,
10
+ };
11
+ }
12
+ describe("upgradeCloudForKube", () => {
13
+ it("upgrades cloud when useKube is true", () => {
14
+ expect(upgradeCloudForKube("cloud", true)).toBe("cloud-v2");
15
+ });
16
+ it("leaves cloud-v2 unchanged", () => {
17
+ expect(upgradeCloudForKube("cloud-v2", false)).toBe("cloud-v2");
18
+ });
19
+ });
20
+ describe("pickReferenceWorkBranch", () => {
21
+ it("prefers development over other work branches", () => {
22
+ var _a;
23
+ expect((_a = pickReferenceWorkBranch([
24
+ branch({ name: "feature-a", lockedFusionEnvironment: "cloud" }),
25
+ branch({ name: "development", lockedFusionEnvironment: "cloud-v2" }),
26
+ ])) === null || _a === void 0 ? void 0 : _a.name).toBe("development");
27
+ });
28
+ it("ignores deploy and hidden branches", () => {
29
+ var _a;
30
+ expect((_a = pickReferenceWorkBranch([
31
+ branch({
32
+ name: "deploy-pod",
33
+ type: "deploy",
34
+ hidden: true,
35
+ lockedFusionEnvironment: "cloud",
36
+ }),
37
+ branch({ name: "development", lockedFusionEnvironment: "cloud-v2" }),
38
+ ])) === null || _a === void 0 ? void 0 : _a.name).toBe("development");
39
+ });
40
+ });
package/src/index.d.ts CHANGED
@@ -9,6 +9,7 @@ export * from "./codegen.js";
9
9
  export * from "./codegen/investigation-context.js";
10
10
  export * from "./diff-hunks.js";
11
11
  export * from "./projects.js";
12
+ export * from "./fusion-environment.js";
12
13
  export * from "./repo-indexing.js";
13
14
  export * from "./organization.js";
14
15
  export * from "./features.js";
package/src/index.js CHANGED
@@ -9,6 +9,7 @@ export * from "./codegen.js";
9
9
  export * from "./codegen/investigation-context.js";
10
10
  export * from "./diff-hunks.js";
11
11
  export * from "./projects.js";
12
+ export * from "./fusion-environment.js";
12
13
  export * from "./repo-indexing.js";
13
14
  export * from "./organization.js";
14
15
  export * from "./features.js";
package/src/projects.d.ts CHANGED
@@ -283,6 +283,14 @@ export interface GitBackupRecordOptions {
283
283
  forced: ForcedBackup;
284
284
  metadata?: Record<string, string | string[] | undefined>;
285
285
  folderName?: string;
286
+ /**
287
+ * Paths of submodules / embedded git repos whose state the bundle cannot
288
+ * reproduce: gitlinks changed within the backed-up range, or inner repos
289
+ * with commits/changes that exist only on the volume. When non-empty the
290
+ * backup is restorable for the outer repo but must not be treated as
291
+ * deletion-safe.
292
+ */
293
+ changedSubmodules?: string[];
286
294
  }
287
295
  export interface RecordScreenshotOptions {
288
296
  projectId: string;