Le SDK
Le SDK de StudioCMS est un outil puissant qui vous permet d’interagir avec StudioCMS par programmation. Il fournit un ensemble de fonctions et d’utilitaires pour gérer et diffuser votre contenu via notre propre client de base de données interne Kysely^. Il constitue également la base du tableau de bord StudioCMS et est basé sur Effect^.
Utilisation de base
Section intitulée « Utilisation de base »Le SDK de StudioCMS est disponible sous forme de module virtuel dans votre projet Astro. Vous pouvez l’importer et l’utiliser avec la syntaxe suivante :
import { const SDKCore: Effect.Effect<{ AUTH: { verifyEmail: { get: (input: string) => Effect.Effect<{ readonly id: string; readonly userId: string; readonly expiresAt: Date; readonly token: string; } | undefined, DBCallbackFailure | DatabaseError, never>; create: (userId: string) => Effect.Effect<{ readonly id: string; readonly userId: string; readonly expiresAt: Date; readonly token: string; }, DBCallbackFailure | DatabaseError | GeneratorError, never>; delete: (input: string) => Effect.Effect<DeleteResult, DBCallbackFailure | DatabaseError, never>; }; oAuth: { create: (input: { readonly providerUserId: string; readonly provider: string; readonly userId: string; }) => Effect.Effect<{ readonly providerUserId: string; readonly provider: string; readonly userId: string; }, DBCallbackFailure | DatabaseError, never>; delete: (input: { readonly userId: string; readonly provider: string; }) => AuthDeletionResponse; searchByProviderId: (input: { readonly providerUserId: string; readonly userId: string; }) => Effect.Effect<{ readonly providerUserId: string; readonly provider: string; readonly userId: string; } | undefined, DBCallbackFailure | DatabaseError, never>; searchProvidersForId: (input: { readonly userId: string; readonly providerId: string; }) => Effect.Effect<{ readonly providerUserId: string; readonly provider: string; readonly userId: string; } | undefined, DBCallbackFailure | DatabaseError, never>; }; permission: { currentStatus: (input: string) => Effect.Effect<{ readonly user: string; readonly rank: "owner" | "admin" | "editor" | "visitor" | "unknown"; } | undefined, DBCallbackFailure | DatabaseError, never>; }; session: { create: (input: { readonly id: string; readonly userId: string; readonly expiresAt: string; }) => Effect.Effect<{ readonly id: string; readonly userId: string; readonly expiresAt: Date; }, DBCallbackFailure | DatabaseError, never>; getById: (input: string) => Effect.Effect<{ readonly id: string; readonly userId: string; readonly expiresAt: Date; } | undefined, DBCallbackFailure | DatabaseError, never>; sessionWithUser: (sessionId: string) => Effect.Effect<{ session: { readonly id: string; readonly userId: string; readonly expiresAt: Date; }; user: { readonly id: string; readonly url?: string | null | undefined; readonly name: string; readonly email?: string | null | undefined; readonly avatar?: string | null | undefined; readonly username: string; readonly password?: string | null | undefined; readonly updatedAt: Date; readonly createdAt: Date; readonly emailVerified: boolean; readonly notifications?: string | null | undefined; }; } | undefined, DBCallbackFailure | DatabaseError, never>; delete: (input: string) => AuthDeletionResponse; update: (input: { readonly id: string; readonly newDate: Date; }) => Effect.Effect<{ readonly id: string; readonly userId: string; readonly expiresAt: Date; }, DBCallbackFailure | DatabaseError, never>; }; user: { create: (userData: { readonly id: string; readonly url?: string | null | undefined; readonly name: string; readonly email?: string | null | undefined; readonly avatar?: string | null | undefined; readonly username: string; readonly password?: string | null | undefined; readonly updatedAt: string; readonly createdAt: string | undefined; readonly emailVerified: boolean; readonly notifications?: string | null | undefined; }, rank: "owner" | "admin" | "editor" ...
The new Effect-TS based SDK implementation that replaces the deprecated SDK.
This unified SDK merges the normal and cached SDK functionalities.
SDKCore, const SDKCoreJs: { AUTH: { verifyEmail: { get: (input: string) => Effect.Effect<{ readonly id: string; readonly userId: string; readonly expiresAt: Date; readonly token: string; } | undefined, DBCallbackFailure | DatabaseError, never>; create: (userId: string) => Effect.Effect<{ readonly id: string; readonly userId: string; readonly expiresAt: Date; readonly token: string; }, DBCallbackFailure | DatabaseError | GeneratorError, never>; delete: (input: string) => Effect.Effect<DeleteResult, DBCallbackFailure | DatabaseError, never>; }; oAuth: { create: (input: { readonly providerUserId: string; readonly provider: string; readonly userId: string; }) => Effect.Effect<{ readonly providerUserId: string; readonly provider: string; readonly userId: string; }, DBCallbackFailure | DatabaseError, never>; delete: (input: { readonly userId: string; readonly provider: string; }) => AuthDeletionResponse; searchByProviderId: (input: { readonly providerUserId: string; readonly userId: string; }) => Effect.Effect<{ readonly providerUserId: string; readonly provider: string; readonly userId: string; } | undefined, DBCallbackFailure | DatabaseError, never>; searchProvidersForId: (input: { readonly userId: string; readonly providerId: string; }) => Effect.Effect<{ readonly providerUserId: string; readonly provider: string; readonly userId: string; } | undefined, DBCallbackFailure | DatabaseError, never>; }; permission: { currentStatus: (input: string) => Effect.Effect<{ readonly user: string; readonly rank: "owner" | "admin" | "editor" | "visitor" | "unknown"; } | undefined, DBCallbackFailure | DatabaseError, never>; }; session: { create: (input: { readonly id: string; readonly userId: string; readonly expiresAt: string; }) => Effect.Effect<{ readonly id: string; readonly userId: string; readonly expiresAt: Date; }, DBCallbackFailure | DatabaseError, never>; getById: (input: string) => Effect.Effect<{ readonly id: string; readonly userId: string; readonly expiresAt: Date; } | undefined, DBCallbackFailure | DatabaseError, never>; sessionWithUser: (sessionId: string) => Effect.Effect<{ session: { readonly id: string; readonly userId: string; readonly expiresAt: Date; }; user: { readonly id: string; readonly url?: string | null | undefined; readonly name: string; readonly email?: string | null | undefined; readonly avatar?: string | null | undefined; readonly username: string; readonly password?: string | null | undefined; readonly updatedAt: Date; readonly createdAt: Date; readonly emailVerified: boolean; readonly notifications?: string | null | undefined; }; } | undefined, DBCallbackFailure | DatabaseError, never>; delete: (input: string) => AuthDeletionResponse; update: (input: { readonly id: string; readonly newDate: Date; }) => Effect.Effect<{ readonly id: string; readonly userId: string; readonly expiresAt: Date; }, DBCallbackFailure | DatabaseError, never>; }; user: { create: (userData: { readonly id: string; readonly url?: string | null | undefined; readonly name: string; readonly email?: string | null | undefined; readonly avatar?: string | null | undefined; readonly username: string; readonly password?: string | null | undefined; readonly updatedAt: string; readonly createdAt: string | undefined; readonly emailVerified: boolean; readonly notifications?: string | null | undefined; }, rank: "owner" | "admin" | "editor" | "visitor" | ...
VanillaJS Version of the SDKCore. Most internal functions will still contain Effects, you can use runSDK from the 'studiocms:sdk' to run these as normal async functions
SDKCoreJs, const runSDK: <A, E>(effect: Effect.Effect<A, E, never>) => Promise<A>
Utility function for running components of the SDKCoreJs
runSDK } from 'studiocms:sdk';import { import Effect
Effect } from 'studiocms/effect';
// Créer l’Effect utilisableconst const pagesEffect: Effect.Effect<CombinedPageData[], DBClientInitializationError | SDKInitializationError | DBCallbackFailure | DatabaseError | ParseError | FolderTreeError | CollectorError | PaginateError, never>
pagesEffect = import Effect
Effect.const gen: <YieldWrap<Effect.Effect<{ AUTH: { verifyEmail: { get: (input: string) => Effect.Effect<{ readonly id: string; readonly userId: string; readonly expiresAt: Date; readonly token: string; } | undefined, DBCallbackFailure | DatabaseError, never>; create: (userId: string) => Effect.Effect<{ readonly id: string; readonly userId: string; readonly expiresAt: Date; readonly token: string; }, DBCallbackFailure | DatabaseError | GeneratorError, never>; delete: (input: string) => Effect.Effect<DeleteResult, DBCallbackFailure | DatabaseError, never>; }; oAuth: { create: (input: { readonly providerUserId: string; readonly provider: string; readonly userId: string; }) => Effect.Effect<{ readonly providerUserId: string; readonly provider: string; readonly userId: string; }, DBCallbackFailure | DatabaseError, never>; delete: (input: { readonly userId: string; readonly provider: string; }) => AuthDeletionResponse; searchByProviderId: (input: { readonly providerUserId: string; readonly userId: string; }) => Effect.Effect<{ readonly providerUserId: string; readonly provider: string; readonly userId: string; } | undefined, DBCallbackFailure | DatabaseError, never>; searchProvidersForId: (input: { readonly userId: string; readonly providerId: string; }) => Effect.Effect<{ readonly providerUserId: string; readonly provider: string; readonly userId: string; } | undefined, DBCallbackFailure | DatabaseError, never>; }; permission: { currentStatus: (input: string) => Effect.Effect<{ readonly user: string; readonly rank: "owner" | "admin" | "editor" | "visitor" | "unknown"; } | undefined, DBCallbackFailure | DatabaseError, never>; }; session: { create: (input: { readonly id: string; readonly userId: string; readonly expiresAt: string; }) => Effect.Effect<{ readonly id: string; readonly userId: string; readonly expiresAt: Date; }, DBCallbackFailure | DatabaseError, never>; getById: (input: string) => Effect.Effect<{ readonly id: string; readonly userId: string; readonly expiresAt: Date; } | undefined, DBCallbackFailure | DatabaseError, never>; sessionWithUser: (sessionId: string) => Effect.Effect<{ session: { readonly id: string; readonly userId: string; readonly expiresAt: Date; }; user: { readonly id: string; readonly url?: string | null | undefined; readonly name: string; readonly email?: string | null | undefined; readonly avatar?: string | null | undefined; readonly username: string; readonly password?: string | null | undefined; readonly updatedAt: Date; readonly createdAt: Date; readonly emailVerified: boolean; readonly notifications?: string | null | undefined; }; } | undefined, DBCallbackFailure | DatabaseError, never>; delete: (input: string) => AuthDeletionResponse; update: (input: { readonly id: string; readonly newDate: Date; }) => Effect.Effect<{ readonly id: string; readonly userId: string; readonly expiresAt: Date; }, DBCallbackFailure | DatabaseError, never>; }; user: { create: (userData: { readonly id: string; readonly url?: string | null | undefined; readonly name: string; readonly email?: string | null | undefined; readonly avatar?: string | null | undefined; readonly username: string; readonly password?: string | null | undefined; readonly updatedAt: string; readonly createdAt: string | undefined; readonly emailVerified: boolean; readonly notifications?: string | null | undefined; }, rank: "owner" | "admin" ... (+1 overload)
Provides a way to write effectful code using generator functions, simplifying
control flow and error handling.
When to Use
Effect.gen allows you to write code that looks and behaves like synchronous
code, but it can handle asynchronous tasks, errors, and complex control flow
(like loops and conditions). It helps make asynchronous code more readable
and easier to manage.
The generator functions work similarly to async/await but with more
explicit control over the execution of effects. You can yield* values from
effects and return the final result at the end.
Example
import { Effect } from "effect"
const addServiceCharge = (amount: number) => amount + 1
const applyDiscount = ( total: number, discountRate: number): Effect.Effect<number, Error> => discountRate === 0 ? Effect.fail(new Error("Discount rate cannot be zero")) : Effect.succeed(total - (total * discountRate) / 100)
const fetchTransactionAmount = Effect.promise(() => Promise.resolve(100))
const fetchDiscountRate = Effect.promise(() => Promise.resolve(5))
export const program = Effect.gen(function* () { const transactionAmount = yield* fetchTransactionAmount const discountRate = yield* fetchDiscountRate const discountedAmount = yield* applyDiscount( transactionAmount, discountRate ) const finalAmount = addServiceCharge(discountedAmount) return `Final amount to charge: ${finalAmount}`})
gen(function* () { const const sdk: { AUTH: { verifyEmail: { get: (input: string) => Effect.Effect<{ readonly id: string; readonly userId: string; readonly expiresAt: Date; readonly token: string; } | undefined, DBCallbackFailure | DatabaseError, never>; create: (userId: string) => Effect.Effect<{ readonly id: string; readonly userId: string; readonly expiresAt: Date; readonly token: string; }, DBCallbackFailure | DatabaseError | GeneratorError, never>; delete: (input: string) => Effect.Effect<DeleteResult, DBCallbackFailure | DatabaseError, never>; }; oAuth: { create: (input: { readonly providerUserId: string; readonly provider: string; readonly userId: string; }) => Effect.Effect<{ readonly providerUserId: string; readonly provider: string; readonly userId: string; }, DBCallbackFailure | DatabaseError, never>; delete: (input: { readonly userId: string; readonly provider: string; }) => AuthDeletionResponse; searchByProviderId: (input: { readonly providerUserId: string; readonly userId: string; }) => Effect.Effect<{ readonly providerUserId: string; readonly provider: string; readonly userId: string; } | undefined, DBCallbackFailure | DatabaseError, never>; searchProvidersForId: (input: { readonly userId: string; readonly providerId: string; }) => Effect.Effect<{ readonly providerUserId: string; readonly provider: string; readonly userId: string; } | undefined, DBCallbackFailure | DatabaseError, never>; }; permission: { currentStatus: (input: string) => Effect.Effect<{ readonly user: string; readonly rank: "owner" | "admin" | "editor" | "visitor" | "unknown"; } | undefined, DBCallbackFailure | DatabaseError, never>; }; session: { create: (input: { readonly id: string; readonly userId: string; readonly expiresAt: string; }) => Effect.Effect<{ readonly id: string; readonly userId: string; readonly expiresAt: Date; }, DBCallbackFailure | DatabaseError, never>; getById: (input: string) => Effect.Effect<{ readonly id: string; readonly userId: string; readonly expiresAt: Date; } | undefined, DBCallbackFailure | DatabaseError, never>; sessionWithUser: (sessionId: string) => Effect.Effect<{ session: { readonly id: string; readonly userId: string; readonly expiresAt: Date; }; user: { readonly id: string; readonly url?: string | null | undefined; readonly name: string; readonly email?: string | null | undefined; readonly avatar?: string | null | undefined; readonly username: string; readonly password?: string | null | undefined; readonly updatedAt: Date; readonly createdAt: Date; readonly emailVerified: boolean; readonly notifications?: string | null | undefined; }; } | undefined, DBCallbackFailure | DatabaseError, never>; delete: (input: string) => AuthDeletionResponse; update: (input: { readonly id: string; readonly newDate: Date; }) => Effect.Effect<{ readonly id: string; readonly userId: string; readonly expiresAt: Date; }, DBCallbackFailure | DatabaseError, never>; }; user: { create: (userData: { readonly id: string; readonly url?: string | null | undefined; readonly name: string; readonly email?: string | null | undefined; readonly avatar?: string | null | undefined; readonly username: string; readonly password?: string | null | undefined; readonly updatedAt: string; readonly createdAt: string | undefined; readonly emailVerified: boolean; readonly notifications?: string | null | undefined; }, rank: "owner" | "admin" | "editor" | "visitor" | ...
sdk = yield* const SDKCore: Effect.Effect<{ AUTH: { verifyEmail: { get: (input: string) => Effect.Effect<{ readonly id: string; readonly userId: string; readonly expiresAt: Date; readonly token: string; } | undefined, DBCallbackFailure | DatabaseError, never>; create: (userId: string) => Effect.Effect<{ readonly id: string; readonly userId: string; readonly expiresAt: Date; readonly token: string; }, DBCallbackFailure | DatabaseError | GeneratorError, never>; delete: (input: string) => Effect.Effect<DeleteResult, DBCallbackFailure | DatabaseError, never>; }; oAuth: { create: (input: { readonly providerUserId: string; readonly provider: string; readonly userId: string; }) => Effect.Effect<{ readonly providerUserId: string; readonly provider: string; readonly userId: string; }, DBCallbackFailure | DatabaseError, never>; delete: (input: { readonly userId: string; readonly provider: string; }) => AuthDeletionResponse; searchByProviderId: (input: { readonly providerUserId: string; readonly userId: string; }) => Effect.Effect<{ readonly providerUserId: string; readonly provider: string; readonly userId: string; } | undefined, DBCallbackFailure | DatabaseError, never>; searchProvidersForId: (input: { readonly userId: string; readonly providerId: string; }) => Effect.Effect<{ readonly providerUserId: string; readonly provider: string; readonly userId: string; } | undefined, DBCallbackFailure | DatabaseError, never>; }; permission: { currentStatus: (input: string) => Effect.Effect<{ readonly user: string; readonly rank: "owner" | "admin" | "editor" | "visitor" | "unknown"; } | undefined, DBCallbackFailure | DatabaseError, never>; }; session: { create: (input: { readonly id: string; readonly userId: string; readonly expiresAt: string; }) => Effect.Effect<{ readonly id: string; readonly userId: string; readonly expiresAt: Date; }, DBCallbackFailure | DatabaseError, never>; getById: (input: string) => Effect.Effect<{ readonly id: string; readonly userId: string; readonly expiresAt: Date; } | undefined, DBCallbackFailure | DatabaseError, never>; sessionWithUser: (sessionId: string) => Effect.Effect<{ session: { readonly id: string; readonly userId: string; readonly expiresAt: Date; }; user: { readonly id: string; readonly url?: string | null | undefined; readonly name: string; readonly email?: string | null | undefined; readonly avatar?: string | null | undefined; readonly username: string; readonly password?: string | null | undefined; readonly updatedAt: Date; readonly createdAt: Date; readonly emailVerified: boolean; readonly notifications?: string | null | undefined; }; } | undefined, DBCallbackFailure | DatabaseError, never>; delete: (input: string) => AuthDeletionResponse; update: (input: { readonly id: string; readonly newDate: Date; }) => Effect.Effect<{ readonly id: string; readonly userId: string; readonly expiresAt: Date; }, DBCallbackFailure | DatabaseError, never>; }; user: { create: (userData: { readonly id: string; readonly url?: string | null | undefined; readonly name: string; readonly email?: string | null | undefined; readonly avatar?: string | null | undefined; readonly username: string; readonly password?: string | null | undefined; readonly updatedAt: string; readonly createdAt: string | undefined; readonly emailVerified: boolean; readonly notifications?: string | null | undefined; }, rank: "owner" | "admin" | "editor" ...
The new Effect-TS based SDK implementation that replaces the deprecated SDK.
This unified SDK merges the normal and cached SDK functionalities.
SDKCore;
// alors faire quelque chose avec le SDK return yield* const sdk: { AUTH: { verifyEmail: { get: (input: string) => Effect.Effect<{ readonly id: string; readonly userId: string; readonly expiresAt: Date; readonly token: string; } | undefined, DBCallbackFailure | DatabaseError, never>; create: (userId: string) => Effect.Effect<{ readonly id: string; readonly userId: string; readonly expiresAt: Date; readonly token: string; }, DBCallbackFailure | DatabaseError | GeneratorError, never>; delete: (input: string) => Effect.Effect<DeleteResult, DBCallbackFailure | DatabaseError, never>; }; oAuth: { create: (input: { readonly providerUserId: string; readonly provider: string; readonly userId: string; }) => Effect.Effect<{ readonly providerUserId: string; readonly provider: string; readonly userId: string; }, DBCallbackFailure | DatabaseError, never>; delete: (input: { readonly userId: string; readonly provider: string; }) => AuthDeletionResponse; searchByProviderId: (input: { readonly providerUserId: string; readonly userId: string; }) => Effect.Effect<{ readonly providerUserId: string; readonly provider: string; readonly userId: string; } | undefined, DBCallbackFailure | DatabaseError, never>; searchProvidersForId: (input: { readonly userId: string; readonly providerId: string; }) => Effect.Effect<{ readonly providerUserId: string; readonly provider: string; readonly userId: string; } | undefined, DBCallbackFailure | DatabaseError, never>; }; permission: { currentStatus: (input: string) => Effect.Effect<{ readonly user: string; readonly rank: "owner" | "admin" | "editor" | "visitor" | "unknown"; } | undefined, DBCallbackFailure | DatabaseError, never>; }; session: { create: (input: { readonly id: string; readonly userId: string; readonly expiresAt: string; }) => Effect.Effect<{ readonly id: string; readonly userId: string; readonly expiresAt: Date; }, DBCallbackFailure | DatabaseError, never>; getById: (input: string) => Effect.Effect<{ readonly id: string; readonly userId: string; readonly expiresAt: Date; } | undefined, DBCallbackFailure | DatabaseError, never>; sessionWithUser: (sessionId: string) => Effect.Effect<{ session: { readonly id: string; readonly userId: string; readonly expiresAt: Date; }; user: { readonly id: string; readonly url?: string | null | undefined; readonly name: string; readonly email?: string | null | undefined; readonly avatar?: string | null | undefined; readonly username: string; readonly password?: string | null | undefined; readonly updatedAt: Date; readonly createdAt: Date; readonly emailVerified: boolean; readonly notifications?: string | null | undefined; }; } | undefined, DBCallbackFailure | DatabaseError, never>; delete: (input: string) => AuthDeletionResponse; update: (input: { readonly id: string; readonly newDate: Date; }) => Effect.Effect<{ readonly id: string; readonly userId: string; readonly expiresAt: Date; }, DBCallbackFailure | DatabaseError, never>; }; user: { create: (userData: { readonly id: string; readonly url?: string | null | undefined; readonly name: string; readonly email?: string | null | undefined; readonly avatar?: string | null | undefined; readonly username: string; readonly password?: string | null | undefined; readonly updatedAt: string; readonly createdAt: string | undefined; readonly emailVerified: boolean; readonly notifications?: string | null | undefined; }, rank: "owner" | "admin" | "editor" | "visitor" | ...
sdk.type GET: { permissionsLists: { owners: () => Effect.Effect<SingleRank[], UsersError | DBCallbackFailure | DatabaseError, never>; admins: () => Effect.Effect<SingleRank[], UsersError | DBCallbackFailure | DatabaseError, never>; editors: () => Effect.Effect<SingleRank[], UsersError | DBCallbackFailure | DatabaseError, never>; visitors: () => Effect.Effect<SingleRank[], UsersError | DBCallbackFailure | DatabaseError, never>; all: () => Effect.Effect<CombinedRank[], DBCallbackFailure | DatabaseError | UsersError, never>; }; ... 12 more ...; tags: { getAll: () => Effect.Effect<readonly { readonly id: number; readonly name: string; readonly description: string; readonly slug: string; readonly meta: { readonly [x: string]: unknown; }; }[], DBCallbackFailure | DatabaseError, never>; byId: (tagId: number) => Effect.Effect<{ readonly id: number; readonly name: string; readonly description: string; readonly slug: string; readonly meta: { readonly [x: string]: unknown; }; } | undefined, DBCallbackFailure | DatabaseError, never>; bySlug: (slug: string) => Effect.Effect<{ readonly id: number; readonly name: string; readonly description: string; readonly slug: string; readonly meta: { readonly [x: string]: unknown; }; } | undefined, DBCallbackFailure | DatabaseError, never>; };}
GET.pages: (includeDrafts?: boolean, metaOnly?: false, paginate?: PaginateInput) => Effect.Effect<CombinedPageData[], ParseError | DBCallbackFailure | DatabaseError | FolderTreeError | CollectorError | PaginateError, never> (+1 overload)
pages()});
// Convertir l’Effect en un programme JS/TSconst const pagesResult1: CombinedPageData[]
pagesResult1 = await runSDK<CombinedPageData[], DBClientInitializationError | SDKInitializationError | DBCallbackFailure | DatabaseError | ParseError | FolderTreeError | CollectorError | PaginateError>(effect: Effect.Effect<CombinedPageData[], DBClientInitializationError | SDKInitializationError | DBCallbackFailure | ... 4 more ... | PaginateError, never>): Promise<...>
Alias for runEffect, used to run SDK effects and convert them to plain JavaScript objects.
runSDK(const pagesEffect: Effect.Effect<CombinedPageData[], DBClientInitializationError | SDKInitializationError | DBCallbackFailure | DatabaseError | ParseError | FolderTreeError | CollectorError | PaginateError, never>
pagesEffect);
// Exécutez simplement le SDKCoreJS avec le wrapper runSDK !const const pagesResult2: CombinedPageData[]
pagesResult2 = await runSDK<CombinedPageData[], DBCallbackFailure | DatabaseError | ParseError | FolderTreeError | CollectorError | PaginateError>(effect: Effect.Effect<CombinedPageData[], DBCallbackFailure | DatabaseError | ParseError | FolderTreeError | CollectorError | PaginateError, never>): Promise<CombinedPageData[]>
Alias for runEffect, used to run SDK effects and convert them to plain JavaScript objects.
runSDK(const SDKCoreJs: { AUTH: { verifyEmail: { get: (input: string) => Effect.Effect<{ readonly id: string; readonly userId: string; readonly expiresAt: Date; readonly token: string; } | undefined, DBCallbackFailure | DatabaseError, never>; create: (userId: string) => Effect.Effect<{ readonly id: string; readonly userId: string; readonly expiresAt: Date; readonly token: string; }, DBCallbackFailure | DatabaseError | GeneratorError, never>; delete: (input: string) => Effect.Effect<DeleteResult, DBCallbackFailure | DatabaseError, never>; }; oAuth: { create: (input: { readonly providerUserId: string; readonly provider: string; readonly userId: string; }) => Effect.Effect<{ readonly providerUserId: string; readonly provider: string; readonly userId: string; }, DBCallbackFailure | DatabaseError, never>; delete: (input: { readonly userId: string; readonly provider: string; }) => AuthDeletionResponse; searchByProviderId: (input: { readonly providerUserId: string; readonly userId: string; }) => Effect.Effect<{ readonly providerUserId: string; readonly provider: string; readonly userId: string; } | undefined, DBCallbackFailure | DatabaseError, never>; searchProvidersForId: (input: { readonly userId: string; readonly providerId: string; }) => Effect.Effect<{ readonly providerUserId: string; readonly provider: string; readonly userId: string; } | undefined, DBCallbackFailure | DatabaseError, never>; }; permission: { currentStatus: (input: string) => Effect.Effect<{ readonly user: string; readonly rank: "owner" | "admin" | "editor" | "visitor" | "unknown"; } | undefined, DBCallbackFailure | DatabaseError, never>; }; session: { create: (input: { readonly id: string; readonly userId: string; readonly expiresAt: string; }) => Effect.Effect<{ readonly id: string; readonly userId: string; readonly expiresAt: Date; }, DBCallbackFailure | DatabaseError, never>; getById: (input: string) => Effect.Effect<{ readonly id: string; readonly userId: string; readonly expiresAt: Date; } | undefined, DBCallbackFailure | DatabaseError, never>; sessionWithUser: (sessionId: string) => Effect.Effect<{ session: { readonly id: string; readonly userId: string; readonly expiresAt: Date; }; user: { readonly id: string; readonly url?: string | null | undefined; readonly name: string; readonly email?: string | null | undefined; readonly avatar?: string | null | undefined; readonly username: string; readonly password?: string | null | undefined; readonly updatedAt: Date; readonly createdAt: Date; readonly emailVerified: boolean; readonly notifications?: string | null | undefined; }; } | undefined, DBCallbackFailure | DatabaseError, never>; delete: (input: string) => AuthDeletionResponse; update: (input: { readonly id: string; readonly newDate: Date; }) => Effect.Effect<{ readonly id: string; readonly userId: string; readonly expiresAt: Date; }, DBCallbackFailure | DatabaseError, never>; }; user: { create: (userData: { readonly id: string; readonly url?: string | null | undefined; readonly name: string; readonly email?: string | null | undefined; readonly avatar?: string | null | undefined; readonly username: string; readonly password?: string | null | undefined; readonly updatedAt: string; readonly createdAt: string | undefined; readonly emailVerified: boolean; readonly notifications?: string | null | undefined; }, rank: "owner" | "admin" | "editor" | "visitor" | ...
VanillaJS Version of the SDKCore. Most internal functions will still contain Effects, you can use runSDK from the 'studiocms:sdk' to run these as normal async functions
SDKCoreJs.type GET: { permissionsLists: { owners: () => Effect.Effect<SingleRank[], UsersError | DBCallbackFailure | DatabaseError, never>; admins: () => Effect.Effect<SingleRank[], UsersError | DBCallbackFailure | DatabaseError, never>; editors: () => Effect.Effect<SingleRank[], UsersError | DBCallbackFailure | DatabaseError, never>; visitors: () => Effect.Effect<SingleRank[], UsersError | DBCallbackFailure | DatabaseError, never>; all: () => Effect.Effect<CombinedRank[], DBCallbackFailure | DatabaseError | UsersError, never>; }; ... 12 more ...; tags: { getAll: () => Effect.Effect<readonly { readonly id: number; readonly name: string; readonly description: string; readonly slug: string; readonly meta: { readonly [x: string]: unknown; }; }[], DBCallbackFailure | DatabaseError, never>; byId: (tagId: number) => Effect.Effect<{ readonly id: number; readonly name: string; readonly description: string; readonly slug: string; readonly meta: { readonly [x: string]: unknown; }; } | undefined, DBCallbackFailure | DatabaseError, never>; bySlug: (slug: string) => Effect.Effect<{ readonly id: number; readonly name: string; readonly description: string; readonly slug: string; readonly meta: { readonly [x: string]: unknown; }; } | undefined, DBCallbackFailure | DatabaseError, never>; };}
GET.pages: (includeDrafts?: boolean, metaOnly?: false, paginate?: PaginateInput) => Effect.Effect<CombinedPageData[], ParseError | DBCallbackFailure | DatabaseError | FolderTreeError | CollectorError | PaginateError, never> (+1 overload)
pages());Utilitaires disponibles
Section intitulée « Utilitaires disponibles »Voici une liste des principaux utilitaires fournis par le SDK de StudioCMS pour interagir avec la base de données.
import { const SDKCoreJs: { AUTH: { verifyEmail: { get: (input: string) => Effect<{ readonly id: string; readonly userId: string; readonly expiresAt: Date; readonly token: string; } | undefined, DBCallbackFailure | DatabaseError, never>; create: (userId: string) => Effect<{ readonly id: string; readonly userId: string; readonly expiresAt: Date; readonly token: string; }, DBCallbackFailure | DatabaseError | GeneratorError, never>; delete: (input: string) => Effect<DeleteResult, DBCallbackFailure | DatabaseError, never>; }; oAuth: { create: (input: { readonly providerUserId: string; readonly provider: string; readonly userId: string; }) => Effect<{ readonly providerUserId: string; readonly provider: string; readonly userId: string; }, DBCallbackFailure | DatabaseError, never>; delete: (input: { readonly userId: string; readonly provider: string; }) => AuthDeletionResponse; searchByProviderId: (input: { readonly providerUserId: string; readonly userId: string; }) => Effect<{ readonly providerUserId: string; readonly provider: string; readonly userId: string; } | undefined, DBCallbackFailure | DatabaseError, never>; searchProvidersForId: (input: { readonly userId: string; readonly providerId: string; }) => Effect<{ readonly providerUserId: string; readonly provider: string; readonly userId: string; } | undefined, DBCallbackFailure | DatabaseError, never>; }; permission: { currentStatus: (input: string) => Effect<{ readonly user: string; readonly rank: "owner" | "admin" | "editor" | "visitor" | "unknown"; } | undefined, DBCallbackFailure | DatabaseError, never>; }; session: { create: (input: { readonly id: string; readonly userId: string; readonly expiresAt: string; }) => Effect<{ readonly id: string; readonly userId: string; readonly expiresAt: Date; }, DBCallbackFailure | DatabaseError, never>; getById: (input: string) => Effect<{ readonly id: string; readonly userId: string; readonly expiresAt: Date; } | undefined, DBCallbackFailure | DatabaseError, never>; sessionWithUser: (sessionId: string) => Effect<{ session: { readonly id: string; readonly userId: string; readonly expiresAt: Date; }; user: { readonly id: string; readonly url?: string | null | undefined; readonly name: string; readonly email?: string | null | undefined; readonly avatar?: string | null | undefined; readonly username: string; readonly password?: string | null | undefined; readonly updatedAt: Date; readonly createdAt: Date; readonly emailVerified: boolean; readonly notifications?: string | null | undefined; }; } | undefined, DBCallbackFailure | DatabaseError, never>; delete: (input: string) => AuthDeletionResponse; update: (input: { readonly id: string; readonly newDate: Date; }) => Effect<{ readonly id: string; readonly userId: string; readonly expiresAt: Date; }, DBCallbackFailure | DatabaseError, never>; }; user: { create: (userData: { readonly id: string; readonly url?: string | null | undefined; readonly name: string; readonly email?: string | null | undefined; readonly avatar?: string | null | undefined; readonly username: string; readonly password?: string | null | undefined; readonly updatedAt: string; readonly createdAt: string | undefined; readonly emailVerified: boolean; readonly notifications?: string | null | undefined; }, rank: "owner" | "admin" | "editor" | "visitor" | "unknown") => Effect<{ readonly id: string; readonly ...
VanillaJS Version of the SDKCore. Most internal functions will still contain Effects, you can use runSDK from the 'studiocms:sdk' to run these as normal async functions
SDKCoreJs } from 'studiocms:sdk';
const { const dbService: DBClientInterface<{ readonly StudioCMSUsersTable: { readonly id: string; readonly name: string; readonly username: string; readonly updatedAt: ColumnType<string, string, string>; readonly createdAt: ColumnType<string, string | undefined, undefined>; readonly emailVerified: number; readonly url?: string | null | undefined; readonly email?: string | null | undefined; readonly avatar?: string | null | undefined; readonly password?: string | null | undefined; readonly notifications?: string | null | undefined; }; ... 14 more ...; readonly StudioCMSStorageManagerUrlMappings: { readonly url: string; readonly updatedAt: number; readonly createdAt: ColumnType<...>; readonly identifier: string; readonly isPermanent: ColumnType<...>; readonly expiresAt?: number | null | undefined; };}>
dbService, const cache: CacheService
cache, const AUTH: { verifyEmail: { get: (input: string) => Effect<{ readonly id: string; readonly userId: string; readonly expiresAt: Date; readonly token: string; } | undefined, DBCallbackFailure | DatabaseError, never>; create: (userId: string) => Effect<{ readonly id: string; readonly userId: string; readonly expiresAt: Date; readonly token: string; }, DBCallbackFailure | DatabaseError | GeneratorError, never>; delete: (input: string) => Effect<DeleteResult, DBCallbackFailure | DatabaseError, never>; }; oAuth: { create: (input: { readonly providerUserId: string; readonly provider: string; readonly userId: string; }) => Effect<{ readonly providerUserId: string; readonly provider: string; readonly userId: string; }, DBCallbackFailure | DatabaseError, never>; delete: (input: { readonly userId: string; readonly provider: string; }) => AuthDeletionResponse; searchByProviderId: (input: { readonly providerUserId: string; readonly userId: string; }) => Effect<{ readonly providerUserId: string; readonly provider: string; readonly userId: string; } | undefined, DBCallbackFailure | DatabaseError, never>; searchProvidersForId: (input: { readonly userId: string; readonly providerId: string; }) => Effect<{ readonly providerUserId: string; readonly provider: string; readonly userId: string; } | undefined, DBCallbackFailure | DatabaseError, never>; }; permission: { currentStatus: (input: string) => Effect<{ readonly user: string; readonly rank: "owner" | "admin" | "editor" | "visitor" | "unknown"; } | undefined, DBCallbackFailure | DatabaseError, never>; }; session: { create: (input: { readonly id: string; readonly userId: string; readonly expiresAt: string; }) => Effect<{ readonly id: string; readonly userId: string; readonly expiresAt: Date; }, DBCallbackFailure | DatabaseError, never>; getById: (input: string) => Effect<{ readonly id: string; readonly userId: string; readonly expiresAt: Date; } | undefined, DBCallbackFailure | DatabaseError, never>; sessionWithUser: (sessionId: string) => Effect<{ session: { readonly id: string; readonly userId: string; readonly expiresAt: Date; }; user: { readonly id: string; readonly url?: string | null | undefined; readonly name: string; readonly email?: string | null | undefined; readonly avatar?: string | null | undefined; readonly username: string; readonly password?: string | null | undefined; readonly updatedAt: Date; readonly createdAt: Date; readonly emailVerified: boolean; readonly notifications?: string | null | undefined; }; } | undefined, DBCallbackFailure | DatabaseError, never>; delete: (input: string) => AuthDeletionResponse; update: (input: { readonly id: string; readonly newDate: Date; }) => Effect<{ readonly id: string; readonly userId: string; readonly expiresAt: Date; }, DBCallbackFailure | DatabaseError, never>; }; user: { create: (userData: { readonly id: string; readonly url?: string | null | undefined; readonly name: string; readonly email?: string | null | undefined; readonly avatar?: string | null | undefined; readonly username: string; readonly password?: string | null | undefined; readonly updatedAt: string; readonly createdAt: string | undefined; readonly emailVerified: boolean; readonly notifications?: string | null | undefined; }, rank: "owner" | "admin" | "editor" | "visitor" | "unknown") => Effect<{ readonly id: string; readonly url?: string | null | undefined; readonly name: string; readonly email?: string | null | undefined; readonly avatar?: string | null | undefined; readonly username: string; readonly password?: string | null | undefined; readonly updatedAt: Date; readonly createdAt: Date; readonly emailVerified: boolean; readonly notifications?: string | null | undefined ...
AUTH, const CLEAR: { page: { byId: (id: string) => Effect<void, never, never>; }; pages: Effect<void, never, never>; latestVersion: Effect<void, never, never>; folderTree: Effect<void, never, never>; folderList: Effect<void, never, never>;}
CLEAR, const CONFIG: { siteConfig: { get: <T extends StudioCMSSiteConfig>() => Effect<DynamicConfigEntry<T> | undefined, UnknownException | DBCallbackFailure | DatabaseError, never>; update: (data: ConfigFinal<StudioCMSSiteConfig>) => Effect<DynamicConfigEntry<StudioCMSSiteConfig>, DBCallbackFailure | DatabaseError, never>; init: (data: ConfigFinal<StudioCMSSiteConfig>) => Effect<DynamicConfigEntry<StudioCMSSiteConfig>, DBCallbackFailure | DatabaseError, never>; }; mailerConfig: { get: () => Effect<DynamicConfigEntry<...> | undefined, DBCallbackFailure | DatabaseError, never>; update: (data: ConfigFinal<...>) => Effect<DynamicConfigEntry<...>, DBCallbackFailure | DatabaseError, never>; init: (data: ConfigFinal<...>) => Effect<DynamicConfigEntry<...>, DBCallbackFailure | DatabaseError, never>; }; notificationConfig: { get: () => Effect<DynamicConfigEntry<...> | undefined, DBCallbackFailure | DatabaseError, never>; update: (data: ConfigFinal<...>) => Effect<DynamicConfigEntry<...>, DBCallbackFailure | DatabaseError, never>; init: (data: ConfigFinal<...>) => Effect<DynamicConfigEntry<...>, DBCallbackFailure | DatabaseError, never>; }; templateConfig: { get: () => Effect<DynamicConfigEntry<...> | undefined, DBCallbackFailure | DatabaseError, never>; update: (data: ConfigFinal<...>) => Effect<DynamicConfigEntry<...>, DBCallbackFailure | DatabaseError | DeepmergeError, never>; init: (data: ConfigFinal<...>) => Effect<DynamicConfigEntry<...>, DBCallbackFailure | DatabaseError, never>; };}
CONFIG, const DELETE: { page: (id: string) => Effect<{ status: "success" | "error"; message: string; }, never, never>; pageContent: (id: string) => Effect<{ status: "success" | "error"; message: string; }, never, never>; pageContentLang: (id: string, lang: string) => Effect<{ status: "success" | "error"; message: string; }, never, never>; tags: (id: number) => Effect<{ status: "success" | "error"; message: string; }, never, never>; ... 4 more ...; user: (userId: string) => Effect<{ status: "success" | "error"; message: string; }, never, never>;}
DELETE, const diffTracking: { insert: (userId: string, pageId: string, data: { content: { start: string; end: string; }; metaData: { start: Partial<{ readonly description: string; readonly title: string; readonly id: string; readonly package: string; readonly showOnNav: boolean; readonly publishedAt: Date; readonly updatedAt: Date; readonly slug: string; readonly contentLang: string; readonly heroImage?: string | null | undefined; readonly categories: readonly string[]; readonly tags: readonly string[]; readonly authorId: string; readonly contributorIds: readonly string[]; readonly showAuthor: boolean; readonly showContributors: boolean; readonly parentFolder?: string | null | undefined; readonly draft: boolean; readonly augments: readonly string[]; }>; end: Partial<{ ...; }>; }; }, diffLength: number) => Effect<diffReturn, DBCallbackFailure | DatabaseError | ParsersError | DiffError, never>; clear: (input: string) => Effect<DeleteResult[], DBCallbackFailure | DatabaseError, never>; get: { byPageId: { all: (pageId: string) => Effect<diffReturn[], DBCallbackFailure | DatabaseError | ParsersError, never>; latest: (pageId: string, count: number) => Effect<diffReturn[], DBCallbackFailure | DatabaseError | ParsersError, never>; }; byUserId: { all: (userId: string) => Effect<diffReturn[], DBCallbackFailure | DatabaseError | ParsersError, never>; latest: (userId: string, count: number) => Effect<diffReturn[], DBCallbackFailure | DatabaseError | ParsersError, never>; }; single: (diffId: string) => Effect<diffReturn | undefined, DBCallbackFailure | DatabaseError | ParsersError, never>; }; revertToDiff: (id: string, type: "content" | "data" | "both") => Effect<diffReturn, ParseError | DBCallbackFailure | DatabaseError | ParsersError | DiffTrackingError, never>; utils: { getMetaDataDifferences: <T extends Record<string, unknown>>(obj1: T, obj2: T) => Effect<{ label: string; previous: unknown; current: unknown; }[], never, never>; getDiffHTML: (diff: string, options?: Diff2HtmlConfig | undefined) => Effect<string, DiffError, never>; };}
diffTracking, const GET: { permissionsLists: { owners: () => Effect<SingleRank[], UsersError | DBCallbackFailure | DatabaseError, never>; admins: () => Effect<SingleRank[], UsersError | DBCallbackFailure | DatabaseError, never>; editors: () => Effect<SingleRank[], UsersError | DBCallbackFailure | DatabaseError, never>; visitors: () => Effect<SingleRank[], UsersError | DBCallbackFailure | DatabaseError, never>; all: () => Effect<CombinedRank[], DBCallbackFailure | DatabaseError | UsersError, never>; }; ... 12 more ...; tags: { getAll: () => Effect<readonly { readonly id: number; readonly name: string; readonly description: string; readonly slug: string; readonly meta: { readonly [x: string]: unknown; }; }[], DBCallbackFailure | DatabaseError, never>; byId: (tagId: number) => Effect<{ readonly id: number; readonly name: string; readonly description: string; readonly slug: string; readonly meta: { readonly [x: string]: unknown; }; } | undefined, DBCallbackFailure | DatabaseError, never>; bySlug: (slug: string) => Effect<{ readonly id: number; readonly name: string; readonly description: string; readonly slug: string; readonly meta: { readonly [x: string]: unknown; }; } | undefined, DBCallbackFailure | DatabaseError, never>; };}
GET, const INIT: { siteConfig: (data: ConfigFinal<StudioCMSSiteConfig>) => Effect<DynamicConfigEntry<StudioCMSSiteConfig>, DBCallbackFailure | DatabaseError, never>; ghostUser: () => Effect<{ readonly id: string; readonly url?: string | null | undefined; readonly name: string; readonly email?: string | null | undefined; readonly avatar?: string | null | undefined; readonly username: string; readonly password?: string | null | undefined; readonly updatedAt: Date; readonly createdAt: Date; readonly emailVerified: boolean; readonly notifications?: string | null | undefined; }, DBCallbackFailure | DatabaseError, never>;}
INIT, const MIDDLEWARES: { verifyCache: () => Effect<void, UnknownException | ParseError | DBCallbackFailure | QueryParseError | QueryError | NotFoundError | FolderTreeError | CollectorError | PaginateError, never>;}
MIDDLEWARES, const notificationSettings: { site: { get: () => Effect<DynamicConfigEntry<StudioCMSNotificationSettings>, DBCallbackFailure | DatabaseError, never>; update: (settings: Omit<StudioCMSNotificationSettings, "_config_version">) => Effect<DynamicConfigEntry<StudioCMSNotificationSettings>, DBCallbackFailure | DatabaseError, never>; };}
notificationSettings, const PLUGINS: { usePluginData: { <T extends Struct<Struct.Fields> | object, R extends object = T extends Struct<any> ? RecursiveSimplifyMutable<T["Type"]> : T>(pluginId: string, opts?: UsePluginDataOptsBase<T>): { getEntries: (filter?: (data: PluginDataEntry<R>[]) => PluginDataEntry<R>[]) => Effect<PluginDataEntry<R>[], StudioCMSSDKError, never>; getEntry: (id: string) => { generatedId: () => Effect<string, never, never>; select: () => Effect<PluginDataEntry<R> | undefined, StudioCMSSDKError, never>; insert: (data: R) => Effect<PluginDataEntry<R>, StudioCMSSDKError, never>; update: (data: R) => Effect<PluginDataEntry<...>, StudioCMSSDKError, never>; }; }; <T extends Struct<...> | object, R extends object = T extends Struct<...> ? RecursiveSimplifyMutable<...> : T>(pluginId: string, opts?: UsePluginDataOpts<...>): { generatedId: () => Effect<string, never, never>; select: () => Effect<PluginDataEntry<...> | undefined, StudioCMSSDKError, never>; insert: (data: R) => Effect<PluginDataEntry<...>, StudioCMSSDKError, never>; update: (data: R) => Effect<PluginDataEntry<...>, StudioCMSSDKError, never>; }; }; initPluginDataCache: (BATCH_SIZE?: number | undefined) => Effect<void, DBCallbackFailure | DatabaseError, never>; clearPluginDataCache: () => Effect<void, never, never>; InferType: { new <S extends Struct<...>, R = RecursiveSimplifyMutable<...>>(schema: S): { readonly _Schema: S; readonly $UsePluginData: S; readonly $Insert: R; }; };}
PLUGINS, const POST: { databaseEntry: { pages: (pageData: OptionalId<string, { readonly id: string; readonly updatedAt: string; readonly description: string; readonly package: string; readonly title: string; readonly showOnNav: boolean; readonly publishedAt: string; readonly slug: string; readonly contentLang: string; readonly heroImage?: string | null | undefined; readonly categories: string; readonly tags: string; readonly authorId: string; readonly contributorIds: string; readonly showAuthor: boolean; readonly showContributors: boolean; readonly parentFolder?: string | null | undefined; readonly draft: boolean; readonly augments: string; }>, pageContent: CombinedInsertContent) => Effect<{ pageData: { readonly id: string; }; pageContent: { readonly id: string; }; }, DBCallbackFailure | DatabaseError, never>; pageContent: (input: { readonly id: string; readonly contentLang: string; readonly contentId: string; readonly content: string; }) => Effect<{ readonly id: string; }, DBCallbackFailure | DatabaseError, never>; tags: (tag: OptionalId<...>) => Effect<{ readonly id: number; }, DBCallbackFailure | DatabaseError | GeneratorError, never>; categories: (category: OptionalId<...>) => Effect<{ readonly id: number; }, DBCallbackFailure | DatabaseError | GeneratorError, never>; permissions: (userId: string, rank: "owner" | "admin" | "editor" | "visitor" | "unknown") => Effect<{ readonly user: string; readonly rank: "owner" | "admin" | "editor" | "visitor" | "unknown"; }, DBCallbackFailure | DatabaseError, never>; diffTracking: (data: OptionalId<...>) => Effect<{ readonly id: string; readonly userId: string; readonly pageId: string; readonly timestamp: Date; readonly pageMetaData: { readonly [x: string]: unknown; }; readonly pageContentStart: string; readonly diff?: string | null | undefined; }, DBCallbackFailure | DatabaseError, never>; folder: (data: OptionalId<...>) => Effect<{ readonly id: string; readonly name: string; readonly parent?: string | null | undefined; }, DBCallbackFailure | DatabaseError, never>; }; databaseEntries: { tags: (tags: OptionalId<...>[]) => Effect<{ readonly id: number; }[], DBCallbackFailure | DatabaseError | GeneratorError, never>; categories: (categories: OptionalId<...>[]) => Effect<{ readonly id: number; }[], DBCallbackFailure | DatabaseError | GeneratorError, never>; permissions: (permissions: { userId: string; rank: "owner" | "admin" | "editor" | "visitor" | "unknown"; }[]) => Effect<{ readonly user: string; readonly rank: "owner" | "admin" | "editor" | "visitor" | "unknown"; }[], DBCallbackFailure | DatabaseError, never>; pages: (pages: MultiPageInsert) => Effect<{ pageData: { readonly id: string; }; pageContent: { readonly id: string; }; }[], DBCallbackFailure | DatabaseError, never>; }; folder: (data: OptionalId<...>) => Effect<{ readonly id: string; readonly name: string; readonly parent?: string | null | undefined; }, DBCallbackFailure | DatabaseError | FolderTreeError, never>; page: (args_0: { pageData: OptionalId<...>; pageContent: CombinedInsertContent; }) => Effect<CombinedPageData | undefined, ParseError | DBCallbackFailure | QueryParseError | QueryError | NotFoundError | FolderTreeError | CollectorError | PaginateError, never>;}
POST, const resetTokenBucket: { new: (userId: string) => Effect<{ readonly id: string; readonly userId: string; readonly token: string; }, DBCallbackFailure | DatabaseError | GeneratorError, never>; delete: (input: string) => Effect<DeleteResult[], DBCallbackFailure | DatabaseError, never>; check: (token: string) => Effect<boolean, DBCallbackFailure | DatabaseError | GeneratorError, never>;}
resetTokenBucket, const REST_API: { tokens: { get: (input: string) => Effect<readonly { readonly id: string; readonly userId: string; readonly key: string; readonly creationDate: Date; readonly description?: string | null | undefined; }[], DBCallbackFailure | DatabaseError, never>; new: (userId: string, description: string) => Effect<{ readonly id: string; readonly userId: string; readonly key: string; readonly creationDate: Date; readonly description?: string | null | undefined; }, DBCallbackFailure | DatabaseError | GeneratorError, never>; delete: (input: { readonly userId: string; readonly tokenId: string; }) => Effect<DeleteResult[], DBCallbackFailure | DatabaseError, never>; verify: (key: string) => Effect<false | { userId: string; key: string; rank: "owner" | "admin" | "editor" | "visitor" | "unknown"; }, DBCallbackFailure | DatabaseError, never>; };}
REST_API, const UPDATE: { pageContent: (input: { readonly id: string; readonly contentLang: string; readonly contentId: string; readonly content: string; }) => Effect<{ readonly id: string; readonly contentLang: string; readonly contentId: string; readonly content: string; }, DBCallbackFailure | DatabaseError, never>; ... 8 more ...; page: { byId: (pageId: string, data: { pageData: { readonly id: string; readonly updatedAt: string; readonly description: string; readonly package: string; readonly title: string; readonly showOnNav: boolean; readonly publishedAt: string; readonly slug: string; readonly contentLang: string; readonly heroImage?: string | null | undefined; readonly categories: string; readonly tags: string; readonly authorId: string; readonly contributorIds: string; readonly showAuthor: boolean; readonly showContributors: boolean; readonly parentFolder?: string | null | undefined; readonly draft: boolean; readonly augments: string; }; pageContent: { readonly id: string; readonly contentLang: string; readonly contentId: string; readonly content: string; }; }) => Effect<CombinedPageData | undefined, ParseError | DBCallbackFailure | QueryParseError | QueryError | NotFoundError | FolderTreeError | CollectorError | PaginateError, never>; bySlug: (slug: string, data: { pageData: { readonly id: string; readonly updatedAt: string; readonly description: string; readonly package: string; readonly title: string; readonly showOnNav: boolean; readonly publishedAt: string; readonly slug: string; readonly contentLang: string; readonly heroImage?: string | null | undefined; readonly categories: string; readonly tags: string; readonly authorId: string; readonly contributorIds: string; readonly showAuthor: boolean; readonly showContributors: boolean; readonly parentFolder?: string | null | undefined; readonly draft: boolean; readonly augments: string; }; pageContent: { readonly id: string; readonly contentLang: string; readonly contentId: string; readonly content: string; }; }) => Effect<CombinedPageData | undefined, ParseError | DBCallbackFailure | DatabaseError | FolderTreeError | CollectorError | PaginateError, never>; };}
UPDATE, const UTIL: { Collectors: { collectCategories: (input: readonly number[]) => Effect<readonly { readonly id: number; readonly name: string; readonly description: string; readonly parent?: number | null | undefined; readonly slug: string; readonly meta: { readonly [x: string]: unknown; }; }[], DBCallbackFailure | DatabaseError, never>; collectTags: (input: readonly number[]) => Effect<readonly { readonly id: number; readonly name: string; readonly description: string; readonly slug: string; readonly meta: { readonly [x: string]: unknown; }; }[], DBCallbackFailure | DatabaseError, never>; collectPageData: { (page: { readonly description: string; readonly title: string; readonly id: string; readonly package: string; readonly showOnNav: boolean; readonly publishedAt: Date; readonly updatedAt: Date; readonly slug: string; readonly contentLang: string; readonly heroImage?: string | null | undefined; readonly categories: readonly string[]; readonly tags: readonly string[]; readonly authorId: string; ... 5 more ...; readonly augments: readonly string[]; }, tree: FolderNode[]): Effect<CombinedPageData, CollectorError | FolderTreeError | DBCallbackFailure | DatabaseError | ParseError, never>; (page: { ...; }, tree: FolderNode[], metaOnly: boolean): Effect<MetaOnlyPageData, CollectorError | FolderTreeError | DBCallbackFailure | DatabaseError | ParseError, never>; }; collectUserData: (user: { readonly id: string; readonly url?: string | null | undefined; readonly name: string; readonly email?: string | null | undefined; readonly avatar?: string | null | undefined; readonly username: string; readonly password?: string | null | undefined; readonly updatedAt: Date; readonly createdAt: Date; readonly emailVerified: boolean; readonly notifications?: string | null | undefined; }) => Effect<CombinedUserData, DBCallbackFailure | DatabaseError, never>; }; ... 4 more ...; Users: { verifyRank: (users: readonly { readonly id: string; readonly url?: string | null | undefined; readonly name: string; readonly email?: string | null | undefined; readonly avatar?: string | null | undefined; readonly username: string; readonly password?: string | null | undefined; readonly updatedAt: Date; readonly createdAt: Date; readonly emailVerified: boolean; readonly notifications?: string | null | undefined; }[], permissions: readonly { readonly user: string; readonly rank: "owner" | "admin" | "editor" | "visitor" | "unknown"; }[], rank: string) => Effect<SingleRank[], UsersError, never>; combineRanks: (rank: string, users: SingleRank[]) => Effect<CombinedRank[], UsersError, never>; clearUserReferences: (userId: string) => Effect<boolean, DBCallbackFailure | QueryError | NotFoundError, never>; };}
UTIL,} = const SDKCoreJs: { AUTH: { verifyEmail: { get: (input: string) => Effect<{ readonly id: string; readonly userId: string; readonly expiresAt: Date; readonly token: string; } | undefined, DBCallbackFailure | DatabaseError, never>; create: (userId: string) => Effect<{ readonly id: string; readonly userId: string; readonly expiresAt: Date; readonly token: string; }, DBCallbackFailure | DatabaseError | GeneratorError, never>; delete: (input: string) => Effect<DeleteResult, DBCallbackFailure | DatabaseError, never>; }; oAuth: { create: (input: { readonly providerUserId: string; readonly provider: string; readonly userId: string; }) => Effect<{ readonly providerUserId: string; readonly provider: string; readonly userId: string; }, DBCallbackFailure | DatabaseError, never>; delete: (input: { readonly userId: string; readonly provider: string; }) => AuthDeletionResponse; searchByProviderId: (input: { readonly providerUserId: string; readonly userId: string; }) => Effect<{ readonly providerUserId: string; readonly provider: string; readonly userId: string; } | undefined, DBCallbackFailure | DatabaseError, never>; searchProvidersForId: (input: { readonly userId: string; readonly providerId: string; }) => Effect<{ readonly providerUserId: string; readonly provider: string; readonly userId: string; } | undefined, DBCallbackFailure | DatabaseError, never>; }; permission: { currentStatus: (input: string) => Effect<{ readonly user: string; readonly rank: "owner" | "admin" | "editor" | "visitor" | "unknown"; } | undefined, DBCallbackFailure | DatabaseError, never>; }; session: { create: (input: { readonly id: string; readonly userId: string; readonly expiresAt: string; }) => Effect<{ readonly id: string; readonly userId: string; readonly expiresAt: Date; }, DBCallbackFailure | DatabaseError, never>; getById: (input: string) => Effect<{ readonly id: string; readonly userId: string; readonly expiresAt: Date; } | undefined, DBCallbackFailure | DatabaseError, never>; sessionWithUser: (sessionId: string) => Effect<{ session: { readonly id: string; readonly userId: string; readonly expiresAt: Date; }; user: { readonly id: string; readonly url?: string | null | undefined; readonly name: string; readonly email?: string | null | undefined; readonly avatar?: string | null | undefined; readonly username: string; readonly password?: string | null | undefined; readonly updatedAt: Date; readonly createdAt: Date; readonly emailVerified: boolean; readonly notifications?: string | null | undefined; }; } | undefined, DBCallbackFailure | DatabaseError, never>; delete: (input: string) => AuthDeletionResponse; update: (input: { readonly id: string; readonly newDate: Date; }) => Effect<{ readonly id: string; readonly userId: string; readonly expiresAt: Date; }, DBCallbackFailure | DatabaseError, never>; }; user: { create: (userData: { readonly id: string; readonly url?: string | null | undefined; readonly name: string; readonly email?: string | null | undefined; readonly avatar?: string | null | undefined; readonly username: string; readonly password?: string | null | undefined; readonly updatedAt: string; readonly createdAt: string | undefined; readonly emailVerified: boolean; readonly notifications?: string | null | undefined; }, rank: "owner" | "admin" | "editor" | "visitor" | "unknown") => Effect<{ readonly id: string; readonly ...
VanillaJS Version of the SDKCore. Most internal functions will still contain Effects, you can use runSDK from the 'studiocms:sdk' to run these as normal async functions
SDKCoreJs;Lectures complémentaires
Section intitulée « Lectures complémentaires »Le SDK de StudioCMS est alimenté par le paquet @withstudiocms/sdk, qui fournit des fonctionnalités et des utilitaires supplémentaires pour travailler avec StudioCMS. Pour plus d’informations, consultez la documentation des packages Kysely et SDK.