@qodalis/cli-server-plugin-public-api 0.0.0-stage → 1.0.0-beta.30
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 +21 -0
- package/README.md +130 -2
- package/dist/cli-public-api-builder.d.ts +136 -0
- package/dist/cli-public-api-builder.d.ts.map +1 -0
- package/dist/cli-public-api-builder.js +377 -0
- package/dist/cli-public-api-builder.js.map +1 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +26 -0
- package/dist/index.js.map +1 -0
- package/dist/openapi.d.ts +24 -0
- package/dist/openapi.d.ts.map +1 -0
- package/dist/openapi.js +79 -0
- package/dist/openapi.js.map +1 -0
- package/dist/package-info.d.ts +8 -0
- package/dist/package-info.d.ts.map +1 -0
- package/dist/package-info.js +12 -0
- package/dist/package-info.js.map +1 -0
- package/dist/quota.d.ts +56 -0
- package/dist/quota.d.ts.map +1 -0
- package/dist/quota.js +65 -0
- package/dist/quota.js.map +1 -0
- package/dist/swagger.d.ts +10 -0
- package/dist/swagger.d.ts.map +1 -0
- package/dist/swagger.js +61 -0
- package/dist/swagger.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/dist/usage-service.d.ts +73 -0
- package/dist/usage-service.d.ts.map +1 -0
- package/dist/usage-service.js +74 -0
- package/dist/usage-service.js.map +1 -0
- package/dist/usage-store.d.ts +31 -0
- package/dist/usage-store.d.ts.map +1 -0
- package/dist/usage-store.js +64 -0
- package/dist/usage-store.js.map +1 -0
- package/package.json +41 -5
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025-2026 Qodalis Solutions
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,131 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @qodalis/cli-server-plugin-public-api
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Public API plugin for [Qodalis CLI Server (Node.js)](https://github.com/qodalis-solutions/cli-server-node): publish your own REST routes as a public API. A guard admits only `host` API tokens of the [users plugin](../users/README.md), checks the route's permission and the account's daily and per-minute quotas, counts each request per token and day, and shows that usage on the token views. Implements the same contract as the .NET (`Qodalis.Cli.Plugin.PublicApi`) and Python servers.
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @qodalis/cli-server-plugin-public-api
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Usage
|
|
12
|
+
|
|
13
|
+
```typescript
|
|
14
|
+
import { createCliServer } from '@qodalis/cli-server-node';
|
|
15
|
+
import { CliUsersBuilder } from '@qodalis/cli-server-plugin-users';
|
|
16
|
+
import { CliPublicApiBuilder } from '@qodalis/cli-server-plugin-public-api';
|
|
17
|
+
|
|
18
|
+
const cli = createCliServer();
|
|
19
|
+
cli.builder.addPermissions([{ name: 'rates:read', description: 'Exchange rates', group: 'Rates' }]);
|
|
20
|
+
|
|
21
|
+
const users = new CliUsersBuilder().build();
|
|
22
|
+
cli.mountPlugin(users);
|
|
23
|
+
|
|
24
|
+
const publicApi = new CliPublicApiBuilder()
|
|
25
|
+
.setUsers(users)
|
|
26
|
+
.setQuota(async (caller) => (await plans.of(caller.userId)).quota) // { requestsPerDay, requestsPerMinute }
|
|
27
|
+
.build();
|
|
28
|
+
cli.mountPlugin(publicApi);
|
|
29
|
+
|
|
30
|
+
cli.app.get('/v1/rates', publicApi.guard('rates:read'), (req, res) => {
|
|
31
|
+
res.json({ rates: [], account: req.qcliCaller!.userId });
|
|
32
|
+
});
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
Your users get `host` tokens from your own pages through `users.apiTokens.create(userId, { name, audience: 'host', permissions: ['rates:read'] })`; those tokens are refused on every CLI route.
|
|
36
|
+
|
|
37
|
+
## The guard
|
|
38
|
+
|
|
39
|
+
`publicApi.guard(permission?)` returns the middlewares to put before a route's handler. The first failing check answers and the request is not counted:
|
|
40
|
+
|
|
41
|
+
| # | Condition | Answer |
|
|
42
|
+
|---|---|---|
|
|
43
|
+
| 1 | authentication fails | as the users plugin's guards: 401 `unauthorized` (no credentials), 401 `invalid or expired token` (unknown, expired or revoked token, or a disabled user's token or session), 401 `session expired`, 401 `account disabled` (a disabled user signed in by an auth adapter), 403 `password change required` |
|
|
44
|
+
| 2 | not a `host` token (a session, an auth-adapter sign-in, a `cli` token) | 403 `forbidden: a host token is required` |
|
|
45
|
+
| 3 | the permission is given and not held | 403 `forbidden: missing permission <permission>` |
|
|
46
|
+
| 4 | the quota resolver throws or rejects | 500 `internal server error` (the error is logged, its text never sent) |
|
|
47
|
+
| 5 | a limit is `0` (or negative) | 403 `forbidden: no API access` |
|
|
48
|
+
| 6 | the account's requests today reached `requestsPerDay` | 429 `quota exceeded: <n> requests per day`, `Retry-After` = seconds to the next UTC midnight |
|
|
49
|
+
| 7 | the account's requests this minute reached `requestsPerMinute` | 429 `too many requests: <n> per minute`, `Retry-After` = seconds to the next UTC minute |
|
|
50
|
+
|
|
51
|
+
Otherwise the request is counted and the handler runs, with `req.qcliCaller` (`{ userId, userName, tokenId, audience, permissions }`).
|
|
52
|
+
|
|
53
|
+
**Quotas are per account:** each token has its own counters (for display), and the limits apply to the sum over every token of the user, revoked tokens included, so more tokens never mean more requests and revoking a token does not reset the day. Windows are fixed UTC days (`yyyy-MM-dd`) and minutes, whatever the server's time zone. The resolver gets the caller; without one, requests are unlimited (and still counted).
|
|
54
|
+
|
|
55
|
+
Every answer that passed check 3 (429s and the handler's own answers included) carries `X-RateLimit-Limit`, `X-RateLimit-Remaining` and `X-RateLimit-Reset` (seconds until the window resets, at least 1). They describe the daily limit when it is set, otherwise the per-minute one, and are left out when both are unlimited.
|
|
56
|
+
|
|
57
|
+
## OpenAPI document and Swagger UI
|
|
58
|
+
|
|
59
|
+
Hand over the document of your public routes (an object, or a path to a JSON file read once by `build()`):
|
|
60
|
+
|
|
61
|
+
```typescript
|
|
62
|
+
const publicApi = new CliPublicApiBuilder()
|
|
63
|
+
.setUsers(users)
|
|
64
|
+
.setOpenApi('./openapi/public.json') // or an object
|
|
65
|
+
.setServerUrl('https://api.example.com') // optional
|
|
66
|
+
.build();
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
| Route | Answer |
|
|
70
|
+
|---|---|
|
|
71
|
+
| `GET /qcli/api/openapi.json` | The document, `Cache-Control: no-cache`, `Access-Control-Allow-Origin: *`; no sign-in, credentials ignored |
|
|
72
|
+
| `GET /qcli/api/swagger` | Swagger UI 5 for that document only (`persistAuthorization: false`, "try it out" on), titled with `info.title` |
|
|
73
|
+
| `GET /qcli/api/swagger/assets/<file>` | Swagger UI's own files (`swagger-ui-dist`) |
|
|
74
|
+
|
|
75
|
+
What the document lacks is added, and the host's own values always win: the bearer scheme `components.securitySchemes.qcliToken` (`{ type: 'http', scheme: 'bearer', bearerFormat: 'qcli_pat' }`), a top-level `security: [{ qcliToken: [] }]`, and `servers: [{ url }]` with `setServerUrl`, else the request's `scheme://host` plus the path the app is mounted under (a parent app's `app.use('/prefix', cli.app)`; a path base starting with `//` or `/\`, or holding whitespace or control characters, answers 400 `{ "error": "invalid path base" }`). Express has no route metadata, so state each operation's permission in your document as `x-required-permission: "rates:read"` (the portal shows it); your `x-codeSamples` are passed through. Without `setOpenApi` an empty document (`info.title` `API`) is served. On a protected server these routes stay public, under `/api` too.
|
|
76
|
+
|
|
77
|
+
The portal plugin shows the document as an API reference with code samples (`new CliPortalBuilder().addSection(publicApi)`).
|
|
78
|
+
|
|
79
|
+
## Usage
|
|
80
|
+
|
|
81
|
+
With the plugin built, `GET /api/v1/qcli/tokens` and `users.apiTokens.list(userId)` add `usage` to every token view (`{ today, last30Days, days: [{ date, requests }] }`, 30 UTC days, oldest first). For your own account pages:
|
|
82
|
+
|
|
83
|
+
```typescript
|
|
84
|
+
const usage = await publicApi.usage.account(userId);
|
|
85
|
+
// { today, quota: { requestsPerDay, requestsPerMinute }, tokens: [{ tokenId, name, usage }] }
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
An unknown user rejects with a `PublicApiError` (`status` 404, `user not found`).
|
|
89
|
+
|
|
90
|
+
## Builder
|
|
91
|
+
|
|
92
|
+
| Method | Default | Description |
|
|
93
|
+
|---|---|---|
|
|
94
|
+
| `setUsers(usersPlugin)` | required | The users plugin: its guards authenticate, its token views show the usage |
|
|
95
|
+
| `setQuota(resolver)` | unlimited | `(caller) => PublicApiQuota \| Promise<PublicApiQuota>`; `null` limits are unlimited |
|
|
96
|
+
| `setUsageStore(store)` | `InMemoryPublicApiUsageStore` | Where the counters are kept |
|
|
97
|
+
| `setUsageRetentionDays(days)` | 31 | Days the day counters are kept (minute counters: 2 minutes); pruned at most once an hour |
|
|
98
|
+
| `setOpenApi(source)` | empty document | The public document: an object, or a path to a JSON file (`public-api: cannot read OpenAPI document <path>` when unreadable) |
|
|
99
|
+
| `setServerUrl(url)` | the request's `scheme://host` plus the parent mount's prefix | The document's `servers` URL when it has none |
|
|
100
|
+
| `setBasePath(path)` | `/qcli/api` | Where the OpenAPI document and Swagger UI are served (`/segment[/segment]`; otherwise `invalid public-api base path: <path>`) |
|
|
101
|
+
| `setTitle(title)` | `API reference` | The portal's label for the API section |
|
|
102
|
+
| `build()` | | `{ prefix, router, cliRoutes: false, publicRoutes, guard(permission?), usage, store, portalSection, installedPlugin }` |
|
|
103
|
+
|
|
104
|
+
## Storage
|
|
105
|
+
|
|
106
|
+
The default store keeps the counters in memory, for one process. Several processes share their limits only through a shared store implementing `IPublicApiUsageStore`:
|
|
107
|
+
|
|
108
|
+
```typescript
|
|
109
|
+
interface IPublicApiUsageStore {
|
|
110
|
+
increment(tokenId: string, userId: string, window: string): Promise<number>; // the token's new count
|
|
111
|
+
decrement(tokenId: string, window: string): Promise<void>;
|
|
112
|
+
accountCount(userId: string, window: string): Promise<number>; // every token of the user
|
|
113
|
+
tokenDays(tokenIds: string[], fromDay: string, toDay: string): Promise<Record<string, Record<string, number>>>;
|
|
114
|
+
prune(beforeDay: string, beforeMinute: string): Promise<void>;
|
|
115
|
+
}
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
A window is a UTC day (`2026-11-19`) or minute (`2026-11-19T23:59`). The guard increments the token's day and minute counters, reads the account's sums and takes the request back when a limit is exceeded, so processes sharing a store never admit more than the limit (under contention an extra request may be refused). Within one process an account's admissions run one at a time, so the limit admits exactly that many requests.
|
|
119
|
+
|
|
120
|
+
## In production
|
|
121
|
+
|
|
122
|
+
- **Middleware order.** On a protected server, a request to a public route of the portal, docs or public-api plugin under `/api` is answered inside the server's auth gate, which runs first. Middleware you add to the app after `createCliServer` (a rate limiter, request logging, compression) does not run for it; add such middleware before the CLI server's app, for example on a parent app (`outer.use(limiter); outer.use(cli.app)`).
|
|
123
|
+
- **Combining with the users plugin's guards.** `publicApi.guard(...)` and `usersPlugin.requirePermission(...)` / `requireHostToken(...)` can sit on one route, in either order. A request is counted only once it has passed the public-api guard. When a users guard after it refuses the request (401/403/500), the count and the `X-RateLimit-*` headers are taken back first, so the refused request is not counted (as with stacked public-api guards, through the same take-back slot). A refused request never carries `req.qcliCaller`, whichever guard refused it.
|
|
124
|
+
- **Set the URLs explicitly.** Without `setServerUrl`, the document's `servers` comes from the request's `Host` header (and the docs plugin's `{{baseUrl}}` likewise without `setBaseUrl`); behind a proxy or with clients sending any `Host`, set both.
|
|
125
|
+
- **"Try it" from another origin.** When the portal is served from another origin than the API, its "try it" calls are cross-origin: enable CORS on your API routes for the portal's origin, allow the `Authorization` header, and expose the rate-limit headers (`Access-Control-Expose-Headers: X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, Retry-After`) so the reader sees them.
|
|
126
|
+
- **Stacked guards** (one on a router, another on a route) count a request once; each later guard only checks its own permission, and a request it refuses (403) is taken back, so it is not counted. Express gives the first guard no view of the later ones, so the take-back happens after the fact: between the first guard's count and a later guard's refusal, another request of the same account near its limit can briefly be refused (the .NET server checks every stacked permission before counting). A client that disconnects while its admission waits is not counted.
|
|
127
|
+
- A request that fails with 500 because the usage store failed is not left counted: the increments that succeeded are taken back (best effort).
|
|
128
|
+
|
|
129
|
+
## Tokens from one service
|
|
130
|
+
|
|
131
|
+
The users plugin checks token names and the 20-token limit in the process that creates the token. Several services may validate tokens over shared stores (a second service with `createCliServer({ cliRoutes: false })` and the users plugin's `setGuardOnly()`), but create and revoke tokens from one service only.
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
import { Router, Request, RequestHandler } from 'express';
|
|
2
|
+
import type { CliInstalledPlugin } from '@qodalis/cli-server-abstractions';
|
|
3
|
+
import { IPublicApiUsageStore } from './usage-store';
|
|
4
|
+
import { PublicApiQuotaResolver } from './quota';
|
|
5
|
+
import { ApiTokenUsage, PublicApiAccountUsage } from './usage-service';
|
|
6
|
+
export declare const DEFAULT_PUBLIC_API_BASE_PATH = "/qcli/api";
|
|
7
|
+
export declare const DEFAULT_PUBLIC_API_TITLE = "API reference";
|
|
8
|
+
export declare const DEFAULT_USAGE_RETENTION_DAYS = 31;
|
|
9
|
+
/** The answer to a session, an adapter sign-in or a `cli` token (the users plugin's text). */
|
|
10
|
+
export declare const HOST_TOKEN_REQUIRED = "forbidden: a host token is required";
|
|
11
|
+
export declare const NO_API_ACCESS = "forbidden: no API access";
|
|
12
|
+
export declare const INVALID_PATH_BASE = "invalid path base";
|
|
13
|
+
/**
|
|
14
|
+
* The path the app is mounted under (a parent app's `app.use('/prefix', cli.app)`): the
|
|
15
|
+
* request's `baseUrl` before the plugin's own `prefix`; undefined when it starts with `//`
|
|
16
|
+
* or `/\` (it would point URLs at another host).
|
|
17
|
+
*/
|
|
18
|
+
export declare function mountPathBase(req: Request, prefix: string): string | undefined;
|
|
19
|
+
/**
|
|
20
|
+
* The users-plugin members this plugin reads (`setUsers(usersPlugin)`); structurally
|
|
21
|
+
* the users plugin's result, which this package does not depend on.
|
|
22
|
+
*/
|
|
23
|
+
export interface PublicApiUsers {
|
|
24
|
+
/** Authentication, host tokens only, then the permissions (the users plugin's texts). */
|
|
25
|
+
requireHostToken(...permissions: string[]): RequestHandler;
|
|
26
|
+
setTokenUsageProvider(provider: ((tokenIds: string[]) => Promise<Record<string, ApiTokenUsage>>) | null): void;
|
|
27
|
+
apiTokens: {
|
|
28
|
+
list(userId: string): Promise<Array<{
|
|
29
|
+
id: string;
|
|
30
|
+
name: string;
|
|
31
|
+
usage?: ApiTokenUsage;
|
|
32
|
+
}>>;
|
|
33
|
+
};
|
|
34
|
+
getUser(id: string): Promise<{
|
|
35
|
+
id: string;
|
|
36
|
+
name: string;
|
|
37
|
+
} | undefined>;
|
|
38
|
+
/** The users plugin's permission matching (wildcards), for stacked guards. */
|
|
39
|
+
serverAuth: {
|
|
40
|
+
hasPermission(ctx: {
|
|
41
|
+
permissions: string[];
|
|
42
|
+
}, permission: string): boolean;
|
|
43
|
+
};
|
|
44
|
+
authService?: {
|
|
45
|
+
getEffectivePermissions(user: {
|
|
46
|
+
id: string;
|
|
47
|
+
name: string;
|
|
48
|
+
}): Promise<string[]>;
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
/** Where the portal finds this plugin's section (`new CliPortalBuilder().addSection(publicApi)`). */
|
|
52
|
+
export interface PublicApiPortalSection {
|
|
53
|
+
kind: 'api';
|
|
54
|
+
title: string;
|
|
55
|
+
basePath: string;
|
|
56
|
+
}
|
|
57
|
+
export interface PublicApiPluginResult {
|
|
58
|
+
/** The base path (default `/qcli/api`): the public OpenAPI document and Swagger UI. */
|
|
59
|
+
prefix: string;
|
|
60
|
+
router: Router;
|
|
61
|
+
/** Host routes: its prefix is not a CLI route (host tokens reach it). */
|
|
62
|
+
cliRoutes: false;
|
|
63
|
+
/** The document and Swagger UI stay public on a protected server (`mountPlugin` reads them). */
|
|
64
|
+
publicRoutes: string[];
|
|
65
|
+
/**
|
|
66
|
+
* The guard for a public route: a `host` token holding `permission` (when given), within
|
|
67
|
+
* the account's quota. Sets `req.qcliCaller` and the `X-RateLimit-*` headers.
|
|
68
|
+
*
|
|
69
|
+
* @example app.get('/v1/rates', publicApi.guard('rates:read'), handler)
|
|
70
|
+
*/
|
|
71
|
+
guard(permission?: string): RequestHandler[];
|
|
72
|
+
/** Usage for a host's own pages. */
|
|
73
|
+
usage: {
|
|
74
|
+
account(userId: string): Promise<PublicApiAccountUsage>;
|
|
75
|
+
};
|
|
76
|
+
/** The usage counters. */
|
|
77
|
+
store: IPublicApiUsageStore;
|
|
78
|
+
/** Read by the portal plugin. */
|
|
79
|
+
portalSection: PublicApiPortalSection;
|
|
80
|
+
installedPlugin: CliInstalledPlugin;
|
|
81
|
+
}
|
|
82
|
+
/** True for `/segment[/segment...]`: starts with `/`, no trailing `/`, not `/` itself. */
|
|
83
|
+
export declare function isValidBasePath(path: unknown): path is string;
|
|
84
|
+
/**
|
|
85
|
+
* Fluent builder for the public-api plugin: a guard for the host's public routes (host
|
|
86
|
+
* tokens only, per-account daily and per-minute quotas, usage counted per token and day),
|
|
87
|
+
* the usage on the users plugin's token views, and (Swagger UI and the OpenAPI document)
|
|
88
|
+
* the host's public API description.
|
|
89
|
+
*
|
|
90
|
+
* @example
|
|
91
|
+
* ```ts
|
|
92
|
+
* const publicApi = new CliPublicApiBuilder()
|
|
93
|
+
* .setUsers(usersPlugin)
|
|
94
|
+
* .setQuota((caller) => ({ requestsPerDay: 1000, requestsPerMinute: 60 }))
|
|
95
|
+
* .build();
|
|
96
|
+
* mountPlugin(publicApi);
|
|
97
|
+
* app.get('/v1/rates', publicApi.guard('rates:read'), (req, res) => res.json(rates));
|
|
98
|
+
* ```
|
|
99
|
+
*/
|
|
100
|
+
export declare class CliPublicApiBuilder {
|
|
101
|
+
private users?;
|
|
102
|
+
private basePath;
|
|
103
|
+
private title;
|
|
104
|
+
private serverUrl?;
|
|
105
|
+
private openApi?;
|
|
106
|
+
private quota?;
|
|
107
|
+
private store?;
|
|
108
|
+
private retentionDays;
|
|
109
|
+
private clock;
|
|
110
|
+
/** The users plugin (required): its guards authenticate, its token views show the usage. */
|
|
111
|
+
setUsers(users: PublicApiUsers): this;
|
|
112
|
+
/** Where the document and Swagger UI are served (default `/qcli/api`). */
|
|
113
|
+
setBasePath(path: string): this;
|
|
114
|
+
/** The portal's label for the API section (default `API reference`). */
|
|
115
|
+
setTitle(title: string): this;
|
|
116
|
+
/**
|
|
117
|
+
* The public API's OpenAPI document: an object (served as given, with the additions), or
|
|
118
|
+
* a path to a JSON file (relative to the working directory) read once by `build()`.
|
|
119
|
+
*/
|
|
120
|
+
setOpenApi(source: object | string): this;
|
|
121
|
+
/** The document's `servers` URL when it has none (default: the request's `scheme://host`). */
|
|
122
|
+
setServerUrl(url: string): this;
|
|
123
|
+
/**
|
|
124
|
+
* The caller's limits, per account (sync or async; none = unlimited). A throw or a
|
|
125
|
+
* rejection answers 500 `internal server error` and the request is not counted.
|
|
126
|
+
*/
|
|
127
|
+
setQuota(resolver: PublicApiQuotaResolver): this;
|
|
128
|
+
/** The usage counters (default in memory, one process). A shared store shares the limits. */
|
|
129
|
+
setUsageStore(store: IPublicApiUsageStore): this;
|
|
130
|
+
/** Days the day counters are kept (default 31); minute counters are kept 2 minutes. */
|
|
131
|
+
setUsageRetentionDays(days: number): this;
|
|
132
|
+
/** The clock the windows are read from (tests). */
|
|
133
|
+
setClock(now: () => Date): this;
|
|
134
|
+
build(): PublicApiPluginResult;
|
|
135
|
+
}
|
|
136
|
+
//# sourceMappingURL=cli-public-api-builder.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli-public-api-builder.d.ts","sourceRoot":"","sources":["../cli-public-api-builder.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,OAAO,EAA0B,cAAc,EAAE,MAAM,SAAS,CAAC;AAClF,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,kCAAkC,CAAC;AAC3E,OAAO,EAAE,oBAAoB,EAA+B,MAAM,eAAe,CAAC;AAClF,OAAO,EACH,sBAAsB,EAUzB,MAAM,SAAS,CAAC;AACjB,OAAO,EAAE,aAAa,EAAE,qBAAqB,EAAyB,MAAM,iBAAiB,CAAC;AAK9F,eAAO,MAAM,4BAA4B,cAAc,CAAC;AACxD,eAAO,MAAM,wBAAwB,kBAAkB,CAAC;AACxD,eAAO,MAAM,4BAA4B,KAAK,CAAC;AAC/C,8FAA8F;AAC9F,eAAO,MAAM,mBAAmB,wCAAwC,CAAC;AACzE,eAAO,MAAM,aAAa,6BAA6B,CAAC;AAoBxD,eAAO,MAAM,iBAAiB,sBAAsB,CAAC;AAErD;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,GAAG,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,S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