@midsummer-ai/sdk 0.1.0-next.901 → 0.1.0-staging.3106

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.
Files changed (40) hide show
  1. package/auth-1W-SzpD3.mjs +441 -0
  2. package/build-DQo-JrlN.d.mts +120 -0
  3. package/bytes-C2pcyl9u.mjs +280 -0
  4. package/{connection-CDk7H1FL.mjs → connection-Cu2GSOaR.mjs} +171 -31
  5. package/database/build.d.mts +2 -2
  6. package/database/build.mjs +1404 -117
  7. package/database/client.d.mts +85 -9
  8. package/database/client.mjs +550 -32
  9. package/database/contract.d.mts +92 -2
  10. package/database/contract.mjs +2179 -3
  11. package/database/errors.d.mts +1 -22
  12. package/database/react.d.mts +133 -0
  13. package/database/react.mjs +488 -0
  14. package/database/server.d.mts +2 -3
  15. package/database/server.mjs +3 -320
  16. package/database/stand-in.d.mts +95 -9
  17. package/database/stand-in.mjs +1436 -116
  18. package/errors-x2vXKi0u.d.mts +25 -0
  19. package/index-DNNXNny7.d.mts +410 -0
  20. package/key-BrRdFY-n.mjs +11 -0
  21. package/package.json +114 -1
  22. package/schema-CTHQMRsW.mjs +217 -0
  23. package/server-B5HK2Ou9.d.mts +574 -0
  24. package/server-EDRbF2u-.mjs +1893 -0
  25. package/{store-BzI9at5x.mjs → store-lIZ5GxVv.mjs} +1 -1
  26. package/{tabs-D-P8_ci_.mjs → tabs-zCh8kceo.mjs} +1 -1
  27. package/vector/contract.d.mts +1 -1
  28. package/vector/contract.mjs +773 -1
  29. package/vector/index.d.mts +2 -2
  30. package/vector/index.mjs +71 -3
  31. package/vector/stand-in.d.mts +1 -1
  32. package/vector/stand-in.mjs +326 -23
  33. package/vector/wire.d.mts +11 -2
  34. package/vector/wire.mjs +179 -14
  35. package/build-SQ44jwSa.d.mts +0 -41
  36. package/index-DdoK0y7D.d.mts +0 -192
  37. package/schema-BF-Y1EVu.mjs +0 -142
  38. package/schema-DS8x1Dn8.mjs +0 -115
  39. package/schema-f7E9uzUn.d.mts +0 -74
  40. package/server-C7O7CICU.d.mts +0 -182
@@ -0,0 +1,574 @@
1
+ //#region src/database/schema.d.ts
2
+ /**
3
+ * A Database's shapes: `v`, `defineTable`, `defineSchema`, and the check of a value against a
4
+ * shape. Plain data and pure functions, the same as the engine's, so a schema built here is the one
5
+ * the Database builds.
6
+ *
7
+ * export default defineSchema({
8
+ * messages: defineTable({ channel: v.string(), body: v.string() }).index("by_channel", "channel"),
9
+ * })
10
+ *
11
+ * A table may also have up to four search indexes, a string field's words ranked best first, and up
12
+ * to four vector indexes, a field of numbers searched by closeness from an action. A field may be a
13
+ * path into an object (`"author.id"`); a filter field may be of any shape; `staged: true` declares an
14
+ * index that serves no search yet:
15
+ *
16
+ * defineTable({ channel: v.string(), body: v.string(), embedding: v.array(v.number()) })
17
+ * .searchIndex("search_body", { searchField: "body", filterFields: ["channel"] })
18
+ * .vectorIndex("by_embedding", { vectorField: "embedding", dimensions: 1536, filterFields: ["channel"] })
19
+ */
20
+ /** A shape, as `v` makes it: a name for the simple ones, an object for the rest. */
21
+ type Shape = "string" | "number" | "boolean" | "document" | "int64" | "bytes" | "timestamp" | "decimal" | {
22
+ readonly optional: Shape;
23
+ } | {
24
+ readonly array: Shape;
25
+ } | {
26
+ readonly object: Readonly<Record<string, Shape>>;
27
+ } | {
28
+ readonly literal: unknown;
29
+ } | {
30
+ readonly union: ReadonlyArray<Shape>;
31
+ } | {
32
+ readonly record: Shape;
33
+ } | {
34
+ readonly id: string;
35
+ };
36
+ /** A table's code: the first 7 characters of every id inserted into it, so a table can be found from an id alone. */
37
+ declare const tableCode: (table: string) => string;
38
+ /**
39
+ * An id's form, whoever mints it: its table's code (`tableCode`, 7 characters), then more base-36 letters and
40
+ * digits (`[0-9a-z]`), 16 to 256 characters in all. The SDK mints the code, 7 characters of its call's FNV-1a, then
41
+ * its insert's count; a Database may mint its own ids (`Rows.newId`), in this form, and `normalizeId` and
42
+ * `v.id` take every id of it for its table.
43
+ */
44
+ declare const ID_FORM: RegExp;
45
+ /** Whether `id` has the form of an id of `table` (`ID_FORM`, beginning with its table's code). */
46
+ declare const isIdForm: (table: string, id: string) => boolean;
47
+ declare const v: Readonly<{
48
+ string: () => Shape;
49
+ number: () => Shape;
50
+ boolean: () => Shape;
51
+ /** Any JSON value, at any depth. */
52
+ document: () => Shape;
53
+ /** Any value, as Convex's `v.any()`: the same shape as `v.document()`. */
54
+ any: () => Shape;
55
+ /** Only null, as Convex's `v.null()`: `v.union(v.string(), v.null())` is a string or null. */
56
+ null: () => Shape;
57
+ /** May be left out or null. */
58
+ optional: (shape: Shape) => Shape;
59
+ array: (shape: Shape) => Shape;
60
+ object: (fields: Record<string, Shape>) => Shape;
61
+ int64: () => Shape;
62
+ bytes: () => Shape;
63
+ timestamp: () => Shape;
64
+ decimal: () => Shape;
65
+ literal: (value: string | number | boolean) => Shape;
66
+ union: (...shapes: Shape[]) => Shape;
67
+ record: (shape: Shape) => Shape;
68
+ id: (table: string) => Shape;
69
+ }>;
70
+ /** An index as declared: one field, a list of them for a compound index, or either with `unique`. */
71
+ type IndexDeclaration = string | ReadonlyArray<string> | {
72
+ readonly fields: string | ReadonlyArray<string>;
73
+ readonly unique: true;
74
+ };
75
+ /** A search index: the string field whose words it ranks, the fields a search may match exactly, and whether it is staged (serving none yet). */
76
+ interface SearchIndex {
77
+ readonly field: string;
78
+ readonly filters: ReadonlyArray<string>;
79
+ readonly staged: boolean;
80
+ }
81
+ /** A vector index: the field holding `dimensions` numbers, the fields a vector search may match exactly, and whether it is staged. */
82
+ interface VectorIndex {
83
+ readonly field: string;
84
+ readonly dimensions: number;
85
+ readonly filters: ReadonlyArray<string>;
86
+ readonly staged: boolean;
87
+ }
88
+ interface Table {
89
+ readonly fields: Readonly<Record<string, Shape>>;
90
+ readonly indexes: Readonly<Record<string, IndexDeclaration>>;
91
+ /** Its search indexes, by name. */
92
+ readonly search: Readonly<Record<string, SearchIndex>>;
93
+ /** Its vector indexes, by name. */
94
+ readonly vector: Readonly<Record<string, VectorIndex>>;
95
+ /** A new table with the index added: one field, or a list for a compound index; `{ unique: true }` lets no two rows share its key. */
96
+ index(name: string, field: string | ReadonlyArray<string>, options?: {
97
+ readonly unique?: boolean;
98
+ }): Table;
99
+ /** A new table with a search index on a string field, with up to 16 filter fields; up to 4 a table. */
100
+ searchIndex(name: string, options: {
101
+ readonly searchField: string;
102
+ readonly filterFields?: ReadonlyArray<string>;
103
+ readonly staged?: boolean;
104
+ }): Table;
105
+ /** A new table with a vector index on a `v.array(v.number())` field of 2 to 4,096 numbers, with up to 16 filter fields; up to 4 a table. */
106
+ vectorIndex(name: string, options: {
107
+ readonly vectorField: string;
108
+ readonly dimensions: number;
109
+ readonly filterFields?: ReadonlyArray<string>;
110
+ readonly staged?: boolean;
111
+ }): Table;
112
+ }
113
+ interface Schema {
114
+ readonly schema: true;
115
+ readonly tables: Readonly<Record<string, Readonly<Record<string, Shape>>>>;
116
+ /** Every table's indexes, by name; a table with none has `{}`. */
117
+ readonly indexes: Readonly<Record<string, Readonly<Record<string, IndexDeclaration>>>>;
118
+ /** The search indexes of each table that has any, by name. */
119
+ readonly search: Readonly<Record<string, Readonly<Record<string, SearchIndex>>>>;
120
+ /** The vector indexes of each table that has any, by name. */
121
+ readonly vector: Readonly<Record<string, Readonly<Record<string, VectorIndex>>>>;
122
+ }
123
+ /** An index's fields in order. */
124
+ declare function indexFields(declared: IndexDeclaration): string[];
125
+ declare function defineTable(fields: Record<string, Shape>): Table;
126
+ declare function defineSchema(tables: Record<string, Table>): Schema;
127
+ /** Whether `value` fits `shape`: null, or the reason. An id fits only its own table (`isIdForm`). */
128
+ declare function shapeError(shape: Shape, value: unknown, at?: string): string | null;
129
+ //#endregion
130
+ //#region src/database/search.d.ts
131
+ /**
132
+ * A row's place in a search's ranking as it was read: its id, score and creation time, its rank key. The
133
+ * ranking is by score, then creation time (newest first), then id, so it is one order on every read.
134
+ * The Database compares each row's key now with the stored key and never moves the position to where its
135
+ * row ranks now, so the ranges of pinned pages split the ranking: a row may move between pages as scores
136
+ * change, but is never in two, and a deleted boundary row needs no lookup.
137
+ */
138
+ interface SearchPosition {
139
+ readonly id: string;
140
+ readonly score: number;
141
+ readonly created: number;
142
+ }
143
+ /**
144
+ * A vector search's filter: rows whose field holds any of these values (`undefined`: the field is
145
+ * missing). An empty list finds nothing; no filter at all is null.
146
+ */
147
+ type VectorFilter = ReadonlyArray<readonly [field: string, value: unknown]>;
148
+ /** What the Database gives an action to search a vector index with: best first. */
149
+ type VectorSearch = (table: string, index: string, query: {
150
+ readonly vector: ReadonlyArray<number>;
151
+ readonly limit: number;
152
+ readonly filter: VectorFilter | null;
153
+ }) => Promise<ReadonlyArray<{
154
+ readonly _id: string;
155
+ readonly _score: number;
156
+ }>>;
157
+ //#endregion
158
+ //#region src/database/server.d.ts
159
+ /** A row as the Database keeps it: its fields, and its own `_`-fields. */
160
+ type Row = Readonly<Record<string, unknown>>;
161
+ /** A row as a function reads it. */
162
+ type Document = Readonly<Record<string, unknown>> & {
163
+ readonly _id: string;
164
+ readonly _version: number;
165
+ readonly _creationTime: number;
166
+ };
167
+ /** A range's equality value or list of prefix values, bounds on the next field, order and limit. */
168
+ interface RangeOptions {
169
+ readonly eq?: unknown;
170
+ readonly gte?: unknown;
171
+ readonly gt?: unknown;
172
+ readonly lte?: unknown;
173
+ readonly lt?: unknown;
174
+ readonly order?: "asc" | "desc";
175
+ readonly limit?: number;
176
+ }
177
+ /** Bounds use the existing range frame's tuples, including equality prefixes. */
178
+ /**
179
+ * A range of an index: equality on its leading fields, bounds, an order and at most `limit` rows. With
180
+ * `bytes`, the Database stops once the rows it returns reach that many bytes (`documentBytes`): the row
181
+ * that reaches it is the last.
182
+ */
183
+ interface IndexBounds {
184
+ readonly eq?: ReadonlyArray<unknown>;
185
+ readonly gte?: ReadonlyArray<unknown>;
186
+ readonly gt?: ReadonlyArray<unknown>;
187
+ readonly lte?: ReadonlyArray<unknown>;
188
+ readonly lt?: ReadonlyArray<unknown>;
189
+ readonly order?: "asc" | "desc";
190
+ readonly limit: number;
191
+ readonly bytes?: number;
192
+ }
193
+ /** A scheduled run, as `ctx.scheduler.status` returns it. */
194
+ interface ScheduledRun {
195
+ readonly name: string;
196
+ readonly args: unknown;
197
+ readonly at: number;
198
+ readonly state: string;
199
+ readonly error?: string;
200
+ }
201
+ /**
202
+ * What a Database gives a query or mutation to run against: its rows, the caller and the call. The
203
+ * Stand-in is one such; the Database's engine is another. Every read returns at once.
204
+ */
205
+ interface Rows {
206
+ get(table: string, id: string): Row | null;
207
+ set(table: string, id: string, fields: Row): void;
208
+ delete(table: string, id: string): void;
209
+ /** The rows of `index` ("by_creation_time" for creation order, "_id" for id order) within the bounds, each with its `_id`. Bounds are lists, one value for each of the index's leading fields. */
210
+ range(table: string, index: string, options: IndexBounds): ReadonlyArray<Row & {
211
+ readonly _id: string;
212
+ }>;
213
+ /** The call's own time. */
214
+ readonly now: number;
215
+ /** The signed-in caller, by the Project's sign-in's subject; null for none. */
216
+ readonly user: string | null;
217
+ /** Whether the Project's own server code, or the Database itself, is the caller. */
218
+ readonly server: boolean;
219
+ /** The sign-in provider the Database trusts, when it trusts exactly one. */
220
+ readonly issuer?: string | null;
221
+ /**
222
+ * Every claim of the caller's token, once the Database has verified it against a provider it trusts
223
+ * (`iss`, `sub`, `aud`, `exp` and the rest, as the token carries them); null when the caller's token
224
+ * was not a provider's. Never set from a token that did not pass.
225
+ */
226
+ readonly claims?: Readonly<Record<string, unknown>> | null;
227
+ /** The call's identity: a mutation's inserted ids come from it, so a run again makes the same ids. */
228
+ readonly call?: string | null;
229
+ /** Whether another function is the caller, which may call internal ones. */
230
+ readonly internal?: boolean;
231
+ /** The host supplies table field types, including int64; null means no schema was loaded. */
232
+ readonly schema: Readonly<Record<string, Readonly<Record<string, Shape>>>> | null;
233
+ /** The host supplies the schema's index declarations; null means no schema was loaded. */
234
+ readonly indexes: Readonly<Record<string, Readonly<Record<string, IndexDeclaration>>>> | null;
235
+ /**
236
+ * The rows of a search index best matching `text`, in rank order (score, then creation time newest
237
+ * first, then id), among those whose `eq` fields hold those values (`undefined`: the field is missing,
238
+ * which null is not): those whose rank key now comes after `after`'s and not after `through`'s (each a
239
+ * stored `SearchPosition`; null: from the start, to the end), at most `limit`, each with its `_score`.
240
+ * None: the Database has no search.
241
+ */
242
+ search?(table: string, index: string, text: string, eq: Readonly<Record<string, unknown>>, limit: number, after?: SearchPosition | null, through?: SearchPosition | null): ReadonlyArray<Row & {
243
+ readonly _id: string;
244
+ readonly _score: number;
245
+ }>;
246
+ /** Each table's search indexes by name, so a search's names are checked before it runs; none: not checked here. */
247
+ readonly searchIndexes?: Readonly<Record<string, Readonly<Record<string, SearchIndex>>>> | null;
248
+ /**
249
+ * Runs another function of the Database inside this transaction, internal ones too: its `args` and
250
+ * answer checked and copied as a call's are, its reads seeing this transaction's writes, a
251
+ * mutation's writes joining them, and all it wrote undone if it throws, which then throws on. A
252
+ * query is given only queries. None: nested calls are refused.
253
+ */
254
+ runNested?(name: string, kind: "query" | "mutation", args: unknown): Promise<unknown>;
255
+ /**
256
+ * An id for a row this call inserts into `table`, as the Database mints it, new and of the id form (`ID_FORM`:
257
+ * its table's code, then base 36, 16 to 256 characters); one not of the form is refused. None: the SDK mints it.
258
+ */
259
+ newId?(table: string): string;
260
+ runAfter(ms: number, name: string, args: unknown): string;
261
+ scheduledRow(id: string): {
262
+ readonly name: string;
263
+ readonly args?: unknown;
264
+ readonly due: number;
265
+ readonly state: string;
266
+ readonly error?: string;
267
+ } | null;
268
+ cancelScheduled(id: string): boolean;
269
+ /** A stored file's URL, which anyone holding it may read; null when no file has the id. Absent: the Database keeps no files. */
270
+ fileUrl?(id: string): string | null;
271
+ /** In a mutation: a URL that takes one upload within an hour, made only if the mutation commits. */
272
+ uploadUrl?(): string;
273
+ /** In a mutation: the file deleted when the mutation commits. */
274
+ deleteFile?(id: string): void;
275
+ /** A stored file's metadata; null when no file has the id. Absent: the Database keeps no metadata. */
276
+ fileMetadata?(id: string): FileMetadata | null;
277
+ /** The tables that have rows, for a Database without a schema, so an id's table can be found from it. */
278
+ tables?(): ReadonlyArray<string>;
279
+ }
280
+ /** What the Database keeps about a stored file: Convex's `_storage` document, as `ctx.db.system.get(id)` returns it. `sha256` is the digest in base64. */
281
+ interface FileMetadata {
282
+ readonly sha256: string;
283
+ readonly size: number;
284
+ readonly contentType: string | null;
285
+ readonly creationTime: number;
286
+ }
287
+ /** A Database's files, as an action reaches them; a file's id is its storage id. */
288
+ interface Files {
289
+ store(bytes: Uint8Array, contentType: string): Promise<string>;
290
+ get(id: string): Promise<{
291
+ readonly bytes: Uint8Array;
292
+ readonly contentType: string;
293
+ } | null>;
294
+ delete(id: string): Promise<void>;
295
+ url(id: string): Promise<string | null>;
296
+ /** A URL that takes one upload within an hour. */
297
+ uploadUrl(): Promise<string>;
298
+ /** A stored file's metadata; null when no file has the id. Absent: the Database keeps no metadata. */
299
+ metadata?(id: string): Promise<FileMetadata | null>;
300
+ }
301
+ /** What a Database gives an action: reads that may wait, the network, and the other functions. */
302
+ interface Capabilities {
303
+ get(table: string, id: string): Promise<Row | null>;
304
+ range(table: string, index: string, options: Parameters<Rows["range"]>[2]): Promise<ReadonlyArray<Row & {
305
+ readonly _id: string;
306
+ }>>;
307
+ readonly user: string | null;
308
+ readonly server: boolean;
309
+ readonly issuer?: string | null;
310
+ readonly claims?: Readonly<Record<string, unknown>> | null;
311
+ readonly internal?: boolean;
312
+ fetch(url: URL, init?: RequestInit): Promise<Response>;
313
+ now(): number;
314
+ random(bytes: number): Uint8Array;
315
+ /** Calls another function as a call of its own, internal ones too; with `kind`, only a function of that kind, any other refused `no function`. */
316
+ run(name: string, args: unknown, kind?: FunctionKind): Promise<unknown>;
317
+ schedule(ms: number, name: string, args: unknown): Promise<string>;
318
+ scheduled(id: string): Promise<ScheduledRun | null>;
319
+ cancel(id: string): Promise<boolean>;
320
+ /** A vector index's nearest rows, best first, having seen every write committed before the call. None: the Database has no vector search. */
321
+ vectorSearch?: VectorSearch;
322
+ /** Each table's vector indexes, so a vector search is checked before it is sent; none: not checked here. */
323
+ readonly vectorIndexes?: Readonly<Record<string, Readonly<Record<string, VectorIndex>>>> | null;
324
+ /** Absent: the Database keeps no files. */
325
+ readonly files?: Files;
326
+ }
327
+ type FunctionKind = "query" | "mutation" | "action";
328
+ /** A function as defined: its name (none until it is exported under one), what runs it, and its options. */
329
+ interface RegisteredFunction {
330
+ readonly name: string | null;
331
+ readonly handler: (on: Rows & Capabilities, args: unknown) => unknown;
332
+ readonly options: {
333
+ readonly kind: FunctionKind;
334
+ readonly args: {
335
+ readonly object: Readonly<Record<string, Shape>>;
336
+ } | null;
337
+ readonly returns: Shape | null;
338
+ readonly internal: boolean;
339
+ readonly cron: string | null;
340
+ readonly http?: boolean;
341
+ };
342
+ }
343
+ /** A function's reference, as `api.<file>.<export>` holds it: its name and kind. */
344
+ interface FunctionReference<Kind extends FunctionKind = FunctionKind> {
345
+ readonly name: string;
346
+ readonly kind: Kind;
347
+ }
348
+ declare const OPERATOR: unique symbol;
349
+ interface Operator {
350
+ readonly [OPERATOR]: "increment" | "take" | "give";
351
+ readonly n: number;
352
+ }
353
+ /** A field's value plus `n` (a field not yet there counts as 0). */
354
+ declare const increment: (n?: number) => Operator;
355
+ /** A field's value minus `n`; below zero the whole mutation fails with `InsufficientError` and writes nothing. */
356
+ declare const take: (n?: number) => Operator;
357
+ /** A field's value plus `n`: the inverse of `take`. */
358
+ declare const give: (n?: number) => Operator;
359
+ /** A `take` asked for more than the field holds: the mutation wrote nothing. */
360
+ declare class InsufficientError extends Error {
361
+ readonly detail: {
362
+ readonly table: string;
363
+ readonly id: string;
364
+ readonly field: string;
365
+ readonly has: number;
366
+ readonly asked: number;
367
+ };
368
+ constructor(detail: {
369
+ readonly table: string;
370
+ readonly id: string;
371
+ readonly field: string;
372
+ readonly has: number;
373
+ readonly asked: number;
374
+ });
375
+ }
376
+ /** A mutation patched or replaced a row that is not there. */
377
+ declare class NotFoundError extends Error {
378
+ readonly detail: {
379
+ readonly table: string;
380
+ readonly id: string;
381
+ };
382
+ constructor(detail: {
383
+ readonly table: string;
384
+ readonly id: string;
385
+ });
386
+ }
387
+ /** A call the Database refused: `why` is its reason, as the client's `DatabaseError` carries it. */
388
+ declare class Refusal extends Error {
389
+ readonly why: string;
390
+ readonly detail?: unknown;
391
+ constructor(why: string, message: string, detail?: unknown);
392
+ }
393
+ /** Whether `id` is an id of `table` (`ID_FORM`, beginning with its table's code), as `ctx.db.normalizeId` checks it. */
394
+ declare const isIdOf: (table: string, id: unknown) => id is string;
395
+ type Definition = {
396
+ readonly args?: Record<string, Shape>;
397
+ readonly returns?: Shape;
398
+ readonly cron?: string;
399
+ readonly handler: (ctx: any, args: any) => unknown;
400
+ };
401
+ /**
402
+ * A signed-in caller, as `ctx.auth.getUserIdentity()` gives it: `tokenIdentifier` (`<issuer>|<subject>`, unique
403
+ * across providers), `subject` and `issuer`, the OIDC profile claims under the names Convex apps read, and every
404
+ * other claim of the token under its own name.
405
+ */
406
+ interface UserIdentity {
407
+ readonly tokenIdentifier: string;
408
+ readonly subject: string;
409
+ readonly issuer: string;
410
+ readonly name?: string;
411
+ readonly givenName?: string;
412
+ readonly familyName?: string;
413
+ readonly nickname?: string;
414
+ readonly preferredUsername?: string;
415
+ readonly profileUrl?: string;
416
+ readonly pictureUrl?: string;
417
+ readonly email?: string;
418
+ readonly emailVerified?: boolean;
419
+ readonly gender?: string;
420
+ readonly birthday?: string;
421
+ readonly timezone?: string;
422
+ readonly language?: string;
423
+ readonly phoneNumber?: string;
424
+ readonly phoneNumberVerified?: boolean;
425
+ readonly address?: string;
426
+ readonly updatedAt?: string;
427
+ readonly [claim: string]: unknown;
428
+ }
429
+ /** A function that reads rows and never writes them: `export const list = query({ args, returns, handler: (ctx, args) => ... })`. */
430
+ declare function query(name: string | Definition, given?: Definition, extra?: {
431
+ internal?: boolean;
432
+ }): RegisteredFunction;
433
+ /** One serializable transaction: `export const send = mutation({ args, returns, handler: (ctx, args) => ... })`. */
434
+ declare function mutation(name: string | Definition, given?: Definition, extra?: {
435
+ internal?: boolean;
436
+ }): RegisteredFunction;
437
+ /**
438
+ * The byte limits every Database keeps. A request to an HTTP action, or the body of a `Request` an
439
+ * action fetches, may be at most `httpBody` bytes: more is refused 413, or `invalid` in an action,
440
+ * before it is read whole. An HTTP action's response is at most `httpResponse`, as Convex caps it:
441
+ * past it, the caller gets a 500. What an action's fetch reads back is at most `fetchResponse`: more is refused
442
+ * `invalid`. A file is at most `fileBytes`.
443
+ */
444
+ declare const limits: Readonly<{
445
+ httpBody: number;
446
+ httpResponse: number;
447
+ fetchResponse: number;
448
+ fileBytes: number;
449
+ }>;
450
+ /** A body too large: `limit` was passed. */
451
+ declare class TooLarge extends Refusal {
452
+ readonly limit: number;
453
+ constructor(what: string, limit: number);
454
+ }
455
+ /** A body's bytes, read no further than `limit`: past it, `TooLarge`. */
456
+ declare function readLimited(body: ReadableStream<Uint8Array> | null, limit: number, what: string): Promise<Uint8Array<ArrayBuffer>>;
457
+ /**
458
+ * An action's fetch over `network`: a URL or a `Request`, https only, checked before any body is
459
+ * read. A body, a `Request`'s or one given in `init`, is read at most `limits.httpBody` bytes into it.
460
+ * What `ctx.fetch` is, and the global `fetch` of an action's module.
461
+ */
462
+ declare function fetchOver(network: (url: URL, init?: RequestInit) => Promise<Response>): (input: string | URL | Request, init?: RequestInit) => Promise<Response>;
463
+ /** May wait on the network: `export const charge = action({ args, returns, handler: async (ctx, args) => ... })`. */
464
+ declare function action(name: string | Definition, given?: Definition, extra?: {
465
+ internal?: boolean;
466
+ }): RegisteredFunction;
467
+ /** As `query`, callable only by another function, never a client. */
468
+ declare const internalQuery: (name: string | Definition, given?: Definition) => RegisteredFunction;
469
+ /** As `mutation`, callable only by another function, never a client. */
470
+ declare const internalMutation: (name: string | Definition, given?: Definition) => RegisteredFunction;
471
+ /** As `action`, callable only by another function, never a client. */
472
+ declare const internalAction: (name: string | Definition, given?: Definition) => RegisteredFunction;
473
+ /** Whether a value is a function defined here, as a module of `db/` exports it. */
474
+ declare const isFunction: (value: unknown) => value is RegisteredFunction;
475
+ /**
476
+ * An HTTP action: `httpAction(async (ctx, request) => new Response(...))`, reached through a route of
477
+ * `http.ts`'s router. Its `ctx` is an action's and `request` is the request as sent. Anyone may call
478
+ * it, so it checks its own callers; no client calls it as a function.
479
+ */
480
+ declare function httpAction(handler: (ctx: any, request: Request) => Response | Promise<Response>): RegisteredFunction;
481
+ /** The methods a route may take. A HEAD request takes a GET route. */
482
+ type HttpMethod = "GET" | "POST" | "PUT" | "PATCH" | "DELETE" | "OPTIONS";
483
+ /** One route: an exact `path`, or every path under a `pathPrefix` that ends in "/". */
484
+ type HttpRoute = ({
485
+ readonly path: string;
486
+ readonly pathPrefix?: undefined;
487
+ } | {
488
+ readonly pathPrefix: string;
489
+ readonly path?: undefined;
490
+ }) & {
491
+ readonly method: HttpMethod;
492
+ readonly handler: RegisteredFunction;
493
+ };
494
+ /**
495
+ * `http.ts`'s default export: the HTTP actions by method and path, under the Database's HTTP
496
+ * address. It has Convex's `HttpRouter` methods: `route`, `getRoutes` and `lookup`.
497
+ */
498
+ declare class HttpRouter {
499
+ #private;
500
+ readonly isRouter: true;
501
+ route(route: HttpRoute): void;
502
+ /** Each route as `[path, method, handler]`, a prefix's path ending in `*`. */
503
+ getRoutes(): ReadonlyArray<readonly [string, HttpMethod, RegisteredFunction]>;
504
+ /**
505
+ * The route a request takes, by its path under the Database's HTTP address, as `[handler, method,
506
+ * path]` (the route's path, a prefix's ending in `*`): an exact path first, then the longest prefix.
507
+ * HEAD takes a GET route.
508
+ */
509
+ lookup(path: string, method: string): readonly [RegisteredFunction, HttpMethod, string] | null;
510
+ }
511
+ /** A router for `http.ts`: `const http = httpRouter()`, its routes, then `export default http`. */
512
+ declare const httpRouter: () => HttpRouter;
513
+ /** Whether a value is `http.ts`'s router. */
514
+ declare const isRouter: (value: unknown) => value is HttpRouter;
515
+ /** Convex's `paginationOptsValidator`: a query's `paginationOpts` argument, as `usePaginatedQuery` sends it. */
516
+ declare const paginationOptsValidator: Shape;
517
+ /**
518
+ * A scheduled run of `crons.ts`: its name, its function and arguments, and either `cron`, a
519
+ * "minute hour day month weekday" expression in UTC, or `every`, an interval in milliseconds counted
520
+ * from when the Database starts its runs.
521
+ */
522
+ type CronJob = {
523
+ readonly name: string;
524
+ readonly function: string;
525
+ readonly args: unknown;
526
+ } & ({
527
+ readonly cron: string;
528
+ } | {
529
+ readonly every: number;
530
+ });
531
+ /**
532
+ * The first time after `after` (milliseconds) that a cron expression runs, in UTC. A day matches by
533
+ * day of the month or by weekday when both are given, as cron has it.
534
+ */
535
+ declare function nextCron(cron: string, after: number): number;
536
+ /** The schedule of one of Convex's `cronJobs()` calls: a cron expression, or an interval kept as one. */
537
+ declare function scheduleOf(kind: string, schedule: unknown): {
538
+ readonly cron: string;
539
+ } | {
540
+ readonly every: number;
541
+ };
542
+ /** `crons.ts`'s default export: the scheduled runs, made as Convex's `cronJobs()` makes them. */
543
+ declare class Crons {
544
+ #private;
545
+ readonly isCrons: true;
546
+ get jobs(): ReadonlyArray<CronJob>;
547
+ cron(name: string, cron: string, fn: unknown, args?: unknown): void;
548
+ hourly(name: string, schedule: {
549
+ minuteUTC: number;
550
+ }, fn: unknown, args?: unknown): void;
551
+ daily(name: string, schedule: {
552
+ hourUTC: number;
553
+ minuteUTC: number;
554
+ }, fn: unknown, args?: unknown): void;
555
+ weekly(name: string, schedule: {
556
+ dayOfWeek: string;
557
+ hourUTC: number;
558
+ minuteUTC: number;
559
+ }, fn: unknown, args?: unknown): void;
560
+ monthly(name: string, schedule: {
561
+ day: number;
562
+ hourUTC: number;
563
+ minuteUTC: number;
564
+ }, fn: unknown, args?: unknown): void;
565
+ interval(name: string, schedule: {
566
+ seconds?: number;
567
+ minutes?: number;
568
+ hours?: number;
569
+ }, fn: unknown, args?: unknown): void;
570
+ }
571
+ /** Convex's `cronJobs()`, for `crons.ts`: `const crons = cronJobs()`, its runs, then `export default crons`. */
572
+ declare const cronJobs: () => Crons;
573
+ //#endregion
574
+ export { VectorIndex as $, increment as A, paginationOptsValidator as B, UserIdentity as C, give as D, fetchOver as E, isIdOf as F, VectorFilter as G, readLimited as H, isRouter as I, IndexDeclaration as J, VectorSearch as K, limits as L, internalMutation as M, internalQuery as N, httpAction as O, isFunction as P, Table as Q, mutation as R, TooLarge as S, cronJobs as T, scheduleOf as U, query as V, take as W, SearchIndex as X, Schema as Y, Shape as Z, Refusal as _, FileMetadata as a, tableCode as at, Rows as b, FunctionReference as c, HttpRouter as d, defineSchema as et, IndexBounds as f, RangeOptions as g, Operator as h, Document as i, shapeError as it, internalAction as j, httpRouter as k, HttpMethod as l, NotFoundError as m, CronJob as n, indexFields as nt, Files as o, v as ot, InsufficientError as p, ID_FORM as q, Crons as r, isIdForm as rt, FunctionKind as s, Capabilities as t, defineTable as tt, HttpRoute as u, RegisteredFunction as v, action as w, ScheduledRun as x, Row as y, nextCron as z };