@tstdl/base 0.93.187 → 0.93.189
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/ai/genkit/multi-region.plugin.js +15 -11
- package/ai/genkit/types.d.ts +1 -1
- package/ai/genkit/types.js +1 -1
- package/authentication/client/authentication.service.d.ts +5 -0
- package/authentication/client/authentication.service.js +21 -4
- package/authentication/models/authentication-totp-recovery-code.model.js +3 -2
- package/authentication/models/totp-results.model.d.ts +1 -0
- package/authentication/models/totp-results.model.js +6 -1
- package/authentication/server/authentication.api-controller.d.ts +1 -0
- package/authentication/server/authentication.api-controller.js +9 -2
- package/authentication/server/authentication.service.js +114 -92
- package/authentication/server/drizzle/{0000_odd_echo.sql → 0000_dry_stepford_cuckoos.sql} +2 -1
- package/authentication/server/drizzle/meta/0000_snapshot.json +24 -2
- package/authentication/server/drizzle/meta/_journal.json +2 -2
- package/circuit-breaker/circuit-breaker.d.ts +22 -10
- package/circuit-breaker/postgres/circuit-breaker.d.ts +5 -4
- package/circuit-breaker/postgres/circuit-breaker.js +21 -19
- package/circuit-breaker/postgres/drizzle/{0000_same_captain_cross.sql → 0000_dapper_hercules.sql} +3 -2
- package/circuit-breaker/postgres/drizzle/meta/0000_snapshot.json +13 -6
- package/circuit-breaker/postgres/drizzle/meta/_journal.json +2 -2
- package/circuit-breaker/postgres/model.d.ts +2 -1
- package/circuit-breaker/postgres/model.js +9 -4
- package/circuit-breaker/postgres/provider.d.ts +1 -1
- package/circuit-breaker/postgres/provider.js +2 -2
- package/circuit-breaker/provider.d.ts +6 -1
- package/cryptography/totp.d.ts +2 -1
- package/cryptography/totp.js +15 -7
- package/orm/sqls/sqls.d.ts +5 -3
- package/orm/sqls/sqls.js +5 -3
- package/package.json +4 -4
- package/rate-limit/postgres/drizzle/{0000_serious_sauron.sql → 0000_previous_zeigeist.sql} +2 -1
- package/rate-limit/postgres/drizzle/meta/0000_snapshot.json +10 -3
- package/rate-limit/postgres/drizzle/meta/_journal.json +2 -2
- package/rate-limit/postgres/postgres-rate-limiter.d.ts +1 -0
- package/rate-limit/postgres/postgres-rate-limiter.js +3 -2
- package/rate-limit/postgres/rate-limit.model.d.ts +1 -0
- package/rate-limit/postgres/rate-limit.model.js +6 -1
- package/rate-limit/postgres/rate-limiter.provider.d.ts +1 -1
- package/rate-limit/postgres/rate-limiter.provider.js +2 -2
- package/rate-limit/provider.d.ts +3 -3
- package/rate-limit/rate-limiter.d.ts +2 -1
- package/signals/notifier.js +1 -1
- package/signals/operators/derive-async.js +11 -6
- package/task-queue/postgres/task-queue.js +8 -8
- package/testing/integration-setup.js +4 -0
|
@@ -11,10 +11,11 @@ export type RateLimiterConfig = {
|
|
|
11
11
|
refillInterval: number;
|
|
12
12
|
};
|
|
13
13
|
export type RateLimiterArgument = string | (RateLimiterConfig & {
|
|
14
|
-
|
|
14
|
+
namespace: string;
|
|
15
15
|
});
|
|
16
16
|
export declare abstract class RateLimiter extends Transactional implements Resolvable<RateLimiterArgument> {
|
|
17
17
|
readonly [resolveArgumentType]: RateLimiterArgument;
|
|
18
|
+
abstract readonly namespace: string;
|
|
18
19
|
abstract readonly burstCapacity: number;
|
|
19
20
|
abstract readonly refillInterval: number;
|
|
20
21
|
/**
|
package/signals/notifier.js
CHANGED
|
@@ -21,7 +21,8 @@ const operatorMap = {
|
|
|
21
21
|
* @returns A Signal that represents the latest value from the async source.
|
|
22
22
|
*/
|
|
23
23
|
export function deriveAsync(source, options) {
|
|
24
|
-
const
|
|
24
|
+
const sourceSignal = computed(source);
|
|
25
|
+
const initialRaw = untracked(sourceSignal);
|
|
25
26
|
const initialSource = isPromise(initialRaw) ? from(initialRaw) : isObservable(initialRaw) ? initialRaw : of(initialRaw);
|
|
26
27
|
const source$ = new BehaviorSubject(initialSource);
|
|
27
28
|
const destroy$ = new Subject();
|
|
@@ -44,14 +45,18 @@ export function deriveAsync(source, options) {
|
|
|
44
45
|
}
|
|
45
46
|
return notification.value;
|
|
46
47
|
}, { equal: options?.equal });
|
|
47
|
-
let
|
|
48
|
+
let lastRaw = initialRaw;
|
|
48
49
|
const effectRef = effect(() => {
|
|
49
|
-
const rawSource =
|
|
50
|
-
if (
|
|
51
|
-
firstRun = false;
|
|
50
|
+
const rawSource = sourceSignal();
|
|
51
|
+
if (rawSource === lastRaw) {
|
|
52
52
|
return;
|
|
53
53
|
}
|
|
54
|
-
|
|
54
|
+
lastRaw = rawSource;
|
|
55
|
+
const observableInput = isPromise(rawSource)
|
|
56
|
+
? from(rawSource)
|
|
57
|
+
: isObservable(rawSource)
|
|
58
|
+
? rawSource
|
|
59
|
+
: of(rawSource);
|
|
55
60
|
untracked(() => source$.next(observableInput));
|
|
56
61
|
});
|
|
57
62
|
registerFinalization(result, () => {
|
|
@@ -86,12 +86,12 @@ let PostgresTaskQueue = class PostgresTaskQueue extends TaskQueue {
|
|
|
86
86
|
#logger = inject(Logger, `PostgresTaskQueue:${this.#namespace}`);
|
|
87
87
|
#cancellationSignal = inject(CancellationSignal);
|
|
88
88
|
#rateLimiter = inject(RateLimiter, {
|
|
89
|
-
|
|
89
|
+
namespace: this.#namespace,
|
|
90
90
|
burstCapacity: this.#config.rateLimit ?? defaultQueueConfig.rateLimit,
|
|
91
91
|
refillInterval: this.#config.rateInterval ?? defaultQueueConfig.rateInterval,
|
|
92
92
|
});
|
|
93
93
|
#circuitBreaker = inject(CircuitBreaker, {
|
|
94
|
-
|
|
94
|
+
namespace: this.#namespace,
|
|
95
95
|
threshold: this.#config.circuitBreakerThreshold ?? defaultQueueConfig.circuitBreakerThreshold,
|
|
96
96
|
resetTimeout: this.#config.circuitBreakerResetTimeout ?? defaultQueueConfig.circuitBreakerResetTimeout,
|
|
97
97
|
});
|
|
@@ -616,7 +616,7 @@ let PostgresTaskQueue = class PostgresTaskQueue extends TaskQueue {
|
|
|
616
616
|
let circuitBreakerResult;
|
|
617
617
|
let rateLimitAcquired = 0;
|
|
618
618
|
if (!forceDequeue) {
|
|
619
|
-
circuitBreakerResult = await this.#circuitBreaker.check();
|
|
619
|
+
circuitBreakerResult = await this.#circuitBreaker.check(this.#namespace);
|
|
620
620
|
if (!circuitBreakerResult.allowed) {
|
|
621
621
|
return [];
|
|
622
622
|
}
|
|
@@ -788,7 +788,7 @@ let PostgresTaskQueue = class PostgresTaskQueue extends TaskQueue {
|
|
|
788
788
|
return;
|
|
789
789
|
}
|
|
790
790
|
if (updatedTask.status == TaskStatus.Completed || updatedTask.status == TaskStatus.WaitingChildren) {
|
|
791
|
-
await this.#circuitBreaker.recordSuccess();
|
|
791
|
+
await this.#circuitBreaker.recordSuccess(this.#namespace);
|
|
792
792
|
}
|
|
793
793
|
await this.resolveDependencies(task.id, updatedTask.status, { namespace: task.namespace, transaction: tx });
|
|
794
794
|
});
|
|
@@ -829,7 +829,7 @@ let PostgresTaskQueue = class PostgresTaskQueue extends TaskQueue {
|
|
|
829
829
|
.from(updated);
|
|
830
830
|
if (updatedRows.length > 0) {
|
|
831
831
|
if (updatedRows.some((r) => r.status == TaskStatus.Completed || r.status == TaskStatus.WaitingChildren)) {
|
|
832
|
-
await this.#circuitBreaker.recordSuccess();
|
|
832
|
+
await this.#circuitBreaker.recordSuccess(this.#namespace);
|
|
833
833
|
}
|
|
834
834
|
await this.resolveDependenciesMany(updatedRows.map((r) => ({ id: r.id, status: r.status })), { transaction: tx });
|
|
835
835
|
}
|
|
@@ -854,7 +854,7 @@ let PostgresTaskQueue = class PostgresTaskQueue extends TaskQueue {
|
|
|
854
854
|
if (isUndefined(updatedRow)) {
|
|
855
855
|
return;
|
|
856
856
|
}
|
|
857
|
-
await this.#circuitBreaker.recordFailure();
|
|
857
|
+
await this.#circuitBreaker.recordFailure(this.#namespace);
|
|
858
858
|
await this.resolveDependencies(task.id, update.status, { namespace: task.namespace, transaction: tx });
|
|
859
859
|
});
|
|
860
860
|
}
|
|
@@ -897,7 +897,7 @@ let PostgresTaskQueue = class PostgresTaskQueue extends TaskQueue {
|
|
|
897
897
|
.select({ id: updated.id, status: updated.status })
|
|
898
898
|
.from(updated);
|
|
899
899
|
if (result.length > 0) {
|
|
900
|
-
await this.#circuitBreaker.recordFailures(result.length);
|
|
900
|
+
await this.#circuitBreaker.recordFailures(this.#namespace, result.length);
|
|
901
901
|
await this.resolveDependenciesMany(result.map((r) => ({ id: r.id, status: r.status })), { transaction: tx });
|
|
902
902
|
}
|
|
903
903
|
});
|
|
@@ -1171,7 +1171,7 @@ let PostgresTaskQueue = class PostgresTaskQueue extends TaskQueue {
|
|
|
1171
1171
|
.where(inArray(taskTable.id, tx.pgTransaction.select().from(selection)))
|
|
1172
1172
|
.returning({ id: taskTable.id, status: taskTable.status });
|
|
1173
1173
|
if (updatedRows.length > 0) {
|
|
1174
|
-
await this.#circuitBreaker.recordFailures(updatedRows.length);
|
|
1174
|
+
await this.#circuitBreaker.recordFailures(this.#namespace, updatedRows.length);
|
|
1175
1175
|
await this.resolveDependenciesMany(updatedRows.map((r) => ({ id: r.id, status: r.status, namespace: this.#namespace })), { transaction: tx });
|
|
1176
1176
|
}
|
|
1177
1177
|
return updatedRows;
|
|
@@ -191,6 +191,10 @@ export async function setupIsolatedIntegrationTest(options = {}) {
|
|
|
191
191
|
serviceOptions: {
|
|
192
192
|
passwordHashing: fastHashDeriveOptions,
|
|
193
193
|
totp: fastTotpHashingOptions,
|
|
194
|
+
bruteForceProtection: {
|
|
195
|
+
subjectBurstCapacity: 1000000,
|
|
196
|
+
ipBurstCapacity: 1000000,
|
|
197
|
+
},
|
|
194
198
|
...options.authentication?.options,
|
|
195
199
|
},
|
|
196
200
|
authenticationAncillaryService: options.authentication?.ancillaryService,
|