@@ -141,44 +141,51 @@ const user: User = {
141141### Validation (Runtime)
142142
143143``` typescript
144+ // Style 1: Namespace from root
144145import { Data } from ' @objectstack/spec' ;
145- // OR
146- import { ObjectSchema } from ' @objectstack/spec/data' ;
146+ const result = Data .ObjectSchema .safeParse (userConfig );
147147
148+ // Style 2: Namespace via subpath
149+ import * as Data from ' @objectstack/spec/data' ;
148150const result = Data .ObjectSchema .safeParse (userConfig );
149- // OR
151+
152+ // Style 3: Direct subpath import
153+ import { ObjectSchema } from ' @objectstack/spec/data' ;
150154const result = ObjectSchema .safeParse (userConfig );
151155
152156if (! result .success ) {
153157 console .error (" Invalid Object definition" , result .error );
154158}
155159```
156- import * as Data from '@objectstack/spec /data';
157-
158- const result = Data.ObjectSchema.safeParse(userConfig);
159- ```
160160
161161### Type Definitions (Compile Time)
162162
163163``` typescript
164+ // Style 1: Namespace from root
164165import type { Data } from ' @objectstack/spec' ;
165- // Or: import type { Field } from '@objectstack/spec/data';
166-
167166const myField: Data .Field = {
168167 name: " task_name" ,
169168 type: " text" ,
170169 label: " Task Name"
171170};
171+
172+ // Style 2: Direct subpath import
173+ import type { Field } from ' @objectstack/spec/data' ;
174+ const myField: Field = {
175+ name: " task_name" ,
176+ type: " text" ,
177+ label: " Task Name"
178+ };
172179```
173180
174- Using subpath imports:
181+ Using namespace imports for multiple protocols :
175182
176183``` typescript
177- import type { Field } from ' @objectstack/spec/data' ;
178- import type { User } from ' @objectstack/spec/system' ;
184+ import type * as Data from ' @objectstack/spec/data' ;
185+ import type * as System from ' @objectstack/spec/system' ;
179186
180- const field: Field = { /* ... */ };
181- const user: User = { /* ... */ };
187+ const field: Data . Field = { /* ... */ };
188+ const user: System . User = { /* ... */ };
182189```
183190
184191### JSON Schema (Tooling)
0 commit comments