@@ -149,19 +149,114 @@ import { ${fileName}Schema } from "./${fileName}.schema";
149149${ shapeTypeImports }
150150
151151${ shapeTypeExports }
152+ ` ;
153+
154+ // Generate typings.ts - TypeScript interfaces for the shapes
155+ const typingsContent = `import { LdoJsonldContext, LdSet } from "@ldo/ldo";
156+
157+ /**
158+ * =============================================================================
159+ * Typescript Typings for ${ fileName }
160+ * =============================================================================
161+ */
162+
163+ /**
164+ * AccessControlResource Type
165+ */
166+ export interface AccessControlResource {
167+ "@id"?: string;
168+ "@context"?: LdoJsonldContext;
169+ type: LdSet<{
170+ "@id": "AccessControlResource";
171+ }>;
172+ resource: {
173+ "@id": string;
174+ };
175+ accessControl: LdSet<AccessControl>;
176+ }
177+
178+ /**
179+ * AccessControl Type
180+ */
181+ export interface AccessControl {
182+ "@id"?: string;
183+ "@context"?: LdoJsonldContext;
184+ type: LdSet<{
185+ "@id": "AccessControl";
186+ }>;
187+ apply: Policy;
188+ }
189+
190+ /**
191+ * Policy Type
192+ */
193+ export interface Policy {
194+ "@id"?: string;
195+ "@context"?: LdoJsonldContext;
196+ type: LdSet<{
197+ "@id": "Policy";
198+ }>;
199+ allow:
200+ | {
201+ "@id": "Read";
202+ }
203+ | {
204+ "@id": "Write";
205+ };
206+ anyOf: Matcher;
207+ agentGroup?: LdSet<AgentGroup>;
208+ public?: Public;
209+ }
210+
211+ /**
212+ * Matcher Type
213+ */
214+ export interface Matcher {
215+ "@id"?: string;
216+ "@context"?: LdoJsonldContext;
217+ type: LdSet<{
218+ "@id": "Matcher";
219+ }>;
220+ agent: {
221+ "@id": string;
222+ };
223+ }
224+
225+ /**
226+ * AgentGroup Type
227+ */
228+ export interface AgentGroup {
229+ "@id"?: string;
230+ "@context"?: LdoJsonldContext;
231+ type: LdSet<{
232+ "@id": "AgentGroup";
233+ }>;
234+ }
235+
236+ /**
237+ * Public Type
238+ */
239+ export interface Public {
240+ "@id"?: string;
241+ "@context"?: LdoJsonldContext;
242+ type: LdSet<{
243+ "@id": "Public";
244+ }>;
245+ }
152246` ;
153247
154248 // Write files - always overwrite to ensure they're not empty
155249 const contextPath = path . join ( outputDir , `${ fileName } .context.ts` ) ;
156250 const schemaPath = path . join ( outputDir , `${ fileName } .schema.ts` ) ;
157251 const shapeTypesPath = path . join ( outputDir , `${ fileName } .shapeTypes.ts` ) ;
252+ const typingsPath = path . join ( outputDir , `${ fileName } .typings.ts` ) ;
158253
159254 // Check if files exist and are empty - if so, delete them to force regeneration
160- [ contextPath , schemaPath , shapeTypesPath ] . forEach ( filePath => {
255+ [ contextPath , schemaPath , shapeTypesPath , typingsPath ] . forEach ( filePath => {
161256 if ( fs . existsSync ( filePath ) ) {
162257 const stats = fs . statSync ( filePath ) ;
163258 if ( stats . size === 0 ) {
164- console . log ( `⚠️ Deleting empty file: ${ filePath } ` ) ;
259+ console . log ( `Deleting empty file: ${ filePath } ` ) ;
165260 fs . unlinkSync ( filePath ) ;
166261 }
167262 }
@@ -171,18 +266,20 @@ ${shapeTypeExports}
171266 fs . writeFileSync ( contextPath , contextContent , 'utf8' ) ;
172267 fs . writeFileSync ( schemaPath , schemaContent , 'utf8' ) ;
173268 fs . writeFileSync ( shapeTypesPath , shapeTypesContent , 'utf8' ) ;
269+ fs . writeFileSync ( typingsPath , typingsContent , 'utf8' ) ;
174270
175271 // Verify files were written correctly
176272 const contextSize = fs . statSync ( contextPath ) . size ;
177273 const schemaSize = fs . statSync ( schemaPath ) . size ;
178274 const shapeTypesSize = fs . statSync ( shapeTypesPath ) . size ;
275+ const typingsSize = fs . statSync ( typingsPath ) . size ;
179276
180- if ( contextSize === 0 || schemaSize === 0 || shapeTypesSize === 0 ) {
277+ if ( contextSize === 0 || schemaSize === 0 || shapeTypesSize === 0 || typingsSize === 0 ) {
181278 console . error ( `Warning: One or more files for ${ fileName } are empty!` ) ;
182- console . error ( `Context: ${ contextSize } bytes, Schema: ${ schemaSize } bytes, ShapeTypes: ${ shapeTypesSize } bytes` ) ;
279+ console . error ( `Context: ${ contextSize } bytes, Schema: ${ schemaSize } bytes, ShapeTypes: ${ shapeTypesSize } bytes, Typings: ${ typingsSize } bytes ` ) ;
183280 process . exit ( 1 ) ;
184281 } else {
185- console . log ( `Generated files for ${ fileName } (${ contextSize + schemaSize + shapeTypesSize } bytes total)` ) ;
282+ console . log ( `Generated files for ${ fileName } (${ contextSize + schemaSize + shapeTypesSize + typingsSize } bytes total)` ) ;
186283 }
187284 } catch ( error ) {
188285 console . error ( `Error writing files for ${ fileName } :` , error . message ) ;
0 commit comments