@tstdl/base 0.93.139 → 0.93.140
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 +166 -0
- package/ai/genkit/multi-region.plugin.js +5 -3
- package/ai/genkit/tests/multi-region.test.d.ts +1 -0
- package/ai/genkit/tests/multi-region.test.js +5 -2
- package/ai/parser/parser.js +2 -2
- package/ai/prompts/build.js +1 -0
- package/ai/prompts/instructions-formatter.d.ts +15 -2
- package/ai/prompts/instructions-formatter.js +36 -31
- package/ai/prompts/prompt-builder.js +5 -5
- package/ai/prompts/steering.d.ts +3 -2
- package/ai/prompts/steering.js +3 -1
- package/ai/tests/instructions-formatter.test.js +1 -0
- package/api/README.md +403 -0
- package/api/client/client.js +7 -13
- package/api/client/tests/api-client.test.js +10 -10
- package/api/default-error-handlers.js +1 -1
- package/api/response.d.ts +2 -2
- package/api/response.js +22 -33
- package/api/server/api-controller.d.ts +1 -1
- package/api/server/api-controller.js +3 -3
- package/api/server/api-request-token.provider.d.ts +1 -0
- package/api/server/api-request-token.provider.js +1 -0
- package/api/server/middlewares/allowed-methods.middleware.js +2 -1
- package/api/server/middlewares/content-type.middleware.js +2 -1
- package/api/types.d.ts +3 -2
- package/application/README.md +240 -0
- package/application/application.js +2 -2
- package/audit/README.md +267 -0
- package/authentication/README.md +288 -0
- package/authentication/client/authentication.service.d.ts +12 -11
- package/authentication/client/authentication.service.js +21 -21
- package/authentication/client/http-client.middleware.js +2 -2
- package/authentication/tests/authentication.client-error-handling.test.js +2 -1
- package/authentication/tests/authentication.client-service-refresh.test.js +5 -3
- package/browser/README.md +401 -0
- package/cancellation/README.md +156 -0
- package/cancellation/tests/coverage.test.d.ts +1 -0
- package/cancellation/tests/coverage.test.js +49 -0
- package/cancellation/tests/leak.test.js +24 -29
- package/cancellation/tests/token.test.d.ts +1 -0
- package/cancellation/tests/token.test.js +136 -0
- package/cancellation/token.d.ts +53 -177
- package/cancellation/token.js +132 -208
- package/context/README.md +174 -0
- package/cookie/README.md +161 -0
- package/css/README.md +157 -0
- package/data-structures/README.md +320 -0
- package/decorators/README.md +140 -0
- package/distributed-loop/README.md +231 -0
- package/distributed-loop/distributed-loop.js +1 -1
- package/document-management/README.md +403 -0
- package/document-management/server/services/document-management.service.js +9 -7
- package/document-management/tests/document-management-core.test.js +2 -7
- package/document-management/tests/document-management.api.test.js +6 -7
- package/document-management/tests/document-statistics.service.test.js +11 -12
- package/document-management/tests/document.service.test.js +3 -3
- package/document-management/tests/enum-helpers.test.js +2 -3
- package/dom/README.md +213 -0
- package/enumerable/README.md +259 -0
- package/enumeration/README.md +121 -0
- package/errors/README.md +267 -0
- package/file/README.md +191 -0
- package/formats/README.md +210 -0
- package/function/README.md +144 -0
- package/http/README.md +318 -0
- package/http/client/adapters/undici.adapter.js +1 -1
- package/http/client/http-client-request.d.ts +6 -5
- package/http/client/http-client-request.js +8 -9
- package/http/server/node/node-http-server.js +1 -2
- package/image-service/README.md +137 -0
- package/injector/README.md +491 -0
- package/intl/README.md +113 -0
- package/json-path/README.md +182 -0
- package/jsx/README.md +154 -0
- package/key-value-store/README.md +191 -0
- package/lock/README.md +249 -0
- package/lock/web/web-lock.js +119 -47
- package/logger/README.md +287 -0
- package/mail/README.md +256 -0
- package/memory/README.md +144 -0
- package/message-bus/README.md +244 -0
- package/message-bus/message-bus-base.js +1 -1
- package/module/README.md +182 -0
- package/module/module.d.ts +1 -1
- package/module/module.js +77 -17
- package/module/modules/web-server.module.js +1 -1
- package/notification/tests/notification-type.service.test.js +24 -15
- package/object-storage/README.md +300 -0
- package/openid-connect/README.md +274 -0
- package/orm/README.md +423 -0
- package/package.json +8 -6
- package/password/README.md +164 -0
- package/pdf/README.md +246 -0
- package/polyfills.js +1 -0
- package/pool/README.md +198 -0
- package/process/README.md +237 -0
- package/promise/README.md +252 -0
- package/promise/cancelable-promise.js +1 -1
- package/random/README.md +193 -0
- package/reflection/README.md +305 -0
- package/rpc/README.md +386 -0
- package/rxjs-utils/README.md +262 -0
- package/schema/README.md +342 -0
- package/serializer/README.md +342 -0
- package/signals/implementation/README.md +134 -0
- package/sse/README.md +278 -0
- package/task-queue/README.md +300 -0
- package/task-queue/postgres/task-queue.d.ts +2 -1
- package/task-queue/postgres/task-queue.js +32 -2
- package/task-queue/task-context.js +1 -1
- package/task-queue/task-queue.d.ts +17 -0
- package/task-queue/task-queue.js +103 -45
- package/task-queue/tests/complex.test.js +4 -4
- package/task-queue/tests/dependencies.test.js +4 -2
- package/task-queue/tests/queue.test.js +111 -0
- package/task-queue/tests/worker.test.js +21 -13
- package/templates/README.md +287 -0
- package/testing/README.md +157 -0
- package/text/README.md +346 -0
- package/threading/README.md +238 -0
- package/types/README.md +311 -0
- package/utils/README.md +322 -0
- package/utils/async-iterable-helpers/observable-iterable.d.ts +1 -1
- package/utils/async-iterable-helpers/observable-iterable.js +4 -8
- package/utils/async-iterable-helpers/take-until.js +4 -4
- package/utils/backoff.js +89 -30
- package/utils/retry-with-backoff.js +1 -1
- package/utils/timer.d.ts +1 -1
- package/utils/timer.js +5 -7
- package/utils/timing.d.ts +1 -1
- package/utils/timing.js +2 -4
- package/utils/z-base32.d.ts +1 -0
- package/utils/z-base32.js +1 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { firstValueFrom, map, race } from 'rxjs';
|
|
1
|
+
import { firstValueFrom, from, map, race } from 'rxjs';
|
|
2
2
|
import { isAsyncIterable } from './is-async-iterable.js';
|
|
3
3
|
export function takeUntilAsync(iterable, cancellationSignal) {
|
|
4
4
|
return isAsyncIterable(iterable)
|
|
@@ -20,7 +20,7 @@ async function* sync(iterable, cancellationSignal) {
|
|
|
20
20
|
}
|
|
21
21
|
async function* async(iterable, cancellationSignal) {
|
|
22
22
|
const iterator = iterable[Symbol.asyncIterator]();
|
|
23
|
-
const cancel$ = cancellationSignal.
|
|
23
|
+
const cancel$ = from(cancellationSignal).pipe(map(() => ({ done: true, value: undefined })));
|
|
24
24
|
try {
|
|
25
25
|
while (true) {
|
|
26
26
|
const result = await firstValueFrom(race([iterator.next(), cancel$]));
|
|
@@ -31,10 +31,10 @@ async function* async(iterable, cancellationSignal) {
|
|
|
31
31
|
}
|
|
32
32
|
}
|
|
33
33
|
catch (error) {
|
|
34
|
-
(iterator.throw ?? iterator.return)?.(error);
|
|
34
|
+
await (iterator.throw ?? iterator.return)?.(error);
|
|
35
35
|
}
|
|
36
36
|
finally {
|
|
37
|
-
iterator.return?.();
|
|
37
|
+
await iterator.return?.();
|
|
38
38
|
}
|
|
39
39
|
return undefined;
|
|
40
40
|
}
|
package/utils/backoff.js
CHANGED
|
@@ -1,3 +1,55 @@
|
|
|
1
|
+
var __addDisposableResource = (this && this.__addDisposableResource) || function (env, value, async) {
|
|
2
|
+
if (value !== null && value !== void 0) {
|
|
3
|
+
if (typeof value !== "object" && typeof value !== "function") throw new TypeError("Object expected.");
|
|
4
|
+
var dispose, inner;
|
|
5
|
+
if (async) {
|
|
6
|
+
if (!Symbol.asyncDispose) throw new TypeError("Symbol.asyncDispose is not defined.");
|
|
7
|
+
dispose = value[Symbol.asyncDispose];
|
|
8
|
+
}
|
|
9
|
+
if (dispose === void 0) {
|
|
10
|
+
if (!Symbol.dispose) throw new TypeError("Symbol.dispose is not defined.");
|
|
11
|
+
dispose = value[Symbol.dispose];
|
|
12
|
+
if (async) inner = dispose;
|
|
13
|
+
}
|
|
14
|
+
if (typeof dispose !== "function") throw new TypeError("Object not disposable.");
|
|
15
|
+
if (inner) dispose = function() { try { inner.call(this); } catch (e) { return Promise.reject(e); } };
|
|
16
|
+
env.stack.push({ value: value, dispose: dispose, async: async });
|
|
17
|
+
}
|
|
18
|
+
else if (async) {
|
|
19
|
+
env.stack.push({ async: true });
|
|
20
|
+
}
|
|
21
|
+
return value;
|
|
22
|
+
};
|
|
23
|
+
var __disposeResources = (this && this.__disposeResources) || (function (SuppressedError) {
|
|
24
|
+
return function (env) {
|
|
25
|
+
function fail(e) {
|
|
26
|
+
env.error = env.hasError ? new SuppressedError(e, env.error, "An error was suppressed during disposal.") : e;
|
|
27
|
+
env.hasError = true;
|
|
28
|
+
}
|
|
29
|
+
var r, s = 0;
|
|
30
|
+
function next() {
|
|
31
|
+
while (r = env.stack.pop()) {
|
|
32
|
+
try {
|
|
33
|
+
if (!r.async && s === 1) return s = 0, env.stack.push(r), Promise.resolve().then(next);
|
|
34
|
+
if (r.dispose) {
|
|
35
|
+
var result = r.dispose.call(r.value);
|
|
36
|
+
if (r.async) return s |= 2, Promise.resolve(result).then(next, function(e) { fail(e); return next(); });
|
|
37
|
+
}
|
|
38
|
+
else s |= 1;
|
|
39
|
+
}
|
|
40
|
+
catch (e) {
|
|
41
|
+
fail(e);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
if (s === 1) return env.hasError ? Promise.reject(env.error) : Promise.resolve();
|
|
45
|
+
if (env.hasError) throw env.error;
|
|
46
|
+
}
|
|
47
|
+
return next();
|
|
48
|
+
};
|
|
49
|
+
})(typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
|
|
50
|
+
var e = new Error(message);
|
|
51
|
+
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
52
|
+
});
|
|
1
53
|
import { CancellationToken } from '../cancellation/token.js';
|
|
2
54
|
import { NEVER } from 'rxjs';
|
|
3
55
|
import { randomFloat } from './math.js';
|
|
@@ -109,37 +161,44 @@ export async function autoBackoffLoop(loopFunction, options = {}) {
|
|
|
109
161
|
* @param options Additional options for backoff configuration and cancellation.
|
|
110
162
|
*/
|
|
111
163
|
export async function backoffLoop(loopFunction, options = {}) {
|
|
112
|
-
const {
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
164
|
+
const env_1 = { stack: [], error: void 0, hasError: false };
|
|
165
|
+
try {
|
|
166
|
+
const { cancellationSignal, ...backoffOptions } = options;
|
|
167
|
+
const backoffHelper = new BackoffHelper(backoffOptions);
|
|
168
|
+
const loopToken = __addDisposableResource(env_1, new CancellationToken(cancellationSignal), false);
|
|
169
|
+
let shouldBackoff = false;
|
|
170
|
+
let customBackoffDelay;
|
|
171
|
+
const controller = {
|
|
172
|
+
backoff: (delay) => {
|
|
173
|
+
shouldBackoff = true;
|
|
174
|
+
customBackoffDelay = delay;
|
|
175
|
+
},
|
|
176
|
+
break: () => loopToken.set(),
|
|
177
|
+
};
|
|
178
|
+
while (loopToken.isUnset) {
|
|
179
|
+
await loopFunction(controller, loopToken, backoffHelper.status);
|
|
180
|
+
// Exit immediately if the loop function requested a break.
|
|
181
|
+
if (loopToken.isSet) {
|
|
182
|
+
return;
|
|
183
|
+
}
|
|
184
|
+
if (shouldBackoff) {
|
|
185
|
+
shouldBackoff = false;
|
|
186
|
+
const delay = customBackoffDelay ?? backoffHelper.getNextDelay();
|
|
187
|
+
await cancelableTimeout(delay, loopToken);
|
|
188
|
+
}
|
|
189
|
+
else {
|
|
190
|
+
// If an iteration completes successfully without a backoff request, reset the delay.
|
|
191
|
+
backoffHelper.reset();
|
|
192
|
+
}
|
|
141
193
|
}
|
|
142
194
|
}
|
|
195
|
+
catch (e_1) {
|
|
196
|
+
env_1.error = e_1;
|
|
197
|
+
env_1.hasError = true;
|
|
198
|
+
}
|
|
199
|
+
finally {
|
|
200
|
+
__disposeResources(env_1);
|
|
201
|
+
}
|
|
143
202
|
}
|
|
144
203
|
/**
|
|
145
204
|
* Creates an async generator that yields a callback to trigger a backoff.
|
|
@@ -182,7 +241,7 @@ export async function* backoffGenerator(options = {}) {
|
|
|
182
241
|
const continueToken = backoffOptions?.continueToken;
|
|
183
242
|
if (isDefined(continueToken)) {
|
|
184
243
|
timeoutSignal = isDefined(cancellationSignal)
|
|
185
|
-
? cancellationSignal.
|
|
244
|
+
? cancellationSignal.inherit(continueToken)
|
|
186
245
|
: continueToken;
|
|
187
246
|
}
|
|
188
247
|
};
|
|
@@ -15,7 +15,7 @@ export async function retryWithBackoff(func, options = {}) {
|
|
|
15
15
|
await backoffLoop(async (controller, loopSignal, status) => {
|
|
16
16
|
try {
|
|
17
17
|
const attemptSignal = isDefined(signal)
|
|
18
|
-
? signal.
|
|
18
|
+
? signal.inherit(loopSignal)
|
|
19
19
|
: loopSignal;
|
|
20
20
|
if (isDefined(timeout)) {
|
|
21
21
|
result = await withTimeout(timeout, async () => await func(attemptSignal));
|
package/utils/timer.d.ts
CHANGED
package/utils/timer.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { isDefined, isUndefined } from './type-guards.js';
|
|
1
2
|
const nsPerSec = 1e9;
|
|
2
3
|
const nsPerMs = 1e6;
|
|
3
4
|
const nsPerUs = 1e3;
|
|
@@ -41,12 +42,10 @@ export class Timer {
|
|
|
41
42
|
return timer.milliseconds;
|
|
42
43
|
}
|
|
43
44
|
start() {
|
|
44
|
-
|
|
45
|
-
this.begin = getBegin();
|
|
46
|
-
}
|
|
45
|
+
this.begin ??= getBegin();
|
|
47
46
|
}
|
|
48
47
|
stop() {
|
|
49
|
-
if (this.begin
|
|
48
|
+
if (isDefined(this.begin)) {
|
|
50
49
|
const nanoseconds = this.read();
|
|
51
50
|
this.elapsedNanoseconds += nanoseconds;
|
|
52
51
|
this.begin = undefined;
|
|
@@ -61,8 +60,7 @@ export class Timer {
|
|
|
61
60
|
this.elapsedNanoseconds = 0;
|
|
62
61
|
}
|
|
63
62
|
get nanoseconds() {
|
|
64
|
-
|
|
65
|
-
return result;
|
|
63
|
+
return this.elapsedNanoseconds + this.read();
|
|
66
64
|
}
|
|
67
65
|
get microseconds() {
|
|
68
66
|
return this.nanoseconds / nsPerUs;
|
|
@@ -74,7 +72,7 @@ export class Timer {
|
|
|
74
72
|
return this.nanoseconds / nsPerSec;
|
|
75
73
|
}
|
|
76
74
|
read() {
|
|
77
|
-
if (this.begin
|
|
75
|
+
if (isUndefined(this.begin)) {
|
|
78
76
|
return 0;
|
|
79
77
|
}
|
|
80
78
|
const result = getDuration(this.begin);
|
package/utils/timing.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type Observable } from 'rxjs';
|
|
2
|
-
import { CancellationSignal } from '../cancellation/token.js';
|
|
2
|
+
import type { CancellationSignal } from '../cancellation/token.js';
|
|
3
3
|
import { type ValueOrProvider } from './value-or-provider.js';
|
|
4
4
|
/** Timeout for specified duration */
|
|
5
5
|
export declare function timeout(milliseconds?: number, options?: {
|
package/utils/timing.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { firstValueFrom, map, race, timer } from 'rxjs';
|
|
2
|
-
import { CancellationSignal } from '../cancellation/token.js';
|
|
1
|
+
import { firstValueFrom, from, map, race, timer } from 'rxjs';
|
|
3
2
|
import { TimeoutError } from '../errors/timeout.error.js';
|
|
4
3
|
import { _throw } from './throw.js';
|
|
5
4
|
import { resolveValueOrProvider } from './value-or-provider.js';
|
|
@@ -21,10 +20,9 @@ export async function timeoutUntil(timestamp) {
|
|
|
21
20
|
}
|
|
22
21
|
/** Timeout for specified duration */
|
|
23
22
|
export async function cancelableTimeout(milliseconds, cancelSignal) {
|
|
24
|
-
const observable = (cancelSignal instanceof CancellationSignal) ? cancelSignal.set$ : cancelSignal;
|
|
25
23
|
return await firstValueFrom(race([
|
|
26
24
|
timer(milliseconds).pipe(map(() => 'timeout')),
|
|
27
|
-
|
|
25
|
+
from(cancelSignal).pipe(map(() => 'canceled')),
|
|
28
26
|
]));
|
|
29
27
|
}
|
|
30
28
|
/** Timeout until specified time */
|
package/utils/z-base32.d.ts
CHANGED
package/utils/z-base32.js
CHANGED