コンテンツにスキップ

検索はプロダクションビルドでのみ利用可能です。 ローカルでテストするには、サイトをビルドしてプレビューしてください。

Bell RPC メソッド

BellWorker はマルチチャネル通知配信を担当するサービスです。WorkerEntrypoint<Env> を継承し、31の RPC メソッドを公開します。


ユーザーの通知チャネル設定を取得します。

async getSettings(params: {
readonly userId: string;
readonly userType?: string;
}): Promise<{
readonly channels: Record<string, readonly string[]>;
}>

ユーザーの通知チャネル設定を更新します。

async updateSettings(params: {
readonly userId: string;
readonly userType: string;
readonly channels: Record<string, readonly string[]>;
}): Promise<{ readonly setting: NotificationSetting }>

テスト通知を送信します。

async sendSettingsTestNotification(params: {
readonly userId: string;
readonly userType?: string;
readonly type?: string;
}): Promise<{
readonly success: boolean;
readonly message: string;
}>

店舗の通知一覧を取得します。

async listNotifications(params: {
readonly shopId: string;
readonly limit?: number;
readonly unreadOnly?: boolean;
}): Promise<{
readonly notifications: readonly ShopNotification[];
}>

個別の通知を既読にします。

async markNotificationAsRead(params: {
readonly id: string;
}): Promise<{ readonly success: boolean }>

店舗の全通知を既読にします。

async markAllAsRead(params: {
readonly shopId: string;
}): Promise<{ readonly success: boolean }>

通知を論理削除します。

async deleteNotification(params: {
readonly id: string;
readonly actionUserId?: string;
}): Promise<{ readonly success: boolean }>

店舗の全通知を論理削除します。

async deleteAllNotifications(params: {
readonly shopId: string;
readonly actionUserId?: string;
}): Promise<{ readonly success: boolean }>

店舗の通知設定を一括取得します。PUSHデバイス・メール通知先・LINEアカウントを含みます。

async getShopNotificationSettings(params: {
readonly shopId: string;
}): Promise<{
readonly pushDevices: readonly ShopPushSubscription[];
readonly emailRecipients: readonly ShopEmailRecipient[];
readonly lineAccounts: readonly ShopLineAccount[];
}>

店舗の 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;
}>
async removeShopPushDevice(params: { readonly id: string }): Promise<{ readonly success: boolean }>

PUSH デバイスの通知カテゴリ設定を更新します。

async updateShopPushCategories(params: {
readonly id: string;
readonly categories: Record<string, boolean>;
}): Promise<{
readonly success: boolean;
readonly subscription: ShopPushSubscription;
}>

店舗のメール通知先を登録します。

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;
}>
async removeShopEmailRecipient(params: { readonly id: string }): Promise<{ readonly success: boolean }>

メール通知先のカテゴリ設定を更新します。

async updateShopEmailCategories(params: {
readonly id: string;
readonly categories: Record<string, boolean>;
}): Promise<{
readonly success: boolean;
readonly recipient: ShopEmailRecipient;
}>

LINE アカウントの通知カテゴリ設定を更新します。

async updateShopLineCategories(params: {
readonly id: string;
readonly categories: Record<string, boolean>;
}): Promise<{
readonly success: boolean;
readonly account: ShopLineAccount;
}>

店舗の特定チャネルにテスト通知を送信します。

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 サブスクリプション(汎用)”

VAPID 公開鍵を取得します。

async getVapidKey(): Promise<{ readonly publicKey: string }>

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;
}>
async unsubscribe(params: { readonly endpoint: string }): Promise<{ readonly success: boolean }>
async listSubscriptions(params: { readonly userId: string }): Promise<{ readonly subscriptions: readonly PushSubscription[] }>
async updateSubscriptionSettings(params: {
readonly id: string;
readonly settings: Record<string, boolean>;
}): Promise<{ readonly success: boolean }>
async deleteSubscription(params: { readonly id: string }): Promise<{ readonly success: boolean }>

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;
}>

PUSH メッセージの送信ログを取得します。

async listPushMessages(params?: {
readonly createdBy?: string;
readonly limit?: number;
}): Promise<{
readonly messages: readonly PushMessage[];
}>

メールを送信します(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;
}>