@tinybirdco/sdk 0.0.4 → 0.0.7
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/README.md +52 -13
- package/dist/api/branches.d.ts.map +1 -1
- package/dist/api/branches.js +6 -5
- package/dist/api/branches.js.map +1 -1
- package/dist/api/branches.test.js +32 -6
- package/dist/api/branches.test.js.map +1 -1
- package/dist/api/build.d.ts.map +1 -1
- package/dist/api/build.js +2 -1
- package/dist/api/build.js.map +1 -1
- package/dist/api/deploy.d.ts +42 -3
- package/dist/api/deploy.d.ts.map +1 -1
- package/dist/api/deploy.js +162 -19
- package/dist/api/deploy.js.map +1 -1
- package/dist/api/deploy.test.js +83 -31
- package/dist/api/deploy.test.js.map +1 -1
- package/dist/api/fetcher.d.ts +6 -0
- package/dist/api/fetcher.d.ts.map +1 -0
- package/dist/api/fetcher.js +13 -0
- package/dist/api/fetcher.js.map +1 -0
- package/dist/api/local.d.ts.map +1 -1
- package/dist/api/local.js +5 -4
- package/dist/api/local.js.map +1 -1
- package/dist/api/local.test.js.map +1 -1
- package/dist/api/resources.d.ts +178 -0
- package/dist/api/resources.d.ts.map +1 -0
- package/dist/api/resources.js +245 -0
- package/dist/api/resources.js.map +1 -0
- package/dist/api/resources.test.d.ts +2 -0
- package/dist/api/resources.test.d.ts.map +1 -0
- package/dist/api/resources.test.js +255 -0
- package/dist/api/resources.test.js.map +1 -0
- package/dist/api/workspaces.d.ts.map +1 -1
- package/dist/api/workspaces.js +2 -1
- package/dist/api/workspaces.js.map +1 -1
- package/dist/api/workspaces.test.js +9 -1
- package/dist/api/workspaces.test.js.map +1 -1
- package/dist/cli/auth.d.ts.map +1 -1
- package/dist/cli/auth.js +2 -1
- package/dist/cli/auth.js.map +1 -1
- package/dist/cli/commands/build.d.ts +3 -4
- package/dist/cli/commands/build.d.ts.map +1 -1
- package/dist/cli/commands/build.js +23 -25
- package/dist/cli/commands/build.js.map +1 -1
- package/dist/cli/commands/deploy.d.ts +41 -0
- package/dist/cli/commands/deploy.d.ts.map +1 -0
- package/dist/cli/commands/deploy.js +92 -0
- package/dist/cli/commands/deploy.js.map +1 -0
- package/dist/cli/commands/dev.d.ts.map +1 -1
- package/dist/cli/commands/dev.js +7 -3
- package/dist/cli/commands/dev.js.map +1 -1
- package/dist/cli/commands/init.d.ts +38 -1
- package/dist/cli/commands/init.d.ts.map +1 -1
- package/dist/cli/commands/init.js +434 -23
- package/dist/cli/commands/init.js.map +1 -1
- package/dist/cli/commands/init.test.js +190 -30
- package/dist/cli/commands/init.test.js.map +1 -1
- package/dist/cli/index.js +80 -15
- package/dist/cli/index.js.map +1 -1
- package/dist/cli/utils/package-manager.d.ts +8 -0
- package/dist/cli/utils/package-manager.d.ts.map +1 -0
- package/dist/cli/utils/package-manager.js +45 -0
- package/dist/cli/utils/package-manager.js.map +1 -0
- package/dist/cli/utils/package-manager.test.d.ts +2 -0
- package/dist/cli/utils/package-manager.test.d.ts.map +1 -0
- package/dist/cli/utils/package-manager.test.js +85 -0
- package/dist/cli/utils/package-manager.test.js.map +1 -0
- package/dist/client/base.d.ts.map +1 -1
- package/dist/client/base.js +2 -1
- package/dist/client/base.js.map +1 -1
- package/dist/codegen/index.d.ts +39 -0
- package/dist/codegen/index.d.ts.map +1 -0
- package/dist/codegen/index.js +300 -0
- package/dist/codegen/index.js.map +1 -0
- package/dist/codegen/index.test.d.ts +2 -0
- package/dist/codegen/index.test.d.ts.map +1 -0
- package/dist/codegen/index.test.js +310 -0
- package/dist/codegen/index.test.js.map +1 -0
- package/dist/codegen/type-mapper.d.ts +20 -0
- package/dist/codegen/type-mapper.d.ts.map +1 -0
- package/dist/codegen/type-mapper.js +238 -0
- package/dist/codegen/type-mapper.js.map +1 -0
- package/dist/codegen/type-mapper.test.d.ts +2 -0
- package/dist/codegen/type-mapper.test.d.ts.map +1 -0
- package/dist/codegen/type-mapper.test.js +167 -0
- package/dist/codegen/type-mapper.test.js.map +1 -0
- package/dist/codegen/utils.d.ts +46 -0
- package/dist/codegen/utils.d.ts.map +1 -0
- package/dist/codegen/utils.js +141 -0
- package/dist/codegen/utils.js.map +1 -0
- package/dist/codegen/utils.test.d.ts +2 -0
- package/dist/codegen/utils.test.d.ts.map +1 -0
- package/dist/codegen/utils.test.js +178 -0
- package/dist/codegen/utils.test.js.map +1 -0
- package/dist/generator/index.d.ts +3 -0
- package/dist/generator/index.d.ts.map +1 -1
- package/dist/generator/index.js +17 -1
- package/dist/generator/index.js.map +1 -1
- package/dist/generator/index.test.js +104 -1
- package/dist/generator/index.test.js.map +1 -1
- package/dist/generator/loader.d.ts +15 -0
- package/dist/generator/loader.d.ts.map +1 -1
- package/dist/generator/loader.js +24 -0
- package/dist/generator/loader.js.map +1 -1
- package/dist/schema/connection.d.ts.map +1 -1
- package/dist/schema/connection.js +3 -2
- package/dist/schema/connection.js.map +1 -1
- package/dist/schema/datasource.d.ts.map +1 -1
- package/dist/schema/datasource.js +3 -2
- package/dist/schema/datasource.js.map +1 -1
- package/dist/schema/params.d.ts.map +1 -1
- package/dist/schema/params.js +3 -2
- package/dist/schema/params.js.map +1 -1
- package/dist/schema/pipe.d.ts +2 -2
- package/dist/schema/pipe.d.ts.map +1 -1
- package/dist/schema/pipe.js +4 -4
- package/dist/schema/pipe.js.map +1 -1
- package/dist/schema/project.d.ts.map +1 -1
- package/dist/schema/project.js +3 -2
- package/dist/schema/project.js.map +1 -1
- package/dist/schema/types.d.ts.map +1 -1
- package/dist/schema/types.js +3 -2
- package/dist/schema/types.js.map +1 -1
- package/dist/test/handlers.d.ts +49 -0
- package/dist/test/handlers.d.ts.map +1 -1
- package/dist/test/handlers.js +45 -0
- package/dist/test/handlers.js.map +1 -1
- package/package.json +4 -2
- package/src/api/branches.test.ts +65 -57
- package/src/api/branches.ts +7 -5
- package/src/api/build.ts +2 -1
- package/src/api/deploy.test.ts +141 -36
- package/src/api/deploy.ts +231 -23
- package/src/api/fetcher.ts +17 -0
- package/src/api/local.test.ts +43 -31
- package/src/api/local.ts +5 -4
- package/src/api/resources.test.ts +332 -0
- package/src/api/resources.ts +555 -0
- package/src/api/workspaces.test.ts +15 -9
- package/src/api/workspaces.ts +3 -1
- package/src/cli/auth.ts +2 -1
- package/src/cli/commands/build.ts +29 -33
- package/src/cli/commands/deploy.ts +131 -0
- package/src/cli/commands/dev.ts +10 -3
- package/src/cli/commands/init.test.ts +239 -30
- package/src/cli/commands/init.ts +548 -26
- package/src/cli/index.ts +117 -20
- package/src/cli/utils/package-manager.test.ts +118 -0
- package/src/cli/utils/package-manager.ts +44 -0
- package/src/client/base.ts +3 -2
- package/src/codegen/index.test.ts +367 -0
- package/src/codegen/index.ts +379 -0
- package/src/codegen/type-mapper.test.ts +224 -0
- package/src/codegen/type-mapper.ts +265 -0
- package/src/codegen/utils.test.ts +221 -0
- package/src/codegen/utils.ts +174 -0
- package/src/generator/index.test.ts +121 -1
- package/src/generator/index.ts +19 -1
- package/src/generator/loader.ts +43 -0
- package/src/schema/connection.ts +3 -2
- package/src/schema/datasource.ts +3 -2
- package/src/schema/params.ts +3 -2
- package/src/schema/pipe.ts +4 -4
- package/src/schema/project.ts +3 -2
- package/src/schema/types.ts +3 -2
- package/src/test/handlers.ts +58 -0
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { describe, it, expect, beforeEach, afterEach } from "vitest";
|
|
2
|
-
import { generateResources, build } from "./index.js";
|
|
2
|
+
import { generateResources, build, buildFromInclude } from "./index.js";
|
|
3
3
|
import { defineProject } from "../schema/project.js";
|
|
4
4
|
import { defineDatasource } from "../schema/datasource.js";
|
|
5
5
|
import { definePipe, node } from "../schema/pipe.js";
|
|
@@ -206,4 +206,124 @@ export const notAProject = { foo: "bar" };
|
|
|
206
206
|
);
|
|
207
207
|
});
|
|
208
208
|
});
|
|
209
|
+
|
|
210
|
+
describe("buildFromInclude with raw datafiles", () => {
|
|
211
|
+
let tempDir: string;
|
|
212
|
+
|
|
213
|
+
beforeEach(() => {
|
|
214
|
+
tempDir = fs.mkdtempSync(path.join(os.tmpdir(), "tinybird-raw-test-"));
|
|
215
|
+
});
|
|
216
|
+
|
|
217
|
+
afterEach(() => {
|
|
218
|
+
try {
|
|
219
|
+
fs.rmSync(tempDir, { recursive: true });
|
|
220
|
+
} catch {
|
|
221
|
+
// Ignore cleanup errors
|
|
222
|
+
}
|
|
223
|
+
});
|
|
224
|
+
|
|
225
|
+
it("includes raw .datasource files directly", async () => {
|
|
226
|
+
// Create a raw datasource file
|
|
227
|
+
const datasourceContent = `SCHEMA >
|
|
228
|
+
timestamp DateTime,
|
|
229
|
+
user_id String
|
|
230
|
+
|
|
231
|
+
ENGINE "MergeTree"
|
|
232
|
+
ENGINE_SORTING_KEY "timestamp"
|
|
233
|
+
`;
|
|
234
|
+
const datasourcePath = path.join(tempDir, "events.datasource");
|
|
235
|
+
fs.writeFileSync(datasourcePath, datasourceContent);
|
|
236
|
+
|
|
237
|
+
const result = await buildFromInclude({
|
|
238
|
+
includePaths: [datasourcePath],
|
|
239
|
+
cwd: tempDir,
|
|
240
|
+
});
|
|
241
|
+
|
|
242
|
+
expect(result.resources.datasources).toHaveLength(1);
|
|
243
|
+
expect(result.resources.datasources[0].name).toBe("events");
|
|
244
|
+
expect(result.resources.datasources[0].content).toBe(datasourceContent);
|
|
245
|
+
expect(result.stats.datasourceCount).toBe(1);
|
|
246
|
+
});
|
|
247
|
+
|
|
248
|
+
it("includes raw .pipe files directly", async () => {
|
|
249
|
+
// Create a raw pipe file
|
|
250
|
+
const pipeContent = `NODE endpoint
|
|
251
|
+
SQL >
|
|
252
|
+
SELECT count() AS total FROM events
|
|
253
|
+
|
|
254
|
+
TYPE endpoint
|
|
255
|
+
`;
|
|
256
|
+
const pipePath = path.join(tempDir, "stats.pipe");
|
|
257
|
+
fs.writeFileSync(pipePath, pipeContent);
|
|
258
|
+
|
|
259
|
+
const result = await buildFromInclude({
|
|
260
|
+
includePaths: [pipePath],
|
|
261
|
+
cwd: tempDir,
|
|
262
|
+
});
|
|
263
|
+
|
|
264
|
+
expect(result.resources.pipes).toHaveLength(1);
|
|
265
|
+
expect(result.resources.pipes[0].name).toBe("stats");
|
|
266
|
+
expect(result.resources.pipes[0].content).toBe(pipeContent);
|
|
267
|
+
expect(result.stats.pipeCount).toBe(1);
|
|
268
|
+
});
|
|
269
|
+
|
|
270
|
+
it("includes multiple raw datasource and pipe files", async () => {
|
|
271
|
+
// Create multiple raw datasource files
|
|
272
|
+
const datasource1Content = `SCHEMA >
|
|
273
|
+
event_id String,
|
|
274
|
+
timestamp DateTime
|
|
275
|
+
|
|
276
|
+
ENGINE "MergeTree"
|
|
277
|
+
ENGINE_SORTING_KEY "timestamp"
|
|
278
|
+
`;
|
|
279
|
+
const datasource1Path = path.join(tempDir, "raw_events.datasource");
|
|
280
|
+
fs.writeFileSync(datasource1Path, datasource1Content);
|
|
281
|
+
|
|
282
|
+
const datasource2Content = `SCHEMA >
|
|
283
|
+
user_id String,
|
|
284
|
+
name String
|
|
285
|
+
|
|
286
|
+
ENGINE "MergeTree"
|
|
287
|
+
ENGINE_SORTING_KEY "user_id"
|
|
288
|
+
`;
|
|
289
|
+
const datasource2Path = path.join(tempDir, "users.datasource");
|
|
290
|
+
fs.writeFileSync(datasource2Path, datasource2Content);
|
|
291
|
+
|
|
292
|
+
// Create a raw pipe file
|
|
293
|
+
const rawPipeContent = `NODE main
|
|
294
|
+
SQL >
|
|
295
|
+
SELECT * FROM raw_events
|
|
296
|
+
|
|
297
|
+
TYPE endpoint
|
|
298
|
+
`;
|
|
299
|
+
const rawPipePath = path.join(tempDir, "raw_endpoint.pipe");
|
|
300
|
+
fs.writeFileSync(rawPipePath, rawPipeContent);
|
|
301
|
+
|
|
302
|
+
const result = await buildFromInclude({
|
|
303
|
+
includePaths: [datasource1Path, datasource2Path, rawPipePath],
|
|
304
|
+
cwd: tempDir,
|
|
305
|
+
});
|
|
306
|
+
|
|
307
|
+
// Should have 2 datasources (both from raw)
|
|
308
|
+
expect(result.resources.datasources).toHaveLength(2);
|
|
309
|
+
expect(result.stats.datasourceCount).toBe(2);
|
|
310
|
+
|
|
311
|
+
// Should have 1 pipe (from raw)
|
|
312
|
+
expect(result.resources.pipes).toHaveLength(1);
|
|
313
|
+
expect(result.stats.pipeCount).toBe(1);
|
|
314
|
+
|
|
315
|
+
// Check the raw files are included with correct content
|
|
316
|
+
const rawDs1 = result.resources.datasources.find(d => d.name === "raw_events");
|
|
317
|
+
expect(rawDs1).toBeDefined();
|
|
318
|
+
expect(rawDs1!.content).toBe(datasource1Content);
|
|
319
|
+
|
|
320
|
+
const rawDs2 = result.resources.datasources.find(d => d.name === "users");
|
|
321
|
+
expect(rawDs2).toBeDefined();
|
|
322
|
+
expect(rawDs2!.content).toBe(datasource2Content);
|
|
323
|
+
|
|
324
|
+
const rawPipe = result.resources.pipes.find(p => p.name === "raw_endpoint");
|
|
325
|
+
expect(rawPipe).toBeDefined();
|
|
326
|
+
expect(rawPipe!.content).toBe(rawPipeContent);
|
|
327
|
+
});
|
|
328
|
+
});
|
|
209
329
|
});
|
package/src/generator/index.ts
CHANGED
|
@@ -166,6 +166,9 @@ export function generateResourcesFromEntities(
|
|
|
166
166
|
* auto-discovered entities. It loads datasources and pipes from the
|
|
167
167
|
* include paths and generates Tinybird resources ready to deploy.
|
|
168
168
|
*
|
|
169
|
+
* Supports both TypeScript files (processed through esbuild) and raw
|
|
170
|
+
* .datasource/.pipe files (included directly).
|
|
171
|
+
*
|
|
169
172
|
* @param options - Build options with include paths
|
|
170
173
|
* @returns Build result with generated resources
|
|
171
174
|
*
|
|
@@ -193,9 +196,24 @@ export async function buildFromInclude(
|
|
|
193
196
|
// Convert to format for generators
|
|
194
197
|
const { datasources, pipes, connections } = entitiesToProject(entities);
|
|
195
198
|
|
|
196
|
-
// Generate resources
|
|
199
|
+
// Generate resources from TypeScript definitions
|
|
197
200
|
const resources = generateResourcesFromEntities(datasources, pipes, connections);
|
|
198
201
|
|
|
202
|
+
// Merge in raw datafiles (loaded directly without processing)
|
|
203
|
+
for (const raw of entities.rawDatasources) {
|
|
204
|
+
resources.datasources.push({
|
|
205
|
+
name: raw.name,
|
|
206
|
+
content: raw.content,
|
|
207
|
+
});
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
for (const raw of entities.rawPipes) {
|
|
211
|
+
resources.pipes.push({
|
|
212
|
+
name: raw.name,
|
|
213
|
+
content: raw.content,
|
|
214
|
+
});
|
|
215
|
+
}
|
|
216
|
+
|
|
199
217
|
return {
|
|
200
218
|
resources,
|
|
201
219
|
entities,
|
package/src/generator/loader.ts
CHANGED
|
@@ -150,6 +150,18 @@ export interface EntityInfo {
|
|
|
150
150
|
sourceFile: string;
|
|
151
151
|
}
|
|
152
152
|
|
|
153
|
+
/**
|
|
154
|
+
* Raw datafile loaded directly from disk
|
|
155
|
+
*/
|
|
156
|
+
export interface RawDatafile {
|
|
157
|
+
/** The file name (without extension) */
|
|
158
|
+
name: string;
|
|
159
|
+
/** The raw content of the file */
|
|
160
|
+
content: string;
|
|
161
|
+
/** The source file path (relative to cwd) */
|
|
162
|
+
sourceFile: string;
|
|
163
|
+
}
|
|
164
|
+
|
|
153
165
|
/**
|
|
154
166
|
* Result of loading entities from multiple files
|
|
155
167
|
*/
|
|
@@ -160,6 +172,10 @@ export interface LoadedEntities {
|
|
|
160
172
|
pipes: Record<string, { definition: PipeDefinition; info: EntityInfo }>;
|
|
161
173
|
/** Discovered connections with their metadata */
|
|
162
174
|
connections: Record<string, { definition: ConnectionDefinition; info: EntityInfo }>;
|
|
175
|
+
/** Raw .datasource files loaded directly */
|
|
176
|
+
rawDatasources: RawDatafile[];
|
|
177
|
+
/** Raw .pipe files loaded directly */
|
|
178
|
+
rawPipes: RawDatafile[];
|
|
163
179
|
/** All source files that were scanned */
|
|
164
180
|
sourceFiles: string[];
|
|
165
181
|
}
|
|
@@ -199,6 +215,8 @@ export async function loadEntities(options: LoadEntitiesOptions): Promise<Loaded
|
|
|
199
215
|
datasources: {},
|
|
200
216
|
pipes: {},
|
|
201
217
|
connections: {},
|
|
218
|
+
rawDatasources: [],
|
|
219
|
+
rawPipes: [],
|
|
202
220
|
sourceFiles: [],
|
|
203
221
|
};
|
|
204
222
|
|
|
@@ -213,6 +231,31 @@ export async function loadEntities(options: LoadEntitiesOptions): Promise<Loaded
|
|
|
213
231
|
}
|
|
214
232
|
|
|
215
233
|
result.sourceFiles.push(includePath);
|
|
234
|
+
|
|
235
|
+
// Check if this is a raw datafile (.datasource or .pipe)
|
|
236
|
+
if (includePath.endsWith(".datasource")) {
|
|
237
|
+
const content = fs.readFileSync(absolutePath, "utf-8");
|
|
238
|
+
const name = path.basename(includePath, ".datasource");
|
|
239
|
+
result.rawDatasources.push({
|
|
240
|
+
name,
|
|
241
|
+
content,
|
|
242
|
+
sourceFile: includePath,
|
|
243
|
+
});
|
|
244
|
+
continue;
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
if (includePath.endsWith(".pipe")) {
|
|
248
|
+
const content = fs.readFileSync(absolutePath, "utf-8");
|
|
249
|
+
const name = path.basename(includePath, ".pipe");
|
|
250
|
+
result.rawPipes.push({
|
|
251
|
+
name,
|
|
252
|
+
content,
|
|
253
|
+
sourceFile: includePath,
|
|
254
|
+
});
|
|
255
|
+
continue;
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
// TypeScript file - process through esbuild
|
|
216
259
|
const fileDir = path.dirname(absolutePath);
|
|
217
260
|
|
|
218
261
|
// Create a temporary output file for the bundle
|
package/src/schema/connection.ts
CHANGED
|
@@ -3,8 +3,9 @@
|
|
|
3
3
|
* Define external connections (Kafka, etc.) as TypeScript with full type safety
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
// Symbol for brand typing
|
|
7
|
-
|
|
6
|
+
// Symbol for brand typing - use Symbol.for() for global registry
|
|
7
|
+
// This ensures the same symbol is used across module instances
|
|
8
|
+
const CONNECTION_BRAND = Symbol.for("tinybird.connection");
|
|
8
9
|
|
|
9
10
|
/**
|
|
10
11
|
* Kafka security protocol options
|
package/src/schema/datasource.ts
CHANGED
|
@@ -7,8 +7,9 @@ import type { AnyTypeValidator } from "./types.js";
|
|
|
7
7
|
import type { EngineConfig } from "./engines.js";
|
|
8
8
|
import type { KafkaConnectionDefinition } from "./connection.js";
|
|
9
9
|
|
|
10
|
-
// Symbol for brand typing
|
|
11
|
-
|
|
10
|
+
// Symbol for brand typing - use Symbol.for() for global registry
|
|
11
|
+
// This ensures the same symbol is used across module instances
|
|
12
|
+
const DATASOURCE_BRAND = Symbol.for("tinybird.datasource");
|
|
12
13
|
|
|
13
14
|
/**
|
|
14
15
|
* A column can be defined as just a type validator,
|
package/src/schema/params.ts
CHANGED
|
@@ -3,8 +3,9 @@
|
|
|
3
3
|
* Similar to the column type validators but for query parameters
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
// Symbol for brand typing
|
|
7
|
-
|
|
6
|
+
// Symbol for brand typing - use Symbol.for() for global registry
|
|
7
|
+
// This ensures the same symbol is used across module instances
|
|
8
|
+
const PARAM_BRAND = Symbol.for("tinybird.param");
|
|
8
9
|
|
|
9
10
|
/**
|
|
10
11
|
* Base interface for parameter validators
|
package/src/schema/pipe.ts
CHANGED
|
@@ -9,10 +9,10 @@ import type { DatasourceDefinition, SchemaDefinition, ColumnDefinition } from ".
|
|
|
9
9
|
import { getColumnType } from "./datasource.js";
|
|
10
10
|
import { getTinybirdType } from "./types.js";
|
|
11
11
|
|
|
12
|
-
/** Symbol for brand typing pipes */
|
|
13
|
-
export const PIPE_BRAND
|
|
14
|
-
/** Symbol for brand typing nodes */
|
|
15
|
-
export const NODE_BRAND
|
|
12
|
+
/** Symbol for brand typing pipes - use Symbol.for() for global registry */
|
|
13
|
+
export const PIPE_BRAND = Symbol.for("tinybird.pipe");
|
|
14
|
+
/** Symbol for brand typing nodes - use Symbol.for() for global registry */
|
|
15
|
+
export const NODE_BRAND = Symbol.for("tinybird.node");
|
|
16
16
|
|
|
17
17
|
/**
|
|
18
18
|
* Parameter definition for a pipe
|
package/src/schema/project.ts
CHANGED
|
@@ -11,8 +11,9 @@ import type { TinybirdClient } from "../client/base.js";
|
|
|
11
11
|
import type { QueryResult } from "../client/types.js";
|
|
12
12
|
import type { InferRow, InferParams, InferOutputRow } from "../infer/index.js";
|
|
13
13
|
|
|
14
|
-
// Symbol for brand typing
|
|
15
|
-
|
|
14
|
+
// Symbol for brand typing - use Symbol.for() for global registry
|
|
15
|
+
// This ensures the same symbol is used across module instances
|
|
16
|
+
const PROJECT_BRAND = Symbol.for("tinybird.project");
|
|
16
17
|
|
|
17
18
|
/**
|
|
18
19
|
* Collection of datasource definitions
|
package/src/schema/types.ts
CHANGED
|
@@ -3,8 +3,9 @@
|
|
|
3
3
|
* Similar to Convex's `v.*` pattern, but for ClickHouse types
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
// Symbol for brand typing
|
|
7
|
-
|
|
6
|
+
// Symbol for brand typing - use Symbol.for() for global registry
|
|
7
|
+
// This ensures the same symbol is used across module instances
|
|
8
|
+
const VALIDATOR_BRAND = Symbol.for("tinybird.validator");
|
|
8
9
|
|
|
9
10
|
/**
|
|
10
11
|
* Base interface for all type validators
|
package/src/test/handlers.ts
CHANGED
|
@@ -63,6 +63,59 @@ export function createNoChangesResponse() {
|
|
|
63
63
|
};
|
|
64
64
|
}
|
|
65
65
|
|
|
66
|
+
/**
|
|
67
|
+
* Create deploy success response (for /v1/deploy endpoint)
|
|
68
|
+
* This returns a deployment object, not a build object
|
|
69
|
+
*/
|
|
70
|
+
export function createDeploySuccessResponse(options?: {
|
|
71
|
+
deploymentId?: string;
|
|
72
|
+
status?: string;
|
|
73
|
+
}) {
|
|
74
|
+
return {
|
|
75
|
+
result: "success",
|
|
76
|
+
deployment: {
|
|
77
|
+
id: options?.deploymentId ?? "deploy-123",
|
|
78
|
+
status: options?.status ?? "pending",
|
|
79
|
+
},
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* Create deployment status response (for /v1/deployments/:id endpoint)
|
|
85
|
+
*/
|
|
86
|
+
export function createDeploymentStatusResponse(options?: {
|
|
87
|
+
deploymentId?: string;
|
|
88
|
+
status?: string;
|
|
89
|
+
}) {
|
|
90
|
+
return {
|
|
91
|
+
result: "success",
|
|
92
|
+
deployment: {
|
|
93
|
+
id: options?.deploymentId ?? "deploy-123",
|
|
94
|
+
status: options?.status ?? "data_ready",
|
|
95
|
+
},
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* Create set-live success response (for /v1/deployments/:id/set-live endpoint)
|
|
101
|
+
*/
|
|
102
|
+
export function createSetLiveSuccessResponse() {
|
|
103
|
+
return {
|
|
104
|
+
result: "success",
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* Create deployments list response (for /v1/deployments endpoint)
|
|
110
|
+
*/
|
|
111
|
+
export function createDeploymentsListResponse(options?: {
|
|
112
|
+
deployments?: Array<{ id: string; status: string; live: boolean }>;
|
|
113
|
+
}) {
|
|
114
|
+
return {
|
|
115
|
+
deployments: options?.deployments ?? [],
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
|
|
66
119
|
/**
|
|
67
120
|
* Default handlers for build and deploy endpoints
|
|
68
121
|
*/
|
|
@@ -76,4 +129,9 @@ export const handlers = [
|
|
|
76
129
|
http.post(`${BASE_URL}/v1/deploy`, () => {
|
|
77
130
|
return HttpResponse.json(createBuildSuccessResponse());
|
|
78
131
|
}),
|
|
132
|
+
|
|
133
|
+
// Deployments list endpoint - empty list by default (no stale deployments)
|
|
134
|
+
http.get(`${BASE_URL}/v1/deployments`, () => {
|
|
135
|
+
return HttpResponse.json(createDeploymentsListResponse());
|
|
136
|
+
}),
|
|
79
137
|
];
|