-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(clone): rename clone-piece to export-component
- Loading branch information
Showing
12 changed files
with
83 additions
and
77 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 5 additions & 2 deletions
7
api/apps/api/src/modules/clone/export/application/resource-pieces.port.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,10 @@ | ||
import { ResourceId } from '../domain/export/resource.id'; | ||
import { ResourceKind } from '../domain/export/resource.kind'; | ||
import { ClonePart } from '../domain/export/clone-part/clone-part'; | ||
import { ExportComponent } from '../domain/export/clone-part/export-component'; | ||
|
||
export abstract class ResourcePieces { | ||
abstract resolveFor(id: ResourceId, kind: ResourceKind): Promise<ClonePart[]>; | ||
abstract resolveFor( | ||
id: ResourceId, | ||
kind: ResourceKind, | ||
): Promise<ExportComponent[]>; | ||
} |
2 changes: 1 addition & 1 deletion
2
...main/events/clone-parts-finished.event.ts → ...events/export-component-finished.event.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
import { IEvent } from '@nestjs/cqrs'; | ||
import { ExportId } from '../export/export.id'; | ||
|
||
export class ClonePartsFinished implements IEvent { | ||
export class ExportComponentFinished implements IEvent { | ||
constructor(public readonly exportId: ExportId) {} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
51 changes: 0 additions & 51 deletions
51
api/apps/api/src/modules/clone/export/domain/export/clone-part/clone-part.ts
This file was deleted.
Oops, something went wrong.
3 changes: 0 additions & 3 deletions
3
api/apps/api/src/modules/clone/export/domain/export/clone-part/piece.id.ts
This file was deleted.
Oops, something went wrong.
2 changes: 1 addition & 1 deletion
2
...port/domain/export/clone-part.snapshot.ts → ...omain/export/export-component.snapshot.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 3 additions & 0 deletions
3
api/apps/api/src/modules/clone/export/domain/export/export-component/component.id.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import { TinyTypeOf } from 'tiny-types'; | ||
|
||
export class ComponentId extends TinyTypeOf<string>() {} |
51 changes: 51 additions & 0 deletions
51
api/apps/api/src/modules/clone/export/domain/export/export-component/export-component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import { v4 } from 'uuid'; | ||
import { ClonePiece } from '../../../../shared-kernel/clone-piece'; | ||
|
||
import { ResourceId } from '../resource.id'; | ||
import { ExportComponentSnapshot } from '../export-component.snapshot'; | ||
|
||
import { ComponentId } from './component.id'; | ||
import { ComponentLocation } from './component-location'; | ||
|
||
export class ExportComponent { | ||
private constructor( | ||
readonly id: ComponentId, | ||
readonly piece: ClonePiece, | ||
readonly resourceId: ResourceId, | ||
private finished: boolean = false, | ||
private uri?: ComponentLocation, | ||
) {} | ||
|
||
static newOne(resourceId: ResourceId, piece: ClonePiece): ExportComponent { | ||
return new ExportComponent(new ComponentId(v4()), piece, resourceId); | ||
} | ||
|
||
finish(location: ComponentLocation) { | ||
this.finished = true; | ||
this.uri = location; | ||
} | ||
|
||
isReady() { | ||
return this.finished; | ||
} | ||
|
||
toSnapshot(): ExportComponentSnapshot { | ||
return { | ||
id: this.id.value, | ||
piece: this.piece, | ||
resourceId: this.resourceId.value, | ||
finished: this.finished, | ||
uri: this.uri?.value, | ||
}; | ||
} | ||
|
||
static fromSnapshot(snapshot: ExportComponentSnapshot) { | ||
return new ExportComponent( | ||
new ComponentId(snapshot.id), | ||
snapshot.piece, | ||
new ResourceId(snapshot.resourceId), | ||
snapshot.finished, | ||
snapshot.uri ? new ComponentLocation(snapshot.uri) : undefined, | ||
); | ||
} | ||
} |
4 changes: 2 additions & 2 deletions
4
api/apps/api/src/modules/clone/export/domain/export/export.snapshot.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,10 @@ | ||
import { ResourceKind } from './resource.kind'; | ||
import { ClonePartSnapshot } from './clone-part.snapshot'; | ||
import { ExportComponentSnapshot } from './export-component.snapshot'; | ||
|
||
export interface ExportSnapshot { | ||
id: string; | ||
resourceId: string; | ||
resourceKind: ResourceKind; | ||
archiveLocation?: string; | ||
exportPieces: ClonePartSnapshot[]; | ||
exportPieces: ExportComponentSnapshot[]; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters