@adobe/spacecat-shared-data-access 3.13.0 → 3.15.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.15.0](https://github.com/adobe/spacecat-shared/compare/@adobe/spacecat-shared-data-access-v3.14.0...@adobe/spacecat-shared-data-access-v3.15.0) (2026-03-11)
2
+
3
+ ### Features
4
+
5
+ * enable urls persistence in PostgreSQL for SentimentTopic ([#1426](https://github.com/adobe/spacecat-shared/issues/1426)) ([6f439b5](https://github.com/adobe/spacecat-shared/commit/6f439b56e5f5ae3989c3fd0f142537c09f1fa4c1))
6
+
7
+ ## [@adobe/spacecat-shared-data-access-v3.14.0](https://github.com/adobe/spacecat-shared/compare/@adobe/spacecat-shared-data-access-v3.13.0...@adobe/spacecat-shared-data-access-v3.14.0) (2026-03-10)
8
+
9
+ ### Features
10
+
11
+ * enable HTTP connection reuse for PostgrestClient and VaultClient ([#1423](https://github.com/adobe/spacecat-shared/issues/1423)) ([ff92207](https://github.com/adobe/spacecat-shared/commit/ff922075a7e4d035c663d33b8b16ebe1c4dce2c6))
12
+
1
13
  ## [@adobe/spacecat-shared-data-access-v3.13.0](https://github.com/adobe/spacecat-shared/compare/@adobe/spacecat-shared-data-access-v3.12.1...@adobe/spacecat-shared-data-access-v3.13.0) (2026-03-10)
2
14
 
3
15
  ### Features
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adobe/spacecat-shared-data-access",
3
- "version": "3.13.0",
3
+ "version": "3.15.0",
4
4
  "description": "Shared modules of the Spacecat Services - Data Access",
5
5
  "type": "module",
6
6
  "engines": {
@@ -40,7 +40,8 @@
40
40
  "access": "public"
41
41
  },
42
42
  "dependencies": {
43
- "@adobe/spacecat-shared-utils": "1.81.1",
43
+ "@adobe/fetch": "^4.2.3",
44
+ "@adobe/spacecat-shared-utils": "1.101.0",
44
45
  "@supabase/postgrest-js": "^1.21.4",
45
46
  "@aws-sdk/client-s3": "^3.940.0",
46
47
  "@types/joi": "17.2.3",
@@ -59,7 +59,6 @@ const schema = new SchemaBuilder(SentimentTopic, SentimentTopicCollection)
59
59
  type: 'list',
60
60
  required: false,
61
61
  default: [],
62
- postgrestIgnore: true,
63
62
  items: {
64
63
  type: 'map',
65
64
  properties: {
@@ -12,11 +12,40 @@
12
12
 
13
13
  import { S3Client } from '@aws-sdk/client-s3';
14
14
  import { PostgrestClient } from '@supabase/postgrest-js';
15
+ import { h1NoCache, keepAliveNoCache } from '@adobe/fetch';
15
16
 
16
17
  import { instrumentAWSClient } from '@adobe/spacecat-shared-utils';
17
18
  import { EntityRegistry } from '../models/index.js';
18
19
  import { registerLogger } from '../util/logger-registry.js';
19
20
 
21
+ // Create a dedicated fetch context for PostgREST with:
22
+ // - keepAlive: true for HTTP/1.1 connection reuse (the default h2() context sets keepAlive: false
23
+ // for h1 on Node 19+, which defeats connection reuse for plain HTTP targets like our ALB)
24
+ // - maxCacheSize: 0 to disable HTTP response caching (PostgREST GET responses are cacheable
25
+ // by default, which could cause stale reads after writes within the same Lambda invocation)
26
+ // h1NoCache() in tests for nock compat; keepAliveNoCache() in prod for connection reuse.
27
+ const fetchContext = process.env.HELIX_FETCH_FORCE_HTTP1
28
+ ? h1NoCache() : keepAliveNoCache();
29
+ const { fetch: postgrestFetch } = fetchContext;
30
+
31
+ /**
32
+ * Creates a fetch wrapper that converts native (WHATWG) Headers instances to plain objects.
33
+ * @adobe/fetch's Headers class doesn't recognize native Headers instances (instanceof check
34
+ * fails), causing all headers to be silently dropped. @supabase/postgrest-js passes native
35
+ * Headers objects, so we convert them to plain objects for compatibility.
36
+ *
37
+ * @param {Function} fetchFn - The underlying fetch function to wrap
38
+ * @returns {Function} A wrapped fetch function with Headers compatibility
39
+ */
40
+ export const createFetchCompat = (fetchFn) => (url, opts) => {
41
+ if (opts?.headers instanceof Headers) {
42
+ return fetchFn(url, { ...opts, headers: Object.fromEntries(opts.headers.entries()) });
43
+ }
44
+ return fetchFn(url, opts);
45
+ };
46
+
47
+ const fetch = createFetchCompat(postgrestFetch);
48
+
20
49
  export * from '../errors/index.js';
21
50
  export * from '../models/index.js';
22
51
  export * from '../util/index.js';
@@ -45,6 +74,7 @@ const createPostgrestService = (config, client = undefined) => {
45
74
  return new PostgrestClient(postgrestUrl, {
46
75
  schema: postgrestSchema,
47
76
  headers,
77
+ fetch,
48
78
  });
49
79
  };
50
80