@tmscloud/tbt-knex 0.0.7 → 0.0.8
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/index.d.ts +1 -0
- package/dist/index.js.map +1 -1
- package/dist/interfaces/route/route-geojson.interfaces.d.ts +105 -0
- package/dist/interfaces/route/route-geojson.interfaces.js +4 -0
- package/dist/interfaces/route/route-geojson.interfaces.js.map +1 -0
- package/dist/interfaces/route/route.interfaces.d.ts +4 -0
- package/package.json +1 -1
- package/dist/dao/password-history/password-history.dao.d.ts +0 -19
- package/dist/dao/password-history/password-history.dao.js +0 -78
- package/dist/dao/password-history/password-history.dao.js.map +0 -1
package/dist/index.d.ts
CHANGED
|
@@ -24,6 +24,7 @@ export { IDutyTemplate, IDutyTemplateCreate, IDutyTemplateUpdate, IDutyTemplateW
|
|
|
24
24
|
export { IEvent, IEventCreate, IEventUpdate, } from "./interfaces/event/event.interfaces";
|
|
25
25
|
export { IRole } from "./interfaces/role/role.interfaces";
|
|
26
26
|
export { IRoute, IRouteInstruction } from "./interfaces/route/route.interfaces";
|
|
27
|
+
export { IRouteGeoJSONProperties, IRouteStopProperties, IRouteWaypointProperties, IRouteSegmentProperties, IRouteMainProperties, IRouteSegmentInstruction, RouteFeatureProperties, IRouteStop, IRouteWaypoint, IRouteSegment, } from "./interfaces/route/route-geojson.interfaces";
|
|
27
28
|
export { IRouteAssignment } from "./interfaces/route-assignment/route-assignment.interfaces";
|
|
28
29
|
export { ISundaysPackageVersion } from "./interfaces/sundays-package-version/sundays-package-version.interfaces";
|
|
29
30
|
export { ISystemSetting, ISystemSettingCreate, ISystemSettingUpdate, } from "./interfaces/system-setting/system-setting.interfaces";
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO;AACP,yDAAsD;AAA7C,wGAAA,SAAS,OAAA;AA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AAAlE,sHAAA,gBAAgB,OAAA;AACzB,gDAA8C;AAArC,mGAAA,OAAO,OAAA;AAChB,kEAA+D;AAAtD,8GAAA,YAAY,OAAA;AACrB,gDAA8C;AAArC,mGAAA,OAAO,OAAA;AA4FhB,sEAA2C;AAClC,sBADF,wBAAW,CACE"}
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Properties on the FeatureCollection itself (top-level metadata).
|
|
3
|
+
* Non-standard but already used throughout the codebase.
|
|
4
|
+
*/
|
|
5
|
+
export interface IRouteGeoJSONProperties {
|
|
6
|
+
name?: string;
|
|
7
|
+
description?: string;
|
|
8
|
+
stops_count?: number;
|
|
9
|
+
waypoints_count?: number;
|
|
10
|
+
route_type?: string;
|
|
11
|
+
total_distance?: number;
|
|
12
|
+
total_duration?: number;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* A bus stop -- primary user-created entity.
|
|
16
|
+
* GeoJSON Feature with geometry.type === 'Point'.
|
|
17
|
+
* Feature.id === crypto.randomUUID()
|
|
18
|
+
*/
|
|
19
|
+
export interface IRouteStopProperties {
|
|
20
|
+
feature_type: 'stop';
|
|
21
|
+
name: string;
|
|
22
|
+
address: string;
|
|
23
|
+
stop_sequence: number;
|
|
24
|
+
customInstruction?: string;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* A turn/waypoint -- auto-generated from Mapbox routing, optionally pinned by user.
|
|
28
|
+
* GeoJSON Feature with geometry.type === 'Point'.
|
|
29
|
+
* Feature.id === crypto.randomUUID()
|
|
30
|
+
*/
|
|
31
|
+
export interface IRouteWaypointProperties {
|
|
32
|
+
feature_type: 'waypoint';
|
|
33
|
+
segment_index: number;
|
|
34
|
+
order_in_segment: number;
|
|
35
|
+
isPinned: boolean;
|
|
36
|
+
customInstruction?: string;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* A segment instruction embedded inside a route_segment feature's properties.
|
|
40
|
+
* Each instruction has a geographic point where the maneuver occurs.
|
|
41
|
+
*/
|
|
42
|
+
export interface IRouteSegmentInstruction {
|
|
43
|
+
id: string;
|
|
44
|
+
stepIndex: number;
|
|
45
|
+
instruction: string;
|
|
46
|
+
distance: number;
|
|
47
|
+
duration: number;
|
|
48
|
+
maneuverType?: string;
|
|
49
|
+
maneuverModifier?: string;
|
|
50
|
+
point: [number, number];
|
|
51
|
+
linkedWaypointId?: string;
|
|
52
|
+
linkedStopId?: string;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* A route segment -- the path between two consecutive stops.
|
|
56
|
+
* GeoJSON Feature with geometry.type === 'LineString'.
|
|
57
|
+
* Feature.id === 'route-segment-{segment_index}'
|
|
58
|
+
*/
|
|
59
|
+
export interface IRouteSegmentProperties {
|
|
60
|
+
feature_type: 'route_segment';
|
|
61
|
+
segment_index: number;
|
|
62
|
+
mode: 'normal' | 'offroad';
|
|
63
|
+
from_stop_id: string;
|
|
64
|
+
to_stop_id: string;
|
|
65
|
+
distance: number;
|
|
66
|
+
duration: number;
|
|
67
|
+
instructions: IRouteSegmentInstruction[];
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* The main combined route line.
|
|
71
|
+
* GeoJSON Feature with geometry.type === 'LineString'.
|
|
72
|
+
* Feature.id === 'route-main'
|
|
73
|
+
*/
|
|
74
|
+
export interface IRouteMainProperties {
|
|
75
|
+
feature_type: 'route';
|
|
76
|
+
}
|
|
77
|
+
export type RouteFeatureProperties = IRouteStopProperties | IRouteWaypointProperties | IRouteSegmentProperties | IRouteMainProperties;
|
|
78
|
+
export interface IRouteStop {
|
|
79
|
+
id: string;
|
|
80
|
+
lat: number;
|
|
81
|
+
lng: number;
|
|
82
|
+
name: string;
|
|
83
|
+
address: string;
|
|
84
|
+
stop_sequence: number;
|
|
85
|
+
customInstruction?: string;
|
|
86
|
+
}
|
|
87
|
+
export interface IRouteWaypoint {
|
|
88
|
+
id: string;
|
|
89
|
+
lat: number;
|
|
90
|
+
lng: number;
|
|
91
|
+
segment_index: number;
|
|
92
|
+
order_in_segment: number;
|
|
93
|
+
isPinned: boolean;
|
|
94
|
+
customInstruction?: string;
|
|
95
|
+
}
|
|
96
|
+
export interface IRouteSegment {
|
|
97
|
+
segment_index: number;
|
|
98
|
+
mode: 'normal' | 'offroad';
|
|
99
|
+
from_stop_id: string;
|
|
100
|
+
to_stop_id: string;
|
|
101
|
+
distance: number;
|
|
102
|
+
duration: number;
|
|
103
|
+
instructions: IRouteSegmentInstruction[];
|
|
104
|
+
geometry: GeoJSON.LineString;
|
|
105
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"route-geojson.interfaces.js","sourceRoot":"","sources":["../../../src/interfaces/route/route-geojson.interfaces.ts"],"names":[],"mappings":";AAAA,qCAAqC"}
|
|
@@ -5,6 +5,7 @@ export interface IRoute {
|
|
|
5
5
|
name: string;
|
|
6
6
|
description?: string;
|
|
7
7
|
geojson: any;
|
|
8
|
+
/** @deprecated Use instructions embedded in GeoJSON route_segment features instead */
|
|
8
9
|
custom_instructions?: any[];
|
|
9
10
|
distance?: number;
|
|
10
11
|
estimated_duration?: number;
|
|
@@ -24,4 +25,7 @@ export interface IRouteInstruction {
|
|
|
24
25
|
maneuverType?: string;
|
|
25
26
|
maneuverModifier?: string;
|
|
26
27
|
geometry?: any;
|
|
28
|
+
point?: [number, number];
|
|
29
|
+
linkedWaypointId?: string;
|
|
30
|
+
linkedStopId?: string;
|
|
27
31
|
}
|
package/package.json
CHANGED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { IPasswordHistory } from "../../interfaces/password-reset/password-reset.interfaces";
|
|
2
|
-
export declare class PasswordHistoryDAO {
|
|
3
|
-
private _knex?;
|
|
4
|
-
private get knex();
|
|
5
|
-
/**
|
|
6
|
-
* Add password to history
|
|
7
|
-
*/
|
|
8
|
-
create(data: IPasswordHistory): Promise<IPasswordHistory>;
|
|
9
|
-
/**
|
|
10
|
-
* Get recent password hashes for a user
|
|
11
|
-
* Used to prevent password reuse
|
|
12
|
-
*/
|
|
13
|
-
getRecentForUser(userId: number, limit?: number): Promise<IPasswordHistory[]>;
|
|
14
|
-
/**
|
|
15
|
-
* Cleanup old password history
|
|
16
|
-
* Keep only the most recent N passwords per user
|
|
17
|
-
*/
|
|
18
|
-
cleanupOldPasswords(keepCount?: number): Promise<number>;
|
|
19
|
-
}
|
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
-
};
|
|
14
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
exports.PasswordHistoryDAO = void 0;
|
|
16
|
-
const KnexConnection_1 = __importDefault(require("../../KnexConnection"));
|
|
17
|
-
class PasswordHistoryDAO {
|
|
18
|
-
get knex() {
|
|
19
|
-
if (!this._knex) {
|
|
20
|
-
this._knex = KnexConnection_1.default.getConnection();
|
|
21
|
-
}
|
|
22
|
-
return this._knex;
|
|
23
|
-
}
|
|
24
|
-
/**
|
|
25
|
-
* Add password to history
|
|
26
|
-
*/
|
|
27
|
-
create(data) {
|
|
28
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
29
|
-
const [result] = yield this.knex("password_history")
|
|
30
|
-
.insert({
|
|
31
|
-
user_id: data.user_id,
|
|
32
|
-
password_hash: data.password_hash,
|
|
33
|
-
})
|
|
34
|
-
.returning("*");
|
|
35
|
-
return result;
|
|
36
|
-
});
|
|
37
|
-
}
|
|
38
|
-
/**
|
|
39
|
-
* Get recent password hashes for a user
|
|
40
|
-
* Used to prevent password reuse
|
|
41
|
-
*/
|
|
42
|
-
getRecentForUser(userId_1) {
|
|
43
|
-
return __awaiter(this, arguments, void 0, function* (userId, limit = 5) {
|
|
44
|
-
return yield this.knex("password_history")
|
|
45
|
-
.where("user_id", userId)
|
|
46
|
-
.orderBy("created_at", "desc")
|
|
47
|
-
.limit(limit);
|
|
48
|
-
});
|
|
49
|
-
}
|
|
50
|
-
/**
|
|
51
|
-
* Cleanup old password history
|
|
52
|
-
* Keep only the most recent N passwords per user
|
|
53
|
-
*/
|
|
54
|
-
cleanupOldPasswords() {
|
|
55
|
-
return __awaiter(this, arguments, void 0, function* (keepCount = 10) {
|
|
56
|
-
// Subquery to get IDs to keep
|
|
57
|
-
const idsToKeep = this.knex("password_history as ph1")
|
|
58
|
-
.select("ph1.id")
|
|
59
|
-
.whereRaw(`
|
|
60
|
-
ph1.id IN (
|
|
61
|
-
SELECT id FROM (
|
|
62
|
-
SELECT id FROM password_history ph2
|
|
63
|
-
WHERE ph2.user_id = ph1.user_id
|
|
64
|
-
ORDER BY created_at DESC
|
|
65
|
-
LIMIT ?
|
|
66
|
-
) as recent
|
|
67
|
-
)
|
|
68
|
-
`, [keepCount]);
|
|
69
|
-
// Delete all records not in the keep list
|
|
70
|
-
const result = yield this.knex("password_history")
|
|
71
|
-
.whereNotIn("id", idsToKeep)
|
|
72
|
-
.delete();
|
|
73
|
-
return result;
|
|
74
|
-
});
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
exports.PasswordHistoryDAO = PasswordHistoryDAO;
|
|
78
|
-
//# sourceMappingURL=password-history.dao.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"password-history.dao.js","sourceRoot":"","sources":["../../../src/dao/password-history/password-history.dao.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AACA,0EAA+C;AAG/C,MAAa,kBAAkB;IAG7B,IAAY,IAAI;QACd,IAAI,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC;YAChB,IAAI,CAAC,KAAK,GAAG,wBAAW,CAAC,aAAa,EAAE,CAAC;QAC3C,CAAC;QACD,OAAO,IAAI,CAAC,KAAK,CAAC;IACpB,CAAC;IAED;;OAEG;IACG,MAAM,CAAC,IAAsB;;YACjC,MAAM,CAAC,MAAM,CAAC,GAAG,MAAM,IAAI,CAAC,IAAI,CAAC,kBAAkB,CAAC;iBACjD,MAAM,CAAC;gBACN,OAAO,EAAE,IAAI,CAAC,OAAO;gBACrB,aAAa,EAAE,IAAI,CAAC,aAAa;aAClC,CAAC;iBACD,SAAS,CAAC,GAAG,CAAC,CAAC;YAElB,OAAO,MAAM,CAAC;QAChB,CAAC;KAAA;IAED;;;OAGG;IACG,gBAAgB;6DACpB,MAAc,EACd,QAAgB,CAAC;YAEjB,OAAO,MAAM,IAAI,CAAC,IAAI,CAAC,kBAAkB,CAAC;iBACvC,KAAK,CAAC,SAAS,EAAE,MAAM,CAAC;iBACxB,OAAO,CAAC,YAAY,EAAE,MAAM,CAAC;iBAC7B,KAAK,CAAC,KAAK,CAAC,CAAC;QAClB,CAAC;KAAA;IAED;;;OAGG;IACG,mBAAmB;6DAAC,YAAoB,EAAE;YAC9C,8BAA8B;YAC9B,MAAM,SAAS,GAAG,IAAI,CAAC,IAAI,CAAC,yBAAyB,CAAC;iBACnD,MAAM,CAAC,QAAQ,CAAC;iBAChB,QAAQ,CAAC;;;;;;;;;OAST,EAAE,CAAC,SAAS,CAAC,CAAC,CAAC;YAElB,0CAA0C;YAC1C,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,IAAI,CAAC,kBAAkB,CAAC;iBAC/C,UAAU,CAAC,IAAI,EAAE,SAAS,CAAC;iBAC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