@croct/sdk 0.6.0 → 0.8.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 -0
- package/activeRecord.js +9 -1
- package/cache/fallbackCache.js +1 -1
- package/cache/index.js +1 -1
- package/channel/beaconSocketChannel.js +5 -5
- package/channel/guaranteedChannel.js +6 -6
- package/channel/index.js +1 -1
- package/channel/queuedChannel.js +6 -6
- package/channel/retryChannel.js +5 -5
- package/channel/socketChannel.js +4 -4
- package/cid/cachedAssigner.js +2 -2
- package/cid/index.js +1 -1
- package/cid/remoteAssigner.js +3 -3
- package/constants.js +1 -1
- package/container.d.ts +1 -0
- package/container.js +20 -12
- package/context.js +1 -1
- package/evaluator.js +14 -14
- package/facade/evaluatorFacade.js +3 -3
- package/facade/sdkFacade.d.ts +1 -0
- package/facade/sdkFacade.js +8 -8
- package/facade/sessionPatch.js +1 -1
- package/facade/trackerFacade.js +7 -5
- package/facade/userPatch.js +1 -1
- package/logging/consoleLogger.js +1 -1
- package/logging/index.js +1 -1
- package/logging/namespacedLogger.js +1 -1
- package/namespacedStorage.js +2 -2
- package/package.json +12 -12
- package/patch.d.ts +5 -1
- package/queue/inMemoryQueue.js +1 -1
- package/queue/index.js +1 -1
- package/queue/monitoredQueue.js +1 -1
- package/retry/arbitraryPolicy.js +1 -1
- package/retry/index.js +1 -1
- 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/eventSchemas.d.ts +3 -1
- package/schema/eventSchemas.js +29 -14
- package/schema/index.js +10 -10
- package/schema/operationSchemas.d.ts +1 -0
- package/schema/operationSchemas.js +11 -1
- package/schema/sdkFacadeSchemas.js +1 -0
- package/schema/sdkSchemas.js +1 -0
- package/schema/userSchema.js +5 -16
- package/sdk.d.ts +1 -0
- package/sdk.js +16 -15
- package/sourceLocation.js +2 -2
- package/token/index.js +1 -1
- package/token/token.js +11 -11
- package/tracker.d.ts +1 -0
- package/tracker.js +30 -22
- package/trackingEvents.d.ts +31 -10
- package/trackingEvents.js +8 -6
- package/uuid.js +1 -1
- package/validation/arrayType.js +8 -8
- package/validation/booleanType.js +1 -1
- package/validation/functionType.js +1 -1
- package/validation/index.js +2 -2
- package/validation/jsonType.d.ts +1 -0
- package/validation/jsonType.js +14 -8
- package/validation/nullType.js +1 -1
- package/validation/numberType.js +6 -6
- package/validation/objectType.js +16 -16
- package/validation/schema.js +1 -1
- package/validation/stringType.js +28 -16
- package/validation/unionType.js +7 -7
- package/validation/violation.js +1 -1
package/facade/trackerFacade.js
CHANGED
|
@@ -11,9 +11,11 @@ var eventSchemas = {
|
|
|
11
11
|
orderPlaced: schema_1.orderPlaced,
|
|
12
12
|
productViewed: schema_1.productViewed,
|
|
13
13
|
userSignedUp: schema_1.userSignedUp,
|
|
14
|
-
testGroupAssigned: schema_1.testGroupAssigned,
|
|
15
14
|
eventOccurred: schema_1.eventOccurred,
|
|
15
|
+
interestShown: schema_1.interestShown,
|
|
16
|
+
postViewed: schema_1.postViewed,
|
|
16
17
|
goalCompleted: schema_1.goalCompleted,
|
|
18
|
+
linkOpened: schema_1.linkOpened,
|
|
17
19
|
};
|
|
18
20
|
function createEvent(type, payload) {
|
|
19
21
|
if (typeof type !== 'string') {
|
|
@@ -22,20 +24,20 @@ function createEvent(type, payload) {
|
|
|
22
24
|
if (typeof payload !== 'object' || payload == null) {
|
|
23
25
|
throw new Error('The event payload must of type object.');
|
|
24
26
|
}
|
|
25
|
-
var event = tslib_1.__assign({ type: type }, payload);
|
|
27
|
+
var event = (0, tslib_1.__assign)({ type: type }, payload);
|
|
26
28
|
validateEvent(event);
|
|
27
29
|
return event;
|
|
28
30
|
}
|
|
29
31
|
function validateEvent(event) {
|
|
30
|
-
var type = event.type, payload = tslib_1.__rest(event, ["type"]);
|
|
32
|
+
var type = event.type, payload = (0, tslib_1.__rest)(event, ["type"]);
|
|
31
33
|
if (!(type in eventSchemas)) {
|
|
32
|
-
throw new Error("Unknown event type '"
|
|
34
|
+
throw new Error("Unknown event type '".concat(type, "'."));
|
|
33
35
|
}
|
|
34
36
|
try {
|
|
35
37
|
eventSchemas[type].validate(payload);
|
|
36
38
|
}
|
|
37
39
|
catch (violation) {
|
|
38
|
-
throw new Error("Invalid event payload: "
|
|
40
|
+
throw new Error("Invalid event payload: ".concat((0, error_1.formatCause)(violation)));
|
|
39
41
|
}
|
|
40
42
|
}
|
|
41
43
|
var TrackerFacade = /** @class */ (function () {
|
package/facade/userPatch.js
CHANGED
|
@@ -4,7 +4,7 @@ exports.UserPatch = void 0;
|
|
|
4
4
|
var tslib_1 = require("tslib");
|
|
5
5
|
var activeRecord_1 = require("../activeRecord");
|
|
6
6
|
var UserPatch = /** @class */ (function (_super) {
|
|
7
|
-
tslib_1.__extends(UserPatch, _super);
|
|
7
|
+
(0, tslib_1.__extends)(UserPatch, _super);
|
|
8
8
|
function UserPatch(tracker) {
|
|
9
9
|
var _this = _super.call(this) || this;
|
|
10
10
|
_this.tracker = tracker;
|
package/logging/consoleLogger.js
CHANGED
|
@@ -35,7 +35,7 @@ var ConsoleLogger = /** @class */ (function () {
|
|
|
35
35
|
});
|
|
36
36
|
ConsoleLogger.prototype.bind = function (method) {
|
|
37
37
|
if (this.namespace !== undefined) {
|
|
38
|
-
return method.bind(window.console, "["
|
|
38
|
+
return method.bind(window.console, "[".concat(this.namespace, "]"));
|
|
39
39
|
}
|
|
40
40
|
return method.bind(window.console);
|
|
41
41
|
};
|
package/logging/index.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.NullLogger = exports.NamespacedLogger = exports.ConsoleLogger = void 0;
|
|
4
4
|
var tslib_1 = require("tslib");
|
|
5
|
-
tslib_1.__exportStar(require("./logger"), exports);
|
|
5
|
+
(0, 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; } });
|
|
8
8
|
var namespacedLogger_1 = require("./namespacedLogger");
|
|
@@ -19,7 +19,7 @@ var NamespacedLogger = /** @class */ (function () {
|
|
|
19
19
|
this.logger.error(this.format(message));
|
|
20
20
|
};
|
|
21
21
|
NamespacedLogger.prototype.format = function (message) {
|
|
22
|
-
return "["
|
|
22
|
+
return "[".concat(this.namespace, "] ").concat(message);
|
|
23
23
|
};
|
|
24
24
|
return NamespacedLogger;
|
|
25
25
|
}());
|
package/namespacedStorage.js
CHANGED
|
@@ -20,7 +20,7 @@ var NamespacedStorage = /** @class */ (function () {
|
|
|
20
20
|
NamespacedStorage.prototype.clear = function () {
|
|
21
21
|
var e_1, _a;
|
|
22
22
|
try {
|
|
23
|
-
for (var _b = tslib_1.__values(this.getKeys()), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
23
|
+
for (var _b = (0, tslib_1.__values)(this.getKeys()), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
24
24
|
var key = _c.value;
|
|
25
25
|
this.storage.removeItem(key);
|
|
26
26
|
}
|
|
@@ -64,7 +64,7 @@ var NamespacedStorage = /** @class */ (function () {
|
|
|
64
64
|
return this.getPrefix() + key;
|
|
65
65
|
};
|
|
66
66
|
NamespacedStorage.prototype.getPrefix = function () {
|
|
67
|
-
return this.namespace
|
|
67
|
+
return "".concat(this.namespace, ".");
|
|
68
68
|
};
|
|
69
69
|
return NamespacedStorage;
|
|
70
70
|
}());
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@croct/sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.8.0",
|
|
4
4
|
"description": "Croct SDK for JavaScript.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": {
|
|
@@ -28,24 +28,24 @@
|
|
|
28
28
|
"build": "tsc"
|
|
29
29
|
},
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"tslib": "^2.
|
|
31
|
+
"tslib": "^2.3.1"
|
|
32
32
|
},
|
|
33
33
|
"devDependencies": {
|
|
34
|
-
"@types/jest": "^26.0.
|
|
35
|
-
"@typescript-eslint/eslint-plugin": "^4.
|
|
36
|
-
"@typescript-eslint/parser": "^4.
|
|
37
|
-
"eslint": "^7.
|
|
34
|
+
"@types/jest": "^26.0.24",
|
|
35
|
+
"@typescript-eslint/eslint-plugin": "^4.33.0",
|
|
36
|
+
"@typescript-eslint/parser": "^4.33.0",
|
|
37
|
+
"eslint": "^7.32.0",
|
|
38
38
|
"eslint-config-airbnb-base": "^14.2.1",
|
|
39
|
-
"eslint-plugin-import": "^2.
|
|
40
|
-
"eslint-plugin-jest": "^24.
|
|
39
|
+
"eslint-plugin-import": "^2.25.4",
|
|
40
|
+
"eslint-plugin-jest": "^24.7.0",
|
|
41
41
|
"fetch-mock": "^9.11.0",
|
|
42
42
|
"jest": "^26.6.3",
|
|
43
|
-
"jest-websocket-mock": "^2.
|
|
44
|
-
"mock-socket": "^9.0
|
|
45
|
-
"node-fetch": "^2.6.
|
|
43
|
+
"jest-websocket-mock": "^2.3.0",
|
|
44
|
+
"mock-socket": "^9.1.0",
|
|
45
|
+
"node-fetch": "^2.6.7",
|
|
46
46
|
"temp-dir": "^2.0.0",
|
|
47
47
|
"ts-jest": "^26.5.6",
|
|
48
|
-
"typescript": "^4.
|
|
48
|
+
"typescript": "^4.5.4"
|
|
49
49
|
},
|
|
50
50
|
"files": [
|
|
51
51
|
"**/*.js",
|
package/patch.d.ts
CHANGED
|
@@ -33,7 +33,11 @@ interface DecrementOperation extends AbstractOperation {
|
|
|
33
33
|
type: 'decrement';
|
|
34
34
|
value: LenientJsonValue;
|
|
35
35
|
}
|
|
36
|
-
|
|
36
|
+
interface removeOperation extends AbstractOperation {
|
|
37
|
+
type: 'remove';
|
|
38
|
+
value: LenientJsonValue;
|
|
39
|
+
}
|
|
40
|
+
export declare type Operation = UnsetOperation | ClearOperation | AddOperation | SetOperation | CombineOperation | MergeOperation | IncrementOperation | DecrementOperation | removeOperation;
|
|
37
41
|
export interface Patch {
|
|
38
42
|
operations: Operation[];
|
|
39
43
|
}
|
package/queue/inMemoryQueue.js
CHANGED
|
@@ -10,7 +10,7 @@ var InMemoryQueue = /** @class */ (function () {
|
|
|
10
10
|
values[_i] = arguments[_i];
|
|
11
11
|
}
|
|
12
12
|
this.queue = [];
|
|
13
|
-
(_a = this.queue).unshift.apply(_a, tslib_1.__spreadArray([], tslib_1.__read(values)));
|
|
13
|
+
(_a = this.queue).unshift.apply(_a, (0, tslib_1.__spreadArray)([], (0, tslib_1.__read)(values), false));
|
|
14
14
|
}
|
|
15
15
|
InMemoryQueue.prototype.all = function () {
|
|
16
16
|
return this.queue.slice();
|
package/queue/index.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.PersistentQueue = exports.MonitoredQueue = exports.InMemoryQueue = exports.CapacityRestrictedQueue = void 0;
|
|
4
4
|
var tslib_1 = require("tslib");
|
|
5
|
-
tslib_1.__exportStar(require("./queue"), exports);
|
|
5
|
+
(0, 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; } });
|
|
8
8
|
var inMemoryQueue_1 = require("./inMemoryQueue");
|
package/queue/monitoredQueue.js
CHANGED
|
@@ -53,7 +53,7 @@ var MonitoredQueue = /** @class */ (function () {
|
|
|
53
53
|
if (this.status === status) {
|
|
54
54
|
return;
|
|
55
55
|
}
|
|
56
|
-
this.logger.debug("Queue status changed to \""
|
|
56
|
+
this.logger.debug("Queue status changed to \"".concat(status, "\""));
|
|
57
57
|
this.report(status);
|
|
58
58
|
this.status = status;
|
|
59
59
|
};
|
package/retry/arbitraryPolicy.js
CHANGED
|
@@ -7,7 +7,7 @@ var ArbitraryPolicy = /** @class */ (function () {
|
|
|
7
7
|
if (delays.length < 1) {
|
|
8
8
|
throw new Error('The list of delays cannot be empty.');
|
|
9
9
|
}
|
|
10
|
-
this.delays = tslib_1.__spreadArray([], tslib_1.__read(delays));
|
|
10
|
+
this.delays = (0, tslib_1.__spreadArray)([], (0, tslib_1.__read)(delays), false);
|
|
11
11
|
}
|
|
12
12
|
ArbitraryPolicy.prototype.getDelay = function (attempt) {
|
|
13
13
|
return this.delays[Math.min(attempt < 0 ? 0 : attempt, this.delays.length - 1)];
|
package/retry/index.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.NeverPolicy = exports.MaxAttemptsPolicy = exports.BackoffPolicy = exports.ArbitraryPolicy = void 0;
|
|
4
4
|
var tslib_1 = require("tslib");
|
|
5
|
-
tslib_1.__exportStar(require("./policy"), exports);
|
|
5
|
+
(0, 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; } });
|
|
8
8
|
var backoffPolicy_1 = require("./backoffPolicy");
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.attributeNameSchema = void 0;
|
|
4
|
+
var validation_1 = require("../validation");
|
|
5
|
+
exports.attributeNameSchema = new validation_1.StringType({
|
|
6
|
+
maxLength: 50,
|
|
7
|
+
format: 'identifier',
|
|
8
|
+
});
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.postDetails = void 0;
|
|
4
|
+
var validation_1 = require("../validation");
|
|
5
|
+
exports.postDetails = new validation_1.ObjectType({
|
|
6
|
+
required: ['postId', 'title', 'publishTime'],
|
|
7
|
+
properties: {
|
|
8
|
+
postId: new validation_1.StringType({
|
|
9
|
+
minLength: 1,
|
|
10
|
+
maxLength: 100,
|
|
11
|
+
}),
|
|
12
|
+
url: new validation_1.StringType({
|
|
13
|
+
format: 'url',
|
|
14
|
+
}),
|
|
15
|
+
title: new validation_1.StringType({
|
|
16
|
+
minLength: 1,
|
|
17
|
+
maxLength: 100,
|
|
18
|
+
}),
|
|
19
|
+
tags: new validation_1.ArrayType({
|
|
20
|
+
items: new validation_1.StringType({
|
|
21
|
+
minLength: 1,
|
|
22
|
+
maxLength: 50,
|
|
23
|
+
}),
|
|
24
|
+
minItems: 1,
|
|
25
|
+
maxItems: 10,
|
|
26
|
+
}),
|
|
27
|
+
categories: new validation_1.ArrayType({
|
|
28
|
+
items: new validation_1.StringType({
|
|
29
|
+
minLength: 1,
|
|
30
|
+
maxLength: 50,
|
|
31
|
+
}),
|
|
32
|
+
minItems: 1,
|
|
33
|
+
maxItems: 10,
|
|
34
|
+
}),
|
|
35
|
+
authors: new validation_1.ArrayType({
|
|
36
|
+
items: new validation_1.StringType({
|
|
37
|
+
minLength: 1,
|
|
38
|
+
maxLength: 50,
|
|
39
|
+
}),
|
|
40
|
+
minItems: 1,
|
|
41
|
+
maxItems: 10,
|
|
42
|
+
}),
|
|
43
|
+
publishTime: new validation_1.NumberType(),
|
|
44
|
+
updateTime: new validation_1.NumberType(),
|
|
45
|
+
},
|
|
46
|
+
});
|
package/schema/eventSchemas.d.ts
CHANGED
|
@@ -5,6 +5,8 @@ export declare const checkoutStarted: ObjectType;
|
|
|
5
5
|
export declare const orderPlaced: ObjectType;
|
|
6
6
|
export declare const productViewed: ObjectType;
|
|
7
7
|
export declare const userSignedUp: ObjectType;
|
|
8
|
-
export declare const testGroupAssigned: ObjectType;
|
|
9
8
|
export declare const goalCompleted: ObjectType;
|
|
9
|
+
export declare const interestShown: ObjectType;
|
|
10
|
+
export declare const postViewed: ObjectType;
|
|
11
|
+
export declare const linkOpened: ObjectType;
|
|
10
12
|
export declare const eventOccurred: ObjectType;
|
package/schema/eventSchemas.js
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.eventOccurred = exports.
|
|
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
4
|
var validation_1 = require("../validation");
|
|
5
5
|
var ecommerceSchemas_1 = require("./ecommerceSchemas");
|
|
6
6
|
var userSchema_1 = require("./userSchema");
|
|
7
|
+
var contentSchemas_1 = require("./contentSchemas");
|
|
7
8
|
exports.cartModified = new validation_1.ObjectType({
|
|
8
9
|
required: ['cart'],
|
|
9
10
|
properties: {
|
|
@@ -48,19 +49,6 @@ exports.userSignedUp = new validation_1.ObjectType({
|
|
|
48
49
|
profile: userSchema_1.userProfileSchema,
|
|
49
50
|
},
|
|
50
51
|
});
|
|
51
|
-
exports.testGroupAssigned = new validation_1.ObjectType({
|
|
52
|
-
required: ['testId', 'groupId'],
|
|
53
|
-
properties: {
|
|
54
|
-
testId: new validation_1.StringType({
|
|
55
|
-
minLength: 1,
|
|
56
|
-
maxLength: 50,
|
|
57
|
-
}),
|
|
58
|
-
groupId: new validation_1.StringType({
|
|
59
|
-
minLength: 1,
|
|
60
|
-
maxLength: 50,
|
|
61
|
-
}),
|
|
62
|
-
},
|
|
63
|
-
});
|
|
64
52
|
exports.goalCompleted = new validation_1.ObjectType({
|
|
65
53
|
required: ['goalId'],
|
|
66
54
|
properties: {
|
|
@@ -77,6 +65,33 @@ exports.goalCompleted = new validation_1.ObjectType({
|
|
|
77
65
|
}),
|
|
78
66
|
},
|
|
79
67
|
});
|
|
68
|
+
exports.interestShown = new validation_1.ObjectType({
|
|
69
|
+
required: ['interests'],
|
|
70
|
+
properties: {
|
|
71
|
+
interests: new validation_1.ArrayType({
|
|
72
|
+
items: new validation_1.StringType({
|
|
73
|
+
minLength: 1,
|
|
74
|
+
maxLength: 50,
|
|
75
|
+
}),
|
|
76
|
+
minItems: 1,
|
|
77
|
+
maxItems: 10,
|
|
78
|
+
}),
|
|
79
|
+
},
|
|
80
|
+
});
|
|
81
|
+
exports.postViewed = new validation_1.ObjectType({
|
|
82
|
+
required: ['post'],
|
|
83
|
+
properties: {
|
|
84
|
+
post: contentSchemas_1.postDetails,
|
|
85
|
+
},
|
|
86
|
+
});
|
|
87
|
+
exports.linkOpened = new validation_1.ObjectType({
|
|
88
|
+
required: ['link'],
|
|
89
|
+
properties: {
|
|
90
|
+
link: new validation_1.StringType({
|
|
91
|
+
format: 'uri-reference',
|
|
92
|
+
}),
|
|
93
|
+
},
|
|
94
|
+
});
|
|
80
95
|
exports.eventOccurred = new validation_1.ObjectType({
|
|
81
96
|
required: ['name'],
|
|
82
97
|
properties: {
|
package/schema/index.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
var tslib_1 = require("tslib");
|
|
4
|
-
tslib_1.__exportStar(require("./contextSchemas"), exports);
|
|
5
|
-
tslib_1.__exportStar(require("./ecommerceSchemas"), exports);
|
|
6
|
-
tslib_1.__exportStar(require("./evaluationSchemas"), exports);
|
|
7
|
-
tslib_1.__exportStar(require("./eventSchemas"), exports);
|
|
8
|
-
tslib_1.__exportStar(require("./loggerSchema"), exports);
|
|
9
|
-
tslib_1.__exportStar(require("./operationSchemas"), exports);
|
|
10
|
-
tslib_1.__exportStar(require("./sdkFacadeSchemas"), exports);
|
|
11
|
-
tslib_1.__exportStar(require("./sdkSchemas"), exports);
|
|
12
|
-
tslib_1.__exportStar(require("./tokenSchema"), exports);
|
|
13
|
-
tslib_1.__exportStar(require("./userSchema"), exports);
|
|
4
|
+
(0, tslib_1.__exportStar)(require("./contextSchemas"), exports);
|
|
5
|
+
(0, tslib_1.__exportStar)(require("./ecommerceSchemas"), exports);
|
|
6
|
+
(0, tslib_1.__exportStar)(require("./evaluationSchemas"), exports);
|
|
7
|
+
(0, tslib_1.__exportStar)(require("./eventSchemas"), exports);
|
|
8
|
+
(0, tslib_1.__exportStar)(require("./loggerSchema"), exports);
|
|
9
|
+
(0, tslib_1.__exportStar)(require("./operationSchemas"), exports);
|
|
10
|
+
(0, tslib_1.__exportStar)(require("./sdkFacadeSchemas"), exports);
|
|
11
|
+
(0, tslib_1.__exportStar)(require("./sdkSchemas"), exports);
|
|
12
|
+
(0, tslib_1.__exportStar)(require("./tokenSchema"), exports);
|
|
13
|
+
(0, tslib_1.__exportStar)(require("./userSchema"), exports);
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.unsetOperation = exports.clearOperation = exports.incrementOperation = exports.decrementOperation = exports.mergeOperation = exports.combineOperation = exports.setOperation = exports.addOperation = void 0;
|
|
3
|
+
exports.removeOperation = exports.unsetOperation = exports.clearOperation = exports.incrementOperation = exports.decrementOperation = exports.mergeOperation = exports.combineOperation = exports.setOperation = exports.addOperation = void 0;
|
|
4
4
|
var validation_1 = require("../validation");
|
|
5
|
+
var attributeSchema_1 = require("./attributeSchema");
|
|
5
6
|
var pointer = new validation_1.StringType({
|
|
6
7
|
format: 'pointer',
|
|
7
8
|
});
|
|
@@ -10,9 +11,11 @@ var simpleArray = new validation_1.JsonArrayType({
|
|
|
10
11
|
});
|
|
11
12
|
var simpleMap = new validation_1.JsonObjectType({
|
|
12
13
|
properties: new validation_1.JsonPrimitiveType(),
|
|
14
|
+
propertyNames: attributeSchema_1.attributeNameSchema,
|
|
13
15
|
});
|
|
14
16
|
var complexMap = new validation_1.JsonObjectType({
|
|
15
17
|
properties: new validation_1.UnionType(new validation_1.JsonPrimitiveType(), simpleArray, simpleMap),
|
|
18
|
+
propertyNames: attributeSchema_1.attributeNameSchema,
|
|
16
19
|
});
|
|
17
20
|
var collectionValue = new validation_1.UnionType(simpleArray, complexMap);
|
|
18
21
|
var mixedValue = new validation_1.UnionType(new validation_1.JsonPrimitiveType(), simpleArray, complexMap);
|
|
@@ -70,3 +73,10 @@ exports.unsetOperation = new validation_1.ObjectType({
|
|
|
70
73
|
path: pointer,
|
|
71
74
|
},
|
|
72
75
|
});
|
|
76
|
+
exports.removeOperation = new validation_1.ObjectType({
|
|
77
|
+
required: ['path', 'value'],
|
|
78
|
+
properties: {
|
|
79
|
+
path: pointer,
|
|
80
|
+
value: mixedValue,
|
|
81
|
+
},
|
|
82
|
+
});
|
|
@@ -16,6 +16,7 @@ exports.sdkFacadeConfigurationSchema = new validation_1.ObjectType({
|
|
|
16
16
|
}),
|
|
17
17
|
tokenScope: contextSchemas_1.tokenScopeSchema,
|
|
18
18
|
debug: new validation_1.BooleanType(),
|
|
19
|
+
test: new validation_1.BooleanType(),
|
|
19
20
|
track: new validation_1.BooleanType(),
|
|
20
21
|
logger: loggerSchema_1.loggerSchema,
|
|
21
22
|
urlSanitizer: new validation_1.FunctionType(),
|
package/schema/sdkSchemas.js
CHANGED
|
@@ -39,6 +39,7 @@ exports.sdkConfigurationSchema = new validation_1.ObjectType({
|
|
|
39
39
|
integer: true,
|
|
40
40
|
}),
|
|
41
41
|
debug: new validation_1.BooleanType(),
|
|
42
|
+
test: new validation_1.BooleanType(),
|
|
42
43
|
logger: loggerSchema_1.loggerSchema,
|
|
43
44
|
urlSanitizer: new validation_1.FunctionType(),
|
|
44
45
|
eventMetadata: exports.eventMetadataSchema,
|
package/schema/userSchema.js
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.userProfileSchema = void 0;
|
|
4
4
|
var validation_1 = require("../validation");
|
|
5
|
+
var attributeSchema_1 = require("./attributeSchema");
|
|
5
6
|
exports.userProfileSchema = new validation_1.ObjectType({
|
|
6
7
|
properties: {
|
|
7
8
|
firstName: new validation_1.StringType({
|
|
@@ -93,10 +94,7 @@ exports.userProfileSchema = new validation_1.ObjectType({
|
|
|
93
94
|
}),
|
|
94
95
|
}),
|
|
95
96
|
custom: new validation_1.ObjectType({
|
|
96
|
-
propertyNames:
|
|
97
|
-
maxLength: 50,
|
|
98
|
-
format: 'identifier',
|
|
99
|
-
}),
|
|
97
|
+
propertyNames: attributeSchema_1.attributeNameSchema,
|
|
100
98
|
maxProperties: 10,
|
|
101
99
|
additionalProperties: new validation_1.UnionType(new validation_1.BooleanType(), new validation_1.NullType(), new validation_1.NumberType(), new validation_1.StringType({
|
|
102
100
|
maxLength: 100,
|
|
@@ -110,20 +108,14 @@ exports.userProfileSchema = new validation_1.ObjectType({
|
|
|
110
108
|
maxLength: 100,
|
|
111
109
|
})),
|
|
112
110
|
}), new validation_1.ObjectType({
|
|
113
|
-
propertyNames:
|
|
114
|
-
maxLength: 50,
|
|
115
|
-
format: 'identifier',
|
|
116
|
-
}),
|
|
111
|
+
propertyNames: attributeSchema_1.attributeNameSchema,
|
|
117
112
|
maxProperties: 10,
|
|
118
113
|
additionalProperties: new validation_1.UnionType(new validation_1.BooleanType(), new validation_1.NullType(), new validation_1.NumberType(), new validation_1.StringType({
|
|
119
114
|
maxLength: 100,
|
|
120
115
|
})),
|
|
121
116
|
})),
|
|
122
117
|
}), new validation_1.ObjectType({
|
|
123
|
-
propertyNames:
|
|
124
|
-
maxLength: 50,
|
|
125
|
-
format: 'identifier',
|
|
126
|
-
}),
|
|
118
|
+
propertyNames: attributeSchema_1.attributeNameSchema,
|
|
127
119
|
maxProperties: 10,
|
|
128
120
|
additionalProperties: new validation_1.UnionType(new validation_1.BooleanType(), new validation_1.NullType(), new validation_1.NumberType(), new validation_1.StringType({
|
|
129
121
|
maxLength: 100,
|
|
@@ -133,10 +125,7 @@ exports.userProfileSchema = new validation_1.ObjectType({
|
|
|
133
125
|
maxLength: 100,
|
|
134
126
|
})),
|
|
135
127
|
}), new validation_1.ObjectType({
|
|
136
|
-
propertyNames:
|
|
137
|
-
maxLength: 50,
|
|
138
|
-
format: 'identifier',
|
|
139
|
-
}),
|
|
128
|
+
propertyNames: attributeSchema_1.attributeNameSchema,
|
|
140
129
|
maxProperties: 10,
|
|
141
130
|
additionalProperties: new validation_1.UnionType(new validation_1.BooleanType(), new validation_1.NullType(), new validation_1.NumberType(), new validation_1.StringType({
|
|
142
131
|
maxLength: 100,
|
package/sdk.d.ts
CHANGED
package/sdk.js
CHANGED
|
@@ -14,7 +14,7 @@ function validateConfiguration(configuration) {
|
|
|
14
14
|
schema_1.sdkConfigurationSchema.validate(configuration);
|
|
15
15
|
}
|
|
16
16
|
catch (violation) {
|
|
17
|
-
throw new Error("Invalid configuration: "
|
|
17
|
+
throw new Error("Invalid configuration: ".concat((0, error_1.formatCause)(violation)));
|
|
18
18
|
}
|
|
19
19
|
}
|
|
20
20
|
var Sdk = /** @class */ (function () {
|
|
@@ -25,14 +25,14 @@ var Sdk = /** @class */ (function () {
|
|
|
25
25
|
var e_1, _a;
|
|
26
26
|
var _b, _c, _d, _e;
|
|
27
27
|
validateConfiguration(configuration);
|
|
28
|
-
var _f = configuration.eventMetadata, customMetadata = _f === void 0 ? {} : _f, containerConfiguration = tslib_1.__rest(configuration, ["eventMetadata"]);
|
|
28
|
+
var _f = configuration.eventMetadata, customMetadata = _f === void 0 ? {} : _f, containerConfiguration = (0, tslib_1.__rest)(configuration, ["eventMetadata"]);
|
|
29
29
|
var eventMetadata = {
|
|
30
30
|
sdkVersion: constants_1.VERSION,
|
|
31
31
|
};
|
|
32
32
|
try {
|
|
33
|
-
for (var _g = tslib_1.__values(Object.keys(customMetadata)), _h = _g.next(); !_h.done; _h = _g.next()) {
|
|
33
|
+
for (var _g = (0, tslib_1.__values)(Object.keys(customMetadata)), _h = _g.next(); !_h.done; _h = _g.next()) {
|
|
34
34
|
var metadata = _h.value;
|
|
35
|
-
eventMetadata["custom_"
|
|
35
|
+
eventMetadata["custom_".concat(metadata)] = customMetadata[metadata];
|
|
36
36
|
}
|
|
37
37
|
}
|
|
38
38
|
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
@@ -42,7 +42,7 @@ var Sdk = /** @class */ (function () {
|
|
|
42
42
|
}
|
|
43
43
|
finally { if (e_1) throw e_1.error; }
|
|
44
44
|
}
|
|
45
|
-
var container = new container_1.Container(tslib_1.__assign(tslib_1.__assign({}, containerConfiguration), { evaluationEndpointUrl: (_b = containerConfiguration.evaluationEndpointUrl) !== null && _b !== void 0 ? _b : constants_1.EVALUATION_ENDPOINT_URL, trackerEndpointUrl: (_c = containerConfiguration.trackerEndpointUrl) !== null && _c !== void 0 ? _c : constants_1.TRACKER_ENDPOINT_URL, bootstrapEndpointUrl: (_d = containerConfiguration.bootstrapEndpointUrl) !== null && _d !== void 0 ? _d : constants_1.BOOTSTRAP_ENDPOINT_URL, beaconQueueSize: (_e = containerConfiguration.beaconQueueSize) !== null && _e !== void 0 ? _e : 100, eventMetadata: eventMetadata }));
|
|
45
|
+
var container = new container_1.Container((0, tslib_1.__assign)((0, tslib_1.__assign)({}, containerConfiguration), { evaluationEndpointUrl: (_b = containerConfiguration.evaluationEndpointUrl) !== null && _b !== void 0 ? _b : constants_1.EVALUATION_ENDPOINT_URL, trackerEndpointUrl: (_c = containerConfiguration.trackerEndpointUrl) !== null && _c !== void 0 ? _c : constants_1.TRACKER_ENDPOINT_URL, bootstrapEndpointUrl: (_d = containerConfiguration.bootstrapEndpointUrl) !== null && _d !== void 0 ? _d : constants_1.BOOTSTRAP_ENDPOINT_URL, beaconQueueSize: (_e = containerConfiguration.beaconQueueSize) !== null && _e !== void 0 ? _e : 100, eventMetadata: eventMetadata }));
|
|
46
46
|
var logger = container.getLogger();
|
|
47
47
|
var _j = container.getConfiguration(), appId = _j.appId, tokenScope = _j.tokenScope;
|
|
48
48
|
logger.debug('\n\n'
|
|
@@ -52,14 +52,15 @@ var Sdk = /** @class */ (function () {
|
|
|
52
52
|
+ '██ ██ ██ ██ ██ ██ ██ \n'
|
|
53
53
|
+ ' ██████ ██ ██ ██████ ██████ ██ \n'
|
|
54
54
|
+ '\n');
|
|
55
|
-
logger.info("Initializing SDK v"
|
|
56
|
-
logger.debug("App ID: "
|
|
55
|
+
logger.info("Initializing SDK v".concat(constants_1.VERSION, "..."));
|
|
56
|
+
logger.debug("App ID: ".concat(appId));
|
|
57
57
|
var context = container.getContext();
|
|
58
58
|
var tab = context.getTab();
|
|
59
59
|
var user = context.getUser();
|
|
60
|
-
logger.debug((tab.isNew ? 'New' : 'Current'
|
|
61
|
-
logger.debug("Token scope: "
|
|
62
|
-
logger.debug("Current user: "
|
|
60
|
+
logger.debug("".concat(tab.isNew ? 'New' : 'Current', " tab: ").concat(tab.id));
|
|
61
|
+
logger.debug("Token scope: ".concat(tokenScope));
|
|
62
|
+
logger.debug("Current user: ".concat(user !== null ? user : 'anonymous'));
|
|
63
|
+
logger.debug("Test mode: ".concat(containerConfiguration.test));
|
|
63
64
|
logger.info('⚡ Croct SDK is ready!');
|
|
64
65
|
return new Sdk(container);
|
|
65
66
|
};
|
|
@@ -112,7 +113,7 @@ var Sdk = /** @class */ (function () {
|
|
|
112
113
|
for (var _i = 0; _i < arguments.length; _i++) {
|
|
113
114
|
namespace[_i] = arguments[_i];
|
|
114
115
|
}
|
|
115
|
-
return (_a = this.container).getLogger.apply(_a, tslib_1.__spreadArray([], tslib_1.__read(namespace)));
|
|
116
|
+
return (_a = this.container).getLogger.apply(_a, (0, tslib_1.__spreadArray)([], (0, tslib_1.__read)(namespace), false));
|
|
116
117
|
};
|
|
117
118
|
Sdk.prototype.getTabStorage = function (namespace) {
|
|
118
119
|
var _a;
|
|
@@ -120,7 +121,7 @@ var Sdk = /** @class */ (function () {
|
|
|
120
121
|
for (var _i = 1; _i < arguments.length; _i++) {
|
|
121
122
|
subnamespace[_i - 1] = arguments[_i];
|
|
122
123
|
}
|
|
123
|
-
return (_a = this.container).getTabStorage.apply(_a, tslib_1.__spreadArray([namespace], tslib_1.__read(subnamespace)));
|
|
124
|
+
return (_a = this.container).getTabStorage.apply(_a, (0, tslib_1.__spreadArray)([namespace], (0, tslib_1.__read)(subnamespace), false));
|
|
124
125
|
};
|
|
125
126
|
Sdk.prototype.getBrowserStorage = function (namespace) {
|
|
126
127
|
var _a;
|
|
@@ -128,12 +129,12 @@ var Sdk = /** @class */ (function () {
|
|
|
128
129
|
for (var _i = 1; _i < arguments.length; _i++) {
|
|
129
130
|
subnamespace[_i - 1] = arguments[_i];
|
|
130
131
|
}
|
|
131
|
-
return (_a = this.container).getBrowserStorage.apply(_a, tslib_1.__spreadArray([namespace], tslib_1.__read(subnamespace)));
|
|
132
|
+
return (_a = this.container).getBrowserStorage.apply(_a, (0, tslib_1.__spreadArray)([namespace], (0, tslib_1.__read)(subnamespace), false));
|
|
132
133
|
};
|
|
133
134
|
Sdk.prototype.close = function () {
|
|
134
|
-
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
135
|
+
return (0, tslib_1.__awaiter)(this, void 0, void 0, function () {
|
|
135
136
|
var logger;
|
|
136
|
-
return tslib_1.__generator(this, function (_a) {
|
|
137
|
+
return (0, tslib_1.__generator)(this, function (_a) {
|
|
137
138
|
switch (_a.label) {
|
|
138
139
|
case 0:
|
|
139
140
|
if (this.closed) {
|
package/sourceLocation.js
CHANGED
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.getLocation = exports.getPosition = exports.getLength = void 0;
|
|
4
4
|
var tslib_1 = require("tslib");
|
|
5
5
|
function getLength(input) {
|
|
6
|
-
return tslib_1.__spreadArray([], tslib_1.__read(input)).length;
|
|
6
|
+
return (0, tslib_1.__spreadArray)([], (0, tslib_1.__read)(input), false).length;
|
|
7
7
|
}
|
|
8
8
|
exports.getLength = getLength;
|
|
9
9
|
function getPosition(input, index) {
|
|
@@ -19,7 +19,7 @@ function getLocation(input, startIndex, endIndex) {
|
|
|
19
19
|
}
|
|
20
20
|
var start;
|
|
21
21
|
var end;
|
|
22
|
-
var chars = tslib_1.__spreadArray([], tslib_1.__read(input));
|
|
22
|
+
var chars = (0, tslib_1.__spreadArray)([], (0, tslib_1.__read)(input), false);
|
|
23
23
|
var line = 1;
|
|
24
24
|
var column = 0;
|
|
25
25
|
for (var offset = 0; offset < chars.length; offset++) {
|
package/token/index.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.ReplicatedTokenStore = exports.InMemoryTokenStore = exports.CachedTokenStore = void 0;
|
|
4
4
|
var tslib_1 = require("tslib");
|
|
5
|
-
tslib_1.__exportStar(require("./token"), exports);
|
|
5
|
+
(0, tslib_1.__exportStar)(require("./token"), exports);
|
|
6
6
|
var cachedTokenStore_1 = require("./cachedTokenStore");
|
|
7
7
|
Object.defineProperty(exports, "CachedTokenStore", { enumerable: true, get: function () { return cachedTokenStore_1.CachedTokenStore; } });
|
|
8
8
|
var inMemoryTokenStore_1 = require("./inMemoryTokenStore");
|