@croct/sdk 0.17.12 → 0.18.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 (227) hide show
  1. package/README.md +13 -15
  2. package/activeRecord.cjs +1 -1
  3. package/activeRecord.d.cts +26 -0
  4. package/activeRecord.js +1 -1
  5. package/apiKey.d.cts +48 -0
  6. package/base64Url.d.cts +4 -0
  7. package/cache/cache.d.cts +17 -0
  8. package/cache/cookieCache.d.cts +22 -0
  9. package/cache/fallbackCache.d.cts +11 -0
  10. package/cache/inMemoryCache.d.cts +11 -0
  11. package/cache/index.cjs +5 -5
  12. package/cache/index.d.cts +4 -0
  13. package/cache/index.js +4 -4
  14. package/cache/localStorageCache.d.cts +19 -0
  15. package/channel/channel.cjs +1 -1
  16. package/channel/channel.d.cts +24 -0
  17. package/channel/channel.js +1 -1
  18. package/channel/encodedChannel.d.cts +12 -0
  19. package/channel/guaranteedChannel.cjs +2 -2
  20. package/channel/guaranteedChannel.d.cts +33 -0
  21. package/channel/guaranteedChannel.js +2 -2
  22. package/channel/httpBeaconChannel.cjs +5 -5
  23. package/channel/httpBeaconChannel.d.cts +26 -0
  24. package/channel/httpBeaconChannel.js +5 -5
  25. package/channel/index.cjs +8 -8
  26. package/channel/index.d.cts +12 -0
  27. package/channel/index.js +7 -7
  28. package/channel/queuedChannel.cjs +7 -3
  29. package/channel/queuedChannel.d.cts +21 -0
  30. package/channel/queuedChannel.js +7 -3
  31. package/channel/retryChannel.cjs +2 -2
  32. package/channel/retryChannel.d.cts +21 -0
  33. package/channel/retryChannel.js +2 -2
  34. package/channel/sandboxChannel.cjs +1 -1
  35. package/channel/sandboxChannel.d.cts +15 -0
  36. package/channel/sandboxChannel.js +1 -1
  37. package/cid/assigner.d.cts +5 -0
  38. package/cid/cachedAssigner.cjs +1 -1
  39. package/cid/cachedAssigner.d.cts +17 -0
  40. package/cid/cachedAssigner.js +1 -1
  41. package/cid/fixedAssigner.d.cts +9 -0
  42. package/cid/index.cjs +5 -5
  43. package/cid/index.d.cts +6 -0
  44. package/cid/index.js +4 -4
  45. package/cid/remoteAssigner.cjs +3 -3
  46. package/cid/remoteAssigner.d.cts +13 -0
  47. package/cid/remoteAssigner.js +3 -3
  48. package/constants.cjs +1 -1
  49. package/constants.d.cts +6 -0
  50. package/constants.d.ts +2 -2
  51. package/constants.js +1 -1
  52. package/container.cjs +18 -18
  53. package/container.d.cts +95 -0
  54. package/container.js +18 -18
  55. package/contentFetcher.cjs +4 -4
  56. package/contentFetcher.d.cts +69 -0
  57. package/contentFetcher.js +4 -4
  58. package/context.cjs +4 -4
  59. package/context.d.cts +36 -0
  60. package/context.js +4 -4
  61. package/error.d.cts +4 -0
  62. package/evaluator.cjs +5 -5
  63. package/evaluator.d.cts +86 -0
  64. package/evaluator.js +5 -5
  65. package/eventManager.d.cts +21 -0
  66. package/eventSubjectProcessor.d.cts +22 -0
  67. package/facade/contentFetcherFacade.cjs +2 -2
  68. package/facade/contentFetcherFacade.d.cts +36 -0
  69. package/facade/contentFetcherFacade.js +2 -2
  70. package/facade/evaluatorFacade.cjs +2 -2
  71. package/facade/evaluatorFacade.d.cts +41 -0
  72. package/facade/evaluatorFacade.js +2 -2
  73. package/facade/index.cjs +7 -9
  74. package/facade/index.d.cts +29 -0
  75. package/facade/index.js +7 -8
  76. package/facade/sdkFacade.cjs +10 -10
  77. package/facade/sdkFacade.d.cts +86 -0
  78. package/facade/sdkFacade.js +10 -10
  79. package/facade/sessionFacade.cjs +1 -1
  80. package/facade/sessionFacade.d.cts +22 -0
  81. package/facade/sessionFacade.js +1 -1
  82. package/facade/sessionPatch.cjs +1 -1
  83. package/facade/sessionPatch.d.cts +21 -0
  84. package/facade/sessionPatch.js +1 -1
  85. package/facade/trackerFacade.cjs +2 -2
  86. package/facade/trackerFacade.d.cts +25 -0
  87. package/facade/trackerFacade.js +2 -2
  88. package/facade/userFacade.cjs +1 -1
  89. package/facade/userFacade.d.cts +28 -0
  90. package/facade/userFacade.js +1 -1
  91. package/facade/userPatch.cjs +1 -1
  92. package/facade/userPatch.d.cts +21 -0
  93. package/facade/userPatch.js +1 -1
  94. package/help.d.cts +5 -0
  95. package/index.cjs +2 -4
  96. package/index.d.cts +25 -0
  97. package/index.js +2 -3
  98. package/logging/consoleLogger.d.cts +13 -0
  99. package/logging/filteredLogger.d.cts +22 -0
  100. package/logging/index.cjs +6 -6
  101. package/logging/index.d.cts +5 -0
  102. package/logging/index.js +5 -5
  103. package/logging/logger.d.cts +11 -0
  104. package/logging/namespacedLogger.d.cts +14 -0
  105. package/logging/nullLogger.d.cts +10 -0
  106. package/namespacedStorage.d.cts +16 -0
  107. package/package.json +4 -1
  108. package/patch.d.cts +46 -0
  109. package/queue/capacityRestrictedQueue.d.cts +16 -0
  110. package/queue/inMemoryQueue.d.cts +15 -0
  111. package/queue/index.cjs +6 -6
  112. package/queue/index.d.cts +6 -0
  113. package/queue/index.js +5 -5
  114. package/queue/monitoredQueue.cjs +1 -1
  115. package/queue/monitoredQueue.d.cts +28 -0
  116. package/queue/monitoredQueue.js +1 -1
  117. package/queue/persistentQueue.d.cts +18 -0
  118. package/queue/queue.d.cts +11 -0
  119. package/retry/arbitraryPolicy.d.cts +10 -0
  120. package/retry/backoffPolicy.d.cts +26 -0
  121. package/retry/index.cjs +6 -6
  122. package/retry/index.d.cts +5 -0
  123. package/retry/index.js +5 -5
  124. package/retry/maxAttemptsPolicy.d.cts +11 -0
  125. package/retry/neverPolicy.d.cts +8 -0
  126. package/retry/policy.d.cts +6 -0
  127. package/schema/attributeSchema.cjs +1 -1
  128. package/schema/attributeSchema.d.cts +6 -0
  129. package/schema/attributeSchema.js +1 -1
  130. package/schema/contentFetcherSchemas.cjs +1 -1
  131. package/schema/contentFetcherSchemas.d.cts +6 -0
  132. package/schema/contentFetcherSchemas.js +1 -1
  133. package/schema/contentSchemas.cjs +1 -1
  134. package/schema/contentSchemas.d.cts +6 -0
  135. package/schema/contentSchemas.js +1 -1
  136. package/schema/contextSchemas.cjs +1 -1
  137. package/schema/contextSchemas.d.cts +6 -0
  138. package/schema/contextSchemas.js +1 -1
  139. package/schema/ecommerceSchemas.cjs +1 -1
  140. package/schema/ecommerceSchemas.d.cts +10 -0
  141. package/schema/ecommerceSchemas.js +1 -1
  142. package/schema/evaluatorSchemas.cjs +1 -1
  143. package/schema/evaluatorSchemas.d.cts +6 -0
  144. package/schema/evaluatorSchemas.js +1 -1
  145. package/schema/eventSchemas.cjs +4 -4
  146. package/schema/eventSchemas.d.cts +16 -0
  147. package/schema/eventSchemas.js +4 -4
  148. package/schema/index.cjs +22 -22
  149. package/schema/index.d.cts +14 -0
  150. package/schema/index.js +11 -11
  151. package/schema/loggerSchema.cjs +1 -1
  152. package/schema/loggerSchema.d.cts +6 -0
  153. package/schema/loggerSchema.js +1 -1
  154. package/schema/operationSchemas.cjs +2 -2
  155. package/schema/operationSchemas.d.cts +14 -0
  156. package/schema/operationSchemas.js +2 -2
  157. package/schema/sdkFacadeSchemas.cjs +4 -4
  158. package/schema/sdkFacadeSchemas.d.cts +6 -0
  159. package/schema/sdkFacadeSchemas.js +4 -4
  160. package/schema/sdkSchemas.cjs +3 -3
  161. package/schema/sdkSchemas.d.cts +8 -0
  162. package/schema/sdkSchemas.js +3 -3
  163. package/schema/tokenSchema.cjs +1 -1
  164. package/schema/tokenSchema.d.cts +6 -0
  165. package/schema/tokenSchema.js +1 -1
  166. package/schema/userSchema.cjs +2 -2
  167. package/schema/userSchema.d.cts +6 -0
  168. package/schema/userSchema.js +2 -2
  169. package/sdk.cjs +4 -4
  170. package/sdk.d.cts +69 -0
  171. package/sdk.js +4 -4
  172. package/sdkEvents.d.cts +15 -0
  173. package/sourceLocation.d.cts +14 -0
  174. package/tab.cjs +1 -1
  175. package/tab.d.cts +40 -0
  176. package/tab.js +1 -1
  177. package/token/cachedTokenStore.cjs +1 -1
  178. package/token/cachedTokenStore.d.cts +13 -0
  179. package/token/cachedTokenStore.js +1 -1
  180. package/token/inMemoryTokenStore.d.cts +11 -0
  181. package/token/index.cjs +5 -5
  182. package/token/index.d.cts +7 -0
  183. package/token/index.js +4 -4
  184. package/token/replicatedTokenStore.d.cts +13 -0
  185. package/token/token.cjs +3 -3
  186. package/token/token.d.cts +70 -0
  187. package/token/token.js +3 -3
  188. package/tracker.cjs +3 -3
  189. package/tracker.d.cts +82 -0
  190. package/tracker.js +3 -3
  191. package/trackingEvents.d.cts +309 -0
  192. package/transformer.d.cts +6 -0
  193. package/utilityTypes.d.cts +4 -0
  194. package/uuid.d.cts +3 -0
  195. package/validation/arrayType.cjs +2 -2
  196. package/validation/arrayType.d.cts +16 -0
  197. package/validation/arrayType.js +2 -2
  198. package/validation/booleanType.cjs +2 -2
  199. package/validation/booleanType.d.cts +9 -0
  200. package/validation/booleanType.js +2 -2
  201. package/validation/functionType.cjs +2 -2
  202. package/validation/functionType.d.cts +9 -0
  203. package/validation/functionType.js +2 -2
  204. package/validation/index.cjs +14 -14
  205. package/validation/index.d.cts +12 -0
  206. package/validation/index.js +12 -12
  207. package/validation/jsonType.cjs +2 -2
  208. package/validation/jsonType.d.cts +35 -0
  209. package/validation/jsonType.js +2 -2
  210. package/validation/mixedSchema.d.cts +7 -0
  211. package/validation/nullType.cjs +2 -2
  212. package/validation/nullType.d.cts +9 -0
  213. package/validation/nullType.js +2 -2
  214. package/validation/numberType.cjs +2 -2
  215. package/validation/numberType.d.cts +16 -0
  216. package/validation/numberType.js +2 -2
  217. package/validation/objectType.cjs +3 -3
  218. package/validation/objectType.d.cts +30 -0
  219. package/validation/objectType.js +3 -3
  220. package/validation/schema.d.cts +18 -0
  221. package/validation/stringType.cjs +2 -2
  222. package/validation/stringType.d.cts +24 -0
  223. package/validation/stringType.js +2 -2
  224. package/validation/unionType.cjs +2 -2
  225. package/validation/unionType.d.cts +11 -0
  226. package/validation/unionType.js +2 -2
  227. package/validation/violation.d.cts +4 -0
package/index.cjs CHANGED
@@ -17,16 +17,14 @@ var __copyProps = (to, from, except, desc) => {
17
17
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
18
  var index_exports = {};
19
19
  __export(index_exports, {
20
- Configuration: () => import_sdk.Configuration,
21
20
  Sdk: () => import_sdk.Sdk,
22
21
  VERSION: () => import_constants.VERSION
23
22
  });
24
23
  module.exports = __toCommonJS(index_exports);
25
- var import_constants = require("./constants");
26
- var import_sdk = require("./sdk");
24
+ var import_constants = require('./constants.cjs');
25
+ var import_sdk = require('./sdk.cjs');
27
26
  // Annotate the CommonJS export names for ESM import in node:
28
27
  0 && (module.exports = {
29
- Configuration,
30
28
  Sdk,
31
29
  VERSION
32
30
  });
package/index.d.cts ADDED
@@ -0,0 +1,25 @@
1
+ export { VERSION } from './constants.cjs';
2
+ export { Configuration, Sdk } from './sdk.cjs';
3
+ import './container.cjs';
4
+ import './logging/logger.cjs';
5
+ import './context.cjs';
6
+ import './token/token.cjs';
7
+ import '@croct/json';
8
+ import './apiKey.cjs';
9
+ import './cache/cache.cjs';
10
+ import './tab.cjs';
11
+ import './eventManager.cjs';
12
+ import './sdkEvents.cjs';
13
+ import './queue/monitoredQueue.cjs';
14
+ import './queue/queue.cjs';
15
+ import './tracker.cjs';
16
+ import './channel/channel.cjs';
17
+ import './retry/policy.cjs';
18
+ import './trackingEvents.cjs';
19
+ import './patch.cjs';
20
+ import './utilityTypes.cjs';
21
+ import './evaluator.cjs';
22
+ import './sourceLocation.cjs';
23
+ import './cid/assigner.cjs';
24
+ import './contentFetcher.cjs';
25
+ import './cache/cookieCache.cjs';
package/index.js CHANGED
@@ -1,7 +1,6 @@
1
- import { VERSION } from "./constants";
2
- import { Sdk, Configuration } from "./sdk";
1
+ import { VERSION } from "./constants.js";
2
+ import { Sdk } from "./sdk.js";
3
3
  export {
4
- Configuration,
5
4
  Sdk,
6
5
  VERSION
7
6
  };
@@ -0,0 +1,13 @@
1
+ import { Logger } from './logger.cjs';
2
+
3
+ declare class ConsoleLogger implements Logger {
4
+ private readonly namespace?;
5
+ constructor(namespace?: string);
6
+ get debug(): (message: string) => void;
7
+ get info(): (message: string) => void;
8
+ get warn(): (message: string) => void;
9
+ get error(): (message: string) => void;
10
+ private bind;
11
+ }
12
+
13
+ export { ConsoleLogger };
@@ -0,0 +1,22 @@
1
+ import { Logger } from './logger.cjs';
2
+
3
+ type LogLevel = 'debug' | 'info' | 'warn' | 'error';
4
+ type LogFilter = (level: LogLevel, message: string) => boolean;
5
+ type FilteredLoggerConfiguration = {
6
+ logger: Logger;
7
+ allowFilter: LogFilter;
8
+ };
9
+ declare class FilteredLogger implements Logger {
10
+ private readonly logger;
11
+ private readonly allowFilter;
12
+ constructor(configuration: FilteredLoggerConfiguration);
13
+ static include(logger: Logger, levels: LogLevel[]): Logger;
14
+ static exclude(logger: Logger, levels: LogLevel[]): FilteredLogger;
15
+ debug(message: string): void;
16
+ info(message: string): void;
17
+ warn(message: string): void;
18
+ error(message: string): void;
19
+ private log;
20
+ }
21
+
22
+ export { FilteredLogger, type FilteredLoggerConfiguration, type LogFilter, type LogLevel };
package/logging/index.cjs CHANGED
@@ -24,16 +24,16 @@ __export(logging_exports, {
24
24
  NullLogger: () => import_nullLogger.NullLogger
25
25
  });
26
26
  module.exports = __toCommonJS(logging_exports);
27
- __reExport(logging_exports, require("./logger"), module.exports);
28
- var import_consoleLogger = require("./consoleLogger");
29
- var import_namespacedLogger = require("./namespacedLogger");
30
- var import_nullLogger = require("./nullLogger");
31
- var import_filteredLogger = require("./filteredLogger");
27
+ __reExport(logging_exports, require('./logger.cjs'), module.exports);
28
+ var import_consoleLogger = require('./consoleLogger.cjs');
29
+ var import_namespacedLogger = require('./namespacedLogger.cjs');
30
+ var import_nullLogger = require('./nullLogger.cjs');
31
+ var import_filteredLogger = require('./filteredLogger.cjs');
32
32
  // Annotate the CommonJS export names for ESM import in node:
33
33
  0 && (module.exports = {
34
34
  ConsoleLogger,
35
35
  FilteredLogger,
36
36
  NamespacedLogger,
37
37
  NullLogger,
38
- ...require("./logger")
38
+ ...require('./logger.cjs')
39
39
  });
@@ -0,0 +1,5 @@
1
+ export { Logger, LoggerFactory } from './logger.cjs';
2
+ export { ConsoleLogger } from './consoleLogger.cjs';
3
+ export { NamespacedLogger } from './namespacedLogger.cjs';
4
+ export { NullLogger } from './nullLogger.cjs';
5
+ export { FilteredLogger } from './filteredLogger.cjs';
package/logging/index.js CHANGED
@@ -1,8 +1,8 @@
1
- export * from "./logger";
2
- import { ConsoleLogger } from "./consoleLogger";
3
- import { NamespacedLogger } from "./namespacedLogger";
4
- import { NullLogger } from "./nullLogger";
5
- import { FilteredLogger } from "./filteredLogger";
1
+ export * from "./logger.js";
2
+ import { ConsoleLogger } from "./consoleLogger.js";
3
+ import { NamespacedLogger } from "./namespacedLogger.js";
4
+ import { NullLogger } from "./nullLogger.js";
5
+ import { FilteredLogger } from "./filteredLogger.js";
6
6
  export {
7
7
  ConsoleLogger,
8
8
  FilteredLogger,
@@ -0,0 +1,11 @@
1
+ interface Logger {
2
+ debug(message: string): void;
3
+ info(message: string): void;
4
+ warn(message: string): void;
5
+ error(message: string): void;
6
+ }
7
+ interface LoggerFactory {
8
+ (namespace?: string): Logger;
9
+ }
10
+
11
+ export type { Logger, LoggerFactory };
@@ -0,0 +1,14 @@
1
+ import { Logger } from './logger.cjs';
2
+
3
+ declare class NamespacedLogger implements Logger {
4
+ private readonly logger;
5
+ private readonly namespace;
6
+ constructor(logger: Logger, namespace: string);
7
+ debug(message: string): void;
8
+ info(message: string): void;
9
+ warn(message: string): void;
10
+ error(message: string): void;
11
+ private format;
12
+ }
13
+
14
+ export { NamespacedLogger };
@@ -0,0 +1,10 @@
1
+ import { Logger } from './logger.cjs';
2
+
3
+ declare class NullLogger implements Logger {
4
+ debug(): void;
5
+ info(): void;
6
+ warn(): void;
7
+ error(): void;
8
+ }
9
+
10
+ export { NullLogger };
@@ -0,0 +1,16 @@
1
+ declare class NamespacedStorage implements Storage {
2
+ private readonly storage;
3
+ private readonly namespace;
4
+ constructor(storage: Storage, namespace: string);
5
+ get length(): number;
6
+ clear(): void;
7
+ getItem(key: string): string | null;
8
+ key(index: number): string | null;
9
+ removeItem(key: string): void;
10
+ setItem(key: string, value: string): void;
11
+ private getKeys;
12
+ private getPrefixedKey;
13
+ private getPrefix;
14
+ }
15
+
16
+ export { NamespacedStorage };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@croct/sdk",
3
- "version": "0.17.12",
3
+ "version": "0.18.1",
4
4
  "description": "Croct SDK for JavaScript.",
5
5
  "license": "MIT",
6
6
  "author": {
@@ -84,6 +84,7 @@
84
84
  "tslib": "^2.5.0"
85
85
  },
86
86
  "devDependencies": {
87
+ "esbuild-fix-imports-plugin": "^1.0.19",
87
88
  "@croct/eslint-plugin": "^0.7.0",
88
89
  "@types/jest": "^29.2.3",
89
90
  "eslint": "^8.57.0",
@@ -101,6 +102,8 @@
101
102
  "**/*.cjs",
102
103
  "**/*.mjs",
103
104
  "**/*.ts",
105
+ "**/*.mts",
106
+ "**/*.cts",
104
107
  "**/*.map"
105
108
  ],
106
109
  "browserslist": [
package/patch.d.cts ADDED
@@ -0,0 +1,46 @@
1
+ import { JsonValue, JsonStructure } from '@croct/json';
2
+
3
+ interface AbstractOperation {
4
+ type: string;
5
+ path: string;
6
+ }
7
+ interface UnsetOperation extends AbstractOperation {
8
+ type: 'unset';
9
+ }
10
+ interface ClearOperation extends AbstractOperation {
11
+ type: 'clear';
12
+ }
13
+ interface SetOperation extends AbstractOperation {
14
+ type: 'set';
15
+ value: JsonValue;
16
+ }
17
+ interface AddOperation extends AbstractOperation {
18
+ type: 'add';
19
+ value: JsonValue;
20
+ }
21
+ interface CombineOperation extends AbstractOperation {
22
+ type: 'combine';
23
+ value: JsonValue;
24
+ }
25
+ interface MergeOperation extends AbstractOperation {
26
+ type: 'merge';
27
+ value: JsonStructure;
28
+ }
29
+ interface IncrementOperation extends AbstractOperation {
30
+ type: 'increment';
31
+ value: JsonValue;
32
+ }
33
+ interface DecrementOperation extends AbstractOperation {
34
+ type: 'decrement';
35
+ value: JsonValue;
36
+ }
37
+ interface removeOperation extends AbstractOperation {
38
+ type: 'remove';
39
+ value: JsonValue;
40
+ }
41
+ type Operation = UnsetOperation | ClearOperation | AddOperation | SetOperation | CombineOperation | MergeOperation | IncrementOperation | DecrementOperation | removeOperation;
42
+ interface Patch {
43
+ operations: Operation[];
44
+ }
45
+
46
+ export type { Operation, Patch };
@@ -0,0 +1,16 @@
1
+ import { Queue } from './queue.cjs';
2
+
3
+ declare class CapacityRestrictedQueue<T> implements Queue<T> {
4
+ private readonly queue;
5
+ private readonly capacity;
6
+ constructor(queue: Queue<T>, capacity: number);
7
+ all(): T[];
8
+ getCapacity(): number;
9
+ isEmpty(): boolean;
10
+ length(): number;
11
+ peek(): T | null;
12
+ push(value: T): void;
13
+ shift(): T;
14
+ }
15
+
16
+ export { CapacityRestrictedQueue };
@@ -0,0 +1,15 @@
1
+ import { Queue } from './queue.cjs';
2
+
3
+ declare class InMemoryQueue<T> implements Queue<T> {
4
+ private queue;
5
+ constructor(...values: T[]);
6
+ all(): T[];
7
+ getCapacity(): number;
8
+ isEmpty(): boolean;
9
+ push(value: T): void;
10
+ peek(): T | null;
11
+ shift(): T;
12
+ length(): number;
13
+ }
14
+
15
+ export { InMemoryQueue };
package/queue/index.cjs CHANGED
@@ -24,16 +24,16 @@ __export(queue_exports, {
24
24
  PersistentQueue: () => import_persistentQueue.PersistentQueue
25
25
  });
26
26
  module.exports = __toCommonJS(queue_exports);
27
- __reExport(queue_exports, require("./queue"), module.exports);
28
- var import_capacityRestrictedQueue = require("./capacityRestrictedQueue");
29
- var import_inMemoryQueue = require("./inMemoryQueue");
30
- var import_monitoredQueue = require("./monitoredQueue");
31
- var import_persistentQueue = require("./persistentQueue");
27
+ __reExport(queue_exports, require('./queue.cjs'), module.exports);
28
+ var import_capacityRestrictedQueue = require('./capacityRestrictedQueue.cjs');
29
+ var import_inMemoryQueue = require('./inMemoryQueue.cjs');
30
+ var import_monitoredQueue = require('./monitoredQueue.cjs');
31
+ var import_persistentQueue = require('./persistentQueue.cjs');
32
32
  // Annotate the CommonJS export names for ESM import in node:
33
33
  0 && (module.exports = {
34
34
  CapacityRestrictedQueue,
35
35
  InMemoryQueue,
36
36
  MonitoredQueue,
37
37
  PersistentQueue,
38
- ...require("./queue")
38
+ ...require('./queue.cjs')
39
39
  });
@@ -0,0 +1,6 @@
1
+ export { Queue } from './queue.cjs';
2
+ export { CapacityRestrictedQueue } from './capacityRestrictedQueue.cjs';
3
+ export { InMemoryQueue } from './inMemoryQueue.cjs';
4
+ export { MonitoredQueue } from './monitoredQueue.cjs';
5
+ export { PersistentQueue } from './persistentQueue.cjs';
6
+ import '../logging/logger.cjs';
package/queue/index.js CHANGED
@@ -1,8 +1,8 @@
1
- export * from "./queue";
2
- import { CapacityRestrictedQueue } from "./capacityRestrictedQueue";
3
- import { InMemoryQueue } from "./inMemoryQueue";
4
- import { MonitoredQueue } from "./monitoredQueue";
5
- import { PersistentQueue } from "./persistentQueue";
1
+ export * from "./queue.js";
2
+ import { CapacityRestrictedQueue } from "./capacityRestrictedQueue.js";
3
+ import { InMemoryQueue } from "./inMemoryQueue.js";
4
+ import { MonitoredQueue } from "./monitoredQueue.js";
5
+ import { PersistentQueue } from "./persistentQueue.js";
6
6
  export {
7
7
  CapacityRestrictedQueue,
8
8
  InMemoryQueue,
@@ -20,7 +20,7 @@ __export(monitoredQueue_exports, {
20
20
  MonitoredQueue: () => MonitoredQueue
21
21
  });
22
22
  module.exports = __toCommonJS(monitoredQueue_exports);
23
- var import_logging = require("../logging");
23
+ var import_logging = require('../logging/index.cjs');
24
24
  class MonitoredQueue {
25
25
  constructor(queue, logger) {
26
26
  this.callbacks = {};
@@ -0,0 +1,28 @@
1
+ import { Queue } from './queue.cjs';
2
+ import { Logger } from '../logging/logger.cjs';
3
+
4
+ type QueueStatus = 'halfEmpty' | 'almostEmpty' | 'empty' | 'halfFull' | 'almostFull' | 'full';
5
+ type QueueCallback<T> = {
6
+ (queue: Queue<T>): void;
7
+ };
8
+ declare class MonitoredQueue<T> implements Queue<T> {
9
+ private readonly queue;
10
+ private readonly logger;
11
+ private readonly callbacks;
12
+ private status;
13
+ constructor(queue: Queue<T>, logger?: Logger);
14
+ all(): T[];
15
+ getCapacity(): number;
16
+ addCallback(status: QueueStatus, callback: QueueCallback<T>): void;
17
+ removeCallback(type: QueueStatus, callback: QueueCallback<T>): void;
18
+ private setStatus;
19
+ private report;
20
+ isEmpty(): boolean;
21
+ length(): number;
22
+ peek(): T | null;
23
+ push(value: T): void;
24
+ shift(): T;
25
+ private updateStatus;
26
+ }
27
+
28
+ export { MonitoredQueue, type QueueCallback, type QueueStatus };
@@ -1,4 +1,4 @@
1
- import { NullLogger } from "../logging";
1
+ import { NullLogger } from "../logging/index.js";
2
2
  class MonitoredQueue {
3
3
  constructor(queue, logger) {
4
4
  this.callbacks = {};
@@ -0,0 +1,18 @@
1
+ import { Queue } from './queue.cjs';
2
+
3
+ declare class PersistentQueue<T> implements Queue<T> {
4
+ private readonly storage;
5
+ private readonly key;
6
+ constructor(storage: Storage, key?: string);
7
+ all(): T[];
8
+ getCapacity(): number;
9
+ isEmpty(): boolean;
10
+ length(): number;
11
+ push(value: T): void;
12
+ peek(): T | null;
13
+ shift(): T;
14
+ private get queue();
15
+ private save;
16
+ }
17
+
18
+ export { PersistentQueue };
@@ -0,0 +1,11 @@
1
+ interface Queue<T> {
2
+ getCapacity(): number;
3
+ all(): T[];
4
+ push(value: T): void;
5
+ shift(): T;
6
+ peek(): T | null;
7
+ isEmpty(): boolean;
8
+ length(): number;
9
+ }
10
+
11
+ export type { Queue };
@@ -0,0 +1,10 @@
1
+ import { RetryPolicy } from './policy.cjs';
2
+
3
+ declare class ArbitraryPolicy<T> implements RetryPolicy<T> {
4
+ private readonly delays;
5
+ constructor(delays: number[]);
6
+ getDelay(attempt: number): number;
7
+ shouldRetry(): boolean;
8
+ }
9
+
10
+ export { ArbitraryPolicy };
@@ -0,0 +1,26 @@
1
+ import { RetryPolicy } from './policy.cjs';
2
+
3
+ type Options = {
4
+ minRetryDelay: number;
5
+ maxRetryDelay: number;
6
+ backoffFactor: number;
7
+ backoffJitter: number;
8
+ maxAttempts: number;
9
+ };
10
+ declare class BackoffPolicy<T> implements RetryPolicy<T> {
11
+ private readonly minRetryDelay;
12
+ private readonly maxRetryDelay;
13
+ private readonly backoffFactor;
14
+ private readonly backoffJitter;
15
+ private readonly maxAttempts;
16
+ constructor(options?: Partial<Options>);
17
+ /**
18
+ * Full Jitter algorithm
19
+ *
20
+ * @see https://www.awsarchitectureblog.com/2015/03/backoff.html
21
+ */
22
+ getDelay(attempt: number): number;
23
+ shouldRetry(attempt: number): boolean;
24
+ }
25
+
26
+ export { BackoffPolicy };
package/retry/index.cjs CHANGED
@@ -24,16 +24,16 @@ __export(retry_exports, {
24
24
  NeverPolicy: () => import_neverPolicy.NeverPolicy
25
25
  });
26
26
  module.exports = __toCommonJS(retry_exports);
27
- __reExport(retry_exports, require("./policy"), module.exports);
28
- var import_arbitraryPolicy = require("./arbitraryPolicy");
29
- var import_backoffPolicy = require("./backoffPolicy");
30
- var import_maxAttemptsPolicy = require("./maxAttemptsPolicy");
31
- var import_neverPolicy = require("./neverPolicy");
27
+ __reExport(retry_exports, require('./policy.cjs'), module.exports);
28
+ var import_arbitraryPolicy = require('./arbitraryPolicy.cjs');
29
+ var import_backoffPolicy = require('./backoffPolicy.cjs');
30
+ var import_maxAttemptsPolicy = require('./maxAttemptsPolicy.cjs');
31
+ var import_neverPolicy = require('./neverPolicy.cjs');
32
32
  // Annotate the CommonJS export names for ESM import in node:
33
33
  0 && (module.exports = {
34
34
  ArbitraryPolicy,
35
35
  BackoffPolicy,
36
36
  MaxAttemptsPolicy,
37
37
  NeverPolicy,
38
- ...require("./policy")
38
+ ...require('./policy.cjs')
39
39
  });
@@ -0,0 +1,5 @@
1
+ export { RetryPolicy } from './policy.cjs';
2
+ export { ArbitraryPolicy } from './arbitraryPolicy.cjs';
3
+ export { BackoffPolicy } from './backoffPolicy.cjs';
4
+ export { MaxAttemptsPolicy } from './maxAttemptsPolicy.cjs';
5
+ export { NeverPolicy } from './neverPolicy.cjs';
package/retry/index.js CHANGED
@@ -1,8 +1,8 @@
1
- export * from "./policy";
2
- import { ArbitraryPolicy } from "./arbitraryPolicy";
3
- import { BackoffPolicy } from "./backoffPolicy";
4
- import { MaxAttemptsPolicy } from "./maxAttemptsPolicy";
5
- import { NeverPolicy } from "./neverPolicy";
1
+ export * from "./policy.js";
2
+ import { ArbitraryPolicy } from "./arbitraryPolicy.js";
3
+ import { BackoffPolicy } from "./backoffPolicy.js";
4
+ import { MaxAttemptsPolicy } from "./maxAttemptsPolicy.js";
5
+ import { NeverPolicy } from "./neverPolicy.js";
6
6
  export {
7
7
  ArbitraryPolicy,
8
8
  BackoffPolicy,
@@ -0,0 +1,11 @@
1
+ import { RetryPolicy } from './policy.cjs';
2
+
3
+ declare class MaxAttemptsPolicy<T> implements RetryPolicy<T> {
4
+ private readonly maxAttempts;
5
+ private readonly delay;
6
+ constructor(delay: number, maxAttempts: number);
7
+ getDelay(): number;
8
+ shouldRetry(attempt: number): boolean;
9
+ }
10
+
11
+ export { MaxAttemptsPolicy };
@@ -0,0 +1,8 @@
1
+ import { RetryPolicy } from './policy.cjs';
2
+
3
+ declare class NeverPolicy<T> implements RetryPolicy<T> {
4
+ getDelay(): number;
5
+ shouldRetry(): boolean;
6
+ }
7
+
8
+ export { NeverPolicy };
@@ -0,0 +1,6 @@
1
+ interface RetryPolicy<T> {
2
+ shouldRetry(attempt: number, subject?: T, failure?: any): boolean;
3
+ getDelay(attempt: number): number;
4
+ }
5
+
6
+ export type { RetryPolicy };
@@ -20,7 +20,7 @@ __export(attributeSchema_exports, {
20
20
  attributeNameSchema: () => attributeNameSchema
21
21
  });
22
22
  module.exports = __toCommonJS(attributeSchema_exports);
23
- var import_validation = require("../validation");
23
+ var import_validation = require('../validation/index.cjs');
24
24
  const attributeNameSchema = new import_validation.StringType({
25
25
  maxLength: 50,
26
26
  format: "identifier"
@@ -0,0 +1,6 @@
1
+ import { StringType } from '../validation/stringType.cjs';
2
+ import '../validation/schema.cjs';
3
+
4
+ declare const attributeNameSchema: StringType;
5
+
6
+ export { attributeNameSchema };
@@ -1,4 +1,4 @@
1
- import { StringType } from "../validation";
1
+ import { StringType } from "../validation/index.js";
2
2
  const attributeNameSchema = new StringType({
3
3
  maxLength: 50,
4
4
  format: "identifier"
@@ -20,7 +20,7 @@ __export(contentFetcherSchemas_exports, {
20
20
  fetchOptionsSchema: () => fetchOptionsSchema
21
21
  });
22
22
  module.exports = __toCommonJS(contentFetcherSchemas_exports);
23
- var import_validation = require("../validation");
23
+ var import_validation = require('../validation/index.cjs');
24
24
  const fetchOptionsSchema = new import_validation.ObjectType({
25
25
  properties: {
26
26
  timeout: new import_validation.NumberType({
@@ -0,0 +1,6 @@
1
+ import { ObjectType } from '../validation/objectType.cjs';
2
+ import '../validation/schema.cjs';
3
+
4
+ declare const fetchOptionsSchema: ObjectType;
5
+
6
+ export { fetchOptionsSchema };
@@ -1,4 +1,4 @@
1
- import { ObjectType, NumberType, JsonObjectType, StringType, UnionType } from "../validation";
1
+ import { ObjectType, NumberType, JsonObjectType, StringType, UnionType } from "../validation/index.js";
2
2
  const fetchOptionsSchema = new ObjectType({
3
3
  properties: {
4
4
  timeout: new NumberType({
@@ -20,7 +20,7 @@ __export(contentSchemas_exports, {
20
20
  postDetails: () => postDetails
21
21
  });
22
22
  module.exports = __toCommonJS(contentSchemas_exports);
23
- var import_validation = require("../validation");
23
+ var import_validation = require('../validation/index.cjs');
24
24
  const postDetails = new import_validation.ObjectType({
25
25
  required: ["postId", "title", "publishTime"],
26
26
  properties: {
@@ -0,0 +1,6 @@
1
+ import { ObjectType } from '../validation/objectType.cjs';
2
+ import '../validation/schema.cjs';
3
+
4
+ declare const postDetails: ObjectType;
5
+
6
+ export { postDetails };
@@ -1,4 +1,4 @@
1
- import { ArrayType, StringType, ObjectType, NumberType } from "../validation";
1
+ import { ArrayType, StringType, ObjectType, NumberType } from "../validation/index.js";
2
2
  const postDetails = new ObjectType({
3
3
  required: ["postId", "title", "publishTime"],
4
4
  properties: {
@@ -20,7 +20,7 @@ __export(contextSchemas_exports, {
20
20
  tokenScopeSchema: () => tokenScopeSchema
21
21
  });
22
22
  module.exports = __toCommonJS(contextSchemas_exports);
23
- var import_validation = require("../validation");
23
+ var import_validation = require('../validation/index.cjs');
24
24
  const tokenScopeSchema = new import_validation.StringType({
25
25
  enumeration: ["global", "contextual", "isolated"]
26
26
  });
@@ -0,0 +1,6 @@
1
+ import { StringType } from '../validation/stringType.cjs';
2
+ import '../validation/schema.cjs';
3
+
4
+ declare const tokenScopeSchema: StringType;
5
+
6
+ export { tokenScopeSchema };
@@ -1,4 +1,4 @@
1
- import { StringType } from "../validation";
1
+ import { StringType } from "../validation/index.js";
2
2
  const tokenScopeSchema = new StringType({
3
3
  enumeration: ["global", "contextual", "isolated"]
4
4
  });