Skip to content

Commit 15730bd

Browse files
Merge pull request #28 from solid/feat/my-storages
Add CODEOWNERS file to require odi-team review for all changes
2 parents 226138e + 27826fb commit 15730bd

3 files changed

Lines changed: 111 additions & 6 deletions

File tree

.github/CODEOWNERS

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# CODEOWNERS file for Solid File Manager
2+
# This file defines who is responsible for code in this repository.
3+
# All changes require approval from at least one member of the odi-team.
4+
5+
# All files in the repository are owned by the ODI Team in the Solid organization
6+
# This ensures all PRs require review from the team
7+
* @solid/odi-team
8+

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"dev": "npm run build:ldo && next dev --port=3001",
88
"build": "npm run build:ldo && npm run build:next",
99
"build:shacl2shex": "npx @jeswr/shacl2shex src/shapes/Model.shaclc src/shapes/Model.shex && node scripts/fix-shex.js",
10-
"build:ldo": "npm run build:shacl2shex && npx @ldo/cli build --input ./src/shapes --output ./src/ldo || true && node scripts/generate-ldo-files.js && node -e \"const fs=require('fs');const files=['src/ldo/Model.context.ts','src/ldo/Model.schema.ts','src/ldo/Model.shapeTypes.ts'];const empty=files.filter(f=>!fs.existsSync(f)||fs.statSync(f).size===0);if(empty.length>0){console.error('Files are empty:',empty.join(', '));process.exit(1);}else{console.log('All LDO files generated successfully');}\"",
10+
"build:ldo": "npm run build:shacl2shex && npx @ldo/cli build --input ./src/shapes --output ./src/ldo || true && node scripts/generate-ldo-files.js && node -e \"const fs=require('fs');const files=['src/ldo/Model.context.ts','src/ldo/Model.schema.ts','src/ldo/Model.shapeTypes.ts','src/ldo/Model.typings.ts'];const empty=files.filter(f=>!fs.existsSync(f)||fs.statSync(f).size===0);if(empty.length>0){console.error('Files are empty:',empty.join(', '));process.exit(1);}else{console.log('All LDO files generated successfully');}\"",
1111
"build:next": "next build",
1212
"start": "next start",
1313
"start:dev": "concurrently \"npm run start:css\" \"npm run start:ldo\" \"npm run dev\"",

scripts/generate-ldo-files.js

Lines changed: 102 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)