@meyicloud/meyi-insight-server 1.1.9 → 1.1.11
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/controllers/incident.controller.d.ts.map +1 -1
- package/dist/controllers/incident.controller.js +2 -0
- package/dist/controllers/incident.controller.js.map +1 -1
- package/dist/database/schema.d.ts +218 -0
- package/dist/database/schema.d.ts.map +1 -1
- package/dist/database/schema.js +28 -1
- package/dist/database/schema.js.map +1 -1
- package/dist/features/incident-groups/incident-group.controller.d.ts +17 -0
- package/dist/features/incident-groups/incident-group.controller.d.ts.map +1 -0
- package/dist/features/incident-groups/incident-group.controller.js +105 -0
- package/dist/features/incident-groups/incident-group.controller.js.map +1 -0
- package/dist/features/incident-groups/incident-group.model.d.ts +58 -0
- package/dist/features/incident-groups/incident-group.model.d.ts.map +1 -0
- package/dist/features/incident-groups/incident-group.model.js +159 -0
- package/dist/features/incident-groups/incident-group.model.js.map +1 -0
- package/dist/features/incident-groups/incident-group.routes.d.ts +5 -0
- package/dist/features/incident-groups/incident-group.routes.d.ts.map +1 -0
- package/dist/features/incident-groups/incident-group.routes.js +13 -0
- package/dist/features/incident-groups/incident-group.routes.js.map +1 -0
- package/dist/features/incident-groups/incident-group.service.d.ts +67 -0
- package/dist/features/incident-groups/incident-group.service.d.ts.map +1 -0
- package/dist/features/incident-groups/incident-group.service.js +154 -0
- package/dist/features/incident-groups/incident-group.service.js.map +1 -0
- package/dist/features/incident-groups/index.d.ts +4 -0
- package/dist/features/incident-groups/index.d.ts.map +1 -0
- package/dist/features/incident-groups/index.js +4 -0
- package/dist/features/incident-groups/index.js.map +1 -0
- package/dist/migrations/run.d.ts.map +1 -1
- package/dist/migrations/run.js +1312 -1285
- package/dist/migrations/run.js.map +1 -1
- package/dist/models/alert.model.js +2 -2
- package/dist/models/incident.model.d.ts +21 -12
- package/dist/models/incident.model.d.ts.map +1 -1
- package/dist/models/incident.model.js +40 -15
- package/dist/models/incident.model.js.map +1 -1
- package/dist/routes/index.d.ts +2 -0
- package/dist/routes/index.d.ts.map +1 -1
- package/dist/routes/index.js +4 -0
- package/dist/routes/index.js.map +1 -1
- package/dist/server.d.ts.map +1 -1
- package/dist/server.js +1 -0
- package/dist/server.js.map +1 -1
- package/dist/service.d.ts +8 -3
- package/dist/service.d.ts.map +1 -1
- package/dist/service.js +5 -0
- package/dist/service.js.map +1 -1
- package/dist/services/incident.service.d.ts +29 -3
- package/dist/services/incident.service.d.ts.map +1 -1
- package/dist/services/incident.service.js +37 -3
- package/dist/services/incident.service.js.map +1 -1
- package/dist/services/retention.service.d.ts +2 -1
- package/dist/services/retention.service.d.ts.map +1 -1
- package/dist/services/retention.service.js +99 -96
- package/dist/services/retention.service.js.map +1 -1
- package/dist/utils/workflowYaml.d.ts +1 -0
- package/dist/utils/workflowYaml.d.ts.map +1 -1
- package/dist/utils/workflowYaml.js +6 -1
- package/dist/utils/workflowYaml.js.map +1 -1
- package/package.json +75 -75
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import { resolveTenantId } from "../../tenancy.js";
|
|
2
|
+
import { parseEnvironmentQuery } from "../connector-environment/environment.query.js";
|
|
3
|
+
import { normalizePriority } from "../incident-priority/priority.rules.js";
|
|
4
|
+
import { IncidentGroupError } from "./incident-group.service.js";
|
|
5
|
+
function parseMultiQuery(value) {
|
|
6
|
+
const rawValues = Array.isArray(value) ? value : value ? [value] : [];
|
|
7
|
+
return rawValues
|
|
8
|
+
.flatMap((item) => String(item).split(","))
|
|
9
|
+
.map((item) => item.trim())
|
|
10
|
+
.filter((item) => item && item !== "all");
|
|
11
|
+
}
|
|
12
|
+
function actor(req) {
|
|
13
|
+
const u = req.user;
|
|
14
|
+
if (!u)
|
|
15
|
+
return { id: null, name: null };
|
|
16
|
+
return {
|
|
17
|
+
id: u.id ? String(u.id) : null,
|
|
18
|
+
name: u.full_name || u.fullName || u.name || u.email || null,
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
function sendError(res, e) {
|
|
22
|
+
if (e instanceof IncidentGroupError) {
|
|
23
|
+
return res.status(e.status).json({ ok: false, error: e.message, ...(e.details ?? {}) });
|
|
24
|
+
}
|
|
25
|
+
return res.status(500).json({ ok: false, error: e?.cause?.message ? `${e.message} - ${e.cause.message}` : e?.message });
|
|
26
|
+
}
|
|
27
|
+
export function createIncidentGroupController(service) {
|
|
28
|
+
return {
|
|
29
|
+
/**
|
|
30
|
+
* GET /incident-groups — accepts the same filter query as GET /incidents (search, status, assigneeId,
|
|
31
|
+
* accountNames, priorities, environment, incidentType, sourceTypes), parsed the same way, so a group
|
|
32
|
+
* appears exactly when one of its members would appear in the list.
|
|
33
|
+
*/
|
|
34
|
+
async list(req, res) {
|
|
35
|
+
try {
|
|
36
|
+
const user = req.user;
|
|
37
|
+
const requestedAssigneeIds = parseMultiQuery(req.query.assigneeId);
|
|
38
|
+
const assigneeIds = requestedAssigneeIds.length > 0
|
|
39
|
+
? requestedAssigneeIds
|
|
40
|
+
: (user?.role === "user" ? [user.id] : undefined);
|
|
41
|
+
const sourceTypes = parseMultiQuery(req.query.sourceTypes);
|
|
42
|
+
const accountNames = parseMultiQuery(req.query.accountName || req.query.accountNames || req.query.accounts);
|
|
43
|
+
const env = parseEnvironmentQuery(req);
|
|
44
|
+
if (env.ok === false)
|
|
45
|
+
return res.status(400).json({ ok: false, error: env.error });
|
|
46
|
+
const priorities = parseMultiQuery(req.query.priorities || req.query.priority).map(normalizePriority);
|
|
47
|
+
if (priorities.some((p) => p === null))
|
|
48
|
+
return res.status(400).json({ ok: false, error: "Invalid priority" });
|
|
49
|
+
const groups = await service.list({
|
|
50
|
+
search: typeof req.query.search === "string" ? req.query.search : undefined,
|
|
51
|
+
assigneeIds,
|
|
52
|
+
statuses: parseMultiQuery(req.query.status),
|
|
53
|
+
sourceTypes: sourceTypes.length > 0 ? sourceTypes : undefined,
|
|
54
|
+
accountNames: accountNames.length > 0 ? accountNames : undefined,
|
|
55
|
+
environment: env.environment,
|
|
56
|
+
priorities: priorities.length > 0 ? priorities : undefined,
|
|
57
|
+
incidentType: (req.query.incidentType || req.query.category || req.query.type),
|
|
58
|
+
tenantId: resolveTenantId(req),
|
|
59
|
+
});
|
|
60
|
+
return res.json({ ok: true, groups });
|
|
61
|
+
}
|
|
62
|
+
catch (e) {
|
|
63
|
+
return sendError(res, e);
|
|
64
|
+
}
|
|
65
|
+
},
|
|
66
|
+
/** POST /incident-groups { incidentIds: string[], name?: string } */
|
|
67
|
+
async create(req, res) {
|
|
68
|
+
try {
|
|
69
|
+
const who = actor(req);
|
|
70
|
+
const group = await service.create({
|
|
71
|
+
tenantId: resolveTenantId(req),
|
|
72
|
+
name: req.body?.name,
|
|
73
|
+
incidentIds: req.body?.incidentIds,
|
|
74
|
+
actorId: who.id,
|
|
75
|
+
actorName: who.name,
|
|
76
|
+
});
|
|
77
|
+
return res.status(201).json({ ok: true, group });
|
|
78
|
+
}
|
|
79
|
+
catch (e) {
|
|
80
|
+
return sendError(res, e);
|
|
81
|
+
}
|
|
82
|
+
},
|
|
83
|
+
/** DELETE /incident-groups/:id/incidents/:incidentId — remove one incident; dissolves the group below 2. */
|
|
84
|
+
async removeIncident(req, res) {
|
|
85
|
+
try {
|
|
86
|
+
const result = await service.removeIncident(req.params.id, req.params.incidentId, resolveTenantId(req));
|
|
87
|
+
return res.json({ ok: true, ...result });
|
|
88
|
+
}
|
|
89
|
+
catch (e) {
|
|
90
|
+
return sendError(res, e);
|
|
91
|
+
}
|
|
92
|
+
},
|
|
93
|
+
/** DELETE /incident-groups/:id — ungroup every incident (incidents themselves are untouched). */
|
|
94
|
+
async dissolve(req, res) {
|
|
95
|
+
try {
|
|
96
|
+
await service.dissolve(req.params.id, resolveTenantId(req));
|
|
97
|
+
return res.json({ ok: true });
|
|
98
|
+
}
|
|
99
|
+
catch (e) {
|
|
100
|
+
return sendError(res, e);
|
|
101
|
+
}
|
|
102
|
+
},
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
//# sourceMappingURL=incident-group.controller.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"incident-group.controller.js","sourceRoot":"","sources":["../../../src/features/incident-groups/incident-group.controller.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AACnD,OAAO,EAAE,qBAAqB,EAAE,MAAM,+CAA+C,CAAC;AACtF,OAAO,EAAE,iBAAiB,EAAE,MAAM,wCAAwC,CAAC;AAE3E,OAAO,EAAE,kBAAkB,EAA6B,MAAM,6BAA6B,CAAC;AAE5F,SAAS,eAAe,CAAC,KAAc;IACrC,MAAM,SAAS,GAAG,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;IACtE,OAAO,SAAS;SACb,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;SAC1C,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC;SAC1B,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,IAAI,IAAI,KAAK,KAAK,CAAC,CAAC;AAC9C,CAAC;AAED,SAAS,KAAK,CAAC,GAAY;IACzB,MAAM,CAAC,GAAI,GAAW,CAAC,IAAI,CAAC;IAC5B,IAAI,CAAC,CAAC;QAAE,OAAO,EAAE,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC;IACxC,OAAO;QACL,EAAE,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,IAAI;QAC9B,IAAI,EAAE,CAAC,CAAC,SAAS,IAAI,CAAC,CAAC,QAAQ,IAAI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3B,CAAC;QACH,CAAC;QAED,4GAA4G;QAC5G,KAAK,CAAC,cAAc,CAAC,GAAY,EAAE,GAAa;YAC9C,IAAI,CAAC;gBACH,MAAM,MAAM,GAAG,MAAM,OAAO,CAAC,cAAc,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,EAAE,GAAG,CAAC,MAAM,CAAC,UAAU,EAAE,eAAe,CAAC,GAAG,CAAC,CAAC,CAAC;gBACxG,OAAO,GAAG,CAAC,IAAI,CAAC,EAAE,EAAE,EAAE,IAAI,EAAE,GAAG,MAAM,EAAE,CAAC,CAAC;YAC3C,CAAC;YAAC,OAAO,CAAM,EAAE,CAAC;gBAChB,OAAO,SAAS,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC;YAC3B,CAAC;QACH,CAAC;QAED,iGAAiG;QACjG,KAAK,CAAC,QAAQ,CAAC,GAAY,EAAE,GAAa;YACxC,IAAI,CAAC;gBACH,MAAM,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,EAAE,eAAe,CAAC,GAAG,CAAC,CAAC,CAAC;gBAC5D,OAAO,GAAG,CAAC,IAAI,CAAC,EAAE,EAAE,EAAE,IAAI,EAAE,CAAC,CAAC;YAChC,CAAC;YAAC,OAAO,CAAM,EAAE,CAAC;gBAChB,OAAO,SAAS,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC;YAC3B,CAAC;QACH,CAAC;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
export declare const INCIDENT_GROUP_MEMBER_UNIQUE_INDEX = "insight_incident_group_members_incident_uq";
|
|
2
|
+
export interface IncidentGroupRow {
|
|
3
|
+
id: string;
|
|
4
|
+
tenantId: string;
|
|
5
|
+
name: string;
|
|
6
|
+
incidentType: string;
|
|
7
|
+
createdBy: string | null;
|
|
8
|
+
createdByName: string | null;
|
|
9
|
+
createdAt: string;
|
|
10
|
+
updatedAt: string;
|
|
11
|
+
}
|
|
12
|
+
export interface IncidentGroupWithMembers extends IncidentGroupRow {
|
|
13
|
+
incidentIds: string[];
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Manual incident groups (user-created, persisted). Every statement is tenant-scoped and parameterized.
|
|
17
|
+
* Grouping never touches insight_incidents rows: membership lives only in insight_incident_group_members.
|
|
18
|
+
*/
|
|
19
|
+
export declare class IncidentGroupModel {
|
|
20
|
+
private db;
|
|
21
|
+
constructor(db: any);
|
|
22
|
+
/** Members among `incidentIds` that already belong to a group in this tenant. */
|
|
23
|
+
findMemberships(incidentIds: string[], tenantId: string): Promise<Array<{
|
|
24
|
+
incidentId: string;
|
|
25
|
+
groupId: string;
|
|
26
|
+
}>>;
|
|
27
|
+
/**
|
|
28
|
+
* Creates a group and its members in one transaction. Throws "INCIDENT_ALREADY_GROUPED" when a
|
|
29
|
+
* concurrent request grouped one of the incidents first (unique index on incident_id).
|
|
30
|
+
*/
|
|
31
|
+
create(input: {
|
|
32
|
+
tenantId: string;
|
|
33
|
+
name: string;
|
|
34
|
+
incidentType: string;
|
|
35
|
+
incidentIds: string[];
|
|
36
|
+
createdBy: string | null;
|
|
37
|
+
createdByName: string | null;
|
|
38
|
+
}): Promise<IncidentGroupRow>;
|
|
39
|
+
/**
|
|
40
|
+
* Deletes groups left with fewer than two members (e.g. after an incident was deleted and its
|
|
41
|
+
* membership cascaded away). Their remaining incident shows in the main list again.
|
|
42
|
+
*/
|
|
43
|
+
dissolveUndersized(tenantId: string): Promise<void>;
|
|
44
|
+
/** Groups (2+ members) with their member ids, newest first. Optionally limited to one incident type. */
|
|
45
|
+
listWithMembers(tenantId: string, incidentType?: string): Promise<IncidentGroupWithMembers[]>;
|
|
46
|
+
findById(groupId: string, tenantId: string): Promise<IncidentGroupRow | null>;
|
|
47
|
+
/**
|
|
48
|
+
* Removes one incident from a group. When fewer than two members remain the group is dissolved.
|
|
49
|
+
* Returns null when the incident is not a member of that group.
|
|
50
|
+
*/
|
|
51
|
+
removeMember(groupId: string, incidentId: string, tenantId: string): Promise<{
|
|
52
|
+
dissolved: boolean;
|
|
53
|
+
remaining: number;
|
|
54
|
+
} | null>;
|
|
55
|
+
/** Dissolves a group (members cascade). Incidents themselves are untouched. Returns false if not found. */
|
|
56
|
+
delete(groupId: string, tenantId: string): Promise<boolean>;
|
|
57
|
+
}
|
|
58
|
+
//# sourceMappingURL=incident-group.model.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"incident-group.model.d.ts","sourceRoot":"","sources":["../../../src/features/incident-groups/incident-group.model.ts"],"names":[],"mappings":"AAWA,eAAO,MAAM,kCAAkC,+CAA+C,CAAC;AAE/F,MAAM,WAAW,gBAAgB;IAC/B,EAAE,EAAE,MAAM,CAAC;IACX,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,YAAY,EAAE,MAAM,CAAC;IACrB,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,aAAa,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,wBAAyB,SAAQ,gBAAgB;IAChE,WAAW,EAAE,MAAM,EAAE,CAAC;CACvB;AAeD;;;GAGG;AACH,qBAAa,kBAAkB;IACjB,OAAO,CAAC,EAAE;gBAAF,EAAE,EAAE,GAAG;IAE3B,iFAAiF;IAC3E,eAAe,CAAC,WAAW,EAAE,MAAM,EAAE,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,KAAK,CAAC;QAAE,UAAU,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAWvH;;;OAGG;IACG,MAAM,CAAC,KAAK,EAAE;QAClB,QAAQ,EAAE,MAAM,CAAC;QACjB,IAAI,EAAE,MAAM,CAAC;QACb,YAAY,EAAE,MAAM,CAAC;QACrB,WAAW,EAAE,MAAM,EAAE,CAAC;QACtB,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;QACzB,aAAa,EAAE,MAAM,GAAG,IAAI,CAAC;KAC9B,GAAG,OAAO,CAAC,gBAAgB,CAAC;IAwB7B;;;OAGG;IACG,kBAAkB,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAQzD,wGAAwG;IAClG,eAAe,CAAC,QAAQ,EAAE,MAAM,EAAE,YAAY,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,wBAAwB,EAAE,CAAC;IAsB7F,QAAQ,CAAC,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,gBAAgB,GAAG,IAAI,CAAC;IAUnF;;;OAGG;IACG,YAAY,CAAC,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC;QAAE,SAAS,EAAE,OAAO,CAAC;QAAC,SAAS,EAAE,MAAM,CAAA;KAAE,GAAG,IAAI,CAAC;IAiCpI,2GAA2G;IACrG,MAAM,CAAC,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;CAQlE"}
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
import { sql } from "drizzle-orm";
|
|
2
|
+
/** Postgres unique_violation, possibly wrapped by drizzle (DrizzleQueryError.cause). */
|
|
3
|
+
function pgCode(err) {
|
|
4
|
+
return err?.code ?? err?.cause?.code;
|
|
5
|
+
}
|
|
6
|
+
function rowsOf(res) {
|
|
7
|
+
return res?.rows ?? (Array.isArray(res) ? res : []);
|
|
8
|
+
}
|
|
9
|
+
export const INCIDENT_GROUP_MEMBER_UNIQUE_INDEX = "insight_incident_group_members_incident_uq";
|
|
10
|
+
function toGroup(r) {
|
|
11
|
+
return {
|
|
12
|
+
id: String(r.id),
|
|
13
|
+
tenantId: String(r.tenant_id),
|
|
14
|
+
name: r.name,
|
|
15
|
+
incidentType: r.incident_type,
|
|
16
|
+
createdBy: r.created_by ?? null,
|
|
17
|
+
createdByName: r.created_by_name ?? null,
|
|
18
|
+
createdAt: r.created_at instanceof Date ? r.created_at.toISOString() : String(r.created_at),
|
|
19
|
+
updatedAt: r.updated_at instanceof Date ? r.updated_at.toISOString() : String(r.updated_at),
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Manual incident groups (user-created, persisted). Every statement is tenant-scoped and parameterized.
|
|
24
|
+
* Grouping never touches insight_incidents rows: membership lives only in insight_incident_group_members.
|
|
25
|
+
*/
|
|
26
|
+
export class IncidentGroupModel {
|
|
27
|
+
db;
|
|
28
|
+
constructor(db) {
|
|
29
|
+
this.db = db;
|
|
30
|
+
}
|
|
31
|
+
/** Members among `incidentIds` that already belong to a group in this tenant. */
|
|
32
|
+
async findMemberships(incidentIds, tenantId) {
|
|
33
|
+
if (!incidentIds.length)
|
|
34
|
+
return [];
|
|
35
|
+
const res = await this.db.execute(sql `
|
|
36
|
+
SELECT m.incident_id, m.group_id
|
|
37
|
+
FROM "meyiconnect"."insight_incident_group_members" m
|
|
38
|
+
WHERE m.tenant_id = ${tenantId}
|
|
39
|
+
AND m.incident_id IN (${sql.join(incidentIds.map((id) => sql `${id}::uuid`), sql `, `)})
|
|
40
|
+
`);
|
|
41
|
+
return rowsOf(res).map((r) => ({ incidentId: String(r.incident_id), groupId: String(r.group_id) }));
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Creates a group and its members in one transaction. Throws "INCIDENT_ALREADY_GROUPED" when a
|
|
45
|
+
* concurrent request grouped one of the incidents first (unique index on incident_id).
|
|
46
|
+
*/
|
|
47
|
+
async create(input) {
|
|
48
|
+
try {
|
|
49
|
+
return await this.db.transaction(async (tx) => {
|
|
50
|
+
const res = await tx.execute(sql `
|
|
51
|
+
INSERT INTO "meyiconnect"."insight_incident_groups" (tenant_id, name, incident_type, created_by, created_by_name)
|
|
52
|
+
VALUES (${input.tenantId}, ${input.name}, ${input.incidentType}, ${input.createdBy}, ${input.createdByName})
|
|
53
|
+
RETURNING *
|
|
54
|
+
`);
|
|
55
|
+
const group = toGroup(rowsOf(res)[0]);
|
|
56
|
+
await tx.execute(sql `
|
|
57
|
+
INSERT INTO "meyiconnect"."insight_incident_group_members" (group_id, incident_id, tenant_id)
|
|
58
|
+
VALUES ${sql.join(input.incidentIds.map((id) => sql `(${group.id}::uuid, ${id}::uuid, ${input.tenantId})`), sql `, `)}
|
|
59
|
+
`);
|
|
60
|
+
return group;
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
catch (err) {
|
|
64
|
+
if (pgCode(err) === "23505")
|
|
65
|
+
throw new Error("INCIDENT_ALREADY_GROUPED");
|
|
66
|
+
throw err;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Deletes groups left with fewer than two members (e.g. after an incident was deleted and its
|
|
71
|
+
* membership cascaded away). Their remaining incident shows in the main list again.
|
|
72
|
+
*/
|
|
73
|
+
async dissolveUndersized(tenantId) {
|
|
74
|
+
await this.db.execute(sql `
|
|
75
|
+
DELETE FROM "meyiconnect"."insight_incident_groups" g
|
|
76
|
+
WHERE g.tenant_id = ${tenantId}
|
|
77
|
+
AND (SELECT COUNT(*) FROM "meyiconnect"."insight_incident_group_members" m WHERE m.group_id = g.id) < 2
|
|
78
|
+
`);
|
|
79
|
+
}
|
|
80
|
+
/** Groups (2+ members) with their member ids, newest first. Optionally limited to one incident type. */
|
|
81
|
+
async listWithMembers(tenantId, incidentType) {
|
|
82
|
+
const typeCond = incidentType ? sql `AND g.incident_type = ${incidentType}` : sql ``;
|
|
83
|
+
const res = await this.db.execute(sql `
|
|
84
|
+
SELECT g.*, m.incident_id
|
|
85
|
+
FROM "meyiconnect"."insight_incident_groups" g
|
|
86
|
+
JOIN "meyiconnect"."insight_incident_group_members" m ON m.group_id = g.id
|
|
87
|
+
WHERE g.tenant_id = ${tenantId} ${typeCond}
|
|
88
|
+
ORDER BY g.created_at DESC, g.id, m.created_at ASC
|
|
89
|
+
`);
|
|
90
|
+
const byId = new Map();
|
|
91
|
+
for (const r of rowsOf(res)) {
|
|
92
|
+
const id = String(r.id);
|
|
93
|
+
let g = byId.get(id);
|
|
94
|
+
if (!g) {
|
|
95
|
+
g = { ...toGroup(r), incidentIds: [] };
|
|
96
|
+
byId.set(id, g);
|
|
97
|
+
}
|
|
98
|
+
g.incidentIds.push(String(r.incident_id));
|
|
99
|
+
}
|
|
100
|
+
return [...byId.values()].filter((g) => g.incidentIds.length >= 2);
|
|
101
|
+
}
|
|
102
|
+
async findById(groupId, tenantId) {
|
|
103
|
+
const res = await this.db.execute(sql `
|
|
104
|
+
SELECT * FROM "meyiconnect"."insight_incident_groups"
|
|
105
|
+
WHERE id = ${groupId}::uuid AND tenant_id = ${tenantId}
|
|
106
|
+
LIMIT 1
|
|
107
|
+
`);
|
|
108
|
+
const row = rowsOf(res)[0];
|
|
109
|
+
return row ? toGroup(row) : null;
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* Removes one incident from a group. When fewer than two members remain the group is dissolved.
|
|
113
|
+
* Returns null when the incident is not a member of that group.
|
|
114
|
+
*/
|
|
115
|
+
async removeMember(groupId, incidentId, tenantId) {
|
|
116
|
+
return this.db.transaction(async (tx) => {
|
|
117
|
+
// Lock the group row so concurrent removals see a consistent member count.
|
|
118
|
+
const locked = await tx.execute(sql `
|
|
119
|
+
SELECT id FROM "meyiconnect"."insight_incident_groups"
|
|
120
|
+
WHERE id = ${groupId}::uuid AND tenant_id = ${tenantId}
|
|
121
|
+
FOR UPDATE
|
|
122
|
+
`);
|
|
123
|
+
if (!rowsOf(locked).length)
|
|
124
|
+
return null;
|
|
125
|
+
const del = await tx.execute(sql `
|
|
126
|
+
DELETE FROM "meyiconnect"."insight_incident_group_members"
|
|
127
|
+
WHERE group_id = ${groupId}::uuid AND incident_id = ${incidentId}::uuid AND tenant_id = ${tenantId}
|
|
128
|
+
RETURNING incident_id
|
|
129
|
+
`);
|
|
130
|
+
if (!rowsOf(del).length)
|
|
131
|
+
return null;
|
|
132
|
+
const cnt = await tx.execute(sql `
|
|
133
|
+
SELECT COUNT(*)::int AS n FROM "meyiconnect"."insight_incident_group_members" WHERE group_id = ${groupId}::uuid
|
|
134
|
+
`);
|
|
135
|
+
const remaining = Number(rowsOf(cnt)[0]?.n ?? 0);
|
|
136
|
+
if (remaining < 2) {
|
|
137
|
+
await tx.execute(sql `
|
|
138
|
+
DELETE FROM "meyiconnect"."insight_incident_groups" WHERE id = ${groupId}::uuid AND tenant_id = ${tenantId}
|
|
139
|
+
`);
|
|
140
|
+
return { dissolved: true, remaining: 0 };
|
|
141
|
+
}
|
|
142
|
+
await tx.execute(sql `
|
|
143
|
+
UPDATE "meyiconnect"."insight_incident_groups" SET updated_at = NOW()
|
|
144
|
+
WHERE id = ${groupId}::uuid AND tenant_id = ${tenantId}
|
|
145
|
+
`);
|
|
146
|
+
return { dissolved: false, remaining };
|
|
147
|
+
});
|
|
148
|
+
}
|
|
149
|
+
/** Dissolves a group (members cascade). Incidents themselves are untouched. Returns false if not found. */
|
|
150
|
+
async delete(groupId, tenantId) {
|
|
151
|
+
const res = await this.db.execute(sql `
|
|
152
|
+
DELETE FROM "meyiconnect"."insight_incident_groups"
|
|
153
|
+
WHERE id = ${groupId}::uuid AND tenant_id = ${tenantId}
|
|
154
|
+
RETURNING id
|
|
155
|
+
`);
|
|
156
|
+
return rowsOf(res).length > 0;
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
//# sourceMappingURL=incident-group.model.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"incident-group.model.js","sourceRoot":"","sources":["../../../src/features/incident-groups/incident-group.model.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,aAAa,CAAC;AAElC,wFAAwF;AACxF,SAAS,MAAM,CAAC,GAAQ;IACtB,OAAO,GAAG,EAAE,IAAI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,CAAC,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC;YACjD,IAAI,SAAS,GAAG,CAAC,EAAE,CAAC;gBAClB,MAAM,EAAE,CAAC,OAAO,CAAC,GAAG,CAAA;2EAC+C,OAAO,0BAA0B,QAAQ;SAC3G,CAAC,CAAC;gBACH,OAAO,EAAE,SAAS,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC,EAAE,CAAC;YAC3C,CAAC;YACD,MAAM,EAAE,CAAC,OAAO,CAAC,GAAG,CAAA;;sBAEJ,OAAO,0BAA0B,QAAQ;OACxD,CAAC,CAAC;YACH,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,SAAS,EAAE,CAAC;QACzC,CAAC,CAAC,CAAC;IACL,CAAC;IAED,2GAA2G;IAC3G,KAAK,CAAC,MAAM,CAAC,OAAe,EAAE,QAAgB;QAC5C,MAAM,GAAG,GAAG,MAAM,IAAI,CAAC,EAAE,CAAC,OAAO,CAAC,GAAG,CAAA;;oBAErB,OAAO,0BAA0B,QAAQ;;KAExD,CAAC,CAAC;QACH,OAAO,MAAM,CAAC,GAAG,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC;IAChC,CAAC;CACF"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { Router } from "express";
|
|
2
|
+
import type { IncidentGroupService } from "./incident-group.service.js";
|
|
3
|
+
/** Mounted at /incident-groups, behind the same auth and RBAC gate as /incidents (role "user" is read-only). */
|
|
4
|
+
export declare function createIncidentGroupRouter(service: IncidentGroupService): Router;
|
|
5
|
+
//# sourceMappingURL=incident-group.routes.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"incident-group.routes.d.ts","sourceRoot":"","sources":["../../../src/features/incident-groups/incident-group.routes.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AAEjC,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,6BAA6B,CAAC;AAExE,gHAAgH;AAChH,wBAAgB,yBAAyB,CAAC,OAAO,EAAE,oBAAoB,GAAG,MAAM,CAU/E"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Router } from "express";
|
|
2
|
+
import { createIncidentGroupController } from "./incident-group.controller.js";
|
|
3
|
+
/** Mounted at /incident-groups, behind the same auth and RBAC gate as /incidents (role "user" is read-only). */
|
|
4
|
+
export function createIncidentGroupRouter(service) {
|
|
5
|
+
const router = Router();
|
|
6
|
+
const ctrl = createIncidentGroupController(service);
|
|
7
|
+
router.get("/", ctrl.list.bind(ctrl));
|
|
8
|
+
router.post("/", ctrl.create.bind(ctrl));
|
|
9
|
+
router.delete("/:id/incidents/:incidentId", ctrl.removeIncident.bind(ctrl));
|
|
10
|
+
router.delete("/:id", ctrl.dissolve.bind(ctrl));
|
|
11
|
+
return router;
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=incident-group.routes.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"incident-group.routes.js","sourceRoot":"","sources":["../../../src/features/incident-groups/incident-group.routes.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AACjC,OAAO,EAAE,6BAA6B,EAAE,MAAM,gCAAgC,CAAC;AAG/E,gHAAgH;AAChH,MAAM,UAAU,yBAAyB,CAAC,OAA6B;IACrE,MAAM,MAAM,GAAG,MAAM,EAAE,CAAC;IACxB,MAAM,IAAI,GAAG,6BAA6B,CAAC,OAAO,CAAC,CAAC;IAEpD,MAAM,CAAC,GAAG,CAAC,GAAG,EAAE,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;IACtC,MAAM,CAAC,IAAI,CAAC,GAAG,EAAE,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;IACzC,MAAM,CAAC,MAAM,CAAC,4BAA4B,EAAE,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;IAC5E,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;IAEhD,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import type { IncidentService } from "../../services/incident.service.js";
|
|
2
|
+
import type { ConnectorEnvironment } from "../connector-environment/environment.types.js";
|
|
3
|
+
import type { IncidentPriority } from "../incident-priority/priority.types.js";
|
|
4
|
+
import type { IncidentGroupModel } from "./incident-group.model.js";
|
|
5
|
+
export declare const INCIDENT_GROUP_LIMITS: Readonly<{
|
|
6
|
+
minMembers: 2;
|
|
7
|
+
maxMembers: 100;
|
|
8
|
+
maxNameLength: 120;
|
|
9
|
+
}>;
|
|
10
|
+
/** Expected client errors; the controller maps `status` to the HTTP status. */
|
|
11
|
+
export declare class IncidentGroupError extends Error {
|
|
12
|
+
readonly status: number;
|
|
13
|
+
readonly details?: Record<string, unknown>;
|
|
14
|
+
constructor(message: string, status: number, details?: Record<string, unknown>);
|
|
15
|
+
}
|
|
16
|
+
export interface IncidentGroupListFilters {
|
|
17
|
+
search?: string;
|
|
18
|
+
assigneeIds?: string[];
|
|
19
|
+
statuses?: string[];
|
|
20
|
+
sourceTypes?: string[];
|
|
21
|
+
accountNames?: string[];
|
|
22
|
+
environment?: ConnectorEnvironment;
|
|
23
|
+
priorities?: IncidentPriority[];
|
|
24
|
+
incidentType?: string;
|
|
25
|
+
tenantId: string;
|
|
26
|
+
}
|
|
27
|
+
/** Name used when the user leaves it blank: the shared resource, else the shared account, else generic. */
|
|
28
|
+
export declare function defaultGroupName(rows: Array<{
|
|
29
|
+
resourceName?: string | null;
|
|
30
|
+
accountName?: string | null;
|
|
31
|
+
}>): string;
|
|
32
|
+
export declare class IncidentGroupService {
|
|
33
|
+
private model;
|
|
34
|
+
private incidents;
|
|
35
|
+
constructor(model: IncidentGroupModel, incidents: IncidentService);
|
|
36
|
+
/**
|
|
37
|
+
* Groups shown on the incident list. A group is returned when at least one member matches the
|
|
38
|
+
* list filters; `incidents` holds those matching members (list DTO shape), while `memberCount`,
|
|
39
|
+
* `statusCounts` and `highestPriority` summarise every member.
|
|
40
|
+
*/
|
|
41
|
+
list(filters: IncidentGroupListFilters): Promise<{
|
|
42
|
+
id: string;
|
|
43
|
+
name: string;
|
|
44
|
+
incidentType: string;
|
|
45
|
+
createdBy: string;
|
|
46
|
+
createdByName: string;
|
|
47
|
+
createdAt: string;
|
|
48
|
+
updatedAt: string;
|
|
49
|
+
memberCount: number;
|
|
50
|
+
statusCounts: Record<string, number>;
|
|
51
|
+
highestPriority: string;
|
|
52
|
+
incidents: any[];
|
|
53
|
+
}[]>;
|
|
54
|
+
create(input: {
|
|
55
|
+
tenantId: string;
|
|
56
|
+
name?: unknown;
|
|
57
|
+
incidentIds?: unknown;
|
|
58
|
+
actorId: string | null;
|
|
59
|
+
actorName: string | null;
|
|
60
|
+
}): Promise<import("./incident-group.model.js").IncidentGroupRow>;
|
|
61
|
+
removeIncident(groupId: string, incidentId: string, tenantId: string): Promise<{
|
|
62
|
+
dissolved: boolean;
|
|
63
|
+
remaining: number;
|
|
64
|
+
}>;
|
|
65
|
+
dissolve(groupId: string, tenantId: string): Promise<void>;
|
|
66
|
+
}
|
|
67
|
+
//# sourceMappingURL=incident-group.service.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"incident-group.service.d.ts","sourceRoot":"","sources":["../../../src/features/incident-groups/incident-group.service.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,oCAAoC,CAAC;AAC1E,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,+CAA+C,CAAC;AAC1F,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,wCAAwC,CAAC;AAE/E,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAA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tB,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;QACvB,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;KAC1B;IA4DK,cAAc,CAAC,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM;;;;IAOpE,QAAQ,CAAC,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM;CAKjD"}
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
import { incidentGroupForSource, isIncidentGroup } from "../../constants/incidentCategories.js";
|
|
2
|
+
export const INCIDENT_GROUP_LIMITS = Object.freeze({
|
|
3
|
+
minMembers: 2,
|
|
4
|
+
maxMembers: 100,
|
|
5
|
+
maxNameLength: 120,
|
|
6
|
+
});
|
|
7
|
+
const UUID_RE = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
|
8
|
+
const PRIORITY_ORDER = ["P1", "P2", "P3", "P4"];
|
|
9
|
+
/** Expected client errors; the controller maps `status` to the HTTP status. */
|
|
10
|
+
export class IncidentGroupError extends Error {
|
|
11
|
+
status;
|
|
12
|
+
details;
|
|
13
|
+
constructor(message, status, details) {
|
|
14
|
+
super(message);
|
|
15
|
+
this.status = status;
|
|
16
|
+
this.details = details;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
function aliasLabel(row) {
|
|
20
|
+
const alias = row?.aliasId ?? row?.alias_id;
|
|
21
|
+
return alias ? `INC-${String(alias).padStart(3, "0")}` : String(row?.id ?? "");
|
|
22
|
+
}
|
|
23
|
+
/** Name used when the user leaves it blank: the shared resource, else the shared account, else generic. */
|
|
24
|
+
export function defaultGroupName(rows) {
|
|
25
|
+
const n = rows.length;
|
|
26
|
+
const shared = (key) => {
|
|
27
|
+
const values = new Set(rows.map((r) => (r[key] || "").trim()).filter(Boolean));
|
|
28
|
+
return values.size === 1 && rows.every((r) => (r[key] || "").trim()) ? [...values][0] : null;
|
|
29
|
+
};
|
|
30
|
+
const resource = shared("resourceName");
|
|
31
|
+
if (resource)
|
|
32
|
+
return `${resource} – ${n} incidents`.slice(0, INCIDENT_GROUP_LIMITS.maxNameLength);
|
|
33
|
+
const account = shared("accountName");
|
|
34
|
+
if (account)
|
|
35
|
+
return `${account} – ${n} incidents`.slice(0, INCIDENT_GROUP_LIMITS.maxNameLength);
|
|
36
|
+
return `Incident group – ${n} incidents`;
|
|
37
|
+
}
|
|
38
|
+
export class IncidentGroupService {
|
|
39
|
+
model;
|
|
40
|
+
incidents;
|
|
41
|
+
constructor(model, incidents) {
|
|
42
|
+
this.model = model;
|
|
43
|
+
this.incidents = incidents;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Groups shown on the incident list. A group is returned when at least one member matches the
|
|
47
|
+
* list filters; `incidents` holds those matching members (list DTO shape), while `memberCount`,
|
|
48
|
+
* `statusCounts` and `highestPriority` summarise every member.
|
|
49
|
+
*/
|
|
50
|
+
async list(filters) {
|
|
51
|
+
await this.model.dissolveUndersized(filters.tenantId);
|
|
52
|
+
const type = filters.incidentType?.trim().toLowerCase();
|
|
53
|
+
const groups = await this.model.listWithMembers(filters.tenantId, type && isIncidentGroup(type) ? type : undefined);
|
|
54
|
+
if (!groups.length)
|
|
55
|
+
return [];
|
|
56
|
+
const allIds = [...new Set(groups.flatMap((g) => g.incidentIds))];
|
|
57
|
+
const { rows, matching } = await this.incidents.findGroupMembers(allIds, filters);
|
|
58
|
+
const rowById = new Map(rows.map((r) => [String(r.id), r]));
|
|
59
|
+
const dtoById = new Map(matching.map((d) => [String(d.id), d]));
|
|
60
|
+
return groups
|
|
61
|
+
.map((g) => {
|
|
62
|
+
const members = g.incidentIds.map((id) => rowById.get(id)).filter(Boolean);
|
|
63
|
+
const statusCounts = {};
|
|
64
|
+
for (const m of members) {
|
|
65
|
+
const s = m.status || "open";
|
|
66
|
+
statusCounts[s] = (statusCounts[s] ?? 0) + 1;
|
|
67
|
+
}
|
|
68
|
+
const highestPriority = PRIORITY_ORDER.find((p) => members.some((m) => m.priority === p)) ?? null;
|
|
69
|
+
return {
|
|
70
|
+
id: g.id,
|
|
71
|
+
name: g.name,
|
|
72
|
+
incidentType: g.incidentType,
|
|
73
|
+
createdBy: g.createdBy,
|
|
74
|
+
createdByName: g.createdByName,
|
|
75
|
+
createdAt: g.createdAt,
|
|
76
|
+
updatedAt: g.updatedAt,
|
|
77
|
+
memberCount: members.length,
|
|
78
|
+
statusCounts,
|
|
79
|
+
highestPriority,
|
|
80
|
+
incidents: g.incidentIds.map((id) => dtoById.get(id)).filter(Boolean),
|
|
81
|
+
};
|
|
82
|
+
})
|
|
83
|
+
.filter((g) => g.memberCount >= INCIDENT_GROUP_LIMITS.minMembers && g.incidents.length > 0);
|
|
84
|
+
}
|
|
85
|
+
async create(input) {
|
|
86
|
+
const rawIds = Array.isArray(input.incidentIds) ? input.incidentIds.map((v) => String(v).trim()) : [];
|
|
87
|
+
const ids = [...new Set(rawIds.filter(Boolean))];
|
|
88
|
+
if (ids.length !== rawIds.length) {
|
|
89
|
+
throw new IncidentGroupError("Each incident can only be added to a group once", 400);
|
|
90
|
+
}
|
|
91
|
+
if (ids.length < INCIDENT_GROUP_LIMITS.minMembers) {
|
|
92
|
+
throw new IncidentGroupError(`Select at least ${INCIDENT_GROUP_LIMITS.minMembers} incidents to group`, 400);
|
|
93
|
+
}
|
|
94
|
+
if (ids.length > INCIDENT_GROUP_LIMITS.maxMembers) {
|
|
95
|
+
throw new IncidentGroupError(`A group can hold at most ${INCIDENT_GROUP_LIMITS.maxMembers} incidents`, 400);
|
|
96
|
+
}
|
|
97
|
+
if (ids.some((id) => !UUID_RE.test(id)))
|
|
98
|
+
throw new IncidentGroupError("Invalid incident id", 400);
|
|
99
|
+
if (input.name !== undefined && input.name !== null && typeof input.name !== "string") {
|
|
100
|
+
throw new IncidentGroupError("Group name must be text", 400);
|
|
101
|
+
}
|
|
102
|
+
const requestedName = typeof input.name === "string" ? input.name.trim() : "";
|
|
103
|
+
if (requestedName.length > INCIDENT_GROUP_LIMITS.maxNameLength) {
|
|
104
|
+
throw new IncidentGroupError(`Group name must be at most ${INCIDENT_GROUP_LIMITS.maxNameLength} characters`, 400);
|
|
105
|
+
}
|
|
106
|
+
const rows = await this.incidents.findByIds(ids, input.tenantId);
|
|
107
|
+
if (rows.length !== ids.length)
|
|
108
|
+
throw new IncidentGroupError("One or more incidents were not found", 404);
|
|
109
|
+
const types = new Set(rows.map((r) => incidentGroupForSource(r.source)));
|
|
110
|
+
if (types.size !== 1) {
|
|
111
|
+
throw new IncidentGroupError("Only incidents of the same type (operations, security or cost) can be grouped", 400);
|
|
112
|
+
}
|
|
113
|
+
// Clean up groups that lost members (e.g. deleted incidents) before checking membership.
|
|
114
|
+
await this.model.dissolveUndersized(input.tenantId);
|
|
115
|
+
const existing = await this.model.findMemberships(ids, input.tenantId);
|
|
116
|
+
if (existing.length) {
|
|
117
|
+
const byId = new Map(rows.map((r) => [String(r.id), r]));
|
|
118
|
+
const labels = existing.map((m) => aliasLabel(byId.get(m.incidentId)));
|
|
119
|
+
throw new IncidentGroupError(`Already in a group: ${labels.join(", ")}. Remove them from their group first.`, 409, { incidentIds: existing.map((m) => m.incidentId) });
|
|
120
|
+
}
|
|
121
|
+
try {
|
|
122
|
+
return await this.model.create({
|
|
123
|
+
tenantId: input.tenantId,
|
|
124
|
+
name: requestedName || defaultGroupName(rows),
|
|
125
|
+
incidentType: [...types][0],
|
|
126
|
+
incidentIds: ids,
|
|
127
|
+
createdBy: input.actorId,
|
|
128
|
+
createdByName: input.actorName,
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
catch (err) {
|
|
132
|
+
if (err?.message === "INCIDENT_ALREADY_GROUPED") {
|
|
133
|
+
throw new IncidentGroupError("One or more incidents were grouped by someone else. Refresh and try again.", 409);
|
|
134
|
+
}
|
|
135
|
+
throw err;
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
async removeIncident(groupId, incidentId, tenantId) {
|
|
139
|
+
if (!UUID_RE.test(groupId) || !UUID_RE.test(incidentId))
|
|
140
|
+
throw new IncidentGroupError("Invalid id", 400);
|
|
141
|
+
const result = await this.model.removeMember(groupId, incidentId, tenantId);
|
|
142
|
+
if (!result)
|
|
143
|
+
throw new IncidentGroupError("Incident is not in this group", 404);
|
|
144
|
+
return result;
|
|
145
|
+
}
|
|
146
|
+
async dissolve(groupId, tenantId) {
|
|
147
|
+
if (!UUID_RE.test(groupId))
|
|
148
|
+
throw new IncidentGroupError("Invalid id", 400);
|
|
149
|
+
const deleted = await this.model.delete(groupId, tenantId);
|
|
150
|
+
if (!deleted)
|
|
151
|
+
throw new IncidentGroupError("Group not found", 404);
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
//# sourceMappingURL=incident-group.service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"incident-group.service.js","sourceRoot":"","sources":["../../../src/features/incident-groups/incident-group.service.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,sBAAsB,EAAE,eAAe,EAAE,MAAM,uCAAuC,CAAC;AAGhG,MAAM,CAAC,MAAM,qBAAqB,GAAG,MAAM,CAAC,MAAM,CAAC;IACjD,UAAU,EAAE,CAAC;IACb,UAAU,EAAE,GAAG;IACf,aAAa,EAAE,GAAG;CACnB,CAAC,CAAC;AAEH,MAAM,OAAO,GAAG,iEAAiE,CAAC;AAClF,MAAM,cAAc,GAAG,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC;AAEhD,+EAA+E;AAC/E,MAAM,OAAO,kBAAmB,SAAQ,KAAK;IACL;IAAyB;IAA/D,YAAY,OAAe,EAAW,MAAc,EAAW,OAAiC;QAC9F,KAAK,CAAC,OAAO,CAAC,CAAC;QADqB,WAAM,GAAN,MAAM,CAAQ;QAAW,YAAO,GAAP,OAAO,CAA0B;IAEhG,CAAC;CACF;AAcD,SAAS,UAAU,CAAC,GAAQ;IAC1B,MAA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C;IACH,CAAC;IAED,KAAK,CAAC,cAAc,CAAC,OAAe,EAAE,UAAkB,EAAE,QAAgB;QACxE,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,UAAU,CAAC;YAAE,MAAM,IAAI,kBAAkB,CAAC,YAAY,EAAE,GAAG,CAAC,CAAC;QACzG,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,OAAO,EAAE,UAAU,EAAE,QAAQ,CAAC,CAAC;QAC5E,IAAI,CAAC,MAAM;YAAE,MAAM,IAAI,kBAAkB,CAAC,+BAA+B,EAAE,GAAG,CAAC,CAAC;QAChF,OAAO,MAAM,CAAC;IAChB,CAAC;IAED,KAAK,CAAC,QAAQ,CAAC,OAAe,EAAE,QAAgB;QAC9C,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC;YAAE,MAAM,IAAI,kBAAkB,CAAC,YAAY,EAAE,GAAG,CAAC,CAAC;QAC5E,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;QAC3D,IAAI,CAAC,OAAO;YAAE,MAAM,IAAI,kBAAkB,CAAC,iBAAiB,EAAE,GAAG,CAAC,CAAC;IACrE,CAAC;CACF"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export { IncidentGroupModel } from "./incident-group.model.js";
|
|
2
|
+
export { IncidentGroupService, IncidentGroupError, INCIDENT_GROUP_LIMITS, defaultGroupName } from "./incident-group.service.js";
|
|
3
|
+
export { createIncidentGroupRouter } from "./incident-group.routes.js";
|
|
4
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/features/incident-groups/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAC/D,OAAO,EAAE,oBAAoB,EAAE,kBAAkB,EAAE,qBAAqB,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AAChI,OAAO,EAAE,yBAAyB,EAAE,MAAM,4BAA4B,CAAC"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export { IncidentGroupModel } from "./incident-group.model.js";
|
|
2
|
+
export { IncidentGroupService, IncidentGroupError, INCIDENT_GROUP_LIMITS, defaultGroupName } from "./incident-group.service.js";
|
|
3
|
+
export { createIncidentGroupRouter } from "./incident-group.routes.js";
|
|
4
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/features/incident-groups/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAC/D,OAAO,EAAE,oBAAoB,EAAE,kBAAkB,EAAE,qBAAqB,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AAChI,OAAO,EAAE,yBAAyB,EAAE,MAAM,4BAA4B,CAAC"}
|