@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.
Files changed (82) hide show
  1. package/README.md +53 -0
  2. package/dist/cli/commands/init.js +2 -2
  3. package/dist/cli/commands/init.test.js +1 -1
  4. package/dist/cli/commands/init.test.js.map +1 -1
  5. package/dist/cli/commands/migrate.d.ts.map +1 -1
  6. package/dist/cli/commands/migrate.js +4 -3
  7. package/dist/cli/commands/migrate.js.map +1 -1
  8. package/dist/cli/commands/migrate.test.js +42 -4
  9. package/dist/cli/commands/migrate.test.js.map +1 -1
  10. package/dist/client/preview.js +1 -1
  11. package/dist/client/preview.js.map +1 -1
  12. package/dist/codegen/index.js +4 -4
  13. package/dist/codegen/index.js.map +1 -1
  14. package/dist/codegen/index.test.js +3 -3
  15. package/dist/codegen/index.test.js.map +1 -1
  16. package/dist/generator/client.js +1 -1
  17. package/dist/generator/connection.d.ts +1 -1
  18. package/dist/generator/connection.d.ts.map +1 -1
  19. package/dist/generator/connection.js +25 -2
  20. package/dist/generator/connection.js.map +1 -1
  21. package/dist/generator/connection.test.js +37 -14
  22. package/dist/generator/connection.test.js.map +1 -1
  23. package/dist/generator/datasource.d.ts.map +1 -1
  24. package/dist/generator/datasource.js +23 -0
  25. package/dist/generator/datasource.js.map +1 -1
  26. package/dist/generator/datasource.test.js +49 -5
  27. package/dist/generator/datasource.test.js.map +1 -1
  28. package/dist/index.d.ts +5 -5
  29. package/dist/index.d.ts.map +1 -1
  30. package/dist/index.js +2 -2
  31. package/dist/index.js.map +1 -1
  32. package/dist/index.test.d.ts +2 -0
  33. package/dist/index.test.d.ts.map +1 -0
  34. package/dist/index.test.js +12 -0
  35. package/dist/index.test.js.map +1 -0
  36. package/dist/migrate/emit-ts.d.ts.map +1 -1
  37. package/dist/migrate/emit-ts.js +69 -13
  38. package/dist/migrate/emit-ts.js.map +1 -1
  39. package/dist/migrate/parse-connection.d.ts +2 -2
  40. package/dist/migrate/parse-connection.d.ts.map +1 -1
  41. package/dist/migrate/parse-connection.js +61 -18
  42. package/dist/migrate/parse-connection.js.map +1 -1
  43. package/dist/migrate/parse-datasource.d.ts.map +1 -1
  44. package/dist/migrate/parse-datasource.js +31 -0
  45. package/dist/migrate/parse-datasource.js.map +1 -1
  46. package/dist/migrate/types.d.ts +18 -1
  47. package/dist/migrate/types.d.ts.map +1 -1
  48. package/dist/schema/connection.d.ts +49 -6
  49. package/dist/schema/connection.d.ts.map +1 -1
  50. package/dist/schema/connection.js +44 -9
  51. package/dist/schema/connection.js.map +1 -1
  52. package/dist/schema/connection.test.js +72 -17
  53. package/dist/schema/connection.test.js.map +1 -1
  54. package/dist/schema/datasource.d.ts +16 -1
  55. package/dist/schema/datasource.d.ts.map +1 -1
  56. package/dist/schema/datasource.js +3 -0
  57. package/dist/schema/datasource.js.map +1 -1
  58. package/dist/schema/datasource.test.js +21 -0
  59. package/dist/schema/datasource.test.js.map +1 -1
  60. package/package.json +1 -1
  61. package/src/cli/commands/init.test.ts +1 -1
  62. package/src/cli/commands/init.ts +2 -2
  63. package/src/cli/commands/migrate.test.ts +58 -4
  64. package/src/cli/commands/migrate.ts +6 -4
  65. package/src/client/preview.ts +1 -1
  66. package/src/codegen/index.test.ts +3 -3
  67. package/src/codegen/index.ts +4 -4
  68. package/src/generator/client.ts +1 -1
  69. package/src/generator/connection.test.ts +45 -14
  70. package/src/generator/connection.ts +30 -2
  71. package/src/generator/datasource.test.ts +57 -5
  72. package/src/generator/datasource.ts +38 -1
  73. package/src/index.test.ts +13 -0
  74. package/src/index.ts +21 -4
  75. package/src/migrate/emit-ts.ts +80 -16
  76. package/src/migrate/parse-connection.ts +108 -30
  77. package/src/migrate/parse-datasource.ts +46 -1
  78. package/src/migrate/types.ts +24 -2
  79. package/src/schema/connection.test.ts +92 -17
  80. package/src/schema/connection.ts +86 -10
  81. package/src/schema/datasource.test.ts +25 -0
  82. 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", () => {
@@ -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,