@brimble/models 2.1.7 → 2.1.9
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/enum/index.d.ts +7 -0
- package/dist/enum/index.js +9 -1
- package/dist/index.d.ts +3 -2
- package/dist/index.js +4 -1
- package/dist/job.d.ts +6 -0
- package/dist/job.js +52 -0
- package/dist/project/index.js +8 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/job.d.ts +19 -0
- package/dist/types/job.js +2 -0
- package/dist/types/project/index.d.ts +2 -0
- package/enum/index.ts +9 -1
- package/index.ts +6 -2
- package/job.ts +31 -0
- package/package.json +1 -1
- package/project/index.ts +8 -0
- package/types/index.ts +1 -0
- package/types/job.ts +20 -0
- package/types/project/index.ts +2 -0
package/dist/enum/index.d.ts
CHANGED
|
@@ -99,3 +99,10 @@ export declare enum DatabaseEngine {
|
|
|
99
99
|
WordPress = "wordpress",
|
|
100
100
|
SQLite = "sqlite"
|
|
101
101
|
}
|
|
102
|
+
export declare enum JobStatus {
|
|
103
|
+
SCHEDULED = "scheduled",
|
|
104
|
+
RUNNING = "running",
|
|
105
|
+
COMPLETED = "completed",
|
|
106
|
+
FAILED = "failed",
|
|
107
|
+
CANCELLED = "cancelled"
|
|
108
|
+
}
|
package/dist/enum/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.DatabaseEngine = exports.ServiceType = 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.GIT_TYPE = void 0;
|
|
3
|
+
exports.JobStatus = exports.DatabaseEngine = exports.ServiceType = 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.GIT_TYPE = void 0;
|
|
4
4
|
var GIT_TYPE;
|
|
5
5
|
(function (GIT_TYPE) {
|
|
6
6
|
GIT_TYPE["GITHUB"] = "GITHUB";
|
|
@@ -118,3 +118,11 @@ var DatabaseEngine;
|
|
|
118
118
|
DatabaseEngine["WordPress"] = "wordpress";
|
|
119
119
|
DatabaseEngine["SQLite"] = "sqlite";
|
|
120
120
|
})(DatabaseEngine = exports.DatabaseEngine || (exports.DatabaseEngine = {}));
|
|
121
|
+
var JobStatus;
|
|
122
|
+
(function (JobStatus) {
|
|
123
|
+
JobStatus["SCHEDULED"] = "scheduled";
|
|
124
|
+
JobStatus["RUNNING"] = "running";
|
|
125
|
+
JobStatus["COMPLETED"] = "completed";
|
|
126
|
+
JobStatus["FAILED"] = "failed";
|
|
127
|
+
JobStatus["CANCELLED"] = "cancelled";
|
|
128
|
+
})(JobStatus = exports.JobStatus || (exports.JobStatus = {}));
|
package/dist/index.d.ts
CHANGED
|
@@ -18,8 +18,9 @@ export { default as Card } from "./card";
|
|
|
18
18
|
export { default as Server } from "./server";
|
|
19
19
|
export { default as Wallet } from "./wallet";
|
|
20
20
|
export { default as DbImage } from "./db-image";
|
|
21
|
-
export {
|
|
22
|
-
export {
|
|
21
|
+
export { default as Job } from "./job";
|
|
22
|
+
export { IUser, IGit, IProject, IPreview, IFollowing, IIntegration, IEnv, IServer, IDomain, IToken, IMember, ITeam, IInstalledIntegration, ILog, ISubscription, ICard, IDns, IRole, IPermission, IMemberPermission, IWallet, IDbImage, IJob } from "./types";
|
|
23
|
+
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 } from "./enum";
|
|
23
24
|
import mongoose from "mongoose";
|
|
24
25
|
export declare const connectToMongo: (mongoUrl: string, config?: mongoose.ConnectOptions) => Promise<void>;
|
|
25
26
|
export declare const db: mongoose.Connection;
|
package/dist/index.js
CHANGED
|
@@ -12,7 +12,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
12
12
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
13
|
};
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
exports.closeMongo = exports.db = exports.connectToMongo = 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.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.Preview = exports.DeletedProject = exports.Project = exports.User = void 0;
|
|
15
|
+
exports.closeMongo = exports.db = exports.connectToMongo = 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.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.Preview = exports.DeletedProject = exports.Project = exports.User = void 0;
|
|
16
16
|
var user_1 = require("./user");
|
|
17
17
|
Object.defineProperty(exports, "User", { enumerable: true, get: function () { return __importDefault(user_1).default; } });
|
|
18
18
|
var project_1 = require("./project");
|
|
@@ -54,6 +54,8 @@ var wallet_1 = require("./wallet");
|
|
|
54
54
|
Object.defineProperty(exports, "Wallet", { enumerable: true, get: function () { return __importDefault(wallet_1).default; } });
|
|
55
55
|
var db_image_1 = require("./db-image");
|
|
56
56
|
Object.defineProperty(exports, "DbImage", { enumerable: true, get: function () { return __importDefault(db_image_1).default; } });
|
|
57
|
+
var job_1 = require("./job");
|
|
58
|
+
Object.defineProperty(exports, "Job", { enumerable: true, get: function () { return __importDefault(job_1).default; } });
|
|
57
59
|
var enum_1 = require("./enum");
|
|
58
60
|
Object.defineProperty(exports, "GIT_TYPE", { enumerable: true, get: function () { return enum_1.GIT_TYPE; } });
|
|
59
61
|
Object.defineProperty(exports, "INTEGRATION_TYPES", { enumerable: true, get: function () { return enum_1.INTEGRATION_TYPES; } });
|
|
@@ -71,6 +73,7 @@ Object.defineProperty(exports, "PERMISSION_TYPE", { enumerable: true, get: funct
|
|
|
71
73
|
Object.defineProperty(exports, "REQUEST_TYPE", { enumerable: true, get: function () { return enum_1.REQUEST_TYPE; } });
|
|
72
74
|
Object.defineProperty(exports, "ServiceType", { enumerable: true, get: function () { return enum_1.ServiceType; } });
|
|
73
75
|
Object.defineProperty(exports, "DatabaseEngine", { enumerable: true, get: function () { return enum_1.DatabaseEngine; } });
|
|
76
|
+
Object.defineProperty(exports, "JobStatus", { enumerable: true, get: function () { return enum_1.JobStatus; } });
|
|
74
77
|
const mongoose_1 = __importDefault(require("mongoose"));
|
|
75
78
|
const utils_1 = require("@brimble/utils");
|
|
76
79
|
const connectToMongo = (mongoUrl, config) => __awaiter(void 0, void 0, void 0, function* () {
|
package/dist/job.d.ts
ADDED
package/dist/job.js
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
const mongoose_1 = __importStar(require("mongoose"));
|
|
27
|
+
const enum_1 = require("./enum");
|
|
28
|
+
const jobSchema = new mongoose_1.Schema({
|
|
29
|
+
title: { type: String, required: true },
|
|
30
|
+
jobId: { type: String, required: true, unique: true },
|
|
31
|
+
url: { type: String, required: true },
|
|
32
|
+
method: { type: String, required: true },
|
|
33
|
+
schedule: { type: String, required: true },
|
|
34
|
+
headers: { type: Map, of: String },
|
|
35
|
+
maxAttempts: { type: Number, default: 5 },
|
|
36
|
+
attempts: { type: Number, default: 0 },
|
|
37
|
+
isRecurring: { type: Boolean, required: true },
|
|
38
|
+
lastRun: Date,
|
|
39
|
+
nextRun: Date,
|
|
40
|
+
body: {
|
|
41
|
+
type: mongoose_1.default.Schema.Types.Mixed,
|
|
42
|
+
required: false,
|
|
43
|
+
},
|
|
44
|
+
status: {
|
|
45
|
+
type: String,
|
|
46
|
+
enum: Object.values(enum_1.JobStatus),
|
|
47
|
+
default: enum_1.JobStatus.SCHEDULED,
|
|
48
|
+
},
|
|
49
|
+
createdAt: { type: Date, default: Date.now },
|
|
50
|
+
updatedAt: { type: Date, default: Date.now },
|
|
51
|
+
});
|
|
52
|
+
exports.default = (0, mongoose_1.model)('Job', jobSchema, 'scheduled_jobs');
|
package/dist/project/index.js
CHANGED
|
@@ -132,6 +132,14 @@ const projectSchema = new mongoose_1.Schema({
|
|
|
132
132
|
type: String,
|
|
133
133
|
default: null,
|
|
134
134
|
},
|
|
135
|
+
last_backup_url: {
|
|
136
|
+
type: String,
|
|
137
|
+
default: null,
|
|
138
|
+
},
|
|
139
|
+
last_backup_at: {
|
|
140
|
+
type: Date,
|
|
141
|
+
default: null,
|
|
142
|
+
},
|
|
135
143
|
}, { timestamps: true });
|
|
136
144
|
exports.default = (0, mongoose_1.model)("Project", projectSchema);
|
|
137
145
|
exports.DeletedProject = (0, mongoose_1.model)("DeletedProject", projectSchema);
|
package/dist/types/index.d.ts
CHANGED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { Document } from "mongoose";
|
|
2
|
+
import { JobStatus } from "../enum";
|
|
3
|
+
export interface IJob extends Document {
|
|
4
|
+
title: string;
|
|
5
|
+
jobId: string;
|
|
6
|
+
url: string;
|
|
7
|
+
method: string;
|
|
8
|
+
schedule: string;
|
|
9
|
+
headers?: Map<string, string>;
|
|
10
|
+
maxAttempts?: number;
|
|
11
|
+
attempts?: number;
|
|
12
|
+
isRecurring: boolean;
|
|
13
|
+
lastRun?: Date;
|
|
14
|
+
nextRun?: Date;
|
|
15
|
+
body?: any;
|
|
16
|
+
status?: JobStatus;
|
|
17
|
+
createdAt?: Date;
|
|
18
|
+
updatedAt?: Date;
|
|
19
|
+
}
|
package/enum/index.ts
CHANGED
|
@@ -113,4 +113,12 @@ export enum DatabaseEngine {
|
|
|
113
113
|
Redis = 'redis',
|
|
114
114
|
WordPress = 'wordpress',
|
|
115
115
|
SQLite = 'sqlite',
|
|
116
|
-
}
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
export enum JobStatus {
|
|
119
|
+
SCHEDULED = "scheduled",
|
|
120
|
+
RUNNING = "running",
|
|
121
|
+
COMPLETED = "completed",
|
|
122
|
+
FAILED = "failed",
|
|
123
|
+
CANCELLED = "cancelled",
|
|
124
|
+
}
|
package/index.ts
CHANGED
|
@@ -18,6 +18,8 @@ export { default as Card } from "./card";
|
|
|
18
18
|
export { default as Server } from "./server";
|
|
19
19
|
export { default as Wallet } from "./wallet";
|
|
20
20
|
export { default as DbImage } from "./db-image";
|
|
21
|
+
export { default as Job } from "./job";
|
|
22
|
+
|
|
21
23
|
export {
|
|
22
24
|
IUser,
|
|
23
25
|
IGit,
|
|
@@ -40,7 +42,8 @@ export {
|
|
|
40
42
|
IPermission,
|
|
41
43
|
IMemberPermission,
|
|
42
44
|
IWallet,
|
|
43
|
-
IDbImage
|
|
45
|
+
IDbImage,
|
|
46
|
+
IJob
|
|
44
47
|
} from "./types";
|
|
45
48
|
export {
|
|
46
49
|
GIT_TYPE,
|
|
@@ -58,7 +61,8 @@ export {
|
|
|
58
61
|
PERMISSION_TYPE,
|
|
59
62
|
REQUEST_TYPE,
|
|
60
63
|
ServiceType,
|
|
61
|
-
DatabaseEngine
|
|
64
|
+
DatabaseEngine,
|
|
65
|
+
JobStatus
|
|
62
66
|
} from "./enum";
|
|
63
67
|
|
|
64
68
|
import mongoose from "mongoose";
|
package/job.ts
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import mongoose, { model, Schema } from "mongoose";
|
|
2
|
+
import { IJob } from "./types/job";
|
|
3
|
+
import { JobStatus } from "./enum";
|
|
4
|
+
|
|
5
|
+
const jobSchema: Schema = new Schema({
|
|
6
|
+
title: { type: String, required: true },
|
|
7
|
+
jobId: { type: String, required: true, unique: true },
|
|
8
|
+
url: { type: String, required: true },
|
|
9
|
+
method: { type: String, required: true },
|
|
10
|
+
schedule: { type: String, required: true },
|
|
11
|
+
headers: { type: Map, of: String },
|
|
12
|
+
maxAttempts: { type: Number, default: 5 },
|
|
13
|
+
attempts: { type: Number, default: 0 },
|
|
14
|
+
isRecurring: { type: Boolean, required: true },
|
|
15
|
+
lastRun: Date,
|
|
16
|
+
nextRun: Date,
|
|
17
|
+
body: {
|
|
18
|
+
type: mongoose.Schema.Types.Mixed,
|
|
19
|
+
required: false,
|
|
20
|
+
},
|
|
21
|
+
status: {
|
|
22
|
+
type: String,
|
|
23
|
+
enum: Object.values(JobStatus),
|
|
24
|
+
default: JobStatus.SCHEDULED,
|
|
25
|
+
},
|
|
26
|
+
createdAt: { type: Date, default: Date.now },
|
|
27
|
+
updatedAt: { type: Date, default: Date.now },
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
export default model<IJob>('Job', jobSchema, 'scheduled_jobs');
|
|
31
|
+
|
package/package.json
CHANGED
package/project/index.ts
CHANGED
|
@@ -132,6 +132,14 @@ const projectSchema = new Schema(
|
|
|
132
132
|
type: String,
|
|
133
133
|
default: null,
|
|
134
134
|
},
|
|
135
|
+
last_backup_url: {
|
|
136
|
+
type: String,
|
|
137
|
+
default: null,
|
|
138
|
+
},
|
|
139
|
+
last_backup_at: {
|
|
140
|
+
type: Date,
|
|
141
|
+
default: null,
|
|
142
|
+
},
|
|
135
143
|
},
|
|
136
144
|
{ timestamps: true },
|
|
137
145
|
);
|
package/types/index.ts
CHANGED
package/types/job.ts
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { Document } from "mongoose";
|
|
2
|
+
import { JobStatus } from "../enum";
|
|
3
|
+
|
|
4
|
+
export interface IJob extends Document {
|
|
5
|
+
title: string;
|
|
6
|
+
jobId: string;
|
|
7
|
+
url: string;
|
|
8
|
+
method: string;
|
|
9
|
+
schedule: string;
|
|
10
|
+
headers?: Map<string, string>;
|
|
11
|
+
maxAttempts?: number;
|
|
12
|
+
attempts?: number;
|
|
13
|
+
isRecurring: boolean;
|
|
14
|
+
lastRun?: Date;
|
|
15
|
+
nextRun?: Date;
|
|
16
|
+
body?: any;
|
|
17
|
+
status?: JobStatus;
|
|
18
|
+
createdAt?: Date;
|
|
19
|
+
updatedAt?: Date;
|
|
20
|
+
}
|