Bell RPC メソッド
BellWorker はマルチチャネル通知配信を担当するサービスです。WorkerEntrypoint<Env> を継承し、31の RPC メソッドを公開します。
通知設定(ユーザー向け)
Section titled “通知設定(ユーザー向け)”getSettings
Section titled “getSettings”ユーザーの通知チャネル設定を取得します。
async getSettings(params: { readonly userId: string; readonly userType?: string;}): Promise<{ readonly channels: Record<string, readonly string[]>;}>updateSettings
Section titled “updateSettings”ユーザーの通知チャネル設定を更新します。
async updateSettings(params: { readonly userId: string; readonly userType: string; readonly channels: Record<string, readonly string[]>;}): Promise<{ readonly setting: NotificationSetting }>sendSettingsTestNotification
Section titled “sendSettingsTestNotification”テスト通知を送信します。
async sendSettingsTestNotification(params: { readonly userId: string; readonly userType?: string; readonly type?: string;}): Promise<{ readonly success: boolean; readonly message: string;}>listNotifications
Section titled “listNotifications”店舗の通知一覧を取得します。
async listNotifications(params: { readonly shopId: string; readonly limit?: number; readonly unreadOnly?: boolean;}): Promise<{ readonly notifications: readonly ShopNotification[];}>markNotificationAsRead
Section titled “markNotificationAsRead”個別の通知を既読にします。
async markNotificationAsRead(params: { readonly id: string;}): Promise<{ readonly success: boolean }>markAllAsRead
Section titled “markAllAsRead”店舗の全通知を既読にします。
async markAllAsRead(params: { readonly shopId: string;}): Promise<{ readonly success: boolean }>deleteNotification
Section titled “deleteNotification”通知を論理削除します。
async deleteNotification(params: { readonly id: string; readonly actionUserId?: string;}): Promise<{ readonly success: boolean }>deleteAllNotifications
Section titled “deleteAllNotifications”店舗の全通知を論理削除します。
async deleteAllNotifications(params: { readonly shopId: string; readonly actionUserId?: string;}): Promise<{ readonly success: boolean }>店舗通知設定
Section titled “店舗通知設定”getShopNotificationSettings
Section titled “getShopNotificationSettings”店舗の通知設定を一括取得します。PUSHデバイス・メール通知先・LINEアカウントを含みます。
async getShopNotificationSettings(params: { readonly shopId: string;}): Promise<{ readonly pushDevices: readonly ShopPushSubscription[]; readonly emailRecipients: readonly ShopEmailRecipient[]; readonly lineAccounts: readonly ShopLineAccount[];}>registerShopPushDevice
Section titled “registerShopPushDevice”店舗の PUSH デバイスを登録します。
async registerShopPushDevice(params: { readonly shopId: string; readonly endpoint: string; readonly p256dh: string; readonly auth: string; readonly deviceName?: string; readonly userAgent?: string; readonly registeredBy?: string; readonly registeredByName?: string;}): Promise<{ readonly success: boolean; readonly subscription: ShopPushSubscription;}>removeShopPushDevice
Section titled “removeShopPushDevice”async removeShopPushDevice(params: { readonly id: string }): Promise<{ readonly success: boolean }>updateShopPushCategories
Section titled “updateShopPushCategories”PUSH デバイスの通知カテゴリ設定を更新します。
async updateShopPushCategories(params: { readonly id: string; readonly categories: Record<string, boolean>;}): Promise<{ readonly success: boolean; readonly subscription: ShopPushSubscription;}>registerShopEmailRecipient
Section titled “registerShopEmailRecipient”店舗のメール通知先を登録します。
async registerShopEmailRecipient(params: { readonly shopId: string; readonly email: string; readonly name?: string; readonly registeredBy?: string; readonly registeredByName?: string;}): Promise<{ readonly success: boolean; readonly recipient: ShopEmailRecipient;}>removeShopEmailRecipient
Section titled “removeShopEmailRecipient”async removeShopEmailRecipient(params: { readonly id: string }): Promise<{ readonly success: boolean }>updateShopEmailCategories
Section titled “updateShopEmailCategories”メール通知先のカテゴリ設定を更新します。
async updateShopEmailCategories(params: { readonly id: string; readonly categories: Record<string, boolean>;}): Promise<{ readonly success: boolean; readonly recipient: ShopEmailRecipient;}>updateShopLineCategories
Section titled “updateShopLineCategories”LINE アカウントの通知カテゴリ設定を更新します。
async updateShopLineCategories(params: { readonly id: string; readonly categories: Record<string, boolean>;}): Promise<{ readonly success: boolean; readonly account: ShopLineAccount;}>sendShopTestNotification
Section titled “sendShopTestNotification”店舗の特定チャネルにテスト通知を送信します。
async sendShopTestNotification(params: { readonly shopId: string; readonly channel: 'push' | 'email' | 'line'; readonly targetId: string;}): Promise<{ readonly success: boolean; readonly error?: string;}>PUSH サブスクリプション(汎用)
Section titled “PUSH サブスクリプション(汎用)”getVapidKey
Section titled “getVapidKey”VAPID 公開鍵を取得します。
async getVapidKey(): Promise<{ readonly publicKey: string }>subscribe
Section titled “subscribe”PUSH 通知サブスクリプションを登録します。
async subscribe(params: { readonly userId: string; readonly userType: string; readonly endpoint: string; readonly p256dh: string; readonly auth: string; readonly deviceName?: string; readonly settings?: Record<string, unknown>; readonly shopId?: string;}): Promise<{ readonly success: boolean; readonly subscription: PushSubscription;}>unsubscribe
Section titled “unsubscribe”async unsubscribe(params: { readonly endpoint: string }): Promise<{ readonly success: boolean }>listSubscriptions
Section titled “listSubscriptions”async listSubscriptions(params: { readonly userId: string }): Promise<{ readonly subscriptions: readonly PushSubscription[] }>updateSubscriptionSettings
Section titled “updateSubscriptionSettings”async updateSubscriptionSettings(params: { readonly id: string; readonly settings: Record<string, boolean>;}): Promise<{ readonly success: boolean }>deleteSubscription
Section titled “deleteSubscription”async deleteSubscription(params: { readonly id: string }): Promise<{ readonly success: boolean }>メッセージ送信
Section titled “メッセージ送信”sendPushMessage
Section titled “sendPushMessage”PUSH メッセージを作成・送信します。scheduledAt に基づき即時送信またはスケジュール予約します。
async sendPushMessage(params: { readonly targetUserId: string; readonly targetType: string; readonly title: string; readonly body: string; readonly url?: string; readonly priority?: string; readonly scheduledAt: string; readonly createdBy: string;}): Promise<{ readonly success: boolean; readonly message: PushMessage; readonly queued: boolean; readonly scheduledForLater: boolean;}>listPushMessages
Section titled “listPushMessages”PUSH メッセージの送信ログを取得します。
async listPushMessages(params?: { readonly createdBy?: string; readonly limit?: number;}): Promise<{ readonly messages: readonly PushMessage[];}>sendEmailRpc
Section titled “sendEmailRpc”メールを送信します(Resend API 経由)。
async sendEmailRpc(params: { readonly to: string; readonly subject: string; readonly text?: string; readonly html?: string;}): Promise<{ readonly success: boolean; readonly error?: string; readonly messageId?: string;}>