@tmlmobilidade/interfaces 20251031.1051.3 → 20251202.1817.5
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/{src → common}/enrich-user-refs.js +1 -2
- package/dist/common/index.d.ts +4 -0
- package/dist/common/index.js +4 -0
- package/dist/{src → common}/mongo-collection.d.ts +3 -3
- package/dist/{src → common}/mongo-collection.js +4 -3
- package/dist/{src → common}/mongo-transaction.d.ts +1 -1
- package/dist/index.d.ts +3 -6
- package/dist/index.js +3 -6
- package/dist/{src/interfaces → interfaces}/agencies/agencies.d.ts +3 -3
- package/dist/{src/interfaces → interfaces}/agencies/agencies.js +1 -1
- package/dist/{src/interfaces → interfaces}/alerts/alerts.d.ts +42 -4
- package/dist/{src/interfaces → interfaces}/alerts/alerts.js +4 -1
- package/dist/interfaces/alerts/index.d.ts +1 -0
- package/dist/interfaces/alerts/index.js +1 -0
- package/dist/interfaces/auth/roles.d.ts +240 -0
- package/dist/interfaces/auth/roles.js +69 -0
- package/dist/{src/interfaces → interfaces}/auth/sessions.d.ts +1 -1
- package/dist/{src/interfaces → interfaces}/auth/sessions.js +1 -1
- package/dist/interfaces/auth/users.d.ts +522 -0
- package/dist/interfaces/auth/users.js +118 -0
- package/dist/{src/interfaces → interfaces}/auth/verification-tokens.d.ts +2 -2
- package/dist/{src/interfaces → interfaces}/auth/verification-tokens.js +1 -1
- package/dist/{src/interfaces → interfaces}/file-exports/file-exports.d.ts +1 -1
- package/dist/{src/interfaces → interfaces}/file-exports/file-exports.js +2 -2
- package/dist/{src/interfaces → interfaces}/files/files.d.ts +1 -1
- package/dist/{src/interfaces → interfaces}/files/files.js +6 -36
- package/dist/{src/interfaces → interfaces}/gtfs-validations/gtfs-validations.d.ts +3 -3
- package/dist/{src/interfaces → interfaces}/gtfs-validations/gtfs-validations.js +1 -1
- package/dist/{src/interfaces → interfaces}/index.d.ts +1 -0
- package/dist/{src/interfaces → interfaces}/index.js +1 -0
- package/dist/interfaces/locations/index.d.ts +2 -0
- package/dist/interfaces/locations/index.js +2 -0
- package/dist/{src/interfaces → interfaces}/locations/locations.d.ts +17 -17
- package/dist/{src/interfaces → interfaces}/locations/locations.js +3 -3
- package/dist/interfaces/locations/municipalities.d.ts +13 -0
- package/dist/interfaces/locations/municipalities.js +29 -0
- package/dist/{src/interfaces → interfaces}/metrics/metrics.d.ts +1 -1
- package/dist/{src/interfaces → interfaces}/metrics/metrics.js +1 -1
- package/dist/{src/interfaces → interfaces}/notifications/notifications.d.ts +1 -1
- package/dist/{src/interfaces → interfaces}/notifications/notifications.js +5 -5
- package/dist/{src/interfaces → interfaces}/organizations/organizations.d.ts +1 -1
- package/dist/{src/interfaces → interfaces}/organizations/organizations.js +3 -3
- package/dist/interfaces/pcgidb/index.d.ts +3 -0
- package/dist/interfaces/pcgidb/index.js +3 -0
- package/dist/interfaces/pcgidb/pcgidb-legacy.d.ts +19 -0
- package/dist/interfaces/pcgidb/pcgidb-legacy.js +133 -0
- package/dist/interfaces/pcgidb/pcgidb-ticketing.d.ts +16 -0
- package/dist/interfaces/pcgidb/pcgidb-ticketing.js +127 -0
- package/dist/interfaces/pcgidb/pcgidb-validations.d.ts +17 -0
- package/dist/interfaces/pcgidb/pcgidb-validations.js +129 -0
- package/dist/{src/interfaces → interfaces}/plans/plans.d.ts +12 -6
- package/dist/{src/interfaces → interfaces}/plans/plans.js +1 -1
- package/dist/{src/interfaces → interfaces}/proposed-changes/proposed-changes.d.ts +1 -1
- package/dist/{src/interfaces → interfaces}/proposed-changes/proposed-changes.js +1 -1
- package/dist/{src/interfaces → interfaces}/rides/hashed-shapes.d.ts +1 -1
- package/dist/{src/interfaces → interfaces}/rides/hashed-shapes.js +1 -1
- package/dist/{src/interfaces → interfaces}/rides/hashed-trips.d.ts +1 -1
- package/dist/{src/interfaces → interfaces}/rides/hashed-trips.js +1 -1
- package/dist/{src/interfaces → interfaces}/rides/pipelines.d.ts +9 -9
- package/dist/{src/interfaces → interfaces}/rides/pipelines.js +20 -2
- package/dist/{src/interfaces → interfaces}/rides/ride-acceptances.d.ts +1 -1
- package/dist/{src/interfaces → interfaces}/rides/ride-acceptances.js +4 -3
- package/dist/{src/interfaces → interfaces}/rides/rides.d.ts +313 -313
- package/dist/{src/interfaces → interfaces}/rides/rides.js +1 -1
- package/dist/{src/interfaces → interfaces}/sams/sams.d.ts +1 -1
- package/dist/{src/interfaces → interfaces}/sams/sams.js +1 -1
- package/dist/{src/interfaces → interfaces}/simplified-apex/simplified-apex-inspection-decisions.d.ts +1 -1
- package/dist/{src/interfaces → interfaces}/simplified-apex/simplified-apex-inspection-decisions.js +1 -1
- package/dist/{src/interfaces → interfaces}/simplified-apex/simplified-apex-inspections.d.ts +1 -1
- package/dist/{src/interfaces → interfaces}/simplified-apex/simplified-apex-inspections.js +1 -1
- package/dist/{src/interfaces → interfaces}/simplified-apex/simplified-apex-locations.d.ts +1 -1
- package/dist/{src/interfaces → interfaces}/simplified-apex/simplified-apex-locations.js +1 -1
- package/dist/{src/interfaces → interfaces}/simplified-apex/simplified-apex-on-board-refunds.d.ts +1 -1
- package/dist/{src/interfaces → interfaces}/simplified-apex/simplified-apex-on-board-refunds.js +1 -1
- package/dist/{src/interfaces → interfaces}/simplified-apex/simplified-apex-on-board-sales.d.ts +1 -1
- package/dist/{src/interfaces → interfaces}/simplified-apex/simplified-apex-on-board-sales.js +1 -1
- package/dist/{src/interfaces → interfaces}/simplified-apex/simplified-apex-validations.d.ts +1 -1
- package/dist/{src/interfaces → interfaces}/simplified-apex/simplified-apex-validations.js +1 -1
- package/dist/{src/interfaces → interfaces}/stops/stops.d.ts +7 -7
- package/dist/{src/interfaces → interfaces}/stops/stops.js +1 -1
- package/dist/interfaces/vehicle-events/index.d.ts +1 -0
- package/dist/interfaces/vehicle-events/index.js +1 -0
- package/dist/interfaces/vehicle-events/simplified-vehicle-events.d.ts +13 -0
- package/dist/interfaces/vehicle-events/simplified-vehicle-events.js +33 -0
- package/dist/{src/interfaces → interfaces}/zones/zones.d.ts +3 -3
- package/dist/{src/interfaces → interfaces}/zones/zones.js +1 -1
- package/dist/{src/providers → providers}/auth/auth.d.ts +21 -12
- package/dist/{src/providers → providers}/auth/auth.js +71 -60
- package/dist/providers/auth/index.d.ts +1 -0
- package/dist/providers/auth/index.js +1 -0
- package/dist/providers/index.d.ts +2 -0
- package/dist/providers/index.js +2 -0
- package/dist/providers/storage/index.d.ts +3 -0
- package/dist/providers/storage/index.js +3 -0
- package/dist/{src/providers → providers}/storage/oci-storage.js +2 -1
- package/dist/{src/providers → providers}/storage/storage.factory.d.ts +2 -11
- package/dist/{src/providers → providers}/storage/storage.factory.js +0 -5
- package/package.json +25 -26
- package/dist/src/interfaces/alerts/alerts-realtime.d.ts +0 -86
- package/dist/src/interfaces/alerts/alerts-realtime.js +0 -47
- package/dist/src/interfaces/alerts/index.d.ts +0 -2
- package/dist/src/interfaces/alerts/index.js +0 -2
- package/dist/src/interfaces/auth/roles.d.ts +0 -39
- package/dist/src/interfaces/auth/roles.js +0 -42
- package/dist/src/interfaces/auth/users.d.ts +0 -107
- package/dist/src/interfaces/auth/users.js +0 -110
- package/dist/src/interfaces/locations/index.d.ts +0 -1
- package/dist/src/interfaces/locations/index.js +0 -1
- package/dist/src/interfaces/vehicle-events/index.d.ts +0 -1
- package/dist/src/interfaces/vehicle-events/index.js +0 -1
- package/dist/src/interfaces/vehicle-events/vehicle-events.d.ts +0 -13
- package/dist/src/interfaces/vehicle-events/vehicle-events.js +0 -37
- package/dist/src/providers/index.d.ts +0 -5
- package/dist/src/providers/index.js +0 -6
- package/dist/src/providers/storage/s3-storage.d.ts +0 -64
- package/dist/src/providers/storage/s3-storage.js +0 -184
- /package/dist/{src → common}/aggregation-pipeline.d.ts +0 -0
- /package/dist/{src → common}/aggregation-pipeline.js +0 -0
- /package/dist/{src → common}/enrich-user-refs.d.ts +0 -0
- /package/dist/{src → common}/mongo-transaction.js +0 -0
- /package/dist/{src/interfaces → interfaces}/agencies/index.d.ts +0 -0
- /package/dist/{src/interfaces → interfaces}/agencies/index.js +0 -0
- /package/dist/{src/interfaces → interfaces}/auth/index.d.ts +0 -0
- /package/dist/{src/interfaces → interfaces}/auth/index.js +0 -0
- /package/dist/{src/interfaces → interfaces}/file-exports/index.d.ts +0 -0
- /package/dist/{src/interfaces → interfaces}/file-exports/index.js +0 -0
- /package/dist/{src/interfaces → interfaces}/files/index.d.ts +0 -0
- /package/dist/{src/interfaces → interfaces}/files/index.js +0 -0
- /package/dist/{src/interfaces → interfaces}/gtfs-validations/index.d.ts +0 -0
- /package/dist/{src/interfaces → interfaces}/gtfs-validations/index.js +0 -0
- /package/dist/{src/interfaces → interfaces}/metrics/index.d.ts +0 -0
- /package/dist/{src/interfaces → interfaces}/metrics/index.js +0 -0
- /package/dist/{src/interfaces → interfaces}/notifications/index.d.ts +0 -0
- /package/dist/{src/interfaces → interfaces}/notifications/index.js +0 -0
- /package/dist/{src/interfaces → interfaces}/organizations/index.d.ts +0 -0
- /package/dist/{src/interfaces → interfaces}/organizations/index.js +0 -0
- /package/dist/{src/interfaces → interfaces}/plans/index.d.ts +0 -0
- /package/dist/{src/interfaces → interfaces}/plans/index.js +0 -0
- /package/dist/{src/interfaces → interfaces}/proposed-changes/index.d.ts +0 -0
- /package/dist/{src/interfaces → interfaces}/proposed-changes/index.js +0 -0
- /package/dist/{src/interfaces → interfaces}/rides/index.d.ts +0 -0
- /package/dist/{src/interfaces → interfaces}/rides/index.js +0 -0
- /package/dist/{src/interfaces → interfaces}/sams/index.d.ts +0 -0
- /package/dist/{src/interfaces → interfaces}/sams/index.js +0 -0
- /package/dist/{src/interfaces → interfaces}/simplified-apex/index.d.ts +0 -0
- /package/dist/{src/interfaces → interfaces}/simplified-apex/index.js +0 -0
- /package/dist/{src/interfaces → interfaces}/stops/index.d.ts +0 -0
- /package/dist/{src/interfaces → interfaces}/stops/index.js +0 -0
- /package/dist/{src/interfaces → interfaces}/zones/index.d.ts +0 -0
- /package/dist/{src/interfaces → interfaces}/zones/index.js +0 -0
- /package/dist/{src/providers → providers}/storage/oci-storage.d.ts +0 -0
- /package/dist/{src/providers → providers}/storage/storage.interface.d.ts +0 -0
- /package/dist/{src/providers → providers}/storage/storage.interface.js +0 -0
|
@@ -1,184 +0,0 @@
|
|
|
1
|
-
/* * */
|
|
2
|
-
import { CopyObjectCommand, CreateBucketCommand, DeleteObjectCommand, DeleteObjectsCommand, GetObjectCommand, HeadBucketCommand, HeadObjectCommand, ListObjectsV2Command, NotFound, PutObjectCommand, S3Client } from '@aws-sdk/client-s3';
|
|
3
|
-
import { getSignedUrl } from '@aws-sdk/s3-request-presigner';
|
|
4
|
-
import { mimeTypes } from '@tmlmobilidade/lib';
|
|
5
|
-
/* * */
|
|
6
|
-
export class S3StorageProvider {
|
|
7
|
-
bucketName;
|
|
8
|
-
s3Client;
|
|
9
|
-
constructor(config) {
|
|
10
|
-
this.s3Client = new S3Client({
|
|
11
|
-
credentials: {
|
|
12
|
-
accessKeyId: config.access_key_id,
|
|
13
|
-
secretAccessKey: config.secret_access_key,
|
|
14
|
-
},
|
|
15
|
-
endpoint: config.endpoint,
|
|
16
|
-
region: config.region,
|
|
17
|
-
});
|
|
18
|
-
this.bucketName = config.bucket_name;
|
|
19
|
-
}
|
|
20
|
-
/**
|
|
21
|
-
* Checks if the bucket exists and creates it if it doesn't.
|
|
22
|
-
*/
|
|
23
|
-
async checkBucket() {
|
|
24
|
-
try {
|
|
25
|
-
await this.s3Client.send(new HeadBucketCommand({ Bucket: this.bucketName }));
|
|
26
|
-
}
|
|
27
|
-
catch (error) {
|
|
28
|
-
if (error instanceof NotFound) {
|
|
29
|
-
await this.s3Client.send(new CreateBucketCommand({ Bucket: this.bucketName }));
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
/**
|
|
34
|
-
* Copies a file from one path to another.
|
|
35
|
-
* @param source - The source file path and name in S3.
|
|
36
|
-
* @param destination - The destination file path and name in S3.
|
|
37
|
-
*/
|
|
38
|
-
async copyFile(source, destination) {
|
|
39
|
-
try {
|
|
40
|
-
await this.s3Client.send(new CopyObjectCommand({
|
|
41
|
-
Bucket: this.bucketName,
|
|
42
|
-
CopySource: `${this.bucketName}/${source}`,
|
|
43
|
-
Key: destination,
|
|
44
|
-
}));
|
|
45
|
-
console.log(`File copied successfully from ${this.bucketName}/${source} to ${this.bucketName}/${destination}`);
|
|
46
|
-
}
|
|
47
|
-
catch (error) {
|
|
48
|
-
console.error('Error copying file:', error);
|
|
49
|
-
throw error;
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
/**
|
|
53
|
-
* Deletes a file from S3.
|
|
54
|
-
* @param key - The file path and name in S3.
|
|
55
|
-
*/
|
|
56
|
-
async deleteFile(key) {
|
|
57
|
-
try {
|
|
58
|
-
const command = new DeleteObjectCommand({
|
|
59
|
-
Bucket: this.bucketName,
|
|
60
|
-
Key: key,
|
|
61
|
-
});
|
|
62
|
-
await this.s3Client.send(command);
|
|
63
|
-
console.log(`File deleted successfully from ${this.bucketName}/${key}`);
|
|
64
|
-
}
|
|
65
|
-
catch (error) {
|
|
66
|
-
console.error('Error deleting file:', error);
|
|
67
|
-
throw error;
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
/**
|
|
71
|
-
* Deletes multiple files from S3.
|
|
72
|
-
* @param keys - The file paths and names in S3.
|
|
73
|
-
*/
|
|
74
|
-
async deleteFiles(keys) {
|
|
75
|
-
try {
|
|
76
|
-
const command = new DeleteObjectsCommand({
|
|
77
|
-
Bucket: this.bucketName,
|
|
78
|
-
Delete: { Objects: keys.map(key => ({ Key: key })) },
|
|
79
|
-
});
|
|
80
|
-
await this.s3Client.send(command);
|
|
81
|
-
}
|
|
82
|
-
catch (error) {
|
|
83
|
-
console.error('Error deleting files:', error);
|
|
84
|
-
throw error;
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
/**
|
|
88
|
-
* Downloads a file from S3.
|
|
89
|
-
* @param key - The file path and name in S3.
|
|
90
|
-
* @returns The file as a readable stream.
|
|
91
|
-
*/
|
|
92
|
-
async downloadFile(key) {
|
|
93
|
-
try {
|
|
94
|
-
const command = new GetObjectCommand({
|
|
95
|
-
Bucket: this.bucketName,
|
|
96
|
-
Key: key,
|
|
97
|
-
});
|
|
98
|
-
const response = await this.s3Client.send(command);
|
|
99
|
-
if (!response.Body) {
|
|
100
|
-
throw new Error(`Failed to download file: ${key} does not exist.`);
|
|
101
|
-
}
|
|
102
|
-
return response.Body;
|
|
103
|
-
}
|
|
104
|
-
catch (error) {
|
|
105
|
-
console.error('Error downloading file:', error);
|
|
106
|
-
throw error;
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
/**
|
|
110
|
-
* Checks if a file exists in S3.
|
|
111
|
-
* @param key - The file path and name in S3.
|
|
112
|
-
* @returns True if the file exists, false otherwise.
|
|
113
|
-
*/
|
|
114
|
-
async fileExists(key) {
|
|
115
|
-
try {
|
|
116
|
-
const command = new HeadObjectCommand({ Bucket: this.bucketName, Key: key });
|
|
117
|
-
await this.s3Client.send(command);
|
|
118
|
-
return true;
|
|
119
|
-
}
|
|
120
|
-
catch (error) {
|
|
121
|
-
if (error instanceof NotFound) {
|
|
122
|
-
return false;
|
|
123
|
-
}
|
|
124
|
-
throw error;
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
/**
|
|
128
|
-
* Get the signed URL of a file from the storage.
|
|
129
|
-
* @param key - The file path and name in the storage.
|
|
130
|
-
* @returns The signed URL of the file.
|
|
131
|
-
*/
|
|
132
|
-
async getFileUrl(key) {
|
|
133
|
-
const command = new GetObjectCommand({
|
|
134
|
-
Bucket: this.bucketName,
|
|
135
|
-
Key: key,
|
|
136
|
-
});
|
|
137
|
-
return getSignedUrl(this.s3Client, command, {
|
|
138
|
-
expiresIn: 60 * 60 * 24, // 1 day
|
|
139
|
-
});
|
|
140
|
-
}
|
|
141
|
-
/**
|
|
142
|
-
* Lists files in an S3 bucket.
|
|
143
|
-
* @param prefix - Filter by prefix (optional).
|
|
144
|
-
* @returns Array of file keys in the bucket.
|
|
145
|
-
*/
|
|
146
|
-
async listFiles(prefix) {
|
|
147
|
-
try {
|
|
148
|
-
const command = new ListObjectsV2Command({
|
|
149
|
-
Bucket: this.bucketName,
|
|
150
|
-
Prefix: prefix,
|
|
151
|
-
});
|
|
152
|
-
const response = await this.s3Client.send(command);
|
|
153
|
-
return response.Contents ? response.Contents.map(item => item.Key || '') : [];
|
|
154
|
-
}
|
|
155
|
-
catch (error) {
|
|
156
|
-
console.error('Error listing files:', error);
|
|
157
|
-
throw error;
|
|
158
|
-
}
|
|
159
|
-
}
|
|
160
|
-
/**
|
|
161
|
-
* Uploads a file to S3.
|
|
162
|
-
* @param key - The file path and name in S3.
|
|
163
|
-
* @param body - The content to upload, either as a string, buffer, or readable stream.
|
|
164
|
-
*/
|
|
165
|
-
async uploadFile(key, body, mimeType) {
|
|
166
|
-
const isImage = mimeType === mimeTypes.png || mimeType === mimeTypes.jpg || mimeType === mimeTypes.jpeg || mimeType === mimeTypes.gif || mimeType === mimeTypes.svg;
|
|
167
|
-
try {
|
|
168
|
-
await this.checkBucket();
|
|
169
|
-
const command = new PutObjectCommand({
|
|
170
|
-
Body: body,
|
|
171
|
-
Bucket: this.bucketName,
|
|
172
|
-
ContentDisposition: isImage ? 'inline' : 'attachment',
|
|
173
|
-
ContentType: mimeType,
|
|
174
|
-
Key: key,
|
|
175
|
-
});
|
|
176
|
-
await this.s3Client.send(command);
|
|
177
|
-
console.log(`File uploaded successfully to ${this.bucketName}/${key}`);
|
|
178
|
-
}
|
|
179
|
-
catch (error) {
|
|
180
|
-
console.error('Error uploading file:', error);
|
|
181
|
-
throw error;
|
|
182
|
-
}
|
|
183
|
-
}
|
|
184
|
-
}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|