ovr 6.2.4 → 7.0.0-next.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 +3 -1
- package/dist/app/index.d.ts +51 -7
- package/dist/app/index.d.ts.map +1 -1
- package/dist/app/index.js +163 -28
- package/dist/auth/auth-data.d.ts +26 -0
- package/dist/auth/auth-data.d.ts.map +1 -0
- package/dist/auth/auth-data.js +42 -0
- package/dist/auth/cbor.d.ts +50 -0
- package/dist/auth/cbor.d.ts.map +1 -0
- package/dist/auth/cbor.js +200 -0
- package/dist/auth/client-source.d.ts +3 -0
- package/dist/auth/client-source.d.ts.map +1 -0
- package/dist/auth/client-source.js +3 -0
- package/dist/auth/client.d.ts +3 -0
- package/dist/auth/client.d.ts.map +1 -0
- package/dist/auth/client.js +186 -0
- package/dist/auth/configure.d.ts +28 -0
- package/dist/auth/configure.d.ts.map +1 -0
- package/dist/auth/configure.js +228 -0
- package/dist/auth/der.d.ts +6 -0
- package/dist/auth/der.d.ts.map +1 -0
- package/dist/auth/der.js +36 -0
- package/dist/auth/index.d.ts +242 -0
- package/dist/auth/index.d.ts.map +1 -0
- package/dist/auth/index.js +152 -0
- package/dist/auth/issue.d.ts +36 -0
- package/dist/auth/issue.d.ts.map +1 -0
- package/dist/auth/issue.js +47 -0
- package/dist/auth/metadata.d.ts +22 -0
- package/dist/auth/metadata.d.ts.map +1 -0
- package/dist/auth/metadata.js +134 -0
- package/dist/auth/oauth.d.ts +29 -0
- package/dist/auth/oauth.d.ts.map +1 -0
- package/dist/auth/oauth.js +724 -0
- package/dist/auth/passkey.d.ts +101 -0
- package/dist/auth/passkey.d.ts.map +1 -0
- package/dist/auth/passkey.js +393 -0
- package/dist/auth/state.d.ts +49 -0
- package/dist/auth/state.d.ts.map +1 -0
- package/dist/auth/state.js +184 -0
- package/dist/auth/storage.d.ts +193 -0
- package/dist/auth/storage.d.ts.map +1 -0
- package/dist/auth/storage.js +410 -0
- package/dist/auth/token.d.ts +12 -0
- package/dist/auth/token.d.ts.map +1 -0
- package/dist/auth/token.js +39 -0
- package/dist/context/index.d.ts +86 -16
- package/dist/context/index.d.ts.map +1 -1
- package/dist/context/index.js +166 -42
- package/dist/cookie/index.d.ts +3 -0
- package/dist/cookie/index.d.ts.map +1 -1
- package/dist/cookie/index.js +1 -0
- package/dist/database/index.d.ts +262 -0
- package/dist/database/index.d.ts.map +1 -0
- package/dist/database/index.js +807 -0
- package/dist/form/index.d.ts +699 -0
- package/dist/form/index.d.ts.map +1 -0
- package/dist/form/index.js +901 -0
- package/dist/index.d.ts +10 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +9 -3
- package/dist/jsx/elements.d.ts +28 -2
- package/dist/jsx/elements.d.ts.map +1 -1
- package/dist/jsx/index.d.ts +20 -4
- package/dist/jsx/index.d.ts.map +1 -1
- package/dist/jsx/index.js +6 -65
- package/dist/limiter/index.d.ts +65 -0
- package/dist/limiter/index.d.ts.map +1 -0
- package/dist/limiter/index.js +157 -0
- package/dist/markdown/index.d.ts +61 -0
- package/dist/markdown/index.d.ts.map +1 -0
- package/dist/markdown/index.js +1160 -0
- package/dist/markup/index.d.ts +188 -0
- package/dist/markup/index.d.ts.map +1 -0
- package/dist/markup/index.js +718 -0
- package/dist/mcp/index.d.ts +73 -0
- package/dist/mcp/index.d.ts.map +1 -0
- package/dist/mcp/index.js +988 -0
- package/dist/middleware/index.d.ts +3 -4
- package/dist/middleware/index.d.ts.map +1 -1
- package/dist/multipart/index.d.ts +53 -7
- package/dist/multipart/index.d.ts.map +1 -1
- package/dist/multipart/index.js +332 -124
- package/dist/route/index.d.ts +226 -80
- package/dist/route/index.d.ts.map +1 -1
- package/dist/route/index.js +239 -99
- package/dist/schema/index.d.ts +307 -734
- package/dist/schema/index.d.ts.map +1 -1
- package/dist/schema/index.js +783 -1050
- package/dist/table/index.d.ts +132 -0
- package/dist/table/index.d.ts.map +1 -0
- package/dist/table/index.js +188 -0
- package/dist/trie/index.js +4 -4
- package/dist/util/index.d.ts +37 -5
- package/dist/util/index.d.ts.map +1 -1
- package/dist/util/index.js +156 -41
- package/package.json +11 -4
- package/src/app/index.ts +230 -42
- package/src/auth/auth-data.ts +56 -0
- package/src/auth/cbor.ts +231 -0
- package/src/auth/client-source.ts +3 -0
- package/src/auth/client.ts +205 -0
- package/src/auth/configure.ts +279 -0
- package/src/auth/der.ts +35 -0
- package/src/auth/index.ts +387 -0
- package/src/auth/issue.ts +52 -0
- package/src/auth/metadata.ts +149 -0
- package/src/auth/oauth.ts +882 -0
- package/src/auth/passkey.ts +556 -0
- package/src/auth/state.ts +213 -0
- package/src/auth/storage.ts +572 -0
- package/src/auth/token.ts +67 -0
- package/src/context/index.ts +240 -65
- package/src/cookie/index.ts +3 -0
- package/src/database/index.ts +1193 -0
- package/src/form/index.ts +1720 -0
- package/src/index.ts +10 -3
- package/src/jsx/elements.ts +45 -25
- package/src/jsx/index.ts +24 -69
- package/src/limiter/index.ts +221 -0
- package/src/markdown/index.ts +1322 -0
- package/src/markup/index.ts +853 -0
- package/src/mcp/conformance.2025-11-25.yml +39 -0
- package/src/mcp/conformance.2026-07-28.yml +56 -0
- package/src/mcp/index.ts +1262 -0
- package/src/middleware/index.ts +5 -6
- package/src/multipart/index.ts +410 -158
- package/src/route/index.ts +559 -278
- package/src/schema/index.ts +1542 -2256
- package/src/table/index.ts +387 -0
- package/src/trie/index.ts +4 -4
- package/src/util/index.ts +163 -49
- package/dist/render/index.d.ts +0 -79
- package/dist/render/index.d.ts.map +0 -1
- package/dist/render/index.js +0 -257
- package/src/render/index.ts +0 -314
|
@@ -0,0 +1,387 @@
|
|
|
1
|
+
import { Schema, normalizers } from "../schema/index.js";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Internal protocol for `describe()`, to give the table it makes its
|
|
5
|
+
* description, which the constructor puts in the schema's definition.
|
|
6
|
+
*/
|
|
7
|
+
const described = Symbol("described");
|
|
8
|
+
|
|
9
|
+
/** Options of a table `describe()` makes */
|
|
10
|
+
type Described = { readonly [described]?: string };
|
|
11
|
+
|
|
12
|
+
export namespace Table {
|
|
13
|
+
/** Column schemas keyed by column name. */
|
|
14
|
+
export type Shape = Schema.Object.Shape;
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Column name of a shape.
|
|
18
|
+
*
|
|
19
|
+
* @template S Table shape
|
|
20
|
+
*/
|
|
21
|
+
export type Key<S extends Shape> = Extract<keyof S, string>;
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Postgres schema and the columns the database supplies.
|
|
25
|
+
*
|
|
26
|
+
* @template S Table shape
|
|
27
|
+
*/
|
|
28
|
+
export interface Options<S extends Shape = Shape> {
|
|
29
|
+
/** Schema containing the table, defaults to the connection's search path. */
|
|
30
|
+
readonly schema?: string;
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Columns that may be omitted on insert because the database supplies a
|
|
34
|
+
* value, with a `DEFAULT`, identity, or generated column.
|
|
35
|
+
*/
|
|
36
|
+
readonly default?: readonly Key<S>[];
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/** Any table. */
|
|
40
|
+
export type Any = Table<string, any, any>;
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Columns whose value may be left out, as with `optional()`, which a row
|
|
44
|
+
* read from the database always has.
|
|
45
|
+
*
|
|
46
|
+
* @template S Table shape
|
|
47
|
+
*/
|
|
48
|
+
export type Omissible<S extends Shape> = {
|
|
49
|
+
[K in keyof S]: undefined extends Schema.Infer<S[K]>
|
|
50
|
+
? unknown extends Schema.Infer<S[K]>
|
|
51
|
+
? never
|
|
52
|
+
: K
|
|
53
|
+
: never;
|
|
54
|
+
}[keyof S];
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* A name Postgres can quote: not empty and without a NUL character.
|
|
58
|
+
*
|
|
59
|
+
* @template N Table, schema, or column name
|
|
60
|
+
*/
|
|
61
|
+
export type Identifier<N extends string> = N extends
|
|
62
|
+
"" | `${string}\0${string}`
|
|
63
|
+
? never
|
|
64
|
+
: N;
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Row returned from the table.
|
|
68
|
+
*
|
|
69
|
+
* @template S Table shape
|
|
70
|
+
*/
|
|
71
|
+
export type Row<S extends Shape> = { [K in keyof S]: Schema.Infer<S[K]> };
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Column names that may be omitted from an insert: nullable or supplied by the database.
|
|
75
|
+
*
|
|
76
|
+
* @template S Table shape
|
|
77
|
+
* @template O Table options
|
|
78
|
+
*/
|
|
79
|
+
export type Defaulted<S extends Shape, O extends Options<S>> =
|
|
80
|
+
| Extract<NonNullable<O["default"]>[number], Key<S>>
|
|
81
|
+
| {
|
|
82
|
+
[K in Key<S>]: unknown extends Schema.Infer<S[K]>
|
|
83
|
+
? never // unknown columns store JSON null, so they are NOT NULL
|
|
84
|
+
: null extends Schema.Infer<S[K]>
|
|
85
|
+
? K
|
|
86
|
+
: never;
|
|
87
|
+
}[Key<S>];
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* Values accepted by `sql.values` for one row.
|
|
91
|
+
*
|
|
92
|
+
* @template S Table shape
|
|
93
|
+
* @template O Table options
|
|
94
|
+
*/
|
|
95
|
+
export type Insert<S extends Shape, O extends Options<S>> = {
|
|
96
|
+
[K in Exclude<Key<S>, Defaulted<S, O>>]: Schema.Infer<S[K]>;
|
|
97
|
+
} & { [K in Defaulted<S, O>]?: Schema.Infer<S[K]> };
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* Values accepted by `sql.set`.
|
|
101
|
+
*
|
|
102
|
+
* @template S Table shape
|
|
103
|
+
*/
|
|
104
|
+
export type Update<S extends Shape> = Partial<Row<S>>;
|
|
105
|
+
|
|
106
|
+
/** Kind of value a column stores, each compatible with several Postgres types. */
|
|
107
|
+
export type Type =
|
|
108
|
+
"string" | "number" | "bigint" | "boolean" | "date" | "json";
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
/** Reference to one column, interpolated by `sql` as a qualified identifier. */
|
|
112
|
+
export class Column {
|
|
113
|
+
/** Table containing the column. */
|
|
114
|
+
readonly table: Table.Any;
|
|
115
|
+
|
|
116
|
+
/** Column name. */
|
|
117
|
+
readonly name: string;
|
|
118
|
+
|
|
119
|
+
/** Kind of value derived from the column schema. */
|
|
120
|
+
readonly type: Table.Type;
|
|
121
|
+
|
|
122
|
+
/** If the column allows `NULL`. */
|
|
123
|
+
readonly nullable: boolean;
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* @param table Table containing the column
|
|
127
|
+
* @param name Column name
|
|
128
|
+
* @param type Kind of value
|
|
129
|
+
* @param nullable If the column allows `NULL`
|
|
130
|
+
*/
|
|
131
|
+
constructor(
|
|
132
|
+
table: Table.Any,
|
|
133
|
+
name: string,
|
|
134
|
+
type: Table.Type,
|
|
135
|
+
nullable: boolean,
|
|
136
|
+
) {
|
|
137
|
+
this.table = table;
|
|
138
|
+
this.name = name;
|
|
139
|
+
this.type = type;
|
|
140
|
+
this.nullable = nullable;
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
/**
|
|
145
|
+
* Postgres table defined with validation schemas.
|
|
146
|
+
*
|
|
147
|
+
* The table is a schema of its rows, so `Schema.Infer<typeof table>` is the
|
|
148
|
+
* row type and `sql.parse(table)` validates returned rows. Keys, constraints, and
|
|
149
|
+
* indexes belong in migrations.
|
|
150
|
+
*
|
|
151
|
+
* @template Name Table name
|
|
152
|
+
* @template S Column schemas
|
|
153
|
+
* @template O Table options
|
|
154
|
+
*/
|
|
155
|
+
export class Table<
|
|
156
|
+
Name extends string,
|
|
157
|
+
S extends Table.Shape,
|
|
158
|
+
const O extends Table.Options<S> = {},
|
|
159
|
+
> extends Schema<Table.Row<S>> {
|
|
160
|
+
/** Table name. */
|
|
161
|
+
readonly name: Name;
|
|
162
|
+
|
|
163
|
+
/** Column schemas. */
|
|
164
|
+
readonly shape: S;
|
|
165
|
+
|
|
166
|
+
/** Postgres schema and the columns the database supplies. */
|
|
167
|
+
readonly options: O;
|
|
168
|
+
|
|
169
|
+
/** Column references for `sql`. */
|
|
170
|
+
readonly columns: { readonly [K in keyof S]: Column };
|
|
171
|
+
|
|
172
|
+
/**
|
|
173
|
+
* Define a table.
|
|
174
|
+
*
|
|
175
|
+
* @param name Table name
|
|
176
|
+
* @param shape Column schemas
|
|
177
|
+
* @param options Postgres schema and the columns the database supplies
|
|
178
|
+
*/
|
|
179
|
+
constructor(
|
|
180
|
+
name: Table.Identifier<Name>,
|
|
181
|
+
// every column's name is quoted as an identifier too
|
|
182
|
+
shape: S &
|
|
183
|
+
([Extract<keyof S, string>] extends [
|
|
184
|
+
Table.Identifier<Extract<keyof S, string>>,
|
|
185
|
+
]
|
|
186
|
+
? unknown
|
|
187
|
+
: "Column names cannot be empty or hold a NUL character") &
|
|
188
|
+
([Table.Omissible<S>] extends [never]
|
|
189
|
+
? unknown
|
|
190
|
+
: `Column ${Extract<Table.Omissible<S>, string>} can be left out: use nullable() or the default option, not optional()`),
|
|
191
|
+
options = {} as O &
|
|
192
|
+
(O["schema"] extends string
|
|
193
|
+
? [Table.Identifier<O["schema"]>] extends [never]
|
|
194
|
+
? "A schema name cannot be empty or hold a NUL character"
|
|
195
|
+
: unknown
|
|
196
|
+
: unknown),
|
|
197
|
+
) {
|
|
198
|
+
const description = (options as Described)[described];
|
|
199
|
+
|
|
200
|
+
super({
|
|
201
|
+
type: "object",
|
|
202
|
+
shape,
|
|
203
|
+
mode: "strip",
|
|
204
|
+
...(description !== undefined && { description }),
|
|
205
|
+
});
|
|
206
|
+
|
|
207
|
+
this.name = name;
|
|
208
|
+
this.shape = shape;
|
|
209
|
+
this.options = options;
|
|
210
|
+
|
|
211
|
+
const columns: Record<string, Column> = {};
|
|
212
|
+
|
|
213
|
+
for (const [key, schema] of Object.entries(shape)) {
|
|
214
|
+
const [type, nullable] = Table.#type(schema.def, `${name}.${key}`);
|
|
215
|
+
|
|
216
|
+
columns[key] = new Column(this, key, type, nullable);
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
this.columns = columns as { readonly [K in keyof S]: Column };
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
override describe(text: string) {
|
|
223
|
+
// still a table, which `derive` would not make, with the names and
|
|
224
|
+
// columns checked when this one was made
|
|
225
|
+
return new Table(
|
|
226
|
+
this.name as never,
|
|
227
|
+
this.shape as never,
|
|
228
|
+
{ ...this.options, [described]: text } as never,
|
|
229
|
+
) as unknown as this;
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
/**
|
|
233
|
+
* Map a column definition to the kind of value it stores.
|
|
234
|
+
*
|
|
235
|
+
* @param def Column schema definition
|
|
236
|
+
* @param column Column label for errors
|
|
237
|
+
* @returns Kind of value and nullability
|
|
238
|
+
*/
|
|
239
|
+
static #type(
|
|
240
|
+
def: Schema.Def,
|
|
241
|
+
column: string,
|
|
242
|
+
): [type: Table.Type, nullable: boolean] {
|
|
243
|
+
switch (def.type) {
|
|
244
|
+
case "string":
|
|
245
|
+
case "boolean":
|
|
246
|
+
case "number":
|
|
247
|
+
case "bigint":
|
|
248
|
+
case "date":
|
|
249
|
+
return [def.type, false];
|
|
250
|
+
case "unknown":
|
|
251
|
+
case "object":
|
|
252
|
+
case "array":
|
|
253
|
+
Table.#json(def, column);
|
|
254
|
+
|
|
255
|
+
return ["json", false];
|
|
256
|
+
case "literal":
|
|
257
|
+
case "enum": {
|
|
258
|
+
const kinds = new Set(
|
|
259
|
+
(def.type === "literal" ? [def.value] : def.values).map(
|
|
260
|
+
(value) => typeof value,
|
|
261
|
+
),
|
|
262
|
+
);
|
|
263
|
+
const [kind] = kinds;
|
|
264
|
+
|
|
265
|
+
if (
|
|
266
|
+
kinds.size === 1 &&
|
|
267
|
+
(kind === "string" || kind === "boolean" || kind === "number")
|
|
268
|
+
)
|
|
269
|
+
return [kind, false];
|
|
270
|
+
|
|
271
|
+
break;
|
|
272
|
+
}
|
|
273
|
+
case "nullable":
|
|
274
|
+
return [Table.#type(def.inner.def, column)[0], true];
|
|
275
|
+
case "check":
|
|
276
|
+
return Table.#type(def.inner.def, column);
|
|
277
|
+
case "preprocess":
|
|
278
|
+
// form fields normalize their input, a stored value parses unchanged
|
|
279
|
+
if (normalizers.has(def.fn)) return Table.#type(def.inner.def, column);
|
|
280
|
+
|
|
281
|
+
throw Table.#invalid(
|
|
282
|
+
column,
|
|
283
|
+
`preprocess() would change stored values when they are read, convert before inserting instead`,
|
|
284
|
+
);
|
|
285
|
+
case "json":
|
|
286
|
+
throw Table.#invalid(
|
|
287
|
+
column,
|
|
288
|
+
`use the parsed object or array schema for JSON instead of json()`,
|
|
289
|
+
);
|
|
290
|
+
// optional() and nullish() are type errors, see `Table.Omissible`
|
|
291
|
+
case "default":
|
|
292
|
+
throw Table.#invalid(
|
|
293
|
+
column,
|
|
294
|
+
`use nullable() or the default option instead of ${def.type}()`,
|
|
295
|
+
);
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
throw Table.#invalid(
|
|
299
|
+
column,
|
|
300
|
+
`${def.type} schemas cannot be stored as a column`,
|
|
301
|
+
);
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
/**
|
|
305
|
+
* @param column Column label
|
|
306
|
+
* @param problem What is wrong with the column's schema
|
|
307
|
+
* @returns Error for a column schema the table cannot store
|
|
308
|
+
*/
|
|
309
|
+
static #invalid(column: string, problem: string) {
|
|
310
|
+
return new TypeError(`Table ${column}: ${problem}`);
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
/**
|
|
314
|
+
* Ensure values stored as JSON parse again when read.
|
|
315
|
+
*
|
|
316
|
+
* @param def Schema definition inside a JSON column
|
|
317
|
+
* @param column Column label for errors
|
|
318
|
+
*/
|
|
319
|
+
static #json(def: Schema.Def, column: string): void {
|
|
320
|
+
switch (def.type) {
|
|
321
|
+
case "unknown":
|
|
322
|
+
case "string":
|
|
323
|
+
case "boolean":
|
|
324
|
+
case "number":
|
|
325
|
+
// stored as an ISO string, read back as a date by the table's schema
|
|
326
|
+
case "date":
|
|
327
|
+
return;
|
|
328
|
+
case "literal":
|
|
329
|
+
case "enum":
|
|
330
|
+
if (
|
|
331
|
+
(def.type === "literal" ? [def.value] : def.values).every(
|
|
332
|
+
(value) =>
|
|
333
|
+
value === null ||
|
|
334
|
+
["string", "number", "boolean", "undefined"].includes(
|
|
335
|
+
typeof value,
|
|
336
|
+
),
|
|
337
|
+
)
|
|
338
|
+
)
|
|
339
|
+
return;
|
|
340
|
+
|
|
341
|
+
break;
|
|
342
|
+
case "array": {
|
|
343
|
+
const empty = def.item.parse(undefined);
|
|
344
|
+
|
|
345
|
+
// JSON stores undefined items as null, which must parse again
|
|
346
|
+
if (
|
|
347
|
+
!empty.issues &&
|
|
348
|
+
empty.data === undefined &&
|
|
349
|
+
def.item.parse(null).issues
|
|
350
|
+
)
|
|
351
|
+
throw Table.#invalid(
|
|
352
|
+
column,
|
|
353
|
+
`JSON stores undefined array items as null, allow null instead of undefined`,
|
|
354
|
+
);
|
|
355
|
+
|
|
356
|
+
return Table.#json(def.item.def, column);
|
|
357
|
+
}
|
|
358
|
+
case "object":
|
|
359
|
+
for (const schema of Object.values(def.shape)) {
|
|
360
|
+
Table.#json(schema.def, column);
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
return;
|
|
364
|
+
case "union":
|
|
365
|
+
for (const schema of def.options) {
|
|
366
|
+
Table.#json(schema.def, column);
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
return;
|
|
370
|
+
case "pipe":
|
|
371
|
+
Table.#json(def.inner.def, column);
|
|
372
|
+
|
|
373
|
+
return Table.#json(def.next.def, column);
|
|
374
|
+
case "optional":
|
|
375
|
+
case "nullable":
|
|
376
|
+
case "nullish":
|
|
377
|
+
case "default":
|
|
378
|
+
case "check":
|
|
379
|
+
return Table.#json(def.inner.def, column);
|
|
380
|
+
}
|
|
381
|
+
|
|
382
|
+
throw Table.#invalid(
|
|
383
|
+
column,
|
|
384
|
+
`${def.type} schemas cannot be stored in JSON`,
|
|
385
|
+
);
|
|
386
|
+
}
|
|
387
|
+
}
|
package/src/trie/index.ts
CHANGED
|
@@ -41,8 +41,8 @@ export class Trie {
|
|
|
41
41
|
/** Matched wildcard route */
|
|
42
42
|
wild: Route | undefined;
|
|
43
43
|
|
|
44
|
-
|
|
45
|
-
static readonly #
|
|
44
|
+
/** A parameter, `split` ignores the global flag `match` needs */
|
|
45
|
+
static readonly #param = /:.+?(?=\/|$)/g;
|
|
46
46
|
|
|
47
47
|
/**
|
|
48
48
|
* Create a new trie.
|
|
@@ -144,8 +144,8 @@ export class Trie {
|
|
|
144
144
|
const endsWithWildcard = pattern.endsWith("*");
|
|
145
145
|
if (endsWithWildcard) pattern = pattern.slice(0, -1);
|
|
146
146
|
|
|
147
|
-
const paramSegments = pattern.match(Trie.#
|
|
148
|
-
const staticSegments = pattern.split(Trie.#
|
|
147
|
+
const paramSegments = pattern.match(Trie.#param) ?? [];
|
|
148
|
+
const staticSegments = pattern.split(Trie.#param);
|
|
149
149
|
|
|
150
150
|
// if the last segment is a param without a trailing slash
|
|
151
151
|
// then there will be an empty string, remove
|