tychat-contracts 1.0.60 → 1.0.62
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/dist/ai/ai-integration-response.dto.d.ts +1 -0
- package/dist/ai/ai-integration-response.dto.d.ts.map +1 -1
- package/dist/ai/ai-integration-response.dto.js +10 -0
- package/dist/ai/ai-usage-response.dto.d.ts +16 -0
- package/dist/ai/ai-usage-response.dto.d.ts.map +1 -0
- package/dist/ai/ai-usage-response.dto.js +77 -0
- package/dist/ai/create-ai-usage.dto.d.ts +14 -0
- package/dist/ai/create-ai-usage.dto.d.ts.map +1 -0
- package/dist/ai/create-ai-usage.dto.js +70 -0
- package/dist/ai/index.d.ts +2 -0
- package/dist/ai/index.d.ts.map +1 -1
- package/dist/ai/index.js +2 -0
- package/dist/conversations/conversation-response.dto.d.ts +16 -0
- package/dist/conversations/conversation-response.dto.d.ts.map +1 -0
- package/dist/conversations/conversation-response.dto.js +98 -0
- package/dist/conversations/conversation-session-response.dto.d.ts +14 -0
- package/dist/conversations/conversation-session-response.dto.d.ts.map +1 -0
- package/dist/conversations/conversation-session-response.dto.js +81 -0
- package/dist/conversations/conversation-type.dto.d.ts +3 -0
- package/dist/conversations/conversation-type.dto.d.ts.map +1 -0
- package/dist/conversations/conversation-type.dto.js +7 -0
- package/dist/conversations/create-conversation-session.dto.d.ts +10 -0
- package/dist/conversations/create-conversation-session.dto.d.ts.map +1 -0
- package/dist/conversations/create-conversation-session.dto.js +46 -0
- package/dist/conversations/create-conversation.dto.d.ts +15 -0
- package/dist/conversations/create-conversation.dto.d.ts.map +1 -0
- package/dist/conversations/create-conversation.dto.js +86 -0
- package/dist/conversations/index.d.ts +6 -0
- package/dist/conversations/index.d.ts.map +1 -0
- package/dist/conversations/index.js +21 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/tenants/tenant-public-by-address-response.dto.d.ts +2 -0
- package/dist/tenants/tenant-public-by-address-response.dto.d.ts.map +1 -1
- package/dist/tenants/tenant-public-by-address-response.dto.js +16 -0
- package/package.json +1 -1
- package/src/ai/ai-integration-response.dto.ts +9 -1
- package/src/ai/ai-usage-response.dto.ts +47 -0
- package/src/ai/create-ai-usage.dto.ts +43 -0
- package/src/ai/index.ts +2 -0
- package/src/conversations/conversation-response.dto.ts +68 -0
- package/src/conversations/conversation-session-response.dto.ts +54 -0
- package/src/conversations/conversation-type.dto.ts +5 -0
- package/src/conversations/create-conversation-session.dto.ts +27 -0
- package/src/conversations/create-conversation.dto.ts +68 -0
- package/src/conversations/index.ts +5 -0
- package/src/index.ts +1 -0
- package/src/tenants/tenant-public-by-address-response.dto.ts +14 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ai-integration-response.dto.d.ts","sourceRoot":"","sources":["../../src/ai/ai-integration-response.dto.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,uBAAuB,EAAE,MAAM,iBAAiB,CAAC;AAE1D,qBAAa,wBAAwB;IAOnC,MAAM,EAAE,MAAM,CAAC;IAQf,QAAQ,EAAE,uBAAuB,CAAC;IAUlC,MAAM,CAAC,EAAE,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"ai-integration-response.dto.d.ts","sourceRoot":"","sources":["../../src/ai/ai-integration-response.dto.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,uBAAuB,EAAE,MAAM,iBAAiB,CAAC;AAE1D,qBAAa,wBAAwB;IAOnC,MAAM,EAAE,MAAM,CAAC;IAQf,QAAQ,EAAE,uBAAuB,CAAC;IAUlC,MAAM,CAAC,EAAE,MAAM,CAAC;IAQhB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB"}
|
|
@@ -18,6 +18,7 @@ class AiIntegrationResponseDto {
|
|
|
18
18
|
tenant;
|
|
19
19
|
response;
|
|
20
20
|
output;
|
|
21
|
+
aiUsageId;
|
|
21
22
|
}
|
|
22
23
|
exports.AiIntegrationResponseDto = AiIntegrationResponseDto;
|
|
23
24
|
__decorate([
|
|
@@ -49,3 +50,12 @@ __decorate([
|
|
|
49
50
|
(0, class_validator_1.IsNotEmpty)(),
|
|
50
51
|
__metadata("design:type", String)
|
|
51
52
|
], AiIntegrationResponseDto.prototype, "output", void 0);
|
|
53
|
+
__decorate([
|
|
54
|
+
(0, swagger_1.ApiPropertyOptional)({
|
|
55
|
+
description: 'AI usage record ID generated after the generation call — used to link token costs to a conversation message',
|
|
56
|
+
example: 'a1b2c3d4-e5f6-7890-abcd-ef1234567890',
|
|
57
|
+
}),
|
|
58
|
+
(0, class_validator_1.IsOptional)(),
|
|
59
|
+
(0, class_validator_1.IsString)(),
|
|
60
|
+
__metadata("design:type", String)
|
|
61
|
+
], AiIntegrationResponseDto.prototype, "aiUsageId", void 0);
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { AiIntegrationDto } from './integration-provider.dto';
|
|
2
|
+
/**
|
|
3
|
+
* Represents a persisted AI token-usage record returned by the API.
|
|
4
|
+
*/
|
|
5
|
+
export declare class AiUsageResponseDto {
|
|
6
|
+
id: string;
|
|
7
|
+
tenant: string;
|
|
8
|
+
unitId?: number;
|
|
9
|
+
integration: AiIntegrationDto;
|
|
10
|
+
model: string;
|
|
11
|
+
promptTokens: number;
|
|
12
|
+
completionTokens: number;
|
|
13
|
+
totalTokens: number;
|
|
14
|
+
createdAt: string;
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=ai-usage-response.dto.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ai-usage-response.dto.d.ts","sourceRoot":"","sources":["../../src/ai/ai-usage-response.dto.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AAE9D;;GAEG;AACH,qBAAa,kBAAkB;IAI7B,EAAE,EAAE,MAAM,CAAC;IAKX,MAAM,EAAE,MAAM,CAAC;IAIf,MAAM,CAAC,EAAE,MAAM,CAAC;IAGhB,WAAW,EAAE,gBAAgB,CAAC;IAK9B,KAAK,EAAE,MAAM,CAAC;IAGd,YAAY,EAAE,MAAM,CAAC;IAGrB,gBAAgB,EAAE,MAAM,CAAC;IAGzB,WAAW,EAAE,MAAM,CAAC;IAQpB,SAAS,EAAE,MAAM,CAAC;CACnB"}
|
|
@@ -0,0 +1,77 @@
|
|
|
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.AiUsageResponseDto = void 0;
|
|
13
|
+
const swagger_1 = require("@nestjs/swagger");
|
|
14
|
+
const class_validator_1 = require("class-validator");
|
|
15
|
+
/**
|
|
16
|
+
* Represents a persisted AI token-usage record returned by the API.
|
|
17
|
+
*/
|
|
18
|
+
class AiUsageResponseDto {
|
|
19
|
+
id;
|
|
20
|
+
tenant;
|
|
21
|
+
unitId;
|
|
22
|
+
integration;
|
|
23
|
+
model;
|
|
24
|
+
promptTokens;
|
|
25
|
+
completionTokens;
|
|
26
|
+
totalTokens;
|
|
27
|
+
createdAt;
|
|
28
|
+
}
|
|
29
|
+
exports.AiUsageResponseDto = AiUsageResponseDto;
|
|
30
|
+
__decorate([
|
|
31
|
+
(0, swagger_1.ApiProperty)({ description: 'AI usage record UUID', example: 'a1b2c3d4-...' }),
|
|
32
|
+
(0, class_validator_1.IsString)(),
|
|
33
|
+
(0, class_validator_1.IsNotEmpty)(),
|
|
34
|
+
__metadata("design:type", String)
|
|
35
|
+
], AiUsageResponseDto.prototype, "id", void 0);
|
|
36
|
+
__decorate([
|
|
37
|
+
(0, swagger_1.ApiProperty)({ description: 'Tenant slug', example: 'clinic-alpha' }),
|
|
38
|
+
(0, class_validator_1.IsString)(),
|
|
39
|
+
(0, class_validator_1.IsNotEmpty)(),
|
|
40
|
+
__metadata("design:type", String)
|
|
41
|
+
], AiUsageResponseDto.prototype, "tenant", void 0);
|
|
42
|
+
__decorate([
|
|
43
|
+
(0, swagger_1.ApiPropertyOptional)({ description: 'Tenant unit id', example: 1 }),
|
|
44
|
+
(0, class_validator_1.IsOptional)(),
|
|
45
|
+
__metadata("design:type", Number)
|
|
46
|
+
], AiUsageResponseDto.prototype, "unitId", void 0);
|
|
47
|
+
__decorate([
|
|
48
|
+
(0, swagger_1.ApiProperty)({ description: 'AI integration used', example: 'OPENAI' }),
|
|
49
|
+
__metadata("design:type", String)
|
|
50
|
+
], AiUsageResponseDto.prototype, "integration", void 0);
|
|
51
|
+
__decorate([
|
|
52
|
+
(0, swagger_1.ApiProperty)({ description: 'Model name', example: 'gpt-4.1-mini' }),
|
|
53
|
+
(0, class_validator_1.IsString)(),
|
|
54
|
+
(0, class_validator_1.IsNotEmpty)(),
|
|
55
|
+
__metadata("design:type", String)
|
|
56
|
+
], AiUsageResponseDto.prototype, "model", void 0);
|
|
57
|
+
__decorate([
|
|
58
|
+
(0, swagger_1.ApiProperty)({ description: 'Number of prompt tokens consumed', example: 120 }),
|
|
59
|
+
__metadata("design:type", Number)
|
|
60
|
+
], AiUsageResponseDto.prototype, "promptTokens", void 0);
|
|
61
|
+
__decorate([
|
|
62
|
+
(0, swagger_1.ApiProperty)({ description: 'Number of completion tokens generated', example: 60 }),
|
|
63
|
+
__metadata("design:type", Number)
|
|
64
|
+
], AiUsageResponseDto.prototype, "completionTokens", void 0);
|
|
65
|
+
__decorate([
|
|
66
|
+
(0, swagger_1.ApiProperty)({ description: 'Total tokens (prompt + completion)', example: 180 }),
|
|
67
|
+
__metadata("design:type", Number)
|
|
68
|
+
], AiUsageResponseDto.prototype, "totalTokens", void 0);
|
|
69
|
+
__decorate([
|
|
70
|
+
(0, swagger_1.ApiProperty)({
|
|
71
|
+
description: 'Creation timestamp (ISO 8601)',
|
|
72
|
+
example: '2024-01-01T00:00:00.000Z',
|
|
73
|
+
}),
|
|
74
|
+
(0, class_validator_1.IsString)(),
|
|
75
|
+
(0, class_validator_1.IsNotEmpty)(),
|
|
76
|
+
__metadata("design:type", String)
|
|
77
|
+
], AiUsageResponseDto.prototype, "createdAt", void 0);
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { AiIntegrationDto } from './integration-provider.dto';
|
|
2
|
+
/**
|
|
3
|
+
* Payload used to persist an AI token-usage record after a generation call.
|
|
4
|
+
*/
|
|
5
|
+
export declare class CreateAiUsageDto {
|
|
6
|
+
tenant: string;
|
|
7
|
+
unitId?: number;
|
|
8
|
+
integration: AiIntegrationDto;
|
|
9
|
+
model: string;
|
|
10
|
+
promptTokens: number;
|
|
11
|
+
completionTokens: number;
|
|
12
|
+
totalTokens: number;
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=create-ai-usage.dto.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create-ai-usage.dto.d.ts","sourceRoot":"","sources":["../../src/ai/create-ai-usage.dto.ts"],"names":[],"mappings":"AAEA,OAAO,EAAmB,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AAE/E;;GAEG;AACH,qBAAa,gBAAgB;IAI3B,MAAM,EAAE,MAAM,CAAC;IAMf,MAAM,CAAC,EAAE,MAAM,CAAC;IAIhB,WAAW,EAAE,gBAAgB,CAAC;IAK9B,KAAK,EAAE,MAAM,CAAC;IAKd,YAAY,EAAE,MAAM,CAAC;IAKrB,gBAAgB,EAAE,MAAM,CAAC;IAKzB,WAAW,EAAE,MAAM,CAAC;CACrB"}
|
|
@@ -0,0 +1,70 @@
|
|
|
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.CreateAiUsageDto = void 0;
|
|
13
|
+
const swagger_1 = require("@nestjs/swagger");
|
|
14
|
+
const class_validator_1 = require("class-validator");
|
|
15
|
+
const integration_provider_dto_1 = require("./integration-provider.dto");
|
|
16
|
+
/**
|
|
17
|
+
* Payload used to persist an AI token-usage record after a generation call.
|
|
18
|
+
*/
|
|
19
|
+
class CreateAiUsageDto {
|
|
20
|
+
tenant;
|
|
21
|
+
unitId;
|
|
22
|
+
integration;
|
|
23
|
+
model;
|
|
24
|
+
promptTokens;
|
|
25
|
+
completionTokens;
|
|
26
|
+
totalTokens;
|
|
27
|
+
}
|
|
28
|
+
exports.CreateAiUsageDto = CreateAiUsageDto;
|
|
29
|
+
__decorate([
|
|
30
|
+
(0, swagger_1.ApiProperty)({ description: 'Tenant slug', example: 'clinic-alpha' }),
|
|
31
|
+
(0, class_validator_1.IsString)(),
|
|
32
|
+
(0, class_validator_1.IsNotEmpty)(),
|
|
33
|
+
__metadata("design:type", String)
|
|
34
|
+
], CreateAiUsageDto.prototype, "tenant", void 0);
|
|
35
|
+
__decorate([
|
|
36
|
+
(0, swagger_1.ApiPropertyOptional)({ description: 'Tenant unit id', example: 1 }),
|
|
37
|
+
(0, class_validator_1.IsOptional)(),
|
|
38
|
+
(0, class_validator_1.IsInt)(),
|
|
39
|
+
(0, class_validator_1.Min)(1),
|
|
40
|
+
__metadata("design:type", Number)
|
|
41
|
+
], CreateAiUsageDto.prototype, "unitId", void 0);
|
|
42
|
+
__decorate([
|
|
43
|
+
(0, swagger_1.ApiProperty)({ description: 'AI integration used', enum: integration_provider_dto_1.AI_INTEGRATIONS }),
|
|
44
|
+
(0, class_validator_1.IsEnum)(integration_provider_dto_1.AI_INTEGRATIONS),
|
|
45
|
+
__metadata("design:type", String)
|
|
46
|
+
], CreateAiUsageDto.prototype, "integration", void 0);
|
|
47
|
+
__decorate([
|
|
48
|
+
(0, swagger_1.ApiProperty)({ description: 'Model name used for generation', example: 'gpt-4.1-mini' }),
|
|
49
|
+
(0, class_validator_1.IsString)(),
|
|
50
|
+
(0, class_validator_1.IsNotEmpty)(),
|
|
51
|
+
__metadata("design:type", String)
|
|
52
|
+
], CreateAiUsageDto.prototype, "model", void 0);
|
|
53
|
+
__decorate([
|
|
54
|
+
(0, swagger_1.ApiProperty)({ description: 'Number of prompt tokens consumed', example: 120 }),
|
|
55
|
+
(0, class_validator_1.IsInt)(),
|
|
56
|
+
(0, class_validator_1.Min)(0),
|
|
57
|
+
__metadata("design:type", Number)
|
|
58
|
+
], CreateAiUsageDto.prototype, "promptTokens", void 0);
|
|
59
|
+
__decorate([
|
|
60
|
+
(0, swagger_1.ApiProperty)({ description: 'Number of completion tokens generated', example: 60 }),
|
|
61
|
+
(0, class_validator_1.IsInt)(),
|
|
62
|
+
(0, class_validator_1.Min)(0),
|
|
63
|
+
__metadata("design:type", Number)
|
|
64
|
+
], CreateAiUsageDto.prototype, "completionTokens", void 0);
|
|
65
|
+
__decorate([
|
|
66
|
+
(0, swagger_1.ApiProperty)({ description: 'Total tokens (prompt + completion)', example: 180 }),
|
|
67
|
+
(0, class_validator_1.IsInt)(),
|
|
68
|
+
(0, class_validator_1.Min)(0),
|
|
69
|
+
__metadata("design:type", Number)
|
|
70
|
+
], CreateAiUsageDto.prototype, "totalTokens", void 0);
|
package/dist/ai/index.d.ts
CHANGED
|
@@ -6,4 +6,6 @@ export * from './ai-integration-request.dto';
|
|
|
6
6
|
export * from './ai-integration-response.dto';
|
|
7
7
|
export * from './list-models.dto';
|
|
8
8
|
export * from './ai-action.dto';
|
|
9
|
+
export * from './create-ai-usage.dto';
|
|
10
|
+
export * from './ai-usage-response.dto';
|
|
9
11
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/ai/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/ai/index.ts"],"names":[],"mappings":"AAAA,cAAc,4BAA4B,CAAC;AAC3C,cAAc,oBAAoB,CAAC;AACnC,cAAc,oBAAoB,CAAC;AACnC,cAAc,sBAAsB,CAAC;AACrC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,+BAA+B,CAAC;AAC9C,cAAc,mBAAmB,CAAC;AAClC,cAAc,iBAAiB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/ai/index.ts"],"names":[],"mappings":"AAAA,cAAc,4BAA4B,CAAC;AAC3C,cAAc,oBAAoB,CAAC;AACnC,cAAc,oBAAoB,CAAC;AACnC,cAAc,sBAAsB,CAAC;AACrC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,+BAA+B,CAAC;AAC9C,cAAc,mBAAmB,CAAC;AAClC,cAAc,iBAAiB,CAAC;AAChC,cAAc,uBAAuB,CAAC;AACtC,cAAc,yBAAyB,CAAC"}
|
package/dist/ai/index.js
CHANGED
|
@@ -22,3 +22,5 @@ __exportStar(require("./ai-integration-request.dto"), exports);
|
|
|
22
22
|
__exportStar(require("./ai-integration-response.dto"), exports);
|
|
23
23
|
__exportStar(require("./list-models.dto"), exports);
|
|
24
24
|
__exportStar(require("./ai-action.dto"), exports);
|
|
25
|
+
__exportStar(require("./create-ai-usage.dto"), exports);
|
|
26
|
+
__exportStar(require("./ai-usage-response.dto"), exports);
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { ConversationTypeDto } from './conversation-type.dto';
|
|
2
|
+
/**
|
|
3
|
+
* Represents a persisted conversation message returned by the API.
|
|
4
|
+
*/
|
|
5
|
+
export declare class ConversationResponseDto {
|
|
6
|
+
id: string;
|
|
7
|
+
tenant: string;
|
|
8
|
+
unitId?: number;
|
|
9
|
+
patientId: string;
|
|
10
|
+
sessionUuid: string;
|
|
11
|
+
type: ConversationTypeDto;
|
|
12
|
+
message: string;
|
|
13
|
+
aiUsageId?: string;
|
|
14
|
+
createdAt: string;
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=conversation-response.dto.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"conversation-response.dto.d.ts","sourceRoot":"","sources":["../../src/conversations/conversation-response.dto.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AAE9D;;GAEG;AACH,qBAAa,uBAAuB;IAIlC,EAAE,EAAE,MAAM,CAAC;IAKX,MAAM,EAAE,MAAM,CAAC;IAIf,MAAM,CAAC,EAAE,MAAM,CAAC;IAQhB,SAAS,EAAE,MAAM,CAAC;IAQlB,WAAW,EAAE,MAAM,CAAC;IAMpB,IAAI,EAAE,mBAAmB,CAAC;IAQ1B,OAAO,EAAE,MAAM,CAAC;IAQhB,SAAS,CAAC,EAAE,MAAM,CAAC;IAQnB,SAAS,EAAE,MAAM,CAAC;CACnB"}
|
|
@@ -0,0 +1,98 @@
|
|
|
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.ConversationResponseDto = void 0;
|
|
13
|
+
const swagger_1 = require("@nestjs/swagger");
|
|
14
|
+
const class_validator_1 = require("class-validator");
|
|
15
|
+
/**
|
|
16
|
+
* Represents a persisted conversation message returned by the API.
|
|
17
|
+
*/
|
|
18
|
+
class ConversationResponseDto {
|
|
19
|
+
id;
|
|
20
|
+
tenant;
|
|
21
|
+
unitId;
|
|
22
|
+
patientId;
|
|
23
|
+
sessionUuid;
|
|
24
|
+
type;
|
|
25
|
+
message;
|
|
26
|
+
aiUsageId;
|
|
27
|
+
createdAt;
|
|
28
|
+
}
|
|
29
|
+
exports.ConversationResponseDto = ConversationResponseDto;
|
|
30
|
+
__decorate([
|
|
31
|
+
(0, swagger_1.ApiProperty)({ description: 'Conversation message UUID', example: 'a1b2c3d4-...' }),
|
|
32
|
+
(0, class_validator_1.IsString)(),
|
|
33
|
+
(0, class_validator_1.IsNotEmpty)(),
|
|
34
|
+
__metadata("design:type", String)
|
|
35
|
+
], ConversationResponseDto.prototype, "id", void 0);
|
|
36
|
+
__decorate([
|
|
37
|
+
(0, swagger_1.ApiProperty)({ description: 'Tenant slug', example: 'clinic-alpha' }),
|
|
38
|
+
(0, class_validator_1.IsString)(),
|
|
39
|
+
(0, class_validator_1.IsNotEmpty)(),
|
|
40
|
+
__metadata("design:type", String)
|
|
41
|
+
], ConversationResponseDto.prototype, "tenant", void 0);
|
|
42
|
+
__decorate([
|
|
43
|
+
(0, swagger_1.ApiPropertyOptional)({ description: 'Tenant unit id', example: 1 }),
|
|
44
|
+
(0, class_validator_1.IsOptional)(),
|
|
45
|
+
__metadata("design:type", Number)
|
|
46
|
+
], ConversationResponseDto.prototype, "unitId", void 0);
|
|
47
|
+
__decorate([
|
|
48
|
+
(0, swagger_1.ApiProperty)({
|
|
49
|
+
description: 'Patient identifier (e.g. phone number)',
|
|
50
|
+
example: '5511999999999',
|
|
51
|
+
}),
|
|
52
|
+
(0, class_validator_1.IsString)(),
|
|
53
|
+
(0, class_validator_1.IsNotEmpty)(),
|
|
54
|
+
__metadata("design:type", String)
|
|
55
|
+
], ConversationResponseDto.prototype, "patientId", void 0);
|
|
56
|
+
__decorate([
|
|
57
|
+
(0, swagger_1.ApiProperty)({
|
|
58
|
+
description: 'Session UUID grouping messages within the 24-hour window',
|
|
59
|
+
example: 'a1b2c3d4-...',
|
|
60
|
+
}),
|
|
61
|
+
(0, class_validator_1.IsString)(),
|
|
62
|
+
(0, class_validator_1.IsNotEmpty)(),
|
|
63
|
+
__metadata("design:type", String)
|
|
64
|
+
], ConversationResponseDto.prototype, "sessionUuid", void 0);
|
|
65
|
+
__decorate([
|
|
66
|
+
(0, swagger_1.ApiProperty)({
|
|
67
|
+
description: 'Conversation type: "ia" or "human"',
|
|
68
|
+
example: 'ia',
|
|
69
|
+
}),
|
|
70
|
+
__metadata("design:type", String)
|
|
71
|
+
], ConversationResponseDto.prototype, "type", void 0);
|
|
72
|
+
__decorate([
|
|
73
|
+
(0, swagger_1.ApiProperty)({
|
|
74
|
+
description: 'Message content',
|
|
75
|
+
example: 'Sure! Let me look up available slots for you.',
|
|
76
|
+
}),
|
|
77
|
+
(0, class_validator_1.IsString)(),
|
|
78
|
+
(0, class_validator_1.IsNotEmpty)(),
|
|
79
|
+
__metadata("design:type", String)
|
|
80
|
+
], ConversationResponseDto.prototype, "message", void 0);
|
|
81
|
+
__decorate([
|
|
82
|
+
(0, swagger_1.ApiPropertyOptional)({
|
|
83
|
+
description: 'AI usage record ID (only present when type is "ia")',
|
|
84
|
+
example: 'a1b2c3d4-...',
|
|
85
|
+
}),
|
|
86
|
+
(0, class_validator_1.IsOptional)(),
|
|
87
|
+
(0, class_validator_1.IsString)(),
|
|
88
|
+
__metadata("design:type", String)
|
|
89
|
+
], ConversationResponseDto.prototype, "aiUsageId", void 0);
|
|
90
|
+
__decorate([
|
|
91
|
+
(0, swagger_1.ApiProperty)({
|
|
92
|
+
description: 'Creation timestamp (ISO 8601)',
|
|
93
|
+
example: '2024-01-01T00:00:00.000Z',
|
|
94
|
+
}),
|
|
95
|
+
(0, class_validator_1.IsString)(),
|
|
96
|
+
(0, class_validator_1.IsNotEmpty)(),
|
|
97
|
+
__metadata("design:type", String)
|
|
98
|
+
], ConversationResponseDto.prototype, "createdAt", void 0);
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Represents a conversation session record returned by the API.
|
|
3
|
+
* A session is valid for 24 hours from its start time.
|
|
4
|
+
*/
|
|
5
|
+
export declare class ConversationSessionResponseDto {
|
|
6
|
+
id: string;
|
|
7
|
+
sessionUuid: string;
|
|
8
|
+
tenant: string;
|
|
9
|
+
patientId: string;
|
|
10
|
+
unitId?: number;
|
|
11
|
+
startedAt: string;
|
|
12
|
+
expiresAt: string;
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=conversation-session-response.dto.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"conversation-session-response.dto.d.ts","sourceRoot":"","sources":["../../src/conversations/conversation-session-response.dto.ts"],"names":[],"mappings":"AAGA;;;GAGG;AACH,qBAAa,8BAA8B;IAIzC,EAAE,EAAE,MAAM,CAAC;IAQX,WAAW,EAAE,MAAM,CAAC;IAKpB,MAAM,EAAE,MAAM,CAAC;IAQf,SAAS,EAAE,MAAM,CAAC;IAIlB,MAAM,CAAC,EAAE,MAAM,CAAC;IAQhB,SAAS,EAAE,MAAM,CAAC;IAQlB,SAAS,EAAE,MAAM,CAAC;CACnB"}
|
|
@@ -0,0 +1,81 @@
|
|
|
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.ConversationSessionResponseDto = void 0;
|
|
13
|
+
const swagger_1 = require("@nestjs/swagger");
|
|
14
|
+
const class_validator_1 = require("class-validator");
|
|
15
|
+
/**
|
|
16
|
+
* Represents a conversation session record returned by the API.
|
|
17
|
+
* A session is valid for 24 hours from its start time.
|
|
18
|
+
*/
|
|
19
|
+
class ConversationSessionResponseDto {
|
|
20
|
+
id;
|
|
21
|
+
sessionUuid;
|
|
22
|
+
tenant;
|
|
23
|
+
patientId;
|
|
24
|
+
unitId;
|
|
25
|
+
startedAt;
|
|
26
|
+
expiresAt;
|
|
27
|
+
}
|
|
28
|
+
exports.ConversationSessionResponseDto = ConversationSessionResponseDto;
|
|
29
|
+
__decorate([
|
|
30
|
+
(0, swagger_1.ApiProperty)({ description: 'Session primary key (UUID)', example: 'a1b2c3d4-...' }),
|
|
31
|
+
(0, class_validator_1.IsString)(),
|
|
32
|
+
(0, class_validator_1.IsNotEmpty)(),
|
|
33
|
+
__metadata("design:type", String)
|
|
34
|
+
], ConversationSessionResponseDto.prototype, "id", void 0);
|
|
35
|
+
__decorate([
|
|
36
|
+
(0, swagger_1.ApiProperty)({
|
|
37
|
+
description: 'Session UUID used to group all messages within the 24-hour window',
|
|
38
|
+
example: 'a1b2c3d4-...',
|
|
39
|
+
}),
|
|
40
|
+
(0, class_validator_1.IsString)(),
|
|
41
|
+
(0, class_validator_1.IsNotEmpty)(),
|
|
42
|
+
__metadata("design:type", String)
|
|
43
|
+
], ConversationSessionResponseDto.prototype, "sessionUuid", void 0);
|
|
44
|
+
__decorate([
|
|
45
|
+
(0, swagger_1.ApiProperty)({ description: 'Tenant slug', example: 'clinic-alpha' }),
|
|
46
|
+
(0, class_validator_1.IsString)(),
|
|
47
|
+
(0, class_validator_1.IsNotEmpty)(),
|
|
48
|
+
__metadata("design:type", String)
|
|
49
|
+
], ConversationSessionResponseDto.prototype, "tenant", void 0);
|
|
50
|
+
__decorate([
|
|
51
|
+
(0, swagger_1.ApiProperty)({
|
|
52
|
+
description: 'Patient identifier (e.g. phone number)',
|
|
53
|
+
example: '5511999999999',
|
|
54
|
+
}),
|
|
55
|
+
(0, class_validator_1.IsString)(),
|
|
56
|
+
(0, class_validator_1.IsNotEmpty)(),
|
|
57
|
+
__metadata("design:type", String)
|
|
58
|
+
], ConversationSessionResponseDto.prototype, "patientId", void 0);
|
|
59
|
+
__decorate([
|
|
60
|
+
(0, swagger_1.ApiPropertyOptional)({ description: 'Tenant unit id', example: 1 }),
|
|
61
|
+
(0, class_validator_1.IsOptional)(),
|
|
62
|
+
__metadata("design:type", Number)
|
|
63
|
+
], ConversationSessionResponseDto.prototype, "unitId", void 0);
|
|
64
|
+
__decorate([
|
|
65
|
+
(0, swagger_1.ApiProperty)({
|
|
66
|
+
description: 'Session start timestamp (ISO 8601)',
|
|
67
|
+
example: '2024-01-01T00:00:00.000Z',
|
|
68
|
+
}),
|
|
69
|
+
(0, class_validator_1.IsString)(),
|
|
70
|
+
(0, class_validator_1.IsNotEmpty)(),
|
|
71
|
+
__metadata("design:type", String)
|
|
72
|
+
], ConversationSessionResponseDto.prototype, "startedAt", void 0);
|
|
73
|
+
__decorate([
|
|
74
|
+
(0, swagger_1.ApiProperty)({
|
|
75
|
+
description: 'Session expiration timestamp (ISO 8601, 24 h after start)',
|
|
76
|
+
example: '2024-01-02T00:00:00.000Z',
|
|
77
|
+
}),
|
|
78
|
+
(0, class_validator_1.IsString)(),
|
|
79
|
+
(0, class_validator_1.IsNotEmpty)(),
|
|
80
|
+
__metadata("design:type", String)
|
|
81
|
+
], ConversationSessionResponseDto.prototype, "expiresAt", void 0);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"conversation-type.dto.d.ts","sourceRoot":"","sources":["../../src/conversations/conversation-type.dto.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,kBAAkB,0BAA2B,CAAC;AAC3D,MAAM,MAAM,mBAAmB,GAAG,CAAC,OAAO,kBAAkB,CAAC,CAAC,MAAM,CAAC,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CONVERSATION_TYPES = void 0;
|
|
4
|
+
// Allowed conversation types.
|
|
5
|
+
// "ia" → patient interacting with the AI.
|
|
6
|
+
// "human" → human staff member responding to the patient.
|
|
7
|
+
exports.CONVERSATION_TYPES = ['ia', 'human'];
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Payload used to obtain (or create) an active 24-hour conversation session
|
|
3
|
+
* for a given patient + tenant combination.
|
|
4
|
+
*/
|
|
5
|
+
export declare class CreateConversationSessionDto {
|
|
6
|
+
tenant: string;
|
|
7
|
+
patientId: string;
|
|
8
|
+
unitId?: number;
|
|
9
|
+
}
|
|
10
|
+
//# sourceMappingURL=create-conversation-session.dto.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create-conversation-session.dto.d.ts","sourceRoot":"","sources":["../../src/conversations/create-conversation-session.dto.ts"],"names":[],"mappings":"AAGA;;;GAGG;AACH,qBAAa,4BAA4B;IAIvC,MAAM,EAAE,MAAM,CAAC;IAQf,SAAS,EAAE,MAAM,CAAC;IAMlB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB"}
|
|
@@ -0,0 +1,46 @@
|
|
|
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.CreateConversationSessionDto = void 0;
|
|
13
|
+
const swagger_1 = require("@nestjs/swagger");
|
|
14
|
+
const class_validator_1 = require("class-validator");
|
|
15
|
+
/**
|
|
16
|
+
* Payload used to obtain (or create) an active 24-hour conversation session
|
|
17
|
+
* for a given patient + tenant combination.
|
|
18
|
+
*/
|
|
19
|
+
class CreateConversationSessionDto {
|
|
20
|
+
tenant;
|
|
21
|
+
patientId;
|
|
22
|
+
unitId;
|
|
23
|
+
}
|
|
24
|
+
exports.CreateConversationSessionDto = CreateConversationSessionDto;
|
|
25
|
+
__decorate([
|
|
26
|
+
(0, swagger_1.ApiProperty)({ description: 'Tenant slug', example: 'clinic-alpha' }),
|
|
27
|
+
(0, class_validator_1.IsString)(),
|
|
28
|
+
(0, class_validator_1.IsNotEmpty)(),
|
|
29
|
+
__metadata("design:type", String)
|
|
30
|
+
], CreateConversationSessionDto.prototype, "tenant", void 0);
|
|
31
|
+
__decorate([
|
|
32
|
+
(0, swagger_1.ApiProperty)({
|
|
33
|
+
description: 'Patient identifier (e.g. phone number or WhatsApp id)',
|
|
34
|
+
example: '5511999999999',
|
|
35
|
+
}),
|
|
36
|
+
(0, class_validator_1.IsString)(),
|
|
37
|
+
(0, class_validator_1.IsNotEmpty)(),
|
|
38
|
+
__metadata("design:type", String)
|
|
39
|
+
], CreateConversationSessionDto.prototype, "patientId", void 0);
|
|
40
|
+
__decorate([
|
|
41
|
+
(0, swagger_1.ApiPropertyOptional)({ description: 'Tenant unit id', example: 1 }),
|
|
42
|
+
(0, class_validator_1.IsOptional)(),
|
|
43
|
+
(0, class_validator_1.IsInt)(),
|
|
44
|
+
(0, class_validator_1.Min)(1),
|
|
45
|
+
__metadata("design:type", Number)
|
|
46
|
+
], CreateConversationSessionDto.prototype, "unitId", void 0);
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { ConversationTypeDto } from './conversation-type.dto';
|
|
2
|
+
/**
|
|
3
|
+
* Payload used to persist a single conversation message.
|
|
4
|
+
* AiUsageId must be provided whenever type is "ia" so token costs can be tracked.
|
|
5
|
+
*/
|
|
6
|
+
export declare class CreateConversationDto {
|
|
7
|
+
tenant: string;
|
|
8
|
+
unitId?: number;
|
|
9
|
+
patientId: string;
|
|
10
|
+
sessionUuid: string;
|
|
11
|
+
type: ConversationTypeDto;
|
|
12
|
+
message: string;
|
|
13
|
+
aiUsageId?: string;
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=create-conversation.dto.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create-conversation.dto.d.ts","sourceRoot":"","sources":["../../src/conversations/create-conversation.dto.ts"],"names":[],"mappings":"AAUA,OAAO,EAAsB,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AAElF;;;GAGG;AACH,qBAAa,qBAAqB;IAIhC,MAAM,EAAE,MAAM,CAAC;IAMf,MAAM,CAAC,EAAE,MAAM,CAAC;IAQhB,SAAS,EAAE,MAAM,CAAC;IAOlB,WAAW,EAAE,MAAM,CAAC;IASpB,IAAI,EAAE,mBAAmB,CAAC;IAQ1B,OAAO,EAAE,MAAM,CAAC;IAQhB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB"}
|
|
@@ -0,0 +1,86 @@
|
|
|
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.CreateConversationDto = void 0;
|
|
13
|
+
const swagger_1 = require("@nestjs/swagger");
|
|
14
|
+
const class_validator_1 = require("class-validator");
|
|
15
|
+
const conversation_type_dto_1 = require("./conversation-type.dto");
|
|
16
|
+
/**
|
|
17
|
+
* Payload used to persist a single conversation message.
|
|
18
|
+
* AiUsageId must be provided whenever type is "ia" so token costs can be tracked.
|
|
19
|
+
*/
|
|
20
|
+
class CreateConversationDto {
|
|
21
|
+
tenant;
|
|
22
|
+
unitId;
|
|
23
|
+
patientId;
|
|
24
|
+
sessionUuid;
|
|
25
|
+
type;
|
|
26
|
+
message;
|
|
27
|
+
aiUsageId;
|
|
28
|
+
}
|
|
29
|
+
exports.CreateConversationDto = CreateConversationDto;
|
|
30
|
+
__decorate([
|
|
31
|
+
(0, swagger_1.ApiProperty)({ description: 'Tenant slug', example: 'clinic-alpha' }),
|
|
32
|
+
(0, class_validator_1.IsString)(),
|
|
33
|
+
(0, class_validator_1.IsNotEmpty)(),
|
|
34
|
+
__metadata("design:type", String)
|
|
35
|
+
], CreateConversationDto.prototype, "tenant", void 0);
|
|
36
|
+
__decorate([
|
|
37
|
+
(0, swagger_1.ApiPropertyOptional)({ description: 'Tenant unit id', example: 1 }),
|
|
38
|
+
(0, class_validator_1.IsOptional)(),
|
|
39
|
+
(0, class_validator_1.IsInt)(),
|
|
40
|
+
(0, class_validator_1.Min)(1),
|
|
41
|
+
__metadata("design:type", Number)
|
|
42
|
+
], CreateConversationDto.prototype, "unitId", void 0);
|
|
43
|
+
__decorate([
|
|
44
|
+
(0, swagger_1.ApiProperty)({
|
|
45
|
+
description: 'Patient identifier (e.g. phone number)',
|
|
46
|
+
example: '5511999999999',
|
|
47
|
+
}),
|
|
48
|
+
(0, class_validator_1.IsString)(),
|
|
49
|
+
(0, class_validator_1.IsNotEmpty)(),
|
|
50
|
+
__metadata("design:type", String)
|
|
51
|
+
], CreateConversationDto.prototype, "patientId", void 0);
|
|
52
|
+
__decorate([
|
|
53
|
+
(0, swagger_1.ApiProperty)({
|
|
54
|
+
description: 'Session UUID that groups messages within the 24-hour window',
|
|
55
|
+
example: 'a1b2c3d4-...',
|
|
56
|
+
}),
|
|
57
|
+
(0, class_validator_1.IsUUID)(),
|
|
58
|
+
__metadata("design:type", String)
|
|
59
|
+
], CreateConversationDto.prototype, "sessionUuid", void 0);
|
|
60
|
+
__decorate([
|
|
61
|
+
(0, swagger_1.ApiProperty)({
|
|
62
|
+
description: 'Conversation type: "ia" when the AI responds to the patient, "human" when a staff member responds',
|
|
63
|
+
enum: conversation_type_dto_1.CONVERSATION_TYPES,
|
|
64
|
+
example: 'ia',
|
|
65
|
+
}),
|
|
66
|
+
(0, class_validator_1.IsEnum)(conversation_type_dto_1.CONVERSATION_TYPES),
|
|
67
|
+
__metadata("design:type", String)
|
|
68
|
+
], CreateConversationDto.prototype, "type", void 0);
|
|
69
|
+
__decorate([
|
|
70
|
+
(0, swagger_1.ApiProperty)({
|
|
71
|
+
description: 'Message content',
|
|
72
|
+
example: 'Hello, I need to schedule an appointment.',
|
|
73
|
+
}),
|
|
74
|
+
(0, class_validator_1.IsString)(),
|
|
75
|
+
(0, class_validator_1.IsNotEmpty)(),
|
|
76
|
+
__metadata("design:type", String)
|
|
77
|
+
], CreateConversationDto.prototype, "message", void 0);
|
|
78
|
+
__decorate([
|
|
79
|
+
(0, swagger_1.ApiPropertyOptional)({
|
|
80
|
+
description: 'AI usage record ID — required when type is "ia"',
|
|
81
|
+
example: 'a1b2c3d4-...',
|
|
82
|
+
}),
|
|
83
|
+
(0, class_validator_1.IsOptional)(),
|
|
84
|
+
(0, class_validator_1.IsString)(),
|
|
85
|
+
__metadata("design:type", String)
|
|
86
|
+
], CreateConversationDto.prototype, "aiUsageId", void 0);
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export * from './conversation-type.dto';
|
|
2
|
+
export * from './create-conversation-session.dto';
|
|
3
|
+
export * from './conversation-session-response.dto';
|
|
4
|
+
export * from './create-conversation.dto';
|
|
5
|
+
export * from './conversation-response.dto';
|
|
6
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/conversations/index.ts"],"names":[],"mappings":"AAAA,cAAc,yBAAyB,CAAC;AACxC,cAAc,mCAAmC,CAAC;AAClD,cAAc,qCAAqC,CAAC;AACpD,cAAc,2BAA2B,CAAC;AAC1C,cAAc,6BAA6B,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
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("./conversation-type.dto"), exports);
|
|
18
|
+
__exportStar(require("./create-conversation-session.dto"), exports);
|
|
19
|
+
__exportStar(require("./conversation-session-response.dto"), exports);
|
|
20
|
+
__exportStar(require("./create-conversation.dto"), exports);
|
|
21
|
+
__exportStar(require("./conversation-response.dto"), exports);
|
package/dist/index.d.ts
CHANGED
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC;AAC/B,cAAc,QAAQ,CAAC;AACvB,cAAc,SAAS,CAAC;AACxB,cAAc,YAAY,CAAC;AAC3B,cAAc,cAAc,CAAC;AAC7B,cAAc,kBAAkB,CAAC;AACjC,cAAc,eAAe,CAAC;AAC9B,cAAc,iBAAiB,CAAC;AAChC,cAAc,YAAY,CAAC;AAC3B,cAAc,WAAW,CAAC;AAC1B,cAAc,MAAM,CAAC;AACrB,cAAc,WAAW,CAAC;AAC1B,cAAc,iBAAiB,CAAC;AAChC,cAAc,WAAW,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC;AAC/B,cAAc,QAAQ,CAAC;AACvB,cAAc,SAAS,CAAC;AACxB,cAAc,YAAY,CAAC;AAC3B,cAAc,cAAc,CAAC;AAC7B,cAAc,kBAAkB,CAAC;AACjC,cAAc,eAAe,CAAC;AAC9B,cAAc,iBAAiB,CAAC;AAChC,cAAc,YAAY,CAAC;AAC3B,cAAc,WAAW,CAAC;AAC1B,cAAc,MAAM,CAAC;AACrB,cAAc,WAAW,CAAC;AAC1B,cAAc,iBAAiB,CAAC;AAChC,cAAc,WAAW,CAAC;AAC1B,cAAc,iBAAiB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -8,5 +8,7 @@ export declare class TenantPublicByAddressResponseDto {
|
|
|
8
8
|
status: 'active' | 'inactive';
|
|
9
9
|
dokploy_frontend_host: string;
|
|
10
10
|
dokploy_backend_host: string;
|
|
11
|
+
logoWhite: string;
|
|
12
|
+
logoDark: string;
|
|
11
13
|
}
|
|
12
14
|
//# sourceMappingURL=tenant-public-by-address-response.dto.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tenant-public-by-address-response.dto.d.ts","sourceRoot":"","sources":["../../src/tenants/tenant-public-by-address-response.dto.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,qBAAa,gCAAgC;IAE3C,IAAI,EAAE,MAAM,CAAC;IAGb,IAAI,EAAE,MAAM,CAAC;IAGb,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IAGxB,MAAM,EAAE,QAAQ,GAAG,UAAU,CAAC;IAO9B,qBAAqB,EAAE,MAAM,CAAC;IAO9B,oBAAoB,EAAE,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"tenant-public-by-address-response.dto.d.ts","sourceRoot":"","sources":["../../src/tenants/tenant-public-by-address-response.dto.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,qBAAa,gCAAgC;IAE3C,IAAI,EAAE,MAAM,CAAC;IAGb,IAAI,EAAE,MAAM,CAAC;IAGb,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IAGxB,MAAM,EAAE,QAAQ,GAAG,UAAU,CAAC;IAO9B,qBAAqB,EAAE,MAAM,CAAC;IAO9B,oBAAoB,EAAE,MAAM,CAAC;IAO7B,SAAS,EAAE,MAAM,CAAC;IAOlB,QAAQ,EAAE,MAAM,CAAC;CAClB"}
|
|
@@ -21,6 +21,8 @@ class TenantPublicByAddressResponseDto {
|
|
|
21
21
|
status;
|
|
22
22
|
dokploy_frontend_host;
|
|
23
23
|
dokploy_backend_host;
|
|
24
|
+
logoWhite;
|
|
25
|
+
logoDark;
|
|
24
26
|
}
|
|
25
27
|
exports.TenantPublicByAddressResponseDto = TenantPublicByAddressResponseDto;
|
|
26
28
|
__decorate([
|
|
@@ -53,3 +55,17 @@ __decorate([
|
|
|
53
55
|
}),
|
|
54
56
|
__metadata("design:type", String)
|
|
55
57
|
], TenantPublicByAddressResponseDto.prototype, "dokploy_backend_host", void 0);
|
|
58
|
+
__decorate([
|
|
59
|
+
(0, swagger_1.ApiProperty)({
|
|
60
|
+
description: 'URL da logo do tenant para fundo claro',
|
|
61
|
+
example: 'https://cdn.seusistema.com/tenants/acme-logo-white.png',
|
|
62
|
+
}),
|
|
63
|
+
__metadata("design:type", String)
|
|
64
|
+
], TenantPublicByAddressResponseDto.prototype, "logoWhite", void 0);
|
|
65
|
+
__decorate([
|
|
66
|
+
(0, swagger_1.ApiProperty)({
|
|
67
|
+
description: 'URL da logo do tenant para fundo escuro',
|
|
68
|
+
example: 'https://cdn.seusistema.com/tenants/acme-logo-dark.png',
|
|
69
|
+
}),
|
|
70
|
+
__metadata("design:type", String)
|
|
71
|
+
], TenantPublicByAddressResponseDto.prototype, "logoDark", void 0);
|
package/package.json
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ApiProperty } from '@nestjs/swagger';
|
|
1
|
+
import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';
|
|
2
2
|
import { Type } from 'class-transformer';
|
|
3
3
|
import { IsNotEmpty, IsOptional, IsString, ValidateNested } from 'class-validator';
|
|
4
4
|
import { AiStructuredResponseDto } from './ai-action.dto';
|
|
@@ -29,4 +29,12 @@ export class AiIntegrationResponseDto {
|
|
|
29
29
|
@IsString()
|
|
30
30
|
@IsNotEmpty()
|
|
31
31
|
output?: string;
|
|
32
|
+
|
|
33
|
+
@ApiPropertyOptional({
|
|
34
|
+
description: 'AI usage record ID generated after the generation call — used to link token costs to a conversation message',
|
|
35
|
+
example: 'a1b2c3d4-e5f6-7890-abcd-ef1234567890',
|
|
36
|
+
})
|
|
37
|
+
@IsOptional()
|
|
38
|
+
@IsString()
|
|
39
|
+
aiUsageId?: string;
|
|
32
40
|
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';
|
|
2
|
+
import { IsNotEmpty, IsOptional, IsString } from 'class-validator';
|
|
3
|
+
import { AiIntegrationDto } from './integration-provider.dto';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Represents a persisted AI token-usage record returned by the API.
|
|
7
|
+
*/
|
|
8
|
+
export class AiUsageResponseDto {
|
|
9
|
+
@ApiProperty({ description: 'AI usage record UUID', example: 'a1b2c3d4-...' })
|
|
10
|
+
@IsString()
|
|
11
|
+
@IsNotEmpty()
|
|
12
|
+
id: string;
|
|
13
|
+
|
|
14
|
+
@ApiProperty({ description: 'Tenant slug', example: 'clinic-alpha' })
|
|
15
|
+
@IsString()
|
|
16
|
+
@IsNotEmpty()
|
|
17
|
+
tenant: string;
|
|
18
|
+
|
|
19
|
+
@ApiPropertyOptional({ description: 'Tenant unit id', example: 1 })
|
|
20
|
+
@IsOptional()
|
|
21
|
+
unitId?: number;
|
|
22
|
+
|
|
23
|
+
@ApiProperty({ description: 'AI integration used', example: 'OPENAI' })
|
|
24
|
+
integration: AiIntegrationDto;
|
|
25
|
+
|
|
26
|
+
@ApiProperty({ description: 'Model name', example: 'gpt-4.1-mini' })
|
|
27
|
+
@IsString()
|
|
28
|
+
@IsNotEmpty()
|
|
29
|
+
model: string;
|
|
30
|
+
|
|
31
|
+
@ApiProperty({ description: 'Number of prompt tokens consumed', example: 120 })
|
|
32
|
+
promptTokens: number;
|
|
33
|
+
|
|
34
|
+
@ApiProperty({ description: 'Number of completion tokens generated', example: 60 })
|
|
35
|
+
completionTokens: number;
|
|
36
|
+
|
|
37
|
+
@ApiProperty({ description: 'Total tokens (prompt + completion)', example: 180 })
|
|
38
|
+
totalTokens: number;
|
|
39
|
+
|
|
40
|
+
@ApiProperty({
|
|
41
|
+
description: 'Creation timestamp (ISO 8601)',
|
|
42
|
+
example: '2024-01-01T00:00:00.000Z',
|
|
43
|
+
})
|
|
44
|
+
@IsString()
|
|
45
|
+
@IsNotEmpty()
|
|
46
|
+
createdAt: string;
|
|
47
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';
|
|
2
|
+
import { IsEnum, IsInt, IsNotEmpty, IsOptional, IsString, Min } from 'class-validator';
|
|
3
|
+
import { AI_INTEGRATIONS, AiIntegrationDto } from './integration-provider.dto';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Payload used to persist an AI token-usage record after a generation call.
|
|
7
|
+
*/
|
|
8
|
+
export class CreateAiUsageDto {
|
|
9
|
+
@ApiProperty({ description: 'Tenant slug', example: 'clinic-alpha' })
|
|
10
|
+
@IsString()
|
|
11
|
+
@IsNotEmpty()
|
|
12
|
+
tenant: string;
|
|
13
|
+
|
|
14
|
+
@ApiPropertyOptional({ description: 'Tenant unit id', example: 1 })
|
|
15
|
+
@IsOptional()
|
|
16
|
+
@IsInt()
|
|
17
|
+
@Min(1)
|
|
18
|
+
unitId?: number;
|
|
19
|
+
|
|
20
|
+
@ApiProperty({ description: 'AI integration used', enum: AI_INTEGRATIONS })
|
|
21
|
+
@IsEnum(AI_INTEGRATIONS)
|
|
22
|
+
integration: AiIntegrationDto;
|
|
23
|
+
|
|
24
|
+
@ApiProperty({ description: 'Model name used for generation', example: 'gpt-4.1-mini' })
|
|
25
|
+
@IsString()
|
|
26
|
+
@IsNotEmpty()
|
|
27
|
+
model: string;
|
|
28
|
+
|
|
29
|
+
@ApiProperty({ description: 'Number of prompt tokens consumed', example: 120 })
|
|
30
|
+
@IsInt()
|
|
31
|
+
@Min(0)
|
|
32
|
+
promptTokens: number;
|
|
33
|
+
|
|
34
|
+
@ApiProperty({ description: 'Number of completion tokens generated', example: 60 })
|
|
35
|
+
@IsInt()
|
|
36
|
+
@Min(0)
|
|
37
|
+
completionTokens: number;
|
|
38
|
+
|
|
39
|
+
@ApiProperty({ description: 'Total tokens (prompt + completion)', example: 180 })
|
|
40
|
+
@IsInt()
|
|
41
|
+
@Min(0)
|
|
42
|
+
totalTokens: number;
|
|
43
|
+
}
|
package/src/ai/index.ts
CHANGED
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';
|
|
2
|
+
import { IsNotEmpty, IsOptional, IsString } from 'class-validator';
|
|
3
|
+
import { ConversationTypeDto } from './conversation-type.dto';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Represents a persisted conversation message returned by the API.
|
|
7
|
+
*/
|
|
8
|
+
export class ConversationResponseDto {
|
|
9
|
+
@ApiProperty({ description: 'Conversation message UUID', example: 'a1b2c3d4-...' })
|
|
10
|
+
@IsString()
|
|
11
|
+
@IsNotEmpty()
|
|
12
|
+
id: string;
|
|
13
|
+
|
|
14
|
+
@ApiProperty({ description: 'Tenant slug', example: 'clinic-alpha' })
|
|
15
|
+
@IsString()
|
|
16
|
+
@IsNotEmpty()
|
|
17
|
+
tenant: string;
|
|
18
|
+
|
|
19
|
+
@ApiPropertyOptional({ description: 'Tenant unit id', example: 1 })
|
|
20
|
+
@IsOptional()
|
|
21
|
+
unitId?: number;
|
|
22
|
+
|
|
23
|
+
@ApiProperty({
|
|
24
|
+
description: 'Patient identifier (e.g. phone number)',
|
|
25
|
+
example: '5511999999999',
|
|
26
|
+
})
|
|
27
|
+
@IsString()
|
|
28
|
+
@IsNotEmpty()
|
|
29
|
+
patientId: string;
|
|
30
|
+
|
|
31
|
+
@ApiProperty({
|
|
32
|
+
description: 'Session UUID grouping messages within the 24-hour window',
|
|
33
|
+
example: 'a1b2c3d4-...',
|
|
34
|
+
})
|
|
35
|
+
@IsString()
|
|
36
|
+
@IsNotEmpty()
|
|
37
|
+
sessionUuid: string;
|
|
38
|
+
|
|
39
|
+
@ApiProperty({
|
|
40
|
+
description: 'Conversation type: "ia" or "human"',
|
|
41
|
+
example: 'ia',
|
|
42
|
+
})
|
|
43
|
+
type: ConversationTypeDto;
|
|
44
|
+
|
|
45
|
+
@ApiProperty({
|
|
46
|
+
description: 'Message content',
|
|
47
|
+
example: 'Sure! Let me look up available slots for you.',
|
|
48
|
+
})
|
|
49
|
+
@IsString()
|
|
50
|
+
@IsNotEmpty()
|
|
51
|
+
message: string;
|
|
52
|
+
|
|
53
|
+
@ApiPropertyOptional({
|
|
54
|
+
description: 'AI usage record ID (only present when type is "ia")',
|
|
55
|
+
example: 'a1b2c3d4-...',
|
|
56
|
+
})
|
|
57
|
+
@IsOptional()
|
|
58
|
+
@IsString()
|
|
59
|
+
aiUsageId?: string;
|
|
60
|
+
|
|
61
|
+
@ApiProperty({
|
|
62
|
+
description: 'Creation timestamp (ISO 8601)',
|
|
63
|
+
example: '2024-01-01T00:00:00.000Z',
|
|
64
|
+
})
|
|
65
|
+
@IsString()
|
|
66
|
+
@IsNotEmpty()
|
|
67
|
+
createdAt: string;
|
|
68
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';
|
|
2
|
+
import { IsNotEmpty, IsOptional, IsString } from 'class-validator';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Represents a conversation session record returned by the API.
|
|
6
|
+
* A session is valid for 24 hours from its start time.
|
|
7
|
+
*/
|
|
8
|
+
export class ConversationSessionResponseDto {
|
|
9
|
+
@ApiProperty({ description: 'Session primary key (UUID)', example: 'a1b2c3d4-...' })
|
|
10
|
+
@IsString()
|
|
11
|
+
@IsNotEmpty()
|
|
12
|
+
id: string;
|
|
13
|
+
|
|
14
|
+
@ApiProperty({
|
|
15
|
+
description: 'Session UUID used to group all messages within the 24-hour window',
|
|
16
|
+
example: 'a1b2c3d4-...',
|
|
17
|
+
})
|
|
18
|
+
@IsString()
|
|
19
|
+
@IsNotEmpty()
|
|
20
|
+
sessionUuid: string;
|
|
21
|
+
|
|
22
|
+
@ApiProperty({ description: 'Tenant slug', example: 'clinic-alpha' })
|
|
23
|
+
@IsString()
|
|
24
|
+
@IsNotEmpty()
|
|
25
|
+
tenant: string;
|
|
26
|
+
|
|
27
|
+
@ApiProperty({
|
|
28
|
+
description: 'Patient identifier (e.g. phone number)',
|
|
29
|
+
example: '5511999999999',
|
|
30
|
+
})
|
|
31
|
+
@IsString()
|
|
32
|
+
@IsNotEmpty()
|
|
33
|
+
patientId: string;
|
|
34
|
+
|
|
35
|
+
@ApiPropertyOptional({ description: 'Tenant unit id', example: 1 })
|
|
36
|
+
@IsOptional()
|
|
37
|
+
unitId?: number;
|
|
38
|
+
|
|
39
|
+
@ApiProperty({
|
|
40
|
+
description: 'Session start timestamp (ISO 8601)',
|
|
41
|
+
example: '2024-01-01T00:00:00.000Z',
|
|
42
|
+
})
|
|
43
|
+
@IsString()
|
|
44
|
+
@IsNotEmpty()
|
|
45
|
+
startedAt: string;
|
|
46
|
+
|
|
47
|
+
@ApiProperty({
|
|
48
|
+
description: 'Session expiration timestamp (ISO 8601, 24 h after start)',
|
|
49
|
+
example: '2024-01-02T00:00:00.000Z',
|
|
50
|
+
})
|
|
51
|
+
@IsString()
|
|
52
|
+
@IsNotEmpty()
|
|
53
|
+
expiresAt: string;
|
|
54
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';
|
|
2
|
+
import { IsInt, IsNotEmpty, IsOptional, IsString, Min } from 'class-validator';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Payload used to obtain (or create) an active 24-hour conversation session
|
|
6
|
+
* for a given patient + tenant combination.
|
|
7
|
+
*/
|
|
8
|
+
export class CreateConversationSessionDto {
|
|
9
|
+
@ApiProperty({ description: 'Tenant slug', example: 'clinic-alpha' })
|
|
10
|
+
@IsString()
|
|
11
|
+
@IsNotEmpty()
|
|
12
|
+
tenant: string;
|
|
13
|
+
|
|
14
|
+
@ApiProperty({
|
|
15
|
+
description: 'Patient identifier (e.g. phone number or WhatsApp id)',
|
|
16
|
+
example: '5511999999999',
|
|
17
|
+
})
|
|
18
|
+
@IsString()
|
|
19
|
+
@IsNotEmpty()
|
|
20
|
+
patientId: string;
|
|
21
|
+
|
|
22
|
+
@ApiPropertyOptional({ description: 'Tenant unit id', example: 1 })
|
|
23
|
+
@IsOptional()
|
|
24
|
+
@IsInt()
|
|
25
|
+
@Min(1)
|
|
26
|
+
unitId?: number;
|
|
27
|
+
}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';
|
|
2
|
+
import {
|
|
3
|
+
IsEnum,
|
|
4
|
+
IsInt,
|
|
5
|
+
IsNotEmpty,
|
|
6
|
+
IsOptional,
|
|
7
|
+
IsString,
|
|
8
|
+
IsUUID,
|
|
9
|
+
Min,
|
|
10
|
+
} from 'class-validator';
|
|
11
|
+
import { CONVERSATION_TYPES, ConversationTypeDto } from './conversation-type.dto';
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Payload used to persist a single conversation message.
|
|
15
|
+
* AiUsageId must be provided whenever type is "ia" so token costs can be tracked.
|
|
16
|
+
*/
|
|
17
|
+
export class CreateConversationDto {
|
|
18
|
+
@ApiProperty({ description: 'Tenant slug', example: 'clinic-alpha' })
|
|
19
|
+
@IsString()
|
|
20
|
+
@IsNotEmpty()
|
|
21
|
+
tenant: string;
|
|
22
|
+
|
|
23
|
+
@ApiPropertyOptional({ description: 'Tenant unit id', example: 1 })
|
|
24
|
+
@IsOptional()
|
|
25
|
+
@IsInt()
|
|
26
|
+
@Min(1)
|
|
27
|
+
unitId?: number;
|
|
28
|
+
|
|
29
|
+
@ApiProperty({
|
|
30
|
+
description: 'Patient identifier (e.g. phone number)',
|
|
31
|
+
example: '5511999999999',
|
|
32
|
+
})
|
|
33
|
+
@IsString()
|
|
34
|
+
@IsNotEmpty()
|
|
35
|
+
patientId: string;
|
|
36
|
+
|
|
37
|
+
@ApiProperty({
|
|
38
|
+
description: 'Session UUID that groups messages within the 24-hour window',
|
|
39
|
+
example: 'a1b2c3d4-...',
|
|
40
|
+
})
|
|
41
|
+
@IsUUID()
|
|
42
|
+
sessionUuid: string;
|
|
43
|
+
|
|
44
|
+
@ApiProperty({
|
|
45
|
+
description:
|
|
46
|
+
'Conversation type: "ia" when the AI responds to the patient, "human" when a staff member responds',
|
|
47
|
+
enum: CONVERSATION_TYPES,
|
|
48
|
+
example: 'ia',
|
|
49
|
+
})
|
|
50
|
+
@IsEnum(CONVERSATION_TYPES)
|
|
51
|
+
type: ConversationTypeDto;
|
|
52
|
+
|
|
53
|
+
@ApiProperty({
|
|
54
|
+
description: 'Message content',
|
|
55
|
+
example: 'Hello, I need to schedule an appointment.',
|
|
56
|
+
})
|
|
57
|
+
@IsString()
|
|
58
|
+
@IsNotEmpty()
|
|
59
|
+
message: string;
|
|
60
|
+
|
|
61
|
+
@ApiPropertyOptional({
|
|
62
|
+
description: 'AI usage record ID — required when type is "ia"',
|
|
63
|
+
example: 'a1b2c3d4-...',
|
|
64
|
+
})
|
|
65
|
+
@IsOptional()
|
|
66
|
+
@IsString()
|
|
67
|
+
aiUsageId?: string;
|
|
68
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -29,4 +29,18 @@ export class TenantPublicByAddressResponseDto {
|
|
|
29
29
|
example: 'acme-backend.tychat.app',
|
|
30
30
|
})
|
|
31
31
|
dokploy_backend_host: string;
|
|
32
|
+
|
|
33
|
+
@ApiProperty({
|
|
34
|
+
description:
|
|
35
|
+
'URL da logo do tenant para fundo claro',
|
|
36
|
+
example: 'https://cdn.seusistema.com/tenants/acme-logo-white.png',
|
|
37
|
+
})
|
|
38
|
+
logoWhite: string;
|
|
39
|
+
|
|
40
|
+
@ApiProperty({
|
|
41
|
+
description:
|
|
42
|
+
'URL da logo do tenant para fundo escuro',
|
|
43
|
+
example: 'https://cdn.seusistema.com/tenants/acme-logo-dark.png',
|
|
44
|
+
})
|
|
45
|
+
logoDark: string;
|
|
32
46
|
}
|