@adobe/spacecat-shared-data-access 3.4.2 → 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 +6 -0
- package/package.json +1 -1
- package/src/models/base/base.collection.js +15 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,9 @@
|
|
|
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
|
+
|
|
1
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)
|
|
2
8
|
|
|
3
9
|
### Bug Fixes
|
package/package.json
CHANGED
|
@@ -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(
|
|
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(
|
|
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()
|