{"id":20630716,"url":"https://github.com/sysgears/domain-schema","last_synced_at":"2025-04-15T18:24:21.275Z","repository":{"id":57109133,"uuid":"109153681","full_name":"sysgears/domain-schema","owner":"sysgears","description":"Domain Driven Design Schema for JavaScript","archived":false,"fork":false,"pushed_at":"2019-07-26T16:49:25.000Z","size":36591,"stargazers_count":22,"open_issues_count":2,"forks_count":2,"subscribers_count":17,"default_branch":"master","last_synced_at":"2025-04-07T01:04:02.554Z","etag":null,"topics":["domain-driven-design","javascript","schema","typescript"],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sysgears.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-11-01T16:13:18.000Z","updated_at":"2021-01-16T19:48:24.000Z","dependencies_parsed_at":"2022-08-21T06:01:03.499Z","dependency_job_id":null,"html_url":"https://github.com/sysgears/domain-schema","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sysgears%2Fdomain-schema","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sysgears%2Fdomain-schema/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sysgears%2Fdomain-schema/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sysgears%2Fdomain-schema/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sysgears","download_url":"https://codeload.github.com/sysgears/domain-schema/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249127083,"owners_count":21216917,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["domain-driven-design","javascript","schema","typescript"],"created_at":"2024-11-16T14:09:21.524Z","updated_at":"2025-04-15T18:24:21.254Z","avatar_url":"https://github.com/sysgears.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"## Domain Schema\n\n[![Twitter Follow](https://img.shields.io/twitter/follow/sysgears.svg?style=social)](https://twitter.com/sysgears)\n\nDomain Schema is a set of packages that let you design your application using Domain Driven Design Principles.\nYou create your schemas with any fields your application needs.\nThen use them as a single source of truth in the application to generate database schemas, forms, GraphQL types, etc.\nDomain Schema set of packages try to help you with this task, not stay on your way, by imposing minimal limitations on the shape\nof your domain schemas, not the fields and the meaning you can use.\n\nExample Domain Schema using ES6 syntax:\n```js\nclass AuthCertificate extends Schema {\n  __ = { name: 'AuthCertificate' };\n  serial = {\n    type: String,\n    unique: true\n  };\n}\n\nclass AuthFacebook extends Schema {\n  __ = { name: 'AuthFacebook' };\n  fbId = {\n    type: String,\n    unique: true\n  };\n  displayName = {\n    type: String,\n    optional: true\n  };\n}\n\nclass UserProfile extends Schema {\n  __ = { name: 'UserProfile' };\n  firstName = {\n    type: String,\n    optional: true\n  };\n  lastName = {\n    type: String,\n    optional: true\n  };\n  fullName = {\n    type: String,\n    optional: true,\n    transient: true\n  };\n  notes = [String];\n}\n\nclass UserAuth extends Schema {\n  __ = { name: 'UserAuth', transient: true };\n  certificate = {\n    type: AuthCertificate,\n    optional: true\n  };\n  facebook = {\n    type: AuthFacebook,\n    optional: true\n  };\n}\n\nexport const User = new DomainSchema(\n  class User extends Schema {\n    __ = { name: 'User' };\n    id = DomainSchema.Integer;\n    username = {\n      type: String,\n      unique: true\n    };\n    email = {\n      type: String,\n      unique: true\n    };\n    password = {\n      type: String,\n      private: true\n    };\n    role = {\n      type: String,\n      default: 'user'\n    };\n    isActive = {\n      type: Boolean,\n      default: false,\n      optional: true\n    };\n    auth = {\n      type: [UserAuth],\n      optional: true\n    };\n    profile = {\n      type: [UserProfile],\n      optional: true\n    };\n  }\n);\n```\n\nExample cyclic Domain Schema definition\n```js\nclass Product extends Schema {\n  __ = { name: 'Product' };\n  id = DomainSchema.Integer;\n  name = String;\n  category = Category;\n}\n\nclass Category extends Schema {\n  __ = { name: 'Category' };\n  public id = DomainSchema.Integer;\n  name = String;\n  products = [Product];\n}\n\nconst ProductSchema = new DomainSchema(Product);\n```\nSuch cyclic dependencies must be contained in one file.\n\n## Contributors\n\nThanks goes to these wonderful people ([emoji key](https://github.com/kentcdodds/all-contributors#emoji-key)):\n\n\u003c!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section --\u003e\n\u003c!-- ALL-CONTRIBUTORS-LIST:END --\u003e\n\nThis project follows the [all-contributors](https://github.com/kentcdodds/all-contributors) specification. Contributions of any kind welcome!\n\n## License\nCopyright © 2017 [SysGears INC]. This source code is licensed under the [MIT] license.\n\n[MIT]: LICENSE\n[SysGears INC]: http://sysgears.com\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsysgears%2Fdomain-schema","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsysgears%2Fdomain-schema","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsysgears%2Fdomain-schema/lists"}