@experts_hub/shared 1.0.23

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 ADDED
@@ -0,0 +1,126 @@
1
+ # @los_generic/shared
2
+
3
+ A public shared library containing DTOs, interfaces, utilities, and other common code for LOS applications.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm install @los_generic/shared
9
+ ```
10
+
11
+ ## Features
12
+
13
+ - **DTOs**: Reusable Data Transfer Objects with validation
14
+ - Country DTOs (CreateCountryDto, UpdateCountryDto)
15
+ - More DTOs can be added as needed
16
+
17
+ - **Interfaces**: Common TypeScript interfaces
18
+ - Pagination interfaces
19
+ - Base interfaces
20
+
21
+ - **Utils**: Utility functions
22
+ - Pagination utilities
23
+ - More utilities can be added as needed
24
+
25
+ ## Usage Examples
26
+
27
+ ### Using DTOs
28
+
29
+ ```typescript
30
+ import { CreateCountryDto, UpdateCountryDto } from '@los_generic/shared';
31
+
32
+ @Post()
33
+ async createCountry(@Body() createCountryDto: CreateCountryDto) {
34
+ // DTO will automatically validate the input
35
+ return this.countryService.create(createCountryDto);
36
+ }
37
+
38
+ @Put(':id')
39
+ async updateCountry(
40
+ @Param('id') id: string,
41
+ @Body() updateCountryDto: UpdateCountryDto
42
+ ) {
43
+ return this.countryService.update(id, updateCountryDto);
44
+ }
45
+ ```
46
+
47
+ ### Using Pagination
48
+
49
+ ```typescript
50
+ import {
51
+ PaginationParams,
52
+ createPaginatedResponse,
53
+ getPaginationParams
54
+ } from '@los_generic/shared';
55
+
56
+ @Get()
57
+ async findAll(@Query() query: PaginationParams) {
58
+ const params = getPaginationParams(query);
59
+ const [items, total] = await this.repository.findAndCount({
60
+ skip: (params.page - 1) * params.limit,
61
+ take: params.limit,
62
+ order: { [params.sortBy]: params.sortOrder }
63
+ });
64
+
65
+ return createPaginatedResponse(items, total, params);
66
+ }
67
+ ```
68
+
69
+ ## Development
70
+
71
+ 1. Install dependencies:
72
+ ```bash
73
+ npm install
74
+ ```
75
+
76
+ 2. Build the package:
77
+ ```bash
78
+ npm run build
79
+ ```
80
+
81
+ 3. Watch for changes during development:
82
+ ```bash
83
+ npm run watch
84
+ ```
85
+
86
+ ## Publishing
87
+
88
+ This package is published as a public package under the @los_generic organization.
89
+
90
+ ```bash
91
+ # For bug fixes (0.0.x)
92
+ npm run patch
93
+
94
+ # For new features (0.x.0)
95
+ npm run minor
96
+
97
+ # For breaking changes (x.0.0)
98
+ npm run major
99
+ ```
100
+
101
+ ## Dependencies
102
+
103
+ ### Peer Dependencies
104
+ - @nestjs/common: ^10.0.0
105
+ - class-transformer: ^0.5.1
106
+ - class-validator: ^0.14.0
107
+
108
+ Make sure these peer dependencies are installed in your project.
109
+
110
+ ## Project Structure
111
+
112
+ ```
113
+ src/
114
+ ├── modules/
115
+ │ └── country/
116
+ │ ├── dto/
117
+ │ │ ├── create-country.dto.ts
118
+ │ │ └── update-country.dto.ts
119
+ │ ├── index.ts
120
+ │ └── pattern.ts
121
+ └── index.ts
122
+ ```
123
+
124
+ ## License
125
+
126
+ ISC
@@ -0,0 +1,11 @@
1
+ declare const AUTHENTICATION_PATTERN: {
2
+ handleValidateToken: string;
3
+ handleLogin: string;
4
+ handleRefreshToken: string;
5
+ handleLogout: string;
6
+ handleLogoutAll: string;
7
+ fetchSessions: string;
8
+ revokeSession: string;
9
+ };
10
+
11
+ export { AUTHENTICATION_PATTERN };
@@ -0,0 +1,11 @@
1
+ declare const AUTHENTICATION_PATTERN: {
2
+ handleValidateToken: string;
3
+ handleLogin: string;
4
+ handleRefreshToken: string;
5
+ handleLogout: string;
6
+ handleLogoutAll: string;
7
+ fetchSessions: string;
8
+ revokeSession: string;
9
+ };
10
+
11
+ export { AUTHENTICATION_PATTERN };
package/dist/index.js ADDED
@@ -0,0 +1,39 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+
19
+ // src/index.ts
20
+ var index_exports = {};
21
+ __export(index_exports, {
22
+ AUTHENTICATION_PATTERN: () => AUTHENTICATION_PATTERN
23
+ });
24
+ module.exports = __toCommonJS(index_exports);
25
+
26
+ // src/modules/authentication/pattern/pattern.ts
27
+ var AUTHENTICATION_PATTERN = {
28
+ handleValidateToken: "handle.validate.token",
29
+ handleLogin: "handle.login",
30
+ handleRefreshToken: "handle.refresh.token",
31
+ handleLogout: "handle.logout",
32
+ handleLogoutAll: "handle.logout.all",
33
+ fetchSessions: "fetch.sessions",
34
+ revokeSession: "revoke.session"
35
+ };
36
+ // Annotate the CommonJS export names for ESM import in node:
37
+ 0 && (module.exports = {
38
+ AUTHENTICATION_PATTERN
39
+ });
package/dist/index.mjs ADDED
@@ -0,0 +1,13 @@
1
+ // src/modules/authentication/pattern/pattern.ts
2
+ var AUTHENTICATION_PATTERN = {
3
+ handleValidateToken: "handle.validate.token",
4
+ handleLogin: "handle.login",
5
+ handleRefreshToken: "handle.refresh.token",
6
+ handleLogout: "handle.logout",
7
+ handleLogoutAll: "handle.logout.all",
8
+ fetchSessions: "fetch.sessions",
9
+ revokeSession: "revoke.session"
10
+ };
11
+ export {
12
+ AUTHENTICATION_PATTERN
13
+ };
@@ -0,0 +1 @@
1
+ export * from './pattern/pattern';
@@ -0,0 +1,9 @@
1
+ export declare const AUTHENTICATION_PATTERN: {
2
+ handleValidateToken: string;
3
+ handleLogin: string;
4
+ handleRefreshToken: string;
5
+ handleLogout: string;
6
+ handleLogoutAll: string;
7
+ fetchSessions: string;
8
+ revokeSession: string;
9
+ };
@@ -0,0 +1 @@
1
+ export * from './authentication';
package/package.json ADDED
@@ -0,0 +1,56 @@
1
+ {
2
+ "name": "@experts_hub/shared",
3
+ "version": "1.0.23",
4
+ "description": "Shared DTOs, interfaces, and utilities for experts hub applications",
5
+ "publishConfig": {
6
+ "registry": "https://registry.npmjs.org/",
7
+ "access": "public"
8
+ },
9
+ "repository": {
10
+ "type": "gitlab",
11
+ "url": "gitlab+https://gitlab.com/los/los-shared.git"
12
+ },
13
+ "main": "dist/index.js",
14
+ "module": "dist/index.mjs",
15
+ "types": "dist/index.d.ts",
16
+ "files": [
17
+ "dist"
18
+ ],
19
+ "scripts": {
20
+ "clean": "rm -rf dist",
21
+ "prebuild": "npm run clean",
22
+ "build": "tsup src/index.ts --format cjs,esm --dts --clean --onSuccess \"tsc --emitDeclarationOnly --declaration\"",
23
+ "watch": "tsup src/index.ts --format cjs,esm --dts --watch",
24
+ "lint": "tsc --noEmit",
25
+ "prepublishOnly": "npm run build",
26
+ "patch": "npm version patch && npm publish --access public",
27
+ "minor": "npm version minor && npm publish --access public",
28
+ "major": "npm version major && npm publish --access public"
29
+ },
30
+ "keywords": [
31
+ "los",
32
+ "shared",
33
+ "dto",
34
+ "nestjs"
35
+ ],
36
+ "author": "",
37
+ "license": "ISC",
38
+ "devDependencies": {
39
+ "@nestjs/common": "^11.0.0",
40
+ "@types/node": "^20.0.0",
41
+ "class-transformer": "^0.5.1",
42
+ "class-validator": "^0.14.0",
43
+ "tsup": "^8.0.0",
44
+ "typescript": "^5.0.0"
45
+ },
46
+ "peerDependencies": {
47
+ "@nestjs/common": "^10.0.0 || ^11.0.0",
48
+ "class-transformer": "^0.5.1",
49
+ "class-validator": "^0.14.0"
50
+ },
51
+ "dependencies": {
52
+ "@nestjs/microservices": "^11.0.19",
53
+ "@nestjs/swagger": "^11.1.2",
54
+ "dotenv": "^16.5.0"
55
+ }
56
+ }