Skip to content

sdk

const studioCMS_SDK: {
addPageToFolderTree: (tree: FolderNode[], folderId: string, newPage: FolderNode) => FolderNode[];
AUTH: {
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
| {
provider: string;
providerUserId: string;
userId: string;
}>;
};
permission: {
currentStatus: (userId: string) => Promise<
| undefined
| {
rank: string;
user: string;
}>;
};
session: {
create: (data: {
expiresAt: Date;
id: string;
userId: string;
}) => Promise<{
expiresAt: Date;
id: string;
userId: string;
}>;
delete: (sessionId: string) => Promise<DeletionResponse>;
sessionWithUser: (sessionId: string) => Promise<{
session: {
expiresAt: Date;
id: string;
userId: string;
};
user: {
avatar: null | string;
createdAt: null | Date;
email: null | string;
id: string;
name: string;
password: null | string;
updatedAt: null | Date;
url: null | string;
username: string;
};
}[]>;
update: (sessionId: string, newDate: Date) => Promise<{
expiresAt: Date;
id: string;
userId: string;
}[]>;
};
user: {
create: (newUserData: {
avatar: null | string;
createdAt: null | Date;
email: null | string;
id: string;
name: string;
password: null | string;
updatedAt: null | Date;
url: null | string;
username: string;
}, rank?: "visitor" | "editor" | "admin" | "owner") => Promise<{
avatar: null | string;
createdAt: null | Date;
email: null | string;
id: string;
name: string;
password: null | string;
updatedAt: null | Date;
url: null | string;
username: string;
}>;
ghost: {
create: () => Promise<any>;
get: () => Promise<any>;
verifyExists: () => Promise<boolean>;
};
searchUsersForUsernameOrEmail: (username: string, email: string) => Promise<{
emailSearch: {
avatar: null | string;
createdAt: null | Date;
email: null | string;
id: string;
name: string;
password: null | string;
updatedAt: null | Date;
url: null | string;
username: string;
}[];
usernameSearch: {
avatar: null | string;
createdAt: null | Date;
email: null | string;
id: string;
name: string;
password: null | string;
updatedAt: null | Date;
url: null | string;
username: string;
}[];
}>;
update: (userId: string, userData: Partial) => Promise<{
avatar: null | string;
createdAt: null | Date;
email: null | string;
id: string;
name: string;
password: null | string;
updatedAt: null | Date;
url: null | string;
username: string;
}>;
};
};
buildFolderTree: () => Promise<FolderNode[]>;
clearUserReferences: (userId: string) => Promise<boolean>;
collectCategories: (categoryIds: number[]) => Promise<{
description: string;
id: number;
meta: unknown;
name: string;
parent: null | number;
slug: string;
}[]>;
collectPageData: (page: {
authorId: null | string;
categories: unknown;
contentLang: string;
contributorIds: unknown;
description: string;
draft: null | boolean;
heroImage: string;
id: string;
package: string;
parentFolder: null | string;
publishedAt: Date;
showAuthor: null | boolean;
showContributors: null | boolean;
showOnNav: boolean;
slug: string;
tags: unknown;
title: string;
updatedAt: null | Date;
}, tree: FolderNode[]) => Promise<CombinedPageData>;
collectTags: (tagIds: number[]) => Promise<{
description: string;
id: number;
meta: unknown;
name: string;
slug: string;
}[]>;
collectUserData: (user: {
avatar: null | string;
createdAt: null | Date;
email: null | string;
id: string;
name: string;
password: null | string;
updatedAt: null | Date;
url: null | string;
username: string;
}) => Promise<CombinedUserData>;
combineRanks: (rank: string, users: SingleRank[]) => CombinedRank[];
db: any;
DELETE: {
categories: (id: number) => Promise<DeletionResponse>;
diffTracking: (id: string) => Promise<DeletionResponse>;
folder: (id: string) => Promise<DeletionResponse>;
page: (id: string) => Promise<DeletionResponse>;
pageContent: (id: string) => Promise<DeletionResponse>;
pageContentLang: (id: string, lang: string) => Promise<DeletionResponse>;
permissions: (userId: string) => Promise<DeletionResponse>;
tags: (id: number) => Promise<DeletionResponse>;
user: (id: string) => Promise<DeletionResponse>;
};
diffTracking: {
clear: (pageId: string) => Promise<void>;
get: {
byPageId: {
all: (pageId: string) => Promise<any>;
latest: (pageId: string, count: number) => Promise<any>;
};
byUserId: {
all: (userId: string) => Promise<any>;
latest: (userId: string, count: number) => Promise<any>;
};
single: (id: string) => Promise<any>;
withHtml: (id: string, options?: any) => Promise<any>;
};
insert: (userId: string, pageId: string, data: {
content: {
end: string;
start: string;
};
metaData: {
end: Partial<{
authorId: null | string;
categories: unknown;
contentLang: string;
contributorIds: unknown;
description: string;
draft: null | boolean;
heroImage: string;
id: string;
package: string;
parentFolder: null | string;
publishedAt: Date;
showAuthor: null | boolean;
showContributors: null | boolean;
showOnNav: boolean;
slug: string;
tags: unknown;
title: string;
updatedAt: null | Date;
}>;
start: Partial<{
authorId: null | string;
categories: unknown;
contentLang: string;
contributorIds: unknown;
description: string;
draft: null | boolean;
heroImage: string;
id: string;
package: string;
parentFolder: null | string;
publishedAt: Date;
showAuthor: null | boolean;
showContributors: null | boolean;
showOnNav: boolean;
slug: string;
tags: unknown;
title: string;
updatedAt: null | Date;
}>;
};
}, diffLength: number) => Promise<any>;
revertToDiff: (id: string, type: "content" | "data" | "both") => Promise<any>;
};
findNodeById: (tree: FolderNode[], id: string) => null | FolderNode;
findNodeByPath: (tree: FolderNode[], path: string[]) => null | FolderNode;
findNodesAlongPath: (tree: FolderNode[], path: string[]) => FolderNode[];
generateRandomIDNumber: (length: number) => number;
generateRandomPassword: (length: number) => string;
generateToken: (userId: string) => string;
GET: {
database: {
config: () => Promise<
| undefined
| {
defaultOgImage: null | string;
description: string;
diffPerPage: number;
enableDiffs: boolean;
gridItems: unknown;
id: number;
loginPageBackground: string;
loginPageCustomImage: null | string;
siteIcon: null | string;
title: string;
}>;
folders: () => Promise<{
id: string;
name: string;
parent: null | string;
}[]>;
pages: (includeDrafts: boolean, tree?: FolderNode[]) => Promise<CombinedPageData[]>;
users: () => Promise<CombinedUserData[]>;
};
databaseEntry: {
folder: (id: string) => Promise<
| undefined
| {
id: string;
name: string;
parent: null | string;
}>;
pages: {
byId: (id: string, tree?: FolderNode[]) => Promise<
| undefined
| CombinedPageData>;
bySlug: (slug: string, tree?: FolderNode[]) => Promise<
| undefined
| CombinedPageData>;
};
users: {
byEmail: (email: string) => Promise<
| undefined
| CombinedUserData>;
byId: (id: string) => Promise<
| undefined
| CombinedUserData>;
byUsername: (username: string) => Promise<
| undefined
| CombinedUserData>;
};
};
databaseTable: {
diffTracking: () => Promise<any>;
oAuthAccounts: () => Promise<any>;
pageContent: () => Promise<any>;
pageData: () => Promise<any>;
pageDataCategories: () => Promise<any>;
pageDataTags: () => Promise<any>;
pageFolderStructure: () => Promise<any>;
permissions: () => Promise<any>;
sessionTable: () => Promise<any>;
siteConfig: () => Promise<any>;
users: () => Promise<any>;
};
packagePages: (packageName: string, tree?: FolderNode[]) => Promise<CombinedPageData[]>;
permissionsLists: {
admins: () => Promise<SingleRank[]>;
all: () => Promise<CombinedRank[]>;
editors: () => Promise<SingleRank[]>;
owners: () => Promise<SingleRank[]>;
visitors: () => Promise<SingleRank[]>;
};
};
getAvailableFolders: () => Promise<FolderListItem[]>;
getFullPath: (tree: FolderNode[], path: string[]) => string[];
INIT: {
ghostUser: () => Promise<{
avatar: null | string;
createdAt: null | Date;
email: null | string;
id: string;
name: string;
password: null | string;
updatedAt: null | Date;
url: null | string;
username: string;
}>;
siteConfig: (config: {
defaultOgImage: null | string;
description: string;
diffPerPage: number;
enableDiffs: boolean;
gridItems: unknown;
id: number;
loginPageBackground: string;
loginPageCustomImage: null | string;
siteIcon: null | string;
title: string;
}) => Promise<{
defaultOgImage: null | string;
description: string;
diffPerPage: number;
enableDiffs: boolean;
gridItems: unknown;
id: number;
loginPageBackground: string;
loginPageCustomImage: null | string;
siteIcon: null | string;
title: string;
}>;
};
parseIdNumberArray: (ids: unknown) => number[];
parseIdStringArray: (ids: unknown) => string[];
POST: {
databaseEntries: {
categories: (data: {
description: string;
id: number;
meta: unknown;
name: string;
parent: null | number;
slug: string;
}[]) => Promise<PageDataCategoriesInsertResponse[]>;
pages: (pages: MultiPageInsert) => Promise<void>;
permissions: (data: {
rank: string;
user: string;
}[]) => Promise<{
rank: string;
user: string;
}[]>;
tags: (data: {
description: string;
id: number;
meta: unknown;
name: string;
slug: string;
}[]) => Promise<PageDataTagsInsertResponse[]>;
};
databaseEntry: {
categories: (category: {
description: string;
id: number;
meta: unknown;
name: string;
parent: null | number;
slug: string;
}) => Promise<any>;
diffTracking: (diff: {
diff: null | string;
id: string;
pageContentStart: string;
pageId: string;
pageMetaData: unknown;
timestamp: null | Date;
userId: string;
}) => Promise<{
diff: null | string;
id: string;
pageContentStart: string;
pageId: string;
pageMetaData: unknown;
timestamp: null | Date;
userId: string;
}[]>;
folder: (folder: {
id: string;
name: string;
parent: null | string;
}) => Promise<{
id: string;
name: string;
parent: null | string;
}[]>;
pageContent: (pageContent: {
content: null | string;
contentId: string;
contentLang: string;
id: string;
}) => Promise<PageContentReturnId[]>;
pages: (pageData: {
authorId: null | string;
categories: unknown;
contentLang: string;
contributorIds: unknown;
description: string;
draft: null | boolean;
heroImage: string;
id: string;
package: string;
parentFolder: null | string;
publishedAt: Date;
showAuthor: null | boolean;
showContributors: null | boolean;
showOnNav: boolean;
slug: string;
tags: unknown;
title: string;
updatedAt: null | Date;
}, pageContent: CombinedInsertContent) => Promise<addDatabaseEntryInsertPage>;
permissions: (userId: string, rank: string) => Promise<{
rank: string;
user: string;
}[]>;
tags: (tag: {
description: string;
id: number;
meta: unknown;
name: string;
slug: string;
}) => Promise<PageDataTagsInsertResponse[]>;
};
};
resetTokenBucket: {
check: (token: string) => Promise<boolean>;
delete: (userId: string) => Promise<void>;
new: (userId: string) => Promise<any>;
};
REST_API: {
tokens: {
delete: (userId: string, tokenId: string) => Promise<void>;
get: (userId: string) => Promise<any>;
new: (userId: string, description: string) => Promise<any>;
verify: (key: string) => Promise<
| false
| {
key: any;
rank: any;
userId: any;
}>;
};
};
testToken: (token: string) => any;
UPDATE: {
categories: (data: {
description: string;
id: number;
meta: unknown;
name: string;
parent: null | number;
slug: string;
}) => Promise<{
description: string;
id: number;
meta: unknown;
name: string;
parent: null | number;
slug: string;
}>;
folder: (data: {
id: string;
name: string;
parent: null | string;
}) => Promise<{
id: string;
name: string;
parent: null | string;
}>;
page: (data: {
authorId: null | string;
categories: unknown;
contentLang: string;
contributorIds: unknown;
description: string;
draft: null | boolean;
heroImage: string;
id: string;
package: string;
parentFolder: null | string;
publishedAt: Date;
showAuthor: null | boolean;
showContributors: null | boolean;
showOnNav: boolean;
slug: string;
tags: unknown;
title: string;
updatedAt: null | Date;
}) => Promise<{
authorId: null | string;
categories: unknown;
contentLang: string;
contributorIds: unknown;
description: string;
draft: null | boolean;
heroImage: string;
id: string;
package: string;
parentFolder: null | string;
publishedAt: Date;
showAuthor: null | boolean;
showContributors: null | boolean;
showOnNav: boolean;
slug: string;
tags: unknown;
title: string;
updatedAt: null | Date;
}>;
pageContent: (data: {
content: null | string;
contentId: string;
contentLang: string;
id: string;
}) => Promise<{
content: null | string;
contentId: string;
contentLang: string;
id: string;
}>;
permissions: (data: {
rank: string;
user: string;
}) => Promise<{
rank: string;
user: string;
}>;
siteConfig: (data: {
defaultOgImage: null | string;
description: string;
diffPerPage: number;
enableDiffs: boolean;
gridItems: unknown;
id: number;
loginPageBackground: string;
loginPageCustomImage: null | string;
siteIcon: null | string;
title: string;
}) => Promise<{
defaultOgImage: null | string;
description: string;
diffPerPage: number;
enableDiffs: boolean;
gridItems: unknown;
id: number;
loginPageBackground: string;
loginPageCustomImage: null | string;
siteIcon: null | string;
title: string;
}>;
tags: (data: {
description: string;
id: number;
meta: unknown;
name: string;
slug: string;
}) => Promise<{
description: string;
id: number;
meta: unknown;
name: string;
slug: string;
}>;
};
verifyRank: (users: {
avatar: null | string;
createdAt: null | Date;
email: null | string;
id: string;
name: string;
password: null | string;
updatedAt: null | Date;
url: null | string;
username: string;
}[], permissions: {
rank: string;
user: string;
}[], rank: string) => SingleRank[];
} = sdkCore;

Defined in: studiocms/packages/studiocms/src/sdk/index.ts:15

The main SDK export for StudioCMS.

This constant provides access to the core functionality of the StudioCMS SDK.

addPageToFolderTree: (tree: FolderNode[], folderId: string, newPage: FolderNode) => FolderNode[];

Adds a new page to the folder tree.

FolderNode[]

The root of the folder tree.

string

The ID of the parent folder.

FolderNode

The new page to add.

FolderNode[]

The updated folder tree

AUTH: {
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
| {
provider: string;
providerUserId: string;
userId: string;
}>;
};
permission: {
currentStatus: (userId: string) => Promise<
| undefined
| {
rank: string;
user: string;
}>;
};
session: {
create: (data: {
expiresAt: Date;
id: string;
userId: string;
}) => Promise<{
expiresAt: Date;
id: string;
userId: string;
}>;
delete: (sessionId: string) => Promise<DeletionResponse>;
sessionWithUser: (sessionId: string) => Promise<{
session: {
expiresAt: Date;
id: string;
userId: string;
};
user: {
avatar: null | string;
createdAt: null | Date;
email: null | string;
id: string;
name: string;
password: null | string;
updatedAt: null | Date;
url: null | string;
username: string;
};
}[]>;
update: (sessionId: string, newDate: Date) => Promise<{
expiresAt: Date;
id: string;
userId: string;
}[]>;
};
user: {
create: (newUserData: {
avatar: null | string;
createdAt: null | Date;
email: null | string;
id: string;
name: string;
password: null | string;
updatedAt: null | Date;
url: null | string;
username: string;
}, rank?: "visitor" | "editor" | "admin" | "owner") => Promise<{
avatar: null | string;
createdAt: null | Date;
email: null | string;
id: string;
name: string;
password: null | string;
updatedAt: null | Date;
url: null | string;
username: string;
}>;
ghost: {
create: () => Promise<any>;
get: () => Promise<any>;
verifyExists: () => Promise<boolean>;
};
searchUsersForUsernameOrEmail: (username: string, email: string) => Promise<{
emailSearch: {
avatar: null | string;
createdAt: null | Date;
email: null | string;
id: string;
name: string;
password: null | string;
updatedAt: null | Date;
url: null | string;
username: string;
}[];
usernameSearch: {
avatar: null | string;
createdAt: null | Date;
email: null | string;
id: string;
name: string;
password: null | string;
updatedAt: null | Date;
url: null | string;
username: string;
}[];
}>;
update: (userId: string, userData: Partial) => Promise<{
avatar: null | string;
createdAt: null | Date;
email: null | string;
id: string;
name: string;
password: null | string;
updatedAt: null | Date;
url: null | string;
username: string;
}>;
};
};

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
| {
provider: string;
providerUserId: string;
userId: string;
}>;
};

Provides various methods to create, delete, and search for OAuth accounts in the StudioCMS database.

create: (data: {
provider: string;
providerUserId: string;
userId: string;
}) => Promise<{
provider: string;
providerUserId: string;
userId: string;
}>;

Creates a new OAuth account in the database.

The data to insert into the OAuth account table.

string

string

string

Promise<{ provider: string; providerUserId: string; userId: string; }>

A promise that resolves to the inserted OAuth account.

If an error occurs while creating the OAuth account.

delete: (userId: string, provider: string) => Promise<DeletionResponse>;

Deletes an OAuth account from the database.

string

The ID of the user associated with the OAuth account.

string

The provider of the OAuth account.

Promise<DeletionResponse>

A promise that resolves to a deletion response.

If an error occurs while deleting the OAuth account.

searchProvidersForId: (providerId: string, userId: string) => Promise<
| undefined
| {
provider: string;
providerUserId: string;
userId: string;
}>;

Searches for OAuth accounts based on the provider ID and user ID.

string

The provider ID to search for.

string

The user ID to search for.

Promise< | undefined | { provider: string; providerUserId: string; userId: string; }>

A promise that resolves to the OAuth account data if found, otherwise undefined.

If an error occurs while searching for the OAuth account.

permission: {
currentStatus: (userId: string) => Promise<
| undefined
| {
rank: string;
user: string;
}>;
};

Provides various methods to get and update permissions for users in the StudioCMS database.

currentStatus: (userId: string) => Promise<
| undefined
| {
rank: string;
user: string;
}>;

Checks the current status of a user’s permissions.

string

Promise< | undefined | { rank: string; user: string; }>

session: {
create: (data: {
expiresAt: Date;
id: string;
userId: string;
}) => Promise<{
expiresAt: Date;
id: string;
userId: string;
}>;
delete: (sessionId: string) => Promise<DeletionResponse>;
sessionWithUser: (sessionId: string) => Promise<{
session: {
expiresAt: Date;
id: string;
userId: string;
};
user: {
avatar: null | string;
createdAt: null | Date;
email: null | string;
id: string;
name: string;
password: null | string;
updatedAt: null | Date;
url: null | string;
username: string;
};
}[]>;
update: (sessionId: string, newDate: Date) => Promise<{
expiresAt: Date;
id: string;
userId: string;
}[]>;
};

Provides various methods to create, delete, and update sessions in the StudioCMS database.

create: (data: {
expiresAt: Date;
id: string;
userId: string;
}) => Promise<{
expiresAt: Date;
id: string;
userId: string;
}>;

Creates a new session in the database.

The data to insert into the session table.

Date

string

string

Promise<{ expiresAt: Date; id: string; userId: string; }>

A promise that resolves to the inserted session.

If an error occurs while creating the session.

delete: (sessionId: string) => Promise<DeletionResponse>;

Deletes a session from the database.

string

The ID of the session to delete.

Promise<DeletionResponse>

A promise that resolves to a deletion response.

If an error occurs while deleting the session.

sessionWithUser: (sessionId: string) => Promise<{
session: {
expiresAt: Date;
id: string;
userId: string;
};
user: {
avatar: null | string;
createdAt: null | Date;
email: null | string;
id: string;
name: string;
password: null | string;
updatedAt: null | Date;
url: null | string;
username: string;
};
}[]>;

Gets a session with the associated user.

string

The ID of the session to search for.

Promise<{ session: { expiresAt: Date; id: string; userId: string; }; user: { avatar: null | string; createdAt: null | Date; email: null | string; id: string; name: string; password: null | string; updatedAt: null | Date; url: null | string; username: string; }; }[]>

A promise that resolves to the session with the associated user.

If an error occurs while getting the session with the user.

update: (sessionId: string, newDate: Date) => Promise<{
expiresAt: Date;
id: string;
userId: string;
}[]>;

Updates the expiration date of a session.

string

The ID of the session to update.

Date

The new expiration date for the session.

Promise<{ expiresAt: Date; id: string; userId: string; }[]>

A promise that resolves to the updated session.

If an error occurs while updating the session.

user: {
create: (newUserData: {
avatar: null | string;
createdAt: null | Date;
email: null | string;
id: string;
name: string;
password: null | string;
updatedAt: null | Date;
url: null | string;
username: string;
}, rank?: "visitor" | "editor" | "admin" | "owner") => Promise<{
avatar: null | string;
createdAt: null | Date;
email: null | string;
id: string;
name: string;
password: null | string;
updatedAt: null | Date;
url: null | string;
username: string;
}>;
ghost: {
create: () => Promise<any>;
get: () => Promise<any>;
verifyExists: () => Promise<boolean>;
};
searchUsersForUsernameOrEmail: (username: string, email: string) => Promise<{
emailSearch: {
avatar: null | string;
createdAt: null | Date;
email: null | string;
id: string;
name: string;
password: null | string;
updatedAt: null | Date;
url: null | string;
username: string;
}[];
usernameSearch: {
avatar: null | string;
createdAt: null | Date;
email: null | string;
id: string;
name: string;
password: null | string;
updatedAt: null | Date;
url: null | string;
username: string;
}[];
}>;
update: (userId: string, userData: Partial) => Promise<{
avatar: null | string;
createdAt: null | Date;
email: null | string;
id: string;
name: string;
password: null | string;
updatedAt: null | Date;
url: null | string;
username: string;
}>;
};

Provides various methods to create, update, and search for users in the StudioCMS database.

create: (newUserData: {
avatar: null | string;
createdAt: null | Date;
email: null | string;
id: string;
name: string;
password: null | string;
updatedAt: null | Date;
url: null | string;
username: string;
}, rank?: "visitor" | "editor" | "admin" | "owner") => Promise<{
avatar: null | string;
createdAt: null | Date;
email: null | string;
id: string;
name: string;
password: null | string;
updatedAt: null | Date;
url: null | string;
username: string;
}>;

Creates a new user in the database.

The data to insert into the users table.

null | string

null | Date

null | string

string

string

null | string

null | Date

null | string

string

"visitor" | "editor" | "admin" | "owner"

Promise<{ avatar: null | string; createdAt: null | Date; email: null | string; id: string; name: string; password: null | string; updatedAt: null | Date; url: null | string; username: string; }>

A promise that resolves to the inserted user.

If an error occurs while creating the user.

ghost: {
create: () => Promise<any>;
get: () => Promise<any>;
verifyExists: () => Promise<boolean>;
};

Ghost user utilities.

create: () => Promise<any>;

Creates the ghost user in the database.

Promise<any>

A promise that resolves to the inserted ghost user.

If an error occurs while creating the ghost user.

get: () => Promise<any>;

Gets the ghost user from the database.

Promise<any>

A promise that resolves to the ghost user.

If an error occurs while getting the ghost user.

verifyExists: () => Promise<boolean>;

Verifies if the ghost user exists in the database.

Promise<boolean>

A promise that resolves to a boolean indicating if the ghost user exists.

If an error occurs while verifying the ghost user.

searchUsersForUsernameOrEmail: (username: string, email: string) => Promise<{
emailSearch: {
avatar: null | string;
createdAt: null | Date;
email: null | string;
id: string;
name: string;
password: null | string;
updatedAt: null | Date;
url: null | string;
username: string;
}[];
usernameSearch: {
avatar: null | string;
createdAt: null | Date;
email: null | string;
id: string;
name: string;
password: null | string;
updatedAt: null | Date;
url: null | string;
username: string;
}[];
}>;

Searches for users based on the provided username or email.

string

The username to search for.

string

The email to search for.

Promise<{ emailSearch: { avatar: null | string; createdAt: null | Date; email: null | string; id: string; name: string; password: null | string; updatedAt: null | Date; url: null | string; username: string; }[]; usernameSearch: { avatar: null | string; createdAt: null | Date; email: null | string; id: string; name: string; password: null | string; updatedAt: null | Date; url: null | string; username: string; }[]; }>

A promise that resolves to an object containing the search results for the username and email.

If an error occurs while searching for the username or email.

update: (userId: string, userData: Partial) => Promise<{
avatar: null | string;
createdAt: null | Date;
email: null | string;
id: string;
name: string;
password: null | string;
updatedAt: null | Date;
url: null | string;
username: string;
}>;

Updates a user in the database.

string

The ID of the user to update.

Partial

The data to update the user with.

Promise<{ avatar: null | string; createdAt: null | Date; email: null | string; id: string; name: string; password: null | string; updatedAt: null | Date; url: null | string; username: string; }>

A promise that resolves to the updated user.

If an error occurs while updating the user.

buildFolderTree: () => Promise<FolderNode[]>;

Gets the folder structure from the database.

Promise<FolderNode[]>

A promise that resolves to an array of folder nodes representing the folder structure.

clearUserReferences: (userId: string) => Promise<boolean>;

string

Promise<boolean>

collectCategories: (categoryIds: number[]) => Promise<{
description: string;
id: number;
meta: unknown;
name: string;
parent: null | number;
slug: string;
}[]>;

Collects categories based on the provided category IDs.

number[]

An array of category IDs to collect.

Promise<{ description: string; id: number; meta: unknown; name: string; parent: null | number; slug: string; }[]>

A promise that resolves to an array of collected categories.

If there is an error while collecting categories.

collectPageData: (page: {
authorId: null | string;
categories: unknown;
contentLang: string;
contributorIds: unknown;
description: string;
draft: null | boolean;
heroImage: string;
id: string;
package: string;
parentFolder: null | string;
publishedAt: Date;
showAuthor: null | boolean;
showContributors: null | boolean;
showOnNav: boolean;
slug: string;
tags: unknown;
title: string;
updatedAt: null | Date;
}, tree: FolderNode[]) => Promise<CombinedPageData>;

Collects and combines various data related to a page.

The page data to collect additional information for.

null | string

unknown

string

unknown

string

null | boolean

string

string

string

null | string

Date

null | boolean

null | boolean

boolean

string

unknown

string

null | Date

FolderNode[]

Promise<CombinedPageData>

A promise that resolves to the combined page data.

If an error occurs while collecting page data.

collectTags: (tagIds: number[]) => Promise<{
description: string;
id: number;
meta: unknown;
name: string;
slug: string;
}[]>;

Collects tags based on the provided tag IDs.

number[]

An array of tag IDs to collect.

Promise<{ description: string; id: number; meta: unknown; name: string; slug: string; }[]>

A promise that resolves to an array of tags.

If an error occurs while fetching the tags.

collectUserData: (user: {
avatar: null | string;
createdAt: null | Date;
email: null | string;
id: string;
name: string;
password: null | string;
updatedAt: null | Date;
url: null | string;
username: string;
}) => Promise<CombinedUserData>;

Collects user data by fetching OAuth data and permission data from the database.

The user object containing user information.

null | string

null | Date

null | string

string

string

null | string

null | Date

null | string

string

Promise<CombinedUserData>

A promise that resolves to a CombinedUserData object containing the user data, OAuth data, and permissions data.

If an error occurs while collecting user data.

combineRanks: (rank: string, users: SingleRank[]) => CombinedRank[];

Combines a given rank with an array of user ranks.

string

The rank to be combined with each user.

SingleRank[]

An array of user ranks to be combined with the given rank.

CombinedRank[]

An array of combined ranks, where each element includes the given rank and the properties of a user rank.

db: any;

DELETE: {
categories: (id: number) => Promise<DeletionResponse>;
diffTracking: (id: string) => Promise<DeletionResponse>;
folder: (id: string) => Promise<DeletionResponse>;
page: (id: string) => Promise<DeletionResponse>;
pageContent: (id: string) => Promise<DeletionResponse>;
pageContentLang: (id: string, lang: string) => Promise<DeletionResponse>;
permissions: (userId: string) => Promise<DeletionResponse>;
tags: (id: number) => Promise<DeletionResponse>;
user: (id: string) => Promise<DeletionResponse>;
};

categories: (id: number) => Promise<DeletionResponse>;

Deletes a category from the database.

number

The ID of the category to delete.

Promise<DeletionResponse>

A promise that resolves to a deletion response.

If an error occurs while deleting the category.

diffTracking: (id: string) => Promise<DeletionResponse>;

Deletes a site configuration from the database.

string

The ID of the site configuration to delete.

Promise<DeletionResponse>

A promise that resolves to a deletion response.

If an error occurs while deleting the site configuration.

folder: (id: string) => Promise<DeletionResponse>;

Deletes a folder from the database.

string

The ID of the folder to delete.

Promise<DeletionResponse>

A promise that resolves to a deletion response.

If an error occurs while deleting the folder.

page: (id: string) => Promise<DeletionResponse>;

Deletes a page from the database.

string

The ID of the page to delete.

Promise<DeletionResponse>

A promise that resolves to a deletion response.

If an error occurs while deleting the page.

pageContent: (id: string) => Promise<DeletionResponse>;

Deletes a page content from the database.

string

The ID of the page content to delete.

Promise<DeletionResponse>

A promise that resolves to a deletion response.

If an error occurs while deleting the page content.

pageContentLang: (id: string, lang: string) => Promise<DeletionResponse>;

Deletes a page content lang from the database.

string

The ID of the page content to delete.

string

The lang of the page content to delete.

Promise<DeletionResponse>

A promise that resolves to a deletion response.

If an error occurs while deleting the page content lang.

permissions: (userId: string) => Promise<DeletionResponse>;

Deletes a permission from the database.

string

The ID of the user to delete the permission for.

Promise<DeletionResponse>

A promise that resolves to a deletion response.

If an error occurs while deleting the permission.

tags: (id: number) => Promise<DeletionResponse>;

Deletes a tag from the database.

number

The ID of the tag to delete.

Promise<DeletionResponse>

A promise that resolves to a deletion response.

If an error occurs while deleting the tag.

user: (id: string) => Promise<DeletionResponse>;

Deletes a user from the database.

string

The ID of the user to delete.

Promise<DeletionResponse>

A promise that resolves to a deletion response.

If an error occurs while deleting the user.

diffTracking: {
clear: (pageId: string) => Promise<void>;
get: {
byPageId: {
all: (pageId: string) => Promise<any>;
latest: (pageId: string, count: number) => Promise<any>;
};
byUserId: {
all: (userId: string) => Promise<any>;
latest: (userId: string, count: number) => Promise<any>;
};
single: (id: string) => Promise<any>;
withHtml: (id: string, options?: any) => Promise<any>;
};
insert: (userId: string, pageId: string, data: {
content: {
end: string;
start: string;
};
metaData: {
end: Partial<{
authorId: null | string;
categories: unknown;
contentLang: string;
contributorIds: unknown;
description: string;
draft: null | boolean;
heroImage: string;
id: string;
package: string;
parentFolder: null | string;
publishedAt: Date;
showAuthor: null | boolean;
showContributors: null | boolean;
showOnNav: boolean;
slug: string;
tags: unknown;
title: string;
updatedAt: null | Date;
}>;
start: Partial<{
authorId: null | string;
categories: unknown;
contentLang: string;
contributorIds: unknown;
description: string;
draft: null | boolean;
heroImage: string;
id: string;
package: string;
parentFolder: null | string;
publishedAt: Date;
showAuthor: null | boolean;
showContributors: null | boolean;
showOnNav: boolean;
slug: string;
tags: unknown;
title: string;
updatedAt: null | Date;
}>;
};
}, diffLength: number) => Promise<any>;
revertToDiff: (id: string, type: "content" | "data" | "both") => Promise<any>;
};

clear: (pageId: string) => Promise<void>;

string

Promise<void>

get: {
byPageId: {
all: (pageId: string) => Promise<any>;
latest: (pageId: string, count: number) => Promise<any>;
};
byUserId: {
all: (userId: string) => Promise<any>;
latest: (userId: string, count: number) => Promise<any>;
};
single: (id: string) => Promise<any>;
withHtml: (id: string, options?: any) => Promise<any>;
};

byPageId: {
all: (pageId: string) => Promise<any>;
latest: (pageId: string, count: number) => Promise<any>;
};

all: (pageId: string) => Promise<any>;

string

Promise<any>

latest: (pageId: string, count: number) => Promise<any>;

string

number

Promise<any>

byUserId: {
all: (userId: string) => Promise<any>;
latest: (userId: string, count: number) => Promise<any>;
};

all: (userId: string) => Promise<any>;

string

Promise<any>

latest: (userId: string, count: number) => Promise<any>;

string

number

Promise<any>

single: (id: string) => Promise<any>;

string

Promise<any>

withHtml: (id: string, options?: any) => Promise<any>;

string

any

Promise<any>

insert: (userId: string, pageId: string, data: {
content: {
end: string;
start: string;
};
metaData: {
end: Partial<{
authorId: null | string;
categories: unknown;
contentLang: string;
contributorIds: unknown;
description: string;
draft: null | boolean;
heroImage: string;
id: string;
package: string;
parentFolder: null | string;
publishedAt: Date;
showAuthor: null | boolean;
showContributors: null | boolean;
showOnNav: boolean;
slug: string;
tags: unknown;
title: string;
updatedAt: null | Date;
}>;
start: Partial<{
authorId: null | string;
categories: unknown;
contentLang: string;
contributorIds: unknown;
description: string;
draft: null | boolean;
heroImage: string;
id: string;
package: string;
parentFolder: null | string;
publishedAt: Date;
showAuthor: null | boolean;
showContributors: null | boolean;
showOnNav: boolean;
slug: string;
tags: unknown;
title: string;
updatedAt: null | Date;
}>;
};
}, diffLength: number) => Promise<any>;

string

string

{ end: string; start: string; }

string

string

{ end: Partial<{ authorId: null | string; categories: unknown; contentLang: string; contributorIds: unknown; description: string; draft: null | boolean; heroImage: string; id: string; package: string; parentFolder: null | string; publishedAt: Date; showAuthor: null | boolean; showContributors: null | boolean; showOnNav: boolean; slug: string; tags: unknown; title: string; updatedAt: null | Date; }>; start: Partial<{ authorId: null | string; categories: unknown; contentLang: string; contributorIds: unknown; description: string; draft: null | boolean; heroImage: string; id: string; package: string; parentFolder: null | string; publishedAt: Date; showAuthor: null | boolean; showContributors: null | boolean; showOnNav: boolean; slug: string; tags: unknown; title: string; updatedAt: null | Date; }>; }

Partial<{ authorId: null | string; categories: unknown; contentLang: string; contributorIds: unknown; description: string; draft: null | boolean; heroImage: string; id: string; package: string; parentFolder: null | string; publishedAt: Date; showAuthor: null | boolean; showContributors: null | boolean; showOnNav: boolean; slug: string; tags: unknown; title: string; updatedAt: null | Date; }>

Partial<{ authorId: null | string; categories: unknown; contentLang: string; contributorIds: unknown; description: string; draft: null | boolean; heroImage: string; id: string; package: string; parentFolder: null | string; publishedAt: Date; showAuthor: null | boolean; showContributors: null | boolean; showOnNav: boolean; slug: string; tags: unknown; title: string; updatedAt: null | Date; }>

number

Promise<any>

revertToDiff: (id: string, type: "content" | "data" | "both") => Promise<any>;

string

"content" | "data" | "both"

Promise<any>

findNodeById: (tree: FolderNode[], id: string) => null | FolderNode;

Finds a node by its ID in the tree.

FolderNode[]

string

The ID of the node to find.

null | FolderNode

The node or null if not found.

findNodeByPath: (tree: FolderNode[], path: string[]) => null | FolderNode;

Finds a node in the tree that matches the given URL path.

FolderNode[]

The root of the folder tree.

string[]

The URL path to locate.

null | FolderNode

The matching node or null if not found.

findNodesAlongPath: (tree: FolderNode[], path: string[]) => FolderNode[];

Finds all nodes along the path to a given URL.

FolderNode[]

The root of the folder tree.

string[]

The URL path to locate.

FolderNode[]

The nodes along the path.

generateRandomIDNumber: (length: number) => number;

Generates a random ID number with the specified length.

number

The length of the random ID number to generate.

number

A random ID number with the specified length.

generateRandomPassword: (length: number) => string;

Generates a random password of the specified length.

number

The length of the password to generate.

string

A randomly generated password string containing uppercase letters, lowercase letters, and digits.

generateToken: (userId: string) => string;

Generates a JSON Web Token (JWT) for a given user ID.

string

The unique identifier of the user for whom the token is being generated.

string

A signed JWT string that expires in 3 hours.

GET: {
database: {
config: () => Promise<
| undefined
| {
defaultOgImage: null | string;
description: string;
diffPerPage: number;
enableDiffs: boolean;
gridItems: unknown;
id: number;
loginPageBackground: string;
loginPageCustomImage: null | string;
siteIcon: null | string;
title: string;
}>;
folders: () => Promise<{
id: string;
name: string;
parent: null | string;
}[]>;
pages: (includeDrafts: boolean, tree?: FolderNode[]) => Promise<CombinedPageData[]>;
users: () => Promise<CombinedUserData[]>;
};
databaseEntry: {
folder: (id: string) => Promise<
| undefined
| {
id: string;
name: string;
parent: null | string;
}>;
pages: {
byId: (id: string, tree?: FolderNode[]) => Promise<
| undefined
| CombinedPageData>;
bySlug: (slug: string, tree?: FolderNode[]) => Promise<
| undefined
| CombinedPageData>;
};
users: {
byEmail: (email: string) => Promise<
| undefined
| CombinedUserData>;
byId: (id: string) => Promise<
| undefined
| CombinedUserData>;
byUsername: (username: string) => Promise<
| undefined
| CombinedUserData>;
};
};
databaseTable: {
diffTracking: () => Promise<any>;
oAuthAccounts: () => Promise<any>;
pageContent: () => Promise<any>;
pageData: () => Promise<any>;
pageDataCategories: () => Promise<any>;
pageDataTags: () => Promise<any>;
pageFolderStructure: () => Promise<any>;
permissions: () => Promise<any>;
sessionTable: () => Promise<any>;
siteConfig: () => Promise<any>;
users: () => Promise<any>;
};
packagePages: (packageName: string, tree?: FolderNode[]) => Promise<CombinedPageData[]>;
permissionsLists: {
admins: () => Promise<SingleRank[]>;
all: () => Promise<CombinedRank[]>;
editors: () => Promise<SingleRank[]>;
owners: () => Promise<SingleRank[]>;
visitors: () => Promise<SingleRank[]>;
};
};

database: {
config: () => Promise<
| undefined
| {
defaultOgImage: null | string;
description: string;
diffPerPage: number;
enableDiffs: boolean;
gridItems: unknown;
id: number;
loginPageBackground: string;
loginPageCustomImage: null | string;
siteIcon: null | string;
title: string;
}>;
folders: () => Promise<{
id: string;
name: string;
parent: null | string;
}[]>;
pages: (includeDrafts: boolean, tree?: FolderNode[]) => Promise<CombinedPageData[]>;
users: () => Promise<CombinedUserData[]>;
};

Retrieves data from the database

config: () => Promise<
| undefined
| {
defaultOgImage: null | string;
description: string;
diffPerPage: number;
enableDiffs: boolean;
gridItems: unknown;
id: number;
loginPageBackground: string;
loginPageCustomImage: null | string;
siteIcon: null | string;
title: string;
}>;

Retrieves the site configuration from the database.

Promise< | undefined | { defaultOgImage: null | string; description: string; diffPerPage: number; enableDiffs: boolean; gridItems: unknown; id: number; loginPageBackground: string; loginPageCustomImage: null | string; siteIcon: null | string; title: string; }>

A promise that resolves to the site configuration.

If an error occurs while getting the site configuration.

folders: () => Promise<{
id: string;
name: string;
parent: null | string;
}[]>;

Promise<{ id: string; name: string; parent: null | string; }[]>

pages: (includeDrafts: boolean, tree?: FolderNode[]) => Promise<CombinedPageData[]>;

Retrieves all pages from the database.

boolean = false

FolderNode[]

Promise<CombinedPageData[]>

A promise that resolves to an array of combined page data.

If an error occurs while getting the pages.

users: () => Promise<CombinedUserData[]>;

Retrieves all users from the database.

Promise<CombinedUserData[]>

A promise that resolves to an array of combined user data.

If an error occurs while getting the users.

databaseEntry: {
folder: (id: string) => Promise<
| undefined
| {
id: string;
name: string;
parent: null | string;
}>;
pages: {
byId: (id: string, tree?: FolderNode[]) => Promise<
| undefined
| CombinedPageData>;
bySlug: (slug: string, tree?: FolderNode[]) => Promise<
| undefined
| CombinedPageData>;
};
users: {
byEmail: (email: string) => Promise<
| undefined
| CombinedUserData>;
byId: (id: string) => Promise<
| undefined
| CombinedUserData>;
byUsername: (username: string) => Promise<
| undefined
| CombinedUserData>;
};
};

Retrieves data from the database by ID.

folder: (id: string) => Promise<
| undefined
| {
id: string;
name: string;
parent: null | string;
}>;

string

Promise< | undefined | { id: string; name: string; parent: null | string; }>

pages: {
byId: (id: string, tree?: FolderNode[]) => Promise<
| undefined
| CombinedPageData>;
bySlug: (slug: string, tree?: FolderNode[]) => Promise<
| undefined
| CombinedPageData>;
};

Retrieves a page from the database

byId: (id: string, tree?: FolderNode[]) => Promise<
| undefined
| CombinedPageData>;

Retrieves a page by ID.

string

The ID of the page to retrieve.

FolderNode[]

Promise< | undefined | CombinedPageData>

A promise that resolves to the page data.

If an error occurs while getting the page.

bySlug: (slug: string, tree?: FolderNode[]) => Promise<
| undefined
| CombinedPageData>;

Retrieves a page by slug.

string

The slug of the page to retrieve.

FolderNode[]

Promise< | undefined | CombinedPageData>

A promise that resolves to the page data.

If an error occurs while getting the page.

users: {
byEmail: (email: string) => Promise<
| undefined
| CombinedUserData>;
byId: (id: string) => Promise<
| undefined
| CombinedUserData>;
byUsername: (username: string) => Promise<
| undefined
| CombinedUserData>;
};

Retrieves a user from the database

byEmail: (email: string) => Promise<
| undefined
| CombinedUserData>;

Retrieves a user by email.

string

The email of the user to retrieve.

Promise< | undefined | CombinedUserData>

A promise that resolves to the user data.

If an error occurs while getting the user.

byId: (id: string) => Promise<
| undefined
| CombinedUserData>;

Retrieves a user by ID.

string

The ID of the user to retrieve.

Promise< | undefined | CombinedUserData>

A promise that resolves to the user data.

If an error occurs while getting the user.

byUsername: (username: string) => Promise<
| undefined
| CombinedUserData>;

Retrieves a user by username.

string

The username of the user to retrieve.

Promise< | undefined | CombinedUserData>

A promise that resolves to the user data.

If an error occurs while getting the user.

databaseTable: {
diffTracking: () => Promise<any>;
oAuthAccounts: () => Promise<any>;
pageContent: () => Promise<any>;
pageData: () => Promise<any>;
pageDataCategories: () => Promise<any>;
pageDataTags: () => Promise<any>;
pageFolderStructure: () => Promise<any>;
permissions: () => Promise<any>;
sessionTable: () => Promise<any>;
siteConfig: () => Promise<any>;
users: () => Promise<any>;
};

Retrieves data from the database tables without any additional processing.

diffTracking: () => Promise<any>;

Retrieves all data from the diff tracking table.

Promise<any>

A promise that resolves to an array of diff tracking data.

If an error occurs while getting the diff tracking data.

oAuthAccounts: () => Promise<any>;

Retrieves all data from the OAuth accounts table.

Promise<any>

A promise that resolves to an array of OAuth account data.

If an error occurs while getting the OAuth accounts.

pageContent: () => Promise<any>;

Retrieves all data from the page content table.

Promise<any>

A promise that resolves to an array of page content.

If an error occurs while getting the page content.

pageData: () => Promise<any>;

Retrieves all data from the page data table.

Promise<any>

A promise that resolves to an array of page data.

If an error occurs while getting the pages.

pageDataCategories: () => Promise<any>;

Retrieves all data from the page data categories table.

Promise<any>

A promise that resolves to an array of page data categories.

If an error occurs while getting the page data categories.

pageDataTags: () => Promise<any>;

Retrieves all data from the page data tags table.

Promise<any>

A promise that resolves to an array of page data tags.

If an error occurs while getting the page data tags.

pageFolderStructure: () => Promise<any>;

Retrieves all data from the page folder structure table.

Promise<any>

A promise that resolves to an array of page folder structure data.

If an error occurs while getting the page folder structure data.

permissions: () => Promise<any>;

Retrieves all data from the permissions table.

Promise<any>

A promise that resolves to an array of permission data.

If an error occurs while getting the permissions.

sessionTable: () => Promise<any>;

Retrieves all data from the session table.

Promise<any>

A promise that resolves to an array of session data.

If an error occurs while getting the sessions.

siteConfig: () => Promise<any>;

Retrieves all data from the site config table.

Promise<any>

A promise that resolves to an array of site configuration data.

If an error occurs while getting the site configuration.

users: () => Promise<any>;

Retrieves all data from the users table.

Promise<any>

A promise that resolves to an array of user data.

If an error occurs while getting the users.

packagePages: (packageName: string, tree?: FolderNode[]) => Promise<CombinedPageData[]>;

Retrieves data from the database by package.

string

FolderNode[]

Promise<CombinedPageData[]>

permissionsLists: {
admins: () => Promise<SingleRank[]>;
all: () => Promise<CombinedRank[]>;
editors: () => Promise<SingleRank[]>;
owners: () => Promise<SingleRank[]>;
visitors: () => Promise<SingleRank[]>;
};

Retrieve Permission Lists

admins: () => Promise<SingleRank[]>;

Retrieves all admins in the database.

Promise<SingleRank[]>

A promise that resolves to an array of combined rank data.

If an error occurs while getting the admins.

all: () => Promise<CombinedRank[]>;

Retrieves all permissions for users in the database.

Promise<CombinedRank[]>

A promise that resolves to an array of combined rank data.

If an error occurs while getting the permissions.

editors: () => Promise<SingleRank[]>;

Retrieves all editors in the database.

Promise<SingleRank[]>

A promise that resolves to an array of combined rank data.

If an error occurs while getting the editors.

owners: () => Promise<SingleRank[]>;

Retrieves all owners in the database.

Promise<SingleRank[]>

A promise that resolves to an array of combined rank data.

If an error occurs while getting the owners.

visitors: () => Promise<SingleRank[]>;

Retrieves all visitors in the database.

Promise<SingleRank[]>

A promise that resolves to an array of combined rank data.

If an error occurs while getting the visitors.

getAvailableFolders: () => Promise<FolderListItem[]>;

Gets the available folders from the database.

Promise<FolderListItem[]>

A promise that resolves to an array of folder list items.

getFullPath: (tree: FolderNode[], path: string[]) => string[];

Finds the full path to a node based on its URL.

FolderNode[]

The root of the folder tree.

string[]

The URL path to locate.

string[]

The full path as an array of node names.

INIT: {
ghostUser: () => Promise<{
avatar: null | string;
createdAt: null | Date;
email: null | string;
id: string;
name: string;
password: null | string;
updatedAt: null | Date;
url: null | string;
username: string;
}>;
siteConfig: (config: {
defaultOgImage: null | string;
description: string;
diffPerPage: number;
enableDiffs: boolean;
gridItems: unknown;
id: number;
loginPageBackground: string;
loginPageCustomImage: null | string;
siteIcon: null | string;
title: string;
}) => Promise<{
defaultOgImage: null | string;
description: string;
diffPerPage: number;
enableDiffs: boolean;
gridItems: unknown;
id: number;
loginPageBackground: string;
loginPageCustomImage: null | string;
siteIcon: null | string;
title: string;
}>;
};

ghostUser: () => Promise<{
avatar: null | string;
createdAt: null | Date;
email: null | string;
id: string;
name: string;
password: null | string;
updatedAt: null | Date;
url: null | string;
username: string;
}>;

Initializes the StudioCMS Ghost User.

The ghost user is a default user that is used to perform actions on behalf of the system as well as to replace deleted users.

Promise<{ avatar: null | string; createdAt: null | Date; email: null | string; id: string; name: string; password: null | string; updatedAt: null | Date; url: null | string; username: string; }>

A promise that resolves to the ghost user record.

If an error occurs while creating the ghost user.

siteConfig: (config: {
defaultOgImage: null | string;
description: string;
diffPerPage: number;
enableDiffs: boolean;
gridItems: unknown;
id: number;
loginPageBackground: string;
loginPageCustomImage: null | string;
siteIcon: null | string;
title: string;
}) => Promise<{
defaultOgImage: null | string;
description: string;
diffPerPage: number;
enableDiffs: boolean;
gridItems: unknown;
id: number;
loginPageBackground: string;
loginPageCustomImage: null | string;
siteIcon: null | string;
title: string;
}>;

Initializes the StudioCMS SiteConfig table with the provided configuration.

The configuration to insert into the SiteConfig table.

null | string

string

number

boolean

unknown

number

string

null | string

null | string

string

Promise<{ defaultOgImage: null | string; description: string; diffPerPage: number; enableDiffs: boolean; gridItems: unknown; id: number; loginPageBackground: string; loginPageCustomImage: null | string; siteIcon: null | string; title: string; }>

A promise that resolves to the inserted site configuration.

If an error occurs while creating the site configuration.

parseIdNumberArray: (ids: unknown) => number[];

Parses an unknown input and casts it to an array of numbers.

unknown

The input to be parsed, expected to be an array of numbers.

number[]

An array of numbers.

parseIdStringArray: (ids: unknown) => string[];

Parses the given input as an array of strings.

unknown

The input to be parsed, expected to be an array of unknown type.

string[]

An array of strings parsed from the input.

POST: {
databaseEntries: {
categories: (data: {
description: string;
id: number;
meta: unknown;
name: string;
parent: null | number;
slug: string;
}[]) => Promise<PageDataCategoriesInsertResponse[]>;
pages: (pages: MultiPageInsert) => Promise<void>;
permissions: (data: {
rank: string;
user: string;
}[]) => Promise<{
rank: string;
user: string;
}[]>;
tags: (data: {
description: string;
id: number;
meta: unknown;
name: string;
slug: string;
}[]) => Promise<PageDataTagsInsertResponse[]>;
};
databaseEntry: {
categories: (category: {
description: string;
id: number;
meta: unknown;
name: string;
parent: null | number;
slug: string;
}) => Promise<any>;
diffTracking: (diff: {
diff: null | string;
id: string;
pageContentStart: string;
pageId: string;
pageMetaData: unknown;
timestamp: null | Date;
userId: string;
}) => Promise<{
diff: null | string;
id: string;
pageContentStart: string;
pageId: string;
pageMetaData: unknown;
timestamp: null | Date;
userId: string;
}[]>;
folder: (folder: {
id: string;
name: string;
parent: null | string;
}) => Promise<{
id: string;
name: string;
parent: null | string;
}[]>;
pageContent: (pageContent: {
content: null | string;
contentId: string;
contentLang: string;
id: string;
}) => Promise<PageContentReturnId[]>;
pages: (pageData: {
authorId: null | string;
categories: unknown;
contentLang: string;
contributorIds: unknown;
description: string;
draft: null | boolean;
heroImage: string;
id: string;
package: string;
parentFolder: null | string;
publishedAt: Date;
showAuthor: null | boolean;
showContributors: null | boolean;
showOnNav: boolean;
slug: string;
tags: unknown;
title: string;
updatedAt: null | Date;
}, pageContent: CombinedInsertContent) => Promise<addDatabaseEntryInsertPage>;
permissions: (userId: string, rank: string) => Promise<{
rank: string;
user: string;
}[]>;
tags: (tag: {
description: string;
id: number;
meta: unknown;
name: string;
slug: string;
}) => Promise<PageDataTagsInsertResponse[]>;
};
};

databaseEntries: {
categories: (data: {
description: string;
id: number;
meta: unknown;
name: string;
parent: null | number;
slug: string;
}[]) => Promise<PageDataCategoriesInsertResponse[]>;
pages: (pages: MultiPageInsert) => Promise<void>;
permissions: (data: {
rank: string;
user: string;
}[]) => Promise<{
rank: string;
user: string;
}[]>;
tags: (data: {
description: string;
id: number;
meta: unknown;
name: string;
slug: string;
}[]) => Promise<PageDataTagsInsertResponse[]>;
};

Inserts data into the database by Array of Entries

categories: (data: {
description: string;
id: number;
meta: unknown;
name: string;
parent: null | number;
slug: string;
}[]) => Promise<PageDataCategoriesInsertResponse[]>;

Inserts multiple categories into the database.

{ description: string; id: number; meta: unknown; name: string; parent: null | number; slug: string; }[]

The data to insert into the page data categories table.

Promise<PageDataCategoriesInsertResponse[]>

A promise that resolves to the inserted categories.

If an error occurs while inserting the categories.

pages: (pages: MultiPageInsert) => Promise<void>;

Inserts multiple pages into the database.

MultiPageInsert

The data to insert into the page data and page content tables.

Promise<void>

A promise that resolves to the inserted pages.

If an error occurs while inserting the pages.

permissions: (data: {
rank: string;
user: string;
}[]) => Promise<{
rank: string;
user: string;
}[]>;

Inserts multiple permissions into the database.

{ rank: string; user: string; }[]

The data to insert into the permissions table.

Promise<{ rank: string; user: string; }[]>

A promise that resolves to the inserted permissions.

If an error occurs while inserting the permissions.

tags: (data: {
description: string;
id: number;
meta: unknown;
name: string;
slug: string;
}[]) => Promise<PageDataTagsInsertResponse[]>;

Inserts multiple tags into the database.

{ description: string; id: number; meta: unknown; name: string; slug: string; }[]

The data to insert into the page data tags table.

Promise<PageDataTagsInsertResponse[]>

A promise that resolves to the inserted tags.

If an error occurs while inserting the tags.

databaseEntry: {
categories: (category: {
description: string;
id: number;
meta: unknown;
name: string;
parent: null | number;
slug: string;
}) => Promise<any>;
diffTracking: (diff: {
diff: null | string;
id: string;
pageContentStart: string;
pageId: string;
pageMetaData: unknown;
timestamp: null | Date;
userId: string;
}) => Promise<{
diff: null | string;
id: string;
pageContentStart: string;
pageId: string;
pageMetaData: unknown;
timestamp: null | Date;
userId: string;
}[]>;
folder: (folder: {
id: string;
name: string;
parent: null | string;
}) => Promise<{
id: string;
name: string;
parent: null | string;
}[]>;
pageContent: (pageContent: {
content: null | string;
contentId: string;
contentLang: string;
id: string;
}) => Promise<PageContentReturnId[]>;
pages: (pageData: {
authorId: null | string;
categories: unknown;
contentLang: string;
contributorIds: unknown;
description: string;
draft: null | boolean;
heroImage: string;
id: string;
package: string;
parentFolder: null | string;
publishedAt: Date;
showAuthor: null | boolean;
showContributors: null | boolean;
showOnNav: boolean;
slug: string;
tags: unknown;
title: string;
updatedAt: null | Date;
}, pageContent: CombinedInsertContent) => Promise<addDatabaseEntryInsertPage>;
permissions: (userId: string, rank: string) => Promise<{
rank: string;
user: string;
}[]>;
tags: (tag: {
description: string;
id: number;
meta: unknown;
name: string;
slug: string;
}) => Promise<PageDataTagsInsertResponse[]>;
};

Inserts data into the database by Entry

categories: (category: {
description: string;
id: number;
meta: unknown;
name: string;
parent: null | number;
slug: string;
}) => Promise<any>;

Inserts a new category into the database.

The data to insert into the page data categories table.

string

number

unknown

string

null | number

string

Promise<any>

A promise that resolves to the inserted category.

If an error occurs while inserting the category.

diffTracking: (diff: {
diff: null | string;
id: string;
pageContentStart: string;
pageId: string;
pageMetaData: unknown;
timestamp: null | Date;
userId: string;
}) => Promise<{
diff: null | string;
id: string;
pageContentStart: string;
pageId: string;
pageMetaData: unknown;
timestamp: null | Date;
userId: string;
}[]>;

Inserts a new diff tracking entry into the database.

The data to insert into the diff tracking table.

null | string

string

string

string

unknown

null | Date

string

Promise<{ diff: null | string; id: string; pageContentStart: string; pageId: string; pageMetaData: unknown; timestamp: null | Date; userId: string; }[]>

A promise that resolves to the inserted diff tracking entry.

If an error occurs while inserting the diff tracking entry.

folder: (folder: {
id: string;
name: string;
parent: null | string;
}) => Promise<{
id: string;
name: string;
parent: null | string;
}[]>;

Inserts a new folder into the database.

The data to insert into the page folder structure table.

string

string

null | string

Promise<{ id: string; name: string; parent: null | string; }[]>

A promise that resolves to the inserted folder.

If an error occurs while inserting the folder.

pageContent: (pageContent: {
content: null | string;
contentId: string;
contentLang: string;
id: string;
}) => Promise<PageContentReturnId[]>;

Inserts new page content into the database.

The data to insert into the page content table.

null | string

string

string

string

Promise<PageContentReturnId[]>

A promise that resolves to the inserted page content.

If an error occurs while inserting the page content.

pages: (pageData: {
authorId: null | string;
categories: unknown;
contentLang: string;
contributorIds: unknown;
description: string;
draft: null | boolean;
heroImage: string;
id: string;
package: string;
parentFolder: null | string;
publishedAt: Date;
showAuthor: null | boolean;
showContributors: null | boolean;
showOnNav: boolean;
slug: string;
tags: unknown;
title: string;
updatedAt: null | Date;
}, pageContent: CombinedInsertContent) => Promise<addDatabaseEntryInsertPage>;

Insert a new page into the database.

The data to insert into the page data table.

null | string

unknown

string

unknown

string

null | boolean

string

string

string

null | string

Date

null | boolean

null | boolean

boolean

string

unknown

string

null | Date

CombinedInsertContent

The data to insert into the page content table.

Promise<addDatabaseEntryInsertPage>

A promise that resolves to the inserted page data and page content.

If an error occurs while inserting the page.

permissions: (userId: string, rank: string) => Promise<{
rank: string;
user: string;
}[]>;

Inserts a new permission into the database.

string

The ID of the user to assign the rank to.

string

The rank to assign to the user.

Promise<{ rank: string; user: string; }[]>

A promise that resolves to the inserted permission.

If an error occurs while inserting the permission.

tags: (tag: {
description: string;
id: number;
meta: unknown;
name: string;
slug: string;
}) => Promise<PageDataTagsInsertResponse[]>;

Inserts a new tag into the database.

The data to insert into the page data tags table.

string

number

unknown

string

string

Promise<PageDataTagsInsertResponse[]>

A promise that resolves to the inserted tag.

If an error occurs while inserting the tag.

resetTokenBucket: {
check: (token: string) => Promise<boolean>;
delete: (userId: string) => Promise<void>;
new: (userId: string) => Promise<any>;
};

check: (token: string) => Promise<boolean>;

string

Promise<boolean>

delete: (userId: string) => Promise<void>;

string

Promise<void>

new: (userId: string) => Promise<any>;

string

Promise<any>

REST_API: {
tokens: {
delete: (userId: string, tokenId: string) => Promise<void>;
get: (userId: string) => Promise<any>;
new: (userId: string, description: string) => Promise<any>;
verify: (key: string) => Promise<
| false
| {
key: any;
rank: any;
userId: any;
}>;
};
};

tokens: {
delete: (userId: string, tokenId: string) => Promise<void>;
get: (userId: string) => Promise<any>;
new: (userId: string, description: string) => Promise<any>;
verify: (key: string) => Promise<
| false
| {
key: any;
rank: any;
userId: any;
}>;
};

delete: (userId: string, tokenId: string) => Promise<void>;

string

string

Promise<void>

get: (userId: string) => Promise<any>;

string

Promise<any>

new: (userId: string, description: string) => Promise<any>;

string

string

Promise<any>

verify: (key: string) => Promise<
| false
| {
key: any;
rank: any;
userId: any;
}>;

string

Promise< | false | { key: any; rank: any; userId: any; }>

testToken: (token: string) => any;

Verifies the provided JWT token using the CMS encryption key.

string

The JWT token to be verified.

any

The decoded token if verification is successful.

Will throw an error if the token is invalid or verification fails.

UPDATE: {
categories: (data: {
description: string;
id: number;
meta: unknown;
name: string;
parent: null | number;
slug: string;
}) => Promise<{
description: string;
id: number;
meta: unknown;
name: string;
parent: null | number;
slug: string;
}>;
folder: (data: {
id: string;
name: string;
parent: null | string;
}) => Promise<{
id: string;
name: string;
parent: null | string;
}>;
page: (data: {
authorId: null | string;
categories: unknown;
contentLang: string;
contributorIds: unknown;
description: string;
draft: null | boolean;
heroImage: string;
id: string;
package: string;
parentFolder: null | string;
publishedAt: Date;
showAuthor: null | boolean;
showContributors: null | boolean;
showOnNav: boolean;
slug: string;
tags: unknown;
title: string;
updatedAt: null | Date;
}) => Promise<{
authorId: null | string;
categories: unknown;
contentLang: string;
contributorIds: unknown;
description: string;
draft: null | boolean;
heroImage: string;
id: string;
package: string;
parentFolder: null | string;
publishedAt: Date;
showAuthor: null | boolean;
showContributors: null | boolean;
showOnNav: boolean;
slug: string;
tags: unknown;
title: string;
updatedAt: null | Date;
}>;
pageContent: (data: {
content: null | string;
contentId: string;
contentLang: string;
id: string;
}) => Promise<{
content: null | string;
contentId: string;
contentLang: string;
id: string;
}>;
permissions: (data: {
rank: string;
user: string;
}) => Promise<{
rank: string;
user: string;
}>;
siteConfig: (data: {
defaultOgImage: null | string;
description: string;
diffPerPage: number;
enableDiffs: boolean;
gridItems: unknown;
id: number;
loginPageBackground: string;
loginPageCustomImage: null | string;
siteIcon: null | string;
title: string;
}) => Promise<{
defaultOgImage: null | string;
description: string;
diffPerPage: number;
enableDiffs: boolean;
gridItems: unknown;
id: number;
loginPageBackground: string;
loginPageCustomImage: null | string;
siteIcon: null | string;
title: string;
}>;
tags: (data: {
description: string;
id: number;
meta: unknown;
name: string;
slug: string;
}) => Promise<{
description: string;
id: number;
meta: unknown;
name: string;
slug: string;
}>;
};

categories: (data: {
description: string;
id: number;
meta: unknown;
name: string;
parent: null | number;
slug: string;
}) => Promise<{
description: string;
id: number;
meta: unknown;
name: string;
parent: null | number;
slug: string;
}>;

Updates a category in the database.

The data to update in the page data categories table.

string

number

unknown

string

null | number

string

Promise<{ description: string; id: number; meta: unknown; name: string; parent: null | number; slug: string; }>

A promise that resolves to the updated category.

If an error occurs while updating the category.

folder: (data: {
id: string;
name: string;
parent: null | string;
}) => Promise<{
id: string;
name: string;
parent: null | string;
}>;

string

string

null | string

Promise<{ id: string; name: string; parent: null | string; }>

page: (data: {
authorId: null | string;
categories: unknown;
contentLang: string;
contributorIds: unknown;
description: string;
draft: null | boolean;
heroImage: string;
id: string;
package: string;
parentFolder: null | string;
publishedAt: Date;
showAuthor: null | boolean;
showContributors: null | boolean;
showOnNav: boolean;
slug: string;
tags: unknown;
title: string;
updatedAt: null | Date;
}) => Promise<{
authorId: null | string;
categories: unknown;
contentLang: string;
contributorIds: unknown;
description: string;
draft: null | boolean;
heroImage: string;
id: string;
package: string;
parentFolder: null | string;
publishedAt: Date;
showAuthor: null | boolean;
showContributors: null | boolean;
showOnNav: boolean;
slug: string;
tags: unknown;
title: string;
updatedAt: null | Date;
}>;

Updates a page in the database.

The data to update in the page data table.

null | string

unknown

string

unknown

string

null | boolean

string

string

string

null | string

Date

null | boolean

null | boolean

boolean

string

unknown

string

null | Date

Promise<{ authorId: null | string; categories: unknown; contentLang: string; contributorIds: unknown; description: string; draft: null | boolean; heroImage: string; id: string; package: string; parentFolder: null | string; publishedAt: Date; showAuthor: null | boolean; showContributors: null | boolean; showOnNav: boolean; slug: string; tags: unknown; title: string; updatedAt: null | Date; }>

A promise that resolves to the updated page data.

If an error occurs while updating the page.

pageContent: (data: {
content: null | string;
contentId: string;
contentLang: string;
id: string;
}) => Promise<{
content: null | string;
contentId: string;
contentLang: string;
id: string;
}>;

Updates a page content in the database.

The data to update in the page content table.

null | string

string

string

string

Promise<{ content: null | string; contentId: string; contentLang: string; id: string; }>

A promise that resolves to the updated page content.

If an error occurs while updating the page content.

permissions: (data: {
rank: string;
user: string;
}) => Promise<{
rank: string;
user: string;
}>;

Updates a permission in the database.

The data to update in the permissions table.

string

string

Promise<{ rank: string; user: string; }>

A promise that resolves to the updated permission.

If an error occurs while updating the permission.

siteConfig: (data: {
defaultOgImage: null | string;
description: string;
diffPerPage: number;
enableDiffs: boolean;
gridItems: unknown;
id: number;
loginPageBackground: string;
loginPageCustomImage: null | string;
siteIcon: null | string;
title: string;
}) => Promise<{
defaultOgImage: null | string;
description: string;
diffPerPage: number;
enableDiffs: boolean;
gridItems: unknown;
id: number;
loginPageBackground: string;
loginPageCustomImage: null | string;
siteIcon: null | string;
title: string;
}>;

Updates a site configuration in the database.

The data to update in the site config table.

null | string

string

number

boolean

unknown

number

string

null | string

null | string

string

Promise<{ defaultOgImage: null | string; description: string; diffPerPage: number; enableDiffs: boolean; gridItems: unknown; id: number; loginPageBackground: string; loginPageCustomImage: null | string; siteIcon: null | string; title: string; }>

A promise that resolves to the updated site configuration.

If an error occurs while updating the site configuration.

tags: (data: {
description: string;
id: number;
meta: unknown;
name: string;
slug: string;
}) => Promise<{
description: string;
id: number;
meta: unknown;
name: string;
slug: string;
}>;

Updates a tag in the database.

The data to update in the page data tags table.

string

number

unknown

string

string

Promise<{ description: string; id: number; meta: unknown; name: string; slug: string; }>

A promise that resolves to the updated tag.

If an error occurs while updating the tag.

verifyRank: (users: {
avatar: null | string;
createdAt: null | Date;
email: null | string;
id: string;
name: string;
password: null | string;
updatedAt: null | Date;
url: null | string;
username: string;
}[], permissions: {
rank: string;
user: string;
}[], rank: string) => SingleRank[];

Verifies the rank of users based on the provided permissions and rank.

{ avatar: null | string; createdAt: null | Date; email: null | string; id: string; name: string; password: null | string; updatedAt: null | Date; url: null | string; username: string; }[]

An array of user objects to be verified.

{ rank: string; user: string; }[]

An array of permission objects that include user ranks.

string

The rank to be verified against the permissions.

SingleRank[]

An array of objects containing the id and name of users with the specified rank.

If an error occurs during the verification process.

Renames and re-exports studioCMS_SDK