@icapps/chat-astrum
Advanced tools
Comparing version 1.0.7 to 1.1.0
@@ -0,1 +1,2 @@ | ||
import { IConversationType } from './models/conversation.model'; | ||
export declare const envs: { | ||
@@ -8,5 +9,5 @@ TEST: string; | ||
export declare const VALID_CHAT_TYPES: { | ||
SINGLE: string; | ||
GROUP: string; | ||
DEPARTMENT: string; | ||
SINGLE: IConversationType; | ||
GROUP: IConversationType; | ||
DEPARTMENT: IConversationType; | ||
}; |
import * as conversation from './services/conversation.service'; | ||
import * as db from './lib/db'; | ||
import * as socket from './lib/socket'; | ||
export * from './models/index'; | ||
export { conversation, db, }; | ||
export { conversation, db, socket, }; |
@@ -7,1 +7,3 @@ "use strict"; | ||
exports.db = db; | ||
const socket = require("./lib/socket"); | ||
exports.socket = socket; |
@@ -0,2 +1,3 @@ | ||
import * as mongoose from 'mongoose'; | ||
export declare let dbConnection: mongoose.Connection | null; | ||
export declare function openConnection(url: string): Promise<void>; | ||
export declare function closeConnection(): Promise<void>; |
"use strict"; | ||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
return new (P || (P = Promise))(function (resolve, reject) { | ||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } | ||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } | ||
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); } | ||
step((generator = generator.apply(thisArg, _arguments || [])).next()); | ||
}); | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const mongoose = require("mongoose"); | ||
const logger_1 = require("./logger"); | ||
let dbConnection; | ||
mongoose.set('useFindAndModify', false); | ||
@@ -18,8 +9,8 @@ function openConnection(url) { | ||
mongoose.connect(url, { useNewUrlParser: true }); | ||
dbConnection = mongoose.connection; | ||
dbConnection.on('error', (err) => { | ||
exports.dbConnection = mongoose.connection; | ||
exports.dbConnection.on('error', (err) => { | ||
logger_1.logger.error(err); | ||
reject(err); | ||
}); | ||
dbConnection.once('open', () => { | ||
exports.dbConnection.once('open', () => { | ||
logger_1.logger.info('Connected to the Mongo database!'); | ||
@@ -31,8 +22,1 @@ resolve(); | ||
exports.openConnection = openConnection; | ||
function closeConnection() { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
if (dbConnection) | ||
return yield dbConnection.close(); | ||
}); | ||
} | ||
exports.closeConnection = closeConnection; |
import { Document, Schema, Model } from 'mongoose'; | ||
import { IDBMessage } from './message.model'; | ||
export declare type IConversationType = 'SINGLE' | 'GROUP' | 'DEPARTMENT'; | ||
export interface IParticipants { | ||
departmentId: string; | ||
employmentIds: string[]; | ||
} | ||
export interface IConversationBaseOperation { | ||
firstName: string; | ||
participants: Partial<IParticipants>; | ||
type: IConversationType; | ||
} | ||
@@ -9,7 +15,4 @@ export interface IConversationCreate extends IConversationBaseOperation { | ||
export interface IDBConversation extends Document { | ||
participants: { | ||
departmentId: string; | ||
employmentIds: string[]; | ||
}; | ||
type: string; | ||
participants: IParticipants; | ||
type: IConversationType; | ||
messages: IDBMessage[]; | ||
@@ -16,0 +19,0 @@ meta: { |
import { Types } from 'mongoose'; | ||
import { IDBConversation } from '../models/conversation.model'; | ||
import { IDBConversation, IConversationCreate } from '../models/conversation.model'; | ||
import { IConversationRights } from '../models/rights.model'; | ||
import { IFilters } from '../models/filter.model'; | ||
export declare function findConversationById(id: Types.ObjectId): Promise<IDBConversation>; | ||
export declare function createConversation(values: IConversationCreate): Promise<IDBConversation>; | ||
export declare function findMyConversations(rights: IConversationRights, filters?: IFilters): Promise<{ | ||
@@ -7,0 +8,0 @@ data: IDBConversation[]; |
@@ -16,2 +16,6 @@ "use strict"; | ||
exports.findConversationById = findConversationById; | ||
function createConversation(values) { | ||
return conversation_model_1.Conversation.create(values); | ||
} | ||
exports.createConversation = createConversation; | ||
function findMyConversations(rights, filters = { limit: 50, offset: 0 }) { | ||
@@ -18,0 +22,0 @@ return __awaiter(this, void 0, void 0, function* () { |
import { Types } from 'mongoose'; | ||
import { IDBConversation } from '../models/conversation.model'; | ||
import { IDBConversation, IParticipants } from '../models/conversation.model'; | ||
import { IConversationRights } from '../models/rights.model'; | ||
@@ -10,2 +10,3 @@ import { IFilters } from '../models/filter.model'; | ||
}>; | ||
export declare function startConversation(holdingId: string, participants: Partial<IParticipants>): Promise<IDBConversation>; | ||
export declare function markAsRead(conversationId: Types.ObjectId, employmentId: string): Promise<void>; |
@@ -11,3 +11,5 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const socket = require("../lib/socket"); | ||
const conversationRepository = require("../repositories/conversation.repository"); | ||
const utils_1 = require("../lib/utils"); | ||
function findConversationById(id) { | ||
@@ -21,2 +23,11 @@ return conversationRepository.findConversationById(id); | ||
exports.findMyConversations = findMyConversations; | ||
function startConversation(holdingId, participants) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const type = utils_1.getConversationType(participants); | ||
const conversation = yield conversationRepository.createConversation({ participants, type }); | ||
socket.addNamespace(holdingId); | ||
return conversation; | ||
}); | ||
} | ||
exports.startConversation = startConversation; | ||
function markAsRead(conversationId, employmentId) { | ||
@@ -23,0 +34,0 @@ return __awaiter(this, void 0, void 0, function* () { |
{ | ||
"name": "@icapps/chat-astrum", | ||
"version": "1.0.7", | ||
"version": "1.1.0", | ||
"description": "Chat module ESS", | ||
@@ -26,2 +26,3 @@ "main": "build/index.js", | ||
"mongoose": "~5.5.11", | ||
"socket.io": "~2.2.0", | ||
"winston": "~3.2.1" | ||
@@ -31,2 +32,3 @@ }, | ||
"@types/faker": "^4.1.5", | ||
"@types/socket.io": "~2.1.2", | ||
"@types/jest": "^24.0.13", | ||
@@ -33,0 +35,0 @@ "@types/joi": "^14.3.3", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Native code
Supply chain riskContains native code (e.g., compiled binaries or shared libraries). Including native code can obscure malicious behavior.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
23606
33
380
4
22
1
+ Addedsocket.io@~2.2.0
+ Addedaccepts@1.3.8(transitive)
+ Addedafter@0.8.2(transitive)
+ Addedarraybuffer.slice@0.0.7(transitive)
+ Addedasync-limiter@1.0.1(transitive)
+ Addedbacko2@1.0.2(transitive)
+ Addedbase64-arraybuffer@0.1.5(transitive)
+ Addedbase64id@1.0.0(transitive)
+ Addedbetter-assert@1.0.2(transitive)
+ Addedblob@0.0.5(transitive)
+ Addedcallsite@1.0.0(transitive)
+ Addedcomponent-bind@1.0.0(transitive)
+ Addedcomponent-emitter@1.2.11.3.1(transitive)
+ Addedcomponent-inherit@0.0.3(transitive)
+ Addeddebug@4.1.1(transitive)
+ Addedengine.io@3.3.2(transitive)
+ Addedengine.io-client@3.3.3(transitive)
+ Addedengine.io-parser@2.1.3(transitive)
+ Addedhas-binary2@1.0.3(transitive)
+ Addedhas-cors@1.1.0(transitive)
+ Addedindexof@0.0.1(transitive)
+ Addedisarray@2.0.1(transitive)
+ Addedmime-db@1.52.0(transitive)
+ Addedmime-types@2.1.35(transitive)
+ Addednegotiator@0.6.3(transitive)
+ Addedobject-component@0.0.3(transitive)
+ Addedparseqs@0.0.5(transitive)
+ Addedparseuri@0.0.5(transitive)
+ Addedsocket.io@2.2.0(transitive)
+ Addedsocket.io-adapter@1.1.2(transitive)
+ Addedsocket.io-client@2.2.0(transitive)
+ Addedsocket.io-parser@3.3.4(transitive)
+ Addedto-array@0.1.4(transitive)
+ Addedws@6.1.4(transitive)
+ Addedxmlhttprequest-ssl@1.6.3(transitive)
+ Addedyeast@0.1.2(transitive)