@asumano/worklip-typeorm-db 1.1.75 → 1.1.77
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/entities/EmailLog.d.ts +3 -0
- package/dist/entities/EmailLog.js +23 -0
- package/dist/entities/Template.d.ts +2 -0
- package/dist/entities/Template.js +9 -0
- package/dist/entities/WhatsappLog.d.ts +3 -0
- package/dist/entities/WhatsappLog.js +22 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +3 -0
- package/dist/template.settings.d.ts +5 -0
- package/dist/template.settings.js +29 -0
- package/dist/views/Templates.d.ts +2 -0
- package/dist/views/Templates.js +4 -0
- package/package.json +1 -1
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { Associate } from "./Associate";
|
|
1
2
|
import { Company } from "./Company";
|
|
2
3
|
import { ServiceOrder } from "./ServiceOrder";
|
|
3
4
|
import { Workshop } from "./Workshop";
|
|
@@ -12,5 +13,7 @@ export declare class EmailLog {
|
|
|
12
13
|
provider_message_id: string;
|
|
13
14
|
status: number;
|
|
14
15
|
error_message: string | null;
|
|
16
|
+
sent_by: Associate | null;
|
|
17
|
+
is_manual: boolean;
|
|
15
18
|
created: Date;
|
|
16
19
|
}
|
|
@@ -11,6 +11,7 @@ var __metadata = (this && this.__metadata) || function (k, v) {
|
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.EmailLog = void 0;
|
|
13
13
|
const typeorm_1 = require("typeorm");
|
|
14
|
+
const Associate_1 = require("./Associate");
|
|
14
15
|
const Company_1 = require("./Company");
|
|
15
16
|
const ServiceOrder_1 = require("./ServiceOrder");
|
|
16
17
|
const Workshop_1 = require("./Workshop");
|
|
@@ -99,6 +100,23 @@ __decorate([
|
|
|
99
100
|
}),
|
|
100
101
|
__metadata("design:type", Object)
|
|
101
102
|
], EmailLog.prototype, "error_message", void 0);
|
|
103
|
+
__decorate([
|
|
104
|
+
(0, typeorm_1.ManyToOne)(() => Associate_1.Associate, {
|
|
105
|
+
onDelete: "SET NULL",
|
|
106
|
+
onUpdate: "NO ACTION",
|
|
107
|
+
nullable: true,
|
|
108
|
+
}),
|
|
109
|
+
(0, typeorm_1.JoinColumn)({ name: "sent_by" }),
|
|
110
|
+
__metadata("design:type", Object)
|
|
111
|
+
], EmailLog.prototype, "sent_by", void 0);
|
|
112
|
+
__decorate([
|
|
113
|
+
(0, typeorm_1.Column)({
|
|
114
|
+
default: false,
|
|
115
|
+
type: "boolean",
|
|
116
|
+
comment: "1 si el destinatario lo escribió a mano el asesor al compartir el informe.",
|
|
117
|
+
}),
|
|
118
|
+
__metadata("design:type", Boolean)
|
|
119
|
+
], EmailLog.prototype, "is_manual", void 0);
|
|
102
120
|
__decorate([
|
|
103
121
|
(0, typeorm_1.Column)({
|
|
104
122
|
type: "datetime",
|
|
@@ -118,4 +136,9 @@ exports.EmailLog = EmailLog = __decorate([
|
|
|
118
136
|
// que crece ~60.000 filas al mes.
|
|
119
137
|
,
|
|
120
138
|
(0, typeorm_1.Index)("IDX_email_log_provider_message_id", ["provider_message_id"])
|
|
139
|
+
// DOC: Sostiene el conteo del tope diario de envíos manuales, que corre ANTES de cada
|
|
140
|
+
// envío con destinatario escrito a mano. Sin él sería un recorrido completo de la tabla
|
|
141
|
+
// en cada compartir.
|
|
142
|
+
,
|
|
143
|
+
(0, typeorm_1.Index)("IDX_email_log_sent_by_created", ["sent_by", "created"])
|
|
121
144
|
], EmailLog);
|
|
@@ -2,12 +2,14 @@ import { Workshop } from "./Workshop";
|
|
|
2
2
|
import { TemplateSection } from "./TemplateSection";
|
|
3
3
|
import { ServiceOrder } from "./ServiceOrder";
|
|
4
4
|
import { VehicleType } from "./VehicleType";
|
|
5
|
+
import { ITemplateSettings } from "../template.settings";
|
|
5
6
|
export declare class Template {
|
|
6
7
|
id: number;
|
|
7
8
|
code: string;
|
|
8
9
|
vehicle_type: VehicleType;
|
|
9
10
|
workshop: Workshop;
|
|
10
11
|
name: string;
|
|
12
|
+
settings: ITemplateSettings | null;
|
|
11
13
|
created: Date;
|
|
12
14
|
updated: Date | null;
|
|
13
15
|
status: number;
|
|
@@ -58,6 +58,15 @@ __decorate([
|
|
|
58
58
|
}),
|
|
59
59
|
__metadata("design:type", String)
|
|
60
60
|
], Template.prototype, "name", void 0);
|
|
61
|
+
__decorate([
|
|
62
|
+
(0, typeorm_1.Column)({
|
|
63
|
+
type: "json",
|
|
64
|
+
default: null,
|
|
65
|
+
nullable: true,
|
|
66
|
+
comment: "Configuración de la plantilla en JSON (hoy: cost). NULL si no se ha configurado nada.",
|
|
67
|
+
}),
|
|
68
|
+
__metadata("design:type", Object)
|
|
69
|
+
], Template.prototype, "settings", void 0);
|
|
61
70
|
__decorate([
|
|
62
71
|
(0, typeorm_1.Column)({
|
|
63
72
|
type: "datetime",
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { Associate } from "./Associate";
|
|
1
2
|
import { Company } from "./Company";
|
|
2
3
|
import { ServiceOrder } from "./ServiceOrder";
|
|
3
4
|
import { Workshop } from "./Workshop";
|
|
@@ -12,5 +13,7 @@ export declare class WhatsappLog {
|
|
|
12
13
|
provider_message_id: string;
|
|
13
14
|
status: number;
|
|
14
15
|
error_message: string | null;
|
|
16
|
+
sent_by: Associate | null;
|
|
17
|
+
is_manual: boolean;
|
|
15
18
|
created: Date;
|
|
16
19
|
}
|
|
@@ -11,6 +11,7 @@ var __metadata = (this && this.__metadata) || function (k, v) {
|
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.WhatsappLog = void 0;
|
|
13
13
|
const typeorm_1 = require("typeorm");
|
|
14
|
+
const Associate_1 = require("./Associate");
|
|
14
15
|
const Company_1 = require("./Company");
|
|
15
16
|
const ServiceOrder_1 = require("./ServiceOrder");
|
|
16
17
|
const Workshop_1 = require("./Workshop");
|
|
@@ -99,6 +100,23 @@ __decorate([
|
|
|
99
100
|
}),
|
|
100
101
|
__metadata("design:type", Object)
|
|
101
102
|
], WhatsappLog.prototype, "error_message", void 0);
|
|
103
|
+
__decorate([
|
|
104
|
+
(0, typeorm_1.ManyToOne)(() => Associate_1.Associate, {
|
|
105
|
+
onDelete: "SET NULL",
|
|
106
|
+
onUpdate: "NO ACTION",
|
|
107
|
+
nullable: true,
|
|
108
|
+
}),
|
|
109
|
+
(0, typeorm_1.JoinColumn)({ name: "sent_by" }),
|
|
110
|
+
__metadata("design:type", Object)
|
|
111
|
+
], WhatsappLog.prototype, "sent_by", void 0);
|
|
112
|
+
__decorate([
|
|
113
|
+
(0, typeorm_1.Column)({
|
|
114
|
+
default: false,
|
|
115
|
+
type: "boolean",
|
|
116
|
+
comment: "1 si el destinatario lo escribió a mano el asesor al compartir el informe.",
|
|
117
|
+
}),
|
|
118
|
+
__metadata("design:type", Boolean)
|
|
119
|
+
], WhatsappLog.prototype, "is_manual", void 0);
|
|
102
120
|
__decorate([
|
|
103
121
|
(0, typeorm_1.Column)({
|
|
104
122
|
type: "datetime",
|
|
@@ -113,4 +131,8 @@ exports.WhatsappLog = WhatsappLog = __decorate([
|
|
|
113
131
|
name: "whatsapp_log",
|
|
114
132
|
}),
|
|
115
133
|
(0, typeorm_1.Index)("IDX_whatsapp_log_company_created", ["company", "created"])
|
|
134
|
+
// DOC: Mismo motivo que en `email_log`: el tope diario de envíos manuales cuenta los DOS
|
|
135
|
+
// canales juntos, así que esta tabla también se consulta antes de cada compartir.
|
|
136
|
+
,
|
|
137
|
+
(0, typeorm_1.Index)("IDX_whatsapp_log_sent_by_created", ["sent_by", "created"])
|
|
116
138
|
], WhatsappLog);
|
package/dist/index.d.ts
CHANGED
|
@@ -3,6 +3,7 @@ import { IBasicFilter } from "./types";
|
|
|
3
3
|
export * from "./entities.views.routes";
|
|
4
4
|
export * from "./visit.summary";
|
|
5
5
|
export * from "./company.legal";
|
|
6
|
+
export * from "./template.settings";
|
|
6
7
|
export declare function createDataBaseSource(): DataSource;
|
|
7
8
|
export declare function showEntityName<T extends ObjectLiteral>(entity: EntityTarget<T>): Promise<Repository<T>>;
|
|
8
9
|
export declare function callStoredProcedureName(storedProcedure: any, elements: any): Promise<any>;
|
package/dist/index.js
CHANGED
|
@@ -54,6 +54,9 @@ __exportStar(require("./visit.summary"), exports);
|
|
|
54
54
|
// DOC: Datos legales/fiscales de la empresa y el catálogo por país. Lo consumen el panel,
|
|
55
55
|
// el portal y el job del aviso, y "estar completo" tiene que significar lo mismo en los tres.
|
|
56
56
|
__exportStar(require("./company.legal"), exports);
|
|
57
|
+
// DOC: Configuración de la plantilla (hoy el costo que hereda la visita). La leen el API al
|
|
58
|
+
// crear la visita y el portal al pintar la tabla, así que la forma es una sola.
|
|
59
|
+
__exportStar(require("./template.settings"), exports);
|
|
57
60
|
let connection = null;
|
|
58
61
|
// DOC: Inicialización en curso. Se memoriza la PROMESA y no el resultado porque el patrón
|
|
59
62
|
// "si no está inicializada, inicialízala" tiene una carrera en el arranque en frío: dos
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export interface ITemplateSettings {
|
|
2
|
+
cost?: number | null;
|
|
3
|
+
}
|
|
4
|
+
export declare const getTemplateCost: (settings: ITemplateSettings | null | undefined) => number | null;
|
|
5
|
+
export declare const withTemplateCost: (settings: ITemplateSettings | null | undefined, cost: number | null) => ITemplateSettings | null;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// DOC: Configuración de la plantilla (`template.settings`). Vive acá y no en cada repo
|
|
3
|
+
// porque el API la escribe y valida, y el portal la pinta: una sola forma para los dos.
|
|
4
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
+
exports.withTemplateCost = exports.getTemplateCost = void 0;
|
|
6
|
+
// DOC: Costo configurado de una plantilla, ya normalizado. Devuelve `null` cuando no hay
|
|
7
|
+
// costo, y NUNCA un negativo ni un NaN: es lo que se copia al precio de la visita.
|
|
8
|
+
const getTemplateCost = (settings) => {
|
|
9
|
+
const cost = settings?.cost;
|
|
10
|
+
if (cost === null || cost === undefined)
|
|
11
|
+
return null;
|
|
12
|
+
const value = Number(cost);
|
|
13
|
+
if (!Number.isFinite(value) || value < 0)
|
|
14
|
+
return null;
|
|
15
|
+
return value;
|
|
16
|
+
};
|
|
17
|
+
exports.getTemplateCost = getTemplateCost;
|
|
18
|
+
// DOC: Deja `settings` listo para guardar con el costo indicado, conservando lo demás que
|
|
19
|
+
// haya adentro. `null` borra el costo; el objeto entero pasa a `null` si queda vacío, para
|
|
20
|
+
// no dejar `{}` en la base.
|
|
21
|
+
const withTemplateCost = (settings, cost) => {
|
|
22
|
+
const next = { ...(settings ?? {}) };
|
|
23
|
+
if (cost === null)
|
|
24
|
+
delete next.cost;
|
|
25
|
+
else
|
|
26
|
+
next.cost = cost;
|
|
27
|
+
return Object.keys(next).length > 0 ? next : null;
|
|
28
|
+
};
|
|
29
|
+
exports.withTemplateCost = withTemplateCost;
|
|
@@ -1,9 +1,11 @@
|
|
|
1
|
+
import { ITemplateSettings } from "../template.settings";
|
|
1
2
|
export declare class Templates {
|
|
2
3
|
id: number;
|
|
3
4
|
code: string;
|
|
4
5
|
vehicle_type: number;
|
|
5
6
|
workshop: number;
|
|
6
7
|
name: string;
|
|
8
|
+
settings: ITemplateSettings | null;
|
|
7
9
|
created: Date;
|
|
8
10
|
updated: Date | null;
|
|
9
11
|
status: number;
|
package/dist/views/Templates.js
CHANGED
|
@@ -34,6 +34,10 @@ __decorate([
|
|
|
34
34
|
(0, typeorm_1.ViewColumn)(),
|
|
35
35
|
__metadata("design:type", String)
|
|
36
36
|
], Templates.prototype, "name", void 0);
|
|
37
|
+
__decorate([
|
|
38
|
+
(0, typeorm_1.ViewColumn)(),
|
|
39
|
+
__metadata("design:type", Object)
|
|
40
|
+
], Templates.prototype, "settings", void 0);
|
|
37
41
|
__decorate([
|
|
38
42
|
(0, typeorm_1.ViewColumn)(),
|
|
39
43
|
__metadata("design:type", Date)
|