@@ -4,7 +4,9 @@ import { Resolvable } from "df/core/common";
44import * as Path from "df/core/path" ;
55import { Session } from "df/core/session" ;
66import {
7+ actionConfigToCompiledGraphTarget ,
78 addDependenciesToActionDependencyTargets ,
9+ configTargetToCompiledGraphTarget ,
810 nativeRequire ,
911 resolveActionsConfigFilename
1012} from "df/core/utils" ;
@@ -37,22 +39,27 @@ export class DataPreparation extends ActionBuilder<dataform.DataPreparation> {
3739 this . proto . dataPreparation = dataPreparationDefinition ;
3840
3941 // Find targets
40- const targets = getTargets ( dataPreparationDefinition )
41- this . proto . targets = targets . map ( ( target ) => this . applySessionToTarget (
42- target ,
43- session . projectConfig ,
44- config . filename ,
45- true
46- ) ) ;
47- this . proto . canonicalTargets = targets . map ( ( target ) => this . applySessionToTarget ( target , session . canonicalProjectConfig ) ) ;
42+ const targets = getTargets ( dataPreparationDefinition ) ;
43+ this . proto . targets = targets . map ( target =>
44+ this . applySessionToTarget ( target , session . projectConfig , config . filename , true )
45+ ) ;
46+ this . proto . canonicalTargets = targets . map ( target =>
47+ this . applySessionToTarget ( target , session . canonicalProjectConfig )
48+ ) ;
4849
4950 // Set the unique target key as the first target defined.
5051 // TODO: Remove once multiple targets are supported.
5152 this . proto . target = this . proto . targets [ 0 ] ;
5253 this . proto . canonicalTarget = this . proto . canonicalTargets [ 0 ] ;
5354
5455 this . proto . tags = config . tags ;
55- this . dependencies ( config . dependencyTargets ) ;
56+ if ( config . dependencyTargets ) {
57+ this . dependencies (
58+ config . dependencyTargets . map ( dependencyTarget =>
59+ configTargetToCompiledGraphTarget ( dataform . ActionConfig . Target . create ( dependencyTarget ) )
60+ )
61+ ) ;
62+ }
5663 this . proto . fileName = config . filename ;
5764 if ( config . disabled ) {
5865 this . proto . disabled = config . disabled ;
@@ -72,7 +79,7 @@ export class DataPreparation extends ActionBuilder<dataform.DataPreparation> {
7279 public dependencies ( value : Resolvable | Resolvable [ ] ) {
7380 const newDependencies = Array . isArray ( value ) ? value : [ value ] ;
7481 newDependencies . forEach ( resolvable =>
75- addDependenciesToActionDependencyTargets ( this , resolvable )
82+ addDependenciesToActionDependencyTargets ( this , resolvable )
7683 ) ;
7784 return this ;
7885 }
@@ -101,17 +108,18 @@ export class DataPreparation extends ActionBuilder<dataform.DataPreparation> {
101108 }
102109}
103110
104- function parseDataPreparationDefinitionJson (
105- dataPreparationAsJson : { [ key : string ] : unknown } ) : dataform . DataPreparationDefinition {
111+ function parseDataPreparationDefinitionJson ( dataPreparationAsJson : {
112+ [ key : string ] : unknown ;
113+ } ) : dataform . DataPreparationDefinition {
106114 try {
107115 return dataform . DataPreparationDefinition . create (
108- verifyObjectMatchesProto (
109- dataform . DataPreparationDefinition ,
110- dataPreparationAsJson as {
111- [ key : string ] : any ;
112- } ,
113- VerifyProtoErrorBehaviour . SHOW_DOCS_LINK
114- )
116+ verifyObjectMatchesProto (
117+ dataform . DataPreparationDefinition ,
118+ dataPreparationAsJson as {
119+ [ key : string ] : any ;
120+ } ,
121+ VerifyProtoErrorBehaviour . SHOW_DOCS_LINK
122+ )
115123 ) ;
116124 } catch ( e ) {
117125 if ( e instanceof ReferenceError ) {
@@ -121,20 +129,18 @@ function parseDataPreparationDefinitionJson(
121129 }
122130}
123131
124- function getTargets (
125- definition : dataform . DataPreparationDefinition
126- ) : dataform . Target [ ] {
132+ function getTargets ( definition : dataform . DataPreparationDefinition ) : dataform . Target [ ] {
127133 const targets : dataform . Target [ ] = [ ] ;
128134
129135 definition . nodes . forEach ( node => {
130136 const table = node . destination ?. table ;
131137 if ( table ) {
132138 const compiledGraphTarget : dataform . ITarget = {
133139 database : table . project ,
134- schema :table . dataset ,
140+ schema : table . dataset ,
135141 name : table . table
136142 } ;
137- targets . push ( dataform . Target . create ( compiledGraphTarget ) )
143+ targets . push ( dataform . Target . create ( compiledGraphTarget ) ) ;
138144 }
139145 } ) ;
140146
0 commit comments