codebase-models 2.1.23 → 3.0.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/.github/workflows/npm-publish-stage.yml +33 -0
- package/dist/index.d.ts +8 -5
- package/dist/index.js +17 -10
- package/dist/src/constant.d.ts +25 -1
- package/dist/src/constant.js +100 -3
- package/dist/src/models/Client.d.ts +1 -1
- package/dist/src/models/Client.js +7 -4
- package/dist/src/models/{SegmentCombination.d.ts → Invitation.d.ts} +15 -14
- package/dist/src/models/Invitation.js +55 -0
- package/dist/src/models/Organization.d.ts +8 -15
- package/dist/src/models/Organization.js +10 -58
- package/dist/src/models/{QueryLog.d.ts → Package.d.ts} +7 -7
- package/dist/src/models/{QueryLog.js → Package.js} +10 -19
- package/dist/src/models/Role.js +16 -7
- package/dist/src/models/{Segment.d.ts → Thread.d.ts} +7 -10
- package/dist/src/models/Thread.js +78 -0
- package/dist/src/models/ThreadMessage.d.ts +35 -0
- package/dist/src/models/ThreadMessage.js +86 -0
- package/dist/src/models/User.d.ts +8 -5
- package/dist/src/models/User.js +13 -37
- package/dist/src/models/UserIdentity.d.ts +35 -0
- package/dist/src/models/{SegmentCombination.js → UserIdentity.js} +11 -47
- package/dist/src/models/UserOrganization.d.ts +33 -0
- package/dist/src/models/{Segment.js → UserOrganization.js} +10 -33
- package/dist/src/models/UserPermission.d.ts +4 -11
- package/dist/src/models/UserPermission.js +27 -10
- package/index.ts +18 -11
- package/package.json +1 -1
- package/src/constant.ts +104 -4
- package/src/models/Client.ts +8 -5
- package/src/models/Invitation.ts +50 -0
- package/src/models/Organization.ts +18 -73
- package/src/models/Package.ts +24 -0
- package/src/models/Role.ts +51 -39
- package/src/models/Thread.ts +57 -0
- package/src/models/ThreadMessage.ts +67 -0
- package/src/models/User.ts +21 -43
- package/src/models/UserIdentity.ts +26 -0
- package/src/models/UserOrganization.ts +23 -0
- package/src/models/UserPermission.ts +31 -21
- package/src/models/QueryLog.ts +0 -35
- package/src/models/Segment.ts +0 -50
- package/src/models/SegmentCombination.ts +0 -68
|
@@ -23,14 +23,11 @@
|
|
|
23
23
|
/// <reference types="mongoose/types/virtuals" />
|
|
24
24
|
/// <reference types="mongoose/types/inferschematype" />
|
|
25
25
|
import mongoose, { Document } from "mongoose";
|
|
26
|
-
export interface
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
client?: mongoose.Schema.Types.ObjectId;
|
|
32
|
-
published?: boolean;
|
|
33
|
-
organizationId?: mongoose.Schema.Types.ObjectId;
|
|
26
|
+
export interface IThread extends Document {
|
|
27
|
+
iid: string;
|
|
28
|
+
organization: mongoose.Schema.Types.ObjectId;
|
|
29
|
+
user: mongoose.Schema.Types.ObjectId;
|
|
30
|
+
name: string;
|
|
34
31
|
}
|
|
35
|
-
declare const
|
|
36
|
-
export default
|
|
32
|
+
declare const Thread: mongoose.Model<any, {}, {}, {}, any, any>;
|
|
33
|
+
export default Thread;
|
|
@@ -0,0 +1,78 @@
|
|
|
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
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
26
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
27
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
28
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
29
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
30
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
31
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
32
|
+
});
|
|
33
|
+
};
|
|
34
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
35
|
+
const mongoose_1 = __importStar(require("mongoose"));
|
|
36
|
+
const constant_1 = require("../constant");
|
|
37
|
+
const ThreadSchema = new mongoose_1.Schema({
|
|
38
|
+
iid: {
|
|
39
|
+
type: String,
|
|
40
|
+
trim: true,
|
|
41
|
+
},
|
|
42
|
+
name: {
|
|
43
|
+
type: String,
|
|
44
|
+
required: true,
|
|
45
|
+
default: "New Conversation",
|
|
46
|
+
},
|
|
47
|
+
organization: {
|
|
48
|
+
type: mongoose_1.default.Schema.Types.ObjectId,
|
|
49
|
+
ref: "organization",
|
|
50
|
+
default: null,
|
|
51
|
+
},
|
|
52
|
+
user: {
|
|
53
|
+
type: mongoose_1.default.Schema.Types.ObjectId,
|
|
54
|
+
ref: "user",
|
|
55
|
+
default: null,
|
|
56
|
+
},
|
|
57
|
+
}, {
|
|
58
|
+
timestamps: true,
|
|
59
|
+
});
|
|
60
|
+
ThreadSchema.pre('save', function (next) {
|
|
61
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
62
|
+
if (!this.iid) {
|
|
63
|
+
let unique = false;
|
|
64
|
+
while (!unique) {
|
|
65
|
+
const id = (0, constant_1.generateRandomIID)();
|
|
66
|
+
const existing = yield mongoose_1.default.models.thread.findOne({ iid: id });
|
|
67
|
+
if (!existing) {
|
|
68
|
+
this.iid = id;
|
|
69
|
+
unique = true;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
next();
|
|
74
|
+
});
|
|
75
|
+
});
|
|
76
|
+
ThreadSchema.index({ iid: 1 }, { unique: true });
|
|
77
|
+
const Thread = mongoose_1.default.models.thread || (0, mongoose_1.model)("thread", ThreadSchema);
|
|
78
|
+
exports.default = Thread;
|
|
@@ -0,0 +1,35 @@
|
|
|
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/types/inferschematype" />
|
|
25
|
+
import mongoose, { Document } from "mongoose";
|
|
26
|
+
export interface IThreadMessage extends Document {
|
|
27
|
+
iid: string;
|
|
28
|
+
organization: mongoose.Schema.Types.ObjectId;
|
|
29
|
+
thread: mongoose.Schema.Types.ObjectId;
|
|
30
|
+
status: string;
|
|
31
|
+
user: mongoose.Schema.Types.ObjectId;
|
|
32
|
+
message: mongoose.Schema.Types.Mixed;
|
|
33
|
+
}
|
|
34
|
+
declare const ThreadMessage: mongoose.Model<any, {}, {}, {}, any, any>;
|
|
35
|
+
export default ThreadMessage;
|
|
@@ -0,0 +1,86 @@
|
|
|
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
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
26
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
27
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
28
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
29
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
30
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
31
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
32
|
+
});
|
|
33
|
+
};
|
|
34
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
35
|
+
const mongoose_1 = __importStar(require("mongoose"));
|
|
36
|
+
const constant_1 = require("../constant");
|
|
37
|
+
const ThreadMessageSchema = new mongoose_1.Schema({
|
|
38
|
+
iid: {
|
|
39
|
+
type: String,
|
|
40
|
+
trim: true,
|
|
41
|
+
},
|
|
42
|
+
organization: {
|
|
43
|
+
type: mongoose_1.default.Schema.Types.ObjectId,
|
|
44
|
+
ref: "organization",
|
|
45
|
+
default: null,
|
|
46
|
+
},
|
|
47
|
+
thread: {
|
|
48
|
+
type: mongoose_1.default.Schema.Types.ObjectId,
|
|
49
|
+
ref: "thread",
|
|
50
|
+
default: null,
|
|
51
|
+
},
|
|
52
|
+
user: {
|
|
53
|
+
type: mongoose_1.default.Schema.Types.ObjectId,
|
|
54
|
+
ref: "user",
|
|
55
|
+
default: null,
|
|
56
|
+
},
|
|
57
|
+
status: {
|
|
58
|
+
type: String,
|
|
59
|
+
enum: ["pending", "success", "failed"],
|
|
60
|
+
default: "pending",
|
|
61
|
+
},
|
|
62
|
+
message: {
|
|
63
|
+
type: mongoose_1.default.Schema.Types.Mixed,
|
|
64
|
+
},
|
|
65
|
+
}, {
|
|
66
|
+
timestamps: true,
|
|
67
|
+
});
|
|
68
|
+
ThreadMessageSchema.pre('save', function (next) {
|
|
69
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
70
|
+
if (!this.iid) {
|
|
71
|
+
let unique = false;
|
|
72
|
+
while (!unique) {
|
|
73
|
+
const id = (0, constant_1.generateRandomIID)();
|
|
74
|
+
const existing = yield mongoose_1.default.models.threadmessage.findOne({ iid: id });
|
|
75
|
+
if (!existing) {
|
|
76
|
+
this.iid = id;
|
|
77
|
+
unique = true;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
next();
|
|
82
|
+
});
|
|
83
|
+
});
|
|
84
|
+
ThreadMessageSchema.index({ iid: 1 }, { unique: true });
|
|
85
|
+
const ThreadMessage = mongoose_1.default.models.threadmessage || (0, mongoose_1.model)("threadmessage", ThreadMessageSchema);
|
|
86
|
+
exports.default = ThreadMessage;
|
|
@@ -24,21 +24,24 @@
|
|
|
24
24
|
/// <reference types="mongoose/types/inferschematype" />
|
|
25
25
|
import mongoose, { Document } from "mongoose";
|
|
26
26
|
export interface IUser extends Document {
|
|
27
|
+
iid: string;
|
|
27
28
|
name: string;
|
|
28
29
|
email: string;
|
|
30
|
+
image: string;
|
|
31
|
+
client: mongoose.Schema.Types.ObjectId[];
|
|
29
32
|
password: string;
|
|
30
33
|
token: string;
|
|
31
|
-
role?: mongoose.Schema.Types.ObjectId[];
|
|
32
34
|
deactivated: boolean;
|
|
33
|
-
client?: mongoose.Schema.Types.ObjectId[];
|
|
34
35
|
twoFactor: boolean;
|
|
35
|
-
|
|
36
|
-
updatedAt: Date;
|
|
36
|
+
emailVerified: boolean;
|
|
37
37
|
resetLink: string;
|
|
38
|
-
organizationId?: mongoose.Schema.Types.ObjectId;
|
|
39
38
|
bigqueryToken: string;
|
|
40
39
|
expirybqToken: string;
|
|
41
40
|
refreshToken: string;
|
|
41
|
+
createdAt: Date;
|
|
42
|
+
updatedAt: Date;
|
|
43
|
+
isSSOUser: boolean;
|
|
44
|
+
role: mongoose.Schema.Types.ObjectId[] | null;
|
|
42
45
|
}
|
|
43
46
|
declare const User: mongoose.Model<any, {}, {}, {}, any, any>;
|
|
44
47
|
export default User;
|
package/dist/src/models/User.js
CHANGED
|
@@ -24,48 +24,24 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
24
24
|
};
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
26
|
const mongoose_1 = __importStar(require("mongoose"));
|
|
27
|
+
const constant_1 = require("../constant");
|
|
27
28
|
const UserSchema = new mongoose_1.Schema({
|
|
29
|
+
iid: { type: String, unique: true, default: () => (0, constant_1.generateRandomIID)() },
|
|
28
30
|
name: String,
|
|
29
|
-
email: {
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
},
|
|
34
|
-
password: {
|
|
35
|
-
type: String,
|
|
36
|
-
required: true,
|
|
37
|
-
},
|
|
31
|
+
email: { type: String, unique: true, required: true },
|
|
32
|
+
client: { type: [mongoose_1.default.Schema.Types.ObjectId], ref: "client", default: null },
|
|
33
|
+
password: { type: String, required: true },
|
|
34
|
+
image: String,
|
|
38
35
|
token: String,
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
deactivated: {
|
|
44
|
-
type: Boolean,
|
|
45
|
-
default: false,
|
|
46
|
-
},
|
|
47
|
-
client: {
|
|
48
|
-
type: [mongoose_1.default.Schema.Types.ObjectId],
|
|
49
|
-
ref: "client",
|
|
50
|
-
default: null,
|
|
51
|
-
},
|
|
52
|
-
twoFactor: {
|
|
53
|
-
type: Boolean,
|
|
54
|
-
default: false,
|
|
55
|
-
},
|
|
56
|
-
organizationId: {
|
|
57
|
-
type: mongoose_1.default.Schema.Types.ObjectId,
|
|
58
|
-
ref: "organization",
|
|
59
|
-
default: null,
|
|
60
|
-
},
|
|
36
|
+
deactivated: { type: Boolean, default: false },
|
|
37
|
+
twoFactor: { type: Boolean, default: false },
|
|
38
|
+
emailVerified: { type: Boolean, default: false },
|
|
39
|
+
resetLink: String,
|
|
61
40
|
bigqueryToken: String,
|
|
62
41
|
expirybqToken: String,
|
|
63
42
|
refreshToken: String,
|
|
64
|
-
},
|
|
65
|
-
|
|
66
|
-
});
|
|
67
|
-
// Add compound indexes for common query patterns
|
|
68
|
-
UserSchema.index({ organizationId: 1, role: 1 });
|
|
69
|
-
UserSchema.index({ organizationId: 1, client: 1 });
|
|
43
|
+
isSSOUser: { type: Boolean, default: false },
|
|
44
|
+
role: { type: [mongoose_1.default.Schema.Types.ObjectId], ref: "role", default: null },
|
|
45
|
+
}, { timestamps: true });
|
|
70
46
|
const User = mongoose_1.default.models.user || (0, mongoose_1.model)("user", UserSchema);
|
|
71
47
|
exports.default = User;
|
|
@@ -0,0 +1,35 @@
|
|
|
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/types/inferschematype" />
|
|
25
|
+
import mongoose, { Document } from "mongoose";
|
|
26
|
+
export interface IUserIdentity extends Document {
|
|
27
|
+
iid: string;
|
|
28
|
+
user: mongoose.Schema.Types.ObjectId;
|
|
29
|
+
provider: "google" | "microsoft" | "github" | "facebook" | "apple";
|
|
30
|
+
providerUserId: string;
|
|
31
|
+
email: string;
|
|
32
|
+
metadata?: any;
|
|
33
|
+
}
|
|
34
|
+
declare const UserIdentity: mongoose.Model<any, {}, {}, {}, any, any>;
|
|
35
|
+
export default UserIdentity;
|
|
@@ -24,50 +24,14 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
24
24
|
};
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
26
|
const mongoose_1 = __importStar(require("mongoose"));
|
|
27
|
-
const
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
},
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
},
|
|
39
|
-
gagroup: {
|
|
40
|
-
typr: String,
|
|
41
|
-
},
|
|
42
|
-
secondaryFilters: {
|
|
43
|
-
type: [],
|
|
44
|
-
default: null,
|
|
45
|
-
},
|
|
46
|
-
segmentType: {
|
|
47
|
-
type: String,
|
|
48
|
-
default: "general",
|
|
49
|
-
},
|
|
50
|
-
client: {
|
|
51
|
-
type: [mongoose_1.default.Schema.Types.ObjectId],
|
|
52
|
-
ref: "client",
|
|
53
|
-
default: null,
|
|
54
|
-
},
|
|
55
|
-
published: {
|
|
56
|
-
type: Boolean,
|
|
57
|
-
default: true,
|
|
58
|
-
},
|
|
59
|
-
order: {
|
|
60
|
-
type: Number,
|
|
61
|
-
default: 1,
|
|
62
|
-
},
|
|
63
|
-
createdAt: {
|
|
64
|
-
type: Date,
|
|
65
|
-
default: new Date(),
|
|
66
|
-
},
|
|
67
|
-
updatedAt: {
|
|
68
|
-
type: Date,
|
|
69
|
-
default: new Date(),
|
|
70
|
-
},
|
|
71
|
-
});
|
|
72
|
-
const SegmentCombination = mongoose_1.default.models.segmentcombination || (0, mongoose_1.model)("segmentcombination", SegmentSchema);
|
|
73
|
-
exports.default = SegmentCombination;
|
|
27
|
+
const constant_1 = require("../constant");
|
|
28
|
+
const UserIdentitySchema = new mongoose_1.Schema({
|
|
29
|
+
iid: { type: String, unique: true, default: () => (0, constant_1.generateRandomIID)() },
|
|
30
|
+
user: { type: mongoose_1.default.Schema.Types.ObjectId, ref: "user", required: true },
|
|
31
|
+
email: { type: String, unique: true, required: true },
|
|
32
|
+
providerUserId: { type: String, required: true },
|
|
33
|
+
provider: { type: String, enum: ["google", "microsoft", "github", "facebook", "apple"], required: true },
|
|
34
|
+
metadata: { type: mongoose_1.default.Schema.Types.Mixed, default: {} },
|
|
35
|
+
}, { timestamps: true });
|
|
36
|
+
const UserIdentity = mongoose_1.default.models.useridentity || (0, mongoose_1.model)("useridentity", UserIdentitySchema);
|
|
37
|
+
exports.default = UserIdentity;
|
|
@@ -0,0 +1,33 @@
|
|
|
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/types/inferschematype" />
|
|
25
|
+
import mongoose from "mongoose";
|
|
26
|
+
export interface IUserOrganization extends Document {
|
|
27
|
+
iid: string;
|
|
28
|
+
user: mongoose.Schema.Types.ObjectId;
|
|
29
|
+
organization: mongoose.Schema.Types.ObjectId;
|
|
30
|
+
role: string;
|
|
31
|
+
}
|
|
32
|
+
declare const UserOrganization: mongoose.Model<any, {}, {}, {}, any, any>;
|
|
33
|
+
export default UserOrganization;
|
|
@@ -24,36 +24,13 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
24
24
|
};
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
26
|
const mongoose_1 = __importStar(require("mongoose"));
|
|
27
|
-
const
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
type: String,
|
|
38
|
-
},
|
|
39
|
-
values: {
|
|
40
|
-
type: String,
|
|
41
|
-
},
|
|
42
|
-
segmentType: {
|
|
43
|
-
type: String,
|
|
44
|
-
default: "general",
|
|
45
|
-
},
|
|
46
|
-
client: {
|
|
47
|
-
type: [mongoose_1.default.Schema.Types.ObjectId],
|
|
48
|
-
ref: "client",
|
|
49
|
-
default: null,
|
|
50
|
-
},
|
|
51
|
-
published: {
|
|
52
|
-
type: Boolean,
|
|
53
|
-
default: true,
|
|
54
|
-
},
|
|
55
|
-
}, {
|
|
56
|
-
timestamps: true,
|
|
57
|
-
});
|
|
58
|
-
const Segment = mongoose_1.default.models.segment || (0, mongoose_1.model)("segment", SegmentSchema);
|
|
59
|
-
exports.default = Segment;
|
|
27
|
+
const constant_1 = require("../constant");
|
|
28
|
+
const UserOrganizationSchema = new mongoose_1.Schema({
|
|
29
|
+
iid: { type: String, unique: true, default: () => (0, constant_1.generateRandomIID)() },
|
|
30
|
+
user: { type: mongoose_1.default.Schema.Types.ObjectId, ref: "user", required: true },
|
|
31
|
+
organization: { type: mongoose_1.default.Schema.Types.ObjectId, ref: "organization", required: true },
|
|
32
|
+
role: { type: String, enum: ["owner", "admin", "member"], default: "member" }
|
|
33
|
+
}, { timestamps: true });
|
|
34
|
+
UserOrganizationSchema.index({ user: 1, organization: 1 }, { unique: true });
|
|
35
|
+
const UserOrganization = mongoose_1.default.models.userorganization || (0, mongoose_1.model)("userorganization", UserOrganizationSchema);
|
|
36
|
+
exports.default = UserOrganization;
|
|
@@ -24,19 +24,12 @@
|
|
|
24
24
|
/// <reference types="mongoose/types/inferschematype" />
|
|
25
25
|
import mongoose, { Document } from "mongoose";
|
|
26
26
|
export interface IUserPermission extends Document {
|
|
27
|
+
iid: string;
|
|
27
28
|
userId: mongoose.Schema.Types.ObjectId;
|
|
28
29
|
clientId: mongoose.Schema.Types.ObjectId;
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
insights: boolean;
|
|
33
|
-
documentsAndLinks: boolean;
|
|
34
|
-
cvrReports: boolean;
|
|
35
|
-
abTesting: boolean;
|
|
36
|
-
abTestingDefault: boolean;
|
|
37
|
-
manageExperiments: boolean;
|
|
38
|
-
preCalculations: boolean;
|
|
39
|
-
};
|
|
30
|
+
organizationId: mongoose.Schema.Types.ObjectId;
|
|
31
|
+
role: string;
|
|
32
|
+
permissions: mongoose.Schema.Types.Mixed;
|
|
40
33
|
createdAt: Date;
|
|
41
34
|
updatedAt: Date;
|
|
42
35
|
}
|
|
@@ -24,7 +24,13 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
24
24
|
};
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
26
|
const mongoose_1 = __importStar(require("mongoose"));
|
|
27
|
+
const constant_1 = require("../constant");
|
|
27
28
|
const UserPermissionSchema = new mongoose_1.Schema({
|
|
29
|
+
iid: {
|
|
30
|
+
type: String,
|
|
31
|
+
unique: true,
|
|
32
|
+
default: () => (0, constant_1.generateRandomIID)()
|
|
33
|
+
},
|
|
28
34
|
userId: {
|
|
29
35
|
type: mongoose_1.default.Schema.Types.ObjectId,
|
|
30
36
|
ref: "user",
|
|
@@ -35,17 +41,28 @@ const UserPermissionSchema = new mongoose_1.Schema({
|
|
|
35
41
|
ref: "client",
|
|
36
42
|
required: true,
|
|
37
43
|
},
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
dashboard: { type: Boolean, default: true },
|
|
44
|
+
role: {
|
|
45
|
+
type: String,
|
|
46
|
+
enum: ["member", "admin", "owner"],
|
|
47
|
+
default: "member",
|
|
48
|
+
},
|
|
49
|
+
organizationId: {
|
|
50
|
+
type: mongoose_1.default.Schema.Types.ObjectId,
|
|
51
|
+
ref: "organization",
|
|
52
|
+
required: true,
|
|
48
53
|
},
|
|
54
|
+
permissions: { type: mongoose_1.default.Schema.Types.Mixed, required: true, default: constant_1.PackageFeaturesConstants },
|
|
55
|
+
// permissions: {
|
|
56
|
+
// abTestingDefault: { type: Boolean, default: true },
|
|
57
|
+
// abTesting: { type: Boolean, default: false },
|
|
58
|
+
// preCalculations: { type: Boolean, default: false },
|
|
59
|
+
// reporting: { type: Boolean, default: true },
|
|
60
|
+
// insights: { type: Boolean, default: true },
|
|
61
|
+
// documentsAndLinks: { type: Boolean, default: true },
|
|
62
|
+
// cvrReports: { type: Boolean, default: true },
|
|
63
|
+
// manageExperiments: { type: Boolean, default: false },
|
|
64
|
+
// dashboard: { type: Boolean, default: true },
|
|
65
|
+
// },
|
|
49
66
|
}, {
|
|
50
67
|
timestamps: true,
|
|
51
68
|
});
|
package/index.ts
CHANGED
|
@@ -2,7 +2,6 @@ import mongoose from "mongoose";
|
|
|
2
2
|
|
|
3
3
|
import Client from "./src/models/Client";
|
|
4
4
|
import ClientReportsTemp from "./src/models/ClientReportsTemp";
|
|
5
|
-
import QueryLog from "./src/models/QueryLog";
|
|
6
5
|
import Report from "./src/models/Report";
|
|
7
6
|
import Test from "./src/models/Test";
|
|
8
7
|
import TestSequentialValue from "./src/models/TestSequentialValue";
|
|
@@ -34,8 +33,6 @@ import ReadNotification from "./src/models/ReadNotification";
|
|
|
34
33
|
import Organization from "./src/models/Organization";
|
|
35
34
|
import Role from "./src/models/Role";
|
|
36
35
|
import SavedSegment from "./src/models/SavedSegment";
|
|
37
|
-
import Segment from "./src/models/Segment";
|
|
38
|
-
import SegmentCombination from "./src/models/SegmentCombination";
|
|
39
36
|
import Snippet from "./src/models/Snippet";
|
|
40
37
|
import StageInCustomerJourney from "./src/models/StageInCustomerJourney";
|
|
41
38
|
import Tag from "./src/models/Tag";
|
|
@@ -49,15 +46,21 @@ import Environment from "./src/models/Environment";
|
|
|
49
46
|
import PrecalculationFilters from "./src/models/PrecalculationFilters";
|
|
50
47
|
import BqPreCompiledData from "./src/models/BqPreCompiledData";
|
|
51
48
|
import CustomQuery from "./src/models/CustomQuery";
|
|
52
|
-
import { generateRandomIID } from "./src/constant";
|
|
49
|
+
import { generateRandomIID, RolesConstants } from "./src/constant";
|
|
53
50
|
import TestTimeline from "./src/models/TestTimeline";
|
|
54
51
|
import CronData from "./src/models/CronData";
|
|
55
52
|
import CronConfig from "./src/models/CronConfig";
|
|
53
|
+
import UserIdentity from "./src/models/UserIdentity";
|
|
54
|
+
import UserOrganization from "./src/models/UserOrganization";
|
|
55
|
+
import Package from "./src/models/Package";
|
|
56
|
+
import Invitation from "./src/models/Invitation";
|
|
57
|
+
import Thread from "./src/models/Thread";
|
|
58
|
+
import ThreadMessage from "./src/models/ThreadMessage";
|
|
56
59
|
async function seedRoles() {
|
|
57
60
|
const checkRoles = await Role.countDocuments();
|
|
58
|
-
if (checkRoles <
|
|
61
|
+
if (checkRoles < RolesConstants.length) {
|
|
59
62
|
Promise.all(
|
|
60
|
-
|
|
63
|
+
RolesConstants.map((name: string) => {
|
|
61
64
|
Role.bulkWrite([
|
|
62
65
|
{
|
|
63
66
|
updateOne: {
|
|
@@ -102,9 +105,9 @@ export async function connect(
|
|
|
102
105
|
|
|
103
106
|
export {
|
|
104
107
|
generateRandomIID,
|
|
108
|
+
RolesConstants,
|
|
105
109
|
Client,
|
|
106
110
|
ClientReportsTemp,
|
|
107
|
-
QueryLog,
|
|
108
111
|
Report,
|
|
109
112
|
Test,
|
|
110
113
|
TestSequentialValue,
|
|
@@ -137,8 +140,6 @@ export {
|
|
|
137
140
|
CustomQuery,
|
|
138
141
|
SavedSegment,
|
|
139
142
|
TestTimeline,
|
|
140
|
-
Segment,
|
|
141
|
-
SegmentCombination,
|
|
142
143
|
Snippet,
|
|
143
144
|
StageInCustomerJourney,
|
|
144
145
|
Tag,
|
|
@@ -153,5 +154,11 @@ export {
|
|
|
153
154
|
BqPreCompiledData,
|
|
154
155
|
CronData,
|
|
155
156
|
CronConfig,
|
|
156
|
-
UserPermission
|
|
157
|
-
|
|
157
|
+
UserPermission,
|
|
158
|
+
UserIdentity,
|
|
159
|
+
UserOrganization,
|
|
160
|
+
Package,
|
|
161
|
+
Invitation,
|
|
162
|
+
Thread,
|
|
163
|
+
ThreadMessage,
|
|
164
|
+
};
|