@abyss-project/console 14.1.0 → 14.2.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/CHANGELOG.md CHANGED
@@ -1,5 +1,12 @@
1
1
  # Changelog
2
2
 
3
+ ## 14.2.0
4
+
5
+ Automation credits, worst-case cost (#686).
6
+
7
+ - `computeWorkflowMaxCreditCost` now follows the engine: the execution starts on the first START connection by order only, and after each step runs a single connection, the first by order whose expression holds. The worst case is the most expensive candidate, not the sum of the children as before: a step with several outgoing connections no longer adds them up. A disabled step costs 0 and the engine moves on, except a disabled `FILTER`, which ends the execution.
8
+ - `IWorkflowCreditStructure` is extended additively: `steps[].isEnabled?` (default true), `connections[].order?` and `connections[].expression?`. `null` or an empty `expression` always matches, so the connections ranked after it are ignored; an omitted `expression` means unknown and keeps every connection as a candidate (a safe over-estimate). The new `IWorkflowCreditConnection` names the connection shape.
9
+
3
10
  ## 14.1.0
4
11
 
5
12
  Automation credits per organisation plan (#686, ADR-0198).
@@ -7,10 +7,14 @@ export interface IWorkflowCreditStructure {
7
7
  steps: {
8
8
  id: string;
9
9
  type: WorkflowStepType;
10
+ isEnabled?: boolean;
10
11
  }[];
11
- connections: {
12
- fromStepId: string | null;
13
- toStepId: string | null;
14
- }[];
12
+ connections: IWorkflowCreditConnection[];
13
+ }
14
+ export interface IWorkflowCreditConnection {
15
+ fromStepId: string | null;
16
+ toStepId: string | null;
17
+ order?: number;
18
+ expression?: string | null;
15
19
  }
16
20
  export declare const computeWorkflowMaxCreditCost: (structure: IWorkflowCreditStructure) => number;
@@ -11,22 +11,35 @@ exports.WORKFLOW_STEP_CREDIT_COST = Object.freeze({
11
11
  });
12
12
  const computeWorkflowCreditCost = (steps) => steps.reduce((total, step) => total + exports.WORKFLOW_STEP_CREDIT_COST[step.type], 0);
13
13
  exports.computeWorkflowCreditCost = computeWorkflowCreditCost;
14
+ const byOrder = (a, b) => (a.order ?? 0) - (b.order ?? 0);
15
+ const alwaysMatches = (connection) => connection.expression === null || connection.expression?.trim() === '';
14
16
  const computeWorkflowMaxCreditCost = (structure) => {
15
17
  const stepsById = new Map(structure.steps.map((step) => [step.id, step]));
16
- const childrenByStepId = new Map();
17
- const entryStepIds = [];
18
+ const entryConnection = structure.connections
19
+ .filter((connection) => connection.fromStepId === null)
20
+ .sort(byOrder)[0];
21
+ if (!entryConnection || entryConnection.toStepId === null) {
22
+ return 0;
23
+ }
24
+ const outgoing = new Map();
18
25
  for (const connection of structure.connections) {
19
- if (connection.toStepId === null) {
20
- continue;
26
+ if (connection.fromStepId !== null) {
27
+ outgoing.set(connection.fromStepId, [
28
+ ...(outgoing.get(connection.fromStepId) ?? []),
29
+ connection,
30
+ ]);
21
31
  }
22
- if (connection.fromStepId === null) {
23
- entryStepIds.push(connection.toStepId);
24
- continue;
32
+ }
33
+ const candidatesByStepId = new Map();
34
+ for (const [stepId, connections] of outgoing) {
35
+ const candidates = [];
36
+ for (const connection of [...connections].sort(byOrder)) {
37
+ candidates.push(connection.toStepId);
38
+ if (alwaysMatches(connection)) {
39
+ break;
40
+ }
25
41
  }
26
- childrenByStepId.set(connection.fromStepId, [
27
- ...(childrenByStepId.get(connection.fromStepId) ?? []),
28
- connection.toStepId,
29
- ]);
42
+ candidatesByStepId.set(stepId, candidates);
30
43
  }
31
44
  const memo = new Map();
32
45
  const visiting = new Set();
@@ -39,17 +52,18 @@ const computeWorkflowMaxCreditCost = (structure) => {
39
52
  if (known !== undefined) {
40
53
  return known;
41
54
  }
42
- visiting.add(stepId);
43
- const childCosts = (childrenByStepId.get(stepId) ?? []).map(costFrom);
44
- visiting.delete(stepId);
45
- const downstream = step.type === workflow_enum_1.WorkflowStepType.SWITCH
46
- ? Math.max(0, ...childCosts)
47
- : childCosts.reduce((total, cost) => total + cost, 0);
48
- const total = exports.WORKFLOW_STEP_CREDIT_COST[step.type] + downstream;
55
+ const isEnabled = step.isEnabled !== false;
56
+ let total = 0;
57
+ if (isEnabled || step.type !== workflow_enum_1.WorkflowStepType.FILTER) {
58
+ visiting.add(stepId);
59
+ const downstream = Math.max(0, ...(candidatesByStepId.get(stepId) ?? []).map((toStepId) => toStepId === null ? 0 : costFrom(toStepId)));
60
+ visiting.delete(stepId);
61
+ total = (isEnabled ? exports.WORKFLOW_STEP_CREDIT_COST[step.type] : 0) + downstream;
62
+ }
49
63
  memo.set(stepId, total);
50
64
  return total;
51
65
  };
52
- return entryStepIds.reduce((total, stepId) => total + costFrom(stepId), 0);
66
+ return costFrom(entryConnection.toStepId);
53
67
  };
54
68
  exports.computeWorkflowMaxCreditCost = computeWorkflowMaxCreditCost;
55
69
  //# sourceMappingURL=workflow-credit.utils.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"workflow-credit.utils.js","sourceRoot":"","sources":["../../src/utils/workflow-credit.utils.ts"],"names":[],"mappings":";;;AAAA,+DAA+D;AAMlD,QAAA,yBAAyB,GAA+C,MAAM,CAAC,MAAM,CAAC;IACjG,CAAC,gCAAgB,CAAC,MAAM,CAAC,EAAE,CAAC;IAC5B,CAAC,gCAAgB,CAAC,MAAM,CAAC,EAAE,CAAC;IAC5B,CAAC,gCAAgB,CAAC,KAAK,CAAC,EAAE,CAAC;IAC3B,CAAC,gCAAgB,CAAC,MAAM,CAAC,EAAE,CAAC;IAC5B,CAAC,gCAAgB,CAAC,IAAI,CAAC,EAAE,CAAC;CAC3B,CAAC,CAAC;AAGI,MAAM,yBAAyB,GAAG,CAAC,KAAmC,EAAU,EAAE,CACvF,KAAK,CAAC,MAAM,CAAC,CAAC,KAAK,EAAE,IAAI,EAAE,EAAE,CAAC,KAAK,GAAG,iCAAyB,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC;AADpE,QAAA,yBAAyB,6BAC2C;AAc1E,MAAM,4BAA4B,GAAG,CAAC,SAAmC,EAAU,EAAE;IAC1F,MAAM,SAAS,GAAG,IAAI,GAAG,CAAC,SAAS,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC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AAgB,CAAC,MAAM,EAAE,CAAC;YACvD,QAAQ,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;YACrB,MAAM,UAAU,GAAG,IAAI,CAAC,GAAG,CACzB,CAAC,EACD,GAAG,CAAC,kBAAkB,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,QAAQ,EAAE,EAAE,CACzD,QAAQ,KAAK,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAC3C,CACF,CAAC;YACF,QAAQ,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;YACxB,KAAK,GAAG,CAAC,SAAS,CAAC,CAAC,CAAC,iCAAyB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,UAAU,CAAC;QAC9E,CAAC;QACD,IAAI,CAAC,GAAG,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;QACxB,OAAO,KAAK,CAAC;IACf,CAAC,CAAC;IAEF,OAAO,QAAQ,CAAC,eAAe,CAAC,QAAQ,CAAC,CAAC;AAC5C,CAAC,CAAC;AA7DW,QAAA,4BAA4B,gCA6DvC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abyss-project/console",
3
- "version": "14.1.0",
3
+ "version": "14.2.0",
4
4
  "description": "Core package to interact with AbyssConsole",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",