@@ -9,7 +9,6 @@ import core, {
9
9
Doc ,
10
10
Enum ,
11
11
generateId ,
12
- Blob as PlatformBlob ,
13
12
Ref ,
14
13
Relation
15
14
} from '@hcengineering/core'
@@ -62,7 +61,7 @@ export class UnifiedDocProcessor {
62
61
63
62
switch ( yamlConfig ?. class ) {
64
63
case card . class . MasterTag : {
65
- const masterTagId = this . metadataStorage . getIdByAbsolutePath ( yamlPath ) as Ref < MasterTag >
64
+ const masterTagId = this . metadataStorage . getRefByPath ( yamlPath ) as Ref < MasterTag >
66
65
const masterTag = await this . createMasterTag ( yamlConfig , masterTagId , parentMasterTagId )
67
66
const masterTagAttrs = await this . createAttributes ( yamlPath , yamlConfig , masterTagId )
68
67
@@ -113,7 +112,7 @@ export class UnifiedDocProcessor {
113
112
if ( fs . existsSync ( yamlPath ) ) {
114
113
const yamlConfig = yaml . load ( fs . readFileSync ( yamlPath , 'utf8' ) ) as Record < string , any >
115
114
if ( yamlConfig ?. class === card . class . MasterTag ) {
116
- masterTagId = this . metadataStorage . getIdByAbsolutePath ( yamlPath ) as Ref < MasterTag >
115
+ masterTagId = this . metadataStorage . getRefByPath ( yamlPath ) as Ref < MasterTag >
117
116
this . metadataStorage . getAssociations ( yamlPath ) . forEach ( ( relationMetadata , propName ) => {
118
117
masterTagRelations . set ( propName , relationMetadata )
119
118
} )
@@ -246,7 +245,7 @@ export class UnifiedDocProcessor {
246
245
masterTagId : Ref < MasterTag > ,
247
246
parentTagId ?: Ref < Tag >
248
247
) : Promise < void > {
249
- const tagId = this . metadataStorage . getIdByAbsolutePath ( tagPath ) as Ref < Tag >
248
+ const tagId = this . metadataStorage . getRefByPath ( tagPath ) as Ref < Tag >
250
249
const tag = await this . createTag ( tagConfig , tagId , masterTagId , parentTagId )
251
250
252
251
const attributes = await this . createAttributes ( tagPath , tagConfig , tagId )
@@ -342,7 +341,7 @@ export class UnifiedDocProcessor {
342
341
const baseType : Record < string , any > = { }
343
342
baseType . _class = core . class . RefTo
344
343
const refPath = path . resolve ( path . dirname ( currentPath ) , property . refTo )
345
- baseType . to = this . metadataStorage . getIdByAbsolutePath ( refPath )
344
+ baseType . to = this . metadataStorage . getRefByPath ( refPath )
346
345
baseType . label = core . string . Ref
347
346
type = property . isArray === true
348
347
? {
@@ -355,7 +354,7 @@ export class UnifiedDocProcessor {
355
354
const baseType : Record < string , any > = { }
356
355
baseType . _class = core . class . EnumOf
357
356
const enumPath = path . resolve ( path . dirname ( currentPath ) , property . enumOf )
358
- baseType . of = this . metadataStorage . getIdByAbsolutePath ( enumPath )
357
+ baseType . of = this . metadataStorage . getRefByPath ( enumPath )
359
358
baseType . label = 'core:string:Enum'
360
359
type = property . isArray === true
361
360
? {
@@ -398,7 +397,7 @@ export class UnifiedDocProcessor {
398
397
const tags = rawTags !== undefined ? ( Array . isArray ( rawTags ) ? rawTags : [ rawTags ] ) : [ ]
399
398
const blobs = rawBlobs !== undefined ? ( Array . isArray ( rawBlobs ) ? rawBlobs : [ rawBlobs ] ) : [ ]
400
399
401
- const cardId = this . metadataStorage . getIdByAbsolutePath ( cardPath ) as Ref < Card >
400
+ const cardId = this . metadataStorage . getRefByPath ( cardPath ) as Ref < Card >
402
401
const cardProps : Record < string , any > = {
403
402
_id : cardId ,
404
403
space : core . space . Workspace ,
@@ -450,7 +449,7 @@ export class UnifiedDocProcessor {
450
449
for ( const val of values ) {
451
450
if ( attrBaseType . _class === core . class . RefTo ) {
452
451
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 >
454
453
propValues . push ( ref )
455
454
} else {
456
455
propValues . push ( val )
@@ -463,7 +462,7 @@ export class UnifiedDocProcessor {
463
462
throw new Error ( `Association not found: ${ key } , ${ cardPath } ` ) // todo: keep the error till builder validation
464
463
}
465
464
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 >
467
466
const relation : UnifiedDoc < Relation > = this . createRelation ( metadata , cardId , otherCardId )
468
467
relations . push ( relation )
469
468
}
@@ -509,7 +508,7 @@ export class UnifiedDocProcessor {
509
508
for ( const tagPath of tags ) {
510
509
const cardDir = path . dirname ( cardPath )
511
510
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 >
513
512
514
513
const tagProps : Record < string , any > = { }
515
514
this . metadataStorage . getAttributes ( tagAbsPath ) . forEach ( ( attr , label ) => {
@@ -545,11 +544,11 @@ export class UnifiedDocProcessor {
545
544
const file = await this . createFile ( attachmentPath )
546
545
result . files . set ( attachmentPath , file )
547
546
548
- const attachmentId = this . metadataStorage . getIdByAbsolutePath ( attachmentPath ) as Ref < Attachment >
547
+ const attachmentId = this . metadataStorage . getRefByPath ( attachmentPath ) as Ref < Attachment >
549
548
const attachmentDoc : UnifiedDoc < Attachment > = {
550
549
_class : 'attachment:class:Attachment' as Ref < Class < Attachment > > ,
551
550
props : {
552
- _id : attachmentId , // id for attachment doc
551
+ _id : attachmentId ,
553
552
space : core . space . Workspace ,
554
553
attachedTo : card . props . _id as Ref < Card > ,
555
554
attachedToClass : card . _class ,
@@ -582,15 +581,15 @@ export class UnifiedDocProcessor {
582
581
) : Promise < UnifiedFile > {
583
582
// const fileAbsPath = path.resolve(path.dirname(currentPath), filePath)
584
583
const fileName = path . basename ( fileAbsPath )
585
- const fileId = this . metadataStorage . getIdByAbsolutePath ( fileAbsPath ) as Ref < PlatformBlob >
584
+ const fileUuid = this . metadataStorage . getUuidByPath ( fileAbsPath )
586
585
const type = contentType ( fileName )
587
586
const size = fs . statSync ( fileAbsPath ) . size
588
587
589
588
const file : UnifiedFile = {
590
- _id : fileId , // id for datastore
589
+ _id : fileUuid , // id for datastore
591
590
name : fileName ,
592
591
type : type !== false ? type : 'application/octet-stream' ,
593
- size, // todo: make sure this one is needed
592
+ size,
594
593
blobProvider : async ( ) => {
595
594
const data = fs . readFileSync ( fileAbsPath )
596
595
const props = type !== false ? { type } : undefined
@@ -608,7 +607,7 @@ export class UnifiedDocProcessor {
608
607
const { class : _class , typeA, typeB, type, nameA, nameB } = yamlConfig
609
608
610
609
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 >
612
611
613
612
const typeAPath = path . resolve ( currentPath , typeA )
614
613
this . metadataStorage . addAssociation ( typeAPath , nameB , {
@@ -624,8 +623,8 @@ export class UnifiedDocProcessor {
624
623
type
625
624
} )
626
625
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 >
629
628
630
629
return {
631
630
_class,
@@ -646,7 +645,7 @@ export class UnifiedDocProcessor {
646
645
yamlConfig : Record < string , any >
647
646
) : Promise < UnifiedDoc < Enum > > {
648
647
const { title, values } = yamlConfig
649
- const enumId = this . metadataStorage . getIdByAbsolutePath ( yamlPath ) as Ref < Enum >
648
+ const enumId = this . metadataStorage . getRefByPath ( yamlPath ) as Ref < Enum >
650
649
return {
651
650
_class : core . class . Enum ,
652
651
props : {
0 commit comments