@asumano/worklip-typeorm-db 1.1.114 → 1.1.115
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/Associate.d.ts +1 -0
- package/dist/entities/Associate.js +8 -0
- package/dist/rules/associate.profile.rules.d.ts +7 -0
- package/dist/rules/associate.profile.rules.js +8 -1
- package/dist/rules/badge.card.rules.d.ts +23 -0
- package/dist/rules/badge.card.rules.js +38 -1
- package/package.json +1 -1
|
@@ -167,6 +167,14 @@ __decorate([
|
|
|
167
167
|
}),
|
|
168
168
|
__metadata("design:type", Number)
|
|
169
169
|
], Associate.prototype, "employment_type", void 0);
|
|
170
|
+
__decorate([
|
|
171
|
+
(0, typeorm_1.Column)({
|
|
172
|
+
type: "int",
|
|
173
|
+
default: 1,
|
|
174
|
+
comment: "Tipo de empleado:\r\n1: Operativo (puede llevar tarifa de nómina).\r\n2: Administrativo (sueldo fijo, sin tarifa).",
|
|
175
|
+
}),
|
|
176
|
+
__metadata("design:type", Number)
|
|
177
|
+
], Associate.prototype, "staff_category", void 0);
|
|
170
178
|
__decorate([
|
|
171
179
|
(0, typeorm_1.ManyToOne)(() => JobTitle_1.JobTitle, {
|
|
172
180
|
nullable: true,
|
|
@@ -20,6 +20,13 @@ export declare const EMPLOYMENT_TYPE: {
|
|
|
20
20
|
};
|
|
21
21
|
export type TEmploymentType = (typeof EMPLOYMENT_TYPE)[keyof typeof EMPLOYMENT_TYPE];
|
|
22
22
|
export declare const isEmploymentType: (value: unknown) => value is TEmploymentType;
|
|
23
|
+
/** DOC: `associate.staff_category` (sql/108). Solo el operativo lleva tarifa de nómina; el administrativo tiene sueldo fijo. */
|
|
24
|
+
export declare const STAFF_CATEGORY: {
|
|
25
|
+
readonly OPERATIONAL: 1;
|
|
26
|
+
readonly ADMINISTRATIVE: 2;
|
|
27
|
+
};
|
|
28
|
+
export type TStaffCategory = (typeof STAFF_CATEGORY)[keyof typeof STAFF_CATEGORY];
|
|
29
|
+
export declare const isStaffCategory: (value: unknown) => value is TStaffCategory;
|
|
23
30
|
export declare const JOB_TITLE_STATUS: {
|
|
24
31
|
readonly INACTIVE: 0;
|
|
25
32
|
readonly ACTIVE: 1;
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// DOC: Foto, tipo de sangre y cargo del empleado (sql/85). Módulo PURO: el API valida y los fronts pintan.
|
|
3
3
|
// import { BLOOD_TYPE } from "@asumano/worklip-typeorm-db/dist/rules/associate.profile.rules";
|
|
4
4
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
-
exports.associateInitials = exports.isAssociatePhotoKey = exports.associatePhotoPrefix = exports.ASSOCIATE_PHOTO_MAX_BYTES = exports.ASSOCIATE_PHOTO_SIZE = exports.normalizeJobTitleName = exports.SUGGESTED_JOB_TITLES = exports.JOB_TITLE_NAME_MAX = exports.JOB_TITLE_STATUS = exports.isEmploymentType = exports.EMPLOYMENT_TYPE = exports.bloodTypeLabel = exports.isBloodType = exports.BLOOD_TYPE_LABEL = exports.BLOOD_TYPE = void 0;
|
|
5
|
+
exports.associateInitials = exports.isAssociatePhotoKey = exports.associatePhotoPrefix = exports.ASSOCIATE_PHOTO_MAX_BYTES = exports.ASSOCIATE_PHOTO_SIZE = exports.normalizeJobTitleName = exports.SUGGESTED_JOB_TITLES = exports.JOB_TITLE_NAME_MAX = exports.JOB_TITLE_STATUS = exports.isStaffCategory = exports.STAFF_CATEGORY = exports.isEmploymentType = exports.EMPLOYMENT_TYPE = exports.bloodTypeLabel = exports.isBloodType = exports.BLOOD_TYPE_LABEL = exports.BLOOD_TYPE = void 0;
|
|
6
6
|
/** DOC: `associate.blood_type`. Dato sensible: solo lo ven el empleado y quien administra usuarios. */
|
|
7
7
|
exports.BLOOD_TYPE = {
|
|
8
8
|
O_POS: 1,
|
|
@@ -35,6 +35,13 @@ exports.EMPLOYMENT_TYPE = {
|
|
|
35
35
|
};
|
|
36
36
|
const isEmploymentType = (value) => Number(value) === exports.EMPLOYMENT_TYPE.DIRECT || Number(value) === exports.EMPLOYMENT_TYPE.CONTRACTOR;
|
|
37
37
|
exports.isEmploymentType = isEmploymentType;
|
|
38
|
+
/** DOC: `associate.staff_category` (sql/108). Solo el operativo lleva tarifa de nómina; el administrativo tiene sueldo fijo. */
|
|
39
|
+
exports.STAFF_CATEGORY = {
|
|
40
|
+
OPERATIONAL: 1,
|
|
41
|
+
ADMINISTRATIVE: 2,
|
|
42
|
+
};
|
|
43
|
+
const isStaffCategory = (value) => Number(value) === exports.STAFF_CATEGORY.OPERATIONAL || Number(value) === exports.STAFF_CATEGORY.ADMINISTRATIVE;
|
|
44
|
+
exports.isStaffCategory = isStaffCategory;
|
|
38
45
|
exports.JOB_TITLE_STATUS = { INACTIVE: 0, ACTIVE: 1 };
|
|
39
46
|
exports.JOB_TITLE_NAME_MAX = 60;
|
|
40
47
|
/** DOC: Lo que ofrece «Agregar sugeridos» en una empresa que todavía no tiene cargos. */
|
|
@@ -49,7 +49,30 @@ export interface IBadgeCardOptions {
|
|
|
49
49
|
paper: (typeof BADGE_PAPER)[keyof typeof BADGE_PAPER];
|
|
50
50
|
tagline: string | null;
|
|
51
51
|
colors: IWorkshopBrandColors | null;
|
|
52
|
+
background: IBadgeBackground;
|
|
52
53
|
}
|
|
54
|
+
export declare const BADGE_BACKGROUND: {
|
|
55
|
+
readonly WHITE: 1;
|
|
56
|
+
readonly COLOR: 2;
|
|
57
|
+
readonly IMAGE: 3;
|
|
58
|
+
};
|
|
59
|
+
export declare const BADGE_BACKGROUND_MAX_BYTES: number;
|
|
60
|
+
export declare const BADGE_VEIL_LIMITS: {
|
|
61
|
+
min: number;
|
|
62
|
+
max: number;
|
|
63
|
+
default: number;
|
|
64
|
+
};
|
|
65
|
+
export interface IBadgeBackground {
|
|
66
|
+
type: (typeof BADGE_BACKGROUND)[keyof typeof BADGE_BACKGROUND];
|
|
67
|
+
color: string | null;
|
|
68
|
+
image: string | null;
|
|
69
|
+
veil: number;
|
|
70
|
+
}
|
|
71
|
+
export declare const DEFAULT_BADGE_BACKGROUND: IBadgeBackground;
|
|
72
|
+
export declare const badgeBackgroundPrefix: (companyCode: string) => string;
|
|
73
|
+
export declare const isBadgeBackgroundKey: (key: unknown, companyCode?: string) => key is string;
|
|
74
|
+
/** DOC: Fondo válido; COLOR sin color o IMAGE sin imagen caen a blanco. */
|
|
75
|
+
export declare const normalizeBadgeBackground: (input: any) => IBadgeBackground;
|
|
53
76
|
export declare const DEFAULT_BADGE_CARD_OPTIONS: IBadgeCardOptions;
|
|
54
77
|
/** DOC: Deja las opciones válidas venga lo que venga (lo guardado o el cuerpo de la petición). */
|
|
55
78
|
export declare const normalizeBadgeCardOptions: (input: any) => IBadgeCardOptions;
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
// los colores en `workshop.details.brand`. Módulo PURO, lo usan el API (PDF) y el front (bocetos).
|
|
4
4
|
// import { BADGE_TEMPLATE } from "@asumano/worklip-typeorm-db/dist/rules/badge.card.rules";
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.readableTextColor = exports.readableAccent = exports.contrastRatio = exports.normalizeBrandColors = exports.isHexColor = exports.NEUTRAL_BRAND_COLORS = exports.maskBadgeDocument = exports.badgeDimensionsMm = exports.normalizeBadgeCardOptions = exports.DEFAULT_BADGE_CARD_OPTIONS = exports.PAPER_MM = exports.BADGE_CUSTOM_LIMITS = exports.BADGE_SIZE_MM = exports.BADGE_DOCUMENT = exports.BADGE_PAPER = exports.BADGE_SIZE = exports.BADGE_TAGLINE_MAX = exports.isVerticalBadge = exports.BADGE_TEMPLATE = void 0;
|
|
6
|
+
exports.readableTextColor = exports.readableAccent = exports.contrastRatio = exports.normalizeBrandColors = exports.isHexColor = exports.NEUTRAL_BRAND_COLORS = exports.maskBadgeDocument = exports.badgeDimensionsMm = exports.normalizeBadgeCardOptions = exports.DEFAULT_BADGE_CARD_OPTIONS = exports.normalizeBadgeBackground = exports.isBadgeBackgroundKey = exports.badgeBackgroundPrefix = exports.DEFAULT_BADGE_BACKGROUND = exports.BADGE_VEIL_LIMITS = exports.BADGE_BACKGROUND_MAX_BYTES = exports.BADGE_BACKGROUND = exports.PAPER_MM = exports.BADGE_CUSTOM_LIMITS = exports.BADGE_SIZE_MM = exports.BADGE_DOCUMENT = exports.BADGE_PAPER = exports.BADGE_SIZE = exports.BADGE_TAGLINE_MAX = exports.isVerticalBadge = exports.BADGE_TEMPLATE = void 0;
|
|
7
7
|
exports.BADGE_TEMPLATE = {
|
|
8
8
|
VERTICAL_STRIPES: 1,
|
|
9
9
|
VERTICAL_BLOCK: 2,
|
|
@@ -30,6 +30,41 @@ exports.PAPER_MM = {
|
|
|
30
30
|
1: { width: 215.9, height: 279.4 },
|
|
31
31
|
2: { width: 210, height: 297 },
|
|
32
32
|
};
|
|
33
|
+
// DOC: Fondo de la cara del carné (frente y reverso): blanco, un color o una imagen de la empresa.
|
|
34
|
+
exports.BADGE_BACKGROUND = { WHITE: 1, COLOR: 2, IMAGE: 3 };
|
|
35
|
+
exports.BADGE_BACKGROUND_MAX_BYTES = 5 * 1024 * 1024;
|
|
36
|
+
// DOC: Velo blanco sobre la imagen, en %, para que el texto oscuro se lea.
|
|
37
|
+
exports.BADGE_VEIL_LIMITS = { min: 0, max: 80, default: 60 };
|
|
38
|
+
exports.DEFAULT_BADGE_BACKGROUND = {
|
|
39
|
+
type: exports.BADGE_BACKGROUND.WHITE,
|
|
40
|
+
color: null,
|
|
41
|
+
image: null,
|
|
42
|
+
veil: exports.BADGE_VEIL_LIMITS.default,
|
|
43
|
+
};
|
|
44
|
+
const badgeBackgroundPrefix = (companyCode) => `companies/${companyCode}/badge-backgrounds/`;
|
|
45
|
+
exports.badgeBackgroundPrefix = badgeBackgroundPrefix;
|
|
46
|
+
const isBadgeBackgroundKey = (key, companyCode) => typeof key === "string" &&
|
|
47
|
+
!key.includes("..") &&
|
|
48
|
+
/^companies\/[^/]+\/badge-backgrounds\/[A-Za-z0-9-]+\.(jpg|png)$/.test(key) &&
|
|
49
|
+
(!companyCode || key.startsWith((0, exports.badgeBackgroundPrefix)(companyCode)));
|
|
50
|
+
exports.isBadgeBackgroundKey = isBadgeBackgroundKey;
|
|
51
|
+
/** DOC: Fondo válido; COLOR sin color o IMAGE sin imagen caen a blanco. */
|
|
52
|
+
const normalizeBadgeBackground = (input) => {
|
|
53
|
+
const d = exports.DEFAULT_BADGE_BACKGROUND;
|
|
54
|
+
const color = (0, exports.isHexColor)(input?.color) ? input.color.toUpperCase() : null;
|
|
55
|
+
const image = (0, exports.isBadgeBackgroundKey)(input?.image) ? input.image : null;
|
|
56
|
+
const veil = Number(input?.veil);
|
|
57
|
+
let type = pick(input?.type, [1, 2, 3], d.type);
|
|
58
|
+
if ((type === exports.BADGE_BACKGROUND.COLOR && !color) || (type === exports.BADGE_BACKGROUND.IMAGE && !image))
|
|
59
|
+
type = d.type;
|
|
60
|
+
return {
|
|
61
|
+
type,
|
|
62
|
+
color,
|
|
63
|
+
image,
|
|
64
|
+
veil: Number.isFinite(veil) ? Math.min(exports.BADGE_VEIL_LIMITS.max, Math.max(exports.BADGE_VEIL_LIMITS.min, Math.round(veil))) : d.veil,
|
|
65
|
+
};
|
|
66
|
+
};
|
|
67
|
+
exports.normalizeBadgeBackground = normalizeBadgeBackground;
|
|
33
68
|
exports.DEFAULT_BADGE_CARD_OPTIONS = {
|
|
34
69
|
template: exports.BADGE_TEMPLATE.VERTICAL_STRIPES,
|
|
35
70
|
back: true,
|
|
@@ -41,6 +76,7 @@ exports.DEFAULT_BADGE_CARD_OPTIONS = {
|
|
|
41
76
|
paper: exports.BADGE_PAPER.LETTER,
|
|
42
77
|
tagline: null,
|
|
43
78
|
colors: null,
|
|
79
|
+
background: exports.DEFAULT_BADGE_BACKGROUND,
|
|
44
80
|
};
|
|
45
81
|
const pick = (value, allowed, fallback) => allowed.includes(Number(value)) ? Number(value) : fallback;
|
|
46
82
|
const clamp = (value, min, max) => {
|
|
@@ -68,6 +104,7 @@ const normalizeBadgeCardOptions = (input) => {
|
|
|
68
104
|
? input.tagline.replace(/\s+/g, " ").trim().slice(0, exports.BADGE_TAGLINE_MAX)
|
|
69
105
|
: null,
|
|
70
106
|
colors: (0, exports.normalizeBrandColors)(input?.colors),
|
|
107
|
+
background: (0, exports.normalizeBadgeBackground)(input?.background),
|
|
71
108
|
};
|
|
72
109
|
};
|
|
73
110
|
exports.normalizeBadgeCardOptions = normalizeBadgeCardOptions;
|