@debugbundle/cli 1.1.0 → 1.1.1
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/main.cjs +331 -32
- package/package.json +1 -1
package/dist/main.cjs
CHANGED
|
@@ -16413,6 +16413,9 @@ var IncidentsResponseSchema = external_exports.object({
|
|
|
16413
16413
|
var IncidentResponseSchema = external_exports.object({
|
|
16414
16414
|
incident: IncidentSchema
|
|
16415
16415
|
}).strict();
|
|
16416
|
+
var BulkIncidentResponseSchema = external_exports.object({
|
|
16417
|
+
incidents: external_exports.array(IncidentSchema)
|
|
16418
|
+
}).strict();
|
|
16416
16419
|
var ImprovementResponseSchema = external_exports.object({
|
|
16417
16420
|
improvement: ImprovementSchema
|
|
16418
16421
|
}).strict();
|
|
@@ -16619,6 +16622,20 @@ function createRetrievalApi(client) {
|
|
|
16619
16622
|
);
|
|
16620
16623
|
return parsed.incident;
|
|
16621
16624
|
},
|
|
16625
|
+
async resolveIncidents(input2) {
|
|
16626
|
+
const parsed = await expectParsed(
|
|
16627
|
+
client.request({
|
|
16628
|
+
method: "POST",
|
|
16629
|
+
path: "/v1/incidents/resolve",
|
|
16630
|
+
bearerToken: input2.bearerToken,
|
|
16631
|
+
body: {
|
|
16632
|
+
incident_ids: input2.incidentIds
|
|
16633
|
+
}
|
|
16634
|
+
}),
|
|
16635
|
+
BulkIncidentResponseSchema
|
|
16636
|
+
);
|
|
16637
|
+
return parsed.incidents;
|
|
16638
|
+
},
|
|
16622
16639
|
async reopenIncident(input2) {
|
|
16623
16640
|
const parsed = await expectParsed(
|
|
16624
16641
|
client.request({
|
|
@@ -16630,6 +16647,20 @@ function createRetrievalApi(client) {
|
|
|
16630
16647
|
);
|
|
16631
16648
|
return parsed.incident;
|
|
16632
16649
|
},
|
|
16650
|
+
async reopenIncidents(input2) {
|
|
16651
|
+
const parsed = await expectParsed(
|
|
16652
|
+
client.request({
|
|
16653
|
+
method: "POST",
|
|
16654
|
+
path: "/v1/incidents/reopen",
|
|
16655
|
+
bearerToken: input2.bearerToken,
|
|
16656
|
+
body: {
|
|
16657
|
+
incident_ids: input2.incidentIds
|
|
16658
|
+
}
|
|
16659
|
+
}),
|
|
16660
|
+
BulkIncidentResponseSchema
|
|
16661
|
+
);
|
|
16662
|
+
return parsed.incidents;
|
|
16663
|
+
},
|
|
16633
16664
|
async getBundle(input2) {
|
|
16634
16665
|
const bundle = await expectParsed(
|
|
16635
16666
|
client.request({
|
|
@@ -18412,7 +18443,8 @@ var STORAGE_BOOTSTRAP_STATEMENTS = [
|
|
|
18412
18443
|
`
|
|
18413
18444
|
CREATE TABLE github_dispatch_deliveries (
|
|
18414
18445
|
id uuid PRIMARY KEY,
|
|
18415
|
-
rule_id uuid NOT NULL
|
|
18446
|
+
rule_id uuid NOT NULL,
|
|
18447
|
+
rule_name text NOT NULL,
|
|
18416
18448
|
project_id uuid NOT NULL REFERENCES projects(id) ON DELETE CASCADE,
|
|
18417
18449
|
incident_id uuid REFERENCES incidents(id) ON DELETE CASCADE,
|
|
18418
18450
|
improvement_opportunity_id uuid REFERENCES improvement_opportunities(id) ON DELETE CASCADE,
|
|
@@ -18500,6 +18532,26 @@ var STORAGE_BOOTSTRAP_STATEMENTS = [
|
|
|
18500
18532
|
`
|
|
18501
18533
|
CREATE INDEX trial_lifecycle_events_org_event_created_idx
|
|
18502
18534
|
ON trial_lifecycle_events (organization_id, event_type, created_at DESC)
|
|
18535
|
+
`,
|
|
18536
|
+
`
|
|
18537
|
+
CREATE TABLE plan_cleanup_tasks (
|
|
18538
|
+
id uuid PRIMARY KEY,
|
|
18539
|
+
organization_id uuid NOT NULL REFERENCES organizations(id) ON DELETE CASCADE,
|
|
18540
|
+
project_id uuid NOT NULL REFERENCES projects(id) ON DELETE CASCADE,
|
|
18541
|
+
cleanup_type text NOT NULL
|
|
18542
|
+
CHECK (cleanup_type IN ('delete_improvement_bundle_objects')),
|
|
18543
|
+
attempt_count integer NOT NULL DEFAULT 0,
|
|
18544
|
+
last_error text,
|
|
18545
|
+
next_attempt_at timestamptz NOT NULL DEFAULT now(),
|
|
18546
|
+
completed_at timestamptz,
|
|
18547
|
+
created_at timestamptz NOT NULL DEFAULT now(),
|
|
18548
|
+
updated_at timestamptz NOT NULL DEFAULT now(),
|
|
18549
|
+
UNIQUE (project_id, cleanup_type)
|
|
18550
|
+
)
|
|
18551
|
+
`,
|
|
18552
|
+
`
|
|
18553
|
+
CREATE INDEX plan_cleanup_tasks_pending_idx
|
|
18554
|
+
ON plan_cleanup_tasks (completed_at, next_attempt_at, created_at)
|
|
18503
18555
|
`
|
|
18504
18556
|
];
|
|
18505
18557
|
|
|
@@ -19151,6 +19203,50 @@ var STORAGE_SCHEMA_MIGRATIONS = [
|
|
|
19151
19203
|
)
|
|
19152
19204
|
`
|
|
19153
19205
|
]
|
|
19206
|
+
}),
|
|
19207
|
+
defineStorageSchemaMigration({
|
|
19208
|
+
id: "202606050001_preserve_github_dispatch_history_when_rules_are_deleted",
|
|
19209
|
+
description: "Snapshot GitHub rule names onto deliveries and decouple delivery history from live rule rows.",
|
|
19210
|
+
statements: [
|
|
19211
|
+
"ALTER TABLE github_dispatch_deliveries ADD COLUMN IF NOT EXISTS rule_name text",
|
|
19212
|
+
`
|
|
19213
|
+
UPDATE github_dispatch_deliveries deliveries
|
|
19214
|
+
SET rule_name = rules.name
|
|
19215
|
+
FROM github_dispatch_rules rules
|
|
19216
|
+
WHERE deliveries.rule_id = rules.id
|
|
19217
|
+
AND deliveries.rule_name IS NULL
|
|
19218
|
+
`,
|
|
19219
|
+
"ALTER TABLE github_dispatch_deliveries ALTER COLUMN rule_name SET DEFAULT ''",
|
|
19220
|
+
"UPDATE github_dispatch_deliveries SET rule_name = '' WHERE rule_name IS NULL",
|
|
19221
|
+
"ALTER TABLE github_dispatch_deliveries ALTER COLUMN rule_name SET NOT NULL",
|
|
19222
|
+
"ALTER TABLE github_dispatch_deliveries DROP CONSTRAINT IF EXISTS github_dispatch_deliveries_rule_id_fkey"
|
|
19223
|
+
]
|
|
19224
|
+
}),
|
|
19225
|
+
defineStorageSchemaMigration({
|
|
19226
|
+
id: "202606050002_add_durable_plan_cleanup_tasks",
|
|
19227
|
+
description: "Persist retryable external cleanup tasks for side effects that cannot be completed transactionally.",
|
|
19228
|
+
statements: [
|
|
19229
|
+
`
|
|
19230
|
+
CREATE TABLE IF NOT EXISTS plan_cleanup_tasks (
|
|
19231
|
+
id uuid PRIMARY KEY,
|
|
19232
|
+
organization_id uuid NOT NULL REFERENCES organizations(id) ON DELETE CASCADE,
|
|
19233
|
+
project_id uuid NOT NULL REFERENCES projects(id) ON DELETE CASCADE,
|
|
19234
|
+
cleanup_type text NOT NULL
|
|
19235
|
+
CHECK (cleanup_type IN ('delete_improvement_bundle_objects')),
|
|
19236
|
+
attempt_count integer NOT NULL DEFAULT 0,
|
|
19237
|
+
last_error text,
|
|
19238
|
+
next_attempt_at timestamptz NOT NULL DEFAULT now(),
|
|
19239
|
+
completed_at timestamptz,
|
|
19240
|
+
created_at timestamptz NOT NULL DEFAULT now(),
|
|
19241
|
+
updated_at timestamptz NOT NULL DEFAULT now(),
|
|
19242
|
+
UNIQUE (project_id, cleanup_type)
|
|
19243
|
+
)
|
|
19244
|
+
`,
|
|
19245
|
+
`
|
|
19246
|
+
CREATE INDEX IF NOT EXISTS plan_cleanup_tasks_pending_idx
|
|
19247
|
+
ON plan_cleanup_tasks (completed_at, next_attempt_at, created_at)
|
|
19248
|
+
`
|
|
19249
|
+
]
|
|
19154
19250
|
})
|
|
19155
19251
|
];
|
|
19156
19252
|
|
|
@@ -19911,6 +20007,7 @@ var ProjectRecordSchema = external_exports.object({
|
|
|
19911
20007
|
relationship: external_exports.enum(["owned", "shared"]),
|
|
19912
20008
|
sharing_state: external_exports.enum(["private", "shared_by_you", "shared_with_you"]),
|
|
19913
20009
|
effective_role: external_exports.enum(["owner", "admin", "member"]),
|
|
20010
|
+
shared_access_suspended: external_exports.boolean().optional(),
|
|
19914
20011
|
name: external_exports.string(),
|
|
19915
20012
|
slug: external_exports.string(),
|
|
19916
20013
|
environment_default: external_exports.string(),
|
|
@@ -19933,6 +20030,7 @@ var DeletedProjectRecordSchema = external_exports.object({
|
|
|
19933
20030
|
relationship: external_exports.enum(["owned", "shared"]),
|
|
19934
20031
|
sharing_state: external_exports.enum(["private", "shared_by_you", "shared_with_you"]),
|
|
19935
20032
|
effective_role: external_exports.enum(["owner", "admin", "member"]),
|
|
20033
|
+
shared_access_suspended: external_exports.boolean().optional(),
|
|
19936
20034
|
name: external_exports.string(),
|
|
19937
20035
|
slug: external_exports.string(),
|
|
19938
20036
|
environment_default: external_exports.string(),
|
|
@@ -26789,6 +26887,15 @@ function formatIncidentDetail(incident) {
|
|
|
26789
26887
|
function formatObjectOutput(payload) {
|
|
26790
26888
|
return JSON.stringify(payload, null, 2);
|
|
26791
26889
|
}
|
|
26890
|
+
function readIncidentIdsInput(input2) {
|
|
26891
|
+
if (Array.isArray(input2.incidentIds) && input2.incidentIds.length > 0) {
|
|
26892
|
+
return input2.incidentIds;
|
|
26893
|
+
}
|
|
26894
|
+
if (typeof input2.incidentId === "string" && input2.incidentId.length > 0) {
|
|
26895
|
+
return [input2.incidentId];
|
|
26896
|
+
}
|
|
26897
|
+
return [];
|
|
26898
|
+
}
|
|
26792
26899
|
function formatIncidentContextDetail(context) {
|
|
26793
26900
|
const incidentSource = context.incident["source"];
|
|
26794
26901
|
const visibility = typeof context.visibility === "object" && context.visibility !== null && !Array.isArray(context.visibility) ? context.visibility : null;
|
|
@@ -27227,10 +27334,27 @@ async function getIncidentWithAuthCommand(input2, dependencies) {
|
|
|
27227
27334
|
});
|
|
27228
27335
|
}
|
|
27229
27336
|
async function resolveIncidentCommand(input2, api) {
|
|
27337
|
+
const incidentIds = readIncidentIdsInput(input2);
|
|
27230
27338
|
try {
|
|
27339
|
+
if (incidentIds.length > 1 && api.resolveIncidents !== void 0) {
|
|
27340
|
+
const incidents = await api.resolveIncidents({
|
|
27341
|
+
bearerToken: input2.bearerToken,
|
|
27342
|
+
incidentIds
|
|
27343
|
+
});
|
|
27344
|
+
if (input2.json) {
|
|
27345
|
+
return {
|
|
27346
|
+
exitCode: 0,
|
|
27347
|
+
output: JSON.stringify({ incidents })
|
|
27348
|
+
};
|
|
27349
|
+
}
|
|
27350
|
+
return {
|
|
27351
|
+
exitCode: 0,
|
|
27352
|
+
output: formatIncidentTable(incidents)
|
|
27353
|
+
};
|
|
27354
|
+
}
|
|
27231
27355
|
const incident = await api.resolveIncident({
|
|
27232
27356
|
bearerToken: input2.bearerToken,
|
|
27233
|
-
incidentId:
|
|
27357
|
+
incidentId: incidentIds[0]
|
|
27234
27358
|
});
|
|
27235
27359
|
if (input2.json) {
|
|
27236
27360
|
return {
|
|
@@ -27247,12 +27371,15 @@ async function resolveIncidentCommand(input2, api) {
|
|
|
27247
27371
|
}
|
|
27248
27372
|
}
|
|
27249
27373
|
async function resolveIncidentWithAuthCommand(input2, dependencies) {
|
|
27374
|
+
const incidentIds = readIncidentIdsInput(input2);
|
|
27250
27375
|
if (await shouldUseLocalRetrieval(input2.source, dependencies)) {
|
|
27251
27376
|
try {
|
|
27252
|
-
const
|
|
27377
|
+
const incidents = await Promise.all(
|
|
27378
|
+
incidentIds.map((incidentId) => resolveLocalIncident({ incidentId }, dependencies))
|
|
27379
|
+
);
|
|
27253
27380
|
return {
|
|
27254
27381
|
exitCode: 0,
|
|
27255
|
-
output: input2.json ? JSON.stringify({ incident }) : formatIncidentDetail(
|
|
27382
|
+
output: input2.json ? JSON.stringify(incidents.length === 1 ? { incident: incidents[0] } : { incidents }) : incidents.length === 1 ? formatIncidentDetail(incidents[0]) : formatIncidentTable(incidents)
|
|
27256
27383
|
};
|
|
27257
27384
|
} catch (error) {
|
|
27258
27385
|
return mapErrorToResult(error);
|
|
@@ -27260,24 +27387,80 @@ async function resolveIncidentWithAuthCommand(input2, dependencies) {
|
|
|
27260
27387
|
}
|
|
27261
27388
|
if (await shouldCombineLocalAndCloudRetrieval(input2.source, dependencies)) {
|
|
27262
27389
|
try {
|
|
27263
|
-
const
|
|
27264
|
-
|
|
27265
|
-
|
|
27266
|
-
|
|
27267
|
-
|
|
27390
|
+
const localIncidents = /* @__PURE__ */ new Map();
|
|
27391
|
+
const cloudIncidentIds = [];
|
|
27392
|
+
for (const incidentId of incidentIds) {
|
|
27393
|
+
try {
|
|
27394
|
+
localIncidents.set(incidentId, await resolveLocalIncident({ incidentId }, dependencies));
|
|
27395
|
+
} catch (error) {
|
|
27396
|
+
if (!isNotFoundRetrievalError(error)) {
|
|
27397
|
+
return mapErrorToResult(error);
|
|
27398
|
+
}
|
|
27399
|
+
cloudIncidentIds.push(incidentId);
|
|
27400
|
+
}
|
|
27401
|
+
}
|
|
27402
|
+
if (cloudIncidentIds.length === 0) {
|
|
27403
|
+
const incidents = incidentIds.map((incidentId) => localIncidents.get(incidentId));
|
|
27404
|
+
return {
|
|
27405
|
+
exitCode: 0,
|
|
27406
|
+
output: input2.json ? JSON.stringify(incidents.length === 1 ? { incident: incidents[0] } : { incidents }) : incidents.length === 1 ? formatIncidentDetail(incidents[0]) : formatIncidentTable(incidents)
|
|
27407
|
+
};
|
|
27408
|
+
}
|
|
27409
|
+
return runAuthenticatedCliCommand(input2, {
|
|
27410
|
+
createApi: createAuthenticatedRetrievalApi,
|
|
27411
|
+
dependencies,
|
|
27412
|
+
runCommand: async (authState, api) => {
|
|
27413
|
+
const cloudIncidents = cloudIncidentIds.length === 1 ? [
|
|
27414
|
+
attachSourceToRecord(
|
|
27415
|
+
await api.resolveIncident({
|
|
27416
|
+
bearerToken: authState.bearer_token,
|
|
27417
|
+
incidentId: cloudIncidentIds[0]
|
|
27418
|
+
}),
|
|
27419
|
+
"cloud"
|
|
27420
|
+
)
|
|
27421
|
+
] : (await api.resolveIncidents({
|
|
27422
|
+
bearerToken: authState.bearer_token,
|
|
27423
|
+
incidentIds: cloudIncidentIds
|
|
27424
|
+
})).map(
|
|
27425
|
+
(incident) => attachSourceToRecord(incident, "cloud")
|
|
27426
|
+
);
|
|
27427
|
+
for (const incident of cloudIncidents) {
|
|
27428
|
+
await syncCloudIncidentCacheStatus(
|
|
27429
|
+
{
|
|
27430
|
+
incidentId: incident.incident_id,
|
|
27431
|
+
incident: {
|
|
27432
|
+
...typeof incident.status === "string" ? { status: incident.status } : {},
|
|
27433
|
+
resolved_at: incident.resolved_at ?? null
|
|
27434
|
+
}
|
|
27435
|
+
},
|
|
27436
|
+
dependencies
|
|
27437
|
+
);
|
|
27438
|
+
localIncidents.set(incident.incident_id, incident);
|
|
27439
|
+
}
|
|
27440
|
+
const incidents = incidentIds.map((incidentId) => localIncidents.get(incidentId));
|
|
27441
|
+
return {
|
|
27442
|
+
exitCode: 0,
|
|
27443
|
+
output: input2.json ? JSON.stringify(incidents.length === 1 ? { incident: incidents[0] } : { incidents }) : incidents.length === 1 ? formatIncidentDetail(incidents[0]) : formatIncidentTable(incidents)
|
|
27444
|
+
};
|
|
27445
|
+
}
|
|
27446
|
+
});
|
|
27268
27447
|
} catch (error) {
|
|
27269
|
-
if (!
|
|
27448
|
+
if (!(error instanceof Error)) {
|
|
27270
27449
|
return mapErrorToResult(error);
|
|
27271
27450
|
}
|
|
27451
|
+
return mapErrorToResult(error);
|
|
27272
27452
|
}
|
|
27273
27453
|
}
|
|
27274
27454
|
return runAuthenticatedCliCommand(input2, {
|
|
27275
27455
|
createApi: createAuthenticatedRetrievalApi,
|
|
27276
27456
|
dependencies,
|
|
27277
27457
|
runCommand: (authState, api) => {
|
|
27278
|
-
const commandInput = {
|
|
27458
|
+
const commandInput = incidentIds.length === 1 ? {
|
|
27279
27459
|
bearerToken: authState.bearer_token,
|
|
27280
|
-
incidentId:
|
|
27460
|
+
incidentId: incidentIds[0]
|
|
27461
|
+
} : {
|
|
27462
|
+
bearerToken: authState.bearer_token,
|
|
27463
|
+
incidentIds
|
|
27281
27464
|
};
|
|
27282
27465
|
if (input2.json !== void 0) {
|
|
27283
27466
|
commandInput.json = input2.json;
|
|
@@ -27290,7 +27473,7 @@ async function resolveIncidentWithAuthCommand(input2, dependencies) {
|
|
|
27290
27473
|
);
|
|
27291
27474
|
await syncCloudIncidentCacheStatus(
|
|
27292
27475
|
{
|
|
27293
|
-
incidentId:
|
|
27476
|
+
incidentId: incident.incident_id,
|
|
27294
27477
|
incident: {
|
|
27295
27478
|
...typeof incident.status === "string" ? { status: incident.status } : {},
|
|
27296
27479
|
resolved_at: incident.resolved_at ?? null
|
|
@@ -27299,19 +27482,54 @@ async function resolveIncidentWithAuthCommand(input2, dependencies) {
|
|
|
27299
27482
|
dependencies
|
|
27300
27483
|
);
|
|
27301
27484
|
return incident;
|
|
27485
|
+
},
|
|
27486
|
+
resolveIncidents: async (requestInput) => {
|
|
27487
|
+
const incidents = (await api.resolveIncidents(requestInput)).map(
|
|
27488
|
+
(incident) => attachSourceToRecord(incident, "cloud")
|
|
27489
|
+
);
|
|
27490
|
+
for (const incident of incidents) {
|
|
27491
|
+
await syncCloudIncidentCacheStatus(
|
|
27492
|
+
{
|
|
27493
|
+
incidentId: incident.incident_id,
|
|
27494
|
+
incident: {
|
|
27495
|
+
...typeof incident.status === "string" ? { status: incident.status } : {},
|
|
27496
|
+
resolved_at: incident.resolved_at ?? null
|
|
27497
|
+
}
|
|
27498
|
+
},
|
|
27499
|
+
dependencies
|
|
27500
|
+
);
|
|
27501
|
+
}
|
|
27502
|
+
return incidents;
|
|
27302
27503
|
}
|
|
27303
27504
|
});
|
|
27304
27505
|
}
|
|
27305
27506
|
});
|
|
27306
27507
|
}
|
|
27307
27508
|
async function reopenIncidentCommand(input2, api) {
|
|
27509
|
+
const incidentIds = readIncidentIdsInput(input2);
|
|
27308
27510
|
if (api.reopenIncident === void 0) {
|
|
27309
27511
|
return mapUnsupportedReopenResult();
|
|
27310
27512
|
}
|
|
27311
27513
|
try {
|
|
27514
|
+
if (incidentIds.length > 1 && api.reopenIncidents !== void 0) {
|
|
27515
|
+
const incidents = await api.reopenIncidents({
|
|
27516
|
+
bearerToken: input2.bearerToken,
|
|
27517
|
+
incidentIds
|
|
27518
|
+
});
|
|
27519
|
+
if (input2.json) {
|
|
27520
|
+
return {
|
|
27521
|
+
exitCode: 0,
|
|
27522
|
+
output: JSON.stringify({ incidents })
|
|
27523
|
+
};
|
|
27524
|
+
}
|
|
27525
|
+
return {
|
|
27526
|
+
exitCode: 0,
|
|
27527
|
+
output: formatIncidentTable(incidents)
|
|
27528
|
+
};
|
|
27529
|
+
}
|
|
27312
27530
|
const incident = await api.reopenIncident({
|
|
27313
27531
|
bearerToken: input2.bearerToken,
|
|
27314
|
-
incidentId:
|
|
27532
|
+
incidentId: incidentIds[0]
|
|
27315
27533
|
});
|
|
27316
27534
|
if (input2.json) {
|
|
27317
27535
|
return {
|
|
@@ -27328,12 +27546,15 @@ async function reopenIncidentCommand(input2, api) {
|
|
|
27328
27546
|
}
|
|
27329
27547
|
}
|
|
27330
27548
|
async function reopenIncidentWithAuthCommand(input2, dependencies) {
|
|
27549
|
+
const incidentIds = readIncidentIdsInput(input2);
|
|
27331
27550
|
if (await shouldUseLocalRetrieval(input2.source, dependencies)) {
|
|
27332
27551
|
try {
|
|
27333
|
-
const
|
|
27552
|
+
const incidents = await Promise.all(
|
|
27553
|
+
incidentIds.map((incidentId) => reopenLocalIncident({ incidentId }, dependencies))
|
|
27554
|
+
);
|
|
27334
27555
|
return {
|
|
27335
27556
|
exitCode: 0,
|
|
27336
|
-
output: input2.json ? JSON.stringify({ incident }) : formatIncidentDetail(
|
|
27557
|
+
output: input2.json ? JSON.stringify(incidents.length === 1 ? { incident: incidents[0] } : { incidents }) : incidents.length === 1 ? formatIncidentDetail(incidents[0]) : formatIncidentTable(incidents)
|
|
27337
27558
|
};
|
|
27338
27559
|
} catch (error) {
|
|
27339
27560
|
return mapErrorToResult(error);
|
|
@@ -27341,24 +27562,80 @@ async function reopenIncidentWithAuthCommand(input2, dependencies) {
|
|
|
27341
27562
|
}
|
|
27342
27563
|
if (await shouldCombineLocalAndCloudRetrieval(input2.source, dependencies)) {
|
|
27343
27564
|
try {
|
|
27344
|
-
const
|
|
27345
|
-
|
|
27346
|
-
|
|
27347
|
-
|
|
27348
|
-
|
|
27565
|
+
const localIncidents = /* @__PURE__ */ new Map();
|
|
27566
|
+
const cloudIncidentIds = [];
|
|
27567
|
+
for (const incidentId of incidentIds) {
|
|
27568
|
+
try {
|
|
27569
|
+
localIncidents.set(incidentId, await reopenLocalIncident({ incidentId }, dependencies));
|
|
27570
|
+
} catch (error) {
|
|
27571
|
+
if (!isNotFoundRetrievalError(error)) {
|
|
27572
|
+
return mapErrorToResult(error);
|
|
27573
|
+
}
|
|
27574
|
+
cloudIncidentIds.push(incidentId);
|
|
27575
|
+
}
|
|
27576
|
+
}
|
|
27577
|
+
if (cloudIncidentIds.length === 0) {
|
|
27578
|
+
const incidents = incidentIds.map((incidentId) => localIncidents.get(incidentId));
|
|
27579
|
+
return {
|
|
27580
|
+
exitCode: 0,
|
|
27581
|
+
output: input2.json ? JSON.stringify(incidents.length === 1 ? { incident: incidents[0] } : { incidents }) : incidents.length === 1 ? formatIncidentDetail(incidents[0]) : formatIncidentTable(incidents)
|
|
27582
|
+
};
|
|
27583
|
+
}
|
|
27584
|
+
return runAuthenticatedCliCommand(input2, {
|
|
27585
|
+
createApi: createAuthenticatedRetrievalApi,
|
|
27586
|
+
dependencies,
|
|
27587
|
+
runCommand: async (authState, api) => {
|
|
27588
|
+
const cloudIncidents = cloudIncidentIds.length === 1 ? [
|
|
27589
|
+
attachSourceToRecord(
|
|
27590
|
+
await api.reopenIncident({
|
|
27591
|
+
bearerToken: authState.bearer_token,
|
|
27592
|
+
incidentId: cloudIncidentIds[0]
|
|
27593
|
+
}),
|
|
27594
|
+
"cloud"
|
|
27595
|
+
)
|
|
27596
|
+
] : (await api.reopenIncidents({
|
|
27597
|
+
bearerToken: authState.bearer_token,
|
|
27598
|
+
incidentIds: cloudIncidentIds
|
|
27599
|
+
})).map(
|
|
27600
|
+
(incident) => attachSourceToRecord(incident, "cloud")
|
|
27601
|
+
);
|
|
27602
|
+
for (const incident of cloudIncidents) {
|
|
27603
|
+
await syncCloudIncidentCacheStatus(
|
|
27604
|
+
{
|
|
27605
|
+
incidentId: incident.incident_id,
|
|
27606
|
+
incident: {
|
|
27607
|
+
...typeof incident.status === "string" ? { status: incident.status } : {},
|
|
27608
|
+
resolved_at: null
|
|
27609
|
+
}
|
|
27610
|
+
},
|
|
27611
|
+
dependencies
|
|
27612
|
+
);
|
|
27613
|
+
localIncidents.set(incident.incident_id, incident);
|
|
27614
|
+
}
|
|
27615
|
+
const incidents = incidentIds.map((incidentId) => localIncidents.get(incidentId));
|
|
27616
|
+
return {
|
|
27617
|
+
exitCode: 0,
|
|
27618
|
+
output: input2.json ? JSON.stringify(incidents.length === 1 ? { incident: incidents[0] } : { incidents }) : incidents.length === 1 ? formatIncidentDetail(incidents[0]) : formatIncidentTable(incidents)
|
|
27619
|
+
};
|
|
27620
|
+
}
|
|
27621
|
+
});
|
|
27349
27622
|
} catch (error) {
|
|
27350
|
-
if (!
|
|
27623
|
+
if (!(error instanceof Error)) {
|
|
27351
27624
|
return mapErrorToResult(error);
|
|
27352
27625
|
}
|
|
27626
|
+
return mapErrorToResult(error);
|
|
27353
27627
|
}
|
|
27354
27628
|
}
|
|
27355
27629
|
return runAuthenticatedCliCommand(input2, {
|
|
27356
27630
|
createApi: createAuthenticatedRetrievalApi,
|
|
27357
27631
|
dependencies,
|
|
27358
27632
|
runCommand: (authState, api) => {
|
|
27359
|
-
const commandInput = {
|
|
27633
|
+
const commandInput = incidentIds.length === 1 ? {
|
|
27360
27634
|
bearerToken: authState.bearer_token,
|
|
27361
|
-
incidentId:
|
|
27635
|
+
incidentId: incidentIds[0]
|
|
27636
|
+
} : {
|
|
27637
|
+
bearerToken: authState.bearer_token,
|
|
27638
|
+
incidentIds
|
|
27362
27639
|
};
|
|
27363
27640
|
if (input2.json !== void 0) {
|
|
27364
27641
|
commandInput.json = input2.json;
|
|
@@ -27371,7 +27648,7 @@ async function reopenIncidentWithAuthCommand(input2, dependencies) {
|
|
|
27371
27648
|
);
|
|
27372
27649
|
await syncCloudIncidentCacheStatus(
|
|
27373
27650
|
{
|
|
27374
|
-
incidentId:
|
|
27651
|
+
incidentId: incident.incident_id,
|
|
27375
27652
|
incident: {
|
|
27376
27653
|
...typeof incident.status === "string" ? { status: incident.status } : {},
|
|
27377
27654
|
resolved_at: null
|
|
@@ -27380,6 +27657,24 @@ async function reopenIncidentWithAuthCommand(input2, dependencies) {
|
|
|
27380
27657
|
dependencies
|
|
27381
27658
|
);
|
|
27382
27659
|
return incident;
|
|
27660
|
+
},
|
|
27661
|
+
reopenIncidents: async (requestInput) => {
|
|
27662
|
+
const incidents = (await api.reopenIncidents(requestInput)).map(
|
|
27663
|
+
(incident) => attachSourceToRecord(incident, "cloud")
|
|
27664
|
+
);
|
|
27665
|
+
for (const incident of incidents) {
|
|
27666
|
+
await syncCloudIncidentCacheStatus(
|
|
27667
|
+
{
|
|
27668
|
+
incidentId: incident.incident_id,
|
|
27669
|
+
incident: {
|
|
27670
|
+
...typeof incident.status === "string" ? { status: incident.status } : {},
|
|
27671
|
+
resolved_at: null
|
|
27672
|
+
}
|
|
27673
|
+
},
|
|
27674
|
+
dependencies
|
|
27675
|
+
);
|
|
27676
|
+
}
|
|
27677
|
+
return incidents;
|
|
27383
27678
|
}
|
|
27384
27679
|
});
|
|
27385
27680
|
}
|
|
@@ -28591,8 +28886,8 @@ var CLI_USAGE_LINES = [
|
|
|
28591
28886
|
" debugbundle incidents [--source <local|cloud>] [--project-id <id>] [--environment <name>] [--service <name>] [--status <status>] [--severity <severity>] [--cursor <cursor>] [--limit <n>] [--auth-file <path>] [--json]",
|
|
28592
28887
|
" debugbundle inspect <incident-id> [--source <local|cloud>] [--auth-file <path>] [--json]",
|
|
28593
28888
|
" debugbundle explain <incident-id> [--source <local|cloud>] [--auth-file <path>] [--json]",
|
|
28594
|
-
" debugbundle resolve <incident-id> [--source <local|cloud>] [--auth-file <path>] [--json]",
|
|
28595
|
-
" debugbundle reopen <incident-id> [--source <local|cloud>] [--auth-file <path>] [--json]",
|
|
28889
|
+
" debugbundle resolve <incident-id> [incident-id ...] [--source <local|cloud>] [--auth-file <path>] [--json]",
|
|
28890
|
+
" debugbundle reopen <incident-id> [incident-id ...] [--source <local|cloud>] [--auth-file <path>] [--json]",
|
|
28596
28891
|
" debugbundle bundle <incident-id> [--source <local|cloud>] [--auth-file <path>] [--json]",
|
|
28597
28892
|
" debugbundle reproduce <incident-id> [--source <local|cloud>] [--auth-file <path>] [--json]",
|
|
28598
28893
|
" debugbundle logs <incident-id> [--level <level>] [--cursor <cursor>] [--limit <n>] [--auth-file <path>] [--json]",
|
|
@@ -34193,7 +34488,7 @@ async function handleCaptureRuleCommand2(parsedArgv, dependencies) {
|
|
|
34193
34488
|
// package.json
|
|
34194
34489
|
var package_default = {
|
|
34195
34490
|
name: "@debugbundle/cli",
|
|
34196
|
-
version: "1.1.
|
|
34491
|
+
version: "1.1.1",
|
|
34197
34492
|
private: false,
|
|
34198
34493
|
description: "Command-line interface for DebugBundle",
|
|
34199
34494
|
license: "AGPL-3.0-only",
|
|
@@ -34547,9 +34842,11 @@ ${formatUsage()}`
|
|
|
34547
34842
|
}
|
|
34548
34843
|
if (command === "resolve") {
|
|
34549
34844
|
expectNoUnknownOptions(parsedArgv, ["auth-file", "json", "source"]);
|
|
34550
|
-
|
|
34845
|
+
if (parsedArgv.positionals.length < 2) {
|
|
34846
|
+
throw new CliInputError("Missing required positional argument incident-id.");
|
|
34847
|
+
}
|
|
34551
34848
|
const input2 = appendCommonAuthOptions(parsedArgv, {
|
|
34552
|
-
|
|
34849
|
+
incidentIds: parsedArgv.positionals.slice(1)
|
|
34553
34850
|
});
|
|
34554
34851
|
const source = readRetrievalSource(parsedArgv);
|
|
34555
34852
|
if (source !== void 0) {
|
|
@@ -34559,9 +34856,11 @@ ${formatUsage()}`
|
|
|
34559
34856
|
}
|
|
34560
34857
|
if (command === "reopen") {
|
|
34561
34858
|
expectNoUnknownOptions(parsedArgv, ["auth-file", "json", "source"]);
|
|
34562
|
-
|
|
34859
|
+
if (parsedArgv.positionals.length < 2) {
|
|
34860
|
+
throw new CliInputError("Missing required positional argument incident-id.");
|
|
34861
|
+
}
|
|
34563
34862
|
const input2 = appendCommonAuthOptions(parsedArgv, {
|
|
34564
|
-
|
|
34863
|
+
incidentIds: parsedArgv.positionals.slice(1)
|
|
34565
34864
|
});
|
|
34566
34865
|
const source = readRetrievalSource(parsedArgv);
|
|
34567
34866
|
if (source !== void 0) {
|