コンテンツにスキップ

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

Vintage RPC メソッド

VintageWorker は連絡先・グループ・ラベル・ブラックリスト管理を担当するサービスです。WorkerEntrypoint<Env> を継承し、37の RPC メソッドを公開します。


連絡先一覧をカーソルページネーションで取得します。各種フィルタリングに対応。

async listContacts(params: {
readonly shopId: string;
readonly index?: string;
readonly userType?: string;
readonly tag?: string;
readonly groupId?: string;
readonly search?: string;
readonly cursor?: string;
readonly limit?: number;
}): Promise<{
readonly contacts: readonly Contact[];
readonly nextCursor: string | null;
readonly hasMore: boolean;
}>

連絡先の詳細を取得します。purelovers 情報、チャットNG状態、マージ候補を含みます。

async getContact(params: {
readonly id: string;
readonly shopId: string;
}): Promise<{ readonly contact: ContactDetail }>

連絡先のアバター画像を取得します。

async getContactAvatar(params: {
readonly id: string;
readonly shopId: string;
}): Promise<{
readonly image: string | null;
readonly isPurelovers: boolean;
}>

店舗の全連絡先で使用されているタグ一覧を取得します。

async getContactTags(params: {
readonly shopId: string;
}): Promise<{ readonly tags: readonly string[] }>

連絡先を作成します。purelovers 未連携の場合は自動的に NO_PURELOVERS_USER チャットNG を設定します。

async createContact(params: {
readonly shopId: string;
readonly name: string;
readonly index: string;
readonly phones?: readonly string[];
readonly emails?: readonly string[];
readonly tags?: readonly string[];
readonly userType: string;
readonly groupIds?: readonly string[];
readonly memo?: string;
}): Promise<{ readonly contact: Contact }>

連絡先を更新します。

async updateContact(params: {
readonly id: string;
readonly shopId: string;
readonly name?: string;
readonly index?: string;
readonly memo?: string;
readonly phones?: readonly string[];
readonly emails?: readonly string[];
readonly tags?: readonly string[];
readonly userType?: string;
readonly groupIds?: readonly string[];
}): Promise<{ readonly contact: Contact }>

連絡先を削除します。

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

2つの連絡先をマージします。電話番号・メール・タグ・グループ・メモが統合されます。

async mergeContacts(params: {
readonly id: string;
readonly targetContactId: string;
readonly shopId: string;
}): Promise<{ readonly contact: Contact }>

addContactToGroup / removeContactFromGroup

Section titled “addContactToGroup / removeContactFromGroup”

連絡先をグループに追加/削除します。

async addContactToGroup(params: {
readonly id: string;
readonly groupId: string;
readonly shopId: string;
}): Promise<{ readonly success: boolean; readonly groupIds: readonly string[] }>
async removeContactFromGroup(params: {
readonly id: string;
readonly groupId: string;
readonly shopId: string;
}): Promise<{ readonly success: boolean; readonly groupIds: readonly string[] }>

連絡先のチャットNGステータスを更新/作成し、履歴を記録します。

async updateContactChatNg(params: {
readonly id: string;
readonly shopId: string;
readonly ngType: string;
readonly isActive: boolean;
readonly reason?: string;
}): Promise<{ readonly chatNg: ContactChatNg }>

チャットNGの変更履歴を取得します。

async getContactChatNgHistory(params: {
readonly id: string;
readonly shopId: string;
}): Promise<{ readonly history: readonly ChatNgHistory[] }>

グループ定義は KV (CONTACT_GROUPS) に保存されます。

async listGroups(params: { readonly shopId: string }): Promise<{ readonly groups: readonly Group[] }>
async getGroup(params: { readonly id: string; readonly shopId: string }): Promise<{ readonly group: Group }>
async createGroup(params: {
readonly shopId: string;
readonly name: string;
readonly icon: string;
readonly color: string;
readonly textColor?: string;
readonly criteria?: Record<string, unknown>;
readonly order: number;
}): Promise<{ readonly group: Group }>
async updateGroup(params: {
readonly id: string;
readonly shopId: string;
readonly name?: string;
readonly icon?: string;
readonly color?: string;
readonly textColor?: string;
readonly criteria?: Record<string, unknown>;
readonly order?: number;
}): Promise<{ readonly group: Group }>
async deleteGroup(params: { readonly id: string; readonly shopId: string }): Promise<{ readonly success: boolean }>
async reorderGroups(params: {
readonly shopId: string;
readonly groupIds: readonly string[];
}): Promise<{ readonly success: boolean }>

async listLabels(params: { readonly shopId: string }): Promise<{ readonly labels: readonly Label[] }>

ラベルを作成または更新(UPSERT)します。

async createLabel(params: {
readonly id: string;
readonly shopId: string;
readonly name: string;
readonly color?: string;
readonly description?: string;
readonly logic?: 'AND' | 'OR';
readonly tags?: readonly string[];
readonly labels?: readonly string[];
}): Promise<{ readonly label: Label }>
async deleteLabel(params: { readonly id: string; readonly shopId: string }): Promise<{ readonly success: boolean }>

Vintage は独自のチャットルーム操作メソッドも持ちます。Fizz のチャットとは独立して、連絡先管理の文脈でチャットデータにアクセスします。

listChatRooms / getChatRoom / createChatRoom

Section titled “listChatRooms / getChatRoom / createChatRoom”
async listChatRooms(params: { readonly shopId: string; readonly userId: string; readonly userType: string; readonly cursor?: string; readonly limit?: number }): Promise<PaginatedResult>
async getChatRoom(params: { readonly roomId: string }): Promise<{ readonly chatRoom: ChatRoom }>
async createChatRoom(params: { readonly shopId: string; readonly contactId: string }): Promise<{ readonly chatRoom: ChatRoom }>
async sendMessage(params: { readonly roomId: string; readonly senderId: string; readonly senderType: string; readonly content: string; readonly messageType?: string; readonly displayDays?: number; readonly metadata?: Record<string, unknown> }): Promise<{ readonly message: ChatMessage }>
async getMessages(params: { readonly roomId: string; readonly cursor?: string; readonly limit?: number }): Promise<PaginatedResult>
async markAsRead(params: { readonly roomId: string; readonly userId: string; readonly userType: string }): Promise<{ readonly success: boolean; readonly lastReadAt: Date }>

指定した連絡先リストにメッセージを一括送信します。

async broadcastMessages(params: {
readonly shopId: string;
readonly content: string;
readonly contactIds: readonly string[];
readonly messageType?: string;
readonly displayDays?: number;
}): Promise<{
readonly success: boolean;
readonly sentCount: number;
readonly sentAt: string;
}>
async deleteChatRoom(params: { readonly roomId: string }): Promise<{ readonly success: boolean }>

店舗固有とグローバルの両方のブラックリストを返します。

async listDomainBlacklist(params: {
readonly shopId: string;
}): Promise<{
readonly domains: readonly DomainBlacklist[];
readonly globalDomains: readonly GlobalDomainBlacklist[];
}>

createDomainBlacklist / deleteDomainBlacklist

Section titled “createDomainBlacklist / deleteDomainBlacklist”
async createDomainBlacklist(params: { readonly shopId: string; readonly domain: string; readonly createdBy: string }): Promise<{ readonly domain: DomainBlacklist }>
async deleteDomainBlacklist(params: { readonly id: string; readonly shopId: string }): Promise<{ readonly success: boolean }>

listGlobalDomainBlacklist / createGlobalDomainBlacklist / deleteGlobalDomainBlacklist

Section titled “listGlobalDomainBlacklist / createGlobalDomainBlacklist / deleteGlobalDomainBlacklist”
async listGlobalDomainBlacklist(): Promise<{ readonly domains: readonly GlobalDomainBlacklist[] }>
async createGlobalDomainBlacklist(params: { readonly domain: string; readonly reason?: string; readonly createdBy: string }): Promise<{ readonly domain: GlobalDomainBlacklist }>
async deleteGlobalDomainBlacklist(params: { readonly id: string }): Promise<{ readonly success: boolean }>

async getShop(params: { readonly shopId: string }): Promise<{ readonly shop: Shop }>
async updateWelcomeMessage(params: {
readonly shopId: string;
readonly welcomeMessage: string | null;
}): Promise<{ readonly success: boolean }>