@guren/server 0.2.0-alpha.7 → 1.0.0-rc.9

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 (54) hide show
  1. package/dist/Application-DtWDHXr1.d.ts +2110 -0
  2. package/dist/BroadcastManager-AkIWUGJo.d.ts +466 -0
  3. package/dist/CacheManager-BkvHEOZX.d.ts +244 -0
  4. package/dist/ConsoleKernel-CqCVrdZs.d.ts +207 -0
  5. package/dist/EventManager-CmIoLt7r.d.ts +207 -0
  6. package/dist/Gate-CNkBYf8m.d.ts +268 -0
  7. package/dist/HealthManager-DUyMIzsZ.d.ts +141 -0
  8. package/dist/I18nManager-Dtgzsf5n.d.ts +270 -0
  9. package/dist/LogManager-7mxnkaPM.d.ts +256 -0
  10. package/dist/MailManager-DpMvYiP9.d.ts +292 -0
  11. package/dist/Scheduler-BstvSca7.d.ts +469 -0
  12. package/dist/StorageManager-oZTHqaza.d.ts +337 -0
  13. package/dist/api-token-JOif2CtG.d.ts +1792 -0
  14. package/dist/app-key-CsBfRC_Q.d.ts +214 -0
  15. package/dist/auth/index.d.ts +418 -0
  16. package/dist/auth/index.js +6742 -0
  17. package/dist/authorization/index.d.ts +129 -0
  18. package/dist/authorization/index.js +621 -0
  19. package/dist/broadcasting/index.d.ts +233 -0
  20. package/dist/broadcasting/index.js +907 -0
  21. package/dist/cache/index.d.ts +233 -0
  22. package/dist/cache/index.js +817 -0
  23. package/dist/encryption/index.d.ts +222 -0
  24. package/dist/encryption/index.js +602 -0
  25. package/dist/events/index.d.ts +155 -0
  26. package/dist/events/index.js +330 -0
  27. package/dist/health/index.d.ts +185 -0
  28. package/dist/health/index.js +379 -0
  29. package/dist/i18n/index.d.ts +101 -0
  30. package/dist/i18n/index.js +597 -0
  31. package/dist/index-9_Jzj5jo.d.ts +7 -0
  32. package/dist/index.d.ts +2628 -619
  33. package/dist/index.js +22229 -3116
  34. package/dist/lambda/index.d.ts +156 -0
  35. package/dist/lambda/index.js +91 -0
  36. package/dist/logging/index.d.ts +50 -0
  37. package/dist/logging/index.js +557 -0
  38. package/dist/mail/index.d.ts +288 -0
  39. package/dist/mail/index.js +695 -0
  40. package/dist/mcp/index.d.ts +139 -0
  41. package/dist/mcp/index.js +382 -0
  42. package/dist/notifications/index.d.ts +271 -0
  43. package/dist/notifications/index.js +741 -0
  44. package/dist/queue/index.d.ts +423 -0
  45. package/dist/queue/index.js +958 -0
  46. package/dist/runtime/index.d.ts +93 -0
  47. package/dist/runtime/index.js +834 -0
  48. package/dist/scheduling/index.d.ts +41 -0
  49. package/dist/scheduling/index.js +836 -0
  50. package/dist/storage/index.d.ts +196 -0
  51. package/dist/storage/index.js +832 -0
  52. package/dist/vite/index.js +203 -3
  53. package/package.json +93 -6
  54. package/dist/chunk-FK2XQSBF.js +0 -160
@@ -0,0 +1,129 @@
1
+ import { f as Policy$1, A as AuthUser, a as AuthorizationResponse, G as Gate, b as AuthorizeOptions } from '../Gate-CNkBYf8m.js';
2
+ export { c as GateCallback, d as GateDefinition, e as GateOptions, P as PolicyClass, g as PolicyMethod, h as PolicyRegistration, i as ResourceAction, R as Response, j as ResponseBuilder, k as authorize, l as can, m as cannot, n as createGate, o as defineGate, p as getGate, s as setGate } from '../Gate-CNkBYf8m.js';
3
+ import { Context } from 'hono';
4
+ import { M as Middleware } from '../index-9_Jzj5jo.js';
5
+
6
+ /**
7
+ * Base policy class for model authorization.
8
+ *
9
+ * @example
10
+ * ```typescript
11
+ * class PostPolicy extends Policy {
12
+ * // Runs before all checks - return true/false to short-circuit
13
+ * before(user: AuthUser | null, ability: string) {
14
+ * if (user?.role === 'admin') {
15
+ * return true // Admins can do anything
16
+ * }
17
+ * return undefined // Continue to specific check
18
+ * }
19
+ *
20
+ * viewAny(user: AuthUser | null) {
21
+ * return true // Anyone can view posts list
22
+ * }
23
+ *
24
+ * view(user: AuthUser | null, post: Post) {
25
+ * return post.published || user?.id === post.authorId
26
+ * }
27
+ *
28
+ * create(user: AuthUser | null) {
29
+ * return user !== null
30
+ * }
31
+ *
32
+ * update(user: AuthUser | null, post: Post) {
33
+ * return user?.id === post.authorId
34
+ * }
35
+ *
36
+ * delete(user: AuthUser | null, post: Post) {
37
+ * return user?.id === post.authorId
38
+ * }
39
+ * }
40
+ * ```
41
+ */
42
+ declare abstract class Policy implements Policy$1 {
43
+ /**
44
+ * Perform pre-authorization checks.
45
+ * Return true to allow, false to deny, undefined to continue to specific check.
46
+ */
47
+ before?(user: AuthUser | null, ability: string): boolean | undefined | Promise<boolean | undefined>;
48
+ /**
49
+ * Allow the action.
50
+ */
51
+ protected allow(message?: string): AuthorizationResponse;
52
+ /**
53
+ * Deny the action.
54
+ */
55
+ protected deny(message?: string, code?: string): AuthorizationResponse;
56
+ /**
57
+ * Deny with a specific HTTP status.
58
+ */
59
+ protected denyWithStatus(status: number, message?: string): AuthorizationResponse & {
60
+ status: number;
61
+ };
62
+ /**
63
+ * Deny as not found (404).
64
+ */
65
+ protected denyAsNotFound(message?: string): AuthorizationResponse & {
66
+ status: 404;
67
+ };
68
+ }
69
+ /**
70
+ * Create a simple policy from an object.
71
+ */
72
+ declare function definePolicy<T>(definition: {
73
+ before?: (user: AuthUser | null, ability: string) => boolean | undefined | Promise<boolean | undefined>;
74
+ viewAny?: (user: AuthUser | null) => boolean | Promise<boolean>;
75
+ view?: (user: AuthUser | null, model: T) => boolean | Promise<boolean>;
76
+ create?: (user: AuthUser | null) => boolean | Promise<boolean>;
77
+ update?: (user: AuthUser | null, model: T) => boolean | Promise<boolean>;
78
+ delete?: (user: AuthUser | null, model: T) => boolean | Promise<boolean>;
79
+ restore?: (user: AuthUser | null, model: T) => boolean | Promise<boolean>;
80
+ forceDelete?: (user: AuthUser | null, model: T) => boolean | Promise<boolean>;
81
+ } & Record<string, ((user: AuthUser | null, ...args: any[]) => boolean | undefined | Promise<boolean | undefined>) | undefined>): new () => Policy;
82
+
83
+ /**
84
+ * Middleware to authorize an ability.
85
+ *
86
+ * @example
87
+ * ```typescript
88
+ * // Authorize a simple ability
89
+ * app.get('/admin', authorizeMiddleware('admin'), adminHandler)
90
+ *
91
+ * // Authorize with model (from route param)
92
+ * app.put('/posts/:id', authorizeMiddleware('update', getPost), updateHandler)
93
+ *
94
+ * // Multiple abilities (any)
95
+ * app.get('/dashboard', authorizeMiddleware(['admin', 'moderator']), dashboardHandler)
96
+ * ```
97
+ */
98
+ declare function authorizeMiddleware(ability: string | string[], modelResolver?: (ctx: Context) => unknown | Promise<unknown>, options?: AuthorizeOptions): Middleware;
99
+ /**
100
+ * Middleware to authorize all given abilities.
101
+ */
102
+ declare function authorizeAllMiddleware(abilities: string[], modelResolver?: (ctx: Context) => unknown | Promise<unknown>, options?: AuthorizeOptions): Middleware;
103
+ /**
104
+ * Middleware factory for resource authorization.
105
+ * Automatically maps HTTP methods to policy abilities.
106
+ *
107
+ * @example
108
+ * ```typescript
109
+ * // Authorize resource actions based on HTTP method
110
+ * app.use('/posts/:id', authorizeResourceMiddleware(getPost))
111
+ * // GET -> view, POST -> create, PUT/PATCH -> update, DELETE -> delete
112
+ * ```
113
+ */
114
+ declare function authorizeResourceMiddleware(modelResolver: (ctx: Context) => unknown | Promise<unknown>, options?: AuthorizeOptions): Middleware;
115
+ /**
116
+ * Create a gate-aware context with authorization helpers.
117
+ */
118
+ declare function withAuthorization(gate: Gate): Middleware;
119
+ /**
120
+ * Helper type for context with authorization.
121
+ */
122
+ interface AuthorizedContext extends Context {
123
+ get(key: 'gate'): Gate;
124
+ get(key: 'can'): (ability: string, ...args: unknown[]) => Promise<boolean>;
125
+ get(key: 'cannot'): (ability: string, ...args: unknown[]) => Promise<boolean>;
126
+ get(key: 'authorize'): (ability: string, ...args: unknown[]) => Promise<void>;
127
+ }
128
+
129
+ export { AuthUser, AuthorizationResponse, AuthorizeOptions, type AuthorizedContext, Gate, Policy, Policy$1 as PolicyInterface, authorizeAllMiddleware, authorizeMiddleware, authorizeResourceMiddleware, definePolicy, withAuthorization };