@robelest/convex-auth 0.0.2-preview.2 → 0.0.3-preview
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/dist/bin.cjs +467 -64
- package/dist/client/index.d.ts +127 -0
- package/dist/client/index.d.ts.map +1 -1
- package/dist/client/index.js +424 -1
- package/dist/client/index.js.map +1 -1
- package/dist/component/_generated/api.d.ts +56 -1
- package/dist/component/_generated/api.d.ts.map +1 -1
- package/dist/component/_generated/api.js.map +1 -1
- package/dist/component/_generated/component.d.ts +141 -3
- package/dist/component/_generated/component.d.ts.map +1 -1
- package/dist/component/convex.config.d.ts.map +1 -1
- package/dist/component/convex.config.js +2 -0
- package/dist/component/convex.config.js.map +1 -1
- package/dist/component/index.d.ts +5 -4
- package/dist/component/index.d.ts.map +1 -1
- package/dist/component/index.js +4 -3
- package/dist/component/index.js.map +1 -1
- package/dist/component/portalBridge.d.ts +80 -0
- package/dist/component/portalBridge.d.ts.map +1 -0
- package/dist/component/portalBridge.js +102 -0
- package/dist/component/portalBridge.js.map +1 -0
- package/dist/component/public.d.ts +353 -9
- package/dist/component/public.d.ts.map +1 -1
- package/dist/component/public.js +328 -33
- package/dist/component/public.js.map +1 -1
- package/dist/component/schema.d.ts +168 -9
- package/dist/component/schema.d.ts.map +1 -1
- package/dist/component/schema.js +113 -7
- package/dist/component/schema.js.map +1 -1
- package/dist/providers/passkey.d.ts +20 -0
- package/dist/providers/passkey.d.ts.map +1 -0
- package/dist/providers/passkey.js +32 -0
- package/dist/providers/passkey.js.map +1 -0
- package/dist/providers/totp.d.ts +14 -0
- package/dist/providers/totp.d.ts.map +1 -0
- package/dist/providers/totp.js +23 -0
- package/dist/providers/totp.js.map +1 -0
- package/dist/server/convex-auth.d.ts +296 -0
- package/dist/server/convex-auth.d.ts.map +1 -0
- package/dist/server/convex-auth.js +480 -0
- package/dist/server/convex-auth.js.map +1 -0
- package/dist/server/email-templates.d.ts +18 -0
- package/dist/server/email-templates.d.ts.map +1 -0
- package/dist/server/email-templates.js +74 -0
- package/dist/server/email-templates.js.map +1 -0
- package/dist/server/implementation/apiKey.d.ts +74 -0
- package/dist/server/implementation/apiKey.d.ts.map +1 -0
- package/dist/server/implementation/apiKey.js +140 -0
- package/dist/server/implementation/apiKey.js.map +1 -0
- package/dist/server/implementation/index.d.ts +169 -7
- package/dist/server/implementation/index.d.ts.map +1 -1
- package/dist/server/implementation/index.js +220 -5
- package/dist/server/implementation/index.js.map +1 -1
- package/dist/server/implementation/passkey.d.ts +33 -0
- package/dist/server/implementation/passkey.d.ts.map +1 -0
- package/dist/server/implementation/passkey.js +450 -0
- package/dist/server/implementation/passkey.js.map +1 -0
- package/dist/server/implementation/redirects.d.ts.map +1 -1
- package/dist/server/implementation/redirects.js +4 -9
- package/dist/server/implementation/redirects.js.map +1 -1
- package/dist/server/implementation/signIn.d.ts +13 -0
- package/dist/server/implementation/signIn.d.ts.map +1 -1
- package/dist/server/implementation/signIn.js +29 -15
- package/dist/server/implementation/signIn.js.map +1 -1
- package/dist/server/implementation/totp.d.ts +40 -0
- package/dist/server/implementation/totp.d.ts.map +1 -0
- package/dist/server/implementation/totp.js +211 -0
- package/dist/server/implementation/totp.js.map +1 -0
- package/dist/server/index.d.ts +26 -2
- package/dist/server/index.d.ts.map +1 -1
- package/dist/server/index.js +63 -16
- package/dist/server/index.js.map +1 -1
- package/dist/server/portal-email.d.ts +19 -0
- package/dist/server/portal-email.d.ts.map +1 -0
- package/dist/server/portal-email.js +89 -0
- package/dist/server/portal-email.js.map +1 -0
- package/dist/server/provider_utils.d.ts +3 -1
- package/dist/server/provider_utils.d.ts.map +1 -1
- package/dist/server/provider_utils.js +39 -1
- package/dist/server/provider_utils.js.map +1 -1
- package/dist/server/types.d.ts +263 -4
- package/dist/server/types.d.ts.map +1 -1
- package/dist/server/version.d.ts +2 -0
- package/dist/server/version.d.ts.map +1 -0
- package/dist/server/version.js +3 -0
- package/dist/server/version.js.map +1 -0
- package/package.json +7 -3
- package/src/cli/index.ts +49 -7
- package/src/cli/portal-link.ts +112 -0
- package/src/cli/portal-upload.ts +411 -0
- package/src/cli/utils.ts +248 -0
- package/src/client/index.ts +489 -1
- package/src/component/_generated/api.ts +72 -1
- package/src/component/_generated/component.ts +241 -4
- package/src/component/convex.config.ts +3 -0
- package/src/component/index.ts +8 -3
- package/src/component/portalBridge.ts +116 -0
- package/src/component/public.ts +373 -37
- package/src/component/schema.ts +122 -7
- package/src/providers/passkey.ts +35 -0
- package/src/providers/totp.ts +26 -0
- package/src/server/convex-auth.ts +602 -0
- package/src/server/email-templates.ts +77 -0
- package/src/server/implementation/apiKey.ts +185 -0
- package/src/server/implementation/index.ts +301 -8
- package/src/server/implementation/passkey.ts +650 -0
- package/src/server/implementation/redirects.ts +4 -11
- package/src/server/implementation/signIn.ts +41 -13
- package/src/server/implementation/totp.ts +366 -0
- package/src/server/index.ts +98 -34
- package/src/server/portal-email.ts +95 -0
- package/src/server/provider_utils.ts +42 -1
- package/src/server/types.ts +285 -4
- package/src/server/version.ts +2 -0
|
@@ -23,6 +23,56 @@ import type { FunctionReference } from "convex/server";
|
|
|
23
23
|
*/
|
|
24
24
|
export type ComponentApi<Name extends string | undefined = string | undefined> =
|
|
25
25
|
{
|
|
26
|
+
portalBridge: {
|
|
27
|
+
gcOldAssets: FunctionReference<
|
|
28
|
+
"mutation",
|
|
29
|
+
"internal",
|
|
30
|
+
{ currentDeploymentId: string },
|
|
31
|
+
any,
|
|
32
|
+
Name
|
|
33
|
+
>;
|
|
34
|
+
getByPath: FunctionReference<
|
|
35
|
+
"query",
|
|
36
|
+
"internal",
|
|
37
|
+
{ path: string },
|
|
38
|
+
any,
|
|
39
|
+
Name
|
|
40
|
+
>;
|
|
41
|
+
getCurrentDeployment: FunctionReference<
|
|
42
|
+
"query",
|
|
43
|
+
"internal",
|
|
44
|
+
{},
|
|
45
|
+
any,
|
|
46
|
+
Name
|
|
47
|
+
>;
|
|
48
|
+
listAssets: FunctionReference<
|
|
49
|
+
"query",
|
|
50
|
+
"internal",
|
|
51
|
+
{ limit?: number },
|
|
52
|
+
any,
|
|
53
|
+
Name
|
|
54
|
+
>;
|
|
55
|
+
recordAsset: FunctionReference<
|
|
56
|
+
"mutation",
|
|
57
|
+
"internal",
|
|
58
|
+
{
|
|
59
|
+
blobId?: string;
|
|
60
|
+
contentType: string;
|
|
61
|
+
deploymentId: string;
|
|
62
|
+
path: string;
|
|
63
|
+
storageId?: string;
|
|
64
|
+
},
|
|
65
|
+
any,
|
|
66
|
+
Name
|
|
67
|
+
>;
|
|
68
|
+
setCurrentDeployment: FunctionReference<
|
|
69
|
+
"mutation",
|
|
70
|
+
"internal",
|
|
71
|
+
{ deploymentId: string },
|
|
72
|
+
null,
|
|
73
|
+
Name
|
|
74
|
+
>;
|
|
75
|
+
};
|
|
26
76
|
public: {
|
|
27
77
|
accountDelete: FunctionReference<
|
|
28
78
|
"mutation",
|
|
@@ -57,6 +107,13 @@ export type ComponentApi<Name extends string | undefined = string | undefined> =
|
|
|
57
107
|
any,
|
|
58
108
|
Name
|
|
59
109
|
>;
|
|
110
|
+
accountListByUser: FunctionReference<
|
|
111
|
+
"query",
|
|
112
|
+
"internal",
|
|
113
|
+
{ userId: string },
|
|
114
|
+
any,
|
|
115
|
+
Name
|
|
116
|
+
>;
|
|
60
117
|
accountPatch: FunctionReference<
|
|
61
118
|
"mutation",
|
|
62
119
|
"internal",
|
|
@@ -102,7 +159,7 @@ export type ComponentApi<Name extends string | undefined = string | undefined> =
|
|
|
102
159
|
inviteAccept: FunctionReference<
|
|
103
160
|
"mutation",
|
|
104
161
|
"internal",
|
|
105
|
-
{ inviteId: string },
|
|
162
|
+
{ acceptedByUserId?: string; inviteId: string },
|
|
106
163
|
any,
|
|
107
164
|
Name
|
|
108
165
|
>;
|
|
@@ -110,11 +167,11 @@ export type ComponentApi<Name extends string | undefined = string | undefined> =
|
|
|
110
167
|
"mutation",
|
|
111
168
|
"internal",
|
|
112
169
|
{
|
|
113
|
-
email
|
|
114
|
-
expiresTime
|
|
170
|
+
email?: string;
|
|
171
|
+
expiresTime?: number;
|
|
115
172
|
extend?: any;
|
|
116
173
|
groupId?: string;
|
|
117
|
-
invitedByUserId
|
|
174
|
+
invitedByUserId?: string;
|
|
118
175
|
role?: string;
|
|
119
176
|
status: "pending" | "accepted" | "revoked" | "expired";
|
|
120
177
|
tokenHash: string;
|
|
@@ -129,6 +186,13 @@ export type ComponentApi<Name extends string | undefined = string | undefined> =
|
|
|
129
186
|
any,
|
|
130
187
|
Name
|
|
131
188
|
>;
|
|
189
|
+
inviteGetByTokenHash: FunctionReference<
|
|
190
|
+
"query",
|
|
191
|
+
"internal",
|
|
192
|
+
{ tokenHash: string },
|
|
193
|
+
any,
|
|
194
|
+
Name
|
|
195
|
+
>;
|
|
132
196
|
inviteList: FunctionReference<
|
|
133
197
|
"query",
|
|
134
198
|
"internal",
|
|
@@ -146,6 +210,67 @@ export type ComponentApi<Name extends string | undefined = string | undefined> =
|
|
|
146
210
|
any,
|
|
147
211
|
Name
|
|
148
212
|
>;
|
|
213
|
+
keyDelete: FunctionReference<
|
|
214
|
+
"mutation",
|
|
215
|
+
"internal",
|
|
216
|
+
{ keyId: string },
|
|
217
|
+
any,
|
|
218
|
+
Name
|
|
219
|
+
>;
|
|
220
|
+
keyGetByHashedKey: FunctionReference<
|
|
221
|
+
"query",
|
|
222
|
+
"internal",
|
|
223
|
+
{ hashedKey: string },
|
|
224
|
+
any,
|
|
225
|
+
Name
|
|
226
|
+
>;
|
|
227
|
+
keyGetById: FunctionReference<
|
|
228
|
+
"query",
|
|
229
|
+
"internal",
|
|
230
|
+
{ keyId: string },
|
|
231
|
+
any,
|
|
232
|
+
Name
|
|
233
|
+
>;
|
|
234
|
+
keyInsert: FunctionReference<
|
|
235
|
+
"mutation",
|
|
236
|
+
"internal",
|
|
237
|
+
{
|
|
238
|
+
expiresAt?: number;
|
|
239
|
+
hashedKey: string;
|
|
240
|
+
name: string;
|
|
241
|
+
prefix: string;
|
|
242
|
+
rateLimit?: { maxRequests: number; windowMs: number };
|
|
243
|
+
scopes: Array<{ resource: string; actions: Array<string> }>;
|
|
244
|
+
userId: string;
|
|
245
|
+
},
|
|
246
|
+
any,
|
|
247
|
+
Name
|
|
248
|
+
>;
|
|
249
|
+
keyList: FunctionReference<"query", "internal", {}, any, Name>;
|
|
250
|
+
keyListByUserId: FunctionReference<
|
|
251
|
+
"query",
|
|
252
|
+
"internal",
|
|
253
|
+
{ userId: string },
|
|
254
|
+
any,
|
|
255
|
+
Name
|
|
256
|
+
>;
|
|
257
|
+
keyPatch: FunctionReference<
|
|
258
|
+
"mutation",
|
|
259
|
+
"internal",
|
|
260
|
+
{
|
|
261
|
+
data: {
|
|
262
|
+
lastUsedAt?: number;
|
|
263
|
+
name?: string;
|
|
264
|
+
rateLimit?: { maxRequests: number; windowMs: number };
|
|
265
|
+
rateLimitState?: { attemptsLeft: number; lastAttemptTime: number };
|
|
266
|
+
revoked?: boolean;
|
|
267
|
+
scopes?: Array<{ resource: string; actions: Array<string> }>;
|
|
268
|
+
};
|
|
269
|
+
keyId: string;
|
|
270
|
+
},
|
|
271
|
+
any,
|
|
272
|
+
Name
|
|
273
|
+
>;
|
|
149
274
|
memberAdd: FunctionReference<
|
|
150
275
|
"mutation",
|
|
151
276
|
"internal",
|
|
@@ -201,6 +326,59 @@ export type ComponentApi<Name extends string | undefined = string | undefined> =
|
|
|
201
326
|
any,
|
|
202
327
|
Name
|
|
203
328
|
>;
|
|
329
|
+
passkeyDelete: FunctionReference<
|
|
330
|
+
"mutation",
|
|
331
|
+
"internal",
|
|
332
|
+
{ passkeyId: string },
|
|
333
|
+
any,
|
|
334
|
+
Name
|
|
335
|
+
>;
|
|
336
|
+
passkeyGetByCredentialId: FunctionReference<
|
|
337
|
+
"query",
|
|
338
|
+
"internal",
|
|
339
|
+
{ credentialId: string },
|
|
340
|
+
any,
|
|
341
|
+
Name
|
|
342
|
+
>;
|
|
343
|
+
passkeyInsert: FunctionReference<
|
|
344
|
+
"mutation",
|
|
345
|
+
"internal",
|
|
346
|
+
{
|
|
347
|
+
algorithm: number;
|
|
348
|
+
backedUp: boolean;
|
|
349
|
+
counter: number;
|
|
350
|
+
createdAt: number;
|
|
351
|
+
credentialId: string;
|
|
352
|
+
deviceType: string;
|
|
353
|
+
name?: string;
|
|
354
|
+
publicKey: ArrayBuffer;
|
|
355
|
+
transports?: Array<string>;
|
|
356
|
+
userId: string;
|
|
357
|
+
},
|
|
358
|
+
any,
|
|
359
|
+
Name
|
|
360
|
+
>;
|
|
361
|
+
passkeyListByUserId: FunctionReference<
|
|
362
|
+
"query",
|
|
363
|
+
"internal",
|
|
364
|
+
{ userId: string },
|
|
365
|
+
any,
|
|
366
|
+
Name
|
|
367
|
+
>;
|
|
368
|
+
passkeyUpdateCounter: FunctionReference<
|
|
369
|
+
"mutation",
|
|
370
|
+
"internal",
|
|
371
|
+
{ counter: number; lastUsedAt: number; passkeyId: string },
|
|
372
|
+
any,
|
|
373
|
+
Name
|
|
374
|
+
>;
|
|
375
|
+
passkeyUpdateMeta: FunctionReference<
|
|
376
|
+
"mutation",
|
|
377
|
+
"internal",
|
|
378
|
+
{ data: any; passkeyId: string },
|
|
379
|
+
any,
|
|
380
|
+
Name
|
|
381
|
+
>;
|
|
204
382
|
rateLimitCreate: FunctionReference<
|
|
205
383
|
"mutation",
|
|
206
384
|
"internal",
|
|
@@ -303,6 +481,7 @@ export type ComponentApi<Name extends string | undefined = string | undefined> =
|
|
|
303
481
|
any,
|
|
304
482
|
Name
|
|
305
483
|
>;
|
|
484
|
+
sessionList: FunctionReference<"query", "internal", {}, any, Name>;
|
|
306
485
|
sessionListByUser: FunctionReference<
|
|
307
486
|
"query",
|
|
308
487
|
"internal",
|
|
@@ -310,6 +489,63 @@ export type ComponentApi<Name extends string | undefined = string | undefined> =
|
|
|
310
489
|
any,
|
|
311
490
|
Name
|
|
312
491
|
>;
|
|
492
|
+
totpDelete: FunctionReference<
|
|
493
|
+
"mutation",
|
|
494
|
+
"internal",
|
|
495
|
+
{ totpId: string },
|
|
496
|
+
any,
|
|
497
|
+
Name
|
|
498
|
+
>;
|
|
499
|
+
totpGetById: FunctionReference<
|
|
500
|
+
"query",
|
|
501
|
+
"internal",
|
|
502
|
+
{ totpId: string },
|
|
503
|
+
any,
|
|
504
|
+
Name
|
|
505
|
+
>;
|
|
506
|
+
totpGetVerifiedByUserId: FunctionReference<
|
|
507
|
+
"query",
|
|
508
|
+
"internal",
|
|
509
|
+
{ userId: string },
|
|
510
|
+
any,
|
|
511
|
+
Name
|
|
512
|
+
>;
|
|
513
|
+
totpInsert: FunctionReference<
|
|
514
|
+
"mutation",
|
|
515
|
+
"internal",
|
|
516
|
+
{
|
|
517
|
+
createdAt: number;
|
|
518
|
+
digits: number;
|
|
519
|
+
name?: string;
|
|
520
|
+
period: number;
|
|
521
|
+
secret: ArrayBuffer;
|
|
522
|
+
userId: string;
|
|
523
|
+
verified: boolean;
|
|
524
|
+
},
|
|
525
|
+
any,
|
|
526
|
+
Name
|
|
527
|
+
>;
|
|
528
|
+
totpListByUserId: FunctionReference<
|
|
529
|
+
"query",
|
|
530
|
+
"internal",
|
|
531
|
+
{ userId: string },
|
|
532
|
+
any,
|
|
533
|
+
Name
|
|
534
|
+
>;
|
|
535
|
+
totpMarkVerified: FunctionReference<
|
|
536
|
+
"mutation",
|
|
537
|
+
"internal",
|
|
538
|
+
{ lastUsedAt: number; totpId: string },
|
|
539
|
+
any,
|
|
540
|
+
Name
|
|
541
|
+
>;
|
|
542
|
+
totpUpdateLastUsed: FunctionReference<
|
|
543
|
+
"mutation",
|
|
544
|
+
"internal",
|
|
545
|
+
{ lastUsedAt: number; totpId: string },
|
|
546
|
+
any,
|
|
547
|
+
Name
|
|
548
|
+
>;
|
|
313
549
|
userFindByVerifiedEmail: FunctionReference<
|
|
314
550
|
"query",
|
|
315
551
|
"internal",
|
|
@@ -338,6 +574,7 @@ export type ComponentApi<Name extends string | undefined = string | undefined> =
|
|
|
338
574
|
any,
|
|
339
575
|
Name
|
|
340
576
|
>;
|
|
577
|
+
userList: FunctionReference<"query", "internal", {}, any, Name>;
|
|
341
578
|
userPatch: FunctionReference<
|
|
342
579
|
"mutation",
|
|
343
580
|
"internal",
|
package/src/component/index.ts
CHANGED
|
@@ -2,19 +2,20 @@
|
|
|
2
2
|
* Configuration and helpers for using Convex Auth on your Convex
|
|
3
3
|
* backend.
|
|
4
4
|
*
|
|
5
|
-
*
|
|
6
|
-
* and
|
|
5
|
+
* Use `new Auth(components.auth, config)` to configure authentication
|
|
6
|
+
* and `Portal(auth)` to create portal admin exports.
|
|
7
7
|
*
|
|
8
8
|
* @module
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
11
|
export {
|
|
12
|
-
Auth,
|
|
12
|
+
Auth as AuthFactory,
|
|
13
13
|
Tokens,
|
|
14
14
|
Doc,
|
|
15
15
|
SignInAction,
|
|
16
16
|
SignOutAction,
|
|
17
17
|
} from "../server/implementation/index.js";
|
|
18
|
+
export { Auth, Portal } from "../server/convex-auth.js";
|
|
18
19
|
export type {
|
|
19
20
|
ConvexAuthConfig,
|
|
20
21
|
AuthProviderConfig,
|
|
@@ -26,5 +27,9 @@ export type {
|
|
|
26
27
|
GenericActionCtxWithAuthConfig,
|
|
27
28
|
AuthProviderMaterializedConfig,
|
|
28
29
|
ConvexAuthMaterializedConfig,
|
|
30
|
+
ApiKeyConfig,
|
|
31
|
+
KeyScope,
|
|
32
|
+
ScopeChecker,
|
|
33
|
+
KeyRecord,
|
|
29
34
|
} from "../server/types.js";
|
|
30
35
|
export type { GenericDoc } from "../server/convex_types.js";
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Bridge functions that delegate to the self-hosting sub-component.
|
|
3
|
+
*
|
|
4
|
+
* The auth component uses self-hosting as a sub-component for serving
|
|
5
|
+
* portal static assets. These functions expose the self-hosting API
|
|
6
|
+
* as internal queries/mutations within the auth component, so the
|
|
7
|
+
* app layer can call them via `ctx.runQuery(components.auth.portalBridge.getByPath, ...)`.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
import { v } from "convex/values";
|
|
11
|
+
import { query, mutation, internalMutation } from "./_generated/server.js";
|
|
12
|
+
import { components } from "./_generated/api.js";
|
|
13
|
+
|
|
14
|
+
// ============================================================================
|
|
15
|
+
// Queries — delegate to selfHosting.lib.*
|
|
16
|
+
// ============================================================================
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Look up a static asset by URL path.
|
|
20
|
+
* Delegates to selfHosting.lib.getByPath.
|
|
21
|
+
*/
|
|
22
|
+
export const getByPath = query({
|
|
23
|
+
args: { path: v.string() },
|
|
24
|
+
returns: v.any(),
|
|
25
|
+
handler: async (ctx, args) => {
|
|
26
|
+
return await ctx.runQuery(components.selfHosting.lib.getByPath, {
|
|
27
|
+
path: args.path,
|
|
28
|
+
});
|
|
29
|
+
},
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Get the current deployment info.
|
|
34
|
+
* Delegates to selfHosting.lib.getCurrentDeployment.
|
|
35
|
+
*/
|
|
36
|
+
export const getCurrentDeployment = query({
|
|
37
|
+
args: {},
|
|
38
|
+
returns: v.any(),
|
|
39
|
+
handler: async (ctx) => {
|
|
40
|
+
return await ctx.runQuery(
|
|
41
|
+
components.selfHosting.lib.getCurrentDeployment,
|
|
42
|
+
{},
|
|
43
|
+
);
|
|
44
|
+
},
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* List all static assets.
|
|
49
|
+
* Delegates to selfHosting.lib.listAssets.
|
|
50
|
+
*/
|
|
51
|
+
export const listAssets = query({
|
|
52
|
+
args: { limit: v.optional(v.number()) },
|
|
53
|
+
returns: v.any(),
|
|
54
|
+
handler: async (ctx, args) => {
|
|
55
|
+
return await ctx.runQuery(components.selfHosting.lib.listAssets, {
|
|
56
|
+
limit: args.limit,
|
|
57
|
+
});
|
|
58
|
+
},
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
// ============================================================================
|
|
62
|
+
// Mutations — delegate to selfHosting.lib.*
|
|
63
|
+
// ============================================================================
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Record an asset after upload.
|
|
67
|
+
* Delegates to selfHosting.lib.recordAsset.
|
|
68
|
+
*/
|
|
69
|
+
export const recordAsset = mutation({
|
|
70
|
+
args: {
|
|
71
|
+
path: v.string(),
|
|
72
|
+
storageId: v.optional(v.string()),
|
|
73
|
+
blobId: v.optional(v.string()),
|
|
74
|
+
contentType: v.string(),
|
|
75
|
+
deploymentId: v.string(),
|
|
76
|
+
},
|
|
77
|
+
returns: v.any(),
|
|
78
|
+
handler: async (ctx, args) => {
|
|
79
|
+
return await ctx.runMutation(components.selfHosting.lib.recordAsset, {
|
|
80
|
+
path: args.path,
|
|
81
|
+
...(args.storageId ? { storageId: args.storageId } : {}),
|
|
82
|
+
...(args.blobId ? { blobId: args.blobId } : {}),
|
|
83
|
+
contentType: args.contentType,
|
|
84
|
+
deploymentId: args.deploymentId,
|
|
85
|
+
});
|
|
86
|
+
},
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* Garbage collect assets from old deployments.
|
|
91
|
+
* Delegates to selfHosting.lib.gcOldAssets.
|
|
92
|
+
*/
|
|
93
|
+
export const gcOldAssets = mutation({
|
|
94
|
+
args: { currentDeploymentId: v.string() },
|
|
95
|
+
returns: v.any(),
|
|
96
|
+
handler: async (ctx, args) => {
|
|
97
|
+
return await ctx.runMutation(components.selfHosting.lib.gcOldAssets, {
|
|
98
|
+
currentDeploymentId: args.currentDeploymentId,
|
|
99
|
+
});
|
|
100
|
+
},
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* Update the current deployment ID.
|
|
105
|
+
* Delegates to selfHosting.lib.setCurrentDeployment.
|
|
106
|
+
*/
|
|
107
|
+
export const setCurrentDeployment = mutation({
|
|
108
|
+
args: { deploymentId: v.string() },
|
|
109
|
+
returns: v.null(),
|
|
110
|
+
handler: async (ctx, args) => {
|
|
111
|
+
return await ctx.runMutation(
|
|
112
|
+
components.selfHosting.lib.setCurrentDeployment,
|
|
113
|
+
{ deploymentId: args.deploymentId },
|
|
114
|
+
);
|
|
115
|
+
},
|
|
116
|
+
});
|