@telos-dev-team/dealernode-permissions 1.0.7 → 1.1.2

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.
@@ -710,11 +710,11 @@ export declare const PERMISSIONS: {
710
710
  readonly DELETE: "authorization.user_dealer_permission.delete";
711
711
  };
712
712
  };
713
- readonly FAILED_ACTION: {
713
+ readonly AUTOMATIC_ACTION: {
714
714
  readonly OPERATIONS: {
715
- readonly VIEW: "failed_action.operations.view";
716
- readonly DELETE: "failed_action.operations.delete";
717
- readonly EXECUTE: "failed_action.operations.execute";
715
+ readonly VIEW: "automatic_action.operations.view";
716
+ readonly DELETE: "automatic_action.operations.delete";
717
+ readonly EXECUTE: "automatic_action.operations.execute";
718
718
  };
719
719
  };
720
720
  readonly CALENDAR: {
@@ -723,5 +723,21 @@ export declare const PERMISSIONS: {
723
723
  readonly UPDATE: "calendar.operations.update";
724
724
  };
725
725
  };
726
+ readonly GPS_PROVIDER: {
727
+ readonly CONFIG: {
728
+ readonly OPERATIONS: {
729
+ readonly CREATE: "gps-provider.config.operations.create";
730
+ readonly VIEW: "gps-provider.config.operations.view";
731
+ readonly UPDATE: "gps-provider.config.operations.update";
732
+ readonly DELETE: "gps-provider.config.operations.delete";
733
+ };
734
+ };
735
+ readonly DEVICE: {
736
+ readonly OPERATIONS: {
737
+ readonly VIEW: "gps-provider.device.operations.view";
738
+ readonly LOCATE: "gps-provider.device.operations.locate";
739
+ };
740
+ };
741
+ };
726
742
  };
727
743
  export type Permission = typeof PERMISSIONS;
@@ -774,13 +774,13 @@ exports.PERMISSIONS = {
774
774
  },
775
775
  },
776
776
  // ============================================
777
- // FAILED_ACTION
777
+ // AUTOMATIC_ACTION
778
778
  // ============================================
779
- FAILED_ACTION: {
779
+ AUTOMATIC_ACTION: {
780
780
  OPERATIONS: {
781
- VIEW: 'failed_action.operations.view',
782
- DELETE: 'failed_action.operations.delete',
783
- EXECUTE: 'failed_action.operations.execute',
781
+ VIEW: 'automatic_action.operations.view',
782
+ DELETE: 'automatic_action.operations.delete',
783
+ EXECUTE: 'automatic_action.operations.execute',
784
784
  },
785
785
  },
786
786
  // ============================================
@@ -792,4 +792,23 @@ exports.PERMISSIONS = {
792
792
  UPDATE: 'calendar.operations.update',
793
793
  },
794
794
  },
795
+ // ============================================
796
+ // GPS PROVIDER
797
+ // ============================================
798
+ GPS_PROVIDER: {
799
+ CONFIG: {
800
+ OPERATIONS: {
801
+ CREATE: 'gps-provider.config.operations.create',
802
+ VIEW: 'gps-provider.config.operations.view',
803
+ UPDATE: 'gps-provider.config.operations.update',
804
+ DELETE: 'gps-provider.config.operations.delete',
805
+ },
806
+ },
807
+ DEVICE: {
808
+ OPERATIONS: {
809
+ VIEW: 'gps-provider.device.operations.view',
810
+ LOCATE: 'gps-provider.device.operations.locate',
811
+ },
812
+ },
813
+ },
795
814
  };
@@ -0,0 +1,109 @@
1
+ # GPS Provider — Permisos a agregar al paquete común
2
+
3
+ Este documento define los permisos del módulo `gps-provider` para integrarlos al
4
+ paquete `@telos-dev-team/dealernode-permissions` (la fuente de verdad de
5
+ permisos de DealerNode). Una vez agregados y publicada una nueva versión del
6
+ paquete, `dealernode-backend` los importa desde `PERMISSIONS.GPS_PROVIDER.*` y
7
+ los persiste en DB con `npm run sync:permissions`.
8
+
9
+ ## Bloque TypeScript a agregar en `src/permissions.ts`
10
+
11
+ Insertar como un top-level más del objeto `PERMISSIONS` (mismo nivel que
12
+ `DEAL`, `CAR`, `PAYMENT`, etc.):
13
+
14
+ ```ts
15
+ GPS_PROVIDER: {
16
+ CONFIG: {
17
+ OPERATIONS: {
18
+ CREATE: 'gps-provider.config.operations.create',
19
+ VIEW: 'gps-provider.config.operations.view',
20
+ UPDATE: 'gps-provider.config.operations.update',
21
+ DELETE: 'gps-provider.config.operations.delete',
22
+ },
23
+ },
24
+ DEVICE: {
25
+ OPERATIONS: {
26
+ VIEW: 'gps-provider.device.operations.view',
27
+ LOCATE: 'gps-provider.device.operations.locate',
28
+ },
29
+ },
30
+ },
31
+ ```
32
+
33
+ Total: **6 permisos nuevos**.
34
+
35
+ ### Naming
36
+
37
+ Sigue la convención existente del paquete: `module.resource.operations.action`,
38
+ con `kebab-case` en el slug del módulo cuando lleva guión (como ya hace el
39
+ paquete para `connected-account`).
40
+
41
+ ### Por qué dos sub-recursos (`CONFIG` y `DEVICE`)
42
+
43
+ - `CONFIG` controla quién puede administrar la configuración del proveedor GPS
44
+ por dealer (credenciales, nombre, tipo de proveedor). Es un recurso CRUD
45
+ clásico → 4 acciones.
46
+ - `DEVICE` controla quién puede consultar dispositivos GPS contra el proveedor
47
+ externo. Se separa en dos por costo:
48
+ - `VIEW` cubre las lecturas (location, history, status, info, mileage,
49
+ alerts, active, search).
50
+ - `LOCATE` controla el único endpoint que **dispara un ping on-demand al
51
+ dispositivo** (`POST /gps-provider/devices/:imei/locate`), que consume cuota
52
+ del proveedor. Tiene sentido restringirlo aparte.
53
+
54
+ ## Mapeo endpoint → permiso
55
+
56
+ | Controller / Método | HTTP | Permiso |
57
+ |---|---|---|
58
+ | `DealerGpsConfigController.create` | `POST /gps-provider/config` | `GPS_PROVIDER.CONFIG.OPERATIONS.CREATE` |
59
+ | `DealerGpsConfigController.findAllByDealer` | `GET /gps-provider/config` | `GPS_PROVIDER.CONFIG.OPERATIONS.VIEW` |
60
+ | `DealerGpsConfigController.findById` | `GET /gps-provider/config/:configId` | `GPS_PROVIDER.CONFIG.OPERATIONS.VIEW` |
61
+ | `DealerGpsConfigController.update` | `PUT /gps-provider/config/:configId` | `GPS_PROVIDER.CONFIG.OPERATIONS.UPDATE` |
62
+ | `DealerGpsConfigController.delete` | `DELETE /gps-provider/config/:configId` | `GPS_PROVIDER.CONFIG.OPERATIONS.DELETE` |
63
+ | `GpsDeviceController.findByImei` | `GET /gps-provider/devices/search` | `GPS_PROVIDER.DEVICE.OPERATIONS.VIEW` |
64
+ | `GpsDeviceController.getDeviceLocation` | `GET /gps-provider/devices/:imei/location` | `GPS_PROVIDER.DEVICE.OPERATIONS.VIEW` |
65
+ | `GpsDeviceController.locateDeviceNow` | `POST /gps-provider/devices/:imei/locate` | `GPS_PROVIDER.DEVICE.OPERATIONS.LOCATE` |
66
+ | `GpsDeviceController.getDeviceHistory` | `GET /gps-provider/devices/:imei/history` | `GPS_PROVIDER.DEVICE.OPERATIONS.VIEW` |
67
+ | `GpsDeviceController.getDeviceStatus` | `GET /gps-provider/devices/:imei/status` | `GPS_PROVIDER.DEVICE.OPERATIONS.VIEW` |
68
+ | `GpsDeviceController.getDeviceInfo` | `GET /gps-provider/devices/:imei/info` | `GPS_PROVIDER.DEVICE.OPERATIONS.VIEW` |
69
+ | `GpsDeviceController.getDeviceMileage` | `GET /gps-provider/devices/:imei/mileage` | `GPS_PROVIDER.DEVICE.OPERATIONS.VIEW` |
70
+ | `GpsDeviceController.getDeviceAlerts` | `GET /gps-provider/devices/:imei/alerts` | `GPS_PROVIDER.DEVICE.OPERATIONS.VIEW` |
71
+ | `GpsDeviceController.isDeviceActive` | `GET /gps-provider/devices/:imei/active` | `GPS_PROVIDER.DEVICE.OPERATIONS.VIEW` |
72
+
73
+ ## Estado anterior (qué se reemplaza)
74
+
75
+ Antes de esta integración, los endpoints del módulo dependían de permisos
76
+ prestados o no validaban:
77
+
78
+ - `POST/PUT /gps-provider/config` usaba `DEALER.OPERATIONS.UPDATE`.
79
+ - `DELETE /gps-provider/config/:id` usaba `DEALER.OPERATIONS.DELETE`.
80
+ - `GET /gps-provider/config` y `GET /gps-provider/config/:id` **no validaban
81
+ permiso alguno** (sólo JWT + filtro por `dealerId`).
82
+ - Los 9 endpoints de `GpsDeviceController` usaban `CAR.GPS.OPERATIONS.VIEW`
83
+ (prestado del módulo `car`), sin distinguir `locate` de lecturas pasivas.
84
+
85
+ ## Pasos de release
86
+
87
+ 1. **Repo del paquete `@telos-dev-team/dealernode-permissions`**: pegar el
88
+ bloque `GPS_PROVIDER` en `src/permissions.ts`, abrir PR, bumpear versión
89
+ (minor: `1.x.0`), publicar.
90
+ 2. **dealernode-backend**:
91
+ - `npm install @telos-dev-team/dealernode-permissions@<nueva-versión>` y
92
+ commitear `package.json` + lockfile.
93
+ - Aplicar los reemplazos en commands y queries del módulo gps-provider
94
+ (los 14 endpoints, ver tabla de arriba).
95
+ 3. **Deploy**.
96
+ 4. **Post-deploy**: correr `npm run sync:permissions` contra el ambiente para
97
+ crear los 6 permisos nuevos en la tabla `permission`. El script es
98
+ idempotente y debe imprimir `6 created, 0 deleted`.
99
+ 5. **Operativo**: asignar los nuevos permisos a los roles correspondientes
100
+ (super_admin, dealer_admin, manager según política). No se hace por código.
101
+
102
+ ## Notas
103
+
104
+ - No se elimina ningún permiso existente; los `CAR.GPS.OPERATIONS.*` y
105
+ `DEAL.GPS.OPERATIONS.*` siguen siendo válidos para sus propios módulos
106
+ (`car`/`deal`). Sólo se deja de **reusarlos** desde `gps-provider`.
107
+ - Si en el futuro hace falta granularidad adicional para device (p. ej.
108
+ separar `VIEW_HISTORY` o `VIEW_ALERTS`), se agrega como una nueva acción
109
+ bajo `GPS_PROVIDER.DEVICE.OPERATIONS` sin romper compatibilidad.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@telos-dev-team/dealernode-permissions",
3
- "version": "1.0.7",
3
+ "version": "1.1.2",
4
4
  "description": "Shared permissions constants for dealernode projects",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -792,13 +792,13 @@ export const PERMISSIONS = {
792
792
  },
793
793
 
794
794
  // ============================================
795
- // FAILED_ACTION
795
+ // AUTOMATIC_ACTION
796
796
  // ============================================
797
- FAILED_ACTION: {
797
+ AUTOMATIC_ACTION: {
798
798
  OPERATIONS: {
799
- VIEW: 'failed_action.operations.view',
800
- DELETE: 'failed_action.operations.delete',
801
- EXECUTE: 'failed_action.operations.execute',
799
+ VIEW: 'automatic_action.operations.view',
800
+ DELETE: 'automatic_action.operations.delete',
801
+ EXECUTE: 'automatic_action.operations.execute',
802
802
  },
803
803
  },
804
804
 
@@ -811,6 +811,26 @@ export const PERMISSIONS = {
811
811
  UPDATE: 'calendar.operations.update',
812
812
  },
813
813
  },
814
+
815
+ // ============================================
816
+ // GPS PROVIDER
817
+ // ============================================
818
+ GPS_PROVIDER: {
819
+ CONFIG: {
820
+ OPERATIONS: {
821
+ CREATE: 'gps-provider.config.operations.create',
822
+ VIEW: 'gps-provider.config.operations.view',
823
+ UPDATE: 'gps-provider.config.operations.update',
824
+ DELETE: 'gps-provider.config.operations.delete',
825
+ },
826
+ },
827
+ DEVICE: {
828
+ OPERATIONS: {
829
+ VIEW: 'gps-provider.device.operations.view',
830
+ LOCATE: 'gps-provider.device.operations.locate',
831
+ },
832
+ },
833
+ },
814
834
  } as const;
815
835
 
816
836
  export type Permission = typeof PERMISSIONS;