@jonloucks/contracts-ts 1.4.0 → 2.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/README.md +69 -21
- package/api/AutoClose.d.ts +2 -2
- package/api/AutoClose.d.ts.map +1 -1
- package/api/AutoClose.js +15 -23
- package/api/AutoClose.js.map +1 -1
- package/api/AutoCloseFactory.d.ts +3 -3
- package/api/AutoCloseFactory.d.ts.map +1 -1
- package/api/AutoCloseFactory.js +5 -9
- package/api/AutoCloseFactory.js.map +1 -1
- package/api/AutoOpen.js +3 -6
- package/api/AutoOpen.js.map +1 -1
- package/api/BasicContract.js +6 -11
- package/api/BasicContract.js.map +1 -1
- package/api/BindStrategy.js +4 -9
- package/api/BindStrategy.js.map +1 -1
- package/api/Contract.js +3 -6
- package/api/Contract.js.map +1 -1
- package/api/ContractException.js +5 -10
- package/api/ContractException.js.map +1 -1
- package/api/ContractFactory.js +3 -6
- package/api/ContractFactory.js.map +1 -1
- package/api/Contracts.d.ts +1 -1
- package/api/Contracts.d.ts.map +1 -1
- package/api/Contracts.js +4 -7
- package/api/Contracts.js.map +1 -1
- package/api/ContractsFactory.js +3 -6
- package/api/ContractsFactory.js.map +1 -1
- package/api/Convenience.d.ts +21 -16
- package/api/Convenience.d.ts.map +1 -1
- package/api/Convenience.js +17 -35
- package/api/Convenience.js.map +1 -1
- package/api/Open.d.ts.map +1 -1
- package/api/Open.js +9 -13
- package/api/Open.js.map +1 -1
- package/api/Promisor.d.ts +9 -5
- package/api/Promisor.d.ts.map +1 -1
- package/api/Promisor.js +18 -23
- package/api/Promisor.js.map +1 -1
- package/api/PromisorFactory.d.ts +3 -2
- package/api/PromisorFactory.d.ts.map +1 -1
- package/api/PromisorFactory.js +5 -9
- package/api/PromisorFactory.js.map +1 -1
- package/api/RatifiedContract.js +11 -16
- package/api/RatifiedContract.js.map +1 -1
- package/api/Repository.d.ts +2 -2
- package/api/Repository.d.ts.map +1 -1
- package/api/Repository.js +4 -7
- package/api/Repository.js.map +1 -1
- package/api/RepositoryFactory.js +5 -9
- package/api/RepositoryFactory.js.map +1 -1
- package/api/Types.d.ts +0 -24
- package/api/Types.d.ts.map +1 -1
- package/api/Types.js +13 -62
- package/api/Types.js.map +1 -1
- package/auxiliary/AtomicBoolean.js +3 -6
- package/auxiliary/AtomicBoolean.js.map +1 -1
- package/auxiliary/AtomicBooleanFactory.js +5 -9
- package/auxiliary/AtomicBooleanFactory.js.map +1 -1
- package/auxiliary/AtomicInteger.js +3 -6
- package/auxiliary/AtomicInteger.js.map +1 -1
- package/auxiliary/AtomicIntegerFactory.js +5 -9
- package/auxiliary/AtomicIntegerFactory.js.map +1 -1
- package/auxiliary/AtomicReference.js +3 -6
- package/auxiliary/AtomicReference.js.map +1 -1
- package/auxiliary/AtomicReferenceFactory.js +5 -9
- package/auxiliary/AtomicReferenceFactory.js.map +1 -1
- package/auxiliary/Checks.js +23 -36
- package/auxiliary/Checks.js.map +1 -1
- package/auxiliary/Consumer.js +7 -12
- package/auxiliary/Consumer.js.map +1 -1
- package/auxiliary/Convenience.d.ts +10 -6
- package/auxiliary/Convenience.d.ts.map +1 -1
- package/auxiliary/Convenience.js +17 -19
- package/auxiliary/Convenience.js.map +1 -1
- package/auxiliary/IdempotenState.d.ts +1 -1
- package/auxiliary/IdempotenState.d.ts.map +1 -1
- package/auxiliary/IdempotenState.js +2 -5
- package/auxiliary/IdempotenState.js.map +1 -1
- package/auxiliary/Idempotent.js +3 -6
- package/auxiliary/Idempotent.js.map +1 -1
- package/auxiliary/IdempotentFactory.js +5 -9
- package/auxiliary/IdempotentFactory.js.map +1 -1
- package/auxiliary/IllegalArgumentException.js +4 -8
- package/auxiliary/IllegalArgumentException.js.map +1 -1
- package/auxiliary/IllegalStateException.js +4 -8
- package/auxiliary/IllegalStateException.js.map +1 -1
- package/auxiliary/Predicate.js +9 -15
- package/auxiliary/Predicate.js.map +1 -1
- package/auxiliary/Supplier.js +10 -16
- package/auxiliary/Supplier.js.map +1 -1
- package/auxiliary/Transform.js +11 -18
- package/auxiliary/Transform.js.map +1 -1
- package/auxiliary/Validate.js +12 -15
- package/auxiliary/Validate.js.map +1 -1
- package/impl/AtomicBoolean.impl.js +1 -4
- package/impl/AtomicBoolean.impl.js.map +1 -1
- package/impl/AtomicBooleanFactory.impl.js +3 -6
- package/impl/AtomicBooleanFactory.impl.js.map +1 -1
- package/impl/AtomicInteger.impl.js +1 -4
- package/impl/AtomicInteger.impl.js.map +1 -1
- package/impl/AtomicIntegerFactory.impl.js +3 -6
- package/impl/AtomicIntegerFactory.impl.js.map +1 -1
- package/impl/AtomicReference.impl.js +2 -7
- package/impl/AtomicReference.impl.js.map +1 -1
- package/impl/AtomicReferenceFactory.impl.js +3 -6
- package/impl/AtomicReferenceFactory.impl.js.map +1 -1
- package/impl/AutoCloseFactory.impl.d.ts +0 -3
- package/impl/AutoCloseFactory.impl.d.ts.map +1 -1
- package/impl/AutoCloseFactory.impl.js +7 -10
- package/impl/AutoCloseFactory.impl.js.map +1 -1
- package/impl/AutoCloseMany.impl.d.ts +0 -2
- package/impl/AutoCloseMany.impl.d.ts.map +1 -1
- package/impl/AutoCloseMany.impl.js +5 -8
- package/impl/AutoCloseMany.impl.js.map +1 -1
- package/impl/AutoCloseOne.impl.d.ts.map +1 -1
- package/impl/AutoCloseOne.impl.js +8 -11
- package/impl/AutoCloseOne.impl.js.map +1 -1
- package/impl/ContractFactory.impl.js +7 -11
- package/impl/ContractFactory.impl.js.map +1 -1
- package/impl/Contracts.impl.d.ts.map +1 -1
- package/impl/Contracts.impl.js +38 -41
- package/impl/Contracts.impl.js.map +1 -1
- package/impl/ContractsFactory.impl.js +28 -32
- package/impl/ContractsFactory.impl.js.map +1 -1
- package/impl/ContractsWrapper.impl.js +3 -6
- package/impl/ContractsWrapper.impl.js.map +1 -1
- package/impl/Events.d.ts +1 -2
- package/impl/Events.d.ts.map +1 -1
- package/impl/Events.impl.d.ts +1 -2
- package/impl/Events.impl.d.ts.map +1 -1
- package/impl/Events.impl.js +6 -9
- package/impl/Events.impl.js.map +1 -1
- package/impl/Events.js +1 -2
- package/impl/Events.js.map +1 -1
- package/impl/ExtractorPromisor.impl.d.ts +2 -1
- package/impl/ExtractorPromisor.impl.d.ts.map +1 -1
- package/impl/ExtractorPromisor.impl.js +6 -9
- package/impl/ExtractorPromisor.impl.js.map +1 -1
- package/impl/Idempotent.impl.js +10 -13
- package/impl/Idempotent.impl.js.map +1 -1
- package/impl/IdempotentFactory.impl.js +5 -8
- package/impl/IdempotentFactory.impl.js.map +1 -1
- package/impl/Internal.impl.js +5 -8
- package/impl/Internal.impl.js.map +1 -1
- package/impl/LifeCyclePromisor.impl.js +19 -22
- package/impl/LifeCyclePromisor.impl.js.map +1 -1
- package/impl/Policy.d.ts +0 -1
- package/impl/Policy.d.ts.map +1 -1
- package/impl/Policy.impl.d.ts +1 -3
- package/impl/Policy.impl.d.ts.map +1 -1
- package/impl/Policy.impl.js +7 -10
- package/impl/Policy.impl.js.map +1 -1
- package/impl/Policy.js +1 -2
- package/impl/PromisorFactory.impl.d.ts.map +1 -1
- package/impl/PromisorFactory.impl.js +11 -14
- package/impl/PromisorFactory.impl.js.map +1 -1
- package/impl/Repository.impl.d.ts.map +1 -1
- package/impl/Repository.impl.js +19 -22
- package/impl/Repository.impl.js.map +1 -1
- package/impl/RepositoryFactory.impl.js +3 -6
- package/impl/RepositoryFactory.impl.js.map +1 -1
- package/impl/SingletonPromisor.impl.js +7 -10
- package/impl/SingletonPromisor.impl.js.map +1 -1
- package/impl/Storage.impl.js +3 -7
- package/impl/Storage.impl.js.map +1 -1
- package/impl/ValuePromisor.impl.js +1 -4
- package/impl/ValuePromisor.impl.js.map +1 -1
- package/index.d.ts +8 -20
- package/index.d.ts.map +1 -1
- package/index.js +10 -38
- package/index.js.map +1 -1
- package/package.json +9 -11
- package/version.js +2 -5
- package/version.js.map +1 -1
- package/auxiliary/Functional.d.ts +0 -9
- package/auxiliary/Functional.d.ts.map +0 -1
- package/auxiliary/Functional.js +0 -23
- package/auxiliary/Functional.js.map +0 -1
package/README.md
CHANGED
|
@@ -10,7 +10,8 @@
|
|
|
10
10
|
Typescript Dependency Contracts for dependency inversion
|
|
11
11
|
|
|
12
12
|
## Documentation
|
|
13
|
-
* [
|
|
13
|
+
* [Project documentation](DOCUMENTATION.md)
|
|
14
|
+
* [License](LICENSE)
|
|
14
15
|
* [Contributing](CONTRIBUTING.md)
|
|
15
16
|
* [Code of conduct](CODE_OF_CONDUCT.md)
|
|
16
17
|
* [Coding standards](CODING_STANDARDS.md)
|
|
@@ -25,6 +26,65 @@ Typescript Dependency Contracts for dependency inversion
|
|
|
25
26
|
npm install @jonloucks/contracts-ts
|
|
26
27
|
```
|
|
27
28
|
|
|
29
|
+
## v2.0.0 Migration Notes
|
|
30
|
+
|
|
31
|
+
v2.0.0 introduces a smaller root export surface, removes deprecated APIs, and finalizes ESM packaging.
|
|
32
|
+
|
|
33
|
+
<details markdown="1"><summary>Root package imports are intentionally minimal</summary>
|
|
34
|
+
|
|
35
|
+
Use root imports only for core exports:
|
|
36
|
+
|
|
37
|
+
```typescript
|
|
38
|
+
import {
|
|
39
|
+
CONTRACTS,
|
|
40
|
+
Contract,
|
|
41
|
+
ContractConfig,
|
|
42
|
+
ContractException,
|
|
43
|
+
Contracts,
|
|
44
|
+
ContractsConfig,
|
|
45
|
+
createContract,
|
|
46
|
+
createContracts,
|
|
47
|
+
VERSION
|
|
48
|
+
} from "@jonloucks/contracts-ts";
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
For broader helper APIs, use convenience or explicit subpath imports:
|
|
52
|
+
|
|
53
|
+
```typescript
|
|
54
|
+
import { bind, enforce, createSingleton } from "@jonloucks/contracts-ts/api/Convenience";
|
|
55
|
+
import { createAtomicBoolean } from "@jonloucks/contracts-ts/auxiliary/Convenience";
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
</details>
|
|
59
|
+
|
|
60
|
+
<details markdown="1"><summary>Transform types moved out of api/Types</summary>
|
|
61
|
+
|
|
62
|
+
```typescript
|
|
63
|
+
// v1.x (removed)
|
|
64
|
+
// import { TransformType, typeToTransform } from "@jonloucks/contracts-ts/api/Types";
|
|
65
|
+
|
|
66
|
+
// v2.0.0
|
|
67
|
+
import { type Type as TransformType } from "@jonloucks/contracts-ts/auxiliary/Transform";
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
</details>
|
|
71
|
+
|
|
72
|
+
<details markdown="1"><summary>Functional barrel removed</summary>
|
|
73
|
+
|
|
74
|
+
```typescript
|
|
75
|
+
// v1.x (removed)
|
|
76
|
+
// import { TransformType } from "@jonloucks/contracts-ts/auxiliary/Functional";
|
|
77
|
+
|
|
78
|
+
// v2.0.0
|
|
79
|
+
import {
|
|
80
|
+
type TransformType,
|
|
81
|
+
transformFromType,
|
|
82
|
+
transformGuard
|
|
83
|
+
} from "@jonloucks/contracts-ts/auxiliary/Convenience";
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
</details>
|
|
87
|
+
|
|
28
88
|
## Usage - code fragments from Example.test.ts
|
|
29
89
|
|
|
30
90
|
<details markdown="1"><summary>Importing the Package</summary>
|
|
@@ -39,10 +99,10 @@ import { CONTRACTS, createContract } from '@jonloucks/contracts-ts';
|
|
|
39
99
|
|
|
40
100
|
```typescript
|
|
41
101
|
import {
|
|
42
|
-
|
|
102
|
+
type AutoClose,
|
|
43
103
|
bind,
|
|
44
104
|
claim,
|
|
45
|
-
|
|
105
|
+
type Contract,
|
|
46
106
|
createExtractor,
|
|
47
107
|
createLifeCycle,
|
|
48
108
|
createRepository,
|
|
@@ -182,40 +242,28 @@ contracts-ts
|
|
|
182
242
|
├── CODE_OF_CONDUCT.md
|
|
183
243
|
├── CODING_STANDARDS.md
|
|
184
244
|
├── CONTRIBUTING.md
|
|
185
|
-
├──
|
|
245
|
+
├── DOCUMENTATION.md
|
|
246
|
+
├── .editorconfig
|
|
186
247
|
├── eslint.config.mjs
|
|
187
|
-
├── jest.config.js
|
|
188
248
|
├── LICENSE
|
|
189
249
|
├── package-lock.json
|
|
190
250
|
├── package.json
|
|
191
251
|
├── PULL_REQUEST_TEMPLATE.md
|
|
192
252
|
├── README.md
|
|
193
|
-
├── scripts
|
|
194
|
-
│ ├── badge-template.svg.dat
|
|
195
|
-
│ └── tsconfig.json
|
|
196
253
|
├── SECURITY.md
|
|
197
254
|
├── src
|
|
198
255
|
│ ├── index.ts
|
|
199
256
|
│ ├── version.ts
|
|
200
257
|
│ ├── api
|
|
201
|
-
│ │
|
|
202
|
-
│ │ ├── *.api.ts
|
|
258
|
+
│ │ └── *.ts
|
|
203
259
|
│ ├── auxiliary
|
|
204
|
-
│ │
|
|
205
|
-
│ │ ├── *.impl.ts
|
|
206
|
-
│ │ ├── *.test.ts // internal implementation specific
|
|
207
|
-
│ │ └── *.api.ts
|
|
260
|
+
│ │ └── *.ts
|
|
208
261
|
│ ├── impl
|
|
209
262
|
│ │ ├── *.ts
|
|
210
|
-
│ │
|
|
211
|
-
│ │ ├── *.test.ts // internal implementation specific
|
|
212
|
-
│ │ └── *.api.ts
|
|
263
|
+
│ │ └── *.test.ts // internal implementation specific
|
|
213
264
|
│ ├── test
|
|
214
265
|
│ │ └── *.test.ts
|
|
215
|
-
│ └── never-publish // non shippable development scripts
|
|
216
|
-
│ ├── *.ts
|
|
217
|
-
│ ├── *.*. // data files etc
|
|
218
|
-
│ └── *.test.ts
|
|
266
|
+
│ └── never-publish // non shippable development scripts (if present)
|
|
219
267
|
├── tsconfig.json
|
|
220
268
|
└── typedoc.json
|
|
221
269
|
```
|
package/api/AutoClose.d.ts
CHANGED
|
@@ -73,7 +73,7 @@ export declare function inlineAutoClose(action: () => void): RequiredType<AutoCl
|
|
|
73
73
|
* @param autoClose the AutoClose to unwrap
|
|
74
74
|
* @returns the original AutoCloseType
|
|
75
75
|
*/
|
|
76
|
-
export declare function
|
|
76
|
+
export declare function unwrap(autoClose: OptionalType<AutoClose>): OptionalType<AutoCloseType>;
|
|
77
77
|
/**
|
|
78
78
|
* Duck-typing check for AutoClose interface.
|
|
79
79
|
*
|
|
@@ -93,5 +93,5 @@ export declare function isClose(instance: unknown): instance is RequiredType<Aut
|
|
|
93
93
|
* @param type the type to convert
|
|
94
94
|
* @returns the AutoClose
|
|
95
95
|
*/
|
|
96
|
-
export declare function
|
|
96
|
+
export declare function fromType(type: RequiredType<AutoCloseType>): RequiredType<AutoClose>;
|
|
97
97
|
//# sourceMappingURL=AutoClose.d.ts.map
|
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,EAAgC,MAAM,mCAAmC,CAAC;AAI7G;;GAEG;AACH,MAAM,MAAM,aAAa,GAAG,SAAS,GAAG,KAAK,GAAG,CAAC,MAAM,OAAO,CAAC,CAAC;AAEhE;;GAEG;AACH,MAAM,WAAW,KAAK;IACpB;;OAEG;IACH,KAAK,IAAI,IAAI,CAAC;CACf;AAED;;;;;GAKG;AACH,MAAM,WAAW,SAAU,SAAQ,KAAK;IACtC;;OAEG;IACH,CAAC,MAAM,CAAC,OAAO,CAAC,IAAI,IAAI,CAAC;CAC1B;AAED;;GAEG;AACH,MAAM,WAAW,aAAc,SAAQ,SAAS;IAE9C;;;;;OAKG;IACH,GAAG,CAAC,SAAS,EAAE,YAAY,CAAC,aAAa,CAAC,GAAG,IAAI,CAAC;CACnD;AAED;;GAEG;AACH,MAAM,WAAW,YAAa,SAAQ,SAAS;IAE7C;;;;OAIG;IACH,GAAG,CAAC,SAAS,EAAE,YAAY,CAAC,aAAa,CAAC,GAAG,IAAI,CAAC;CACnD;AAED;;GAEG;AACH,eAAO,MAAM,eAAe,EAAE,SAe7B,CAAC;AAEF;;GAEG;AACH,MAAM,WAAW,gBAAiB,SAAQ,SAAS;IAEjD;;OAEG;IACH,mBAAmB,IAAI,Y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C,SAAS,EAAE,YAAY,CAAC,SAAS,CAAC,GAAG,YAAY,CAAC,aAAa,CAAC,CAQtF;AAED;;;;;GAKG;AACH,wBAAgB,KAAK,CAAC,QAAQ,EAAE,OAAO,GAAG,QAAQ,IAAI,YAAY,CAAC,SAAS,CAAC,CAE5E;AAED;;;;;GAKG;AACH,wBAAgB,OAAO,CAAC,QAAQ,EAAE,OAAO,GAAG,QAAQ,IAAI,YAAY,CAAC,SAAS,CAAC,CAE9E;AAED;;;;GAIG;AACH,wBAAgB,QAAQ,CAAC,IAAI,EAAE,YAAY,CAAC,aAAa,CAAC,GAAG,YAAY,CAAC,SAAS,CAAC,CAWnF"}
|
package/api/AutoClose.js
CHANGED
|
@@ -1,18 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
exports.inlineAutoClose = inlineAutoClose;
|
|
5
|
-
exports.unwrapAutoClose = unwrapAutoClose;
|
|
6
|
-
exports.guard = guard;
|
|
7
|
-
exports.isClose = isClose;
|
|
8
|
-
exports.typeToAutoClose = typeToAutoClose;
|
|
9
|
-
const Types_1 = require("@jonloucks/contracts-ts/api/Types");
|
|
10
|
-
const Checks_1 = require("@jonloucks/contracts-ts/auxiliary/Checks");
|
|
11
|
-
const IllegalArgumentException_1 = require("@jonloucks/contracts-ts/auxiliary/IllegalArgumentException");
|
|
1
|
+
import { guardFunctions, isNotPresent } from "@jonloucks/contracts-ts/api/Types";
|
|
2
|
+
import { presentCheck } from "@jonloucks/contracts-ts/auxiliary/Checks";
|
|
3
|
+
import { IllegalArgumentException } from "@jonloucks/contracts-ts/auxiliary/IllegalArgumentException";
|
|
12
4
|
/**
|
|
13
5
|
* A no-op AutoClose instance that does nothing on close or dispose.
|
|
14
6
|
*/
|
|
15
|
-
|
|
7
|
+
export const AUTO_CLOSE_NONE = {
|
|
16
8
|
/**
|
|
17
9
|
* AutoClose.close override
|
|
18
10
|
*/
|
|
@@ -32,7 +24,7 @@ exports.AUTO_CLOSE_NONE = {
|
|
|
32
24
|
* @returns true if the instance is an AutoCloseWrapper, false otherwise
|
|
33
25
|
*/
|
|
34
26
|
function guardAutoCloseWrapper(instance) {
|
|
35
|
-
return
|
|
27
|
+
return guardFunctions(instance, 'unwrapAutoCloseType');
|
|
36
28
|
}
|
|
37
29
|
/**
|
|
38
30
|
* Convert a simple runnable into an AutoClose with dispose
|
|
@@ -40,7 +32,7 @@ function guardAutoCloseWrapper(instance) {
|
|
|
40
32
|
* @param action the runnable action to perform on close/dispose
|
|
41
33
|
* @returns the AutoClose instance
|
|
42
34
|
*/
|
|
43
|
-
function inlineAutoClose(action) {
|
|
35
|
+
export function inlineAutoClose(action) {
|
|
44
36
|
return {
|
|
45
37
|
close: action,
|
|
46
38
|
[Symbol.dispose]: action,
|
|
@@ -53,8 +45,8 @@ function inlineAutoClose(action) {
|
|
|
53
45
|
* @param autoClose the AutoClose to unwrap
|
|
54
46
|
* @returns the original AutoCloseType
|
|
55
47
|
*/
|
|
56
|
-
function
|
|
57
|
-
if (
|
|
48
|
+
export function unwrap(autoClose) {
|
|
49
|
+
if (isNotPresent(autoClose)) {
|
|
58
50
|
return autoClose;
|
|
59
51
|
}
|
|
60
52
|
if (guardAutoCloseWrapper(autoClose)) {
|
|
@@ -68,8 +60,8 @@ function unwrapAutoClose(autoClose) {
|
|
|
68
60
|
* @param instance the instance to check
|
|
69
61
|
* @returns true if the instance implements AutoClose, false otherwise
|
|
70
62
|
*/
|
|
71
|
-
function guard(instance) {
|
|
72
|
-
return
|
|
63
|
+
export function guard(instance) {
|
|
64
|
+
return guardFunctions(instance, 'close', Symbol.dispose);
|
|
73
65
|
}
|
|
74
66
|
/**
|
|
75
67
|
* Duck-typing check for object with close() method.
|
|
@@ -77,16 +69,16 @@ function guard(instance) {
|
|
|
77
69
|
* @param instance the instance to check
|
|
78
70
|
* @returns true if the instance implements AutoClose, false otherwise
|
|
79
71
|
*/
|
|
80
|
-
function isClose(instance) {
|
|
81
|
-
return
|
|
72
|
+
export function isClose(instance) {
|
|
73
|
+
return guardFunctions(instance, 'close');
|
|
82
74
|
}
|
|
83
75
|
/**
|
|
84
76
|
* Convert an AutoCloseType to an AutoClose
|
|
85
77
|
* @param type the type to convert
|
|
86
78
|
* @returns the AutoClose
|
|
87
79
|
*/
|
|
88
|
-
function
|
|
89
|
-
const presentType =
|
|
80
|
+
export function fromType(type) {
|
|
81
|
+
const presentType = presentCheck(type, "AutoClose type must be present.");
|
|
90
82
|
if (guard(presentType)) {
|
|
91
83
|
return presentType;
|
|
92
84
|
}
|
|
@@ -97,7 +89,7 @@ function typeToAutoClose(type) {
|
|
|
97
89
|
return inlineAutoClose(presentType);
|
|
98
90
|
}
|
|
99
91
|
else {
|
|
100
|
-
throw new
|
|
92
|
+
throw new IllegalArgumentException("Invalid AutoClose type.");
|
|
101
93
|
}
|
|
102
94
|
}
|
|
103
95
|
//# sourceMappingURL=AutoClose.js.map
|
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":"AAAA,OAAO,EAA8B,cAAc,EAAE,YAAY,EAAE,MAAM,mCAAmC,CAAC;AAC7G,OAAO,EAAE,YAAY,EAAE,MAAM,0CAA0C,CAAC;AACxE,OAAO,EAAE,wBAAwB,EAAE,MAAM,4DAA4D,CAAC;AAyDtG;;GAEG;AACH,MAAM,CAAC,MAAM,eAAe,GAAc;IAExC;;OAEG;IACH,KAAK,EAAE,GAAG,EAAE;QACV,QAAQ;IACV,CAAC;IAED;;OAEG;IACH,CAAC,MAAM,CAAC,OAAO,CAAC,EAAE,GAAG,EAAE;QACrB,QAAQ;IACV,CAAC;CACF,CAAC;AAaF;;;;GAIG;AACH,SAAS,qBAAqB,CAAC,QAAiB;IAC9C,OAAO,cAAc,CAAC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D,CAAC;SAAM,CAAC;QACN,MAAM,IAAI,wBAAwB,CAAC,yBAAyB,CAAC,CAAC;IAChE,CAAC;AACH,CAAC"}
|
|
@@ -24,9 +24,9 @@ export interface AutoCloseFactory {
|
|
|
24
24
|
*/
|
|
25
25
|
createAutoCloseOne(): RequiredType<AutoCloseOne>;
|
|
26
26
|
}
|
|
27
|
-
export { AutoClose, AutoCloseMany, AutoCloseOne, AutoCloseType } from "@jonloucks/contracts-ts/api/AutoClose";
|
|
28
|
-
export { Contract } from "@jonloucks/contracts-ts/api/Contract";
|
|
29
|
-
export { OptionalType, RequiredType } from "@jonloucks/contracts-ts/api/Types";
|
|
27
|
+
export { type AutoClose, type AutoCloseMany, type AutoCloseOne, type AutoCloseType } from "@jonloucks/contracts-ts/api/AutoClose";
|
|
28
|
+
export { type Contract } from "@jonloucks/contracts-ts/api/Contract";
|
|
29
|
+
export { type OptionalType, type RequiredType } from "@jonloucks/contracts-ts/api/Types";
|
|
30
30
|
/**
|
|
31
31
|
* Type guard for AutoCloseFactory interface.
|
|
32
32
|
*
|
|
@@ -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,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,YA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
-
exports.guard = guard;
|
|
5
|
-
const RatifiedContract_1 = require("@jonloucks/contracts-ts/api/RatifiedContract");
|
|
6
|
-
const Types_1 = require("@jonloucks/contracts-ts/api/Types");
|
|
1
|
+
import { create as createContract } from "@jonloucks/contracts-ts/api/RatifiedContract";
|
|
2
|
+
import { guardFunctions } from "@jonloucks/contracts-ts/api/Types";
|
|
7
3
|
/**
|
|
8
4
|
* Type guard for AutoCloseFactory interface.
|
|
9
5
|
*
|
|
10
6
|
* @param instance the instance to check
|
|
11
7
|
* @returns true if the instance implements AutoCloseFactory
|
|
12
8
|
*/
|
|
13
|
-
function guard(instance) {
|
|
14
|
-
return
|
|
9
|
+
export function guard(instance) {
|
|
10
|
+
return guardFunctions(instance, 'createAutoClose', 'createAutoCloseMany', 'createAutoCloseOne');
|
|
15
11
|
}
|
|
16
12
|
/**
|
|
17
13
|
* The Contract for AutoCloseFactory implementation.
|
|
18
14
|
*/
|
|
19
|
-
|
|
15
|
+
export const CONTRACT = createContract({
|
|
20
16
|
test: guard,
|
|
21
17
|
name: "AutoCloseFactory",
|
|
22
18
|
typeName: "AutoCloseFactory"
|
|
@@ -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":"AAEA,OAAO,EAAE,MAAM,IAAI,cAAc,EAAE,MAAM,8CAA8C,CAAC;AACxF,OAAO,EAAE,cAAc,EAAgB,MAAM,mCAAmC,CAAC;AAiCjF;;;;;GAKG;AACH,MAAM,UAAU,KAAK,CAAC,QAAiB;IACnC,OAAO,cAAc,CAAC,QAAQ,EAAE,iBAAiB,EAAE,qBAAqB,EAAE,oBAAoB,CAAC,CAAC;AACpG,CAAC;AAED;;GAEG;AACH,MAAM,CAAC,MAAM,QAAQ,GAA+B,cAAc,CAAC;IAC/D,IAAI,EAAE,KAAK;IACX,IAAI,EAAE,kBAAkB;IACxB,QAAQ,EAAE,kBAAkB;CAC/B,CAAC,CAAC"}
|
package/api/AutoOpen.js
CHANGED
|
@@ -1,14 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.guard = guard;
|
|
4
|
-
const Types_1 = require("@jonloucks/contracts-ts/api/Types");
|
|
1
|
+
import { guardFunctions } from "@jonloucks/contracts-ts/api/Types";
|
|
5
2
|
/**
|
|
6
3
|
* Duck-typing check for AutoOpen interface.
|
|
7
4
|
*
|
|
8
5
|
* @param instance the instance to check
|
|
9
6
|
* @returns true if the instance implements AutoOpen, false otherwise
|
|
10
7
|
*/
|
|
11
|
-
function guard(instance) {
|
|
12
|
-
return
|
|
8
|
+
export function guard(instance) {
|
|
9
|
+
return guardFunctions(instance, 'autoOpen');
|
|
13
10
|
}
|
|
14
11
|
//# 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":"
|
|
1
|
+
{"version":3,"file":"AutoOpen.js","sourceRoot":"","sources":["../../src/api/AutoOpen.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAgB,MAAM,mCAAmC,CAAC;AAgBjF;;;;;GAKG;AACH,MAAM,UAAU,KAAK,CAAC,QAAiB;IACnC,OAAO,cAAc,CAAC,QAAQ,EAAE,UAAU,CAAC,CAAC;AAChD,CAAC"}
|
package/api/BasicContract.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
3
2
|
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
4
3
|
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
@@ -11,18 +10,15 @@ var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (
|
|
|
11
10
|
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
12
11
|
};
|
|
13
12
|
var _a, _BasicContract_id, _BasicContract_name, _BasicContract_typeName, _BasicContract_tester, _BasicContract_replaceable, _BasicContract_guarded;
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
exports.create = create;
|
|
17
|
-
const Types_1 = require("@jonloucks/contracts-ts/api/Types");
|
|
18
|
-
const ContractException_1 = require("@jonloucks/contracts-ts/api/ContractException");
|
|
13
|
+
import { isNotPresent } from "@jonloucks/contracts-ts/api/Types";
|
|
14
|
+
import { ContractException } from "@jonloucks/contracts-ts/api/ContractException";
|
|
19
15
|
/**
|
|
20
16
|
* Create a basic Contract
|
|
21
17
|
*
|
|
22
18
|
* @param config the configuration for the Contract
|
|
23
19
|
* @returns the created Contract
|
|
24
20
|
*/
|
|
25
|
-
function create(config) {
|
|
21
|
+
export function create(config) {
|
|
26
22
|
return BasicContract.create(config);
|
|
27
23
|
}
|
|
28
24
|
/**
|
|
@@ -33,7 +29,7 @@ function create(config) {
|
|
|
33
29
|
*
|
|
34
30
|
* Class designed for extension.
|
|
35
31
|
*/
|
|
36
|
-
class BasicContract {
|
|
32
|
+
export class BasicContract {
|
|
37
33
|
/**
|
|
38
34
|
* Create a contract derived from the given configuration
|
|
39
35
|
*
|
|
@@ -53,7 +49,7 @@ class BasicContract {
|
|
|
53
49
|
* @throws ContractException if the value can't be cast to the return type.
|
|
54
50
|
*/
|
|
55
51
|
cast(value) {
|
|
56
|
-
if (
|
|
52
|
+
if (isNotPresent(value)) {
|
|
57
53
|
if (__classPrivateFieldGet(this, _BasicContract_guarded, "f")) {
|
|
58
54
|
this.throwCastException();
|
|
59
55
|
}
|
|
@@ -135,10 +131,9 @@ class BasicContract {
|
|
|
135
131
|
}
|
|
136
132
|
throwCastException() {
|
|
137
133
|
// Note: message intentionally does not include the instance value
|
|
138
|
-
throw new
|
|
134
|
+
throw new ContractException(`Casting error. Unable to cast '${this.toString()}'.`);
|
|
139
135
|
}
|
|
140
136
|
}
|
|
141
|
-
exports.BasicContract = BasicContract;
|
|
142
137
|
_a = BasicContract, _BasicContract_id = new WeakMap(), _BasicContract_name = new WeakMap(), _BasicContract_typeName = new WeakMap(), _BasicContract_tester = new WeakMap(), _BasicContract_replaceable = new WeakMap(), _BasicContract_guarded = new WeakMap();
|
|
143
138
|
BasicContract.ID_GENERATOR = 1;
|
|
144
139
|
//# sourceMappingURL=BasicContract.js.map
|
package/api/BasicContract.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BasicContract.js","sourceRoot":"","sources":["../../src/api/BasicContract.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"BasicContract.js","sourceRoot":"","sources":["../../src/api/BasicContract.ts"],"names":[],"mappings":";;;;;;;;;;;;AACA,OAAO,EAAE,YAAY,EAA8B,MAAM,mCAAmC,CAAC;AAC7F,OAAO,EAAE,iBAAiB,EAAE,MAAM,+CAA+C,CAAC;AAElF;;;;;GAKG;AACH,MAAM,UAAU,MAAM,CAAI,MAAyB;IACjD,OAAO,aAAa,CAAC,MAAM,CAAI,MAAM,CAAC,CAAC;AACzC,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,OAAO,aAAa;IAExB;;;;;;QAMI;IACJ,MAAM,CAAC,MAAM,CAAI,MAAyB;QACxC,OAAO,IAAI,EAAa,CAAI,MAAM,CAAC,CAAC;IACtC,CAAC;IAED;;;;;;;MAOE;IACK,IAAI,CAAC,KAAiC;QAC3C,IAAI,YAAY,CAAC,KAAK,CAAC,EAAE,CAAC;YACxB,IAAI,uBAAA,IAAI,8BAAS,EAAE,CAAC;gBAClB,IAAI,CAAC,kBAAkB,EAAE,CAAC;YAC5B,CAAC;iBAAM,CAAC;g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AAK,MAAA,CAAC;QAC1D,uBAAA,IAAI,0BAAY,eAAe,EAAE,OAAO,IAAI,IAAI,MAAA,CAAC;QACjD,uBAAA,IAAI,uBAAS,eAAe,EAAE,IAAI,IAAI,EAAE,MAAA,CAAC;QACzC,uBAAA,IAAI,2BAAa,eAAe,EAAE,QAAQ,IAAI,EAAE,MAAA,CAAC;QACjD,uBAAA,IAAI,yBAAW,eAAe,EAAE,IAAI,IAAI,CAAC,CAAC,OAAO,EAA8B,EAAE,CAAC,IAAI,CAAC,MAAA,CAAC;IAC1F,CAAC;IAEO,kBAAkB;QACxB,kEAAkE;QAClE,MAAM,IAAI,iBAAiB,CAAC,kCAAkC,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC;IACrF,CAAC;;;AAEc,0BAAY,GAAW,CAAC,AAAZ,CAAa"}
|
package/api/BindStrategy.js
CHANGED
|
@@ -1,27 +1,22 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.DEFAULT_BIND_STRATEGY = void 0;
|
|
4
|
-
exports.resolveBindStrategy = resolveBindStrategy;
|
|
5
|
-
exports.guard = guard;
|
|
6
1
|
/**
|
|
7
2
|
* The default binding strategy
|
|
8
3
|
*/
|
|
9
|
-
|
|
4
|
+
export const DEFAULT_BIND_STRATEGY = "IF_ALLOWED";
|
|
10
5
|
/**
|
|
11
6
|
* Resolve the given BindStrategy or return the default
|
|
12
7
|
*
|
|
13
8
|
* @param bindStrategy the bind strategy to resolve
|
|
14
9
|
* @return the resolved bind strategy
|
|
15
10
|
*/
|
|
16
|
-
function resolveBindStrategy(bindStrategy) {
|
|
17
|
-
return bindStrategy ??
|
|
11
|
+
export function resolveBindStrategy(bindStrategy) {
|
|
12
|
+
return bindStrategy ?? DEFAULT_BIND_STRATEGY;
|
|
18
13
|
}
|
|
19
14
|
/**
|
|
20
15
|
* Check if given value is a BindStrategy or null/undefined
|
|
21
16
|
* @param instance the value to check
|
|
22
17
|
* @returns true if value is a BindStrategy or null/undefined
|
|
23
18
|
*/
|
|
24
|
-
function guard(instance) {
|
|
19
|
+
export function guard(instance) {
|
|
25
20
|
switch (instance) {
|
|
26
21
|
case undefined:
|
|
27
22
|
case null:
|
package/api/BindStrategy.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BindStrategy.js","sourceRoot":"","sources":["../../src/api/BindStrategy.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"BindStrategy.js","sourceRoot":"","sources":["../../src/api/BindStrategy.ts"],"names":[],"mappings":"AAsBA;;GAEG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAiB,YAAY,CAAA;AAO/D;;;;;GAKG;AACH,MAAM,UAAU,mBAAmB,CAAC,YAAwC;IACxE,OAAO,YAAY,IAAI,qBAAqB,CAAC;AACjD,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,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.js
CHANGED
|
@@ -1,14 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.guard = guard;
|
|
4
|
-
const Types_1 = require("@jonloucks/contracts-ts/api/Types");
|
|
1
|
+
import { guardFunctions } from "@jonloucks/contracts-ts/api/Types";
|
|
5
2
|
/**
|
|
6
3
|
* Duck-typing check for Contract interface.
|
|
7
4
|
*
|
|
8
5
|
* @param instance the instance to check
|
|
9
6
|
* @returns true if the instance implements Contract, false otherwise
|
|
10
7
|
*/
|
|
11
|
-
function guard(instance) {
|
|
12
|
-
return
|
|
8
|
+
export function guard(instance) {
|
|
9
|
+
return guardFunctions(instance, 'cast', 'name', 'typeName', 'replaceable');
|
|
13
10
|
}
|
|
14
11
|
//# 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":"AAAA,OAAO,EAAE,cAAc,EAA8B,MAAM,mCAAmC,CAAC;AAkG/F;;;;;GAKG;AACH,MAAM,UAAU,KAAK,CAAI,QAAiB;IACxC,OAAO,cAAc,CAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,aAAa,CAAC,CAAC;AAC7E,CAAC"}
|
package/api/ContractException.js
CHANGED
|
@@ -1,13 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ContractException = void 0;
|
|
4
|
-
exports.guard = guard;
|
|
5
|
-
const Checks_1 = require("@jonloucks/contracts-ts/auxiliary/Checks");
|
|
1
|
+
import { messageCheck, used } from "@jonloucks/contracts-ts/auxiliary/Checks";
|
|
6
2
|
/**
|
|
7
3
|
* Runtime exception thrown for Contract related problems.
|
|
8
4
|
* For example, when claimed contract is not bound to a promisor.
|
|
9
5
|
*/
|
|
10
|
-
class ContractException extends Error {
|
|
6
|
+
export class ContractException extends Error {
|
|
11
7
|
/**
|
|
12
8
|
* Create a new ContractException
|
|
13
9
|
*
|
|
@@ -16,8 +12,8 @@ class ContractException extends Error {
|
|
|
16
12
|
*/
|
|
17
13
|
constructor(message, thrown = null) {
|
|
18
14
|
// super(messageCheck(message), thrown || undefined);
|
|
19
|
-
super(
|
|
20
|
-
|
|
15
|
+
super(messageCheck(message));
|
|
16
|
+
used(thrown);
|
|
21
17
|
this.name = "ContractException";
|
|
22
18
|
Object.setPrototypeOf(this, ContractException.prototype);
|
|
23
19
|
}
|
|
@@ -38,14 +34,13 @@ class ContractException extends Error {
|
|
|
38
34
|
}
|
|
39
35
|
}
|
|
40
36
|
}
|
|
41
|
-
exports.ContractException = ContractException;
|
|
42
37
|
/**
|
|
43
38
|
* Type guard for ContractException
|
|
44
39
|
*
|
|
45
40
|
* @param value the value to check
|
|
46
41
|
* @return true if value is ContractException, false otherwise
|
|
47
42
|
*/
|
|
48
|
-
function guard(value) {
|
|
43
|
+
export function guard(value) {
|
|
49
44
|
return value instanceof ContractException;
|
|
50
45
|
}
|
|
51
46
|
//# sourceMappingURL=ContractException.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ContractException.js","sourceRoot":"","sources":["../../src/api/ContractException.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"ContractException.js","sourceRoot":"","sources":["../../src/api/ContractException.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,IAAI,EAAE,MAAM,0CAA0C,CAAC;AAE9E;;;GAGG;AACH,MAAM,OAAO,iBAAkB,SAAQ,KAAK;IAE1C;;;;;OAKG;IACH,YAAmB,OAAe,EAAE,SAAuB,IAAI;QAC7D,qDAAqD;QACrD,KAAK,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC,CAAC;QAE7B,IAAI,CAAC,MAAM,CAAC,CAAC;QAEb,IAAI,CAAC,IAAI,GAAG,mBAAmB,CAAC;QAChC,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,iBAAiB,CAAC,SAAS,CAAC,CAAA;IAC1D,CAAC;IAED;;;;OAIG;IACH,MAAM,CAAC,OAAO,CAAC,MAAe,EAAE,OAAgB;QAC9C,IAAI,KAAK,CAAC,MAAM,CAAC,EAAE,CAAC;YAClB,MAAM,MAAM,CAAC;QACf,CAAC;aAAM,IAAI,MAAM,YAAY,KAAK,EAAE,CAAC;YACnC,MAAM,IAAI,iBAAiB,CAAC,OAAO,IAAI,MAAM,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;QACjE,CAAC;aAAM,CAAC;YACN,MAAM,IAAI,iBAAiB,CAAC,OAAO,IAAI,+BAA+B,CAAC,CAAC;QAC1E,CAAC;IACH,CAAC;CACF;AAED;;;;;GAKG;AACH,MAAM,UAAU,KAAK,CAAC,KAAc;IAClC,OAAO,KAAK,YAAY,iBAAiB,CAAC;AAC5C,CAAC"}
|
package/api/ContractFactory.js
CHANGED
|
@@ -1,14 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.guard = guard;
|
|
4
|
-
const Types_1 = require("@jonloucks/contracts-ts/api/Types");
|
|
1
|
+
import { guardFunctions } from "@jonloucks/contracts-ts/api/Types";
|
|
5
2
|
/**
|
|
6
3
|
* Type guard for ContractFactory
|
|
7
4
|
*
|
|
8
5
|
* @param value the value to check
|
|
9
6
|
* @return true if value is a ContractFactory, false otherwise
|
|
10
7
|
*/
|
|
11
|
-
function guard(value) {
|
|
12
|
-
return
|
|
8
|
+
export function guard(value) {
|
|
9
|
+
return guardFunctions(value, 'createContract');
|
|
13
10
|
}
|
|
14
11
|
//# sourceMappingURL=ContractFactory.js.map
|
|
@@ -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":"AACA,OAAO,EAAE,cAAc,EAA8B,MAAM,mCAAmC,CAAC;AAmB/F;;;;;GAKG;AACH,MAAM,UAAU,KAAK,CAAC,KAAc;IAClC,OAAO,cAAc,CAAC,KAAK,EAAE,gBAAgB,CAAC,CAAC;AACjD,CAAC"}
|
package/api/Contracts.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { AutoClose } from "@jonloucks/contracts-ts/api/AutoClose";
|
|
|
2
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
|
-
import { PromisorType } from "@jonloucks/contracts-ts/api/Promisor";
|
|
5
|
+
import { Type as PromisorType } from "@jonloucks/contracts-ts/api/Promisor";
|
|
6
6
|
import { OptionalType, RequiredType } from "@jonloucks/contracts-ts/api/Types";
|
|
7
7
|
/**
|
|
8
8
|
* The Contracts configuration
|
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,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;
|
|
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,IAAI,IAAI,YAAY,EAAE,MAAM,sCAAsC,CAAC;AAC5E,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,15 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.guard = guard;
|
|
4
|
-
const Open_1 = require("@jonloucks/contracts-ts/api/Open");
|
|
5
|
-
const Types_1 = require("@jonloucks/contracts-ts/api/Types");
|
|
1
|
+
import { guard as openGuard } from "@jonloucks/contracts-ts/api/Open";
|
|
2
|
+
import { guardFunctions } from "@jonloucks/contracts-ts/api/Types";
|
|
6
3
|
/**
|
|
7
4
|
* Type guard for Contracts
|
|
8
5
|
*
|
|
9
6
|
* @param value the value to check
|
|
10
7
|
* @return true if value is Contracts, false otherwise
|
|
11
8
|
*/
|
|
12
|
-
function guard(value) {
|
|
13
|
-
return
|
|
9
|
+
export function guard(value) {
|
|
10
|
+
return guardFunctions(value, 'claim', 'enforce', 'isBound', 'bind') && openGuard(value);
|
|
14
11
|
}
|
|
15
12
|
//# 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":"AACA,OAAO,EAAQ,KAAK,IAAI,SAAS,EAAE,MAAM,kCAAkC,CAAC;AAI5E,OAAO,EAAE,cAAc,EAA8B,MAAM,mCAAmC,CAAC;AAkF/F;;;;;GAKG;AACH,MAAM,UAAU,KAAK,CAAC,KAAc;IAClC,OAAO,cAAc,CAAC,KAAK,EAAE,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,CAAC,IAAI,SAAS,CAAC,KAAK,CAAC,CAAC;AAC1F,CAAC"}
|
package/api/ContractsFactory.js
CHANGED
|
@@ -1,14 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.guard = guard;
|
|
4
|
-
const Types_1 = require("@jonloucks/contracts-ts/api/Types");
|
|
1
|
+
import { guardFunctions } from "@jonloucks/contracts-ts/api/Types";
|
|
5
2
|
/**
|
|
6
3
|
* Type guard for ContractsFactory
|
|
7
4
|
*
|
|
8
5
|
* @param value the value to check
|
|
9
6
|
* @return true if value is ContractsFactory, false otherwise
|
|
10
7
|
*/
|
|
11
|
-
function guard(value) {
|
|
12
|
-
return
|
|
8
|
+
export function guard(value) {
|
|
9
|
+
return guardFunctions(value, 'createContracts');
|
|
13
10
|
}
|
|
14
11
|
//# 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":"AACA,OAAO,EAAE,cAAc,EAAgB,MAAM,mCAAmC,CAAC;AAkBjF;;;;;GAKG;AACH,MAAM,UAAU,KAAK,CAAC,KAAc;IAClC,OAAO,cAAc,CAAC,KAAK,EAAE,iBAAiB,CAAC,CAAC;AAClD,CAAC"}
|