@@ -8,12 +8,24 @@ import {
88 type ModelDefaultCatalog ,
99 type ModelDefinition ,
1010} from '@/api/client'
11+ import type {
12+ ModelEncodedFQN ,
13+ ModelName ,
14+ ModelPath ,
15+ ModelEncodedName ,
16+ ModelFullPath ,
17+ } from '@/domain/models'
1118import { isArrayNotEmpty } from '@/utils/index'
1219import { ModelInitial } from './initial'
1320import type { Lineage } from './lineage'
1421
15- export interface InitialSQLMeshModel extends Model {
16- lineage ?: Record < string , Lineage >
22+ export interface InitialSQLMeshModel
23+ extends Omit < Model , 'name' | 'fqn' | 'path' | 'full_path' > {
24+ name : ModelName
25+ fqn : ModelEncodedFQN
26+ path : ModelPath
27+ full_path : ModelFullPath
28+ lineage ?: Record < ModelName , Lineage >
1729}
1830
1931export class ModelSQLMeshModel <
@@ -22,9 +34,10 @@ export class ModelSQLMeshModel<
2234 _details : ModelDetails = { }
2335 _detailsIndex : string = ''
2436
25- name : string
26- fqn : string
27- path : string
37+ name : ModelEncodedName
38+ fqn : ModelEncodedFQN
39+ path : ModelPath
40+ full_path : ModelFullPath
2841 dialect : string
2942 type : ModelType
3043 columns : Column [ ]
@@ -46,10 +59,11 @@ export class ModelSQLMeshModel<
4659 } ,
4760 )
4861
49- this . name = encodeURI ( this . initial . name )
50- this . fqn = encodeURI ( this . initial . fqn )
62+ this . name = encodeURI ( this . initial . name ) as ModelEncodedName
63+ this . fqn = encodeURI ( this . initial . fqn ) as ModelEncodedFQN
5164 this . default_catalog = this . initial . default_catalog
52- this . path = this . initial . path
65+ this . path = this . initial . path as ModelPath
66+ this . full_path = this . initial . full_path as ModelFullPath
5367 this . dialect = this . initial . dialect
5468 this . description = this . initial . description
5569 this . sql = this . initial . sql
@@ -127,17 +141,21 @@ export class ModelSQLMeshModel<
127141 } else if ( key === 'details' ) {
128142 this . details = value as ModelDetails
129143 } else if ( key === 'name' ) {
130- this . name = encodeURI ( value as string )
144+ this . name = encodeURI ( value as string ) as ModelEncodedName
131145 } else if ( key === 'fqn' ) {
132- this . fqn = encodeURI ( value as string )
146+ this . fqn = encodeURI ( value as string ) as ModelEncodedFQN
133147 } else if ( key === 'type' ) {
134148 this . type = value as ModelType
135149 } else if ( key === 'default_catalog' ) {
136150 this . default_catalog = value as ModelDefaultCatalog
137151 } else if ( key === 'description' ) {
138152 this . description = value as ModelDescription
153+ } else if ( key === 'full_path' ) {
154+ this . full_path = value as ModelFullPath
155+ } else if ( key === 'path' ) {
156+ this . path = value as ModelPath
139157 } else if ( key in this ) {
140- this [ key as 'path' | ' dialect' | 'sql' ] = value as string
158+ this [ key as 'dialect' | 'sql' ] = value as string
141159 }
142160 }
143161 }
0 commit comments