{"size": 1859, "ext": "js", "max_stars_repo_path": "packages/@core.codegen/templates/schema00/domains/{{domain}}/schema/{{name}}.js", "max_stars_repo_name": "buzzon/qw", "max_stars_repo_stars_event_min_datetime": "2021-04-20T08:39:34.000Z", "max_stars_repo_stars_event_max_datetime": "2022-02-15T07:04:04.000Z", "max_issues_repo_path": "packages/@core.codegen/templates/schema00/domains/{{domain}}/schema/{{name}}.js", "max_issues_repo_name": "buzzon/qw", "max_issues_repo_issues_event_min_datetime": "2021-04-01T11:31:37.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-30T07:11:45.000Z", "max_forks_repo_path": "packages/@core.codegen/templates/schema00/domains/{{domain}}/schema/{{name}}.js", "max_forks_repo_name": "buzzon/qw", "max_forks_repo_forks_event_min_datetime": "2021-04-15T11:05:57.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-04T05:10:15.000Z"}
{"max_stars_count": 11, "max_issues_count": 190, "max_forks_count": 6, "avg_line_length": 34.4259259259, "max_line_length": 138, "alphanum_fraction": 0.5804195804}
/**
 * Generated by `{{ command }}`
 */

const { Text, Relationship, Integer, Select, Checkbox, DateTimeUtc, CalendarDay, Decimal, Password, File } = require('@keystonejs/fields')
const { Json } = require('@core/keystone/fields')
const { GQLListSchema } = require('@core/keystone/schema')
const { historical, versioned, uuided, tracked, softDeleted } = require('@core/keystone/plugins')
const { SENDER_FIELD, DV_FIELD } = require('@{{app}}/domains/common/schema/fields')
const access = require('@{{app}}/domains/{{ domain }}/access/{{name}}')


const {{ name }} = new GQLListSchema('{{ name }}', {
    // TODO(codegen): write doc for the {{ name }} domain model!
    schemaDoc: 'TODO DOC!',
    fields: {
        dv: DV_FIELD,
        sender: SENDER_FIELD,
{% for field in signature %}
        {{ field.name }}: {
            // TODO(codegen): write doc for {{ name }}.{{ field.name }} field!
            schemaDoc: 'TODO DOC!',
            type: {{ field.type }},
{%- if field.isRelation %}
            ref: '{{ field.ref }}',
{%- elif field.type === 'Select' %}
            options: '{{ field.options }}',
{%- endif %}
{%- if field.isRequired %}
            isRequired: true,
{%- endif %}
{%- if field.isRelation %}
{%- if field.isRequired %}
            knexOptions: { isNotNullable: true }, // Required relationship only!
{%- endif %}
            kmigratorOptions: { null: {{ not field.isRequired }}, on_delete: 'models.{{ field.on_delete }}' },
{%- endif %}
        },
{% endfor %}
    },
    plugins: [uuided(), versioned(), tracked(), softDeleted(), historical()],
    access: {
        read: access.canRead{{ pluralize.plural(name) }},
        create: access.canManage{{ pluralize.plural(name) }},
        update: access.canManage{{ pluralize.plural(name) }},
        delete: false,
        auth: true,
    },
})

module.exports = {
    {{ name }},
}
