Skip to content

Commit b8d5b11

Browse files
committed
fix(#4570): spell reference-doc import examples from the real export surface
`build-docs.ts` derived each page's "TypeScript Usage" block from the JSON Schema file name — the value import verbatim, the `import type` line with a `Schema` suffix stripped — on the assumption that both names exist. Nothing verified it, and `check:docs` structurally could not: it diffs the generator's output against the committed docs, so a name the generator invents stays "in sync" with itself forever. Compiling the committed `import type` lines against `packages/spec/src` gives 150 `has no exported member` errors, and every `.parse()` example called a type rather than the schema const. Both lines are now resolved against `api-surface.json`, the committed record of every `name (kind)` per public entry point: - value import: `<Name>Schema` when the entry exports it, else `<Name>` (a merged `export const Foo = z.enum(…)` + `export type Foo` is reported as `type` by kindOf, so presence — not kind — is the sound signal there); - type import: `<Name>` only when the entry exports it with a type-bearing kind, which kindOf's TypeAlias-before-Variable ordering makes decidable; - the example parses with the resolved const. A name that resolves to nothing is dropped from the page AND recorded in the new `docs-import-surface.baseline.json` — a shrink-only ratchet, so #4539's scenario (deleting a zero-consumer type alias while its schema keeps its reference page) now turns `check:docs` red instead of silently publishing a dead import. The baseline is regenerated only by an explicit `--update-import-baseline`, never by a `gen:` script, for the same reason the dual-source baseline is (#4446). 225 reference pages regenerate with corrected imports. The 154 accepted gaps are 150 schemas with no exported type alias (#4593) and 4 whose names are mangled by a first-occurrence `replace('Schema','')` in build-schemas.ts (#4592). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012C2cd7tL8QDoZ2QKN3djJ5
1 parent ce92674 commit b8d5b11

230 files changed

Lines changed: 1113 additions & 510 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
---
2+
"@objectstack/spec": patch
3+
---
4+
5+
Reference docs: import examples are now spelled from the package's real export surface
6+
7+
`build-docs.ts` derived each page's "TypeScript Usage" block from the JSON Schema file
8+
name — the value import verbatim, the `import type` line with a `Schema` suffix stripped —
9+
and nothing verified either name existed. `check:docs` could not catch it: it diffs the
10+
generator's output against the committed docs, so a name the generator invents stays "in
11+
sync" with itself forever. 150 of the committed `import type` names did not compile, and
12+
the `.parse()` example called a type rather than the schema const.
13+
14+
Both lines are now resolved against `api-surface.json`, the committed record of every
15+
`name (kind)` per entry point: only names the entry really exports are emitted, and the
16+
example parses with the actual schema const. A name that resolves to nothing is dropped
17+
from the page and recorded in the new `docs-import-surface.baseline.json` — a shrink-only
18+
ratchet, so removing a type alias while its schema keeps a reference page now turns
19+
`check:docs` red instead of silently publishing a dead import.

content/docs/references/ai/agent.mdx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,11 @@ AI Model Configuration
1414
## TypeScript Usage
1515

1616
```typescript
17-
import { AIModelConfig, Agent, StructuredOutputConfig, StructuredOutputFormat, TransformPipelineStep } from '@objectstack/spec/ai';
18-
import type { AIModelConfig, Agent, StructuredOutputConfig, StructuredOutputFormat, TransformPipelineStep } from '@objectstack/spec/ai';
17+
import { AIModelConfigSchema, AgentSchema, StructuredOutputConfigSchema, StructuredOutputFormatSchema, TransformPipelineStepSchema } from '@objectstack/spec/ai';
18+
import type { Agent, StructuredOutputConfig, StructuredOutputFormat, TransformPipelineStep } from '@objectstack/spec/ai';
1919

2020
// Validate data
21-
const result = AIModelConfig.parse(data);
21+
const result = AIModelConfigSchema.parse(data);
2222
```
2323

2424
---

content/docs/references/ai/conversation.mdx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,11 @@ Enables context preservation, conversation history, and token optimization.
1818
## TypeScript Usage
1919

2020
```typescript
21-
import { CodeContent, ConversationAnalytics, ConversationContext, ConversationMessage, ConversationSession, ConversationSummary, FileContent, FunctionCall, ImageContent, MessageContent, MessageContentType, MessagePruningEvent, MessageRole, TextContent, TokenBudgetConfig, TokenBudgetStrategy, TokenUsageStats, ToolCall } from '@objectstack/spec/ai';
22-
import type { CodeContent, ConversationAnalytics, ConversationContext, ConversationMessage, ConversationSession, ConversationSummary, FileContent, FunctionCall, ImageContent, MessageContent, MessageContentType, MessagePruningEvent, MessageRole, TextContent, TokenBudgetConfig, TokenBudgetStrategy, TokenUsageStats, ToolCall } from '@objectstack/spec/ai';
21+
import { CodeContentSchema, ConversationAnalyticsSchema, ConversationContextSchema, ConversationMessageSchema, ConversationSessionSchema, ConversationSummarySchema, FileContentSchema, FunctionCallSchema, ImageContentSchema, MessageContentSchema, MessageContentTypeSchema, MessagePruningEventSchema, MessageRoleSchema, TextContentSchema, TokenBudgetConfigSchema, TokenBudgetStrategySchema, TokenUsageStatsSchema, ToolCallSchema } from '@objectstack/spec/ai';
22+
import type { ConversationAnalytics, ConversationContext, ConversationMessage, ConversationSession, ConversationSummary, FunctionCall, MessageContent, MessageContentType, MessagePruningEvent, MessageRole, TokenBudgetConfig, TokenBudgetStrategy, TokenUsageStats, ToolCall } from '@objectstack/spec/ai';
2323

2424
// Validate data
25-
const result = CodeContent.parse(data);
25+
const result = CodeContentSchema.parse(data);
2626
```
2727

2828
---

content/docs/references/ai/embedding.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,11 @@ vector primitives so any RAG strategy can be built on top.
3838
## TypeScript Usage
3939

4040
```typescript
41-
import { EmbeddingModel, VectorStore, VectorStoreProvider } from '@objectstack/spec/ai';
41+
import { EmbeddingModelSchema, VectorStoreSchema, VectorStoreProviderSchema } from '@objectstack/spec/ai';
4242
import type { EmbeddingModel, VectorStore, VectorStoreProvider } from '@objectstack/spec/ai';
4343

4444
// Validate data
45-
const result = EmbeddingModel.parse(data);
45+
const result = EmbeddingModelSchema.parse(data);
4646
```
4747

4848
---

content/docs/references/ai/knowledge-document.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,11 @@ See `content/docs/protocol/knowledge.mdx` for the full design.
2626
## TypeScript Usage
2727

2828
```typescript
29-
import { KnowledgeChunk, KnowledgeDocument, KnowledgeHit } from '@objectstack/spec/ai';
29+
import { KnowledgeChunkSchema, KnowledgeDocumentSchema, KnowledgeHitSchema } from '@objectstack/spec/ai';
3030
import type { KnowledgeChunk, KnowledgeDocument, KnowledgeHit } from '@objectstack/spec/ai';
3131

3232
// Validate data
33-
const result = KnowledgeChunk.parse(data);
33+
const result = KnowledgeChunkSchema.parse(data);
3434
```
3535

3636
---

content/docs/references/ai/knowledge-source.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,11 @@ See `content/docs/protocol/knowledge.mdx` for the full design.
2828
## TypeScript Usage
2929

3030
```typescript
31-
import { FileKnowledgeSource, HttpKnowledgeSource, KnowledgeRefreshPolicy, KnowledgeSource, KnowledgeSourceKind, ObjectKnowledgeSource } from '@objectstack/spec/ai';
31+
import { FileKnowledgeSourceSchema, HttpKnowledgeSourceSchema, KnowledgeRefreshPolicySchema, KnowledgeSourceSchema, KnowledgeSourceKindSchema, ObjectKnowledgeSourceSchema } from '@objectstack/spec/ai';
3232
import type { FileKnowledgeSource, HttpKnowledgeSource, KnowledgeRefreshPolicy, KnowledgeSource, KnowledgeSourceKind, ObjectKnowledgeSource } from '@objectstack/spec/ai';
3333

3434
// Validate data
35-
const result = FileKnowledgeSource.parse(data);
35+
const result = FileKnowledgeSourceSchema.parse(data);
3636
```
3737

3838
---

content/docs/references/ai/mcp.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,11 @@ at runtime and does not need a metadata representation.
4040
## TypeScript Usage
4141

4242
```typescript
43-
import { MCPApprovalPolicy, MCPServerRef, MCPToolBinding, MCPTransport } from '@objectstack/spec/ai';
43+
import { MCPApprovalPolicySchema, MCPServerRefSchema, MCPToolBindingSchema, MCPTransportSchema } from '@objectstack/spec/ai';
4444
import type { MCPApprovalPolicy, MCPServerRef, MCPToolBinding, MCPTransport } from '@objectstack/spec/ai';
4545

4646
// Validate data
47-
const result = MCPApprovalPolicy.parse(data);
47+
const result = MCPApprovalPolicySchema.parse(data);
4848
```
4949

5050
---

content/docs/references/ai/model-registry.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,11 @@ Enables AI-powered ObjectStack applications to discover and use LLMs consistentl
1818
## TypeScript Usage
1919

2020
```typescript
21-
import { ModelCapability, ModelConfig, ModelLimits, ModelPricing, ModelProvider, ModelRegistry, ModelRegistryEntry, ModelSelectionCriteria, PromptTemplate, PromptVariable } from '@objectstack/spec/ai';
21+
import { ModelCapabilitySchema, ModelConfigSchema, ModelLimitsSchema, ModelPricingSchema, ModelProviderSchema, ModelRegistrySchema, ModelRegistryEntrySchema, ModelSelectionCriteriaSchema, PromptTemplateSchema, PromptVariableSchema } from '@objectstack/spec/ai';
2222
import type { ModelCapability, ModelConfig, ModelLimits, ModelPricing, ModelProvider, ModelRegistry, ModelRegistryEntry, ModelSelectionCriteria, PromptTemplate, PromptVariable } from '@objectstack/spec/ai';
2323

2424
// Validate data
25-
const result = ModelCapability.parse(data);
25+
const result = ModelCapabilitySchema.parse(data);
2626
```
2727

2828
---

content/docs/references/ai/skill.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,11 @@ Allows context-aware activation based on object type, user role, etc.
1818
## TypeScript Usage
1919

2020
```typescript
21-
import { Skill, SkillTriggerCondition } from '@objectstack/spec/ai';
21+
import { SkillSchema, SkillTriggerConditionSchema } from '@objectstack/spec/ai';
2222
import type { Skill, SkillTriggerCondition } from '@objectstack/spec/ai';
2323

2424
// Validate data
25-
const result = Skill.parse(data);
25+
const result = SkillSchema.parse(data);
2626
```
2727

2828
---

content/docs/references/ai/solution-blueprint.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,11 @@ batch-draft. This is the safety valve for low-specificity input.
3434
## TypeScript Usage
3535

3636
```typescript
37-
import { BlueprintApp, BlueprintCondition, BlueprintDashboard, BlueprintField, BlueprintNavItem, BlueprintObject, BlueprintSeed, BlueprintSummaryOperations, BlueprintView, BlueprintWidgetCondition, SolutionBlueprint, SolutionBlueprintStrict } from '@objectstack/spec/ai';
37+
import { BlueprintAppSchema, BlueprintConditionSchema, BlueprintDashboardSchema, BlueprintFieldSchema, BlueprintNavItemSchema, BlueprintObjectSchema, BlueprintSeedSchema, BlueprintSummaryOperationsSchema, BlueprintViewSchema, BlueprintWidgetConditionSchema, SolutionBlueprintSchema, SolutionBlueprintStrictSchema } from '@objectstack/spec/ai';
3838
import type { BlueprintApp, BlueprintCondition, BlueprintDashboard, BlueprintField, BlueprintNavItem, BlueprintObject, BlueprintSeed, BlueprintSummaryOperations, BlueprintView, BlueprintWidgetCondition, SolutionBlueprint, SolutionBlueprintStrict } from '@objectstack/spec/ai';
3939

4040
// Validate data
41-
const result = BlueprintApp.parse(data);
41+
const result = BlueprintAppSchema.parse(data);
4242
```
4343

4444
---

0 commit comments

Comments
 (0)