@tstdl/base 0.92.145 → 0.92.148
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/ai-file.service.d.ts +29 -1
- package/ai/ai-file.service.js +66 -23
- package/ai/ai-session.d.ts +28 -1
- package/ai/ai-session.js +27 -0
- package/ai/ai.service.d.ts +89 -5
- package/ai/ai.service.js +130 -27
- package/ai/functions.d.ts +7 -1
- package/ai/functions.js +7 -1
- package/ai/module.d.ts +8 -0
- package/ai/module.js +4 -0
- package/ai/types.d.ts +115 -2
- package/ai/types.js +16 -0
- package/api/client/client.d.ts +3 -1
- package/api/client/client.js +5 -2
- package/api/default-error-handlers.d.ts +1 -1
- package/api/index.d.ts +1 -9
- package/api/index.js +1 -9
- package/api/response.d.ts +1 -1
- package/api/server/api-controller.d.ts +1 -1
- package/api/server/error-handler.d.ts +1 -1
- package/api/server/gateway.d.ts +1 -5
- package/api/server/gateway.js +0 -4
- package/api/server/middlewares/catch-error.middleware.d.ts +1 -1
- package/api/server/module.d.ts +1 -1
- package/api/types.d.ts +1 -1
- package/api/utils.d.ts +1 -0
- package/api/utils.js +1 -0
- package/application/application.d.ts +1 -1
- package/authentication/authentication.api.d.ts +36 -1
- package/authentication/authentication.api.js +28 -0
- package/authentication/client/api.client.d.ts +14 -1
- package/authentication/client/api.client.js +13 -0
- package/authentication/client/authentication.service.d.ts +104 -1
- package/authentication/client/authentication.service.js +103 -0
- package/authentication/client/http-client.middleware.d.ts +5 -0
- package/authentication/client/http-client.middleware.js +6 -2
- package/authentication/client/module.d.ts +20 -1
- package/authentication/client/module.js +6 -1
- package/authentication/client/tokens.d.ts +6 -0
- package/authentication/client/tokens.js +6 -0
- package/authentication/models/authentication-credentials.model.d.ts +6 -0
- package/authentication/models/authentication-credentials.model.js +6 -0
- package/authentication/models/authentication-session.model.d.ts +6 -0
- package/authentication/models/authentication-session.model.js +6 -0
- package/authentication/models/init-secret-reset-data.model.d.ts +10 -1
- package/authentication/models/init-secret-reset-data.model.js +10 -1
- package/authentication/models/token-payload-base.model.d.ts +24 -4
- package/authentication/models/token-payload-base.model.js +24 -4
- package/authentication/models/token.model.d.ts +33 -2
- package/authentication/server/authentication-ancillary.service.d.ts +27 -4
- package/authentication/server/authentication-ancillary.service.js +7 -0
- package/authentication/server/authentication-api-request-token.provider.d.ts +3 -0
- package/authentication/server/authentication-api-request-token.provider.js +3 -0
- package/authentication/server/authentication-secret-requirements.validator.d.ts +37 -0
- package/authentication/server/authentication-secret-requirements.validator.js +22 -0
- package/authentication/server/authentication.api-controller.d.ts +66 -1
- package/authentication/server/authentication.api-controller.js +65 -0
- package/authentication/server/authentication.service.d.ts +191 -11
- package/authentication/server/authentication.service.js +157 -8
- package/authentication/server/helper.d.ts +44 -5
- package/authentication/server/helper.js +43 -4
- package/authentication/server/module.d.ts +23 -1
- package/authentication/server/module.js +23 -1
- package/browser/browser-context-controller.d.ts +1 -1
- package/browser/browser-controller.d.ts +1 -1
- package/browser/browser-controller.js +1 -1
- package/browser/element-controller.d.ts +1 -1
- package/browser/locator-controller.d.ts +1 -1
- package/context/context.d.ts +1 -1
- package/data-structures/context-data-map.d.ts +1 -1
- package/database/mongo/mongo-base.repository.d.ts +1 -1
- package/database/mongo/types.d.ts +1 -1
- package/database/query.d.ts +1 -1
- package/document-management/api/document-management.api.d.ts +13 -0
- package/document-management/api/document-management.api.js +8 -0
- package/document-management/models/document-management-table.d.ts +1 -1
- package/document-management/models/document-validation-definition.model.d.ts +1 -1
- package/document-management/server/schemas.d.ts +1 -1
- package/document-management/server/services/document-collection.service.d.ts +1 -1
- package/document-management/server/services/document-management-observation.service.d.ts +1 -1
- package/document-management/server/services/document-management.service.d.ts +1 -1
- package/document-management/server/services/document-property.service.d.ts +3 -3
- package/document-management/server/services/document-request.service.d.ts +1 -1
- package/document-management/server/services/document-validation.service.d.ts +1 -1
- package/document-management/server/services/document-workflow.service.d.ts +1 -1
- package/document-management/server/services/document.service.d.ts +1 -1
- package/document-management/server/services/singleton.d.ts +1 -1
- package/document-management/service-models/document-management.view-model.d.ts +1 -1
- package/document-management/service-models/enriched/enriched-document-assignment.view.d.ts +1 -1
- package/document-management/service-models/enriched/enriched-document-category.view.d.ts +1 -1
- package/document-management/service-models/enriched/enriched-document-collection.view.d.ts +1 -1
- package/document-management/service-models/enriched/enriched-document-request.view.d.ts +1 -1
- package/document-management/service-models/enriched/enriched-document-type.view.d.ts +1 -1
- package/document-management/service-models/enriched/enriched-document.view.d.ts +1 -1
- package/document-management/service-models/enriched/enriched-requests-template-data.model.d.ts +1 -1
- package/dom/file-select-dialog.d.ts +1 -1
- package/enumeration/enumeration.d.ts +1 -1
- package/errors/custom.error.d.ts +3 -0
- package/errors/custom.error.js +0 -1
- package/errors/errors.localization.d.ts +1 -1
- package/errors/not-supported.error.d.ts +1 -1
- package/{formats.js → formats/formats.js} +3 -3
- package/formats/index.d.ts +1 -0
- package/formats/index.js +1 -0
- package/http/client/http-client-request.d.ts +1 -1
- package/http/client/http-client-request.js +1 -1
- package/http/client/http-client-response.d.ts +1 -1
- package/http/client/http-client.d.ts +1 -1
- package/http/client/module.d.ts +1 -1
- package/http/http-body.d.ts +1 -1
- package/http/http-value-map.d.ts +1 -1
- package/http/http.error.d.ts +1 -1
- package/http/index.d.ts +1 -0
- package/http/index.js +1 -0
- package/http/server/http-server-request.d.ts +1 -1
- package/http/server/http-server-response.d.ts +1 -1
- package/http/tokens.d.ts +5 -0
- package/http/tokens.js +5 -0
- package/http/types.d.ts +1 -1
- package/http/utils.d.ts +1 -1
- package/injector/decorators.d.ts +1 -1
- package/injector/index.d.ts +1 -1
- package/injector/index.js +1 -1
- package/injector/injector.d.ts +10 -1
- package/injector/injector.js +6 -0
- package/injector/interfaces.d.ts +1 -1
- package/injector/provider.d.ts +1 -1
- package/injector/resolution.d.ts +10 -5
- package/injector/resolve-chain.d.ts +2 -2
- package/injector/resolve-chain.js +1 -1
- package/injector/resolve.error.js +1 -1
- package/injector/token.d.ts +8 -1
- package/injector/token.js +7 -0
- package/injector/types.d.ts +1 -1
- package/key-value-store/key-value-store.provider.d.ts +2 -2
- package/key-value-store/key-value.store.d.ts +2 -2
- package/key-value-store/mongo/mongo-key-value-store.provider.d.ts +1 -1
- package/key-value-store/mongo/mongo-key-value.store.d.ts +1 -1
- package/key-value-store/postgres/key-value-store.service.d.ts +1 -1
- package/mail/mail.service.d.ts +1 -1
- package/mail/models/mail-data.model.d.ts +1 -1
- package/mail/models/mail-template.model.d.ts +1 -1
- package/mail/module.d.ts +1 -1
- package/module/index.d.ts +0 -1
- package/module/index.js +0 -1
- package/module/module-base.d.ts +1 -1
- package/module/module-metric-reporter.js +1 -1
- package/module/module.d.ts +1 -1
- package/module/modules/function.module.js +1 -1
- package/object-storage/object.d.ts +1 -1
- package/openid-connect/mongo-oidc-state.repository.d.ts +1 -1
- package/openid-connect/oidc.service.d.ts +1 -1
- package/orm/decorators.d.ts +2 -2
- package/orm/entity.d.ts +1 -1
- package/orm/index.d.ts +3 -3
- package/orm/index.js +3 -3
- package/orm/query.d.ts +1 -1
- package/orm/repository.types.d.ts +1 -1
- package/orm/schemas/json.d.ts +1 -1
- package/orm/server/database-schema.d.ts +1 -1
- package/orm/server/drizzle/schema-converter.d.ts +1 -1
- package/orm/server/repository.d.ts +1 -1
- package/orm/server/transaction.d.ts +1 -1
- package/orm/server/transactional.d.ts +3 -3
- package/orm/server/types.d.ts +1 -1
- package/orm/types.d.ts +1 -1
- package/package.json +23 -20
- package/queue/mongo/job.d.ts +1 -1
- package/queue/mongo/queue.js +31 -31
- package/queue/postgres/job.model.d.ts +1 -1
- package/queue/postgres/queue.d.ts +1 -1
- package/queue/postgres/queue.provider.d.ts +1 -1
- package/queue/provider.d.ts +1 -1
- package/reflection/decorators.d.ts +1 -1
- package/reflection/registry.d.ts +1 -1
- package/reflection/types.d.ts +1 -1
- package/reflection/utils.d.ts +1 -1
- package/rpc/model.d.ts +1 -1
- package/rxjs-utils/retry-backoff.js +2 -2
- package/schema/converters/openapi-converter.d.ts +1 -1
- package/schema/decorators/schema.d.ts +1 -1
- package/schema/decorators/utils.d.ts +1 -1
- package/schema/schema.d.ts +1 -1
- package/schema/schema.error.d.ts +1 -1
- package/schema/schemas/array.d.ts +1 -1
- package/schema/schemas/enumeration.d.ts +1 -1
- package/schema/schemas/function.d.ts +1 -1
- package/schema/schemas/instance.d.ts +1 -1
- package/schema/schemas/nullable.d.ts +1 -1
- package/schema/schemas/number.d.ts +1 -1
- package/schema/schemas/object.d.ts +1 -1
- package/schema/schemas/one-or-many.d.ts +1 -1
- package/schema/schemas/optional.d.ts +1 -1
- package/schema/schemas/simple.d.ts +1 -1
- package/search-index/elastic/model/index-mapping.d.ts +1 -1
- package/search-index/elastic/search-index.js +3 -4
- package/search-index/memory/memory-search-index.d.ts +1 -1
- package/search-index/memory/memory-search-index.js +1 -1
- package/serializer/handlers/binary.d.ts +1 -1
- package/serializer/serializable.d.ts +1 -1
- package/serializer/types.d.ts +1 -1
- package/templates/module.d.ts +1 -1
- package/templates/renderers/handlebars.template-renderer.d.ts +1 -1
- package/templates/renderers/jsx.template-renderer.d.ts +1 -1
- package/templates/renderers/mjml.template-renderer.d.ts +1 -1
- package/templates/renderers/string.template-renderer.d.ts +1 -1
- package/templates/resolvers/file.template-resolver.d.ts +1 -1
- package/templates/resolvers/jsx.template-resolver.d.ts +1 -1
- package/templates/resolvers/string.template-resolver.d.ts +1 -1
- package/templates/template.model.d.ts +1 -1
- package/templates/template.renderer.d.ts +1 -1
- package/templates/template.service.d.ts +1 -1
- package/text/dynamic-text.model.d.ts +1 -1
- package/text/localization.service.d.ts +1 -1
- package/types/geo-json.d.ts +1 -1
- package/types/index.d.ts +2 -0
- package/types/tagged.d.ts +1 -1
- package/{types.d.ts → types/types.d.ts} +2 -1
- package/utils/async-hook/async-hook.d.ts +109 -0
- package/utils/async-hook/async-hook.js +77 -3
- package/utils/backoff.d.ts +125 -43
- package/utils/backoff.js +140 -65
- package/utils/base64.d.ts +1 -1
- package/utils/base64.js +1 -2
- package/utils/binary.d.ts +1 -1
- package/utils/comparison.d.ts +5 -5
- package/utils/comparison.js +5 -3
- package/utils/cryptography.d.ts +1 -1
- package/utils/encoding.d.ts +1 -1
- package/utils/enum.d.ts +1 -1
- package/utils/equals.d.ts +1 -1
- package/utils/format-error.d.ts +1 -1
- package/utils/function/class.d.ts +1 -1
- package/utils/function/memoize.d.ts +1 -1
- package/utils/helpers.d.ts +1 -1
- package/utils/helpers.js +2 -2
- package/utils/jwt.d.ts +3 -3
- package/utils/merge.d.ts +1 -1
- package/utils/middleware.js +3 -3
- package/utils/object/decycle.d.ts +1 -1
- package/utils/object/forward-ref.d.ts +1 -1
- package/utils/object/lazy-property.d.ts +1 -1
- package/utils/object/object.d.ts +1 -1
- package/utils/object/property-name.d.ts +1 -1
- package/utils/patch-worker.d.ts +1 -1
- package/utils/reactive-value-to-signal.d.ts +1 -1
- package/utils/reflection.d.ts +1 -1
- package/utils/repl.d.ts +1 -1
- package/utils/singleton.d.ts +1 -1
- package/utils/stream/size-limited-stream.d.ts +1 -1
- package/utils/type/extends.d.ts +1 -1
- package/utils/type-guards.d.ts +1 -1
- package/utils/url-builder.d.ts +1 -1
- package/utils/z-base32.d.ts +1 -1
- package/module/utils.d.ts +0 -4
- package/module/utils.js +0 -21
- /package/{formats.d.ts → formats/formats.d.ts} +0 -0
- /package/{types.js → types/types.js} +0 -0
- /package/{web-types.d.ts → types/web-types.d.ts} +0 -0
- /package/{web-types.js → types/web-types.js} +0 -0
package/utils/backoff.js
CHANGED
|
@@ -1,101 +1,177 @@
|
|
|
1
1
|
import { CancellationToken } from '../cancellation/token.js';
|
|
2
|
-
import {
|
|
2
|
+
import { NEVER } from 'rxjs';
|
|
3
|
+
import { randomFloat } from './math.js';
|
|
3
4
|
import { cancelableTimeout } from './timing.js';
|
|
4
5
|
import { isDefined } from './type-guards.js';
|
|
6
|
+
/**
|
|
7
|
+
* Default options for a robust backoff strategy.
|
|
8
|
+
*/
|
|
9
|
+
export const DEFAULT_BACKOFF_OPTIONS = {
|
|
10
|
+
strategy: 'exponential',
|
|
11
|
+
initialDelay: 1000,
|
|
12
|
+
increase: 2,
|
|
13
|
+
maximumDelay: 30_000, // 30 seconds
|
|
14
|
+
jitter: 0.15,
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* A helper class to manage the state of a backoff strategy.
|
|
18
|
+
*/
|
|
5
19
|
export class BackoffHelper {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
this.
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
20
|
+
options;
|
|
21
|
+
currentDelay;
|
|
22
|
+
/**
|
|
23
|
+
* Creates a new BackoffHelper.
|
|
24
|
+
* @param options Partial backoff options, which will be merged with sane defaults.
|
|
25
|
+
*/
|
|
26
|
+
constructor(options) {
|
|
27
|
+
this.options = { ...DEFAULT_BACKOFF_OPTIONS, ...options };
|
|
28
|
+
const { initialDelay, increase, jitter, strategy } = this.options;
|
|
29
|
+
if (initialDelay < 0) {
|
|
30
|
+
throw new Error('initialDelay must be non-negative.');
|
|
31
|
+
}
|
|
32
|
+
if (increase < 0) {
|
|
33
|
+
throw new Error('increase must be non-negative.');
|
|
34
|
+
}
|
|
35
|
+
if ((jitter < 0) || (jitter > 1)) {
|
|
36
|
+
throw new Error('jitter must be between 0 and 1.');
|
|
37
|
+
}
|
|
38
|
+
if (strategy == 'exponential' && increase <= 1) {
|
|
39
|
+
console.warn('Using an exponential backoff with an increase factor <= 1 is not recommended as the delay will not grow.');
|
|
40
|
+
}
|
|
41
|
+
this.currentDelay = this.options.initialDelay;
|
|
17
42
|
}
|
|
43
|
+
/**
|
|
44
|
+
* Resets the current delay to the initial delay.
|
|
45
|
+
*/
|
|
18
46
|
reset() {
|
|
19
|
-
this.
|
|
47
|
+
this.currentDelay = this.options.initialDelay;
|
|
20
48
|
}
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
49
|
+
/**
|
|
50
|
+
* Calculates and returns the next backoff delay based on the configured strategy.
|
|
51
|
+
* This also updates the internal state for the subsequent call.
|
|
52
|
+
* @returns The next delay in milliseconds.
|
|
53
|
+
*/
|
|
54
|
+
getNextDelay() {
|
|
55
|
+
const newDelay = getNewDelay(this.options.strategy, this.currentDelay, this.options.increase, this.options.maximumDelay);
|
|
56
|
+
this.currentDelay = newDelay;
|
|
57
|
+
if (this.options.jitter > 0) {
|
|
58
|
+
const jitterAmount = newDelay * randomFloat(-this.options.jitter, this.options.jitter); // ±jitter
|
|
59
|
+
return Math.max(0, newDelay + jitterAmount);
|
|
60
|
+
}
|
|
61
|
+
return newDelay;
|
|
24
62
|
}
|
|
25
63
|
}
|
|
26
64
|
/**
|
|
27
|
-
*
|
|
28
|
-
*
|
|
29
|
-
*
|
|
30
|
-
*
|
|
65
|
+
* Runs a function in a loop, automatically backing off on errors.
|
|
66
|
+
*
|
|
67
|
+
* This function is a convenient wrapper that catches any errors from `loopFunction`,
|
|
68
|
+
* triggers a backoff, and continues the loop.
|
|
69
|
+
*
|
|
70
|
+
* @param loopFunction The asynchronous function to execute in each iteration.
|
|
71
|
+
* @param options Additional options for backoff configuration, cancellation, and error handling.
|
|
31
72
|
*/
|
|
32
|
-
export async function autoBackoffLoop(
|
|
33
|
-
const errorHandler
|
|
34
|
-
|
|
73
|
+
export async function autoBackoffLoop(loopFunction, options = {}) {
|
|
74
|
+
const { errorHandler, ...loopOptions } = options;
|
|
75
|
+
await backoffLoop(async (controller, signal) => {
|
|
35
76
|
try {
|
|
36
|
-
await loopFunction(controller);
|
|
77
|
+
await loopFunction(controller, signal);
|
|
37
78
|
}
|
|
38
79
|
catch (error) {
|
|
39
|
-
errorHandler(error);
|
|
80
|
+
errorHandler?.(error);
|
|
40
81
|
controller.backoff();
|
|
41
82
|
}
|
|
42
|
-
},
|
|
83
|
+
}, loopOptions);
|
|
43
84
|
}
|
|
44
85
|
/**
|
|
45
|
-
*
|
|
46
|
-
*
|
|
47
|
-
*
|
|
48
|
-
*
|
|
86
|
+
* Runs a function in a loop, allowing manual control over backoff and breaking.
|
|
87
|
+
* The loop continues until it is explicitly broken via the controller or the cancellation signal is set.
|
|
88
|
+
* If `controller.backoff()` is not called in an iteration, the delay is reset for the next backoff.
|
|
89
|
+
*
|
|
90
|
+
* @param loopFunction The function to execute, receiving a controller to manage the loop.
|
|
91
|
+
* @param options Additional options for backoff configuration and cancellation.
|
|
49
92
|
*/
|
|
50
|
-
export async function backoffLoop(
|
|
51
|
-
const
|
|
52
|
-
const
|
|
53
|
-
|
|
93
|
+
export async function backoffLoop(loopFunction, options = {}) {
|
|
94
|
+
const { cancellationSignal, ...backoffOptions } = options;
|
|
95
|
+
const backoffHelper = new BackoffHelper(backoffOptions);
|
|
96
|
+
const loopToken = new CancellationToken();
|
|
97
|
+
let shouldBackoff = false;
|
|
98
|
+
if (isDefined(cancellationSignal)) {
|
|
99
|
+
loopToken.inherit(cancellationSignal, { set: true, unset: false, complete: false, error: false });
|
|
100
|
+
}
|
|
54
101
|
const controller = {
|
|
55
|
-
backoff: () =>
|
|
56
|
-
break: () =>
|
|
102
|
+
backoff: () => shouldBackoff = true,
|
|
103
|
+
break: () => loopToken.set(),
|
|
57
104
|
};
|
|
58
|
-
while (
|
|
59
|
-
await loopFunction(controller);
|
|
60
|
-
if
|
|
105
|
+
while (loopToken.isUnset) {
|
|
106
|
+
await loopFunction(controller, loopToken.signal);
|
|
107
|
+
// Exit immediately if the loop function requested a break.
|
|
108
|
+
if (loopToken.isSet) {
|
|
61
109
|
return;
|
|
62
110
|
}
|
|
63
|
-
if (
|
|
64
|
-
|
|
65
|
-
const
|
|
66
|
-
await cancelableTimeout(
|
|
111
|
+
if (shouldBackoff) {
|
|
112
|
+
shouldBackoff = false;
|
|
113
|
+
const delay = backoffHelper.getNextDelay();
|
|
114
|
+
await cancelableTimeout(delay, loopToken.signal);
|
|
67
115
|
}
|
|
68
116
|
else {
|
|
117
|
+
// If an iteration completes successfully without a backoff request, reset the delay.
|
|
69
118
|
backoffHelper.reset();
|
|
70
119
|
}
|
|
71
120
|
}
|
|
72
121
|
}
|
|
73
122
|
/**
|
|
74
|
-
*
|
|
75
|
-
*
|
|
76
|
-
*
|
|
123
|
+
* Creates an async generator that yields a callback to trigger a backoff.
|
|
124
|
+
* This is useful for `for-await-of` loops where you need fine-grained control.
|
|
125
|
+
* The generator terminates when the `cancellationSignal` is set or the loop is terminated by break.
|
|
126
|
+
*
|
|
127
|
+
* @param options Options for backoff configuration and an optional cancellation signal.
|
|
77
128
|
* @example
|
|
78
|
-
*
|
|
79
|
-
*
|
|
80
|
-
*
|
|
81
|
-
*
|
|
129
|
+
* ```ts
|
|
130
|
+
* const token = new CancellationToken();
|
|
131
|
+
*
|
|
132
|
+
* // with a cancellation signal
|
|
133
|
+
* for await (const backoff of backoffGenerator({ cancellationSignal: token.signal })) {
|
|
134
|
+
* const success = await doSomeWork();
|
|
135
|
+
* if (!success) {
|
|
136
|
+
* backoff(); // Schedule a backoff before the next iteration.
|
|
137
|
+
* }
|
|
82
138
|
* }
|
|
139
|
+
*
|
|
140
|
+
* // without a cancellation signal (loop is broken manually)
|
|
141
|
+
* for await (const backoff of backoffGenerator()) {
|
|
142
|
+
* const success = await doSomeWork();
|
|
143
|
+
* if (success) {
|
|
144
|
+
* break; // Exit the loop
|
|
145
|
+
* }
|
|
146
|
+
* backoff();
|
|
147
|
+
* }
|
|
148
|
+
* ```
|
|
83
149
|
*/
|
|
84
|
-
export async function* backoffGenerator(options
|
|
85
|
-
const
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
150
|
+
export async function* backoffGenerator(options = {}) {
|
|
151
|
+
const { cancellationSignal, ...backoffOptions } = options;
|
|
152
|
+
const backoffHelper = new BackoffHelper(backoffOptions);
|
|
153
|
+
// Loop indefinitely if no cancellation signal is provided.
|
|
154
|
+
// The consumer is responsible for breaking the loop.
|
|
155
|
+
while (cancellationSignal?.isUnset ?? true) {
|
|
156
|
+
let backoffTriggered = false;
|
|
157
|
+
let timeoutSignal = cancellationSignal;
|
|
158
|
+
const backoffCallback = (backoffOptions) => {
|
|
159
|
+
backoffTriggered = true;
|
|
160
|
+
const continueToken = backoffOptions?.continueToken;
|
|
91
161
|
if (isDefined(continueToken)) {
|
|
92
|
-
|
|
162
|
+
timeoutSignal = isDefined(cancellationSignal)
|
|
163
|
+
? cancellationSignal.createChild().inherit(continueToken)
|
|
164
|
+
: continueToken;
|
|
93
165
|
}
|
|
94
166
|
};
|
|
95
|
-
yield
|
|
96
|
-
if (
|
|
97
|
-
|
|
98
|
-
|
|
167
|
+
yield backoffCallback;
|
|
168
|
+
// Break immediately if the cancellation signal (if provided) is set.
|
|
169
|
+
if (cancellationSignal?.isSet == true) {
|
|
170
|
+
break;
|
|
171
|
+
}
|
|
172
|
+
if (backoffTriggered) {
|
|
173
|
+
const delay = backoffHelper.getNextDelay();
|
|
174
|
+
await cancelableTimeout(delay, timeoutSignal ?? NEVER);
|
|
99
175
|
}
|
|
100
176
|
else {
|
|
101
177
|
backoffHelper.reset();
|
|
@@ -112,8 +188,7 @@ function getNewDelay(strategy, currentDelay, increase, maximumDelay) {
|
|
|
112
188
|
newDelay = currentDelay * increase;
|
|
113
189
|
break;
|
|
114
190
|
default:
|
|
115
|
-
throw new Error(
|
|
191
|
+
throw new Error(`Unknown backoff strategy: ${strategy}`);
|
|
116
192
|
}
|
|
117
|
-
|
|
118
|
-
return newDelay;
|
|
193
|
+
return Math.min(newDelay, maximumDelay);
|
|
119
194
|
}
|
package/utils/base64.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { BinaryData } from '../types.js';
|
|
1
|
+
import type { BinaryData } from '../types/index.js';
|
|
2
2
|
export declare function encodeBase64(array: BinaryData, bytesOffset?: number, bytesLength?: number): string;
|
|
3
3
|
export declare function decodeBase64(base64: string): Uint8Array;
|
|
4
4
|
export declare function encodeBase64Url(array: BinaryData, bytesOffset?: number, length?: number): string;
|
package/utils/base64.js
CHANGED
|
@@ -36,7 +36,7 @@ export function decodeBase64Url(base64Url) {
|
|
|
36
36
|
}
|
|
37
37
|
export function base64ToBase64Url(input) {
|
|
38
38
|
return input
|
|
39
|
-
.replace(/=/ug, '')
|
|
39
|
+
.replace(/=/ug, '')
|
|
40
40
|
.replace(/\+/ug, '-')
|
|
41
41
|
.replace(/\//ug, '_');
|
|
42
42
|
}
|
|
@@ -98,7 +98,6 @@ export function utf8ArrayToString(bytes) {
|
|
|
98
98
|
}
|
|
99
99
|
return string;
|
|
100
100
|
}
|
|
101
|
-
// eslint-disable-next-line max-lines-per-function, max-statements
|
|
102
101
|
export function stringToUtf8Array(string) {
|
|
103
102
|
let bytesLength = 0;
|
|
104
103
|
for (let i = 0; i < string.length; i++) {
|
package/utils/binary.d.ts
CHANGED
package/utils/comparison.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
export declare function compareByValueSelection<T>(...selectors: ((item: T) =>
|
|
2
|
-
export declare function compareByValueSelectionDescending<T>(...selectors: ((item: T) =>
|
|
3
|
-
export declare function compareByValueSelectionOrdered<T>(...selectors: (readonly [(item: T) =>
|
|
1
|
+
export declare function compareByValueSelection<T, C extends string | number>(...selectors: ((item: T) => C)[]): (a: T, b: T) => number;
|
|
2
|
+
export declare function compareByValueSelectionDescending<T, C extends string | number>(...selectors: ((item: T) => C)[]): (a: T, b: T) => number;
|
|
3
|
+
export declare function compareByValueSelectionOrdered<T, C extends string | number>(...selectors: (readonly [(item: T) => C, 1 | -1])[]): (a: T, b: T) => number;
|
|
4
4
|
export declare function compareByValueToOrder<T>(order: T[]): (a: T, b: T) => number;
|
|
5
5
|
export declare const orderRest: unique symbol;
|
|
6
6
|
export declare function compareByValueSelectionToOrder<T, TSelect>(order: (TSelect | typeof orderRest)[], selector: (item: T) => TSelect): (a: T, b: T) => number;
|
|
7
|
-
export declare function compareByValue<T>(a: T, b: T
|
|
8
|
-
export declare function compareByValueDescending<T>(a: T, b: T
|
|
7
|
+
export declare function compareByValue<T>(a: T, b: NoInfer<T>, strict?: boolean): number;
|
|
8
|
+
export declare function compareByValueDescending<T>(a: T, b: NoInfer<T>, strict?: boolean): number;
|
package/utils/comparison.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { isNullOrUndefined } from './type-guards.js';
|
|
2
|
+
import { typeOf } from './type-of.js';
|
|
1
3
|
export function compareByValueSelection(...selectors) {
|
|
2
4
|
return (a, b) => {
|
|
3
5
|
for (const selector of selectors) {
|
|
@@ -51,7 +53,7 @@ export function compareByValueSelectionToOrder(order, selector) {
|
|
|
51
53
|
const selectedB = selector(b);
|
|
52
54
|
const indexA = indexMap.get(selectedA) ?? indexMap.get(orderRest);
|
|
53
55
|
const indexB = indexMap.get(selectedB) ?? indexMap.get(orderRest);
|
|
54
|
-
if (indexA
|
|
56
|
+
if (isNullOrUndefined(indexA) || isNullOrUndefined(indexB)) {
|
|
55
57
|
throw new Error('Value not defined in order.');
|
|
56
58
|
}
|
|
57
59
|
return compareByValue(indexA, indexB);
|
|
@@ -70,7 +72,7 @@ export function compareByValue(a, b, strict = true) {
|
|
|
70
72
|
if (!strict) {
|
|
71
73
|
return 0;
|
|
72
74
|
}
|
|
73
|
-
throw new Error(
|
|
75
|
+
throw new Error(`Values of type ${typeOf(a)} and ${typeOf(b)} are not comparable.`);
|
|
74
76
|
}
|
|
75
77
|
export function compareByValueDescending(a, b, strict = true) {
|
|
76
78
|
if (a === b) {
|
|
@@ -85,5 +87,5 @@ export function compareByValueDescending(a, b, strict = true) {
|
|
|
85
87
|
if (!strict) {
|
|
86
88
|
return 0;
|
|
87
89
|
}
|
|
88
|
-
throw new Error(
|
|
90
|
+
throw new Error(`Values of type ${typeOf(a)} and ${typeOf(b)} are not comparable.`);
|
|
89
91
|
}
|
package/utils/cryptography.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { BinaryData, TypedExtract } from '../types.js';
|
|
1
|
+
import type { BinaryData, TypedExtract } from '../types/index.js';
|
|
2
2
|
import type { ReadonlyTuple } from 'type-fest';
|
|
3
3
|
export type AesMode = 'CBC' | 'CTR' | 'GCM' | 'KW';
|
|
4
4
|
export type EcdsaCurve = 'P-256' | 'P-384' | 'P-521';
|
package/utils/encoding.d.ts
CHANGED
package/utils/enum.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { EnumerationEntries, EnumerationKey, EnumerationObject, EnumerationValue } from '../types.js';
|
|
1
|
+
import type { EnumerationEntries, EnumerationKey, EnumerationObject, EnumerationValue } from '../types/index.js';
|
|
2
2
|
export declare function enumValueName<T extends EnumerationObject>(enumeration: T, value: T[keyof T]): EnumerationKey<T>;
|
|
3
3
|
export declare function enumEntries<T extends EnumerationObject>(enumeration: T): EnumerationEntries<T>;
|
|
4
4
|
export declare function enumKeys<T extends EnumerationObject>(enumeration: T): EnumerationKey<T>[];
|
package/utils/equals.d.ts
CHANGED
package/utils/format-error.d.ts
CHANGED
package/utils/helpers.d.ts
CHANGED
package/utils/helpers.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { supportsNotification } from '../supports.js';
|
|
2
1
|
import { DetailsError } from '../errors/details.error.js';
|
|
2
|
+
import { supportsNotification } from '../supports.js';
|
|
3
3
|
import { decycle } from './object/decycle.js';
|
|
4
4
|
/**
|
|
5
5
|
* Create an structured clone of an value using Notification if available, otherwise history state (may alters history)
|
|
@@ -64,7 +64,7 @@ export function parseFirstAndFamilyName(name) {
|
|
|
64
64
|
const firstName = parts.map((part) => part.trim()).join(' ');
|
|
65
65
|
return {
|
|
66
66
|
firstName: firstName.length > 0 ? firstName : undefined,
|
|
67
|
-
familyName: familyName.length > 0 ? familyName : undefined
|
|
67
|
+
familyName: familyName.length > 0 ? familyName : undefined,
|
|
68
68
|
};
|
|
69
69
|
}
|
|
70
70
|
export function iif(condition, trueFn, falseFn) {
|
package/utils/jwt.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import type { OneOrMany,
|
|
1
|
+
import type { OneOrMany, Record } from '../types/index.js';
|
|
2
2
|
import type { Key } from './cryptography.js';
|
|
3
3
|
export type JwtTokenAlgorithm = 'HS256' | 'HS384' | 'HS512';
|
|
4
|
-
export type JwtTokenHeader<T extends
|
|
4
|
+
export type JwtTokenHeader<T extends Record<string> = Record<string>> = {
|
|
5
5
|
alg: JwtTokenAlgorithm;
|
|
6
6
|
typ: 'JWT';
|
|
7
7
|
} & T;
|
|
8
|
-
export type JwtToken<TPayload =
|
|
8
|
+
export type JwtToken<TPayload = Record<string>, THeader extends JwtTokenHeader = JwtTokenHeader> = {
|
|
9
9
|
readonly header: THeader;
|
|
10
10
|
readonly payload: TPayload;
|
|
11
11
|
};
|
package/utils/merge.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { IsEqual, MergeDeep, MergeDeepOptions as TypeFestMergeDeepOptions } from 'type-fest';
|
|
2
|
-
import type { If, Merge, Record, TypedOmit } from '../types.js';
|
|
2
|
+
import type { If, Merge, Record, TypedOmit } from '../types/index.js';
|
|
3
3
|
type BaseType = Record | any[] | Map<any, any> | Set<any>;
|
|
4
4
|
export declare function merge<A extends BaseType, B extends BaseType>(a: A | undefined, b: B | undefined): A extends (infer T)[] ? B extends (infer U)[] ? (T | U)[] : never : A extends Map<infer K, infer V> ? B extends Map<infer K2, infer V2> ? Map<K | K2, V | V2> : never : A extends Set<infer T> ? B extends Set<infer U> ? Set<T | U> : never : A extends Record ? B extends Record ? Merge<A, B> : never : never;
|
|
5
5
|
export type MergeDeepOptions = TypedOmit<TypeFestMergeDeepOptions, 'arrayMergeMode'> & {
|
package/utils/middleware.js
CHANGED
|
@@ -32,11 +32,11 @@ export function composeAsyncMiddleware(middlewares, options = {}) {
|
|
|
32
32
|
if ((index < currentIndex) && (options.allowMultipleNextCalls != true)) {
|
|
33
33
|
throw new Error('next() called multiple times');
|
|
34
34
|
}
|
|
35
|
-
|
|
35
|
+
await dispatch(index + 1);
|
|
36
36
|
}
|
|
37
|
-
|
|
37
|
+
await middleware(context, next);
|
|
38
38
|
}
|
|
39
|
-
|
|
39
|
+
await dispatch(0);
|
|
40
40
|
}
|
|
41
41
|
return composedMiddleware;
|
|
42
42
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { AbstractConstructor } from '../../types.js';
|
|
1
|
+
import type { AbstractConstructor } from '../../types/index.js';
|
|
2
2
|
declare const isForwardRef: unique symbol;
|
|
3
3
|
export type ForwardRefTypeHint = 'object' | 'function' | AbstractConstructor;
|
|
4
4
|
export type ForwardRefOptions<T extends object = object> = {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Function, IfUnknown } from '../../types.js';
|
|
1
|
+
import type { Function, IfUnknown } from '../../types/index.js';
|
|
2
2
|
declare const lazyObjectValueSymbol: unique symbol;
|
|
3
3
|
export type LazyPropertyInitializer<T, K extends keyof T> = (this: T, key: K) => T[K];
|
|
4
4
|
export type LazyPropertyObjectDefinition<T extends object, P extends keyof T> = LazyPropertyDescriptor & {
|
package/utils/object/object.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type JsonPathInput } from '../../json-path/json-path.js';
|
|
2
|
-
import type { BaseType, FromEntries, ObjectLiteral, Optionalize, PickBy, Record, SimplifyObject, UnionToIntersection } from '../../types.js';
|
|
2
|
+
import type { BaseType, FromEntries, ObjectLiteral, Optionalize, PickBy, Record, SimplifyObject, UnionToIntersection } from '../../types/index.js';
|
|
3
3
|
export declare function hasOwnProperty<T extends Record, K extends keyof UnionToIntersection<T>>(obj: T, key: K): obj is Extract<T, Partial<Record<K>>>;
|
|
4
4
|
export declare function hasOwnProperty<T extends Record>(obj: T, key: keyof T): boolean;
|
|
5
5
|
/**
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { DeepFlatten, DeepNonNullable, Record } from '../../types.js';
|
|
1
|
+
import type { DeepFlatten, DeepNonNullable, Record } from '../../types/index.js';
|
|
2
2
|
export declare const propertyName: unique symbol;
|
|
3
3
|
export declare const cast: unique symbol;
|
|
4
4
|
export type PropertyName = {
|
package/utils/patch-worker.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type Signal, type ToSignalOptions } from '../signals/api.js';
|
|
2
|
-
import type { ReactiveValue } from '../types.js';
|
|
2
|
+
import type { ReactiveValue } from '../types/index.js';
|
|
3
3
|
export type ReactiveValueToSignalOptions<T> = ToSignalOptions<T>;
|
|
4
4
|
export declare function reactiveValueToSignal<T>(source: ReactiveValue<T>): Signal<T | undefined>;
|
|
5
5
|
export declare function reactiveValueToSignal<T>(source: ReactiveValue<T>, options: ReactiveValueToSignalOptions<T | undefined> & {
|
package/utils/reflection.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import 'reflect-metadata/lite';
|
|
2
|
-
import type { Type } from '../types.js';
|
|
2
|
+
import type { Type } from '../types/index.js';
|
|
3
3
|
export declare function getDesignType(target: object, propertyKey?: string | symbol): Type;
|
|
4
4
|
export declare function hasDesignType(target: object, propertyKey?: string | symbol): boolean;
|
|
5
5
|
export declare function getParameterTypes(target: object, propertyKey?: string | symbol): Type[] | undefined;
|
package/utils/repl.d.ts
CHANGED
package/utils/singleton.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ObjectLiteral } from '../types.js';
|
|
1
|
+
import type { ObjectLiteral } from '../types/index.js';
|
|
2
2
|
export type Builder<T> = () => T;
|
|
3
3
|
export type AsyncBuilder<T> = () => Promise<T>;
|
|
4
4
|
export declare function singleton<T>(type: ObjectLiteral, builder: Builder<T>): T;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type { BinaryData } from '../../types.js';
|
|
1
|
+
import type { BinaryData } from '../../types/index.js';
|
|
2
2
|
export declare function sizeLimitTransform<T extends BinaryData>(maxBytes: number, writableStrategy?: QueuingStrategy<T>, readableStrategy?: QueuingStrategy<T>): TransformStream<T, T>;
|
package/utils/type/extends.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import type { AbstractConstructor } from '../../types.js';
|
|
1
|
+
import type { AbstractConstructor } from '../../types/index.js';
|
|
2
2
|
export declare function typeExtends<Type extends AbstractConstructor, Base extends Type>(type: Type, base: Base): type is Base;
|
|
3
3
|
export declare function typeExtends<Base extends AbstractConstructor>(type: AbstractConstructor, base: Base): type is Base;
|
package/utils/type-guards.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { AbstractConstructor, BinaryData, JsonPrimitive, PascalCase, Primitive, Type, TypedArray } from '../types.js';
|
|
1
|
+
import type { AbstractConstructor, BinaryData, JsonPrimitive, PascalCase, Primitive, Type, TypedArray } from '../types/index.js';
|
|
2
2
|
export type AssertionMessage = string | (() => string);
|
|
3
3
|
export type IsFunction<T> = <U extends T = T>(value: any) => value is U;
|
|
4
4
|
export type IsNotFunction<T> = <V>(value: V) => value is Exclude<V, T>;
|
package/utils/url-builder.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { UndefinableJsonObject, UndefinableJsonPrimitive } from '../types.js';
|
|
1
|
+
import type { UndefinableJsonObject, UndefinableJsonPrimitive } from '../types/index.js';
|
|
2
2
|
export type UrlBuilderParameterValue = UndefinableJsonPrimitive;
|
|
3
3
|
export type UrlBuilderParameters = UndefinableJsonObject;
|
|
4
4
|
export type UrlBuilderOptions = {
|
package/utils/z-base32.d.ts
CHANGED
package/module/utils.d.ts
DELETED
package/module/utils.js
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
export async function runModules(modules, logger) {
|
|
2
|
-
const promises = modules.map(async (module) => {
|
|
3
|
-
if (logger != undefined) {
|
|
4
|
-
logger.verbose(`starting module ${module.name}`);
|
|
5
|
-
}
|
|
6
|
-
await module.run();
|
|
7
|
-
});
|
|
8
|
-
await Promise.all(promises);
|
|
9
|
-
}
|
|
10
|
-
export async function stopModules(modules, logger) {
|
|
11
|
-
const promises = modules.map(async (module) => {
|
|
12
|
-
if (logger != undefined) {
|
|
13
|
-
logger.verbose(`stopping module ${module.name}`);
|
|
14
|
-
}
|
|
15
|
-
await module.stop();
|
|
16
|
-
if (logger != undefined) {
|
|
17
|
-
logger.verbose(`stopped module ${module.name}`);
|
|
18
|
-
}
|
|
19
|
-
});
|
|
20
|
-
await Promise.all(promises);
|
|
21
|
-
}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|