@vellumai/credential-executor 0.12.8 → 0.12.10

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.
@@ -29,6 +29,7 @@
29
29
  "./platform-credential": "./src/platform-credential.ts",
30
30
  "./plan-credit": "./src/plan-credit.ts",
31
31
  "./integration-categories": "./src/integration-categories.ts",
32
+ "./migration-import": "./src/migration-import.ts",
32
33
  "./mcp-oauth": "./src/mcp-oauth.ts"
33
34
  },
34
35
  "scripts": {
@@ -0,0 +1,36 @@
1
+ import { describe, expect, test } from "bun:test";
2
+
3
+ import { parseImportFailure } from "../migration-import.js";
4
+
5
+ describe("parseImportFailure", () => {
6
+ test("parses a validation report", () => {
7
+ const failure = parseImportFailure(
8
+ JSON.stringify({
9
+ success: false,
10
+ reason: "validation_failed",
11
+ errors: [
12
+ {
13
+ code: "entry_hash",
14
+ message: "Checksum mismatch",
15
+ path: "workspace/a.md",
16
+ },
17
+ ],
18
+ }),
19
+ );
20
+ expect(failure).toEqual({
21
+ reason: "validation_failed",
22
+ errors: [{ message: "Checksum mismatch", path: "workspace/a.md" }],
23
+ });
24
+ });
25
+
26
+ test("parses a plain message body", () => {
27
+ expect(parseImportFailure('{"message":"disk full"}')).toEqual({
28
+ message: "disk full",
29
+ });
30
+ });
31
+
32
+ test("returns null for text that is not an import failure", () => {
33
+ expect(parseImportFailure("not json")).toBeNull();
34
+ expect(parseImportFailure('{"job_id":"abc"}')).toBeNull();
35
+ });
36
+ });
@@ -0,0 +1,31 @@
1
+ /**
2
+ * Failure body of a `.vbundle` import from the assistant's migration routes:
3
+ * a structured validation report (`reason` plus per-file `errors`) or a plain
4
+ * `message`. Clients that restore bundles parse it to tell the owner which
5
+ * file failed instead of printing raw JSON.
6
+ */
7
+
8
+ import { z } from "zod";
9
+
10
+ export const importFailureSchema = z.object({
11
+ reason: z.string().optional(),
12
+ message: z.string().optional(),
13
+ errors: z
14
+ .array(z.object({ message: z.string(), path: z.string().optional() }))
15
+ .optional(),
16
+ });
17
+
18
+ export type ImportFailure = z.infer<typeof importFailureSchema>;
19
+
20
+ /** Parse an import failure from JSON text, or null when the text is not one. */
21
+ export function parseImportFailure(text: string): ImportFailure | null {
22
+ try {
23
+ const parsed = importFailureSchema.safeParse(JSON.parse(text));
24
+ return parsed.success &&
25
+ (parsed.data.reason || parsed.data.message || parsed.data.errors)
26
+ ? parsed.data
27
+ : null;
28
+ } catch {
29
+ return null;
30
+ }
31
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vellumai/credential-executor",
3
- "version": "0.12.8",
3
+ "version": "0.12.10",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "exports": {