Unify ID, audit, and tenant field naming across protocol layer#877
Unify ID, audit, and tenant field naming across protocol layer#877
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Replace all standalone _id property keys with id across test object literals, where clauses, and assertion expectations. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Replace all standalone `_id` references with `id` across all CRM action handler files (contact, global, opportunity, case, lead). This includes type annotations, property access, destructuring, and object literals. Compound identifiers like `account_id`, `contact_id`, etc. are preserved. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…ross source files Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
…, and docs Replace MongoDB-style _id field references with the platform-standard id field name in: - Mock kernels (studio, client tests) - REST, runtime, and objectql test data - QA testing schema and tests - Documentation examples and SQL snippets Compound identifiers (owner_id, account_id, tenant_id) are preserved. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
|
@copilot 仔细检查所有相关代码评估是否已经完成了任务中的所有要求 |
…ns.mdx Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
Re-audited the full codebase against all 6 requirements in the issue. Found and fixed 2 remaining Final audit results:
All 6625 spec tests + 85 runtime + 40 rest + 134 objectql tests pass. Pre-existing failures in |
There was a problem hiding this comment.
Pull request overview
This PR standardizes protocol-layer field naming across ObjectStack (primary key, audit fields, and tenant isolation) to eliminate mixed usage of _id/id, modified_*/updated_*, and space_id/tenant_id across runtime, ObjectQL, client tests, Studio UI, examples, and documentation.
Changes:
- Replaced protocol-facing
_idwithidacross ObjectQL protocol/engine paths, tests, Studio UI, examples, and docs. - Renamed audit and tenant fields to canonical names (
updated_at,updated_by,tenant_id) in ObjectQL plugin middleware/hooks and related references. - Removed legacy
_idcompatibility shims/fallbacks in QA adapters, mocks, and memory matcher.
Reviewed changes
Copilot reviewed 41 out of 41 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| packages/spec/src/qa/testing.zod.ts | Update QA schema examples to reference body.id instead of body._id. |
| packages/spec/src/qa/testing.test.ts | Align QA tests with body.id capture/assertion paths. |
| packages/spec/src/integration/connector/database.zod.ts | Update connector example primary key naming (Mongo example changed). |
| packages/spec/src/data/mapping.zod.ts | Update mapping comment example to use id. |
| packages/spec/src/data/mapping.test.ts | Update mapping tests to use id and fields: ['id', ...]. |
| packages/spec/src/data/dataset.zod.ts | Update dataset comment to reflect id naming guidance. |
| packages/spec/docs/SYNC_ARCHITECTURE.md | Update sync example timestamp field reference. |
| packages/spec/DEVELOPMENT_PLAN.md | Update development plan example from _id to id. |
| packages/runtime/src/http-dispatcher.test.ts | Update runtime dispatcher tests to return records with id. |
| packages/rest/src/rest.test.ts | Update REST server tests to use record.id. |
| packages/plugins/driver-memory/src/memory-matcher.ts | Remove _id→id path compatibility behavior in matcher helper. |
| packages/objectql/src/protocol.ts | Switch protocol operations to filter/return id and use updated_at. |
| packages/objectql/src/protocol-data.test.ts | Update protocol data operation tests to use id filters/records. |
| packages/objectql/src/plugin.ts | Rename audit/tenant stamping and filters to updated_* + tenant_id, and use id filters. |
| packages/objectql/src/engine.ts | Use id for expand/query/update/delete/count paths and remove _id extraction. |
| packages/objectql/src/engine.test.ts | Update engine tests for populate/expand behavior with id. |
| packages/core/src/qa/http-adapter.ts | Remove _id payload fallbacks; require id for read/update/delete. |
| packages/client/src/client.msw.test.ts | Update client MSW tests to return id only. |
| packages/client/src/client.hono.test.ts | Update client Hono tests to return id only. |
| examples/app-todo/src/actions/task.handlers.ts | Update example action handlers to use record.id and return { id }. |
| examples/app-crm/src/actions/handlers/opportunity.handlers.ts | Update CRM example handler to use id and return { id }. |
| examples/app-crm/src/actions/handlers/lead.handlers.ts | Update CRM conversion handler to use id across linked records. |
| examples/app-crm/src/actions/handlers/global.handlers.ts | Update global handler to reference record.id and return activity.id. |
| examples/app-crm/src/actions/handlers/contact.handlers.ts | Update contact handlers to use id for updates and activity creation. |
| examples/app-crm/src/actions/handlers/case.handlers.ts | Update case handlers to update by record.id. |
| content/prompts/plugin/data-seed.prompt.md | Update prompt examples to use .id in updates/calls. |
| content/prompts/platform/automation.prompt.md | Update automation prompt filter examples to use id. |
| content/docs/references/qa/testing.mdx | Update docs to show capture paths using body.id. |
| content/docs/protocol/objectui/layout-dsl.mdx | Update relation comment to reference account.id. |
| content/docs/protocol/objectui/actions.mdx | Update endpoint templates from {_id} to {id}. |
| content/docs/protocol/objectql/types.mdx | Update ObjectQL type/storage examples to reference id. |
| content/docs/protocol/objectql/security.mdx | Update security doc examples to show id. |
| content/docs/protocol/objectql/schema.mdx | Update schema doc examples/system fields to use id. |
| content/docs/protocol/objectql/query-syntax.mdx | Update query syntax examples (joins/cursors/filters) to use id. |
| content/docs/protocol/objectql/index.mdx | Update ObjectQL index doc join example to use id. |
| content/docs/guides/standards.mdx | Update standards checklist wording related to _id. |
| apps/studio/src/types.ts | Remove _id from Studio Task type; use id only. |
| apps/studio/src/mocks/createKernel.ts | Remove _id fallbacks in Studio mock broker shim. |
| apps/studio/src/components/ObjectDataTable.tsx | Remove _id fallback from React keys and delete handler. |
| apps/studio/src/components/ObjectDataForm.tsx | Remove _id usage; update audit exclusion list to updated_by. |
| ROADMAP.md | Add roadmap entry documenting unified naming change. |
Comments suppressed due to low confidence (2)
packages/spec/src/integration/connector/database.zod.ts:282
- In the MongoDB connector example,
DatabaseTableSchema.primaryKeyis described as the “Actual table name in database” / “Primary key column”. For MongoDB collections the primary key field is typically_id; usingprimaryKey: 'id'here is misleading and may cause incorrect configs if copied. Consider reverting this example to_id, or clarifying in the schema/docs thatprimaryKeyrefers to the mapped ObjectStack field name rather than the source DB field.
content/docs/guides/standards.mdx:549 - This checklist item reads like lookup field names should not end with
_id, but the rest of the docs and schemas use the conventional*_idforeign-key naming (e.g.account_id) while the referenced record’s primary key isid(not_id). Please reword this to avoid suggesting that foreign key fields should be renamed away from*_id.
- [ ] Lookups don't have `_id` suffix (use `id`)
- [ ] All validations have clear messages
_id,modified_at/by,space_idacross the codebasepackages/objectql/src/plugin.ts—modified_at→updated_at,modified_by→updated_by,space_id→tenant_id,_id→idpackages/objectql/src/protocol.ts—_id→idin all filter/data operations,modified_at→updated_atpackages/objectql/src/engine.ts—_id→idin filters, data access, and ObjectProxypackages/objectql/src/engine.test.ts—_id→idin all test data/assertionspackages/objectql/src/protocol-data.test.ts—_id→idin all test datapackages/core/src/qa/http-adapter.ts— Remove_idfallbacks, use onlyidpackages/plugins/driver-memory/src/memory-matcher.ts— Remove_idcompatibility shimapps/studio/src/types.ts— Remove_idfrom Task interfaceapps/studio/src/components/ObjectDataForm.tsx— Remove_idrefs,modified_by→updated_byapps/studio/src/components/ObjectDataTable.tsx— Remove_idfallbacksapps/studio/src/mocks/createKernel.ts— Remove_idfallbacksexamples/app-todo/src/actions/task.handlers.ts—_id→idexamples/app-crm/src/actions/handlers/*.ts—_id→idpackages/spec/src/data/dataset.zod.ts— Update commentpackages/spec/src/data/mapping.zod.ts— Update commentpackages/spec/src/data/mapping.test.ts—_id→idin test datapackages/spec/src/integration/connector/database.zod.ts—_id→idpackages/spec/src/qa/testing.zod.tsandtesting.test.ts—_id→idpackages/rest/src/rest.test.ts—_id→idpackages/runtime/src/http-dispatcher.test.ts—_id→idpackages/client/src/*.test.ts—_id→idcontent/prompts/— Update_idrefs in prompt filescontent/docs/— Update_idrefs in documentation (including actions.mdx endpoint templates)packages/spec/DEVELOPMENT_PLAN.md—_id→idpackages/spec/docs/SYNC_ARCHITECTURE.md—modified_at→updated_atROADMAP.mdwith unified field naming entry_id/modified_at/space_idin protocol-level codeAudit Summary:
modified_at/modified_by: ✅ Zero remaining (only in ROADMAP changelog text)space_id: ✅ Zero remaining (only in ROADMAP changelog text)_id(standalone): ✅ Zero remaining in protocol code. Only remaining are:_idas param name) — correct_id") — correctforeignField: '_id'in storage-layer examples — intentionally preserved_id— correctOriginal prompt
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.