@comunica/actor-init-query 4.0.1-alpha.48.0 → 4.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -118,13 +118,13 @@ class CliArgsHandlerBase {
|
|
|
118
118
|
type: 'number',
|
|
119
119
|
describe: 'The number of retries to perform on failed fetch requests',
|
|
120
120
|
},
|
|
121
|
-
|
|
121
|
+
httpRetryDelayFallback: {
|
|
122
122
|
type: 'number',
|
|
123
|
-
describe: 'The
|
|
123
|
+
describe: 'The fallback delay in milliseconds between fetch retries',
|
|
124
124
|
},
|
|
125
|
-
|
|
126
|
-
type: '
|
|
127
|
-
describe: '
|
|
125
|
+
httpRetryDelayLimit: {
|
|
126
|
+
type: 'number',
|
|
127
|
+
describe: 'The upper limit in milliseconds for the delay between fetch retries',
|
|
128
128
|
},
|
|
129
129
|
unionDefaultGraph: {
|
|
130
130
|
type: 'boolean',
|
|
@@ -216,19 +216,19 @@ class CliArgsHandlerBase {
|
|
|
216
216
|
if (args.httpRetryCount) {
|
|
217
217
|
context[context_entries_1.KeysHttp.httpRetryCount.name] = args.httpRetryCount;
|
|
218
218
|
}
|
|
219
|
-
// Define HTTP delay between retries
|
|
220
|
-
if (args.
|
|
219
|
+
// Define fallback HTTP delay between retries
|
|
220
|
+
if (args.httpRetryDelayFallback) {
|
|
221
221
|
if (!args.httpRetryCount) {
|
|
222
|
-
throw new Error('The --
|
|
222
|
+
throw new Error('The --httpRetryDelayFallback option requires the --httpRetryCount option to be set');
|
|
223
223
|
}
|
|
224
|
-
context[context_entries_1.KeysHttp.
|
|
224
|
+
context[context_entries_1.KeysHttp.httpRetryDelayFallback.name] = args.httpRetryDelayFallback;
|
|
225
225
|
}
|
|
226
|
-
// Define
|
|
227
|
-
if (args.
|
|
226
|
+
// Define limit to the delay between HTTP retries
|
|
227
|
+
if (args.httpRetryDelayLimit) {
|
|
228
228
|
if (!args.httpRetryCount) {
|
|
229
|
-
throw new Error('The --
|
|
229
|
+
throw new Error('The --httpRetryDelayLimit option requires the --httpRetryCount option to be set');
|
|
230
230
|
}
|
|
231
|
-
context[context_entries_1.KeysHttp.
|
|
231
|
+
context[context_entries_1.KeysHttp.httpRetryDelayLimit.name] = args.httpRetryDelayLimit;
|
|
232
232
|
}
|
|
233
233
|
// Define union default graph
|
|
234
234
|
if (args.unionDefaultGraph) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CliArgsHandlerBase.js","sourceRoot":"","sources":["CliArgsHandlerBase.ts"],"names":[],"mappings":";;;AAAA,6CAA6C;AAC7C,2DAA0C;AAC1C,qCAAmD;AACnD,8BAA8B;AAC9B,kCAAkC;AAClC,+DAA4G;AAC5G,yCAA+C;AAC/C,2DAAuD;AAIvD,MAAM,OAAO,GAAmB,OAAO,CAAC,UAAU,CAAC,CAAC;AAEpD;;GAEG;AACH,MAAa,kBAAkB;IAG7B,YAAmB,cAA+B;QAChD,IAAI,CAAC,cAAc,GAAG,cAAc,CAAC;IACvC,CAAC;IAEM,MAAM,CAAC,eAAe,CAAC,OAAe,EAAE,QAAgB;QAC7D,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE;YAC7B,IAAA,yBAAI,EAAC,OAAO,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,EAAE;gBACtC,IAAI,KAAK,EAAE,CAAC;oBACV,OAAO,CAAC,QAAQ,CAAC,CAAC;gBACpB,CAAC;gBACD,OAAO,CAAC,CAAC,MAAM,IAAI,MAAM,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC;YACxC,CAAC,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;IACL,CAAC;IAEM,MAAM,CAAC,wBAAwB;QACpC,OAAO,IAAA,oBAAU,EAAC,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,YAAY,CAAC,CAAC,CAAC;IACxD,CAAC;IAED;;;;OAIG;IACI,MAAM,CAAC,yBAAyB,CAAC,YAAoB;QA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AAI,CAAC,GAAG,IAAI,CAAC,cAAc,CAAC;QAC9D,CAAC;QAED,6CAA6C;QAC7C,IAAI,IAAI,CAAC,sBAAsB,EAAE,CAAC;YAChC,IAAI,CAAC,IAAI,CAAC,cAAc,EAAE,CAAC;gBACzB,MAAM,IAAI,KAAK,CAAC,oFAAoF,CAAC,CAAC;YACxG,CAAC;YACD,OAAO,CAAC,0BAAQ,CAAC,sBAAsB,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC,sBAAsB,CAAC;QAC9E,CAAC;QAED,6BAA6B;QAC7B,IAAI,IAAI,CAAC,iBAAiB,EAAE,CAAC;YAC3B,OAAO,CAAC,oCAAkB,CAAC,iBAAiB,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC;QAC5D,CAAC;QAED,qCAAqC;QACrC,IAAI,IAAI,CAAC,eAAe,EAAE,CAAC;YACzB,OAAO,CAAC,+BAAa,CAAC,eAAe,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC;QACrD,CAAC;QAED,2CAA2C;QAC3C,IAAI,IAAI,CAAC,iBAAiB,EAAE,CAAC;YAC3B,OAAO,CAAC,+BAAa,CAAC,iBAAiB,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC;QACvD,CAAC;IACH,CAAC;CACF;AAlQD,gDAkQC;AACD,4CAA4C","sourcesContent":["/* eslint-disable import/no-nodejs-modules */\nimport { exec } from 'node:child_process';\nimport { existsSync, readFileSync } from 'node:fs';\nimport * as OS from 'node:os';\nimport * as Path from 'node:path';\nimport { KeysHttp, KeysInitQuery, KeysQueryOperation, KeysRdfUpdateQuads } from '@comunica/context-entries';\nimport { ActionContext } from '@comunica/core';\nimport { LoggerPretty } from '@comunica/logger-pretty';\nimport type { IActionContext, ICliArgsHandler } from '@comunica/types';\nimport type { Argv } from 'yargs';\n\nconst process: NodeJS.Process = require('process/');\n\n/**\n * Basic CLI arguments handler that handles common options.\n */\nexport class CliArgsHandlerBase implements ICliArgsHandler {\n private readonly initialContext?: IActionContext;\n\n public constructor(initialContext?: IActionContext) {\n this.initialContext = initialContext;\n }\n\n public static getScriptOutput(command: string, fallback: string): Promise<string> {\n return new Promise((resolve) => {\n exec(command, (error, stdout, stderr) => {\n if (error) {\n resolve(fallback);\n }\n resolve((stdout || stderr).trimEnd());\n });\n });\n }\n\n public static isDevelopmentEnvironment(): boolean {\n return existsSync(Path.join(__dirname, `../../test`));\n }\n\n /**\n * Converts an URL like 'hypermedia@http://user:passwd@example.com to an IDataSource\n * @param {string} sourceString An url with possibly a type and authorization.\n * @return {[id: string]: any} An IDataSource which represents the sourceString.\n */\n public static getSourceObjectFromString(sourceString: string): Record<string, any> {\n const source: Record<string, any> = {};\n const mediaTypeRegex = /^([^:]*)@/u;\n const mediaTypeMatches = mediaTypeRegex.exec(sourceString);\n if (mediaTypeMatches) {\n source.type = mediaTypeMatches[1];\n sourceString = sourceString.slice((<number> source.type.length) + 1);\n }\n const authRegex = /\\/\\/(.*:.*)@/u;\n const authMatches = authRegex.exec(sourceString);\n if (authMatches) {\n const credentials = authMatches[1];\n source.context = new ActionContext({\n [KeysHttp.auth.name]: decodeURIComponent(credentials),\n });\n sourceString = sourceString.slice(0, authMatches.index + 2) +\n sourceString.slice(authMatches.index + credentials.length + 3);\n }\n source.value = sourceString;\n return source;\n }\n\n public populateYargs(argumentsBuilder: Argv<any>): Argv<any> {\n return argumentsBuilder\n .command(\n '$0 [sources...]',\n 'evaluates SPARQL queries',\n () => {\n // Do nothing\n },\n () => {\n // Do nothing\n },\n )\n .default('sources', [])\n .hide('sources')\n .wrap(160)\n .version(false)\n .options({\n context: {\n alias: 'c',\n type: 'string',\n describe: 'Use the given JSON context string or file (e.g., config.json)',\n },\n to: {\n type: 'string',\n describe: 'Destination for update queries',\n },\n baseIRI: {\n alias: 'b',\n type: 'string',\n describe: 'base IRI for the query (e.g., http://example.org/)',\n },\n dateTime: {\n alias: 'd',\n type: 'string',\n describe: 'Sets a datetime for querying Memento-enabled archives',\n },\n logLevel: {\n alias: 'l',\n type: 'string',\n describe: 'Sets the log level (e.g., debug, info, warn, ...)',\n default: 'warn',\n },\n lenient: {\n type: 'boolean',\n describe: 'If failing requests and parsing errors should be logged instead of causing a hard crash',\n },\n version: {\n alias: 'v',\n type: 'boolean',\n describe: 'Prints version information',\n },\n showStackTrace: {\n type: 'boolean',\n describe: 'Prints the full stacktrace when errors are thrown',\n },\n httpTimeout: {\n type: 'number',\n describe: 'HTTP requests timeout in milliseconds',\n },\n httpBodyTimeout: {\n type: 'boolean',\n describe: 'Makes the HTTP timeout take into account the response body stream read',\n },\n httpRetryCount: {\n type: 'number',\n describe: 'The number of retries to perform on failed fetch requests',\n },\n httpRetryDelay: {\n type: 'number',\n describe: 'The number of milliseconds to wait between fetch retries',\n },\n httpRetryOnServerError: {\n type: 'boolean',\n describe: 'If fetch should be retried on 5xx server error responses, instead of being resolved.',\n },\n unionDefaultGraph: {\n type: 'boolean',\n describe: 'If the default graph should also contain the union of all named graphs',\n },\n invalidateCache: {\n type: 'boolean',\n describe: 'Enable cache invalidation before each query execution',\n },\n distinctConstruct: {\n type: 'boolean',\n describe: 'If the query engine should deduplicate resulting triples',\n },\n })\n .exitProcess(false)\n .fail(false)\n .help(false);\n }\n\n public async handleArgs(args: Record<string, any>, context: Record<string, any>): Promise<void> {\n // Print version information\n if (args.version) {\n // eslint-disable-next-line ts/no-require-imports,ts/no-var-requires,import/extensions\n const comunicaVersion: string = require('../../package.json').version;\n const dev: string = CliArgsHandlerBase.isDevelopmentEnvironment() ? '(dev)' : '';\n const nodeVersion: string = process.version;\n const npmVersion: string = await CliArgsHandlerBase.getScriptOutput('npm -v', '_NPM is unavailable_');\n const yarnVersion: string = await CliArgsHandlerBase.getScriptOutput('yarn -v', '_Yarn is unavailable_');\n const os = `${OS.platform()} (${OS.type()} ${OS.release()})`;\n\n const message = `| software | version\n| ---------------- | -------\n| Comunica Engine | ${comunicaVersion} ${dev}\n| node | ${nodeVersion}\n| npm | ${npmVersion}\n| yarn | ${yarnVersion}\n| Operating System | ${os}\n`;\n\n throw new Error(message);\n }\n\n // Inherit default context options\n if (this.initialContext) {\n Object.assign(context, this.initialContext.toJS());\n }\n\n // Define context\n if (args.context) {\n Object.assign(context, JSON.parse(existsSync(args.context) ? readFileSync(args.c, 'utf8') : args.context));\n } else if (args.sources[0]?.startsWith('{')) {\n // For backwards compatibility inline JSON\n Object.assign(context, JSON.parse(args.sources[0]));\n args.sources.shift();\n }\n\n // Add sources to context\n if (args.sources.length > 0) {\n context.sources = context.sources || [];\n // eslint-disable-next-line unicorn/no-array-for-each\n args.sources.forEach((sourceValue: string) => {\n const source = CliArgsHandlerBase.getSourceObjectFromString(sourceValue);\n context.sources.push(source);\n });\n }\n\n // Add destination to context\n if (args.to) {\n context[KeysRdfUpdateQuads.destination.name] = args.to;\n }\n\n // Set the logger\n if (!context.log) {\n context.log = new LoggerPretty({ level: args.logLevel });\n }\n\n // Define the base IRI\n if (args.baseIRI) {\n context[KeysInitQuery.baseIRI.name] = args.baseIRI;\n }\n\n // Define lenient-mode\n if (args.lenient) {\n context[KeysInitQuery.lenient.name] = true;\n }\n\n // Define HTTP timeout\n if (args.httpTimeout) {\n context[KeysHttp.httpTimeout.name] = args.httpTimeout;\n }\n\n // Define HTTP body timeout\n if (args.httpBodyTimeout) {\n if (!args.httpTimeout) {\n throw new Error('The --httpBodyTimeout option requires the --httpTimeout option to be set');\n }\n context[KeysHttp.httpBodyTimeout.name] = args.httpBodyTimeout;\n }\n\n // Define HTTP retry count\n if (args.httpRetryCount) {\n context[KeysHttp.httpRetryCount.name] = args.httpRetryCount;\n }\n\n // Define HTTP delay between retries\n if (args.httpRetryDelay) {\n if (!args.httpRetryCount) {\n throw new Error('The --httpRetryDelay option requires the --httpRetryCount option to be set');\n }\n context[KeysHttp.httpRetryDelay.name] = args.httpRetryDelay;\n }\n\n // Define HTTP retry on server error response\n if (args.httpRetryOnServerError) {\n if (!args.httpRetryCount) {\n throw new Error('The --httpRetryOnServerError option requires the --httpRetryCount option to be set');\n }\n context[KeysHttp.httpRetryOnServerError.name] = args.httpRetryOnServerError;\n }\n\n // Define union default graph\n if (args.unionDefaultGraph) {\n context[KeysQueryOperation.unionDefaultGraph.name] = true;\n }\n\n // Define if cache should be disabled\n if (args.invalidateCache) {\n context[KeysInitQuery.invalidateCache.name] = true;\n }\n\n // Define if results should be deduplicated\n if (args.distinctConstruct) {\n context[KeysInitQuery.distinctConstruct.name] = true;\n }\n }\n}\n/* eslint-enable import/no-nodejs-modules */\n"]}
|
|
1
|
+
{"version":3,"file":"CliArgsHandlerBase.js","sourceRoot":"","sources":["CliArgsHandlerBase.ts"],"names":[],"mappings":";;;AAAA,6CAA6C;AAC7C,2DAA0C;AAC1C,qCAAmD;AACnD,8BAA8B;AAC9B,kCAAkC;AAClC,+DAA4G;AAC5G,yCAA+C;AAC/C,2DAAuD;AAIvD,MAAM,OAAO,GAAmB,OAAO,CAAC,UAAU,CAAC,CAAC;AAEpD;;GAEG;AACH,MAAa,kBAAkB;IAG7B,YAAmB,cAA+B;QAChD,IAAI,CAAC,cAAc,GAAG,cAAc,CAAC;IACvC,CAAC;IAEM,MAAM,CAAC,eAAe,CAAC,OAAe,EAAE,QAAgB;QAC7D,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE;YAC7B,IAAA,yBAAI,EAAC,OAAO,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,EAAE;gBACtC,IAAI,KAAK,EAAE,CAAC;oBACV,OAAO,CAAC,QAAQ,CAAC,CAAC;gBACpB,CAAC;gBACD,OAAO,CAAC,CAAC,MAAM,IAAI,MAAM,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC;YACxC,CAAC,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;IACL,CAAC;IAEM,MAAM,CAAC,wBAAwB;QACpC,OAAO,IAAA,oBAAU,EAAC,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,YAAY,CAAC,CAAC,CAAC;IACxD,CAAC;IAED;;;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YACxG,CAAC;YACD,OAAO,CAAC,0BAAQ,CAAC,sBAAsB,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC,sBAAsB,CAAC;QAC9E,CAAC;QAED,iDAAiD;QACjD,IAAI,IAAI,CAAC,mBAAmB,EAAE,CAAC;YAC7B,IAAI,CAAC,IAAI,CAAC,cAAc,EAAE,CAAC;gBACzB,MAAM,IAAI,KAAK,CAAC,iFAAiF,CAAC,CAAC;YACrG,CAAC;YACD,OAAO,CAAC,0BAAQ,CAAC,mBAAmB,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC,mBAAmB,CAAC;QACxE,CAAC;QAED,6BAA6B;QAC7B,IAAI,IAAI,CAAC,iBAAiB,EAAE,CAAC;YAC3B,OAAO,CAAC,oCAAkB,CAAC,iBAAiB,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC;QAC5D,CAAC;QAED,qCAAqC;QACrC,IAAI,IAAI,CAAC,eAAe,EAAE,CAAC;YACzB,OAAO,CAAC,+BAAa,CAAC,eAAe,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC;QACrD,CAAC;QAED,2CAA2C;QAC3C,IAAI,IAAI,CAAC,iBAAiB,EAAE,CAAC;YAC3B,OAAO,CAAC,+BAAa,CAAC,iBAAiB,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC;QACvD,CAAC;IACH,CAAC;CACF;AAlQD,gDAkQC;AACD,4CAA4C","sourcesContent":["/* eslint-disable import/no-nodejs-modules */\nimport { exec } from 'node:child_process';\nimport { existsSync, readFileSync } from 'node:fs';\nimport * as OS from 'node:os';\nimport * as Path from 'node:path';\nimport { KeysHttp, KeysInitQuery, KeysQueryOperation, KeysRdfUpdateQuads } from '@comunica/context-entries';\nimport { ActionContext } from '@comunica/core';\nimport { LoggerPretty } from '@comunica/logger-pretty';\nimport type { IActionContext, ICliArgsHandler } from '@comunica/types';\nimport type { Argv } from 'yargs';\n\nconst process: NodeJS.Process = require('process/');\n\n/**\n * Basic CLI arguments handler that handles common options.\n */\nexport class CliArgsHandlerBase implements ICliArgsHandler {\n private readonly initialContext?: IActionContext;\n\n public constructor(initialContext?: IActionContext) {\n this.initialContext = initialContext;\n }\n\n public static getScriptOutput(command: string, fallback: string): Promise<string> {\n return new Promise((resolve) => {\n exec(command, (error, stdout, stderr) => {\n if (error) {\n resolve(fallback);\n }\n resolve((stdout || stderr).trimEnd());\n });\n });\n }\n\n public static isDevelopmentEnvironment(): boolean {\n return existsSync(Path.join(__dirname, `../../test`));\n }\n\n /**\n * Converts an URL like 'hypermedia@http://user:passwd@example.com to an IDataSource\n * @param {string} sourceString An url with possibly a type and authorization.\n * @return {[id: string]: any} An IDataSource which represents the sourceString.\n */\n public static getSourceObjectFromString(sourceString: string): Record<string, any> {\n const source: Record<string, any> = {};\n const mediaTypeRegex = /^([^:]*)@/u;\n const mediaTypeMatches = mediaTypeRegex.exec(sourceString);\n if (mediaTypeMatches) {\n source.type = mediaTypeMatches[1];\n sourceString = sourceString.slice((<number> source.type.length) + 1);\n }\n const authRegex = /\\/\\/(.*:.*)@/u;\n const authMatches = authRegex.exec(sourceString);\n if (authMatches) {\n const credentials = authMatches[1];\n source.context = new ActionContext({\n [KeysHttp.auth.name]: decodeURIComponent(credentials),\n });\n sourceString = sourceString.slice(0, authMatches.index + 2) +\n sourceString.slice(authMatches.index + credentials.length + 3);\n }\n source.value = sourceString;\n return source;\n }\n\n public populateYargs(argumentsBuilder: Argv<any>): Argv<any> {\n return argumentsBuilder\n .command(\n '$0 [sources...]',\n 'evaluates SPARQL queries',\n () => {\n // Do nothing\n },\n () => {\n // Do nothing\n },\n )\n .default('sources', [])\n .hide('sources')\n .wrap(160)\n .version(false)\n .options({\n context: {\n alias: 'c',\n type: 'string',\n describe: 'Use the given JSON context string or file (e.g., config.json)',\n },\n to: {\n type: 'string',\n describe: 'Destination for update queries',\n },\n baseIRI: {\n alias: 'b',\n type: 'string',\n describe: 'base IRI for the query (e.g., http://example.org/)',\n },\n dateTime: {\n alias: 'd',\n type: 'string',\n describe: 'Sets a datetime for querying Memento-enabled archives',\n },\n logLevel: {\n alias: 'l',\n type: 'string',\n describe: 'Sets the log level (e.g., debug, info, warn, ...)',\n default: 'warn',\n },\n lenient: {\n type: 'boolean',\n describe: 'If failing requests and parsing errors should be logged instead of causing a hard crash',\n },\n version: {\n alias: 'v',\n type: 'boolean',\n describe: 'Prints version information',\n },\n showStackTrace: {\n type: 'boolean',\n describe: 'Prints the full stacktrace when errors are thrown',\n },\n httpTimeout: {\n type: 'number',\n describe: 'HTTP requests timeout in milliseconds',\n },\n httpBodyTimeout: {\n type: 'boolean',\n describe: 'Makes the HTTP timeout take into account the response body stream read',\n },\n httpRetryCount: {\n type: 'number',\n describe: 'The number of retries to perform on failed fetch requests',\n },\n httpRetryDelayFallback: {\n type: 'number',\n describe: 'The fallback delay in milliseconds between fetch retries',\n },\n httpRetryDelayLimit: {\n type: 'number',\n describe: 'The upper limit in milliseconds for the delay between fetch retries',\n },\n unionDefaultGraph: {\n type: 'boolean',\n describe: 'If the default graph should also contain the union of all named graphs',\n },\n invalidateCache: {\n type: 'boolean',\n describe: 'Enable cache invalidation before each query execution',\n },\n distinctConstruct: {\n type: 'boolean',\n describe: 'If the query engine should deduplicate resulting triples',\n },\n })\n .exitProcess(false)\n .fail(false)\n .help(false);\n }\n\n public async handleArgs(args: Record<string, any>, context: Record<string, any>): Promise<void> {\n // Print version information\n if (args.version) {\n // eslint-disable-next-line ts/no-require-imports,ts/no-var-requires,import/extensions\n const comunicaVersion: string = require('../../package.json').version;\n const dev: string = CliArgsHandlerBase.isDevelopmentEnvironment() ? '(dev)' : '';\n const nodeVersion: string = process.version;\n const npmVersion: string = await CliArgsHandlerBase.getScriptOutput('npm -v', '_NPM is unavailable_');\n const yarnVersion: string = await CliArgsHandlerBase.getScriptOutput('yarn -v', '_Yarn is unavailable_');\n const os = `${OS.platform()} (${OS.type()} ${OS.release()})`;\n\n const message = `| software | version\n| ---------------- | -------\n| Comunica Engine | ${comunicaVersion} ${dev}\n| node | ${nodeVersion}\n| npm | ${npmVersion}\n| yarn | ${yarnVersion}\n| Operating System | ${os}\n`;\n\n throw new Error(message);\n }\n\n // Inherit default context options\n if (this.initialContext) {\n Object.assign(context, this.initialContext.toJS());\n }\n\n // Define context\n if (args.context) {\n Object.assign(context, JSON.parse(existsSync(args.context) ? readFileSync(args.c, 'utf8') : args.context));\n } else if (args.sources[0]?.startsWith('{')) {\n // For backwards compatibility inline JSON\n Object.assign(context, JSON.parse(args.sources[0]));\n args.sources.shift();\n }\n\n // Add sources to context\n if (args.sources.length > 0) {\n context.sources = context.sources || [];\n // eslint-disable-next-line unicorn/no-array-for-each\n args.sources.forEach((sourceValue: string) => {\n const source = CliArgsHandlerBase.getSourceObjectFromString(sourceValue);\n context.sources.push(source);\n });\n }\n\n // Add destination to context\n if (args.to) {\n context[KeysRdfUpdateQuads.destination.name] = args.to;\n }\n\n // Set the logger\n if (!context.log) {\n context.log = new LoggerPretty({ level: args.logLevel });\n }\n\n // Define the base IRI\n if (args.baseIRI) {\n context[KeysInitQuery.baseIRI.name] = args.baseIRI;\n }\n\n // Define lenient-mode\n if (args.lenient) {\n context[KeysInitQuery.lenient.name] = true;\n }\n\n // Define HTTP timeout\n if (args.httpTimeout) {\n context[KeysHttp.httpTimeout.name] = args.httpTimeout;\n }\n\n // Define HTTP body timeout\n if (args.httpBodyTimeout) {\n if (!args.httpTimeout) {\n throw new Error('The --httpBodyTimeout option requires the --httpTimeout option to be set');\n }\n context[KeysHttp.httpBodyTimeout.name] = args.httpBodyTimeout;\n }\n\n // Define HTTP retry count\n if (args.httpRetryCount) {\n context[KeysHttp.httpRetryCount.name] = args.httpRetryCount;\n }\n\n // Define fallback HTTP delay between retries\n if (args.httpRetryDelayFallback) {\n if (!args.httpRetryCount) {\n throw new Error('The --httpRetryDelayFallback option requires the --httpRetryCount option to be set');\n }\n context[KeysHttp.httpRetryDelayFallback.name] = args.httpRetryDelayFallback;\n }\n\n // Define limit to the delay between HTTP retries\n if (args.httpRetryDelayLimit) {\n if (!args.httpRetryCount) {\n throw new Error('The --httpRetryDelayLimit option requires the --httpRetryCount option to be set');\n }\n context[KeysHttp.httpRetryDelayLimit.name] = args.httpRetryDelayLimit;\n }\n\n // Define union default graph\n if (args.unionDefaultGraph) {\n context[KeysQueryOperation.unionDefaultGraph.name] = true;\n }\n\n // Define if cache should be disabled\n if (args.invalidateCache) {\n context[KeysInitQuery.invalidateCache.name] = true;\n }\n\n // Define if results should be deduplicated\n if (args.distinctConstruct) {\n context[KeysInitQuery.distinctConstruct.name] = true;\n }\n }\n}\n/* eslint-enable import/no-nodejs-modules */\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@comunica/actor-init-query",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.0.2",
|
|
4
4
|
"description": "A query init actor",
|
|
5
5
|
"lsd:module": true,
|
|
6
6
|
"license": "MIT",
|
|
@@ -41,16 +41,16 @@
|
|
|
41
41
|
"build:components": "componentsjs-generator"
|
|
42
42
|
},
|
|
43
43
|
"dependencies": {
|
|
44
|
-
"@comunica/actor-http-proxy": "4.0.
|
|
45
|
-
"@comunica/bus-http-invalidate": "4.0.
|
|
46
|
-
"@comunica/bus-init": "4.0.
|
|
47
|
-
"@comunica/bus-query-process": "4.0.
|
|
48
|
-
"@comunica/bus-query-result-serialize": "4.0.
|
|
49
|
-
"@comunica/context-entries": "4.0.
|
|
50
|
-
"@comunica/core": "4.0.
|
|
51
|
-
"@comunica/logger-pretty": "4.0.
|
|
52
|
-
"@comunica/runner": "4.0.
|
|
53
|
-
"@comunica/types": "4.0.
|
|
44
|
+
"@comunica/actor-http-proxy": "^4.0.2",
|
|
45
|
+
"@comunica/bus-http-invalidate": "^4.0.2",
|
|
46
|
+
"@comunica/bus-init": "^4.0.2",
|
|
47
|
+
"@comunica/bus-query-process": "^4.0.2",
|
|
48
|
+
"@comunica/bus-query-result-serialize": "^4.0.2",
|
|
49
|
+
"@comunica/context-entries": "^4.0.2",
|
|
50
|
+
"@comunica/core": "^4.0.2",
|
|
51
|
+
"@comunica/logger-pretty": "^4.0.2",
|
|
52
|
+
"@comunica/runner": "^4.0.2",
|
|
53
|
+
"@comunica/types": "^4.0.2",
|
|
54
54
|
"@rdfjs/types": "*",
|
|
55
55
|
"@types/yargs": "^17.0.24",
|
|
56
56
|
"asynciterator": "^3.9.0",
|
|
@@ -66,5 +66,5 @@
|
|
|
66
66
|
"browser": {
|
|
67
67
|
"./lib/index.js": "./lib/index-browser.js"
|
|
68
68
|
},
|
|
69
|
-
"gitHead": "
|
|
69
|
+
"gitHead": "b60deab76821557f8d027208ab743d3c66fc60ea"
|
|
70
70
|
}
|