@tmlmobilidade/interfaces 20260720.2249.10 → 20260723.1350.16

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.
Files changed (64) hide show
  1. package/dist/common/index.d.ts +0 -1
  2. package/dist/common/index.js +0 -1
  3. package/dist/interfaces/index.d.ts +0 -8
  4. package/dist/interfaces/index.js +0 -8
  5. package/dist/interfaces/rides/index.d.ts +0 -5
  6. package/dist/interfaces/rides/index.js +0 -5
  7. package/dist/interfaces/rides/pipelines.d.ts +1 -1
  8. package/dist/interfaces/rides/pipelines.js +3 -3
  9. package/dist/interfaces/simplified-apex/index.d.ts +0 -2
  10. package/dist/interfaces/simplified-apex/index.js +0 -2
  11. package/dist/interfaces/vehicle-events/simplified-vehicle-events.d.ts +1 -1
  12. package/package.json +3 -2
  13. package/dist/common/mongo-transaction.d.ts +0 -25
  14. package/dist/common/mongo-transaction.js +0 -61
  15. package/dist/interfaces/alerts/alerts.d.ts +0 -124
  16. package/dist/interfaces/alerts/alerts.js +0 -50
  17. package/dist/interfaces/alerts/index.d.ts +0 -1
  18. package/dist/interfaces/alerts/index.js +0 -1
  19. package/dist/interfaces/file-exports/file-exports.d.ts +0 -20
  20. package/dist/interfaces/file-exports/file-exports.js +0 -47
  21. package/dist/interfaces/file-exports/index.d.ts +0 -1
  22. package/dist/interfaces/file-exports/index.js +0 -1
  23. package/dist/interfaces/files/files.d.ts +0 -63
  24. package/dist/interfaces/files/files.js +0 -198
  25. package/dist/interfaces/files/index.d.ts +0 -1
  26. package/dist/interfaces/files/index.js +0 -1
  27. package/dist/interfaces/gtfs-validations/gtfs-validations.d.ts +0 -71
  28. package/dist/interfaces/gtfs-validations/gtfs-validations.js +0 -40
  29. package/dist/interfaces/gtfs-validations/index.d.ts +0 -1
  30. package/dist/interfaces/gtfs-validations/index.js +0 -1
  31. package/dist/interfaces/pcgidb/index.d.ts +0 -3
  32. package/dist/interfaces/pcgidb/index.js +0 -3
  33. package/dist/interfaces/pcgidb/pcgidb-legacy.d.ts +0 -21
  34. package/dist/interfaces/pcgidb/pcgidb-legacy.js +0 -82
  35. package/dist/interfaces/pcgidb/pcgidb-ticketing.d.ts +0 -20
  36. package/dist/interfaces/pcgidb/pcgidb-ticketing.js +0 -81
  37. package/dist/interfaces/pcgidb/pcgidb-validations.d.ts +0 -21
  38. package/dist/interfaces/pcgidb/pcgidb-validations.js +0 -84
  39. package/dist/interfaces/plans/index.d.ts +0 -1
  40. package/dist/interfaces/plans/index.js +0 -1
  41. package/dist/interfaces/plans/plans.d.ts +0 -83
  42. package/dist/interfaces/plans/plans.js +0 -41
  43. package/dist/interfaces/rides/hashed-patterns.d.ts +0 -16
  44. package/dist/interfaces/rides/hashed-patterns.js +0 -35
  45. package/dist/interfaces/rides/hashed-shapes.d.ts +0 -16
  46. package/dist/interfaces/rides/hashed-shapes.js +0 -34
  47. package/dist/interfaces/rides/hashed-trips.d.ts +0 -16
  48. package/dist/interfaces/rides/hashed-trips.js +0 -35
  49. package/dist/interfaces/rides/ride-acceptances.d.ts +0 -23
  50. package/dist/interfaces/rides/ride-acceptances.js +0 -85
  51. package/dist/interfaces/rides/rides.d.ts +0 -922
  52. package/dist/interfaces/rides/rides.js +0 -107
  53. package/dist/interfaces/simplified-apex/simplified-apex-inspection-decisions.d.ts +0 -13
  54. package/dist/interfaces/simplified-apex/simplified-apex-inspection-decisions.js +0 -36
  55. package/dist/interfaces/simplified-apex/simplified-apex-inspections.d.ts +0 -13
  56. package/dist/interfaces/simplified-apex/simplified-apex-inspections.js +0 -36
  57. package/dist/interfaces/stops/index.d.ts +0 -1
  58. package/dist/interfaces/stops/index.js +0 -1
  59. package/dist/interfaces/stops/stops.d.ts +0 -289
  60. package/dist/interfaces/stops/stops.js +0 -105
  61. package/dist/interfaces/vehicles/index.d.ts +0 -1
  62. package/dist/interfaces/vehicles/index.js +0 -1
  63. package/dist/interfaces/vehicles/vehicles.d.ts +0 -16
  64. package/dist/interfaces/vehicles/vehicles.js +0 -34
@@ -1,4 +1,3 @@
1
1
  export * from './aggregation-pipeline.js';
2
2
  export * from './enrich-user-refs.js';
3
3
  export * from './mongo-collection.js';
4
- export * from './mongo-transaction.js';
@@ -1,4 +1,3 @@
1
1
  export * from './aggregation-pipeline.js';
2
2
  export * from './enrich-user-refs.js';
3
3
  export * from './mongo-collection.js';
4
- export * from './mongo-transaction.js';
@@ -1,16 +1,8 @@
1
- export * from './alerts/index.js';
2
- export * from './file-exports/index.js';
3
- export * from './files/index.js';
4
- export * from './gtfs-validations/index.js';
5
1
  export * from './locations/index.js';
6
2
  export * from './metrics/index.js';
7
3
  export * from './notifications/index.js';
8
- export * from './pcgidb/index.js';
9
- export * from './plans/index.js';
10
4
  export * from './proposed-changes/index.js';
11
5
  export * from './rides/index.js';
12
6
  export * from './sams/index.js';
13
7
  export * from './simplified-apex/index.js';
14
- export * from './stops/index.js';
15
8
  export * from './vehicle-events/index.js';
16
- export * from './vehicles/index.js';
@@ -1,16 +1,8 @@
1
- export * from './alerts/index.js';
2
- export * from './file-exports/index.js';
3
- export * from './files/index.js';
4
- export * from './gtfs-validations/index.js';
5
1
  export * from './locations/index.js';
6
2
  export * from './metrics/index.js';
7
3
  export * from './notifications/index.js';
8
- export * from './pcgidb/index.js';
9
- export * from './plans/index.js';
10
4
  export * from './proposed-changes/index.js';
11
5
  export * from './rides/index.js';
12
6
  export * from './sams/index.js';
13
7
  export * from './simplified-apex/index.js';
14
- export * from './stops/index.js';
15
8
  export * from './vehicle-events/index.js';
16
- export * from './vehicles/index.js';
@@ -1,6 +1 @@
1
- export * from './hashed-patterns.js';
2
- export * from './hashed-shapes.js';
3
- export * from './hashed-trips.js';
4
1
  export * from './pipelines.js';
5
- export * from './ride-acceptances.js';
6
- export * from './rides.js';
@@ -1,6 +1 @@
1
- export * from './hashed-patterns.js';
2
- export * from './hashed-shapes.js';
3
- export * from './hashed-trips.js';
4
1
  export * from './pipelines.js';
5
- export * from './ride-acceptances.js';
6
- export * from './rides.js';
@@ -101,7 +101,7 @@ type RidesPipelineFilter = OneOrTheOther<DatesRange, OperationalDateRange> & {
101
101
  seen_statuses?: SeenStatus[];
102
102
  stop_ids?: string[];
103
103
  ticketing_status?: TicketingStatus[];
104
- vehicle_ids?: number[];
104
+ vehicle_ids?: string[];
105
105
  };
106
106
  /**
107
107
  * Creates MongoDB aggregation pipeline stages to filter and process ride data.
@@ -368,8 +368,8 @@ function buildSearchPipeline(filter) {
368
368
  if (vehicleMatch) {
369
369
  const vehicleIDs = vehicleMatch[1]
370
370
  .split(',')
371
- .map(id => Number(id.trim()))
372
- .filter(id => !isNaN(id));
371
+ .map(id => id.trim())
372
+ .filter(Boolean);
373
373
  if (vehicleIDs.length > 0) {
374
374
  pipeline.push({ $match: { vehicle_ids: { $in: vehicleIDs } } });
375
375
  }
@@ -420,7 +420,7 @@ export function ridesBatchAggregationPipeline({ ...filter }) {
420
420
  pipeline.push({ $sort: { start_time_scheduled: 1 } });
421
421
  // Stage 3: Filter by line IDs if provided
422
422
  if (filter.line_ids?.length)
423
- pipeline.push({ $match: { line_id: { $in: filter.line_ids.map(id => Number(id)) } } });
423
+ pipeline.push({ $match: { line_id: { $in: filter.line_ids } } });
424
424
  // Stage 4: Search by term routing and selective fallback regex
425
425
  pipeline.push(...buildSearchPipeline(filter));
426
426
  // Stage 5: Search by vehicle IDs from search field if provided (legacy support)
@@ -1,5 +1,3 @@
1
- export * from './simplified-apex-inspection-decisions.js';
2
- export * from './simplified-apex-inspections.js';
3
1
  export * from './simplified-apex-locations.js';
4
2
  export * from './simplified-apex-on-board-refunds.js';
5
3
  export * from './simplified-apex-on-board-sales.js';
@@ -1,5 +1,3 @@
1
- export * from './simplified-apex-inspection-decisions.js';
2
- export * from './simplified-apex-inspections.js';
3
1
  export * from './simplified-apex-locations.js';
4
2
  export * from './simplified-apex-on-board-refunds.js';
5
3
  export * from './simplified-apex-on-board-sales.js';
@@ -1,5 +1,5 @@
1
1
  import { MongoCollectionClass } from '../../common/mongo-collection.js';
2
- import { type SimplifiedVehicleEvent } from '@tmlmobilidade/types';
2
+ import { type SimplifiedVehicleEvent } from '@tmlmobilidade/go-types-vehicle-events';
3
3
  import { type IndexDescription } from 'mongodb';
4
4
  declare class SimplifiedVehicleEventsClass extends MongoCollectionClass<SimplifiedVehicleEvent, SimplifiedVehicleEvent, SimplifiedVehicleEvent> {
5
5
  private static _instance;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tmlmobilidade/interfaces",
3
- "version": "20260720.2249.10",
3
+ "version": "20260723.1350.16",
4
4
  "author": {
5
5
  "email": "iso@tmlmobilidade.pt",
6
6
  "name": "TML-ISO"
@@ -37,10 +37,11 @@
37
37
  },
38
38
  "dependencies": {
39
39
  "@tmlmobilidade/consts": "*",
40
- "@tmlmobilidade/databases": "*",
41
40
  "@tmlmobilidade/dates": "*",
42
41
  "@tmlmobilidade/files": "*",
43
42
  "@tmlmobilidade/go-interfaces-godb": "*",
43
+ "@tmlmobilidade/go-types-apex": "*",
44
+ "@tmlmobilidade/go-types-vehicle-events": "*",
44
45
  "@tmlmobilidade/logger": "*",
45
46
  "@tmlmobilidade/mongo": "*",
46
47
  "@tmlmobilidade/ssh": "*",
@@ -1,25 +0,0 @@
1
- /**
2
- * NOTE: TRANSACTIONS ARE ONLY SUPPORTED BY REPLICA SETS
3
- *
4
- * Transaction numbers are only allowed on a replica set member or mongos
5
- *
6
- * @see https://www.mongodb.com/docs/manual/core/transactions-operations/
7
- */
8
- import { MongoConnector } from '@tmlmobilidade/mongo';
9
- import { ClientSession } from 'mongodb';
10
- import { MongoCollectionClass } from './mongo-collection.js';
11
- export declare class Transaction {
12
- private mongoConnector;
13
- private session;
14
- constructor(mongoConnector: MongoConnector);
15
- abort(): Promise<void>;
16
- commit(): Promise<void>;
17
- getSession(): ClientSession;
18
- start(): Promise<void>;
19
- }
20
- export declare class TransactionManager<T extends readonly MongoCollectionClass<any, any, any>[]> {
21
- private collections;
22
- private transactions;
23
- constructor(collections: T);
24
- withTransaction<R>(callback: (collections: T, transactions: Map<MongoCollectionClass<any, any, any>, Transaction>) => Promise<R>): Promise<R>;
25
- }
@@ -1,61 +0,0 @@
1
- /**
2
- * NOTE: TRANSACTIONS ARE ONLY SUPPORTED BY REPLICA SETS
3
- *
4
- * Transaction numbers are only allowed on a replica set member or mongos
5
- *
6
- * @see https://www.mongodb.com/docs/manual/core/transactions-operations/
7
- */
8
- export class Transaction {
9
- mongoConnector;
10
- session;
11
- constructor(mongoConnector) {
12
- this.mongoConnector = mongoConnector;
13
- }
14
- async abort() {
15
- await this.session.abortTransaction();
16
- await this.session.endSession();
17
- }
18
- async commit() {
19
- await this.session.commitTransaction();
20
- await this.session.endSession();
21
- }
22
- getSession() {
23
- return this.session;
24
- }
25
- async start() {
26
- this.session = (await this.mongoConnector).client.startSession();
27
- this.session.startTransaction();
28
- }
29
- }
30
- export class TransactionManager {
31
- collections;
32
- transactions = new Map();
33
- constructor(collections) {
34
- this.collections = collections;
35
- }
36
- async withTransaction(callback) {
37
- try {
38
- // Start transactions for each collection
39
- for (const collection of this.collections) {
40
- const transaction = new Transaction(collection.getMongoConnector());
41
- await transaction.start();
42
- this.transactions.set(collection, transaction);
43
- }
44
- // Execute callback with collections and transaction map
45
- const result = await callback(this.collections, this.transactions);
46
- // If successful, commit all transactions
47
- await Promise.all(Array.from(this.transactions.values()).map(transaction => transaction.commit()));
48
- return result;
49
- }
50
- catch (error) {
51
- // If any error occurs, abort all transactions
52
- for (const transaction of this.transactions.values()) {
53
- await transaction.abort();
54
- }
55
- throw error;
56
- }
57
- finally {
58
- this.transactions.clear();
59
- }
60
- }
61
- }
@@ -1,124 +0,0 @@
1
- import { MongoCollectionClass } from '../../common/mongo-collection.js';
2
- import { type Alert, type CreateAlertDto, type UpdateAlertDto } from '@tmlmobilidade/types';
3
- import { IndexDescription } from 'mongodb';
4
- import { z } from 'zod';
5
- declare class AlertsClass extends MongoCollectionClass<Alert, CreateAlertDto, UpdateAlertDto> {
6
- private static _instance;
7
- protected createSchema: z.ZodSchema;
8
- protected updateSchema: z.ZodSchema;
9
- private constructor();
10
- static getInstance(): Promise<AlertsClass>;
11
- findByExternalId(external_id: string): Promise<import("mongodb").WithId<{
12
- _id: string;
13
- created_at: number & {
14
- __brand: "UnixTimestamp";
15
- };
16
- created_by: string | null;
17
- is_locked: boolean;
18
- updated_at: number & {
19
- __brand: "UnixTimestamp";
20
- };
21
- description: string;
22
- active_period_end_date: import("@tmlmobilidade/types").UnixTimestamp | null;
23
- active_period_start_date: number & {
24
- __brand: "UnixTimestamp";
25
- };
26
- agency_id: string;
27
- auto_texts: boolean;
28
- cause: "ACCIDENT" | "CONSTRUCTION" | "DEMONSTRATION" | "MEDICAL_EMERGENCY" | "POLICE_ACTIVITY" | "STRIKE" | "TECHNICAL_ISSUE" | "WEATHER" | "ABUSIVE_PARKING" | "DRIVER_ABSENCE" | "DRIVER_ISSUE" | "HIGH_PASSENGER_LOAD" | "NETWORK_UPDATE" | "ROAD_ISSUE" | "TRAFFIC_JAM" | "PUBLIC_DISORDER" | "VEHICLE_ISSUE";
29
- coordinates: [number, number] | null;
30
- effect: "ACCESSIBILITY_ISSUE" | "ADDITIONAL_SERVICE" | "DETOUR" | "MODIFIED_SERVICE" | "NO_SERVICE" | "REDUCED_SERVICE" | "SIGNIFICANT_DELAYS" | "STOP_MOVED" | "REALTIME_INFO_ISSUE" | "ON_BOARD_SALE_ISSUE";
31
- external_id: string | null;
32
- file_id: string | null;
33
- info_url: string | null;
34
- municipality_ids: string[];
35
- publish_end_date: import("@tmlmobilidade/types").UnixTimestamp | null;
36
- publish_start_date: import("@tmlmobilidade/types").UnixTimestamp | null;
37
- publish_status: "published" | "archived" | "draft";
38
- reference_type: "agency" | "lines" | "stops" | "rides";
39
- references: {
40
- child_ids: string[];
41
- parent_id: string;
42
- }[];
43
- title: string;
44
- user_instructions: string;
45
- updated_by?: string | undefined;
46
- }>>;
47
- findByMunicipalityId(municipality_id: string): Promise<import("mongodb").WithId<{
48
- _id: string;
49
- created_at: number & {
50
- __brand: "UnixTimestamp";
51
- };
52
- created_by: string | null;
53
- is_locked: boolean;
54
- updated_at: number & {
55
- __brand: "UnixTimestamp";
56
- };
57
- description: string;
58
- active_period_end_date: import("@tmlmobilidade/types").UnixTimestamp | null;
59
- active_period_start_date: number & {
60
- __brand: "UnixTimestamp";
61
- };
62
- agency_id: string;
63
- auto_texts: boolean;
64
- cause: "ACCIDENT" | "CONSTRUCTION" | "DEMONSTRATION" | "MEDICAL_EMERGENCY" | "POLICE_ACTIVITY" | "STRIKE" | "TECHNICAL_ISSUE" | "WEATHER" | "ABUSIVE_PARKING" | "DRIVER_ABSENCE" | "DRIVER_ISSUE" | "HIGH_PASSENGER_LOAD" | "NETWORK_UPDATE" | "ROAD_ISSUE" | "TRAFFIC_JAM" | "PUBLIC_DISORDER" | "VEHICLE_ISSUE";
65
- coordinates: [number, number] | null;
66
- effect: "ACCESSIBILITY_ISSUE" | "ADDITIONAL_SERVICE" | "DETOUR" | "MODIFIED_SERVICE" | "NO_SERVICE" | "REDUCED_SERVICE" | "SIGNIFICANT_DELAYS" | "STOP_MOVED" | "REALTIME_INFO_ISSUE" | "ON_BOARD_SALE_ISSUE";
67
- external_id: string | null;
68
- file_id: string | null;
69
- info_url: string | null;
70
- municipality_ids: string[];
71
- publish_end_date: import("@tmlmobilidade/types").UnixTimestamp | null;
72
- publish_start_date: import("@tmlmobilidade/types").UnixTimestamp | null;
73
- publish_status: "published" | "archived" | "draft";
74
- reference_type: "agency" | "lines" | "stops" | "rides";
75
- references: {
76
- child_ids: string[];
77
- parent_id: string;
78
- }[];
79
- title: string;
80
- user_instructions: string;
81
- updated_by?: string | undefined;
82
- }>[]>;
83
- findByTitle(title: string): Promise<import("mongodb").WithId<{
84
- _id: string;
85
- created_at: number & {
86
- __brand: "UnixTimestamp";
87
- };
88
- created_by: string | null;
89
- is_locked: boolean;
90
- updated_at: number & {
91
- __brand: "UnixTimestamp";
92
- };
93
- description: string;
94
- active_period_end_date: import("@tmlmobilidade/types").UnixTimestamp | null;
95
- active_period_start_date: number & {
96
- __brand: "UnixTimestamp";
97
- };
98
- agency_id: string;
99
- auto_texts: boolean;
100
- cause: "ACCIDENT" | "CONSTRUCTION" | "DEMONSTRATION" | "MEDICAL_EMERGENCY" | "POLICE_ACTIVITY" | "STRIKE" | "TECHNICAL_ISSUE" | "WEATHER" | "ABUSIVE_PARKING" | "DRIVER_ABSENCE" | "DRIVER_ISSUE" | "HIGH_PASSENGER_LOAD" | "NETWORK_UPDATE" | "ROAD_ISSUE" | "TRAFFIC_JAM" | "PUBLIC_DISORDER" | "VEHICLE_ISSUE";
101
- coordinates: [number, number] | null;
102
- effect: "ACCESSIBILITY_ISSUE" | "ADDITIONAL_SERVICE" | "DETOUR" | "MODIFIED_SERVICE" | "NO_SERVICE" | "REDUCED_SERVICE" | "SIGNIFICANT_DELAYS" | "STOP_MOVED" | "REALTIME_INFO_ISSUE" | "ON_BOARD_SALE_ISSUE";
103
- external_id: string | null;
104
- file_id: string | null;
105
- info_url: string | null;
106
- municipality_ids: string[];
107
- publish_end_date: import("@tmlmobilidade/types").UnixTimestamp | null;
108
- publish_start_date: import("@tmlmobilidade/types").UnixTimestamp | null;
109
- publish_status: "published" | "archived" | "draft";
110
- reference_type: "agency" | "lines" | "stops" | "rides";
111
- references: {
112
- child_ids: string[];
113
- parent_id: string;
114
- }[];
115
- title: string;
116
- user_instructions: string;
117
- updated_by?: string | undefined;
118
- }>>;
119
- protected getCollectionIndexes(): IndexDescription[];
120
- protected getCollectionName(): string;
121
- protected getEnvName(): string;
122
- }
123
- export declare const alerts: AlertsClass;
124
- export {};
@@ -1,50 +0,0 @@
1
- /* * */
2
- import { MongoCollectionClass } from '../../common/mongo-collection.js';
3
- import { CreateAlertSchema, UpdateAlertSchema } from '@tmlmobilidade/types';
4
- import { asyncSingletonProxy } from '@tmlmobilidade/utils';
5
- /* * */
6
- class AlertsClass extends MongoCollectionClass {
7
- static _instance;
8
- createSchema = CreateAlertSchema;
9
- updateSchema = UpdateAlertSchema;
10
- constructor() {
11
- super();
12
- }
13
- static async getInstance() {
14
- if (!AlertsClass._instance) {
15
- const instance = new AlertsClass();
16
- await instance.connect();
17
- AlertsClass._instance = instance;
18
- }
19
- return AlertsClass._instance;
20
- }
21
- async findByExternalId(external_id) {
22
- return this.mongoCollection.findOne({ external_id });
23
- }
24
- async findByMunicipalityId(municipality_id) {
25
- return this.mongoCollection.find({ municipality_ids: { $in: [municipality_id] } }).toArray();
26
- }
27
- async findByTitle(title) {
28
- return this.mongoCollection.findOne({ title });
29
- }
30
- getCollectionIndexes() {
31
- return [
32
- { background: true, key: { agency_ids: 1 } },
33
- { background: true, key: { line_ids: 1 } },
34
- { background: true, key: { municipality_ids: 1 } },
35
- { background: true, key: { route_ids: 1 } },
36
- { background: true, key: { stop_ids: 1 } },
37
- { background: true, key: { title: 1 } },
38
- { background: true, key: { active_period_end_date: -1, active_period_start_date: -1 } },
39
- { background: true, key: { publish_end_date: -1, publish_start_date: -1 } },
40
- ];
41
- }
42
- getCollectionName() {
43
- return 'alerts';
44
- }
45
- getEnvName() {
46
- return 'DATABASE_URI';
47
- }
48
- }
49
- /* * */
50
- export const alerts = asyncSingletonProxy(AlertsClass);
@@ -1 +0,0 @@
1
- export * from './alerts.js';
@@ -1 +0,0 @@
1
- export * from './alerts.js';
@@ -1,20 +0,0 @@
1
- import { MongoCollectionClass } from '../../common/mongo-collection.js';
2
- import { CreateFileExportDto, FileExport } from '@tmlmobilidade/types';
3
- import { IndexDescription } from 'mongodb';
4
- import { z } from 'zod';
5
- declare class FileExportsClass extends MongoCollectionClass<FileExport, CreateFileExportDto<any>, Partial<FileExport>> {
6
- private static _instance;
7
- protected createSchema: z.ZodSchema;
8
- protected updateSchema: z.ZodSchema;
9
- private constructor();
10
- static getInstance(): Promise<FileExportsClass>;
11
- protected getCollectionIndexes(): IndexDescription[];
12
- protected getCollectionName(): string;
13
- protected getEnvName(): string;
14
- }
15
- /**
16
- * @deprecated This class is deprecated and will be removed in the future.
17
- * Use `@tmlmobilidade/go-interfaces-godb` instead.
18
- */
19
- export declare const fileExports: FileExportsClass;
20
- export {};
@@ -1,47 +0,0 @@
1
- /* eslint-disable @typescript-eslint/no-explicit-any */
2
- /* * */
3
- import { MongoCollectionClass } from '../../common/mongo-collection.js';
4
- import { CreateFileExportSchema, UpdateFileExportSchema } from '@tmlmobilidade/types';
5
- import { asyncSingletonProxy } from '@tmlmobilidade/utils';
6
- /* * */
7
- class FileExportsClass extends MongoCollectionClass {
8
- //
9
- //
10
- //
11
- static _instance;
12
- createSchema = CreateFileExportSchema;
13
- updateSchema = UpdateFileExportSchema;
14
- constructor() {
15
- super();
16
- }
17
- static async getInstance() {
18
- if (!FileExportsClass._instance) {
19
- const instance = new FileExportsClass();
20
- await instance.connect();
21
- FileExportsClass._instance = instance;
22
- }
23
- return FileExportsClass._instance;
24
- }
25
- getCollectionIndexes() {
26
- return [
27
- { background: true, key: { file_name: 1 } },
28
- { background: true, key: { processing_status: 1 } },
29
- { background: true, key: { scope: 1 } },
30
- { background: true, key: { type: 1 } },
31
- { background: true, expireAfterSeconds: 60_000 * 4 * 60, key: { created_at: 1 } }, // 4 hours
32
- { background: true, key: { updated_at: 1 } },
33
- ];
34
- }
35
- getCollectionName() {
36
- return 'exports';
37
- }
38
- getEnvName() {
39
- return 'DATABASE_URI';
40
- }
41
- }
42
- /* * */
43
- /**
44
- * @deprecated This class is deprecated and will be removed in the future.
45
- * Use `@tmlmobilidade/go-interfaces-godb` instead.
46
- */
47
- export const fileExports = asyncSingletonProxy(FileExportsClass);
@@ -1 +0,0 @@
1
- export * from './file-exports.js';
@@ -1 +0,0 @@
1
- export * from './file-exports.js';
@@ -1,63 +0,0 @@
1
- import { MongoCollectionClass } from '../../common/mongo-collection.js';
2
- import { type CreateFileDto, type File, type UpdateFileDto } from '@tmlmobilidade/types';
3
- import { DeleteOptions, DeleteResult, FindOptions, IndexDescription, InsertOneOptions, WithId } from 'mongodb';
4
- import { Readable } from 'node:stream';
5
- import { z } from 'zod';
6
- declare class FilesClass extends MongoCollectionClass<File, CreateFileDto, UpdateFileDto> {
7
- private static _instance;
8
- protected createSchema: z.ZodSchema;
9
- protected updateSchema: z.ZodSchema;
10
- private readonly bucketName;
11
- private readonly storageService;
12
- private constructor();
13
- static getInstance(): Promise<FilesClass>;
14
- /**
15
- * Clones a file from one resource to another.
16
- * @param fileId - The unique identifier of the file in the database.
17
- * @param resourceId - The unique identifier of the resource to clone the file to.
18
- * @returns The file that was cloned.
19
- */
20
- clone(fileId: string, scope: string, resourceId: string, options?: InsertOneOptions): Promise<File>;
21
- /**
22
- * Deletes a file from the storage service and the database.
23
- * @param fileId - The unique identifier of the file in the database.
24
- * @returns The file that was deleted.
25
- */
26
- deleteById(fileId: string, options?: DeleteOptions): Promise<DeleteResult>;
27
- /**
28
- * Retrieves a file from the database and adds the signed URL to the file object.
29
- * @param file_id - The unique identifier of the file in the database.
30
- * @returns The file with the signed URL.
31
- */
32
- findById(id: string, options?: FindOptions): Promise<null | WithId<File>>;
33
- /**
34
- * Retrieves the signed URL of a file from the storage service.
35
- * @param params - Object containing either `file_id` or `key`.
36
- * @param params.file_id - The unique identifier of the file in the database.
37
- * @param params.key - The storage key of the file.
38
- * @param options - Optional options.
39
- * @returns The signed URL of the file.
40
- * @throws {Error} If neither `file_id` nor `key` is provided.
41
- * @throws {HttpException} If `file_id` is provided but the file is not found.
42
- */
43
- getFileUrl({ file_id, key }: {
44
- file_id?: string;
45
- key?: string;
46
- }, options?: FindOptions): Promise<string>;
47
- /**
48
- * Uploads a file to the storage service and inserts it into the database.
49
- * @param file - The file to upload, either as a string, buffer, or readable stream.
50
- * @param createFileDto - The file type to create.
51
- * @returns The file that was uploaded.
52
- */
53
- upload(file: Buffer | Readable | ReadableStream | string, createFileDto: CreateFileDto & {
54
- _id?: string;
55
- }, options?: InsertOneOptions & {
56
- override?: boolean;
57
- }): Promise<File>;
58
- protected getCollectionIndexes(): IndexDescription[];
59
- protected getCollectionName(): string;
60
- protected getEnvName(): string;
61
- }
62
- export declare const files: FilesClass;
63
- export {};