@contentrain/types 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Contentrain
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,174 @@
1
+ # `@contentrain/types`
2
+
3
+ Shared TypeScript types for the Contentrain ecosystem.
4
+
5
+ This package is the common schema layer used by:
6
+
7
+ - `@contentrain/mcp`
8
+ - `contentrain`
9
+ - `@contentrain/query`
10
+ - `@contentrain/rules`
11
+
12
+ It defines the stable type vocabulary for models, config, metadata, validation, scanning, and context files.
13
+
14
+ ## ✨ When To Use It
15
+
16
+ Use `@contentrain/types` when you are:
17
+
18
+ - building tooling on top of Contentrain packages
19
+ - sharing model/config types between packages in a workspace
20
+ - authoring framework integrations or SDK extensions
21
+ - consuming Contentrain JSON structures directly in TypeScript
22
+
23
+ ## 🚀 Install
24
+
25
+ ```bash
26
+ pnpm add @contentrain/types
27
+ ```
28
+
29
+ ## 📦 What It Exports
30
+
31
+ Core unions:
32
+
33
+ - `FieldType`
34
+ - `ModelKind`
35
+ - `ContentStatus`
36
+ - `ContentSource`
37
+ - `WorkflowMode`
38
+ - `StackType`
39
+ - `Platform`
40
+ - `ContextSource`
41
+ - `CollectionRuntimeFormat`
42
+ - `LocaleStrategy`
43
+
44
+ Core interfaces:
45
+
46
+ - `FieldDef`
47
+ - `ModelDefinition`
48
+ - `ContentrainConfig`
49
+ - `Vocabulary`
50
+ - `EntryMeta`
51
+ - `AssetEntry`
52
+ - `ValidationError`
53
+ - `ValidationResult`
54
+ - `ScaffoldTemplate`
55
+ - `ScanCandidate`
56
+ - `DuplicateGroup`
57
+ - `GraphNode`
58
+ - `ProjectGraph`
59
+ - `ScanCandidatesResult`
60
+ - `ScanSummaryResult`
61
+ - `ContextJson`
62
+
63
+ Storage/runtime helper types:
64
+
65
+ - `SingletonContentFile`
66
+ - `CollectionContentFile`
67
+ - `DictionaryContentFile`
68
+ - `CollectionEntry`
69
+ - `CollectionContentOutput`
70
+ - `SingletonMeta`
71
+ - `CollectionMeta`
72
+ - `DocumentMeta`
73
+ - `DictionaryMeta`
74
+
75
+ ## 🧭 Stability
76
+
77
+ This package is intended to be the shared public contract across the Contentrain ecosystem.
78
+
79
+ In practice that means:
80
+
81
+ - types exported from the package root are the public surface
82
+ - packages should depend on these shared definitions instead of redefining domain types
83
+ - breaking changes here should be treated as ecosystem-level breaking changes
84
+
85
+ ## 🧪 Quick Example
86
+
87
+ ```ts
88
+ import type {
89
+ ContentrainConfig,
90
+ FieldDef,
91
+ ModelDefinition,
92
+ ValidationResult,
93
+ } from '@contentrain/types'
94
+
95
+ const fields: Record<string, FieldDef> = {
96
+ title: { type: 'string', required: true },
97
+ slug: { type: 'slug', required: true, unique: true },
98
+ }
99
+
100
+ const model: ModelDefinition = {
101
+ id: 'blog-post',
102
+ name: 'Blog Post',
103
+ kind: 'collection',
104
+ domain: 'blog',
105
+ i18n: true,
106
+ fields,
107
+ }
108
+
109
+ const config: ContentrainConfig = {
110
+ version: 1,
111
+ stack: 'next',
112
+ workflow: 'review',
113
+ locales: { default: 'en', supported: ['en', 'tr'] },
114
+ domains: ['blog'],
115
+ }
116
+
117
+ const result: ValidationResult = {
118
+ valid: true,
119
+ errors: [],
120
+ }
121
+ ```
122
+
123
+ ## 📝 Import Style
124
+
125
+ Type-only usage:
126
+
127
+ ```ts
128
+ import type { ModelDefinition, ContentrainConfig } from '@contentrain/types'
129
+ ```
130
+
131
+ Runtime-safe mixed usage:
132
+
133
+ ```ts
134
+ import type { FieldDef } from '@contentrain/types'
135
+ ```
136
+
137
+ ## 🧠 Design Role
138
+
139
+ `@contentrain/types` exists so every package in the monorepo speaks the same domain language.
140
+
141
+ Examples:
142
+
143
+ - MCP validates and writes `ModelDefinition`
144
+ - CLI reads `ContextJson`
145
+ - SDK codegen consumes `ModelDefinition` and `FieldDef`
146
+ - AI rules align with the same model and workflow vocabulary
147
+
148
+ This package should stay:
149
+
150
+ - small
151
+ - dependency-light
152
+ - stable
153
+ - free of package-specific behavior
154
+
155
+ ## 🛠 Development
156
+
157
+ From the monorepo root:
158
+
159
+ ```bash
160
+ pnpm --filter @contentrain/types build
161
+ pnpm --filter @contentrain/types test
162
+ pnpm --filter @contentrain/types typecheck
163
+ ```
164
+
165
+ ## 🔗 Related Packages
166
+
167
+ - `@contentrain/mcp`
168
+ - `contentrain`
169
+ - `@contentrain/query`
170
+ - `@contentrain/rules`
171
+
172
+ ## 📄 License
173
+
174
+ MIT
@@ -0,0 +1,191 @@
1
+ //#region src/index.d.ts
2
+ type FieldType = 'string' | 'text' | 'email' | 'url' | 'slug' | 'color' | 'phone' | 'code' | 'icon' | 'markdown' | 'richtext' | 'number' | 'integer' | 'decimal' | 'percent' | 'rating' | 'boolean' | 'date' | 'datetime' | 'image' | 'video' | 'file' | 'relation' | 'relations' | 'select' | 'array' | 'object';
3
+ type ModelKind = 'singleton' | 'collection' | 'document' | 'dictionary';
4
+ type ContentStatus = 'draft' | 'in_review' | 'published' | 'rejected' | 'archived';
5
+ type ContentSource = 'agent' | 'human' | 'import';
6
+ type WorkflowMode = 'auto-merge' | 'review';
7
+ type StackType = 'nuxt' | 'next' | 'astro' | 'sveltekit' | 'remix' | 'analog' | 'vue' | 'react' | 'svelte' | 'solid' | 'angular' | 'react-native' | 'expo' | 'flutter' | 'node' | 'express' | 'fastify' | 'nestjs' | 'django' | 'rails' | 'laravel' | 'go' | 'rust' | 'dotnet' | 'hugo' | 'jekyll' | 'eleventy' | 'electron' | 'tauri' | 'other';
8
+ type Platform = 'web' | 'mobile' | 'api' | 'desktop' | 'static' | 'other';
9
+ type ContextSource = 'mcp-local' | 'mcp-studio' | 'studio-ui';
10
+ type CollectionRuntimeFormat = 'map' | 'array';
11
+ interface FieldDef {
12
+ type: FieldType;
13
+ required?: boolean;
14
+ unique?: boolean;
15
+ default?: unknown;
16
+ min?: number;
17
+ max?: number;
18
+ pattern?: string;
19
+ options?: string[];
20
+ model?: string | string[];
21
+ items?: string | FieldDef;
22
+ fields?: Record<string, FieldDef>;
23
+ accept?: string;
24
+ maxSize?: number;
25
+ description?: string;
26
+ }
27
+ type LocaleStrategy = 'file' | 'suffix' | 'directory' | 'none';
28
+ interface ModelDefinition {
29
+ id: string;
30
+ name: string;
31
+ kind: ModelKind;
32
+ domain: string;
33
+ i18n: boolean;
34
+ description?: string;
35
+ fields?: Record<string, FieldDef>;
36
+ /** Framework-relative path for content files (e.g. "content/blog", "locales"). When set, content is written here instead of .contentrain/content/ */
37
+ content_path?: string;
38
+ /** How locale is encoded in file names. Default: "file" ({dir}/{locale}.json or {dir}/{slug}/{locale}.md) */
39
+ locale_strategy?: LocaleStrategy;
40
+ }
41
+ interface ContentrainConfig {
42
+ version: number;
43
+ platform?: Platform;
44
+ stack: StackType;
45
+ workflow: WorkflowMode;
46
+ repository?: {
47
+ provider: 'github';
48
+ owner: string;
49
+ name: string;
50
+ default_branch: string;
51
+ };
52
+ locales: {
53
+ default: string;
54
+ supported: string[];
55
+ };
56
+ domains: string[];
57
+ assets_path?: string;
58
+ branchRetention?: number;
59
+ }
60
+ interface Vocabulary {
61
+ version: number;
62
+ terms: Record<string, Record<string, string>>;
63
+ }
64
+ interface EntryMeta {
65
+ status: ContentStatus;
66
+ source: ContentSource;
67
+ updated_by: string;
68
+ approved_by?: string | null;
69
+ version?: string;
70
+ publish_at?: string;
71
+ expire_at?: string;
72
+ }
73
+ type SingletonMeta = EntryMeta;
74
+ type CollectionMeta = Record<string, EntryMeta>;
75
+ type DocumentMeta = EntryMeta;
76
+ type DictionaryMeta = EntryMeta;
77
+ interface AssetEntry {
78
+ path: string;
79
+ type: string;
80
+ size: number;
81
+ alt?: string;
82
+ }
83
+ interface ValidationError {
84
+ severity: 'error' | 'warning' | 'notice';
85
+ model?: string;
86
+ locale?: string;
87
+ entry?: string;
88
+ slug?: string;
89
+ field?: string;
90
+ message: string;
91
+ }
92
+ interface ValidationResult {
93
+ valid: boolean;
94
+ errors: ValidationError[];
95
+ }
96
+ type SingletonContentFile = Record<string, unknown>;
97
+ type CollectionContentFile = Record<string, Record<string, unknown>>;
98
+ type DictionaryContentFile = Record<string, string>;
99
+ type CollectionEntry = {
100
+ id: string;
101
+ } & Record<string, unknown>;
102
+ type CollectionContentOutput = CollectionEntry[];
103
+ interface ScaffoldTemplate {
104
+ id: string;
105
+ models: ModelDefinition[];
106
+ sample_content?: Record<string, Record<string, unknown>>;
107
+ vocabulary?: Record<string, Record<string, string>>;
108
+ }
109
+ type StringContext = 'jsx_text' | 'jsx_attribute' | 'template_text' | 'template_attribute' | 'variable_assignment' | 'function_argument' | 'object_value' | 'other';
110
+ type FileCategory = 'page' | 'component' | 'layout' | 'other';
111
+ interface ScanCandidate {
112
+ file: string;
113
+ line: number;
114
+ column: number;
115
+ value: string;
116
+ context: StringContext;
117
+ surrounding: string;
118
+ }
119
+ interface DuplicateGroup {
120
+ value: string;
121
+ count: number;
122
+ occurrences: Array<{
123
+ file: string;
124
+ line: number;
125
+ }>;
126
+ }
127
+ interface GraphNode {
128
+ file: string;
129
+ category: FileCategory;
130
+ components?: string[];
131
+ imports: string[];
132
+ used_by: string[];
133
+ strings: number;
134
+ }
135
+ interface ProjectGraph {
136
+ pages: GraphNode[];
137
+ components: GraphNode[];
138
+ layouts: GraphNode[];
139
+ orphan_files: string[];
140
+ stats: {
141
+ total_files: number;
142
+ total_components: number;
143
+ total_pages: number;
144
+ total_strings_estimate: number;
145
+ };
146
+ }
147
+ interface ScanCandidatesResult {
148
+ candidates: ScanCandidate[];
149
+ duplicates: DuplicateGroup[];
150
+ stats: {
151
+ files_scanned: number;
152
+ raw_strings_found: number;
153
+ after_filtering: number;
154
+ candidates_returned: number;
155
+ has_more: boolean;
156
+ };
157
+ }
158
+ interface ScanSummaryResult {
159
+ total_files: number;
160
+ total_candidates_estimate: number;
161
+ by_directory: Record<string, {
162
+ files: number;
163
+ candidates: number;
164
+ }>;
165
+ top_repeated: Array<{
166
+ value: string;
167
+ count: number;
168
+ }>;
169
+ sampling_note?: string;
170
+ file_types: Record<string, number>;
171
+ }
172
+ interface ContextJson {
173
+ version: string;
174
+ lastOperation: {
175
+ tool: string;
176
+ model: string;
177
+ locale: string;
178
+ entries?: string[];
179
+ timestamp: string;
180
+ source: ContextSource;
181
+ };
182
+ stats: {
183
+ models: number;
184
+ entries: number;
185
+ locales: string[];
186
+ lastSync: string;
187
+ };
188
+ }
189
+ //#endregion
190
+ export { AssetEntry, CollectionContentFile, CollectionContentOutput, CollectionEntry, CollectionMeta, CollectionRuntimeFormat, ContentSource, ContentStatus, ContentrainConfig, ContextJson, ContextSource, DictionaryContentFile, DictionaryMeta, DocumentMeta, DuplicateGroup, EntryMeta, FieldDef, FieldType, FileCategory, GraphNode, LocaleStrategy, ModelDefinition, ModelKind, Platform, ProjectGraph, ScaffoldTemplate, ScanCandidate, ScanCandidatesResult, ScanSummaryResult, SingletonContentFile, SingletonMeta, StackType, StringContext, ValidationError, ValidationResult, Vocabulary, WorkflowMode };
191
+ //# sourceMappingURL=index.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.mts","names":[],"sources":["../src/index.ts"],"mappings":";KAEY,SAAA;AAAA,KAUA,SAAA;AAAA,KACA,aAAA;AAAA,KACA,aAAA;AAAA,KACA,YAAA;AAAA,KAEA,SAAA;AAAA,KAeA,QAAA;AAAA,KACA,aAAA;AAAA,KACA,uBAAA;AAAA,UAIK,QAAA;EACf,IAAA,EAAM,SAAA;EACN,QAAA;EACA,MAAA;EACA,OAAA;EACA,GAAA;EACA,GAAA;EACA,OAAA;EACA,OAAA;EACA,KAAA;EACA,KAAA,YAAiB,QAAA;EACjB,MAAA,GAAS,MAAA,SAAe,QAAA;EACxB,MAAA;EACA,OAAA;EACA,WAAA;AAAA;AAAA,KAKU,cAAA;AAAA,UAEK,eAAA;EACf,EAAA;EACA,IAAA;EACA,IAAA,EAAM,SAAA;EACN,MAAA;EACA,IAAA;EACA,WAAA;EACA,MAAA,GAAS,MAAA,SAAe,QAAA;EAlCN;EAoClB,YAAA;EAnCU;EAqCV,eAAA,GAAkB,cAAA;AAAA;AAAA,UAKH,iBAAA;EACf,OAAA;EACA,QAAA,GAAW,QAAA;EACX,KAAA,EAAO,SAAA;EACP,QAAA,EAAU,YAAA;EACV,UAAA;IACE,QAAA;IACA,KAAA;IACA,IAAA;IACA,cAAA;EAAA;EAEF,OAAA;IACE,OAAA;IACA,SAAA;EAAA;EAEF,OAAA;EACA,WAAA;EACA,eAAA;AAAA;AAAA,UAKe,UAAA;EACf,OAAA;EACA,KAAA,EAAO,MAAA,SAAe,MAAA;AAAA;AAAA,UAKP,SAAA;EACf,MAAA,EAAQ,aAAA;EACR,MAAA,EAAQ,aAAA;EACR,UAAA;EACA,WAAA;EACA,OAAA;EACA,UAAA;EACA,SAAA;AAAA;AAAA,KAGU,aAAA,GAA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Y,cAAA;EACZ,KAAA;IACE,aAAA;IACA,iBAAA;IACA,eAAA;IACA,mBAAA;IACA,QAAA;EAAA;AAAA;AAAA,UAIa,iBAAA;EACf,WAAA;EACA,yBAAA;EACA,YAAA,EAAc,MAAA;IAAiB,KAAA;IAAe,UAAA;EAAA;EAC9C,YAAA,EAAc,KAAA;IAAQ,KAAA;IAAe,KAAA;EAAA;EACrC,aAAA;EACA,UAAA,EAAY,MAAA;AAAA;AAAA,UAKG,WAAA;EACf,OAAA;EACA,aAAA;IACE,IAAA;IACA,KAAA;IACA,MAAA;IACA,OAAA;IACA,SAAA;IACA,MAAA,EAAQ,aAAA;EAAA;EAEV,KAAA;IACE,MAAA;IACA,OAAA;IACA,OAAA;IACA,QAAA;EAAA;AAAA"}
package/dist/index.mjs ADDED
@@ -0,0 +1 @@
1
+ export {};
package/package.json ADDED
@@ -0,0 +1,49 @@
1
+ {
2
+ "name": "@contentrain/types",
3
+ "version": "0.1.0",
4
+ "license": "MIT",
5
+ "description": "Shared TypeScript types for Contentrain ecosystem",
6
+ "type": "module",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "git+https://github.com/contentrain/contentrain-ai.git",
10
+ "directory": "packages/types"
11
+ },
12
+ "homepage": "https://github.com/contentrain/contentrain-ai/tree/main/packages/types",
13
+ "bugs": {
14
+ "url": "https://github.com/contentrain/contentrain-ai/issues"
15
+ },
16
+ "keywords": [
17
+ "contentrain",
18
+ "types",
19
+ "typescript",
20
+ "schema",
21
+ "content-governance"
22
+ ],
23
+ "sideEffects": false,
24
+ "publishConfig": {
25
+ "access": "public"
26
+ },
27
+ "exports": {
28
+ ".": {
29
+ "types": "./dist/index.d.ts",
30
+ "import": "./dist/index.mjs"
31
+ }
32
+ },
33
+ "main": "./dist/index.mjs",
34
+ "types": "./dist/index.d.ts",
35
+ "files": [
36
+ "dist"
37
+ ],
38
+ "devDependencies": {
39
+ "tsdown": "^0.21.0",
40
+ "typescript": "^5.7.0"
41
+ },
42
+ "scripts": {
43
+ "build": "tsdown src/index.ts --format esm --dts",
44
+ "dev": "tsdown src/index.ts --format esm --dts --watch",
45
+ "test": "vitest run",
46
+ "typecheck": "tsc --noEmit",
47
+ "clean": "rm -rf dist"
48
+ }
49
+ }