@brimble/models 3.8.17 → 3.8.20

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.
@@ -238,6 +238,11 @@ const projectSchema = new mongoose_1.Schema({
238
238
  type: String,
239
239
  required: false,
240
240
  },
241
+ volume: {
242
+ type: mongoose_1.Schema.Types.ObjectId,
243
+ ref: "Volume",
244
+ default: null,
245
+ },
241
246
  }, { timestamps: true });
242
247
  // Partial index for the free-tier lifecycle crons. Restricts the index to
243
248
  // rows that actually carry an expiry, so paid/legacy projects stay out of it.
@@ -11,6 +11,7 @@ import { IDbImage } from "../db-image";
11
11
  import { IAutoScalingGroup } from "../auto-scaling-group";
12
12
  import { IProjectEnvironment } from "../project-environment";
13
13
  import { IRegion } from "../region";
14
+ import { IVolume } from "../volume";
14
15
  export interface IProject extends Document {
15
16
  name: string;
16
17
  healthCheckPath?: string;
@@ -94,4 +95,5 @@ export interface IProject extends Document {
94
95
  whiteListedIps?: string[];
95
96
  diskSize?: number;
96
97
  volumeMount: string;
98
+ volume: IVolume | null;
97
99
  }
@@ -1,6 +1,7 @@
1
1
  import { Document, Types } from "mongoose";
2
2
  import { IUser } from "./user";
3
3
  import { ITeam } from "./team";
4
+ import { IRegion } from "./region";
4
5
  export interface IVolume extends Document {
5
6
  name: string;
6
7
  user?: IUser;
@@ -8,7 +9,7 @@ export interface IVolume extends Document {
8
9
  size: number;
9
10
  mount_path?: string;
10
11
  csi_volume_id: string | null;
11
- region: string | null;
12
+ region: IRegion | null;
12
13
  attached_sandbox_id: Types.ObjectId | null;
13
14
  attached_project_id: Types.ObjectId | null;
14
15
  last_attached_at: Date | null;
@@ -38,8 +38,6 @@ const volumeUsageSegmentSchema = new mongoose_1.Schema({
38
38
  volumeUsageSegmentSchema.index({ user_id: 1, billed: 1, "costs.endDate": 1 });
39
39
  volumeUsageSegmentSchema.index({ team_id: 1, billed: 1, "costs.endDate": 1 });
40
40
  volumeUsageSegmentSchema.index({ volume_id: 1, "costs.endDate": 1 });
41
- // Partial unique: at most one open (endDate: null) segment per volume.
42
- // The provider relies on E11000 keyPattern.volume_id to detect race-condition duplicates.
43
41
  volumeUsageSegmentSchema.index({ volume_id: 1 }, {
44
42
  unique: true,
45
43
  partialFilterExpression: { "costs.endDate": null },
package/dist/volume.js CHANGED
@@ -18,7 +18,7 @@ const volumeSchema = new mongoose_1.Schema({
18
18
  size: { type: Number, required: true },
19
19
  mount_path: { type: String },
20
20
  csi_volume_id: { type: String, default: null },
21
- region: { type: String, default: null },
21
+ region: { type: mongoose_1.Schema.Types.ObjectId, ref: "Region", default: null },
22
22
  attached_sandbox_id: {
23
23
  type: mongoose_1.Schema.Types.ObjectId,
24
24
  ref: "Sandbox",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@brimble/models",
3
- "version": "3.8.17",
3
+ "version": "3.8.20",
4
4
  "description": "Brimble models",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
package/project/index.ts CHANGED
@@ -238,6 +238,11 @@ const projectSchema = new Schema(
238
238
  type: String,
239
239
  required: false,
240
240
  },
241
+ volume: {
242
+ type: Schema.Types.ObjectId,
243
+ ref: "Volume",
244
+ default: null,
245
+ },
241
246
  },
242
247
  { timestamps: true },
243
248
  );
@@ -1,4 +1,4 @@
1
- import { Document } from "mongoose";
1
+ import { Document, Types } from "mongoose";
2
2
  import { GIT_TYPE, PROJECT_STATUS, ServiceType } from "../../enum";
3
3
  import { IDomain } from "../domain";
4
4
  import { IEnv } from "../env";
@@ -11,6 +11,7 @@ import { IDbImage } from "../db-image";
11
11
  import { IAutoScalingGroup } from "../auto-scaling-group";
12
12
  import { IProjectEnvironment } from "../project-environment";
13
13
  import { IRegion } from "../region";
14
+ import { IVolume } from "../volume";
14
15
 
15
16
  export interface IProject extends Document {
16
17
  name: string;
@@ -95,4 +96,5 @@ export interface IProject extends Document {
95
96
  whiteListedIps?: string[];
96
97
  diskSize?: number;
97
98
  volumeMount: string;
99
+ volume: IVolume | null;
98
100
  }
package/types/volume.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  import { Document, Types } from "mongoose";
2
2
  import { IUser } from "./user";
3
3
  import { ITeam } from "./team";
4
+ import { IRegion } from "./region";
4
5
 
5
6
  export interface IVolume extends Document {
6
7
  name: string;
@@ -9,7 +10,7 @@ export interface IVolume extends Document {
9
10
  size: number;
10
11
  mount_path?: string;
11
12
  csi_volume_id: string | null;
12
- region: string | null;
13
+ region: IRegion | null;
13
14
  attached_sandbox_id: Types.ObjectId | null;
14
15
  attached_project_id: Types.ObjectId | null;
15
16
  last_attached_at: Date | null;
@@ -43,8 +43,6 @@ volumeUsageSegmentSchema.index({ user_id: 1, billed: 1, "costs.endDate": 1 });
43
43
  volumeUsageSegmentSchema.index({ team_id: 1, billed: 1, "costs.endDate": 1 });
44
44
  volumeUsageSegmentSchema.index({ volume_id: 1, "costs.endDate": 1 });
45
45
 
46
- // Partial unique: at most one open (endDate: null) segment per volume.
47
- // The provider relies on E11000 keyPattern.volume_id to detect race-condition duplicates.
48
46
  volumeUsageSegmentSchema.index(
49
47
  { volume_id: 1 },
50
48
  {
package/volume.ts CHANGED
@@ -20,7 +20,7 @@ const volumeSchema: Schema = new Schema(
20
20
  size: { type: Number, required: true },
21
21
  mount_path: { type: String },
22
22
  csi_volume_id: { type: String, default: null },
23
- region: { type: String, default: null },
23
+ region: { type: Schema.Types.ObjectId, ref: "Region", default: null },
24
24
  attached_sandbox_id: {
25
25
  type: Schema.Types.ObjectId,
26
26
  ref: "Sandbox",