Skip to content

Commit e440afe

Browse files
chore: Merge pull request #41 from mindfiredigital/changeset-release/main
Version Packages
2 parents ab4fd74 + b8799d6 commit e440afe

File tree

9 files changed

+1129
-1
lines changed

9 files changed

+1129
-1
lines changed

packages/monoapp/CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# @mindfiredigital/monodog
22

3+
## 1.2.0
4+
5+
### Minor Changes
6+
7+
- Merge pull request #40 from mindfiredigital/development
8+
39
## 1.1.3
410

511
### Patch Changes

packages/monoapp/dist/controllers/publish-controller.js

Lines changed: 458 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
"use strict";
2+
Object.defineProperty(exports, "__esModule", { value: true });
3+
exports.PipelineAuditLogRepository = void 0;
4+
const prisma_client_1 = require("./prisma-client");
5+
const prisma = (0, prisma_client_1.getPrismaClient)();
6+
/**
7+
* Pipeline Audit Log Repository - Handles all PipelineAuditLog-related database operations
8+
*/
9+
class PipelineAuditLogRepository {
10+
/**
11+
* Create an audit log entry
12+
*/
13+
static async create(pipelineId, userId, username, action, resourceType, resourceId, resourceName, details = {}, status = 'success', errorMessage) {
14+
await prisma.pipelineAuditLog.create({
15+
data: {
16+
pipelineId,
17+
userId,
18+
username,
19+
action,
20+
resourceType,
21+
resourceId,
22+
resourceName,
23+
details: JSON.stringify(details),
24+
status,
25+
errorMessage,
26+
},
27+
});
28+
}
29+
/**
30+
* Get audit logs for a pipeline
31+
*/
32+
static async findByPipelineId(pipelineId, limit = 50, offset = 0) {
33+
return await prisma.pipelineAuditLog.findMany({
34+
where: { pipelineId },
35+
orderBy: { timestamp: 'desc' },
36+
take: limit,
37+
skip: offset,
38+
});
39+
}
40+
/**
41+
* Get audit logs by action
42+
*/
43+
static async findByAction(action, limit = 50, offset = 0) {
44+
return await prisma.pipelineAuditLog.findMany({
45+
where: { action },
46+
orderBy: { timestamp: 'desc' },
47+
take: limit,
48+
skip: offset,
49+
});
50+
}
51+
/**
52+
* Get audit logs by user
53+
*/
54+
static async findByUser(userId, limit = 50, offset = 0) {
55+
return await prisma.pipelineAuditLog.findMany({
56+
where: { userId },
57+
orderBy: { timestamp: 'desc' },
58+
take: limit,
59+
skip: offset,
60+
});
61+
}
62+
/**
63+
* Get audit logs by status
64+
*/
65+
static async findByStatus(status, limit = 50, offset = 0) {
66+
return await prisma.pipelineAuditLog.findMany({
67+
where: { status },
68+
orderBy: { timestamp: 'desc' },
69+
take: limit,
70+
skip: offset,
71+
});
72+
}
73+
/**
74+
* Get count of audit logs for a pipeline
75+
*/
76+
static async countByPipelineId(pipelineId) {
77+
return await prisma.pipelineAuditLog.count({
78+
where: { pipelineId },
79+
});
80+
}
81+
}
82+
exports.PipelineAuditLogRepository = PipelineAuditLogRepository;
Lines changed: 123 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+
"use strict";
2+
Object.defineProperty(exports, "__esModule", { value: true });
3+
exports.ReleasePipelineRepository = void 0;
4+
const prisma_client_1 = require("./prisma-client");
5+
const prisma = (0, prisma_client_1.getPrismaClient)();
6+
/**
7+
* Release Pipeline Repository - Handles all ReleasePipeline-related database operations
8+
*/
9+
class ReleasePipelineRepository {
10+
/**
11+
* Create or update a release pipeline
12+
*/
13+
static async createOrUpdate(pipeline) {
14+
const existing = await prisma.releasePipeline.findFirst({
15+
where: {
16+
releaseVersion: pipeline.releaseVersion,
17+
packageName: pipeline.packageName,
18+
owner: pipeline.owner,
19+
repo: pipeline.repo,
20+
},
21+
});
22+
let result;
23+
if (existing) {
24+
result = await prisma.releasePipeline.update({
25+
where: { id: existing.id },
26+
data: {
27+
currentStatus: pipeline.currentStatus,
28+
currentConclusion: pipeline.currentConclusion,
29+
lastRunId: pipeline.lastRunId ? String(pipeline.lastRunId) : null,
30+
triggeredAt: pipeline.triggeredAt,
31+
},
32+
});
33+
}
34+
else {
35+
result = await prisma.releasePipeline.create({
36+
data: {
37+
releaseVersion: pipeline.releaseVersion,
38+
packageName: pipeline.packageName,
39+
owner: pipeline.owner,
40+
repo: pipeline.repo,
41+
workflowId: pipeline.workflowId,
42+
workflowName: pipeline.workflowName,
43+
workflowPath: pipeline.workflowPath,
44+
triggerType: pipeline.triggerType,
45+
triggeredBy: pipeline.triggeredBy,
46+
triggeredAt: pipeline.triggeredAt,
47+
currentStatus: pipeline.currentStatus,
48+
currentConclusion: pipeline.currentConclusion,
49+
lastRunId: pipeline.lastRunId ? String(pipeline.lastRunId) : null,
50+
},
51+
});
52+
}
53+
return {
54+
id: result.id,
55+
releaseVersion: result.releaseVersion,
56+
packageName: result.packageName,
57+
};
58+
}
59+
/**
60+
* Update pipeline status and conclusion
61+
*/
62+
static async updateStatus(pipelineId, currentStatus, currentConclusion, lastRunId) {
63+
return await prisma.releasePipeline.update({
64+
where: { id: pipelineId },
65+
data: {
66+
currentStatus,
67+
currentConclusion,
68+
...(lastRunId && { lastRunId: String(lastRunId) }),
69+
updatedAt: new Date(),
70+
},
71+
});
72+
}
73+
/**
74+
* Get recent pipelines for dashboard
75+
*/
76+
static async getRecent(limit = 20, offset = 0) {
77+
const pipelines = await prisma.releasePipeline.findMany({
78+
orderBy: { triggeredAt: 'desc' },
79+
take: limit,
80+
skip: offset,
81+
});
82+
// Enrich with workflowPath if not already set
83+
return pipelines.map((p) => ({
84+
...p,
85+
workflowPath: p.workflowPath || 'release.yml',
86+
}));
87+
}
88+
/**
89+
* Delete old pipelines (cleanup)
90+
*/
91+
static async deleteOld(daysOld = 90) {
92+
const cutoffDate = new Date();
93+
cutoffDate.setDate(cutoffDate.getDate() - daysOld);
94+
const result = await prisma.releasePipeline.deleteMany({
95+
where: {
96+
createdAt: {
97+
lt: cutoffDate,
98+
},
99+
},
100+
});
101+
return result.count;
102+
}
103+
/**
104+
* Find pipeline by ID
105+
*/
106+
static async findById(id) {
107+
return await prisma.releasePipeline.findUnique({
108+
where: { id },
109+
});
110+
}
111+
/**
112+
* Find pipeline by release version and package name
113+
*/
114+
static async findByReleaseAndPackage(releaseVersion, packageName) {
115+
return await prisma.releasePipeline.findFirst({
116+
where: {
117+
releaseVersion,
118+
packageName,
119+
},
120+
});
121+
}
122+
}
123+
exports.ReleasePipelineRepository = ReleasePipelineRepository;
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
"use strict";
2+
var __importDefault = (this && this.__importDefault) || function (mod) {
3+
return (mod && mod.__esModule) ? mod : { "default": mod };
4+
};
5+
Object.defineProperty(exports, "__esModule", { value: true });
6+
const express_1 = __importDefault(require("express"));
7+
const publish_controller_1 = require("../controllers/publish-controller");
8+
const auth_middleware_1 = require("../middleware/auth-middleware");
9+
const publishRouter = express_1.default.Router();
10+
/**
11+
* GET /api/publish/packages
12+
* Get all workspace packages for publishing
13+
* Requires: read permission
14+
*/
15+
publishRouter.get('/packages', auth_middleware_1.authenticationMiddleware, publish_controller_1.getPublishPackages);
16+
/**
17+
* GET /api/publish/changesets
18+
* Get existing unpublished changesets
19+
* Requires: read permission
20+
*/
21+
publishRouter.get('/changesets', auth_middleware_1.authenticationMiddleware, publish_controller_1.getPublishChangesets);
22+
/**
23+
* POST /api/publish/preview
24+
* Preview the publish plan (calculate new versions, affected packages)
25+
* Requires: read permission
26+
*/
27+
publishRouter.post('/preview', auth_middleware_1.authenticationMiddleware, publish_controller_1.previewPublish);
28+
/**
29+
* POST /api/publish/changesets
30+
* Create a new changeset for the selected packages
31+
* Requires: write permission
32+
*/
33+
publishRouter.post('/changesets', auth_middleware_1.authenticationMiddleware, (0, auth_middleware_1.repositoryPermissionMiddleware)('write'), publish_controller_1.createChangeset);
34+
/**
35+
* GET /api/publish/status
36+
* Check publish readiness (working tree, changesets, etc.)
37+
* Requires: read permission
38+
*/
39+
publishRouter.get('/status', auth_middleware_1.authenticationMiddleware, publish_controller_1.checkPublishStatus);
40+
/**
41+
* POST /api/publish/trigger
42+
* Trigger the publishing workflow
43+
* Requires: maintain permission
44+
*/
45+
publishRouter.post('/trigger', auth_middleware_1.authenticationMiddleware, (0, auth_middleware_1.repositoryPermissionMiddleware)('maintain'), publish_controller_1.triggerPublish);
46+
exports.default = publishRouter;

0 commit comments

Comments
 (0)