@jonloucks/contracts-ts 1.1.0 → 1.2.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/Open.d.ts +14 -2
- package/api/Open.d.ts.map +1 -1
- package/api/Open.js +28 -1
- package/api/Open.js.map +1 -1
- package/auxiliary/Convenience.d.ts +9 -1
- package/auxiliary/Convenience.d.ts.map +1 -1
- package/auxiliary/Convenience.js +11 -0
- package/auxiliary/Convenience.js.map +1 -1
- package/auxiliary/IdempotenState.d.ts +11 -0
- package/auxiliary/IdempotenState.d.ts.map +1 -0
- package/auxiliary/IdempotenState.js +10 -0
- package/auxiliary/IdempotenState.js.map +1 -0
- package/auxiliary/Idempotent.d.ts +38 -0
- package/auxiliary/Idempotent.d.ts.map +1 -0
- package/auxiliary/Idempotent.js +14 -0
- package/auxiliary/Idempotent.js.map +1 -0
- package/auxiliary/IdempotentFactory.d.ts +28 -0
- package/auxiliary/IdempotentFactory.d.ts.map +1 -0
- package/auxiliary/IdempotentFactory.js +23 -0
- package/auxiliary/IdempotentFactory.js.map +1 -0
- package/impl/Contracts.impl.d.ts.map +1 -1
- package/impl/Contracts.impl.js +16 -18
- package/impl/Contracts.impl.js.map +1 -1
- package/impl/ContractsFactory.impl.d.ts.map +1 -1
- package/impl/ContractsFactory.impl.js +3 -0
- package/impl/ContractsFactory.impl.js.map +1 -1
- package/impl/ContractsWrapper.impl.d.ts.map +1 -1
- package/impl/ContractsWrapper.impl.js +20 -26
- package/impl/ContractsWrapper.impl.js.map +1 -1
- package/impl/Events.impl.d.ts +1 -1
- package/impl/Events.impl.d.ts.map +1 -1
- package/impl/Events.impl.js +4 -15
- package/impl/Events.impl.js.map +1 -1
- package/impl/Idempotent.impl.d.ts +5 -5
- package/impl/Idempotent.impl.d.ts.map +1 -1
- package/impl/Idempotent.impl.js +62 -17
- package/impl/Idempotent.impl.js.map +1 -1
- package/impl/IdempotentFactory.impl.d.ts +12 -0
- package/impl/IdempotentFactory.impl.d.ts.map +1 -0
- package/impl/IdempotentFactory.impl.js +25 -0
- package/impl/IdempotentFactory.impl.js.map +1 -0
- package/impl/Repository.impl.d.ts +1 -1
- package/impl/Repository.impl.d.ts.map +1 -1
- package/impl/Repository.impl.js +6 -10
- package/impl/Repository.impl.js.map +1 -1
- package/package.json +2 -2
- package/version.js +1 -1
- package/impl/Idempotent.d.ts +0 -26
- package/impl/Idempotent.d.ts.map +0 -1
- package/impl/Idempotent.js +0 -3
- package/impl/Idempotent.js.map +0 -1
package/api/Open.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { AutoClose } from "
|
|
2
|
-
import {
|
|
1
|
+
import { AutoClose, AutoCloseType } from "@jonloucks/contracts-ts/api/AutoClose";
|
|
2
|
+
import { AutoOpen } from "@jonloucks/contracts-ts/api/AutoOpen";
|
|
3
|
+
import { RequiredType } from "@jonloucks/contracts-ts/api/AutoCloseFactory";
|
|
3
4
|
/**
|
|
4
5
|
* Interface representing an entity that can be opened, returning an AutoClose mechanism.
|
|
5
6
|
*/
|
|
@@ -10,6 +11,10 @@ export interface Open {
|
|
|
10
11
|
*/
|
|
11
12
|
open(): AutoClose;
|
|
12
13
|
}
|
|
14
|
+
/**
|
|
15
|
+
* The type used to open an Idempotent
|
|
16
|
+
*/
|
|
17
|
+
export type OpenType = AutoOpen | Open | (() => AutoCloseType);
|
|
13
18
|
/**
|
|
14
19
|
* Duck-typing check for Open interface.
|
|
15
20
|
*
|
|
@@ -17,4 +22,11 @@ export interface Open {
|
|
|
17
22
|
* @returns true if the value implements Open, false otherwise
|
|
18
23
|
*/
|
|
19
24
|
export declare function guard(value: unknown): value is RequiredType<Open>;
|
|
25
|
+
/**
|
|
26
|
+
* Convert an OpenType to an Open instance.
|
|
27
|
+
*
|
|
28
|
+
* @param type the OpenType to convert
|
|
29
|
+
* @return the Open instance
|
|
30
|
+
*/
|
|
31
|
+
export declare function typeToOpen(type: OpenType): Open;
|
|
20
32
|
//# sourceMappingURL=Open.d.ts.map
|
package/api/Open.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Open.d.ts","sourceRoot":"","sources":["../../src/api/Open.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"Open.d.ts","sourceRoot":"","sources":["../../src/api/Open.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,aAAa,EAAmB,MAAM,uCAAuC,CAAC;AAClG,OAAO,EAAE,QAAQ,EAA0B,MAAM,sCAAsC,CAAC;AAExF,OAAO,EAAE,YAAY,EAAE,MAAM,8CAA8C,CAAC;AAE5E;;GAEG;AACH,MAAM,WAAW,IAAI;IAEnB;;;OAGG;IACH,IAAI,IAAI,SAAS,CAAC;CACnB;AAED;;GAEG;AACH,MAAM,MAAM,QAAQ,GAAG,QAAQ,GAAG,IAAI,GAAG,CAAC,MAAM,aAAa,CAAC,CAAC;AAE/D;;;;;GAKG;AACH,wBAAgB,KAAK,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,YAAY,CAAC,IAAI,CAAC,CAEjE;AAED;;;;;GAKG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,QAAQ,GAAG,IAAI,CAc/C"}
|
package/api/Open.js
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.guard = guard;
|
|
4
|
-
|
|
4
|
+
exports.typeToOpen = typeToOpen;
|
|
5
|
+
const AutoClose_1 = require("@jonloucks/contracts-ts/api/AutoClose");
|
|
6
|
+
const AutoOpen_1 = require("@jonloucks/contracts-ts/api/AutoOpen");
|
|
7
|
+
const Types_1 = require("@jonloucks/contracts-ts/api/Types");
|
|
5
8
|
/**
|
|
6
9
|
* Duck-typing check for Open interface.
|
|
7
10
|
*
|
|
@@ -11,4 +14,28 @@ const Types_1 = require("./Types");
|
|
|
11
14
|
function guard(value) {
|
|
12
15
|
return (0, Types_1.guardFunctions)(value, 'open');
|
|
13
16
|
}
|
|
17
|
+
/**
|
|
18
|
+
* Convert an OpenType to an Open instance.
|
|
19
|
+
*
|
|
20
|
+
* @param type the OpenType to convert
|
|
21
|
+
* @return the Open instance
|
|
22
|
+
*/
|
|
23
|
+
function typeToOpen(type) {
|
|
24
|
+
if ((0, AutoOpen_1.guard)(type)) {
|
|
25
|
+
return {
|
|
26
|
+
open: () => type.autoOpen()
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
else if (guard(type)) {
|
|
30
|
+
return type;
|
|
31
|
+
}
|
|
32
|
+
else if ((0, Types_1.isFunction)(type)) {
|
|
33
|
+
return {
|
|
34
|
+
open: () => (0, AutoClose_1.typeToAutoClose)(type())
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
else {
|
|
38
|
+
throw new Error("Invalid Open type.");
|
|
39
|
+
}
|
|
40
|
+
}
|
|
14
41
|
//# sourceMappingURL=Open.js.map
|
package/api/Open.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Open.js","sourceRoot":"","sources":["../../src/api/Open.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"Open.js","sourceRoot":"","sources":["../../src/api/Open.ts"],"names":[],"mappings":";;AA4BA,sBAEC;AAQD,gCAcC;AApDD,qEAAkG;AAClG,mEAAwF;AACxF,6DAA+E;AAoB/E;;;;;GAKG;AACH,SAAgB,KAAK,CAAC,KAAc;IAClC,OAAO,IAAA,sBAAc,EAAC,KAAK,EAAE,MAAM,CAAC,CAAC;AACvC,CAAC;AAED;;;;;GAKG;AACH,SAAgB,UAAU,CAAC,IAAc;IACvC,IAAI,IAAA,gBAAa,EAAC,IAAI,CAAC,EAAE,CAAC;QACxB,OAAO;YACL,IAAI,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,QAAQ,EAAE;SAC5B,CAAA;IACH,CAAC;SAAM,IAAI,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC;QACvB,OAAO,IAAI,CAAC;IACd,CAAC;SAAM,IAAI,IAAA,kBAAU,EAAC,IAAI,CAAC,EAAE,CAAC;QAC5B,OAAO;YACL,IAAI,EAAE,GAAG,EAAE,CAAC,IAAA,2BAAe,EAAC,IAAI,EAAE,CAAC;SACpC,CAAC;IACJ,CAAC;SAAM,CAAC;QACN,MAAM,IAAI,KAAK,CAAC,oBAAoB,CAAC,CAAC;IACxC,CAAC;AACH,CAAC"}
|
|
@@ -2,7 +2,8 @@ import { RequiredType } from "@jonloucks/contracts-ts/api/Types";
|
|
|
2
2
|
import { AtomicBoolean } from "@jonloucks/contracts-ts/auxiliary/AtomicBoolean";
|
|
3
3
|
import { AtomicReference } from "@jonloucks/contracts-ts/auxiliary/AtomicReference";
|
|
4
4
|
import { AtomicInteger } from "@jonloucks/contracts-ts/auxiliary/AtomicInteger";
|
|
5
|
-
|
|
5
|
+
import { Idempotent, Config as IdempotentConfig } from "@jonloucks/contracts-ts/auxiliary/Idempotent";
|
|
6
|
+
export { AtomicBoolean, AtomicReference, AtomicInteger, RequiredType, Idempotent, IdempotentConfig };
|
|
6
7
|
/**
|
|
7
8
|
* @module Convenience
|
|
8
9
|
* @description
|
|
@@ -37,4 +38,11 @@ export declare function createAtomicReference<T>(initialValue?: T): RequiredType
|
|
|
37
38
|
* @returns the AtomicInteger instance
|
|
38
39
|
*/
|
|
39
40
|
export declare function createAtomicInteger(initialValue?: number): RequiredType<AtomicInteger>;
|
|
41
|
+
/**
|
|
42
|
+
* Create an Idempotent via the shared global CONTRACTS instance.
|
|
43
|
+
*
|
|
44
|
+
* @param config the idempotent configuration
|
|
45
|
+
* @returns the Idempotent instance
|
|
46
|
+
*/
|
|
47
|
+
export declare function createIdempotent(config: IdempotentConfig): RequiredType<Idempotent>;
|
|
40
48
|
//# sourceMappingURL=Convenience.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Convenience.d.ts","sourceRoot":"","sources":["../../src/auxiliary/Convenience.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,mCAAmC,CAAC;
|
|
1
|
+
{"version":3,"file":"Convenience.d.ts","sourceRoot":"","sources":["../../src/auxiliary/Convenience.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,mCAAmC,CAAC;AAMjE,OAAO,EAAE,aAAa,EAAE,MAAM,iDAAiD,CAAC;AAChF,OAAO,EAAE,eAAe,EAAE,MAAM,mDAAmD,CAAC;AACpF,OAAO,EAAE,aAAa,EAAE,MAAM,iDAAiD,CAAC;AAChF,OAAO,EAAE,UAAU,EAAE,MAAM,IAAI,gBAAgB,EAAE,MAAM,8CAA8C,CAAC;AAEtG,OAAO,EAAE,aAAa,EAAG,eAAe,EAAE,aAAa,EAAE,YAAY,EAAE,UAAU,EAAE,gBAAgB,EAAE,CAAC;AAEtG;;;;;;;;;;;;GAYG;AAEH;;;;;GAKG;AACH,wBAAgB,mBAAmB,CAAC,YAAY,CAAC,EAAE,OAAO,GAAG,YAAY,CAAC,aAAa,CAAC,CAEvF;AAED;;;;;GAKG;AACH,wBAAgB,qBAAqB,CAAC,CAAC,EAAE,YAAY,CAAC,EAAE,CAAC,GAAG,YAAY,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC,CAE3F;AAED;;;;;GAKG;AACH,wBAAgB,mBAAmB,CAAC,YAAY,CAAC,EAAE,MAAM,GAAG,YAAY,CAAC,aAAa,CAAC,CAEtF;AAED;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,gBAAgB,GAAG,YAAY,CAAC,UAAU,CAAC,CAEnF"}
|
package/auxiliary/Convenience.js
CHANGED
|
@@ -3,10 +3,12 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.createAtomicBoolean = createAtomicBoolean;
|
|
4
4
|
exports.createAtomicReference = createAtomicReference;
|
|
5
5
|
exports.createAtomicInteger = createAtomicInteger;
|
|
6
|
+
exports.createIdempotent = createIdempotent;
|
|
6
7
|
const contracts_ts_1 = require("@jonloucks/contracts-ts");
|
|
7
8
|
const AtomicBooleanFactory_1 = require("@jonloucks/contracts-ts/auxiliary/AtomicBooleanFactory");
|
|
8
9
|
const AtomicReferenceFactory_1 = require("@jonloucks/contracts-ts/auxiliary/AtomicReferenceFactory");
|
|
9
10
|
const AtomicIntegerFactory_1 = require("@jonloucks/contracts-ts/auxiliary/AtomicIntegerFactory");
|
|
11
|
+
const IdempotentFactory_1 = require("@jonloucks/contracts-ts/auxiliary/IdempotentFactory");
|
|
10
12
|
/**
|
|
11
13
|
* @module Convenience
|
|
12
14
|
* @description
|
|
@@ -47,4 +49,13 @@ function createAtomicReference(initialValue) {
|
|
|
47
49
|
function createAtomicInteger(initialValue) {
|
|
48
50
|
return contracts_ts_1.CONTRACTS.enforce(AtomicIntegerFactory_1.CONTRACT).createAtomicInteger(initialValue);
|
|
49
51
|
}
|
|
52
|
+
/**
|
|
53
|
+
* Create an Idempotent via the shared global CONTRACTS instance.
|
|
54
|
+
*
|
|
55
|
+
* @param config the idempotent configuration
|
|
56
|
+
* @returns the Idempotent instance
|
|
57
|
+
*/
|
|
58
|
+
function createIdempotent(config) {
|
|
59
|
+
return contracts_ts_1.CONTRACTS.enforce(IdempotentFactory_1.CONTRACT).createIdempotent(config);
|
|
60
|
+
}
|
|
50
61
|
//# sourceMappingURL=Convenience.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Convenience.js","sourceRoot":"","sources":["../../src/auxiliary/Convenience.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"Convenience.js","sourceRoot":"","sources":["../../src/auxiliary/Convenience.ts"],"names":[],"mappings":";;AAiCA,kDAEC;AAQD,sDAEC;AAQD,kDAEC;AAQD,4CAEC;AAhED,0DAAoD;AACpD,iGAAqG;AACrG,qGAAyG;AACzG,iGAAqG;AACrG,2FAAqG;AAQrG;;;;;;;;;;;;GAYG;AAEH;;;;;GAKG;AACH,SAAgB,mBAAmB,CAAC,YAAsB;IACxD,OAAO,wBAAS,CAAC,OAAO,CAAC,+BAAe,CAAC,CAAC,mBAAmB,CAAC,YAAY,CAAC,CAAC;AAC9E,CAAC;AAED;;;;;GAKG;AACH,SAAgB,qBAAqB,CAAI,YAAgB;IACvD,OAAO,wBAAS,CAAC,OAAO,CAAC,iCAAiB,CAAC,CAAC,qBAAqB,CAAC,YAAY,CAAC,CAAC;AAClF,CAAC;AAED;;;;;GAKG;AACH,SAAgB,mBAAmB,CAAC,YAAqB;IACvD,OAAO,wBAAS,CAAC,OAAO,CAAC,+BAAe,CAAC,CAAC,mBAAmB,CAAC,YAAY,CAAC,CAAC;AAC9E,CAAC;AAED;;;;;GAKG;AACH,SAAgB,gBAAgB,CAAC,MAAwB;IACvD,OAAO,wBAAS,CAAC,OAAO,CAAC,4BAAkB,CAAC,CAAC,gBAAgB,CAAC,MAAM,CAAC,CAAC;AACxE,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The possible states of an Idempotent
|
|
3
|
+
*/
|
|
4
|
+
export declare const STATES: readonly ["OPENABLE", "OPENING", "OPENED", "CLOSING", "CLOSED", "DESTROYED"];
|
|
5
|
+
/** The possible states of an Idempotent */
|
|
6
|
+
export type State = typeof STATES[number];
|
|
7
|
+
/** The IdempotentState type */
|
|
8
|
+
export { State as IdempotentState };
|
|
9
|
+
/** The starting state for an Idempotent */
|
|
10
|
+
export declare const START_STATE: State;
|
|
11
|
+
//# sourceMappingURL=IdempotenState.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"IdempotenState.d.ts","sourceRoot":"","sources":["../../src/auxiliary/IdempotenState.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,eAAO,MAAM,MAAM,8EAA+E,CAAC;AAEnG,2CAA2C;AAC3C,MAAM,MAAM,KAAK,GAAG,OAAO,MAAM,CAAC,MAAM,CAAC,CAAC;AAE1C,+BAA+B;AAC/B,OAAO,EAAE,KAAK,IAAI,eAAe,EAAE,CAAC;AAEpC,2CAA2C;AAC3C,eAAO,MAAM,WAAW,EAAE,KAAkB,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.START_STATE = exports.STATES = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* The possible states of an Idempotent
|
|
6
|
+
*/
|
|
7
|
+
exports.STATES = ['OPENABLE', 'OPENING', 'OPENED', 'CLOSING', 'CLOSED', 'DESTROYED'];
|
|
8
|
+
/** The starting state for an Idempotent */
|
|
9
|
+
exports.START_STATE = 'OPENABLE';
|
|
10
|
+
//# sourceMappingURL=IdempotenState.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"IdempotenState.js","sourceRoot":"","sources":["../../src/auxiliary/IdempotenState.ts"],"names":[],"mappings":";;;AAAA;;GAEG;AACU,QAAA,MAAM,GAAG,CAAC,UAAU,EAAE,SAAS,EAAE,QAAQ,EAAE,SAAS,EAAE,QAAQ,EAAE,WAAW,CAAU,CAAC;AAQnG,2CAA2C;AAC9B,QAAA,WAAW,GAAU,UAAU,CAAC"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { Open, OpenType } from "@jonloucks/contracts-ts/api/Open";
|
|
2
|
+
import { State } from "@jonloucks/contracts-ts/auxiliary/IdempotenState";
|
|
3
|
+
import { Contracts } from "@jonloucks/contracts-ts/api/Contracts";
|
|
4
|
+
import { RequiredType } from "@jonloucks/contracts-ts/api/Types";
|
|
5
|
+
/**
|
|
6
|
+
* The configuration used to create a new Idempotent instance
|
|
7
|
+
*/
|
|
8
|
+
export interface Config {
|
|
9
|
+
/** The Contracts instance to use */
|
|
10
|
+
contracts?: Contracts;
|
|
11
|
+
/** The Open type to use when opening the Idempotent */
|
|
12
|
+
open: OpenType;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* The Idempotent API
|
|
16
|
+
*/
|
|
17
|
+
export interface Idempotent extends Open {
|
|
18
|
+
/**
|
|
19
|
+
* Get the current state of the Idempotent
|
|
20
|
+
*
|
|
21
|
+
* @return the current state
|
|
22
|
+
*/
|
|
23
|
+
getState(): State;
|
|
24
|
+
/**
|
|
25
|
+
* Determine if the Idempotent is open
|
|
26
|
+
*
|
|
27
|
+
* @return true if the Idempotent is open
|
|
28
|
+
*/
|
|
29
|
+
isOpen(): boolean;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Determine if an instance implements Idempotent
|
|
33
|
+
*
|
|
34
|
+
* @param instance the instance to check
|
|
35
|
+
* @returns true if the instance implements Idempotent
|
|
36
|
+
*/
|
|
37
|
+
export declare function guard(instance: unknown): instance is RequiredType<Idempotent>;
|
|
38
|
+
//# sourceMappingURL=Idempotent.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Idempotent.d.ts","sourceRoot":"","sources":["../../src/auxiliary/Idempotent.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,kCAAkC,CAAC;AAClE,OAAO,EAAE,KAAK,EAAE,MAAM,kDAAkD,CAAC;AACzE,OAAO,EAAE,SAAS,EAAE,MAAM,uCAAuC,CAAC;AAClE,OAAO,EAAkB,YAAY,EAAE,MAAM,mCAAmC,CAAC;AAEjF;;GAEG;AACH,MAAM,WAAW,MAAM;IAErB,oCAAoC;IACpC,SAAS,CAAC,EAAE,SAAS,CAAC;IAEtB,uDAAuD;IACvD,IAAI,EAAE,QAAQ,CAAC;CAChB;AAED;;GAEG;AACH,MAAM,WAAW,UAAW,SAAQ,IAAI;IAEtC;;;;OAIG;IACH,QAAQ,IAAI,KAAK,CAAC;IAElB;;;;OAIG;IACH,MAAM,IAAI,OAAO,CAAC;CACnB;AAED;;;;;GAKG;AACH,wBAAgB,KAAK,CAAC,QAAQ,EAAE,OAAO,GAAG,QAAQ,IAAI,YAAY,CAAC,UAAU,CAAC,CAM7E"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.guard = guard;
|
|
4
|
+
const Types_1 = require("@jonloucks/contracts-ts/api/Types");
|
|
5
|
+
/**
|
|
6
|
+
* Determine if an instance implements Idempotent
|
|
7
|
+
*
|
|
8
|
+
* @param instance the instance to check
|
|
9
|
+
* @returns true if the instance implements Idempotent
|
|
10
|
+
*/
|
|
11
|
+
function guard(instance) {
|
|
12
|
+
return (0, Types_1.guardFunctions)(instance, 'getState', 'open', 'isOpen');
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=Idempotent.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Idempotent.js","sourceRoot":"","sources":["../../src/auxiliary/Idempotent.ts"],"names":[],"mappings":";;AA2CA,sBAMC;AA9CD,6DAAiF;AAkCjF;;;;;GAKG;AACH,SAAgB,KAAK,CAAC,QAAiB;IACrC,OAAO,IAAA,sBAAc,EAAC,QAAQ,EAC5B,UAAU,EACV,MAAM,EACN,QAAQ,CACT,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { Contract } from "@jonloucks/contracts-ts/api/Contract";
|
|
2
|
+
import { RequiredType } from "@jonloucks/contracts-ts/api/Types";
|
|
3
|
+
import { Idempotent, Config } from "@jonloucks/contracts-ts/auxiliary/Idempotent";
|
|
4
|
+
/**
|
|
5
|
+
* Idempotent Factory
|
|
6
|
+
*/
|
|
7
|
+
export interface IdempotentFactory {
|
|
8
|
+
/**
|
|
9
|
+
* Create a new {@link Idempotent} using the provided configuration.
|
|
10
|
+
*
|
|
11
|
+
* @param config configuration for the idempotent; invalid or null/undefined values are not allowed
|
|
12
|
+
* @returns an {@link Idempotent} instance created from the given configuration
|
|
13
|
+
* @throws Error if the configuration is invalid or the idempotent cannot be created
|
|
14
|
+
*/
|
|
15
|
+
createIdempotent(config: Config): RequiredType<Idempotent>;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Determine if the given instance is a IdempotentFactory
|
|
19
|
+
*
|
|
20
|
+
* @param instance the instance to check
|
|
21
|
+
* @return true if the instance is a IdempotentFactory
|
|
22
|
+
*/
|
|
23
|
+
export declare function guard(instance: unknown): instance is RequiredType<IdempotentFactory>;
|
|
24
|
+
/**
|
|
25
|
+
* Contract for IdempotentFactory
|
|
26
|
+
*/
|
|
27
|
+
export declare const CONTRACT: Contract<IdempotentFactory>;
|
|
28
|
+
//# sourceMappingURL=IdempotentFactory.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"IdempotentFactory.d.ts","sourceRoot":"","sources":["../../src/auxiliary/IdempotentFactory.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,sCAAsC,CAAC;AAChE,OAAO,EAAE,YAAY,EAAkB,MAAM,mCAAmC,CAAC;AACjF,OAAO,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,8CAA8C,CAAC;AAElF;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAEhC;;;;;;OAMG;IACH,gBAAgB,CAAC,MAAM,EAAE,MAAM,GAAG,YAAY,CAAC,UAAU,CAAC,CAAC;CAC5D;AAED;;;;;GAKG;AACH,wBAAgB,KAAK,CAAC,QAAQ,EAAE,OAAO,GAAG,QAAQ,IAAI,YAAY,CAAC,iBAAiB,CAAC,CAEpF;AAED;;GAEG;AACH,eAAO,MAAM,QAAQ,EAAE,QAAQ,CAAC,iBAAiB,CAG/C,CAAC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CONTRACT = void 0;
|
|
4
|
+
exports.guard = guard;
|
|
5
|
+
const RatifiedContract_1 = require("@jonloucks/contracts-ts/api/RatifiedContract");
|
|
6
|
+
const Types_1 = require("@jonloucks/contracts-ts/api/Types");
|
|
7
|
+
/**
|
|
8
|
+
* Determine if the given instance is a IdempotentFactory
|
|
9
|
+
*
|
|
10
|
+
* @param instance the instance to check
|
|
11
|
+
* @return true if the instance is a IdempotentFactory
|
|
12
|
+
*/
|
|
13
|
+
function guard(instance) {
|
|
14
|
+
return (0, Types_1.guardFunctions)(instance, 'createIdempotent');
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Contract for IdempotentFactory
|
|
18
|
+
*/
|
|
19
|
+
exports.CONTRACT = (0, RatifiedContract_1.create)({
|
|
20
|
+
name: "IdempotentFactory",
|
|
21
|
+
test: guard
|
|
22
|
+
});
|
|
23
|
+
//# sourceMappingURL=IdempotentFactory.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"IdempotentFactory.js","sourceRoot":"","sources":["../../src/auxiliary/IdempotentFactory.ts"],"names":[],"mappings":";;;AA0BA,sBAEC;AA5BD,mFAAwF;AAExF,6DAAiF;AAkBjF;;;;;GAKG;AACH,SAAgB,KAAK,CAAC,QAAiB;IACrC,OAAO,IAAA,sBAAc,EAAC,QAAQ,EAAE,kBAAkB,CAAC,CAAC;AACtD,CAAC;AAED;;GAEG;AACU,QAAA,QAAQ,GAAgC,IAAA,yBAAc,EAAC;IAClE,IAAI,EAAE,mBAAmB;IACzB,IAAI,EAAE,KAAK;CACZ,CAAC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Contracts.impl.d.ts","sourceRoot":"","sources":["../../src/impl/Contracts.impl.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,uCAAuC,CAAC;AAE1E,OAAO,EAAgB,YAAY,EAAa,MAAM,mCAAmC,CAAC;
|
|
1
|
+
{"version":3,"file":"Contracts.impl.d.ts","sourceRoot":"","sources":["../../src/impl/Contracts.impl.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,uCAAuC,CAAC;AAE1E,OAAO,EAAgB,YAAY,EAAa,MAAM,mCAAmC,CAAC;AAY1F;;;;;GAKG;AACH,wBAAgB,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,YAAY,CAAC,SAAS,CAAC,CAE9D"}
|
package/impl/Contracts.impl.js
CHANGED
|
@@ -14,8 +14,9 @@ const Promisor_1 = require("@jonloucks/contracts-ts/api/Promisor");
|
|
|
14
14
|
const Types_1 = require("@jonloucks/contracts-ts/api/Types");
|
|
15
15
|
const Checks_1 = require("@jonloucks/contracts-ts/auxiliary/Checks");
|
|
16
16
|
const AutoCloseMany_impl_1 = require("./AutoCloseMany.impl");
|
|
17
|
-
const Events_impl_1 = require("./Events.impl");
|
|
18
17
|
const Idempotent_impl_1 = require("./Idempotent.impl");
|
|
18
|
+
const AtomicBoolean_impl_1 = require("./AtomicBoolean.impl");
|
|
19
|
+
const Events_impl_1 = require("./Events.impl");
|
|
19
20
|
const Internal_impl_1 = require("./Internal.impl");
|
|
20
21
|
const Policy_impl_1 = require("./Policy.impl");
|
|
21
22
|
/**
|
|
@@ -42,10 +43,7 @@ class ContractsImpl {
|
|
|
42
43
|
* Open.open override.
|
|
43
44
|
*/
|
|
44
45
|
open() {
|
|
45
|
-
|
|
46
|
-
return this.firstOpen();
|
|
47
|
-
}
|
|
48
|
-
return AutoClose_1.AUTO_CLOSE_NONE;
|
|
46
|
+
return this.idempotent.open();
|
|
49
47
|
}
|
|
50
48
|
/**
|
|
51
49
|
* Contracts.claim override.
|
|
@@ -101,18 +99,19 @@ class ContractsImpl {
|
|
|
101
99
|
}
|
|
102
100
|
firstOpen() {
|
|
103
101
|
this.closeMany.add(this.events.open());
|
|
104
|
-
return (
|
|
102
|
+
return () => this.closeFirstOpen();
|
|
105
103
|
}
|
|
106
104
|
closeFirstOpen() {
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
this.closeMany.close();
|
|
113
|
-
}
|
|
105
|
+
try {
|
|
106
|
+
this.attemptToCloseBindings();
|
|
107
|
+
}
|
|
108
|
+
finally {
|
|
109
|
+
this.closeMany.close();
|
|
114
110
|
}
|
|
115
111
|
}
|
|
112
|
+
shutdown() {
|
|
113
|
+
this.closeFirstOpen();
|
|
114
|
+
}
|
|
116
115
|
attemptToCloseBindings() {
|
|
117
116
|
const MAX_RETRIES = 6;
|
|
118
117
|
let iterations = 0;
|
|
@@ -169,10 +168,9 @@ class ContractsImpl {
|
|
|
169
168
|
if ((0, Types_1.isPresent)(previousPromisor)) {
|
|
170
169
|
previousPromisor.decrementUsage();
|
|
171
170
|
}
|
|
172
|
-
const breakBindingOnce = (0,
|
|
173
|
-
breakBindingOnce.transitionToOpen();
|
|
171
|
+
const breakBindingOnce = (0, AtomicBoolean_impl_1.create)(true);
|
|
174
172
|
return (0, AutoClose_1.inlineAutoClose)(() => {
|
|
175
|
-
if (breakBindingOnce.
|
|
173
|
+
if (breakBindingOnce.compareAndSet(true, false)) {
|
|
176
174
|
this.breakBinding(contract, promisor);
|
|
177
175
|
}
|
|
178
176
|
});
|
|
@@ -233,7 +231,7 @@ class ContractsImpl {
|
|
|
233
231
|
}
|
|
234
232
|
constructor(config) {
|
|
235
233
|
this.closeMany = (0, AutoCloseMany_impl_1.create)();
|
|
236
|
-
this.idempotent = (0, Idempotent_impl_1.create)();
|
|
234
|
+
this.idempotent = (0, Idempotent_impl_1.create)({ open: () => this.firstOpen() });
|
|
237
235
|
_ContractsImpl_promisorMap.set(this, new Map());
|
|
238
236
|
this.partners = [];
|
|
239
237
|
const validConfig = (0, Checks_1.configCheck)(config);
|
|
@@ -241,7 +239,7 @@ class ContractsImpl {
|
|
|
241
239
|
this.policy = (0, Policy_impl_1.create)(validConfig);
|
|
242
240
|
this.events = (0, Events_impl_1.create)({
|
|
243
241
|
names: validConfig?.shutdownEvents ?? [],
|
|
244
|
-
callback: () => this.
|
|
242
|
+
callback: () => this.shutdown()
|
|
245
243
|
});
|
|
246
244
|
if ((0, Types_1.isPresent)(validPartners)) {
|
|
247
245
|
this.partners.push(...validPartners);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Contracts.impl.js","sourceRoot":"","sources":["../../src/impl/Contracts.impl.ts"],"names":[],"mappings":";;;;;;;;
|
|
1
|
+
{"version":3,"file":"Contracts.impl.js","sourceRoot":"","sources":["../../src/impl/Contracts.impl.ts"],"names":[],"mappings":";;;;;;;;AAyBA,wBAEC;AA3BD,qEAAmH;AAEnH,2EAA+G;AAE/G,qFAAkF;AAElF,mEAA8F;AAC9F,6DAA0F;AAC1F,qEAAoG;AAIpG,6DAAoF;AACpF,uDAA+D;AAC/D,6DAAqE;AACrE,+CAA+D;AAC/D,mDAA2C;AAC3C,+CAA+D;AAE/D;;;;;GAKG;AACH,SAAgB,MAAM,CAAC,MAAc;IACnC,OAAO,aAAa,CAAC,cAAc,CAAC,MAAM,CAAC,CAAC;AAC9C,CAAC;AAED,yCAAyC;AAEzC;;GAEG;AACH,MAAM,aAAa;IAEjB;;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;QAC5B,MAAM,aAAa,GAAgB,IAAA,sBAAa,EAAC,QAAQ,CAAC,CAAC;QAC3D,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC,aAAa,CAAC,CAAC;QACzC,MAAM,QAAQ,GAA8B,IAAI,CAAC,kBAAkB,CAAC,aAAa,CAAC,CAAC;QAEnF,IAAI,IAAA,iBAAS,EAAC,QAAQ,CAAC,EAAE,CAAC;YACxB,OAAO,aAAa,CAAC,IAAI,CAAC,QAAQ,CAAC,MAAM,EAAE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AC,CAAC;QACxC,IAAI,CAAC,MAAM,GAAG,IAAA,oBAAY,EAAC;YACzB,KAAK,EAAE,WAAW,EAAE,cAAc,IAAI,EAAE;YACxC,QAAQ,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,QAAQ,EAAE;SAChC,CAAC,CAAC;QAEH,IAAI,IAAA,iBAAS,EAAC,aAAa,CAAC,EAAE,CAAC;YAC7B,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,GAAG,aAAa,CAAC,CAAC;QACvC,CAAC;IACH,CAAC;CAQF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ContractsFactory.impl.d.ts","sourceRoot":"","sources":["../../src/impl/ContractsFactory.impl.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,IAAI,eAAe,EAAE,MAAM,uCAAuC,CAAC;AAC7F,OAAO,EAAE,gBAAgB,EAAE,MAAM,8CAA8C,CAAC;AAIhF,OAAO,EAAE,YAAY,EAAE,MAAM,mCAAmC,CAAC;
|
|
1
|
+
{"version":3,"file":"ContractsFactory.impl.d.ts","sourceRoot":"","sources":["../../src/impl/ContractsFactory.impl.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,IAAI,eAAe,EAAE,MAAM,uCAAuC,CAAC;AAC7F,OAAO,EAAE,gBAAgB,EAAE,MAAM,8CAA8C,CAAC;AAIhF,OAAO,EAAE,YAAY,EAAE,MAAM,mCAAmC,CAAC;AAgBjE;;;;GAIG;AACH,wBAAgB,MAAM,IAAI,YAAY,CAAC,gBAAgB,CAAC,CAEvD;AAED;;;;;GAKG;AACH,wBAAgB,eAAe,CAAC,MAAM,CAAC,EAAE,eAAe,GAAG,YAAY,CAAC,SAAS,CAAC,CAEjF"}
|
|
@@ -8,6 +8,7 @@ const RepositoryFactory_1 = require("@jonloucks/contracts-ts/api/RepositoryFacto
|
|
|
8
8
|
const AtomicBooleanFactory_1 = require("@jonloucks/contracts-ts/auxiliary/AtomicBooleanFactory");
|
|
9
9
|
const AtomicIntegerFactory_1 = require("@jonloucks/contracts-ts/auxiliary/AtomicIntegerFactory");
|
|
10
10
|
const AtomicReferenceFactory_1 = require("@jonloucks/contracts-ts/auxiliary/AtomicReferenceFactory");
|
|
11
|
+
const IdempotentFactory_1 = require("@jonloucks/contracts-ts/auxiliary/IdempotentFactory");
|
|
11
12
|
const AtomicBooleanFactory_impl_1 = require("./AtomicBooleanFactory.impl");
|
|
12
13
|
const AtomicIntegerFactory_impl_1 = require("./AtomicIntegerFactory.impl");
|
|
13
14
|
const AtomicReferenceFactory_impl_1 = require("./AtomicReferenceFactory.impl");
|
|
@@ -16,6 +17,7 @@ const Contracts_impl_1 = require("./Contracts.impl");
|
|
|
16
17
|
const ContractsWrapper_impl_1 = require("./ContractsWrapper.impl");
|
|
17
18
|
const PromisorFactory_impl_1 = require("./PromisorFactory.impl");
|
|
18
19
|
const RepositoryFactory_impl_1 = require("./RepositoryFactory.impl");
|
|
20
|
+
const IdempotentFactory_impl_1 = require("./IdempotentFactory.impl");
|
|
19
21
|
/**
|
|
20
22
|
* Factory method to create a ContractsFactory
|
|
21
23
|
*
|
|
@@ -53,6 +55,7 @@ class ContractsFactoryImpl {
|
|
|
53
55
|
createKernelRepository(contracts) {
|
|
54
56
|
const repositoryFactory = (0, RepositoryFactory_impl_1.create)(contracts);
|
|
55
57
|
const repository = repositoryFactory.createRepository();
|
|
58
|
+
repository.keep(IdempotentFactory_1.CONTRACT, IdempotentFactory_impl_1.create);
|
|
56
59
|
repository.keep(PromisorFactory_1.CONTRACT, PromisorFactory_impl_1.create);
|
|
57
60
|
repository.keep(RepositoryFactory_1.CONTRACT, () => repositoryFactory);
|
|
58
61
|
repository.keep(AtomicBooleanFactory_1.CONTRACT, AtomicBooleanFactory_impl_1.create);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ContractsFactory.impl.js","sourceRoot":"","sources":["../../src/impl/ContractsFactory.impl.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"ContractsFactory.impl.js","sourceRoot":"","sources":["../../src/impl/ContractsFactory.impl.ts"],"names":[],"mappings":";;AA2BA,wBAEC;AAQD,0CAEC;AAvCD,mFAA8F;AAG9F,iFAA2F;AAE3F,qFAAkH;AAElH,iGAA4G;AAC5G,iGAA4G;AAC5G,qGAAgH;AAChH,2FAAqG;AAErG,2EAAuF;AACvF,2EAAuF;AACvF,+EAA2F;AAC3F,mEAA+E;AAC/E,qDAAiE;AACjE,mEAAgE;AAChE,iEAA6E;AAC7E,qEAAiF;AACjF,qEAAiF;AAEjF;;;;GAIG;AACH,SAAgB,MAAM;IACpB,OAAO,oBAAoB,CAAC,cAAc,EAAE,CAAC;AAC/C,CAAC;AAED;;;;;GAKG;AACH,SAAgB,eAAe,CAAC,MAAwB;IACtD,OAAO,MAAM,EAAE,CAAC,eAAe,CAAC,MAAM,CAAC,CAAC;AAC1C,CAAC;AAED,yCAAyC;AAEzC;;GAEG;AACH,MAAM,oBAAoB;IAExB;;OAEG;IACH,eAAe,CAAC,MAAwB;QACtC,MAAM,YAAY,GAAkC,MAAM,IAAI,IAAI,CAAC,aAAa,CAAC;QACjF,MAAM,SAAS,GAA4B,IAAA,uBAAmB,EAAC,YAAY,CAAC,CAAC;QAC7E,MAAM,UAAU,GAA6B,IAAI,CAAC,sBAAsB,CAAC,SAAS,CAAC,CAAC;QAEpF,OAAO,IAAA,4BAAa,EAAC,SAAS,EAAE,UAAU,CAAC,CAAC;IAC9C,CAAC;IAED,MAAM,CAAC,cAAc;QACnB,OAAO,IAAI,oBAAoB,EAAE,CAAC;IACpC,CAAC;IAEO,sBAAsB,CAAC,SAAoB;QACjD,MAAM,iBAAiB,GAAoC,IAAA,+BAA2B,EAAC,SAAS,CAAC,CAAC;QAClG,MAAM,UAAU,GAA6B,iBAAiB,CAAC,gBAAgB,EAAE,CAAC;QAElF,UAAU,CAAC,IAAI,CAAC,4BAAkB,EAAE,+BAA2B,CAAC,CAAC;QACjE,UAAU,CAAC,IAAI,CAAC,0BAAgB,EAAE,6BAAyB,CAAC,CAAC;QAC7D,UAAU,CAAC,IAAI,CAAC,4BAAkB,EAAE,GAAG,EAAE,CAAC,iBAAiB,CAAC,CAAC;QAC7D,UAAU,CAAC,IAAI,CAAC,+BAAsB,EAAE,kCAA8B,CAAC,CAAC;QACxE,UAAU,CAAC,IAAI,CAAC,+BAAsB,EAAE,kCAA8B,CAAC,CAAC;QACxE,UAAU,CAAC,IAAI,CAAC,iCAAwB,EAAE,oCAAgC,CAAC,CAAC;QAC5E,UAAU,CAAC,IAAI,CAAC,2BAAkB,EAAE,8BAA0B,CAAC,CAAC;QAEhE,OAAO,UAAU,CAAC;IACpB,CAAC;IAED;QAIQ,kBAAa,GAAkC,EAAE,CAAC;QAHxD,SAAS;IACX,CAAC;CAGF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ContractsWrapper.impl.d.ts","sourceRoot":"","sources":["../../src/impl/ContractsWrapper.impl.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,SAAS,EAAE,MAAM,uCAAuC,CAAC;AAElE,OAAO,EAAE,UAAU,EAAE,MAAM,wCAAwC,CAAC;
|
|
1
|
+
{"version":3,"file":"ContractsWrapper.impl.d.ts","sourceRoot":"","sources":["../../src/impl/ContractsWrapper.impl.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,SAAS,EAAE,MAAM,uCAAuC,CAAC;AAElE,OAAO,EAAE,UAAU,EAAE,MAAM,wCAAwC,CAAC;AACpE,OAAO,EAAgB,YAAY,EAAE,MAAM,mCAAmC,CAAC;AAE/E;;;;;;;GAOG;AACH,wBAAgB,IAAI,CAAC,SAAS,EAAE,YAAY,CAAC,SAAS,CAAC,EAAE,UAAU,EAAE,YAAY,CAAC,UAAU,CAAC,GAAG,SAAS,CAExG"}
|
|
@@ -24,50 +24,44 @@ class ContractsWrapper {
|
|
|
24
24
|
return new ContractsWrapper(contracts, repository);
|
|
25
25
|
}
|
|
26
26
|
claim(contract) {
|
|
27
|
-
return this.
|
|
27
|
+
return this._contracts.claim(contract);
|
|
28
28
|
}
|
|
29
29
|
enforce(contract) {
|
|
30
|
-
return this.
|
|
30
|
+
return this._contracts.enforce(contract);
|
|
31
31
|
}
|
|
32
32
|
isBound(contract) {
|
|
33
|
-
return this.
|
|
33
|
+
return this._contracts.isBound(contract);
|
|
34
34
|
}
|
|
35
35
|
bind(contract, promisor, bindStrategy) {
|
|
36
|
-
return this.
|
|
36
|
+
return this._contracts.bind(contract, promisor, bindStrategy);
|
|
37
37
|
}
|
|
38
38
|
autoOpen() {
|
|
39
39
|
return this.open();
|
|
40
40
|
}
|
|
41
41
|
open() {
|
|
42
|
-
const
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
42
|
+
const closeRepository = this._repository.open();
|
|
43
|
+
try {
|
|
44
|
+
const closeConcurrency = this._contracts.open();
|
|
45
|
+
return (0, AutoClose_1.inlineAutoClose)(() => {
|
|
46
46
|
try {
|
|
47
|
-
|
|
47
|
+
closeConcurrency.close();
|
|
48
48
|
}
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
throw error;
|
|
49
|
+
finally {
|
|
50
|
+
closeRepository.close(); // ensure repository is closed
|
|
52
51
|
}
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
}
|
|
60
|
-
finally {
|
|
61
|
-
closeContracts.close(); // ensure contracts are closed even if repository close fails
|
|
62
|
-
}
|
|
63
|
-
});
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
catch (thrown) {
|
|
55
|
+
closeRepository.close();
|
|
56
|
+
throw thrown;
|
|
57
|
+
}
|
|
64
58
|
}
|
|
65
59
|
toString() {
|
|
66
|
-
return this.
|
|
60
|
+
return this._contracts.toString();
|
|
67
61
|
}
|
|
68
62
|
constructor(contracts, repository) {
|
|
69
|
-
this.
|
|
70
|
-
this.
|
|
63
|
+
this._contracts = contracts;
|
|
64
|
+
this._repository = repository;
|
|
71
65
|
}
|
|
72
66
|
}
|
|
73
67
|
;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ContractsWrapper.impl.js","sourceRoot":"","sources":["../../src/impl/ContractsWrapper.impl.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"ContractsWrapper.impl.js","sourceRoot":"","sources":["../../src/impl/ContractsWrapper.impl.ts"],"names":[],"mappings":";;AAgBA,oBAEC;AAlBD,qEAAmF;AAQnF;;;;;;;GAOG;AACH,SAAgB,IAAI,CAAC,SAAkC,EAAE,UAAoC;IAC3F,OAAO,gBAAgB,CAAC,cAAc,CAAC,SAAS,EAAE,UAAU,CAAC,CAAC;AAChE,CAAC;AAED,yCAAyC;AAEzC;;;;GAIG;AACH,MAAM,gBAAgB;IAEpB,MAAM,CAAC,cAAc,CAAC,SAAkC,EAAE,UAAoC;QAC5F,OAAO,IAAI,gBAAgB,CAAC,SAAS,EAAE,UAAU,CAAC,CAAC;IACrD,CAAC;IAED,KAAK,CAAI,QAAqB;QAC5B,OAAO,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;IACzC,CAAC;IAED,OAAO,CAAI,QAAqB;QAC9B,OAAO,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;IAC3C,CAAC;IAED,OAAO,CAAI,QAAqB;QAC9B,OAAO,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;IAC3C,CAAC;IAED,IAAI,CAAI,QAAqB,EAAE,QAAyB,EAAE,YAA+B;QACvF,OAAO,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,QAAQ,EAAE,QAAQ,EAAE,YAAY,CAAC,CAAC;IAChE,CAAC;IAED,QAAQ;QACN,OAAO,IAAI,CAAC,IAAI,EAAE,CAAC;IACrB,CAAC;IAED,IAAI;QACF,MAAM,eAAe,GAAc,IAAI,CAAC,WAAW,CAAC,IAAI,EAAE,CAAC;QAC3D,IAAI,CAAC;YACH,MAAM,gBAAgB,GAAc,IAAI,CAAC,UAAU,CAAC,IAAI,EAAE,CAAC;YAC3D,OAAO,IAAA,2BAAe,EAAC,GAAG,EAAE;gBAC1B,IAAI,CAAC;oBACH,gBAAgB,CAAC,KAAK,EAAE,CAAC;gBAC3B,CAAC;wBAAS,CAAC;oBACT,eAAe,CAAC,KAAK,EAAE,CAAC,CAAC,8BAA8B;gBACzD,CAAC;YACH,CAAC,CAAC,CAAC;QACL,CAAC;QAAC,OAAO,MAAM,EAAE,CAAC;YAChB,eAAe,CAAC,KAAK,EAAE,CAAC;YACxB,MAAM,MAAM,CAAA;QACd,CAAC;IACH,CAAC;IAED,QAAQ;QACN,OAAO,IAAI,CAAC,UAAU,CAAC,QAAQ,EAAE,CAAC;IACpC,CAAC;IAED,YAAoB,SAAkC,EAAE,UAAoC;QAC1F,IAAI,CAAC,UAAU,GAAG,SAAS,CAAC;QAC5B,IAAI,CAAC,WAAW,GAAG,UAAU,CAAC;IAChC,CAAC;CAIF;AAAA,CAAC"}
|
package/impl/Events.impl.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Events.impl.d.ts","sourceRoot":"","sources":["../../src/impl/Events.impl.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,mCAAmC,CAAC;
|
|
1
|
+
{"version":3,"file":"Events.impl.d.ts","sourceRoot":"","sources":["../../src/impl/Events.impl.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,mCAAmC,CAAC;AAKjE,OAAO,EAAY,MAAM,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAEpD,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC;AAE1B;;;;;GAKG;AACH,wBAAgB,MAAM,CAAC,MAAM,CAAC,EAAE,MAAM,GAAG,YAAY,CAAC,MAAM,CAAC,CAE5D"}
|
package/impl/Events.impl.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.create = create;
|
|
4
|
-
const AutoClose_1 = require("@jonloucks/contracts-ts/api/AutoClose");
|
|
5
4
|
const Checks_1 = require("@jonloucks/contracts-ts/auxiliary/Checks");
|
|
6
5
|
const Idempotent_impl_1 = require("./Idempotent.impl");
|
|
7
6
|
/**
|
|
@@ -22,12 +21,7 @@ class EventsImpl {
|
|
|
22
21
|
return this.open();
|
|
23
22
|
}
|
|
24
23
|
open() {
|
|
25
|
-
|
|
26
|
-
return this.firstOpen();
|
|
27
|
-
}
|
|
28
|
-
else {
|
|
29
|
-
return AutoClose_1.AUTO_CLOSE_NONE;
|
|
30
|
-
}
|
|
24
|
+
return this.idempotent.open();
|
|
31
25
|
}
|
|
32
26
|
isOpen() {
|
|
33
27
|
return this.idempotent.isOpen();
|
|
@@ -39,19 +33,14 @@ class EventsImpl {
|
|
|
39
33
|
this.names.forEach(name => {
|
|
40
34
|
process.on(name, this.callback);
|
|
41
35
|
});
|
|
42
|
-
return (
|
|
43
|
-
this.closeFirstOpen();
|
|
44
|
-
});
|
|
45
|
-
}
|
|
46
|
-
closeFirstOpen() {
|
|
47
|
-
if (this.idempotent.transitionToClosed()) {
|
|
36
|
+
return () => {
|
|
48
37
|
this.names.forEach(name => {
|
|
49
38
|
process.off(name, this.callback);
|
|
50
39
|
});
|
|
51
|
-
}
|
|
40
|
+
};
|
|
52
41
|
}
|
|
53
42
|
constructor(config) {
|
|
54
|
-
this.idempotent = (0, Idempotent_impl_1.create)();
|
|
43
|
+
this.idempotent = (0, Idempotent_impl_1.create)({ open: () => this.firstOpen() });
|
|
55
44
|
const validConfig = (0, Checks_1.configCheck)(config);
|
|
56
45
|
this.names = validConfig?.names ?? [];
|
|
57
46
|
this.callback = (0, Checks_1.presentCheck)(validConfig?.callback, "Callback must be present.");
|
package/impl/Events.impl.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Events.impl.js","sourceRoot":"","sources":["../../src/impl/Events.impl.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"Events.impl.js","sourceRoot":"","sources":["../../src/impl/Events.impl.ts"],"names":[],"mappings":";;AAgBA,wBAEC;AAhBD,qEAAqF;AAGrF,uDAA+D;AAK/D;;;;;GAKG;AACH,SAAgB,MAAM,CAAC,MAAe;IACpC,OAAO,UAAU,CAAC,cAAc,CAAC,MAAM,CAAC,CAAC;AAC3C,CAAC;AAED,yCAAyC;AAEzC;;GAEG;AACH,MAAM,UAAU;IAEd,QAAQ;QACN,OAAO,IAAI,CAAC,IAAI,EAAE,CAAC;IACrB,CAAC;IAED,IAAI;QACF,OAAO,IAAI,CAAC,UAAU,CAAC,IAAI,EAAE,CAAC;IAChC,CAAC;IAED,MAAM;QACJ,OAAO,IAAI,CAAC,UAAU,CAAC,MAAM,EAAE,CAAC;IAClC,CAAC;IAED,MAAM,CAAC,cAAc,CAAC,MAAe;QACnC,OAAO,IAAI,UAAU,CAAC,MAAM,CAAC,CAAC;IAChC,CAAC;IAEO,SAAS;QACf,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE;YACxB,OAAO,CAAC,EAAE,CAAC,IAAI,EAAE,IAAI,CAAC,QAAQ,CAAC,CAAC;QAClC,CAAC,CAAC,CAAC;QAEH,OAAO,GAAG,EAAE;YACV,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE;gBACxB,OAAO,CAAC,GAAG,CAAC,IAAI,EAAE,IAAI,CAAC,QAAQ,CAAC,CAAC;YACnC,CAAC,CAAC,CAAC;QACL,CAAC,CAAC;IACJ,CAAC;IAED,YAAoB,MAAe;QAQlB,eAAU,GAAe,IAAA,wBAAgB,EAAC,EAAE,IAAI,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,SAAS,EAAE,EAAC,CAAC,CAAC;QAP1F,MAAM,WAAW,GAAG,IAAA,oBAAW,EAAC,MAAM,CAAC,CAAC;QACxC,IAAI,CAAC,KAAK,GAAG,WAAW,EAAE,KAAK,IAAI,EAAE,CAAC;QACtC,IAAI,CAAC,QAAQ,GAAG,IAAA,qBAAY,EAAC,WAAW,EAAE,QAAQ,EAAE,2BAA2B,CAAC,CAAA;IAClF,CAAC;CAKF"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { Idempotent } from "
|
|
2
|
-
export { Idempotent } from "./Idempotent";
|
|
1
|
+
import { Idempotent, Config } from "@jonloucks/contracts-ts/auxiliary/Idempotent";
|
|
3
2
|
/**
|
|
4
|
-
*
|
|
3
|
+
* Create a new Idempotent
|
|
5
4
|
*
|
|
6
|
-
* @
|
|
5
|
+
* @param config the idempotent configuration
|
|
6
|
+
* @return the new Idempotent
|
|
7
7
|
*/
|
|
8
|
-
export declare function create(): Idempotent;
|
|
8
|
+
export declare function create(config: Config): Idempotent;
|
|
9
9
|
//# sourceMappingURL=Idempotent.impl.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Idempotent.impl.d.ts","sourceRoot":"","sources":["../../src/impl/Idempotent.impl.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Idempotent.impl.d.ts","sourceRoot":"","sources":["../../src/impl/Idempotent.impl.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,8CAA8C,CAAC;AASlF;;;;;GAKG;AACH,wBAAgB,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,UAAU,CAEjD"}
|
package/impl/Idempotent.impl.js
CHANGED
|
@@ -1,37 +1,82 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.create = create;
|
|
4
|
+
const AutoClose_1 = require("@jonloucks/contracts-ts/api/AutoClose");
|
|
5
|
+
const Open_1 = require("@jonloucks/contracts-ts/api/Open");
|
|
6
|
+
const Checks_1 = require("@jonloucks/contracts-ts/auxiliary/Checks");
|
|
4
7
|
const AtomicBoolean_impl_1 = require("./AtomicBoolean.impl");
|
|
5
8
|
/**
|
|
6
|
-
*
|
|
9
|
+
* Create a new Idempotent
|
|
7
10
|
*
|
|
8
|
-
* @
|
|
11
|
+
* @param config the idempotent configuration
|
|
12
|
+
* @return the new Idempotent
|
|
9
13
|
*/
|
|
10
|
-
function create() {
|
|
11
|
-
return IdempotentImpl.internalCreate();
|
|
14
|
+
function create(config) {
|
|
15
|
+
return IdempotentImpl.internalCreate(config);
|
|
12
16
|
}
|
|
13
17
|
// ---- Implementation details below ----
|
|
14
18
|
const IS_CLOSED = false;
|
|
15
19
|
const IS_OPEN = true;
|
|
16
|
-
/**
|
|
17
|
-
* The Idempotent implementation
|
|
18
|
-
*/
|
|
19
20
|
class IdempotentImpl {
|
|
20
|
-
|
|
21
|
-
|
|
21
|
+
// Idempotent.getState
|
|
22
|
+
getState() {
|
|
23
|
+
return this._idempotentState;
|
|
22
24
|
}
|
|
23
|
-
|
|
24
|
-
|
|
25
|
+
// Idempotent.open
|
|
26
|
+
open() {
|
|
27
|
+
if (this.transitionToOpen()) {
|
|
28
|
+
return this.firstOpen();
|
|
29
|
+
}
|
|
30
|
+
else {
|
|
31
|
+
return AutoClose_1.AUTO_CLOSE_NONE;
|
|
32
|
+
}
|
|
25
33
|
}
|
|
34
|
+
// Idempotent.isOpen
|
|
26
35
|
isOpen() {
|
|
27
|
-
return this.
|
|
36
|
+
return this._flag.get() === IS_OPEN;
|
|
37
|
+
}
|
|
38
|
+
static internalCreate(config) {
|
|
39
|
+
return new IdempotentImpl(config);
|
|
28
40
|
}
|
|
29
|
-
|
|
30
|
-
|
|
41
|
+
firstOpen() {
|
|
42
|
+
this._idempotentState = "OPENING";
|
|
43
|
+
try {
|
|
44
|
+
this._closeDelegate = this.openDelegate();
|
|
45
|
+
this._idempotentState = "OPENED";
|
|
46
|
+
}
|
|
47
|
+
catch (thrown) {
|
|
48
|
+
this._flag.set(IS_CLOSED);
|
|
49
|
+
this._idempotentState = "OPENABLE";
|
|
50
|
+
throw thrown;
|
|
51
|
+
}
|
|
52
|
+
return this._firstClose;
|
|
53
|
+
}
|
|
54
|
+
openDelegate() {
|
|
55
|
+
return (0, Checks_1.presentCheck)(this._delegate.open(), "Close must be present.");
|
|
56
|
+
}
|
|
57
|
+
transitionToOpen() {
|
|
58
|
+
return this._flag.compareAndSet(IS_CLOSED, IS_OPEN);
|
|
59
|
+
}
|
|
60
|
+
transitionToClosed() {
|
|
61
|
+
return this._flag.compareAndSet(IS_OPEN, IS_CLOSED);
|
|
31
62
|
}
|
|
32
|
-
constructor() {
|
|
33
|
-
this.
|
|
34
|
-
this.
|
|
63
|
+
constructor(config) {
|
|
64
|
+
this._flag = (0, AtomicBoolean_impl_1.create)(IS_CLOSED);
|
|
65
|
+
this._closeDelegate = undefined;
|
|
66
|
+
this._idempotentState = "OPENABLE";
|
|
67
|
+
this._delegate = (0, Open_1.typeToOpen)(config.open);
|
|
68
|
+
this._firstClose = (0, AutoClose_1.inlineAutoClose)(() => {
|
|
69
|
+
if (this.transitionToClosed()) {
|
|
70
|
+
this._idempotentState = "CLOSING";
|
|
71
|
+
try {
|
|
72
|
+
this._closeDelegate?.close();
|
|
73
|
+
}
|
|
74
|
+
finally {
|
|
75
|
+
this._closeDelegate = undefined;
|
|
76
|
+
this._idempotentState = "CLOSED";
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
});
|
|
35
80
|
}
|
|
36
81
|
}
|
|
37
82
|
//# sourceMappingURL=Idempotent.impl.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Idempotent.impl.js","sourceRoot":"","sources":["../../src/impl/Idempotent.impl.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"Idempotent.impl.js","sourceRoot":"","sources":["../../src/impl/Idempotent.impl.ts"],"names":[],"mappings":";;AAeA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IAAI,EAAE,EAAE,wBAAwB,CAAC,CAAC;IACvE,CAAC;IAEO,gBAAgB;QACtB,OAAO,IAAI,CAAC,KAAK,CAAC,aAAa,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC;IACtD,CAAC;IAEO,kBAAkB;QACxB,OAAO,IAAI,CAAC,KAAK,CAAC,aAAa,CAAC,OAAO,EAAE,SAAS,CAAC,CAAC;IACtD,CAAC;IAED,YAAoB,MAAc;QAiBjB,UAAK,GAAkB,IAAA,2BAAmB,EAAC,SAAS,CAAC,CAAC;QAC/D,mBAAc,GAA0B,SAAS,CAAC;QAClD,qBAAgB,GAAoB,UAAU,CAAC;QAlBrD,IAAI,CAAC,SAAS,GAAG,IAAA,iBAAU,EAAC,MAAM,CAAC,IAAI,CAAC,CAAC;QACzC,IAAI,CAAC,WAAW,GAAG,IAAA,2BAAe,EAAC,GAAG,EAAE;YACtC,IAAI,IAAI,CAAC,kBAAkB,EAAE,EAAE,CAAC;gBAC9B,IAAI,CAAC,gBAAgB,GAAG,SAAS,CAAC;gBAClC,IAAI,CAAC;oBACA,IAAI,CAAC,cAAc,EAAE,KAAK,EAAE,CAAC;gBAClC,CAAC;wBAAS,CAAC;oBACT,IAAI,CAAC,cAAc,GAAG,SAAS,CAAC;oBAChC,IAAI,CAAC,gBAAgB,GAAG,QAAQ,CAAC;gBACnC,CAAC;YACH,CAAC;QACH,CAAC,CAAC,CAAC;IACL,CAAC;CAOF"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Contracts } from "@jonloucks/contracts-ts/api/Contracts";
|
|
2
|
+
import { IdempotentFactory } from "@jonloucks/contracts-ts/auxiliary/IdempotentFactory";
|
|
3
|
+
export interface Config {
|
|
4
|
+
contracts?: Contracts;
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* Create a new IdempotentFactory
|
|
8
|
+
*
|
|
9
|
+
* @return the new IdempotentFactory
|
|
10
|
+
*/
|
|
11
|
+
export declare function create(config?: Config): IdempotentFactory;
|
|
12
|
+
//# sourceMappingURL=IdempotentFactory.impl.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"IdempotentFactory.impl.d.ts","sourceRoot":"","sources":["../../src/impl/IdempotentFactory.impl.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,uCAAuC,CAAC;AAClE,OAAO,EAAE,iBAAiB,EAAE,MAAM,qDAAqD,CAAC;AAMxF,MAAM,WAAW,MAAM;IACrB,SAAS,CAAC,EAAE,SAAS,CAAC;CACvB;AAED;;;;GAIG;AACH,wBAAgB,MAAM,CAAC,MAAM,CAAC,EAAE,MAAM,GAAG,iBAAiB,CAEzD"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.create = create;
|
|
4
|
+
const Idempotent_impl_1 = require("./Idempotent.impl");
|
|
5
|
+
/**
|
|
6
|
+
* Create a new IdempotentFactory
|
|
7
|
+
*
|
|
8
|
+
* @return the new IdempotentFactory
|
|
9
|
+
*/
|
|
10
|
+
function create(config) {
|
|
11
|
+
return IdempotentFactoryImpl.internalCreate(config);
|
|
12
|
+
}
|
|
13
|
+
// ---- Implementation details below ----
|
|
14
|
+
class IdempotentFactoryImpl {
|
|
15
|
+
createIdempotent(config) {
|
|
16
|
+
return (0, Idempotent_impl_1.create)(config);
|
|
17
|
+
}
|
|
18
|
+
static internalCreate(config) {
|
|
19
|
+
return new IdempotentFactoryImpl(config);
|
|
20
|
+
}
|
|
21
|
+
constructor(_config) {
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
;
|
|
25
|
+
//# sourceMappingURL=IdempotentFactory.impl.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"IdempotentFactory.impl.js","sourceRoot":"","sources":["../../src/impl/IdempotentFactory.impl.ts"],"names":[],"mappings":";;AAgBA,wBAEC;AAbD,uDAAmE;AAMnE;;;;GAIG;AACH,SAAgB,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,IAAA,wBAAoB,EAAC,MAAM,CAAC,CAAC;IACtC,CAAC;IAED,MAAM,CAAC,cAAc,CAAC,MAAe;QACnC,OAAO,IAAI,qBAAqB,CAAC,MAAM,CAAC,CAAC;IAC3C,CAAC;IAED,YAAoB,OAAgB;IACpC,CAAC;CACF;AAAA,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Config, Repository } from "@jonloucks/contracts-ts/api/Repository";
|
|
2
2
|
import { RequiredType } from "@jonloucks/contracts-ts/api/Types";
|
|
3
3
|
/**
|
|
4
4
|
* Factory method to create Repository instance.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Repository.impl.d.ts","sourceRoot":"","sources":["../../src/impl/Repository.impl.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,
|
|
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,EAAE,YAAY,EAAgB,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
|
@@ -39,10 +39,7 @@ class RepositoryImpl {
|
|
|
39
39
|
* Open.open
|
|
40
40
|
*/
|
|
41
41
|
open() {
|
|
42
|
-
|
|
43
|
-
return this.firstOpen();
|
|
44
|
-
}
|
|
45
|
-
return AutoClose_1.AUTO_CLOSE_NONE;
|
|
42
|
+
return this.idempotent.open();
|
|
46
43
|
}
|
|
47
44
|
/**
|
|
48
45
|
* Repository.store override.
|
|
@@ -98,7 +95,9 @@ class RepositoryImpl {
|
|
|
98
95
|
constructor(config) {
|
|
99
96
|
this.id = RepositoryImpl.ID_GENERATOR++;
|
|
100
97
|
_RepositoryImpl_storedContracts.set(this, new Map());
|
|
101
|
-
this.idempotent = (0, Idempotent_impl_1.create)(
|
|
98
|
+
this.idempotent = (0, Idempotent_impl_1.create)({
|
|
99
|
+
open: () => this.firstOpen()
|
|
100
|
+
});
|
|
102
101
|
_RepositoryImpl_requiredContracts.set(this, new Set());
|
|
103
102
|
const validConfig = config ?? {};
|
|
104
103
|
this.contracts = (0, Checks_1.contractsCheck)(validConfig.contracts);
|
|
@@ -111,12 +110,9 @@ class RepositoryImpl {
|
|
|
111
110
|
storage.bind();
|
|
112
111
|
}
|
|
113
112
|
this.check();
|
|
114
|
-
return (
|
|
115
|
-
}
|
|
116
|
-
closeFirstOpen() {
|
|
117
|
-
if (this.idempotent.transitionToClosed()) {
|
|
113
|
+
return () => {
|
|
118
114
|
this.reverseCloseStorage();
|
|
119
|
-
}
|
|
115
|
+
};
|
|
120
116
|
}
|
|
121
117
|
reverseCloseStorage() {
|
|
122
118
|
const storageStack = [];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Repository.impl.js","sourceRoot":"","sources":["../../src/impl/Repository.impl.ts"],"names":[],"mappings":";;;;;;;;AAqBA,wBAEC;AAvBD,
|
|
1
|
+
{"version":3,"file":"Repository.impl.js","sourceRoot":"","sources":["../../src/impl/Repository.impl.ts"],"names":[],"mappings":";;;;;;;;AAqBA,wBAEC;AAvBD,qEAAkG;AAElG,2EAA6F;AAE7F,qFAAkF;AAElF,mEAA8F;AAG9F,qEAAyF;AAGzF,uDAA+D;AAC/D,iDAA6C;AAE7C;;;;;GAKG;AACH,SAAgB,MAAM,CAAC,MAAe;IACpC,OAAO,cAAc,CAAC,cAAc,CAAC,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,IAAI,WAAW,CAAC,iBAAiB,EAAE,CAAC;YAClC,WAAW,CAAC,iBAAiB,CAAC,OAAO,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC;QAC9E,CAAC;IACH,CAAC;IAEO,SAAS;QACf,KAAK,MAAM,OAAO,IAAI,uBAAA,IAAI,uCAAiB,CAAC,MAAM,EAAE,EAAE,CAAC;YACrD,OAAO,CAAC,IAAI,EAAE,CAAC;QACjB,CAAC;QACD,IAAI,CAAC,KAAK,EAAE,CAAC;QACb,OAAO,GAAG,EAAE;YACV,IAAI,CAAC,mBAAmB,EAAE,CAAC;QAC7B,CAAC,CAAA;IACH,CAAC;IAEO,mBAAmB;QACzB,MAAM,YAAY,GAA2B,EAAE,CAAC;QAChD,KAAK,MAAM,OAAO,IAAI,uBAAA,IAAI,uCAAiB,CAAC,MAAM,EAAE,EAAE,CAAC;YACrD,YAAY,CAAC,IAAI,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"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jonloucks/contracts-ts",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.2.0",
|
|
4
4
|
"description": "Typescript Dependency Contracts for dependency inversion",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"types": "index.d.ts",
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
"scripts": {
|
|
34
34
|
"build": "tsc",
|
|
35
35
|
"test": "jest",
|
|
36
|
-
"test:watch": "jest --watch --watchAll
|
|
36
|
+
"test:watch": "jest --watch --watchAll",
|
|
37
37
|
"test:coverage": "jest --coverage",
|
|
38
38
|
"test:diagnostics": "jest --detectOpenHandles",
|
|
39
39
|
"lint": "eslint . --ext .ts",
|
package/version.js
CHANGED
|
@@ -3,5 +3,5 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.VERSION = exports.NAME = void 0;
|
|
4
4
|
// generated file - do not edit
|
|
5
5
|
exports.NAME = "@jonloucks/contracts-ts";
|
|
6
|
-
exports.VERSION = "1.
|
|
6
|
+
exports.VERSION = "1.2.0";
|
|
7
7
|
//# sourceMappingURL=version.js.map
|
package/impl/Idempotent.d.ts
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Idempotent state transition management interface.
|
|
3
|
-
*
|
|
4
|
-
* Implementations manage idempotent transitions between open and closed states.
|
|
5
|
-
*/
|
|
6
|
-
export interface Idempotent {
|
|
7
|
-
/**
|
|
8
|
-
* Transition to open state.
|
|
9
|
-
*
|
|
10
|
-
* @returns true if the state was changed to open, false if it was already open
|
|
11
|
-
*/
|
|
12
|
-
transitionToOpen(): boolean;
|
|
13
|
-
/**
|
|
14
|
-
* Transition to closed state.
|
|
15
|
-
*
|
|
16
|
-
* @returns true if the state was changed to closed, false if it was already closed
|
|
17
|
-
*/
|
|
18
|
-
transitionToClosed(): boolean;
|
|
19
|
-
/**
|
|
20
|
-
* Check if the state is open.
|
|
21
|
-
*
|
|
22
|
-
* @returns true if the state is open, false otherwise
|
|
23
|
-
*/
|
|
24
|
-
isOpen(): boolean;
|
|
25
|
-
}
|
|
26
|
-
//# sourceMappingURL=Idempotent.d.ts.map
|
package/impl/Idempotent.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Idempotent.d.ts","sourceRoot":"","sources":["../../src/impl/Idempotent.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,MAAM,WAAW,UAAU;IACzB;;;;OAIG;IACH,gBAAgB,IAAI,OAAO,CAAC;IAE5B;;;;OAIG;IACH,kBAAkB,IAAI,OAAO,CAAC;IAE9B;;;;OAIG;IACH,MAAM,IAAI,OAAO,CAAC;CACnB"}
|
package/impl/Idempotent.js
DELETED
package/impl/Idempotent.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Idempotent.js","sourceRoot":"","sources":["../../src/impl/Idempotent.ts"],"names":[],"mappings":""}
|