@abi-software/map-utilities 1.6.1-beta.3 → 1.6.1-beta.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
+
* @private
|
|
2
3
|
* Competency Queries
|
|
3
4
|
*
|
|
4
5
|
* competencyQuery: base function
|
|
@@ -6,8 +7,7 @@
|
|
|
6
7
|
*
|
|
7
8
|
* Note: use named-export for better tree-shaking.
|
|
8
9
|
*/
|
|
9
|
-
|
|
10
|
-
async function postRequest(API_URL, payload) {
|
|
10
|
+
async function _postRequest(API_URL, payload) {
|
|
11
11
|
try {
|
|
12
12
|
const response = await fetch(API_URL, {
|
|
13
13
|
method: "POST",
|
|
@@ -30,7 +30,7 @@ async function postRequest(API_URL, payload) {
|
|
|
30
30
|
|
|
31
31
|
/**
|
|
32
32
|
* Competency Query
|
|
33
|
-
*
|
|
33
|
+
* @public
|
|
34
34
|
* @param {Object} options - Query options.
|
|
35
35
|
* @param {string} options.flatmapAPI - Base URL of the flatmap server.
|
|
36
36
|
* @param {string} options.knowledgeSource - SCKAN source ID.
|
|
@@ -69,36 +69,54 @@ async function competencyQuery(options) {
|
|
|
69
69
|
payload.order = [orderId];
|
|
70
70
|
}
|
|
71
71
|
|
|
72
|
-
return
|
|
72
|
+
return _postRequest(API_URL, payload);
|
|
73
73
|
}
|
|
74
74
|
|
|
75
|
+
/**
|
|
76
|
+
* @public
|
|
77
|
+
* @param {*} flatmapAPI
|
|
78
|
+
* @param {*} knowledgeSource
|
|
79
|
+
* @param {*} featureId
|
|
80
|
+
* @returns
|
|
81
|
+
*/
|
|
75
82
|
// Neuron populations associated with a location [query id => 1] (or)
|
|
76
83
|
// Neuron populations that share at least one edge with another neuron population [query id => 23]
|
|
77
84
|
async function queryAllConnectedPaths(flatmapAPI, knowledgeSource, featureId) {
|
|
78
85
|
const featureIds = Array.isArray(featureId) ? featureId : [featureId];
|
|
79
|
-
const
|
|
86
|
+
const isPath = featureIds[0].startsWith('ilxtr:');
|
|
87
|
+
const queryId = isPath ? 23 : 1;
|
|
88
|
+
const columnId = isPath ? 'path_id' : 'feature_id';
|
|
89
|
+
const originalPaths = isPath ? featureIds : [];
|
|
80
90
|
const data = await competencyQuery({
|
|
81
91
|
flatmapAPI: flatmapAPI,
|
|
82
92
|
knowledgeSource: knowledgeSource,
|
|
83
93
|
queryId: queryId,
|
|
84
94
|
parameters: [
|
|
85
95
|
{
|
|
86
|
-
column:
|
|
96
|
+
column: columnId,
|
|
87
97
|
value: featureIds
|
|
88
98
|
},
|
|
89
99
|
]
|
|
90
100
|
});
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
101
|
+
|
|
102
|
+
// value => [ 'source_id', 'path_id', 'axon_terminal']
|
|
103
|
+
const paths = data?.results?.values?.map(value => value[1]) || [];
|
|
104
|
+
const combined = [...new Set([...originalPaths, ...paths])];
|
|
105
|
+
|
|
106
|
+
// Continue to forward and backward connections
|
|
107
|
+
const additionalPaths = await queryForwardBackwardConnections(flatmapAPI, knowledgeSource, combined);
|
|
108
|
+
const total = [...new Set([...combined, ...additionalPaths])];
|
|
109
|
+
|
|
110
|
+
return total;
|
|
100
111
|
}
|
|
101
112
|
|
|
113
|
+
/**
|
|
114
|
+
* @public
|
|
115
|
+
* @param {*} flatmapAPI
|
|
116
|
+
* @param {*} knowledgeSource
|
|
117
|
+
* @param {*} featureId
|
|
118
|
+
* @returns
|
|
119
|
+
*/
|
|
102
120
|
// Neuron populations beginning at a location
|
|
103
121
|
async function queryPathsByOrigin(flatmapAPI, knowledgeSource, featureId) {
|
|
104
122
|
const data = await competencyQuery({
|
|
@@ -123,6 +141,13 @@ async function queryPathsByOrigin(flatmapAPI, knowledgeSource, featureId) {
|
|
|
123
141
|
return [];
|
|
124
142
|
}
|
|
125
143
|
|
|
144
|
+
/**
|
|
145
|
+
* @public
|
|
146
|
+
* @param {*} flatmapAPI
|
|
147
|
+
* @param {*} knowledgeSource
|
|
148
|
+
* @param {*} featureId
|
|
149
|
+
* @returns
|
|
150
|
+
*/
|
|
126
151
|
// Neuron populations via a location
|
|
127
152
|
async function queryPathsByViaLocation(flatmapAPI, knowledgeSource, featureId) {
|
|
128
153
|
const data = await competencyQuery({
|
|
@@ -147,6 +172,13 @@ async function queryPathsByViaLocation(flatmapAPI, knowledgeSource, featureId) {
|
|
|
147
172
|
return [];
|
|
148
173
|
}
|
|
149
174
|
|
|
175
|
+
/**
|
|
176
|
+
* @public
|
|
177
|
+
* @param {*} flatmapAPI
|
|
178
|
+
* @param {*} knowledgeSource
|
|
179
|
+
* @param {*} featureId
|
|
180
|
+
* @returns
|
|
181
|
+
*/
|
|
150
182
|
// Neuron populations terminating at a location
|
|
151
183
|
async function queryPathsByDestination(flatmapAPI, knowledgeSource, featureId) {
|
|
152
184
|
const data = await competencyQuery({
|
|
@@ -171,7 +203,12 @@ async function queryPathsByDestination(flatmapAPI, knowledgeSource, featureId) {
|
|
|
171
203
|
return [];
|
|
172
204
|
}
|
|
173
205
|
|
|
174
|
-
|
|
206
|
+
/**
|
|
207
|
+
* @private
|
|
208
|
+
* @param {*} inputArray
|
|
209
|
+
* @returns
|
|
210
|
+
*/
|
|
211
|
+
function _extractFeatureIds(inputArray) {
|
|
175
212
|
const result = [];
|
|
176
213
|
|
|
177
214
|
for (const itemString of inputArray) {
|
|
@@ -186,6 +223,13 @@ function extractFeatureIds(inputArray) {
|
|
|
186
223
|
return result;
|
|
187
224
|
}
|
|
188
225
|
|
|
226
|
+
/**
|
|
227
|
+
* @public
|
|
228
|
+
* @param {*} flatmapAPI
|
|
229
|
+
* @param {*} knowledgeSource
|
|
230
|
+
* @param {*} pathIds
|
|
231
|
+
* @returns
|
|
232
|
+
*/
|
|
189
233
|
// Neuron populations as forward or backward connections of a neuron population
|
|
190
234
|
async function queryForwardBackwardConnections(flatmapAPI, knowledgeSource, pathIds) {
|
|
191
235
|
const data = await competencyQuery({
|
|
@@ -211,13 +255,18 @@ async function queryForwardBackwardConnections(flatmapAPI, knowledgeSource, path
|
|
|
211
255
|
return [];
|
|
212
256
|
}
|
|
213
257
|
|
|
258
|
+
/**
|
|
259
|
+
* @public
|
|
260
|
+
* @param {*} options
|
|
261
|
+
* @returns
|
|
262
|
+
*/
|
|
214
263
|
// Neuron populations from origin to destination, via
|
|
215
264
|
// Query 24: Neuron populations that have source, via, and destination nodes
|
|
216
265
|
// Query 25: Neuron populations that have source, via, and destination locations
|
|
217
266
|
async function queryPathsByRoute({ flatmapAPI, knowledgeSource, origins, destinations, vias }) {
|
|
218
|
-
const originFeatureIds =
|
|
219
|
-
const destinationFeatureIds =
|
|
220
|
-
const viaFeatureIds =
|
|
267
|
+
const originFeatureIds = _extractFeatureIds(origins);
|
|
268
|
+
const destinationFeatureIds = _extractFeatureIds(destinations);
|
|
269
|
+
const viaFeatureIds = _extractFeatureIds(vias);
|
|
221
270
|
|
|
222
271
|
const paramsF = [
|
|
223
272
|
{
|
|
@@ -98,7 +98,7 @@ const CITATION_OPTIONS = [
|
|
|
98
98
|
},
|
|
99
99
|
{
|
|
100
100
|
label: 'Chicago',
|
|
101
|
-
value: 'chicago-
|
|
101
|
+
value: 'chicago-author-date',
|
|
102
102
|
},
|
|
103
103
|
{
|
|
104
104
|
label: 'IEEE',
|
|
@@ -405,7 +405,7 @@ export default {
|
|
|
405
405
|
return citation && !citation[this.citationType] && !citation.error;
|
|
406
406
|
},
|
|
407
407
|
isCitationError: function (citation) {
|
|
408
|
-
return citation && citation.error;
|
|
408
|
+
return citation && citation.error && citation.error.type === this.citationType;
|
|
409
409
|
},
|
|
410
410
|
updateCopyContents: function () {
|
|
411
411
|
const citationTypeObj = this.citationOptions.find((item) => item.value === this.citationType);
|