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.
- package/README.md +1 -1
- package/dist/api/audits/index.d.ts +338 -417
- package/dist/api/audits/index.d.ts.map +1 -1
- package/dist/api/files/index.d.ts +1 -80
- package/dist/api/files/index.d.ts.map +1 -1
- package/dist/api/jobs/index.d.ts +156 -235
- package/dist/api/jobs/index.d.ts.map +1 -1
- package/dist/api/notifications/index.d.ts +170 -249
- package/dist/api/notifications/index.d.ts.map +1 -1
- package/dist/api/parameters/index.d.ts +266 -345
- package/dist/api/parameters/index.d.ts.map +1 -1
- package/dist/api/users/index.d.ts +755 -834
- package/dist/api/users/index.d.ts.map +1 -1
- package/dist/api/verifications/index.d.ts +125 -125
- package/dist/api/verifications/index.d.ts.map +1 -1
- package/dist/cli/index.d.ts +116 -20
- package/dist/cli/index.d.ts.map +1 -1
- package/dist/cli/index.js +212 -124
- package/dist/cli/index.js.map +1 -1
- package/dist/command/index.d.ts +6 -11
- package/dist/command/index.d.ts.map +1 -1
- package/dist/command/index.js +2 -2
- package/dist/command/index.js.map +1 -1
- package/dist/core/index.browser.js +26 -4
- package/dist/core/index.browser.js.map +1 -1
- package/dist/core/index.d.ts +16 -1
- package/dist/core/index.d.ts.map +1 -1
- package/dist/core/index.js +26 -4
- package/dist/core/index.js.map +1 -1
- package/dist/core/index.native.js +26 -4
- package/dist/core/index.native.js.map +1 -1
- package/dist/logger/index.d.ts +1 -1
- package/dist/logger/index.d.ts.map +1 -1
- package/dist/logger/index.js +12 -2
- package/dist/logger/index.js.map +1 -1
- package/dist/mcp/index.d.ts.map +1 -1
- package/dist/mcp/index.js +1 -1
- package/dist/mcp/index.js.map +1 -1
- package/dist/orm/index.d.ts +37 -173
- package/dist/orm/index.d.ts.map +1 -1
- package/dist/orm/index.js +193 -422
- package/dist/orm/index.js.map +1 -1
- package/dist/server/auth/index.d.ts +167 -167
- package/dist/server/cache/index.d.ts +12 -0
- package/dist/server/cache/index.d.ts.map +1 -1
- package/dist/server/cache/index.js +55 -2
- package/dist/server/cache/index.js.map +1 -1
- package/dist/server/compress/index.d.ts +6 -0
- package/dist/server/compress/index.d.ts.map +1 -1
- package/dist/server/compress/index.js +36 -1
- package/dist/server/compress/index.js.map +1 -1
- package/dist/server/core/index.browser.js +2 -2
- package/dist/server/core/index.browser.js.map +1 -1
- package/dist/server/core/index.d.ts +10 -10
- package/dist/server/core/index.d.ts.map +1 -1
- package/dist/server/core/index.js +6 -3
- package/dist/server/core/index.js.map +1 -1
- package/dist/server/links/index.d.ts +39 -39
- package/dist/server/links/index.d.ts.map +1 -1
- package/dist/server/security/index.d.ts +9 -9
- package/dist/server/static/index.d.ts.map +1 -1
- package/dist/server/static/index.js +4 -0
- package/dist/server/static/index.js.map +1 -1
- package/dist/server/swagger/index.d.ts.map +1 -1
- package/dist/server/swagger/index.js +2 -3
- package/dist/server/swagger/index.js.map +1 -1
- package/dist/vite/index.d.ts +101 -106
- package/dist/vite/index.d.ts.map +1 -1
- package/dist/vite/index.js +571 -508
- package/dist/vite/index.js.map +1 -1
- package/package.json +1 -1
- package/src/cli/apps/AlephaCli.ts +0 -2
- package/src/cli/atoms/buildOptions.ts +88 -0
- package/src/cli/commands/build.ts +32 -69
- package/src/cli/commands/db.ts +0 -4
- package/src/cli/commands/dev.ts +16 -4
- package/src/cli/commands/gen/env.ts +53 -0
- package/src/cli/commands/gen/openapi.ts +1 -1
- package/src/cli/commands/gen/resource.ts +15 -0
- package/src/cli/commands/gen.ts +7 -1
- package/src/cli/commands/init.ts +0 -1
- package/src/cli/commands/test.ts +0 -1
- package/src/cli/commands/verify.ts +1 -1
- package/src/cli/defineConfig.ts +49 -7
- package/src/cli/index.ts +0 -1
- package/src/cli/services/AlephaCliUtils.ts +36 -25
- package/src/command/helpers/Runner.spec.ts +2 -2
- package/src/command/helpers/Runner.ts +1 -1
- package/src/command/primitives/$command.ts +0 -6
- package/src/command/providers/CliProvider.ts +1 -3
- package/src/core/Alepha.ts +42 -0
- package/src/logger/index.ts +15 -3
- package/src/mcp/transports/StdioMcpTransport.ts +1 -1
- package/src/orm/index.ts +2 -8
- package/src/queue/core/providers/WorkerProvider.spec.ts +48 -32
- package/src/server/cache/providers/ServerCacheProvider.spec.ts +183 -0
- package/src/server/cache/providers/ServerCacheProvider.ts +94 -9
- package/src/server/compress/providers/ServerCompressProvider.ts +61 -2
- package/src/server/core/helpers/ServerReply.ts +2 -2
- package/src/server/core/providers/ServerProvider.ts +11 -1
- package/src/server/static/providers/ServerStaticProvider.ts +10 -0
- package/src/server/swagger/providers/ServerSwaggerProvider.ts +5 -8
- package/src/vite/helpers/importViteReact.ts +13 -0
- package/src/vite/index.ts +1 -21
- package/src/vite/plugins/viteAlephaDev.ts +16 -1
- package/src/vite/plugins/viteAlephaSsrPreload.ts +222 -0
- package/src/vite/tasks/buildClient.ts +11 -0
- package/src/vite/tasks/buildServer.ts +47 -3
- package/src/vite/tasks/devServer.ts +69 -0
- package/src/vite/tasks/index.ts +2 -1
- package/src/cli/assets/viteConfigTs.ts +0 -14
- package/src/cli/commands/run.ts +0 -24
- package/src/vite/plugins/viteAlepha.ts +0 -37
- package/src/vite/plugins/viteAlephaBuild.ts +0 -281
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as
|
|
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:
|
|
24
|
-
name:
|
|
25
|
-
type:
|
|
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:
|
|
31
|
-
provider:
|
|
32
|
-
access_token:
|
|
33
|
-
issued_at:
|
|
34
|
-
expires_in:
|
|
35
|
-
refresh_token:
|
|
36
|
-
refresh_token_expires_in:
|
|
37
|
-
refresh_expires_in:
|
|
38
|
-
id_token:
|
|
39
|
-
scope:
|
|
40
|
-
user:
|
|
41
|
-
id:
|
|
42
|
-
name:
|
|
43
|
-
email:
|
|
44
|
-
username:
|
|
45
|
-
picture:
|
|
46
|
-
sessionId:
|
|
47
|
-
organizations:
|
|
48
|
-
roles:
|
|
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:
|
|
51
|
-
prefix:
|
|
52
|
-
links:
|
|
53
|
-
name:
|
|
54
|
-
group:
|
|
55
|
-
path:
|
|
56
|
-
method:
|
|
57
|
-
requestBodyType:
|
|
58
|
-
service:
|
|
59
|
-
rawSchema:
|
|
60
|
-
body:
|
|
61
|
-
response:
|
|
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:
|
|
70
|
-
provider:
|
|
71
|
-
access_token:
|
|
72
|
-
issued_at:
|
|
73
|
-
expires_in:
|
|
74
|
-
refresh_token:
|
|
75
|
-
refresh_token_expires_in:
|
|
76
|
-
refresh_expires_in:
|
|
77
|
-
id_token:
|
|
78
|
-
scope:
|
|
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:
|
|
84
|
-
user:
|
|
85
|
-
id:
|
|
86
|
-
name:
|
|
87
|
-
email:
|
|
88
|
-
username:
|
|
89
|
-
picture:
|
|
90
|
-
sessionId:
|
|
91
|
-
organizations:
|
|
92
|
-
roles:
|
|
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:
|
|
95
|
-
prefix:
|
|
96
|
-
links:
|
|
97
|
-
name:
|
|
98
|
-
group:
|
|
99
|
-
path:
|
|
100
|
-
method:
|
|
101
|
-
requestBodyType:
|
|
102
|
-
service:
|
|
103
|
-
rawSchema:
|
|
104
|
-
body:
|
|
105
|
-
response:
|
|
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<
|
|
120
|
-
provider:
|
|
121
|
-
realm:
|
|
122
|
-
codeVerifier:
|
|
123
|
-
redirectUri:
|
|
124
|
-
state:
|
|
125
|
-
nonce:
|
|
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<
|
|
128
|
-
provider:
|
|
129
|
-
access_token:
|
|
130
|
-
issued_at:
|
|
131
|
-
expires_in:
|
|
132
|
-
refresh_token:
|
|
133
|
-
refresh_token_expires_in:
|
|
134
|
-
refresh_expires_in:
|
|
135
|
-
id_token:
|
|
136
|
-
scope:
|
|
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:
|
|
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:
|
|
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:
|
|
159
|
-
user:
|
|
160
|
-
id:
|
|
161
|
-
name:
|
|
162
|
-
email:
|
|
163
|
-
username:
|
|
164
|
-
picture:
|
|
165
|
-
sessionId:
|
|
166
|
-
organizations:
|
|
167
|
-
roles:
|
|
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:
|
|
170
|
-
prefix:
|
|
171
|
-
links:
|
|
172
|
-
name:
|
|
173
|
-
group:
|
|
174
|
-
path:
|
|
175
|
-
method:
|
|
176
|
-
requestBodyType:
|
|
177
|
-
service:
|
|
178
|
-
rawSchema:
|
|
179
|
-
body:
|
|
180
|
-
response:
|
|
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:
|
|
191
|
-
provider:
|
|
190
|
+
query: alepha165.TObject<{
|
|
191
|
+
provider: alepha165.TString;
|
|
192
192
|
}>;
|
|
193
|
-
body:
|
|
194
|
-
refresh_token:
|
|
195
|
-
access_token:
|
|
193
|
+
body: alepha165.TObject<{
|
|
194
|
+
refresh_token: alepha165.TString;
|
|
195
|
+
access_token: alepha165.TOptional<alepha165.TString>;
|
|
196
196
|
}>;
|
|
197
|
-
response:
|
|
198
|
-
provider:
|
|
199
|
-
access_token:
|
|
200
|
-
issued_at:
|
|
201
|
-
expires_in:
|
|
202
|
-
refresh_token:
|
|
203
|
-
refresh_token_expires_in:
|
|
204
|
-
refresh_expires_in:
|
|
205
|
-
id_token:
|
|
206
|
-
scope:
|
|
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:
|
|
214
|
-
provider:
|
|
215
|
-
realm:
|
|
213
|
+
query: alepha165.TObject<{
|
|
214
|
+
provider: alepha165.TString;
|
|
215
|
+
realm: alepha165.TOptional<alepha165.TString>;
|
|
216
216
|
}>;
|
|
217
|
-
body:
|
|
218
|
-
username:
|
|
219
|
-
password:
|
|
217
|
+
body: alepha165.TObject<{
|
|
218
|
+
username: alepha165.TString;
|
|
219
|
+
password: alepha165.TString;
|
|
220
220
|
}>;
|
|
221
|
-
response:
|
|
222
|
-
provider:
|
|
223
|
-
access_token:
|
|
224
|
-
issued_at:
|
|
225
|
-
expires_in:
|
|
226
|
-
refresh_token:
|
|
227
|
-
refresh_token_expires_in:
|
|
228
|
-
refresh_expires_in:
|
|
229
|
-
id_token:
|
|
230
|
-
scope:
|
|
231
|
-
user:
|
|
232
|
-
id:
|
|
233
|
-
name:
|
|
234
|
-
email:
|
|
235
|
-
username:
|
|
236
|
-
picture:
|
|
237
|
-
sessionId:
|
|
238
|
-
organizations:
|
|
239
|
-
roles:
|
|
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:
|
|
242
|
-
prefix:
|
|
243
|
-
links:
|
|
244
|
-
name:
|
|
245
|
-
group:
|
|
246
|
-
path:
|
|
247
|
-
method:
|
|
248
|
-
requestBodyType:
|
|
249
|
-
service:
|
|
250
|
-
rawSchema:
|
|
251
|
-
body:
|
|
252
|
-
response:
|
|
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:
|
|
263
|
-
provider:
|
|
264
|
-
realm:
|
|
265
|
-
redirect_uri:
|
|
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:
|
|
278
|
-
post_logout_redirect_uri:
|
|
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:
|
|
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,
|
|
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
|