@girverket/xenocline 0.0.9
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/LICENSE.md +66 -0
- package/README.md +739 -0
- package/dist/aggregator.d.ts +53 -0
- package/dist/aggregator.js +31 -0
- package/dist/aggregator.js.map +1 -0
- package/dist/constants.d.ts +2 -0
- package/dist/context.d.ts +3 -0
- package/dist/event/aggregator.d.ts +16 -0
- package/dist/event/aggregator.js +29 -0
- package/dist/event/aggregator.js.map +1 -0
- package/dist/event/event.d.ts +14 -0
- package/dist/event/event.js +12 -0
- package/dist/event/event.js.map +1 -0
- package/dist/event/handler.d.ts +7 -0
- package/dist/event/handler.js +8 -0
- package/dist/event/handler.js.map +1 -0
- package/dist/event/node.d.ts +40 -0
- package/dist/event/node.js +24 -0
- package/dist/event/node.js.map +1 -0
- package/dist/event/phase.d.ts +15 -0
- package/dist/event/phase.js +12 -0
- package/dist/event/phase.js.map +1 -0
- package/dist/event/process.d.ts +14 -0
- package/dist/event/process.js +15 -0
- package/dist/event/process.js.map +1 -0
- package/dist/event/transition.d.ts +45 -0
- package/dist/event/transition.js +35 -0
- package/dist/event/transition.js.map +1 -0
- package/dist/event.d.ts +30 -0
- package/dist/execution/aggregator.d.ts +23 -0
- package/dist/execution/aggregator.js +81 -0
- package/dist/execution/aggregator.js.map +1 -0
- package/dist/execution/event.d.ts +26 -0
- package/dist/execution/event.js +29 -0
- package/dist/execution/event.js.map +1 -0
- package/dist/execution/next.d.ts +7 -0
- package/dist/execution/next.js +137 -0
- package/dist/execution/next.js.map +1 -0
- package/dist/execution/node.d.ts +4 -0
- package/dist/execution/node.js +194 -0
- package/dist/execution/node.js.map +1 -0
- package/dist/execution/phase.d.ts +5 -0
- package/dist/execution/phase.js +23 -0
- package/dist/execution/phase.js.map +1 -0
- package/dist/execution/process.d.ts +35 -0
- package/dist/execution/process.js +115 -0
- package/dist/execution/process.js.map +1 -0
- package/dist/input.d.ts +6 -0
- package/dist/input.js +4 -0
- package/dist/input.js.map +1 -0
- package/dist/logger.d.ts +12 -0
- package/dist/node/aggregatornode.d.ts +40 -0
- package/dist/node/aggregatornode.js +41 -0
- package/dist/node/aggregatornode.js.map +1 -0
- package/dist/node/node.d.ts +18 -0
- package/dist/node/node.js +80 -0
- package/dist/node/node.js.map +1 -0
- package/dist/node/phasenode.d.ts +49 -0
- package/dist/node/phasenode.js +37 -0
- package/dist/node/phasenode.js.map +1 -0
- package/dist/output.d.ts +6 -0
- package/dist/phase.d.ts +23 -0
- package/dist/phase.js +24 -0
- package/dist/phase.js.map +1 -0
- package/dist/process.d.ts +15 -0
- package/dist/process.js +106 -0
- package/dist/process.js.map +1 -0
- package/dist/transition/beginning.d.ts +19 -0
- package/dist/transition/beginning.js +31 -0
- package/dist/transition/beginning.js.map +1 -0
- package/dist/transition/connection.d.ts +55 -0
- package/dist/transition/connection.js +90 -0
- package/dist/transition/connection.js.map +1 -0
- package/dist/transition/decision.d.ts +20 -0
- package/dist/transition/decision.js +47 -0
- package/dist/transition/decision.js.map +1 -0
- package/dist/transition/next.d.ts +13 -0
- package/dist/transition/next.js +81 -0
- package/dist/transition/next.js.map +1 -0
- package/dist/transition/termination.d.ts +17 -0
- package/dist/transition/termination.js +50 -0
- package/dist/transition/termination.js.map +1 -0
- package/dist/transition/transition.d.ts +16 -0
- package/dist/transition/transition.js +72 -0
- package/dist/transition/transition.js.map +1 -0
- package/dist/util/general.d.ts +4 -0
- package/dist/util/general.js +6 -0
- package/dist/util/general.js.map +1 -0
- package/dist/utility/event/eventfilter.d.ts +7 -0
- package/dist/utility/event/eventfilter.js +15 -0
- package/dist/utility/event/eventfilter.js.map +1 -0
- package/dist/utility/event/filteredhandler.d.ts +13 -0
- package/dist/utility/event/filteredhandler.js +18 -0
- package/dist/utility/event/filteredhandler.js.map +1 -0
- package/dist/utility/event/logginghandler.d.ts +12 -0
- package/dist/xenocline.cjs +1362 -0
- package/dist/xenocline.cjs.map +1 -0
- package/dist/xenocline.d.ts +72 -0
- package/dist/xenocline.js +21 -0
- package/dist/xenocline.js.map +1 -0
- package/output/kodrdriv/260109-2305-commit-message.md +3 -0
- package/output/kodrdriv/260109-2307-release-notes.md +28 -0
- package/output/kodrdriv/260109-2318-commit-message.md +6 -0
- package/output/kodrdriv/260109-2321-release-notes.md +39 -0
- package/output/kodrdriv/RELEASE_NOTES.md +37 -0
- package/output/kodrdriv/RELEASE_TITLE.md +1 -0
- package/output/kodrdriv/agentic-reflection-commit-2026-01-10T07-05-39-771Z.md +52 -0
- package/output/kodrdriv/agentic-reflection-commit-2026-01-10T07-18-31-315Z.md +55 -0
- package/output/kodrdriv/agentic-reflection-release-2026-01-10T07-07-33-739Z.md +257 -0
- package/output/kodrdriv/agentic-reflection-release-2026-01-10T07-21-54-717Z.md +394 -0
- package/package.json +69 -0
- package/scripts/pre-commit-hook.sh +53 -0
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export type TransitionType = 'connection' | 'decision' | 'termination' | 'beginning';
|
|
2
|
+
/**
|
|
3
|
+
* Base interface for transitions between nodes in a process.
|
|
4
|
+
* It is primarily a marker interface that allows Connection,
|
|
5
|
+
* Decision and Termination to share common generics.
|
|
6
|
+
*/
|
|
7
|
+
export interface Transition {
|
|
8
|
+
id: string;
|
|
9
|
+
type: TransitionType;
|
|
10
|
+
}
|
|
11
|
+
export declare const createTransition: (type: TransitionType, id: string) => Readonly<Transition>;
|
|
12
|
+
export declare const isTransition: (item: any) => item is Transition;
|
|
13
|
+
export declare const validateTransition: (item: any, coordinates?: string[]) => Array<{
|
|
14
|
+
coordinates: string[];
|
|
15
|
+
error: string;
|
|
16
|
+
}>;
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
const createTransition = (type, id)=>{
|
|
2
|
+
return {
|
|
3
|
+
id,
|
|
4
|
+
type
|
|
5
|
+
};
|
|
6
|
+
};
|
|
7
|
+
const isTransition = (item)=>{
|
|
8
|
+
return item !== null && typeof item === 'object' && typeof item.id === 'string' && (item.type === 'connection' || item.type === 'decision' || item.type === 'termination' || item.type === 'beginning');
|
|
9
|
+
};
|
|
10
|
+
const validateTransition = (item, coordinates)=>{
|
|
11
|
+
const errors = [];
|
|
12
|
+
const currentCoordinates = [
|
|
13
|
+
...coordinates || [],
|
|
14
|
+
'Transition'
|
|
15
|
+
];
|
|
16
|
+
if (item === undefined || item === null) {
|
|
17
|
+
errors.push({
|
|
18
|
+
coordinates: [
|
|
19
|
+
...currentCoordinates
|
|
20
|
+
],
|
|
21
|
+
error: 'Transition is undefined or null.'
|
|
22
|
+
});
|
|
23
|
+
return errors;
|
|
24
|
+
}
|
|
25
|
+
if (typeof item !== 'object') {
|
|
26
|
+
errors.push({
|
|
27
|
+
coordinates: [
|
|
28
|
+
...currentCoordinates
|
|
29
|
+
],
|
|
30
|
+
error: 'Transition is not an object.'
|
|
31
|
+
});
|
|
32
|
+
return errors;
|
|
33
|
+
}
|
|
34
|
+
if (item.id === undefined || typeof item.id !== 'string') {
|
|
35
|
+
errors.push({
|
|
36
|
+
coordinates: [
|
|
37
|
+
...currentCoordinates
|
|
38
|
+
],
|
|
39
|
+
error: 'Transition id is undefined or not a string.'
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
if (item.type === undefined || typeof item.type !== 'string') {
|
|
43
|
+
errors.push({
|
|
44
|
+
coordinates: [
|
|
45
|
+
...currentCoordinates
|
|
46
|
+
],
|
|
47
|
+
error: 'Transition type is undefined or not a string.'
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
if (item.type !== 'connection' && item.type !== 'decision' && item.type !== 'termination' && item.type !== 'beginning') {
|
|
51
|
+
errors.push({
|
|
52
|
+
coordinates: [
|
|
53
|
+
...currentCoordinates
|
|
54
|
+
],
|
|
55
|
+
error: 'Transition type is not a valid type.'
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
// We have an id, push to current coordinates
|
|
59
|
+
currentCoordinates.push(`Transition: ${item.id}`);
|
|
60
|
+
if (item.type === undefined || typeof item.type !== 'string') {
|
|
61
|
+
errors.push({
|
|
62
|
+
coordinates: [
|
|
63
|
+
...currentCoordinates
|
|
64
|
+
],
|
|
65
|
+
error: 'Transition type is undefined or not a string.'
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
return errors;
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
export { createTransition, isTransition, validateTransition };
|
|
72
|
+
//# sourceMappingURL=transition.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transition.js","sources":["../../src/transition/transition.ts"],"sourcesContent":["export type TransitionType = 'connection' | 'decision' | 'termination' | 'beginning';\n\n/**\n * Base interface for transitions between nodes in a process.\n * It is primarily a marker interface that allows Connection,\n * Decision and Termination to share common generics.\n */\nexport interface Transition {\n id: string;\n type: TransitionType;\n}\n\nexport const createTransition = (type: TransitionType, id: string): Readonly<Transition> => {\n return {\n id,\n type,\n };\n};\n\nexport const isTransition = (item: any): item is Transition => {\n return item !== null && typeof item === 'object' && typeof item.id === 'string' && (item.type === 'connection' || item.type === 'decision' || item.type === 'termination' || item.type === 'beginning');\n};\n\nexport const validateTransition = (item: any, coordinates?: string[]): Array<{ coordinates: string[], error: string }> => {\n const errors: Array<{ coordinates: string[], error: string }> = [];\n const currentCoordinates = [...(coordinates || []), 'Transition'];\n\n if (item === undefined || item === null) {\n errors.push({ coordinates: [...currentCoordinates], error: 'Transition is undefined or null.' });\n return errors;\n }\n\n if (typeof item !== 'object') {\n errors.push({ coordinates: [...currentCoordinates], error: 'Transition is not an object.' });\n return errors;\n }\n\n if (item.id === undefined || typeof item.id !== 'string') {\n errors.push({ coordinates: [...currentCoordinates], error: 'Transition id is undefined or not a string.' });\n }\n\n if (item.type === undefined || typeof item.type !== 'string') {\n errors.push({ coordinates: [...currentCoordinates], error: 'Transition type is undefined or not a string.' });\n }\n\n if (item.type !== 'connection' && item.type !== 'decision' && item.type !== 'termination' && item.type !== 'beginning') {\n errors.push({ coordinates: [...currentCoordinates], error: 'Transition type is not a valid type.' });\n }\n\n // We have an id, push to current coordinates\n currentCoordinates.push(`Transition: ${item.id}`);\n\n if (item.type === undefined || typeof item.type !== 'string') {\n errors.push({ coordinates: [...currentCoordinates], error: 'Transition type is undefined or not a string.' });\n }\n\n return errors;\n};"],"names":["createTransition","type","id","isTransition","item","validateTransition","coordinates","errors","currentCoordinates","undefined","push","error"],"mappings":"AAYO,MAAMA,gBAAAA,GAAmB,CAACC,IAAAA,EAAsBC,EAAAA,GAAAA;IACnD,OAAO;AACHA,QAAAA,EAAAA;AACAD,QAAAA;AACJ,KAAA;AACJ;AAEO,MAAME,eAAe,CAACC,IAAAA,GAAAA;IACzB,OAAOA,IAAAA,KAAS,IAAA,IAAQ,OAAOA,IAAAA,KAAS,QAAA,IAAY,OAAOA,IAAAA,CAAKF,EAAE,KAAK,QAAA,KAAaE,IAAAA,CAAKH,IAAI,KAAK,YAAA,IAAgBG,IAAAA,CAAKH,IAAI,KAAK,UAAA,IAAcG,IAAAA,CAAKH,IAAI,KAAK,aAAA,IAAiBG,IAAAA,CAAKH,IAAI,KAAK,WAAU,CAAA;AACzM;AAEO,MAAMI,kBAAAA,GAAqB,CAACD,IAAAA,EAAWE,WAAAA,GAAAA;AAC1C,IAAA,MAAMC,SAA0D,EAAE;AAClE,IAAA,MAAMC,kBAAAA,GAAqB;AAAKF,QAAAA,GAAAA,WAAAA,IAAe,EAAE;AAAG,QAAA;AAAa,KAAA;IAEjE,IAAIF,IAAAA,KAASK,SAAAA,IAAaL,IAAAA,KAAS,IAAA,EAAM;AACrCG,QAAAA,MAAAA,CAAOG,IAAI,CAAC;YAAEJ,WAAAA,EAAa;AAAIE,gBAAAA,GAAAA;AAAmB,aAAA;YAAEG,KAAAA,EAAO;AAAmC,SAAA,CAAA;QAC9F,OAAOJ,MAAAA;AACX,IAAA;IAEA,IAAI,OAAOH,SAAS,QAAA,EAAU;AAC1BG,QAAAA,MAAAA,CAAOG,IAAI,CAAC;YAAEJ,WAAAA,EAAa;AAAIE,gBAAAA,GAAAA;AAAmB,aAAA;YAAEG,KAAAA,EAAO;AAA+B,SAAA,CAAA;QAC1F,OAAOJ,MAAAA;AACX,IAAA;IAEA,IAAIH,IAAAA,CAAKF,EAAE,KAAKO,SAAAA,IAAa,OAAOL,IAAAA,CAAKF,EAAE,KAAK,QAAA,EAAU;AACtDK,QAAAA,MAAAA,CAAOG,IAAI,CAAC;YAAEJ,WAAAA,EAAa;AAAIE,gBAAAA,GAAAA;AAAmB,aAAA;YAAEG,KAAAA,EAAO;AAA8C,SAAA,CAAA;AAC7G,IAAA;IAEA,IAAIP,IAAAA,CAAKH,IAAI,KAAKQ,SAAAA,IAAa,OAAOL,IAAAA,CAAKH,IAAI,KAAK,QAAA,EAAU;AAC1DM,QAAAA,MAAAA,CAAOG,IAAI,CAAC;YAAEJ,WAAAA,EAAa;AAAIE,gBAAAA,GAAAA;AAAmB,aAAA;YAAEG,KAAAA,EAAO;AAAgD,SAAA,CAAA;AAC/G,IAAA;AAEA,IAAA,IAAIP,IAAAA,CAAKH,IAAI,KAAK,YAAA,IAAgBG,KAAKH,IAAI,KAAK,UAAA,IAAcG,IAAAA,CAAKH,IAAI,KAAK,aAAA,IAAiBG,IAAAA,CAAKH,IAAI,KAAK,WAAA,EAAa;AACpHM,QAAAA,MAAAA,CAAOG,IAAI,CAAC;YAAEJ,WAAAA,EAAa;AAAIE,gBAAAA,GAAAA;AAAmB,aAAA;YAAEG,KAAAA,EAAO;AAAuC,SAAA,CAAA;AACtG,IAAA;;AAGAH,IAAAA,kBAAAA,CAAmBE,IAAI,CAAC,CAAC,YAAY,EAAEN,IAAAA,CAAKF,EAAE,CAAA,CAAE,CAAA;IAEhD,IAAIE,IAAAA,CAAKH,IAAI,KAAKQ,SAAAA,IAAa,OAAOL,IAAAA,CAAKH,IAAI,KAAK,QAAA,EAAU;AAC1DM,QAAAA,MAAAA,CAAOG,IAAI,CAAC;YAAEJ,WAAAA,EAAa;AAAIE,gBAAAA,GAAAA;AAAmB,aAAA;YAAEG,KAAAA,EAAO;AAAgD,SAAA,CAAA;AAC/G,IAAA;IAEA,OAAOJ,MAAAA;AACX;;;;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"general.js","sources":["../../src/util/general.ts"],"sourcesContent":["export const clean = (obj: any) => {\n return Object.fromEntries(\n Object.entries(obj).filter(([_, v]) => v !== undefined)\n );\n}\n\n//Recursive implementation of jSON.stringify;\nexport const stringifyJSON = function (obj: any, visited: Set<any> = new Set()): string {\n const arrOfKeyVals: string[] = [];\n const arrVals: string[] = [];\n let objKeys: string[] = [];\n\n /*********CHECK FOR PRIMITIVE TYPES**********/\n if (typeof obj === 'number' || typeof obj === 'boolean' || obj === null)\n return '' + obj;\n else if (typeof obj === 'string')\n return '\"' + obj + '\"';\n\n /*********DETECT CIRCULAR REFERENCES**********/\n if (obj instanceof Object && visited.has(obj)) {\n return '\"(circular)\"';\n }\n\n /*********CHECK FOR ARRAY**********/\n else if (Array.isArray(obj)) {\n //check for empty array\n if (obj[0] === undefined)\n return '[]';\n else {\n // Add array to visited before processing its elements\n visited.add(obj);\n obj.forEach(function (el) {\n arrVals.push(stringifyJSON(el, visited));\n });\n return '[' + arrVals + ']';\n }\n }\n /*********CHECK FOR OBJECT**********/\n else if (obj instanceof Object) {\n // Add object to visited before processing its properties\n visited.add(obj);\n //get object keys\n objKeys = Object.keys(obj);\n //set key output;\n objKeys.forEach(function (key) {\n const keyOut = '\"' + key + '\":';\n const keyValOut = obj[key];\n //skip functions and undefined properties\n if (keyValOut instanceof Function || keyValOut === undefined)\n return; // Skip this entry entirely instead of pushing an empty string\n else if (typeof keyValOut === 'string')\n arrOfKeyVals.push(keyOut + '\"' + keyValOut + '\"');\n else if (typeof keyValOut === 'boolean' || typeof keyValOut === 'number' || keyValOut === null)\n arrOfKeyVals.push(keyOut + keyValOut);\n //check for nested objects, call recursively until no more objects\n else if (keyValOut instanceof Object) {\n arrOfKeyVals.push(keyOut + stringifyJSON(keyValOut, visited));\n }\n });\n return '{' + arrOfKeyVals + '}';\n }\n return '';\n};"],"names":["clean","obj","Object","fromEntries","entries","filter","_","v","undefined"],"mappings":"AAAO,MAAMA,QAAQ,CAACC,GAAAA,GAAAA;AAClB,IAAA,OAAOC,MAAAA,CAAOC,WAAW,CACrBD,MAAAA,CAAOE,OAAO,CAACH,GAAAA,CAAAA,CAAKI,MAAM,CAAC,CAAC,CAACC,CAAAA,EAAGC,CAAAA,CAAE,GAAKA,CAAAA,KAAMC,SAAAA,CAAAA,CAAAA;AAErD;;;;"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { Event } from '../../event/event';
|
|
2
|
+
export interface EventFilter<E extends Event = Event> {
|
|
3
|
+
type?: string[];
|
|
4
|
+
stage?: string[];
|
|
5
|
+
filter: (event: E) => boolean;
|
|
6
|
+
}
|
|
7
|
+
export declare const createEventFilter: <E extends Event = Event>(type?: string[], stage?: string[]) => EventFilter<E>;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
const createEventFilter = (type, stage)=>{
|
|
2
|
+
const filterFn = (event)=>{
|
|
3
|
+
const typeMatch = !type || type.includes(event.type);
|
|
4
|
+
const stageMatch = !stage || stage.includes(event.stage);
|
|
5
|
+
return typeMatch && stageMatch;
|
|
6
|
+
};
|
|
7
|
+
return {
|
|
8
|
+
type,
|
|
9
|
+
stage,
|
|
10
|
+
filter: filterFn
|
|
11
|
+
};
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
export { createEventFilter };
|
|
15
|
+
//# sourceMappingURL=eventfilter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"eventfilter.js","sources":["../../../src/utility/event/eventfilter.ts"],"sourcesContent":["import type { Event } from '../../event/event';\n\nexport interface EventFilter<E extends Event = Event> {\n type?: string[];\n stage?: string[];\n filter: (event: E) => boolean;\n}\n\nexport const createEventFilter = <E extends Event = Event>(\n type?: string[],\n stage?: string[]\n): EventFilter<E> => {\n const filterFn = (event: E): boolean => {\n const typeMatch = !type || type.includes(event.type);\n const stageMatch = !stage || stage.includes(event.stage);\n return typeMatch && stageMatch;\n };\n\n return {\n type,\n stage,\n filter: filterFn,\n };\n};\n"],"names":["createEventFilter","type","stage","filterFn","event","typeMatch","includes","stageMatch","filter"],"mappings":"AAQO,MAAMA,iBAAAA,GAAoB,CAC7BC,IAAAA,EACAC,KAAAA,GAAAA;AAEA,IAAA,MAAMC,WAAW,CAACC,KAAAA,GAAAA;AACd,QAAA,MAAMC,YAAY,CAACJ,IAAAA,IAAQA,KAAKK,QAAQ,CAACF,MAAMH,IAAI,CAAA;AACnD,QAAA,MAAMM,aAAa,CAACL,KAAAA,IAASA,MAAMI,QAAQ,CAACF,MAAMF,KAAK,CAAA;AACvD,QAAA,OAAOG,SAAAA,IAAaE,UAAAA;AACxB,IAAA,CAAA;IAEA,OAAO;AACHN,QAAAA,IAAAA;AACAC,QAAAA,KAAAA;QACAM,MAAAA,EAAQL;AACZ,KAAA;AACJ;;;;"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Event } from '../../event/event';
|
|
2
|
+
import { Context } from '../../context';
|
|
3
|
+
import { EventHandler, HandleMethod } from '../../event/handler';
|
|
4
|
+
import { EventFilter } from './eventfilter';
|
|
5
|
+
export interface FilteredHandler<E extends Event = Event, C extends Context = Context> extends EventHandler<E, C> {
|
|
6
|
+
filter: EventFilter<E>;
|
|
7
|
+
handler: EventHandler<E, C>;
|
|
8
|
+
}
|
|
9
|
+
export declare const createFilteredHandler: <E extends Event = Event, C extends Context = Context>(filter: EventFilter<E>, options: {
|
|
10
|
+
handler: EventHandler<E, C>;
|
|
11
|
+
} | {
|
|
12
|
+
handle: HandleMethod<E, C>;
|
|
13
|
+
}) => FilteredHandler<E, C>;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { createEventHandler } from '../../event/handler.js';
|
|
2
|
+
|
|
3
|
+
const createFilteredHandler = (filter, options)=>{
|
|
4
|
+
const handler = 'handler' in options ? options.handler : createEventHandler(options.handle);
|
|
5
|
+
const handle = async (event, context)=>{
|
|
6
|
+
if (filter.filter(event)) {
|
|
7
|
+
await handler.handle(event, context);
|
|
8
|
+
}
|
|
9
|
+
};
|
|
10
|
+
return {
|
|
11
|
+
filter,
|
|
12
|
+
handler,
|
|
13
|
+
handle
|
|
14
|
+
};
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
export { createFilteredHandler };
|
|
18
|
+
//# sourceMappingURL=filteredhandler.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"filteredhandler.js","sources":["../../../src/utility/event/filteredhandler.ts"],"sourcesContent":["import type { Event } from '../../event/event';\nimport type { Context } from '../../context';\nimport { createEventHandler, EventHandler, HandleMethod } from '../../event/handler';\nimport type { EventFilter } from './eventfilter';\n\nexport interface FilteredHandler<E extends Event = Event, C extends Context = Context> extends EventHandler<E, C> {\n filter: EventFilter<E>;\n handler: EventHandler<E, C>;\n}\n\nexport const createFilteredHandler = <E extends Event = Event, C extends Context = Context>(\n filter: EventFilter<E>,\n options: { handler: EventHandler<E, C> } | { handle: HandleMethod<E, C> }\n): FilteredHandler<E, C> => {\n const handler: EventHandler<E, C> = 'handler' in options ? options.handler : createEventHandler<E, C>(options.handle);\n\n const handle: HandleMethod<E, C> = async (event, context) => {\n if (filter.filter(event)) {\n await handler.handle(event, context);\n }\n };\n\n return {\n filter,\n handler,\n handle,\n };\n};\n"],"names":["createFilteredHandler","filter","options","handler","createEventHandler","handle","event","context"],"mappings":";;AAUO,MAAMA,qBAAAA,GAAwB,CACjCC,MAAAA,EACAC,OAAAA,GAAAA;IAEA,MAAMC,OAAAA,GAA8B,aAAaD,OAAAA,GAAUA,OAAAA,CAAQC,OAAO,GAAGC,kBAAAA,CAAyBF,QAAQG,MAAM,CAAA;IAEpH,MAAMA,MAAAA,GAA6B,OAAOC,KAAAA,EAAOC,OAAAA,GAAAA;QAC7C,IAAIN,MAAAA,CAAOA,MAAM,CAACK,KAAAA,CAAAA,EAAQ;YACtB,MAAMH,OAAAA,CAAQE,MAAM,CAACC,KAAAA,EAAOC,OAAAA,CAAAA;AAChC,QAAA;AACJ,IAAA,CAAA;IAEA,OAAO;AACHN,QAAAA,MAAAA;AACAE,QAAAA,OAAAA;AACAE,QAAAA;AACJ,KAAA;AACJ;;;;"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Logger, LogLevel } from '../../logger';
|
|
2
|
+
import { Event } from '../../event/event';
|
|
3
|
+
import { EventHandler } from '../../event/handler';
|
|
4
|
+
import { Context } from '../../context';
|
|
5
|
+
export type EventLogFunction<T extends Event, C extends Context> = (event: T, context: C) => [message: string, ...args: any[]];
|
|
6
|
+
export type LoggingHandler<T extends Event, C extends Context> = EventHandler<T, C>;
|
|
7
|
+
export interface LoggingHandlerOptions {
|
|
8
|
+
level: LogLevel;
|
|
9
|
+
context: string;
|
|
10
|
+
log: EventLogFunction<any, any>;
|
|
11
|
+
}
|
|
12
|
+
export declare const createLoggingHandler: <T extends Event, C extends Context>(logger: Logger, options: Partial<LoggingHandlerOptions>) => LoggingHandler<T, C>;
|