tychat-contracts 1.3.3 → 1.3.5
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 +3 -0
- package/dist/ai/ai-integration-response.dto.d.ts.map +1 -1
- package/dist/ai/ai-integration-response.dto.js +27 -0
- package/dist/analytics/analytics-emitter.helper.d.ts +1 -1
- package/dist/analytics/analytics-emitter.helper.js +1 -1
- package/dist/anamneses/anamnesis-token-session.dto.d.ts +15 -0
- package/dist/anamneses/anamnesis-token-session.dto.d.ts.map +1 -0
- package/dist/anamneses/anamnesis-token-session.dto.js +72 -0
- package/dist/anamneses/create-anamnesis-by-token.dto.d.ts +5 -0
- package/dist/anamneses/create-anamnesis-by-token.dto.d.ts.map +1 -0
- package/dist/anamneses/create-anamnesis-by-token.dto.js +42 -0
- package/dist/anamneses/index.d.ts +4 -0
- package/dist/anamneses/index.d.ts.map +1 -0
- package/dist/anamneses/index.js +19 -0
- package/dist/anamneses/patient-anamnesis.dto.d.ts +10 -0
- package/dist/anamneses/patient-anamnesis.dto.d.ts.map +1 -0
- package/dist/anamneses/patient-anamnesis.dto.js +51 -0
- package/dist/configurations/plan-summary.dto.d.ts +1 -0
- package/dist/configurations/plan-summary.dto.d.ts.map +1 -1
- package/dist/configurations/plan-summary.dto.js +5 -0
- package/dist/conversations/followup-events.dto.d.ts +1 -0
- package/dist/conversations/followup-events.dto.d.ts.map +1 -1
- package/dist/conversations/followup-events.dto.js +7 -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/consume-tenant-ai-tokens.dto.d.ts +14 -0
- package/dist/tenants/consume-tenant-ai-tokens.dto.d.ts.map +1 -0
- package/dist/tenants/consume-tenant-ai-tokens.dto.js +64 -0
- package/dist/tenants/index.d.ts +4 -0
- package/dist/tenants/index.d.ts.map +1 -1
- package/dist/tenants/index.js +4 -0
- package/dist/tenants/recharge-tenant-ai-tokens.dto.d.ts +10 -0
- package/dist/tenants/recharge-tenant-ai-tokens.dto.d.ts.map +1 -0
- package/dist/tenants/recharge-tenant-ai-tokens.dto.js +49 -0
- package/dist/tenants/renew-tenant-ai-tokens.dto.d.ts +7 -0
- package/dist/tenants/renew-tenant-ai-tokens.dto.d.ts.map +1 -0
- package/dist/tenants/renew-tenant-ai-tokens.dto.js +34 -0
- package/dist/tenants/tenant-ai-token-state.dto.d.ts +13 -0
- package/dist/tenants/tenant-ai-token-state.dto.d.ts.map +1 -0
- package/dist/tenants/tenant-ai-token-state.dto.js +83 -0
- package/package.json +1 -1
- package/src/ai/ai-integration-response.dto.ts +21 -0
- package/src/analytics/analytics-emitter.helper.ts +1 -1
- package/src/anamneses/anamnesis-token-session.dto.ts +38 -0
- package/src/anamneses/create-anamnesis-by-token.dto.ts +25 -0
- package/src/anamneses/index.ts +3 -0
- package/src/anamneses/patient-anamnesis.dto.ts +24 -0
- package/src/configurations/plan-summary.dto.ts +3 -0
- package/src/conversations/followup-events.dto.ts +5 -0
- package/src/index.ts +1 -0
- package/src/tenants/consume-tenant-ai-tokens.dto.ts +41 -0
- package/src/tenants/index.ts +4 -0
- package/src/tenants/recharge-tenant-ai-tokens.dto.ts +27 -0
- package/src/tenants/renew-tenant-ai-tokens.dto.ts +16 -0
- package/src/tenants/tenant-ai-token-state.dto.ts +50 -0
|
@@ -4,5 +4,8 @@ export declare class AiIntegrationResponseDto {
|
|
|
4
4
|
response: AiStructuredResponseDto;
|
|
5
5
|
output?: string;
|
|
6
6
|
aiUsageId?: string;
|
|
7
|
+
promptTokens?: number;
|
|
8
|
+
completionTokens?: number;
|
|
9
|
+
totalTokens?: number;
|
|
7
10
|
}
|
|
8
11
|
//# sourceMappingURL=ai-integration-response.dto.d.ts.map
|
|
@@ -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;IAQhB,SAAS,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;IAOnB,YAAY,CAAC,EAAE,MAAM,CAAC;IAOtB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAO1B,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB"}
|
|
@@ -19,6 +19,9 @@ class AiIntegrationResponseDto {
|
|
|
19
19
|
response;
|
|
20
20
|
output;
|
|
21
21
|
aiUsageId;
|
|
22
|
+
promptTokens;
|
|
23
|
+
completionTokens;
|
|
24
|
+
totalTokens;
|
|
22
25
|
}
|
|
23
26
|
exports.AiIntegrationResponseDto = AiIntegrationResponseDto;
|
|
24
27
|
__decorate([
|
|
@@ -59,3 +62,27 @@ __decorate([
|
|
|
59
62
|
(0, class_validator_1.IsString)(),
|
|
60
63
|
__metadata("design:type", String)
|
|
61
64
|
], AiIntegrationResponseDto.prototype, "aiUsageId", void 0);
|
|
65
|
+
__decorate([
|
|
66
|
+
(0, swagger_1.ApiPropertyOptional)({
|
|
67
|
+
description: 'Prompt tokens consumed in this AI request',
|
|
68
|
+
example: 120,
|
|
69
|
+
}),
|
|
70
|
+
(0, class_validator_1.IsOptional)(),
|
|
71
|
+
__metadata("design:type", Number)
|
|
72
|
+
], AiIntegrationResponseDto.prototype, "promptTokens", void 0);
|
|
73
|
+
__decorate([
|
|
74
|
+
(0, swagger_1.ApiPropertyOptional)({
|
|
75
|
+
description: 'Completion tokens generated in this AI request',
|
|
76
|
+
example: 90,
|
|
77
|
+
}),
|
|
78
|
+
(0, class_validator_1.IsOptional)(),
|
|
79
|
+
__metadata("design:type", Number)
|
|
80
|
+
], AiIntegrationResponseDto.prototype, "completionTokens", void 0);
|
|
81
|
+
__decorate([
|
|
82
|
+
(0, swagger_1.ApiPropertyOptional)({
|
|
83
|
+
description: 'Total tokens consumed in this AI request',
|
|
84
|
+
example: 210,
|
|
85
|
+
}),
|
|
86
|
+
(0, class_validator_1.IsOptional)(),
|
|
87
|
+
__metadata("design:type", Number)
|
|
88
|
+
], AiIntegrationResponseDto.prototype, "totalTokens", void 0);
|
|
@@ -14,7 +14,7 @@ export interface EmitAnalyticEventOptions {
|
|
|
14
14
|
/**
|
|
15
15
|
* Builds the Kafka payload to be sent to the analytics service.
|
|
16
16
|
*
|
|
17
|
-
* Usage (fire-and-forget via
|
|
17
|
+
* Usage (fire-and-forget via ClientProxy.emit):
|
|
18
18
|
* ```ts
|
|
19
19
|
* this.analyticsClient.emit(
|
|
20
20
|
* TOPIC_ANALYTICS_EVENT,
|
|
@@ -8,7 +8,7 @@ Object.defineProperty(exports, "TOPIC_ANALYTICS_EVENT", { enumerable: true, get:
|
|
|
8
8
|
/**
|
|
9
9
|
* Builds the Kafka payload to be sent to the analytics service.
|
|
10
10
|
*
|
|
11
|
-
* Usage (fire-and-forget via
|
|
11
|
+
* Usage (fire-and-forget via ClientProxy.emit):
|
|
12
12
|
* ```ts
|
|
13
13
|
* this.analyticsClient.emit(
|
|
14
14
|
* TOPIC_ANALYTICS_EVENT,
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export declare class AnamnesisTokenSessionPatientDto {
|
|
2
|
+
id: string;
|
|
3
|
+
name: string;
|
|
4
|
+
cpf: string | null;
|
|
5
|
+
phone: string | null;
|
|
6
|
+
}
|
|
7
|
+
export declare class AnamnesisTokenSessionDto {
|
|
8
|
+
valid: boolean;
|
|
9
|
+
reason?: 'not_found' | 'expired' | 'consumed' | 'invalid_scope';
|
|
10
|
+
scope?: string;
|
|
11
|
+
expiresAt?: string;
|
|
12
|
+
appointmentId?: string;
|
|
13
|
+
patient?: AnamnesisTokenSessionPatientDto;
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=anamnesis-token-session.dto.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"anamnesis-token-session.dto.d.ts","sourceRoot":"","sources":["../../src/anamneses/anamnesis-token-session.dto.ts"],"names":[],"mappings":"AAEA,qBAAa,+BAA+B;IAE1C,EAAE,EAAE,MAAM,CAAC;IAGX,IAAI,EAAE,MAAM,CAAC;IAGb,GAAG,EAAE,MAAM,GAAG,IAAI,CAAC;IAGnB,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;CACtB;AAED,qBAAa,wBAAwB;IAEnC,KAAK,EAAE,OAAO,CAAC;IAMf,MAAM,CAAC,EAAE,WAAW,GAAG,SAAS,GAAG,UAAU,GAAG,eAAe,CAAC;IAGhE,KAAK,CAAC,EAAE,MAAM,CAAC;IAGf,SAAS,CAAC,EAAE,MAAM,CAAC;IAGnB,aAAa,CAAC,EAAE,MAAM,CAAC;IAGvB,OAAO,CAAC,EAAE,+BAA+B,CAAC;CAC3C"}
|
|
@@ -0,0 +1,72 @@
|
|
|
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.AnamnesisTokenSessionDto = exports.AnamnesisTokenSessionPatientDto = void 0;
|
|
13
|
+
const swagger_1 = require("@nestjs/swagger");
|
|
14
|
+
class AnamnesisTokenSessionPatientDto {
|
|
15
|
+
id;
|
|
16
|
+
name;
|
|
17
|
+
cpf;
|
|
18
|
+
phone;
|
|
19
|
+
}
|
|
20
|
+
exports.AnamnesisTokenSessionPatientDto = AnamnesisTokenSessionPatientDto;
|
|
21
|
+
__decorate([
|
|
22
|
+
(0, swagger_1.ApiProperty)({ example: '550e8400-e29b-41d4-a716-446655440000' }),
|
|
23
|
+
__metadata("design:type", String)
|
|
24
|
+
], AnamnesisTokenSessionPatientDto.prototype, "id", void 0);
|
|
25
|
+
__decorate([
|
|
26
|
+
(0, swagger_1.ApiProperty)({ example: 'Maria Souza' }),
|
|
27
|
+
__metadata("design:type", String)
|
|
28
|
+
], AnamnesisTokenSessionPatientDto.prototype, "name", void 0);
|
|
29
|
+
__decorate([
|
|
30
|
+
(0, swagger_1.ApiPropertyOptional)({ example: '12345678909', nullable: true }),
|
|
31
|
+
__metadata("design:type", Object)
|
|
32
|
+
], AnamnesisTokenSessionPatientDto.prototype, "cpf", void 0);
|
|
33
|
+
__decorate([
|
|
34
|
+
(0, swagger_1.ApiPropertyOptional)({ example: '+5511999999999', nullable: true }),
|
|
35
|
+
__metadata("design:type", Object)
|
|
36
|
+
], AnamnesisTokenSessionPatientDto.prototype, "phone", void 0);
|
|
37
|
+
class AnamnesisTokenSessionDto {
|
|
38
|
+
valid;
|
|
39
|
+
reason;
|
|
40
|
+
scope;
|
|
41
|
+
expiresAt;
|
|
42
|
+
appointmentId;
|
|
43
|
+
patient;
|
|
44
|
+
}
|
|
45
|
+
exports.AnamnesisTokenSessionDto = AnamnesisTokenSessionDto;
|
|
46
|
+
__decorate([
|
|
47
|
+
(0, swagger_1.ApiProperty)({ example: true }),
|
|
48
|
+
__metadata("design:type", Boolean)
|
|
49
|
+
], AnamnesisTokenSessionDto.prototype, "valid", void 0);
|
|
50
|
+
__decorate([
|
|
51
|
+
(0, swagger_1.ApiPropertyOptional)({
|
|
52
|
+
example: 'expired',
|
|
53
|
+
enum: ['not_found', 'expired', 'consumed', 'invalid_scope'],
|
|
54
|
+
}),
|
|
55
|
+
__metadata("design:type", String)
|
|
56
|
+
], AnamnesisTokenSessionDto.prototype, "reason", void 0);
|
|
57
|
+
__decorate([
|
|
58
|
+
(0, swagger_1.ApiPropertyOptional)({ example: 'anamnesis:submit:self' }),
|
|
59
|
+
__metadata("design:type", String)
|
|
60
|
+
], AnamnesisTokenSessionDto.prototype, "scope", void 0);
|
|
61
|
+
__decorate([
|
|
62
|
+
(0, swagger_1.ApiPropertyOptional)({ example: '2026-04-14T14:30:00.000Z' }),
|
|
63
|
+
__metadata("design:type", String)
|
|
64
|
+
], AnamnesisTokenSessionDto.prototype, "expiresAt", void 0);
|
|
65
|
+
__decorate([
|
|
66
|
+
(0, swagger_1.ApiPropertyOptional)({ example: '550e8400-e29b-41d4-a716-446655440111' }),
|
|
67
|
+
__metadata("design:type", String)
|
|
68
|
+
], AnamnesisTokenSessionDto.prototype, "appointmentId", void 0);
|
|
69
|
+
__decorate([
|
|
70
|
+
(0, swagger_1.ApiPropertyOptional)({ type: AnamnesisTokenSessionPatientDto }),
|
|
71
|
+
__metadata("design:type", AnamnesisTokenSessionPatientDto)
|
|
72
|
+
], AnamnesisTokenSessionDto.prototype, "patient", void 0);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create-anamnesis-by-token.dto.d.ts","sourceRoot":"","sources":["../../src/anamneses/create-anamnesis-by-token.dto.ts"],"names":[],"mappings":"AAGA,qBAAa,yBAAyB;IAOpC,KAAK,EAAE,MAAM,CAAC;IAad,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACtC"}
|
|
@@ -0,0 +1,42 @@
|
|
|
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.CreateAnamnesisByTokenDto = void 0;
|
|
13
|
+
const swagger_1 = require("@nestjs/swagger");
|
|
14
|
+
const class_validator_1 = require("class-validator");
|
|
15
|
+
class CreateAnamnesisByTokenDto {
|
|
16
|
+
token;
|
|
17
|
+
answersJson;
|
|
18
|
+
}
|
|
19
|
+
exports.CreateAnamnesisByTokenDto = CreateAnamnesisByTokenDto;
|
|
20
|
+
__decorate([
|
|
21
|
+
(0, swagger_1.ApiProperty)({
|
|
22
|
+
description: 'Token único de acesso à página de anamnese',
|
|
23
|
+
example: 'a5f8b3f1...',
|
|
24
|
+
}),
|
|
25
|
+
(0, class_validator_1.IsString)(),
|
|
26
|
+
(0, class_validator_1.MinLength)(16),
|
|
27
|
+
__metadata("design:type", String)
|
|
28
|
+
], CreateAnamnesisByTokenDto.prototype, "token", void 0);
|
|
29
|
+
__decorate([
|
|
30
|
+
(0, swagger_1.ApiProperty)({
|
|
31
|
+
description: 'Respostas estruturadas do formulário de anamnese',
|
|
32
|
+
type: Object,
|
|
33
|
+
example: {
|
|
34
|
+
hasAllergy: true,
|
|
35
|
+
allergyDescription: 'Dipirona',
|
|
36
|
+
medications: ['Omeprazol'],
|
|
37
|
+
},
|
|
38
|
+
}),
|
|
39
|
+
(0, class_validator_1.IsObject)(),
|
|
40
|
+
(0, class_validator_1.IsNotEmpty)(),
|
|
41
|
+
__metadata("design:type", Object)
|
|
42
|
+
], CreateAnamnesisByTokenDto.prototype, "answersJson", void 0);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/anamneses/index.ts"],"names":[],"mappings":"AAAA,cAAc,iCAAiC,CAAC;AAChD,cAAc,+BAA+B,CAAC;AAC9C,cAAc,yBAAyB,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
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("./create-anamnesis-by-token.dto"), exports);
|
|
18
|
+
__exportStar(require("./anamnesis-token-session.dto"), exports);
|
|
19
|
+
__exportStar(require("./patient-anamnesis.dto"), exports);
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export declare class PatientAnamnesisDto {
|
|
2
|
+
id: string;
|
|
3
|
+
patientId: string;
|
|
4
|
+
appointmentId: string | null;
|
|
5
|
+
startDate: string;
|
|
6
|
+
endDate: string;
|
|
7
|
+
answersJson: Record<string, unknown>;
|
|
8
|
+
createdAt: string;
|
|
9
|
+
}
|
|
10
|
+
//# sourceMappingURL=patient-anamnesis.dto.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"patient-anamnesis.dto.d.ts","sourceRoot":"","sources":["../../src/anamneses/patient-anamnesis.dto.ts"],"names":[],"mappings":"AAEA,qBAAa,mBAAmB;IAE9B,EAAE,EAAE,MAAM,CAAC;IAGX,SAAS,EAAE,MAAM,CAAC;IAGlB,aAAa,EAAE,MAAM,GAAG,IAAI,CAAC;IAG7B,SAAS,EAAE,MAAM,CAAC;IAGlB,OAAO,EAAE,MAAM,CAAC;IAGhB,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAGrC,SAAS,EAAE,MAAM,CAAC;CACnB"}
|
|
@@ -0,0 +1,51 @@
|
|
|
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.PatientAnamnesisDto = void 0;
|
|
13
|
+
const swagger_1 = require("@nestjs/swagger");
|
|
14
|
+
class PatientAnamnesisDto {
|
|
15
|
+
id;
|
|
16
|
+
patientId;
|
|
17
|
+
appointmentId;
|
|
18
|
+
startDate;
|
|
19
|
+
endDate;
|
|
20
|
+
answersJson;
|
|
21
|
+
createdAt;
|
|
22
|
+
}
|
|
23
|
+
exports.PatientAnamnesisDto = PatientAnamnesisDto;
|
|
24
|
+
__decorate([
|
|
25
|
+
(0, swagger_1.ApiProperty)({ example: '550e8400-e29b-41d4-a716-446655440010' }),
|
|
26
|
+
__metadata("design:type", String)
|
|
27
|
+
], PatientAnamnesisDto.prototype, "id", void 0);
|
|
28
|
+
__decorate([
|
|
29
|
+
(0, swagger_1.ApiProperty)({ example: '550e8400-e29b-41d4-a716-446655440000' }),
|
|
30
|
+
__metadata("design:type", String)
|
|
31
|
+
], PatientAnamnesisDto.prototype, "patientId", void 0);
|
|
32
|
+
__decorate([
|
|
33
|
+
(0, swagger_1.ApiPropertyOptional)({ example: '550e8400-e29b-41d4-a716-446655440111', nullable: true }),
|
|
34
|
+
__metadata("design:type", Object)
|
|
35
|
+
], PatientAnamnesisDto.prototype, "appointmentId", void 0);
|
|
36
|
+
__decorate([
|
|
37
|
+
(0, swagger_1.ApiProperty)({ example: '2026-04-14T10:00:00.000Z' }),
|
|
38
|
+
__metadata("design:type", String)
|
|
39
|
+
], PatientAnamnesisDto.prototype, "startDate", void 0);
|
|
40
|
+
__decorate([
|
|
41
|
+
(0, swagger_1.ApiProperty)({ example: '2026-10-14T10:00:00.000Z' }),
|
|
42
|
+
__metadata("design:type", String)
|
|
43
|
+
], PatientAnamnesisDto.prototype, "endDate", void 0);
|
|
44
|
+
__decorate([
|
|
45
|
+
(0, swagger_1.ApiProperty)({ type: Object }),
|
|
46
|
+
__metadata("design:type", Object)
|
|
47
|
+
], PatientAnamnesisDto.prototype, "answersJson", void 0);
|
|
48
|
+
__decorate([
|
|
49
|
+
(0, swagger_1.ApiProperty)({ example: '2026-04-14T10:00:10.000Z' }),
|
|
50
|
+
__metadata("design:type", String)
|
|
51
|
+
], PatientAnamnesisDto.prototype, "createdAt", void 0);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plan-summary.dto.d.ts","sourceRoot":"","sources":["../../src/configurations/plan-summary.dto.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,qBAAa,cAAc;IAEzB,EAAE,EAAE,MAAM,CAAC;IAGX,IAAI,EAAE,MAAM,CAAC;IAGb,KAAK,EAAE,MAAM,CAAC;IAGd,cAAc,EAAE,MAAM,CAAC;IAGvB,QAAQ,EAAE,MAAM,CAAC;IAGjB,MAAM,EAAE,QAAQ,GAAG,UAAU,CAAC;IAG9B,oBAAoB,EAAE,MAAM,CAAC;IAG7B,WAAW,EAAE,MAAM,CAAC;IAGpB,UAAU,EAAE,MAAM,CAAC;IAGnB,aAAa,EAAE,MAAM,CAAC;IAGtB,iBAAiB,EAAE,MAAM,CAAC;IAG1B,aAAa,EAAE,MAAM,CAAC;IAGtB,SAAS,CAAC,EAAE,IAAI,CAAC;IAGjB,SAAS,CAAC,EAAE,IAAI,CAAC;CAClB"}
|
|
1
|
+
{"version":3,"file":"plan-summary.dto.d.ts","sourceRoot":"","sources":["../../src/configurations/plan-summary.dto.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,qBAAa,cAAc;IAEzB,EAAE,EAAE,MAAM,CAAC;IAGX,IAAI,EAAE,MAAM,CAAC;IAGb,KAAK,EAAE,MAAM,CAAC;IAGd,cAAc,EAAE,MAAM,CAAC;IAGvB,QAAQ,EAAE,MAAM,CAAC;IAGjB,MAAM,EAAE,QAAQ,GAAG,UAAU,CAAC;IAG9B,oBAAoB,EAAE,MAAM,CAAC;IAG7B,WAAW,EAAE,MAAM,CAAC;IAGpB,UAAU,EAAE,MAAM,CAAC;IAGnB,aAAa,EAAE,MAAM,CAAC;IAGtB,iBAAiB,EAAE,MAAM,CAAC;IAG1B,aAAa,EAAE,MAAM,CAAC;IAGtB,eAAe,EAAE,MAAM,CAAC;IAGxB,SAAS,CAAC,EAAE,IAAI,CAAC;IAGjB,SAAS,CAAC,EAAE,IAAI,CAAC;CAClB"}
|
|
@@ -27,6 +27,7 @@ class PlanSummaryDto {
|
|
|
27
27
|
maxAttendants;
|
|
28
28
|
maxAdministrators;
|
|
29
29
|
maxProcedures;
|
|
30
|
+
monthlyAiTokens;
|
|
30
31
|
createdAt;
|
|
31
32
|
updatedAt;
|
|
32
33
|
}
|
|
@@ -79,6 +80,10 @@ __decorate([
|
|
|
79
80
|
(0, swagger_1.ApiProperty)({ description: 'Max procedures', example: 200 }),
|
|
80
81
|
__metadata("design:type", Number)
|
|
81
82
|
], PlanSummaryDto.prototype, "maxProcedures", void 0);
|
|
83
|
+
__decorate([
|
|
84
|
+
(0, swagger_1.ApiProperty)({ description: 'Monthly AI token allowance', example: 5000 }),
|
|
85
|
+
__metadata("design:type", Number)
|
|
86
|
+
], PlanSummaryDto.prototype, "monthlyAiTokens", void 0);
|
|
82
87
|
__decorate([
|
|
83
88
|
(0, swagger_1.ApiPropertyOptional)(),
|
|
84
89
|
__metadata("design:type", Date)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"followup-events.dto.d.ts","sourceRoot":"","sources":["../../src/conversations/followup-events.dto.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,kBAAkB,iBAAiB,CAAC;AACjD,eAAO,MAAM,sBAAsB,qBAAqB,CAAC;AACzD,eAAO,MAAM,6BAA6B,4BAA4B,CAAC;AACvE,eAAO,MAAM,yBAAyB,wBAAwB,CAAC;AAE/D,qEAAqE;AACrE,eAAO,MAAM,uBAAuB,sBAAsB,CAAC;AAC3D,gEAAgE;AAChE,eAAO,MAAM,wCAAwC,oCAClB,CAAC;AAEpC,qBAAa,gCAAgC;IAK3C,MAAM,EAAE,MAAM,CAAC;IAMf,SAAS,EAAE,MAAM,CAAC;IAIlB,WAAW,EAAE,MAAM,CAAC;IAIpB,MAAM,CAAC,EAAE,MAAM,CAAC;IAMhB,WAAW,EAAE,IAAI,GAAG,OAAO,GAAG,SAAS,CAAC;IAKxC,UAAU,CAAC,EAAE,OAAO,CAAC;IAIrB,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,qBAAa,iCAAiC;IAK5C,MAAM,EAAE,MAAM,CAAC;IAIf,MAAM,CAAC,EAAE,MAAM,CAAC;IAMhB,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAIhC,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,qBAAa,8BAA8B;IAKzC,MAAM,EAAE,MAAM,CAAC;IAIf,aAAa,EAAE,MAAM,CAAC;IAMtB,SAAS,EAAE,MAAM,CAAC;IAMlB,MAAM,EAAE,MAAM,CAAC;IAMf,cAAc,CAAC,EAAE,MAAM,CAAC;IAKxB,IAAI,CAAC,EAAE,MAAM,CAAC;IAKd,QAAQ,CAAC,EAAE,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"followup-events.dto.d.ts","sourceRoot":"","sources":["../../src/conversations/followup-events.dto.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,kBAAkB,iBAAiB,CAAC;AACjD,eAAO,MAAM,sBAAsB,qBAAqB,CAAC;AACzD,eAAO,MAAM,6BAA6B,4BAA4B,CAAC;AACvE,eAAO,MAAM,yBAAyB,wBAAwB,CAAC;AAE/D,qEAAqE;AACrE,eAAO,MAAM,uBAAuB,sBAAsB,CAAC;AAC3D,gEAAgE;AAChE,eAAO,MAAM,wCAAwC,oCAClB,CAAC;AAEpC,qBAAa,gCAAgC;IAK3C,MAAM,EAAE,MAAM,CAAC;IAMf,SAAS,EAAE,MAAM,CAAC;IAIlB,WAAW,EAAE,MAAM,CAAC;IAIpB,MAAM,CAAC,EAAE,MAAM,CAAC;IAMhB,WAAW,EAAE,IAAI,GAAG,OAAO,GAAG,SAAS,CAAC;IAKxC,UAAU,CAAC,EAAE,OAAO,CAAC;IAIrB,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,qBAAa,iCAAiC;IAK5C,MAAM,EAAE,MAAM,CAAC;IAIf,MAAM,CAAC,EAAE,MAAM,CAAC;IAMhB,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAIhC,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,qBAAa,8BAA8B;IAKzC,MAAM,EAAE,MAAM,CAAC;IAIf,aAAa,EAAE,MAAM,CAAC;IAMtB,SAAS,EAAE,MAAM,CAAC;IAMlB,MAAM,EAAE,MAAM,CAAC;IAMf,cAAc,CAAC,EAAE,MAAM,CAAC;IAKxB,IAAI,CAAC,EAAE,MAAM,CAAC;IAKd,QAAQ,CAAC,EAAE,MAAM,CAAC;IAKlB,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAI3B,UAAU,EAAE,MAAM,CAAC;CACpB"}
|
|
@@ -111,6 +111,7 @@ class AppointmentChangedEventPayload {
|
|
|
111
111
|
previousStatus;
|
|
112
112
|
date;
|
|
113
113
|
exitTime;
|
|
114
|
+
checkinCompleted;
|
|
114
115
|
occurredAt;
|
|
115
116
|
}
|
|
116
117
|
exports.AppointmentChangedEventPayload = AppointmentChangedEventPayload;
|
|
@@ -159,6 +160,12 @@ __decorate([
|
|
|
159
160
|
(0, class_validator_1.IsISO8601)(),
|
|
160
161
|
__metadata("design:type", String)
|
|
161
162
|
], AppointmentChangedEventPayload.prototype, "exitTime", void 0);
|
|
163
|
+
__decorate([
|
|
164
|
+
(0, swagger_1.ApiProperty)({ required: false, example: true }),
|
|
165
|
+
(0, class_validator_1.IsOptional)(),
|
|
166
|
+
(0, class_validator_1.IsBoolean)(),
|
|
167
|
+
__metadata("design:type", Boolean)
|
|
168
|
+
], AppointmentChangedEventPayload.prototype, "checkinCompleted", void 0);
|
|
162
169
|
__decorate([
|
|
163
170
|
(0, swagger_1.ApiProperty)({ example: '2026-03-30T12:03:14.000Z' }),
|
|
164
171
|
(0, class_validator_1.IsISO8601)(),
|
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,mBAAmB,CAAC;AAClC,cAAc,MAAM,CAAC;AACrB,cAAc,WAAW,CAAC;AAC1B,cAAc,iBAAiB,CAAC;AAChC,cAAc,WAAW,CAAC;AAC1B,cAAc,iBAAiB,CAAC;AAChC,cAAc,eAAe,CAAC;AAC9B,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC;AAC3B,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,mBAAmB,CAAC;AAClC,cAAc,MAAM,CAAC;AACrB,cAAc,WAAW,CAAC;AAC1B,cAAc,iBAAiB,CAAC;AAChC,cAAc,WAAW,CAAC;AAC1B,cAAc,iBAAiB,CAAC;AAChC,cAAc,eAAe,CAAC;AAC9B,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC;AAC3B,cAAc,WAAW,CAAC;AAC1B,cAAc,aAAa,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { TenantAiTokenStateDto } from './tenant-ai-token-state.dto';
|
|
2
|
+
export declare const TENANT_AI_TOKEN_CONSUMPTION_SOURCES: readonly ["ai.request", "ai.followup.generate"];
|
|
3
|
+
export type TenantAiTokenConsumptionSourceDto = (typeof TENANT_AI_TOKEN_CONSUMPTION_SOURCES)[number];
|
|
4
|
+
export declare class ConsumeTenantAiTokensDto {
|
|
5
|
+
tenant: string;
|
|
6
|
+
tokens: number;
|
|
7
|
+
source: TenantAiTokenConsumptionSourceDto;
|
|
8
|
+
correlationId?: string;
|
|
9
|
+
}
|
|
10
|
+
export declare class ConsumeTenantAiTokensResponseDto extends TenantAiTokenStateDto {
|
|
11
|
+
consumed: number;
|
|
12
|
+
becameZero: boolean;
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=consume-tenant-ai-tokens.dto.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"consume-tenant-ai-tokens.dto.d.ts","sourceRoot":"","sources":["../../src/tenants/consume-tenant-ai-tokens.dto.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,qBAAqB,EAAE,MAAM,6BAA6B,CAAC;AAEpE,eAAO,MAAM,mCAAmC,iDAAkD,CAAC;AACnG,MAAM,MAAM,iCAAiC,GAC3C,CAAC,OAAO,mCAAmC,CAAC,CAAC,MAAM,CAAC,CAAC;AAEvD,qBAAa,wBAAwB;IAInC,MAAM,EAAE,MAAM,CAAC;IAKf,MAAM,EAAE,MAAM,CAAC;IAOf,MAAM,EAAE,iCAAiC,CAAC;IAK1C,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAED,qBAAa,gCAAiC,SAAQ,qBAAqB;IAIzE,QAAQ,EAAE,MAAM,CAAC;IAGjB,UAAU,EAAE,OAAO,CAAC;CACrB"}
|
|
@@ -0,0 +1,64 @@
|
|
|
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.ConsumeTenantAiTokensResponseDto = exports.ConsumeTenantAiTokensDto = exports.TENANT_AI_TOKEN_CONSUMPTION_SOURCES = void 0;
|
|
13
|
+
const swagger_1 = require("@nestjs/swagger");
|
|
14
|
+
const class_validator_1 = require("class-validator");
|
|
15
|
+
const tenant_ai_token_state_dto_1 = require("./tenant-ai-token-state.dto");
|
|
16
|
+
exports.TENANT_AI_TOKEN_CONSUMPTION_SOURCES = ['ai.request', 'ai.followup.generate'];
|
|
17
|
+
class ConsumeTenantAiTokensDto {
|
|
18
|
+
tenant;
|
|
19
|
+
tokens;
|
|
20
|
+
source;
|
|
21
|
+
correlationId;
|
|
22
|
+
}
|
|
23
|
+
exports.ConsumeTenantAiTokensDto = ConsumeTenantAiTokensDto;
|
|
24
|
+
__decorate([
|
|
25
|
+
(0, swagger_1.ApiProperty)({ description: 'Tenant slug', example: 'clinic-alpha' }),
|
|
26
|
+
(0, class_validator_1.IsString)(),
|
|
27
|
+
(0, class_validator_1.IsNotEmpty)(),
|
|
28
|
+
__metadata("design:type", String)
|
|
29
|
+
], ConsumeTenantAiTokensDto.prototype, "tenant", void 0);
|
|
30
|
+
__decorate([
|
|
31
|
+
(0, swagger_1.ApiProperty)({ description: 'Tokens to consume', example: 420 }),
|
|
32
|
+
(0, class_validator_1.IsInt)(),
|
|
33
|
+
(0, class_validator_1.Min)(0),
|
|
34
|
+
__metadata("design:type", Number)
|
|
35
|
+
], ConsumeTenantAiTokensDto.prototype, "tokens", void 0);
|
|
36
|
+
__decorate([
|
|
37
|
+
(0, swagger_1.ApiProperty)({
|
|
38
|
+
description: 'Deterministic source of consumption',
|
|
39
|
+
enum: exports.TENANT_AI_TOKEN_CONSUMPTION_SOURCES,
|
|
40
|
+
}),
|
|
41
|
+
(0, class_validator_1.IsIn)(exports.TENANT_AI_TOKEN_CONSUMPTION_SOURCES),
|
|
42
|
+
__metadata("design:type", String)
|
|
43
|
+
], ConsumeTenantAiTokensDto.prototype, "source", void 0);
|
|
44
|
+
__decorate([
|
|
45
|
+
(0, swagger_1.ApiProperty)({ description: 'Optional operation correlation id', required: false }),
|
|
46
|
+
(0, class_validator_1.IsOptional)(),
|
|
47
|
+
(0, class_validator_1.IsString)(),
|
|
48
|
+
__metadata("design:type", String)
|
|
49
|
+
], ConsumeTenantAiTokensDto.prototype, "correlationId", void 0);
|
|
50
|
+
class ConsumeTenantAiTokensResponseDto extends tenant_ai_token_state_dto_1.TenantAiTokenStateDto {
|
|
51
|
+
consumed;
|
|
52
|
+
becameZero;
|
|
53
|
+
}
|
|
54
|
+
exports.ConsumeTenantAiTokensResponseDto = ConsumeTenantAiTokensResponseDto;
|
|
55
|
+
__decorate([
|
|
56
|
+
(0, swagger_1.ApiProperty)({ description: 'How many tokens were actually consumed', example: 420 }),
|
|
57
|
+
(0, class_validator_1.IsInt)(),
|
|
58
|
+
(0, class_validator_1.Min)(0),
|
|
59
|
+
__metadata("design:type", Number)
|
|
60
|
+
], ConsumeTenantAiTokensResponseDto.prototype, "consumed", void 0);
|
|
61
|
+
__decorate([
|
|
62
|
+
(0, swagger_1.ApiProperty)({ description: 'True when the balance reached zero in this operation', example: false }),
|
|
63
|
+
__metadata("design:type", Boolean)
|
|
64
|
+
], ConsumeTenantAiTokensResponseDto.prototype, "becameZero", void 0);
|
package/dist/tenants/index.d.ts
CHANGED
|
@@ -3,4 +3,8 @@ export * from './get-tenant-by-address.query.dto';
|
|
|
3
3
|
export * from './tenant-public-by-address-response.dto';
|
|
4
4
|
export * from './whatsapp-provider-kind.dto';
|
|
5
5
|
export * from './tenant-slug.util';
|
|
6
|
+
export * from './tenant-ai-token-state.dto';
|
|
7
|
+
export * from './consume-tenant-ai-tokens.dto';
|
|
8
|
+
export * from './recharge-tenant-ai-tokens.dto';
|
|
9
|
+
export * from './renew-tenant-ai-tokens.dto';
|
|
6
10
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/tenants/index.ts"],"names":[],"mappings":"AAAA,cAAc,qCAAqC,CAAC;AACpD,cAAc,mCAAmC,CAAC;AAClD,cAAc,yCAAyC,CAAC;AACxD,cAAc,8BAA8B,CAAC;AAC7C,cAAc,oBAAoB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/tenants/index.ts"],"names":[],"mappings":"AAAA,cAAc,qCAAqC,CAAC;AACpD,cAAc,mCAAmC,CAAC;AAClD,cAAc,yCAAyC,CAAC;AACxD,cAAc,8BAA8B,CAAC;AAC7C,cAAc,oBAAoB,CAAC;AACnC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,gCAAgC,CAAC;AAC/C,cAAc,iCAAiC,CAAC;AAChD,cAAc,8BAA8B,CAAC"}
|
package/dist/tenants/index.js
CHANGED
|
@@ -19,3 +19,7 @@ __exportStar(require("./get-tenant-by-address.query.dto"), exports);
|
|
|
19
19
|
__exportStar(require("./tenant-public-by-address-response.dto"), exports);
|
|
20
20
|
__exportStar(require("./whatsapp-provider-kind.dto"), exports);
|
|
21
21
|
__exportStar(require("./tenant-slug.util"), exports);
|
|
22
|
+
__exportStar(require("./tenant-ai-token-state.dto"), exports);
|
|
23
|
+
__exportStar(require("./consume-tenant-ai-tokens.dto"), exports);
|
|
24
|
+
__exportStar(require("./recharge-tenant-ai-tokens.dto"), exports);
|
|
25
|
+
__exportStar(require("./renew-tenant-ai-tokens.dto"), exports);
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { TenantAiTokenStateDto } from './tenant-ai-token-state.dto';
|
|
2
|
+
export declare class RechargeTenantAiTokensDto {
|
|
3
|
+
tenantId: string;
|
|
4
|
+
amount: number;
|
|
5
|
+
reason?: string;
|
|
6
|
+
}
|
|
7
|
+
export declare class RechargeTenantAiTokensResponseDto extends TenantAiTokenStateDto {
|
|
8
|
+
added: number;
|
|
9
|
+
}
|
|
10
|
+
//# sourceMappingURL=recharge-tenant-ai-tokens.dto.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"recharge-tenant-ai-tokens.dto.d.ts","sourceRoot":"","sources":["../../src/tenants/recharge-tenant-ai-tokens.dto.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,qBAAqB,EAAE,MAAM,6BAA6B,CAAC;AAEpE,qBAAa,yBAAyB;IAIpC,QAAQ,EAAE,MAAM,CAAC;IAKjB,MAAM,EAAE,MAAM,CAAC;IAKf,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,qBAAa,iCAAkC,SAAQ,qBAAqB;IAI1E,KAAK,EAAE,MAAM,CAAC;CACf"}
|
|
@@ -0,0 +1,49 @@
|
|
|
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.RechargeTenantAiTokensResponseDto = exports.RechargeTenantAiTokensDto = void 0;
|
|
13
|
+
const swagger_1 = require("@nestjs/swagger");
|
|
14
|
+
const class_validator_1 = require("class-validator");
|
|
15
|
+
const tenant_ai_token_state_dto_1 = require("./tenant-ai-token-state.dto");
|
|
16
|
+
class RechargeTenantAiTokensDto {
|
|
17
|
+
tenantId;
|
|
18
|
+
amount;
|
|
19
|
+
reason;
|
|
20
|
+
}
|
|
21
|
+
exports.RechargeTenantAiTokensDto = RechargeTenantAiTokensDto;
|
|
22
|
+
__decorate([
|
|
23
|
+
(0, swagger_1.ApiProperty)({ description: 'Tenant id (UUID)', example: 'a1b2c3d4-e5f6-7890-abcd-ef1234567890' }),
|
|
24
|
+
(0, class_validator_1.IsString)(),
|
|
25
|
+
(0, class_validator_1.IsNotEmpty)(),
|
|
26
|
+
__metadata("design:type", String)
|
|
27
|
+
], RechargeTenantAiTokensDto.prototype, "tenantId", void 0);
|
|
28
|
+
__decorate([
|
|
29
|
+
(0, swagger_1.ApiProperty)({ description: 'Amount of tokens to add', example: 10000 }),
|
|
30
|
+
(0, class_validator_1.IsInt)(),
|
|
31
|
+
(0, class_validator_1.Min)(1),
|
|
32
|
+
__metadata("design:type", Number)
|
|
33
|
+
], RechargeTenantAiTokensDto.prototype, "amount", void 0);
|
|
34
|
+
__decorate([
|
|
35
|
+
(0, swagger_1.ApiPropertyOptional)({ description: 'Free text reason for audit', example: 'Recarga manual realizada pelo financeiro' }),
|
|
36
|
+
(0, class_validator_1.IsOptional)(),
|
|
37
|
+
(0, class_validator_1.IsString)(),
|
|
38
|
+
__metadata("design:type", String)
|
|
39
|
+
], RechargeTenantAiTokensDto.prototype, "reason", void 0);
|
|
40
|
+
class RechargeTenantAiTokensResponseDto extends tenant_ai_token_state_dto_1.TenantAiTokenStateDto {
|
|
41
|
+
added;
|
|
42
|
+
}
|
|
43
|
+
exports.RechargeTenantAiTokensResponseDto = RechargeTenantAiTokensResponseDto;
|
|
44
|
+
__decorate([
|
|
45
|
+
(0, swagger_1.ApiProperty)({ description: 'Recharge amount applied', example: 10000 }),
|
|
46
|
+
(0, class_validator_1.IsInt)(),
|
|
47
|
+
(0, class_validator_1.Min)(1),
|
|
48
|
+
__metadata("design:type", Number)
|
|
49
|
+
], RechargeTenantAiTokensResponseDto.prototype, "added", void 0);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"renew-tenant-ai-tokens.dto.d.ts","sourceRoot":"","sources":["../../src/tenants/renew-tenant-ai-tokens.dto.ts"],"names":[],"mappings":"AAGA,qBAAa,sBAAsB;IAIjC,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,qBAAa,8BAA8B;IAIzC,YAAY,EAAE,MAAM,CAAC;CACtB"}
|
|
@@ -0,0 +1,34 @@
|
|
|
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.RenewTenantAiTokensResponseDto = exports.RenewTenantAiTokensDto = void 0;
|
|
13
|
+
const swagger_1 = require("@nestjs/swagger");
|
|
14
|
+
const class_validator_1 = require("class-validator");
|
|
15
|
+
class RenewTenantAiTokensDto {
|
|
16
|
+
tenantId;
|
|
17
|
+
}
|
|
18
|
+
exports.RenewTenantAiTokensDto = RenewTenantAiTokensDto;
|
|
19
|
+
__decorate([
|
|
20
|
+
(0, swagger_1.ApiPropertyOptional)({ description: 'Optional tenant id to renew one tenant only' }),
|
|
21
|
+
(0, class_validator_1.IsOptional)(),
|
|
22
|
+
(0, class_validator_1.IsString)(),
|
|
23
|
+
__metadata("design:type", String)
|
|
24
|
+
], RenewTenantAiTokensDto.prototype, "tenantId", void 0);
|
|
25
|
+
class RenewTenantAiTokensResponseDto {
|
|
26
|
+
renewedCount;
|
|
27
|
+
}
|
|
28
|
+
exports.RenewTenantAiTokensResponseDto = RenewTenantAiTokensResponseDto;
|
|
29
|
+
__decorate([
|
|
30
|
+
(0, swagger_1.ApiPropertyOptional)({ description: 'How many tenants were renewed', example: 12 }),
|
|
31
|
+
(0, class_validator_1.IsInt)(),
|
|
32
|
+
(0, class_validator_1.Min)(0),
|
|
33
|
+
__metadata("design:type", Number)
|
|
34
|
+
], RenewTenantAiTokensResponseDto.prototype, "renewedCount", void 0);
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export declare class TenantAiTokenStateDto {
|
|
2
|
+
tenant: string;
|
|
3
|
+
currentBalance: number;
|
|
4
|
+
monthlyAllowance: number;
|
|
5
|
+
blocked: boolean;
|
|
6
|
+
cycleStartedAt: string;
|
|
7
|
+
nextRenewalAt: string;
|
|
8
|
+
recurrenceDays: number;
|
|
9
|
+
canUseAi: boolean;
|
|
10
|
+
lastConsumedAt?: string;
|
|
11
|
+
lastRechargedAt?: string;
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=tenant-ai-token-state.dto.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tenant-ai-token-state.dto.d.ts","sourceRoot":"","sources":["../../src/tenants/tenant-ai-token-state.dto.ts"],"names":[],"mappings":"AAGA,qBAAa,qBAAqB;IAIhC,MAAM,EAAE,MAAM,CAAC;IAKf,cAAc,EAAE,MAAM,CAAC;IAKvB,gBAAgB,EAAE,MAAM,CAAC;IAIzB,OAAO,EAAE,OAAO,CAAC;IAIjB,cAAc,EAAE,MAAM,CAAC;IAIvB,aAAa,EAAE,MAAM,CAAC;IAKtB,cAAc,EAAE,MAAM,CAAC;IAIvB,QAAQ,EAAE,OAAO,CAAC;IAKlB,cAAc,CAAC,EAAE,MAAM,CAAC;IAKxB,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B"}
|
|
@@ -0,0 +1,83 @@
|
|
|
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.TenantAiTokenStateDto = void 0;
|
|
13
|
+
const swagger_1 = require("@nestjs/swagger");
|
|
14
|
+
const class_validator_1 = require("class-validator");
|
|
15
|
+
class TenantAiTokenStateDto {
|
|
16
|
+
tenant;
|
|
17
|
+
currentBalance;
|
|
18
|
+
monthlyAllowance;
|
|
19
|
+
blocked;
|
|
20
|
+
cycleStartedAt;
|
|
21
|
+
nextRenewalAt;
|
|
22
|
+
recurrenceDays;
|
|
23
|
+
canUseAi;
|
|
24
|
+
lastConsumedAt;
|
|
25
|
+
lastRechargedAt;
|
|
26
|
+
}
|
|
27
|
+
exports.TenantAiTokenStateDto = TenantAiTokenStateDto;
|
|
28
|
+
__decorate([
|
|
29
|
+
(0, swagger_1.ApiProperty)({ description: 'Tenant slug', example: 'clinic-alpha' }),
|
|
30
|
+
(0, class_validator_1.IsString)(),
|
|
31
|
+
(0, class_validator_1.IsNotEmpty)(),
|
|
32
|
+
__metadata("design:type", String)
|
|
33
|
+
], TenantAiTokenStateDto.prototype, "tenant", void 0);
|
|
34
|
+
__decorate([
|
|
35
|
+
(0, swagger_1.ApiProperty)({ description: 'Current remaining AI tokens', example: 2400 }),
|
|
36
|
+
(0, class_validator_1.IsInt)(),
|
|
37
|
+
(0, class_validator_1.Min)(0),
|
|
38
|
+
__metadata("design:type", Number)
|
|
39
|
+
], TenantAiTokenStateDto.prototype, "currentBalance", void 0);
|
|
40
|
+
__decorate([
|
|
41
|
+
(0, swagger_1.ApiProperty)({ description: 'Monthly allowance configured for current cycle', example: 5000 }),
|
|
42
|
+
(0, class_validator_1.IsInt)(),
|
|
43
|
+
(0, class_validator_1.Min)(0),
|
|
44
|
+
__metadata("design:type", Number)
|
|
45
|
+
], TenantAiTokenStateDto.prototype, "monthlyAllowance", void 0);
|
|
46
|
+
__decorate([
|
|
47
|
+
(0, swagger_1.ApiProperty)({ description: 'Whether IA is blocked for this tenant', example: false }),
|
|
48
|
+
(0, class_validator_1.IsBoolean)(),
|
|
49
|
+
__metadata("design:type", Boolean)
|
|
50
|
+
], TenantAiTokenStateDto.prototype, "blocked", void 0);
|
|
51
|
+
__decorate([
|
|
52
|
+
(0, swagger_1.ApiProperty)({ description: 'Current cycle start timestamp', example: '2026-04-01T00:00:00.000Z' }),
|
|
53
|
+
(0, class_validator_1.IsDateString)(),
|
|
54
|
+
__metadata("design:type", String)
|
|
55
|
+
], TenantAiTokenStateDto.prototype, "cycleStartedAt", void 0);
|
|
56
|
+
__decorate([
|
|
57
|
+
(0, swagger_1.ApiProperty)({ description: 'Next monthly renewal timestamp', example: '2026-05-01T00:00:00.000Z' }),
|
|
58
|
+
(0, class_validator_1.IsDateString)(),
|
|
59
|
+
__metadata("design:type", String)
|
|
60
|
+
], TenantAiTokenStateDto.prototype, "nextRenewalAt", void 0);
|
|
61
|
+
__decorate([
|
|
62
|
+
(0, swagger_1.ApiProperty)({ description: 'Plan recurrence in days used for renewal', example: 30 }),
|
|
63
|
+
(0, class_validator_1.IsInt)(),
|
|
64
|
+
(0, class_validator_1.Min)(1),
|
|
65
|
+
__metadata("design:type", Number)
|
|
66
|
+
], TenantAiTokenStateDto.prototype, "recurrenceDays", void 0);
|
|
67
|
+
__decorate([
|
|
68
|
+
(0, swagger_1.ApiProperty)({ description: 'True when balance is currently greater than zero', example: true }),
|
|
69
|
+
(0, class_validator_1.IsBoolean)(),
|
|
70
|
+
__metadata("design:type", Boolean)
|
|
71
|
+
], TenantAiTokenStateDto.prototype, "canUseAi", void 0);
|
|
72
|
+
__decorate([
|
|
73
|
+
(0, swagger_1.ApiProperty)({ description: 'Last consumption timestamp', required: false }),
|
|
74
|
+
(0, class_validator_1.IsOptional)(),
|
|
75
|
+
(0, class_validator_1.IsDateString)(),
|
|
76
|
+
__metadata("design:type", String)
|
|
77
|
+
], TenantAiTokenStateDto.prototype, "lastConsumedAt", void 0);
|
|
78
|
+
__decorate([
|
|
79
|
+
(0, swagger_1.ApiProperty)({ description: 'Last recharge timestamp', required: false }),
|
|
80
|
+
(0, class_validator_1.IsOptional)(),
|
|
81
|
+
(0, class_validator_1.IsDateString)(),
|
|
82
|
+
__metadata("design:type", String)
|
|
83
|
+
], TenantAiTokenStateDto.prototype, "lastRechargedAt", void 0);
|
package/package.json
CHANGED
|
@@ -37,4 +37,25 @@ export class AiIntegrationResponseDto {
|
|
|
37
37
|
@IsOptional()
|
|
38
38
|
@IsString()
|
|
39
39
|
aiUsageId?: string;
|
|
40
|
+
|
|
41
|
+
@ApiPropertyOptional({
|
|
42
|
+
description: 'Prompt tokens consumed in this AI request',
|
|
43
|
+
example: 120,
|
|
44
|
+
})
|
|
45
|
+
@IsOptional()
|
|
46
|
+
promptTokens?: number;
|
|
47
|
+
|
|
48
|
+
@ApiPropertyOptional({
|
|
49
|
+
description: 'Completion tokens generated in this AI request',
|
|
50
|
+
example: 90,
|
|
51
|
+
})
|
|
52
|
+
@IsOptional()
|
|
53
|
+
completionTokens?: number;
|
|
54
|
+
|
|
55
|
+
@ApiPropertyOptional({
|
|
56
|
+
description: 'Total tokens consumed in this AI request',
|
|
57
|
+
example: 210,
|
|
58
|
+
})
|
|
59
|
+
@IsOptional()
|
|
60
|
+
totalTokens?: number;
|
|
40
61
|
}
|
|
@@ -17,7 +17,7 @@ export interface EmitAnalyticEventOptions {
|
|
|
17
17
|
/**
|
|
18
18
|
* Builds the Kafka payload to be sent to the analytics service.
|
|
19
19
|
*
|
|
20
|
-
* Usage (fire-and-forget via
|
|
20
|
+
* Usage (fire-and-forget via ClientProxy.emit):
|
|
21
21
|
* ```ts
|
|
22
22
|
* this.analyticsClient.emit(
|
|
23
23
|
* TOPIC_ANALYTICS_EVENT,
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';
|
|
2
|
+
|
|
3
|
+
export class AnamnesisTokenSessionPatientDto {
|
|
4
|
+
@ApiProperty({ example: '550e8400-e29b-41d4-a716-446655440000' })
|
|
5
|
+
id: string;
|
|
6
|
+
|
|
7
|
+
@ApiProperty({ example: 'Maria Souza' })
|
|
8
|
+
name: string;
|
|
9
|
+
|
|
10
|
+
@ApiPropertyOptional({ example: '12345678909', nullable: true })
|
|
11
|
+
cpf: string | null;
|
|
12
|
+
|
|
13
|
+
@ApiPropertyOptional({ example: '+5511999999999', nullable: true })
|
|
14
|
+
phone: string | null;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export class AnamnesisTokenSessionDto {
|
|
18
|
+
@ApiProperty({ example: true })
|
|
19
|
+
valid: boolean;
|
|
20
|
+
|
|
21
|
+
@ApiPropertyOptional({
|
|
22
|
+
example: 'expired',
|
|
23
|
+
enum: ['not_found', 'expired', 'consumed', 'invalid_scope'],
|
|
24
|
+
})
|
|
25
|
+
reason?: 'not_found' | 'expired' | 'consumed' | 'invalid_scope';
|
|
26
|
+
|
|
27
|
+
@ApiPropertyOptional({ example: 'anamnesis:submit:self' })
|
|
28
|
+
scope?: string;
|
|
29
|
+
|
|
30
|
+
@ApiPropertyOptional({ example: '2026-04-14T14:30:00.000Z' })
|
|
31
|
+
expiresAt?: string;
|
|
32
|
+
|
|
33
|
+
@ApiPropertyOptional({ example: '550e8400-e29b-41d4-a716-446655440111' })
|
|
34
|
+
appointmentId?: string;
|
|
35
|
+
|
|
36
|
+
@ApiPropertyOptional({ type: AnamnesisTokenSessionPatientDto })
|
|
37
|
+
patient?: AnamnesisTokenSessionPatientDto;
|
|
38
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { ApiProperty } from '@nestjs/swagger';
|
|
2
|
+
import { IsNotEmpty, IsObject, IsString, MinLength } from 'class-validator';
|
|
3
|
+
|
|
4
|
+
export class CreateAnamnesisByTokenDto {
|
|
5
|
+
@ApiProperty({
|
|
6
|
+
description: 'Token único de acesso à página de anamnese',
|
|
7
|
+
example: 'a5f8b3f1...',
|
|
8
|
+
})
|
|
9
|
+
@IsString()
|
|
10
|
+
@MinLength(16)
|
|
11
|
+
token: string;
|
|
12
|
+
|
|
13
|
+
@ApiProperty({
|
|
14
|
+
description: 'Respostas estruturadas do formulário de anamnese',
|
|
15
|
+
type: Object,
|
|
16
|
+
example: {
|
|
17
|
+
hasAllergy: true,
|
|
18
|
+
allergyDescription: 'Dipirona',
|
|
19
|
+
medications: ['Omeprazol'],
|
|
20
|
+
},
|
|
21
|
+
})
|
|
22
|
+
@IsObject()
|
|
23
|
+
@IsNotEmpty()
|
|
24
|
+
answersJson: Record<string, unknown>;
|
|
25
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';
|
|
2
|
+
|
|
3
|
+
export class PatientAnamnesisDto {
|
|
4
|
+
@ApiProperty({ example: '550e8400-e29b-41d4-a716-446655440010' })
|
|
5
|
+
id: string;
|
|
6
|
+
|
|
7
|
+
@ApiProperty({ example: '550e8400-e29b-41d4-a716-446655440000' })
|
|
8
|
+
patientId: string;
|
|
9
|
+
|
|
10
|
+
@ApiPropertyOptional({ example: '550e8400-e29b-41d4-a716-446655440111', nullable: true })
|
|
11
|
+
appointmentId: string | null;
|
|
12
|
+
|
|
13
|
+
@ApiProperty({ example: '2026-04-14T10:00:00.000Z' })
|
|
14
|
+
startDate: string;
|
|
15
|
+
|
|
16
|
+
@ApiProperty({ example: '2026-10-14T10:00:00.000Z' })
|
|
17
|
+
endDate: string;
|
|
18
|
+
|
|
19
|
+
@ApiProperty({ type: Object })
|
|
20
|
+
answersJson: Record<string, unknown>;
|
|
21
|
+
|
|
22
|
+
@ApiProperty({ example: '2026-04-14T10:00:10.000Z' })
|
|
23
|
+
createdAt: string;
|
|
24
|
+
}
|
|
@@ -40,6 +40,9 @@ export class PlanSummaryDto {
|
|
|
40
40
|
@ApiProperty({ description: 'Max procedures', example: 200 })
|
|
41
41
|
maxProcedures: number;
|
|
42
42
|
|
|
43
|
+
@ApiProperty({ description: 'Monthly AI token allowance', example: 5000 })
|
|
44
|
+
monthlyAiTokens: number;
|
|
45
|
+
|
|
43
46
|
@ApiPropertyOptional()
|
|
44
47
|
createdAt?: Date;
|
|
45
48
|
|
|
@@ -110,6 +110,11 @@ export class AppointmentChangedEventPayload {
|
|
|
110
110
|
@IsISO8601()
|
|
111
111
|
exitTime?: string;
|
|
112
112
|
|
|
113
|
+
@ApiProperty({ required: false, example: true })
|
|
114
|
+
@IsOptional()
|
|
115
|
+
@IsBoolean()
|
|
116
|
+
checkinCompleted?: boolean;
|
|
117
|
+
|
|
113
118
|
@ApiProperty({ example: '2026-03-30T12:03:14.000Z' })
|
|
114
119
|
@IsISO8601()
|
|
115
120
|
occurredAt: string;
|
package/src/index.ts
CHANGED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { ApiProperty } from '@nestjs/swagger';
|
|
2
|
+
import { IsIn, IsInt, IsNotEmpty, IsOptional, IsString, Min } from 'class-validator';
|
|
3
|
+
import { TenantAiTokenStateDto } from './tenant-ai-token-state.dto';
|
|
4
|
+
|
|
5
|
+
export const TENANT_AI_TOKEN_CONSUMPTION_SOURCES = ['ai.request', 'ai.followup.generate'] as const;
|
|
6
|
+
export type TenantAiTokenConsumptionSourceDto =
|
|
7
|
+
(typeof TENANT_AI_TOKEN_CONSUMPTION_SOURCES)[number];
|
|
8
|
+
|
|
9
|
+
export class ConsumeTenantAiTokensDto {
|
|
10
|
+
@ApiProperty({ description: 'Tenant slug', example: 'clinic-alpha' })
|
|
11
|
+
@IsString()
|
|
12
|
+
@IsNotEmpty()
|
|
13
|
+
tenant: string;
|
|
14
|
+
|
|
15
|
+
@ApiProperty({ description: 'Tokens to consume', example: 420 })
|
|
16
|
+
@IsInt()
|
|
17
|
+
@Min(0)
|
|
18
|
+
tokens: number;
|
|
19
|
+
|
|
20
|
+
@ApiProperty({
|
|
21
|
+
description: 'Deterministic source of consumption',
|
|
22
|
+
enum: TENANT_AI_TOKEN_CONSUMPTION_SOURCES,
|
|
23
|
+
})
|
|
24
|
+
@IsIn(TENANT_AI_TOKEN_CONSUMPTION_SOURCES)
|
|
25
|
+
source: TenantAiTokenConsumptionSourceDto;
|
|
26
|
+
|
|
27
|
+
@ApiProperty({ description: 'Optional operation correlation id', required: false })
|
|
28
|
+
@IsOptional()
|
|
29
|
+
@IsString()
|
|
30
|
+
correlationId?: string;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export class ConsumeTenantAiTokensResponseDto extends TenantAiTokenStateDto {
|
|
34
|
+
@ApiProperty({ description: 'How many tokens were actually consumed', example: 420 })
|
|
35
|
+
@IsInt()
|
|
36
|
+
@Min(0)
|
|
37
|
+
consumed: number;
|
|
38
|
+
|
|
39
|
+
@ApiProperty({ description: 'True when the balance reached zero in this operation', example: false })
|
|
40
|
+
becameZero: boolean;
|
|
41
|
+
}
|
package/src/tenants/index.ts
CHANGED
|
@@ -3,3 +3,7 @@ export * from './get-tenant-by-address.query.dto';
|
|
|
3
3
|
export * from './tenant-public-by-address-response.dto';
|
|
4
4
|
export * from './whatsapp-provider-kind.dto';
|
|
5
5
|
export * from './tenant-slug.util';
|
|
6
|
+
export * from './tenant-ai-token-state.dto';
|
|
7
|
+
export * from './consume-tenant-ai-tokens.dto';
|
|
8
|
+
export * from './recharge-tenant-ai-tokens.dto';
|
|
9
|
+
export * from './renew-tenant-ai-tokens.dto';
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';
|
|
2
|
+
import { IsInt, IsNotEmpty, IsOptional, IsString, Min } from 'class-validator';
|
|
3
|
+
import { TenantAiTokenStateDto } from './tenant-ai-token-state.dto';
|
|
4
|
+
|
|
5
|
+
export class RechargeTenantAiTokensDto {
|
|
6
|
+
@ApiProperty({ description: 'Tenant id (UUID)', example: 'a1b2c3d4-e5f6-7890-abcd-ef1234567890' })
|
|
7
|
+
@IsString()
|
|
8
|
+
@IsNotEmpty()
|
|
9
|
+
tenantId: string;
|
|
10
|
+
|
|
11
|
+
@ApiProperty({ description: 'Amount of tokens to add', example: 10000 })
|
|
12
|
+
@IsInt()
|
|
13
|
+
@Min(1)
|
|
14
|
+
amount: number;
|
|
15
|
+
|
|
16
|
+
@ApiPropertyOptional({ description: 'Free text reason for audit', example: 'Recarga manual realizada pelo financeiro' })
|
|
17
|
+
@IsOptional()
|
|
18
|
+
@IsString()
|
|
19
|
+
reason?: string;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export class RechargeTenantAiTokensResponseDto extends TenantAiTokenStateDto {
|
|
23
|
+
@ApiProperty({ description: 'Recharge amount applied', example: 10000 })
|
|
24
|
+
@IsInt()
|
|
25
|
+
@Min(1)
|
|
26
|
+
added: number;
|
|
27
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { ApiPropertyOptional } from '@nestjs/swagger';
|
|
2
|
+
import { IsInt, IsOptional, IsString, Min } from 'class-validator';
|
|
3
|
+
|
|
4
|
+
export class RenewTenantAiTokensDto {
|
|
5
|
+
@ApiPropertyOptional({ description: 'Optional tenant id to renew one tenant only' })
|
|
6
|
+
@IsOptional()
|
|
7
|
+
@IsString()
|
|
8
|
+
tenantId?: string;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export class RenewTenantAiTokensResponseDto {
|
|
12
|
+
@ApiPropertyOptional({ description: 'How many tenants were renewed', example: 12 })
|
|
13
|
+
@IsInt()
|
|
14
|
+
@Min(0)
|
|
15
|
+
renewedCount: number;
|
|
16
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { ApiProperty } from '@nestjs/swagger';
|
|
2
|
+
import { IsBoolean, IsDateString, IsInt, IsNotEmpty, IsOptional, IsString, Min } from 'class-validator';
|
|
3
|
+
|
|
4
|
+
export class TenantAiTokenStateDto {
|
|
5
|
+
@ApiProperty({ description: 'Tenant slug', example: 'clinic-alpha' })
|
|
6
|
+
@IsString()
|
|
7
|
+
@IsNotEmpty()
|
|
8
|
+
tenant: string;
|
|
9
|
+
|
|
10
|
+
@ApiProperty({ description: 'Current remaining AI tokens', example: 2400 })
|
|
11
|
+
@IsInt()
|
|
12
|
+
@Min(0)
|
|
13
|
+
currentBalance: number;
|
|
14
|
+
|
|
15
|
+
@ApiProperty({ description: 'Monthly allowance configured for current cycle', example: 5000 })
|
|
16
|
+
@IsInt()
|
|
17
|
+
@Min(0)
|
|
18
|
+
monthlyAllowance: number;
|
|
19
|
+
|
|
20
|
+
@ApiProperty({ description: 'Whether IA is blocked for this tenant', example: false })
|
|
21
|
+
@IsBoolean()
|
|
22
|
+
blocked: boolean;
|
|
23
|
+
|
|
24
|
+
@ApiProperty({ description: 'Current cycle start timestamp', example: '2026-04-01T00:00:00.000Z' })
|
|
25
|
+
@IsDateString()
|
|
26
|
+
cycleStartedAt: string;
|
|
27
|
+
|
|
28
|
+
@ApiProperty({ description: 'Next monthly renewal timestamp', example: '2026-05-01T00:00:00.000Z' })
|
|
29
|
+
@IsDateString()
|
|
30
|
+
nextRenewalAt: string;
|
|
31
|
+
|
|
32
|
+
@ApiProperty({ description: 'Plan recurrence in days used for renewal', example: 30 })
|
|
33
|
+
@IsInt()
|
|
34
|
+
@Min(1)
|
|
35
|
+
recurrenceDays: number;
|
|
36
|
+
|
|
37
|
+
@ApiProperty({ description: 'True when balance is currently greater than zero', example: true })
|
|
38
|
+
@IsBoolean()
|
|
39
|
+
canUseAi: boolean;
|
|
40
|
+
|
|
41
|
+
@ApiProperty({ description: 'Last consumption timestamp', required: false })
|
|
42
|
+
@IsOptional()
|
|
43
|
+
@IsDateString()
|
|
44
|
+
lastConsumedAt?: string;
|
|
45
|
+
|
|
46
|
+
@ApiProperty({ description: 'Last recharge timestamp', required: false })
|
|
47
|
+
@IsOptional()
|
|
48
|
+
@IsDateString()
|
|
49
|
+
lastRechargedAt?: string;
|
|
50
|
+
}
|