콘텐츠로 이동

virtuals/sdk/modules/notificationSettings

이 콘텐츠는 아직 번역되지 않았습니다.

Defined in: studiocms/packages/studiocms/src/virtuals/sdk/modules/notificationSettings.ts:34^

  • any

new SDKCore_NotificationSettings(): SDKCore_NotificationSettings

SDKCore_NotificationSettings

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