Entity definitions in separate YML files

Hi, I'd like to propose a solution that allows for defining entities in separate files. In this case, the manifest.yml file would have a structure like:
### manifest.yml
name: Example App
entities:
User:
properties:
- name
# ...

extend:
- entities/Language.yml

### entities/Language.yml
Language:
properties: #...
### manifest.yml
name: Example App
entities:
User:
properties:
- name
# ...

extend:
- entities/Language.yml

### entities/Language.yml
Language:
properties: #...
What do you think, does it make sense? I'd find it useful, as building a single file for multiple entities, often with comments, is a bit pointless for me.
2 Replies
SebConejo
SebConejo2mo ago
Hi @fedehusk thank you for your feedback. What's the purpos of this feature request ? Is it to have a clean repo, easier to read ? We can add it to the feature-request and let see if it is upvoted by the community. It's the best way to see your proposals implemented. -> https://github.com/mnfst/manifest/discussions/categories/feature-request
GitHub
mnfst manifest Feature Request · Discussions
Explore the GitHub Discussions forum for mnfst manifest in the Feature Request category.
fedehusk
fedehuskOP2mo ago
My main purpose is to have an easier to read schema file. I'm using Manifest more like some database helper, not strictly as a full backend service. This way I don't have to use too many SQL functions and I can save some time while coding. At the moment I use the script below:
console.log("\x1b[42m\x1b[30m[MANIFEST]\x1b[0m", "GENERATING MANIFEST.YML FILE");
import YAML from "yaml"; import { $, Glob } from "bun";
const g = new Glob("*.yml");

const mode = Bun.argv.at(2) || "parse";
console.log("\x1b[46m\x1b[30m[MANIFEST]\x1b[0m", "Using "+mode+" mode");

if (mode == "parse") {

let entities = {};
for (const f of g.scanSync("./manifest")) {
entities[f.replace(".yml", "")] = YAML.parse(await Bun.file('./manifest/'+f).text())[f.replace(".yml", "")];
console.log("\x1b[46m\x1b[30m[MANIFEST]\x1b[0m", "Loaded and parsed "+f);
}
let y = YAML.parse(await Bun.file('./manifest.yml').text()); y = {}; y.name = "ExampleApp"; y.entities = entities;;
Bun.write("./manifest.yml", YAML.stringify(y));

} else if (mode == "join") {

let entities = "name: ExampleEpp\nentities:";
for (const f of g.scanSync("./manifest")) {
const txt = await Bun.file('./manifest/'+f).text()
entities += "\n\n\n"+txt.split('\n').map(line => ' ' + line).join('\n')
console.log("\x1b[46m\x1b[30m[MANIFEST]\x1b[0m", "Loaded and joined "+f);
}
Bun.write("./manifest.yml", entities);

}

console.log("\x1b[42m\x1b[30m[MANIFEST]\x1b[0m", "MANIFEST.YML SUCCESSFULLY GENERATED")
await $`bun node_modules/manifest/dist/manifest/src/main.js`
console.log("\x1b[42m\x1b[30m[MANIFEST]\x1b[0m", "GENERATING MANIFEST.YML FILE");
import YAML from "yaml"; import { $, Glob } from "bun";
const g = new Glob("*.yml");

const mode = Bun.argv.at(2) || "parse";
console.log("\x1b[46m\x1b[30m[MANIFEST]\x1b[0m", "Using "+mode+" mode");

if (mode == "parse") {

let entities = {};
for (const f of g.scanSync("./manifest")) {
entities[f.replace(".yml", "")] = YAML.parse(await Bun.file('./manifest/'+f).text())[f.replace(".yml", "")];
console.log("\x1b[46m\x1b[30m[MANIFEST]\x1b[0m", "Loaded and parsed "+f);
}
let y = YAML.parse(await Bun.file('./manifest.yml').text()); y = {}; y.name = "ExampleApp"; y.entities = entities;;
Bun.write("./manifest.yml", YAML.stringify(y));

} else if (mode == "join") {

let entities = "name: ExampleEpp\nentities:";
for (const f of g.scanSync("./manifest")) {
const txt = await Bun.file('./manifest/'+f).text()
entities += "\n\n\n"+txt.split('\n').map(line => ' ' + line).join('\n')
console.log("\x1b[46m\x1b[30m[MANIFEST]\x1b[0m", "Loaded and joined "+f);
}
Bun.write("./manifest.yml", entities);

}

console.log("\x1b[42m\x1b[30m[MANIFEST]\x1b[0m", "MANIFEST.YML SUCCESSFULLY GENERATED")
await $`bun node_modules/manifest/dist/manifest/src/main.js`
However, I think a built-in feature like this would be much better

Did you find this page helpful?