@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/facade/userFacade.js
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.UserFacade = void 0;
|
|
4
|
+
var userPatch_1 = require("./userPatch");
|
|
2
5
|
var UserFacade = /** @class */ (function () {
|
|
3
6
|
function UserFacade(context, tracker) {
|
|
4
7
|
this.context = context;
|
|
@@ -11,8 +14,8 @@ var UserFacade = /** @class */ (function () {
|
|
|
11
14
|
return this.context.isAnonymous();
|
|
12
15
|
};
|
|
13
16
|
UserFacade.prototype.edit = function () {
|
|
14
|
-
return new UserPatch(this.tracker);
|
|
17
|
+
return new userPatch_1.UserPatch(this.tracker);
|
|
15
18
|
};
|
|
16
19
|
return UserFacade;
|
|
17
20
|
}());
|
|
18
|
-
|
|
21
|
+
exports.UserFacade = UserFacade;
|
package/facade/userPatch.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import ActiveRecord from '../activeRecord';
|
|
2
|
-
import Tracker from '../tracker';
|
|
1
|
+
import { ActiveRecord } from '../activeRecord';
|
|
2
|
+
import { Tracker } from '../tracker';
|
|
3
3
|
import { UserProfileChanged } from '../trackingEvents';
|
|
4
|
-
export
|
|
4
|
+
export declare class UserPatch extends ActiveRecord<UserProfileChanged> {
|
|
5
5
|
private readonly tracker;
|
|
6
6
|
constructor(tracker: Tracker);
|
|
7
7
|
save(): Promise<UserProfileChanged>;
|
package/facade/userPatch.js
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.UserPatch = void 0;
|
|
4
|
+
var tslib_1 = require("tslib");
|
|
5
|
+
var activeRecord_1 = require("../activeRecord");
|
|
3
6
|
var UserPatch = /** @class */ (function (_super) {
|
|
4
|
-
__extends(UserPatch, _super);
|
|
7
|
+
tslib_1.__extends(UserPatch, _super);
|
|
5
8
|
function UserPatch(tracker) {
|
|
6
9
|
var _this = _super.call(this) || this;
|
|
7
10
|
_this.tracker = tracker;
|
|
@@ -23,5 +26,5 @@ var UserPatch = /** @class */ (function (_super) {
|
|
|
23
26
|
return promise;
|
|
24
27
|
};
|
|
25
28
|
return UserPatch;
|
|
26
|
-
}(ActiveRecord));
|
|
27
|
-
|
|
29
|
+
}(activeRecord_1.ActiveRecord));
|
|
30
|
+
exports.UserPatch = UserPatch;
|
package/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { VERSION } from './constants';
|
|
2
|
-
import Sdk,
|
|
3
|
-
export { Sdk
|
|
2
|
+
import { Sdk, Configuration } from './sdk';
|
|
3
|
+
export { Sdk, Configuration, VERSION };
|
package/index.js
CHANGED
|
@@ -1,3 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.VERSION = exports.Sdk = void 0;
|
|
4
|
+
var constants_1 = require("./constants");
|
|
5
|
+
Object.defineProperty(exports, "VERSION", { enumerable: true, get: function () { return constants_1.VERSION; } });
|
|
6
|
+
var sdk_1 = require("./sdk");
|
|
7
|
+
Object.defineProperty(exports, "Sdk", { enumerable: true, get: function () { return sdk_1.Sdk; } });
|
package/json.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Logger } from './
|
|
2
|
-
export
|
|
1
|
+
import { Logger } from './logger';
|
|
2
|
+
export declare class ConsoleLogger implements Logger {
|
|
3
3
|
private readonly namespace?;
|
|
4
4
|
constructor(namespace?: string);
|
|
5
5
|
get debug(): (message: string) => void;
|
package/logging/consoleLogger.js
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ConsoleLogger = void 0;
|
|
1
4
|
var ConsoleLogger = /** @class */ (function () {
|
|
2
5
|
function ConsoleLogger(namespace) {
|
|
3
6
|
this.namespace = namespace;
|
|
@@ -6,28 +9,28 @@ var ConsoleLogger = /** @class */ (function () {
|
|
|
6
9
|
get: function () {
|
|
7
10
|
return this.bind(window.console.debug);
|
|
8
11
|
},
|
|
9
|
-
enumerable:
|
|
12
|
+
enumerable: false,
|
|
10
13
|
configurable: true
|
|
11
14
|
});
|
|
12
15
|
Object.defineProperty(ConsoleLogger.prototype, "info", {
|
|
13
16
|
get: function () {
|
|
14
17
|
return this.bind(window.console.info);
|
|
15
18
|
},
|
|
16
|
-
enumerable:
|
|
19
|
+
enumerable: false,
|
|
17
20
|
configurable: true
|
|
18
21
|
});
|
|
19
22
|
Object.defineProperty(ConsoleLogger.prototype, "warn", {
|
|
20
23
|
get: function () {
|
|
21
24
|
return this.bind(window.console.warn);
|
|
22
25
|
},
|
|
23
|
-
enumerable:
|
|
26
|
+
enumerable: false,
|
|
24
27
|
configurable: true
|
|
25
28
|
});
|
|
26
29
|
Object.defineProperty(ConsoleLogger.prototype, "error", {
|
|
27
30
|
get: function () {
|
|
28
31
|
return this.bind(window.console.error);
|
|
29
32
|
},
|
|
30
|
-
enumerable:
|
|
33
|
+
enumerable: false,
|
|
31
34
|
configurable: true
|
|
32
35
|
});
|
|
33
36
|
ConsoleLogger.prototype.bind = function (method) {
|
|
@@ -38,4 +41,4 @@ var ConsoleLogger = /** @class */ (function () {
|
|
|
38
41
|
};
|
|
39
42
|
return ConsoleLogger;
|
|
40
43
|
}());
|
|
41
|
-
|
|
44
|
+
exports.ConsoleLogger = ConsoleLogger;
|
package/logging/index.d.ts
CHANGED
|
@@ -1,9 +1,4 @@
|
|
|
1
|
-
export
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
error(message: string): void;
|
|
6
|
-
}
|
|
7
|
-
export interface LoggerFactory {
|
|
8
|
-
(namespace?: string): Logger;
|
|
9
|
-
}
|
|
1
|
+
export * from './logger';
|
|
2
|
+
export { ConsoleLogger } from './consoleLogger';
|
|
3
|
+
export { NamespacedLogger } from './namespacedLogger';
|
|
4
|
+
export { NullLogger } from './nullLogger';
|
package/logging/index.js
CHANGED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.NullLogger = exports.NamespacedLogger = exports.ConsoleLogger = void 0;
|
|
4
|
+
var tslib_1 = require("tslib");
|
|
5
|
+
tslib_1.__exportStar(require("./logger"), exports);
|
|
6
|
+
var consoleLogger_1 = require("./consoleLogger");
|
|
7
|
+
Object.defineProperty(exports, "ConsoleLogger", { enumerable: true, get: function () { return consoleLogger_1.ConsoleLogger; } });
|
|
8
|
+
var namespacedLogger_1 = require("./namespacedLogger");
|
|
9
|
+
Object.defineProperty(exports, "NamespacedLogger", { enumerable: true, get: function () { return namespacedLogger_1.NamespacedLogger; } });
|
|
10
|
+
var nullLogger_1 = require("./nullLogger");
|
|
11
|
+
Object.defineProperty(exports, "NullLogger", { enumerable: true, get: function () { return nullLogger_1.NullLogger; } });
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Logger } from './
|
|
2
|
-
export
|
|
1
|
+
import { Logger } from './logger';
|
|
2
|
+
export declare class NamespacedLogger implements Logger {
|
|
3
3
|
private readonly logger;
|
|
4
4
|
private readonly namespace;
|
|
5
5
|
constructor(logger: Logger, namespace: string);
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.NamespacedLogger = void 0;
|
|
1
4
|
var NamespacedLogger = /** @class */ (function () {
|
|
2
5
|
function NamespacedLogger(logger, namespace) {
|
|
3
6
|
this.logger = logger;
|
|
@@ -20,4 +23,4 @@ var NamespacedLogger = /** @class */ (function () {
|
|
|
20
23
|
};
|
|
21
24
|
return NamespacedLogger;
|
|
22
25
|
}());
|
|
23
|
-
|
|
26
|
+
exports.NamespacedLogger = NamespacedLogger;
|
package/logging/nullLogger.d.ts
CHANGED
package/logging/nullLogger.js
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.NullLogger = void 0;
|
|
1
4
|
var NullLogger = /** @class */ (function () {
|
|
2
5
|
function NullLogger() {
|
|
3
6
|
}
|
|
@@ -15,4 +18,4 @@ var NullLogger = /** @class */ (function () {
|
|
|
15
18
|
};
|
|
16
19
|
return NullLogger;
|
|
17
20
|
}());
|
|
18
|
-
|
|
21
|
+
exports.NullLogger = NullLogger;
|
package/namespacedStorage.d.ts
CHANGED
package/namespacedStorage.js
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.NamespacedStorage = void 0;
|
|
4
|
+
var tslib_1 = require("tslib");
|
|
2
5
|
var NamespacedStorage = /** @class */ (function () {
|
|
3
6
|
function NamespacedStorage(storage, namespace) {
|
|
4
7
|
if (namespace === '') {
|
|
@@ -11,13 +14,13 @@ var NamespacedStorage = /** @class */ (function () {
|
|
|
11
14
|
get: function () {
|
|
12
15
|
return this.getKeys().length;
|
|
13
16
|
},
|
|
14
|
-
enumerable:
|
|
17
|
+
enumerable: false,
|
|
15
18
|
configurable: true
|
|
16
19
|
});
|
|
17
20
|
NamespacedStorage.prototype.clear = function () {
|
|
18
21
|
var e_1, _a;
|
|
19
22
|
try {
|
|
20
|
-
for (var _b = __values(this.getKeys()), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
23
|
+
for (var _b = tslib_1.__values(this.getKeys()), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
21
24
|
var key = _c.value;
|
|
22
25
|
this.storage.removeItem(key);
|
|
23
26
|
}
|
|
@@ -65,4 +68,4 @@ var NamespacedStorage = /** @class */ (function () {
|
|
|
65
68
|
};
|
|
66
69
|
return NamespacedStorage;
|
|
67
70
|
}());
|
|
68
|
-
|
|
71
|
+
exports.NamespacedStorage = NamespacedStorage;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@croct/sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.7.0",
|
|
4
4
|
"description": "Croct SDK for JavaScript.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": {
|
|
@@ -8,8 +8,11 @@
|
|
|
8
8
|
"email": "sdk-js+lib@croct.com",
|
|
9
9
|
"url": "https://croct.com"
|
|
10
10
|
},
|
|
11
|
-
"main": "index.js",
|
|
12
|
-
"types": "index.d.ts",
|
|
11
|
+
"main": "./index.js",
|
|
12
|
+
"types": "./index.d.ts",
|
|
13
|
+
"engines": {
|
|
14
|
+
"node": ">=10"
|
|
15
|
+
},
|
|
13
16
|
"repository": {
|
|
14
17
|
"type": "git",
|
|
15
18
|
"url": "git+https://github.com/croct-tech/sdk-js.git"
|
|
@@ -25,24 +28,24 @@
|
|
|
25
28
|
"build": "tsc"
|
|
26
29
|
},
|
|
27
30
|
"dependencies": {
|
|
28
|
-
"tslib": "^2.
|
|
31
|
+
"tslib": "^2.2.0"
|
|
29
32
|
},
|
|
30
33
|
"devDependencies": {
|
|
31
|
-
"@types/jest": "^
|
|
32
|
-
"@typescript-eslint/eslint-plugin": "^
|
|
33
|
-
"@typescript-eslint/parser": "^
|
|
34
|
-
"eslint": "^
|
|
35
|
-
"eslint-config-airbnb-base": "^14.
|
|
36
|
-
"eslint-plugin-import": "^2.
|
|
37
|
-
"eslint-plugin-jest": "^
|
|
38
|
-
"fetch-mock": "^9.
|
|
39
|
-
"jest": "^
|
|
40
|
-
"jest-websocket-mock": "^
|
|
41
|
-
"mock-socket": "^
|
|
42
|
-
"node-fetch": "^2.6.
|
|
34
|
+
"@types/jest": "^26.0.23",
|
|
35
|
+
"@typescript-eslint/eslint-plugin": "^4.24.0",
|
|
36
|
+
"@typescript-eslint/parser": "^4.24.0",
|
|
37
|
+
"eslint": "^7.27.0",
|
|
38
|
+
"eslint-config-airbnb-base": "^14.2.1",
|
|
39
|
+
"eslint-plugin-import": "^2.23.3",
|
|
40
|
+
"eslint-plugin-jest": "^24.3.6",
|
|
41
|
+
"fetch-mock": "^9.11.0",
|
|
42
|
+
"jest": "^26.6.3",
|
|
43
|
+
"jest-websocket-mock": "^2.2.0",
|
|
44
|
+
"mock-socket": "^9.0.3",
|
|
45
|
+
"node-fetch": "^2.6.1",
|
|
43
46
|
"temp-dir": "^2.0.0",
|
|
44
|
-
"ts-jest": "^
|
|
45
|
-
"typescript": "^
|
|
47
|
+
"ts-jest": "^26.5.6",
|
|
48
|
+
"typescript": "^4.2.4"
|
|
46
49
|
},
|
|
47
50
|
"files": [
|
|
48
51
|
"**/*.js",
|
package/patch.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Queue } from './
|
|
2
|
-
export
|
|
1
|
+
import { Queue } from './queue';
|
|
2
|
+
export declare class CapacityRestrictedQueue<T> implements Queue<T> {
|
|
3
3
|
private readonly queue;
|
|
4
4
|
private readonly capacity;
|
|
5
5
|
constructor(queue: Queue<T>, capacity: number);
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CapacityRestrictedQueue = void 0;
|
|
1
4
|
var CapacityRestrictedQueue = /** @class */ (function () {
|
|
2
5
|
function CapacityRestrictedQueue(queue, capacity) {
|
|
3
6
|
this.queue = queue;
|
|
@@ -29,4 +32,4 @@ var CapacityRestrictedQueue = /** @class */ (function () {
|
|
|
29
32
|
};
|
|
30
33
|
return CapacityRestrictedQueue;
|
|
31
34
|
}());
|
|
32
|
-
|
|
35
|
+
exports.CapacityRestrictedQueue = CapacityRestrictedQueue;
|
package/queue/inMemoryQueue.d.ts
CHANGED
package/queue/inMemoryQueue.js
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.InMemoryQueue = void 0;
|
|
4
|
+
var tslib_1 = require("tslib");
|
|
2
5
|
var InMemoryQueue = /** @class */ (function () {
|
|
3
6
|
function InMemoryQueue() {
|
|
4
7
|
var _a;
|
|
@@ -7,7 +10,7 @@ var InMemoryQueue = /** @class */ (function () {
|
|
|
7
10
|
values[_i] = arguments[_i];
|
|
8
11
|
}
|
|
9
12
|
this.queue = [];
|
|
10
|
-
(_a = this.queue).unshift.apply(_a,
|
|
13
|
+
(_a = this.queue).unshift.apply(_a, tslib_1.__spreadArray([], tslib_1.__read(values)));
|
|
11
14
|
}
|
|
12
15
|
InMemoryQueue.prototype.all = function () {
|
|
13
16
|
return this.queue.slice();
|
|
@@ -36,4 +39,4 @@ var InMemoryQueue = /** @class */ (function () {
|
|
|
36
39
|
};
|
|
37
40
|
return InMemoryQueue;
|
|
38
41
|
}());
|
|
39
|
-
|
|
42
|
+
exports.InMemoryQueue = InMemoryQueue;
|
package/queue/index.d.ts
CHANGED
|
@@ -1,9 +1,5 @@
|
|
|
1
|
-
export
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
peek(): T | null;
|
|
7
|
-
isEmpty(): boolean;
|
|
8
|
-
length(): number;
|
|
9
|
-
}
|
|
1
|
+
export * from './queue';
|
|
2
|
+
export { CapacityRestrictedQueue } from './capacityRestrictedQueue';
|
|
3
|
+
export { InMemoryQueue } from './inMemoryQueue';
|
|
4
|
+
export { MonitoredQueue } from './monitoredQueue';
|
|
5
|
+
export { PersistentQueue } from './persistentQueue';
|
package/queue/index.js
CHANGED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PersistentQueue = exports.MonitoredQueue = exports.InMemoryQueue = exports.CapacityRestrictedQueue = void 0;
|
|
4
|
+
var tslib_1 = require("tslib");
|
|
5
|
+
tslib_1.__exportStar(require("./queue"), exports);
|
|
6
|
+
var capacityRestrictedQueue_1 = require("./capacityRestrictedQueue");
|
|
7
|
+
Object.defineProperty(exports, "CapacityRestrictedQueue", { enumerable: true, get: function () { return capacityRestrictedQueue_1.CapacityRestrictedQueue; } });
|
|
8
|
+
var inMemoryQueue_1 = require("./inMemoryQueue");
|
|
9
|
+
Object.defineProperty(exports, "InMemoryQueue", { enumerable: true, get: function () { return inMemoryQueue_1.InMemoryQueue; } });
|
|
10
|
+
var monitoredQueue_1 = require("./monitoredQueue");
|
|
11
|
+
Object.defineProperty(exports, "MonitoredQueue", { enumerable: true, get: function () { return monitoredQueue_1.MonitoredQueue; } });
|
|
12
|
+
var persistentQueue_1 = require("./persistentQueue");
|
|
13
|
+
Object.defineProperty(exports, "PersistentQueue", { enumerable: true, get: function () { return persistentQueue_1.PersistentQueue; } });
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { Queue } from './
|
|
1
|
+
import { Queue } from './queue';
|
|
2
2
|
import { Logger } from '../logging';
|
|
3
|
-
export declare type
|
|
4
|
-
export declare type
|
|
3
|
+
export declare type QueueStatus = 'halfEmpty' | 'almostEmpty' | 'empty' | 'halfFull' | 'almostFull' | 'full';
|
|
4
|
+
export declare type QueueCallback<T> = {
|
|
5
5
|
(queue: Queue<T>): void;
|
|
6
6
|
};
|
|
7
|
-
export
|
|
7
|
+
export declare class MonitoredQueue<T> implements Queue<T> {
|
|
8
8
|
private readonly queue;
|
|
9
9
|
private readonly logger;
|
|
10
10
|
private readonly callbacks;
|
|
@@ -12,8 +12,8 @@ export default class MonitoredQueue<T> implements Queue<T> {
|
|
|
12
12
|
constructor(queue: Queue<T>, logger?: Logger);
|
|
13
13
|
all(): T[];
|
|
14
14
|
getCapacity(): number;
|
|
15
|
-
addCallback(status:
|
|
16
|
-
removeCallback(type:
|
|
15
|
+
addCallback(status: QueueStatus, callback: QueueCallback<T>): void;
|
|
16
|
+
removeCallback(type: QueueStatus, callback: QueueCallback<T>): void;
|
|
17
17
|
private setStatus;
|
|
18
18
|
private report;
|
|
19
19
|
isEmpty(): boolean;
|
package/queue/monitoredQueue.js
CHANGED
|
@@ -1,9 +1,12 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MonitoredQueue = void 0;
|
|
4
|
+
var logging_1 = require("../logging");
|
|
2
5
|
var MonitoredQueue = /** @class */ (function () {
|
|
3
6
|
function MonitoredQueue(queue, logger) {
|
|
4
7
|
this.callbacks = {};
|
|
5
8
|
this.queue = queue;
|
|
6
|
-
this.logger =
|
|
9
|
+
this.logger = logger !== null && logger !== void 0 ? logger : new logging_1.NullLogger();
|
|
7
10
|
this.updateStatus();
|
|
8
11
|
}
|
|
9
12
|
MonitoredQueue.prototype.all = function () {
|
|
@@ -118,4 +121,4 @@ var MonitoredQueue = /** @class */ (function () {
|
|
|
118
121
|
};
|
|
119
122
|
return MonitoredQueue;
|
|
120
123
|
}());
|
|
121
|
-
|
|
124
|
+
exports.MonitoredQueue = MonitoredQueue;
|
package/queue/persistentQueue.js
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PersistentQueue = void 0;
|
|
1
4
|
var PersistentQueue = /** @class */ (function () {
|
|
2
5
|
function PersistentQueue(storage, key) {
|
|
3
6
|
if (key === void 0) { key = 'queue'; }
|
|
@@ -42,7 +45,7 @@ var PersistentQueue = /** @class */ (function () {
|
|
|
42
45
|
}
|
|
43
46
|
return this.cache;
|
|
44
47
|
},
|
|
45
|
-
enumerable:
|
|
48
|
+
enumerable: false,
|
|
46
49
|
configurable: true
|
|
47
50
|
});
|
|
48
51
|
PersistentQueue.prototype.flush = function () {
|
|
@@ -62,4 +65,4 @@ var PersistentQueue = /** @class */ (function () {
|
|
|
62
65
|
};
|
|
63
66
|
return PersistentQueue;
|
|
64
67
|
}());
|
|
65
|
-
|
|
68
|
+
exports.PersistentQueue = PersistentQueue;
|
package/queue/queue.d.ts
ADDED
package/queue/queue.js
ADDED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { RetryPolicy } from './
|
|
2
|
-
export
|
|
1
|
+
import { RetryPolicy } from './policy';
|
|
2
|
+
export declare class ArbitraryPolicy<T> implements RetryPolicy<T> {
|
|
3
3
|
private readonly delays;
|
|
4
4
|
constructor(delays: number[]);
|
|
5
5
|
getDelay(attempt: number): number;
|
package/retry/arbitraryPolicy.js
CHANGED
|
@@ -1,10 +1,13 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ArbitraryPolicy = void 0;
|
|
4
|
+
var tslib_1 = require("tslib");
|
|
2
5
|
var ArbitraryPolicy = /** @class */ (function () {
|
|
3
6
|
function ArbitraryPolicy(delays) {
|
|
4
7
|
if (delays.length < 1) {
|
|
5
8
|
throw new Error('The list of delays cannot be empty.');
|
|
6
9
|
}
|
|
7
|
-
this.delays =
|
|
10
|
+
this.delays = tslib_1.__spreadArray([], tslib_1.__read(delays));
|
|
8
11
|
}
|
|
9
12
|
ArbitraryPolicy.prototype.getDelay = function (attempt) {
|
|
10
13
|
return this.delays[Math.min(attempt < 0 ? 0 : attempt, this.delays.length - 1)];
|
|
@@ -14,4 +17,4 @@ var ArbitraryPolicy = /** @class */ (function () {
|
|
|
14
17
|
};
|
|
15
18
|
return ArbitraryPolicy;
|
|
16
19
|
}());
|
|
17
|
-
|
|
20
|
+
exports.ArbitraryPolicy = ArbitraryPolicy;
|
package/retry/backoffPolicy.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { RetryPolicy } from './
|
|
1
|
+
import { RetryPolicy } from './policy';
|
|
2
2
|
declare type Options = {
|
|
3
3
|
minRetryDelay: number;
|
|
4
4
|
maxRetryDelay: number;
|
|
@@ -6,7 +6,7 @@ declare type Options = {
|
|
|
6
6
|
backoffJitter: number;
|
|
7
7
|
maxAttempts: number;
|
|
8
8
|
};
|
|
9
|
-
export
|
|
9
|
+
export declare class BackoffPolicy<T> implements RetryPolicy<T> {
|
|
10
10
|
private readonly minRetryDelay;
|
|
11
11
|
private readonly maxRetryDelay;
|
|
12
12
|
private readonly backoffFactor;
|
package/retry/backoffPolicy.js
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.BackoffPolicy = void 0;
|
|
1
4
|
var BackoffPolicy = /** @class */ (function () {
|
|
2
5
|
function BackoffPolicy(options) {
|
|
3
6
|
if (options === void 0) { options = {}; }
|
|
@@ -51,4 +54,4 @@ var BackoffPolicy = /** @class */ (function () {
|
|
|
51
54
|
};
|
|
52
55
|
return BackoffPolicy;
|
|
53
56
|
}());
|
|
54
|
-
|
|
57
|
+
exports.BackoffPolicy = BackoffPolicy;
|
package/retry/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
export
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
}
|
|
1
|
+
export * from './policy';
|
|
2
|
+
export { ArbitraryPolicy } from './arbitraryPolicy';
|
|
3
|
+
export { BackoffPolicy } from './backoffPolicy';
|
|
4
|
+
export { MaxAttemptsPolicy } from './maxAttemptsPolicy';
|
|
5
|
+
export { NeverPolicy } from './neverPolicy';
|
package/retry/index.js
CHANGED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.NeverPolicy = exports.MaxAttemptsPolicy = exports.BackoffPolicy = exports.ArbitraryPolicy = void 0;
|
|
4
|
+
var tslib_1 = require("tslib");
|
|
5
|
+
tslib_1.__exportStar(require("./policy"), exports);
|
|
6
|
+
var arbitraryPolicy_1 = require("./arbitraryPolicy");
|
|
7
|
+
Object.defineProperty(exports, "ArbitraryPolicy", { enumerable: true, get: function () { return arbitraryPolicy_1.ArbitraryPolicy; } });
|
|
8
|
+
var backoffPolicy_1 = require("./backoffPolicy");
|
|
9
|
+
Object.defineProperty(exports, "BackoffPolicy", { enumerable: true, get: function () { return backoffPolicy_1.BackoffPolicy; } });
|
|
10
|
+
var maxAttemptsPolicy_1 = require("./maxAttemptsPolicy");
|
|
11
|
+
Object.defineProperty(exports, "MaxAttemptsPolicy", { enumerable: true, get: function () { return maxAttemptsPolicy_1.MaxAttemptsPolicy; } });
|
|
12
|
+
var neverPolicy_1 = require("./neverPolicy");
|
|
13
|
+
Object.defineProperty(exports, "NeverPolicy", { enumerable: true, get: function () { return neverPolicy_1.NeverPolicy; } });
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { RetryPolicy } from './
|
|
2
|
-
export
|
|
1
|
+
import { RetryPolicy } from './policy';
|
|
2
|
+
export declare class MaxAttemptsPolicy<T> implements RetryPolicy<T> {
|
|
3
3
|
private readonly maxAttempts;
|
|
4
4
|
private readonly delay;
|
|
5
5
|
constructor(delay: number, maxAttempts: number);
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MaxAttemptsPolicy = void 0;
|
|
1
4
|
var MaxAttemptsPolicy = /** @class */ (function () {
|
|
2
5
|
function MaxAttemptsPolicy(delay, maxAttempts) {
|
|
3
6
|
if (delay < 0) {
|
|
@@ -17,4 +20,4 @@ var MaxAttemptsPolicy = /** @class */ (function () {
|
|
|
17
20
|
};
|
|
18
21
|
return MaxAttemptsPolicy;
|
|
19
22
|
}());
|
|
20
|
-
|
|
23
|
+
exports.MaxAttemptsPolicy = MaxAttemptsPolicy;
|
package/retry/neverPolicy.d.ts
CHANGED