Skip to content

Commit

Permalink
demo:
Browse files Browse the repository at this point in the history
  • Loading branch information
tysonrm committed Aug 11, 2023
1 parent 04b05fa commit f92334d
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions src/domain/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -244,10 +244,6 @@ import * as ports from './ports'
// Models
import * as modelSpecs from './config'

/**
*
* @param {ModelSpecification} spec
*/
function validateSpec (spec) {
const missing = ['endpoint', 'factory'].filter(key => !spec[key])
if (missing?.length > 0) {
Expand All @@ -261,12 +257,13 @@ function validateSpec (spec) {
* @param {ModelSpecification} spec
* @param {*} dependencies - services injected
*/
function makeModel (spec) {
function makeModel (spec, modelName) {
validateSpec(spec)
const mixins = spec.mixins || []
const dependencies = spec.dependencies || {}
return {
...spec,
modelName: modelName.toUpperCase(),
mixins: mixins.concat(GlobalMixins),
dependencies: {
...dependencies,
Expand All @@ -275,6 +272,7 @@ function makeModel (spec) {
}
}

export const models = Object.entries(modelSpecs).map(([k, v]) =>
makeModel({ ...v, modelName: k })
)
export const models = Object.entries(modelSpecs)
.map(([k, v]) => ({ [k.toUpperCase()]: makeModel(v, k) }))
.reduce((a, b) => ({ ...a, ...b }))

0 comments on commit f92334d

Please sign in to comment.