Skip to content
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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

KShivendu
Copy link
Contributor

@KShivendu KShivendu commented Oct 12, 2023

Upgrades for codemeta v3 support

Related to #23

Comment on lines +35 to +61
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.
};
Copy link
Member

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

Comment on lines +245 to +247
if (doc['@type'] === 'Role') {
return;
}
Copy link
Member

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;
Copy link
Member

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?

Comment on lines +126 to +127
for (let role of roles.split(",")) {
const [roleName, startDate, endDate] = role.split(":");
Copy link
Member

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

Comment on lines 31 to +32
function validateUrl(fieldName, doc) {
if (!isUrl(doc)) {
if (!isBlankNodeId(doc) && !isUrl(doc)) {
Copy link
Member

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.

Comment on lines +136 to +137
"SoftwareSourceCode": softwareFieldValidatorsV2,
"SoftwareApplication": softwareFieldValidatorsV2,
Copy link
Member

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants