n8n-nodes-autotask 2.22.3 → 2.23.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/dist/credentials/AutotaskApi.credentials.d.ts.map +1 -1
- package/dist/credentials/AutotaskApi.credentials.js +39 -0
- package/dist/credentials/AutotaskApi.credentials.js.map +1 -1
- package/dist/nodes/Autotask/helpers/http/redis/client.d.ts +75 -0
- package/dist/nodes/Autotask/helpers/http/redis/client.d.ts.map +1 -0
- package/dist/nodes/Autotask/helpers/http/redis/client.js +176 -0
- package/dist/nodes/Autotask/helpers/http/redis/client.js.map +1 -0
- package/dist/nodes/Autotask/helpers/http/redis/threadStore.d.ts +14 -0
- package/dist/nodes/Autotask/helpers/http/redis/threadStore.d.ts.map +1 -0
- package/dist/nodes/Autotask/helpers/http/redis/threadStore.js +52 -0
- package/dist/nodes/Autotask/helpers/http/redis/threadStore.js.map +1 -0
- package/dist/nodes/Autotask/helpers/http/redis/usageStore.d.ts +17 -0
- package/dist/nodes/Autotask/helpers/http/redis/usageStore.d.ts.map +1 -0
- package/dist/nodes/Autotask/helpers/http/redis/usageStore.js +37 -0
- package/dist/nodes/Autotask/helpers/http/redis/usageStore.js.map +1 -0
- package/dist/nodes/Autotask/helpers/http/request.d.ts +14 -0
- package/dist/nodes/Autotask/helpers/http/request.d.ts.map +1 -1
- package/dist/nodes/Autotask/helpers/http/request.js +115 -13
- package/dist/nodes/Autotask/helpers/http/request.js.map +1 -1
- package/dist/nodes/Autotask/helpers/http/retryHandler.d.ts +1 -0
- package/dist/nodes/Autotask/helpers/http/retryHandler.d.ts.map +1 -1
- package/dist/nodes/Autotask/helpers/http/retryHandler.js +104 -12
- package/dist/nodes/Autotask/helpers/http/retryHandler.js.map +1 -1
- package/dist/nodes/Autotask/helpers/http/threadLimit.d.ts +5 -0
- package/dist/nodes/Autotask/helpers/http/threadLimit.d.ts.map +1 -1
- package/dist/nodes/Autotask/helpers/http/threadLimit.js +27 -17
- package/dist/nodes/Autotask/helpers/http/threadLimit.js.map +1 -1
- package/dist/nodes/Autotask/resources/apiThreshold/execute.d.ts.map +1 -1
- package/dist/nodes/Autotask/resources/apiThreshold/execute.js +36 -2
- package/dist/nodes/Autotask/resources/apiThreshold/execute.js.map +1 -1
- package/dist/nodes/Autotask/types/base/auth.d.ts +5 -0
- package/dist/nodes/Autotask/types/base/auth.d.ts.map +1 -1
- package/dist/package.json +4 -18
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +4 -18
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AutotaskApi.credentials.d.ts","sourceRoot":"","sources":["../../credentials/AutotaskApi.credentials.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACX,oBAAoB,EACpB,sBAAsB,EACtB,eAAe,EACf,eAAe,EACf,MAAM,cAAc,CAAC;AAKtB,qBAAa,WAAY,YAAW,eAAe;IAClD,IAAI,SAAiB;IACrB,WAAW,SAAkB;IAC7B,IAAI,EAAG,qCAAqC,CAAU;IACtD,gBAAgB,SAAqF;IACrG,UAAU,EAAE,eAAe,EAAE,
|
|
1
|
+
{"version":3,"file":"AutotaskApi.credentials.d.ts","sourceRoot":"","sources":["../../credentials/AutotaskApi.credentials.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACX,oBAAoB,EACpB,sBAAsB,EACtB,eAAe,EACf,eAAe,EACf,MAAM,cAAc,CAAC;AAKtB,qBAAa,WAAY,YAAW,eAAe;IAClD,IAAI,SAAiB;IACrB,WAAW,SAAkB;IAC7B,IAAI,EAAG,qCAAqC,CAAU;IACtD,gBAAgB,SAAqF;IACrG,UAAU,EAAE,eAAe,EAAE,CA+Y3B;IAEF,YAAY,EAAE,oBAAoB,CAUhC;IAEF,IAAI,EAAE,sBAAsB,CAY1B;IAEF,WAAW;CAKX"}
|
|
@@ -287,6 +287,45 @@ class AutotaskApi {
|
|
|
287
287
|
},
|
|
288
288
|
},
|
|
289
289
|
},
|
|
290
|
+
{
|
|
291
|
+
displayName: 'Enable Redis Coordination',
|
|
292
|
+
name: 'redisEnabled',
|
|
293
|
+
type: 'boolean',
|
|
294
|
+
default: false,
|
|
295
|
+
description: 'Coordinate Autotask thread limits and threshold polling across multiple n8n workers via Redis. When off, each worker tracks limits independently (current behaviour).',
|
|
296
|
+
},
|
|
297
|
+
{
|
|
298
|
+
displayName: 'Redis Host',
|
|
299
|
+
name: 'redisHost',
|
|
300
|
+
type: 'string',
|
|
301
|
+
default: '',
|
|
302
|
+
displayOptions: { show: { redisEnabled: [true] } },
|
|
303
|
+
description: 'Redis server hostname or IP',
|
|
304
|
+
},
|
|
305
|
+
{
|
|
306
|
+
displayName: 'Redis Port',
|
|
307
|
+
name: 'redisPort',
|
|
308
|
+
type: 'number',
|
|
309
|
+
default: 6379,
|
|
310
|
+
displayOptions: { show: { redisEnabled: [true] } },
|
|
311
|
+
},
|
|
312
|
+
{
|
|
313
|
+
displayName: 'Redis Password',
|
|
314
|
+
name: 'redisPassword',
|
|
315
|
+
type: 'string',
|
|
316
|
+
typeOptions: { password: true },
|
|
317
|
+
default: '',
|
|
318
|
+
displayOptions: { show: { redisEnabled: [true] } },
|
|
319
|
+
description: 'Leave blank if the Redis server requires no auth',
|
|
320
|
+
},
|
|
321
|
+
{
|
|
322
|
+
displayName: 'Redis TLS',
|
|
323
|
+
name: 'redisTls',
|
|
324
|
+
type: 'boolean',
|
|
325
|
+
default: false,
|
|
326
|
+
displayOptions: { show: { redisEnabled: [true] } },
|
|
327
|
+
description: 'Whether to connect using TLS (rediss://)',
|
|
328
|
+
},
|
|
290
329
|
{
|
|
291
330
|
displayName: 'WARNING: Disabling Cache Causes High API Usage',
|
|
292
331
|
name: 'cachingWarning',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AutotaskApi.credentials.js","sourceRoot":"","sources":["../../credentials/AutotaskApi.credentials.ts"],"names":[],"mappings":";;;;;;AAOA,sEAAqC;AACrC,2DAA+D;AAE/D,MAAa,WAA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FAA0F;gBACnG,GAAG,EAAE,8BAA8B;gBACnC,MAAM,EAAE,KAAK;gBACb,OAAO,EAAE;oBACR,kBAAkB,EAAE,sCAAsC;oBAC1D,QAAQ,EAAE,4BAA4B;oBACtC,MAAM,EAAE,0BAA0B;oBAClC,cAAc,EAAE,kBAAkB;iBAClB;aACjB;SACD,CAAC;IAOH,CAAC;IALA,WAAW;QACV,qDAAqD;QACrD,wDAAwD;QACxD,oBAAY,CAAC,iBAAiB,EAAE,CAAC;IAClC,CAAC;CACD;
|
|
1
|
+
{"version":3,"file":"AutotaskApi.credentials.js","sourceRoot":"","sources":["../../credentials/AutotaskApi.credentials.ts"],"names":[],"mappings":";;;;;;AAOA,sEAAqC;AACrC,2DAA+D;AAE/D,MAAa,WAAW;IAAxB;QACC,SAAI,GAAG,aAAa,CAAC;QACrB,gBAAW,GAAG,cAAc,CAAC;QAC7B,SAAI,GAAG,qCAA8C,CAAC;QACtD,qBAAgB,GAAG,iFAAiF,CAAC;QACrG,eAAU,GAAsB;YAC/B;gBACC,WAAW,EAAE,sBAAsB;gBACnC,IAAI,EAAE,oBAAoB;gBAC1B,IAAI,EAAE,QAAQ;gBACd,WAAW,EAAE;oBACZ,QAAQ,EAAE,IAAI;iBACd;gBACD,OAAO,EAAE,EAAE;gBACX,QAAQ,EAAE,IAAI;gBACd,WAAW,EAAE,iGAAiG;aAC9G;YACD;gBACC,WAAW,EAAE,UAAU;gBACvB,IAAI,EAAE,UAAU;gBAChB,IAAI,EAAE,QAAQ;gBACd,OAAO,EAAE,EAAE;gBACX,QAAQ,EAAE,IAAI;gBACd,WAAW,EAAE,kEAAkE;aAC/E;YACD;gBACC,WAAW,EAAE,QAAQ;gBACrB,IAAI,EAAE,QAAQ;gBACd,IAAI,EAAE,QAAQ;gBACd,WAAW,EAAE;oBACZ,QAAQ,EAAE,IAAI;iBACd;gBACD,OAAO,EAAE,EAAE;gBACX,QAAQ,EAAE,IAAI;gBACd,WAAW,EAAE,8DAA8D;aAC3E;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iBACD;aACD;SACD,CAAC;QAEF,iBAAY,GAAyB;YACpC,IAAI,EAAE,SAAS;YACf,UAAU,EAAE;gBACX,OAAO,EAAE;oBACR,kBAAkB,EAAE,sCAAsC;oBAC1D,QAAQ,EAAE,4BAA4B;oBACtC,MAAM,EAAE,0BAA0B;oBAClC,cAAc,EAAE,kBAAkB;iBAClB;aACjB;SACD,CAAC;QAEF,SAAI,GAA2B;YAC9B,OAAO,EAAE;gBACR,OAAO,EAAE,0FAA0F;gBACnG,GAAG,EAAE,8BAA8B;gBACnC,MAAM,EAAE,KAAK;gBACb,OAAO,EAAE;oBACR,kBAAkB,EAAE,sCAAsC;oBAC1D,QAAQ,EAAE,4BAA4B;oBACtC,MAAM,EAAE,0BAA0B;oBAClC,cAAc,EAAE,kBAAkB;iBAClB;aACjB;SACD,CAAC;IAOH,CAAC;IALA,WAAW;QACV,qDAAqD;QACrD,wDAAwD;QACxD,oBAAY,CAAC,iBAAiB,EAAE,CAAC;IAClC,CAAC;CACD;AArbD,kCAqbC"}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
export declare const REDIS_KEY_PREFIX = "n8n-autotask";
|
|
2
|
+
export interface RedisConfig {
|
|
3
|
+
host: string;
|
|
4
|
+
port: number;
|
|
5
|
+
password?: string;
|
|
6
|
+
tls: boolean;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Reads Redis connection settings from Autotask credentials. Returns null when disabled.
|
|
10
|
+
* Param is Record<string, unknown> so call sites can pass `credentials as unknown as Record<string, unknown>`
|
|
11
|
+
* and compile under strict mode (a typed interface param would reject `unknown`-valued fields).
|
|
12
|
+
*/
|
|
13
|
+
export declare function getRedisConfigFromCredentials(creds: Record<string, unknown>): RedisConfig | null;
|
|
14
|
+
/**
|
|
15
|
+
* 16-char hash of the THREAD-limit identity: {baseUrl, APIIntegrationcode}.
|
|
16
|
+
* Username + Secret intentionally excluded.
|
|
17
|
+
*
|
|
18
|
+
* Rationale: Autotask scopes the 3-concurrent thread limit (Itgenatr005) by
|
|
19
|
+
* (object endpoint + tracking identifier), where the tracking identifier IS the
|
|
20
|
+
* API integration code — NOT the API username (confirmed by Autotask's
|
|
21
|
+
* ThreadLimiting docs: the limit applies to "the combination of each unique API
|
|
22
|
+
* tracking identifier plus object endpoint call"). Two API users that share one
|
|
23
|
+
* integration code share ONE Autotask thread budget; they MUST therefore share one
|
|
24
|
+
* Redis semaphore. Splitting the thread key by Username would give each user its own
|
|
25
|
+
* 3-slot semaphore (6 effective slots for one budget) and re-introduce the exact
|
|
26
|
+
* Itgenatr005 over-subscription this feature fixes. This also matches the in-memory
|
|
27
|
+
* `endpointThreadTracker`, which keys on endpoint alone (no username dimension), so
|
|
28
|
+
* the fail-open fallback stays equivalent.
|
|
29
|
+
*
|
|
30
|
+
* Object key is `APIIntegrationcode` (verbatim credential field name) so a Phase-2 cache
|
|
31
|
+
* migration that hashes the same identity produces matching keys.
|
|
32
|
+
*/
|
|
33
|
+
export declare function redisKeyHash(baseUrl: string, integrationCode: string): string;
|
|
34
|
+
/**
|
|
35
|
+
* 16-char hash of the POLL/USAGE identity: {baseUrl, APIIntegrationcode, Username}.
|
|
36
|
+
* Username IS included here (and Secret still excluded — survives rotation).
|
|
37
|
+
*
|
|
38
|
+
* Rationale: the `poll` dedup lock and `usage` snapshot key carry the database-wide
|
|
39
|
+
* `ThresholdInformation` triple. Two distinct API users (different `Username`) on the
|
|
40
|
+
* same zone + integration code may point at DIFFERENT Autotask databases — a zone URL
|
|
41
|
+
* hosts many tenant databases, so baseUrl + integration code alone does not identify a
|
|
42
|
+
* database. Sharing the poll/usage key across them would serve one credential's usage
|
|
43
|
+
* snapshot for the other and suppress the other's own poll for the lock window
|
|
44
|
+
* (the cross-credential bleed Codex flagged). Adding Username scopes these keys per
|
|
45
|
+
* API user; when two users genuinely share one database the underlying number is
|
|
46
|
+
* identical, so this never harms correctness — it only prevents the bleed.
|
|
47
|
+
*
|
|
48
|
+
* NOTE: this hash is for poll/usage ONLY. The thread semaphore deliberately uses
|
|
49
|
+
* `redisKeyHash` (no Username) — see its rationale above. Do NOT swap them.
|
|
50
|
+
*/
|
|
51
|
+
export declare function redisUsageKeyHash(baseUrl: string, integrationCode: string, username: string): string;
|
|
52
|
+
/** Replaces a known password substring with *** so it never reaches logs. */
|
|
53
|
+
export declare function scrubRedisSecret(message: string, password?: string): string;
|
|
54
|
+
export interface RedisLike {
|
|
55
|
+
set(key: string, value: string, opts?: {
|
|
56
|
+
NX?: boolean;
|
|
57
|
+
PX?: number;
|
|
58
|
+
}): Promise<string | null>;
|
|
59
|
+
get(key: string): Promise<string | null>;
|
|
60
|
+
eval(script: string, opts: {
|
|
61
|
+
keys: string[];
|
|
62
|
+
arguments: string[];
|
|
63
|
+
}): Promise<unknown>;
|
|
64
|
+
zRem(key: string, member: string): Promise<number>;
|
|
65
|
+
destroy?(): void;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Returns a connected Redis client for the given config, or null if Redis is
|
|
69
|
+
* unavailable/unhealthy (caller must fail open). Lazy-requires `redis` so a
|
|
70
|
+
* missing module degrades to null rather than erroring the node at load.
|
|
71
|
+
*/
|
|
72
|
+
export declare function getRedisClient(cfg: RedisConfig): Promise<RedisLike | null>;
|
|
73
|
+
/** Test-only: reset the client registry. */
|
|
74
|
+
export declare function __resetRedisRegistry(): void;
|
|
75
|
+
//# sourceMappingURL=client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../../../../../nodes/Autotask/helpers/http/redis/client.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,gBAAgB,iBAAiB,CAAC;AAE/C,MAAM,WAAW,WAAW;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,GAAG,EAAE,OAAO,CAAC;CACb;AAED;;;;GAIG;AACH,wBAAgB,6BAA6B,CAAC,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AI,IAAI,CAM3C"}
|
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.REDIS_KEY_PREFIX = void 0;
|
|
4
|
+
exports.getRedisConfigFromCredentials = getRedisConfigFromCredentials;
|
|
5
|
+
exports.redisKeyHash = redisKeyHash;
|
|
6
|
+
exports.redisUsageKeyHash = redisUsageKeyHash;
|
|
7
|
+
exports.scrubRedisSecret = scrubRedisSecret;
|
|
8
|
+
exports.getRedisClient = getRedisClient;
|
|
9
|
+
exports.__resetRedisRegistry = __resetRedisRegistry;
|
|
10
|
+
const service_1 = require("../../cache/service");
|
|
11
|
+
exports.REDIS_KEY_PREFIX = 'n8n-autotask';
|
|
12
|
+
/**
|
|
13
|
+
* Reads Redis connection settings from Autotask credentials. Returns null when disabled.
|
|
14
|
+
* Param is Record<string, unknown> so call sites can pass `credentials as unknown as Record<string, unknown>`
|
|
15
|
+
* and compile under strict mode (a typed interface param would reject `unknown`-valued fields).
|
|
16
|
+
*/
|
|
17
|
+
function getRedisConfigFromCredentials(creds) {
|
|
18
|
+
if (!creds || !creds['redisEnabled'] || !creds['redisHost']) {
|
|
19
|
+
return null;
|
|
20
|
+
}
|
|
21
|
+
const port = creds['redisPort'];
|
|
22
|
+
return {
|
|
23
|
+
host: String(creds['redisHost']),
|
|
24
|
+
port: typeof port === 'number' ? port : 6379,
|
|
25
|
+
password: creds['redisPassword'] ? String(creds['redisPassword']) : undefined,
|
|
26
|
+
tls: Boolean(creds['redisTls']),
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* 16-char hash of the THREAD-limit identity: {baseUrl, APIIntegrationcode}.
|
|
31
|
+
* Username + Secret intentionally excluded.
|
|
32
|
+
*
|
|
33
|
+
* Rationale: Autotask scopes the 3-concurrent thread limit (Itgenatr005) by
|
|
34
|
+
* (object endpoint + tracking identifier), where the tracking identifier IS the
|
|
35
|
+
* API integration code — NOT the API username (confirmed by Autotask's
|
|
36
|
+
* ThreadLimiting docs: the limit applies to "the combination of each unique API
|
|
37
|
+
* tracking identifier plus object endpoint call"). Two API users that share one
|
|
38
|
+
* integration code share ONE Autotask thread budget; they MUST therefore share one
|
|
39
|
+
* Redis semaphore. Splitting the thread key by Username would give each user its own
|
|
40
|
+
* 3-slot semaphore (6 effective slots for one budget) and re-introduce the exact
|
|
41
|
+
* Itgenatr005 over-subscription this feature fixes. This also matches the in-memory
|
|
42
|
+
* `endpointThreadTracker`, which keys on endpoint alone (no username dimension), so
|
|
43
|
+
* the fail-open fallback stays equivalent.
|
|
44
|
+
*
|
|
45
|
+
* Object key is `APIIntegrationcode` (verbatim credential field name) so a Phase-2 cache
|
|
46
|
+
* migration that hashes the same identity produces matching keys.
|
|
47
|
+
*/
|
|
48
|
+
function redisKeyHash(baseUrl, integrationCode) {
|
|
49
|
+
return (0, service_1.hashCachePayload)({ baseUrl, APIIntegrationcode: integrationCode }).slice(0, 16);
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* 16-char hash of the POLL/USAGE identity: {baseUrl, APIIntegrationcode, Username}.
|
|
53
|
+
* Username IS included here (and Secret still excluded — survives rotation).
|
|
54
|
+
*
|
|
55
|
+
* Rationale: the `poll` dedup lock and `usage` snapshot key carry the database-wide
|
|
56
|
+
* `ThresholdInformation` triple. Two distinct API users (different `Username`) on the
|
|
57
|
+
* same zone + integration code may point at DIFFERENT Autotask databases — a zone URL
|
|
58
|
+
* hosts many tenant databases, so baseUrl + integration code alone does not identify a
|
|
59
|
+
* database. Sharing the poll/usage key across them would serve one credential's usage
|
|
60
|
+
* snapshot for the other and suppress the other's own poll for the lock window
|
|
61
|
+
* (the cross-credential bleed Codex flagged). Adding Username scopes these keys per
|
|
62
|
+
* API user; when two users genuinely share one database the underlying number is
|
|
63
|
+
* identical, so this never harms correctness — it only prevents the bleed.
|
|
64
|
+
*
|
|
65
|
+
* NOTE: this hash is for poll/usage ONLY. The thread semaphore deliberately uses
|
|
66
|
+
* `redisKeyHash` (no Username) — see its rationale above. Do NOT swap them.
|
|
67
|
+
*/
|
|
68
|
+
function redisUsageKeyHash(baseUrl, integrationCode, username) {
|
|
69
|
+
return (0, service_1.hashCachePayload)({ baseUrl, APIIntegrationcode: integrationCode, Username: username }).slice(0, 16);
|
|
70
|
+
}
|
|
71
|
+
/** Replaces a known password substring with *** so it never reaches logs. */
|
|
72
|
+
function scrubRedisSecret(message, password) {
|
|
73
|
+
if (!password || password.length < 3)
|
|
74
|
+
return message;
|
|
75
|
+
return message.split(password).join('***');
|
|
76
|
+
}
|
|
77
|
+
const registry = new Map();
|
|
78
|
+
const RETRY_AFTER_FAIL_MS = 30000;
|
|
79
|
+
// Opaque per-password token for the registry key. The password is NOT hashed
|
|
80
|
+
// (a fast hash of a credential trips js/insufficient-password-hash) and never
|
|
81
|
+
// leaves the process — this token only distinguishes registry entries so two
|
|
82
|
+
// credentials sharing host:port:tls but using different Redis passwords never
|
|
83
|
+
// share a client. The password is already held in memory on RedisConfig; this
|
|
84
|
+
// adds no new exposure and is never logged, persisted, or transmitted.
|
|
85
|
+
const pwTokens = new Map();
|
|
86
|
+
function passwordToken(password) {
|
|
87
|
+
if (!password)
|
|
88
|
+
return 'nopw';
|
|
89
|
+
let token = pwTokens.get(password);
|
|
90
|
+
if (!token) {
|
|
91
|
+
token = `pw${pwTokens.size}`;
|
|
92
|
+
pwTokens.set(password, token);
|
|
93
|
+
}
|
|
94
|
+
return token;
|
|
95
|
+
}
|
|
96
|
+
function connectionKey(cfg) {
|
|
97
|
+
return `${cfg.host}:${cfg.port}:${cfg.tls ? 1 : 0}:${passwordToken(cfg.password)}`;
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Returns a connected Redis client for the given config, or null if Redis is
|
|
101
|
+
* unavailable/unhealthy (caller must fail open). Lazy-requires `redis` so a
|
|
102
|
+
* missing module degrades to null rather than erroring the node at load.
|
|
103
|
+
*/
|
|
104
|
+
async function getRedisClient(cfg) {
|
|
105
|
+
const key = connectionKey(cfg);
|
|
106
|
+
const existing = registry.get(key);
|
|
107
|
+
if (existing) {
|
|
108
|
+
if (existing.healthy && existing.client)
|
|
109
|
+
return existing.client;
|
|
110
|
+
if (existing.connecting)
|
|
111
|
+
return existing.connecting;
|
|
112
|
+
if (Date.now() - existing.lastFailedAt < RETRY_AFTER_FAIL_MS)
|
|
113
|
+
return null;
|
|
114
|
+
}
|
|
115
|
+
const entry = existing !== null && existing !== void 0 ? existing : { client: null, healthy: false, connecting: null, lastFailedAt: 0 };
|
|
116
|
+
registry.set(key, entry);
|
|
117
|
+
entry.connecting = (async () => {
|
|
118
|
+
try {
|
|
119
|
+
// Lazy require — keeps the node load-safe if `redis` is missing.
|
|
120
|
+
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
|
121
|
+
const { createClient } = require('redis');
|
|
122
|
+
// reconnectStrategy:false — first connection failure is final and connect() rejects.
|
|
123
|
+
// Without this, node-redis retries indefinitely and connect() never settles,
|
|
124
|
+
// causing every caller to hang until n8n's execution timeout (fail-open defeated).
|
|
125
|
+
// connectTimeout:3000 — bound the OS-default SYN timeout so a silently-dropped
|
|
126
|
+
// packet doesn't stall the promise for tens of seconds.
|
|
127
|
+
const socketOpts = cfg.tls
|
|
128
|
+
? { host: cfg.host, port: cfg.port, tls: true, reconnectStrategy: false, connectTimeout: 3000 }
|
|
129
|
+
: { host: cfg.host, port: cfg.port, reconnectStrategy: false, connectTimeout: 3000 };
|
|
130
|
+
const client = createClient({
|
|
131
|
+
socket: socketOpts,
|
|
132
|
+
password: cfg.password,
|
|
133
|
+
});
|
|
134
|
+
client.on('error', (err) => {
|
|
135
|
+
var _a, _b;
|
|
136
|
+
entry.healthy = false;
|
|
137
|
+
entry.lastFailedAt = Date.now();
|
|
138
|
+
try {
|
|
139
|
+
(_b = (_a = entry.client) === null || _a === void 0 ? void 0 : _a.destroy) === null || _b === void 0 ? void 0 : _b.call(_a);
|
|
140
|
+
}
|
|
141
|
+
catch { /* ignore */ }
|
|
142
|
+
entry.client = null;
|
|
143
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
144
|
+
console.warn(`[redis] client error: ${scrubRedisSecret(msg, cfg.password)}`);
|
|
145
|
+
});
|
|
146
|
+
await client.connect();
|
|
147
|
+
entry.client = client;
|
|
148
|
+
entry.healthy = true;
|
|
149
|
+
return entry.client;
|
|
150
|
+
}
|
|
151
|
+
catch (err) {
|
|
152
|
+
entry.healthy = false;
|
|
153
|
+
entry.lastFailedAt = Date.now();
|
|
154
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
155
|
+
console.warn(`[redis] connect failed: ${scrubRedisSecret(msg, cfg.password)}`);
|
|
156
|
+
return null;
|
|
157
|
+
}
|
|
158
|
+
finally {
|
|
159
|
+
entry.connecting = null;
|
|
160
|
+
}
|
|
161
|
+
})();
|
|
162
|
+
return entry.connecting;
|
|
163
|
+
}
|
|
164
|
+
/** Test-only: reset the client registry. */
|
|
165
|
+
function __resetRedisRegistry() {
|
|
166
|
+
var _a, _b;
|
|
167
|
+
for (const entry of registry.values()) {
|
|
168
|
+
try {
|
|
169
|
+
(_b = (_a = entry.client) === null || _a === void 0 ? void 0 : _a.destroy) === null || _b === void 0 ? void 0 : _b.call(_a);
|
|
170
|
+
}
|
|
171
|
+
catch { /* ignore */ }
|
|
172
|
+
}
|
|
173
|
+
registry.clear();
|
|
174
|
+
pwTokens.clear();
|
|
175
|
+
}
|
|
176
|
+
//# sourceMappingURL=client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.js","sourceRoot":"","sources":["../../../../../../nodes/Autotask/helpers/http/redis/client.ts"],"names":[],"mappings":";;;AAiBA,sEAWC;AAqBD,oCAEC;AAmBD,8CAEC;AAGD,4CAGC;AAoDD,wCAuDC;AAGD,oDAMC;AAjMD,iDAAuD;AAE1C,QAAA,gBAAgB,GAAG,cAAc,CAAC;AAS/C;;;;GAIG;AACH,SAAgB,6BAA6B,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AAED,4CAA4C;AAC5C,SAAgB,oBAAoB;;IACnC,KAAK,MAAM,KAAK,IAAI,QAAQ,CAAC,MAAM,EAAE,EAAE,CAAC;QACvC,IAAI,CAAC;YAAC,MAAA,MAAA,KAAK,CAAC,MAAM,0CAAE,OAAO,kDAAI,CAAC;QAAC,CAAC;QAAC,MAAM,CAAC,CAAC,YAAY,CAAC,CAAC;IAC1D,CAAC;IACD,QAAQ,CAAC,KAAK,EAAE,CAAC;IACjB,QAAQ,CAAC,KAAK,EAAE,CAAC;AAClB,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { RedisLike } from './client';
|
|
2
|
+
export interface AcquireResult {
|
|
3
|
+
acquired: boolean;
|
|
4
|
+
member: string;
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* Attempts to acquire one concurrency lease on `key`.
|
|
8
|
+
* @param leaseMs lease lifetime; the lease score = now + leaseMs (use <=0 in tests to pre-expire)
|
|
9
|
+
* @param keyTtlMs whole-key safety TTL (should exceed leaseMs)
|
|
10
|
+
*/
|
|
11
|
+
export declare function acquireThreadSlot(client: RedisLike, key: string, limit: number, leaseMs: number, keyTtlMs: number): Promise<AcquireResult>;
|
|
12
|
+
/** Releases a previously-acquired lease. Idempotent (ZREM of an absent member is a no-op). */
|
|
13
|
+
export declare function releaseThreadSlot(client: RedisLike, key: string, member: string): Promise<void>;
|
|
14
|
+
//# sourceMappingURL=threadStore.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"threadStore.d.ts","sourceRoot":"","sources":["../../../../../../nodes/Autotask/helpers/http/redis/threadStore.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AA2B1C,MAAM,WAAW,aAAa;IAC7B,QAAQ,EAAE,OAAO,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC;CACf;AAED;;;;GAIG;AACH,wBAAsB,iBAAiB,CACtC,MAAM,EAAE,SAAS,EACjB,GAAG,EAAE,MAAM,EACX,KAAK,EAAE,MAAM,EACb,OAAO,EAAE,MAAM,EACf,QAAQ,EAAE,MAAM,GACd,OAAO,CAAC,aAAa,CAAC,CAcxB;AAED,8FAA8F;AAC9F,wBAAsB,iBAAiB,CACtC,MAAM,EAAE,SAAS,EACjB,GAAG,EAAE,MAAM,EACX,MAAM,EAAE,MAAM,GACZ,OAAO,CAAC,IAAI,CAAC,CAEf"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.acquireThreadSlot = acquireThreadSlot;
|
|
4
|
+
exports.releaseThreadSlot = releaseThreadSlot;
|
|
5
|
+
/**
|
|
6
|
+
* Atomic acquire: evict expired leases, then add our lease iff under the limit.
|
|
7
|
+
* KEYS[1] = semaphore key
|
|
8
|
+
* ARGV[1] = now (ms) ARGV[2] = leaseExpiry score (now + leaseMs)
|
|
9
|
+
* ARGV[3] = limit ARGV[4] = member (uuid)
|
|
10
|
+
* ARGV[5] = whole-key safety TTL (ms)
|
|
11
|
+
* Returns 1 if acquired, 0 if full.
|
|
12
|
+
*/
|
|
13
|
+
const ACQUIRE_SCRIPT = `
|
|
14
|
+
redis.call('ZREMRANGEBYSCORE', KEYS[1], 0, ARGV[1])
|
|
15
|
+
if redis.call('ZCARD', KEYS[1]) < tonumber(ARGV[3]) then
|
|
16
|
+
redis.call('ZADD', KEYS[1], ARGV[2], ARGV[4])
|
|
17
|
+
redis.call('PEXPIRE', KEYS[1], tonumber(ARGV[5]))
|
|
18
|
+
return 1
|
|
19
|
+
end
|
|
20
|
+
return 0
|
|
21
|
+
`;
|
|
22
|
+
let counter = 0;
|
|
23
|
+
function newMember() {
|
|
24
|
+
// uuid not required — uniqueness within a process+time is enough; vary by counter+hrtime.
|
|
25
|
+
counter += 1;
|
|
26
|
+
return `${process.pid}-${counter}-${process.hrtime.bigint().toString()}`;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Attempts to acquire one concurrency lease on `key`.
|
|
30
|
+
* @param leaseMs lease lifetime; the lease score = now + leaseMs (use <=0 in tests to pre-expire)
|
|
31
|
+
* @param keyTtlMs whole-key safety TTL (should exceed leaseMs)
|
|
32
|
+
*/
|
|
33
|
+
async function acquireThreadSlot(client, key, limit, leaseMs, keyTtlMs) {
|
|
34
|
+
const now = Date.now();
|
|
35
|
+
const member = newMember();
|
|
36
|
+
const res = await client.eval(ACQUIRE_SCRIPT, {
|
|
37
|
+
keys: [key],
|
|
38
|
+
arguments: [
|
|
39
|
+
String(now),
|
|
40
|
+
String(now + leaseMs),
|
|
41
|
+
String(limit),
|
|
42
|
+
member,
|
|
43
|
+
String(keyTtlMs),
|
|
44
|
+
],
|
|
45
|
+
});
|
|
46
|
+
return { acquired: res === 1, member };
|
|
47
|
+
}
|
|
48
|
+
/** Releases a previously-acquired lease. Idempotent (ZREM of an absent member is a no-op). */
|
|
49
|
+
async function releaseThreadSlot(client, key, member) {
|
|
50
|
+
await client.zRem(key, member);
|
|
51
|
+
}
|
|
52
|
+
//# sourceMappingURL=threadStore.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"threadStore.js","sourceRoot":"","sources":["../../../../../../nodes/Autotask/helpers/http/redis/threadStore.ts"],"names":[],"mappings":";;AAqCA,8CAoBC;AAGD,8CAMC;AAhED;;;;;;;GAOG;AACH,MAAM,cAAc,GAAG;;;;;;;;CAQtB,CAAC;AAEF,IAAI,OAAO,GAAG,CAAC,CAAC;AAChB,SAAS,SAAS;IACjB,0FAA0F;IAC1F,OAAO,IAAI,CAAC,CAAC;IACb,OAAO,GAAG,OAAO,CAAC,GAAG,IAAI,OAAO,IAAI,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,EAAE,CAAC;AAC1E,CAAC;AAOD;;;;GAIG;AACI,KAAK,UAAU,iBAAiB,CACtC,MAAiB,EACjB,GAAW,EACX,KAAa,EACb,OAAe,EACf,QAAgB;IAEhB,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;IACvB,MAAM,MAAM,GAAG,SAAS,EAAE,CAAC;IAC3B,MAAM,GAAG,GAAG,MAAM,MAAM,CAAC,IAAI,CAAC,cAAc,EAAE;QAC7C,IAAI,EAAE,CAAC,GAAG,CAAC;QACX,SAAS,EAAE;YACV,MAAM,CAAC,GAAG,CAAC;YACX,MAAM,CAAC,GAAG,GAAG,OAAO,CAAC;YACrB,MAAM,CAAC,KAAK,CAAC;YACb,MAAM;YACN,MAAM,CAAC,QAAQ,CAAC;SAChB;KACD,CAAC,CAAC;IACH,OAAO,EAAE,QAAQ,EAAE,GAAG,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;AACxC,CAAC;AAED,8FAA8F;AACvF,KAAK,UAAU,iBAAiB,CACtC,MAAiB,EACjB,GAAW,EACX,MAAc;IAEd,MAAM,MAAM,CAAC,IAAI,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC;AAChC,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { RedisLike } from './client';
|
|
2
|
+
export interface SharedUsage {
|
|
3
|
+
externalRequestThreshold: number;
|
|
4
|
+
requestThresholdTimeframe: number;
|
|
5
|
+
currentTimeframeRequestCount: number;
|
|
6
|
+
syncedAt: number;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Returns true if this caller won the poll lock (i.e. nobody polled within `windowMs`).
|
|
10
|
+
* Implemented as SET key 1 NX PX windowMs — one round-trip, no Lua, no winner election.
|
|
11
|
+
*/
|
|
12
|
+
export declare function tryAcquirePollLock(client: RedisLike, hash: string, windowMs: number): Promise<boolean>;
|
|
13
|
+
/** Stores the latest ThresholdInformation snapshot for cluster-wide reads. */
|
|
14
|
+
export declare function writeUsage(client: RedisLike, hash: string, usage: SharedUsage, ttlMs: number): Promise<void>;
|
|
15
|
+
/** Reads the shared usage snapshot, or null if absent/unparseable. */
|
|
16
|
+
export declare function readUsage(client: RedisLike, hash: string): Promise<SharedUsage | null>;
|
|
17
|
+
//# sourceMappingURL=usageStore.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"usageStore.d.ts","sourceRoot":"","sources":["../../../../../../nodes/Autotask/helpers/http/redis/usageStore.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAG1C,MAAM,WAAW,WAAW;IAC3B,wBAAwB,EAAE,MAAM,CAAC;IACjC,yBAAyB,EAAE,MAAM,CAAC;IAClC,4BAA4B,EAAE,MAAM,CAAC;IACrC,QAAQ,EAAE,MAAM,CAAC;CACjB;AASD;;;GAGG;AACH,wBAAsB,kBAAkB,CACvC,MAAM,EAAE,SAAS,EACjB,IAAI,EAAE,MAAM,EACZ,QAAQ,EAAE,MAAM,GACd,OAAO,CAAC,OAAO,CAAC,CAGlB;AAED,8EAA8E;AAC9E,wBAAsB,UAAU,CAC/B,MAAM,EAAE,SAAS,EACjB,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,WAAW,EAClB,KAAK,EAAE,MAAM,GACX,OAAO,CAAC,IAAI,CAAC,CAEf;AAED,sEAAsE;AACtE,wBAAsB,SAAS,CAAC,MAAM,EAAE,SAAS,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,GAAG,IAAI,CAAC,CAQ5F"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.tryAcquirePollLock = tryAcquirePollLock;
|
|
4
|
+
exports.writeUsage = writeUsage;
|
|
5
|
+
exports.readUsage = readUsage;
|
|
6
|
+
const client_1 = require("./client");
|
|
7
|
+
function pollKey(hash) {
|
|
8
|
+
return `${client_1.REDIS_KEY_PREFIX}:poll:${hash}`;
|
|
9
|
+
}
|
|
10
|
+
function usageKey(hash) {
|
|
11
|
+
return `${client_1.REDIS_KEY_PREFIX}:usage:${hash}`;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Returns true if this caller won the poll lock (i.e. nobody polled within `windowMs`).
|
|
15
|
+
* Implemented as SET key 1 NX PX windowMs — one round-trip, no Lua, no winner election.
|
|
16
|
+
*/
|
|
17
|
+
async function tryAcquirePollLock(client, hash, windowMs) {
|
|
18
|
+
const res = await client.set(pollKey(hash), '1', { NX: true, PX: windowMs });
|
|
19
|
+
return res === 'OK';
|
|
20
|
+
}
|
|
21
|
+
/** Stores the latest ThresholdInformation snapshot for cluster-wide reads. */
|
|
22
|
+
async function writeUsage(client, hash, usage, ttlMs) {
|
|
23
|
+
await client.set(usageKey(hash), JSON.stringify(usage), { PX: ttlMs });
|
|
24
|
+
}
|
|
25
|
+
/** Reads the shared usage snapshot, or null if absent/unparseable. */
|
|
26
|
+
async function readUsage(client, hash) {
|
|
27
|
+
const raw = await client.get(usageKey(hash));
|
|
28
|
+
if (!raw)
|
|
29
|
+
return null;
|
|
30
|
+
try {
|
|
31
|
+
return JSON.parse(raw);
|
|
32
|
+
}
|
|
33
|
+
catch {
|
|
34
|
+
return null;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
//# sourceMappingURL=usageStore.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"usageStore.js","sourceRoot":"","sources":["../../../../../../nodes/Autotask/helpers/http/redis/usageStore.ts"],"names":[],"mappings":";;AAqBA,gDAOC;AAGD,gCAOC;AAGD,8BAQC;AAhDD,qCAA4C;AAS5C,SAAS,OAAO,CAAC,IAAY;IAC5B,OAAO,GAAG,yBAAgB,SAAS,IAAI,EAAE,CAAC;AAC3C,CAAC;AACD,SAAS,QAAQ,CAAC,IAAY;IAC7B,OAAO,GAAG,yBAAgB,UAAU,IAAI,EAAE,CAAC;AAC5C,CAAC;AAED;;;GAGG;AACI,KAAK,UAAU,kBAAkB,CACvC,MAAiB,EACjB,IAAY,EACZ,QAAgB;IAEhB,MAAM,GAAG,GAAG,MAAM,MAAM,CAAC,GAAG,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,GAAG,EAAE,EAAE,EAAE,EAAE,IAAI,EAAE,EAAE,EAAE,QAAQ,EAAE,CAAC,CAAC;IAC7E,OAAO,GAAG,KAAK,IAAI,CAAC;AACrB,CAAC;AAED,8EAA8E;AACvE,KAAK,UAAU,UAAU,CAC/B,MAAiB,EACjB,IAAY,EACZ,KAAkB,EAClB,KAAa;IAEb,MAAM,MAAM,CAAC,GAAG,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,EAAE,EAAE,EAAE,EAAE,KAAK,EAAE,CAAC,CAAC;AACxE,CAAC;AAED,sEAAsE;AAC/D,KAAK,UAAU,SAAS,CAAC,MAAiB,EAAE,IAAY;IAC9D,MAAM,GAAG,GAAG,MAAM,MAAM,CAAC,GAAG,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC;IAC7C,IAAI,CAAC,GAAG;QAAE,OAAO,IAAI,CAAC;IACtB,IAAI,CAAC;QACJ,OAAO,IAAI,CAAC,KAAK,CAAC,GAAG,CAAgB,CAAC;IACvC,CAAC;IAAC,MAAM,CAAC;QACR,OAAO,IAAI,CAAC;IACb,CAAC;AACF,CAAC"}
|
|
@@ -1,6 +1,20 @@
|
|
|
1
1
|
import type { IExecuteFunctions, IHookFunctions, ILoadOptionsFunctions, JsonObject } from 'n8n-workflow';
|
|
2
2
|
import type { IRequestConfig } from '../../types';
|
|
3
3
|
import type { OperationType } from '../../types/base/entity-types';
|
|
4
|
+
import { type RedisLike } from './redis/client';
|
|
5
|
+
/**
|
|
6
|
+
* Acquires one concurrency slot for `endpoint` via Redis when healthy, else the
|
|
7
|
+
* in-memory tracker. Returns a release function.
|
|
8
|
+
*
|
|
9
|
+
* Behaviour when Redis is healthy but the semaphore stays full past the maxWait
|
|
10
|
+
* window: THROW a synthetic, retryable thread-limit error (Option A). This keeps
|
|
11
|
+
* the semaphore applying backpressure exactly when contention is highest instead
|
|
12
|
+
* of firing a doomed request at Autotask (which would burn a request against the
|
|
13
|
+
* db-wide budget and, via the retry handler, re-enter this function and bypass
|
|
14
|
+
* again). The throw only happens on the Redis-full-after-maxWait path — the
|
|
15
|
+
* Redis-error fall-through and the in-memory path remain fail-open and unchanged.
|
|
16
|
+
*/
|
|
17
|
+
export declare function acquireConcurrencySlot(redis: RedisLike | null, threadKey: string, inMemoryEndpoint: string): Promise<() => Promise<void>>;
|
|
4
18
|
interface IUrlOptions {
|
|
5
19
|
parentId?: string | number;
|
|
6
20
|
entityId?: string | number;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"request.d.ts","sourceRoot":"","sources":["../../../../../nodes/Autotask/helpers/http/request.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACX,iBAAiB,EACjB,cAAc,EACd,qBAAqB,EAErB,UAAU,EAEV,MAAM,cAAc,CAAC;AAItB,OAAO,KAAK,EAAE,cAAc,EAAwB,MAAM,aAAa,CAAC;AAMxE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;
|
|
1
|
+
{"version":3,"file":"request.d.ts","sourceRoot":"","sources":["../../../../../nodes/Autotask/helpers/http/request.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACX,iBAAiB,EACjB,cAAc,EACd,qBAAqB,EAErB,UAAU,EAEV,MAAM,cAAc,CAAC;AAItB,OAAO,KAAK,EAAE,cAAc,EAAwB,MAAM,aAAa,CAAC;AAMxE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AAMnE,OAAO,EAAkF,KAAK,SAAS,EAAE,MAAM,gBAAgB,CAAC;AA0BhI;;;;;;;;;;;GAWG;AACH,wBAAsB,sBAAsB,CAC3C,KAAK,EAAE,SAAS,GAAG,IAAI,EACvB,SAAS,EAAE,MAAM,EACjB,gBAAgB,EAAE,MAAM,G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