assignment-user-matcher 1.6.0 → 1.8.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/README.md +177 -11
- package/dist/escalation/policy.d.ts +65 -0
- package/dist/escalation/policy.d.ts.map +1 -0
- package/dist/escalation/policy.js +120 -0
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/learning/auto-weights.d.ts +18 -8
- package/dist/learning/auto-weights.d.ts.map +1 -1
- package/dist/learning/auto-weights.js +120 -18
- package/dist/learning/features.d.ts +2 -2
- package/dist/learning/features.d.ts.map +1 -1
- package/dist/learning/features.js +10 -2
- package/dist/managers/LearningManager.d.ts +7 -0
- package/dist/managers/LearningManager.d.ts.map +1 -1
- package/dist/managers/LearningManager.js +85 -11
- package/dist/managers/WorkflowManager.d.ts +10 -0
- package/dist/managers/WorkflowManager.d.ts.map +1 -1
- package/dist/managers/WorkflowManager.js +57 -2
- package/dist/matcher.class.d.ts +141 -4
- package/dist/matcher.class.d.ts.map +1 -1
- package/dist/matcher.class.js +801 -27
- package/dist/queries/pagination.d.ts +5 -0
- package/dist/queries/pagination.d.ts.map +1 -1
- package/dist/queries/pagination.js +13 -1
- package/dist/scoring/match-score.d.ts +6 -0
- package/dist/scoring/match-score.d.ts.map +1 -1
- package/dist/scoring/match-score.js +17 -2
- package/dist/sla/policy.d.ts +49 -0
- package/dist/sla/policy.d.ts.map +1 -0
- package/dist/sla/policy.js +96 -0
- package/dist/tracing/decision-trace.d.ts.map +1 -1
- package/dist/tracing/decision-trace.js +4 -2
- package/dist/types/matcher.d.ts +395 -2
- package/dist/types/matcher.d.ts.map +1 -1
- package/dist/utils/keys.d.ts +8 -0
- package/dist/utils/keys.d.ts.map +1 -1
- package/dist/utils/keys.js +16 -0
- package/dist/workflow-builder.d.ts +22 -0
- package/dist/workflow-builder.d.ts.map +1 -1
- package/dist/workflow-builder.js +29 -0
- package/dist/workflow-validation.d.ts.map +1 -1
- package/dist/workflow-validation.js +32 -0
- package/package.json +2 -1
|
@@ -104,6 +104,23 @@ export declare class WorkflowStepBuilder {
|
|
|
104
104
|
* Set a timeout for this step in milliseconds.
|
|
105
105
|
*/
|
|
106
106
|
timeout(ms: number): this;
|
|
107
|
+
/**
|
|
108
|
+
* Advance to `stepId` when this step times out, instead of failing the run.
|
|
109
|
+
*
|
|
110
|
+
* The classic escalation ladder — page the primary, and if nobody responds
|
|
111
|
+
* within the timeout, move on to the secondary rather than giving up:
|
|
112
|
+
*
|
|
113
|
+
* ```typescript
|
|
114
|
+
* .step('page-primary')
|
|
115
|
+
* .targetUser({ tag: 'oncall-primary' })
|
|
116
|
+
* .timeout(60_000)
|
|
117
|
+
* .escalateTo('page-secondary')
|
|
118
|
+
* .done()
|
|
119
|
+
* ```
|
|
120
|
+
*
|
|
121
|
+
* Requires a timeout on this step or a workflow `defaultTimeout()`.
|
|
122
|
+
*/
|
|
123
|
+
escalateTo(stepId: string): this;
|
|
107
124
|
/**
|
|
108
125
|
* Finish configuring this step and return to the parent builder.
|
|
109
126
|
*/
|
|
@@ -138,6 +155,11 @@ export declare class WorkflowBuilder {
|
|
|
138
155
|
* Set the default timeout for all steps (in milliseconds).
|
|
139
156
|
*/
|
|
140
157
|
defaultTimeout(ms: number): this;
|
|
158
|
+
/**
|
|
159
|
+
* Cap how many times one run may escalate through `escalateTo()` before
|
|
160
|
+
* falling back to the ordinary failure path (default 10).
|
|
161
|
+
*/
|
|
162
|
+
maxEscalationDepth(depth: number): this;
|
|
141
163
|
/**
|
|
142
164
|
* Start building a new step.
|
|
143
165
|
* @param id - Unique identifier for the step within this workflow
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"workflow-builder.d.ts","sourceRoot":"","sources":["../src/workflow-builder.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsCG;AAEH,OAAO,KAAK,EACR,kBAAkB,EAElB,YAAY,EACZ,UAA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AC,MAAM,EAAE,GAAG,CAAC,CAAC;KAC/B,CAAC;IACF,SAAS,CAAC,EAAE,MAAM,CAAC;CACtB,CAAC,GACH,kBAAkB,CAuBpB;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAC5B,EAAE,EAAE,MAAM,EACV,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE;IACL,gBAAgB,EAAE,OAAO,CAAC,UAAU,CAAC,CAAC;IACtC,gBAAgB,EAAE,OAAO,CAAC,UAAU,CAAC,CAAC;IACtC,kBAAkB,CAAC,EAAE,OAAO,CAAC,UAAU,CAAC,CAAC;IACzC,kBAAkB,CAAC,EAAE,OAAO,CAAC,UAAU,CAAC,CAAC;IACzC,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,eAAe,CAAC,EAAE,MAAM,CAAC;CAC5B,GACF,kBAAkB,CA6BpB"}
|
package/dist/workflow-builder.js
CHANGED
|
@@ -158,6 +158,26 @@ class WorkflowStepBuilder {
|
|
|
158
158
|
this.step.timeoutMs = ms;
|
|
159
159
|
return this;
|
|
160
160
|
}
|
|
161
|
+
/**
|
|
162
|
+
* Advance to `stepId` when this step times out, instead of failing the run.
|
|
163
|
+
*
|
|
164
|
+
* The classic escalation ladder — page the primary, and if nobody responds
|
|
165
|
+
* within the timeout, move on to the secondary rather than giving up:
|
|
166
|
+
*
|
|
167
|
+
* ```typescript
|
|
168
|
+
* .step('page-primary')
|
|
169
|
+
* .targetUser({ tag: 'oncall-primary' })
|
|
170
|
+
* .timeout(60_000)
|
|
171
|
+
* .escalateTo('page-secondary')
|
|
172
|
+
* .done()
|
|
173
|
+
* ```
|
|
174
|
+
*
|
|
175
|
+
* Requires a timeout on this step or a workflow `defaultTimeout()`.
|
|
176
|
+
*/
|
|
177
|
+
escalateTo(stepId) {
|
|
178
|
+
this.step.onTimeoutStepId = stepId;
|
|
179
|
+
return this;
|
|
180
|
+
}
|
|
161
181
|
/**
|
|
162
182
|
* Finish configuring this step and return to the parent builder.
|
|
163
183
|
*/
|
|
@@ -221,6 +241,14 @@ class WorkflowBuilder {
|
|
|
221
241
|
this.definition.defaultTimeoutMs = ms;
|
|
222
242
|
return this;
|
|
223
243
|
}
|
|
244
|
+
/**
|
|
245
|
+
* Cap how many times one run may escalate through `escalateTo()` before
|
|
246
|
+
* falling back to the ordinary failure path (default 10).
|
|
247
|
+
*/
|
|
248
|
+
maxEscalationDepth(depth) {
|
|
249
|
+
this.definition.maxEscalationDepth = depth;
|
|
250
|
+
return this;
|
|
251
|
+
}
|
|
224
252
|
/**
|
|
225
253
|
* Start building a new step.
|
|
226
254
|
* @param id - Unique identifier for the step within this workflow
|
|
@@ -260,6 +288,7 @@ class WorkflowBuilder {
|
|
|
260
288
|
initialStepId: this.definition.initialStepId,
|
|
261
289
|
steps: this.steps,
|
|
262
290
|
defaultTimeoutMs: this.definition.defaultTimeoutMs,
|
|
291
|
+
maxEscalationDepth: this.definition.maxEscalationDepth,
|
|
263
292
|
metadata: this.definition.metadata,
|
|
264
293
|
});
|
|
265
294
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"workflow-validation.d.ts","sourceRoot":"","sources":["../src/workflow-validation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,uBAAuB,EAAgB,MAAM,iBAAiB,CAAC;AAiDjG,wBAAgB,0BAA0B,CAAC,UAAU,EAAE,kBAAkB,GAAG,kBAAkB,
|
|
1
|
+
{"version":3,"file":"workflow-validation.d.ts","sourceRoot":"","sources":["../src/workflow-validation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,uBAAuB,EAAgB,MAAM,iBAAiB,CAAC;AAiDjG,wBAAgB,0BAA0B,CAAC,UAAU,EAAE,kBAAkB,GAAG,kBAAkB,CAoD7F;AA+BD,wBAAgB,2BAA2B,CAAC,UAAU,EAAE,uBAAuB,GAAG,kBAAkB,GAAG,kBAAkB,CA2BxH"}
|
|
@@ -79,9 +79,38 @@ function validateWorkflowDefinition(definition) {
|
|
|
79
79
|
}
|
|
80
80
|
}
|
|
81
81
|
}
|
|
82
|
+
validateEscalationTargets(definition, stepIds);
|
|
82
83
|
return definition;
|
|
83
84
|
}
|
|
84
85
|
exports.validateWorkflowDefinition = validateWorkflowDefinition;
|
|
86
|
+
/**
|
|
87
|
+
* `onTimeoutStepId` turns a timeout into a forward hop instead of a failure.
|
|
88
|
+
* Everything that would make that hop meaningless or non-terminating is
|
|
89
|
+
* rejected at registration rather than discovered at 3am.
|
|
90
|
+
*/
|
|
91
|
+
function validateEscalationTargets(definition, stepIds) {
|
|
92
|
+
const parallelMembers = new Set();
|
|
93
|
+
for (const step of definition.steps) {
|
|
94
|
+
for (const id of step.parallelStepIds ?? [])
|
|
95
|
+
parallelMembers.add(id);
|
|
96
|
+
}
|
|
97
|
+
for (const step of definition.steps) {
|
|
98
|
+
if (!step.onTimeoutStepId)
|
|
99
|
+
continue;
|
|
100
|
+
if (!stepIds.has(step.onTimeoutStepId)) {
|
|
101
|
+
throw new Error(`Step "${step.id}" escalates to non-existent step "${step.onTimeoutStepId}" on timeout`);
|
|
102
|
+
}
|
|
103
|
+
if (step.onTimeoutStepId === step.id) {
|
|
104
|
+
throw new Error(`Step "${step.id}" escalates to itself on timeout, which never terminates`);
|
|
105
|
+
}
|
|
106
|
+
if (!step.timeoutMs && !definition.defaultTimeoutMs) {
|
|
107
|
+
throw new Error(`Step "${step.id}" escalates on timeout but has no timeoutMs (or workflow defaultTimeoutMs)`);
|
|
108
|
+
}
|
|
109
|
+
if (parallelMembers.has(step.id)) {
|
|
110
|
+
throw new Error(`Step "${step.id}" is part of a parallel group; escalate-on-timeout is not supported there`);
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
}
|
|
85
114
|
function normalizeWorkflowDefinition(definition) {
|
|
86
115
|
const steps = [...definition.steps];
|
|
87
116
|
if (!steps.length) {
|
|
@@ -97,6 +126,9 @@ function normalizeWorkflowDefinition(definition) {
|
|
|
97
126
|
if (definition.defaultTimeoutMs !== undefined) {
|
|
98
127
|
normalized.defaultTimeoutMs = definition.defaultTimeoutMs;
|
|
99
128
|
}
|
|
129
|
+
if (definition.maxEscalationDepth !== undefined) {
|
|
130
|
+
normalized.maxEscalationDepth = definition.maxEscalationDepth;
|
|
131
|
+
}
|
|
100
132
|
if (definition.metadata !== undefined) {
|
|
101
133
|
normalized.metadata = definition.metadata;
|
|
102
134
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "assignment-user-matcher",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.8.0",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "https://github.com/ViljarVoidula/assignment-user-matcher"
|
|
@@ -28,6 +28,7 @@
|
|
|
28
28
|
"scripts": {
|
|
29
29
|
"test": "nyc mocha tests/ --recursive --extension .ts --exit",
|
|
30
30
|
"benchmark:learning": "ts-node benchmark-learning.ts",
|
|
31
|
+
"benchmark:weights": "ts-node benchmark-weights.ts",
|
|
31
32
|
"build:docs": "npx typedoc --plugin typedoc-plugin-markdown",
|
|
32
33
|
"prettier": "prettier --write .",
|
|
33
34
|
"build": "rimraf dist && tsc && mkdir -p dist/lua && cp src/lua/*.lua dist/lua/",
|