Skip to content

Commit

Permalink
Generate arrays to support client side sdk
Browse files Browse the repository at this point in the history
  • Loading branch information
ChappIO committed Aug 10, 2023
1 parent 9c5485d commit 4c26a36
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 3 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ Then, run the `models snapshot` command to export your model to disk: `directus
Example:

```bash
directus models snapshot ./src/model.ts
directus models snapshot ./path/to/target/model.d.ts
```

## Note: Geometry Support
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "directus-extension-models",
"description": "Generate .d.ts files from your directus schema",
"icon": "extension",
"version": "2.1.0",
"version": "2.2.0",
"keywords": [
"directus",
"directus-extension",
Expand Down
3 changes: 2 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -153,9 +153,10 @@ Model generation will still continue, no worries.

function generateIndex(collections: CollectionsOverview): string {
let source = ``;
console.log({collections});
source += '\nexport type Collections = {\n';
Object.values(collections).forEach((collection: Collection) => {
source += ` ${collection.collection}: ${className(collection)};\n`
source += ` ${collection.collection}: ${className(collection)}${collection.singleton ? '' : '[]'};\n`
});
source += '}\n';
return source;
Expand Down

0 comments on commit 4c26a36

Please sign in to comment.