@guren/server 2.8.0 → 2.10.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/dist/{chunk-JTNRAWQR.js → chunk-SQR7277M.js} +1 -0
- package/dist/{chunk-4BUZXYGV.js → chunk-VSA3QY5Q.js} +2 -2
- package/dist/database/Seeder.d.ts +38 -0
- package/dist/database/SeederRunner.d.ts +17 -0
- package/dist/database/types.d.ts +14 -0
- package/dist/discovery/AutoDiscovery.d.ts +8 -0
- package/dist/http/Application.d.ts +0 -1
- package/dist/index.js +38 -28
- package/dist/runtime/index.js +16 -2
- package/dist/storage/index.js +1 -1
- package/package.json +2 -2
|
@@ -6,7 +6,7 @@ import standard from "figlet/importable-fonts/Standard.js";
|
|
|
6
6
|
// package.json
|
|
7
7
|
var package_default = {
|
|
8
8
|
name: "@guren/server",
|
|
9
|
-
version: "2.
|
|
9
|
+
version: "2.10.0",
|
|
10
10
|
type: "module",
|
|
11
11
|
license: "MIT",
|
|
12
12
|
repository: {
|
|
@@ -119,7 +119,7 @@ var package_default = {
|
|
|
119
119
|
test: "bun test"
|
|
120
120
|
},
|
|
121
121
|
dependencies: {
|
|
122
|
-
"@guren/orm": "^2.
|
|
122
|
+
"@guren/orm": "^2.6.0",
|
|
123
123
|
"@modelcontextprotocol/sdk": "^1.30.0",
|
|
124
124
|
chalk: "^5.3.0",
|
|
125
125
|
consola: "^3.4.2",
|
|
@@ -1,18 +1,53 @@
|
|
|
1
1
|
import type { SeederClass } from './types.js';
|
|
2
2
|
/**
|
|
3
3
|
* Reset called seeders tracking (for testing).
|
|
4
|
+
*
|
|
5
|
+
* @deprecated Bookkeeping for {@link BaseSeeder}'s `callOnce`. Write seeders
|
|
6
|
+
* with `defineSeeder` from `@guren/core` instead, which needs no such
|
|
7
|
+
* tracking. Deprecated in 2.9.0, removed in 3.0.0.
|
|
4
8
|
*/
|
|
5
9
|
export declare function resetCalledSeeders(): void;
|
|
6
10
|
/**
|
|
7
11
|
* Abstract base class for database seeders.
|
|
12
|
+
*
|
|
13
|
+
* @deprecated Write seeders with `defineSeeder` from `@guren/core` instead.
|
|
14
|
+
* Deprecated in 2.9.0, removed in 3.0.0.
|
|
15
|
+
*
|
|
16
|
+
* A seeder class is not itself the problem: `db:seed` loads every seeder
|
|
17
|
+
* through `runSeeders()`, which does accept an exported class whose prototype
|
|
18
|
+
* has a `run` method, constructs it, and calls `run({ db })`. What this base
|
|
19
|
+
* class gets wrong is the signature it imposes on that method. `run()` is
|
|
20
|
+
* declared to take no parameters, so it hides the one argument a seeder
|
|
21
|
+
* needs.
|
|
22
|
+
*
|
|
23
|
+
* A subclass cannot simply correct that: declaring `run(ctx: SeederContext)`
|
|
24
|
+
* fails to compile against the base (`TS2416: Target signature provides too
|
|
25
|
+
* few arguments. Expected 1 or more, but got 0`). Widening it to an optional
|
|
26
|
+
* `run(ctx?: SeederContext)` does compile, but then the subclass has to handle
|
|
27
|
+
* a missing context — and that case is real, because
|
|
28
|
+
* {@link BaseSeeder.call}, {@link BaseSeeder.callOnce},
|
|
29
|
+
* {@link BaseSeeder.callMany} and {@link BaseSeeder.callParallel} construct
|
|
30
|
+
* child seeders and invoke `run()` with no arguments at all. A parent that
|
|
31
|
+
* received a context cannot pass it down.
|
|
32
|
+
*
|
|
33
|
+
* The orchestration these classes were written for, `SeederRunner`, is
|
|
34
|
+
* reached by no Guren command.
|
|
8
35
|
*/
|
|
9
36
|
export declare abstract class BaseSeeder {
|
|
37
|
+
constructor();
|
|
10
38
|
/**
|
|
11
39
|
* Run the seeder.
|
|
40
|
+
*
|
|
41
|
+
* Declared without parameters, which is what makes this class the wrong
|
|
42
|
+
* base: `runSeeders()` calls it with a `{ db }` context that this signature
|
|
43
|
+
* cannot name.
|
|
12
44
|
*/
|
|
13
45
|
abstract run(): Promise<void>;
|
|
14
46
|
/**
|
|
15
47
|
* Call another seeder.
|
|
48
|
+
*
|
|
49
|
+
* No context is forwarded: the child's `run()` is invoked with no
|
|
50
|
+
* arguments, whatever the caller itself received.
|
|
16
51
|
*/
|
|
17
52
|
protected call(SeederClass: SeederClass): Promise<void>;
|
|
18
53
|
/**
|
|
@@ -31,5 +66,8 @@ export declare abstract class BaseSeeder {
|
|
|
31
66
|
}
|
|
32
67
|
/**
|
|
33
68
|
* Alias for BaseSeeder.
|
|
69
|
+
*
|
|
70
|
+
* @deprecated Write seeders with `defineSeeder` from `@guren/core` instead.
|
|
71
|
+
* Deprecated in 2.9.0, removed in 3.0.0. See {@link BaseSeeder}.
|
|
34
72
|
*/
|
|
35
73
|
export { BaseSeeder as Seeder };
|
|
@@ -1,6 +1,19 @@
|
|
|
1
1
|
import type { SeederClass, SeederRunnerOptions } from './types.js';
|
|
2
2
|
/**
|
|
3
3
|
* Seeder runner for executing database seeders.
|
|
4
|
+
*
|
|
5
|
+
* @deprecated No Guren command reaches this runner. Write seeders with
|
|
6
|
+
* `defineSeeder` from `@guren/core` and run them with `db:seed`. Deprecated
|
|
7
|
+
* in 2.9.0, removed in 3.0.0.
|
|
8
|
+
*
|
|
9
|
+
* `db:seed` seeds by loading the seeders folder through `runSeeders()`, which
|
|
10
|
+
* runs every seeder it finds there and hands each one a `{ db }` context. This
|
|
11
|
+
* runner orchestrates differently: it runs a single seeder per call, taken
|
|
12
|
+
* from a class passed in, a name registered with {@link SeederRunner.register},
|
|
13
|
+
* or a name resolved to `<seedersPath>/<Name>.ts` and defaulting to
|
|
14
|
+
* `DatabaseSeeder`; it constructs it with `new` and invokes `.run()` with no
|
|
15
|
+
* context. Nothing in the framework calls any of it. See {@link BaseSeeder}
|
|
16
|
+
* for what the no-context `run()` costs a seeder written against it.
|
|
4
17
|
*/
|
|
5
18
|
export declare class SeederRunner {
|
|
6
19
|
private options;
|
|
@@ -37,5 +50,9 @@ export declare class SeederRunner {
|
|
|
37
50
|
}
|
|
38
51
|
/**
|
|
39
52
|
* Create a seeder runner.
|
|
53
|
+
*
|
|
54
|
+
* @deprecated No Guren command reaches this runner. Write seeders with
|
|
55
|
+
* `defineSeeder` from `@guren/core` instead. Deprecated in 2.9.0, removed in
|
|
56
|
+
* 3.0.0. See {@link SeederRunner}.
|
|
40
57
|
*/
|
|
41
58
|
export declare function createSeederRunner(options?: SeederRunnerOptions): SeederRunner;
|
package/dist/database/types.d.ts
CHANGED
|
@@ -1,11 +1,21 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Seeder class interface.
|
|
3
|
+
*
|
|
4
|
+
* @deprecated The constructor shape `BaseSeeder` and `SeederRunner` expect.
|
|
5
|
+
* Write seeders with `defineSeeder` from `@guren/core` instead. Deprecated in
|
|
6
|
+
* 2.9.0, removed in 3.0.0.
|
|
3
7
|
*/
|
|
4
8
|
export interface SeederClass {
|
|
5
9
|
new (): Seeder;
|
|
6
10
|
}
|
|
7
11
|
/**
|
|
8
12
|
* Abstract seeder interface.
|
|
13
|
+
*
|
|
14
|
+
* Exported from the package root as `SeederInterface`.
|
|
15
|
+
*
|
|
16
|
+
* @deprecated The no-context `run()` shape `BaseSeeder` imposes. Write seeders
|
|
17
|
+
* with `defineSeeder` from `@guren/core` instead, whose handler is typed to
|
|
18
|
+
* receive `{ db }`. Deprecated in 2.9.0, removed in 3.0.0.
|
|
9
19
|
*/
|
|
10
20
|
export interface Seeder {
|
|
11
21
|
run(): Promise<void>;
|
|
@@ -28,6 +38,10 @@ export interface Factory<T> {
|
|
|
28
38
|
}
|
|
29
39
|
/**
|
|
30
40
|
* Seeder runner options.
|
|
41
|
+
*
|
|
42
|
+
* @deprecated Options for `SeederRunner`, which no Guren command reaches.
|
|
43
|
+
* Write seeders with `defineSeeder` from `@guren/core` and run them with
|
|
44
|
+
* `db:seed`. Deprecated in 2.9.0, removed in 3.0.0.
|
|
31
45
|
*/
|
|
32
46
|
export interface SeederRunnerOptions {
|
|
33
47
|
/**
|
|
@@ -33,6 +33,14 @@ export interface DiscoveryResult {
|
|
|
33
33
|
* Auto-discovery engine that scans application directories and discovers
|
|
34
34
|
* framework components (providers, listeners, jobs, events).
|
|
35
35
|
*
|
|
36
|
+
* Standalone by design: nothing in `Application` runs this scan, so
|
|
37
|
+
* registration stays explicit — `createApp({ providers: [...] })`, and
|
|
38
|
+
* `defineModule` lists for modules — which is what `guren check` verifies
|
|
39
|
+
* and what bundle-deploy targets (Workers, Vercel, Lambda) require, since a
|
|
40
|
+
* runtime directory scan finds nothing in a bundle. A caller that wants
|
|
41
|
+
* discovery runs the scan itself and feeds each result into the matching
|
|
42
|
+
* registry, as the example below does.
|
|
43
|
+
*
|
|
36
44
|
* Uses `Bun.Glob` to scan directories and dynamic `import()` to load modules.
|
|
37
45
|
*
|
|
38
46
|
* @example
|
|
@@ -72,7 +72,6 @@ export interface ApplicationOptions {
|
|
|
72
72
|
* is registered automatically.
|
|
73
73
|
*/
|
|
74
74
|
readonly i18n?: I18nPluginOptions;
|
|
75
|
-
readonly discover?: boolean;
|
|
76
75
|
readonly routes?: RouteRegistration;
|
|
77
76
|
/**
|
|
78
77
|
* Application modules (RFC 0002) — each module's providers are appended
|
package/dist/index.js
CHANGED
|
@@ -5,7 +5,7 @@ import {
|
|
|
5
5
|
logDevServerBanner,
|
|
6
6
|
parseImportMap,
|
|
7
7
|
startViteDevServer
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-VSA3QY5Q.js";
|
|
9
9
|
import {
|
|
10
10
|
PendingSchedule,
|
|
11
11
|
Schedule,
|
|
@@ -25,8 +25,9 @@ import {
|
|
|
25
25
|
MemoryDriver as MemoryDriver3,
|
|
26
26
|
S3Driver,
|
|
27
27
|
StorageManager,
|
|
28
|
-
createStorageManager
|
|
29
|
-
|
|
28
|
+
createStorageManager,
|
|
29
|
+
warnOnce
|
|
30
|
+
} from "./chunk-SQR7277M.js";
|
|
30
31
|
import {
|
|
31
32
|
trimSlashes
|
|
32
33
|
} from "./chunk-AZOYI43J.js";
|
|
@@ -220,6 +221,14 @@ import {
|
|
|
220
221
|
AuthenticationException,
|
|
221
222
|
HttpException
|
|
222
223
|
} from "./chunk-DAQKYKLH.js";
|
|
224
|
+
import {
|
|
225
|
+
CacheManager,
|
|
226
|
+
FileStore,
|
|
227
|
+
MemoryStore,
|
|
228
|
+
RedisStore,
|
|
229
|
+
TaggedCache,
|
|
230
|
+
createCacheManager
|
|
231
|
+
} from "./chunk-HPET6XY5.js";
|
|
223
232
|
import {
|
|
224
233
|
BroadcastManager,
|
|
225
234
|
Channel,
|
|
@@ -235,14 +244,6 @@ import {
|
|
|
235
244
|
parseRequestPayload,
|
|
236
245
|
setBroadcastManager
|
|
237
246
|
} from "./chunk-DRNPVBAA.js";
|
|
238
|
-
import {
|
|
239
|
-
CacheManager,
|
|
240
|
-
FileStore,
|
|
241
|
-
MemoryStore,
|
|
242
|
-
RedisStore,
|
|
243
|
-
TaggedCache,
|
|
244
|
-
createCacheManager
|
|
245
|
-
} from "./chunk-HPET6XY5.js";
|
|
246
247
|
import {
|
|
247
248
|
claimHotDisposable,
|
|
248
249
|
isHotReloadRuntime,
|
|
@@ -770,7 +771,7 @@ function substituteParams(path, params) {
|
|
|
770
771
|
}
|
|
771
772
|
function createContractHandler(path, options, handler) {
|
|
772
773
|
return async (ctx) => {
|
|
773
|
-
const params = parseRouteSegment(options.params, ctx.req.param(),
|
|
774
|
+
const params = parseRouteSegment(options.params, ctx.req.param(), 422);
|
|
774
775
|
if (params instanceof Response) {
|
|
775
776
|
return params;
|
|
776
777
|
}
|
|
@@ -843,6 +844,12 @@ function validationErrorResponse(error, status) {
|
|
|
843
844
|
headers: { "Content-Type": "application/json; charset=utf-8" }
|
|
844
845
|
});
|
|
845
846
|
}
|
|
847
|
+
function throwOnInvalid(schema, data) {
|
|
848
|
+
const result = schema.safeParse(data);
|
|
849
|
+
if (!result.success) {
|
|
850
|
+
throw ValidationException.withMessages(formatValidationErrors(result.error));
|
|
851
|
+
}
|
|
852
|
+
}
|
|
846
853
|
function createContractValidationMiddleware(route) {
|
|
847
854
|
if (!isControllerAction(route.handler)) {
|
|
848
855
|
return null;
|
|
@@ -853,21 +860,10 @@ function createContractValidationMiddleware(route) {
|
|
|
853
860
|
}
|
|
854
861
|
return async (c, next) => {
|
|
855
862
|
if (schemas.params) {
|
|
856
|
-
|
|
857
|
-
if (result instanceof Response) {
|
|
858
|
-
throw ValidationException.withMessages(
|
|
859
|
-
formatValidationErrors(schemas.params.safeParse(c.req.param()).error)
|
|
860
|
-
);
|
|
861
|
-
}
|
|
863
|
+
throwOnInvalid(schemas.params, c.req.param());
|
|
862
864
|
}
|
|
863
865
|
if (schemas.query) {
|
|
864
|
-
|
|
865
|
-
const result = parseRouteSegment(schemas.query, query, 422);
|
|
866
|
-
if (result instanceof Response) {
|
|
867
|
-
throw ValidationException.withMessages(
|
|
868
|
-
formatValidationErrors(schemas.query.safeParse(query).error)
|
|
869
|
-
);
|
|
870
|
-
}
|
|
866
|
+
throwOnInvalid(schemas.query, flattenRequestQueries(c));
|
|
871
867
|
}
|
|
872
868
|
await next();
|
|
873
869
|
if (schemas.output && c.res) {
|
|
@@ -2840,9 +2836,10 @@ function registerProcessTeardown(onSignal, onExit) {
|
|
|
2840
2836
|
process.once("SIGTERM", onSignal);
|
|
2841
2837
|
process.on("exit", onExit);
|
|
2842
2838
|
return () => {
|
|
2843
|
-
process
|
|
2844
|
-
|
|
2845
|
-
|
|
2839
|
+
const emitter = process;
|
|
2840
|
+
emitter.off("SIGINT", onSignal);
|
|
2841
|
+
emitter.off("SIGTERM", onSignal);
|
|
2842
|
+
emitter.off("exit", onExit);
|
|
2846
2843
|
};
|
|
2847
2844
|
}
|
|
2848
2845
|
function viteCloseTimeoutMs() {
|
|
@@ -4796,8 +4793,17 @@ function resetCalledSeeders() {
|
|
|
4796
4793
|
calledSeeders.clear();
|
|
4797
4794
|
}
|
|
4798
4795
|
var BaseSeeder = class {
|
|
4796
|
+
constructor() {
|
|
4797
|
+
warnOnce(
|
|
4798
|
+
"seeder-class-convention:base-seeder",
|
|
4799
|
+
"[guren] Deprecation (seeder-class-convention): BaseSeeder/Seeder is deprecated\n since 2.9.0, will be removed in 3.0.0.\n Write seeders with defineSeeder from '@guren/core': its handler receives { db }, which BaseSeeder.run() is declared not to take."
|
|
4800
|
+
);
|
|
4801
|
+
}
|
|
4799
4802
|
/**
|
|
4800
4803
|
* Call another seeder.
|
|
4804
|
+
*
|
|
4805
|
+
* No context is forwarded: the child's `run()` is invoked with no
|
|
4806
|
+
* arguments, whatever the caller itself received.
|
|
4801
4807
|
*/
|
|
4802
4808
|
async call(SeederClass) {
|
|
4803
4809
|
const seeder = new SeederClass();
|
|
@@ -4989,6 +4995,10 @@ var SeederRunner = class {
|
|
|
4989
4995
|
options;
|
|
4990
4996
|
seeders = /* @__PURE__ */ new Map();
|
|
4991
4997
|
constructor(options = {}) {
|
|
4998
|
+
warnOnce(
|
|
4999
|
+
"seeder-class-convention:seeder-runner",
|
|
5000
|
+
"[guren] Deprecation (seeder-class-convention): SeederRunner is deprecated\n since 2.9.0, will be removed in 3.0.0.\n No Guren command runs it. Write seeders with defineSeeder from '@guren/core' and run them with `guren db:seed`."
|
|
5001
|
+
);
|
|
4992
5002
|
this.options = {
|
|
4993
5003
|
seedersPath: options.seedersPath ?? "db/seeders",
|
|
4994
5004
|
defaultSeeder: options.defaultSeeder ?? "DatabaseSeeder",
|
package/dist/runtime/index.js
CHANGED
|
@@ -4,7 +4,7 @@ import {
|
|
|
4
4
|
logDevServerBanner,
|
|
5
5
|
parseImportMap,
|
|
6
6
|
startViteDevServer
|
|
7
|
-
} from "../chunk-
|
|
7
|
+
} from "../chunk-VSA3QY5Q.js";
|
|
8
8
|
import {
|
|
9
9
|
trimTrailingSlashes
|
|
10
10
|
} from "../chunk-AZOYI43J.js";
|
|
@@ -390,11 +390,20 @@ function configureInertiaAssets(app, options) {
|
|
|
390
390
|
}
|
|
391
391
|
const publicRoute = options.publicRoute ?? "/public/*";
|
|
392
392
|
const rewriteRequestPath = createStaticRewrite(publicRoute);
|
|
393
|
+
const hashedAssetsPrefix = `${publicRouteBase(publicRoute)}/assets/`;
|
|
393
394
|
app.use(
|
|
394
395
|
publicRoute,
|
|
395
396
|
serveStatic2({
|
|
396
397
|
root: publicDir,
|
|
397
|
-
rewriteRequestPath
|
|
398
|
+
rewriteRequestPath,
|
|
399
|
+
// Vite writes content-hashed filenames under `assets/`, so those
|
|
400
|
+
// responses can be cached forever. Files elsewhere in public/ keep
|
|
401
|
+
// stable names and must stay revalidatable.
|
|
402
|
+
onFound: (_path, ctx) => {
|
|
403
|
+
if (ctx.req.path.startsWith(hashedAssetsPrefix)) {
|
|
404
|
+
ctx.header("Cache-Control", "public, max-age=31536000, immutable");
|
|
405
|
+
}
|
|
406
|
+
}
|
|
398
407
|
})
|
|
399
408
|
);
|
|
400
409
|
if (options.favicon !== false) {
|
|
@@ -413,6 +422,11 @@ function configureInertiaAssets(app, options) {
|
|
|
413
422
|
}
|
|
414
423
|
}
|
|
415
424
|
}
|
|
425
|
+
function publicRouteBase(route) {
|
|
426
|
+
const wildcardIndex = route.indexOf("*");
|
|
427
|
+
const base = wildcardIndex >= 0 ? route.slice(0, wildcardIndex) : route;
|
|
428
|
+
return trimTrailingSlashes(base);
|
|
429
|
+
}
|
|
416
430
|
function registerBuiltInertiaClient(app, inertiaClientDir, inertiaClientPath) {
|
|
417
431
|
const {
|
|
418
432
|
base: inertiaClientBase,
|
package/dist/storage/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@guren/server",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.10.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -113,7 +113,7 @@
|
|
|
113
113
|
"test": "bun test"
|
|
114
114
|
},
|
|
115
115
|
"dependencies": {
|
|
116
|
-
"@guren/orm": "^2.
|
|
116
|
+
"@guren/orm": "^2.6.0",
|
|
117
117
|
"@modelcontextprotocol/sdk": "^1.30.0",
|
|
118
118
|
"chalk": "^5.3.0",
|
|
119
119
|
"consola": "^3.4.2",
|