@vite-hub/rate-limit 0.1.0 → 0.3.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.
- package/README.md +18 -14
- package/dist/cli-szm60zN5.d.ts +163 -0
- package/dist/cli.d.ts +1 -1
- package/dist/cli.js +12 -26
- package/dist/{cloudflare-DUDRACVB.js → cloudflare-otBvOPv4.js} +5 -4
- package/dist/{counters-pKORpgGd.d.ts → counters-DXpF67J_.d.ts} +3 -3
- package/dist/{counters-wdEMxDEY.js → counters-DgVdHwdL.js} +13 -6
- package/dist/dev-peer-CHafxbtj.js +238 -0
- package/dist/drivers/cloudflare.d.ts +1 -1
- package/dist/drivers/cloudflare.js +1 -1
- package/dist/drivers/kv.d.ts +2 -0
- package/dist/drivers/kv.js +92 -0
- package/dist/drivers/memory.d.ts +1 -1
- package/dist/drivers/memory.js +5 -5
- package/dist/durability.d.ts +12 -0
- package/dist/durability.js +35 -0
- package/dist/error-diagnostics-MgAnhRTP.js +234 -0
- package/dist/index.d.ts +16 -7
- package/dist/index.js +108 -38
- package/dist/{inspect-D-FzyM_x.js → inspect-B6gTdgy9.js} +7 -1
- package/dist/kv-C1wpLulE.d.ts +29 -0
- package/dist/{limiter-DBrMI4vi.js → kv-provider-C1S6dRTR.js} +16 -9
- package/dist/{operations-tNUdj3G4.d.ts → operation-definition-8gOe-ubD.d.ts} +37 -15
- package/dist/operations-BYRa7wpx.js +1355 -0
- package/dist/{operations-Bu-xulNd.js → operations-CLI9w3rO.js} +9 -14
- package/dist/operations.d.ts +9 -4
- package/dist/operations.js +51 -23
- package/dist/runtime.d.ts +21 -3
- package/dist/runtime.js +2 -2
- package/dist/state-BU-zcLNY.js +89 -0
- package/dist/{types-CQEJpgtz.d.ts → types-CMyR1JeW.d.ts} +43 -23
- package/dist/vite.d.ts +131 -21
- package/dist/vite.js +349 -2479
- package/package.json +21 -17
- package/dist/cli-Cniq99iX.d.ts +0 -85
- package/dist/error-diagnostics-CTAC_bbr.js +0 -56
- package/dist/h3-v1-request-qoGwJr5-.js +0 -235
- package/dist/operations-B09NnEjT.js +0 -1438
- package/dist/state-Ct7zR8fD.js +0 -43
|
@@ -75,7 +75,7 @@ declare namespace StandardSchemaV1 {
|
|
|
75
75
|
type InferOutput<Schema extends StandardTypedV1> = StandardTypedV1.InferOutput<Schema>;
|
|
76
76
|
}
|
|
77
77
|
//#endregion
|
|
78
|
-
//#region ../internal/src/
|
|
78
|
+
//#region ../internal/src/operation-definition.d.ts
|
|
79
79
|
/** `read` never changes state. `write` changes state. `destructive` deletes or publishes. */
|
|
80
80
|
type OperationKind = "read" | "write" | "destructive";
|
|
81
81
|
/** The signed-in user of a call. */
|
|
@@ -98,7 +98,9 @@ interface OperationAccess {
|
|
|
98
98
|
readonly mode: string;
|
|
99
99
|
/**
|
|
100
100
|
* The sections that the call may use. `"all"` when no section filter applies. An entry is a section id (`"kv"`, every
|
|
101
|
-
* operation of the section)
|
|
101
|
+
* operation of the section), `"<section>:read"` (only the operations that read), or `"<section>:<scope>"` (only the
|
|
102
|
+
* calls of a scoped operation for that scope, such as `"blob:media"` for one Blob store). `"<section>:<scope>:read"`
|
|
103
|
+
* allows only the reads of that scope.
|
|
102
104
|
*/
|
|
103
105
|
readonly sections: "all" | readonly string[];
|
|
104
106
|
readonly user?: OperationUser;
|
|
@@ -116,6 +118,12 @@ interface OperationContext {
|
|
|
116
118
|
env?: Record<string, unknown>;
|
|
117
119
|
waitUntil?: (task: Promise<unknown>) => void;
|
|
118
120
|
request?: Request;
|
|
121
|
+
/**
|
|
122
|
+
* The request event of the HTTP request that carries the call, when there is one: the Request of the Console route,
|
|
123
|
+
* with its Standard Context. Operations hand it to app hooks that read the request's own session, such as `identify`
|
|
124
|
+
* of Comments.
|
|
125
|
+
*/
|
|
126
|
+
event?: unknown;
|
|
119
127
|
/** Operations set a success status here, such as 202 for an accepted call. */
|
|
120
128
|
response?: {
|
|
121
129
|
status?: number;
|
|
@@ -138,9 +146,16 @@ interface OperationDefinition<Input, Output> {
|
|
|
138
146
|
description: string;
|
|
139
147
|
/**
|
|
140
148
|
* Console section that grants access, such as `content`. `false`: any Console user. A function reads the section
|
|
141
|
-
* from the input, for operations that serve several sections.
|
|
149
|
+
* from the input, for operations that serve several sections. Section ids cannot contain `:`; it is reserved for
|
|
150
|
+
* scope and read-only grants. A function that returns an invalid id denies the call.
|
|
142
151
|
*/
|
|
143
152
|
section: string | false | ((input: Input) => string | undefined);
|
|
153
|
+
/**
|
|
154
|
+
* The part of a string `section` that one call uses, such as the Blob store that the input names. The call then needs
|
|
155
|
+
* the section (every scope) or `"<section>:<scope>"` (only this scope). A scope that is empty, is `read`, or has a
|
|
156
|
+
* `:` needs the whole section.
|
|
157
|
+
*/
|
|
158
|
+
scope?: (input: Input) => string | undefined;
|
|
144
159
|
/** `read` never changes state. `write` changes state. `destructive` deletes or publishes; the CLI asks for `--yes`, MCP marks `destructiveHint`, agents require approval by default. */
|
|
145
160
|
kind: OperationKind;
|
|
146
161
|
/** Standard Schema (valibot in this repo). Its Standard JSON Schema builds CLI flags and the MCP input schema. */
|
|
@@ -149,19 +164,14 @@ interface OperationDefinition<Input, Output> {
|
|
|
149
164
|
cli?: {
|
|
150
165
|
/** Defaults: namespace = section, command = verb. */
|
|
151
166
|
namespace?: string;
|
|
167
|
+
/** A space groups commands: `jobs list` and `jobs show` run as `vitehub <namespace> jobs list` and `jobs show`. */
|
|
152
168
|
command?: string;
|
|
153
169
|
/** Input keys read from positional arguments, in order. */
|
|
154
170
|
positional?: string[];
|
|
155
171
|
/** Human output, written verbatim. Without it the CLI prints JSON. `--json` always prints JSON. */
|
|
156
172
|
format?: (output: Output) => string;
|
|
157
|
-
/** `vitehub <namespace>` runs this command when no command is named
|
|
173
|
+
/** `vitehub <namespace>` runs this command when no command is named. */
|
|
158
174
|
default?: boolean;
|
|
159
|
-
/**
|
|
160
|
-
* Route of the app that takes a signed dispatch of this operation, such as `/_vitehub/schedules/run`. With `--url`
|
|
161
|
-
* and a dispatch key in the environment (`VITEHUB_DISPATCH_KEY`), the command signs the input and posts it there, so
|
|
162
|
-
* a CI job needs no Console credentials. Without a key it calls the RPC.
|
|
163
|
-
*/
|
|
164
|
-
dispatch?: string;
|
|
165
175
|
};
|
|
166
176
|
/** Largest request body in bytes. It can raise the 64 KiB default but not lower it. */
|
|
167
177
|
maxRequestBytes?: number;
|
|
@@ -170,8 +180,16 @@ interface OperationDefinition<Input, Output> {
|
|
|
170
180
|
* confirmation, and agents run it without approval. Without it, every call of a `destructive` operation asks.
|
|
171
181
|
*/
|
|
172
182
|
readOnlyWhen?: (input: Input) => boolean;
|
|
173
|
-
/**
|
|
174
|
-
|
|
183
|
+
/**
|
|
184
|
+
* How MCP offers the operation as a tool. `false`: MCP does not offer it, such as an editor transport that only the
|
|
185
|
+
* Console uses. `title`: the short title that clients show, instead of the name in words. `format`: the text of a
|
|
186
|
+
* result for the Agent, such as a list of lines. The result stays the structured content. Without `format`, the text
|
|
187
|
+
* is the result as JSON.
|
|
188
|
+
*/
|
|
189
|
+
mcp?: false | {
|
|
190
|
+
title?: string;
|
|
191
|
+
format?: (output: NoInfer<Output>) => string;
|
|
192
|
+
};
|
|
175
193
|
/** `false`: the operation never reads `context.user`, so the Console skips the session lookup for it. */
|
|
176
194
|
user?: false;
|
|
177
195
|
/**
|
|
@@ -182,24 +200,28 @@ interface OperationDefinition<Input, Output> {
|
|
|
182
200
|
run: (input: Input, context: OperationContext) => Output | Promise<Output>;
|
|
183
201
|
}
|
|
184
202
|
/** An operation of any input and output, as a registry holds it. */
|
|
185
|
-
interface AnyOperation extends Omit<OperationDefinition<unknown, unknown>, "cli" | "input" | "output" | "readOnlyWhen" | "run" | "section"> {
|
|
203
|
+
interface AnyOperation extends Omit<OperationDefinition<unknown, unknown>, "cli" | "input" | "mcp" | "output" | "readOnlyWhen" | "run" | "scope" | "section"> {
|
|
186
204
|
readOnlyWhen?: (input: never) => boolean;
|
|
187
205
|
cli?: {
|
|
188
206
|
namespace?: string;
|
|
189
207
|
command?: string;
|
|
190
208
|
default?: boolean;
|
|
191
|
-
dispatch?: string;
|
|
192
209
|
positional?: string[];
|
|
193
210
|
format?: (output: never) => string;
|
|
194
211
|
};
|
|
212
|
+
mcp?: false | {
|
|
213
|
+
title?: string;
|
|
214
|
+
format?: (output: never) => string;
|
|
215
|
+
};
|
|
195
216
|
input: StandardSchemaV1;
|
|
196
217
|
output?: StandardSchemaV1;
|
|
197
218
|
run: (input: never, context: OperationContext) => unknown;
|
|
219
|
+
scope?: (input: never) => string | undefined;
|
|
198
220
|
section: string | false | ((input: never) => string | undefined);
|
|
199
221
|
}
|
|
200
222
|
/** The contribution of one plugin: operations, or a module that exports them. */
|
|
201
223
|
interface OperationContributionEntry {
|
|
202
|
-
/**
|
|
224
|
+
/** The absolute path of the module that generated code imports, such as `ownModule(import.meta.url, "operations")`. */
|
|
203
225
|
module: string;
|
|
204
226
|
/** Named export that holds an operation or an array of operations. Defaults to `default`. */
|
|
205
227
|
export?: string;
|