@modainteract/moda-interact-shared 1.5.0 → 2.0.0
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/incidents/index.d.ts +124 -0
- package/dist/incidents/index.js +264 -0
- package/dist/incidents/index.js.map +1 -0
- package/package.json +7 -2
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
|
|
3
|
+
/** Durable outcome of one occurrence; duplicate deliveries have no side effects. */
|
|
4
|
+
type IncidentReportResult = {
|
|
5
|
+
incidentKey: string;
|
|
6
|
+
recorded: boolean;
|
|
7
|
+
occurrenceCount: number;
|
|
8
|
+
status: "OPEN" | "RESOLVED";
|
|
9
|
+
};
|
|
10
|
+
type IncidentSnapshot = {
|
|
11
|
+
incidentKey: string;
|
|
12
|
+
status: "OPEN" | "RESOLVED";
|
|
13
|
+
occurrenceCount: number;
|
|
14
|
+
lastOccurredAt: Date;
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* Transactional persistence contract, implemented by the consuming service.
|
|
18
|
+
* transactionForKey MUST serialize operations for the same key across processes,
|
|
19
|
+
* INCLUDING first creation; the callback must be retried on a conflicting insert.
|
|
20
|
+
* insertOccurrenceIfNew MUST enforce a GLOBAL unique occurrenceId (not only per
|
|
21
|
+
* incident); an occurrenceId already belonging to another key MUST throw.
|
|
22
|
+
* On creation loadOrCreate MUST initialise occurrenceCount=1; recordOccurrence
|
|
23
|
+
* MUST NOT increment that first occurrence again. If a duplicate is encountered
|
|
24
|
+
* when newlyCreated=true, the transaction MUST fail and roll back creation.
|
|
25
|
+
* Every operation in this port, including optional support notification, MUST
|
|
26
|
+
* participate in the SAME database transaction and roll back together.
|
|
27
|
+
*/
|
|
28
|
+
interface IncidentTransaction {
|
|
29
|
+
loadOrCreate(input: {
|
|
30
|
+
incidentKey: string;
|
|
31
|
+
occurrence: OperationalIncidentOccurrenceV1;
|
|
32
|
+
}): Promise<IncidentSnapshot & {
|
|
33
|
+
newlyCreated: boolean;
|
|
34
|
+
}>;
|
|
35
|
+
insertOccurrenceIfNew(input: {
|
|
36
|
+
incidentKey: string;
|
|
37
|
+
occurrence: OperationalIncidentOccurrenceV1;
|
|
38
|
+
}): Promise<boolean>;
|
|
39
|
+
recordOccurrence(input: {
|
|
40
|
+
incidentKey: string;
|
|
41
|
+
occurrence: OperationalIncidentOccurrenceV1;
|
|
42
|
+
reopen: boolean;
|
|
43
|
+
newlyCreated: boolean;
|
|
44
|
+
}): Promise<IncidentSnapshot>;
|
|
45
|
+
/** Optional, safe internal support projection; at most one per incident key. */
|
|
46
|
+
notifySupportOnce?(input: {
|
|
47
|
+
incidentKey: string;
|
|
48
|
+
occurrence: OperationalIncidentOccurrenceV1;
|
|
49
|
+
}): Promise<void>;
|
|
50
|
+
}
|
|
51
|
+
interface IncidentPersistence {
|
|
52
|
+
transactionForKey<T>(key: string, fn: (tx: IncidentTransaction) => Promise<T>): Promise<T>;
|
|
53
|
+
}
|
|
54
|
+
interface IncidentReporterLogger {
|
|
55
|
+
error(event: string, fields: Record<string, unknown>): void;
|
|
56
|
+
}
|
|
57
|
+
/** Reporter never turns an operational-notification failure into the producer's failure. */
|
|
58
|
+
declare function createOperationalIncidentReporter(options: {
|
|
59
|
+
persistence: IncidentPersistence;
|
|
60
|
+
logger: IncidentReporterLogger;
|
|
61
|
+
notifySupport?: boolean;
|
|
62
|
+
}): {
|
|
63
|
+
report(raw: unknown): Promise<IncidentReportResult | null>;
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
/** A deliberately small interface; the application's Prisma transaction client supplies it. */
|
|
67
|
+
interface OperationalIncidentSqlClient {
|
|
68
|
+
$queryRawUnsafe<T = unknown>(query: string, ...parameters: unknown[]): Promise<T>;
|
|
69
|
+
}
|
|
70
|
+
interface OperationalIncidentPrismaClient {
|
|
71
|
+
$transaction<T>(fn: (tx: OperationalIncidentSqlClient) => Promise<T>, options?: {
|
|
72
|
+
maxWait?: number;
|
|
73
|
+
timeout?: number;
|
|
74
|
+
isolationLevel?: "Serializable";
|
|
75
|
+
}): Promise<T>;
|
|
76
|
+
}
|
|
77
|
+
/** Optional merchant-support projection. This callback MUST use the supplied transaction. */
|
|
78
|
+
type OperationalIncidentSupportWriter = (input: {
|
|
79
|
+
tx: OperationalIncidentSqlClient;
|
|
80
|
+
incidentId: string;
|
|
81
|
+
incidentKey: string;
|
|
82
|
+
occurrence: OperationalIncidentOccurrenceV1;
|
|
83
|
+
}) => Promise<void>;
|
|
84
|
+
/**
|
|
85
|
+
* PostgreSQL/Prisma adapter. No global Prisma client or credentials are created.
|
|
86
|
+
* All writes and an optional support projection occur within a single transaction.
|
|
87
|
+
* Uses a per-key transaction advisory lock and a row lock for cross-process safety.
|
|
88
|
+
*/
|
|
89
|
+
declare function createPrismaOperationalIncidentPersistence(options: {
|
|
90
|
+
prisma: OperationalIncidentPrismaClient;
|
|
91
|
+
supportWriter?: OperationalIncidentSupportWriter;
|
|
92
|
+
maxAttempts?: number;
|
|
93
|
+
}): IncidentPersistence;
|
|
94
|
+
|
|
95
|
+
declare const OPERATIONAL_INCIDENT_CONTRACT_VERSION: "operational-incident.v1";
|
|
96
|
+
declare const OperationalIncidentOccurrenceV1Schema: z.ZodObject<{
|
|
97
|
+
contractVersion: z.ZodLiteral<"operational-incident.v1">;
|
|
98
|
+
sourceService: z.ZodString;
|
|
99
|
+
environment: z.ZodEnum<{
|
|
100
|
+
local: "local";
|
|
101
|
+
development: "development";
|
|
102
|
+
test: "test";
|
|
103
|
+
staging: "staging";
|
|
104
|
+
production: "production";
|
|
105
|
+
}>;
|
|
106
|
+
category: z.ZodString;
|
|
107
|
+
reasonCode: z.ZodString;
|
|
108
|
+
resourceKey: z.ZodString;
|
|
109
|
+
shopId: z.ZodNullable<z.ZodString>;
|
|
110
|
+
severity: z.ZodEnum<{
|
|
111
|
+
LOW: "LOW";
|
|
112
|
+
MEDIUM: "MEDIUM";
|
|
113
|
+
HIGH: "HIGH";
|
|
114
|
+
CRITICAL: "CRITICAL";
|
|
115
|
+
}>;
|
|
116
|
+
occurrenceId: z.ZodString;
|
|
117
|
+
correlationId: z.ZodString;
|
|
118
|
+
occurredAt: z.ZodISODateTime;
|
|
119
|
+
}, z.core.$strict>;
|
|
120
|
+
type OperationalIncidentOccurrenceV1 = z.infer<typeof OperationalIncidentOccurrenceV1Schema>;
|
|
121
|
+
declare function parseOperationalIncidentOccurrenceV1(input: unknown): OperationalIncidentOccurrenceV1;
|
|
122
|
+
declare function createOperationalIncidentKey(input: Pick<OperationalIncidentOccurrenceV1, "sourceService" | "environment" | "category" | "reasonCode" | "resourceKey" | "shopId">): string;
|
|
123
|
+
|
|
124
|
+
export { type IncidentPersistence, type IncidentReportResult, type IncidentReporterLogger, type IncidentSnapshot, type IncidentTransaction, OPERATIONAL_INCIDENT_CONTRACT_VERSION, type OperationalIncidentOccurrenceV1, OperationalIncidentOccurrenceV1Schema, type OperationalIncidentPrismaClient, type OperationalIncidentSqlClient, type OperationalIncidentSupportWriter, createOperationalIncidentKey, createOperationalIncidentReporter, createPrismaOperationalIncidentPersistence, parseOperationalIncidentOccurrenceV1 };
|
|
@@ -0,0 +1,264 @@
|
|
|
1
|
+
// src/incidents/index.ts
|
|
2
|
+
import { createHash } from "crypto";
|
|
3
|
+
import { z } from "zod";
|
|
4
|
+
|
|
5
|
+
// src/incidents/reporter.ts
|
|
6
|
+
function createOperationalIncidentReporter(options) {
|
|
7
|
+
return {
|
|
8
|
+
async report(raw) {
|
|
9
|
+
let occurrence;
|
|
10
|
+
try {
|
|
11
|
+
occurrence = parseOperationalIncidentOccurrenceV1(raw);
|
|
12
|
+
} catch {
|
|
13
|
+
options.logger.error("operational_incident.invalid_occurrence", {});
|
|
14
|
+
return null;
|
|
15
|
+
}
|
|
16
|
+
const incidentKey = createOperationalIncidentKey({
|
|
17
|
+
sourceService: occurrence.sourceService,
|
|
18
|
+
environment: occurrence.environment,
|
|
19
|
+
category: occurrence.category,
|
|
20
|
+
reasonCode: occurrence.reasonCode,
|
|
21
|
+
resourceKey: occurrence.resourceKey,
|
|
22
|
+
shopId: occurrence.shopId
|
|
23
|
+
});
|
|
24
|
+
try {
|
|
25
|
+
return await options.persistence.transactionForKey(incidentKey, async (tx) => {
|
|
26
|
+
const current = await tx.loadOrCreate({ incidentKey, occurrence });
|
|
27
|
+
const recorded = await tx.insertOccurrenceIfNew({ incidentKey, occurrence });
|
|
28
|
+
if (!recorded) {
|
|
29
|
+
return {
|
|
30
|
+
incidentKey,
|
|
31
|
+
recorded: false,
|
|
32
|
+
occurrenceCount: current.occurrenceCount,
|
|
33
|
+
status: current.status
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
const updated = await tx.recordOccurrence({
|
|
37
|
+
incidentKey,
|
|
38
|
+
occurrence,
|
|
39
|
+
reopen: current.status === "RESOLVED",
|
|
40
|
+
newlyCreated: current.newlyCreated
|
|
41
|
+
});
|
|
42
|
+
if (options.notifySupport && occurrence.shopId !== null && tx.notifySupportOnce) {
|
|
43
|
+
await tx.notifySupportOnce({ incidentKey, occurrence });
|
|
44
|
+
}
|
|
45
|
+
return {
|
|
46
|
+
incidentKey,
|
|
47
|
+
recorded: true,
|
|
48
|
+
occurrenceCount: updated.occurrenceCount,
|
|
49
|
+
status: "OPEN"
|
|
50
|
+
};
|
|
51
|
+
});
|
|
52
|
+
} catch {
|
|
53
|
+
options.logger.error("operational_incident.report_failed", {
|
|
54
|
+
incidentKey,
|
|
55
|
+
sourceService: occurrence.sourceService,
|
|
56
|
+
environment: occurrence.environment,
|
|
57
|
+
occurrenceId: occurrence.occurrenceId
|
|
58
|
+
});
|
|
59
|
+
return null;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
// src/incidents/postgres.ts
|
|
66
|
+
import { randomUUID } from "crypto";
|
|
67
|
+
async function rows(tx, statement, ...params) {
|
|
68
|
+
return tx.$queryRawUnsafe(statement, ...params);
|
|
69
|
+
}
|
|
70
|
+
function snapshot(row) {
|
|
71
|
+
return {
|
|
72
|
+
incidentKey: row.incidentKey,
|
|
73
|
+
status: row.status,
|
|
74
|
+
occurrenceCount: row.occurrenceCount,
|
|
75
|
+
lastOccurredAt: row.lastOccurredAt
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
var PgIncidentTransaction = class {
|
|
79
|
+
constructor(tx, supportWriter) {
|
|
80
|
+
this.tx = tx;
|
|
81
|
+
this.supportWriter = supportWriter;
|
|
82
|
+
}
|
|
83
|
+
tx;
|
|
84
|
+
supportWriter;
|
|
85
|
+
incidentId = null;
|
|
86
|
+
newIncident = false;
|
|
87
|
+
async loadOrCreate({ incidentKey, occurrence }) {
|
|
88
|
+
const inserted = await rows(
|
|
89
|
+
this.tx,
|
|
90
|
+
`
|
|
91
|
+
INSERT INTO support."OperationalIncident" (
|
|
92
|
+
"id", "incidentKey", "sourceService", "environment", "category", "reasonCode",
|
|
93
|
+
"resourceKey", "shopId", "severity", "status", "occurrenceCount",
|
|
94
|
+
"firstOccurredAt", "lastOccurredAt", "lastCorrelationId")
|
|
95
|
+
VALUES ($1,$2,$3,$4,$5,$6,$7,$8,$9,'OPEN',1,$10::timestamptz,$10::timestamptz,$11)
|
|
96
|
+
ON CONFLICT ("incidentKey") DO NOTHING RETURNING *`,
|
|
97
|
+
randomUUID(),
|
|
98
|
+
incidentKey,
|
|
99
|
+
occurrence.sourceService,
|
|
100
|
+
occurrence.environment,
|
|
101
|
+
occurrence.category,
|
|
102
|
+
occurrence.reasonCode,
|
|
103
|
+
occurrence.resourceKey,
|
|
104
|
+
occurrence.shopId,
|
|
105
|
+
occurrence.severity,
|
|
106
|
+
occurrence.occurredAt,
|
|
107
|
+
occurrence.correlationId
|
|
108
|
+
);
|
|
109
|
+
this.newIncident = inserted.length > 0;
|
|
110
|
+
const found = await rows(
|
|
111
|
+
this.tx,
|
|
112
|
+
`SELECT * FROM support."OperationalIncident" WHERE "incidentKey" = $1 FOR UPDATE`,
|
|
113
|
+
incidentKey
|
|
114
|
+
);
|
|
115
|
+
if (found.length !== 1) throw new Error("incident row not found after upsert");
|
|
116
|
+
this.incidentId = found[0].id;
|
|
117
|
+
return { ...snapshot(found[0]), newlyCreated: this.newIncident };
|
|
118
|
+
}
|
|
119
|
+
async insertOccurrenceIfNew({ incidentKey, occurrence }) {
|
|
120
|
+
if (!this.incidentId) throw new Error("incident not loaded");
|
|
121
|
+
const created = await rows(
|
|
122
|
+
this.tx,
|
|
123
|
+
`
|
|
124
|
+
INSERT INTO support."OperationalIncidentEvent"
|
|
125
|
+
("id", "incidentId", "eventType", "correlationId", "occurredAt")
|
|
126
|
+
VALUES ($1::uuid, $2, 'OCCURRED', $3, $4::timestamptz)
|
|
127
|
+
ON CONFLICT ("id") DO NOTHING RETURNING "id"`,
|
|
128
|
+
occurrence.occurrenceId,
|
|
129
|
+
this.incidentId,
|
|
130
|
+
occurrence.correlationId,
|
|
131
|
+
occurrence.occurredAt
|
|
132
|
+
);
|
|
133
|
+
if (!created.length) {
|
|
134
|
+
if (this.newIncident) throw new Error("duplicate occurrence cannot create new incident");
|
|
135
|
+
const existing = await rows(this.tx, `
|
|
136
|
+
SELECT i."incidentKey" FROM support."OperationalIncidentEvent" e
|
|
137
|
+
JOIN support."OperationalIncident" i ON i."id" = e."incidentId"
|
|
138
|
+
WHERE e."id" = $1::uuid`, occurrence.occurrenceId);
|
|
139
|
+
if (existing.length !== 1 || existing[0].incidentKey !== incidentKey) {
|
|
140
|
+
throw new Error("occurrence already belongs to another incident");
|
|
141
|
+
}
|
|
142
|
+
return false;
|
|
143
|
+
}
|
|
144
|
+
return true;
|
|
145
|
+
}
|
|
146
|
+
async recordOccurrence({ incidentKey, occurrence, reopen, newlyCreated }) {
|
|
147
|
+
if (!this.incidentId) throw new Error("incident not loaded");
|
|
148
|
+
if (reopen) {
|
|
149
|
+
await rows(
|
|
150
|
+
this.tx,
|
|
151
|
+
`INSERT INTO support."OperationalIncidentEvent"
|
|
152
|
+
("id", "incidentId", "eventType", "correlationId", "occurredAt")
|
|
153
|
+
VALUES ($1::uuid,$2,'REOPENED',$3,$4::timestamptz)`,
|
|
154
|
+
randomUUID(),
|
|
155
|
+
this.incidentId,
|
|
156
|
+
occurrence.correlationId,
|
|
157
|
+
occurrence.occurredAt
|
|
158
|
+
);
|
|
159
|
+
}
|
|
160
|
+
const updated = await rows(
|
|
161
|
+
this.tx,
|
|
162
|
+
`
|
|
163
|
+
UPDATE support."OperationalIncident" SET
|
|
164
|
+
"occurrenceCount" = "occurrenceCount" + $2::integer,
|
|
165
|
+
"lastOccurredAt" = GREATEST("lastOccurredAt", $3::timestamptz),
|
|
166
|
+
"lastCorrelationId" = $4,
|
|
167
|
+
"severity" = $5,
|
|
168
|
+
"status" = 'OPEN', "resolvedAt" = NULL,
|
|
169
|
+
"resolvedByPlatformAdminId" = NULL, "resolutionNote" = NULL,
|
|
170
|
+
"revision" = "revision" + 1
|
|
171
|
+
WHERE "incidentKey" = $1 RETURNING *`,
|
|
172
|
+
incidentKey,
|
|
173
|
+
newlyCreated ? 0 : 1,
|
|
174
|
+
occurrence.occurredAt,
|
|
175
|
+
occurrence.correlationId,
|
|
176
|
+
occurrence.severity
|
|
177
|
+
);
|
|
178
|
+
if (updated.length !== 1) throw new Error("incident update failed");
|
|
179
|
+
return snapshot(updated[0]);
|
|
180
|
+
}
|
|
181
|
+
async notifySupportOnce(input) {
|
|
182
|
+
if (this.supportWriter && this.incidentId) await this.supportWriter({
|
|
183
|
+
tx: this.tx,
|
|
184
|
+
incidentId: this.incidentId,
|
|
185
|
+
incidentKey: input.incidentKey,
|
|
186
|
+
occurrence: input.occurrence
|
|
187
|
+
});
|
|
188
|
+
}
|
|
189
|
+
};
|
|
190
|
+
function retryable(error) {
|
|
191
|
+
const code = typeof error === "object" && error !== null && "code" in error ? error.code : void 0;
|
|
192
|
+
return code === "P2034" || code === "40001" || code === "40P01";
|
|
193
|
+
}
|
|
194
|
+
function createPrismaOperationalIncidentPersistence(options) {
|
|
195
|
+
const maxAttempts = options.maxAttempts ?? 3;
|
|
196
|
+
if (!Number.isInteger(maxAttempts) || maxAttempts < 1 || maxAttempts > 10) {
|
|
197
|
+
throw new Error("maxAttempts must be between 1 and 10");
|
|
198
|
+
}
|
|
199
|
+
return {
|
|
200
|
+
async transactionForKey(key, fn) {
|
|
201
|
+
for (let attempt = 1; ; attempt++) {
|
|
202
|
+
try {
|
|
203
|
+
return await options.prisma.$transaction(async (tx) => {
|
|
204
|
+
await rows(tx, `SELECT pg_advisory_xact_lock(hashtextextended($1::text, 0))::text AS acquired`, key);
|
|
205
|
+
return fn(new PgIncidentTransaction(tx, options.supportWriter));
|
|
206
|
+
}, { isolationLevel: "Serializable", timeout: 15e3 });
|
|
207
|
+
} catch (error) {
|
|
208
|
+
if (attempt >= maxAttempts || !retryable(error)) throw error;
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
};
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
// src/incidents/index.ts
|
|
216
|
+
var OPERATIONAL_INCIDENT_CONTRACT_VERSION = "operational-incident.v1";
|
|
217
|
+
var identifier = z.string().min(1).max(128).regex(/^[A-Za-z0-9][A-Za-z0-9._:-]*$/);
|
|
218
|
+
var smallIdentifier = z.string().min(1).max(64).regex(/^[A-Za-z0-9][A-Za-z0-9._:-]*$/);
|
|
219
|
+
var opaqueId = z.string().uuid();
|
|
220
|
+
var OperationalIncidentOccurrenceV1Schema = z.strictObject({
|
|
221
|
+
contractVersion: z.literal(OPERATIONAL_INCIDENT_CONTRACT_VERSION),
|
|
222
|
+
sourceService: smallIdentifier,
|
|
223
|
+
environment: z.enum(["local", "development", "test", "staging", "production"]),
|
|
224
|
+
category: smallIdentifier,
|
|
225
|
+
reasonCode: identifier,
|
|
226
|
+
resourceKey: identifier,
|
|
227
|
+
shopId: z.string().min(1).max(128).nullable(),
|
|
228
|
+
severity: z.enum(["LOW", "MEDIUM", "HIGH", "CRITICAL"]),
|
|
229
|
+
occurrenceId: opaqueId,
|
|
230
|
+
correlationId: identifier,
|
|
231
|
+
occurredAt: z.iso.datetime({ offset: true })
|
|
232
|
+
// Deliberately no arbitrary metadata bag, message, headers or exception object.
|
|
233
|
+
});
|
|
234
|
+
function parseOperationalIncidentOccurrenceV1(input) {
|
|
235
|
+
return OperationalIncidentOccurrenceV1Schema.parse(input);
|
|
236
|
+
}
|
|
237
|
+
function createOperationalIncidentKey(input) {
|
|
238
|
+
const parsed = OperationalIncidentOccurrenceV1Schema.pick({
|
|
239
|
+
sourceService: true,
|
|
240
|
+
environment: true,
|
|
241
|
+
category: true,
|
|
242
|
+
reasonCode: true,
|
|
243
|
+
resourceKey: true,
|
|
244
|
+
shopId: true
|
|
245
|
+
}).parse(input);
|
|
246
|
+
return createHash("sha256").update(JSON.stringify([
|
|
247
|
+
"operational-incident-key.v1",
|
|
248
|
+
parsed.sourceService,
|
|
249
|
+
parsed.environment,
|
|
250
|
+
parsed.category,
|
|
251
|
+
parsed.reasonCode,
|
|
252
|
+
parsed.shopId,
|
|
253
|
+
parsed.resourceKey
|
|
254
|
+
])).digest("hex");
|
|
255
|
+
}
|
|
256
|
+
export {
|
|
257
|
+
OPERATIONAL_INCIDENT_CONTRACT_VERSION,
|
|
258
|
+
OperationalIncidentOccurrenceV1Schema,
|
|
259
|
+
createOperationalIncidentKey,
|
|
260
|
+
createOperationalIncidentReporter,
|
|
261
|
+
createPrismaOperationalIncidentPersistence,
|
|
262
|
+
parseOperationalIncidentOccurrenceV1
|
|
263
|
+
};
|
|
264
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/incidents/index.ts","../../src/incidents/reporter.ts","../../src/incidents/postgres.ts"],"sourcesContent":["import { createHash } from \"node:crypto\";\nimport { z } from \"zod\";\n\n// ARCH-033 v1: safe, internal-only occurrence envelope. Producer classifies actionability.\nexport const OPERATIONAL_INCIDENT_CONTRACT_VERSION = \"operational-incident.v1\" as const;\nconst identifier = z.string().min(1).max(128).regex(/^[A-Za-z0-9][A-Za-z0-9._:-]*$/);\nconst smallIdentifier = z.string().min(1).max(64).regex(/^[A-Za-z0-9][A-Za-z0-9._:-]*$/);\nconst opaqueId = z.string().uuid();\nexport const OperationalIncidentOccurrenceV1Schema = z.strictObject({\n contractVersion: z.literal(OPERATIONAL_INCIDENT_CONTRACT_VERSION),\n sourceService: smallIdentifier,\n environment: z.enum([\"local\", \"development\", \"test\", \"staging\", \"production\"]),\n category: smallIdentifier,\n reasonCode: identifier,\n resourceKey: identifier,\n shopId: z.string().min(1).max(128).nullable(),\n severity: z.enum([\"LOW\", \"MEDIUM\", \"HIGH\", \"CRITICAL\"]),\n occurrenceId: opaqueId,\n correlationId: identifier,\n occurredAt: z.iso.datetime({ offset: true }),\n // Deliberately no arbitrary metadata bag, message, headers or exception object.\n});\nexport type OperationalIncidentOccurrenceV1 = z.infer<typeof OperationalIncidentOccurrenceV1Schema>;\nexport function parseOperationalIncidentOccurrenceV1(input: unknown): OperationalIncidentOccurrenceV1 {\n return OperationalIncidentOccurrenceV1Schema.parse(input);\n}\nexport function createOperationalIncidentKey(input: Pick<OperationalIncidentOccurrenceV1,\n \"sourceService\" | \"environment\" | \"category\" | \"reasonCode\" | \"resourceKey\" | \"shopId\">): string {\n const parsed = OperationalIncidentOccurrenceV1Schema.pick({\n sourceService: true, environment: true, category: true, reasonCode: true, resourceKey: true, shopId: true,\n }).parse(input);\n return createHash(\"sha256\").update(JSON.stringify([\n \"operational-incident-key.v1\", parsed.sourceService, parsed.environment, parsed.category,\n parsed.reasonCode, parsed.shopId, parsed.resourceKey,\n ])).digest(\"hex\");\n}\n\nexport { createOperationalIncidentReporter } from \"./reporter.js\";\nexport type {\n IncidentPersistence, IncidentTransaction, IncidentSnapshot, IncidentReportResult,\n IncidentReporterLogger,\n} from \"./reporter.js\";\n\nexport { createPrismaOperationalIncidentPersistence } from \"./postgres.js\";\nexport type { OperationalIncidentPrismaClient, OperationalIncidentSqlClient, OperationalIncidentSupportWriter } from \"./postgres.js\";\n","import { createOperationalIncidentKey, parseOperationalIncidentOccurrenceV1 } from \"./index.js\";\nimport type { OperationalIncidentOccurrenceV1 } from \"./index.js\";\n\n/** Durable outcome of one occurrence; duplicate deliveries have no side effects. */\nexport type IncidentReportResult = {\n incidentKey: string;\n recorded: boolean;\n occurrenceCount: number;\n status: \"OPEN\" | \"RESOLVED\";\n};\n\nexport type IncidentSnapshot = {\n incidentKey: string;\n status: \"OPEN\" | \"RESOLVED\";\n occurrenceCount: number;\n lastOccurredAt: Date;\n};\n\n/**\n * Transactional persistence contract, implemented by the consuming service.\n * transactionForKey MUST serialize operations for the same key across processes,\n * INCLUDING first creation; the callback must be retried on a conflicting insert.\n * insertOccurrenceIfNew MUST enforce a GLOBAL unique occurrenceId (not only per\n * incident); an occurrenceId already belonging to another key MUST throw.\n * On creation loadOrCreate MUST initialise occurrenceCount=1; recordOccurrence\n * MUST NOT increment that first occurrence again. If a duplicate is encountered\n * when newlyCreated=true, the transaction MUST fail and roll back creation.\n * Every operation in this port, including optional support notification, MUST\n * participate in the SAME database transaction and roll back together.\n */\nexport interface IncidentTransaction {\n loadOrCreate(input: { incidentKey: string; occurrence: OperationalIncidentOccurrenceV1 }): Promise<IncidentSnapshot & { newlyCreated: boolean }>;\n insertOccurrenceIfNew(input: { incidentKey: string; occurrence: OperationalIncidentOccurrenceV1 }): Promise<boolean>;\n recordOccurrence(input: {\n incidentKey: string;\n occurrence: OperationalIncidentOccurrenceV1;\n reopen: boolean;\n newlyCreated: boolean;\n }): Promise<IncidentSnapshot>;\n /** Optional, safe internal support projection; at most one per incident key. */\n notifySupportOnce?(input: { incidentKey: string; occurrence: OperationalIncidentOccurrenceV1 }): Promise<void>;\n}\nexport interface IncidentPersistence {\n transactionForKey<T>(key: string, fn: (tx: IncidentTransaction) => Promise<T>): Promise<T>;\n}\nexport interface IncidentReporterLogger {\n error(event: string, fields: Record<string, unknown>): void;\n}\n\n/** Reporter never turns an operational-notification failure into the producer's failure. */\nexport function createOperationalIncidentReporter(options: {\n persistence: IncidentPersistence;\n logger: IncidentReporterLogger;\n notifySupport?: boolean;\n}) {\n return {\n async report(raw: unknown): Promise<IncidentReportResult | null> {\n let occurrence: OperationalIncidentOccurrenceV1;\n try {\n occurrence = parseOperationalIncidentOccurrenceV1(raw);\n } catch {\n // Fail closed, and do not log potentially sensitive invalid payloads.\n options.logger.error(\"operational_incident.invalid_occurrence\", {});\n return null;\n }\n const incidentKey = createOperationalIncidentKey({\n sourceService: occurrence.sourceService, environment: occurrence.environment,\n category: occurrence.category, reasonCode: occurrence.reasonCode,\n resourceKey: occurrence.resourceKey, shopId: occurrence.shopId,\n });\n try {\n return await options.persistence.transactionForKey(incidentKey, async (tx) => {\n const current = await tx.loadOrCreate({ incidentKey, occurrence });\n const recorded = await tx.insertOccurrenceIfNew({ incidentKey, occurrence });\n if (!recorded) {\n return { incidentKey, recorded: false, occurrenceCount: current.occurrenceCount,\n status: current.status };\n }\n const updated = await tx.recordOccurrence({ incidentKey, occurrence,\n reopen: current.status === \"RESOLVED\", newlyCreated: current.newlyCreated });\n if (options.notifySupport && occurrence.shopId !== null && tx.notifySupportOnce) {\n await tx.notifySupportOnce({ incidentKey, occurrence });\n }\n return { incidentKey, recorded: true, occurrenceCount: updated.occurrenceCount,\n status: \"OPEN\" as const };\n });\n } catch {\n options.logger.error(\"operational_incident.report_failed\", {\n incidentKey, sourceService: occurrence.sourceService,\n environment: occurrence.environment, occurrenceId: occurrence.occurrenceId,\n });\n return null;\n }\n },\n };\n}\n","import { randomUUID } from \"node:crypto\";\nimport type { OperationalIncidentOccurrenceV1 } from \"./index.js\";\nimport type { IncidentPersistence, IncidentSnapshot, IncidentTransaction } from \"./reporter.js\";\n\n/** A deliberately small interface; the application's Prisma transaction client supplies it. */\nexport interface OperationalIncidentSqlClient {\n $queryRawUnsafe<T = unknown>(query: string, ...parameters: unknown[]): Promise<T>;\n}\nexport interface OperationalIncidentPrismaClient {\n $transaction<T>(fn: (tx: OperationalIncidentSqlClient) => Promise<T>, options?: {\n maxWait?: number; timeout?: number; isolationLevel?: \"Serializable\";\n }): Promise<T>;\n}\n\n/** Optional merchant-support projection. This callback MUST use the supplied transaction. */\nexport type OperationalIncidentSupportWriter = (input: {\n tx: OperationalIncidentSqlClient;\n incidentId: string;\n incidentKey: string;\n occurrence: OperationalIncidentOccurrenceV1;\n}) => Promise<void>;\n\ninterface IncidentRow {\n id: string;\n incidentKey: string;\n status: \"OPEN\" | \"RESOLVED\";\n occurrenceCount: number;\n lastOccurredAt: Date;\n}\n\nasync function rows<T>(tx: OperationalIncidentSqlClient, statement: string, ...params: unknown[]): Promise<T[]> {\n return tx.$queryRawUnsafe<T[]>(statement, ...params);\n}\n\nfunction snapshot(row: IncidentRow): IncidentSnapshot {\n return { incidentKey: row.incidentKey, status: row.status,\n occurrenceCount: row.occurrenceCount, lastOccurredAt: row.lastOccurredAt };\n}\n\nclass PgIncidentTransaction implements IncidentTransaction {\n private incidentId: string | null = null;\n private newIncident = false;\n constructor(private readonly tx: OperationalIncidentSqlClient,\n private readonly supportWriter?: OperationalIncidentSupportWriter) {}\n\n async loadOrCreate({ incidentKey, occurrence }: {\n incidentKey: string; occurrence: OperationalIncidentOccurrenceV1;\n }): Promise<IncidentSnapshot & { newlyCreated: boolean }> {\n const inserted = await rows<IncidentRow>(this.tx, `\n INSERT INTO support.\"OperationalIncident\" (\n \"id\", \"incidentKey\", \"sourceService\", \"environment\", \"category\", \"reasonCode\",\n \"resourceKey\", \"shopId\", \"severity\", \"status\", \"occurrenceCount\",\n \"firstOccurredAt\", \"lastOccurredAt\", \"lastCorrelationId\")\n VALUES ($1,$2,$3,$4,$5,$6,$7,$8,$9,'OPEN',1,$10::timestamptz,$10::timestamptz,$11)\n ON CONFLICT (\"incidentKey\") DO NOTHING RETURNING *`,\n randomUUID(), incidentKey, occurrence.sourceService, occurrence.environment,\n occurrence.category, occurrence.reasonCode, occurrence.resourceKey,\n occurrence.shopId, occurrence.severity, occurrence.occurredAt, occurrence.correlationId);\n this.newIncident = inserted.length > 0;\n const found = await rows<IncidentRow>(this.tx,\n `SELECT * FROM support.\"OperationalIncident\" WHERE \"incidentKey\" = $1 FOR UPDATE`, incidentKey);\n if (found.length !== 1) throw new Error(\"incident row not found after upsert\");\n this.incidentId = found[0]!.id;\n return { ...snapshot(found[0]!), newlyCreated: this.newIncident };\n }\n\n async insertOccurrenceIfNew({ incidentKey, occurrence }: {\n incidentKey: string; occurrence: OperationalIncidentOccurrenceV1;\n }): Promise<boolean> {\n if (!this.incidentId) throw new Error(\"incident not loaded\");\n const created = await rows<{ id: string }>(this.tx, `\n INSERT INTO support.\"OperationalIncidentEvent\"\n (\"id\", \"incidentId\", \"eventType\", \"correlationId\", \"occurredAt\")\n VALUES ($1::uuid, $2, 'OCCURRED', $3, $4::timestamptz)\n ON CONFLICT (\"id\") DO NOTHING RETURNING \"id\"`,\n occurrence.occurrenceId, this.incidentId, occurrence.correlationId, occurrence.occurredAt);\n if (!created.length) {\n if (this.newIncident) throw new Error(\"duplicate occurrence cannot create new incident\");\n const existing = await rows<{ incidentKey: string }>(this.tx, `\n SELECT i.\"incidentKey\" FROM support.\"OperationalIncidentEvent\" e\n JOIN support.\"OperationalIncident\" i ON i.\"id\" = e.\"incidentId\"\n WHERE e.\"id\" = $1::uuid`, occurrence.occurrenceId);\n if (existing.length !== 1 || existing[0]!.incidentKey !== incidentKey) {\n throw new Error(\"occurrence already belongs to another incident\");\n }\n return false;\n }\n return true;\n }\n\n async recordOccurrence({ incidentKey, occurrence, reopen, newlyCreated }: {\n incidentKey: string; occurrence: OperationalIncidentOccurrenceV1;\n reopen: boolean; newlyCreated: boolean;\n }): Promise<IncidentSnapshot> {\n if (!this.incidentId) throw new Error(\"incident not loaded\");\n if (reopen) {\n await rows(this.tx, `INSERT INTO support.\"OperationalIncidentEvent\"\n (\"id\", \"incidentId\", \"eventType\", \"correlationId\", \"occurredAt\")\n VALUES ($1::uuid,$2,'REOPENED',$3,$4::timestamptz)`,\n randomUUID(), this.incidentId, occurrence.correlationId, occurrence.occurredAt);\n }\n const updated = await rows<IncidentRow>(this.tx, `\n UPDATE support.\"OperationalIncident\" SET\n \"occurrenceCount\" = \"occurrenceCount\" + $2::integer,\n \"lastOccurredAt\" = GREATEST(\"lastOccurredAt\", $3::timestamptz),\n \"lastCorrelationId\" = $4,\n \"severity\" = $5,\n \"status\" = 'OPEN', \"resolvedAt\" = NULL,\n \"resolvedByPlatformAdminId\" = NULL, \"resolutionNote\" = NULL,\n \"revision\" = \"revision\" + 1\n WHERE \"incidentKey\" = $1 RETURNING *`, incidentKey,\n newlyCreated ? 0 : 1, occurrence.occurredAt, occurrence.correlationId, occurrence.severity);\n if (updated.length !== 1) throw new Error(\"incident update failed\");\n return snapshot(updated[0]!);\n }\n\n async notifySupportOnce(input: { incidentKey: string; occurrence: OperationalIncidentOccurrenceV1 }): Promise<void> {\n if (this.supportWriter && this.incidentId) await this.supportWriter({\n tx: this.tx, incidentId: this.incidentId,\n incidentKey: input.incidentKey, occurrence: input.occurrence,\n });\n }\n}\n\nfunction retryable(error: unknown): boolean {\n const code = typeof error === \"object\" && error !== null && \"code\" in error\n ? (error as { code?: unknown }).code : undefined;\n return code === \"P2034\" || code === \"40001\" || code === \"40P01\";\n}\n\n/**\n * PostgreSQL/Prisma adapter. No global Prisma client or credentials are created.\n * All writes and an optional support projection occur within a single transaction.\n * Uses a per-key transaction advisory lock and a row lock for cross-process safety.\n */\nexport function createPrismaOperationalIncidentPersistence(options: {\n prisma: OperationalIncidentPrismaClient;\n supportWriter?: OperationalIncidentSupportWriter;\n maxAttempts?: number;\n}): IncidentPersistence {\n const maxAttempts = options.maxAttempts ?? 3;\n if (!Number.isInteger(maxAttempts) || maxAttempts < 1 || maxAttempts > 10) {\n throw new Error(\"maxAttempts must be between 1 and 10\");\n }\n return {\n async transactionForKey<T>(key: string, fn: (tx: IncidentTransaction) => Promise<T>): Promise<T> {\n for (let attempt = 1; ; attempt++) {\n try {\n return await options.prisma.$transaction(async (tx) => {\n await rows(tx, `SELECT pg_advisory_xact_lock(hashtextextended($1::text, 0))::text AS acquired`, key);\n return fn(new PgIncidentTransaction(tx, options.supportWriter));\n }, { isolationLevel: \"Serializable\", timeout: 15000 });\n } catch (error) {\n if (attempt >= maxAttempts || !retryable(error)) throw error;\n }\n }\n },\n };\n}\n"],"mappings":";AAAA,SAAS,kBAAkB;AAC3B,SAAS,SAAS;;;ACiDX,SAAS,kCAAkC,SAI/C;AACD,SAAO;AAAA,IACL,MAAM,OAAO,KAAoD;AAC/D,UAAI;AACJ,UAAI;AACF,qBAAa,qCAAqC,GAAG;AAAA,MACvD,QAAQ;AAEN,gBAAQ,OAAO,MAAM,2CAA2C,CAAC,CAAC;AAClE,eAAO;AAAA,MACT;AACA,YAAM,cAAc,6BAA6B;AAAA,QAC/C,eAAe,WAAW;AAAA,QAAe,aAAa,WAAW;AAAA,QACjE,UAAU,WAAW;AAAA,QAAU,YAAY,WAAW;AAAA,QACtD,aAAa,WAAW;AAAA,QAAa,QAAQ,WAAW;AAAA,MAC1D,CAAC;AACD,UAAI;AACF,eAAO,MAAM,QAAQ,YAAY,kBAAkB,aAAa,OAAO,OAAO;AAC5E,gBAAM,UAAU,MAAM,GAAG,aAAa,EAAE,aAAa,WAAW,CAAC;AACjE,gBAAM,WAAW,MAAM,GAAG,sBAAsB,EAAE,aAAa,WAAW,CAAC;AAC3E,cAAI,CAAC,UAAU;AACb,mBAAO;AAAA,cAAE;AAAA,cAAa,UAAU;AAAA,cAAO,iBAAiB,QAAQ;AAAA,cAC9D,QAAQ,QAAQ;AAAA,YAAO;AAAA,UAC3B;AACA,gBAAM,UAAU,MAAM,GAAG,iBAAiB;AAAA,YAAE;AAAA,YAAa;AAAA,YACvD,QAAQ,QAAQ,WAAW;AAAA,YAAY,cAAc,QAAQ;AAAA,UAAa,CAAC;AAC7E,cAAI,QAAQ,iBAAiB,WAAW,WAAW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2
2
|
"name": "@modainteract/moda-interact-shared",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
@@ -95,6 +95,10 @@
|
|
|
95
95
|
"./merchant-knowledge/node": {
|
|
96
96
|
"types": "./dist/merchant-knowledge/node.d.ts",
|
|
97
97
|
"import": "./dist/merchant-knowledge/node.js"
|
|
98
|
+
},
|
|
99
|
+
"./incidents": {
|
|
100
|
+
"types": "./dist/incidents/index.d.ts",
|
|
101
|
+
"import": "./dist/incidents/index.js"
|
|
98
102
|
}
|
|
99
103
|
},
|
|
100
104
|
"files": [
|
|
@@ -114,7 +118,8 @@
|
|
|
114
118
|
"prepack": "npm run build",
|
|
115
119
|
"validate:commerce-entrypoints": "node scripts/validate-commerce-entrypoints.mjs",
|
|
116
120
|
"validate:arch023-shared-entrypoints": "npm run build && node scripts/validate-arch023-shared-entrypoints.mjs",
|
|
117
|
-
"validate:arch024-model-entrypoints": "npm run build && node scripts/validate-arch024-model-entrypoints.mjs"
|
|
121
|
+
"validate:arch024-model-entrypoints": "npm run build && node scripts/validate-arch024-model-entrypoints.mjs",
|
|
122
|
+
"test:arch033-incidents:postgres": "node scripts/test-arch033-incidents-postgres.mjs"
|
|
118
123
|
},
|
|
119
124
|
"dependencies": {
|
|
120
125
|
"@opentelemetry/api": "^1.9.0",
|