-
Notifications
You must be signed in to change notification settings - Fork 173
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove custom generic stringifiers (#1912)
* Remove stringified map * Remove stringified set * Fix lint error * Fix @see usage
- Loading branch information
Showing
11 changed files
with
100 additions
and
371 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 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,35 +1,39 @@ | ||
import { StringifiedMap } from "df/common/strings/stringifier"; | ||
import { targetStringifier } from "df/core/targets"; | ||
import { dataform } from "df/protos/ts"; | ||
|
||
export const combineAllActions = (graph: dataform.ICompiledGraph) => { | ||
return ([] as Array< | ||
dataform.ITable | dataform.IOperation | dataform.IAssertion | dataform.IDeclaration | dataform.IDataPreparation | ||
>).concat( | ||
type CoreProtoActionTypes = | ||
| dataform.ITable | ||
| dataform.IOperation | ||
| dataform.IAssertion | ||
| dataform.IDeclaration | ||
| dataform.IDataPreparation; | ||
|
||
function combineAllActions(graph: dataform.ICompiledGraph) { | ||
return ([] as CoreProtoActionTypes[]).concat( | ||
graph.tables || ([] as dataform.ITable[]), | ||
graph.operations || ([] as dataform.IOperation[]), | ||
graph.assertions || ([] as dataform.IAssertion[]), | ||
graph.declarations || ([] as dataform.IDeclaration[]), | ||
graph.dataPreparations || ([] as dataform.IDataPreparation[]) | ||
); | ||
}; | ||
} | ||
|
||
export function actionsByTarget(compiledGraph: dataform.ICompiledGraph) { | ||
return new StringifiedMap( | ||
targetStringifier, | ||
combineAllActions(compiledGraph) | ||
// Required for backwards compatibility with old versions of @dataform/core. | ||
.filter(action => !!action.target) | ||
.map(action => [action.target, action]) | ||
); | ||
const actionsMap = new Map<string, CoreProtoActionTypes>(); | ||
combineAllActions(compiledGraph) | ||
// Required for backwards compatibility with old versions of @dataform/core. | ||
.filter(action => !!action.target) | ||
.forEach(action => { | ||
actionsMap.set(targetStringifier.stringify(action.target), action); | ||
}); | ||
} | ||
|
||
export function actionsByCanonicalTarget(compiledGraph: dataform.ICompiledGraph) { | ||
return new StringifiedMap( | ||
targetStringifier, | ||
combineAllActions(compiledGraph) | ||
// Required for backwards compatibility with old versions of @dataform/core. | ||
.filter(action => !!action.canonicalTarget) | ||
.map(action => [action.canonicalTarget, action]) | ||
); | ||
const actionsMap = new Map<string, CoreProtoActionTypes>(); | ||
combineAllActions(compiledGraph) | ||
// Required for backwards compatibility with old versions of @dataform/core. | ||
.filter(action => !!action.canonicalTarget) | ||
.forEach(action => { | ||
actionsMap.set(targetStringifier.stringify(action.canonicalTarget), action); | ||
}); | ||
} |
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
Oops, something went wrong.