Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
…vation, extend SystemObjectName with all system objects, create sys-namespaced object definitions across plugin-auth/plugin-security/plugin-audit Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
…re unification Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
…ocumentation Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
|
@copilot 仔细评估是否已经完成了任务中要求的所有开发 |
…hema-config to use SystemObjectName constants Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
经过完整评估,发现了遗漏并在 72bc3eb 中修复: 补齐的遗漏项:
当前完成状态(issue 6 项工程任务):
|
There was a problem hiding this comment.
Pull request overview
Introduces a namespace-based system-object naming approach by adding an optional namespace to ObjectSchema, auto-deriving tableName from {namespace}_{name}, and adding/expanding canonical sys_* object definitions across auth/security/audit plugins.
Changes:
- Add
ObjectSchema.namespacewithObjectSchema.create()auto-derivingtableNameas{namespace}_{name}. - Expand
SystemObjectNameconstants and tests; update auth schema mappings to use the constants. - Add new
sysnamespace object definitions for plugin-auth/plugin-security and introduce a new plugin-audit package exportingSysAuditLog.
Reviewed changes
Copilot reviewed 33 out of 34 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| ROADMAP.md | Updates roadmap documentation for namespace-based system object naming + plugin ownership listing. |
| pnpm-lock.yaml | Lockfile updates including new plugin-audit importer and metadata fields. |
| packages/spec/src/system/constants/system-names.ts | Adds new SystemObjectName.* entries and makes resolveTableName namespace-aware. |
| packages/spec/src/system/constants/system-names.test.ts | Extends tests for new system object names and namespace table derivation behavior. |
| packages/spec/src/data/object.zod.ts | Adds namespace to ObjectSchema and auto-derives tableName in ObjectSchema.create(). |
| packages/spec/src/data/object.test.ts | Adds validation + factory tests for namespace acceptance and tableName derivation. |
| packages/plugins/plugin-security/src/objects/sys-role.object.ts | Adds SysRole system object definition (namespace: 'sys'). |
| packages/plugins/plugin-security/src/objects/sys-permission-set.object.ts | Adds SysPermissionSet system object definition (namespace: 'sys'). |
| packages/plugins/plugin-security/src/objects/index.ts | Exposes security plugin sys objects via a local barrel export. |
| packages/plugins/plugin-security/src/index.ts | Re-exports sys objects from plugin-security package entry. |
| packages/plugins/plugin-auth/src/objects/sys-verification.object.ts | Adds SysVerification system object definition. |
| packages/plugins/plugin-auth/src/objects/sys-user.object.ts | Adds SysUser system object definition. |
| packages/plugins/plugin-auth/src/objects/sys-two-factor.object.ts | Adds SysTwoFactor system object definition. |
| packages/plugins/plugin-auth/src/objects/sys-team.object.ts | Adds SysTeam system object definition. |
| packages/plugins/plugin-auth/src/objects/sys-team-member.object.ts | Adds SysTeamMember system object definition. |
| packages/plugins/plugin-auth/src/objects/sys-session.object.ts | Adds SysSession system object definition. |
| packages/plugins/plugin-auth/src/objects/sys-organization.object.ts | Adds SysOrganization system object definition. |
| packages/plugins/plugin-auth/src/objects/sys-member.object.ts | Adds SysMember system object definition. |
| packages/plugins/plugin-auth/src/objects/sys-invitation.object.ts | Adds SysInvitation system object definition. |
| packages/plugins/plugin-auth/src/objects/sys-api-key.object.ts | Adds SysApiKey system object definition. |
| packages/plugins/plugin-auth/src/objects/sys-account.object.ts | Adds SysAccount system object definition. |
| packages/plugins/plugin-auth/src/objects/index.ts | Reworks plugin-auth object exports: canonical Sys* plus deprecated Auth* re-exports. |
| packages/plugins/plugin-auth/src/objects/auth-verification.object.ts | Converts AuthVerification to a deprecated re-export of SysVerification. |
| packages/plugins/plugin-auth/src/objects/auth-user.object.ts | Converts AuthUser to a deprecated re-export of SysUser. |
| packages/plugins/plugin-auth/src/objects/auth-session.object.ts | Converts AuthSession to a deprecated re-export of SysSession. |
| packages/plugins/plugin-auth/src/objects/auth-account.object.ts | Converts AuthAccount to a deprecated re-export of SysAccount. |
| packages/plugins/plugin-auth/src/auth-schema-config.ts | Uses SystemObjectName.* constants for better-auth plugin schema model names. |
| packages/plugins/plugin-audit/tsconfig.json | Adds TS config for the new plugin-audit package. |
| packages/plugins/plugin-audit/src/objects/sys-audit-log.object.ts | Adds SysAuditLog system object definition for immutable audit trails. |
| packages/plugins/plugin-audit/src/objects/index.ts | Barrel export for audit plugin sys objects. |
| packages/plugins/plugin-audit/src/index.ts | Package entry exporting SysAuditLog. |
| packages/plugins/plugin-audit/package.json | New @objectstack/plugin-audit package definition and build/test scripts. |
| packages/metadata/src/objects/sys-metadata.object.ts | Migrates sys_metadata object to namespace: 'sys', name: 'metadata'. |
| CHANGELOG.md | Documents the namespace feature, new system objects, and new plugin-audit package. |
Files not reviewed (1)
- pnpm-lock.yaml: Language not supported
| ### Changed | ||
| - **System object naming convention** — All system objects now use `namespace: 'sys'` with short `name` | ||
| (e.g., `name: 'user'` instead of `name: 'sys_user'`). The `sys_` prefix is auto-derived via | ||
| `tableName` = `{namespace}_{name}`. File naming follows `sys-{name}.object.ts` pattern. | ||
| - **plugin-auth object exports** — New canonical exports use `Sys*` prefix (e.g., `SysUser`, `SysSession`). |
There was a problem hiding this comment.
The Unreleased section now contains two consecutive "### Changed" headings (one starting at line 26 and another at line 35). This breaks Keep-a-Changelog formatting and makes it unclear which bullets belong to which section. Please merge these into a single "### Changed" section (or otherwise restructure the headings) so there's only one "Changed" block per release section.
| * Namespace must be a single lowercase word (no underscores or hyphens) | ||
| * to ensure clean auto-derivation of `{namespace}_{name}` table names. | ||
| * | ||
| * @example namespace: 'sys' → tableName defaults to 'sys_user' | ||
| * @example namespace: 'crm' → tableName defaults to 'crm_account' | ||
| */ | ||
| namespace: z.string().regex(/^[a-z][a-z0-9]*$/).optional().describe('Logical domain namespace — single lowercase word (e.g. "sys", "crm"). Used for routing, permissions, and auto-deriving tableName as {namespace}_{name}.'), | ||
|
|
There was a problem hiding this comment.
The new namespace docs say it must be a "single lowercase word" and the test descriptions below also imply alpha-only, but the regex /^[a-z][a-z0-9]*$/ allows digits after the first character. Please either tighten the regex to match the stated constraint, or update the docs to explicitly allow lowercase alphanumerics.
| it('should reject invalid namespace format (must be lowercase alpha)', () => { | ||
| const result = ObjectSchema.safeParse({ | ||
| namespace: 'Sys', | ||
| name: 'user', | ||
| fields: {}, | ||
| }); | ||
| expect(result.success).toBe(false); | ||
| }); |
There was a problem hiding this comment.
Test description says namespace "must be lowercase alpha", but the actual schema regex allows digits (e.g. sys2). Please align the test wording with the implemented validation (or change the regex if alpha-only is intended).
| Objects now declare `namespace: 'sys'` and a short `name` (e.g., `name: 'user'`). The physical table name | ||
| `sys_user` is auto-derived as `{namespace}_{name}` by `ObjectSchema.create()`. | ||
|
|
||
| | Constant Key | Protocol Name | Plugin | Description | | ||
| |:---|:---|:---|:---| | ||
| | `SystemObjectName.USER` | `sys_user` | plugin-auth | Authentication: user identity | |
There was a problem hiding this comment.
In this section, the table column is labeled "Protocol Name" but the values shown (e.g. sys_user) are described elsewhere in the section as the physical table name auto-derived from {namespace}_{name}. Consider renaming the column to something like "Physical Table" / "Derived Table Name" to avoid confusing protocol identifiers with storage names. Also, since this section now describes a namespace-based convention, the section title still referencing a "sys_ Prefix" is misleading.
System objects were scattered across plugins with inconsistent naming, no namespace convention, and manual
tableNameboilerplate. This unifies allsys_*objects under a single architectural pattern.ObjectSchema
namespacepropertyNew optional field on
ObjectSchemaBase. When set,ObjectSchema.create()auto-derivestableNameas{namespace}_{name}:Explicit
tableNamestill wins. Objects withoutnamespaceare unaffected.StorageNameMapping.resolveTableName()updated with the same fallback chain:tableName→{namespace}_{name}→name.SystemObjectName expansion
Added 10 constants:
ORGANIZATION,MEMBER,INVITATION,TEAM,TEAM_MEMBER,API_KEY,TWO_FACTOR,ROLE,PERMISSION_SET,AUDIT_LOG(15 total including existingUSER,SESSION,ACCOUNT,VERIFICATION,METADATA).System object definitions by plugin
SysUser,SysSession,SysAccount,SysVerification) tonamespace: 'sys'. AddedSysOrganization,SysMember,SysInvitation,SysTeam,SysTeamMember,SysApiKey,SysTwoFactor.SysRole,SysPermissionSet.SysAuditLog— immutable, API read-only.All files follow
sys-{name}.object.ts/Sys{PascalCase}convention.auth-schema-config.ts unified to use SystemObjectName constants
All 6 organization plugin schema mappings (
AUTH_ORGANIZATION_SCHEMA,AUTH_MEMBER_SCHEMA,AUTH_INVITATION_SCHEMA,AUTH_TEAM_SCHEMA,AUTH_TEAM_MEMBER_SCHEMA,AUTH_TWO_FACTOR_SCHEMA) now referenceSystemObjectName.*constants instead of hardcoded'sys_*'strings, ensuring a single source of truth for all system object names.Backward compatibility
Old
auth-*.object.tsfiles re-export as deprecated aliases (AuthUser→SysUser, etc.). Removal planned for v4.0.Original prompt
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.