Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@tinybirdco/sdk",
"version": "0.0.58",
"version": "0.0.59",
"description": "TypeScript SDK for Tinybird Forward - define datasources and pipes as TypeScript",
"type": "module",
"main": "./dist/index.js",
Expand Down
16 changes: 15 additions & 1 deletion src/schema/datasource.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
getColumnNames,
column,
} from "./datasource.js";
import { t } from "./types.js";
import { t, type AnyTypeValidator } from "./types.js";
import { engine } from "./engines.js";
import { defineKafkaConnection, defineS3Connection, defineGCSConnection } from "./connection.js";

Expand Down Expand Up @@ -259,6 +259,20 @@ describe("Datasource Schema", () => {
expect(result).toBeUndefined();
});

it("never returns a function when validator branding is missing", () => {
const validator = t.string();
// Simulate a validator-like object where isTypeValidator() fails by
// removing symbol keys (including the validator brand).
const unbrandedValidator = Object.fromEntries(
Object.entries(validator as unknown as Record<string, unknown>)
) as unknown as AnyTypeValidator;

const result = getColumnJsonPath(unbrandedValidator);

expect(result).toBeUndefined();
expect(typeof result).not.toBe("function");
});

it("returns jsonPath from validator modifier", () => {
const validator = t.string().jsonPath("$.user.id");
const result = getColumnJsonPath(validator);
Expand Down
4 changes: 3 additions & 1 deletion src/schema/datasource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,9 @@ export function getColumnJsonPath(column: AnyTypeValidator | ColumnDefinition):
return getModifiers(column).jsonPath;
}

if (column.jsonPath !== undefined) {
// Check typeof to avoid returning the jsonPath method from validators
// if isTypeValidator incorrectly returns false (e.g., cross-module Symbol issues)
if (typeof column.jsonPath === "string") {
return column.jsonPath;
}

Expand Down