Skip to content

The SDK

The StudioCMS SDK is a powerful tool that allows you to interact with StudioCMS programmatically. It provides a set of functions and utilities that allow you to manage and serve your content using our own in-house Kysely^ database client. It also provides the backbone for the StudioCMS Dashboard, and is built with Effect^.

The StudioCMS SDK is available as a virtual module in your Astro project. You can import and utilize it using the following syntax:

example.ts
import {
const SDKCore: Effect.Effect<{
AUTH: {
verifyEmail: {
get: (input: string) => Effect.Effect<{
readonly id: string;
readonly userId: string;
readonly token: string;
readonly expiresAt: Date;
} | undefined, DBCallbackFailure | DatabaseError, never>;
create: (userId: string) => Effect.Effect<{
readonly id: string;
readonly userId: string;
readonly token: string;
readonly expiresAt: Date;
}, DBCallbackFailure | DatabaseError | GeneratorError, never>;
delete: (input: string) => Effect.Effect<DeleteResult, DBCallbackFailure | DatabaseError, never>;
};
oAuth: {
create: (input: {
readonly providerUserId: string;
readonly provider: string;
readonly userId: string;
}) => Effect.Effect<{
readonly providerUserId: string;
readonly provider: string;
readonly userId: string;
}, DBCallbackFailure | DatabaseError, never>;
delete: (input: {
readonly userId: string;
readonly provider: string;
}) => AuthDeletionResponse;
searchByProviderId: (input: {
readonly providerUserId: string;
readonly userId: string;
}) => Effect.Effect<{
readonly providerUserId: string;
readonly provider: string;
readonly userId: string;
} | undefined, DBCallbackFailure | DatabaseError, never>;
searchProvidersForId: (input: {
readonly userId: string;
readonly providerId: string;
}) => Effect.Effect<{
readonly providerUserId: string;
readonly provider: string;
readonly userId: string;
} | undefined, DBCallbackFailure | DatabaseError, never>;
};
permission: {
currentStatus: (input: string) => Effect.Effect<{
readonly user: string;
readonly rank: "owner" | "admin" | "editor" | "visitor" | "unknown";
} | undefined, DBCallbackFailure | DatabaseError, never>;
};
session: {
create: (input: {
readonly id: string;
readonly userId: string;
readonly expiresAt: string;
}) => Effect.Effect<{
readonly id: string;
readonly userId: string;
readonly expiresAt: Date;
}, DBCallbackFailure | DatabaseError, never>;
getById: (input: string) => Effect.Effect<{
readonly id: string;
readonly userId: string;
readonly expiresAt: Date;
} | undefined, DBCallbackFailure | DatabaseError, never>;
sessionWithUser: (sessionId: string) => Effect.Effect<{
session: {
readonly id: string;
readonly userId: string;
readonly expiresAt: Date;
};
user: {
readonly name: string;
readonly id: string;
readonly url: string | null | undefined;
readonly email: string | null | undefined;
readonly avatar: string | null | undefined;
readonly username: string;
readonly password: string | null | undefined;
readonly updatedAt: Date;
readonly createdAt: Date;
readonly emailVerified: boolean;
readonly notifications: string | null | undefined;
};
} | undefined, DBCallbackFailure | DatabaseError, never>;
delete: (input: string) => AuthDeletionResponse;
update: (input: {
readonly id: string;
readonly newDate: {
toString: {};
toDateString: {};
toTimeString: {};
toLocaleString: {};
toLocaleDateString: {};
toLocaleTimeString: {};
valueOf: {};
getTime: {};
getFullYear: {};
getUTCFullYear: {};
getMonth: {};
getUTCMonth: {};
getDate: {};
getUTCDate: {};
getDay: {};
getUTCDay: {};
getHours: {};
getUTCHours: {};
getMinutes: {};
getUTCMinutes: {};
getSeconds: {};
getUTCSeconds: {};
getMilliseconds: {};
getUTCMilliseconds: {};
getTimezoneOffset ...

The new Effect-TS based SDK implementation that replaces the deprecated SDK. This unified SDK merges the normal and cached SDK functionalities.

@example

import { Effect } from 'studiocms/effect';
import { SDKCore } from 'studiocms:sdk';
const db = Effect.gen(function* () {
const sdk = yield* SDKCore;
return sdk.db;
}).pipe(Effect.provide(SDKCore.Default));

SDKCore
,
const SDKCoreJs: {
AUTH: {
verifyEmail: {
get: (input: string) => Effect.Effect<{
readonly id: string;
readonly userId: string;
readonly token: string;
readonly expiresAt: Date;
} | undefined, DBCallbackFailure | DatabaseError, never>;
create: (userId: string) => Effect.Effect<{
readonly id: string;
readonly userId: string;
readonly token: string;
readonly expiresAt: Date;
}, DBCallbackFailure | DatabaseError | GeneratorError, never>;
delete: (input: string) => Effect.Effect<DeleteResult, DBCallbackFailure | DatabaseError, never>;
};
oAuth: {
create: (input: {
readonly providerUserId: string;
readonly provider: string;
readonly userId: string;
}) => Effect.Effect<{
readonly providerUserId: string;
readonly provider: string;
readonly userId: string;
}, DBCallbackFailure | DatabaseError, never>;
delete: (input: {
readonly userId: string;
readonly provider: string;
}) => AuthDeletionResponse;
searchByProviderId: (input: {
readonly providerUserId: string;
readonly userId: string;
}) => Effect.Effect<{
readonly providerUserId: string;
readonly provider: string;
readonly userId: string;
} | undefined, DBCallbackFailure | DatabaseError, never>;
searchProvidersForId: (input: {
readonly userId: string;
readonly providerId: string;
}) => Effect.Effect<{
readonly providerUserId: string;
readonly provider: string;
readonly userId: string;
} | undefined, DBCallbackFailure | DatabaseError, never>;
};
permission: {
currentStatus: (input: string) => Effect.Effect<{
readonly user: string;
readonly rank: "owner" | "admin" | "editor" | "visitor" | "unknown";
} | undefined, DBCallbackFailure | DatabaseError, never>;
};
session: {
create: (input: {
readonly id: string;
readonly userId: string;
readonly expiresAt: string;
}) => Effect.Effect<{
readonly id: string;
readonly userId: string;
readonly expiresAt: Date;
}, DBCallbackFailure | DatabaseError, never>;
getById: (input: string) => Effect.Effect<{
readonly id: string;
readonly userId: string;
readonly expiresAt: Date;
} | undefined, DBCallbackFailure | DatabaseError, never>;
sessionWithUser: (sessionId: string) => Effect.Effect<{
session: {
readonly id: string;
readonly userId: string;
readonly expiresAt: Date;
};
user: {
readonly name: string;
readonly id: string;
readonly url: string | null | undefined;
readonly email: string | null | undefined;
readonly avatar: string | null | undefined;
readonly username: string;
readonly password: string | null | undefined;
readonly updatedAt: Date;
readonly createdAt: Date;
readonly emailVerified: boolean;
readonly notifications: string | null | undefined;
};
} | undefined, DBCallbackFailure | DatabaseError, never>;
delete: (input: string) => AuthDeletionResponse;
update: (input: {
readonly id: string;
readonly newDate: {
toString: {};
toDateString: {};
toTimeString: {};
toLocaleString: {};
toLocaleDateString: {};
toLocaleTimeString: {};
valueOf: {};
getTime: {};
getFullYear: {};
getUTCFullYear: {};
getMonth: {};
getUTCMonth: {};
getDate: {};
getUTCDate: {};
getDay: {};
getUTCDay: {};
getHours: {};
getUTCHours: {};
getMinutes: {};
getUTCMinutes: {};
getSeconds: {};
getUTCSeconds: {};
getMilliseconds: {};
getUTCMilliseconds: {};
getTimezoneOffset ...

VanillaJS Version of the SDKCore. Most internal functions will still contain Effects, you can use runSDK from the 'studiocms:sdk' to run these as normal async functions

@example

import { SDKCoreJs, runSDK } from 'studiocms:sdk';
const pages = await runSDK(SDKCoreJs.GET.pages());

SDKCoreJs
,
const runSDK: <A, E>(effect: Effect.Effect<A, E, never>) => Promise<A>

Utility function for running components of the SDKCoreJs

@example

import { SDKCoreJs, runSDK } from 'studiocms:sdk';
const pages = await runSDK(SDKCoreJs.GET.pages());

runSDK
} from 'studiocms:sdk';
import {
import Effect

@since2.0.0

@since2.0.0

@since2.0.0

Effect
} from 'studiocms/effect';
// Create the Usable Effect
const
const pagesEffect: Effect.Effect<CombinedPageData[], DBClientInitializationError | SDKInitializationError | DBCallbackFailure | DatabaseError | ParseError | FolderTreeError | CollectorError | PaginateError, never>
pagesEffect
=
import Effect

@since2.0.0

@since2.0.0

@since2.0.0

Effect
.
const gen: <YieldWrap<Effect.Effect<{
AUTH: {
verifyEmail: {
get: (input: string) => Effect.Effect<{
readonly id: string;
readonly userId: string;
readonly token: string;
readonly expiresAt: Date;
} | undefined, DBCallbackFailure | DatabaseError, never>;
create: (userId: string) => Effect.Effect<{
readonly id: string;
readonly userId: string;
readonly token: string;
readonly expiresAt: Date;
}, DBCallbackFailure | DatabaseError | GeneratorError, never>;
delete: (input: string) => Effect.Effect<DeleteResult, DBCallbackFailure | DatabaseError, never>;
};
oAuth: {
create: (input: {
readonly providerUserId: string;
readonly provider: string;
readonly userId: string;
}) => Effect.Effect<{
readonly providerUserId: string;
readonly provider: string;
readonly userId: string;
}, DBCallbackFailure | DatabaseError, never>;
delete: (input: {
readonly userId: string;
readonly provider: string;
}) => AuthDeletionResponse;
searchByProviderId: (input: {
readonly providerUserId: string;
readonly userId: string;
}) => Effect.Effect<{
readonly providerUserId: string;
readonly provider: string;
readonly userId: string;
} | undefined, DBCallbackFailure | DatabaseError, never>;
searchProvidersForId: (input: {
readonly userId: string;
readonly providerId: string;
}) => Effect.Effect<{
readonly providerUserId: string;
readonly provider: string;
readonly userId: string;
} | undefined, DBCallbackFailure | DatabaseError, never>;
};
permission: {
currentStatus: (input: string) => Effect.Effect<{
readonly user: string;
readonly rank: "owner" | "admin" | "editor" | "visitor" | "unknown";
} | undefined, DBCallbackFailure | DatabaseError, never>;
};
session: {
create: (input: {
readonly id: string;
readonly userId: string;
readonly expiresAt: string;
}) => Effect.Effect<{
readonly id: string;
readonly userId: string;
readonly expiresAt: Date;
}, DBCallbackFailure | DatabaseError, never>;
getById: (input: string) => Effect.Effect<{
readonly id: string;
readonly userId: string;
readonly expiresAt: Date;
} | undefined, DBCallbackFailure | DatabaseError, never>;
sessionWithUser: (sessionId: string) => Effect.Effect<{
session: {
readonly id: string;
readonly userId: string;
readonly expiresAt: Date;
};
user: {
readonly name: string;
readonly id: string;
readonly url: string | null | undefined;
readonly email: string | null | undefined;
readonly avatar: string | null | undefined;
readonly username: string;
readonly password: string | null | undefined;
readonly updatedAt: Date;
readonly createdAt: Date;
readonly emailVerified: boolean;
readonly notifications: string | null | undefined;
};
} | undefined, DBCallbackFailure | DatabaseError, never>;
delete: (input: string) => AuthDeletionResponse;
update: (input: {
readonly id: string;
readonly newDate: {
toString: {};
toDateString: {};
toTimeString: {};
toLocaleString: {};
toLocaleDateString: {};
toLocaleTimeString: {};
valueOf: {};
getTime: {};
getFullYear: {};
getUTCFullYear: {};
getMonth: {};
getUTCMonth: {};
getDate: {};
getUTCDate: {};
getDay: {};
getUTCDay: {};
getHours: {};
getUTCHours: {};
getMinutes: {};
getUTCMinutes: {};
getSeconds: {};
getUTCSeconds: {};
getMilliseconds: {};
getUTCMilliseconds: {};
getTimezoneOffset ... (+1 overload)

Provides a way to write effectful code using generator functions, simplifying control flow and error handling.

When to Use

Effect.gen allows you to write code that looks and behaves like synchronous code, but it can handle asynchronous tasks, errors, and complex control flow (like loops and conditions). It helps make asynchronous code more readable and easier to manage.

The generator functions work similarly to async/await but with more explicit control over the execution of effects. You can yield* values from effects and return the final result at the end.

Example

import { Effect } from "effect"
const addServiceCharge = (amount: number) => amount + 1
const applyDiscount = (
total: number,
discountRate: number
): Effect.Effect<number, Error> =>
discountRate === 0
? Effect.fail(new Error("Discount rate cannot be zero"))
: Effect.succeed(total - (total * discountRate) / 100)
const fetchTransactionAmount = Effect.promise(() => Promise.resolve(100))
const fetchDiscountRate = Effect.promise(() => Promise.resolve(5))
export const program = Effect.gen(function* () {
const transactionAmount = yield* fetchTransactionAmount
const discountRate = yield* fetchDiscountRate
const discountedAmount = yield* applyDiscount(
transactionAmount,
discountRate
)
const finalAmount = addServiceCharge(discountedAmount)
return `Final amount to charge: ${finalAmount}`
})

@since2.0.0

gen
(function* () {
const
const sdk: {
AUTH: {
verifyEmail: {
get: (input: string) => Effect.Effect<{
readonly id: string;
readonly userId: string;
readonly token: string;
readonly expiresAt: Date;
} | undefined, DBCallbackFailure | DatabaseError, never>;
create: (userId: string) => Effect.Effect<{
readonly id: string;
readonly userId: string;
readonly token: string;
readonly expiresAt: Date;
}, DBCallbackFailure | DatabaseError | GeneratorError, never>;
delete: (input: string) => Effect.Effect<DeleteResult, DBCallbackFailure | DatabaseError, never>;
};
oAuth: {
create: (input: {
readonly providerUserId: string;
readonly provider: string;
readonly userId: string;
}) => Effect.Effect<{
readonly providerUserId: string;
readonly provider: string;
readonly userId: string;
}, DBCallbackFailure | DatabaseError, never>;
delete: (input: {
readonly userId: string;
readonly provider: string;
}) => AuthDeletionResponse;
searchByProviderId: (input: {
readonly providerUserId: string;
readonly userId: string;
}) => Effect.Effect<{
readonly providerUserId: string;
readonly provider: string;
readonly userId: string;
} | undefined, DBCallbackFailure | DatabaseError, never>;
searchProvidersForId: (input: {
readonly userId: string;
readonly providerId: string;
}) => Effect.Effect<{
readonly providerUserId: string;
readonly provider: string;
readonly userId: string;
} | undefined, DBCallbackFailure | DatabaseError, never>;
};
permission: {
currentStatus: (input: string) => Effect.Effect<{
readonly user: string;
readonly rank: "owner" | "admin" | "editor" | "visitor" | "unknown";
} | undefined, DBCallbackFailure | DatabaseError, never>;
};
session: {
create: (input: {
readonly id: string;
readonly userId: string;
readonly expiresAt: string;
}) => Effect.Effect<{
readonly id: string;
readonly userId: string;
readonly expiresAt: Date;
}, DBCallbackFailure | DatabaseError, never>;
getById: (input: string) => Effect.Effect<{
readonly id: string;
readonly userId: string;
readonly expiresAt: Date;
} | undefined, DBCallbackFailure | DatabaseError, never>;
sessionWithUser: (sessionId: string) => Effect.Effect<{
session: {
readonly id: string;
readonly userId: string;
readonly expiresAt: Date;
};
user: {
readonly name: string;
readonly id: string;
readonly url: string | null | undefined;
readonly email: string | null | undefined;
readonly avatar: string | null | undefined;
readonly username: string;
readonly password: string | null | undefined;
readonly updatedAt: Date;
readonly createdAt: Date;
readonly emailVerified: boolean;
readonly notifications: string | null | undefined;
};
} | undefined, DBCallbackFailure | DatabaseError, never>;
delete: (input: string) => AuthDeletionResponse;
update: (input: {
readonly id: string;
readonly newDate: {
toString: {};
toDateString: {};
toTimeString: {};
toLocaleString: {};
toLocaleDateString: {};
toLocaleTimeString: {};
valueOf: {};
getTime: {};
getFullYear: {};
getUTCFullYear: {};
getMonth: {};
getUTCMonth: {};
getDate: {};
getUTCDate: {};
getDay: {};
getUTCDay: {};
getHours: {};
getUTCHours: {};
getMinutes: {};
getUTCMinutes: {};
getSeconds: {};
getUTCSeconds: {};
getMilliseconds: {};
getUTCMilliseconds: {};
getTimezoneOffset ...
sdk
= yield*
const SDKCore: Effect.Effect<{
AUTH: {
verifyEmail: {
get: (input: string) => Effect.Effect<{
readonly id: string;
readonly userId: string;
readonly token: string;
readonly expiresAt: Date;
} | undefined, DBCallbackFailure | DatabaseError, never>;
create: (userId: string) => Effect.Effect<{
readonly id: string;
readonly userId: string;
readonly token: string;
readonly expiresAt: Date;
}, DBCallbackFailure | DatabaseError | GeneratorError, never>;
delete: (input: string) => Effect.Effect<DeleteResult, DBCallbackFailure | DatabaseError, never>;
};
oAuth: {
create: (input: {
readonly providerUserId: string;
readonly provider: string;
readonly userId: string;
}) => Effect.Effect<{
readonly providerUserId: string;
readonly provider: string;
readonly userId: string;
}, DBCallbackFailure | DatabaseError, never>;
delete: (input: {
readonly userId: string;
readonly provider: string;
}) => AuthDeletionResponse;
searchByProviderId: (input: {
readonly providerUserId: string;
readonly userId: string;
}) => Effect.Effect<{
readonly providerUserId: string;
readonly provider: string;
readonly userId: string;
} | undefined, DBCallbackFailure | DatabaseError, never>;
searchProvidersForId: (input: {
readonly userId: string;
readonly providerId: string;
}) => Effect.Effect<{
readonly providerUserId: string;
readonly provider: string;
readonly userId: string;
} | undefined, DBCallbackFailure | DatabaseError, never>;
};
permission: {
currentStatus: (input: string) => Effect.Effect<{
readonly user: string;
readonly rank: "owner" | "admin" | "editor" | "visitor" | "unknown";
} | undefined, DBCallbackFailure | DatabaseError, never>;
};
session: {
create: (input: {
readonly id: string;
readonly userId: string;
readonly expiresAt: string;
}) => Effect.Effect<{
readonly id: string;
readonly userId: string;
readonly expiresAt: Date;
}, DBCallbackFailure | DatabaseError, never>;
getById: (input: string) => Effect.Effect<{
readonly id: string;
readonly userId: string;
readonly expiresAt: Date;
} | undefined, DBCallbackFailure | DatabaseError, never>;
sessionWithUser: (sessionId: string) => Effect.Effect<{
session: {
readonly id: string;
readonly userId: string;
readonly expiresAt: Date;
};
user: {
readonly name: string;
readonly id: string;
readonly url: string | null | undefined;
readonly email: string | null | undefined;
readonly avatar: string | null | undefined;
readonly username: string;
readonly password: string | null | undefined;
readonly updatedAt: Date;
readonly createdAt: Date;
readonly emailVerified: boolean;
readonly notifications: string | null | undefined;
};
} | undefined, DBCallbackFailure | DatabaseError, never>;
delete: (input: string) => AuthDeletionResponse;
update: (input: {
readonly id: string;
readonly newDate: {
toString: {};
toDateString: {};
toTimeString: {};
toLocaleString: {};
toLocaleDateString: {};
toLocaleTimeString: {};
valueOf: {};
getTime: {};
getFullYear: {};
getUTCFullYear: {};
getMonth: {};
getUTCMonth: {};
getDate: {};
getUTCDate: {};
getDay: {};
getUTCDay: {};
getHours: {};
getUTCHours: {};
getMinutes: {};
getUTCMinutes: {};
getSeconds: {};
getUTCSeconds: {};
getMilliseconds: {};
getUTCMilliseconds: {};
getTimezoneOffset ...

The new Effect-TS based SDK implementation that replaces the deprecated SDK. This unified SDK merges the normal and cached SDK functionalities.

@example

import { Effect } from 'studiocms/effect';
import { SDKCore } from 'studiocms:sdk';
const db = Effect.gen(function* () {
const sdk = yield* SDKCore;
return sdk.db;
}).pipe(Effect.provide(SDKCore.Default));

SDKCore
;
// then do something with the SDK
return yield*
const sdk: {
AUTH: {
verifyEmail: {
get: (input: string) => Effect.Effect<{
readonly id: string;
readonly userId: string;
readonly token: string;
readonly expiresAt: Date;
} | undefined, DBCallbackFailure | DatabaseError, never>;
create: (userId: string) => Effect.Effect<{
readonly id: string;
readonly userId: string;
readonly token: string;
readonly expiresAt: Date;
}, DBCallbackFailure | DatabaseError | GeneratorError, never>;
delete: (input: string) => Effect.Effect<DeleteResult, DBCallbackFailure | DatabaseError, never>;
};
oAuth: {
create: (input: {
readonly providerUserId: string;
readonly provider: string;
readonly userId: string;
}) => Effect.Effect<{
readonly providerUserId: string;
readonly provider: string;
readonly userId: string;
}, DBCallbackFailure | DatabaseError, never>;
delete: (input: {
readonly userId: string;
readonly provider: string;
}) => AuthDeletionResponse;
searchByProviderId: (input: {
readonly providerUserId: string;
readonly userId: string;
}) => Effect.Effect<{
readonly providerUserId: string;
readonly provider: string;
readonly userId: string;
} | undefined, DBCallbackFailure | DatabaseError, never>;
searchProvidersForId: (input: {
readonly userId: string;
readonly providerId: string;
}) => Effect.Effect<{
readonly providerUserId: string;
readonly provider: string;
readonly userId: string;
} | undefined, DBCallbackFailure | DatabaseError, never>;
};
permission: {
currentStatus: (input: string) => Effect.Effect<{
readonly user: string;
readonly rank: "owner" | "admin" | "editor" | "visitor" | "unknown";
} | undefined, DBCallbackFailure | DatabaseError, never>;
};
session: {
create: (input: {
readonly id: string;
readonly userId: string;
readonly expiresAt: string;
}) => Effect.Effect<{
readonly id: string;
readonly userId: string;
readonly expiresAt: Date;
}, DBCallbackFailure | DatabaseError, never>;
getById: (input: string) => Effect.Effect<{
readonly id: string;
readonly userId: string;
readonly expiresAt: Date;
} | undefined, DBCallbackFailure | DatabaseError, never>;
sessionWithUser: (sessionId: string) => Effect.Effect<{
session: {
readonly id: string;
readonly userId: string;
readonly expiresAt: Date;
};
user: {
readonly name: string;
readonly id: string;
readonly url: string | null | undefined;
readonly email: string | null | undefined;
readonly avatar: string | null | undefined;
readonly username: string;
readonly password: string | null | undefined;
readonly updatedAt: Date;
readonly createdAt: Date;
readonly emailVerified: boolean;
readonly notifications: string | null | undefined;
};
} | undefined, DBCallbackFailure | DatabaseError, never>;
delete: (input: string) => AuthDeletionResponse;
update: (input: {
readonly id: string;
readonly newDate: {
toString: {};
toDateString: {};
toTimeString: {};
toLocaleString: {};
toLocaleDateString: {};
toLocaleTimeString: {};
valueOf: {};
getTime: {};
getFullYear: {};
getUTCFullYear: {};
getMonth: {};
getUTCMonth: {};
getDate: {};
getUTCDate: {};
getDay: {};
getUTCDay: {};
getHours: {};
getUTCHours: {};
getMinutes: {};
getUTCMinutes: {};
getSeconds: {};
getUTCSeconds: {};
getMilliseconds: {};
getUTCMilliseconds: {};
getTimezoneOffset ...
sdk
.
type GET: {
permissionsLists: {
owners: () => Effect.Effect<SingleRank[], UsersError | DBCallbackFailure | DatabaseError, never>;
admins: () => Effect.Effect<SingleRank[], UsersError | DBCallbackFailure | DatabaseError, never>;
editors: () => Effect.Effect<SingleRank[], UsersError | DBCallbackFailure | DatabaseError, never>;
visitors: () => Effect.Effect<SingleRank[], UsersError | DBCallbackFailure | DatabaseError, never>;
all: () => Effect.Effect<CombinedRank[], DBCallbackFailure | DatabaseError | UsersError, never>;
};
... 10 more ...;
pageFolderTree: (hideDefaultIndex?: boolean) => Effect.Effect<FolderNode[], ParseError | DBCallbackFailure | QueryParseError | QueryError | NotFoundError | FolderTreeError | CollectorError | PaginateError, never>;
}
GET
.
pages: (includeDrafts?: boolean, hideDefaultIndex?: boolean, metaOnly?: false, paginate?: PaginateInput) => Effect.Effect<CombinedPageData[], ParseError | DBCallbackFailure | DatabaseError | FolderTreeError | CollectorError | PaginateError, never> (+1 overload)
pages
()
});
// Convert the Effect into a JS/TS "program"
const
const pagesResult1: CombinedPageData[]
pagesResult1
= await
runSDK<CombinedPageData[], DBClientInitializationError | SDKInitializationError | DBCallbackFailure | DatabaseError | ParseError | FolderTreeError | CollectorError | PaginateError>(effect: Effect.Effect<CombinedPageData[], DBClientInitializationError | SDKInitializationError | DBCallbackFailure | ... 4 more ... | PaginateError, never>): Promise<...>

Alias for runEffect, used to run SDK effects and convert them to plain JavaScript objects.

@parameffect - The Effect to be converted.

@returnsA promise that resolves to the plain JavaScript object representation of the effect's result.

runSDK
(
const pagesEffect: Effect.Effect<CombinedPageData[], DBClientInitializationError | SDKInitializationError | DBCallbackFailure | DatabaseError | ParseError | FolderTreeError | CollectorError | PaginateError, never>
pagesEffect
);
// Just run the SDKCoreJS with the runSDK wrapper!
const
const pagesResult2: CombinedPageData[]
pagesResult2
= await
runSDK<CombinedPageData[], DBCallbackFailure | DatabaseError | ParseError | FolderTreeError | CollectorError | PaginateError>(effect: Effect.Effect<CombinedPageData[], DBCallbackFailure | DatabaseError | ParseError | FolderTreeError | CollectorError | PaginateError, never>): Promise<CombinedPageData[]>

Alias for runEffect, used to run SDK effects and convert them to plain JavaScript objects.

@parameffect - The Effect to be converted.

@returnsA promise that resolves to the plain JavaScript object representation of the effect's result.

runSDK
(
const SDKCoreJs: {
AUTH: {
verifyEmail: {
get: (input: string) => Effect.Effect<{
readonly id: string;
readonly userId: string;
readonly token: string;
readonly expiresAt: Date;
} | undefined, DBCallbackFailure | DatabaseError, never>;
create: (userId: string) => Effect.Effect<{
readonly id: string;
readonly userId: string;
readonly token: string;
readonly expiresAt: Date;
}, DBCallbackFailure | DatabaseError | GeneratorError, never>;
delete: (input: string) => Effect.Effect<DeleteResult, DBCallbackFailure | DatabaseError, never>;
};
oAuth: {
create: (input: {
readonly providerUserId: string;
readonly provider: string;
readonly userId: string;
}) => Effect.Effect<{
readonly providerUserId: string;
readonly provider: string;
readonly userId: string;
}, DBCallbackFailure | DatabaseError, never>;
delete: (input: {
readonly userId: string;
readonly provider: string;
}) => AuthDeletionResponse;
searchByProviderId: (input: {
readonly providerUserId: string;
readonly userId: string;
}) => Effect.Effect<{
readonly providerUserId: string;
readonly provider: string;
readonly userId: string;
} | undefined, DBCallbackFailure | DatabaseError, never>;
searchProvidersForId: (input: {
readonly userId: string;
readonly providerId: string;
}) => Effect.Effect<{
readonly providerUserId: string;
readonly provider: string;
readonly userId: string;
} | undefined, DBCallbackFailure | DatabaseError, never>;
};
permission: {
currentStatus: (input: string) => Effect.Effect<{
readonly user: string;
readonly rank: "owner" | "admin" | "editor" | "visitor" | "unknown";
} | undefined, DBCallbackFailure | DatabaseError, never>;
};
session: {
create: (input: {
readonly id: string;
readonly userId: string;
readonly expiresAt: string;
}) => Effect.Effect<{
readonly id: string;
readonly userId: string;
readonly expiresAt: Date;
}, DBCallbackFailure | DatabaseError, never>;
getById: (input: string) => Effect.Effect<{
readonly id: string;
readonly userId: string;
readonly expiresAt: Date;
} | undefined, DBCallbackFailure | DatabaseError, never>;
sessionWithUser: (sessionId: string) => Effect.Effect<{
session: {
readonly id: string;
readonly userId: string;
readonly expiresAt: Date;
};
user: {
readonly name: string;
readonly id: string;
readonly url: string | null | undefined;
readonly email: string | null | undefined;
readonly avatar: string | null | undefined;
readonly username: string;
readonly password: string | null | undefined;
readonly updatedAt: Date;
readonly createdAt: Date;
readonly emailVerified: boolean;
readonly notifications: string | null | undefined;
};
} | undefined, DBCallbackFailure | DatabaseError, never>;
delete: (input: string) => AuthDeletionResponse;
update: (input: {
readonly id: string;
readonly newDate: {
toString: {};
toDateString: {};
toTimeString: {};
toLocaleString: {};
toLocaleDateString: {};
toLocaleTimeString: {};
valueOf: {};
getTime: {};
getFullYear: {};
getUTCFullYear: {};
getMonth: {};
getUTCMonth: {};
getDate: {};
getUTCDate: {};
getDay: {};
getUTCDay: {};
getHours: {};
getUTCHours: {};
getMinutes: {};
getUTCMinutes: {};
getSeconds: {};
getUTCSeconds: {};
getMilliseconds: {};
getUTCMilliseconds: {};
getTimezoneOffset ...

VanillaJS Version of the SDKCore. Most internal functions will still contain Effects, you can use runSDK from the 'studiocms:sdk' to run these as normal async functions

@example

import { SDKCoreJs, runSDK } from 'studiocms:sdk';
const pages = await runSDK(SDKCoreJs.GET.pages());

SDKCoreJs
.
type GET: {
permissionsLists: {
owners: () => Effect.Effect<SingleRank[], UsersError | DBCallbackFailure | DatabaseError, never>;
admins: () => Effect.Effect<SingleRank[], UsersError | DBCallbackFailure | DatabaseError, never>;
editors: () => Effect.Effect<SingleRank[], UsersError | DBCallbackFailure | DatabaseError, never>;
visitors: () => Effect.Effect<SingleRank[], UsersError | DBCallbackFailure | DatabaseError, never>;
all: () => Effect.Effect<CombinedRank[], DBCallbackFailure | DatabaseError | UsersError, never>;
};
... 10 more ...;
pageFolderTree: (hideDefaultIndex?: boolean) => Effect.Effect<FolderNode[], ParseError | DBCallbackFailure | QueryParseError | QueryError | NotFoundError | FolderTreeError | CollectorError | PaginateError, never>;
}
GET
.
pages: (includeDrafts?: boolean, hideDefaultIndex?: boolean, metaOnly?: false, paginate?: PaginateInput) => Effect.Effect<CombinedPageData[], ParseError | DBCallbackFailure | DatabaseError | FolderTreeError | CollectorError | PaginateError, never> (+1 overload)
pages
());

The following is a list of the Primary utils provided by the StudioCMS SDK for interacting with the database.

utils.ts
import {
const SDKCoreJs: {
AUTH: {
verifyEmail: {
get: (input: string) => Effect<{
readonly id: string;
readonly userId: string;
readonly token: string;
readonly expiresAt: Date;
} | undefined, DBCallbackFailure | DatabaseError, never>;
create: (userId: string) => Effect<{
readonly id: string;
readonly userId: string;
readonly token: string;
readonly expiresAt: Date;
}, DBCallbackFailure | DatabaseError | GeneratorError, never>;
delete: (input: string) => Effect<DeleteResult, DBCallbackFailure | DatabaseError, never>;
};
oAuth: {
create: (input: {
readonly providerUserId: string;
readonly provider: string;
readonly userId: string;
}) => Effect<{
readonly providerUserId: string;
readonly provider: string;
readonly userId: string;
}, DBCallbackFailure | DatabaseError, never>;
delete: (input: {
readonly userId: string;
readonly provider: string;
}) => AuthDeletionResponse;
searchByProviderId: (input: {
readonly providerUserId: string;
readonly userId: string;
}) => Effect<{
readonly providerUserId: string;
readonly provider: string;
readonly userId: string;
} | undefined, DBCallbackFailure | DatabaseError, never>;
searchProvidersForId: (input: {
readonly userId: string;
readonly providerId: string;
}) => Effect<{
readonly providerUserId: string;
readonly provider: string;
readonly userId: string;
} | undefined, DBCallbackFailure | DatabaseError, never>;
};
permission: {
currentStatus: (input: string) => Effect<{
readonly user: string;
readonly rank: "owner" | "admin" | "editor" | "visitor" | "unknown";
} | undefined, DBCallbackFailure | DatabaseError, never>;
};
session: {
create: (input: {
readonly id: string;
readonly userId: string;
readonly expiresAt: string;
}) => Effect<{
readonly id: string;
readonly userId: string;
readonly expiresAt: Date;
}, DBCallbackFailure | DatabaseError, never>;
getById: (input: string) => Effect<{
readonly id: string;
readonly userId: string;
readonly expiresAt: Date;
} | undefined, DBCallbackFailure | DatabaseError, never>;
sessionWithUser: (sessionId: string) => Effect<{
session: {
readonly id: string;
readonly userId: string;
readonly expiresAt: Date;
};
user: {
readonly name: string;
readonly id: string;
readonly url: string | null | undefined;
readonly email: string | null | undefined;
readonly avatar: string | null | undefined;
readonly username: string;
readonly password: string | null | undefined;
readonly updatedAt: Date;
readonly createdAt: Date;
readonly emailVerified: boolean;
readonly notifications: string | null | undefined;
};
} | undefined, DBCallbackFailure | DatabaseError, never>;
delete: (input: string) => AuthDeletionResponse;
update: (input: {
readonly id: string;
readonly newDate: {
toString: {};
toDateString: {};
toTimeString: {};
toLocaleString: {};
toLocaleDateString: {};
toLocaleTimeString: {};
valueOf: {};
getTime: {};
getFullYear: {};
getUTCFullYear: {};
getMonth: {};
getUTCMonth: {};
getDate: {};
getUTCDate: {};
getDay: {};
getUTCDay: {};
getHours: {};
getUTCHours: {};
getMinutes: {};
getUTCMinutes: {};
getSeconds: {};
getUTCSeconds: {};
getMilliseconds: {};
getUTCMilliseconds: {};
getTimezoneOffset: {};
setTime: {};
setMilliseconds ...

VanillaJS Version of the SDKCore. Most internal functions will still contain Effects, you can use runSDK from the 'studiocms:sdk' to run these as normal async functions

@example

import { SDKCoreJs, runSDK } from 'studiocms:sdk';
const pages = await runSDK(SDKCoreJs.GET.pages());

SDKCoreJs
} from 'studiocms:sdk';
const {
const dbService: DBClientInterface<{
readonly StudioCMSUsersTable: {
readonly id: string;
readonly url: string | null | undefined;
readonly name: string;
readonly email: string | null | undefined;
readonly avatar: string | null | undefined;
readonly username: string;
readonly password: string | null | undefined;
readonly updatedAt: ColumnType<string, string, string>;
readonly createdAt: ColumnType<string, string | undefined, never>;
readonly emailVerified: number;
readonly notifications: string | null | undefined;
};
... 13 more ...;
readonly StudioCMSDynamicConfigSettings: {
readonly id: string;
readonly data: ColumnType<...>;
};
}>
dbService
,
const cache: CacheService
cache
,
const AUTH: {
verifyEmail: {
get: (input: string) => Effect<{
readonly id: string;
readonly userId: string;
readonly token: string;
readonly expiresAt: Date;
} | undefined, DBCallbackFailure | DatabaseError, never>;
create: (userId: string) => Effect<{
readonly id: string;
readonly userId: string;
readonly token: string;
readonly expiresAt: Date;
}, DBCallbackFailure | DatabaseError | GeneratorError, never>;
delete: (input: string) => Effect<DeleteResult, DBCallbackFailure | DatabaseError, never>;
};
oAuth: {
create: (input: {
readonly providerUserId: string;
readonly provider: string;
readonly userId: string;
}) => Effect<{
readonly providerUserId: string;
readonly provider: string;
readonly userId: string;
}, DBCallbackFailure | DatabaseError, never>;
delete: (input: {
readonly userId: string;
readonly provider: string;
}) => AuthDeletionResponse;
searchByProviderId: (input: {
readonly providerUserId: string;
readonly userId: string;
}) => Effect<{
readonly providerUserId: string;
readonly provider: string;
readonly userId: string;
} | undefined, DBCallbackFailure | DatabaseError, never>;
searchProvidersForId: (input: {
readonly userId: string;
readonly providerId: string;
}) => Effect<{
readonly providerUserId: string;
readonly provider: string;
readonly userId: string;
} | undefined, DBCallbackFailure | DatabaseError, never>;
};
permission: {
currentStatus: (input: string) => Effect<{
readonly user: string;
readonly rank: "owner" | "admin" | "editor" | "visitor" | "unknown";
} | undefined, DBCallbackFailure | DatabaseError, never>;
};
session: {
create: (input: {
readonly id: string;
readonly userId: string;
readonly expiresAt: string;
}) => Effect<{
readonly id: string;
readonly userId: string;
readonly expiresAt: Date;
}, DBCallbackFailure | DatabaseError, never>;
getById: (input: string) => Effect<{
readonly id: string;
readonly userId: string;
readonly expiresAt: Date;
} | undefined, DBCallbackFailure | DatabaseError, never>;
sessionWithUser: (sessionId: string) => Effect<{
session: {
readonly id: string;
readonly userId: string;
readonly expiresAt: Date;
};
user: {
readonly name: string;
readonly id: string;
readonly url: string | null | undefined;
readonly email: string | null | undefined;
readonly avatar: string | null | undefined;
readonly username: string;
readonly password: string | null | undefined;
readonly updatedAt: Date;
readonly createdAt: Date;
readonly emailVerified: boolean;
readonly notifications: string | null | undefined;
};
} | undefined, DBCallbackFailure | DatabaseError, never>;
delete: (input: string) => AuthDeletionResponse;
update: (input: {
readonly id: string;
readonly newDate: {
toString: {};
toDateString: {};
toTimeString: {};
toLocaleString: {};
toLocaleDateString: {};
toLocaleTimeString: {};
valueOf: {};
getTime: {};
getFullYear: {};
getUTCFullYear: {};
getMonth: {};
getUTCMonth: {};
getDate: {};
getUTCDate: {};
getDay: {};
getUTCDay: {};
getHours: {};
getUTCHours: {};
getMinutes: {};
getUTCMinutes: {};
getSeconds: {};
getUTCSeconds: {};
getMilliseconds: {};
getUTCMilliseconds: {};
getTimezoneOffset: {};
setTime: {};
setMilliseconds: {};
setUTCMilliseconds: {};
setSeconds: {};
setUTCSeconds: {};
setMinutes: {};
setUTCMinutes: {};
setHours: {};
setUTCHours: {};
setDate: {};
setUTCDate: {};
setMonth: {};
setUTCMonth: {};
setFullYear: {};
setUTCFullYear: {};
toUTCString: {};
toISOString ...
AUTH
,
const CLEAR: {
page: {
byId: (id: string) => Effect<void, never, never>;
};
pages: Effect<void, never, never>;
latestVersion: Effect<void, never, never>;
folderTree: Effect<void, never, never>;
folderList: Effect<void, never, never>;
}
CLEAR
,
const CONFIG: {
siteConfig: {
get: () => Effect<DynamicConfigEntry<StudioCMSSiteConfig> | undefined, DBCallbackFailure | DatabaseError, never>;
update: (data: ConfigFinal<StudioCMSSiteConfig>) => Effect<DynamicConfigEntry<StudioCMSSiteConfig>, DBCallbackFailure | DatabaseError, never>;
init: (data: ConfigFinal<StudioCMSSiteConfig>) => Effect<DynamicConfigEntry<StudioCMSSiteConfig>, DBCallbackFailure | DatabaseError, never>;
};
mailerConfig: {
get: () => Effect<DynamicConfigEntry<...> | undefined, DBCallbackFailure | DatabaseError, never>;
update: (data: ConfigFinal<...>) => Effect<DynamicConfigEntry<...>, DBCallbackFailure | DatabaseError, never>;
init: (data: ConfigFinal<...>) => Effect<DynamicConfigEntry<...>, DBCallbackFailure | DatabaseError, never>;
};
notificationConfig: {
get: () => Effect<DynamicConfigEntry<...> | undefined, DBCallbackFailure | DatabaseError, never>;
update: (data: ConfigFinal<...>) => Effect<DynamicConfigEntry<...>, DBCallbackFailure | DatabaseError, never>;
init: (data: ConfigFinal<...>) => Effect<DynamicConfigEntry<...>, DBCallbackFailure | DatabaseError, never>;
};
templateConfig: {
get: () => Effect<DynamicConfigEntry<...> | undefined, DBCallbackFailure | DatabaseError, never>;
update: (data: ConfigFinal<...>) => Effect<DynamicConfigEntry<...>, Error, never>;
init: (data: ConfigFinal<...>) => Effect<DynamicConfigEntry<...>, DBCallbackFailure | DatabaseError, never>;
};
}
CONFIG
,
const DELETE: {
page: (id: string) => Effect<{
status: "success" | "error";
message: string;
}, never, never>;
pageContent: (id: string) => Effect<{
status: "success" | "error";
message: string;
}, never, never>;
pageContentLang: (id: string, lang: string) => Effect<{
status: "success" | "error";
message: string;
}, never, never>;
tags: (id: number) => Effect<{
status: "success" | "error";
message: string;
}, never, never>;
... 4 more ...;
user: (userId: string) => Effect<{
status: "success" | "error";
message: string;
}, never, never>;
}
DELETE
,
const diffTracking: {
insert: (userId: string, pageId: string, data: {
content: {
start: string;
end: string;
};
metaData: {
start: Partial<{
readonly description: string;
readonly title: string;
readonly id: string;
readonly package: string;
readonly showOnNav: boolean;
readonly publishedAt: Date;
readonly updatedAt: Date;
readonly slug: string;
readonly contentLang: string;
readonly heroImage: string | null | undefined;
readonly categories: readonly string[];
readonly tags: readonly string[];
readonly authorId: string;
readonly contributorIds: readonly string[];
readonly showAuthor: boolean;
readonly showContributors: boolean;
readonly parentFolder: string | null | undefined;
readonly draft: boolean;
readonly augments: readonly string[];
}>;
end: Partial<{
...;
}>;
};
}, diffLength: number) => Effect<diffReturn, DBCallbackFailure | DatabaseError | ParsersError | DiffError, never>;
clear: (input: string) => Effect<DeleteResult[], DBCallbackFailure | DatabaseError, never>;
get: {
byPageId: {
all: (pageId: string) => Effect<diffReturn[], DBCallbackFailure | DatabaseError | ParsersError, never>;
latest: (pageId: string, count: number) => Effect<diffReturn[], DBCallbackFailure | DatabaseError | ParsersError, never>;
};
byUserId: {
all: (userId: string) => Effect<diffReturn[], DBCallbackFailure | DatabaseError | ParsersError, never>;
latest: (userId: string, count: number) => Effect<diffReturn[], DBCallbackFailure | DatabaseError | ParsersError, never>;
};
single: (diffId: string) => Effect<diffReturn | undefined, DBCallbackFailure | DatabaseError | ParsersError, never>;
};
revertToDiff: (id: string, type: "data" | "content" | "both") => Effect<diffReturn, ParseError | DBCallbackFailure | DatabaseError | ParsersError | DiffTrackingError, never>;
utils: {
getMetaDataDifferences: <T extends Record<string, unknown>>(obj1: T, obj2: T) => Effect<{
label: string;
previous: unknown;
current: unknown;
}[], never, never>;
getDiffHTML: (diff: string, options?: Diff2HtmlConfig | undefined) => Effect<string, DiffError, never>;
};
}
diffTracking
,
const GET: {
permissionsLists: {
owners: () => Effect<SingleRank[], UsersError | DBCallbackFailure | DatabaseError, never>;
admins: () => Effect<SingleRank[], UsersError | DBCallbackFailure | DatabaseError, never>;
editors: () => Effect<SingleRank[], UsersError | DBCallbackFailure | DatabaseError, never>;
visitors: () => Effect<SingleRank[], UsersError | DBCallbackFailure | DatabaseError, never>;
all: () => Effect<CombinedRank[], DBCallbackFailure | DatabaseError | UsersError, never>;
};
... 10 more ...;
pageFolderTree: (hideDefaultIndex?: boolean) => Effect<FolderNode[], ParseError | DBCallbackFailure | QueryParseError | QueryError | NotFoundError | FolderTreeError | CollectorError | PaginateError, never>;
}
GET
,
const INIT: {
siteConfig: (data: ConfigFinal<StudioCMSSiteConfig>) => Effect<DynamicConfigEntry<StudioCMSSiteConfig>, DBCallbackFailure | DatabaseError, never>;
ghostUser: () => Effect<{
readonly name: string;
readonly id: string;
readonly url: string | null | undefined;
readonly email: string | null | undefined;
readonly avatar: string | null | undefined;
readonly username: string;
readonly password: string | null | undefined;
readonly updatedAt: Date;
readonly createdAt: Date;
readonly emailVerified: boolean;
readonly notifications: string | null | undefined;
}, DBCallbackFailure | DatabaseError, never>;
}
INIT
,
const MIDDLEWARES: {
verifyCache: () => Effect<void, ParseError | DBCallbackFailure | QueryParseError | QueryError | NotFoundError | FolderTreeError | CollectorError | PaginateError, never>;
}
MIDDLEWARES
,
const notificationSettings: {
site: {
get: () => Effect<DynamicConfigEntry<StudioCMSNotificationSettings>, DBCallbackFailure | DatabaseError, never>;
update: (settings: Omit<StudioCMSNotificationSettings, "_config_version">) => Effect<DynamicConfigEntry<StudioCMSNotificationSettings>, DBCallbackFailure | DatabaseError, never>;
};
}
notificationSettings
,
const PLUGINS: {
usePluginData: {
<T extends Struct<Struct.Fields> | object, R extends object = T extends Struct<any> ? RecursiveSimplifyMutable<T["Type"]> : T>(pluginId: string, opts?: UsePluginDataOptsBase<T>): {
getEntries: (filter?: (data: PluginDataEntry<R>[]) => PluginDataEntry<R>[]) => Effect<PluginDataEntry<R>[], Error, never>;
getEntry: (id: string) => {
generatedId: () => Effect<string, never, never>;
select: () => Effect<PluginDataEntry<R> | undefined, Error, never>;
insert: (data: R) => Effect<PluginDataEntry<R>, Error, never>;
update: (data: R) => Effect<PluginDataEntry<R>, Error, never>;
};
};
<T extends Struct<Struct.Fields> | object, R extends object = T extends Struct<...> ? RecursiveSimplifyMutable<...> : T>(pluginId: string, opts?: UsePluginDataOpts<...>): {
generatedId: () => Effect<string, never, never>;
select: () => Effect<PluginDataEntry<...> | undefined, Error, never>;
insert: (data: R) => Effect<PluginDataEntry<...>, Error, never>;
update: (data: R) => Effect<PluginDataEntry<...>, Error, never>;
};
};
initPluginDataCache: (BATCH_SIZE?: number | undefined) => Effect<void, DBCallbackFailure | DatabaseError, never>;
clearPluginDataCache: () => Effect<void, never, never>;
InferType: {
new <S extends Struct<...>, R = RecursiveSimplifyMutable<...>>(schema: S): {
readonly _Schema: S;
readonly $UsePluginData: S;
readonly $Insert: R;
};
};
}
PLUGINS
,
const POST: {
databaseEntry: {
pages: (pageData: OptionalId<string, {
readonly tags: string;
readonly id: string;
readonly description: string;
readonly slug: string;
readonly contentLang: string;
readonly updatedAt: string;
readonly package: string;
readonly title: string;
readonly showOnNav: boolean;
readonly publishedAt: string;
readonly heroImage: string | null | undefined;
readonly categories: string;
readonly authorId: string;
readonly contributorIds: string;
readonly showAuthor: boolean;
readonly showContributors: boolean;
readonly parentFolder: string | null | undefined;
readonly draft: boolean;
readonly augments: string;
}>, pageContent: CombinedInsertContent) => Effect<{
pageData: {
readonly id: string;
};
pageContent: {
readonly id: string;
};
}, DBCallbackFailure | DatabaseError, never>;
pageContent: (input: {
readonly id: string;
readonly contentId: string;
readonly contentLang: string;
readonly content: string;
}) => Effect<{
readonly id: string;
}, DBCallbackFailure | DatabaseError, never>;
tags: (tag: OptionalId<...>) => Effect<{
readonly id: number;
}, DBCallbackFailure | DatabaseError | GeneratorError, never>;
categories: (category: OptionalId<...>) => Effect<{
readonly id: number;
}, DBCallbackFailure | DatabaseError | GeneratorError, never>;
permissions: (userId: string, rank: "owner" | "admin" | "editor" | "visitor" | "unknown") => Effect<{
readonly user: string;
readonly rank: "owner" | "admin" | "editor" | "visitor" | "unknown";
}, DBCallbackFailure | DatabaseError, never>;
diffTracking: (data: OptionalId<...>) => Effect<{
readonly id: string;
readonly userId: string;
readonly pageMetaData: {
readonly [x: string]: unknown;
};
readonly pageId: string;
readonly timestamp: Date;
readonly pageContentStart: string;
readonly diff: string | null | undefined;
}, DBCallbackFailure | DatabaseError, never>;
folder: (data: OptionalId<...>) => Effect<{
readonly name: string;
readonly id: string;
readonly parent: string | null | undefined;
}, DBCallbackFailure | DatabaseError, never>;
};
databaseEntries: {
tags: (tags: OptionalId<...>[]) => Effect<{
readonly id: number;
}[], DBCallbackFailure | DatabaseError | GeneratorError, never>;
categories: (categories: OptionalId<...>[]) => Effect<{
readonly id: number;
}[], DBCallbackFailure | DatabaseError | GeneratorError, never>;
permissions: (permissions: {
userId: string;
rank: "owner" | "admin" | "editor" | "visitor" | "unknown";
}[]) => Effect<{
readonly user: string;
readonly rank: "owner" | "admin" | "editor" | "visitor" | "unknown";
}[], DBCallbackFailure | DatabaseError, never>;
pages: (pages: MultiPageInsert) => Effect<{
pageData: {
readonly id: string;
};
pageContent: {
readonly id: string;
};
}[], DBCallbackFailure | DatabaseError, never>;
};
folder: (data: OptionalId<...>) => Effect<{
readonly name: string;
readonly id: string;
readonly parent: string | null | undefined;
}, DBCallbackFailure | DatabaseError | FolderTreeError, never>;
page: (args_0: {
pageData: OptionalId<...>;
pageContent: CombinedInsertContent;
}) => Effect<CombinedPageData | undefined, ParseError | DBCallbackFailure | QueryParseError | QueryError | NotFoundError | FolderTreeError | CollectorError | PaginateError, never>;
}
POST
,
const resetTokenBucket: {
new: (userId: string) => Effect<{
readonly id: string;
readonly userId: string;
readonly token: string;
}, DBCallbackFailure | DatabaseError | GeneratorError, never>;
delete: (input: string) => Effect<DeleteResult[], DBCallbackFailure | DatabaseError, never>;
check: (token: string) => Effect<boolean, DBCallbackFailure | DatabaseError | GeneratorError, never>;
}
resetTokenBucket
,
const REST_API: {
tokens: {
get: (input: string) => Effect<readonly {
readonly key: string;
readonly id: string;
readonly description: string | null | undefined;
readonly userId: string;
readonly creationDate: Date;
}[], DBCallbackFailure | DatabaseError, never>;
new: (userId: string, description: string) => Effect<{
readonly key: string;
readonly id: string;
readonly description: string | null | undefined;
readonly userId: string;
readonly creationDate: Date;
}, DBCallbackFailure | DatabaseError | GeneratorError, never>;
delete: (input: {
readonly userId: string;
readonly tokenId: string;
}) => Effect<DeleteResult[], DBCallbackFailure | DatabaseError, never>;
verify: (key: string) => Effect<false | {
userId: string;
key: string;
rank: "owner" | "admin" | "editor" | "visitor" | "unknown";
}, DBCallbackFailure | DatabaseError, never>;
};
}
REST_API
,
const UPDATE: {
pageContent: (input: {
readonly id: string;
readonly contentId: string;
readonly contentLang: string;
readonly content: string;
}) => Effect<{
readonly id: string;
readonly contentId: string;
readonly contentLang: string;
readonly content: string;
}, DBCallbackFailure | DatabaseError, never>;
... 8 more ...;
page: {
byId: (pageId: string, data: {
pageData: {
readonly tags: string;
readonly id: string;
readonly description: string;
readonly slug: string;
readonly contentLang: string;
readonly updatedAt: string;
readonly package: string;
readonly title: string;
readonly showOnNav: boolean;
readonly publishedAt: string;
readonly heroImage: string | null | undefined;
readonly categories: string;
readonly authorId: string;
readonly contributorIds: string;
readonly showAuthor: boolean;
readonly showContributors: boolean;
readonly parentFolder: string | null | undefined;
readonly draft: boolean;
readonly augments: string;
};
pageContent: {
readonly id: string;
readonly contentId: string;
readonly contentLang: string;
readonly content: string;
};
}) => Effect<CombinedPageData | undefined, ParseError | DBCallbackFailure | QueryParseError | QueryError | NotFoundError | FolderTreeError | CollectorError | PaginateError, never>;
bySlug: (slug: string, data: {
pageData: {
readonly tags: string;
readonly id: string;
readonly description: string;
readonly slug: string;
readonly contentLang: string;
readonly updatedAt: string;
readonly package: string;
readonly title: string;
readonly showOnNav: boolean;
readonly publishedAt: string;
readonly heroImage: string | null | undefined;
readonly categories: string;
readonly authorId: string;
readonly contributorIds: string;
readonly showAuthor: boolean;
readonly showContributors: boolean;
readonly parentFolder: string | null | undefined;
readonly draft: boolean;
readonly augments: string;
};
pageContent: {
readonly id: string;
readonly contentId: string;
readonly contentLang: string;
readonly content: string;
};
}) => Effect<CombinedPageData | undefined, ParseError | DBCallbackFailure | DatabaseError | FolderTreeError | CollectorError | PaginateError, never>;
};
}
UPDATE
,
const UTIL: {
Collectors: {
collectCategories: (input: {
readonly [x: number]: number;
readonly length: number;
toString: {};
toLocaleString: {};
concat: {};
join: {};
slice: {};
indexOf: {};
lastIndexOf: {};
every: {};
some: {};
forEach: {};
map: {};
filter: {};
reduce: {};
reduceRight: {};
find: {};
findIndex: {};
entries: {};
keys: {};
values: {};
includes: {};
flatMap: {};
flat: {};
at: {};
findLast: {};
findLastIndex: {};
toReversed: {};
toSorted: {};
toSpliced: {};
with: {};
[Symbol.iterator]: {};
readonly [Symbol.unscopables]: {
readonly [x: number]: boolean | undefined;
readonly length?: boolean | undefined;
toString?: boolean | undefined;
toLocaleString?: boolean | undefined;
concat?: boolean | undefined;
join?: boolean | undefined;
slice?: boolean | undefined;
indexOf?: boolean | undefined;
lastIndexOf?: boolean | undefined;
every?: boolean | undefined;
some?: boolean | undefined;
forEach?: boolean | undefined;
map?: boolean | undefined;
filter?: boolean | undefined;
reduce?: boolean | undefined;
reduceRight?: boolean | undefined;
find?: boolean | undefined;
findIndex?: boolean | undefined;
entries?: boolean | undefined;
keys?: boolean | undefined;
values?: boolean | undefined;
includes?: boolean | undefined;
flatMap?: boolean | undefined;
flat?: boolean | undefined;
at?: boolean | undefined;
findLast?: boolean | undefined;
findLastIndex?: boolean | undefined;
toReversed?: boolean | undefined;
toSorted?: boolean | undefined;
toSpliced?: boolean | undefined;
with?: boolean | undefined;
[Symbol.iterator]?: boolean | undefined;
readonly [Symbol.unscopables]?: boolean | undefined;
};
}) => Effect<readonly {
readonly name: string;
readonly id: number;
readonly parent: number | null | undefined;
readonly description: string;
readonly slug: string;
readonly meta: {
readonly [x: string]: unknown;
};
}[], DBCallbackFailure | DatabaseError, never>;
collectTags: (input: {
readonly [x: number]: number;
readonly length: number;
toString: {};
toLocaleString: {};
concat: {};
join: {};
slice: {};
indexOf: {};
lastIndexOf: {};
every: {};
some: {};
forEach: {};
map: {};
filter: {};
reduce: {};
reduceRight: {};
find: {};
findIndex: {};
entries: {};
keys: {};
values: {};
includes: {};
flatMap: {};
flat: {};
at: {};
findLast: {};
findLastIndex: {};
toReversed: {};
toSorted: {};
toSpliced: {};
with: {};
[Symbol.iterator]: {};
readonly [Symbol.unscopables]: {
readonly [x: number]: boolean | undefined;
readonly length?: boolean | undefined;
toString?: boolean | undefined;
toLocaleString?: boolean | undefined;
concat?: boolean | undefined;
join?: boolean | undefined;
slice?: boolean | undefined;
indexOf?: boolean | undefined;
lastIndexOf?: boolean | undefined;
every?: boolean | undefined;
some?: boolean | undefined;
forEach?: boolean | undefined;
map?: boolean | undefined;
filter?: boolean | undefined;
reduce?: boolean | undefined;
reduceRight?: boolean | undefined;
find?: boolean | undefined;
findIndex?: boolean | undefined;
entries?: boolean | undefined;
keys?: boolean | undefined;
values?: boolean | undefined;
includes?: boolean | undefined;
flatMap?: boolean | undefined;
flat?: boolean | undefined;
at ...
UTIL
,
} =
const SDKCoreJs: {
AUTH: {
verifyEmail: {
get: (input: string) => Effect<{
readonly id: string;
readonly userId: string;
readonly token: string;
readonly expiresAt: Date;
} | undefined, DBCallbackFailure | DatabaseError, never>;
create: (userId: string) => Effect<{
readonly id: string;
readonly userId: string;
readonly token: string;
readonly expiresAt: Date;
}, DBCallbackFailure | DatabaseError | GeneratorError, never>;
delete: (input: string) => Effect<DeleteResult, DBCallbackFailure | DatabaseError, never>;
};
oAuth: {
create: (input: {
readonly providerUserId: string;
readonly provider: string;
readonly userId: string;
}) => Effect<{
readonly providerUserId: string;
readonly provider: string;
readonly userId: string;
}, DBCallbackFailure | DatabaseError, never>;
delete: (input: {
readonly userId: string;
readonly provider: string;
}) => AuthDeletionResponse;
searchByProviderId: (input: {
readonly providerUserId: string;
readonly userId: string;
}) => Effect<{
readonly providerUserId: string;
readonly provider: string;
readonly userId: string;
} | undefined, DBCallbackFailure | DatabaseError, never>;
searchProvidersForId: (input: {
readonly userId: string;
readonly providerId: string;
}) => Effect<{
readonly providerUserId: string;
readonly provider: string;
readonly userId: string;
} | undefined, DBCallbackFailure | DatabaseError, never>;
};
permission: {
currentStatus: (input: string) => Effect<{
readonly user: string;
readonly rank: "owner" | "admin" | "editor" | "visitor" | "unknown";
} | undefined, DBCallbackFailure | DatabaseError, never>;
};
session: {
create: (input: {
readonly id: string;
readonly userId: string;
readonly expiresAt: string;
}) => Effect<{
readonly id: string;
readonly userId: string;
readonly expiresAt: Date;
}, DBCallbackFailure | DatabaseError, never>;
getById: (input: string) => Effect<{
readonly id: string;
readonly userId: string;
readonly expiresAt: Date;
} | undefined, DBCallbackFailure | DatabaseError, never>;
sessionWithUser: (sessionId: string) => Effect<{
session: {
readonly id: string;
readonly userId: string;
readonly expiresAt: Date;
};
user: {
readonly name: string;
readonly id: string;
readonly url: string | null | undefined;
readonly email: string | null | undefined;
readonly avatar: string | null | undefined;
readonly username: string;
readonly password: string | null | undefined;
readonly updatedAt: Date;
readonly createdAt: Date;
readonly emailVerified: boolean;
readonly notifications: string | null | undefined;
};
} | undefined, DBCallbackFailure | DatabaseError, never>;
delete: (input: string) => AuthDeletionResponse;
update: (input: {
readonly id: string;
readonly newDate: {
toString: {};
toDateString: {};
toTimeString: {};
toLocaleString: {};
toLocaleDateString: {};
toLocaleTimeString: {};
valueOf: {};
getTime: {};
getFullYear: {};
getUTCFullYear: {};
getMonth: {};
getUTCMonth: {};
getDate: {};
getUTCDate: {};
getDay: {};
getUTCDay: {};
getHours: {};
getUTCHours: {};
getMinutes: {};
getUTCMinutes: {};
getSeconds: {};
getUTCSeconds: {};
getMilliseconds: {};
getUTCMilliseconds: {};
getTimezoneOffset: {};
setTime: {};
setMilliseconds ...

VanillaJS Version of the SDKCore. Most internal functions will still contain Effects, you can use runSDK from the 'studiocms:sdk' to run these as normal async functions

@example

import { SDKCoreJs, runSDK } from 'studiocms:sdk';
const pages = await runSDK(SDKCoreJs.GET.pages());

SDKCoreJs
;