@friggframework/core 2.0.0-next.128 → 2.0.0-next.129

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.
Files changed (43) hide show
  1. package/CLAUDE.md +166 -7
  2. package/core/CLAUDE.md +57 -1
  3. package/core/Worker.js +420 -9
  4. package/core/create-handler.js +20 -0
  5. package/core/index.js +6 -0
  6. package/core/invocation-deadline.js +91 -0
  7. package/core/invocation-scope.js +30 -24
  8. package/core/rate-limited-response.js +27 -0
  9. package/errors/fetch-error.js +10 -6
  10. package/errors/index.js +2 -0
  11. package/errors/rate-limit-error.js +46 -0
  12. package/handlers/app-handler-helpers.js +15 -0
  13. package/handlers/backend-utils.js +75 -1
  14. package/handlers/workers/integration-defined-workers.js +2 -0
  15. package/index.js +18 -0
  16. package/infrastructure/scheduler/eventbridge-scheduler-adapter.js +2 -0
  17. package/integrations/repositories/integration-repository-documentdb.js +59 -10
  18. package/integrations/repositories/integration-repository-interface.js +50 -7
  19. package/integrations/repositories/integration-repository-mongo.js +88 -16
  20. package/integrations/repositories/integration-repository-postgres.js +89 -16
  21. package/integrations/repositories/message-item-shared.js +17 -0
  22. package/integrations/tests/doubles/prisma-message-row.js +24 -0
  23. package/integrations/tests/doubles/test-integration-repository.js +32 -2
  24. package/integrations/use-cases/clear-rate-limit-wait.js +28 -0
  25. package/integrations/use-cases/index.js +7 -1
  26. package/integrations/use-cases/record-rate-limit-message.js +104 -0
  27. package/integrations/use-cases/record-rate-limit-wait.js +36 -0
  28. package/integrations/use-cases/update-integration-messages.js +28 -9
  29. package/logs/serialize.js +15 -0
  30. package/modules/requester/oauth-2.js +8 -0
  31. package/modules/requester/rate-limit/index.js +4 -0
  32. package/modules/requester/rate-limit/parsers.js +249 -0
  33. package/modules/requester/rate-limit/policy.js +321 -0
  34. package/modules/requester/requester.js +187 -9
  35. package/package.json +7 -6
  36. package/queues/queue-deferral.js +80 -0
  37. package/queues/queue-delivery.js +1 -0
  38. package/queues/queuer-util.js +1 -1
  39. package/types/core/consumer.fixture.ts +12 -0
  40. package/types/core/index.d.ts +84 -0
  41. package/types/errors/index.d.ts +47 -0
  42. package/types/integrations/index.d.ts +25 -4
  43. package/types/module-plugin/index.d.ts +45 -0
@@ -0,0 +1,249 @@
1
+ const MAX_HINT_WAIT_MS = 366 * 24 * 60 * 60 * 1000;
2
+
3
+ const SECONDS_PATTERN = /^\d+(?:\.\d+)?$/;
4
+ const HAS_LETTER = /[A-Za-z]/;
5
+ const EPOCH_SECONDS_MIN = 1e9;
6
+ const EPOCH_MILLISECONDS_MIN = 1e12;
7
+
8
+ const RESET_HEADERS = [
9
+ 'x-ratelimit-reset',
10
+ 'ratelimit-reset',
11
+ 'x-rate-limit-reset',
12
+ ];
13
+ const REMAINING_HEADERS = [
14
+ 'x-ratelimit-remaining',
15
+ 'ratelimit-remaining',
16
+ 'x-rate-limit-remaining',
17
+ ];
18
+
19
+ const isMissing = (value) => value === undefined || value === null;
20
+
21
+ function readEntries(headers, wanted) {
22
+ for (const entry of headers) {
23
+ if (Array.isArray(entry) && String(entry[0]).toLowerCase() === wanted) {
24
+ return entry[1];
25
+ }
26
+ }
27
+ return undefined;
28
+ }
29
+
30
+ function readKeys(headers, wanted) {
31
+ for (const key of Object.keys(headers)) {
32
+ if (key.toLowerCase() === wanted) return headers[key];
33
+ }
34
+ return undefined;
35
+ }
36
+
37
+ function headerValue(headers, name) {
38
+ if (!headers || typeof headers !== 'object') return undefined;
39
+ const wanted = name.toLowerCase();
40
+ const hasGet = typeof headers.get === 'function';
41
+
42
+ let value;
43
+ if (hasGet) {
44
+ value = headers.get(name);
45
+ if (isMissing(value)) value = headers.get(wanted);
46
+ }
47
+ if (isMissing(value) && typeof headers[Symbol.iterator] === 'function') {
48
+ value = readEntries(headers, wanted);
49
+ }
50
+ if (isMissing(value) && !hasGet && !Array.isArray(headers)) {
51
+ value = readKeys(headers, wanted);
52
+ }
53
+ if (Array.isArray(value)) value = value[0];
54
+ if (isMissing(value)) return undefined;
55
+
56
+ const text = String(value).trim();
57
+ return text === '' ? undefined : text;
58
+ }
59
+
60
+ function definedOnly(fields) {
61
+ const result = {};
62
+ for (const [key, value] of Object.entries(fields)) {
63
+ if (value !== undefined) result[key] = value;
64
+ }
65
+ return result;
66
+ }
67
+
68
+ function hintFromWait(waitMs, now, { source = 'header', ...extra } = {}) {
69
+ if (!Number.isFinite(waitMs) || waitMs < 0 || waitMs > MAX_HINT_WAIT_MS) {
70
+ return null;
71
+ }
72
+ return {
73
+ waitMs,
74
+ retryAt: new Date(now + waitMs),
75
+ ...definedOnly(extra),
76
+ source,
77
+ };
78
+ }
79
+
80
+ function hintFromRetryAt(retryAt, now, { source = 'header', ...extra } = {}) {
81
+ const at = retryAt instanceof Date ? retryAt.getTime() : Number.NaN;
82
+ if (Number.isNaN(at)) return null;
83
+ const waitMs = Math.max(0, at - now);
84
+ if (waitMs > MAX_HINT_WAIT_MS) return null;
85
+ return { waitMs, retryAt: new Date(at), ...definedOnly(extra), source };
86
+ }
87
+
88
+ function parseDate(text) {
89
+ if (!HAS_LETTER.test(text)) return null;
90
+ const at = Date.parse(text);
91
+ return Number.isNaN(at) ? null : new Date(at);
92
+ }
93
+
94
+ function parseRetryAfter(value, { now = Date.now() } = {}) {
95
+ if (isMissing(value)) return null;
96
+ const text = String(value).trim();
97
+ if (text === '') return null;
98
+ if (SECONDS_PATTERN.test(text))
99
+ return hintFromWait(Number(text) * 1000, now);
100
+ const date = parseDate(text);
101
+ return date ? hintFromRetryAt(date, now) : null;
102
+ }
103
+
104
+ function numberOrUndefined(text) {
105
+ if (text === undefined) return undefined;
106
+ const number = Number(text);
107
+ return Number.isFinite(number) ? number : undefined;
108
+ }
109
+
110
+ function firstHeader(headers, names) {
111
+ for (const name of names) {
112
+ const value = headerValue(headers, name);
113
+ if (value !== undefined) return value;
114
+ }
115
+ return undefined;
116
+ }
117
+
118
+ function parseResetValue(text, now, deltaToMs, extra) {
119
+ if (SECONDS_PATTERN.test(text)) {
120
+ const number = Number(text);
121
+ if (number >= EPOCH_MILLISECONDS_MIN) {
122
+ return hintFromRetryAt(new Date(number), now, extra);
123
+ }
124
+ if (number >= EPOCH_SECONDS_MIN) {
125
+ return hintFromRetryAt(new Date(number * 1000), now, extra);
126
+ }
127
+ return hintFromWait(number * deltaToMs, now, extra);
128
+ }
129
+ const date = parseDate(text);
130
+ return date ? hintFromRetryAt(date, now, extra) : null;
131
+ }
132
+
133
+ function parseResetHeaders(
134
+ headers,
135
+ { now = Date.now(), resetDeltaUnit = 's' } = {}
136
+ ) {
137
+ const remaining = numberOrUndefined(
138
+ firstHeader(headers, REMAINING_HEADERS)
139
+ );
140
+ const extra = { remaining };
141
+ const deltaToMs = resetDeltaUnit === 'ms' ? 1 : 1000;
142
+
143
+ const after = headerValue(headers, 'x-ratelimit-reset-after');
144
+ if (after !== undefined && SECONDS_PATTERN.test(after)) {
145
+ return hintFromWait(Number(after) * deltaToMs, now, extra);
146
+ }
147
+
148
+ for (const name of RESET_HEADERS) {
149
+ const value = headerValue(headers, name);
150
+ if (value === undefined) continue;
151
+ const hint = parseResetValue(value, now, deltaToMs, extra);
152
+ if (hint) return hint;
153
+ }
154
+ return null;
155
+ }
156
+
157
+ function splitList(text) {
158
+ const items = [];
159
+ let current = '';
160
+ let quoted = false;
161
+ for (const char of text) {
162
+ if (char === '"') quoted = !quoted;
163
+ if (char === ',' && !quoted) {
164
+ items.push(current);
165
+ current = '';
166
+ } else {
167
+ current += char;
168
+ }
169
+ }
170
+ items.push(current);
171
+ return items.map((item) => item.trim()).filter(Boolean);
172
+ }
173
+
174
+ function parseStructuredItem(item) {
175
+ const [head, ...params] = item.split(';').map((part) => part.trim());
176
+ const values = {};
177
+ for (const param of params) {
178
+ const [key, raw] = param.split('=').map((part) => part.trim());
179
+ if (key) values[key] = numberOrUndefined(raw);
180
+ }
181
+ const name = head.replace(/^"|"$/g, '');
182
+ return {
183
+ name: name || undefined,
184
+ remaining: values.r,
185
+ waitSeconds: values.t,
186
+ };
187
+ }
188
+
189
+ function pickStructured(items) {
190
+ const usable = items.filter(
191
+ (item) => Number.isFinite(item.waitSeconds) && item.waitSeconds >= 0
192
+ );
193
+ usable.sort((a, b) => {
194
+ const byRemaining =
195
+ (a.remaining ?? Infinity) - (b.remaining ?? Infinity);
196
+ if (byRemaining !== 0 && !Number.isNaN(byRemaining)) return byRemaining;
197
+ return b.waitSeconds - a.waitSeconds;
198
+ });
199
+ return usable[0];
200
+ }
201
+
202
+ function readKeyValue(text, key) {
203
+ const match = new RegExp(
204
+ String.raw`(?:^|[,;\s])${key}\s*=\s*([^,;\s]+)`,
205
+ 'i'
206
+ ).exec(text);
207
+ return match ? match[1] : undefined;
208
+ }
209
+
210
+ function parseIetfRateLimit(headers, { now = Date.now() } = {}) {
211
+ const raw = headerValue(headers, 'ratelimit');
212
+ if (raw === undefined) return null;
213
+ const policyHeader = headerValue(headers, 'ratelimit-policy');
214
+
215
+ if (/;\s*t\s*=/.test(raw)) {
216
+ const chosen = pickStructured(splitList(raw).map(parseStructuredItem));
217
+ if (!chosen) return null;
218
+ return hintFromWait(chosen.waitSeconds * 1000, now, {
219
+ remaining: chosen.remaining,
220
+ policy: chosen.name ?? policyHeader,
221
+ });
222
+ }
223
+
224
+ const reset = readKeyValue(raw, 'reset');
225
+ if (reset === undefined || !SECONDS_PATTERN.test(reset)) return null;
226
+ return hintFromWait(Number(reset) * 1000, now, {
227
+ remaining: numberOrUndefined(readKeyValue(raw, 'remaining')),
228
+ policy: policyHeader,
229
+ });
230
+ }
231
+
232
+ const BUILT_IN_PARSERS = {
233
+ retryAfter: (headers, { now } = {}) =>
234
+ parseRetryAfter(headerValue(headers, 'retry-after'), { now }),
235
+ resetHeaders: parseResetHeaders,
236
+ ietf: parseIetfRateLimit,
237
+ };
238
+
239
+ module.exports = {
240
+ BUILT_IN_PARSERS,
241
+ MAX_HINT_WAIT_MS,
242
+ definedOnly,
243
+ headerValue,
244
+ hintFromRetryAt,
245
+ hintFromWait,
246
+ parseIetfRateLimit,
247
+ parseResetHeaders,
248
+ parseRetryAfter,
249
+ };
@@ -0,0 +1,321 @@
1
+ const {
2
+ BUILT_IN_PARSERS,
3
+ definedOnly,
4
+ hintFromRetryAt,
5
+ hintFromWait,
6
+ } = require('./parsers');
7
+
8
+ const DEFAULT_PARSERS = ['retryAfter', 'resetHeaders', 'ietf'];
9
+ const RESET_DELTA_UNITS = ['s', 'ms'];
10
+ const MIN_HINTED_WAIT_MS = 1_000;
11
+ const JITTER_MAX_MS = 1_000;
12
+ const JITTER_RATIO = 0.1;
13
+
14
+ const REASONS = new Set([
15
+ 'burst',
16
+ 'daily',
17
+ 'monthly',
18
+ 'concurrency',
19
+ 'unknown',
20
+ ]);
21
+ const CLASSIFY_SOURCES = new Set(['header', 'body', 'static']);
22
+ const SCOPES = new Set(['credential', 'entity', 'app']);
23
+
24
+ const normalizedPolicies = new WeakSet();
25
+ const policiesByClass = new WeakMap();
26
+
27
+ const isObject = (value) => value !== null && typeof value === 'object';
28
+ const isThenable = (value) => typeof value?.then === 'function';
29
+
30
+ function isPlainObject(value) {
31
+ if (!isObject(value) || Array.isArray(value)) return false;
32
+ const prototype = Object.getPrototypeOf(value);
33
+ return prototype === Object.prototype || prototype === null;
34
+ }
35
+
36
+ function readParsers(raw, owner) {
37
+ if (!Array.isArray(raw.parsers)) return [...DEFAULT_PARSERS];
38
+ for (const name of raw.parsers) {
39
+ if (!Object.hasOwn(BUILT_IN_PARSERS, name)) {
40
+ throw new TypeError(
41
+ `${owner}.rateLimit.parsers: unknown parser "${String(
42
+ name
43
+ )}"; known: ${Object.keys(BUILT_IN_PARSERS).join(', ')}`
44
+ );
45
+ }
46
+ }
47
+ return [...raw.parsers];
48
+ }
49
+
50
+ function readResetDeltaUnit(raw, owner) {
51
+ const unit = raw.resetDeltaUnit;
52
+ if (unit === undefined || RESET_DELTA_UNITS.includes(unit)) return unit;
53
+ throw new TypeError(
54
+ `${owner}.rateLimit.resetDeltaUnit: unknown unit "${String(
55
+ unit
56
+ )}"; known: ${RESET_DELTA_UNITS.join(', ')}`
57
+ );
58
+ }
59
+
60
+ function normalizePolicy(raw, owner) {
61
+ if (!isPlainObject(raw)) return undefined;
62
+
63
+ const policy = {
64
+ scope:
65
+ SCOPES.has(raw.scope) || typeof raw.scope === 'function'
66
+ ? raw.scope
67
+ : 'entity',
68
+ parsers: readParsers(raw, owner),
69
+ };
70
+ if (typeof raw.classify === 'function') {
71
+ policy.classify = (signal) => raw.classify(signal);
72
+ }
73
+ const resetDeltaUnit = readResetDeltaUnit(raw, owner);
74
+ if (resetDeltaUnit) policy.resetDeltaUnit = resetDeltaUnit;
75
+ if (Number.isFinite(raw.minRetryAfterMs) && raw.minRetryAfterMs >= 0) {
76
+ policy.minRetryAfterMs = raw.minRetryAfterMs;
77
+ }
78
+ if (Number.isInteger(raw.maxConcurrency) && raw.maxConcurrency > 0) {
79
+ policy.maxConcurrency = raw.maxConcurrency;
80
+ }
81
+ if (Array.isArray(raw.windows)) policy.windows = raw.windows;
82
+ if (isPlainObject(raw.userHints)) policy.userHints = raw.userHints;
83
+
84
+ normalizedPolicies.add(policy);
85
+ return policy;
86
+ }
87
+
88
+ function readRateLimitPolicy(ctor) {
89
+ if (typeof ctor !== 'function') return undefined;
90
+ if (policiesByClass.has(ctor)) return policiesByClass.get(ctor);
91
+ const policy = normalizePolicy(ctor.rateLimit, ctor.name || 'Requester');
92
+ policiesByClass.set(ctor, policy);
93
+ return policy;
94
+ }
95
+
96
+ function asPolicy(value) {
97
+ if (!isObject(value)) return undefined;
98
+ if (normalizedPolicies.has(value)) return value;
99
+ return normalizePolicy(value, 'policy');
100
+ }
101
+
102
+ function computeScopeKey(policy, requester) {
103
+ const label = requester?._telemetryModuleLabel?.() ?? 'unknown';
104
+ const scope = policy?.scope ?? 'entity';
105
+ const delegate = requester?.delegate;
106
+
107
+ if (scope === 'app') return `${label}:app`;
108
+ if (scope === 'entity') {
109
+ const id = delegate?.entity?.id;
110
+ return id === undefined || id === null
111
+ ? undefined
112
+ : `${label}:entity:${id}`;
113
+ }
114
+ if (scope === 'credential') {
115
+ const credential = delegate?.credential;
116
+ const id =
117
+ credential?.id ??
118
+ (typeof credential === 'string' ? credential : undefined);
119
+ return id === undefined || id === null
120
+ ? undefined
121
+ : `${label}:credential:${id}`;
122
+ }
123
+ if (typeof scope === 'function') {
124
+ try {
125
+ const value = scope(requester);
126
+ return typeof value === 'string' || Number.isFinite(value)
127
+ ? `${label}:custom:${value}`
128
+ : undefined;
129
+ } catch {
130
+ return undefined;
131
+ }
132
+ }
133
+ return undefined;
134
+ }
135
+
136
+ function toDate(value) {
137
+ if (value === undefined || value === null) return null;
138
+ const date = value instanceof Date ? value : new Date(value);
139
+ return Number.isNaN(date.getTime()) ? null : date;
140
+ }
141
+
142
+ function normalizeClassified(raw, now) {
143
+ if (!isObject(raw)) return null;
144
+ const retryAt = toDate(raw.retryAt);
145
+ if (!REASONS.has(raw.reason) && !Number.isFinite(raw.waitMs) && !retryAt) {
146
+ return null;
147
+ }
148
+
149
+ const extra = {
150
+ reason: REASONS.has(raw.reason) ? raw.reason : 'unknown',
151
+ policy: typeof raw.policy === 'string' ? raw.policy : undefined,
152
+ remaining: Number.isFinite(raw.remaining) ? raw.remaining : undefined,
153
+ source: CLASSIFY_SOURCES.has(raw.source) ? raw.source : 'body',
154
+ };
155
+
156
+ let hint = retryAt ? hintFromRetryAt(retryAt, now, extra) : null;
157
+ if (!hint && Number.isFinite(raw.waitMs)) {
158
+ hint = hintFromWait(raw.waitMs, now, extra);
159
+ }
160
+ return {
161
+ reason: extra.reason,
162
+ policy: extra.policy,
163
+ remaining: extra.remaining,
164
+ hint,
165
+ };
166
+ }
167
+
168
+ function runClassify(policy, signal, now, onClassifyError) {
169
+ if (typeof policy?.classify !== 'function') return null;
170
+ let raw;
171
+ try {
172
+ raw = policy.classify({
173
+ status: signal.status,
174
+ headers: signal.headers,
175
+ body: signal.body,
176
+ });
177
+ if (isThenable(raw)) {
178
+ Promise.resolve(raw).catch(() => {});
179
+ throw new TypeError(
180
+ 'classify() must return a hint or null, not a Promise'
181
+ );
182
+ }
183
+ } catch (error) {
184
+ if (!onClassifyError) throw error;
185
+ onClassifyError(error);
186
+ return null;
187
+ }
188
+ return normalizeClassified(raw, now);
189
+ }
190
+
191
+ function parsedHint(policy, headers, now) {
192
+ for (const name of policy?.parsers ?? DEFAULT_PARSERS) {
193
+ const hint = BUILT_IN_PARSERS[name](headers, {
194
+ now,
195
+ resetDeltaUnit: policy?.resetDeltaUnit,
196
+ });
197
+ if (hint) return hint;
198
+ }
199
+ return null;
200
+ }
201
+
202
+ function staticHint(policy, reason, now) {
203
+ const window = policy?.windows?.find(
204
+ (candidate) =>
205
+ candidate &&
206
+ candidate.name === reason &&
207
+ Number.isFinite(candidate.perMs) &&
208
+ candidate.perMs > 0
209
+ );
210
+ const waitMs = Math.max(window?.perMs ?? 0, policy?.minRetryAfterMs ?? 0);
211
+ return waitMs > 0 ? hintFromWait(waitMs, now, { source: 'static' }) : null;
212
+ }
213
+
214
+ function withClassified(hint, classified) {
215
+ return {
216
+ ...hint,
217
+ reason: classified?.reason ?? 'unknown',
218
+ ...definedOnly({
219
+ policy: classified?.policy ?? hint.policy,
220
+ remaining: classified?.remaining ?? hint.remaining,
221
+ }),
222
+ };
223
+ }
224
+
225
+ function resolveCandidates(policy, signal, { now, onClassifyError }) {
226
+ const classified = runClassify(policy, signal, now, onClassifyError);
227
+ if (signal.status !== 429 && !classified) return { hint: null, classified };
228
+ if (classified?.hint) return { hint: classified.hint, classified };
229
+
230
+ const parsed = parsedHint(policy, signal.headers, now);
231
+ if (parsed) return { hint: withClassified(parsed, classified), classified };
232
+
233
+ const fromPolicy = staticHint(policy, classified?.reason, now);
234
+ if (fromPolicy) {
235
+ return { hint: withClassified(fromPolicy, classified), classified };
236
+ }
237
+ return { hint: null, classified };
238
+ }
239
+
240
+ function classifyRateLimit(policy, signal, options = {}) {
241
+ const { now = Date.now(), onClassifyError } = options;
242
+ return resolveCandidates(asPolicy(policy), signal, { now, onClassifyError })
243
+ .hint;
244
+ }
245
+
246
+ function resolveRateLimitHint(policy, signal, options = {}) {
247
+ const {
248
+ attempt = 0,
249
+ backOff = [],
250
+ now = Date.now(),
251
+ onClassifyError,
252
+ } = options;
253
+ const { hint, classified } = resolveCandidates(asPolicy(policy), signal, {
254
+ now,
255
+ onClassifyError,
256
+ });
257
+ if (hint) return hint;
258
+ if (signal.status !== 429 && !classified) return null;
259
+ if (signal.status !== 429) {
260
+ return {
261
+ reason: classified.reason,
262
+ ...definedOnly({
263
+ policy: classified.policy,
264
+ remaining: classified.remaining,
265
+ }),
266
+ };
267
+ }
268
+
269
+ const waitMs =
270
+ attempt < backOff.length ? Number(backOff[attempt]) * 1000 || 0 : 0;
271
+ return {
272
+ waitMs,
273
+ retryAt: new Date(now + waitMs),
274
+ reason: classified?.reason ?? 'unknown',
275
+ ...definedOnly({
276
+ policy: classified?.policy,
277
+ remaining: classified?.remaining,
278
+ }),
279
+ source: 'backoff',
280
+ };
281
+ }
282
+
283
+ function computeWaitMs({ hint, policy, budgetMs, random = Math.random }) {
284
+ const base = Math.max(
285
+ hint.waitMs,
286
+ policy?.minRetryAfterMs ?? 0,
287
+ MIN_HINTED_WAIT_MS
288
+ );
289
+ if (base > budgetMs) return { waitMs: base, fits: false };
290
+
291
+ const jitter = Math.floor(
292
+ random() * Math.min(JITTER_MAX_MS, base * JITTER_RATIO)
293
+ );
294
+ return { waitMs: Math.min(base + jitter, budgetMs), fits: true };
295
+ }
296
+
297
+ function inProcessBudgetMs({
298
+ maxInProcessWaitMs,
299
+ requestTimeoutMs,
300
+ remainingMs = Infinity,
301
+ waitedMs = 0,
302
+ } = {}) {
303
+ const halfLeftMs = remainingMs / 2;
304
+ const sleepableMs =
305
+ requestTimeoutMs > 0
306
+ ? Math.max(remainingMs - requestTimeoutMs, halfLeftMs)
307
+ : halfLeftMs;
308
+ return Math.max(0, Math.min(maxInProcessWaitMs - waitedMs, sleepableMs));
309
+ }
310
+
311
+ module.exports = {
312
+ DEFAULT_PARSERS,
313
+ JITTER_MAX_MS,
314
+ MIN_HINTED_WAIT_MS,
315
+ classifyRateLimit,
316
+ computeScopeKey,
317
+ computeWaitMs,
318
+ inProcessBudgetMs,
319
+ readRateLimitPolicy,
320
+ resolveRateLimitHint,
321
+ };