@umapi/contracts 1.0.1

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,22 @@
1
+ # @umapi/contracts
2
+
3
+ Общие контракты для микросервисов UMAPI, включая интерфейсы и DTO.
4
+
5
+ ## Установка
6
+
7
+ ```bash
8
+ npm install @umapi/contracts
9
+ ```
10
+
11
+ ## Использование
12
+
13
+ ```typescript
14
+ import { BaseResponse, CreateUserDto } from "@umapi/contracts";
15
+ ```
16
+
17
+ ## Разработка
18
+
19
+ ```bash
20
+ npm run build
21
+ npm publish
22
+ ```
@@ -0,0 +1,18 @@
1
+ /**
2
+ * DTO для создания пользователя
3
+ */
4
+ export declare class CreateUserDto {
5
+ email: string;
6
+ password: string;
7
+ name?: string;
8
+ }
9
+ /**
10
+ * DTO для ответа с данными пользователя
11
+ */
12
+ export declare class UserResponseDto {
13
+ id: string;
14
+ email: string;
15
+ name?: string;
16
+ createdAt: Date;
17
+ }
18
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/dto/index.ts"],"names":[],"mappings":"AAGA;;GAEG;AACH,qBAAa,aAAa;IAItB,KAAK,EAAG,MAAM,CAAC;IAIf,QAAQ,EAAG,MAAM,CAAC;IAKlB,IAAI,CAAC,EAAE,MAAM,CAAC;CACjB;AAED;;GAEG;AACH,qBAAa,eAAe;IAGxB,EAAE,EAAG,MAAM,CAAC;IAKZ,KAAK,EAAG,MAAM,CAAC;IAKf,IAAI,CAAC,EAAE,MAAM,CAAC;IAGd,SAAS,EAAG,IAAI,CAAC;CACpB"}
@@ -0,0 +1,66 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ var __metadata = (this && this.__metadata) || function (k, v) {
9
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.UserResponseDto = exports.CreateUserDto = void 0;
13
+ const swagger_1 = require("@nestjs/swagger");
14
+ const class_validator_1 = require("class-validator");
15
+ /**
16
+ * DTO для создания пользователя
17
+ */
18
+ class CreateUserDto {
19
+ }
20
+ exports.CreateUserDto = CreateUserDto;
21
+ __decorate([
22
+ (0, swagger_1.ApiProperty)({ description: 'Адрес электронной почты пользователя', example: 'user@example.com' }),
23
+ (0, class_validator_1.IsEmail)(),
24
+ (0, class_validator_1.IsString)(),
25
+ __metadata("design:type", String)
26
+ ], CreateUserDto.prototype, "email", void 0);
27
+ __decorate([
28
+ (0, swagger_1.ApiProperty)({ description: 'Пароль пользователя', example: 'password123' }),
29
+ (0, class_validator_1.IsString)(),
30
+ __metadata("design:type", String)
31
+ ], CreateUserDto.prototype, "password", void 0);
32
+ __decorate([
33
+ (0, swagger_1.ApiProperty)({ description: 'Имя пользователя', required: false, example: 'Иван Иванов' }),
34
+ (0, class_validator_1.IsOptional)(),
35
+ (0, class_validator_1.IsString)(),
36
+ __metadata("design:type", String)
37
+ ], CreateUserDto.prototype, "name", void 0);
38
+ /**
39
+ * DTO для ответа с данными пользователя
40
+ */
41
+ class UserResponseDto {
42
+ }
43
+ exports.UserResponseDto = UserResponseDto;
44
+ __decorate([
45
+ (0, swagger_1.ApiProperty)({ description: 'ID пользователя', example: '123e4567-e89b-12d3-a456-426614174000' }),
46
+ (0, class_validator_1.IsString)(),
47
+ __metadata("design:type", String)
48
+ ], UserResponseDto.prototype, "id", void 0);
49
+ __decorate([
50
+ (0, swagger_1.ApiProperty)({ description: 'Адрес электронной почты пользователя', example: 'user@example.com' }),
51
+ (0, class_validator_1.IsEmail)(),
52
+ (0, class_validator_1.IsString)(),
53
+ __metadata("design:type", String)
54
+ ], UserResponseDto.prototype, "email", void 0);
55
+ __decorate([
56
+ (0, swagger_1.ApiProperty)({ description: 'Имя пользователя', required: false, example: 'Иван Иванов' }),
57
+ (0, class_validator_1.IsOptional)(),
58
+ (0, class_validator_1.IsString)(),
59
+ __metadata("design:type", String)
60
+ ], UserResponseDto.prototype, "name", void 0);
61
+ __decorate([
62
+ (0, swagger_1.ApiProperty)({ description: 'Дата создания пользователя', example: '2023-01-01T00:00:00.000Z' }),
63
+ __metadata("design:type", Date)
64
+ ], UserResponseDto.prototype, "createdAt", void 0);
65
+ // Добавить больше DTO по мере необходимости для конкретных сервисов
66
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/dto/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,6CAA8C;AAC9C,qDAAgE;AAEhE;;GAEG;AACH,MAAa,aAAa;CAczB;AAdD,sCAcC;AAVG;IAHC,IAAA,qBAAW,EAAC,EAAE,WAAW,EAAE,sCAAsC,EAAE,OAAO,EAAE,kBAAkB,EAAE,CAAC;IACjG,IAAA,yBAAO,GAAE;IACT,IAAA,0BAAQ,GAAE;;4CACI;AAIf;IAFC,IAAA,qBAAW,EAAC,EAAE,WAAW,EAAE,qBAAqB,EAAE,OAAO,EAAE,aAAa,EAAE,CAAC;IAC3E,IAAA,0BAAQ,GAAE;;+CACO;AAKlB;IAHC,IAAA,qBAAW,EAAC,EAAE,WAAW,EAAE,kBAAkB,EAAE,QAAQ,EAAE,KAAK,EAAE,OAAO,EAAE,aAAa,EAAE,CAAC;IACzF,IAAA,4BAAU,GAAE;IACZ,IAAA,0BAAQ,GAAE;;2CACG;AAGlB;;GAEG;AACH,MAAa,eAAe;CAiB3B;AAjBD,0CAiBC;AAdG;IAFC,IAAA,qBAAW,EAAC,EAAE,WAAW,EAAE,iBAAiB,EAAE,OAAO,EAAE,sCAAsC,EAAE,CAAC;IAChG,IAAA,0BAAQ,GAAE;;2CACC;AAKZ;IAHC,IAAA,qBAAW,EAAC,EAAE,WAAW,EAAE,sCAAsC,EAAE,OAAO,EAAE,kBAAkB,EAAE,CAAC;IACjG,IAAA,yBAAO,GAAE;IACT,IAAA,0BAAQ,GAAE;;8CACI;AAKf;IAHC,IAAA,qBAAW,EAAC,EAAE,WAAW,EAAE,kBAAkB,EAAE,QAAQ,EAAE,KAAK,EAAE,OAAO,EAAE,aAAa,EAAE,CAAC;IACzF,IAAA,4BAAU,GAAE;IACZ,IAAA,0BAAQ,GAAE;;6CACG;AAGd;IADC,IAAA,qBAAW,EAAC,EAAE,WAAW,EAAE,4BAA4B,EAAE,OAAO,EAAE,0BAA0B,EAAE,CAAC;8BACpF,IAAI;kDAAC;AAGrB,oEAAoE"}
@@ -0,0 +1,3 @@
1
+ export * from './dto';
2
+ export * from './interfaces';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,cAAc,OAAO,CAAC;AACtB,cAAc,cAAc,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,20 @@
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
+ // Экспорт всех контрактов
18
+ __exportStar(require("./dto"), exports);
19
+ __exportStar(require("./interfaces"), exports);
20
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,0BAA0B;AAC1B,wCAAsB;AACtB,+CAA6B"}
@@ -0,0 +1,34 @@
1
+ /**
2
+ * Базовый ответ API
3
+ */
4
+ export interface BaseResponse<T = any> {
5
+ /** Успешность операции */
6
+ success: boolean;
7
+ /** Данные ответа (опционально) */
8
+ data?: T;
9
+ /** Сообщение (опционально) */
10
+ message?: string;
11
+ /** Ошибка (опционально) */
12
+ error?: string;
13
+ }
14
+ /**
15
+ * Метаданные пагинации
16
+ */
17
+ export interface PaginationMeta {
18
+ /** Номер страницы */
19
+ page: number;
20
+ /** Размер страницы */
21
+ limit: number;
22
+ /** Общее количество */
23
+ total: number;
24
+ /** Общее количество страниц */
25
+ totalPages: number;
26
+ }
27
+ /**
28
+ * Пагинированный ответ
29
+ */
30
+ export interface PaginatedResponse<T> extends BaseResponse<T[]> {
31
+ /** Метаданные пагинации */
32
+ meta: PaginationMeta;
33
+ }
34
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/interfaces/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,WAAW,YAAY,CAAC,CAAC,GAAG,GAAG;IACjC,0BAA0B;IAC1B,OAAO,EAAE,OAAO,CAAC;IACjB,kCAAkC;IAClC,IAAI,CAAC,EAAE,CAAC,CAAC;IACT,8BAA8B;IAC9B,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,2BAA2B;IAC3B,KAAK,CAAC,EAAE,MAAM,CAAC;CAClB;AAED;;GAEG;AACH,MAAM,WAAW,cAAc;IAC3B,qBAAqB;IACrB,IAAI,EAAE,MAAM,CAAC;IACb,sBAAsB;IACtB,KAAK,EAAE,MAAM,CAAC;IACd,uBAAuB;IACvB,KAAK,EAAE,MAAM,CAAC;IACd,+BAA+B;IAC/B,UAAU,EAAE,MAAM,CAAC;CACtB;AAED;;GAEG;AACH,MAAM,WAAW,iBAAiB,CAAC,CAAC,CAAE,SAAQ,YAAY,CAAC,CAAC,EAAE,CAAC;IAC3D,2BAA2B;IAC3B,IAAI,EAAE,cAAc,CAAC;CACxB"}
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/interfaces/index.ts"],"names":[],"mappings":""}
package/package.json ADDED
@@ -0,0 +1,34 @@
1
+ {
2
+ "name": "@umapi/contracts",
3
+ "version": "1.0.1",
4
+ "description": "Shared contracts for UMAPI microservices",
5
+ "main": "dist/index.js",
6
+ "types": "dist/index.d.ts",
7
+ "scripts": {
8
+ "build": "tsc",
9
+ "prepublishOnly": "npm run build",
10
+ "test": "echo \"No tests specified\""
11
+ },
12
+ "keywords": [
13
+ "umapi",
14
+ "contracts",
15
+ "dto",
16
+ "interfaces"
17
+ ],
18
+ "author": "",
19
+ "license": "MIT",
20
+ "dependencies": {
21
+ "class-transformer": "^0.5.1",
22
+ "class-validator": "^0.14.1",
23
+ "reflect-metadata": "^0.2.2"
24
+ },
25
+ "peerDependencies": {
26
+ "@nestjs/swagger": "^7.0.0"
27
+ },
28
+ "files": [
29
+ "dist"
30
+ ],
31
+ "devDependencies": {
32
+ "typescript": "^5.9.3"
33
+ }
34
+ }