-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: Upgrades for codemeta v3 support #24
base: master
Are you sure you want to change the base?
Conversation
const directCodemetaFieldsV2 = { | ||
'codeRepository': '#codeRepository', | ||
'contIntegration': '#contIntegration', | ||
'dateCreated': '#dateCreated', | ||
'datePublished': '#datePublished', | ||
'dateModified': '#dateModified', | ||
'downloadUrl': '#downloadUrl', | ||
'issueTracker': '#issueTracker', | ||
'name': '#name', | ||
'version': '#version', | ||
'identifier': '#identifier', | ||
'description': '#description', | ||
'applicationCategory': '#applicationCategory', | ||
'releaseNotes': '#releaseNotes', | ||
'funding': '#funding', | ||
'developmentStatus': '#funding', | ||
'isPartOf': '#isPartOf', | ||
'referencePublication': '#referencePublication' | ||
}; | ||
|
||
const directCodemetaFieldsV3 = { | ||
...directCodemetaFieldsV2, | ||
// 'hasSourceCode': '#hasSourceCode', -> Generator is for SoftwareSource code not SoftwareApplication | ||
'isSourceCodeOf': '#isSourceCodeOf', | ||
'continuousIntegration': '#contIntegration', | ||
// 'embargoEndDate': '#embargoDate' -> Not in use for v2. Not required for v3 either. | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we can do better than this, by generating fields unconditionally so produced documents will work regardless of Codemeta version the reader's expects. See #25
if (doc['@type'] === 'Role') { | ||
return; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why?
for (const doc of docs) { | ||
if (doc['@type'] === 'Role') { | ||
let authorId = doc['author']['@id']; | ||
authorId = isBlankNodeId(authorId) ? authorId.substring(2) : authorId; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As far as I can tell, there is nothing preventing a document to have both https://example.org/
as IRI and _:https://example.org/
as blank node identifier. Stripping _:
would make them collide. Why do you need to strip the prefix?
for (let role of roles.split(",")) { | ||
const [roleName, startDate, endDate] = role.split(":"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's user input, you need to validate it
function validateUrl(fieldName, doc) { | ||
if (!isUrl(doc)) { | ||
if (!isBlankNodeId(doc) && !isUrl(doc)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You probably need to turn this into two functions: one for @id
(which may be blank node identifiers or URIs) and one for actual URLs.
"SoftwareSourceCode": softwareFieldValidatorsV2, | ||
"SoftwareApplication": softwareFieldValidatorsV2, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm do we even use those?
Upgrades for codemeta v3 support
Related to #23