feat(data_store): implement V3 cascading lookup and ID Vision standardization
- Added GET /v3/data_store/code/{code} with hierarchical context-aware fallback.
- Implemented ID Vision standard in Data_Store_Base (string IDs, internal int exclusion).
- Enhanced Data_Store_Base robustness to handle stringified 'NULL' values from the database.
- Fixed legacy router bugs by removing undefined parameters (inc_event_cfg, inc_event_location).
- Corrected type hints and resolved UnboundLocalError in data_store methods.
- Updated Frontend Integration Guide with Section 8: Data Store V3.
- Added unified E2E test script: tests/e2e/test_e2e_v3_data_store_lookup.py.
This commit is contained in:
@@ -136,4 +136,35 @@ V3 returns machine-readable error objects in `meta.details` for failures.
|
||||
- `database_duplicate`: Non-unique value (Code 1062).
|
||||
- `database_constraint`: Foreign key violation (Codes 1451, 1452).
|
||||
- `database_schema`: Invalid column name (Codes 1054, 1146).
|
||||
- `validation`: Pydantic validation failed (Check `details` for field-specific errors).
|
||||
- `validation`: Pydantic validation failed (Check `details` for field-specific errors).
|
||||
|
||||
---
|
||||
|
||||
## 8. Data Store Cascading Lookup (V3)
|
||||
|
||||
V3 provides a specialized endpoint for retrieving configuration or content snippets by a human-friendly `code`. This uses a **hierarchical fallback** logic to find the best fit for the current context.
|
||||
|
||||
### A. The V3 Lookup Endpoint
|
||||
**Path:** `GET /v3/data_store/code/{code}`
|
||||
|
||||
**Query Parameters:**
|
||||
| Parameter | Type | Required | Description |
|
||||
| :--- | :--- | :--- | :--- |
|
||||
| `for_type` | String | No | Parent object type (e.g., `event`, `person`). |
|
||||
| `for_id` | String | No | Parent object random ID. |
|
||||
|
||||
### B. Cascading Logic (Specificity)
|
||||
The API automatically resolves the "best fit" record in the following order:
|
||||
1. **Record Specific:** Matches `for_type` + `for_id` (and account).
|
||||
2. **Account Specific:** Matches the `x-account-id` header.
|
||||
3. **Global Default:** Matches `code` where `account_id` is `NULL`.
|
||||
|
||||
### C. Example Implementation
|
||||
```ts
|
||||
// GET /v3/data_store/code/event_launcher_main_info?for_type=event&for_id=nmBfuGFeR0k
|
||||
export async function get_data_store_v3({ api_cfg, code, for_type, for_id }) {
|
||||
const endpoint = `/v3/data_store/code/${code}`;
|
||||
const params = { for_type, for_id };
|
||||
return await get_object({ api_cfg, endpoint, params });
|
||||
}
|
||||
```
|
||||
Reference in New Issue
Block a user