codebase-models 3.0.1 → 3.0.3
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/src/models/Client.d.ts +5 -0
- package/dist/src/models/Client.js +17 -11
- package/dist/src/models/CustomQuery.d.ts +2 -14
- package/dist/src/models/CustomQuery.js +1 -1
- package/dist/src/models/HypothesisSheet.d.ts +1 -3
- package/dist/src/models/HypothesisSheet.js +1 -1
- package/dist/src/models/NewIdeas.d.ts +1 -3
- package/dist/src/models/NewIdeas.js +1 -1
- package/package.json +1 -1
- package/src/models/Client.ts +36 -23
- package/src/models/CustomQuery.ts +1 -1
- package/src/models/HypothesisSheet.ts +2 -2
- package/src/models/NewIdeas.ts +1 -1
|
@@ -28,6 +28,10 @@ export interface IProperty extends Document {
|
|
|
28
28
|
viewId: string;
|
|
29
29
|
platform?: string;
|
|
30
30
|
}
|
|
31
|
+
export interface IShopify extends Document {
|
|
32
|
+
shopDomain: string;
|
|
33
|
+
accessToken: string;
|
|
34
|
+
}
|
|
31
35
|
export interface IClient extends Document {
|
|
32
36
|
iid: string;
|
|
33
37
|
organization: mongoose.Schema.Types.ObjectId;
|
|
@@ -47,6 +51,7 @@ export interface IClient extends Document {
|
|
|
47
51
|
NDAStatus?: boolean;
|
|
48
52
|
retainerValue: number;
|
|
49
53
|
useIntraDayTable: boolean;
|
|
54
|
+
shopify?: IShopify;
|
|
50
55
|
}
|
|
51
56
|
declare const Client: mongoose.Model<any, {}, {}, {}, any, any>;
|
|
52
57
|
export default Client;
|
|
@@ -42,26 +42,31 @@ mongoose_1.default.plugin(mongoose_slug_updater_1.default);
|
|
|
42
42
|
const PropertySchema = new mongoose_1.Schema({
|
|
43
43
|
propertyname: { type: String, required: true },
|
|
44
44
|
viewId: { type: String, required: true },
|
|
45
|
-
platform: { type: String, default: "GA4" }
|
|
45
|
+
platform: { type: String, default: "GA4" },
|
|
46
|
+
});
|
|
47
|
+
const shopifySchema = new mongoose_1.Schema({
|
|
48
|
+
shopDomain: { type: String, required: true },
|
|
49
|
+
accessToken: { type: String, required: true },
|
|
46
50
|
});
|
|
47
51
|
const ClientSchema = new mongoose_1.Schema({
|
|
48
52
|
iid: {
|
|
49
53
|
type: String,
|
|
50
54
|
trim: true,
|
|
51
55
|
unique: true,
|
|
52
|
-
default: () => (0, constant_1.generateRandomIID)()
|
|
56
|
+
default: () => (0, constant_1.generateRandomIID)(),
|
|
53
57
|
},
|
|
54
|
-
organization: {
|
|
58
|
+
organization: {
|
|
59
|
+
type: mongoose_1.default.Schema.Types.ObjectId,
|
|
55
60
|
ref: "organization",
|
|
56
61
|
default: null,
|
|
57
|
-
required: true
|
|
62
|
+
required: true,
|
|
58
63
|
},
|
|
59
64
|
name: { type: String, required: true },
|
|
60
65
|
slug: {
|
|
61
66
|
type: String,
|
|
62
67
|
slug: ["name"],
|
|
63
68
|
slugPaddingSize: 4,
|
|
64
|
-
unique: true
|
|
69
|
+
unique: true,
|
|
65
70
|
},
|
|
66
71
|
viewId: { type: String },
|
|
67
72
|
portfolioClient: { type: Boolean, default: false },
|
|
@@ -69,7 +74,7 @@ const ClientSchema = new mongoose_1.Schema({
|
|
|
69
74
|
tier: {
|
|
70
75
|
type: mongoose_1.default.Schema.Types.ObjectId,
|
|
71
76
|
ref: "tier",
|
|
72
|
-
default: null
|
|
77
|
+
default: null,
|
|
73
78
|
},
|
|
74
79
|
active: { type: Boolean, default: true },
|
|
75
80
|
currency: { type: String, default: "USD" },
|
|
@@ -77,18 +82,19 @@ const ClientSchema = new mongoose_1.Schema({
|
|
|
77
82
|
createdBy: {
|
|
78
83
|
type: mongoose_1.default.Schema.Types.ObjectId,
|
|
79
84
|
ref: "user",
|
|
80
|
-
default: null
|
|
85
|
+
default: null,
|
|
81
86
|
},
|
|
82
87
|
onboardDate: { type: Date, default: Date.now },
|
|
83
88
|
bqClientId: { type: String, default: null },
|
|
84
89
|
defaultDataSet: { type: String },
|
|
85
90
|
NDAStatus: { type: Boolean, default: false },
|
|
86
91
|
retainerValue: { type: Number },
|
|
87
|
-
useIntraDayTable: { type: Boolean }
|
|
92
|
+
useIntraDayTable: { type: Boolean },
|
|
93
|
+
shopify: { type: shopifySchema, default: null },
|
|
88
94
|
}, {
|
|
89
|
-
timestamps: true
|
|
95
|
+
timestamps: true,
|
|
90
96
|
});
|
|
91
|
-
ClientSchema.pre(
|
|
97
|
+
ClientSchema.pre("save", function (next) {
|
|
92
98
|
return __awaiter(this, void 0, void 0, function* () {
|
|
93
99
|
if (!this.iid) {
|
|
94
100
|
let unique = false;
|
|
@@ -107,7 +113,7 @@ ClientSchema.pre('save', function (next) {
|
|
|
107
113
|
// Add compound indexes for better query performance
|
|
108
114
|
ClientSchema.index({ active: 1 });
|
|
109
115
|
ClientSchema.index({ organization: 1, active: 1 });
|
|
110
|
-
ClientSchema.index({ name: 1 }, { collation: { locale:
|
|
116
|
+
ClientSchema.index({ name: 1 }, { collation: { locale: "en", strength: 2 } }); // Case-insensitive search
|
|
111
117
|
ClientSchema.index({ tier: 1, active: 1 }); // For tier-based queries
|
|
112
118
|
ClientSchema.index({ onboardDate: 1 }); // For date-based queries
|
|
113
119
|
ClientSchema.index({ portfolioClient: 1, active: 1 }); // For portfolio client queries
|
|
@@ -22,18 +22,6 @@
|
|
|
22
22
|
/// <reference types="mongoose/types/validation" />
|
|
23
23
|
/// <reference types="mongoose/types/virtuals" />
|
|
24
24
|
/// <reference types="mongoose/types/inferschematype" />
|
|
25
|
-
import mongoose
|
|
26
|
-
|
|
27
|
-
iid: string;
|
|
28
|
-
organizationId?: mongoose.Schema.Types.ObjectId;
|
|
29
|
-
title: string;
|
|
30
|
-
module: string;
|
|
31
|
-
client: mongoose.Schema.Types.ObjectId;
|
|
32
|
-
query: string;
|
|
33
|
-
metadata: any;
|
|
34
|
-
createdBy?: mongoose.Schema.Types.ObjectId;
|
|
35
|
-
}
|
|
36
|
-
declare const CustomQuery: mongoose.Model<ICustomQuery, {}, {}, {}, mongoose.Document<unknown, {}, ICustomQuery> & ICustomQuery & {
|
|
37
|
-
_id: mongoose.Types.ObjectId;
|
|
38
|
-
}, any>;
|
|
25
|
+
import mongoose from 'mongoose';
|
|
26
|
+
declare const CustomQuery: mongoose.Model<any, {}, {}, {}, any, any>;
|
|
39
27
|
export default CustomQuery;
|
|
@@ -65,5 +65,5 @@ CustomQuerySchema.pre('save', function (next) {
|
|
|
65
65
|
next();
|
|
66
66
|
});
|
|
67
67
|
});
|
|
68
|
-
const CustomQuery = (0, mongoose_1.model)('
|
|
68
|
+
const CustomQuery = mongoose_1.default.models.customquery || (0, mongoose_1.model)('customquery', CustomQuerySchema);
|
|
69
69
|
exports.default = CustomQuery;
|
|
@@ -44,7 +44,5 @@ export interface IHypothesisSheet extends Document {
|
|
|
44
44
|
tested?: Boolean;
|
|
45
45
|
createdBy?: mongoose.Schema.Types.ObjectId;
|
|
46
46
|
}
|
|
47
|
-
declare const HypothesisSheet: mongoose.Model<
|
|
48
|
-
_id: mongoose.Types.ObjectId;
|
|
49
|
-
}, any>;
|
|
47
|
+
declare const HypothesisSheet: mongoose.Model<any, {}, {}, {}, any, any>;
|
|
50
48
|
export default HypothesisSheet;
|
|
@@ -114,5 +114,5 @@ const HypothesisSheetSchema = new mongoose_1.Schema({
|
|
|
114
114
|
}, {
|
|
115
115
|
timestamps: true,
|
|
116
116
|
});
|
|
117
|
-
const HypothesisSheet = (0, mongoose_1.model)("
|
|
117
|
+
const HypothesisSheet = mongoose_1.default.models.hypothesissheet || (0, mongoose_1.model)("hypothesissheet", HypothesisSheetSchema);
|
|
118
118
|
exports.default = HypothesisSheet;
|
|
@@ -34,7 +34,5 @@ export interface INewIdeas extends Document {
|
|
|
34
34
|
totalPriority?: string;
|
|
35
35
|
createdBy?: mongoose.Schema.Types.ObjectId;
|
|
36
36
|
}
|
|
37
|
-
declare const NewIdeas: mongoose.Model<
|
|
38
|
-
_id: mongoose.Types.ObjectId;
|
|
39
|
-
}, any>;
|
|
37
|
+
declare const NewIdeas: mongoose.Model<any, {}, {}, {}, any, any>;
|
|
40
38
|
export default NewIdeas;
|
|
@@ -67,5 +67,5 @@ NewIdeasSchema.index({
|
|
|
67
67
|
client: 1,
|
|
68
68
|
viewId: 1,
|
|
69
69
|
});
|
|
70
|
-
const NewIdeas = (0, mongoose_1.model)("
|
|
70
|
+
const NewIdeas = mongoose_1.default.models.newideas || (0, mongoose_1.model)("newideas", NewIdeasSchema);
|
|
71
71
|
exports.default = NewIdeas;
|
package/package.json
CHANGED
package/src/models/Client.ts
CHANGED
|
@@ -13,7 +13,17 @@ export interface IProperty extends Document {
|
|
|
13
13
|
const PropertySchema: Schema = new Schema<IProperty>({
|
|
14
14
|
propertyname: { type: String, required: true },
|
|
15
15
|
viewId: { type: String, required: true },
|
|
16
|
-
platform: { type: String, default: "GA4" }
|
|
16
|
+
platform: { type: String, default: "GA4" },
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
export interface IShopify extends Document {
|
|
20
|
+
shopDomain: string;
|
|
21
|
+
accessToken: string;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
const shopifySchema: Schema = new Schema<IShopify>({
|
|
25
|
+
shopDomain: { type: String, required: true },
|
|
26
|
+
accessToken: { type: String, required: true },
|
|
17
27
|
});
|
|
18
28
|
|
|
19
29
|
export interface IClient extends Document {
|
|
@@ -35,6 +45,7 @@ export interface IClient extends Document {
|
|
|
35
45
|
NDAStatus?: boolean;
|
|
36
46
|
retainerValue: number;
|
|
37
47
|
useIntraDayTable: boolean;
|
|
48
|
+
shopify?: IShopify;
|
|
38
49
|
}
|
|
39
50
|
|
|
40
51
|
const ClientSchema: Schema = new Schema<IClient>(
|
|
@@ -43,49 +54,51 @@ const ClientSchema: Schema = new Schema<IClient>(
|
|
|
43
54
|
type: String,
|
|
44
55
|
trim: true,
|
|
45
56
|
unique: true,
|
|
46
|
-
default: () => generateRandomIID()
|
|
57
|
+
default: () => generateRandomIID(),
|
|
47
58
|
},
|
|
48
|
-
organization: {
|
|
59
|
+
organization: {
|
|
60
|
+
type: mongoose.Schema.Types.ObjectId,
|
|
49
61
|
ref: "organization",
|
|
50
62
|
default: null,
|
|
51
|
-
required: true
|
|
63
|
+
required: true,
|
|
52
64
|
},
|
|
53
65
|
name: { type: String, required: true },
|
|
54
|
-
slug: {
|
|
55
|
-
type: String,
|
|
56
|
-
slug: ["name"],
|
|
57
|
-
slugPaddingSize: 4,
|
|
58
|
-
unique: true
|
|
66
|
+
slug: {
|
|
67
|
+
type: String,
|
|
68
|
+
slug: ["name"],
|
|
69
|
+
slugPaddingSize: 4,
|
|
70
|
+
unique: true,
|
|
59
71
|
},
|
|
60
72
|
viewId: { type: String },
|
|
61
73
|
portfolioClient: { type: Boolean, default: false },
|
|
62
74
|
gaproperties: [PropertySchema],
|
|
63
|
-
tier: {
|
|
64
|
-
type: mongoose.Schema.Types.ObjectId,
|
|
65
|
-
ref: "tier",
|
|
66
|
-
default: null
|
|
75
|
+
tier: {
|
|
76
|
+
type: mongoose.Schema.Types.ObjectId,
|
|
77
|
+
ref: "tier",
|
|
78
|
+
default: null,
|
|
67
79
|
},
|
|
68
80
|
active: { type: Boolean, default: true },
|
|
69
81
|
currency: { type: String, default: "USD" },
|
|
70
82
|
logo: { type: String, default: "" },
|
|
71
|
-
createdBy: {
|
|
72
|
-
type: mongoose.Schema.Types.ObjectId,
|
|
73
|
-
ref: "user",
|
|
74
|
-
default: null
|
|
83
|
+
createdBy: {
|
|
84
|
+
type: mongoose.Schema.Types.ObjectId,
|
|
85
|
+
ref: "user",
|
|
86
|
+
default: null,
|
|
75
87
|
},
|
|
76
88
|
onboardDate: { type: Date, default: Date.now },
|
|
77
89
|
bqClientId: { type: String, default: null },
|
|
78
90
|
defaultDataSet: { type: String },
|
|
79
91
|
NDAStatus: { type: Boolean, default: false },
|
|
80
92
|
retainerValue: { type: Number },
|
|
81
|
-
useIntraDayTable: { type: Boolean }
|
|
93
|
+
useIntraDayTable: { type: Boolean },
|
|
94
|
+
shopify: { type: shopifySchema, default: null },
|
|
82
95
|
},
|
|
83
|
-
{
|
|
84
|
-
timestamps: true
|
|
96
|
+
{
|
|
97
|
+
timestamps: true,
|
|
85
98
|
}
|
|
86
99
|
);
|
|
87
100
|
|
|
88
|
-
ClientSchema.pre(
|
|
101
|
+
ClientSchema.pre("save", async function (next) {
|
|
89
102
|
if (!this.iid) {
|
|
90
103
|
let unique = false;
|
|
91
104
|
while (!unique) {
|
|
@@ -96,14 +109,14 @@ ClientSchema.pre('save', async function(next) {
|
|
|
96
109
|
unique = true;
|
|
97
110
|
}
|
|
98
111
|
}
|
|
99
|
-
}
|
|
112
|
+
}
|
|
100
113
|
next();
|
|
101
114
|
});
|
|
102
115
|
|
|
103
116
|
// Add compound indexes for better query performance
|
|
104
117
|
ClientSchema.index({ active: 1 });
|
|
105
118
|
ClientSchema.index({ organization: 1, active: 1 });
|
|
106
|
-
ClientSchema.index({ name: 1 }, { collation: { locale:
|
|
119
|
+
ClientSchema.index({ name: 1 }, { collation: { locale: "en", strength: 2 } }); // Case-insensitive search
|
|
107
120
|
ClientSchema.index({ tier: 1, active: 1 }); // For tier-based queries
|
|
108
121
|
ClientSchema.index({ onboardDate: 1 }); // For date-based queries
|
|
109
122
|
ClientSchema.index({ portfolioClient: 1, active: 1 }); // For portfolio client queries
|
|
@@ -46,6 +46,6 @@ CustomQuerySchema.pre('save', async function(next) {
|
|
|
46
46
|
});
|
|
47
47
|
|
|
48
48
|
|
|
49
|
-
const CustomQuery = model<ICustomQuery>('
|
|
49
|
+
const CustomQuery = mongoose.models.customquery || model<ICustomQuery>('customquery', CustomQuerySchema);
|
|
50
50
|
|
|
51
51
|
export default CustomQuery;
|
|
@@ -113,8 +113,8 @@ const HypothesisSheetSchema = new Schema<IHypothesisSheet>(
|
|
|
113
113
|
}
|
|
114
114
|
);
|
|
115
115
|
|
|
116
|
-
const HypothesisSheet = model<IHypothesisSheet>(
|
|
117
|
-
"
|
|
116
|
+
const HypothesisSheet = mongoose.models.hypothesissheet || model<IHypothesisSheet>(
|
|
117
|
+
"hypothesissheet",
|
|
118
118
|
HypothesisSheetSchema
|
|
119
119
|
);
|
|
120
120
|
|
package/src/models/NewIdeas.ts
CHANGED