@jonloucks/contracts-ts 1.3.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 +10 -14
- 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
|
@@ -1,26 +1,23 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.create = create;
|
|
4
|
-
const Idempotent_impl_1 = require("./Idempotent.impl");
|
|
5
|
-
const Checks_1 = require("../auxiliary/Checks");
|
|
1
|
+
import { used } from "@jonloucks/contracts-ts/auxiliary/Checks";
|
|
2
|
+
import { create as createIdempotentImpl } from "./Idempotent.impl.js";
|
|
6
3
|
/**
|
|
7
4
|
* Create a new IdempotentFactory
|
|
8
5
|
*
|
|
9
6
|
* @return the new IdempotentFactory
|
|
10
7
|
*/
|
|
11
|
-
function create(config) {
|
|
8
|
+
export function create(config) {
|
|
12
9
|
return IdempotentFactoryImpl.internalCreate(config);
|
|
13
10
|
}
|
|
14
11
|
// ---- Implementation details below ----
|
|
15
12
|
class IdempotentFactoryImpl {
|
|
16
13
|
createIdempotent(config) {
|
|
17
|
-
return (
|
|
14
|
+
return createIdempotentImpl(config);
|
|
18
15
|
}
|
|
19
16
|
static internalCreate(config) {
|
|
20
17
|
return new IdempotentFactoryImpl(config);
|
|
21
18
|
}
|
|
22
19
|
constructor(config) {
|
|
23
|
-
|
|
20
|
+
used(config);
|
|
24
21
|
}
|
|
25
22
|
}
|
|
26
23
|
;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IdempotentFactory.impl.js","sourceRoot":"","sources":["../../src/impl/IdempotentFactory.impl.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"IdempotentFactory.impl.js","sourceRoot":"","sources":["../../src/impl/IdempotentFactory.impl.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,IAAI,EAAE,MAAM,0CAA0C,CAAC;AAEhE,OAAO,EAAE,MAAM,IAAI,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAMtE;;;;GAIG;AACH,MAAM,UAAU,MAAM,CAAC,MAAe;IACpC,OAAO,qBAAqB,CAAC,cAAc,CAAC,MAAM,CAAC,CAAC;AACtD,CAAC;AAED,yCAAyC;AAEzC,MAAM,qBAAqB;IAEzB,gBAAgB,CAAC,MAAwB;QACvC,OAAO,oBAAoB,CAAC,MAAM,CAAC,CAAC;IACtC,CAAC;IAED,MAAM,CAAC,cAAc,CAAC,MAAe;QACnC,OAAO,IAAI,qBAAqB,CAAC,MAAM,CAAC,CAAC;IAC3C,CAAC;IAED,YAAoB,MAAe;QACjC,IAAI,CAAC,MAAM,CAAC,CAAC;IACf,CAAC;CACF;AAAA,CAAC"}
|
package/impl/Internal.impl.js
CHANGED
|
@@ -1,12 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.Internal = void 0;
|
|
4
|
-
const ContractException_1 = require("@jonloucks/contracts-ts/api/ContractException");
|
|
5
|
-
const Checks_1 = require("@jonloucks/contracts-ts/auxiliary/Checks");
|
|
1
|
+
import { ContractException } from "@jonloucks/contracts-ts/api/ContractException";
|
|
2
|
+
import { presentCheck } from "@jonloucks/contracts-ts/auxiliary/Checks";
|
|
6
3
|
/**
|
|
7
4
|
* Helper functions for internal implementations.
|
|
8
5
|
*/
|
|
9
|
-
|
|
6
|
+
export const Internal = {
|
|
10
7
|
/**
|
|
11
8
|
* Iterate over a Map in reverse order, invoking the callback for each entry.
|
|
12
9
|
*
|
|
@@ -14,7 +11,7 @@ exports.Internal = {
|
|
|
14
11
|
* @param callback the callback to invoke for each entry
|
|
15
12
|
*/
|
|
16
13
|
mapForEachReversed(map, callback) {
|
|
17
|
-
const validMap =
|
|
14
|
+
const validMap = presentCheck(map, "Map must be present.");
|
|
18
15
|
const entries = [];
|
|
19
16
|
validMap.forEach((value, key) => {
|
|
20
17
|
entries.push([key, value]);
|
|
@@ -40,7 +37,7 @@ exports.Internal = {
|
|
|
40
37
|
const messages = errorList.map(error => `- ${error instanceof Error ? error.message : String(error)}`);
|
|
41
38
|
// Join the messages with a newline separator
|
|
42
39
|
const messagesJoined = messages.join('\n');
|
|
43
|
-
throw new
|
|
40
|
+
throw new ContractException(message + "\n" + messagesJoined);
|
|
44
41
|
}
|
|
45
42
|
}
|
|
46
43
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Internal.impl.js","sourceRoot":"","sources":["../../src/impl/Internal.impl.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Internal.impl.js","sourceRoot":"","sources":["../../src/impl/Internal.impl.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,+CAA+C,CAAC;AAClF,OAAO,EAAE,YAAY,EAAE,MAAM,0CAA0C,CAAC;AAExE;;GAEG;AACH,MAAM,CAAC,MAAM,QAAQ,GAAG;IAEtB;;;;;OAKG;IACH,kBAAkB,CAAO,GAAc,EAAE,QAAoC;QAC3E,MAAM,QAAQ,GAAG,YAAY,CAAC,GAAG,EAAE,sBAAsB,CAAC,CAAC;QAC3D,MAAM,OAAO,GAAa,EAAE,CAAC;QAC7B,QAAQ,CAAC,OAAO,CAAC,CAAC,KAAK,EAAE,GAAG,EAAE,EAAE;YAC9B,OAAO,CAAC,IAAI,CAAC,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC,CAAC;QAC7B,CAAC,CAAC,CAAC;QACH,OAAO,OAAO,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YAC1B,MAAM,KAAK,GAAG,OAAO,CAAC,GAAG,EAAG,CAAC;YAC7B,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;QAC/B,CAAC;IACH,CAAC;IAED;;;;;;OAMG;IACH,mBAAmB,CAAC,OAAe,EAAE,GAAG,SAAoB;QAC1D,IAAI,SAAS,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YAC3B,MAAM,SAAS,CAAC,CAAC,CAAC,CAAC;QACrB,CAAC;aAAM,CAAC;YACN,gDAAgD;YAChD,MAAM,QAAQ,GAAG,SAAS,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC,KAAK,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;YAEvG,6CAA6C;YAC7C,MAAM,cAAc,GAAG,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YAE3C,MAAM,IAAI,iBAAiB,CAAC,OAAO,GAAG,IAAI,GAAG,cAAc,CAAC,CAAC;QAC/D,CAAC;IACH,CAAC;CACF,CAAA"}
|
|
@@ -1,14 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
const AtomicInteger_impl_1 = require("./AtomicInteger.impl");
|
|
10
|
-
const AtomicReference_impl_1 = require("./AtomicReference.impl");
|
|
11
|
-
const AutoCloseOne_impl_1 = require("./AutoCloseOne.impl");
|
|
1
|
+
import { guard as isAutoOpen } from "@jonloucks/contracts-ts/api/AutoOpen";
|
|
2
|
+
import { isPresent } from "@jonloucks/contracts-ts/api/Types";
|
|
3
|
+
import { promisorCheck } from "@jonloucks/contracts-ts/auxiliary/Checks";
|
|
4
|
+
import { IllegalStateException } from "@jonloucks/contracts-ts/auxiliary/IllegalStateException";
|
|
5
|
+
import { create as createAtomicBoolean } from "./AtomicBoolean.impl.js";
|
|
6
|
+
import { create as createAtomicInteger } from "./AtomicInteger.impl.js";
|
|
7
|
+
import { create as createAtomicReference } from "./AtomicReference.impl.js";
|
|
8
|
+
import { create as createAutoCloseOne } from "./AutoCloseOne.impl.js";
|
|
12
9
|
/**
|
|
13
10
|
* Factory to create an Life Cycle promisor implementation
|
|
14
11
|
*
|
|
@@ -16,7 +13,7 @@ const AutoCloseOne_impl_1 = require("./AutoCloseOne.impl");
|
|
|
16
13
|
* @param <T> the type of deliverable
|
|
17
14
|
* @returns the new Life Cycle Promisor implementation
|
|
18
15
|
*/
|
|
19
|
-
function create(referent) {
|
|
16
|
+
export function create(referent) {
|
|
20
17
|
return LifeCyclePromisorImpl.internalCreate(referent);
|
|
21
18
|
}
|
|
22
19
|
// ---- Implementation details below ----
|
|
@@ -26,7 +23,7 @@ function create(referent) {
|
|
|
26
23
|
*/
|
|
27
24
|
class LifeCyclePromisorImpl {
|
|
28
25
|
demand() {
|
|
29
|
-
const currentDeliverable = (
|
|
26
|
+
const currentDeliverable = createAtomicReference();
|
|
30
27
|
if (this.getCurrentDeliverable(currentDeliverable)) {
|
|
31
28
|
return currentDeliverable.get();
|
|
32
29
|
}
|
|
@@ -53,16 +50,16 @@ class LifeCyclePromisorImpl {
|
|
|
53
50
|
return new LifeCyclePromisorImpl(referentPromisor);
|
|
54
51
|
}
|
|
55
52
|
constructor(referentPromisor) {
|
|
56
|
-
this.usageCounter = (
|
|
57
|
-
this.isDeliverableAcquired = (
|
|
58
|
-
this.atomicDeliverable = (
|
|
59
|
-
this.openException = (
|
|
60
|
-
this.closer = (
|
|
61
|
-
this.referent =
|
|
53
|
+
this.usageCounter = createAtomicInteger();
|
|
54
|
+
this.isDeliverableAcquired = createAtomicBoolean();
|
|
55
|
+
this.atomicDeliverable = createAtomicReference();
|
|
56
|
+
this.openException = createAtomicReference();
|
|
57
|
+
this.closer = createAutoCloseOne();
|
|
58
|
+
this.referent = promisorCheck(referentPromisor);
|
|
62
59
|
}
|
|
63
60
|
getCurrentDeliverable(placeholder) {
|
|
64
61
|
if (this.usageCounter.get() == 0) {
|
|
65
|
-
throw new
|
|
62
|
+
throw new IllegalStateException("Usage count is zero.");
|
|
66
63
|
}
|
|
67
64
|
this.maybeRethrowOpenException();
|
|
68
65
|
if (this.isDeliverableAcquired.get()) {
|
|
@@ -73,7 +70,7 @@ class LifeCyclePromisorImpl {
|
|
|
73
70
|
}
|
|
74
71
|
maybeRethrowOpenException() {
|
|
75
72
|
const thrown = this.openException.get();
|
|
76
|
-
if (
|
|
73
|
+
if (isPresent(thrown)) {
|
|
77
74
|
throw thrown;
|
|
78
75
|
}
|
|
79
76
|
}
|
|
@@ -94,7 +91,7 @@ class LifeCyclePromisorImpl {
|
|
|
94
91
|
return currentDeliverable;
|
|
95
92
|
}
|
|
96
93
|
openDeliverable(deliverable) {
|
|
97
|
-
if (
|
|
94
|
+
if (isPresent(deliverable) && isAutoOpen(deliverable)) {
|
|
98
95
|
const autoOpen = deliverable;
|
|
99
96
|
try {
|
|
100
97
|
this.closer.set(autoOpen.autoOpen());
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LifeCyclePromisor.impl.js","sourceRoot":"","sources":["../../src/impl/LifeCyclePromisor.impl.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"LifeCyclePromisor.impl.js","sourceRoot":"","sources":["../../src/impl/LifeCyclePromisor.impl.ts"],"names":[],"mappings":"AACA,OAAO,EAAY,KAAK,IAAI,UAAU,EAAE,MAAM,sCAAsC,CAAC;AAErF,OAAO,EAA8B,SAAS,EAAE,MAAM,mCAAmC,CAAC;AAI1F,OAAO,EAAE,aAAa,EAAE,MAAM,0CAA0C,CAAC;AACzE,OAAO,EAAE,qBAAqB,EAAE,MAAM,yDAAyD,CAAC;AAEhG,OAAO,EAAE,MAAM,IAAI,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AACxE,OAAO,EAAE,MAAM,IAAI,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AACxE,OAAO,EAAE,MAAM,IAAI,qBAAqB,EAAE,MAAM,2BAA2B,CAAC;AAC5E,OAAO,EAAE,MAAM,IAAI,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAEtE;;;;;;GAMG;AACH,MAAM,UAAU,MAAM,CAAI,QAAqB;IAC7C,OAAO,qBAAqB,CAAC,cAAc,CAAI,QAAQ,CAAC,CAAC;AAC3D,CAAC;AAED,yCAAyC;AAEzC;;;GAGG;AACH,MAAM,qBAAqB;IAElB,MAAM;QACX,MAAM,kBAAkB,GAAuB,q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AAC,QAAQ,CAAC,QAAQ,EAAE,CAAC,CAAC;YACvC,CAAC;YAAC,OAAO,MAAM,EAAE,CAAC;gBAChB,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;gBAC/B,IAAI,CAAC,qBAAqB,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;gBACtC,MAAM,MAAM,CAAC;YACf,CAAC;QACH,CAAC;IACH,CAAC;IAEO,gBAAgB;QACtB,IAAI,IAAI,CAAC,qBAAqB,CAAC,GAAG,EAAE,EAAE,CAAC;YACrC,MAAM,WAAW,GAA2B,IAAI,CAAC,iBAAiB,CAAC,GAAG,EAAE,CAAC;YACzE,IAAI,CAAC;gBACH,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC;YACtB,CAAC;oBAAS,CAAC;gBACT,IAAI,CAAC,iBAAiB,CAAC,aAAa,CAAC,WAAW,EAAE,IAAI,CAAC,CAAC;gBACxD,IAAI,CAAC,qBAAqB,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;YACxC,CAAC;QACH,CAAC;IACH,CAAC;CAQF"}
|
package/impl/Policy.d.ts
CHANGED
package/impl/Policy.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Policy.d.ts","sourceRoot":"","sources":["../../src/impl/Policy.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,sCAAsC,CAAC;AAEhE
|
|
1
|
+
{"version":3,"file":"Policy.d.ts","sourceRoot":"","sources":["../../src/impl/Policy.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,sCAAsC,CAAC;AAEhE;;GAEG;AACH,MAAM,WAAW,MAAM;IAErB;;;;;OAKG;IACH,aAAa,CAAC,CAAC,EAAE,QAAQ,EAAE,QAAQ,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC;CAC/C"}
|
package/impl/Policy.impl.d.ts
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import { Config as ContractsConfig } from "@jonloucks/contracts-ts/api/Contracts";
|
|
2
2
|
import { RequiredType } from "@jonloucks/contracts-ts/api/Types";
|
|
3
|
-
import { Policy } from "./Policy";
|
|
4
|
-
export { RequiredType } from "@jonloucks/contracts-ts/api/Types";
|
|
5
|
-
export { Policy } from "./Policy";
|
|
3
|
+
import { Policy } from "./Policy.js";
|
|
6
4
|
/**
|
|
7
5
|
* Factory method to create Policy instance.
|
|
8
6
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Policy.impl.d.ts","sourceRoot":"","sources":["../../src/impl/Policy.impl.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,MAAM,IAAI,eAAe,EAAE,MAAM,uCAAuC,CAAC;AAElF,OAAO,EAAE,YAAY,EAAE,MAAM,mCAAmC,CAAC;
|
|
1
|
+
{"version":3,"file":"Policy.impl.d.ts","sourceRoot":"","sources":["../../src/impl/Policy.impl.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,MAAM,IAAI,eAAe,EAAE,MAAM,uCAAuC,CAAC;AAElF,OAAO,EAAE,YAAY,EAAE,MAAM,mCAAmC,CAAC;AAEjE,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAErC;;;;;GAKG;AACH,wBAAgB,MAAM,CAAC,MAAM,CAAC,EAAE,eAAe,GAAG,YAAY,CAAC,MAAM,CAAC,CAIrE"}
|
package/impl/Policy.impl.js
CHANGED
|
@@ -1,16 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const ContractException_1 = require("@jonloucks/contracts-ts/api/ContractException");
|
|
5
|
-
const RatifiedContract_1 = require("@jonloucks/contracts-ts/api/RatifiedContract");
|
|
6
|
-
const Checks_1 = require("../auxiliary/Checks");
|
|
1
|
+
import { ContractException } from "@jonloucks/contracts-ts/api/ContractException";
|
|
2
|
+
import { isRatifiedContract } from "@jonloucks/contracts-ts/api/RatifiedContract";
|
|
3
|
+
import { used } from "@jonloucks/contracts-ts/auxiliary/Checks";
|
|
7
4
|
/**
|
|
8
5
|
* Factory method to create Policy instance.
|
|
9
6
|
*
|
|
10
7
|
* @param config the configuration for the Policy instance
|
|
11
8
|
* @returns the Policy implementation
|
|
12
9
|
*/
|
|
13
|
-
function create(config) {
|
|
10
|
+
export function create(config) {
|
|
14
11
|
return {
|
|
15
12
|
checkContract: compileContractCheck(config)
|
|
16
13
|
};
|
|
@@ -19,12 +16,12 @@ function create(config) {
|
|
|
19
16
|
function compileContractCheck(config) {
|
|
20
17
|
const ratified = config?.ratified ?? true;
|
|
21
18
|
if (ratified === false) {
|
|
22
|
-
return (c) => {
|
|
19
|
+
return (c) => { used(c); };
|
|
23
20
|
}
|
|
24
21
|
else {
|
|
25
22
|
return (contract) => {
|
|
26
|
-
if (
|
|
27
|
-
throw new
|
|
23
|
+
if (isRatifiedContract(contract) === false) {
|
|
24
|
+
throw new ContractException("Action denied: Only a ratified contract can be used.");
|
|
28
25
|
}
|
|
29
26
|
};
|
|
30
27
|
}
|
package/impl/Policy.impl.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Policy.impl.js","sourceRoot":"","sources":["../../src/impl/Policy.impl.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Policy.impl.js","sourceRoot":"","sources":["../../src/impl/Policy.impl.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,iBAAiB,EAAE,MAAM,+CAA+C,CAAC;AAElF,OAAO,EAAE,kBAAkB,EAAE,MAAM,8CAA8C,CAAC;AAElF,OAAO,EAAE,IAAI,EAAE,MAAM,0CAA0C,CAAC;AAGhE;;;;;GAKG;AACH,MAAM,UAAU,MAAM,CAAC,MAAwB;IAC7C,OAAO;QACL,aAAa,EAAE,oBAAoB,CAAC,MAAM,CAAC;KAC5C,CAAC;AACJ,CAAC;AAED,yCAAyC;AAEzC,SAAS,oBAAoB,CAAI,MAAwB;IACvD,MAAM,QAAQ,GAAY,MAAM,EAAE,QAAQ,IAAI,IAAI,CAAC;IACnD,IAAI,QAAQ,KAAK,KAAK,EAAE,CAAC;QACvB,OAAO,CAAC,CAAc,EAAE,EAAE,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IAC1C,CAAC;SAAM,CAAC;QACN,OAAO,CAAC,QAAqB,EAAE,EAAE;YAC/B,IAAI,kBAAkB,CAAC,QAAQ,CAAC,KAAK,KAAK,EAAE,CAAC;gBAC3C,MAAM,IAAI,iBAAiB,CAAC,sDAAsD,CAAC,CAAC;YACtF,CAAC;QACH,CAAC,CAAC;IACJ,CAAC;AACH,CAAC"}
|
package/impl/Policy.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PromisorFactory.impl.d.ts","sourceRoot":"","sources":["../../src/impl/PromisorFactory.impl.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,6CAA6C,CAAC;AAC9E,OAAO,EAAgB,YAAY,
|
|
1
|
+
{"version":3,"file":"PromisorFactory.impl.d.ts","sourceRoot":"","sources":["../../src/impl/PromisorFactory.impl.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,6CAA6C,CAAC;AAC9E,OAAO,EAAgB,YAAY,EAAE,MAAM,mCAAmC,CAAC;AAO/E;;;;GAIG;AACH,wBAAgB,MAAM,IAAI,YAAY,CAAC,eAAe,CAAC,CAEtD"}
|
|
@@ -1,18 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
const LifeCyclePromisor_impl_1 = require("./LifeCyclePromisor.impl");
|
|
8
|
-
const SingletonPromisor_impl_1 = require("./SingletonPromisor.impl");
|
|
9
|
-
const ValuePromisor_impl_1 = require("./ValuePromisor.impl");
|
|
1
|
+
import { fromType } from "@jonloucks/contracts-ts/api/Promisor";
|
|
2
|
+
import { fromType as typeToTransform } from "@jonloucks/contracts-ts/auxiliary/Transform";
|
|
3
|
+
import { create as createExtractor } from "./ExtractorPromisor.impl.js";
|
|
4
|
+
import { create as createLifeCycle } from "./LifeCyclePromisor.impl.js";
|
|
5
|
+
import { create as createSingleton } from "./SingletonPromisor.impl.js";
|
|
6
|
+
import { create as createValue } from "./ValuePromisor.impl.js";
|
|
10
7
|
/**
|
|
11
8
|
* Factory to create a PromisorFactory implementation
|
|
12
9
|
*
|
|
13
10
|
* @returns the PromisorFactory implementation
|
|
14
11
|
*/
|
|
15
|
-
function create() {
|
|
12
|
+
export function create() {
|
|
16
13
|
return PromisorsImpl.internalCreate();
|
|
17
14
|
}
|
|
18
15
|
// ---- Implementation details below ----
|
|
@@ -24,25 +21,25 @@ class PromisorsImpl {
|
|
|
24
21
|
* PromisorFactory.createValue override.
|
|
25
22
|
*/
|
|
26
23
|
createValue(deliverable) {
|
|
27
|
-
return (
|
|
24
|
+
return createValue(deliverable);
|
|
28
25
|
}
|
|
29
26
|
/**
|
|
30
27
|
* PromisorFactory.createSingleton override.
|
|
31
28
|
*/
|
|
32
29
|
createSingleton(promisor) {
|
|
33
|
-
return (
|
|
30
|
+
return createSingleton(fromType(promisor));
|
|
34
31
|
}
|
|
35
32
|
/**
|
|
36
33
|
* PromisorFactory.createLifeCycle override.
|
|
37
34
|
*/
|
|
38
35
|
createLifeCycle(promisor) {
|
|
39
|
-
return (
|
|
36
|
+
return createLifeCycle(fromType(promisor));
|
|
40
37
|
}
|
|
41
38
|
/**
|
|
42
39
|
* PromisorFactory.createExtractor override.
|
|
43
40
|
*/
|
|
44
41
|
createExtractor(promisor, extractor) {
|
|
45
|
-
return (
|
|
42
|
+
return createExtractor(fromType(promisor), typeToTransform(extractor));
|
|
46
43
|
}
|
|
47
44
|
static internalCreate() {
|
|
48
45
|
return new PromisorsImpl();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PromisorFactory.impl.js","sourceRoot":"","sources":["../../src/impl/PromisorFactory.impl.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"PromisorFactory.impl.js","sourceRoot":"","sources":["../../src/impl/PromisorFactory.impl.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkC,QAAQ,EAAE,MAAM,sCAAsC,CAAC;AAGhG,OAAO,EAAyB,QAAQ,IAAI,eAAe,EAAE,MAAM,6CAA6C,CAAC;AACjH,OAAO,EAAE,MAAM,IAAI,eAAe,EAAE,MAAM,6BAA6B,CAAC;AACxE,OAAO,EAAE,MAAM,IAAI,eAAe,EAAE,MAAM,6BAA6B,CAAC;AACxE,OAAO,EAAE,MAAM,IAAI,eAAe,EAAE,MAAM,6BAA6B,CAAC;AACxE,OAAO,EAAE,MAAM,IAAI,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAEhE;;;;GAIG;AACH,MAAM,UAAU,MAAM;IACpB,OAAO,aAAa,CAAC,cAAc,EAAE,CAAC;AACxC,CAAC;AAED,yCAAyC;AAEzC;;GAEG;AACH,MAAM,aAAa;IAEjB;;OAEG;IACH,WAAW,CAAI,WAA4B;QACzC,OAAO,WAAW,CAAI,WAAW,CAAC,CAAC;IACrC,CAAC;IAED;;OAEG;IACH,eAAe,CAAI,QAAyB;QAC1C,OAAO,eAAe,CAAI,QAAQ,CAAC,QAAQ,CAAC,CAAC,CAAC;IAChD,CAAC;IAED;;OAEG;IACH,eAAe,CAAI,QAAyB;QAC1C,OAAO,eAAe,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC,CAAC;IAC7C,CAAC;IAED;;OAEG;IACH,eAAe,CAAO,QAAyB,EAAE,SAA8B;QAC7E,OAAO,eAAe,CAAO,QAAQ,CAAC,QAAQ,CAAC,EAAE,eAAe,CAAC,SAAS,CAAC,CAAC,CAAC;IAC/E,CAAC;IAED,MAAM,CAAC,cAAc;QACnB,OAAO,IAAI,aAAa,EAAE,CAAC;IAC7B,CAAC;IAED;IACA,CAAC;CACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Repository.impl.d.ts","sourceRoot":"","sources":["../../src/impl/Repository.impl.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,wCAAwC,CAAC;AAC5E,OAAO,
|
|
1
|
+
{"version":3,"file":"Repository.impl.d.ts","sourceRoot":"","sources":["../../src/impl/Repository.impl.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,wCAAwC,CAAC;AAC5E,OAAO,EAAgB,YAAY,EAAE,MAAM,mCAAmC,CAAC;AAO/E;;;;;GAKG;AACH,wBAAgB,MAAM,CAAC,MAAM,CAAC,EAAE,MAAM,GAAG,YAAY,CAAC,UAAU,CAAC,CAEhE"}
|
package/impl/Repository.impl.js
CHANGED
|
@@ -1,26 +1,23 @@
|
|
|
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");
|
|
5
4
|
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
6
5
|
};
|
|
7
6
|
var _RepositoryImpl_storedContracts, _RepositoryImpl_requiredContracts;
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
const Idempotent_impl_1 = require("./Idempotent.impl");
|
|
16
|
-
const Storage_impl_1 = require("./Storage.impl");
|
|
7
|
+
import { inlineAutoClose } from "@jonloucks/contracts-ts/api/AutoClose";
|
|
8
|
+
import { resolveBindStrategy } from "@jonloucks/contracts-ts/api/BindStrategy";
|
|
9
|
+
import { ContractException } from "@jonloucks/contracts-ts/api/ContractException";
|
|
10
|
+
import { fromType } from "@jonloucks/contracts-ts/api/Promisor";
|
|
11
|
+
import { contractCheck, contractsCheck } from "@jonloucks/contracts-ts/auxiliary/Checks";
|
|
12
|
+
import { create as createIdempotent } from "./Idempotent.impl.js";
|
|
13
|
+
import { StorageImpl } from "./Storage.impl.js";
|
|
17
14
|
/**
|
|
18
15
|
* Factory method to create Repository instance.
|
|
19
16
|
*
|
|
20
17
|
* @param contracts the Contracts instance to be used by the Repository
|
|
21
18
|
* @returns the Repository implementation
|
|
22
19
|
*/
|
|
23
|
-
function create(config) {
|
|
20
|
+
export function create(config) {
|
|
24
21
|
return RepositoryImpl.internalCreate(config);
|
|
25
22
|
}
|
|
26
23
|
// ---- Implementation details below ----
|
|
@@ -44,18 +41,18 @@ class RepositoryImpl {
|
|
|
44
41
|
* Repository.store override.
|
|
45
42
|
*/
|
|
46
43
|
store(contract, promisor, bindStrategy) {
|
|
47
|
-
const validContract =
|
|
48
|
-
const validPromisor = (
|
|
49
|
-
const validBindStrategy =
|
|
44
|
+
const validContract = contractCheck(contract);
|
|
45
|
+
const validPromisor = fromType(promisor);
|
|
46
|
+
const validBindStrategy = resolveBindStrategy(bindStrategy);
|
|
50
47
|
if (__classPrivateFieldGet(this, _RepositoryImpl_storedContracts, "f").has(validContract) && this.idempotent.isOpen()) {
|
|
51
|
-
throw new
|
|
48
|
+
throw new ContractException("The contract " + validContract + " is already stored.");
|
|
52
49
|
}
|
|
53
|
-
const storage = new
|
|
50
|
+
const storage = new StorageImpl(this.contracts, validContract, validPromisor, validBindStrategy);
|
|
54
51
|
if (this.idempotent.isOpen()) {
|
|
55
52
|
storage.bind();
|
|
56
53
|
}
|
|
57
54
|
__classPrivateFieldGet(this, _RepositoryImpl_storedContracts, "f").set(validContract, storage);
|
|
58
|
-
return
|
|
55
|
+
return inlineAutoClose(() => {
|
|
59
56
|
if (__classPrivateFieldGet(this, _RepositoryImpl_storedContracts, "f").get(validContract) === storage) {
|
|
60
57
|
__classPrivateFieldGet(this, _RepositoryImpl_storedContracts, "f").delete(validContract);
|
|
61
58
|
storage.close();
|
|
@@ -66,7 +63,7 @@ class RepositoryImpl {
|
|
|
66
63
|
* Repository.keep override.
|
|
67
64
|
*/
|
|
68
65
|
keep(contract, promisor, bindStrategy) {
|
|
69
|
-
this.store(contract, promisor,
|
|
66
|
+
this.store(contract, promisor, resolveBindStrategy(bindStrategy));
|
|
70
67
|
}
|
|
71
68
|
/**
|
|
72
69
|
* Repository.check override.
|
|
@@ -74,7 +71,7 @@ class RepositoryImpl {
|
|
|
74
71
|
check() {
|
|
75
72
|
__classPrivateFieldGet(this, _RepositoryImpl_requiredContracts, "f").forEach((contract) => {
|
|
76
73
|
if (!this.contracts.isBound(contract)) {
|
|
77
|
-
throw new
|
|
74
|
+
throw new ContractException("The contract " + contract + " is required.");
|
|
78
75
|
}
|
|
79
76
|
});
|
|
80
77
|
}
|
|
@@ -82,7 +79,7 @@ class RepositoryImpl {
|
|
|
82
79
|
* Repository.require override.
|
|
83
80
|
*/
|
|
84
81
|
require(contract) {
|
|
85
|
-
const validContract =
|
|
82
|
+
const validContract = contractCheck(contract);
|
|
86
83
|
__classPrivateFieldGet(this, _RepositoryImpl_requiredContracts, "f").add(validContract);
|
|
87
84
|
}
|
|
88
85
|
/**
|
|
@@ -94,12 +91,12 @@ class RepositoryImpl {
|
|
|
94
91
|
constructor(config) {
|
|
95
92
|
this.id = RepositoryImpl.ID_GENERATOR++;
|
|
96
93
|
_RepositoryImpl_storedContracts.set(this, new Map());
|
|
97
|
-
this.idempotent = (
|
|
94
|
+
this.idempotent = createIdempotent({
|
|
98
95
|
open: () => this.firstOpen()
|
|
99
96
|
});
|
|
100
97
|
_RepositoryImpl_requiredContracts.set(this, new Set());
|
|
101
98
|
const validConfig = config ?? {};
|
|
102
|
-
this.contracts =
|
|
99
|
+
this.contracts = contractsCheck(validConfig.contracts);
|
|
103
100
|
if (validConfig.requiredContracts) {
|
|
104
101
|
validConfig.requiredContracts.forEach((contract) => this.require(contract));
|
|
105
102
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Repository.impl.js","sourceRoot":"","sources":["../../src/impl/Repository.impl.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Repository.impl.js","sourceRoot":"","sources":["../../src/impl/Repository.impl.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAA4B,eAAe,EAAE,MAAM,uCAAuC,CAAC;AAElG,OAAO,EAAgB,mBAAmB,EAAE,MAAM,0CAA0C,CAAC;AAE7F,OAAO,EAAE,iBAAiB,EAAE,MAAM,+CAA+C,CAAC;AAElF,OAAO,EAAkC,QAAQ,EAAE,MAAM,sCAAsC,CAAC;AAGhG,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,0CAA0C,CAAC;AAGzF,OAAO,EAAE,MAAM,IAAI,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAClE,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAEhD;;;;;GAKG;AACH,MAAM,UAAU,MAAM,CAAC,MAAe;IACpC,OAAO,cAAc,CAAC,cAAc,CAAC,MAAM,CAAC,CAAC;AAC/C,CAAC;AAED,yCAAyC;AAEzC;;GAEG;AACH,MAAM,cAAc;IAElB;;OAEG;IACH,QAAQ;QACN,OAAO,IAAI,CAAC,IAAI,EAAE,CAAC;IACrB,CAAC;IAED;;OAEG;IACH,IAAI;QACF,OAAO,IAAI,CAAC,UAAU,CAAC,IAAI,EAAE,CAAC;IAChC,CAAC;IAED;;OAEG;IACH,KAAK,CAAI,QAAqB,EAAE,QAAyB,EAAE,YAA8C;QACvG,MAAM,aAAa,GAAgB,aAAa,CAAC,QAAQ,CAAC,CAAC;QAC3D,MAAM,aAAa,GAAgB,QAAQ,CAAC,QAAQ,CAAC,CAAC;QACtD,MAAM,iBAAiB,GAAiB,mBAAmB,CAAC,YAAY,CAAC,CAAC;QAE1E,IAAI,uBAAA,IAAI,uCAAiB,CAAC,GAAG,CAAC,aAAa,CAAC,IAAI,IA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I,CAAC,OAAO,CAAC,CAAC;QAC7B,CAAC;QACD,IAAI,CAAC;YACH,OAAO,YAAY,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;gBAC/B,YAAY,CAAC,GAAG,EAAG,CAAC,KAAK,EAAE,CAAC;YAC9B,CAAC;QACH,CAAC;gBAAS,CAAC;YACT,uBAAA,IAAI,uCAAiB,CAAC,KAAK,EAAE,CAAC;QAChC,CAAC;IACH,CAAC;IAED,MAAM,CAAC,cAAc,CAAC,MAAe;QACnC,OAAO,IAAI,cAAc,CAAC,MAAM,CAAC,CAAC;IACpC,CAAC;;;AAEc,2BAAY,GAAW,CAAC,AAAZ,CAAa"}
|
|
@@ -1,14 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.create = create;
|
|
4
|
-
const Repository_impl_1 = require("./Repository.impl");
|
|
1
|
+
import { create as createRepository } from "./Repository.impl.js";
|
|
5
2
|
/**
|
|
6
3
|
* Factory method to create a RepositoryFactory
|
|
7
4
|
*
|
|
8
5
|
* @param contracts the Contracts instance to be used by the RepositoryFactory
|
|
9
6
|
* @returns the RepositoryFactory implementation
|
|
10
7
|
*/
|
|
11
|
-
function create(contracts) {
|
|
8
|
+
export function create(contracts) {
|
|
12
9
|
return RepositoryFactoryImpl.internalCreate(contracts);
|
|
13
10
|
}
|
|
14
11
|
// ---- Implementation details below ----
|
|
@@ -21,7 +18,7 @@ class RepositoryFactoryImpl {
|
|
|
21
18
|
if (!validConfig.contracts) {
|
|
22
19
|
validConfig.contracts = this.contracts;
|
|
23
20
|
}
|
|
24
|
-
return (
|
|
21
|
+
return createRepository(validConfig);
|
|
25
22
|
}
|
|
26
23
|
static internalCreate(contracts) {
|
|
27
24
|
return new RepositoryFactoryImpl(contracts);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RepositoryFactory.impl.js","sourceRoot":"","sources":["../../src/impl/RepositoryFactory.impl.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"RepositoryFactory.impl.js","sourceRoot":"","sources":["../../src/impl/RepositoryFactory.impl.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,MAAM,IAAI,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAElE;;;;;GAKG;AACH,MAAM,UAAU,MAAM,CAAC,SAAoB;IACzC,OAAO,qBAAqB,CAAC,cAAc,CAAC,SAAS,CAAC,CAAC;AACzD,CAAC;AAED,yCAAyC;AAEzC;;GAEG;AACH,MAAM,qBAAqB;IAEzB,gBAAgB,CAAC,MAAe;QAC9B,MAAM,WAAW,GAAY,EAAC,GAAG,CAAC,MAAM,IAAI,EAAE,CAAC,EAAC,CAAC;QAEjD,IAAI,CAAC,WAAW,CAAC,SAAS,EAAE,CAAC;YAC3B,WAAW,CAAC,SAAS,GAAG,IAAI,CAAC,SAAS,CAAC;QACzC,CAAC;QAED,OAAO,gBAAgB,CAAC,WAAW,CAAC,CAAC;IACvC,CAAC;IAED,MAAM,CAAC,cAAc,CAAC,SAAoB;QACxC,OAAO,IAAI,qBAAqB,CAAC,SAAS,CAAC,CAAC;IAC9C,CAAC;IAED,YAAoB,SAAoB;QACtC,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;IAC7B,CAAC;CAGF"}
|
|
@@ -1,9 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const Checks_1 = require("@jonloucks/contracts-ts/auxiliary/Checks");
|
|
5
|
-
const AtomicBoolean_impl_1 = require("./AtomicBoolean.impl");
|
|
6
|
-
const AtomicReference_impl_1 = require("./AtomicReference.impl");
|
|
1
|
+
import { promisorCheck } from "@jonloucks/contracts-ts/auxiliary/Checks";
|
|
2
|
+
import { create as createAtomicBoolean } from "./AtomicBoolean.impl.js";
|
|
3
|
+
import { create as createAtomicReference } from "./AtomicReference.impl.js";
|
|
7
4
|
/**
|
|
8
5
|
* Factory method to create an Singleton promisor implementation
|
|
9
6
|
*
|
|
@@ -11,7 +8,7 @@ const AtomicReference_impl_1 = require("./AtomicReference.impl");
|
|
|
11
8
|
* @param <T> the type of deliverable
|
|
12
9
|
* @returns the new Singleton Promisor implementation
|
|
13
10
|
*/
|
|
14
|
-
function create(referent) {
|
|
11
|
+
export function create(referent) {
|
|
15
12
|
return SingletonPromisorImpl.internalCreate(referent);
|
|
16
13
|
}
|
|
17
14
|
// ---- Implementation details below ----
|
|
@@ -36,9 +33,9 @@ class SingletonPromisorImpl {
|
|
|
36
33
|
return new SingletonPromisorImpl(referent);
|
|
37
34
|
}
|
|
38
35
|
constructor(referent) {
|
|
39
|
-
this.singletonRef = (
|
|
40
|
-
this.firstTime = (
|
|
41
|
-
this.referent =
|
|
36
|
+
this.singletonRef = createAtomicReference();
|
|
37
|
+
this.firstTime = createAtomicBoolean(true);
|
|
38
|
+
this.referent = promisorCheck(referent);
|
|
42
39
|
}
|
|
43
40
|
}
|
|
44
41
|
//# sourceMappingURL=SingletonPromisor.impl.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SingletonPromisor.impl.js","sourceRoot":"","sources":["../../src/impl/SingletonPromisor.impl.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"SingletonPromisor.impl.js","sourceRoot":"","sources":["../../src/impl/SingletonPromisor.impl.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,aAAa,EAAE,MAAM,0CAA0C,CAAC;AAEzE,OAAO,EAAE,MAAM,IAAI,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AACxE,OAAO,EAAE,MAAM,IAAI,qBAAqB,EAAE,MAAM,2BAA2B,CAAC;AAE5E;;;;;;GAMG;AACH,MAAM,UAAU,MAAM,CAAI,QAAqB;IAC7C,OAAO,qBAAqB,CAAC,cAAc,CAAI,QAAQ,CAAC,CAAC;AAC3D,CAAC;AAED,yCAAyC;AAEzC;;;GAGG;AACH,MAAM,qBAAqB;IAEzB,MAAM;QACJ,IAAI,IAAI,CAAC,SAAS,CAAC,aAAa,CAAC,IAAI,EAAE,KAAK,CAAC,EAAE,CAAC;YAC9C,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,IAAI,CAAC,QAAQ,CAAC,MAAM,EAAE,CAAC,CAAC;QAChD,CAAC;QACD,OAAO,IAAI,CAAC,YAAY,CAAC,GAAG,EAAE,CAAC;IACjC,CAAC;IAED,cAAc;QACZ,OAAO,IAAI,CAAC,QAAQ,CAAC,cAAc,EAAE,CAAC;IACxC,CAAC;IAED,cAAc;QACZ,OAAO,IAAI,CAAC,QAAQ,CAAC,cAAc,EAAE,CAAC;IACxC,CAAC;IAED,MAAM,CAAC,cAAc,CAAI,QAAqB;QAC5C,OAAO,IAAI,qBAAqB,CAAI,QAAQ,CAAC,CAAC;IAChD,CAAC;IAED,YAAoB,QAAqB;QAKxB,iBAAY,GAAqC,qBAAqB,EAAmB,CAAC;QAC1F,cAAS,GAAkB,mBAAmB,CAAC,IAAI,CAAC,CAAC;QALpE,IAAI,CAAC,QAAQ,GAAG,aAAa,CAAC,QAAQ,CAAC,CAAC;IAC1C,CAAC;CAKF"}
|
package/impl/Storage.impl.js
CHANGED
|
@@ -1,11 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.StorageImpl = void 0;
|
|
4
|
-
const AutoCloseOne_impl_1 = require("./AutoCloseOne.impl");
|
|
1
|
+
import { create as createAutoCloseOne } from "./AutoCloseOne.impl.js";
|
|
5
2
|
// ---- Implementation details below ----
|
|
6
|
-
class StorageImpl {
|
|
3
|
+
export class StorageImpl {
|
|
7
4
|
constructor(contracts, contract, promisor, bindStrategy) {
|
|
8
|
-
this.closeBinding = (
|
|
5
|
+
this.closeBinding = createAutoCloseOne();
|
|
9
6
|
this.contracts = contracts;
|
|
10
7
|
this.contract = contract;
|
|
11
8
|
this.promisor = promisor;
|
|
@@ -22,5 +19,4 @@ class StorageImpl {
|
|
|
22
19
|
this.closeBinding.close();
|
|
23
20
|
}
|
|
24
21
|
}
|
|
25
|
-
exports.StorageImpl = StorageImpl;
|
|
26
22
|
//# sourceMappingURL=Storage.impl.js.map
|
package/impl/Storage.impl.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Storage.impl.js","sourceRoot":"","sources":["../../src/impl/Storage.impl.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Storage.impl.js","sourceRoot":"","sources":["../../src/impl/Storage.impl.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,MAAM,IAAI,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAEtE,yCAAyC;AAEzC,MAAM,OAAO,WAAW;IAEtB,YAAY,SAAoB,EAAE,QAAqB,EAAE,QAA4B,EAAE,YAA0B;QAwBhG,iBAAY,GAAiB,kBAAkB,EAAE,CAAC;QAvBjE,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;QAC3B,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QACzB,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QACzB,IAAI,CAAC,YAAY,GAAG,YAAY,CAAC;IACnC,CAAC;IAED,CAAC,MAAM,CAAC,OAAO,CAAC;QACd,IAAI,CAAC,KAAK,EAAE,CAAC;IACf,CAAC;IAED,IAAI;QACF,IAAI,CAAC,KAAK,EAAE,CAAC;QACb,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC,YAAY,CAAC,CAAC,CAAC;IAC9F,CAAC;IAED,KAAK;QACH,IAAI,CAAC,YAAY,CAAC,KAAK,EAAE,CAAC;IAC5B,CAAC;CAOF"}
|
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.create = create;
|
|
4
1
|
/**
|
|
5
2
|
* Factory method to create an constant value promisor implementation
|
|
6
3
|
*
|
|
@@ -8,7 +5,7 @@ exports.create = create;
|
|
|
8
5
|
* @param <T> the type of deliverable
|
|
9
6
|
* @returns the new constant value Promisor implementation
|
|
10
7
|
*/
|
|
11
|
-
function create(value) {
|
|
8
|
+
export function create(value) {
|
|
12
9
|
return ValuePromisorImpl.internalCreate(value);
|
|
13
10
|
}
|
|
14
11
|
// ---- Implementation details below ----
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ValuePromisor.impl.js","sourceRoot":"","sources":["../../src/impl/ValuePromisor.impl.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"ValuePromisor.impl.js","sourceRoot":"","sources":["../../src/impl/ValuePromisor.impl.ts"],"names":[],"mappings":"AAGA;;;;;;GAMG;AACH,MAAM,UAAU,MAAM,CAAI,KAAsB;IAC9C,OAAO,iBAAiB,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC;AACjD,CAAC;AAED,yCAAyC;AAEzC;;;GAGG;AACH,MAAM,iBAAiB;IAErB,MAAM;QACJ,OAAO,IAAI,CAAC,KAAK,CAAA;IACnB,CAAC;IAED,cAAc;QACZ,OAAO,CAAC,CAAC;IACX,CAAC;IAED,cAAc;QACZ,OAAO,CAAC,CAAC;IACX,CAAC;IAED,MAAM,CAAC,cAAc,CAAI,KAAsB;QAC7C,OAAO,IAAI,iBAAiB,CAAI,KAAK,CAAC,CAAC;IACzC,CAAC;IAED,YAAoB,KAAsB;QACxC,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACnB,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IAC5B,CAAC;CAGF"}
|