snapshot of https://github.com/cortezaproject/corteza.git (2024.9.x, 2026-09-18; blobs > 131072B omitted)
Some checks failed
SonarQube / SonarQube (push) Failing after 5m28s
E2e test on main branch push / server and client test (map[name:admin port:8080]) (push) Failing after 3m33s
Server and lib tests / Library test (js) (push) Failing after 1m36s
Server and lib tests / Library test (vue) (push) Successful in 2m24s
Server and lib tests / Web client test (admin) (push) Successful in 2m52s
Server and lib tests / Web client test (compose) (push) Successful in 3m23s
Server and lib tests / Web client test (discovery) (push) Successful in 2m49s
Server and lib tests / Web client test (one) (push) Successful in 2m52s
Server and lib tests / Web client test (privacy) (push) Successful in 2m44s
Server and lib tests / Web client test (reporter) (push) Successful in 2m56s
Server and lib tests / Web client test (workflow) (push) Successful in 3m0s
Server and lib tests / Server tests (push) Failing after 4m55s
E2e test on main branch push / notify-failure (push) Failing after 9s
Server and lib tests / Send matrix testing notification (push) Successful in 2s
Mark stale issues and pull requests / stale (push) Successful in 40s
Some checks failed
SonarQube / SonarQube (push) Failing after 5m28s
E2e test on main branch push / server and client test (map[name:admin port:8080]) (push) Failing after 3m33s
Server and lib tests / Library test (js) (push) Failing after 1m36s
Server and lib tests / Library test (vue) (push) Successful in 2m24s
Server and lib tests / Web client test (admin) (push) Successful in 2m52s
Server and lib tests / Web client test (compose) (push) Successful in 3m23s
Server and lib tests / Web client test (discovery) (push) Successful in 2m49s
Server and lib tests / Web client test (one) (push) Successful in 2m52s
Server and lib tests / Web client test (privacy) (push) Successful in 2m44s
Server and lib tests / Web client test (reporter) (push) Successful in 2m56s
Server and lib tests / Web client test (workflow) (push) Successful in 3m0s
Server and lib tests / Server tests (push) Failing after 4m55s
E2e test on main branch push / notify-failure (push) Failing after 9s
Server and lib tests / Send matrix testing notification (push) Successful in 2s
Mark stale issues and pull requests / stale (push) Successful in 40s
This commit is contained in:
151
server/codegen/server.dal_models.cue
Normal file
151
server/codegen/server.dal_models.cue
Normal file
@@ -0,0 +1,151 @@
|
||||
package codegen
|
||||
|
||||
import (
|
||||
"github.com/cortezaproject/corteza/server/app"
|
||||
"github.com/cortezaproject/corteza/server/codegen/schema"
|
||||
)
|
||||
|
||||
|
||||
_dalModelFn: {
|
||||
res="res": schema.#Resource
|
||||
|
||||
"output": {
|
||||
"var": string | *"\(res.expIdent)"
|
||||
"resType": string | *"types.\(res.expIdent)ResourceType"
|
||||
|
||||
"ident": res.model.ident
|
||||
|
||||
"attributes": [
|
||||
for attr in res.model.attributes if attr.dal != _|_ {
|
||||
attr
|
||||
|
||||
"dal": {
|
||||
attr.dal
|
||||
|
||||
// Only these field types support "has-default" flag
|
||||
if (attr.dal.type & ( "ID" | "Ref" | "Number" | "Boolean" | "Enum" | "JSON" )) != _|_ {
|
||||
"hasDefault": attr.dal.default != _|_
|
||||
}
|
||||
|
||||
if attr.dal.default != _|_ {
|
||||
"quotedDefault": attr.dal.type == "String"
|
||||
}
|
||||
|
||||
if attr.dal.meta != _|_ {
|
||||
"meta": attr.dal.meta
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
|
||||
"indexes": {[string]: close({
|
||||
"ident": string
|
||||
"type": string
|
||||
"unique"?: bool
|
||||
"predicate"?: string
|
||||
"fields": [{
|
||||
"attribute": string
|
||||
"modifers"?: [string, ...]
|
||||
"sort"?: string
|
||||
"nulls"?: string
|
||||
}, ...]
|
||||
})} | *null
|
||||
|
||||
if res.model.indexes != _|_ {
|
||||
"indexes": {
|
||||
for index in res.model.indexes {
|
||||
"\(index.ident)": {
|
||||
|
||||
if index.primary == true {
|
||||
"ident": "PRIMARY"
|
||||
}
|
||||
|
||||
if index.primary == false {
|
||||
"ident": index.ident
|
||||
"unique": index.unique
|
||||
}
|
||||
|
||||
"type": index.type
|
||||
|
||||
if index.predicate != _|_ {
|
||||
"predicate": index.predicate
|
||||
}
|
||||
|
||||
"fields": [
|
||||
for field in index.fields {
|
||||
"attribute": res.model.attributes[field.attribute].expIdent
|
||||
|
||||
if field.modifiers != _|_ {
|
||||
"modifiers": field.modifiers
|
||||
}
|
||||
if field.sort != _|_ {
|
||||
"sort": field.sort
|
||||
}
|
||||
if field.nulls != _|_ {
|
||||
"nulls": field.nulls
|
||||
}
|
||||
},
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
[...schema.#codegen] &
|
||||
[
|
||||
{
|
||||
template: "gocode/dal/$component_model.go.tpl"
|
||||
output: "system/model/corteza.gen.go"
|
||||
payload: {
|
||||
package: "model"
|
||||
|
||||
imports: [
|
||||
for res in app.resources if (res.model.attributes != _|_) {
|
||||
"\(res.package.ident)type \"\(res.package.import)\"",
|
||||
}
|
||||
]
|
||||
|
||||
// Operation/resource validators, grouped by resource
|
||||
models: {
|
||||
for res in app.resources if (res.model.attributes != _|_) {
|
||||
"\(res.ident)": {
|
||||
// overriding resoure-type (import package alias) for app resources
|
||||
"resType": "\(res.package.ident)type.\(res.expIdent)ResourceType"
|
||||
|
||||
(_dalModelFn & { "res": res }).output
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
},
|
||||
for cmp in app.corteza.components {
|
||||
template: "gocode/dal/$component_model.go.tpl"
|
||||
output: "\(cmp.ident)/model/models.gen.go"
|
||||
payload: {
|
||||
package: "model"
|
||||
|
||||
imports: [
|
||||
"\"github.com/cortezaproject/corteza/server/\(cmp.ident)/types\"",
|
||||
]
|
||||
|
||||
// Operation/resource validators, grouped by resource
|
||||
models: {
|
||||
for res in cmp.resources if (res.model.attributes != _|_) {
|
||||
"\(res.ident)": {
|
||||
(_dalModelFn & { "res": res }).output
|
||||
}
|
||||
},
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
for cmp in app.corteza.components {
|
||||
template: "gocode/dal/$component_init.go.tpl"
|
||||
output: "\(cmp.ident)/model/init.gen.go"
|
||||
payload: {
|
||||
package: "model"
|
||||
}
|
||||
},
|
||||
]
|
||||
Reference in New Issue
Block a user