@asumano/worklip-typeorm-db 1.1.112 → 1.1.113

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.
@@ -20,6 +20,8 @@ export declare class Associate {
20
20
  city: City | null;
21
21
  address: string | null;
22
22
  photo: string | null;
23
+ face_consent: number | null;
24
+ face_consent_at: Date | null;
23
25
  blood_type: number | null;
24
26
  job_title: JobTitle | null;
25
27
  password: string;
@@ -132,6 +132,24 @@ __decorate([
132
132
  }),
133
133
  __metadata("design:type", Object)
134
134
  ], Associate.prototype, "photo", void 0);
135
+ __decorate([
136
+ (0, typeorm_1.Column)({
137
+ nullable: true,
138
+ default: null,
139
+ type: "int",
140
+ comment: "Reconocimiento facial. NULL: sin registrar, 1: autoriza (al registrarle las fotos), 2: retiró la autorización.",
141
+ }),
142
+ __metadata("design:type", Object)
143
+ ], Associate.prototype, "face_consent", void 0);
144
+ __decorate([
145
+ (0, typeorm_1.Column)({
146
+ nullable: true,
147
+ default: null,
148
+ type: "datetime",
149
+ comment: "Fecha en que autorizó o retiró el reconocimiento facial.",
150
+ }),
151
+ __metadata("design:type", Object)
152
+ ], Associate.prototype, "face_consent_at", void 0);
135
153
  __decorate([
136
154
  (0, typeorm_1.Column)({
137
155
  nullable: true,
@@ -0,0 +1,9 @@
1
+ import { Associate } from "./Associate";
2
+ export declare class AssociateFace {
3
+ id: number;
4
+ associate: Associate;
5
+ image: string;
6
+ source: number;
7
+ created_by: Associate | null;
8
+ created: Date;
9
+ }
@@ -0,0 +1,72 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ var __metadata = (this && this.__metadata) || function (k, v) {
9
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.AssociateFace = void 0;
13
+ const typeorm_1 = require("typeorm");
14
+ const Associate_1 = require("./Associate");
15
+ // DOC: Fotos del rostro del empleado para el reconocimiento facial (sql/99). Máximo 3 por empleado.
16
+ let AssociateFace = class AssociateFace {
17
+ };
18
+ exports.AssociateFace = AssociateFace;
19
+ __decorate([
20
+ (0, typeorm_1.PrimaryGeneratedColumn)({
21
+ type: "int",
22
+ comment: "Número de identificación (ID) único de cada registro.",
23
+ }),
24
+ __metadata("design:type", Number)
25
+ ], AssociateFace.prototype, "id", void 0);
26
+ __decorate([
27
+ (0, typeorm_1.ManyToOne)(() => Associate_1.Associate, {
28
+ onDelete: "CASCADE",
29
+ onUpdate: "NO ACTION",
30
+ }),
31
+ (0, typeorm_1.JoinColumn)({ name: "associate" }),
32
+ __metadata("design:type", Associate_1.Associate)
33
+ ], AssociateFace.prototype, "associate", void 0);
34
+ __decorate([
35
+ (0, typeorm_1.Column)({
36
+ type: "varchar",
37
+ length: 255,
38
+ comment: "Llave en R2 de la foto (WebP o JPG), en companies/<empresa>/associates-face/<empleado>/.",
39
+ }),
40
+ __metadata("design:type", String)
41
+ ], AssociateFace.prototype, "image", void 0);
42
+ __decorate([
43
+ (0, typeorm_1.Column)({
44
+ type: "int",
45
+ default: 1,
46
+ comment: "Dónde se tomó. 1: sistema (pantalla), 2: terminal.",
47
+ }),
48
+ __metadata("design:type", Number)
49
+ ], AssociateFace.prototype, "source", void 0);
50
+ __decorate([
51
+ (0, typeorm_1.ManyToOne)(() => Associate_1.Associate, {
52
+ nullable: true,
53
+ onDelete: "SET NULL",
54
+ onUpdate: "NO ACTION",
55
+ }),
56
+ (0, typeorm_1.JoinColumn)({ name: "created_by" }),
57
+ __metadata("design:type", Object)
58
+ ], AssociateFace.prototype, "created_by", void 0);
59
+ __decorate([
60
+ (0, typeorm_1.Column)({
61
+ type: "datetime",
62
+ comment: "Fecha de creación del registro.",
63
+ default: () => "CURRENT_TIMESTAMP",
64
+ }),
65
+ __metadata("design:type", Date)
66
+ ], AssociateFace.prototype, "created", void 0);
67
+ exports.AssociateFace = AssociateFace = __decorate([
68
+ (0, typeorm_1.Index)("IDX_associate_face_associate", ["associate"]),
69
+ (0, typeorm_1.Entity)("associate_face", {
70
+ comment: "Fotos del rostro de los empleados para el reconocimiento facial de la terminal.",
71
+ })
72
+ ], AssociateFace);
@@ -136,5 +136,6 @@ export { ObdCode } from "./entities/ObdCode";
136
136
  export { WorkshopReportInbox } from "./entities/WorkshopReportInbox";
137
137
  export { WorkshopUnknownDevice } from "./entities/WorkshopUnknownDevice";
138
138
  export { JobTitle } from "./entities/JobTitle";
139
+ export { AssociateFace } from "./entities/AssociateFace";
139
140
  export { AssociatePayRate } from "./entities/AssociatePayRate";
140
141
  export { PayrollMonthDays } from "./entities/PayrollMonthDays";
@@ -2,7 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.AssociateSection = exports.AssociatePermission = exports.AssociateRole = exports.AssociatePlatform = exports.ClientSubscription = exports.ClientPlanLimit = exports.ClientPlan = exports.ClientDocumentDispute = exports.ReviewTaskEvent = exports.ReviewTask = exports.MasterNotification = exports.ClientSession = exports.ClientNotification = exports.ClientIdentity = exports.PypRuleVote = exports.PypRule = exports.VehicleVerification = exports.ClientVehicleInvite = exports.ClientVehicle = exports.CompanyVehicle = exports.CompanyClient = exports.Appointment = exports.DocumentType = exports.ReminderType = exports.Reminder = exports.ServiceOrderHistory = exports.ServiceOrder = exports.TemplateSection = exports.SectionItem = exports.Section = exports.Template = exports.Workshop = exports.GlobalTemplateSection = exports.GlobalSectionItem = exports.GlobalSection = exports.GlobalTemplate = exports.AssociateNotification = exports.AssociateSession = exports.MasterSession = exports.Associate = exports.Client = exports.Master = exports.VehicleReport = exports.Vehicle = exports.Brand = exports.Company = exports.City = exports.Region = exports.WhatsappLine = exports.Country = void 0;
4
4
  exports.AssociateDailyStats = exports.WorkshopDailyStats = exports.WorkboardEvent = exports.ServiceOrderStage = exports.WorkboardStatus = exports.CompanyDiscount = exports.DiscountCode = exports.WorkshopDisplay = exports.WorkshopInsurer = exports.WorkshopOfferedService = exports.Insurer = exports.OfferedService = exports.WorkshopOutingRecipient = exports.ServiceOrderOuting = exports.ServiceOrderPart = exports.ServiceOrderObservation = exports.VisitResult = exports.ReminderTypeCompanyType = exports.PlanCompanyType = exports.WorkshopCompanyType = exports.CompanyCompanyType = exports.CompanyType = exports.PlanFeature = exports.CompanyFeature = exports.Feature = exports.UsageAlert = exports.SubscriptionAddonTemplate = exports.PaymentTransaction = exports.BillingInvoice = exports.EmailSuppression = exports.EmailLog = exports.WhatsappLog = exports.ServiceOrderApproval = exports.MediaFile = exports.BillingUsageSnapshot = exports.PaymentMethod = exports.SubscriptionAddon = exports.CompanySubscription = exports.SubscriptionPlan = exports.CountryHoliday = exports.CompanyVehicleType = exports.BrandVehicleType = exports.CompanyBrand = exports.VehicleType = exports.MasterSection = exports.MasterPermission = exports.MasterRole = exports.MasterPlatform = exports.MasterPasswordReset = exports.AssociatePasswordReset = void 0;
5
- exports.PayrollMonthDays = exports.AssociatePayRate = exports.JobTitle = exports.WorkshopUnknownDevice = exports.WorkshopReportInbox = exports.ObdCode = exports.VehicleMeasurement = exports.WorkshopEquipment = exports.EquipmentType = exports.CompanyAiUsage = exports.CompanyQuotaAdjustment = exports.VisitSearchHistory = exports.VisitAiAnalysis = exports.VisitSearchPerson = exports.VisitItemSearch = exports.GlobalSectionItems = exports.GlobalSections = exports.GlobalTemplates = exports.SubscriptionAddonTemplates = exports.SubscriptionPlans = exports.Masters = exports.Companies = exports.WorkshopsByAssociate = exports.Workshops = exports.SectionItems = exports.Sections = exports.Templates = exports.Reminders = exports.Vehicles = exports.Clients = exports.ServicesOrderLite = exports.ServicesOrder = exports.Associates = exports.AssociateSectionFeature = exports.AttendanceMark = exports.WorkshopReader = exports.AssociateTag = exports.WorkshopTag = exports.MetricEvent = exports.StageMetric = void 0;
5
+ exports.PayrollMonthDays = exports.AssociatePayRate = exports.AssociateFace = exports.JobTitle = exports.WorkshopUnknownDevice = exports.WorkshopReportInbox = exports.ObdCode = exports.VehicleMeasurement = exports.WorkshopEquipment = exports.EquipmentType = exports.CompanyAiUsage = exports.CompanyQuotaAdjustment = exports.VisitSearchHistory = exports.VisitAiAnalysis = exports.VisitSearchPerson = exports.VisitItemSearch = exports.GlobalSectionItems = exports.GlobalSections = exports.GlobalTemplates = exports.SubscriptionAddonTemplates = exports.SubscriptionPlans = exports.Masters = exports.Companies = exports.WorkshopsByAssociate = exports.Workshops = exports.SectionItems = exports.Sections = exports.Templates = exports.Reminders = exports.Vehicles = exports.Clients = exports.ServicesOrderLite = exports.ServicesOrder = exports.Associates = exports.AssociateSectionFeature = exports.AttendanceMark = exports.WorkshopReader = exports.AssociateTag = exports.WorkshopTag = exports.MetricEvent = exports.StageMetric = void 0;
6
6
  var Country_1 = require("./entities/Country");
7
7
  Object.defineProperty(exports, "Country", { enumerable: true, get: function () { return Country_1.Country; } });
8
8
  var WhatsappLine_1 = require("./entities/WhatsappLine");
@@ -306,6 +306,8 @@ var WorkshopUnknownDevice_1 = require("./entities/WorkshopUnknownDevice");
306
306
  Object.defineProperty(exports, "WorkshopUnknownDevice", { enumerable: true, get: function () { return WorkshopUnknownDevice_1.WorkshopUnknownDevice; } });
307
307
  var JobTitle_1 = require("./entities/JobTitle");
308
308
  Object.defineProperty(exports, "JobTitle", { enumerable: true, get: function () { return JobTitle_1.JobTitle; } });
309
+ var AssociateFace_1 = require("./entities/AssociateFace");
310
+ Object.defineProperty(exports, "AssociateFace", { enumerable: true, get: function () { return AssociateFace_1.AssociateFace; } });
309
311
  var AssociatePayRate_1 = require("./entities/AssociatePayRate");
310
312
  Object.defineProperty(exports, "AssociatePayRate", { enumerable: true, get: function () { return AssociatePayRate_1.AssociatePayRate; } });
311
313
  var PayrollMonthDays_1 = require("./entities/PayrollMonthDays");
@@ -0,0 +1,19 @@
1
+ /** DOC: `associate.face_consent`. NULL = nunca registrado (se puede registrar). */
2
+ export declare const FACE_CONSENT: {
3
+ readonly GRANTED: 1;
4
+ readonly WITHDRAWN: 2;
5
+ };
6
+ /** DOC: `associate_face.source`: dónde se tomó la foto. */
7
+ export declare const FACE_SOURCE: {
8
+ readonly SYSTEM: 1;
9
+ readonly TERMINAL: 2;
10
+ };
11
+ export declare const FACE_MAX_PHOTOS = 3;
12
+ export declare const FACE_MAX_BYTES: number;
13
+ /** DOC: JPG o WebP; nunca PNG, para no confundirse con la foto del carné. */
14
+ export declare const FACE_IMAGE_TYPES: readonly string[];
15
+ /** DOC: Carpeta APARTE de la del carné (`associates/`): las URLs de esa se firman para cualquiera de la empresa. */
16
+ export declare const associateFacePrefix: (companyCode: string, associateCode: string) => string;
17
+ export declare const isAssociateFaceKey: (key: unknown, companyCode: string | null | undefined, associateCode: string | null | undefined) => key is string;
18
+ /** DOC: ¿Se le pueden subir fotos? Solo si no retiró la autorización. */
19
+ export declare const canRegisterFace: (consent: number | null | undefined) => boolean;
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+ // DOC: Fotos del rostro para el reconocimiento facial de la terminal de asistencia (sql/99). Módulo PURO.
3
+ // import { FACE_CONSENT } from "@asumano/worklip-typeorm-db/dist/rules/associate.face.rules";
4
+ // Las registra SOLO quien tenga MANAGE_FACE_RECOGNITION (o el dueño). Registrarlas = el empleado autoriza;
5
+ // si la retira en su perfil, se borran y nadie le puede subir otras hasta que él la vuelva a dar.
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ exports.canRegisterFace = exports.isAssociateFaceKey = exports.associateFacePrefix = exports.FACE_IMAGE_TYPES = exports.FACE_MAX_BYTES = exports.FACE_MAX_PHOTOS = exports.FACE_SOURCE = exports.FACE_CONSENT = void 0;
8
+ /** DOC: `associate.face_consent`. NULL = nunca registrado (se puede registrar). */
9
+ exports.FACE_CONSENT = { GRANTED: 1, WITHDRAWN: 2 };
10
+ /** DOC: `associate_face.source`: dónde se tomó la foto. */
11
+ exports.FACE_SOURCE = { SYSTEM: 1, TERMINAL: 2 };
12
+ exports.FACE_MAX_PHOTOS = 3;
13
+ exports.FACE_MAX_BYTES = 2 * 1024 * 1024;
14
+ /** DOC: JPG o WebP; nunca PNG, para no confundirse con la foto del carné. */
15
+ exports.FACE_IMAGE_TYPES = ["image/webp", "image/jpeg"];
16
+ /** DOC: Carpeta APARTE de la del carné (`associates/`): las URLs de esa se firman para cualquiera de la empresa. */
17
+ const associateFacePrefix = (companyCode, associateCode) => `companies/${companyCode}/associates-face/${associateCode}/`;
18
+ exports.associateFacePrefix = associateFacePrefix;
19
+ const isAssociateFaceKey = (key, companyCode, associateCode) => typeof key === "string" &&
20
+ !!companyCode &&
21
+ !!associateCode &&
22
+ !key.includes("..") &&
23
+ key.startsWith((0, exports.associateFacePrefix)(companyCode, associateCode)) &&
24
+ /\.(webp|jpg)$/i.test(key);
25
+ exports.isAssociateFaceKey = isAssociateFaceKey;
26
+ /** DOC: ¿Se le pueden subir fotos? Solo si no retiró la autorización. */
27
+ const canRegisterFace = (consent) => consent !== exports.FACE_CONSENT.WITHDRAWN;
28
+ exports.canRegisterFace = canRegisterFace;
@@ -54,6 +54,7 @@ export declare const ATTENDANCE_LIMITS: {
54
54
  export interface ICompanyAttendanceSettings {
55
55
  allow_document: boolean;
56
56
  employees_see_own: boolean;
57
+ face_recognition: boolean;
57
58
  }
58
59
  export interface IWorkshopAttendanceSettings {
59
60
  tolerance_minutes: number;
@@ -48,6 +48,7 @@ const clampTolerance = (value) => {
48
48
  const normalizeCompanyAttendance = (raw) => ({
49
49
  allow_document: raw?.allow_document === true,
50
50
  employees_see_own: raw?.employees_see_own === true,
51
+ face_recognition: raw?.face_recognition === true,
51
52
  });
52
53
  exports.normalizeCompanyAttendance = normalizeCompanyAttendance;
53
54
  const normalizeWorkshopAttendance = (raw) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@asumano/worklip-typeorm-db",
3
- "version": "1.1.112",
3
+ "version": "1.1.113",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },