Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@annotation-studio/redux

Package Overview
Dependencies
Maintainers
1
Versions
173
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@annotation-studio/redux - npm Package Compare versions

Comparing version 1.0.0-next.5a1be109 to 1.0.0-next.5f131126

es/lib/annotation/__tests__/part-of-test.js

91

es/actions/drafts.js

@@ -46,9 +46,19 @@ import _extends from 'babel-runtime/helpers/extends';

export function createDraft(scope, emptyInput, template) {
var motivation = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 'tagging';
var selectors = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : null;
var draftDefaults = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : null;
var immutableSelector = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : null;
var path = arguments.length > 7 && arguments[7] !== undefined ? arguments[7] : [];
var name = arguments.length > 8 && arguments[8] !== undefined ? arguments[8] : null;
export function createDraft(scope, _ref) {
var emptyInput = _ref.emptyInput,
template = _ref.template,
_ref$motivation = _ref.motivation,
motivation = _ref$motivation === undefined ? 'tagging' : _ref$motivation,
_ref$selectors = _ref.selectors,
selectors = _ref$selectors === undefined ? null : _ref$selectors,
_ref$draftDefaults = _ref.draftDefaults,
draftDefaults = _ref$draftDefaults === undefined ? null : _ref$draftDefaults,
_ref$immutableSelecto = _ref.immutableSelector,
immutableSelector = _ref$immutableSelecto === undefined ? null : _ref$immutableSelecto,
_ref$path = _ref.path,
path = _ref$path === undefined ? [] : _ref$path,
_ref$name = _ref.name,
name = _ref$name === undefined ? null : _ref$name,
_ref$partOf = _ref.partOf,
partOf = _ref$partOf === undefined ? null : _ref$partOf;

@@ -59,3 +69,3 @@ return function (dispatch, getState) {

// Create draft.
dispatch(createDirectDraft(scope, id, input, template, selectors, motivation, path));
dispatch(createDirectDraft(scope, id, input, template, selectors, motivation, path, null, partOf));
// And select it straight away.

@@ -100,5 +110,5 @@ dispatch(selectDraft(scope, id));

export function changeFingerPrintLifecyle(_ref, desiredLifecycle) {
var fingerprint = _ref.fingerprint,
draft = _objectWithoutProperties(_ref, ['fingerprint']);
export function changeFingerPrintLifecyle(_ref2, desiredLifecycle) {
var fingerprint = _ref2.fingerprint,
draft = _objectWithoutProperties(_ref2, ['fingerprint']);

@@ -108,38 +118,55 @@ var lifecycle = getValidLifecycle(desiredLifecycle, draft.lifecycle);

return _extends({}, draft, {
fingerprint: createFingerprint(fingerprint.scope, fingerprint.path, fingerprint.identity, fingerprint.created, lifecycle, fingerprint.source, fingerprint.creator)
fingerprint: createFingerprint(_extends({}, fingerprint, {
lifecycle: lifecycle
}))
});
}
export function changeFingerPrintCreator(_ref2, creator) {
var fingerprint = _ref2.fingerprint,
draft = _objectWithoutProperties(_ref2, ['fingerprint']);
export function changeFingerPrintCreator(_ref3, creator) {
var fingerprint = _ref3.fingerprint,
draft = _objectWithoutProperties(_ref3, ['fingerprint']);
return _extends({}, draft, {
fingerprint: createFingerprint(fingerprint.scope, fingerprint.path, fingerprint.identity, fingerprint.created, fingerprint.lifecycle, fingerprint.source, creator)
fingerprint: createFingerprint(_extends({}, fingerprint, {
creator: creator
}))
});
}
export function changeFingerprintSource(_ref3, source) {
var fingerprint = _ref3.fingerprint,
draft = _objectWithoutProperties(_ref3, ['fingerprint']);
export function changeFingerprintSource(_ref4, source) {
var fingerprint = _ref4.fingerprint,
draft = _objectWithoutProperties(_ref4, ['fingerprint']);
return _extends({}, draft, {
fingerprint: createFingerprint(fingerprint.scope, fingerprint.path, fingerprint.identity, fingerprint.created, fingerprint.lifecycle, source, fingerprint.creator)
fingerprint: createFingerprint(_extends({}, fingerprint, {
source: source
}))
});
}
export function changeFingerprintIdentity(_ref4, identity) {
var fingerprint = _ref4.fingerprint,
draft = _objectWithoutProperties(_ref4, ['fingerprint']);
export function changeFingerprintIdentity(_ref5, identity) {
var fingerprint = _ref5.fingerprint,
draft = _objectWithoutProperties(_ref5, ['fingerprint']);
return _extends({}, draft, {
fingerprint: createFingerprint(fingerprint.scope, fingerprint.path, identity, fingerprint.created, fingerprint.lifecycle, fingerprint.source, fingerprint.creator)
fingerprint: createFingerprint(_extends({}, fingerprint, {
identity: identity
}))
});
}
export function createFingerprint(scope, path, identity) {
var created = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : null;
var lifecycle = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : null;
var source = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : null;
var creator = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : null;
export function createFingerprint(_ref6) {
var scope = _ref6.scope,
path = _ref6.path,
identity = _ref6.identity,
_ref6$created = _ref6.created,
created = _ref6$created === undefined ? null : _ref6$created,
_ref6$lifecycle = _ref6.lifecycle,
lifecycle = _ref6$lifecycle === undefined ? null : _ref6$lifecycle,
_ref6$source = _ref6.source,
source = _ref6$source === undefined ? null : _ref6$source,
_ref6$creator = _ref6.creator,
creator = _ref6$creator === undefined ? null : _ref6$creator,
_ref6$partOf = _ref6.partOf,
partOf = _ref6$partOf === undefined ? null : _ref6$partOf;

@@ -153,3 +180,4 @@ return {

source: source ? source : 'memory', // memory | elucidate | localStorage
creator: creator ? creator : 'unknown'
creator: creator ? creator : 'unknown',
partOf: partOf ? partOf : null // Usually manifest.
};

@@ -163,2 +191,3 @@ }

var created = arguments.length > 7 && arguments[7] !== undefined ? arguments[7] : null;
var partOf = arguments.length > 8 && arguments[8] !== undefined ? arguments[8] : null;

@@ -173,3 +202,3 @@ return {

motivation: motivation,
fingerprint: createFingerprint(scope, path, null, created, null, null, 'you')
fingerprint: createFingerprint({ scope: scope, path: path, created: created, creator: 'you', partOf: partOf })
}

@@ -176,0 +205,0 @@ };

@@ -76,2 +76,3 @@ import md5 from 'blueimp-md5';

dispatch(addElucidateAnnotation(annotation));
return annotation;
});

@@ -78,0 +79,0 @@ };

@@ -14,2 +14,3 @@ import _extends from 'babel-runtime/helpers/extends';

import { richAnnotationList } from './query/elucidateQuery';
import { currentManifest } from './query/manifestQuery';
import { setViewer, withViewer } from './actions/viewer';

@@ -67,2 +68,3 @@ import { currentSelectorIsSecondary, isSelecting } from './query/selectorQuery';

currentResource: currentResource,
currentManifest: currentManifest(state),
isSelecting: isSelecting(state),

@@ -69,0 +71,0 @@ isSelectingPrimary: isSelecting(state) && currentSelectorIsSecondary(state) === false,

@@ -112,3 +112,3 @@ import Annotation from '../Annotation';

const annotation = jsonify(
createAnnotationFromCaptureModelAndDraft('http://manifest', captureModel, draft),
createAnnotationFromCaptureModelAndDraft({ target: 'http://manifest', captureModel, draft }),
);

@@ -115,0 +115,0 @@

@@ -266,3 +266,3 @@ import {

const annotation = jsonify(
createAnnotationFromCaptureModelAndDraft('http://manifest', captureModel, draft),
createAnnotationFromCaptureModelAndDraft({ target: 'http://manifest', captureModel, draft }),
);

@@ -269,0 +269,0 @@

@@ -113,3 +113,3 @@ import Annotation from '../Annotation';

const annotation = jsonify(
createAnnotationFromCaptureModelAndDraft('http://manifest', captureModel, draft),
createAnnotationFromCaptureModelAndDraft({ target: 'http://manifest', captureModel, draft, partOf: 'http://some-manifest' }),
);

@@ -134,3 +134,6 @@

'generator': 'http://omeka.dlcs-ida.org/api/item_sets/733',
'target': 'http://manifest',
'target': {
'dcterms:isPartOf': 'http://some-manifest',
'id': 'http://manifest',
},
'motivation': {

@@ -137,0 +140,0 @@ 'id': 'oa:tagging',

@@ -173,3 +173,3 @@ import { createAnnotationFromCaptureModelAndDraft } from '../mapping';

const annotation = jsonify(
createAnnotationFromCaptureModelAndDraft('http://manifest', captureModel, draft),
createAnnotationFromCaptureModelAndDraft({ target: 'http://manifest', captureModel, draft }),
);

@@ -176,0 +176,0 @@

@@ -667,3 +667,3 @@ import { createAnnotationFromCaptureModelAndDraft } from '../mapping';

it('should create annotation', () => {
const annotation = jsonify(createAnnotationFromCaptureModelAndDraft('http://manifest', captureModel, draft));
const annotation = jsonify(createAnnotationFromCaptureModelAndDraft({ target: 'http://manifest', captureModel, draft }));
const [

@@ -670,0 +670,0 @@ nameAnnotation,

@@ -0,1 +1,2 @@

import _extends from 'babel-runtime/helpers/extends';
import _classCallCheck from 'babel-runtime/helpers/classCallCheck';

@@ -16,3 +17,3 @@

function AnnotationSelector(id, scale, format, language, processingLanguage, textDirection, selector) {
function AnnotationSelector(id, scale, format, language, processingLanguage, textDirection, selector, partOf) {
_classCallCheck(this, AnnotationSelector);

@@ -30,9 +31,9 @@

this.textDirection = textDirection;
this.selector = AnnotationSelector.parseTarget(id, scale, selector);
this.selector = AnnotationSelector.parseTarget(id, scale, selector, partOf);
}
AnnotationSelector.fromTarget = function fromTarget(target, selector) {
AnnotationSelector.fromTarget = function fromTarget(target, selector, partOf) {
var annotationSelector = new AnnotationSelector();
annotationSelector.source = target;
annotationSelector.selector = selector;
annotationSelector.selector = AnnotationSelector.parseTarget(selector, 1, null, partOf);
return annotationSelector;

@@ -48,5 +49,9 @@ };

if (text['dcterms:isPartOf']) {
text.partOf = text['dcterms:isPartOf'];
}
// https://www.w3.org/TR/annotation-model/#bodies-and-targets
if (text.id) {
return new AnnotationSelector(text.id, scale, text.format, text.language, text.processingLanguage, text.textDirection);
return new AnnotationSelector(text.id, scale, text.format, text.language, text.processingLanguage, text.textDirection, null, text.partOf);
}

@@ -56,3 +61,3 @@

if (text.source) {
return new AnnotationSelector(text.source, scale, text.format, text.language, text.processingLanguage, text.textDirection, text.selector);
return new AnnotationSelector(text.source, scale, text.format, text.language, text.processingLanguage, text.textDirection, text.selector, text.partOf);
}

@@ -67,2 +72,3 @@

var selector = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
var partOf = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : null;

@@ -96,9 +102,11 @@ var toParse = source;

return source.split('#')[0];
}
},
partOf: partOf
};
}
return source;
return _extends({}, source, { partOf: partOf });
};
AnnotationSelector.prototype.toJSON = function toJSON() {
AnnotationSelector.prototype.getStringSelector = function getStringSelector() {
if (!this.selector || this.selector.x === null || isNaN(Math.floor(this.selector.x)) || this.selector.y === null || isNaN(Math.floor(this.selector.y))) {

@@ -115,2 +123,15 @@ return this.source;

AnnotationSelector.prototype.toJSON = function toJSON() {
// If we have a part of, we can't reduce to string.
if (this.selector && this.selector.partOf) {
// This is the target field.
return {
id: this.getStringSelector(),
'dcterms:isPartOf': this.selector.partOf
};
}
return this.getStringSelector();
};
AnnotationSelector.prototype.toString = function toString() {

@@ -117,0 +138,0 @@ return this.id;

@@ -10,5 +10,5 @@ import _extends from 'babel-runtime/helpers/extends';

// Draft value is {id: 'http://..'}
export var FIELD_TYPES_THAT_ARE_ENTITIES = ['madoc:nullableCaptureModel', 'madoc:fallbackOptions'];
export var FIELD_TYPES_THAT_ARE_ENTITIES = ['madoc:nullableCaptureModel', 'madoc:fallbackOptions', 'madoc:autocomplete'];
// Draft value is {label: 'human readable'}
export var FIELD_TYPES_THAT_ARE_HUMAN_READABLE = ['madoc:nullableCaptureModel', 'madoc:fallbackOptions'];
export var FIELD_TYPES_THAT_ARE_HUMAN_READABLE = ['madoc:nullableCaptureModel', 'madoc:fallbackOptions', 'madoc:autocomplete'];

@@ -290,3 +290,9 @@ export function createCombinedAnnotationBody(captureModel, draft) {

export function createAnnotationFromCaptureModelAndDraft(target, captureModel, draft, customDraftSelector) {
export function createAnnotationFromCaptureModelAndDraft(_ref2) {
var target = _ref2.target,
captureModel = _ref2.captureModel,
draft = _ref2.draft,
customDraftSelector = _ref2.customDraftSelector,
partOf = _ref2.partOf;
var bodies = [];

@@ -353,3 +359,3 @@ var label = 'unknown';

return new Annotation(null, label, AnnotationBodyList.fromJsonLD(bodies), AnnotationSelector.fromTarget(target, draftSelector), motivation, generator);
return new Annotation(null, label, AnnotationBodyList.fromJsonLD(bodies), AnnotationSelector.fromTarget(target, draftSelector, partOf), motivation, generator);
}

@@ -0,1 +1,2 @@

import _extends from 'babel-runtime/helpers/extends';
import _classCallCheck from 'babel-runtime/helpers/classCallCheck';

@@ -12,3 +13,3 @@

function AnnotationSelector(id, scale, format, language, processingLanguage, textDirection, selector) {
function AnnotationSelector(id, scale, format, language, processingLanguage, textDirection, selector, partOf) {
_classCallCheck(this, AnnotationSelector);

@@ -28,3 +29,3 @@

this.textDirection = textDirection;
this.target = AnnotationSelector.parseTarget(id, scale, selector);
this.target = AnnotationSelector.parseTarget(id, scale, selector, partOf);
}

@@ -41,3 +42,3 @@

if (text.id) {
return new AnnotationSelector(text.id, scale, text.format, text.language, text.processingLanguage, text.textDirection);
return new AnnotationSelector(text.id, scale, text.format, text.language, text.processingLanguage, text.textDirection, null, text['dcterms:isPartOf']);
}

@@ -47,3 +48,3 @@

if (text.source) {
return new AnnotationSelector(text.source, scale, text.format, text.language, text.processingLanguage, text.textDirection, text.selector);
return new AnnotationSelector(text.source, scale, text.format, text.language, text.processingLanguage, text.textDirection, text.selector, text['dcterms:isPartOf']);
}

@@ -58,2 +59,3 @@

var selector = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
var partOf = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : null;

@@ -75,2 +77,3 @@ var toParse = source;

height: parseInt(match[5], 10) * scale,
partOf: partOf,
toString: function toString() {

@@ -82,3 +85,3 @@ // @todo maybe something else?

}
return source;
return _extends({}, source, { partOf: partOf });
};

@@ -85,0 +88,0 @@

@@ -8,4 +8,4 @@ import _asyncIterator from 'babel-runtime/helpers/asyncIterator';

var fetchPageCollection = function () {
var _ref3 = _asyncGenerator.wrap( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(resource) {
var currentPage, _iterator2, _isArray2, _i2, _ref4, item;
var _ref4 = _asyncGenerator.wrap( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(resource) {
var currentPage, _iterator2, _isArray2, _i2, _ref5, item;

@@ -43,3 +43,3 @@ return _regeneratorRuntime.wrap(function _callee2$(_context2) {

case 8:
_ref4 = _iterator2[_i2++];
_ref5 = _iterator2[_i2++];
_context2.next = 15;

@@ -59,6 +59,6 @@ break;

case 14:
_ref4 = _i2.value;
_ref5 = _i2.value;
case 15:
item = _ref4;
item = _ref5;
_context2.next = 18;

@@ -87,4 +87,4 @@ return item;

return function fetchPageCollection(_x5) {
return _ref3.apply(this, arguments);
return function fetchPageCollection(_x6) {
return _ref4.apply(this, arguments);
};

@@ -107,2 +107,5 @@ }();

var _ref = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : {},
withoutCredentials = _ref.withoutCredentials;
return fetch(uri, {

@@ -112,3 +115,3 @@ method: method,

body: JSON.stringify(body),
credentials: process.env.NODE_ENV === 'production' ? 'include' : null,
credentials: withoutCredentials ? null : process.env.NODE_ENV === 'production' ? 'include' : null,
cache: process.env.NODE_ENV === 'production' ? 'default' : 'force-cache',

@@ -128,3 +131,8 @@ redirect: 'follow'

export function get(uri, body) {
return makeRequest('GET', uri, body);
try {
return makeRequest('GET', uri, body);
} catch (e) {
console.warn('Request failed, trying again without credentials', e);
return makeRequest('GET', uri, body, { withoutCredentials: true });
}
}

@@ -135,3 +143,8 @@

return makeRequest('POST', uri, body, headers);
try {
return makeRequest('POST', uri, body);
} catch (e) {
console.warn('Request failed, trying again without credentials', e);
return makeRequest('POST', uri, body, { withoutCredentials: true });
}
}

@@ -142,3 +155,8 @@

return makeRequest('PUT', uri, body, headers);
try {
return makeRequest('PUT', uri, body);
} catch (e) {
console.warn('Request failed, trying again without credentials', e);
return makeRequest('PUT', uri, body, { withoutCredentials: true });
}
}

@@ -151,4 +169,4 @@

export var getAllAnnotationsFromCollection = function () {
var _ref = _asyncGenerator.wrap( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(collectionResource) {
var firstPage, _iterator, _isArray, _i, _ref2, item, collection, _item;
var _ref2 = _asyncGenerator.wrap( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(collectionResource) {
var firstPage, _iterator, _isArray, _i, _ref3, item, collection, _item;

@@ -185,3 +203,3 @@ return _regeneratorRuntime.wrap(function _callee$(_context) {

case 7:
_ref2 = _iterator[_i++];
_ref3 = _iterator[_i++];
_context.next = 14;

@@ -201,6 +219,6 @@ break;

case 13:
_ref2 = _i.value;
_ref3 = _i.value;
case 14:
item = _ref2;
item = _ref3;
_context.next = 17;

@@ -253,4 +271,4 @@ return item;

return function getAllAnnotationsFromCollection(_x4) {
return _ref.apply(this, arguments);
return function getAllAnnotationsFromCollection(_x5) {
return _ref2.apply(this, arguments);
};

@@ -257,0 +275,0 @@ }();

@@ -16,3 +16,5 @@ {

"editor.next": "Nesaf",
"editor.save": "Arbed",
"editor.save_in_progress": "Save work as in progress",
"resourceNavigation.defaultTitle": "What do you want to tag (Default title)"
}
}

@@ -17,3 +17,5 @@ {

"editor.next": "Next",
"editor.save": "Save",
"editor.save_in_progress": "Save work as in progress",
"resourceNavigation.defaultTitle": "What do you want to tag"
}

@@ -100,9 +100,19 @@ 'use strict';

function createDraft(scope, emptyInput, template) {
var motivation = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 'tagging';
var selectors = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : null;
var draftDefaults = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : null;
var immutableSelector = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : null;
var path = arguments.length > 7 && arguments[7] !== undefined ? arguments[7] : [];
var name = arguments.length > 8 && arguments[8] !== undefined ? arguments[8] : null;
function createDraft(scope, _ref) {
var emptyInput = _ref.emptyInput,
template = _ref.template,
_ref$motivation = _ref.motivation,
motivation = _ref$motivation === undefined ? 'tagging' : _ref$motivation,
_ref$selectors = _ref.selectors,
selectors = _ref$selectors === undefined ? null : _ref$selectors,
_ref$draftDefaults = _ref.draftDefaults,
draftDefaults = _ref$draftDefaults === undefined ? null : _ref$draftDefaults,
_ref$immutableSelecto = _ref.immutableSelector,
immutableSelector = _ref$immutableSelecto === undefined ? null : _ref$immutableSelecto,
_ref$path = _ref.path,
path = _ref$path === undefined ? [] : _ref$path,
_ref$name = _ref.name,
name = _ref$name === undefined ? null : _ref$name,
_ref$partOf = _ref.partOf,
partOf = _ref$partOf === undefined ? null : _ref$partOf;

@@ -113,3 +123,3 @@ return function (dispatch, getState) {

// Create draft.
dispatch(createDirectDraft(scope, id, input, template, selectors, motivation, path));
dispatch(createDirectDraft(scope, id, input, template, selectors, motivation, path, null, partOf));
// And select it straight away.

@@ -154,5 +164,5 @@ dispatch(selectDraft(scope, id));

function changeFingerPrintLifecyle(_ref, desiredLifecycle) {
var fingerprint = _ref.fingerprint,
draft = (0, _objectWithoutProperties3.default)(_ref, ['fingerprint']);
function changeFingerPrintLifecyle(_ref2, desiredLifecycle) {
var fingerprint = _ref2.fingerprint,
draft = (0, _objectWithoutProperties3.default)(_ref2, ['fingerprint']);

@@ -162,38 +172,55 @@ var lifecycle = getValidLifecycle(desiredLifecycle, draft.lifecycle);

return (0, _extends3.default)({}, draft, {
fingerprint: createFingerprint(fingerprint.scope, fingerprint.path, fingerprint.identity, fingerprint.created, lifecycle, fingerprint.source, fingerprint.creator)
fingerprint: createFingerprint((0, _extends3.default)({}, fingerprint, {
lifecycle: lifecycle
}))
});
}
function changeFingerPrintCreator(_ref2, creator) {
var fingerprint = _ref2.fingerprint,
draft = (0, _objectWithoutProperties3.default)(_ref2, ['fingerprint']);
function changeFingerPrintCreator(_ref3, creator) {
var fingerprint = _ref3.fingerprint,
draft = (0, _objectWithoutProperties3.default)(_ref3, ['fingerprint']);
return (0, _extends3.default)({}, draft, {
fingerprint: createFingerprint(fingerprint.scope, fingerprint.path, fingerprint.identity, fingerprint.created, fingerprint.lifecycle, fingerprint.source, creator)
fingerprint: createFingerprint((0, _extends3.default)({}, fingerprint, {
creator: creator
}))
});
}
function changeFingerprintSource(_ref3, source) {
var fingerprint = _ref3.fingerprint,
draft = (0, _objectWithoutProperties3.default)(_ref3, ['fingerprint']);
function changeFingerprintSource(_ref4, source) {
var fingerprint = _ref4.fingerprint,
draft = (0, _objectWithoutProperties3.default)(_ref4, ['fingerprint']);
return (0, _extends3.default)({}, draft, {
fingerprint: createFingerprint(fingerprint.scope, fingerprint.path, fingerprint.identity, fingerprint.created, fingerprint.lifecycle, source, fingerprint.creator)
fingerprint: createFingerprint((0, _extends3.default)({}, fingerprint, {
source: source
}))
});
}
function changeFingerprintIdentity(_ref4, identity) {
var fingerprint = _ref4.fingerprint,
draft = (0, _objectWithoutProperties3.default)(_ref4, ['fingerprint']);
function changeFingerprintIdentity(_ref5, identity) {
var fingerprint = _ref5.fingerprint,
draft = (0, _objectWithoutProperties3.default)(_ref5, ['fingerprint']);
return (0, _extends3.default)({}, draft, {
fingerprint: createFingerprint(fingerprint.scope, fingerprint.path, identity, fingerprint.created, fingerprint.lifecycle, fingerprint.source, fingerprint.creator)
fingerprint: createFingerprint((0, _extends3.default)({}, fingerprint, {
identity: identity
}))
});
}
function createFingerprint(scope, path, identity) {
var created = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : null;
var lifecycle = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : null;
var source = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : null;
var creator = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : null;
function createFingerprint(_ref6) {
var scope = _ref6.scope,
path = _ref6.path,
identity = _ref6.identity,
_ref6$created = _ref6.created,
created = _ref6$created === undefined ? null : _ref6$created,
_ref6$lifecycle = _ref6.lifecycle,
lifecycle = _ref6$lifecycle === undefined ? null : _ref6$lifecycle,
_ref6$source = _ref6.source,
source = _ref6$source === undefined ? null : _ref6$source,
_ref6$creator = _ref6.creator,
creator = _ref6$creator === undefined ? null : _ref6$creator,
_ref6$partOf = _ref6.partOf,
partOf = _ref6$partOf === undefined ? null : _ref6$partOf;

@@ -207,3 +234,4 @@ return {

source: source ? source : 'memory', // memory | elucidate | localStorage
creator: creator ? creator : 'unknown'
creator: creator ? creator : 'unknown',
partOf: partOf ? partOf : null // Usually manifest.
};

@@ -217,2 +245,3 @@ }

var created = arguments.length > 7 && arguments[7] !== undefined ? arguments[7] : null;
var partOf = arguments.length > 8 && arguments[8] !== undefined ? arguments[8] : null;

@@ -227,3 +256,3 @@ return {

motivation: motivation,
fingerprint: createFingerprint(scope, path, null, created, null, null, 'you')
fingerprint: createFingerprint({ scope: scope, path: path, created: created, creator: 'you', partOf: partOf })
}

@@ -230,0 +259,0 @@ };

@@ -102,2 +102,3 @@ 'use strict';

dispatch(addElucidateAnnotation(annotation));
return annotation;
});

@@ -104,0 +105,0 @@ };

@@ -35,2 +35,4 @@ 'use strict';

var _manifestQuery = require('./query/manifestQuery');
var _viewer = require('./actions/viewer');

@@ -91,2 +93,3 @@

currentResource: currentResource,
currentManifest: (0, _manifestQuery.currentManifest)(state),
isSelecting: (0, _selectorQuery.isSelecting)(state),

@@ -93,0 +96,0 @@ isSelectingPrimary: (0, _selectorQuery.isSelecting)(state) && (0, _selectorQuery.currentSelectorIsSecondary)(state) === false,

@@ -112,3 +112,3 @@ import Annotation from '../Annotation';

const annotation = jsonify(
createAnnotationFromCaptureModelAndDraft('http://manifest', captureModel, draft),
createAnnotationFromCaptureModelAndDraft({ target: 'http://manifest', captureModel, draft }),
);

@@ -115,0 +115,0 @@

@@ -266,3 +266,3 @@ import {

const annotation = jsonify(
createAnnotationFromCaptureModelAndDraft('http://manifest', captureModel, draft),
createAnnotationFromCaptureModelAndDraft({ target: 'http://manifest', captureModel, draft }),
);

@@ -269,0 +269,0 @@

@@ -113,3 +113,3 @@ import Annotation from '../Annotation';

const annotation = jsonify(
createAnnotationFromCaptureModelAndDraft('http://manifest', captureModel, draft),
createAnnotationFromCaptureModelAndDraft({ target: 'http://manifest', captureModel, draft, partOf: 'http://some-manifest' }),
);

@@ -134,3 +134,6 @@

'generator': 'http://omeka.dlcs-ida.org/api/item_sets/733',
'target': 'http://manifest',
'target': {
'dcterms:isPartOf': 'http://some-manifest',
'id': 'http://manifest',
},
'motivation': {

@@ -137,0 +140,0 @@ 'id': 'oa:tagging',

@@ -173,3 +173,3 @@ import { createAnnotationFromCaptureModelAndDraft } from '../mapping';

const annotation = jsonify(
createAnnotationFromCaptureModelAndDraft('http://manifest', captureModel, draft),
createAnnotationFromCaptureModelAndDraft({ target: 'http://manifest', captureModel, draft }),
);

@@ -176,0 +176,0 @@

@@ -667,3 +667,3 @@ import { createAnnotationFromCaptureModelAndDraft } from '../mapping';

it('should create annotation', () => {
const annotation = jsonify(createAnnotationFromCaptureModelAndDraft('http://manifest', captureModel, draft));
const annotation = jsonify(createAnnotationFromCaptureModelAndDraft({ target: 'http://manifest', captureModel, draft }));
const [

@@ -670,0 +670,0 @@ nameAnnotation,

@@ -6,2 +6,6 @@ 'use strict';

var _extends2 = require('babel-runtime/helpers/extends');
var _extends3 = _interopRequireDefault(_extends2);
var _classCallCheck2 = require('babel-runtime/helpers/classCallCheck');

@@ -26,3 +30,3 @@

function AnnotationSelector(id, scale, format, language, processingLanguage, textDirection, selector) {
function AnnotationSelector(id, scale, format, language, processingLanguage, textDirection, selector, partOf) {
(0, _classCallCheck3.default)(this, AnnotationSelector);

@@ -40,9 +44,9 @@

this.textDirection = textDirection;
this.selector = AnnotationSelector.parseTarget(id, scale, selector);
this.selector = AnnotationSelector.parseTarget(id, scale, selector, partOf);
}
AnnotationSelector.fromTarget = function fromTarget(target, selector) {
AnnotationSelector.fromTarget = function fromTarget(target, selector, partOf) {
var annotationSelector = new AnnotationSelector();
annotationSelector.source = target;
annotationSelector.selector = selector;
annotationSelector.selector = AnnotationSelector.parseTarget(selector, 1, null, partOf);
return annotationSelector;

@@ -58,5 +62,9 @@ };

if (text['dcterms:isPartOf']) {
text.partOf = text['dcterms:isPartOf'];
}
// https://www.w3.org/TR/annotation-model/#bodies-and-targets
if (text.id) {
return new AnnotationSelector(text.id, scale, text.format, text.language, text.processingLanguage, text.textDirection);
return new AnnotationSelector(text.id, scale, text.format, text.language, text.processingLanguage, text.textDirection, null, text.partOf);
}

@@ -66,3 +74,3 @@

if (text.source) {
return new AnnotationSelector(text.source, scale, text.format, text.language, text.processingLanguage, text.textDirection, text.selector);
return new AnnotationSelector(text.source, scale, text.format, text.language, text.processingLanguage, text.textDirection, text.selector, text.partOf);
}

@@ -77,2 +85,3 @@

var selector = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
var partOf = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : null;

@@ -106,9 +115,11 @@ var toParse = source;

return source.split('#')[0];
}
},
partOf: partOf
};
}
return source;
return (0, _extends3.default)({}, source, { partOf: partOf });
};
AnnotationSelector.prototype.toJSON = function toJSON() {
AnnotationSelector.prototype.getStringSelector = function getStringSelector() {
if (!this.selector || this.selector.x === null || isNaN(Math.floor(this.selector.x)) || this.selector.y === null || isNaN(Math.floor(this.selector.y))) {

@@ -125,2 +136,15 @@ return this.source;

AnnotationSelector.prototype.toJSON = function toJSON() {
// If we have a part of, we can't reduce to string.
if (this.selector && this.selector.partOf) {
// This is the target field.
return {
id: this.getStringSelector(),
'dcterms:isPartOf': this.selector.partOf
};
}
return this.getStringSelector();
};
AnnotationSelector.prototype.toString = function toString() {

@@ -127,0 +151,0 @@ return this.id;

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

// Draft value is {id: 'http://..'}
var FIELD_TYPES_THAT_ARE_ENTITIES = exports.FIELD_TYPES_THAT_ARE_ENTITIES = ['madoc:nullableCaptureModel', 'madoc:fallbackOptions'];
var FIELD_TYPES_THAT_ARE_ENTITIES = exports.FIELD_TYPES_THAT_ARE_ENTITIES = ['madoc:nullableCaptureModel', 'madoc:fallbackOptions', 'madoc:autocomplete'];
// Draft value is {label: 'human readable'}
var FIELD_TYPES_THAT_ARE_HUMAN_READABLE = exports.FIELD_TYPES_THAT_ARE_HUMAN_READABLE = ['madoc:nullableCaptureModel', 'madoc:fallbackOptions'];
var FIELD_TYPES_THAT_ARE_HUMAN_READABLE = exports.FIELD_TYPES_THAT_ARE_HUMAN_READABLE = ['madoc:nullableCaptureModel', 'madoc:fallbackOptions', 'madoc:autocomplete'];

@@ -328,3 +328,9 @@ function createCombinedAnnotationBody(captureModel, draft) {

function createAnnotationFromCaptureModelAndDraft(target, captureModel, draft, customDraftSelector) {
function createAnnotationFromCaptureModelAndDraft(_ref2) {
var target = _ref2.target,
captureModel = _ref2.captureModel,
draft = _ref2.draft,
customDraftSelector = _ref2.customDraftSelector,
partOf = _ref2.partOf;
var bodies = [];

@@ -391,3 +397,3 @@ var label = 'unknown';

return new _Annotation2.default(null, label, _AnnotationBodyList2.default.fromJsonLD(bodies), _AnnotationSelector2.default.fromTarget(target, draftSelector), motivation, generator);
return new _Annotation2.default(null, label, _AnnotationBodyList2.default.fromJsonLD(bodies), _AnnotationSelector2.default.fromTarget(target, draftSelector, partOf), motivation, generator);
}

@@ -6,2 +6,6 @@ 'use strict';

var _extends2 = require('babel-runtime/helpers/extends');
var _extends3 = _interopRequireDefault(_extends2);
var _classCallCheck2 = require('babel-runtime/helpers/classCallCheck');

@@ -22,3 +26,3 @@

function AnnotationSelector(id, scale, format, language, processingLanguage, textDirection, selector) {
function AnnotationSelector(id, scale, format, language, processingLanguage, textDirection, selector, partOf) {
(0, _classCallCheck3.default)(this, AnnotationSelector);

@@ -38,3 +42,3 @@

this.textDirection = textDirection;
this.target = AnnotationSelector.parseTarget(id, scale, selector);
this.target = AnnotationSelector.parseTarget(id, scale, selector, partOf);
}

@@ -51,3 +55,3 @@

if (text.id) {
return new AnnotationSelector(text.id, scale, text.format, text.language, text.processingLanguage, text.textDirection);
return new AnnotationSelector(text.id, scale, text.format, text.language, text.processingLanguage, text.textDirection, null, text['dcterms:isPartOf']);
}

@@ -57,3 +61,3 @@

if (text.source) {
return new AnnotationSelector(text.source, scale, text.format, text.language, text.processingLanguage, text.textDirection, text.selector);
return new AnnotationSelector(text.source, scale, text.format, text.language, text.processingLanguage, text.textDirection, text.selector, text['dcterms:isPartOf']);
}

@@ -68,2 +72,3 @@

var selector = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
var partOf = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : null;

@@ -85,2 +90,3 @@ var toParse = source;

height: parseInt(match[5], 10) * scale,
partOf: partOf,
toString: function toString() {

@@ -92,3 +98,3 @@ // @todo maybe something else?

}
return source;
return (0, _extends3.default)({}, source, { partOf: partOf });
};

@@ -95,0 +101,0 @@

@@ -27,4 +27,4 @@ 'use strict';

var getAllAnnotationsFromCollection = exports.getAllAnnotationsFromCollection = function () {
var _ref = _asyncGenerator3.default.wrap( /*#__PURE__*/_regenerator2.default.mark(function _callee(collectionResource) {
var firstPage, _iterator, _isArray, _i, _ref2, item, collection, _item;
var _ref2 = _asyncGenerator3.default.wrap( /*#__PURE__*/_regenerator2.default.mark(function _callee(collectionResource) {
var firstPage, _iterator, _isArray, _i, _ref3, item, collection, _item;

@@ -61,3 +61,3 @@ return _regenerator2.default.wrap(function _callee$(_context) {

case 7:
_ref2 = _iterator[_i++];
_ref3 = _iterator[_i++];
_context.next = 14;

@@ -77,6 +77,6 @@ break;

case 13:
_ref2 = _i.value;
_ref3 = _i.value;
case 14:
item = _ref2;
item = _ref3;
_context.next = 17;

@@ -129,4 +129,4 @@ return item;

return function getAllAnnotationsFromCollection(_x4) {
return _ref.apply(this, arguments);
return function getAllAnnotationsFromCollection(_x5) {
return _ref2.apply(this, arguments);
};

@@ -136,4 +136,4 @@ }();

var fetchPageCollection = function () {
var _ref3 = _asyncGenerator3.default.wrap( /*#__PURE__*/_regenerator2.default.mark(function _callee2(resource) {
var currentPage, _iterator2, _isArray2, _i2, _ref4, item;
var _ref4 = _asyncGenerator3.default.wrap( /*#__PURE__*/_regenerator2.default.mark(function _callee2(resource) {
var currentPage, _iterator2, _isArray2, _i2, _ref5, item;

@@ -171,3 +171,3 @@ return _regenerator2.default.wrap(function _callee2$(_context2) {

case 8:
_ref4 = _iterator2[_i2++];
_ref5 = _iterator2[_i2++];
_context2.next = 15;

@@ -187,6 +187,6 @@ break;

case 14:
_ref4 = _i2.value;
_ref5 = _i2.value;
case 15:
item = _ref4;
item = _ref5;
_context2.next = 18;

@@ -215,4 +215,4 @@ return item;

return function fetchPageCollection(_x5) {
return _ref3.apply(this, arguments);
return function fetchPageCollection(_x6) {
return _ref4.apply(this, arguments);
};

@@ -252,2 +252,5 @@ }();

var _ref = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : {},
withoutCredentials = _ref.withoutCredentials;
return fetch(uri, {

@@ -257,3 +260,3 @@ method: method,

body: JSON.stringify(body),
credentials: process.env.NODE_ENV === 'production' ? 'include' : null,
credentials: withoutCredentials ? null : process.env.NODE_ENV === 'production' ? 'include' : null,
cache: process.env.NODE_ENV === 'production' ? 'default' : 'force-cache',

@@ -273,3 +276,8 @@ redirect: 'follow'

function get(uri, body) {
return makeRequest('GET', uri, body);
try {
return makeRequest('GET', uri, body);
} catch (e) {
console.warn('Request failed, trying again without credentials', e);
return makeRequest('GET', uri, body, { withoutCredentials: true });
}
}

@@ -280,3 +288,8 @@

return makeRequest('POST', uri, body, headers);
try {
return makeRequest('POST', uri, body);
} catch (e) {
console.warn('Request failed, trying again without credentials', e);
return makeRequest('POST', uri, body, { withoutCredentials: true });
}
}

@@ -287,3 +300,8 @@

return makeRequest('PUT', uri, body, headers);
try {
return makeRequest('PUT', uri, body);
} catch (e) {
console.warn('Request failed, trying again without credentials', e);
return makeRequest('PUT', uri, body, { withoutCredentials: true });
}
}

@@ -290,0 +308,0 @@

@@ -16,3 +16,5 @@ {

"editor.next": "Nesaf",
"editor.save": "Arbed",
"editor.save_in_progress": "Save work as in progress",
"resourceNavigation.defaultTitle": "What do you want to tag (Default title)"
}
}

@@ -17,3 +17,5 @@ {

"editor.next": "Next",
"editor.save": "Save",
"editor.save_in_progress": "Save work as in progress",
"resourceNavigation.defaultTitle": "What do you want to tag"
}
{
"name": "@annotation-studio/redux",
"version": "1.0.0-next.5a1be109",
"version": "1.0.0-next.5f131126",
"description": "Describe annotation-redux here",
"main": "es/index.js",
"main": "lib/index.js",
"module": "es/index.js",

@@ -13,4 +13,5 @@ "files": [

"scripts": {
"watch": "./bin/watch",
"watch": "nwb-watch-module",
"build": "nwb build-web-module --copy-files",
"build-quick": "nwb build-web-module --copy-files",
"clean": "nwb clean-module",

@@ -20,3 +21,3 @@ "test": "NODE_ENV=test jest",

"test:watch": "npm run test -- --watch",
"prepublish": "npm run build"
"prepublish": "NODE_ENV=production npm run build"
},

@@ -26,4 +27,2 @@ "dependencies": {

"immutability-helper": "^2.1.2",
"react-intl": "^2.4.0",
"react-intl-redux": "^0.7.0",
"react-redux": "^5.0.3",

@@ -38,7 +37,7 @@ "redux": "^3.6.0",

"peerDependencies": {
"react-intl": "^2.2.2",
"react-intl": "^2.4.0",
"react-intl-redux": "^0.7.0"
},
"devDependencies": {
"@fesk/test-environment": "^1.0.0-next.5a1be109",
"@fesk/test-environment": "^1.0.0-next.5f131126",
"babel-jest": "^20.0.3",

@@ -48,6 +47,10 @@ "babel-plugin-transform-async-to-generator": "^6.24.1",

"babel-plugin-transform-regenerator": "^6.24.1",
"create-nwb-webpack-config": "^1.0.0",
"cross-spawn": "^6.0.5",
"jest": "^20.0.0",
"nwb": "^0.21.5",
"nwb-watch": "^1.0.0-next.5f131126",
"react-intl": "^2.2.2",
"react-intl-redux": "^0.7.0"
"react-intl-redux": "^0.7.0",
"webpack-cli": "^2.0.11"
},

@@ -54,0 +57,0 @@ "publishConfig": {

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