@jonloucks/contracts-ts 0.5.0 → 1.0.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/api/AutoClose.d.ts +3 -5
- package/api/AutoClose.d.ts.map +1 -1
- package/api/AutoClose.js +14 -7
- package/api/AutoClose.js.map +1 -1
- package/api/AutoCloseFactory.d.ts +2 -11
- package/api/AutoCloseFactory.d.ts.map +1 -1
- package/api/AutoCloseFactory.js +4 -25
- package/api/AutoCloseFactory.js.map +1 -1
- package/api/AutoOpen.d.ts +3 -5
- package/api/AutoOpen.d.ts.map +1 -1
- package/api/AutoOpen.js +1 -2
- package/api/AutoOpen.js.map +1 -1
- package/api/BasicContract.d.ts +8 -2
- package/api/BasicContract.d.ts.map +1 -1
- package/api/BasicContract.js +35 -7
- package/api/BasicContract.js.map +1 -1
- package/api/BindStrategy.d.ts +0 -3
- package/api/BindStrategy.d.ts.map +1 -1
- package/api/BindStrategy.js +0 -1
- package/api/BindStrategy.js.map +1 -1
- package/api/Contract.d.ts +15 -13
- package/api/Contract.d.ts.map +1 -1
- package/api/Contract.js +1 -1
- package/api/Contract.js.map +1 -1
- package/api/ContractFactory.d.ts +2 -2
- package/api/ContractFactory.d.ts.map +1 -1
- package/api/ContractFactory.js +1 -1
- package/api/ContractFactory.js.map +1 -1
- package/api/Contracts.d.ts +4 -4
- package/api/Contracts.d.ts.map +1 -1
- package/api/Contracts.js +2 -2
- package/api/Contracts.js.map +1 -1
- package/api/ContractsFactory.d.ts +2 -2
- package/api/ContractsFactory.d.ts.map +1 -1
- package/api/ContractsFactory.js +1 -1
- package/api/ContractsFactory.js.map +1 -1
- package/api/Open.d.ts +20 -0
- package/api/Open.d.ts.map +1 -0
- package/api/Open.js +14 -0
- package/api/Open.js.map +1 -0
- package/api/Promisor.d.ts +1 -10
- package/api/Promisor.d.ts.map +1 -1
- package/api/Promisor.js +2 -26
- package/api/Promisor.js.map +1 -1
- package/api/PromisorFactory.d.ts +1 -7
- package/api/PromisorFactory.d.ts.map +1 -1
- package/api/PromisorFactory.js +4 -24
- package/api/PromisorFactory.js.map +1 -1
- package/api/RatifiedContract.d.ts +2 -2
- package/api/RatifiedContract.d.ts.map +1 -1
- package/api/RatifiedContract.js +1 -4
- package/api/RatifiedContract.js.map +1 -1
- package/api/Repository.d.ts +4 -9
- package/api/Repository.d.ts.map +1 -1
- package/api/Repository.js +2 -25
- package/api/Repository.js.map +1 -1
- package/api/RepositoryFactory.d.ts +2 -8
- package/api/RepositoryFactory.d.ts.map +1 -1
- package/api/RepositoryFactory.js +2 -23
- package/api/RepositoryFactory.js.map +1 -1
- package/api/Types.d.ts +11 -66
- package/api/Types.d.ts.map +1 -1
- package/api/Types.js +14 -105
- package/api/Types.js.map +1 -1
- package/auxiliary/AtomicBoolean.d.ts +2 -11
- package/auxiliary/AtomicBoolean.d.ts.map +1 -1
- package/auxiliary/AtomicBoolean.js +1 -25
- package/auxiliary/AtomicBoolean.js.map +1 -1
- package/auxiliary/AtomicBooleanFactory.d.ts +3 -12
- package/auxiliary/AtomicBooleanFactory.d.ts.map +1 -1
- package/auxiliary/AtomicBooleanFactory.js +2 -24
- package/auxiliary/AtomicBooleanFactory.js.map +1 -1
- package/auxiliary/AtomicInteger.d.ts +2 -11
- package/auxiliary/AtomicInteger.d.ts.map +1 -1
- package/auxiliary/AtomicInteger.js +1 -25
- package/auxiliary/AtomicInteger.js.map +1 -1
- package/auxiliary/AtomicIntegerFactory.d.ts +3 -12
- package/auxiliary/AtomicIntegerFactory.d.ts.map +1 -1
- package/auxiliary/AtomicIntegerFactory.js +2 -24
- package/auxiliary/AtomicIntegerFactory.js.map +1 -1
- package/auxiliary/AtomicReference.d.ts +2 -11
- package/auxiliary/AtomicReference.d.ts.map +1 -1
- package/auxiliary/AtomicReference.js +1 -25
- package/auxiliary/AtomicReference.js.map +1 -1
- package/auxiliary/AtomicReferenceFactory.d.ts +2 -11
- package/auxiliary/AtomicReferenceFactory.d.ts.map +1 -1
- package/auxiliary/AtomicReferenceFactory.js +2 -24
- package/auxiliary/AtomicReferenceFactory.js.map +1 -1
- package/impl/AtomicBooleanFactory.impl.js +2 -2
- package/impl/AtomicBooleanFactory.impl.js.map +1 -1
- package/impl/AtomicIntegerFactory.impl.js +2 -2
- package/impl/AtomicIntegerFactory.impl.js.map +1 -1
- package/impl/AtomicReferenceFactory.impl.js +2 -2
- package/impl/AtomicReferenceFactory.impl.js.map +1 -1
- package/impl/ContractFactory.impl.js +2 -2
- package/impl/ContractFactory.impl.js.map +1 -1
- package/impl/Contracts.impl.d.ts.map +1 -1
- package/impl/Contracts.impl.js +7 -1
- package/impl/Contracts.impl.js.map +1 -1
- package/impl/ContractsFactory.impl.js +4 -4
- package/impl/ContractsFactory.impl.js.map +1 -1
- package/impl/ContractsWrapper.impl.d.ts.map +1 -1
- package/impl/ContractsWrapper.impl.js +3 -0
- package/impl/ContractsWrapper.impl.js.map +1 -1
- package/impl/Events.d.ts +2 -2
- package/impl/Events.d.ts.map +1 -1
- package/impl/Events.impl.d.ts.map +1 -1
- package/impl/Events.impl.js +3 -0
- package/impl/Events.impl.js.map +1 -1
- package/impl/LifeCyclePromisor.impl.js +2 -2
- package/impl/LifeCyclePromisor.impl.js.map +1 -1
- package/impl/Repository.impl.d.ts.map +1 -1
- package/impl/Repository.impl.js +7 -1
- package/impl/Repository.impl.js.map +1 -1
- package/impl/RepositoryFactory.impl.js +1 -1
- package/impl/RepositoryFactory.impl.js.map +1 -1
- package/index.d.ts +3 -3
- package/index.d.ts.map +1 -1
- package/index.js +7 -7
- package/index.js.map +1 -1
- package/package.json +2 -2
- package/api/Lawyer.d.ts +0 -20
- package/api/Lawyer.d.ts.map +0 -1
- package/api/Lawyer.js +0 -3
- package/api/Lawyer.js.map +0 -1
- package/auxiliary/ClassCastException.d.ts +0 -8
- package/auxiliary/ClassCastException.d.ts.map +0 -1
- package/auxiliary/ClassCastException.js +0 -18
- package/auxiliary/ClassCastException.js.map +0 -1
package/api/AutoClose.d.ts
CHANGED
|
@@ -58,7 +58,7 @@ export interface AutoCloseWrapper extends AutoClose {
|
|
|
58
58
|
/**
|
|
59
59
|
* Unwrap to get the original AutoCloseType.
|
|
60
60
|
*/
|
|
61
|
-
|
|
61
|
+
unwrapAutoCloseType(): RequiredType<AutoCloseType>;
|
|
62
62
|
}
|
|
63
63
|
/**
|
|
64
64
|
* Convert a simple runnable into an AutoClose with dispose
|
|
@@ -80,16 +80,14 @@ export declare function unwrapAutoClose(autoClose: OptionalType<AutoClose>): Opt
|
|
|
80
80
|
* @param instance the instance to check
|
|
81
81
|
* @returns true if the instance implements AutoClose, false otherwise
|
|
82
82
|
*/
|
|
83
|
-
export declare function guard(instance: unknown): instance is
|
|
84
|
-
/** @deprecated use guard instead*/
|
|
85
|
-
export { guard as isAutoClose };
|
|
83
|
+
export declare function guard(instance: unknown): instance is RequiredType<AutoClose>;
|
|
86
84
|
/**
|
|
87
85
|
* Duck-typing check for object with close() method.
|
|
88
86
|
*
|
|
89
87
|
* @param instance the instance to check
|
|
90
88
|
* @returns true if the instance implements AutoClose, false otherwise
|
|
91
89
|
*/
|
|
92
|
-
export declare function isClose(instance: unknown): instance is
|
|
90
|
+
export declare function isClose(instance: unknown): instance is RequiredType<AutoClose>;
|
|
93
91
|
/**
|
|
94
92
|
* Convert an AutoCloseType to an AutoClose
|
|
95
93
|
* @param type the type to convert
|
package/api/AutoClose.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AutoClose.d.ts","sourceRoot":"","sources":["../../src/api/AutoClose.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,YAAY,
|
|
1
|
+
{"version":3,"file":"AutoClose.d.ts","sourceRoot":"","sources":["../../src/api/AutoClose.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,YAAY,EAAgC,MAAM,mCAAmC,CAAC;AAI7G;;GAEG;AACH,MAAM,MAAM,aAAa,GAAG,SAAS,GAAG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GAAG,YAAY,CAAC,SAAS,CAAC,CAW1F"}
|
package/api/AutoClose.js
CHANGED
|
@@ -4,12 +4,11 @@ exports.AUTO_CLOSE_NONE = void 0;
|
|
|
4
4
|
exports.inlineAutoClose = inlineAutoClose;
|
|
5
5
|
exports.unwrapAutoClose = unwrapAutoClose;
|
|
6
6
|
exports.guard = guard;
|
|
7
|
-
exports.isAutoClose = guard;
|
|
8
7
|
exports.isClose = isClose;
|
|
9
8
|
exports.typeToAutoClose = typeToAutoClose;
|
|
10
9
|
const Types_1 = require("@jonloucks/contracts-ts/api/Types");
|
|
11
|
-
const IllegalArgumentException_1 = require("@jonloucks/contracts-ts/auxiliary/IllegalArgumentException");
|
|
12
10
|
const Checks_1 = require("@jonloucks/contracts-ts/auxiliary/Checks");
|
|
11
|
+
const IllegalArgumentException_1 = require("@jonloucks/contracts-ts/auxiliary/IllegalArgumentException");
|
|
13
12
|
/**
|
|
14
13
|
* A no-op AutoClose instance that does nothing on close or dispose.
|
|
15
14
|
*/
|
|
@@ -27,6 +26,14 @@ exports.AUTO_CLOSE_NONE = {
|
|
|
27
26
|
// no-op
|
|
28
27
|
}
|
|
29
28
|
};
|
|
29
|
+
/**
|
|
30
|
+
* Check if an instance is an AutoCloseWrapper
|
|
31
|
+
* @param instance the instance to check
|
|
32
|
+
* @returns true if the instance is an AutoCloseWrapper, false otherwise
|
|
33
|
+
*/
|
|
34
|
+
function guardAutoCloseWrapper(instance) {
|
|
35
|
+
return (0, Types_1.guardFunctions)(instance, 'unwrapAutoCloseType');
|
|
36
|
+
}
|
|
30
37
|
/**
|
|
31
38
|
* Convert a simple runnable into an AutoClose with dispose
|
|
32
39
|
*
|
|
@@ -37,7 +44,7 @@ function inlineAutoClose(action) {
|
|
|
37
44
|
return {
|
|
38
45
|
close: action,
|
|
39
46
|
[Symbol.dispose]: action,
|
|
40
|
-
|
|
47
|
+
unwrapAutoCloseType: () => action
|
|
41
48
|
};
|
|
42
49
|
}
|
|
43
50
|
/**
|
|
@@ -50,8 +57,8 @@ function unwrapAutoClose(autoClose) {
|
|
|
50
57
|
if ((0, Types_1.isNotPresent)(autoClose)) {
|
|
51
58
|
return autoClose;
|
|
52
59
|
}
|
|
53
|
-
if (
|
|
54
|
-
return autoClose.
|
|
60
|
+
if (guardAutoCloseWrapper(autoClose)) {
|
|
61
|
+
return autoClose.unwrapAutoCloseType();
|
|
55
62
|
}
|
|
56
63
|
return autoClose;
|
|
57
64
|
}
|
|
@@ -62,7 +69,7 @@ function unwrapAutoClose(autoClose) {
|
|
|
62
69
|
* @returns true if the instance implements AutoClose, false otherwise
|
|
63
70
|
*/
|
|
64
71
|
function guard(instance) {
|
|
65
|
-
return (0, Types_1.
|
|
72
|
+
return (0, Types_1.guardFunctions)(instance, 'close', Symbol.dispose);
|
|
66
73
|
}
|
|
67
74
|
/**
|
|
68
75
|
* Duck-typing check for object with close() method.
|
|
@@ -71,7 +78,7 @@ function guard(instance) {
|
|
|
71
78
|
* @returns true if the instance implements AutoClose, false otherwise
|
|
72
79
|
*/
|
|
73
80
|
function isClose(instance) {
|
|
74
|
-
return (0, Types_1.
|
|
81
|
+
return (0, Types_1.guardFunctions)(instance, 'close');
|
|
75
82
|
}
|
|
76
83
|
/**
|
|
77
84
|
* Convert an AutoCloseType to an AutoClose
|
package/api/AutoClose.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AutoClose.js","sourceRoot":"","sources":["../../src/api/AutoClose.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"AutoClose.js","sourceRoot":"","sources":["../../src/api/AutoClose.ts"],"names":[],"mappings":";;;AAyGA,0CAMC;AAQD,0CAQC;AAQD,sBAEC;AAQD,0BAEC;AAOD,0CAWC;AArKD,6DAA6G;AAC7G,qEAAwE;AACxE,yGAAsG;AAyDtG;;GAEG;AACU,QAAA,eAAe,GAAc;IAExC;;OAEG;IACH,KAAK,EAAE,GAAG,EAAE;QACV,QAAQ;IACV,CAAC;IAED;;O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O,eAAe,CAAC,GAAG,EAAE,CAAC,WAAW,CAAC,KAAK,EAAE,CAAC,CAAC;IACpD,CAAC;SAAM,IAAI,OAAO,WAAW,KAAK,UAAU,EAAE,CAAC;QAC7C,OAAO,eAAe,CAAC,WAA4B,CAAC,CAAC;IACvD,CAAC;SAAM,CAAC;QACN,MAAM,IAAI,mDAAwB,CAAC,yBAAyB,CAAC,CAAC;IAChE,CAAC;AACH,CAAC"}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { AutoClose, AutoCloseMany, AutoCloseOne, AutoCloseType } from "@jonloucks/contracts-ts/api/AutoClose";
|
|
2
2
|
import { Contract } from "@jonloucks/contracts-ts/api/Contract";
|
|
3
|
-
import {
|
|
4
|
-
import { OptionalType, RequiredType } from "@jonloucks/contracts-ts/api/Types";
|
|
3
|
+
import { RequiredType } from "@jonloucks/contracts-ts/api/Types";
|
|
5
4
|
/**
|
|
6
5
|
* Interface for a factory that creates AutoClose instances.
|
|
7
6
|
*/
|
|
@@ -34,15 +33,7 @@ export { OptionalType, RequiredType } from "@jonloucks/contracts-ts/api/Types";
|
|
|
34
33
|
* @param instance the instance to check
|
|
35
34
|
* @returns true if the instance implements AutoCloseFactory
|
|
36
35
|
*/
|
|
37
|
-
export declare function guard(instance: unknown): instance is
|
|
38
|
-
/** @deprecated use guard instead
|
|
39
|
-
*/
|
|
40
|
-
export { guard as isAutoCloseFactory };
|
|
41
|
-
/**
|
|
42
|
-
* For creating a Contract for AutoCloseFactory with duck-typing checks.
|
|
43
|
-
* @deprecated use CONTRACT instead
|
|
44
|
-
*/
|
|
45
|
-
export declare const LAWYER: Lawyer<AutoCloseFactory>;
|
|
36
|
+
export declare function guard(instance: unknown): instance is RequiredType<AutoCloseFactory>;
|
|
46
37
|
/**
|
|
47
38
|
* The Contract for AutoCloseFactory implementation.
|
|
48
39
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AutoCloseFactory.d.ts","sourceRoot":"","sources":["../../src/api/AutoCloseFactory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,uCAAuC,CAAC;AAC9G,OAAO,EAAE,QAAQ,
|
|
1
|
+
{"version":3,"file":"AutoCloseFactory.d.ts","sourceRoot":"","sources":["../../src/api/AutoCloseFactory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,uCAAuC,CAAC;AAC9G,OAAO,EAAE,QAAQ,EAAE,MAAM,sCAAsC,CAAC;AAEhE,OAAO,EAAkB,YAAY,EAAE,MAAM,mCAAmC,CAAC;AAEjF;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAE7B;;;;OAIG;IACH,eAAe,CAAC,IAAI,EAAE,YAAY,CAAC,aAAa,CAAC,GAAG,YAAY,CAAC,SAAS,CAAC,CAAC;IAE5E;;;;OAIG;IACH,mBAAmB,IAAI,YAAY,CAAC,aAAa,CAAC,CAAC;IAEnD;;;;OAIG;IACH,kBAAkB,IAAI,YAAY,CAAC,YAAY,CAAC,CAAC;CACpD;AAED,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,uCAAuC,CAAC;AAC9G,OAAO,EAAE,QAAQ,EAAE,MAAM,sCAAsC,CAAC;AAChE,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,mCAAmC,CAAC;AAE/E;;;;;GAKG;AACH,wBAAgB,KAAK,CAAC,QAAQ,EAAE,OAAO,GAAG,QAAQ,IAAI,YAAY,CAAC,gBAAgB,CAAC,CAEnF;AAED;;GAEG;AACH,eAAO,MAAM,QAAQ,EAAE,QAAQ,CAAC,gBAAgB,CAI9C,CAAC"}
|
package/api/AutoCloseFactory.js
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.CONTRACT =
|
|
3
|
+
exports.CONTRACT = void 0;
|
|
4
4
|
exports.guard = guard;
|
|
5
|
-
exports.isAutoCloseFactory = guard;
|
|
6
5
|
const RatifiedContract_1 = require("@jonloucks/contracts-ts/api/RatifiedContract");
|
|
7
6
|
const Types_1 = require("@jonloucks/contracts-ts/api/Types");
|
|
8
7
|
/**
|
|
@@ -12,34 +11,14 @@ const Types_1 = require("@jonloucks/contracts-ts/api/Types");
|
|
|
12
11
|
* @returns true if the instance implements AutoCloseFactory
|
|
13
12
|
*/
|
|
14
13
|
function guard(instance) {
|
|
15
|
-
return (0, Types_1.
|
|
14
|
+
return (0, Types_1.guardFunctions)(instance, 'createAutoClose', 'createAutoCloseMany', 'createAutoCloseOne');
|
|
16
15
|
}
|
|
17
|
-
/**
|
|
18
|
-
* For creating a Contract for AutoCloseFactory with duck-typing checks.
|
|
19
|
-
* @deprecated use CONTRACT instead
|
|
20
|
-
*/
|
|
21
|
-
exports.LAWYER = new class {
|
|
22
|
-
/**
|
|
23
|
-
* Lawyer.isDeliverable override
|
|
24
|
-
*/
|
|
25
|
-
isDeliverable(instance) {
|
|
26
|
-
return guard(instance);
|
|
27
|
-
}
|
|
28
|
-
/**
|
|
29
|
-
* Lawyer.createContract override
|
|
30
|
-
*/
|
|
31
|
-
createContract(config) {
|
|
32
|
-
const copy = { ...config ?? {} };
|
|
33
|
-
copy.test ?? (copy.test = this.isDeliverable);
|
|
34
|
-
copy.typeName ?? (copy.typeName = "AutoCloseFactory");
|
|
35
|
-
return (0, RatifiedContract_1.create)(copy);
|
|
36
|
-
}
|
|
37
|
-
};
|
|
38
16
|
/**
|
|
39
17
|
* The Contract for AutoCloseFactory implementation.
|
|
40
18
|
*/
|
|
41
19
|
exports.CONTRACT = (0, RatifiedContract_1.create)({
|
|
42
20
|
test: guard,
|
|
43
|
-
name: "AutoCloseFactory"
|
|
21
|
+
name: "AutoCloseFactory",
|
|
22
|
+
typeName: "AutoCloseFactory"
|
|
44
23
|
});
|
|
45
24
|
//# sourceMappingURL=AutoCloseFactory.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AutoCloseFactory.js","sourceRoot":"","sources":["../../src/api/AutoCloseFactory.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"AutoCloseFactory.js","sourceRoot":"","sources":["../../src/api/AutoCloseFactory.ts"],"names":[],"mappings":";;;AA0CA,sBAEC;AA1CD,mFAAwF;AACxF,6DAAiF;AAiCjF;;;;;GAKG;AACH,SAAgB,KAAK,CAAC,QAAiB;IACnC,OAAO,IAAA,sBAAc,EAAC,QAAQ,EAAE,iBAAiB,EAAE,qBAAqB,EAAE,oBAAoB,CAAC,CAAC;AACpG,CAAC;AAED;;GAEG;AACU,QAAA,QAAQ,GAA+B,IAAA,yBAAc,EAAC;IAC/D,IAAI,EAAE,KAAK;IACX,IAAI,EAAE,kBAAkB;IACxB,QAAQ,EAAE,kBAAkB;CAC/B,CAAC,CAAC"}
|
package/api/AutoOpen.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { AutoClose } from "@jonloucks/contracts-ts/api/AutoClose";
|
|
2
|
+
import { RequiredType } from "@jonloucks/contracts-ts/api/Types";
|
|
2
3
|
/**
|
|
3
4
|
* Opt-in interface to be called once after creation, although implementations should
|
|
4
5
|
* handle this gracefully. For example, this is when threads or hooks could be added.
|
|
@@ -11,7 +12,7 @@ export interface AutoOpen {
|
|
|
11
12
|
* AutoOpen this instance
|
|
12
13
|
* @return the mechanism to shut down
|
|
13
14
|
*/
|
|
14
|
-
|
|
15
|
+
autoOpen(): AutoClose;
|
|
15
16
|
}
|
|
16
17
|
/**
|
|
17
18
|
* Duck-typing check for AutoOpen interface.
|
|
@@ -19,8 +20,5 @@ export interface AutoOpen {
|
|
|
19
20
|
* @param instance the instance to check
|
|
20
21
|
* @returns true if the instance implements AutoOpen, false otherwise
|
|
21
22
|
*/
|
|
22
|
-
export declare function guard(instance: unknown): instance is AutoOpen
|
|
23
|
-
/** @deprecated use guard instead
|
|
24
|
-
*/
|
|
25
|
-
export { guard as isAutoOpen };
|
|
23
|
+
export declare function guard(instance: unknown): instance is RequiredType<AutoOpen>;
|
|
26
24
|
//# sourceMappingURL=AutoOpen.d.ts.map
|
package/api/AutoOpen.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AutoOpen.d.ts","sourceRoot":"","sources":["../../src/api/AutoOpen.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,uCAAuC,CAAC;
|
|
1
|
+
{"version":3,"file":"AutoOpen.d.ts","sourceRoot":"","sources":["../../src/api/AutoOpen.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,uCAAuC,CAAC;AAClE,OAAO,EAAkB,YAAY,EAAE,MAAM,mCAAmC,CAAC;AAEjF;;;;;;GAMG;AACH,MAAM,WAAW,QAAQ;IAErB;;;OAGG;IACH,QAAQ,IAAI,SAAS,CAAC;CACzB;AAED;;;;;GAKG;AACH,wBAAgB,KAAK,CAAC,QAAQ,EAAE,OAAO,GAAG,QAAQ,IAAI,YAAY,CAAC,QAAQ,CAAC,CAE3E"}
|
package/api/AutoOpen.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.guard = guard;
|
|
4
|
-
exports.isAutoOpen = guard;
|
|
5
4
|
const Types_1 = require("@jonloucks/contracts-ts/api/Types");
|
|
6
5
|
/**
|
|
7
6
|
* Duck-typing check for AutoOpen interface.
|
|
@@ -10,6 +9,6 @@ const Types_1 = require("@jonloucks/contracts-ts/api/Types");
|
|
|
10
9
|
* @returns true if the instance implements AutoOpen, false otherwise
|
|
11
10
|
*/
|
|
12
11
|
function guard(instance) {
|
|
13
|
-
return (0, Types_1.
|
|
12
|
+
return (0, Types_1.guardFunctions)(instance, 'autoOpen');
|
|
14
13
|
}
|
|
15
14
|
//# sourceMappingURL=AutoOpen.js.map
|
package/api/AutoOpen.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AutoOpen.js","sourceRoot":"","sources":["../../src/api/AutoOpen.ts"],"names":[],"mappings":";;AAyBA,sBAEC;
|
|
1
|
+
{"version":3,"file":"AutoOpen.js","sourceRoot":"","sources":["../../src/api/AutoOpen.ts"],"names":[],"mappings":";;AAyBA,sBAEC;AA1BD,6DAAiF;AAkBjF;;;;;GAKG;AACH,SAAgB,KAAK,CAAC,QAAiB;IACnC,OAAO,IAAA,sBAAc,EAAC,QAAQ,EAAE,UAAU,CAAC,CAAC;AAChD,CAAC"}
|
package/api/BasicContract.d.ts
CHANGED
|
@@ -30,13 +30,18 @@ export declare class BasicContract<T> implements Contract<T> {
|
|
|
30
30
|
*
|
|
31
31
|
* @param value the value to cast
|
|
32
32
|
* @return the checked value. Note: null is possible. The Promisor is allowed to return null
|
|
33
|
-
* @throws
|
|
33
|
+
* @throws ContractException if the value can't be cast to the return type.
|
|
34
34
|
*/
|
|
35
35
|
cast(value: unknown | null | undefined): DeliveryType<T>;
|
|
36
36
|
/**
|
|
37
37
|
* @return the contract name
|
|
38
38
|
*/
|
|
39
39
|
get name(): string;
|
|
40
|
+
/**
|
|
41
|
+
* When guarded is true the Contract throws exception if deliverable is null or undefined
|
|
42
|
+
* The default is true.
|
|
43
|
+
*/
|
|
44
|
+
get guarded(): boolean;
|
|
40
45
|
/**
|
|
41
46
|
* Note: Do not rely on this being a java class name
|
|
42
47
|
* Note: The actual class is never exposed and is by design.
|
|
@@ -62,13 +67,14 @@ export declare class BasicContract<T> implements Contract<T> {
|
|
|
62
67
|
* @param config
|
|
63
68
|
*/
|
|
64
69
|
constructor(config?: Config<T> | null);
|
|
70
|
+
private throwCastException;
|
|
65
71
|
private static ID_GENERATOR;
|
|
66
72
|
private readonly _id;
|
|
67
73
|
private readonly _name;
|
|
68
74
|
private readonly _typeName;
|
|
69
75
|
private readonly _tester;
|
|
70
|
-
private readonly _caster;
|
|
71
76
|
private readonly _replaceable;
|
|
77
|
+
private readonly _guarded;
|
|
72
78
|
}
|
|
73
79
|
type DeliveryType<T> = OptionalType<T>;
|
|
74
80
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BasicContract.d.ts","sourceRoot":"","sources":["../../src/api/BasicContract.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,sCAAsC,CAAC;AACxE,OAAO,
|
|
1
|
+
{"version":3,"file":"BasicContract.d.ts","sourceRoot":"","sources":["../../src/api/BasicContract.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,sCAAsC,CAAC;AACxE,OAAO,EAAgB,YAAY,EAAE,YAAY,EAAE,MAAM,mCAAmC,CAAC;AAG7F;;;;;GAKG;AACH,wBAAgB,MAAM,CAAC,CAAC,EAAE,MAAM,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC,GAAG,IAAI,GAAG,YAAY,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAE9E;AAED;;;;;;;GAOG;AACH,qBAAa,aAAa,CAAC,CAAC,CAAE,YAAW,QAAQ,CAAC,CAAC,CAAC;IAElD;;;;;;QAMI;IACJ,MAAM,CAAC,MAAM,CAAC,CAAC,EAAE,MAAM,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC,GAAG,IAAI,GAAG,QAAQ,CAAC,CAAC,CAAC;IAIxD;;;;;;;MAOE;IACK,IAAI,CAAC,KAAK,EAAE,OAAO,GAAG,IAAI,GAAG,SAAS,GAAG,YAAY,CAAC,CAAC,CAAC;IAc/D;;OAEG;IACH,IAAW,IAAI,IAAI,MAAM,CAExB;IAED;;;OAGG;IACH,IAAW,OAAO,IAAI,OAAO,CAE5B;IAED;;;;;OAKG;IACH,IAAW,QAAQ,IAAI,MAAM,CAE5B;IAED;;;;;OAKG;IACH,IAAW,WAAW,IAAI,OAAO,CAEhC;IAED;;;;OAIG;IACI,QAAQ,IAAI,MAAM;IAYzB;;;OAGG;gBACgB,MAAM,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC,GAAG,IAAI;IAS5C,OAAO,CAAC,kBAAkB;IAK1B,OAAO,CAAC,MAAM,CAAC,YAAY,CAAa;IAExC,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAwC;IAC5D,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAS;IAC/B,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAS;IACnC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAc;IACtC,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAU;IACvC,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAU;CACpC;AAED,KAAK,YAAY,CAAC,CAAC,IAAI,YAAY,CAAC,CAAC,CAAC,CAAC"}
|
package/api/BasicContract.js
CHANGED
|
@@ -2,7 +2,8 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.BasicContract = void 0;
|
|
4
4
|
exports.create = create;
|
|
5
|
-
const
|
|
5
|
+
const Types_1 = require("@jonloucks/contracts-ts/api/Types");
|
|
6
|
+
const ContractException_1 = require("@jonloucks/contracts-ts/api/ContractException");
|
|
6
7
|
/**
|
|
7
8
|
* Create a basic Contract
|
|
8
9
|
*
|
|
@@ -37,14 +38,22 @@ class BasicContract {
|
|
|
37
38
|
*
|
|
38
39
|
* @param value the value to cast
|
|
39
40
|
* @return the checked value. Note: null is possible. The Promisor is allowed to return null
|
|
40
|
-
* @throws
|
|
41
|
+
* @throws ContractException if the value can't be cast to the return type.
|
|
41
42
|
*/
|
|
42
43
|
cast(value) {
|
|
44
|
+
if ((0, Types_1.isNotPresent)(value)) {
|
|
45
|
+
if (this._guarded) {
|
|
46
|
+
this.throwCastException();
|
|
47
|
+
}
|
|
48
|
+
else {
|
|
49
|
+
return value;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
43
52
|
if (this._tester(value)) {
|
|
44
|
-
return
|
|
53
|
+
return value;
|
|
45
54
|
}
|
|
46
55
|
else {
|
|
47
|
-
|
|
56
|
+
this.throwCastException();
|
|
48
57
|
}
|
|
49
58
|
}
|
|
50
59
|
/**
|
|
@@ -53,6 +62,13 @@ class BasicContract {
|
|
|
53
62
|
get name() {
|
|
54
63
|
return this._name;
|
|
55
64
|
}
|
|
65
|
+
/**
|
|
66
|
+
* When guarded is true the Contract throws exception if deliverable is null or undefined
|
|
67
|
+
* The default is true.
|
|
68
|
+
*/
|
|
69
|
+
get guarded() {
|
|
70
|
+
return this._guarded;
|
|
71
|
+
}
|
|
56
72
|
/**
|
|
57
73
|
* Note: Do not rely on this being a java class name
|
|
58
74
|
* Note: The actual class is never exposed and is by design.
|
|
@@ -77,7 +93,15 @@ class BasicContract {
|
|
|
77
93
|
* @returns a string representation of the contract
|
|
78
94
|
*/
|
|
79
95
|
toString() {
|
|
80
|
-
|
|
96
|
+
let text = `Contract(id=${this._id}`;
|
|
97
|
+
if (this.name.length > 0) {
|
|
98
|
+
text += `, name=${this.name}`;
|
|
99
|
+
}
|
|
100
|
+
if (this.typeName.length > 0) {
|
|
101
|
+
text += `, type=${this.typeName}`;
|
|
102
|
+
}
|
|
103
|
+
text += `)`;
|
|
104
|
+
return text;
|
|
81
105
|
}
|
|
82
106
|
/**
|
|
83
107
|
*
|
|
@@ -87,10 +111,14 @@ class BasicContract {
|
|
|
87
111
|
this._id = BasicContract.ID_GENERATOR++;
|
|
88
112
|
const candidateConfig = config ?? {};
|
|
89
113
|
this._replaceable = candidateConfig?.replaceable ?? false;
|
|
114
|
+
this._guarded = candidateConfig?.guarded ?? true;
|
|
90
115
|
this._name = candidateConfig?.name ?? "";
|
|
91
116
|
this._typeName = candidateConfig?.typeName ?? "";
|
|
92
|
-
this._tester = candidateConfig?.test ?? ((
|
|
93
|
-
|
|
117
|
+
this._tester = candidateConfig?.test ?? ((_instance) => true);
|
|
118
|
+
}
|
|
119
|
+
throwCastException() {
|
|
120
|
+
// Note: message intentionally does not include the instance value
|
|
121
|
+
throw new ContractException_1.ContractException(`Casting error. Unable to cast '${this.toString()}'.`);
|
|
94
122
|
}
|
|
95
123
|
}
|
|
96
124
|
exports.BasicContract = BasicContract;
|
package/api/BasicContract.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BasicContract.js","sourceRoot":"","sources":["../../src/api/BasicContract.ts"],"names":[],"mappings":";;;AAUA,wBAEC;
|
|
1
|
+
{"version":3,"file":"BasicContract.js","sourceRoot":"","sources":["../../src/api/BasicContract.ts"],"names":[],"mappings":";;;AAUA,wBAEC;AAXD,6DAA6F;AAC7F,qFAAkF;AAElF;;;;;GAKG;AACH,SAAgB,MAAM,CAAI,MAAyB;IACjD,OAAO,aAAa,CAAC,MAAM,CAAI,MAAM,CAAC,CAAC;AACzC,CAAC;AAED;;;;;;;GAOG;AACH,MAAa,aAAa;IAExB;;;;;;QAMI;IACJ,MAAM,CAAC,MAAM,CAAI,MAAyB;QACxC,OAAO,IAAI,aAAa,CAAI,MAAM,CAAC,CAAC;IACtC,CAAC;IAED;;;;;;;MAOE;IACK,IAAI,CAAC,KAAiC;QAC3C,IAAI,IAAA,oBAAY,EAAC,KAAK,CAAC,EAAE,CAAC;YACxB,IAAI,IAAI,CAAC,QAAQ,EAAE,CAAC;gBAClB,IAAI,CAAC,kBAAkB,EAAE,CAAC;YAC5B,CAAC;iBAAM,CAAC;gBACN,OAAO,KAAwB,CAAC;YAClC,CAAC;QACH,CAAC;QAAC,IAAI,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;YAC1B,OAAO,KAAK,CAAC;QACf,CAAC;aAAM,CAAC;YACJ,IAAI,CAAC,kBAAkB,EAAE,CAAC;QAC9B,CAAC;IACH,CAAC;IAED;;OAEG;IACH,IAAW,IAAI;QACb,OAAO,IAAI,CAAC,KAAK,CAAC;IACpB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AAI,qCAAiB,CAAC,kCAAkC,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC;IACrF,CAAC;;AAvGH,sCAiHC;AARgB,0BAAY,GAAW,CAAC,AAAZ,CAAa"}
|
package/api/BindStrategy.d.ts
CHANGED
|
@@ -42,7 +42,4 @@ export declare function resolveBindStrategy(bindStrategy: OptionalType<BindStrat
|
|
|
42
42
|
* @returns true if value is a BindStrategy or null/undefined
|
|
43
43
|
*/
|
|
44
44
|
export declare function guard(instance: unknown): instance is OptionalType<BindStrategy>;
|
|
45
|
-
/** @deprecated use guard instead
|
|
46
|
-
*/
|
|
47
|
-
export { guard as isBindStrategy };
|
|
48
45
|
//# sourceMappingURL=BindStrategy.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BindStrategy.d.ts","sourceRoot":"","sources":["../../src/api/BindStrategy.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,mCAAmC,CAAC;AAE/E;;;;;;;;GAQG;AACH,MAAM,MAAM,YAAY;AACpB;;EAEE;AACF,QAAQ;AACR;;EAEE;AACF,cAAc;AACd;;EAEE;AACF,YAAY,CAAC;AAEjB;;GAEG;AACH,eAAO,MAAM,qBAAqB,EAAE,YAA2B,CAAA;AAE/D;;GAEG;AACH,MAAM,MAAM,gBAAgB,GAAG,YAAY,CAAC,YAAY,CAAC,CAAC;AAE1D;;;;;GAKG;AACH,wBAAgB,mBAAmB,CAAC,YAAY,EAAE,YAAY,CAAC,YAAY,CAAC,GAAG,YAAY,CAAC,YAAY,CAAC,CAExG;AAED;;;;GAIG;AACH,wBAAgB,KAAK,CAAC,QAAQ,EAAE,OAAO,GAAG,QAAQ,IAAI,YAAY,CAAC,YAAY,CAAC,CAW/E
|
|
1
|
+
{"version":3,"file":"BindStrategy.d.ts","sourceRoot":"","sources":["../../src/api/BindStrategy.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,mCAAmC,CAAC;AAE/E;;;;;;;;GAQG;AACH,MAAM,MAAM,YAAY;AACpB;;EAEE;AACF,QAAQ;AACR;;EAEE;AACF,cAAc;AACd;;EAEE;AACF,YAAY,CAAC;AAEjB;;GAEG;AACH,eAAO,MAAM,qBAAqB,EAAE,YAA2B,CAAA;AAE/D;;GAEG;AACH,MAAM,MAAM,gBAAgB,GAAG,YAAY,CAAC,YAAY,CAAC,CAAC;AAE1D;;;;;GAKG;AACH,wBAAgB,mBAAmB,CAAC,YAAY,EAAE,YAAY,CAAC,YAAY,CAAC,GAAG,YAAY,CAAC,YAAY,CAAC,CAExG;AAED;;;;GAIG;AACH,wBAAgB,KAAK,CAAC,QAAQ,EAAE,OAAO,GAAG,QAAQ,IAAI,YAAY,CAAC,YAAY,CAAC,CAW/E"}
|
package/api/BindStrategy.js
CHANGED
package/api/BindStrategy.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BindStrategy.js","sourceRoot":"","sources":["../../src/api/BindStrategy.ts"],"names":[],"mappings":";;;AAyCA,kDAEC;AAOD,sBAWC;
|
|
1
|
+
{"version":3,"file":"BindStrategy.js","sourceRoot":"","sources":["../../src/api/BindStrategy.ts"],"names":[],"mappings":";;;AAyCA,kDAEC;AAOD,sBAWC;AApCD;;GAEG;AACU,QAAA,qBAAqB,GAAiB,YAAY,CAAA;AAO/D;;;;;GAKG;AACH,SAAgB,mBAAmB,CAAC,YAAwC;IACxE,OAAO,YAAY,IAAI,6BAAqB,CAAC;AACjD,CAAC;AAED;;;;GAIG;AACH,SAAgB,KAAK,CAAC,QAAiB;IACnC,QAAQ,QAAQ,EAAE,CAAC;QACf,KAAK,SAAS,CAAC;QACf,KAAK,IAAI,CAAC;QACV,KAAK,QAAQ,CAAC;QACd,KAAK,cAAc,CAAC;QACpB,KAAK,YAAY;YACb,OAAO,IAAI,CAAC;QAChB;YACI,OAAO,KAAK,CAAC;IACrB,CAAC;AACL,CAAC"}
|
package/api/Contract.d.ts
CHANGED
|
@@ -1,24 +1,16 @@
|
|
|
1
|
-
import { OptionalType } from "@jonloucks/contracts-ts/api/Types";
|
|
1
|
+
import { OptionalType, RequiredType } from "@jonloucks/contracts-ts/api/Types";
|
|
2
2
|
/**
|
|
3
3
|
* Configuration for a Contract
|
|
4
4
|
*
|
|
5
5
|
* @param <T> The Contract deliverable type
|
|
6
6
|
*/
|
|
7
7
|
export interface Config<T> {
|
|
8
|
-
/**
|
|
9
|
-
* Ensure an instance is of type T (or descendant)
|
|
10
|
-
*
|
|
11
|
-
* @param instance the value to cast to type T
|
|
12
|
-
* @return the value, null is allowed
|
|
13
|
-
* @throws ClassCastException when type of instance is not correct
|
|
14
|
-
*/
|
|
15
|
-
cast?: (instance: unknown) => OptionalType<T>;
|
|
16
8
|
/**
|
|
17
9
|
* the predefine test to check if instance is of type T
|
|
18
10
|
* @param instance the instance to check
|
|
19
|
-
* @returns
|
|
11
|
+
* @returns true if the instance is of type T, false otherwise
|
|
20
12
|
*/
|
|
21
|
-
test?: (instance: unknown) => instance is
|
|
13
|
+
test?: (instance: unknown) => instance is RequiredType<T>;
|
|
22
14
|
/**
|
|
23
15
|
* User defined name for this contract.
|
|
24
16
|
* Note: Do not rely on this being a java class name
|
|
@@ -45,6 +37,11 @@ export interface Config<T> {
|
|
|
45
37
|
* and must comply with RatifiedContract rules.
|
|
46
38
|
*/
|
|
47
39
|
ratified?: boolean;
|
|
40
|
+
/**
|
|
41
|
+
* When guarded is true the Contract throws exception if deliverable is null or undefined
|
|
42
|
+
* The default is true.
|
|
43
|
+
*/
|
|
44
|
+
guarded?: boolean;
|
|
48
45
|
}
|
|
49
46
|
/**
|
|
50
47
|
* A Contract defines a deliverable type by name and type.
|
|
@@ -58,7 +55,7 @@ export interface Contract<T> {
|
|
|
58
55
|
*
|
|
59
56
|
* @param value the value to cast
|
|
60
57
|
* @return the checked value. Note: null is possible. The Promisor is allowed to return null
|
|
61
|
-
* @throws
|
|
58
|
+
* @throws ContractException if the value can't be cast to the return type.
|
|
62
59
|
*/
|
|
63
60
|
cast(value: OptionalType<unknown>): OptionalType<T>;
|
|
64
61
|
/**
|
|
@@ -79,6 +76,11 @@ export interface Contract<T> {
|
|
|
79
76
|
* @return true if replaceable
|
|
80
77
|
*/
|
|
81
78
|
get replaceable(): boolean;
|
|
79
|
+
/**
|
|
80
|
+
* When guarded is true the Contract throws exception if deliverable is null or undefined
|
|
81
|
+
* The default is true.
|
|
82
|
+
*/
|
|
83
|
+
get guarded(): boolean;
|
|
82
84
|
}
|
|
83
85
|
/**
|
|
84
86
|
* Duck-typing check for Contract interface.
|
|
@@ -86,5 +88,5 @@ export interface Contract<T> {
|
|
|
86
88
|
* @param instance the instance to check
|
|
87
89
|
* @returns true if the instance implements Contract, false otherwise
|
|
88
90
|
*/
|
|
89
|
-
export declare function guard<T>(instance: unknown): instance is Contract<T
|
|
91
|
+
export declare function guard<T>(instance: unknown): instance is RequiredType<Contract<T>>;
|
|
90
92
|
//# sourceMappingURL=Contract.d.ts.map
|
package/api/Contract.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Contract.d.ts","sourceRoot":"","sources":["../../src/api/Contract.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"Contract.d.ts","sourceRoot":"","sources":["../../src/api/Contract.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkB,YAAY,EAAE,YAAY,EAAE,MAAM,mCAAmC,CAAC;AAE/F;;;;GAIG;AACH,MAAM,WAAW,MAAM,CAAC,CAAC;IAEvB;;;;OAIG;IACH,IAAI,CAAC,EAAE,CAAC,QAAQ,EAAE,OAAO,KAAK,QAAQ,IAAI,YAAY,CAAC,CAAC,CAAC,CAAC;IAE1D;;;;;OAKG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;IAEd;;;;;OAKG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAElB;;;;;OAKG;IACH,WAAW,CAAC,EAAE,OAAO,CAAC;IAEtB;;;OAGG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IAEnB;;;OAGG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAED;;;;GAIG;AACH,MAAM,WAAW,QAAQ,CAAC,CAAC;IAEzB;;;;;;;MAOE;IACF,IAAI,CAAC,KAAK,EAAE,YAAY,CAAC,OAAO,CAAC,GAAG,YAAY,CAAC,CAAC,CAAC,CAAC;IAEpD;;OAEG;IACH,IAAI,IAAI,IAAI,MAAM,CAAC;IAEnB;;;;;OAKG;IACH,IAAI,QAAQ,IAAI,MAAM,CAAC;IAEvB;;;;;OAKG;IACH,IAAI,WAAW,IAAI,OAAO,CAAC;IAE3B;;;OAGG;IACH,IAAI,OAAO,IAAI,OAAO,CAAC;CACxB;AAED;;;;;GAKG;AACH,wBAAgB,KAAK,CAAC,CAAC,EAAE,QAAQ,EAAE,OAAO,GAAG,QAAQ,IAAI,YAAY,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAEjF"}
|
package/api/Contract.js
CHANGED
|
@@ -9,6 +9,6 @@ const Types_1 = require("@jonloucks/contracts-ts/api/Types");
|
|
|
9
9
|
* @returns true if the instance implements Contract, false otherwise
|
|
10
10
|
*/
|
|
11
11
|
function guard(instance) {
|
|
12
|
-
return (0, Types_1.
|
|
12
|
+
return (0, Types_1.guardFunctions)(instance, 'cast', 'name', 'typeName', 'replaceable');
|
|
13
13
|
}
|
|
14
14
|
//# sourceMappingURL=Contract.js.map
|
package/api/Contract.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Contract.js","sourceRoot":"","sources":["../../src/api/Contract.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"Contract.js","sourceRoot":"","sources":["../../src/api/Contract.ts"],"names":[],"mappings":";;AAwGA,sBAEC;AA1GD,6DAA+F;AAkG/F;;;;;GAKG;AACH,SAAgB,KAAK,CAAI,QAAiB;IACxC,OAAO,IAAA,sBAAc,EAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,aAAa,CAAC,CAAC;AAC7E,CAAC"}
|
package/api/ContractFactory.d.ts
CHANGED
|
@@ -13,7 +13,7 @@ export interface ContractFactory {
|
|
|
13
13
|
* @param config the Contract configuration
|
|
14
14
|
* @return the new Contract
|
|
15
15
|
*/
|
|
16
|
-
|
|
16
|
+
createContract<T>(config?: OptionalType<Config<T>>): RequiredType<Contract<T>>;
|
|
17
17
|
}
|
|
18
18
|
/**
|
|
19
19
|
* Type guard for ContractFactory
|
|
@@ -21,5 +21,5 @@ export interface ContractFactory {
|
|
|
21
21
|
* @param value the value to check
|
|
22
22
|
* @return true if value is ContractFactory, false otherwise
|
|
23
23
|
*/
|
|
24
|
-
export declare function guard(value: unknown): value is ContractFactory
|
|
24
|
+
export declare function guard(value: unknown): value is RequiredType<ContractFactory>;
|
|
25
25
|
//# sourceMappingURL=ContractFactory.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ContractFactory.d.ts","sourceRoot":"","sources":["../../src/api/ContractFactory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,sCAAsC,CAAC;AACxE,OAAO,
|
|
1
|
+
{"version":3,"file":"ContractFactory.d.ts","sourceRoot":"","sources":["../../src/api/ContractFactory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,sCAAsC,CAAC;AACxE,OAAO,EAAkB,YAAY,EAAE,YAAY,EAAE,MAAM,mCAAmC,CAAC;AAE/F;;;GAGG;AACH,MAAM,WAAW,eAAe;IAE9B;;;;;;;OAOG;IACH,cAAc,CAAC,CAAC,EAAE,MAAM,CAAC,EAAE,YAAY,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,GAAG,YAAY,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC;CAChF;AAED;;;;;GAKG;AACH,wBAAgB,KAAK,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,YAAY,CAAC,eAAe,CAAC,CAE5E"}
|
package/api/ContractFactory.js
CHANGED
|
@@ -9,6 +9,6 @@ const Types_1 = require("@jonloucks/contracts-ts/api/Types");
|
|
|
9
9
|
* @return true if value is ContractFactory, false otherwise
|
|
10
10
|
*/
|
|
11
11
|
function guard(value) {
|
|
12
|
-
return (0, Types_1.
|
|
12
|
+
return (0, Types_1.guardFunctions)(value, 'createContract');
|
|
13
13
|
}
|
|
14
14
|
//# sourceMappingURL=ContractFactory.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ContractFactory.js","sourceRoot":"","sources":["../../src/api/ContractFactory.ts"],"names":[],"mappings":";;AA0BA,sBAEC;AA3BD,
|
|
1
|
+
{"version":3,"file":"ContractFactory.js","sourceRoot":"","sources":["../../src/api/ContractFactory.ts"],"names":[],"mappings":";;AA0BA,sBAEC;AA3BD,6DAA+F;AAmB/F;;;;;GAKG;AACH,SAAgB,KAAK,CAAC,KAAc;IAClC,OAAO,IAAA,sBAAc,EAAC,KAAK,EAAE,gBAAgB,CAAC,CAAC;AACjD,CAAC"}
|
package/api/Contracts.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { AutoClose } from "@jonloucks/contracts-ts/api/AutoClose";
|
|
2
|
-
import {
|
|
2
|
+
import { Open } from "@jonloucks/contracts-ts/api/Open";
|
|
3
3
|
import { BindStrategyType as BindType } from "@jonloucks/contracts-ts/api/BindStrategy";
|
|
4
4
|
import { Contract } from "@jonloucks/contracts-ts/api/Contract";
|
|
5
5
|
import { PromisorType } from "@jonloucks/contracts-ts/api/Promisor";
|
|
@@ -30,7 +30,7 @@ export interface Config {
|
|
|
30
30
|
* It does know how to load the default from contracts-impl.
|
|
31
31
|
* However, the design is open to have it replaced with an alternative implementation.
|
|
32
32
|
*/
|
|
33
|
-
export interface Contracts extends
|
|
33
|
+
export interface Contracts extends Open {
|
|
34
34
|
/**
|
|
35
35
|
* Claim the deliverable from a bound contract.
|
|
36
36
|
*
|
|
@@ -47,7 +47,7 @@ export interface Contracts extends AutoOpen {
|
|
|
47
47
|
*
|
|
48
48
|
* @param contract the contract to claim
|
|
49
49
|
* @param <T> type of value returned
|
|
50
|
-
* @return the value returned by the bound Promisor, but never null
|
|
50
|
+
* @return the value returned by the bound Promisor, but never null or undefined
|
|
51
51
|
* @throws ContractException if Promisor binding does not exist for the contract, or the deliverable is null
|
|
52
52
|
* @throws SecurityException if permission is denied
|
|
53
53
|
* @throws IllegalArgumentException may throw when an argument is null
|
|
@@ -82,5 +82,5 @@ export interface Contracts extends AutoOpen {
|
|
|
82
82
|
* @param value the value to check
|
|
83
83
|
* @return true if value is Contracts, false otherwise
|
|
84
84
|
*/
|
|
85
|
-
export declare function guard(value: unknown): value is Contracts
|
|
85
|
+
export declare function guard(value: unknown): value is RequiredType<Contracts>;
|
|
86
86
|
//# sourceMappingURL=Contracts.d.ts.map
|
package/api/Contracts.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Contracts.d.ts","sourceRoot":"","sources":["../../src/api/Contracts.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,uCAAuC,CAAC;AAClE,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"Contracts.d.ts","sourceRoot":"","sources":["../../src/api/Contracts.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,uCAAuC,CAAC;AAClE,OAAO,EAAE,IAAI,EAAsB,MAAM,kCAAkC,CAAC;AAC5E,OAAO,EAAE,gBAAgB,IAAI,QAAQ,EAAE,MAAM,0CAA0C,CAAC;AACxF,OAAO,EAAE,QAAQ,EAAE,MAAM,sCAAsC,CAAC;AAChE,OAAO,EAAE,YAAY,EAAE,MAAM,sCAAsC,CAAC;AACpE,OAAO,EAAkB,YAAY,EAAE,YAAY,EAAE,MAAM,mCAAmC,CAAC;AAE/F;;GAEG;AACH,MAAM,WAAW,MAAM;IACrB;;OAEG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IAEnB;;OAEG;IACH,QAAQ,CAAC,EAAE,SAAS,EAAE,CAAA;IAEtB;;;;;OAKG;IACH,cAAc,CAAC,EAAE,MAAM,EAAE,CAAC;CAC3B;AAED;;;;;GAKG;AACH,MAAM,WAAW,SAAU,SAAQ,IAAI;IAErC;;;;;;;;;OASG;IACH,KAAK,CAAC,CAAC,EAAE,QAAQ,EAAE,QAAQ,CAAC,CAAC,CAAC,GAAG,YAAY,CAAC,CAAC,CAAC,CAAC;IAEjD;;;;;;;;;OASG;IACH,OAAO,CAAC,CAAC,EAAE,QAAQ,EAAE,QAAQ,CAAC,CAAC,CAAC,GAAG,YAAY,CAAC,CAAC,CAAC,CAAC;IAEnD;;;;;;;OAOG;IACH,OAAO,CAAC,CAAC,EAAE,QAAQ,EAAE,QAAQ,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC;IAE3C;;;;;;;;;;;OAWG;IACH,IAAI,CAAC,CAAC,EAAE,QAAQ,EAAE,QAAQ,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,YAAY,CAAC,CAAC,CAAC,EAAE,YAAY,CAAC,EAAE,QAAQ,GAAG,SAAS,CAAC;CAC/F;AAED;;;;;GAKG;AACH,wBAAgB,KAAK,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,YAAY,CAAC,SAAS,CAAC,CAEtE"}
|
package/api/Contracts.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.guard = guard;
|
|
4
|
-
const
|
|
4
|
+
const Open_1 = require("@jonloucks/contracts-ts/api/Open");
|
|
5
5
|
const Types_1 = require("@jonloucks/contracts-ts/api/Types");
|
|
6
6
|
/**
|
|
7
7
|
* Type guard for Contracts
|
|
@@ -10,6 +10,6 @@ const Types_1 = require("@jonloucks/contracts-ts/api/Types");
|
|
|
10
10
|
* @return true if value is Contracts, false otherwise
|
|
11
11
|
*/
|
|
12
12
|
function guard(value) {
|
|
13
|
-
return (0, Types_1.
|
|
13
|
+
return (0, Types_1.guardFunctions)(value, 'claim', 'enforce', 'isBound', 'bind') && (0, Open_1.guard)(value);
|
|
14
14
|
}
|
|
15
15
|
//# sourceMappingURL=Contracts.js.map
|
package/api/Contracts.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Contracts.js","sourceRoot":"","sources":["../../src/api/Contracts.ts"],"names":[],"mappings":";;AA6FA,sBAEC;AA9FD,
|
|
1
|
+
{"version":3,"file":"Contracts.js","sourceRoot":"","sources":["../../src/api/Contracts.ts"],"names":[],"mappings":";;AA6FA,sBAEC;AA9FD,2DAA4E;AAI5E,6DAA+F;AAkF/F;;;;;GAKG;AACH,SAAgB,KAAK,CAAC,KAAc;IAClC,OAAO,IAAA,sBAAc,EAAC,KAAK,EAAE,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,CAAC,IAAI,IAAA,YAAS,EAAC,KAAK,CAAC,CAAC;AAC1F,CAAC"}
|