pgbeam 0.1.0
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/dist/index.d.ts +3713 -0
- package/dist/index.js +463 -0
- package/dist/operations.d.ts +3360 -0
- package/dist/operations.js +328 -0
- package/package.json +62 -0
package/dist/index.js
ADDED
|
@@ -0,0 +1,463 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Generated by scripts/generate-maps.ts — do not edit manually.
|
|
3
|
+
* Run: pnpm --filter pgbeam generate
|
|
4
|
+
*/ const operationsByTag = {
|
|
5
|
+
account: {
|
|
6
|
+
exportAccountData: {
|
|
7
|
+
method: "GET",
|
|
8
|
+
path: "/v1/account/export"
|
|
9
|
+
}
|
|
10
|
+
},
|
|
11
|
+
usage: {
|
|
12
|
+
getOrganizationActivity: {
|
|
13
|
+
method: "GET",
|
|
14
|
+
path: "/v1/organizations/{org_id}/activity"
|
|
15
|
+
},
|
|
16
|
+
listPlans: {
|
|
17
|
+
method: "GET",
|
|
18
|
+
path: "/v1/plans"
|
|
19
|
+
},
|
|
20
|
+
getOrganizationPlan: {
|
|
21
|
+
method: "GET",
|
|
22
|
+
path: "/v1/organizations/{org_id}/plan"
|
|
23
|
+
},
|
|
24
|
+
getProjectInsights: {
|
|
25
|
+
method: "GET",
|
|
26
|
+
path: "/v1/projects/{project_id}/insights"
|
|
27
|
+
},
|
|
28
|
+
getOrganizationUsage: {
|
|
29
|
+
method: "GET",
|
|
30
|
+
path: "/v1/organizations/{org_id}/usage"
|
|
31
|
+
},
|
|
32
|
+
getProjectUsage: {
|
|
33
|
+
method: "GET",
|
|
34
|
+
path: "/v1/projects/{project_id}/usage"
|
|
35
|
+
}
|
|
36
|
+
},
|
|
37
|
+
catalog: {
|
|
38
|
+
listQueryCatalog: {
|
|
39
|
+
method: "GET",
|
|
40
|
+
path: "/v1/projects/{project_id}/databases/{database_id}/catalog"
|
|
41
|
+
},
|
|
42
|
+
updateCacheRule: {
|
|
43
|
+
method: "PUT",
|
|
44
|
+
path: "/v1/projects/{project_id}/databases/{database_id}/catalog/{query_hash}/cache-rule"
|
|
45
|
+
}
|
|
46
|
+
},
|
|
47
|
+
databases: {
|
|
48
|
+
listDatabases: {
|
|
49
|
+
method: "GET",
|
|
50
|
+
path: "/v1/projects/{project_id}/databases"
|
|
51
|
+
},
|
|
52
|
+
createDatabase: {
|
|
53
|
+
method: "POST",
|
|
54
|
+
path: "/v1/projects/{project_id}/databases"
|
|
55
|
+
},
|
|
56
|
+
getDatabase: {
|
|
57
|
+
method: "GET",
|
|
58
|
+
path: "/v1/projects/{project_id}/databases/{database_id}"
|
|
59
|
+
},
|
|
60
|
+
updateDatabase: {
|
|
61
|
+
method: "PATCH",
|
|
62
|
+
path: "/v1/projects/{project_id}/databases/{database_id}"
|
|
63
|
+
},
|
|
64
|
+
deleteDatabase: {
|
|
65
|
+
method: "DELETE",
|
|
66
|
+
path: "/v1/projects/{project_id}/databases/{database_id}"
|
|
67
|
+
},
|
|
68
|
+
testDatabaseConnection: {
|
|
69
|
+
method: "POST",
|
|
70
|
+
path: "/v1/projects/{project_id}/databases/{database_id}/test-connection"
|
|
71
|
+
}
|
|
72
|
+
},
|
|
73
|
+
domains: {
|
|
74
|
+
listCustomDomains: {
|
|
75
|
+
method: "GET",
|
|
76
|
+
path: "/v1/projects/{project_id}/domains"
|
|
77
|
+
},
|
|
78
|
+
createCustomDomain: {
|
|
79
|
+
method: "POST",
|
|
80
|
+
path: "/v1/projects/{project_id}/domains"
|
|
81
|
+
},
|
|
82
|
+
deleteCustomDomain: {
|
|
83
|
+
method: "DELETE",
|
|
84
|
+
path: "/v1/projects/{project_id}/domains/{domain_id}"
|
|
85
|
+
},
|
|
86
|
+
verifyCustomDomain: {
|
|
87
|
+
method: "POST",
|
|
88
|
+
path: "/v1/projects/{project_id}/domains/{domain_id}/verify"
|
|
89
|
+
}
|
|
90
|
+
},
|
|
91
|
+
health: {
|
|
92
|
+
getHealth: {
|
|
93
|
+
method: "GET",
|
|
94
|
+
path: "/v1/health"
|
|
95
|
+
}
|
|
96
|
+
},
|
|
97
|
+
onboarding: {
|
|
98
|
+
getOnboardingProgress: {
|
|
99
|
+
method: "GET",
|
|
100
|
+
path: "/v1/organizations/{org_id}/onboarding"
|
|
101
|
+
},
|
|
102
|
+
updateOnboardingProgress: {
|
|
103
|
+
method: "PATCH",
|
|
104
|
+
path: "/v1/organizations/{org_id}/onboarding"
|
|
105
|
+
}
|
|
106
|
+
},
|
|
107
|
+
projects: {
|
|
108
|
+
listProjects: {
|
|
109
|
+
method: "GET",
|
|
110
|
+
path: "/v1/projects"
|
|
111
|
+
},
|
|
112
|
+
createProject: {
|
|
113
|
+
method: "POST",
|
|
114
|
+
path: "/v1/projects"
|
|
115
|
+
},
|
|
116
|
+
getProject: {
|
|
117
|
+
method: "GET",
|
|
118
|
+
path: "/v1/projects/{project_id}"
|
|
119
|
+
},
|
|
120
|
+
updateProject: {
|
|
121
|
+
method: "PATCH",
|
|
122
|
+
path: "/v1/projects/{project_id}"
|
|
123
|
+
},
|
|
124
|
+
deleteProject: {
|
|
125
|
+
method: "DELETE",
|
|
126
|
+
path: "/v1/projects/{project_id}"
|
|
127
|
+
},
|
|
128
|
+
getProjectMetrics: {
|
|
129
|
+
method: "GET",
|
|
130
|
+
path: "/v1/projects/{project_id}/metrics"
|
|
131
|
+
}
|
|
132
|
+
},
|
|
133
|
+
regions: {
|
|
134
|
+
listRegions: {
|
|
135
|
+
method: "GET",
|
|
136
|
+
path: "/v1/regions"
|
|
137
|
+
}
|
|
138
|
+
},
|
|
139
|
+
replicas: {
|
|
140
|
+
listReplicas: {
|
|
141
|
+
method: "GET",
|
|
142
|
+
path: "/v1/databases/{database_id}/replicas"
|
|
143
|
+
},
|
|
144
|
+
createReplica: {
|
|
145
|
+
method: "POST",
|
|
146
|
+
path: "/v1/databases/{database_id}/replicas"
|
|
147
|
+
},
|
|
148
|
+
deleteReplica: {
|
|
149
|
+
method: "DELETE",
|
|
150
|
+
path: "/v1/databases/{database_id}/replicas/{replica_id}"
|
|
151
|
+
}
|
|
152
|
+
},
|
|
153
|
+
waitlist: {
|
|
154
|
+
joinWaitlist: {
|
|
155
|
+
method: "POST",
|
|
156
|
+
path: "/v1/waitlist"
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
};
|
|
160
|
+
const operationsByPath = {
|
|
161
|
+
"GET /v1/account/export": {
|
|
162
|
+
method: "GET",
|
|
163
|
+
path: "/v1/account/export",
|
|
164
|
+
operationId: "exportAccountData"
|
|
165
|
+
},
|
|
166
|
+
"GET /v1/organizations/{org_id}/activity": {
|
|
167
|
+
method: "GET",
|
|
168
|
+
path: "/v1/organizations/{org_id}/activity",
|
|
169
|
+
operationId: "getOrganizationActivity"
|
|
170
|
+
},
|
|
171
|
+
"GET /v1/plans": {
|
|
172
|
+
method: "GET",
|
|
173
|
+
path: "/v1/plans",
|
|
174
|
+
operationId: "listPlans"
|
|
175
|
+
},
|
|
176
|
+
"GET /v1/organizations/{org_id}/plan": {
|
|
177
|
+
method: "GET",
|
|
178
|
+
path: "/v1/organizations/{org_id}/plan",
|
|
179
|
+
operationId: "getOrganizationPlan"
|
|
180
|
+
},
|
|
181
|
+
"GET /v1/projects/{project_id}/databases/{database_id}/catalog": {
|
|
182
|
+
method: "GET",
|
|
183
|
+
path: "/v1/projects/{project_id}/databases/{database_id}/catalog",
|
|
184
|
+
operationId: "listQueryCatalog"
|
|
185
|
+
},
|
|
186
|
+
"PUT /v1/projects/{project_id}/databases/{database_id}/catalog/{query_hash}/cache-rule": {
|
|
187
|
+
method: "PUT",
|
|
188
|
+
path: "/v1/projects/{project_id}/databases/{database_id}/catalog/{query_hash}/cache-rule",
|
|
189
|
+
operationId: "updateCacheRule"
|
|
190
|
+
},
|
|
191
|
+
"GET /v1/projects/{project_id}/databases": {
|
|
192
|
+
method: "GET",
|
|
193
|
+
path: "/v1/projects/{project_id}/databases",
|
|
194
|
+
operationId: "listDatabases"
|
|
195
|
+
},
|
|
196
|
+
"POST /v1/projects/{project_id}/databases": {
|
|
197
|
+
method: "POST",
|
|
198
|
+
path: "/v1/projects/{project_id}/databases",
|
|
199
|
+
operationId: "createDatabase"
|
|
200
|
+
},
|
|
201
|
+
"GET /v1/projects/{project_id}/databases/{database_id}": {
|
|
202
|
+
method: "GET",
|
|
203
|
+
path: "/v1/projects/{project_id}/databases/{database_id}",
|
|
204
|
+
operationId: "getDatabase"
|
|
205
|
+
},
|
|
206
|
+
"PATCH /v1/projects/{project_id}/databases/{database_id}": {
|
|
207
|
+
method: "PATCH",
|
|
208
|
+
path: "/v1/projects/{project_id}/databases/{database_id}",
|
|
209
|
+
operationId: "updateDatabase"
|
|
210
|
+
},
|
|
211
|
+
"DELETE /v1/projects/{project_id}/databases/{database_id}": {
|
|
212
|
+
method: "DELETE",
|
|
213
|
+
path: "/v1/projects/{project_id}/databases/{database_id}",
|
|
214
|
+
operationId: "deleteDatabase"
|
|
215
|
+
},
|
|
216
|
+
"POST /v1/projects/{project_id}/databases/{database_id}/test-connection": {
|
|
217
|
+
method: "POST",
|
|
218
|
+
path: "/v1/projects/{project_id}/databases/{database_id}/test-connection",
|
|
219
|
+
operationId: "testDatabaseConnection"
|
|
220
|
+
},
|
|
221
|
+
"GET /v1/projects/{project_id}/domains": {
|
|
222
|
+
method: "GET",
|
|
223
|
+
path: "/v1/projects/{project_id}/domains",
|
|
224
|
+
operationId: "listCustomDomains"
|
|
225
|
+
},
|
|
226
|
+
"POST /v1/projects/{project_id}/domains": {
|
|
227
|
+
method: "POST",
|
|
228
|
+
path: "/v1/projects/{project_id}/domains",
|
|
229
|
+
operationId: "createCustomDomain"
|
|
230
|
+
},
|
|
231
|
+
"DELETE /v1/projects/{project_id}/domains/{domain_id}": {
|
|
232
|
+
method: "DELETE",
|
|
233
|
+
path: "/v1/projects/{project_id}/domains/{domain_id}",
|
|
234
|
+
operationId: "deleteCustomDomain"
|
|
235
|
+
},
|
|
236
|
+
"POST /v1/projects/{project_id}/domains/{domain_id}/verify": {
|
|
237
|
+
method: "POST",
|
|
238
|
+
path: "/v1/projects/{project_id}/domains/{domain_id}/verify",
|
|
239
|
+
operationId: "verifyCustomDomain"
|
|
240
|
+
},
|
|
241
|
+
"GET /v1/health": {
|
|
242
|
+
method: "GET",
|
|
243
|
+
path: "/v1/health",
|
|
244
|
+
operationId: "getHealth"
|
|
245
|
+
},
|
|
246
|
+
"GET /v1/projects/{project_id}/insights": {
|
|
247
|
+
method: "GET",
|
|
248
|
+
path: "/v1/projects/{project_id}/insights",
|
|
249
|
+
operationId: "getProjectInsights"
|
|
250
|
+
},
|
|
251
|
+
"GET /v1/organizations/{org_id}/onboarding": {
|
|
252
|
+
method: "GET",
|
|
253
|
+
path: "/v1/organizations/{org_id}/onboarding",
|
|
254
|
+
operationId: "getOnboardingProgress"
|
|
255
|
+
},
|
|
256
|
+
"PATCH /v1/organizations/{org_id}/onboarding": {
|
|
257
|
+
method: "PATCH",
|
|
258
|
+
path: "/v1/organizations/{org_id}/onboarding",
|
|
259
|
+
operationId: "updateOnboardingProgress"
|
|
260
|
+
},
|
|
261
|
+
"GET /v1/projects": {
|
|
262
|
+
method: "GET",
|
|
263
|
+
path: "/v1/projects",
|
|
264
|
+
operationId: "listProjects"
|
|
265
|
+
},
|
|
266
|
+
"POST /v1/projects": {
|
|
267
|
+
method: "POST",
|
|
268
|
+
path: "/v1/projects",
|
|
269
|
+
operationId: "createProject"
|
|
270
|
+
},
|
|
271
|
+
"GET /v1/projects/{project_id}": {
|
|
272
|
+
method: "GET",
|
|
273
|
+
path: "/v1/projects/{project_id}",
|
|
274
|
+
operationId: "getProject"
|
|
275
|
+
},
|
|
276
|
+
"PATCH /v1/projects/{project_id}": {
|
|
277
|
+
method: "PATCH",
|
|
278
|
+
path: "/v1/projects/{project_id}",
|
|
279
|
+
operationId: "updateProject"
|
|
280
|
+
},
|
|
281
|
+
"DELETE /v1/projects/{project_id}": {
|
|
282
|
+
method: "DELETE",
|
|
283
|
+
path: "/v1/projects/{project_id}",
|
|
284
|
+
operationId: "deleteProject"
|
|
285
|
+
},
|
|
286
|
+
"GET /v1/projects/{project_id}/metrics": {
|
|
287
|
+
method: "GET",
|
|
288
|
+
path: "/v1/projects/{project_id}/metrics",
|
|
289
|
+
operationId: "getProjectMetrics"
|
|
290
|
+
},
|
|
291
|
+
"GET /v1/regions": {
|
|
292
|
+
method: "GET",
|
|
293
|
+
path: "/v1/regions",
|
|
294
|
+
operationId: "listRegions"
|
|
295
|
+
},
|
|
296
|
+
"GET /v1/databases/{database_id}/replicas": {
|
|
297
|
+
method: "GET",
|
|
298
|
+
path: "/v1/databases/{database_id}/replicas",
|
|
299
|
+
operationId: "listReplicas"
|
|
300
|
+
},
|
|
301
|
+
"POST /v1/databases/{database_id}/replicas": {
|
|
302
|
+
method: "POST",
|
|
303
|
+
path: "/v1/databases/{database_id}/replicas",
|
|
304
|
+
operationId: "createReplica"
|
|
305
|
+
},
|
|
306
|
+
"DELETE /v1/databases/{database_id}/replicas/{replica_id}": {
|
|
307
|
+
method: "DELETE",
|
|
308
|
+
path: "/v1/databases/{database_id}/replicas/{replica_id}",
|
|
309
|
+
operationId: "deleteReplica"
|
|
310
|
+
},
|
|
311
|
+
"GET /v1/organizations/{org_id}/usage": {
|
|
312
|
+
method: "GET",
|
|
313
|
+
path: "/v1/organizations/{org_id}/usage",
|
|
314
|
+
operationId: "getOrganizationUsage"
|
|
315
|
+
},
|
|
316
|
+
"GET /v1/projects/{project_id}/usage": {
|
|
317
|
+
method: "GET",
|
|
318
|
+
path: "/v1/projects/{project_id}/usage",
|
|
319
|
+
operationId: "getProjectUsage"
|
|
320
|
+
},
|
|
321
|
+
"POST /v1/waitlist": {
|
|
322
|
+
method: "POST",
|
|
323
|
+
path: "/v1/waitlist",
|
|
324
|
+
operationId: "joinWaitlist"
|
|
325
|
+
}
|
|
326
|
+
};
|
|
327
|
+
|
|
328
|
+
class ApiError extends Error {
|
|
329
|
+
constructor(status, statusText, body){
|
|
330
|
+
var _extractMessage;
|
|
331
|
+
const message = typeof body === "object" && body !== null ? (_extractMessage = extractMessage(body)) != null ? _extractMessage : statusText : statusText;
|
|
332
|
+
super(message);
|
|
333
|
+
this.name = "ApiError";
|
|
334
|
+
this.status = status;
|
|
335
|
+
this.statusText = statusText;
|
|
336
|
+
this.body = body;
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
/** Extract a human-readable message from an API error body. */ function extractMessage(body) {
|
|
340
|
+
if (typeof body !== "object" || body === null) return undefined;
|
|
341
|
+
const obj = body;
|
|
342
|
+
// API returns { error: { code, message } }
|
|
343
|
+
if (typeof obj.error === "object" && obj.error !== null) {
|
|
344
|
+
const inner = obj.error;
|
|
345
|
+
if (typeof inner.message === "string") return inner.message;
|
|
346
|
+
}
|
|
347
|
+
if (typeof obj.message === "string") return obj.message;
|
|
348
|
+
return undefined;
|
|
349
|
+
}
|
|
350
|
+
async function fetcher(options) {
|
|
351
|
+
let url = options.path;
|
|
352
|
+
if (options.pathParams) {
|
|
353
|
+
for (const [key, value] of Object.entries(options.pathParams)){
|
|
354
|
+
url = url.replace(`{${key}}`, encodeURIComponent(value));
|
|
355
|
+
}
|
|
356
|
+
}
|
|
357
|
+
const fullUrl = new URL(url, options.baseUrl);
|
|
358
|
+
if (options.queryParams) {
|
|
359
|
+
for (const [key, value] of Object.entries(options.queryParams)){
|
|
360
|
+
if (value !== undefined && value !== null) {
|
|
361
|
+
fullUrl.searchParams.set(key, String(value));
|
|
362
|
+
}
|
|
363
|
+
}
|
|
364
|
+
}
|
|
365
|
+
const headers = {};
|
|
366
|
+
if (options.token) {
|
|
367
|
+
headers.Authorization = `Bearer ${options.token}`;
|
|
368
|
+
}
|
|
369
|
+
if (options.body !== undefined) {
|
|
370
|
+
headers["Content-Type"] = "application/json";
|
|
371
|
+
}
|
|
372
|
+
var _options_fetchImpl;
|
|
373
|
+
const fetchFn = (_options_fetchImpl = options.fetchImpl) != null ? _options_fetchImpl : globalThis.fetch;
|
|
374
|
+
const response = await fetchFn(fullUrl.toString(), {
|
|
375
|
+
method: options.method,
|
|
376
|
+
headers,
|
|
377
|
+
body: options.body !== undefined ? JSON.stringify(options.body) : undefined
|
|
378
|
+
});
|
|
379
|
+
if (options.onResponse) {
|
|
380
|
+
await options.onResponse(response);
|
|
381
|
+
}
|
|
382
|
+
if (!response.ok) {
|
|
383
|
+
const errorBody = await response.json().catch(()=>null);
|
|
384
|
+
throw new ApiError(response.status, response.statusText, errorBody);
|
|
385
|
+
}
|
|
386
|
+
if (response.status === 204) return undefined;
|
|
387
|
+
const contentType = response.headers.get("content-type");
|
|
388
|
+
if (contentType && contentType.includes("application/json")) {
|
|
389
|
+
return response.json();
|
|
390
|
+
}
|
|
391
|
+
// Fallback: try JSON, return undefined if body is empty/non-JSON
|
|
392
|
+
const text = await response.text();
|
|
393
|
+
if (!text) return undefined;
|
|
394
|
+
return JSON.parse(text);
|
|
395
|
+
}
|
|
396
|
+
|
|
397
|
+
class PgBeamClient {
|
|
398
|
+
async _resolveToken() {
|
|
399
|
+
if (typeof this._tokenOrFn === "function") {
|
|
400
|
+
return this._tokenOrFn();
|
|
401
|
+
}
|
|
402
|
+
return this._tokenOrFn;
|
|
403
|
+
}
|
|
404
|
+
_call(method, path) {
|
|
405
|
+
return async (params = {})=>{
|
|
406
|
+
const token = await this._resolveToken();
|
|
407
|
+
return fetcher({
|
|
408
|
+
method,
|
|
409
|
+
path,
|
|
410
|
+
pathParams: params.pathParams,
|
|
411
|
+
queryParams: params.queryParams,
|
|
412
|
+
body: params.body,
|
|
413
|
+
baseUrl: this._baseUrl,
|
|
414
|
+
token,
|
|
415
|
+
fetchImpl: this._fetchImpl,
|
|
416
|
+
onResponse: this._onResponse
|
|
417
|
+
});
|
|
418
|
+
};
|
|
419
|
+
}
|
|
420
|
+
/** Access API operations via tag-based namespaces or `.request()`. */ get api() {
|
|
421
|
+
if (this._api) return this._api;
|
|
422
|
+
const request = async (route, params)=>{
|
|
423
|
+
const meta = operationsByPath[route];
|
|
424
|
+
if (!meta) throw new Error(`Unknown route: ${String(route)}`);
|
|
425
|
+
const token = await this._resolveToken();
|
|
426
|
+
return fetcher({
|
|
427
|
+
method: meta.method,
|
|
428
|
+
path: meta.path,
|
|
429
|
+
pathParams: params == null ? void 0 : params.pathParams,
|
|
430
|
+
queryParams: params == null ? void 0 : params.queryParams,
|
|
431
|
+
body: params == null ? void 0 : params.body,
|
|
432
|
+
baseUrl: this._baseUrl,
|
|
433
|
+
token,
|
|
434
|
+
fetchImpl: this._fetchImpl,
|
|
435
|
+
onResponse: this._onResponse
|
|
436
|
+
});
|
|
437
|
+
};
|
|
438
|
+
this._api = new Proxy({}, {
|
|
439
|
+
get: (_, prop)=>{
|
|
440
|
+
if (prop === "request") return request;
|
|
441
|
+
const tagOps = operationsByTag[prop];
|
|
442
|
+
if (!tagOps) return undefined;
|
|
443
|
+
return new Proxy({}, {
|
|
444
|
+
get: (_, method)=>{
|
|
445
|
+
const ops = tagOps;
|
|
446
|
+
const opMeta = ops[method];
|
|
447
|
+
if (!opMeta) return undefined;
|
|
448
|
+
return this._call(opMeta.method, opMeta.path);
|
|
449
|
+
}
|
|
450
|
+
});
|
|
451
|
+
}
|
|
452
|
+
});
|
|
453
|
+
return this._api;
|
|
454
|
+
}
|
|
455
|
+
constructor(options){
|
|
456
|
+
this._baseUrl = options.baseUrl;
|
|
457
|
+
this._tokenOrFn = options.token;
|
|
458
|
+
this._fetchImpl = options.fetch;
|
|
459
|
+
this._onResponse = options.onResponse;
|
|
460
|
+
}
|
|
461
|
+
}
|
|
462
|
+
|
|
463
|
+
export { ApiError, PgBeamClient, extractMessage };
|