codebase-models 2.1.24 → 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 +7 -4
- package/dist/index.js +14 -8
- package/dist/src/constant.d.ts +24 -1
- package/dist/src/constant.js +89 -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/{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 +12 -6
- package/package.json +1 -1
- package/src/constant.ts +88 -3
- 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/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,33 @@
|
|
|
1
|
+
# This workflow will run tests using node and then publish a package to GitHub Packages when a release is created
|
|
2
|
+
# For more information see: https://docs.github.com/en/actions/publishing-packages/publishing-nodejs-packages
|
|
3
|
+
|
|
4
|
+
name: Publish Codebase Shared Models on NPM (Stage)
|
|
5
|
+
|
|
6
|
+
on:
|
|
7
|
+
push:
|
|
8
|
+
branches:
|
|
9
|
+
- staging
|
|
10
|
+
|
|
11
|
+
jobs:
|
|
12
|
+
build:
|
|
13
|
+
runs-on: ubuntu-latest
|
|
14
|
+
steps:
|
|
15
|
+
- uses: actions/checkout@v4
|
|
16
|
+
- uses: actions/setup-node@v4
|
|
17
|
+
with:
|
|
18
|
+
node-version: 20
|
|
19
|
+
- run: npm ci
|
|
20
|
+
|
|
21
|
+
publish-npm:
|
|
22
|
+
needs: build
|
|
23
|
+
runs-on: ubuntu-latest
|
|
24
|
+
steps:
|
|
25
|
+
- uses: actions/checkout@v4
|
|
26
|
+
- uses: actions/setup-node@v4
|
|
27
|
+
with:
|
|
28
|
+
node-version: 20
|
|
29
|
+
registry-url: https://registry.npmjs.org/
|
|
30
|
+
- run: npm ci
|
|
31
|
+
- run: npm publish --tag stage
|
|
32
|
+
env:
|
|
33
|
+
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}
|
package/dist/index.d.ts
CHANGED
|
@@ -25,7 +25,6 @@
|
|
|
25
25
|
import mongoose from "mongoose";
|
|
26
26
|
import Client from "./src/models/Client";
|
|
27
27
|
import ClientReportsTemp from "./src/models/ClientReportsTemp";
|
|
28
|
-
import QueryLog from "./src/models/QueryLog";
|
|
29
28
|
import Report from "./src/models/Report";
|
|
30
29
|
import Test from "./src/models/Test";
|
|
31
30
|
import TestSequentialValue from "./src/models/TestSequentialValue";
|
|
@@ -57,8 +56,6 @@ import ReadNotification from "./src/models/ReadNotification";
|
|
|
57
56
|
import Organization from "./src/models/Organization";
|
|
58
57
|
import Role from "./src/models/Role";
|
|
59
58
|
import SavedSegment from "./src/models/SavedSegment";
|
|
60
|
-
import Segment from "./src/models/Segment";
|
|
61
|
-
import SegmentCombination from "./src/models/SegmentCombination";
|
|
62
59
|
import Snippet from "./src/models/Snippet";
|
|
63
60
|
import StageInCustomerJourney from "./src/models/StageInCustomerJourney";
|
|
64
61
|
import Tag from "./src/models/Tag";
|
|
@@ -76,5 +73,11 @@ import { generateRandomIID, RolesConstants } from "./src/constant";
|
|
|
76
73
|
import TestTimeline from "./src/models/TestTimeline";
|
|
77
74
|
import CronData from "./src/models/CronData";
|
|
78
75
|
import CronConfig from "./src/models/CronConfig";
|
|
76
|
+
import UserIdentity from "./src/models/UserIdentity";
|
|
77
|
+
import UserOrganization from "./src/models/UserOrganization";
|
|
78
|
+
import Package from "./src/models/Package";
|
|
79
|
+
import Invitation from "./src/models/Invitation";
|
|
80
|
+
import Thread from "./src/models/Thread";
|
|
81
|
+
import ThreadMessage from "./src/models/ThreadMessage";
|
|
79
82
|
export declare function connect(uri: string, options?: mongoose.ConnectOptions | undefined): Promise<typeof mongoose>;
|
|
80
|
-
export { generateRandomIID, RolesConstants, Client, ClientReportsTemp,
|
|
83
|
+
export { generateRandomIID, RolesConstants, Client, ClientReportsTemp, Report, Test, TestSequentialValue, User, AppEvent, Announcement, ClientAdditionalRevenue, ClientLearning, ClientLinks, ClientNextStep, ClientNote, ClientRetention, ClientStrategy, ClientSurvey, CVRReport, Faq, Feedback, Goal, Hypothesis, HypothesisSheet, LandingPages, NewIdeas, Notification, Page, PageElement, PageTestType, Portfolio, ReadNotification, Role, CustomQuery, SavedSegment, TestTimeline, Snippet, StageInCustomerJourney, Tag, Temp, Tier, Trigger, ClientScript, Audience, Environment, Organization, PrecalculationFilters, BqPreCompiledData, CronData, CronConfig, UserPermission, UserIdentity, UserOrganization, Package, Invitation, Thread, ThreadMessage, };
|
package/dist/index.js
CHANGED
|
@@ -12,15 +12,13 @@ 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.Organization = exports.Environment = exports.Audience = exports.ClientScript = exports.Trigger = exports.Tier = exports.Temp = exports.Tag = exports.StageInCustomerJourney = exports.Snippet = exports.
|
|
16
|
-
exports.
|
|
15
|
+
exports.CronData = exports.BqPreCompiledData = exports.PrecalculationFilters = exports.Organization = exports.Environment = exports.Audience = exports.ClientScript = exports.Trigger = exports.Tier = exports.Temp = exports.Tag = exports.StageInCustomerJourney = exports.Snippet = exports.TestTimeline = exports.SavedSegment = exports.CustomQuery = exports.Role = exports.ReadNotification = exports.Portfolio = exports.PageTestType = exports.PageElement = exports.Page = exports.Notification = exports.NewIdeas = exports.LandingPages = exports.HypothesisSheet = exports.Hypothesis = exports.Goal = exports.Feedback = exports.Faq = exports.CVRReport = exports.ClientSurvey = exports.ClientStrategy = exports.ClientRetention = exports.ClientNote = exports.ClientNextStep = exports.ClientLinks = exports.ClientLearning = exports.ClientAdditionalRevenue = exports.Announcement = exports.AppEvent = exports.User = exports.TestSequentialValue = exports.Test = exports.Report = exports.ClientReportsTemp = exports.Client = exports.RolesConstants = exports.generateRandomIID = exports.connect = void 0;
|
|
16
|
+
exports.ThreadMessage = exports.Thread = exports.Invitation = exports.Package = exports.UserOrganization = exports.UserIdentity = exports.UserPermission = exports.CronConfig = void 0;
|
|
17
17
|
const mongoose_1 = __importDefault(require("mongoose"));
|
|
18
18
|
const Client_1 = __importDefault(require("./src/models/Client"));
|
|
19
19
|
exports.Client = Client_1.default;
|
|
20
20
|
const ClientReportsTemp_1 = __importDefault(require("./src/models/ClientReportsTemp"));
|
|
21
21
|
exports.ClientReportsTemp = ClientReportsTemp_1.default;
|
|
22
|
-
const QueryLog_1 = __importDefault(require("./src/models/QueryLog"));
|
|
23
|
-
exports.QueryLog = QueryLog_1.default;
|
|
24
22
|
const Report_1 = __importDefault(require("./src/models/Report"));
|
|
25
23
|
exports.Report = Report_1.default;
|
|
26
24
|
const Test_1 = __importDefault(require("./src/models/Test"));
|
|
@@ -83,10 +81,6 @@ const Role_1 = __importDefault(require("./src/models/Role"));
|
|
|
83
81
|
exports.Role = Role_1.default;
|
|
84
82
|
const SavedSegment_1 = __importDefault(require("./src/models/SavedSegment"));
|
|
85
83
|
exports.SavedSegment = SavedSegment_1.default;
|
|
86
|
-
const Segment_1 = __importDefault(require("./src/models/Segment"));
|
|
87
|
-
exports.Segment = Segment_1.default;
|
|
88
|
-
const SegmentCombination_1 = __importDefault(require("./src/models/SegmentCombination"));
|
|
89
|
-
exports.SegmentCombination = SegmentCombination_1.default;
|
|
90
84
|
const Snippet_1 = __importDefault(require("./src/models/Snippet"));
|
|
91
85
|
exports.Snippet = Snippet_1.default;
|
|
92
86
|
const StageInCustomerJourney_1 = __importDefault(require("./src/models/StageInCustomerJourney"));
|
|
@@ -122,6 +116,18 @@ const CronData_1 = __importDefault(require("./src/models/CronData"));
|
|
|
122
116
|
exports.CronData = CronData_1.default;
|
|
123
117
|
const CronConfig_1 = __importDefault(require("./src/models/CronConfig"));
|
|
124
118
|
exports.CronConfig = CronConfig_1.default;
|
|
119
|
+
const UserIdentity_1 = __importDefault(require("./src/models/UserIdentity"));
|
|
120
|
+
exports.UserIdentity = UserIdentity_1.default;
|
|
121
|
+
const UserOrganization_1 = __importDefault(require("./src/models/UserOrganization"));
|
|
122
|
+
exports.UserOrganization = UserOrganization_1.default;
|
|
123
|
+
const Package_1 = __importDefault(require("./src/models/Package"));
|
|
124
|
+
exports.Package = Package_1.default;
|
|
125
|
+
const Invitation_1 = __importDefault(require("./src/models/Invitation"));
|
|
126
|
+
exports.Invitation = Invitation_1.default;
|
|
127
|
+
const Thread_1 = __importDefault(require("./src/models/Thread"));
|
|
128
|
+
exports.Thread = Thread_1.default;
|
|
129
|
+
const ThreadMessage_1 = __importDefault(require("./src/models/ThreadMessage"));
|
|
130
|
+
exports.ThreadMessage = ThreadMessage_1.default;
|
|
125
131
|
function seedRoles() {
|
|
126
132
|
return __awaiter(this, void 0, void 0, function* () {
|
|
127
133
|
const checkRoles = yield Role_1.default.countDocuments();
|
package/dist/src/constant.d.ts
CHANGED
|
@@ -15,5 +15,28 @@ declare const RolesConstants: string[];
|
|
|
15
15
|
* @throws Error if UUID generation fails
|
|
16
16
|
*/
|
|
17
17
|
declare const generateRandomIID: () => string;
|
|
18
|
-
|
|
18
|
+
declare const PermissionsConstants: {
|
|
19
|
+
dashboard: string;
|
|
20
|
+
reporting: string;
|
|
21
|
+
insights: string;
|
|
22
|
+
documentsAndLinks: string;
|
|
23
|
+
cvrReports: string;
|
|
24
|
+
abTesting: string;
|
|
25
|
+
abTestingDefault: string;
|
|
26
|
+
manageOrganizations: string;
|
|
27
|
+
manageInvitations: string;
|
|
28
|
+
manageClients: string;
|
|
29
|
+
};
|
|
30
|
+
declare const PackageFeaturesConstants: ({
|
|
31
|
+
name: string;
|
|
32
|
+
value: boolean;
|
|
33
|
+
description: string;
|
|
34
|
+
allowedCount: null;
|
|
35
|
+
} | {
|
|
36
|
+
name: string;
|
|
37
|
+
value: boolean;
|
|
38
|
+
description: string;
|
|
39
|
+
allowedCount: number;
|
|
40
|
+
})[];
|
|
41
|
+
export { generateRandomIID, RolesConstants, PermissionsConstants, PackageFeaturesConstants };
|
|
19
42
|
export default HypothesisSheetConstants;
|
package/dist/src/constant.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.RolesConstants = exports.generateRandomIID = void 0;
|
|
3
|
+
exports.PackageFeaturesConstants = exports.PermissionsConstants = exports.RolesConstants = exports.generateRandomIID = void 0;
|
|
4
4
|
const uuid_1 = require("uuid");
|
|
5
5
|
const HypothesisSheetConstants = {
|
|
6
6
|
NO: 0,
|
|
@@ -17,8 +17,6 @@ const HypothesisSheetConstants = {
|
|
|
17
17
|
const RolesConstants = [
|
|
18
18
|
"USER",
|
|
19
19
|
"ADMIN",
|
|
20
|
-
// "EDITOR",
|
|
21
|
-
// "COLLABORATOR",
|
|
22
20
|
"CLIENT",
|
|
23
21
|
"EXTERNAL",
|
|
24
22
|
"QA",
|
|
@@ -40,4 +38,92 @@ const generateRandomIID = () => {
|
|
|
40
38
|
}
|
|
41
39
|
};
|
|
42
40
|
exports.generateRandomIID = generateRandomIID;
|
|
41
|
+
const PermissionsConstants = {
|
|
42
|
+
dashboard: "dashboard",
|
|
43
|
+
reporting: "reporting",
|
|
44
|
+
insights: "insights",
|
|
45
|
+
documentsAndLinks: "documentsAndLinks",
|
|
46
|
+
cvrReports: "cvrReports",
|
|
47
|
+
abTesting: "abTesting",
|
|
48
|
+
abTestingDefault: "abTestingDefault",
|
|
49
|
+
manageOrganizations: "manageOrganizations",
|
|
50
|
+
manageInvitations: "manageInvitations",
|
|
51
|
+
manageClients: "manageClients",
|
|
52
|
+
};
|
|
53
|
+
exports.PermissionsConstants = PermissionsConstants;
|
|
54
|
+
const PackageFeaturesConstants = [
|
|
55
|
+
{
|
|
56
|
+
name: "DASHBOARD",
|
|
57
|
+
value: true,
|
|
58
|
+
description: "Access to the dashboard",
|
|
59
|
+
allowedCount: null,
|
|
60
|
+
},
|
|
61
|
+
{
|
|
62
|
+
name: "REPORTING",
|
|
63
|
+
value: true,
|
|
64
|
+
description: "Access to the reporting",
|
|
65
|
+
allowedCount: null,
|
|
66
|
+
},
|
|
67
|
+
{
|
|
68
|
+
name: "INSIGHTS",
|
|
69
|
+
value: true,
|
|
70
|
+
description: "Access to the insights",
|
|
71
|
+
allowedCount: null,
|
|
72
|
+
},
|
|
73
|
+
{
|
|
74
|
+
name: "DOCUMENTSANDLINKS",
|
|
75
|
+
value: true,
|
|
76
|
+
description: "Access to the documents and links",
|
|
77
|
+
allowedCount: 5,
|
|
78
|
+
},
|
|
79
|
+
{
|
|
80
|
+
name: "CVRREPORTS",
|
|
81
|
+
value: true,
|
|
82
|
+
description: "Access to the cvr reports",
|
|
83
|
+
allowedCount: null,
|
|
84
|
+
},
|
|
85
|
+
{
|
|
86
|
+
name: "ABTESTING",
|
|
87
|
+
value: false,
|
|
88
|
+
description: "Access to the ab testing",
|
|
89
|
+
allowedCount: null,
|
|
90
|
+
},
|
|
91
|
+
{
|
|
92
|
+
name: "ABTESTINGDEFAULT",
|
|
93
|
+
value: true,
|
|
94
|
+
description: "Access to the ab testing default",
|
|
95
|
+
allowedCount: null,
|
|
96
|
+
},
|
|
97
|
+
{
|
|
98
|
+
name: "MANAGEEXPERIMENTS",
|
|
99
|
+
value: true,
|
|
100
|
+
description: "Access to the experiments",
|
|
101
|
+
allowedCount: null,
|
|
102
|
+
},
|
|
103
|
+
{
|
|
104
|
+
name: "PRECALCULATIONS",
|
|
105
|
+
value: false,
|
|
106
|
+
description: "Access to the pre calculations",
|
|
107
|
+
allowedCount: null,
|
|
108
|
+
},
|
|
109
|
+
{
|
|
110
|
+
name: "MANAGEORGANIZATIONS",
|
|
111
|
+
value: true,
|
|
112
|
+
description: "Access to the organizations",
|
|
113
|
+
allowedCount: 1,
|
|
114
|
+
},
|
|
115
|
+
{
|
|
116
|
+
name: "MANAGEINVITATIONS",
|
|
117
|
+
value: true,
|
|
118
|
+
description: "Access to the invitations",
|
|
119
|
+
allowedCount: 1,
|
|
120
|
+
},
|
|
121
|
+
{
|
|
122
|
+
name: "MANAGECLIENTS",
|
|
123
|
+
value: true,
|
|
124
|
+
description: "Access to the clients",
|
|
125
|
+
allowedCount: 3,
|
|
126
|
+
},
|
|
127
|
+
];
|
|
128
|
+
exports.PackageFeaturesConstants = PackageFeaturesConstants;
|
|
43
129
|
exports.default = HypothesisSheetConstants;
|
|
@@ -30,7 +30,7 @@ export interface IProperty extends Document {
|
|
|
30
30
|
}
|
|
31
31
|
export interface IClient extends Document {
|
|
32
32
|
iid: string;
|
|
33
|
-
|
|
33
|
+
organization: mongoose.Schema.Types.ObjectId;
|
|
34
34
|
name: string;
|
|
35
35
|
slug?: string;
|
|
36
36
|
viewId?: string;
|
|
@@ -48,10 +48,14 @@ const ClientSchema = new mongoose_1.Schema({
|
|
|
48
48
|
iid: {
|
|
49
49
|
type: String,
|
|
50
50
|
trim: true,
|
|
51
|
+
unique: true,
|
|
52
|
+
default: () => (0, constant_1.generateRandomIID)()
|
|
51
53
|
},
|
|
52
|
-
|
|
54
|
+
organization: { type: mongoose_1.default.Schema.Types.ObjectId,
|
|
53
55
|
ref: "organization",
|
|
54
|
-
default: null
|
|
56
|
+
default: null,
|
|
57
|
+
required: true
|
|
58
|
+
},
|
|
55
59
|
name: { type: String, required: true },
|
|
56
60
|
slug: {
|
|
57
61
|
type: String,
|
|
@@ -100,10 +104,9 @@ ClientSchema.pre('save', function (next) {
|
|
|
100
104
|
next();
|
|
101
105
|
});
|
|
102
106
|
});
|
|
103
|
-
ClientSchema.index({ iid: 1 }, { unique: true });
|
|
104
107
|
// Add compound indexes for better query performance
|
|
105
108
|
ClientSchema.index({ active: 1 });
|
|
106
|
-
ClientSchema.index({
|
|
109
|
+
ClientSchema.index({ organization: 1, active: 1 });
|
|
107
110
|
ClientSchema.index({ name: 1 }, { collation: { locale: 'en', strength: 2 } }); // Case-insensitive search
|
|
108
111
|
ClientSchema.index({ tier: 1, active: 1 }); // For tier-based queries
|
|
109
112
|
ClientSchema.index({ onboardDate: 1 }); // For date-based queries
|
|
@@ -23,18 +23,19 @@
|
|
|
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
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
26
|
+
export interface IInvitation extends Document {
|
|
27
|
+
iid: string;
|
|
28
|
+
email: string;
|
|
29
|
+
invitedBy: mongoose.Types.ObjectId;
|
|
30
|
+
organization: mongoose.Types.ObjectId;
|
|
31
|
+
client?: mongoose.Types.ObjectId;
|
|
32
|
+
role?: string;
|
|
33
|
+
permissions?: mongoose.Schema.Types.Mixed;
|
|
34
|
+
token: string;
|
|
35
|
+
status: string;
|
|
36
|
+
expiresAt: Date;
|
|
37
|
+
createdAt: Date;
|
|
38
|
+
updatedAt: Date;
|
|
38
39
|
}
|
|
39
|
-
declare const
|
|
40
|
-
export default
|
|
40
|
+
declare const Invitation: mongoose.Model<any, {}, {}, {}, any, any>;
|
|
41
|
+
export default Invitation;
|
|
@@ -0,0 +1,55 @@
|
|
|
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 constant_1 = require("../constant");
|
|
28
|
+
const InvitationSchema = new mongoose_1.Schema({
|
|
29
|
+
iid: { type: String, unique: true, default: () => (0, constant_1.generateRandomIID)() },
|
|
30
|
+
email: { type: String, required: true },
|
|
31
|
+
invitedBy: { type: mongoose_1.default.Schema.Types.ObjectId, ref: "user", required: true },
|
|
32
|
+
organization: { type: mongoose_1.default.Schema.Types.ObjectId, ref: "organization", required: true },
|
|
33
|
+
client: { type: mongoose_1.default.Schema.Types.ObjectId, ref: "client" },
|
|
34
|
+
role: { type: String, enum: ["owner", "admin", "member"], default: "member" },
|
|
35
|
+
permissions: { type: mongoose_1.default.Schema.Types.Mixed, required: true, default: {
|
|
36
|
+
dashboard: true,
|
|
37
|
+
reporting: false,
|
|
38
|
+
insights: false,
|
|
39
|
+
documentsAndLinks: false,
|
|
40
|
+
cvrReports: false,
|
|
41
|
+
abTesting: false,
|
|
42
|
+
abTestingDefault: true,
|
|
43
|
+
manageExperiments: false,
|
|
44
|
+
preCalculations: false,
|
|
45
|
+
} },
|
|
46
|
+
token: { type: String, unique: true, required: true },
|
|
47
|
+
status: { type: String, enum: ["pending", "accepted", "expired", "revoked"], default: "pending" },
|
|
48
|
+
expiresAt: { type: Date, default: Date.now() + 1000 * 60 * 60 * 24 * 30 },
|
|
49
|
+
}, {
|
|
50
|
+
timestamps: true
|
|
51
|
+
});
|
|
52
|
+
InvitationSchema.index({ email: 1, organization: 1 });
|
|
53
|
+
InvitationSchema.index({ token: 1 }, { unique: true });
|
|
54
|
+
const Invitation = mongoose_1.default.models.invitation || (0, mongoose_1.model)("invitation", InvitationSchema);
|
|
55
|
+
exports.default = Invitation;
|
|
@@ -24,22 +24,15 @@
|
|
|
24
24
|
/// <reference types="mongoose/types/inferschematype" />
|
|
25
25
|
import mongoose, { Document } from "mongoose";
|
|
26
26
|
export interface IOrganization extends Document {
|
|
27
|
+
iid: string;
|
|
27
28
|
name: string;
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
zip: string;
|
|
36
|
-
country: string;
|
|
37
|
-
phone: string;
|
|
38
|
-
logo: string;
|
|
39
|
-
website: string;
|
|
40
|
-
createdAt: Date;
|
|
41
|
-
updatedAt: Date;
|
|
42
|
-
isActive: boolean;
|
|
29
|
+
ownerId: mongoose.Schema.Types.ObjectId;
|
|
30
|
+
stripeCustomerId?: string;
|
|
31
|
+
packageId?: mongoose.Schema.Types.ObjectId;
|
|
32
|
+
subscriptionId: String;
|
|
33
|
+
subscriptionStatus: String;
|
|
34
|
+
lastPaymentDate: Date;
|
|
35
|
+
currentPeriodEnd: Date;
|
|
43
36
|
}
|
|
44
37
|
declare const Organization: mongoose.Model<any, {}, {}, {}, any, any>;
|
|
45
38
|
export default Organization;
|
|
@@ -24,67 +24,19 @@ 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 OrganizationSchema = new mongoose_1.Schema({
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
},
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
adminEmail: {
|
|
38
|
-
type: String,
|
|
39
|
-
required: true,
|
|
40
|
-
},
|
|
41
|
-
adminContact: {
|
|
42
|
-
type: String,
|
|
43
|
-
required: true,
|
|
44
|
-
},
|
|
45
|
-
createdBy: {
|
|
46
|
-
type: mongoose_1.default.Schema.Types.ObjectId,
|
|
47
|
-
ref: "user",
|
|
48
|
-
},
|
|
49
|
-
address: {
|
|
50
|
-
type: String,
|
|
51
|
-
required: true,
|
|
52
|
-
},
|
|
53
|
-
city: {
|
|
54
|
-
type: String,
|
|
55
|
-
required: true,
|
|
56
|
-
},
|
|
57
|
-
state: {
|
|
58
|
-
type: String,
|
|
59
|
-
required: true,
|
|
60
|
-
},
|
|
61
|
-
zip: {
|
|
62
|
-
type: String,
|
|
63
|
-
required: true,
|
|
64
|
-
},
|
|
65
|
-
country: {
|
|
66
|
-
type: String,
|
|
67
|
-
required: true,
|
|
68
|
-
},
|
|
69
|
-
phone: {
|
|
70
|
-
type: String,
|
|
71
|
-
required: true,
|
|
72
|
-
},
|
|
73
|
-
logo: {
|
|
74
|
-
type: String,
|
|
75
|
-
required: true,
|
|
76
|
-
},
|
|
77
|
-
website: {
|
|
78
|
-
type: String,
|
|
79
|
-
required: true,
|
|
80
|
-
},
|
|
81
|
-
isActive: {
|
|
82
|
-
type: Boolean,
|
|
83
|
-
default: true,
|
|
84
|
-
},
|
|
29
|
+
iid: { type: String, default: () => (0, constant_1.generateRandomIID)() },
|
|
30
|
+
name: { type: String, required: true },
|
|
31
|
+
ownerId: { type: mongoose_1.default.Schema.Types.ObjectId, ref: "user", required: true },
|
|
32
|
+
stripeCustomerId: String,
|
|
33
|
+
packageId: { type: mongoose_1.default.Types.ObjectId, ref: "package" },
|
|
34
|
+
subscriptionId: String,
|
|
35
|
+
subscriptionStatus: String,
|
|
36
|
+
lastPaymentDate: Date,
|
|
37
|
+
currentPeriodEnd: Date,
|
|
85
38
|
}, {
|
|
86
39
|
timestamps: true
|
|
87
40
|
});
|
|
88
41
|
const Organization = mongoose_1.default.models.organization || (0, mongoose_1.model)("organization", OrganizationSchema);
|
|
89
|
-
OrganizationSchema.index({ name: 1, isActive: 1 });
|
|
90
42
|
exports.default = Organization;
|
|
@@ -23,11 +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
|
-
|
|
26
|
+
export interface IPackage extends Document {
|
|
27
|
+
iid: string;
|
|
28
|
+
name: string;
|
|
29
|
+
stripeProductId: string;
|
|
30
|
+
features: mongoose.Schema.Types.Mixed;
|
|
31
31
|
}
|
|
32
|
-
declare const
|
|
33
|
-
export default
|
|
32
|
+
declare const Package: mongoose.Model<any, {}, {}, {}, any, any>;
|
|
33
|
+
export default Package;
|
|
@@ -24,24 +24,15 @@ 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
|
-
type: String,
|
|
35
|
-
},
|
|
36
|
-
timeTaken: {
|
|
37
|
-
type: Number,
|
|
38
|
-
},
|
|
39
|
-
user: {
|
|
40
|
-
type: mongoose_1.default.Schema.Types.ObjectId,
|
|
41
|
-
ref: "user",
|
|
42
|
-
},
|
|
27
|
+
const constant_1 = require("../constant");
|
|
28
|
+
const PackageSchema = new mongoose_1.Schema({
|
|
29
|
+
iid: { type: String, unique: true, default: () => (0, constant_1.generateRandomIID)() },
|
|
30
|
+
name: { type: String, required: true },
|
|
31
|
+
stripeProductId: { type: String },
|
|
32
|
+
// userPermissions: { type: mongoose.Schema.Types.ObjectId, ref: "userpermission", required: true },
|
|
33
|
+
features: { type: mongoose_1.default.Schema.Types.Mixed, required: true, default: constant_1.PackageFeaturesConstants },
|
|
43
34
|
}, {
|
|
44
|
-
timestamps: true
|
|
35
|
+
timestamps: true
|
|
45
36
|
});
|
|
46
|
-
const
|
|
47
|
-
exports.default =
|
|
37
|
+
const Package = mongoose_1.default.models.package || (0, mongoose_1.model)("package", PackageSchema);
|
|
38
|
+
exports.default = Package;
|
|
@@ -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;
|