@jbrowse/plugin-rdf 2.17.0 → 3.0.0

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.
@@ -1,10 +1,11 @@
1
- import { BaseFeatureDataAdapter, BaseOptions } from '@jbrowse/core/data_adapters/BaseAdapter';
2
- import { NoAssemblyRegion } from '@jbrowse/core/util/types';
3
- import { Feature } from '@jbrowse/core/util/simpleFeature';
4
- import { Instance } from 'mobx-state-tree';
5
- import PluginManager from '@jbrowse/core/PluginManager';
6
- import { getSubAdapterType } from '@jbrowse/core/data_adapters/dataAdapterCache';
1
+ import { BaseFeatureDataAdapter } from '@jbrowse/core/data_adapters/BaseAdapter';
7
2
  import type MyConfigSchema from './configSchema';
3
+ import type PluginManager from '@jbrowse/core/PluginManager';
4
+ import type { BaseOptions } from '@jbrowse/core/data_adapters/BaseAdapter';
5
+ import type { getSubAdapterType } from '@jbrowse/core/data_adapters/dataAdapterCache';
6
+ import type { Feature } from '@jbrowse/core/util/simpleFeature';
7
+ import type { NoAssemblyRegion } from '@jbrowse/core/util/types';
8
+ import type { Instance } from 'mobx-state-tree';
8
9
  export default class SPARQLAdapter extends BaseFeatureDataAdapter {
9
10
  private endpoint;
10
11
  private queryTemplate;
@@ -3,11 +3,11 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
+ const configuration_1 = require("@jbrowse/core/configuration");
6
7
  const BaseAdapter_1 = require("@jbrowse/core/data_adapters/BaseAdapter");
7
8
  const rxjs_1 = require("@jbrowse/core/util/rxjs");
8
9
  const simpleFeature_1 = __importDefault(require("@jbrowse/core/util/simpleFeature"));
9
10
  const string_template_1 = __importDefault(require("string-template"));
10
- const configuration_1 = require("@jbrowse/core/configuration");
11
11
  class SPARQLAdapter extends BaseAdapter_1.BaseFeatureDataAdapter {
12
12
  constructor(config, getSubAdapter, pluginManager) {
13
13
  super(config, getSubAdapter, pluginManager);
@@ -17,7 +17,7 @@ class SPARQLAdapter extends BaseAdapter_1.BaseFeatureDataAdapter {
17
17
  this.refNamesQueryTemplate = (0, configuration_1.readConfObject)(config, 'refNamesQueryTemplate');
18
18
  this.configRefNames = (0, configuration_1.readConfObject)(config, 'refNames');
19
19
  }
20
- async getRefNames(opts = {}) {
20
+ async getRefNames(opts) {
21
21
  if (this.refNames) {
22
22
  return this.refNames;
23
23
  }
@@ -36,21 +36,23 @@ class SPARQLAdapter extends BaseAdapter_1.BaseFeatureDataAdapter {
36
36
  const filledTemplate = encodeURIComponent((0, string_template_1.default)(this.queryTemplate, query));
37
37
  const { refName } = query;
38
38
  const results = await this.querySparql(filledTemplate, opts);
39
- this.resultsToFeatures(results, refName).forEach(feature => {
39
+ const features = this.resultsToFeatures(results, refName);
40
+ for (const feature of features) {
40
41
  observer.next(feature);
41
- });
42
+ }
42
43
  observer.complete();
43
- }, opts.signal);
44
+ }, opts.stopToken);
44
45
  }
45
- async querySparql(query, opts) {
46
+ async querySparql(query, _opts) {
46
47
  let additionalQueryParams = '';
47
48
  if (this.additionalQueryParams.length) {
48
49
  additionalQueryParams = `&${this.additionalQueryParams.join('&')}`;
49
50
  }
50
- const signal = opts === null || opts === void 0 ? void 0 : opts.signal;
51
- const response = await fetch(`${this.endpoint}?query=${query}${additionalQueryParams}`, {
52
- headers: { accept: 'application/json,application/sparql-results+json' },
53
- signal,
51
+ const url = `${this.endpoint}?query=${query}${additionalQueryParams}`;
52
+ const response = await fetch(url, {
53
+ headers: {
54
+ accept: 'application/json,application/sparql-results+json',
55
+ },
54
56
  });
55
57
  return response.json();
56
58
  }
@@ -105,7 +107,6 @@ class SPARQLAdapter extends BaseAdapter_1.BaseFeatureDataAdapter {
105
107
  };
106
108
  });
107
109
  });
108
- // resolve subfeatures, keeping only top-level features in seenFeatures
109
110
  for (const [uniqueId, f] of Object.entries(seenFeatures)) {
110
111
  const pid = f.data.parentUniqueId;
111
112
  f.data.parentUniqueId = undefined;
@@ -163,6 +164,6 @@ class SPARQLAdapter extends BaseAdapter_1.BaseFeatureDataAdapter {
163
164
  }
164
165
  return true;
165
166
  }
166
- freeResources( /* { region } */) { }
167
+ freeResources() { }
167
168
  }
168
169
  exports.default = SPARQLAdapter;
@@ -1,2 +1,2 @@
1
- export { default as AdapterClass } from './SPARQLAdapter';
2
- export { default as configSchema } from './configSchema';
1
+ import type PluginManager from '@jbrowse/core/PluginManager';
2
+ export default function SPARQLAdapterF(pluginManager: PluginManager): void;
@@ -1,10 +1,52 @@
1
1
  "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
2
35
  var __importDefault = (this && this.__importDefault) || function (mod) {
3
36
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
37
  };
5
38
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.configSchema = exports.AdapterClass = void 0;
7
- var SPARQLAdapter_1 = require("./SPARQLAdapter");
8
- Object.defineProperty(exports, "AdapterClass", { enumerable: true, get: function () { return __importDefault(SPARQLAdapter_1).default; } });
9
- var configSchema_1 = require("./configSchema");
10
- Object.defineProperty(exports, "configSchema", { enumerable: true, get: function () { return __importDefault(configSchema_1).default; } });
39
+ exports.default = SPARQLAdapterF;
40
+ const pluggableElementTypes_1 = require("@jbrowse/core/pluggableElementTypes");
41
+ const configSchema_1 = __importDefault(require("./configSchema"));
42
+ function SPARQLAdapterF(pluginManager) {
43
+ pluginManager.addAdapterType(() => new pluggableElementTypes_1.AdapterType({
44
+ name: 'SPARQLAdapter',
45
+ displayName: 'SPARQL adapter',
46
+ configSchema: configSchema_1.default,
47
+ adapterMetadata: {
48
+ category: 'Uncommon',
49
+ },
50
+ getAdapterClass: () => Promise.resolve().then(() => __importStar(require('./SPARQLAdapter'))).then(r => r.default),
51
+ }));
52
+ }
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import Plugin from '@jbrowse/core/Plugin';
2
- import PluginManager from '@jbrowse/core/PluginManager';
2
+ import type PluginManager from '@jbrowse/core/PluginManager';
3
3
  export default class RdfPlugin extends Plugin {
4
4
  name: string;
5
5
  install(pluginManager: PluginManager): void;
package/dist/index.js CHANGED
@@ -3,22 +3,16 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- const AdapterType_1 = __importDefault(require("@jbrowse/core/pluggableElementTypes/AdapterType"));
7
6
  const Plugin_1 = __importDefault(require("@jbrowse/core/Plugin"));
8
- const SPARQLAdapter_1 = require("./SPARQLAdapter");
9
7
  const tracks_1 = require("@jbrowse/core/util/tracks");
8
+ const SPARQLAdapter_1 = __importDefault(require("./SPARQLAdapter"));
10
9
  class RdfPlugin extends Plugin_1.default {
11
10
  constructor() {
12
11
  super(...arguments);
13
12
  this.name = 'RdfPlugin';
14
13
  }
15
14
  install(pluginManager) {
16
- pluginManager.addAdapterType(() => new AdapterType_1.default({
17
- name: 'SPARQLAdapter',
18
- displayName: 'SPARQL adapter',
19
- configSchema: SPARQLAdapter_1.configSchema,
20
- AdapterClass: SPARQLAdapter_1.AdapterClass,
21
- }));
15
+ (0, SPARQLAdapter_1.default)(pluginManager);
22
16
  pluginManager.addToExtensionPoint('Core-guessAdapterForLocation', (adapterGuesser) => {
23
17
  return (file, index, adapterHint) => {
24
18
  const regexGuess = /\/sparql$/i;
@@ -1,10 +1,11 @@
1
- import { BaseFeatureDataAdapter, BaseOptions } from '@jbrowse/core/data_adapters/BaseAdapter';
2
- import { NoAssemblyRegion } from '@jbrowse/core/util/types';
3
- import { Feature } from '@jbrowse/core/util/simpleFeature';
4
- import { Instance } from 'mobx-state-tree';
5
- import PluginManager from '@jbrowse/core/PluginManager';
6
- import { getSubAdapterType } from '@jbrowse/core/data_adapters/dataAdapterCache';
1
+ import { BaseFeatureDataAdapter } from '@jbrowse/core/data_adapters/BaseAdapter';
7
2
  import type MyConfigSchema from './configSchema';
3
+ import type PluginManager from '@jbrowse/core/PluginManager';
4
+ import type { BaseOptions } from '@jbrowse/core/data_adapters/BaseAdapter';
5
+ import type { getSubAdapterType } from '@jbrowse/core/data_adapters/dataAdapterCache';
6
+ import type { Feature } from '@jbrowse/core/util/simpleFeature';
7
+ import type { NoAssemblyRegion } from '@jbrowse/core/util/types';
8
+ import type { Instance } from 'mobx-state-tree';
8
9
  export default class SPARQLAdapter extends BaseFeatureDataAdapter {
9
10
  private endpoint;
10
11
  private queryTemplate;
@@ -1,8 +1,8 @@
1
- import { BaseFeatureDataAdapter, } from '@jbrowse/core/data_adapters/BaseAdapter';
1
+ import { readConfObject } from '@jbrowse/core/configuration';
2
+ import { BaseFeatureDataAdapter } from '@jbrowse/core/data_adapters/BaseAdapter';
2
3
  import { ObservableCreate } from '@jbrowse/core/util/rxjs';
3
4
  import SimpleFeature from '@jbrowse/core/util/simpleFeature';
4
5
  import format from 'string-template';
5
- import { readConfObject } from '@jbrowse/core/configuration';
6
6
  export default class SPARQLAdapter extends BaseFeatureDataAdapter {
7
7
  constructor(config, getSubAdapter, pluginManager) {
8
8
  super(config, getSubAdapter, pluginManager);
@@ -12,7 +12,7 @@ export default class SPARQLAdapter extends BaseFeatureDataAdapter {
12
12
  this.refNamesQueryTemplate = readConfObject(config, 'refNamesQueryTemplate');
13
13
  this.configRefNames = readConfObject(config, 'refNames');
14
14
  }
15
- async getRefNames(opts = {}) {
15
+ async getRefNames(opts) {
16
16
  if (this.refNames) {
17
17
  return this.refNames;
18
18
  }
@@ -31,21 +31,23 @@ export default class SPARQLAdapter extends BaseFeatureDataAdapter {
31
31
  const filledTemplate = encodeURIComponent(format(this.queryTemplate, query));
32
32
  const { refName } = query;
33
33
  const results = await this.querySparql(filledTemplate, opts);
34
- this.resultsToFeatures(results, refName).forEach(feature => {
34
+ const features = this.resultsToFeatures(results, refName);
35
+ for (const feature of features) {
35
36
  observer.next(feature);
36
- });
37
+ }
37
38
  observer.complete();
38
- }, opts.signal);
39
+ }, opts.stopToken);
39
40
  }
40
- async querySparql(query, opts) {
41
+ async querySparql(query, _opts) {
41
42
  let additionalQueryParams = '';
42
43
  if (this.additionalQueryParams.length) {
43
44
  additionalQueryParams = `&${this.additionalQueryParams.join('&')}`;
44
45
  }
45
- const signal = opts === null || opts === void 0 ? void 0 : opts.signal;
46
- const response = await fetch(`${this.endpoint}?query=${query}${additionalQueryParams}`, {
47
- headers: { accept: 'application/json,application/sparql-results+json' },
48
- signal,
46
+ const url = `${this.endpoint}?query=${query}${additionalQueryParams}`;
47
+ const response = await fetch(url, {
48
+ headers: {
49
+ accept: 'application/json,application/sparql-results+json',
50
+ },
49
51
  });
50
52
  return response.json();
51
53
  }
@@ -100,7 +102,6 @@ export default class SPARQLAdapter extends BaseFeatureDataAdapter {
100
102
  };
101
103
  });
102
104
  });
103
- // resolve subfeatures, keeping only top-level features in seenFeatures
104
105
  for (const [uniqueId, f] of Object.entries(seenFeatures)) {
105
106
  const pid = f.data.parentUniqueId;
106
107
  f.data.parentUniqueId = undefined;
@@ -158,5 +159,5 @@ export default class SPARQLAdapter extends BaseFeatureDataAdapter {
158
159
  }
159
160
  return true;
160
161
  }
161
- freeResources( /* { region } */) { }
162
+ freeResources() { }
162
163
  }
@@ -1,2 +1,2 @@
1
- export { default as AdapterClass } from './SPARQLAdapter';
2
- export { default as configSchema } from './configSchema';
1
+ import type PluginManager from '@jbrowse/core/PluginManager';
2
+ export default function SPARQLAdapterF(pluginManager: PluginManager): void;
@@ -1,2 +1,13 @@
1
- export { default as AdapterClass } from './SPARQLAdapter';
2
- export { default as configSchema } from './configSchema';
1
+ import { AdapterType } from '@jbrowse/core/pluggableElementTypes';
2
+ import configSchema from './configSchema';
3
+ export default function SPARQLAdapterF(pluginManager) {
4
+ pluginManager.addAdapterType(() => new AdapterType({
5
+ name: 'SPARQLAdapter',
6
+ displayName: 'SPARQL adapter',
7
+ configSchema,
8
+ adapterMetadata: {
9
+ category: 'Uncommon',
10
+ },
11
+ getAdapterClass: () => import('./SPARQLAdapter').then(r => r.default),
12
+ }));
13
+ }
package/esm/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import Plugin from '@jbrowse/core/Plugin';
2
- import PluginManager from '@jbrowse/core/PluginManager';
2
+ import type PluginManager from '@jbrowse/core/PluginManager';
3
3
  export default class RdfPlugin extends Plugin {
4
4
  name: string;
5
5
  install(pluginManager: PluginManager): void;
package/esm/index.js CHANGED
@@ -1,19 +1,13 @@
1
- import AdapterType from '@jbrowse/core/pluggableElementTypes/AdapterType';
2
1
  import Plugin from '@jbrowse/core/Plugin';
3
- import { AdapterClass as SPARQLAdapterClass, configSchema as sparqlAdapterConfigSchema, } from './SPARQLAdapter';
4
2
  import { getFileName } from '@jbrowse/core/util/tracks';
3
+ import SPARQLAdapterF from './SPARQLAdapter';
5
4
  export default class RdfPlugin extends Plugin {
6
5
  constructor() {
7
6
  super(...arguments);
8
7
  this.name = 'RdfPlugin';
9
8
  }
10
9
  install(pluginManager) {
11
- pluginManager.addAdapterType(() => new AdapterType({
12
- name: 'SPARQLAdapter',
13
- displayName: 'SPARQL adapter',
14
- configSchema: sparqlAdapterConfigSchema,
15
- AdapterClass: SPARQLAdapterClass,
16
- }));
10
+ SPARQLAdapterF(pluginManager);
17
11
  pluginManager.addToExtensionPoint('Core-guessAdapterForLocation', (adapterGuesser) => {
18
12
  return (file, index, adapterHint) => {
19
13
  const regexGuess = /\/sparql$/i;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jbrowse/plugin-rdf",
3
- "version": "2.17.0",
3
+ "version": "3.0.0",
4
4
  "description": "JBrowse 2 RDF resources",
5
5
  "keywords": [
6
6
  "jbrowse",
@@ -51,5 +51,5 @@
51
51
  "publishConfig": {
52
52
  "access": "public"
53
53
  },
54
- "gitHead": "eed30b5e671f8f7823652d7cecc51aa89226de46"
54
+ "gitHead": "2c6897f1fa732b1db5b094d1dca197e333e95319"
55
55
  }