@croct/sdk 0.5.0 → 0.7.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/activeRecord.d.ts +1 -1
- package/activeRecord.js +15 -12
- package/base64Url.js +7 -2
- package/cache/cache.d.ts +12 -0
- package/cache/cache.js +2 -0
- package/cache/fallbackCache.d.ts +2 -2
- package/cache/fallbackCache.js +6 -3
- package/cache/inMemoryCache.d.ts +2 -2
- package/cache/inMemoryCache.js +5 -2
- package/cache/index.d.ts +4 -12
- package/cache/index.js +11 -0
- package/cache/localStorageCache.d.ts +2 -2
- package/cache/localStorageCache.js +4 -1
- package/channel/beaconSocketChannel.d.ts +3 -3
- package/channel/beaconSocketChannel.js +12 -9
- package/channel/channel.d.ts +15 -0
- package/channel/channel.js +2 -0
- package/channel/encodedChannel.d.ts +2 -2
- package/channel/encodedChannel.js +4 -1
- package/channel/guaranteedChannel.d.ts +1 -1
- package/channel/guaranteedChannel.js +10 -7
- package/channel/index.d.ts +8 -15
- package/channel/index.js +19 -0
- package/channel/queuedChannel.d.ts +2 -2
- package/channel/queuedChannel.js +10 -7
- package/channel/retryChannel.d.ts +3 -3
- package/channel/retryChannel.js +18 -15
- package/channel/sandboxChannel.d.ts +2 -2
- package/channel/sandboxChannel.js +4 -1
- package/channel/socketChannel.d.ts +1 -1
- package/channel/socketChannel.js +12 -9
- package/cid/assigner.d.ts +3 -0
- package/cid/assigner.js +2 -0
- package/cid/cachedAssigner.d.ts +5 -5
- package/cid/cachedAssigner.js +9 -6
- package/cid/fixedAssigner.d.ts +6 -0
- package/cid/fixedAssigner.js +13 -0
- package/cid/index.d.ts +4 -3
- package/cid/index.js +11 -0
- package/cid/remoteAssigner.d.ts +3 -3
- package/cid/remoteAssigner.js +11 -8
- package/constants.js +8 -5
- package/container.d.ts +5 -5
- package/container.js +49 -55
- package/context.d.ts +4 -4
- package/context.js +14 -13
- package/error.d.ts +1 -1
- package/error.js +7 -2
- package/evaluator.d.ts +2 -2
- package/evaluator.js +26 -23
- package/eventManager.d.ts +1 -1
- package/eventManager.js +5 -2
- package/facade/evaluatorFacade.d.ts +3 -3
- package/facade/evaluatorFacade.js +13 -10
- package/facade/index.d.ts +7 -0
- package/facade/index.js +19 -0
- package/facade/sdkFacade.d.ts +9 -9
- package/facade/sdkFacade.js +35 -32
- package/facade/sessionFacade.d.ts +3 -3
- package/facade/sessionFacade.js +6 -3
- package/facade/sessionPatch.d.ts +3 -3
- package/facade/sessionPatch.js +8 -5
- package/facade/trackerFacade.d.ts +2 -2
- package/facade/trackerFacade.js +21 -17
- package/facade/userFacade.d.ts +4 -4
- package/facade/userFacade.js +6 -3
- package/facade/userPatch.d.ts +3 -3
- package/facade/userPatch.js +8 -5
- package/index.d.ts +2 -2
- package/index.js +7 -3
- package/json.js +2 -0
- package/logging/consoleLogger.d.ts +2 -2
- package/logging/consoleLogger.js +8 -5
- package/logging/index.d.ts +4 -9
- package/logging/index.js +11 -0
- package/logging/logger.d.ts +9 -0
- package/logging/logger.js +2 -0
- package/logging/namespacedLogger.d.ts +2 -2
- package/logging/namespacedLogger.js +4 -1
- package/logging/nullLogger.d.ts +2 -2
- package/logging/nullLogger.js +4 -1
- package/namespacedStorage.d.ts +1 -1
- package/namespacedStorage.js +7 -4
- package/package.json +21 -18
- package/patch.js +2 -0
- package/queue/capacityRestrictedQueue.d.ts +2 -2
- package/queue/capacityRestrictedQueue.js +4 -1
- package/queue/inMemoryQueue.d.ts +2 -2
- package/queue/inMemoryQueue.js +6 -3
- package/queue/index.d.ts +5 -9
- package/queue/index.js +13 -0
- package/queue/monitoredQueue.d.ts +6 -6
- package/queue/monitoredQueue.js +6 -3
- package/queue/persistentQueue.d.ts +2 -2
- package/queue/persistentQueue.js +5 -2
- package/queue/queue.d.ts +9 -0
- package/queue/queue.js +2 -0
- package/retry/arbitraryPolicy.d.ts +2 -2
- package/retry/arbitraryPolicy.js +6 -3
- package/retry/backoffPolicy.d.ts +2 -2
- package/retry/backoffPolicy.js +4 -1
- package/retry/index.d.ts +5 -4
- package/retry/index.js +13 -0
- package/retry/maxAttemptsPolicy.d.ts +2 -2
- package/retry/maxAttemptsPolicy.js +4 -1
- package/retry/neverPolicy.d.ts +2 -2
- package/retry/neverPolicy.js +4 -1
- package/retry/policy.d.ts +4 -0
- package/retry/policy.js +2 -0
- package/schema/attributeSchema.d.ts +2 -0
- package/schema/attributeSchema.js +8 -0
- package/schema/contentSchemas.d.ts +2 -0
- package/schema/contentSchemas.js +46 -0
- package/schema/contextSchemas.d.ts +1 -1
- package/schema/contextSchemas.js +5 -2
- package/schema/ecommerceSchemas.d.ts +1 -1
- package/schema/ecommerceSchemas.js +60 -60
- package/schema/evaluationSchemas.d.ts +1 -1
- package/schema/evaluationSchemas.js +7 -6
- package/schema/eventSchemas.d.ts +3 -2
- package/schema/eventSchemas.js +53 -48
- package/schema/index.d.ts +10 -0
- package/schema/index.js +13 -0
- package/schema/loggerSchema.d.ts +1 -1
- package/schema/loggerSchema.js +9 -7
- package/schema/operationSchemas.d.ts +1 -1
- package/schema/operationSchemas.js +26 -24
- package/schema/sdkFacadeSchemas.d.ts +2 -2
- package/schema/sdkFacadeSchemas.js +22 -24
- package/schema/sdkSchemas.d.ts +2 -2
- package/schema/sdkSchemas.js +21 -22
- package/schema/tokenSchema.d.ts +2 -3
- package/schema/tokenSchema.js +18 -17
- package/schema/userSchema.d.ts +1 -1
- package/schema/userSchema.js +47 -61
- package/sdk.d.ts +5 -5
- package/sdk.js +27 -24
- package/sdkEvents.d.ts +2 -2
- package/sdkEvents.js +2 -0
- package/sourceLocation.js +12 -6
- package/tab.d.ts +2 -2
- package/tab.js +12 -9
- package/token/cachedTokenStore.d.ts +3 -3
- package/token/cachedTokenStore.js +6 -3
- package/token/inMemoryTokenStore.d.ts +2 -2
- package/token/inMemoryTokenStore.js +4 -1
- package/token/index.d.ts +4 -41
- package/token/index.js +11 -96
- package/token/replicatedTokenStore.d.ts +2 -2
- package/token/replicatedTokenStore.js +4 -1
- package/token/token.d.ts +41 -0
- package/token/token.js +99 -0
- package/tracker.d.ts +3 -3
- package/tracker.js +29 -26
- package/trackingEvents.d.ts +29 -14
- package/trackingEvents.js +20 -14
- package/transformer.js +5 -1
- package/utilityTypes.js +2 -0
- package/uuid.js +5 -1
- package/validation/arrayType.d.ts +2 -2
- package/validation/arrayType.js +13 -9
- package/validation/booleanType.d.ts +2 -2
- package/validation/booleanType.js +7 -3
- package/validation/functionType.d.ts +2 -2
- package/validation/functionType.js +7 -3
- package/validation/index.d.ts +12 -18
- package/validation/index.js +29 -30
- package/validation/jsonType.d.ts +2 -1
- package/validation/jsonType.js +25 -14
- package/validation/mixedSchema.d.ts +2 -2
- package/validation/mixedSchema.js +4 -1
- package/validation/nullType.d.ts +2 -2
- package/validation/nullType.js +7 -3
- package/validation/numberType.d.ts +2 -2
- package/validation/numberType.js +13 -9
- package/validation/objectType.d.ts +2 -2
- package/validation/objectType.js +23 -18
- package/validation/schema.d.ts +16 -0
- package/validation/schema.js +15 -0
- package/validation/stringType.d.ts +2 -2
- package/validation/stringType.js +16 -12
- package/validation/unionType.d.ts +2 -2
- package/validation/unionType.js +14 -10
- package/validation/violation.d.ts +2 -0
- package/validation/violation.js +24 -0
- package/cid/fixedCidAssigner.d.ts +0 -6
- package/cid/fixedCidAssigner.js +0 -10
package/activeRecord.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Patch } from './patch';
|
|
2
2
|
import { JsonArray, JsonObject, JsonValue } from './json';
|
|
3
3
|
import { TrackingEvent } from './trackingEvents';
|
|
4
|
-
export
|
|
4
|
+
export declare abstract class ActiveRecord<T extends TrackingEvent> {
|
|
5
5
|
private readonly operations;
|
|
6
6
|
set(value: JsonValue): this;
|
|
7
7
|
set(property: string, value: JsonValue): this;
|
package/activeRecord.js
CHANGED
|
@@ -1,14 +1,17 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ActiveRecord = void 0;
|
|
4
|
+
var tslib_1 = require("tslib");
|
|
5
|
+
var schema_1 = require("./schema");
|
|
3
6
|
var operationSchema = {
|
|
4
|
-
add: addOperation,
|
|
5
|
-
set: setOperation,
|
|
6
|
-
merge: mergeOperation,
|
|
7
|
-
combine: combineOperation,
|
|
8
|
-
increment: incrementOperation,
|
|
9
|
-
decrement: decrementOperation,
|
|
10
|
-
clear: clearOperation,
|
|
11
|
-
unset: unsetOperation,
|
|
7
|
+
add: schema_1.addOperation,
|
|
8
|
+
set: schema_1.setOperation,
|
|
9
|
+
merge: schema_1.mergeOperation,
|
|
10
|
+
combine: schema_1.combineOperation,
|
|
11
|
+
increment: schema_1.incrementOperation,
|
|
12
|
+
decrement: schema_1.decrementOperation,
|
|
13
|
+
clear: schema_1.clearOperation,
|
|
14
|
+
unset: schema_1.unsetOperation,
|
|
12
15
|
};
|
|
13
16
|
var ActiveRecord = /** @class */ (function () {
|
|
14
17
|
function ActiveRecord() {
|
|
@@ -85,7 +88,7 @@ var ActiveRecord = /** @class */ (function () {
|
|
|
85
88
|
});
|
|
86
89
|
};
|
|
87
90
|
ActiveRecord.prototype.pushOperation = function (operation) {
|
|
88
|
-
var type = operation.type, data = __rest(operation, ["type"]);
|
|
91
|
+
var type = operation.type, data = tslib_1.__rest(operation, ["type"]);
|
|
89
92
|
operationSchema[type].validate(data);
|
|
90
93
|
this.operations.push(operation);
|
|
91
94
|
return this;
|
|
@@ -102,4 +105,4 @@ var ActiveRecord = /** @class */ (function () {
|
|
|
102
105
|
};
|
|
103
106
|
return ActiveRecord;
|
|
104
107
|
}());
|
|
105
|
-
|
|
108
|
+
exports.ActiveRecord = ActiveRecord;
|
package/base64Url.js
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.base64UrlDecode = exports.base64UrlEncode = void 0;
|
|
1
4
|
function base64Unescape(value) {
|
|
2
5
|
return (value + '==='.slice((value.length + 3) % 4)).replace(/-/g, '+').replace(/_/g, '/');
|
|
3
6
|
}
|
|
@@ -7,9 +10,11 @@ function base64Escape(value) {
|
|
|
7
10
|
.replace(/\//g, '_')
|
|
8
11
|
.replace(/=/g, '');
|
|
9
12
|
}
|
|
10
|
-
|
|
13
|
+
function base64UrlEncode(value) {
|
|
11
14
|
return base64Escape(window.btoa(value));
|
|
12
15
|
}
|
|
13
|
-
|
|
16
|
+
exports.base64UrlEncode = base64UrlEncode;
|
|
17
|
+
function base64UrlDecode(value) {
|
|
14
18
|
return window.atob(base64Unescape(value));
|
|
15
19
|
}
|
|
20
|
+
exports.base64UrlDecode = base64UrlDecode;
|
package/cache/cache.d.ts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export interface Cache {
|
|
2
|
+
get(): string | null;
|
|
3
|
+
put(value: string): void;
|
|
4
|
+
clear(): void;
|
|
5
|
+
}
|
|
6
|
+
export interface CacheListener {
|
|
7
|
+
(value: string | null): void;
|
|
8
|
+
}
|
|
9
|
+
export interface ObservableCache extends Cache {
|
|
10
|
+
addListener(listener: CacheListener): void;
|
|
11
|
+
removeListener(listener: CacheListener): void;
|
|
12
|
+
}
|
package/cache/cache.js
ADDED
package/cache/fallbackCache.d.ts
CHANGED
package/cache/fallbackCache.js
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.FallbackCache = void 0;
|
|
4
|
+
var tslib_1 = require("tslib");
|
|
2
5
|
var FallbackCache = /** @class */ (function () {
|
|
3
6
|
function FallbackCache() {
|
|
4
7
|
var caches = [];
|
|
@@ -10,7 +13,7 @@ var FallbackCache = /** @class */ (function () {
|
|
|
10
13
|
FallbackCache.prototype.get = function () {
|
|
11
14
|
var e_1, _a;
|
|
12
15
|
try {
|
|
13
|
-
for (var _b = __values(this.caches), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
16
|
+
for (var _b = tslib_1.__values(this.caches), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
14
17
|
var cache = _c.value;
|
|
15
18
|
var value = cache.get();
|
|
16
19
|
if (value !== null) {
|
|
@@ -35,4 +38,4 @@ var FallbackCache = /** @class */ (function () {
|
|
|
35
38
|
};
|
|
36
39
|
return FallbackCache;
|
|
37
40
|
}());
|
|
38
|
-
|
|
41
|
+
exports.FallbackCache = FallbackCache;
|
package/cache/inMemoryCache.d.ts
CHANGED
package/cache/inMemoryCache.js
CHANGED
|
@@ -1,10 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.InMemoryCache = void 0;
|
|
1
4
|
var InMemoryCache = /** @class */ (function () {
|
|
2
5
|
function InMemoryCache(cache) {
|
|
3
6
|
this.cache = cache;
|
|
4
7
|
}
|
|
5
8
|
InMemoryCache.prototype.get = function () {
|
|
6
9
|
var _a;
|
|
7
|
-
return _a = this.cache
|
|
10
|
+
return (_a = this.cache) !== null && _a !== void 0 ? _a : null;
|
|
8
11
|
};
|
|
9
12
|
InMemoryCache.prototype.put = function (value) {
|
|
10
13
|
this.cache = value;
|
|
@@ -14,4 +17,4 @@ var InMemoryCache = /** @class */ (function () {
|
|
|
14
17
|
};
|
|
15
18
|
return InMemoryCache;
|
|
16
19
|
}());
|
|
17
|
-
|
|
20
|
+
exports.InMemoryCache = InMemoryCache;
|
package/cache/index.d.ts
CHANGED
|
@@ -1,12 +1,4 @@
|
|
|
1
|
-
export
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
}
|
|
6
|
-
export interface CacheListener {
|
|
7
|
-
(value: string | null): void;
|
|
8
|
-
}
|
|
9
|
-
export interface ObservableCache extends Cache {
|
|
10
|
-
addListener(listener: CacheListener): void;
|
|
11
|
-
removeListener(listener: CacheListener): void;
|
|
12
|
-
}
|
|
1
|
+
export * from './cache';
|
|
2
|
+
export { FallbackCache } from './fallbackCache';
|
|
3
|
+
export { InMemoryCache } from './inMemoryCache';
|
|
4
|
+
export { LocalStorageCache } from './localStorageCache';
|
package/cache/index.js
CHANGED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.LocalStorageCache = exports.InMemoryCache = exports.FallbackCache = void 0;
|
|
4
|
+
var tslib_1 = require("tslib");
|
|
5
|
+
tslib_1.__exportStar(require("./cache"), exports);
|
|
6
|
+
var fallbackCache_1 = require("./fallbackCache");
|
|
7
|
+
Object.defineProperty(exports, "FallbackCache", { enumerable: true, get: function () { return fallbackCache_1.FallbackCache; } });
|
|
8
|
+
var inMemoryCache_1 = require("./inMemoryCache");
|
|
9
|
+
Object.defineProperty(exports, "InMemoryCache", { enumerable: true, get: function () { return inMemoryCache_1.InMemoryCache; } });
|
|
10
|
+
var localStorageCache_1 = require("./localStorageCache");
|
|
11
|
+
Object.defineProperty(exports, "LocalStorageCache", { enumerable: true, get: function () { return localStorageCache_1.LocalStorageCache; } });
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { CacheListener, ObservableCache } from './
|
|
2
|
-
export
|
|
1
|
+
import { CacheListener, ObservableCache } from './cache';
|
|
2
|
+
export declare class LocalStorageCache implements ObservableCache {
|
|
3
3
|
private readonly storage;
|
|
4
4
|
private readonly key;
|
|
5
5
|
private value;
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.LocalStorageCache = void 0;
|
|
1
4
|
var LocalStorageCache = /** @class */ (function () {
|
|
2
5
|
function LocalStorageCache(storage, key) {
|
|
3
6
|
this.listeners = [];
|
|
@@ -60,4 +63,4 @@ var LocalStorageCache = /** @class */ (function () {
|
|
|
60
63
|
};
|
|
61
64
|
return LocalStorageCache;
|
|
62
65
|
}());
|
|
63
|
-
|
|
66
|
+
exports.LocalStorageCache = LocalStorageCache;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { ChannelListener, DuplexChannel } from './
|
|
1
|
+
import { ChannelListener, DuplexChannel } from './channel';
|
|
2
2
|
import { Envelope } from './guaranteedChannel';
|
|
3
3
|
import { Logger, LoggerFactory } from '../logging';
|
|
4
|
-
import CidAssigner from '../cid';
|
|
4
|
+
import { CidAssigner } from '../cid';
|
|
5
5
|
export interface DuplexChannelFactory {
|
|
6
6
|
(url: string, logger: Logger): DuplexChannel<string, string>;
|
|
7
7
|
}
|
|
@@ -14,7 +14,7 @@ declare type Configuration = {
|
|
|
14
14
|
cidAssigner: CidAssigner;
|
|
15
15
|
cidParameter: string;
|
|
16
16
|
};
|
|
17
|
-
export
|
|
17
|
+
export declare class BeaconSocketChannel implements DuplexChannel<string, Envelope<string, string>> {
|
|
18
18
|
private readonly socketFactory;
|
|
19
19
|
private readonly logger;
|
|
20
20
|
private readonly loggerFactory;
|
|
@@ -1,13 +1,16 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.BeaconSocketChannel = void 0;
|
|
4
|
+
var tslib_1 = require("tslib");
|
|
5
|
+
var logging_1 = require("../logging");
|
|
3
6
|
var BeaconSocketChannel = /** @class */ (function () {
|
|
4
7
|
function BeaconSocketChannel(configuration) {
|
|
5
8
|
var _a, _b;
|
|
6
9
|
this.listeners = [];
|
|
7
10
|
this.connectionIndex = 0;
|
|
8
11
|
this.socketFactory = configuration.channelFactory;
|
|
9
|
-
this.logger = (_a = configuration.logger
|
|
10
|
-
this.loggerFactory = (_b = configuration.loggerFactory
|
|
12
|
+
this.logger = (_a = configuration.logger) !== null && _a !== void 0 ? _a : new logging_1.NullLogger();
|
|
13
|
+
this.loggerFactory = (_b = configuration.loggerFactory) !== null && _b !== void 0 ? _b : (function () { return new logging_1.NullLogger(); });
|
|
11
14
|
this.cidAssigner = configuration.cidAssigner;
|
|
12
15
|
this.cidParameter = configuration.cidParameter;
|
|
13
16
|
this.trackerEndpointUrl = configuration.trackerEndpointUrl;
|
|
@@ -16,9 +19,9 @@ var BeaconSocketChannel = /** @class */ (function () {
|
|
|
16
19
|
}
|
|
17
20
|
BeaconSocketChannel.prototype.publish = function (_a) {
|
|
18
21
|
var receiptId = _a.id, message = _a.message;
|
|
19
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
22
|
+
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
20
23
|
var _b, token, timestamp, context, payload, _c;
|
|
21
|
-
return __generator(this, function (_d) {
|
|
24
|
+
return tslib_1.__generator(this, function (_d) {
|
|
22
25
|
switch (_d.label) {
|
|
23
26
|
case 0:
|
|
24
27
|
_b = JSON.parse(message), token = _b.token, timestamp = _b.timestamp, context = _b.context, payload = _b.payload;
|
|
@@ -49,9 +52,9 @@ var BeaconSocketChannel = /** @class */ (function () {
|
|
|
49
52
|
});
|
|
50
53
|
};
|
|
51
54
|
BeaconSocketChannel.prototype.createSocketChannel = function (token) {
|
|
52
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
55
|
+
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
53
56
|
var endpoint, _a, _b, _c, channel;
|
|
54
|
-
return __generator(this, function (_d) {
|
|
57
|
+
return tslib_1.__generator(this, function (_d) {
|
|
55
58
|
switch (_d.label) {
|
|
56
59
|
case 0:
|
|
57
60
|
endpoint = new URL(this.trackerEndpointUrl);
|
|
@@ -106,4 +109,4 @@ var BeaconSocketChannel = /** @class */ (function () {
|
|
|
106
109
|
};
|
|
107
110
|
return BeaconSocketChannel;
|
|
108
111
|
}());
|
|
109
|
-
|
|
112
|
+
exports.BeaconSocketChannel = BeaconSocketChannel;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export interface Closeable {
|
|
2
|
+
close(): Promise<void>;
|
|
3
|
+
}
|
|
4
|
+
export interface OutputChannel<O> extends Closeable {
|
|
5
|
+
publish(message: O): Promise<void>;
|
|
6
|
+
}
|
|
7
|
+
export declare type ChannelListener<T> = {
|
|
8
|
+
(message: T): void;
|
|
9
|
+
};
|
|
10
|
+
export interface InputChannel<I> extends Closeable {
|
|
11
|
+
subscribe(listener: ChannelListener<I>): void;
|
|
12
|
+
unsubscribe(listener: ChannelListener<I>): void;
|
|
13
|
+
}
|
|
14
|
+
export interface DuplexChannel<I, O> extends InputChannel<I>, OutputChannel<O> {
|
|
15
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { OutputChannel } from './
|
|
1
|
+
import { OutputChannel } from './channel';
|
|
2
2
|
import { Transformer } from '../transformer';
|
|
3
|
-
export
|
|
3
|
+
export declare class EncodedChannel<D, E> implements OutputChannel<D> {
|
|
4
4
|
private readonly encode;
|
|
5
5
|
private readonly channel;
|
|
6
6
|
constructor(channel: OutputChannel<E>, encoder: Transformer<D, E>);
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.EncodedChannel = void 0;
|
|
1
4
|
var EncodedChannel = /** @class */ (function () {
|
|
2
5
|
function EncodedChannel(channel, encoder) {
|
|
3
6
|
this.channel = channel;
|
|
@@ -12,4 +15,4 @@ var EncodedChannel = /** @class */ (function () {
|
|
|
12
15
|
};
|
|
13
16
|
return EncodedChannel;
|
|
14
17
|
}());
|
|
15
|
-
|
|
18
|
+
exports.EncodedChannel = EncodedChannel;
|
|
@@ -1,5 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.GuaranteedChannel = exports.TimeStamper = void 0;
|
|
4
|
+
var tslib_1 = require("tslib");
|
|
5
|
+
var logging_1 = require("../logging");
|
|
3
6
|
var TimeStamper = /** @class */ (function () {
|
|
4
7
|
function TimeStamper() {
|
|
5
8
|
}
|
|
@@ -8,16 +11,16 @@ var TimeStamper = /** @class */ (function () {
|
|
|
8
11
|
};
|
|
9
12
|
return TimeStamper;
|
|
10
13
|
}());
|
|
11
|
-
|
|
14
|
+
exports.TimeStamper = TimeStamper;
|
|
12
15
|
var GuaranteedChannel = /** @class */ (function () {
|
|
13
16
|
function GuaranteedChannel(_a) {
|
|
14
17
|
var _b;
|
|
15
|
-
var channel = _a.channel, logger = _a.logger, stamper = _a.stamper, options = __rest(_a, ["channel", "logger", "stamper"]);
|
|
18
|
+
var channel = _a.channel, logger = _a.logger, stamper = _a.stamper, options = tslib_1.__rest(_a, ["channel", "logger", "stamper"]);
|
|
16
19
|
this.closed = false;
|
|
17
20
|
this.channel = channel;
|
|
18
|
-
this.logger =
|
|
21
|
+
this.logger = logger !== null && logger !== void 0 ? logger : new logging_1.NullLogger();
|
|
19
22
|
this.stamper = stamper;
|
|
20
|
-
this.options = __assign(__assign({}, options), { ackTimeout: (_b = options.ackTimeout
|
|
23
|
+
this.options = tslib_1.__assign(tslib_1.__assign({}, options), { ackTimeout: (_b = options.ackTimeout) !== null && _b !== void 0 ? _b : 5000 });
|
|
21
24
|
}
|
|
22
25
|
GuaranteedChannel.prototype.publish = function (message) {
|
|
23
26
|
var _this = this;
|
|
@@ -74,4 +77,4 @@ var GuaranteedChannel = /** @class */ (function () {
|
|
|
74
77
|
};
|
|
75
78
|
return GuaranteedChannel;
|
|
76
79
|
}());
|
|
77
|
-
|
|
80
|
+
exports.GuaranteedChannel = GuaranteedChannel;
|
package/channel/index.d.ts
CHANGED
|
@@ -1,15 +1,8 @@
|
|
|
1
|
-
export
|
|
2
|
-
|
|
3
|
-
}
|
|
4
|
-
export
|
|
5
|
-
|
|
6
|
-
}
|
|
7
|
-
export
|
|
8
|
-
|
|
9
|
-
};
|
|
10
|
-
export interface InputChannel<I> extends Closeable {
|
|
11
|
-
subscribe(listener: ChannelListener<I>): void;
|
|
12
|
-
unsubscribe(listener: ChannelListener<I>): void;
|
|
13
|
-
}
|
|
14
|
-
export interface DuplexChannel<I, O> extends InputChannel<I>, OutputChannel<O> {
|
|
15
|
-
}
|
|
1
|
+
export * from './channel';
|
|
2
|
+
export { BeaconSocketChannel, DuplexChannelFactory } from './beaconSocketChannel';
|
|
3
|
+
export { EncodedChannel } from './encodedChannel';
|
|
4
|
+
export { GuaranteedChannel } from './guaranteedChannel';
|
|
5
|
+
export { QueuedChannel } from './queuedChannel';
|
|
6
|
+
export { RetryChannel } from './retryChannel';
|
|
7
|
+
export { SandboxChannel } from './sandboxChannel';
|
|
8
|
+
export { SocketChannel } from './socketChannel';
|
package/channel/index.js
CHANGED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SocketChannel = exports.SandboxChannel = exports.RetryChannel = exports.QueuedChannel = exports.GuaranteedChannel = exports.EncodedChannel = exports.BeaconSocketChannel = void 0;
|
|
4
|
+
var tslib_1 = require("tslib");
|
|
5
|
+
tslib_1.__exportStar(require("./channel"), exports);
|
|
6
|
+
var beaconSocketChannel_1 = require("./beaconSocketChannel");
|
|
7
|
+
Object.defineProperty(exports, "BeaconSocketChannel", { enumerable: true, get: function () { return beaconSocketChannel_1.BeaconSocketChannel; } });
|
|
8
|
+
var encodedChannel_1 = require("./encodedChannel");
|
|
9
|
+
Object.defineProperty(exports, "EncodedChannel", { enumerable: true, get: function () { return encodedChannel_1.EncodedChannel; } });
|
|
10
|
+
var guaranteedChannel_1 = require("./guaranteedChannel");
|
|
11
|
+
Object.defineProperty(exports, "GuaranteedChannel", { enumerable: true, get: function () { return guaranteedChannel_1.GuaranteedChannel; } });
|
|
12
|
+
var queuedChannel_1 = require("./queuedChannel");
|
|
13
|
+
Object.defineProperty(exports, "QueuedChannel", { enumerable: true, get: function () { return queuedChannel_1.QueuedChannel; } });
|
|
14
|
+
var retryChannel_1 = require("./retryChannel");
|
|
15
|
+
Object.defineProperty(exports, "RetryChannel", { enumerable: true, get: function () { return retryChannel_1.RetryChannel; } });
|
|
16
|
+
var sandboxChannel_1 = require("./sandboxChannel");
|
|
17
|
+
Object.defineProperty(exports, "SandboxChannel", { enumerable: true, get: function () { return sandboxChannel_1.SandboxChannel; } });
|
|
18
|
+
var socketChannel_1 = require("./socketChannel");
|
|
19
|
+
Object.defineProperty(exports, "SocketChannel", { enumerable: true, get: function () { return socketChannel_1.SocketChannel; } });
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { OutputChannel } from './
|
|
1
|
+
import { OutputChannel } from './channel';
|
|
2
2
|
import { Queue } from '../queue';
|
|
3
3
|
import { Logger } from '../logging';
|
|
4
|
-
export
|
|
4
|
+
export declare class QueuedChannel<T> implements OutputChannel<T> {
|
|
5
5
|
private readonly channel;
|
|
6
6
|
private readonly queue;
|
|
7
7
|
private readonly logger;
|
package/channel/queuedChannel.js
CHANGED
|
@@ -1,11 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.QueuedChannel = void 0;
|
|
4
|
+
var tslib_1 = require("tslib");
|
|
5
|
+
var logging_1 = require("../logging");
|
|
3
6
|
var QueuedChannel = /** @class */ (function () {
|
|
4
7
|
function QueuedChannel(channel, queue, logger) {
|
|
5
8
|
this.closed = false;
|
|
6
9
|
this.channel = channel;
|
|
7
10
|
this.queue = queue;
|
|
8
|
-
this.logger =
|
|
11
|
+
this.logger = logger !== null && logger !== void 0 ? logger : new logging_1.NullLogger();
|
|
9
12
|
}
|
|
10
13
|
QueuedChannel.prototype.flush = function () {
|
|
11
14
|
if (this.pending === undefined) {
|
|
@@ -59,7 +62,7 @@ var QueuedChannel = /** @class */ (function () {
|
|
|
59
62
|
};
|
|
60
63
|
var this_1 = this;
|
|
61
64
|
try {
|
|
62
|
-
for (var _b = __values(this.queue.all()), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
65
|
+
for (var _b = tslib_1.__values(this.queue.all()), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
63
66
|
var message = _c.value;
|
|
64
67
|
_loop_1(message);
|
|
65
68
|
}
|
|
@@ -74,9 +77,9 @@ var QueuedChannel = /** @class */ (function () {
|
|
|
74
77
|
return this.pending;
|
|
75
78
|
};
|
|
76
79
|
QueuedChannel.prototype.close = function () {
|
|
77
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
80
|
+
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
78
81
|
var _a;
|
|
79
|
-
return __generator(this, function (_b) {
|
|
82
|
+
return tslib_1.__generator(this, function (_b) {
|
|
80
83
|
switch (_b.label) {
|
|
81
84
|
case 0:
|
|
82
85
|
this.closed = true;
|
|
@@ -101,4 +104,4 @@ var QueuedChannel = /** @class */ (function () {
|
|
|
101
104
|
};
|
|
102
105
|
return QueuedChannel;
|
|
103
106
|
}());
|
|
104
|
-
|
|
107
|
+
exports.QueuedChannel = QueuedChannel;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { OutputChannel } from './
|
|
1
|
+
import { OutputChannel } from './channel';
|
|
2
2
|
import { Logger } from '../logging';
|
|
3
3
|
import { RetryPolicy } from '../retry';
|
|
4
4
|
declare type Configuration<T> = {
|
|
@@ -6,14 +6,14 @@ declare type Configuration<T> = {
|
|
|
6
6
|
retryPolicy: RetryPolicy<T>;
|
|
7
7
|
logger?: Logger;
|
|
8
8
|
};
|
|
9
|
-
export
|
|
9
|
+
export declare class RetryChannel<T> implements OutputChannel<T> {
|
|
10
10
|
private readonly channel;
|
|
11
11
|
private readonly retryPolicy;
|
|
12
12
|
private readonly logger;
|
|
13
13
|
private closed;
|
|
14
14
|
constructor({ channel, retryPolicy, logger }: Configuration<T>);
|
|
15
15
|
publish(message: T): Promise<void>;
|
|
16
|
-
retry(message: T, error:
|
|
16
|
+
retry(message: T, error: unknown): Promise<void>;
|
|
17
17
|
close(): Promise<void>;
|
|
18
18
|
}
|
|
19
19
|
export {};
|
package/channel/retryChannel.js
CHANGED
|
@@ -1,12 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.RetryChannel = void 0;
|
|
4
|
+
var tslib_1 = require("tslib");
|
|
5
|
+
var logging_1 = require("../logging");
|
|
3
6
|
var RetryChannel = /** @class */ (function () {
|
|
4
7
|
function RetryChannel(_a) {
|
|
5
8
|
var channel = _a.channel, retryPolicy = _a.retryPolicy, logger = _a.logger;
|
|
6
9
|
this.closed = false;
|
|
7
10
|
this.channel = channel;
|
|
8
11
|
this.retryPolicy = retryPolicy;
|
|
9
|
-
this.logger =
|
|
12
|
+
this.logger = logger !== null && logger !== void 0 ? logger : new logging_1.NullLogger();
|
|
10
13
|
}
|
|
11
14
|
RetryChannel.prototype.publish = function (message) {
|
|
12
15
|
var _this = this;
|
|
@@ -16,17 +19,17 @@ var RetryChannel = /** @class */ (function () {
|
|
|
16
19
|
return this.channel.publish(message).catch(function (error) { return _this.retry(message, error); });
|
|
17
20
|
};
|
|
18
21
|
RetryChannel.prototype.retry = function (message, error) {
|
|
19
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
22
|
+
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
20
23
|
var attempt, _loop_1, this_1, state_1;
|
|
21
24
|
var _this = this;
|
|
22
|
-
return __generator(this, function (_a) {
|
|
25
|
+
return tslib_1.__generator(this, function (_a) {
|
|
23
26
|
switch (_a.label) {
|
|
24
27
|
case 0:
|
|
25
28
|
attempt = 0;
|
|
26
29
|
_loop_1 = function () {
|
|
27
|
-
var delay,
|
|
28
|
-
return __generator(this, function (
|
|
29
|
-
switch (
|
|
30
|
+
var delay, _b, _c;
|
|
31
|
+
return tslib_1.__generator(this, function (_d) {
|
|
32
|
+
switch (_d.label) {
|
|
30
33
|
case 0:
|
|
31
34
|
if (this_1.closed) {
|
|
32
35
|
throw new Error('Connection deliberately closed.');
|
|
@@ -49,15 +52,15 @@ var RetryChannel = /** @class */ (function () {
|
|
|
49
52
|
}, delay);
|
|
50
53
|
})];
|
|
51
54
|
case 1:
|
|
52
|
-
|
|
53
|
-
|
|
55
|
+
_d.sent();
|
|
56
|
+
_d.label = 2;
|
|
54
57
|
case 2:
|
|
55
|
-
|
|
56
|
-
|
|
58
|
+
_d.trys.push([2, 4, , 5]);
|
|
59
|
+
_b = {};
|
|
57
60
|
return [4 /*yield*/, this_1.channel.publish(message)];
|
|
58
|
-
case 3: return [2 /*return*/, (
|
|
61
|
+
case 3: return [2 /*return*/, (_b.value = _d.sent(), _b)];
|
|
59
62
|
case 4:
|
|
60
|
-
|
|
63
|
+
_c = _d.sent();
|
|
61
64
|
attempt += 1;
|
|
62
65
|
return [3 /*break*/, 5];
|
|
63
66
|
case 5: return [2 /*return*/];
|
|
@@ -85,4 +88,4 @@ var RetryChannel = /** @class */ (function () {
|
|
|
85
88
|
};
|
|
86
89
|
return RetryChannel;
|
|
87
90
|
}());
|
|
88
|
-
|
|
91
|
+
exports.RetryChannel = RetryChannel;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { ChannelListener, DuplexChannel } from './
|
|
2
|
-
export
|
|
1
|
+
import { ChannelListener, DuplexChannel } from './channel';
|
|
2
|
+
export declare class SandboxChannel<I, O> implements DuplexChannel<I, O> {
|
|
3
3
|
private readonly listeners;
|
|
4
4
|
readonly messages: O[];
|
|
5
5
|
private closed;
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SandboxChannel = void 0;
|
|
1
4
|
var SandboxChannel = /** @class */ (function () {
|
|
2
5
|
function SandboxChannel() {
|
|
3
6
|
this.listeners = [];
|
|
@@ -31,4 +34,4 @@ var SandboxChannel = /** @class */ (function () {
|
|
|
31
34
|
};
|
|
32
35
|
return SandboxChannel;
|
|
33
36
|
}());
|
|
34
|
-
|
|
37
|
+
exports.SandboxChannel = SandboxChannel;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Logger } from '../logging';
|
|
2
|
-
import { ChannelListener, DuplexChannel } from './
|
|
2
|
+
import { ChannelListener, DuplexChannel } from './channel';
|
|
3
3
|
declare type Input = string | ArrayBufferLike | Blob | ArrayBufferView;
|
|
4
4
|
declare type Output = string | ArrayBuffer | Blob;
|
|
5
5
|
declare type Options = {
|