@adobe/spacecat-shared-data-access 3.75.3 → 3.76.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.76.0](https://github.com/adobe/spacecat-shared/compare/@adobe/spacecat-shared-data-access-v3.75.4...@adobe/spacecat-shared-data-access-v3.76.0) (2026-06-17)
2
+
3
+ ### Features
4
+
5
+ * add `allByExternalOwnerIdAndExternalSiteId` type to SiteCollection ([#1655](https://github.com/adobe/spacecat-shared/issues/1655)) ([c73e2b1](https://github.com/adobe/spacecat-shared/commit/c73e2b12fc5eec9d95fb5453c0ef7bb217e6e170))
6
+
7
+ ## [@adobe/spacecat-shared-data-access-v3.75.4](https://github.com/adobe/spacecat-shared/compare/@adobe/spacecat-shared-data-access-v3.75.3...@adobe/spacecat-shared-data-access-v3.75.4) (2026-06-16)
8
+
9
+ ### Bug Fixes
10
+
11
+ * **data-access:** batch suggestion-grant lookups to avoid 414 URI Too Long ([#1684](https://github.com/adobe/spacecat-shared/issues/1684)) ([941660c](https://github.com/adobe/spacecat-shared/commit/941660cea9ea37cc2e4bf50528923f9f051b540e))
12
+
1
13
  ## [@adobe/spacecat-shared-data-access-v3.75.3](https://github.com/adobe/spacecat-shared/compare/@adobe/spacecat-shared-data-access-v3.75.2...@adobe/spacecat-shared-data-access-v3.75.3) (2026-06-16)
2
14
 
3
15
  ### Bug Fixes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adobe/spacecat-shared-data-access",
3
- "version": "3.75.3",
3
+ "version": "3.76.0",
4
4
  "description": "Shared modules of the Spacecat Services - Data Access",
5
5
  "type": "module",
6
6
  "engines": {
@@ -419,4 +419,7 @@ export interface SiteCollection extends BaseCollection<Site> {
419
419
  findByExternalOwnerIdAndExternalSiteId(
420
420
  externalOwnerId: string, externalSiteId: string
421
421
  ): Promise<Site | null>;
422
+ allByExternalOwnerIdAndExternalSiteId(
423
+ externalOwnerId: string, externalSiteId: string
424
+ ): Promise<Site[]>;
422
425
  }
@@ -27,8 +27,18 @@ import DataAccessError from '../../errors/data-access.error.js';
27
27
  class SuggestionGrantCollection extends BaseCollection {
28
28
  static COLLECTION_NAME = 'SuggestionGrantCollection';
29
29
 
30
+ /**
31
+ * Max suggestion IDs per PostgREST request. PostgREST serializes `.in()` into the request
32
+ * URL (`suggestion_id=in.(<uuid>,<uuid>,...)`); each UUID costs ~39 chars, so 100 IDs keeps
33
+ * the query string near ~4KB — comfortably under the ~8KB limit that otherwise triggers a
34
+ * `414 URI Too Long` and fails the whole lookup.
35
+ */
36
+ static FIND_BY_SUGGESTION_IDS_CHUNK_SIZE = 100;
37
+
30
38
  /**
31
39
  * Finds all grant rows for the given suggestion IDs (suggestion_id, grant_id only).
40
+ * Lookups are chunked to avoid `414 URI Too Long` from PostgREST GET URLs when many
41
+ * suggestion IDs are supplied.
32
42
  *
33
43
  * @async
34
44
  * @param {string[]} suggestionIds - Suggestion IDs to look up.
@@ -39,16 +49,28 @@ class SuggestionGrantCollection extends BaseCollection {
39
49
  if (!Array.isArray(suggestionIds) || suggestionIds.length === 0) {
40
50
  return [];
41
51
  }
42
- const { data, error } = await this.postgrestService
43
- .from(this.tableName)
44
- .select('suggestion_id,grant_id')
45
- .in('suggestion_id', suggestionIds);
46
52
 
47
- if (error) {
48
- throw new DataAccessError('Failed to find grants by suggestion IDs', this, error);
53
+ const chunkSize = SuggestionGrantCollection.FIND_BY_SUGGESTION_IDS_CHUNK_SIZE;
54
+ const rows = [];
55
+
56
+ for (let i = 0; i < suggestionIds.length; i += chunkSize) {
57
+ const chunk = suggestionIds.slice(i, i + chunkSize);
58
+ // eslint-disable-next-line no-await-in-loop
59
+ const { data, error } = await this.postgrestService
60
+ .from(this.tableName)
61
+ .select('suggestion_id,grant_id')
62
+ .in('suggestion_id', chunk);
63
+
64
+ if (error) {
65
+ throw new DataAccessError('Failed to find grants by suggestion IDs', this, error);
66
+ }
67
+
68
+ if (data) {
69
+ rows.push(...data);
70
+ }
49
71
  }
50
72
 
51
- return data ?? [];
73
+ return rows;
52
74
  }
53
75
 
54
76
  /**