Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions .changeset/front-door-examples-compile.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
---
'@objectstack/spec': patch
---

Fix four self-contained TSDoc `@example` blocks in `packages/spec/src` that did
not compile against the package's own built declarations, and add `os:check`
markers so `check:skill-examples` keeps them honest going forward.

The package's front-door header (`src/index.ts`) taught a root namespace-import
style (`import { Data, UI, System, Auth, AI, API } from '@objectstack/spec'`)
the root has never exported, and two subpath-import styles that named
`@objectstack/spec/auth` — a subpath that does not exist (the real one is
`@objectstack/spec/identity`). The header now documents three styles that
actually compile: root-level `defineX` factory imports (`defineStack`,
`defineView`, `defineApp`, `defineFlow`, `defineAgent`, `defineTool`,
`defineSkill`, …, which the root really does export), namespace imports via
subpath, and direct subpath imports — all against `@objectstack/spec/identity`
instead of the non-existent `/auth`.

`src/shared/branded-types.zod.ts`'s `@example` imported `ObjectNameSchema` /
`FieldNameSchema` from the package root; both are exported only from
`@objectstack/spec/shared`. Fixed the specifier.

No behavior change — TSDoc examples only.
2 changes: 1 addition & 1 deletion content/docs/references/shared/branded-types.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ where a FieldName is expected, even though both are strings at runtime.

@example
```ts
import { ObjectNameSchema, FieldNameSchema } from '@objectstack/spec';
import { ObjectNameSchema, FieldNameSchema } from '@objectstack/spec/shared';

const objName = ObjectNameSchema.parse('project_task'); // ObjectName
const fieldName = FieldNameSchema.parse('task_name'); // FieldName
Expand Down
56 changes: 40 additions & 16 deletions packages/spec/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,37 +5,61 @@
*
* ObjectStack Protocol & Specification
*
* This package does NOT export types at the root level to prevent naming conflicts.
* Please use namespaced imports or subpath imports.
*
* This package does NOT export type namespaces at the root level, to prevent
* naming conflicts — `import { Data, UI, System } from '@objectstack/spec'`
* names nothing the root exports. The root DOES export a curated set of
* authoring `defineX` factory functions (`defineStack`, `defineView`,
* `defineApp`, `defineFlow`, `defineAgent`, `defineTool`, `defineSkill`, …)
* for direct top-level use. Every domain's TYPES, and its `*Schema` values,
* are reached through that domain's own subpath instead
* (`@objectstack/spec/data`, `@objectstack/spec/identity`, …).
*
* ## Import Styles
*
* ### Style 1: Namespace Imports from Root
*
* ### Style 1: Root-Level Factory Imports
* <!-- os:check -->
* ```typescript
* import { Data, UI, System, Auth, AI, API } from '@objectstack/spec';
*
* const field: Data.Field = { name: 'task_name', type: 'text' };
* const user: Auth.User = { id: 'u1', email: 'user@example.com' };
* import { defineSkill } from '@objectstack/spec';
*
* const skill = defineSkill({
* name: 'case_management',
* label: 'Case Management',
* description: 'Handles support case lifecycle',
* instructions: 'Use these tools to create, update, and resolve support cases.',
* tools: ['create_case', 'update_case', 'resolve_case'],
* });
* ```
*
*
* ### Style 2: Namespace Imports via Subpath
* <!-- os:check -->
* ```typescript
* import * as Data from '@objectstack/spec/data';
* import * as UI from '@objectstack/spec/ui';
* import * as System from '@objectstack/spec/system';
* import * as Auth from '@objectstack/spec/auth';
*
* import * as Identity from '@objectstack/spec/identity';
*
* const field: Data.Field = { name: 'task_name', type: 'text' };
* const user: Auth.User = { id: 'u1', email: 'user@example.com' };
* const user: Identity.User = {
* id: 'u1',
* email: 'user@example.com',
* createdAt: '2026-01-01T00:00:00.000Z',
* updatedAt: '2026-01-01T00:00:00.000Z',
* };
* ```
*
*
* ### Style 3: Direct Subpath Imports
* <!-- os:check -->
* ```typescript
* import { Field, FieldType } from '@objectstack/spec/data';
* import { User, Session } from '@objectstack/spec/auth';
* import { User } from '@objectstack/spec/identity';
*
* const field: Field = { name: 'task_name', type: 'text' };
* const user: User = { id: 'u1', email: 'user@example.com' };
* const user: User = {
* id: 'u1',
* email: 'user@example.com',
* createdAt: '2026-01-01T00:00:00.000Z',
* updatedAt: '2026-01-01T00:00:00.000Z',
* };
* ```
*
* ## Standing principle for export surfaces (#10096, maintainer ruling 2026-08-20)
Expand Down
3 changes: 2 additions & 1 deletion packages/spec/src/shared/branded-types.zod.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,9 @@ import { SnakeCaseIdentifierSchema, SystemIdentifierSchema } from './identifiers
* where a FieldName is expected, even though both are strings at runtime.
*
* @example
* <!-- os:check -->
* ```ts
* import { ObjectNameSchema, FieldNameSchema } from '@objectstack/spec';
* import { ObjectNameSchema, FieldNameSchema } from '@objectstack/spec/shared';
*
* const objName = ObjectNameSchema.parse('project_task'); // ObjectName
* const fieldName = FieldNameSchema.parse('task_name'); // FieldName
Expand Down
Loading