cocoda-sdk 1.0.13 → 2.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.
Files changed (36) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +74 -28
  3. package/dist/cjs/index.cjs +2673 -0
  4. package/dist/cocoda-sdk.js +33 -17423
  5. package/dist/cocoda-sdk.js.LICENSES.txt +105 -86
  6. package/dist/cocoda-sdk.js.map +7 -0
  7. package/dist/esm/errors/index.js +46 -0
  8. package/dist/esm/index.js +9 -0
  9. package/dist/esm/lib/CocodaSDK.js +269 -0
  10. package/dist/esm/providers/base-provider.js +368 -0
  11. package/dist/esm/providers/concept-api-provider.js +278 -0
  12. package/dist/esm/providers/index.js +20 -0
  13. package/dist/esm/providers/label-search-suggestion-provider.js +101 -0
  14. package/dist/esm/providers/loc-api-provider.js +185 -0
  15. package/dist/esm/providers/local-mappings-provider.js +337 -0
  16. package/dist/esm/providers/mappings-api-provider.js +264 -0
  17. package/dist/esm/providers/occurrences-api-provider.js +163 -0
  18. package/dist/esm/providers/reconciliation-api-provider.js +140 -0
  19. package/dist/esm/providers/skosmos-api-provider.js +345 -0
  20. package/{utils → dist/esm/utils}/index.js +40 -53
  21. package/dist/esm/utils/lodash.js +34 -0
  22. package/package.json +16 -17
  23. package/errors/index.js +0 -119
  24. package/index.js +0 -5
  25. package/lib/CocodaSDK.js +0 -360
  26. package/providers/base-provider.js +0 -581
  27. package/providers/concept-api-provider.js +0 -377
  28. package/providers/index.js +0 -34
  29. package/providers/label-search-suggestion-provider.js +0 -219
  30. package/providers/loc-api-provider.js +0 -275
  31. package/providers/local-mappings-provider.js +0 -459
  32. package/providers/mappings-api-provider.js +0 -396
  33. package/providers/occurrences-api-provider.js +0 -234
  34. package/providers/reconciliation-api-provider.js +0 -211
  35. package/providers/skosmos-api-provider.js +0 -441
  36. package/utils/lodash.js +0 -21
@@ -0,0 +1,337 @@
1
+ import BaseProvider from "./base-provider.js";
2
+ import jskos from "jskos-tools";
3
+ import * as _ from "../utils/lodash.js";
4
+ import localforage from "localforage";
5
+ import { v4 as uuid } from "uuid";
6
+ import * as errors from "../errors/index.js";
7
+ const uriPrefix = "urn:uuid:";
8
+ class LocalMappingsProvider extends BaseProvider {
9
+ _setup() {
10
+ this.has.mappings = {
11
+ read: true,
12
+ create: true,
13
+ update: true,
14
+ delete: true
15
+ };
16
+ this.queue = [];
17
+ this.localStorageKey = "cocoda-mappings--" + this._path;
18
+ let oldLocalStorageKey = "mappings";
19
+ let addUris = () => {
20
+ return localforage.getItem(this.localStorageKey).then((mappings) => {
21
+ mappings = mappings || [];
22
+ let adjusted = 0;
23
+ for (let mapping of mappings.filter((m) => !m.uri || !m.uri.startsWith(uriPrefix))) {
24
+ if (mapping.uri) {
25
+ if (!mapping.identifier) {
26
+ mapping.identifier = [];
27
+ }
28
+ mapping.identifier.push(mapping.uri);
29
+ }
30
+ mapping.uri = `${uriPrefix}${uuid()}`;
31
+ adjusted += 1;
32
+ }
33
+ if (adjusted) {
34
+ console.warn(`URIs added to ${adjusted} local mappings.`);
35
+ }
36
+ return localforage.setItem(this.localStorageKey, mappings);
37
+ });
38
+ };
39
+ localforage.getItem(oldLocalStorageKey).then((results) => {
40
+ if (results) {
41
+ console.warn(`Warning: There is old data in local storage (or IndexedDB, depending on the ) with the key "${oldLocalStorageKey}". This data will not be used anymore. A manual export is necessary to get this data back.`);
42
+ }
43
+ });
44
+ this.queue.push(addUris().catch((error) => {
45
+ console.warn("Error when adding URIs to local mappings:", error);
46
+ }));
47
+ }
48
+ isAuthorizedFor({ type, action }) {
49
+ if (type == "mappings" && action != "anonymous") {
50
+ return true;
51
+ }
52
+ return false;
53
+ }
54
+ _getMappingsQueue() {
55
+ let last = _.last(this.queue) || Promise.resolve();
56
+ return new Promise((resolve) => {
57
+ function defer() {
58
+ var res, rej;
59
+ var promise2 = new Promise((resolve2, reject) => {
60
+ res = resolve2;
61
+ rej = reject;
62
+ });
63
+ promise2.resolve = res;
64
+ promise2.reject = rej;
65
+ return promise2;
66
+ }
67
+ let promise = defer();
68
+ let done = () => {
69
+ promise.resolve();
70
+ };
71
+ this.queue.push(promise);
72
+ last.then(() => {
73
+ return localforage.getItem(this.localStorageKey);
74
+ }).then((mappings) => {
75
+ resolve({ mappings, done });
76
+ });
77
+ });
78
+ }
79
+ async getMapping({ mapping, ...config }) {
80
+ config._raw = true;
81
+ if (!mapping || !mapping.uri) {
82
+ throw new errors.InvalidOrMissingParameterError({ parameter: "mapping" });
83
+ }
84
+ return (await this.getMappings({ ...config, uri: mapping.uri }))[0];
85
+ }
86
+ async getMappings({ from, fromScheme, to, toScheme, creator, type, partOf, offset, limit, direction, mode, identifier, uri } = {}) {
87
+ let params = {};
88
+ if (from) {
89
+ params.from = _.isString(from) ? from : from.uri;
90
+ }
91
+ if (fromScheme) {
92
+ params.fromScheme = _.isString(fromScheme) ? { uri: fromScheme } : fromScheme;
93
+ }
94
+ if (to) {
95
+ params.to = _.isString(to) ? to : to.uri;
96
+ }
97
+ if (toScheme) {
98
+ params.toScheme = _.isString(toScheme) ? { uri: toScheme } : toScheme;
99
+ }
100
+ if (creator) {
101
+ params.creator = _.isString(creator) ? creator : jskos.prefLabel(creator);
102
+ }
103
+ if (type) {
104
+ params.type = _.isString(type) ? type : type.uri;
105
+ }
106
+ if (partOf) {
107
+ params.partOf = _.isString(partOf) ? partOf : partOf.uri;
108
+ }
109
+ if (offset) {
110
+ params.offset = offset;
111
+ }
112
+ if (limit) {
113
+ params.limit = limit;
114
+ }
115
+ if (direction) {
116
+ params.direction = direction;
117
+ }
118
+ if (mode) {
119
+ params.mode = mode;
120
+ }
121
+ if (identifier) {
122
+ params.identifier = identifier;
123
+ }
124
+ if (uri) {
125
+ params.uri = uri;
126
+ }
127
+ return this._getMappingsQueue().catch((relatedError) => {
128
+ throw new errors.CDKError({ message: "Could not get mappings from local storage", relatedError });
129
+ }).then(({ mappings, done }) => {
130
+ done();
131
+ let checkConcept = (concept, param) => concept.uri == param || param && concept.notation && concept.notation[0].toLowerCase() == param.toLowerCase();
132
+ if (params.from || params.to) {
133
+ mappings = mappings.filter((mapping) => {
134
+ let fromInFrom = jskos.conceptsOfMapping(mapping, "from").find((concept) => checkConcept(concept, params.from)) != null;
135
+ let fromInTo = jskos.conceptsOfMapping(mapping, "to").find((concept) => checkConcept(concept, params.from)) != null;
136
+ let toInFrom = jskos.conceptsOfMapping(mapping, "from").find((concept) => checkConcept(concept, params.to)) != null;
137
+ let toInTo = jskos.conceptsOfMapping(mapping, "to").find((concept) => checkConcept(concept, params.to)) != null;
138
+ if (params.direction == "backward") {
139
+ if (params.mode == "or") {
140
+ return params.from && fromInTo || params.to && toInFrom;
141
+ } else {
142
+ return (!params.from || fromInTo) && (!params.to || toInFrom);
143
+ }
144
+ } else if (params.direction == "both") {
145
+ if (params.mode == "or") {
146
+ return params.from && (fromInFrom || fromInTo) || params.to && (toInFrom || toInTo);
147
+ } else {
148
+ return (!params.from || fromInFrom) && (!params.to || toInTo) || (!params.from || fromInTo) && (!params.to || toInFrom);
149
+ }
150
+ } else {
151
+ if (params.mode == "or") {
152
+ return params.from && fromInFrom || params.to && toInTo;
153
+ } else {
154
+ return (!params.from || fromInFrom) && (!params.to || toInTo);
155
+ }
156
+ }
157
+ });
158
+ }
159
+ if (params.fromScheme || params.toScheme) {
160
+ mappings = mappings.filter((mapping) => {
161
+ let fromInFrom = jskos.compare(mapping.fromScheme, params.fromScheme);
162
+ let fromInTo = jskos.compare(mapping.toScheme, params.fromScheme);
163
+ let toInFrom = jskos.compare(mapping.fromScheme, params.toScheme);
164
+ let toInTo = jskos.compare(mapping.toScheme, params.toScheme);
165
+ if (params.direction == "backward") {
166
+ if (params.mode == "or") {
167
+ return params.fromScheme && fromInTo || params.toScheme && toInFrom;
168
+ } else {
169
+ return (!params.fromScheme || fromInTo) && (!params.toScheme || toInFrom);
170
+ }
171
+ } else if (params.direction == "both") {
172
+ if (params.mode == "or") {
173
+ return params.fromScheme && (fromInFrom || fromInTo) || params.toScheme && (toInFrom || toInTo);
174
+ } else {
175
+ return (!params.fromScheme || fromInFrom) && (!params.toScheme || toInTo) || (!params.fromScheme || fromInTo) && (!params.toScheme || toInFrom);
176
+ }
177
+ } else {
178
+ if (params.mode == "or") {
179
+ return params.fromScheme && fromInFrom || params.toScheme && toInTo;
180
+ } else {
181
+ return (!params.fromScheme || fromInFrom) && (!params.toScheme || toInTo);
182
+ }
183
+ }
184
+ });
185
+ }
186
+ if (params.creator) {
187
+ let creators = params.creator.split("|");
188
+ mappings = mappings.filter((mapping) => {
189
+ return (mapping.creator && mapping.creator.find((creator2) => creators.includes(jskos.prefLabel(creator2)) || creators.includes(creator2.uri))) != null;
190
+ });
191
+ }
192
+ if (params.type) {
193
+ mappings = mappings.filter((mapping) => (mapping.type || [jskos.defaultMappingType.uri]).includes(params.type));
194
+ }
195
+ if (params.partOf) {
196
+ mappings = mappings.filter((mapping) => {
197
+ return mapping.partOf != null && mapping.partOf.find((partOf2) => jskos.compare(partOf2, { uri: params.partOf })) != null;
198
+ });
199
+ }
200
+ if (params.identifier) {
201
+ mappings = mappings.filter((mapping) => {
202
+ return params.identifier.split("|").map((identifier2) => {
203
+ return (mapping.identifier || []).includes(identifier2) || mapping.uri == identifier2;
204
+ }).reduce((current, total) => current || total);
205
+ });
206
+ }
207
+ if (params.uri) {
208
+ mappings = mappings.filter((mapping) => mapping.uri == params.uri);
209
+ }
210
+ let totalCount = mappings.length;
211
+ mappings = mappings.sort((a, b) => {
212
+ let aDate = a.modified || a.created;
213
+ let bDate = b.modified || b.created;
214
+ if (bDate == null) {
215
+ return -1;
216
+ }
217
+ if (aDate == null) {
218
+ return 1;
219
+ }
220
+ if (aDate > bDate) {
221
+ return -1;
222
+ }
223
+ return 1;
224
+ });
225
+ mappings = mappings.slice(params.offset || 0);
226
+ mappings = mappings.slice(0, params.limit);
227
+ mappings._totalCount = totalCount;
228
+ return mappings;
229
+ });
230
+ }
231
+ async postMapping({ mapping }) {
232
+ if (!mapping) {
233
+ throw new errors.InvalidOrMissingParameterError({ parameter: "mapping" });
234
+ }
235
+ let { mappings: localMappings, done } = await this._getMappingsQueue();
236
+ if (!mapping.uri || !mapping.uri.startsWith(uriPrefix)) {
237
+ if (mapping.uri) {
238
+ if (!mapping.identifier) {
239
+ mapping.identifier = [];
240
+ }
241
+ mapping.identifier.push(mapping.uri);
242
+ }
243
+ mapping.uri = `${uriPrefix}${uuid()}`;
244
+ }
245
+ if (localMappings.find((m) => m.uri == mapping.uri)) {
246
+ done();
247
+ throw new errors.InvalidOrMissingParameterError({ parameter: "mapping", message: "Duplicate URI" });
248
+ }
249
+ if (!mapping.created) {
250
+ mapping.created = new Date().toISOString();
251
+ }
252
+ if (!mapping.modified) {
253
+ mapping.modified = mapping.created;
254
+ }
255
+ localMappings.push(mapping);
256
+ localMappings = localMappings.map((mapping2) => jskos.minifyMapping(mapping2));
257
+ try {
258
+ await localforage.setItem(this.localStorageKey, localMappings);
259
+ done();
260
+ return mapping;
261
+ } catch (error) {
262
+ done();
263
+ throw error;
264
+ }
265
+ }
266
+ async putMapping({ mapping }) {
267
+ if (!mapping) {
268
+ throw new errors.InvalidOrMissingParameterError({ parameter: "mapping" });
269
+ }
270
+ let { mappings: localMappings, done } = await this._getMappingsQueue();
271
+ const index = localMappings.findIndex((m) => m.uri == mapping.uri);
272
+ if (index == -1) {
273
+ done();
274
+ throw new errors.InvalidOrMissingParameterError({ parameter: "mapping", message: "Mapping not found" });
275
+ }
276
+ if (!mapping.created) {
277
+ mapping.created = localMappings[index].created;
278
+ }
279
+ mapping.modified = new Date().toISOString();
280
+ localMappings[index] = mapping;
281
+ localMappings = localMappings.map((mapping2) => jskos.minifyMapping(mapping2));
282
+ try {
283
+ await localforage.setItem(this.localStorageKey, localMappings);
284
+ done();
285
+ return mapping;
286
+ } catch (error) {
287
+ done();
288
+ throw error;
289
+ }
290
+ }
291
+ async patchMapping({ mapping }) {
292
+ if (!mapping) {
293
+ throw new errors.InvalidOrMissingParameterError({ parameter: "mapping" });
294
+ }
295
+ let { mappings: localMappings, done } = await this._getMappingsQueue();
296
+ const index = localMappings.findIndex((m) => m.uri == mapping.uri);
297
+ if (index == -1) {
298
+ done();
299
+ throw new errors.InvalidOrMissingParameterError({ parameter: "mapping", message: "Mapping not found" });
300
+ }
301
+ if (!mapping.created) {
302
+ mapping.created = localMappings[index].created;
303
+ }
304
+ mapping.modified = new Date().toISOString();
305
+ localMappings[index] = Object.assign(localMappings[index], mapping);
306
+ localMappings = localMappings.map((mapping2) => jskos.minifyMapping(mapping2));
307
+ try {
308
+ await localforage.setItem(this.localStorageKey, localMappings);
309
+ done();
310
+ return mapping;
311
+ } catch (error) {
312
+ done();
313
+ throw error;
314
+ }
315
+ }
316
+ async deleteMapping({ mapping }) {
317
+ if (!mapping) {
318
+ throw new errors.InvalidOrMissingParameterError({ parameter: "mapping" });
319
+ }
320
+ let { mappings: localMappings, done } = await this._getMappingsQueue();
321
+ try {
322
+ localMappings = localMappings.filter((m) => m.uri != mapping.uri);
323
+ localMappings = localMappings.map((mapping2) => jskos.minifyMapping(mapping2));
324
+ await localforage.setItem(this.localStorageKey, localMappings);
325
+ done();
326
+ return true;
327
+ } catch (error) {
328
+ done();
329
+ throw error;
330
+ }
331
+ }
332
+ }
333
+ LocalMappingsProvider.providerName = "LocalMappings";
334
+ LocalMappingsProvider.stored = true;
335
+ export {
336
+ LocalMappingsProvider as default
337
+ };
@@ -0,0 +1,264 @@
1
+ import BaseProvider from "./base-provider.js";
2
+ import jskos from "jskos-tools";
3
+ import * as _ from "../utils/lodash.js";
4
+ import * as errors from "../errors/index.js";
5
+ import * as utils from "../utils/index.js";
6
+ class MappingsApiProvider extends BaseProvider {
7
+ _prepare() {
8
+ if (this._api.api && this._api.status === void 0) {
9
+ this._api.status = utils.concatUrl(this._api.api, "/status");
10
+ }
11
+ }
12
+ _setup() {
13
+ if (this._api.api) {
14
+ const endpoints = {
15
+ mappings: "/mappings",
16
+ concordances: "/concordances",
17
+ annotations: "/annotations"
18
+ };
19
+ for (let key of Object.keys(endpoints)) {
20
+ if (this._api[key] === void 0) {
21
+ this._api[key] = utils.concatUrl(this._api.api, endpoints[key]);
22
+ }
23
+ }
24
+ }
25
+ this.has.mappings = this._api.mappings ? {} : false;
26
+ if (this.has.mappings) {
27
+ this.has.mappings.read = !!_.get(this._config, "mappings.read", true);
28
+ this.has.mappings.create = !!_.get(this._config, "mappings.create");
29
+ this.has.mappings.update = !!_.get(this._config, "mappings.update");
30
+ this.has.mappings.delete = !!_.get(this._config, "mappings.delete");
31
+ this.has.mappings.anonymous = !!_.get(this._config, "mappings.anonymous");
32
+ }
33
+ this.has.concordances = !!this._api.concordances;
34
+ this.has.annotations = this._api.annotations ? {} : false;
35
+ if (this.has.annotations) {
36
+ this.has.annotations.read = !!_.get(this._config, "annotations.read");
37
+ this.has.annotations.create = !!_.get(this._config, "annotations.create");
38
+ this.has.annotations.update = !!_.get(this._config, "annotations.update");
39
+ this.has.annotations.delete = !!_.get(this._config, "annotations.delete");
40
+ }
41
+ this.has.auth = _.get(this._config, "auth.key") != null;
42
+ this._defaultParams = {
43
+ properties: "annotations"
44
+ };
45
+ }
46
+ async getMapping({ mapping, ...config }) {
47
+ if (!mapping) {
48
+ throw new errors.InvalidOrMissingParameterError({ parameter: "mapping" });
49
+ }
50
+ if (!mapping.uri || !mapping.uri.startsWith(this._api.mappings)) {
51
+ throw new errors.InvalidOrMissingParameterError({ parameter: "mapping", message: "URI doesn't seem to be part of this registry." });
52
+ }
53
+ try {
54
+ return await this.axios({
55
+ ...config,
56
+ url: mapping.uri,
57
+ params: {
58
+ ...this._defaultParams,
59
+ ...config.params || {}
60
+ }
61
+ });
62
+ } catch (error) {
63
+ if (_.get(error, "response.status") == 404) {
64
+ return null;
65
+ }
66
+ throw error;
67
+ }
68
+ }
69
+ async getMappings({ from, fromScheme, to, toScheme, creator, type, partOf, offset, limit, direction, mode, identifier, sort, order, ...config }) {
70
+ let params = {}, url = this._api.mappings;
71
+ if (from) {
72
+ params.from = _.isString(from) ? from : from.uri;
73
+ }
74
+ if (fromScheme) {
75
+ params.fromScheme = _.isString(fromScheme) ? fromScheme : fromScheme.uri;
76
+ }
77
+ if (to) {
78
+ params.to = _.isString(to) ? to : to.uri;
79
+ }
80
+ if (toScheme) {
81
+ params.toScheme = _.isString(toScheme) ? toScheme : toScheme.uri;
82
+ }
83
+ if (creator) {
84
+ params.creator = _.isString(creator) ? creator : jskos.prefLabel(creator);
85
+ }
86
+ if (type) {
87
+ params.type = _.isString(type) ? type : type.uri;
88
+ }
89
+ if (partOf) {
90
+ params.partOf = _.isString(partOf) ? partOf : partOf.uri;
91
+ }
92
+ if (offset) {
93
+ params.offset = offset;
94
+ }
95
+ if (limit) {
96
+ params.limit = limit;
97
+ }
98
+ if (direction) {
99
+ params.direction = direction;
100
+ }
101
+ if (mode) {
102
+ params.mode = mode;
103
+ }
104
+ if (identifier) {
105
+ params.identifier = identifier;
106
+ }
107
+ if (sort) {
108
+ params.sort = sort;
109
+ }
110
+ if (order) {
111
+ params.order = order;
112
+ }
113
+ return this.axios({
114
+ ...config,
115
+ method: "get",
116
+ url,
117
+ params: {
118
+ ...this._defaultParams,
119
+ ...config.params || {},
120
+ ...params
121
+ }
122
+ });
123
+ }
124
+ async postMapping({ mapping, ...config }) {
125
+ if (!mapping) {
126
+ throw new errors.InvalidOrMissingParameterError({ parameter: "mapping" });
127
+ }
128
+ mapping = jskos.minifyMapping(mapping);
129
+ mapping = jskos.addMappingIdentifiers(mapping);
130
+ return this.axios({
131
+ ...config,
132
+ method: "post",
133
+ url: this._api.mappings,
134
+ data: mapping,
135
+ params: {
136
+ ...this._defaultParams,
137
+ ...config.params || {}
138
+ }
139
+ });
140
+ }
141
+ async putMapping({ mapping, ...config }) {
142
+ if (!mapping) {
143
+ throw new errors.InvalidOrMissingParameterError({ parameter: "mapping" });
144
+ }
145
+ mapping = jskos.minifyMapping(mapping);
146
+ mapping = jskos.addMappingIdentifiers(mapping);
147
+ const uri = mapping.uri;
148
+ if (!uri || !uri.startsWith(this._api.mappings)) {
149
+ throw new errors.InvalidOrMissingParameterError({ parameter: "mapping", message: "URI doesn't seem to be part of this registry." });
150
+ }
151
+ return this.axios({
152
+ ...config,
153
+ method: "put",
154
+ url: uri,
155
+ data: mapping,
156
+ params: {
157
+ ...this._defaultParams,
158
+ ...config.params || {}
159
+ }
160
+ });
161
+ }
162
+ async patchMapping({ mapping, ...config }) {
163
+ if (!mapping) {
164
+ throw new errors.InvalidOrMissingParameterError({ parameter: "mapping" });
165
+ }
166
+ mapping = jskos.minifyMapping(mapping);
167
+ mapping = jskos.addMappingIdentifiers(mapping);
168
+ const uri = mapping.uri;
169
+ if (!uri || !uri.startsWith(this._api.mappings)) {
170
+ throw new errors.InvalidOrMissingParameterError({ parameter: "mapping", message: "URI doesn't seem to be part of this registry." });
171
+ }
172
+ return this.axios({
173
+ ...config,
174
+ method: "patch",
175
+ url: uri,
176
+ data: mapping,
177
+ params: {
178
+ ...this._defaultParams,
179
+ ...config.params || {}
180
+ }
181
+ });
182
+ }
183
+ async deleteMapping({ mapping, ...config }) {
184
+ if (!mapping) {
185
+ throw new errors.InvalidOrMissingParameterError({ parameter: "mapping" });
186
+ }
187
+ const uri = mapping.uri;
188
+ if (!uri || !uri.startsWith(this._api.mappings)) {
189
+ throw new errors.InvalidOrMissingParameterError({ parameter: "mapping", message: "URI doesn't seem to be part of this registry." });
190
+ }
191
+ await this.axios({
192
+ ...config,
193
+ method: "delete",
194
+ url: uri
195
+ });
196
+ return true;
197
+ }
198
+ async getAnnotations({ target, ...config }) {
199
+ if (target) {
200
+ _.set(config, "params.target", target);
201
+ }
202
+ return this.axios({
203
+ ...config,
204
+ method: "get",
205
+ url: this._api.annotations
206
+ });
207
+ }
208
+ async postAnnotation({ annotation, ...config }) {
209
+ return this.axios({
210
+ ...config,
211
+ method: "post",
212
+ url: this._api.annotations,
213
+ data: annotation
214
+ });
215
+ }
216
+ async putAnnotation({ annotation, ...config }) {
217
+ const uri = annotation.id;
218
+ if (!uri || !uri.startsWith(this._api.annotations)) {
219
+ throw new errors.InvalidOrMissingParameterError({ parameter: "annotation", message: "URI doesn't seem to be part of this registry." });
220
+ }
221
+ return this.axios({
222
+ ...config,
223
+ method: "put",
224
+ url: uri,
225
+ data: annotation
226
+ });
227
+ }
228
+ async patchAnnotation({ annotation, ...config }) {
229
+ const uri = annotation.id;
230
+ if (!uri || !uri.startsWith(this._api.annotations)) {
231
+ throw new errors.InvalidOrMissingParameterError({ parameter: "annotation", message: "URI doesn't seem to be part of this registry." });
232
+ }
233
+ return this.axios({
234
+ ...config,
235
+ method: "patch",
236
+ url: uri,
237
+ data: annotation
238
+ });
239
+ }
240
+ async deleteAnnotation({ annotation, ...config }) {
241
+ const uri = annotation.id;
242
+ if (!uri || !uri.startsWith(this._api.annotations)) {
243
+ throw new errors.InvalidOrMissingParameterError({ parameter: "annotation", message: "URI doesn't seem to be part of this registry." });
244
+ }
245
+ await this.axios({
246
+ ...config,
247
+ method: "delete",
248
+ url: uri
249
+ });
250
+ return true;
251
+ }
252
+ async getConcordances(config) {
253
+ return this.axios({
254
+ ...config,
255
+ method: "get",
256
+ url: this._api.concordances
257
+ });
258
+ }
259
+ }
260
+ MappingsApiProvider.providerName = "MappingsApi";
261
+ MappingsApiProvider.stored = true;
262
+ export {
263
+ MappingsApiProvider as default
264
+ };