@brandboostinggmbh/observable-workflows 0.15.0 → 0.15.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/index.d.ts CHANGED
@@ -562,7 +562,6 @@ declare const createCleanupManager: (context: {
562
562
  stepStatus: string;
563
563
  errorRef: string | null;
564
564
  resultRef: string | null;
565
- workflowName: string;
566
565
  }[];
567
566
  externalStorageKeysCount: number;
568
567
  }>;
@@ -574,7 +573,6 @@ declare const createCleanupManager: (context: {
574
573
  stepStatus: string;
575
574
  errorRef: string | null;
576
575
  resultRef: string | null;
577
- workflowName: string;
578
576
  }[];
579
577
  deletedExternalStorageKeysCount: number;
580
578
  }>;
package/dist/index.js CHANGED
@@ -1348,30 +1348,37 @@ const createCleanupManager = (context) => {
1348
1348
  const result = await context.D1.prepare(
1349
1349
  /* sql */
1350
1350
  `
1351
- SELECT instanceId, workflowName, inputRef
1351
+ SELECT instanceId, inputRef
1352
1352
  FROM WorkflowTable
1353
1353
  WHERE tenantId = ?
1354
1354
  AND startTime < (strftime('%s', 'now', '-' || ? || ' days') * 1000)
1355
1355
  AND workflowStatus IN (${statusPlaceholders})
1356
- ORDER BY workflowName, instanceId
1356
+ ORDER BY instanceId
1357
1357
  LIMIT ?
1358
1358
  `
1359
1359
  ).bind(context.tenantId, config.deleteWorkflowsOlderThanDays, ...statuses, limit).all();
1360
1360
  return result.results;
1361
1361
  };
1362
- const getAffectedSteps = async (workflows) => {
1363
- if (workflows.length === 0) return [];
1364
- const workflowIds = workflows.map(() => "?").join(", ");
1362
+ const getAffectedSteps = async (config, limit) => {
1363
+ const { statuses, statusPlaceholders } = buildStatusesAndPlaceholders(config);
1364
+ if (statuses.length === 0) return [];
1365
1365
  const result = await context.D1.prepare(
1366
1366
  /* sql */
1367
1367
  `
1368
- SELECT s.instanceId, s.stepName, s.stepStatus, s.errorRef, s.resultRef, w.workflowName
1368
+ SELECT s.instanceId, s.stepName, s.stepStatus, s.errorRef, s.resultRef
1369
1369
  FROM StepTable s
1370
- JOIN WorkflowTable w ON s.instanceId = w.instanceId
1371
- WHERE s.instanceId IN (${workflowIds})
1372
- ORDER BY w.workflowName, s.instanceId, s.stepName
1370
+ WHERE s.instanceId IN (
1371
+ SELECT instanceId
1372
+ FROM WorkflowTable
1373
+ WHERE tenantId = ?
1374
+ AND startTime < (strftime('%s', 'now', '-' || ? || ' days') * 1000)
1375
+ AND workflowStatus IN (${statusPlaceholders})
1376
+ ORDER BY instanceId
1377
+ LIMIT ?
1378
+ )
1379
+ ORDER BY s.instanceId, s.stepName
1373
1380
  `
1374
- ).bind(...workflows.map((w) => w.instanceId)).all();
1381
+ ).bind(context.tenantId, config.deleteWorkflowsOlderThanDays, ...statuses, limit).all();
1375
1382
  return result.results;
1376
1383
  };
1377
1384
  const collectExternalStorageKeys = (workflows, steps) => {
@@ -1390,7 +1397,7 @@ const createCleanupManager = (context) => {
1390
1397
  externalStorageKeysCount: 0
1391
1398
  };
1392
1399
  const affectedWorkflows = await getAffectedWorkflows(config, limit);
1393
- const affectedSteps = await getAffectedSteps(affectedWorkflows);
1400
+ const affectedSteps = await getAffectedSteps(config, limit);
1394
1401
  let externalStorageKeysCount = 0;
1395
1402
  if (config.deleteRefsFromExternalStorage && context.externalBlobStorage) {
1396
1403
  const externalKeys = collectExternalStorageKeys(affectedWorkflows, affectedSteps);
@@ -1409,7 +1416,7 @@ const createCleanupManager = (context) => {
1409
1416
  deletedExternalStorageKeysCount: 0
1410
1417
  };
1411
1418
  const deletedWorkflows = await getAffectedWorkflows(config, limit);
1412
- const deletedSteps = await getAffectedSteps(deletedWorkflows);
1419
+ const deletedSteps = await getAffectedSteps(config, limit);
1413
1420
  let deletedExternalStorageKeysCount = 0;
1414
1421
  if (config.deleteRefsFromExternalStorage && context.externalBlobStorage) {
1415
1422
  const externalKeys = collectExternalStorageKeys(deletedWorkflows, deletedSteps);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@brandboostinggmbh/observable-workflows",
3
- "version": "0.15.0",
3
+ "version": "0.15.1",
4
4
  "description": "My awesome typescript library",
5
5
  "type": "module",
6
6
  "license": "MIT",