@qodalis/cli-server-plugin-public-api 0.0.0-stage → 1.0.0-beta.29

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.
@@ -0,0 +1,377 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CliPublicApiBuilder = exports.INVALID_PATH_BASE = exports.NO_API_ACCESS = exports.HOST_TOKEN_REQUIRED = exports.DEFAULT_USAGE_RETENTION_DAYS = exports.DEFAULT_PUBLIC_API_TITLE = exports.DEFAULT_PUBLIC_API_BASE_PATH = void 0;
4
+ exports.mountPathBase = mountPathBase;
5
+ exports.isValidBasePath = isValidBasePath;
6
+ const express_1 = require("express");
7
+ const usage_store_1 = require("./usage-store");
8
+ const quota_1 = require("./quota");
9
+ const usage_service_1 = require("./usage-service");
10
+ const package_info_1 = require("./package-info");
11
+ const openapi_1 = require("./openapi");
12
+ const swagger_1 = require("./swagger");
13
+ exports.DEFAULT_PUBLIC_API_BASE_PATH = '/qcli/api';
14
+ exports.DEFAULT_PUBLIC_API_TITLE = 'API reference';
15
+ exports.DEFAULT_USAGE_RETENTION_DAYS = 31;
16
+ /** The answer to a session, an adapter sign-in or a `cli` token (the users plugin's text). */
17
+ exports.HOST_TOKEN_REQUIRED = 'forbidden: a host token is required';
18
+ exports.NO_API_ACCESS = 'forbidden: no API access';
19
+ const PRUNE_INTERVAL_MS = 60 * 60 * 1000;
20
+ /** Set on a request once a guard counted it: the token and the windows it was counted in. */
21
+ const COUNTED = Symbol('qcli.publicApi.counted');
22
+ const RATE_LIMIT_HEADERS = ['X-RateLimit-Limit', 'X-RateLimit-Remaining', 'X-RateLimit-Reset'];
23
+ /**
24
+ * The users plugin's take-back slot (`Symbol.for`, no import): set once a request is counted,
25
+ * run by any later guard (users or public-api) that refuses it.
26
+ */
27
+ const ON_REFUSED = Symbol.for('qcli.onRefused');
28
+ const MINUTE_ROWS_KEPT = 2;
29
+ exports.INVALID_PATH_BASE = 'invalid path base';
30
+ /**
31
+ * The path the app is mounted under (a parent app's `app.use('/prefix', cli.app)`): the
32
+ * request's `baseUrl` before the plugin's own `prefix`; undefined when it starts with `//`
33
+ * or `/\` (it would point URLs at another host).
34
+ */
35
+ function mountPathBase(req, prefix) {
36
+ const base = prefix === '/' ? req.baseUrl : req.baseUrl.slice(0, Math.max(0, req.baseUrl.length - prefix.length));
37
+ // `//`, `/\`, whitespace or control characters (`/\t/host` reads as `//host` in a browser)
38
+ return base.startsWith('//') || base.startsWith('/\\') || /[\s\u0000-\u001f\u007f]/.test(base) ? undefined : base;
39
+ }
40
+ /** True for `/segment[/segment...]`: starts with `/`, no trailing `/`, not `/` itself. */
41
+ function isValidBasePath(path) {
42
+ return typeof path === 'string' && /^(\/[A-Za-z0-9._~-]+)+$/.test(path);
43
+ }
44
+ /**
45
+ * Fluent builder for the public-api plugin: a guard for the host's public routes (host
46
+ * tokens only, per-account daily and per-minute quotas, usage counted per token and day),
47
+ * the usage on the users plugin's token views, and (Swagger UI and the OpenAPI document)
48
+ * the host's public API description.
49
+ *
50
+ * @example
51
+ * ```ts
52
+ * const publicApi = new CliPublicApiBuilder()
53
+ * .setUsers(usersPlugin)
54
+ * .setQuota((caller) => ({ requestsPerDay: 1000, requestsPerMinute: 60 }))
55
+ * .build();
56
+ * mountPlugin(publicApi);
57
+ * app.get('/v1/rates', publicApi.guard('rates:read'), (req, res) => res.json(rates));
58
+ * ```
59
+ */
60
+ class CliPublicApiBuilder {
61
+ users;
62
+ basePath = exports.DEFAULT_PUBLIC_API_BASE_PATH;
63
+ title = exports.DEFAULT_PUBLIC_API_TITLE;
64
+ serverUrl;
65
+ openApi;
66
+ quota;
67
+ store;
68
+ retentionDays = exports.DEFAULT_USAGE_RETENTION_DAYS;
69
+ clock = () => new Date();
70
+ /** The users plugin (required): its guards authenticate, its token views show the usage. */
71
+ setUsers(users) {
72
+ this.users = users;
73
+ return this;
74
+ }
75
+ /** Where the document and Swagger UI are served (default `/qcli/api`). */
76
+ setBasePath(path) {
77
+ this.basePath = path;
78
+ return this;
79
+ }
80
+ /** The portal's label for the API section (default `API reference`). */
81
+ setTitle(title) {
82
+ this.title = title;
83
+ return this;
84
+ }
85
+ /**
86
+ * The public API's OpenAPI document: an object (served as given, with the additions), or
87
+ * a path to a JSON file (relative to the working directory) read once by `build()`.
88
+ */
89
+ setOpenApi(source) {
90
+ this.openApi = source;
91
+ return this;
92
+ }
93
+ /** The document's `servers` URL when it has none (default: the request's `scheme://host`). */
94
+ setServerUrl(url) {
95
+ if (!/^https?:\/\/[^\s]+$/.test(url)) {
96
+ throw new Error(`public-api: the server URL must be an http(s) URL: ${url}`);
97
+ }
98
+ this.serverUrl = url.replace(/\/+$/, '');
99
+ return this;
100
+ }
101
+ /**
102
+ * The caller's limits, per account (sync or async; none = unlimited). A throw or a
103
+ * rejection answers 500 `internal server error` and the request is not counted.
104
+ */
105
+ setQuota(resolver) {
106
+ this.quota = resolver;
107
+ return this;
108
+ }
109
+ /** The usage counters (default in memory, one process). A shared store shares the limits. */
110
+ setUsageStore(store) {
111
+ this.store = store;
112
+ return this;
113
+ }
114
+ /** Days the day counters are kept (default 31); minute counters are kept 2 minutes. */
115
+ setUsageRetentionDays(days) {
116
+ if (!Number.isInteger(days) || days < 1) {
117
+ throw new Error(`public-api: usage retention must be a positive number of days: ${days}`);
118
+ }
119
+ this.retentionDays = days;
120
+ return this;
121
+ }
122
+ /** The clock the windows are read from (tests). */
123
+ setClock(now) {
124
+ this.clock = now;
125
+ return this;
126
+ }
127
+ build() {
128
+ const users = this.users;
129
+ if (!users) {
130
+ throw new Error('public-api: setUsers(usersPlugin) is required');
131
+ }
132
+ if (!isValidBasePath(this.basePath)) {
133
+ throw new Error(`invalid public-api base path: ${this.basePath}`);
134
+ }
135
+ const basePath = this.basePath;
136
+ const document = (0, openapi_1.loadOpenApiSource)(this.openApi);
137
+ const serverUrl = this.serverUrl;
138
+ const store = this.store ?? new usage_store_1.InMemoryPublicApiUsageStore();
139
+ const now = this.clock;
140
+ const retentionDays = this.retentionDays;
141
+ const getQuota = () => this.quota;
142
+ const usage = new usage_service_1.PublicApiUsageService(store, users, getQuota, now);
143
+ users.setTokenUsageProvider((ids) => usage.tokenUsage(ids));
144
+ let lastPrune = 0;
145
+ const pruneNow = (at) => {
146
+ if (at.getTime() - lastPrune < PRUNE_INTERVAL_MS)
147
+ return;
148
+ lastPrune = at.getTime();
149
+ const beforeMinute = (0, quota_1.minuteWindow)(new Date(at.getTime() - MINUTE_ROWS_KEPT * 60_000));
150
+ store.prune((0, quota_1.dayBefore)(at, retentionDays), beforeMinute).catch((err) => {
151
+ console.error('[public-api] usage prune failed:', err);
152
+ });
153
+ };
154
+ // Admissions of one account run one at a time in this process, so its limit admits
155
+ // exactly that many requests; the store's increment-then-check keeps processes that
156
+ // share it from admitting more than the limit.
157
+ const accountQueues = new Map();
158
+ const serialized = async (userId, fn) => {
159
+ const previous = accountQueues.get(userId) ?? Promise.resolve();
160
+ let release;
161
+ const current = new Promise((r) => (release = r));
162
+ const tail = previous.then(() => current);
163
+ accountQueues.set(userId, tail);
164
+ await previous;
165
+ try {
166
+ return await fn();
167
+ }
168
+ finally {
169
+ release();
170
+ if (accountQueues.get(userId) === tail)
171
+ accountQueues.delete(userId);
172
+ }
173
+ };
174
+ // A refused request carries no caller: only an admitted one reaches code with `req.qcliCaller`
175
+ const forgetCaller = (req) => {
176
+ const r = req;
177
+ delete r.qcliCaller;
178
+ delete r.qcliAuth;
179
+ };
180
+ const internalError = (req, res, what, err) => {
181
+ forgetCaller(req);
182
+ // never expose the error's text
183
+ console.error(`[public-api] ${what}:`, err);
184
+ if (!res.headersSent)
185
+ res.status(500).json({ error: 'internal server error' });
186
+ };
187
+ const admit = (req, res, next) => {
188
+ const caller = req.qcliCaller;
189
+ if (!caller || caller.audience !== 'host' || !caller.tokenId) {
190
+ forgetCaller(req);
191
+ res.status(403).json({ error: exports.HOST_TOKEN_REQUIRED });
192
+ return;
193
+ }
194
+ const tokenId = caller.tokenId;
195
+ const marked = req;
196
+ if (marked[COUNTED]) {
197
+ // a stacked guard: counted once, by the first guard
198
+ next();
199
+ return;
200
+ }
201
+ (async () => {
202
+ let perDay;
203
+ let perMinute;
204
+ try {
205
+ const resolver = getQuota();
206
+ const quota = resolver ? await resolver({ ...caller, permissions: [...caller.permissions] }) : quota_1.UNLIMITED;
207
+ perDay = (0, quota_1.normalizeLimit)(quota?.requestsPerDay);
208
+ perMinute = (0, quota_1.normalizeLimit)(quota?.requestsPerMinute);
209
+ }
210
+ catch (err) {
211
+ internalError(req, res, 'quota resolver failed', err);
212
+ return;
213
+ }
214
+ if (perDay === 0 || perMinute === 0) {
215
+ forgetCaller(req);
216
+ res.status(403).json({ error: exports.NO_API_ACCESS });
217
+ return;
218
+ }
219
+ const at = now();
220
+ const day = (0, quota_1.dayWindow)(at);
221
+ const minute = (0, quota_1.minuteWindow)(at);
222
+ let outcome;
223
+ try {
224
+ outcome = await serialized(caller.userId, async () => {
225
+ // increment, check the account's sums, compensate when over a limit
226
+ // the client went away while waiting: not counted, nothing answered
227
+ if (req.socket?.destroyed || res.destroyed) {
228
+ return { cancelled: true, dayCount: 0, minuteCount: 0 };
229
+ }
230
+ const counted = [];
231
+ try {
232
+ await store.increment(tokenId, caller.userId, day);
233
+ counted.push(day);
234
+ await store.increment(tokenId, caller.userId, minute);
235
+ counted.push(minute);
236
+ const dayCount = await store.accountCount(caller.userId, day);
237
+ const minuteCount = await store.accountCount(caller.userId, minute);
238
+ const refused = perDay !== null && dayCount > perDay
239
+ ? 'day'
240
+ : perMinute !== null && minuteCount > perMinute
241
+ ? 'minute'
242
+ : undefined;
243
+ if (refused) {
244
+ await store.decrement(tokenId, day);
245
+ counted.shift();
246
+ await store.decrement(tokenId, minute);
247
+ counted.shift();
248
+ }
249
+ return { refused, dayCount, minuteCount };
250
+ }
251
+ catch (err) {
252
+ // a request answered 500 is not left counted (best effort)
253
+ for (const window of counted) {
254
+ await store.decrement(tokenId, window).catch(() => undefined);
255
+ }
256
+ throw err;
257
+ }
258
+ });
259
+ }
260
+ catch (err) {
261
+ internalError(req, res, 'usage store failed', err);
262
+ return;
263
+ }
264
+ if (outcome.cancelled) {
265
+ res.destroy();
266
+ return;
267
+ }
268
+ if (!outcome.refused) {
269
+ marked[COUNTED] = { tokenId, windows: [day, minute] };
270
+ // a later guard refusing the request takes the count (and the headers) back
271
+ marked[ON_REFUSED] = async () => {
272
+ delete marked[ON_REFUSED];
273
+ delete marked[COUNTED];
274
+ for (const header of RATE_LIMIT_HEADERS)
275
+ res.removeHeader(header);
276
+ try {
277
+ await Promise.all([day, minute].map((w) => store.decrement(tokenId, w)));
278
+ }
279
+ catch (err) {
280
+ console.error('[public-api] usage store failed:', err);
281
+ }
282
+ };
283
+ }
284
+ pruneNow(at);
285
+ const headers = (0, quota_1.rateLimitHeaders)({ perDay, perMinute }, outcome.dayCount, outcome.minuteCount, at);
286
+ if (headers) {
287
+ res.setHeader('X-RateLimit-Limit', String(headers.limit));
288
+ res.setHeader('X-RateLimit-Remaining', String(outcome.refused ? 0 : headers.remaining));
289
+ res.setHeader('X-RateLimit-Reset', String(headers.reset));
290
+ }
291
+ if (outcome.refused === 'day') {
292
+ res.setHeader('Retry-After', String((0, quota_1.secondsToNextDay)(at)));
293
+ forgetCaller(req);
294
+ res.status(429).json({ error: `quota exceeded: ${perDay} requests per day` });
295
+ return;
296
+ }
297
+ if (outcome.refused === 'minute') {
298
+ res.setHeader('Retry-After', String((0, quota_1.secondsToNextMinute)(at)));
299
+ forgetCaller(req);
300
+ res.status(429).json({ error: `too many requests: ${perMinute} per minute` });
301
+ return;
302
+ }
303
+ next();
304
+ })().catch((err) => internalError(req, res, 'guard failed', err));
305
+ };
306
+ const guard = (permission) => {
307
+ // authentication, then host tokens only, then the permission (the users plugin's texts)
308
+ const authenticate = users.requireHostToken(...(permission ? [permission] : []));
309
+ const check = (req, res, next) => {
310
+ const marked = req;
311
+ const counted = marked[COUNTED];
312
+ if (!counted) {
313
+ authenticate(req, res, next);
314
+ return;
315
+ }
316
+ // A later stacked guard checks only its own permission. Express runs the guards one
317
+ // after the other, so the first one cannot see this permission: a refusal here takes
318
+ // the request's count back, so a refused request is not counted.
319
+ if (!permission || users.serverAuth.hasPermission({ permissions: marked.qcliCaller?.permissions ?? [] }, permission)) {
320
+ next();
321
+ return;
322
+ }
323
+ const takeBack = marked[ON_REFUSED] ?? (async () => undefined);
324
+ takeBack().finally(() => {
325
+ forgetCaller(req);
326
+ res.status(403).json({ error: `forbidden: missing permission ${permission}` });
327
+ });
328
+ };
329
+ return [check, admit];
330
+ };
331
+ // The document and Swagger UI: no sign-in, credentials ignored
332
+ const router = (0, express_1.Router)();
333
+ router.get('/openapi.json', (req, res) => {
334
+ const pathBase = mountPathBase(req, basePath);
335
+ if (pathBase === undefined) {
336
+ res.setHeader('Cache-Control', 'no-cache').status(400).json({ error: exports.INVALID_PATH_BASE });
337
+ return;
338
+ }
339
+ const url = serverUrl ?? `${req.protocol}://${req.get('host') ?? 'localhost'}${pathBase}`;
340
+ res.setHeader('Cache-Control', 'no-cache');
341
+ res.setHeader('Access-Control-Allow-Origin', '*');
342
+ res.json((0, openapi_1.publicDocument)(document(), url));
343
+ });
344
+ router.get('/swagger', (req, res) => {
345
+ const pathBase = mountPathBase(req, basePath);
346
+ if (pathBase === undefined) {
347
+ res.setHeader('Cache-Control', 'no-cache').status(400).json({ error: exports.INVALID_PATH_BASE });
348
+ return;
349
+ }
350
+ res.setHeader('Cache-Control', 'no-cache');
351
+ res.type('html').send((0, swagger_1.swaggerPage)(pathBase + basePath, (0, openapi_1.documentTitle)(document())));
352
+ });
353
+ router.get('/swagger/assets/:file', (0, swagger_1.swaggerAssets)((0, swagger_1.swaggerUiDir)()));
354
+ // every other path under the public `/swagger/*` prefix is this plugin's 404, never a host route
355
+ router.get('/swagger/*', (_req, res) => {
356
+ res.setHeader('Cache-Control', 'no-cache').status(404).json({ error: 'not found' });
357
+ });
358
+ // public on a protected server, under /api too (the gate never opens a CLI route this way)
359
+ const publicRoutes = [
360
+ ...['/openapi.json', '/swagger'].flatMap((p) => [`GET ${basePath}${p}`, `HEAD ${basePath}${p}`]),
361
+ `GET ${basePath}/swagger/*`,
362
+ ];
363
+ return {
364
+ prefix: basePath,
365
+ router,
366
+ cliRoutes: false,
367
+ publicRoutes,
368
+ guard,
369
+ usage: { account: (userId) => usage.account(userId) },
370
+ store,
371
+ portalSection: { kind: 'api', title: this.title, basePath },
372
+ installedPlugin: package_info_1.publicApiInstalledPlugin,
373
+ };
374
+ }
375
+ }
376
+ exports.CliPublicApiBuilder = CliPublicApiBuilder;
377
+ //# sourceMappingURL=cli-public-api-builder.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cli-public-api-builder.js","sourceRoot":"","sources":["../cli-public-api-builder.ts"],"names":[],"mappings":";;;AAoDA,sCAIC;AAiDD,0CAEC;AA3GD,qCAAkF;AAElF,+CAAkF;AAClF,mCAWiB;AACjB,mDAA8F;AAC9F,iDAA0D;AAC1D,uCAA6E;AAC7E,uCAAqE;AAExD,QAAA,4BAA4B,GAAG,WAAW,CAAC;AAC3C,QAAA,wBAAwB,GAAG,eAAe,CAAC;AAC3C,QAAA,4BAA4B,GAAG,EAAE,CAAC;AAC/C,8FAA8F;AACjF,QAAA,mBAAmB,GAAG,qCAAqC,CAAC;AAC5D,QAAA,aAAa,GAAG,0BAA0B,CAAC;AAExD,MAAM,iBAAiB,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC;AACzC,6FAA6F;AAC7F,MAAM,OAAO,GAAkB,MAAM,CAAC,wBAAwB,CAAC,CAAC;AAChE,MAAM,kBAAkB,GAAG,CAAC,mBAAmB,EAAE,uBAAuB,EAAE,mBAAmB,CAAC,CAAC;AAE/F;;;GAGG;AACH,MAAM,UAAU,GAAkB,MAAM,CAAC,GAAG,CAAC,gBAAgB,CAAU,CAAC;AAQxE,MAAM,gBAAgB,GAAG,CAAC,CAAC;AACd,QAAA,iBAAiB,GAAG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BLIC_API_BASE_PATH, DEFAULT_PUBLIC_API_TITLE, DEFAULT_USAGE_RETENTION_DAYS, HOST_TOKEN_REQUIRED, NO_API_ACCESS, INVALID_PATH_BASE, mountPathBase, } from './cli-public-api-builder';
2
+ export { PublicApiQuota, PublicApiQuotaResolver, QcliCaller } from './quota';
3
+ export { IPublicApiUsageStore, InMemoryPublicApiUsageStore } from './usage-store';
4
+ export { ApiTokenUsage, ApiTokenUsageDay, PublicApiAccountUsage, PublicApiTokenUsage, PublicApiError, USAGE_DAYS, } from './usage-service';
5
+ export { publicApiInstalledPlugin, PUBLIC_API_PLUGIN_ID } from './package-info';
6
+ export { OpenApiDocument, QCLI_TOKEN_SCHEME } from './openapi';
7
+ export { SWAGGER_ASSETS } from './swagger';
8
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,mBAAmB,EACnB,qBAAqB,EACrB,cAAc,EACd,sBAAsB,EACtB,eAAe,EACf,4BAA4B,EAC5B,wBAAwB,EACxB,4BAA4B,EAC5B,mBAAmB,EACnB,aAAa,EACb,iBAAiB,EACjB,aAAa,GAChB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,cAAc,EAAE,sBAAsB,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAC7E,OAAO,EAAE,oBAAoB,EAAE,2BAA2B,EAAE,MAAM,eAAe,CAAC;AAClF,OAAO,EACH,aAAa,EACb,gBAAgB,EAChB,qBAAqB,EACrB,mBAAmB,EACnB,cAAc,EACd,UAAU,GACb,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,wBAAwB,EAAE,oBAAoB,EAAE,MAAM,gBAAgB,CAAC;AAChF,OAAO,EAAE,eAAe,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAC;AAC/D,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SWAGGER_ASSETS = exports.QCLI_TOKEN_SCHEME = exports.PUBLIC_API_PLUGIN_ID = exports.publicApiInstalledPlugin = exports.USAGE_DAYS = exports.PublicApiError = exports.InMemoryPublicApiUsageStore = exports.mountPathBase = exports.INVALID_PATH_BASE = exports.NO_API_ACCESS = exports.HOST_TOKEN_REQUIRED = exports.DEFAULT_USAGE_RETENTION_DAYS = exports.DEFAULT_PUBLIC_API_TITLE = exports.DEFAULT_PUBLIC_API_BASE_PATH = exports.isValidBasePath = exports.CliPublicApiBuilder = void 0;
4
+ var cli_public_api_builder_1 = require("./cli-public-api-builder");
5
+ Object.defineProperty(exports, "CliPublicApiBuilder", { enumerable: true, get: function () { return cli_public_api_builder_1.CliPublicApiBuilder; } });
6
+ Object.defineProperty(exports, "isValidBasePath", { enumerable: true, get: function () { return cli_public_api_builder_1.isValidBasePath; } });
7
+ Object.defineProperty(exports, "DEFAULT_PUBLIC_API_BASE_PATH", { enumerable: true, get: function () { return cli_public_api_builder_1.DEFAULT_PUBLIC_API_BASE_PATH; } });
8
+ Object.defineProperty(exports, "DEFAULT_PUBLIC_API_TITLE", { enumerable: true, get: function () { return cli_public_api_builder_1.DEFAULT_PUBLIC_API_TITLE; } });
9
+ Object.defineProperty(exports, "DEFAULT_USAGE_RETENTION_DAYS", { enumerable: true, get: function () { return cli_public_api_builder_1.DEFAULT_USAGE_RETENTION_DAYS; } });
10
+ Object.defineProperty(exports, "HOST_TOKEN_REQUIRED", { enumerable: true, get: function () { return cli_public_api_builder_1.HOST_TOKEN_REQUIRED; } });
11
+ Object.defineProperty(exports, "NO_API_ACCESS", { enumerable: true, get: function () { return cli_public_api_builder_1.NO_API_ACCESS; } });
12
+ Object.defineProperty(exports, "INVALID_PATH_BASE", { enumerable: true, get: function () { return cli_public_api_builder_1.INVALID_PATH_BASE; } });
13
+ Object.defineProperty(exports, "mountPathBase", { enumerable: true, get: function () { return cli_public_api_builder_1.mountPathBase; } });
14
+ var usage_store_1 = require("./usage-store");
15
+ Object.defineProperty(exports, "InMemoryPublicApiUsageStore", { enumerable: true, get: function () { return usage_store_1.InMemoryPublicApiUsageStore; } });
16
+ var usage_service_1 = require("./usage-service");
17
+ Object.defineProperty(exports, "PublicApiError", { enumerable: true, get: function () { return usage_service_1.PublicApiError; } });
18
+ Object.defineProperty(exports, "USAGE_DAYS", { enumerable: true, get: function () { return usage_service_1.USAGE_DAYS; } });
19
+ var package_info_1 = require("./package-info");
20
+ Object.defineProperty(exports, "publicApiInstalledPlugin", { enumerable: true, get: function () { return package_info_1.publicApiInstalledPlugin; } });
21
+ Object.defineProperty(exports, "PUBLIC_API_PLUGIN_ID", { enumerable: true, get: function () { return package_info_1.PUBLIC_API_PLUGIN_ID; } });
22
+ var openapi_1 = require("./openapi");
23
+ Object.defineProperty(exports, "QCLI_TOKEN_SCHEME", { enumerable: true, get: function () { return openapi_1.QCLI_TOKEN_SCHEME; } });
24
+ var swagger_1 = require("./swagger");
25
+ Object.defineProperty(exports, "SWAGGER_ASSETS", { enumerable: true, get: function () { return swagger_1.SWAGGER_ASSETS; } });
26
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":";;;AAAA,mEAakC;AAZ9B,6HAAA,mBAAmB,OAAA;AAInB,yHAAA,eAAe,OAAA;AACf,sIAAA,4BAA4B,OAAA;AAC5B,kIAAA,wBAAwB,OAAA;AACxB,sIAAA,4BAA4B,OAAA;AAC5B,6HAAA,mBAAmB,OAAA;AACnB,uHAAA,aAAa,OAAA;AACb,2HAAA,iBAAiB,OAAA;AACjB,uHAAA,aAAa,OAAA;AAGjB,6CAAkF;AAAnD,0HAAA,2BAA2B,OAAA;AAC1D,iDAOyB;AAFrB,+GAAA,cAAc,OAAA;AACd,2GAAA,UAAU,OAAA;AAEd,+CAAgF;AAAvE,wHAAA,wBAAwB,OAAA;AAAE,oHAAA,oBAAoB,OAAA;AACvD,qCAA+D;AAArC,4GAAA,iBAAiB,OAAA;AAC3C,qCAA2C;AAAlC,yGAAA,cAAc,OAAA"}
@@ -0,0 +1,24 @@
1
+ /** An OpenAPI document (JSON object). */
2
+ export type OpenApiDocument = Record<string, unknown>;
3
+ /** The bearer scheme added as `components.securitySchemes.qcliToken`. */
4
+ export declare const QCLI_TOKEN_SCHEME: {
5
+ readonly type: "http";
6
+ readonly scheme: "bearer";
7
+ readonly bearerFormat: "qcli_pat";
8
+ readonly description: "API token (qcli_pat_…), sent as Authorization: Bearer <token>";
9
+ };
10
+ /**
11
+ * The host's document: an object (used as given, read on every request), or a path to a
12
+ * JSON file (relative to the working directory), read once. Throws
13
+ * `public-api: cannot read OpenAPI document <path>` when the file cannot be read or parsed.
14
+ */
15
+ export declare function loadOpenApiSource(source: object | string | undefined): () => OpenApiDocument;
16
+ /**
17
+ * A copy of the document with what it lacks added (the host's values always win): the
18
+ * `qcliToken` bearer scheme, a top-level `security` requirement for it, and `servers`
19
+ * with `serverUrl`. The source is never modified.
20
+ */
21
+ export declare function publicDocument(source: OpenApiDocument, serverUrl: string): OpenApiDocument;
22
+ /** The document's `info.title`, or `API`. */
23
+ export declare function documentTitle(doc: OpenApiDocument): string;
24
+ //# sourceMappingURL=openapi.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"openapi.d.ts","sourceRoot":"","sources":["../openapi.ts"],"names":[],"mappings":"AAGA,yCAAyC;AACzC,MAAM,MAAM,eAAe,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAEtD,yEAAyE;AACzE,eAAO,MAAM,iBAAiB;;;;;CAKpB,CAAC;AAQX;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,GAAG,MAAM,eAAe,CAyB5F;AAED;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,MAAM,EAAE,eAAe,EAAE,SAAS,EAAE,MAAM,GAAG,eAAe,CAe1F;AAED,6CAA6C;AAC7C,wBAAgB,aAAa,CAAC,GAAG,EAAE,eAAe,GAAG,MAAM,CAG1D"}
@@ -0,0 +1,79 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.QCLI_TOKEN_SCHEME = void 0;
4
+ exports.loadOpenApiSource = loadOpenApiSource;
5
+ exports.publicDocument = publicDocument;
6
+ exports.documentTitle = documentTitle;
7
+ const fs_1 = require("fs");
8
+ const path_1 = require("path");
9
+ /** The bearer scheme added as `components.securitySchemes.qcliToken`. */
10
+ exports.QCLI_TOKEN_SCHEME = {
11
+ type: 'http',
12
+ scheme: 'bearer',
13
+ bearerFormat: 'qcli_pat',
14
+ description: 'API token (qcli_pat_…), sent as Authorization: Bearer <token>',
15
+ };
16
+ /** Served when the host set no document: no paths, the additions only. */
17
+ const EMPTY_DOCUMENT = { openapi: '3.1.0', info: { title: 'API', version: '1.0.0' }, paths: {} };
18
+ const isObject = (value) => typeof value === 'object' && value !== null && !Array.isArray(value);
19
+ /**
20
+ * The host's document: an object (used as given, read on every request), or a path to a
21
+ * JSON file (relative to the working directory), read once. Throws
22
+ * `public-api: cannot read OpenAPI document <path>` when the file cannot be read or parsed.
23
+ */
24
+ function loadOpenApiSource(source) {
25
+ if (source === undefined)
26
+ return () => EMPTY_DOCUMENT;
27
+ if (typeof source === 'string') {
28
+ let doc;
29
+ try {
30
+ doc = JSON.parse((0, fs_1.readFileSync)((0, path_1.resolve)(source), 'utf8'));
31
+ }
32
+ catch {
33
+ doc = undefined;
34
+ }
35
+ if (!isObject(doc)) {
36
+ throw new Error(`public-api: cannot read OpenAPI document ${source}`);
37
+ }
38
+ return () => doc;
39
+ }
40
+ if (!isObject(source)) {
41
+ throw new Error('public-api: the OpenAPI document must be an object or a path to a JSON file');
42
+ }
43
+ // checked once at startup: every request clones and serialises it
44
+ try {
45
+ structuredClone(source);
46
+ JSON.stringify(source);
47
+ }
48
+ catch {
49
+ throw new Error('public-api: the OpenAPI document must be JSON-serialisable');
50
+ }
51
+ return () => source;
52
+ }
53
+ /**
54
+ * A copy of the document with what it lacks added (the host's values always win): the
55
+ * `qcliToken` bearer scheme, a top-level `security` requirement for it, and `servers`
56
+ * with `serverUrl`. The source is never modified.
57
+ */
58
+ function publicDocument(source, serverUrl) {
59
+ const doc = structuredClone(source);
60
+ const components = isObject(doc.components) ? doc.components : (doc.components = {});
61
+ const schemes = isObject(components.securitySchemes) ? components.securitySchemes : (components.securitySchemes = {});
62
+ if (!('qcliToken' in schemes)) {
63
+ schemes.qcliToken = { ...exports.QCLI_TOKEN_SCHEME };
64
+ }
65
+ // a top-level security requirement counts as set only when it is non-empty
66
+ if (!Array.isArray(doc.security) || doc.security.length === 0) {
67
+ doc.security = [{ qcliToken: [] }];
68
+ }
69
+ if (!Array.isArray(doc.servers) || doc.servers.length === 0) {
70
+ doc.servers = [{ url: serverUrl }];
71
+ }
72
+ return doc;
73
+ }
74
+ /** The document's `info.title`, or `API`. */
75
+ function documentTitle(doc) {
76
+ const info = doc.info;
77
+ return isObject(info) && typeof info.title === 'string' && info.title ? info.title : 'API';
78
+ }
79
+ //# sourceMappingURL=openapi.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"openapi.js","sourceRoot":"","sources":["../openapi.ts"],"names":[],"mappings":";;;AAyBA,8CAyBC;AAOD,wCAeC;AAGD,sCAGC;AA9ED,2BAAkC;AAClC,+BAA+B;AAK/B,yEAAyE;AAC5D,QAAA,iBAAiB,GAAG;IAC7B,IAAI,EAAE,MAAM;IACZ,MAAM,EAAE,QAAQ;IAChB,YAAY,EAAE,UAAU;IACxB,WAAW,EAAE,+DAA+D;CACtE,CAAC;AAEX,0EAA0E;AAC1E,MAAM,cAAc,GAAoB,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,EAAE,KAAK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,CAAC,KAAK,CAAC;AAC/F,CAAC"}
@@ -0,0 +1,8 @@
1
+ import { CliInstalledPlugin } from '@qodalis/cli-server-abstractions';
2
+ /** This package's id (npm name). */
3
+ export declare const PUBLIC_API_PLUGIN_ID = "@qodalis/cli-server-plugin-public-api";
4
+ /** This package, as listed among the server's installed plugins. */
5
+ export declare const publicApiInstalledPlugin: CliInstalledPlugin & {
6
+ icon?: string;
7
+ };
8
+ //# sourceMappingURL=package-info.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"package-info.d.ts","sourceRoot":"","sources":["../package-info.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAuB,MAAM,kCAAkC,CAAC;AAE3F,oCAAoC;AACpC,eAAO,MAAM,oBAAoB,0CAA0C,CAAC;AAE5E,oEAAoE;AACpE,eAAO,MAAM,wBAAwB,EAAE,kBAAkB,GAAG;IAAE,IAAI,CAAC,EAAE,MAAM,CAAA;CAG1E,CAAC"}
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.publicApiInstalledPlugin = exports.PUBLIC_API_PLUGIN_ID = void 0;
4
+ const cli_server_abstractions_1 = require("@qodalis/cli-server-abstractions");
5
+ /** This package's id (npm name). */
6
+ exports.PUBLIC_API_PLUGIN_ID = '@qodalis/cli-server-plugin-public-api';
7
+ /** This package, as listed among the server's installed plugins. */
8
+ exports.publicApiInstalledPlugin = {
9
+ ...((0, cli_server_abstractions_1.readInstalledPlugin)(__dirname, exports.PUBLIC_API_PLUGIN_ID, 'Public API') ?? { id: exports.PUBLIC_API_PLUGIN_ID, name: 'Public API' }),
10
+ icon: '🔑',
11
+ };
12
+ //# sourceMappingURL=package-info.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"package-info.js","sourceRoot":"","sources":["../package-info.ts"],"names":[],"mappings":";;;AAAA,8EAA2F;AAE3F,oCAAoC;AACvB,QAAA,oBAAoB,GAAG,uCAAuC,CAAC;AAE5E,oEAAoE;AACvD,QAAA,wBAAwB,GAA2C;IAC5E,GAAG,CAAC,IAAA,6CAAmB,EAAC,SAAS,EAAE,4BAAoB,EAAE,YAAY,CAAC,IAAI,EAAE,EAAE,EAAE,4BAAoB,EAAE,IAAI,EAAE,YAAY,EAAE,CAAC;IAC3H,IAAI,EAAE,IAAI;CACb,CAAC"}