@rebasepro/server 0.23.0 → 0.24.1-canary.g56af4a4
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/README.md +1 -1
- package/bin/rebase-server.js +4 -2
- package/dist/GCSStorageController-DivE9bAx.js +402 -0
- package/dist/GCSStorageController-DivE9bAx.js.map +1 -0
- package/dist/S3StorageController-D_vKs4kP.js +480 -0
- package/dist/S3StorageController-D_vKs4kP.js.map +1 -0
- package/dist/api/ast-schema-editor.d.ts +92 -1
- package/dist/api/errors.d.ts +9 -0
- package/dist/api/live-schema-routes.d.ts +38 -8
- package/dist/api/logs-routes.d.ts +39 -1
- package/dist/api/openapi-generator.d.ts +17 -0
- package/dist/api/rest/api-generator.d.ts +97 -11
- package/dist/api/rest/auth-collection-writes.d.ts +28 -21
- package/dist/api/rest/field-access-query.d.ts +28 -8
- package/dist/api/rest/field-ops.d.ts +19 -7
- package/dist/api/rest/query-body.d.ts +10 -0
- package/dist/api/rest/write-validation.d.ts +9 -7
- package/dist/api/schema-editor-routes.d.ts +10 -1
- package/dist/api/sql-export-routes.d.ts +8 -0
- package/dist/api/types.d.ts +28 -1
- package/dist/{ast-schema-editor-Mvr50v_S.js → ast-schema-editor-CSdL0iCk.js} +310 -12
- package/dist/ast-schema-editor-CSdL0iCk.js.map +1 -0
- package/dist/auth/access.d.ts +121 -0
- package/dist/auth/adapter-middleware.d.ts +2 -1
- package/dist/auth/address-ownership.d.ts +16 -1
- package/dist/auth/admin-roles-route.d.ts +4 -2
- package/dist/auth/admin-roles.d.ts +17 -20
- package/dist/auth/admin-user-ops.d.ts +24 -2
- package/dist/auth/admin-users-route.d.ts +2 -0
- package/dist/auth/api-keys/api-key-middleware.d.ts +56 -55
- package/dist/auth/api-keys/api-key-routes.d.ts +41 -11
- package/dist/auth/api-keys/api-key-store.d.ts +31 -8
- package/dist/auth/api-keys/api-key-types.d.ts +14 -16
- package/dist/auth/api-keys/http-operation.d.ts +19 -0
- package/dist/auth/api-keys/index.d.ts +11 -11
- package/dist/auth/api-keys/key-grant.d.ts +41 -0
- package/dist/auth/api-keys/legacy-permissions.d.ts +33 -0
- package/dist/auth/auth-hooks.d.ts +46 -7
- package/dist/auth/builtin-auth-adapter.d.ts +8 -0
- package/dist/auth/cookie-utils.d.ts +7 -0
- package/dist/auth/deliverable-address.d.ts +6 -0
- package/dist/auth/email-change-routes.d.ts +41 -0
- package/dist/auth/expired-token-sweep.d.ts +71 -0
- package/dist/auth/impersonation.d.ts +110 -0
- package/dist/auth/index.d.ts +4 -2
- package/dist/auth/interfaces.d.ts +120 -59
- package/dist/auth/jwt-crypto.d.ts +7 -0
- package/dist/auth/jwt-keys.d.ts +4 -0
- package/dist/auth/jwt.d.ts +54 -3
- package/dist/auth/magic-link-routes.d.ts +2 -6
- package/dist/auth/mfa-routes.d.ts +2 -9
- package/dist/auth/middleware.d.ts +17 -5
- package/dist/auth/otp-routes.d.ts +2 -6
- package/dist/auth/passwordless-signup.d.ts +27 -0
- package/dist/auth/platform-token.d.ts +122 -0
- package/dist/auth/rate-limiter.d.ts +54 -1
- package/dist/auth/registration-policy.d.ts +17 -0
- package/dist/auth/routes.d.ts +45 -0
- package/dist/auth/scope-routes.d.ts +22 -0
- package/dist/auth/session-routes.d.ts +11 -6
- package/dist/auth/token-revocation.d.ts +50 -1
- package/dist/auth/user-picking.d.ts +35 -0
- package/dist/auth/verify-credential.d.ts +28 -0
- package/dist/{auth-B-GIMpDG.js → auth-OPq_FeMs.js} +3115 -638
- package/dist/auth-OPq_FeMs.js.map +1 -0
- package/dist/auth_adapter-CIItCTc8.js +21 -0
- package/dist/auth_adapter-CIItCTc8.js.map +1 -0
- package/dist/backend-DTAOsLQc.js.map +1 -1
- package/dist/backup/backup-common.d.ts +24 -3
- package/dist/backup/backup-routes.d.ts +46 -5
- package/dist/backup/backup-schedule.d.ts +33 -0
- package/dist/backup/backup-storage.d.ts +16 -0
- package/dist/backup/index.d.ts +5 -1
- package/dist/backup-5d7XhLX3.js +581 -0
- package/dist/backup-5d7XhLX3.js.map +1 -0
- package/dist/boot/bundle.d.ts +19 -0
- package/dist/boot/driver.d.ts +3 -0
- package/dist/boot/env.d.ts +56 -4
- package/dist/boot/http-server.d.ts +22 -0
- package/dist/boot/options.d.ts +16 -1
- package/dist/boot/runtime-cors.d.ts +17 -0
- package/dist/boot/security-headers.d.ts +26 -0
- package/dist/boot/static-routing.d.ts +65 -0
- package/dist/collection_patch-BRu-BvDv.js +472 -0
- package/dist/collection_patch-BRu-BvDv.js.map +1 -0
- package/dist/{contract-routes-CbFjuBwa.js → contract-routes-02lASyJI.js} +5 -8
- package/dist/contract-routes-02lASyJI.js.map +1 -0
- package/dist/cron/cron-routes.d.ts +1 -1
- package/dist/cron/cron-scheduler.d.ts +94 -23
- package/dist/cron/cron-store.d.ts +31 -4
- package/dist/cron/define-cron.d.ts +6 -2
- package/dist/cron/index.d.ts +1 -1
- package/dist/{cron-loader-DfTj2Hbi.js → cron-loader-D7OmleAb.js} +11 -7
- package/dist/cron-loader-D7OmleAb.js.map +1 -0
- package/dist/{cron-routes-eE8nif_b.js → cron-routes-CBfiaqEL.js} +34 -8
- package/dist/cron-routes-CBfiaqEL.js.map +1 -0
- package/dist/{cron-scheduler-B0pLfAix.js → cron-scheduler-C2vbETMo.js} +349 -65
- package/dist/cron-scheduler-C2vbETMo.js.map +1 -0
- package/dist/cron-store-B2Ih0gCN.js +540 -0
- package/dist/cron-store-B2Ih0gCN.js.map +1 -0
- package/dist/{ddl-bootstrap-C6mo0Kmz.js → ddl-bootstrap-BaqMSa4Y.js} +2 -2
- package/dist/{ddl-bootstrap-C6mo0Kmz.js.map → ddl-bootstrap-BaqMSa4Y.js.map} +1 -1
- package/dist/email/index.d.ts +2 -2
- package/dist/email/smtp-email-service.d.ts +23 -0
- package/dist/email/templates.d.ts +22 -0
- package/dist/email/types.d.ts +44 -0
- package/dist/env.d.ts +1 -39
- package/dist/{errors-DWsX4yTd.js → errors-D6_y86c5.js} +102 -8
- package/dist/errors-D6_y86c5.js.map +1 -0
- package/dist/filter-dialect-REl-TjZr.js +1628 -0
- package/dist/filter-dialect-REl-TjZr.js.map +1 -0
- package/dist/{function-loader-xnbDAPfa.js → function-loader-BDKKiBmy.js} +5 -4
- package/dist/function-loader-BDKKiBmy.js.map +1 -0
- package/dist/{function-routes-Chet4-lB.js → function-routes-DWB7BBsi.js} +25 -13
- package/dist/function-routes-DWB7BBsi.js.map +1 -0
- package/dist/functions/context.d.ts +26 -6
- package/dist/functions/define-function.d.ts +7 -4
- package/dist/functions/guards.d.ts +22 -5
- package/dist/functions/index.d.ts +2 -2
- package/dist/functions/index.js +114 -37
- package/dist/functions/index.js.map +1 -1
- package/dist/functions/request-timeout.d.ts +7 -5
- package/dist/history/history-routes.d.ts +9 -0
- package/dist/history/retention-sweep.d.ts +81 -0
- package/dist/{history-recorder-B4MpJfJK.js → history-recorder-DHenr3lm.js} +4 -4
- package/dist/{history-recorder-B4MpJfJK.js.map → history-recorder-DHenr3lm.js.map} +1 -1
- package/dist/{history-store-BhxWOuz9.js → history-store-DPofGVDp.js} +2 -2
- package/dist/{history-store-BhxWOuz9.js.map → history-store-DPofGVDp.js.map} +1 -1
- package/dist/index.d.ts +14 -7
- package/dist/index.es.js +23363 -17552
- package/dist/index.es.js.map +1 -1
- package/dist/init/health.d.ts +17 -2
- package/dist/init/shutdown.d.ts +20 -0
- package/dist/init.d.ts +70 -6
- package/dist/internal-tables-L2t39RdT.js +136 -0
- package/dist/internal-tables-L2t39RdT.js.map +1 -0
- package/dist/jobs/job-queue.d.ts +8 -0
- package/dist/jobs/job-store.d.ts +24 -0
- package/dist/jobs/types.d.ts +25 -4
- package/dist/{jobs-CazMYhyy.js → jobs-BpD4Q0qR.js} +235 -25
- package/dist/jobs-BpD4Q0qR.js.map +1 -0
- package/dist/{jwt-DnQHNFCl.js → jwt-Bqcu7cGt.js} +207 -77
- package/dist/jwt-Bqcu7cGt.js.map +1 -0
- package/dist/{keys-CogCQpxG.js → keys-GAVZqbqx.js} +3 -17
- package/dist/{keys-CogCQpxG.js.map → keys-GAVZqbqx.js.map} +1 -1
- package/dist/load-failure-UvzZgGXT.js +48 -0
- package/dist/load-failure-UvzZgGXT.js.map +1 -0
- package/dist/{logger-DO2PZc4i.js → logger-D-S-hO5e.js} +26 -3
- package/dist/logger-D-S-hO5e.js.map +1 -0
- package/dist/{logs-routes-Bj4TYYUl.js → logs-routes-DAdv37GI.js} +48 -8
- package/dist/logs-routes-DAdv37GI.js.map +1 -0
- package/dist/mcp/consent-page.d.ts +1 -1
- package/dist/mcp/mcp-routes.d.ts +7 -0
- package/dist/mcp/mcp-tools.d.ts +23 -9
- package/dist/mcp/oauth-metadata.d.ts +21 -16
- package/dist/mcp/oauth-routes.d.ts +7 -1
- package/dist/metrics/index.d.ts +18 -0
- package/dist/metrics/pool-wait.d.ts +50 -0
- package/dist/offline-8Ks3yp9n-CadBKm2D.js +3305 -0
- package/dist/offline-8Ks3yp9n-CadBKm2D.js.map +1 -0
- package/dist/offline-store-D9ytNNaa-BCr2vsFB.js +1903 -0
- package/dist/offline-store-D9ytNNaa-BCr2vsFB.js.map +1 -0
- package/dist/{openapi-generator-O_O24MAT.js → openapi-generator-BqoUh4Ij.js} +455 -80
- package/dist/openapi-generator-BqoUh4Ij.js.map +1 -0
- package/dist/policy-PdzX-Opd.js +121 -0
- package/dist/policy-PdzX-Opd.js.map +1 -0
- package/dist/project_manifest-R6y_KHms.js +59 -0
- package/dist/project_manifest-R6y_KHms.js.map +1 -0
- package/dist/{proxy-Czngl3p9.js → proxy-qRlqeUmO.js} +2 -2
- package/dist/{proxy-Czngl3p9.js.map → proxy-qRlqeUmO.js.map} +1 -1
- package/dist/{query-parser-DGRVFNM3.js → query-parser-DK9eMkb9.js} +497 -52
- package/dist/query-parser-DK9eMkb9.js.map +1 -0
- package/dist/{request-timeout-C_4C2BeR.js → request-timeout-Dnl2_OBc.js} +17 -10
- package/dist/request-timeout-Dnl2_OBc.js.map +1 -0
- package/dist/resumable-upload-threshold-CKv-Ry0l.js +24 -0
- package/dist/resumable-upload-threshold-CKv-Ry0l.js.map +1 -0
- package/dist/schema-edit/apply-schema-change.d.ts +73 -3
- package/dist/schema-edit/local-source.d.ts +29 -0
- package/dist/schema-edit/project-root.d.ts +3 -2
- package/dist/schema-edit/remote-source.d.ts +20 -5
- package/dist/schema-edit/source-editor.d.ts +28 -0
- package/dist/schema-editor-routes-BFf3i8jm.js +136 -0
- package/dist/schema-editor-routes-BFf3i8jm.js.map +1 -0
- package/dist/serve-spa.d.ts +58 -0
- package/dist/services/outbound-post.d.ts +50 -0
- package/dist/services/outbound-url-guard.d.ts +34 -5
- package/dist/services/routed-realtime-service.d.ts +16 -0
- package/dist/services/webhook-service.d.ts +66 -14
- package/dist/soft-delete-params-47yBGs3_.js +668 -0
- package/dist/soft-delete-params-47yBGs3_.js.map +1 -0
- package/dist/sql-export-routes-BNNuGGLP.js +240 -0
- package/dist/sql-export-routes-BNNuGGLP.js.map +1 -0
- package/dist/{src-vkcwKXbT.js → src-CatHFUym.js} +439 -20
- package/dist/src-CatHFUym.js.map +1 -0
- package/dist/storage/GCSStorageController.d.ts +48 -2
- package/dist/storage/LocalStorageController.d.ts +69 -2
- package/dist/storage/S3StorageController.d.ts +39 -3
- package/dist/storage/image-transform.d.ts +5 -0
- package/dist/storage/index.d.ts +2 -2
- package/dist/storage/maintenance-routes.d.ts +23 -0
- package/dist/storage/maintenance.d.ts +126 -0
- package/dist/storage/property-limits.d.ts +41 -6
- package/dist/storage/rendition-cache.d.ts +9 -11
- package/dist/storage/request-keys.d.ts +15 -0
- package/dist/storage/request-principals.d.ts +30 -0
- package/dist/storage/requested-object.d.ts +74 -0
- package/dist/storage/routes.d.ts +52 -14
- package/dist/storage/source-variables.d.ts +10 -0
- package/dist/storage/streams.d.ts +42 -0
- package/dist/storage/tus-handler.d.ts +76 -7
- package/dist/storage/types.d.ts +101 -7
- package/dist/storage/upload-validation.d.ts +13 -0
- package/dist/storage-resumable-VO-cMpse-C_YX71pO.js +125 -0
- package/dist/storage-resumable-VO-cMpse-C_YX71pO.js.map +1 -0
- package/dist/strings.es-BeZWAodn.js +256 -0
- package/dist/strings.es-BeZWAodn.js.map +1 -0
- package/dist/upload-validation-Dd-fnsbA.js +172 -0
- package/dist/upload-validation-Dd-fnsbA.js.map +1 -0
- package/dist/utils/byte-size.d.ts +10 -0
- package/dist/utils/compression.d.ts +6 -0
- package/dist/utils/load-failure.d.ts +14 -0
- package/dist/utils/logger.d.ts +12 -0
- package/package.json +5 -5
- package/dist/GCSStorageController-CjrA4PMo.js +0 -242
- package/dist/GCSStorageController-CjrA4PMo.js.map +0 -1
- package/dist/S3StorageController-B6pKDNVj.js +0 -264
- package/dist/S3StorageController-B6pKDNVj.js.map +0 -1
- package/dist/admin-roles-vYdp_Pil.js +0 -36
- package/dist/admin-roles-vYdp_Pil.js.map +0 -1
- package/dist/admin_block-DxKLmdiv.js +0 -206
- package/dist/admin_block-DxKLmdiv.js.map +0 -1
- package/dist/ast-schema-editor-Mvr50v_S.js.map +0 -1
- package/dist/auth/api-keys/api-key-permission-guard.d.ts +0 -65
- package/dist/auth-B-GIMpDG.js.map +0 -1
- package/dist/backup-D7YR94N3.js +0 -253
- package/dist/backup-D7YR94N3.js.map +0 -1
- package/dist/contract-routes-CbFjuBwa.js.map +0 -1
- package/dist/cron-loader-DfTj2Hbi.js.map +0 -1
- package/dist/cron-routes-eE8nif_b.js.map +0 -1
- package/dist/cron-scheduler-B0pLfAix.js.map +0 -1
- package/dist/cron-store-TcoGz-xS.js +0 -305
- package/dist/cron-store-TcoGz-xS.js.map +0 -1
- package/dist/dynamic-import-X40pTZUQ.js +0 -23
- package/dist/dynamic-import-X40pTZUQ.js.map +0 -1
- package/dist/errors-DWsX4yTd.js.map +0 -1
- package/dist/function-loader-xnbDAPfa.js.map +0 -1
- package/dist/function-routes-Chet4-lB.js.map +0 -1
- package/dist/jobs-CazMYhyy.js.map +0 -1
- package/dist/jwt-DnQHNFCl.js.map +0 -1
- package/dist/logger-DO2PZc4i.js.map +0 -1
- package/dist/logs-routes-Bj4TYYUl.js.map +0 -1
- package/dist/openapi-generator-O_O24MAT.js.map +0 -1
- package/dist/query-parser-DGRVFNM3.js.map +0 -1
- package/dist/request-timeout-C_4C2BeR.js.map +0 -1
- package/dist/schema-editor-routes-C5-lh_jO.js +0 -87
- package/dist/schema-editor-routes-C5-lh_jO.js.map +0 -1
- package/dist/src-pmvW7BFx.js +0 -6688
- package/dist/src-pmvW7BFx.js.map +0 -1
- package/dist/src-vkcwKXbT.js.map +0 -1
- package/dist/types-BfKcm9do.js +0 -39
- package/dist/types-BfKcm9do.js.map +0 -1
|
@@ -1,20 +1,24 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* What a token may do at `/mcp
|
|
2
|
+
* What a token may do at `/mcp`: the data-plane scopes its tools need, in the
|
|
3
|
+
* vocabulary every other credential uses — `data:read`, `data:write`,
|
|
4
|
+
* `data:delete` — each narrowable to one collection (`data:read:posts`).
|
|
3
5
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
* permissions is one nobody reads.
|
|
9
|
-
*
|
|
10
|
-
* They are not a substitute for RLS. A `mcp:read` token still reads through the
|
|
11
|
-
* user's own policies — the scope decides whether the tool exists for this
|
|
12
|
-
* session, the database decides which rows come back.
|
|
6
|
+
* They are not a substitute for RLS. A `data:read` token still reads through
|
|
7
|
+
* the user's own policies — the scope decides whether a tool exists for this
|
|
8
|
+
* session and which collections it reaches; the database decides which rows
|
|
9
|
+
* come back.
|
|
13
10
|
*/
|
|
14
|
-
export declare const MCP_SCOPES: readonly ["
|
|
11
|
+
export declare const MCP_SCOPES: readonly ["data:read", "data:write", "data:delete"];
|
|
15
12
|
export type McpScope = (typeof MCP_SCOPES)[number];
|
|
16
13
|
/** The scope a client gets when it asks for nothing in particular. */
|
|
17
|
-
export declare const DEFAULT_MCP_SCOPE = "
|
|
14
|
+
export declare const DEFAULT_MCP_SCOPE = "data:read";
|
|
15
|
+
/**
|
|
16
|
+
* A scope string as granted before `/mcp` spoke the shared vocabulary, read as
|
|
17
|
+
* what it granted: `mcp:read` was every read, `mcp:write` every create, change
|
|
18
|
+
* and delete. Applied to stored refresh grants and to access tokens still in
|
|
19
|
+
* flight, so a connection made before the change keeps exactly its reach.
|
|
20
|
+
*/
|
|
21
|
+
export declare function upgradeStoredMcpScope(scope: string): string;
|
|
18
22
|
/**
|
|
19
23
|
* The canonical resource identifier for this server's MCP endpoint.
|
|
20
24
|
*
|
|
@@ -93,12 +97,13 @@ export declare function redirectUriAllowed(candidate: string, registered: string
|
|
|
93
97
|
*
|
|
94
98
|
* An unknown scope is dropped rather than refused. RFC 6749 §3.3 allows either,
|
|
95
99
|
* and dropping is what keeps a client that asks for `openid profile email` out
|
|
96
|
-
* of habit from failing to connect at all — it gets the
|
|
97
|
-
* entitled to and none of the ones it invented.
|
|
100
|
+
* of habit from failing to connect at all — it gets the data scopes it is
|
|
101
|
+
* entitled to and none of the ones it invented. A collection target is kept:
|
|
102
|
+
* `data:read:posts` is a narrower grant, never a wider one.
|
|
98
103
|
*/
|
|
99
104
|
export declare function narrowScope(requested: string | undefined | null): string;
|
|
100
|
-
/**
|
|
101
|
-
export declare function
|
|
105
|
+
/** A granted scope string as the list of scopes it holds. */
|
|
106
|
+
export declare function scopeList(scope: string): string[];
|
|
102
107
|
/**
|
|
103
108
|
* The `WWW-Authenticate` value for an unauthenticated request.
|
|
104
109
|
*
|
|
@@ -72,7 +72,13 @@ export declare function createOAuthRoutes(config: OAuthRoutesConfig): Hono<HonoE
|
|
|
72
72
|
* means a stored row is never itself the hazard.
|
|
73
73
|
*/
|
|
74
74
|
export declare function redirectUriProblem(uri: string): string | null;
|
|
75
|
-
/**
|
|
75
|
+
/**
|
|
76
|
+
* Human-readable consent lines, one per granted scope.
|
|
77
|
+
*
|
|
78
|
+
* Worded for the person consenting, not taken from the scope catalogue: what
|
|
79
|
+
* they need to read here is that the client gets *their own* access and no
|
|
80
|
+
* more, and which collections it reaches when the grant names some.
|
|
81
|
+
*/
|
|
76
82
|
export declare function describeScopes(scope: string): {
|
|
77
83
|
scope: string;
|
|
78
84
|
description: string;
|
package/dist/metrics/index.d.ts
CHANGED
|
@@ -31,11 +31,24 @@ export type MetricSurface = "data" | "auth" | "storage" | "functions" | "admin"
|
|
|
31
31
|
| "other";
|
|
32
32
|
/** Whether a path is the platform looking in, rather than a request served. */
|
|
33
33
|
export declare function isUncountedPath(pathname: string): boolean;
|
|
34
|
+
/**
|
|
35
|
+
* How long a query waited for a pooled database connection, in milliseconds —
|
|
36
|
+
* opening one included, when the pool had to. Labelled by data source. See
|
|
37
|
+
* `pool-wait.ts`, which records it, and why it matters there.
|
|
38
|
+
*/
|
|
39
|
+
export declare const DB_POOL_WAIT_METRIC = "rebase_db_pool_wait_ms";
|
|
40
|
+
/**
|
|
41
|
+
* Buckets for {@link DB_POOL_WAIT_METRIC}. A checkout from a pool with an idle
|
|
42
|
+
* connection takes well under a millisecond, so the low end is finer than a
|
|
43
|
+
* request's: the interesting number is how much of the tail is above zero.
|
|
44
|
+
*/
|
|
45
|
+
export declare const POOL_WAIT_BUCKETS_MS: number[];
|
|
34
46
|
export declare class MetricsRegistry {
|
|
35
47
|
private requests;
|
|
36
48
|
private latency;
|
|
37
49
|
private gauges;
|
|
38
50
|
private counters;
|
|
51
|
+
private histograms;
|
|
39
52
|
readonly startedAt: number;
|
|
40
53
|
private static labelKey;
|
|
41
54
|
private static parseLabels;
|
|
@@ -51,6 +64,11 @@ export declare class MetricsRegistry {
|
|
|
51
64
|
recordRequest(labels: Record<string, string>, durationMs: number): void;
|
|
52
65
|
incrementCounter(name: string, labels?: Record<string, string>, by?: number): void;
|
|
53
66
|
setGauge(name: string, value: number, labels?: Record<string, string>): void;
|
|
67
|
+
/**
|
|
68
|
+
* Record one observation in a named histogram. `buckets` are its upper
|
|
69
|
+
* bounds, fixed by the first observation of the series.
|
|
70
|
+
*/
|
|
71
|
+
observe(name: string, value: number, labels?: Record<string, string>, buckets?: readonly number[]): void;
|
|
54
72
|
/** Prometheus escaping: backslash, quote and newline, in that order. */
|
|
55
73
|
private static formatLabels;
|
|
56
74
|
/** Group `name -> [[labelKey, value]]` for one-HELP-per-metric rendering. */
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* How long queries wait for a pooled database connection.
|
|
3
|
+
*
|
|
4
|
+
* A write holds its connection — and its transaction, and the locks it has
|
|
5
|
+
* taken — for as long as its callbacks run: `beforeSave` runs after the
|
|
6
|
+
* transaction has begun, `afterSave` before it commits. Callbacks that await
|
|
7
|
+
* something slow therefore take connections out of the pool for that long, and
|
|
8
|
+
* once enough of them run at once every other request queues for one. Measured
|
|
9
|
+
* with the default pool of 20: 25 concurrent saves whose `beforeSave` awaited
|
|
10
|
+
* 300 ms made an unrelated one-row read wait 290 ms for a connection.
|
|
11
|
+
*
|
|
12
|
+
* Nothing else shows that queue. Request latency rises, but so it does for a
|
|
13
|
+
* slow query; this histogram says how much of a request was spent waiting for
|
|
14
|
+
* a connection at all. Near zero is a healthy pool.
|
|
15
|
+
*
|
|
16
|
+
* @module
|
|
17
|
+
*/
|
|
18
|
+
import { type MetricsRegistry } from "./index.js";
|
|
19
|
+
/** `pg.Pool`'s callback form of `connect`, which `pool.query` uses internally. */
|
|
20
|
+
type ConnectCallback = (err: Error | undefined, client: unknown, done: (release?: unknown) => void) => void;
|
|
21
|
+
/**
|
|
22
|
+
* `connect` as a `pg.Pool` has it: a promise without a callback, the callback
|
|
23
|
+
* with one. Both are timed — transactions check out with the first,
|
|
24
|
+
* `pool.query` with the second.
|
|
25
|
+
*/
|
|
26
|
+
export type PoolConnect = (callback?: ConnectCallback) => Promise<unknown> | void;
|
|
27
|
+
/**
|
|
28
|
+
* Time every checkout from `pool`, from the call to the moment a connection is
|
|
29
|
+
* handed over, and report it to `record` in milliseconds. A failed checkout is
|
|
30
|
+
* not recorded: it is an error, not a wait.
|
|
31
|
+
*
|
|
32
|
+
* Wraps `connect` on this pool object only. `false` when the pool has no
|
|
33
|
+
* `connect` to time (a driver that is not pool-based) or is timed already.
|
|
34
|
+
*/
|
|
35
|
+
export declare function timePoolCheckouts(pool: {
|
|
36
|
+
connect?: PoolConnect;
|
|
37
|
+
}, record: (waitMs: number) => void): boolean;
|
|
38
|
+
/**
|
|
39
|
+
* Time the checkouts of every pool-based data source into `registry`'s
|
|
40
|
+
* {@link DB_POOL_WAIT_METRIC} histogram, labelled by the source's key.
|
|
41
|
+
*/
|
|
42
|
+
export declare function recordPoolWaits(registry: MetricsRegistry, sources: readonly {
|
|
43
|
+
key: string;
|
|
44
|
+
connection: {
|
|
45
|
+
pool?: {
|
|
46
|
+
connect?: PoolConnect;
|
|
47
|
+
};
|
|
48
|
+
};
|
|
49
|
+
}[]): void;
|
|
50
|
+
export {};
|