@distilled.cloud/clickhouse-cloud 0.0.0-stage → 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 +138 -2
- package/lib/.lazy.json +1 -0
- package/lib/_bundle/lazy.js +4 -0
- package/lib/_bundle/sdk.js +2 -0
- package/lib/_bundle/sdk.js.map +1 -0
- package/lib/credentials.d.ts +34 -0
- package/lib/credentials.d.ts.map +1 -0
- package/lib/credentials.js +1 -0
- package/lib/errors.d.ts +58 -0
- package/lib/errors.d.ts.map +1 -0
- package/lib/errors.js +1 -0
- package/lib/index.d.ts +49 -0
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +6 -0
- package/lib/pagination.d.ts +10 -0
- package/lib/pagination.d.ts.map +1 -0
- package/lib/pagination.js +1 -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 +35 -0
- package/lib/retry.d.ts.map +1 -0
- package/lib/retry.js +1 -0
- package/lib/services/api_keys.d.ts +175 -0
- package/lib/services/api_keys.d.ts.map +1 -0
- package/lib/services/api_keys.js +2 -0
- package/lib/services/api_keys.js.map +1 -0
- package/lib/services/backup.d.ts +117 -0
- package/lib/services/backup.d.ts.map +1 -0
- package/lib/services/backup.js +2 -0
- package/lib/services/backup.js.map +1 -0
- package/lib/services/billing.d.ts +69 -0
- package/lib/services/billing.d.ts.map +1 -0
- package/lib/services/billing.js +2 -0
- package/lib/services/billing.js.map +1 -0
- package/lib/services/click_pipes.d.ts +1637 -0
- package/lib/services/click_pipes.d.ts.map +1 -0
- package/lib/services/click_pipes.js +31 -0
- package/lib/services/click_pipes.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/organization.d.ts +336 -0
- package/lib/services/organization.d.ts.map +1 -0
- package/lib/services/organization.js +2 -0
- package/lib/services/organization.js.map +1 -0
- package/lib/services/postgres.d.ts +726 -0
- package/lib/services/postgres.d.ts.map +1 -0
- package/lib/services/postgres.js +31 -0
- package/lib/services/postgres.js.map +1 -0
- package/lib/services/prometheus.d.ts +71 -0
- package/lib/services/prometheus.d.ts.map +1 -0
- package/lib/services/prometheus.js +2 -0
- package/lib/services/prometheus.js.map +1 -0
- package/lib/services/query_api_endpoints.d.ts +189 -0
- package/lib/services/query_api_endpoints.d.ts.map +1 -0
- package/lib/services/query_api_endpoints.js +2 -0
- package/lib/services/query_api_endpoints.js.map +1 -0
- package/lib/services/role_management.d.ts +159 -0
- package/lib/services/role_management.d.ts.map +1 -0
- package/lib/services/role_management.js +2 -0
- package/lib/services/role_management.js.map +1 -0
- package/lib/services/saved_queries.d.ts +129 -0
- package/lib/services/saved_queries.d.ts.map +1 -0
- package/lib/services/saved_queries.js +2 -0
- package/lib/services/saved_queries.js.map +1 -0
- package/lib/services/service.d.ts +886 -0
- package/lib/services/service.d.ts.map +1 -0
- package/lib/services/service.js +41 -0
- package/lib/services/service.js.map +1 -0
- package/lib/services/udf.d.ts +373 -0
- package/lib/services/udf.d.ts.map +1 -0
- package/lib/services/udf.js +24 -0
- package/lib/services/udf.js.map +1 -0
- package/lib/services/user_management.d.ts +150 -0
- package/lib/services/user_management.d.ts.map +1 -0
- package/lib/services/user_management.js +2 -0
- package/lib/services/user_management.js.map +1 -0
- package/lib/services.lazy/api_keys.js +1 -0
- package/lib/services.lazy/backup.js +1 -0
- package/lib/services.lazy/billing.js +1 -0
- package/lib/services.lazy/click_pipes.js +3 -0
- package/lib/services.lazy/index.js +3 -0
- package/lib/services.lazy/organization.js +1 -0
- package/lib/services.lazy/postgres.js +4 -0
- package/lib/services.lazy/prometheus.js +1 -0
- package/lib/services.lazy/query_api_endpoints.js +1 -0
- package/lib/services.lazy/role_management.js +1 -0
- package/lib/services.lazy/saved_queries.js +1 -0
- package/lib/services.lazy/service.js +4 -0
- package/lib/services.lazy/udf.js +3 -0
- package/lib/services.lazy/user_management.js +1 -0
- package/lib/traits.d.ts +11 -0
- package/lib/traits.d.ts.map +1 -0
- package/lib/traits.js +1 -0
- package/lib/unstable-services/backup.d.ts +165 -0
- package/lib/unstable-services/backup.d.ts.map +1 -0
- package/lib/unstable-services/backup.js +2 -0
- package/lib/unstable-services/backup.js.map +1 -0
- package/lib/unstable-services/billing.d.ts +84 -0
- package/lib/unstable-services/billing.d.ts.map +1 -0
- package/lib/unstable-services/billing.js +2 -0
- package/lib/unstable-services/billing.js.map +1 -0
- package/lib/unstable-services/click_pipes.d.ts +324 -0
- package/lib/unstable-services/click_pipes.d.ts.map +1 -0
- package/lib/unstable-services/click_pipes.js +2 -0
- package/lib/unstable-services/click_pipes.js.map +1 -0
- package/lib/unstable-services/click_stack.d.ts +3538 -0
- package/lib/unstable-services/click_stack.d.ts.map +1 -0
- package/lib/unstable-services/click_stack.js +60 -0
- package/lib/unstable-services/click_stack.js.map +1 -0
- package/lib/unstable-services/index.d.ts +11 -0
- package/lib/unstable-services/index.d.ts.map +1 -0
- package/lib/unstable-services/index.js +10 -0
- package/lib/unstable-services/notifications.d.ts +166 -0
- package/lib/unstable-services/notifications.d.ts.map +1 -0
- package/lib/unstable-services/notifications.js +2 -0
- package/lib/unstable-services/notifications.js.map +1 -0
- package/lib/unstable-services/organization.d.ts +403 -0
- package/lib/unstable-services/organization.d.ts.map +1 -0
- package/lib/unstable-services/organization.js +26 -0
- package/lib/unstable-services/organization.js.map +1 -0
- package/lib/unstable-services/postgres.d.ts +415 -0
- package/lib/unstable-services/postgres.d.ts.map +1 -0
- package/lib/unstable-services/postgres.js +2 -0
- package/lib/unstable-services/postgres.js.map +1 -0
- package/lib/unstable-services/service.d.ts +244 -0
- package/lib/unstable-services/service.d.ts.map +1 -0
- package/lib/unstable-services/service.js +2 -0
- package/lib/unstable-services/service.js.map +1 -0
- package/lib/unstable-services/snapshot.d.ts +146 -0
- package/lib/unstable-services/snapshot.d.ts.map +1 -0
- package/lib/unstable-services/snapshot.js +2 -0
- package/lib/unstable-services/snapshot.js.map +1 -0
- package/lib/unstable-services/user_management.d.ts +41 -0
- package/lib/unstable-services/user_management.d.ts.map +1 -0
- package/lib/unstable-services/user_management.js +2 -0
- package/lib/unstable-services/user_management.js.map +1 -0
- package/lib/unstable-services.lazy/backup.js +1 -0
- package/lib/unstable-services.lazy/billing.js +1 -0
- package/lib/unstable-services.lazy/click_pipes.js +1 -0
- package/lib/unstable-services.lazy/click_stack.js +4 -0
- package/lib/unstable-services.lazy/index.js +3 -0
- package/lib/unstable-services.lazy/notifications.js +1 -0
- package/lib/unstable-services.lazy/organization.js +4 -0
- package/lib/unstable-services.lazy/postgres.js +1 -0
- package/lib/unstable-services.lazy/service.js +1 -0
- package/lib/unstable-services.lazy/snapshot.js +1 -0
- package/lib/unstable-services.lazy/user_management.js +1 -0
- package/package.json +94 -3
- package/src/credentials.ts +88 -0
- package/src/errors.ts +76 -0
- package/src/index.ts +53 -0
- package/src/pagination.ts +9 -0
- package/src/protocol.ts +76 -0
- package/src/retry.ts +53 -0
- package/src/services/api_keys.ts +466 -0
- package/src/services/backup.ts +347 -0
- package/src/services/billing.ts +170 -0
- package/src/services/click_pipes.ts +3483 -0
- package/src/services/index.ts +14 -0
- package/src/services/organization.ts +901 -0
- package/src/services/postgres.ts +1967 -0
- package/src/services/prometheus.ts +271 -0
- package/src/services/query_api_endpoints.ts +466 -0
- package/src/services/role_management.ts +436 -0
- package/src/services/saved_queries.ts +384 -0
- package/src/services/service.ts +2112 -0
- package/src/services/udf.ts +1019 -0
- package/src/services/user_management.ts +508 -0
- package/src/traits.ts +45 -0
- package/src/unstable-services/backup.ts +422 -0
- package/src/unstable-services/billing.ts +232 -0
- package/src/unstable-services/click_pipes.ts +702 -0
- package/src/unstable-services/click_stack.ts +7114 -0
- package/src/unstable-services/index.ts +11 -0
- package/src/unstable-services/notifications.ts +451 -0
- package/src/unstable-services/organization.ts +1107 -0
- package/src/unstable-services/postgres.ts +1061 -0
- package/src/unstable-services/service.ts +795 -0
- package/src/unstable-services/snapshot.ts +397 -0
- package/src/unstable-services/user_management.ts +127 -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,3 +1,139 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @distilled.cloud/clickhouse-cloud
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Effect-native ClickHouse Cloud SDK, generated from the OpenAPI document the API serves at [`https://api.clickhouse.cloud/v1`](https://api.clickhouse.cloud/v1).
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @distilled.cloud/clickhouse-cloud effect
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Quick start
|
|
12
|
+
|
|
13
|
+
List the organization's services.
|
|
14
|
+
|
|
15
|
+
```ts
|
|
16
|
+
import { Effect, Layer } from "effect";
|
|
17
|
+
import * as FetchHttpClient from "effect/http/FetchHttpClient";
|
|
18
|
+
import * as ClickHouseCloud from "@distilled.cloud/clickhouse-cloud";
|
|
19
|
+
import * as Organization from "@distilled.cloud/clickhouse-cloud/organization";
|
|
20
|
+
import * as Service from "@distilled.cloud/clickhouse-cloud/service";
|
|
21
|
+
|
|
22
|
+
const program = Effect.gen(function* () {
|
|
23
|
+
const organizations = yield* Organization.listOrganizations({});
|
|
24
|
+
const organizationId = organizations.result[0]?.id;
|
|
25
|
+
if (organizationId === undefined) return [];
|
|
26
|
+
|
|
27
|
+
const services = yield* Service.listServices({ organizationId });
|
|
28
|
+
return services.map(({ name, state, region }) => ({ name, state, region }));
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
const Live = Layer.mergeAll(
|
|
32
|
+
FetchHttpClient.layer,
|
|
33
|
+
ClickHouseCloud.CredentialsFromEnv,
|
|
34
|
+
);
|
|
35
|
+
|
|
36
|
+
program.pipe(Effect.provide(Live), Effect.runPromise).then(console.log);
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
Operations return the payload of ClickHouse's `{ status, requestId, result }`
|
|
40
|
+
response. Create a service, then stop and delete it (a service must be stopped
|
|
41
|
+
before it can be deleted, and both are asynchronous):
|
|
42
|
+
|
|
43
|
+
```ts
|
|
44
|
+
import { Effect, Schedule } from "effect";
|
|
45
|
+
import * as Service from "@distilled.cloud/clickhouse-cloud/service";
|
|
46
|
+
|
|
47
|
+
const lifecycle = (organizationId: string) =>
|
|
48
|
+
Effect.gen(function* () {
|
|
49
|
+
const { service } = yield* Service.createService({
|
|
50
|
+
organizationId,
|
|
51
|
+
name: "distilled-example",
|
|
52
|
+
provider: "aws",
|
|
53
|
+
region: "us-east-1",
|
|
54
|
+
ipAccessList: [{ source: "0.0.0.0/0", description: "anywhere" }],
|
|
55
|
+
});
|
|
56
|
+
if (service?.id === undefined) return;
|
|
57
|
+
const serviceId = service.id;
|
|
58
|
+
|
|
59
|
+
yield* Service.updateServiceState({
|
|
60
|
+
organizationId,
|
|
61
|
+
serviceId,
|
|
62
|
+
command: "stop",
|
|
63
|
+
});
|
|
64
|
+
yield* Service.getService({ organizationId, serviceId }).pipe(
|
|
65
|
+
Effect.repeat({
|
|
66
|
+
until: ({ state }) => state === "stopped",
|
|
67
|
+
schedule: Schedule.spaced("15 seconds"),
|
|
68
|
+
}),
|
|
69
|
+
);
|
|
70
|
+
yield* Service.deleteService({ organizationId, serviceId });
|
|
71
|
+
});
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
Some failures have their own error, told apart from other answers of the same
|
|
75
|
+
status by the envelope's `error` text: `DeletionProtectionEnabled` and
|
|
76
|
+
`ServiceNotTerminable` (`deleteService`, `409`), `InstanceLimitReached`
|
|
77
|
+
(`createService`, `409`), `ServiceNotIdle` (`updateServiceState`, `400`),
|
|
78
|
+
`DeletionProtectionNotEnabled` (`updatePostgresService`, `400`) and
|
|
79
|
+
`FeatureUnavailable` (a `403` for a feature the plan or organization lacks,
|
|
80
|
+
such as ClickStack that is not set up). Every other failure is the status's
|
|
81
|
+
class.
|
|
82
|
+
|
|
83
|
+
## Services
|
|
84
|
+
|
|
85
|
+
One module per API tag: `service`, `apiKeys`, `backup`, `clickPipes`,
|
|
86
|
+
`organization` (including BYOC infrastructure), `roleManagement`,
|
|
87
|
+
`userManagement`, `billing`, `prometheus`, `queryApiEndpoints`,
|
|
88
|
+
`savedQueries` and `udf`.
|
|
89
|
+
|
|
90
|
+
ClickHouse Cloud marks every operation of `clickStack`, `postgres`,
|
|
91
|
+
`notifications` and `snapshot` Beta, so those modules import from
|
|
92
|
+
`unstable/`:
|
|
93
|
+
|
|
94
|
+
```ts
|
|
95
|
+
import * as Postgres from "@distilled.cloud/clickhouse-cloud/unstable/postgres";
|
|
96
|
+
import * as ClickStack from "@distilled.cloud/clickhouse-cloud/unstable/click_stack";
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
Some operations in the other modules (BYOC infrastructure in `organization`,
|
|
100
|
+
for example) are Beta too; their modules stay on the stable path.
|
|
101
|
+
|
|
102
|
+
Operations return the `result` of the API's `{ status, requestId, result }`
|
|
103
|
+
envelope. A cursor-paginated list (`listApiKeys`, `listClickPipes`, `listUdfs`,
|
|
104
|
+
…) returns the page, `{ result, nextCursor }`, because the cursor rides beside
|
|
105
|
+
the `result`; its `.pages()` and `.items()` walk every page. The Prometheus
|
|
106
|
+
metrics operations and `postgres.getPostgresServiceCaCertificates`
|
|
107
|
+
return the response body as a `string`.
|
|
108
|
+
|
|
109
|
+
Secrets in responses come back as `Redacted`: the `keySecret` from
|
|
110
|
+
`apiKeys.createApiKey`, the service password from `service.createService` and
|
|
111
|
+
`service.updateServicePassword`, a Postgres service's `password` and
|
|
112
|
+
`connectionString`, an object-storage ClickPipe source's `connectionString`,
|
|
113
|
+
and every ClickStack webhook's `url` (for an incoming webhook the URL is the
|
|
114
|
+
credential; PagerDuty's fixed endpoint is redacted too, because all webhook
|
|
115
|
+
kinds share one response union). Secrets the API only accepts — the other
|
|
116
|
+
ClickPipes source credentials, backup bucket keys and connection strings,
|
|
117
|
+
password and key-secret hashes, a new Postgres password — are typed
|
|
118
|
+
`string | Redacted` and sent unwrapped. Key IDs (`accessKeyId`) stay plain
|
|
119
|
+
strings.
|
|
120
|
+
|
|
121
|
+
## Auth
|
|
122
|
+
|
|
123
|
+
HTTP Basic with an API key: `CLICKHOUSE_CLOUD_API_KEY_ID` as the username and
|
|
124
|
+
`CLICKHOUSE_CLOUD_API_KEY_SECRET` as the password. Optional:
|
|
125
|
+
`CLICKHOUSE_CLOUD_API_URL` (default `https://api.clickhouse.cloud`). Or build
|
|
126
|
+
the layer yourself:
|
|
127
|
+
|
|
128
|
+
```ts
|
|
129
|
+
import * as Redacted from "effect/Redacted";
|
|
130
|
+
import * as ClickHouseCloud from "@distilled.cloud/clickhouse-cloud";
|
|
131
|
+
|
|
132
|
+
const Credentials = ClickHouseCloud.credentials({
|
|
133
|
+
keyId: "…",
|
|
134
|
+
keySecret: Redacted.make(process.env.CLICKHOUSE_CLOUD_API_KEY_SECRET!),
|
|
135
|
+
});
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
Each key is limited to 10 requests per 10 seconds; a `429` surfaces as
|
|
139
|
+
`TooManyRequests`, which the default retry policy retries with backoff.
|
package/lib/.lazy.json
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"serviceDirs":["unstable-services","services"],"twins":[]}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{api$D as e,api$call as t,api$error as n,api$named as ee,api$newError as r,api$op as i,api$opPaginated as a,category$withAuthError as o,category$withBadRequestError as s,category$withConflictError as c,category$withParseError as te,config$Redacted as ne,config$String as l,config$all as re,config$withDefault as ie,pagination$paginateCursor as ae,retry$capped as u,retry$jittered as d,retry$makeDefault as f,retry$throttlingFactory as p,retry$throttlingOptions as m,retry$transientFactory as h,retry$transientOptions as g,schema_lite_typed$TaggedError as _,schema_lite_typed$Unknown as v,trait$Body as y,trait$FormDataFile as b,trait$Header as x,trait$Http as S,trait$HttpBody as C,trait$KeyDictionary as w,trait$Label as T,trait$Query as E,trait$ResponseCode as D,trait$UnionCases as O,trait$applyErrorMatchers as k,trait$bodySymbol as A,trait$errorMatchersSymbol as j,trait$formDataFileSymbol as M,trait$getErrorMatchers as N,trait$headerSymbol as P,trait$httpBodySymbol as F,trait$httpSymbol as I,trait$keyDictionarySymbol as L,trait$labelSymbol as R,trait$querySymbol as z,trait$responseCodeSymbol as B,trait$unionCasesSymbol as V}from"@distilled.cloud/core/_bundle/base";import{errors$API_ERRORS as H,errors$BadGateway as U,errors$BadRequest as W,errors$ConfigError as G,errors$Conflict as K,errors$DEFAULT_ERRORS as q,errors$Forbidden as J,errors$GatewayTimeout as Y,errors$HTTP_STATUS_MAP as oe,errors$InternalServerError as se,errors$Locked as ce,errors$NotFound as le,errors$ServiceUnavailable as ue,errors$TooManyRequests as de,errors$Unauthorized as fe,errors$UnknownErrorFields as pe,errors$UnprocessableEntity as me,protocol_rest$RawResponse as he,protocol_rest$RawResponseRoot as ge,protocol_rest$SensitiveValue as _e,protocol_rest$rawResponseRootSymbol as ve,protocol_rest$rawResponseSymbol as ye,protocol_rest$restProtocol as be,protocol_rest$sensitiveValueSymbol as xe,protocol_rest$unknownErrorProps as Se,schema_lite$Array as Ce,schema_lite$Boolean as we,schema_lite$NullOr as Te,schema_lite$Number as Ee,schema_lite$Record as De,schema_lite$String as Oe,schema_lite$Struct as ke,schema_lite$StructWithRest as Ae,schema_lite$TaggedError as je,schema_lite$Union as Me,schema_lite$Unknown as Ne,schema_lite$at as Pe,schema_lite$optional as Fe,schema_lite$suspend as Ie}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 Le from"effect/Redacted";import*as Re from"effect/encoding/Base64";const $=`https://api.clickhouse.cloud`;var Credentials=class extends (/*@__PURE__*/ X.Service()(`ClickHouseCloudCredentials`)){};const ze=/*@__PURE__*/ re({keyId:/*@__PURE__*/ l(`CLICKHOUSE_CLOUD_API_KEY_ID`),keySecret:/*@__PURE__*/ ne(`CLICKHOUSE_CLOUD_API_KEY_SECRET`),apiBaseUrl:/*@__PURE__*/ l(`CLICKHOUSE_CLOUD_API_URL`).pipe(/*@__PURE__*/ ie($))});const Be=/*@__PURE__*/ Q.effect(Credentials,/*@__PURE__*/ Z.map(/*@__PURE__*/ ze.pipe(/*@__PURE__*/ Z.map(({keyId:e,keySecret:t,apiBaseUrl:n})=>({keyId:e,keySecret:t,apiBaseUrl:n.replace(/\/+$/,``)})),/*@__PURE__*/ Z.mapError(()=>new G({message:`CLICKHOUSE_CLOUD_API_KEY_ID and CLICKHOUSE_CLOUD_API_KEY_SECRET environment variables are required`}))),e=>Z.succeed(e)));const credentials=e=>Q.succeed(Credentials,Z.succeed({keyId:e.keyId,keySecret:e.keySecret,apiBaseUrl:(e.apiBaseUrl??`https://api.clickhouse.cloud`).replace(/\/+$/,``)}));var UnknownClickHouseCloudError=class extends (/*@__PURE__*/ _()(`UnknownClickHouseCloudError`,pe)){};var ClickHouseCloudParseError=class extends (/*@__PURE__*/ _()(`ClickHouseCloudParseError`,{body:v,cause:v}).pipe(te)){};const Ve=H;const isObject=e=>typeof e===`object`&&e!==null&&!Array.isArray(e);const unwrapResult=e=>isObject(e)&&`result`in e?e.result:e;const makeProtocol=e=>be({credentials:/*@__PURE__*/ Z.flatten(Credentials),baseUrl:e=>e.apiBaseUrl,headers:e=>({Authorization:`Basic ${Re.encode(`${e.keyId}:${Le.value(e.keySecret)}`)}`}),...e?{transformResponse:unwrapResult}:{},unknownError:e=>new UnknownClickHouseCloudError(Se(e)),parseError:({body:e,cause:t})=>new ClickHouseCloudParseError({body:e,cause:t})});const He=/*@__PURE__*/ makeProtocol(true);const Ue=/*@__PURE__*/ makeProtocol(false);var Retry=class extends (/*@__PURE__*/ X.Service()(`ClickHouseCloudRetry`)){};const policy=e=>Z.provide(Q.succeed(Retry,e));const We=/*@__PURE__*/ Z.provide(/*@__PURE__*/ Q.succeed(Retry,{while:()=>false}));const Ge=/*@__PURE__*/ policy(p);const Ke=/*@__PURE__*/ policy(h);export{c as Ca,Te as Fc,Ee as Gc,De as Hc,Oe as Jc,ke as Kc,Ae as Lc,je as Mc,Me as Oc,Ne as Pc,Pe as Rc,Fe as Wc,Ie as Xc,e as a,t as b,Credentials as credentials$Credentials,Be as credentials$CredentialsFromEnv,$ as credentials$DEFAULT_API_BASE_URL,credentials as credentials$credentials,H as errors$API_ERRORS,U as errors$BadGateway,W as errors$BadRequest,ClickHouseCloudParseError as errors$ClickHouseCloudParseError,Ve as errors$ClickHouseCloudServiceErrors,G as errors$ConfigError,K as errors$Conflict,q as errors$DEFAULT_ERRORS,J as errors$Forbidden,Y as errors$GatewayTimeout,oe as errors$HTTP_STATUS_MAP,se as errors$InternalServerError,ce as errors$Locked,le as errors$NotFound,ue as errors$ServiceUnavailable,de as errors$TooManyRequests,fe as errors$Unauthorized,UnknownClickHouseCloudError as errors$UnknownClickHouseCloudError,me as errors$UnprocessableEntity,n as f,ee as l,r as m,i as n,a as o,ae as pagination$paginateCursor,Ue as protocol$ClickHouseCloudPaginatedProtocol,He as protocol$ClickHouseCloudProtocol,Retry as retry$Retry,u as retry$capped,d as retry$jittered,f as retry$makeDefault,We as retry$none,policy as retry$policy,Ge as retry$throttling,p as retry$throttlingFactory,m as retry$throttlingOptions,Ke as retry$transient,h as retry$transientFactory,g as retry$transientOptions,y as traits$Body,b as traits$FormDataFile,x as traits$Header,S as traits$Http,C as traits$HttpBody,w as traits$KeyDictionary,T as traits$Label,E as traits$Query,he as traits$RawResponse,ge as traits$RawResponseRoot,D as traits$ResponseCode,_e as traits$SensitiveValue,O as traits$UnionCases,k as traits$applyErrorMatchers,A as traits$bodySymbol,j as traits$errorMatchersSymbol,M as traits$formDataFileSymbol,N as traits$getErrorMatchers,P as traits$headerSymbol,F as traits$httpBodySymbol,I as traits$httpSymbol,L as traits$keyDictionarySymbol,R as traits$labelSymbol,z as traits$querySymbol,ve as traits$rawResponseRootSymbol,ye as traits$rawResponseSymbol,B as traits$responseCodeSymbol,xe as traits$sensitiveValueSymbol,V as traits$unionCasesSymbol,Ce as wc,we as xc,o as ya,s as za};
|
|
2
|
+
//# sourceMappingURL=sdk.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sdk.js","names":["Schema.Unknown","Category.withParseError","D","call","error","named","newError","op","opPaginated","withAuthError","withBadRequestError","withConflictError","withParseError","Redacted$3","String$2","all$1","withDefault","paginateCursor","capped","jittered","makeDefault","throttlingFactory","throttlingOptions","transientFactory","transientOptions","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","RawResponse","RawResponseRoot","SensitiveValue","rawResponseRootSymbol","rawResponseSymbol","restProtocol","sensitiveValueSymbol","unknownErrorProps","Array$1","Boolean","NullOr","Number","Record","String","Struct","StructWithRest","TaggedError","Union","Unknown","at","optional","suspend","Context","Effect","Layer","Redacted","Base64","DEFAULT_API_BASE_URL","envConfig","CredentialsFromEnv","apiBaseUrl","config","ClickHouseCloudServiceErrors","value","body","creds","unwrap","info","ClickHouseCloudProtocol","ClickHouseCloudPaginatedProtocol","optionsOrFactory","none","throttling","transient"],"sources":["../../src/credentials.ts","../../src/errors.ts","../../src/protocol.ts","../../src/retry.ts"],"mappings":"08EAsBA,MAAa8F,EAAuB,+BAWpC,IAAa,YAAb,eACwB,gBAAQ,QAA4C,CAAC,CACzE,4BACF,EAAA,AAAE,CAAC,EAEL,MAAMC,GAA0B,iBAAiB,CAC/C,MAAqB,gBAAoB,6BAA6B,EACtE,UAAyB,iBAAsB,iCAAiC,EAChF,WAA0B,gBAAoB,0BAA0B,CAAC,CAAC,KAC1D,iBAAyBD,CAAoB,CAC7D,CACF,CAAC,EASD,MAAaE,GAA0E,gBAAM,OAC3F,YACc,gBAAO,IACL,iBAAU,KACR,gBAAO,KAAK,CAAE,QAAO,YAAW,iBAAkB,CAC9D,QACA,YACA,WAAYC,EAAW,QAAQ,OAAQ,EAAE,CAC3C,EAAE,EACY,gBAAO,aAEjB,IAAI5C,EAAY,CACd,QACE,oGACJ,CAAC,CACL,CACF,EACC,GAAWqC,EAAO,QAAQQ,CAAM,CACnC,CACF,EAGA,MAAa,YAAe,GAK1BP,EAAM,QACJ,YACAD,EAAO,QAAQ,CACb,MAAOQ,EAAO,MACd,UAAWA,EAAO,UAClB,YAAaA,EAAO,YAAA,+BAAA,CAAoC,QAAQ,OAAQ,EAAE,CAC5E,CAAC,CACH,ECrCF,IAAa,4BAAb,eACwB,gBAAgD,CAAC,CACrE,8BACAjC,EACF,EAAA,AAAE,CAAC,EAGL,IAAa,0BAAb,eACwB,gBAA8C,CAAC,CACnE,4BACA,CACE,KAAMjE,EACN,MAAOA,CACT,CACF,CAAC,CAAC,KAAKC,EAAuB,EAAA,AAAE,CAAC,EAQnC,MAAakG,GAA+BjD,ECpB5C,MAAM,SAAY,GAChB,OAAOkD,IAAU,UAAYA,IAAU,MAAQ,CAAC,MAAM,QAAQA,CAAK,EAErE,MAAM,aAAgB,GACpB,SAASC,CAAI,GAAK,WAAYA,EAAOA,EAAK,OAASA,EAErD,MAAM,aAAgB,GACpB7B,GAAa,CAGX,YAA2B,gBAAO,QAAQ,WAAW,EACrD,QAAU,GAAU8B,EAAM,WAC1B,QAAU,IAAW,CACnB,cAAe,SAAST,GAAO,OAAO,GAAGS,EAAM,MAAM,GAAGV,GAAS,MAAMU,EAAM,SAAS,GAAG,GAC3F,GACA,GAAIC,EAAS,CAAE,kBAAmB,YAAa,EAAI,CAAC,EACpD,aAAe,GAAS,IAAI,4BAA4B7B,GAAkB8B,CAAI,CAAC,EAC/E,YAAa,CAAE,OAAM,WAAY,IAAI,0BAA0B,CAAE,OAAM,OAAM,CAAC,CAChF,CAAC,EAEH,MAAaC,GAAwC,2BAAa,IAAI,EAGtE,MAAaC,GAAiD,2BAAa,KAAK,ECtChF,IAAa,MAAb,eAAyC,gBAAQ,QAAuB,CAAC,CAAC,sBAAsB,EAAA,AAAE,CAAC,EAGnG,MAAa,OAAU,GACrBhB,EAAO,QAAQC,EAAM,QAAQ,MAAOgB,CAAgB,CAAC,EAGvD,MAAaC,GAAqB,gBAAO,QACzB,gBAAM,QAAQ,MAAO,CAAE,UAAa,KAAM,CAAC,CAC3D,EAGA,MAAaC,GAA2B,qBAAOxF,CAAiB,EAGhE,MAAayF,GAA0B,qBAAOvF,CAAgB"}
|
|
@@ -0,0 +1,34 @@
|
|
|
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 * as Redacted from "effect/Redacted";
|
|
6
|
+
/** ClickHouse Cloud's API origin (the spec's `servers` entry). */
|
|
7
|
+
export declare const DEFAULT_API_BASE_URL = "https://api.clickhouse.cloud";
|
|
8
|
+
export interface Config {
|
|
9
|
+
/** API key ID, sent as the Basic-auth username. */
|
|
10
|
+
readonly keyId: string;
|
|
11
|
+
/** API key secret, sent as the Basic-auth password. */
|
|
12
|
+
readonly keySecret: Redacted.Redacted<string>;
|
|
13
|
+
/** API origin, without a trailing slash. */
|
|
14
|
+
readonly apiBaseUrl: string;
|
|
15
|
+
}
|
|
16
|
+
declare const Credentials_base: Context.ServiceClass<Credentials, "ClickHouseCloudCredentials", Effect.Effect<Config, never, never>>;
|
|
17
|
+
export declare class Credentials extends /*@__PURE__*/ Credentials_base {
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Reads `CLICKHOUSE_CLOUD_API_KEY_ID` and `CLICKHOUSE_CLOUD_API_KEY_SECRET`
|
|
21
|
+
* (both required) and `CLICKHOUSE_CLOUD_API_URL` (optional).
|
|
22
|
+
*
|
|
23
|
+
* Its configuration is read and checked once, when the layer is built: a
|
|
24
|
+
* problem there fails the layer with `ConfigError`.
|
|
25
|
+
*/
|
|
26
|
+
export declare const CredentialsFromEnv: Layer.Layer<Credentials, ConfigError>;
|
|
27
|
+
/** Credentials from an API key ID, its redacted secret and an optional origin. */
|
|
28
|
+
export declare const credentials: (config: {
|
|
29
|
+
readonly keyId: string;
|
|
30
|
+
readonly keySecret: Redacted.Redacted<string>;
|
|
31
|
+
readonly apiBaseUrl?: string;
|
|
32
|
+
}) => Layer.Layer<Credentials>;
|
|
33
|
+
export {};
|
|
34
|
+
//# sourceMappingURL=credentials.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"credentials.d.ts","sources":["../src/credentials.ts"],"names":[],"mappings":"AAeA,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,QAAQ,MAAM,iBAAiB,CAAC;AAE5C,kEAAkE;AAClE,eAAO,MAAM,oBAAoB,iCAAiC,CAAC;AAEnE,MAAM,WAAW,MAAM;IACrB,mDAAmD;IACnD,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,uDAAuD;IACvD,QAAQ,CAAC,SAAS,EAAE,QAAQ,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;IAC9C,4CAA4C;IAC5C,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;CAC7B;;AAED,qBAAa,WACX,SAAQ,aAAa,CAAC,gBAErB;CAAG;AAUN;;;;;;GAMG;AACH,eAAO,MAAM,kBAAkB,EAAE,KAAK,CAAC,KAAK,CAAC,WAAW,EAAE,WAAW,CAmBpE,CAAC;AAEF,kFAAkF;AAClF,eAAO,MAAM,WAAW,WAAY;IAClC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,SAAS,EAAE,QAAQ,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;IAC9C,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC;CAC9B,KAAG,KAAK,CAAC,KAAK,CAAC,WAAW,CAQxB,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,58 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ClickHouse Cloud error types.
|
|
3
|
+
*
|
|
4
|
+
* Re-exports the common HTTP errors from core and adds the unknown-error and
|
|
5
|
+
* parse-error classes.
|
|
6
|
+
*
|
|
7
|
+
* Every ClickHouse Cloud failure carries the same envelope -- `{ "status":
|
|
8
|
+
* number, "error": string, "requestId": string }` -- where `error` is a
|
|
9
|
+
* human-readable description and there is no machine-readable code. The spec
|
|
10
|
+
* lists `400` and `500` on every operation and a few more statuses on some,
|
|
11
|
+
* all against that one envelope, so the SDK dispatches on the status (the
|
|
12
|
+
* classes here) and keeps the body on {@link UnknownClickHouseCloudError}
|
|
13
|
+
* for the statuses nothing else maps (the documented `410` and `424`
|
|
14
|
+
* included). Where an answer means something a caller acts on, a patch under
|
|
15
|
+
* `patches/` types it per operation by status and `error` text:
|
|
16
|
+
* `DeletionProtectionEnabled`, `ServiceNotTerminable` and `InstanceLimitReached`
|
|
17
|
+
* (409), `FeatureUnavailable` (a 403 for a feature the plan or organization
|
|
18
|
+
* lacks, such as ClickStack not set up or a BYOC-only operation),
|
|
19
|
+
* `ServiceNotIdle` and `DeletionProtectionNotEnabled` (400). Everything else
|
|
20
|
+
* stays the status's class, with the envelope's `error` as its message.
|
|
21
|
+
*/
|
|
22
|
+
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";
|
|
23
|
+
export type { DefaultErrors } from "@distilled.cloud/core/errors";
|
|
24
|
+
import * as Schema from "@distilled.cloud/core/schema-lite-typed";
|
|
25
|
+
declare const UnknownClickHouseCloudError_base: Schema.TaggedErrorClass<"UnknownClickHouseCloudError", {
|
|
26
|
+
status: import("effect/Schema").Number;
|
|
27
|
+
code: import("effect/Schema").optional<import("effect/Schema").String>;
|
|
28
|
+
message: import("effect/Schema").optional<import("effect/Schema").String>;
|
|
29
|
+
body: import("effect/Schema").Unknown;
|
|
30
|
+
}>;
|
|
31
|
+
/**
|
|
32
|
+
* Unknown ClickHouse Cloud error -- returned when a failed response's HTTP
|
|
33
|
+
* status has no mapped error class. `status` is that HTTP status, `message`
|
|
34
|
+
* is the envelope's `error` text, and `body` is the whole response body
|
|
35
|
+
* (with its `requestId`, which ClickHouse Cloud support asks for).
|
|
36
|
+
*/
|
|
37
|
+
export declare class UnknownClickHouseCloudError extends /*@__PURE__*/ UnknownClickHouseCloudError_base {
|
|
38
|
+
}
|
|
39
|
+
declare const ClickHouseCloudParseError_base: Schema.TaggedErrorClass<"ClickHouseCloudParseError", {
|
|
40
|
+
readonly body: import("effect/Schema").Unknown;
|
|
41
|
+
readonly cause: import("effect/Schema").Unknown;
|
|
42
|
+
}> & (new (...args: any[]) => {
|
|
43
|
+
"@distilled.cloud/error/categories": {
|
|
44
|
+
ParseError: true;
|
|
45
|
+
};
|
|
46
|
+
});
|
|
47
|
+
/** A 2xx response that does not match the operation's output schema. */
|
|
48
|
+
export declare class ClickHouseCloudParseError extends /*@__PURE__*/ ClickHouseCloudParseError_base {
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* The errors declared on the ClickHouse Cloud service: any operation can
|
|
52
|
+
* return them, and every generated operation lists them as its
|
|
53
|
+
* `serviceErrors`. Today that is each of core's status classes (401, 403, 404,
|
|
54
|
+
* 429, the 5xx ...).
|
|
55
|
+
*/
|
|
56
|
+
export declare const ClickHouseCloudServiceErrors: readonly [typeof import("@distilled.cloud/core/errors").Unauthorized, typeof import("@distilled.cloud/core/errors").Forbidden, typeof import("@distilled.cloud/core/errors").NotFound, typeof import("@distilled.cloud/core/errors").BadRequest, typeof import("@distilled.cloud/core/errors").Conflict, typeof import("@distilled.cloud/core/errors").UnprocessableEntity, typeof import("@distilled.cloud/core/errors").TooManyRequests, typeof import("@distilled.cloud/core/errors").Locked, 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];
|
|
57
|
+
export type ClickHouseCloudServiceError = InstanceType<(typeof ClickHouseCloudServiceErrors)[number]>;
|
|
58
|
+
//# sourceMappingURL=errors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;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;AACtC,YAAY,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAGlE,OAAO,KAAK,MAAM,MAAM,yCAAyC,CAAC;;;;;;;AAElE;;;;;GAKG;AACH,qBAAa,2BACX,SAAQ,aAAa,CAAC,gCAGrB;CAAG;;;;;;;;;AAEN,wEAAwE;AACxE,qBAAa,yBACX,SAAQ,aAAa,CAAC,8BAMS;CAAG;AAEpC;;;;;GAKG;AACH,eAAO,MAAM,4BAA4B,+tBAAa,CAAC;AACvD,MAAM,MAAM,2BAA2B,GAAG,YAAY,CACpD,CAAC,OAAO,4BAA4B,CAAC,CAAC,MAAM,CAAC,CAC9C,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$ClickHouseCloudParseError as ClickHouseCloudParseError, errors$ClickHouseCloudServiceErrors as ClickHouseCloudServiceErrors, 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$TooManyRequests as TooManyRequests, errors$Unauthorized as Unauthorized, errors$UnknownClickHouseCloudError as UnknownClickHouseCloudError, errors$UnprocessableEntity as UnprocessableEntity } from "./_bundle/sdk.js";
|
package/lib/index.d.ts
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @distilled.cloud/clickhouse-cloud -- ClickHouse Cloud API SDK for Effect.
|
|
3
|
+
*
|
|
4
|
+
* `./services` is generated by `scripts/generate.ts` from the Smithy models
|
|
5
|
+
* that `scripts/convert.ts` converts from the OpenAPI document ClickHouse
|
|
6
|
+
* Cloud serves at `https://api.clickhouse.cloud/v1`, mirrored at
|
|
7
|
+
* `specs/spec-mirror-clickhouse-cloud/specs/openapi.json`. Everything else in
|
|
8
|
+
* this folder is hand-written.
|
|
9
|
+
*
|
|
10
|
+
* One module per API tag (`service`, `apiKeys`, `clickPipes`, ...), the
|
|
11
|
+
* split the API reference uses. A module whose every operation is Beta
|
|
12
|
+
* upstream is generated to `./unstable-services` and imported as
|
|
13
|
+
* `@distilled.cloud/clickhouse-cloud/unstable/<module>` (`postgres`,
|
|
14
|
+
* `click_stack`, ...). Operations return the `result` of
|
|
15
|
+
* the API's `{ status, requestId, result }` envelope; a cursor page keeps the
|
|
16
|
+
* envelope, with its `result` page beside `nextCursor`.
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* ```ts
|
|
20
|
+
* import { Effect, Layer } from "effect";
|
|
21
|
+
* import * as FetchHttpClient from "effect/http/FetchHttpClient";
|
|
22
|
+
* import * as ClickHouseCloud from "@distilled.cloud/clickhouse-cloud";
|
|
23
|
+
* import * as Organization from "@distilled.cloud/clickhouse-cloud/organization";
|
|
24
|
+
* import * as Service from "@distilled.cloud/clickhouse-cloud/service";
|
|
25
|
+
*
|
|
26
|
+
* const program = Effect.gen(function* () {
|
|
27
|
+
* const organizations = yield* Organization.listOrganizations({});
|
|
28
|
+
* const organizationId = organizations.result[0]?.id;
|
|
29
|
+
* if (organizationId === undefined) return [];
|
|
30
|
+
*
|
|
31
|
+
* const services = yield* Service.listServices({ organizationId });
|
|
32
|
+
* return services.map(({ name, state, region }) => ({ name, state, region }));
|
|
33
|
+
* });
|
|
34
|
+
*
|
|
35
|
+
* const Live = Layer.mergeAll(
|
|
36
|
+
* FetchHttpClient.layer,
|
|
37
|
+
* ClickHouseCloud.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 { ClickHouseCloudProtocol, ClickHouseCloudPaginatedProtocol, type ClickHouseCloudOpError, type ClickHouseCloudOpContext, } from "./protocol.ts";
|
|
47
|
+
export { paginateCursor } from "./pagination.ts";
|
|
48
|
+
export * as Retry from "./retry.ts";
|
|
49
|
+
//# 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,EACL,uBAAuB,EACvB,gCAAgC,EAChC,KAAK,sBAAsB,EAC3B,KAAK,wBAAwB,GAC9B,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AACjD,OAAO,KAAK,KAAK,MAAM,YAAY,CAAC"}
|
package/lib/index.js
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export * from "./credentials.js";
|
|
2
|
+
export * from "./errors.js";
|
|
3
|
+
export * as T from "./traits.js";
|
|
4
|
+
export { ClickHouseCloudProtocol, ClickHouseCloudPaginatedProtocol } from "./protocol.js";
|
|
5
|
+
export { paginateCursor } from "./pagination.js";
|
|
6
|
+
export * as Retry from "./retry.js";
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ClickHouse Cloud pagination -- hand-written.
|
|
3
|
+
*
|
|
4
|
+
* Cursor-paginated lists take `cursor` and `limit` and answer with the page
|
|
5
|
+
* under `result` beside `nextCursor` (`null` on the last page). Generated
|
|
6
|
+
* operations pass core's {@link paginateCursor} strategy to
|
|
7
|
+
* `API.makePaginated`; `patches/<service>/pagination.json` marks them.
|
|
8
|
+
*/
|
|
9
|
+
export { paginateCursor } from "@distilled.cloud/core/pagination";
|
|
10
|
+
//# sourceMappingURL=pagination.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pagination.d.ts","sources":["../src/pagination.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,EAAE,cAAc,EAAE,MAAM,kCAAkC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { pagination$paginateCursor as paginateCursor } from "./_bundle/sdk.js";
|
|
@@ -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 { ClickHouseCloudParseError, UnknownClickHouseCloudError, type ClickHouseCloudServiceError } from "./errors.ts";
|
|
5
|
+
/**
|
|
6
|
+
* What every generated ClickHouse Cloud operation fails with besides its own
|
|
7
|
+
* errors: the service's errors, the protocol's, and what resolving the
|
|
8
|
+
* credentials fails with. Generated service files annotate operations with
|
|
9
|
+
* `API.OperationMethod<I, O, ClickHouseCloudOpError,
|
|
10
|
+
* ClickHouseCloudOpContext>` explicitly so the compiler never infers these
|
|
11
|
+
* back out of the schema generics.
|
|
12
|
+
*/
|
|
13
|
+
export type ClickHouseCloudOpError = ClickHouseCloudServiceError | ErrorOf<typeof ClickHouseCloudProtocol | typeof ClickHouseCloudPaginatedProtocol>;
|
|
14
|
+
/** Context (requirements) shared by every generated ClickHouse Cloud operation. */
|
|
15
|
+
export type ClickHouseCloudOpContext = Credentials | HttpClient.HttpClient;
|
|
16
|
+
export declare const ClickHouseCloudProtocol: import("@distilled.cloud/core/protocol").Protocol<ClickHouseCloudParseError | UnknownClickHouseCloudError | import("@distilled.cloud/core/protocol-rest").RestProtocolError, Credentials>;
|
|
17
|
+
/** The protocol for cursor-paginated operations: the envelope stays whole. */
|
|
18
|
+
export declare const ClickHouseCloudPaginatedProtocol: import("@distilled.cloud/core/protocol").Protocol<ClickHouseCloudParseError | UnknownClickHouseCloudError | 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;AA4B9D,OAAO,KAAK,KAAK,UAAU,MAAM,wBAAwB,CAAC;AAE1D,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EACL,yBAAyB,EACzB,2BAA2B,EAC3B,KAAK,2BAA2B,EACjC,MAAM,aAAa,CAAC;AAErB;;;;;;;GAOG;AACH,MAAM,MAAM,sBAAsB,GAC9B,2BAA2B,GAC3B,OAAO,CAAC,OAAO,uBAAuB,GAAG,OAAO,gCAAgC,CAAC,CAAC;AAEtF,mFAAmF;AACnF,MAAM,MAAM,wBAAwB,GAAG,WAAW,GAAG,UAAU,CAAC,UAAU,CAAC;AAsB3E,eAAO,MAAM,uBAAuB,2LAAmC,CAAC;AAExE,8EAA8E;AAC9E,eAAO,MAAM,gCAAgC,2LAAoC,CAAC"}
|
package/lib/protocol.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { protocol$ClickHouseCloudPaginatedProtocol as ClickHouseCloudPaginatedProtocol, protocol$ClickHouseCloudProtocol as ClickHouseCloudProtocol } from "./_bundle/sdk.js";
|
package/lib/retry.d.ts
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ClickHouse Cloud retry surface -- a veneer over `@distilled.cloud/core/retry`.
|
|
3
|
+
*
|
|
4
|
+
* The `Retry` service tag is threaded into every generated operation, so a
|
|
5
|
+
* caller-installed policy applies to all ClickHouse Cloud calls below it and
|
|
6
|
+
* core's `makeDefault` is the fallback when none is provided.
|
|
7
|
+
*
|
|
8
|
+
* Each API key is limited to 10 requests per 10 seconds. A tripped limit is a
|
|
9
|
+
* `429`, which core maps to `TooManyRequests`; the default policy retries it
|
|
10
|
+
* with backoff and honors a `Retry-After` header.
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```ts
|
|
14
|
+
* import * as ClickHouseCloud from "@distilled.cloud/clickhouse-cloud";
|
|
15
|
+
*
|
|
16
|
+
* myEffect.pipe(ClickHouseCloud.Retry.transient);
|
|
17
|
+
* ```
|
|
18
|
+
*/
|
|
19
|
+
import { type Policy } from "@distilled.cloud/core/retry";
|
|
20
|
+
import * as Context from "effect/Context";
|
|
21
|
+
import * as Effect from "effect/Effect";
|
|
22
|
+
export { type Factory, type Options, type Policy, capped, jittered, makeDefault, throttlingFactory, throttlingOptions, transientFactory, transientOptions, } from "@distilled.cloud/core/retry";
|
|
23
|
+
declare const Retry_base: Context.ServiceClass<Retry, "ClickHouseCloudRetry", Policy>;
|
|
24
|
+
/** Context tag for configuring retry behavior of ClickHouse Cloud API calls. */
|
|
25
|
+
export declare class Retry extends /*@__PURE__*/ Retry_base {
|
|
26
|
+
}
|
|
27
|
+
/** Provides a custom retry policy to every ClickHouse Cloud API call below it. */
|
|
28
|
+
export declare const policy: (optionsOrFactory: Policy) => <A, E, R>(self: Effect.Effect<A, E, R>) => Effect.Effect<A, E, Exclude<R, Retry>>;
|
|
29
|
+
/** Disables all automatic retries. */
|
|
30
|
+
export declare const none: <A, E, R>(self: Effect.Effect<A, E, R>) => Effect.Effect<A, E, Exclude<R, Retry>>;
|
|
31
|
+
/** Retries all throttling errors indefinitely (honoring server hints). */
|
|
32
|
+
export declare const throttling: <A, E, R>(self: Effect.Effect<A, E, R>) => Effect.Effect<A, E, Exclude<R, Retry>>;
|
|
33
|
+
/** Retries all transient errors indefinitely (honoring server hints). */
|
|
34
|
+
export declare const transient: <A, E, R>(self: Effect.Effect<A, E, R>) => Effect.Effect<A, E, Exclude<R, Retry>>;
|
|
35
|
+
//# sourceMappingURL=retry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"retry.d.ts","sources":["../src/retry.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AACH,OAAO,EAAE,KAAK,MAAM,EAAuC,MAAM,6BAA6B,CAAC;AAC/F,OAAO,KAAK,OAAO,MAAM,gBAAgB,CAAC;AAC1C,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AAGxC,OAAO,EACL,KAAK,OAAO,EACZ,KAAK,OAAO,EACZ,KAAK,MAAM,EACX,MAAM,EACN,QAAQ,EACR,WAAW,EACX,iBAAiB,EACjB,iBAAiB,EACjB,gBAAgB,EAChB,gBAAgB,GACjB,MAAM,6BAA6B,CAAC;;AAErC,gFAAgF;AAChF,qBAAa,KAAM,SAAQ,aAAa,CAAC,UAAwD;CAAG;AAEpG,kFAAkF;AAClF,eAAO,MAAM,MAAM,qBAAsB,MAAM,sFACS,CAAC;AAEzD,sCAAsC;AACtC,eAAO,MAAM,IAAI,mFAEhB,CAAC;AAEF,0EAA0E;AAC1E,eAAO,MAAM,UAAU,mFAA0C,CAAC;AAElE,yEAAyE;AACzE,eAAO,MAAM,SAAS,mFAAyC,CAAC"}
|