@telos-dev-team/dealernode-permissions 1.1.56 → 1.1.58

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.
@@ -118,6 +118,27 @@ export declare const BACKOFFICE_PERMISSIONS: {
118
118
  */
119
119
  readonly CREDENTIALS: "backoffice.billing.credentials";
120
120
  };
121
+ /**
122
+ * Emails the system sent, read-only, across every dealer (dealernode-backend
123
+ * `src/email`): list them with their delivery status (sent, delivered,
124
+ * opened, bounced, spam complaint, failed) and open one to see its content
125
+ * and timeline. No MANAGE — the backoffice never sends or edits these, it
126
+ * only audits what the platform already sent.
127
+ */
128
+ readonly EMAILS: {
129
+ readonly VIEW: "backoffice.emails.view";
130
+ };
131
+ /**
132
+ * A dealer's notification configuration from the backoffice
133
+ * (dealernode-backend `dealer_notification_config`): the email addresses that
134
+ * receive payment, refund and dispute receipts, plus the payment-reminder
135
+ * lead times (first bank payment, pickup, BHPH). Not the per-type notification
136
+ * routing (`notification_routing`) — that is its own concern.
137
+ */
138
+ readonly DEALER_NOTIFICATIONS: {
139
+ readonly VIEW: "backoffice.dealer_notifications.view";
140
+ readonly MANAGE: "backoffice.dealer_notifications.manage";
141
+ };
121
142
  };
122
143
  export type BackofficePermission = typeof BACKOFFICE_PERMISSIONS;
123
144
  /**
@@ -137,10 +158,10 @@ export type BackofficePermissionId = Leaves<BackofficePermission>;
137
158
  */
138
159
  export declare const BACKOFFICE_PERMISSION_PRESETS: {
139
160
  /** Every `*.view` permission, nothing else. */
140
- readonly READ_ONLY: ("backoffice.dealers.view" | "backoffice.dealers.manage" | "backoffice.users.view" | "backoffice.users.manage" | "backoffice.permissions.manage" | "backoffice.payments.view" | "backoffice.payments.manage" | "backoffice.dealer_resources.view" | "backoffice.dealer_resources.manage" | "backoffice.catalog.view" | "backoffice.catalog.manage" | "backoffice.dealer_roles.view" | "backoffice.dealer_roles.manage" | "backoffice.dealer_members.view" | "backoffice.dealer_members.manage" | "backoffice.dealer_relationships.view" | "backoffice.dealer_relationships.manage" | "backoffice.dealer_groups.view" | "backoffice.dealer_groups.manage" | "backoffice.workflows.view" | "backoffice.workflows.manage" | "backoffice.billing.view" | "backoffice.billing.manage" | "backoffice.billing.credentials")[];
161
+ readonly READ_ONLY: ("backoffice.dealers.view" | "backoffice.dealers.manage" | "backoffice.users.view" | "backoffice.users.manage" | "backoffice.permissions.manage" | "backoffice.payments.view" | "backoffice.payments.manage" | "backoffice.dealer_resources.view" | "backoffice.dealer_resources.manage" | "backoffice.catalog.view" | "backoffice.catalog.manage" | "backoffice.dealer_roles.view" | "backoffice.dealer_roles.manage" | "backoffice.dealer_members.view" | "backoffice.dealer_members.manage" | "backoffice.dealer_relationships.view" | "backoffice.dealer_relationships.manage" | "backoffice.dealer_groups.view" | "backoffice.dealer_groups.manage" | "backoffice.workflows.view" | "backoffice.workflows.manage" | "backoffice.billing.view" | "backoffice.billing.manage" | "backoffice.billing.credentials" | "backoffice.emails.view" | "backoffice.dealer_notifications.view" | "backoffice.dealer_notifications.manage")[];
141
162
  /** Read-only plus the two areas support routinely needs to act on. */
142
- readonly SUPPORT: readonly [...("backoffice.dealers.view" | "backoffice.dealers.manage" | "backoffice.users.view" | "backoffice.users.manage" | "backoffice.permissions.manage" | "backoffice.payments.view" | "backoffice.payments.manage" | "backoffice.dealer_resources.view" | "backoffice.dealer_resources.manage" | "backoffice.catalog.view" | "backoffice.catalog.manage" | "backoffice.dealer_roles.view" | "backoffice.dealer_roles.manage" | "backoffice.dealer_members.view" | "backoffice.dealer_members.manage" | "backoffice.dealer_relationships.view" | "backoffice.dealer_relationships.manage" | "backoffice.dealer_groups.view" | "backoffice.dealer_groups.manage" | "backoffice.workflows.view" | "backoffice.workflows.manage" | "backoffice.billing.view" | "backoffice.billing.manage" | "backoffice.billing.credentials")[], "backoffice.dealers.manage", "backoffice.dealer_resources.manage"];
163
+ readonly SUPPORT: readonly [...("backoffice.dealers.view" | "backoffice.dealers.manage" | "backoffice.users.view" | "backoffice.users.manage" | "backoffice.permissions.manage" | "backoffice.payments.view" | "backoffice.payments.manage" | "backoffice.dealer_resources.view" | "backoffice.dealer_resources.manage" | "backoffice.catalog.view" | "backoffice.catalog.manage" | "backoffice.dealer_roles.view" | "backoffice.dealer_roles.manage" | "backoffice.dealer_members.view" | "backoffice.dealer_members.manage" | "backoffice.dealer_relationships.view" | "backoffice.dealer_relationships.manage" | "backoffice.dealer_groups.view" | "backoffice.dealer_groups.manage" | "backoffice.workflows.view" | "backoffice.workflows.manage" | "backoffice.billing.view" | "backoffice.billing.manage" | "backoffice.billing.credentials" | "backoffice.emails.view" | "backoffice.dealer_notifications.view" | "backoffice.dealer_notifications.manage")[], "backoffice.dealers.manage", "backoffice.dealer_resources.manage", "backoffice.dealer_relationships.manage"];
143
164
  /** Every backoffice permission. */
144
- readonly ADMIN: ("backoffice.dealers.view" | "backoffice.dealers.manage" | "backoffice.users.view" | "backoffice.users.manage" | "backoffice.permissions.manage" | "backoffice.payments.view" | "backoffice.payments.manage" | "backoffice.dealer_resources.view" | "backoffice.dealer_resources.manage" | "backoffice.catalog.view" | "backoffice.catalog.manage" | "backoffice.dealer_roles.view" | "backoffice.dealer_roles.manage" | "backoffice.dealer_members.view" | "backoffice.dealer_members.manage" | "backoffice.dealer_relationships.view" | "backoffice.dealer_relationships.manage" | "backoffice.dealer_groups.view" | "backoffice.dealer_groups.manage" | "backoffice.workflows.view" | "backoffice.workflows.manage" | "backoffice.billing.view" | "backoffice.billing.manage" | "backoffice.billing.credentials")[];
165
+ readonly ADMIN: ("backoffice.dealers.view" | "backoffice.dealers.manage" | "backoffice.users.view" | "backoffice.users.manage" | "backoffice.permissions.manage" | "backoffice.payments.view" | "backoffice.payments.manage" | "backoffice.dealer_resources.view" | "backoffice.dealer_resources.manage" | "backoffice.catalog.view" | "backoffice.catalog.manage" | "backoffice.dealer_roles.view" | "backoffice.dealer_roles.manage" | "backoffice.dealer_members.view" | "backoffice.dealer_members.manage" | "backoffice.dealer_relationships.view" | "backoffice.dealer_relationships.manage" | "backoffice.dealer_groups.view" | "backoffice.dealer_groups.manage" | "backoffice.workflows.view" | "backoffice.workflows.manage" | "backoffice.billing.view" | "backoffice.billing.manage" | "backoffice.billing.credentials" | "backoffice.emails.view" | "backoffice.dealer_notifications.view" | "backoffice.dealer_notifications.manage")[];
145
166
  };
146
167
  export {};
@@ -121,6 +121,27 @@ exports.BACKOFFICE_PERMISSIONS = {
121
121
  */
122
122
  CREDENTIALS: "backoffice.billing.credentials",
123
123
  },
124
+ /**
125
+ * Emails the system sent, read-only, across every dealer (dealernode-backend
126
+ * `src/email`): list them with their delivery status (sent, delivered,
127
+ * opened, bounced, spam complaint, failed) and open one to see its content
128
+ * and timeline. No MANAGE — the backoffice never sends or edits these, it
129
+ * only audits what the platform already sent.
130
+ */
131
+ EMAILS: {
132
+ VIEW: "backoffice.emails.view",
133
+ },
134
+ /**
135
+ * A dealer's notification configuration from the backoffice
136
+ * (dealernode-backend `dealer_notification_config`): the email addresses that
137
+ * receive payment, refund and dispute receipts, plus the payment-reminder
138
+ * lead times (first bank payment, pickup, BHPH). Not the per-type notification
139
+ * routing (`notification_routing`) — that is its own concern.
140
+ */
141
+ DEALER_NOTIFICATIONS: {
142
+ VIEW: "backoffice.dealer_notifications.view",
143
+ MANAGE: "backoffice.dealer_notifications.manage",
144
+ },
124
145
  };
125
146
  function flatten(node) {
126
147
  const values = [];
@@ -151,6 +172,7 @@ exports.BACKOFFICE_PERMISSION_PRESETS = {
151
172
  ...READ_ONLY_BACKOFFICE_PERMISSIONS,
152
173
  exports.BACKOFFICE_PERMISSIONS.DEALERS.MANAGE,
153
174
  exports.BACKOFFICE_PERMISSIONS.DEALER_RESOURCES.MANAGE,
175
+ exports.BACKOFFICE_PERMISSIONS.DEALER_RELATIONSHIPS.MANAGE,
154
176
  ],
155
177
  /** Every backoffice permission. */
156
178
  ADMIN: ALL_BACKOFFICE_PERMISSIONS,
@@ -632,12 +632,6 @@ export declare const PERMISSIONS: {
632
632
  readonly DEALER_RELATIONSHIP: {
633
633
  readonly OPERATIONS: {
634
634
  readonly VIEW: "dealer_relationship.operations.view";
635
- readonly CREATE: "dealer_relationship.operations.create";
636
- readonly APPROVE: "dealer_relationship.operations.approve";
637
- readonly REJECT: "dealer_relationship.operations.reject";
638
- readonly REVOKE: "dealer_relationship.operations.revoke";
639
- readonly SUSPEND: "dealer_relationship.operations.suspend";
640
- readonly REACTIVATE: "dealer_relationship.operations.reactivate";
641
635
  };
642
636
  readonly RESOURCE: {
643
637
  readonly VIEW_INVENTORY: "dealer_relationship.resource.view_inventory";
@@ -654,12 +648,6 @@ export declare const PERMISSIONS: {
654
648
  readonly VIEW_PLATES: "dealer_relationship.resource.view_plates";
655
649
  readonly VIEW_ARBITRATIONS: "dealer_relationship.resource.view_arbitrations";
656
650
  };
657
- readonly PERMISSION: {
658
- readonly REQUEST: "dealer_relationship.permission.request";
659
- readonly APPROVE: "dealer_relationship.permission.approve";
660
- readonly REJECT: "dealer_relationship.permission.reject";
661
- readonly REVOKE: "dealer_relationship.permission.revoke";
662
- };
663
651
  };
664
652
  readonly DEALER_GROUP: {
665
653
  readonly OPERATIONS: {
@@ -692,12 +692,6 @@ exports.PERMISSIONS = {
692
692
  DEALER_RELATIONSHIP: {
693
693
  OPERATIONS: {
694
694
  VIEW: "dealer_relationship.operations.view",
695
- CREATE: "dealer_relationship.operations.create",
696
- APPROVE: "dealer_relationship.operations.approve",
697
- REJECT: "dealer_relationship.operations.reject",
698
- REVOKE: "dealer_relationship.operations.revoke",
699
- SUSPEND: "dealer_relationship.operations.suspend",
700
- REACTIVATE: "dealer_relationship.operations.reactivate",
701
695
  },
702
696
  RESOURCE: {
703
697
  VIEW_INVENTORY: "dealer_relationship.resource.view_inventory",
@@ -714,12 +708,6 @@ exports.PERMISSIONS = {
714
708
  VIEW_PLATES: "dealer_relationship.resource.view_plates",
715
709
  VIEW_ARBITRATIONS: "dealer_relationship.resource.view_arbitrations",
716
710
  },
717
- PERMISSION: {
718
- REQUEST: "dealer_relationship.permission.request",
719
- APPROVE: "dealer_relationship.permission.approve",
720
- REJECT: "dealer_relationship.permission.reject",
721
- REVOKE: "dealer_relationship.permission.revoke",
722
- },
723
711
  },
724
712
  // ============================================
725
713
  // DEALER GROUP
package/package.json CHANGED
@@ -1,9 +1,12 @@
1
1
  {
2
2
  "name": "@telos-dev-team/dealernode-permissions",
3
- "version": "1.1.56",
3
+ "version": "1.1.58",
4
4
  "description": "Shared permissions constants for dealernode projects",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
7
+ "files": [
8
+ "dist"
9
+ ],
7
10
  "publishConfig": {
8
11
  "access": "public"
9
12
  },
@@ -1,37 +0,0 @@
1
- name: Publish to npm
2
-
3
- on:
4
- push:
5
- branches: [main]
6
-
7
- jobs:
8
- publish:
9
- runs-on: ubuntu-latest
10
- permissions:
11
- contents: write
12
-
13
- steps:
14
- - uses: actions/checkout@v4
15
- with:
16
- fetch-depth: 0
17
-
18
- - uses: actions/setup-node@v4
19
- with:
20
- node-version: 22
21
- registry-url: https://registry.npmjs.org
22
-
23
- - run: npm ci
24
-
25
- - name: Bump version and publish
26
- env:
27
- NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
28
- run: |
29
- git config user.name "github-actions[bot]"
30
- git config user.email "github-actions[bot]@users.noreply.github.com"
31
- npm version patch --no-git-tag-version
32
- VERSION=$(node -p "require('./package.json').version")
33
- npm publish
34
- git add package.json package-lock.json
35
- git commit -m "chore: release v${VERSION}"
36
- git tag "v${VERSION}"
37
- git push && git push --tags
@@ -1,109 +0,0 @@
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.
@@ -1,168 +0,0 @@
1
- /**
2
- * Backoffice realm — a separate, flat catalog from `PERMISSIONS`.
3
- *
4
- * The backoffice (internal admin tool) authorizes against its own
5
- * `backoffice_user_permission` table, never against a dealer's `user_dealer`
6
- * membership. Its permission ids share the `permission` table in the
7
- * database with the product catalog above, but the two are otherwise
8
- * unrelated: a `backoffice.*` id is never assignable to a dealer role, and a
9
- * product id is never assignable to a backoffice user. Keeping them as a
10
- * separate export (instead of a top-level key inside `PERMISSIONS`) makes
11
- * that boundary explicit and lets each side filter the other out of its own
12
- * catalog listing.
13
- */
14
- export const BACKOFFICE_PERMISSIONS = {
15
- DEALERS: {
16
- VIEW: "backoffice.dealers.view",
17
- MANAGE: "backoffice.dealers.manage",
18
- },
19
- USERS: {
20
- VIEW: "backoffice.users.view",
21
- MANAGE: "backoffice.users.manage",
22
- },
23
- /**
24
- * Split out from USERS.MANAGE on purpose: granting/revoking a backoffice
25
- * user's permissions is more sensitive than editing their name or email,
26
- * and folding both into one permission let any admin escalate themselves
27
- * to anything. No VIEW counterpart — reading a user's permissions is
28
- * already covered by USERS.VIEW (GET /backoffice/users/:id).
29
- */
30
- PERMISSIONS: {
31
- MANAGE: "backoffice.permissions.manage",
32
- },
33
- PAYMENTS: {
34
- VIEW: "backoffice.payments.view",
35
- MANAGE: "backoffice.payments.manage",
36
- },
37
- /**
38
- * Management of per-dealer resources from the backoffice — catalogs each
39
- * dealer otherwise manages under Company → Resources: bank, color, floor,
40
- * purchase_source, agency, plate_origin, wholesale_target,
41
- * commission_category, deal_actor_type, title_status,
42
- * car_extra_category/type, deal_extra_category/type, arbitration_issue_type.
43
- * One permission per area (same grain as DEALERS/USERS/PAYMENTS), not one
44
- * per entity — 15 very similar entities, one permission each would be
45
- * noise with no real granularity benefit.
46
- */
47
- DEALER_RESOURCES: {
48
- VIEW: "backoffice.dealer_resources.view",
49
- MANAGE: "backoffice.dealer_resources.manage",
50
- },
51
- /** Global vehicle catalog: brand/model/trim/style/fuel-type/title-brand. */
52
- CATALOG: {
53
- VIEW: "backoffice.catalog.view",
54
- MANAGE: "backoffice.catalog.manage",
55
- },
56
- /**
57
- * Management of a dealer's roles and permissions from the backoffice —
58
- * roles, role↔permission, role↔user and direct user↔permission grants.
59
- * Its own permission (not DEALER_RESOURCES): roles/permissions govern a
60
- * dealer's whole RBAC, more sensitive than a catalog of colors/banks.
61
- */
62
- DEALER_ROLES: {
63
- VIEW: "backoffice.dealer_roles.view",
64
- MANAGE: "backoffice.dealer_roles.manage",
65
- },
66
- /**
67
- * Members of any dealer from the backoffice: list them, view one, and
68
- * replace its roles and deal actor types. Its own permission (not
69
- * DEALER_ROLES): who may edit a dealer's role catalog is not the same as who
70
- * may re-assign people to those roles. Never touches a member's direct
71
- * permissions.
72
- */
73
- DEALER_MEMBERS: {
74
- VIEW: "backoffice.dealer_members.view",
75
- MANAGE: "backoffice.dealer_members.manage",
76
- },
77
- /**
78
- * Dealer-to-dealer relationships of any dealer from the backoffice: list them
79
- * and (MANAGE) create/revoke/suspend/reactivate a relationship and set the
80
- * capabilities one dealer grants another. Management only — the product keeps
81
- * the runtime read-path that resolves cross-dealer access per request.
82
- */
83
- DEALER_RELATIONSHIPS: {
84
- VIEW: "backoffice.dealer_relationships.view",
85
- MANAGE: "backoffice.dealer_relationships.manage",
86
- },
87
- /**
88
- * Dealer groups from the backoffice: list them and (MANAGE) create/update/
89
- * delete a group, add/remove members, set the group permission contract,
90
- * manage group user assignments and propagate roles across the group.
91
- */
92
- DEALER_GROUPS: {
93
- VIEW: "backoffice.dealer_groups.view",
94
- MANAGE: "backoffice.dealer_groups.manage",
95
- },
96
- /**
97
- * Workflows of any dealer from the backoffice: list them, open the editor,
98
- * and (MANAGE) create, edit, version and test them, including the AI
99
- * assistant. Never decides which workflows run in production: that is
100
- * assigned by each dealer from the product.
101
- */
102
- WORKFLOWS: {
103
- VIEW: "backoffice.workflows.view",
104
- MANAGE: "backoffice.workflows.manage",
105
- },
106
- /**
107
- * Platform-to-dealer billing (dealernode-backend `src/billing`): plans,
108
- * global charge provider, dealer subscriptions, cards and invoices. Not
109
- * PAYMENTS, which is what a dealer charges its own buyers.
110
- */
111
- BILLING: {
112
- VIEW: "backoffice.billing.view",
113
- MANAGE: "backoffice.billing.manage",
114
- /**
115
- * Load and change the platform's merchant credentials on each charge
116
- * provider. Separate from MANAGE because these keys move money: whoever
117
- * manages plans and subscriptions doesn't need to be able to change them.
118
- */
119
- CREDENTIALS: "backoffice.billing.credentials",
120
- },
121
- } as const;
122
-
123
- export type BackofficePermission = typeof BACKOFFICE_PERMISSIONS;
124
-
125
- /**
126
- * The actual union of backoffice permission id strings. `BackofficePermission`
127
- * (the type of the whole tree, mirroring `Permission` above) can't be used to
128
- * type "any single backoffice permission id" — this can.
129
- */
130
- type Leaves<T> = T extends string ? T : { [K in keyof T]: Leaves<T[K]> }[keyof T];
131
- export type BackofficePermissionId = Leaves<BackofficePermission>;
132
-
133
- function flatten(node: Record<string, unknown>): BackofficePermissionId[] {
134
- const values: BackofficePermissionId[] = [];
135
- for (const key of Object.keys(node)) {
136
- const value = node[key];
137
- if (typeof value === "string") {
138
- values.push(value as BackofficePermissionId);
139
- } else if (typeof value === "object" && value !== null) {
140
- values.push(...flatten(value as Record<string, unknown>));
141
- }
142
- }
143
- return values;
144
- }
145
-
146
- const ALL_BACKOFFICE_PERMISSIONS = flatten(BACKOFFICE_PERMISSIONS);
147
- const READ_ONLY_BACKOFFICE_PERMISSIONS = ALL_BACKOFFICE_PERMISSIONS.filter((id) =>
148
- id.endsWith(".view"),
149
- );
150
-
151
- /**
152
- * Selection presets for the permission-assignment UI. Consumers resolve
153
- * these ids against their own `permission` table rows (the DB, not this
154
- * package, owns the ULIDs) — see `GET /backoffice/permissions/backoffice`
155
- * in dealernode-backend.
156
- */
157
- export const BACKOFFICE_PERMISSION_PRESETS = {
158
- /** Every `*.view` permission, nothing else. */
159
- READ_ONLY: READ_ONLY_BACKOFFICE_PERMISSIONS,
160
- /** Read-only plus the two areas support routinely needs to act on. */
161
- SUPPORT: [
162
- ...READ_ONLY_BACKOFFICE_PERMISSIONS,
163
- BACKOFFICE_PERMISSIONS.DEALERS.MANAGE,
164
- BACKOFFICE_PERMISSIONS.DEALER_RESOURCES.MANAGE,
165
- ],
166
- /** Every backoffice permission. */
167
- ADMIN: ALL_BACKOFFICE_PERMISSIONS,
168
- } as const satisfies Record<string, readonly BackofficePermissionId[]>;
package/src/index.ts DELETED
@@ -1,7 +0,0 @@
1
- export { PERMISSIONS, Permission } from './permissions';
2
- export {
3
- BACKOFFICE_PERMISSIONS,
4
- BackofficePermission,
5
- BackofficePermissionId,
6
- BACKOFFICE_PERMISSION_PRESETS,
7
- } from './backoffice-permissions';