🔍 チャットスキーマ
チャットスキーマは、Nodeblocksアプリケーションでチャットデータのバリデーション用のJSON Schema定義を提供します。これらのスキーマはデータの整合性を確保し、チャット関連のAPIエンドポイントの明確な契約を提供します。
🎯 概要
チャットスキーマは以下の目的で設計されています:
- チャットデータのバリデーション - 処理前の検証
- リアルタイムメッセージングのサポート - ユーザー間の通信
- チャネル管理の処理 - ユーザーサブスクリプション
- メッセージ検索の有効化 - フィルタリング機能
- チャネル権限の提供 - アクセス制御
- リアルタイム通知のサポート - 更新
📋 チャットスキーマタイプ
ChatChannelIcon
チャットチャネルアイコンのメタデータ用のTypeScript型。
目的: データベースに保存されるチャネルアイコンファイル情報の構造を定義
Type Definition:
type ChatChannelIcon = {
objectId: string; // Unique identifier for the file in storage
type: string; // MIME type of the icon file (e.g., 'image/png')
}
使用例:
import { ChatChannelIcon } from '@nodeblocks/backend-sdk';
const channelIcon: ChatChannelIcon = {
objectId: 'icon-uuid-123',
type: 'image/png'
};
チャネルスキーマ
チャネル管理用のコアチャットチャネル構造。
メッセージスキーマ
リアルタイム通信用のチャットメッセージ構造。
サブスクリプションスキーマ
チャネルアクセス制御用のユーザーサブスクリプション構造。
🔧 利用可能なチャットスキーマ
📺 チャネルスキーマ
chatChannelSchema
コアチャネルフィールドを持つベースチャットチャネルスキーマ。
目的: チャット機能の基本的なチャネル構造を定義
スキーマ詳細:
- Type:
object - 必須フィールド: なし(ベーススキーマ)
- Additional Properties:
false(strict validation) - プロパティ:
name?: string- チャネル名ownerId?: string- チャネル所有者のアイデンティティIDicon?: ChatChannelIcon | null- チャネルアイコンファイルのメタデータ(objectIdとtype)またはnull
使用例:
import { schemas } from '@nodeblocks/backend-sdk';
const { chatChannelSchema } = schemas;
const validate = ajv.compile(chatChannelSchema as SchemaDefinition);
const isValid = validate({
name: 'General Chat',
ownerId: 'identity123'
});
createChatChannelSchema
必須のnameとownerを持つチャットチャネル作成スキーマ。
目的: 作成時のチャネルデータをバリデーション
スキーマ詳細:
- Type:
object - 必須フィールド:
name,ownerId - Optional Fields:
icon - Additional Properties:
false(strict validation) - Content-Type:
application/json - リクエストボディ:
required
使用例:
import { schemas } from '@nodeblocks/backend-sdk';
const { createChatChannelSchema } = schemas;
const schema = createChatChannelSchema({});
const validate = ajv.compile(schema.schemas as SchemaDefinition);
const isValid = validate({
name: 'General Chat',
ownerId: 'user123'
});
updateChatChannelSchema
チャネル変更用のオプションフィールドを持つチャットチャネル更新スキーマ。
目的: 部分的なチャネルデータ更新をバリデーション
スキーマ詳細:
- Type:
object - 必須フィールド: なし(すべてのフィールドがオプション)
- Additional Properties:
false(strict validation) - Content-Type:
application/json - パラメータ:
channelId(path parameter) - リクエストボディ:
required - Optional Properties:
name?: string- 更新されたチャネル名icon?: ChatChannelIcon | null- 更新されたチャネルアイコンまたはnullでアイコンを削除
使用例:
import { schemas } from '@nodeblocks/backend-sdk';
const { updateChatChannelSchema } = schemas;
const schema = updateChatChannelSchema({});
const validate = ajv.compile(schema.schemas as SchemaDefinition);
const isValid = validate({ name: 'Updated Channel Name' });
getChatChannelSchema
単一チャネル取得用のチャットチャネル取得スキーマ。
目的: 特定のチャットチャネル取得リクエストをバリデーション
スキーマ詳細:
- パラメータ:
channelId(path parameter) - 目的: 特定のチャットチャネル取得リクエストをバリデーション
使用例:
import { schemas } from '@nodeblocks/backend-sdk';
const { getChatChannelSchema } = schemas;
const schema = getChatChannelSchema({});
const validate = ajv.compile(schema.schemas as SchemaDefinition);
const isValid = validate({ channelId: 'channel123' });
deleteChatChannelSchema
チャネル削除用のチャットチャネル削除スキーマ。
目的: 特定のチャットチャネル削除リクエストをバリデーション
スキーマ詳細:
- パラメータ:
channelId(path parameter) - 目的: 特定のチャットチャネル削除リクエストをバリデーション
使用例:
import { schemas } from '@nodeblocks/backend-sdk';
const { deleteChatChannelSchema } = schemas;
const schema = deleteChatChannelSchema({});
const validate = ajv.compile(schema.schemas as SchemaDefinition);
const isValid = validate({ channelId: 'channel123' });
findChatChannelsSchema
フィルタリングとページネーション付きチャネル検索用のチャットチャネル検索スキーマ。
目的: チャットチャネルの検索とページネーションリクエストをバリデーション
スキーマ詳細:
- クエリパラメータ:
name?: string- チャネル名でフィルタownerId?: string- 所有者のアイデンティティでフィルタpage?: number- ページネーションのページ番号limit?: number- ページネーションの制限
- 目的: チャットチャネルの検索とページネーションリクエストをバリデーション
使用例:
import { schemas } from '@nodeblocks/backend-sdk';
const { findChatChannelsSchema } = schemas;
const schema = findChatChannelsSchema({});
const validate = ajv.compile(schema.schemas as SchemaDefinition);
const isValid = validate({ name: 'General', page: 1, limit: 10 });
getChannelMessagesSchema
パスパラメータバリデーション付きチャネルメッセージ取得スキーマ。
目的: 特定チャネル内のすべてのメッセージ取得のGETリクエストをバリデーション
Schema Structure:
{
channelId: string; // required - channel identifier from URL path
}
スキーマ詳細:
- パラメータ:
channelId(path parameter, required) - 目的: メッセージ取得のためのパス内のチャネルIDの存在をバリデーション
使用例:
import { schemas } from '@nodeblocks/backend-sdk';
const { getChannelMessagesSchema } = schemas;
// Apply to feature composition:
export const getChannelMessagesFeature = compose(
getChannelMessagesSchema,
getChannelMessagesRoute
);
パスパラメータ:
| Parameter | Type | Required | Description |
|---|---|---|---|
channelId | string | ✅ | Channel identifier |
💬 メッセージスキーマ
chatMessageSchema
コアメッセージフィールドを持つベースチャットメッセージスキーマ。
目的: チャット機能の基本的なメッセージ構造を定義
スキーマ詳細:
- Type:
object - 必須フィールド: なし(ベーススキーマ)
- Additional Properties:
false(strict validation) - プロパティ:
content?: string- メッセージ内容senderId?: string- メッセージ送信者のアイデンティティIDtitle?: string- メッセージタイトル
使用例:
import { schemas } from '@nodeblocks/backend-sdk';
const { chatMessageSchema } = schemas;
const validate = ajv.compile(chatMessageSchema as SchemaDefinition);
const isValid = validate({
content: 'Hello world!',
senderId: 'identity123',
title: 'Greeting'
});
chatMessageAttachmentSchema
ファイル参照とタイプバリデーション付きチャットメッセージ添付スキーマ。
目的: チャットメッセージ内の個別の添付オブジェクトをバリデーション
スキーマ詳細:
- Type:
object - 必須フィールド:
objectId(UUID format),type(string) - Additional Properties:
false(strict validation)
プロパティ:
objectId: string- ストレージ内の添付ファイルへのUUID参照type: string- MIMEタイプまたはファイルカテゴリ
TypeScript Types:
type ChatMessageAttachment = {
objectId: string;
type: string;
};
type NormalizedChatMessageAttachment = {
url: string; // Signed URL after normalization
type: string;
};
使用例:
import { schemas } from '@nodeblocks/backend-sdk';
const attachment: ChatMessageAttachment = {
objectId: '550e8400-e29b-41d4-a716-446655440000',
type: 'image/png'
};
createChatMessageAttachmentSchema
必須ファイル参照とタイプバリデーション付きチャットメッセージ添付作成スキーマ。
目的: 既存メッセージにファイルを追加する際の添付作成リクエストをバリデーション
スキーマ詳細:
- Type:
object - 必須フィールド:
objectId(UUID format),type(string) - Additional Properties:
false(strict validation) - Content-Type:
application/json - リクエストボディ:
required
プロパティ:
objectId: string- ストレージ内のアップロードされたファイルへのUUID参照type: string- MIMEタイプまたはファイルカテゴリ
使用例:
import { schemas } from '@nodeblocks/backend-sdk';
const { createChatMessageAttachmentSchema } = schemas;
const schema = createChatMessageAttachmentSchema({});
const validate = ajv.compile(schema.schemas as SchemaDefinition);
const isValid = validate({
objectId: '550e8400-e29b-41d4-a716-446655440000',
type: 'image/png'
});
リクエスト例:
POST /messages/:messageId/attachments
Content-Type: application/json
{
"objectId": "550e8400-e29b-41d4-a716-446655440000",
"type": "image/png"
}
主な機能:
- objectIdが有効なUUIDであることをバリデーション
- objectIdとtypeフィールドの両方が必須
createChatMessageAttachmentブロック関数と共に使用- 作成時に添付ファイルは自動的にベースエンティティフィールドを受け取る
deleteChatMessageAttachmentSchema
パスパラメータバリデーション付きチャットメッセージ添付削除スキーマ。
目的: メッセージIDと添付IDを持つ添付削除リクエストをバリデーション
スキーマ詳細:
- Type: Path parameters
- 必須パラメータ:
messageId(string),attachmentId(string) - Method: DELETE
パスパラメータ:
messageId: string- 添付を含むチャットメッセージのUUIDattachmentId: string- 削除する添付のUUID
使用例:
import { schemas } from '@nodeblocks/backend-sdk';
const { deleteChatMessageAttachmentSchema } = schemas;
// Schema validates path parameters
const schema = deleteChatMessageAttachmentSchema({});
リクエスト例:
DELETE /messages/550e8400-e29b-41d4-a716-446655440000/attachments/660e8400-e29b-41d4-a716-446655440001
主な機能:
- messageIdとattachmentIdの両方のパスパラメータをバリデーション
deleteChatMessageAttachmentブロック関数と共に使用- データベースから添付を削除し、ストレージからファイルを削除
- 成功時に204 No Contentを返す
createChatMessageSchema
必須のcontent、sender、channelを持つチャットメッセージ作成スキーマ。
目的: 作成時のメッセージデータをバリデーション
スキーマ詳細:
- Type:
object - 必須フィールド:
content,senderId,channelId - Optional Fields:
title - Additional Properties:
false(strict validation) - Content-Type:
application/json - リクエストボディ:
required
使用例:
import { schemas } from '@nodeblocks/backend-sdk';
const { createChatMessageSchema } = schemas;
const schema = createChatMessageSchema({});
const validate = ajv.compile(schema.schemas as SchemaDefinition);
const isValid = validate({
content: 'Hello world!',
senderId: 'user123',
channelId: 'channel456'
});
updateChatMessageSchema
メッセージ変更用のオプションフィールドを持つチャットメッセージ更新スキーマ。
目的: 部分的なメッセージデータ更新をバリデーション
スキーマ詳細:
- Type:
object - 必須フィールド: なし(すべてのフィールドがオプション)
- Additional Properties:
false(strict validation) - Content-Type:
application/json - パラメータ:
messageId(path parameter) - リクエストボディ:
required
使用例:
import { schemas } from '@nodeblocks/backend-sdk';
const { updateChatMessageSchema } = schemas;
const schema = updateChatMessageSchema({});
const validate = ajv.compile(schema.schemas as SchemaDefinition);
const isValid = validate({ content: 'Updated message content' });
getChatMessageSchema
単一メッセージ取得用のチャットメッセージ取得スキーマ。
目的: 特定のチャットメッセージ取得リクエストをバリデーション
スキーマ詳細:
- パラメータ:
messageId(path parameter) - 目的: 特定のチャットメッセージ取得リクエストをバリデーション
使用例:
import { schemas } from '@nodeblocks/backend-sdk';
const { getChatMessageSchema } = schemas;
const schema = getChatMessageSchema({});
const validate = ajv.compile(schema.schemas as SchemaDefinition);
const isValid = validate({ messageId: 'message123' });
deleteChatMessageSchema
メッセージ削除用のチャットメッセージ削除スキーマ。
目的: 特定のチャットメッセージ削除リクエストをバリデーション
スキーマ詳細:
- パラメータ:
messageId(path parameter) - 目的: 特定のチャットメッセージ削除リクエストをバリデーション
使用例:
import { schemas } from '@nodeblocks/backend-sdk';
const { deleteChatMessageSchema } = schemas;
const schema = deleteChatMessageSchema({});
const validate = ajv.compile(schema.schemas as SchemaDefinition);
const isValid = validate({ messageId: 'message123' });
findChatMessagesSchema
フィルタリングとページネーション付きメッセージ検索用のチャットメッセージ検索スキーマ。
目的: 特定チャネル内のチャットメッセージの検索とページネーションリクエストをバリデーション
スキーマ詳細:
- クエリパラメータ:
channelId: string- チャネルでフィルタ(必須)content?: string- メッセージ内容でフィルタ(オプション)senderId?: string- 送信者でフィルタ(オプション)title?: string- メッセージタイトルでフィルタ(オプション)page?: number- ページネーションのページ番号limit?: number- ページネーションの制限
- 目的: チャットメッセージの検索とページネーションリクエストをバリデーション
使用例:
import { schemas } from '@nodeblocks/backend-sdk';
const { findChatMessagesSchema } = schemas;
const schema = findChatMessagesSchema({});
const validate = ajv.compile(schema.schemas as SchemaDefinition);
const isValid = validate({
channelId: 'channel123',
senderId: 'user123',
page: 1,
limit: 10
});
channelIdQueryParameter
WebSocketチャットメッセージルーティング用のチャネルIDクエリパラメータ。
目的: リアルタイムメッセージストリーミング用のWebSocket接続で使用されるchannelIdクエリパラメータを定義
Parameter Details:
- Location:
query(URL query string) - Name:
channelId - Required:
true - Type:
string
使用例:
// Used in WebSocket schema composition:
export const streamChatMessagesSchema = withSchema({
parameters: [channelIdQueryParameter]
});
// Client WebSocket connection:
// ws://localhost:3000/messages/listen?channelId=channel123
クエリ文字列の例:
?channelId=550e8400-e29b-41d4-a716-446655440000
streamChatMessagesSchema
WebSocket接続用のchannelIdクエリパラメータバリデーション付きチャットメッセージストリーミングスキーマ。
目的: リアルタイムチャットメッセージストリーミング用のWebSocket接続リクエストをバリデーション
スキーマ詳細:
- Protocol: WebSocket (ws)
- パラメータ:
channelId(query parameter, required) - 目的: メッセージストリーミング用のWebSocket接続確立時にchannelIdが提供されることを保証
クエリパラメータ:
| Field | Type | Required | Description |
|---|---|---|---|
channelId | string | ✅ | Channel ID for streaming messages |
使用例:
import { schemas } from '@nodeblocks/backend-sdk';
const { streamChatMessagesSchema } = schemas;
// Applied in feature composition:
export const streamChatMessagesFeature = compose(
streamChatMessagesSchema,
streamChatMessagesRoute
);
// Client establishes WebSocket connection:
const ws = new WebSocket('ws://localhost:3000/messages/listen?channelId=channel123');
WebSocketフロー:
- クライアントがクエリ文字列に
channelIdを含めて接続 - スキーマが
channelIdの存在をバリデーション - サーバーがチャネル用のMongoDB変更ストリームを確立
- 新しいメッセージがリアルタイムでクライアントにストリーミングされる
エラーハンドリング:
channelIdが欠落: 400ステータスでバリデーションエラーを返す- 無効な
channelId形式: バリデーションエラーを返す
📝 メッセージテンプレートスキーマ
再利用可能なチャットコンテンツと標準化されたメッセージング用のメッセージテンプレート構造。
chatMessageTemplateSchema
再利用可能なメッセージテンプレートの構造を定義するベースチャットメッセージテンプレートスキーマ。
目的: アプリケーション全体で使用されるチャットメッセージテンプレートのコア構造を定義
スキーマ詳細:
- Type:
object - 必須フィールド: なし(ベーススキーマ)
- Additional Properties:
false(strict validation) - プロパティ:
content?: string- テンプレートメッセージ内容organizationId?: string- テンプレートスコープ用の組織識別子permissions?: string[]- アクセス制御用の権限文字列の配列title?: string- テンプレートタイトル/説明
使用例:
// Use as base for other schemas:
export const createSchema = withSchema({
requestBody: {
content: {
'application/json': {
schema: {
...chatMessageTemplateSchema,
required: ['content', 'title']
}
}
}
}
});
createChatMessageTemplateSchema
テンプレート作成リクエスト用の必須フィールドバリデーション付きチャットメッセージテンプレート作成スキーマ。
目的: 必須のcontentとtitleフィールドを含むメッセージテンプレートデータの作成をバリデーション
スキーマ詳細:
- Content-Type:
application/json - リクエストボディ:
required - 必須フィールド:
content,title - Optional Fields:
organizationId,permissions - Additional Properties:
false(strict validation)
リクエストボディ構造:
| Field | Type | Required | Description |
|---|---|---|---|
content | string | ✅ | Template message content |
title | string | ✅ | Template title/description |
organizationId | string | ❌ | Organization identifier for template scope |
permissions | string[] | ❌ | Array of permission strings for access control |
使用例:
// Use as base for other schemas:
export const createSchema = withSchema({
requestBody: {
content: {
'application/json': {
schema: {
...chatMessageTemplateSchema,
required: ['content', 'title']
}
}
}
}
});
getChatMessageTemplateSchema
パスパラメータバリデーション付きチャットメッセージテンプレート取得スキーマ。
目的: IDによるチャットメッセージテンプレート取得リクエストをバリデーション
スキーマ詳細:
- パラメータ:
messageTemplateId(path parameter) - 目的: IDによるチャットメッセージテンプレート取得リクエストをバリデーション
使用例:
import { schemas } from '@nodeblocks/backend-sdk';
const { getChatMessageTemplateSchema } = schemas;
const schema = getChatMessageTemplateSchema({});
const validate = ajv.compile(schema.schemas as SchemaDefinition);
const isValid = validate({ messageTemplateId: 'template123' });
updateChatMessageTemplateSchema
パスパラメータと部分ボディバリデーション付きチャットメッセージテンプレート更新スキーマ。
目的: 部分データサポート付きの既存チャットメッセージテンプレート更新リクエストをバリデーション
スキーマ詳細:
- Content-Type:
application/json - リクエストボディ:
required - パラメータ:
messageTemplateId(path parameter) - 必須フィールド: なし(部分更新)
- Optional Fields:
content,title - Additional Properties:
false(strict validation)
リクエストボディ構造:
| Field | Type | Required | Description |
|---|---|---|---|
content | string | ❌ | Updated template message content |
title | string | ❌ | Updated template title/description |
使用例:
import { schemas } from '@nodeblocks/backend-sdk';
const { updateChatMessageTemplateSchema } = schemas;
const schema = updateChatMessageTemplateSchema({});
const validate = ajv.compile(schema.schemas as SchemaDefinition);
const isValid = validate({
messageTemplateId: 'template123',
content: 'Updated message content',
title: 'Updated title'
});
deleteChatMessageTemplateSchema
パスパラメータバリデーション付きチャットメッセージテンプレート削除スキーマ。
目的: IDによる既存チャットメッセージテンプレート削除リクエストをバリデーション。
スキーマ詳細:
- Content-Type: Not applicable (no request body)
- リクエストボディ: None
- パラメータ:
messageTemplateId(path parameter) - 必須フィールド:
messageTemplateId - Additional Properties:
false(strict validation)
リクエストパラメータ:
| Parameter | Type | Required | Description |
|---|---|---|---|
messageTemplateId | string | ✅ | Unique identifier of the message template to delete |
使用例:
import { schemas } from '@nodeblocks/backend-sdk';
const { deleteChatMessageTemplateSchema } = schemas;
const schema = deleteChatMessageTemplateSchema({});
const validate = ajv.compile(schema.schemas as SchemaDefinition);
const isValid = validate({
messageTemplateId: 'template123'
});
findChatMessageTemplatesSchema
ページネーションバリデーション付きチャットメッセージテンプレートリストスキーマ。
目的: ページネーションサポート付きのチャットメッセージテンプレートリストリクエストをバリデーション。
Schema Structure:
{
page?: number; // optional - page number (1-1000)
limit?: number; // optional - records per page (1-50)
}
スキーマ詳細:
- Content-Type: Not applicable (query parameters only)
- リクエストボディ: None
- パラメータ: Uses common pagination query parameters
- 必須フィールド: なし
- Additional Properties:
false(strict validation)
クエリパラメータ:
| Parameter | Type | Required | Default | Range | Description |
|---|---|---|---|---|---|
page | number | ❌ | 1 | 1-1000 | Page number for pagination |
limit | number | ❌ | 10 | 1-50 | Number of templates per page |
使用例:
import { schemas } from '@nodeblocks/backend-sdk';
const { findChatMessageTemplatesSchema } = schemas;
const schema = findChatMessageTemplatesSchema({});
const validate = ajv.compile(schema.schemas as SchemaDefinition);
const isValid = validate({
page: 1,
limit: 10
});
// Apply to feature composition:
export const findChatMessageTemplatesFeature = compose(
findChatMessageTemplatesSchema,
findChatMessageTemplatesRoute
);
バリデーションルール:
page: オプションの整数、最小値1、最大値1000limit: オプションの整数、最小値1、最大値50- 両方のパラメータは共通のページネーションスキーマに対してバリデーションされる
findChatMessageTemplatesForOrganizationSchema
組織スコープ付きページネーション付きチャットメッセージテンプレート取得スキーマ。
目的: ページネーションサポート付きの特定組織にスコープされたチャットメッセージテンプレート取得リクエストをバリデーション。
Schema Structure:
{
organizationId: string; // required - organization identifier for scoped retrieval
page?: number; // optional - page number for pagination
limit?: number; // optional - items per page for pagination
}
スキーマ詳細:
- Content-Type: Not applicable (path and query parameters only)
- リクエストボディ: None
- パラメータ: Organization ID path parameter plus pagination query parameters
- 必須フィールド:
organizationId(path parameter) - Additional Properties:
false(strict validation)
パスパラメータ:
| Parameter | Type | Required | Description |
|---|---|---|---|
organizationId | string | ✅ | Unique identifier of the organization to retrieve templates for |
クエリパラメータ:
| Parameter | Type | Required | Default | Range | Description |
|---|---|---|---|---|---|
page | number | ❌ | 1 | 1-1000 | Page number for pagination |
limit | number | ❌ | 10 | 1-50 | Number of templates per page |
使用例:
import { schemas } from '@nodeblocks/backend-sdk';
const { findChatMessageTemplatesForOrganizationSchema } = schemas;
const schema = findChatMessageTemplatesForOrganizationSchema({});
const validate = ajv.compile(schema.schemas as SchemaDefinition);
const isValid = validate({
organizationId: 'org-123',
page: 1,
limit: 10
});
// Apply to feature composition:
export const findChatMessageTemplatesForOrganizationFeature = compose(
findChatMessageTemplatesForOrganizationSchema,
findChatMessageTemplatesForOrganizationRoute
);
バリデーションルール:
organizationId: 必須の文字列識別子page: オプションの整数、最小値1、最大値1000limit: オプションの整数、最小値1、最大値50- パスパラメータバリデーションにより組織スコープを保証
- ページネーションパラメータは共通スキーマに対してバリデーションされる
🔔 サブスクリプションスキーマ
chatSubscriptionSchema
コアサブスクリプションフィールドを持つベースチャットサブスクリプションスキーマ。
目的: チャットチャネルの基本的なサブスクリプション構造を定義
スキーマ詳細:
- Type:
object - 必須フィールド: なし(ベーススキーマ)
- Additional Properties:
false(strict validation) - プロパティ:
approved?: boolean- サブスクリプション承認ステータスpermissions?: string[]- ユーザー権限配列subscribedAt?: string- サブスクリプション日(date-time形式)subscribedId?: string- サブスクライバーのアイデンティティIDchannelId?: string- チャネルID
使用例:
import { schemas } from '@nodeblocks/backend-sdk';
const { chatSubscriptionSchema } = schemas;
const validate = ajv.compile(chatSubscriptionSchema as SchemaDefinition);
const isValid = validate({
channelId: 'channel123',
subscribedId: 'identity456',
approved: true,
permissions: ['read', 'write']
});
createChatSubscriptionSchema
必須チャネルID付きチャットサブスクリプション作成スキーマ。
目的: 作成時のサブスクリプションデータをバリデーション
スキーマ詳細:
- Type:
object - 必須フィールド:
channelId,subscribedId - Optional Fields:
approved,permissions,subscribedAt - Additional Properties:
false(strict validation) - Content-Type:
application/json - リクエストボディ:
required
使用例:
import { schemas } from '@nodeblocks/backend-sdk';
const { createChatSubscriptionSchema } = schemas;
const schema = createChatSubscriptionSchema({});
const validate = ajv.compile(schema.schemas as SchemaDefinition);
const isValid = validate({
channelId: 'channel123',
subscribedId: 'user456',
approved: true
});
getChatSubscriptionSchema
単一サブスクリプション取得用のチャットサブスクリプション取得スキーマ。
目的: 特定のチャットサブスクリプション取得リクエストをバリデーション
スキーマ詳細:
- パラメータ:
subscriptionId(path parameter)
使用例:
import { schemas } from '@nodeblocks/backend-sdk';
const { getChatSubscriptionSchema } = schemas;
const schema = getChatSubscriptionSchema({});
const validate = ajv.compile(schema.schemas as SchemaDefinition);
const isValid = validate({ subscriptionId: 'sub123' });
deleteChatSubscriptionSchema
サブスクリプション削除用のチャットサブスクリプション削除スキーマ。
目的: 特定のチャットサブスクリプション削除リクエストをバリデーション
スキーマ詳細:
- パラメータ:
subscriptionId(path parameter) - 目的: 特定のチャットサブスクリプション削除リクエストをバリデーション
使用例:
import { schemas } from '@nodeblocks/backend-sdk';
const { deleteChatSubscriptionSchema } = schemas;
const schema = deleteChatSubscriptionSchema({});
const validate = ajv.compile(schema.schemas as SchemaDefinition);
const isValid = validate({ subscriptionId: 'sub123' });
findChatSubscriptionsSchema
フィルタリングとページネーション付きサブスクリプション検索用のチャットサブスクリプション検索スキーマ。
目的: チャットサブスクリプションの検索とページネーションリクエストをバリデーション
スキーマ詳細:
- クエリパラメータ:
approved?: boolean- 承認ステータスでフィルタchannelId?: string- チャネルでフィルタsubscribedAt?: string- サブスクリプション日でフィルタ(date-time形式)subscribedId?: string- サブスクライバーでフィルタpage?: number- ページネーションのページ番号limit?: number- ページネーションの制限
- 目的: チャットサブスクリプションの検索とページネーションリクエストをバリデーション
使用例:
import { schemas } from '@nodeblocks/backend-sdk';
const { findChatSubscriptionsSchema } = schemas;
const schema = findChatSubscriptionsSchema({});
const validate = ajv.compile(schema.schemas as SchemaDefinition);
const isValid = validate({
approved: true,
page: 1,
limit: 10
});
📊 チャットチャネル読み取り状態スキーマ
chatChannelReadStateSchema
読み取り状態追跡用の必須フィールド付きチャットチャネル読み取り状態スキーマ。
目的: 必須のidentityIdとlastReadMessageIdを含むチャットチャネル読み取り状態データをバリデーション
Schema Structure:
{
identityId: string; // required - unique identifier for the user
lastReadMessageId: string; // required - unique identifier for the last read message
}
スキーマ詳細:
- Type:
object - 必須フィールド: なし(フィールドはupsertChatChannelReadStateSchemaで必須になる)
- Additional Properties:
false(strict validation)
使用例:
import { schemas } from '@nodeblocks/backend-sdk';
const { chatChannelReadStateSchema } = schemas;
// Use as base schema for read state validation
const validate = ajv.compile(chatChannelReadStateSchema);
const isValid = validate({
identityId: '00000000-0000-1000-a000-111111111111',
lastReadMessageId: '00000000-0000-1000-a000-222222222222'
});
upsertChatChannelReadStateSchema
パスパラメータとリクエストボディバリデーション付きチャットチャネル読み取り状態アップサートスキーマ。
目的: チャネル読み取り状態のアップサート用のPUTリクエストをバリデーション
Schema Structure:
{
// Path parameters
channelId: string; // required - unique identifier for the chat channel
// Request body
identityId: string; // required - unique identifier for the user
lastReadMessageId: string; // required - unique identifier for the last read message
}
スキーマ詳細:
- パラメータ:
channelId(path parameter, required) - リクエストボディ:
identityId,lastReadMessageId(both required) - Content-Type:
application/json - Additional Properties:
false(strict validation)
使用例:
import { schemas } from '@nodeblocks/backend-sdk';
const { upsertChatChannelReadStateSchema } = schemas;
// Apply to feature composition:
export const upsertChatChannelReadStateFeature = compose(
upsertChatChannelReadStateSchema,
upsertChatChannelReadStateRoute
);
リクエストボディ要件:
| Field | Type | Required | Description |
|---|---|---|---|
identityId | string | ✅ | User identity ID |
lastReadMessageId | string | ✅ | Last read message ID |
パスパラメータ:
| Parameter | Type | Required | Description |
|---|---|---|---|
channelId | string | ✅ | Chat channel ID |
🔗 関連ドキュメント
- チャットドメイン概要 - チャットドメイン概要