@tinybirdco/sdk 0.0.43 → 0.0.45
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 +53 -0
- package/dist/cli/commands/init.js +2 -2
- package/dist/cli/commands/init.test.js +1 -1
- package/dist/cli/commands/init.test.js.map +1 -1
- package/dist/cli/commands/migrate.d.ts.map +1 -1
- package/dist/cli/commands/migrate.js +4 -3
- package/dist/cli/commands/migrate.js.map +1 -1
- package/dist/cli/commands/migrate.test.js +42 -4
- package/dist/cli/commands/migrate.test.js.map +1 -1
- package/dist/client/preview.js +1 -1
- package/dist/client/preview.js.map +1 -1
- package/dist/codegen/index.js +4 -4
- package/dist/codegen/index.js.map +1 -1
- package/dist/codegen/index.test.js +3 -3
- package/dist/codegen/index.test.js.map +1 -1
- package/dist/generator/client.js +1 -1
- package/dist/generator/connection.d.ts +1 -1
- package/dist/generator/connection.d.ts.map +1 -1
- package/dist/generator/connection.js +25 -2
- package/dist/generator/connection.js.map +1 -1
- package/dist/generator/connection.test.js +37 -14
- package/dist/generator/connection.test.js.map +1 -1
- package/dist/generator/datasource.d.ts.map +1 -1
- package/dist/generator/datasource.js +23 -0
- package/dist/generator/datasource.js.map +1 -1
- package/dist/generator/datasource.test.js +49 -5
- package/dist/generator/datasource.test.js.map +1 -1
- package/dist/index.d.ts +5 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/index.test.d.ts +2 -0
- package/dist/index.test.d.ts.map +1 -0
- package/dist/index.test.js +12 -0
- package/dist/index.test.js.map +1 -0
- package/dist/migrate/emit-ts.d.ts.map +1 -1
- package/dist/migrate/emit-ts.js +69 -13
- package/dist/migrate/emit-ts.js.map +1 -1
- package/dist/migrate/parse-connection.d.ts +2 -2
- package/dist/migrate/parse-connection.d.ts.map +1 -1
- package/dist/migrate/parse-connection.js +61 -18
- package/dist/migrate/parse-connection.js.map +1 -1
- package/dist/migrate/parse-datasource.d.ts.map +1 -1
- package/dist/migrate/parse-datasource.js +31 -0
- package/dist/migrate/parse-datasource.js.map +1 -1
- package/dist/migrate/types.d.ts +18 -1
- package/dist/migrate/types.d.ts.map +1 -1
- package/dist/schema/connection.d.ts +49 -6
- package/dist/schema/connection.d.ts.map +1 -1
- package/dist/schema/connection.js +44 -9
- package/dist/schema/connection.js.map +1 -1
- package/dist/schema/connection.test.js +72 -17
- package/dist/schema/connection.test.js.map +1 -1
- package/dist/schema/datasource.d.ts +16 -1
- package/dist/schema/datasource.d.ts.map +1 -1
- package/dist/schema/datasource.js +3 -0
- package/dist/schema/datasource.js.map +1 -1
- package/dist/schema/datasource.test.js +21 -0
- package/dist/schema/datasource.test.js.map +1 -1
- package/package.json +1 -1
- package/src/cli/commands/init.test.ts +1 -1
- package/src/cli/commands/init.ts +2 -2
- package/src/cli/commands/migrate.test.ts +58 -4
- package/src/cli/commands/migrate.ts +6 -4
- package/src/client/preview.ts +1 -1
- package/src/codegen/index.test.ts +3 -3
- package/src/codegen/index.ts +4 -4
- package/src/generator/client.ts +1 -1
- package/src/generator/connection.test.ts +45 -14
- package/src/generator/connection.ts +30 -2
- package/src/generator/datasource.test.ts +57 -5
- package/src/generator/datasource.ts +38 -1
- package/src/index.test.ts +13 -0
- package/src/index.ts +21 -4
- package/src/migrate/emit-ts.ts +80 -16
- package/src/migrate/parse-connection.ts +108 -30
- package/src/migrate/parse-datasource.ts +46 -1
- package/src/migrate/types.ts +24 -2
- package/src/schema/connection.test.ts +92 -17
- package/src/schema/connection.ts +86 -10
- package/src/schema/datasource.test.ts +25 -0
- package/src/schema/datasource.ts +21 -1
|
@@ -9,6 +9,7 @@ import {
|
|
|
9
9
|
} from "./datasource.js";
|
|
10
10
|
import { t } from "./types.js";
|
|
11
11
|
import { engine } from "./engines.js";
|
|
12
|
+
import { defineKafkaConnection, defineS3Connection } from "./connection.js";
|
|
12
13
|
|
|
13
14
|
describe("Datasource Schema", () => {
|
|
14
15
|
describe("defineDatasource", () => {
|
|
@@ -85,6 +86,30 @@ describe("Datasource Schema", () => {
|
|
|
85
86
|
});
|
|
86
87
|
expect(ds2._name).toBe("events_v2");
|
|
87
88
|
});
|
|
89
|
+
|
|
90
|
+
it("throws when both kafka and s3 ingestion are configured", () => {
|
|
91
|
+
const kafkaConn = defineKafkaConnection("my_kafka", {
|
|
92
|
+
bootstrapServers: "kafka.example.com:9092",
|
|
93
|
+
});
|
|
94
|
+
const s3Conn = defineS3Connection("my_s3", {
|
|
95
|
+
region: "us-east-1",
|
|
96
|
+
arn: "arn:aws:iam::123456789012:role/tinybird-s3-access",
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
expect(() =>
|
|
100
|
+
defineDatasource("events", {
|
|
101
|
+
schema: { id: t.string() },
|
|
102
|
+
kafka: {
|
|
103
|
+
connection: kafkaConn,
|
|
104
|
+
topic: "events",
|
|
105
|
+
},
|
|
106
|
+
s3: {
|
|
107
|
+
connection: s3Conn,
|
|
108
|
+
bucketUri: "s3://my-bucket/events/*.csv",
|
|
109
|
+
},
|
|
110
|
+
})
|
|
111
|
+
).toThrow("Datasource cannot define both `kafka` and `s3` ingestion options.");
|
|
112
|
+
});
|
|
88
113
|
});
|
|
89
114
|
|
|
90
115
|
describe("isDatasourceDefinition", () => {
|
package/src/schema/datasource.ts
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
|
|
6
6
|
import type { AnyTypeValidator } from "./types.js";
|
|
7
7
|
import type { EngineConfig } from "./engines.js";
|
|
8
|
-
import type { KafkaConnectionDefinition } from "./connection.js";
|
|
8
|
+
import type { KafkaConnectionDefinition, S3ConnectionDefinition } from "./connection.js";
|
|
9
9
|
import type { TokenDefinition, DatasourceTokenScope } from "./token.js";
|
|
10
10
|
|
|
11
11
|
// Symbol for brand typing - use Symbol.for() for global registry
|
|
@@ -68,6 +68,20 @@ export interface KafkaConfig {
|
|
|
68
68
|
autoOffsetReset?: "earliest" | "latest";
|
|
69
69
|
}
|
|
70
70
|
|
|
71
|
+
/**
|
|
72
|
+
* S3 import configuration for a datasource
|
|
73
|
+
*/
|
|
74
|
+
export interface S3Config {
|
|
75
|
+
/** S3 connection to use */
|
|
76
|
+
connection: S3ConnectionDefinition;
|
|
77
|
+
/** S3 bucket URI, for example: s3://my-bucket/path/*.csv */
|
|
78
|
+
bucketUri: string;
|
|
79
|
+
/** Import schedule, for example: @auto or @once */
|
|
80
|
+
schedule?: string;
|
|
81
|
+
/** Incremental import lower bound timestamp expression */
|
|
82
|
+
fromTimestamp?: string;
|
|
83
|
+
}
|
|
84
|
+
|
|
71
85
|
/**
|
|
72
86
|
* Options for defining a datasource
|
|
73
87
|
*/
|
|
@@ -95,6 +109,8 @@ export interface DatasourceOptions<TSchema extends SchemaDefinition> {
|
|
|
95
109
|
forwardQuery?: string;
|
|
96
110
|
/** Kafka ingestion configuration */
|
|
97
111
|
kafka?: KafkaConfig;
|
|
112
|
+
/** S3 ingestion configuration */
|
|
113
|
+
s3?: S3Config;
|
|
98
114
|
}
|
|
99
115
|
|
|
100
116
|
/**
|
|
@@ -152,6 +168,10 @@ export function defineDatasource<TSchema extends SchemaDefinition>(
|
|
|
152
168
|
);
|
|
153
169
|
}
|
|
154
170
|
|
|
171
|
+
if (options.kafka && options.s3) {
|
|
172
|
+
throw new Error("Datasource cannot define both `kafka` and `s3` ingestion options.");
|
|
173
|
+
}
|
|
174
|
+
|
|
155
175
|
return {
|
|
156
176
|
[DATASOURCE_BRAND]: true,
|
|
157
177
|
_name: name,
|