@distilled.cloud/tinybird 0.0.0 → 1.0.0-rc.21
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/LICENSE +201 -0
- package/README.md +128 -4
- package/lib/.lazy.json +1 -0
- package/lib/_bundle/sdk.js +2 -0
- package/lib/_bundle/sdk.js.map +1 -0
- package/lib/credentials.d.ts +29 -0
- package/lib/credentials.d.ts.map +1 -0
- package/lib/credentials.js +1 -0
- package/lib/errors.d.ts +52 -0
- package/lib/errors.d.ts.map +1 -0
- package/lib/errors.js +1 -0
- package/lib/index.d.ts +48 -0
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +5 -0
- package/lib/protocol.d.ts +19 -0
- package/lib/protocol.d.ts.map +1 -0
- package/lib/protocol.js +1 -0
- package/lib/retry.d.ts +50 -0
- package/lib/retry.d.ts.map +1 -0
- package/lib/retry.js +1 -0
- package/lib/services/analyze.d.ts +17 -0
- package/lib/services/analyze.d.ts.map +1 -0
- package/lib/services/analyze.js +2 -0
- package/lib/services/analyze.js.map +1 -0
- package/lib/services/api_endpoints.d.ts +26 -0
- package/lib/services/api_endpoints.d.ts.map +1 -0
- package/lib/services/api_endpoints.js +2 -0
- package/lib/services/api_endpoints.js.map +1 -0
- package/lib/services/copy_pipes.d.ts +102 -0
- package/lib/services/copy_pipes.d.ts.map +1 -0
- package/lib/services/copy_pipes.js +2 -0
- package/lib/services/copy_pipes.js.map +1 -0
- package/lib/services/datasource.d.ts +171 -0
- package/lib/services/datasource.d.ts.map +1 -0
- package/lib/services/datasource.js +2 -0
- package/lib/services/datasource.js.map +1 -0
- package/lib/services/environment_variables.d.ts +61 -0
- package/lib/services/environment_variables.d.ts.map +1 -0
- package/lib/services/environment_variables.js +2 -0
- package/lib/services/environment_variables.js.map +1 -0
- package/lib/services/events.d.ts +21 -0
- package/lib/services/events.d.ts.map +1 -0
- package/lib/services/events.js +2 -0
- package/lib/services/events.js.map +1 -0
- package/lib/services/index.d.ts +14 -0
- package/lib/services/index.d.ts.map +1 -0
- package/lib/services/index.js +13 -0
- package/lib/services/jobs.d.ts +45 -0
- package/lib/services/jobs.d.ts.map +1 -0
- package/lib/services/jobs.js +2 -0
- package/lib/services/jobs.js.map +1 -0
- package/lib/services/materialized_views.d.ts +64 -0
- package/lib/services/materialized_views.d.ts.map +1 -0
- package/lib/services/materialized_views.js +2 -0
- package/lib/services/materialized_views.js.map +1 -0
- package/lib/services/organizations.d.ts +214 -0
- package/lib/services/organizations.d.ts.map +1 -0
- package/lib/services/organizations.js +2 -0
- package/lib/services/organizations.js.map +1 -0
- package/lib/services/pipe.d.ts +243 -0
- package/lib/services/pipe.d.ts.map +1 -0
- package/lib/services/pipe.js +2 -0
- package/lib/services/pipe.js.map +1 -0
- package/lib/services/query.d.ts +50 -0
- package/lib/services/query.d.ts.map +1 -0
- package/lib/services/query.js +2 -0
- package/lib/services/query.js.map +1 -0
- package/lib/services/sink_pipes.d.ts +95 -0
- package/lib/services/sink_pipes.d.ts.map +1 -0
- package/lib/services/sink_pipes.js +2 -0
- package/lib/services/sink_pipes.js.map +1 -0
- package/lib/services/token.d.ts +107 -0
- package/lib/services/token.d.ts.map +1 -0
- package/lib/services/token.js +2 -0
- package/lib/services/token.js.map +1 -0
- package/lib/services.lazy/analyze.js +1 -0
- package/lib/services.lazy/api_endpoints.js +1 -0
- package/lib/services.lazy/copy_pipes.js +1 -0
- package/lib/services.lazy/datasource.js +1 -0
- package/lib/services.lazy/environment_variables.js +1 -0
- package/lib/services.lazy/events.js +1 -0
- package/lib/services.lazy/index.js +3 -0
- package/lib/services.lazy/jobs.js +1 -0
- package/lib/services.lazy/materialized_views.js +1 -0
- package/lib/services.lazy/organizations.js +1 -0
- package/lib/services.lazy/pipe.js +1 -0
- package/lib/services.lazy/query.js +1 -0
- package/lib/services.lazy/sink_pipes.js +1 -0
- package/lib/services.lazy/token.js +1 -0
- package/lib/traits.d.ts +10 -0
- package/lib/traits.d.ts.map +1 -0
- package/lib/traits.js +1 -0
- package/package.json +76 -2
- package/src/credentials.ts +76 -0
- package/src/errors.ts +83 -0
- package/src/index.ts +47 -0
- package/src/protocol.ts +48 -0
- package/src/retry.ts +69 -0
- package/src/services/analyze.ts +75 -0
- package/src/services/api_endpoints.ts +115 -0
- package/src/services/copy_pipes.ts +315 -0
- package/src/services/datasource.ts +438 -0
- package/src/services/environment_variables.ts +213 -0
- package/src/services/events.ts +86 -0
- package/src/services/index.ts +14 -0
- package/src/services/jobs.ts +156 -0
- package/src/services/materialized_views.ts +200 -0
- package/src/services/organizations.ts +552 -0
- package/src/services/pipe.ts +700 -0
- package/src/services/query.ts +150 -0
- package/src/services/sink_pipes.ts +295 -0
- package/src/services/token.ts +359 -0
- package/src/traits.ts +47 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright [yyyy] [name of copyright owner]
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
package/README.md
CHANGED
|
@@ -1,9 +1,133 @@
|
|
|
1
1
|
# @distilled.cloud/tinybird
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Effect-native Tinybird SDK, generated from the [Tinybird API reference](https://www.tinybird.co/docs/api-reference).
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
## Installation
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
```bash
|
|
8
|
+
npm install @distilled.cloud/tinybird effect
|
|
9
|
+
```
|
|
8
10
|
|
|
9
|
-
|
|
11
|
+
## Quick start
|
|
12
|
+
|
|
13
|
+
```ts
|
|
14
|
+
import { Effect, Layer } from "effect";
|
|
15
|
+
import * as FetchHttpClient from "effect/http/FetchHttpClient";
|
|
16
|
+
import * as Tinybird from "@distilled.cloud/tinybird";
|
|
17
|
+
import * as Events from "@distilled.cloud/tinybird/events";
|
|
18
|
+
import * as Query from "@distilled.cloud/tinybird/query";
|
|
19
|
+
|
|
20
|
+
const program = Effect.gen(function* () {
|
|
21
|
+
const ingested = yield* Events.sendEvents({
|
|
22
|
+
name: "events",
|
|
23
|
+
wait: true,
|
|
24
|
+
body: '{"timestamp":"2026-11-17 00:00:00","city":"Chicago","amount":3}\n',
|
|
25
|
+
});
|
|
26
|
+
const { body: bytes } = yield* Query.querySql({
|
|
27
|
+
q: "SELECT city, sum(amount) AS total FROM events GROUP BY city FORMAT JSON",
|
|
28
|
+
});
|
|
29
|
+
const { data } = JSON.parse(new TextDecoder().decode(bytes));
|
|
30
|
+
return { ingested, data };
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
const Live = Layer.mergeAll(
|
|
34
|
+
FetchHttpClient.layer,
|
|
35
|
+
Tinybird.CredentialsFromEnv,
|
|
36
|
+
);
|
|
37
|
+
|
|
38
|
+
program.pipe(Effect.provide(Live), Effect.runPromise).then(console.log);
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
## Auth
|
|
42
|
+
|
|
43
|
+
`TINYBIRD_TOKEN` as `Authorization: Bearer`: a workspace token with the scopes the call needs
|
|
44
|
+
(`DATASOURCES:APPEND:<name>` for `sendEvents`, `PIPES:READ:<pipe>` for `queryPipe`, `ADMIN`, ...).
|
|
45
|
+
Optional `TINYBIRD_API_BASE_URL`, the API host of the workspace's
|
|
46
|
+
[region](https://www.tinybird.co/docs/api-reference#regions-and-endpoints) -- default
|
|
47
|
+
`https://api.tinybird.co`. Or provide them yourself:
|
|
48
|
+
|
|
49
|
+
```ts
|
|
50
|
+
import * as Redacted from "effect/Redacted";
|
|
51
|
+
|
|
52
|
+
Tinybird.credentials({
|
|
53
|
+
token: Redacted.make(token),
|
|
54
|
+
apiBaseUrl: "https://api.us-east.tinybird.co",
|
|
55
|
+
});
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
## Services
|
|
59
|
+
|
|
60
|
+
One module per reference page, each imported from its subpath:
|
|
61
|
+
|
|
62
|
+
| Module | Operations |
|
|
63
|
+
| --- | --- |
|
|
64
|
+
| `datasource` | `listDatasources`, `getDatasource`, `createDatasource` (create, append, replace; `csv`/`ndjson` file parts), `alterDatasource`, `updateDatasource`, `truncateDatasource`, `deleteDatasourceRows`, `deleteDatasource` |
|
|
65
|
+
| `events` | `sendEvents` |
|
|
66
|
+
| `query` | `querySql`, `querySqlWithBody` |
|
|
67
|
+
| `pipe` | `listPipes`, `getPipe`, `createPipe`, `updatePipe`, `deletePipe`, `getPipeByFileName`, `updatePipeByFileName`, `deletePipeByFileName`, `queryPipe`, `queryPipeWithBody`, `createPipeNode`, `updatePipeNode`, `deletePipeNode`, `explainPipe`, `explainPipeNode` |
|
|
68
|
+
| `api_endpoints` | `createPipeNodeEndpoint`, `deletePipeNodeEndpoint` |
|
|
69
|
+
| `copy_pipes` | `createPipeNodeCopy`, `updatePipeNodeCopy`, `deletePipeNodeCopy`, `runPipeCopy`, `pausePipeCopy`, `resumePipeCopy`, `cancelPipeCopy` |
|
|
70
|
+
| `materialized_views` | `createPipeNodeMaterialization`, `deletePipeNodeMaterialization`, `populatePipeNode` |
|
|
71
|
+
| `sink_pipes` | `createPipeNodeSink`, `deletePipeNodeSink`, `triggerPipeSink`, `getS3Settings`, `getS3TrustPolicy`, `getS3WriteAccessPolicy` |
|
|
72
|
+
| `token` | `listTokens`, `getToken`, `createToken`, `updateToken`, `refreshToken`, `deleteToken` |
|
|
73
|
+
| `environment_variables` | `listVariables`, `getVariable`, `createVariable`, `updateVariable`, `deleteVariable` |
|
|
74
|
+
| `jobs` | `listJobs`, `getJob`, `cancelJob` |
|
|
75
|
+
| `analyze` | `analyzeData` |
|
|
76
|
+
| `organizations` | `listOrganizationClusters`, `getOrganizationClustersConfiguration`, `updateOrganizationClusterWeights`, `addOrganizationClusterReplica`, `addOrganizationClusterReplicaByName`, `removeOrganizationClusterReplica`, `removeOrganizationClusterReplicaByName` |
|
|
77
|
+
|
|
78
|
+
## Bodies and formats
|
|
79
|
+
|
|
80
|
+
- `queryPipe`, `queryPipeWithBody`, `querySql` and `querySqlWithBody` answer in the format you ask for
|
|
81
|
+
(`format: "csv" | "json" | "ndjson" | "parquet" | "prometheus"`, or `FORMAT <name>` in the SQL), so they
|
|
82
|
+
return `{ body, contentType }`: the response bytes as a `Stream<Uint8Array>` read as they arrive (`Stream.mkUint8Array` collects them) and its `Content-Type`. Decode
|
|
83
|
+
JSON or text yourself; Parquet stays intact.
|
|
84
|
+
- `getPipeByFileName` returns the Pipe's datafile as a `string`.
|
|
85
|
+
- `sendEvents` sends `body` verbatim as NDJSON; `createPipeNode` sends its SQL `body` as text.
|
|
86
|
+
- `createDatasource` and `analyzeData` upload files as multipart parts (`csv`, `ndjson`, `file`) given as
|
|
87
|
+
`Uint8Array`.
|
|
88
|
+
- Template parameters are caller-named. Pass them as extra keys to `querySqlWithBody` and
|
|
89
|
+
`queryPipeWithBody`, which send them in the JSON body. `queryPipe` and `querySql` are `GET`s and only send
|
|
90
|
+
the parameters they model (see below).
|
|
91
|
+
- `createToken` makes a static token from `scope`, or a JWT when you give `expiration_time` (Unix seconds)
|
|
92
|
+
and `scopes`. Each JWT scope can pin template parameters with `fixed_params`. Every query made with that
|
|
93
|
+
JWT uses them, which is how one token serves one tenant:
|
|
94
|
+
|
|
95
|
+
```ts
|
|
96
|
+
const { token } = yield* Token.createToken({
|
|
97
|
+
name: "tenant_42",
|
|
98
|
+
expiration_time: Math.floor(Date.now() / 1000) + 3600,
|
|
99
|
+
scopes: [{ type: "PIPES:READ", resource: "events_by_city", fixed_params: { tenant_id: 42 } }],
|
|
100
|
+
});
|
|
101
|
+
```
|
|
102
|
+
- The reference types most JSON responses by example only, so those outputs are open objects. Token
|
|
103
|
+
responses are modeled, and their `token` values come back `Redacted`.
|
|
104
|
+
|
|
105
|
+
## Not covered yet
|
|
106
|
+
|
|
107
|
+
Some parameters have names the caller picks, and the reference documents them as a family. They need
|
|
108
|
+
query-parameter maps, which distilled core does not have yet, so these calls cannot send them:
|
|
109
|
+
|
|
110
|
+
| Operation | Parameters it cannot send | It does send |
|
|
111
|
+
| --- | --- | --- |
|
|
112
|
+
| `querySql`, `queryPipe` (`GET`) | template parameters | the modeled parameters; use `querySqlWithBody` / `queryPipeWithBody` for templates |
|
|
113
|
+
| `createDatasource` | `engine_*` other than `engine_sorting_key`, `engine_ver`, `engine_settings` | `engine` and those three |
|
|
114
|
+
| `createPipeNode`, `createPipeNodeMaterialization` | `engine_*` settings of the target Data Source | `engine` |
|
|
115
|
+
| `triggerPipeSink` | `{key}` template variables for the sink query | `file_template`, `format`, `compression`, `write_strategy` |
|
|
116
|
+
|
|
117
|
+
`engine_*` settings only apply when a Data Source is created. In Tinybird Forward that happens through
|
|
118
|
+
deployments, not these calls (see below), so the `engine_*` rows only affect Classic workspaces.
|
|
119
|
+
|
|
120
|
+
## Errors
|
|
121
|
+
|
|
122
|
+
Failures are typed by status: `BadRequest`, `Unauthorized`, `Forbidden`, `NotFound`, `Conflict`,
|
|
123
|
+
`UnprocessableEntity`, `TooManyRequests` (retried), `InternalServerError` and other 5xx (retried); any other
|
|
124
|
+
status is `UnknownTinybirdError`. `message` is Tinybird's `error`. A missing `TINYBIRD_TOKEN` is a
|
|
125
|
+
`ConfigError`.
|
|
126
|
+
|
|
127
|
+
## Tinybird Forward and Classic
|
|
128
|
+
|
|
129
|
+
The reference covers both. In a Tinybird Forward workspace, Pipes, Data Sources, Copy and Materialized
|
|
130
|
+
nodes, Sinks and resource-scoped tokens are created and changed through deployments, so the API answers
|
|
131
|
+
`Forbidden` ("can only be done via deployments") to `createPipe`, `createPipeNode`, `createDatasource`
|
|
132
|
+
with `mode: "create"`, `alterDatasource` and the rest. Ingestion, queries, jobs, copies, tokens without
|
|
133
|
+
a resource, and environment variables work in both.
|
package/lib/.lazy.json
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"serviceDirs":["services"],"twins":[]}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{api$D as e,api$call as t,api$named as n,api$op as r,category$withParseError as i,config$Redacted as a,config$String as o,config$all as ee,config$withDefault as te,retry$capped as ne,retry$jittered as re,retry$makeDefault as ie,retry$throttlingFactory as s,retry$throttlingOptions as c,retry$transientFactory as l,retry$transientOptions as u,schema_lite_typed$TaggedError as d,schema_lite_typed$Unknown as f,trait$Body as p,trait$FormDataFile as m,trait$Header as h,trait$Http as g,trait$HttpBody as _,trait$KeyDictionary as v,trait$Label as y,trait$Query as b,trait$ResponseCode as x,trait$UnionCases as S,trait$applyErrorMatchers as C,trait$bodySymbol as w,trait$errorMatchersSymbol as T,trait$formDataFileSymbol as E,trait$getErrorMatchers as D,trait$headerSymbol as O,trait$httpBodySymbol as k,trait$httpSymbol as A,trait$keyDictionarySymbol as j,trait$labelSymbol as M,trait$querySymbol as N,trait$responseCodeSymbol as P,trait$unionCasesSymbol as F}from"@distilled.cloud/core/_bundle/base";import{errors$API_ERRORS as I,errors$BadGateway as L,errors$BadRequest as R,errors$ConfigError as z,errors$Conflict as B,errors$DEFAULT_ERRORS as V,errors$Forbidden as H,errors$GatewayTimeout as U,errors$HTTP_STATUS_MAP as W,errors$InternalServerError as G,errors$Locked as K,errors$NotFound as q,errors$ServiceUnavailable as J,errors$TooManyRequests as Y,errors$Unauthorized as ae,errors$UnknownErrorFields as oe,errors$UnprocessableEntity as se,protocol_rest$BinaryResponse as ce,protocol_rest$BinaryStream as le,protocol_rest$RawResponse as ue,protocol_rest$RawResponseRoot as de,protocol_rest$SensitiveValue as fe,protocol_rest$binaryResponseSymbol as pe,protocol_rest$rawResponseRootSymbol as me,protocol_rest$rawResponseSymbol as he,protocol_rest$restProtocol as ge,protocol_rest$sensitiveValueSymbol as _e,protocol_rest$unknownErrorProps as ve,schema_lite$Array as ye,schema_lite$Boolean as be,schema_lite$NullOr as xe,schema_lite$Number as Se,schema_lite$Record as Ce,schema_lite$String as we,schema_lite$Struct as Te,schema_lite$StructWithRest as Ee,schema_lite$Unknown as De,schema_lite$at as Oe,schema_lite$instanceOf as ke,schema_lite$optional as Ae,schema_lite$suspend as je}from"@distilled.cloud/core/_bundle/rest";import*as X from"effect/Context";import*as Z from"effect/Effect";import*as Q from"effect/Layer";import*as Me from"effect/Redacted";const $=`https://api.tinybird.co`;var Credentials=class extends (/*@__PURE__*/ X.Service()(`TinybirdCredentials`)){};const Ne=/*@__PURE__*/ ee({token:/*@__PURE__*/ a(`TINYBIRD_TOKEN`),apiBaseUrl:/*@__PURE__*/ o(`TINYBIRD_API_BASE_URL`).pipe(/*@__PURE__*/ te($))});const Pe=/*@__PURE__*/ Q.effect(Credentials,/*@__PURE__*/ Z.map(/*@__PURE__*/ Ne.pipe(/*@__PURE__*/ Z.mapError(()=>new z({message:`TINYBIRD_TOKEN environment variable is required`}))),e=>Z.succeed(e)));const credentials=e=>Q.succeed(Credentials,Z.succeed({token:e.token,apiBaseUrl:e.apiBaseUrl??`https://api.tinybird.co`}));var UnknownTinybirdError=class extends (/*@__PURE__*/ d()(`UnknownTinybirdError`,oe)){};var TinybirdParseError=class extends (/*@__PURE__*/ d()(`TinybirdParseError`,{body:f,cause:f}).pipe(i)){};const Fe=I;const Ie=/*@__PURE__*/ ge({credentials:/*@__PURE__*/ Z.flatten(Credentials),baseUrl:e=>e.apiBaseUrl.replace(/\/+$/,``),headers:e=>({Authorization:`Bearer ${Me.value(e.token)}`}),unknownError:e=>new UnknownTinybirdError(ve(e)),parseError:({body:e,cause:t})=>new TinybirdParseError({body:e,cause:t})});var Retry=class extends (/*@__PURE__*/ X.Service()(`TinybirdRetry`)){};const policy=e=>Z.provide(Q.succeed(Retry,e));const Le=/*@__PURE__*/ Z.provide(/*@__PURE__*/ Q.succeed(Retry,{while:()=>false}));const Re=ie;const ze=re;const Be=ne;const Ve=c;const He=/*@__PURE__*/ policy(s);const Ue=u;const We=/*@__PURE__*/ policy(l);export{Oe as Bc,ke as Ec,Ae as Gc,je as Hc,e as a,t as b,Credentials as credentials$Credentials,Pe as credentials$CredentialsFromEnv,$ as credentials$DEFAULT_API_BASE_URL,credentials as credentials$credentials,I as errors$API_ERRORS,L as errors$BadGateway,R as errors$BadRequest,z as errors$ConfigError,B as errors$Conflict,V as errors$DEFAULT_ERRORS,H as errors$Forbidden,U as errors$GatewayTimeout,W as errors$HTTP_STATUS_MAP,G as errors$InternalServerError,K as errors$Locked,q as errors$NotFound,J as errors$ServiceUnavailable,TinybirdParseError as errors$TinybirdParseError,Fe as errors$TinybirdServiceErrors,Y as errors$TooManyRequests,ae as errors$Unauthorized,UnknownTinybirdError as errors$UnknownTinybirdError,se as errors$UnprocessableEntity,ye as gc,be as hc,n as l,r as n,xe as pc,Ie as protocol$TinybirdProtocol,Se as qc,Ce as rc,Retry as retry$Retry,Be as retry$capped,ze as retry$jittered,Re as retry$makeDefault,Le as retry$none,policy as retry$policy,He as retry$throttling,Ve as retry$throttlingOptions,We as retry$transient,Ue as retry$transientOptions,we as tc,ce as traits$BinaryResponse,p as traits$Body,m as traits$FormDataFile,h as traits$Header,g as traits$Http,_ as traits$HttpBody,v as traits$KeyDictionary,y as traits$Label,b as traits$Query,ue as traits$RawResponse,de as traits$RawResponseRoot,x as traits$ResponseCode,fe as traits$SensitiveValue,S as traits$UnionCases,C as traits$applyErrorMatchers,pe as traits$binaryResponseSymbol,w as traits$bodySymbol,T as traits$errorMatchersSymbol,E as traits$formDataFileSymbol,D as traits$getErrorMatchers,O as traits$headerSymbol,k as traits$httpBodySymbol,A as traits$httpSymbol,j as traits$keyDictionarySymbol,M as traits$labelSymbol,N as traits$querySymbol,me as traits$rawResponseRootSymbol,he as traits$rawResponseSymbol,P as traits$responseCodeSymbol,_e as traits$sensitiveValueSymbol,F as traits$unionCasesSymbol,le as ub,Te as uc,Ee as vc,De as zc};
|
|
2
|
+
//# sourceMappingURL=sdk.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sdk.js","names":["Schema.Unknown","Category.withParseError","Retries.makeDefault","Retries.jittered","Retries.capped","Retries.throttlingOptions","Retries.throttlingFactory","Retries.transientOptions","Retries.transientFactory","D","call","named","op","withParseError","Redacted$3","String$2","all$1","withDefault","capped$1","jittered$1","makeDefault$1","throttlingFactory","throttlingOptions$1","transientFactory","transientOptions$1","TaggedError$1","Unknown$1","Body","FormDataFile","Header","Http","HttpBody","KeyDictionary","Label","Query","ResponseCode","UnionCases","applyErrorMatchers","bodySymbol","errorMatchersSymbol","formDataFileSymbol","getErrorMatchers","headerSymbol","httpBodySymbol","httpSymbol","keyDictionarySymbol","labelSymbol","querySymbol","responseCodeSymbol","unionCasesSymbol","API_ERRORS","BadGateway","BadRequest","ConfigError","Conflict","DEFAULT_ERRORS","Forbidden","GatewayTimeout","HTTP_STATUS_MAP","InternalServerError","Locked","NotFound","ServiceUnavailable","TooManyRequests","Unauthorized","UnknownErrorFields","UnprocessableEntity","BinaryResponse","BinaryStream","RawResponse","RawResponseRoot","SensitiveValue","binaryResponseSymbol","rawResponseRootSymbol","rawResponseSymbol","restProtocol","sensitiveValueSymbol","unknownErrorProps","Array","Boolean","NullOr","Number","Record","String","Struct","StructWithRest","Unknown","at","instanceOf","optional","suspend","Context","Effect","Layer","Redacted","DEFAULT_API_BASE_URL","envConfig","CredentialsFromEnv","config","TinybirdServiceErrors","TinybirdProtocol","creds","info","optionsOrFactory","none","makeDefault","jittered","capped","throttlingOptions","throttling","transientOptions","transient"],"sources":["../../src/credentials.ts","../../src/errors.ts","../../src/protocol.ts","../../src/retry.ts"],"mappings":"0zEAuBA,MAAa+F,EAAuB,0BAQpC,IAAa,YAAb,eACwB,gBAAQ,QAA4C,CAAC,CACzE,qBACF,EAAA,AAAE,CAAC,EAEL,MAAMC,GAA0B,iBAAiB,CAC/C,MAAqB,gBAAsB,gBAAgB,EAC3D,WAA0B,gBAAoB,uBAAuB,CAAC,CAAC,KACvD,iBAAyBD,CAAoB,CAC7D,CACF,CAAC,EAQD,MAAaE,GAAmC,gBAAM,OACpD,YACc,gBAAO,IACL,iBAAU,KACR,gBAAO,aAEjB,IAAI5C,EAAY,CACd,QAAS,iDACX,CAAC,CACL,CACF,EACC,GAAWuC,EAAO,QAAQM,CAAM,CACnC,CACF,EAGA,MAAa,YAAe,GAI1BL,EAAM,QACJ,YACAD,EAAO,QAAQ,CACb,MAAOM,EAAO,MACd,WAAYA,EAAO,YAAA,yBACrB,CAAC,CACH,EC9BF,IAAa,qBAAb,eACwB,gBAAyC,CAAC,CAC9D,uBACAjC,EACF,EAAA,AAAE,CAAC,EAGL,IAAa,mBAAb,eACwB,gBAAuC,CAAC,CAAC,qBAAsB,CACnF,KAAMjE,EACN,MAAOA,CACT,CAAC,CAAC,CAAC,KAAKC,CAAuB,EAAA,AAAE,CAAC,EAyBpC,MAAakG,GAAwBjD,EC5CrC,MAAakD,GAAiC,iBAAa,CAGzD,YAA2B,gBAAO,QAAQ,WAAW,EACrD,QAAU,GAAUC,EAAM,WAAW,QAAQ,OAAQ,EAAE,EACvD,QAAU,IAAW,CACnB,cAAe,UAAUP,GAAS,MAAMO,EAAM,KAAK,GACrD,GACA,aAAe,GAAS,IAAI,qBAAqBxB,GAAkByB,CAAI,CAAC,EACxE,YAAa,CAAE,OAAM,WAAY,IAAI,mBAAmB,CAAE,OAAM,OAAM,CAAC,CACzE,CAAC,ECtBD,IAAa,MAAb,eAAyC,gBAAQ,QAAuB,CAAC,CAAC,eAAe,EAAA,AAAE,CAAC,EAG5F,MAAa,OAOR,GAAwCV,EAAO,QAAQC,EAAM,QAAQ,MAAOU,CAAgB,CAAC,EAGlG,MAAaC,GAE+C,gBAAO,QACnD,gBAAM,QAAQ,MAAO,CAAE,UAAa,KAAM,CAAC,CAC3D,EAOA,MAAaC,GAAuBvG,GAEpC,MAAawG,GAAWvG,GACxB,MAAawG,GAASvG,GAGtB,MAAawG,GAA6BvG,EAG1C,MAAawG,GAE+C,qBAAOvG,CAAyB,EAG5F,MAAawG,GAA4BvG,EAGzC,MAAawG,GAE+C,qBAAOvG,CAAwB"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { ConfigError } from "@distilled.cloud/core/errors";
|
|
2
|
+
import * as Context from "effect/Context";
|
|
3
|
+
import * as Effect from "effect/Effect";
|
|
4
|
+
import * as Layer from "effect/Layer";
|
|
5
|
+
import type * as Redacted from "effect/Redacted";
|
|
6
|
+
/** The API host of Tinybird's default region (GCP europe-west3). */
|
|
7
|
+
export declare const DEFAULT_API_BASE_URL = "https://api.tinybird.co";
|
|
8
|
+
export interface Config {
|
|
9
|
+
readonly token: Redacted.Redacted<string>;
|
|
10
|
+
/** The workspace region's API host, e.g. `https://api.us-east.tinybird.co`. */
|
|
11
|
+
readonly apiBaseUrl: string;
|
|
12
|
+
}
|
|
13
|
+
declare const Credentials_base: Context.ServiceClass<Credentials, "TinybirdCredentials", Effect.Effect<Config, never, never>>;
|
|
14
|
+
export declare class Credentials extends /*@__PURE__*/ Credentials_base {
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Reads `TINYBIRD_TOKEN` and, optionally, `TINYBIRD_API_BASE_URL`.
|
|
18
|
+
*
|
|
19
|
+
* Its configuration is read and checked once, when the layer is built: a
|
|
20
|
+
* problem there fails the layer with `ConfigError`.
|
|
21
|
+
*/
|
|
22
|
+
export declare const CredentialsFromEnv: Layer.Layer<Credentials, ConfigError, never>;
|
|
23
|
+
/** Credentials from a redacted token and, optionally, the region's API host. */
|
|
24
|
+
export declare const credentials: (config: {
|
|
25
|
+
readonly token: Redacted.Redacted<string>;
|
|
26
|
+
readonly apiBaseUrl?: string;
|
|
27
|
+
}) => Layer.Layer<Credentials>;
|
|
28
|
+
export {};
|
|
29
|
+
//# sourceMappingURL=credentials.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"credentials.d.ts","sources":["../src/credentials.ts"],"names":[],"mappings":"AAgBA,OAAO,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AAC3D,OAAO,KAAK,OAAO,MAAM,gBAAgB,CAAC;AAC1C,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AACxC,OAAO,KAAK,KAAK,MAAM,cAAc,CAAC;AACtC,OAAO,KAAK,KAAK,QAAQ,MAAM,iBAAiB,CAAC;AAEjD,oEAAoE;AACpE,eAAO,MAAM,oBAAoB,4BAA4B,CAAC;AAE9D,MAAM,WAAW,MAAM;IACrB,QAAQ,CAAC,KAAK,EAAE,QAAQ,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;IAC1C,+EAA+E;IAC/E,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;CAC7B;;AAED,qBAAa,WACX,SAAQ,aAAa,CAAC,gBAErB;CAAG;AASN;;;;;GAKG;AACH,eAAO,MAAM,kBAAkB,8CAa9B,CAAC;AAEF,gFAAgF;AAChF,eAAO,MAAM,WAAW,WAAY;IAClC,QAAQ,CAAC,KAAK,EAAE,QAAQ,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;IAC1C,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC;CAC9B,KAAG,KAAK,CAAC,KAAK,CAAC,WAAW,CAOxB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { credentials$Credentials as Credentials, credentials$CredentialsFromEnv as CredentialsFromEnv, credentials$DEFAULT_API_BASE_URL as DEFAULT_API_BASE_URL, credentials$credentials as credentials } from "./_bundle/sdk.js";
|
package/lib/errors.d.ts
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tinybird error types.
|
|
3
|
+
*
|
|
4
|
+
* Tinybird answers a failure with `{ "error": "<message>" }` (some routes add
|
|
5
|
+
* `documentation` or other fields) under an HTTP status, and its reference
|
|
6
|
+
* types failures only as per-operation status tables (`400`, `403`, `404`,
|
|
7
|
+
* `409`, `413`, `422`, `429`, `5xx`). The SDK dispatches on the status with
|
|
8
|
+
* core's shared classes; a status nothing maps comes back as
|
|
9
|
+
* {@link UnknownTinybirdError} with the body.
|
|
10
|
+
*/
|
|
11
|
+
export { BadGateway, BadRequest, Conflict, ConfigError, Forbidden, GatewayTimeout, InternalServerError, Locked, NotFound, ServiceUnavailable, TooManyRequests, Unauthorized, UnprocessableEntity, HTTP_STATUS_MAP, DEFAULT_ERRORS, API_ERRORS, } from "@distilled.cloud/core/errors";
|
|
12
|
+
import type { BadRequest as CoreBadRequest, Conflict as CoreConflict, DefaultErrors as CoreDefaultErrors, Forbidden as CoreForbidden, Locked as CoreLocked, NotFound as CoreNotFound, UnprocessableEntity as CoreUnprocessableEntity } from "@distilled.cloud/core/errors";
|
|
13
|
+
import * as Schema from "@distilled.cloud/core/schema-lite-typed";
|
|
14
|
+
declare const UnknownTinybirdError_base: Schema.TaggedErrorClass<"UnknownTinybirdError", {
|
|
15
|
+
status: import("effect/Schema").Number;
|
|
16
|
+
code: import("effect/Schema").optional<import("effect/Schema").String>;
|
|
17
|
+
message: import("effect/Schema").optional<import("effect/Schema").String>;
|
|
18
|
+
body: import("effect/Schema").Unknown;
|
|
19
|
+
}>;
|
|
20
|
+
/**
|
|
21
|
+
* Unknown Tinybird error -- a failed response whose status has no mapped
|
|
22
|
+
* class (`413` payload too large, for one). `message` is Tinybird's `error`.
|
|
23
|
+
*/
|
|
24
|
+
export declare class UnknownTinybirdError extends /*@__PURE__*/ UnknownTinybirdError_base {
|
|
25
|
+
}
|
|
26
|
+
declare const TinybirdParseError_base: Schema.TaggedErrorClass<"TinybirdParseError", {
|
|
27
|
+
readonly body: import("effect/Schema").Unknown;
|
|
28
|
+
readonly cause: import("effect/Schema").Unknown;
|
|
29
|
+
}> & (new (...args: any[]) => {
|
|
30
|
+
"@distilled.cloud/error/categories": {
|
|
31
|
+
ParseError: true;
|
|
32
|
+
};
|
|
33
|
+
});
|
|
34
|
+
/** A 2xx body that did not match the operation's output (validating modes only). */
|
|
35
|
+
export declare class TinybirdParseError extends /*@__PURE__*/ TinybirdParseError_base {
|
|
36
|
+
}
|
|
37
|
+
/** Errors any Tinybird operation may surface besides the shared HTTP status errors. */
|
|
38
|
+
export type ClientErrors = UnknownTinybirdError | TinybirdParseError;
|
|
39
|
+
/**
|
|
40
|
+
* Default Tinybird operation errors. Every operation carries the whole set:
|
|
41
|
+
* the reference lists statuses per operation inconsistently (many sections
|
|
42
|
+
* list none), so any of them can come back from any call.
|
|
43
|
+
*/
|
|
44
|
+
export type DefaultErrors = CoreDefaultErrors | CoreBadRequest | CoreForbidden | CoreNotFound | CoreConflict | CoreUnprocessableEntity | CoreLocked | ClientErrors;
|
|
45
|
+
/**
|
|
46
|
+
* The errors declared on the Tinybird service: any operation can return them,
|
|
47
|
+
* and every generated operation lists them as its `serviceErrors`. Today that
|
|
48
|
+
* is each of core's status classes (401, 403, 404, 429, the 5xx ...).
|
|
49
|
+
*/
|
|
50
|
+
export declare const TinybirdServiceErrors: readonly [typeof import("@distilled.cloud/core/errors").Unauthorized, typeof CoreForbidden, typeof CoreNotFound, typeof CoreBadRequest, typeof CoreConflict, typeof CoreUnprocessableEntity, typeof import("@distilled.cloud/core/errors").TooManyRequests, typeof CoreLocked, typeof import("@distilled.cloud/core/errors").InternalServerError, typeof import("@distilled.cloud/core/errors").BadGateway, typeof import("@distilled.cloud/core/errors").ServiceUnavailable, typeof import("@distilled.cloud/core/errors").GatewayTimeout];
|
|
51
|
+
export type TinybirdServiceError = InstanceType<(typeof TinybirdServiceErrors)[number]>;
|
|
52
|
+
//# sourceMappingURL=errors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,OAAO,EACL,UAAU,EACV,UAAU,EACV,QAAQ,EACR,WAAW,EACX,SAAS,EACT,cAAc,EACd,mBAAmB,EACnB,MAAM,EACN,QAAQ,EACR,kBAAkB,EAClB,eAAe,EACf,YAAY,EACZ,mBAAmB,EACnB,eAAe,EACf,cAAc,EACd,UAAU,GACX,MAAM,8BAA8B,CAAC;AAEtC,OAAO,KAAK,EACV,UAAU,IAAI,cAAc,EAC5B,QAAQ,IAAI,YAAY,EACxB,aAAa,IAAI,iBAAiB,EAClC,SAAS,IAAI,aAAa,EAC1B,MAAM,IAAI,UAAU,EACpB,QAAQ,IAAI,YAAY,EACxB,mBAAmB,IAAI,uBAAuB,EAC/C,MAAM,8BAA8B,CAAC;AAEtC,OAAO,KAAK,MAAM,MAAM,yCAAyC,CAAC;;;;;;;AAElE;;;GAGG;AACH,qBAAa,oBACX,SAAQ,aAAa,CAAC,yBAGrB;CAAG;;;;;;;;;AAEN,oFAAoF;AACpF,qBAAa,kBACX,SAAQ,aAAa,CAAC,uBAGU;CAAG;AAErC,uFAAuF;AACvF,MAAM,MAAM,YAAY,GAAG,oBAAoB,GAAG,kBAAkB,CAAC;AAErE;;;;GAIG;AACH,MAAM,MAAM,aAAa,GACrB,iBAAiB,GACjB,cAAc,GACd,aAAa,GACb,YAAY,GACZ,YAAY,GACZ,uBAAuB,GACvB,UAAU,GACV,YAAY,CAAC;AAEjB;;;;GAIG;AACH,eAAO,MAAM,qBAAqB,6gBAAa,CAAC;AAChD,MAAM,MAAM,oBAAoB,GAAG,YAAY,CAAC,CAAC,OAAO,qBAAqB,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC"}
|
package/lib/errors.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { errors$API_ERRORS as API_ERRORS, errors$BadGateway as BadGateway, errors$BadRequest as BadRequest, errors$ConfigError as ConfigError, errors$Conflict as Conflict, errors$DEFAULT_ERRORS as DEFAULT_ERRORS, errors$Forbidden as Forbidden, errors$GatewayTimeout as GatewayTimeout, errors$HTTP_STATUS_MAP as HTTP_STATUS_MAP, errors$InternalServerError as InternalServerError, errors$Locked as Locked, errors$NotFound as NotFound, errors$ServiceUnavailable as ServiceUnavailable, errors$TinybirdParseError as TinybirdParseError, errors$TinybirdServiceErrors as TinybirdServiceErrors, errors$TooManyRequests as TooManyRequests, errors$Unauthorized as Unauthorized, errors$UnknownTinybirdError as UnknownTinybirdError, errors$UnprocessableEntity as UnprocessableEntity } from "./_bundle/sdk.js";
|
package/lib/index.d.ts
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @distilled.cloud/tinybird -- Tinybird SDK for Effect.
|
|
3
|
+
*
|
|
4
|
+
* `./services` is generated by `scripts/generate.ts` from the Smithy models
|
|
5
|
+
* that `scripts/convert.ts` reads out of Tinybird's API reference, mirrored
|
|
6
|
+
* as Markdown under `specs/spec-mirror-tinybird/specs/api-reference`.
|
|
7
|
+
* Everything else in this folder is hand-written.
|
|
8
|
+
*
|
|
9
|
+
* One module per reference page: `datasource`, `events`, `query`, `pipe`,
|
|
10
|
+
* `api_endpoints`, `copy_pipes`, `materialized_views`, `sink_pipes`, `token`,
|
|
11
|
+
* `environment_variables`, `jobs`, `analyze` and `organizations`. Import each
|
|
12
|
+
* from its subpath.
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* ```ts
|
|
16
|
+
* import { Effect, Layer } from "effect";
|
|
17
|
+
* import * as FetchHttpClient from "effect/http/FetchHttpClient";
|
|
18
|
+
* import * as Tinybird from "@distilled.cloud/tinybird";
|
|
19
|
+
* import * as Events from "@distilled.cloud/tinybird/events";
|
|
20
|
+
* import * as Query from "@distilled.cloud/tinybird/query";
|
|
21
|
+
*
|
|
22
|
+
* const program = Effect.gen(function* () {
|
|
23
|
+
* const ingested = yield* Events.sendEvents({
|
|
24
|
+
* name: "events",
|
|
25
|
+
* wait: true,
|
|
26
|
+
* body: '{"timestamp":"2026-11-17 00:00:00","city":"Chicago","amount":3}\n',
|
|
27
|
+
* });
|
|
28
|
+
* const { body: bytes } = yield* Query.querySql({
|
|
29
|
+
* q: "SELECT city, sum(amount) AS total FROM events GROUP BY city FORMAT JSON",
|
|
30
|
+
* });
|
|
31
|
+
* const { data } = JSON.parse(new TextDecoder().decode(bytes));
|
|
32
|
+
* return { ingested, data };
|
|
33
|
+
* });
|
|
34
|
+
*
|
|
35
|
+
* const Live = Layer.mergeAll(
|
|
36
|
+
* FetchHttpClient.layer,
|
|
37
|
+
* Tinybird.CredentialsFromEnv,
|
|
38
|
+
* );
|
|
39
|
+
*
|
|
40
|
+
* program.pipe(Effect.provide(Live), Effect.runPromise).then(console.log);
|
|
41
|
+
* ```
|
|
42
|
+
*/
|
|
43
|
+
export * from "./credentials.ts";
|
|
44
|
+
export * from "./errors.ts";
|
|
45
|
+
export * as T from "./traits.ts";
|
|
46
|
+
export { TinybirdProtocol, type TinybirdOpError, type TinybirdOpContext } from "./protocol.ts";
|
|
47
|
+
export * as Retry from "./retry.ts";
|
|
48
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyCG;AACH,cAAc,kBAAkB,CAAC;AACjC,cAAc,aAAa,CAAC;AAC5B,OAAO,KAAK,CAAC,MAAM,aAAa,CAAC;AACjC,OAAO,EAAE,gBAAgB,EAAE,KAAK,eAAe,EAAE,KAAK,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAC/F,OAAO,KAAK,KAAK,MAAM,YAAY,CAAC"}
|
package/lib/index.js
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { ErrorOf } from "@distilled.cloud/core/protocol";
|
|
2
|
+
import type * as HttpClient from "effect/http/HttpClient";
|
|
3
|
+
import { Credentials } from "./credentials.ts";
|
|
4
|
+
import { TinybirdParseError, UnknownTinybirdError, type TinybirdServiceError } from "./errors.ts";
|
|
5
|
+
/**
|
|
6
|
+
* What every generated Tinybird operation fails with besides its own errors:
|
|
7
|
+
* the errors declared on the service, and the errors declared on the protocol.
|
|
8
|
+
* Nobody lists the protocol's: its type carries what its code fails with (a
|
|
9
|
+
* response that does not match its schema, a failed response nothing declares,
|
|
10
|
+
* core's REST errors, and what resolving the credentials fails with).
|
|
11
|
+
* Generated service files annotate operations with `API.OperationMethod<I, O,
|
|
12
|
+
* TinybirdOpError, TinybirdOpContext>` explicitly so the compiler never infers
|
|
13
|
+
* these back out of the schema generics.
|
|
14
|
+
*/
|
|
15
|
+
export type TinybirdOpError = TinybirdServiceError | ErrorOf<typeof TinybirdProtocol>;
|
|
16
|
+
/** Context (requirements) shared by every generated Tinybird operation. */
|
|
17
|
+
export type TinybirdOpContext = Credentials | HttpClient.HttpClient;
|
|
18
|
+
export declare const TinybirdProtocol: import("@distilled.cloud/core/protocol").Protocol<TinybirdParseError | UnknownTinybirdError | import("@distilled.cloud/core/protocol-rest").RestProtocolError, Credentials>;
|
|
19
|
+
//# sourceMappingURL=protocol.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"protocol.d.ts","sources":["../src/protocol.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,gCAAgC,CAAC;AAiB9D,OAAO,KAAK,KAAK,UAAU,MAAM,wBAAwB,CAAC;AAE1D,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,kBAAkB,EAAE,oBAAoB,EAAE,KAAK,oBAAoB,EAAE,MAAM,aAAa,CAAC;AAElG;;;;;;;;;GASG;AACH,MAAM,MAAM,eAAe,GAAG,oBAAoB,GAAG,OAAO,CAAC,OAAO,gBAAgB,CAAC,CAAC;AAEtF,2EAA2E;AAC3E,MAAM,MAAM,iBAAiB,GAAG,WAAW,GAAG,UAAU,CAAC,UAAU,CAAC;AAEpE,eAAO,MAAM,gBAAgB,6KAU3B,CAAC"}
|
package/lib/protocol.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { protocol$TinybirdProtocol as TinybirdProtocol } from "./_bundle/sdk.js";
|
package/lib/retry.d.ts
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import * as Retries from "@distilled.cloud/core/retry";
|
|
2
|
+
/**
|
|
3
|
+
* Tinybird retry surface -- a veneer over `@distilled.cloud/core/retry`.
|
|
4
|
+
*
|
|
5
|
+
* The `Retry` service tag is threaded into every generated operation via
|
|
6
|
+
* `API.make({ retry: Retry })`, so a caller-installed policy applies to all
|
|
7
|
+
* Tinybird calls below it and core's `makeDefault` is the fallback when none is
|
|
8
|
+
* provided.
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```ts
|
|
12
|
+
* import * as Tinybird from "@distilled.cloud/tinybird";
|
|
13
|
+
*
|
|
14
|
+
* myEffect.pipe(Tinybird.Retry.transient);
|
|
15
|
+
* ```
|
|
16
|
+
*/
|
|
17
|
+
import * as Context from "effect/Context";
|
|
18
|
+
import * as Effect from "effect/Effect";
|
|
19
|
+
export type Options = Retries.Options;
|
|
20
|
+
export type Factory = Retries.Factory;
|
|
21
|
+
export type Policy = Retries.Policy;
|
|
22
|
+
declare const Retry_base: Context.ServiceClass<Retry, "TinybirdRetry", Retries.Policy>;
|
|
23
|
+
/** Context tag for configuring retry behavior of Tinybird API calls. */
|
|
24
|
+
export declare class Retry extends /*@__PURE__*/ Retry_base {
|
|
25
|
+
}
|
|
26
|
+
/** Provides a custom retry policy to every Tinybird API call below it. */
|
|
27
|
+
export declare const policy: {
|
|
28
|
+
(options: Options): <A, E, R>(effect: Effect.Effect<A, E, R>) => Effect.Effect<A, E, Exclude<R, Retry>>;
|
|
29
|
+
(factory: Factory): <A, E, R>(effect: Effect.Effect<A, E, R>) => Effect.Effect<A, E, Exclude<R, Retry>>;
|
|
30
|
+
};
|
|
31
|
+
/** Disables all automatic retries. */
|
|
32
|
+
export declare const none: <A, E, R>(effect: Effect.Effect<A, E, R>) => Effect.Effect<A, E, Exclude<R, Retry>>;
|
|
33
|
+
/**
|
|
34
|
+
* The default retry policy (core's): transient/throttling/retryable errors,
|
|
35
|
+
* capped exponential backoff with jitter, server `retryAfter` hints honored
|
|
36
|
+
* with precedence.
|
|
37
|
+
*/
|
|
38
|
+
export declare const makeDefault: Factory;
|
|
39
|
+
export declare const jittered: <Error, Env>(self: import("effect/Schedule").Schedule<unknown, unknown, Error, Env>) => import("effect/Schedule").Schedule<unknown, unknown, Error, Env>;
|
|
40
|
+
export declare const capped: (max: import("effect/Duration").Duration) => <Error, Env>(self: import("effect/Schedule").Schedule<unknown, unknown, Error, Env>) => import("effect/Schedule").Schedule<unknown, unknown, Error, Env>;
|
|
41
|
+
/** Retry options that retry all throttling errors indefinitely. */
|
|
42
|
+
export declare const throttlingOptions: Options;
|
|
43
|
+
/** Retries all throttling errors indefinitely (honoring server hints). */
|
|
44
|
+
export declare const throttling: <A, E, R>(effect: Effect.Effect<A, E, R>) => Effect.Effect<A, E, Exclude<R, Retry>>;
|
|
45
|
+
/** Retry options that retry all transient errors indefinitely. */
|
|
46
|
+
export declare const transientOptions: Options;
|
|
47
|
+
/** Retries all transient errors indefinitely. */
|
|
48
|
+
export declare const transient: <A, E, R>(effect: Effect.Effect<A, E, R>) => Effect.Effect<A, E, Exclude<R, Retry>>;
|
|
49
|
+
export {};
|
|
50
|
+
//# sourceMappingURL=retry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"retry.d.ts","sources":["../src/retry.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,OAAO,MAAM,6BAA6B,CAAC;AACvD;;;;;;;;;;;;;;GAcG;AACH,OAAO,KAAK,OAAO,MAAM,gBAAgB,CAAC;AAC1C,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AAGxC,MAAM,MAAM,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC;AACtC,MAAM,MAAM,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC;AACtC,MAAM,MAAM,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;;AAEpC,wEAAwE;AACxE,qBAAa,KAAM,SAAQ,aAAa,CAAC,UAAiD;CAAG;AAE7F,0EAA0E;AAC1E,eAAO,MAAM,MAAM,EAAE;IACnB,CACE,OAAO,EAAE,OAAO,GACf,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,KAAK,MAAM,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,EAAE,OAAO,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC,CAAC;IACvF,CACE,OAAO,EAAE,OAAO,GACf,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,KAAK,MAAM,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,EAAE,OAAO,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC,CAAC;CACU,CAAC;AAEpG,sCAAsC;AACtC,eAAO,MAAM,IAAI,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EACzB,MAAM,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,KAC3B,MAAM,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,EAAE,OAAO,CAAC,CAAC,EAAE,KAAK,CAAC,CAEzC,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,WAAW,EAAE,OAA6B,CAAC;AAExD,eAAO,MAAM,QAAQ,0JAAmB,CAAC;AACzC,eAAO,MAAM,MAAM,uMAAiB,CAAC;AAErC,mEAAmE;AACnE,eAAO,MAAM,iBAAiB,EAAE,OAAmC,CAAC;AAEpE,0EAA0E;AAC1E,eAAO,MAAM,UAAU,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAC/B,MAAM,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,KAC3B,MAAM,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,EAAE,OAAO,CAAC,CAAC,EAAE,KAAK,CAAC,CAAmD,CAAC;AAE9F,kEAAkE;AAClE,eAAO,MAAM,gBAAgB,EAAE,OAAkC,CAAC;AAElE,iDAAiD;AACjD,eAAO,MAAM,SAAS,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAC9B,MAAM,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,KAC3B,MAAM,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,EAAE,OAAO,CAAC,CAAC,EAAE,KAAK,CAAC,CAAkD,CAAC"}
|
package/lib/retry.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { retry$Retry as Retry, retry$capped as capped, retry$jittered as jittered, retry$makeDefault as makeDefault, retry$none as none, retry$policy as policy, retry$throttling as throttling, retry$throttlingOptions as throttlingOptions, retry$transient as transient, retry$transientOptions as transientOptions } from "./_bundle/sdk.js";
|