@carbonbox/domain 0.31.0 → 0.32.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/carbonbox/reporting/report-instances/domain/entity/IReportInstance.js +2 -0
- package/build/carbonbox/reporting/report-instances/domain/entity/ReportInstance.js +371 -0
- package/build/carbonbox/reporting/report-instances/domain/enums/ReportInstanceStatus.js +38 -0
- package/build/carbonbox/reporting/report-instances/domain/exceptions/ReportInstanceCannotBeApprovedByClientError.js +32 -0
- package/build/carbonbox/reporting/report-instances/domain/exceptions/ReportInstanceCannotBeApprovedInternallyError.js +32 -0
- package/build/carbonbox/reporting/report-instances/domain/exceptions/ReportInstanceCannotBeGeneratedError.js +32 -0
- package/build/carbonbox/reporting/report-instances/domain/exceptions/ReportInstanceCannotBePublishedError.js +32 -0
- package/build/carbonbox/reporting/report-instances/domain/exceptions/ReportInstanceCannotBeRejectedError.js +32 -0
- package/build/carbonbox/reporting/report-instances/domain/exceptions/ReportInstanceInvalidStatusTransitionError.js +32 -0
- package/build/carbonbox/reporting/report-instances/domain/repository/IReportInstanceRepository.js +2 -0
- package/build/carbonbox/reporting/report-instances/domain/types/ReportInstancePrimitives.js +2 -0
- package/build/carbonbox/reporting/report-instances/domain/types/ReportInstanceProps.js +2 -0
- package/build/carbonbox/reporting/report-templates/domain/entity/IReportTemplate.js +2 -0
- package/build/carbonbox/reporting/report-templates/domain/entity/ReportTemplate.js +275 -0
- package/build/carbonbox/reporting/report-templates/domain/exceptions/ReportTemplateCannotBeActivatedError.js +32 -0
- package/build/carbonbox/reporting/report-templates/domain/exceptions/ReportTemplateCannotBeDeprecatedError.js +32 -0
- package/build/carbonbox/reporting/report-templates/domain/exceptions/ReportTemplateCannotBeVersionedError.js +32 -0
- package/build/carbonbox/reporting/report-templates/domain/repository/IReportTemplateRepository.js +2 -0
- package/build/carbonbox/reporting/shared/domain/types/AIExecutionRecordPrimitives.js +2 -0
- package/build/carbonbox/reporting/shared/domain/types/ApprovalRecordPrimitives.js +2 -0
- package/build/carbonbox/reporting/shared/domain/types/QuestionnaireAnswerPrimitives.js +2 -0
- package/build/carbonbox/reporting/shared/domain/types/ReportPeriodPrimitives.js +2 -0
- package/build/carbonbox/reporting/text-banks/domain/entity/ITextBank.js +2 -0
- package/build/carbonbox/reporting/text-banks/domain/entity/TextBank.js +173 -0
- package/build/carbonbox/reporting/text-banks/domain/repository/ITextBankRepository.js +2 -0
- package/build/carbonbox/reporting/text-banks/domain/types/TextBankEntryPrimitives.js +2 -0
- package/build/carbonbox/reporting/text-banks/domain/types/TextBankEntryProps.js +2 -0
- package/build/carbonbox/reporting/text-banks/domain/types/TextBankPrimitives.js +2 -0
- package/build/carbonbox/reporting/text-banks/domain/types/TextBankProps.js +2 -0
- package/build/carbonbox/shared/domain/enums/ErrorCode.js +11 -0
- package/build/main/index.js +75 -8
- package/build/types/carbonbox/reporting/report-instances/domain/entity/IReportInstance.d.ts +36 -0
- package/build/types/carbonbox/reporting/report-instances/domain/entity/IReportInstance.d.ts.map +1 -0
- package/build/types/carbonbox/reporting/report-instances/domain/entity/ReportInstance.d.ts +59 -0
- package/build/types/carbonbox/reporting/report-instances/domain/entity/ReportInstance.d.ts.map +1 -0
- package/build/types/carbonbox/reporting/report-instances/domain/enums/ReportInstanceStatus.d.ts +35 -0
- package/build/types/carbonbox/reporting/report-instances/domain/enums/ReportInstanceStatus.d.ts.map +1 -0
- package/build/types/carbonbox/reporting/report-instances/domain/exceptions/ReportInstanceCannotBeApprovedByClientError.d.ts +7 -0
- package/build/types/carbonbox/reporting/report-instances/domain/exceptions/ReportInstanceCannotBeApprovedByClientError.d.ts.map +1 -0
- package/build/types/carbonbox/reporting/report-instances/domain/exceptions/ReportInstanceCannotBeApprovedInternallyError.d.ts +7 -0
- package/build/types/carbonbox/reporting/report-instances/domain/exceptions/ReportInstanceCannotBeApprovedInternallyError.d.ts.map +1 -0
- package/build/types/carbonbox/reporting/report-instances/domain/exceptions/ReportInstanceCannotBeGeneratedError.d.ts +7 -0
- package/build/types/carbonbox/reporting/report-instances/domain/exceptions/ReportInstanceCannotBeGeneratedError.d.ts.map +1 -0
- package/build/types/carbonbox/reporting/report-instances/domain/exceptions/ReportInstanceCannotBePublishedError.d.ts +7 -0
- package/build/types/carbonbox/reporting/report-instances/domain/exceptions/ReportInstanceCannotBePublishedError.d.ts.map +1 -0
- package/build/types/carbonbox/reporting/report-instances/domain/exceptions/ReportInstanceCannotBeRejectedError.d.ts +7 -0
- package/build/types/carbonbox/reporting/report-instances/domain/exceptions/ReportInstanceCannotBeRejectedError.d.ts.map +1 -0
- package/build/types/carbonbox/reporting/report-instances/domain/exceptions/ReportInstanceInvalidStatusTransitionError.d.ts +7 -0
- package/build/types/carbonbox/reporting/report-instances/domain/exceptions/ReportInstanceInvalidStatusTransitionError.d.ts.map +1 -0
- package/build/types/carbonbox/reporting/report-instances/domain/repository/IReportInstanceRepository.d.ts +84 -0
- package/build/types/carbonbox/reporting/report-instances/domain/repository/IReportInstanceRepository.d.ts.map +1 -0
- package/build/types/carbonbox/reporting/report-instances/domain/types/ReportInstancePrimitives.d.ts +28 -0
- package/build/types/carbonbox/reporting/report-instances/domain/types/ReportInstancePrimitives.d.ts.map +1 -0
- package/build/types/carbonbox/reporting/report-instances/domain/types/ReportInstanceProps.d.ts +28 -0
- package/build/types/carbonbox/reporting/report-instances/domain/types/ReportInstanceProps.d.ts.map +1 -0
- package/build/types/carbonbox/reporting/report-templates/domain/entity/IReportTemplate.d.ts +24 -0
- package/build/types/carbonbox/reporting/report-templates/domain/entity/IReportTemplate.d.ts.map +1 -0
- package/build/types/carbonbox/reporting/report-templates/domain/entity/ReportTemplate.d.ts +43 -0
- package/build/types/carbonbox/reporting/report-templates/domain/entity/ReportTemplate.d.ts.map +1 -0
- package/build/types/carbonbox/reporting/report-templates/domain/exceptions/ReportTemplateCannotBeActivatedError.d.ts +7 -0
- package/build/types/carbonbox/reporting/report-templates/domain/exceptions/ReportTemplateCannotBeActivatedError.d.ts.map +1 -0
- package/build/types/carbonbox/reporting/report-templates/domain/exceptions/ReportTemplateCannotBeDeprecatedError.d.ts +7 -0
- package/build/types/carbonbox/reporting/report-templates/domain/exceptions/ReportTemplateCannotBeDeprecatedError.d.ts.map +1 -0
- package/build/types/carbonbox/reporting/report-templates/domain/exceptions/ReportTemplateCannotBeVersionedError.d.ts +7 -0
- package/build/types/carbonbox/reporting/report-templates/domain/exceptions/ReportTemplateCannotBeVersionedError.d.ts.map +1 -0
- package/build/types/carbonbox/reporting/report-templates/domain/repository/IReportTemplateRepository.d.ts +97 -0
- package/build/types/carbonbox/reporting/report-templates/domain/repository/IReportTemplateRepository.d.ts.map +1 -0
- package/build/types/carbonbox/reporting/report-templates/domain/types/ReportTemplatePrimitives.d.ts +15 -15
- package/build/types/carbonbox/reporting/report-templates/domain/types/ReportTemplatePrimitives.d.ts.map +1 -1
- package/build/types/carbonbox/reporting/report-templates/domain/types/ReportTemplateProps.d.ts +20 -16
- package/build/types/carbonbox/reporting/report-templates/domain/types/ReportTemplateProps.d.ts.map +1 -1
- package/build/types/carbonbox/reporting/shared/domain/types/AIExecutionRecordPrimitives.d.ts +14 -0
- package/build/types/carbonbox/reporting/shared/domain/types/AIExecutionRecordPrimitives.d.ts.map +1 -0
- package/build/types/carbonbox/reporting/shared/domain/types/ApprovalRecordPrimitives.d.ts +12 -0
- package/build/types/carbonbox/reporting/shared/domain/types/ApprovalRecordPrimitives.d.ts.map +1 -0
- package/build/types/carbonbox/reporting/shared/domain/types/QuestionnaireAnswerPrimitives.d.ts +11 -0
- package/build/types/carbonbox/reporting/shared/domain/types/QuestionnaireAnswerPrimitives.d.ts.map +1 -0
- package/build/types/carbonbox/reporting/shared/domain/types/ReportPeriodPrimitives.d.ts +9 -0
- package/build/types/carbonbox/reporting/shared/domain/types/ReportPeriodPrimitives.d.ts.map +1 -0
- package/build/types/carbonbox/reporting/text-banks/domain/entity/ITextBank.d.ts +16 -0
- package/build/types/carbonbox/reporting/text-banks/domain/entity/ITextBank.d.ts.map +1 -0
- package/build/types/carbonbox/reporting/text-banks/domain/entity/TextBank.d.ts +36 -0
- package/build/types/carbonbox/reporting/text-banks/domain/entity/TextBank.d.ts.map +1 -0
- package/build/types/carbonbox/reporting/text-banks/domain/repository/ITextBankRepository.d.ts +52 -0
- package/build/types/carbonbox/reporting/text-banks/domain/repository/ITextBankRepository.d.ts.map +1 -0
- package/build/types/carbonbox/reporting/text-banks/domain/types/TextBankEntryPrimitives.d.ts +45 -0
- package/build/types/carbonbox/reporting/text-banks/domain/types/TextBankEntryPrimitives.d.ts.map +1 -0
- package/build/types/carbonbox/reporting/text-banks/domain/types/TextBankEntryProps.d.ts +46 -0
- package/build/types/carbonbox/reporting/text-banks/domain/types/TextBankEntryProps.d.ts.map +1 -0
- package/build/types/carbonbox/reporting/text-banks/domain/types/TextBankPrimitives.d.ts +33 -0
- package/build/types/carbonbox/reporting/text-banks/domain/types/TextBankPrimitives.d.ts.map +1 -0
- package/build/types/carbonbox/reporting/text-banks/domain/types/TextBankProps.d.ts +37 -0
- package/build/types/carbonbox/reporting/text-banks/domain/types/TextBankProps.d.ts.map +1 -0
- package/build/types/carbonbox/shared/domain/enums/ErrorCode.d.ts +11 -0
- package/build/types/carbonbox/shared/domain/enums/ErrorCode.d.ts.map +1 -1
- package/build/types/main/index.d.ts +48 -0
- package/build/types/main/index.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,275 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
3
|
+
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
4
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
5
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
6
|
+
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
7
|
+
};
|
|
8
|
+
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
9
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
10
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
11
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
12
|
+
};
|
|
13
|
+
var _ReportTemplate_version, _ReportTemplate_previousVersionId, _ReportTemplate_type, _ReportTemplate_footprintType, _ReportTemplate_reportingStandard, _ReportTemplate_requiresApproval, _ReportTemplate_status, _ReportTemplate_sections, _ReportTemplate_textBankId, _ReportTemplate_createdBy, _ReportTemplate_createdAt, _ReportTemplate_updatedAt;
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.ReportTemplate = void 0;
|
|
16
|
+
const AggregateRoot_1 = require("../../../../shared/domain/entities/AggregateRoot");
|
|
17
|
+
const ReportTemplateId_1 = require("../value-objects/ReportTemplateId");
|
|
18
|
+
const ReportTemplateStatus_1 = require("../enums/ReportTemplateStatus");
|
|
19
|
+
const ReportType_1 = require("../../../shared/domain/enums/ReportType");
|
|
20
|
+
const ReportSection_1 = require("../../../shared/domain/value-objects/ReportSection");
|
|
21
|
+
const ReportTemplateCannotBeActivatedError_1 = require("../exceptions/ReportTemplateCannotBeActivatedError");
|
|
22
|
+
const ReportTemplateCannotBeDeprecatedError_1 = require("../exceptions/ReportTemplateCannotBeDeprecatedError");
|
|
23
|
+
const ReportTemplateCannotBeVersionedError_1 = require("../exceptions/ReportTemplateCannotBeVersionedError");
|
|
24
|
+
class ReportTemplate extends AggregateRoot_1.AggregateRoot {
|
|
25
|
+
constructor(props, skipDomainValidation) {
|
|
26
|
+
const id = skipDomainValidation
|
|
27
|
+
? ReportTemplateId_1.ReportTemplateId.fromPrimitives(props.id).toPrimitives()
|
|
28
|
+
: ReportTemplateId_1.ReportTemplateId.create(props.id).toPrimitives();
|
|
29
|
+
super({ id }, skipDomainValidation);
|
|
30
|
+
_ReportTemplate_version.set(this, void 0);
|
|
31
|
+
_ReportTemplate_previousVersionId.set(this, void 0);
|
|
32
|
+
_ReportTemplate_type.set(this, void 0);
|
|
33
|
+
_ReportTemplate_footprintType.set(this, void 0);
|
|
34
|
+
_ReportTemplate_reportingStandard.set(this, void 0);
|
|
35
|
+
_ReportTemplate_requiresApproval.set(this, void 0);
|
|
36
|
+
_ReportTemplate_status.set(this, void 0);
|
|
37
|
+
_ReportTemplate_sections.set(this, void 0);
|
|
38
|
+
_ReportTemplate_textBankId.set(this, void 0);
|
|
39
|
+
_ReportTemplate_createdBy.set(this, void 0);
|
|
40
|
+
_ReportTemplate_createdAt.set(this, void 0);
|
|
41
|
+
_ReportTemplate_updatedAt.set(this, void 0);
|
|
42
|
+
__classPrivateFieldSet(this, _ReportTemplate_version, props.version, "f");
|
|
43
|
+
__classPrivateFieldSet(this, _ReportTemplate_previousVersionId, props.previousVersionId, "f");
|
|
44
|
+
__classPrivateFieldSet(this, _ReportTemplate_type, props.type, "f");
|
|
45
|
+
__classPrivateFieldSet(this, _ReportTemplate_footprintType, props.footprintType, "f");
|
|
46
|
+
__classPrivateFieldSet(this, _ReportTemplate_reportingStandard, props.reportingStandard, "f");
|
|
47
|
+
__classPrivateFieldSet(this, _ReportTemplate_requiresApproval, props.requiresClientApproval, "f");
|
|
48
|
+
__classPrivateFieldSet(this, _ReportTemplate_status, props.status, "f");
|
|
49
|
+
__classPrivateFieldSet(this, _ReportTemplate_textBankId, props.textBankId, "f");
|
|
50
|
+
__classPrivateFieldSet(this, _ReportTemplate_createdBy, props.createdBy, "f");
|
|
51
|
+
__classPrivateFieldSet(this, _ReportTemplate_createdAt, props.createdAt, "f");
|
|
52
|
+
__classPrivateFieldSet(this, _ReportTemplate_updatedAt, props.updatedAt, "f");
|
|
53
|
+
if (skipDomainValidation === false) {
|
|
54
|
+
// Initialize with domain validation
|
|
55
|
+
__classPrivateFieldSet(this, _ReportTemplate_sections, props.sections.map((s) => ReportSection_1.ReportSection.create(s.toPrimitives())), "f");
|
|
56
|
+
}
|
|
57
|
+
else {
|
|
58
|
+
// Initialize from primitives (no domain validation)
|
|
59
|
+
__classPrivateFieldSet(this, _ReportTemplate_sections, props.sections.map((s) => ReportSection_1.ReportSection.fromPrimitives(s.toPrimitives())), "f");
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
static create(props) {
|
|
63
|
+
const now = new Date().toISOString();
|
|
64
|
+
const id = `${props.type}-${props.footprintType}-${props.reportingStandard}-v${props.version}`;
|
|
65
|
+
const fullProps = {
|
|
66
|
+
...props,
|
|
67
|
+
id,
|
|
68
|
+
createdAt: now,
|
|
69
|
+
updatedAt: now,
|
|
70
|
+
};
|
|
71
|
+
return new ReportTemplate(fullProps, false);
|
|
72
|
+
}
|
|
73
|
+
static fromPrimitives(primitives) {
|
|
74
|
+
const props = {
|
|
75
|
+
id: primitives.id,
|
|
76
|
+
version: primitives.version,
|
|
77
|
+
previousVersionId: primitives.previousVersionId,
|
|
78
|
+
type: primitives.type,
|
|
79
|
+
footprintType: primitives.footprintType,
|
|
80
|
+
reportingStandard: primitives.reportingStandard,
|
|
81
|
+
requiresClientApproval: primitives.requiresClientApproval,
|
|
82
|
+
status: primitives.status,
|
|
83
|
+
sections: primitives.sections.map((s) => ReportSection_1.ReportSection.fromPrimitives(s)),
|
|
84
|
+
textBankId: primitives.textBankId,
|
|
85
|
+
createdBy: primitives.createdBy,
|
|
86
|
+
createdAt: primitives.createdAt,
|
|
87
|
+
updatedAt: primitives.updatedAt,
|
|
88
|
+
};
|
|
89
|
+
return new ReportTemplate(props, true);
|
|
90
|
+
}
|
|
91
|
+
get toPrimitives() {
|
|
92
|
+
return {
|
|
93
|
+
id: this.id.toPrimitives(),
|
|
94
|
+
version: __classPrivateFieldGet(this, _ReportTemplate_version, "f"),
|
|
95
|
+
previousVersionId: __classPrivateFieldGet(this, _ReportTemplate_previousVersionId, "f"),
|
|
96
|
+
type: __classPrivateFieldGet(this, _ReportTemplate_type, "f"),
|
|
97
|
+
footprintType: __classPrivateFieldGet(this, _ReportTemplate_footprintType, "f"),
|
|
98
|
+
reportingStandard: __classPrivateFieldGet(this, _ReportTemplate_reportingStandard, "f"),
|
|
99
|
+
requiresClientApproval: __classPrivateFieldGet(this, _ReportTemplate_requiresApproval, "f"),
|
|
100
|
+
status: __classPrivateFieldGet(this, _ReportTemplate_status, "f"),
|
|
101
|
+
sections: __classPrivateFieldGet(this, _ReportTemplate_sections, "f").map((s) => s.toPrimitives()),
|
|
102
|
+
textBankId: __classPrivateFieldGet(this, _ReportTemplate_textBankId, "f"),
|
|
103
|
+
createdBy: __classPrivateFieldGet(this, _ReportTemplate_createdBy, "f"),
|
|
104
|
+
createdAt: __classPrivateFieldGet(this, _ReportTemplate_createdAt, "f"),
|
|
105
|
+
updatedAt: __classPrivateFieldGet(this, _ReportTemplate_updatedAt, "f"),
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
toProps() {
|
|
109
|
+
return {
|
|
110
|
+
id: this.id.toPrimitives(),
|
|
111
|
+
version: __classPrivateFieldGet(this, _ReportTemplate_version, "f"),
|
|
112
|
+
previousVersionId: __classPrivateFieldGet(this, _ReportTemplate_previousVersionId, "f"),
|
|
113
|
+
type: __classPrivateFieldGet(this, _ReportTemplate_type, "f"),
|
|
114
|
+
footprintType: __classPrivateFieldGet(this, _ReportTemplate_footprintType, "f"),
|
|
115
|
+
reportingStandard: __classPrivateFieldGet(this, _ReportTemplate_reportingStandard, "f"),
|
|
116
|
+
requiresClientApproval: __classPrivateFieldGet(this, _ReportTemplate_requiresApproval, "f"),
|
|
117
|
+
status: __classPrivateFieldGet(this, _ReportTemplate_status, "f"),
|
|
118
|
+
sections: __classPrivateFieldGet(this, _ReportTemplate_sections, "f"),
|
|
119
|
+
textBankId: __classPrivateFieldGet(this, _ReportTemplate_textBankId, "f"),
|
|
120
|
+
createdBy: __classPrivateFieldGet(this, _ReportTemplate_createdBy, "f"),
|
|
121
|
+
createdAt: __classPrivateFieldGet(this, _ReportTemplate_createdAt, "f"),
|
|
122
|
+
updatedAt: __classPrivateFieldGet(this, _ReportTemplate_updatedAt, "f"),
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
// Getters
|
|
126
|
+
getId() {
|
|
127
|
+
return this.id.toPrimitives();
|
|
128
|
+
}
|
|
129
|
+
getVersion() {
|
|
130
|
+
return __classPrivateFieldGet(this, _ReportTemplate_version, "f");
|
|
131
|
+
}
|
|
132
|
+
getPreviousVersionId() {
|
|
133
|
+
return __classPrivateFieldGet(this, _ReportTemplate_previousVersionId, "f");
|
|
134
|
+
}
|
|
135
|
+
getType() {
|
|
136
|
+
return __classPrivateFieldGet(this, _ReportTemplate_type, "f");
|
|
137
|
+
}
|
|
138
|
+
getFootprintType() {
|
|
139
|
+
return __classPrivateFieldGet(this, _ReportTemplate_footprintType, "f");
|
|
140
|
+
}
|
|
141
|
+
getReportingStandard() {
|
|
142
|
+
return __classPrivateFieldGet(this, _ReportTemplate_reportingStandard, "f");
|
|
143
|
+
}
|
|
144
|
+
requiresClientApproval() {
|
|
145
|
+
return __classPrivateFieldGet(this, _ReportTemplate_requiresApproval, "f");
|
|
146
|
+
}
|
|
147
|
+
getStatus() {
|
|
148
|
+
return __classPrivateFieldGet(this, _ReportTemplate_status, "f");
|
|
149
|
+
}
|
|
150
|
+
getSections() {
|
|
151
|
+
return __classPrivateFieldGet(this, _ReportTemplate_sections, "f").map((s) => s.toPrimitives());
|
|
152
|
+
}
|
|
153
|
+
getTextBankId() {
|
|
154
|
+
return __classPrivateFieldGet(this, _ReportTemplate_textBankId, "f");
|
|
155
|
+
}
|
|
156
|
+
getCreatedBy() {
|
|
157
|
+
return __classPrivateFieldGet(this, _ReportTemplate_createdBy, "f");
|
|
158
|
+
}
|
|
159
|
+
getCreatedAt() {
|
|
160
|
+
return __classPrivateFieldGet(this, _ReportTemplate_createdAt, "f");
|
|
161
|
+
}
|
|
162
|
+
getUpdatedAt() {
|
|
163
|
+
return __classPrivateFieldGet(this, _ReportTemplate_updatedAt, "f");
|
|
164
|
+
}
|
|
165
|
+
// Business logic - Status checks
|
|
166
|
+
isActive() {
|
|
167
|
+
return __classPrivateFieldGet(this, _ReportTemplate_status, "f") === ReportTemplateStatus_1.ReportTemplateStatus.ACTIVE;
|
|
168
|
+
}
|
|
169
|
+
isDraft() {
|
|
170
|
+
return __classPrivateFieldGet(this, _ReportTemplate_status, "f") === ReportTemplateStatus_1.ReportTemplateStatus.DRAFT;
|
|
171
|
+
}
|
|
172
|
+
isDeprecated() {
|
|
173
|
+
return __classPrivateFieldGet(this, _ReportTemplate_status, "f") === ReportTemplateStatus_1.ReportTemplateStatus.DEPRECATED;
|
|
174
|
+
}
|
|
175
|
+
// Business logic - Capabilities
|
|
176
|
+
canBeActivated() {
|
|
177
|
+
if (!this.isDraft()) {
|
|
178
|
+
return false;
|
|
179
|
+
}
|
|
180
|
+
// Template must have at least one section
|
|
181
|
+
if (__classPrivateFieldGet(this, _ReportTemplate_sections, "f").length === 0) {
|
|
182
|
+
return false;
|
|
183
|
+
}
|
|
184
|
+
// All sections must have at least one block
|
|
185
|
+
const allSectionsHaveBlocks = __classPrivateFieldGet(this, _ReportTemplate_sections, "f").every((section) => section.getBlocks().length > 0);
|
|
186
|
+
return allSectionsHaveBlocks;
|
|
187
|
+
}
|
|
188
|
+
canBeModified() {
|
|
189
|
+
// Only DRAFT templates can be modified
|
|
190
|
+
// ACTIVE or DEPRECATED templates are immutable
|
|
191
|
+
return this.isDraft();
|
|
192
|
+
}
|
|
193
|
+
canBeDeprecated() {
|
|
194
|
+
// Only ACTIVE templates can be deprecated
|
|
195
|
+
return this.isActive();
|
|
196
|
+
}
|
|
197
|
+
// Business logic - Actions
|
|
198
|
+
activate() {
|
|
199
|
+
if (!this.canBeActivated()) {
|
|
200
|
+
let reason;
|
|
201
|
+
if (!this.isDraft()) {
|
|
202
|
+
reason = `Invalid status: ${__classPrivateFieldGet(this, _ReportTemplate_status, "f")}`;
|
|
203
|
+
}
|
|
204
|
+
else if (__classPrivateFieldGet(this, _ReportTemplate_sections, "f").length === 0) {
|
|
205
|
+
reason = 'Template has no sections';
|
|
206
|
+
}
|
|
207
|
+
else {
|
|
208
|
+
reason = 'Not all sections have at least one block';
|
|
209
|
+
}
|
|
210
|
+
throw ReportTemplateCannotBeActivatedError_1.ReportTemplateCannotBeActivatedError.create(this.id.toPrimitives(), __classPrivateFieldGet(this, _ReportTemplate_status, "f"), reason);
|
|
211
|
+
}
|
|
212
|
+
__classPrivateFieldSet(this, _ReportTemplate_status, ReportTemplateStatus_1.ReportTemplateStatus.ACTIVE, "f");
|
|
213
|
+
__classPrivateFieldSet(this, _ReportTemplate_updatedAt, new Date().toISOString(), "f");
|
|
214
|
+
}
|
|
215
|
+
deprecate() {
|
|
216
|
+
if (!this.canBeDeprecated()) {
|
|
217
|
+
const reason = `Invalid status: ${__classPrivateFieldGet(this, _ReportTemplate_status, "f")}. Only ACTIVE templates can be deprecated`;
|
|
218
|
+
throw ReportTemplateCannotBeDeprecatedError_1.ReportTemplateCannotBeDeprecatedError.create(this.id.toPrimitives(), __classPrivateFieldGet(this, _ReportTemplate_status, "f"), reason);
|
|
219
|
+
}
|
|
220
|
+
__classPrivateFieldSet(this, _ReportTemplate_status, ReportTemplateStatus_1.ReportTemplateStatus.DEPRECATED, "f");
|
|
221
|
+
__classPrivateFieldSet(this, _ReportTemplate_updatedAt, new Date().toISOString(), "f");
|
|
222
|
+
}
|
|
223
|
+
createNewVersion(createdBy) {
|
|
224
|
+
if (!this.isActive()) {
|
|
225
|
+
const reason = `Invalid status: ${__classPrivateFieldGet(this, _ReportTemplate_status, "f")}. Only ACTIVE templates can be versioned`;
|
|
226
|
+
throw ReportTemplateCannotBeVersionedError_1.ReportTemplateCannotBeVersionedError.create(this.id.toPrimitives(), __classPrivateFieldGet(this, _ReportTemplate_status, "f"), reason);
|
|
227
|
+
}
|
|
228
|
+
const newProps = {
|
|
229
|
+
id: `${__classPrivateFieldGet(this, _ReportTemplate_type, "f")}-${__classPrivateFieldGet(this, _ReportTemplate_footprintType, "f")}-${__classPrivateFieldGet(this, _ReportTemplate_reportingStandard, "f")}-v${__classPrivateFieldGet(this, _ReportTemplate_version, "f") + 1}`,
|
|
230
|
+
version: __classPrivateFieldGet(this, _ReportTemplate_version, "f") + 1,
|
|
231
|
+
previousVersionId: this.id.toPrimitives(),
|
|
232
|
+
type: __classPrivateFieldGet(this, _ReportTemplate_type, "f"),
|
|
233
|
+
footprintType: __classPrivateFieldGet(this, _ReportTemplate_footprintType, "f"),
|
|
234
|
+
reportingStandard: __classPrivateFieldGet(this, _ReportTemplate_reportingStandard, "f"),
|
|
235
|
+
requiresClientApproval: __classPrivateFieldGet(this, _ReportTemplate_requiresApproval, "f"),
|
|
236
|
+
status: ReportTemplateStatus_1.ReportTemplateStatus.DRAFT,
|
|
237
|
+
sections: [...__classPrivateFieldGet(this, _ReportTemplate_sections, "f")],
|
|
238
|
+
textBankId: __classPrivateFieldGet(this, _ReportTemplate_textBankId, "f"),
|
|
239
|
+
createdBy,
|
|
240
|
+
createdAt: new Date().toISOString(),
|
|
241
|
+
updatedAt: new Date().toISOString(),
|
|
242
|
+
};
|
|
243
|
+
return new ReportTemplate(newProps, false);
|
|
244
|
+
}
|
|
245
|
+
// Helper methods
|
|
246
|
+
isAuditable() {
|
|
247
|
+
return __classPrivateFieldGet(this, _ReportTemplate_type, "f") === ReportType_1.ReportType.AUDITABLE;
|
|
248
|
+
}
|
|
249
|
+
isTechnical() {
|
|
250
|
+
return __classPrivateFieldGet(this, _ReportTemplate_type, "f") === ReportType_1.ReportType.TECHNICAL;
|
|
251
|
+
}
|
|
252
|
+
isExecutive() {
|
|
253
|
+
return __classPrivateFieldGet(this, _ReportTemplate_type, "f") === ReportType_1.ReportType.EXECUTIVE;
|
|
254
|
+
}
|
|
255
|
+
isCustom() {
|
|
256
|
+
return __classPrivateFieldGet(this, _ReportTemplate_type, "f") === ReportType_1.ReportType.CUSTOM;
|
|
257
|
+
}
|
|
258
|
+
getTemplateTypeLabel() {
|
|
259
|
+
const labels = {
|
|
260
|
+
[ReportType_1.ReportType.AUDITABLE]: 'Auditable Report',
|
|
261
|
+
[ReportType_1.ReportType.TECHNICAL]: 'Technical Report',
|
|
262
|
+
[ReportType_1.ReportType.EXECUTIVE]: 'Executive Summary',
|
|
263
|
+
[ReportType_1.ReportType.CUSTOM]: 'Custom Report',
|
|
264
|
+
};
|
|
265
|
+
return labels[__classPrivateFieldGet(this, _ReportTemplate_type, "f")] || 'Unknown Report Type';
|
|
266
|
+
}
|
|
267
|
+
getTotalBlocks() {
|
|
268
|
+
return __classPrivateFieldGet(this, _ReportTemplate_sections, "f").reduce((total, section) => total + section.getBlocks().length, 0);
|
|
269
|
+
}
|
|
270
|
+
hasTextBank() {
|
|
271
|
+
return __classPrivateFieldGet(this, _ReportTemplate_textBankId, "f") !== null && __classPrivateFieldGet(this, _ReportTemplate_textBankId, "f").trim() !== '';
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
exports.ReportTemplate = ReportTemplate;
|
|
275
|
+
_ReportTemplate_version = new WeakMap(), _ReportTemplate_previousVersionId = new WeakMap(), _ReportTemplate_type = new WeakMap(), _ReportTemplate_footprintType = new WeakMap(), _ReportTemplate_reportingStandard = new WeakMap(), _ReportTemplate_requiresApproval = new WeakMap(), _ReportTemplate_status = new WeakMap(), _ReportTemplate_sections = new WeakMap(), _ReportTemplate_textBankId = new WeakMap(), _ReportTemplate_createdBy = new WeakMap(), _ReportTemplate_createdAt = new WeakMap(), _ReportTemplate_updatedAt = new WeakMap();
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ReportTemplateCannotBeActivatedError = void 0;
|
|
4
|
+
const CodedRootError_1 = require("../../../../shared/domain/exceptions/CodedRootError");
|
|
5
|
+
const ErrorCode_1 = require("../../../../shared/domain/enums/ErrorCode");
|
|
6
|
+
class ReportTemplateCannotBeActivatedError extends CodedRootError_1.CodedRootError {
|
|
7
|
+
constructor(templateId, currentStatus, reason) {
|
|
8
|
+
const technicalMessage = `Report template '${templateId}' cannot be activated. Current status: ${currentStatus}. Reason: ${reason}`;
|
|
9
|
+
const context = {
|
|
10
|
+
templateId,
|
|
11
|
+
currentStatus,
|
|
12
|
+
reason,
|
|
13
|
+
timestamp: new Date().toISOString(),
|
|
14
|
+
};
|
|
15
|
+
const suggestions = [
|
|
16
|
+
'Ensure the report template is in DRAFT status before attempting activation',
|
|
17
|
+
'Verify that the template has at least one section with blocks',
|
|
18
|
+
'Check that all sections have at least one block defined',
|
|
19
|
+
`Review the report template '${templateId}' configuration`,
|
|
20
|
+
'Confirm that all required fields are properly configured',
|
|
21
|
+
];
|
|
22
|
+
super(ErrorCode_1.ErrorCode.REPORT_TEMPLATE_CANNOT_BE_ACTIVATED, technicalMessage, context, suggestions);
|
|
23
|
+
this.name = 'ReportTemplateCannotBeActivatedError';
|
|
24
|
+
}
|
|
25
|
+
static create(templateId, currentStatus, reason) {
|
|
26
|
+
return new ReportTemplateCannotBeActivatedError(templateId, currentStatus, reason);
|
|
27
|
+
}
|
|
28
|
+
logError() {
|
|
29
|
+
return `${this.name}: ${this.technicalMessage}`;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
exports.ReportTemplateCannotBeActivatedError = ReportTemplateCannotBeActivatedError;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ReportTemplateCannotBeDeprecatedError = void 0;
|
|
4
|
+
const CodedRootError_1 = require("../../../../shared/domain/exceptions/CodedRootError");
|
|
5
|
+
const ErrorCode_1 = require("../../../../shared/domain/enums/ErrorCode");
|
|
6
|
+
class ReportTemplateCannotBeDeprecatedError extends CodedRootError_1.CodedRootError {
|
|
7
|
+
constructor(templateId, currentStatus, reason) {
|
|
8
|
+
const technicalMessage = `Report template '${templateId}' cannot be deprecated. Current status: ${currentStatus}. Reason: ${reason}`;
|
|
9
|
+
const context = {
|
|
10
|
+
templateId,
|
|
11
|
+
currentStatus,
|
|
12
|
+
reason,
|
|
13
|
+
timestamp: new Date().toISOString(),
|
|
14
|
+
};
|
|
15
|
+
const suggestions = [
|
|
16
|
+
'Ensure the report template is in ACTIVE status before attempting deprecation',
|
|
17
|
+
'Verify that there is a newer version of the template available',
|
|
18
|
+
`Review the report template '${templateId}' lifecycle status`,
|
|
19
|
+
'Check if there are any active report instances using this template',
|
|
20
|
+
'Consider creating a new version before deprecating this template',
|
|
21
|
+
];
|
|
22
|
+
super(ErrorCode_1.ErrorCode.REPORT_TEMPLATE_CANNOT_BE_DEPRECATED, technicalMessage, context, suggestions);
|
|
23
|
+
this.name = 'ReportTemplateCannotBeDeprecatedError';
|
|
24
|
+
}
|
|
25
|
+
static create(templateId, currentStatus, reason) {
|
|
26
|
+
return new ReportTemplateCannotBeDeprecatedError(templateId, currentStatus, reason);
|
|
27
|
+
}
|
|
28
|
+
logError() {
|
|
29
|
+
return `${this.name}: ${this.technicalMessage}`;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
exports.ReportTemplateCannotBeDeprecatedError = ReportTemplateCannotBeDeprecatedError;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ReportTemplateCannotBeVersionedError = void 0;
|
|
4
|
+
const CodedRootError_1 = require("../../../../shared/domain/exceptions/CodedRootError");
|
|
5
|
+
const ErrorCode_1 = require("../../../../shared/domain/enums/ErrorCode");
|
|
6
|
+
class ReportTemplateCannotBeVersionedError extends CodedRootError_1.CodedRootError {
|
|
7
|
+
constructor(templateId, currentStatus, reason) {
|
|
8
|
+
const technicalMessage = `Report template '${templateId}' cannot be versioned. Current status: ${currentStatus}. Reason: ${reason}`;
|
|
9
|
+
const context = {
|
|
10
|
+
templateId,
|
|
11
|
+
currentStatus,
|
|
12
|
+
reason,
|
|
13
|
+
timestamp: new Date().toISOString(),
|
|
14
|
+
};
|
|
15
|
+
const suggestions = [
|
|
16
|
+
'Ensure the report template is in ACTIVE status before creating a new version',
|
|
17
|
+
'Verify that the template is properly configured and validated',
|
|
18
|
+
`Review the report template '${templateId}' status and configuration`,
|
|
19
|
+
'Check that the template has been activated and is not deprecated',
|
|
20
|
+
'Consider activating the template before attempting to create a new version',
|
|
21
|
+
];
|
|
22
|
+
super(ErrorCode_1.ErrorCode.REPORT_TEMPLATE_CANNOT_BE_VERSIONED, technicalMessage, context, suggestions);
|
|
23
|
+
this.name = 'ReportTemplateCannotBeVersionedError';
|
|
24
|
+
}
|
|
25
|
+
static create(templateId, currentStatus, reason) {
|
|
26
|
+
return new ReportTemplateCannotBeVersionedError(templateId, currentStatus, reason);
|
|
27
|
+
}
|
|
28
|
+
logError() {
|
|
29
|
+
return `${this.name}: ${this.technicalMessage}`;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
exports.ReportTemplateCannotBeVersionedError = ReportTemplateCannotBeVersionedError;
|
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
3
|
+
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
4
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
5
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
6
|
+
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
7
|
+
};
|
|
8
|
+
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
9
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
10
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
11
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
12
|
+
};
|
|
13
|
+
var _TextBank_templateId, _TextBank_version, _TextBank_entries, _TextBank_createdAt, _TextBank_updatedAt;
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.TextBank = void 0;
|
|
16
|
+
const AggregateRoot_1 = require("../../../../shared/domain/entities/AggregateRoot");
|
|
17
|
+
const TextBankId_1 = require("../value-objects/TextBankId");
|
|
18
|
+
class TextBank extends AggregateRoot_1.AggregateRoot {
|
|
19
|
+
constructor(props, skipDomainValidation) {
|
|
20
|
+
const id = skipDomainValidation
|
|
21
|
+
? TextBankId_1.TextBankId.fromPrimitives(props.id).toPrimitives()
|
|
22
|
+
: TextBankId_1.TextBankId.create(props.id).toPrimitives();
|
|
23
|
+
super({ id }, skipDomainValidation);
|
|
24
|
+
_TextBank_templateId.set(this, void 0);
|
|
25
|
+
_TextBank_version.set(this, void 0);
|
|
26
|
+
_TextBank_entries.set(this, void 0);
|
|
27
|
+
_TextBank_createdAt.set(this, void 0);
|
|
28
|
+
_TextBank_updatedAt.set(this, void 0);
|
|
29
|
+
__classPrivateFieldSet(this, _TextBank_templateId, props.templateId, "f");
|
|
30
|
+
__classPrivateFieldSet(this, _TextBank_version, props.version, "f");
|
|
31
|
+
__classPrivateFieldSet(this, _TextBank_entries, props.entries, "f");
|
|
32
|
+
__classPrivateFieldSet(this, _TextBank_createdAt, props.createdAt, "f");
|
|
33
|
+
__classPrivateFieldSet(this, _TextBank_updatedAt, props.updatedAt, "f");
|
|
34
|
+
}
|
|
35
|
+
static create(props) {
|
|
36
|
+
const now = new Date().toISOString();
|
|
37
|
+
const id = `${props.templateId}-v${props.version}-${now}`;
|
|
38
|
+
const fullProps = {
|
|
39
|
+
...props,
|
|
40
|
+
id,
|
|
41
|
+
createdAt: now,
|
|
42
|
+
updatedAt: now,
|
|
43
|
+
};
|
|
44
|
+
return new TextBank(fullProps, false);
|
|
45
|
+
}
|
|
46
|
+
static fromPrimitives(primitives) {
|
|
47
|
+
const props = {
|
|
48
|
+
id: primitives.id,
|
|
49
|
+
templateId: primitives.templateId,
|
|
50
|
+
version: primitives.version,
|
|
51
|
+
entries: primitives.entries,
|
|
52
|
+
createdAt: primitives.createdAt,
|
|
53
|
+
updatedAt: primitives.updatedAt,
|
|
54
|
+
};
|
|
55
|
+
return new TextBank(props, true);
|
|
56
|
+
}
|
|
57
|
+
get toPrimitives() {
|
|
58
|
+
return {
|
|
59
|
+
id: this.id.toPrimitives(),
|
|
60
|
+
templateId: __classPrivateFieldGet(this, _TextBank_templateId, "f"),
|
|
61
|
+
version: __classPrivateFieldGet(this, _TextBank_version, "f"),
|
|
62
|
+
entries: __classPrivateFieldGet(this, _TextBank_entries, "f"),
|
|
63
|
+
createdAt: __classPrivateFieldGet(this, _TextBank_createdAt, "f"),
|
|
64
|
+
updatedAt: __classPrivateFieldGet(this, _TextBank_updatedAt, "f"),
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
toProps() {
|
|
68
|
+
return {
|
|
69
|
+
id: this.id.toPrimitives(),
|
|
70
|
+
templateId: __classPrivateFieldGet(this, _TextBank_templateId, "f"),
|
|
71
|
+
version: __classPrivateFieldGet(this, _TextBank_version, "f"),
|
|
72
|
+
entries: __classPrivateFieldGet(this, _TextBank_entries, "f"),
|
|
73
|
+
createdAt: __classPrivateFieldGet(this, _TextBank_createdAt, "f"),
|
|
74
|
+
updatedAt: __classPrivateFieldGet(this, _TextBank_updatedAt, "f"),
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
// Getters
|
|
78
|
+
getId() {
|
|
79
|
+
return this.id.toPrimitives();
|
|
80
|
+
}
|
|
81
|
+
getTemplateId() {
|
|
82
|
+
return __classPrivateFieldGet(this, _TextBank_templateId, "f");
|
|
83
|
+
}
|
|
84
|
+
getVersion() {
|
|
85
|
+
return __classPrivateFieldGet(this, _TextBank_version, "f");
|
|
86
|
+
}
|
|
87
|
+
getEntries() {
|
|
88
|
+
return [...__classPrivateFieldGet(this, _TextBank_entries, "f")];
|
|
89
|
+
}
|
|
90
|
+
getCreatedAt() {
|
|
91
|
+
return __classPrivateFieldGet(this, _TextBank_createdAt, "f");
|
|
92
|
+
}
|
|
93
|
+
getUpdatedAt() {
|
|
94
|
+
return __classPrivateFieldGet(this, _TextBank_updatedAt, "f");
|
|
95
|
+
}
|
|
96
|
+
// Business logic methods
|
|
97
|
+
getEntriesByCategory(category) {
|
|
98
|
+
return __classPrivateFieldGet(this, _TextBank_entries, "f").filter((entry) => entry.category === category);
|
|
99
|
+
}
|
|
100
|
+
getEntryById(entryId) {
|
|
101
|
+
const entry = __classPrivateFieldGet(this, _TextBank_entries, "f").find((e) => e.id === entryId);
|
|
102
|
+
return entry || null;
|
|
103
|
+
}
|
|
104
|
+
getEntriesBySubcategory(category, subcategory) {
|
|
105
|
+
return __classPrivateFieldGet(this, _TextBank_entries, "f").filter((entry) => entry.category === category && entry.subcategory === subcategory);
|
|
106
|
+
}
|
|
107
|
+
getEntriesByTags(tags) {
|
|
108
|
+
return __classPrivateFieldGet(this, _TextBank_entries, "f").filter((entry) => tags.some((tag) => entry.tags.includes(tag)));
|
|
109
|
+
}
|
|
110
|
+
getEntriesByLanguage(language) {
|
|
111
|
+
return __classPrivateFieldGet(this, _TextBank_entries, "f").filter((entry) => entry.language === language);
|
|
112
|
+
}
|
|
113
|
+
searchEntries(query) {
|
|
114
|
+
const lowerQuery = query.toLowerCase();
|
|
115
|
+
return __classPrivateFieldGet(this, _TextBank_entries, "f").filter((entry) => entry.content.toLowerCase().includes(lowerQuery)
|
|
116
|
+
|| entry.category.toLowerCase().includes(lowerQuery)
|
|
117
|
+
|| (entry.subcategory && entry.subcategory.toLowerCase().includes(lowerQuery))
|
|
118
|
+
|| entry.tags.some((tag) => tag.toLowerCase().includes(lowerQuery)));
|
|
119
|
+
}
|
|
120
|
+
// Helper methods
|
|
121
|
+
hasEntries() {
|
|
122
|
+
return __classPrivateFieldGet(this, _TextBank_entries, "f").length > 0;
|
|
123
|
+
}
|
|
124
|
+
getTotalEntries() {
|
|
125
|
+
return __classPrivateFieldGet(this, _TextBank_entries, "f").length;
|
|
126
|
+
}
|
|
127
|
+
getCategories() {
|
|
128
|
+
const categories = new Set(__classPrivateFieldGet(this, _TextBank_entries, "f").map((entry) => entry.category));
|
|
129
|
+
return Array.from(categories).sort();
|
|
130
|
+
}
|
|
131
|
+
getSubcategories(category) {
|
|
132
|
+
const subcategories = new Set(__classPrivateFieldGet(this, _TextBank_entries, "f")
|
|
133
|
+
.filter((entry) => entry.category === category && entry.subcategory)
|
|
134
|
+
.map((entry) => entry.subcategory));
|
|
135
|
+
return Array.from(subcategories).sort();
|
|
136
|
+
}
|
|
137
|
+
getAllTags() {
|
|
138
|
+
const tags = new Set(__classPrivateFieldGet(this, _TextBank_entries, "f").flatMap((entry) => entry.tags));
|
|
139
|
+
return Array.from(tags).sort();
|
|
140
|
+
}
|
|
141
|
+
getLanguages() {
|
|
142
|
+
const languages = new Set(__classPrivateFieldGet(this, _TextBank_entries, "f").map((entry) => entry.language));
|
|
143
|
+
return Array.from(languages).sort();
|
|
144
|
+
}
|
|
145
|
+
addEntry(entry) {
|
|
146
|
+
__classPrivateFieldGet(this, _TextBank_entries, "f").push(entry);
|
|
147
|
+
__classPrivateFieldSet(this, _TextBank_updatedAt, new Date().toISOString(), "f");
|
|
148
|
+
}
|
|
149
|
+
removeEntry(entryId) {
|
|
150
|
+
const index = __classPrivateFieldGet(this, _TextBank_entries, "f").findIndex((e) => e.id === entryId);
|
|
151
|
+
if (index === -1) {
|
|
152
|
+
return false;
|
|
153
|
+
}
|
|
154
|
+
__classPrivateFieldGet(this, _TextBank_entries, "f").splice(index, 1);
|
|
155
|
+
__classPrivateFieldSet(this, _TextBank_updatedAt, new Date().toISOString(), "f");
|
|
156
|
+
return true;
|
|
157
|
+
}
|
|
158
|
+
updateEntry(entryId, updatedEntry) {
|
|
159
|
+
const index = __classPrivateFieldGet(this, _TextBank_entries, "f").findIndex((e) => e.id === entryId);
|
|
160
|
+
if (index === -1) {
|
|
161
|
+
return false;
|
|
162
|
+
}
|
|
163
|
+
__classPrivateFieldGet(this, _TextBank_entries, "f")[index] = {
|
|
164
|
+
...__classPrivateFieldGet(this, _TextBank_entries, "f")[index],
|
|
165
|
+
...updatedEntry,
|
|
166
|
+
updatedAt: new Date().toISOString(),
|
|
167
|
+
};
|
|
168
|
+
__classPrivateFieldSet(this, _TextBank_updatedAt, new Date().toISOString(), "f");
|
|
169
|
+
return true;
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
exports.TextBank = TextBank;
|
|
173
|
+
_TextBank_templateId = new WeakMap(), _TextBank_version = new WeakMap(), _TextBank_entries = new WeakMap(), _TextBank_createdAt = new WeakMap(), _TextBank_updatedAt = new WeakMap();
|
|
@@ -140,6 +140,17 @@ var ErrorCode;
|
|
|
140
140
|
ErrorCode["INVALID_REPORT_SECTION_ORDER"] = "CBX-RPT-004";
|
|
141
141
|
ErrorCode["INVALID_REPORT_SECTION_TITLE"] = "CBX-RPT-005";
|
|
142
142
|
ErrorCode["INVALID_REPORT_TEMPLATE_ID"] = "CBX-RPT-006";
|
|
143
|
+
ErrorCode["REPORT_INSTANCE_CANNOT_BE_GENERATED"] = "CBX-RPT-007";
|
|
144
|
+
ErrorCode["REPORT_INSTANCE_CANNOT_BE_APPROVED_INTERNALLY"] = "CBX-RPT-008";
|
|
145
|
+
ErrorCode["REPORT_INSTANCE_CANNOT_BE_APPROVED_BY_CLIENT"] = "CBX-RPT-009";
|
|
146
|
+
ErrorCode["REPORT_INSTANCE_CANNOT_BE_PUBLISHED"] = "CBX-RPT-010";
|
|
147
|
+
ErrorCode["REPORT_INSTANCE_CANNOT_BE_REJECTED"] = "CBX-RPT-011";
|
|
148
|
+
ErrorCode["REPORT_INSTANCE_INVALID_STATUS_TRANSITION"] = "CBX-RPT-012";
|
|
149
|
+
ErrorCode["REPORT_INSTANCE_MISSING_DATA_SNAPSHOT"] = "CBX-RPT-013";
|
|
150
|
+
ErrorCode["REPORT_INSTANCE_MISSING_GENERATED_CONTENT"] = "CBX-RPT-014";
|
|
151
|
+
ErrorCode["REPORT_TEMPLATE_CANNOT_BE_ACTIVATED"] = "CBX-RPT-015";
|
|
152
|
+
ErrorCode["REPORT_TEMPLATE_CANNOT_BE_DEPRECATED"] = "CBX-RPT-016";
|
|
153
|
+
ErrorCode["REPORT_TEMPLATE_CANNOT_BE_VERSIONED"] = "CBX-RPT-017";
|
|
143
154
|
// Shared/Common Errors (CBX-SHR-XXX)
|
|
144
155
|
ErrorCode["INVALID_EMAIL"] = "CBX-SHR-001";
|
|
145
156
|
ErrorCode["INVALID_DATE_FORMAT"] = "CBX-SHR-002";
|