資料表標籤
以範圍限定的標籤整理相關資料表、安全管理指派關係,並可用兩步驟 purge 流程一次下線整個 tag 系統。
POST
路由範本
/private/module/custom_tables/{scope}/table-tags用途
在單一範圍內建立帶有名稱與顏色的資料表群組。
適用時機
要把一組相關資料表歸入同一系統或流程前使用。
實際掛載路徑
- 聊天室
/private/module/custom_tables/chatroom/{chatroom_id}/table-tags - 部門
/private/module/custom_tables/department/{department_id}/table-tags - 公司
/private/module/custom_tables/company/table-tags
範圍
| 範圍 | 是否提供 | 驗證與權限 |
|---|---|---|
| 聊天室 | 可使用 | ChatRoomAccessRequired |
| 部門 | 可使用 | DepartmentAccessRequired |
| 公司 | 可使用 | CompanyAccessRequired |
請求結構
CustomTableTagPayload| 欄位 | 型別 | 必填 | 說明 |
|---|---|---|---|
color | string | 否 | Optional display color, '#rgb', '#rgba', '#rrggbb' or '#rrggbbaa', or empty. |
description | string | 否 | Optional human description. |
name | string | 是 | Tag name (unique per scope). |
回應結構
CustomTableTagResponse| 欄位 | 型別 | 必填 | 說明 |
|---|---|---|---|
color | string | 是 | Display color ('' when unset) |
created_at | string (date-time) | 是 | Creation timestamp |
description | string | 是 | Human description ('' when unset) |
id | string | 是 | Tag UUID |
name | string | 是 | Tag name |
table_count | integer | 是 | Number of tables assigned to this tag |
updated_at | string (date-time) | 是 | Last modification timestamp |
範例
建立營運標籤
請求
{
"pathParams": {
"chatroom_id": "11111111-1111-4111-8111-111111111111"
},
"body": {
"name": "營運",
"description": "日常營運相關資料表",
"color": "#2563eb"
}
}回應201
{
"id": "55555555-5555-4555-8555-555555555555",
"name": "營運",
"description": "日常營運相關資料表",
"color": "#2563eb",
"table_count": 0,
"created_at": "2026-07-19T01:30:00",
"updated_at": "2026-07-19T01:35:00"
}錯誤
| 狀態 | 發生條件 | 錯誤本文 |
|---|---|---|
| 409 | 同一範圍已有標籤使用指定名稱。 | |
GET
路由範本
/private/module/custom_tables/{scope}/table-tags用途
依名稱排序回傳此範圍的標籤,以及目前指派的資料表數量。
適用時機
適合呈現標籤導覽,或在篩選資料表前先解析標籤 UUID。
實際掛載路徑
- 聊天室
/private/module/custom_tables/chatroom/{chatroom_id}/table-tags - 部門
/private/module/custom_tables/department/{department_id}/table-tags - 公司
/private/module/custom_tables/company/table-tags
範圍
| 範圍 | 是否提供 | 驗證與權限 |
|---|---|---|
| 聊天室 | 可使用 | ChatRoomAccessRequired |
| 部門 | 可使用 | DepartmentAccessRequired |
| 公司 | 可使用 | CompanyAccessRequired |
回應結構
CustomTableTagListResponse| 欄位 | 型別 | 必填 | 說明 |
|---|---|---|---|
tags | CustomTableTagResponse[] | 是 | Tags in this scope |
total | integer | 是 | Number of tags |
範例
列出標籤與指派數量
請求
{
"pathParams": {
"chatroom_id": "11111111-1111-4111-8111-111111111111"
}
}回應200
{
"tags": [
{
"id": "55555555-5555-4555-8555-555555555555",
"name": "營運",
"description": "日常營運相關資料表",
"color": "#2563eb",
"table_count": 0,
"created_at": "2026-07-19T01:30:00",
"updated_at": "2026-07-19T01:35:00"
}
],
"total": 1
}PATCH
路由範本
/private/module/custom_tables/{scope}/table-tags/{tag_id}用途
局部修改同一 scope 內標籤的名稱、說明或顏色;未提供任何欄位時請求會失敗。
適用時機
重新命名系統群組或調整顯示樣式時使用。
實際掛載路徑
- 聊天室
/private/module/custom_tables/chatroom/{chatroom_id}/table-tags/{tag_id} - 部門
/private/module/custom_tables/department/{department_id}/table-tags/{tag_id} - 公司
/private/module/custom_tables/company/table-tags/{tag_id}
範圍
| 範圍 | 是否提供 | 驗證與權限 |
|---|---|---|
| 聊天室 | 可使用 | ChatRoomAccessRequired |
| 部門 | 可使用 | DepartmentAccessRequired |
| 公司 | 可使用 | CompanyAccessRequired |
參數
| 欄位 | 位置 | 型別 | 必填 | 說明 |
|---|---|---|---|---|
tag_id | path | uuid | 是 | 指定範圍內的標籤 UUID。 |
請求結構
CustomTableTagUpdatePayload| 欄位 | 型別 | 必填 | 說明 |
|---|---|---|---|
color | string | null | 否 | New display color, '#rgb', '#rgba', '#rrggbb' or '#rrggbbaa', or empty to clear. |
description | string | null | 否 | New description. |
name | string | null | 否 | New tag name (unique per scope). |
回應結構
CustomTableTagResponse| 欄位 | 型別 | 必填 | 說明 |
|---|---|---|---|
color | string | 是 | Display color ('' when unset) |
created_at | string (date-time) | 是 | Creation timestamp |
description | string | 是 | Human description ('' when unset) |
id | string | 是 | Tag UUID |
name | string | 是 | Tag name |
table_count | integer | 是 | Number of tables assigned to this tag |
updated_at | string (date-time) | 是 | Last modification timestamp |
範例
重新命名並換色
請求
{
"pathParams": {
"chatroom_id": "11111111-1111-4111-8111-111111111111",
"tag_id": "55555555-5555-4555-8555-555555555555"
},
"body": {
"name": "核心營運",
"color": "#1d4ed8"
}
}回應200
{
"id": "55555555-5555-4555-8555-555555555555",
"name": "核心營運",
"description": "日常營運相關資料表",
"color": "#1d4ed8",
"table_count": 0,
"created_at": "2026-07-19T01:30:00",
"updated_at": "2026-07-19T01:35:00"
}錯誤
| 狀態 | 發生條件 | 錯誤本文 |
|---|---|---|
| 400 | 未提供任何要更新的欄位。 | |
| 404 | 指定範圍內找不到此標籤。 | |
DELETE
路由範本
/private/module/custom_tables/{scope}/table-tags/{tag_id}用途
刪除標籤與指派關係,不會刪除任何資料表。
適用時機
群組不再使用,但所屬資料表仍需保留時使用。
實際掛載路徑
- 聊天室
/private/module/custom_tables/chatroom/{chatroom_id}/table-tags/{tag_id} - 部門
/private/module/custom_tables/department/{department_id}/table-tags/{tag_id} - 公司
/private/module/custom_tables/company/table-tags/{tag_id}
範圍
| 範圍 | 是否提供 | 驗證與權限 |
|---|---|---|
| 聊天室 | 可使用 | ChatRoomAccessRequired |
| 部門 | 可使用 | DepartmentAccessRequired |
| 公司 | 可使用 | CompanyAccessRequired |
參數
| 欄位 | 位置 | 型別 | 必填 | 說明 |
|---|---|---|---|---|
tag_id | path | uuid | 是 | 要刪除的標籤 UUID。 |
回應結構
SuccessResponse| 欄位 | 型別 | 必填 | 說明 |
|---|---|---|---|
message | string | 否 | 未指定 |
範例
刪除標籤
請求
{
"pathParams": {
"chatroom_id": "11111111-1111-4111-8111-111111111111",
"tag_id": "55555555-5555-4555-8555-555555555555"
}
}回應200
{
"message": "Tag deleted successfully"
}錯誤
| 狀態 | 發生條件 | 錯誤本文 |
|---|---|---|
| 404 | 指定範圍內找不到此標籤。 | |
PUT
路由範本
/private/module/custom_tables/{scope}/table-tags/{tag_id}/tables用途
讓標籤指派集合精確等於送入的資料表 UUID 清單。
適用時機
儲存標籤成員編輯器的完整狀態時使用。
實際掛載路徑
- 聊天室
/private/module/custom_tables/chatroom/{chatroom_id}/table-tags/{tag_id}/tables - 部門
/private/module/custom_tables/department/{department_id}/table-tags/{tag_id}/tables - 公司
/private/module/custom_tables/company/table-tags/{tag_id}/tables
範圍
| 範圍 | 是否提供 | 驗證與權限 |
|---|---|---|
| 聊天室 | 可使用 | ChatRoomAccessRequired |
| 部門 | 可使用 | DepartmentAccessRequired |
| 公司 | 可使用 | CompanyAccessRequired |
參數
| 欄位 | 位置 | 型別 | 必填 | 說明 |
|---|---|---|---|---|
tag_id | path | uuid | 是 | 要取代指派集合的標籤 UUID。 |
請求結構
TagTablesReplacePayload| 欄位 | 型別 | 必填 | 說明 |
|---|---|---|---|
table_ids | string[] | 是 | Custom-table UUIDs; every id must exist in the tag's scope. |
回應結構
TagTablesResponse| 欄位 | 型別 | 必填 | 說明 |
|---|---|---|---|
table_ids | string[] | 是 | Assigned custom-table UUIDs |
total | integer | 是 | Number of assigned tables |
範例
整批取代標籤指派
請求
{
"pathParams": {
"chatroom_id": "11111111-1111-4111-8111-111111111111",
"tag_id": "55555555-5555-4555-8555-555555555555"
},
"body": {
"table_ids": [
"22222222-2222-4222-8222-222222222222"
]
}
}回應200
{
"table_ids": [
"22222222-2222-4222-8222-222222222222"
],
"total": 1
}錯誤
| 狀態 | 發生條件 | 錯誤本文 |
|---|---|---|
| 404 | 某個資料表 UUID 不存在,或屬於其他範圍。 | |
POST
路由範本
/private/module/custom_tables/{scope}/table-tags/{tag_id}/tables/{table_id}用途
把一張同範圍資料表加入標籤,並回傳完整指派集合。
適用時機
互動式標籤編輯器中,單筆加入資料表時使用。
實際掛載路徑
- 聊天室
/private/module/custom_tables/chatroom/{chatroom_id}/table-tags/{tag_id}/tables/{table_id} - 部門
/private/module/custom_tables/department/{department_id}/table-tags/{tag_id}/tables/{table_id} - 公司
/private/module/custom_tables/company/table-tags/{tag_id}/tables/{table_id}
範圍
| 範圍 | 是否提供 | 驗證與權限 |
|---|---|---|
| 聊天室 | 可使用 | ChatRoomAccessRequired |
| 部門 | 可使用 | DepartmentAccessRequired |
| 公司 | 可使用 | CompanyAccessRequired |
參數
| 欄位 | 位置 | 型別 | 必填 | 說明 |
|---|---|---|---|---|
tag_id | path | uuid | 是 | 目標標籤 UUID。 |
table_id | path | uuid | 是 | 同一範圍內現行資料表的 UUID。 |
回應結構
TagTablesResponse| 欄位 | 型別 | 必填 | 說明 |
|---|---|---|---|
table_ids | string[] | 是 | Assigned custom-table UUIDs |
total | integer | 是 | Number of assigned tables |
範例
把訂單資料表加入標籤
請求
{
"pathParams": {
"chatroom_id": "11111111-1111-4111-8111-111111111111",
"tag_id": "55555555-5555-4555-8555-555555555555",
"table_id": "22222222-2222-4222-8222-222222222222"
}
}回應201
{
"table_ids": [
"22222222-2222-4222-8222-222222222222"
],
"total": 1
}錯誤
| 狀態 | 發生條件 | 錯誤本文 |
|---|---|---|
| 404 | 此範圍內找不到指定標籤或資料表。 | |
DELETE
路由範本
/private/module/custom_tables/{scope}/table-tags/{tag_id}/tables/{table_id}用途
移除一筆資料表指派,並回傳標籤剩餘的資料表 UUID。
適用時機
互動式標籤編輯器中,單筆移除資料表時使用。
實際掛載路徑
- 聊天室
/private/module/custom_tables/chatroom/{chatroom_id}/table-tags/{tag_id}/tables/{table_id} - 部門
/private/module/custom_tables/department/{department_id}/table-tags/{tag_id}/tables/{table_id} - 公司
/private/module/custom_tables/company/table-tags/{tag_id}/tables/{table_id}
範圍
| 範圍 | 是否提供 | 驗證與權限 |
|---|---|---|
| 聊天室 | 可使用 | ChatRoomAccessRequired |
| 部門 | 可使用 | DepartmentAccessRequired |
| 公司 | 可使用 | CompanyAccessRequired |
參數
| 欄位 | 位置 | 型別 | 必填 | 說明 |
|---|---|---|---|---|
tag_id | path | uuid | 是 | 目標標籤 UUID。 |
table_id | path | uuid | 是 | 要從標籤移除的資料表 UUID。 |
回應結構
TagTablesResponse| 欄位 | 型別 | 必填 | 說明 |
|---|---|---|---|
table_ids | string[] | 是 | Assigned custom-table UUIDs |
total | integer | 是 | Number of assigned tables |
範例
從標籤移除訂單資料表
請求
{
"pathParams": {
"chatroom_id": "11111111-1111-4111-8111-111111111111",
"tag_id": "55555555-5555-4555-8555-555555555555",
"table_id": "22222222-2222-4222-8222-222222222222"
}
}回應200
{
"table_ids": [],
"total": 0
}錯誤
| 狀態 | 發生條件 | 錯誤本文 |
|---|---|---|
| 404 | 指定範圍內找不到此標籤。 | |
POST
路由範本
/private/module/custom_tables/{scope}/table-tags/{tag_id}/purge/preview用途
計算一次銷毀 tag 所有成員表、綁定該 tag 的全部 commands、其 IaC state rows 以及 tag 本身的爆炸半徑——沒有 blocker 時同樣發出 15 分鐘一次性 ticket。
適用時機
當一整套已佈建的系統(通常由 IaC apply 產生、以 tag 綁成一組的表與 commands)要整體下線、而不是一張一張刪時使用。
實際掛載路徑
- 聊天室
/private/module/custom_tables/chatroom/{chatroom_id}/table-tags/{tag_id}/purge/preview - 部門
/private/module/custom_tables/department/{department_id}/table-tags/{tag_id}/purge/preview - 公司
/private/module/custom_tables/company/table-tags/{tag_id}/purge/preview
範圍
| 範圍 | 是否提供 | 驗證與權限 |
|---|---|---|
| 聊天室 | 可使用 | ChatRoomAccessRequired |
| 部門 | 可使用 | DepartmentAccessRequired |
| 公司 | 可使用 | CompanyAccessRequired |
參數
| 欄位 | 位置 | 型別 | 必填 | 說明 |
|---|---|---|---|---|
tag_id | path | uuid | 是 | 其成員表與 commands 構成待 purge 系統的那個 tag。 |
回應結構
PurgePreviewResponse| 欄位 | 型別 | 必填 | 說明 |
|---|---|---|---|
blockers | PurgeBlocker[] | 是 | Conditions preventing a ticket (empty = ticket issued) |
commands_affected | PurgeCommandInfo[] | 是 | OTHER live commands whose dependency set references a purged table — they become zombies (still deletable individually), NOT deleted by this purge |
commands_to_delete | PurgeCommandInfo[] | 是 | Commands the purge deletes (tag lane: every command bound to the tag; names release immediately) |
cross_table_impact | PurgeCrossTableImpact[] | 是 | Live tables outside the purge set whose schemas/rules the cascade mutates |
expires_at | string (date-time) | null | 否 | Ticket expiry (UTC) |
iac_state_rows | integer | 是 | IaC state rows removed with the purged tables |
tables | PurgeImpactTable[] | 是 | Tables that will be permanently destroyed (records + history + row) |
ticket | string | null | 否 | One-shot purge ticket (null when blockers exist); bound to the previewing user |
views | integer | 是 | Saved views destroyed with the purged tables |
範例
預覽一個雙表系統的 purge
請求
{
"pathParams": {
"chatroom_id": "11111111-1111-4111-8111-111111111111",
"tag_id": "55555555-5555-4555-8555-555555555555"
}
}回應200
{
"tables": [
{
"id": "22222222-2222-4222-8222-222222222222",
"name": "訂單",
"record_count": 128,
"is_deleted": false
},
{
"id": "66666666-6666-4666-8666-666666666666",
"name": "出貨單",
"record_count": 54,
"is_deleted": false
}
],
"cross_table_impact": [],
"commands_to_delete": [
{
"id": "eeeeeeee-eeee-4eee-8eee-eeeeeeeeeeee",
"name": "ship-order"
}
],
"commands_affected": [],
"views": 3,
"iac_state_rows": 6,
"blockers": [],
"ticket": "f1f1f1f1-f1f1-4f1f-8f1f-f1f1f1f1f1f1",
"expires_at": "2026-07-28T03:15:00Z"
}錯誤
| 狀態 | 發生條件 | 錯誤本文 |
|---|---|---|
| 404 | 此 scope 內沒有這個 id 的 tag。 | |
| 403 | 整系統 purge 會銷毀表與 commands,因此要求 scope-manager 權威——tag 刪除那道弱閘(任一成員即可)不夠格。 | |
POST
路由範本
/private/module/custom_tables/{scope}/table-tags/{tag_id}/purge用途
永久銷毀所有成員表、軟刪綁定該 tag 的每個 command(名字立即釋放)、清除這些 commands 的 IaC state rows,並刪除 tag 本身。
適用時機
下線一個 tag 系統的第二步:preview 後 15 分鐘內、由同一位使用者執行。
實際掛載路徑
- 聊天室
/private/module/custom_tables/chatroom/{chatroom_id}/table-tags/{tag_id}/purge - 部門
/private/module/custom_tables/department/{department_id}/table-tags/{tag_id}/purge - 公司
/private/module/custom_tables/company/table-tags/{tag_id}/purge
範圍
| 範圍 | 是否提供 | 驗證與權限 |
|---|---|---|
| 聊天室 | 可使用 | ChatRoomAccessRequired |
| 部門 | 可使用 | DepartmentAccessRequired |
| 公司 | 可使用 | CompanyAccessRequired |
參數
| 欄位 | 位置 | 型別 | 必填 | 說明 |
|---|---|---|---|---|
tag_id | path | uuid | 是 | 要 purge 的 tag——必須與 ticket 的標的一致。 |
ticket | query | uuid | 是 | tag purge preview 回應中的一次性 ticket。任何走到 ticket 驗證那一步的嘗試都會燒掉它,成敗皆然——唯一例外是 purge_blocked 的拒絕,它發生在消耗 ticket 之前。 |
回應結構
TagPurgeResponse| 欄位 | 型別 | 必填 | 說明 |
|---|---|---|---|
deleted_commands | integer | 是 | Commands soft-deleted with the system (names released) |
message | string | 是 | Human-readable outcome |
purged_tables | string[] | 是 | Ids of the tables permanently destroyed, in execution order |
tag_id | string | 是 | The deleted tag's id |
範例
執行已預覽的系統 purge
請求
{
"pathParams": {
"chatroom_id": "11111111-1111-4111-8111-111111111111",
"tag_id": "55555555-5555-4555-8555-555555555555"
},
"query": {
"ticket": "f1f1f1f1-f1f1-4f1f-8f1f-f1f1f1f1f1f1"
}
}回應200
{
"tag_id": "55555555-5555-4555-8555-555555555555",
"purged_tables": [
"22222222-2222-4222-8222-222222222222",
"66666666-6666-4666-8666-666666666666"
],
"deleted_commands": 1,
"message": "System permanently purged (tables, commands, and tag removed)"
}錯誤
| 狀態 | 發生條件 | 錯誤本文 |
|---|---|---|
| 404 | ticket 不存在或已過期(效期 15 分鐘)。請重新 preview。 | |
| 403 | ticket 屬於另一位使用者。誰 preview,誰執行。 | |
| 409 | preview 之後系統漂移了——表被還原或改名、command 增減、或 tag 掛載變動。重新 preview 並重新核准。 | |
| 409 | ticket 是為另一個標的簽發的——別的 tag,或單表 lane。ticket 已燒掉;請對這個 tag 重新 preview。 | |
| 409 | blocker 在 execute 時會重驗一次(縱深防禦)。preview 之後成員表又掛上別的 tag,就算 ticket 有效也會被擋下。 | |
| 423 | 一或多張成員表持有 migration 鎖;preflight 會點名它們。等 migration 結束後重新 preview——這次嘗試花掉的 ticket 不會回來。若鎖是在執行中途才撞上,回應會是掛著這個狀態碼的 purge_partial_failure 內容,而不是 500。 | |
| 500 | 每張成員表的 cascade 獨立 commit,所以系統中途失敗時,前面的成員已經永久消失。回應會精確列出哪些表已 purge、哪張失敗——千萬不要丟掉這份結果。復原路徑是對縮小後的系統重新 preview。 | |
Last updated on