@brimble/models 1.3.18 → 1.3.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.
@@ -1,2 +1,2 @@
1
- @brimble/models:build: cache hit, replaying output ceb1b80b818d995c
1
+ @brimble/models:build: cache hit, replaying output b985931a71ed5fe9
2
2
  @brimble/models:build: $ tsc -p .
@@ -0,0 +1,4 @@
1
+ /// <reference types="mongoose" />
2
+ import { IActivity } from "./types";
3
+ declare const _default: import("mongoose").Model<IActivity, {}, {}>;
4
+ export default _default;
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const mongoose_1 = require("mongoose");
4
+ const enum_1 = require("./enum");
5
+ const activitySchema = new mongoose_1.Schema({
6
+ type: {
7
+ type: String,
8
+ enum: Object.values(enum_1.ACTIVITY_TYPE),
9
+ required: true,
10
+ },
11
+ authUser: {
12
+ type: mongoose_1.Schema.Types.ObjectId,
13
+ ref: "User",
14
+ required: true,
15
+ },
16
+ project: {
17
+ type: mongoose_1.Schema.Types.ObjectId,
18
+ ref: "Project",
19
+ },
20
+ user: {
21
+ type: mongoose_1.Schema.Types.ObjectId,
22
+ ref: "User",
23
+ },
24
+ }, { timestamps: true });
25
+ exports.default = mongoose_1.model("Activity", activitySchema);
@@ -3,10 +3,17 @@ export declare enum GIT_TYPE {
3
3
  GITLAB = "GITLAB",
4
4
  BITBUCKET = "BITBUCKET"
5
5
  }
6
+ export declare enum ENVIRONMENT {
7
+ DEVELOPMENT = "DEVELOPMENT",
8
+ STAGING = "STAGING",
9
+ PRODUCTION = "PRODUCTION"
10
+ }
6
11
  export declare enum INTEGRATION_TYPE {
7
12
  SLACK = "SLACK",
8
13
  ASANA = "ASANA",
9
14
  SENTRY = "SENTRY",
15
+ DISCORD = "DISCORD",
16
+ ONBOARDBASE = "ONBOARDBASE",
10
17
  CONTENTFUL = "CONTENTFUL"
11
18
  }
12
19
  export declare enum OAUTH_PERMISSIONS {
@@ -1,17 +1,25 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.OAUTH_PERMISSIONS = exports.INTEGRATION_TYPE = exports.GIT_TYPE = void 0;
3
+ exports.OAUTH_PERMISSIONS = exports.INTEGRATION_TYPE = exports.ENVIRONMENT = exports.GIT_TYPE = void 0;
4
4
  var GIT_TYPE;
5
5
  (function (GIT_TYPE) {
6
6
  GIT_TYPE["GITHUB"] = "GITHUB";
7
7
  GIT_TYPE["GITLAB"] = "GITLAB";
8
8
  GIT_TYPE["BITBUCKET"] = "BITBUCKET";
9
9
  })(GIT_TYPE = exports.GIT_TYPE || (exports.GIT_TYPE = {}));
10
+ var ENVIRONMENT;
11
+ (function (ENVIRONMENT) {
12
+ ENVIRONMENT["DEVELOPMENT"] = "DEVELOPMENT";
13
+ ENVIRONMENT["STAGING"] = "STAGING";
14
+ ENVIRONMENT["PRODUCTION"] = "PRODUCTION";
15
+ })(ENVIRONMENT = exports.ENVIRONMENT || (exports.ENVIRONMENT = {}));
10
16
  var INTEGRATION_TYPE;
11
17
  (function (INTEGRATION_TYPE) {
12
18
  INTEGRATION_TYPE["SLACK"] = "SLACK";
13
19
  INTEGRATION_TYPE["ASANA"] = "ASANA";
14
20
  INTEGRATION_TYPE["SENTRY"] = "SENTRY";
21
+ INTEGRATION_TYPE["DISCORD"] = "DISCORD";
22
+ INTEGRATION_TYPE["ONBOARDBASE"] = "ONBOARDBASE";
15
23
  INTEGRATION_TYPE["CONTENTFUL"] = "CONTENTFUL";
16
24
  })(INTEGRATION_TYPE = exports.INTEGRATION_TYPE || (exports.INTEGRATION_TYPE = {}));
17
25
  var OAUTH_PERMISSIONS;
package/dist/env.js CHANGED
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const mongoose_1 = require("mongoose");
4
+ const enum_1 = require("./enum");
4
5
  const envSchema = new mongoose_1.Schema({
5
6
  project: {
6
7
  ref: "Project",
@@ -18,6 +19,11 @@ const envSchema = new mongoose_1.Schema({
18
19
  type: mongoose_1.Schema.Types.ObjectId,
19
20
  ref: "User",
20
21
  required: true,
21
- }
22
+ },
23
+ environment: {
24
+ type: String,
25
+ enum: Object.values(enum_1.ENVIRONMENT),
26
+ required: true,
27
+ },
22
28
  }, { timestamps: true });
23
29
  exports.default = mongoose_1.model("Env", envSchema);
package/dist/index.d.ts CHANGED
@@ -6,5 +6,6 @@ export { default as Domain } from "./domain";
6
6
  export { default as Env } from "./env";
7
7
  export { default as Token } from "./token";
8
8
  export { IUser, IGit, IProject, IFollowing, IIntegration, IEnv, IDomain, IToken, } from "./types";
9
- export { GIT_TYPE, INTEGRATION_TYPE, OAUTH_PERMISSIONS } from "./enum";
9
+ export { GIT_TYPE, INTEGRATION_TYPE, OAUTH_PERMISSIONS, ENVIRONMENT } from "./enum";
10
10
  export declare const connectToMongo: (mongoUrl: string) => Promise<void>;
11
+ export declare const closeMongo: () => void;
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.connectToMongo = void 0;
15
+ exports.closeMongo = exports.connectToMongo = void 0;
16
16
  var user_1 = require("./user");
17
17
  Object.defineProperty(exports, "User", { enumerable: true, get: function () { return user_1.default; } });
18
18
  var project_1 = require("./project");
@@ -31,9 +31,10 @@ var enum_1 = require("./enum");
31
31
  Object.defineProperty(exports, "GIT_TYPE", { enumerable: true, get: function () { return enum_1.GIT_TYPE; } });
32
32
  Object.defineProperty(exports, "INTEGRATION_TYPE", { enumerable: true, get: function () { return enum_1.INTEGRATION_TYPE; } });
33
33
  Object.defineProperty(exports, "OAUTH_PERMISSIONS", { enumerable: true, get: function () { return enum_1.OAUTH_PERMISSIONS; } });
34
+ Object.defineProperty(exports, "ENVIRONMENT", { enumerable: true, get: function () { return enum_1.ENVIRONMENT; } });
34
35
  const mongoose_1 = __importDefault(require("mongoose"));
35
36
  const utils_1 = require("@brimble/utils");
36
- // Connection to Mongo
37
+ // Connection to Mongo
37
38
  exports.connectToMongo = (mongoUrl) => __awaiter(void 0, void 0, void 0, function* () {
38
39
  const options = { useNewUrlParser: true, useUnifiedTopology: true };
39
40
  mongoose_1.default.set("useFindAndModify", false);
@@ -50,3 +51,6 @@ exports.connectToMongo = (mongoUrl) => __awaiter(void 0, void 0, void 0, functio
50
51
  return process.exit(1);
51
52
  });
52
53
  });
54
+ exports.closeMongo = () => {
55
+ mongoose_1.default.connection.close(true);
56
+ };
@@ -6,7 +6,8 @@ const integrationSchema = new mongoose_1.Schema({
6
6
  user_id: {
7
7
  type: mongoose_1.Schema.Types.ObjectId,
8
8
  ref: "User",
9
- required: true,
9
+ default: null,
10
+ required: false,
10
11
  },
11
12
  name: {
12
13
  type: String,
package/dist/token.js CHANGED
@@ -22,6 +22,11 @@ const tokenSchema = new mongoose_1.Schema({
22
22
  unique: true,
23
23
  },
24
24
  installationUrl: String,
25
+ encodedToken: {
26
+ type: String,
27
+ default: null,
28
+ required: false,
29
+ },
25
30
  permissions: {
26
31
  type: Array,
27
32
  required: true
@@ -0,0 +1,10 @@
1
+ import { Document } from "mongoose";
2
+ import { ACTIVITY_TYPE } from "../enum";
3
+ import { IProject } from "./project";
4
+ import { IUser } from "./user";
5
+ export interface IActivity extends Document {
6
+ type: ACTIVITY_TYPE;
7
+ project: IProject;
8
+ user: IUser;
9
+ authUser: IUser;
10
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,4 +1,5 @@
1
1
  import { Document } from "mongoose";
2
+ import { ENVIRONMENT } from "../enum";
2
3
  import { IProject } from "./project";
3
4
  import { IUser } from "./user";
4
5
  export interface IEnv extends Document {
@@ -6,4 +7,5 @@ export interface IEnv extends Document {
6
7
  value: string;
7
8
  project: IProject;
8
9
  user: IUser;
10
+ environment: ENVIRONMENT;
9
11
  }
@@ -1,7 +1,7 @@
1
1
  import { Document } from "mongoose";
2
2
  import { INTEGRATION_TYPE } from "../enum";
3
3
  export interface IIntegration extends Document {
4
- user_id: string;
4
+ user_id: string | null;
5
5
  app_id?: string;
6
6
  name: INTEGRATION_TYPE;
7
7
  scope_description?: string;
@@ -6,5 +6,6 @@ export interface IToken extends Document {
6
6
  description: string[];
7
7
  image: string;
8
8
  installationUrl?: string;
9
+ encodedToken?: string | null;
9
10
  permission: OAUTH_PERMISSIONS[];
10
11
  }
package/enum/index.ts CHANGED
@@ -3,10 +3,18 @@ export enum GIT_TYPE {
3
3
  GITLAB = "GITLAB",
4
4
  BITBUCKET = "BITBUCKET",
5
5
  }
6
+
7
+ export enum ENVIRONMENT {
8
+ DEVELOPMENT = "DEVELOPMENT",
9
+ STAGING = "STAGING",
10
+ PRODUCTION = "PRODUCTION"
11
+ }
6
12
  export enum INTEGRATION_TYPE {
7
13
  SLACK = "SLACK",
8
14
  ASANA = "ASANA",
9
15
  SENTRY = "SENTRY",
16
+ DISCORD = "DISCORD",
17
+ ONBOARDBASE = "ONBOARDBASE",
10
18
  CONTENTFUL = "CONTENTFUL",
11
19
  }
12
20
 
package/env.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import { model, Schema } from "mongoose";
2
+ import { ENVIRONMENT } from "./enum";
2
3
  import { IEnv } from "./types";
3
4
 
4
5
  const envSchema = new Schema(
@@ -19,7 +20,12 @@ const envSchema = new Schema(
19
20
  type: Schema.Types.ObjectId,
20
21
  ref: "User",
21
22
  required: true,
22
- }
23
+ },
24
+ environment: {
25
+ type: String,
26
+ enum: Object.values(ENVIRONMENT),
27
+ required: true,
28
+ },
23
29
  },
24
30
  { timestamps: true },
25
31
  );
package/index.ts CHANGED
@@ -15,12 +15,12 @@ export {
15
15
  IDomain,
16
16
  IToken,
17
17
  } from "./types";
18
- export { GIT_TYPE, INTEGRATION_TYPE, OAUTH_PERMISSIONS } from "./enum";
18
+ export { GIT_TYPE, INTEGRATION_TYPE, OAUTH_PERMISSIONS, ENVIRONMENT } from "./enum";
19
19
 
20
20
  import mongoose from "mongoose";
21
21
  import { log } from "@brimble/utils";
22
22
 
23
- // Connection to Mongo
23
+ // Connection to Mongo
24
24
  export const connectToMongo = async (mongoUrl: string): Promise<void> => {
25
25
  const options = { useNewUrlParser: true, useUnifiedTopology: true };
26
26
  mongoose.set("useFindAndModify", false);
@@ -40,3 +40,7 @@ export const connectToMongo = async (mongoUrl: string): Promise<void> => {
40
40
  return process.exit(1);
41
41
  });
42
42
  };
43
+
44
+ export const closeMongo = () => {
45
+ mongoose.connection.close(true);
46
+ }
package/integration.ts CHANGED
@@ -7,7 +7,8 @@ const integrationSchema: Schema = new Schema(
7
7
  user_id: {
8
8
  type: Schema.Types.ObjectId,
9
9
  ref: "User",
10
- required: true,
10
+ default: null,
11
+ required: false,
11
12
  },
12
13
  name: {
13
14
  type: String,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@brimble/models",
3
- "version": "1.3.18",
3
+ "version": "1.3.20",
4
4
  "description": "Brimble models",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -28,7 +28,7 @@
28
28
  },
29
29
  "license": "MIT",
30
30
  "dependencies": {
31
- "@brimble/utils": "^1.3.6",
31
+ "@brimble/utils": "^1.3.8",
32
32
  "dotenv": "^8.2.0",
33
33
  "mongoose": "^5.8.11",
34
34
  "uuid": "^8.3.2"
@@ -43,5 +43,5 @@
43
43
  "ts-node": "^8.10.2",
44
44
  "typescript": "^3.9.5"
45
45
  },
46
- "gitHead": "e7cda88ae45cfc10d7020dbe0343b6dd409d4e06"
46
+ "gitHead": "f94a643b9b48a4c5f16186507e6986822d498647"
47
47
  }
package/token.ts CHANGED
@@ -23,6 +23,11 @@ const tokenSchema = new Schema(
23
23
  unique: true,
24
24
  },
25
25
  installationUrl: String,
26
+ encodedToken: {
27
+ type: String,
28
+ default: null,
29
+ required: false,
30
+ },
26
31
  permissions: {
27
32
  type: Array,
28
33
  required: true
package/types/env.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import { Document } from "mongoose";
2
+ import { ENVIRONMENT } from "../enum";
2
3
  import { IProject } from "./project";
3
4
  import { IUser } from "./user";
4
5
 
@@ -7,4 +8,5 @@ export interface IEnv extends Document {
7
8
  value: string;
8
9
  project: IProject;
9
10
  user: IUser;
11
+ environment: ENVIRONMENT;
10
12
  }
@@ -2,7 +2,7 @@ import { Document } from "mongoose";
2
2
  import { INTEGRATION_TYPE } from "../enum";
3
3
 
4
4
  export interface IIntegration extends Document {
5
- user_id: string;
5
+ user_id: string | null;
6
6
 
7
7
  app_id?: string;
8
8
 
package/types/token.ts CHANGED
@@ -12,5 +12,7 @@ export interface IToken extends Document {
12
12
 
13
13
  installationUrl?: string;
14
14
 
15
+ encodedToken?: string | null;
16
+
15
17
  permission: OAUTH_PERMISSIONS[];
16
18
  }