跳转到内容

SDK

StudioCMS SDK 是一个强大的工具,允许您以编程方式与 StudioCMS 交互。它提供了一套函数和实用工具,使您能够使用 Astro DB 管理和提供内容。它同时也是 StudioCMS 仪表板的核心基础。

StudioCMS SDK 在您的 Astro 项目中作为虚拟模块提供。您可以使用以下语法导入它:

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';
// 或者
import
const SDKCached: {
GET: {
page: {
byId: {
(id: string): Promise<PageDataCacheObject>;
(id: string, metaOnly?: boolean): Promise<MetaOnlyPageDataCacheObject>;
};
bySlug: {
...;
};
};
pages: {
...;
};
folderPages: {
...;
};
siteConfig: () => Promise<SiteConfigCacheObject>;
latestVersion: () => Promise<VersionCacheObject>;
folderTree: () => Promise<FolderTreeCacheObject>;
pageFolderTree: (includeDrafts?: boolean, hideDefaultIndex?: boolean) => Promise<FolderTreeCacheObject>;
folderList: () => Promise<FolderListCacheObject>;
folder: (id: string) => Promise<tsPageFolderSelect | 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;
providerUserId: string;
}[]>;
sessionTable: () => Promise<{
id: string;
userId: string;
expiresAt: Date;
}[ ...
SDKCached
from 'studiocms:sdk/cache';

studioCMSSDK 对象提供了一套允许您与 StudioCMS 交互的函数和实用工具。您可以使用这些函数在 Astro 项目中创建、读取、更新和删除内容。

studioCMSSDKCached 对象提供了一套函数和实用工具,允许您在 StudioCMS SDK 之上使用缓存层进行交互。您可以使用这些函数在 Astro 项目中缓存内容。

SDK.AUTH 对象提供了一套管理 Astro 项目身份验证的函数和实用工具。您可以使用这些函数来验证用户、管理会话等。

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
;

SDK.INIT 对象提供了一套用于在 Astro 项目中初始化 StudioCMS SDK 的函数和实用工具。您可以使用这些函数设置 SDK、进行配置等。

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;
hideDefaultIndex?: 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;
... 4 more ...;
hideDefaultIndex?: boolean;
}) => Promise<{
...;
}>;
ghostUser: () => Promise<{
...;
}>;
}
INIT
;

SDK.GET 对象提供了一套从 Astro DB 检索内容的函数和实用工具。您可以使用这些函数按 ID 获取内容、按类型获取内容等。

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, hideDefaultIndex?: boolean, tree?: FolderNode[], metaOnly?: false, paginate?: PaginateInput): Promise<CombinedPageData[]>;
(includeDrafts?: boolean, hideDefaultIndex?: boolean, tree?: FolderNode[], metaOnly?: true, paginate?: PaginateInput): Promise<MetaOnlyPageData[]>;
};
folderPages: {
(id: string, includeDrafts?: boolean, hideDefaultIndex?: boolean, tree?: FolderNode[], metaOnly?: false, paginate?: PaginateInput): Promise<CombinedPageData[]>;
(id: string, includeDrafts?: boolean, hideDefaultIndex?: boolean, tree?: FolderNode[], metaOnly?: true, paginate?: PaginateInput): Promise<MetaOnlyPageData[]>;
};
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>;
(id: string, tree?: FolderNode[], metaOnly?: boolean): Promise<MetaOnlyPageData | undefined>;
};
bySlug: {
(slug: string, tree?: FolderNode[]): Promise<CombinedPageData | undefined>;
(slug: string, tree?: FolderNode[], metaOnly?: boolean): Promise<MetaOnlyPageData | 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[]>;
(packageName: string, tree?: FolderNode[], metaOnly?: boolean): Promise<MetaOnlyPageData[]>;
}
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, hideDefaultIndex?: boolean, tree?: FolderNode[], metaOnly?: false, paginate?: PaginateInput): Promise<CombinedPageData[]>;
(includeDrafts?: boolean, hideDefaultIndex?: boolean, tree?: FolderNode[], metaOnly?: true, paginate?: PaginateInput): Promise<MetaOnlyPageData[]>;
};
folderPages: {
(id: string, includeDrafts?: boolean, hideDefaultIndex?: boolean, tree?: FolderNode[], metaOnly?: false, paginate?: PaginateInput): Promise<CombinedPageData[]>;
(id: string, includeDrafts?: boolean, hideDefaultIndex?: boolean, tree?: FolderNode[], metaOnly?: true, paginate?: PaginateInput): Promise<MetaOnlyPageData[]>;
};
config: () => Promise<{
...;
} | 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>;
(id: string, tree?: FolderNode[], metaOnly?: boolean): Promise<MetaOnlyPageData | undefined>;
};
bySlug: {
(slug: string, tree?: FolderNode[]): Promise<CombinedPageData | undefined>;
( ...
GET
;

SDK.POST 对象提供了一套在 Astro DB 中创建内容的函数和实用工具。您可以使用这些函数按类型创建内容、按 ID 创建内容等。

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 对象提供了一套更新 Astro DB 中内容的函数和实用工具。您可以使用这些函数按 ID 更新内容、按类型更新内容等。

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;
hideDefaultIndex: 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 对象提供了一套从 Astro DB 中删除内容的函数和实用工具。您可以使用这些函数按 ID 删除内容、按类型删除内容等。

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
;

SDK.db 对象提供了一套直接与 Astro DB 交互的函数和实用工具。您可以使用这些函数查询数据库、运行自定义查询等。

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 的更多信息,请查看 Astro DB 指南^

SDK.REST_API 对象提供了一套 REST API 用来与 StudioCMS 和 Astro DB 交互的函数和实用工具。

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 对象提供了一套跟踪 Astro DB 中变更的函数和实用工具。您可以使用这些函数跟踪内容变更、用户变更等。

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
;

StudioCMS SDK 还提供了一套可与 SDK 交互的实用工具函数。这些函数包括:

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, noExpire?: boolean) => string
generateToken
,
const testToken: (token: string) => JwtVerificationResult
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>;
(page: {
...;
}, tree: FolderNode[], metaOnly: boolean): Promise<MetaOnlyPageData>;
}
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 还提供了一个具有部分标准 SDK 功能并在其基础上增加缓存层的缓存版本。您可以使用以下语法导入缓存版 SDK:

import
const SDKCached: {
GET: {
page: {
byId: {
(id: string): Promise<PageDataCacheObject>;
(id: string, metaOnly?: boolean): Promise<MetaOnlyPageDataCacheObject>;
};
bySlug: {
...;
};
};
pages: {
...;
};
folderPages: {
...;
};
siteConfig: () => Promise<SiteConfigCacheObject>;
latestVersion: () => Promise<VersionCacheObject>;
folderTree: () => Promise<FolderTreeCacheObject>;
pageFolderTree: (includeDrafts?: boolean, hideDefaultIndex?: boolean) => Promise<FolderTreeCacheObject>;
folderList: () => Promise<FolderListCacheObject>;
folder: (id: string) => Promise<tsPageFolderSelect | 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;
providerUserId: string;
}[]>;
sessionTable: () => Promise<{
id: string;
userId: string;
expiresAt: Date;
}[ ...
SDKCached
from 'studiocms:sdk/cache';

SDKCached.GET 对象提供了一套带缓存的从 Astro DB 检索内容的函数和实用工具。您可以使用这些函数按 ID 获取内容、按类型获取内容等。

import
const SDKCached: {
GET: {
page: {
byId: {
(id: string): Promise<PageDataCacheObject>;
(id: string, metaOnly?: boolean): Promise<MetaOnlyPageDataCacheObject>;
};
bySlug: {
...;
};
};
pages: {
...;
};
folderPages: {
...;
};
siteConfig: () => Promise<SiteConfigCacheObject>;
latestVersion: () => Promise<VersionCacheObject>;
folderTree: () => Promise<FolderTreeCacheObject>;
pageFolderTree: (includeDrafts?: boolean, hideDefaultIndex?: boolean) => Promise<FolderTreeCacheObject>;
folderList: () => Promise<FolderListCacheObject>;
folder: (id: string) => Promise<tsPageFolderSelect | 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;
providerUserId: string;
}[]>;
sessionTable: () => Promise<{
id: string;
userId: string;
expiresAt: Date;
}[ ...
SDKCached
from 'studiocms:sdk/cache';
const {
const page: {
byId: {
(id: string): Promise<PageDataCacheObject>;
(id: string, metaOnly?: boolean): Promise<MetaOnlyPageDataCacheObject>;
};
bySlug: {
...;
};
}
page
,
const pages: {
(includeDrafts?: boolean, hideDefaultIndex?: boolean, metaOnly?: false, paginate?: PaginateInput): Promise<PageDataCacheObject[]>;
(includeDrafts?: boolean, hideDefaultIndex?: boolean, metaOnly?: true, paginate?: PaginateInput): Promise<MetaOnlyPageDataCacheObject[]>;
}
pages
,
const siteConfig: () => Promise<SiteConfigCacheObject>
siteConfig
,
const latestVersion: () => Promise<VersionCacheObject>
latestVersion
,
const folderTree: () => Promise<FolderTreeCacheObject>
folderTree
,
const pageFolderTree: (includeDrafts?: boolean, hideDefaultIndex?: boolean) => Promise<FolderTreeCacheObject>
pageFolderTree
,
const folderList: () => Promise<FolderListCacheObject>
folderList
,
const folder: (id: string) => Promise<tsPageFolderSelect | undefined>
folder
,
} =
const SDKCached: {
GET: {
page: {
byId: {
(id: string): Promise<PageDataCacheObject>;
(id: string, metaOnly?: boolean): Promise<MetaOnlyPageDataCacheObject>;
};
bySlug: {
...;
};
};
pages: {
...;
};
folderPages: {
...;
};
siteConfig: () => Promise<SiteConfigCacheObject>;
latestVersion: () => Promise<VersionCacheObject>;
folderTree: () => Promise<FolderTreeCacheObject>;
pageFolderTree: (includeDrafts?: boolean, hideDefaultIndex?: boolean) => Promise<FolderTreeCacheObject>;
folderList: () => Promise<FolderListCacheObject>;
folder: (id: string) => Promise<tsPageFolderSelect | 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;
providerUserId: string;
}[]>;
sessionTable: () => Promise<{
id: string;
userId: string;
expiresAt: Date;
}[ ...
SDKCached
.
type GET: {
page: {
byId: {
(id: string): Promise<PageDataCacheObject>;
(id: string, metaOnly?: boolean): Promise<MetaOnlyPageDataCacheObject>;
};
bySlug: {
...;
};
};
... 8 more ...;
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;
providerUserId: string;
}[]>;
sessionTable: () => Promise<{
id: string;
userId: string;
expiresAt: Date;
}[]>;
permissions: () => Promise<{
user: string;
rank: string;
}[]>;
pageData: () => Promise<{
title: string;
description: string;
slug: string;
id: string;
updatedAt: Date | null;
package: string;
showOnNav: boolean;
publishedAt: Date;
contentLang: string;
heroImage: string;
categories: unknown;
tags: unknown;
authorId: string | null;
contributorIds: unknown;
showAuthor: boolean | null;
showContributors ...
GET
;

SDKCached.CLEAR 对象提供了一套用于清除缓存版 SDK 中缓存的函数和实用工具。您可以使用这些函数清除特定内容类型的缓存、清除特定内容 ID 的缓存等。

import
const SDKCached: {
GET: {
page: {
byId: {
(id: string): Promise<PageDataCacheObject>;
(id: string, metaOnly?: boolean): Promise<MetaOnlyPageDataCacheObject>;
};
bySlug: {
...;
};
};
pages: {
...;
};
folderPages: {
...;
};
siteConfig: () => Promise<SiteConfigCacheObject>;
latestVersion: () => Promise<VersionCacheObject>;
folderTree: () => Promise<FolderTreeCacheObject>;
pageFolderTree: (includeDrafts?: boolean, hideDefaultIndex?: boolean) => Promise<FolderTreeCacheObject>;
folderList: () => Promise<FolderListCacheObject>;
folder: (id: string) => Promise<tsPageFolderSelect | 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;
providerUserId: string;
}[]>;
sessionTable: () => Promise<{
id: string;
userId: string;
expiresAt: Date;
}[ ...
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>;
(id: string, metaOnly?: boolean): Promise<MetaOnlyPageDataCacheObject>;
};
bySlug: {
...;
};
};
pages: {
...;
};
folderPages: {
...;
};
siteConfig: () => Promise<SiteConfigCacheObject>;
latestVersion: () => Promise<VersionCacheObject>;
folderTree: () => Promise<FolderTreeCacheObject>;
pageFolderTree: (includeDrafts?: boolean, hideDefaultIndex?: boolean) => Promise<FolderTreeCacheObject>;
folderList: () => Promise<FolderListCacheObject>;
folder: (id: string) => Promise<tsPageFolderSelect | 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;
providerUserId: string;
}[]>;
sessionTable: () => Promise<{
id: string;
userId: string;
expiresAt: Date;
}[ ...
SDKCached
.
type CLEAR: {
page: {
byId: (id: string) => void;
bySlug: (slug: string) => void;
};
pages: () => void;
latestVersion: () => void;
folderTree: () => void;
folderList: () => void;
}
CLEAR
;

SDKCached.UPDATE 对象提供了一套带缓存的更新 Astro DB 中内容的函数和实用工具。您可以使用这些函数按 ID 更新内容、按类型更新内容等。

import
const SDKCached: {
GET: {
page: {
byId: {
(id: string): Promise<PageDataCacheObject>;
(id: string, metaOnly?: boolean): Promise<MetaOnlyPageDataCacheObject>;
};
bySlug: {
...;
};
};
pages: {
...;
};
folderPages: {
...;
};
siteConfig: () => Promise<SiteConfigCacheObject>;
latestVersion: () => Promise<VersionCacheObject>;
folderTree: () => Promise<FolderTreeCacheObject>;
pageFolderTree: (includeDrafts?: boolean, hideDefaultIndex?: boolean) => Promise<FolderTreeCacheObject>;
folderList: () => Promise<FolderListCacheObject>;
folder: (id: string) => Promise<tsPageFolderSelect | 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;
providerUserId: string;
}[]>;
sessionTable: () => Promise<{
id: string;
userId: string;
expiresAt: Date;
}[ ...
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>;
(id: string, metaOnly?: boolean): Promise<MetaOnlyPageDataCacheObject>;
};
bySlug: {
...;
};
};
pages: {
...;
};
folderPages: {
...;
};
siteConfig: () => Promise<SiteConfigCacheObject>;
latestVersion: () => Promise<VersionCacheObject>;
folderTree: () => Promise<FolderTreeCacheObject>;
pageFolderTree: (includeDrafts?: boolean, hideDefaultIndex?: boolean) => Promise<FolderTreeCacheObject>;
folderList: () => Promise<FolderListCacheObject>;
folder: (id: string) => Promise<tsPageFolderSelect | 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;
providerUserId: string;
}[]>;
sessionTable: () => Promise<{
id: string;
userId: string;
expiresAt: Date;
}[ ...
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
;

这是指向标准 SDK db 对象的直接通路。

更多信息请参见 SDK.db