@croct/sdk 0.10.0 → 0.11.0-alpha.1
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/.src/activeRecord.ts +150 -0
- package/.src/base64Url.ts +18 -0
- package/.src/cache/cache.ts +15 -0
- package/.src/cache/fallbackCache.ts +29 -0
- package/.src/cache/inMemoryCache.ts +21 -0
- package/.src/cache/index.ts +4 -0
- package/.src/cache/localStorageCache.ts +85 -0
- package/.src/channel/beaconSocketChannel.ts +153 -0
- package/.src/channel/channel.ts +20 -0
- package/.src/channel/encodedChannel.ts +21 -0
- package/.src/channel/guaranteedChannel.ts +131 -0
- package/.src/channel/index.ts +8 -0
- package/.src/channel/queuedChannel.ts +112 -0
- package/.src/channel/retryChannel.ts +90 -0
- package/.src/channel/sandboxChannel.ts +43 -0
- package/.src/channel/socketChannel.ts +217 -0
- package/.src/cid/assigner.ts +3 -0
- package/.src/cid/cachedAssigner.ts +35 -0
- package/.src/cid/fixedAssigner.ts +13 -0
- package/.src/cid/index.ts +4 -0
- package/.src/cid/remoteAssigner.ts +47 -0
- package/.src/constants.ts +6 -0
- package/.src/container.ts +388 -0
- package/.src/contentFetcher.ts +226 -0
- package/.src/context.ts +137 -0
- package/.src/error.ts +31 -0
- package/.src/evaluator.ts +251 -0
- package/.src/eventManager.ts +53 -0
- package/.src/facade/contentFetcherFacade.ts +69 -0
- package/.src/facade/evaluatorFacade.ts +152 -0
- package/.src/facade/index.ts +7 -0
- package/.src/facade/sdkFacade.ts +291 -0
- package/.src/facade/sessionFacade.ts +14 -0
- package/.src/facade/sessionPatch.ts +32 -0
- package/.src/facade/trackerFacade.ts +98 -0
- package/.src/facade/userFacade.ts +26 -0
- package/.src/facade/userPatch.ts +32 -0
- package/.src/index.ts +4 -0
- package/.src/logging/consoleLogger.ts +37 -0
- package/.src/logging/index.ts +4 -0
- package/.src/logging/logger.ts +13 -0
- package/.src/logging/namespacedLogger.ts +32 -0
- package/.src/logging/nullLogger.ts +19 -0
- package/.src/namespacedStorage.ts +69 -0
- package/.src/patch.ts +64 -0
- package/.src/queue/capacityRestrictedQueue.ts +44 -0
- package/.src/queue/inMemoryQueue.ts +43 -0
- package/.src/queue/index.ts +5 -0
- package/.src/queue/monitoredQueue.ts +168 -0
- package/.src/queue/persistentQueue.ts +84 -0
- package/.src/queue/queue.ts +15 -0
- package/.src/retry/arbitraryPolicy.ts +21 -0
- package/.src/retry/backoffPolicy.ts +84 -0
- package/.src/retry/index.ts +5 -0
- package/.src/retry/maxAttemptsPolicy.ts +28 -0
- package/.src/retry/neverPolicy.ts +11 -0
- package/.src/retry/policy.ts +5 -0
- package/.src/schema/attributeSchema.ts +6 -0
- package/.src/schema/contentFetcherSchemas.ts +23 -0
- package/.src/schema/contentSchemas.ts +44 -0
- package/.src/schema/contextSchemas.ts +5 -0
- package/.src/schema/ecommerceSchemas.ts +179 -0
- package/.src/schema/evaluatorSchemas.ts +11 -0
- package/.src/schema/eventSchemas.ts +150 -0
- package/.src/schema/index.ts +11 -0
- package/.src/schema/loggerSchema.ts +12 -0
- package/.src/schema/operationSchemas.ts +102 -0
- package/.src/schema/sdkFacadeSchemas.ts +44 -0
- package/.src/schema/sdkSchemas.ts +49 -0
- package/.src/schema/tokenSchema.ts +42 -0
- package/.src/schema/userSchema.ts +184 -0
- package/.src/sdk.ts +174 -0
- package/.src/sdkEvents.ts +15 -0
- package/.src/sourceLocation.ts +85 -0
- package/.src/tab.ts +148 -0
- package/.src/token/cachedTokenStore.ts +34 -0
- package/.src/token/inMemoryTokenStore.ts +13 -0
- package/.src/token/index.ts +4 -0
- package/.src/token/replicatedTokenStore.ts +21 -0
- package/.src/token/token.ts +164 -0
- package/.src/tracker.ts +460 -0
- package/.src/trackingEvents.ts +456 -0
- package/.src/transformer.ts +7 -0
- package/.src/utilityTypes.ts +3 -0
- package/.src/uuid.ts +43 -0
- package/.src/validation/arrayType.ts +71 -0
- package/.src/validation/booleanType.ts +22 -0
- package/.src/validation/functionType.ts +22 -0
- package/.src/validation/index.ts +12 -0
- package/.src/validation/jsonType.ts +157 -0
- package/.src/validation/mixedSchema.ts +7 -0
- package/.src/validation/nullType.ts +22 -0
- package/.src/validation/numberType.ts +59 -0
- package/.src/validation/objectType.ts +138 -0
- package/.src/validation/schema.ts +21 -0
- package/.src/validation/stringType.ts +118 -0
- package/.src/validation/unionType.ts +53 -0
- package/.src/validation/violation.ts +23 -0
- package/activeRecord.js +33 -36
- package/base64Url.js +1 -0
- package/cache/cache.js +1 -0
- package/cache/fallbackCache.js +16 -32
- package/cache/inMemoryCache.js +10 -10
- package/cache/index.js +2 -1
- package/cache/localStorageCache.js +25 -25
- package/channel/beaconSocketChannel.d.ts +1 -1
- package/channel/beaconSocketChannel.js +50 -79
- package/channel/channel.d.ts +1 -1
- package/channel/channel.js +1 -0
- package/channel/encodedChannel.js +9 -10
- package/channel/guaranteedChannel.d.ts +4 -4
- package/channel/guaranteedChannel.js +42 -43
- package/channel/index.js +2 -1
- package/channel/queuedChannel.js +36 -64
- package/channel/retryChannel.d.ts +1 -1
- package/channel/retryChannel.js +45 -77
- package/channel/sandboxChannel.js +18 -18
- package/channel/socketChannel.d.ts +4 -4
- package/channel/socketChannel.js +78 -79
- package/cid/assigner.js +1 -0
- package/cid/cachedAssigner.js +16 -27
- package/cid/fixedAssigner.js +6 -6
- package/cid/index.js +2 -1
- package/cid/remoteAssigner.js +24 -36
- package/constants.d.ts +6 -5
- package/constants.js +7 -5
- package/container.d.ts +13 -6
- package/container.js +153 -168
- package/contentFetcher.d.ts +59 -0
- package/contentFetcher.js +130 -0
- package/context.d.ts +3 -3
- package/context.js +37 -38
- package/error.js +3 -2
- package/evaluator.d.ts +33 -24
- package/evaluator.js +127 -117
- package/eventManager.d.ts +1 -1
- package/eventManager.js +15 -15
- package/facade/contentFetcherFacade.d.ts +27 -0
- package/facade/contentFetcherFacade.js +41 -0
- package/facade/evaluatorFacade.d.ts +13 -3
- package/facade/evaluatorFacade.js +58 -72
- package/facade/index.js +1 -0
- package/facade/sdkFacade.d.ts +10 -3
- package/facade/sdkFacade.js +130 -141
- package/facade/sessionFacade.js +7 -7
- package/facade/sessionPatch.js +10 -13
- package/facade/trackerFacade.js +33 -38
- package/facade/userFacade.js +11 -11
- package/facade/userPatch.js +10 -13
- package/index.js +3 -2
- package/logging/consoleLogger.js +19 -35
- package/logging/index.js +2 -1
- package/logging/logger.js +1 -0
- package/logging/namespacedLogger.js +15 -15
- package/logging/nullLogger.js +11 -13
- package/namespacedStorage.js +31 -47
- package/package.json +13 -16
- package/patch.d.ts +1 -1
- package/patch.js +1 -0
- package/queue/capacityRestrictedQueue.js +18 -18
- package/queue/inMemoryQueue.js +23 -28
- package/queue/index.js +2 -1
- package/queue/monitoredQueue.d.ts +2 -2
- package/queue/monitoredQueue.js +40 -40
- package/queue/persistentQueue.js +34 -38
- package/queue/queue.js +1 -0
- package/retry/arbitraryPolicy.js +9 -10
- package/retry/backoffPolicy.d.ts +1 -1
- package/retry/backoffPolicy.js +12 -13
- package/retry/index.js +2 -1
- package/retry/maxAttemptsPolicy.js +8 -8
- package/retry/neverPolicy.js +7 -9
- package/retry/policy.js +1 -0
- package/schema/attributeSchema.js +2 -1
- package/schema/contentFetcherSchemas.d.ts +2 -0
- package/schema/contentFetcherSchemas.js +23 -0
- package/schema/contentSchemas.js +2 -1
- package/schema/contextSchemas.js +2 -1
- package/schema/ecommerceSchemas.js +2 -1
- package/schema/evaluatorSchemas.d.ts +2 -0
- package/schema/{evaluationSchemas.js → evaluatorSchemas.js} +4 -3
- package/schema/eventSchemas.js +6 -7
- package/schema/index.d.ts +2 -1
- package/schema/index.js +4 -2
- package/schema/loggerSchema.js +2 -1
- package/schema/operationSchemas.js +9 -8
- package/schema/sdkFacadeSchemas.js +10 -6
- package/schema/sdkSchemas.js +9 -5
- package/schema/tokenSchema.js +6 -4
- package/schema/userSchema.js +3 -2
- package/sdk.d.ts +9 -3
- package/sdk.js +82 -127
- package/sdkEvents.d.ts +3 -3
- package/sdkEvents.js +1 -0
- package/sourceLocation.d.ts +3 -3
- package/sourceLocation.js +14 -14
- package/tab.d.ts +5 -5
- package/tab.js +51 -80
- package/token/cachedTokenStore.js +10 -10
- package/token/inMemoryTokenStore.js +8 -8
- package/token/index.js +2 -1
- package/token/replicatedTokenStore.js +8 -8
- package/token/token.d.ts +9 -5
- package/token/token.js +64 -57
- package/tracker.d.ts +4 -4
- package/tracker.js +146 -122
- package/trackingEvents.d.ts +36 -36
- package/trackingEvents.js +13 -6
- package/transformer.js +2 -1
- package/utilityTypes.d.ts +2 -2
- package/utilityTypes.js +1 -0
- package/uuid.js +10 -7
- package/validation/arrayType.d.ts +2 -2
- package/validation/arrayType.js +30 -27
- package/validation/booleanType.js +12 -15
- package/validation/functionType.js +12 -15
- package/validation/index.js +2 -1
- package/validation/jsonType.d.ts +2 -2
- package/validation/jsonType.js +62 -80
- package/validation/mixedSchema.js +5 -7
- package/validation/nullType.js +12 -15
- package/validation/numberType.d.ts +1 -1
- package/validation/numberType.js +24 -22
- package/validation/objectType.d.ts +1 -1
- package/validation/objectType.js +62 -72
- package/validation/schema.js +7 -10
- package/validation/stringType.d.ts +1 -1
- package/validation/stringType.js +37 -47
- package/validation/unionType.js +28 -77
- package/validation/violation.js +2 -2
- package/schema/evaluationSchemas.d.ts +0 -2
package/queue/inMemoryQueue.js
CHANGED
|
@@ -1,42 +1,37 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.InMemoryQueue = void 0;
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
function InMemoryQueue() {
|
|
7
|
-
var _a;
|
|
8
|
-
var values = [];
|
|
9
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
|
10
|
-
values[_i] = arguments[_i];
|
|
11
|
-
}
|
|
4
|
+
class InMemoryQueue {
|
|
5
|
+
constructor(...values) {
|
|
12
6
|
this.queue = [];
|
|
13
|
-
|
|
7
|
+
this.queue.unshift(...values);
|
|
14
8
|
}
|
|
15
|
-
|
|
9
|
+
all() {
|
|
16
10
|
return this.queue.slice();
|
|
17
|
-
}
|
|
18
|
-
|
|
11
|
+
}
|
|
12
|
+
getCapacity() {
|
|
19
13
|
return Infinity;
|
|
20
|
-
}
|
|
21
|
-
|
|
14
|
+
}
|
|
15
|
+
isEmpty() {
|
|
22
16
|
return this.queue.length === 0;
|
|
23
|
-
}
|
|
24
|
-
|
|
17
|
+
}
|
|
18
|
+
push(value) {
|
|
25
19
|
this.queue.push(value);
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
20
|
+
}
|
|
21
|
+
peek() {
|
|
22
|
+
var _a;
|
|
23
|
+
return (_a = this.queue[0]) !== null && _a !== void 0 ? _a : null;
|
|
24
|
+
}
|
|
25
|
+
shift() {
|
|
26
|
+
const value = this.queue.shift();
|
|
27
|
+
if (value === undefined) {
|
|
33
28
|
throw new Error('The queue is empty.');
|
|
34
29
|
}
|
|
35
30
|
return value;
|
|
36
|
-
}
|
|
37
|
-
|
|
31
|
+
}
|
|
32
|
+
length() {
|
|
38
33
|
return this.queue.length;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
}());
|
|
34
|
+
}
|
|
35
|
+
}
|
|
42
36
|
exports.InMemoryQueue = InMemoryQueue;
|
|
37
|
+
//# sourceMappingURL=inMemoryQueue.js.map
|
package/queue/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.PersistentQueue = exports.MonitoredQueue = exports.InMemoryQueue = exports.CapacityRestrictedQueue = void 0;
|
|
4
|
-
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
5
|
tslib_1.__exportStar(require("./queue"), exports);
|
|
6
6
|
var capacityRestrictedQueue_1 = require("./capacityRestrictedQueue");
|
|
7
7
|
Object.defineProperty(exports, "CapacityRestrictedQueue", { enumerable: true, get: function () { return capacityRestrictedQueue_1.CapacityRestrictedQueue; } });
|
|
@@ -11,3 +11,4 @@ var monitoredQueue_1 = require("./monitoredQueue");
|
|
|
11
11
|
Object.defineProperty(exports, "MonitoredQueue", { enumerable: true, get: function () { return monitoredQueue_1.MonitoredQueue; } });
|
|
12
12
|
var persistentQueue_1 = require("./persistentQueue");
|
|
13
13
|
Object.defineProperty(exports, "PersistentQueue", { enumerable: true, get: function () { return persistentQueue_1.PersistentQueue; } });
|
|
14
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Queue } from './queue';
|
|
2
2
|
import { Logger } from '../logging';
|
|
3
|
-
export
|
|
4
|
-
export
|
|
3
|
+
export type QueueStatus = 'halfEmpty' | 'almostEmpty' | 'empty' | 'halfFull' | 'almostFull' | 'full';
|
|
4
|
+
export type QueueCallback<T> = {
|
|
5
5
|
(queue: Queue<T>): void;
|
|
6
6
|
};
|
|
7
7
|
export declare class MonitoredQueue<T> implements Queue<T> {
|
package/queue/monitoredQueue.js
CHANGED
|
@@ -1,22 +1,23 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.MonitoredQueue = void 0;
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
const logging_1 = require("../logging");
|
|
5
|
+
class MonitoredQueue {
|
|
6
|
+
constructor(queue, logger) {
|
|
7
7
|
this.callbacks = {};
|
|
8
8
|
this.queue = queue;
|
|
9
9
|
this.logger = logger !== null && logger !== void 0 ? logger : new logging_1.NullLogger();
|
|
10
10
|
this.updateStatus();
|
|
11
11
|
}
|
|
12
|
-
|
|
12
|
+
all() {
|
|
13
13
|
return this.queue.all();
|
|
14
|
-
}
|
|
15
|
-
|
|
14
|
+
}
|
|
15
|
+
getCapacity() {
|
|
16
16
|
return this.queue.getCapacity();
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
var
|
|
17
|
+
}
|
|
18
|
+
addCallback(status, callback) {
|
|
19
|
+
var _a;
|
|
20
|
+
const callbacks = (_a = this.callbacks[status]) !== null && _a !== void 0 ? _a : [];
|
|
20
21
|
if (!callbacks.includes(callback)) {
|
|
21
22
|
callbacks.push(callback);
|
|
22
23
|
}
|
|
@@ -38,30 +39,29 @@ var MonitoredQueue = /** @class */ (function () {
|
|
|
38
39
|
}
|
|
39
40
|
break;
|
|
40
41
|
}
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
if (
|
|
42
|
+
}
|
|
43
|
+
removeCallback(type, callback) {
|
|
44
|
+
const callbacks = this.callbacks[type];
|
|
45
|
+
if (callbacks == null) {
|
|
45
46
|
return;
|
|
46
47
|
}
|
|
47
|
-
|
|
48
|
+
const index = callbacks.indexOf(callback);
|
|
48
49
|
if (index >= 0) {
|
|
49
50
|
callbacks.splice(index, 1);
|
|
50
51
|
}
|
|
51
|
-
}
|
|
52
|
-
|
|
52
|
+
}
|
|
53
|
+
setStatus(status) {
|
|
53
54
|
if (this.status === status) {
|
|
54
55
|
return;
|
|
55
56
|
}
|
|
56
|
-
this.logger.debug(
|
|
57
|
+
this.logger.debug(`Queue status changed to "${status}"`);
|
|
57
58
|
this.report(status);
|
|
58
59
|
this.status = status;
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
var callbacks = this.callbacks[status];
|
|
60
|
+
}
|
|
61
|
+
report(status) {
|
|
62
|
+
const callbacks = this.callbacks[status];
|
|
63
63
|
if (callbacks !== undefined) {
|
|
64
|
-
callbacks.forEach(
|
|
64
|
+
callbacks.forEach(callback => callback(this));
|
|
65
65
|
}
|
|
66
66
|
switch (status) {
|
|
67
67
|
case 'empty':
|
|
@@ -75,28 +75,28 @@ var MonitoredQueue = /** @class */ (function () {
|
|
|
75
75
|
default:
|
|
76
76
|
break;
|
|
77
77
|
}
|
|
78
|
-
}
|
|
79
|
-
|
|
78
|
+
}
|
|
79
|
+
isEmpty() {
|
|
80
80
|
return this.queue.isEmpty();
|
|
81
|
-
}
|
|
82
|
-
|
|
81
|
+
}
|
|
82
|
+
length() {
|
|
83
83
|
return this.queue.length();
|
|
84
|
-
}
|
|
85
|
-
|
|
84
|
+
}
|
|
85
|
+
peek() {
|
|
86
86
|
return this.queue.peek();
|
|
87
|
-
}
|
|
88
|
-
|
|
87
|
+
}
|
|
88
|
+
push(value) {
|
|
89
89
|
this.queue.push(value);
|
|
90
90
|
this.updateStatus();
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
|
|
91
|
+
}
|
|
92
|
+
shift() {
|
|
93
|
+
const value = this.queue.shift();
|
|
94
94
|
this.updateStatus();
|
|
95
95
|
return value;
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
96
|
+
}
|
|
97
|
+
updateStatus() {
|
|
98
|
+
const length = this.queue.length();
|
|
99
|
+
const capacity = this.getCapacity();
|
|
100
100
|
if (length <= capacity * 0.5) {
|
|
101
101
|
if (length === 0) {
|
|
102
102
|
this.setStatus('empty');
|
|
@@ -118,7 +118,7 @@ var MonitoredQueue = /** @class */ (function () {
|
|
|
118
118
|
else {
|
|
119
119
|
this.setStatus('halfFull');
|
|
120
120
|
}
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
}());
|
|
121
|
+
}
|
|
122
|
+
}
|
|
124
123
|
exports.MonitoredQueue = MonitoredQueue;
|
|
124
|
+
//# sourceMappingURL=monitoredQueue.js.map
|
package/queue/persistentQueue.js
CHANGED
|
@@ -1,58 +1,54 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.PersistentQueue = void 0;
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
if (key === void 0) { key = 'queue'; }
|
|
4
|
+
class PersistentQueue {
|
|
5
|
+
constructor(storage, key = 'queue') {
|
|
7
6
|
this.storage = storage;
|
|
8
7
|
this.key = key;
|
|
9
8
|
}
|
|
10
|
-
|
|
9
|
+
all() {
|
|
11
10
|
return this.queue.slice();
|
|
12
|
-
}
|
|
13
|
-
|
|
11
|
+
}
|
|
12
|
+
getCapacity() {
|
|
14
13
|
return Infinity;
|
|
15
|
-
}
|
|
16
|
-
|
|
14
|
+
}
|
|
15
|
+
isEmpty() {
|
|
17
16
|
return this.length() === 0;
|
|
18
|
-
}
|
|
19
|
-
|
|
17
|
+
}
|
|
18
|
+
length() {
|
|
20
19
|
return this.queue.length;
|
|
21
|
-
}
|
|
22
|
-
|
|
20
|
+
}
|
|
21
|
+
push(value) {
|
|
23
22
|
this.queue.push(value);
|
|
24
23
|
this.flush();
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
|
|
24
|
+
}
|
|
25
|
+
peek() {
|
|
26
|
+
const item = this.queue[0];
|
|
28
27
|
if (item === undefined) {
|
|
29
28
|
return null;
|
|
30
29
|
}
|
|
31
30
|
return item;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
if (
|
|
31
|
+
}
|
|
32
|
+
shift() {
|
|
33
|
+
const value = this.queue.shift();
|
|
34
|
+
if (value === undefined) {
|
|
36
35
|
throw new Error('The queue is empty.');
|
|
37
36
|
}
|
|
38
37
|
this.flush();
|
|
39
38
|
return value;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
this.storage.
|
|
53
|
-
};
|
|
54
|
-
PersistentQueue.prototype.load = function () {
|
|
55
|
-
var data = this.storage.getItem(this.key);
|
|
39
|
+
}
|
|
40
|
+
get queue() {
|
|
41
|
+
if (this.cache === undefined) {
|
|
42
|
+
this.cache = this.load();
|
|
43
|
+
}
|
|
44
|
+
return this.cache;
|
|
45
|
+
}
|
|
46
|
+
flush() {
|
|
47
|
+
var _a;
|
|
48
|
+
this.storage.setItem(this.key, JSON.stringify((_a = this.cache) !== null && _a !== void 0 ? _a : []));
|
|
49
|
+
}
|
|
50
|
+
load() {
|
|
51
|
+
const data = this.storage.getItem(this.key);
|
|
56
52
|
if (data === null) {
|
|
57
53
|
return [];
|
|
58
54
|
}
|
|
@@ -62,7 +58,7 @@ var PersistentQueue = /** @class */ (function () {
|
|
|
62
58
|
catch (error) {
|
|
63
59
|
return [];
|
|
64
60
|
}
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
}());
|
|
61
|
+
}
|
|
62
|
+
}
|
|
68
63
|
exports.PersistentQueue = PersistentQueue;
|
|
64
|
+
//# sourceMappingURL=persistentQueue.js.map
|
package/queue/queue.js
CHANGED
package/retry/arbitraryPolicy.js
CHANGED
|
@@ -1,20 +1,19 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.ArbitraryPolicy = void 0;
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
function ArbitraryPolicy(delays) {
|
|
4
|
+
class ArbitraryPolicy {
|
|
5
|
+
constructor(delays) {
|
|
7
6
|
if (delays.length < 1) {
|
|
8
7
|
throw new Error('The list of delays cannot be empty.');
|
|
9
8
|
}
|
|
10
|
-
this.delays =
|
|
9
|
+
this.delays = [...delays];
|
|
11
10
|
}
|
|
12
|
-
|
|
11
|
+
getDelay(attempt) {
|
|
13
12
|
return this.delays[Math.min(attempt < 0 ? 0 : attempt, this.delays.length - 1)];
|
|
14
|
-
}
|
|
15
|
-
|
|
13
|
+
}
|
|
14
|
+
shouldRetry() {
|
|
16
15
|
return true;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
}());
|
|
16
|
+
}
|
|
17
|
+
}
|
|
20
18
|
exports.ArbitraryPolicy = ArbitraryPolicy;
|
|
19
|
+
//# sourceMappingURL=arbitraryPolicy.js.map
|
package/retry/backoffPolicy.d.ts
CHANGED
package/retry/backoffPolicy.js
CHANGED
|
@@ -1,15 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.BackoffPolicy = void 0;
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
if (options === void 0) { options = {}; }
|
|
4
|
+
class BackoffPolicy {
|
|
5
|
+
constructor(options = {}) {
|
|
7
6
|
this.minRetryDelay = 1000;
|
|
8
7
|
this.maxRetryDelay = 30000;
|
|
9
8
|
this.backoffFactor = 2;
|
|
10
9
|
this.backoffJitter = 1;
|
|
11
10
|
this.maxAttempts = Infinity;
|
|
12
|
-
|
|
11
|
+
const { minRetryDelay = this.minRetryDelay, maxRetryDelay = this.maxRetryDelay, backoffFactor = this.backoffFactor, backoffJitter = this.backoffJitter, maxAttempts = this.maxAttempts, } = options;
|
|
13
12
|
if (minRetryDelay < 0) {
|
|
14
13
|
throw new Error('The minimum retry delay must be non-negative.');
|
|
15
14
|
}
|
|
@@ -36,22 +35,22 @@ var BackoffPolicy = /** @class */ (function () {
|
|
|
36
35
|
*
|
|
37
36
|
* @see https://www.awsarchitectureblog.com/2015/03/backoff.html
|
|
38
37
|
*/
|
|
39
|
-
|
|
40
|
-
|
|
38
|
+
getDelay(attempt) {
|
|
39
|
+
let delay = Math.min(Math.max(this.backoffFactor ** attempt, this.minRetryDelay), this.maxRetryDelay);
|
|
41
40
|
if (this.backoffJitter > 0) {
|
|
42
41
|
// Jitter will result in a random value between the minimum and
|
|
43
42
|
// calculated delay for a given attempt.
|
|
44
|
-
|
|
45
|
-
|
|
43
|
+
const min = Math.ceil(this.minRetryDelay);
|
|
44
|
+
const max = Math.floor(delay);
|
|
46
45
|
delay = Math.floor(Math.random() * (max - min + 1)) + min;
|
|
47
46
|
}
|
|
48
47
|
// Removing any fractional digits
|
|
49
48
|
delay -= delay % 1;
|
|
50
49
|
return delay;
|
|
51
|
-
}
|
|
52
|
-
|
|
50
|
+
}
|
|
51
|
+
shouldRetry(attempt) {
|
|
53
52
|
return attempt < this.maxAttempts;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
}());
|
|
53
|
+
}
|
|
54
|
+
}
|
|
57
55
|
exports.BackoffPolicy = BackoffPolicy;
|
|
56
|
+
//# sourceMappingURL=backoffPolicy.js.map
|
package/retry/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.NeverPolicy = exports.MaxAttemptsPolicy = exports.BackoffPolicy = exports.ArbitraryPolicy = void 0;
|
|
4
|
-
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
5
|
tslib_1.__exportStar(require("./policy"), exports);
|
|
6
6
|
var arbitraryPolicy_1 = require("./arbitraryPolicy");
|
|
7
7
|
Object.defineProperty(exports, "ArbitraryPolicy", { enumerable: true, get: function () { return arbitraryPolicy_1.ArbitraryPolicy; } });
|
|
@@ -11,3 +11,4 @@ var maxAttemptsPolicy_1 = require("./maxAttemptsPolicy");
|
|
|
11
11
|
Object.defineProperty(exports, "MaxAttemptsPolicy", { enumerable: true, get: function () { return maxAttemptsPolicy_1.MaxAttemptsPolicy; } });
|
|
12
12
|
var neverPolicy_1 = require("./neverPolicy");
|
|
13
13
|
Object.defineProperty(exports, "NeverPolicy", { enumerable: true, get: function () { return neverPolicy_1.NeverPolicy; } });
|
|
14
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.MaxAttemptsPolicy = void 0;
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
class MaxAttemptsPolicy {
|
|
5
|
+
constructor(delay, maxAttempts) {
|
|
6
6
|
if (delay < 0) {
|
|
7
7
|
throw new Error('Delay must be non-negative.');
|
|
8
8
|
}
|
|
@@ -12,12 +12,12 @@ var MaxAttemptsPolicy = /** @class */ (function () {
|
|
|
12
12
|
this.maxAttempts = maxAttempts;
|
|
13
13
|
this.delay = delay;
|
|
14
14
|
}
|
|
15
|
-
|
|
15
|
+
getDelay() {
|
|
16
16
|
return this.delay;
|
|
17
|
-
}
|
|
18
|
-
|
|
17
|
+
}
|
|
18
|
+
shouldRetry(attempt) {
|
|
19
19
|
return attempt < this.maxAttempts;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
}());
|
|
20
|
+
}
|
|
21
|
+
}
|
|
23
22
|
exports.MaxAttemptsPolicy = MaxAttemptsPolicy;
|
|
23
|
+
//# sourceMappingURL=maxAttemptsPolicy.js.map
|
package/retry/neverPolicy.js
CHANGED
|
@@ -1,15 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.NeverPolicy = void 0;
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
}
|
|
7
|
-
NeverPolicy.prototype.getDelay = function () {
|
|
4
|
+
class NeverPolicy {
|
|
5
|
+
getDelay() {
|
|
8
6
|
return Infinity;
|
|
9
|
-
}
|
|
10
|
-
|
|
7
|
+
}
|
|
8
|
+
shouldRetry() {
|
|
11
9
|
return false;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
}());
|
|
10
|
+
}
|
|
11
|
+
}
|
|
15
12
|
exports.NeverPolicy = NeverPolicy;
|
|
13
|
+
//# sourceMappingURL=neverPolicy.js.map
|
package/retry/policy.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.attributeNameSchema = void 0;
|
|
4
|
-
|
|
4
|
+
const validation_1 = require("../validation");
|
|
5
5
|
exports.attributeNameSchema = new validation_1.StringType({
|
|
6
6
|
maxLength: 50,
|
|
7
7
|
format: 'identifier',
|
|
8
8
|
});
|
|
9
|
+
//# sourceMappingURL=attributeSchema.js.map
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.fetchOptionsSchema = void 0;
|
|
4
|
+
const validation_1 = require("../validation");
|
|
5
|
+
exports.fetchOptionsSchema = new validation_1.ObjectType({
|
|
6
|
+
properties: {
|
|
7
|
+
timeout: new validation_1.NumberType({
|
|
8
|
+
integer: true,
|
|
9
|
+
minimum: 0,
|
|
10
|
+
}),
|
|
11
|
+
version: new validation_1.UnionType(new validation_1.StringType({
|
|
12
|
+
pattern: /^\d+$/,
|
|
13
|
+
}), new validation_1.NumberType({
|
|
14
|
+
integer: true,
|
|
15
|
+
minimum: 1,
|
|
16
|
+
})),
|
|
17
|
+
preferredLocale: new validation_1.StringType({
|
|
18
|
+
pattern: /^[a-z]{2,3}([-_][a-z]{2,3})?$/i,
|
|
19
|
+
}),
|
|
20
|
+
attributes: new validation_1.JsonObjectType(),
|
|
21
|
+
},
|
|
22
|
+
});
|
|
23
|
+
//# sourceMappingURL=contentFetcherSchemas.js.map
|
package/schema/contentSchemas.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.postDetails = void 0;
|
|
4
|
-
|
|
4
|
+
const validation_1 = require("../validation");
|
|
5
5
|
exports.postDetails = new validation_1.ObjectType({
|
|
6
6
|
required: ['postId', 'title', 'publishTime'],
|
|
7
7
|
properties: {
|
|
@@ -44,3 +44,4 @@ exports.postDetails = new validation_1.ObjectType({
|
|
|
44
44
|
updateTime: new validation_1.NumberType(),
|
|
45
45
|
},
|
|
46
46
|
});
|
|
47
|
+
//# sourceMappingURL=contentSchemas.js.map
|
package/schema/contextSchemas.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.tokenScopeSchema = void 0;
|
|
4
|
-
|
|
4
|
+
const validation_1 = require("../validation");
|
|
5
5
|
exports.tokenScopeSchema = new validation_1.StringType({
|
|
6
6
|
enumeration: ['global', 'contextual', 'isolated'],
|
|
7
7
|
});
|
|
8
|
+
//# sourceMappingURL=contextSchemas.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.order = exports.orderItem = exports.cart = exports.cartItem = exports.productDetails = void 0;
|
|
4
|
-
|
|
4
|
+
const validation_1 = require("../validation");
|
|
5
5
|
exports.productDetails = new validation_1.ObjectType({
|
|
6
6
|
required: ['productId', 'name', 'displayPrice'],
|
|
7
7
|
properties: {
|
|
@@ -175,3 +175,4 @@ exports.order = new validation_1.ObjectType({
|
|
|
175
175
|
}),
|
|
176
176
|
},
|
|
177
177
|
});
|
|
178
|
+
//# sourceMappingURL=ecommerceSchemas.js.map
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
|
|
5
|
-
exports.
|
|
3
|
+
exports.evaluationOptionsSchema = void 0;
|
|
4
|
+
const validation_1 = require("../validation");
|
|
5
|
+
exports.evaluationOptionsSchema = new validation_1.ObjectType({
|
|
6
6
|
properties: {
|
|
7
7
|
timeout: new validation_1.NumberType({
|
|
8
8
|
integer: true,
|
|
@@ -11,3 +11,4 @@ exports.optionsSchema = new validation_1.ObjectType({
|
|
|
11
11
|
attributes: new validation_1.JsonObjectType(),
|
|
12
12
|
},
|
|
13
13
|
});
|
|
14
|
+
//# sourceMappingURL=evaluatorSchemas.js.map
|
package/schema/eventSchemas.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.eventOccurred = exports.linkOpened = exports.postViewed = exports.interestShown = exports.goalCompleted = exports.userSignedUp = exports.productViewed = exports.orderPlaced = exports.checkoutStarted = exports.cartViewed = exports.cartModified = void 0;
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
4
|
+
const validation_1 = require("../validation");
|
|
5
|
+
const ecommerceSchemas_1 = require("./ecommerceSchemas");
|
|
6
|
+
const userSchema_1 = require("./userSchema");
|
|
7
|
+
const contentSchemas_1 = require("./contentSchemas");
|
|
8
8
|
exports.cartModified = new validation_1.ObjectType({
|
|
9
9
|
required: ['cart'],
|
|
10
10
|
properties: {
|
|
@@ -88,9 +88,7 @@ exports.postViewed = new validation_1.ObjectType({
|
|
|
88
88
|
exports.linkOpened = new validation_1.ObjectType({
|
|
89
89
|
required: ['link'],
|
|
90
90
|
properties: {
|
|
91
|
-
link: new validation_1.StringType(
|
|
92
|
-
format: 'uri-reference',
|
|
93
|
-
}),
|
|
91
|
+
link: new validation_1.StringType(),
|
|
94
92
|
},
|
|
95
93
|
});
|
|
96
94
|
exports.eventOccurred = new validation_1.ObjectType({
|
|
@@ -129,3 +127,4 @@ exports.eventOccurred = new validation_1.ObjectType({
|
|
|
129
127
|
}),
|
|
130
128
|
},
|
|
131
129
|
});
|
|
130
|
+
//# sourceMappingURL=eventSchemas.js.map
|
package/schema/index.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export * from './contextSchemas';
|
|
2
2
|
export * from './ecommerceSchemas';
|
|
3
|
-
export * from './
|
|
3
|
+
export * from './evaluatorSchemas';
|
|
4
|
+
export * from './contentFetcherSchemas';
|
|
4
5
|
export * from './eventSchemas';
|
|
5
6
|
export * from './loggerSchema';
|
|
6
7
|
export * from './operationSchemas';
|
package/schema/index.js
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
|
|
3
|
+
const tslib_1 = require("tslib");
|
|
4
4
|
tslib_1.__exportStar(require("./contextSchemas"), exports);
|
|
5
5
|
tslib_1.__exportStar(require("./ecommerceSchemas"), exports);
|
|
6
|
-
tslib_1.__exportStar(require("./
|
|
6
|
+
tslib_1.__exportStar(require("./evaluatorSchemas"), exports);
|
|
7
|
+
tslib_1.__exportStar(require("./contentFetcherSchemas"), exports);
|
|
7
8
|
tslib_1.__exportStar(require("./eventSchemas"), exports);
|
|
8
9
|
tslib_1.__exportStar(require("./loggerSchema"), exports);
|
|
9
10
|
tslib_1.__exportStar(require("./operationSchemas"), exports);
|
|
@@ -11,3 +12,4 @@ tslib_1.__exportStar(require("./sdkFacadeSchemas"), exports);
|
|
|
11
12
|
tslib_1.__exportStar(require("./sdkSchemas"), exports);
|
|
12
13
|
tslib_1.__exportStar(require("./tokenSchema"), exports);
|
|
13
14
|
tslib_1.__exportStar(require("./userSchema"), exports);
|
|
15
|
+
//# sourceMappingURL=index.js.map
|