@tinybirdco/sdk 0.0.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/README.md +518 -0
- package/bin/tinybird.js +7 -0
- package/dist/api/branches.d.ts +98 -0
- package/dist/api/branches.d.ts.map +1 -0
- package/dist/api/branches.js +203 -0
- package/dist/api/branches.js.map +1 -0
- package/dist/api/branches.test.d.ts +2 -0
- package/dist/api/branches.test.d.ts.map +1 -0
- package/dist/api/branches.test.js +286 -0
- package/dist/api/branches.test.js.map +1 -0
- package/dist/api/build.d.ts +130 -0
- package/dist/api/build.d.ts.map +1 -0
- package/dist/api/build.js +143 -0
- package/dist/api/build.js.map +1 -0
- package/dist/api/build.test.d.ts +2 -0
- package/dist/api/build.test.d.ts.map +1 -0
- package/dist/api/build.test.js +138 -0
- package/dist/api/build.test.js.map +1 -0
- package/dist/api/deploy.d.ts +39 -0
- package/dist/api/deploy.d.ts.map +1 -0
- package/dist/api/deploy.js +135 -0
- package/dist/api/deploy.js.map +1 -0
- package/dist/api/deploy.test.d.ts +2 -0
- package/dist/api/deploy.test.d.ts.map +1 -0
- package/dist/api/deploy.test.js +118 -0
- package/dist/api/deploy.test.js.map +1 -0
- package/dist/api/workspaces.d.ts +46 -0
- package/dist/api/workspaces.d.ts.map +1 -0
- package/dist/api/workspaces.js +39 -0
- package/dist/api/workspaces.js.map +1 -0
- package/dist/api/workspaces.test.d.ts +2 -0
- package/dist/api/workspaces.test.d.ts.map +1 -0
- package/dist/api/workspaces.test.js +65 -0
- package/dist/api/workspaces.test.js.map +1 -0
- package/dist/cli/auth.d.ts +86 -0
- package/dist/cli/auth.d.ts.map +1 -0
- package/dist/cli/auth.js +284 -0
- package/dist/cli/auth.js.map +1 -0
- package/dist/cli/branch-store.d.ts +53 -0
- package/dist/cli/branch-store.d.ts.map +1 -0
- package/dist/cli/branch-store.js +91 -0
- package/dist/cli/branch-store.js.map +1 -0
- package/dist/cli/branch-store.test.d.ts +2 -0
- package/dist/cli/branch-store.test.d.ts.map +1 -0
- package/dist/cli/branch-store.test.js +115 -0
- package/dist/cli/branch-store.test.js.map +1 -0
- package/dist/cli/commands/branch.d.ts +82 -0
- package/dist/cli/commands/branch.d.ts.map +1 -0
- package/dist/cli/commands/branch.js +215 -0
- package/dist/cli/commands/branch.js.map +1 -0
- package/dist/cli/commands/build.d.ts +43 -0
- package/dist/cli/commands/build.d.ts.map +1 -0
- package/dist/cli/commands/build.js +138 -0
- package/dist/cli/commands/build.js.map +1 -0
- package/dist/cli/commands/dev.d.ts +78 -0
- package/dist/cli/commands/dev.d.ts.map +1 -0
- package/dist/cli/commands/dev.js +226 -0
- package/dist/cli/commands/dev.js.map +1 -0
- package/dist/cli/commands/init.d.ts +45 -0
- package/dist/cli/commands/init.d.ts.map +1 -0
- package/dist/cli/commands/init.js +277 -0
- package/dist/cli/commands/init.js.map +1 -0
- package/dist/cli/commands/init.test.d.ts +2 -0
- package/dist/cli/commands/init.test.d.ts.map +1 -0
- package/dist/cli/commands/init.test.js +158 -0
- package/dist/cli/commands/init.test.js.map +1 -0
- package/dist/cli/commands/login.d.ts +37 -0
- package/dist/cli/commands/login.d.ts.map +1 -0
- package/dist/cli/commands/login.js +64 -0
- package/dist/cli/commands/login.js.map +1 -0
- package/dist/cli/config.d.ts +114 -0
- package/dist/cli/config.d.ts.map +1 -0
- package/dist/cli/config.js +258 -0
- package/dist/cli/config.js.map +1 -0
- package/dist/cli/config.test.d.ts +2 -0
- package/dist/cli/config.test.d.ts.map +1 -0
- package/dist/cli/config.test.js +243 -0
- package/dist/cli/config.test.js.map +1 -0
- package/dist/cli/env.d.ts +29 -0
- package/dist/cli/env.d.ts.map +1 -0
- package/dist/cli/env.js +66 -0
- package/dist/cli/env.js.map +1 -0
- package/dist/cli/git.d.ts +29 -0
- package/dist/cli/git.d.ts.map +1 -0
- package/dist/cli/git.js +114 -0
- package/dist/cli/git.js.map +1 -0
- package/dist/cli/git.test.d.ts +2 -0
- package/dist/cli/git.test.d.ts.map +1 -0
- package/dist/cli/git.test.js +125 -0
- package/dist/cli/git.test.js.map +1 -0
- package/dist/cli/index.d.ts +7 -0
- package/dist/cli/index.d.ts.map +1 -0
- package/dist/cli/index.js +337 -0
- package/dist/cli/index.js.map +1 -0
- package/dist/cli/utils/schema-validation.d.ts +95 -0
- package/dist/cli/utils/schema-validation.d.ts.map +1 -0
- package/dist/cli/utils/schema-validation.js +175 -0
- package/dist/cli/utils/schema-validation.js.map +1 -0
- package/dist/cli/utils/schema-validation.test.d.ts +5 -0
- package/dist/cli/utils/schema-validation.test.d.ts.map +1 -0
- package/dist/cli/utils/schema-validation.test.js +173 -0
- package/dist/cli/utils/schema-validation.test.js.map +1 -0
- package/dist/client/base.d.ts +116 -0
- package/dist/client/base.d.ts.map +1 -0
- package/dist/client/base.js +328 -0
- package/dist/client/base.js.map +1 -0
- package/dist/client/types.d.ts +137 -0
- package/dist/client/types.d.ts.map +1 -0
- package/dist/client/types.js +43 -0
- package/dist/client/types.js.map +1 -0
- package/dist/generator/client.d.ts +44 -0
- package/dist/generator/client.d.ts.map +1 -0
- package/dist/generator/client.js +144 -0
- package/dist/generator/client.js.map +1 -0
- package/dist/generator/datasource.d.ts +57 -0
- package/dist/generator/datasource.d.ts.map +1 -0
- package/dist/generator/datasource.js +169 -0
- package/dist/generator/datasource.js.map +1 -0
- package/dist/generator/datasource.test.d.ts +2 -0
- package/dist/generator/datasource.test.d.ts.map +1 -0
- package/dist/generator/datasource.test.js +254 -0
- package/dist/generator/datasource.test.js.map +1 -0
- package/dist/generator/index.d.ts +131 -0
- package/dist/generator/index.d.ts.map +1 -0
- package/dist/generator/index.js +121 -0
- package/dist/generator/index.js.map +1 -0
- package/dist/generator/index.test.d.ts +2 -0
- package/dist/generator/index.test.d.ts.map +1 -0
- package/dist/generator/index.test.js +175 -0
- package/dist/generator/index.test.js.map +1 -0
- package/dist/generator/loader.d.ts +156 -0
- package/dist/generator/loader.d.ts.map +1 -0
- package/dist/generator/loader.js +295 -0
- package/dist/generator/loader.js.map +1 -0
- package/dist/generator/pipe.d.ts +72 -0
- package/dist/generator/pipe.d.ts.map +1 -0
- package/dist/generator/pipe.js +174 -0
- package/dist/generator/pipe.js.map +1 -0
- package/dist/generator/pipe.test.d.ts +2 -0
- package/dist/generator/pipe.test.d.ts.map +1 -0
- package/dist/generator/pipe.test.js +393 -0
- package/dist/generator/pipe.test.js.map +1 -0
- package/dist/index.d.ts +74 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +73 -0
- package/dist/index.js.map +1 -0
- package/dist/infer/index.d.ts +202 -0
- package/dist/infer/index.d.ts.map +1 -0
- package/dist/infer/index.js +5 -0
- package/dist/infer/index.js.map +1 -0
- package/dist/schema/datasource.d.ts +135 -0
- package/dist/schema/datasource.d.ts.map +1 -0
- package/dist/schema/datasource.js +105 -0
- package/dist/schema/datasource.js.map +1 -0
- package/dist/schema/datasource.test.d.ts +2 -0
- package/dist/schema/datasource.test.d.ts.map +1 -0
- package/dist/schema/datasource.test.js +142 -0
- package/dist/schema/datasource.test.js.map +1 -0
- package/dist/schema/engines.d.ts +157 -0
- package/dist/schema/engines.d.ts.map +1 -0
- package/dist/schema/engines.js +155 -0
- package/dist/schema/engines.js.map +1 -0
- package/dist/schema/engines.test.d.ts +2 -0
- package/dist/schema/engines.test.d.ts.map +1 -0
- package/dist/schema/engines.test.js +221 -0
- package/dist/schema/engines.test.js.map +1 -0
- package/dist/schema/params.d.ts +106 -0
- package/dist/schema/params.d.ts.map +1 -0
- package/dist/schema/params.js +138 -0
- package/dist/schema/params.js.map +1 -0
- package/dist/schema/params.test.d.ts +2 -0
- package/dist/schema/params.test.d.ts.map +1 -0
- package/dist/schema/params.test.js +175 -0
- package/dist/schema/params.test.js.map +1 -0
- package/dist/schema/pipe.d.ts +436 -0
- package/dist/schema/pipe.d.ts.map +1 -0
- package/dist/schema/pipe.js +484 -0
- package/dist/schema/pipe.js.map +1 -0
- package/dist/schema/pipe.test.d.ts +2 -0
- package/dist/schema/pipe.test.d.ts.map +1 -0
- package/dist/schema/pipe.test.js +488 -0
- package/dist/schema/pipe.test.js.map +1 -0
- package/dist/schema/project.d.ts +202 -0
- package/dist/schema/project.d.ts.map +1 -0
- package/dist/schema/project.js +188 -0
- package/dist/schema/project.js.map +1 -0
- package/dist/schema/project.test.d.ts +2 -0
- package/dist/schema/project.test.d.ts.map +1 -0
- package/dist/schema/project.test.js +180 -0
- package/dist/schema/project.test.js.map +1 -0
- package/dist/schema/types.d.ts +140 -0
- package/dist/schema/types.d.ts.map +1 -0
- package/dist/schema/types.js +174 -0
- package/dist/schema/types.js.map +1 -0
- package/dist/schema/types.test.d.ts +2 -0
- package/dist/schema/types.test.d.ts.map +1 -0
- package/dist/schema/types.test.js +176 -0
- package/dist/schema/types.test.js.map +1 -0
- package/dist/test/handlers.d.ts +58 -0
- package/dist/test/handlers.d.ts.map +1 -0
- package/dist/test/handlers.js +62 -0
- package/dist/test/handlers.js.map +1 -0
- package/dist/test/setup.d.ts +5 -0
- package/dist/test/setup.d.ts.map +1 -0
- package/dist/test/setup.js +11 -0
- package/dist/test/setup.js.map +1 -0
- package/package.json +57 -0
- package/src/api/branches.test.ts +377 -0
- package/src/api/branches.ts +334 -0
- package/src/api/build.test.ts +216 -0
- package/src/api/build.ts +266 -0
- package/src/api/deploy.test.ts +193 -0
- package/src/api/deploy.ts +163 -0
- package/src/api/workspaces.test.ts +81 -0
- package/src/api/workspaces.ts +77 -0
- package/src/cli/auth.ts +358 -0
- package/src/cli/branch-store.test.ts +139 -0
- package/src/cli/branch-store.ts +137 -0
- package/src/cli/commands/branch.ts +306 -0
- package/src/cli/commands/build.ts +183 -0
- package/src/cli/commands/dev.ts +334 -0
- package/src/cli/commands/init.test.ts +249 -0
- package/src/cli/commands/init.ts +323 -0
- package/src/cli/commands/login.ts +98 -0
- package/src/cli/config.test.ts +359 -0
- package/src/cli/config.ts +335 -0
- package/src/cli/env.ts +86 -0
- package/src/cli/git.test.ts +147 -0
- package/src/cli/git.ts +125 -0
- package/src/cli/index.ts +382 -0
- package/src/cli/utils/schema-validation.test.ts +222 -0
- package/src/cli/utils/schema-validation.ts +272 -0
- package/src/client/base.ts +414 -0
- package/src/client/types.ts +165 -0
- package/src/generator/client.ts +194 -0
- package/src/generator/datasource.test.ts +297 -0
- package/src/generator/datasource.ts +217 -0
- package/src/generator/index.test.ts +209 -0
- package/src/generator/index.ts +203 -0
- package/src/generator/loader.ts +406 -0
- package/src/generator/pipe.test.ts +441 -0
- package/src/generator/pipe.ts +220 -0
- package/src/index.ts +191 -0
- package/src/infer/index.ts +247 -0
- package/src/schema/datasource.test.ts +187 -0
- package/src/schema/datasource.ts +195 -0
- package/src/schema/engines.test.ts +247 -0
- package/src/schema/engines.ts +271 -0
- package/src/schema/params.test.ts +208 -0
- package/src/schema/params.ts +249 -0
- package/src/schema/pipe.test.ts +588 -0
- package/src/schema/pipe.ts +832 -0
- package/src/schema/project.test.ts +236 -0
- package/src/schema/project.ts +394 -0
- package/src/schema/types.test.ts +212 -0
- package/src/schema/types.ts +366 -0
- package/src/test/handlers.ts +79 -0
- package/src/test/setup.ts +13 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pipe.test.js","sourceRoot":"","sources":["../../src/generator/pipe.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAC9C,OAAO,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAC3D,OAAO,EAAE,UAAU,EAAE,sBAAsB,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AAC7E,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAC3D,OAAO,EAAE,CAAC,EAAE,MAAM,oBAAoB,CAAC;AACvC,OAAO,EAAE,CAAC,EAAE,MAAM,qBAAqB,CAAC;AACxC,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,C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|
|
2
|
+
* @tinybirdco/sdk - TypeScript SDK for Tinybird Forward
|
|
3
|
+
*
|
|
4
|
+
* Define datasources and pipes as TypeScript with full type safety.
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* ```ts
|
|
8
|
+
* import {
|
|
9
|
+
* defineDatasource,
|
|
10
|
+
* definePipe,
|
|
11
|
+
* defineProject,
|
|
12
|
+
* node,
|
|
13
|
+
* t,
|
|
14
|
+
* p,
|
|
15
|
+
* engine,
|
|
16
|
+
* createClient,
|
|
17
|
+
* } from '@tinybirdco/sdk';
|
|
18
|
+
*
|
|
19
|
+
* // Define a datasource
|
|
20
|
+
* const events = defineDatasource('events', {
|
|
21
|
+
* schema: {
|
|
22
|
+
* timestamp: t.dateTime(),
|
|
23
|
+
* user_id: t.string(),
|
|
24
|
+
* event_type: t.string().lowCardinality(),
|
|
25
|
+
* },
|
|
26
|
+
* engine: engine.mergeTree({
|
|
27
|
+
* sortingKey: ['user_id', 'timestamp'],
|
|
28
|
+
* }),
|
|
29
|
+
* });
|
|
30
|
+
*
|
|
31
|
+
* // Define a pipe
|
|
32
|
+
* const topEvents = definePipe('top_events', {
|
|
33
|
+
* params: {
|
|
34
|
+
* limit: p.int32().optional(10),
|
|
35
|
+
* },
|
|
36
|
+
* nodes: [
|
|
37
|
+
* node({
|
|
38
|
+
* name: 'aggregated',
|
|
39
|
+
* sql: 'SELECT event_type, count() as cnt FROM events GROUP BY event_type LIMIT {{Int32(limit, 10)}}',
|
|
40
|
+
* }),
|
|
41
|
+
* ],
|
|
42
|
+
* output: {
|
|
43
|
+
* event_type: t.string(),
|
|
44
|
+
* cnt: t.uint64(),
|
|
45
|
+
* },
|
|
46
|
+
* endpoint: true,
|
|
47
|
+
* });
|
|
48
|
+
*
|
|
49
|
+
* // Create project
|
|
50
|
+
* export default defineProject({
|
|
51
|
+
* datasources: { events },
|
|
52
|
+
* pipes: { topEvents },
|
|
53
|
+
* });
|
|
54
|
+
* ```
|
|
55
|
+
*/
|
|
56
|
+
export { t } from "./schema/types.js";
|
|
57
|
+
export type { TypeValidator, AnyTypeValidator, TypeModifiers, InferType, TinybirdType, } from "./schema/types.js";
|
|
58
|
+
export { isTypeValidator, getTinybirdType, getModifiers, } from "./schema/types.js";
|
|
59
|
+
export { p } from "./schema/params.js";
|
|
60
|
+
export type { ParamValidator, AnyParamValidator, InferParamType, } from "./schema/params.js";
|
|
61
|
+
export { isParamValidator, getParamTinybirdType, isParamRequired, getParamDefault, getParamDescription, } from "./schema/params.js";
|
|
62
|
+
export { engine, getEngineClause, getSortingKey, getPrimaryKey } from "./schema/engines.js";
|
|
63
|
+
export type { EngineConfig, BaseMergeTreeConfig, MergeTreeConfig, ReplacingMergeTreeConfig, SummingMergeTreeConfig, AggregatingMergeTreeConfig, CollapsingMergeTreeConfig, VersionedCollapsingMergeTreeConfig, } from "./schema/engines.js";
|
|
64
|
+
export { defineDatasource, isDatasourceDefinition, column, getColumnType, getColumnJsonPath, getColumnNames } from "./schema/datasource.js";
|
|
65
|
+
export type { DatasourceDefinition, DatasourceOptions, SchemaDefinition, ColumnDefinition, TokenConfig, ExtractSchema, } from "./schema/datasource.js";
|
|
66
|
+
export { definePipe, defineEndpoint, defineMaterializedView, defineCopyPipe, node, isPipeDefinition, isNodeDefinition, getEndpointConfig, getMaterializedConfig, getCopyConfig, isMaterializedView, isCopyPipe, getNodeNames, getNode, sql, } from "./schema/pipe.js";
|
|
67
|
+
export type { PipeDefinition, PipeOptions, EndpointOptions, CopyPipeOptions, CopyConfig, NodeDefinition, NodeOptions, ParamsDefinition, OutputDefinition, EndpointConfig, MaterializedConfig, MaterializedViewOptions, PipeTokenConfig, ExtractParams, ExtractOutput, } from "./schema/pipe.js";
|
|
68
|
+
export { defineProject, isProjectDefinition, getDatasourceNames, getPipeNames, getDatasource, getPipe, createTinybirdClient } from "./schema/project.js";
|
|
69
|
+
export type { ProjectDefinition, ProjectConfig, ProjectClient, TinybirdClientConfig, DatasourcesDefinition, PipesDefinition, ExtractDatasources, ExtractPipes, DataModel, } from "./schema/project.js";
|
|
70
|
+
export type { Infer, InferRow, InferParams, InferOutput, InferOutputRow, InferEvent, PartialRow, InferSchema, InferTinybirdTypes, InferMaterializedTarget, InferMaterializedTargetRow, IsMaterializedPipe, } from "./infer/index.js";
|
|
71
|
+
export { TinybirdClient, createClient } from "./client/base.js";
|
|
72
|
+
export { TinybirdError } from "./client/types.js";
|
|
73
|
+
export type { ClientConfig, QueryResult, IngestResult, QueryOptions, IngestOptions, ColumnMeta, QueryStatistics, TinybirdErrorResponse, TypedPipeEndpoint, TypedDatasourceIngest, } from "./client/types.js";
|
|
74
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsDG;AAGH,OAAO,EAAE,CAAC,EAAE,MAAM,mBAAmB,CAAC;AACtC,YAAY,EACV,aAAa,EACb,gBAAgB,EAChB,aAAa,EACb,SAAS,EACT,YAAY,GACb,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EACL,eAAe,EACf,eAAe,EACf,YAAY,GACb,MAAM,mBAAmB,CAAC;AAG3B,OAAO,EAAE,CAAC,EAAE,MAAM,oBAAoB,CAAC;AACvC,YAAY,EACV,cAAc,EACd,iBAAiB,EACjB,cAAc,GACf,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EACL,gBAAgB,EAChB,oBAAoB,EACpB,eAAe,EACf,eAAe,EACf,mBAAmB,GACpB,MAAM,oBAAoB,CAAC;AAG5B,OAAO,EAAE,MAAM,EAAE,eAAe,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAC5F,YAAY,EACV,YAAY,EACZ,mBAAmB,EACnB,eAAe,EACf,wBAAwB,EACxB,sBAAsB,EACtB,0BAA0B,EAC1B,yB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AAE,MAAM,kBAAkB,CAAC;AAChE,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAClD,YAAY,EACV,YAAY,EACZ,WAAW,EACX,YAAY,EACZ,YAAY,EACZ,aAAa,EACb,UAAU,EACV,eAAe,EACf,qBAAqB,EACrB,iBAAiB,EACjB,qBAAqB,GACtB,MAAM,mBAAmB,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @tinybirdco/sdk - TypeScript SDK for Tinybird Forward
|
|
3
|
+
*
|
|
4
|
+
* Define datasources and pipes as TypeScript with full type safety.
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* ```ts
|
|
8
|
+
* import {
|
|
9
|
+
* defineDatasource,
|
|
10
|
+
* definePipe,
|
|
11
|
+
* defineProject,
|
|
12
|
+
* node,
|
|
13
|
+
* t,
|
|
14
|
+
* p,
|
|
15
|
+
* engine,
|
|
16
|
+
* createClient,
|
|
17
|
+
* } from '@tinybirdco/sdk';
|
|
18
|
+
*
|
|
19
|
+
* // Define a datasource
|
|
20
|
+
* const events = defineDatasource('events', {
|
|
21
|
+
* schema: {
|
|
22
|
+
* timestamp: t.dateTime(),
|
|
23
|
+
* user_id: t.string(),
|
|
24
|
+
* event_type: t.string().lowCardinality(),
|
|
25
|
+
* },
|
|
26
|
+
* engine: engine.mergeTree({
|
|
27
|
+
* sortingKey: ['user_id', 'timestamp'],
|
|
28
|
+
* }),
|
|
29
|
+
* });
|
|
30
|
+
*
|
|
31
|
+
* // Define a pipe
|
|
32
|
+
* const topEvents = definePipe('top_events', {
|
|
33
|
+
* params: {
|
|
34
|
+
* limit: p.int32().optional(10),
|
|
35
|
+
* },
|
|
36
|
+
* nodes: [
|
|
37
|
+
* node({
|
|
38
|
+
* name: 'aggregated',
|
|
39
|
+
* sql: 'SELECT event_type, count() as cnt FROM events GROUP BY event_type LIMIT {{Int32(limit, 10)}}',
|
|
40
|
+
* }),
|
|
41
|
+
* ],
|
|
42
|
+
* output: {
|
|
43
|
+
* event_type: t.string(),
|
|
44
|
+
* cnt: t.uint64(),
|
|
45
|
+
* },
|
|
46
|
+
* endpoint: true,
|
|
47
|
+
* });
|
|
48
|
+
*
|
|
49
|
+
* // Create project
|
|
50
|
+
* export default defineProject({
|
|
51
|
+
* datasources: { events },
|
|
52
|
+
* pipes: { topEvents },
|
|
53
|
+
* });
|
|
54
|
+
* ```
|
|
55
|
+
*/
|
|
56
|
+
// ============ Schema Types ============
|
|
57
|
+
export { t } from "./schema/types.js";
|
|
58
|
+
export { isTypeValidator, getTinybirdType, getModifiers, } from "./schema/types.js";
|
|
59
|
+
// ============ Parameter Types ============
|
|
60
|
+
export { p } from "./schema/params.js";
|
|
61
|
+
export { isParamValidator, getParamTinybirdType, isParamRequired, getParamDefault, getParamDescription, } from "./schema/params.js";
|
|
62
|
+
// ============ Engine Configurations ============
|
|
63
|
+
export { engine, getEngineClause, getSortingKey, getPrimaryKey } from "./schema/engines.js";
|
|
64
|
+
// ============ Datasource ============
|
|
65
|
+
export { defineDatasource, isDatasourceDefinition, column, getColumnType, getColumnJsonPath, getColumnNames } from "./schema/datasource.js";
|
|
66
|
+
// ============ Pipe ============
|
|
67
|
+
export { definePipe, defineEndpoint, defineMaterializedView, defineCopyPipe, node, isPipeDefinition, isNodeDefinition, getEndpointConfig, getMaterializedConfig, getCopyConfig, isMaterializedView, isCopyPipe, getNodeNames, getNode, sql, } from "./schema/pipe.js";
|
|
68
|
+
// ============ Project ============
|
|
69
|
+
export { defineProject, isProjectDefinition, getDatasourceNames, getPipeNames, getDatasource, getPipe, createTinybirdClient } from "./schema/project.js";
|
|
70
|
+
// ============ Client ============
|
|
71
|
+
export { TinybirdClient, createClient } from "./client/base.js";
|
|
72
|
+
export { TinybirdError } from "./client/types.js";
|
|
73
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","s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for extracting TypeScript types from Tinybird definitions
|
|
3
|
+
*/
|
|
4
|
+
import type { TypeValidator, TypeModifiers } from "../schema/types.js";
|
|
5
|
+
import type { ParamValidator } from "../schema/params.js";
|
|
6
|
+
import type { DatasourceDefinition, SchemaDefinition, ColumnDefinition } from "../schema/datasource.js";
|
|
7
|
+
import type { PipeDefinition, ParamsDefinition, OutputDefinition } from "../schema/pipe.js";
|
|
8
|
+
/**
|
|
9
|
+
* Extract the TypeScript type from a type validator
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* ```ts
|
|
13
|
+
* import { t, Infer } from '@tinybirdco/sdk';
|
|
14
|
+
*
|
|
15
|
+
* const myType = t.string();
|
|
16
|
+
* type MyType = Infer<typeof myType>; // string
|
|
17
|
+
*
|
|
18
|
+
* const myArray = t.array(t.int32());
|
|
19
|
+
* type MyArray = Infer<typeof myArray>; // number[]
|
|
20
|
+
* ```
|
|
21
|
+
*/
|
|
22
|
+
export type Infer<T> = T extends TypeValidator<infer U, string, TypeModifiers> ? U : T extends ParamValidator<infer U, string, boolean> ? U : never;
|
|
23
|
+
/**
|
|
24
|
+
* Infer a single column type, handling both raw validators and column definitions
|
|
25
|
+
*/
|
|
26
|
+
type InferColumn<T> = T extends TypeValidator<infer U, string, TypeModifiers> ? U : T extends {
|
|
27
|
+
type: TypeValidator<infer U, string, TypeModifiers>;
|
|
28
|
+
} ? U : never;
|
|
29
|
+
/**
|
|
30
|
+
* Extract a row type from a datasource definition
|
|
31
|
+
*
|
|
32
|
+
* @example
|
|
33
|
+
* ```ts
|
|
34
|
+
* import { defineDatasource, t, InferRow } from '@tinybirdco/sdk';
|
|
35
|
+
*
|
|
36
|
+
* const events = defineDatasource('events', {
|
|
37
|
+
* schema: {
|
|
38
|
+
* id: t.string(),
|
|
39
|
+
* count: t.int32(),
|
|
40
|
+
* timestamp: t.dateTime(),
|
|
41
|
+
* },
|
|
42
|
+
* });
|
|
43
|
+
*
|
|
44
|
+
* type EventRow = InferRow<typeof events>;
|
|
45
|
+
* // { id: string; count: number; timestamp: Date }
|
|
46
|
+
* ```
|
|
47
|
+
*/
|
|
48
|
+
export type InferRow<T> = T extends DatasourceDefinition<infer S> ? {
|
|
49
|
+
[K in keyof S]: InferColumn<S[K]>;
|
|
50
|
+
} : never;
|
|
51
|
+
/**
|
|
52
|
+
* Infer a single parameter type, respecting required/optional
|
|
53
|
+
*/
|
|
54
|
+
type InferSingleParam<T> = T extends ParamValidator<infer U, string, infer R> ? R extends true ? U : U | undefined : never;
|
|
55
|
+
/**
|
|
56
|
+
* Extract the required parameter keys from a params definition
|
|
57
|
+
*/
|
|
58
|
+
type RequiredParamKeys<T extends ParamsDefinition> = {
|
|
59
|
+
[K in keyof T]: T[K] extends ParamValidator<unknown, string, true> ? K : never;
|
|
60
|
+
}[keyof T];
|
|
61
|
+
/**
|
|
62
|
+
* Extract the optional parameter keys from a params definition
|
|
63
|
+
*/
|
|
64
|
+
type OptionalParamKeys<T extends ParamsDefinition> = {
|
|
65
|
+
[K in keyof T]: T[K] extends ParamValidator<unknown, string, false> ? K : never;
|
|
66
|
+
}[keyof T];
|
|
67
|
+
/**
|
|
68
|
+
* Extract the params type from a pipe definition
|
|
69
|
+
*
|
|
70
|
+
* @example
|
|
71
|
+
* ```ts
|
|
72
|
+
* import { definePipe, p, InferParams } from '@tinybirdco/sdk';
|
|
73
|
+
*
|
|
74
|
+
* const myPipe = definePipe('my_pipe', {
|
|
75
|
+
* params: {
|
|
76
|
+
* userId: p.string(),
|
|
77
|
+
* limit: p.int32().optional(10),
|
|
78
|
+
* },
|
|
79
|
+
* nodes: [...],
|
|
80
|
+
* output: {...},
|
|
81
|
+
* });
|
|
82
|
+
*
|
|
83
|
+
* type MyParams = InferParams<typeof myPipe>;
|
|
84
|
+
* // { userId: string; limit?: number }
|
|
85
|
+
* ```
|
|
86
|
+
*/
|
|
87
|
+
export type InferParams<T> = T extends PipeDefinition<infer P, OutputDefinition> ? {
|
|
88
|
+
[K in RequiredParamKeys<P>]: InferSingleParam<P[K]>;
|
|
89
|
+
} & {
|
|
90
|
+
[K in OptionalParamKeys<P>]?: InferSingleParam<P[K]>;
|
|
91
|
+
} : never;
|
|
92
|
+
/**
|
|
93
|
+
* Extract the output type (single row) from a pipe definition
|
|
94
|
+
*
|
|
95
|
+
* @example
|
|
96
|
+
* ```ts
|
|
97
|
+
* import { definePipe, t, InferOutput } from '@tinybirdco/sdk';
|
|
98
|
+
*
|
|
99
|
+
* const myPipe = definePipe('my_pipe', {
|
|
100
|
+
* params: {},
|
|
101
|
+
* nodes: [...],
|
|
102
|
+
* output: {
|
|
103
|
+
* name: t.string(),
|
|
104
|
+
* count: t.uint64(),
|
|
105
|
+
* },
|
|
106
|
+
* });
|
|
107
|
+
*
|
|
108
|
+
* type MyOutput = InferOutput<typeof myPipe>;
|
|
109
|
+
* // { name: string; count: number }[]
|
|
110
|
+
* ```
|
|
111
|
+
*/
|
|
112
|
+
export type InferOutput<T> = T extends PipeDefinition<ParamsDefinition, infer O> ? {
|
|
113
|
+
[K in keyof O]: InferColumn<O[K]>;
|
|
114
|
+
}[] : never;
|
|
115
|
+
/**
|
|
116
|
+
* Extract a single output row type (without array wrapper)
|
|
117
|
+
*/
|
|
118
|
+
export type InferOutputRow<T> = T extends PipeDefinition<ParamsDefinition, infer O> ? {
|
|
119
|
+
[K in keyof O]: InferColumn<O[K]>;
|
|
120
|
+
} : never;
|
|
121
|
+
/**
|
|
122
|
+
* Infer the event type for ingestion (same as row type)
|
|
123
|
+
*
|
|
124
|
+
* @example
|
|
125
|
+
* ```ts
|
|
126
|
+
* import { defineDatasource, t, InferEvent } from '@tinybirdco/sdk';
|
|
127
|
+
*
|
|
128
|
+
* const events = defineDatasource('events', {
|
|
129
|
+
* schema: {
|
|
130
|
+
* id: t.string(),
|
|
131
|
+
* timestamp: t.dateTime(),
|
|
132
|
+
* },
|
|
133
|
+
* });
|
|
134
|
+
*
|
|
135
|
+
* type Event = InferEvent<typeof events>;
|
|
136
|
+
* // { id: string; timestamp: Date }
|
|
137
|
+
*
|
|
138
|
+
* // Use for type-safe event ingestion
|
|
139
|
+
* const event: Event = { id: '123', timestamp: new Date() };
|
|
140
|
+
* ```
|
|
141
|
+
*/
|
|
142
|
+
export type InferEvent<T> = InferRow<T>;
|
|
143
|
+
/**
|
|
144
|
+
* Make all properties of InferRow optional (for partial updates)
|
|
145
|
+
*/
|
|
146
|
+
export type PartialRow<T> = T extends DatasourceDefinition<infer S> ? Partial<{
|
|
147
|
+
[K in keyof S]: InferColumn<S[K]>;
|
|
148
|
+
}> : never;
|
|
149
|
+
/**
|
|
150
|
+
* Extract the schema definition type from a datasource
|
|
151
|
+
*/
|
|
152
|
+
export type InferSchema<T> = T extends DatasourceDefinition<infer S> ? S : never;
|
|
153
|
+
/**
|
|
154
|
+
* Helper type to get the Tinybird type string for a schema
|
|
155
|
+
* Handles both raw TypeValidators and ColumnDefinition wrappers
|
|
156
|
+
*/
|
|
157
|
+
export type InferTinybirdTypes<T extends SchemaDefinition> = {
|
|
158
|
+
[K in keyof T]: T[K] extends ColumnDefinition<infer V> ? V extends TypeValidator<unknown, infer TB, TypeModifiers> ? TB : never : T[K] extends TypeValidator<unknown, infer TB, TypeModifiers> ? TB : never;
|
|
159
|
+
};
|
|
160
|
+
/**
|
|
161
|
+
* Extract the target datasource from a materialized view pipe
|
|
162
|
+
*
|
|
163
|
+
* @example
|
|
164
|
+
* ```ts
|
|
165
|
+
* import { definePipe, defineDatasource, t, engine, InferMaterializedTarget } from '@tinybirdco/sdk';
|
|
166
|
+
*
|
|
167
|
+
* const salesByHour = defineDatasource('sales_by_hour', {
|
|
168
|
+
* schema: { day: t.date(), total: t.uint64() },
|
|
169
|
+
* engine: engine.aggregatingMergeTree({ sortingKey: ['day'] }),
|
|
170
|
+
* });
|
|
171
|
+
*
|
|
172
|
+
* const salesMv = definePipe('sales_mv', {
|
|
173
|
+
* nodes: [...],
|
|
174
|
+
* output: { day: t.date(), total: t.uint64() },
|
|
175
|
+
* materialized: { datasource: salesByHour },
|
|
176
|
+
* });
|
|
177
|
+
*
|
|
178
|
+
* type Target = InferMaterializedTarget<typeof salesMv>;
|
|
179
|
+
* // typeof salesByHour
|
|
180
|
+
* ```
|
|
181
|
+
*/
|
|
182
|
+
export type InferMaterializedTarget<T> = T extends PipeDefinition<ParamsDefinition, OutputDefinition> ? T["options"]["materialized"] extends {
|
|
183
|
+
datasource: infer D;
|
|
184
|
+
} ? D extends DatasourceDefinition<SchemaDefinition> ? D : never : never : never;
|
|
185
|
+
/**
|
|
186
|
+
* Extract the target datasource row type from a materialized view pipe
|
|
187
|
+
*
|
|
188
|
+
* @example
|
|
189
|
+
* ```ts
|
|
190
|
+
* type TargetRow = InferMaterializedTargetRow<typeof salesMv>;
|
|
191
|
+
* // { day: Date; total: number }
|
|
192
|
+
* ```
|
|
193
|
+
*/
|
|
194
|
+
export type InferMaterializedTargetRow<T> = InferRow<InferMaterializedTarget<T>>;
|
|
195
|
+
/**
|
|
196
|
+
* Check if a pipe definition is a materialized view (type-level)
|
|
197
|
+
*/
|
|
198
|
+
export type IsMaterializedPipe<T> = T extends PipeDefinition<ParamsDefinition, OutputDefinition> ? T["options"]["materialized"] extends {
|
|
199
|
+
datasource: DatasourceDefinition<SchemaDefinition>;
|
|
200
|
+
} ? true : false : false;
|
|
201
|
+
export {};
|
|
202
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/infer/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACvE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAC1D,OAAO,KAAK,EAAE,oBAAoB,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AACxG,OAAO,KAAK,EAAE,cAAc,EAAE,gBAAgB,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ChB,gBAAgB,CACjB,GACG,CAAC,CAAC,SAAS,CAAC,CAAC,cAAc,CAAC,SAAS;IAAE,UAAU,EAAE,oBAAoB,CAAC,gBAAgB,CAAC,CAAA;CAAE,GACzF,IAAI,GACJ,KAAK,GACP,KAAK,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/infer/index.ts"],"names":[],"mappings":"AAAA;;GAEG"}
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Datasource definition for Tinybird
|
|
3
|
+
* Define table schemas as TypeScript with full type safety
|
|
4
|
+
*/
|
|
5
|
+
import type { AnyTypeValidator } from "./types.js";
|
|
6
|
+
import type { EngineConfig } from "./engines.js";
|
|
7
|
+
declare const DATASOURCE_BRAND: unique symbol;
|
|
8
|
+
/**
|
|
9
|
+
* A column can be defined as just a type validator,
|
|
10
|
+
* or with additional options like JSON path or default value
|
|
11
|
+
*/
|
|
12
|
+
export interface ColumnDefinition<T extends AnyTypeValidator = AnyTypeValidator> {
|
|
13
|
+
/** The column type */
|
|
14
|
+
type: T;
|
|
15
|
+
/** JSON path for extracting from nested JSON (e.g., '$.user.id') */
|
|
16
|
+
jsonPath?: string;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Schema definition is a record of column names to type validators or column definitions
|
|
20
|
+
*/
|
|
21
|
+
export type SchemaDefinition = Record<string, AnyTypeValidator | ColumnDefinition>;
|
|
22
|
+
/**
|
|
23
|
+
* Token configuration for datasource access
|
|
24
|
+
*/
|
|
25
|
+
export interface TokenConfig {
|
|
26
|
+
/** Token name */
|
|
27
|
+
name: string;
|
|
28
|
+
/** Permissions granted to this token */
|
|
29
|
+
permissions: readonly ("READ" | "APPEND")[];
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Options for defining a datasource
|
|
33
|
+
*/
|
|
34
|
+
export interface DatasourceOptions<TSchema extends SchemaDefinition> {
|
|
35
|
+
/** Human-readable description of the datasource */
|
|
36
|
+
description?: string;
|
|
37
|
+
/** Column schema definition */
|
|
38
|
+
schema: TSchema;
|
|
39
|
+
/** Table engine configuration */
|
|
40
|
+
engine?: EngineConfig;
|
|
41
|
+
/** Access tokens for this datasource */
|
|
42
|
+
tokens?: readonly TokenConfig[];
|
|
43
|
+
/** Workspaces to share this datasource with */
|
|
44
|
+
sharedWith?: readonly string[];
|
|
45
|
+
/**
|
|
46
|
+
* Whether to generate JSON path expressions for columns.
|
|
47
|
+
* Set to false for datasources that are targets of materialized views.
|
|
48
|
+
* Defaults to true.
|
|
49
|
+
*/
|
|
50
|
+
jsonPaths?: boolean;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* A datasource definition with full type information
|
|
54
|
+
*/
|
|
55
|
+
export interface DatasourceDefinition<TSchema extends SchemaDefinition = SchemaDefinition> {
|
|
56
|
+
readonly [DATASOURCE_BRAND]: true;
|
|
57
|
+
/** Datasource name */
|
|
58
|
+
readonly _name: string;
|
|
59
|
+
/** Type marker for inference */
|
|
60
|
+
readonly _type: "datasource";
|
|
61
|
+
/** Schema definition */
|
|
62
|
+
readonly _schema: TSchema;
|
|
63
|
+
/** Full options */
|
|
64
|
+
readonly options: DatasourceOptions<TSchema>;
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Define a Tinybird datasource
|
|
68
|
+
*
|
|
69
|
+
* @param name - The datasource name (must be valid identifier)
|
|
70
|
+
* @param options - Datasource configuration including schema and engine
|
|
71
|
+
* @returns A datasource definition that can be used in a project
|
|
72
|
+
*
|
|
73
|
+
* @example
|
|
74
|
+
* ```ts
|
|
75
|
+
* import { defineDatasource, t, engine } from '@tinybirdco/sdk';
|
|
76
|
+
*
|
|
77
|
+
* export const events = defineDatasource('events', {
|
|
78
|
+
* description: 'User event tracking data',
|
|
79
|
+
* schema: {
|
|
80
|
+
* timestamp: t.dateTime(),
|
|
81
|
+
* event_id: t.uuid(),
|
|
82
|
+
* user_id: t.string(),
|
|
83
|
+
* event_type: t.string().lowCardinality(),
|
|
84
|
+
* properties: t.json(),
|
|
85
|
+
* session_id: t.string().nullable(),
|
|
86
|
+
* },
|
|
87
|
+
* engine: engine.mergeTree({
|
|
88
|
+
* sortingKey: ['user_id', 'timestamp'],
|
|
89
|
+
* partitionKey: 'toYYYYMM(timestamp)',
|
|
90
|
+
* ttl: 'timestamp + INTERVAL 90 DAY',
|
|
91
|
+
* }),
|
|
92
|
+
* });
|
|
93
|
+
* ```
|
|
94
|
+
*/
|
|
95
|
+
export declare function defineDatasource<TSchema extends SchemaDefinition>(name: string, options: DatasourceOptions<TSchema>): DatasourceDefinition<TSchema>;
|
|
96
|
+
/**
|
|
97
|
+
* Check if a value is a datasource definition
|
|
98
|
+
*/
|
|
99
|
+
export declare function isDatasourceDefinition(value: unknown): value is DatasourceDefinition;
|
|
100
|
+
/**
|
|
101
|
+
* Get the column type for a schema entry (handles both raw validators and column definitions)
|
|
102
|
+
*/
|
|
103
|
+
export declare function getColumnType(column: AnyTypeValidator | ColumnDefinition): AnyTypeValidator;
|
|
104
|
+
/**
|
|
105
|
+
* Get the JSON path for a column if defined
|
|
106
|
+
*/
|
|
107
|
+
export declare function getColumnJsonPath(column: AnyTypeValidator | ColumnDefinition): string | undefined;
|
|
108
|
+
/**
|
|
109
|
+
* Get all column names from a schema
|
|
110
|
+
*/
|
|
111
|
+
export declare function getColumnNames<TSchema extends SchemaDefinition>(schema: TSchema): (keyof TSchema)[];
|
|
112
|
+
/**
|
|
113
|
+
* Helper type to extract the schema from a datasource definition
|
|
114
|
+
*/
|
|
115
|
+
export type ExtractSchema<T> = T extends DatasourceDefinition<infer S> ? S : never;
|
|
116
|
+
/**
|
|
117
|
+
* Column definition helper for complex column configurations
|
|
118
|
+
*
|
|
119
|
+
* @example
|
|
120
|
+
* ```ts
|
|
121
|
+
* import { defineDatasource, t, column } from '@tinybirdco/sdk';
|
|
122
|
+
*
|
|
123
|
+
* export const events = defineDatasource('events', {
|
|
124
|
+
* schema: {
|
|
125
|
+
* // Simple column
|
|
126
|
+
* id: t.string(),
|
|
127
|
+
* // Column with JSON extraction
|
|
128
|
+
* user_id: column(t.string(), { jsonPath: '$.user.id' }),
|
|
129
|
+
* },
|
|
130
|
+
* });
|
|
131
|
+
* ```
|
|
132
|
+
*/
|
|
133
|
+
export declare function column<T extends AnyTypeValidator>(type: T, options?: Omit<ColumnDefinition<T>, "type">): ColumnDefinition<T>;
|
|
134
|
+
export {};
|
|
135
|
+
//# sourceMappingURL=datasource.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"datasource.d.ts","sourceRoot":"","sources":["../../src/schema/datasource.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AACnD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAGjD,QAAA,MAAM,gBAAgB,eAAgC,CAAC;AAEvD;;;GAGG;AACH,MAAM,WAAW,gBAAgB,CAAC,CAAC,SAAS,gBAAgB,GAAG,gBAAgB;IAC7E,sBAAsB;IACtB,IAAI,EAAE,CAAC,CAAC;IACR,oEAAoE;IACpE,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED;;GAEG;AACH,MAAM,MAAM,gBAAgB,GAAG,MAAM,CAAC,MAAM,EAAE,gBAAgB,GAAG,gBAAgB,CAAC,CAAC;AAEnF;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B,iBAAiB;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,wCAAwC;IACxC,WAAW,EAAE,SAAS,CAAC,MAAM,GAAG,QAAQ,CAAC,EAAE,CAAC;CAC7C;AAED;;GAEG;AACH,MAAM,WAAW,iBAAiB,CAAC,OAAO,SAAS,gBAAgB;IACjE,mDAAmD;IACnD,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,+BAA+B;IAC/B,MAAM,EAAE,OAAO,CAAC;IAChB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EAAE,CAEnB;AAED;;GAEG;AACH,MAAM,MAAM,aAAa,CAAC,CAAC,IAAI,CAAC,SAAS,oBAAoB,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;AAEnF;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,MAAM,CAAC,CAAC,SAAS,gBAAgB,EAC/C,IAAI,EAAE,CAAC,EACP,OAAO,CAAC,EAAE,IAAI,CAAC,gBAAgB,CAAC,CAAC,CAAC,EAAE,MAAM,CAAC,GAC1C,gBAAgB,CAAC,CAAC,CAAC,CAKrB"}
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Datasource definition for Tinybird
|
|
3
|
+
* Define table schemas as TypeScript with full type safety
|
|
4
|
+
*/
|
|
5
|
+
// Symbol for brand typing
|
|
6
|
+
const DATASOURCE_BRAND = Symbol("tinybird.datasource");
|
|
7
|
+
/**
|
|
8
|
+
* Define a Tinybird datasource
|
|
9
|
+
*
|
|
10
|
+
* @param name - The datasource name (must be valid identifier)
|
|
11
|
+
* @param options - Datasource configuration including schema and engine
|
|
12
|
+
* @returns A datasource definition that can be used in a project
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* ```ts
|
|
16
|
+
* import { defineDatasource, t, engine } from '@tinybirdco/sdk';
|
|
17
|
+
*
|
|
18
|
+
* export const events = defineDatasource('events', {
|
|
19
|
+
* description: 'User event tracking data',
|
|
20
|
+
* schema: {
|
|
21
|
+
* timestamp: t.dateTime(),
|
|
22
|
+
* event_id: t.uuid(),
|
|
23
|
+
* user_id: t.string(),
|
|
24
|
+
* event_type: t.string().lowCardinality(),
|
|
25
|
+
* properties: t.json(),
|
|
26
|
+
* session_id: t.string().nullable(),
|
|
27
|
+
* },
|
|
28
|
+
* engine: engine.mergeTree({
|
|
29
|
+
* sortingKey: ['user_id', 'timestamp'],
|
|
30
|
+
* partitionKey: 'toYYYYMM(timestamp)',
|
|
31
|
+
* ttl: 'timestamp + INTERVAL 90 DAY',
|
|
32
|
+
* }),
|
|
33
|
+
* });
|
|
34
|
+
* ```
|
|
35
|
+
*/
|
|
36
|
+
export function defineDatasource(name, options) {
|
|
37
|
+
// Validate name is a valid identifier
|
|
38
|
+
if (!/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(name)) {
|
|
39
|
+
throw new Error(`Invalid datasource name: "${name}". Must start with a letter or underscore and contain only alphanumeric characters and underscores.`);
|
|
40
|
+
}
|
|
41
|
+
return {
|
|
42
|
+
[DATASOURCE_BRAND]: true,
|
|
43
|
+
_name: name,
|
|
44
|
+
_type: "datasource",
|
|
45
|
+
_schema: options.schema,
|
|
46
|
+
options,
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Check if a value is a datasource definition
|
|
51
|
+
*/
|
|
52
|
+
export function isDatasourceDefinition(value) {
|
|
53
|
+
return (typeof value === "object" &&
|
|
54
|
+
value !== null &&
|
|
55
|
+
DATASOURCE_BRAND in value &&
|
|
56
|
+
value[DATASOURCE_BRAND] === true);
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Get the column type for a schema entry (handles both raw validators and column definitions)
|
|
60
|
+
*/
|
|
61
|
+
export function getColumnType(column) {
|
|
62
|
+
if ("type" in column && typeof column.type === "object") {
|
|
63
|
+
return column.type;
|
|
64
|
+
}
|
|
65
|
+
return column;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Get the JSON path for a column if defined
|
|
69
|
+
*/
|
|
70
|
+
export function getColumnJsonPath(column) {
|
|
71
|
+
if ("jsonPath" in column) {
|
|
72
|
+
return column.jsonPath;
|
|
73
|
+
}
|
|
74
|
+
return undefined;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Get all column names from a schema
|
|
78
|
+
*/
|
|
79
|
+
export function getColumnNames(schema) {
|
|
80
|
+
return Object.keys(schema);
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Column definition helper for complex column configurations
|
|
84
|
+
*
|
|
85
|
+
* @example
|
|
86
|
+
* ```ts
|
|
87
|
+
* import { defineDatasource, t, column } from '@tinybirdco/sdk';
|
|
88
|
+
*
|
|
89
|
+
* export const events = defineDatasource('events', {
|
|
90
|
+
* schema: {
|
|
91
|
+
* // Simple column
|
|
92
|
+
* id: t.string(),
|
|
93
|
+
* // Column with JSON extraction
|
|
94
|
+
* user_id: column(t.string(), { jsonPath: '$.user.id' }),
|
|
95
|
+
* },
|
|
96
|
+
* });
|
|
97
|
+
* ```
|
|
98
|
+
*/
|
|
99
|
+
export function column(type, options) {
|
|
100
|
+
return {
|
|
101
|
+
type,
|
|
102
|
+
...options,
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
//# sourceMappingURL=datasource.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"datasource.js","sourceRoot":"","sources":["../../src/schema/datasource.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAKH,0BAA0B;AAC1B,MAAM,gBAAgB,GAAG,MAAM,CAAC,qBAAqB,CAAC,CAAC;AAiEvD;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,MAAM,UAAU,gBAAgB,CAC9B,IAAY,EACZ,OAAmC;IAEnC,sCAAsC;IACtC,IAAI,CAAC,0BAA0B,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;QAC3C,MAAM,IAAI,KAAK,CACb,6BAA6B,IAAI,qGAAqG,CACvI,CAAC;IACJ,CAAC;IAED,OAAO;QACL,CAAC,gBAAgB,CAAC,EAAE,IAAI;QACxB,KAAK,EAAE,IAAI;QACX,KAAK,EAAE,YAAY;QACnB,OAAO,EAAE,OAAO,CAAC,MAAM;QACvB,OAAO;KACR,CAAC;AACJ,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,sBAAsB,CAAC,KAAc;IACnD,OAAO,CACL,OAAO,KAAK,KAAK,QAAQ;QACzB,KAAK,KAAK,IAAI;QACd,gBAAgB,IAAI,KAAK;QACxB,KAAiC,CAAC,gBAAgB,CAAC,KAAK,IAAI,CAC9D,CAAC;AACJ,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,aAAa,CAAC,MAA2C;IACvE,IAAI,MAAM,IAAI,MAAM,IAAI,OAAO,MAAM,CAAC,IAAI,KAAK,QAAQ,EAAE,CAAC;QACxD,OAAO,MAAM,CAAC,IAAI,CAAC;IACrB,CAAC;IACD,OAAO,MAA0B,CAAC;AACpC,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,iBAAiB,CAAC,MAA2C;IAC3E,IAAI,UAAU,IAAI,MAAM,EAAE,CAAC;QACzB,OAAO,MAAM,CAAC,QAAQ,CAAC;IACzB,CAAC;IACD,OAAO,SAAS,CAAC;AACnB,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,cAAc,CAC5B,MAAe;IAEf,OAAO,MAAM,CAAC,IAAI,CAAC,MAAM,CAAsB,CAAC;AAClD,CAAC;AAOD;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,UAAU,MAAM,CACpB,IAAO,EACP,OAA2C;IAE3C,OAAO;QACL,IAAI;QACJ,GAAG,OAAO;KACX,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"datasource.test.d.ts","sourceRoot":"","sources":["../../src/schema/datasource.test.ts"],"names":[],"mappings":""}
|