@jonloucks/concurrency-ts 0.4.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 +248 -0
- package/api/Completable.d.ts +51 -0
- package/api/Completable.d.ts.map +1 -0
- package/api/Completable.js +11 -0
- package/api/Completable.js.map +1 -0
- package/api/CompletableFactory.d.ts +29 -0
- package/api/CompletableFactory.d.ts.map +1 -0
- package/api/CompletableFactory.js +19 -0
- package/api/CompletableFactory.js.map +1 -0
- package/api/Completion.d.ts +18 -0
- package/api/Completion.d.ts.map +1 -0
- package/api/Completion.js +2 -0
- package/api/Completion.js.map +1 -0
- package/api/CompletionNotify.d.ts +23 -0
- package/api/CompletionNotify.d.ts.map +1 -0
- package/api/CompletionNotify.js +11 -0
- package/api/CompletionNotify.js.map +1 -0
- package/api/CompletionState.d.ts +35 -0
- package/api/CompletionState.d.ts.map +1 -0
- package/api/CompletionState.js +64 -0
- package/api/CompletionState.js.map +1 -0
- package/api/Concurrency.d.ts +90 -0
- package/api/Concurrency.d.ts.map +1 -0
- package/api/Concurrency.js +19 -0
- package/api/Concurrency.js.map +1 -0
- package/api/ConcurrencyException.d.ts +27 -0
- package/api/ConcurrencyException.d.ts.map +1 -0
- package/api/ConcurrencyException.js +53 -0
- package/api/ConcurrencyException.js.map +1 -0
- package/api/ConcurrencyFactory.d.ts +41 -0
- package/api/ConcurrencyFactory.d.ts.map +1 -0
- package/api/ConcurrencyFactory.js +19 -0
- package/api/ConcurrencyFactory.js.map +1 -0
- package/api/IsCompleted.d.ts +20 -0
- package/api/IsCompleted.d.ts.map +1 -0
- package/api/IsCompleted.js +11 -0
- package/api/IsCompleted.js.map +1 -0
- package/api/OnCompletion.d.ts +23 -0
- package/api/OnCompletion.d.ts.map +1 -0
- package/api/OnCompletion.js +12 -0
- package/api/OnCompletion.js.map +1 -0
- package/api/Rule.d.ts +28 -0
- package/api/Rule.d.ts.map +1 -0
- package/api/Rule.js +11 -0
- package/api/Rule.js.map +1 -0
- package/api/StateMachine.d.ts +95 -0
- package/api/StateMachine.d.ts.map +1 -0
- package/api/StateMachine.js +13 -0
- package/api/StateMachine.js.map +1 -0
- package/api/StateMachineFactory.d.ts +29 -0
- package/api/StateMachineFactory.d.ts.map +1 -0
- package/api/StateMachineFactory.js +19 -0
- package/api/StateMachineFactory.js.map +1 -0
- package/api/TimeoutException.d.ts +21 -0
- package/api/TimeoutException.d.ts.map +1 -0
- package/api/TimeoutException.js +27 -0
- package/api/TimeoutException.js.map +1 -0
- package/api/Transition.d.ts +44 -0
- package/api/Transition.d.ts.map +1 -0
- package/api/Transition.js +11 -0
- package/api/Transition.js.map +1 -0
- package/api/Types.d.ts +27 -0
- package/api/Types.d.ts.map +1 -0
- package/api/Types.js +28 -0
- package/api/Types.js.map +1 -0
- package/api/Waitable.d.ts +39 -0
- package/api/Waitable.d.ts.map +1 -0
- package/api/Waitable.js +17 -0
- package/api/Waitable.js.map +1 -0
- package/api/WaitableConsumer.d.ts +54 -0
- package/api/WaitableConsumer.d.ts.map +1 -0
- package/api/WaitableConsumer.js +11 -0
- package/api/WaitableConsumer.js.map +1 -0
- package/api/WaitableFactory.d.ts +29 -0
- package/api/WaitableFactory.d.ts.map +1 -0
- package/api/WaitableFactory.js +19 -0
- package/api/WaitableFactory.js.map +1 -0
- package/api/WaitableNotify.d.ts +31 -0
- package/api/WaitableNotify.d.ts.map +1 -0
- package/api/WaitableNotify.js +12 -0
- package/api/WaitableNotify.js.map +1 -0
- package/api/WaitableSupplier.d.ts +53 -0
- package/api/WaitableSupplier.d.ts.map +1 -0
- package/api/WaitableSupplier.js +11 -0
- package/api/WaitableSupplier.js.map +1 -0
- package/auxiliary/Checks.d.ts +116 -0
- package/auxiliary/Checks.d.ts.map +1 -0
- package/auxiliary/Checks.js +145 -0
- package/auxiliary/Checks.js.map +1 -0
- package/auxiliary/Consumer.d.ts +45 -0
- package/auxiliary/Consumer.d.ts.map +1 -0
- package/auxiliary/Consumer.js +45 -0
- package/auxiliary/Consumer.js.map +1 -0
- package/auxiliary/Predicate.d.ts +55 -0
- package/auxiliary/Predicate.d.ts.map +1 -0
- package/auxiliary/Predicate.js +73 -0
- package/auxiliary/Predicate.js.map +1 -0
- package/auxiliary/Supplier.d.ts +52 -0
- package/auxiliary/Supplier.d.ts.map +1 -0
- package/auxiliary/Supplier.js +67 -0
- package/auxiliary/Supplier.js.map +1 -0
- package/impl/Completable.impl.d.ts +10 -0
- package/impl/Completable.impl.d.ts.map +1 -0
- package/impl/Completable.impl.js +136 -0
- package/impl/Completable.impl.js.map +1 -0
- package/impl/CompletableFactory.impl.d.ts +9 -0
- package/impl/CompletableFactory.impl.d.ts.map +1 -0
- package/impl/CompletableFactory.impl.js +42 -0
- package/impl/CompletableFactory.impl.js.map +1 -0
- package/impl/CompleteLater.impl.d.ts +12 -0
- package/impl/CompleteLater.impl.d.ts.map +1 -0
- package/impl/CompleteLater.impl.js +31 -0
- package/impl/CompleteLater.impl.js.map +1 -0
- package/impl/CompleteNow.impl.d.ts +14 -0
- package/impl/CompleteNow.impl.d.ts.map +1 -0
- package/impl/CompleteNow.impl.js +33 -0
- package/impl/CompleteNow.impl.js.map +1 -0
- package/impl/Concurrency.impl.d.ts +9 -0
- package/impl/Concurrency.impl.d.ts.map +1 -0
- package/impl/Concurrency.impl.js +84 -0
- package/impl/Concurrency.impl.js.map +1 -0
- package/impl/ConcurrencyFactory.impl.d.ts +10 -0
- package/impl/ConcurrencyFactory.impl.d.ts.map +1 -0
- package/impl/ConcurrencyFactory.impl.js +74 -0
- package/impl/ConcurrencyFactory.impl.js.map +1 -0
- package/impl/ConcurrencyWrapper.impl.d.ts +13 -0
- package/impl/ConcurrencyWrapper.impl.d.ts.map +1 -0
- package/impl/ConcurrencyWrapper.impl.js +85 -0
- package/impl/ConcurrencyWrapper.impl.js.map +1 -0
- package/impl/Events.d.ts +25 -0
- package/impl/Events.d.ts.map +1 -0
- package/impl/Events.impl.d.ts +11 -0
- package/impl/Events.impl.d.ts.map +1 -0
- package/impl/Events.impl.js +63 -0
- package/impl/Events.impl.js.map +1 -0
- package/impl/Events.js +3 -0
- package/impl/Events.js.map +1 -0
- package/impl/ExposedPromise.d.ts +26 -0
- package/impl/ExposedPromise.d.ts.map +1 -0
- package/impl/ExposedPromise.impl.d.ts +9 -0
- package/impl/ExposedPromise.impl.d.ts.map +1 -0
- package/impl/ExposedPromise.impl.js +41 -0
- package/impl/ExposedPromise.impl.js.map +1 -0
- package/impl/ExposedPromise.js +2 -0
- package/impl/ExposedPromise.js.map +1 -0
- package/impl/Internal.impl.d.ts +35 -0
- package/impl/Internal.impl.d.ts.map +1 -0
- package/impl/Internal.impl.js +90 -0
- package/impl/Internal.impl.js.map +1 -0
- package/impl/StateMachine.impl.d.ts +9 -0
- package/impl/StateMachine.impl.d.ts.map +1 -0
- package/impl/StateMachine.impl.js +184 -0
- package/impl/StateMachine.impl.js.map +1 -0
- package/impl/StateMachineFactory.impl.d.ts +9 -0
- package/impl/StateMachineFactory.impl.d.ts.map +1 -0
- package/impl/StateMachineFactory.impl.js +43 -0
- package/impl/StateMachineFactory.impl.js.map +1 -0
- package/impl/Waitable.impl.d.ts +8 -0
- package/impl/Waitable.impl.d.ts.map +1 -0
- package/impl/Waitable.impl.js +212 -0
- package/impl/Waitable.impl.js.map +1 -0
- package/impl/WaitableFactory.impl.d.ts +9 -0
- package/impl/WaitableFactory.impl.d.ts.map +1 -0
- package/impl/WaitableFactory.impl.js +42 -0
- package/impl/WaitableFactory.impl.js.map +1 -0
- package/index.d.ts +25 -0
- package/index.d.ts.map +1 -0
- package/index.js +33 -0
- package/index.js.map +1 -0
- package/package.json +88 -0
- package/version.d.ts +3 -0
- package/version.d.ts.map +1 -0
- package/version.js +4 -0
- package/version.js.map +1 -0
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { guardFunctions } from "@jonloucks/concurrency-ts/api/Types";
|
|
2
|
+
import { createContract } from "@jonloucks/contracts-ts";
|
|
3
|
+
/**
|
|
4
|
+
* Determine if the given instance is a Concurrency
|
|
5
|
+
*
|
|
6
|
+
* @param instance the instance to test
|
|
7
|
+
* @return true if the instance is a Concurrency
|
|
8
|
+
*/
|
|
9
|
+
export function guard(instance) {
|
|
10
|
+
return guardFunctions(instance, 'createWaitable', 'createStateMachine', 'createCompletable', 'completeLater', 'completeNow', 'open');
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* The Concurrency contract
|
|
14
|
+
*/
|
|
15
|
+
export const CONTRACT = createContract({
|
|
16
|
+
name: "Concurrency",
|
|
17
|
+
test: guard
|
|
18
|
+
});
|
|
19
|
+
//# sourceMappingURL=Concurrency.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Concurrency.js","sourceRoot":"","sources":["../../src/api/Concurrency.ts"],"names":[],"mappings":"AAIA,OAAO,EAA0B,cAAc,EAAsD,MAAM,qCAAqC,CAAC;AAGjJ,OAAO,EAAuB,cAAc,EAAE,MAAM,yBAAyB,CAAC;AAgG9E;;;;;GAKG;AACH,MAAM,UAAU,KAAK,CAAC,QAAiB;IACrC,OAAO,cAAc,CAAC,QAAQ,EAC5B,gBAAgB,EAChB,oBAAoB,EACpB,mBAAmB,EACnB,eAAe,EACf,aAAa,EACb,MAAM,CACP,CAAC;AACJ,CAAC;AAED;;GAEG;AACH,MAAM,CAAC,MAAM,QAAQ,GAA0B,cAAc,CAAc;IACzE,IAAI,EAAE,aAAa;IACnB,IAAI,EAAE,KAAK;CACZ,CAAC,CAAC"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Runtime exception thrown for Concurrency related problems.
|
|
3
|
+
*/
|
|
4
|
+
export declare class ConcurrencyException extends Error {
|
|
5
|
+
/**
|
|
6
|
+
* Passthrough for {@link Error(String, Throwable)}
|
|
7
|
+
*
|
|
8
|
+
* @param message the message for this exception
|
|
9
|
+
* @param thrown the cause of this exception, null is allowed
|
|
10
|
+
*/
|
|
11
|
+
constructor(message: string, thrown?: Error | null);
|
|
12
|
+
/**
|
|
13
|
+
* Ensure something that was caught is rethrown as a ConcurrencyException
|
|
14
|
+
* @param caught the caught value
|
|
15
|
+
* @param message the optional message to use if caught is not an ConcurrencyException
|
|
16
|
+
*/
|
|
17
|
+
static rethrow(caught: unknown, message?: string): never;
|
|
18
|
+
private static throwUnknown;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Determine if an instance is a ConcurrencyException
|
|
22
|
+
*
|
|
23
|
+
* @param instance the instance to check
|
|
24
|
+
* @returns true if the instance is a ConcurrencyException
|
|
25
|
+
*/
|
|
26
|
+
export declare function guard(instance: unknown): instance is ConcurrencyException;
|
|
27
|
+
//# sourceMappingURL=ConcurrencyException.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ConcurrencyException.d.ts","sourceRoot":"","sources":["../../src/api/ConcurrencyException.ts"],"names":[],"mappings":"AAIA;;GAEG;AACH,qBAAa,oBAAqB,SAAQ,KAAK;IAE7C;;;;;OAKG;gBACgB,OAAO,EAAE,MAAM,EAAE,MAAM,GAAE,KAAK,GAAG,IAAW;IAQ/D;;;;OAIG;IACH,MAAM,CAAC,OAAO,CAAC,MAAM,EAAE,OAAO,EAAE,OAAO,CAAC,EAAE,MAAM,GAAG,KAAK;IAYxD,OAAO,CAAC,MAAM,CAAC,YAAY;CAG5B;AAED;;;;;GAKG;AACH,wBAAgB,KAAK,CAAC,QAAQ,EAAE,OAAO,GAAG,QAAQ,IAAI,oBAAoB,CAEzE"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { messageCheck } from "@jonloucks/contracts-ts/auxiliary/Checks";
|
|
2
|
+
import { isNotPresent } from "@jonloucks/contracts-ts/api/Types";
|
|
3
|
+
import { used } from "@jonloucks/contracts-ts/auxiliary/Checks";
|
|
4
|
+
/**
|
|
5
|
+
* Runtime exception thrown for Concurrency related problems.
|
|
6
|
+
*/
|
|
7
|
+
export class ConcurrencyException extends Error {
|
|
8
|
+
/**
|
|
9
|
+
* Passthrough for {@link Error(String, Throwable)}
|
|
10
|
+
*
|
|
11
|
+
* @param message the message for this exception
|
|
12
|
+
* @param thrown the cause of this exception, null is allowed
|
|
13
|
+
*/
|
|
14
|
+
constructor(message, thrown = null) {
|
|
15
|
+
// super(messageCheck(message), thrown || undefined);
|
|
16
|
+
super(messageCheck(message));
|
|
17
|
+
used(thrown);
|
|
18
|
+
this.name = "ConcurrencyException";
|
|
19
|
+
Object.setPrototypeOf(this, ConcurrencyException.prototype);
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Ensure something that was caught is rethrown as a ConcurrencyException
|
|
23
|
+
* @param caught the caught value
|
|
24
|
+
* @param message the optional message to use if caught is not an ConcurrencyException
|
|
25
|
+
*/
|
|
26
|
+
static rethrow(caught, message) {
|
|
27
|
+
if (isNotPresent(caught)) {
|
|
28
|
+
this.throwUnknown(message);
|
|
29
|
+
}
|
|
30
|
+
else if (guard(caught)) {
|
|
31
|
+
throw caught;
|
|
32
|
+
}
|
|
33
|
+
else if (caught instanceof Error) {
|
|
34
|
+
throw new ConcurrencyException(message ?? caught.message, caught);
|
|
35
|
+
}
|
|
36
|
+
else {
|
|
37
|
+
this.throwUnknown(message);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
static throwUnknown(message) {
|
|
41
|
+
throw new ConcurrencyException(message ?? "Unknown type of caught value.");
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Determine if an instance is a ConcurrencyException
|
|
46
|
+
*
|
|
47
|
+
* @param instance the instance to check
|
|
48
|
+
* @returns true if the instance is a ConcurrencyException
|
|
49
|
+
*/
|
|
50
|
+
export function guard(instance) {
|
|
51
|
+
return instance instanceof ConcurrencyException;
|
|
52
|
+
}
|
|
53
|
+
//# sourceMappingURL=ConcurrencyException.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ConcurrencyException.js","sourceRoot":"","sources":["../../src/api/ConcurrencyException.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,0CAA0C,CAAA;AACvE,OAAO,EAAE,YAAY,EAAE,MAAM,mCAAmC,CAAC;AACjE,OAAO,EAAE,IAAI,EAAE,MAAM,0CAA0C,CAAC;AAEhE;;GAEG;AACH,MAAM,OAAO,oBAAqB,SAAQ,KAAK;IAE7C;;;;;OAKG;IACH,YAAmB,OAAe,EAAE,SAAuB,IAAI;QAC7D,qDAAqD;QACrD,KAAK,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC,CAAC;QAC7B,IAAI,CAAC,MAAM,CAAC,CAAC;QACb,IAAI,CAAC,IAAI,GAAG,sBAAsB,CAAC;QACnC,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,oBAAoB,CAAC,SAAS,CAAC,CAAA;IAC7D,CAAC;IAED;;;;OAIG;IACH,MAAM,CAAC,OAAO,CAAC,MAAe,EAAE,OAAgB;QAC9C,IAAI,YAAY,CAAC,MAAM,CAAC,EAAE,CAAC;YACxB,IAAI,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC;QAC9B,CAAC;aAAM,IAAI,KAAK,CAAC,MAAM,CAAC,EAAE,CAAC;YACzB,MAAM,MAAM,CAAC;QACf,CAAC;aAAM,IAAI,MAAM,YAAY,KAAK,EAAE,CAAC;YACnC,MAAM,IAAI,oBAAoB,CAAC,OAAO,IAAI,MAAM,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;QACpE,CAAC;aAAM,CAAC;YACL,IAAI,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC;QAC9B,CAAC;IACH,CAAC;IAEO,MAAM,CAAC,YAAY,CAAE,OAAgB;QAC3C,MAAM,IAAI,oBAAoB,CAAC,OAAO,IAAI,+BAA+B,CAAC,CAAC;IAC7E,CAAC;CACF;AAED;;;;;GAKG;AACH,MAAM,UAAU,KAAK,CAAC,QAAiB;IACrC,OAAO,QAAQ,YAAY,oBAAoB,CAAC;AAClD,CAAC"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { Concurrency, Config as ConcurrencyConfig } from "@jonloucks/concurrency-ts/api/Concurrency";
|
|
2
|
+
import { Contract } from "@jonloucks/contracts-ts";
|
|
3
|
+
import { RequiredType } from "@jonloucks/concurrency-ts/api/Types";
|
|
4
|
+
import { Repository } from "@jonloucks/contracts-ts/api/Repository";
|
|
5
|
+
/**
|
|
6
|
+
* Responsible for creating new instances of Concurrency
|
|
7
|
+
*/
|
|
8
|
+
export interface ConcurrencyFactory {
|
|
9
|
+
/**
|
|
10
|
+
* Create a new instance of Concurrency
|
|
11
|
+
* <p>
|
|
12
|
+
* Note: caller is responsible for calling Open.open and calling
|
|
13
|
+
* the AutoClose.close when done with the instance.
|
|
14
|
+
* </p>
|
|
15
|
+
* @param config the Concurrency configuration for the new instance
|
|
16
|
+
* @return the new Concurrency instance
|
|
17
|
+
* @throws IllegalArgumentException if config is null or when configuration is invalid
|
|
18
|
+
*/
|
|
19
|
+
createConcurrency(config?: ConcurrencyConfig): Concurrency;
|
|
20
|
+
/**
|
|
21
|
+
* Install all the requirements and promises to the given Contracts Repository.
|
|
22
|
+
* Include Concurrency#CONTRACT which will provide a unique
|
|
23
|
+
*
|
|
24
|
+
* @param repository the repository to add requirements and promises to
|
|
25
|
+
* @param config the Concurrency config
|
|
26
|
+
* @throws IllegalArgumentException if config is null, config is invalid, or repository is null
|
|
27
|
+
*/
|
|
28
|
+
install(repository: RequiredType<Repository>, config?: ConcurrencyConfig): void;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Determine if the given instance is a ConcurrencyFactory
|
|
32
|
+
*
|
|
33
|
+
* @param instance the instance to check
|
|
34
|
+
* @return true if instance is a ConcurrencyFactory, false otherwise
|
|
35
|
+
*/
|
|
36
|
+
export declare function guard(instance: unknown): instance is RequiredType<ConcurrencyFactory>;
|
|
37
|
+
/**
|
|
38
|
+
* The Contract for ConcurrencyFactory
|
|
39
|
+
*/
|
|
40
|
+
export declare const CONTRACT: Contract<ConcurrencyFactory>;
|
|
41
|
+
//# sourceMappingURL=ConcurrencyFactory.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ConcurrencyFactory.d.ts","sourceRoot":"","sources":["../../src/api/ConcurrencyFactory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,IAAI,iBAAiB,EAAE,MAAM,2CAA2C,CAAC;AACrG,OAAO,EAAE,QAAQ,EAAkB,MAAM,yBAAyB,CAAC;AACnE,OAAO,EAAE,YAAY,EAAkB,MAAM,qCAAqC,CAAC;AACnF,OAAO,EAAE,UAAU,EAAE,MAAM,wCAAwC,CAAC;AAEpE;;GAEG;AACH,MAAM,WAAW,kBAAkB;IAEjC;;;;;;;;;OASG;IACH,iBAAiB,CAAC,MAAM,CAAC,EAAE,iBAAiB,GAAG,WAAW,CAAC;IAE3D;;;;;;;OAOG;IACH,OAAO,CAAC,UAAU,EAAE,YAAY,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC,EAAE,iBAAiB,GAAG,IAAI,CAAC;CACjF;AAED;;;;;GAKG;AACH,wBAAgB,KAAK,CAAC,QAAQ,EAAE,OAAO,GAAG,QAAQ,IAAI,YAAY,CAAC,kBAAkB,CAAC,CAErF;AAED;;GAEG;AACH,eAAO,MAAM,QAAQ,EAAE,QAAQ,CAAC,kBAAkB,CAGhD,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { createContract } from "@jonloucks/contracts-ts";
|
|
2
|
+
import { guardFunctions } from "@jonloucks/concurrency-ts/api/Types";
|
|
3
|
+
/**
|
|
4
|
+
* Determine if the given instance is a ConcurrencyFactory
|
|
5
|
+
*
|
|
6
|
+
* @param instance the instance to check
|
|
7
|
+
* @return true if instance is a ConcurrencyFactory, false otherwise
|
|
8
|
+
*/
|
|
9
|
+
export function guard(instance) {
|
|
10
|
+
return guardFunctions(instance, 'createConcurrency', 'install');
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* The Contract for ConcurrencyFactory
|
|
14
|
+
*/
|
|
15
|
+
export const CONTRACT = createContract({
|
|
16
|
+
name: "ConcurrencyFactory",
|
|
17
|
+
test: guard
|
|
18
|
+
});
|
|
19
|
+
//# sourceMappingURL=ConcurrencyFactory.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ConcurrencyFactory.js","sourceRoot":"","sources":["../../src/api/ConcurrencyFactory.ts"],"names":[],"mappings":"AACA,OAAO,EAAY,cAAc,EAAE,MAAM,yBAAyB,CAAC;AACnE,OAAO,EAAgB,cAAc,EAAE,MAAM,qCAAqC,CAAC;AA+BnF;;;;;GAKG;AACH,MAAM,UAAU,KAAK,CAAC,QAAiB;IACrC,OAAO,cAAc,CAAC,QAAQ,EAAE,mBAAmB,EAAE,SAAS,CAAC,CAAC;AAClE,CAAC;AAED;;GAEG;AACH,MAAM,CAAC,MAAM,QAAQ,GAAiC,cAAc,CAAC;IACnE,IAAI,EAAE,oBAAoB;IAC1B,IAAI,EAAE,KAAK;CACZ,CAAC,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { RequiredType } from "@jonloucks/concurrency-ts/api/Types";
|
|
2
|
+
/**
|
|
3
|
+
* An interface to determine if an action or activity is completed
|
|
4
|
+
*/
|
|
5
|
+
export interface IsCompleted {
|
|
6
|
+
/**
|
|
7
|
+
* Is the action or activity completed
|
|
8
|
+
*
|
|
9
|
+
* @return true if completed, false otherwise
|
|
10
|
+
*/
|
|
11
|
+
isCompleted(): boolean;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Determine if the given instance is an IsCompleted
|
|
15
|
+
*
|
|
16
|
+
* @param instance the instance to check
|
|
17
|
+
* @return true if instance is an IsCompleted, false otherwise
|
|
18
|
+
*/
|
|
19
|
+
export declare function guard(instance: unknown): instance is RequiredType<IsCompleted>;
|
|
20
|
+
//# sourceMappingURL=IsCompleted.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"IsCompleted.d.ts","sourceRoot":"","sources":["../../src/api/IsCompleted.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAkB,MAAM,qCAAqC,CAAC;AAEnF;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B;;;;OAIG;IACH,WAAW,IAAI,OAAO,CAAC;CACxB;AAED;;;;;GAKG;AACH,wBAAgB,KAAK,CAAC,QAAQ,EAAE,OAAO,GAAG,QAAQ,IAAI,YAAY,CAAC,WAAW,CAAC,CAE9E"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { guardFunctions } from "@jonloucks/concurrency-ts/api/Types";
|
|
2
|
+
/**
|
|
3
|
+
* Determine if the given instance is an IsCompleted
|
|
4
|
+
*
|
|
5
|
+
* @param instance the instance to check
|
|
6
|
+
* @return true if instance is an IsCompleted, false otherwise
|
|
7
|
+
*/
|
|
8
|
+
export function guard(instance) {
|
|
9
|
+
return guardFunctions(instance, 'isCompleted');
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=IsCompleted.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"IsCompleted.js","sourceRoot":"","sources":["../../src/api/IsCompleted.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgB,cAAc,EAAE,MAAM,qCAAqC,CAAC;AAcnF;;;;;GAKG;AACH,MAAM,UAAU,KAAK,CAAC,QAAiB;IACrC,OAAO,cAAc,CAAC,QAAQ,EAAE,aAAa,CAAC,CAAC;AACjD,CAAC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { Completion } from "@jonloucks/concurrency-ts/api/Completion";
|
|
2
|
+
import { RequiredType } from "@jonloucks/concurrency-ts/api/Types";
|
|
3
|
+
/**
|
|
4
|
+
* Responsibility: to receive the information when an action or activity has finished.
|
|
5
|
+
* Use for both asynchronous and synchronous actions. The only difference is when and on what
|
|
6
|
+
* thread the callback is executed on
|
|
7
|
+
* @param <T> the type of completion value
|
|
8
|
+
*/
|
|
9
|
+
export interface OnCompletion<T> {
|
|
10
|
+
/**
|
|
11
|
+
* Callback which receives the
|
|
12
|
+
* @param completion the completion information.
|
|
13
|
+
*/
|
|
14
|
+
onCompletion(completion: RequiredType<Completion<T>>): void;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Determine if the given instance is an OnCompletion
|
|
18
|
+
*
|
|
19
|
+
* @param instance the instance to check
|
|
20
|
+
* @return true if instance is an OnCompletion, false otherwise
|
|
21
|
+
*/
|
|
22
|
+
export declare function guard<T>(instance: unknown): instance is RequiredType<OnCompletion<T>>;
|
|
23
|
+
//# sourceMappingURL=OnCompletion.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"OnCompletion.d.ts","sourceRoot":"","sources":["../../src/api/OnCompletion.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,0CAA0C,CAAC;AACtE,OAAO,EAAE,YAAY,EAAkB,MAAM,qCAAqC,CAAC;AAEnF;;;;;GAKG;AACH,MAAM,WAAW,YAAY,CAAC,CAAC;IAE7B;;;OAGG;IACH,YAAY,CAAC,UAAU,EAAE,YAAY,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC;CAC7D;AAED;;;;;GAKG;AACH,wBAAgB,KAAK,CAAC,CAAC,EAAE,QAAQ,EAAE,OAAO,GAAG,QAAQ,IAAI,YAAY,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,CAErF"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { guardFunctions } from "@jonloucks/concurrency-ts/api/Types";
|
|
2
|
+
/**
|
|
3
|
+
* Determine if the given instance is an OnCompletion
|
|
4
|
+
*
|
|
5
|
+
* @param instance the instance to check
|
|
6
|
+
* @return true if instance is an OnCompletion, false otherwise
|
|
7
|
+
*/
|
|
8
|
+
export function guard(instance) {
|
|
9
|
+
return guardFunctions(instance, 'onCompletion');
|
|
10
|
+
}
|
|
11
|
+
;
|
|
12
|
+
//# sourceMappingURL=OnCompletion.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"OnCompletion.js","sourceRoot":"","sources":["../../src/api/OnCompletion.ts"],"names":[],"mappings":"AACA,OAAO,EAAgB,cAAc,EAAE,MAAM,qCAAqC,CAAC;AAiBnF;;;;;GAKG;AACH,MAAM,UAAU,KAAK,CAAI,QAAiB;IACxC,OAAO,cAAc,CAAC,QAAQ,EAAE,cAAc,CAAC,CAAC;AAClD,CAAC;AAAA,CAAC"}
|
package/api/Rule.d.ts
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { RequiredType } from "@jonloucks/concurrency-ts/api/Types";
|
|
2
|
+
/**
|
|
3
|
+
* Opt-in interface a state type can implement to assist in determining the valid transitions
|
|
4
|
+
*/
|
|
5
|
+
export interface Rule<T> {
|
|
6
|
+
/**
|
|
7
|
+
* Determine if 'this' state can transition to the target
|
|
8
|
+
*
|
|
9
|
+
* @param event the event name
|
|
10
|
+
* @param goal the goal state
|
|
11
|
+
* @return true if the transition is valid
|
|
12
|
+
*/
|
|
13
|
+
canTransition(event: string, goal: T): boolean;
|
|
14
|
+
/**
|
|
15
|
+
* Determine if the given state is a terminal state
|
|
16
|
+
*
|
|
17
|
+
* @return true if the state is terminal
|
|
18
|
+
*/
|
|
19
|
+
isTerminal?: boolean;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Type guard to determine if an instance implements Rule
|
|
23
|
+
*
|
|
24
|
+
* @param instance the instance to check
|
|
25
|
+
* @return true if instance is a Rule
|
|
26
|
+
*/
|
|
27
|
+
export declare function guard<T>(instance: unknown): instance is RequiredType<Rule<T>>;
|
|
28
|
+
//# sourceMappingURL=Rule.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Rule.d.ts","sourceRoot":"","sources":["../../src/api/Rule.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAkB,MAAM,qCAAqC,CAAC;AAEnF;;EAEE;AACF,MAAM,WAAW,IAAI,CAAC,CAAC;IAErB;;;;;;OAMG;IACH,aAAa,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,GAAG,OAAO,CAAC;IAE/C;;;;OAIG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB;AAED;;;;;GAKG;AACH,wBAAgB,KAAK,CAAC,CAAC,EAAE,QAAQ,EAAE,OAAO,GAAG,QAAQ,IAAI,YAAY,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAE7E"}
|
package/api/Rule.js
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { guardFunctions } from "@jonloucks/concurrency-ts/api/Types";
|
|
2
|
+
/**
|
|
3
|
+
* Type guard to determine if an instance implements Rule
|
|
4
|
+
*
|
|
5
|
+
* @param instance the instance to check
|
|
6
|
+
* @return true if instance is a Rule
|
|
7
|
+
*/
|
|
8
|
+
export function guard(instance) {
|
|
9
|
+
return guardFunctions(instance, 'canTransition');
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=Rule.js.map
|
package/api/Rule.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Rule.js","sourceRoot":"","sources":["../../src/api/Rule.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgB,cAAc,EAAE,MAAM,qCAAqC,CAAC;AAwBnF;;;;;GAKG;AACH,MAAM,UAAU,KAAK,CAAI,QAAiB;IACxC,OAAO,cAAc,CAAC,QAAQ,EAAE,eAAe,CAAC,CAAC;AACnD,CAAC"}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import { Rule } from "@jonloucks/concurrency-ts/api/Rule";
|
|
2
|
+
import { Transition } from "@jonloucks/concurrency-ts/api/Transition";
|
|
3
|
+
import { OptionalType, RequiredType } from "@jonloucks/concurrency-ts/api/Types";
|
|
4
|
+
import { WaitableNotify } from "@jonloucks/concurrency-ts/api/WaitableNotify";
|
|
5
|
+
import { WaitableSupplier } from "@jonloucks/concurrency-ts/api/WaitableSupplier";
|
|
6
|
+
import { Open } from "@jonloucks/contracts-ts/api/Open";
|
|
7
|
+
import { IsCompleted } from "@jonloucks/concurrency-ts/api/IsCompleted";
|
|
8
|
+
import { Contracts } from "@jonloucks/contracts-ts/api/Contracts";
|
|
9
|
+
/**
|
|
10
|
+
* State machine.
|
|
11
|
+
* User defined states with rules to restrict state transitions.
|
|
12
|
+
*
|
|
13
|
+
* @param <T> the user defined state type
|
|
14
|
+
*/
|
|
15
|
+
export interface StateMachine<T> extends Open, WaitableSupplier<T>, WaitableNotify<T>, IsCompleted {
|
|
16
|
+
/**
|
|
17
|
+
* Set the current state, state must already exist and be an allowed transition
|
|
18
|
+
*
|
|
19
|
+
* @param event the event name
|
|
20
|
+
* @param state the new state
|
|
21
|
+
* @return true if state was changed
|
|
22
|
+
* @throws IllegalArgumentException when event is null, state is null, or unknown
|
|
23
|
+
*/
|
|
24
|
+
setState(event: string, state: T): boolean;
|
|
25
|
+
/**
|
|
26
|
+
* Get the current state
|
|
27
|
+
*
|
|
28
|
+
* @return the current state, never null
|
|
29
|
+
*/
|
|
30
|
+
getState(): T;
|
|
31
|
+
/**
|
|
32
|
+
* Determine if the given state is known
|
|
33
|
+
*
|
|
34
|
+
* @param state the state to check
|
|
35
|
+
* @return true if and only if the state is known
|
|
36
|
+
* @throws IllegalArgumentException when state is null
|
|
37
|
+
*/
|
|
38
|
+
hasState(state: T): boolean;
|
|
39
|
+
/**
|
|
40
|
+
* Determine if a transition is allowed from the current state to a new one.
|
|
41
|
+
*
|
|
42
|
+
* @param event the event that is triggering the transition
|
|
43
|
+
* @param state the candidate state to transition to
|
|
44
|
+
* @return if transition event is allowed to change the current state to the given state
|
|
45
|
+
* @throws IllegalArgumentException when event is null, state is null, or unknown
|
|
46
|
+
*/
|
|
47
|
+
isTransitionAllowed(event: string, state: T): boolean;
|
|
48
|
+
/**
|
|
49
|
+
* Execute a transition from the current state to another
|
|
50
|
+
*
|
|
51
|
+
* @param transition the transition to execute
|
|
52
|
+
* @param <R> the return type of the transition. For example, a Closeable during open.
|
|
53
|
+
* @return the transition return value
|
|
54
|
+
* @throws IllegalArgumentException when transition is null or required fields are not present.
|
|
55
|
+
*/
|
|
56
|
+
transition<R>(transition: Transition<T, R>): OptionalType<R>;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* StateMachine configuration
|
|
60
|
+
*
|
|
61
|
+
* @param <T> the type of each state
|
|
62
|
+
*/
|
|
63
|
+
export interface Config<T> {
|
|
64
|
+
/**
|
|
65
|
+
* The contracts to use
|
|
66
|
+
*/
|
|
67
|
+
contracts?: Contracts;
|
|
68
|
+
/**
|
|
69
|
+
* Return the initial value. It is required, the use of required is because
|
|
70
|
+
* the builder may not have provided a value
|
|
71
|
+
*
|
|
72
|
+
* @return the optional initial state
|
|
73
|
+
*/
|
|
74
|
+
initialValue: RequiredType<T>;
|
|
75
|
+
/**
|
|
76
|
+
* @return the list of states in the state machine
|
|
77
|
+
*/
|
|
78
|
+
states: readonly T[];
|
|
79
|
+
/**
|
|
80
|
+
* Get all the rules for a specified state
|
|
81
|
+
*
|
|
82
|
+
* @param state the state
|
|
83
|
+
* @return the rules of the state
|
|
84
|
+
*/
|
|
85
|
+
getStateRules?(state: T): ReadonlyArray<Rule<T>>;
|
|
86
|
+
}
|
|
87
|
+
export { type Config as StateMachineConfig };
|
|
88
|
+
/**
|
|
89
|
+
* Determine if the given instance is a StateMachine
|
|
90
|
+
*
|
|
91
|
+
* @param instance the instance to check
|
|
92
|
+
* @return true if the instance is a StateMachine
|
|
93
|
+
*/
|
|
94
|
+
export declare function guard<T>(instance: unknown): instance is RequiredType<StateMachine<T>>;
|
|
95
|
+
//# sourceMappingURL=StateMachine.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"StateMachine.d.ts","sourceRoot":"","sources":["../../src/api/StateMachine.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,oCAAoC,CAAC;AAC1D,OAAO,EAAE,UAAU,EAAE,MAAM,0CAA0C,CAAC;AACtE,OAAO,EAAE,YAAY,EAAE,YAAY,EAAkB,MAAM,qCAAqC,CAAC;AACjG,OAAO,EAAE,cAAc,EAAgC,MAAM,8CAA8C,CAAC;AAC5G,OAAO,EAAE,gBAAgB,EAAkC,MAAM,gDAAgD,CAAC;AAClH,OAAO,EAAE,IAAI,EAAE,MAAM,kCAAkC,CAAC;AACxD,OAAO,EAAE,WAAW,EAAE,MAAM,2CAA2C,CAAC;AACxE,OAAO,EAAE,SAAS,EAAE,MAAM,uCAAuC,CAAC;AAElE;;;;;GAKG;AACH,MAAM,WAAW,YAAY,CAAC,CAAC,CAAE,SAAQ,IAAI,EAAE,gBAAgB,CAAC,CAAC,CAAC,EAAE,cAAc,CAAC,CAAC,CAAC,EAAE,WAAW;IAEhG;;;;;;;OAOG;IACH,QAAQ,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,GAAG,OAAO,CAAC;IAE3C;;;;OAIG;IACH,QAAQ,IAAI,CAAC,CAAC;IAEd;;;;;;OAMG;IACH,QAAQ,CAAC,KAAK,EAAE,CAAC,GAAG,OAAO,CAAC;IAE5B;;;;;;;OAOG;IACH,mBAAmB,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,GAAG,OAAO,CAAC;IAEtD;;;;;;;OAOG;IACH,UAAU,CAAC,CAAC,EAAE,UAAU,EAAE,UAAU,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,YAAY,CAAC,CAAC,CAAC,CAAC;CAC9D;AAED;;;;GAIG;AACH,MAAM,WAAW,MAAM,CAAC,CAAC;IAEvB;;OAEG;IACH,SAAS,CAAC,EAAE,SAAS,CAAC;IAEtB;;;;;OAKG;IACH,YAAY,EAAE,YAAY,CAAC,CAAC,CAAC,CAAC;IAE9B;;OAEG;IACH,MAAM,EAAE,SAAS,CAAC,EAAE,CAAC;IAErB;;;;;OAKG;IACH,aAAa,CAAC,CAAC,KAAK,EAAE,CAAC,GAAG,aAAa,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;CAClD;AAED,OAAO,EAAE,KAAK,MAAM,IAAI,kBAAkB,EAAE,CAAE;AAE9C;;;;;GAKG;AACH,wBAAgB,KAAK,CAAC,CAAC,EAAE,QAAQ,EAAE,OAAO,GAAG,QAAQ,IAAI,YAAY,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,CAUrF"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { guardFunctions } from "@jonloucks/concurrency-ts/api/Types";
|
|
2
|
+
import { guard as guardWaitableNotify } from "@jonloucks/concurrency-ts/api/WaitableNotify";
|
|
3
|
+
import { guard as guardWaitableSupplier } from "@jonloucks/concurrency-ts/api/WaitableSupplier";
|
|
4
|
+
/**
|
|
5
|
+
* Determine if the given instance is a StateMachine
|
|
6
|
+
*
|
|
7
|
+
* @param instance the instance to check
|
|
8
|
+
* @return true if the instance is a StateMachine
|
|
9
|
+
*/
|
|
10
|
+
export function guard(instance) {
|
|
11
|
+
return guardFunctions(instance, 'isTransitionAllowed', 'isCompleted', 'getState', 'setState', 'hasState', 'transition', 'open') && guardWaitableNotify(instance) && guardWaitableSupplier(instance);
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=StateMachine.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"StateMachine.js","sourceRoot":"","sources":["../../src/api/StateMachine.ts"],"names":[],"mappings":"AAEA,OAAO,EAA8B,cAAc,EAAE,MAAM,qCAAqC,CAAC;AACjG,OAAO,EAAkB,KAAK,IAAI,mBAAmB,EAAE,MAAM,8CAA8C,CAAC;AAC5G,OAAO,EAAoB,KAAK,IAAI,qBAAqB,EAAE,MAAM,gDAAgD,CAAC;AAgGlH;;;;;GAKG;AACH,MAAM,UAAU,KAAK,CAAI,QAAiB;IACxC,OAAO,cAAc,CAAC,QAAQ,EAC5B,qBAAqB,EACrB,aAAa,EACb,UAAU,EACV,UAAU,EACV,UAAU,EACV,YAAY,EACZ,MAAM,CACP,IAAI,mBAAmB,CAAI,QAAQ,CAAC,IAAI,qBAAqB,CAAI,QAAQ,CAAC,CAAC;AAC9E,CAAC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { Contract } from "@jonloucks/contracts-ts";
|
|
2
|
+
import { RequiredType } from "@jonloucks/concurrency-ts/api/Types";
|
|
3
|
+
import { Config, StateMachine } from "@jonloucks/concurrency-ts/api/StateMachine";
|
|
4
|
+
/**
|
|
5
|
+
* Rule machine, containing a set of sets that can be transitioned to by events/actions
|
|
6
|
+
*/
|
|
7
|
+
export interface StateMachineFactory {
|
|
8
|
+
/**
|
|
9
|
+
* Create a new StateMachine by configuration
|
|
10
|
+
*
|
|
11
|
+
* @param config the configuration
|
|
12
|
+
* @return the new StateMachine
|
|
13
|
+
* @param <T> the type of each state
|
|
14
|
+
* @throws IllegalArgumentException if config is null or configuration is invalid
|
|
15
|
+
*/
|
|
16
|
+
createStateMachine<T>(config: Config<T>): RequiredType<StateMachine<T>>;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Determine if the given instance is a StateMachineFactory
|
|
20
|
+
*
|
|
21
|
+
* @param instance the instance to check
|
|
22
|
+
* @return true if the instance is a StateMachineFactory
|
|
23
|
+
*/
|
|
24
|
+
export declare function guard(instance: unknown): instance is RequiredType<StateMachineFactory>;
|
|
25
|
+
/**
|
|
26
|
+
* Contract for StateMachineFactory
|
|
27
|
+
*/
|
|
28
|
+
export declare const CONTRACT: Contract<StateMachineFactory>;
|
|
29
|
+
//# sourceMappingURL=StateMachineFactory.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"StateMachineFactory.d.ts","sourceRoot":"","sources":["../../src/api/StateMachineFactory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAiB,MAAM,yBAAyB,CAAC;AAClE,OAAO,EAAE,YAAY,EAAkB,MAAM,qCAAqC,CAAC;AACnF,OAAO,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,4CAA4C,CAAC;AAElF;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAClC;;;;;;;OAOG;IACH,kBAAkB,CAAC,CAAC,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC,GAAG,YAAY,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,CAAC;CACzE;AAED;;;;;GAKG;AACH,wBAAgB,KAAK,CAAC,QAAQ,EAAE,OAAO,GAAG,QAAQ,IAAI,YAAY,CAAC,mBAAmB,CAAC,CAEtF;AAED;;GAEG;AACH,eAAO,MAAM,QAAQ,EAAE,QAAQ,CAAC,mBAAmB,CAGjD,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { createContract } from "@jonloucks/contracts-ts";
|
|
2
|
+
import { guardFunctions } from "@jonloucks/concurrency-ts/api/Types";
|
|
3
|
+
/**
|
|
4
|
+
* Determine if the given instance is a StateMachineFactory
|
|
5
|
+
*
|
|
6
|
+
* @param instance the instance to check
|
|
7
|
+
* @return true if the instance is a StateMachineFactory
|
|
8
|
+
*/
|
|
9
|
+
export function guard(instance) {
|
|
10
|
+
return guardFunctions(instance, 'createStateMachine');
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Contract for StateMachineFactory
|
|
14
|
+
*/
|
|
15
|
+
export const CONTRACT = createContract({
|
|
16
|
+
name: "StateMachineFactory",
|
|
17
|
+
test: guard
|
|
18
|
+
});
|
|
19
|
+
//# sourceMappingURL=StateMachineFactory.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"StateMachineFactory.js","sourceRoot":"","sources":["../../src/api/StateMachineFactory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAY,cAAc,EAAC,MAAM,yBAAyB,CAAC;AAClE,OAAO,EAAgB,cAAc,EAAE,MAAM,qCAAqC,CAAC;AAkBnF;;;;;GAKG;AACH,MAAM,UAAU,KAAK,CAAC,QAAiB;IACrC,OAAO,cAAc,CAAC,QAAQ,EAAE,oBAAoB,CAAC,CAAC;AACxD,CAAC;AAED;;GAEG;AACH,MAAM,CAAC,MAAM,QAAQ,GAAkC,cAAc,CAAC;IACpE,IAAI,EAAE,qBAAqB;IAC3B,IAAI,EAAE,KAAK;CACZ,CAAC,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { ConcurrencyException } from "@jonloucks/concurrency-ts/api/ConcurrencyException";
|
|
2
|
+
/**
|
|
3
|
+
* Runtime exception thrown for Concurrency timeout related problems.
|
|
4
|
+
*/
|
|
5
|
+
export declare class TimeoutException extends ConcurrencyException {
|
|
6
|
+
/**
|
|
7
|
+
* Passthrough for {@link Error(String, Throwable)}
|
|
8
|
+
*
|
|
9
|
+
* @param message the message for this exception
|
|
10
|
+
* @param thrown the cause of this exception, null is allowed
|
|
11
|
+
*/
|
|
12
|
+
constructor(message: string, thrown?: Error | null);
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Determine if an instance is a TimeoutException
|
|
16
|
+
*
|
|
17
|
+
* @param instance the instance to check
|
|
18
|
+
* @returns true if the instance is a TimeoutException
|
|
19
|
+
*/
|
|
20
|
+
export declare function guard(instance: unknown): instance is TimeoutException;
|
|
21
|
+
//# sourceMappingURL=TimeoutException.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TimeoutException.d.ts","sourceRoot":"","sources":["../../src/api/TimeoutException.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,oDAAoD,CAAC;AAE1F;;GAEG;AACH,qBAAa,gBAAiB,SAAQ,oBAAoB;IAExD;;;;;OAKG;gBACgB,OAAO,EAAE,MAAM,EAAE,MAAM,GAAE,KAAK,GAAG,IAAW;CAKhE;AAED;;;;;GAKG;AACH,wBAAgB,KAAK,CAAC,QAAQ,EAAE,OAAO,GAAG,QAAQ,IAAI,gBAAgB,CAErE"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { ConcurrencyException } from "@jonloucks/concurrency-ts/api/ConcurrencyException";
|
|
2
|
+
/**
|
|
3
|
+
* Runtime exception thrown for Concurrency timeout related problems.
|
|
4
|
+
*/
|
|
5
|
+
export class TimeoutException extends ConcurrencyException {
|
|
6
|
+
/**
|
|
7
|
+
* Passthrough for {@link Error(String, Throwable)}
|
|
8
|
+
*
|
|
9
|
+
* @param message the message for this exception
|
|
10
|
+
* @param thrown the cause of this exception, null is allowed
|
|
11
|
+
*/
|
|
12
|
+
constructor(message, thrown = null) {
|
|
13
|
+
super(message, thrown);
|
|
14
|
+
this.name = "TimeoutException";
|
|
15
|
+
Object.setPrototypeOf(this, TimeoutException.prototype);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Determine if an instance is a TimeoutException
|
|
20
|
+
*
|
|
21
|
+
* @param instance the instance to check
|
|
22
|
+
* @returns true if the instance is a TimeoutException
|
|
23
|
+
*/
|
|
24
|
+
export function guard(instance) {
|
|
25
|
+
return instance instanceof TimeoutException;
|
|
26
|
+
}
|
|
27
|
+
//# sourceMappingURL=TimeoutException.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TimeoutException.js","sourceRoot":"","sources":["../../src/api/TimeoutException.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,oDAAoD,CAAC;AAE1F;;GAEG;AACH,MAAM,OAAO,gBAAiB,SAAQ,oBAAoB;IAExD;;;;;OAKG;IACH,YAAmB,OAAe,EAAE,SAAuB,IAAI;QAC7D,KAAK,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;QACvB,IAAI,CAAC,IAAI,GAAG,kBAAkB,CAAC;QAC/B,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,gBAAgB,CAAC,SAAS,CAAC,CAAA;IACzD,CAAC;CACF;AAED;;;;;GAKG;AACH,MAAM,UAAU,KAAK,CAAC,QAAiB;IACrC,OAAO,QAAQ,YAAY,gBAAgB,CAAC;AAC9C,CAAC"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { RequiredType } from "@jonloucks/concurrency-ts/api/Types";
|
|
2
|
+
/**
|
|
3
|
+
* Defines how a transition between states will be done
|
|
4
|
+
*
|
|
5
|
+
* @param <R> return type of the transition
|
|
6
|
+
*/
|
|
7
|
+
export interface Transition<S, R> {
|
|
8
|
+
/**
|
|
9
|
+
* @return the name of the event
|
|
10
|
+
*/
|
|
11
|
+
event: string;
|
|
12
|
+
/**
|
|
13
|
+
* @return the goal state of this transition
|
|
14
|
+
*/
|
|
15
|
+
successState: S;
|
|
16
|
+
/**
|
|
17
|
+
* @return the optional state if an exception is thrown
|
|
18
|
+
*/
|
|
19
|
+
errorState?: S;
|
|
20
|
+
/**
|
|
21
|
+
* The optional state if the transition is not allowed.
|
|
22
|
+
*/
|
|
23
|
+
failedState?: S;
|
|
24
|
+
/**
|
|
25
|
+
* @return the optional return value on success
|
|
26
|
+
*/
|
|
27
|
+
getSuccessValue?(): R;
|
|
28
|
+
/**
|
|
29
|
+
* @return the optional return value on exception thrown
|
|
30
|
+
*/
|
|
31
|
+
getErrorValue?(): R;
|
|
32
|
+
/**
|
|
33
|
+
* @return the optional return value if transition is not allowed
|
|
34
|
+
*/
|
|
35
|
+
getFailedValue?(): R;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Type guard to determine if an instance implements Transition
|
|
39
|
+
*
|
|
40
|
+
* @param instance the instance to check
|
|
41
|
+
* @return true if instance is a Transition
|
|
42
|
+
*/
|
|
43
|
+
export declare function guard<S, R>(instance: unknown): instance is RequiredType<Transition<S, R>>;
|
|
44
|
+
//# sourceMappingURL=Transition.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Transition.d.ts","sourceRoot":"","sources":["../../src/api/Transition.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAkB,MAAM,qCAAqC,CAAC;AAEnF;;;;GAIG;AACH,MAAM,WAAW,UAAU,CAAC,CAAC,EAAE,CAAC;IAE9B;;OAEG;IACH,KAAK,EAAE,MAAM,CAAC;IAEd;;OAEG;IACH,YAAY,EAAE,CAAC,CAAC;IAEhB;;OAEG;IACH,UAAU,CAAC,EAAE,CAAC,CAAA;IAEd;;OAEG;IACH,WAAW,CAAC,EAAE,CAAC,CAAA;IAEf;;OAEG;IACH,eAAe,CAAC,IAAI,CAAC,CAAC;IAEtB;;OAEG;IACH,aAAa,CAAC,IAAI,CAAC,CAAC;IAEpB;;OAEG;IACH,cAAc,CAAC,IAAI,CAAC,CAAC;CACtB;AAED;;;;;GAKG;AACH,wBAAgB,KAAK,CAAC,CAAC,EAAE,CAAC,EAAE,QAAQ,EAAE,OAAO,GAAG,QAAQ,IAAI,YAAY,CAAC,UAAU,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAWzF"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { guardFunctions } from "@jonloucks/concurrency-ts/api/Types";
|
|
2
|
+
/**
|
|
3
|
+
* Type guard to determine if an instance implements Transition
|
|
4
|
+
*
|
|
5
|
+
* @param instance the instance to check
|
|
6
|
+
* @return true if instance is a Transition
|
|
7
|
+
*/
|
|
8
|
+
export function guard(instance) {
|
|
9
|
+
return guardFunctions(instance, 'event', 'goalState', 'errorState', 'failedState', 'getSuccessValue', 'getErrorValue', 'getFailedValue');
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=Transition.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Transition.js","sourceRoot":"","sources":["../../src/api/Transition.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgB,cAAc,EAAE,MAAM,qCAAqC,CAAC;AA6CnF;;;;;GAKG;AACH,MAAM,UAAU,KAAK,CAAO,QAAiB;IAC3C,OAAO,cAAc,CACnB,QAAQ,EACR,OAAO,EACP,WAAW,EACX,YAAY,EACZ,aAAa,EACb,iBAAiB,EACjB,eAAe,EACf,gBAAgB,CACjB,CAAC;AACJ,CAAC"}
|