Das SDK
Das StudioCMS SDK ist ein leistungsstarkes Werkzeug, mit dem du programmatisch mit StudioCMS interagieren kannst. Es bietet eine Reihe von Funktionen und Dienstprogrammen, mit denen du deine Inhalte mit Astro DB verwalten und bereitstellen kannst. Außerdem bildet es das Rückgrat für das StudioCMS-Dashboard.
Verwendung
'Read the “', Verwendung, '” section'Das StudioCMS SDK ist als virtuelles Modul in deinem Astro-Projekt verfügbar. Du kannst es mit der folgenden Syntax importieren:
import const SDK: { addPageToFolderTree: (tree: FolderNode[], folderId: string, newPage: FolderNode) => FolderNode[]; ... 29 more ...; notificationSettings: { site: { get: () => Promise<{ id: string; emailVerification: boolean; requireAdminVerification: boolean; requireEditorVerification: boolean; oAuthBypassVerification: boolean; }>; update: (settings: { ...; }) => Promise<{ id: string; emailVerification: boolean; requireAdminVerification: boolean; requireEditorVerification: boolean; oAuthBypassVerification: boolean; }>; }; };}
SDK from 'studiocms:sdk';// Orimport const SDKCached: { GET: { page: { byId: (id: string) => Promise<PageDataCacheObject>; bySlug: (slug: string) => Promise<PageDataCacheObject>; }; pages: (includeDrafts?: boolean) => Promise<PageDataCacheObject[]>; siteConfig: () => Promise<SiteConfigCacheObject>; latestVersion: () => Promise<VersionCacheObject>; folderTree: () => Promise<FolderTreeCacheObject>; pageFolderTree: (includeDrafts?: boolean) => Promise<FolderTreeCacheObject>; folderList: () => Promise<FolderListCacheObject>; folder: (id: string) => Promise<{ name: string; id: string; parent: string | null; } | undefined>; databaseTable: { ...; }; }; ... 5 more ...; diffTracking: { ...; };}
SDKCached from 'studiocms:sdk/cache';
Das Objekt studioCMSSDK
bietet eine Reihe von Funktionen und Dienstprogrammen, mit denen du mit StudioCMS interagieren kannst. Du kannst diese Funktionen nutzen, um Inhalte in deinem Astro-Projekt zu erstellen, zu lesen, zu aktualisieren und zu löschen.
Das Objekt studioCMSSDKCached
bietet eine Reihe von Funktionen und Dienstprogrammen, die es dir ermöglichen, mit dem StudioCMS SDK zu interagieren und es mit einer Caching-Schicht zu versehen. Du kannst diese Funktionen nutzen, um Inhalte in deinem Astro-Projekt zwischenzuspeichern.
StudioCMS SDK (Standard)
'Read the “', StudioCMS SDK (Standard), '” section'Das Objekt SDK.AUTH
bietet eine Reihe von Funktionen und Dienstprogrammen, mit denen du die Authentifizierung in deinem Astro-Projekt verwalten kannst. Du kannst diese Funktionen nutzen, um Benutzer zu authentifizieren, Sitzungen zu verwalten und vieles mehr.
import const SDK: { addPageToFolderTree: (tree: FolderNode[], folderId: string, newPage: FolderNode) => FolderNode[]; ... 29 more ...; notificationSettings: { site: { get: () => Promise<{ id: string; emailVerification: boolean; requireAdminVerification: boolean; requireEditorVerification: boolean; oAuthBypassVerification: boolean; }>; update: (settings: { ...; }) => Promise<{ id: string; emailVerification: boolean; requireAdminVerification: boolean; requireEditorVerification: boolean; oAuthBypassVerification: boolean; }>; }; };}
SDK from 'studiocms:sdk';
const { const oAuth: { create: (data: { provider: string; providerUserId: string; userId: string; }) => Promise<{ provider: string; providerUserId: string; userId: string; }>; delete: (userId: string, provider: string) => Promise<DeletionResponse>; searchProvidersForId: (providerId: string, userId: string) => Promise<{ ...; } | undefined>;}
oAuth, const permission: { currentStatus: (userId: string) => Promise<{ user: string; rank: string; } | undefined>;}
permission, const session: { create: (data: { userId: string; expiresAt: Date; id?: string; }) => Promise<{ id: string; userId: string; expiresAt: Date; }>; sessionWithUser: (sessionId: string) => Promise<{ user: { ...; }; session: { ...; }; }[]>; delete: (sessionId: string) => Promise<DeletionResponse>; update: (sessionId: string, newDate: Date) => Promise<{ ...; }[]>;}
session, const user: { create: (newUserData: { name: string; username: string; id?: string; url?: string | null; email?: string | null; avatar?: string | null; password?: string | null; updatedAt?: Date | null; createdAt?: Date | null; emailVerified?: boolean; notifications?: string | null; }, rank?: "visitor" | "editor" | "admin" | "owner") => Promise<{ ...; }>; update: (userId: string, userData: Partial<...>) => Promise<{ ...; }>; searchUsersForUsernameOrEmail: (username: string, email: string) => Promise<{ usernameSearch: { ...; }[]; emailSearch: { ...; }[]; }>; ghost: { verifyExists: () => Promise<boolean>; create: () => Promise<{ name: string; password: string | null; email: string | null; url: string | null; username: string; id: string; avatar: string | null; updatedAt: Date | null; createdAt: Date | null; emailVerified: boolean; notifications: string | null; }>; get: () => Promise<{ name: string; password: string | null; email: string | null; url: string | null; username: string; id: string; avatar: string | null; updatedAt: Date | null; createdAt: Date | null; emailVerified: boolean; notifications: string | ...
user,} = const SDK: { addPageToFolderTree: (tree: FolderNode[], folderId: string, newPage: FolderNode) => FolderNode[]; ... 29 more ...; notificationSettings: { site: { get: () => Promise<{ id: string; emailVerification: boolean; requireAdminVerification: boolean; requireEditorVerification: boolean; oAuthBypassVerification: boolean; }>; update: (settings: { ...; }) => Promise<{ id: string; emailVerification: boolean; requireAdminVerification: boolean; requireEditorVerification: boolean; oAuthBypassVerification: boolean; }>; }; };}
SDK.type AUTH: { verifyEmail: { get: (id: string) => Promise<{ id: string; userId: string; token: string; expiresAt: Date; } | null>; create: (userId: string) => Promise<{ id: string; userId: string; token: string; expiresAt: Date; }>; delete: (userId: string) => Promise<void>; }; oAuth: { create: (data: { ...; }) => Promise<{ ...; }>; delete: (userId: string, provider: string) => Promise<DeletionResponse>; searchProvidersForId: (providerId: string, userId: string) => Promise<{ ...; } | undefined>; }; permission: { currentStatus: (userId: string) => Promise<{ ...; } | undefined>; }; session: { create: (data: { ...; }) => Promise<{ ...; }>; sessionWithUser: (sessionId: string) => Promise<{ user: { ...; }; session: { ...; }; }[]>; delete: (sessionId: string) => Promise<DeletionResponse>; update: (sessionId: string, newDate: Date) => Promise<{ ...; }[]>; }; user: { create: (newUserData: { ...; }, rank?: "visitor" | "editor" | "admin" | "owner") => Promise<{ ...; }>; update: (userId: string, userData: Partial<...>) => Promise<{ ...; }>; searchUsersForUsernameOrEmail ...
AUTH;
Das Objekt SDK.INIT
bietet eine Reihe von Funktionen und Dienstprogrammen, mit denen du das StudioCMS SDK in deinem Astro-Projekt initialisieren kannst. Du kannst diese Funktionen nutzen, um das SDK einzurichten, zu konfigurieren und vieles mehr.
import const SDK: { addPageToFolderTree: (tree: FolderNode[], folderId: string, newPage: FolderNode) => FolderNode[]; ... 29 more ...; notificationSettings: { site: { get: () => Promise<{ id: string; emailVerification: boolean; requireAdminVerification: boolean; requireEditorVerification: boolean; oAuthBypassVerification: boolean; }>; update: (settings: { ...; }) => Promise<{ id: string; emailVerification: boolean; requireAdminVerification: boolean; requireEditorVerification: boolean; oAuthBypassVerification: boolean; }>; }; };}
SDK from 'studiocms:sdk';
const { const siteConfig: (config: { title: string; description: string; id?: number; defaultOgImage?: string | null; siteIcon?: string | null; loginPageBackground?: string; loginPageCustomImage?: string | null; enableDiffs?: boolean; diffPerPage?: number; gridItems?: unknown; enableMailer?: boolean;}) => Promise<{ ...;}>
siteConfig, const ghostUser: () => Promise<{ id: string; name: string; url: string | null; email: string | null; avatar: string | null; username: string; password: string | null; updatedAt: Date | null; createdAt: Date | null; emailVerified: boolean; notifications: string | null;}>
ghostUser,} = const SDK: { addPageToFolderTree: (tree: FolderNode[], folderId: string, newPage: FolderNode) => FolderNode[]; ... 29 more ...; notificationSettings: { site: { get: () => Promise<{ id: string; emailVerification: boolean; requireAdminVerification: boolean; requireEditorVerification: boolean; oAuthBypassVerification: boolean; }>; update: (settings: { ...; }) => Promise<{ id: string; emailVerification: boolean; requireAdminVerification: boolean; requireEditorVerification: boolean; oAuthBypassVerification: boolean; }>; }; };}
SDK.type INIT: { siteConfig: (config: { title: string; description: string; id?: number; defaultOgImage?: string | null; siteIcon?: string | null; loginPageBackground?: string; loginPageCustomImage?: string | null; enableDiffs?: boolean; diffPerPage?: number; gridItems?: unknown; enableMailer?: boolean; }) => Promise<{ ...; }>; ghostUser: () => Promise<{ ...; }>;}
INIT;
Das Objekt SDK.GET
bietet eine Reihe von Funktionen und Dienstprogrammen, mit denen du Inhalte aus Astro DB abrufen kannst. Du kannst diese Funktionen nutzen, um Inhalte nach ID, nach Typ und mehr abzurufen.
import const SDK: { addPageToFolderTree: (tree: FolderNode[], folderId: string, newPage: FolderNode) => FolderNode[]; ... 29 more ...; notificationSettings: { site: { get: () => Promise<{ id: string; emailVerification: boolean; requireAdminVerification: boolean; requireEditorVerification: boolean; oAuthBypassVerification: boolean; }>; update: (settings: { ...; }) => Promise<{ id: string; emailVerification: boolean; requireAdminVerification: boolean; requireEditorVerification: boolean; oAuthBypassVerification: boolean; }>; }; };}
SDK from 'studiocms:sdk';
const { const database: { users: () => Promise<CombinedUserData[]>; pages: (includeDrafts?: boolean, tree?: FolderNode[]) => Promise<CombinedPageData[]>; config: () => Promise<{ ...; } | undefined>; folders: () => Promise<{ ...; }[]>;}
database, const databaseEntry: { users: { byId: (id: string) => Promise<CombinedUserData | undefined>; byUsername: (username: string) => Promise<CombinedUserData | undefined>; byEmail: (email: string) => Promise<CombinedUserData | undefined>; }; pages: { byId: (id: string, tree?: FolderNode[]) => Promise<CombinedPageData | undefined>; bySlug: (slug: string, tree?: FolderNode[]) => Promise<CombinedPageData | undefined>; }; folder: (id: string) => Promise<{ ...; } | undefined>;}
databaseEntry, const databaseTable: { users: () => Promise<{ name: string; password: string | null; email: string | null; url: string | null; username: string; id: string; avatar: string | null; updatedAt: Date | null; createdAt: Date | null; emailVerified: boolean; notifications: string | null; }[]>; ... 11 more ...; emailVerificationTokens: () => Promise<{ id: string; userId: string; token: string; expiresAt: Date; }[]>;}
databaseTable, const permissionsLists: { all: () => Promise<CombinedRank[]>; owners: () => Promise<SingleRank[]>; admins: () => Promise<SingleRank[]>; editors: () => Promise<SingleRank[]>; visitors: () => Promise<SingleRank[]>;}
permissionsLists, const packagePages: (packageName: string, tree?: FolderNode[]) => Promise<CombinedPageData[]>
packagePages,} = const SDK: { addPageToFolderTree: (tree: FolderNode[], folderId: string, newPage: FolderNode) => FolderNode[]; ... 29 more ...; notificationSettings: { site: { get: () => Promise<{ id: string; emailVerification: boolean; requireAdminVerification: boolean; requireEditorVerification: boolean; oAuthBypassVerification: boolean; }>; update: (settings: { ...; }) => Promise<{ id: string; emailVerification: boolean; requireAdminVerification: boolean; requireEditorVerification: boolean; oAuthBypassVerification: boolean; }>; }; };}
SDK.type GET: { database: { users: () => Promise<CombinedUserData[]>; pages: (includeDrafts?: boolean, tree?: FolderNode[]) => Promise<CombinedPageData[]>; config: () => Promise<{ id: number; title: string; description: string; defaultOgImage: string | null; ... 6 more ...; enableMailer: boolean; } | undefined>; folders: () => Promise<{ ...; }[]>; }; databaseEntry: { users: { byId: (id: string) => Promise<CombinedUserData | undefined>; byUsername: (username: string) => Promise<CombinedUserData | undefined>; byEmail: (email: string) => Promise<CombinedUserData | undefined>; }; pages: { byId: (id: string, tree?: FolderNode[]) => Promise<CombinedPageData | undefined>; bySlug: (slug: string, tree?: FolderNode[]) => Promise<CombinedPageData | undefined>; }; folder: (id: string) => Promise<{ ...; } | undefined>; }; databaseTable: { users: () => Promise<{ name: string; password: string | null; email: string | null; url: string | null; username: string; id: string; avatar: string | null; updatedAt: Date | null; createdAt: Date | null; emailVerified: boolean; notifications: string | null; }[]>; oAuthAccounts: () => Promise<{ userId: string; provider: string ...
GET;
Das Objekt SDK.POST
bietet eine Reihe von Funktionen und Dienstprogrammen, mit denen du Inhalte in Astro DB erstellen kannst. Du kannst diese Funktionen nutzen, um Inhalte nach Typ zu erstellen, Inhalte nach ID zu erstellen und vieles mehr.
import const SDK: { addPageToFolderTree: (tree: FolderNode[], folderId: string, newPage: FolderNode) => FolderNode[]; ... 29 more ...; notificationSettings: { site: { get: () => Promise<{ id: string; emailVerification: boolean; requireAdminVerification: boolean; requireEditorVerification: boolean; oAuthBypassVerification: boolean; }>; update: (settings: { ...; }) => Promise<{ id: string; emailVerification: boolean; requireAdminVerification: boolean; requireEditorVerification: boolean; oAuthBypassVerification: boolean; }>; }; };}
SDK from 'studiocms:sdk';
const { const databaseEntry: { pages: (pageData: { title: string; description: string; slug: string; id?: string; package?: string; showOnNav?: boolean; publishedAt?: Date; updatedAt?: Date | null; contentLang?: string; heroImage?: string; ... 7 more ...; draft?: boolean | null; }, pageContent: CombinedInsertContent) => Promise<addDatabaseEntryInsertPage>; ... 5 more ...; folder: (folder: { ...; }) => Promise<{ ...; }>;}
databaseEntry, const databaseEntries: { tags: (data: { name: string; description: string; slug: string; meta: unknown; id?: number; }[]) => Promise<PageDataTagsInsertResponse[]>; categories: (data: { ...; }[]) => Promise<PageDataCategoriesInsertResponse[]>; permissions: (data: { ...; }[]) => Promise<{ ...; }[]>; pages: (pages: MultiPageInsert) => Promise<void>;}
databaseEntries,} = const SDK: { addPageToFolderTree: (tree: FolderNode[], folderId: string, newPage: FolderNode) => FolderNode[]; ... 29 more ...; notificationSettings: { site: { get: () => Promise<{ id: string; emailVerification: boolean; requireAdminVerification: boolean; requireEditorVerification: boolean; oAuthBypassVerification: boolean; }>; update: (settings: { ...; }) => Promise<{ id: string; emailVerification: boolean; requireAdminVerification: boolean; requireEditorVerification: boolean; oAuthBypassVerification: boolean; }>; }; };}
SDK.type POST: { databaseEntry: { pages: (pageData: { title: string; description: string; slug: string; id?: string; package?: string; showOnNav?: boolean; publishedAt?: Date; updatedAt?: Date | null; contentLang?: string; ... 8 more ...; draft?: boolean | null; }, pageContent: CombinedInsertContent) => Promise<addDatabaseEntryInsertPage>; pageContent: (pageContent: { ...; }) => Promise<PageContentReturnId[]>; tags: (tag: { ...; }) => Promise<PageDataTagsInsertResponse[]>; categories: (category: { ...; }) => Promise<{ id: number; }[]>; permissions: (userId: string, rank: string) => Promise<{ ...; }[]>; diffTracking: (diff: { ...; }) => Promise<{ ...; }[]>; folder: (folder: { ...; }) => Promise<{ ...; }>; }; databaseEntries: { tags: (data: { ...; }[]) => Promise<PageDataTagsInsertResponse[]>; categories: (data: { ...; }[]) => Promise<PageDataCategoriesInsertResponse[]>; permissions: (data: { ...; }[]) => Promise<{ ...; }[]>; pages: (pages: MultiPageInsert) => Promise<void>; };}
POST;
SDK.UPDATE
'Read the “', SDK.UPDATE, '” section'Das Objekt SDK.UPDATE
bietet eine Reihe von Funktionen und Dienstprogrammen, mit denen du Inhalte in Astro DB aktualisieren kannst. Du kannst diese Funktionen nutzen, um Inhalte nach ID zu aktualisieren, Inhalte nach Typ zu aktualisieren und vieles mehr.
import const SDK: { addPageToFolderTree: (tree: FolderNode[], folderId: string, newPage: FolderNode) => FolderNode[]; ... 29 more ...; notificationSettings: { site: { get: () => Promise<{ id: string; emailVerification: boolean; requireAdminVerification: boolean; requireEditorVerification: boolean; oAuthBypassVerification: boolean; }>; update: (settings: { ...; }) => Promise<{ id: string; emailVerification: boolean; requireAdminVerification: boolean; requireEditorVerification: boolean; oAuthBypassVerification: boolean; }>; }; };}
SDK from 'studiocms:sdk';
const { const page: (data: { id: string; package: string; title: string; description: string; showOnNav: boolean; publishedAt: Date; updatedAt: Date | null; slug: string; contentLang: string; heroImage: string; ... 7 more ...; draft: boolean | null;}) => Promise<{ ...;}>
page, const pageContent: (data: { id: string; contentLang: string; contentId: string; content: string | null;}) => Promise<{ id: string; contentLang: string; contentId: string; content: string | null;}>
pageContent, const tags: (data: { id: number; name: string; description: string; slug: string; meta: unknown;}) => Promise<{ id: number; name: string; description: string; slug: string; meta: unknown;}>
tags, const categories: (data: { id: number; name: string; description: string; slug: string; meta: unknown; parent: number | null;}) => Promise<{ id: number; name: string; description: string; slug: string; meta: unknown; parent: number | null;}>
categories, const permissions: (data: { user: string; rank: string;}) => Promise<{ user: string; rank: string;}>
permissions, const siteConfig: (data: { id: number; title: string; description: string; defaultOgImage: string | null; siteIcon: string | null; loginPageBackground: string; loginPageCustomImage: string | null; enableDiffs: boolean; diffPerPage: number; gridItems: unknown; enableMailer: boolean;}) => Promise<{ ...;}>
siteConfig, const folder: (data: { id: string; name: string; parent: string | null;}) => Promise<{ id: string; name: string; parent: string | null;}>
folder,} = const SDK: { addPageToFolderTree: (tree: FolderNode[], folderId: string, newPage: FolderNode) => FolderNode[]; ... 29 more ...; notificationSettings: { site: { get: () => Promise<{ id: string; emailVerification: boolean; requireAdminVerification: boolean; requireEditorVerification: boolean; oAuthBypassVerification: boolean; }>; update: (settings: { ...; }) => Promise<{ id: string; emailVerification: boolean; requireAdminVerification: boolean; requireEditorVerification: boolean; oAuthBypassVerification: boolean; }>; }; };}
SDK.type UPDATE: { page: (data: { id: string; package: string; title: string; description: string; showOnNav: boolean; publishedAt: Date; updatedAt: Date | null; slug: string; contentLang: string; heroImage: string; ... 7 more ...; draft: boolean | null; }) => Promise<{ ...; }>; ... 5 more ...; folder: (data: { ...; }) => Promise<{ ...; }>;}
UPDATE;
SDK.DELETE
'Read the “', SDK.DELETE, '” section'Das Objekt SDK.DELETE
bietet eine Reihe von Funktionen und Hilfsmitteln, mit denen du Inhalte aus Astro DB löschen kannst. Du kannst diese Funktionen nutzen, um Inhalte nach ID, nach Typ und mehr zu löschen.
import const SDK: { addPageToFolderTree: (tree: FolderNode[], folderId: string, newPage: FolderNode) => FolderNode[]; ... 29 more ...; notificationSettings: { site: { get: () => Promise<{ id: string; emailVerification: boolean; requireAdminVerification: boolean; requireEditorVerification: boolean; oAuthBypassVerification: boolean; }>; update: (settings: { ...; }) => Promise<{ id: string; emailVerification: boolean; requireAdminVerification: boolean; requireEditorVerification: boolean; oAuthBypassVerification: boolean; }>; }; };}
SDK from 'studiocms:sdk';
const { const page: (id: string) => Promise<DeletionResponse>
page, const pageContent: (id: string) => Promise<DeletionResponse>
pageContent, const pageContentLang: (id: string, lang: string) => Promise<DeletionResponse>
pageContentLang, const tags: (id: number) => Promise<DeletionResponse>
tags, const categories: (id: number) => Promise<DeletionResponse>
categories, const permissions: (userId: string) => Promise<DeletionResponse>
permissions, const diffTracking: (id: string) => Promise<DeletionResponse>
diffTracking, const folder: (id: string) => Promise<DeletionResponse>
folder, const user: (id: string) => Promise<DeletionResponse>
user,} = const SDK: { addPageToFolderTree: (tree: FolderNode[], folderId: string, newPage: FolderNode) => FolderNode[]; ... 29 more ...; notificationSettings: { site: { get: () => Promise<{ id: string; emailVerification: boolean; requireAdminVerification: boolean; requireEditorVerification: boolean; oAuthBypassVerification: boolean; }>; update: (settings: { ...; }) => Promise<{ id: string; emailVerification: boolean; requireAdminVerification: boolean; requireEditorVerification: boolean; oAuthBypassVerification: boolean; }>; }; };}
SDK.type DELETE: { page: (id: string) => Promise<DeletionResponse>; pageContent: (id: string) => Promise<DeletionResponse>; ... 6 more ...; user: (id: string) => Promise<DeletionResponse>;}
DELETE;
Das Objekt SDK.db
bietet eine Reihe von Funktionen und Dienstprogrammen, mit denen du direkt mit der Astro-DB interagieren kannst. Du kannst diese Funktionen nutzen, um die Datenbank abzufragen, benutzerdefinierte Abfragen durchzuführen und vieles mehr.
import const SDK: { addPageToFolderTree: (tree: FolderNode[], folderId: string, newPage: FolderNode) => FolderNode[]; ... 29 more ...; notificationSettings: { site: { get: () => Promise<{ id: string; emailVerification: boolean; requireAdminVerification: boolean; requireEditorVerification: boolean; oAuthBypassVerification: boolean; }>; update: (settings: { ...; }) => Promise<{ id: string; emailVerification: boolean; requireAdminVerification: boolean; requireEditorVerification: boolean; oAuthBypassVerification: boolean; }>; }; };}
SDK from 'studiocms:sdk';
const { const db: Database
db } = const SDK: { addPageToFolderTree: (tree: FolderNode[], folderId: string, newPage: FolderNode) => FolderNode[]; ... 29 more ...; notificationSettings: { site: { get: () => Promise<{ id: string; emailVerification: boolean; requireAdminVerification: boolean; requireEditorVerification: boolean; oAuthBypassVerification: boolean; }>; update: (settings: { ...; }) => Promise<{ id: string; emailVerification: boolean; requireAdminVerification: boolean; requireEditorVerification: boolean; oAuthBypassVerification: boolean; }>; }; };}
SDK;
db
findest du im Astro DB Guide^ SDK.REST_API
'Read the “', SDK.REST_API, '” section'Das Objekt SDK.REST_API
bietet eine Reihe von Funktionen und Dienstprogrammen, die die REST-API verwendet, um mit dem StudioCMS und der Astro DB zu interagieren.
import const SDK: { addPageToFolderTree: (tree: FolderNode[], folderId: string, newPage: FolderNode) => FolderNode[]; ... 29 more ...; notificationSettings: { site: { get: () => Promise<{ id: string; emailVerification: boolean; requireAdminVerification: boolean; requireEditorVerification: boolean; oAuthBypassVerification: boolean; }>; update: (settings: { ...; }) => Promise<{ id: string; emailVerification: boolean; requireAdminVerification: boolean; requireEditorVerification: boolean; oAuthBypassVerification: boolean; }>; }; };}
SDK from 'studiocms:sdk';
const { tokens: { get: (userId: string) => Promise<{ key: string; description: string | null; id: string; userId: string; creationDate: Date; }[]>; new: (userId: string, description: string) => Promise<{ key: string; description: string | null; id: string; userId: string; creationDate: Date; }>; delete: (userId: string, tokenId: string) => Promise<void>; verify: (key: string) => Promise<false | { userId: string; key: string; rank: string; }>;}
tokens: { get: (userId: string) => Promise<{ key: string; description: string | null; id: string; userId: string; creationDate: Date;}[]>
get: const getToken: (userId: string) => Promise<{ key: string; description: string | null; id: string; userId: string; creationDate: Date;}[]>
getToken, new: (userId: string, description: string) => Promise<{ key: string; description: string | null; id: string; userId: string; creationDate: Date;}>
new: const newToken: (userId: string, description: string) => Promise<{ key: string; description: string | null; id: string; userId: string; creationDate: Date;}>
newToken, delete: (userId: string, tokenId: string) => Promise<void>
delete: const deleteToken: (userId: string, tokenId: string) => Promise<void>
deleteToken, verify: (key: string) => Promise<false | { userId: string; key: string; rank: string;}>
verify: const verifyToken: (key: string) => Promise<false | { userId: string; key: string; rank: string;}>
verifyToken, },} = const SDK: { addPageToFolderTree: (tree: FolderNode[], folderId: string, newPage: FolderNode) => FolderNode[]; ... 29 more ...; notificationSettings: { site: { get: () => Promise<{ id: string; emailVerification: boolean; requireAdminVerification: boolean; requireEditorVerification: boolean; oAuthBypassVerification: boolean; }>; update: (settings: { ...; }) => Promise<{ id: string; emailVerification: boolean; requireAdminVerification: boolean; requireEditorVerification: boolean; oAuthBypassVerification: boolean; }>; }; };}
SDK.type REST_API: { tokens: { get: (userId: string) => Promise<{ key: string; description: string | null; id: string; userId: string; creationDate: Date; }[]>; new: (userId: string, description: string) => Promise<{ key: string; description: string | null; id: string; userId: string; creationDate: Date; }>; delete: (userId: string, tokenId: string) => Promise<void>; verify: (key: string) => Promise<false | { userId: string; key: string; rank: string; }>; };}
REST_API;
SDK.diffTracking
'Read the “', SDK.diffTracking, '” section'Das Objekt SDK.diffTracking
bietet eine Reihe von Funktionen und Dienstprogrammen, mit denen du Änderungen in Astro DB verfolgen kannst. Du kannst diese Funktionen nutzen, um Änderungen an Inhalten, an Benutzern und mehr zu verfolgen.
import const SDK: { addPageToFolderTree: (tree: FolderNode[], folderId: string, newPage: FolderNode) => FolderNode[]; ... 29 more ...; notificationSettings: { site: { get: () => Promise<{ id: string; emailVerification: boolean; requireAdminVerification: boolean; requireEditorVerification: boolean; oAuthBypassVerification: boolean; }>; update: (settings: { ...; }) => Promise<{ id: string; emailVerification: boolean; requireAdminVerification: boolean; requireEditorVerification: boolean; oAuthBypassVerification: boolean; }>; }; };}
SDK from 'studiocms:sdk';
const { const insert: (userId: string, pageId: string, data: { content: { start: string; end: string; }; metaData: { start: Partial<{ id: string; package: string; title: string; description: string; showOnNav: boolean; publishedAt: Date; updatedAt: Date | null; slug: string; ... 9 more ...; draft: boolean | null; }>; end: Partial<{ ...; }>; };}, diffLength: number) => Promise<diffReturn>
insert, const clear: (pageId: string) => Promise<void>
clear, const get: { byPageId: { all: (pageId: string) => Promise<diffReturn[]>; latest: (pageId: string, count: number) => Promise<diffReturn[]>; }; byUserId: { all: (userId: string) => Promise<diffReturn[]>; latest: (userId: string, count: number) => Promise<diffReturn[]>; }; single: (id: string) => Promise<diffReturn | undefined>;}
get, const revertToDiff: (id: string, type: "content" | "data" | "both") => Promise<diffReturn>
revertToDiff} = const SDK: { addPageToFolderTree: (tree: FolderNode[], folderId: string, newPage: FolderNode) => FolderNode[]; ... 29 more ...; notificationSettings: { site: { get: () => Promise<{ id: string; emailVerification: boolean; requireAdminVerification: boolean; requireEditorVerification: boolean; oAuthBypassVerification: boolean; }>; update: (settings: { ...; }) => Promise<{ id: string; emailVerification: boolean; requireAdminVerification: boolean; requireEditorVerification: boolean; oAuthBypassVerification: boolean; }>; }; };}
SDK.diffTracking: { insert: (userId: string, pageId: string, data: { content: { start: string; end: string; }; metaData: { start: Partial<{ id: string; package: string; title: string; description: string; showOnNav: boolean; publishedAt: Date; updatedAt: Date | null; slug: string; contentLang: string; heroImage: string; ... 7 more ...; draft: boolean | null; }>; end: Partial<{ ...; }>; }; }, diffLength: number) => Promise<diffReturn>; clear: (pageId: string) => Promise<void>; get: { byPageId: { all: (pageId: string) => Promise<diffReturn[]>; latest: (pageId: string, count: number) => Promise<diffReturn[]>; }; byUserId: { all: (userId: string) => Promise<diffReturn[]>; latest: (userId: string, count: number) => Promise<diffReturn[]>; }; single: (id: string) => Promise<diffReturn | undefined>; }; revertToDiff: (id: string, type: "content" | "data" | "both") => Promise<diffReturn>; utils: { getMetaDataDifferences<T extends Record<string, any>>(obj1: T, obj2: T): { label: string; previous: any; current: any; }[]; getDiffHTML(diff: string | null, options?: Diff2HtmlConfig): string; };}
diffTracking;
Nützliche Funktionen
'Read the “', Nützliche Funktionen, '” section'Das StudioCMS SDK bietet auch eine Reihe von Hilfsfunktionen, mit denen du mit dem SDK interagieren kannst. Zu diesen Funktionen gehören:
import const SDK: { addPageToFolderTree: (tree: FolderNode[], folderId: string, newPage: FolderNode) => FolderNode[]; ... 29 more ...; notificationSettings: { site: { get: () => Promise<{ id: string; emailVerification: boolean; requireAdminVerification: boolean; requireEditorVerification: boolean; oAuthBypassVerification: boolean; }>; update: (settings: { ...; }) => Promise<{ id: string; emailVerification: boolean; requireAdminVerification: boolean; requireEditorVerification: boolean; oAuthBypassVerification: boolean; }>; }; };}
SDK from 'studiocms:sdk';
const { const addPageToFolderTree: (tree: FolderNode[], folderId: string, newPage: FolderNode) => FolderNode[]
addPageToFolderTree, const findNodeById: (tree: FolderNode[], id: string) => FolderNode | null
findNodeById, const findNodeByPath: (tree: FolderNode[], path: string[]) => FolderNode | null
findNodeByPath, const findNodesAlongPath: (tree: FolderNode[], path: string[]) => FolderNode[]
findNodesAlongPath, const getFullPath: (tree: FolderNode[], path: string[]) => string[]
getFullPath, const parseIdNumberArray: (ids: unknown) => number[]
parseIdNumberArray, const parseIdStringArray: (ids: unknown) => string[]
parseIdStringArray, const generateRandomIDNumber: (length: number) => number
generateRandomIDNumber, const generateToken: (userId: string) => string
generateToken, const testToken: (token: string) => string | jwt.JwtPayload
testToken, const combineRanks: (rank: string, users: SingleRank[]) => CombinedRank[]
combineRanks, const verifyRank: (users: tsUsersSelect[], permissions: tsPermissionsSelect[], rank: string) => SingleRank[]
verifyRank, const buildFolderTree: () => Promise<FolderNode[]>
buildFolderTree, const getAvailableFolders: () => Promise<FolderListItem[]>
getAvailableFolders, const clearUserReferences: (userId: string) => Promise<boolean>
clearUserReferences, const collectCategories: (categoryIds: number[]) => Promise<CombinedPageData["categories"]>
collectCategories, const collectTags: (tagIds: number[]) => Promise<CombinedPageData["tags"]>
collectTags, const collectPageData: (page: { id: string; updatedAt: Date | null; categories: unknown; package: string; title: string; description: string; showOnNav: boolean; publishedAt: Date; slug: string; contentLang: string; ... 7 more ...; draft: boolean | null;}, tree: FolderNode[]) => Promise<CombinedPageData>
collectPageData, const collectUserData: (user: { id: string; name: string; url: string | null; email: string | null; avatar: string | null; username: string; password: string | null; updatedAt: Date | null; createdAt: Date | null; emailVerified: boolean; notifications: string | null;}) => Promise<CombinedUserData>
collectUserData, const generateRandomPassword: (length: number) => string
generateRandomPassword,} = const SDK: { addPageToFolderTree: (tree: FolderNode[], folderId: string, newPage: FolderNode) => FolderNode[]; ... 29 more ...; notificationSettings: { site: { get: () => Promise<{ id: string; emailVerification: boolean; requireAdminVerification: boolean; requireEditorVerification: boolean; oAuthBypassVerification: boolean; }>; update: (settings: { ...; }) => Promise<{ id: string; emailVerification: boolean; requireAdminVerification: boolean; requireEditorVerification: boolean; oAuthBypassVerification: boolean; }>; }; };}
SDK;
StudioCMS SDK (Cached)
'Read the “', StudioCMS SDK (Cached), '” section'Das StudioCMS SDK bietet auch eine gecachte Version des SDK mit einer begrenzten Untermenge der SDK-Funktionen, die eine Caching-Schicht über dem Standard-SDK enthält. Du kannst das gecachte SDK mit der folgenden Syntax importieren:
import const SDKCached: { GET: { page: { byId: (id: string) => Promise<PageDataCacheObject>; bySlug: (slug: string) => Promise<PageDataCacheObject>; }; pages: (includeDrafts?: boolean) => Promise<PageDataCacheObject[]>; siteConfig: () => Promise<SiteConfigCacheObject>; latestVersion: () => Promise<VersionCacheObject>; folderTree: () => Promise<FolderTreeCacheObject>; pageFolderTree: (includeDrafts?: boolean) => Promise<FolderTreeCacheObject>; folderList: () => Promise<FolderListCacheObject>; folder: (id: string) => Promise<{ name: string; id: string; parent: string | null; } | undefined>; databaseTable: { ...; }; }; ... 5 more ...; diffTracking: { ...; };}
SDKCached from 'studiocms:sdk/cache';
SDKCached.GET
'Read the “', SDKCached.GET, '” section'Das Objekt SDKCached.GET
bietet eine Reihe von Funktionen und Dienstprogrammen, mit denen du Inhalte aus der Astro-DB abrufen kannst, die mit einer Zwischenspeicherschicht versehen sind. Du kannst diese Funktionen nutzen, um Inhalte nach ID, nach Typ und mehr abzurufen.
import const SDKCached: { GET: { page: { byId: (id: string) => Promise<PageDataCacheObject>; bySlug: (slug: string) => Promise<PageDataCacheObject>; }; pages: (includeDrafts?: boolean) => Promise<PageDataCacheObject[]>; siteConfig: () => Promise<SiteConfigCacheObject>; latestVersion: () => Promise<VersionCacheObject>; folderTree: () => Promise<FolderTreeCacheObject>; pageFolderTree: (includeDrafts?: boolean) => Promise<FolderTreeCacheObject>; folderList: () => Promise<FolderListCacheObject>; folder: (id: string) => Promise<{ name: string; id: string; parent: string | null; } | undefined>; databaseTable: { ...; }; }; ... 5 more ...; diffTracking: { ...; };}
SDKCached from 'studiocms:sdk/cache';
const { const page: { byId: (id: string) => Promise<PageDataCacheObject>; bySlug: (slug: string) => Promise<PageDataCacheObject>;}
page, const pages: (includeDrafts?: boolean) => Promise<PageDataCacheObject[]>
pages, const siteConfig: () => Promise<SiteConfigCacheObject>
siteConfig, const latestVersion: () => Promise<VersionCacheObject>
latestVersion, const folderTree: () => Promise<FolderTreeCacheObject>
folderTree, const pageFolderTree: (includeDrafts?: boolean) => Promise<FolderTreeCacheObject>
pageFolderTree, const folderList: () => Promise<FolderListCacheObject>
folderList, const folder: (id: string) => Promise<{ name: string; id: string; parent: string | null;} | undefined>
folder,} = const SDKCached: { GET: { page: { byId: (id: string) => Promise<PageDataCacheObject>; bySlug: (slug: string) => Promise<PageDataCacheObject>; }; pages: (includeDrafts?: boolean) => Promise<PageDataCacheObject[]>; siteConfig: () => Promise<SiteConfigCacheObject>; latestVersion: () => Promise<VersionCacheObject>; folderTree: () => Promise<FolderTreeCacheObject>; pageFolderTree: (includeDrafts?: boolean) => Promise<FolderTreeCacheObject>; folderList: () => Promise<FolderListCacheObject>; folder: (id: string) => Promise<{ name: string; id: string; parent: string | null; } | undefined>; databaseTable: { ...; }; }; ... 5 more ...; diffTracking: { ...; };}
SDKCached.type GET: { page: { byId: (id: string) => Promise<PageDataCacheObject>; bySlug: (slug: string) => Promise<PageDataCacheObject>; }; ... 7 more ...; databaseTable: { ...; };}
GET;
SDKCached.CLEAR
'Read the “', SDKCached.CLEAR, '” section'Das Objekt SDKCached.CLEAR
bietet eine Reihe von Funktionen und Hilfsmitteln, mit denen du den Cache im SDK-Cache löschen kannst. Du kannst diese Funktionen verwenden, um den Cache für einen bestimmten Inhaltstyp zu löschen, den Cache für eine bestimmte Inhalts-ID zu löschen und vieles mehr.
import const SDKCached: { GET: { page: { byId: (id: string) => Promise<PageDataCacheObject>; bySlug: (slug: string) => Promise<PageDataCacheObject>; }; pages: (includeDrafts?: boolean) => Promise<PageDataCacheObject[]>; siteConfig: () => Promise<SiteConfigCacheObject>; latestVersion: () => Promise<VersionCacheObject>; folderTree: () => Promise<FolderTreeCacheObject>; pageFolderTree: (includeDrafts?: boolean) => Promise<FolderTreeCacheObject>; folderList: () => Promise<FolderListCacheObject>; folder: (id: string) => Promise<{ name: string; id: string; parent: string | null; } | undefined>; databaseTable: { ...; }; }; ... 5 more ...; diffTracking: { ...; };}
SDKCached from 'studiocms:sdk/cache';
const { const page: { byId: (id: string) => void; bySlug: (slug: string) => void;}
page, const pages: () => void
pages, const latestVersion: () => void
latestVersion, const folderTree: () => void
folderTree, const folderList: () => void
folderList,} = const SDKCached: { GET: { page: { byId: (id: string) => Promise<PageDataCacheObject>; bySlug: (slug: string) => Promise<PageDataCacheObject>; }; pages: (includeDrafts?: boolean) => Promise<PageDataCacheObject[]>; siteConfig: () => Promise<SiteConfigCacheObject>; latestVersion: () => Promise<VersionCacheObject>; folderTree: () => Promise<FolderTreeCacheObject>; pageFolderTree: (includeDrafts?: boolean) => Promise<FolderTreeCacheObject>; folderList: () => Promise<FolderListCacheObject>; folder: (id: string) => Promise<{ name: string; id: string; parent: string | null; } | undefined>; databaseTable: { ...; }; }; ... 5 more ...; diffTracking: { ...; };}
SDKCached.type CLEAR: { page: { byId: (id: string) => void; bySlug: (slug: string) => void; }; pages: () => void; latestVersion: () => void; folderTree: () => void; folderList: () => void;}
CLEAR;
SDKCached.UPDATE
'Read the “', SDKCached.UPDATE, '” section'Das Objekt SDKCached.UPDATE
bietet eine Reihe von Funktionen und Dienstprogrammen, mit denen du Inhalte in Astro DB mit einer Zwischenspeicherschicht aktualisieren kannst. Du kannst diese Funktionen nutzen, um Inhalte nach ID zu aktualisieren, Inhalte nach Typ zu aktualisieren und vieles mehr.
import const SDKCached: { GET: { page: { byId: (id: string) => Promise<PageDataCacheObject>; bySlug: (slug: string) => Promise<PageDataCacheObject>; }; pages: (includeDrafts?: boolean) => Promise<PageDataCacheObject[]>; siteConfig: () => Promise<SiteConfigCacheObject>; latestVersion: () => Promise<VersionCacheObject>; folderTree: () => Promise<FolderTreeCacheObject>; pageFolderTree: (includeDrafts?: boolean) => Promise<FolderTreeCacheObject>; folderList: () => Promise<FolderListCacheObject>; folder: (id: string) => Promise<{ name: string; id: string; parent: string | null; } | undefined>; databaseTable: { ...; }; }; ... 5 more ...; diffTracking: { ...; };}
SDKCached from 'studiocms:sdk/cache';
const { const page: { byId: (id: string, data: { pageData: tsPageDataSelect; pageContent: tsPageContentSelect; }) => Promise<PageDataCacheObject>; bySlug: (slug: string, data: { pageData: tsPageDataSelect; pageContent: tsPageContentSelect; }) => Promise<PageDataCacheObject>;}
page, const siteConfig: (data: SiteConfig) => Promise<SiteConfigCacheObject>
siteConfig, const latestVersion: () => Promise<VersionCacheObject>
latestVersion, const folderTree: () => Promise<FolderTreeCacheObject>
folderTree, const folderList: () => Promise<FolderListCacheObject>
folderList, const folder: (data: tsPageFolderSelect) => Promise<{ name: string; id: string; parent: string | null;}>
folder,} = const SDKCached: { GET: { page: { byId: (id: string) => Promise<PageDataCacheObject>; bySlug: (slug: string) => Promise<PageDataCacheObject>; }; pages: (includeDrafts?: boolean) => Promise<PageDataCacheObject[]>; siteConfig: () => Promise<SiteConfigCacheObject>; latestVersion: () => Promise<VersionCacheObject>; folderTree: () => Promise<FolderTreeCacheObject>; pageFolderTree: (includeDrafts?: boolean) => Promise<FolderTreeCacheObject>; folderList: () => Promise<FolderListCacheObject>; folder: (id: string) => Promise<{ name: string; id: string; parent: string | null; } | undefined>; databaseTable: { ...; }; }; ... 5 more ...; diffTracking: { ...; };}
SDKCached.type UPDATE: { page: { byId: (id: string, data: { pageData: tsPageDataSelect; pageContent: tsPageContentSelect; }) => Promise<PageDataCacheObject>; bySlug: (slug: string, data: { pageData: tsPageDataSelect; pageContent: tsPageContentSelect; }) => Promise<PageDataCacheObject>; }; ... 4 more ...; folder: (data: tsPageFolderSelect) => Promise<{ name: string; id: string; parent: string | null; }>;}
UPDATE;
SDKCached.db
'Read the “', SDKCached.db, '” section'Dies ist ein Passthrough zum Standard SDK db
Objekt.
SDK.db
für weitere Informationen