@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/facade/sessionPatch.js
CHANGED
|
@@ -1,16 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.SessionPatch = void 0;
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
var _this = _super.call(this) || this;
|
|
10
|
-
_this.tracker = tracker;
|
|
11
|
-
return _this;
|
|
4
|
+
const activeRecord_1 = require("../activeRecord");
|
|
5
|
+
class SessionPatch extends activeRecord_1.ActiveRecord {
|
|
6
|
+
constructor(tracker) {
|
|
7
|
+
super();
|
|
8
|
+
this.tracker = tracker;
|
|
12
9
|
}
|
|
13
|
-
|
|
10
|
+
save() {
|
|
14
11
|
if (!this.isDirty()) {
|
|
15
12
|
// Empty patch
|
|
16
13
|
return Promise.resolve({
|
|
@@ -18,13 +15,13 @@ var SessionPatch = /** @class */ (function (_super) {
|
|
|
18
15
|
patch: { operations: [] },
|
|
19
16
|
});
|
|
20
17
|
}
|
|
21
|
-
|
|
18
|
+
const promise = this.tracker.track({
|
|
22
19
|
type: 'sessionAttributesChanged',
|
|
23
20
|
patch: this.buildPatch(),
|
|
24
21
|
});
|
|
25
22
|
this.reset();
|
|
26
23
|
return promise;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
}(activeRecord_1.ActiveRecord));
|
|
24
|
+
}
|
|
25
|
+
}
|
|
30
26
|
exports.SessionPatch = SessionPatch;
|
|
27
|
+
//# sourceMappingURL=sessionPatch.js.map
|
package/facade/trackerFacade.js
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.TrackerFacade = void 0;
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
var eventSchemas = {
|
|
4
|
+
const error_1 = require("../error");
|
|
5
|
+
const schema_1 = require("../schema");
|
|
6
|
+
const eventSchemas = {
|
|
8
7
|
cartViewed: schema_1.cartViewed,
|
|
9
8
|
cartModified: schema_1.cartModified,
|
|
10
9
|
checkoutStarted: schema_1.checkoutStarted,
|
|
@@ -17,6 +16,18 @@ var eventSchemas = {
|
|
|
17
16
|
goalCompleted: schema_1.goalCompleted,
|
|
18
17
|
linkOpened: schema_1.linkOpened,
|
|
19
18
|
};
|
|
19
|
+
function validateEvent(event) {
|
|
20
|
+
const { type, ...payload } = event;
|
|
21
|
+
if (!(type in eventSchemas)) {
|
|
22
|
+
throw new Error(`Unknown event type '${type}'.`);
|
|
23
|
+
}
|
|
24
|
+
try {
|
|
25
|
+
eventSchemas[type].validate(payload);
|
|
26
|
+
}
|
|
27
|
+
catch (violation) {
|
|
28
|
+
throw new Error(`Invalid event payload: ${(0, error_1.formatCause)(violation)}`);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
20
31
|
function createEvent(type, payload) {
|
|
21
32
|
if (typeof type !== 'string') {
|
|
22
33
|
throw new Error('The event type must of type string.');
|
|
@@ -24,48 +35,32 @@ function createEvent(type, payload) {
|
|
|
24
35
|
if (typeof payload !== 'object' || payload == null) {
|
|
25
36
|
throw new Error('The event payload must of type object.');
|
|
26
37
|
}
|
|
27
|
-
|
|
38
|
+
const event = { type: type, ...payload };
|
|
28
39
|
validateEvent(event);
|
|
29
40
|
return event;
|
|
30
41
|
}
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
if (!(type in eventSchemas)) {
|
|
34
|
-
throw new Error("Unknown event type '".concat(type, "'."));
|
|
35
|
-
}
|
|
36
|
-
try {
|
|
37
|
-
eventSchemas[type].validate(payload);
|
|
38
|
-
}
|
|
39
|
-
catch (violation) {
|
|
40
|
-
throw new Error("Invalid event payload: ".concat((0, error_1.formatCause)(violation)));
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
var TrackerFacade = /** @class */ (function () {
|
|
44
|
-
function TrackerFacade(tracker) {
|
|
42
|
+
class TrackerFacade {
|
|
43
|
+
constructor(tracker) {
|
|
45
44
|
this.tracker = tracker;
|
|
46
45
|
}
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
enumerable: false,
|
|
52
|
-
configurable: true
|
|
53
|
-
});
|
|
54
|
-
TrackerFacade.prototype.enable = function () {
|
|
46
|
+
get flushed() {
|
|
47
|
+
return this.tracker.flushed;
|
|
48
|
+
}
|
|
49
|
+
enable() {
|
|
55
50
|
this.tracker.enable();
|
|
56
|
-
}
|
|
57
|
-
|
|
51
|
+
}
|
|
52
|
+
disable() {
|
|
58
53
|
this.tracker.disable();
|
|
59
|
-
}
|
|
60
|
-
|
|
54
|
+
}
|
|
55
|
+
addListener(listener) {
|
|
61
56
|
this.tracker.addListener(listener);
|
|
62
|
-
}
|
|
63
|
-
|
|
57
|
+
}
|
|
58
|
+
removeListener(listener) {
|
|
64
59
|
this.tracker.removeListener(listener);
|
|
65
|
-
}
|
|
66
|
-
|
|
60
|
+
}
|
|
61
|
+
track(type, payload) {
|
|
67
62
|
return this.tracker.track(createEvent(type, payload));
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
}());
|
|
63
|
+
}
|
|
64
|
+
}
|
|
71
65
|
exports.TrackerFacade = TrackerFacade;
|
|
66
|
+
//# sourceMappingURL=trackerFacade.js.map
|
package/facade/userFacade.js
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.UserFacade = void 0;
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
const userPatch_1 = require("./userPatch");
|
|
5
|
+
class UserFacade {
|
|
6
|
+
constructor(context, tracker) {
|
|
7
7
|
this.context = context;
|
|
8
8
|
this.tracker = tracker;
|
|
9
9
|
}
|
|
10
|
-
|
|
10
|
+
isIdentified() {
|
|
11
11
|
return !this.isAnonymous();
|
|
12
|
-
}
|
|
13
|
-
|
|
12
|
+
}
|
|
13
|
+
isAnonymous() {
|
|
14
14
|
return this.context.isAnonymous();
|
|
15
|
-
}
|
|
16
|
-
|
|
15
|
+
}
|
|
16
|
+
edit() {
|
|
17
17
|
return new userPatch_1.UserPatch(this.tracker);
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
}());
|
|
18
|
+
}
|
|
19
|
+
}
|
|
21
20
|
exports.UserFacade = UserFacade;
|
|
21
|
+
//# sourceMappingURL=userFacade.js.map
|
package/facade/userPatch.js
CHANGED
|
@@ -1,16 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.UserPatch = void 0;
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
var _this = _super.call(this) || this;
|
|
10
|
-
_this.tracker = tracker;
|
|
11
|
-
return _this;
|
|
4
|
+
const activeRecord_1 = require("../activeRecord");
|
|
5
|
+
class UserPatch extends activeRecord_1.ActiveRecord {
|
|
6
|
+
constructor(tracker) {
|
|
7
|
+
super();
|
|
8
|
+
this.tracker = tracker;
|
|
12
9
|
}
|
|
13
|
-
|
|
10
|
+
save() {
|
|
14
11
|
if (!this.isDirty()) {
|
|
15
12
|
// Empty patch
|
|
16
13
|
return Promise.resolve({
|
|
@@ -18,13 +15,13 @@ var UserPatch = /** @class */ (function (_super) {
|
|
|
18
15
|
patch: { operations: [] },
|
|
19
16
|
});
|
|
20
17
|
}
|
|
21
|
-
|
|
18
|
+
const promise = this.tracker.track({
|
|
22
19
|
type: 'userProfileChanged',
|
|
23
20
|
patch: this.buildPatch(),
|
|
24
21
|
});
|
|
25
22
|
this.reset();
|
|
26
23
|
return promise;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
}(activeRecord_1.ActiveRecord));
|
|
24
|
+
}
|
|
25
|
+
}
|
|
30
26
|
exports.UserPatch = UserPatch;
|
|
27
|
+
//# sourceMappingURL=userPatch.js.map
|
package/index.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.VERSION = exports.Sdk = void 0;
|
|
4
|
-
|
|
4
|
+
const constants_1 = require("./constants");
|
|
5
5
|
Object.defineProperty(exports, "VERSION", { enumerable: true, get: function () { return constants_1.VERSION; } });
|
|
6
|
-
|
|
6
|
+
const sdk_1 = require("./sdk");
|
|
7
7
|
Object.defineProperty(exports, "Sdk", { enumerable: true, get: function () { return sdk_1.Sdk; } });
|
|
8
|
+
//# sourceMappingURL=index.js.map
|
package/logging/consoleLogger.js
CHANGED
|
@@ -1,44 +1,28 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.ConsoleLogger = void 0;
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
class ConsoleLogger {
|
|
5
|
+
constructor(namespace) {
|
|
6
6
|
this.namespace = namespace;
|
|
7
7
|
}
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
});
|
|
22
|
-
Object.defineProperty(ConsoleLogger.prototype, "warn", {
|
|
23
|
-
get: function () {
|
|
24
|
-
return this.bind(window.console.warn);
|
|
25
|
-
},
|
|
26
|
-
enumerable: false,
|
|
27
|
-
configurable: true
|
|
28
|
-
});
|
|
29
|
-
Object.defineProperty(ConsoleLogger.prototype, "error", {
|
|
30
|
-
get: function () {
|
|
31
|
-
return this.bind(window.console.error);
|
|
32
|
-
},
|
|
33
|
-
enumerable: false,
|
|
34
|
-
configurable: true
|
|
35
|
-
});
|
|
36
|
-
ConsoleLogger.prototype.bind = function (method) {
|
|
8
|
+
get debug() {
|
|
9
|
+
return this.bind(window.console.debug);
|
|
10
|
+
}
|
|
11
|
+
get info() {
|
|
12
|
+
return this.bind(window.console.info);
|
|
13
|
+
}
|
|
14
|
+
get warn() {
|
|
15
|
+
return this.bind(window.console.warn);
|
|
16
|
+
}
|
|
17
|
+
get error() {
|
|
18
|
+
return this.bind(window.console.error);
|
|
19
|
+
}
|
|
20
|
+
bind(method) {
|
|
37
21
|
if (this.namespace !== undefined) {
|
|
38
|
-
return method.bind(window.console,
|
|
22
|
+
return method.bind(window.console, `[${this.namespace}]`);
|
|
39
23
|
}
|
|
40
24
|
return method.bind(window.console);
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
}());
|
|
25
|
+
}
|
|
26
|
+
}
|
|
44
27
|
exports.ConsoleLogger = ConsoleLogger;
|
|
28
|
+
//# sourceMappingURL=consoleLogger.js.map
|
package/logging/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.NullLogger = exports.NamespacedLogger = exports.ConsoleLogger = void 0;
|
|
4
|
-
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
5
|
tslib_1.__exportStar(require("./logger"), exports);
|
|
6
6
|
var consoleLogger_1 = require("./consoleLogger");
|
|
7
7
|
Object.defineProperty(exports, "ConsoleLogger", { enumerable: true, get: function () { return consoleLogger_1.ConsoleLogger; } });
|
|
@@ -9,3 +9,4 @@ var namespacedLogger_1 = require("./namespacedLogger");
|
|
|
9
9
|
Object.defineProperty(exports, "NamespacedLogger", { enumerable: true, get: function () { return namespacedLogger_1.NamespacedLogger; } });
|
|
10
10
|
var nullLogger_1 = require("./nullLogger");
|
|
11
11
|
Object.defineProperty(exports, "NullLogger", { enumerable: true, get: function () { return nullLogger_1.NullLogger; } });
|
|
12
|
+
//# sourceMappingURL=index.js.map
|
package/logging/logger.js
CHANGED
|
@@ -1,26 +1,26 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.NamespacedLogger = void 0;
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
class NamespacedLogger {
|
|
5
|
+
constructor(logger, namespace) {
|
|
6
6
|
this.logger = logger;
|
|
7
7
|
this.namespace = namespace;
|
|
8
8
|
}
|
|
9
|
-
|
|
9
|
+
debug(message) {
|
|
10
10
|
this.logger.debug(this.format(message));
|
|
11
|
-
}
|
|
12
|
-
|
|
11
|
+
}
|
|
12
|
+
info(message) {
|
|
13
13
|
this.logger.info(this.format(message));
|
|
14
|
-
}
|
|
15
|
-
|
|
14
|
+
}
|
|
15
|
+
warn(message) {
|
|
16
16
|
this.logger.warn(this.format(message));
|
|
17
|
-
}
|
|
18
|
-
|
|
17
|
+
}
|
|
18
|
+
error(message) {
|
|
19
19
|
this.logger.error(this.format(message));
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
return
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
}());
|
|
20
|
+
}
|
|
21
|
+
format(message) {
|
|
22
|
+
return `[${this.namespace}] ${message}`;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
26
25
|
exports.NamespacedLogger = NamespacedLogger;
|
|
26
|
+
//# sourceMappingURL=namespacedLogger.js.map
|
package/logging/nullLogger.js
CHANGED
|
@@ -1,21 +1,19 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.NullLogger = void 0;
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
}
|
|
7
|
-
NullLogger.prototype.debug = function () {
|
|
4
|
+
class NullLogger {
|
|
5
|
+
debug() {
|
|
8
6
|
// suppress debug logs
|
|
9
|
-
}
|
|
10
|
-
|
|
7
|
+
}
|
|
8
|
+
info() {
|
|
11
9
|
// suppress info logs
|
|
12
|
-
}
|
|
13
|
-
|
|
10
|
+
}
|
|
11
|
+
warn() {
|
|
14
12
|
// suppress warning logs
|
|
15
|
-
}
|
|
16
|
-
|
|
13
|
+
}
|
|
14
|
+
error() {
|
|
17
15
|
// suppress error logs
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
}());
|
|
16
|
+
}
|
|
17
|
+
}
|
|
21
18
|
exports.NullLogger = NullLogger;
|
|
19
|
+
//# sourceMappingURL=nullLogger.js.map
|
package/namespacedStorage.js
CHANGED
|
@@ -1,71 +1,55 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.NamespacedStorage = void 0;
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
function NamespacedStorage(storage, namespace) {
|
|
4
|
+
class NamespacedStorage {
|
|
5
|
+
constructor(storage, namespace) {
|
|
7
6
|
if (namespace === '') {
|
|
8
7
|
throw new Error('The namespace cannot be empty.');
|
|
9
8
|
}
|
|
10
9
|
this.storage = storage;
|
|
11
10
|
this.namespace = namespace;
|
|
12
11
|
}
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
});
|
|
20
|
-
NamespacedStorage.prototype.clear = function () {
|
|
21
|
-
var e_1, _a;
|
|
22
|
-
try {
|
|
23
|
-
for (var _b = tslib_1.__values(this.getKeys()), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
24
|
-
var key = _c.value;
|
|
25
|
-
this.storage.removeItem(key);
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
29
|
-
finally {
|
|
30
|
-
try {
|
|
31
|
-
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
32
|
-
}
|
|
33
|
-
finally { if (e_1) throw e_1.error; }
|
|
12
|
+
get length() {
|
|
13
|
+
return this.getKeys().length;
|
|
14
|
+
}
|
|
15
|
+
clear() {
|
|
16
|
+
for (const key of this.getKeys()) {
|
|
17
|
+
this.storage.removeItem(key);
|
|
34
18
|
}
|
|
35
|
-
}
|
|
36
|
-
|
|
19
|
+
}
|
|
20
|
+
getItem(key) {
|
|
37
21
|
return this.storage.getItem(this.getPrefixedKey(key));
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
|
|
22
|
+
}
|
|
23
|
+
key(index) {
|
|
24
|
+
const keys = this.getKeys();
|
|
41
25
|
if (index >= keys.length) {
|
|
42
26
|
return null;
|
|
43
27
|
}
|
|
44
28
|
return keys[index].substring(this.namespace.length + 1);
|
|
45
|
-
}
|
|
46
|
-
|
|
29
|
+
}
|
|
30
|
+
removeItem(key) {
|
|
47
31
|
this.storage.removeItem(this.getPrefixedKey(key));
|
|
48
|
-
}
|
|
49
|
-
|
|
32
|
+
}
|
|
33
|
+
setItem(key, value) {
|
|
50
34
|
this.storage.setItem(this.getPrefixedKey(key), value);
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
for (
|
|
56
|
-
|
|
35
|
+
}
|
|
36
|
+
getKeys() {
|
|
37
|
+
const keys = [];
|
|
38
|
+
const prefix = this.getPrefix();
|
|
39
|
+
for (let index = 0; index < this.storage.length; index++) {
|
|
40
|
+
const key = this.storage.key(index);
|
|
57
41
|
if (key !== null && key.indexOf(prefix) === 0) {
|
|
58
42
|
keys.push(key);
|
|
59
43
|
}
|
|
60
44
|
}
|
|
61
45
|
return keys;
|
|
62
|
-
}
|
|
63
|
-
|
|
46
|
+
}
|
|
47
|
+
getPrefixedKey(key) {
|
|
64
48
|
return this.getPrefix() + key;
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
return
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
}());
|
|
49
|
+
}
|
|
50
|
+
getPrefix() {
|
|
51
|
+
return `${this.namespace}.`;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
71
54
|
exports.NamespacedStorage = NamespacedStorage;
|
|
55
|
+
//# sourceMappingURL=namespacedStorage.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@croct/sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.11.0-alpha.1",
|
|
4
4
|
"description": "Croct SDK for JavaScript.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": {
|
|
@@ -25,28 +25,25 @@
|
|
|
25
25
|
"lint": "eslint 'src/**/*.ts' 'test/**/*.ts'",
|
|
26
26
|
"test": "jest -c jest.config.js --coverage",
|
|
27
27
|
"validate": "tsc --noEmit",
|
|
28
|
-
"build": "tsc"
|
|
28
|
+
"build": "tsc -p tsconfig.build.json"
|
|
29
29
|
},
|
|
30
30
|
"dependencies": {
|
|
31
31
|
"@croct/json": "^1.0",
|
|
32
|
-
"tslib": "^2.
|
|
32
|
+
"tslib": "^2.4.1"
|
|
33
33
|
},
|
|
34
34
|
"devDependencies": {
|
|
35
|
-
"@
|
|
36
|
-
"@
|
|
37
|
-
"
|
|
38
|
-
"eslint": "^8.0.0",
|
|
39
|
-
"eslint-config-airbnb-base": "^15.0.0",
|
|
40
|
-
"eslint-plugin-import": "^2.25.4",
|
|
41
|
-
"eslint-plugin-jest": "^27.0.0",
|
|
35
|
+
"@croct/eslint-plugin": "^0.6.3",
|
|
36
|
+
"@types/jest": "^29.2.3",
|
|
37
|
+
"eslint": "^8.27.0",
|
|
42
38
|
"fetch-mock": "^9.11.0",
|
|
43
|
-
"jest": "^
|
|
44
|
-
"jest-
|
|
45
|
-
"
|
|
39
|
+
"jest": "^29.3.1",
|
|
40
|
+
"jest-environment-jsdom": "^29.3.1",
|
|
41
|
+
"jest-extended": "^3.1.0",
|
|
42
|
+
"jest-websocket-mock": "^2.4.0",
|
|
43
|
+
"mock-socket": "^9.1.5",
|
|
46
44
|
"node-fetch": "^2.6.7",
|
|
47
|
-
"
|
|
48
|
-
"
|
|
49
|
-
"typescript": "^4.5.4"
|
|
45
|
+
"ts-jest": "^29.0.3",
|
|
46
|
+
"typescript": "^4.8.0"
|
|
50
47
|
},
|
|
51
48
|
"files": [
|
|
52
49
|
"**/*.js",
|
package/patch.d.ts
CHANGED
|
@@ -37,7 +37,7 @@ interface removeOperation extends AbstractOperation {
|
|
|
37
37
|
type: 'remove';
|
|
38
38
|
value: JsonValue;
|
|
39
39
|
}
|
|
40
|
-
export
|
|
40
|
+
export type Operation = UnsetOperation | ClearOperation | AddOperation | SetOperation | CombineOperation | MergeOperation | IncrementOperation | DecrementOperation | removeOperation;
|
|
41
41
|
export interface Patch {
|
|
42
42
|
operations: Operation[];
|
|
43
43
|
}
|
package/patch.js
CHANGED
|
@@ -1,35 +1,35 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.CapacityRestrictedQueue = void 0;
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
class CapacityRestrictedQueue {
|
|
5
|
+
constructor(queue, capacity) {
|
|
6
6
|
this.queue = queue;
|
|
7
7
|
this.capacity = capacity;
|
|
8
8
|
}
|
|
9
|
-
|
|
9
|
+
all() {
|
|
10
10
|
return this.queue.all();
|
|
11
|
-
}
|
|
12
|
-
|
|
11
|
+
}
|
|
12
|
+
getCapacity() {
|
|
13
13
|
return this.capacity;
|
|
14
|
-
}
|
|
15
|
-
|
|
14
|
+
}
|
|
15
|
+
isEmpty() {
|
|
16
16
|
return this.queue.isEmpty();
|
|
17
|
-
}
|
|
18
|
-
|
|
17
|
+
}
|
|
18
|
+
length() {
|
|
19
19
|
return Math.min(this.capacity, this.queue.length());
|
|
20
|
-
}
|
|
21
|
-
|
|
20
|
+
}
|
|
21
|
+
peek() {
|
|
22
22
|
return this.queue.peek();
|
|
23
|
-
}
|
|
24
|
-
|
|
23
|
+
}
|
|
24
|
+
push(value) {
|
|
25
25
|
if (this.queue.length() >= this.capacity) {
|
|
26
26
|
throw new Error('Maximum queue capacity reached.');
|
|
27
27
|
}
|
|
28
28
|
this.queue.push(value);
|
|
29
|
-
}
|
|
30
|
-
|
|
29
|
+
}
|
|
30
|
+
shift() {
|
|
31
31
|
return this.queue.shift();
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
}());
|
|
32
|
+
}
|
|
33
|
+
}
|
|
35
34
|
exports.CapacityRestrictedQueue = CapacityRestrictedQueue;
|
|
35
|
+
//# sourceMappingURL=capacityRestrictedQueue.js.map
|