Comparing version 0.1.9 to 0.1.10
@@ -123,9 +123,65 @@ /** | ||
// latter part of id has context | ||
if (h_context[m_prefix[2]]) { | ||
z_context = h_context[m_prefix[2]]; | ||
// first part of id has primary context | ||
if (h_context[m_prefix[1]]) { | ||
// ref primary context | ||
var z_primary_context = h_context[m_prefix[1]]; | ||
// primary context is only a prefix | ||
if ('string' === typeof z_primary_context) { | ||
// try to resolve secondary context too | ||
var h_secondary_context = h_context[m_prefix[2]]; | ||
// secondary context should be json-ld context | ||
if ('object' !== typeof h_secondary_context) { | ||
local.fail('expected secondary context name "' + m_prefix[2] + '" from "' + s_name + '" to be json-ld object; instead got: ' + (0, _arginfo2['default'])(h_secondary_context)); | ||
} | ||
// clone secondary context | ||
var h_local_context = { | ||
id: h_secondary_context['@id'], | ||
type: h_secondary_context['@type'] | ||
}; | ||
// if it does not have an id, append the latter part of the name to primary prefix | ||
h_local_context.id = z_primary_context + m_prefix[2]; | ||
// return that context hash | ||
return h_local_context; | ||
} | ||
// primary context is a json-ld context | ||
else { | ||
// primary context is missing an id | ||
if (!z_primary_context['@id']) { | ||
local.fail('json-ld context node is missing \'@id\' property at context name "' + m_prefix[1] + '": ' + (0, _arginfo2['default'])(z_primary_context)); | ||
} | ||
// ref primary context id | ||
var s_primary_context_id = z_primary_context['@id']; | ||
// secondary context is directly available | ||
if (h_context[s_primary_context_id + m_prefix[2]]) { | ||
// just use that | ||
z_context = h_context[s_primary_context_id + m_prefix[2]]; | ||
} | ||
// secondary context not available | ||
else { | ||
// use the primary context node | ||
var h_local_context = (0, _clone2['default'])(h_context[s_primary_context_id], true); | ||
// extend its id with the latter part of the name | ||
h_local_context.id += m_prefix[2]; | ||
// return that context hash | ||
return h_local_context; | ||
} | ||
} | ||
} | ||
// at least we tried... | ||
else { | ||
local.fail('failed to resolve context of "' + s_name + '"'); | ||
local.fail('failed to resolve primary context of name: "' + m_prefix[1] + '" from "' + s_name + '"'); | ||
} | ||
@@ -135,3 +191,3 @@ } | ||
else { | ||
local.fail('failed to resolve context of "' + s_name + '"'); | ||
local.fail('failed to resolve context of non-prefixed name: "' + s_name + '"'); | ||
} | ||
@@ -753,5 +809,9 @@ } | ||
// skip context node, for now | ||
// skip context node, for now... | ||
if ('@context' === s_key) { | ||
local.warn('@context is currently unsupported on json-ld nodes; ignorning context on this node'); | ||
// only warn about non-global context nodes | ||
if (h_node !== h_jsonld) { | ||
local.warn('@context is currently unsupported on nested json-ld nodes; ignorning context on this node'); | ||
} | ||
continue; | ||
@@ -934,3 +994,3 @@ } | ||
// map each node to network node | ||
// construct list of networked top-level nodes | ||
var a_nodes = (function () { | ||
@@ -937,0 +997,0 @@ |
{ | ||
"name": "graphy", | ||
"version": "0.1.9", | ||
"version": "0.1.10", | ||
"description": "Query linked-data graphs by abstracting away traditional JSON-LD interaction", | ||
@@ -5,0 +5,0 @@ "author": { |
34452
896