@cool-digital-solutions/interferir-models 1.0.97 → 1.0.99
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,9 +1,33 @@
|
|
|
1
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
|
+
};
|
|
2
25
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
26
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
27
|
};
|
|
5
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
29
|
const mongoose_1 = require("mongoose");
|
|
30
|
+
const lodash = __importStar(require("lodash"));
|
|
7
31
|
const express_http_context_1 = __importDefault(require("express-http-context"));
|
|
8
32
|
const _config_1 = require("../config");
|
|
9
33
|
const themeSchema = new mongoose_1.Schema({
|
|
@@ -44,6 +68,7 @@ const themeSchema = new mongoose_1.Schema({
|
|
|
44
68
|
enum: Object.values(_config_1.ContentDraftStatus),
|
|
45
69
|
default: _config_1.ContentDraftStatus.DEFAULT,
|
|
46
70
|
},
|
|
71
|
+
instantResearchId: { type: mongoose_1.Schema.Types.ObjectId, ref: 'InstantResearch' },
|
|
47
72
|
sfTags: [{ type: mongoose_1.Schema.Types.ObjectId, ref: 'SFTag' }],
|
|
48
73
|
sfIndustries: [{ type: mongoose_1.Schema.Types.ObjectId, ref: 'Industry' }],
|
|
49
74
|
sfTechnologies: [{ type: mongoose_1.Schema.Types.ObjectId, ref: 'Technology' }],
|
|
@@ -59,6 +84,32 @@ const themeSchema = new mongoose_1.Schema({
|
|
|
59
84
|
updatedDate: { type: Number, index: -1 },
|
|
60
85
|
createdDate: { type: Number, index: -1 },
|
|
61
86
|
}, _config_1.schemaOptions);
|
|
87
|
+
const excludeNonNullField = (schema, options) => {
|
|
88
|
+
const { fieldName } = options;
|
|
89
|
+
const addCondition = function (next) {
|
|
90
|
+
if (!this.getQuery().hasOwnProperty(fieldName))
|
|
91
|
+
this.where({ $or: [{ [fieldName]: { $eq: null } }, { [fieldName]: { $exists: false } }] });
|
|
92
|
+
next();
|
|
93
|
+
};
|
|
94
|
+
const addAggregateCondition = function (next) {
|
|
95
|
+
const pipeline = this.pipeline();
|
|
96
|
+
const hasFieldName = lodash.some(pipeline, (stage) => {
|
|
97
|
+
if (stage.$match)
|
|
98
|
+
return lodash.has(stage.$match, fieldName);
|
|
99
|
+
return false;
|
|
100
|
+
});
|
|
101
|
+
if (!hasFieldName)
|
|
102
|
+
this.pipeline().unshift({ $match: { $or: [{ [fieldName]: { $eq: null } }, { [fieldName]: { $exists: false } }] } });
|
|
103
|
+
next();
|
|
104
|
+
};
|
|
105
|
+
schema.pre('find', addCondition);
|
|
106
|
+
schema.pre('findOne', addCondition);
|
|
107
|
+
schema.pre('findOneAndUpdate', addCondition);
|
|
108
|
+
schema.pre('countDocuments', addCondition);
|
|
109
|
+
schema.pre('count', addCondition);
|
|
110
|
+
schema.pre('aggregate', addAggregateCondition);
|
|
111
|
+
};
|
|
112
|
+
themeSchema.plugin(excludeNonNullField, { fieldName: 'instantResearchId' });
|
|
62
113
|
themeSchema.pre('save', function (next) {
|
|
63
114
|
const user = express_http_context_1.default.get('user');
|
|
64
115
|
const notUpdatedBy = express_http_context_1.default.get('notUpdatedBy');
|
|
@@ -30,7 +30,7 @@ export declare enum ContactMessageTypes {
|
|
|
30
30
|
MISSING_MATCH = "missingMatch",
|
|
31
31
|
CONTACT = "contact",
|
|
32
32
|
TRAINING_SESSION = "trainingSession",
|
|
33
|
-
|
|
33
|
+
PRIVATE_RESEARCH_ACCESS_REQUEST = "privateResearchAccessRequest",
|
|
34
34
|
DEFAULT = ""
|
|
35
35
|
}
|
|
36
36
|
export interface IContactMessage extends BaseSchema {
|
|
@@ -7,6 +7,6 @@ var ContactMessageTypes;
|
|
|
7
7
|
ContactMessageTypes["MISSING_MATCH"] = "missingMatch";
|
|
8
8
|
ContactMessageTypes["CONTACT"] = "contact";
|
|
9
9
|
ContactMessageTypes["TRAINING_SESSION"] = "trainingSession";
|
|
10
|
-
ContactMessageTypes["
|
|
10
|
+
ContactMessageTypes["PRIVATE_RESEARCH_ACCESS_REQUEST"] = "privateResearchAccessRequest";
|
|
11
11
|
ContactMessageTypes["DEFAULT"] = "";
|
|
12
12
|
})(ContactMessageTypes || (exports.ContactMessageTypes = ContactMessageTypes = {}));
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
/// <reference types="mongoose/types/virtuals" />
|
|
24
24
|
/// <reference types="mongoose/types/inferschematype" />
|
|
25
25
|
import { Types } from 'mongoose';
|
|
26
|
-
import { IImage, ISFTag, IIndustry, ITechnology, ISFCategory, ISFSubCategory, IUser } from './';
|
|
26
|
+
import { IImage, ISFTag, IIndustry, ITechnology, ISFCategory, ISFSubCategory, IUser, IInstantResearch } from './';
|
|
27
27
|
import { BaseModel, BaseSchema, ContentDraftStatus, ContentStatus, ContentStatusCount } from '../config';
|
|
28
28
|
interface ThemeContent {
|
|
29
29
|
title?: string;
|
|
@@ -45,6 +45,7 @@ export interface ITheme extends BaseSchema {
|
|
|
45
45
|
solutionCount?: ContentStatusCount | number;
|
|
46
46
|
companyCount?: ContentStatusCount | number;
|
|
47
47
|
showCounts?: boolean;
|
|
48
|
+
instantResearchId?: Types.ObjectId | IInstantResearch;
|
|
48
49
|
status: ContentStatus;
|
|
49
50
|
draftVersionStatus?: ContentDraftStatus | null;
|
|
50
51
|
sfTags?: Types.ObjectId[] | ISFTag[];
|