@tmlmobilidade/controllers 20260222.2136.56 → 20260223.1747.6

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.
@@ -1,5 +1,5 @@
1
1
  /* * */
2
- import { HttpException, HttpStatus } from '@tmlmobilidade/consts';
2
+ import { HttpException, HTTP_STATUS } from '@tmlmobilidade/consts';
3
3
  import { agencies } from '@tmlmobilidade/interfaces';
4
4
  /* * */
5
5
  export class AgenciesSharedController {
@@ -11,7 +11,7 @@ export class AgenciesSharedController {
11
11
  */
12
12
  static async getAll(request, reply) {
13
13
  const allAgencies = await agencies.findMany({}, { sort: { _id: 1 } });
14
- reply.send({ data: allAgencies, error: null, statusCode: HttpStatus.OK });
14
+ reply.send({ data: allAgencies, error: null, statusCode: HTTP_STATUS.OK });
15
15
  }
16
16
  /**
17
17
  * Returns an Agency by ID.
@@ -21,7 +21,7 @@ export class AgenciesSharedController {
21
21
  static async getById(request, reply) {
22
22
  const agencyData = await agencies.findById(request.params.id);
23
23
  if (!agencyData)
24
- throw new HttpException(HttpStatus.NOT_FOUND, 'Agency not found');
25
- reply.send({ data: agencyData, error: null, statusCode: HttpStatus.OK });
24
+ throw new HttpException(HTTP_STATUS.NOT_FOUND, 'Agency not found');
25
+ reply.send({ data: agencyData, error: null, statusCode: HTTP_STATUS.OK });
26
26
  }
27
27
  }
@@ -1,6 +1,6 @@
1
1
  /* * */
2
2
  import { ridesChangeStream } from './watch.js';
3
- import { HttpStatus } from '@tmlmobilidade/consts';
3
+ import { HTTP_STATUS } from '@tmlmobilidade/consts';
4
4
  import { rides, ridesBatchAggregationPipeline } from '@tmlmobilidade/interfaces';
5
5
  import { normalizeRide } from '@tmlmobilidade/normalizers';
6
6
  import { GetRidesBatchQuerySchema, PermissionCatalog } from '@tmlmobilidade/types';
@@ -23,7 +23,7 @@ export class RidesSharedController {
23
23
  // based on their permissions. If none, return an empty array.
24
24
  const ridesPermission = PermissionCatalog.get(request.permissions, scope, action);
25
25
  if (!ridesPermission['resources']?.agency_ids?.length)
26
- return reply.send({ data: [], error: null, statusCode: HttpStatus.OK });
26
+ return reply.send({ data: [], error: null, statusCode: HTTP_STATUS.OK });
27
27
  const allowAllAgencies = ridesPermission['resources'].agency_ids.includes(PermissionCatalog.ALLOW_ALL_FLAG);
28
28
  //
29
29
  // If search is provided, immediately try to find the ride by ID.
@@ -36,7 +36,7 @@ export class RidesSharedController {
36
36
  });
37
37
  if (foundRideById) {
38
38
  const normalizedRide = normalizeRide(foundRideById);
39
- return reply.send({ data: [normalizedRide], error: null, statusCode: HttpStatus.OK });
39
+ return reply.send({ data: [normalizedRide], error: null, statusCode: HTTP_STATUS.OK });
40
40
  }
41
41
  //
42
42
  // Get the rides batch using native MongoDB cursor
@@ -69,7 +69,7 @@ export class RidesSharedController {
69
69
  reply.send({
70
70
  data: ridesBatch ?? [],
71
71
  error: null,
72
- statusCode: HttpStatus.OK,
72
+ statusCode: HTTP_STATUS.OK,
73
73
  });
74
74
  //
75
75
  }
@@ -85,7 +85,7 @@ export class RidesSharedController {
85
85
  // based on their permissions. If none, return an empty array.
86
86
  const ridesPermission = PermissionCatalog.get(request.permissions, scope, action);
87
87
  if (!ridesPermission['resources']?.agency_ids?.length)
88
- return reply.send({ data: null, error: null, statusCode: HttpStatus.OK });
88
+ return reply.send({ data: null, error: null, statusCode: HTTP_STATUS.OK });
89
89
  const allowAllAgencies = ridesPermission['resources'].agency_ids.includes(PermissionCatalog.ALLOW_ALL_FLAG);
90
90
  //
91
91
  // If search is provided, immediately try to find the ride by ID.
@@ -97,7 +97,7 @@ export class RidesSharedController {
97
97
  });
98
98
  if (foundRideById) {
99
99
  const normalizedRide = normalizeRide(foundRideById);
100
- return reply.send({ data: normalizedRide, error: null, statusCode: HttpStatus.OK });
100
+ return reply.send({ data: normalizedRide, error: null, statusCode: HTTP_STATUS.OK });
101
101
  }
102
102
  //
103
103
  }
@@ -23,7 +23,7 @@
23
23
  * - Clean subscription management per client
24
24
  * - Reduced database load and network overhead
25
25
  */
26
- import { HttpStatus } from '@tmlmobilidade/consts';
26
+ import { HTTP_STATUS } from '@tmlmobilidade/consts';
27
27
  import { rides } from '@tmlmobilidade/interfaces';
28
28
  import { normalizeRide } from '@tmlmobilidade/normalizers';
29
29
  import { AsyncSingletonProxy } from '@tmlmobilidade/utils';
@@ -102,7 +102,7 @@ class RidesChangeStreamManager {
102
102
  const message = {
103
103
  data: normalizedRide,
104
104
  error: null,
105
- statusCode: HttpStatus.OK,
105
+ statusCode: HTTP_STATUS.OK,
106
106
  };
107
107
  // Publish to all subscribers via EventEmitter
108
108
  this.emitter.emit('change', message);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tmlmobilidade/controllers",
3
- "version": "20260222.2136.56",
3
+ "version": "20260223.1747.6",
4
4
  "author": {
5
5
  "email": "iso@tmlmobilidade.pt",
6
6
  "name": "TML-ISO"