@tstdl/base 0.89.8 → 0.90.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.
Files changed (90) hide show
  1. package/api/response.d.ts +2 -6
  2. package/api/response.js +9 -32
  3. package/api/server/gateway.js +3 -3
  4. package/api/server/middlewares/allowed-methods.middleware.js +1 -1
  5. package/authentication/client/authentication.service.js +6 -6
  6. package/authentication/errors/secret-requirements.error.d.ts +1 -1
  7. package/authentication/errors/secret-requirements.error.js +1 -1
  8. package/authentication/server/authentication.api-controller.js +2 -2
  9. package/authentication/server/authentication.service.js +2 -2
  10. package/authentication/server/helper.js +2 -2
  11. package/browser/module.js +1 -1
  12. package/cookie/cookie.js +1 -1
  13. package/data-structures/index-out-of-bounds.error.d.ts +1 -1
  14. package/data-structures/index-out-of-bounds.error.js +1 -1
  15. package/data-structures/sorted-array-list.js +1 -1
  16. package/database/mongo/mongo-base.repository.js +1 -1
  17. package/disposable/async-disposer.js +1 -1
  18. package/errors/errors.localization.d.ts +44 -0
  19. package/errors/errors.localization.js +65 -0
  20. package/{error → errors}/index.d.ts +2 -0
  21. package/{error → errors}/index.js +2 -0
  22. package/errors/invalid-credentials.error.d.ts +5 -0
  23. package/errors/invalid-credentials.error.js +7 -0
  24. package/http/http-headers.js +1 -1
  25. package/http/http-value-map.js +1 -1
  26. package/http/http.error.d.ts +1 -1
  27. package/http/http.error.js +1 -1
  28. package/http/utils.js +3 -3
  29. package/injector/resolve.error.d.ts +1 -1
  30. package/injector/resolve.error.js +1 -1
  31. package/openid-connect/oidc.service.js +2 -2
  32. package/package.json +3 -4
  33. package/reflection/decorator-data.js +1 -1
  34. package/rpc/rpc-error.d.ts +1 -1
  35. package/rpc/rpc-error.js +1 -1
  36. package/rpc/rpc.js +1 -1
  37. package/schema/schema.error.d.ts +2 -2
  38. package/schema/schema.error.js +1 -1
  39. package/search-index/elastic/search-index.js +2 -2
  40. package/search-index/error.d.ts +1 -1
  41. package/search-index/error.js +1 -1
  42. package/sse/server-sent-events.js +1 -1
  43. package/templates/providers/file.template-provider.js +1 -1
  44. package/templates/resolvers/file.template-resolver.js +1 -1
  45. package/text/localization.service.js +1 -1
  46. package/utils/async-iterable-helpers/parallel/for-each.js +1 -1
  47. package/utils/compression.js +1 -1
  48. package/utils/date-time.js +1 -1
  49. package/utils/encoding.js +1 -1
  50. package/utils/file-reader.js +1 -1
  51. package/utils/helpers.js +1 -1
  52. package/utils/image.js +1 -1
  53. package/utils/jwt.js +1 -1
  54. package/utils/math.js +1 -1
  55. package/utils/stream/size-limited-stream.js +1 -1
  56. package/utils/stream/stream-reader.js +1 -1
  57. package/utils/timing.js +1 -1
  58. package/utils/type-guards.js +1 -1
  59. /package/{error → errors}/api.error.d.ts +0 -0
  60. /package/{error → errors}/api.error.js +0 -0
  61. /package/{error → errors}/assertion.error.d.ts +0 -0
  62. /package/{error → errors}/assertion.error.js +0 -0
  63. /package/{error → errors}/bad-request.error.d.ts +0 -0
  64. /package/{error → errors}/bad-request.error.js +0 -0
  65. /package/{error → errors}/custom.error.d.ts +0 -0
  66. /package/{error → errors}/custom.error.js +0 -0
  67. /package/{error → errors}/details.error.d.ts +0 -0
  68. /package/{error → errors}/details.error.js +0 -0
  69. /package/{error → errors}/forbidden.error.d.ts +0 -0
  70. /package/{error → errors}/forbidden.error.js +0 -0
  71. /package/{error → errors}/invalid-token.error.d.ts +0 -0
  72. /package/{error → errors}/invalid-token.error.js +0 -0
  73. /package/{error → errors}/max-bytes-exceeded.error.d.ts +0 -0
  74. /package/{error → errors}/max-bytes-exceeded.error.js +0 -0
  75. /package/{error → errors}/method-not-allowed.error.d.ts +0 -0
  76. /package/{error → errors}/method-not-allowed.error.js +0 -0
  77. /package/{error → errors}/multi.error.d.ts +0 -0
  78. /package/{error → errors}/multi.error.js +0 -0
  79. /package/{error → errors}/not-found.error.d.ts +0 -0
  80. /package/{error → errors}/not-found.error.js +0 -0
  81. /package/{error → errors}/not-implemented.error.d.ts +0 -0
  82. /package/{error → errors}/not-implemented.error.js +0 -0
  83. /package/{error → errors}/not-supported.error.d.ts +0 -0
  84. /package/{error → errors}/not-supported.error.js +0 -0
  85. /package/{error → errors}/timeout.error.d.ts +0 -0
  86. /package/{error → errors}/timeout.error.js +0 -0
  87. /package/{error → errors}/unauthorized.error.d.ts +0 -0
  88. /package/{error → errors}/unauthorized.error.js +0 -0
  89. /package/{error → errors}/unsupported-media-type.error.d.ts +0 -0
  90. /package/{error → errors}/unsupported-media-type.error.js +0 -0
package/api/response.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import type { CustomError, CustomErrorStatic } from '../error/index.js';
1
+ import type { CustomError, CustomErrorStatic } from '../errors/index.js';
2
2
  import type { UndefinableJson } from '../types.js';
3
3
  export type ErrorHandlerData = undefined | UndefinableJson;
4
4
  export type ErrorSerializer<T extends CustomError, TData extends ErrorHandlerData> = (error: T) => TData;
@@ -22,14 +22,10 @@ export type ResponseError = {
22
22
  data?: ErrorHandlerData;
23
23
  };
24
24
  export declare function registerErrorHandler<T extends CustomError, TData extends ErrorHandlerData>(constructor: CustomErrorStatic<T>, statusCode: number, serializer: ErrorSerializer<T, TData>, deserializer: ErrorDeserializer<T, TData>): void;
25
- export declare function hasErrorHandler(constructor: CustomErrorStatic | ErrorResponse | string): boolean;
25
+ export declare function hasErrorHandler(typeOrResponseOrName: CustomErrorStatic | ErrorResponse | string): boolean;
26
26
  export declare function getErrorStatusCode(error: CustomError, defaultStatusCode?: number): number;
27
- export declare function createResultResponse<T>(result: T): ResultResponse<T>;
28
27
  export declare function createErrorResponse(error: Error, details?: any): ErrorResponse;
29
28
  export declare function createErrorResponse(name: string, message: string, details?: any): ErrorResponse;
30
- export declare function parseResponse<T>(response: Response<T>): T;
31
29
  export declare function parseErrorResponse(response: ErrorResponse, fallbackToGenericApiError?: true): Error;
32
30
  export declare function parseErrorResponse(response: ErrorResponse, fallbackToGenericApiError: false): Error | undefined;
33
- export declare function isResultResponse<T = any>(response: Response<T> | unknown): response is ResultResponse<T>;
34
31
  export declare function isErrorResponse(response: Response<any> | unknown): response is ErrorResponse;
35
- export declare function isResponse<T = any>(obj: unknown): obj is Response<T>;
package/api/response.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { SecretRequirementsError } from '../authentication/errors/secret-requirements.error.js';
2
2
  import { SchemaError } from '../schema/schema.error.js';
3
- import { ApiError, BadRequestError, ForbiddenError, InvalidTokenError, MaxBytesExceededError, MethodNotAllowedError, NotFoundError, NotImplementedError, NotSupportedError, UnauthorizedError, UnsupportedMediaTypeError } from '../error/index.js';
3
+ import { ApiError, BadRequestError, ForbiddenError, InvalidTokenError, MaxBytesExceededError, MethodNotAllowedError, NotFoundError, NotImplementedError, NotSupportedError, UnauthorizedError, UnsupportedMediaTypeError } from '../errors/index.js';
4
4
  import { assertString, isDefined, isFunction, isObject, isString } from '../utils/type-guards.js';
5
5
  import { deserializeSchemaError, serializeSchemaError } from './default-error-handlers.js';
6
6
  const errorHandlers = new Map();
@@ -11,25 +11,19 @@ export function registerErrorHandler(constructor, statusCode, serializer, deseri
11
11
  }
12
12
  errorHandlers.set(constructor.errorName, { statusCode, serializer, deserializer });
13
13
  }
14
- export function hasErrorHandler(constructor) {
15
- const name = isFunction(constructor)
16
- ? constructor.errorName
17
- : isString(constructor)
18
- ? constructor
19
- : isErrorResponse(constructor)
20
- ? constructor.error.name
14
+ export function hasErrorHandler(typeOrResponseOrName) {
15
+ const name = isFunction(typeOrResponseOrName)
16
+ ? typeOrResponseOrName.errorName
17
+ : isString(typeOrResponseOrName)
18
+ ? typeOrResponseOrName
19
+ : isErrorResponse(typeOrResponseOrName)
20
+ ? typeOrResponseOrName.error.name
21
21
  : undefined;
22
22
  return errorHandlers.has(name);
23
23
  }
24
24
  export function getErrorStatusCode(error, defaultStatusCode = 500) {
25
25
  return errorHandlers.get(error.name)?.statusCode ?? defaultStatusCode;
26
26
  }
27
- export function createResultResponse(result) {
28
- const response = {
29
- result
30
- };
31
- return response;
32
- }
33
27
  export function createErrorResponse(errorOrName, message = '', details) {
34
28
  let response;
35
29
  if (errorOrName instanceof Error) {
@@ -66,15 +60,6 @@ export function createErrorResponse(errorOrName, message = '', details) {
66
60
  }
67
61
  return response;
68
62
  }
69
- export function parseResponse(response) {
70
- if (isResultResponse(response)) {
71
- return response.result;
72
- }
73
- if (isErrorResponse(response)) {
74
- throw parseErrorResponse(response);
75
- }
76
- throw new Error('Unsupported response.');
77
- }
78
63
  export function parseErrorResponse(response, fallbackToGenericApiError = true) {
79
64
  const handler = errorHandlers.get(response.error.name);
80
65
  if (handler != undefined) {
@@ -86,16 +71,8 @@ export function parseErrorResponse(response, fallbackToGenericApiError = true) {
86
71
  }
87
72
  return new ApiError(response);
88
73
  }
89
- export function isResultResponse(response) {
90
- const hasResult = isObject(response) && isDefined(response.result);
91
- return hasResult;
92
- }
93
74
  export function isErrorResponse(response) {
94
- const hasError = isObject(response) && isDefined(response.error);
95
- return hasError;
96
- }
97
- export function isResponse(obj) {
98
- return (isResultResponse(obj) || isErrorResponse(obj));
75
+ return isObject(response) && isDefined(response.error);
99
76
  }
100
77
  registerErrorHandler(ApiError, 400, ({ response }) => response, (response) => new ApiError(response));
101
78
  registerErrorHandler(BadRequestError, 400, () => undefined, (_, error) => new BadRequestError(error.message));
@@ -11,9 +11,9 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
11
11
  return function (target, key) { decorator(target, key, paramIndex); }
12
12
  };
13
13
  import 'urlpattern-polyfill'; // eslint-disable-line import/no-unassigned-import
14
- import { BadRequestError } from '../../error/bad-request.error.js';
15
- import { NotFoundError } from '../../error/not-found.error.js';
16
- import { NotImplementedError } from '../../error/not-implemented.error.js';
14
+ import { BadRequestError } from '../../errors/bad-request.error.js';
15
+ import { NotFoundError } from '../../errors/not-found.error.js';
16
+ import { NotImplementedError } from '../../errors/not-implemented.error.js';
17
17
  import { HttpServerResponse } from '../../http/server/index.js';
18
18
  import { InjectArg, ResolveArg, Singleton, resolveArgumentType } from '../../injector/index.js';
19
19
  import { Logger } from '../../logger/index.js';
@@ -1,4 +1,4 @@
1
- import { MethodNotAllowedError } from '../../../error/method-not-allowed.error.js';
1
+ import { MethodNotAllowedError } from '../../../errors/method-not-allowed.error.js';
2
2
  import { HttpServerResponse } from '../../../http/server/index.js';
3
3
  import { isUndefined } from '../../../utils/type-guards.js';
4
4
  export async function allowedMethodsMiddleware(request, next, context) {
@@ -13,12 +13,12 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
13
13
  import { Subject, filter, firstValueFrom, race, timer } from 'rxjs';
14
14
  import { CancellationToken } from '../../cancellation/token.js';
15
15
  import { disposeAsync } from '../../disposable/index.js';
16
- import { BadRequestError } from '../../error/bad-request.error.js';
17
- import { ForbiddenError } from '../../error/forbidden.error.js';
18
- import { InvalidTokenError } from '../../error/invalid-token.error.js';
19
- import { NotFoundError } from '../../error/not-found.error.js';
20
- import { NotSupportedError } from '../../error/not-supported.error.js';
21
- import { UnauthorizedError } from '../../error/unauthorized.error.js';
16
+ import { BadRequestError } from '../../errors/bad-request.error.js';
17
+ import { ForbiddenError } from '../../errors/forbidden.error.js';
18
+ import { InvalidTokenError } from '../../errors/invalid-token.error.js';
19
+ import { NotFoundError } from '../../errors/not-found.error.js';
20
+ import { NotSupportedError } from '../../errors/not-supported.error.js';
21
+ import { UnauthorizedError } from '../../errors/unauthorized.error.js';
22
22
  import { Inject, Optional, Singleton, afterResolve, inject } from '../../injector/index.js';
23
23
  import { Lock } from '../../lock/index.js';
24
24
  import { Logger } from '../../logger/index.js';
@@ -1,4 +1,4 @@
1
- import { CustomError } from '../../error/custom.error.js';
1
+ import { CustomError } from '../../errors/custom.error.js';
2
2
  export declare class SecretRequirementsError extends CustomError {
3
3
  static readonly errorName = "SecretRequirementsError";
4
4
  constructor(message?: string);
@@ -1,4 +1,4 @@
1
- import { CustomError } from '../../error/custom.error.js';
1
+ import { CustomError } from '../../errors/custom.error.js';
2
2
  export class SecretRequirementsError extends CustomError {
3
3
  static errorName = 'SecretRequirementsError';
4
4
  constructor(message = 'Secret requirements not met.') {
@@ -8,7 +8,7 @@ var __metadata = (this && this.__metadata) || function (k, v) {
8
8
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
9
9
  };
10
10
  import { apiController } from '../../api/server/index.js';
11
- import { UnauthorizedError } from '../../error/unauthorized.error.js';
11
+ import { InvalidCredentialsError } from '../../errors/invalid-credentials.error.js';
12
12
  import { HttpServerResponse } from '../../http/server/index.js';
13
13
  import { currentTimestamp } from '../../utils/date-time.js';
14
14
  import { authenticationApiDefinition } from '../authentication.api.js';
@@ -23,7 +23,7 @@ let AuthenticationApiController = class AuthenticationApiController {
23
23
  async token({ parameters }) {
24
24
  const authenticationResult = await this.authenticationService.authenticate(parameters.subject, parameters.secret);
25
25
  if (!authenticationResult.success) {
26
- throw new UnauthorizedError('Invalid credentials.');
26
+ throw new InvalidCredentialsError();
27
27
  }
28
28
  const result = await this.authenticationService.getToken(authenticationResult.subject, parameters.data);
29
29
  return this.getTokenResponse(result);
@@ -10,8 +10,8 @@ var __metadata = (this && this.__metadata) || function (k, v) {
10
10
  var __param = (this && this.__param) || function (paramIndex, decorator) {
11
11
  return function (target, key) { decorator(target, key, paramIndex); }
12
12
  };
13
- import { InvalidTokenError } from '../../error/invalid-token.error.js';
14
- import { NotImplementedError } from '../../error/not-implemented.error.js';
13
+ import { InvalidTokenError } from '../../errors/invalid-token.error.js';
14
+ import { NotImplementedError } from '../../errors/not-implemented.error.js';
15
15
  import { Inject, Optional, Singleton, afterResolve } from '../../injector/index.js';
16
16
  import { Alphabet } from '../../utils/alphabet.js';
17
17
  import { deriveBytesMultiple, importPbkdf2Key } from '../../utils/cryptography.js';
@@ -1,5 +1,5 @@
1
- import { BadRequestError } from '../../error/bad-request.error.js';
2
- import { InvalidTokenError } from '../../error/invalid-token.error.js';
1
+ import { BadRequestError } from '../../errors/bad-request.error.js';
2
+ import { InvalidTokenError } from '../../errors/invalid-token.error.js';
3
3
  import { currentTimestampSeconds } from '../../utils/date-time.js';
4
4
  import { parseAndValidateJwtTokenString } from '../../utils/jwt.js';
5
5
  import { isArray, isDefined, isUndefined } from '../../utils/type-guards.js';
package/browser/module.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { chromium, firefox, webkit } from 'playwright';
2
- import { NotSupportedError } from '../error/not-supported.error.js';
2
+ import { NotSupportedError } from '../errors/not-supported.error.js';
3
3
  import { Injector } from '../injector/injector.js';
4
4
  import { copyObjectProperties, filterUndefinedObjectProperties } from '../utils/object/object.js';
5
5
  import { isDefined, isUndefined } from '../utils/type-guards.js';
package/cookie/cookie.js CHANGED
@@ -1,4 +1,4 @@
1
- import { NotSupportedError } from '../error/not-supported.error.js';
1
+ import { NotSupportedError } from '../errors/not-supported.error.js';
2
2
  import { trim } from '../utils/string/trim.js';
3
3
  import { isDefined, isNumber, isUndefined } from '../utils/type-guards.js';
4
4
  const sameSiteMap = {
@@ -1,4 +1,4 @@
1
- import { CustomError } from '../error/custom.error.js';
1
+ import { CustomError } from '../errors/custom.error.js';
2
2
  export declare class IndexOutOfBoundsError extends CustomError {
3
3
  constructor({ index, count, size }: {
4
4
  index: number;
@@ -1,4 +1,4 @@
1
- import { CustomError } from '../error/custom.error.js';
1
+ import { CustomError } from '../errors/custom.error.js';
2
2
  import { isDefined } from '../utils/type-guards.js';
3
3
  export class IndexOutOfBoundsError extends CustomError {
4
4
  constructor({ index, count, size }) {
@@ -9,7 +9,7 @@ var __metadata = (this && this.__metadata) || function (k, v) {
9
9
  };
10
10
  var SortedArrayList_1;
11
11
  /* eslint-disable @typescript-eslint/member-ordering */
12
- import { NotImplementedError } from '../error/not-implemented.error.js';
12
+ import { NotImplementedError } from '../errors/not-implemented.error.js';
13
13
  import { Serializable, serializable } from '../serializer/serializable.js';
14
14
  import { binarySearch, binarySearchFirst, binarySearchInsertionIndex, binarySearchLast } from '../utils/binary-search.js';
15
15
  import { compareByValue } from '../utils/comparison.js';
@@ -1,4 +1,4 @@
1
- import { NotFoundError } from '../../error/not-found.error.js';
1
+ import { NotFoundError } from '../../errors/not-found.error.js';
2
2
  import { objectKeys } from '../../utils/object/object.js';
3
3
  import { assertDefined, isNull, isNullOrUndefined } from '../../utils/type-guards.js';
4
4
  import { mongoDocumentFromMaybeNewEntity, toEntity, toMongoDocument, toMongoProjection, toNewEntity, toProjectedEntity } from './model/document.js';
@@ -1,6 +1,6 @@
1
1
  import { isDefined, isNullOrUndefined } from '../utils/type-guards.js';
2
2
  import { CancellationToken } from '../cancellation/token.js';
3
- import { MultiError } from '../error/multi.error.js';
3
+ import { MultiError } from '../errors/multi.error.js';
4
4
  import { dispose, disposeAsync, isAsyncDisposable, isDisposable } from './disposable.js';
5
5
  const deferrerToken = Symbol('DeferrerToken');
6
6
  export class AsyncDisposer {
@@ -0,0 +1,44 @@
1
+ import type { Localization, LocalizeItem } from '../text/localization.service.js';
2
+ import type { ApiError } from './api.error.js';
3
+ import type { BadRequestError } from './bad-request.error.js';
4
+ import type { CustomErrorStatic } from './custom.error.js';
5
+ import type { ForbiddenError } from './forbidden.error.js';
6
+ import type { InvalidCredentialsError } from './invalid-credentials.error.js';
7
+ import type { InvalidTokenError } from './invalid-token.error.js';
8
+ import type { MaxBytesExceededError } from './max-bytes-exceeded.error.js';
9
+ import type { MethodNotAllowedError } from './method-not-allowed.error.js';
10
+ import type { NotFoundError } from './not-found.error.js';
11
+ import type { NotImplementedError } from './not-implemented.error.js';
12
+ import type { NotSupportedError } from './not-supported.error.js';
13
+ import type { TimeoutError } from './timeout.error.js';
14
+ import type { UnauthorizedError } from './unauthorized.error.js';
15
+ import type { UnsupportedMediaTypeError } from './unsupported-media-type.error.js';
16
+ type TstdlErrors = [
17
+ typeof ApiError,
18
+ typeof BadRequestError,
19
+ typeof ForbiddenError,
20
+ typeof InvalidCredentialsError,
21
+ typeof InvalidTokenError,
22
+ typeof MaxBytesExceededError,
23
+ typeof MethodNotAllowedError,
24
+ typeof NotFoundError,
25
+ typeof NotImplementedError,
26
+ typeof NotSupportedError,
27
+ typeof TimeoutError,
28
+ typeof UnauthorizedError,
29
+ typeof UnsupportedMediaTypeError
30
+ ];
31
+ export type ErrorsLocalizationEntries<T extends CustomErrorStatic[]> = {
32
+ [I in Extract<keyof T, number> as TstdlErrors[I]['errorName']]: {
33
+ header: LocalizeItem<InstanceType<T[I]>>;
34
+ message?: LocalizeItem<InstanceType<T[I]>>;
35
+ };
36
+ };
37
+ export type ErrorsLocalization<T extends CustomErrorStatic[] = CustomErrorStatic[]> = Localization<{
38
+ errors: ErrorsLocalizationEntries<T>;
39
+ }>;
40
+ export declare const errorsLocalizationKeys: import("../text/localization.service.js").ProxyLocalizationKeys<{
41
+ errors: ErrorsLocalizationEntries<CustomErrorStatic<import("./custom.error.js").CustomError>[]>;
42
+ }>;
43
+ export declare const germanTstdlErrorsLocalization: ErrorsLocalization<TstdlErrors>;
44
+ export {};
@@ -0,0 +1,65 @@
1
+ import { getLocalizationKeys } from '../text/localization.service.js';
2
+ export const errorsLocalizationKeys = getLocalizationKeys();
3
+ export const germanTstdlErrorsLocalization = {
4
+ language: { code: 'de', name: 'Deutsch' },
5
+ keys: {
6
+ errors: {
7
+ ApiError: {
8
+ header: 'API Fehler',
9
+ message: getErrorMessage
10
+ },
11
+ BadRequestError: {
12
+ header: 'Ungültige Anfrage',
13
+ message: getErrorMessage
14
+ },
15
+ ForbiddenError: {
16
+ header: 'Zugriff nicht erlaubt',
17
+ message: getErrorMessage
18
+ },
19
+ InvalidCredentialsError: {
20
+ header: 'Ungültige Zugangsdaten',
21
+ message: getErrorMessage
22
+ },
23
+ InvalidTokenError: {
24
+ header: 'Anmeldung ungültig oder abgelaufen',
25
+ message: getErrorMessage
26
+ },
27
+ MaxBytesExceededError: {
28
+ header: 'Daten größer als erlaubt',
29
+ message: getErrorMessage
30
+ },
31
+ MethodNotAllowedError: {
32
+ header: 'Ungültige Anfrage',
33
+ message: getErrorMessage
34
+ },
35
+ NotFoundError: {
36
+ header: 'Nicht gefunden',
37
+ message: getErrorMessage
38
+ },
39
+ NotImplementedError: {
40
+ header: 'Funktion nicht implementiert',
41
+ message: getErrorMessage
42
+ },
43
+ NotSupportedError: {
44
+ header: 'Nicht unterstützt',
45
+ message: getErrorMessage
46
+ },
47
+ TimeoutError: {
48
+ header: 'Zeitüberschreitung',
49
+ message: getErrorMessage
50
+ },
51
+ UnauthorizedError: {
52
+ header: 'Unautorisiert',
53
+ message: getErrorMessage
54
+ },
55
+ UnsupportedMediaTypeError: {
56
+ header: '',
57
+ message: getErrorMessage
58
+ }
59
+ }
60
+ },
61
+ enums: []
62
+ };
63
+ function getErrorMessage(error) {
64
+ return `${error.message}`;
65
+ }
@@ -8,7 +8,9 @@ export * from './assertion.error.js';
8
8
  export * from './bad-request.error.js';
9
9
  export * from './custom.error.js';
10
10
  export * from './details.error.js';
11
+ export * from './errors.localization.js';
11
12
  export * from './forbidden.error.js';
13
+ export * from './invalid-credentials.error.js';
12
14
  export * from './invalid-token.error.js';
13
15
  export * from './max-bytes-exceeded.error.js';
14
16
  export * from './method-not-allowed.error.js';
@@ -8,7 +8,9 @@ export * from './assertion.error.js';
8
8
  export * from './bad-request.error.js';
9
9
  export * from './custom.error.js';
10
10
  export * from './details.error.js';
11
+ export * from './errors.localization.js';
11
12
  export * from './forbidden.error.js';
13
+ export * from './invalid-credentials.error.js';
12
14
  export * from './invalid-token.error.js';
13
15
  export * from './max-bytes-exceeded.error.js';
14
16
  export * from './method-not-allowed.error.js';
@@ -0,0 +1,5 @@
1
+ import { CustomError } from './custom.error.js';
2
+ export declare class InvalidCredentialsError extends CustomError {
3
+ static readonly errorName = "InvalidCredentialsError";
4
+ constructor(message?: string);
5
+ }
@@ -0,0 +1,7 @@
1
+ import { CustomError } from './custom.error.js';
2
+ export class InvalidCredentialsError extends CustomError {
3
+ static errorName = 'InvalidCredentialsError';
4
+ constructor(message = 'Invalid credentials.') {
5
+ super({ message });
6
+ }
7
+ }
@@ -1,4 +1,4 @@
1
- import { BadRequestError } from '../error/bad-request.error.js';
1
+ import { BadRequestError } from '../errors/bad-request.error.js';
2
2
  import { numberPattern } from '../utils/patterns.js';
3
3
  import { isNotNumber, isNotString, isNullOrUndefined, isNumber, isString, isUndefined } from '../utils/type-guards.js';
4
4
  import { HttpValueMap } from './http-value-map.js';
@@ -1,4 +1,4 @@
1
- import { BadRequestError } from '../error/bad-request.error.js';
1
+ import { BadRequestError } from '../errors/bad-request.error.js';
2
2
  import { toArray } from '../utils/array/array.js';
3
3
  import { isIterable } from '../utils/iterable-helpers/is-iterable.js';
4
4
  import { objectEntries } from '../utils/object/object.js';
@@ -1,6 +1,6 @@
1
1
  import type { TypedOmit, UndefinableJson } from '../types.js';
2
2
  import type { ErrorExtraInfo } from '../utils/format-error.js';
3
- import { CustomError } from '../error/custom.error.js';
3
+ import { CustomError } from '../errors/custom.error.js';
4
4
  import type { HttpClientRequest, HttpClientRequestObject, HttpClientResponse, HttpClientResponseObject } from './client/index.js';
5
5
  export declare enum HttpErrorReason {
6
6
  Unknown = "Unknown",
@@ -1,6 +1,6 @@
1
1
  import { propertyNameOf } from '../utils/object/property-name.js';
2
2
  import { isDefined, isNotString, isString } from '../utils/type-guards.js';
3
- import { CustomError } from '../error/custom.error.js';
3
+ import { CustomError } from '../errors/custom.error.js';
4
4
  export var HttpErrorReason;
5
5
  (function (HttpErrorReason) {
6
6
  HttpErrorReason["Unknown"] = "Unknown";
package/http/utils.js CHANGED
@@ -1,6 +1,6 @@
1
- import { MaxBytesExceededError } from '../error/max-bytes-exceeded.error.js';
2
- import { NotSupportedError } from '../error/not-supported.error.js';
3
- import { UnsupportedMediaTypeError } from '../error/unsupported-media-type.error.js';
1
+ import { MaxBytesExceededError } from '../errors/max-bytes-exceeded.error.js';
2
+ import { NotSupportedError } from '../errors/not-supported.error.js';
3
+ import { UnsupportedMediaTypeError } from '../errors/unsupported-media-type.error.js';
4
4
  import { isAnyIterable } from '../utils/any-iterable-iterator.js';
5
5
  import { decompress, decompressStream } from '../utils/compression.js';
6
6
  import { decodeText, decodeTextStream } from '../utils/encoding.js';
@@ -1,4 +1,4 @@
1
- import { CustomError } from '../error/custom.error.js';
1
+ import { CustomError } from '../errors/custom.error.js';
2
2
  import type { ResolveChain } from './resolve-chain.js';
3
3
  export declare class ResolveError extends CustomError {
4
4
  constructor(message: string, chain: ResolveChain, cause?: Error);
@@ -1,4 +1,4 @@
1
- import { CustomError } from '../error/custom.error.js';
1
+ import { CustomError } from '../errors/custom.error.js';
2
2
  import { isDefined } from '../utils/type-guards.js';
3
3
  export class ResolveError extends CustomError {
4
4
  constructor(message, chain, cause) {
@@ -10,8 +10,8 @@ var __metadata = (this && this.__metadata) || function (k, v) {
10
10
  var __param = (this && this.__param) || function (paramIndex, decorator) {
11
11
  return function (target, key) { decorator(target, key, paramIndex); }
12
12
  };
13
- import { ForbiddenError } from '../error/forbidden.error.js';
14
- import { NotImplementedError } from '../error/not-implemented.error.js';
13
+ import { ForbiddenError } from '../errors/forbidden.error.js';
14
+ import { NotImplementedError } from '../errors/not-implemented.error.js';
15
15
  import { HttpClient } from '../http/client/index.js';
16
16
  import { HttpHeaders } from '../http/http-headers.js';
17
17
  import { Inject, Optional, Singleton } from '../injector/index.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tstdl/base",
3
- "version": "0.89.8",
3
+ "version": "0.90.0",
4
4
  "author": "Patrick Hein",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -44,7 +44,7 @@
44
44
  "./disposable": "./disposable/index.js",
45
45
  "./distributed-loop": "./distributed-loop/index.js",
46
46
  "./enumerable": "./enumerable/index.js",
47
- "./error": "./error/index.js",
47
+ "./errors": "./errors/index.js",
48
48
  "./function": "./function/index.js",
49
49
  "./http": "./http/index.js",
50
50
  "./http/undici": "./http/client/adapters/undici.adapter.js",
@@ -134,14 +134,13 @@
134
134
  "peerDependencies": {
135
135
  "@elastic/elasticsearch": "^8.10",
136
136
  "@koa/router": "^12.0",
137
- "@tstdl/angular": "^0.89",
137
+ "@tstdl/angular": "^0.90",
138
138
  "@zxcvbn-ts/core": "^3.0",
139
139
  "@zxcvbn-ts/language-common": "^3.0",
140
140
  "@zxcvbn-ts/language-de": "^3.0",
141
141
  "@zxcvbn-ts/language-en": "^3.0",
142
142
  "chroma-js": "^2.4",
143
143
  "handlebars": "^4.7",
144
- "knex": "^2.5",
145
144
  "koa": "^2.14",
146
145
  "minio": "^7.1",
147
146
  "mjml": "^4.14",
@@ -1,4 +1,4 @@
1
- import { DetailsError } from '../error/details.error.js';
1
+ import { DetailsError } from '../errors/details.error.js';
2
2
  import { isDefined, isFunction, isNumber, isObject, isUndefined } from '../utils/type-guards.js';
3
3
  import { getConstructor } from './utils.js';
4
4
  // eslint-disable-next-line max-lines-per-function
@@ -1,4 +1,4 @@
1
- import { CustomError } from '../error/custom.error.js';
1
+ import { CustomError } from '../errors/custom.error.js';
2
2
  export declare class RpcError extends CustomError {
3
3
  static readonly errorName = "RpcError";
4
4
  constructor(message: string, cause?: any);
package/rpc/rpc-error.js CHANGED
@@ -1,4 +1,4 @@
1
- import { CustomError } from '../error/custom.error.js';
1
+ import { CustomError } from '../errors/custom.error.js';
2
2
  import { formatError } from '../utils/format-error.js';
3
3
  import { isDefined, isObject } from '../utils/type-guards.js';
4
4
  export class RpcError extends CustomError {
package/rpc/rpc.js CHANGED
@@ -1,6 +1,6 @@
1
1
  /* eslint-disable @typescript-eslint/no-unsafe-return */
2
2
  /* eslint-disable @typescript-eslint/no-unsafe-argument */
3
- import { NotImplementedError } from '../error/not-implemented.error.js';
3
+ import { NotImplementedError } from '../errors/not-implemented.error.js';
4
4
  import { deserialize, registerSerializer, serialize } from '../serializer/index.js';
5
5
  import { hasOwnProperty } from '../utils/object/object.js';
6
6
  import { reflectMethods } from '../utils/proxy.js';
@@ -1,5 +1,5 @@
1
- import type { CustomErrorOptions } from '../error/custom.error.js';
2
- import { CustomError } from '../error/custom.error.js';
1
+ import type { CustomErrorOptions } from '../errors/custom.error.js';
2
+ import { CustomError } from '../errors/custom.error.js';
3
3
  import type { JsonPath } from '../json-path/index.js';
4
4
  import type { OneOrMany, TypedOmit, UndefinableJson } from '../types.js';
5
5
  import type { ErrorExtraInfo } from '../utils/format-error.js';
@@ -1,4 +1,4 @@
1
- import { CustomError } from '../error/custom.error.js';
1
+ import { CustomError } from '../errors/custom.error.js';
2
2
  import { toArray } from '../utils/array/array.js';
3
3
  import { isArray, isDefined, isNotNullOrUndefined, isString } from '../utils/type-guards.js';
4
4
  import { getExpectString } from './schema.js';
@@ -1,5 +1,5 @@
1
- import { BadRequestError } from '../../error/bad-request.error.js';
2
- import { MultiError } from '../../error/multi.error.js';
1
+ import { BadRequestError } from '../../errors/bad-request.error.js';
2
+ import { MultiError } from '../../errors/multi.error.js';
3
3
  import { afterResolve } from '../../injector/interfaces.js';
4
4
  import { SearchIndex, SearchIndexError } from '../../search-index/index.js';
5
5
  import { decodeBase64, encodeBase64 } from '../../utils/base64.js';
@@ -1,4 +1,4 @@
1
- import { CustomError } from '../error/custom.error.js';
1
+ import { CustomError } from '../errors/custom.error.js';
2
2
  export declare class SearchIndexError extends CustomError {
3
3
  static readonly errorName = "SearchIndexError";
4
4
  readonly type: string;
@@ -1,4 +1,4 @@
1
- import { CustomError } from '../error/custom.error.js';
1
+ import { CustomError } from '../errors/custom.error.js';
2
2
  import { isDefined } from '../utils/type-guards.js';
3
3
  export class SearchIndexError extends CustomError {
4
4
  static errorName = 'SearchIndexError';
@@ -1,4 +1,4 @@
1
- import { NotSupportedError } from '../error/not-supported.error.js';
1
+ import { NotSupportedError } from '../errors/not-supported.error.js';
2
2
  import { distinctUntilChanged, filter, fromEvent, map, merge, ReplaySubject, share, shareReplay, startWith, takeUntil } from 'rxjs';
3
3
  export var ServerSentEventsState;
4
4
  (function (ServerSentEventsState) {
@@ -11,7 +11,7 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
11
11
  return function (target, key) { decorator(target, key, paramIndex); }
12
12
  };
13
13
  import * as path from 'node:path';
14
- import { BadRequestError } from '../../error/bad-request.error.js';
14
+ import { BadRequestError } from '../../errors/bad-request.error.js';
15
15
  import { InjectArg, Singleton } from '../../injector/decorators.js';
16
16
  import { resolveArgumentType } from '../../injector/interfaces.js';
17
17
  import { Schema } from '../../schema/index.js';
@@ -12,7 +12,7 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
12
12
  };
13
13
  import * as fs from 'node:fs/promises';
14
14
  import * as path from 'node:path';
15
- import { BadRequestError } from '../../error/bad-request.error.js';
15
+ import { BadRequestError } from '../../errors/bad-request.error.js';
16
16
  import { InjectArg, Singleton } from '../../injector/decorators.js';
17
17
  import { resolveArgumentType } from '../../injector/interfaces.js';
18
18
  import { Property } from '../../schema/index.js';
@@ -10,7 +10,7 @@ var __metadata = (this && this.__metadata) || function (k, v) {
10
10
  var __param = (this && this.__param) || function (paramIndex, decorator) {
11
11
  return function (target, key) { decorator(target, key, paramIndex); }
12
12
  };
13
- import { DetailsError } from '../error/details.error.js';
13
+ import { DetailsError } from '../errors/details.error.js';
14
14
  import { ResolveArg, Singleton } from '../injector/decorators.js';
15
15
  import { Logger } from '../logger/index.js';
16
16
  import { computed, signal, toObservable } from '../signals/api.js';
@@ -1,5 +1,5 @@
1
1
  import { ObservableSet } from '../../../collections/observable/observable-set.js';
2
- import { MultiError } from '../../../error/multi.error.js';
2
+ import { MultiError } from '../../../errors/multi.error.js';
3
3
  export async function parallelForEach(iterable, concurrency, func) {
4
4
  const running = new ObservableSet();
5
5
  const errors = [];
@@ -1,4 +1,4 @@
1
- import { NotSupportedError } from '../error/not-supported.error.js';
1
+ import { NotSupportedError } from '../errors/not-supported.error.js';
2
2
  import { dynamicImport } from '../import.js';
3
3
  import { supportsReadableStream } from '../supports.js';
4
4
  import { isAsyncIterable } from './async-iterable-helpers/is-async-iterable.js';
@@ -1,4 +1,4 @@
1
- import { NotSupportedError } from '../error/not-supported.error.js';
1
+ import { NotSupportedError } from '../errors/not-supported.error.js';
2
2
  import { DateTime } from 'luxon';
3
3
  import { isDate, isNumber } from './type-guards.js';
4
4
  import { typeOf } from './type-of.js';
package/utils/encoding.js CHANGED
@@ -1,4 +1,4 @@
1
- import { AssertionError } from '../error/assertion.error.js';
1
+ import { AssertionError } from '../errors/assertion.error.js';
2
2
  import { createArray } from './array/array.js';
3
3
  import { toUint8Array } from './binary.js';
4
4
  import { isUndefined } from './type-guards.js';
@@ -1,4 +1,4 @@
1
- import { DetailsError } from '../error/details.error.js';
1
+ import { DetailsError } from '../errors/details.error.js';
2
2
  export async function readAsText(blob, encoding) {
3
3
  return setup((reader) => reader.readAsText(blob, encoding));
4
4
  }
package/utils/helpers.js CHANGED
@@ -1,6 +1,6 @@
1
1
  /* eslint-disable @typescript-eslint/ban-types */
2
2
  import { supportsNotification } from '../supports.js';
3
- import { DetailsError } from '../error/details.error.js';
3
+ import { DetailsError } from '../errors/details.error.js';
4
4
  import { decycle } from './object/decycle.js';
5
5
  import { isDefined } from './type-guards.js';
6
6
  /**
package/utils/image.js CHANGED
@@ -1,4 +1,4 @@
1
- import { AssertionError } from '../error/assertion.error.js';
1
+ import { AssertionError } from '../errors/assertion.error.js';
2
2
  import { firstValueFrom, fromEvent, map, race, switchMap, throwError } from 'rxjs';
3
3
  import { FactoryMap } from './factory-map.js';
4
4
  import { assertNotNullPass, isFunction, isNull } from './type-guards.js';
package/utils/jwt.js CHANGED
@@ -1,4 +1,4 @@
1
- import { InvalidTokenError } from '../error/invalid-token.error.js';
1
+ import { InvalidTokenError } from '../errors/invalid-token.error.js';
2
2
  import { toArray } from './array/array.js';
3
3
  import { decodeBase64Url, encodeBase64Url } from './base64.js';
4
4
  import { importHmacKey, sign } from './cryptography.js';
package/utils/math.js CHANGED
@@ -1,4 +1,4 @@
1
- import { NotSupportedError } from '../error/not-supported.error.js';
1
+ import { NotSupportedError } from '../errors/not-supported.error.js';
2
2
  import { defaultRandomNumberGeneratorFn } from '../random/number-generator/random-number-generator-function.js';
3
3
  /**
4
4
  * Generate a random float in interval [min, max).
@@ -1,4 +1,4 @@
1
- import { MaxBytesExceededError } from '../../error/max-bytes-exceeded.error.js';
1
+ import { MaxBytesExceededError } from '../../errors/max-bytes-exceeded.error.js';
2
2
  export function sizeLimitTransform(maxBytes, writableStrategy, readableStrategy) {
3
3
  let totalLength = 0;
4
4
  return new TransformStream({
@@ -1,4 +1,4 @@
1
- import { BadRequestError } from '../../error/bad-request.error.js';
1
+ import { BadRequestError } from '../../errors/bad-request.error.js';
2
2
  import { isAnyIterable } from '../any-iterable-iterator.js';
3
3
  import { concatArrayBufferViews } from '../binary.js';
4
4
  import { isDefined } from '../type-guards.js';
package/utils/timing.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { firstValueFrom, map, race, timer } from 'rxjs';
2
- import { TimeoutError } from '../error/timeout.error.js';
2
+ import { TimeoutError } from '../errors/timeout.error.js';
3
3
  import { _throw } from './throw.js';
4
4
  import { resolveValueOrProvider } from './value-or-provider.js';
5
5
  /** timeout for specified duration */
@@ -1,6 +1,6 @@
1
1
  /* eslint-disable @typescript-eslint/ban-types, @typescript-eslint/restrict-template-expressions, max-statements-per-line, no-eq-null */
2
2
  import { supportsBlob, supportsReadableStream } from '../supports.js';
3
- import { AssertionError } from '../error/assertion.error.js';
3
+ import { AssertionError } from '../errors/assertion.error.js';
4
4
  export function assert(condition, message = 'assertion failed') {
5
5
  if (!condition) {
6
6
  throw new AssertionError((typeof message == 'function') ? message() : message);
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes