gemcap-be-common 1.4.161 → 1.4.162

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.
@@ -53,6 +53,7 @@ export interface IScorecardDefinition {
53
53
  export interface IScorecardVersion {
54
54
  scorecardId: mongoose.Types.ObjectId;
55
55
  version: string;
56
+ status: 'draft' | 'active' | 'archived';
56
57
  validFrom: Date;
57
58
  validTo?: Date;
58
59
  definition: IScorecardDefinition;
@@ -89,6 +89,12 @@ exports.ScorecardVersionSchema = new mongoose_1.default.Schema({
89
89
  validTo: {
90
90
  type: Date,
91
91
  },
92
+ status: {
93
+ type: String,
94
+ enum: ['draft', 'active', 'archived'],
95
+ required: true,
96
+ index: true,
97
+ },
92
98
  definition: {
93
99
  type: mongoose_1.default.Schema.Types.Mixed,
94
100
  required: true,
@@ -98,9 +104,11 @@ exports.ScorecardVersionSchema = new mongoose_1.default.Schema({
98
104
  versionKey: false,
99
105
  });
100
106
  exports.ScorecardVersion = mongoose_1.default.model(_models_1.MODEL_NAMES.scorecardVersion, exports.ScorecardVersionSchema);
107
+ exports.ScorecardVersionSchema.index({ scorecardId: 1, version: 1 }, { unique: true });
108
+ exports.ScorecardVersionSchema.index({ scorecardId: 1, status: 1 }, { unique: true, partialFilterExpression: { status: 'active' } });
101
109
  exports.ScorecardVersionSchema.pre('save', function (next) {
102
- if (!this.isNew && this.isModified('definitionJson')) {
103
- return next(new Error('ScorecardVersion is immutable'));
110
+ if (!this.isNew && this.isModified('definition')) {
111
+ return next(new Error('ScorecardVersion definition is immutable'));
104
112
  }
105
113
  next();
106
114
  });
@@ -35,6 +35,7 @@ export interface IScorecardDefinition {
35
35
  export interface IScorecardVersion {
36
36
  scorecardId: mongoose.Types.ObjectId;
37
37
  version: string;
38
+ status: 'draft' | 'active' | 'archived';
38
39
  validFrom: Date;
39
40
  validTo?: Date;
40
41
  definition: IScorecardDefinition;
@@ -157,6 +158,12 @@ export const ScorecardVersionSchema = new mongoose.Schema<IScorecardVersion, TSc
157
158
  validTo: {
158
159
  type: Date,
159
160
  },
161
+ status: {
162
+ type: String,
163
+ enum: ['draft', 'active', 'archived'],
164
+ required: true,
165
+ index: true,
166
+ },
160
167
  definition: {
161
168
  type: mongoose.Schema.Types.Mixed,
162
169
  required: true,
@@ -170,9 +177,19 @@ export const ScorecardVersionSchema = new mongoose.Schema<IScorecardVersion, TSc
170
177
 
171
178
  export const ScorecardVersion = mongoose.model<IScorecardVersion, TScorecardVersionModel>(MODEL_NAMES.scorecardVersion, ScorecardVersionSchema);
172
179
 
180
+ ScorecardVersionSchema.index(
181
+ { scorecardId: 1, version: 1 },
182
+ { unique: true },
183
+ );
184
+
185
+ ScorecardVersionSchema.index(
186
+ { scorecardId: 1, status: 1 },
187
+ { unique: true, partialFilterExpression: { status: 'active' } }
188
+ );
189
+
173
190
  ScorecardVersionSchema.pre('save', function(next) {
174
- if (!this.isNew && this.isModified('definitionJson')) {
175
- return next(new Error('ScorecardVersion is immutable'));
191
+ if (!this.isNew && this.isModified('definition')) {
192
+ return next(new Error('ScorecardVersion definition is immutable'));
176
193
  }
177
194
  next();
178
195
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gemcap-be-common",
3
- "version": "1.4.161",
3
+ "version": "1.4.162",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {