@croct/sdk 0.10.0 → 0.11.0-alpha

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.
Files changed (122) hide show
  1. package/activeRecord.js +32 -36
  2. package/cache/fallbackCache.js +15 -32
  3. package/cache/inMemoryCache.js +9 -10
  4. package/cache/index.js +1 -1
  5. package/cache/localStorageCache.js +24 -25
  6. package/channel/beaconSocketChannel.d.ts +1 -1
  7. package/channel/beaconSocketChannel.js +49 -79
  8. package/channel/channel.d.ts +1 -1
  9. package/channel/encodedChannel.js +8 -10
  10. package/channel/guaranteedChannel.d.ts +4 -4
  11. package/channel/guaranteedChannel.js +41 -43
  12. package/channel/index.js +1 -1
  13. package/channel/queuedChannel.js +35 -64
  14. package/channel/retryChannel.d.ts +1 -1
  15. package/channel/retryChannel.js +44 -77
  16. package/channel/sandboxChannel.js +17 -18
  17. package/channel/socketChannel.d.ts +4 -4
  18. package/channel/socketChannel.js +77 -79
  19. package/cid/cachedAssigner.js +15 -27
  20. package/cid/fixedAssigner.js +5 -6
  21. package/cid/index.js +1 -1
  22. package/cid/remoteAssigner.js +23 -36
  23. package/constants.d.ts +3 -2
  24. package/constants.js +6 -5
  25. package/container.d.ts +13 -6
  26. package/container.js +152 -168
  27. package/contentFetcher.d.ts +59 -0
  28. package/contentFetcher.js +129 -0
  29. package/context.d.ts +3 -3
  30. package/context.js +36 -38
  31. package/error.js +2 -2
  32. package/evaluator.d.ts +33 -24
  33. package/evaluator.js +126 -117
  34. package/eventManager.d.ts +1 -1
  35. package/eventManager.js +14 -15
  36. package/facade/contentFetcherFacade.d.ts +27 -0
  37. package/facade/contentFetcherFacade.js +40 -0
  38. package/facade/evaluatorFacade.d.ts +13 -3
  39. package/facade/evaluatorFacade.js +57 -72
  40. package/facade/sdkFacade.d.ts +10 -3
  41. package/facade/sdkFacade.js +129 -141
  42. package/facade/sessionFacade.js +6 -7
  43. package/facade/sessionPatch.js +9 -13
  44. package/facade/trackerFacade.js +32 -38
  45. package/facade/userFacade.js +10 -11
  46. package/facade/userPatch.js +9 -13
  47. package/index.js +2 -2
  48. package/logging/consoleLogger.js +18 -35
  49. package/logging/index.js +1 -1
  50. package/logging/namespacedLogger.js +14 -15
  51. package/logging/nullLogger.js +10 -13
  52. package/namespacedStorage.js +30 -47
  53. package/package.json +13 -16
  54. package/patch.d.ts +1 -1
  55. package/queue/capacityRestrictedQueue.js +17 -18
  56. package/queue/inMemoryQueue.js +22 -28
  57. package/queue/index.js +1 -1
  58. package/queue/monitoredQueue.d.ts +2 -2
  59. package/queue/monitoredQueue.js +39 -40
  60. package/queue/persistentQueue.js +33 -38
  61. package/retry/arbitraryPolicy.js +8 -10
  62. package/retry/backoffPolicy.d.ts +1 -1
  63. package/retry/backoffPolicy.js +11 -13
  64. package/retry/index.js +1 -1
  65. package/retry/maxAttemptsPolicy.js +7 -8
  66. package/retry/neverPolicy.js +6 -9
  67. package/schema/attributeSchema.js +1 -1
  68. package/schema/contentFetcherSchemas.d.ts +2 -0
  69. package/schema/contentFetcherSchemas.js +22 -0
  70. package/schema/contentSchemas.js +1 -1
  71. package/schema/contextSchemas.js +1 -1
  72. package/schema/ecommerceSchemas.js +1 -1
  73. package/schema/evaluatorSchemas.d.ts +2 -0
  74. package/schema/{evaluationSchemas.js → evaluatorSchemas.js} +3 -3
  75. package/schema/eventSchemas.js +5 -7
  76. package/schema/index.d.ts +2 -1
  77. package/schema/index.js +3 -2
  78. package/schema/loggerSchema.js +1 -1
  79. package/schema/operationSchemas.js +8 -8
  80. package/schema/sdkFacadeSchemas.js +9 -6
  81. package/schema/sdkSchemas.js +8 -5
  82. package/schema/tokenSchema.js +5 -4
  83. package/schema/userSchema.js +2 -2
  84. package/sdk.d.ts +9 -3
  85. package/sdk.js +81 -127
  86. package/sdkEvents.d.ts +3 -3
  87. package/sourceLocation.d.ts +3 -3
  88. package/sourceLocation.js +13 -14
  89. package/tab.d.ts +5 -5
  90. package/tab.js +50 -80
  91. package/token/cachedTokenStore.js +9 -10
  92. package/token/inMemoryTokenStore.js +7 -8
  93. package/token/index.js +1 -1
  94. package/token/replicatedTokenStore.js +7 -8
  95. package/token/token.d.ts +9 -5
  96. package/token/token.js +63 -57
  97. package/tracker.d.ts +4 -4
  98. package/tracker.js +145 -122
  99. package/trackingEvents.d.ts +36 -36
  100. package/trackingEvents.js +12 -6
  101. package/transformer.js +1 -1
  102. package/utilityTypes.d.ts +2 -2
  103. package/uuid.js +9 -7
  104. package/validation/arrayType.d.ts +2 -2
  105. package/validation/arrayType.js +29 -27
  106. package/validation/booleanType.js +11 -15
  107. package/validation/functionType.js +11 -15
  108. package/validation/index.js +1 -1
  109. package/validation/jsonType.d.ts +2 -2
  110. package/validation/jsonType.js +61 -80
  111. package/validation/mixedSchema.js +4 -7
  112. package/validation/nullType.js +11 -15
  113. package/validation/numberType.d.ts +1 -1
  114. package/validation/numberType.js +23 -22
  115. package/validation/objectType.d.ts +1 -1
  116. package/validation/objectType.js +61 -72
  117. package/validation/schema.js +6 -10
  118. package/validation/stringType.d.ts +1 -1
  119. package/validation/stringType.js +36 -47
  120. package/validation/unionType.js +27 -77
  121. package/validation/violation.js +1 -2
  122. package/schema/evaluationSchemas.d.ts +0 -2
package/activeRecord.js CHANGED
@@ -1,9 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ActiveRecord = void 0;
4
- var tslib_1 = require("tslib");
5
- var schema_1 = require("./schema");
6
- var operationSchema = {
4
+ const schema_1 = require("./schema");
5
+ const operationSchema = {
7
6
  add: schema_1.addOperation,
8
7
  set: schema_1.setOperation,
9
8
  merge: schema_1.mergeOperation,
@@ -14,11 +13,11 @@ var operationSchema = {
14
13
  unset: schema_1.unsetOperation,
15
14
  remove: schema_1.removeOperation,
16
15
  };
17
- var ActiveRecord = /** @class */ (function () {
18
- function ActiveRecord() {
16
+ class ActiveRecord {
17
+ constructor() {
19
18
  this.operations = [];
20
19
  }
21
- ActiveRecord.prototype.set = function (propertyOrValue, value) {
20
+ set(propertyOrValue, value) {
22
21
  if (typeof propertyOrValue === 'string') {
23
22
  return this.pushOperation({
24
23
  type: 'set',
@@ -31,22 +30,22 @@ var ActiveRecord = /** @class */ (function () {
31
30
  path: '.',
32
31
  value: propertyOrValue,
33
32
  });
34
- };
35
- ActiveRecord.prototype.add = function (property, value) {
33
+ }
34
+ add(property, value) {
36
35
  return this.pushOperation({
37
36
  type: 'add',
38
37
  path: property,
39
38
  value: value,
40
39
  });
41
- };
42
- ActiveRecord.prototype.combine = function (property, value) {
40
+ }
41
+ combine(property, value) {
43
42
  return this.pushOperation({
44
43
  type: 'combine',
45
44
  path: property,
46
45
  value: value,
47
46
  });
48
- };
49
- ActiveRecord.prototype.merge = function (propertyOrValue, value) {
47
+ }
48
+ merge(propertyOrValue, value) {
50
49
  if (typeof propertyOrValue === 'string') {
51
50
  return this.pushOperation({
52
51
  type: 'merge',
@@ -59,58 +58,55 @@ var ActiveRecord = /** @class */ (function () {
59
58
  path: '.',
60
59
  value: propertyOrValue,
61
60
  });
62
- };
63
- ActiveRecord.prototype.increment = function (property, amount) {
64
- if (amount === void 0) { amount = 1; }
61
+ }
62
+ increment(property, amount = 1) {
65
63
  return this.pushOperation({
66
64
  type: 'increment',
67
65
  path: property,
68
66
  value: amount,
69
67
  });
70
- };
71
- ActiveRecord.prototype.decrement = function (property, amount) {
72
- if (amount === void 0) { amount = 1; }
68
+ }
69
+ decrement(property, amount = 1) {
73
70
  return this.pushOperation({
74
71
  type: 'decrement',
75
72
  path: property,
76
73
  value: amount,
77
74
  });
78
- };
79
- ActiveRecord.prototype.clear = function (property) {
75
+ }
76
+ clear(property) {
80
77
  return this.pushOperation({
81
78
  type: 'clear',
82
79
  path: property,
83
80
  });
84
- };
85
- ActiveRecord.prototype.unset = function (property) {
81
+ }
82
+ unset(property) {
86
83
  return this.pushOperation({
87
84
  type: 'unset',
88
85
  path: property,
89
86
  });
90
- };
91
- ActiveRecord.prototype.remove = function (property, value) {
87
+ }
88
+ remove(property, value) {
92
89
  return this.pushOperation({
93
90
  type: 'remove',
94
91
  path: property,
95
92
  value: value,
96
93
  });
97
- };
98
- ActiveRecord.prototype.pushOperation = function (operation) {
99
- var type = operation.type, data = tslib_1.__rest(operation, ["type"]);
94
+ }
95
+ pushOperation(operation) {
96
+ const { type, ...data } = operation;
100
97
  operationSchema[type].validate(data);
101
98
  this.operations.push(operation);
102
99
  return this;
103
- };
104
- ActiveRecord.prototype.reset = function () {
100
+ }
101
+ reset() {
105
102
  this.operations.splice(0);
106
103
  return this;
107
- };
108
- ActiveRecord.prototype.isDirty = function () {
104
+ }
105
+ isDirty() {
109
106
  return this.operations.length > 0;
110
- };
111
- ActiveRecord.prototype.buildPatch = function () {
107
+ }
108
+ buildPatch() {
112
109
  return { operations: this.operations.slice() };
113
- };
114
- return ActiveRecord;
115
- }());
110
+ }
111
+ }
116
112
  exports.ActiveRecord = ActiveRecord;
@@ -1,41 +1,24 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.FallbackCache = void 0;
4
- var tslib_1 = require("tslib");
5
- var FallbackCache = /** @class */ (function () {
6
- function FallbackCache() {
7
- var caches = [];
8
- for (var _i = 0; _i < arguments.length; _i++) {
9
- caches[_i] = arguments[_i];
10
- }
4
+ class FallbackCache {
5
+ constructor(...caches) {
11
6
  this.caches = caches;
12
7
  }
13
- FallbackCache.prototype.get = function () {
14
- var e_1, _a;
15
- try {
16
- for (var _b = tslib_1.__values(this.caches), _c = _b.next(); !_c.done; _c = _b.next()) {
17
- var cache = _c.value;
18
- var value = cache.get();
19
- if (value !== null) {
20
- return value;
21
- }
22
- }
23
- }
24
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
25
- finally {
26
- try {
27
- if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
8
+ get() {
9
+ for (const cache of this.caches) {
10
+ const value = cache.get();
11
+ if (value !== null) {
12
+ return value;
28
13
  }
29
- finally { if (e_1) throw e_1.error; }
30
14
  }
31
15
  return null;
32
- };
33
- FallbackCache.prototype.put = function (value) {
34
- this.caches.forEach(function (cache) { return cache.put(value); });
35
- };
36
- FallbackCache.prototype.clear = function () {
37
- this.caches.forEach(function (cache) { return cache.clear(); });
38
- };
39
- return FallbackCache;
40
- }());
16
+ }
17
+ put(value) {
18
+ this.caches.forEach(cache => cache.put(value));
19
+ }
20
+ clear() {
21
+ this.caches.forEach(cache => cache.clear());
22
+ }
23
+ }
41
24
  exports.FallbackCache = FallbackCache;
@@ -1,20 +1,19 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.InMemoryCache = void 0;
4
- var InMemoryCache = /** @class */ (function () {
5
- function InMemoryCache(cache) {
4
+ class InMemoryCache {
5
+ constructor(cache) {
6
6
  this.cache = cache;
7
7
  }
8
- InMemoryCache.prototype.get = function () {
8
+ get() {
9
9
  var _a;
10
10
  return (_a = this.cache) !== null && _a !== void 0 ? _a : null;
11
- };
12
- InMemoryCache.prototype.put = function (value) {
11
+ }
12
+ put(value) {
13
13
  this.cache = value;
14
- };
15
- InMemoryCache.prototype.clear = function () {
14
+ }
15
+ clear() {
16
16
  delete this.cache;
17
- };
18
- return InMemoryCache;
19
- }());
17
+ }
18
+ }
20
19
  exports.InMemoryCache = InMemoryCache;
package/cache/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.LocalStorageCache = exports.InMemoryCache = exports.FallbackCache = void 0;
4
- var tslib_1 = require("tslib");
4
+ const tslib_1 = require("tslib");
5
5
  tslib_1.__exportStar(require("./cache"), exports);
6
6
  var fallbackCache_1 = require("./fallbackCache");
7
7
  Object.defineProperty(exports, "FallbackCache", { enumerable: true, get: function () { return fallbackCache_1.FallbackCache; } });
@@ -1,50 +1,50 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.LocalStorageCache = void 0;
4
- var LocalStorageCache = /** @class */ (function () {
5
- function LocalStorageCache(storage, key) {
4
+ class LocalStorageCache {
5
+ constructor(storage, key) {
6
6
  this.listeners = [];
7
7
  this.storage = storage;
8
8
  this.key = key;
9
9
  this.value = storage.getItem(key);
10
10
  }
11
- LocalStorageCache.autoSync = function (cache) {
12
- var listener = cache.sync.bind(cache);
11
+ static autoSync(cache) {
12
+ const listener = cache.sync.bind(cache);
13
13
  window.addEventListener('storage', listener);
14
- return function () { return window.removeEventListener('storage', listener); };
15
- };
16
- LocalStorageCache.prototype.get = function () {
14
+ return () => window.removeEventListener('storage', listener);
15
+ }
16
+ get() {
17
17
  return this.value;
18
- };
19
- LocalStorageCache.prototype.put = function (value) {
18
+ }
19
+ put(value) {
20
20
  this.storage.setItem(this.key, value);
21
21
  if (this.value !== value) {
22
22
  this.value = value;
23
23
  this.notifyChange(value);
24
24
  }
25
- };
26
- LocalStorageCache.prototype.clear = function () {
25
+ }
26
+ clear() {
27
27
  this.storage.removeItem(this.key);
28
28
  if (this.value !== null) {
29
29
  this.value = null;
30
30
  this.notifyChange(null);
31
31
  }
32
- };
33
- LocalStorageCache.prototype.addListener = function (listener) {
32
+ }
33
+ addListener(listener) {
34
34
  if (!this.listeners.includes(listener)) {
35
35
  this.listeners.push(listener);
36
36
  }
37
- };
38
- LocalStorageCache.prototype.removeListener = function (listener) {
39
- var index = this.listeners.indexOf(listener);
37
+ }
38
+ removeListener(listener) {
39
+ const index = this.listeners.indexOf(listener);
40
40
  if (index > -1) {
41
41
  this.listeners.splice(index, 1);
42
42
  }
43
- };
44
- LocalStorageCache.prototype.notifyChange = function (value) {
45
- this.listeners.forEach(function (listener) { return listener(value); });
46
- };
47
- LocalStorageCache.prototype.sync = function (event) {
43
+ }
44
+ notifyChange(value) {
45
+ this.listeners.forEach(listener => listener(value));
46
+ }
47
+ sync(event) {
48
48
  if (event.storageArea !== this.storage || (event.key !== null && event.key !== this.key)) {
49
49
  // Ignore unrelated changes
50
50
  return;
@@ -55,12 +55,11 @@ var LocalStorageCache = /** @class */ (function () {
55
55
  * In case of cascading changes, it prevents notifying listeners
56
56
  * about intermediate states already outdated at this point.
57
57
  */
58
- var value = this.storage.getItem(this.key);
58
+ const value = this.storage.getItem(this.key);
59
59
  if (this.value !== value) {
60
60
  this.value = value;
61
61
  this.notifyChange(value);
62
62
  }
63
- };
64
- return LocalStorageCache;
65
- }());
63
+ }
64
+ }
66
65
  exports.LocalStorageCache = LocalStorageCache;
@@ -5,7 +5,7 @@ import { CidAssigner } from '../cid';
5
5
  export interface DuplexChannelFactory {
6
6
  (url: string, logger: Logger): DuplexChannel<string, string>;
7
7
  }
8
- declare type Configuration = {
8
+ type Configuration = {
9
9
  logger?: Logger;
10
10
  loggerFactory?: LoggerFactory;
11
11
  tokenParameter: string;
@@ -1,112 +1,82 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.BeaconSocketChannel = void 0;
4
- var tslib_1 = require("tslib");
5
- var logging_1 = require("../logging");
6
- var BeaconSocketChannel = /** @class */ (function () {
7
- function BeaconSocketChannel(configuration) {
4
+ const logging_1 = require("../logging");
5
+ class BeaconSocketChannel {
6
+ constructor(configuration) {
8
7
  var _a, _b;
9
8
  this.listeners = [];
10
9
  this.connectionIndex = 0;
11
10
  this.socketFactory = configuration.channelFactory;
12
11
  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(); });
12
+ this.loggerFactory = (_b = configuration.loggerFactory) !== null && _b !== void 0 ? _b : (() => new logging_1.NullLogger());
14
13
  this.cidAssigner = configuration.cidAssigner;
15
14
  this.cidParameter = configuration.cidParameter;
16
15
  this.trackerEndpointUrl = configuration.trackerEndpointUrl;
17
16
  this.tokenParameter = configuration.tokenParameter;
18
17
  this.notify = this.notify.bind(this);
19
18
  }
20
- BeaconSocketChannel.prototype.publish = function (_a) {
21
- var receiptId = _a.id, message = _a.message;
22
- return tslib_1.__awaiter(this, void 0, void 0, function () {
23
- var _b, token, timestamp, context, payload, _c;
24
- return tslib_1.__generator(this, function (_d) {
25
- switch (_d.label) {
26
- case 0:
27
- _b = JSON.parse(message), token = _b.token, timestamp = _b.timestamp, context = _b.context, payload = _b.payload;
28
- if (!(this.token !== token || this.socketChannel === undefined)) return [3 /*break*/, 4];
29
- if (!(this.socketChannel !== undefined)) return [3 /*break*/, 2];
30
- this.logger.info('Connection no longer valid for current message.');
31
- this.socketChannel.unsubscribe(this.notify);
32
- return [4 /*yield*/, this.socketChannel.close()];
33
- case 1:
34
- _d.sent();
35
- _d.label = 2;
36
- case 2:
37
- this.token = token;
38
- _c = this;
39
- return [4 /*yield*/, this.createSocketChannel(token)];
40
- case 3:
41
- _c.socketChannel = _d.sent();
42
- _d.label = 4;
43
- case 4: return [2 /*return*/, this.socketChannel.publish(JSON.stringify({
44
- receiptId: receiptId,
45
- originalTime: timestamp,
46
- departureTime: Date.now(),
47
- context: context,
48
- payload: payload,
49
- }))];
50
- }
51
- });
52
- });
53
- };
54
- BeaconSocketChannel.prototype.createSocketChannel = function (token) {
55
- return tslib_1.__awaiter(this, void 0, void 0, function () {
56
- var endpoint, _a, _b, _c, channel;
57
- return tslib_1.__generator(this, function (_d) {
58
- switch (_d.label) {
59
- case 0:
60
- endpoint = new URL(this.trackerEndpointUrl);
61
- _b = (_a = endpoint.searchParams).append;
62
- _c = [this.cidParameter];
63
- return [4 /*yield*/, this.cidAssigner.assignCid()];
64
- case 1:
65
- _b.apply(_a, _c.concat([_d.sent()]));
66
- if (token !== undefined) {
67
- endpoint.searchParams.append(this.tokenParameter, token);
68
- }
69
- channel = this.socketFactory(endpoint.toString(), this.loggerFactory("WebSocket#".concat(this.connectionIndex)));
70
- this.connectionIndex += 1;
71
- channel.subscribe(this.notify);
72
- return [2 /*return*/, channel];
73
- }
74
- });
75
- });
76
- };
77
- BeaconSocketChannel.prototype.subscribe = function (listener) {
19
+ async publish({ id: receiptId, message }) {
20
+ const { token, timestamp, context, payload } = JSON.parse(message);
21
+ if (this.token !== token || this.socketChannel === undefined) {
22
+ if (this.socketChannel !== undefined) {
23
+ this.logger.info('Connection no longer valid for current message.');
24
+ this.socketChannel.unsubscribe(this.notify);
25
+ await this.socketChannel.close();
26
+ }
27
+ this.token = token;
28
+ this.socketChannel = await this.createSocketChannel(token);
29
+ }
30
+ return this.socketChannel.publish(JSON.stringify({
31
+ receiptId: receiptId,
32
+ originalTime: timestamp,
33
+ departureTime: Date.now(),
34
+ context: context,
35
+ payload: payload,
36
+ }));
37
+ }
38
+ async createSocketChannel(token) {
39
+ const endpoint = new URL(this.trackerEndpointUrl);
40
+ endpoint.searchParams.append(this.cidParameter, await this.cidAssigner.assignCid());
41
+ if (token !== undefined) {
42
+ endpoint.searchParams.append(this.tokenParameter, token);
43
+ }
44
+ const channel = this.socketFactory(endpoint.toString(), this.loggerFactory(`WebSocket#${this.connectionIndex}`));
45
+ this.connectionIndex += 1;
46
+ channel.subscribe(this.notify);
47
+ return channel;
48
+ }
49
+ subscribe(listener) {
78
50
  if (!this.listeners.includes(listener)) {
79
51
  this.listeners.push(listener);
80
52
  }
81
- };
82
- BeaconSocketChannel.prototype.unsubscribe = function (listener) {
83
- var index = this.listeners.indexOf(listener);
53
+ }
54
+ unsubscribe(listener) {
55
+ const index = this.listeners.indexOf(listener);
84
56
  if (index >= 0) {
85
57
  this.listeners.splice(index, 1);
86
58
  }
87
- };
88
- BeaconSocketChannel.prototype.notify = function (message) {
89
- var _this = this;
90
- var confirmation;
59
+ }
60
+ notify(message) {
61
+ let confirmation;
91
62
  try {
92
63
  confirmation = JSON.parse(message);
93
64
  }
94
- catch (_a) {
65
+ catch {
95
66
  this.logger.error('Invalid JSON message received.');
96
67
  return;
97
68
  }
98
- var _b = confirmation.violations, violations = _b === void 0 ? [] : _b, receiptId = confirmation.receiptId;
99
- violations.forEach(function (violation) { return _this.logger.error(violation.message); });
69
+ const { violations = [], receiptId } = confirmation;
70
+ violations.forEach(violation => this.logger.error(violation.message));
100
71
  if (receiptId !== null) {
101
- this.listeners.forEach(function (dispatch) { return dispatch(receiptId); });
72
+ this.listeners.forEach(dispatch => dispatch(receiptId));
102
73
  }
103
- };
104
- BeaconSocketChannel.prototype.close = function () {
74
+ }
75
+ close() {
105
76
  if (this.socketChannel === undefined) {
106
77
  return Promise.resolve();
107
78
  }
108
79
  return this.socketChannel.close();
109
- };
110
- return BeaconSocketChannel;
111
- }());
80
+ }
81
+ }
112
82
  exports.BeaconSocketChannel = BeaconSocketChannel;
@@ -4,7 +4,7 @@ export interface Closeable {
4
4
  export interface OutputChannel<O> extends Closeable {
5
5
  publish(message: O): Promise<void>;
6
6
  }
7
- export declare type ChannelListener<T> = {
7
+ export type ChannelListener<T> = {
8
8
  (message: T): void;
9
9
  };
10
10
  export interface InputChannel<I> extends Closeable {
@@ -1,18 +1,16 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.EncodedChannel = void 0;
4
- var EncodedChannel = /** @class */ (function () {
5
- function EncodedChannel(channel, encoder) {
4
+ class EncodedChannel {
5
+ constructor(channel, encoder) {
6
6
  this.channel = channel;
7
7
  this.encode = encoder;
8
8
  }
9
- EncodedChannel.prototype.publish = function (message) {
10
- var _this = this;
11
- return this.encode(message).then((function (result) { return _this.channel.publish(result); }));
12
- };
13
- EncodedChannel.prototype.close = function () {
9
+ publish(message) {
10
+ return this.encode(message).then((result => this.channel.publish(result)));
11
+ }
12
+ close() {
14
13
  return this.channel.close();
15
- };
16
- return EncodedChannel;
17
- }());
14
+ }
15
+ }
18
16
  exports.EncodedChannel = EncodedChannel;
@@ -1,19 +1,19 @@
1
1
  import { Logger } from '../logging';
2
2
  import { DuplexChannel, OutputChannel } from './channel';
3
- export declare type MessageStamper<M, S> = {
3
+ export type MessageStamper<M, S> = {
4
4
  generate(message: M): S;
5
5
  };
6
6
  export declare class TimeStamper implements MessageStamper<any, string> {
7
7
  generate(): string;
8
8
  }
9
- export declare type Envelope<M, S> = {
9
+ export type Envelope<M, S> = {
10
10
  id: S;
11
11
  message: M;
12
12
  };
13
- declare type Options = {
13
+ type Options = {
14
14
  ackTimeout: number;
15
15
  };
16
- declare type Configuration<M, S> = Partial<Options> & {
16
+ type Configuration<M, S> = Partial<Options> & {
17
17
  channel: DuplexChannel<S, Envelope<M, S>>;
18
18
  stamper: MessageStamper<M, S>;
19
19
  logger?: Logger;