@zintrust/zedgi 3.0.1 → 3.0.2

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/README.md CHANGED
@@ -31,6 +31,10 @@ ZEDGI_REDIS_HEADER=
31
31
  ZEDGI_QUEUE_HEADER=
32
32
  ZEDGI_MYSQL_HEADER=
33
33
  ZEDGI_POSTGRES_HEADER=
34
+
35
+ # Optional Redis credential profile for queues. Falls back to ZEDGI_REDIS_PROFILE.
36
+ ZEDGI_QUEUE_PROFILE=
37
+ ZEDGI_REDIS_PROFILE=
34
38
  ```
35
39
 
36
40
  ## Drivers
@@ -68,6 +72,11 @@ can be used for producers, monitoring, and consumers. When `QUEUE_CONNECTION` an
68
72
  to `queue-zedgi` to keep workers, monitors, and producers on the same Zedgi-backed
69
73
  Redis target.
70
74
 
75
+ When `ZEDGI_QUEUE_PROFILE` is set, the queue driver uses that named Redis
76
+ credential profile. ZinTrust registers the profile with the configured Redis DB
77
+ (`REDIS_QUEUE_DB` or `WORKERS_REDIS_QUEUE_DB`) so BullMQ keys are read from the
78
+ intended logical database.
79
+
71
80
  ## Registration
72
81
 
73
82
  The package registers:
@@ -4,6 +4,7 @@ type RedisConfig = {
4
4
  db?: number;
5
5
  database?: number;
6
6
  header?: Record<string, unknown>;
7
+ profile?: string;
7
8
  };
8
9
  declare const createZedgiMonitorDriver: (config: RedisConfig) => QueueDriver;
9
10
  export { createZedgiMonitorDriver };
@@ -111,6 +111,7 @@ const createZedgiMonitorDriver = (config) => {
111
111
  password: config.password,
112
112
  database: config.db ?? config.database,
113
113
  header: config.header,
114
+ profile: config.profile,
114
115
  });
115
116
  return {
116
117
  enqueue: createZedgiEnqueue(getQueueConfig),
@@ -112,6 +112,15 @@ const redisCredentialFromConfig = (config, fallbackHeaderKey) => {
112
112
  credential['header'] = header;
113
113
  return credential;
114
114
  };
115
+ const resolveCredentialProfile = (config) => {
116
+ if (config === null || typeof config !== 'object')
117
+ return undefined;
118
+ const profile = config.profile;
119
+ if (typeof profile !== 'string')
120
+ return undefined;
121
+ const normalized = profile.trim();
122
+ return normalized === '' ? undefined : normalized;
123
+ };
115
124
  const sqlCredentialFromConfig = (config, fallbackHeaderKey) => {
116
125
  const credential = {};
117
126
  if (hasText(config.username))
@@ -144,10 +153,22 @@ export const ZedgiRuntime = Object.freeze({
144
153
  client = undefined;
145
154
  },
146
155
  redis(config = {}) {
156
+ const explicitProfile = resolveCredentialProfile(config);
157
+ if (explicitProfile !== undefined) {
158
+ const credential = redisCredentialFromConfig(config, 'ZEDGI_REDIS_HEADER');
159
+ registerProfile('redis', explicitProfile, credential);
160
+ return ensureClient().redis(explicitProfile);
161
+ }
147
162
  const credential = memoizeCredential('redis', 'redis', redisCredentialFromConfig(config, 'ZEDGI_REDIS_HEADER'), redisCredentials);
148
163
  return ensureClient().redis(getProfileName(credential));
149
164
  },
150
165
  queue(name, config = {}) {
166
+ const explicitProfile = resolveCredentialProfile(config);
167
+ if (explicitProfile !== undefined) {
168
+ const credential = redisCredentialFromConfig(config, 'ZEDGI_QUEUE_HEADER');
169
+ registerProfile('redis', explicitProfile, credential);
170
+ return ensureClient().queue(name, explicitProfile);
171
+ }
151
172
  const credential = memoizeCredential('redis', 'redis', redisCredentialFromConfig(config, 'ZEDGI_QUEUE_HEADER'), redisCredentials);
152
173
  return ensureClient().queue(name, getProfileName(credential));
153
174
  },
package/dist/types.d.ts CHANGED
@@ -18,6 +18,7 @@ export type ZedgiQueueConfig = {
18
18
  password?: string;
19
19
  database?: number;
20
20
  header?: Record<string, unknown>;
21
+ profile?: string;
21
22
  };
22
23
  export type CacheDriver = {
23
24
  get<T>(key: string): Promise<T | null>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zintrust/zedgi",
3
- "version": "3.0.1",
3
+ "version": "3.0.2",
4
4
  "description": "Zedgi HTTPS transport drivers for ZinTrust cache, database, and queue.",
5
5
  "private": false,
6
6
  "type": "module",