@toxplanet/pegasus-sdk 1.1.0 → 1.1.2

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.
@@ -19,9 +19,9 @@ module.exports = {
19
19
  rejectUnauthorized: false
20
20
  }
21
21
  },
22
- indexRoutes: {
23
- chemicals: ['chemicals*'],
24
- documents: ['documents*'],
25
- search: [/^(chemicals|substances|search)/]
26
- }
22
+ indexRoutes: {
23
+ chemicals: ['chemical_index*'],
24
+ documents: ['document_nones_index*'],
25
+ search: [/^(chemical_index|document_nones_index|search)/]
26
+ }
27
27
  };
package/lib/chemicals.js CHANGED
@@ -239,52 +239,52 @@ class ChemicalsService {
239
239
 
240
240
  indexPatterns.forEach(pattern => {
241
241
  elasticsearchService.registerIndexRoute(pattern, {
242
- index: async (params) => {
242
+ index: async (params) => {
243
243
  const chemical = params.body;
244
- return await this.createChemical(chemical);
245
- },
246
-
247
- bulk: async (params) => {
248
- const operations = params.body || params.operations;
249
- const documents = [];
244
+ return await this.createChemical(chemical);
245
+ },
250
246
 
251
- for (let i = 0; i < operations.length; i += 2) {
252
- const action = operations[i];
253
- const document = operations[i + 1];
247
+ bulk: async (params) => {
248
+ const operations = params.body || params.operations;
249
+ const documents = [];
254
250
 
255
- if (action.index || action.create) {
256
- documents.push(document);
251
+ for (let i = 0; i < operations.length; i += 2) {
252
+ const action = operations[i];
253
+ const document = operations[i + 1];
254
+
255
+ if (action.index || action.create) {
256
+ documents.push(document);
257
+ }
257
258
  }
258
- }
259
+
260
+ return await this.bulkIndexFielded(documents);
261
+ },
259
262
 
260
- return await this.bulkIndexFielded(documents);
261
- },
262
-
263
- get: async (params) => {
264
- return await this.getChemicalById(params.id);
265
- },
266
-
267
- update: async (params) => {
268
- return await this.updateChemical(params.id, params.body);
269
- },
270
-
271
- delete: async (params) => {
272
- return await this.deleteChemical(params.id);
273
- },
274
-
275
- search: async (params) => {
276
- const query = params.body?.query;
277
- const searchTerm = query?.match?.chemical_name ||
278
- query?.term?.chemical_name ||
279
- query?.query_string?.query || '';
280
- const limit = params.body?.size || 10;
263
+ get: async (params) => {
264
+ return await this.getChemicalById(params.id);
265
+ },
281
266
 
282
- return await this.searchByName(searchTerm, limit);
283
- },
284
-
285
- count: async (params) => {
286
- return await this.countAll();
287
- }
267
+ update: async (params) => {
268
+ return await this.updateChemical(params.id, params.body);
269
+ },
270
+
271
+ delete: async (params) => {
272
+ return await this.deleteChemical(params.id);
273
+ },
274
+
275
+ search: async (params) => {
276
+ const query = params.body?.query;
277
+ const searchTerm = query?.match?.chemical_name ||
278
+ query?.term?.chemical_name ||
279
+ query?.query_string?.query || '';
280
+ const limit = params.body?.size || 10;
281
+
282
+ return await this.searchByName(searchTerm, limit);
283
+ },
284
+
285
+ count: async (params) => {
286
+ return await this.countAll();
287
+ }
288
288
  });
289
289
  });
290
290
  }
package/lib/documents.js CHANGED
@@ -50,42 +50,42 @@ class DocumentsService {
50
50
 
51
51
  indexPatterns.forEach(pattern => {
52
52
  elasticsearchService.registerIndexRoute(pattern, {
53
- index: async (params) => {
54
- const document = params.body;
55
- return await this.createDocument(document.document_path, document.cas_numbers || []);
56
- },
57
-
58
- bulk: async (params) => {
59
- const operations = params.body || params.operations;
60
- const documents = [];
53
+ index: async (params) => {
54
+ const document = params.body;
55
+ return await this.createDocument(document.document_path, document.cas_numbers || []);
56
+ },
61
57
 
62
- for (let i = 0; i < operations.length; i += 2) {
63
- const action = operations[i];
64
- const document = operations[i + 1];
58
+ bulk: async (params) => {
59
+ const operations = params.body || params.operations;
60
+ const documents = [];
65
61
 
66
- if (action.index || action.create) {
67
- documents.push(document);
62
+ for (let i = 0; i < operations.length; i += 2) {
63
+ const action = operations[i];
64
+ const document = operations[i + 1];
65
+
66
+ if (action.index || action.create) {
67
+ documents.push(document);
68
+ }
68
69
  }
69
- }
70
+
71
+ return await this.bulkCreateDocuments(documents);
72
+ },
73
+
74
+ get: async (params) => {
75
+ return await this.getDocumentById(params.id);
76
+ },
70
77
 
71
- return await this.bulkCreateDocuments(documents);
72
- },
73
-
74
- get: async (params) => {
75
- return await this.getDocumentById(params.id);
76
- },
77
-
78
- update: async (params) => {
79
- return await this.updateDocument(params.id, params.body);
80
- },
81
-
82
- delete: async (params) => {
83
- return await this.deleteDocument(params.id);
84
- },
85
-
86
- count: async (params) => {
87
- return await this.countDocuments();
88
- }
78
+ update: async (params) => {
79
+ return await this.updateDocument(params.id, params.body);
80
+ },
81
+
82
+ delete: async (params) => {
83
+ return await this.deleteDocument(params.id);
84
+ },
85
+
86
+ count: async (params) => {
87
+ return await this.countDocuments();
88
+ }
89
89
  });
90
90
  });
91
91
  }
package/lib/search.js CHANGED
@@ -308,26 +308,26 @@ class SearchService {
308
308
 
309
309
  indexPatterns.forEach(pattern => {
310
310
  elasticsearchService.registerIndexRoute(pattern, {
311
- search: async (params) => {
312
- const query = params.body?.query;
313
- const searchTerm = query?.match?.chemical_name ||
314
- query?.term?.chemical_name ||
315
- query?.query_string?.query ||
316
- query?.match_all ? '*' : '';
317
- const limit = params.body?.size || 10;
311
+ search: async (params) => {
312
+ const query = params.body?.query;
313
+ const searchTerm = query?.match?.chemical_name ||
314
+ query?.term?.chemical_name ||
315
+ query?.query_string?.query ||
316
+ query?.match_all ? '*' : '';
317
+ const limit = params.body?.size || 10;
318
+
319
+ return await this.searchChemicals(searchTerm, { limit });
320
+ },
318
321
 
319
- return await this.searchChemicals(searchTerm, { limit });
320
- },
321
-
322
- count: async (params) => {
323
- const query = params.body?.query;
324
- const searchTerm = query?.match?.chemical_name ||
325
- query?.term?.chemical_name ||
326
- query?.query_string?.query || '';
327
-
328
- const results = await this.searchChemicals(searchTerm, { limit: 10000 });
329
- return { count: results.results.length };
330
- }
322
+ count: async (params) => {
323
+ const query = params.body?.query;
324
+ const searchTerm = query?.match?.chemical_name ||
325
+ query?.term?.chemical_name ||
326
+ query?.query_string?.query || '';
327
+
328
+ const results = await this.searchChemicals(searchTerm, { limit: 10000 });
329
+ return { count: results.results.length };
330
+ }
331
331
  });
332
332
  });
333
333
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@toxplanet/pegasus-sdk",
3
- "version": "1.1.0",
3
+ "version": "1.1.2",
4
4
  "description": "SDK for migrating chemical data to Pegasus PostgreSQL + OpenSearch architecture with Elasticsearch client compatibility",
5
5
  "main": "index.js",
6
6
  "type": "commonjs",