assignment-user-matcher 1.2.1 → 1.2.3
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 +609 -5
- package/dist/index.d.ts +7 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +13 -1
- package/dist/learning/auto-weights.d.ts +31 -0
- package/dist/learning/auto-weights.d.ts.map +1 -0
- package/dist/learning/auto-weights.js +65 -0
- package/dist/learning/features.d.ts +19 -0
- package/dist/learning/features.d.ts.map +1 -0
- package/dist/learning/features.js +55 -0
- package/dist/lua/workflow-transition.lua +29 -0
- package/dist/managers/LearningManager.d.ts +129 -0
- package/dist/managers/LearningManager.d.ts.map +1 -0
- package/dist/managers/LearningManager.js +269 -0
- package/dist/managers/ReliabilityManager.d.ts +60 -2
- package/dist/managers/ReliabilityManager.d.ts.map +1 -1
- package/dist/managers/ReliabilityManager.js +190 -9
- package/dist/managers/TelemetryManager.d.ts.map +1 -1
- package/dist/managers/WorkflowManager.d.ts +80 -6
- package/dist/managers/WorkflowManager.d.ts.map +1 -1
- package/dist/managers/WorkflowManager.js +464 -81
- package/dist/matcher.class.d.ts +180 -13
- package/dist/matcher.class.d.ts.map +1 -1
- package/dist/matcher.class.js +632 -46
- package/dist/queries/pagination.d.ts.map +1 -1
- package/dist/queries/pagination.js +9 -6
- package/dist/scoring/match-score.d.ts.map +1 -1
- package/dist/scoring/match-score.js +1 -1
- package/dist/types/matcher.d.ts +258 -9
- package/dist/types/matcher.d.ts.map +1 -1
- package/dist/utils/geo.d.ts +26 -0
- package/dist/utils/geo.d.ts.map +1 -0
- package/dist/utils/geo.js +62 -0
- package/dist/utils/keys.d.ts +15 -0
- package/dist/utils/keys.d.ts.map +1 -1
- package/dist/utils/keys.js +17 -0
- package/dist/workflow-builder.d.ts +2 -4
- package/dist/workflow-builder.d.ts.map +1 -1
- package/dist/workflow-builder.js +4 -46
- package/dist/workflow-validation.d.ts +4 -0
- package/dist/workflow-validation.d.ts.map +1 -0
- package/dist/workflow-validation.js +85 -0
- package/package.json +4 -2
|
@@ -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,
|
|
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,UAAU,EACV,gBAAgB,EAChB,kBAAkB,EACrB,MAAM,iBAAiB,CAAC;AAGzB;;GAEG;AACH,qBAAa,mBAAmB;IAC5B,OAAO,CAAC,IAAI,CAAe;IAC3B,OAAO,CAAC,aAAa,CAAkB;gBAE3B,EAAE,EAAE,MAAM,EAAE,aAAa,EAAE,eAAe;IAWtD;;OAEG;IACH,QAAQ,CAAC,IAAI,EAAE,gBAAgB,GAAG,IAAI;IAKtC;;OAEG;IACH,IAAI,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI;IAKxB;;OAEG;IACH,UAAU,CAAC,QAAQ,EAAE,OAAO,CAAC,UAAU,CAAC,GAAG,IAAI;IAK/C;;OAEG;IACH,WAAW,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,IAAI;IAM/D;;;OAGG;IACH,UAAU,CAAC,MAAM,EAAE,kBAAkB,GAAG,IAAI;IAK5C;;;;OAIG;IACH,KAAK,CAAC,SAAS,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,GAAG,IAAI;IAQpD;;;OAGG;IACH,WAAW,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,GAAG,IAAI;IAKxC;;;OAGG;IACH,QAAQ,CAAC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B,cAAc,CAC1B,EAAE,EAAE,MAAM,EACV,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,KAAK,CAAC;IACT,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,OAAO,CAAC,UAAU,CAAC,CAAC;IAChC,UAAU,CAAC,EAAE,WAAW,GAAG,UAAU,GAAG,MAAM,GAAG;QAAE,GAAG,EAAE,MAAM,CAAA;KAAE,CAAC;IACjE,QAAQ,CAAC,EAAE,gBAAgB,CAAC;IAC5B,WAAW,CAAC,EAAE;QACV,OAAO,EAAE,MAAM,CAAC;QAChB,KAAK,CAAC,EAAE,MAAM,CAAC,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
|
@@ -40,6 +40,7 @@
|
|
|
40
40
|
*/
|
|
41
41
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
42
42
|
exports.approvalWorkflow = exports.linearWorkflow = exports.workflow = exports.WorkflowBuilder = exports.WorkflowStepBuilder = void 0;
|
|
43
|
+
const workflow_validation_1 = require("./workflow-validation");
|
|
43
44
|
/**
|
|
44
45
|
* Builder for individual workflow steps.
|
|
45
46
|
*/
|
|
@@ -239,58 +240,15 @@ class WorkflowBuilder {
|
|
|
239
240
|
* @throws Error if the workflow is invalid
|
|
240
241
|
*/
|
|
241
242
|
build() {
|
|
242
|
-
|
|
243
|
-
if (!this.definition.id) {
|
|
244
|
-
throw new Error('Workflow ID is required');
|
|
245
|
-
}
|
|
246
|
-
if (!this.definition.name) {
|
|
247
|
-
throw new Error('Workflow name is required');
|
|
248
|
-
}
|
|
249
|
-
if (this.steps.length === 0) {
|
|
250
|
-
throw new Error('Workflow must have at least one step');
|
|
251
|
-
}
|
|
252
|
-
if (!this.definition.initialStepId) {
|
|
253
|
-
// Default to first step if not specified
|
|
254
|
-
this.definition.initialStepId = this.steps[0].id;
|
|
255
|
-
}
|
|
256
|
-
// Validate initial step exists
|
|
257
|
-
const initialStep = this.steps.find(s => s.id === this.definition.initialStepId);
|
|
258
|
-
if (!initialStep) {
|
|
259
|
-
throw new Error(`Initial step "${this.definition.initialStepId}" not found`);
|
|
260
|
-
}
|
|
261
|
-
// Validate all referenced step IDs exist
|
|
262
|
-
for (const step of this.steps) {
|
|
263
|
-
const taskType = step.taskType ?? 'assignment';
|
|
264
|
-
if (taskType === 'machine' && !step.machineTask?.handler) {
|
|
265
|
-
throw new Error(`Step "${step.id}" has taskType "machine" but no machineTask.handler`);
|
|
266
|
-
}
|
|
267
|
-
if (step.routing) {
|
|
268
|
-
for (const route of step.routing) {
|
|
269
|
-
if (!this.steps.find(s => s.id === route.targetStepId)) {
|
|
270
|
-
throw new Error(`Step "${step.id}" references non-existent step "${route.targetStepId}" in routing`);
|
|
271
|
-
}
|
|
272
|
-
}
|
|
273
|
-
}
|
|
274
|
-
if (step.defaultNextStepId && !this.steps.find(s => s.id === step.defaultNextStepId)) {
|
|
275
|
-
throw new Error(`Step "${step.id}" references non-existent step "${step.defaultNextStepId}" as default next`);
|
|
276
|
-
}
|
|
277
|
-
if (step.parallelStepIds) {
|
|
278
|
-
for (const parallelId of step.parallelStepIds) {
|
|
279
|
-
if (!this.steps.find(s => s.id === parallelId)) {
|
|
280
|
-
throw new Error(`Step "${step.id}" references non-existent parallel step "${parallelId}"`);
|
|
281
|
-
}
|
|
282
|
-
}
|
|
283
|
-
}
|
|
284
|
-
}
|
|
285
|
-
return {
|
|
243
|
+
return (0, workflow_validation_1.normalizeWorkflowDefinition)({
|
|
286
244
|
id: this.definition.id,
|
|
287
245
|
name: this.definition.name,
|
|
288
|
-
version: this.definition.version
|
|
246
|
+
version: this.definition.version,
|
|
289
247
|
initialStepId: this.definition.initialStepId,
|
|
290
248
|
steps: this.steps,
|
|
291
249
|
defaultTimeoutMs: this.definition.defaultTimeoutMs,
|
|
292
250
|
metadata: this.definition.metadata,
|
|
293
|
-
};
|
|
251
|
+
});
|
|
294
252
|
}
|
|
295
253
|
}
|
|
296
254
|
exports.WorkflowBuilder = WorkflowBuilder;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { WorkflowDefinition, WorkflowDefinitionInput } from './types/matcher';
|
|
2
|
+
export declare function validateWorkflowDefinition(definition: WorkflowDefinition): WorkflowDefinition;
|
|
3
|
+
export declare function normalizeWorkflowDefinition(definition: WorkflowDefinitionInput | WorkflowDefinition): WorkflowDefinition;
|
|
4
|
+
//# sourceMappingURL=workflow-validation.d.ts.map
|
|
@@ -0,0 +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;AA6BjG,wBAAgB,0BAA0B,CAAC,UAAU,EAAE,kBAAkB,GAAG,kBAAkB,CAgD7F;AAED,wBAAgB,2BAA2B,CAAC,UAAU,EAAE,uBAAuB,GAAG,kBAAkB,GAAG,kBAAkB,CAuBxH"}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.normalizeWorkflowDefinition = exports.validateWorkflowDefinition = void 0;
|
|
4
|
+
function ensureNonEmpty(value, message) {
|
|
5
|
+
if (!value?.trim()) {
|
|
6
|
+
throw new Error(message);
|
|
7
|
+
}
|
|
8
|
+
return value;
|
|
9
|
+
}
|
|
10
|
+
function validateStepBasics(step) {
|
|
11
|
+
ensureNonEmpty(step.id, 'Workflow step ID is required');
|
|
12
|
+
ensureNonEmpty(step.name, `Step "${step.id}" must have a name`);
|
|
13
|
+
if (typeof step.targetUser === 'object' && step.targetUser !== null && 'tag' in step.targetUser) {
|
|
14
|
+
ensureNonEmpty(step.targetUser.tag, `Step "${step.id}" must have a non-empty target tag`);
|
|
15
|
+
}
|
|
16
|
+
const taskType = step.taskType ?? 'assignment';
|
|
17
|
+
if (taskType === 'machine') {
|
|
18
|
+
ensureNonEmpty(step.machineTask?.handler, `Step "${step.id}" has taskType "machine" but no machineTask.handler`);
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
if (!step.assignmentTemplate) {
|
|
22
|
+
throw new Error(`Assignment step "${step.id}" is missing assignmentTemplate`);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
function validateWorkflowDefinition(definition) {
|
|
26
|
+
ensureNonEmpty(definition.id, 'Workflow ID is required');
|
|
27
|
+
ensureNonEmpty(definition.name, 'Workflow name is required');
|
|
28
|
+
if (!definition.steps.length) {
|
|
29
|
+
throw new Error('Workflow must have at least one step');
|
|
30
|
+
}
|
|
31
|
+
const stepIds = new Set();
|
|
32
|
+
for (const step of definition.steps) {
|
|
33
|
+
validateStepBasics(step);
|
|
34
|
+
if (stepIds.has(step.id)) {
|
|
35
|
+
throw new Error(`Duplicate workflow step ID "${step.id}"`);
|
|
36
|
+
}
|
|
37
|
+
stepIds.add(step.id);
|
|
38
|
+
}
|
|
39
|
+
ensureNonEmpty(definition.initialStepId, 'Workflow initial step ID is required');
|
|
40
|
+
if (!stepIds.has(definition.initialStepId)) {
|
|
41
|
+
throw new Error(`Initial step "${definition.initialStepId}" not found`);
|
|
42
|
+
}
|
|
43
|
+
for (const step of definition.steps) {
|
|
44
|
+
if (step.routing) {
|
|
45
|
+
for (const route of step.routing) {
|
|
46
|
+
if (!stepIds.has(route.targetStepId)) {
|
|
47
|
+
throw new Error(`Step "${step.id}" references non-existent step "${route.targetStepId}" in routing`);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
if (step.defaultNextStepId && !stepIds.has(step.defaultNextStepId)) {
|
|
52
|
+
throw new Error(`Step "${step.id}" references non-existent step "${step.defaultNextStepId}" as default next`);
|
|
53
|
+
}
|
|
54
|
+
if (step.parallelStepIds) {
|
|
55
|
+
for (const parallelStepId of step.parallelStepIds) {
|
|
56
|
+
if (!stepIds.has(parallelStepId)) {
|
|
57
|
+
throw new Error(`Step "${step.id}" references non-existent parallel step "${parallelStepId}"`);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
return definition;
|
|
63
|
+
}
|
|
64
|
+
exports.validateWorkflowDefinition = validateWorkflowDefinition;
|
|
65
|
+
function normalizeWorkflowDefinition(definition) {
|
|
66
|
+
const steps = [...definition.steps];
|
|
67
|
+
if (!steps.length) {
|
|
68
|
+
throw new Error('Workflow must have at least one step');
|
|
69
|
+
}
|
|
70
|
+
const normalized = {
|
|
71
|
+
id: definition.id,
|
|
72
|
+
name: definition.name,
|
|
73
|
+
version: definition.version ?? 1,
|
|
74
|
+
initialStepId: definition.initialStepId ?? steps[0].id,
|
|
75
|
+
steps,
|
|
76
|
+
};
|
|
77
|
+
if (definition.defaultTimeoutMs !== undefined) {
|
|
78
|
+
normalized.defaultTimeoutMs = definition.defaultTimeoutMs;
|
|
79
|
+
}
|
|
80
|
+
if (definition.metadata !== undefined) {
|
|
81
|
+
normalized.metadata = definition.metadata;
|
|
82
|
+
}
|
|
83
|
+
return validateWorkflowDefinition(normalized);
|
|
84
|
+
}
|
|
85
|
+
exports.normalizeWorkflowDefinition = normalizeWorkflowDefinition;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "assignment-user-matcher",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.3",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "https://github.com/ViljarVoidula/assignment-user-matcher"
|
|
@@ -50,8 +50,10 @@
|
|
|
50
50
|
},
|
|
51
51
|
"scripts": {
|
|
52
52
|
"test": "nyc mocha tests/ --recursive --extension .ts --exit",
|
|
53
|
+
"benchmark:learning": "ts-node benchmark-learning.ts",
|
|
53
54
|
"build:docs": "npx typedoc --plugin typedoc-plugin-markdown",
|
|
54
55
|
"prettier": "prettier --write .",
|
|
55
|
-
"build": "rimraf dist && tsc"
|
|
56
|
+
"build": "rimraf dist && tsc && mkdir -p dist/lua && cp src/lua/*.lua dist/lua/",
|
|
57
|
+
"release:patch": "bash ./scripts/release-patch-local.sh.example"
|
|
56
58
|
}
|
|
57
59
|
}
|