@puca/puca-core 12.8.1 → 12.9.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/dist/core/services/task.service.d.ts +13 -3
- package/dist/core/services/task.service.js +6 -1
- package/dist/core/services/task.service.js.map +1 -1
- package/dist/packages/crm/crm.service.d.ts +39 -0
- package/dist/packages/crm/crm.service.js +57 -0
- package/dist/packages/crm/crm.service.js.map +1 -0
- package/dist/{functions → packages/functions}/function.service.d.ts +2 -2
- package/dist/packages/functions/function.service.js.map +1 -0
- package/dist/packages/index.d.ts +5 -0
- package/dist/packages/index.js +12 -0
- package/dist/packages/index.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/dist/functions/function.service.js.map +0 -1
- package/dist/functions/index.d.ts +0 -3
- package/dist/functions/index.js +0 -8
- package/dist/functions/index.js.map +0 -1
- /package/dist/{functions → packages/functions}/function.service.js +0 -0
|
@@ -1,12 +1,17 @@
|
|
|
1
1
|
import { User } from "../../models/user";
|
|
2
2
|
import { ComunicationService } from "./comunication/comunication.service";
|
|
3
|
-
export declare
|
|
3
|
+
export declare enum TaskStatus {
|
|
4
|
+
Open = "open",
|
|
5
|
+
Closed = "closed"
|
|
6
|
+
}
|
|
7
|
+
export declare type Task<T = unknown> = {
|
|
4
8
|
title: string;
|
|
5
9
|
end_date: Date;
|
|
6
10
|
description?: string;
|
|
7
11
|
assigned: string;
|
|
8
12
|
related_entity: string;
|
|
9
13
|
related_entity_id: string;
|
|
14
|
+
metadata?: T;
|
|
10
15
|
} & ({
|
|
11
16
|
kind: 'event';
|
|
12
17
|
start_date: Date;
|
|
@@ -15,11 +20,16 @@ export declare type Task = {
|
|
|
15
20
|
kind: 'task';
|
|
16
21
|
all_day: true;
|
|
17
22
|
});
|
|
23
|
+
export declare type TaskModel<T = unknown> = Task<T> & {
|
|
24
|
+
puca_pid?: string;
|
|
25
|
+
puca_key?: number;
|
|
26
|
+
status?: TaskStatus;
|
|
27
|
+
};
|
|
18
28
|
export declare class TaskService {
|
|
19
29
|
private readonly comunicationService;
|
|
20
30
|
constructor(comunicationService: ComunicationService);
|
|
21
|
-
add(args: {
|
|
22
|
-
task: Task
|
|
31
|
+
add<T>(args: {
|
|
32
|
+
task: Task<T>;
|
|
23
33
|
user: User;
|
|
24
34
|
}): Promise<void>;
|
|
25
35
|
}
|
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.TaskService = void 0;
|
|
3
|
+
exports.TaskService = exports.TaskStatus = void 0;
|
|
4
|
+
var TaskStatus;
|
|
5
|
+
(function (TaskStatus) {
|
|
6
|
+
TaskStatus["Open"] = "open";
|
|
7
|
+
TaskStatus["Closed"] = "closed";
|
|
8
|
+
})(TaskStatus = exports.TaskStatus || (exports.TaskStatus = {}));
|
|
4
9
|
class TaskService {
|
|
5
10
|
constructor(comunicationService) {
|
|
6
11
|
this.comunicationService = comunicationService;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"task.service.js","sourceRoot":"","sources":["../../../src/core/services/task.service.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"task.service.js","sourceRoot":"","sources":["../../../src/core/services/task.service.ts"],"names":[],"mappings":";;;AAGA,IAAY,UAGX;AAHD,WAAY,UAAU;IACpB,2BAAa,CAAA;IACb,+BAAiB,CAAA;AACnB,CAAC,EAHW,UAAU,GAAV,kBAAU,KAAV,kBAAU,QAGrB;AAyBD,MAAa,WAAW;IACtB,YAA6B,mBAAwC;QAAxC,wBAAmB,GAAnB,mBAAmB,CAAqB;IAAI,CAAC;IAE1E,KAAK,CAAC,GAAG,CAAI,IAGZ;QACC,MAAM,IAAI,CAAC,mBAAmB,CAAC,IAAI,CAAC;YAClC,UAAU,EAAE,eAAe;YAC3B,IAAI,EAAE,UAAU;YAChB,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,IAAI,EAAE,IAAI,CAAC,IAAI;SAChB,CAAC,CAAC;IACL,CAAC;CACF;AAdD,kCAcC"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { ComunicationService } from "../../core/services/comunication/comunication.service";
|
|
2
|
+
import { UserService } from "../../core/services/user.service";
|
|
3
|
+
import { ModuleConfigService } from "../../essential/module-config.service";
|
|
4
|
+
import { User } from "../../models/user";
|
|
5
|
+
import { SecondaryDatabase } from "../../orm/services/secondary-database/secondary-database.service";
|
|
6
|
+
import { MqService } from '../../core/services/mq/mq.service';
|
|
7
|
+
export interface AnalysisFeatureByPersonConfig {
|
|
8
|
+
description: string;
|
|
9
|
+
path: string;
|
|
10
|
+
}
|
|
11
|
+
export interface InteractionType {
|
|
12
|
+
puca_pid: string;
|
|
13
|
+
name: string;
|
|
14
|
+
description?: string;
|
|
15
|
+
}
|
|
16
|
+
export declare class CrmService {
|
|
17
|
+
private readonly moduleConfig;
|
|
18
|
+
private readonly secondaryDatabase;
|
|
19
|
+
private readonly comunicationService;
|
|
20
|
+
private readonly userService;
|
|
21
|
+
private readonly mqService;
|
|
22
|
+
private readonly logger;
|
|
23
|
+
constructor(moduleConfig: ModuleConfigService, secondaryDatabase: SecondaryDatabase, comunicationService: ComunicationService, userService: UserService, mqService: MqService);
|
|
24
|
+
activeFeature<T>(featureName: string, props: T): Promise<void>;
|
|
25
|
+
activeFeatureAnalysisFeatureByPersonConfig(props: AnalysisFeatureByPersonConfig[]): Promise<void>;
|
|
26
|
+
createInteractionTypeList(args: {
|
|
27
|
+
list: InteractionType[];
|
|
28
|
+
}): Promise<void>;
|
|
29
|
+
addInteraction(interaction: {
|
|
30
|
+
puca_pid?: string;
|
|
31
|
+
type: string;
|
|
32
|
+
target: string;
|
|
33
|
+
author?: string;
|
|
34
|
+
link: string;
|
|
35
|
+
user: User;
|
|
36
|
+
text: string;
|
|
37
|
+
has_indicators?: boolean;
|
|
38
|
+
}): Promise<void>;
|
|
39
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CrmService = void 0;
|
|
4
|
+
const _ = require("lodash");
|
|
5
|
+
const logger_1 = require("../../core/services/logger");
|
|
6
|
+
class CrmService {
|
|
7
|
+
constructor(moduleConfig, secondaryDatabase, comunicationService, userService, mqService) {
|
|
8
|
+
this.moduleConfig = moduleConfig;
|
|
9
|
+
this.secondaryDatabase = secondaryDatabase;
|
|
10
|
+
this.comunicationService = comunicationService;
|
|
11
|
+
this.userService = userService;
|
|
12
|
+
this.mqService = mqService;
|
|
13
|
+
this.logger = new logger_1.Logger('CrmService');
|
|
14
|
+
}
|
|
15
|
+
async activeFeature(featureName, props) {
|
|
16
|
+
const moduleConfig = await this.moduleConfig.getModuleConfig();
|
|
17
|
+
await this.secondaryDatabase.set(`puca-crm:feature:${featureName}:${moduleConfig.name}`, JSON.stringify(props));
|
|
18
|
+
}
|
|
19
|
+
async activeFeatureAnalysisFeatureByPersonConfig(props) {
|
|
20
|
+
await this.activeFeature('analysisFeatureByPersonConfig', props);
|
|
21
|
+
}
|
|
22
|
+
async createInteractionTypeList(args) {
|
|
23
|
+
const pucaUser = await this.userService.loadUserBy({
|
|
24
|
+
key: 'username',
|
|
25
|
+
value: 'puca-user',
|
|
26
|
+
loadPermissions: false
|
|
27
|
+
});
|
|
28
|
+
try {
|
|
29
|
+
await this.comunicationService.call({
|
|
30
|
+
moduleName: 'puca-crm-api',
|
|
31
|
+
path: 'puca-crm-api/interaction-type/setup',
|
|
32
|
+
method: 'post',
|
|
33
|
+
body: args.list,
|
|
34
|
+
user: pucaUser,
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
catch (error) {
|
|
38
|
+
this.logger.error(error);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
async addInteraction(interaction) {
|
|
42
|
+
if (!interaction.author) {
|
|
43
|
+
interaction.author = interaction.user.puca_pid;
|
|
44
|
+
}
|
|
45
|
+
if (interaction.has_indicators === undefined) {
|
|
46
|
+
interaction.has_indicators = false;
|
|
47
|
+
}
|
|
48
|
+
try {
|
|
49
|
+
await this.mqService.sendToQueue('add-interaction', _.omit(interaction, 'user'));
|
|
50
|
+
}
|
|
51
|
+
catch (error) {
|
|
52
|
+
this.logger.error(error);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
exports.CrmService = CrmService;
|
|
57
|
+
//# sourceMappingURL=crm.service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"crm.service.js","sourceRoot":"","sources":["../../../src/packages/crm/crm.service.ts"],"names":[],"mappings":";;;AAAA,4BAA2B;AAG3B,uDAAmD;AAmBnD,MAAa,UAAU;IAGrB,YACmB,YAAiC,EACjC,iBAAoC,EACpC,mBAAwC,EACxC,WAAwB,EACxB,SAAoB;QAJpB,iBAAY,GAAZ,YAAY,CAAqB;QACjC,sBAAiB,GAAjB,iBAAiB,CAAmB;QACpC,wBAAmB,GAAnB,mBAAmB,CAAqB;QACxC,gBAAW,GAAX,WAAW,CAAa;QACxB,cAAS,GAAT,SAAS,CAAW;QAPtB,WAAM,GAAG,IAAI,eAAM,CAAC,YAAY,CAAC,CAAA;IAUlD,CAAC;IAED,KAAK,CAAC,aAAa,CAAI,WAAmB,EAAE,KAAQ;QAClD,MAAM,YAAY,GAAG,MAAM,IAAI,CAAC,YAAY,CAAC,eAAe,EAAE,CAAA;QAC9D,MAAM,IAAI,CAAC,iBAAiB,CAAC,GAAG,CAC9B,oBAAoB,WAAW,IAAI,YAAY,CAAC,IAAI,EAAE,EAAE,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAC9E,CAAA;IACH,CAAC;IAED,KAAK,CAAC,0CAA0C,CAAC,KAAsC;QACrF,MAAM,IAAI,CAAC,aAAa,CACtB,+BAA+B,EAAE,KAAK,CACvC,CAAA;IACH,CAAC;IAED,KAAK,CAAC,yBAAyB,CAAC,IAE/B;QACC,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,WAAW,CAAC,UAAU,CAAC;YACjD,GAAG,EAAE,UAAU;YACf,KAAK,EAAE,WAAW;YAClB,eAAe,EAAE,KAAK;SACvB,CAAC,CAAA;QAEF,IAAI;YACF,MAAM,IAAI,CAAC,mBAAmB,CAAC,IAAI,CAAC;gBAClC,UAAU,EAAE,cAAc;gBAC1B,IAAI,EAAE,qCAAqC;gBAC3C,MAAM,EAAE,MAAM;gBACd,IAAI,EAAE,IAAI,CAAC,IAAI;gBACf,IAAI,EAAE,QAAQ;aACf,CAAC,CAAC;SACJ;QAAC,OAAO,KAAK,EAAE;YACd,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,CAAA;SACzB;IACH,CAAC;IAED,KAAK,CAAC,cAAc,CAAC,WAWpB;QACC,IAAG,CAAC,WAAW,CAAC,MAAM,EAAE;YACtB,WAAW,CAAC,MAAM,GAAG,WAAW,CAAC,IAAI,CAAC,QAAQ,CAAA;SAC/C;QAED,IAAG,WAAW,CAAC,cAAc,KAAK,SAAS,EAAE;YAC3C,WAAW,CAAC,cAAc,GAAG,KAAK,CAAA;SACnC;QAED,IAAI;YACF,MAAM,IAAI,CAAC,SAAS,CAAC,WAAW,CAC9B,iBAAiB,EACjB,CAAC,CAAC,IAAI,CAAC,WAAW,EAAE,MAAM,CAAC,CAC5B,CAAA;SACF;QAAC,OAAO,KAAK,EAAE;YACd,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,CAAA;SACzB;IACH,CAAC;CAGF;AA/ED,gCA+EC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { ComunicationService } from "
|
|
2
|
-
import { User } from "
|
|
1
|
+
import { ComunicationService } from "../../core/services/comunication/comunication.service";
|
|
2
|
+
import { User } from "../../models/user";
|
|
3
3
|
export interface CallArgs<T> {
|
|
4
4
|
functionPid: string;
|
|
5
5
|
environmentPid?: string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"function.service.js","sourceRoot":"","sources":["../../../src/packages/functions/function.service.ts"],"names":[],"mappings":";;AAAA,4BAA4B;AAkB5B,MAAqB,eAAe;IAClC,YAA6B,mBAAwC;QAAxC,wBAAmB,GAAnB,mBAAmB,CAAqB;IAAI,CAAC;IAG1E,KAAK,CAAC,QAAQ,CAAO,IAAiB;QACpC,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,mBAAmB,CAAC,IAAI,CAAI;YACtD,UAAU,EAAE,oBAAoB;YAChC,IAAI,EAAE,oBAAoB;YAC1B,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,EAAE,MAAM,CAAC;YAC1B,MAAM,EAAE,MAAM;SACf,CAAC,CAAA;QACF,OAAO,QAAQ,CAAC,IAAI,CAAA;IACtB,CAAC;CAOF;AApBD,kCAoBC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { MultiTenantAdapter } from "../plugins/multi-tenant/multi-tentant.adapter";
|
|
2
|
+
import { CrmService } from "./crm/crm.service";
|
|
3
|
+
import FunctionService from "./functions/function.service";
|
|
4
|
+
export declare const functionService: MultiTenantAdapter<FunctionService>;
|
|
5
|
+
export declare const crmService: MultiTenantAdapter<CrmService>;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.crmService = exports.functionService = void 0;
|
|
4
|
+
const services_1 = require("../core/services");
|
|
5
|
+
const essential_1 = require("../essential");
|
|
6
|
+
const services_2 = require("../orm/services");
|
|
7
|
+
const multi_tentant_adapter_1 = require("../plugins/multi-tenant/multi-tentant.adapter");
|
|
8
|
+
const crm_service_1 = require("./crm/crm.service");
|
|
9
|
+
const function_service_1 = require("./functions/function.service");
|
|
10
|
+
exports.functionService = new multi_tentant_adapter_1.MultiTenantAdapter(domain => new function_service_1.default(services_1.comunicationService.get(domain)));
|
|
11
|
+
exports.crmService = new multi_tentant_adapter_1.MultiTenantAdapter(domain => new crm_service_1.CrmService(essential_1.moduleConfigService, services_2.secondaryDataBase.get(domain), services_1.comunicationService.get(domain), services_1.userService.get(domain), services_1.mqService.get(domain)));
|
|
12
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/packages/index.ts"],"names":[],"mappings":";;;AAAA,+CAAkG;AAClG,4CAAmD;AACnD,8CAAoD;AACpD,yFAAmF;AACnF,mDAA+C;AAC/C,mEAA2D;AAE9C,QAAA,eAAe,GAAG,IAAI,0CAAkB,CACnD,MAAM,CAAC,EAAE,CAAC,IAAI,0BAAe,CAAC,8BAAmB,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,CAC/D,CAAC;AAEW,QAAA,UAAU,GAAG,IAAI,0CAAkB,CAC9C,MAAM,CAAC,EAAE,CAAC,IAAI,wBAAU,CACtB,+BAAmB,EACnB,4BAAiB,CAAC,GAAG,CAAC,MAAM,CAAC,EAC7B,8BAAmB,CAAC,GAAG,CAAC,MAAM,CAAC,EAC/B,sBAAW,CAAC,GAAG,CAAC,MAAM,CAAC,EACvB,oBAAS,CAAC,GAAG,CAAC,MAAM,CAAC,CACtB,CACF,CAAC"}
|