virtuals/sdk/modules/init
Classes
Section titled “Classes”SDKCore_INIT
Section titled “SDKCore_INIT”Defined in: studiocms/packages/studiocms/src/virtuals/sdk/modules/init.ts:29^
Effectful service for initializing core StudioCMS modules.
Remarks
Section titled “Remarks”This service provides initialization routines for the StudioCMS system, including setting up the site configuration and ensuring the existence of the ghost user.
Example
Section titled “Example”const init = yield* SDKCore_INIT;yield* init.siteConfig({ ... });yield* init.ghostUser();
Service
Section titled “Service”- Depends on AstroDB and SDKCore_AUTH services.
Throws
Section titled “Throws”Throws if database errors occur during initialization.
Extends
Section titled “Extends”any
Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new SDKCore_INIT(): SDKCore_INIT
Returns
Section titled “Returns”Inherited from
Section titled “Inherited from”Effect.Service<SDKCore_INIT>()( 'studiocms/sdk/SDKCore/modules/init', { dependencies: [AstroDB.Default, SDKCore_AUTH.Default], effect: genLogger('studiocms/sdk/SDKCore/modules/init/effect')(function () { const [dbService, AUTH] = yield Effect.all([AstroDB, SDKCore_AUTH]);
const INIT = { / Initializes the StudioCMS SiteConfig table with the provided configuration.
@param config - The configuration to insert into the SiteConfig table. @returns A promise that resolves to the inserted site configuration. @throws {StudioCMS_SDK_Error} If an error occurs while creating the site configuration. / siteConfig: (config: SiteConfig) => dbService .execute((db) => db .insert(tsSiteConfig) .values({ ...config, id: CMSSiteConfigId }) .returning() .get() ) .pipe( Effect.catchTags({ 'studiocms/sdk/effect/db/LibSQLDatabaseError': (cause) => Effect.fail( new SDKCoreError({ type: 'LibSQLDatabaseError', cause: new StudioCMS_SDK_Error(INIT.siteConfig Error: ${cause}), }) ), }) ), / 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.
@returns A promise that resolves to the ghost user record. @throws {StudioCMS_SDK_Error} If an error occurs while creating the ghost user. / ghostUser: () => Effect.gen(function () { const ghostUserRecord = yield AUTH.user.ghost.get(); if (!ghostUserRecord) { return yield AUTH.user.ghost.create(); } return ghostUserRecord; }), };
return INIT; }), }).constructor