pgbeam 0.2.1 → 0.2.3
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 +190 -0
- package/README.md +8 -0
- package/dist/index.cjs +44 -42
- package/dist/index.d.cts +998 -973
- package/dist/index.d.mts +998 -973
- package/dist/index.mjs +44 -42
- package/dist/operations.cjs +11 -9
- package/dist/operations.d.cts +836 -800
- package/dist/operations.d.mts +836 -800
- package/dist/operations.mjs +11 -9
- package/package.json +5 -5
package/dist/index.mjs
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import { _ } from '@swc/helpers/_/_extends';
|
|
2
|
-
|
|
3
1
|
/**
|
|
4
2
|
* Generated by scripts/generate-maps.ts — do not edit manually.
|
|
5
3
|
* Run: pnpm --filter pgbeam generate
|
|
@@ -19,10 +17,6 @@ import { _ } from '@swc/helpers/_/_extends';
|
|
|
19
17
|
}
|
|
20
18
|
},
|
|
21
19
|
analytics: {
|
|
22
|
-
getOrganizationActivity: {
|
|
23
|
-
method: "GET",
|
|
24
|
-
path: "/v1/organizations/{org_id}/activity"
|
|
25
|
-
},
|
|
26
20
|
listPlans: {
|
|
27
21
|
method: "GET",
|
|
28
22
|
path: "/v1/plans"
|
|
@@ -149,6 +143,12 @@ import { _ } from '@swc/helpers/_/_extends';
|
|
|
149
143
|
method: "GET",
|
|
150
144
|
path: "/v1/regions"
|
|
151
145
|
}
|
|
146
|
+
},
|
|
147
|
+
mCP: {
|
|
148
|
+
mcpTransport: {
|
|
149
|
+
method: "POST",
|
|
150
|
+
path: "/v1/mcp"
|
|
151
|
+
}
|
|
152
152
|
}
|
|
153
153
|
};
|
|
154
154
|
const operationsByPath = {
|
|
@@ -157,11 +157,6 @@ const operationsByPath = {
|
|
|
157
157
|
path: "/v1/account/export",
|
|
158
158
|
operationId: "exportAccountData"
|
|
159
159
|
},
|
|
160
|
-
"GET /v1/organizations/{org_id}/activity": {
|
|
161
|
-
method: "GET",
|
|
162
|
-
path: "/v1/organizations/{org_id}/activity",
|
|
163
|
-
operationId: "getOrganizationActivity"
|
|
164
|
-
},
|
|
165
160
|
"GET /v1/plans": {
|
|
166
161
|
method: "GET",
|
|
167
162
|
path: "/v1/plans",
|
|
@@ -252,6 +247,11 @@ const operationsByPath = {
|
|
|
252
247
|
path: "/v1/projects/{project_id}/insights",
|
|
253
248
|
operationId: "getProjectInsights"
|
|
254
249
|
},
|
|
250
|
+
"POST /v1/mcp": {
|
|
251
|
+
method: "POST",
|
|
252
|
+
path: "/v1/mcp",
|
|
253
|
+
operationId: "mcpTransport"
|
|
254
|
+
},
|
|
255
255
|
"GET /v1/organizations/{org_id}/onboarding": {
|
|
256
256
|
method: "GET",
|
|
257
257
|
path: "/v1/organizations/{org_id}/onboarding",
|
|
@@ -326,8 +326,7 @@ const operationsByPath = {
|
|
|
326
326
|
|
|
327
327
|
class ApiError extends Error {
|
|
328
328
|
constructor(status, statusText, body){
|
|
329
|
-
|
|
330
|
-
const message = typeof body === "object" && body !== null ? (_extractMessage = extractMessage(body)) != null ? _extractMessage : statusText : statusText;
|
|
329
|
+
const message = typeof body === "object" && body !== null ? extractMessage(body) ?? statusText : statusText;
|
|
331
330
|
super(message);
|
|
332
331
|
this.name = "ApiError";
|
|
333
332
|
this.status = status;
|
|
@@ -346,24 +345,28 @@ class ApiError extends Error {
|
|
|
346
345
|
if (typeof obj.message === "string") return obj.message;
|
|
347
346
|
return undefined;
|
|
348
347
|
}
|
|
349
|
-
const RETRYABLE_STATUS_CODES =
|
|
348
|
+
const RETRYABLE_STATUS_CODES = [
|
|
350
349
|
408,
|
|
351
350
|
429,
|
|
352
351
|
502,
|
|
353
352
|
503,
|
|
354
353
|
504
|
|
355
|
-
]
|
|
354
|
+
];
|
|
356
355
|
const DEFAULT_RETRY = {
|
|
357
356
|
maxRetries: 5,
|
|
358
357
|
initialDelayMs: 500,
|
|
359
|
-
maxDelayMs:
|
|
358
|
+
maxDelayMs: 30_000,
|
|
360
359
|
idempotencyKeys: true
|
|
361
360
|
};
|
|
362
361
|
function resolveRetry(config) {
|
|
363
|
-
if (!config) return
|
|
362
|
+
if (!config) return {
|
|
363
|
+
...DEFAULT_RETRY,
|
|
364
364
|
maxRetries: 0
|
|
365
|
-
}
|
|
366
|
-
return
|
|
365
|
+
};
|
|
366
|
+
return {
|
|
367
|
+
...DEFAULT_RETRY,
|
|
368
|
+
...config
|
|
369
|
+
};
|
|
367
370
|
}
|
|
368
371
|
/** Parse Retry-After header as milliseconds. Returns undefined if unparseable. */ function parseRetryAfter(response) {
|
|
369
372
|
const header = response.headers.get("Retry-After");
|
|
@@ -401,7 +404,6 @@ function isMutatingMethod(method) {
|
|
|
401
404
|
return upper === "POST" || upper === "PATCH";
|
|
402
405
|
}
|
|
403
406
|
async function fetcher(options) {
|
|
404
|
-
var _options_fetchImpl;
|
|
405
407
|
let url = options.path;
|
|
406
408
|
if (options.pathParams) {
|
|
407
409
|
for (const [key, value] of Object.entries(options.pathParams)){
|
|
@@ -423,20 +425,21 @@ async function fetcher(options) {
|
|
|
423
425
|
if (options.body !== undefined) {
|
|
424
426
|
headers["Content-Type"] = "application/json";
|
|
425
427
|
}
|
|
426
|
-
const fetchFn =
|
|
428
|
+
const fetchFn = options.fetchImpl ?? globalThis.fetch;
|
|
427
429
|
const retry = resolveRetry(options.retry);
|
|
428
430
|
const urlStr = fullUrl.toString();
|
|
429
431
|
const fetchBody = options.body !== undefined ? JSON.stringify(options.body) : undefined;
|
|
430
432
|
// Generate idempotency key once, reused across all retry attempts.
|
|
431
433
|
const idempotencyKey = retry.maxRetries > 0 && retry.idempotencyKeys && isMutatingMethod(options.method) ? generateUUID() : undefined;
|
|
432
434
|
for(let attempt = 0; attempt <= retry.maxRetries; attempt++){
|
|
433
|
-
const reqHeaders =
|
|
435
|
+
const reqHeaders = {
|
|
436
|
+
...headers
|
|
437
|
+
};
|
|
434
438
|
// Attach idempotency key on all attempts for mutating requests.
|
|
435
439
|
if (idempotencyKey) {
|
|
436
440
|
reqHeaders["Idempotency-Key"] = idempotencyKey;
|
|
437
441
|
}
|
|
438
442
|
try {
|
|
439
|
-
var _parseRetryAfter;
|
|
440
443
|
const response = await fetchFn(urlStr, {
|
|
441
444
|
method: options.method,
|
|
442
445
|
headers: reqHeaders,
|
|
@@ -449,12 +452,12 @@ async function fetcher(options) {
|
|
|
449
452
|
return parseResponseBody(response);
|
|
450
453
|
}
|
|
451
454
|
// Non-retryable error or last attempt — throw immediately.
|
|
452
|
-
if (!RETRYABLE_STATUS_CODES.
|
|
455
|
+
if (!RETRYABLE_STATUS_CODES.includes(response.status) || attempt === retry.maxRetries) {
|
|
453
456
|
const errorBody = await response.json().catch(()=>null);
|
|
454
457
|
throw new ApiError(response.status, response.statusText, errorBody);
|
|
455
458
|
}
|
|
456
459
|
// Retryable error — wait and retry.
|
|
457
|
-
const delay =
|
|
460
|
+
const delay = parseRetryAfter(response) ?? backoff(attempt, retry.initialDelayMs, retry.maxDelayMs);
|
|
458
461
|
await sleep(delay);
|
|
459
462
|
} catch (err) {
|
|
460
463
|
// If it's already an ApiError, rethrow (we threw it above).
|
|
@@ -471,7 +474,7 @@ async function fetcher(options) {
|
|
|
471
474
|
async function parseResponseBody(response) {
|
|
472
475
|
if (response.status === 204) return undefined;
|
|
473
476
|
const contentType = response.headers.get("content-type");
|
|
474
|
-
if (contentType
|
|
477
|
+
if (contentType?.includes("application/json")) {
|
|
475
478
|
return response.json();
|
|
476
479
|
}
|
|
477
480
|
// Fallback: try JSON, return undefined if body is empty/non-JSON
|
|
@@ -479,7 +482,7 @@ async function parseResponseBody(response) {
|
|
|
479
482
|
if (!text) return undefined;
|
|
480
483
|
try {
|
|
481
484
|
return JSON.parse(text);
|
|
482
|
-
} catch
|
|
485
|
+
} catch {
|
|
483
486
|
return undefined;
|
|
484
487
|
}
|
|
485
488
|
}
|
|
@@ -488,6 +491,17 @@ function sleep(ms) {
|
|
|
488
491
|
}
|
|
489
492
|
|
|
490
493
|
class PgBeamClient {
|
|
494
|
+
constructor(options){
|
|
495
|
+
this._baseUrl = options.baseUrl;
|
|
496
|
+
this._tokenOrFn = options.token;
|
|
497
|
+
this._fetchImpl = options.fetch;
|
|
498
|
+
this._onResponse = options.onResponse;
|
|
499
|
+
this._retry = options.retry === false ? {
|
|
500
|
+
maxRetries: 0
|
|
501
|
+
} : options.retry ?? {
|
|
502
|
+
maxRetries: 5
|
|
503
|
+
};
|
|
504
|
+
}
|
|
491
505
|
async _resolveToken() {
|
|
492
506
|
if (typeof this._tokenOrFn === "function") {
|
|
493
507
|
return this._tokenOrFn();
|
|
@@ -520,9 +534,9 @@ class PgBeamClient {
|
|
|
520
534
|
return fetcher({
|
|
521
535
|
method: meta.method,
|
|
522
536
|
path: meta.path,
|
|
523
|
-
pathParams: params
|
|
524
|
-
queryParams: params
|
|
525
|
-
body: params
|
|
537
|
+
pathParams: params?.pathParams,
|
|
538
|
+
queryParams: params?.queryParams,
|
|
539
|
+
body: params?.body,
|
|
526
540
|
baseUrl: this._baseUrl,
|
|
527
541
|
token,
|
|
528
542
|
fetchImpl: this._fetchImpl,
|
|
@@ -547,18 +561,6 @@ class PgBeamClient {
|
|
|
547
561
|
});
|
|
548
562
|
return this._api;
|
|
549
563
|
}
|
|
550
|
-
constructor(options){
|
|
551
|
-
var _options_retry;
|
|
552
|
-
this._baseUrl = options.baseUrl;
|
|
553
|
-
this._tokenOrFn = options.token;
|
|
554
|
-
this._fetchImpl = options.fetch;
|
|
555
|
-
this._onResponse = options.onResponse;
|
|
556
|
-
this._retry = options.retry === false ? {
|
|
557
|
-
maxRetries: 0
|
|
558
|
-
} : (_options_retry = options.retry) != null ? _options_retry : {
|
|
559
|
-
maxRetries: 5
|
|
560
|
-
};
|
|
561
|
-
}
|
|
562
564
|
}
|
|
563
565
|
|
|
564
566
|
export { ApiError, PgBeamClient, extractMessage };
|
package/dist/operations.cjs
CHANGED
|
@@ -19,10 +19,6 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
19
19
|
}
|
|
20
20
|
},
|
|
21
21
|
analytics: {
|
|
22
|
-
getOrganizationActivity: {
|
|
23
|
-
method: "GET",
|
|
24
|
-
path: "/v1/organizations/{org_id}/activity"
|
|
25
|
-
},
|
|
26
22
|
listPlans: {
|
|
27
23
|
method: "GET",
|
|
28
24
|
path: "/v1/plans"
|
|
@@ -149,6 +145,12 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
149
145
|
method: "GET",
|
|
150
146
|
path: "/v1/regions"
|
|
151
147
|
}
|
|
148
|
+
},
|
|
149
|
+
mCP: {
|
|
150
|
+
mcpTransport: {
|
|
151
|
+
method: "POST",
|
|
152
|
+
path: "/v1/mcp"
|
|
153
|
+
}
|
|
152
154
|
}
|
|
153
155
|
};
|
|
154
156
|
const operationsByPath = {
|
|
@@ -157,11 +159,6 @@ const operationsByPath = {
|
|
|
157
159
|
path: "/v1/account/export",
|
|
158
160
|
operationId: "exportAccountData"
|
|
159
161
|
},
|
|
160
|
-
"GET /v1/organizations/{org_id}/activity": {
|
|
161
|
-
method: "GET",
|
|
162
|
-
path: "/v1/organizations/{org_id}/activity",
|
|
163
|
-
operationId: "getOrganizationActivity"
|
|
164
|
-
},
|
|
165
162
|
"GET /v1/plans": {
|
|
166
163
|
method: "GET",
|
|
167
164
|
path: "/v1/plans",
|
|
@@ -252,6 +249,11 @@ const operationsByPath = {
|
|
|
252
249
|
path: "/v1/projects/{project_id}/insights",
|
|
253
250
|
operationId: "getProjectInsights"
|
|
254
251
|
},
|
|
252
|
+
"POST /v1/mcp": {
|
|
253
|
+
method: "POST",
|
|
254
|
+
path: "/v1/mcp",
|
|
255
|
+
operationId: "mcpTransport"
|
|
256
|
+
},
|
|
255
257
|
"GET /v1/organizations/{org_id}/onboarding": {
|
|
256
258
|
method: "GET",
|
|
257
259
|
path: "/v1/organizations/{org_id}/onboarding",
|