@jonloucks/contracts-ts 0.4.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 -3
- package/api/AutoClose.d.ts.map +1 -1
- package/api/AutoClose.js +17 -9
- package/api/AutoClose.js.map +1 -1
- package/api/AutoCloseFactory.d.ts +5 -3
- package/api/AutoCloseFactory.d.ts.map +1 -1
- package/api/AutoCloseFactory.js +14 -20
- package/api/AutoCloseFactory.js.map +1 -1
- package/api/AutoOpen.d.ts +3 -2
- package/api/AutoOpen.d.ts.map +1 -1
- package/api/AutoOpen.js +3 -3
- 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 +1 -1
- package/api/BindStrategy.d.ts.map +1 -1
- package/api/BindStrategy.js +2 -2
- package/api/BindStrategy.js.map +1 -1
- package/api/Contract.d.ts +21 -12
- package/api/Contract.d.ts.map +1 -1
- package/api/Contract.js +11 -0
- package/api/Contract.js.map +1 -1
- package/api/ContractException.d.ts +7 -0
- package/api/ContractException.d.ts.map +1 -1
- package/api/ContractException.js +11 -1
- package/api/ContractException.js.map +1 -1
- package/api/ContractFactory.d.ts +8 -1
- package/api/ContractFactory.d.ts.map +1 -1
- package/api/ContractFactory.js +11 -0
- package/api/ContractFactory.js.map +1 -1
- package/api/Contracts.d.ts +10 -3
- package/api/Contracts.d.ts.map +1 -1
- package/api/Contracts.js +12 -0
- package/api/Contracts.js.map +1 -1
- package/api/ContractsFactory.d.ts +8 -1
- package/api/ContractsFactory.d.ts.map +1 -1
- package/api/ContractsFactory.js +11 -0
- 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 -6
- package/api/Promisor.d.ts.map +1 -1
- package/api/Promisor.js +5 -27
- package/api/Promisor.js.map +1 -1
- package/api/PromisorFactory.d.ts +5 -3
- package/api/PromisorFactory.d.ts.map +1 -1
- package/api/PromisorFactory.js +14 -20
- 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 +8 -5
- package/api/Repository.d.ts.map +1 -1
- package/api/Repository.js +9 -20
- package/api/Repository.js.map +1 -1
- package/api/RepositoryFactory.d.ts +6 -4
- package/api/RepositoryFactory.d.ts.map +1 -1
- package/api/RepositoryFactory.js +13 -20
- 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 +6 -3
- package/auxiliary/AtomicBoolean.d.ts.map +1 -1
- package/auxiliary/AtomicBoolean.js +8 -20
- package/auxiliary/AtomicBoolean.js.map +1 -1
- package/auxiliary/AtomicBooleanFactory.d.ts +6 -4
- package/auxiliary/AtomicBooleanFactory.d.ts.map +1 -1
- package/auxiliary/AtomicBooleanFactory.js +13 -20
- package/auxiliary/AtomicBooleanFactory.js.map +1 -1
- package/auxiliary/AtomicInteger.d.ts +6 -3
- package/auxiliary/AtomicInteger.d.ts.map +1 -1
- package/auxiliary/AtomicInteger.js +8 -20
- package/auxiliary/AtomicInteger.js.map +1 -1
- package/auxiliary/AtomicIntegerFactory.d.ts +6 -4
- package/auxiliary/AtomicIntegerFactory.d.ts.map +1 -1
- package/auxiliary/AtomicIntegerFactory.js +13 -20
- package/auxiliary/AtomicIntegerFactory.js.map +1 -1
- package/auxiliary/AtomicReference.d.ts +6 -4
- package/auxiliary/AtomicReference.d.ts.map +1 -1
- package/auxiliary/AtomicReference.js +8 -20
- package/auxiliary/AtomicReference.js.map +1 -1
- package/auxiliary/AtomicReferenceFactory.d.ts +6 -4
- package/auxiliary/AtomicReferenceFactory.d.ts.map +1 -1
- package/auxiliary/AtomicReferenceFactory.js +13 -20
- 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 +3 -2
- package/version.d.ts.map +1 -1
- package/version.js +14 -8
- package/version.js.map +1 -1
- package/api/Lawyer.d.ts +0 -19
- 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
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ContractFactory.js","sourceRoot":"","sources":["../../src/api/ContractFactory.ts"],"names":[],"mappings":""}
|
|
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
|
|
@@ -76,4 +76,11 @@ export interface Contracts extends AutoOpen {
|
|
|
76
76
|
*/
|
|
77
77
|
bind<T>(contract: Contract<T>, promisor: PromisorType<T>, bindStrategy?: BindType): AutoClose;
|
|
78
78
|
}
|
|
79
|
+
/**
|
|
80
|
+
* Type guard for Contracts
|
|
81
|
+
*
|
|
82
|
+
* @param value the value to check
|
|
83
|
+
* @return true if value is Contracts, false otherwise
|
|
84
|
+
*/
|
|
85
|
+
export declare function guard(value: unknown): value is RequiredType<Contracts>;
|
|
79
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,3 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.guard = guard;
|
|
4
|
+
const Open_1 = require("@jonloucks/contracts-ts/api/Open");
|
|
5
|
+
const Types_1 = require("@jonloucks/contracts-ts/api/Types");
|
|
6
|
+
/**
|
|
7
|
+
* Type guard for Contracts
|
|
8
|
+
*
|
|
9
|
+
* @param value the value to check
|
|
10
|
+
* @return true if value is Contracts, false otherwise
|
|
11
|
+
*/
|
|
12
|
+
function guard(value) {
|
|
13
|
+
return (0, Types_1.guardFunctions)(value, 'claim', 'enforce', 'isBound', 'bind') && (0, Open_1.guard)(value);
|
|
14
|
+
}
|
|
3
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":""}
|
|
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"}
|
|
@@ -12,6 +12,13 @@ export interface ContractsFactory {
|
|
|
12
12
|
* @param config the Contracts configuration
|
|
13
13
|
* @return the new Contracts
|
|
14
14
|
*/
|
|
15
|
-
|
|
15
|
+
createContracts(config?: Config): RequiredType<Contracts>;
|
|
16
16
|
}
|
|
17
|
+
/**
|
|
18
|
+
* Type guard for ContractsFactory
|
|
19
|
+
*
|
|
20
|
+
* @param value the value to check
|
|
21
|
+
* @return true if value is ContractsFactory, false otherwise
|
|
22
|
+
*/
|
|
23
|
+
export declare function guard(value: unknown): value is RequiredType<ContractsFactory>;
|
|
17
24
|
//# sourceMappingURL=ContractsFactory.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ContractsFactory.d.ts","sourceRoot":"","sources":["../../src/api/ContractsFactory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,uCAAuC,CAAC;AAC1E,OAAO,
|
|
1
|
+
{"version":3,"file":"ContractsFactory.d.ts","sourceRoot":"","sources":["../../src/api/ContractsFactory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,uCAAuC,CAAC;AAC1E,OAAO,EAAkB,YAAY,EAAE,MAAM,mCAAmC,CAAC;AAEjF;;;GAGG;AACH,MAAM,WAAW,gBAAgB;IAE/B;;;;;;OAMG;IACH,eAAe,CAAC,MAAM,CAAC,EAAE,MAAM,GAAG,YAAY,CAAC,SAAS,CAAC,CAAC;CAC3D;AAED;;;;;GAKG;AACH,wBAAgB,KAAK,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,YAAY,CAAC,gBAAgB,CAAC,CAE7E"}
|
package/api/ContractsFactory.js
CHANGED
|
@@ -1,3 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.guard = guard;
|
|
4
|
+
const Types_1 = require("@jonloucks/contracts-ts/api/Types");
|
|
5
|
+
/**
|
|
6
|
+
* Type guard for ContractsFactory
|
|
7
|
+
*
|
|
8
|
+
* @param value the value to check
|
|
9
|
+
* @return true if value is ContractsFactory, false otherwise
|
|
10
|
+
*/
|
|
11
|
+
function guard(value) {
|
|
12
|
+
return (0, Types_1.guardFunctions)(value, 'createContracts');
|
|
13
|
+
}
|
|
3
14
|
//# sourceMappingURL=ContractsFactory.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ContractsFactory.js","sourceRoot":"","sources":["../../src/api/ContractsFactory.ts"],"names":[],"mappings":""}
|
|
1
|
+
{"version":3,"file":"ContractsFactory.js","sourceRoot":"","sources":["../../src/api/ContractsFactory.ts"],"names":[],"mappings":";;AAyBA,sBAEC;AA1BD,6DAAiF;AAkBjF;;;;;GAKG;AACH,SAAgB,KAAK,CAAC,KAAc;IAClC,OAAO,IAAA,sBAAc,EAAC,KAAK,EAAE,iBAAiB,CAAC,CAAC;AAClD,CAAC"}
|
package/api/Open.d.ts
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { AutoClose } from "./AutoClose";
|
|
2
|
+
import { RequiredType } from "./AutoCloseFactory";
|
|
3
|
+
/**
|
|
4
|
+
* Interface representing an entity that can be opened, returning an AutoClose mechanism.
|
|
5
|
+
*/
|
|
6
|
+
export interface Open {
|
|
7
|
+
/**
|
|
8
|
+
* Open this instance.
|
|
9
|
+
* @return the mechanism to close
|
|
10
|
+
*/
|
|
11
|
+
open(): AutoClose;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Duck-typing check for Open interface.
|
|
15
|
+
*
|
|
16
|
+
* @param value the value to check
|
|
17
|
+
* @returns true if the value implements Open, false otherwise
|
|
18
|
+
*/
|
|
19
|
+
export declare function guard(value: unknown): value is RequiredType<Open>;
|
|
20
|
+
//# sourceMappingURL=Open.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Open.d.ts","sourceRoot":"","sources":["../../src/api/Open.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAExC,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAElD;;GAEG;AACH,MAAM,WAAW,IAAI;IAEnB;;;OAGG;IACH,IAAI,IAAI,SAAS,CAAC;CACnB;AAED;;;;;GAKG;AACH,wBAAgB,KAAK,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,YAAY,CAAC,IAAI,CAAC,CAEjE"}
|
package/api/Open.js
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.guard = guard;
|
|
4
|
+
const Types_1 = require("./Types");
|
|
5
|
+
/**
|
|
6
|
+
* Duck-typing check for Open interface.
|
|
7
|
+
*
|
|
8
|
+
* @param value the value to check
|
|
9
|
+
* @returns true if the value implements Open, false otherwise
|
|
10
|
+
*/
|
|
11
|
+
function guard(value) {
|
|
12
|
+
return (0, Types_1.guardFunctions)(value, 'open');
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=Open.js.map
|
package/api/Open.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Open.js","sourceRoot":"","sources":["../../src/api/Open.ts"],"names":[],"mappings":";;AAsBA,sBAEC;AAvBD,mCAAyC;AAezC;;;;;GAKG;AACH,SAAgB,KAAK,CAAC,KAAc;IAClC,OAAO,IAAA,sBAAc,EAAC,KAAK,EAAE,MAAM,CAAC,CAAC;AACvC,CAAC"}
|
package/api/Promisor.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { Lawyer } from "@jonloucks/contracts-ts/api/Lawyer";
|
|
2
1
|
import { OptionalType, RequiredType } from "@jonloucks/contracts-ts/api/Types";
|
|
3
2
|
/**
|
|
4
3
|
* Interface for providing a deliverable for a Contract
|
|
@@ -34,11 +33,7 @@ export interface Promisor<T> {
|
|
|
34
33
|
* @param instance the instance to check
|
|
35
34
|
* @returns true if the instance is a Promisor, false otherwise
|
|
36
35
|
*/
|
|
37
|
-
export declare function
|
|
38
|
-
/**
|
|
39
|
-
* For creating a Contract for Promisor with duck-typing checks.
|
|
40
|
-
*/
|
|
41
|
-
export declare const LAWYER: Lawyer<Promisor<unknown>>;
|
|
36
|
+
export declare function guard<T>(instance: unknown): instance is RequiredType<Promisor<T>>;
|
|
42
37
|
/**
|
|
43
38
|
* A type that can be converted to a Promisor
|
|
44
39
|
*/
|
package/api/Promisor.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Promisor.d.ts","sourceRoot":"","sources":["../../src/api/Promisor.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Promisor.d.ts","sourceRoot":"","sources":["../../src/api/Promisor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,YAAY,EAA+C,MAAM,mCAAmC,CAAC;AAG5H;;;;;GAKG;AACH,MAAM,WAAW,QAAQ,CAAC,CAAC;IAEzB;;;OAGG;IACH,MAAM,IAAI,YAAY,CAAC,CAAC,CAAC,CAAC;IAE1B;;;;;;OAMG;IACH,cAAc,IAAI,MAAM,CAAC;IAEzB;;;;;;OAMG;IACH,cAAc,IAAI,MAAM,CAAC;CAC1B;AAED;;;;GAIG;AACH,wBAAgB,KAAK,CAAC,CAAC,EAAE,QAAQ,EAAE,OAAO,GAAG,QAAQ,IAAI,YAAY,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAEjF;AAED;;GAEG;AACH,MAAM,MAAM,YAAY,CAAC,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,GAAG,QAAQ,CAAC,CAAC,CAAC,GAAG,CAAC,MAAM,YAAY,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,MAAM,MAAM,CAAC,CAAC,GAAG,CAAC,GAAG,IAAI,GAAG,SAAS,CAAC;AAE7H;;;;;GAKG;AACH,wBAAgB,cAAc,CAAC,CAAC,EAAE,IAAI,EAAE,YAAY,CAAC,CAAC,CAAC,GAAG,YAAY,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAYlF;AA+BD;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAAC,CAAC,EAAE,QAAQ,EAAE,YAAY,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,GAAG,YAAY,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,CAQxG"}
|
package/api/Promisor.js
CHANGED
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
exports.isPromisor = isPromisor;
|
|
3
|
+
exports.guard = guard;
|
|
5
4
|
exports.typeToPromisor = typeToPromisor;
|
|
6
5
|
exports.unwrapPromisorType = unwrapPromisorType;
|
|
7
|
-
const RatifiedContract_1 = require("@jonloucks/contracts-ts/api/RatifiedContract");
|
|
8
6
|
const Types_1 = require("@jonloucks/contracts-ts/api/Types");
|
|
9
7
|
const Checks_1 = require("@jonloucks/contracts-ts/auxiliary/Checks");
|
|
10
8
|
/**
|
|
@@ -12,29 +10,9 @@ const Checks_1 = require("@jonloucks/contracts-ts/auxiliary/Checks");
|
|
|
12
10
|
* @param instance the instance to check
|
|
13
11
|
* @returns true if the instance is a Promisor, false otherwise
|
|
14
12
|
*/
|
|
15
|
-
function
|
|
16
|
-
return (0, Types_1.
|
|
13
|
+
function guard(instance) {
|
|
14
|
+
return (0, Types_1.guardFunctions)(instance, 'demand', 'incrementUsage', 'decrementUsage');
|
|
17
15
|
}
|
|
18
|
-
/**
|
|
19
|
-
* For creating a Contract for Promisor with duck-typing checks.
|
|
20
|
-
*/
|
|
21
|
-
exports.LAWYER = new class {
|
|
22
|
-
/**
|
|
23
|
-
* Lawyer.isDeliverable override
|
|
24
|
-
*/
|
|
25
|
-
isDeliverable(instance) {
|
|
26
|
-
return isPromisor(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 = "Promisor");
|
|
35
|
-
return (0, RatifiedContract_1.create)(copy);
|
|
36
|
-
}
|
|
37
|
-
};
|
|
38
16
|
/**
|
|
39
17
|
* Convert a PromisorType to a Promisor
|
|
40
18
|
*
|
|
@@ -45,10 +23,10 @@ function typeToPromisor(type) {
|
|
|
45
23
|
if ((0, Types_1.isNotPresent)(type)) {
|
|
46
24
|
return wrapPromisor(type, () => type); // supplier of null or undefined
|
|
47
25
|
}
|
|
48
|
-
else if ((0, Types_1.
|
|
26
|
+
else if ((0, Types_1.isConstructor)(type)) {
|
|
49
27
|
return wrapPromisor(type, () => new type()); // supplier of new instance
|
|
50
28
|
}
|
|
51
|
-
else if (
|
|
29
|
+
else if (guard(type)) {
|
|
52
30
|
return type; // already a Promisor
|
|
53
31
|
}
|
|
54
32
|
else if (typeof type === 'function') {
|
package/api/Promisor.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Promisor.js","sourceRoot":"","sources":["../../src/api/Promisor.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Promisor.js","sourceRoot":"","sources":["../../src/api/Promisor.ts"],"names":[],"mappings":";;AAyCA,sBAEC;AAaD,wCAYC;AAqCD,gDAQC;AAjHD,6DAA4H;AAC5H,qEAAwE;AAmCxE;;;;GAIG;AACH,SAAgB,KAAK,CAAI,QAAiB;IACxC,OAAO,IAAA,sBAAc,EAAC,QAAQ,EAAE,QAAQ,EAAE,gBAAgB,EAAE,gBAAgB,CAAC,CAAC;AAChF,CAAC;AAOD;;;;;GAKG;AACH,SAAgB,cAAc,CAAI,IAAqB;IACrD,IAAI,IAAA,oBAAY,EAAC,IAAI,CAAC,EAAE,CAAC;QACvB,OAAO,YAAY,CAAI,IAAI,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC,gCAAgC;IAC5E,CAAC;SAAM,IAAI,IAAA,qBAAa,EAAI,IAAI,CAAC,EAAE,CAAC;QAClC,OAAO,YAAY,CAAI,IAAI,EAAE,GAAG,EAAE,CAAC,IAAI,IAAI,EAAE,CAAC,CAAC,CAAC,2BAA2B;IAC7E,CAAC;SAAM,IAAI,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC;QACvB,OAAO,IAAI,CAAC,CAAC,qBAAqB;IACpC,CAAC;SAAM,IAAI,OAAO,IAAI,KAAK,UAAU,EAAE,CAAC;QACtC,OAAO,YAAY,CAAI,IAAI,EAAE,IAAe,CAAC,CAAC;IAChD,CAAC;SAAM,CAAC;QACN,OAAO,YAAY,CAAI,IAAI,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC,sDAAsD;IAClG,CAAC;AACH,CAAC;AAaD;;;;;;GAMG;AACH,SAAS,YAAY,CAAI,IAAqB,EAAE,MAA6B;IAC3E,MAAM,WAAW,GAAG,IAAA,qBAAY,EAAC,MAAM,EAAE,2CAA2C,CAAC,CAAC;IACtF,IAAI,UAAU,GAAW,CAAC,CAAC;IAC3B,OAAO;QACL,MAAM,EAAE,WAAW;QACnB,cAAc,EAAE,GAAG,EAAE,CAAC,EAAE,UAAU;QAClC,cAAc,EAAE,GAAG,EAAE,CAAC,EAAE,UAAU;QAClC,kBAAkB,EAAE,GAAG,EAAE,CAAC,IAAI;KAC/B,CAAC;AACJ,CAAC;AAED;;;;;GAKG;AACH,SAAgB,kBAAkB,CAAI,QAAmC;IACrE,IAAI,IAAA,oBAAY,EAAC,QAAQ,CAAC,EAAE,CAAC;QACzB,OAAO,QAAQ,CAAC;IACpB,CAAC;IACD,IAAI,oBAAoB,IAAI,QAAQ,IAAI,OAAO,QAAQ,CAAC,kBAAkB,KAAK,UAAU,EAAE,CAAC;QACxF,OAAO,QAAQ,CAAC,kBAAkB,EAAE,CAAC;IACzC,CAAC;IACD,OAAO,QAAQ,CAAA;AACnB,CAAC"}
|
package/api/PromisorFactory.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { Contract } from "@jonloucks/contracts-ts/api/Contract";
|
|
2
|
-
import { Lawyer } from "@jonloucks/contracts-ts/api/Lawyer";
|
|
3
2
|
import { Promisor, PromisorType } from "@jonloucks/contracts-ts/api/Promisor";
|
|
4
3
|
import { OptionalType, RequiredType, Transform } from "@jonloucks/contracts-ts/api/Types";
|
|
5
4
|
/**
|
|
@@ -46,9 +45,12 @@ export interface PromisorFactory {
|
|
|
46
45
|
createExtractor<T, R>(promisor: PromisorType<T>, extractor: Transform<T, R>): RequiredType<Promisor<R>>;
|
|
47
46
|
}
|
|
48
47
|
/**
|
|
49
|
-
*
|
|
48
|
+
* Type guard for PromisorFactory
|
|
49
|
+
*
|
|
50
|
+
* @param value the value to check
|
|
51
|
+
* @return true if value is PromisorFactory, false otherwise
|
|
50
52
|
*/
|
|
51
|
-
export declare
|
|
53
|
+
export declare function guard(instance: unknown): instance is RequiredType<PromisorFactory>;
|
|
52
54
|
/**
|
|
53
55
|
* The Contract for PromisorFactory implementation.
|
|
54
56
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PromisorFactory.d.ts","sourceRoot":"","sources":["../../src/api/PromisorFactory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,
|
|
1
|
+
{"version":3,"file":"PromisorFactory.d.ts","sourceRoot":"","sources":["../../src/api/PromisorFactory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,sCAAsC,CAAC;AAChE,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,sCAAsC,CAAC;AAE9E,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,SAAS,EAAkB,MAAM,mCAAmC,CAAC;AAE1G;;GAEG;AACH,MAAM,WAAW,eAAe;IAE9B;;;;;;OAMG;IACH,WAAW,CAAC,CAAC,EAAE,WAAW,EAAE,YAAY,CAAC,CAAC,CAAC,GAAG,YAAY,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC;IAExE;;;;;;;;OAQG;IACH,eAAe,CAAC,CAAC,EAAE,QAAQ,EAAE,YAAY,CAAC,CAAC,CAAC,GAAG,YAAY,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC;IAEzE;;;;;;;OAOG;IACH,eAAe,CAAC,CAAC,EAAE,QAAQ,EAAE,YAAY,CAAC,CAAC,CAAC,GAAG,YAAY,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC;IAEzE;;;;;;;;;OASG;IACH,eAAe,CAAC,CAAC,EAAE,CAAC,EAAE,QAAQ,EAAE,YAAY,CAAC,CAAC,CAAC,EAAE,SAAS,EAAE,SAAS,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,YAAY,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC;CACzG;AAED;;;;;GAKG;AACH,wBAAgB,KAAK,CAAC,QAAQ,EAAE,OAAO,GAAG,QAAQ,IAAI,YAAY,CAAC,eAAe,CAAC,CAElF;AAED;;GAEG;AACH,eAAO,MAAM,QAAQ,EAAE,QAAQ,CAAC,eAAe,CAI7C,CAAC"}
|
package/api/PromisorFactory.js
CHANGED
|
@@ -1,30 +1,24 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.CONTRACT =
|
|
3
|
+
exports.CONTRACT = void 0;
|
|
4
|
+
exports.guard = guard;
|
|
4
5
|
const RatifiedContract_1 = require("@jonloucks/contracts-ts/api/RatifiedContract");
|
|
5
6
|
const Types_1 = require("@jonloucks/contracts-ts/api/Types");
|
|
6
7
|
/**
|
|
7
|
-
*
|
|
8
|
+
* Type guard for PromisorFactory
|
|
9
|
+
*
|
|
10
|
+
* @param value the value to check
|
|
11
|
+
* @return true if value is PromisorFactory, false otherwise
|
|
8
12
|
*/
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
*/
|
|
13
|
-
isDeliverable(instance) {
|
|
14
|
-
return (0, Types_1.hasFunctions)(instance, 'createExtractor', 'createLifeCycle', 'createSingleton', 'createValue');
|
|
15
|
-
}
|
|
16
|
-
/**
|
|
17
|
-
* Lawyer.createContract override
|
|
18
|
-
*/
|
|
19
|
-
createContract(config) {
|
|
20
|
-
const copy = { ...config ?? {} };
|
|
21
|
-
copy.test ?? (copy.test = this.isDeliverable);
|
|
22
|
-
copy.typeName ?? (copy.typeName = "PromisorFactory");
|
|
23
|
-
return (0, RatifiedContract_1.create)(copy);
|
|
24
|
-
}
|
|
25
|
-
};
|
|
13
|
+
function guard(instance) {
|
|
14
|
+
return (0, Types_1.guardFunctions)(instance, 'createExtractor', 'createLifeCycle', 'createSingleton', 'createValue');
|
|
15
|
+
}
|
|
26
16
|
/**
|
|
27
17
|
* The Contract for PromisorFactory implementation.
|
|
28
18
|
*/
|
|
29
|
-
exports.CONTRACT =
|
|
19
|
+
exports.CONTRACT = (0, RatifiedContract_1.create)({
|
|
20
|
+
test: guard,
|
|
21
|
+
name: "PromisorFactory",
|
|
22
|
+
typeName: "PromisorFactory"
|
|
23
|
+
});
|
|
30
24
|
//# sourceMappingURL=PromisorFactory.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PromisorFactory.js","sourceRoot":"","sources":["../../src/api/PromisorFactory.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"PromisorFactory.js","sourceRoot":"","sources":["../../src/api/PromisorFactory.ts"],"names":[],"mappings":";;;AA2DA,sBAEC;AA3DD,mFAAwF;AACxF,6DAA0G;AAkD1G;;;;;GAKG;AACH,SAAgB,KAAK,CAAC,QAAiB;IACrC,OAAO,IAAA,sBAAc,EAAC,QAAQ,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,aAAa,CAAC,CAAC;AAC1G,CAAC;AAED;;GAEG;AACU,QAAA,QAAQ,GAA8B,IAAA,yBAAc,EAAC;IAChE,IAAI,EAAE,KAAK;IACX,IAAI,EAAE,iBAAiB;IACvB,QAAQ,EAAE,iBAAiB;CAC5B,CAAC,CAAC"}
|
|
@@ -10,7 +10,7 @@ import { OptionalType, RequiredType } from "@jonloucks/contracts-ts/api/Types";
|
|
|
10
10
|
* @param config the configuration for the RatifiedContract
|
|
11
11
|
* @returns the created RatifiedContract
|
|
12
12
|
*/
|
|
13
|
-
export declare function create<T>(config?: Config<T> |
|
|
13
|
+
export declare function create<T>(config?: Config<T> | undefined): Contract<T>;
|
|
14
14
|
/**
|
|
15
15
|
* Checks if the given instance is a RatifiedContract.
|
|
16
16
|
* @param instance the instance to check
|
|
@@ -39,7 +39,7 @@ declare class RatifiedContract<T> extends BasicContract<T> {
|
|
|
39
39
|
* @param <T> the type of deliverable for this Contract
|
|
40
40
|
* @return the new Contract
|
|
41
41
|
*/
|
|
42
|
-
static create<T>(config?: Config<T> |
|
|
42
|
+
static create<T>(config?: Config<T> | undefined): Contract<T>;
|
|
43
43
|
static isRatifiedContract(instance: unknown): instance is RatifiedContract<unknown>;
|
|
44
44
|
/**
|
|
45
45
|
* Being a RatifiedContract means something special. It is not something that you proclaim
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RatifiedContract.d.ts","sourceRoot":"","sources":["../../src/api/RatifiedContract.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,2CAA2C,CAAC;AAC1E,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,sCAAsC,CAAC;AAExE,OAAO,EAAE,YAAY,EAAE,YAAY,EAA2B,MAAM,mCAAmC,CAAC;AAExG;;;;;;;;GAQG;AACH,wBAAgB,MAAM,CAAC,CAAC,EAAE,MAAM,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC,GAAG,
|
|
1
|
+
{"version":3,"file":"RatifiedContract.d.ts","sourceRoot":"","sources":["../../src/api/RatifiedContract.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,2CAA2C,CAAC;AAC1E,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,sCAAsC,CAAC;AAExE,OAAO,EAAE,YAAY,EAAE,YAAY,EAA2B,MAAM,mCAAmC,CAAC;AAExG;;;;;;;;GAQG;AACH,wBAAgB,MAAM,CAAC,CAAC,EAAE,MAAM,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC,GAAG,SAAS,GAAG,QAAQ,CAAC,CAAC,CAAC,CAErE;AAED;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,QAAQ,EAAE,OAAO,GAAG,QAAQ,IAAI,gBAAgB,CAAC,OAAO,CAAC,CAE3F;AAED;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAAC,CAAC,EAAE,MAAM,CAAC,EAAE,YAAY,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,GAAG,MAAM,IAAI,YAAY,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAEzG;AAED;;;;;GAKG;AACH,cAAM,gBAAgB,CAAC,CAAC,CAAE,SAAQ,aAAa,CAAC,CAAC,CAAC;;IAEhD;;;;;;QAMI;IACJ,MAAM,CAAC,MAAM,CAAC,CAAC,EAAE,MAAM,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC,GAAG,SAAS,GAAG,QAAQ,CAAC,CAAC,CAAC;IAI7D,MAAM,CAAC,kBAAkB,CAAC,QAAQ,EAAE,OAAO,GAAG,QAAQ,IAAI,gBAAgB,CAAC,OAAO,CAAC;IAYnF;;;;;;;;;OASG;IACH,OAAO,CAAC,cAAc;IAMtB,OAAO;IAMP,OAAO,CAAC,MAAM,CAAC,cAAc;CAS9B"}
|
package/api/RatifiedContract.js
CHANGED
|
@@ -39,10 +39,7 @@ function isRatifiedContract(instance) {
|
|
|
39
39
|
* @returns true if the configuration is ratifiable, false otherwise
|
|
40
40
|
*/
|
|
41
41
|
function isRatifiableConfig(config) {
|
|
42
|
-
|
|
43
|
-
return false;
|
|
44
|
-
}
|
|
45
|
-
return (0, Types_1.isPresent)(config.test) || (0, Types_1.isPresent)(config.cast);
|
|
42
|
+
return (0, Types_1.isPresent)(config) && (0, Types_1.isPresent)(config.test);
|
|
46
43
|
}
|
|
47
44
|
/**
|
|
48
45
|
* A RatifiedContract is a Contract that has been verified to have either a test or cast function.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RatifiedContract.js","sourceRoot":"","sources":["../../src/api/RatifiedContract.ts"],"names":[],"mappings":";;;;;;;;AAcA,wBAEC;AAOD,gDAEC;AAQD,
|
|
1
|
+
{"version":3,"file":"RatifiedContract.js","sourceRoot":"","sources":["../../src/api/RatifiedContract.ts"],"names":[],"mappings":";;;;;;;;AAcA,wBAEC;AAOD,gDAEC;AAQD,gDAEC;AAnCD,6EAA0E;AAE1E,qFAAkF;AAClF,6DAAwG;AAExG;;;;;;;;GAQG;AACH,SAAgB,MAAM,CAAI,MAA8B;IACtD,OAAO,gBAAgB,CAAC,MAAM,CAAI,MAAM,CAAC,CAAC;AAC5C,CAAC;AAED;;;;GAIG;AACH,SAAgB,kBAAkB,CAAC,QAAiB;IAClD,OAAO,gBAAgB,CAAC,kBAAkB,CAAC,QAAQ,CAAC,CAAC;AACvD,CAAC;AAED;;;;;GAKG;AACH,SAAgB,kBAAkB,CAAI,MAAgC;IACpE,OAAO,IAAA,iBAAS,EAAC,MAAM,CAAC,IAAI,IAAA,iBAAS,EAAC,MAAM,CAAC,IAAI,CAAC,CAAC;AACrD,CAAC;AAED;;;;;GAKG;AACH,MAAM,gBAAoB,SAAQ,6BAAgB;IAEhD;;;;;;QAMI;IACJ,MAAM,CAAC,MAAM,CAAI,MAA8B;QAC7C,OAAO,IAAI,EAAgB,CAAI,MAAM,CAAC,CAAC;IACzC,CAAC;IAED,MAAM,CAAC,kBAAkB,CAAC,QAAiB;QACzC,IAAI,IAAA,oBAAY,EAAC,QAAQ,CAAC,EAAE,CAAC;YAC3B,OAAO,KAAK,CAAC;QACf,CAAC;QACD,IAAI,CAAC;YACH,MAAM,SAAS,GAAG,QAAqC,CAAC;YACxD,OAAO,uBAAA,SAAS,gCAAQ,KAAK,uBAAA,EAAgB,oCAAQ,CAAC;QACxD,CAAC;QAAC,MAAM,CAAC;YACP,OAAO,KAAK,CAAC;QACf,CAAC;IACH,CAAC;IAED;;;;;;;;;OASG;IACK,cAAc;QACpB,IAAI,uBAAA,IAAI,gCAAQ,KAAK,uBAAA,EAAgB,oCAAQ,EAAE,CAAC;YAC9C,MAAM,IAAI,qCAAiB,CAAC,sDAAsD,CAAC,CAAC;QACtF,CAAC;IACH,CAAC;IAED,YAAoB,MAAgC;QAClD,KAAK,CAAC,EAAgB,CAAC,cAAc,CAAC,MAAM,CAAC,CAAC,CAAC;QAaxC,mCAAkB,uBAAA,EAAgB,oCAAQ,EAAC;QAZlD,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;QACpB,IAAI,CAAC,cAAc,EAAE,CAAC;IACxB,CAAC;IAEO,MAAM,CAAC,cAAc,CAAI,MAAgC;QAC/D,IAAI,kBAAkB,CAAC,MAAM,CAAC,EAAE,CAAC;YAC/B,OAAO,MAAiC,CAAC;QAC3C,CAAC;QACD,MAAM,IAAI,qCAAiB,CAAC,2EAA2E,CAAC,CAAC;IAC3G,CAAC;;;AAEe,oCAAkB,MAAM,CAAC,UAAU,CAAC,EAA7B,CAA8B"}
|
package/api/Repository.d.ts
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import { AutoClose } from "@jonloucks/contracts-ts/api/AutoClose";
|
|
2
|
-
import {
|
|
2
|
+
import { Open } from "@jonloucks/contracts-ts/api/Open";
|
|
3
3
|
import { BindStrategy } from "@jonloucks/contracts-ts/api/BindStrategy";
|
|
4
4
|
import { Contract } from "@jonloucks/contracts-ts/api/Contract";
|
|
5
|
-
import { Lawyer } from "@jonloucks/contracts-ts/api/Lawyer";
|
|
6
5
|
import { PromisorType } from "@jonloucks/contracts-ts/api/Promisor";
|
|
6
|
+
import { RequiredType } from "@jonloucks/contracts-ts/api/Types";
|
|
7
7
|
/**
|
|
8
8
|
* A repository for multiple contract promisors
|
|
9
9
|
* This is an opt-in feature to simplify the managing of many contract bindings.
|
|
10
10
|
* 1. Optional feature to register required contracts.
|
|
11
11
|
* 2. Optional feature to manage multiple contract bindings.
|
|
12
12
|
*/
|
|
13
|
-
export interface Repository extends
|
|
13
|
+
export interface Repository extends Open {
|
|
14
14
|
/**
|
|
15
15
|
* Store the binding.
|
|
16
16
|
* Note: Replacing a Contract already promised in this Repository is forbidden after the Repository is opened.
|
|
@@ -49,7 +49,10 @@ export interface Repository extends AutoOpen {
|
|
|
49
49
|
require<T>(contract: Contract<T>): void;
|
|
50
50
|
}
|
|
51
51
|
/**
|
|
52
|
-
*
|
|
52
|
+
* Type guard for Repository
|
|
53
|
+
*
|
|
54
|
+
* @param value the value to check
|
|
55
|
+
* @return true if value is Repository, false otherwise
|
|
53
56
|
*/
|
|
54
|
-
export declare
|
|
57
|
+
export declare function guard(value: unknown): value is RequiredType<Repository>;
|
|
55
58
|
//# sourceMappingURL=Repository.d.ts.map
|
package/api/Repository.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Repository.d.ts","sourceRoot":"","sources":["../../src/api/Repository.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,uCAAuC,CAAC;AAClE,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"Repository.d.ts","sourceRoot":"","sources":["../../src/api/Repository.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,uCAAuC,CAAC;AAClE,OAAO,EAAE,IAAI,EAAsB,MAAM,kCAAkC,CAAC;AAC5E,OAAO,EAAE,YAAY,EAAE,MAAM,0CAA0C,CAAC;AACxE,OAAO,EAAE,QAAQ,EAAE,MAAM,sCAAsC,CAAC;AAChE,OAAO,EAAE,YAAY,EAAE,MAAM,sCAAsC,CAAC;AACpE,OAAO,EAAkB,YAAY,EAAE,MAAM,mCAAmC,CAAC;AAEjF;;;;;GAKG;AACH,MAAM,WAAW,UAAW,SAAQ,IAAI;IAEtC;;;;;;;;;;;;OAYG;IACH,KAAK,CAAC,CAAC,EAAE,QAAQ,EAAE,QAAQ,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,YAAY,CAAC,CAAC,CAAC,EAAE,YAAY,CAAC,EAAE,YAAY,GAAG,SAAS,CAAA;IAElG;;;;;;;;;;OAUG;IACH,IAAI,CAAC,CAAC,EAAE,QAAQ,EAAE,QAAQ,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,YAAY,CAAC,CAAC,CAAC,EAAE,YAAY,CAAC,EAAE,YAAY,GAAG,IAAI,CAAC;IAE7F;;OAEG;IACH,KAAK,IAAI,IAAI,CAAC;IAEd;;;;OAIG;IACH,OAAO,CAAC,CAAC,EAAE,QAAQ,EAAE,QAAQ,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC;CACzC;AAED;;;;;GAKG;AACH,wBAAgB,KAAK,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,YAAY,CAAC,UAAU,CAAC,CAEvE"}
|
package/api/Repository.js
CHANGED
|
@@ -1,26 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
const
|
|
3
|
+
exports.guard = guard;
|
|
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 Repository
|
|
8
|
+
*
|
|
9
|
+
* @param value the value to check
|
|
10
|
+
* @return true if value is Repository, false otherwise
|
|
8
11
|
*/
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
*/
|
|
13
|
-
isDeliverable(instance) {
|
|
14
|
-
return (0, Types_1.hasFunctions)(instance, 'store', 'keep', 'check', 'require', 'open');
|
|
15
|
-
}
|
|
16
|
-
/**
|
|
17
|
-
* Lawyer.createContract override
|
|
18
|
-
*/
|
|
19
|
-
createContract(config) {
|
|
20
|
-
const copy = { ...config };
|
|
21
|
-
copy.typeName ?? (copy.typeName = "Repository");
|
|
22
|
-
copy.test ?? (copy.test = this.isDeliverable);
|
|
23
|
-
return (0, RatifiedContract_1.create)(copy);
|
|
24
|
-
}
|
|
25
|
-
};
|
|
12
|
+
function guard(value) {
|
|
13
|
+
return (0, Types_1.guardFunctions)(value, 'store', 'keep', 'check', 'require') && (0, Open_1.guard)(value);
|
|
14
|
+
}
|
|
26
15
|
//# sourceMappingURL=Repository.js.map
|
package/api/Repository.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Repository.js","sourceRoot":"","sources":["../../src/api/Repository.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Repository.js","sourceRoot":"","sources":["../../src/api/Repository.ts"],"names":[],"mappings":";;AA8DA,sBAEC;AA/DD,2DAA4E;AAI5E,6DAAiF;AAmDjF;;;;;GAKG;AACH,SAAgB,KAAK,CAAC,KAAc;IAClC,OAAO,IAAA,sBAAc,EAAC,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,SAAS,CAAC,IAAI,IAAA,YAAS,EAAC,KAAK,CAAC,CAAC;AACxF,CAAC"}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { Contract } from "@jonloucks/contracts-ts/api/Contract";
|
|
2
|
-
import { Lawyer } from "@jonloucks/contracts-ts/api/Lawyer";
|
|
3
2
|
import { Repository } from "@jonloucks/contracts-ts/api/Repository";
|
|
4
3
|
import { RequiredType } from "@jonloucks/contracts-ts/api/Types";
|
|
5
4
|
/**
|
|
@@ -9,12 +8,15 @@ export interface RepositoryFactory {
|
|
|
9
8
|
/**
|
|
10
9
|
* Create a new Repository instance.
|
|
11
10
|
*/
|
|
12
|
-
|
|
11
|
+
createRepository(): RequiredType<Repository>;
|
|
13
12
|
}
|
|
14
13
|
/**
|
|
15
|
-
*
|
|
14
|
+
* Type guard for RepositoryFactory
|
|
15
|
+
*
|
|
16
|
+
* @param value the value to check
|
|
17
|
+
* @return true if value is RepositoryFactory, false otherwise
|
|
16
18
|
*/
|
|
17
|
-
export declare
|
|
19
|
+
export declare function guard(value: unknown): value is RequiredType<RepositoryFactory>;
|
|
18
20
|
/**
|
|
19
21
|
* The factory Contract for creating new Repository instances.
|
|
20
22
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RepositoryFactory.d.ts","sourceRoot":"","sources":["../../src/api/RepositoryFactory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,
|
|
1
|
+
{"version":3,"file":"RepositoryFactory.d.ts","sourceRoot":"","sources":["../../src/api/RepositoryFactory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,sCAAsC,CAAC;AAEhE,OAAO,EAAE,UAAU,EAAE,MAAM,wCAAwC,CAAC;AACpE,OAAO,EAAE,YAAY,EAAkB,MAAM,mCAAmC,CAAC;AAEjF;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAEhC;;OAEG;IACH,gBAAgB,IAAI,YAAY,CAAC,UAAU,CAAC,CAAC;CAC9C;AAED;;;;;GAKG;AACH,wBAAgB,KAAK,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,YAAY,CAAC,iBAAiB,CAAC,CAE9E;AAED;;GAEG;AACH,eAAO,MAAM,QAAQ,EAAE,QAAQ,CAAC,YAAY,CAAC,iBAAiB,CAAC,CAG7D,CAAC"}
|
package/api/RepositoryFactory.js
CHANGED
|
@@ -1,30 +1,23 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.CONTRACT =
|
|
3
|
+
exports.CONTRACT = void 0;
|
|
4
|
+
exports.guard = guard;
|
|
4
5
|
const RatifiedContract_1 = require("@jonloucks/contracts-ts/api/RatifiedContract");
|
|
5
6
|
const Types_1 = require("@jonloucks/contracts-ts/api/Types");
|
|
6
7
|
/**
|
|
7
|
-
*
|
|
8
|
+
* Type guard for RepositoryFactory
|
|
9
|
+
*
|
|
10
|
+
* @param value the value to check
|
|
11
|
+
* @return true if value is RepositoryFactory, false otherwise
|
|
8
12
|
*/
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
*/
|
|
13
|
-
isDeliverable(instance) {
|
|
14
|
-
return (0, Types_1.hasFunctions)(instance, "create");
|
|
15
|
-
}
|
|
16
|
-
/**
|
|
17
|
-
* Lawyer.createContract override
|
|
18
|
-
*/
|
|
19
|
-
createContract(config) {
|
|
20
|
-
const copy = { ...config ?? {} };
|
|
21
|
-
copy.test ?? (copy.test = this.isDeliverable);
|
|
22
|
-
copy.typeName ?? (copy.typeName = "RepositoryFactory");
|
|
23
|
-
return (0, RatifiedContract_1.create)(copy);
|
|
24
|
-
}
|
|
25
|
-
};
|
|
13
|
+
function guard(value) {
|
|
14
|
+
return (0, Types_1.guardFunctions)(value, "createRepository");
|
|
15
|
+
}
|
|
26
16
|
/**
|
|
27
17
|
* The factory Contract for creating new Repository instances.
|
|
28
18
|
*/
|
|
29
|
-
exports.CONTRACT =
|
|
19
|
+
exports.CONTRACT = (0, RatifiedContract_1.create)({
|
|
20
|
+
test: guard,
|
|
21
|
+
name: "RepositoryFactory"
|
|
22
|
+
});
|
|
30
23
|
//# sourceMappingURL=RepositoryFactory.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RepositoryFactory.js","sourceRoot":"","sources":["../../src/api/RepositoryFactory.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"RepositoryFactory.js","sourceRoot":"","sources":["../../src/api/RepositoryFactory.ts"],"names":[],"mappings":";;;AAsBA,sBAEC;AAvBD,mFAAwF;AAExF,6DAAiF;AAajF;;;;;GAKG;AACH,SAAgB,KAAK,CAAC,KAAc;IAClC,OAAO,IAAA,sBAAc,EAAC,KAAK,EAAE,kBAAkB,CAAC,CAAC;AACnD,CAAC;AAED;;GAEG;AACU,QAAA,QAAQ,GAA8C,IAAA,yBAAc,EAAC;IAChF,IAAI,EAAE,KAAK;IACX,IAAI,EAAE,mBAAmB;CAC1B,CAAC,CAAC"}
|