@lucaapp/service-utils 1.62.6 → 1.64.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.
package/README.md CHANGED
@@ -1,24 +1,31 @@
1
1
  ## service-utils
2
2
 
3
- `service-utils` aims at swapping common functionality for most/all backend services in order to reduce code duplication.
4
- Future use-cases should include logging, inter-service communication, metrics etc.
3
+ `service-utils` is a shared package that provides functionality for backend
4
+ services to reduce code duplication. It includes utilities for:
5
5
 
6
- #### Development
6
+ - Logging and monitoring
7
+ - API validation and OpenAPI documentation
8
+ - Error handling
9
+ - Database operations
10
+ - Authentication and authorization
11
+ - Kafka messaging
12
+ - HTTP client operations
13
+ - And more
7
14
 
8
- Development of service-utils package will take place in your local machine, not within the docker context.
9
- Therefore, some adoptions and preparations are necessary.
10
- Follow these steps for initial setup:
15
+ ### Development Setup
11
16
 
12
- * Navigate to `packages/service-utils`
13
- * Run `yarn link`
14
- * Navigate to `services/backend`
15
- * Run `yarn link @lucaapp/service-utils`
17
+ 1. Navigate to `packages/service-utils`
18
+ 2. Run `yarn link`
19
+ 3. Navigate to `services/backend`
20
+ 4. Run `yarn link @lucaapp/service-utils`
16
21
 
17
- This will connect your local sources for `@lucaapp/service-utils`.
18
- When making changes within the package, make sure to run the `build` target within `packages/service-utils/package.json` to have the changes available to backend web.
22
+ This will connect your local sources for `@lucaapp/service-utils`. When making
23
+ changes:
19
24
 
20
- After this preparations run `package-development` from `services/backend/package.json`.
21
- The following environment should be at least in place when running the target to make sure your local `backend` setup uses the proper endpoints:
25
+ 1. Run `yarn build` in `packages/service-utils` to compile changes
26
+ 2. Run `yarn package-development` in `services/backend` to test changes
27
+
28
+ Required environment variables for local development:
22
29
 
23
30
  ```shell
24
31
  export DB_HOSTNAME=localhost
@@ -26,16 +33,34 @@ export KAFKA_BROKER=localhost:9094
26
33
  export REDIS_HOSTNAME=localhost
27
34
  ```
28
35
 
29
- It will utilize the linked package and run `backend` locally.
30
- Make sure your docker stack has at least `database`, `kafka` and `redis`, but *not* `backend` up and running.
36
+ Ensure your docker stack has `database`, `kafka`, and `redis` running (but not
37
+ `backend`).
38
+
39
+ ### Available Scripts
40
+
41
+ - `yarn build` - Compile TypeScript to JavaScript
42
+ - `yarn ts:check` - Type check without emitting files
43
+ - `yarn lint` - Run ESLint
44
+ - `yarn test` - Run tests with Vitest
45
+ - `yarn test:coverage` - Run tests with coverage report
46
+ - `yarn test:ci` - Run tests in CI environment
47
+ - `yarn audit` - Run security audit (ignoring dev dependencies)
48
+
49
+ ### Publishing
31
50
 
32
- You should now be able to develop changes for `@lucaapp/service-utils`.
51
+ The package is automatically published when changes are merged to `dev`. Follow
52
+ [semantic-release](https://www.npmjs.com/package/semantic-release) conventions
53
+ in commit messages to trigger appropriate versioning.
33
54
 
34
- #### Packaging
55
+ ### Dependencies
35
56
 
36
- Packaging of `@lucaapp/service-utils` will be automatically published, when run in `dev`.
37
- See `./gitlab-ci/publish[.template].yml` for reference.
57
+ The package uses modern versions of key dependencies:
38
58
 
39
- Make sure to follow [semantic-release](https://www.npmjs.com/package/semantic-release) conventions when writing commit messages.
59
+ - TypeScript 5.5.3
60
+ - Node.js 18
61
+ - Express 4.21.2
62
+ - Sequelize 6.32.0
63
+ - Zod 3.22.3
64
+ - Vitest 3.0.5 for testing
40
65
 
41
- Depending on the used semantic-release indicators a new version of `@lucaapp/service-utils` will be made available and tagged within the luca-web repository.
66
+ See `package.json` for a complete list of dependencies.
@@ -0,0 +1,16 @@
1
+ export declare enum OperatorRole {
2
+ Owner = "Owner",// level 6
3
+ Admin = "Admin",// level 5
4
+ Finance = "Finance",// level 4
5
+ Manager = "Manager",// level 3
6
+ Supervisor = "Supervisor",// level 2
7
+ Viewer = "Viewer"
8
+ }
9
+ export type OperatorLocationGroup = {
10
+ uuid: string;
11
+ operatorId: string;
12
+ locationGroupId: string;
13
+ role: OperatorRole;
14
+ createdAt: Date;
15
+ updatedAt: Date;
16
+ };
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.OperatorRole = void 0;
4
+ var OperatorRole;
5
+ (function (OperatorRole) {
6
+ OperatorRole["Owner"] = "Owner";
7
+ OperatorRole["Admin"] = "Admin";
8
+ OperatorRole["Finance"] = "Finance";
9
+ OperatorRole["Manager"] = "Manager";
10
+ OperatorRole["Supervisor"] = "Supervisor";
11
+ OperatorRole["Viewer"] = "Viewer";
12
+ })(OperatorRole || (exports.OperatorRole = OperatorRole = {}));
@@ -5,4 +5,9 @@ export type Reservation = {
5
5
  startsAt: Date;
6
6
  createdAt: Date;
7
7
  updatedAt: Date;
8
+ tables?: Array<{
9
+ id: string;
10
+ internalNumber: number;
11
+ customName: string | null;
12
+ }>;
8
13
  };
@@ -0,0 +1 @@
1
+ export * from './money';
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./money"), exports);
@@ -0,0 +1,21 @@
1
+ import { DataTypes } from 'sequelize';
2
+ declare class MONEY extends DataTypes.ABSTRACT.prototype.constructor {
3
+ static key: string;
4
+ static warn: () => void;
5
+ key: string;
6
+ escape: boolean;
7
+ types: {
8
+ postgres: string[];
9
+ sqlite: string[];
10
+ };
11
+ static toSql(): string;
12
+ validate(value: unknown, options: unknown): boolean;
13
+ _sanitize(value: unknown): number;
14
+ static stringify(value: unknown): string;
15
+ static dialectTypes: string;
16
+ static parse(value: unknown): number;
17
+ }
18
+ export declare const ExtendedDataTypes: {
19
+ MONEY: typeof MONEY & (() => typeof MONEY);
20
+ };
21
+ export {};
@@ -0,0 +1,56 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ExtendedDataTypes = void 0;
4
+ const sequelize_1 = require("sequelize");
5
+ // Define the MONEY data type
6
+ class MONEY extends sequelize_1.DataTypes.ABSTRACT.prototype.constructor {
7
+ constructor() {
8
+ super(...arguments);
9
+ this.key = MONEY.key;
10
+ // Optional: disable escaping after stringifier. Do this at your own risk, since this opens opportunity for SQL injections.
11
+ this.escape = false;
12
+ // Optional: map dialect datatype names (mandatory if not creating dialect-specific datatype classes as in the example below)
13
+ this.types = {
14
+ postgres: ['pg_new_type'],
15
+ sqlite: ['sqlite_new_type'],
16
+ };
17
+ }
18
+ // Mandatory: complete definition of the new type in the database
19
+ static toSql() {
20
+ return 'INTEGER(11) UNSIGNED ZEROFILL';
21
+ }
22
+ // Optional: validator function
23
+ validate(value, options) {
24
+ return typeof value === 'number' && !Number.isNaN(value);
25
+ }
26
+ // Optional: sanitizer
27
+ _sanitize(value) {
28
+ // Force all numbers to be positive
29
+ return value < 0 ? 0 : Math.round(value);
30
+ }
31
+ // Optional: value stringifier before sending to database
32
+ static stringify(value) {
33
+ return value.toString();
34
+ }
35
+ // Optional: parser for values received from the database
36
+ static parse(value) {
37
+ return Number.parseInt(value);
38
+ }
39
+ }
40
+ // Mandatory: set the type key
41
+ MONEY.key = 'MONEY';
42
+ MONEY.warn = () => { };
43
+ MONEY.dialectTypes = 'test';
44
+ // Create a new type that extends DataTypes and includes MONEY
45
+ exports.ExtendedDataTypes = {
46
+ // ...DataTypes,
47
+ MONEY: sequelize_1.Utils.classToInvokable(MONEY),
48
+ };
49
+ // Export the extended DataTypes
50
+ // export { ExtendedDataTypes as DataTypes };
51
+ // // Type declaration merging
52
+ // declare module 'sequelize' {
53
+ // interface DataTypes {
54
+ // MONEY: typeof MONEY;
55
+ // }
56
+ // }
@@ -0,0 +1,2 @@
1
+ export type { Logger } from 'pino';
2
+ export type { HttpLogger } from 'pino-http';
@@ -0,0 +1,2 @@
1
+ export type { Logger } from 'pino';
2
+ export type { HttpLogger } from 'pino-http';
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lucaapp/service-utils",
3
- "version": "1.62.6",
3
+ "version": "1.64.0",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "files": [
@@ -20,14 +20,14 @@
20
20
  "dependencies": {
21
21
  "@asteasolutions/zod-to-openapi": "6.1.0",
22
22
  "@hapi/boom": "^10.0.0",
23
- "@sentry/node": "^9.3.0",
24
- "@tsconfig/node18": "1.0.1",
23
+ "@sentry/node": "^9.10.1",
24
+ "@tsconfig/node22": "22.0.0",
25
25
  "@types/express": "4.17.15",
26
26
  "@types/express-serve-static-core": "^4.17.43",
27
- "@types/node": "18.18.2",
27
+ "@types/node": "22.13.11",
28
28
  "@types/response-time": "^2.3.8",
29
29
  "@types/swagger-ui-express": "4.1.3",
30
- "axios": "^1.7.4",
30
+ "axios": "^1.8.2",
31
31
  "busboy": "^1.6.0",
32
32
  "cls-rtracer": "^2.6.2",
33
33
  "express": "4.21.2",
@@ -47,41 +47,44 @@
47
47
  "swagger-ui-express": "5.0.1",
48
48
  "url-value-parser": "^2.2.0",
49
49
  "uuid": "^9.0.0",
50
- "zod": "3.22.3"
50
+ "zod": "3.22.3",
51
+ "@apidevtools/swagger-parser": "10.0.3"
51
52
  },
52
53
  "devDependencies": {
53
- "@types/busboy": "^1.5.3",
54
+ "@types/busboy": "^1.5.4",
54
55
  "@types/lodash": "^4.14.187",
55
56
  "@types/negotiator": "^0.6.1",
56
57
  "@types/pino-http": "5.8.4",
57
- "@types/supertest": "2.0.11",
58
+ "@types/supertest": "2.0.16",
58
59
  "@types/uuid": "^8.3.4",
59
60
  "@typescript-eslint/eslint-plugin": "^7.15.0",
60
61
  "@typescript-eslint/parser": "^7.15.0",
61
- "@vitest/coverage-v8": "3.0.4",
62
- "conventional-changelog-conventionalcommits": "^5.0.0",
62
+ "@vitest/coverage-v8": "3.1.1",
63
+ "conventional-changelog-conventionalcommits": "^8.0.0",
63
64
  "eslint": "8.57.0",
64
65
  "eslint-plugin-prettier": "4.2.1",
65
66
  "eslint-plugin-vitest": "0.4.1",
66
- "improved-yarn-audit": "^3.0.0",
67
+ "improved-yarn-audit": "^3.0.3",
67
68
  "prettier": "2.7.1",
68
- "semantic-release": "^19.0.3",
69
- "semantic-release-monorepo": "^7.0.5",
69
+ "semantic-release": "^19.0.5",
70
+ "semantic-release-monorepo": "^7.0.8",
70
71
  "supertest": "^6.3.3",
71
72
  "typescript": "5.5.3",
72
73
  "vite-tsconfig-paths": "4.3.2",
73
- "vitest": "3.0.5"
74
+ "vitest": "3.1.1"
74
75
  },
75
76
  "resolutions": {
76
77
  "yaml": "2.2.2",
77
- "semver": "7.5.2",
78
- "follow-redirects": "1.15.6",
78
+ "semver": "7.7.1",
79
+ "follow-redirects": "1.15.9",
79
80
  "braces": "3.0.3",
80
- "send": "0.19.0",
81
+ "send": "0.19.1",
81
82
  "rollup": "4.22.4",
82
- "cookie": ">= 0.7.0",
83
+ "cookie": ">= 1.0.2",
83
84
  "string-width": "4.2.3",
84
85
  "@types/express": "4.17.15",
85
- "esbuild": "^0.25.0"
86
+ "esbuild": "^0.25.5",
87
+ "axios": "^1.8.2",
88
+ "vite": "6.2.5"
86
89
  }
87
90
  }