@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.
Files changed (231) hide show
  1. package/.src/activeRecord.ts +150 -0
  2. package/.src/base64Url.ts +18 -0
  3. package/.src/cache/cache.ts +15 -0
  4. package/.src/cache/fallbackCache.ts +29 -0
  5. package/.src/cache/inMemoryCache.ts +21 -0
  6. package/.src/cache/index.ts +4 -0
  7. package/.src/cache/localStorageCache.ts +85 -0
  8. package/.src/channel/beaconSocketChannel.ts +153 -0
  9. package/.src/channel/channel.ts +20 -0
  10. package/.src/channel/encodedChannel.ts +21 -0
  11. package/.src/channel/guaranteedChannel.ts +131 -0
  12. package/.src/channel/index.ts +8 -0
  13. package/.src/channel/queuedChannel.ts +112 -0
  14. package/.src/channel/retryChannel.ts +90 -0
  15. package/.src/channel/sandboxChannel.ts +43 -0
  16. package/.src/channel/socketChannel.ts +217 -0
  17. package/.src/cid/assigner.ts +3 -0
  18. package/.src/cid/cachedAssigner.ts +35 -0
  19. package/.src/cid/fixedAssigner.ts +13 -0
  20. package/.src/cid/index.ts +4 -0
  21. package/.src/cid/remoteAssigner.ts +47 -0
  22. package/.src/constants.ts +6 -0
  23. package/.src/container.ts +388 -0
  24. package/.src/contentFetcher.ts +226 -0
  25. package/.src/context.ts +137 -0
  26. package/.src/error.ts +31 -0
  27. package/.src/evaluator.ts +251 -0
  28. package/.src/eventManager.ts +53 -0
  29. package/.src/facade/contentFetcherFacade.ts +69 -0
  30. package/.src/facade/evaluatorFacade.ts +152 -0
  31. package/.src/facade/index.ts +7 -0
  32. package/.src/facade/sdkFacade.ts +291 -0
  33. package/.src/facade/sessionFacade.ts +14 -0
  34. package/.src/facade/sessionPatch.ts +32 -0
  35. package/.src/facade/trackerFacade.ts +98 -0
  36. package/.src/facade/userFacade.ts +26 -0
  37. package/.src/facade/userPatch.ts +32 -0
  38. package/.src/index.ts +4 -0
  39. package/.src/logging/consoleLogger.ts +37 -0
  40. package/.src/logging/index.ts +4 -0
  41. package/.src/logging/logger.ts +13 -0
  42. package/.src/logging/namespacedLogger.ts +32 -0
  43. package/.src/logging/nullLogger.ts +19 -0
  44. package/.src/namespacedStorage.ts +69 -0
  45. package/.src/patch.ts +64 -0
  46. package/.src/queue/capacityRestrictedQueue.ts +44 -0
  47. package/.src/queue/inMemoryQueue.ts +43 -0
  48. package/.src/queue/index.ts +5 -0
  49. package/.src/queue/monitoredQueue.ts +168 -0
  50. package/.src/queue/persistentQueue.ts +84 -0
  51. package/.src/queue/queue.ts +15 -0
  52. package/.src/retry/arbitraryPolicy.ts +21 -0
  53. package/.src/retry/backoffPolicy.ts +84 -0
  54. package/.src/retry/index.ts +5 -0
  55. package/.src/retry/maxAttemptsPolicy.ts +28 -0
  56. package/.src/retry/neverPolicy.ts +11 -0
  57. package/.src/retry/policy.ts +5 -0
  58. package/.src/schema/attributeSchema.ts +6 -0
  59. package/.src/schema/contentFetcherSchemas.ts +23 -0
  60. package/.src/schema/contentSchemas.ts +44 -0
  61. package/.src/schema/contextSchemas.ts +5 -0
  62. package/.src/schema/ecommerceSchemas.ts +179 -0
  63. package/.src/schema/evaluatorSchemas.ts +11 -0
  64. package/.src/schema/eventSchemas.ts +150 -0
  65. package/.src/schema/index.ts +11 -0
  66. package/.src/schema/loggerSchema.ts +12 -0
  67. package/.src/schema/operationSchemas.ts +102 -0
  68. package/.src/schema/sdkFacadeSchemas.ts +44 -0
  69. package/.src/schema/sdkSchemas.ts +49 -0
  70. package/.src/schema/tokenSchema.ts +42 -0
  71. package/.src/schema/userSchema.ts +184 -0
  72. package/.src/sdk.ts +174 -0
  73. package/.src/sdkEvents.ts +15 -0
  74. package/.src/sourceLocation.ts +85 -0
  75. package/.src/tab.ts +148 -0
  76. package/.src/token/cachedTokenStore.ts +34 -0
  77. package/.src/token/inMemoryTokenStore.ts +13 -0
  78. package/.src/token/index.ts +4 -0
  79. package/.src/token/replicatedTokenStore.ts +21 -0
  80. package/.src/token/token.ts +164 -0
  81. package/.src/tracker.ts +460 -0
  82. package/.src/trackingEvents.ts +456 -0
  83. package/.src/transformer.ts +7 -0
  84. package/.src/utilityTypes.ts +3 -0
  85. package/.src/uuid.ts +43 -0
  86. package/.src/validation/arrayType.ts +71 -0
  87. package/.src/validation/booleanType.ts +22 -0
  88. package/.src/validation/functionType.ts +22 -0
  89. package/.src/validation/index.ts +12 -0
  90. package/.src/validation/jsonType.ts +157 -0
  91. package/.src/validation/mixedSchema.ts +7 -0
  92. package/.src/validation/nullType.ts +22 -0
  93. package/.src/validation/numberType.ts +59 -0
  94. package/.src/validation/objectType.ts +138 -0
  95. package/.src/validation/schema.ts +21 -0
  96. package/.src/validation/stringType.ts +118 -0
  97. package/.src/validation/unionType.ts +53 -0
  98. package/.src/validation/violation.ts +23 -0
  99. package/activeRecord.js +33 -36
  100. package/base64Url.js +1 -0
  101. package/cache/cache.js +1 -0
  102. package/cache/fallbackCache.js +16 -32
  103. package/cache/inMemoryCache.js +10 -10
  104. package/cache/index.js +2 -1
  105. package/cache/localStorageCache.js +25 -25
  106. package/channel/beaconSocketChannel.d.ts +1 -1
  107. package/channel/beaconSocketChannel.js +50 -79
  108. package/channel/channel.d.ts +1 -1
  109. package/channel/channel.js +1 -0
  110. package/channel/encodedChannel.js +9 -10
  111. package/channel/guaranteedChannel.d.ts +4 -4
  112. package/channel/guaranteedChannel.js +42 -43
  113. package/channel/index.js +2 -1
  114. package/channel/queuedChannel.js +36 -64
  115. package/channel/retryChannel.d.ts +1 -1
  116. package/channel/retryChannel.js +45 -77
  117. package/channel/sandboxChannel.js +18 -18
  118. package/channel/socketChannel.d.ts +4 -4
  119. package/channel/socketChannel.js +78 -79
  120. package/cid/assigner.js +1 -0
  121. package/cid/cachedAssigner.js +16 -27
  122. package/cid/fixedAssigner.js +6 -6
  123. package/cid/index.js +2 -1
  124. package/cid/remoteAssigner.js +24 -36
  125. package/constants.d.ts +6 -5
  126. package/constants.js +7 -5
  127. package/container.d.ts +13 -6
  128. package/container.js +153 -168
  129. package/contentFetcher.d.ts +59 -0
  130. package/contentFetcher.js +130 -0
  131. package/context.d.ts +3 -3
  132. package/context.js +37 -38
  133. package/error.js +3 -2
  134. package/evaluator.d.ts +33 -24
  135. package/evaluator.js +127 -117
  136. package/eventManager.d.ts +1 -1
  137. package/eventManager.js +15 -15
  138. package/facade/contentFetcherFacade.d.ts +27 -0
  139. package/facade/contentFetcherFacade.js +41 -0
  140. package/facade/evaluatorFacade.d.ts +13 -3
  141. package/facade/evaluatorFacade.js +58 -72
  142. package/facade/index.js +1 -0
  143. package/facade/sdkFacade.d.ts +10 -3
  144. package/facade/sdkFacade.js +130 -141
  145. package/facade/sessionFacade.js +7 -7
  146. package/facade/sessionPatch.js +10 -13
  147. package/facade/trackerFacade.js +33 -38
  148. package/facade/userFacade.js +11 -11
  149. package/facade/userPatch.js +10 -13
  150. package/index.js +3 -2
  151. package/logging/consoleLogger.js +19 -35
  152. package/logging/index.js +2 -1
  153. package/logging/logger.js +1 -0
  154. package/logging/namespacedLogger.js +15 -15
  155. package/logging/nullLogger.js +11 -13
  156. package/namespacedStorage.js +31 -47
  157. package/package.json +13 -16
  158. package/patch.d.ts +1 -1
  159. package/patch.js +1 -0
  160. package/queue/capacityRestrictedQueue.js +18 -18
  161. package/queue/inMemoryQueue.js +23 -28
  162. package/queue/index.js +2 -1
  163. package/queue/monitoredQueue.d.ts +2 -2
  164. package/queue/monitoredQueue.js +40 -40
  165. package/queue/persistentQueue.js +34 -38
  166. package/queue/queue.js +1 -0
  167. package/retry/arbitraryPolicy.js +9 -10
  168. package/retry/backoffPolicy.d.ts +1 -1
  169. package/retry/backoffPolicy.js +12 -13
  170. package/retry/index.js +2 -1
  171. package/retry/maxAttemptsPolicy.js +8 -8
  172. package/retry/neverPolicy.js +7 -9
  173. package/retry/policy.js +1 -0
  174. package/schema/attributeSchema.js +2 -1
  175. package/schema/contentFetcherSchemas.d.ts +2 -0
  176. package/schema/contentFetcherSchemas.js +23 -0
  177. package/schema/contentSchemas.js +2 -1
  178. package/schema/contextSchemas.js +2 -1
  179. package/schema/ecommerceSchemas.js +2 -1
  180. package/schema/evaluatorSchemas.d.ts +2 -0
  181. package/schema/{evaluationSchemas.js → evaluatorSchemas.js} +4 -3
  182. package/schema/eventSchemas.js +6 -7
  183. package/schema/index.d.ts +2 -1
  184. package/schema/index.js +4 -2
  185. package/schema/loggerSchema.js +2 -1
  186. package/schema/operationSchemas.js +9 -8
  187. package/schema/sdkFacadeSchemas.js +10 -6
  188. package/schema/sdkSchemas.js +9 -5
  189. package/schema/tokenSchema.js +6 -4
  190. package/schema/userSchema.js +3 -2
  191. package/sdk.d.ts +9 -3
  192. package/sdk.js +82 -127
  193. package/sdkEvents.d.ts +3 -3
  194. package/sdkEvents.js +1 -0
  195. package/sourceLocation.d.ts +3 -3
  196. package/sourceLocation.js +14 -14
  197. package/tab.d.ts +5 -5
  198. package/tab.js +51 -80
  199. package/token/cachedTokenStore.js +10 -10
  200. package/token/inMemoryTokenStore.js +8 -8
  201. package/token/index.js +2 -1
  202. package/token/replicatedTokenStore.js +8 -8
  203. package/token/token.d.ts +9 -5
  204. package/token/token.js +64 -57
  205. package/tracker.d.ts +4 -4
  206. package/tracker.js +146 -122
  207. package/trackingEvents.d.ts +36 -36
  208. package/trackingEvents.js +13 -6
  209. package/transformer.js +2 -1
  210. package/utilityTypes.d.ts +2 -2
  211. package/utilityTypes.js +1 -0
  212. package/uuid.js +10 -7
  213. package/validation/arrayType.d.ts +2 -2
  214. package/validation/arrayType.js +30 -27
  215. package/validation/booleanType.js +12 -15
  216. package/validation/functionType.js +12 -15
  217. package/validation/index.js +2 -1
  218. package/validation/jsonType.d.ts +2 -2
  219. package/validation/jsonType.js +62 -80
  220. package/validation/mixedSchema.js +5 -7
  221. package/validation/nullType.js +12 -15
  222. package/validation/numberType.d.ts +1 -1
  223. package/validation/numberType.js +24 -22
  224. package/validation/objectType.d.ts +1 -1
  225. package/validation/objectType.js +62 -72
  226. package/validation/schema.js +7 -10
  227. package/validation/stringType.d.ts +1 -1
  228. package/validation/stringType.js +37 -47
  229. package/validation/unionType.js +28 -77
  230. package/validation/violation.js +2 -2
  231. package/schema/evaluationSchemas.d.ts +0 -2
@@ -1,42 +1,37 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.InMemoryQueue = void 0;
4
- var tslib_1 = require("tslib");
5
- var InMemoryQueue = /** @class */ (function () {
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
- (_a = this.queue).unshift.apply(_a, tslib_1.__spreadArray([], tslib_1.__read(values), false));
7
+ this.queue.unshift(...values);
14
8
  }
15
- InMemoryQueue.prototype.all = function () {
9
+ all() {
16
10
  return this.queue.slice();
17
- };
18
- InMemoryQueue.prototype.getCapacity = function () {
11
+ }
12
+ getCapacity() {
19
13
  return Infinity;
20
- };
21
- InMemoryQueue.prototype.isEmpty = function () {
14
+ }
15
+ isEmpty() {
22
16
  return this.queue.length === 0;
23
- };
24
- InMemoryQueue.prototype.push = function (value) {
17
+ }
18
+ push(value) {
25
19
  this.queue.push(value);
26
- };
27
- InMemoryQueue.prototype.peek = function () {
28
- return this.queue[0] || null;
29
- };
30
- InMemoryQueue.prototype.shift = function () {
31
- var value = this.queue.shift();
32
- if (!value) {
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
- InMemoryQueue.prototype.length = function () {
31
+ }
32
+ length() {
38
33
  return this.queue.length;
39
- };
40
- return InMemoryQueue;
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
- var tslib_1 = require("tslib");
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 declare type QueueStatus = 'halfEmpty' | 'almostEmpty' | 'empty' | 'halfFull' | 'almostFull' | 'full';
4
- export declare type QueueCallback<T> = {
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> {
@@ -1,22 +1,23 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.MonitoredQueue = void 0;
4
- var logging_1 = require("../logging");
5
- var MonitoredQueue = /** @class */ (function () {
6
- function MonitoredQueue(queue, logger) {
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
- MonitoredQueue.prototype.all = function () {
12
+ all() {
13
13
  return this.queue.all();
14
- };
15
- MonitoredQueue.prototype.getCapacity = function () {
14
+ }
15
+ getCapacity() {
16
16
  return this.queue.getCapacity();
17
- };
18
- MonitoredQueue.prototype.addCallback = function (status, callback) {
19
- var callbacks = this.callbacks[status] || [];
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
- MonitoredQueue.prototype.removeCallback = function (type, callback) {
43
- var callbacks = this.callbacks[type];
44
- if (!callbacks) {
42
+ }
43
+ removeCallback(type, callback) {
44
+ const callbacks = this.callbacks[type];
45
+ if (callbacks == null) {
45
46
  return;
46
47
  }
47
- var index = callbacks.indexOf(callback);
48
+ const index = callbacks.indexOf(callback);
48
49
  if (index >= 0) {
49
50
  callbacks.splice(index, 1);
50
51
  }
51
- };
52
- MonitoredQueue.prototype.setStatus = function (status) {
52
+ }
53
+ setStatus(status) {
53
54
  if (this.status === status) {
54
55
  return;
55
56
  }
56
- this.logger.debug("Queue status changed to \"".concat(status, "\""));
57
+ this.logger.debug(`Queue status changed to "${status}"`);
57
58
  this.report(status);
58
59
  this.status = status;
59
- };
60
- MonitoredQueue.prototype.report = function (status) {
61
- var _this = this;
62
- var callbacks = this.callbacks[status];
60
+ }
61
+ report(status) {
62
+ const callbacks = this.callbacks[status];
63
63
  if (callbacks !== undefined) {
64
- callbacks.forEach(function (callback) { return callback(_this); });
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
- MonitoredQueue.prototype.isEmpty = function () {
78
+ }
79
+ isEmpty() {
80
80
  return this.queue.isEmpty();
81
- };
82
- MonitoredQueue.prototype.length = function () {
81
+ }
82
+ length() {
83
83
  return this.queue.length();
84
- };
85
- MonitoredQueue.prototype.peek = function () {
84
+ }
85
+ peek() {
86
86
  return this.queue.peek();
87
- };
88
- MonitoredQueue.prototype.push = function (value) {
87
+ }
88
+ push(value) {
89
89
  this.queue.push(value);
90
90
  this.updateStatus();
91
- };
92
- MonitoredQueue.prototype.shift = function () {
93
- var value = this.queue.shift();
91
+ }
92
+ shift() {
93
+ const value = this.queue.shift();
94
94
  this.updateStatus();
95
95
  return value;
96
- };
97
- MonitoredQueue.prototype.updateStatus = function () {
98
- var length = this.queue.length();
99
- var capacity = this.getCapacity();
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
- return MonitoredQueue;
123
- }());
121
+ }
122
+ }
124
123
  exports.MonitoredQueue = MonitoredQueue;
124
+ //# sourceMappingURL=monitoredQueue.js.map
@@ -1,58 +1,54 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.PersistentQueue = void 0;
4
- var PersistentQueue = /** @class */ (function () {
5
- function PersistentQueue(storage, key) {
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
- PersistentQueue.prototype.all = function () {
9
+ all() {
11
10
  return this.queue.slice();
12
- };
13
- PersistentQueue.prototype.getCapacity = function () {
11
+ }
12
+ getCapacity() {
14
13
  return Infinity;
15
- };
16
- PersistentQueue.prototype.isEmpty = function () {
14
+ }
15
+ isEmpty() {
17
16
  return this.length() === 0;
18
- };
19
- PersistentQueue.prototype.length = function () {
17
+ }
18
+ length() {
20
19
  return this.queue.length;
21
- };
22
- PersistentQueue.prototype.push = function (value) {
20
+ }
21
+ push(value) {
23
22
  this.queue.push(value);
24
23
  this.flush();
25
- };
26
- PersistentQueue.prototype.peek = function () {
27
- var item = this.queue[0];
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
- PersistentQueue.prototype.shift = function () {
34
- var value = this.queue.shift();
35
- if (!value) {
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
- Object.defineProperty(PersistentQueue.prototype, "queue", {
42
- get: function () {
43
- if (!this.cache) {
44
- this.cache = this.load();
45
- }
46
- return this.cache;
47
- },
48
- enumerable: false,
49
- configurable: true
50
- });
51
- PersistentQueue.prototype.flush = function () {
52
- this.storage.setItem(this.key, JSON.stringify(this.cache || []));
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
- return PersistentQueue;
67
- }());
61
+ }
62
+ }
68
63
  exports.PersistentQueue = PersistentQueue;
64
+ //# sourceMappingURL=persistentQueue.js.map
package/queue/queue.js CHANGED
@@ -1,2 +1,3 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=queue.js.map
@@ -1,20 +1,19 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ArbitraryPolicy = void 0;
4
- var tslib_1 = require("tslib");
5
- var ArbitraryPolicy = /** @class */ (function () {
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 = tslib_1.__spreadArray([], tslib_1.__read(delays), false);
9
+ this.delays = [...delays];
11
10
  }
12
- ArbitraryPolicy.prototype.getDelay = function (attempt) {
11
+ getDelay(attempt) {
13
12
  return this.delays[Math.min(attempt < 0 ? 0 : attempt, this.delays.length - 1)];
14
- };
15
- ArbitraryPolicy.prototype.shouldRetry = function () {
13
+ }
14
+ shouldRetry() {
16
15
  return true;
17
- };
18
- return ArbitraryPolicy;
19
- }());
16
+ }
17
+ }
20
18
  exports.ArbitraryPolicy = ArbitraryPolicy;
19
+ //# sourceMappingURL=arbitraryPolicy.js.map
@@ -1,5 +1,5 @@
1
1
  import { RetryPolicy } from './policy';
2
- declare type Options = {
2
+ type Options = {
3
3
  minRetryDelay: number;
4
4
  maxRetryDelay: number;
5
5
  backoffFactor: number;
@@ -1,15 +1,14 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.BackoffPolicy = void 0;
4
- var BackoffPolicy = /** @class */ (function () {
5
- function BackoffPolicy(options) {
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
- var _a = options.minRetryDelay, minRetryDelay = _a === void 0 ? this.minRetryDelay : _a, _b = options.maxRetryDelay, maxRetryDelay = _b === void 0 ? this.maxRetryDelay : _b, _c = options.backoffFactor, backoffFactor = _c === void 0 ? this.backoffFactor : _c, _d = options.backoffJitter, backoffJitter = _d === void 0 ? this.backoffJitter : _d, _e = options.maxAttempts, maxAttempts = _e === void 0 ? this.maxAttempts : _e;
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
- BackoffPolicy.prototype.getDelay = function (attempt) {
40
- var delay = Math.min(Math.max(Math.pow(this.backoffFactor, attempt), this.minRetryDelay), this.maxRetryDelay);
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
- var min = Math.ceil(this.minRetryDelay);
45
- var max = Math.floor(delay);
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
- BackoffPolicy.prototype.shouldRetry = function (attempt) {
50
+ }
51
+ shouldRetry(attempt) {
53
52
  return attempt < this.maxAttempts;
54
- };
55
- return BackoffPolicy;
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
- var tslib_1 = require("tslib");
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
- var MaxAttemptsPolicy = /** @class */ (function () {
5
- function MaxAttemptsPolicy(delay, maxAttempts) {
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
- MaxAttemptsPolicy.prototype.getDelay = function () {
15
+ getDelay() {
16
16
  return this.delay;
17
- };
18
- MaxAttemptsPolicy.prototype.shouldRetry = function (attempt) {
17
+ }
18
+ shouldRetry(attempt) {
19
19
  return attempt < this.maxAttempts;
20
- };
21
- return MaxAttemptsPolicy;
22
- }());
20
+ }
21
+ }
23
22
  exports.MaxAttemptsPolicy = MaxAttemptsPolicy;
23
+ //# sourceMappingURL=maxAttemptsPolicy.js.map
@@ -1,15 +1,13 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.NeverPolicy = void 0;
4
- var NeverPolicy = /** @class */ (function () {
5
- function NeverPolicy() {
6
- }
7
- NeverPolicy.prototype.getDelay = function () {
4
+ class NeverPolicy {
5
+ getDelay() {
8
6
  return Infinity;
9
- };
10
- NeverPolicy.prototype.shouldRetry = function () {
7
+ }
8
+ shouldRetry() {
11
9
  return false;
12
- };
13
- return NeverPolicy;
14
- }());
10
+ }
11
+ }
15
12
  exports.NeverPolicy = NeverPolicy;
13
+ //# sourceMappingURL=neverPolicy.js.map
package/retry/policy.js CHANGED
@@ -1,2 +1,3 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=policy.js.map
@@ -1,8 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.attributeNameSchema = void 0;
4
- var validation_1 = require("../validation");
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,2 @@
1
+ import { ObjectType } from '../validation';
2
+ export declare const fetchOptionsSchema: ObjectType;
@@ -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
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.postDetails = void 0;
4
- var validation_1 = require("../validation");
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
@@ -1,7 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.tokenScopeSchema = void 0;
4
- var validation_1 = require("../validation");
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
- var validation_1 = require("../validation");
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
@@ -0,0 +1,2 @@
1
+ import { ObjectType } from '../validation';
2
+ export declare const evaluationOptionsSchema: ObjectType;
@@ -1,8 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.optionsSchema = void 0;
4
- var validation_1 = require("../validation");
5
- exports.optionsSchema = new validation_1.ObjectType({
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
@@ -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
- var validation_1 = require("../validation");
5
- var ecommerceSchemas_1 = require("./ecommerceSchemas");
6
- var userSchema_1 = require("./userSchema");
7
- var contentSchemas_1 = require("./contentSchemas");
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 './evaluationSchemas';
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
- var tslib_1 = require("tslib");
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("./evaluationSchemas"), exports);
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