@lucaapp/service-utils 1.46.0 → 1.46.2

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.
@@ -115,9 +115,7 @@ const validateAndSendResponse = async (expressResponse, response, validResponses
115
115
  // get schema respective to status code
116
116
  const responseSchema = validResponses.find(responseSchema => responseSchema.status === response.status);
117
117
  const schema = responseSchema?.schema;
118
- const isZodSchema = schema instanceof zod_1.z.ZodSchema;
119
- const isZodVoid = schema instanceof zod_1.z.ZodVoid;
120
- (0, assert_1.default)(isZodSchema || isZodVoid);
118
+ (0, assert_1.default)(schema);
121
119
  // validate response schema
122
120
  const validatedResponseBody = await schema.parseAsync(response.body);
123
121
  if (validatedResponseBody === undefined) {
@@ -26,7 +26,7 @@ declare class Money implements Money {
26
26
  * @deprecated Use getFormattedString in place of getEuroString
27
27
  */
28
28
  getEuroString(): string;
29
- getFormattedString(locale: string): string;
29
+ getFormattedString(locale: string, includeSymbol?: boolean): string;
30
30
  percentage(percentage: number): Money;
31
31
  min(comparator: Money): Money;
32
32
  max(comparator: Money): Money;
@@ -40,9 +40,9 @@ class Money {
40
40
  getEuroString() {
41
41
  return this.getEuroAmount().toFixed(2);
42
42
  }
43
- getFormattedString(locale) {
43
+ getFormattedString(locale, includeSymbol = true) {
44
44
  const transactionalLanguage = locale === 'de' ? 'de-DE' : 'en-US';
45
- return new Intl.NumberFormat(transactionalLanguage, {
45
+ const formattedString = new Intl.NumberFormat(transactionalLanguage, {
46
46
  style: 'currency',
47
47
  currency: 'EUR',
48
48
  minimumFractionDigits: 2,
@@ -50,6 +50,9 @@ class Money {
50
50
  })
51
51
  .format(this.getEuroAmount())
52
52
  .replace(/\s/, ' ');
53
+ return includeSymbol
54
+ ? formattedString
55
+ : formattedString.replace(/€|\s/g, '');
53
56
  }
54
57
  add(addend) {
55
58
  return Money.fromAmount(this.value + (addend?.value || 0));
@@ -6,6 +6,16 @@ import { z } from 'zod';
6
6
  type JWKS = {
7
7
  keys: jose.JWK[];
8
8
  };
9
+ export declare enum ServiceIdentityErrorType {
10
+ NO_JWT_PROVIDED = "SERVICE_IDENTITY_NO_JWT_PROVIDED",
11
+ URL_MISMATCH = "SERVICE_IDENTITY_URL_MISMATCH",
12
+ METHOD_MISMATCH = "SERVICE_IDENTITY_METHOD_MISMATCH"
13
+ }
14
+ export declare class ServiceIdentityError extends Error {
15
+ type: ServiceIdentityErrorType;
16
+ meta?: object | undefined;
17
+ constructor(type: ServiceIdentityErrorType, message?: string, meta?: object | undefined);
18
+ }
9
19
  declare class ServiceIdentity {
10
20
  readonly identityName: string;
11
21
  readonly identityKid: string;
@@ -26,7 +26,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
26
26
  return (mod && mod.__esModule) ? mod : { "default": mod };
27
27
  };
28
28
  Object.defineProperty(exports, "__esModule", { value: true });
29
- exports.ServiceIdentity = void 0;
29
+ exports.ServiceIdentity = exports.ServiceIdentityError = exports.ServiceIdentityErrorType = void 0;
30
30
  const jose = __importStar(require("jose"));
31
31
  const url_1 = require("url");
32
32
  const boom_1 = require("@hapi/boom");
@@ -47,7 +47,7 @@ var ServiceIdentityErrorType;
47
47
  ServiceIdentityErrorType["NO_JWT_PROVIDED"] = "SERVICE_IDENTITY_NO_JWT_PROVIDED";
48
48
  ServiceIdentityErrorType["URL_MISMATCH"] = "SERVICE_IDENTITY_URL_MISMATCH";
49
49
  ServiceIdentityErrorType["METHOD_MISMATCH"] = "SERVICE_IDENTITY_METHOD_MISMATCH";
50
- })(ServiceIdentityErrorType || (ServiceIdentityErrorType = {}));
50
+ })(ServiceIdentityErrorType = exports.ServiceIdentityErrorType || (exports.ServiceIdentityErrorType = {}));
51
51
  class ServiceIdentityError extends Error {
52
52
  constructor(type, message, meta) {
53
53
  super(message);
@@ -55,6 +55,7 @@ class ServiceIdentityError extends Error {
55
55
  this.meta = meta;
56
56
  }
57
57
  }
58
+ exports.ServiceIdentityError = ServiceIdentityError;
58
59
  class ServiceIdentity {
59
60
  constructor(identityName, identityKid, identityPrivateKey, identityPublicKey, debug = false) {
60
61
  this.jwksCache = {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lucaapp/service-utils",
3
- "version": "1.46.0",
3
+ "version": "1.46.2",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "files": [
@@ -12,39 +12,19 @@
12
12
  "build": "tsc -p tsconfig.build.json",
13
13
  "ts:check": "tsc -p . --noEmit",
14
14
  "lint": "eslint .",
15
- "test": "jest",
16
- "test:coverage": "jest --coverage",
17
- "test:ci": "jest --ci --coverage",
15
+ "test": "vitest run",
16
+ "test:coverage": "vitest run --coverage",
17
+ "test:ci": "VITEST_JUNIT_SUITE_NAME=service-utils CI=true vitest run --coverage",
18
18
  "audit": "improved-yarn-audit --ignore-dev-deps"
19
19
  },
20
- "devDependencies": {
21
- "@types/express": "4.17.13",
22
- "@types/jest": "^28.1.5",
23
- "@types/lodash": "^4.14.187",
24
- "@types/negotiator": "^0.6.1",
25
- "@types/uuid": "^8.3.4",
26
- "@typescript-eslint/eslint-plugin": "^5.30.6",
27
- "@typescript-eslint/parser": "^5.30.6",
28
- "conventional-changelog-conventionalcommits": "^5.0.0",
29
- "eslint": "^8.19.0",
30
- "eslint-plugin-prettier": "4.2.1",
31
- "improved-yarn-audit": "^3.0.0",
32
- "jest": "^28.1.2",
33
- "jest-junit": "^14.0.0",
34
- "prettier": "2.7.1",
35
- "semantic-release": "^19.0.3",
36
- "semantic-release-monorepo": "^7.0.5",
37
- "supertest": "^6.3.3",
38
- "ts-jest": "^28.0.5",
39
- "typescript": "^4.7.4"
40
- },
41
20
  "dependencies": {
42
- "@asteasolutions/zod-to-openapi": "4.1.0",
21
+ "@asteasolutions/zod-to-openapi": "4.6.0",
43
22
  "@hapi/boom": "^10.0.0",
44
23
  "@types/express": "4.17.13",
45
24
  "@types/response-time": "^2.3.5",
46
25
  "@types/supertest": "^2.0.12",
47
26
  "@types/swagger-ui-express": "4.1.3",
27
+ "@types/node": "18.11.9",
48
28
  "axios": "^0.27.2",
49
29
  "cls-rtracer": "^2.6.2",
50
30
  "express": "4.18.1",
@@ -52,6 +32,7 @@
52
32
  "jose": "4.9.2",
53
33
  "kafkajs": "2.1.0",
54
34
  "lodash": "^4.17.21",
35
+ "@tsconfig/node18": "1.0.1",
55
36
  "moment": "^2.29.4",
56
37
  "negotiator": "^0.6.3",
57
38
  "pino-http": "8.2.1",
@@ -61,6 +42,32 @@
61
42
  "swagger-ui-express": "4.5.0",
62
43
  "url-value-parser": "^2.2.0",
63
44
  "uuid": "^9.0.0",
45
+ "vitest": "0.30.1",
64
46
  "zod": "^3.21.4"
47
+ },
48
+ "devDependencies": {
49
+ "@types/express": "4.17.13",
50
+ "@types/lodash": "^4.14.187",
51
+ "@types/negotiator": "^0.6.1",
52
+ "@types/uuid": "^8.3.4",
53
+ "@types/supertest": "2.0.11",
54
+ "@typescript-eslint/eslint-plugin": "^5.30.6",
55
+ "@typescript-eslint/parser": "^5.30.6",
56
+ "conventional-changelog-conventionalcommits": "^5.0.0",
57
+ "eslint": "^8.19.0",
58
+ "eslint-plugin-prettier": "4.2.1",
59
+ "improved-yarn-audit": "^3.0.0",
60
+ "@vitest/coverage-c8": "0.29.2",
61
+ "@vitest/ui": "0.29.2",
62
+ "prettier": "2.7.1",
63
+ "semantic-release": "^19.0.3",
64
+ "semantic-release-monorepo": "^7.0.5",
65
+ "supertest": "^6.3.3",
66
+ "vite-tsconfig-paths": "4.0.5",
67
+ "eslint-plugin-vitest": "0.0.54",
68
+ "typescript": "^4.7.4"
69
+ },
70
+ "resolutions": {
71
+ "yaml": "2.2.2"
65
72
  }
66
73
  }