@adobe/spacecat-shared-data-access 3.4.1 → 3.5.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.
package/CHANGELOG.md CHANGED
@@ -1,3 +1,15 @@
1
+ ## [@adobe/spacecat-shared-data-access-v3.5.0](https://github.com/adobe/spacecat-shared/compare/@adobe/spacecat-shared-data-access-v3.4.2...@adobe/spacecat-shared-data-access-v3.5.0) (2026-03-02)
2
+
3
+ ### Features
4
+
5
+ * **data-access:** auto-normalize enum values in PostgREST query filters ([#1392](https://github.com/adobe/spacecat-shared/issues/1392)) ([f44d0d2](https://github.com/adobe/spacecat-shared/commit/f44d0d257b0d47a719f592da13e91b2b01d89454))
6
+
7
+ ## [@adobe/spacecat-shared-data-access-v3.4.2](https://github.com/adobe/spacecat-shared/compare/@adobe/spacecat-shared-data-access-v3.4.1...@adobe/spacecat-shared-data-access-v3.4.2) (2026-03-02)
8
+
9
+ ### Bug Fixes
10
+
11
+ * **deps:** update external fixes ([#1223](https://github.com/adobe/spacecat-shared/issues/1223)) ([7ee8461](https://github.com/adobe/spacecat-shared/commit/7ee8461c99223d07a2f47bd6838b6942fcb30f28))
12
+
1
13
  ## [@adobe/spacecat-shared-data-access-v3.4.1](https://github.com/adobe/spacecat-shared/compare/@adobe/spacecat-shared-data-access-v3.4.0...@adobe/spacecat-shared-data-access-v3.4.1) (2026-03-01)
2
14
 
3
15
  ### Bug Fixes
@@ -22,7 +22,7 @@ services:
22
22
  retries: 10
23
23
 
24
24
  postgrest:
25
- image: postgrest/postgrest:v14.4
25
+ image: postgrest/postgrest:v14.5
26
26
  container_name: spacecat-test-postgrest
27
27
  depends_on:
28
28
  db:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adobe/spacecat-shared-data-access",
3
- "version": "3.4.1",
3
+ "version": "3.5.0",
4
4
  "description": "Shared modules of the Spacecat Services - Data Access",
5
5
  "type": "module",
6
6
  "engines": {
@@ -49,10 +49,10 @@
49
49
  "pluralize": "8.0.0"
50
50
  },
51
51
  "devDependencies": {
52
- "chai": "6.2.1",
52
+ "chai": "6.2.2",
53
53
  "chai-as-promised": "8.0.2",
54
- "nock": "14.0.10",
55
- "sinon": "21.0.0",
54
+ "nock": "14.0.11",
55
+ "sinon": "21.0.1",
56
56
  "sinon-chai": "4.0.1"
57
57
  }
58
58
  }
@@ -92,6 +92,14 @@ class BaseCollection {
92
92
  return isSingleFieldAcrossAll ? field : null;
93
93
  }
94
94
 
95
+ #normalizeEnumValue(key, value) {
96
+ if (typeof value !== 'string') return value;
97
+ const attr = this.schema.getAttribute(key);
98
+ if (!Array.isArray(attr?.type)) return value;
99
+ const match = attr.type.find((v) => v.toLowerCase() === value.toLowerCase());
100
+ return match ?? value;
101
+ }
102
+
95
103
  // eslint-disable-next-line class-methods-use-this
96
104
  #isInvalidInputError(error) {
97
105
  let current = error;
@@ -378,7 +386,7 @@ class BaseCollection {
378
386
 
379
387
  let filtered = query;
380
388
  Object.entries(keys).forEach(([key, value]) => {
381
- filtered = filtered.eq(this.#toDbField(key), value);
389
+ filtered = filtered.eq(this.#toDbField(key), this.#normalizeEnumValue(key, value));
382
390
  });
383
391
  return filtered;
384
392
  }
@@ -615,7 +623,9 @@ class BaseCollection {
615
623
  const bulkKeyField = this.#resolveBulkKeyField(keys);
616
624
  if (bulkKeyField) {
617
625
  const dbField = this.#toDbField(bulkKeyField);
618
- const values = keys.map((key) => key[bulkKeyField]);
626
+ const values = keys.map(
627
+ (key) => this.#normalizeEnumValue(bulkKeyField, key[bulkKeyField]),
628
+ );
619
629
  const select = this.#buildSelect(options.attributes);
620
630
 
621
631
  // Chunk values to avoid 414 URI Too Large from PostgREST GET URLs.
@@ -967,7 +977,9 @@ class BaseCollection {
967
977
  const bulkKeyField = this.#resolveBulkKeyField(keys);
968
978
  if (bulkKeyField) {
969
979
  const dbField = this.#toDbField(bulkKeyField);
970
- const values = keys.map((key) => key[bulkKeyField]);
980
+ const values = keys.map(
981
+ (key) => this.#normalizeEnumValue(bulkKeyField, key[bulkKeyField]),
982
+ );
971
983
  const { error } = await this.postgrestService
972
984
  .from(this.tableName)
973
985
  .delete()