@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.
- package/dist/common/index.d.ts +0 -1
- package/dist/common/index.js +0 -1
- package/dist/interfaces/index.d.ts +0 -8
- package/dist/interfaces/index.js +0 -8
- package/dist/interfaces/rides/index.d.ts +0 -5
- package/dist/interfaces/rides/index.js +0 -5
- package/dist/interfaces/rides/pipelines.d.ts +1 -1
- package/dist/interfaces/rides/pipelines.js +3 -3
- package/dist/interfaces/simplified-apex/index.d.ts +0 -2
- package/dist/interfaces/simplified-apex/index.js +0 -2
- package/dist/interfaces/vehicle-events/simplified-vehicle-events.d.ts +1 -1
- package/package.json +3 -2
- package/dist/common/mongo-transaction.d.ts +0 -25
- package/dist/common/mongo-transaction.js +0 -61
- package/dist/interfaces/alerts/alerts.d.ts +0 -124
- package/dist/interfaces/alerts/alerts.js +0 -50
- package/dist/interfaces/alerts/index.d.ts +0 -1
- package/dist/interfaces/alerts/index.js +0 -1
- package/dist/interfaces/file-exports/file-exports.d.ts +0 -20
- package/dist/interfaces/file-exports/file-exports.js +0 -47
- package/dist/interfaces/file-exports/index.d.ts +0 -1
- package/dist/interfaces/file-exports/index.js +0 -1
- package/dist/interfaces/files/files.d.ts +0 -63
- package/dist/interfaces/files/files.js +0 -198
- package/dist/interfaces/files/index.d.ts +0 -1
- package/dist/interfaces/files/index.js +0 -1
- package/dist/interfaces/gtfs-validations/gtfs-validations.d.ts +0 -71
- package/dist/interfaces/gtfs-validations/gtfs-validations.js +0 -40
- package/dist/interfaces/gtfs-validations/index.d.ts +0 -1
- package/dist/interfaces/gtfs-validations/index.js +0 -1
- package/dist/interfaces/pcgidb/index.d.ts +0 -3
- package/dist/interfaces/pcgidb/index.js +0 -3
- package/dist/interfaces/pcgidb/pcgidb-legacy.d.ts +0 -21
- package/dist/interfaces/pcgidb/pcgidb-legacy.js +0 -82
- package/dist/interfaces/pcgidb/pcgidb-ticketing.d.ts +0 -20
- package/dist/interfaces/pcgidb/pcgidb-ticketing.js +0 -81
- package/dist/interfaces/pcgidb/pcgidb-validations.d.ts +0 -21
- package/dist/interfaces/pcgidb/pcgidb-validations.js +0 -84
- package/dist/interfaces/plans/index.d.ts +0 -1
- package/dist/interfaces/plans/index.js +0 -1
- package/dist/interfaces/plans/plans.d.ts +0 -83
- package/dist/interfaces/plans/plans.js +0 -41
- package/dist/interfaces/rides/hashed-patterns.d.ts +0 -16
- package/dist/interfaces/rides/hashed-patterns.js +0 -35
- package/dist/interfaces/rides/hashed-shapes.d.ts +0 -16
- package/dist/interfaces/rides/hashed-shapes.js +0 -34
- package/dist/interfaces/rides/hashed-trips.d.ts +0 -16
- package/dist/interfaces/rides/hashed-trips.js +0 -35
- package/dist/interfaces/rides/ride-acceptances.d.ts +0 -23
- package/dist/interfaces/rides/ride-acceptances.js +0 -85
- package/dist/interfaces/rides/rides.d.ts +0 -922
- package/dist/interfaces/rides/rides.js +0 -107
- package/dist/interfaces/simplified-apex/simplified-apex-inspection-decisions.d.ts +0 -13
- package/dist/interfaces/simplified-apex/simplified-apex-inspection-decisions.js +0 -36
- package/dist/interfaces/simplified-apex/simplified-apex-inspections.d.ts +0 -13
- package/dist/interfaces/simplified-apex/simplified-apex-inspections.js +0 -36
- package/dist/interfaces/stops/index.d.ts +0 -1
- package/dist/interfaces/stops/index.js +0 -1
- package/dist/interfaces/stops/stops.d.ts +0 -289
- package/dist/interfaces/stops/stops.js +0 -105
- package/dist/interfaces/vehicles/index.d.ts +0 -1
- package/dist/interfaces/vehicles/index.js +0 -1
- package/dist/interfaces/vehicles/vehicles.d.ts +0 -16
- package/dist/interfaces/vehicles/vehicles.js +0 -34
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
import { MongoCollectionClass } from '../../common/mongo-collection.js';
|
|
2
|
-
import { type CreatePlanDto, type Plan, type UpdatePlanDto } from '@tmlmobilidade/types';
|
|
3
|
-
import { IndexDescription } from 'mongodb';
|
|
4
|
-
import { z } from 'zod';
|
|
5
|
-
declare class PlansClass extends MongoCollectionClass<Plan, CreatePlanDto, UpdatePlanDto> {
|
|
6
|
-
private static _instance;
|
|
7
|
-
protected createSchema: z.ZodSchema;
|
|
8
|
-
protected updateSchema: z.ZodSchema;
|
|
9
|
-
private constructor();
|
|
10
|
-
static getInstance(): Promise<PlansClass>;
|
|
11
|
-
/**
|
|
12
|
-
* Finds Plan documents by agency ID.
|
|
13
|
-
*
|
|
14
|
-
* @param id - The agency ID to search for
|
|
15
|
-
* @returns A promise that resolves to an array of matching documents
|
|
16
|
-
*/
|
|
17
|
-
findByAgencyId(id: string): Promise<import("mongodb").WithId<{
|
|
18
|
-
_id: string;
|
|
19
|
-
created_at: number & {
|
|
20
|
-
__brand: "UnixTimestamp";
|
|
21
|
-
};
|
|
22
|
-
created_by: string | null;
|
|
23
|
-
is_locked: boolean;
|
|
24
|
-
updated_at: number & {
|
|
25
|
-
__brand: "UnixTimestamp";
|
|
26
|
-
};
|
|
27
|
-
gtfs_agency: {
|
|
28
|
-
agency_id: string;
|
|
29
|
-
agency_name: string;
|
|
30
|
-
agency_timezone: string;
|
|
31
|
-
agency_email?: string | null | undefined;
|
|
32
|
-
agency_fare_url?: string | null | undefined;
|
|
33
|
-
agency_lang?: string | null | undefined;
|
|
34
|
-
agency_phone?: string | null | undefined;
|
|
35
|
-
agency_url?: string | null | undefined;
|
|
36
|
-
};
|
|
37
|
-
gtfs_feed_info: {
|
|
38
|
-
feed_lang: string;
|
|
39
|
-
feed_end_date?: import("@tmlmobilidade/types").OperationalDate | null | undefined;
|
|
40
|
-
feed_start_date?: import("@tmlmobilidade/types").OperationalDate | null | undefined;
|
|
41
|
-
default_lang?: string | null | undefined;
|
|
42
|
-
feed_contact_email?: string | null | undefined;
|
|
43
|
-
feed_contact_url?: string | null | undefined;
|
|
44
|
-
feed_publisher_name?: string | null | undefined;
|
|
45
|
-
feed_publisher_url?: string | null | undefined;
|
|
46
|
-
feed_version?: string | null | undefined;
|
|
47
|
-
};
|
|
48
|
-
apex_file_id: string | null;
|
|
49
|
-
apps: {
|
|
50
|
-
controller: {
|
|
51
|
-
status: "error" | "waiting" | "processing" | "complete" | "skipped";
|
|
52
|
-
last_hash: string | null;
|
|
53
|
-
timestamp: import("@tmlmobilidade/types").UnixTimestamp | null;
|
|
54
|
-
};
|
|
55
|
-
hub_gtfs: {
|
|
56
|
-
status: "error" | "waiting" | "processing" | "complete" | "skipped";
|
|
57
|
-
last_hash: string | null;
|
|
58
|
-
timestamp: import("@tmlmobilidade/types").UnixTimestamp | null;
|
|
59
|
-
};
|
|
60
|
-
hub_schedules: {
|
|
61
|
-
status: "error" | "waiting" | "processing" | "complete" | "skipped";
|
|
62
|
-
last_hash: string | null;
|
|
63
|
-
timestamp: import("@tmlmobilidade/types").UnixTimestamp | null;
|
|
64
|
-
};
|
|
65
|
-
merger: {
|
|
66
|
-
status: "error" | "waiting" | "processing" | "complete" | "skipped";
|
|
67
|
-
last_hash: string | null;
|
|
68
|
-
timestamp: import("@tmlmobilidade/types").UnixTimestamp | null;
|
|
69
|
-
};
|
|
70
|
-
};
|
|
71
|
-
hash: string;
|
|
72
|
-
operation_file_id: string;
|
|
73
|
-
pcgi_legacy: {
|
|
74
|
-
operation_plan_id: string | null;
|
|
75
|
-
};
|
|
76
|
-
updated_by?: string | undefined;
|
|
77
|
-
}>[]>;
|
|
78
|
-
protected getCollectionIndexes(): IndexDescription[];
|
|
79
|
-
protected getCollectionName(): string;
|
|
80
|
-
protected getEnvName(): string;
|
|
81
|
-
}
|
|
82
|
-
export declare const plans: PlansClass;
|
|
83
|
-
export {};
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
/* * */
|
|
2
|
-
import { MongoCollectionClass } from '../../common/mongo-collection.js';
|
|
3
|
-
import { CreatePlanSchema, UpdatePlanSchema } from '@tmlmobilidade/types';
|
|
4
|
-
import { asyncSingletonProxy } from '@tmlmobilidade/utils';
|
|
5
|
-
/* * */
|
|
6
|
-
class PlansClass extends MongoCollectionClass {
|
|
7
|
-
static _instance;
|
|
8
|
-
createSchema = CreatePlanSchema;
|
|
9
|
-
updateSchema = UpdatePlanSchema;
|
|
10
|
-
constructor() {
|
|
11
|
-
super();
|
|
12
|
-
}
|
|
13
|
-
static async getInstance() {
|
|
14
|
-
if (!PlansClass._instance) {
|
|
15
|
-
const instance = new PlansClass();
|
|
16
|
-
await instance.connect();
|
|
17
|
-
PlansClass._instance = instance;
|
|
18
|
-
}
|
|
19
|
-
return PlansClass._instance;
|
|
20
|
-
}
|
|
21
|
-
/**
|
|
22
|
-
* Finds Plan documents by agency ID.
|
|
23
|
-
*
|
|
24
|
-
* @param id - The agency ID to search for
|
|
25
|
-
* @returns A promise that resolves to an array of matching documents
|
|
26
|
-
*/
|
|
27
|
-
async findByAgencyId(id) {
|
|
28
|
-
return this.mongoCollection.find({ agency_id: id }).toArray();
|
|
29
|
-
}
|
|
30
|
-
getCollectionIndexes() {
|
|
31
|
-
return [];
|
|
32
|
-
}
|
|
33
|
-
getCollectionName() {
|
|
34
|
-
return 'plans';
|
|
35
|
-
}
|
|
36
|
-
getEnvName() {
|
|
37
|
-
return 'DATABASE_URI';
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
/* * */
|
|
41
|
-
export const plans = asyncSingletonProxy(PlansClass);
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { MongoCollectionClass } from '../../common/mongo-collection.js';
|
|
2
|
-
import { type HashedPattern } from '@tmlmobilidade/types';
|
|
3
|
-
import { type IndexDescription } from 'mongodb';
|
|
4
|
-
import { z } from 'zod';
|
|
5
|
-
declare class HashedPatternsClass extends MongoCollectionClass<HashedPattern, HashedPattern, HashedPattern> {
|
|
6
|
-
private static _instance;
|
|
7
|
-
protected createSchema: z.ZodSchema;
|
|
8
|
-
protected updateSchema: z.ZodSchema;
|
|
9
|
-
private constructor();
|
|
10
|
-
static getInstance(): Promise<HashedPatternsClass>;
|
|
11
|
-
protected getCollectionIndexes(): IndexDescription[];
|
|
12
|
-
protected getCollectionName(): string;
|
|
13
|
-
protected getEnvName(): string;
|
|
14
|
-
}
|
|
15
|
-
export declare const hashedPatterns: HashedPatternsClass;
|
|
16
|
-
export {};
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
/* * */
|
|
2
|
-
import { MongoCollectionClass } from '../../common/mongo-collection.js';
|
|
3
|
-
import { DocumentSchema } from '@tmlmobilidade/types';
|
|
4
|
-
import { asyncSingletonProxy } from '@tmlmobilidade/utils';
|
|
5
|
-
/* * */
|
|
6
|
-
class HashedPatternsClass extends MongoCollectionClass {
|
|
7
|
-
static _instance;
|
|
8
|
-
createSchema = DocumentSchema;
|
|
9
|
-
updateSchema = DocumentSchema;
|
|
10
|
-
constructor() {
|
|
11
|
-
super();
|
|
12
|
-
}
|
|
13
|
-
static async getInstance() {
|
|
14
|
-
if (!HashedPatternsClass._instance) {
|
|
15
|
-
const instance = new HashedPatternsClass();
|
|
16
|
-
await instance.connect();
|
|
17
|
-
HashedPatternsClass._instance = instance;
|
|
18
|
-
}
|
|
19
|
-
return HashedPatternsClass._instance;
|
|
20
|
-
}
|
|
21
|
-
getCollectionIndexes() {
|
|
22
|
-
return [
|
|
23
|
-
{ background: true, key: { agency_id: 1 } },
|
|
24
|
-
{ background: true, key: { line_id: 1 } },
|
|
25
|
-
];
|
|
26
|
-
}
|
|
27
|
-
getCollectionName() {
|
|
28
|
-
return 'hashed_patterns';
|
|
29
|
-
}
|
|
30
|
-
getEnvName() {
|
|
31
|
-
return 'DATABASE_URI';
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
/* * */
|
|
35
|
-
export const hashedPatterns = asyncSingletonProxy(HashedPatternsClass);
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { MongoCollectionClass } from '../../common/mongo-collection.js';
|
|
2
|
-
import { HashedShape } from '@tmlmobilidade/types';
|
|
3
|
-
import { IndexDescription } from 'mongodb';
|
|
4
|
-
import { z } from 'zod';
|
|
5
|
-
declare class HashedShapesClass extends MongoCollectionClass<HashedShape, HashedShape, HashedShape> {
|
|
6
|
-
private static _instance;
|
|
7
|
-
protected createSchema: z.ZodSchema;
|
|
8
|
-
protected updateSchema: z.ZodSchema;
|
|
9
|
-
private constructor();
|
|
10
|
-
static getInstance(): Promise<HashedShapesClass>;
|
|
11
|
-
protected getCollectionIndexes(): IndexDescription[];
|
|
12
|
-
protected getCollectionName(): string;
|
|
13
|
-
protected getEnvName(): string;
|
|
14
|
-
}
|
|
15
|
-
export declare const hashedShapes: HashedShapesClass;
|
|
16
|
-
export {};
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
/* * */
|
|
2
|
-
import { MongoCollectionClass } from '../../common/mongo-collection.js';
|
|
3
|
-
import { DocumentSchema } from '@tmlmobilidade/types';
|
|
4
|
-
import { asyncSingletonProxy } from '@tmlmobilidade/utils';
|
|
5
|
-
/* * */
|
|
6
|
-
class HashedShapesClass extends MongoCollectionClass {
|
|
7
|
-
static _instance;
|
|
8
|
-
createSchema = DocumentSchema;
|
|
9
|
-
updateSchema = DocumentSchema;
|
|
10
|
-
constructor() {
|
|
11
|
-
super();
|
|
12
|
-
}
|
|
13
|
-
static async getInstance() {
|
|
14
|
-
if (!HashedShapesClass._instance) {
|
|
15
|
-
const instance = new HashedShapesClass();
|
|
16
|
-
await instance.connect();
|
|
17
|
-
HashedShapesClass._instance = instance;
|
|
18
|
-
}
|
|
19
|
-
return HashedShapesClass._instance;
|
|
20
|
-
}
|
|
21
|
-
getCollectionIndexes() {
|
|
22
|
-
return [
|
|
23
|
-
{ background: true, key: { agency_id: 1 } },
|
|
24
|
-
];
|
|
25
|
-
}
|
|
26
|
-
getCollectionName() {
|
|
27
|
-
return 'hashed_shapes';
|
|
28
|
-
}
|
|
29
|
-
getEnvName() {
|
|
30
|
-
return 'DATABASE_URI';
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
/* * */
|
|
34
|
-
export const hashedShapes = asyncSingletonProxy(HashedShapesClass);
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { MongoCollectionClass } from '../../common/mongo-collection.js';
|
|
2
|
-
import { type HashedTrip } from '@tmlmobilidade/types';
|
|
3
|
-
import { type IndexDescription } from 'mongodb';
|
|
4
|
-
import { z } from 'zod';
|
|
5
|
-
declare class HashedTripsClass extends MongoCollectionClass<HashedTrip, HashedTrip, HashedTrip> {
|
|
6
|
-
private static _instance;
|
|
7
|
-
protected createSchema: z.ZodSchema;
|
|
8
|
-
protected updateSchema: z.ZodSchema;
|
|
9
|
-
private constructor();
|
|
10
|
-
static getInstance(): Promise<HashedTripsClass>;
|
|
11
|
-
protected getCollectionIndexes(): IndexDescription[];
|
|
12
|
-
protected getCollectionName(): string;
|
|
13
|
-
protected getEnvName(): string;
|
|
14
|
-
}
|
|
15
|
-
export declare const hashedTrips: HashedTripsClass;
|
|
16
|
-
export {};
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
/* * */
|
|
2
|
-
import { MongoCollectionClass } from '../../common/mongo-collection.js';
|
|
3
|
-
import { DocumentSchema } from '@tmlmobilidade/types';
|
|
4
|
-
import { asyncSingletonProxy } from '@tmlmobilidade/utils';
|
|
5
|
-
/* * */
|
|
6
|
-
class HashedTripsClass extends MongoCollectionClass {
|
|
7
|
-
static _instance;
|
|
8
|
-
createSchema = DocumentSchema;
|
|
9
|
-
updateSchema = DocumentSchema;
|
|
10
|
-
constructor() {
|
|
11
|
-
super();
|
|
12
|
-
}
|
|
13
|
-
static async getInstance() {
|
|
14
|
-
if (!HashedTripsClass._instance) {
|
|
15
|
-
const instance = new HashedTripsClass();
|
|
16
|
-
await instance.connect();
|
|
17
|
-
HashedTripsClass._instance = instance;
|
|
18
|
-
}
|
|
19
|
-
return HashedTripsClass._instance;
|
|
20
|
-
}
|
|
21
|
-
getCollectionIndexes() {
|
|
22
|
-
return [
|
|
23
|
-
{ background: true, key: { agency_id: 1 } },
|
|
24
|
-
{ background: true, key: { line_id: 1 } },
|
|
25
|
-
];
|
|
26
|
-
}
|
|
27
|
-
getCollectionName() {
|
|
28
|
-
return 'hashed_trips';
|
|
29
|
-
}
|
|
30
|
-
getEnvName() {
|
|
31
|
-
return 'DATABASE_URI';
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
/* * */
|
|
35
|
-
export const hashedTrips = asyncSingletonProxy(HashedTripsClass);
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { MongoCollectionClass } from '../../common/mongo-collection.js';
|
|
2
|
-
import { type CreateRideAcceptanceDto, type RideAcceptance, type UpdateRideAcceptanceDto } from '@tmlmobilidade/types';
|
|
3
|
-
import { IndexDescription, InsertOneOptions, UpdateOptions } from 'mongodb';
|
|
4
|
-
import { z } from 'zod';
|
|
5
|
-
declare class RideAcceptanceClass extends MongoCollectionClass<RideAcceptance, CreateRideAcceptanceDto, UpdateRideAcceptanceDto> {
|
|
6
|
-
private static _instance;
|
|
7
|
-
protected createSchema: z.ZodSchema;
|
|
8
|
-
protected updateSchema: z.ZodSchema;
|
|
9
|
-
private constructor();
|
|
10
|
-
static getInstance(): Promise<RideAcceptanceClass>;
|
|
11
|
-
createByRideId(ride_id: string, data: CreateRideAcceptanceDto, options?: InsertOneOptions & {
|
|
12
|
-
returnResult?: boolean;
|
|
13
|
-
}): Promise<RideAcceptance>;
|
|
14
|
-
findByRideId(ride_id: string): Promise<null | RideAcceptance>;
|
|
15
|
-
updateByRideId(ride_id: string, data: UpdateRideAcceptanceDto, options?: UpdateOptions & {
|
|
16
|
-
returnResult?: boolean;
|
|
17
|
-
}): Promise<RideAcceptance>;
|
|
18
|
-
protected getCollectionIndexes(): IndexDescription[];
|
|
19
|
-
protected getCollectionName(): string;
|
|
20
|
-
protected getEnvName(): string;
|
|
21
|
-
}
|
|
22
|
-
export declare const rideAcceptances: Omit<RideAcceptanceClass, 'deleteById' | 'deleteMany' | 'deleteOne' | 'insertOne' | 'updateById' | 'updateOne'>;
|
|
23
|
-
export {};
|
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
/* * */
|
|
2
|
-
import { MongoCollectionClass } from '../../common/mongo-collection.js';
|
|
3
|
-
import { HTTP_STATUS, HttpException } from '@tmlmobilidade/consts';
|
|
4
|
-
import { Dates } from '@tmlmobilidade/dates';
|
|
5
|
-
import { CreateRideAcceptanceSchema, UpdateRideAcceptanceSchema } from '@tmlmobilidade/types';
|
|
6
|
-
import { asyncSingletonProxy, compareObjects, flattenObject } from '@tmlmobilidade/utils';
|
|
7
|
-
/* * */
|
|
8
|
-
class RideAcceptanceClass extends MongoCollectionClass {
|
|
9
|
-
static _instance;
|
|
10
|
-
createSchema = CreateRideAcceptanceSchema;
|
|
11
|
-
updateSchema = UpdateRideAcceptanceSchema;
|
|
12
|
-
constructor() {
|
|
13
|
-
super();
|
|
14
|
-
}
|
|
15
|
-
static async getInstance() {
|
|
16
|
-
if (!RideAcceptanceClass._instance) {
|
|
17
|
-
const instance = new RideAcceptanceClass();
|
|
18
|
-
await instance.connect();
|
|
19
|
-
RideAcceptanceClass._instance = instance;
|
|
20
|
-
}
|
|
21
|
-
return RideAcceptanceClass._instance;
|
|
22
|
-
}
|
|
23
|
-
async createByRideId(ride_id, data, options = {}) {
|
|
24
|
-
const currentTimestamp = Dates.now('utc').unix_timestamp;
|
|
25
|
-
const createdBy = data.created_by || 'system';
|
|
26
|
-
data.comments.push({
|
|
27
|
-
created_at: currentTimestamp,
|
|
28
|
-
created_by: createdBy,
|
|
29
|
-
message: 'Ride acceptance created',
|
|
30
|
-
type: 'note',
|
|
31
|
-
updated_at: currentTimestamp,
|
|
32
|
-
});
|
|
33
|
-
data.comments.push({
|
|
34
|
-
created_at: currentTimestamp,
|
|
35
|
-
created_by: createdBy,
|
|
36
|
-
curr_value: data.analysis_summary,
|
|
37
|
-
field: 'analysis_summary',
|
|
38
|
-
prev_value: null,
|
|
39
|
-
type: 'field_changed',
|
|
40
|
-
updated_at: currentTimestamp,
|
|
41
|
-
});
|
|
42
|
-
return super.insertOne({ ...data, ride_id }, { options });
|
|
43
|
-
}
|
|
44
|
-
async findByRideId(ride_id) {
|
|
45
|
-
return super.findOne({ ride_id });
|
|
46
|
-
}
|
|
47
|
-
async updateByRideId(ride_id, data, options = {}) {
|
|
48
|
-
const prevAcceptance = await this.findByRideId(ride_id);
|
|
49
|
-
if (!prevAcceptance) {
|
|
50
|
-
throw new HttpException(HTTP_STATUS.NOT_FOUND, 'Ride acceptance not found');
|
|
51
|
-
}
|
|
52
|
-
const diff = compareObjects(prevAcceptance, data);
|
|
53
|
-
const flattenedDiff = flattenObject(diff);
|
|
54
|
-
data.comments = data.comments || prevAcceptance.comments || [];
|
|
55
|
-
for (const key of Object.keys(flattenedDiff)) {
|
|
56
|
-
if (key === 'is_locked' || key === 'acceptance_status' || key === 'justification' || key === 'analysis_summary') {
|
|
57
|
-
data.comments.push({
|
|
58
|
-
created_at: Dates.now('utc').unix_timestamp,
|
|
59
|
-
created_by: data.updated_by || 'system',
|
|
60
|
-
curr_value: data[key],
|
|
61
|
-
field: key,
|
|
62
|
-
prev_value: prevAcceptance[key],
|
|
63
|
-
type: 'field_changed',
|
|
64
|
-
updated_at: Dates.now('utc').unix_timestamp,
|
|
65
|
-
updated_by: data.updated_by || 'system',
|
|
66
|
-
});
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
return super.updateOne({ ride_id }, data, options);
|
|
70
|
-
}
|
|
71
|
-
getCollectionIndexes() {
|
|
72
|
-
return [
|
|
73
|
-
{ background: true, key: { ride_id: 1 } },
|
|
74
|
-
{ background: true, key: { acceptance_status: 1 } },
|
|
75
|
-
];
|
|
76
|
-
}
|
|
77
|
-
getCollectionName() {
|
|
78
|
-
return 'ride_acceptances';
|
|
79
|
-
}
|
|
80
|
-
getEnvName() {
|
|
81
|
-
return 'DATABASE_URI';
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
/* * */
|
|
85
|
-
export const rideAcceptances = asyncSingletonProxy(RideAcceptanceClass);
|