// noinspection JSUnusedGlobalSymbols,SpellCheckingInspection import { C6Constants, restRequest, restOrm, } from "@carbonorm/carbonnode"; import type { iC6Object, } from "@carbonorm/carbonnode"; {{#if CUSTOM_IMPORTS_GENERATED}}{{{CUSTOM_IMPORTS_GENERATED}}} {{/if}} import { GLOBAL_REST_PARAMETERS, RestTablePrefix, } from "./core"; export const SCOPED_C6_BY_DATABASE: Record> = { {{#each SCOPED_DATABASES}} '{{DATABASE_KEY}}': (() => { {{#each RELATIONS}} const {{SCOPED_TABLE_CONST}}: Record & { TABLE_NAME: string; RELATION_TYPE: 'TABLE' | 'VIEW'; READ_ONLY: boolean; } = { TABLE_NAME: '{{TABLE_NAME}}', RELATION_TYPE: '{{RELATION_TYPE}}', READ_ONLY: {{READ_ONLY}}, {{#each COLUMNS_UPPERCASE}} {{@key}}: '{{this}}', {{/each}} PRIMARY: [ {{#PRIMARY}} '{{this}}', {{/PRIMARY}} ], PRIMARY_SHORT: [ {{#each PRIMARY_SHORT}} '{{this}}', {{/each}} ], COLUMNS: { {{#each COLUMNS}} '{{@key}}': '{{this}}', {{/each}} }, TYPE_VALIDATION: { {{#each TYPE_VALIDATION}} '{{@key}}': { MYSQL_TYPE: '{{this.MYSQL_TYPE}}', MAX_LENGTH: '{{this.MAX_LENGTH}}', AUTO_INCREMENT: {{this.AUTO_INCREMENT}}, SKIP_COLUMN_IN_POST: {{this.SKIP_COLUMN_IN_POST}} }, {{/each}} }, REGEX_VALIDATION: { {{#each REGEX_VALIDATION}} '{{@key}}': '{{this}}', {{/each}} }, LIFECYCLE_HOOKS: { GET: {beforeProcessing:{}, beforeExecution:{}, afterExecution:{}, afterCommit:{}}, PUT: {beforeProcessing:{}, beforeExecution:{}, afterExecution:{}, afterCommit:{}}, POST: {beforeProcessing:{}, beforeExecution:{}, afterExecution:{}, afterCommit:{}}, DELETE: {beforeProcessing:{}, beforeExecution:{}, afterExecution:{}, afterCommit:{}}, }, TABLE_REFERENCES: { {{#each TABLE_REFERENCES}}'{{@key}}': [{{#this}}{ TABLE: '{{TABLE}}', COLUMN: '{{COLUMN}}', CONSTRAINT: '{{CONSTRAINT}}', },{{/this}}],{{/each}} }, TABLE_REFERENCED_BY: { {{#each TABLE_REFERENCED_BY}}'{{@key}}': [{{#this}}{ TABLE: '{{TABLE}}', COLUMN: '{{COLUMN}}', CONSTRAINT: '{{CONSTRAINT}}', },{{/this}}],{{/each}} } }; {{/each}} const scopedTables = { {{#each RELATIONS}} '{{TABLE_NAME_SHORT}}': {{SCOPED_TABLE_CONST}}, {{/each}} } as Record; const scopedC6: iC6Object = { ...C6Constants, C6VERSION: '{{../C6VERSION}}', PREFIX: RestTablePrefix, TABLES: scopedTables as any, ORM: {}, ...scopedTables, }; {{#each RELATIONS}} const {{SCOPED_BINDING_CONST}} = { ...{{SCOPED_TABLE_CONST}}, {{#if READ_ONLY}} Get: (restRequest as any)(() => ({ ...GLOBAL_REST_PARAMETERS, C6: scopedC6, restModel: {{SCOPED_TABLE_CONST}} as any{{#if ../../OBJECT_OVERRIDES}}, {{{../../OBJECT_OVERRIDES}}}{{/if}}, requestMethod: 'GET', })) {{else}} ...restOrm(() => ({ ...GLOBAL_REST_PARAMETERS, C6: scopedC6, restModel: {{SCOPED_TABLE_CONST}} as any{{#if ../../OBJECT_OVERRIDES}}, {{{../../OBJECT_OVERRIDES}}}{{/if}} })) {{/if}} }; {{/each}} (scopedC6 as any).ORM = { {{#each RELATIONS}} {{TABLE_NAME_SHORT_PASCAL_CASE}}: {{SCOPED_BINDING_CONST}}, {{/each}} }; return scopedC6; })(), {{/each}} };