You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Console-side companion to framework#2694 (publish-time namespace-prefix enforcement). Give authors the compliant namespace at design time in Studio's dialogs, so they never build a prefix-less object and only discover it when publish rejects the batch.
Framework side (framework#2694)
New writable packages: if the manifest has no namespace, one is derived from the last id segment (com.example.leave → leave) and persisted; an explicitly declared namespace always wins (HotCRM crm untouched).
publishPackageDrafts rejects any draft whose object name lacks the <namespace>_ prefix — error Object 'ticket' is missing the package namespace prefix. Rename it to 'hr_ticket' (namespace = 'hr')., code NAMESPACE_PREFIX, whole batch fails atomically.
Two reusable helpers live in packages/spec/src/kernel/namespace-prefix.ts, exported from @objectstack/spec/kernel:
deriveNamespaceFromPackageId(packageId): string | null — last dot-segment, lowercased and sanitized to ^[a-z][a-z0-9_]{1,19}$.
validateObjectNamespacePrefix(objectName, namespace): string | null — returns an actionable message or null; allows sys_*, flags legacy <ns>__<short> FQNs.
objectui must reuse these two — do not re-implement the rule (AGENTS.md #0/#0.1: one spec-owned contract, no second de-facto dialect).
⛔ Blocked on: spec publish
These helpers are not yet in any published @objectstack/spec (npm latest is @objectstack/spec@12.6.0; this repo depends on ^12.3.0 — neither has them). framework#2694 is a minor bump, so they'll land in a new version (likely 12.7.0). Do not start until that version is published to npm — importing @objectstack/spec/kernel before then breaks typecheck/build/tests and can't be browser-verified or merged.
objectui changes needed (once spec publishes)
Bump the dep — raise @objectstack/spec in packages/app-shell/package.json to the version containing the helpers (mind the AGENTS.md version-alignment rule for the fixed release group).
New-package dialogs — add a namespace field (both writable-base creation entry points):
packages/app-shell/src/views/studio-design/BuilderLanding.tsx — the inline name+id creator (createBasePackage); this is the "只有名称+包 ID 两个字段" surface from the task.
packages/app-shell/src/views/studio-design/packages-io.ts — thread a namespace param through createBasePackage(id, name) into the POST body.
Field behavior: default = deriveNamespaceFromPackageId(packageId), live-updating with the package-id input until the user edits it; editable; validated against ^[a-z][a-z0-9_]{1,19}$ (2–20 chars); hint text "所有对象名将以 <namespace>_ 开头(如 leave_request)". Put namespace into the POST /api/v1/packages manifest (framework also back-derives, but sending it explicitly is clearer).
New-object dialog — auto-prefix the identifier — StudioDesignSurface.tsx "+ new object" (~L1825, via CreateItemDialog). On submit, run validateObjectNamespacePrefix(name, namespace); if non-compliant, prepend <namespace>_ (don't double-prefix an already-compliant name). Read the current package's namespace from its manifest via GET /api/v1/packages. Goal: an author can never produce a prefix-less object, and never eats a NAMESPACE_PREFIX rejection at publish.
New writable package: the namespace field defaults to the id-derived value, tracks the id input until touched, and is editable + validated.
New object: the identifier is auto-prefixed with the current package's namespace; already-compliant names are not double-prefixed.
Bypassing the UI (create a prefix-less object directly via API) and publishing surfaces the NAMESPACE_PREFIX error message inline in the publish result.
No renderer-side re-implementation of the derive/validate rule — both come from @objectstack/spec/kernel.
Console-side companion to framework#2694 (publish-time namespace-prefix enforcement). Give authors the compliant namespace at design time in Studio's dialogs, so they never build a prefix-less object and only discover it when publish rejects the batch.
Framework side (framework#2694)
New writable packages: if the manifest has no
namespace, one is derived from the last id segment (com.example.leave→leave) and persisted; an explicitly declared namespace always wins (HotCRMcrmuntouched).publishPackageDraftsrejects any draft whose object name lacks the<namespace>_prefix — errorObject 'ticket' is missing the package namespace prefix. Rename it to 'hr_ticket' (namespace = 'hr')., codeNAMESPACE_PREFIX, whole batch fails atomically.Two reusable helpers live in
packages/spec/src/kernel/namespace-prefix.ts, exported from@objectstack/spec/kernel:deriveNamespaceFromPackageId(packageId): string | null— last dot-segment, lowercased and sanitized to^[a-z][a-z0-9_]{1,19}$.validateObjectNamespacePrefix(objectName, namespace): string | null— returns an actionable message ornull; allowssys_*, flags legacy<ns>__<short>FQNs.objectui must reuse these two — do not re-implement the rule (AGENTS.md #0/#0.1: one spec-owned contract, no second de-facto dialect).
⛔ Blocked on: spec publish
These helpers are not yet in any published
@objectstack/spec(npm latest is@objectstack/spec@12.6.0; this repo depends on^12.3.0— neither has them). framework#2694 is a minor bump, so they'll land in a new version (likely12.7.0). Do not start until that version is published to npm — importing@objectstack/spec/kernelbefore then breaks typecheck/build/tests and can't be browser-verified or merged.objectui changes needed (once spec publishes)
Bump the dep — raise
@objectstack/specinpackages/app-shell/package.jsonto the version containing the helpers (mind the AGENTS.md version-alignment rule for the fixed release group).New-package dialogs — add a
namespacefield (both writable-base creation entry points):packages/app-shell/src/views/studio-design/BuilderLanding.tsx— the inline name+id creator (createBasePackage); this is the "只有名称+包 ID 两个字段" surface from the task.packages/app-shell/src/views/metadata-admin/PackagesPage.tsxCreatePackageDialog— the top-bar package-switcher "+ new" (POSTs{ manifest: {...} }).packages/app-shell/src/views/studio-design/packages-io.ts— thread anamespaceparam throughcreateBasePackage(id, name)into the POST body.deriveNamespaceFromPackageId(packageId), live-updating with the package-id input until the user edits it; editable; validated against^[a-z][a-z0-9_]{1,19}$(2–20 chars); hint text "所有对象名将以<namespace>_开头(如leave_request)". Putnamespaceinto the POST/api/v1/packagesmanifest (framework also back-derives, but sending it explicitly is clearer).New-object dialog — auto-prefix the identifier —
StudioDesignSurface.tsx"+ new object" (~L1825, viaCreateItemDialog). On submit, runvalidateObjectNamespacePrefix(name, namespace); if non-compliant, prepend<namespace>_(don't double-prefix an already-compliant name). Read the current package's namespace from its manifest viaGET /api/v1/packages. Goal: an author can never produce a prefix-less object, and never eats aNAMESPACE_PREFIXrejection at publish.Publish-failure display — verify that a
failed[]entry withcode: NAMESPACE_PREFIXshows itserrorcopy inline in the publish result (should already be covered by the inline-error work in #2589/fix(studio): surface spec-validation failures on the field at save/publish #2234 — confirm, don't rebuild).Acceptance
namespacefield defaults to the id-derived value, tracks the id input until touched, and is editable + validated.NAMESPACE_PREFIXerror message inline in the publish result.@objectstack/spec/kernel.Refs framework#2694.