@@ -9,7 +9,6 @@ import core, {
99 Doc ,
1010 Enum ,
1111 generateId ,
12- Blob as PlatformBlob ,
1312 Ref ,
1413 Relation
1514} from '@hcengineering/core'
@@ -62,7 +61,7 @@ export class UnifiedDocProcessor {
6261
6362 switch ( yamlConfig ?. class ) {
6463 case card . class . MasterTag : {
65- const masterTagId = this . metadataStorage . getIdByAbsolutePath ( yamlPath ) as Ref < MasterTag >
64+ const masterTagId = this . metadataStorage . getRefByPath ( yamlPath ) as Ref < MasterTag >
6665 const masterTag = await this . createMasterTag ( yamlConfig , masterTagId , parentMasterTagId )
6766 const masterTagAttrs = await this . createAttributes ( yamlPath , yamlConfig , masterTagId )
6867
@@ -113,7 +112,7 @@ export class UnifiedDocProcessor {
113112 if ( fs . existsSync ( yamlPath ) ) {
114113 const yamlConfig = yaml . load ( fs . readFileSync ( yamlPath , 'utf8' ) ) as Record < string , any >
115114 if ( yamlConfig ?. class === card . class . MasterTag ) {
116- masterTagId = this . metadataStorage . getIdByAbsolutePath ( yamlPath ) as Ref < MasterTag >
115+ masterTagId = this . metadataStorage . getRefByPath ( yamlPath ) as Ref < MasterTag >
117116 this . metadataStorage . getAssociations ( yamlPath ) . forEach ( ( relationMetadata , propName ) => {
118117 masterTagRelations . set ( propName , relationMetadata )
119118 } )
@@ -246,7 +245,7 @@ export class UnifiedDocProcessor {
246245 masterTagId : Ref < MasterTag > ,
247246 parentTagId ?: Ref < Tag >
248247 ) : Promise < void > {
249- const tagId = this . metadataStorage . getIdByAbsolutePath ( tagPath ) as Ref < Tag >
248+ const tagId = this . metadataStorage . getRefByPath ( tagPath ) as Ref < Tag >
250249 const tag = await this . createTag ( tagConfig , tagId , masterTagId , parentTagId )
251250
252251 const attributes = await this . createAttributes ( tagPath , tagConfig , tagId )
@@ -342,7 +341,7 @@ export class UnifiedDocProcessor {
342341 const baseType : Record < string , any > = { }
343342 baseType . _class = core . class . RefTo
344343 const refPath = path . resolve ( path . dirname ( currentPath ) , property . refTo )
345- baseType . to = this . metadataStorage . getIdByAbsolutePath ( refPath )
344+ baseType . to = this . metadataStorage . getRefByPath ( refPath )
346345 baseType . label = core . string . Ref
347346 type = property . isArray === true
348347 ? {
@@ -355,7 +354,7 @@ export class UnifiedDocProcessor {
355354 const baseType : Record < string , any > = { }
356355 baseType . _class = core . class . EnumOf
357356 const enumPath = path . resolve ( path . dirname ( currentPath ) , property . enumOf )
358- baseType . of = this . metadataStorage . getIdByAbsolutePath ( enumPath )
357+ baseType . of = this . metadataStorage . getRefByPath ( enumPath )
359358 baseType . label = 'core:string:Enum'
360359 type = property . isArray === true
361360 ? {
@@ -398,7 +397,7 @@ export class UnifiedDocProcessor {
398397 const tags = rawTags !== undefined ? ( Array . isArray ( rawTags ) ? rawTags : [ rawTags ] ) : [ ]
399398 const blobs = rawBlobs !== undefined ? ( Array . isArray ( rawBlobs ) ? rawBlobs : [ rawBlobs ] ) : [ ]
400399
401- const cardId = this . metadataStorage . getIdByAbsolutePath ( cardPath ) as Ref < Card >
400+ const cardId = this . metadataStorage . getRefByPath ( cardPath ) as Ref < Card >
402401 const cardProps : Record < string , any > = {
403402 _id : cardId ,
404403 space : core . space . Workspace ,
@@ -450,7 +449,7 @@ export class UnifiedDocProcessor {
450449 for ( const val of values ) {
451450 if ( attrBaseType . _class === core . class . RefTo ) {
452451 const refPath = path . resolve ( path . dirname ( cardPath ) , val )
453- const ref = this . metadataStorage . getIdByAbsolutePath ( refPath ) as Ref < Card >
452+ const ref = this . metadataStorage . getRefByPath ( refPath ) as Ref < Card >
454453 propValues . push ( ref )
455454 } else {
456455 propValues . push ( val )
@@ -463,7 +462,7 @@ export class UnifiedDocProcessor {
463462 throw new Error ( `Association not found: ${ key } , ${ cardPath } ` ) // todo: keep the error till builder validation
464463 }
465464 const otherCardPath = path . resolve ( path . dirname ( cardPath ) , value ) // todo: value can be array of paths
466- const otherCardId = this . metadataStorage . getIdByAbsolutePath ( otherCardPath ) as Ref < Card >
465+ const otherCardId = this . metadataStorage . getRefByPath ( otherCardPath ) as Ref < Card >
467466 const relation : UnifiedDoc < Relation > = this . createRelation ( metadata , cardId , otherCardId )
468467 relations . push ( relation )
469468 }
@@ -509,7 +508,7 @@ export class UnifiedDocProcessor {
509508 for ( const tagPath of tags ) {
510509 const cardDir = path . dirname ( cardPath )
511510 const tagAbsPath = path . resolve ( cardDir , tagPath )
512- const tagId = this . metadataStorage . getIdByAbsolutePath ( tagAbsPath ) as Ref < Tag >
511+ const tagId = this . metadataStorage . getRefByPath ( tagAbsPath ) as Ref < Tag >
513512
514513 const tagProps : Record < string , any > = { }
515514 this . metadataStorage . getAttributes ( tagAbsPath ) . forEach ( ( attr , label ) => {
@@ -545,11 +544,11 @@ export class UnifiedDocProcessor {
545544 const file = await this . createFile ( attachmentPath )
546545 result . files . set ( attachmentPath , file )
547546
548- const attachmentId = this . metadataStorage . getIdByAbsolutePath ( attachmentPath ) as Ref < Attachment >
547+ const attachmentId = this . metadataStorage . getRefByPath ( attachmentPath ) as Ref < Attachment >
549548 const attachmentDoc : UnifiedDoc < Attachment > = {
550549 _class : 'attachment:class:Attachment' as Ref < Class < Attachment > > ,
551550 props : {
552- _id : attachmentId , // id for attachment doc
551+ _id : attachmentId ,
553552 space : core . space . Workspace ,
554553 attachedTo : card . props . _id as Ref < Card > ,
555554 attachedToClass : card . _class ,
@@ -582,15 +581,15 @@ export class UnifiedDocProcessor {
582581 ) : Promise < UnifiedFile > {
583582 // const fileAbsPath = path.resolve(path.dirname(currentPath), filePath)
584583 const fileName = path . basename ( fileAbsPath )
585- const fileId = this . metadataStorage . getIdByAbsolutePath ( fileAbsPath ) as Ref < PlatformBlob >
584+ const fileUuid = this . metadataStorage . getUuidByPath ( fileAbsPath )
586585 const type = contentType ( fileName )
587586 const size = fs . statSync ( fileAbsPath ) . size
588587
589588 const file : UnifiedFile = {
590- _id : fileId , // id for datastore
589+ _id : fileUuid , // id for datastore
591590 name : fileName ,
592591 type : type !== false ? type : 'application/octet-stream' ,
593- size, // todo: make sure this one is needed
592+ size,
594593 blobProvider : async ( ) => {
595594 const data = fs . readFileSync ( fileAbsPath )
596595 const props = type !== false ? { type } : undefined
@@ -608,7 +607,7 @@ export class UnifiedDocProcessor {
608607 const { class : _class , typeA, typeB, type, nameA, nameB } = yamlConfig
609608
610609 const currentPath = path . dirname ( yamlPath )
611- const associationId = this . metadataStorage . getIdByAbsolutePath ( yamlPath ) as Ref < Association >
610+ const associationId = this . metadataStorage . getRefByPath ( yamlPath ) as Ref < Association >
612611
613612 const typeAPath = path . resolve ( currentPath , typeA )
614613 this . metadataStorage . addAssociation ( typeAPath , nameB , {
@@ -624,8 +623,8 @@ export class UnifiedDocProcessor {
624623 type
625624 } )
626625
627- const typeAId = this . metadataStorage . getIdByAbsolutePath ( typeAPath ) as Ref < MasterTag >
628- const typeBId = this . metadataStorage . getIdByAbsolutePath ( typeBPath ) as Ref < MasterTag >
626+ const typeAId = this . metadataStorage . getRefByPath ( typeAPath ) as Ref < MasterTag >
627+ const typeBId = this . metadataStorage . getRefByPath ( typeBPath ) as Ref < MasterTag >
629628
630629 return {
631630 _class,
@@ -646,7 +645,7 @@ export class UnifiedDocProcessor {
646645 yamlConfig : Record < string , any >
647646 ) : Promise < UnifiedDoc < Enum > > {
648647 const { title, values } = yamlConfig
649- const enumId = this . metadataStorage . getIdByAbsolutePath ( yamlPath ) as Ref < Enum >
648+ const enumId = this . metadataStorage . getRefByPath ( yamlPath ) as Ref < Enum >
650649 return {
651650 _class : core . class . Enum ,
652651 props : {
0 commit comments