-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'development' into 'main'
Add ShExML execution capabilities to weaver (mostly bug fixing) See merge request rml/proc/rmlweaver-js!1
- Loading branch information
Showing
163 changed files
with
1,340 additions
and
958 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
# The input parts | ||
{ | ||
# Shows a list of options | ||
"Type" = [ | ||
"feat", | ||
"fix", | ||
"docs", | ||
"style", | ||
"refactor", | ||
"test", | ||
"chore" | ||
] | ||
"Scope" = @ # Single line input | ||
"Subject" = @ | ||
"Body" = !@ # Multi-line input | ||
"Footer" = !@ | ||
} | ||
|
||
# predefined messages | ||
# this section is optional | ||
{ | ||
vb = "chore: version bump" | ||
readme = "docs: updated readme" | ||
} | ||
|
||
# The output format | ||
# Takes the values provided from the input stage | ||
# and interpolates them in | ||
${Type} (${Scope}): ${Subject} | ||
|
||
${Body} | ||
|
||
${Footer} | ||
|
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 |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"tabWidth": 4, | ||
"semi": false, | ||
"singleQuote": true | ||
} |
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,88 +1,144 @@ | ||
import {Operator} from "./Operator.js"; | ||
import Handlebars from 'handlebars'; | ||
import {BlankNode, Iri, LanguageDataType, Literal} from "../types.js"; | ||
import { Operator } from './Operator.js' | ||
import Handlebars from 'handlebars' | ||
import { BlankNode, Iri, LanguageDataType, Literal } from '../types.js' | ||
import { forEach } from 'most' | ||
|
||
export class ExtendOp extends Operator { | ||
generateMapping(key, mapping) { // In function so recursion is possible | ||
generateMapping(key, mapping) { | ||
// In function so recursion is possible | ||
|
||
if (key.charAt(0) === '?') key = key.slice(1) // Remove ? When we have a *variable* attribute | ||
|
||
const innerFunction = mapping.inner_function != null ? this.generateMapping(key, mapping.inner_function) : null; | ||
let regex = /\{([^}]+)}/g // Match text between curly brackets. | ||
const innerFunction = | ||
mapping.inner_function != null | ||
? this.generateMapping(key, mapping.inner_function) | ||
: null | ||
|
||
switch (mapping.type) { | ||
|
||
case('Iri'): | ||
return obj => { | ||
innerFunction(obj); | ||
obj[key] = new Iri(obj[key]); | ||
}; | ||
|
||
case('Literal'): | ||
const dtypeFunction = mapping.dtype_function != null ? this.generateMapping(key, mapping.inner_function) : null; | ||
const langtypeFunction = mapping.langtype_function != null ? this.generateMapping(key, mapping.inner_function) : null; | ||
|
||
|
||
return obj => { | ||
innerFunction(obj); | ||
if(dtypeFunction !== null){ | ||
case 'Iri': | ||
return (obj) => { | ||
innerFunction(obj) | ||
obj[key] = new Iri(obj[key]) | ||
} | ||
|
||
case 'Literal': | ||
const dtypeFunction = | ||
mapping.dtype_function != null | ||
? this.generateMapping(key, mapping.inner_function) | ||
: null | ||
const langtypeFunction = | ||
mapping.langtype_function != null | ||
? this.generateMapping(key, mapping.inner_function) | ||
: null | ||
|
||
return (obj) => { | ||
innerFunction(obj) | ||
if (dtypeFunction !== null) { | ||
dtypeFunction(obj) | ||
} | ||
if(langtypeFunction !== null){ | ||
if (langtypeFunction !== null) { | ||
langtypeFunction(obj) | ||
} | ||
obj[key] = new Literal(obj[key]); | ||
}; | ||
|
||
case('BlankNode'): | ||
return obj => { | ||
innerFunction(obj); | ||
obj[key] = new BlankNode(obj[key]); | ||
}; | ||
|
||
case('UriEncode'): | ||
return obj => { | ||
innerFunction(obj); | ||
|
||
obj[key] = encodeURI(obj[key]).replace(',', '%2C').replace('(', '%28').replace(')', '%29'); // Encode URI, Maybe manually in the future to match RML mapper. | ||
}; | ||
|
||
case('Reference'): | ||
return (obj => { | ||
obj[key] = obj[mapping.value]; | ||
}); | ||
|
||
case('Constant'): | ||
return (obj => { | ||
obj[key] = mapping.value; | ||
}); | ||
|
||
case('TemplateString'): | ||
const regex = /\{([^}]+)}/g; // Match text between curly brackets. | ||
const template_string = mapping.value.replace(regex, (match, content) => `{{[${content}]}}`); // Double brackets for HandleBars. | ||
const template = Handlebars.compile(template_string); | ||
return (obj => { | ||
obj[key] = template(obj); | ||
}); | ||
obj[key] = new Literal(obj[key]) | ||
} | ||
|
||
case 'BlankNode': | ||
return (obj) => { | ||
innerFunction(obj) | ||
obj[key] = new BlankNode(obj[key]) | ||
} | ||
|
||
case 'UriEncode': | ||
return (obj) => { | ||
innerFunction(obj) | ||
|
||
obj[key] = encodeURI(obj[key]) | ||
.replace(',', '%2C') | ||
.replace('(', '%28') | ||
.replace(')', '%29') // Encode URI, Maybe manually in the future to match RML mapper. | ||
} | ||
|
||
case 'Reference': | ||
return (obj) => { | ||
obj[key] = obj[mapping.value] | ||
} | ||
|
||
case 'Constant': | ||
return (obj) => { | ||
obj[key] = mapping.value | ||
} | ||
|
||
case 'TemplateString': | ||
// Match text between curly brackets. | ||
let template_string = mapping.value.replace( | ||
regex, | ||
(match, content) => `{{[${content}]}}`, | ||
) // Double brackets for HandleBars. | ||
let template = Handlebars.compile(template_string) | ||
return (obj) => { | ||
obj[key] = template(obj) | ||
} | ||
|
||
case 'TemplateFunctionValue': | ||
let template_string_2 = mapping.template.replace( | ||
regex, | ||
(match, content) => `{{[${content}]}}`, | ||
) // Double brackets for HandleBars. | ||
let template2 = Handlebars.compile(template_string_2) | ||
let var_function_pairs = {} | ||
for (let pair of mapping.variable_function_pairs) { | ||
let variable = pair[0] | ||
let ext_func = pair[1] | ||
ext_func = this.generateMapping(key, ext_func) | ||
var_function_pairs[variable] = ext_func | ||
} | ||
|
||
return (obj) => { | ||
let temp_val = {}; | ||
for (let variable in var_function_pairs) { | ||
let nest_func = var_function_pairs[variable] | ||
nest_func(obj) | ||
temp_val[variable] = obj[key] | ||
} | ||
obj[key] = template2(temp_val) | ||
} | ||
|
||
case 'Concatenate': | ||
const left_function = this.generateMapping( | ||
key, | ||
mapping.left_value, | ||
) | ||
const right_function = this.generateMapping( | ||
key, | ||
mapping.right_value, | ||
) | ||
return (obj) => { | ||
left_function(obj) | ||
const left_value = obj[key] | ||
right_function(obj) | ||
const right_value = obj[key] | ||
obj[key] = left_value + mapping.separator + right_value | ||
} | ||
|
||
default: | ||
throw Error(`Type (${mapping.type}) found in extend operator not supported!`); | ||
throw Error( | ||
`Type (${mapping.type}) found in extend operator not supported!`, | ||
) | ||
} | ||
} | ||
|
||
|
||
constructor(id, config) { | ||
super(id, config); | ||
this.extensions = []; | ||
super(id, config) | ||
this.extensions = [] | ||
for (let key in config) { | ||
this.extensions.push(this.generateMapping(key, config[key])); | ||
this.extensions.push(this.generateMapping(key, config[key])) | ||
} | ||
} | ||
|
||
next(v) { | ||
this.extensions.forEach(extend => { | ||
extend(v); | ||
}); | ||
this.push(v); | ||
this.extensions.forEach((extend) => { | ||
extend(v) | ||
}) | ||
this.push(v) | ||
} | ||
|
||
} |
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.