Buckets:
| import { z } from "zod" | |
| import { fn } from "./util/fn" | |
| import { Actor } from "./actor" | |
| import { and, Database, eq, isNull } from "./drizzle" | |
| import { Identifier } from "./identifier" | |
| import { ProviderTable } from "./schema/provider.sql" | |
| export namespace Provider { | |
| export const list = fn(z.void(), () => | |
| Database.use((tx) => | |
| tx | |
| .select() | |
| .from(ProviderTable) | |
| .where(and(eq(ProviderTable.workspaceID, Actor.workspace()), isNull(ProviderTable.timeDeleted))), | |
| ), | |
| ) | |
| export const create = fn( | |
| z.object({ | |
| provider: z.string().min(1).max(64), | |
| credentials: z.string(), | |
| }), | |
| async ({ provider, credentials }) => { | |
| Actor.assertAdmin() | |
| return Database.use((tx) => | |
| tx | |
| .insert(ProviderTable) | |
| .values({ | |
| id: Identifier.create("provider"), | |
| workspaceID: Actor.workspace(), | |
| provider, | |
| credentials, | |
| }) | |
| .onDuplicateKeyUpdate({ | |
| set: { | |
| credentials, | |
| timeDeleted: null, | |
| }, | |
| }), | |
| ) | |
| }, | |
| ) | |
| export const remove = fn( | |
| z.object({ | |
| provider: z.string(), | |
| }), | |
| async ({ provider }) => { | |
| Actor.assertAdmin() | |
| return Database.use((tx) => | |
| tx | |
| .delete(ProviderTable) | |
| .where(and(eq(ProviderTable.provider, provider), eq(ProviderTable.workspaceID, Actor.workspace()))), | |
| ) | |
| }, | |
| ) | |
| } | |
Xet Storage Details
- Size:
- 1.46 kB
- Xet hash:
- dd4bb2dce90ce78e21d6295688e6f3e9a9d1e8ad13818b4327bf9e4d16210059
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.