@distilled.cloud/tinybird 0.0.0 → 1.0.0-rc.22

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 (113) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +128 -4
  3. package/lib/.lazy.json +1 -0
  4. package/lib/_bundle/sdk.js +2 -0
  5. package/lib/_bundle/sdk.js.map +1 -0
  6. package/lib/credentials.d.ts +29 -0
  7. package/lib/credentials.d.ts.map +1 -0
  8. package/lib/credentials.js +1 -0
  9. package/lib/errors.d.ts +52 -0
  10. package/lib/errors.d.ts.map +1 -0
  11. package/lib/errors.js +1 -0
  12. package/lib/index.d.ts +48 -0
  13. package/lib/index.d.ts.map +1 -0
  14. package/lib/index.js +5 -0
  15. package/lib/protocol.d.ts +19 -0
  16. package/lib/protocol.d.ts.map +1 -0
  17. package/lib/protocol.js +1 -0
  18. package/lib/retry.d.ts +50 -0
  19. package/lib/retry.d.ts.map +1 -0
  20. package/lib/retry.js +1 -0
  21. package/lib/services/analyze.d.ts +17 -0
  22. package/lib/services/analyze.d.ts.map +1 -0
  23. package/lib/services/analyze.js +2 -0
  24. package/lib/services/analyze.js.map +1 -0
  25. package/lib/services/api_endpoints.d.ts +26 -0
  26. package/lib/services/api_endpoints.d.ts.map +1 -0
  27. package/lib/services/api_endpoints.js +2 -0
  28. package/lib/services/api_endpoints.js.map +1 -0
  29. package/lib/services/copy_pipes.d.ts +102 -0
  30. package/lib/services/copy_pipes.d.ts.map +1 -0
  31. package/lib/services/copy_pipes.js +2 -0
  32. package/lib/services/copy_pipes.js.map +1 -0
  33. package/lib/services/datasource.d.ts +171 -0
  34. package/lib/services/datasource.d.ts.map +1 -0
  35. package/lib/services/datasource.js +2 -0
  36. package/lib/services/datasource.js.map +1 -0
  37. package/lib/services/environment_variables.d.ts +61 -0
  38. package/lib/services/environment_variables.d.ts.map +1 -0
  39. package/lib/services/environment_variables.js +2 -0
  40. package/lib/services/environment_variables.js.map +1 -0
  41. package/lib/services/events.d.ts +21 -0
  42. package/lib/services/events.d.ts.map +1 -0
  43. package/lib/services/events.js +2 -0
  44. package/lib/services/events.js.map +1 -0
  45. package/lib/services/index.d.ts +14 -0
  46. package/lib/services/index.d.ts.map +1 -0
  47. package/lib/services/index.js +13 -0
  48. package/lib/services/jobs.d.ts +45 -0
  49. package/lib/services/jobs.d.ts.map +1 -0
  50. package/lib/services/jobs.js +2 -0
  51. package/lib/services/jobs.js.map +1 -0
  52. package/lib/services/materialized_views.d.ts +64 -0
  53. package/lib/services/materialized_views.d.ts.map +1 -0
  54. package/lib/services/materialized_views.js +2 -0
  55. package/lib/services/materialized_views.js.map +1 -0
  56. package/lib/services/organizations.d.ts +214 -0
  57. package/lib/services/organizations.d.ts.map +1 -0
  58. package/lib/services/organizations.js +2 -0
  59. package/lib/services/organizations.js.map +1 -0
  60. package/lib/services/pipe.d.ts +243 -0
  61. package/lib/services/pipe.d.ts.map +1 -0
  62. package/lib/services/pipe.js +2 -0
  63. package/lib/services/pipe.js.map +1 -0
  64. package/lib/services/query.d.ts +50 -0
  65. package/lib/services/query.d.ts.map +1 -0
  66. package/lib/services/query.js +2 -0
  67. package/lib/services/query.js.map +1 -0
  68. package/lib/services/sink_pipes.d.ts +95 -0
  69. package/lib/services/sink_pipes.d.ts.map +1 -0
  70. package/lib/services/sink_pipes.js +2 -0
  71. package/lib/services/sink_pipes.js.map +1 -0
  72. package/lib/services/token.d.ts +107 -0
  73. package/lib/services/token.d.ts.map +1 -0
  74. package/lib/services/token.js +2 -0
  75. package/lib/services/token.js.map +1 -0
  76. package/lib/services.lazy/analyze.js +1 -0
  77. package/lib/services.lazy/api_endpoints.js +1 -0
  78. package/lib/services.lazy/copy_pipes.js +1 -0
  79. package/lib/services.lazy/datasource.js +1 -0
  80. package/lib/services.lazy/environment_variables.js +1 -0
  81. package/lib/services.lazy/events.js +1 -0
  82. package/lib/services.lazy/index.js +3 -0
  83. package/lib/services.lazy/jobs.js +1 -0
  84. package/lib/services.lazy/materialized_views.js +1 -0
  85. package/lib/services.lazy/organizations.js +1 -0
  86. package/lib/services.lazy/pipe.js +1 -0
  87. package/lib/services.lazy/query.js +1 -0
  88. package/lib/services.lazy/sink_pipes.js +1 -0
  89. package/lib/services.lazy/token.js +1 -0
  90. package/lib/traits.d.ts +10 -0
  91. package/lib/traits.d.ts.map +1 -0
  92. package/lib/traits.js +1 -0
  93. package/package.json +76 -2
  94. package/src/credentials.ts +76 -0
  95. package/src/errors.ts +83 -0
  96. package/src/index.ts +47 -0
  97. package/src/protocol.ts +48 -0
  98. package/src/retry.ts +69 -0
  99. package/src/services/analyze.ts +75 -0
  100. package/src/services/api_endpoints.ts +115 -0
  101. package/src/services/copy_pipes.ts +315 -0
  102. package/src/services/datasource.ts +438 -0
  103. package/src/services/environment_variables.ts +213 -0
  104. package/src/services/events.ts +86 -0
  105. package/src/services/index.ts +14 -0
  106. package/src/services/jobs.ts +156 -0
  107. package/src/services/materialized_views.ts +200 -0
  108. package/src/services/organizations.ts +552 -0
  109. package/src/services/pipe.ts +700 -0
  110. package/src/services/query.ts +150 -0
  111. package/src/services/sink_pipes.ts +295 -0
  112. package/src/services/token.ts +359 -0
  113. package/src/traits.ts +47 -0
@@ -0,0 +1,438 @@
1
+ import * as API from "@distilled.cloud/core/api";
2
+ // AUTO-GENERATED by scripts/generate.ts from .generated-specs (specs/spec-mirror-tinybird/specs/api-reference). Do not edit.
3
+ import * as S from "@distilled.cloud/core/schema-lite";
4
+ import * as __L from "@distilled.cloud/core/schema-lite";
5
+ import type * as Redacted from "effect/Redacted";
6
+ import { TinybirdServiceErrors } from "../errors.ts";
7
+ import { TinybirdProtocol, type TinybirdOpError, type TinybirdOpContext } from "../protocol.ts";
8
+ import * as Retry from "../retry.ts";
9
+ import * as T from "../traits.ts";
10
+ // Schema table, filled on first reach (see __S at the end).
11
+ const __s: any[] = [];
12
+
13
+ export type { TinybirdOpError, TinybirdOpContext };
14
+
15
+ /** Span facts shared by every operation (com.distilled.telemetry#service). */
16
+ const TELEMETRY = {
17
+ system: "tinybird-api",
18
+ responseHeaders: [
19
+ { header: "x-request-id", name: "http.response.header.x-request-id", transform: "list" },
20
+ { header: "request-id", name: "http.response.header.request-id", transform: "list" },
21
+ ],
22
+ prefix: "Tinybird",
23
+ service: "Datasource",
24
+ labels: "tinybird",
25
+ propagate: "w3c",
26
+ } as const;
27
+
28
+ export interface AlterDatasourceRequest {
29
+ datasource: string;
30
+ /** Optional. Set the whole schema that adds new columns to the existing ones of a Data Source. */
31
+ schema?: string | undefined;
32
+ /** Optional. Sets the description of the Data Source. */
33
+ description?: string | undefined;
34
+ /** Optional. Default: false. When set to true, the 'value' column of a Kafka Data Source will save the JSON as a raw string. */
35
+ kafka_store_raw_value?: boolean | undefined;
36
+ /** Optional. Default: false. When set to true, the 'headers' of a Kafka Data Source will be saved as a binary map. */
37
+ kafka_store_headers?: boolean | undefined;
38
+ /** Optional. Set to any value accepted in ClickHouse for a TTL or to 'false' to remove the TTL. See example below. */
39
+ ttl?: string | undefined;
40
+ /** Optional. Default: false. Set to true to show what would be modified in the Data Source, without running any modification at all. */
41
+ dry?: boolean | undefined;
42
+ }
43
+ export type AlterDatasourceResponseBodyMap = { [key: string]: unknown | undefined };
44
+ export type AlterDatasourceResponse = AlterDatasourceResponseBodyMap;
45
+ export interface CreateDatasourceRequest {
46
+ /** Default: `create`. Other modes: `append` and `replace`. <br> The `create` mode creates a new Data Source and attempts to import the data of the CSV if a URL is provided or the body contains any data. <br> The `append` mode inserts the new rows provided into an existing Data Source (it will also create it if it does not exist yet). <br> The `replace` mode will remove the previous Data Source and its data and replace it with the new one; Pipes or queries pointing to this Data Source will immediately start returning data from the new one and without disruption once the replace operation is complete. <br> <br> The `create` mode will automatically name the Data Source if no `name` parameter is provided; for the `append` and `replace` modes to work, the `name` parameter must be provided and the schema must be compatible. */
47
+ mode?: string | undefined;
48
+ /** Optional. Name of the Data Source to create, append or replace data. This parameter is mandatory when using the `append` or `replace` modes. */
49
+ name?: string | undefined;
50
+ /** Optional. The URL of the CSV with the data to be imported */
51
+ url?: string | undefined;
52
+ /** Optional. The one-character string separating the fields. We try to guess the delimiter based on the CSV contents using some statistics, but sometimes we fail to identify the correct one. If you know your CSV's field delimiter, you can use this parameter to explicitly define it. */
53
+ dialect_delimiter?: string | undefined;
54
+ /** Optional. The one- or two-character string separating the records. We try to guess the delimiter based on the CSV contents using some statistics, but sometimes we fail to identify the correct one. If you know your CSV's record delimiter, you can use this parameter to explicitly define it. */
55
+ dialect_new_line?: string | undefined;
56
+ /** Optional. The escapechar removes any special meaning from the following character. This is useful if the CSV does not use double quotes to encapsulate a column but uses double quotes in the content of a column and it is escaped with, e.g. a backslash. */
57
+ dialect_escapechar?: string | undefined;
58
+ /** Optional. Data Source schema in the format 'column_name Type, column_name_2 Type2...'. When creating a Data Source with format `ndjson` the `schema` must include the `jsonpath` for each column, see the `JSONPaths` section for more details. */
59
+ schema?: string | undefined;
60
+ /** Optional. Index definitions, one per line, to create alongside the Data Source. */
61
+ indexes?: string | undefined;
62
+ /** Optional. Engine for the underlying data. Requires the `schema` parameter. */
63
+ engine?: string | undefined;
64
+ /** Default: `false`. When using `true` and sending the data in the request body, Tinybird will return block status while loading using Line-delimited JSON. */
65
+ progress?: string | undefined;
66
+ /** Auth token with create or append permissions. Required only if no Bearer Authorization header is found */
67
+ token?: string | Redacted.Redacted<string> | undefined;
68
+ /** Default: `true` The `type_guessing` parameter is not taken into account when replacing or appending data to an existing Data Source. When using `false` all columns are created as `String` otherwise it tries to guess the column types based on the CSV contents. Sometimes you are not familiar with the data and the first step is to get familiar with it: by disabling the type guessing, we enable you to quickly import everything as strings that you can explore with SQL and cast to the right type or shape in whatever way you see fit via a Pipe. */
69
+ type_guessing?: string | undefined;
70
+ /** Optional. Enables returning debug information from logs. It can include `blocks`, `block_log` and/or `hook_log` */
71
+ debug?: string | undefined;
72
+ /** Optional. When used in combination with the `replace` mode it allows you to replace a portion of your Data Source that matches the `replace_condition` SQL statement with the contents of the `url` or query passed as a parameter. See this [guide](https://www.tinybird.co/guide/replacing-and-deleting-data#replace-data-selectively) to learn more. */
73
+ replace_condition?: string | undefined;
74
+ /** Optional. When `true` and using `mode=replace`, incompatible rows that do not match the partition key are skipped instead of failing the operation. */
75
+ skip_incompatible_partition_key?: boolean | undefined;
76
+ /** Default: `csv`. Indicates the format of the data to be ingested in the Data Source. By default is `csv` and you should specify `format=ndjson` for NDJSON format, and `format=parquet` for Parquet files. */
77
+ format?: string | undefined;
78
+ /** Optional. Connector service used for managed imports. Supported values: `s3`, `s3_iamrole`, `gcs` or `dynamodb`. */
79
+ service?: string | undefined;
80
+ /** Optional. Connector identifier to use together with `service` when importing from external sources (required for S3/GCS/DynamoDB). */
81
+ connector?: string | undefined;
82
+ /** Required when `service` is `s3`, `s3_iamrole` or `gcs`. URI of the bucket to ingest from, following the provider naming rules. */
83
+ bucket_uri?: string | undefined;
84
+ /** Optional when using a bucket `service`. ISO 8601 timestamp that sets the earliest object modification time to ingest. */
85
+ from_time?: string | undefined;
86
+ /** Optional when using a bucket `service`. ISO 8601 timestamp that sets the latest object modification time to ingest. For @auto ingestion from blob storages, it is ignored. */
87
+ to_time?: string | undefined;
88
+ /** Required when `service` is `dynamodb`. ARN of the DynamoDB table to ingest. */
89
+ dynamodb_table_arn?: string | undefined;
90
+ /** A local CSV file to import (multipart part `csv`). */
91
+ csv?: Uint8Array | undefined;
92
+ /** A local NDJSON file to import (multipart part `ndjson`). */
93
+ ndjson?: Uint8Array | undefined;
94
+ /** Engine sorting key (`ORDER BY`). */
95
+ engine_sorting_key?: string | undefined;
96
+ /** ReplacingMergeTree version column. */
97
+ engine_ver?: string | undefined;
98
+ /** Engine settings, e.g. `index_granularity=2048, ttl_only_drop_parts=false`. */
99
+ engine_settings?: string | undefined;
100
+ }
101
+ export type CreateDatasourceResponseBodyMap = { [key: string]: unknown | undefined };
102
+ export type CreateDatasourceResponse = CreateDatasourceResponseBodyMap;
103
+ export interface DeleteDatasourceRequest {
104
+ datasource: string;
105
+ /** Default: `false` . The `force` parameter is taken into account when trying to delete Materialized Views. By default, when using `false` the deletion will not be carried out; you can enable it by setting it to `true`. If the given Data Source is being used as the trigger of a Materialized Node, it will not be deleted in any case. */
106
+ force?: string | undefined;
107
+ /** Default: `false`. It allows you to test the deletion. When using `true` it will execute all deletion validations and return the possible affected materializations and other dependencies of a given Data Source. */
108
+ dry_run?: string | undefined;
109
+ /** Auth token. Only required if no Bearer Authorization header is sent. It must have `DROP:datasource_name` scope for the given Data Source. */
110
+ token?: string | Redacted.Redacted<string> | undefined;
111
+ }
112
+ export type DeleteDatasourceResponseBodyMap = { [key: string]: unknown | undefined };
113
+ export type DeleteDatasourceResponse = DeleteDatasourceResponseBodyMap;
114
+ export interface DeleteDatasourceRowsRequest {
115
+ datasource: string;
116
+ /** Mandatory. A string representing the WHERE SQL clause you'd add to a regular DELETE FROM <table> WHERE <delete_condition> statement. Most of the times you might want to write a simple `delete_condition` such as `column_name=value` but any valid SQL statement including conditional operators is valid */
117
+ delete_condition: string;
118
+ /** Default: `false`. It allows you to test the deletion. When using `true` it will execute all deletion validations and return number of matched `rows_to_be_deleted`. */
119
+ dry_run?: string | undefined;
120
+ }
121
+ export type DeleteDatasourceRowsResponseBodyMap = { [key: string]: unknown | undefined };
122
+ export type DeleteDatasourceRowsResponse = DeleteDatasourceRowsResponseBodyMap;
123
+ export interface GetDatasourceRequest {
124
+ datasource: string;
125
+ /** comma separated list of the Data Source attributes to return in the response. Example: `attrs=name,id,engine`. Leave empty to return a full response */
126
+ attrs?: string | undefined;
127
+ }
128
+ export type GetDatasourceResponseBodyMap = { [key: string]: unknown | undefined };
129
+ export type GetDatasourceResponse = GetDatasourceResponseBodyMap;
130
+ export interface ListDatasourcesRequest {
131
+ /** comma separated list of the Data Source attributes to return in the response. Example: `attrs=name,id,engine`. Leave empty to return a full response */
132
+ attrs?: string | undefined;
133
+ }
134
+ export type ListDatasourcesResponseBodyMap = { [key: string]: unknown | undefined };
135
+ export type ListDatasourcesResponse = ListDatasourcesResponseBodyMap;
136
+ export interface TruncateDatasourceRequest {
137
+ datasource: string;
138
+ }
139
+ export type TruncateDatasourceResponseBodyMap = { [key: string]: unknown | undefined };
140
+ export type TruncateDatasourceResponse = TruncateDatasourceResponseBodyMap;
141
+ export interface UpdateDatasourceRequest {
142
+ datasource: string;
143
+ /** new name for the Data Source */
144
+ name?: string | undefined;
145
+ /** Auth token. Only required if no Bearer Authorization header is sent. It should have `DATASOURCES:CREATE` scope for the given Data Source */
146
+ token?: string | Redacted.Redacted<string> | undefined;
147
+ /** Connector ID to link it to */
148
+ connector?: string | undefined;
149
+ /** Optional: custom query to collect from the external data source */
150
+ query?: string | undefined;
151
+ }
152
+ export type UpdateDatasourceResponseBodyMap = { [key: string]: unknown | undefined };
153
+ export type UpdateDatasourceResponse = UpdateDatasourceResponseBodyMap;
154
+ export type AlterDatasourceError = TinybirdOpError;
155
+ /** Modify the Data Source schema. This endpoint supports the operation to alter the following fields of a Data Source: The schema parameter can be used to add new columns at the end of the existing ones in a Data Source. Be aware that currently we don't validate if the change will affect the existing MVs (Materialized Views) attached to the Data Source to be modified, so this change may break existing MVs. For example, avoid changing a Data Source that has a MV created with something like `SELECT * FROM Data Source ...`. If you want to have forward compatible MVs with column additions, create them especifying the columns instead of using the `*` operator. Also, take in account that, for now, the only engines supporting adding new columns are those inside the MergeTree family. To add a column to a Data Source, call this endpoint with the Data Source name and the new schema definition. For example, having a Data Source created like this: if you want to add a new column 'concept String', you need to call this endpoint with the new schema: If everything went ok, you will get the operations done in the response: You can also view the inferred operations without executing them adding `dry=true` in the parameters. - To modify the description of a Data Source: - To save in the "value" column of a Kafka Data Source the JSON as a raw string: - To modify the TTL of a Data Source: - Use a time-based column from the datasource schema (e.g. a DateTime column). - Express the TTL in valid ClickHouse syntax using toInterval*() functions. - URL-encode the expression to ensure it's parsed correctly. Supported intervals include toIntervalMinute(), toIntervalHour(), toIntervalDay(), toIntervalMonth(), etc. - To remove the TTL of a Data Source: - To add default values to the columns of a Data Source: - To add default values to the columns of a NDJSON Data Source, add the default definition after the jsonpath definition: - To make a column nullable, change the type of the column adding the Nullable type prefix to old one: - To drop a column, just remove the column from the schema definition. It will not be possible removing columns that are part of the primary or partition key: You can also alter the JSONPaths of existing Data Sources. In that case you have to specify the [JSONPath](/docs/guides/ingesting-data/ingest-ndjson-data) in the schema in the same way as when you created the Data Source. Reference: https://www.tinybird.co/docs/api-reference/datasource-api */
156
+ export const alterDatasource: API.OperationMethod<
157
+ AlterDatasourceRequest,
158
+ AlterDatasourceResponse,
159
+ AlterDatasourceError,
160
+ TinybirdOpContext
161
+ > = /*@__PURE__*/ API.make(() => ({
162
+ input: __S(0, __c0, 0) as any as S.Schema<AlterDatasourceRequest>,
163
+ output: __S(3, __c1, 1) as any as S.Schema<AlterDatasourceResponse>,
164
+ errors: [],
165
+ serviceErrors: TinybirdServiceErrors,
166
+ protocol: TinybirdProtocol,
167
+ retry: Retry.Retry,
168
+ telemetry: TELEMETRY,
169
+ span: "AlterDatasource",
170
+ }));
171
+
172
+ export type CreateDatasourceError = TinybirdOpError;
173
+ /** This endpoint supports 3 modes to enable 3 distinct operations, depending on the parameters provided: - Create a new Data Source with a schema - Append data to an existing Data Source - Replace data in an existing Data Source The mode is controlled by setting the `mode` parameter, for example, `-d "mode=create"`. Each mode has different [rate limits](/docs/api-reference/overview#limits). When importing remote files by URL, if the server hosting the remote file supports HTTP Range headers, the import process will be parallelized. Reference: https://www.tinybird.co/docs/api-reference/datasource-api */
174
+ export const createDatasource: API.OperationMethod<
175
+ CreateDatasourceRequest,
176
+ CreateDatasourceResponse,
177
+ CreateDatasourceError,
178
+ TinybirdOpContext
179
+ > = /*@__PURE__*/ API.make(() => ({
180
+ input: __S(4, __c2, 0) as any as S.Schema<CreateDatasourceRequest>,
181
+ output: __S(3, __c1, 1) as any as S.Schema<CreateDatasourceResponse>,
182
+ errors: [],
183
+ serviceErrors: TinybirdServiceErrors,
184
+ protocol: TinybirdProtocol,
185
+ retry: Retry.Retry,
186
+ telemetry: TELEMETRY,
187
+ span: "CreateDatasource",
188
+ }));
189
+
190
+ export type DeleteDatasourceError = TinybirdOpError;
191
+ /** Drops a Data Source from your account. Reference: https://www.tinybird.co/docs/api-reference/datasource-api */
192
+ export const deleteDatasource: API.OperationMethod<
193
+ DeleteDatasourceRequest,
194
+ DeleteDatasourceResponse,
195
+ DeleteDatasourceError,
196
+ TinybirdOpContext
197
+ > = /*@__PURE__*/ API.make(() => ({
198
+ input: __S(6, __c3, 0) as any as S.Schema<DeleteDatasourceRequest>,
199
+ output: __S(3, __c1, 1) as any as S.Schema<DeleteDatasourceResponse>,
200
+ errors: [],
201
+ serviceErrors: TinybirdServiceErrors,
202
+ protocol: TinybirdProtocol,
203
+ retry: Retry.Retry,
204
+ telemetry: TELEMETRY,
205
+ span: "DeleteDatasource",
206
+ }));
207
+
208
+ export type DeleteDatasourceRowsError = TinybirdOpError;
209
+ /** Deletes rows from a Data Source in your account given a SQL condition. Auth token in use must have the `DATASOURCES:CREATE` scope. When deleting rows from a Data Source, the response will not be the final result of the deletion but a Job. You can check the job status and progress using the [Jobs API](/docs/api-reference/jobs-api). In the response, `id`, `job_id`, and `delete_id` should have the same value: To check on the progress of the delete job, use the `job_id` from the Delete API response to query the [Jobs API](/docs/api-reference/jobs-api). For example, to check on the status of the above delete job: Would respond with: Tinybird uses ClickHouse as the underlying storage technology. ClickHouse features different strategies to store data, these different strategies define not only where and how the data is stored but what kind of data access, queries, and availability your data has. In ClickHouse terms, a Tinybird Data Source uses a [Table Engine](https://clickhouse.tech/docs/en/engines/table_engines/) that determines those factors. Currently, Tinybird supports deleting data for data sources with the following Engines: - MergeTree - ReplacingMergeTree - SummingMergeTree - AggregatingMergeTree - CollapsingMergeTree - VersionedCollapsingMergeTree If the Data Source has dependent Materialized Views, those won't be cascade deleted. In case you want to delete data from other dependent Materialized Views, you'll have to do a subsequent call to this method for the affected view with a proper `delete_condition`. This applies as well to the associated `quarantine` Data Source. Reference: https://www.tinybird.co/docs/api-reference/datasource-api */
210
+ export const deleteDatasourceRows: API.OperationMethod<
211
+ DeleteDatasourceRowsRequest,
212
+ DeleteDatasourceRowsResponse,
213
+ DeleteDatasourceRowsError,
214
+ TinybirdOpContext
215
+ > = /*@__PURE__*/ API.make(() => ({
216
+ input: __S(8, __c4, 0) as any as S.Schema<DeleteDatasourceRowsRequest>,
217
+ output: __S(3, __c1, 1) as any as S.Schema<DeleteDatasourceRowsResponse>,
218
+ errors: [],
219
+ serviceErrors: TinybirdServiceErrors,
220
+ protocol: TinybirdProtocol,
221
+ retry: Retry.Retry,
222
+ telemetry: TELEMETRY,
223
+ span: "DeleteDatasourceRows",
224
+ }));
225
+
226
+ export type GetDatasourceError = TinybirdOpError;
227
+ /** Get Data Source information and stats. The token provided must have read access to the Data Source. `id` and `name` are two ways to refer to the Data Source in SQL queries and API endpoints. The only difference is that the `id` never changes; it will work even if you change the `name` (which is the name used to display the Data Source in the UI). In general you can use `id` or `name` indistinctively: Using the above response as an example: `select count(1) from events_table` is equivalent to `select count(1) from t_bd1c62b5e67142bd9bf9a7f113a2b6ea` The id `t_bd1c62b5e67142bd9bf9a7f113a2b6ea` is not a descriptive name so you can add a description like `t_my_events_datasource.bd1c62b5e67142bd9bf9a7f113a2b6ea` The `statistics` property contains information about the table. Those numbers are an estimation: `bytes` is the estimated data size on disk and `row_count` the estimated number of rows. These statistics are updated whenever data is appended to the Data Source. The `used_by` property contains the list of pipes that are using this data source. Only Pipe `id` and `name` are sent. The `type` property indicates the `format` used when the Data Source was created. Available formats are `csv`, `ndjson`, and `parquet`. The Data Source `type` indicates what file format you can use to ingest data. Reference: https://www.tinybird.co/docs/api-reference/datasource-api */
228
+ export const getDatasource: API.OperationMethod<
229
+ GetDatasourceRequest,
230
+ GetDatasourceResponse,
231
+ GetDatasourceError,
232
+ TinybirdOpContext
233
+ > = /*@__PURE__*/ API.make(() => ({
234
+ input: __S(10, __c5, 0) as any as S.Schema<GetDatasourceRequest>,
235
+ output: __S(3, __c1, 1) as any as S.Schema<GetDatasourceResponse>,
236
+ errors: [],
237
+ serviceErrors: TinybirdServiceErrors,
238
+ protocol: TinybirdProtocol,
239
+ retry: Retry.Retry,
240
+ telemetry: TELEMETRY,
241
+ span: "GetDatasource",
242
+ }));
243
+
244
+ export type ListDatasourcesError = TinybirdOpError;
245
+ /** Get a list of the Data Sources in your account. The token you use to query the available Data Sources will determine what Data Sources get returned: only those accessible with the token you are using will be returned in the response. Note that the `statistics`'s `bytes` and `row_count` attributes might be `null` depending on how the Data Source was created. Reference: https://www.tinybird.co/docs/api-reference/datasource-api */
246
+ export const listDatasources: API.OperationMethod<
247
+ ListDatasourcesRequest,
248
+ ListDatasourcesResponse,
249
+ ListDatasourcesError,
250
+ TinybirdOpContext
251
+ > = /*@__PURE__*/ API.make(() => ({
252
+ input: __S(12, __c6, 0) as any as S.Schema<ListDatasourcesRequest>,
253
+ output: __S(3, __c1, 1) as any as S.Schema<ListDatasourcesResponse>,
254
+ errors: [],
255
+ serviceErrors: TinybirdServiceErrors,
256
+ protocol: TinybirdProtocol,
257
+ retry: Retry.Retry,
258
+ telemetry: TELEMETRY,
259
+ span: "ListDatasources",
260
+ }));
261
+
262
+ export type TruncateDatasourceError = TinybirdOpError;
263
+ /** Truncates a Data Source in your account. If the Data Source has dependent Materialized Views, those **won't** be truncated in cascade. In case you want to delete data from other dependent Materialized Views, you'll have to do a subsequent call to this method. Auth token in use must have the `DATASOURCES:CREATE` scope. This works as well for the `quarantine` table of a Data Source. Remember that the quarantine table for a Data Source has the same name but with the "_quarantine" suffix. Reference: https://www.tinybird.co/docs/api-reference/datasource-api */
264
+ export const truncateDatasource: API.OperationMethod<
265
+ TruncateDatasourceRequest,
266
+ TruncateDatasourceResponse,
267
+ TruncateDatasourceError,
268
+ TinybirdOpContext
269
+ > = /*@__PURE__*/ API.make(() => ({
270
+ input: __S(14, __c7, 0) as any as S.Schema<TruncateDatasourceRequest>,
271
+ output: __S(3, __c1, 1) as any as S.Schema<TruncateDatasourceResponse>,
272
+ errors: [],
273
+ serviceErrors: TinybirdServiceErrors,
274
+ protocol: TinybirdProtocol,
275
+ retry: Retry.Retry,
276
+ telemetry: TELEMETRY,
277
+ span: "TruncateDatasource",
278
+ }));
279
+
280
+ export type UpdateDatasourceError = TinybirdOpError;
281
+ /** Update Data Source attributes Reference: https://www.tinybird.co/docs/api-reference/datasource-api */
282
+ export const updateDatasource: API.OperationMethod<
283
+ UpdateDatasourceRequest,
284
+ UpdateDatasourceResponse,
285
+ UpdateDatasourceError,
286
+ TinybirdOpContext
287
+ > = /*@__PURE__*/ API.make(() => ({
288
+ input: __S(16, __c8, 0) as any as S.Schema<UpdateDatasourceRequest>,
289
+ output: __S(3, __c1, 1) as any as S.Schema<UpdateDatasourceResponse>,
290
+ errors: [],
291
+ serviceErrors: TinybirdServiceErrors,
292
+ protocol: TinybirdProtocol,
293
+ retry: Retry.Retry,
294
+ telemetry: TELEMETRY,
295
+ span: "UpdateDatasource",
296
+ }));
297
+
298
+ // Schema builders: each runs one schema initializer, on that schema's first use.
299
+ function __c0(j: number): any {
300
+ switch (j) {
301
+ case 0:
302
+ return S.suspend(() =>
303
+ S.Struct({
304
+ datasource: S.String.pipe(T.Label()),
305
+ schema: S.optional(S.String.pipe(T.Query())),
306
+ description: S.optional(S.String.pipe(T.Query())),
307
+ kafka_store_raw_value: S.optional(S.Boolean.pipe(T.Query())),
308
+ kafka_store_headers: S.optional(S.Boolean.pipe(T.Query())),
309
+ ttl: S.optional(S.String.pipe(T.Query())),
310
+ dry: S.optional(S.Boolean.pipe(T.Query())),
311
+ }).pipe(T.Http({ method: "POST", uri: "/v0/datasources/{datasource}/alter", code: 200 })),
312
+ ).annotate({ identifier: "AlterDatasourceRequest" });
313
+ }
314
+ }
315
+ function __c1(j: number): any {
316
+ switch (j) {
317
+ case 0:
318
+ return S.Record(S.String, S.Unknown);
319
+ case 1:
320
+ return S.suspend(() => __S(2, __c1, 0).pipe(T.RawResponseRoot())).annotate({
321
+ identifier: "AlterDatasourceResponse",
322
+ });
323
+ }
324
+ }
325
+ function __c2(j: number): any {
326
+ switch (j) {
327
+ case 0:
328
+ return S.suspend(() =>
329
+ S.Struct({
330
+ mode: S.optional(S.String.pipe(T.Query())),
331
+ name: S.optional(S.String.pipe(T.Query())),
332
+ url: S.optional(S.String.pipe(T.Query())),
333
+ dialect_delimiter: S.optional(S.String.pipe(T.Query())),
334
+ dialect_new_line: S.optional(S.String.pipe(T.Query())),
335
+ dialect_escapechar: S.optional(S.String.pipe(T.Query())),
336
+ schema: S.optional(S.String.pipe(T.Query())),
337
+ indexes: S.optional(S.String.pipe(T.Query())),
338
+ engine: S.optional(S.String.pipe(T.Query())),
339
+ progress: S.optional(S.String.pipe(T.Query())),
340
+ token: S.optional(S.String.pipe(T.Query(), T.SensitiveValue({}))),
341
+ type_guessing: S.optional(S.String.pipe(T.Query())),
342
+ debug: S.optional(S.String.pipe(T.Query())),
343
+ replace_condition: S.optional(S.String.pipe(T.Query())),
344
+ skip_incompatible_partition_key: S.optional(S.Boolean.pipe(T.Query())),
345
+ format: S.optional(S.String.pipe(T.Query())),
346
+ service: S.optional(S.String.pipe(T.Query())),
347
+ connector: S.optional(S.String.pipe(T.Query())),
348
+ bucket_uri: S.optional(S.String.pipe(T.Query())),
349
+ from_time: S.optional(S.String.pipe(T.Query())),
350
+ to_time: S.optional(S.String.pipe(T.Query())),
351
+ dynamodb_table_arn: S.optional(S.String.pipe(T.Query())),
352
+ csv: S.optional(S.instanceOf(Uint8Array)),
353
+ ndjson: S.optional(S.instanceOf(Uint8Array)),
354
+ engine_sorting_key: S.optional(S.String.pipe(T.Query())),
355
+ engine_ver: S.optional(S.String.pipe(T.Query())),
356
+ engine_settings: S.optional(S.String.pipe(T.Query())),
357
+ }).pipe(
358
+ T.Http({ method: "POST", uri: "/v0/datasources", code: 200, contentType: "multipart" }),
359
+ ),
360
+ ).annotate({ identifier: "CreateDatasourceRequest" });
361
+ }
362
+ }
363
+ function __c3(j: number): any {
364
+ switch (j) {
365
+ case 0:
366
+ return S.suspend(() =>
367
+ S.Struct({
368
+ datasource: S.String.pipe(T.Label()),
369
+ force: S.optional(S.String.pipe(T.Query())),
370
+ dry_run: S.optional(S.String.pipe(T.Query())),
371
+ token: S.optional(S.String.pipe(T.Query(), T.SensitiveValue({}))),
372
+ }).pipe(T.Http({ method: "DELETE", uri: "/v0/datasources/{datasource}", code: 200 })),
373
+ ).annotate({ identifier: "DeleteDatasourceRequest" });
374
+ }
375
+ }
376
+ function __c4(j: number): any {
377
+ switch (j) {
378
+ case 0:
379
+ return S.suspend(() =>
380
+ S.Struct({
381
+ datasource: S.String.pipe(T.Label()),
382
+ delete_condition: S.String.pipe(T.Query()),
383
+ dry_run: S.optional(S.String.pipe(T.Query())),
384
+ }).pipe(T.Http({ method: "POST", uri: "/v0/datasources/{datasource}/delete", code: 200 })),
385
+ ).annotate({ identifier: "DeleteDatasourceRowsRequest" });
386
+ }
387
+ }
388
+ function __c5(j: number): any {
389
+ switch (j) {
390
+ case 0:
391
+ return S.suspend(() =>
392
+ S.Struct({
393
+ datasource: S.String.pipe(T.Label()),
394
+ attrs: S.optional(S.String.pipe(T.Query())),
395
+ }).pipe(T.Http({ method: "GET", uri: "/v0/datasources/{datasource}", code: 200 })),
396
+ ).annotate({ identifier: "GetDatasourceRequest" });
397
+ }
398
+ }
399
+ function __c6(j: number): any {
400
+ switch (j) {
401
+ case 0:
402
+ return S.suspend(() =>
403
+ S.Struct({
404
+ attrs: S.optional(S.String.pipe(T.Query())),
405
+ }).pipe(T.Http({ method: "GET", uri: "/v0/datasources", code: 200 })),
406
+ ).annotate({ identifier: "ListDatasourcesRequest" });
407
+ }
408
+ }
409
+ function __c7(j: number): any {
410
+ switch (j) {
411
+ case 0:
412
+ return S.suspend(() =>
413
+ S.Struct({
414
+ datasource: S.String.pipe(T.Label()),
415
+ }).pipe(
416
+ T.Http({ method: "POST", uri: "/v0/datasources/{datasource}/truncate", code: 200 }),
417
+ ),
418
+ ).annotate({ identifier: "TruncateDatasourceRequest" });
419
+ }
420
+ }
421
+ function __c8(j: number): any {
422
+ switch (j) {
423
+ case 0:
424
+ return S.suspend(() =>
425
+ S.Struct({
426
+ datasource: S.String.pipe(T.Label()),
427
+ name: S.optional(S.String.pipe(T.Query())),
428
+ token: S.optional(S.String.pipe(T.Query(), T.SensitiveValue({}))),
429
+ connector: S.optional(S.String.pipe(T.Query())),
430
+ query: S.optional(S.String.pipe(T.Query())),
431
+ }).pipe(T.Http({ method: "PUT", uri: "/v0/datasources/{datasource}", code: 200 })),
432
+ ).annotate({ identifier: "UpdateDatasourceRequest" });
433
+ }
434
+ }
435
+ // Schema table: entry i is schema j of builder f, made on first reach.
436
+ function __S(i: number, f: (j: number) => unknown, j: number): any {
437
+ return (__s[i] ??= __L.at(f, j));
438
+ }
@@ -0,0 +1,213 @@
1
+ import * as API from "@distilled.cloud/core/api";
2
+ // AUTO-GENERATED by scripts/generate.ts from .generated-specs (specs/spec-mirror-tinybird/specs/api-reference). Do not edit.
3
+ import * as S from "@distilled.cloud/core/schema-lite";
4
+ import * as __L from "@distilled.cloud/core/schema-lite";
5
+ import type * as Redacted from "effect/Redacted";
6
+ import { TinybirdServiceErrors } from "../errors.ts";
7
+ import { TinybirdProtocol, type TinybirdOpError, type TinybirdOpContext } from "../protocol.ts";
8
+ import * as Retry from "../retry.ts";
9
+ import * as T from "../traits.ts";
10
+ // Schema table, filled on first reach (see __S at the end).
11
+ const __s: any[] = [];
12
+
13
+ export type { TinybirdOpError, TinybirdOpContext };
14
+
15
+ /** Span facts shared by every operation (com.distilled.telemetry#service). */
16
+ const TELEMETRY = {
17
+ system: "tinybird-api",
18
+ responseHeaders: [
19
+ { header: "x-request-id", name: "http.response.header.x-request-id", transform: "list" },
20
+ { header: "request-id", name: "http.response.header.request-id", transform: "list" },
21
+ ],
22
+ prefix: "Tinybird",
23
+ service: "EnvironmentVariables",
24
+ labels: "tinybird",
25
+ propagate: "w3c",
26
+ } as const;
27
+
28
+ export interface CreateVariableRequest {
29
+ /** The type of the variable. Defaults to `secret` */
30
+ type?: string | undefined;
31
+ /** The name of the variable */
32
+ name?: string | undefined;
33
+ /** The variable value */
34
+ value?: string | Redacted.Redacted<string> | undefined;
35
+ }
36
+ export type CreateVariableResponseBodyMap = { [key: string]: unknown | undefined };
37
+ export type CreateVariableResponse = CreateVariableResponseBodyMap;
38
+ export interface DeleteVariableRequest {
39
+ variable: string;
40
+ }
41
+ export type DeleteVariableResponseBodyMap = { [key: string]: unknown | undefined };
42
+ export type DeleteVariableResponse = DeleteVariableResponseBodyMap;
43
+ export interface GetVariableRequest {
44
+ variable: string;
45
+ }
46
+ export type GetVariableResponseBodyMap = { [key: string]: unknown | undefined };
47
+ export type GetVariableResponse = GetVariableResponseBodyMap;
48
+ export interface ListVariablesRequest {}
49
+ export type ListVariablesResponseBodyMap = { [key: string]: unknown | undefined };
50
+ export type ListVariablesResponse = ListVariablesResponseBodyMap;
51
+ export interface UpdateVariableRequest {
52
+ variable: string;
53
+ /** The new variable value. */
54
+ value: string | Redacted.Redacted<string>;
55
+ }
56
+ export type UpdateVariableResponseBodyMap = { [key: string]: unknown | undefined };
57
+ export type UpdateVariableResponse = UpdateVariableResponseBodyMap;
58
+ export type CreateVariableError = TinybirdOpError;
59
+ /** Creates a new environment variable. Environment variables names are unique for a Workspace. Reference: https://www.tinybird.co/docs/api-reference/environment-variables-api */
60
+ export const createVariable: API.OperationMethod<
61
+ CreateVariableRequest,
62
+ CreateVariableResponse,
63
+ CreateVariableError,
64
+ TinybirdOpContext
65
+ > = /*@__PURE__*/ API.make(() => ({
66
+ input: __S(0, __c0, 0) as any as S.Schema<CreateVariableRequest>,
67
+ output: __S(3, __c1, 1) as any as S.Schema<CreateVariableResponse>,
68
+ errors: [],
69
+ serviceErrors: TinybirdServiceErrors,
70
+ protocol: TinybirdProtocol,
71
+ retry: Retry.Retry,
72
+ telemetry: TELEMETRY,
73
+ span: "CreateVariable",
74
+ }));
75
+
76
+ export type DeleteVariableError = TinybirdOpError;
77
+ /** Deletes an environment variable. Reference: https://www.tinybird.co/docs/api-reference/environment-variables-api */
78
+ export const deleteVariable: API.OperationMethod<
79
+ DeleteVariableRequest,
80
+ DeleteVariableResponse,
81
+ DeleteVariableError,
82
+ TinybirdOpContext
83
+ > = /*@__PURE__*/ API.make(() => ({
84
+ input: __S(4, __c2, 0) as any as S.Schema<DeleteVariableRequest>,
85
+ output: __S(3, __c1, 1) as any as S.Schema<DeleteVariableResponse>,
86
+ errors: [],
87
+ serviceErrors: TinybirdServiceErrors,
88
+ protocol: TinybirdProtocol,
89
+ retry: Retry.Retry,
90
+ telemetry: TELEMETRY,
91
+ span: "DeleteVariable",
92
+ }));
93
+
94
+ export type GetVariableError = TinybirdOpError;
95
+ /** Fetches information about a particular environment variable. The value isn't returned. Reference: https://www.tinybird.co/docs/api-reference/environment-variables-api */
96
+ export const getVariable: API.OperationMethod<
97
+ GetVariableRequest,
98
+ GetVariableResponse,
99
+ GetVariableError,
100
+ TinybirdOpContext
101
+ > = /*@__PURE__*/ API.make(() => ({
102
+ input: __S(6, __c3, 0) as any as S.Schema<GetVariableRequest>,
103
+ output: __S(3, __c1, 1) as any as S.Schema<GetVariableResponse>,
104
+ errors: [],
105
+ serviceErrors: TinybirdServiceErrors,
106
+ protocol: TinybirdProtocol,
107
+ retry: Retry.Retry,
108
+ telemetry: TELEMETRY,
109
+ span: "GetVariable",
110
+ }));
111
+
112
+ export type ListVariablesError = TinybirdOpError;
113
+ /** Retrieves all Workspace environment variables. The value isn't returned. Reference: https://www.tinybird.co/docs/api-reference/environment-variables-api */
114
+ export const listVariables: API.OperationMethod<
115
+ ListVariablesRequest,
116
+ ListVariablesResponse,
117
+ ListVariablesError,
118
+ TinybirdOpContext
119
+ > = /*@__PURE__*/ API.make(() => ({
120
+ input: __S(8, __c4, 0) as any as S.Schema<ListVariablesRequest>,
121
+ output: __S(3, __c1, 1) as any as S.Schema<ListVariablesResponse>,
122
+ errors: [],
123
+ serviceErrors: TinybirdServiceErrors,
124
+ protocol: TinybirdProtocol,
125
+ retry: Retry.Retry,
126
+ telemetry: TELEMETRY,
127
+ span: "ListVariables",
128
+ }));
129
+
130
+ export type UpdateVariableError = TinybirdOpError;
131
+ /** Updates an environment variable. Reference: https://www.tinybird.co/docs/api-reference/environment-variables-api */
132
+ export const updateVariable: API.OperationMethod<
133
+ UpdateVariableRequest,
134
+ UpdateVariableResponse,
135
+ UpdateVariableError,
136
+ TinybirdOpContext
137
+ > = /*@__PURE__*/ API.make(() => ({
138
+ input: __S(10, __c5, 0) as any as S.Schema<UpdateVariableRequest>,
139
+ output: __S(3, __c1, 1) as any as S.Schema<UpdateVariableResponse>,
140
+ errors: [],
141
+ serviceErrors: TinybirdServiceErrors,
142
+ protocol: TinybirdProtocol,
143
+ retry: Retry.Retry,
144
+ telemetry: TELEMETRY,
145
+ span: "UpdateVariable",
146
+ }));
147
+
148
+ // Schema builders: each runs one schema initializer, on that schema's first use.
149
+ function __c0(j: number): any {
150
+ switch (j) {
151
+ case 0:
152
+ return S.suspend(() =>
153
+ S.Struct({
154
+ type: S.optional(S.String.pipe(T.Query())),
155
+ name: S.optional(S.String.pipe(T.Query())),
156
+ value: S.optional(S.String.pipe(T.Query(), T.SensitiveValue({}))),
157
+ }).pipe(T.Http({ method: "POST", uri: "/v0/variables", code: 200 })),
158
+ ).annotate({ identifier: "CreateVariableRequest" });
159
+ }
160
+ }
161
+ function __c1(j: number): any {
162
+ switch (j) {
163
+ case 0:
164
+ return S.Record(S.String, S.Unknown);
165
+ case 1:
166
+ return S.suspend(() => __S(2, __c1, 0).pipe(T.RawResponseRoot())).annotate({
167
+ identifier: "CreateVariableResponse",
168
+ });
169
+ }
170
+ }
171
+ function __c2(j: number): any {
172
+ switch (j) {
173
+ case 0:
174
+ return S.suspend(() =>
175
+ S.Struct({
176
+ variable: S.String.pipe(T.Label()),
177
+ }).pipe(T.Http({ method: "DELETE", uri: "/v0/variables/{variable}", code: 200 })),
178
+ ).annotate({ identifier: "DeleteVariableRequest" });
179
+ }
180
+ }
181
+ function __c3(j: number): any {
182
+ switch (j) {
183
+ case 0:
184
+ return S.suspend(() =>
185
+ S.Struct({
186
+ variable: S.String.pipe(T.Label()),
187
+ }).pipe(T.Http({ method: "GET", uri: "/v0/variables/{variable}", code: 200 })),
188
+ ).annotate({ identifier: "GetVariableRequest" });
189
+ }
190
+ }
191
+ function __c4(j: number): any {
192
+ switch (j) {
193
+ case 0:
194
+ return S.suspend(() =>
195
+ S.Struct({}).pipe(T.Http({ method: "GET", uri: "/v0/variables", code: 200 })),
196
+ ).annotate({ identifier: "ListVariablesRequest" });
197
+ }
198
+ }
199
+ function __c5(j: number): any {
200
+ switch (j) {
201
+ case 0:
202
+ return S.suspend(() =>
203
+ S.Struct({
204
+ variable: S.String.pipe(T.Label()),
205
+ value: S.String.pipe(T.Query(), T.SensitiveValue({})),
206
+ }).pipe(T.Http({ method: "PUT", uri: "/v0/variables/{variable}", code: 200 })),
207
+ ).annotate({ identifier: "UpdateVariableRequest" });
208
+ }
209
+ }
210
+ // Schema table: entry i is schema j of builder f, made on first reach.
211
+ function __S(i: number, f: (j: number) => unknown, j: number): any {
212
+ return (__s[i] ??= __L.at(f, j));
213
+ }