-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add extension to transform result
- Loading branch information
1 parent
e0cd9ba
commit e9a5446
Showing
11 changed files
with
116 additions
and
89 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
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 was deleted.
Oops, something went wrong.
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,68 @@ | ||
import { DatatypeModule } from "../../../../modules/datatype"; | ||
import { DatasetSchema } from "../../../dataset-resolver/interfaces/resolver"; | ||
import { DatasetResolver } from "../../../dataset-resolver/resolver"; | ||
import { ChacaUtils } from "../../../utils"; | ||
import { Filename } from "../../generators/file-creator/filename"; | ||
import { DumpFile } from "../../generators/generator"; | ||
import { DumpConfig } from "../../interfaces/export"; | ||
import { FileFormat } from "../../value-object/format"; | ||
import { FileName } from "../../value-object/name"; | ||
import { Verbose } from "../../value-object/verbose"; | ||
import { GeneratorFilter } from "../generator-filter/generator-filter"; | ||
import { ExtensionFilename } from "./value-object/filename"; | ||
|
||
export class DumpResolver { | ||
private readonly format: FileFormat; | ||
private readonly filename: FileName; | ||
private readonly verbose: Verbose; | ||
|
||
constructor( | ||
private readonly utils: ChacaUtils, | ||
private readonly datatypeModule: DatatypeModule, | ||
private readonly filter: GeneratorFilter, | ||
config: DumpConfig, | ||
) { | ||
this.format = new FileFormat(config.format); | ||
this.filename = new FileName(config.filename); | ||
this.verbose = new Verbose(config.verbose); | ||
} | ||
|
||
data(data: any): DumpFile[] { | ||
const generator = this.filter.execute(this.format.value()); | ||
|
||
const result = generator.dump({ | ||
data: data, | ||
filename: new Filename(this.filename.value()), | ||
}); | ||
|
||
return result.map((r) => { | ||
return { | ||
content: r.content, | ||
filename: new ExtensionFilename(r.filename, generator.ext).value(), | ||
}; | ||
}); | ||
} | ||
|
||
relational(schemas: DatasetSchema[]): DumpFile[] { | ||
const generator = this.filter.execute(this.format.value()); | ||
|
||
const resolver = new DatasetResolver(this.utils, this.datatypeModule, { | ||
schemas: schemas, | ||
verbose: this.verbose.value(), | ||
}); | ||
|
||
const result = generator.dumpRelational({ | ||
resolver: resolver, | ||
filename: new Filename(this.filename.value()), | ||
}); | ||
|
||
return result.map((r) => { | ||
return { | ||
content: r.content, | ||
filename: new ExtensionFilename(r.filename, generator.ext).value(), | ||
}; | ||
}); | ||
} | ||
} | ||
|
||
export type { DumpFile, DumpConfig }; |
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,11 @@ | ||
export class ExtensionFilename { | ||
private readonly _value: string; | ||
|
||
constructor(name: string, ext: string) { | ||
this._value = `${name}.${ext}`; | ||
} | ||
|
||
value() { | ||
return this._value; | ||
} | ||
} |
22 changes: 11 additions & 11 deletions
22
src/core/export/resolvers/export.ts → src/core/export/resolvers/export/export.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
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
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