@tmscloud/tbt-knex 0.0.1 → 0.0.2
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/.github/workflows/build-and-push.yml +118 -0
- package/Dockerfile +36 -0
- package/build-image.sh +16 -0
- package/dist/dao/event/event.dao.d.ts +38 -0
- package/dist/dao/event/event.dao.js +162 -0
- package/dist/dao/event/event.dao.js.map +1 -0
- package/dist/dao/route/route.dao.d.ts +10 -2
- package/dist/dao/route/route.dao.js +94 -9
- package/dist/dao/route/route.dao.js.map +1 -1
- package/dist/index.d.ts +12 -10
- package/dist/index.js +13 -11
- package/dist/index.js.map +1 -1
- package/dist/interfaces/event/event.interfaces.d.ts +22 -0
- package/dist/interfaces/event/event.interfaces.js +3 -0
- package/dist/interfaces/event/event.interfaces.js.map +1 -0
- package/dist/interfaces/route/route.interfaces.d.ts +3 -0
- package/package.json +1 -1
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
name: Build and Push to ECR
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches:
|
|
6
|
+
- main
|
|
7
|
+
|
|
8
|
+
# Shared constants
|
|
9
|
+
env:
|
|
10
|
+
AWS_REGION: us-east-1
|
|
11
|
+
ECR_REPOSITORY: tms-tbt-migration
|
|
12
|
+
|
|
13
|
+
jobs:
|
|
14
|
+
build_and_push:
|
|
15
|
+
name: Build and Push Migrations Image
|
|
16
|
+
runs-on: ubuntu-latest
|
|
17
|
+
environment: development
|
|
18
|
+
concurrency: build-push
|
|
19
|
+
|
|
20
|
+
permissions:
|
|
21
|
+
id-token: write
|
|
22
|
+
contents: read
|
|
23
|
+
|
|
24
|
+
steps:
|
|
25
|
+
- name: Checkout
|
|
26
|
+
uses: actions/checkout@v4
|
|
27
|
+
|
|
28
|
+
- name: Compute image tags
|
|
29
|
+
id: tags
|
|
30
|
+
run: |
|
|
31
|
+
# Compute timestamp in UTC (YYYYmmdd-HHMM format)
|
|
32
|
+
TIMESTAMP=$(date -u +'%Y.%m.%d-%H%M')
|
|
33
|
+
echo "timestamp=$TIMESTAMP" >> $GITHUB_OUTPUT
|
|
34
|
+
|
|
35
|
+
# Compute short and full SHA
|
|
36
|
+
SHORT_SHA=$(git rev-parse --short HEAD)
|
|
37
|
+
FULL_SHA=$(git rev-parse HEAD)
|
|
38
|
+
echo "short_sha=$SHORT_SHA" >> $GITHUB_OUTPUT
|
|
39
|
+
echo "full_sha=$FULL_SHA" >> $GITHUB_OUTPUT
|
|
40
|
+
|
|
41
|
+
# Compute immutable image tags
|
|
42
|
+
CI_TAG="ci-${TIMESTAMP}-${SHORT_SHA}"
|
|
43
|
+
SHA_TAG="sha-${FULL_SHA}"
|
|
44
|
+
echo "ci_tag=$CI_TAG" >> $GITHUB_OUTPUT
|
|
45
|
+
echo "sha_tag=$SHA_TAG" >> $GITHUB_OUTPUT
|
|
46
|
+
|
|
47
|
+
echo "## Image Tags" >> $GITHUB_STEP_SUMMARY
|
|
48
|
+
echo "- CI Tag: \`$CI_TAG\`" >> $GITHUB_STEP_SUMMARY
|
|
49
|
+
echo "- SHA Tag: \`$SHA_TAG\`" >> $GITHUB_STEP_SUMMARY
|
|
50
|
+
echo "- Commit: \`$FULL_SHA\`" >> $GITHUB_STEP_SUMMARY
|
|
51
|
+
|
|
52
|
+
- name: Configure AWS credentials
|
|
53
|
+
uses: aws-actions/configure-aws-credentials@v4
|
|
54
|
+
with:
|
|
55
|
+
# SOURCE OF TRUTH: GitHub Environment Secret (global)
|
|
56
|
+
role-to-assume: ${{ secrets.DEVELOPMENT_AWS_ROLE_TO_ASUME_OIDC }}
|
|
57
|
+
aws-region: ${{ env.AWS_REGION }}
|
|
58
|
+
|
|
59
|
+
- name: Login to Amazon ECR
|
|
60
|
+
id: login-ecr
|
|
61
|
+
uses: aws-actions/amazon-ecr-login@v2
|
|
62
|
+
|
|
63
|
+
- name: Build Docker image
|
|
64
|
+
id: build-image
|
|
65
|
+
env:
|
|
66
|
+
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
|
|
67
|
+
CI_TAG: ${{ steps.tags.outputs.ci_tag }}
|
|
68
|
+
SHA_TAG: ${{ steps.tags.outputs.sha_tag }}
|
|
69
|
+
run: |
|
|
70
|
+
echo "Building image for linux/amd64..."
|
|
71
|
+
docker buildx build \
|
|
72
|
+
--platform linux/amd64 \
|
|
73
|
+
-t $ECR_REGISTRY/$ECR_REPOSITORY:$CI_TAG \
|
|
74
|
+
-t $ECR_REGISTRY/$ECR_REPOSITORY:$SHA_TAG \
|
|
75
|
+
--load \
|
|
76
|
+
.
|
|
77
|
+
|
|
78
|
+
# Output the canonical deployment tag
|
|
79
|
+
echo "image=$ECR_REGISTRY/$ECR_REPOSITORY:$SHA_TAG" >> $GITHUB_OUTPUT
|
|
80
|
+
|
|
81
|
+
- name: Push image tags to Amazon ECR
|
|
82
|
+
env:
|
|
83
|
+
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
|
|
84
|
+
CI_TAG: ${{ steps.tags.outputs.ci_tag }}
|
|
85
|
+
SHA_TAG: ${{ steps.tags.outputs.sha_tag }}
|
|
86
|
+
run: |
|
|
87
|
+
echo "Pushing immutable tags to ECR..."
|
|
88
|
+
docker push $ECR_REGISTRY/$ECR_REPOSITORY:$CI_TAG
|
|
89
|
+
docker push $ECR_REGISTRY/$ECR_REPOSITORY:$SHA_TAG
|
|
90
|
+
|
|
91
|
+
echo "## Pushed Images" >> $GITHUB_STEP_SUMMARY
|
|
92
|
+
echo "- \`$ECR_REGISTRY/$ECR_REPOSITORY:$CI_TAG\`" >> $GITHUB_STEP_SUMMARY
|
|
93
|
+
echo "- \`$ECR_REGISTRY/$ECR_REPOSITORY:$SHA_TAG\`" >> $GITHUB_STEP_SUMMARY
|
|
94
|
+
|
|
95
|
+
- name: Build Summary
|
|
96
|
+
env:
|
|
97
|
+
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
|
|
98
|
+
CI_TAG: ${{ steps.tags.outputs.ci_tag }}
|
|
99
|
+
SHA_TAG: ${{ steps.tags.outputs.sha_tag }}
|
|
100
|
+
FULL_SHA: ${{ steps.tags.outputs.full_sha }}
|
|
101
|
+
run: |
|
|
102
|
+
echo "## ✅ Build and Push Complete" >> $GITHUB_STEP_SUMMARY
|
|
103
|
+
echo "" >> $GITHUB_STEP_SUMMARY
|
|
104
|
+
echo "### Build Details" >> $GITHUB_STEP_SUMMARY
|
|
105
|
+
echo "- **Commit SHA**: \`$FULL_SHA\`" >> $GITHUB_STEP_SUMMARY
|
|
106
|
+
echo "- **ECR Repository**: \`$ECR_REPOSITORY\`" >> $GITHUB_STEP_SUMMARY
|
|
107
|
+
echo "" >> $GITHUB_STEP_SUMMARY
|
|
108
|
+
echo "### Immutable Image Tags" >> $GITHUB_STEP_SUMMARY
|
|
109
|
+
echo "" >> $GITHUB_STEP_SUMMARY
|
|
110
|
+
echo "**SHA Tag (recommended for deployment):**" >> $GITHUB_STEP_SUMMARY
|
|
111
|
+
echo "\`\`\`" >> $GITHUB_STEP_SUMMARY
|
|
112
|
+
echo "$ECR_REGISTRY/$ECR_REPOSITORY:$SHA_TAG" >> $GITHUB_STEP_SUMMARY
|
|
113
|
+
echo "\`\`\`" >> $GITHUB_STEP_SUMMARY
|
|
114
|
+
echo "" >> $GITHUB_STEP_SUMMARY
|
|
115
|
+
echo "**CI Tag (with timestamp):**" >> $GITHUB_STEP_SUMMARY
|
|
116
|
+
echo "\`\`\`" >> $GITHUB_STEP_SUMMARY
|
|
117
|
+
echo "$ECR_REGISTRY/$ECR_REPOSITORY:$CI_TAG" >> $GITHUB_STEP_SUMMARY
|
|
118
|
+
echo "\`\`\`" >> $GITHUB_STEP_SUMMARY
|
package/Dockerfile
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
# ==============================================
|
|
2
|
+
# Knex Migrations Container (Optimized)
|
|
3
|
+
# ==============================================
|
|
4
|
+
# Note: This container needs TypeScript support since migrations are in TS
|
|
5
|
+
# It's a short-lived container, so optimization focus is on build speed
|
|
6
|
+
FROM node:22-alpine
|
|
7
|
+
|
|
8
|
+
WORKDIR /app
|
|
9
|
+
|
|
10
|
+
# Install only needed dependencies
|
|
11
|
+
COPY package*.json ./
|
|
12
|
+
RUN npm ci && \
|
|
13
|
+
npm cache clean --force
|
|
14
|
+
|
|
15
|
+
# Copy TypeScript configuration
|
|
16
|
+
COPY tsconfig.json ./
|
|
17
|
+
|
|
18
|
+
# Copy knexfile and migrations
|
|
19
|
+
COPY knexfile.ts ./
|
|
20
|
+
COPY migrations ./migrations
|
|
21
|
+
|
|
22
|
+
# Copy source code (needed for imports in migrations)
|
|
23
|
+
COPY src ./src
|
|
24
|
+
|
|
25
|
+
# Set environment to production
|
|
26
|
+
ENV NODE_ENV=production
|
|
27
|
+
|
|
28
|
+
# Create non-root user
|
|
29
|
+
RUN addgroup -g 1001 -S nodejs && \
|
|
30
|
+
adduser -S nodejs -u 1001 && \
|
|
31
|
+
chown -R nodejs:nodejs /app
|
|
32
|
+
|
|
33
|
+
USER nodejs
|
|
34
|
+
|
|
35
|
+
# Default command runs migrations
|
|
36
|
+
CMD ["npx", "knex", "migrate:latest"]
|
package/build-image.sh
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
|
|
3
|
+
# Build the Docker image for local development
|
|
4
|
+
# Use --platform to ensure linux/amd64 compatibility for AWS ECS/Fargate
|
|
5
|
+
IMAGE_NAME='tms-tbt-knex'
|
|
6
|
+
TAG='first'
|
|
7
|
+
docker buildx build --platform linux/amd64 -t $IMAGE_NAME:$TAG --load .
|
|
8
|
+
|
|
9
|
+
echo "✓ Image built successfully: $IMAGE_NAME:$TAG"
|
|
10
|
+
echo ""
|
|
11
|
+
echo "To use this image in another docker-compose.yml:"
|
|
12
|
+
echo " services:"
|
|
13
|
+
echo " migrations:"
|
|
14
|
+
echo " image: $IMAGE_NAME:$TAG"
|
|
15
|
+
|
|
16
|
+
# docker tag tms-tbt-knex:first 937623187882.dkr.ecr.us-east-1.amazonaws.com/tms-tbt-migration:first
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { IEvent, IEventCreate, IEventUpdate } from "../../interfaces/event/event.interfaces";
|
|
2
|
+
import { IBaseDAO, IDataPaginator } from "../../d.types";
|
|
3
|
+
export declare class EventDAO implements IBaseDAO<IEvent> {
|
|
4
|
+
private _knex?;
|
|
5
|
+
private get knex();
|
|
6
|
+
/**
|
|
7
|
+
* Get all events with pagination
|
|
8
|
+
*/
|
|
9
|
+
getAll(page?: number, limit?: number): Promise<IDataPaginator<IEvent>>;
|
|
10
|
+
/**
|
|
11
|
+
* Get event by ID (only active events by default)
|
|
12
|
+
*/
|
|
13
|
+
getById(id: number, includeInactive?: boolean): Promise<IEvent | null>;
|
|
14
|
+
/**
|
|
15
|
+
* Get event by UUID (only active events by default)
|
|
16
|
+
*/
|
|
17
|
+
getByUuid(uuid: string, includeInactive?: boolean): Promise<IEvent | null>;
|
|
18
|
+
/**
|
|
19
|
+
* Get event by name (only active events by default)
|
|
20
|
+
*/
|
|
21
|
+
getByName(name: string, includeInactive?: boolean): Promise<IEvent | null>;
|
|
22
|
+
/**
|
|
23
|
+
* Create a new event
|
|
24
|
+
*/
|
|
25
|
+
create(data: IEventCreate): Promise<IEvent>;
|
|
26
|
+
/**
|
|
27
|
+
* Update an event by ID
|
|
28
|
+
*/
|
|
29
|
+
update(id: number, data: IEventUpdate): Promise<IEvent | null>;
|
|
30
|
+
/**
|
|
31
|
+
* Delete an event by ID (soft delete by setting is_active to false)
|
|
32
|
+
*/
|
|
33
|
+
delete(id: number): Promise<boolean>;
|
|
34
|
+
/**
|
|
35
|
+
* Hard delete an event by ID
|
|
36
|
+
*/
|
|
37
|
+
hardDelete(id: number): Promise<boolean>;
|
|
38
|
+
}
|
|
@@ -0,0 +1,162 @@
|
|
|
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.EventDAO = void 0;
|
|
16
|
+
const KnexConnection_1 = __importDefault(require("../../KnexConnection"));
|
|
17
|
+
class EventDAO {
|
|
18
|
+
get knex() {
|
|
19
|
+
if (!this._knex) {
|
|
20
|
+
this._knex = KnexConnection_1.default.getConnection();
|
|
21
|
+
}
|
|
22
|
+
return this._knex;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Get all events with pagination
|
|
26
|
+
*/
|
|
27
|
+
getAll() {
|
|
28
|
+
return __awaiter(this, arguments, void 0, function* (page = 1, limit = 10) {
|
|
29
|
+
const offset = (page - 1) * limit;
|
|
30
|
+
// Get paginated data
|
|
31
|
+
const data = yield this.knex("events")
|
|
32
|
+
.select("*")
|
|
33
|
+
.where("is_active", true)
|
|
34
|
+
.limit(limit)
|
|
35
|
+
.offset(offset)
|
|
36
|
+
.orderBy("created_at", "desc");
|
|
37
|
+
// Get total count
|
|
38
|
+
const totalCountResult = yield this.knex("events")
|
|
39
|
+
.where("is_active", true)
|
|
40
|
+
.count("* as count")
|
|
41
|
+
.first();
|
|
42
|
+
const totalCount = Number((totalCountResult === null || totalCountResult === void 0 ? void 0 : totalCountResult.count) || 0);
|
|
43
|
+
const count = data.length;
|
|
44
|
+
const totalPages = Math.ceil(totalCount / limit);
|
|
45
|
+
return {
|
|
46
|
+
success: true,
|
|
47
|
+
data,
|
|
48
|
+
page,
|
|
49
|
+
limit,
|
|
50
|
+
count,
|
|
51
|
+
totalCount,
|
|
52
|
+
totalPages,
|
|
53
|
+
};
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Get event by ID (only active events by default)
|
|
58
|
+
*/
|
|
59
|
+
getById(id_1) {
|
|
60
|
+
return __awaiter(this, arguments, void 0, function* (id, includeInactive = false) {
|
|
61
|
+
const query = this.knex("events")
|
|
62
|
+
.select("*")
|
|
63
|
+
.where("id", id);
|
|
64
|
+
if (!includeInactive) {
|
|
65
|
+
query.where("is_active", true);
|
|
66
|
+
}
|
|
67
|
+
const result = yield query.first();
|
|
68
|
+
return result || null;
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Get event by UUID (only active events by default)
|
|
73
|
+
*/
|
|
74
|
+
getByUuid(uuid_1) {
|
|
75
|
+
return __awaiter(this, arguments, void 0, function* (uuid, includeInactive = false) {
|
|
76
|
+
const query = this.knex("events")
|
|
77
|
+
.select("*")
|
|
78
|
+
.where("uuid", uuid);
|
|
79
|
+
if (!includeInactive) {
|
|
80
|
+
query.where("is_active", true);
|
|
81
|
+
}
|
|
82
|
+
const result = yield query.first();
|
|
83
|
+
return result || null;
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Get event by name (only active events by default)
|
|
88
|
+
*/
|
|
89
|
+
getByName(name_1) {
|
|
90
|
+
return __awaiter(this, arguments, void 0, function* (name, includeInactive = false) {
|
|
91
|
+
const query = this.knex("events")
|
|
92
|
+
.select("*")
|
|
93
|
+
.where("name", name);
|
|
94
|
+
if (!includeInactive) {
|
|
95
|
+
query.where("is_active", true);
|
|
96
|
+
}
|
|
97
|
+
const result = yield query.first();
|
|
98
|
+
return result || null;
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Create a new event
|
|
103
|
+
*/
|
|
104
|
+
create(data) {
|
|
105
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
106
|
+
const [result] = yield this.knex("events")
|
|
107
|
+
.insert({
|
|
108
|
+
name: data.name,
|
|
109
|
+
start_date: data.start_date || null,
|
|
110
|
+
end_date: data.end_date || null,
|
|
111
|
+
is_active: data.is_active !== undefined ? data.is_active : true,
|
|
112
|
+
})
|
|
113
|
+
.returning("*");
|
|
114
|
+
return result;
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* Update an event by ID
|
|
119
|
+
*/
|
|
120
|
+
update(id, data) {
|
|
121
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
122
|
+
const updateData = {};
|
|
123
|
+
if (data.name !== undefined)
|
|
124
|
+
updateData.name = data.name;
|
|
125
|
+
if (data.start_date !== undefined)
|
|
126
|
+
updateData.start_date = data.start_date;
|
|
127
|
+
if (data.end_date !== undefined)
|
|
128
|
+
updateData.end_date = data.end_date;
|
|
129
|
+
if (data.is_active !== undefined)
|
|
130
|
+
updateData.is_active = data.is_active;
|
|
131
|
+
updateData.updated_at = new Date();
|
|
132
|
+
const [result] = yield this.knex("events")
|
|
133
|
+
.where("id", id)
|
|
134
|
+
.update(updateData)
|
|
135
|
+
.returning("*");
|
|
136
|
+
return result || null;
|
|
137
|
+
});
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* Delete an event by ID (soft delete by setting is_active to false)
|
|
141
|
+
*/
|
|
142
|
+
delete(id) {
|
|
143
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
144
|
+
const result = yield this.knex("events").where("id", id).update({
|
|
145
|
+
is_active: false,
|
|
146
|
+
updated_at: new Date(),
|
|
147
|
+
});
|
|
148
|
+
return result > 0;
|
|
149
|
+
});
|
|
150
|
+
}
|
|
151
|
+
/**
|
|
152
|
+
* Hard delete an event by ID
|
|
153
|
+
*/
|
|
154
|
+
hardDelete(id) {
|
|
155
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
156
|
+
const result = yield this.knex("events").where("id", id).delete();
|
|
157
|
+
return result > 0;
|
|
158
|
+
});
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
exports.EventDAO = EventDAO;
|
|
162
|
+
//# sourceMappingURL=event.dao.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"event.dao.js","sourceRoot":"","sources":["../../../src/dao/event/event.dao.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AACA,0EAA+C;AAQ/C,MAAa,QAAQ;IAGnB,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;6DACV,OAAe,CAAC,EAChB,QAAgB,EAAE;YAElB,MAAM,MAAM,GAAG,CAAC,IAAI,GAAG,CAAC,CAAC,GAAG,KAAK,CAAC;YAElC,qBAAqB;YACrB,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC;iBACnC,MAAM,CAAC,GAAG,CAAC;iBACX,KAAK,CAAC,WAAW,EAAE,IAAI,CAAC;iBACxB,KAAK,CAAC,KAAK,CAAC;iBACZ,MAAM,CAAC,MAAM,CAAC;iBACd,OAAO,CAAC,YAAY,EAAE,MAAM,CAAC,CAAC;YAEjC,kBAAkB;YAClB,MAAM,gBAAgB,GAAG,MAAM,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC;iBAC/C,KAAK,CAAC,WAAW,EAAE,IAAI,CAAC;iBACxB,KAAK,CAAC,YAAY,CAAC;iBACnB,KAAK,EAAE,CAAC;YAEX,MAAM,UAAU,GAAG,MAAM,CAAC,CAAA,gB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AC,QAAQ,CAAC;YACrE,IAAI,IAAI,CAAC,SAAS,KAAK,SAAS;gBAAE,UAAU,CAAC,SAAS,GAAG,IAAI,CAAC,SAAS,CAAC;YAExE,UAAU,CAAC,UAAU,GAAG,IAAI,IAAI,EAAE,CAAC;YAEnC,MAAM,CAAC,MAAM,CAAC,GAAG,MAAM,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC;iBACvC,KAAK,CAAC,IAAI,EAAE,EAAE,CAAC;iBACf,MAAM,CAAC,UAAU,CAAC;iBAClB,SAAS,CAAC,GAAG,CAAC,CAAC;YAElB,OAAO,MAAM,IAAI,IAAI,CAAC;QACxB,CAAC;KAAA;IAED;;OAEG;IACG,MAAM,CAAC,EAAU;;YACrB,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,KAAK,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,MAAM,CAAC;gBAC9D,SAAS,EAAE,KAAK;gBAChB,UAAU,EAAE,IAAI,IAAI,EAAE;aACvB,CAAC,CAAC;YAEH,OAAO,MAAM,GAAG,CAAC,CAAC;QACpB,CAAC;KAAA;IAED;;OAEG;IACG,UAAU,CAAC,EAAU;;YACzB,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,KAAK,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC;YAElE,OAAO,MAAM,GAAG,CAAC,CAAC;QACpB,CAAC;KAAA;CACF;AAzJD,4BAyJC"}
|
|
@@ -12,11 +12,11 @@ export declare class RouteDAO implements IBaseDAO<IRoute> {
|
|
|
12
12
|
*/
|
|
13
13
|
getAll(page?: number, limit?: number): Promise<IDataPaginator<IRoute>>;
|
|
14
14
|
/**
|
|
15
|
-
* Get route by ID
|
|
15
|
+
* Get route by ID with joined event data
|
|
16
16
|
*/
|
|
17
17
|
getById(id: number): Promise<IRoute | null>;
|
|
18
18
|
/**
|
|
19
|
-
* Get route by UUID
|
|
19
|
+
* Get route by UUID with joined event data
|
|
20
20
|
*/
|
|
21
21
|
getByUuid(uuid: string): Promise<IRoute | null>;
|
|
22
22
|
/**
|
|
@@ -35,4 +35,12 @@ export declare class RouteDAO implements IBaseDAO<IRoute> {
|
|
|
35
35
|
* Hard delete a route by ID
|
|
36
36
|
*/
|
|
37
37
|
hardDelete(id: number): Promise<boolean>;
|
|
38
|
+
/**
|
|
39
|
+
* Get all routes by event ID with pagination
|
|
40
|
+
*/
|
|
41
|
+
getAllByEventId(eventId: number, page?: number, limit?: number): Promise<IDataPaginator<IRoute>>;
|
|
42
|
+
/**
|
|
43
|
+
* Get all routes by event UUID with pagination
|
|
44
|
+
*/
|
|
45
|
+
getAllByEventUuid(eventUuid: string, page?: number, limit?: number): Promise<IDataPaginator<IRoute>>;
|
|
38
46
|
}
|
|
@@ -25,11 +25,16 @@ class RouteDAO {
|
|
|
25
25
|
* Parse JSON fields from database
|
|
26
26
|
*/
|
|
27
27
|
parseRouteJson(route) {
|
|
28
|
-
|
|
28
|
+
const parsed = Object.assign(Object.assign({}, route), { geojson: typeof route.geojson === "string"
|
|
29
29
|
? JSON.parse(route.geojson)
|
|
30
30
|
: route.geojson, custom_instructions: typeof route.custom_instructions === "string"
|
|
31
31
|
? JSON.parse(route.custom_instructions)
|
|
32
32
|
: route.custom_instructions });
|
|
33
|
+
// Handle joined event data
|
|
34
|
+
if (route.event && typeof route.event === "string") {
|
|
35
|
+
parsed.event = JSON.parse(route.event);
|
|
36
|
+
}
|
|
37
|
+
return parsed;
|
|
33
38
|
}
|
|
34
39
|
/**
|
|
35
40
|
* Get all routes with pagination
|
|
@@ -66,25 +71,27 @@ class RouteDAO {
|
|
|
66
71
|
});
|
|
67
72
|
}
|
|
68
73
|
/**
|
|
69
|
-
* Get route by ID
|
|
74
|
+
* Get route by ID with joined event data
|
|
70
75
|
*/
|
|
71
76
|
getById(id) {
|
|
72
77
|
return __awaiter(this, void 0, void 0, function* () {
|
|
73
|
-
const result = yield this.knex("routes")
|
|
74
|
-
.
|
|
75
|
-
.
|
|
78
|
+
const result = yield this.knex("routes as r")
|
|
79
|
+
.leftJoin("events as e", "r.event_id", "e.id")
|
|
80
|
+
.select("r.*", this.knex.raw("to_jsonb(e.*) as event"))
|
|
81
|
+
.where("r.id", id)
|
|
76
82
|
.first();
|
|
77
83
|
return result ? this.parseRouteJson(result) : null;
|
|
78
84
|
});
|
|
79
85
|
}
|
|
80
86
|
/**
|
|
81
|
-
* Get route by UUID
|
|
87
|
+
* Get route by UUID with joined event data
|
|
82
88
|
*/
|
|
83
89
|
getByUuid(uuid) {
|
|
84
90
|
return __awaiter(this, void 0, void 0, function* () {
|
|
85
|
-
const result = yield this.knex("routes")
|
|
86
|
-
.
|
|
87
|
-
.
|
|
91
|
+
const result = yield this.knex("routes as r")
|
|
92
|
+
.leftJoin("events as e", "r.event_id", "e.id")
|
|
93
|
+
.select("r.*", this.knex.raw("to_jsonb(e.*) as event"))
|
|
94
|
+
.where("r.uuid", uuid)
|
|
88
95
|
.first();
|
|
89
96
|
return result ? this.parseRouteJson(result) : null;
|
|
90
97
|
});
|
|
@@ -104,6 +111,7 @@ class RouteDAO {
|
|
|
104
111
|
: null,
|
|
105
112
|
distance: data.distance,
|
|
106
113
|
estimated_duration: data.estimated_duration,
|
|
114
|
+
event_id: data.event_id,
|
|
107
115
|
is_active: data.is_active !== undefined ? data.is_active : true,
|
|
108
116
|
})
|
|
109
117
|
.returning("*");
|
|
@@ -131,6 +139,8 @@ class RouteDAO {
|
|
|
131
139
|
updateData.distance = data.distance;
|
|
132
140
|
if (data.estimated_duration !== undefined)
|
|
133
141
|
updateData.estimated_duration = data.estimated_duration;
|
|
142
|
+
if (data.event_id !== undefined)
|
|
143
|
+
updateData.event_id = data.event_id;
|
|
134
144
|
if (data.is_active !== undefined)
|
|
135
145
|
updateData.is_active = data.is_active;
|
|
136
146
|
updateData.updated_at = new Date();
|
|
@@ -162,6 +172,81 @@ class RouteDAO {
|
|
|
162
172
|
return result > 0;
|
|
163
173
|
});
|
|
164
174
|
}
|
|
175
|
+
/**
|
|
176
|
+
* Get all routes by event ID with pagination
|
|
177
|
+
*/
|
|
178
|
+
getAllByEventId(eventId_1) {
|
|
179
|
+
return __awaiter(this, arguments, void 0, function* (eventId, page = 1, limit = 10) {
|
|
180
|
+
const offset = (page - 1) * limit;
|
|
181
|
+
// Get paginated data with event joined
|
|
182
|
+
const rawData = yield this.knex("routes as r")
|
|
183
|
+
.leftJoin("events as e", "r.event_id", "e.id")
|
|
184
|
+
.select("r.*", this.knex.raw("to_jsonb(e.*) as event"))
|
|
185
|
+
.where("r.is_active", true)
|
|
186
|
+
.where("r.event_id", eventId)
|
|
187
|
+
.limit(limit)
|
|
188
|
+
.offset(offset)
|
|
189
|
+
.orderBy("r.created_at", "desc");
|
|
190
|
+
// Parse JSON fields
|
|
191
|
+
const data = rawData.map((route) => this.parseRouteJson(route));
|
|
192
|
+
// Get total count
|
|
193
|
+
const totalCountResult = yield this.knex("routes")
|
|
194
|
+
.where("is_active", true)
|
|
195
|
+
.where("event_id", eventId)
|
|
196
|
+
.count("* as count")
|
|
197
|
+
.first();
|
|
198
|
+
const totalCount = Number((totalCountResult === null || totalCountResult === void 0 ? void 0 : totalCountResult.count) || 0);
|
|
199
|
+
const count = data.length;
|
|
200
|
+
const totalPages = Math.ceil(totalCount / limit);
|
|
201
|
+
return {
|
|
202
|
+
success: true,
|
|
203
|
+
data,
|
|
204
|
+
page,
|
|
205
|
+
limit,
|
|
206
|
+
count,
|
|
207
|
+
totalCount,
|
|
208
|
+
totalPages,
|
|
209
|
+
};
|
|
210
|
+
});
|
|
211
|
+
}
|
|
212
|
+
/**
|
|
213
|
+
* Get all routes by event UUID with pagination
|
|
214
|
+
*/
|
|
215
|
+
getAllByEventUuid(eventUuid_1) {
|
|
216
|
+
return __awaiter(this, arguments, void 0, function* (eventUuid, page = 1, limit = 10) {
|
|
217
|
+
const offset = (page - 1) * limit;
|
|
218
|
+
// Get paginated data with event joined, filtering by event UUID
|
|
219
|
+
const rawData = yield this.knex("routes as r")
|
|
220
|
+
.leftJoin("events as e", "r.event_id", "e.id")
|
|
221
|
+
.select("r.*", this.knex.raw("to_jsonb(e.*) as event"))
|
|
222
|
+
.where("r.is_active", true)
|
|
223
|
+
.where("e.uuid", eventUuid)
|
|
224
|
+
.limit(limit)
|
|
225
|
+
.offset(offset)
|
|
226
|
+
.orderBy("r.created_at", "desc");
|
|
227
|
+
// Parse JSON fields
|
|
228
|
+
const data = rawData.map((route) => this.parseRouteJson(route));
|
|
229
|
+
// Get total count
|
|
230
|
+
const totalCountResult = yield this.knex("routes as r")
|
|
231
|
+
.leftJoin("events as e", "r.event_id", "e.id")
|
|
232
|
+
.where("r.is_active", true)
|
|
233
|
+
.where("e.uuid", eventUuid)
|
|
234
|
+
.count("* as count")
|
|
235
|
+
.first();
|
|
236
|
+
const totalCount = Number((totalCountResult === null || totalCountResult === void 0 ? void 0 : totalCountResult.count) || 0);
|
|
237
|
+
const count = data.length;
|
|
238
|
+
const totalPages = Math.ceil(totalCount / limit);
|
|
239
|
+
return {
|
|
240
|
+
success: true,
|
|
241
|
+
data,
|
|
242
|
+
page,
|
|
243
|
+
limit,
|
|
244
|
+
count,
|
|
245
|
+
totalCount,
|
|
246
|
+
totalPages,
|
|
247
|
+
};
|
|
248
|
+
});
|
|
249
|
+
}
|
|
165
250
|
}
|
|
166
251
|
exports.RouteDAO = RouteDAO;
|
|
167
252
|
//# sourceMappingURL=route.dao.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"route.dao.js","sourceRoot":"","sources":["../../../src/dao/route/route.dao.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AACA,0EAA+C;AAI/C,MAAa,QAAQ;IAGnB,IAAY,IAAI;QACd,IAAI,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC;YAChB,IAAI,CAAC,KAAK,GAAG,wBAAW,CAAC,aAAa,EAAE,CAAC;QAC3C,CA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ver-tracking.dao";
|
|
2
|
+
export { EventDAO } from "./dao/event/event.dao";
|
|
3
|
+
export { GPSLocationDAO } from "./dao/gps-location/gps-location.dao";
|
|
3
4
|
export { RoleDAO } from "./dao/role/role.dao";
|
|
4
|
-
export {
|
|
5
|
+
export { RouteDAO } from "./dao/route/route.dao";
|
|
5
6
|
export { RouteAssignmentDAO } from "./dao/route-assignment/route-assignment.dao";
|
|
7
|
+
export { SundaysPackageVersionDAO } from "./dao/sundays-package-version/sundays-package-version.dao";
|
|
6
8
|
export { TripDAO } from "./dao/trip/trip.dao";
|
|
7
|
-
export {
|
|
8
|
-
export { DriverTrackingDAO } from "./dao/driver-tracking/driver-tracking.dao";
|
|
9
|
+
export { UserDAO } from "./dao/user/user.dao";
|
|
9
10
|
export { IDataPaginator } from "./d.types";
|
|
10
|
-
export {
|
|
11
|
-
export {
|
|
11
|
+
export { IDriverTracking, IDriverTrackingCreate, IDriverTrackingBatchCreate, ITrackingPoint, ITrackingMetadata, IActiveDriver, ITrackingSession, ITrackingFilters, } from "./interfaces/driver-tracking/driver-tracking.interfaces";
|
|
12
|
+
export { IEvent, IEventCreate, IEventUpdate, } from "./interfaces/event/event.interfaces";
|
|
13
|
+
export { IGPSLocation, IGPSLocationWithDistance, ITripLocationSummary, } from "./interfaces/gps-location/gps-location.interfaces";
|
|
12
14
|
export { IRole } from "./interfaces/role/role.interfaces";
|
|
13
|
-
export {
|
|
15
|
+
export { IRoute, IRouteInstruction } from "./interfaces/route/route.interfaces";
|
|
14
16
|
export { IRouteAssignment } from "./interfaces/route-assignment/route-assignment.interfaces";
|
|
17
|
+
export { ISundaysPackageVersion } from "./interfaces/sundays-package-version/sundays-package-version.interfaces";
|
|
15
18
|
export { ITrip, ITripStop, ITripWithStops, } from "./interfaces/trip/trip.interfaces";
|
|
16
|
-
export {
|
|
17
|
-
export { IDriverTracking, IDriverTrackingCreate, IDriverTrackingBatchCreate, ITrackingPoint, ITrackingMetadata, IActiveDriver, ITrackingSession, ITrackingFilters, } from "./interfaces/driver-tracking/driver-tracking.interfaces";
|
|
19
|
+
export { IUser, IUserSafe, IRefreshToken, } from "./interfaces/user/user.interfaces";
|
|
18
20
|
import KnexManager from "./KnexConnection";
|
|
19
21
|
export { KnexManager };
|
package/dist/index.js
CHANGED
|
@@ -3,24 +3,26 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.KnexManager = exports.
|
|
6
|
+
exports.KnexManager = exports.UserDAO = exports.TripDAO = exports.SundaysPackageVersionDAO = exports.RouteAssignmentDAO = exports.RouteDAO = exports.RoleDAO = exports.GPSLocationDAO = exports.EventDAO = exports.DriverTrackingDAO = void 0;
|
|
7
7
|
// DAOs
|
|
8
|
-
var
|
|
9
|
-
Object.defineProperty(exports, "
|
|
10
|
-
var
|
|
11
|
-
Object.defineProperty(exports, "
|
|
8
|
+
var driver_tracking_dao_1 = require("./dao/driver-tracking/driver-tracking.dao");
|
|
9
|
+
Object.defineProperty(exports, "DriverTrackingDAO", { enumerable: true, get: function () { return driver_tracking_dao_1.DriverTrackingDAO; } });
|
|
10
|
+
var event_dao_1 = require("./dao/event/event.dao");
|
|
11
|
+
Object.defineProperty(exports, "EventDAO", { enumerable: true, get: function () { return event_dao_1.EventDAO; } });
|
|
12
|
+
var gps_location_dao_1 = require("./dao/gps-location/gps-location.dao");
|
|
13
|
+
Object.defineProperty(exports, "GPSLocationDAO", { enumerable: true, get: function () { return gps_location_dao_1.GPSLocationDAO; } });
|
|
12
14
|
var role_dao_1 = require("./dao/role/role.dao");
|
|
13
15
|
Object.defineProperty(exports, "RoleDAO", { enumerable: true, get: function () { return role_dao_1.RoleDAO; } });
|
|
14
|
-
var
|
|
15
|
-
Object.defineProperty(exports, "
|
|
16
|
+
var route_dao_1 = require("./dao/route/route.dao");
|
|
17
|
+
Object.defineProperty(exports, "RouteDAO", { enumerable: true, get: function () { return route_dao_1.RouteDAO; } });
|
|
16
18
|
var route_assignment_dao_1 = require("./dao/route-assignment/route-assignment.dao");
|
|
17
19
|
Object.defineProperty(exports, "RouteAssignmentDAO", { enumerable: true, get: function () { return route_assignment_dao_1.RouteAssignmentDAO; } });
|
|
20
|
+
var sundays_package_version_dao_1 = require("./dao/sundays-package-version/sundays-package-version.dao");
|
|
21
|
+
Object.defineProperty(exports, "SundaysPackageVersionDAO", { enumerable: true, get: function () { return sundays_package_version_dao_1.SundaysPackageVersionDAO; } });
|
|
18
22
|
var trip_dao_1 = require("./dao/trip/trip.dao");
|
|
19
23
|
Object.defineProperty(exports, "TripDAO", { enumerable: true, get: function () { return trip_dao_1.TripDAO; } });
|
|
20
|
-
var
|
|
21
|
-
Object.defineProperty(exports, "
|
|
22
|
-
var driver_tracking_dao_1 = require("./dao/driver-tracking/driver-tracking.dao");
|
|
23
|
-
Object.defineProperty(exports, "DriverTrackingDAO", { enumerable: true, get: function () { return driver_tracking_dao_1.DriverTrackingDAO; } });
|
|
24
|
+
var user_dao_1 = require("./dao/user/user.dao");
|
|
25
|
+
Object.defineProperty(exports, "UserDAO", { enumerable: true, get: function () { return user_dao_1.UserDAO; } });
|
|
24
26
|
const KnexConnection_1 = __importDefault(require("./KnexConnection"));
|
|
25
27
|
exports.KnexManager = KnexConnection_1.default;
|
|
26
28
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO;AACP,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO;AACP,iFAA8E;AAArE,wHAAA,iBAAiB,OAAA;AAC1B,mDAAiD;AAAxC,qGAAA,QAAQ,OAAA;AACjB,wEAAqE;AAA5D,kHAAA,cAAc,OAAA;AACvB,gDAA8C;AAArC,mGAAA,OAAO,OAAA;AAChB,mDAAiD;AAAxC,qGAAA,QAAQ,OAAA;AACjB,oFAAiF;AAAxE,0HAAA,kBAAkB,OAAA;AAC3B,yGAAqG;AAA5F,uIAAA,wBAAwB,OAAA;AACjC,gDAA8C;AAArC,mGAAA,OAAO,OAAA;AAChB,gDAA8C;AAArC,mGAAA,OAAO,OAAA;AAuChB,sEAA2C;AAClC,sBADF,wBAAW,CACE"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export interface IEvent {
|
|
2
|
+
id?: number;
|
|
3
|
+
uuid?: string;
|
|
4
|
+
name: string;
|
|
5
|
+
start_date?: Date | string | null;
|
|
6
|
+
end_date?: Date | string | null;
|
|
7
|
+
is_active?: boolean;
|
|
8
|
+
created_at?: Date | string;
|
|
9
|
+
updated_at?: Date | string;
|
|
10
|
+
}
|
|
11
|
+
export interface IEventCreate {
|
|
12
|
+
name: string;
|
|
13
|
+
start_date?: Date | string | null;
|
|
14
|
+
end_date?: Date | string | null;
|
|
15
|
+
is_active?: boolean;
|
|
16
|
+
}
|
|
17
|
+
export interface IEventUpdate {
|
|
18
|
+
name?: string;
|
|
19
|
+
start_date?: Date | string | null;
|
|
20
|
+
end_date?: Date | string | null;
|
|
21
|
+
is_active?: boolean;
|
|
22
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"event.interfaces.js","sourceRoot":"","sources":["../../../src/interfaces/event/event.interfaces.ts"],"names":[],"mappings":""}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { IEvent } from "../event/event.interfaces";
|
|
1
2
|
export interface IRoute {
|
|
2
3
|
id?: number;
|
|
3
4
|
uuid?: string;
|
|
@@ -7,6 +8,8 @@ export interface IRoute {
|
|
|
7
8
|
custom_instructions?: any[];
|
|
8
9
|
distance?: number;
|
|
9
10
|
estimated_duration?: number;
|
|
11
|
+
event_id?: number;
|
|
12
|
+
event?: IEvent;
|
|
10
13
|
is_active?: boolean;
|
|
11
14
|
created_at?: Date;
|
|
12
15
|
updated_at?: Date;
|