alepha 0.14.3 → 0.14.4

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 (114) hide show
  1. package/README.md +1 -1
  2. package/dist/api/audits/index.d.ts +338 -417
  3. package/dist/api/audits/index.d.ts.map +1 -1
  4. package/dist/api/files/index.d.ts +1 -80
  5. package/dist/api/files/index.d.ts.map +1 -1
  6. package/dist/api/jobs/index.d.ts +156 -235
  7. package/dist/api/jobs/index.d.ts.map +1 -1
  8. package/dist/api/notifications/index.d.ts +170 -249
  9. package/dist/api/notifications/index.d.ts.map +1 -1
  10. package/dist/api/parameters/index.d.ts +266 -345
  11. package/dist/api/parameters/index.d.ts.map +1 -1
  12. package/dist/api/users/index.d.ts +755 -834
  13. package/dist/api/users/index.d.ts.map +1 -1
  14. package/dist/api/verifications/index.d.ts +125 -125
  15. package/dist/api/verifications/index.d.ts.map +1 -1
  16. package/dist/cli/index.d.ts +116 -20
  17. package/dist/cli/index.d.ts.map +1 -1
  18. package/dist/cli/index.js +212 -124
  19. package/dist/cli/index.js.map +1 -1
  20. package/dist/command/index.d.ts +6 -11
  21. package/dist/command/index.d.ts.map +1 -1
  22. package/dist/command/index.js +2 -2
  23. package/dist/command/index.js.map +1 -1
  24. package/dist/core/index.browser.js +26 -4
  25. package/dist/core/index.browser.js.map +1 -1
  26. package/dist/core/index.d.ts +16 -1
  27. package/dist/core/index.d.ts.map +1 -1
  28. package/dist/core/index.js +26 -4
  29. package/dist/core/index.js.map +1 -1
  30. package/dist/core/index.native.js +26 -4
  31. package/dist/core/index.native.js.map +1 -1
  32. package/dist/logger/index.d.ts +1 -1
  33. package/dist/logger/index.d.ts.map +1 -1
  34. package/dist/logger/index.js +12 -2
  35. package/dist/logger/index.js.map +1 -1
  36. package/dist/mcp/index.d.ts.map +1 -1
  37. package/dist/mcp/index.js +1 -1
  38. package/dist/mcp/index.js.map +1 -1
  39. package/dist/orm/index.d.ts +37 -173
  40. package/dist/orm/index.d.ts.map +1 -1
  41. package/dist/orm/index.js +193 -422
  42. package/dist/orm/index.js.map +1 -1
  43. package/dist/server/auth/index.d.ts +167 -167
  44. package/dist/server/cache/index.d.ts +12 -0
  45. package/dist/server/cache/index.d.ts.map +1 -1
  46. package/dist/server/cache/index.js +55 -2
  47. package/dist/server/cache/index.js.map +1 -1
  48. package/dist/server/compress/index.d.ts +6 -0
  49. package/dist/server/compress/index.d.ts.map +1 -1
  50. package/dist/server/compress/index.js +36 -1
  51. package/dist/server/compress/index.js.map +1 -1
  52. package/dist/server/core/index.browser.js +2 -2
  53. package/dist/server/core/index.browser.js.map +1 -1
  54. package/dist/server/core/index.d.ts +10 -10
  55. package/dist/server/core/index.d.ts.map +1 -1
  56. package/dist/server/core/index.js +6 -3
  57. package/dist/server/core/index.js.map +1 -1
  58. package/dist/server/links/index.d.ts +39 -39
  59. package/dist/server/links/index.d.ts.map +1 -1
  60. package/dist/server/security/index.d.ts +9 -9
  61. package/dist/server/static/index.d.ts.map +1 -1
  62. package/dist/server/static/index.js +4 -0
  63. package/dist/server/static/index.js.map +1 -1
  64. package/dist/server/swagger/index.d.ts.map +1 -1
  65. package/dist/server/swagger/index.js +2 -3
  66. package/dist/server/swagger/index.js.map +1 -1
  67. package/dist/vite/index.d.ts +101 -106
  68. package/dist/vite/index.d.ts.map +1 -1
  69. package/dist/vite/index.js +571 -508
  70. package/dist/vite/index.js.map +1 -1
  71. package/package.json +1 -1
  72. package/src/cli/apps/AlephaCli.ts +0 -2
  73. package/src/cli/atoms/buildOptions.ts +88 -0
  74. package/src/cli/commands/build.ts +32 -69
  75. package/src/cli/commands/db.ts +0 -4
  76. package/src/cli/commands/dev.ts +16 -4
  77. package/src/cli/commands/gen/env.ts +53 -0
  78. package/src/cli/commands/gen/openapi.ts +1 -1
  79. package/src/cli/commands/gen/resource.ts +15 -0
  80. package/src/cli/commands/gen.ts +7 -1
  81. package/src/cli/commands/init.ts +0 -1
  82. package/src/cli/commands/test.ts +0 -1
  83. package/src/cli/commands/verify.ts +1 -1
  84. package/src/cli/defineConfig.ts +49 -7
  85. package/src/cli/index.ts +0 -1
  86. package/src/cli/services/AlephaCliUtils.ts +36 -25
  87. package/src/command/helpers/Runner.spec.ts +2 -2
  88. package/src/command/helpers/Runner.ts +1 -1
  89. package/src/command/primitives/$command.ts +0 -6
  90. package/src/command/providers/CliProvider.ts +1 -3
  91. package/src/core/Alepha.ts +42 -0
  92. package/src/logger/index.ts +15 -3
  93. package/src/mcp/transports/StdioMcpTransport.ts +1 -1
  94. package/src/orm/index.ts +2 -8
  95. package/src/queue/core/providers/WorkerProvider.spec.ts +48 -32
  96. package/src/server/cache/providers/ServerCacheProvider.spec.ts +183 -0
  97. package/src/server/cache/providers/ServerCacheProvider.ts +94 -9
  98. package/src/server/compress/providers/ServerCompressProvider.ts +61 -2
  99. package/src/server/core/helpers/ServerReply.ts +2 -2
  100. package/src/server/core/providers/ServerProvider.ts +11 -1
  101. package/src/server/static/providers/ServerStaticProvider.ts +10 -0
  102. package/src/server/swagger/providers/ServerSwaggerProvider.ts +5 -8
  103. package/src/vite/helpers/importViteReact.ts +13 -0
  104. package/src/vite/index.ts +1 -21
  105. package/src/vite/plugins/viteAlephaDev.ts +16 -1
  106. package/src/vite/plugins/viteAlephaSsrPreload.ts +222 -0
  107. package/src/vite/tasks/buildClient.ts +11 -0
  108. package/src/vite/tasks/buildServer.ts +47 -3
  109. package/src/vite/tasks/devServer.ts +69 -0
  110. package/src/vite/tasks/index.ts +2 -1
  111. package/src/cli/assets/viteConfigTs.ts +0 -14
  112. package/src/cli/commands/run.ts +0 -24
  113. package/src/vite/plugins/viteAlepha.ts +0 -37
  114. package/src/vite/plugins/viteAlephaBuild.ts +0 -281
@@ -1,4 +1,4 @@
1
- import * as alepha181 from "alepha";
1
+ import * as alepha165 from "alepha";
2
2
  import { Alepha, Async, KIND, Primitive, Static } from "alepha";
3
3
  import * as alepha_server_cookies0 from "alepha/server/cookies";
4
4
  import { Cookies, ServerCookiesProvider } from "alepha/server/cookies";
@@ -20,45 +20,45 @@ declare const alephaServerAuthRoutes: {
20
20
  };
21
21
  //#endregion
22
22
  //#region ../../src/server/auth/schemas/authenticationProviderSchema.d.ts
23
- declare const authenticationProviderSchema: alepha181.TObject<{
24
- name: alepha181.TString;
25
- type: alepha181.TUnsafe<"OAUTH2" | "OIDC" | "CREDENTIALS">;
23
+ declare const authenticationProviderSchema: alepha165.TObject<{
24
+ name: alepha165.TString;
25
+ type: alepha165.TUnsafe<"OAUTH2" | "OIDC" | "CREDENTIALS">;
26
26
  }>;
27
27
  type AuthenticationProvider = Static<typeof authenticationProviderSchema>;
28
28
  //#endregion
29
29
  //#region ../../src/server/auth/schemas/tokenResponseSchema.d.ts
30
- declare const tokenResponseSchema: alepha181.TObject<{
31
- provider: alepha181.TString;
32
- access_token: alepha181.TString;
33
- issued_at: alepha181.TNumber;
34
- expires_in: alepha181.TOptional<alepha181.TNumber>;
35
- refresh_token: alepha181.TOptional<alepha181.TString>;
36
- refresh_token_expires_in: alepha181.TOptional<alepha181.TNumber>;
37
- refresh_expires_in: alepha181.TOptional<alepha181.TNumber>;
38
- id_token: alepha181.TOptional<alepha181.TString>;
39
- scope: alepha181.TOptional<alepha181.TString>;
40
- user: alepha181.TObject<{
41
- id: alepha181.TString;
42
- name: alepha181.TOptional<alepha181.TString>;
43
- email: alepha181.TOptional<alepha181.TString>;
44
- username: alepha181.TOptional<alepha181.TString>;
45
- picture: alepha181.TOptional<alepha181.TString>;
46
- sessionId: alepha181.TOptional<alepha181.TString>;
47
- organizations: alepha181.TOptional<alepha181.TArray<alepha181.TString>>;
48
- roles: alepha181.TOptional<alepha181.TArray<alepha181.TString>>;
30
+ declare const tokenResponseSchema: alepha165.TObject<{
31
+ provider: alepha165.TString;
32
+ access_token: alepha165.TString;
33
+ issued_at: alepha165.TNumber;
34
+ expires_in: alepha165.TOptional<alepha165.TNumber>;
35
+ refresh_token: alepha165.TOptional<alepha165.TString>;
36
+ refresh_token_expires_in: alepha165.TOptional<alepha165.TNumber>;
37
+ refresh_expires_in: alepha165.TOptional<alepha165.TNumber>;
38
+ id_token: alepha165.TOptional<alepha165.TString>;
39
+ scope: alepha165.TOptional<alepha165.TString>;
40
+ user: alepha165.TObject<{
41
+ id: alepha165.TString;
42
+ name: alepha165.TOptional<alepha165.TString>;
43
+ email: alepha165.TOptional<alepha165.TString>;
44
+ username: alepha165.TOptional<alepha165.TString>;
45
+ picture: alepha165.TOptional<alepha165.TString>;
46
+ sessionId: alepha165.TOptional<alepha165.TString>;
47
+ organizations: alepha165.TOptional<alepha165.TArray<alepha165.TString>>;
48
+ roles: alepha165.TOptional<alepha165.TArray<alepha165.TString>>;
49
49
  }>;
50
- api: alepha181.TObject<{
51
- prefix: alepha181.TOptional<alepha181.TString>;
52
- links: alepha181.TArray<alepha181.TObject<{
53
- name: alepha181.TString;
54
- group: alepha181.TOptional<alepha181.TString>;
55
- path: alepha181.TString;
56
- method: alepha181.TOptional<alepha181.TString>;
57
- requestBodyType: alepha181.TOptional<alepha181.TString>;
58
- service: alepha181.TOptional<alepha181.TString>;
59
- rawSchema: alepha181.TOptional<alepha181.TObject<{
60
- body: alepha181.TOptional<alepha181.TString>;
61
- response: alepha181.TOptional<alepha181.TString>;
50
+ api: alepha165.TObject<{
51
+ prefix: alepha165.TOptional<alepha165.TString>;
52
+ links: alepha165.TArray<alepha165.TObject<{
53
+ name: alepha165.TString;
54
+ group: alepha165.TOptional<alepha165.TString>;
55
+ path: alepha165.TString;
56
+ method: alepha165.TOptional<alepha165.TString>;
57
+ requestBodyType: alepha165.TOptional<alepha165.TString>;
58
+ service: alepha165.TOptional<alepha165.TString>;
59
+ rawSchema: alepha165.TOptional<alepha165.TObject<{
60
+ body: alepha165.TOptional<alepha165.TString>;
61
+ response: alepha165.TOptional<alepha165.TString>;
62
62
  }>>;
63
63
  }>>;
64
64
  }>;
@@ -66,43 +66,43 @@ declare const tokenResponseSchema: alepha181.TObject<{
66
66
  type TokenResponse = Static<typeof tokenResponseSchema>;
67
67
  //#endregion
68
68
  //#region ../../src/server/auth/schemas/tokensSchema.d.ts
69
- declare const tokensSchema: alepha181.TObject<{
70
- provider: alepha181.TString;
71
- access_token: alepha181.TString;
72
- issued_at: alepha181.TNumber;
73
- expires_in: alepha181.TOptional<alepha181.TNumber>;
74
- refresh_token: alepha181.TOptional<alepha181.TString>;
75
- refresh_token_expires_in: alepha181.TOptional<alepha181.TNumber>;
76
- refresh_expires_in: alepha181.TOptional<alepha181.TNumber>;
77
- id_token: alepha181.TOptional<alepha181.TString>;
78
- scope: alepha181.TOptional<alepha181.TString>;
69
+ declare const tokensSchema: alepha165.TObject<{
70
+ provider: alepha165.TString;
71
+ access_token: alepha165.TString;
72
+ issued_at: alepha165.TNumber;
73
+ expires_in: alepha165.TOptional<alepha165.TNumber>;
74
+ refresh_token: alepha165.TOptional<alepha165.TString>;
75
+ refresh_token_expires_in: alepha165.TOptional<alepha165.TNumber>;
76
+ refresh_expires_in: alepha165.TOptional<alepha165.TNumber>;
77
+ id_token: alepha165.TOptional<alepha165.TString>;
78
+ scope: alepha165.TOptional<alepha165.TString>;
79
79
  }>;
80
80
  type Tokens = Static<typeof tokensSchema>;
81
81
  //#endregion
82
82
  //#region ../../src/server/auth/schemas/userinfoResponseSchema.d.ts
83
- declare const userinfoResponseSchema: alepha181.TObject<{
84
- user: alepha181.TOptional<alepha181.TObject<{
85
- id: alepha181.TString;
86
- name: alepha181.TOptional<alepha181.TString>;
87
- email: alepha181.TOptional<alepha181.TString>;
88
- username: alepha181.TOptional<alepha181.TString>;
89
- picture: alepha181.TOptional<alepha181.TString>;
90
- sessionId: alepha181.TOptional<alepha181.TString>;
91
- organizations: alepha181.TOptional<alepha181.TArray<alepha181.TString>>;
92
- roles: alepha181.TOptional<alepha181.TArray<alepha181.TString>>;
83
+ declare const userinfoResponseSchema: alepha165.TObject<{
84
+ user: alepha165.TOptional<alepha165.TObject<{
85
+ id: alepha165.TString;
86
+ name: alepha165.TOptional<alepha165.TString>;
87
+ email: alepha165.TOptional<alepha165.TString>;
88
+ username: alepha165.TOptional<alepha165.TString>;
89
+ picture: alepha165.TOptional<alepha165.TString>;
90
+ sessionId: alepha165.TOptional<alepha165.TString>;
91
+ organizations: alepha165.TOptional<alepha165.TArray<alepha165.TString>>;
92
+ roles: alepha165.TOptional<alepha165.TArray<alepha165.TString>>;
93
93
  }>>;
94
- api: alepha181.TObject<{
95
- prefix: alepha181.TOptional<alepha181.TString>;
96
- links: alepha181.TArray<alepha181.TObject<{
97
- name: alepha181.TString;
98
- group: alepha181.TOptional<alepha181.TString>;
99
- path: alepha181.TString;
100
- method: alepha181.TOptional<alepha181.TString>;
101
- requestBodyType: alepha181.TOptional<alepha181.TString>;
102
- service: alepha181.TOptional<alepha181.TString>;
103
- rawSchema: alepha181.TOptional<alepha181.TObject<{
104
- body: alepha181.TOptional<alepha181.TString>;
105
- response: alepha181.TOptional<alepha181.TString>;
94
+ api: alepha165.TObject<{
95
+ prefix: alepha165.TOptional<alepha165.TString>;
96
+ links: alepha165.TArray<alepha165.TObject<{
97
+ name: alepha165.TString;
98
+ group: alepha165.TOptional<alepha165.TString>;
99
+ path: alepha165.TString;
100
+ method: alepha165.TOptional<alepha165.TString>;
101
+ requestBodyType: alepha165.TOptional<alepha165.TString>;
102
+ service: alepha165.TOptional<alepha165.TString>;
103
+ rawSchema: alepha165.TOptional<alepha165.TObject<{
104
+ body: alepha165.TOptional<alepha165.TString>;
105
+ response: alepha165.TOptional<alepha165.TString>;
106
106
  }>>;
107
107
  }>>;
108
108
  }>;
@@ -116,35 +116,35 @@ declare class ServerAuthProvider {
116
116
  protected readonly serverCookiesProvider: ServerCookiesProvider;
117
117
  protected readonly dateTimeProvider: DateTimeProvider;
118
118
  protected readonly serverLinksProvider: ServerLinksProvider;
119
- protected readonly authorizationCode: alepha_server_cookies0.AbstractCookiePrimitive<alepha181.TObject<{
120
- provider: alepha181.TString;
121
- realm: alepha181.TOptional<alepha181.TString>;
122
- codeVerifier: alepha181.TOptional<alepha181.TString>;
123
- redirectUri: alepha181.TOptional<alepha181.TString>;
124
- state: alepha181.TOptional<alepha181.TString>;
125
- nonce: alepha181.TOptional<alepha181.TString>;
119
+ protected readonly authorizationCode: alepha_server_cookies0.AbstractCookiePrimitive<alepha165.TObject<{
120
+ provider: alepha165.TString;
121
+ realm: alepha165.TOptional<alepha165.TString>;
122
+ codeVerifier: alepha165.TOptional<alepha165.TString>;
123
+ redirectUri: alepha165.TOptional<alepha165.TString>;
124
+ state: alepha165.TOptional<alepha165.TString>;
125
+ nonce: alepha165.TOptional<alepha165.TString>;
126
126
  }>>;
127
- readonly tokens: alepha_server_cookies0.AbstractCookiePrimitive<alepha181.TObject<{
128
- provider: alepha181.TString;
129
- access_token: alepha181.TString;
130
- issued_at: alepha181.TNumber;
131
- expires_in: alepha181.TOptional<alepha181.TNumber>;
132
- refresh_token: alepha181.TOptional<alepha181.TString>;
133
- refresh_token_expires_in: alepha181.TOptional<alepha181.TNumber>;
134
- refresh_expires_in: alepha181.TOptional<alepha181.TNumber>;
135
- id_token: alepha181.TOptional<alepha181.TString>;
136
- scope: alepha181.TOptional<alepha181.TString>;
127
+ readonly tokens: alepha_server_cookies0.AbstractCookiePrimitive<alepha165.TObject<{
128
+ provider: alepha165.TString;
129
+ access_token: alepha165.TString;
130
+ issued_at: alepha165.TNumber;
131
+ expires_in: alepha165.TOptional<alepha165.TNumber>;
132
+ refresh_token: alepha165.TOptional<alepha165.TString>;
133
+ refresh_token_expires_in: alepha165.TOptional<alepha165.TNumber>;
134
+ refresh_expires_in: alepha165.TOptional<alepha165.TNumber>;
135
+ id_token: alepha165.TOptional<alepha165.TString>;
136
+ scope: alepha165.TOptional<alepha165.TString>;
137
137
  }>>;
138
138
  get identities(): Array<AuthPrimitive>;
139
139
  getAuthenticationProviders(filters?: {
140
140
  realmName?: string;
141
141
  }): AuthenticationProvider[];
142
- protected readonly configure: alepha181.HookPrimitive<"configure">;
142
+ protected readonly configure: alepha165.HookPrimitive<"configure">;
143
143
  protected getAccessTokens(tokens: Tokens): string | undefined;
144
144
  /**
145
145
  * Fill request headers with access token from cookies or fallback to provider's fallback function.
146
146
  */
147
- protected readonly onRequest: alepha181.HookPrimitive<"server:onRequest">;
147
+ protected readonly onRequest: alepha165.HookPrimitive<"server:onRequest">;
148
148
  /**
149
149
  * Convert cookies to tokens.
150
150
  * If the tokens are expired, try to refresh them using the refresh token.
@@ -155,29 +155,29 @@ declare class ServerAuthProvider {
155
155
  * Get user information.
156
156
  */
157
157
  readonly userinfo: alepha_server0.RoutePrimitive<{
158
- response: alepha181.TObject<{
159
- user: alepha181.TOptional<alepha181.TObject<{
160
- id: alepha181.TString;
161
- name: alepha181.TOptional<alepha181.TString>;
162
- email: alepha181.TOptional<alepha181.TString>;
163
- username: alepha181.TOptional<alepha181.TString>;
164
- picture: alepha181.TOptional<alepha181.TString>;
165
- sessionId: alepha181.TOptional<alepha181.TString>;
166
- organizations: alepha181.TOptional<alepha181.TArray<alepha181.TString>>;
167
- roles: alepha181.TOptional<alepha181.TArray<alepha181.TString>>;
158
+ response: alepha165.TObject<{
159
+ user: alepha165.TOptional<alepha165.TObject<{
160
+ id: alepha165.TString;
161
+ name: alepha165.TOptional<alepha165.TString>;
162
+ email: alepha165.TOptional<alepha165.TString>;
163
+ username: alepha165.TOptional<alepha165.TString>;
164
+ picture: alepha165.TOptional<alepha165.TString>;
165
+ sessionId: alepha165.TOptional<alepha165.TString>;
166
+ organizations: alepha165.TOptional<alepha165.TArray<alepha165.TString>>;
167
+ roles: alepha165.TOptional<alepha165.TArray<alepha165.TString>>;
168
168
  }>>;
169
- api: alepha181.TObject<{
170
- prefix: alepha181.TOptional<alepha181.TString>;
171
- links: alepha181.TArray<alepha181.TObject<{
172
- name: alepha181.TString;
173
- group: alepha181.TOptional<alepha181.TString>;
174
- path: alepha181.TString;
175
- method: alepha181.TOptional<alepha181.TString>;
176
- requestBodyType: alepha181.TOptional<alepha181.TString>;
177
- service: alepha181.TOptional<alepha181.TString>;
178
- rawSchema: alepha181.TOptional<alepha181.TObject<{
179
- body: alepha181.TOptional<alepha181.TString>;
180
- response: alepha181.TOptional<alepha181.TString>;
169
+ api: alepha165.TObject<{
170
+ prefix: alepha165.TOptional<alepha165.TString>;
171
+ links: alepha165.TArray<alepha165.TObject<{
172
+ name: alepha165.TString;
173
+ group: alepha165.TOptional<alepha165.TString>;
174
+ path: alepha165.TString;
175
+ method: alepha165.TOptional<alepha165.TString>;
176
+ requestBodyType: alepha165.TOptional<alepha165.TString>;
177
+ service: alepha165.TOptional<alepha165.TString>;
178
+ rawSchema: alepha165.TOptional<alepha165.TObject<{
179
+ body: alepha165.TOptional<alepha165.TString>;
180
+ response: alepha165.TOptional<alepha165.TString>;
181
181
  }>>;
182
182
  }>>;
183
183
  }>;
@@ -187,69 +187,69 @@ declare class ServerAuthProvider {
187
187
  * Refresh a token for internal providers.
188
188
  */
189
189
  readonly refresh: alepha_server0.RoutePrimitive<{
190
- query: alepha181.TObject<{
191
- provider: alepha181.TString;
190
+ query: alepha165.TObject<{
191
+ provider: alepha165.TString;
192
192
  }>;
193
- body: alepha181.TObject<{
194
- refresh_token: alepha181.TString;
195
- access_token: alepha181.TOptional<alepha181.TString>;
193
+ body: alepha165.TObject<{
194
+ refresh_token: alepha165.TString;
195
+ access_token: alepha165.TOptional<alepha165.TString>;
196
196
  }>;
197
- response: alepha181.TObject<{
198
- provider: alepha181.TString;
199
- access_token: alepha181.TString;
200
- issued_at: alepha181.TNumber;
201
- expires_in: alepha181.TOptional<alepha181.TNumber>;
202
- refresh_token: alepha181.TOptional<alepha181.TString>;
203
- refresh_token_expires_in: alepha181.TOptional<alepha181.TNumber>;
204
- refresh_expires_in: alepha181.TOptional<alepha181.TNumber>;
205
- id_token: alepha181.TOptional<alepha181.TString>;
206
- scope: alepha181.TOptional<alepha181.TString>;
197
+ response: alepha165.TObject<{
198
+ provider: alepha165.TString;
199
+ access_token: alepha165.TString;
200
+ issued_at: alepha165.TNumber;
201
+ expires_in: alepha165.TOptional<alepha165.TNumber>;
202
+ refresh_token: alepha165.TOptional<alepha165.TString>;
203
+ refresh_token_expires_in: alepha165.TOptional<alepha165.TNumber>;
204
+ refresh_expires_in: alepha165.TOptional<alepha165.TNumber>;
205
+ id_token: alepha165.TOptional<alepha165.TString>;
206
+ scope: alepha165.TOptional<alepha165.TString>;
207
207
  }>;
208
208
  }>;
209
209
  /**
210
210
  * Login for local password-based authentication.
211
211
  */
212
212
  readonly token: alepha_server0.RoutePrimitive<{
213
- query: alepha181.TObject<{
214
- provider: alepha181.TString;
215
- realm: alepha181.TOptional<alepha181.TString>;
213
+ query: alepha165.TObject<{
214
+ provider: alepha165.TString;
215
+ realm: alepha165.TOptional<alepha165.TString>;
216
216
  }>;
217
- body: alepha181.TObject<{
218
- username: alepha181.TString;
219
- password: alepha181.TString;
217
+ body: alepha165.TObject<{
218
+ username: alepha165.TString;
219
+ password: alepha165.TString;
220
220
  }>;
221
- response: alepha181.TObject<{
222
- provider: alepha181.TString;
223
- access_token: alepha181.TString;
224
- issued_at: alepha181.TNumber;
225
- expires_in: alepha181.TOptional<alepha181.TNumber>;
226
- refresh_token: alepha181.TOptional<alepha181.TString>;
227
- refresh_token_expires_in: alepha181.TOptional<alepha181.TNumber>;
228
- refresh_expires_in: alepha181.TOptional<alepha181.TNumber>;
229
- id_token: alepha181.TOptional<alepha181.TString>;
230
- scope: alepha181.TOptional<alepha181.TString>;
231
- user: alepha181.TObject<{
232
- id: alepha181.TString;
233
- name: alepha181.TOptional<alepha181.TString>;
234
- email: alepha181.TOptional<alepha181.TString>;
235
- username: alepha181.TOptional<alepha181.TString>;
236
- picture: alepha181.TOptional<alepha181.TString>;
237
- sessionId: alepha181.TOptional<alepha181.TString>;
238
- organizations: alepha181.TOptional<alepha181.TArray<alepha181.TString>>;
239
- roles: alepha181.TOptional<alepha181.TArray<alepha181.TString>>;
221
+ response: alepha165.TObject<{
222
+ provider: alepha165.TString;
223
+ access_token: alepha165.TString;
224
+ issued_at: alepha165.TNumber;
225
+ expires_in: alepha165.TOptional<alepha165.TNumber>;
226
+ refresh_token: alepha165.TOptional<alepha165.TString>;
227
+ refresh_token_expires_in: alepha165.TOptional<alepha165.TNumber>;
228
+ refresh_expires_in: alepha165.TOptional<alepha165.TNumber>;
229
+ id_token: alepha165.TOptional<alepha165.TString>;
230
+ scope: alepha165.TOptional<alepha165.TString>;
231
+ user: alepha165.TObject<{
232
+ id: alepha165.TString;
233
+ name: alepha165.TOptional<alepha165.TString>;
234
+ email: alepha165.TOptional<alepha165.TString>;
235
+ username: alepha165.TOptional<alepha165.TString>;
236
+ picture: alepha165.TOptional<alepha165.TString>;
237
+ sessionId: alepha165.TOptional<alepha165.TString>;
238
+ organizations: alepha165.TOptional<alepha165.TArray<alepha165.TString>>;
239
+ roles: alepha165.TOptional<alepha165.TArray<alepha165.TString>>;
240
240
  }>;
241
- api: alepha181.TObject<{
242
- prefix: alepha181.TOptional<alepha181.TString>;
243
- links: alepha181.TArray<alepha181.TObject<{
244
- name: alepha181.TString;
245
- group: alepha181.TOptional<alepha181.TString>;
246
- path: alepha181.TString;
247
- method: alepha181.TOptional<alepha181.TString>;
248
- requestBodyType: alepha181.TOptional<alepha181.TString>;
249
- service: alepha181.TOptional<alepha181.TString>;
250
- rawSchema: alepha181.TOptional<alepha181.TObject<{
251
- body: alepha181.TOptional<alepha181.TString>;
252
- response: alepha181.TOptional<alepha181.TString>;
241
+ api: alepha165.TObject<{
242
+ prefix: alepha165.TOptional<alepha165.TString>;
243
+ links: alepha165.TArray<alepha165.TObject<{
244
+ name: alepha165.TString;
245
+ group: alepha165.TOptional<alepha165.TString>;
246
+ path: alepha165.TString;
247
+ method: alepha165.TOptional<alepha165.TString>;
248
+ requestBodyType: alepha165.TOptional<alepha165.TString>;
249
+ service: alepha165.TOptional<alepha165.TString>;
250
+ rawSchema: alepha165.TOptional<alepha165.TObject<{
251
+ body: alepha165.TOptional<alepha165.TString>;
252
+ response: alepha165.TOptional<alepha165.TString>;
253
253
  }>>;
254
254
  }>>;
255
255
  }>;
@@ -259,10 +259,10 @@ declare class ServerAuthProvider {
259
259
  * Oauth2/OIDC login route.
260
260
  */
261
261
  readonly login: alepha_server0.RoutePrimitive<{
262
- query: alepha181.TObject<{
263
- provider: alepha181.TString;
264
- realm: alepha181.TOptional<alepha181.TString>;
265
- redirect_uri: alepha181.TOptional<alepha181.TString>;
262
+ query: alepha165.TObject<{
263
+ provider: alepha165.TString;
264
+ realm: alepha165.TOptional<alepha165.TString>;
265
+ redirect_uri: alepha165.TOptional<alepha165.TString>;
266
266
  }>;
267
267
  }>;
268
268
  /**
@@ -274,8 +274,8 @@ declare class ServerAuthProvider {
274
274
  * Logout route for OAuth2/OIDC providers.
275
275
  */
276
276
  readonly logout: alepha_server0.RoutePrimitive<{
277
- query: alepha181.TObject<{
278
- post_logout_redirect_uri: alepha181.TOptional<alepha181.TString>;
277
+ query: alepha165.TObject<{
278
+ post_logout_redirect_uri: alepha165.TOptional<alepha165.TString>;
279
279
  }>;
280
280
  }>;
281
281
  /**
@@ -604,7 +604,7 @@ declare module "alepha" {
604
604
  * @see {@link ServerAuthProvider}
605
605
  * @module alepha.server.auth
606
606
  */
607
- declare const AlephaServerAuth: alepha181.Service<alepha181.Module>;
607
+ declare const AlephaServerAuth: alepha165.Service<alepha165.Module>;
608
608
  //#endregion
609
609
  export { $auth, $authCredentials, $authGithub, $authGoogle, AccessToken, AlephaServerAuth, AuthExternal, AuthInternal, AuthPrimitive, AuthPrimitiveOptions, AuthenticationProvider, Credentials, CredentialsFn, CredentialsOptions, LinkAccountFn, LinkAccountOptions, OAuth2Options, OAuth2Profile, OidcOptions, ServerAuthProvider, TokenResponse, Tokens, UserinfoResponse, WithLinkFn, WithLoginFn, alephaServerAuthRoutes, authenticationProviderSchema, tokenResponseSchema, tokensSchema, userinfoResponseSchema };
610
610
  //# sourceMappingURL=index.d.ts.map
@@ -40,6 +40,18 @@ declare class ServerCacheProvider {
40
40
  protected shouldStore(cache?: ServerRouteCache): boolean;
41
41
  protected shouldUseEtag(cache?: ServerRouteCache): boolean;
42
42
  protected createCacheKey(route: ServerRoute, config?: ServerRequest): string;
43
+ /**
44
+ * Collect a ReadableStream into a string and store it in the cache.
45
+ * This runs in the background while the original stream is sent to the client.
46
+ *
47
+ * @param stream - The stream to collect
48
+ * @param key - Cache key
49
+ * @param status - HTTP status code
50
+ * @param contentType - Content-Type header
51
+ * @param generateEtag - Whether to generate and return an ETag
52
+ * @returns The generated ETag hash, or undefined
53
+ */
54
+ protected collectStreamForCache(stream: ReadableStream<Uint8Array>, key: string, status: number | undefined, contentType: string | undefined, generateEtag: boolean): Promise<string | undefined>;
43
55
  }
44
56
  type ServerRouteCache =
45
57
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","names":[],"sources":["../../../src/server/cache/providers/ServerCacheProvider.ts","../../../src/server/cache/index.ts"],"sourcesContent":[],"mappings":";;;;;;;;;;;;;;;AAWuB;;;;IAgBqB,KAAA,CAAA,EAHhC,gBAGgC;EACtB;EAAO,UAAA,eAAA,CAAA,gBADe,mBACf,CAAA,CAAA;IAAA,UAAA,EAAA,GAAA,GAAP,OAAO,CAAA,IAAA,CAAA;EAAA;AAY7B;AAAgC,cAAnB,mBAAA,CACW;EACG,mBAAA,GAAA,EAFK,cAAA,CACR,MACG;EACF,mBAAA,MAAA,EADE,MACF;EACC,mBAAA,IAAA,EADD,gBACC;EAAA,mBAAA,KAAA,EAAA,aAAA,CAAA,gBAAA,CAAA,eAAA,EAAA,GAAA,EAAA,CAAA;EAIK,YAAA,CAAA,OAAA,EAAA,UAAA,CAAA,EAAA,MAAA;EAIE,UAAA,CAAA,KAAA,EAAA,WAAA,CAAA,EAAW,OAAX,CAAA,IAAA,CAAA;EAAW,mBAAA,eAAA,EAAA,OAAA,CASR,aATQ,CAAA,kBAAA,CAAA;EAAA,mBASR,gBAAA,EAAA,OAAA,CAkCC,aAlCD,CAAA,mBAAA,CAAA;EAAA,mBAkCC,SAAA,EAAA,OAAA,CAiDP,aAjDO,CAAA,kBAAA,CAAA;EAAA,mBAiDP,MAAA,EAAA,OAAA,CA4DH,aA5DG,CAAA,eAAA,CAAA;EAAA,mBA4DH,UAAA,EAAA,OAAA,CAuCI,aAvCJ,CAAA,mBAAA,CAAA;EAAA,uBAuCI,CAAA,KAAA,CAAA,EAgEU,gBAhEV,CAAA,EAAA,MAAA,GAAA,SAAA;EAgEU,UAAA,iBAAA,CAAA,QAAA,EAAA,MAAA,GAiEQ,YAjER,CAAA,EAAA,MAAA;EAiEQ,UAAA,WAAA,CAAA,KAAA,CAAA,EAQjB,gBARiB,CAAA,EAAA,OAAA;EAQjB,UAAA,aAAA,CAAA,KAAA,CAAA,EAOE,gBAPF,CAAA,EAAA,OAAA;EAOE,UAAA,cAAA,CAAA,KAAA,EAQA,WARA,EAAA,MAAA,CAAA,EAQsB,aARtB,CAAA,EAAA,MAAA;;AAQsB,KAa5C,gBAAA;;AAAZ;;;;;;AAqFM;;;MCvcN;;;;;;;;iBDsYqB,eAAe;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;sBA8CN;;;;;uBAKC;;;;;;;;;;;;;;;UAgBrB,eAAA;;;;;;;;;;;;;;;;;;AApea;;;;;;;;;AA6BvB;;;;;;;;;;AAqBoC,cCvBvB,iBDyDwB,ECzDP,OAAA,CAAA,ODyDO,CCtDnC,OAAA,CAH4B,MAAA,CDyDO"}
1
+ {"version":3,"file":"index.d.ts","names":[],"sources":["../../../src/server/cache/providers/ServerCacheProvider.ts","../../../src/server/cache/index.ts"],"sourcesContent":[],"mappings":";;;;;;;;;;;;;;;AAWuB;;;;IAgBqB,KAAA,CAAA,EAHhC,gBAGgC;EACtB;EAAO,UAAA,eAAA,CAAA,gBADe,mBACf,CAAA,CAAA;IAAA,UAAA,EAAA,GAAA,GAAP,OAAO,CAAA,IAAA,CAAA;EAAA;AAY7B;AAAgC,cAAnB,mBAAA,CACW;EACG,mBAAA,GAAA,EAFK,cAAA,CACR,MACG;EACF,mBAAA,MAAA,EADE,MACF;EACC,mBAAA,IAAA,EADD,gBACC;EAAA,mBAAA,KAAA,EAAA,aAAA,CAAA,gBAAA,CAAA,eAAA,EAAA,GAAA,EAAA,CAAA;EAIK,YAAA,CAAA,OAAA,EAAA,UAAA,CAAA,EAAA,MAAA;EAIE,UAAA,CAAA,KAAA,EAAA,WAAA,CAAA,EAAW,OAAX,CAAA,IAAA,CAAA;EAAW,mBAAA,eAAA,EAAA,OAAA,CASR,aATQ,CAAA,kBAAA,CAAA;EAAA,mBASR,gBAAA,EAAA,OAAA,CAkCC,aAlCD,CAAA,mBAAA,CAAA;EAAA,mBAkCC,SAAA,EAAA,OAAA,CAiDP,aAjDO,CAAA,kBAAA,CAAA;EAAA,mBAiDP,MAAA,EAAA,OAAA,CA4DH,aA5DG,CAAA,eAAA,CAAA;EAAA,mBA4DH,UAAA,EAAA,OAAA,CAuCI,aAvCJ,CAAA,mBAAA,CAAA;EAAA,uBAuCI,CAAA,KAAA,CAAA,EA+FU,gBA/FV,CAAA,EAAA,MAAA,GAAA,SAAA;EA+FU,UAAA,iBAAA,CAAA,QAAA,EAAA,MAAA,GAiEQ,YAjER,CAAA,EAAA,MAAA;EAiEQ,UAAA,WAAA,CAAA,KAAA,CAAA,EAQjB,gBARiB,CAAA,EAAA,OAAA;EAQjB,UAAA,aAAA,CAAA,KAAA,CAAA,EAOE,gBAPF,CAAA,EAAA,OAAA;EAOE,UAAA,cAAA,CAAA,KAAA,EAQA,WARA,EAAA,MAAA,CAAA,EAQsB,aARtB,CAAA,EAAA,MAAA;EAQA;;;;;;AAmElC;;;;;EAuE2C,UAAA,qBAAA,CAAA,MAAA,EAlH/B,cAkH+B,CAlHhB,UAkHgB,CAAA,EAAA,GAAA,EAAA,MAAA,EAAA,MAAA,EAAA,MAAA,GAAA,SAAA,EAAA,WAAA,EAAA,MAAA,GAAA,SAAA,EAAA,YAAA,EAAA,OAAA,CAAA,EA7GtC,OA6GsC,CAAA,MAAA,GAAA,SAAA,CAAA;AAcrC;KArFM,gBAAA;;;ACvcZ;;;;;;;;;;;;;;;;iBD2dqB,eAAe;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;sBA8CN;;;;;uBAKC;;;;;;;;;;;;;;;UAgBrB,eAAA;;;;;;;;;;;;;;;;;;AAzjBa;;;;;;;;;AA6BvB;;;;;;;;;;AAqBoC,cCvBvB,iBDyDwB,ECzDP,OAAA,CAAA,ODyDO,CCtDnC,OAAA,CAH4B,MAAA,CDyDO"}
@@ -136,12 +136,28 @@ var ServerCacheProvider = class {
136
136
  const shouldStore = this.shouldStore(cache);
137
137
  const shouldUseEtag = this.shouldUseEtag(cache);
138
138
  if (!shouldStore && !shouldUseEtag) return;
139
- if (typeof response.body !== "string") return;
140
139
  if (response.status && response.status >= 400) return;
140
+ response.headers ??= {};
141
141
  const key = this.createCacheKey(route, request);
142
+ if (response.body instanceof ReadableStream && shouldStore) {
143
+ const [clientStream, cacheStream] = response.body.tee();
144
+ response.body = clientStream;
145
+ this.collectStreamForCache(cacheStream, key, response.status, response.headers?.["content-type"], shouldUseEtag).then((hash) => {
146
+ if (shouldUseEtag && hash) this.log.trace("Stream cached with hash", {
147
+ key,
148
+ hash
149
+ });
150
+ }).catch((err) => {
151
+ this.log.warn("Failed to cache stream", {
152
+ key,
153
+ error: err
154
+ });
155
+ });
156
+ return;
157
+ }
158
+ if (typeof response.body !== "string") return;
142
159
  const generatedEtag = this.generateETag(response.body);
143
160
  const lastModified = this.time.toISOString();
144
- response.headers ??= {};
145
161
  if (shouldStore) {
146
162
  this.log.trace("Storing response", {
147
163
  key,
@@ -209,6 +225,43 @@ var ServerCacheProvider = class {
209
225
  for (const [key, value] of Object.entries(config?.query ?? {})) params.push(`${key}=${value}`);
210
226
  return `${route.method}:${route.path.replaceAll(":", "")}:${params.join(",").replaceAll(":", "")}`;
211
227
  }
228
+ /**
229
+ * Collect a ReadableStream into a string and store it in the cache.
230
+ * This runs in the background while the original stream is sent to the client.
231
+ *
232
+ * @param stream - The stream to collect
233
+ * @param key - Cache key
234
+ * @param status - HTTP status code
235
+ * @param contentType - Content-Type header
236
+ * @param generateEtag - Whether to generate and return an ETag
237
+ * @returns The generated ETag hash, or undefined
238
+ */
239
+ async collectStreamForCache(stream, key, status, contentType, generateEtag) {
240
+ const chunks = [];
241
+ const reader = stream.getReader();
242
+ try {
243
+ while (true) {
244
+ const { done, value } = await reader.read();
245
+ if (done) break;
246
+ chunks.push(value);
247
+ }
248
+ const decoder = new TextDecoder();
249
+ const body = chunks.map((chunk) => decoder.decode(chunk, { stream: true })).join("") + decoder.decode();
250
+ const hash = this.generateETag(body);
251
+ const lastModified = this.time.toISOString();
252
+ this.log.trace("Storing streamed response", { key });
253
+ await this.cache.set(key, {
254
+ body,
255
+ status,
256
+ contentType,
257
+ lastModified,
258
+ hash
259
+ });
260
+ return generateEtag ? hash : void 0;
261
+ } finally {
262
+ reader.releaseLock();
263
+ }
264
+ }
212
265
  };
213
266
 
214
267
  //#endregion