@guren/server 2.25.1 → 2.27.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.
Files changed (121) hide show
  1. package/dist/{DocsViewerServiceProvider-CIRNHQ2I.js → DocsViewerServiceProvider-BMbcTYVw.js} +1 -1
  2. package/dist/{Gate-YOt54xGF.js → Gate-BL_zW82W.js} +1 -1
  3. package/dist/{Job-COMzBNOL.js → Job-DsFMcXVk.js} +35 -3
  4. package/dist/{McpServiceProvider-B-LioPSz.js → McpServiceProvider-PGFPlYTy.js} +1 -1
  5. package/dist/{Resource-BdYd4J9a.js → Resource-q3tJpJ0K.js} +194 -54
  6. package/dist/{ServiceProvider-DDW3MqQJ.js → ServiceProvider-G0YclITd.js} +60 -8
  7. package/dist/agent/dispatch.d.ts +4 -4
  8. package/dist/agent/public.js +1 -1
  9. package/dist/agent/scopes.d.ts +1 -3
  10. package/dist/agent-request-Caj6bnbj.js +18 -0
  11. package/dist/auth/AuthManager.d.ts +4 -0
  12. package/dist/auth/email-verification.d.ts +8 -1
  13. package/dist/auth/index.js +1 -1
  14. package/dist/auth/password/describe-hasher.d.ts +11 -0
  15. package/dist/auth/password-reset.d.ts +8 -2
  16. package/dist/{auth-vFeem6uM.js → auth-DIugW0O-.js} +108 -13
  17. package/dist/authorization/index.js +2 -2
  18. package/dist/authorization/middleware.d.ts +8 -0
  19. package/dist/{authorization-BLhwA2Yh.js → authorization-Daa6CxCg.js} +17 -2
  20. package/dist/broadcasting/BroadcastManager.d.ts +23 -6
  21. package/dist/broadcasting/index.d.ts +1 -1
  22. package/dist/broadcasting/index.js +1 -1
  23. package/dist/broadcasting/types.d.ts +13 -1
  24. package/dist/{broadcasting-BUBCPCnu.js → broadcasting-N4cRV42s.js} +205 -34
  25. package/dist/cache/CacheManager.d.ts +5 -0
  26. package/dist/cache/TaggedCache.d.ts +2 -0
  27. package/dist/cache/index.js +1 -1
  28. package/dist/cache/pending-computations.d.ts +22 -0
  29. package/dist/cache/stores/FileStore.d.ts +2 -0
  30. package/dist/cache/stores/MemoryStore.d.ts +1 -0
  31. package/dist/cache/stores/RedisStore.d.ts +1 -0
  32. package/dist/cache/stores/file-lock.d.ts +1 -0
  33. package/dist/cache/types.d.ts +2 -0
  34. package/dist/{cache-93n2PCnB.js → cache-BlXopnH1.js} +247 -38
  35. package/dist/contained-path-BkNSBljW.js +78 -0
  36. package/dist/container/Container.d.ts +6 -2
  37. package/dist/container/ServiceProvider.d.ts +27 -2
  38. package/dist/container/defineModule.d.ts +14 -5
  39. package/dist/container/definePlugin.d.ts +2 -0
  40. package/dist/{default-application-D5ezhhiV.js → default-application-DWwscxfW.js} +14 -18
  41. package/dist/dev-banner-CfQDnkfQ.js +51 -0
  42. package/dist/{dispatch-BAwzftws.js → dispatch-ENWpBxbE.js} +26 -4
  43. package/dist/driver-map-CkQc52j-.js +12 -0
  44. package/dist/encryption/index.js +1 -1
  45. package/dist/{encryption-D1dxfMqD.js → encryption-CWK5l22W.js} +1 -1
  46. package/dist/events/EventManager.d.ts +2 -0
  47. package/dist/events/index.js +1 -1
  48. package/dist/{events-c94CdUFc.js → events-DQavGm8W.js} +20 -7
  49. package/dist/health/HealthManager.d.ts +0 -1
  50. package/dist/health/index.js +1 -1
  51. package/dist/{health-CB0oS_UE.js → health-Bg0Xj3aD.js} +8 -8
  52. package/dist/host-port-t6wQFaRu.js +15 -0
  53. package/dist/hot-reload/testing.d.ts +2 -1
  54. package/dist/http/Application.d.ts +31 -2
  55. package/dist/http/dev-banner.d.ts +0 -8
  56. package/dist/http/host-port.d.ts +8 -0
  57. package/dist/http/middleware/force-https.d.ts +2 -1
  58. package/dist/http/middleware/index.d.ts +1 -0
  59. package/dist/http/middleware/rate-limit.d.ts +1 -4
  60. package/dist/http/middleware/session-manager.d.ts +5 -0
  61. package/dist/http/middleware/websocket-origin.d.ts +22 -0
  62. package/dist/http/public-assets.d.ts +6 -1
  63. package/dist/i18n/index.js +1 -1
  64. package/dist/{i18n-DqcRD4qL.js → i18n-DmMKcbqj.js} +1 -1
  65. package/dist/index.d.ts +8 -4
  66. package/dist/index.js +744 -273
  67. package/dist/internal/agent-request.d.ts +18 -0
  68. package/dist/internal/app-conventions.d.ts +6 -0
  69. package/dist/internal/app-conventions.js +9 -0
  70. package/dist/internal/dispatched-request.d.ts +4 -0
  71. package/dist/internal/testing.d.ts +1 -1
  72. package/dist/internal/testing.js +3 -3
  73. package/dist/internal/zod-json-schema.js +1 -1
  74. package/dist/introspection/driver-map.d.ts +3 -0
  75. package/dist/introspection/flag.d.ts +12 -0
  76. package/dist/introspection/manifest.d.ts +17 -0
  77. package/dist/introspection/plain-json.d.ts +7 -0
  78. package/dist/introspection/types.d.ts +167 -0
  79. package/dist/lambda/index.js +66 -28
  80. package/dist/logging/index.js +1 -1
  81. package/dist/{logging-YbKmbAd7.js → logging-Ci0mBk5k.js} +1 -1
  82. package/dist/mail/index.js +1 -1
  83. package/dist/{mail-uRBrUl9q.js → mail-CI2Kfe8P.js} +2 -2
  84. package/dist/mcp/index.js +1 -1
  85. package/dist/mvc/Controller.d.ts +3 -2
  86. package/dist/mvc/Router.d.ts +33 -0
  87. package/dist/mvc/inertia/InertiaEngine.d.ts +31 -0
  88. package/dist/mvc/inertia/props.d.ts +71 -0
  89. package/dist/notifications/index.js +1 -1
  90. package/dist/notifications/registry.d.ts +2 -2
  91. package/dist/{notifications-LHuujttf.js → notifications-Bp2uamzD.js} +7 -5
  92. package/dist/providers/ConfigServiceProvider.d.ts +12 -5
  93. package/dist/queue/Job.d.ts +5 -0
  94. package/dist/queue/QueueManager.d.ts +3 -0
  95. package/dist/queue/Worker.d.ts +6 -1
  96. package/dist/queue/drivers/RedisDriver.d.ts +4 -2
  97. package/dist/queue/drivers/SqsDriver.d.ts +31 -2
  98. package/dist/queue/drivers/redis-queue-scripts.d.ts +83 -0
  99. package/dist/queue/index.js +2 -2
  100. package/dist/queue/serialize.d.ts +7 -0
  101. package/dist/queue/types.d.ts +13 -2
  102. package/dist/{queue-BiBn5Sff.js → queue-C8s3buYz.js} +299 -125
  103. package/dist/redis/RedisEmailVerificationStore.d.ts +2 -0
  104. package/dist/redis/RedisPasswordResetStore.d.ts +2 -0
  105. package/dist/redis/auth-token-scripts.d.ts +4 -0
  106. package/dist/redis/index.js +50 -0
  107. package/dist/runtime/index.js +17 -37
  108. package/dist/scheduling/ScheduledTask.d.ts +2 -1
  109. package/dist/scheduling/index.js +1 -1
  110. package/dist/{scheduling-DhYfbJFj.js → scheduling-DNV5tj44.js} +32 -38
  111. package/dist/serialize-CKXek0Tr.js +17 -0
  112. package/dist/storage/StorageManager.d.ts +5 -0
  113. package/dist/storage/drivers/LocalDriver.d.ts +15 -0
  114. package/dist/storage/index.js +1 -1
  115. package/dist/storage/url-path.d.ts +2 -0
  116. package/dist/{storage-6HLaUf9j.js → storage-IlUesK2t.js} +91 -29
  117. package/dist/support/contained-path.d.ts +8 -0
  118. package/dist/support/registry-collision.d.ts +12 -0
  119. package/dist/{vite-manifest-DK55BTLk.js → vite-manifest-wPxfAzjW.js} +2 -58
  120. package/package.json +6 -2
  121. package/dist/trim-slashes-BLY9hKAa.js +0 -22
@@ -0,0 +1,18 @@
1
+ /**
2
+ * How a request says it is an agent tool call (RFC 0016 §3), in a leaf module
3
+ * so the dispatcher that writes the header and the auth middlewares that read
4
+ * it share one spelling. Not exported from the package index.
5
+ *
6
+ * Read only to choose the *shape* of a refusal: a tool caller cannot follow a
7
+ * redirect, so a guard answers it with JSON instead. Nothing may authorize on
8
+ * it, since any client can send it and gets no more than a JSON refusal.
9
+ */
10
+ /** Request header naming the protocol surface a tool call arrived on. */
11
+ export declare const AGENT_SURFACE_HEADER = "X-Guren-Agent-Surface";
12
+ export interface HeaderReader {
13
+ req?: {
14
+ header(name: string): string | undefined;
15
+ };
16
+ }
17
+ /** Whether the request was built by the agent dispatcher (`buildToolRequest`). */
18
+ export declare function isAgentToolRequest(ctx: HeaderReader): boolean;
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Where an app registers its durable agents (RFC 0017). A leaf with no imports:
3
+ * `@guren/core/internal/deploy-build` reads it at plugin build time, where the
4
+ * runtime barrel must not load, and the CLI checks read it without depending on core.
5
+ */
6
+ export declare const AGENTS_CONFIG_FILE = "config/agents.ts";
@@ -0,0 +1,9 @@
1
+ //#region src/internal/app-conventions.ts
2
+ /**
3
+ * Where an app registers its durable agents (RFC 0017). A leaf with no imports:
4
+ * `@guren/core/internal/deploy-build` reads it at plugin build time, where the
5
+ * runtime barrel must not load, and the CLI checks read it without depending on core.
6
+ */
7
+ const AGENTS_CONFIG_FILE = "config/agents.ts";
8
+ //#endregion
9
+ export { AGENTS_CONFIG_FILE };
@@ -0,0 +1,4 @@
1
+ /** Mark `request` as built by `buildToolRequest`, returning that same object. */
2
+ export declare function markDispatchedToolRequest(request: Request): Request;
3
+ /** Whether this exact object was built by the dispatcher in this process. */
4
+ export declare function isDispatchedToolRequest(request: Request): boolean;
@@ -7,7 +7,7 @@
7
7
  */
8
8
  export { Controller } from '../mvc/Controller.js';
9
9
  export type { InertiaPageContractLike, InertiaResponseOptions } from '../mvc/Controller.js';
10
- export { acceptsJson, serializePage } from '../mvc/inertia/InertiaEngine.js';
10
+ export { acceptsJson, buildInertiaPage, INERTIA_VARY, serializePage } from '../mvc/inertia/InertiaEngine.js';
11
11
  export { Resource, JsonResource, collect } from '../http/resources/Resource.js';
12
12
  export { ValidationException } from '../errors/exceptions/ValidationException.js';
13
13
  export { AuthenticationException } from '../errors/exceptions/AuthenticationException.js';
@@ -1,6 +1,6 @@
1
- import { _ as acceptsJson, f as definePlugin, i as Controller, n as Resource, r as collect, t as JsonResource, u as defineModule, y as serializePage } from "../Resource-BdYd4J9a.js";
1
+ import { _ as INERTIA_VARY, f as definePlugin, i as Controller, n as Resource, r as collect, t as JsonResource, u as defineModule, v as acceptsJson, x as serializePage, y as buildInertiaPage } from "../Resource-q3tJpJ0K.js";
2
2
  import { r as formatValidationErrors } from "../request-CLOYytGP.js";
3
3
  import { n as ValidationException } from "../errors-JpkcCjjn.js";
4
- import { n as ServiceProvider } from "../ServiceProvider-DDW3MqQJ.js";
4
+ import { n as ServiceProvider } from "../ServiceProvider-G0YclITd.js";
5
5
  import { o as AuthenticationException } from "../context-af2n5abO.js";
6
- export { AuthenticationException, Controller, JsonResource, Resource, ServiceProvider, ValidationException, acceptsJson, collect, defineModule, definePlugin, formatValidationErrors, serializePage };
6
+ export { AuthenticationException, Controller, INERTIA_VARY, JsonResource, Resource, ServiceProvider, ValidationException, acceptsJson, buildInertiaPage, collect, defineModule, definePlugin, formatValidationErrors, serializePage };
@@ -101,7 +101,7 @@ function toJsonSchema(schema, warnings, label, io) {
101
101
  return {
102
102
  type: "object",
103
103
  properties: details.properties,
104
- required: details.required.size > 0 ? Array.from(details.required) : void 0
104
+ ...details.required.size > 0 ? { required: Array.from(details.required) } : {}
105
105
  };
106
106
  }
107
107
  case "nullable": {
@@ -0,0 +1,3 @@
1
+ import type { DriverMapEntry } from './types.js';
2
+ /** `DriverMapEntry` from a manager's entries, each with the driver it was configured with or null. */
3
+ export declare function describeDriverMap(defaultName: string, drivers: Iterable<[string, string | null]>): DriverMapEntry;
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Whether this code runs for an introspection: the CLI child's `GUREN_INTROSPECT=1`,
3
+ * or inside an `Application.introspect()` in this process. The one reader of both.
4
+ */
5
+ export declare function isIntrospecting(): boolean;
6
+ /** Runs `fn` with {@link isIntrospecting} true for it and everything it schedules, timers that outlive it included. */
7
+ export declare function runIntrospecting<T>(fn: () => T): T;
8
+ /** `listen()` under the flag: an introspection run must never open a socket. */
9
+ export declare class IntrospectionListenError extends Error {
10
+ readonly code = "GUREN_INTROSPECT_LISTEN";
11
+ constructor();
12
+ }
@@ -0,0 +1,17 @@
1
+ import type { Container } from '../container/Container.js';
2
+ import type { GurenModule } from '../container/defineModule.js';
3
+ import type { AuthPluginOptions } from '../http/Application.js';
4
+ import type { Router } from '../mvc/Router.js';
5
+ import type { AppManifest, ManifestWarning, ProviderEntry } from './types.js';
6
+ interface ManifestSources {
7
+ readonly router: Router;
8
+ readonly container: Container;
9
+ readonly providers: ProviderEntry[];
10
+ readonly providerWarnings: ManifestWarning[];
11
+ readonly modules: ReadonlyArray<GurenModule>;
12
+ readonly authOptions?: AuthPluginOptions;
13
+ readonly hasBootCallback: boolean;
14
+ }
15
+ /** Builds the manifest from a registered, unmounted, unbooted app (RFC 0026 §1). */
16
+ export declare function buildAppManifest(sources: ManifestSources): AppManifest;
17
+ export {};
@@ -0,0 +1,7 @@
1
+ /**
2
+ * A deep copy holding only JSON values, with `undefined` object keys dropped and
3
+ * `undefined` array items turned into `null`, as `JSON.stringify` does. Anything
4
+ * else (a function, a Map, a class instance, a bigint, a cycle) throws, so a
5
+ * manifest field that would not survive `--json` fails here instead of vanishing.
6
+ */
7
+ export declare function toPlainJson<T>(value: T): T;
@@ -0,0 +1,167 @@
1
+ import type { DerivedAgentTool } from '../agent/derive.js';
2
+ import type { MiddlewareCapabilities } from '../http/middleware/capabilities.js';
3
+ import type { JsonSchemaObject } from '../internal/zod-json-schema.js';
4
+ import type { RouteDefinition } from '../mvc/Router.js';
5
+ /**
6
+ * What `Application.introspect()` reports (RFC 0026 §1): the app after every
7
+ * provider and every route registered, before anything mounted or booted. Plain
8
+ * JSON throughout, so `guren introspect --json` prints it as it is.
9
+ */
10
+ export interface AppManifest {
11
+ schemaVersion: 1;
12
+ generatedAt: string;
13
+ /** `file` is null when `introspect()` ran in process rather than under the CLI, which names the entry it imported. */
14
+ entry: {
15
+ file: string | null;
16
+ root: string;
17
+ stage: 'register';
18
+ };
19
+ runtime: {
20
+ bun: string | null;
21
+ node: string | null;
22
+ platform: string;
23
+ };
24
+ providers: ProviderEntry[];
25
+ modules: ModuleEntry[];
26
+ routes: RouteEntry[];
27
+ middlewareAliases: Record<string, MiddlewareEntry>;
28
+ /** Container keys present after `register()`, sorted. */
29
+ bindings: string[];
30
+ session?: SessionEntry;
31
+ auth?: AuthEntry;
32
+ cache?: DriverMapEntry;
33
+ storage?: DriverMapEntry;
34
+ queue?: DriverMapEntry;
35
+ attachments?: AttachmentsEntry;
36
+ agentTools: DerivedAgentTool[];
37
+ warnings: ManifestWarning[];
38
+ }
39
+ /** How a provider was registered. `app.register` is a provider added through `Application.register()` after construction. */
40
+ export type ProviderSource = 'framework' | 'options.providers' | 'module' | 'app.register';
41
+ /** `skipped` is a deferred provider: it registers on the first `make()` after boot, which introspection never reaches. */
42
+ export type ProviderRegisterOutcome = 'ran' | 'introspect-hook' | 'threw' | 'skipped';
43
+ export interface ProviderEntry {
44
+ /** `constructor.name`, durable because Guren forbids identifier mangling. */
45
+ name: string;
46
+ source: ProviderSource;
47
+ module?: string;
48
+ deferred: boolean;
49
+ provides: string[];
50
+ register: ProviderRegisterOutcome;
51
+ error?: string;
52
+ }
53
+ export interface ModuleEntry {
54
+ name: string;
55
+ prefix?: string;
56
+ /** Class names, like `ProviderEntry.name`. */
57
+ providers: string[];
58
+ /** Class names; the console keys a command by the name in its `signature`. */
59
+ commands: string[];
60
+ routeCount: number;
61
+ }
62
+ export interface ControllerRef {
63
+ name: string;
64
+ action: string;
65
+ /** Project-relative; null when identity matching found no file. */
66
+ file: string | null;
67
+ /** `'default'` or the named export; null with `file`. */
68
+ exportName: string | null;
69
+ resolved: 'identity' | 'name-only';
70
+ }
71
+ export interface MiddlewareEntry {
72
+ kind: 'alias' | 'group' | 'inline';
73
+ /** The alias or group name; an inline handler's function name, or null. */
74
+ name: string | null;
75
+ /** A group's aliases, expanded through nested groups. */
76
+ members?: string[];
77
+ capabilities: MiddlewareCapabilities;
78
+ /** The one ability this middleware checks: a single-ability check, or on a route the verb-map ability of a resource check. */
79
+ ability?: string;
80
+ /** A name no alias or group registers; `mount()` refuses it. */
81
+ unresolved?: true;
82
+ /** A group's members no alias registers, which `mount()` refuses the same way. */
83
+ unresolvedMembers?: string[];
84
+ }
85
+ export type JsonSchema = JsonSchemaObject;
86
+ export type RouteSchemaEntry = JsonSchema | {
87
+ unreadable: string;
88
+ };
89
+ export type RouteEntry = Omit<RouteDefinition, 'schemas' | 'controller' | 'middlewareNames' | 'module'> & {
90
+ module: string | null;
91
+ controller?: ControllerRef;
92
+ /** In the order `mount()` runs them: named, then group-scoped inline, then route-local inline. */
93
+ middleware: MiddlewareEntry[];
94
+ schemas: Partial<Record<'params' | 'query' | 'body' | 'output', RouteSchemaEntry>>;
95
+ };
96
+ /** `driver` and `perProcess` are null for an `auth.sessionOptions.store` thunk, which only calling it would answer. */
97
+ export interface SessionStoreEntry {
98
+ /** The configured driver name, or the store's constructor name for `auth.sessionOptions.store`. */
99
+ driver: string | null;
100
+ /** The `database` driver's table, by its SQL name. */
101
+ table?: string;
102
+ perProcess: boolean | null;
103
+ }
104
+ export interface SessionEntry {
105
+ source: 'manager' | 'auth.sessionOptions.store' | 'none';
106
+ default: string;
107
+ stores: Record<string, SessionStoreEntry>;
108
+ }
109
+ export interface AuthProviderEntry {
110
+ /** `model` for `useModel()`; `custom` for a factory passed to `registerProvider()`. */
111
+ kind: 'model' | 'custom';
112
+ model?: string;
113
+ /** The hasher's constructor name; null for a custom provider, whose hasher only its factory knows. */
114
+ hasher: string | null;
115
+ /**
116
+ * The format a framework hasher writes, matched by exact class: `DefaultHasher`
117
+ * reports one class name for scrypt and Argon2id. Null for a subclass or an app's own hasher.
118
+ */
119
+ algorithm: 'scrypt' | 'argon2' | 'bcrypt' | null;
120
+ /** Whether writing needs `Bun.password` (`ScryptHasher`, `DefaultHasher` on argon2); null where `algorithm` is. */
121
+ requiresBun: boolean | null;
122
+ }
123
+ export interface AuthEntry {
124
+ guards: string[];
125
+ defaultGuard: string | null;
126
+ /** The hasher new passwords are written with (`createApp({ auth: { hasher } })`), by constructor name. */
127
+ hasher: string;
128
+ /** As on {@link AuthProviderEntry}. */
129
+ algorithm: 'scrypt' | 'argon2' | 'bcrypt' | null;
130
+ requiresBun: boolean | null;
131
+ providers: Record<string, AuthProviderEntry>;
132
+ }
133
+ export interface DriverMapEntry {
134
+ default: string;
135
+ /** `driver` is null for an entry registered as a bare factory, whose driver is unknowable without calling it. */
136
+ entries: Record<string, {
137
+ driver: string | null;
138
+ }>;
139
+ }
140
+ export interface AttachmentsEntry {
141
+ configured: boolean;
142
+ table?: string;
143
+ disk?: string;
144
+ /** `route: false` is a disk configured `serve: 'direct'`, whose URLs bypass the delivery route. */
145
+ disks?: Record<string, {
146
+ visibility: 'public' | 'private';
147
+ route: boolean;
148
+ serve: 'auto' | 'redirect' | 'proxy';
149
+ }>;
150
+ delivery?: {
151
+ prefix: string;
152
+ routeName: string;
153
+ mounted: boolean;
154
+ };
155
+ }
156
+ /** What an attachments engine reports of itself; the manifest adds `delivery.mounted` from the route registry. */
157
+ export type AttachmentsDescription = Omit<AttachmentsEntry, 'delivery'> & {
158
+ delivery?: Omit<NonNullable<AttachmentsEntry['delivery']>, 'mounted'>;
159
+ };
160
+ export interface ManifestWarning {
161
+ code: string;
162
+ message: string;
163
+ provider?: string;
164
+ route?: string;
165
+ /** The container key a `config-unverified` warning left unbound, so a reader can tell that section from an absent one. */
166
+ key?: string;
167
+ }
@@ -1,5 +1,6 @@
1
1
  import { n as detectServerlessRuntime } from "../serverless-D96rJb6x.js";
2
- import { a as getJob } from "../Job-COMzBNOL.js";
2
+ import { a as getJob } from "../Job-DsFMcXVk.js";
3
+ import { t as deserializeQueuedJob } from "../serialize-CKXek0Tr.js";
3
4
  import { handle } from "hono/aws-lambda";
4
5
  //#region src/lambda/index.ts
5
6
  /** Create an AWS Lambda handler from an already booted Guren application. */
@@ -12,26 +13,73 @@ function createLambdaHandler(app) {
12
13
  */
13
14
  function createSqsHandler() {
14
15
  return async (event) => {
15
- const failures = [];
16
- const results = await Promise.allSettled(event.Records.map(async (record) => {
17
- const job = deserializeSqsJob(record.body);
18
- const JobClass = getJob(job.name);
19
- if (!JobClass) throw new Error(`Job class not found: ${job.name}`);
20
- const instance = new JobClass();
21
- job.attempts++;
22
- try {
23
- await instance.handle(job.payload);
24
- } catch (error) {
25
- if (job.attempts >= job.maxAttempts && instance.failed) try {
26
- await instance.failed(job.payload, error);
27
- } catch {}
28
- throw error;
16
+ if (event.Records.some((record) => record.eventSourceARN.endsWith(".fifo"))) {
17
+ for (let index = 0; index < event.Records.length; index++) try {
18
+ await processSqsRecord(event.Records[index]);
19
+ } catch {
20
+ const stopped = event.Records.slice(index);
21
+ for (const record of stopped.slice(1)) logSqsFailure({
22
+ msg: "SQS record left unprocessed",
23
+ messageId: record.messageId,
24
+ stoppedAt: stopped[0].messageId
25
+ });
26
+ return { batchItemFailures: stopped.map((record) => ({ itemIdentifier: record.messageId })) };
29
27
  }
30
- }));
31
- for (let i = 0; i < results.length; i++) if (results[i].status === "rejected") failures.push({ itemIdentifier: event.Records[i].messageId });
32
- return { batchItemFailures: failures };
28
+ return { batchItemFailures: [] };
29
+ }
30
+ const results = await Promise.allSettled(event.Records.map(processSqsRecord));
31
+ const batchItemFailures = [];
32
+ for (let index = 0; index < results.length; index++) if (results[index].status === "rejected") batchItemFailures.push({ itemIdentifier: event.Records[index].messageId });
33
+ return { batchItemFailures };
33
34
  };
34
35
  }
36
+ /** The tests parse these lines, so the envelope is a contract, not formatting. */
37
+ function logSqsFailure(fields) {
38
+ console.error(JSON.stringify({
39
+ level: "error",
40
+ ...fields
41
+ }));
42
+ }
43
+ async function processSqsRecord(record) {
44
+ let job;
45
+ try {
46
+ job = deserializeQueuedJob(record.body);
47
+ const JobClass = getJob(job.name);
48
+ if (!JobClass) throw new Error(`Job class not found: ${job.name}`);
49
+ const receiveCount = Number(record.attributes.ApproximateReceiveCount);
50
+ if (!Number.isSafeInteger(receiveCount) || receiveCount < 1) throw new Error("SQS records require a positive ApproximateReceiveCount.");
51
+ if (!Number.isSafeInteger(job.attempts) || job.attempts < 0 || !Number.isSafeInteger(job.maxAttempts) || job.maxAttempts < 1) throw new Error("SQS jobs require valid attempts and maxAttempts counts.");
52
+ job.attempts += receiveCount;
53
+ if (job.attempts > job.maxAttempts) throw new Error(`SQS job exceeded maxAttempts (${job.maxAttempts}).`);
54
+ const instance = new JobClass();
55
+ try {
56
+ await instance.handle(job.payload);
57
+ } catch (error) {
58
+ if (job.attempts >= job.maxAttempts && instance.failed) try {
59
+ await instance.failed(job.payload, error);
60
+ } catch (hookError) {
61
+ logSqsFailure({
62
+ msg: "Error in job.failed() handler",
63
+ messageId: record.messageId,
64
+ job: job.name,
65
+ error: hookError.message
66
+ });
67
+ }
68
+ throw error;
69
+ }
70
+ } catch (error) {
71
+ logSqsFailure({
72
+ msg: "SQS job failed",
73
+ messageId: record.messageId,
74
+ job: job?.name,
75
+ queue: job?.queue,
76
+ attempt: job?.attempts,
77
+ maxAttempts: job?.maxAttempts,
78
+ error: error.message
79
+ });
80
+ throw error;
81
+ }
82
+ }
35
83
  /** Create an AWS Lambda handler for running scheduled tasks via EventBridge. */
36
84
  function createScheduleHandler(scheduler) {
37
85
  return async () => {
@@ -68,15 +116,5 @@ function getLambdaContext() {
68
116
  tmpDir: "/tmp"
69
117
  };
70
118
  }
71
- /** Deserialize a JSON SQS message body into a QueuedJob-like object. */
72
- function deserializeSqsJob(body) {
73
- const raw = JSON.parse(body);
74
- return {
75
- ...raw,
76
- availableAt: new Date(raw.availableAt),
77
- createdAt: new Date(raw.createdAt),
78
- reservedAt: raw.reservedAt ? new Date(raw.reservedAt) : null
79
- };
80
- }
81
119
  //#endregion
82
120
  export { createConsoleHandler, createLambdaHandler, createScheduleHandler, createSqsHandler, getLambdaContext, isLambda };
@@ -1,4 +1,4 @@
1
1
  import { n as filterSensitiveData, t as Logger } from "../Logger-DWXdtLSJ.js";
2
2
  import { a as LOG_LEVEL_PRIORITY, i as matchDailyFileDate, n as dailyFileDateStamp, r as dailyFilePath, t as DailyFileChannel } from "../DailyFileChannel-CTTPA0EF.js";
3
- import { a as FileChannel, i as setLogManager, n as createLogManager, o as ConsoleChannel, r as getLogManager, t as LogManager } from "../logging-YbKmbAd7.js";
3
+ import { a as FileChannel, i as setLogManager, n as createLogManager, o as ConsoleChannel, r as getLogManager, t as LogManager } from "../logging-Ci0mBk5k.js";
4
4
  export { ConsoleChannel, DailyFileChannel, FileChannel, LOG_LEVEL_PRIORITY, LogManager, Logger, createLogManager, dailyFileDateStamp, dailyFilePath, filterSensitiveData, getLogManager, matchDailyFileDate, setLogManager };
@@ -1,4 +1,4 @@
1
- import { h as warnDeprecatedSetter, i as bindAmbient, m as warnDeprecatedGetter, n as ambientBinding } from "./default-application-D5ezhhiV.js";
1
+ import { h as warnDeprecatedSetter, i as bindAmbient, m as warnDeprecatedGetter, n as ambientBinding } from "./default-application-DWwscxfW.js";
2
2
  import { r as isPromiseLike, t as Logger } from "./Logger-DWXdtLSJ.js";
3
3
  import { a as LOG_LEVEL_PRIORITY, t as DailyFileChannel } from "./DailyFileChannel-CTTPA0EF.js";
4
4
  import * as path$1 from "node:path";
@@ -1,2 +1,2 @@
1
- import { a as MailManager, c as MemoryTransport, i as setMailManager, l as ResendTransport, n as getMailManager, o as createMailManager, r as mail, s as LogTransport, t as Mail, u as SmtpTransport } from "../mail-uRBrUl9q.js";
1
+ import { a as MailManager, c as MemoryTransport, i as setMailManager, l as ResendTransport, n as getMailManager, o as createMailManager, r as mail, s as LogTransport, t as Mail, u as SmtpTransport } from "../mail-CI2Kfe8P.js";
2
2
  export { LogTransport, Mail, MailManager, MemoryTransport, ResendTransport, SmtpTransport, createMailManager, getMailManager, mail, setMailManager };
@@ -1,6 +1,6 @@
1
1
  import { t as resolveOptional } from "./resolve-optional-ax6gPWTp.js";
2
- import { h as warnDeprecatedSetter, i as bindAmbient, m as warnDeprecatedGetter, n as ambientBinding } from "./default-application-D5ezhhiV.js";
3
- import { c as pinnedQueueDriver, d as resolveQueueDriver, i as enqueueJob, l as registerJob, t as Job } from "./Job-COMzBNOL.js";
2
+ import { h as warnDeprecatedSetter, i as bindAmbient, m as warnDeprecatedGetter, n as ambientBinding } from "./default-application-DWwscxfW.js";
3
+ import { c as pinnedQueueDriver, d as resolveQueueDriver, i as enqueueJob, l as registerJob, t as Job } from "./Job-DsFMcXVk.js";
4
4
  import { t as parseMailAddress } from "./address-D0Iq-XIH.js";
5
5
  import nodemailer from "nodemailer";
6
6
  //#region src/mail/transports/SmtpTransport.ts
package/dist/mcp/index.js CHANGED
@@ -1,2 +1,2 @@
1
- import { t as McpServiceProvider } from "../McpServiceProvider-B-LioPSz.js";
1
+ import { t as McpServiceProvider } from "../McpServiceProvider-PGFPlYTy.js";
2
2
  export { McpServiceProvider };
@@ -2,6 +2,7 @@ import type { Context } from 'hono';
2
2
  import type { FC } from 'hono/jsx';
3
3
  import { type ViewOptions } from './view.js';
4
4
  import { type InertiaOptions } from './inertia/InertiaEngine.js';
5
+ import type { InertiaPropsInput, ResolvedInertiaProps } from './inertia/props.js';
5
6
  import { type ResolvedSharedInertiaProps } from './inertia/shared.js';
6
7
  import { type RegisteredTranslationKey, type ReplacementValues } from '../i18n/index.js';
7
8
  import type { AuthContext } from '../auth/types.js';
@@ -147,8 +148,8 @@ export declare class Controller {
147
148
  * data is emitted verbatim, so sanitize user-supplied URLs upstream.
148
149
  */
149
150
  protected view<P>(component: FC<P>, props: P, options?: ViewOptions): Promise<Response>;
150
- protected inertia<Component extends string, Props extends DefaultInertiaProps>(component: Component, props: Props, options?: InertiaResponseOptions): Promise<InertiaResponse<Component, Props & ResolvedSharedInertiaProps>>;
151
- protected inertia<TPage extends InertiaPageContractLike>(page: TPage, props: InertiaPageProps<TPage>, options?: InertiaResponseOptions): Promise<InertiaResponse<InertiaPageComponent<TPage>, InertiaPageProps<TPage> & ResolvedSharedInertiaProps>>;
151
+ protected inertia<Component extends string, Props extends DefaultInertiaProps>(component: Component, props: Props, options?: InertiaResponseOptions): Promise<InertiaResponse<Component, ResolvedInertiaProps<Props> & ResolvedSharedInertiaProps>>;
152
+ protected inertia<TPage extends InertiaPageContractLike>(page: TPage, props: InertiaPropsInput<InertiaPageProps<TPage>>, options?: InertiaResponseOptions): Promise<InertiaResponse<InertiaPageComponent<TPage>, InertiaPageProps<TPage> & ResolvedSharedInertiaProps>>;
152
153
  /**
153
154
  * Locale for the current request: the request-scoped `locale` context
154
155
  * variable wins over the app-wide i18n locale. Falls back to `'en'`.
@@ -4,6 +4,7 @@ import type { Container } from '../container/Container.js';
4
4
  import type { ValidationSchema } from '../http/middleware/validation.js';
5
5
  import { type MiddlewareCapabilities } from '../http/middleware/capabilities.js';
6
6
  import { type PrototypeRouteHandler } from './prototype.js';
7
+ import type { MiddlewareEntry } from '../introspection/types.js';
7
8
  /** Constructor type for Controller classes. */
8
9
  export type ControllerConstructor<T extends Controller = Controller> = (new (...args: any[]) => T) & {
9
10
  inject?: readonly string[];
@@ -167,6 +168,8 @@ export interface RouteDefinition {
167
168
  agent?: AgentRouteMetadata;
168
169
  /** Still on its fixture (RFC 0021): registered with the `prototype` handler rather than a controller. */
169
170
  prototype?: true;
171
+ /** The `defineModule()` name of the module whose registrar added the route (the outer one, when modules nest). Absent: the app's own route. */
172
+ module?: string;
170
173
  summary?: string;
171
174
  description?: string;
172
175
  tags?: string[];
@@ -274,6 +277,33 @@ export declare class Router<in M extends string = never> {
274
277
  clear(): void;
275
278
  resetMiddleware(): void;
276
279
  definitions(): RouteDefinition[];
280
+ /** How many routes are registered, without building {@link definitions}. */
281
+ get routeCount(): number;
282
+ /**
283
+ * Records `module` on every route registered from index `start` on. `mountModuleRoutes()` calls
284
+ * it once the registrar settled, so a route an async registrar adds after an `await` counts, and a
285
+ * module a registrar mounts itself is named after the outer one, which `manifest.modules` lists.
286
+ * @internal
287
+ */
288
+ assignModule(start: number, module: string): void;
289
+ /**
290
+ * The handler behind each {@link definitions} entry, index-aligned with it
291
+ * (RFC 0026 §3): the controller class there is reduced to its name.
292
+ */
293
+ registeredHandlers(): ReadonlyArray<{
294
+ index: number;
295
+ controller?: ControllerConstructor;
296
+ action?: string;
297
+ }>;
298
+ /**
299
+ * Every alias and group resolved, and each route's chain in `mount()` order,
300
+ * index-aligned with {@link definitions} (RFC 0026 §3). Like `definitions()`,
301
+ * an unregistered name is reported rather than thrown.
302
+ */
303
+ describeMiddleware(): {
304
+ aliases: Record<string, MiddlewareEntry>;
305
+ routes: MiddlewareEntry[][];
306
+ };
277
307
  applyMiddlewareScope<T>(items: readonly MiddlewareScopeEntry[], callback: () => T): T;
278
308
  private register;
279
309
  private add;
@@ -284,6 +314,9 @@ export declare class Router<in M extends string = never> {
284
314
  * stay side-effect-free for routers that never mount (audit, codegen).
285
315
  */
286
316
  private aggregateCapabilities;
317
+ private describeNamedMiddleware;
318
+ /** A group's alias names through nested groups, each group expanded once whatever path reaches it. */
319
+ private expandGroup;
287
320
  private resolveMiddlewareNames;
288
321
  }
289
322
  declare class RouterMiddlewareGroupBuilder<in M extends string = never> {
@@ -32,6 +32,8 @@ export interface InertiaPagePayload {
32
32
  props: Record<string, unknown>;
33
33
  url: string;
34
34
  version?: string;
35
+ /** Deferred prop keys by group, announced on a full visit and fetched by the client per group. */
36
+ deferredProps?: Record<string, string[]>;
35
37
  }
36
38
  export interface InertiaSsrContext {
37
39
  page: InertiaPagePayload;
@@ -102,6 +104,35 @@ export declare function setInertiaDocument(options: InertiaDocumentOptions | und
102
104
  */
103
105
  export declare function setInertiaSsrRenderer(renderer: InertiaSsrRenderer | undefined): void;
104
106
  export declare function inertia(component: string, props: Record<string, unknown>, options?: InertiaOptions): Promise<Response>;
107
+ export interface InertiaRenderResult {
108
+ readonly response: Response;
109
+ /** The page the response carries; absent on a 409 version-mismatch, which renders none. */
110
+ readonly page?: InertiaPagePayload;
111
+ }
112
+ /**
113
+ * The page body varies on the partial-reload headers as well as on
114
+ * `X-Inertia`: a shared cache keyed on the URL alone would hand a narrowed
115
+ * partial response to the next full visit.
116
+ */
117
+ export declare const INERTIA_VARY = "Accept, X-Inertia, X-Inertia-Partial-Component, X-Inertia-Partial-Data, X-Inertia-Partial-Except";
118
+ /**
119
+ * {@link inertia} plus the page it sent, for a caller that records the props
120
+ * actually resolved (`Controller.inertia()`'s response marker). The version
121
+ * check runs before any prop resolves: a 409 must not run a lazy prop's query.
122
+ */
123
+ export declare function renderInertia(component: string, props: Record<string, unknown>, options?: InertiaOptions): Promise<InertiaRenderResult>;
124
+ export interface InertiaPageOptions {
125
+ readonly url?: string;
126
+ readonly version?: string;
127
+ readonly request?: Request;
128
+ }
129
+ /**
130
+ * The page object for one request: props resolved under the request's
131
+ * partial-reload headers, the deferred announcement, and the page url derived
132
+ * from the request when `url` is absent. `@guren/testing`'s mock builds its
133
+ * page here too, so the two cannot disagree on the payload's shape.
134
+ */
135
+ export declare function buildInertiaPage(component: string, props: Record<string, unknown>, options: InertiaPageOptions): Promise<InertiaPagePayload>;
105
136
  export declare function serializePage(page: InertiaPagePayload): string;
106
137
  export declare function acceptsJson(request: Request): boolean;
107
138
  export {};
@@ -0,0 +1,71 @@
1
+ /**
2
+ * Prop evaluation for the Inertia protocol's partial reloads and deferred
3
+ * props (https://inertiajs.com/the-protocol, "Prop Evaluation Model").
4
+ * `@guren/testing`'s controller mock resolves through the same function, so a
5
+ * test cannot pass on a prop set production would not send.
6
+ */
7
+ declare const DEFERRED_BRAND: unique symbol;
8
+ declare const ALWAYS_BRAND: unique symbol;
9
+ export interface AlwaysProp<T> {
10
+ readonly [ALWAYS_BRAND]: true;
11
+ readonly value: T;
12
+ /** The plain value, so a consumer that serializes shared props before the engine sees them sends the value itself. */
13
+ toJSON(): T;
14
+ }
15
+ /**
16
+ * A prop sent on every response, partial reloads included, whatever the
17
+ * `only`/`except` lists say (Laravel's `Inertia::always()`). The protocol's
18
+ * `errors` is one; a flash-backed shared prop is the usual other, since a
19
+ * flash the partial filter drops is gone with the request.
20
+ */
21
+ export declare function always<T>(value: T): AlwaysProp<T>;
22
+ export declare function isAlwaysProp(value: unknown): value is AlwaysProp<unknown>;
23
+ export interface DeferredProp<T> {
24
+ readonly [DEFERRED_BRAND]: true;
25
+ readonly resolve: () => T | Promise<T>;
26
+ readonly group: string;
27
+ }
28
+ /**
29
+ * A prop resolved in a follow-up request rather than the initial visit
30
+ * (Laravel's `Inertia::defer()`). The initial response announces the key under
31
+ * `deferredProps[group]` and the client fetches each group with one partial
32
+ * reload; `resolve` runs only on the request that asks for the key.
33
+ */
34
+ export declare function defer<T>(resolve: () => T, group?: string): DeferredProp<Awaited<T>>;
35
+ export declare function isDeferredProp(value: unknown): value is DeferredProp<unknown>;
36
+ /** What a controller may pass for a prop the page declares as `T`. */
37
+ export type InertiaPropInput<T> = T | DeferredProp<T> | AlwaysProp<T> | (() => T | Promise<T>);
38
+ export type InertiaPropsInput<Props> = {
39
+ [K in keyof Props]: InertiaPropInput<Props[K]>;
40
+ };
41
+ /** The value the page receives for one prop input: a deferred, always or lazy prop as its resolved type. */
42
+ export type ResolvedInertiaProp<V> = V extends DeferredProp<unknown> ? Awaited<ReturnType<V['resolve']>> : V extends AlwaysProp<unknown> ? V['value'] : V extends () => infer R ? Awaited<R> : V;
43
+ export type ResolvedInertiaProps<Props> = {
44
+ [K in keyof Props]: ResolvedInertiaProp<Props[K]>;
45
+ };
46
+ export interface PartialReload {
47
+ /** Top-level prop names listed in `X-Inertia-Partial-Data`; empty means every prop. */
48
+ readonly only: ReadonlySet<string>;
49
+ readonly except: ReadonlySet<string>;
50
+ }
51
+ export interface ResolvedInertiaPage {
52
+ readonly props: Record<string, unknown>;
53
+ /** Present on a full visit that carried at least one deferred prop. */
54
+ readonly deferredProps?: Record<string, string[]>;
55
+ }
56
+ /**
57
+ * The partial reload a request asks for, or undefined for a full visit. A
58
+ * partial reload is an Inertia request whose `X-Inertia-Partial-Component`
59
+ * names the component being rendered; a different component (the visit was
60
+ * redirected elsewhere) is a full visit again.
61
+ */
62
+ export declare function readPartialReload(request: Request | undefined, component: string): PartialReload | undefined;
63
+ /**
64
+ * The props a response carries under the protocol's evaluation rules: a full
65
+ * visit resolves every prop but the deferred ones, which it announces; a
66
+ * partial reload resolves only the selected props, deferred ones included, and
67
+ * announces nothing; an always prop is sent either way; a lazy prop (a function
68
+ * value) runs only when sent. Resolvers run concurrently, unlike Laravel's.
69
+ */
70
+ export declare function resolveInertiaProps(input: Record<string, unknown>, partial: PartialReload | undefined): Promise<ResolvedInertiaPage>;
71
+ export {};
@@ -1,2 +1,2 @@
1
- import { a as NotificationManager, c as setNotificationManager, d as getNotification, f as registerNotification, i as MailChannel, l as resolveNotifiableType, n as SlackChannel, o as createNotificationManager, p as Notification, r as DatabaseChannel, s as getNotificationManager, t as MemoryChannel, u as clearNotificationRegistry } from "../notifications-LHuujttf.js";
1
+ import { a as NotificationManager, c as setNotificationManager, d as getNotification, f as registerNotification, i as MailChannel, l as resolveNotifiableType, n as SlackChannel, o as createNotificationManager, p as Notification, r as DatabaseChannel, s as getNotificationManager, t as MemoryChannel, u as clearNotificationRegistry } from "../notifications-Bp2uamzD.js";
2
2
  export { DatabaseChannel, MailChannel, MemoryChannel, Notification, NotificationManager, SlackChannel, clearNotificationRegistry, createNotificationManager, getNotification, getNotificationManager, registerNotification, resolveNotifiableType, setNotificationManager };