Skip to content

Commit

Permalink
chore: Standardize files (#84)
Browse files Browse the repository at this point in the history
  • Loading branch information
ddeboer authored Jun 14, 2024
1 parent eb3a3ae commit 907ce8f
Show file tree
Hide file tree
Showing 26 changed files with 487 additions and 522 deletions.
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ npm run compile
npm run ld-workbench -- --config static/example
```

The configuration of this project is validated and defined by [JSON Schema](https://json-schema.org). The schema is located in `./static/ld-workbench-schema.json`. To create the types from this schema, run `npm run util:json-schema-to-typescript`. This will regenerate `./src/types/LDWorkbenchConfiguration.d.ts`, do not modify this file by hand.
The configuration of this project is validated and defined by [JSON Schema](https://json-schema.org). The schema is located in `./static/ld-workbench-schema.json`. To create the types from this schema, run `npm run util:json-schema-to-typescript`. This will regenerate `./src/types/configuration.d.ts`, do not modify this file by hand.

## Committing changes

Expand Down
6 changes: 3 additions & 3 deletions src/cliArgs.ts → src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,16 @@ program
)
.version(version());
program.parse();
export const cliArgs: {
export const cli: {
config: string;
pipeline?: string;
stage?: string;
silent?: boolean;
init?: boolean;
} = program.opts();

if (cliArgs.init !== undefined) {
if (Object.values(cliArgs).length !== 2) {
if (cli.init !== undefined) {
if (Object.values(cli).length !== 2) {
error(
'The --init flag can not be used in conjunction with other CLI arguments.'
);
Expand Down
158 changes: 158 additions & 0 deletions src/configuration.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,158 @@
/* eslint-disable */
/**
* This file was automatically generated by json-schema-to-typescript.
* DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file,
* and run json-schema-to-typescript to regenerate this file.
*/

/**
* JSON Schema for LDWorkbench.
* It helps with the writing of the configuration needed to run LDWorkbench pipelines.
*/
export interface Configuration {
/**
* The name of your pipeline. It must be unique over all your configurations.
*/
name: string;
/**
* An optional description for your pipeline.
*/
description?: string;
/**
* An optional base directory for files referenced by `file://...` paths. This defaults to the directory that contains the YAML configuration file.
*/
baseDir?: string;
/**
* The file where the final result of your pipeline is saved.
*/
destination?: string;
/**
* A pipeline stage consists of an iterator and one or more generators.
*
* @minItems 1
*/
stages: [
{
/**
* The name of the stage. It must be unique within the pipeline.
*/
name: string;
iterator: {
/**
* SPARQL SELECT query that returns a `$this` binding for each URI that will be passed to the generator(s). Either an inline string (`SELECT $this WHERE {...}`) or a reference to a file (`file://...`) that contains the query.
*/
query: string;
/**
* SPARQL endpoint for the iterator. If it starts with `file://`, a local RDF file is queried. If omitted the result of the previous stage is used.
*/
endpoint?: string;
/**
* Number of `$this` bindings retrieved per query. Defaults to the LIMIT value of your iterator query or 10 if no LIMIT is present.
*/
batchSize?: number;
/**
* Human-readable time delay for requests to the the iterator’s SPARQL endpoint (e.g. `5ms`, `100 milliseconds`, `1s`).
*/
delay?: string;
};
/**
* @minItems 1
*/
generator: [
{
/**
* SPARQL CONSTRUCT query that takes a `$this` binding from the iterator and generates triples for it. Either an inline string (`CONSTRUCT $this schema:name ?name WHERE {$this ...}`) or a reference to a file (`file://...`) that contains the query.
*/
query: string;
/**
* The SPARQL endpoint for the generator. If it starts with `file://`, a local RDF file is queried. If omitted, the endpoint of the iterator is used.
*/
endpoint?: string;
/**
* Overrule the generator's behaviour of fetching results for 10 bindings of `$this` per request.
*/
batchSize?: number;
},
...{
/**
* SPARQL CONSTRUCT query that takes a `$this` binding from the iterator and generates triples for it. Either an inline string (`CONSTRUCT $this schema:name ?name WHERE {$this ...}`) or a reference to a file (`file://...`) that contains the query.
*/
query: string;
/**
* The SPARQL endpoint for the generator. If it starts with `file://`, a local RDF file is queried. If omitted, the endpoint of the iterator is used.
*/
endpoint?: string;
/**
* Overrule the generator's behaviour of fetching results for 10 bindings of `$this` per request.
*/
batchSize?: number;
}[]
];
/**
* The optional path where the results are saved. If omitted, a temporary file will be created.
*/
destination?: string;
},
...{
/**
* The name of the stage. It must be unique within the pipeline.
*/
name: string;
iterator: {
/**
* SPARQL SELECT query that returns a `$this` binding for each URI that will be passed to the generator(s). Either an inline string (`SELECT $this WHERE {...}`) or a reference to a file (`file://...`) that contains the query.
*/
query: string;
/**
* SPARQL endpoint for the iterator. If it starts with `file://`, a local RDF file is queried. If omitted the result of the previous stage is used.
*/
endpoint?: string;
/**
* Number of `$this` bindings retrieved per query. Defaults to the LIMIT value of your iterator query or 10 if no LIMIT is present.
*/
batchSize?: number;
/**
* Human-readable time delay for requests to the the iterator’s SPARQL endpoint (e.g. `5ms`, `100 milliseconds`, `1s`).
*/
delay?: string;
};
/**
* @minItems 1
*/
generator: [
{
/**
* SPARQL CONSTRUCT query that takes a `$this` binding from the iterator and generates triples for it. Either an inline string (`CONSTRUCT $this schema:name ?name WHERE {$this ...}`) or a reference to a file (`file://...`) that contains the query.
*/
query: string;
/**
* The SPARQL endpoint for the generator. If it starts with `file://`, a local RDF file is queried. If omitted, the endpoint of the iterator is used.
*/
endpoint?: string;
/**
* Overrule the generator's behaviour of fetching results for 10 bindings of `$this` per request.
*/
batchSize?: number;
},
...{
/**
* SPARQL CONSTRUCT query that takes a `$this` binding from the iterator and generates triples for it. Either an inline string (`CONSTRUCT $this schema:name ?name WHERE {$this ...}`) or a reference to a file (`file://...`) that contains the query.
*/
query: string;
/**
* The SPARQL endpoint for the generator. If it starts with `file://`, a local RDF file is queried. If omitted, the endpoint of the iterator is used.
*/
endpoint?: string;
/**
* Overrule the generator's behaviour of fetching results for 10 bindings of `$this` per request.
*/
batchSize?: number;
}[]
];
/**
* The optional path where the results are saved. If omitted, a temporary file will be created.
*/
destination?: string;
}[]
];
}
4 changes: 2 additions & 2 deletions src/lib/File.class.ts → src/file.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ import {
mkdirSync,
createReadStream,
} from 'fs';
import {isFile, isFilePathString} from '../utils/guards.js';
import {isFile, isFilePathString} from './utils/guards.js';
import {dirname} from 'path';
import chalk from 'chalk';
import {type Ora} from 'ora';
import type Pipeline from './Pipeline.class.js';
import type Pipeline from './pipeline.js';
import {pipeline as streamPipeline} from 'stream/promises';

export default class File {
Expand Down
12 changes: 6 additions & 6 deletions src/lib/Generator.class.ts → src/generator.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import type {ConstructQuery} from 'sparqljs';
import type Stage from './Stage.class.js';
import getSPARQLQuery from '../utils/getSPARQLQuery.js';
import type Stage from './stage.js';
import getSPARQLQuery from './utils/getSPARQLQuery.js';
import type {Quad, NamedNode} from '@rdfjs/types';
import getSPARQLQueryString from '../utils/getSPARQLQueryString.js';
import getEndpoint from '../utils/getEndpoint.js';
import getSPARQLQueryString from './utils/getSPARQLQueryString.js';
import getEndpoint from './utils/getEndpoint.js';
import type {Endpoint, QueryEngine, QuerySource} from './types.js';
import getEngine from '../utils/getEngine.js';
import getEngineSource from '../utils/getEngineSource.js';
import getEngine from './utils/getEngine.js';
import getEngineSource from './utils/getEngineSource.js';
import EventEmitter from 'node:events';

const DEFAULT_BATCH_SIZE = 10;
Expand Down
12 changes: 6 additions & 6 deletions src/lib/Iterator.class.ts → src/iterator.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import EventEmitter from 'node:events';
import type {SelectQuery} from 'sparqljs';
import type Stage from './Stage.class.js';
import type Stage from './stage.js';
import type {NamedNode} from '@rdfjs/types';
import getSPARQLQuery from '../utils/getSPARQLQuery.js';
import getSPARQLQuery from './utils/getSPARQLQuery.js';
import {type Bindings} from '@comunica/types';
import getSPARQLQueryString from '../utils/getSPARQLQueryString.js';
import getEndpoint from '../utils/getEndpoint.js';
import getSPARQLQueryString from './utils/getSPARQLQueryString.js';
import getEndpoint from './utils/getEndpoint.js';
import type {Endpoint, QueryEngine, QuerySource} from './types.js';
import getEngine from '../utils/getEngine.js';
import getEngineSource from '../utils/getEngineSource.js';
import getEngine from './utils/getEngine.js';
import getEngineSource from './utils/getEngineSource.js';
import parse from 'parse-duration';

const DEFAULT_LIMIT = 10;
Expand Down
Loading

0 comments on commit 907ce8f

Please sign in to comment.