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
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import mongoose, { Document, Schema, model } from "mongoose";
|
|
2
|
+
import { generateRandomIID } from "../constant";
|
|
3
|
+
|
|
4
|
+
export interface IUserIdentity extends Document {
|
|
5
|
+
iid: string;
|
|
6
|
+
user: mongoose.Schema.Types.ObjectId;
|
|
7
|
+
provider: "google" | "microsoft" | "github" | "facebook" | "apple";
|
|
8
|
+
providerUserId: string;
|
|
9
|
+
email: string;
|
|
10
|
+
metadata?: any;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
const UserIdentitySchema = new Schema<IUserIdentity>(
|
|
14
|
+
{
|
|
15
|
+
iid: { type: String, unique: true, default: () => generateRandomIID() },
|
|
16
|
+
user: { type: mongoose.Schema.Types.ObjectId, ref: "user", required: true },
|
|
17
|
+
email: { type: String, unique: true, required: true },
|
|
18
|
+
providerUserId: { type: String, required: true },
|
|
19
|
+
provider: { type: String, enum: ["google", "microsoft", "github", "facebook", "apple"], required: true },
|
|
20
|
+
metadata: { type: mongoose.Schema.Types.Mixed, default: {} },
|
|
21
|
+
},
|
|
22
|
+
{ timestamps: true }
|
|
23
|
+
);
|
|
24
|
+
|
|
25
|
+
const UserIdentity = mongoose.models.useridentity || model<IUserIdentity>("useridentity", UserIdentitySchema);
|
|
26
|
+
export default UserIdentity;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import mongoose, { model, Schema } from "mongoose";
|
|
2
|
+
import { generateRandomIID } from "../constant";
|
|
3
|
+
|
|
4
|
+
export interface IUserOrganization extends Document {
|
|
5
|
+
iid: string;
|
|
6
|
+
user: mongoose.Schema.Types.ObjectId;
|
|
7
|
+
organization: mongoose.Schema.Types.ObjectId;
|
|
8
|
+
role: string;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
const UserOrganizationSchema = new Schema<IUserOrganization>(
|
|
12
|
+
{
|
|
13
|
+
iid: { type: String, unique: true, default: () => generateRandomIID() },
|
|
14
|
+
user: { type: mongoose.Schema.Types.ObjectId, ref: "user", required: true },
|
|
15
|
+
organization: { type: mongoose.Schema.Types.ObjectId, ref: "organization", required: true },
|
|
16
|
+
role: { type: String, enum: ["owner", "admin", "member"], default: "member" }
|
|
17
|
+
},
|
|
18
|
+
{ timestamps: true }
|
|
19
|
+
);
|
|
20
|
+
|
|
21
|
+
UserOrganizationSchema.index({ user: 1, organization: 1 }, { unique: true });
|
|
22
|
+
const UserOrganization = mongoose.models.userorganization || model<IUserOrganization>("userorganization", UserOrganizationSchema);
|
|
23
|
+
export default UserOrganization;
|
|
@@ -1,24 +1,23 @@
|
|
|
1
1
|
import mongoose, { Document, Schema, model } from "mongoose";
|
|
2
|
+
import { generateRandomIID, PackageFeaturesConstants } from "../constant";
|
|
2
3
|
|
|
3
4
|
export interface IUserPermission extends Document {
|
|
5
|
+
iid: string;
|
|
4
6
|
userId: mongoose.Schema.Types.ObjectId;
|
|
5
7
|
clientId: mongoose.Schema.Types.ObjectId;
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
insights: boolean;
|
|
10
|
-
documentsAndLinks: boolean;
|
|
11
|
-
cvrReports: boolean;
|
|
12
|
-
abTesting: boolean;
|
|
13
|
-
abTestingDefault: boolean;
|
|
14
|
-
manageExperiments: boolean;
|
|
15
|
-
preCalculations: boolean;
|
|
16
|
-
}
|
|
8
|
+
organizationId: mongoose.Schema.Types.ObjectId;
|
|
9
|
+
role: string;
|
|
10
|
+
permissions: mongoose.Schema.Types.Mixed;
|
|
17
11
|
createdAt: Date;
|
|
18
12
|
updatedAt: Date;
|
|
19
13
|
}
|
|
20
14
|
|
|
21
15
|
const UserPermissionSchema = new Schema<IUserPermission>({
|
|
16
|
+
iid: {
|
|
17
|
+
type: String,
|
|
18
|
+
unique: true,
|
|
19
|
+
default: () => generateRandomIID()
|
|
20
|
+
},
|
|
22
21
|
userId: {
|
|
23
22
|
type: mongoose.Schema.Types.ObjectId,
|
|
24
23
|
ref: "user",
|
|
@@ -29,17 +28,28 @@ const UserPermissionSchema = new Schema<IUserPermission>({
|
|
|
29
28
|
ref: "client",
|
|
30
29
|
required: true,
|
|
31
30
|
},
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
dashboard: { type: Boolean, default: true },
|
|
31
|
+
role: {
|
|
32
|
+
type: String,
|
|
33
|
+
enum: ["member", "admin", "owner"],
|
|
34
|
+
default: "member",
|
|
35
|
+
},
|
|
36
|
+
organizationId: {
|
|
37
|
+
type: mongoose.Schema.Types.ObjectId,
|
|
38
|
+
ref: "organization",
|
|
39
|
+
required: true,
|
|
42
40
|
},
|
|
41
|
+
permissions: { type: mongoose.Schema.Types.Mixed, required: true, default: PackageFeaturesConstants },
|
|
42
|
+
// permissions: {
|
|
43
|
+
// abTestingDefault: { type: Boolean, default: true },
|
|
44
|
+
// abTesting: { type: Boolean, default: false },
|
|
45
|
+
// preCalculations: { type: Boolean, default: false },
|
|
46
|
+
// reporting: { type: Boolean, default: true },
|
|
47
|
+
// insights: { type: Boolean, default: true },
|
|
48
|
+
// documentsAndLinks: { type: Boolean, default: true },
|
|
49
|
+
// cvrReports: { type: Boolean, default: true },
|
|
50
|
+
// manageExperiments: { type: Boolean, default: false },
|
|
51
|
+
// dashboard: { type: Boolean, default: true },
|
|
52
|
+
// },
|
|
43
53
|
},
|
|
44
54
|
{
|
|
45
55
|
timestamps: true,
|
package/src/models/QueryLog.ts
DELETED
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import mongoose, { Document, Schema, model } from "mongoose";
|
|
2
|
-
|
|
3
|
-
export interface IQueryLog extends Document {
|
|
4
|
-
organizationId?: mongoose.Schema.Types.ObjectId;
|
|
5
|
-
query: string;
|
|
6
|
-
timeTaken: number;
|
|
7
|
-
user?: mongoose.Schema.Types.ObjectId;
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
const QueryLogSchema = new Schema<IQueryLog>(
|
|
11
|
-
{
|
|
12
|
-
organizationId: {
|
|
13
|
-
type: mongoose.Schema.Types.ObjectId,
|
|
14
|
-
ref: "organization",
|
|
15
|
-
default: null,
|
|
16
|
-
},
|
|
17
|
-
query: {
|
|
18
|
-
type: String,
|
|
19
|
-
},
|
|
20
|
-
timeTaken: {
|
|
21
|
-
type: Number,
|
|
22
|
-
},
|
|
23
|
-
user: {
|
|
24
|
-
type: mongoose.Schema.Types.ObjectId,
|
|
25
|
-
ref: "user",
|
|
26
|
-
},
|
|
27
|
-
},
|
|
28
|
-
{
|
|
29
|
-
timestamps: true,
|
|
30
|
-
}
|
|
31
|
-
);
|
|
32
|
-
|
|
33
|
-
const QueryLog = mongoose.models.querylog || model<IQueryLog>("querylog", QueryLogSchema);
|
|
34
|
-
|
|
35
|
-
export default QueryLog;
|
package/src/models/Segment.ts
DELETED
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
import mongoose, { Document, Schema, model } from "mongoose";
|
|
2
|
-
|
|
3
|
-
export interface ISegment extends Document {
|
|
4
|
-
name?: string;
|
|
5
|
-
key?: string;
|
|
6
|
-
values?: string;
|
|
7
|
-
segmentType?: string;
|
|
8
|
-
client?: mongoose.Schema.Types.ObjectId;
|
|
9
|
-
published?: boolean;
|
|
10
|
-
organizationId?: mongoose.Schema.Types.ObjectId;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
const SegmentSchema = new Schema<ISegment>(
|
|
14
|
-
{
|
|
15
|
-
organizationId: {
|
|
16
|
-
type: mongoose.Schema.Types.ObjectId,
|
|
17
|
-
ref: "organization",
|
|
18
|
-
default: null,
|
|
19
|
-
},
|
|
20
|
-
name: {
|
|
21
|
-
type: String,
|
|
22
|
-
},
|
|
23
|
-
key: {
|
|
24
|
-
type: String,
|
|
25
|
-
},
|
|
26
|
-
values: {
|
|
27
|
-
type: String,
|
|
28
|
-
},
|
|
29
|
-
segmentType: {
|
|
30
|
-
type: String,
|
|
31
|
-
default: "general",
|
|
32
|
-
},
|
|
33
|
-
client: {
|
|
34
|
-
type: [mongoose.Schema.Types.ObjectId],
|
|
35
|
-
ref: "client",
|
|
36
|
-
default: null,
|
|
37
|
-
},
|
|
38
|
-
published: {
|
|
39
|
-
type: Boolean,
|
|
40
|
-
default: true,
|
|
41
|
-
},
|
|
42
|
-
},
|
|
43
|
-
{
|
|
44
|
-
timestamps: true,
|
|
45
|
-
}
|
|
46
|
-
);
|
|
47
|
-
|
|
48
|
-
const Segment = mongoose.models.segment || model<ISegment>("segment", SegmentSchema);
|
|
49
|
-
|
|
50
|
-
export default Segment;
|
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
import mongoose, { Document, Schema, model } from "mongoose";
|
|
2
|
-
|
|
3
|
-
export interface ISegmentCombination extends Document {
|
|
4
|
-
name?: string;
|
|
5
|
-
combination?: [];
|
|
6
|
-
gagroup?: string;
|
|
7
|
-
secondaryFilters?: [];
|
|
8
|
-
segmentType?: string;
|
|
9
|
-
client?: mongoose.Schema.Types.ObjectId[];
|
|
10
|
-
published?: boolean;
|
|
11
|
-
order?: Number;
|
|
12
|
-
createdAt?: Date;
|
|
13
|
-
updatedAt?: Date;
|
|
14
|
-
organizationId?: mongoose.Schema.Types.ObjectId;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
const SegmentSchema = new Schema<ISegmentCombination>({
|
|
18
|
-
organizationId: {
|
|
19
|
-
type: mongoose.Schema.Types.ObjectId,
|
|
20
|
-
ref: "organization",
|
|
21
|
-
default: null,
|
|
22
|
-
},
|
|
23
|
-
name: {
|
|
24
|
-
type: String,
|
|
25
|
-
},
|
|
26
|
-
combination: {
|
|
27
|
-
type: [],
|
|
28
|
-
},
|
|
29
|
-
gagroup: {
|
|
30
|
-
typr: String,
|
|
31
|
-
},
|
|
32
|
-
secondaryFilters: {
|
|
33
|
-
type: [],
|
|
34
|
-
default: null,
|
|
35
|
-
},
|
|
36
|
-
segmentType: {
|
|
37
|
-
type: String,
|
|
38
|
-
default: "general",
|
|
39
|
-
},
|
|
40
|
-
client: {
|
|
41
|
-
type: [mongoose.Schema.Types.ObjectId],
|
|
42
|
-
ref: "client",
|
|
43
|
-
default: null,
|
|
44
|
-
},
|
|
45
|
-
published: {
|
|
46
|
-
type: Boolean,
|
|
47
|
-
default: true,
|
|
48
|
-
},
|
|
49
|
-
order: {
|
|
50
|
-
type: Number,
|
|
51
|
-
default: 1,
|
|
52
|
-
},
|
|
53
|
-
createdAt: {
|
|
54
|
-
type: Date,
|
|
55
|
-
default: new Date(),
|
|
56
|
-
},
|
|
57
|
-
updatedAt: {
|
|
58
|
-
type: Date,
|
|
59
|
-
default: new Date(),
|
|
60
|
-
},
|
|
61
|
-
});
|
|
62
|
-
|
|
63
|
-
const SegmentCombination = mongoose.models.segmentcombination || model<ISegmentCombination>(
|
|
64
|
-
"segmentcombination",
|
|
65
|
-
SegmentSchema
|
|
66
|
-
);
|
|
67
|
-
|
|
68
|
-
export default SegmentCombination;
|