New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

digirati-annotation-bridge

Package Overview
Dependencies
Maintainers
1
Versions
164
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

digirati-annotation-bridge - npm Package Compare versions

Comparing version 0.2.10 to 0.2.11-alpha.7057ef82

49

es/index.js

@@ -6,6 +6,34 @@ import { addCaptureModel, addInteractiveResource, addResourceTemplate } from 'digirati-annotation-redux/es/actions/resourceTemplate';

import { BODY_TYPE, COMBINE, CONFORMS_TO, DESCRIPTION, EXTERNALISE, FORM_FIELDS, HUMAN_READABLE, ID, INPUT_TYPE, MOTIVATED_BY, MULTIPLE, PURPOSE, RDFS_LABEL, SERIALIZE, TITLE, TYPE, UI_GROUP, UI_CHOICE, SELECTOR, HAS_PART } from './vocab';
import { BODY_TYPE, COMBINE, CONFORMS_TO, DESCRIPTION, EXTERNALISE, FORM_FIELDS, HAS_PART, HUMAN_READABLE, ID, INPUT_TYPE, MOTIVATED_BY, MULTIPLE, PURPOSE, RDFS_LABEL, SELECTOR, SERIALIZE, TITLE, TYPE, UI_CHOICE, UI_GROUP } from './vocab';
import { castBool, labelId } from './helpers';
export function getMotivationInstance(str) {
var motive = str.toLowerCase();
// Remove the open annotation prefix.
if (motive.indexOf('oa:') === 0) {
return getMotivationInstance(motive.substr(3));
}
if (['assessing', 'bookmarking', 'classifying', 'commenting', 'describing', 'editing', 'highlighting', 'identifying', 'linking', 'moderating', 'questioning', 'replying', 'tagging'].indexOf(motive) !== -1) {
return motive;
}
// This is the default to fallback to.
return 'tagging';
}
function motivationFromForm(motivatedBy) {
if (!motivatedBy) {
return null;
}
if (!motivatedBy.id) {
return null;
}
return {
id: motivatedBy.id,
label: motivatedBy.label ? motivatedBy.label : motivatedBy.id,
instance: getMotivationInstance(motivatedBy.id)
};
}
export function mapDraftToDataSet(captureModels, values) {

@@ -28,5 +56,5 @@ var contexts = {};

return {
"type": ["TextualBody", "Dataset"],
"value": JSON.stringify(body),
"format": "text/plain"
'type': ['TextualBody', 'Dataset'],
'value': JSON.stringify(body),
'format': 'text/plain'
};

@@ -43,2 +71,13 @@ }

export function getDraftFromCaptureModel(template) {
return {
motivation: motivationFromForm(template && template.captureModels && template.captureModels['madoc:form'] ? template.captureModels['madoc:form'].motivatedBy : {
id: null,
label: 'Tagging',
instance: 'tagging'
}),
resources: getDraftTemplateFromCaptureModel(template)
};
}
export function getDraftTemplateFromCaptureModel(template) {

@@ -75,3 +114,3 @@ var resources = template && template.captureModels && template.captureModels['madoc:form'] && template.captureModels['madoc:form'].interactiveResources;

selector: resourceTemplate[SELECTOR] ? resourceTemplate[SELECTOR][ID] : null,
motivatedBy: labelId(resourceTemplate[MOTIVATED_BY])
motivatedBy: motivationFromForm(labelId(resourceTemplate[MOTIVATED_BY]))
}));

@@ -78,0 +117,0 @@

@@ -5,5 +5,7 @@ 'use strict';

exports.resourceTemplateReverseTypeLookup = exports.parseTarget = exports.mapTarget = exports.mapAnnotationBody = exports.createDraftFromAnnotation = undefined;
exports.getMotivationInstance = getMotivationInstance;
exports.mapDraftToDataSet = mapDraftToDataSet;
exports.dataSetToAnnotation = dataSetToAnnotation;
exports.getW3CAnnotationBody = getW3CAnnotationBody;
exports.getDraftFromCaptureModel = getDraftFromCaptureModel;
exports.getDraftTemplateFromCaptureModel = getDraftTemplateFromCaptureModel;

@@ -25,2 +27,30 @@ exports.omekaImportResourceTemplate = omekaImportResourceTemplate;

function getMotivationInstance(str) {
var motive = str.toLowerCase();
// Remove the open annotation prefix.
if (motive.indexOf('oa:') === 0) {
return getMotivationInstance(motive.substr(3));
}
if (['assessing', 'bookmarking', 'classifying', 'commenting', 'describing', 'editing', 'highlighting', 'identifying', 'linking', 'moderating', 'questioning', 'replying', 'tagging'].indexOf(motive) !== -1) {
return motive;
}
// This is the default to fallback to.
return 'tagging';
}
function motivationFromForm(motivatedBy) {
if (!motivatedBy) {
return null;
}
if (!motivatedBy.id) {
return null;
}
return {
id: motivatedBy.id,
label: motivatedBy.label ? motivatedBy.label : motivatedBy.id,
instance: getMotivationInstance(motivatedBy.id)
};
}
function mapDraftToDataSet(captureModels, values) {

@@ -43,5 +73,5 @@ var contexts = {};

return {
"type": ["TextualBody", "Dataset"],
"value": JSON.stringify(body),
"format": "text/plain"
'type': ['TextualBody', 'Dataset'],
'value': JSON.stringify(body),
'format': 'text/plain'
};

@@ -58,2 +88,13 @@ }

function getDraftFromCaptureModel(template) {
return {
motivation: motivationFromForm(template && template.captureModels && template.captureModels['madoc:form'] ? template.captureModels['madoc:form'].motivatedBy : {
id: null,
label: 'Tagging',
instance: 'tagging'
}),
resources: getDraftTemplateFromCaptureModel(template)
};
}
function getDraftTemplateFromCaptureModel(template) {

@@ -90,3 +131,3 @@ var resources = template && template.captureModels && template.captureModels['madoc:form'] && template.captureModels['madoc:form'].interactiveResources;

selector: resourceTemplate[_vocab.SELECTOR] ? resourceTemplate[_vocab.SELECTOR][_vocab.ID] : null,
motivatedBy: (0, _helpers.labelId)(resourceTemplate[_vocab.MOTIVATED_BY])
motivatedBy: motivationFromForm((0, _helpers.labelId)(resourceTemplate[_vocab.MOTIVATED_BY]))
}));

@@ -93,0 +134,0 @@

7

package.json
{
"name": "digirati-annotation-bridge",
"version": "0.2.10",
"version": "0.2.11-alpha.7057ef82",
"description": "Describe annotation-bridge here",

@@ -17,6 +17,7 @@ "main": "lib/index.js",

"test:coverage": "nwb test --coverage",
"test:watch": "nwb test --server"
"test:watch": "nwb test --server",
"prepublish": "npm run build"
},
"dependencies": {
"digirati-annotation-redux": "^0.2.10"
"digirati-annotation-redux": "^0.2.11-alpha.7057ef82"
},

@@ -23,0 +24,0 @@ "devDependencies": {

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc