@telos-dev-team/dealernode-permissions 1.0.6 → 1.1.1
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/permissions.d.ts +22 -0
- package/dist/permissions.js +28 -0
- package/gps-provider-permissions.md +109 -0
- package/package.json +1 -1
- package/src/permissions.ts +30 -0
package/dist/permissions.d.ts
CHANGED
|
@@ -717,5 +717,27 @@ export declare const PERMISSIONS: {
|
|
|
717
717
|
readonly EXECUTE: "failed_action.operations.execute";
|
|
718
718
|
};
|
|
719
719
|
};
|
|
720
|
+
readonly CALENDAR: {
|
|
721
|
+
readonly OPERATIONS: {
|
|
722
|
+
readonly VIEW: "calendar.operations.view";
|
|
723
|
+
readonly UPDATE: "calendar.operations.update";
|
|
724
|
+
};
|
|
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
|
+
};
|
|
720
742
|
};
|
|
721
743
|
export type Permission = typeof PERMISSIONS;
|
package/dist/permissions.js
CHANGED
|
@@ -783,4 +783,32 @@ exports.PERMISSIONS = {
|
|
|
783
783
|
EXECUTE: 'failed_action.operations.execute',
|
|
784
784
|
},
|
|
785
785
|
},
|
|
786
|
+
// ============================================
|
|
787
|
+
// CALENDAR
|
|
788
|
+
// ============================================
|
|
789
|
+
CALENDAR: {
|
|
790
|
+
OPERATIONS: {
|
|
791
|
+
VIEW: 'calendar.operations.view',
|
|
792
|
+
UPDATE: 'calendar.operations.update',
|
|
793
|
+
},
|
|
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
|
+
},
|
|
786
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
package/src/permissions.ts
CHANGED
|
@@ -801,6 +801,36 @@ export const PERMISSIONS = {
|
|
|
801
801
|
EXECUTE: 'failed_action.operations.execute',
|
|
802
802
|
},
|
|
803
803
|
},
|
|
804
|
+
|
|
805
|
+
// ============================================
|
|
806
|
+
// CALENDAR
|
|
807
|
+
// ============================================
|
|
808
|
+
CALENDAR: {
|
|
809
|
+
OPERATIONS: {
|
|
810
|
+
VIEW: 'calendar.operations.view',
|
|
811
|
+
UPDATE: 'calendar.operations.update',
|
|
812
|
+
},
|
|
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
|
+
},
|
|
804
834
|
} as const;
|
|
805
835
|
|
|
806
836
|
export type Permission = typeof PERMISSIONS;
|