@brimble/models 2.1.8 → 2.2.0
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 +17 -2
- package/dist/enum/index.js +18 -1
- package/dist/index.d.ts +4 -2
- package/dist/index.js +7 -1
- package/dist/job.d.ts +6 -0
- package/dist/job.js +52 -0
- package/dist/liscense.d.ts +56 -0
- package/dist/liscense.js +29 -0
- package/dist/types/index.d.ts +2 -0
- package/dist/types/job.d.ts +19 -0
- package/dist/types/job.js +2 -0
- package/dist/types/liscense.d.ts +8 -0
- package/dist/types/liscense.js +2 -0
- package/enum/index.ts +17 -0
- package/index.ts +9 -2
- package/job.ts +31 -0
- package/liscense.ts +31 -0
- package/package.json +1 -1
- package/types/index.ts +2 -0
- package/types/job.ts +20 -0
- package/types/liscense.ts +10 -0
package/dist/enum/index.d.ts
CHANGED
|
@@ -56,7 +56,8 @@ export declare enum SUBSCRIPTION_PLAN_TYPE {
|
|
|
56
56
|
FreePlan = "FREE_PLAN",
|
|
57
57
|
DeveloperPlan = "DEVELOPER_PLAN",
|
|
58
58
|
TeamPlan = "TEAM_PLAN",
|
|
59
|
-
DatabasePlan = "DATABASE_PLAN"
|
|
59
|
+
DatabasePlan = "DATABASE_PLAN",
|
|
60
|
+
LiscensePlan = "LISCENSE_PLAN"
|
|
60
61
|
}
|
|
61
62
|
export declare enum OAUTH_PERMISSIONS {
|
|
62
63
|
READ_USER = "read_user",
|
|
@@ -89,7 +90,8 @@ export declare enum PERMISSION_TYPE {
|
|
|
89
90
|
}
|
|
90
91
|
export declare enum ServiceType {
|
|
91
92
|
Database = "database",
|
|
92
|
-
WebService = "web-service"
|
|
93
|
+
WebService = "web-service",
|
|
94
|
+
Liscense = "liscense"
|
|
93
95
|
}
|
|
94
96
|
export declare enum DatabaseEngine {
|
|
95
97
|
MySQL = "mysql",
|
|
@@ -99,3 +101,16 @@ export declare enum DatabaseEngine {
|
|
|
99
101
|
WordPress = "wordpress",
|
|
100
102
|
SQLite = "sqlite"
|
|
101
103
|
}
|
|
104
|
+
export declare enum JobStatus {
|
|
105
|
+
SCHEDULED = "scheduled",
|
|
106
|
+
RUNNING = "running",
|
|
107
|
+
COMPLETED = "completed",
|
|
108
|
+
FAILED = "failed",
|
|
109
|
+
CANCELLED = "cancelled"
|
|
110
|
+
}
|
|
111
|
+
export declare enum LicenseStatus {
|
|
112
|
+
ACTIVE = "ACTIVE",
|
|
113
|
+
EXPIRED = "EXPIRED",
|
|
114
|
+
SUSPENDED = "SUSPENDED",
|
|
115
|
+
REVOKED = "REVOKED"
|
|
116
|
+
}
|
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.LicenseStatus = 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";
|
|
@@ -69,6 +69,7 @@ var SUBSCRIPTION_PLAN_TYPE;
|
|
|
69
69
|
SUBSCRIPTION_PLAN_TYPE["DeveloperPlan"] = "DEVELOPER_PLAN";
|
|
70
70
|
SUBSCRIPTION_PLAN_TYPE["TeamPlan"] = "TEAM_PLAN";
|
|
71
71
|
SUBSCRIPTION_PLAN_TYPE["DatabasePlan"] = "DATABASE_PLAN";
|
|
72
|
+
SUBSCRIPTION_PLAN_TYPE["LiscensePlan"] = "LISCENSE_PLAN";
|
|
72
73
|
})(SUBSCRIPTION_PLAN_TYPE = exports.SUBSCRIPTION_PLAN_TYPE || (exports.SUBSCRIPTION_PLAN_TYPE = {}));
|
|
73
74
|
var OAUTH_PERMISSIONS;
|
|
74
75
|
(function (OAUTH_PERMISSIONS) {
|
|
@@ -108,6 +109,7 @@ var ServiceType;
|
|
|
108
109
|
(function (ServiceType) {
|
|
109
110
|
ServiceType["Database"] = "database";
|
|
110
111
|
ServiceType["WebService"] = "web-service";
|
|
112
|
+
ServiceType["Liscense"] = "liscense";
|
|
111
113
|
})(ServiceType = exports.ServiceType || (exports.ServiceType = {}));
|
|
112
114
|
var DatabaseEngine;
|
|
113
115
|
(function (DatabaseEngine) {
|
|
@@ -118,3 +120,18 @@ var DatabaseEngine;
|
|
|
118
120
|
DatabaseEngine["WordPress"] = "wordpress";
|
|
119
121
|
DatabaseEngine["SQLite"] = "sqlite";
|
|
120
122
|
})(DatabaseEngine = exports.DatabaseEngine || (exports.DatabaseEngine = {}));
|
|
123
|
+
var JobStatus;
|
|
124
|
+
(function (JobStatus) {
|
|
125
|
+
JobStatus["SCHEDULED"] = "scheduled";
|
|
126
|
+
JobStatus["RUNNING"] = "running";
|
|
127
|
+
JobStatus["COMPLETED"] = "completed";
|
|
128
|
+
JobStatus["FAILED"] = "failed";
|
|
129
|
+
JobStatus["CANCELLED"] = "cancelled";
|
|
130
|
+
})(JobStatus = exports.JobStatus || (exports.JobStatus = {}));
|
|
131
|
+
var LicenseStatus;
|
|
132
|
+
(function (LicenseStatus) {
|
|
133
|
+
LicenseStatus["ACTIVE"] = "ACTIVE";
|
|
134
|
+
LicenseStatus["EXPIRED"] = "EXPIRED";
|
|
135
|
+
LicenseStatus["SUSPENDED"] = "SUSPENDED";
|
|
136
|
+
LicenseStatus["REVOKED"] = "REVOKED";
|
|
137
|
+
})(LicenseStatus = exports.LicenseStatus || (exports.LicenseStatus = {}));
|
package/dist/index.d.ts
CHANGED
|
@@ -18,8 +18,10 @@ 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 { default as Liscense } from "./liscense";
|
|
23
|
+
export { IUser, IGit, IProject, IPreview, IFollowing, IIntegration, IEnv, IServer, IDomain, IToken, IMember, ITeam, IInstalledIntegration, ILog, ISubscription, ICard, IDns, IRole, IPermission, IMemberPermission, IWallet, IDbImage, IJob, ILicense } from "./types";
|
|
24
|
+
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 } from "./enum";
|
|
23
25
|
import mongoose from "mongoose";
|
|
24
26
|
export declare const connectToMongo: (mongoUrl: string, config?: mongoose.ConnectOptions) => Promise<void>;
|
|
25
27
|
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.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.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.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,10 @@ 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; } });
|
|
59
|
+
var liscense_1 = require("./liscense");
|
|
60
|
+
Object.defineProperty(exports, "Liscense", { enumerable: true, get: function () { return __importDefault(liscense_1).default; } });
|
|
57
61
|
var enum_1 = require("./enum");
|
|
58
62
|
Object.defineProperty(exports, "GIT_TYPE", { enumerable: true, get: function () { return enum_1.GIT_TYPE; } });
|
|
59
63
|
Object.defineProperty(exports, "INTEGRATION_TYPES", { enumerable: true, get: function () { return enum_1.INTEGRATION_TYPES; } });
|
|
@@ -71,6 +75,8 @@ Object.defineProperty(exports, "PERMISSION_TYPE", { enumerable: true, get: funct
|
|
|
71
75
|
Object.defineProperty(exports, "REQUEST_TYPE", { enumerable: true, get: function () { return enum_1.REQUEST_TYPE; } });
|
|
72
76
|
Object.defineProperty(exports, "ServiceType", { enumerable: true, get: function () { return enum_1.ServiceType; } });
|
|
73
77
|
Object.defineProperty(exports, "DatabaseEngine", { enumerable: true, get: function () { return enum_1.DatabaseEngine; } });
|
|
78
|
+
Object.defineProperty(exports, "JobStatus", { enumerable: true, get: function () { return enum_1.JobStatus; } });
|
|
79
|
+
Object.defineProperty(exports, "LicenseStatus", { enumerable: true, get: function () { return enum_1.LicenseStatus; } });
|
|
74
80
|
const mongoose_1 = __importDefault(require("mongoose"));
|
|
75
81
|
const utils_1 = require("@brimble/utils");
|
|
76
82
|
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');
|
|
@@ -0,0 +1,56 @@
|
|
|
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-delete/node_modules/mongoose/types/aggregate" />
|
|
26
|
+
/// <reference types="mongoose-delete/node_modules/mongoose/types/callback" />
|
|
27
|
+
/// <reference types="mongoose-delete/node_modules/mongoose/types/collection" />
|
|
28
|
+
/// <reference types="mongoose-delete/node_modules/mongoose/types/connection" />
|
|
29
|
+
/// <reference types="mongoose-delete/node_modules/mongoose/types/cursor" />
|
|
30
|
+
/// <reference types="mongoose-delete/node_modules/mongoose/types/document" />
|
|
31
|
+
/// <reference types="mongoose-delete/node_modules/mongoose/types/error" />
|
|
32
|
+
/// <reference types="mongoose-delete/node_modules/mongoose/types/expressions" />
|
|
33
|
+
/// <reference types="mongoose-delete/node_modules/mongoose/types/helpers" />
|
|
34
|
+
/// <reference types="mongoose-delete/node_modules/mongoose/types/middlewares" />
|
|
35
|
+
/// <reference types="mongoose-delete/node_modules/mongoose/types/indexes" />
|
|
36
|
+
/// <reference types="mongoose-delete/node_modules/mongoose/types/models" />
|
|
37
|
+
/// <reference types="mongoose-delete/node_modules/mongoose/types/mongooseoptions" />
|
|
38
|
+
/// <reference types="mongoose-delete/node_modules/mongoose/types/pipelinestage" />
|
|
39
|
+
/// <reference types="mongoose-delete/node_modules/mongoose/types/populate" />
|
|
40
|
+
/// <reference types="mongoose-delete/node_modules/mongoose/types/query" />
|
|
41
|
+
/// <reference types="mongoose-delete/node_modules/mongoose/types/schemaoptions" />
|
|
42
|
+
/// <reference types="mongoose-delete/node_modules/mongoose/types/schematypes" />
|
|
43
|
+
/// <reference types="mongoose-delete/node_modules/mongoose/types/session" />
|
|
44
|
+
/// <reference types="mongoose-delete/node_modules/mongoose/types/types" />
|
|
45
|
+
/// <reference types="mongoose-delete/node_modules/mongoose/types/utility" />
|
|
46
|
+
/// <reference types="mongoose-delete/node_modules/mongoose/types/validation" />
|
|
47
|
+
/// <reference types="mongoose-delete/node_modules/mongoose/types/virtuals" />
|
|
48
|
+
/// <reference types="mongoose-delete/node_modules/mongoose" />
|
|
49
|
+
/// <reference types="mongoose/types/inferschematype" />
|
|
50
|
+
/// <reference types="mongoose-delete/node_modules/mongoose/types/inferschematype" />
|
|
51
|
+
/// <reference types="mongoose-delete/node_modules/mongoose/types/inferrawdoctype" />
|
|
52
|
+
import { ILicense } from "./types/liscense";
|
|
53
|
+
declare const _default: import("mongoose").Model<ILicense, {}, {}, {}, import("mongoose").Document<unknown, {}, ILicense> & ILicense & {
|
|
54
|
+
_id: import("mongoose").Types.ObjectId;
|
|
55
|
+
}, any>;
|
|
56
|
+
export default _default;
|
package/dist/liscense.js
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const mongoose_1 = require("mongoose");
|
|
4
|
+
const enum_1 = require("./enum");
|
|
5
|
+
const licenseSchema = new mongoose_1.Schema({
|
|
6
|
+
licenseKey: {
|
|
7
|
+
type: String,
|
|
8
|
+
required: true,
|
|
9
|
+
unique: true
|
|
10
|
+
},
|
|
11
|
+
userId: {
|
|
12
|
+
type: mongoose_1.Schema.Types.ObjectId,
|
|
13
|
+
ref: 'User',
|
|
14
|
+
required: true
|
|
15
|
+
},
|
|
16
|
+
subscriptionId: {
|
|
17
|
+
type: mongoose_1.Schema.Types.ObjectId,
|
|
18
|
+
ref: 'Subscription',
|
|
19
|
+
required: true
|
|
20
|
+
},
|
|
21
|
+
status: {
|
|
22
|
+
type: String,
|
|
23
|
+
enum: Object.values(enum_1.LicenseStatus),
|
|
24
|
+
default: enum_1.LicenseStatus.ACTIVE
|
|
25
|
+
},
|
|
26
|
+
}, { timestamps: true });
|
|
27
|
+
licenseSchema.index({ userId: 1, status: 1 });
|
|
28
|
+
licenseSchema.index({ licenseKey: 1 });
|
|
29
|
+
exports.default = (0, mongoose_1.model)('License', licenseSchema, 'licenses');
|
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
|
@@ -65,6 +65,7 @@ export enum SUBSCRIPTION_PLAN_TYPE {
|
|
|
65
65
|
DeveloperPlan = 'DEVELOPER_PLAN',
|
|
66
66
|
TeamPlan = 'TEAM_PLAN',
|
|
67
67
|
DatabasePlan = 'DATABASE_PLAN',
|
|
68
|
+
LiscensePlan = 'LISCENSE_PLAN'
|
|
68
69
|
}
|
|
69
70
|
|
|
70
71
|
export enum OAUTH_PERMISSIONS {
|
|
@@ -104,6 +105,7 @@ export enum PERMISSION_TYPE {
|
|
|
104
105
|
export enum ServiceType {
|
|
105
106
|
Database = 'database',
|
|
106
107
|
WebService = 'web-service',
|
|
108
|
+
Liscense = "liscense"
|
|
107
109
|
}
|
|
108
110
|
|
|
109
111
|
export enum DatabaseEngine {
|
|
@@ -113,4 +115,19 @@ export enum DatabaseEngine {
|
|
|
113
115
|
Redis = 'redis',
|
|
114
116
|
WordPress = 'wordpress',
|
|
115
117
|
SQLite = 'sqlite',
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
export enum JobStatus {
|
|
121
|
+
SCHEDULED = "scheduled",
|
|
122
|
+
RUNNING = "running",
|
|
123
|
+
COMPLETED = "completed",
|
|
124
|
+
FAILED = "failed",
|
|
125
|
+
CANCELLED = "cancelled",
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
export enum LicenseStatus {
|
|
129
|
+
ACTIVE = "ACTIVE",
|
|
130
|
+
EXPIRED = "EXPIRED",
|
|
131
|
+
SUSPENDED = "SUSPENDED",
|
|
132
|
+
REVOKED = "REVOKED"
|
|
116
133
|
}
|
package/index.ts
CHANGED
|
@@ -18,6 +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 { default as Job } from "./job";
|
|
22
|
+
export { default as Liscense } from "./liscense"
|
|
23
|
+
|
|
21
24
|
export {
|
|
22
25
|
IUser,
|
|
23
26
|
IGit,
|
|
@@ -40,7 +43,9 @@ export {
|
|
|
40
43
|
IPermission,
|
|
41
44
|
IMemberPermission,
|
|
42
45
|
IWallet,
|
|
43
|
-
IDbImage
|
|
46
|
+
IDbImage,
|
|
47
|
+
IJob,
|
|
48
|
+
ILicense
|
|
44
49
|
} from "./types";
|
|
45
50
|
export {
|
|
46
51
|
GIT_TYPE,
|
|
@@ -58,7 +63,9 @@ export {
|
|
|
58
63
|
PERMISSION_TYPE,
|
|
59
64
|
REQUEST_TYPE,
|
|
60
65
|
ServiceType,
|
|
61
|
-
DatabaseEngine
|
|
66
|
+
DatabaseEngine,
|
|
67
|
+
JobStatus,
|
|
68
|
+
LicenseStatus
|
|
62
69
|
} from "./enum";
|
|
63
70
|
|
|
64
71
|
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/liscense.ts
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { model, Schema } from "mongoose";
|
|
2
|
+
import { ILicense } from "./types/liscense";
|
|
3
|
+
import { LicenseStatus } from "./enum";
|
|
4
|
+
|
|
5
|
+
const licenseSchema: Schema = new Schema({
|
|
6
|
+
licenseKey: {
|
|
7
|
+
type: String,
|
|
8
|
+
required: true,
|
|
9
|
+
unique: true
|
|
10
|
+
},
|
|
11
|
+
userId: {
|
|
12
|
+
type: Schema.Types.ObjectId,
|
|
13
|
+
ref: 'User',
|
|
14
|
+
required: true
|
|
15
|
+
},
|
|
16
|
+
subscriptionId: {
|
|
17
|
+
type: Schema.Types.ObjectId,
|
|
18
|
+
ref: 'Subscription',
|
|
19
|
+
required: true
|
|
20
|
+
},
|
|
21
|
+
status: {
|
|
22
|
+
type: String,
|
|
23
|
+
enum: Object.values(LicenseStatus),
|
|
24
|
+
default: LicenseStatus.ACTIVE
|
|
25
|
+
},
|
|
26
|
+
}, { timestamps: true });
|
|
27
|
+
|
|
28
|
+
licenseSchema.index({ userId: 1, status: 1 });
|
|
29
|
+
licenseSchema.index({ licenseKey: 1 });
|
|
30
|
+
|
|
31
|
+
export default model<ILicense>('License', licenseSchema, 'licenses');
|
package/package.json
CHANGED
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
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import mongoose, { Document } from "mongoose";
|
|
2
|
+
import { LicenseStatus } from "../enum";
|
|
3
|
+
|
|
4
|
+
export interface ILicense extends Document {
|
|
5
|
+
licenseKey: string;
|
|
6
|
+
userId: mongoose.Types.ObjectId;
|
|
7
|
+
status: LicenseStatus;
|
|
8
|
+
subscriptionId: mongoose.Types.ObjectId;
|
|
9
|
+
}
|
|
10
|
+
|