@guren/server 1.0.0-rc.19 → 1.0.0-rc.20

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.
@@ -1362,6 +1362,28 @@ declare class Controller {
1362
1362
  }>(modelClass: T): Awaited<ReturnType<T['findOrFail']>>;
1363
1363
  protected get ctx(): Context;
1364
1364
  protected get request(): hono.HonoRequest<any, unknown>;
1365
+ /**
1366
+ * Get an uploaded file from a multipart request.
1367
+ *
1368
+ * Returns null when the field is missing, is not a file, or the upload is
1369
+ * empty. Hono caches the parsed body, so this composes with other body
1370
+ * reads in the same request.
1371
+ *
1372
+ * @example
1373
+ * ```typescript
1374
+ * const avatar = await this.file('avatar')
1375
+ * if (!avatar) {
1376
+ * throw ValidationException.withMessages({ avatar: 'Choose a file.' })
1377
+ * }
1378
+ * await storage.disk().put(`avatars/${avatar.name}`, Buffer.from(await avatar.arrayBuffer()))
1379
+ * ```
1380
+ */
1381
+ protected file(name: string): Promise<File | null>;
1382
+ /**
1383
+ * Get all uploaded files for a multipart field (e.g. `<input multiple>`).
1384
+ * Returns an empty array when none were uploaded.
1385
+ */
1386
+ protected files(name: string): Promise<File[]>;
1365
1387
  protected get auth(): AuthContext;
1366
1388
  protected make<K extends keyof ServiceBindings>(key: K): ServiceBindings[K];
1367
1389
  protected make<T>(key: string): T;
@@ -1,4 +1,4 @@
1
- import { C as Container } from './Application-CddorcPa.js';
1
+ import { C as Container } from './Application-C8Gja0FE.js';
2
2
 
3
3
  /**
4
4
  * Parsed argument definition.
@@ -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: "1.0.0-rc.19",
9
+ version: "1.0.0-rc.20",
10
10
  type: "module",
11
11
  license: "MIT",
12
12
  repository: {
@@ -111,8 +111,8 @@ var package_default = {
111
111
  test: "bun test"
112
112
  },
113
113
  dependencies: {
114
- "@guren/inertia-client": "^1.0.0-rc.18",
115
- "@guren/orm": "^1.0.0-rc.20",
114
+ "@guren/inertia-client": "^1.0.0-rc.19",
115
+ "@guren/orm": "^1.0.0-rc.21",
116
116
  "@modelcontextprotocol/sdk": "^1.27.1",
117
117
  chalk: "^5.3.0",
118
118
  consola: "^3.4.2",
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { E as ErrorResponse, S as ServiceProvider, C as Container, c as ServiceBindings, Q as QueueManager, N as NotificationManager } from './Application-CddorcPa.js';
2
- export { A as Application, d as ApplicationListenOptions, e as AuthPayload, f as CSRF_FORM_FIELD, g as CSRF_HEADER_NAME, h as CSRF_TOKEN_KEY, P as ContainerProvider, i as ContextualBinding, j as ContextualBindingBuilder, k as ContextualNeedsBuilder, m as Controller, n as ControllerInertiaProps, o as CsrfOptions, p as DatabaseChannelOptions, q as DatabaseNotification, r as ExceptionClass, t as ExceptionHandler, u as ExceptionHandlerOptions, v as ExceptionRenderer, w as ExceptionReporter, F as FailedJob, H as HostAuthorizationOptions, x as HstsOptions, I as InertiaOptions, y as InertiaPagePayload, z as InertiaResponse, B as InertiaSharedProps, J as InertiaSsrContext, K as InertiaSsrOptions, L as InertiaSsrRenderer, M as InertiaSsrResult, O as InferInertiaProps, R as Job, T as JobClass, U as JobFailureHandler, V as JobHandler, W as JobOptions, X as Notifiable, Y as Notification, Z as NotificationAttachment, _ as NotificationChannel, $ as NotificationChannelFactory, a0 as NotificationClass, a1 as NotificationMailMessage, a2 as NotificationManagerOptions, a3 as ProviderManager, a4 as QueueConfig, a5 as QueueDriver, a6 as QueueDriverFactory, a7 as QueuedJob, a8 as RendererRegistration, a9 as ResolvedSharedInertiaProps, aa as ResourceRouteOptions, ab as RouteBuilder, ac as RouteContractOptions, ad as RouteDefinition, ae as RouteOpenApiMetadata, af as RouteResourceAction, ag as Router, ah as SecurityHeadersOptions, ai as SentNotification, aj as ServiceBinding, ak as ServiceClass, al as ServiceFactory, am as ServiceProviderClass, an as ServiceProviderConstructor, ao as ServiceProviderOptions, ap as SharedInertiaPropsResolver, aq as SlackAttachment, ar as SlackBlock, as as SlackMessage, at as VALIDATED_DATA_KEY, au as ValidateRequestOptions, av as ValidationSchema, aw as WorkerOptions, ax as abort, ay as abortIf, az as abortUnless, aA as clearJobRegistry, aB as createApp, aC as createContainer, aD as createCsrfMiddleware, aE as createExceptionHandler, aF as createHostAuthorizationMiddleware, aG as createNotificationManager, aH as createQueueManager, aI as createSecurityHeaders, aJ as csrfField, aK as formatValidationErrors, aL as getContainer, aM as getCsrfToken, aN as getExceptionHandler, aO as getJob, aP as getNotificationManager, aQ as getQueueDriver, aR as getRegisteredJobs, aS as getValidatedData, aT as inertia, aU as parseRequestPayload, aV as registerJob, aW as resolve, aX as setContainer, aY as setExceptionHandler, aZ as setInertiaSharedProps, a_ as setNotificationManager, a$ as setQueueDriver, b0 as validate, b1 as validateRequest, b2 as validateRequestWith, b3 as validateSafe, b4 as verifyCsrfToken } from './Application-CddorcPa.js';
1
+ import { E as ErrorResponse, S as ServiceProvider, C as Container, c as ServiceBindings, Q as QueueManager, N as NotificationManager } from './Application-C8Gja0FE.js';
2
+ export { A as Application, d as ApplicationListenOptions, e as AuthPayload, f as CSRF_FORM_FIELD, g as CSRF_HEADER_NAME, h as CSRF_TOKEN_KEY, P as ContainerProvider, i as ContextualBinding, j as ContextualBindingBuilder, k as ContextualNeedsBuilder, m as Controller, n as ControllerInertiaProps, o as CsrfOptions, p as DatabaseChannelOptions, q as DatabaseNotification, r as ExceptionClass, t as ExceptionHandler, u as ExceptionHandlerOptions, v as ExceptionRenderer, w as ExceptionReporter, F as FailedJob, H as HostAuthorizationOptions, x as HstsOptions, I as InertiaOptions, y as InertiaPagePayload, z as InertiaResponse, B as InertiaSharedProps, J as InertiaSsrContext, K as InertiaSsrOptions, L as InertiaSsrRenderer, M as InertiaSsrResult, O as InferInertiaProps, R as Job, T as JobClass, U as JobFailureHandler, V as JobHandler, W as JobOptions, X as Notifiable, Y as Notification, Z as NotificationAttachment, _ as NotificationChannel, $ as NotificationChannelFactory, a0 as NotificationClass, a1 as NotificationMailMessage, a2 as NotificationManagerOptions, a3 as ProviderManager, a4 as QueueConfig, a5 as QueueDriver, a6 as QueueDriverFactory, a7 as QueuedJob, a8 as RendererRegistration, a9 as ResolvedSharedInertiaProps, aa as ResourceRouteOptions, ab as RouteBuilder, ac as RouteContractOptions, ad as RouteDefinition, ae as RouteOpenApiMetadata, af as RouteResourceAction, ag as Router, ah as SecurityHeadersOptions, ai as SentNotification, aj as ServiceBinding, ak as ServiceClass, al as ServiceFactory, am as ServiceProviderClass, an as ServiceProviderConstructor, ao as ServiceProviderOptions, ap as SharedInertiaPropsResolver, aq as SlackAttachment, ar as SlackBlock, as as SlackMessage, at as VALIDATED_DATA_KEY, au as ValidateRequestOptions, av as ValidationSchema, aw as WorkerOptions, ax as abort, ay as abortIf, az as abortUnless, aA as clearJobRegistry, aB as createApp, aC as createContainer, aD as createCsrfMiddleware, aE as createExceptionHandler, aF as createHostAuthorizationMiddleware, aG as createNotificationManager, aH as createQueueManager, aI as createSecurityHeaders, aJ as csrfField, aK as formatValidationErrors, aL as getContainer, aM as getCsrfToken, aN as getExceptionHandler, aO as getJob, aP as getNotificationManager, aQ as getQueueDriver, aR as getRegisteredJobs, aS as getValidatedData, aT as inertia, aU as parseRequestPayload, aV as registerJob, aW as resolve, aX as setContainer, aY as setExceptionHandler, aZ as setInertiaSharedProps, a_ as setNotificationManager, a$ as setQueueDriver, b0 as validate, b1 as validateRequest, b2 as validateRequestWith, b3 as validateSafe, b4 as verifyCsrfToken } from './Application-C8Gja0FE.js';
3
3
  import * as hono from 'hono';
4
4
  import { Context, MiddlewareHandler } from 'hono';
5
5
  export { Context } from 'hono';
@@ -35,8 +35,8 @@ export { DatabaseChannel, MailChannel, MailChannelOptions, MemoryChannel, SlackC
35
35
  import { B as BroadcastManager } from './BroadcastManager-AkIWUGJo.js';
36
36
  export { A as AuthMiddlewareOptions, a as BroadcastDriver, b as BroadcastDriverFactory, c as BroadcastEvent, d as BroadcastManagerOptions, e as BroadcastableEvent, C as Channel, f as ChannelAuthorizer, g as ChannelRegistration, P as PresenceBroadcastDriver, h as PresenceChannel, i as PresenceChannelAuthorizer, j as PresenceMember, k as PrivateChannel, S as SSEClient, l as SSEMiddlewareOptions, W as WebSocketClient, m as createBroadcastManager, n as getBroadcastManager, s as setBroadcastManager } from './BroadcastManager-AkIWUGJo.js';
37
37
  export { RedisClient as BroadcastRedisClient, RedisDriverOptions as BroadcastRedisDriverOptions, MemoryDriver as MemoryBroadcastDriver, RedisDriver as RedisBroadcastDriver, createTypedBroadcaster } from './broadcasting/index.js';
38
- import { I as InputInterface, P as ParsedSignature, O as OptionDefinition, a as CommandInstance, b as OutputInterface } from './ConsoleKernel-BlCJEZTR.js';
39
- export { A as ArgumentDefinition, c as CommandClass, C as ConsoleKernel, d as ConsoleKernelOptions, e as ProgressInterface, f as PromptInterface, S as ScheduledCommand, g as createConsoleKernel } from './ConsoleKernel-BlCJEZTR.js';
38
+ import { I as InputInterface, P as ParsedSignature, O as OptionDefinition, a as CommandInstance, b as OutputInterface } from './ConsoleKernel-JELd-SXr.js';
39
+ export { A as ArgumentDefinition, c as CommandClass, C as ConsoleKernel, d as ConsoleKernelOptions, e as ProgressInterface, f as PromptInterface, S as ScheduledCommand, g as createConsoleKernel } from './ConsoleKernel-JELd-SXr.js';
40
40
  import * as readline from 'readline';
41
41
  export { R as AuthResponse, A as AuthUser, a as AuthorizationResponse, b as AuthorizeOptions, G as Gate, c as GateCallback, d as GateDefinition, e as GateOptions, P as PolicyClass, f as PolicyInterface, g as PolicyMethod, h as PolicyRegistration, i as ResourceAction, j as ResponseBuilder, k as authorizeAbility, l as can, m as cannot, n as createGate, o as defineGate, p as getGate, s as setGate } from './Gate-CynjZCtS.js';
42
42
  export { AuthorizedContext, Policy, authorizeAllMiddleware, authorizeMiddleware, authorizeResourceMiddleware, definePolicy, withAuthorization } from './authorization/index.js';
package/dist/index.js CHANGED
@@ -102,7 +102,7 @@ import {
102
102
  logDevServerBanner,
103
103
  parseImportMap,
104
104
  startViteDevServer
105
- } from "./chunk-ORR2IYRD.js";
105
+ } from "./chunk-TGQLJOB5.js";
106
106
  import {
107
107
  API_TOKEN_KEY,
108
108
  AuthManager,
@@ -2382,6 +2382,38 @@ var Controller = class {
2382
2382
  get request() {
2383
2383
  return this.ctx.req;
2384
2384
  }
2385
+ /**
2386
+ * Get an uploaded file from a multipart request.
2387
+ *
2388
+ * Returns null when the field is missing, is not a file, or the upload is
2389
+ * empty. Hono caches the parsed body, so this composes with other body
2390
+ * reads in the same request.
2391
+ *
2392
+ * @example
2393
+ * ```typescript
2394
+ * const avatar = await this.file('avatar')
2395
+ * if (!avatar) {
2396
+ * throw ValidationException.withMessages({ avatar: 'Choose a file.' })
2397
+ * }
2398
+ * await storage.disk().put(`avatars/${avatar.name}`, Buffer.from(await avatar.arrayBuffer()))
2399
+ * ```
2400
+ */
2401
+ async file(name) {
2402
+ const body = await this.ctx.req.parseBody({ all: true });
2403
+ const value = body[name];
2404
+ const candidate = Array.isArray(value) ? value[0] : value;
2405
+ return candidate instanceof File && candidate.size > 0 ? candidate : null;
2406
+ }
2407
+ /**
2408
+ * Get all uploaded files for a multipart field (e.g. `<input multiple>`).
2409
+ * Returns an empty array when none were uploaded.
2410
+ */
2411
+ async files(name) {
2412
+ const body = await this.ctx.req.parseBody({ all: true });
2413
+ const value = body[name];
2414
+ const values = Array.isArray(value) ? value : value !== void 0 ? [value] : [];
2415
+ return values.filter((item) => item instanceof File && item.size > 0);
2416
+ }
2385
2417
  get auth() {
2386
2418
  const auth = this.ctx.get(AUTH_CONTEXT_KEY);
2387
2419
  if (!auth) {
@@ -1,8 +1,8 @@
1
1
  import * as hono_aws_lambda from 'hono/aws-lambda';
2
2
  export { APIGatewayProxyResult, LambdaEvent } from 'hono/aws-lambda';
3
- import { A as Application } from '../Application-CddorcPa.js';
3
+ import { A as Application } from '../Application-C8Gja0FE.js';
4
4
  import { S as Scheduler } from '../Scheduler-BstvSca7.js';
5
- import { C as ConsoleKernel } from '../ConsoleKernel-BlCJEZTR.js';
5
+ import { C as ConsoleKernel } from '../ConsoleKernel-JELd-SXr.js';
6
6
  import 'hono';
7
7
  import '../api-token-BGOsfuI9.js';
8
8
  import '@guren/orm';
@@ -1,5 +1,5 @@
1
1
  import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
2
- import { S as ServiceProvider } from '../Application-CddorcPa.js';
2
+ import { S as ServiceProvider } from '../Application-C8Gja0FE.js';
3
3
  import 'hono';
4
4
  import '../api-token-BGOsfuI9.js';
5
5
  import '@guren/orm';
@@ -1,5 +1,5 @@
1
- import { _ as NotificationChannel, X as Notifiable, Y as Notification, q as DatabaseNotification, p as DatabaseChannelOptions, as as SlackMessage, ai as SentNotification } from '../Application-CddorcPa.js';
2
- export { Z as NotificationAttachment, $ as NotificationChannelFactory, a0 as NotificationClass, a1 as NotificationMailMessage, N as NotificationManager, a2 as NotificationManagerOptions, aq as SlackAttachment, ar as SlackBlock, aG as createNotificationManager, aP as getNotificationManager, a_ as setNotificationManager } from '../Application-CddorcPa.js';
1
+ import { _ as NotificationChannel, X as Notifiable, Y as Notification, q as DatabaseNotification, p as DatabaseChannelOptions, as as SlackMessage, ai as SentNotification } from '../Application-C8Gja0FE.js';
2
+ export { Z as NotificationAttachment, $ as NotificationChannelFactory, a0 as NotificationClass, a1 as NotificationMailMessage, N as NotificationManager, a2 as NotificationManagerOptions, aq as SlackAttachment, ar as SlackBlock, aG as createNotificationManager, aP as getNotificationManager, a_ as setNotificationManager } from '../Application-C8Gja0FE.js';
3
3
  import { M as MailManager } from '../MailManager-DpMvYiP9.js';
4
4
  import 'hono';
5
5
  import '../api-token-BGOsfuI9.js';
@@ -1,5 +1,5 @@
1
- import { a5 as QueueDriver, a7 as QueuedJob, F as FailedJob, aw as WorkerOptions } from '../Application-CddorcPa.js';
2
- export { R as Job, T as JobClass, U as JobFailureHandler, V as JobHandler, W as JobOptions, a4 as QueueConfig, a6 as QueueDriverFactory, Q as QueueManager, aA as clearJobRegistry, aH as createQueueManager, aO as getJob, aQ as getQueueDriver, aR as getRegisteredJobs, aV as registerJob, a$ as setQueueDriver } from '../Application-CddorcPa.js';
1
+ import { a5 as QueueDriver, a7 as QueuedJob, F as FailedJob, aw as WorkerOptions } from '../Application-C8Gja0FE.js';
2
+ export { R as Job, T as JobClass, U as JobFailureHandler, V as JobHandler, W as JobOptions, a4 as QueueConfig, a6 as QueueDriverFactory, Q as QueueManager, aA as clearJobRegistry, aH as createQueueManager, aO as getJob, aQ as getQueueDriver, aR as getRegisteredJobs, aV as registerJob, a$ as setQueueDriver } from '../Application-C8Gja0FE.js';
3
3
  import { Redis } from 'ioredis';
4
4
  import 'hono';
5
5
  import '../api-token-BGOsfuI9.js';
@@ -1,5 +1,5 @@
1
- import { A as Application } from '../Application-CddorcPa.js';
2
- export { D as DevBannerOptions, G as GUREN_ASCII_ART, a as StartViteDevServerOptions, b as StartedViteDevServer, l as logDevServerBanner, s as startViteDevServer } from '../Application-CddorcPa.js';
1
+ import { A as Application } from '../Application-C8Gja0FE.js';
2
+ export { D as DevBannerOptions, G as GUREN_ASCII_ART, a as StartViteDevServerOptions, b as StartedViteDevServer, l as logDevServerBanner, s as startViteDevServer } from '../Application-C8Gja0FE.js';
3
3
  import 'hono';
4
4
  import '../api-token-BGOsfuI9.js';
5
5
  import '@guren/orm';
@@ -3,7 +3,7 @@ import {
3
3
  logDevServerBanner,
4
4
  parseImportMap,
5
5
  startViteDevServer
6
- } from "../chunk-ORR2IYRD.js";
6
+ } from "../chunk-TGQLJOB5.js";
7
7
  import {
8
8
  hash
9
9
  } from "../chunk-QQKTH5KX.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@guren/server",
3
- "version": "1.0.0-rc.19",
3
+ "version": "1.0.0-rc.20",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -105,8 +105,8 @@
105
105
  "test": "bun test"
106
106
  },
107
107
  "dependencies": {
108
- "@guren/inertia-client": "^1.0.0-rc.18",
109
- "@guren/orm": "^1.0.0-rc.20",
108
+ "@guren/inertia-client": "^1.0.0-rc.19",
109
+ "@guren/orm": "^1.0.0-rc.21",
110
110
  "@modelcontextprotocol/sdk": "^1.27.1",
111
111
  "chalk": "^5.3.0",
112
112
  "consola": "^3.4.2",