virtuals/sdk/modules/notificationSettings
Classes
Section titled “Classes”SDKCore_NotificationSettings
Section titled “SDKCore_NotificationSettings”Defined in: studiocms/packages/studiocms/src/virtuals/sdk/modules/notificationSettings.ts:34^
Extends
Section titled “Extends”any
Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new SDKCore_NotificationSettings(): SDKCore_NotificationSettings
Returns
Section titled “Returns”Inherited from
Section titled “Inherited from”Effect.Service<SDKCore_NotificationSettings>()( 'studiocms/sdk/SDKCore/modules/notificationSettings', { dependencies: [AstroDB.Default], effect: genLogger('studiocms/sdk/SDKCore/modules/notificationSettings/effect')(function () { const dbService = yield AstroDB;
const notificationSettings = { site: { / Retrieves the site-wide notification settings. @returns An Effect that resolves to the current notification settings. @throws SDKCoreError when a database error occurs. / get: () => Effect.gen(function () { const data = yield dbService.execute((db) => db .select() .from(tsNotificationSettings) .where(eq(tsNotificationSettings.id, CMSNotificationSettingsId)) .get() );
if (!data) { return yield dbService.execute((db) => db .insert(tsNotificationSettings) .values(NotificationSettingsDefaults) .returning() .get() ); }
return data; }).pipe( Effect.catchTags({ 'studiocms/sdk/effect/db/LibSQLDatabaseError': (cause) => Effect.fail( new SDKCoreError({ type: 'LibSQLDatabaseError', cause: new StudioCMS_SDK_Error( notificationSettings.site.get Error: ${cause} ), }) ), }) ),
/ Updates the site-wide notification settings. @param settings - The new notification settings to be updated. @returns An Effect that resolves to the updated settings. @throws SDKCoreError when a database error occurs. / update: dbService.makeQuery((ex, settings: tsNotificationSettingsInsert) => ex((db) => db .update(tsNotificationSettings) .set(settings) .where(eq(tsNotificationSettings.id, CMSNotificationSettingsId)) .returning() .get() ).pipe( Effect.catchTags({ 'studiocms/sdk/effect/db/LibSQLDatabaseError': (cause) => Effect.fail( new SDKCoreError({ type: 'LibSQLDatabaseError', cause: new StudioCMS_SDK_Error( notificationSettings.site.update Error: ${cause} ), }) ), }) ) ), }, };
return notificationSettings; }), }).constructor