@brimble/models 3.8.11 → 3.8.13
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/domain/index.js +4 -0
- package/dist/enum/index.d.ts +11 -2
- package/dist/enum/index.js +11 -1
- package/dist/index.d.ts +4 -2
- package/dist/index.js +7 -1
- package/dist/plan_configuration.js +12 -1
- package/dist/sandbox-snapshot.d.ts +30 -0
- package/dist/sandbox-snapshot.js +53 -0
- package/dist/sandbox-usage-segment.d.ts +30 -0
- package/dist/sandbox-usage-segment.js +57 -0
- package/dist/sandbox.js +25 -12
- package/dist/team.js +8 -0
- package/dist/types/domain/index.d.ts +1 -0
- package/dist/types/index.d.ts +2 -0
- package/dist/types/plan_configuration.d.ts +11 -0
- package/dist/types/sandbox-snapshot.d.ts +16 -0
- package/dist/types/sandbox-snapshot.js +2 -0
- package/dist/types/sandbox-usage-segment.d.ts +25 -0
- package/dist/types/sandbox-usage-segment.js +2 -0
- package/dist/types/sandbox.d.ts +6 -3
- package/dist/types/team.d.ts +2 -0
- package/dist/types/user.d.ts +2 -0
- package/dist/user.js +8 -0
- package/domain/index.ts +4 -0
- package/enum/index.ts +10 -0
- package/index.ts +7 -0
- package/package.json +1 -1
- package/plan_configuration.ts +12 -1
- package/sandbox-snapshot.ts +58 -0
- package/sandbox-usage-segment.ts +69 -0
- package/sandbox.ts +25 -12
- package/team.ts +8 -0
- package/types/domain/index.ts +1 -0
- package/types/index.ts +6 -0
- package/types/plan_configuration.ts +11 -0
- package/types/sandbox-snapshot.ts +17 -0
- package/types/sandbox-usage-segment.ts +28 -0
- package/types/sandbox.ts +6 -3
- package/types/team.ts +2 -0
- package/types/user.ts +2 -0
- package/user.ts +8 -0
package/dist/domain/index.js
CHANGED
package/dist/enum/index.d.ts
CHANGED
|
@@ -228,12 +228,21 @@ export declare enum SANDBOX_STATUS {
|
|
|
228
228
|
STARTING = "starting",
|
|
229
229
|
READY = "ready",
|
|
230
230
|
FAILED = "failed",
|
|
231
|
-
DESTROYED = "destroyed"
|
|
231
|
+
DESTROYED = "destroyed",
|
|
232
|
+
PAUSING = "pausing",
|
|
233
|
+
PAUSED = "paused",
|
|
234
|
+
RESUMING = "resuming"
|
|
232
235
|
}
|
|
233
236
|
export declare enum SANDBOX_DESTROY_REASON {
|
|
234
237
|
USER = "user",
|
|
235
238
|
IDLE_TTL = "idle_ttl",
|
|
236
239
|
MAX_LIFETIME = "max_lifetime",
|
|
237
240
|
FAILED = "failed",
|
|
238
|
-
ONE_SHOT_STOPPED = "one_shot_stopped"
|
|
241
|
+
ONE_SHOT_STOPPED = "one_shot_stopped",
|
|
242
|
+
PAUSED_TOO_LONG = "paused_too_long"
|
|
243
|
+
}
|
|
244
|
+
export declare enum SANDBOX_SNAPSHOT_STATUS {
|
|
245
|
+
CREATING = "creating",
|
|
246
|
+
READY = "ready",
|
|
247
|
+
FAILED = "failed"
|
|
239
248
|
}
|
package/dist/enum/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.SANDBOX_DESTROY_REASON = exports.SANDBOX_STATUS = exports.SANDBOX_TEMPLATE = exports.INVOICE_TYPE = exports.INVOICE_PAYMENT_STATUS = exports.INVOICE_STATUS = exports.COLLAB_TOOLBAR_POSITION = exports.COLLAB_THEME = exports.COLLAB_INTEGRATION_TYPE = exports.COLLAB_ANNOTATION_STATUS = exports.NomadDeploymentStatus = exports.DomainTransferStatus = exports.DomainTransferDirection = exports.DomainTransferProvider = exports.DomainRenewalStatus = exports.FrameworkApplicationType = exports.SCALING_METRIC = exports.SCALING_STRATEGY = exports.LicenseStatus = exports.JobStatus = exports.DatabaseEngine = exports.ServiceType = exports.REGION_CONTINENT = exports.PERMISSION_TYPE = exports.ROLES = exports.DNS_TYPE = exports.SERVER_STATUS = exports.OAUTH_PERMISSIONS = exports.SUBSCRIPTION_PLAN_TYPE = exports.SUBSCRIPTION_STATUS = exports.PROJECT_STATUS = exports.CARD_TYPES = exports.INTEGRATION_PROVIDERS = exports.INTEGRATION_TYPES = exports.ENVIRONMENT = exports.REQUEST_TYPE = exports.BUILD_DISABLED_BY = exports.SERVER_PROTOCOL = exports.GIT_TYPE = void 0;
|
|
3
|
+
exports.SANDBOX_SNAPSHOT_STATUS = exports.SANDBOX_DESTROY_REASON = exports.SANDBOX_STATUS = exports.SANDBOX_TEMPLATE = exports.INVOICE_TYPE = exports.INVOICE_PAYMENT_STATUS = exports.INVOICE_STATUS = exports.COLLAB_TOOLBAR_POSITION = exports.COLLAB_THEME = exports.COLLAB_INTEGRATION_TYPE = exports.COLLAB_ANNOTATION_STATUS = exports.NomadDeploymentStatus = exports.DomainTransferStatus = exports.DomainTransferDirection = exports.DomainTransferProvider = exports.DomainRenewalStatus = exports.FrameworkApplicationType = exports.SCALING_METRIC = exports.SCALING_STRATEGY = exports.LicenseStatus = exports.JobStatus = exports.DatabaseEngine = exports.ServiceType = exports.REGION_CONTINENT = exports.PERMISSION_TYPE = exports.ROLES = exports.DNS_TYPE = exports.SERVER_STATUS = exports.OAUTH_PERMISSIONS = exports.SUBSCRIPTION_PLAN_TYPE = exports.SUBSCRIPTION_STATUS = exports.PROJECT_STATUS = exports.CARD_TYPES = exports.INTEGRATION_PROVIDERS = exports.INTEGRATION_TYPES = exports.ENVIRONMENT = exports.REQUEST_TYPE = exports.BUILD_DISABLED_BY = exports.SERVER_PROTOCOL = exports.GIT_TYPE = void 0;
|
|
4
4
|
var GIT_TYPE;
|
|
5
5
|
(function (GIT_TYPE) {
|
|
6
6
|
GIT_TYPE["GITHUB"] = "GITHUB";
|
|
@@ -270,6 +270,9 @@ var SANDBOX_STATUS;
|
|
|
270
270
|
SANDBOX_STATUS["READY"] = "ready";
|
|
271
271
|
SANDBOX_STATUS["FAILED"] = "failed";
|
|
272
272
|
SANDBOX_STATUS["DESTROYED"] = "destroyed";
|
|
273
|
+
SANDBOX_STATUS["PAUSING"] = "pausing";
|
|
274
|
+
SANDBOX_STATUS["PAUSED"] = "paused";
|
|
275
|
+
SANDBOX_STATUS["RESUMING"] = "resuming";
|
|
273
276
|
})(SANDBOX_STATUS = exports.SANDBOX_STATUS || (exports.SANDBOX_STATUS = {}));
|
|
274
277
|
var SANDBOX_DESTROY_REASON;
|
|
275
278
|
(function (SANDBOX_DESTROY_REASON) {
|
|
@@ -278,4 +281,11 @@ var SANDBOX_DESTROY_REASON;
|
|
|
278
281
|
SANDBOX_DESTROY_REASON["MAX_LIFETIME"] = "max_lifetime";
|
|
279
282
|
SANDBOX_DESTROY_REASON["FAILED"] = "failed";
|
|
280
283
|
SANDBOX_DESTROY_REASON["ONE_SHOT_STOPPED"] = "one_shot_stopped";
|
|
284
|
+
SANDBOX_DESTROY_REASON["PAUSED_TOO_LONG"] = "paused_too_long";
|
|
281
285
|
})(SANDBOX_DESTROY_REASON = exports.SANDBOX_DESTROY_REASON || (exports.SANDBOX_DESTROY_REASON = {}));
|
|
286
|
+
var SANDBOX_SNAPSHOT_STATUS;
|
|
287
|
+
(function (SANDBOX_SNAPSHOT_STATUS) {
|
|
288
|
+
SANDBOX_SNAPSHOT_STATUS["CREATING"] = "creating";
|
|
289
|
+
SANDBOX_SNAPSHOT_STATUS["READY"] = "ready";
|
|
290
|
+
SANDBOX_SNAPSHOT_STATUS["FAILED"] = "failed";
|
|
291
|
+
})(SANDBOX_SNAPSHOT_STATUS = exports.SANDBOX_SNAPSHOT_STATUS || (exports.SANDBOX_SNAPSHOT_STATUS = {}));
|
package/dist/index.d.ts
CHANGED
|
@@ -55,8 +55,10 @@ export { default as ActivityLog } from "./activity-log";
|
|
|
55
55
|
export { default as OwnershipTransfer } from "./ownership-transfer";
|
|
56
56
|
export { default as Sandbox } from "./sandbox";
|
|
57
57
|
export { default as SandboxImage } from "./sandbox-image";
|
|
58
|
-
export {
|
|
59
|
-
export {
|
|
58
|
+
export { default as SandboxSnapshot } from "./sandbox-snapshot";
|
|
59
|
+
export { default as SandboxUsageSegment } from "./sandbox-usage-segment";
|
|
60
|
+
export { IUser, IGit, IProject, IProjectAnalytics, IPreview, IProjectConnection, IFollowing, IIntegration, IEnv, IServer, IDomain, IToken, IMember, ITeam, IInstalledIntegration, ILog, ISubscription, ICard, IDns, IRole, IPermission, IMemberPermission, IWallet, IDbImage, IJob, ILicense, IPlanConfiguration, IAutoScalingGroup, IComputeChange, IRegion, IVolume, IFramework, BrimbleFrameworkType, ISettings, ILoadBalancerPort, IDomainRenewal, IDomainTransfer, IWebhookCategory, IWebhookEvent, IWebhookSetting, IIntention, IProvider, ICollabAnnotation, ICollabComment, ICollabAttachment, ICollabIntegration, ICollabSettings, ICollabShareToken, ICollabPushSubscription, IAppMessage, IInvoice, ITag, IProjectTagAssignment, ICashierSubscription, ICashierSubscriptionItem, IProjectEnvironment, IEnvironmentVariable, IActivityLog, IOwnershipTransfer, ISandbox, ISandboxSpecs, ISandboxImage, ISandboxSnapshot, ISandboxUsageSegment, ISandboxUsageSegmentCurrent, ISandboxUsageSegmentCosts, } from "./types";
|
|
61
|
+
export { GIT_TYPE, INTEGRATION_TYPES, INTEGRATION_PROVIDERS, OAUTH_PERMISSIONS, ENVIRONMENT, SERVER_STATUS, ROLES, SUBSCRIPTION_PLAN_TYPE, PROJECT_STATUS, SUBSCRIPTION_STATUS, CARD_TYPES, DNS_TYPE, PERMISSION_TYPE, REQUEST_TYPE, ServiceType, DatabaseEngine, JobStatus, LicenseStatus, REGION_CONTINENT, BUILD_DISABLED_BY, SERVER_PROTOCOL, FrameworkApplicationType, DomainRenewalStatus, DomainTransferProvider, DomainTransferDirection, DomainTransferStatus, NomadDeploymentStatus, COLLAB_ANNOTATION_STATUS, COLLAB_INTEGRATION_TYPE, COLLAB_THEME, COLLAB_TOOLBAR_POSITION, INVOICE_STATUS, INVOICE_PAYMENT_STATUS, INVOICE_TYPE, SANDBOX_TEMPLATE, SANDBOX_STATUS, SANDBOX_DESTROY_REASON, SANDBOX_SNAPSHOT_STATUS, } from "./enum";
|
|
60
62
|
import mongoose from "mongoose";
|
|
61
63
|
export declare const connectToMongo: (mongoUrl: string, config?: mongoose.ConnectOptions) => Promise<void>;
|
|
62
64
|
export declare const db: mongoose.Connection;
|
package/dist/index.js
CHANGED
|
@@ -13,7 +13,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
13
13
|
};
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
15
|
exports.ProjectTagAssignment = exports.Tag = exports.Invoice = exports.AppMessage = exports.CollabPushSubscription = exports.CollabShareToken = exports.CollabSettings = exports.CollabIntegration = exports.CollabComment = exports.CollabAnnotation = exports.Provider = exports.Intention = exports.WebhookSetting = exports.WebhookEvent = exports.WebhookCategory = exports.DomainTransfer = exports.DomainRenewal = exports.LoadBalancerPort = exports.Settings = exports.Framework = exports.Volume = exports.Region = exports.ComputeChange = exports.AutoScalingGroup = exports.PlanConfiguration = exports.Liscense = exports.Job = exports.DbImage = exports.Wallet = exports.Server = exports.Card = exports.Subscription = exports.Log = exports.Role = exports.MemberPermission = exports.Permission = exports.Member = exports.Team = exports.Token = exports.Env = exports.Dns = exports.Domain = exports.Integration = exports.Following = exports.ProjectConnection = exports.Preview = exports.ProjectAnalytics = exports.DeletedProject = exports.Project = exports.User = void 0;
|
|
16
|
-
exports.
|
|
16
|
+
exports.db = exports.connectToMongo = exports.SANDBOX_SNAPSHOT_STATUS = exports.SANDBOX_DESTROY_REASON = exports.SANDBOX_STATUS = exports.SANDBOX_TEMPLATE = exports.INVOICE_TYPE = exports.INVOICE_PAYMENT_STATUS = exports.INVOICE_STATUS = exports.COLLAB_TOOLBAR_POSITION = exports.COLLAB_THEME = exports.COLLAB_INTEGRATION_TYPE = exports.COLLAB_ANNOTATION_STATUS = exports.NomadDeploymentStatus = exports.DomainTransferStatus = exports.DomainTransferDirection = exports.DomainTransferProvider = exports.DomainRenewalStatus = exports.FrameworkApplicationType = exports.SERVER_PROTOCOL = exports.BUILD_DISABLED_BY = exports.REGION_CONTINENT = exports.LicenseStatus = exports.JobStatus = exports.DatabaseEngine = exports.ServiceType = exports.REQUEST_TYPE = exports.PERMISSION_TYPE = exports.DNS_TYPE = exports.CARD_TYPES = exports.SUBSCRIPTION_STATUS = exports.PROJECT_STATUS = exports.SUBSCRIPTION_PLAN_TYPE = exports.ROLES = exports.SERVER_STATUS = exports.ENVIRONMENT = exports.OAUTH_PERMISSIONS = exports.INTEGRATION_PROVIDERS = exports.INTEGRATION_TYPES = exports.GIT_TYPE = exports.SandboxUsageSegment = exports.SandboxSnapshot = exports.SandboxImage = exports.Sandbox = exports.OwnershipTransfer = exports.ActivityLog = exports.EnvironmentVariable = exports.ProjectEnvironment = exports.CashierSubscriptionItem = exports.CashierSubscription = void 0;
|
|
17
|
+
exports.healthCheckMongo = exports.closeMongo = void 0;
|
|
17
18
|
var user_1 = require("./user");
|
|
18
19
|
Object.defineProperty(exports, "User", { enumerable: true, get: function () { return __importDefault(user_1).default; } });
|
|
19
20
|
var project_1 = require("./project");
|
|
@@ -129,6 +130,10 @@ var sandbox_1 = require("./sandbox");
|
|
|
129
130
|
Object.defineProperty(exports, "Sandbox", { enumerable: true, get: function () { return __importDefault(sandbox_1).default; } });
|
|
130
131
|
var sandbox_image_1 = require("./sandbox-image");
|
|
131
132
|
Object.defineProperty(exports, "SandboxImage", { enumerable: true, get: function () { return __importDefault(sandbox_image_1).default; } });
|
|
133
|
+
var sandbox_snapshot_1 = require("./sandbox-snapshot");
|
|
134
|
+
Object.defineProperty(exports, "SandboxSnapshot", { enumerable: true, get: function () { return __importDefault(sandbox_snapshot_1).default; } });
|
|
135
|
+
var sandbox_usage_segment_1 = require("./sandbox-usage-segment");
|
|
136
|
+
Object.defineProperty(exports, "SandboxUsageSegment", { enumerable: true, get: function () { return __importDefault(sandbox_usage_segment_1).default; } });
|
|
132
137
|
var enum_1 = require("./enum");
|
|
133
138
|
Object.defineProperty(exports, "GIT_TYPE", { enumerable: true, get: function () { return enum_1.GIT_TYPE; } });
|
|
134
139
|
Object.defineProperty(exports, "INTEGRATION_TYPES", { enumerable: true, get: function () { return enum_1.INTEGRATION_TYPES; } });
|
|
@@ -167,6 +172,7 @@ Object.defineProperty(exports, "INVOICE_TYPE", { enumerable: true, get: function
|
|
|
167
172
|
Object.defineProperty(exports, "SANDBOX_TEMPLATE", { enumerable: true, get: function () { return enum_1.SANDBOX_TEMPLATE; } });
|
|
168
173
|
Object.defineProperty(exports, "SANDBOX_STATUS", { enumerable: true, get: function () { return enum_1.SANDBOX_STATUS; } });
|
|
169
174
|
Object.defineProperty(exports, "SANDBOX_DESTROY_REASON", { enumerable: true, get: function () { return enum_1.SANDBOX_DESTROY_REASON; } });
|
|
175
|
+
Object.defineProperty(exports, "SANDBOX_SNAPSHOT_STATUS", { enumerable: true, get: function () { return enum_1.SANDBOX_SNAPSHOT_STATUS; } });
|
|
170
176
|
const mongoose_1 = __importDefault(require("mongoose"));
|
|
171
177
|
const utils_1 = require("@brimble/utils");
|
|
172
178
|
const connectToMongo = (mongoUrl, config) => __awaiter(void 0, void 0, void 0, function* () {
|
|
@@ -40,6 +40,17 @@ const PlanConfigurationSchema = new mongoose_1.Schema({
|
|
|
40
40
|
can_deploy_all_applications: { type: Boolean, required: true, default: false },
|
|
41
41
|
stripe_prices: { type: mongoose_1.Schema.Types.Mixed, required: false, default: {} },
|
|
42
42
|
sandbox_max_count: { type: Number, required: false, default: 3 },
|
|
43
|
-
|
|
43
|
+
sanxbox_hours_max: { type: Number, required: false, default: 16 },
|
|
44
|
+
sandbox_enabled: { type: Boolean, required: false, default: true },
|
|
45
|
+
sandbox_cpu_hours_included: { type: Number, default: 0 },
|
|
46
|
+
sandbox_memory_gb_hours_included: { type: Number, default: 0 },
|
|
47
|
+
sandbox_max_runtime_minutes: { type: Number, default: 0 },
|
|
48
|
+
sandbox_max_vcpu: { type: Number, default: 0 },
|
|
49
|
+
sandbox_max_memory_gb: { type: Number, default: 0 },
|
|
50
|
+
sandbox_creation_rate_per_minute: { type: Number, default: 0 },
|
|
51
|
+
sandbox_cpu_overage_price: { type: Number, default: 0 },
|
|
52
|
+
sandbox_memory_overage_price: { type: Number, default: 0 },
|
|
53
|
+
sandbox_snapshot_storage_price: { type: Number, default: 0 },
|
|
54
|
+
sandbox_snapshot_gb_months_included: { type: Number, default: 0 }
|
|
44
55
|
}, { timestamps: true });
|
|
45
56
|
exports.default = (0, mongoose_1.model)("PlanConfigurations", PlanConfigurationSchema, "plan_configurations");
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/// <reference types="mongoose/types/aggregate" />
|
|
2
|
+
/// <reference types="mongoose/types/callback" />
|
|
3
|
+
/// <reference types="mongoose/types/collection" />
|
|
4
|
+
/// <reference types="mongoose/types/connection" />
|
|
5
|
+
/// <reference types="mongoose/types/cursor" />
|
|
6
|
+
/// <reference types="mongoose/types/document" />
|
|
7
|
+
/// <reference types="mongoose/types/error" />
|
|
8
|
+
/// <reference types="mongoose/types/expressions" />
|
|
9
|
+
/// <reference types="mongoose/types/helpers" />
|
|
10
|
+
/// <reference types="mongoose/types/middlewares" />
|
|
11
|
+
/// <reference types="mongoose/types/indexes" />
|
|
12
|
+
/// <reference types="mongoose/types/models" />
|
|
13
|
+
/// <reference types="mongoose/types/mongooseoptions" />
|
|
14
|
+
/// <reference types="mongoose/types/pipelinestage" />
|
|
15
|
+
/// <reference types="mongoose/types/populate" />
|
|
16
|
+
/// <reference types="mongoose/types/query" />
|
|
17
|
+
/// <reference types="mongoose/types/schemaoptions" />
|
|
18
|
+
/// <reference types="mongoose/types/schematypes" />
|
|
19
|
+
/// <reference types="mongoose/types/session" />
|
|
20
|
+
/// <reference types="mongoose/types/types" />
|
|
21
|
+
/// <reference types="mongoose/types/utility" />
|
|
22
|
+
/// <reference types="mongoose/types/validation" />
|
|
23
|
+
/// <reference types="mongoose/types/virtuals" />
|
|
24
|
+
/// <reference types="mongoose" />
|
|
25
|
+
/// <reference types="mongoose/types/inferschematype" />
|
|
26
|
+
import { ISandboxSnapshot } from "./types/sandbox-snapshot";
|
|
27
|
+
declare const _default: import("mongoose").Model<ISandboxSnapshot, {}, {}, {}, import("mongoose").Document<unknown, {}, ISandboxSnapshot> & ISandboxSnapshot & {
|
|
28
|
+
_id: import("mongoose").Types.ObjectId;
|
|
29
|
+
}, any>;
|
|
30
|
+
export default _default;
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const mongoose_1 = require("mongoose");
|
|
4
|
+
const soft_delete_plugin_mongoose_1 = require("soft-delete-plugin-mongoose");
|
|
5
|
+
const enum_1 = require("./enum");
|
|
6
|
+
const sandboxSnapshotSchema = new mongoose_1.Schema({
|
|
7
|
+
user_id: {
|
|
8
|
+
type: mongoose_1.Schema.Types.ObjectId,
|
|
9
|
+
ref: "User",
|
|
10
|
+
required: true,
|
|
11
|
+
index: true,
|
|
12
|
+
},
|
|
13
|
+
team: {
|
|
14
|
+
type: mongoose_1.Schema.Types.ObjectId,
|
|
15
|
+
ref: "Team",
|
|
16
|
+
default: null,
|
|
17
|
+
index: true,
|
|
18
|
+
},
|
|
19
|
+
sandbox_id: {
|
|
20
|
+
type: mongoose_1.Schema.Types.ObjectId,
|
|
21
|
+
ref: "Sandbox",
|
|
22
|
+
required: true,
|
|
23
|
+
index: true,
|
|
24
|
+
},
|
|
25
|
+
name: {
|
|
26
|
+
type: String,
|
|
27
|
+
required: true,
|
|
28
|
+
match: /^[a-z0-9-]{1,40}$/,
|
|
29
|
+
},
|
|
30
|
+
image_tag: {
|
|
31
|
+
type: String,
|
|
32
|
+
required: true,
|
|
33
|
+
},
|
|
34
|
+
source_template: {
|
|
35
|
+
type: String,
|
|
36
|
+
required: true,
|
|
37
|
+
},
|
|
38
|
+
status: {
|
|
39
|
+
type: String,
|
|
40
|
+
enum: Object.values(enum_1.SANDBOX_SNAPSHOT_STATUS),
|
|
41
|
+
default: enum_1.SANDBOX_SNAPSHOT_STATUS.CREATING,
|
|
42
|
+
},
|
|
43
|
+
failure_reason: {
|
|
44
|
+
type: String,
|
|
45
|
+
default: null,
|
|
46
|
+
},
|
|
47
|
+
size_bytes: {
|
|
48
|
+
type: Number,
|
|
49
|
+
default: null,
|
|
50
|
+
},
|
|
51
|
+
}, { timestamps: { createdAt: "created_at", updatedAt: "updated_at" } });
|
|
52
|
+
sandboxSnapshotSchema.plugin(soft_delete_plugin_mongoose_1.softDeletePlugin);
|
|
53
|
+
exports.default = (0, mongoose_1.model)("SandboxSnapshot", sandboxSnapshotSchema);
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/// <reference types="mongoose/types/aggregate" />
|
|
2
|
+
/// <reference types="mongoose/types/callback" />
|
|
3
|
+
/// <reference types="mongoose/types/collection" />
|
|
4
|
+
/// <reference types="mongoose/types/connection" />
|
|
5
|
+
/// <reference types="mongoose/types/cursor" />
|
|
6
|
+
/// <reference types="mongoose/types/document" />
|
|
7
|
+
/// <reference types="mongoose/types/error" />
|
|
8
|
+
/// <reference types="mongoose/types/expressions" />
|
|
9
|
+
/// <reference types="mongoose/types/helpers" />
|
|
10
|
+
/// <reference types="mongoose/types/middlewares" />
|
|
11
|
+
/// <reference types="mongoose/types/indexes" />
|
|
12
|
+
/// <reference types="mongoose/types/models" />
|
|
13
|
+
/// <reference types="mongoose/types/mongooseoptions" />
|
|
14
|
+
/// <reference types="mongoose/types/pipelinestage" />
|
|
15
|
+
/// <reference types="mongoose/types/populate" />
|
|
16
|
+
/// <reference types="mongoose/types/query" />
|
|
17
|
+
/// <reference types="mongoose/types/schemaoptions" />
|
|
18
|
+
/// <reference types="mongoose/types/schematypes" />
|
|
19
|
+
/// <reference types="mongoose/types/session" />
|
|
20
|
+
/// <reference types="mongoose/types/types" />
|
|
21
|
+
/// <reference types="mongoose/types/utility" />
|
|
22
|
+
/// <reference types="mongoose/types/validation" />
|
|
23
|
+
/// <reference types="mongoose/types/virtuals" />
|
|
24
|
+
/// <reference types="mongoose" />
|
|
25
|
+
/// <reference types="mongoose/types/inferschematype" />
|
|
26
|
+
import { ISandboxUsageSegment } from "./types/sandbox-usage-segment";
|
|
27
|
+
declare const _default: import("mongoose").Model<ISandboxUsageSegment, {}, {}, {}, import("mongoose").Document<unknown, {}, ISandboxUsageSegment> & ISandboxUsageSegment & {
|
|
28
|
+
_id: import("mongoose").Types.ObjectId;
|
|
29
|
+
}, any>;
|
|
30
|
+
export default _default;
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const mongoose_1 = require("mongoose");
|
|
4
|
+
const sandboxUsageSegmentSchema = new mongoose_1.Schema({
|
|
5
|
+
sandbox_id: {
|
|
6
|
+
type: mongoose_1.Schema.Types.ObjectId,
|
|
7
|
+
ref: "Sandbox",
|
|
8
|
+
required: true,
|
|
9
|
+
index: true,
|
|
10
|
+
},
|
|
11
|
+
user_id: {
|
|
12
|
+
type: mongoose_1.Schema.Types.ObjectId,
|
|
13
|
+
ref: "User",
|
|
14
|
+
required: true,
|
|
15
|
+
index: true,
|
|
16
|
+
},
|
|
17
|
+
team_id: {
|
|
18
|
+
type: mongoose_1.Schema.Types.ObjectId,
|
|
19
|
+
ref: "Team",
|
|
20
|
+
required: false,
|
|
21
|
+
index: true,
|
|
22
|
+
default: null,
|
|
23
|
+
},
|
|
24
|
+
current: {
|
|
25
|
+
cpu: { type: Number, required: true },
|
|
26
|
+
memory: { type: Number, required: true },
|
|
27
|
+
storage: { type: Number, required: true },
|
|
28
|
+
},
|
|
29
|
+
costs: {
|
|
30
|
+
startDate: { type: Date, required: true },
|
|
31
|
+
endDate: { type: Date, default: null },
|
|
32
|
+
},
|
|
33
|
+
billed: {
|
|
34
|
+
type: Boolean,
|
|
35
|
+
default: false,
|
|
36
|
+
index: true,
|
|
37
|
+
},
|
|
38
|
+
region: {
|
|
39
|
+
type: String,
|
|
40
|
+
required: false,
|
|
41
|
+
},
|
|
42
|
+
template: {
|
|
43
|
+
type: String,
|
|
44
|
+
required: false,
|
|
45
|
+
},
|
|
46
|
+
}, {
|
|
47
|
+
timestamps: true,
|
|
48
|
+
});
|
|
49
|
+
sandboxUsageSegmentSchema.index({ user_id: 1, billed: 1, "costs.endDate": 1 });
|
|
50
|
+
sandboxUsageSegmentSchema.index({ team_id: 1, billed: 1, "costs.endDate": 1 });
|
|
51
|
+
sandboxUsageSegmentSchema.index({ sandbox_id: 1, "costs.endDate": 1 });
|
|
52
|
+
sandboxUsageSegmentSchema.index({ sandbox_id: 1 }, {
|
|
53
|
+
unique: true,
|
|
54
|
+
partialFilterExpression: { "costs.endDate": null },
|
|
55
|
+
name: "uniq_open_sandbox_usage_segment_per_sandbox",
|
|
56
|
+
});
|
|
57
|
+
exports.default = (0, mongoose_1.model)("SandboxUsageSegment", sandboxUsageSegmentSchema, "sandbox_usage_segments");
|
package/dist/sandbox.js
CHANGED
|
@@ -36,18 +36,6 @@ const sandboxSchema = new mongoose_1.Schema({
|
|
|
36
36
|
type: String,
|
|
37
37
|
default: null,
|
|
38
38
|
},
|
|
39
|
-
host: {
|
|
40
|
-
type: String,
|
|
41
|
-
default: null,
|
|
42
|
-
},
|
|
43
|
-
port: {
|
|
44
|
-
type: Number,
|
|
45
|
-
default: null,
|
|
46
|
-
},
|
|
47
|
-
agent_token_hash: {
|
|
48
|
-
type: String,
|
|
49
|
-
default: null,
|
|
50
|
-
},
|
|
51
39
|
region: {
|
|
52
40
|
type: String,
|
|
53
41
|
required: true,
|
|
@@ -94,6 +82,31 @@ const sandboxSchema = new mongoose_1.Schema({
|
|
|
94
82
|
type: Boolean,
|
|
95
83
|
default: false,
|
|
96
84
|
},
|
|
85
|
+
persistent: {
|
|
86
|
+
type: Boolean,
|
|
87
|
+
default: false,
|
|
88
|
+
},
|
|
89
|
+
persistent_disk_gb: {
|
|
90
|
+
type: Number,
|
|
91
|
+
default: null,
|
|
92
|
+
},
|
|
93
|
+
csi_volume_id: {
|
|
94
|
+
type: String,
|
|
95
|
+
default: null,
|
|
96
|
+
},
|
|
97
|
+
paused_at: {
|
|
98
|
+
type: Date,
|
|
99
|
+
default: null,
|
|
100
|
+
},
|
|
101
|
+
image_override: {
|
|
102
|
+
type: String,
|
|
103
|
+
default: null,
|
|
104
|
+
},
|
|
105
|
+
from_snapshot: {
|
|
106
|
+
type: mongoose_1.Schema.Types.ObjectId,
|
|
107
|
+
ref: "SandboxSnapshot",
|
|
108
|
+
default: null,
|
|
109
|
+
},
|
|
97
110
|
isDeleted: {
|
|
98
111
|
type: Boolean,
|
|
99
112
|
default: false,
|
package/dist/team.js
CHANGED
|
@@ -46,6 +46,14 @@ const teamSchema = new mongoose_1.Schema({
|
|
|
46
46
|
type: Boolean,
|
|
47
47
|
default: false,
|
|
48
48
|
},
|
|
49
|
+
sandbox_disabled: {
|
|
50
|
+
type: Boolean,
|
|
51
|
+
default: false,
|
|
52
|
+
},
|
|
53
|
+
sandbox_disabled_by: {
|
|
54
|
+
type: String,
|
|
55
|
+
default: null,
|
|
56
|
+
},
|
|
49
57
|
subscription: {
|
|
50
58
|
type: mongoose_1.Schema.Types.ObjectId,
|
|
51
59
|
required: false,
|
package/dist/types/index.d.ts
CHANGED
|
@@ -56,3 +56,5 @@ export type { IActivityLog } from "./activity-log";
|
|
|
56
56
|
export type { IOwnershipTransfer } from "./ownership-transfer";
|
|
57
57
|
export type { ISandbox, ISandboxSpecs } from "./sandbox";
|
|
58
58
|
export type { ISandboxImage } from "./sandbox-image";
|
|
59
|
+
export type { ISandboxSnapshot } from "./sandbox-snapshot";
|
|
60
|
+
export type { ISandboxUsageSegment, ISandboxUsageSegmentCurrent, ISandboxUsageSegmentCosts, } from "./sandbox-usage-segment";
|
|
@@ -35,5 +35,16 @@ export interface IPlanConfiguration extends Document {
|
|
|
35
35
|
can_deploy_all_applications: boolean;
|
|
36
36
|
stripe_prices?: Record<string, string>;
|
|
37
37
|
sandbox_max_count: number;
|
|
38
|
+
sanxbox_hours_max: number;
|
|
38
39
|
sandbox_enabled: boolean;
|
|
40
|
+
sandbox_cpu_hours_included: number;
|
|
41
|
+
sandbox_memory_gb_hours_included: number;
|
|
42
|
+
sandbox_max_runtime_minutes: number;
|
|
43
|
+
sandbox_max_vcpu: number;
|
|
44
|
+
sandbox_max_memory_gb: number;
|
|
45
|
+
sandbox_creation_rate_per_minute: number;
|
|
46
|
+
sandbox_cpu_overage_price: number;
|
|
47
|
+
sandbox_memory_overage_price: number;
|
|
48
|
+
sandbox_snapshot_storage_price: number;
|
|
49
|
+
sandbox_snapshot_gb_months_included: number;
|
|
39
50
|
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { Document, Types } from "mongoose";
|
|
2
|
+
import { SANDBOX_SNAPSHOT_STATUS } from "../enum";
|
|
3
|
+
export interface ISandboxSnapshot extends Document {
|
|
4
|
+
user_id: Types.ObjectId;
|
|
5
|
+
team: Types.ObjectId | null;
|
|
6
|
+
sandbox_id: Types.ObjectId;
|
|
7
|
+
name: string;
|
|
8
|
+
image_tag: string;
|
|
9
|
+
source_template: string;
|
|
10
|
+
status: SANDBOX_SNAPSHOT_STATUS;
|
|
11
|
+
failure_reason: string | null;
|
|
12
|
+
size_bytes: number | null;
|
|
13
|
+
created_at: Date;
|
|
14
|
+
updated_at: Date;
|
|
15
|
+
isDeleted: boolean;
|
|
16
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { Document, Types } from "mongoose";
|
|
2
|
+
import { ISandbox } from "./sandbox";
|
|
3
|
+
import { IUser } from "./user";
|
|
4
|
+
import { ITeam } from "./team";
|
|
5
|
+
export interface ISandboxUsageSegmentCurrent {
|
|
6
|
+
cpu: number;
|
|
7
|
+
memory: number;
|
|
8
|
+
storage: number;
|
|
9
|
+
}
|
|
10
|
+
export interface ISandboxUsageSegmentCosts {
|
|
11
|
+
startDate: Date;
|
|
12
|
+
endDate: Date | null;
|
|
13
|
+
}
|
|
14
|
+
export interface ISandboxUsageSegment extends Document {
|
|
15
|
+
sandbox_id: ISandbox | Types.ObjectId;
|
|
16
|
+
user_id: IUser | Types.ObjectId;
|
|
17
|
+
team_id: ITeam | Types.ObjectId | null;
|
|
18
|
+
current: ISandboxUsageSegmentCurrent;
|
|
19
|
+
costs: ISandboxUsageSegmentCosts;
|
|
20
|
+
billed: boolean;
|
|
21
|
+
region?: string;
|
|
22
|
+
template?: string;
|
|
23
|
+
createdAt: Date;
|
|
24
|
+
updatedAt: Date;
|
|
25
|
+
}
|
package/dist/types/sandbox.d.ts
CHANGED
|
@@ -16,9 +16,6 @@ export interface ISandbox extends Document {
|
|
|
16
16
|
status: SANDBOX_STATUS;
|
|
17
17
|
nomad_job_id: string;
|
|
18
18
|
nomad_alloc_id: string | null;
|
|
19
|
-
host: string | null;
|
|
20
|
-
port: number | null;
|
|
21
|
-
agent_token_hash: string | null;
|
|
22
19
|
region: string;
|
|
23
20
|
specs: ISandboxSpecs;
|
|
24
21
|
created_at: Date;
|
|
@@ -30,5 +27,11 @@ export interface ISandbox extends Document {
|
|
|
30
27
|
destroy_timeout: string | null;
|
|
31
28
|
one_shot: boolean;
|
|
32
29
|
block_outbound: boolean;
|
|
30
|
+
persistent: boolean;
|
|
31
|
+
persistent_disk_gb: number | null;
|
|
32
|
+
csi_volume_id: string | null;
|
|
33
|
+
paused_at: Date | null;
|
|
34
|
+
image_override: string | null;
|
|
35
|
+
from_snapshot: Types.ObjectId | null;
|
|
33
36
|
isDeleted: boolean;
|
|
34
37
|
}
|
package/dist/types/team.d.ts
CHANGED
|
@@ -15,6 +15,8 @@ export interface ITeam extends Document {
|
|
|
15
15
|
build_minutes_cycle_anchor: Date | null;
|
|
16
16
|
build_disabled: boolean;
|
|
17
17
|
build_disabled_by: BUILD_DISABLED_BY;
|
|
18
|
+
sandbox_disabled: boolean;
|
|
19
|
+
sandbox_disabled_by: "system" | "payment_failure" | null;
|
|
18
20
|
subscription: ISubscription;
|
|
19
21
|
enforce_2fa: boolean;
|
|
20
22
|
enforce_2fa_at: Date | null;
|
package/dist/types/user.d.ts
CHANGED
|
@@ -27,6 +27,8 @@ export interface IUser extends Document {
|
|
|
27
27
|
is_waitlist: boolean;
|
|
28
28
|
build_disabled: boolean;
|
|
29
29
|
build_disabled_by: BUILD_DISABLED_BY;
|
|
30
|
+
sandbox_disabled: boolean;
|
|
31
|
+
sandbox_disabled_by: "system" | "payment_failure" | null;
|
|
30
32
|
spending_limit: number;
|
|
31
33
|
build_minutes: number;
|
|
32
34
|
disabled: boolean;
|
package/dist/user.js
CHANGED
|
@@ -39,6 +39,14 @@ const userSchema = new mongoose_1.Schema({
|
|
|
39
39
|
type: String,
|
|
40
40
|
required: false,
|
|
41
41
|
},
|
|
42
|
+
sandbox_disabled: {
|
|
43
|
+
type: Boolean,
|
|
44
|
+
default: false,
|
|
45
|
+
},
|
|
46
|
+
sandbox_disabled_by: {
|
|
47
|
+
type: String,
|
|
48
|
+
default: null,
|
|
49
|
+
},
|
|
42
50
|
ai_usage_count: {
|
|
43
51
|
type: Number,
|
|
44
52
|
default: 0,
|
package/domain/index.ts
CHANGED
package/enum/index.ts
CHANGED
|
@@ -266,6 +266,9 @@ export enum SANDBOX_STATUS {
|
|
|
266
266
|
READY = "ready",
|
|
267
267
|
FAILED = "failed",
|
|
268
268
|
DESTROYED = "destroyed",
|
|
269
|
+
PAUSING = "pausing",
|
|
270
|
+
PAUSED = "paused",
|
|
271
|
+
RESUMING = "resuming",
|
|
269
272
|
}
|
|
270
273
|
|
|
271
274
|
export enum SANDBOX_DESTROY_REASON {
|
|
@@ -274,4 +277,11 @@ export enum SANDBOX_DESTROY_REASON {
|
|
|
274
277
|
MAX_LIFETIME = "max_lifetime",
|
|
275
278
|
FAILED = "failed",
|
|
276
279
|
ONE_SHOT_STOPPED = "one_shot_stopped",
|
|
280
|
+
PAUSED_TOO_LONG = "paused_too_long",
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
export enum SANDBOX_SNAPSHOT_STATUS {
|
|
284
|
+
CREATING = "creating",
|
|
285
|
+
READY = "ready",
|
|
286
|
+
FAILED = "failed",
|
|
277
287
|
}
|
package/index.ts
CHANGED
|
@@ -55,6 +55,8 @@ export { default as ActivityLog } from "./activity-log";
|
|
|
55
55
|
export { default as OwnershipTransfer } from "./ownership-transfer";
|
|
56
56
|
export { default as Sandbox } from "./sandbox";
|
|
57
57
|
export { default as SandboxImage } from "./sandbox-image";
|
|
58
|
+
export { default as SandboxSnapshot } from "./sandbox-snapshot";
|
|
59
|
+
export { default as SandboxUsageSegment } from "./sandbox-usage-segment";
|
|
58
60
|
|
|
59
61
|
export {
|
|
60
62
|
IUser,
|
|
@@ -119,6 +121,10 @@ export {
|
|
|
119
121
|
ISandbox,
|
|
120
122
|
ISandboxSpecs,
|
|
121
123
|
ISandboxImage,
|
|
124
|
+
ISandboxSnapshot,
|
|
125
|
+
ISandboxUsageSegment,
|
|
126
|
+
ISandboxUsageSegmentCurrent,
|
|
127
|
+
ISandboxUsageSegmentCosts,
|
|
122
128
|
} from "./types";
|
|
123
129
|
export {
|
|
124
130
|
GIT_TYPE,
|
|
@@ -158,6 +164,7 @@ export {
|
|
|
158
164
|
SANDBOX_TEMPLATE,
|
|
159
165
|
SANDBOX_STATUS,
|
|
160
166
|
SANDBOX_DESTROY_REASON,
|
|
167
|
+
SANDBOX_SNAPSHOT_STATUS,
|
|
161
168
|
} from "./enum";
|
|
162
169
|
|
|
163
170
|
import mongoose from "mongoose";
|
package/package.json
CHANGED
package/plan_configuration.ts
CHANGED
|
@@ -41,7 +41,18 @@ const PlanConfigurationSchema = new Schema<IPlanConfiguration>(
|
|
|
41
41
|
can_deploy_all_applications: { type: Boolean, required: true, default: false },
|
|
42
42
|
stripe_prices: { type: Schema.Types.Mixed, required: false, default: {} },
|
|
43
43
|
sandbox_max_count: { type: Number, required: false, default: 3 },
|
|
44
|
-
|
|
44
|
+
sanxbox_hours_max: { type: Number, required: false, default: 16},
|
|
45
|
+
sandbox_enabled: { type: Boolean, required: false, default: true },
|
|
46
|
+
sandbox_cpu_hours_included: { type: Number, default: 0 },
|
|
47
|
+
sandbox_memory_gb_hours_included: { type: Number, default: 0 },
|
|
48
|
+
sandbox_max_runtime_minutes: { type: Number, default: 0 },
|
|
49
|
+
sandbox_max_vcpu: { type: Number, default: 0 },
|
|
50
|
+
sandbox_max_memory_gb: { type: Number, default: 0 },
|
|
51
|
+
sandbox_creation_rate_per_minute: { type: Number, default: 0 },
|
|
52
|
+
sandbox_cpu_overage_price: { type: Number, default: 0 },
|
|
53
|
+
sandbox_memory_overage_price: { type: Number, default: 0 },
|
|
54
|
+
sandbox_snapshot_storage_price: { type: Number, default: 0 },
|
|
55
|
+
sandbox_snapshot_gb_months_included: { type: Number, default: 0 }
|
|
45
56
|
},
|
|
46
57
|
{ timestamps: true },
|
|
47
58
|
);
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { model, Schema } from "mongoose";
|
|
2
|
+
import { softDeletePlugin } from "soft-delete-plugin-mongoose";
|
|
3
|
+
import { ISandboxSnapshot } from "./types/sandbox-snapshot";
|
|
4
|
+
import { SANDBOX_SNAPSHOT_STATUS } from "./enum";
|
|
5
|
+
|
|
6
|
+
const sandboxSnapshotSchema: Schema = new Schema(
|
|
7
|
+
{
|
|
8
|
+
user_id: {
|
|
9
|
+
type: Schema.Types.ObjectId,
|
|
10
|
+
ref: "User",
|
|
11
|
+
required: true,
|
|
12
|
+
index: true,
|
|
13
|
+
},
|
|
14
|
+
team: {
|
|
15
|
+
type: Schema.Types.ObjectId,
|
|
16
|
+
ref: "Team",
|
|
17
|
+
default: null,
|
|
18
|
+
index: true,
|
|
19
|
+
},
|
|
20
|
+
sandbox_id: {
|
|
21
|
+
type: Schema.Types.ObjectId,
|
|
22
|
+
ref: "Sandbox",
|
|
23
|
+
required: true,
|
|
24
|
+
index: true,
|
|
25
|
+
},
|
|
26
|
+
name: {
|
|
27
|
+
type: String,
|
|
28
|
+
required: true,
|
|
29
|
+
match: /^[a-z0-9-]{1,40}$/,
|
|
30
|
+
},
|
|
31
|
+
image_tag: {
|
|
32
|
+
type: String,
|
|
33
|
+
required: true,
|
|
34
|
+
},
|
|
35
|
+
source_template: {
|
|
36
|
+
type: String,
|
|
37
|
+
required: true,
|
|
38
|
+
},
|
|
39
|
+
status: {
|
|
40
|
+
type: String,
|
|
41
|
+
enum: Object.values(SANDBOX_SNAPSHOT_STATUS),
|
|
42
|
+
default: SANDBOX_SNAPSHOT_STATUS.CREATING,
|
|
43
|
+
},
|
|
44
|
+
failure_reason: {
|
|
45
|
+
type: String,
|
|
46
|
+
default: null,
|
|
47
|
+
},
|
|
48
|
+
size_bytes: {
|
|
49
|
+
type: Number,
|
|
50
|
+
default: null,
|
|
51
|
+
},
|
|
52
|
+
},
|
|
53
|
+
{ timestamps: { createdAt: "created_at", updatedAt: "updated_at" } },
|
|
54
|
+
);
|
|
55
|
+
|
|
56
|
+
sandboxSnapshotSchema.plugin(softDeletePlugin);
|
|
57
|
+
|
|
58
|
+
export default model<ISandboxSnapshot>("SandboxSnapshot", sandboxSnapshotSchema);
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { model, Schema } from "mongoose";
|
|
2
|
+
import { ISandboxUsageSegment } from "./types/sandbox-usage-segment";
|
|
3
|
+
|
|
4
|
+
const sandboxUsageSegmentSchema = new Schema<ISandboxUsageSegment>(
|
|
5
|
+
{
|
|
6
|
+
sandbox_id: {
|
|
7
|
+
type: Schema.Types.ObjectId,
|
|
8
|
+
ref: "Sandbox",
|
|
9
|
+
required: true,
|
|
10
|
+
index: true,
|
|
11
|
+
},
|
|
12
|
+
user_id: {
|
|
13
|
+
type: Schema.Types.ObjectId,
|
|
14
|
+
ref: "User",
|
|
15
|
+
required: true,
|
|
16
|
+
index: true,
|
|
17
|
+
},
|
|
18
|
+
team_id: {
|
|
19
|
+
type: Schema.Types.ObjectId,
|
|
20
|
+
ref: "Team",
|
|
21
|
+
required: false,
|
|
22
|
+
index: true,
|
|
23
|
+
default: null,
|
|
24
|
+
},
|
|
25
|
+
current: {
|
|
26
|
+
cpu: { type: Number, required: true },
|
|
27
|
+
memory: { type: Number, required: true },
|
|
28
|
+
storage: { type: Number, required: true },
|
|
29
|
+
},
|
|
30
|
+
costs: {
|
|
31
|
+
startDate: { type: Date, required: true },
|
|
32
|
+
endDate: { type: Date, default: null },
|
|
33
|
+
},
|
|
34
|
+
billed: {
|
|
35
|
+
type: Boolean,
|
|
36
|
+
default: false,
|
|
37
|
+
index: true,
|
|
38
|
+
},
|
|
39
|
+
region: {
|
|
40
|
+
type: String,
|
|
41
|
+
required: false,
|
|
42
|
+
},
|
|
43
|
+
template: {
|
|
44
|
+
type: String,
|
|
45
|
+
required: false,
|
|
46
|
+
},
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
timestamps: true,
|
|
50
|
+
},
|
|
51
|
+
);
|
|
52
|
+
|
|
53
|
+
sandboxUsageSegmentSchema.index({ user_id: 1, billed: 1, "costs.endDate": 1 });
|
|
54
|
+
sandboxUsageSegmentSchema.index({ team_id: 1, billed: 1, "costs.endDate": 1 });
|
|
55
|
+
sandboxUsageSegmentSchema.index({ sandbox_id: 1, "costs.endDate": 1 });
|
|
56
|
+
sandboxUsageSegmentSchema.index(
|
|
57
|
+
{ sandbox_id: 1 },
|
|
58
|
+
{
|
|
59
|
+
unique: true,
|
|
60
|
+
partialFilterExpression: { "costs.endDate": null },
|
|
61
|
+
name: "uniq_open_sandbox_usage_segment_per_sandbox",
|
|
62
|
+
},
|
|
63
|
+
);
|
|
64
|
+
|
|
65
|
+
export default model<ISandboxUsageSegment>(
|
|
66
|
+
"SandboxUsageSegment",
|
|
67
|
+
sandboxUsageSegmentSchema,
|
|
68
|
+
"sandbox_usage_segments",
|
|
69
|
+
);
|
package/sandbox.ts
CHANGED
|
@@ -36,18 +36,6 @@ const sandboxSchema: Schema = new Schema({
|
|
|
36
36
|
type: String,
|
|
37
37
|
default: null,
|
|
38
38
|
},
|
|
39
|
-
host: {
|
|
40
|
-
type: String,
|
|
41
|
-
default: null,
|
|
42
|
-
},
|
|
43
|
-
port: {
|
|
44
|
-
type: Number,
|
|
45
|
-
default: null,
|
|
46
|
-
},
|
|
47
|
-
agent_token_hash: {
|
|
48
|
-
type: String,
|
|
49
|
-
default: null,
|
|
50
|
-
},
|
|
51
39
|
region: {
|
|
52
40
|
type: String,
|
|
53
41
|
required: true,
|
|
@@ -94,6 +82,31 @@ const sandboxSchema: Schema = new Schema({
|
|
|
94
82
|
type: Boolean,
|
|
95
83
|
default: false,
|
|
96
84
|
},
|
|
85
|
+
persistent: {
|
|
86
|
+
type: Boolean,
|
|
87
|
+
default: false,
|
|
88
|
+
},
|
|
89
|
+
persistent_disk_gb: {
|
|
90
|
+
type: Number,
|
|
91
|
+
default: null,
|
|
92
|
+
},
|
|
93
|
+
csi_volume_id: {
|
|
94
|
+
type: String,
|
|
95
|
+
default: null,
|
|
96
|
+
},
|
|
97
|
+
paused_at: {
|
|
98
|
+
type: Date,
|
|
99
|
+
default: null,
|
|
100
|
+
},
|
|
101
|
+
image_override: {
|
|
102
|
+
type: String,
|
|
103
|
+
default: null,
|
|
104
|
+
},
|
|
105
|
+
from_snapshot: {
|
|
106
|
+
type: Schema.Types.ObjectId,
|
|
107
|
+
ref: "SandboxSnapshot",
|
|
108
|
+
default: null,
|
|
109
|
+
},
|
|
97
110
|
isDeleted: {
|
|
98
111
|
type: Boolean,
|
|
99
112
|
default: false,
|
package/team.ts
CHANGED
|
@@ -47,6 +47,14 @@ const teamSchema: Schema = new Schema(
|
|
|
47
47
|
type: Boolean,
|
|
48
48
|
default: false,
|
|
49
49
|
},
|
|
50
|
+
sandbox_disabled: {
|
|
51
|
+
type: Boolean,
|
|
52
|
+
default: false,
|
|
53
|
+
},
|
|
54
|
+
sandbox_disabled_by: {
|
|
55
|
+
type: String,
|
|
56
|
+
default: null,
|
|
57
|
+
},
|
|
50
58
|
subscription: {
|
|
51
59
|
type: Schema.Types.ObjectId,
|
|
52
60
|
required: false,
|
package/types/domain/index.ts
CHANGED
package/types/index.ts
CHANGED
|
@@ -56,3 +56,9 @@ export type { IActivityLog } from "./activity-log";
|
|
|
56
56
|
export type { IOwnershipTransfer } from "./ownership-transfer";
|
|
57
57
|
export type { ISandbox, ISandboxSpecs } from "./sandbox";
|
|
58
58
|
export type { ISandboxImage } from "./sandbox-image";
|
|
59
|
+
export type { ISandboxSnapshot } from "./sandbox-snapshot";
|
|
60
|
+
export type {
|
|
61
|
+
ISandboxUsageSegment,
|
|
62
|
+
ISandboxUsageSegmentCurrent,
|
|
63
|
+
ISandboxUsageSegmentCosts,
|
|
64
|
+
} from "./sandbox-usage-segment";
|
|
@@ -36,5 +36,16 @@ export interface IPlanConfiguration extends Document {
|
|
|
36
36
|
can_deploy_all_applications: boolean;
|
|
37
37
|
stripe_prices?: Record<string, string>;
|
|
38
38
|
sandbox_max_count: number;
|
|
39
|
+
sanxbox_hours_max: number;
|
|
39
40
|
sandbox_enabled: boolean;
|
|
41
|
+
sandbox_cpu_hours_included: number;
|
|
42
|
+
sandbox_memory_gb_hours_included: number;
|
|
43
|
+
sandbox_max_runtime_minutes: number;
|
|
44
|
+
sandbox_max_vcpu: number;
|
|
45
|
+
sandbox_max_memory_gb: number;
|
|
46
|
+
sandbox_creation_rate_per_minute: number;
|
|
47
|
+
sandbox_cpu_overage_price: number;
|
|
48
|
+
sandbox_memory_overage_price: number;
|
|
49
|
+
sandbox_snapshot_storage_price: number;
|
|
50
|
+
sandbox_snapshot_gb_months_included: number;
|
|
40
51
|
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { Document, Types } from "mongoose";
|
|
2
|
+
import { SANDBOX_SNAPSHOT_STATUS } from "../enum";
|
|
3
|
+
|
|
4
|
+
export interface ISandboxSnapshot extends Document {
|
|
5
|
+
user_id: Types.ObjectId;
|
|
6
|
+
team: Types.ObjectId | null;
|
|
7
|
+
sandbox_id: Types.ObjectId;
|
|
8
|
+
name: string;
|
|
9
|
+
image_tag: string;
|
|
10
|
+
source_template: string;
|
|
11
|
+
status: SANDBOX_SNAPSHOT_STATUS;
|
|
12
|
+
failure_reason: string | null;
|
|
13
|
+
size_bytes: number | null;
|
|
14
|
+
created_at: Date;
|
|
15
|
+
updated_at: Date;
|
|
16
|
+
isDeleted: boolean;
|
|
17
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { Document, Types } from "mongoose";
|
|
2
|
+
import { ISandbox } from "./sandbox";
|
|
3
|
+
import { IUser } from "./user";
|
|
4
|
+
import { ITeam } from "./team";
|
|
5
|
+
|
|
6
|
+
export interface ISandboxUsageSegmentCurrent {
|
|
7
|
+
cpu: number;
|
|
8
|
+
memory: number;
|
|
9
|
+
storage: number;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export interface ISandboxUsageSegmentCosts {
|
|
13
|
+
startDate: Date;
|
|
14
|
+
endDate: Date | null;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export interface ISandboxUsageSegment extends Document {
|
|
18
|
+
sandbox_id: ISandbox | Types.ObjectId;
|
|
19
|
+
user_id: IUser | Types.ObjectId;
|
|
20
|
+
team_id: ITeam | Types.ObjectId | null;
|
|
21
|
+
current: ISandboxUsageSegmentCurrent;
|
|
22
|
+
costs: ISandboxUsageSegmentCosts;
|
|
23
|
+
billed: boolean;
|
|
24
|
+
region?: string;
|
|
25
|
+
template?: string;
|
|
26
|
+
createdAt: Date;
|
|
27
|
+
updatedAt: Date;
|
|
28
|
+
}
|
package/types/sandbox.ts
CHANGED
|
@@ -18,9 +18,6 @@ export interface ISandbox extends Document {
|
|
|
18
18
|
status: SANDBOX_STATUS;
|
|
19
19
|
nomad_job_id: string;
|
|
20
20
|
nomad_alloc_id: string | null;
|
|
21
|
-
host: string | null;
|
|
22
|
-
port: number | null;
|
|
23
|
-
agent_token_hash: string | null;
|
|
24
21
|
region: string;
|
|
25
22
|
specs: ISandboxSpecs;
|
|
26
23
|
created_at: Date;
|
|
@@ -32,5 +29,11 @@ export interface ISandbox extends Document {
|
|
|
32
29
|
destroy_timeout: string | null;
|
|
33
30
|
one_shot: boolean;
|
|
34
31
|
block_outbound: boolean;
|
|
32
|
+
persistent: boolean;
|
|
33
|
+
persistent_disk_gb: number | null;
|
|
34
|
+
csi_volume_id: string | null;
|
|
35
|
+
paused_at: Date | null;
|
|
36
|
+
image_override: string | null;
|
|
37
|
+
from_snapshot: Types.ObjectId | null;
|
|
35
38
|
isDeleted: boolean;
|
|
36
39
|
}
|
package/types/team.ts
CHANGED
|
@@ -16,6 +16,8 @@ export interface ITeam extends Document {
|
|
|
16
16
|
build_minutes_cycle_anchor: Date | null;
|
|
17
17
|
build_disabled: boolean;
|
|
18
18
|
build_disabled_by: BUILD_DISABLED_BY;
|
|
19
|
+
sandbox_disabled: boolean;
|
|
20
|
+
sandbox_disabled_by: "system" | "payment_failure" | null;
|
|
19
21
|
subscription: ISubscription;
|
|
20
22
|
enforce_2fa: boolean;
|
|
21
23
|
enforce_2fa_at: Date | null;
|
package/types/user.ts
CHANGED
|
@@ -28,6 +28,8 @@ export interface IUser extends Document {
|
|
|
28
28
|
is_waitlist: boolean;
|
|
29
29
|
build_disabled: boolean;
|
|
30
30
|
build_disabled_by: BUILD_DISABLED_BY;
|
|
31
|
+
sandbox_disabled: boolean;
|
|
32
|
+
sandbox_disabled_by: "system" | "payment_failure" | null;
|
|
31
33
|
spending_limit: number;
|
|
32
34
|
build_minutes: number;
|
|
33
35
|
disabled: boolean;
|
package/user.ts
CHANGED
|
@@ -41,6 +41,14 @@ const userSchema: Schema = new Schema(
|
|
|
41
41
|
type: String,
|
|
42
42
|
required: false,
|
|
43
43
|
},
|
|
44
|
+
sandbox_disabled: {
|
|
45
|
+
type: Boolean,
|
|
46
|
+
default: false,
|
|
47
|
+
},
|
|
48
|
+
sandbox_disabled_by: {
|
|
49
|
+
type: String,
|
|
50
|
+
default: null,
|
|
51
|
+
},
|
|
44
52
|
ai_usage_count: {
|
|
45
53
|
type: Number,
|
|
46
54
|
default: 0,
|