@open-pencil/cloud 0.0.0-stage → 0.16.0
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/LICENSE +202 -0
- package/LICENSE-MIT +21 -0
- package/NOTICE +7 -0
- package/README.md +37 -2
- package/dist/bin/ai-relay.d.mts +1 -0
- package/dist/bin/ai-relay.mjs +31 -0
- package/dist/bin/ai-relay.mjs.map +1 -0
- package/dist/bin/server.d.mts +1 -0
- package/dist/bin/server.mjs +29 -0
- package/dist/bin/server.mjs.map +1 -0
- package/dist/client.d.ts +1520 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +1917 -0
- package/dist/client.js.map +1 -0
- package/dist/contract.d.ts +2 -0
- package/dist/contract.js +2 -0
- package/dist/contract2.js +1453 -0
- package/dist/contract2.js.map +1 -0
- package/dist/email.d.ts +169 -0
- package/dist/email.d.ts.map +1 -0
- package/dist/email.js +670 -0
- package/dist/email.js.map +1 -0
- package/dist/index.d.ts +1755 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/listen.mjs +1881 -0
- package/dist/listen.mjs.map +1 -0
- package/dist/runtime-node.d.mts +10040 -0
- package/dist/runtime-node.d.mts.map +1 -0
- package/dist/runtime-node.mjs +32 -0
- package/dist/runtime-node.mjs.map +1 -0
- package/dist/server.d.ts +12792 -0
- package/dist/server.d.ts.map +1 -0
- package/dist/server.js +8475 -0
- package/dist/server.js.map +1 -0
- package/dist/server.mjs +8324 -0
- package/dist/server.mjs.map +1 -0
- package/dist/server2.mjs +505 -0
- package/dist/server2.mjs.map +1 -0
- package/package.json +124 -4
- package/src/admin/api/routes.ts +223 -0
- package/src/admin/api/security.ts +12 -0
- package/src/admin/audit/service.ts +138 -0
- package/src/admin/email/service.ts +140 -0
- package/src/admin/enrollment/email.ts +77 -0
- package/src/admin/enrollment/service.ts +308 -0
- package/src/admin/errors.ts +20 -0
- package/src/admin/index.ts +19 -0
- package/src/admin/list.ts +61 -0
- package/src/admin/operations/service.ts +70 -0
- package/src/admin/schema.ts +28 -0
- package/src/admin/users/service.ts +369 -0
- package/src/ai-relay/app.ts +251 -0
- package/src/ai-relay/config.ts +120 -0
- package/src/ai-relay/db/index.ts +10 -0
- package/src/ai-relay/db/migrate.ts +32 -0
- package/src/ai-relay/db/migrations/001_usage.ts +26 -0
- package/src/ai-relay/db/schema.ts +20 -0
- package/src/ai-relay/index.ts +18 -0
- package/src/ai-relay/metering.ts +68 -0
- package/src/ai-relay/usage.ts +115 -0
- package/src/client/ai.ts +96 -0
- package/src/client/api.ts +528 -0
- package/src/client/auth/client.ts +188 -0
- package/src/client/auth/failure.ts +54 -0
- package/src/client/auth/navigation.ts +45 -0
- package/src/client/device-authorization.ts +134 -0
- package/src/client/discovery.ts +105 -0
- package/src/client/images.ts +81 -0
- package/src/client/index.ts +53 -0
- package/src/client/portal/account.ts +183 -0
- package/src/client/portal/administration.ts +130 -0
- package/src/client/portal/client.ts +18 -0
- package/src/client/portal/request.ts +115 -0
- package/src/client/response.ts +51 -0
- package/src/client/workspaces.ts +142 -0
- package/src/contract/account.ts +204 -0
- package/src/contract/admin/index.ts +187 -0
- package/src/contract/ai.ts +150 -0
- package/src/contract/collaboration.ts +45 -0
- package/src/contract/discovery.ts +81 -0
- package/src/contract/documents.ts +265 -0
- package/src/contract/entitlements.ts +28 -0
- package/src/contract/index.ts +204 -0
- package/src/contract/links.ts +87 -0
- package/src/contract/portal.ts +11 -0
- package/src/contract/relay.ts +368 -0
- package/src/contract/sharing.ts +191 -0
- package/src/contract/versions.ts +87 -0
- package/src/contract/workspaces.ts +100 -0
- package/src/email/index.ts +14 -0
- package/src/email/render.ts +276 -0
- package/src/email/schema.ts +144 -0
- package/src/email/templates/brand.ts +105 -0
- package/src/email/templates/document-invitation.ts +35 -0
- package/src/email/templates/enrollment.ts +27 -0
- package/src/email/templates/layout.ts +18 -0
- package/src/runtime/cloudflare/email.ts +70 -0
- package/src/runtime/cloudflare/environment.ts +57 -0
- package/src/runtime/cloudflare/index.ts +3 -0
- package/src/runtime/cloudflare/relay.ts +136 -0
- package/src/runtime/cloudflare/site.ts +13 -0
- package/src/runtime/cloudflare/tsconfig.json +21 -0
- package/src/runtime/cloudflare/worker.ts +160 -0
- package/src/runtime/node/admin.ts +59 -0
- package/src/runtime/node/ai-relay/main.ts +35 -0
- package/src/runtime/node/ai-relay/server.ts +63 -0
- package/src/runtime/node/application.ts +50 -0
- package/src/runtime/node/bootstrap.ts +22 -0
- package/src/runtime/node/cleanup.ts +24 -0
- package/src/runtime/node/command.ts +17 -0
- package/src/runtime/node/config.ts +16 -0
- package/src/runtime/node/email/runtime.ts +43 -0
- package/src/runtime/node/email/transport.ts +112 -0
- package/src/runtime/node/entitlements/main.ts +41 -0
- package/src/runtime/node/entitlements/refusal.ts +15 -0
- package/src/runtime/node/index.ts +25 -0
- package/src/runtime/node/listen.ts +35 -0
- package/src/runtime/node/main.ts +29 -0
- package/src/runtime/node/migrate.ts +13 -0
- package/src/runtime/node/quota-reconcile.ts +9 -0
- package/src/runtime/node/relay.ts +54 -0
- package/src/runtime/node/server.ts +121 -0
- package/src/runtime/node/site.ts +64 -0
- package/src/runtime/postgres/database.ts +19 -0
- package/src/runtime/s3/objects.ts +244 -0
- package/src/runtime/site/server.ts +82 -0
- package/src/server/account/actions.ts +66 -0
- package/src/server/account/routes.ts +300 -0
- package/src/server/ai/errors.ts +7 -0
- package/src/server/ai/index.ts +4 -0
- package/src/server/ai/keys.ts +43 -0
- package/src/server/ai/routes.ts +43 -0
- package/src/server/ai/service.ts +70 -0
- package/src/server/api/index.ts +8 -0
- package/src/server/api/router.ts +117 -0
- package/src/server/api/types.ts +7 -0
- package/src/server/app.ts +375 -0
- package/src/server/auth/account.ts +73 -0
- package/src/server/auth/activity.ts +213 -0
- package/src/server/auth/adapter.ts +79 -0
- package/src/server/auth/email.ts +125 -0
- package/src/server/auth/endpoints.ts +57 -0
- package/src/server/auth/factory.ts +583 -0
- package/src/server/auth/index.ts +17 -0
- package/src/server/auth/mfa-assurance.ts +55 -0
- package/src/server/auth/runtime.ts +26 -0
- package/src/server/auth/session.ts +19 -0
- package/src/server/auth/social-providers.ts +55 -0
- package/src/server/auth/user-agent.ts +16 -0
- package/src/server/auth/workspace-access.ts +23 -0
- package/src/server/cleanup/configured.ts +38 -0
- package/src/server/cleanup/documents.ts +231 -0
- package/src/server/cleanup/index.ts +29 -0
- package/src/server/cleanup/objects.ts +27 -0
- package/src/server/cleanup/revisions.ts +232 -0
- package/src/server/cleanup/uploads.ts +129 -0
- package/src/server/cleanup/worker.ts +79 -0
- package/src/server/collaboration/index.ts +28 -0
- package/src/server/collaboration/relay/authorize.ts +53 -0
- package/src/server/collaboration/relay/awareness.ts +104 -0
- package/src/server/collaboration/relay/documents.ts +39 -0
- package/src/server/collaboration/relay/hub.ts +524 -0
- package/src/server/collaboration/relay/index.ts +15 -0
- package/src/server/collaboration/relay/persistence.ts +48 -0
- package/src/server/collaboration/routes.ts +77 -0
- package/src/server/collaboration/service.ts +188 -0
- package/src/server/config/deployment.ts +178 -0
- package/src/server/config/index.ts +20 -0
- package/src/server/config/limits.ts +8 -0
- package/src/server/config/public.ts +66 -0
- package/src/server/config/schema.ts +512 -0
- package/src/server/db/database.ts +15 -0
- package/src/server/db/expressions.ts +13 -0
- package/src/server/db/index.ts +21 -0
- package/src/server/db/migrate.ts +177 -0
- package/src/server/db/migrations/001_foundation.ts +164 -0
- package/src/server/db/migrations/002_upload_cleanup_claims.ts +34 -0
- package/src/server/db/migrations/003_document_cleanup_claims.ts +23 -0
- package/src/server/db/migrations/004_document_sharing.ts +82 -0
- package/src/server/db/migrations/005_document_collaboration_epoch.ts +13 -0
- package/src/server/db/migrations/006_invitation_continuation.ts +27 -0
- package/src/server/db/migrations/007_collaboration_state.ts +25 -0
- package/src/server/db/migrations/008_storage_reservations.ts +37 -0
- package/src/server/db/migrations/009_workspace_entitlements.ts +22 -0
- package/src/server/db/migrations/010_upload_finalization.ts +22 -0
- package/src/server/db/migrations/011_upload_finalization_lease.ts +12 -0
- package/src/server/db/migrations/012_transactional_email.ts +48 -0
- package/src/server/db/migrations/013_admin_enrollment.ts +54 -0
- package/src/server/db/migrations/014_enrollment_email_kinds.ts +30 -0
- package/src/server/db/migrations/015_cloud_rate_limit.ts +22 -0
- package/src/server/db/migrations/016_auth_schema.ts +16 -0
- package/src/server/db/migrations/017_authentication_email_kinds.ts +32 -0
- package/src/server/db/migrations/018_authentication_mfa.ts +78 -0
- package/src/server/db/migrations/019_better_auth_account_issuer.ts +42 -0
- package/src/server/db/migrations/020_workspace_invitations.ts +57 -0
- package/src/server/db/migrations/021_document_versions.ts +66 -0
- package/src/server/db/migrations/022_entitlement_external_version.ts +17 -0
- package/src/server/db/migrations/023_document_images.ts +61 -0
- package/src/server/db/migrations/024_account_activity.ts +66 -0
- package/src/server/db/migrations/025_table_names.ts +58 -0
- package/src/server/db/migrations/026_user_picture.ts +30 -0
- package/src/server/db/migrations/027_document_kind.ts +19 -0
- package/src/server/db/migrations/helpers.ts +78 -0
- package/src/server/db/tables.ts +394 -0
- package/src/server/documents/access.ts +103 -0
- package/src/server/documents/errors.ts +16 -0
- package/src/server/documents/images.ts +407 -0
- package/src/server/documents/index.ts +14 -0
- package/src/server/documents/limits.ts +57 -0
- package/src/server/documents/repository.ts +141 -0
- package/src/server/documents/routes.ts +239 -0
- package/src/server/documents/service.ts +597 -0
- package/src/server/documents/summary.ts +37 -0
- package/src/server/documents/types.ts +14 -0
- package/src/server/documents/versions/checkpoint.ts +98 -0
- package/src/server/documents/versions/history.ts +25 -0
- package/src/server/documents/versions/index.ts +4 -0
- package/src/server/documents/versions/routes.ts +112 -0
- package/src/server/documents/versions/service.ts +397 -0
- package/src/server/email/crypto.ts +57 -0
- package/src/server/email/index.ts +18 -0
- package/src/server/email/invitations.ts +30 -0
- package/src/server/email/service.ts +245 -0
- package/src/server/email/types.ts +56 -0
- package/src/server/email/worker.ts +33 -0
- package/src/server/index.ts +279 -0
- package/src/server/internal/index.ts +8 -0
- package/src/server/internal/routes.ts +41 -0
- package/src/server/internal/schema.ts +10 -0
- package/src/server/internal/service.ts +44 -0
- package/src/server/invitations/index.ts +6 -0
- package/src/server/invitations/types.ts +30 -0
- package/src/server/objects/index.ts +16 -0
- package/src/server/objects/types.ts +81 -0
- package/src/server/pictures/index.ts +9 -0
- package/src/server/pictures/provider.ts +61 -0
- package/src/server/pictures/routes.ts +21 -0
- package/src/server/pictures/service.ts +235 -0
- package/src/server/policy/configured.ts +23 -0
- package/src/server/policy/database.ts +108 -0
- package/src/server/policy/entitlements.ts +29 -0
- package/src/server/policy/index.ts +17 -0
- package/src/server/policy/keys.ts +23 -0
- package/src/server/policy/policy.ts +117 -0
- package/src/server/policy/provider.ts +67 -0
- package/src/server/policy/schema.ts +69 -0
- package/src/server/policy/service.ts +85 -0
- package/src/server/policy/static.ts +62 -0
- package/src/server/quota/index.ts +7 -0
- package/src/server/quota/reconcile.ts +61 -0
- package/src/server/quota/storage.ts +165 -0
- package/src/server/rate-limit/cleanup.ts +16 -0
- package/src/server/rate-limit/index.ts +12 -0
- package/src/server/rate-limit/keys.ts +38 -0
- package/src/server/rate-limit/middleware.ts +137 -0
- package/src/server/rate-limit/postgres.ts +79 -0
- package/src/server/sharing/access.ts +29 -0
- package/src/server/sharing/actor.ts +12 -0
- package/src/server/sharing/capabilities/service.ts +262 -0
- package/src/server/sharing/continuation.ts +85 -0
- package/src/server/sharing/contracts.ts +80 -0
- package/src/server/sharing/crypto.ts +48 -0
- package/src/server/sharing/document-routes.ts +41 -0
- package/src/server/sharing/errors.ts +12 -0
- package/src/server/sharing/grants/service.ts +79 -0
- package/src/server/sharing/http.ts +41 -0
- package/src/server/sharing/index.ts +39 -0
- package/src/server/sharing/invitations/service.ts +315 -0
- package/src/server/sharing/policy.ts +44 -0
- package/src/server/sharing/routes.ts +251 -0
- package/src/server/sharing/service.ts +117 -0
- package/src/server/validation.ts +24 -0
- package/src/server/worker/interval.ts +23 -0
- package/src/server/worker/periodic.ts +42 -0
- package/src/server/workspaces/index.ts +16 -0
- package/src/server/workspaces/members.ts +502 -0
- package/src/server/workspaces/repository.ts +91 -0
- package/src/server/workspaces/routes.ts +198 -0
- package/src/server/workspaces/service.ts +84 -0
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
import {
|
|
2
|
+
cloudAccountMutationResponseSchema,
|
|
3
|
+
cloudAccountSessionsResponseSchema,
|
|
4
|
+
cloudAccountStatusResponseSchema,
|
|
5
|
+
cloudAuthenticationMethodsResponseSchema,
|
|
6
|
+
cloudMFAEnableResponseSchema,
|
|
7
|
+
cloudMFARecoveryCodesResponseSchema,
|
|
8
|
+
cloudMFAStatusResponseSchema,
|
|
9
|
+
cloudMFAVerifyResponseSchema,
|
|
10
|
+
cloudPasskeysResponseSchema,
|
|
11
|
+
cloudPictureResponseSchema,
|
|
12
|
+
cloudProfileResponseSchema,
|
|
13
|
+
cloudSignInsResponseSchema,
|
|
14
|
+
cloudSocialLinkResponseSchema
|
|
15
|
+
} from '#cloud/contract'
|
|
16
|
+
|
|
17
|
+
import type { CloudCall, PortalRouteClients } from './request'
|
|
18
|
+
|
|
19
|
+
export function createAccountAPI(call: CloudCall, { account }: PortalRouteClients) {
|
|
20
|
+
return {
|
|
21
|
+
accountStatus(signal?: AbortSignal) {
|
|
22
|
+
return call(
|
|
23
|
+
(options) => account.status.$get(undefined, options),
|
|
24
|
+
cloudAccountStatusResponseSchema,
|
|
25
|
+
signal
|
|
26
|
+
)
|
|
27
|
+
},
|
|
28
|
+
authenticationMethods(signal?: AbortSignal) {
|
|
29
|
+
return call(
|
|
30
|
+
(options) => account.authentication.$get(undefined, options),
|
|
31
|
+
cloudAuthenticationMethodsResponseSchema,
|
|
32
|
+
signal
|
|
33
|
+
)
|
|
34
|
+
},
|
|
35
|
+
mfaStatus(signal?: AbortSignal) {
|
|
36
|
+
return call(
|
|
37
|
+
(options) => account.mfa.$get(undefined, options),
|
|
38
|
+
cloudMFAStatusResponseSchema,
|
|
39
|
+
signal
|
|
40
|
+
)
|
|
41
|
+
},
|
|
42
|
+
enableTOTP(password?: string, signal?: AbortSignal) {
|
|
43
|
+
return call(
|
|
44
|
+
(options) => account.mfa.totp.enable.$post({ json: { password } }, options),
|
|
45
|
+
cloudMFAEnableResponseSchema,
|
|
46
|
+
signal
|
|
47
|
+
)
|
|
48
|
+
},
|
|
49
|
+
verifyTOTP(code: string, signal?: AbortSignal) {
|
|
50
|
+
return call(
|
|
51
|
+
(options) => account.mfa.totp.verify.$post({ json: { code } }, options),
|
|
52
|
+
cloudMFAVerifyResponseSchema,
|
|
53
|
+
signal
|
|
54
|
+
)
|
|
55
|
+
},
|
|
56
|
+
verifyRecoveryCode(code: string, signal?: AbortSignal) {
|
|
57
|
+
return call(
|
|
58
|
+
(options) => account.mfa.recovery.verify.$post({ json: { code } }, options),
|
|
59
|
+
cloudMFAVerifyResponseSchema,
|
|
60
|
+
signal
|
|
61
|
+
)
|
|
62
|
+
},
|
|
63
|
+
regenerateRecoveryCodes(password?: string, signal?: AbortSignal) {
|
|
64
|
+
return call(
|
|
65
|
+
(options) => account.mfa.recovery.regenerate.$post({ json: { password } }, options),
|
|
66
|
+
cloudMFARecoveryCodesResponseSchema,
|
|
67
|
+
signal
|
|
68
|
+
)
|
|
69
|
+
},
|
|
70
|
+
disableTOTP(password?: string, signal?: AbortSignal) {
|
|
71
|
+
return call(
|
|
72
|
+
(options) => account.mfa.totp.disable.$post({ json: { password } }, options),
|
|
73
|
+
cloudAccountMutationResponseSchema,
|
|
74
|
+
signal
|
|
75
|
+
)
|
|
76
|
+
},
|
|
77
|
+
passkeys(signal?: AbortSignal) {
|
|
78
|
+
return call(
|
|
79
|
+
(options) => account.mfa.passkeys.$get(undefined, options),
|
|
80
|
+
cloudPasskeysResponseSchema,
|
|
81
|
+
signal
|
|
82
|
+
)
|
|
83
|
+
},
|
|
84
|
+
deletePasskey(id: string, signal?: AbortSignal) {
|
|
85
|
+
return call(
|
|
86
|
+
(options) => account.mfa.passkeys.delete.$post({ json: { id } }, options),
|
|
87
|
+
cloudAccountMutationResponseSchema,
|
|
88
|
+
signal
|
|
89
|
+
)
|
|
90
|
+
},
|
|
91
|
+
changePassword(currentPassword: string, newPassword: string, signal?: AbortSignal) {
|
|
92
|
+
return call(
|
|
93
|
+
(options) =>
|
|
94
|
+
account.authentication['change-password'].$post(
|
|
95
|
+
{ json: { currentPassword, newPassword } },
|
|
96
|
+
options
|
|
97
|
+
),
|
|
98
|
+
cloudAccountMutationResponseSchema,
|
|
99
|
+
signal
|
|
100
|
+
)
|
|
101
|
+
},
|
|
102
|
+
linkSocial(provider: 'google' | 'apple', callbackURL: string, signal?: AbortSignal) {
|
|
103
|
+
return call(
|
|
104
|
+
(options) =>
|
|
105
|
+
account.authentication['link-social'].$post({ json: { provider, callbackURL } }, options),
|
|
106
|
+
cloudSocialLinkResponseSchema,
|
|
107
|
+
signal
|
|
108
|
+
)
|
|
109
|
+
},
|
|
110
|
+
profile(signal?: AbortSignal) {
|
|
111
|
+
return call(
|
|
112
|
+
(options) => account.profile.$get(undefined, options),
|
|
113
|
+
cloudProfileResponseSchema,
|
|
114
|
+
signal
|
|
115
|
+
)
|
|
116
|
+
},
|
|
117
|
+
updateProfile(name: string, signal?: AbortSignal) {
|
|
118
|
+
return call(
|
|
119
|
+
(options) => account.profile.$post({ json: { name } }, options),
|
|
120
|
+
cloudAccountMutationResponseSchema,
|
|
121
|
+
signal
|
|
122
|
+
)
|
|
123
|
+
},
|
|
124
|
+
/** Shows `data`, a Base64 PNG or JPEG the page cropped and shrank, as the account's picture. */
|
|
125
|
+
uploadPicture(data: string, signal?: AbortSignal) {
|
|
126
|
+
return call(
|
|
127
|
+
(options) => account.profile.picture.$put({ json: { data } }, options),
|
|
128
|
+
cloudPictureResponseSchema,
|
|
129
|
+
signal
|
|
130
|
+
)
|
|
131
|
+
},
|
|
132
|
+
removePicture(signal?: AbortSignal) {
|
|
133
|
+
return call(
|
|
134
|
+
(options) => account.profile.picture.$delete(undefined, options),
|
|
135
|
+
cloudAccountMutationResponseSchema,
|
|
136
|
+
signal
|
|
137
|
+
)
|
|
138
|
+
},
|
|
139
|
+
/** Sends a confirmation to the new address; the email changes once it is followed. */
|
|
140
|
+
changeEmail(newEmail: string, callbackURL: string, signal?: AbortSignal) {
|
|
141
|
+
return call(
|
|
142
|
+
(options) => account.profile.email.$post({ json: { newEmail, callbackURL } }, options),
|
|
143
|
+
cloudAccountMutationResponseSchema,
|
|
144
|
+
signal
|
|
145
|
+
)
|
|
146
|
+
},
|
|
147
|
+
sessions(signal?: AbortSignal) {
|
|
148
|
+
return call(
|
|
149
|
+
(options) => account.sessions.$get(undefined, options),
|
|
150
|
+
cloudAccountSessionsResponseSchema,
|
|
151
|
+
signal
|
|
152
|
+
)
|
|
153
|
+
},
|
|
154
|
+
revokeSession(sessionId: string, signal?: AbortSignal) {
|
|
155
|
+
return call(
|
|
156
|
+
(options) => account.sessions.revoke.$post({ json: { sessionId } }, options),
|
|
157
|
+
cloudAccountMutationResponseSchema,
|
|
158
|
+
signal
|
|
159
|
+
)
|
|
160
|
+
},
|
|
161
|
+
revokeOtherSessions(signal?: AbortSignal) {
|
|
162
|
+
return call(
|
|
163
|
+
(options) => account.sessions['revoke-others'].$post(undefined, options),
|
|
164
|
+
cloudAccountMutationResponseSchema,
|
|
165
|
+
signal
|
|
166
|
+
)
|
|
167
|
+
},
|
|
168
|
+
signIns(signal?: AbortSignal) {
|
|
169
|
+
return call(
|
|
170
|
+
(options) => account['sign-ins'].$get(undefined, options),
|
|
171
|
+
cloudSignInsResponseSchema,
|
|
172
|
+
signal
|
|
173
|
+
)
|
|
174
|
+
},
|
|
175
|
+
unlinkAuthenticationMethod(methodId: string, signal?: AbortSignal) {
|
|
176
|
+
return call(
|
|
177
|
+
(options) => account.authentication.unlink.$post({ json: { methodId } }, options),
|
|
178
|
+
cloudAccountMutationResponseSchema,
|
|
179
|
+
signal
|
|
180
|
+
)
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
}
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
import {
|
|
2
|
+
adminAuditResponseSchema,
|
|
3
|
+
adminEmailResponseSchema,
|
|
4
|
+
adminMutationResponseSchema,
|
|
5
|
+
adminOperationsResponseSchema,
|
|
6
|
+
cloudAdminSessionResponseSchema,
|
|
7
|
+
cloudAdminUserDetailSchema,
|
|
8
|
+
cloudAdminUsersResponseSchema,
|
|
9
|
+
enrollmentReviewResponseSchema,
|
|
10
|
+
enrollmentsResponseSchema,
|
|
11
|
+
type CloudAdminAuditFilter,
|
|
12
|
+
type CloudAdminEmailFilter,
|
|
13
|
+
type CloudAdminUserFilter,
|
|
14
|
+
type EnrollmentStatus
|
|
15
|
+
} from '#cloud/contract'
|
|
16
|
+
|
|
17
|
+
import type { CloudCall, PortalRouteClients } from './request'
|
|
18
|
+
|
|
19
|
+
/** A page of an admin list: words to search for, one of its filters, and where the page starts. */
|
|
20
|
+
export type AdminListRequest<Filter extends string> = {
|
|
21
|
+
search?: string
|
|
22
|
+
filter?: Filter
|
|
23
|
+
limit?: number
|
|
24
|
+
offset?: number
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/** The query string for `request`; an empty search asks for everything. */
|
|
28
|
+
function listQuery<Filter extends string>(request: AdminListRequest<Filter>) {
|
|
29
|
+
return {
|
|
30
|
+
query: {
|
|
31
|
+
search: request.search || undefined,
|
|
32
|
+
filter: request.filter,
|
|
33
|
+
limit: request.limit,
|
|
34
|
+
offset: request.offset
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export function createAdministrationAPI(call: CloudCall, { admin, api }: PortalRouteClients) {
|
|
40
|
+
return {
|
|
41
|
+
session(signal?: AbortSignal) {
|
|
42
|
+
return call(
|
|
43
|
+
(options) => api.session.$get(undefined, options),
|
|
44
|
+
cloudAdminSessionResponseSchema,
|
|
45
|
+
signal
|
|
46
|
+
)
|
|
47
|
+
},
|
|
48
|
+
enrollments(request: AdminListRequest<EnrollmentStatus>, signal?: AbortSignal) {
|
|
49
|
+
return call(
|
|
50
|
+
(options) => admin.enrollments.$get(listQuery(request), options),
|
|
51
|
+
enrollmentsResponseSchema,
|
|
52
|
+
signal
|
|
53
|
+
)
|
|
54
|
+
},
|
|
55
|
+
reviewEnrollment(
|
|
56
|
+
id: string,
|
|
57
|
+
action: 'approve' | 'reject' | 'revoke',
|
|
58
|
+
note?: string,
|
|
59
|
+
signal?: AbortSignal
|
|
60
|
+
) {
|
|
61
|
+
return call(
|
|
62
|
+
(options) =>
|
|
63
|
+
admin.enrollments[':id'][action].$post({ param: { id }, json: { note } }, options),
|
|
64
|
+
enrollmentReviewResponseSchema,
|
|
65
|
+
signal
|
|
66
|
+
)
|
|
67
|
+
},
|
|
68
|
+
users(request: AdminListRequest<CloudAdminUserFilter>, signal?: AbortSignal) {
|
|
69
|
+
return call(
|
|
70
|
+
(options) => admin.users.$get(listQuery(request), options),
|
|
71
|
+
cloudAdminUsersResponseSchema,
|
|
72
|
+
signal
|
|
73
|
+
)
|
|
74
|
+
},
|
|
75
|
+
user(id: string, signal?: AbortSignal) {
|
|
76
|
+
return call(
|
|
77
|
+
(options) => admin.users[':id'].$get({ param: { id } }, options),
|
|
78
|
+
cloudAdminUserDetailSchema,
|
|
79
|
+
signal
|
|
80
|
+
)
|
|
81
|
+
},
|
|
82
|
+
userAction(
|
|
83
|
+
action: 'ban' | 'unban' | 'revoke-sessions' | 'reset-two-step' | 'remove-picture',
|
|
84
|
+
userId: string,
|
|
85
|
+
reason?: string,
|
|
86
|
+
signal?: AbortSignal
|
|
87
|
+
) {
|
|
88
|
+
return call(
|
|
89
|
+
(options) => admin.users[action].$post({ json: { userId, reason } }, options),
|
|
90
|
+
adminMutationResponseSchema,
|
|
91
|
+
signal
|
|
92
|
+
)
|
|
93
|
+
},
|
|
94
|
+
setAdmin(userId: string, enabled: boolean, signal?: AbortSignal) {
|
|
95
|
+
return call(
|
|
96
|
+
(options) => admin.users['set-admin'].$post({ json: { userId, enabled } }, options),
|
|
97
|
+
adminMutationResponseSchema,
|
|
98
|
+
signal
|
|
99
|
+
)
|
|
100
|
+
},
|
|
101
|
+
email(request: AdminListRequest<CloudAdminEmailFilter>, signal?: AbortSignal) {
|
|
102
|
+
return call(
|
|
103
|
+
(options) => admin.email.$get(listQuery(request), options),
|
|
104
|
+
adminEmailResponseSchema,
|
|
105
|
+
signal
|
|
106
|
+
)
|
|
107
|
+
},
|
|
108
|
+
regenerateEmail(id: string, signal?: AbortSignal) {
|
|
109
|
+
return call(
|
|
110
|
+
(options) => admin.email[':id'].regenerate.$post({ param: { id } }, options),
|
|
111
|
+
adminMutationResponseSchema,
|
|
112
|
+
signal
|
|
113
|
+
)
|
|
114
|
+
},
|
|
115
|
+
audit(request: AdminListRequest<CloudAdminAuditFilter>, signal?: AbortSignal) {
|
|
116
|
+
return call(
|
|
117
|
+
(options) => admin.audit.$get(listQuery(request), options),
|
|
118
|
+
adminAuditResponseSchema,
|
|
119
|
+
signal
|
|
120
|
+
)
|
|
121
|
+
},
|
|
122
|
+
operations(signal?: AbortSignal) {
|
|
123
|
+
return call(
|
|
124
|
+
(options) => admin.operations.$get(undefined, options),
|
|
125
|
+
adminOperationsResponseSchema,
|
|
126
|
+
signal
|
|
127
|
+
)
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { createAccountAPI } from './account'
|
|
2
|
+
import { createAdministrationAPI } from './administration'
|
|
3
|
+
import { createCloudCall, createPortalRouteClients, type CloudPortalClientOptions } from './request'
|
|
4
|
+
|
|
5
|
+
export { CloudPortalAPIError, type CloudPortalAPIErrorKind } from './request'
|
|
6
|
+
export type { CloudPortalClientOptions } from './request'
|
|
7
|
+
|
|
8
|
+
/** The account and administration routes Cloud's own web pages use, validated against the contract. */
|
|
9
|
+
export function createCloudPortalClient(options: CloudPortalClientOptions = {}) {
|
|
10
|
+
const call = createCloudCall(options)
|
|
11
|
+
const routes = createPortalRouteClients(options)
|
|
12
|
+
return {
|
|
13
|
+
...createAccountAPI(call, routes),
|
|
14
|
+
...createAdministrationAPI(call, routes)
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export type CloudPortalClient = ReturnType<typeof createCloudPortalClient>
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import type { CloudAdminRoutes } from '#cloud/admin/api/routes'
|
|
2
|
+
import type { CloudFetch } from '#cloud/client/discovery'
|
|
3
|
+
import {
|
|
4
|
+
accountSecurityErrorResponseSchema,
|
|
5
|
+
adminErrorResponseSchema,
|
|
6
|
+
type AccountSecurityErrorCode,
|
|
7
|
+
type AdminErrorCode
|
|
8
|
+
} from '#cloud/contract'
|
|
9
|
+
import type { CloudAccountRoutes } from '#cloud/server/account/routes'
|
|
10
|
+
import type { CloudAPI } from '#cloud/server/api'
|
|
11
|
+
import { hc } from 'hono/client'
|
|
12
|
+
import * as v from 'valibot'
|
|
13
|
+
|
|
14
|
+
export type CloudPortalAPIErrorKind =
|
|
15
|
+
| 'authentication-required'
|
|
16
|
+
| 'authorization-required'
|
|
17
|
+
| 'cancelled'
|
|
18
|
+
| 'domain'
|
|
19
|
+
| 'network'
|
|
20
|
+
| 'protocol'
|
|
21
|
+
| 'timeout'
|
|
22
|
+
|
|
23
|
+
export class CloudPortalAPIError extends Error {
|
|
24
|
+
override readonly name = 'CloudPortalAPIError'
|
|
25
|
+
|
|
26
|
+
constructor(
|
|
27
|
+
readonly kind: CloudPortalAPIErrorKind,
|
|
28
|
+
readonly code?: AdminErrorCode | AccountSecurityErrorCode,
|
|
29
|
+
options?: ErrorOptions
|
|
30
|
+
) {
|
|
31
|
+
super(kind, options)
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export type CloudPortalClientOptions = {
|
|
36
|
+
baseURL?: string
|
|
37
|
+
fetch?: CloudFetch
|
|
38
|
+
timeoutMs?: number
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/** The parts of a response the portal reads; the typed Hono clients' responses have them. */
|
|
42
|
+
type PortalResponse = Pick<Response, 'ok' | 'status' | 'json'>
|
|
43
|
+
|
|
44
|
+
/** Sends one request with the call's `init` (its signal); the typed Hono clients fit this shape. */
|
|
45
|
+
export type CloudSend = (options: { init: RequestInit }) => Promise<PortalResponse>
|
|
46
|
+
|
|
47
|
+
export type CloudCall = <Output>(
|
|
48
|
+
send: CloudSend,
|
|
49
|
+
schema: v.GenericSchema<unknown, Output>,
|
|
50
|
+
signal?: AbortSignal
|
|
51
|
+
) => Promise<Output>
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Sends a request and reads its answer the same way for every portal route: transport failures,
|
|
55
|
+
* missing sessions and permissions, and domain errors become `CloudPortalAPIError`, and a success
|
|
56
|
+
* body is checked against the contract.
|
|
57
|
+
*/
|
|
58
|
+
export function createCloudCall(options: CloudPortalClientOptions = {}): CloudCall {
|
|
59
|
+
const timeoutMs = options.timeoutMs ?? 10_000
|
|
60
|
+
return async (send, schema, callerSignal) => {
|
|
61
|
+
const timeout = AbortSignal.timeout(timeoutMs)
|
|
62
|
+
const signal = callerSignal ? AbortSignal.any([callerSignal, timeout]) : timeout
|
|
63
|
+
let response: PortalResponse
|
|
64
|
+
try {
|
|
65
|
+
response = await send({ init: { signal } })
|
|
66
|
+
} catch (cause) {
|
|
67
|
+
if (callerSignal?.aborted) throw new CloudPortalAPIError('cancelled', undefined, { cause })
|
|
68
|
+
if (timeout.aborted) throw new CloudPortalAPIError('timeout', undefined, { cause })
|
|
69
|
+
throw new CloudPortalAPIError('network', undefined, { cause })
|
|
70
|
+
}
|
|
71
|
+
if (response.status === 401) throw new CloudPortalAPIError('authentication-required')
|
|
72
|
+
let body: unknown
|
|
73
|
+
try {
|
|
74
|
+
body = await response.json()
|
|
75
|
+
} catch (cause) {
|
|
76
|
+
if (response.status === 403) throw new CloudPortalAPIError('authorization-required')
|
|
77
|
+
throw new CloudPortalAPIError('protocol', undefined, { cause })
|
|
78
|
+
}
|
|
79
|
+
if (!response.ok) {
|
|
80
|
+
const accountError = v.safeParse(accountSecurityErrorResponseSchema, body)
|
|
81
|
+
const adminError = v.safeParse(adminErrorResponseSchema, body)
|
|
82
|
+
let code: AdminErrorCode | AccountSecurityErrorCode | undefined
|
|
83
|
+
if (accountError.success) code = accountError.output.error.code
|
|
84
|
+
else if (adminError.success) code = adminError.output.error.code
|
|
85
|
+
// A refusal that says why, such as a session that must sign in again, is the domain's;
|
|
86
|
+
// a bare or plain `forbidden` one is a missing permission.
|
|
87
|
+
if (response.status === 403 && (!code || code === 'forbidden')) {
|
|
88
|
+
throw new CloudPortalAPIError('authorization-required')
|
|
89
|
+
}
|
|
90
|
+
throw new CloudPortalAPIError('domain', code)
|
|
91
|
+
}
|
|
92
|
+
const parsed = v.safeParse(schema, body)
|
|
93
|
+
if (!parsed.success) {
|
|
94
|
+
throw new CloudPortalAPIError('protocol', undefined, { cause: parsed.issues })
|
|
95
|
+
}
|
|
96
|
+
return parsed.output
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
/** Typed clients for the routes the portal calls, all on the server's own address. */
|
|
101
|
+
export function createPortalRouteClients(options: CloudPortalClientOptions = {}) {
|
|
102
|
+
const origin = options.baseURL ?? globalThis.location.origin
|
|
103
|
+
const clientOptions = {
|
|
104
|
+
fetch: options.fetch,
|
|
105
|
+
headers: { Accept: 'application/json' },
|
|
106
|
+
init: { credentials: 'include' as const }
|
|
107
|
+
}
|
|
108
|
+
return {
|
|
109
|
+
account: hc<CloudAccountRoutes>(origin, clientOptions).api.account,
|
|
110
|
+
admin: hc<CloudAdminRoutes>(new URL('/api/admin', origin).href, clientOptions),
|
|
111
|
+
api: hc<CloudAPI>(new URL('/api', origin).href, clientOptions)
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
export type PortalRouteClients = ReturnType<typeof createPortalRouteClients>
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import * as v from 'valibot'
|
|
2
|
+
|
|
3
|
+
const cloudErrorResponseSchema = v.object({
|
|
4
|
+
error: v.object({ code: v.string() })
|
|
5
|
+
})
|
|
6
|
+
|
|
7
|
+
/** The part of a fetch or Hono client response the client reads. */
|
|
8
|
+
export type CloudResponse = Pick<Response, 'ok' | 'status' | 'json'>
|
|
9
|
+
|
|
10
|
+
export type CloudClientDiagnostic = (message: string, error: unknown) => void
|
|
11
|
+
|
|
12
|
+
export class CloudAPIError extends Error {
|
|
13
|
+
override readonly name = 'CloudAPIError'
|
|
14
|
+
|
|
15
|
+
constructor(
|
|
16
|
+
message: string,
|
|
17
|
+
readonly status: number,
|
|
18
|
+
readonly code?: string
|
|
19
|
+
) {
|
|
20
|
+
super(message)
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export async function responseBody(
|
|
25
|
+
response: CloudResponse,
|
|
26
|
+
onDiagnostic?: CloudClientDiagnostic
|
|
27
|
+
): Promise<unknown> {
|
|
28
|
+
if (response.ok) return response.status === 204 ? null : response.json()
|
|
29
|
+
let code: string | undefined
|
|
30
|
+
try {
|
|
31
|
+
const body = v.safeParse(cloudErrorResponseSchema, await response.json())
|
|
32
|
+
if (body.success) code = body.output.error.code
|
|
33
|
+
} catch (error) {
|
|
34
|
+
onDiagnostic?.('Cloud API error response was not JSON', error)
|
|
35
|
+
}
|
|
36
|
+
throw new CloudAPIError(
|
|
37
|
+
`OpenPencil Cloud request failed with HTTP ${response.status}`,
|
|
38
|
+
response.status,
|
|
39
|
+
code
|
|
40
|
+
)
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export async function parseResponse<
|
|
44
|
+
TSchema extends v.BaseSchema<unknown, unknown, v.BaseIssue<unknown>>
|
|
45
|
+
>(
|
|
46
|
+
request: Promise<CloudResponse>,
|
|
47
|
+
schema: TSchema,
|
|
48
|
+
onDiagnostic?: CloudClientDiagnostic
|
|
49
|
+
): Promise<v.InferOutput<TSchema>> {
|
|
50
|
+
return v.parse(schema, await responseBody(await request, onDiagnostic))
|
|
51
|
+
}
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
import {
|
|
2
|
+
createdWorkspaceInvitationSchema,
|
|
3
|
+
workspaceEntitlementsSchema,
|
|
4
|
+
workspaceListSchema,
|
|
5
|
+
workspaceMembersSchema,
|
|
6
|
+
workspaceSummarySchema,
|
|
7
|
+
workspaceUsageSchema,
|
|
8
|
+
type CreatedWorkspaceInvitation,
|
|
9
|
+
type CreateWorkspaceInvitationInput,
|
|
10
|
+
type WorkspaceEntitlements,
|
|
11
|
+
type WorkspaceList,
|
|
12
|
+
type WorkspaceMembers,
|
|
13
|
+
type WorkspaceRole,
|
|
14
|
+
type WorkspaceSummary,
|
|
15
|
+
type WorkspaceUsage
|
|
16
|
+
} from '#cloud/contract'
|
|
17
|
+
import type { CloudAPI } from '#cloud/server/api'
|
|
18
|
+
import type { hc } from 'hono/client'
|
|
19
|
+
import * as v from 'valibot'
|
|
20
|
+
|
|
21
|
+
import { parseResponse, responseBody, type CloudClientDiagnostic } from './response'
|
|
22
|
+
|
|
23
|
+
const workspaceResponseSchema = v.object({ workspace: workspaceSummarySchema })
|
|
24
|
+
const usageResponseSchema = v.object({ usage: workspaceUsageSchema })
|
|
25
|
+
const entitlementResponseSchema = v.object({ entitlements: workspaceEntitlementsSchema })
|
|
26
|
+
|
|
27
|
+
/** Workspaces, their members, invitations, entitlements, and storage use. */
|
|
28
|
+
export function createWorkspaceRequests(
|
|
29
|
+
client: ReturnType<typeof hc<CloudAPI>>,
|
|
30
|
+
onDiagnostic?: CloudClientDiagnostic
|
|
31
|
+
) {
|
|
32
|
+
return {
|
|
33
|
+
async listWorkspaces(): Promise<WorkspaceList> {
|
|
34
|
+
return parseResponse(client.workspaces.$get(), workspaceListSchema, onDiagnostic)
|
|
35
|
+
},
|
|
36
|
+
async createWorkspace(name: string): Promise<WorkspaceSummary> {
|
|
37
|
+
const response = await parseResponse(
|
|
38
|
+
client.workspaces.$post({ json: { name } }),
|
|
39
|
+
workspaceResponseSchema,
|
|
40
|
+
onDiagnostic
|
|
41
|
+
)
|
|
42
|
+
return response.workspace
|
|
43
|
+
},
|
|
44
|
+
async renameWorkspace(workspaceId: string, name: string): Promise<WorkspaceSummary> {
|
|
45
|
+
const response = await parseResponse(
|
|
46
|
+
client.workspaces[':workspaceId'].$patch({ param: { workspaceId }, json: { name } }),
|
|
47
|
+
workspaceResponseSchema,
|
|
48
|
+
onDiagnostic
|
|
49
|
+
)
|
|
50
|
+
return response.workspace
|
|
51
|
+
},
|
|
52
|
+
/** Deletes an empty workspace; the server refuses one that still holds documents. */
|
|
53
|
+
async deleteWorkspace(workspaceId: string): Promise<void> {
|
|
54
|
+
await responseBody(
|
|
55
|
+
await client.workspaces[':workspaceId'].$delete({ param: { workspaceId } }),
|
|
56
|
+
onDiagnostic
|
|
57
|
+
)
|
|
58
|
+
},
|
|
59
|
+
/** The workspace's members, and for administrators its pending invitations. */
|
|
60
|
+
async listWorkspaceMembers(workspaceId: string): Promise<WorkspaceMembers> {
|
|
61
|
+
return parseResponse(
|
|
62
|
+
client.workspaces[':workspaceId'].members.$get({ param: { workspaceId } }),
|
|
63
|
+
workspaceMembersSchema,
|
|
64
|
+
onDiagnostic
|
|
65
|
+
)
|
|
66
|
+
},
|
|
67
|
+
async inviteToWorkspace(
|
|
68
|
+
workspaceId: string,
|
|
69
|
+
input: CreateWorkspaceInvitationInput
|
|
70
|
+
): Promise<CreatedWorkspaceInvitation> {
|
|
71
|
+
return parseResponse(
|
|
72
|
+
client.workspaces[':workspaceId'].invitations.$post({
|
|
73
|
+
param: { workspaceId },
|
|
74
|
+
json: input
|
|
75
|
+
}),
|
|
76
|
+
createdWorkspaceInvitationSchema,
|
|
77
|
+
onDiagnostic
|
|
78
|
+
)
|
|
79
|
+
},
|
|
80
|
+
/** Sends a waiting invitation again; its earlier link stops working. */
|
|
81
|
+
async resendWorkspaceInvitation(
|
|
82
|
+
workspaceId: string,
|
|
83
|
+
invitationId: string
|
|
84
|
+
): Promise<CreatedWorkspaceInvitation> {
|
|
85
|
+
return parseResponse(
|
|
86
|
+
client.workspaces[':workspaceId'].invitations[':invitationId'].resend.$post({
|
|
87
|
+
param: { workspaceId, invitationId }
|
|
88
|
+
}),
|
|
89
|
+
createdWorkspaceInvitationSchema,
|
|
90
|
+
onDiagnostic
|
|
91
|
+
)
|
|
92
|
+
},
|
|
93
|
+
async revokeWorkspaceInvitation(workspaceId: string, invitationId: string): Promise<void> {
|
|
94
|
+
await responseBody(
|
|
95
|
+
await client.workspaces[':workspaceId'].invitations[':invitationId'].$delete({
|
|
96
|
+
param: { workspaceId, invitationId }
|
|
97
|
+
}),
|
|
98
|
+
onDiagnostic
|
|
99
|
+
)
|
|
100
|
+
},
|
|
101
|
+
async updateWorkspaceMember(
|
|
102
|
+
workspaceId: string,
|
|
103
|
+
userId: string,
|
|
104
|
+
role: WorkspaceRole
|
|
105
|
+
): Promise<void> {
|
|
106
|
+
await responseBody(
|
|
107
|
+
await client.workspaces[':workspaceId'].members[':userId'].$patch({
|
|
108
|
+
param: { workspaceId, userId },
|
|
109
|
+
json: { role }
|
|
110
|
+
}),
|
|
111
|
+
onDiagnostic
|
|
112
|
+
)
|
|
113
|
+
},
|
|
114
|
+
/** Removes someone from the workspace; with the person's own id, leaves it. */
|
|
115
|
+
async removeWorkspaceMember(workspaceId: string, userId: string): Promise<void> {
|
|
116
|
+
await responseBody(
|
|
117
|
+
await client.workspaces[':workspaceId'].members[':userId'].$delete({
|
|
118
|
+
param: { workspaceId, userId }
|
|
119
|
+
}),
|
|
120
|
+
onDiagnostic
|
|
121
|
+
)
|
|
122
|
+
},
|
|
123
|
+
async getWorkspaceEntitlements(workspaceId: string): Promise<WorkspaceEntitlements> {
|
|
124
|
+
const response = await parseResponse(
|
|
125
|
+
client.workspaces[':workspaceId'].entitlements.$get({ param: { workspaceId } }),
|
|
126
|
+
entitlementResponseSchema,
|
|
127
|
+
onDiagnostic
|
|
128
|
+
)
|
|
129
|
+
return response.entitlements
|
|
130
|
+
},
|
|
131
|
+
async getUsage(workspaceId: string): Promise<WorkspaceUsage> {
|
|
132
|
+
const response = await parseResponse(
|
|
133
|
+
client.workspaces[':workspaceId'].usage.$get({
|
|
134
|
+
param: { workspaceId }
|
|
135
|
+
}),
|
|
136
|
+
usageResponseSchema,
|
|
137
|
+
onDiagnostic
|
|
138
|
+
)
|
|
139
|
+
return response.usage
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
}
|