@vite-hub/rate-limit 0.0.3 → 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.
@@ -0,0 +1,160 @@
1
+ //#region src/types.d.ts
2
+ type MaybePromise<T> = Promise<T> | T;
3
+ type RateLimitWindow = `${number}ms` | `${number}s` | `${number}m` | `${number}h` | `${number}d`;
4
+ type RateLimitEnforcement = "best-effort" | "strict";
5
+ type RateLimitFailurePolicy = "allow" | "deny";
6
+ type RateLimitCounterScope = "global" | "location" | "process";
7
+ type RateLimitRejectedAttemptBehavior = "counted" | "not-counted" | "unknown";
8
+ interface RateLimitPolicy {
9
+ enforcement?: RateLimitEnforcement;
10
+ failure?: RateLimitFailurePolicy;
11
+ limit: number;
12
+ window: RateLimitWindow;
13
+ }
14
+ interface RequireRateLimitOptions extends RateLimitPolicy {
15
+ key?: string;
16
+ }
17
+ /** A server request event: an H3 2 event, as in Nitro 3, or an H3 1 event, as in Nuxt 4. */
18
+ type RateLimitRequestEvent = {
19
+ readonly req: {
20
+ readonly headers: {
21
+ get: (name: string) => string | null;
22
+ };
23
+ };
24
+ } | {
25
+ readonly node: {
26
+ readonly req: {
27
+ readonly headers: Readonly<Record<string, string | string[] | undefined>>;
28
+ };
29
+ };
30
+ };
31
+ interface ResolvedRateLimitPolicy {
32
+ readonly enforcement: RateLimitEnforcement;
33
+ readonly failure: RateLimitFailurePolicy;
34
+ readonly limit: number;
35
+ readonly window: RateLimitWindow;
36
+ readonly windowMs: number;
37
+ }
38
+ interface RateLimitConsumeInput {
39
+ key: string;
40
+ }
41
+ interface RateLimitDriverInput extends RateLimitConsumeInput {
42
+ limit: number;
43
+ name?: string;
44
+ windowMs: number;
45
+ }
46
+ interface RateLimitDriverResult {
47
+ allowed: boolean;
48
+ remaining?: number;
49
+ /** Positive Unix timestamp in milliseconds, at most `8.64e15`. */
50
+ resetAt?: number;
51
+ retryAfter?: number;
52
+ used?: number;
53
+ }
54
+ type RateLimitDriverOutcome = [error: null, value: RateLimitDriverResult] | [error: Error, value: undefined];
55
+ interface RateLimitDecisionBase extends RateLimitDriverResult {
56
+ limit: number;
57
+ windowMs: number;
58
+ }
59
+ interface RateLimitAllowedDecision extends RateLimitDecisionBase {
60
+ allowed: true;
61
+ cause?: never;
62
+ reason?: never;
63
+ }
64
+ interface RateLimitLimitedDecision extends RateLimitDecisionBase {
65
+ allowed: false;
66
+ cause?: never;
67
+ reason: "limited";
68
+ }
69
+ interface RateLimitUnavailableDecision extends RateLimitDecisionBase {
70
+ cause: unknown;
71
+ reason: "unavailable";
72
+ }
73
+ type RateLimitDecision = RateLimitAllowedDecision | RateLimitLimitedDecision | RateLimitUnavailableDecision;
74
+ interface RateLimitDriverCapabilities {
75
+ readonly enforcement: RateLimitEnforcement;
76
+ readonly rejectedAttempts: RateLimitRejectedAttemptBehavior;
77
+ readonly scope: RateLimitCounterScope;
78
+ readonly windows?: readonly number[];
79
+ }
80
+ /** Counter state that a driver reads without consuming a token. */
81
+ interface RateLimitDriverPeekResult {
82
+ /** Positive window-end timestamp in milliseconds, at most `8.64e15`. Omit it when no counter is active. */
83
+ resetAt?: number;
84
+ /** Tokens consumed in the current window. `0` when the key has no active counter. */
85
+ used: number;
86
+ }
87
+ type RateLimitDriverPeekOutcome = [error: null, value: RateLimitDriverPeekResult] | [error: Error, value: undefined];
88
+ type RateLimitDriverResetOutcome = [error: Error | null];
89
+ interface RateLimitDriver {
90
+ capabilities: RateLimitDriverCapabilities;
91
+ consume: (input: RateLimitDriverInput) => MaybePromise<RateLimitDriverOutcome>;
92
+ name: string;
93
+ /**
94
+ * Reads the counter of a key without consuming a token. Omit it when the provider cannot read a counter. The
95
+ * Rate Limiter then reports `unsupported`.
96
+ */
97
+ peek?: (input: RateLimitDriverInput) => MaybePromise<RateLimitDriverPeekOutcome>;
98
+ /** Deletes the counter of a key. Omit it when the provider cannot reset a counter. */
99
+ reset?: (input: RateLimitDriverInput) => MaybePromise<RateLimitDriverResetOutcome>;
100
+ }
101
+ interface RateLimitPeekBase {
102
+ limit: number;
103
+ windowMs: number;
104
+ }
105
+ /** Counter state of one key. `peek()` does not consume a token. */
106
+ type RateLimitPeekResult = (RateLimitPeekBase & {
107
+ remaining: number;
108
+ resetAt?: number;
109
+ status: "known";
110
+ used: number;
111
+ }) | (RateLimitPeekBase & {
112
+ reason: string;
113
+ status: "unsupported";
114
+ }) | (RateLimitPeekBase & {
115
+ cause: unknown;
116
+ status: "unavailable";
117
+ });
118
+ type RateLimitResetResult = {
119
+ status: "reset";
120
+ } | {
121
+ reason: string;
122
+ status: "unsupported";
123
+ } | {
124
+ cause: unknown;
125
+ status: "unavailable";
126
+ };
127
+ interface RateLimiter {
128
+ readonly capabilities: RateLimitDriverCapabilities;
129
+ consume: (input: RateLimitConsumeInput) => Promise<RateLimitDecision>;
130
+ /** Reads the counter of a key without consuming a token. */
131
+ peek: (input: RateLimitConsumeInput) => Promise<RateLimitPeekResult>;
132
+ policy: ResolvedRateLimitPolicy;
133
+ /** Deletes the counter of a key, so the next request starts a new window. */
134
+ reset: (input: RateLimitConsumeInput) => Promise<RateLimitResetResult>;
135
+ }
136
+ interface RateLimitDeclaration {
137
+ name: string;
138
+ policy: RateLimitPolicy;
139
+ source: {
140
+ column: number;
141
+ file: string;
142
+ line: number;
143
+ };
144
+ }
145
+ interface CreateRateLimiterOptions extends RateLimitPolicy {
146
+ driver: RateLimitDriver;
147
+ name?: string;
148
+ }
149
+ type RateLimitProvider = "auto" | "cloudflare" | "memory";
150
+ interface RateLimitModuleOptions {
151
+ namespace?: string;
152
+ provider?: RateLimitProvider;
153
+ projectRoot?: string;
154
+ scanDirs?: string[];
155
+ }
156
+ interface RateLimitRuntimeConfig {
157
+ provider: Exclude<RateLimitProvider, "auto">;
158
+ }
159
+ //#endregion
160
+ export { RateLimitRuntimeConfig as C, ResolvedRateLimitPolicy as D, RequireRateLimitOptions as E, RateLimitResetResult as S, RateLimiter as T, RateLimitPeekResult as _, RateLimitDeclaration as a, RateLimitRejectedAttemptBehavior as b, RateLimitDriverInput as c, RateLimitDriverPeekResult as d, RateLimitDriverResetOutcome as f, RateLimitModuleOptions as g, RateLimitFailurePolicy as h, RateLimitDecision as i, RateLimitDriverOutcome as l, RateLimitEnforcement as m, RateLimitConsumeInput as n, RateLimitDriver as o, RateLimitDriverResult as p, RateLimitCounterScope as r, RateLimitDriverCapabilities as s, CreateRateLimiterOptions as t, RateLimitDriverPeekOutcome as u, RateLimitPolicy as v, RateLimitWindow as w, RateLimitRequestEvent as x, RateLimitProvider as y };
package/dist/vite.d.ts CHANGED
@@ -1,14 +1,338 @@
1
- import { f as RateLimitModuleOptions } from "./types-BX4hSfYX.js";
1
+ import { r as ViteHubCliPluginMetadata } from "./cli-Cniq99iX.js";
2
+ import { a as RateLimitDeclaration, g as RateLimitModuleOptions } from "./types-CQEJpgtz.js";
3
+ import { n as OperationContributionEntry } from "./operations-tNUdj3G4.js";
2
4
  import { Plugin } from "vite";
3
-
5
+ //#region ../internal/src/inspect.d.ts
6
+ interface ViteHubDefinitionField {
7
+ label: string;
8
+ value: string;
9
+ }
10
+ /** Serializable summary of one discovered Definition. Files are relative to the project root. */
11
+ interface ViteHubDefinitionSummary {
12
+ fields: readonly ViteHubDefinitionField[];
13
+ file: string;
14
+ name: string;
15
+ source: string;
16
+ }
17
+ /** Lists the Definitions that one owner package discovered for the resolved Vite config. */
18
+ interface ViteHubDefinitionInspector {
19
+ /** Stable singular kind, for example `queue` or `rate-limit`. */
20
+ kind: string;
21
+ label: string;
22
+ list: () => Promise<readonly ViteHubDefinitionSummary[]> | readonly ViteHubDefinitionSummary[];
23
+ }
24
+ /** One generated Provider Output file or directory that an owner package can write. */
25
+ interface ViteHubProviderOutputEntry {
26
+ description: string;
27
+ owner: string;
28
+ /** Absolute path. */
29
+ path: string;
30
+ }
31
+ interface ViteHubInspectionContributor {
32
+ definitions?: readonly ViteHubDefinitionInspector[];
33
+ providerOutput?: readonly ViteHubProviderOutputEntry[];
34
+ }
35
+ type ViteHubInspectionContributorFactory = () => ViteHubInspectionContributor | undefined | Promise<ViteHubInspectionContributor | undefined>;
36
+ interface ViteHubInspectionPluginMetadata {
37
+ inspect?: ViteHubInspectionContributor | ViteHubInspectionContributorFactory;
38
+ }
39
+ //#endregion
40
+ //#region src/discovery.d.ts
41
+ export declare function discoverRateLimitDeclarations(options: {
42
+ rootDir: string;
43
+ scanDirs?: string[];
44
+ }): RateLimitDeclaration[];
45
+ //#endregion
46
+ //#region ../internal/src/console.d.ts
47
+ type MaybePromise<T> = T | Promise<T>;
48
+ /** Lists discovered Definitions in a sidebar and shows the selected Definition's fields. */
49
+ interface ViteHubConsoleDefinitionCatalogView {
50
+ kind: "definition-catalog";
51
+ /** States which runtime data this catalog does not include. */
52
+ notice: string;
53
+ }
54
+ interface ViteHubConsoleRecordColumn {
55
+ /** Key in `ViteHubConsoleRecord.cells`. */
56
+ key: string;
57
+ label: string;
58
+ }
59
+ /** Shows records in a table and the selected record's fields in a detail panel. */
60
+ interface ViteHubConsoleRecordTableView {
61
+ columns: readonly ViteHubConsoleRecordColumn[];
62
+ kind: "record-table";
63
+ /** States the source and limits of the records. */
64
+ notice: string;
65
+ }
66
+ /**
67
+ * Lists the collections and documents of an owner runtime and edits them with owner actions: a form generated from each
68
+ * collection's JSON Schema, a Markdown body, save, publish, and revision history.
69
+ */
70
+ interface ViteHubConsoleDocumentEditorView {
71
+ kind: "document-editor";
72
+ /** States where documents are stored and what the editor does not do. */
73
+ notice: string;
74
+ }
75
+ interface ViteHubConsoleOperationColumn {
76
+ /** Dot path into each item of the result, such as `author.name` or `messages.0.body`. */
77
+ key: string;
78
+ label: string;
79
+ /** `datetime` shows a time in milliseconds since the epoch as a date. `excerpt` cuts a long text. */
80
+ format?: "datetime" | "excerpt";
81
+ }
82
+ /** A chip above the list. Choosing it merges `input` into the operation input. The first chip is the default. */
83
+ interface ViteHubConsoleOperationFilter {
84
+ id: string;
85
+ label: string;
86
+ input: Readonly<Record<string, unknown>>;
87
+ }
88
+ /**
89
+ * Lists the items that an operation returns, called over the Console RPC with the signed-in Console user. The operation
90
+ * checks the access of that user for each item, so the view shows only what the user may read. `operation` must return an
91
+ * array of objects with an `id`. A failure of the operation, with its `fix`, shows where the list would be.
92
+ */
93
+ interface ViteHubConsoleOperationView {
94
+ columns: readonly ViteHubConsoleOperationColumn[];
95
+ filters?: readonly ViteHubConsoleOperationFilter[];
96
+ kind: "operation-view";
97
+ /**
98
+ * Makes each row a link: `{path}` placeholders take values from the item and are URL-encoded, and `{path:path}` takes an
99
+ * app path and encodes each segment (a value that is not an app path, such as `//evil.com/x`, gives no link). Rows where
100
+ * `when.path` is not `when.equals` get none.
101
+ */
102
+ link?: {
103
+ label?: string;
104
+ template: string;
105
+ when?: {
106
+ equals: string;
107
+ path: string;
108
+ };
109
+ };
110
+ notice: string;
111
+ /** Operation name, such as `comments.list`. */
112
+ operation: string;
113
+ /** Fetch every page with `limit` and a `before` object whose keys read these dot paths from the last item. */
114
+ pagination?: {
115
+ limit: number;
116
+ cursor: Readonly<Record<string, string>>;
117
+ };
118
+ }
119
+ interface ViteHubConsoleAuthView {
120
+ kind: "auth-management";
121
+ notice: string;
122
+ }
123
+ interface ViteHubConsoleAuthSection extends ViteHubConsoleSectionDescriptor<ViteHubConsoleAuthView> {}
124
+ type ViteHubConsoleSectionView = ViteHubConsoleOperationView | ViteHubConsoleAuthView | ViteHubConsoleDefinitionCatalogView | ViteHubConsoleRecordTableView | ViteHubConsoleDocumentEditorView;
125
+ /**
126
+ * The overview of a document editor section: document counts by state, the changes that wait for a publish, recent
127
+ * activity, and a New button per collection. It reads the owner `overview` action.
128
+ */
129
+ interface ViteHubConsoleDocumentDashboardView {
130
+ kind: "document-dashboard";
131
+ }
132
+ /**
133
+ * The media library of a document editor section: folders, uploads, alt text, focal points, and crops of the Blob Store
134
+ * that `blob.serve` serves. The owner decides who may use it with `mediaAccess`, and finds the documents that use a file
135
+ * with `references`. The page needs the Blob section, so declare it with `requires: ["blob"]`.
136
+ */
137
+ interface ViteHubConsoleMediaLibraryView {
138
+ kind: "media-library";
139
+ }
140
+ /**
141
+ * The singletons of a document editor section, such as site settings: one row per singleton that opens it in the
142
+ * editor. Singletons appear here instead of among the collections, and the Console hides the page when the section has
143
+ * none.
144
+ */
145
+ interface ViteHubConsoleDocumentSettingsView {
146
+ kind: "document-settings";
147
+ }
148
+ /** A view that the Console UI in `vite-hub` renders for a section page. */
149
+ type ViteHubConsoleSectionPageView = ViteHubConsoleDocumentDashboardView | ViteHubConsoleDocumentSettingsView | ViteHubConsoleMediaLibraryView;
150
+ /**
151
+ * A page of a section next to its main view, such as the Content dashboard or media library. The section sidebar lists
152
+ * the pages, and each page has its own URL:
153
+ *
154
+ * - `/_vitehub/<section>` serves the `index` page, or the main view when the section has none.
155
+ * - `/_vitehub/<section>/-/<page>` serves every other page. The `-` segment keeps page URLs apart from the main view's
156
+ * own segments, such as a collection name.
157
+ *
158
+ * Pages share the access of their section: `console.authorize` that allows the section allows every page of it.
159
+ */
160
+ interface ViteHubConsoleSectionPage {
161
+ /** Lowercase route segment, for example `media`. */
162
+ id: string;
163
+ /** Display name, for example `Media`. */
164
+ label: string;
165
+ /** Iconify class name, for example `i-lucide-image`. */
166
+ icon: string;
167
+ view: ViteHubConsoleSectionPageView;
168
+ /**
169
+ * Serve this page at the section root. At most one page sets it, and `/_vitehub/<section>/-/<id>` then redirects to
170
+ * the root.
171
+ */
172
+ index?: boolean;
173
+ /**
174
+ * Sidebar heading, for example `Assets`. Pages without a group lead the sidebar, above the main view's navigation.
175
+ * Grouped pages follow it, in the order their group first appears.
176
+ */
177
+ group?: string;
178
+ /** Section ids that the project must enable, such as `["blob"]`. The Console leaves the page out otherwise. */
179
+ requires?: readonly string[];
180
+ }
181
+ /** One entry of a record's activity, such as a comment in a thread. `at` is an ISO 8601 timestamp. */
182
+ interface ViteHubConsoleRecordActivity {
183
+ author: string;
184
+ at: string;
185
+ text: string;
186
+ }
187
+ /** One serializable record row. Values are display strings. Do not put credentials in records. */
188
+ interface ViteHubConsoleRecord {
189
+ cells: Readonly<Record<string, string>>;
190
+ fields: readonly ViteHubDefinitionField[];
191
+ id: string;
192
+ /** The Console can run this record when it represents a runnable Schedule Definition. */
193
+ runnable?: boolean;
194
+ /**
195
+ * Where the record lives in the app, such as the page of a comment thread. `href` is an app path that starts with one
196
+ * `/`, or an `https:` URL. The Console opens it in a new tab.
197
+ */
198
+ link?: {
199
+ href: string;
200
+ label: string;
201
+ };
202
+ /** Entries in time order, such as the comments of a thread. The Console shows them as a conversation. */
203
+ activity?: readonly ViteHubConsoleRecordActivity[];
204
+ }
205
+ /** Serializable description of a Console section. The Console UI in `vite-hub` renders the view. */
206
+ interface ViteHubConsoleSectionDescriptor<TView extends ViteHubConsoleSectionView = ViteHubConsoleSectionView> {
207
+ description: string;
208
+ /**
209
+ * Iconify class name, for example `i-lucide-inbox`. The Console draws with Lucide; `ph` also resolves. The
210
+ * Console build bundles the icon of every section in the `vite-hub` Console registry and fails if it cannot resolve one.
211
+ */
212
+ icon: string;
213
+ /** Lowercase route segment, for example `queues`. The Console serves the section at `/_vitehub/<id>`. */
214
+ id: string;
215
+ /** Plural display name, for example `Queues`. */
216
+ label: string;
217
+ view: TView;
218
+ /** Pages next to the main view, in sidebar order. Only document editor sections render pages today. */
219
+ pages?: readonly ViteHubConsoleSectionPage[];
220
+ }
221
+ interface ViteHubConsoleDefinitionCatalogSection<TOptions = void> extends ViteHubConsoleSectionDescriptor<ViteHubConsoleDefinitionCatalogView> {
222
+ /** Reads the section data on the server. The Console never runs it in the browser. */
223
+ read: (options: TOptions) => MaybePromise<readonly ViteHubDefinitionSummary[]>;
224
+ }
225
+ interface ViteHubConsoleRecordTableSection<TOptions = void> extends ViteHubConsoleSectionDescriptor<ViteHubConsoleRecordTableView> {
226
+ /** Reads the section data on the server. The Console never runs it in the browser. */
227
+ read: (options: TOptions) => MaybePromise<readonly ViteHubConsoleRecord[]>;
228
+ }
229
+ /** A named export of an owner package server module that the host imports in its generated server code. */
230
+ interface ViteHubConsoleServerExport {
231
+ /** Named export of `module`. */
232
+ export: string;
233
+ /**
234
+ * Owner package module specifier, for example `@vite-hub/email/runtime/console`. The host maps it to the module
235
+ * path that the application can import.
236
+ */
237
+ module: string;
238
+ }
239
+ /**
240
+ * Server module export that returns records on each Console request. The export must be a
241
+ * {@link ViteHubConsoleRuntimeRecordReader}.
242
+ */
243
+ interface ViteHubConsoleRuntimeReader extends ViteHubConsoleServerExport {}
244
+ /**
245
+ * A record table that also reads records at request time. The Console shows the build-time records of `read` first,
246
+ * then the records of the `runtime` reader. A runtime record replaces a build-time record with the same id.
247
+ */
248
+ interface ViteHubConsoleRuntimeRecordTableSection<TOptions = void> extends ViteHubConsoleSectionDescriptor<ViteHubConsoleRecordTableView> {
249
+ /** Reads build-time records on the server. When omitted, the section has only runtime records. */
250
+ read?: (options: TOptions) => MaybePromise<readonly ViteHubConsoleRecord[]>;
251
+ runtime: ViteHubConsoleRuntimeReader;
252
+ /**
253
+ * Returns the absolute path of the application module that turns the section on, such as `server/comments.ts`, or
254
+ * `undefined` when the project has none. With it, the host shows the section only when the module exists; without
255
+ * it, a Vite option enables the section.
256
+ */
257
+ entry?: (options: TOptions) => MaybePromise<string | undefined>;
258
+ }
259
+ /** A section whose list comes from an operation, called with the Console user on each visit. It has no build-time data. */
260
+ interface ViteHubConsoleOperationSection extends ViteHubConsoleSectionDescriptor<ViteHubConsoleOperationView> {}
261
+ /**
262
+ * A document editor section. The owner finds the application module that holds its runtime, such as `server/content.ts`,
263
+ * and names the server export that turns that module into {@link ViteHubConsoleDocumentActions}. The host shows the
264
+ * section only when `entry` finds a module, imports the module on the first Console request, and checks the Console
265
+ * section before it calls an action. The owner actions check their own access policy for the signed-in user.
266
+ */
267
+ interface ViteHubConsoleDocumentEditorSection<TOptions = void> extends ViteHubConsoleSectionDescriptor<ViteHubConsoleDocumentEditorView> {
268
+ /** Returns the absolute path of the application module, or `undefined` when the project has none. */
269
+ entry: (options: TOptions) => MaybePromise<string | undefined>;
270
+ /**
271
+ * Reads, at build time and without running the application, what the project lacks for some editor features, such as
272
+ * a runner for scheduled publishes. The Console merges it with the owner `setup` action on each request.
273
+ */
274
+ inspect?: (options: TOptions, entry: string) => MaybePromise<ViteHubConsoleDocumentSetup>;
275
+ /** Owner export that must be a {@link ViteHubConsoleDocumentActionsFactory}. */
276
+ actions: ViteHubConsoleServerExport;
277
+ }
278
+ /**
279
+ * A Console section that an owner package contributes. The owner defines the label, icon, view, and data reader.
280
+ * `TOptions` is the discovery context that the host passes to `read`.
281
+ */
282
+ type ViteHubConsoleSectionContribution<TOptions = void> = ViteHubConsoleAuthSection | ViteHubConsoleDefinitionCatalogSection<TOptions> | ViteHubConsoleRecordTableSection<TOptions> | ViteHubConsoleRuntimeRecordTableSection<TOptions> | ViteHubConsoleDocumentEditorSection<TOptions> | ViteHubConsoleOperationSection;
283
+ /** A fix that the owner names for a feature the project lacks, such as `Add authorize to defineContent().` */
284
+ interface ViteHubConsoleDocumentHint {
285
+ /** One sentence that names the fix. Text in backticks shows as code. */
286
+ message: string;
287
+ /** Absolute URL of the documentation for the fix. */
288
+ docs?: string;
289
+ }
290
+ /**
291
+ * What the project lacks for some editor features. The editor names each fix where the feature would be, instead of
292
+ * failing without a reason.
293
+ */
294
+ interface ViteHubConsoleDocumentSetup {
295
+ /** Present when no user can read anything because the owner has no access policy. */
296
+ access?: ViteHubConsoleDocumentHint;
297
+ /**
298
+ * Live co-editing. `definition` names the Realtime Definition whose rooms are `<collection>/<id>`; the editor joins
299
+ * the room of a Markdown document instead of taking the edit lease. `unavailable` names why the owner wanted live
300
+ * editing and the host cannot run it, such as a host without a Realtime authority. Absent when live editing is off.
301
+ */
302
+ live?: {
303
+ definition: string;
304
+ } | {
305
+ unavailable: string;
306
+ };
307
+ /**
308
+ * Present when nothing runs scheduled publishes. The editor disables Schedule, and overdue schedules name the fix.
309
+ */
310
+ schedule?: ViteHubConsoleDocumentHint;
311
+ }
312
+ //#endregion
313
+ //#region src/inspect.d.ts
314
+ interface RateLimitInspectionOptions {
315
+ projectRoot: string;
316
+ rootDir: string;
317
+ scanDirs?: string[];
318
+ }
319
+ /** Lists `requireRateLimit()` declarations as serializable inspection summaries. */
320
+ export declare function inspectRateLimitDefinitions(options: RateLimitInspectionOptions): ViteHubDefinitionSummary[];
321
+ /** Console section that lists discovered Rate Limit Definitions. `vitehub inspect definitions` reads the same data. */
322
+ export declare const rateLimitConsoleSection: ViteHubConsoleSectionContribution<RateLimitInspectionOptions>;
323
+ //#endregion
4
324
  //#region src/vite.d.ts
5
- type RateLimitVitePluginOptions = RateLimitModuleOptions;
6
- type RateLimitVitePlugin = Plugin;
7
- declare function hubRateLimit(options?: RateLimitVitePluginOptions): RateLimitVitePlugin;
325
+ export type RateLimitVitePluginOptions = RateLimitModuleOptions;
326
+ export type RateLimitVitePlugin = Plugin & {
327
+ vitehub: ViteHubCliPluginMetadata & ViteHubInspectionPluginMetadata & {
328
+ operations: readonly OperationContributionEntry[];
329
+ };
330
+ };
331
+ export declare function hubRateLimit(options?: RateLimitVitePluginOptions): RateLimitVitePlugin;
8
332
  declare module "vite" {
9
333
  interface UserConfig {
10
334
  rateLimit?: RateLimitModuleOptions;
11
335
  }
12
336
  }
13
337
  //#endregion
14
- export { RateLimitVitePlugin, RateLimitVitePluginOptions, hubRateLimit };
338
+ export type { RateLimitInspectionOptions };