@toxplanet/pegasus-sdk 1.1.14 → 1.1.16

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/lib/chemicals.js CHANGED
@@ -75,25 +75,27 @@ class ChemicalsService {
75
75
  _buildChemicalUpsertSql(chemical) {
76
76
  const sql = [
77
77
  'INSERT INTO chemicals (source_id, chemical_name, chemical_meta, chemical_identifiers, chemical_synonyms, chemical_categories, created_at, updated_at)',
78
- 'VALUES (@source_id, @chemical_name, @chemical_meta, @chemical_identifiers, @chemical_synonyms, @chemical_categories, @created_at, @updated_at)',
78
+ 'VALUES (@source_id, @chemical_name, @chemical_meta::jsonb, @chemical_identifiers::jsonb, @chemical_synonyms, @chemical_categories, @created_at, @updated_at)',
79
79
  'ON CONFLICT (source_id) DO UPDATE SET',
80
80
  ' chemical_name = @chemical_name,',
81
- ' chemical_meta = @chemical_meta,',
82
- ' chemical_identifiers = @chemical_identifiers,',
81
+ ' chemical_meta = @chemical_meta::jsonb,',
82
+ ' chemical_identifiers = @chemical_identifiers::jsonb,',
83
83
  ' chemical_synonyms = @chemical_synonyms,',
84
84
  ' chemical_categories = @chemical_categories,',
85
85
  ' updated_at = @updated_at'
86
86
  ].join('\n');
87
87
 
88
+ const serializeDate = (d) => d instanceof Date ? d.toISOString() : d;
89
+
88
90
  const parameters = {
89
91
  '@source_id': chemical.sourceId,
90
92
  '@chemical_name': chemical.chemicalName,
91
- '@chemical_meta': chemical.chemicalMeta,
92
- '@chemical_identifiers': chemical.chemicalIdentifiers,
93
- '@chemical_synonyms': chemical.chemicalSynonyms,
94
- '@chemical_categories': chemical.chemicalCategories,
95
- '@created_at': chemical.createdAt instanceof Date ? chemical.createdAt.toISOString() : chemical.createdAt,
96
- '@updated_at': chemical.updatedAt instanceof Date ? chemical.updatedAt.toISOString() : chemical.updatedAt
93
+ '@chemical_meta': JSON.stringify(chemical.chemicalMeta ?? {}),
94
+ '@chemical_identifiers': JSON.stringify(chemical.chemicalIdentifiers ?? {}),
95
+ '@chemical_synonyms': JSON.stringify(chemical.chemicalSynonyms ?? []),
96
+ '@chemical_categories': JSON.stringify(chemical.chemicalCategories ?? []),
97
+ '@created_at': serializeDate(chemical.createdAt),
98
+ '@updated_at': serializeDate(chemical.updatedAt)
97
99
  };
98
100
 
99
101
  return { sql, parameters };
package/lib/db/schema.js CHANGED
@@ -17,8 +17,8 @@ const chemicals = pgTable('chemicals', {
17
17
  nameIdx: index('idx_chemicals_name').on(table.chemicalName),
18
18
  createdAtIdx: index('idx_chemicals_created_at').on(table.createdAt),
19
19
  updatedAtIdx: index('idx_chemicals_updated_at').on(table.updatedAt),
20
- identifiersGinIdx: index('idx_chemicals_identifiers_gin').using('gin').on(table.chemicalIdentifiers),
21
- synonymsGinIdx: index('idx_chemicals_synonyms_gin').using('gin').on(table.chemicalSynonyms)
20
+ identifiersGinIdx: index('idx_chemicals_identifiers_gin').on(table.chemicalIdentifiers),
21
+ synonymsGinIdx: index('idx_chemicals_synonyms_gin').on(table.chemicalSynonyms)
22
22
  };
23
23
  });
24
24
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@toxplanet/pegasus-sdk",
3
- "version": "1.1.14",
3
+ "version": "1.1.16",
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",