@chanl/scorecards-core 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (130) hide show
  1. package/LICENSE +21 -0
  2. package/dist/dto/create-scorecard-category.dto.d.ts +7 -0
  3. package/dist/dto/create-scorecard-category.dto.d.ts.map +1 -0
  4. package/dist/dto/create-scorecard-category.dto.js +38 -0
  5. package/dist/dto/create-scorecard-category.dto.js.map +1 -0
  6. package/dist/dto/create-scorecard-criteria.dto.d.ts +11 -0
  7. package/dist/dto/create-scorecard-criteria.dto.d.ts.map +1 -0
  8. package/dist/dto/create-scorecard-criteria.dto.js +63 -0
  9. package/dist/dto/create-scorecard-criteria.dto.js.map +1 -0
  10. package/dist/dto/create-scorecard-result.dto.d.ts +8 -0
  11. package/dist/dto/create-scorecard-result.dto.d.ts.map +1 -0
  12. package/dist/dto/create-scorecard-result.dto.js +41 -0
  13. package/dist/dto/create-scorecard-result.dto.js.map +1 -0
  14. package/dist/dto/create-scorecard.dto.d.ts +9 -0
  15. package/dist/dto/create-scorecard.dto.d.ts.map +1 -0
  16. package/dist/dto/create-scorecard.dto.js +54 -0
  17. package/dist/dto/create-scorecard.dto.js.map +1 -0
  18. package/dist/dto/index.d.ts +8 -0
  19. package/dist/dto/index.d.ts.map +1 -0
  20. package/dist/dto/index.js +18 -0
  21. package/dist/dto/index.js.map +1 -0
  22. package/dist/dto/update-scorecard-category.dto.d.ts +6 -0
  23. package/dist/dto/update-scorecard-category.dto.d.ts.map +1 -0
  24. package/dist/dto/update-scorecard-category.dto.js +9 -0
  25. package/dist/dto/update-scorecard-category.dto.js.map +1 -0
  26. package/dist/dto/update-scorecard-criteria.dto.d.ts +6 -0
  27. package/dist/dto/update-scorecard-criteria.dto.d.ts.map +1 -0
  28. package/dist/dto/update-scorecard-criteria.dto.js +9 -0
  29. package/dist/dto/update-scorecard-criteria.dto.js.map +1 -0
  30. package/dist/dto/update-scorecard.dto.d.ts +6 -0
  31. package/dist/dto/update-scorecard.dto.d.ts.map +1 -0
  32. package/dist/dto/update-scorecard.dto.js +9 -0
  33. package/dist/dto/update-scorecard.dto.js.map +1 -0
  34. package/dist/evaluation/evaluation.service.d.ts +35 -0
  35. package/dist/evaluation/evaluation.service.d.ts.map +1 -0
  36. package/dist/evaluation/evaluation.service.js +225 -0
  37. package/dist/evaluation/evaluation.service.js.map +1 -0
  38. package/dist/evaluation/index.d.ts +2 -0
  39. package/dist/evaluation/index.d.ts.map +1 -0
  40. package/dist/evaluation/index.js +6 -0
  41. package/dist/evaluation/index.js.map +1 -0
  42. package/dist/handlers/conversation-completeness.handler.d.ts +7 -0
  43. package/dist/handlers/conversation-completeness.handler.d.ts.map +1 -0
  44. package/dist/handlers/conversation-completeness.handler.js +74 -0
  45. package/dist/handlers/conversation-completeness.handler.js.map +1 -0
  46. package/dist/handlers/criteria-handler-registry.d.ts +12 -0
  47. package/dist/handlers/criteria-handler-registry.d.ts.map +1 -0
  48. package/dist/handlers/criteria-handler-registry.js +45 -0
  49. package/dist/handlers/criteria-handler-registry.js.map +1 -0
  50. package/dist/handlers/criteria-handler.interface.d.ts +81 -0
  51. package/dist/handlers/criteria-handler.interface.d.ts.map +1 -0
  52. package/dist/handlers/criteria-handler.interface.js +3 -0
  53. package/dist/handlers/criteria-handler.interface.js.map +1 -0
  54. package/dist/handlers/hallucination.handler.d.ts +7 -0
  55. package/dist/handlers/hallucination.handler.d.ts.map +1 -0
  56. package/dist/handlers/hallucination.handler.js +86 -0
  57. package/dist/handlers/hallucination.handler.js.map +1 -0
  58. package/dist/handlers/index.d.ts +13 -0
  59. package/dist/handlers/index.d.ts.map +1 -0
  60. package/dist/handlers/index.js +29 -0
  61. package/dist/handlers/index.js.map +1 -0
  62. package/dist/handlers/keyword.handler.d.ts +7 -0
  63. package/dist/handlers/keyword.handler.d.ts.map +1 -0
  64. package/dist/handlers/keyword.handler.js +64 -0
  65. package/dist/handlers/keyword.handler.js.map +1 -0
  66. package/dist/handlers/knowledge-retention.handler.d.ts +7 -0
  67. package/dist/handlers/knowledge-retention.handler.d.ts.map +1 -0
  68. package/dist/handlers/knowledge-retention.handler.js +74 -0
  69. package/dist/handlers/knowledge-retention.handler.js.map +1 -0
  70. package/dist/handlers/prompt.handler.d.ts +7 -0
  71. package/dist/handlers/prompt.handler.d.ts.map +1 -0
  72. package/dist/handlers/prompt.handler.js +77 -0
  73. package/dist/handlers/prompt.handler.js.map +1 -0
  74. package/dist/handlers/rag-faithfulness.handler.d.ts +7 -0
  75. package/dist/handlers/rag-faithfulness.handler.d.ts.map +1 -0
  76. package/dist/handlers/rag-faithfulness.handler.js +110 -0
  77. package/dist/handlers/rag-faithfulness.handler.js.map +1 -0
  78. package/dist/handlers/response-time.handler.d.ts +7 -0
  79. package/dist/handlers/response-time.handler.d.ts.map +1 -0
  80. package/dist/handlers/response-time.handler.js +56 -0
  81. package/dist/handlers/response-time.handler.js.map +1 -0
  82. package/dist/handlers/role-adherence.handler.d.ts +7 -0
  83. package/dist/handlers/role-adherence.handler.d.ts.map +1 -0
  84. package/dist/handlers/role-adherence.handler.js +74 -0
  85. package/dist/handlers/role-adherence.handler.js.map +1 -0
  86. package/dist/handlers/scoring-utils.d.ts +10 -0
  87. package/dist/handlers/scoring-utils.d.ts.map +1 -0
  88. package/dist/handlers/scoring-utils.js +88 -0
  89. package/dist/handlers/scoring-utils.js.map +1 -0
  90. package/dist/handlers/tool-call.handler.d.ts +7 -0
  91. package/dist/handlers/tool-call.handler.d.ts.map +1 -0
  92. package/dist/handlers/tool-call.handler.js +43 -0
  93. package/dist/handlers/tool-call.handler.js.map +1 -0
  94. package/dist/index.d.ts +8 -0
  95. package/dist/index.d.ts.map +1 -0
  96. package/dist/index.js +52 -0
  97. package/dist/index.js.map +1 -0
  98. package/dist/schemas/index.d.ts +5 -0
  99. package/dist/schemas/index.d.ts.map +1 -0
  100. package/dist/schemas/index.js +23 -0
  101. package/dist/schemas/index.js.map +1 -0
  102. package/dist/schemas/scorecard-category.schema.d.ts +20 -0
  103. package/dist/schemas/scorecard-category.schema.d.ts.map +1 -0
  104. package/dist/schemas/scorecard-category.schema.js +83 -0
  105. package/dist/schemas/scorecard-category.schema.js.map +1 -0
  106. package/dist/schemas/scorecard-criteria.schema.d.ts +92 -0
  107. package/dist/schemas/scorecard-criteria.schema.d.ts.map +1 -0
  108. package/dist/schemas/scorecard-criteria.schema.js +153 -0
  109. package/dist/schemas/scorecard-criteria.schema.js.map +1 -0
  110. package/dist/schemas/scorecard-result.schema.d.ts +47 -0
  111. package/dist/schemas/scorecard-result.schema.d.ts.map +1 -0
  112. package/dist/schemas/scorecard-result.schema.js +96 -0
  113. package/dist/schemas/scorecard-result.schema.js.map +1 -0
  114. package/dist/schemas/scorecard.schema.d.ts +21 -0
  115. package/dist/schemas/scorecard.schema.d.ts.map +1 -0
  116. package/dist/schemas/scorecard.schema.js +90 -0
  117. package/dist/schemas/scorecard.schema.js.map +1 -0
  118. package/dist/scorecards.controller.d.ts +104 -0
  119. package/dist/scorecards.controller.d.ts.map +1 -0
  120. package/dist/scorecards.controller.js +366 -0
  121. package/dist/scorecards.controller.js.map +1 -0
  122. package/dist/scorecards.module.d.ts +3 -0
  123. package/dist/scorecards.module.d.ts.map +1 -0
  124. package/dist/scorecards.module.js +59 -0
  125. package/dist/scorecards.module.js.map +1 -0
  126. package/dist/scorecards.service.d.ts +89 -0
  127. package/dist/scorecards.service.d.ts.map +1 -0
  128. package/dist/scorecards.service.js +587 -0
  129. package/dist/scorecards.service.js.map +1 -0
  130. package/package.json +39 -0
@@ -0,0 +1,587 @@
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
+ var __param = (this && this.__param) || function (paramIndex, decorator) {
12
+ return function (target, key) { decorator(target, key, paramIndex); }
13
+ };
14
+ var ScorecardsService_1;
15
+ Object.defineProperty(exports, "__esModule", { value: true });
16
+ exports.ScorecardsService = void 0;
17
+ const common_1 = require("@nestjs/common");
18
+ const mongoose_1 = require("@nestjs/mongoose");
19
+ const mongoose_2 = require("mongoose");
20
+ const scorecard_schema_1 = require("./schemas/scorecard.schema");
21
+ const scorecard_category_schema_1 = require("./schemas/scorecard-category.schema");
22
+ const scorecard_criteria_schema_1 = require("./schemas/scorecard-criteria.schema");
23
+ const scorecard_result_schema_1 = require("./schemas/scorecard-result.schema");
24
+ let ScorecardsService = ScorecardsService_1 = class ScorecardsService {
25
+ constructor(scorecardModel, categoryModel, criteriaModel, resultModel) {
26
+ this.scorecardModel = scorecardModel;
27
+ this.categoryModel = categoryModel;
28
+ this.criteriaModel = criteriaModel;
29
+ this.resultModel = resultModel;
30
+ this.logger = new common_1.Logger(ScorecardsService_1.name);
31
+ }
32
+ // ============================================================================
33
+ // SCORECARD CRUD
34
+ // ============================================================================
35
+ async createScorecard(dto) {
36
+ const scorecard = new this.scorecardModel({
37
+ ...dto,
38
+ categoryIds: [],
39
+ });
40
+ const saved = await scorecard.save();
41
+ this.logger.log(`Created scorecard ${saved._id}`);
42
+ return saved;
43
+ }
44
+ async findAllScorecards(options = {}) {
45
+ const filter = {};
46
+ if (options.status) {
47
+ filter.status = options.status;
48
+ }
49
+ if (options.tags && options.tags.length > 0) {
50
+ filter.tags = { $in: options.tags };
51
+ }
52
+ if (options.search) {
53
+ filter.$or = [
54
+ { name: { $regex: options.search, $options: 'i' } },
55
+ { description: { $regex: options.search, $options: 'i' } },
56
+ ];
57
+ }
58
+ const page = options.page || 1;
59
+ const limit = options.limit || 20;
60
+ const skip = (page - 1) * limit;
61
+ const sortOrder = options.sortOrder === 'asc' ? 1 : -1;
62
+ const sortBy = options.sortBy || 'createdAt';
63
+ const [data, total] = await Promise.all([
64
+ this.scorecardModel
65
+ .find(filter)
66
+ .sort({ [sortBy]: sortOrder })
67
+ .skip(skip)
68
+ .limit(limit)
69
+ .exec(),
70
+ this.scorecardModel.countDocuments(filter),
71
+ ]);
72
+ const totalPages = Math.ceil(total / limit);
73
+ return {
74
+ data,
75
+ pagination: {
76
+ page,
77
+ limit,
78
+ total,
79
+ totalPages,
80
+ hasNextPage: page < totalPages,
81
+ hasPrevPage: page > 1,
82
+ },
83
+ };
84
+ }
85
+ async findScorecardById(scorecardId) {
86
+ return this.scorecardModel.findById(scorecardId);
87
+ }
88
+ async updateScorecard(scorecardId, dto) {
89
+ return this.scorecardModel.findByIdAndUpdate(scorecardId, { $set: dto }, { new: true });
90
+ }
91
+ async deleteScorecard(scorecardId) {
92
+ const result = await this.scorecardModel.deleteOne({
93
+ _id: new mongoose_2.Types.ObjectId(scorecardId),
94
+ });
95
+ if (result.deletedCount === 0) {
96
+ return false;
97
+ }
98
+ // Cascade delete related categories and criteria
99
+ await Promise.all([
100
+ this.categoryModel.deleteMany({ scorecardId: new mongoose_2.Types.ObjectId(scorecardId) }),
101
+ this.criteriaModel.deleteMany({ scorecardId: new mongoose_2.Types.ObjectId(scorecardId) }),
102
+ ]);
103
+ this.logger.log(`Deleted scorecard ${scorecardId} and related data`);
104
+ return true;
105
+ }
106
+ // ============================================================================
107
+ // CATEGORY CRUD
108
+ // ============================================================================
109
+ async createCategory(scorecardId, dto) {
110
+ // Verify scorecard exists
111
+ const scorecard = await this.findScorecardById(scorecardId);
112
+ if (!scorecard) {
113
+ throw new common_1.NotFoundException(`Scorecard ${scorecardId} not found`);
114
+ }
115
+ const category = new this.categoryModel({
116
+ ...dto,
117
+ scorecardId: new mongoose_2.Types.ObjectId(scorecardId),
118
+ criteriaIds: [],
119
+ version: 1,
120
+ });
121
+ const saved = await category.save();
122
+ // Add category to scorecard's categoryIds
123
+ await this.scorecardModel.findByIdAndUpdate(scorecardId, {
124
+ $push: { categoryIds: saved._id },
125
+ });
126
+ this.logger.log(`Created category ${saved._id} for scorecard ${scorecardId}`);
127
+ return saved;
128
+ }
129
+ async findCategoriesByScorecard(scorecardId) {
130
+ // Verify scorecard exists
131
+ const scorecard = await this.findScorecardById(scorecardId);
132
+ if (!scorecard) {
133
+ throw new common_1.NotFoundException(`Scorecard ${scorecardId} not found`);
134
+ }
135
+ return this.categoryModel
136
+ .find({ scorecardId: new mongoose_2.Types.ObjectId(scorecardId) })
137
+ .sort({ order: 1 })
138
+ .exec();
139
+ }
140
+ async findCategoryById(categoryId) {
141
+ return this.categoryModel.findById(categoryId);
142
+ }
143
+ async updateCategory(categoryId, dto) {
144
+ const category = await this.findCategoryById(categoryId);
145
+ if (!category) {
146
+ return null;
147
+ }
148
+ return this.categoryModel.findByIdAndUpdate(categoryId, { $set: { ...dto, version: category.version + 1 } }, { new: true });
149
+ }
150
+ async deleteCategory(categoryId) {
151
+ const category = await this.findCategoryById(categoryId);
152
+ if (!category) {
153
+ return false;
154
+ }
155
+ // Remove from scorecard's categoryIds
156
+ await this.scorecardModel.findByIdAndUpdate(category.scorecardId, {
157
+ $pull: { categoryIds: new mongoose_2.Types.ObjectId(categoryId) },
158
+ });
159
+ // Delete category and its criteria
160
+ await Promise.all([
161
+ this.categoryModel.deleteOne({ _id: new mongoose_2.Types.ObjectId(categoryId) }),
162
+ this.criteriaModel.deleteMany({ categoryId: new mongoose_2.Types.ObjectId(categoryId) }),
163
+ ]);
164
+ this.logger.log(`Deleted category ${categoryId} and related criteria`);
165
+ return true;
166
+ }
167
+ // ============================================================================
168
+ // CRITERIA CRUD
169
+ // ============================================================================
170
+ async createCriteria(scorecardId, categoryId, dto) {
171
+ // Verify scorecard exists
172
+ const scorecard = await this.findScorecardById(scorecardId);
173
+ if (!scorecard) {
174
+ throw new common_1.NotFoundException(`Scorecard ${scorecardId} not found`);
175
+ }
176
+ // Verify category exists
177
+ const category = await this.findCategoryById(categoryId);
178
+ if (!category) {
179
+ throw new common_1.NotFoundException(`Category ${categoryId} not found`);
180
+ }
181
+ // Auto-generate key if not provided
182
+ const key = dto.key || this.generateKey(dto.name);
183
+ const criteria = new this.criteriaModel({
184
+ ...dto,
185
+ key,
186
+ scorecardId: new mongoose_2.Types.ObjectId(scorecardId),
187
+ categoryId: new mongoose_2.Types.ObjectId(categoryId),
188
+ version: 1,
189
+ isActive: dto.isActive ?? true,
190
+ });
191
+ const saved = await criteria.save();
192
+ // Add criteria to category's criteriaIds
193
+ await this.categoryModel.findByIdAndUpdate(categoryId, {
194
+ $push: { criteriaIds: saved._id },
195
+ });
196
+ this.logger.log(`Created criteria ${saved._id} for category ${categoryId}`);
197
+ return saved;
198
+ }
199
+ async findCriteriaByCategory(categoryId) {
200
+ // Verify category exists
201
+ const category = await this.findCategoryById(categoryId);
202
+ if (!category) {
203
+ throw new common_1.NotFoundException(`Category ${categoryId} not found`);
204
+ }
205
+ return this.criteriaModel
206
+ .find({ categoryId: new mongoose_2.Types.ObjectId(categoryId), isActive: true })
207
+ .sort({ order: 1 })
208
+ .exec();
209
+ }
210
+ async findCriteriaByScorecard(scorecardId) {
211
+ // Verify scorecard exists
212
+ const scorecard = await this.findScorecardById(scorecardId);
213
+ if (!scorecard) {
214
+ throw new common_1.NotFoundException(`Scorecard ${scorecardId} not found`);
215
+ }
216
+ return this.criteriaModel
217
+ .find({ scorecardId: new mongoose_2.Types.ObjectId(scorecardId), isActive: true })
218
+ .sort({ order: 1 })
219
+ .exec();
220
+ }
221
+ async findCriteriaById(criteriaId) {
222
+ return this.criteriaModel.findById(criteriaId);
223
+ }
224
+ async updateCriteria(criteriaId, dto) {
225
+ const criteria = await this.findCriteriaById(criteriaId);
226
+ if (!criteria) {
227
+ return null;
228
+ }
229
+ return this.criteriaModel.findByIdAndUpdate(criteriaId, { $set: { ...dto, version: criteria.version + 1 } }, { new: true });
230
+ }
231
+ async deleteCriteria(criteriaId) {
232
+ const criteria = await this.findCriteriaById(criteriaId);
233
+ if (!criteria) {
234
+ return false;
235
+ }
236
+ // Remove from category's criteriaIds
237
+ await this.categoryModel.findByIdAndUpdate(criteria.categoryId, {
238
+ $pull: { criteriaIds: new mongoose_2.Types.ObjectId(criteriaId) },
239
+ });
240
+ // Delete criteria
241
+ await this.criteriaModel.deleteOne({
242
+ _id: new mongoose_2.Types.ObjectId(criteriaId),
243
+ });
244
+ this.logger.log(`Deleted criteria ${criteriaId}`);
245
+ return true;
246
+ }
247
+ // ============================================================================
248
+ // RESULT CRUD
249
+ // ============================================================================
250
+ async createResult(dto) {
251
+ // Verify scorecard exists
252
+ const scorecard = await this.findScorecardById(dto.scorecardId);
253
+ if (!scorecard) {
254
+ throw new common_1.NotFoundException(`Scorecard ${dto.scorecardId} not found`);
255
+ }
256
+ const result = new this.resultModel({
257
+ ...dto,
258
+ scorecardId: new mongoose_2.Types.ObjectId(dto.scorecardId),
259
+ });
260
+ const saved = await result.save();
261
+ this.logger.log(`Created scorecard result ${saved._id} for scorecard ${dto.scorecardId}`);
262
+ return saved;
263
+ }
264
+ async findAllResults(options = {}) {
265
+ const filter = {};
266
+ if (options.scorecardId) {
267
+ filter.scorecardId = new mongoose_2.Types.ObjectId(options.scorecardId);
268
+ }
269
+ if (options.status) {
270
+ filter.status = options.status;
271
+ }
272
+ const page = options.page || 1;
273
+ const limit = options.limit || 20;
274
+ const skip = (page - 1) * limit;
275
+ const sortOrder = options.sortOrder === 'asc' ? 1 : -1;
276
+ const sortBy = options.sortBy || 'createdAt';
277
+ const [data, total] = await Promise.all([
278
+ this.resultModel
279
+ .find(filter)
280
+ .sort({ [sortBy]: sortOrder })
281
+ .skip(skip)
282
+ .limit(limit)
283
+ .exec(),
284
+ this.resultModel.countDocuments(filter),
285
+ ]);
286
+ const totalPages = Math.ceil(total / limit);
287
+ return {
288
+ data,
289
+ pagination: {
290
+ page,
291
+ limit,
292
+ total,
293
+ totalPages,
294
+ hasNextPage: page < totalPages,
295
+ hasPrevPage: page > 1,
296
+ },
297
+ };
298
+ }
299
+ async findResultById(resultId) {
300
+ return this.resultModel.findById(resultId);
301
+ }
302
+ async findResultsByCall(callId) {
303
+ return this.resultModel.find({ callId });
304
+ }
305
+ async findResultsByExecution(executionId) {
306
+ // Accepts both MongoDB _id and scenarioExecutionId (exec_uuid)
307
+ return this.resultModel.find({ scenarioExecutionId: executionId });
308
+ }
309
+ async deleteResult(resultId) {
310
+ const result = await this.resultModel.deleteOne({
311
+ _id: new mongoose_2.Types.ObjectId(resultId),
312
+ });
313
+ return result.deletedCount > 0;
314
+ }
315
+ // ============================================================================
316
+ // DEFAULT SCORECARD
317
+ // ============================================================================
318
+ /**
319
+ * Get the default scorecard.
320
+ * Resolution: Most recently created active scorecard.
321
+ * Returns null if no active scorecards exist.
322
+ */
323
+ async getDefault() {
324
+ const scorecard = await this.scorecardModel
325
+ .findOne({ status: 'active' })
326
+ .sort({ createdAt: -1 })
327
+ .exec();
328
+ if (!scorecard) {
329
+ return null;
330
+ }
331
+ return {
332
+ scorecard,
333
+ source: 'most_recent',
334
+ };
335
+ }
336
+ /**
337
+ * Create a default scorecard if none exists.
338
+ * Used to ensure at least one scorecard exists for evaluation.
339
+ */
340
+ async createDefaultScorecardIfNeeded() {
341
+ try {
342
+ // Check if an active scorecard already exists
343
+ const existing = await this.scorecardModel.findOne({ status: 'active' }).exec();
344
+ if (existing) {
345
+ this.logger.log(`Default scorecard already exists: ${existing._id}`);
346
+ return existing._id;
347
+ }
348
+ // Get default scorecard data structure
349
+ const defaultData = this.getDefaultScorecardData();
350
+ // Create the scorecard
351
+ const createdScorecard = await this.createScorecard({
352
+ name: defaultData.name,
353
+ description: defaultData.description,
354
+ status: defaultData.status,
355
+ });
356
+ const scorecardId = createdScorecard._id;
357
+ if (!scorecardId) {
358
+ throw new Error('Failed to extract scorecard ID after creation');
359
+ }
360
+ const scorecardObjectId = typeof scorecardId === 'string'
361
+ ? new mongoose_2.Types.ObjectId(scorecardId)
362
+ : scorecardId;
363
+ // Create categories and criteria
364
+ for (const categoryData of defaultData.categories) {
365
+ const category = await this.createCategory(scorecardObjectId.toString(), {
366
+ name: categoryData.name,
367
+ description: categoryData.description,
368
+ weight: categoryData.weight,
369
+ });
370
+ const categoryIdStr = category._id?.toString() || '';
371
+ for (const criteriaData of categoryData.criteria) {
372
+ await this.createCriteria(scorecardObjectId.toString(), categoryIdStr, {
373
+ categoryId: categoryIdStr,
374
+ key: criteriaData.key,
375
+ name: criteriaData.name,
376
+ type: criteriaData.type,
377
+ settings: criteriaData.settings,
378
+ threshold: criteriaData.threshold,
379
+ });
380
+ }
381
+ }
382
+ this.logger.log(`Created default scorecard ${scorecardObjectId}`);
383
+ return scorecardObjectId;
384
+ }
385
+ catch (error) {
386
+ this.logger.error(`Failed to create default scorecard: ${error.message}`, error.stack);
387
+ return null;
388
+ }
389
+ }
390
+ /**
391
+ * Get default scorecard data structure.
392
+ * Creates a comprehensive scorecard with 5 categories covering all aspects of call quality.
393
+ */
394
+ getDefaultScorecardData() {
395
+ return {
396
+ name: 'Call Quality Scorecard',
397
+ description: 'Comprehensive call quality evaluation with communication, problem-solving, and timing metrics',
398
+ status: 'active',
399
+ categories: [
400
+ {
401
+ name: 'Opening & Greeting',
402
+ description: 'Evaluates how the agent opens the call',
403
+ weight: 15,
404
+ criteria: [
405
+ {
406
+ key: 'proper_greeting',
407
+ name: 'Proper Greeting',
408
+ type: scorecard_criteria_schema_1.CriteriaType.PROMPT,
409
+ settings: {
410
+ description: 'Did the agent introduce themselves and greet the customer professionally?',
411
+ evaluationType: 'boolean',
412
+ },
413
+ threshold: { expectedValue: true },
414
+ },
415
+ {
416
+ key: 'greeting_keywords',
417
+ name: 'Greeting Keywords',
418
+ type: scorecard_criteria_schema_1.CriteriaType.KEYWORD,
419
+ settings: {
420
+ matchType: 'must_contain',
421
+ keyword: [
422
+ 'hello',
423
+ 'hi',
424
+ 'good morning',
425
+ 'good afternoon',
426
+ 'good evening',
427
+ 'thank you for calling',
428
+ 'how can I help',
429
+ ],
430
+ },
431
+ },
432
+ ],
433
+ },
434
+ {
435
+ name: 'Problem Resolution',
436
+ description: 'Evaluates how well the agent addresses customer issues',
437
+ weight: 35,
438
+ criteria: [
439
+ {
440
+ key: 'issue_identified',
441
+ name: 'Issue Identified',
442
+ type: scorecard_criteria_schema_1.CriteriaType.PROMPT,
443
+ settings: {
444
+ description: "Did the agent correctly identify and understand the customer's issue or request?",
445
+ evaluationType: 'boolean',
446
+ },
447
+ threshold: { expectedValue: true },
448
+ },
449
+ {
450
+ key: 'resolution_quality',
451
+ name: 'Resolution Quality',
452
+ type: scorecard_criteria_schema_1.CriteriaType.PROMPT,
453
+ settings: {
454
+ description: "Rate how effectively the agent resolved or addressed the customer's issue (0-10, where 10 is fully resolved)",
455
+ evaluationType: 'score',
456
+ },
457
+ threshold: { min: 7, max: 10 },
458
+ },
459
+ {
460
+ key: 'clear_explanation',
461
+ name: 'Clear Explanation',
462
+ type: scorecard_criteria_schema_1.CriteriaType.PROMPT,
463
+ settings: {
464
+ description: 'Did the agent provide clear and understandable explanations?',
465
+ evaluationType: 'boolean',
466
+ },
467
+ threshold: { expectedValue: true },
468
+ },
469
+ ],
470
+ },
471
+ {
472
+ name: 'Communication Quality',
473
+ description: 'Evaluates professionalism and communication style',
474
+ weight: 25,
475
+ criteria: [
476
+ {
477
+ key: 'politeness_score',
478
+ name: 'Politeness & Professionalism',
479
+ type: scorecard_criteria_schema_1.CriteriaType.PROMPT,
480
+ settings: {
481
+ description: "Rate the agent's overall politeness and professional demeanor (0-10)",
482
+ evaluationType: 'score',
483
+ },
484
+ threshold: { min: 7, max: 10 },
485
+ },
486
+ {
487
+ key: 'empathy_shown',
488
+ name: 'Empathy Demonstrated',
489
+ type: scorecard_criteria_schema_1.CriteriaType.PROMPT,
490
+ settings: {
491
+ description: "Did the agent show empathy and understanding toward the customer's situation?",
492
+ evaluationType: 'boolean',
493
+ },
494
+ threshold: { expectedValue: true },
495
+ },
496
+ {
497
+ key: 'no_inappropriate_language',
498
+ name: 'Professional Language',
499
+ type: scorecard_criteria_schema_1.CriteriaType.KEYWORD,
500
+ settings: {
501
+ matchType: 'must_not_contain',
502
+ keyword: [
503
+ 'damn',
504
+ 'hell',
505
+ 'crap',
506
+ 'stupid',
507
+ 'idiot',
508
+ 'shut up',
509
+ ],
510
+ },
511
+ },
512
+ ],
513
+ },
514
+ {
515
+ name: 'Closing & Follow-up',
516
+ description: 'Evaluates how the agent closes the call',
517
+ weight: 10,
518
+ criteria: [
519
+ {
520
+ key: 'proper_closing',
521
+ name: 'Proper Closing',
522
+ type: scorecard_criteria_schema_1.CriteriaType.PROMPT,
523
+ settings: {
524
+ description: 'Did the agent properly close the call by thanking the customer and offering further assistance?',
525
+ evaluationType: 'boolean',
526
+ },
527
+ threshold: { expectedValue: true },
528
+ },
529
+ {
530
+ key: 'closing_keywords',
531
+ name: 'Closing Keywords',
532
+ type: scorecard_criteria_schema_1.CriteriaType.KEYWORD,
533
+ settings: {
534
+ matchType: 'must_contain',
535
+ keyword: [
536
+ 'thank you',
537
+ 'thanks',
538
+ 'have a great day',
539
+ 'is there anything else',
540
+ 'goodbye',
541
+ 'bye',
542
+ ],
543
+ },
544
+ },
545
+ ],
546
+ },
547
+ {
548
+ name: 'Timing Metrics',
549
+ description: 'Evaluates response time and call efficiency',
550
+ weight: 15,
551
+ criteria: [
552
+ {
553
+ key: 'agent_response_time',
554
+ name: 'Agent Response Time',
555
+ type: scorecard_criteria_schema_1.CriteriaType.RESPONSE_TIME,
556
+ settings: { participant: 'agent' },
557
+ threshold: { max: 5 },
558
+ },
559
+ ],
560
+ },
561
+ ],
562
+ };
563
+ }
564
+ // ============================================================================
565
+ // HELPERS
566
+ // ============================================================================
567
+ generateKey(name) {
568
+ return name
569
+ .toLowerCase()
570
+ .replace(/[^a-z0-9\s]/g, '')
571
+ .replace(/\s+/g, '_')
572
+ .replace(/^[0-9]/, '_$&');
573
+ }
574
+ };
575
+ exports.ScorecardsService = ScorecardsService;
576
+ exports.ScorecardsService = ScorecardsService = ScorecardsService_1 = __decorate([
577
+ (0, common_1.Injectable)(),
578
+ __param(0, (0, mongoose_1.InjectModel)(scorecard_schema_1.Scorecard.name)),
579
+ __param(1, (0, mongoose_1.InjectModel)(scorecard_category_schema_1.ScorecardCategory.name)),
580
+ __param(2, (0, mongoose_1.InjectModel)(scorecard_criteria_schema_1.ScorecardCriteria.name)),
581
+ __param(3, (0, mongoose_1.InjectModel)(scorecard_result_schema_1.ScorecardResult.name)),
582
+ __metadata("design:paramtypes", [mongoose_2.Model,
583
+ mongoose_2.Model,
584
+ mongoose_2.Model,
585
+ mongoose_2.Model])
586
+ ], ScorecardsService);
587
+ //# sourceMappingURL=scorecards.service.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"scorecards.service.js","sourceRoot":"","sources":["../src/scorecards.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,2CAAuE;AACvE,+CAA+C;AAC/C,uCAAqD;AACrD,iEAA0E;AAC1E,mFAG6C;AAC7C,mFAI6C;AAC7C,+EAG2C;AAsBpC,IAAM,iBAAiB,yBAAvB,MAAM,iBAAiB;IAG5B,YAEE,cAAgD,EAEhD,aAAuD,EAEvD,aAAuD,EAEvD,WAAmD;QAN3C,mBAAc,GAAd,cAAc,CAA0B;QAExC,kBAAa,GAAb,aAAa,CAAkC;QAE/C,kBAAa,GAAb,aAAa,CAAkC;QAE/C,gBAAW,GAAX,WAAW,CAAgC;QAVpC,WAAM,GAAG,IAAI,eAAM,CAAC,mBAAiB,CAAC,IAAI,CAAC,CAAC;IAW1D,CAAC;IAEJ,+EAA+E;IAC/E,iBAAiB;IACjB,+EAA+E;IAE/E,KAAK,CAAC,eAAe,CACnB,GAAuB;QAEvB,MAAM,SAAS,GAAG,IAAI,IAAI,CAAC,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AC1B,IAAI,EAAE,qBAAqB;4BAC3B,IAAI,EAAE,wCAAY,CAAC,aAAa;4BAChC,QAAQ,EAAE,EAAE,WAAW,EAAE,OAAO,EAAE;4BAClC,SAAS,EAAE,EAAE,GAAG,EAAE,CAAC,EAAE;yBACtB;qBACF;iBACF;aACF;SACF,CAAC;IACJ,CAAC;IAED,+EAA+E;IAC/E,UAAU;IACV,+EAA+E;IAE/E,WAAW,CAAC,IAAY;QACtB,OAAO,IAAI;aACR,WAAW,EAAE;aACb,OAAO,CAAC,cAAc,EAAE,EAAE,CAAC;aAC3B,OAAO,CAAC,MAAM,EAAE,GAAG,CAAC;aACpB,OAAO,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC;IAC9B,CAAC;CACF,CAAA;AAxvBY,8CAAiB;4BAAjB,iBAAiB;IAD7B,IAAA,mBAAU,GAAE;IAKR,WAAA,IAAA,sBAAW,EAAC,4BAAS,CAAC,IAAI,CAAC,CAAA;IAE3B,WAAA,IAAA,sBAAW,EAAC,6CAAiB,CAAC,IAAI,CAAC,CAAA;IAEnC,WAAA,IAAA,sBAAW,EAAC,6CAAiB,CAAC,IAAI,CAAC,CAAA;IAEnC,WAAA,IAAA,sBAAW,EAAC,yCAAe,CAAC,IAAI,CAAC,CAAA;qCALV,gBAAK;QAEN,gBAAK;QAEL,gBAAK;QAEP,gBAAK;GAXjB,iBAAiB,CAwvB7B"}
package/package.json ADDED
@@ -0,0 +1,39 @@
1
+ {
2
+ "name": "@chanl/scorecards-core",
3
+ "version": "0.4.0",
4
+ "description": "Core scorecard engine: scorecards, criteria, evaluation",
5
+ "main": "dist/index.js",
6
+ "types": "dist/index.d.ts",
7
+ "files": [
8
+ "dist"
9
+ ],
10
+ "publishConfig": {
11
+ "access": "public"
12
+ },
13
+ "license": "MIT",
14
+ "dependencies": {
15
+ "@nestjs/common": "^10.0.0",
16
+ "@nestjs/core": "^10.0.0",
17
+ "@nestjs/mapped-types": "^2.0.0",
18
+ "@nestjs/mongoose": "^10.0.0",
19
+ "mongoose": "^7.0.0",
20
+ "class-validator": "^0.14.0",
21
+ "class-transformer": "^0.5.1",
22
+ "rxjs": "^7.0.0",
23
+ "reflect-metadata": "^0.1.13"
24
+ },
25
+ "devDependencies": {
26
+ "@nestjs/testing": "^10.0.0",
27
+ "@types/jest": "^29.0.0",
28
+ "jest": "^29.0.0",
29
+ "ts-jest": "^29.0.0",
30
+ "typescript": "^5.0.0",
31
+ "mongodb-memory-server": "^9.0.0"
32
+ },
33
+ "scripts": {
34
+ "build": "tsc",
35
+ "test": "jest --passWithNoTests",
36
+ "test:cov": "jest --coverage --passWithNoTests",
37
+ "clean": "rm -rf dist"
38
+ }
39
+ }