chore: bump version to 0.19.0-rc.3 and update JsonField handling for improved value parsing

This commit is contained in:
dswbx
2025-10-28 16:07:43 +01:00
parent b57f362e3a
commit be39e8a391
3 changed files with 10 additions and 7 deletions

View File

@@ -7,7 +7,7 @@ describe("[data] JsonField", async () => {
const field = new JsonField("test");
fieldTestSuite(bunTestRunner, JsonField, {
defaultValue: { a: 1 },
sampleValues: ["string", { test: 1 }, 1],
//sampleValues: ["string", { test: 1 }, 1],
schemaType: "text",
});
@@ -33,9 +33,9 @@ describe("[data] JsonField", async () => {
});
test("getValue", async () => {
expect(field.getValue({ test: 1 }, "form")).toBe('{\n "test": 1\n}');
expect(field.getValue("string", "form")).toBe('"string"');
expect(field.getValue(1, "form")).toBe("1");
expect(field.getValue({ test: 1 }, "form")).toEqual({ test: 1 });
expect(field.getValue("string", "form")).toBe("string");
expect(field.getValue(1, "form")).toBe(1);
expect(field.getValue('{"test":1}', "submit")).toEqual({ test: 1 });
expect(field.getValue('"string"', "submit")).toBe("string");
@@ -43,6 +43,5 @@ describe("[data] JsonField", async () => {
expect(field.getValue({ test: 1 }, "table")).toBe('{"test":1}');
expect(field.getValue("string", "table")).toBe('"string"');
expect(field.getValue(1, "form")).toBe("1");
});
});

View File

@@ -3,7 +3,7 @@
"type": "module",
"sideEffects": false,
"bin": "./dist/cli/index.js",
"version": "0.19.0-rc.2",
"version": "0.19.0-rc.3",
"description": "Lightweight Firebase/Supabase alternative built to run anywhere — incl. Next.js, React Router, Astro, Cloudflare, Bun, Node, AWS Lambda & more.",
"homepage": "https://bknd.io",
"repository": {

View File

@@ -80,7 +80,11 @@ export class JsonField<Required extends true | false = false, TypeOverride = obj
return value;
}
return JSON.parse(value);
try {
return JSON.parse(value);
} catch (e) {
return value;
}
}
return value;