-
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.
fix: Set source type for endpoints (#68)
* Refactor Pipeline to validate in constructor instead of requiring a separate call to valiate().
- Loading branch information
Showing
12 changed files
with
51 additions
and
102 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
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
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,20 +1,28 @@ | ||
import {isPreviousStage} from './guards.js'; | ||
import {existsSync} from 'fs'; | ||
import path from 'path'; | ||
import type {Endpoint} from '../lib/types.js'; | ||
import type {Endpoint, QuerySource} from '../lib/types.js'; | ||
|
||
export default function getEngineSource(endpoint: Endpoint): string { | ||
let source: string; | ||
export default function getEngineSource(endpoint: Endpoint): QuerySource { | ||
if (isPreviousStage(endpoint)) { | ||
const previousStage = endpoint.load(); | ||
if (!existsSync(previousStage.destinationPath)) { | ||
throw new Error( | ||
`The result from stage "${previousStage.name}" (${previousStage.destinationPath}) is not available, make sure to run that stage first` | ||
); | ||
} | ||
source = path.resolve(previousStage.destinationPath); | ||
} else { | ||
source = endpoint.toString(); | ||
return { | ||
type: 'file', | ||
value: path.resolve(previousStage.destinationPath), | ||
}; | ||
} else if (endpoint instanceof URL) { | ||
return { | ||
type: 'sparql', | ||
value: endpoint.toString(), | ||
}; | ||
} | ||
return source; | ||
|
||
return { | ||
value: endpoint.toString(), | ||
}; | ||
} |
Oops, something went wrong.