@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.
- package/README.md +13 -15
- package/activeRecord.cjs +1 -1
- package/activeRecord.d.cts +26 -0
- package/activeRecord.js +1 -1
- package/apiKey.d.cts +48 -0
- package/base64Url.d.cts +4 -0
- package/cache/cache.d.cts +17 -0
- package/cache/cookieCache.d.cts +22 -0
- package/cache/fallbackCache.d.cts +11 -0
- package/cache/inMemoryCache.d.cts +11 -0
- package/cache/index.cjs +5 -5
- package/cache/index.d.cts +4 -0
- package/cache/index.js +4 -4
- package/cache/localStorageCache.d.cts +19 -0
- package/channel/channel.cjs +1 -1
- package/channel/channel.d.cts +24 -0
- package/channel/channel.js +1 -1
- package/channel/encodedChannel.d.cts +12 -0
- package/channel/guaranteedChannel.cjs +2 -2
- package/channel/guaranteedChannel.d.cts +33 -0
- package/channel/guaranteedChannel.js +2 -2
- package/channel/httpBeaconChannel.cjs +5 -5
- package/channel/httpBeaconChannel.d.cts +26 -0
- package/channel/httpBeaconChannel.js +5 -5
- package/channel/index.cjs +8 -8
- package/channel/index.d.cts +12 -0
- package/channel/index.js +7 -7
- package/channel/queuedChannel.cjs +7 -3
- package/channel/queuedChannel.d.cts +21 -0
- package/channel/queuedChannel.js +7 -3
- package/channel/retryChannel.cjs +2 -2
- package/channel/retryChannel.d.cts +21 -0
- package/channel/retryChannel.js +2 -2
- package/channel/sandboxChannel.cjs +1 -1
- package/channel/sandboxChannel.d.cts +15 -0
- package/channel/sandboxChannel.js +1 -1
- package/cid/assigner.d.cts +5 -0
- package/cid/cachedAssigner.cjs +1 -1
- package/cid/cachedAssigner.d.cts +17 -0
- package/cid/cachedAssigner.js +1 -1
- package/cid/fixedAssigner.d.cts +9 -0
- package/cid/index.cjs +5 -5
- package/cid/index.d.cts +6 -0
- package/cid/index.js +4 -4
- package/cid/remoteAssigner.cjs +3 -3
- package/cid/remoteAssigner.d.cts +13 -0
- package/cid/remoteAssigner.js +3 -3
- package/constants.cjs +1 -1
- package/constants.d.cts +6 -0
- package/constants.d.ts +2 -2
- package/constants.js +1 -1
- package/container.cjs +18 -18
- package/container.d.cts +95 -0
- package/container.js +18 -18
- package/contentFetcher.cjs +4 -4
- package/contentFetcher.d.cts +69 -0
- package/contentFetcher.js +4 -4
- package/context.cjs +4 -4
- package/context.d.cts +36 -0
- package/context.js +4 -4
- package/error.d.cts +4 -0
- package/evaluator.cjs +5 -5
- package/evaluator.d.cts +86 -0
- package/evaluator.js +5 -5
- package/eventManager.d.cts +21 -0
- package/eventSubjectProcessor.d.cts +22 -0
- package/facade/contentFetcherFacade.cjs +2 -2
- package/facade/contentFetcherFacade.d.cts +36 -0
- package/facade/contentFetcherFacade.js +2 -2
- package/facade/evaluatorFacade.cjs +2 -2
- package/facade/evaluatorFacade.d.cts +41 -0
- package/facade/evaluatorFacade.js +2 -2
- package/facade/index.cjs +7 -9
- package/facade/index.d.cts +29 -0
- package/facade/index.js +7 -8
- package/facade/sdkFacade.cjs +10 -10
- package/facade/sdkFacade.d.cts +86 -0
- package/facade/sdkFacade.js +10 -10
- package/facade/sessionFacade.cjs +1 -1
- package/facade/sessionFacade.d.cts +22 -0
- package/facade/sessionFacade.js +1 -1
- package/facade/sessionPatch.cjs +1 -1
- package/facade/sessionPatch.d.cts +21 -0
- package/facade/sessionPatch.js +1 -1
- package/facade/trackerFacade.cjs +2 -2
- package/facade/trackerFacade.d.cts +25 -0
- package/facade/trackerFacade.js +2 -2
- package/facade/userFacade.cjs +1 -1
- package/facade/userFacade.d.cts +28 -0
- package/facade/userFacade.js +1 -1
- package/facade/userPatch.cjs +1 -1
- package/facade/userPatch.d.cts +21 -0
- package/facade/userPatch.js +1 -1
- package/help.d.cts +5 -0
- package/index.cjs +2 -4
- package/index.d.cts +25 -0
- package/index.js +2 -3
- package/logging/consoleLogger.d.cts +13 -0
- package/logging/filteredLogger.d.cts +22 -0
- package/logging/index.cjs +6 -6
- package/logging/index.d.cts +5 -0
- package/logging/index.js +5 -5
- package/logging/logger.d.cts +11 -0
- package/logging/namespacedLogger.d.cts +14 -0
- package/logging/nullLogger.d.cts +10 -0
- package/namespacedStorage.d.cts +16 -0
- package/package.json +4 -1
- package/patch.d.cts +46 -0
- package/queue/capacityRestrictedQueue.d.cts +16 -0
- package/queue/inMemoryQueue.d.cts +15 -0
- package/queue/index.cjs +6 -6
- package/queue/index.d.cts +6 -0
- package/queue/index.js +5 -5
- package/queue/monitoredQueue.cjs +1 -1
- package/queue/monitoredQueue.d.cts +28 -0
- package/queue/monitoredQueue.js +1 -1
- package/queue/persistentQueue.d.cts +18 -0
- package/queue/queue.d.cts +11 -0
- package/retry/arbitraryPolicy.d.cts +10 -0
- package/retry/backoffPolicy.d.cts +26 -0
- package/retry/index.cjs +6 -6
- package/retry/index.d.cts +5 -0
- package/retry/index.js +5 -5
- package/retry/maxAttemptsPolicy.d.cts +11 -0
- package/retry/neverPolicy.d.cts +8 -0
- package/retry/policy.d.cts +6 -0
- package/schema/attributeSchema.cjs +1 -1
- package/schema/attributeSchema.d.cts +6 -0
- package/schema/attributeSchema.js +1 -1
- package/schema/contentFetcherSchemas.cjs +1 -1
- package/schema/contentFetcherSchemas.d.cts +6 -0
- package/schema/contentFetcherSchemas.js +1 -1
- package/schema/contentSchemas.cjs +1 -1
- package/schema/contentSchemas.d.cts +6 -0
- package/schema/contentSchemas.js +1 -1
- package/schema/contextSchemas.cjs +1 -1
- package/schema/contextSchemas.d.cts +6 -0
- package/schema/contextSchemas.js +1 -1
- package/schema/ecommerceSchemas.cjs +1 -1
- package/schema/ecommerceSchemas.d.cts +10 -0
- package/schema/ecommerceSchemas.js +1 -1
- package/schema/evaluatorSchemas.cjs +1 -1
- package/schema/evaluatorSchemas.d.cts +6 -0
- package/schema/evaluatorSchemas.js +1 -1
- package/schema/eventSchemas.cjs +4 -4
- package/schema/eventSchemas.d.cts +16 -0
- package/schema/eventSchemas.js +4 -4
- package/schema/index.cjs +22 -22
- package/schema/index.d.cts +14 -0
- package/schema/index.js +11 -11
- package/schema/loggerSchema.cjs +1 -1
- package/schema/loggerSchema.d.cts +6 -0
- package/schema/loggerSchema.js +1 -1
- package/schema/operationSchemas.cjs +2 -2
- package/schema/operationSchemas.d.cts +14 -0
- package/schema/operationSchemas.js +2 -2
- package/schema/sdkFacadeSchemas.cjs +4 -4
- package/schema/sdkFacadeSchemas.d.cts +6 -0
- package/schema/sdkFacadeSchemas.js +4 -4
- package/schema/sdkSchemas.cjs +3 -3
- package/schema/sdkSchemas.d.cts +8 -0
- package/schema/sdkSchemas.js +3 -3
- package/schema/tokenSchema.cjs +1 -1
- package/schema/tokenSchema.d.cts +6 -0
- package/schema/tokenSchema.js +1 -1
- package/schema/userSchema.cjs +2 -2
- package/schema/userSchema.d.cts +6 -0
- package/schema/userSchema.js +2 -2
- package/sdk.cjs +4 -4
- package/sdk.d.cts +69 -0
- package/sdk.js +4 -4
- package/sdkEvents.d.cts +15 -0
- package/sourceLocation.d.cts +14 -0
- package/tab.cjs +1 -1
- package/tab.d.cts +40 -0
- package/tab.js +1 -1
- package/token/cachedTokenStore.cjs +1 -1
- package/token/cachedTokenStore.d.cts +13 -0
- package/token/cachedTokenStore.js +1 -1
- package/token/inMemoryTokenStore.d.cts +11 -0
- package/token/index.cjs +5 -5
- package/token/index.d.cts +7 -0
- package/token/index.js +4 -4
- package/token/replicatedTokenStore.d.cts +13 -0
- package/token/token.cjs +3 -3
- package/token/token.d.cts +70 -0
- package/token/token.js +3 -3
- package/tracker.cjs +3 -3
- package/tracker.d.cts +82 -0
- package/tracker.js +3 -3
- package/trackingEvents.d.cts +309 -0
- package/transformer.d.cts +6 -0
- package/utilityTypes.d.cts +4 -0
- package/uuid.d.cts +3 -0
- package/validation/arrayType.cjs +2 -2
- package/validation/arrayType.d.cts +16 -0
- package/validation/arrayType.js +2 -2
- package/validation/booleanType.cjs +2 -2
- package/validation/booleanType.d.cts +9 -0
- package/validation/booleanType.js +2 -2
- package/validation/functionType.cjs +2 -2
- package/validation/functionType.d.cts +9 -0
- package/validation/functionType.js +2 -2
- package/validation/index.cjs +14 -14
- package/validation/index.d.cts +12 -0
- package/validation/index.js +12 -12
- package/validation/jsonType.cjs +2 -2
- package/validation/jsonType.d.cts +35 -0
- package/validation/jsonType.js +2 -2
- package/validation/mixedSchema.d.cts +7 -0
- package/validation/nullType.cjs +2 -2
- package/validation/nullType.d.cts +9 -0
- package/validation/nullType.js +2 -2
- package/validation/numberType.cjs +2 -2
- package/validation/numberType.d.cts +16 -0
- package/validation/numberType.js +2 -2
- package/validation/objectType.cjs +3 -3
- package/validation/objectType.d.cts +30 -0
- package/validation/objectType.js +3 -3
- package/validation/schema.d.cts +18 -0
- package/validation/stringType.cjs +2 -2
- package/validation/stringType.d.cts +24 -0
- package/validation/stringType.js +2 -2
- package/validation/unionType.cjs +2 -2
- package/validation/unionType.d.cts +11 -0
- package/validation/unionType.js +2 -2
- package/validation/violation.d.cts +4 -0
package/README.md
CHANGED
|
@@ -1,24 +1,22 @@
|
|
|
1
1
|
<p align="center">
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
2
|
+
<a href="https://croct.com" target="_blank">
|
|
3
|
+
<picture>
|
|
4
|
+
<source media="(min-width: 769px) and (prefers-color-scheme: light)" srcset="https://github.com/croct-tech/plug-js/blob/master/.github/assets/header-light.svg">
|
|
5
|
+
<source media="(min-width: 769px) and (prefers-color-scheme: dark)" srcset="https://github.com/croct-tech/plug-js/blob/master/.github/assets/header-dark.svg">
|
|
6
|
+
<source media="(max-width: 768px) and (prefers-color-scheme: dark)" srcset="https://github.com/croct-tech/plug-js/blob/master/.github/assets/header-dark-mobile.svg">
|
|
7
|
+
<source media="(max-width: 768px) and (prefers-color-scheme: light)" srcset="https://github.com/croct-tech/plug-js/blob/master/.github/assets/header-light-mobile.svg">
|
|
8
|
+
<img src="https://github.com/croct-tech/plug-js/blob/master/.github/assets/header-light-mobile.svg" alt="Croct JavaScript SDK" title="Croct JavaScript SDK" width="100%">
|
|
9
|
+
</picture>
|
|
10
|
+
</a>
|
|
11
|
+
<br/>
|
|
12
|
+
<strong>SDK JS</strong><br/>
|
|
13
|
+
The official Croct SDK for JavaScript.
|
|
9
14
|
</p>
|
|
15
|
+
|
|
10
16
|
<p align="center">
|
|
11
17
|
<a href="https://www.npmjs.com/package/@croct/sdk"><img alt="Version" src="https://img.shields.io/npm/v/@croct/sdk"/></a>
|
|
12
18
|
<a href="https://github.com/croct-tech/sdk-js/actions?query=workflow%3AValidations"><img alt="Build" src="https://github.com/croct-tech/sdk-js/workflows/Validations/badge.svg"/></a>
|
|
13
|
-
<a href="https://codeclimate.com/repos/5e7251b3172af05fe9000e27/maintainability"><img alt="Maintainability" src="https://api.codeclimate.com/v1/badges/c44df78a3ed891af11bb/maintainability"/></a>
|
|
14
19
|
<a href="https://codeclimate.com/repos/5e7251b3172af05fe9000e27/test_coverage"><img alt="Coverage" src="https://api.codeclimate.com/v1/badges/c44df78a3ed891af11bb/test_coverage"/></a>
|
|
15
|
-
<br />
|
|
16
|
-
<br />
|
|
17
|
-
<a href="https://github.com/croct-tech/sdk-js/releases">📦Releases</a>
|
|
18
|
-
·
|
|
19
|
-
<a href="https://github.com/croct-tech/sdk-js/issues/new?labels=bug&template=bug-report.md">🐞Report Bug</a>
|
|
20
|
-
·
|
|
21
|
-
<a href="https://github.com/croct-tech/sdk-js/issues/new?labels=enhancement&template=feature-request.md">✨Request Feature</a>
|
|
22
20
|
</p>
|
|
23
21
|
|
|
24
22
|
## Installation
|
package/activeRecord.cjs
CHANGED
|
@@ -20,7 +20,7 @@ __export(activeRecord_exports, {
|
|
|
20
20
|
ActiveRecord: () => ActiveRecord
|
|
21
21
|
});
|
|
22
22
|
module.exports = __toCommonJS(activeRecord_exports);
|
|
23
|
-
var import_schema = require(
|
|
23
|
+
var import_schema = require('./schema/index.cjs');
|
|
24
24
|
const operationSchema = {
|
|
25
25
|
add: import_schema.addOperation,
|
|
26
26
|
set: import_schema.setOperation,
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { JsonValue, JsonStructure } from '@croct/json';
|
|
2
|
+
import { Patch } from './patch.cjs';
|
|
3
|
+
import { TrackingEvent } from './trackingEvents.cjs';
|
|
4
|
+
import './utilityTypes.cjs';
|
|
5
|
+
|
|
6
|
+
declare abstract class ActiveRecord<T extends TrackingEvent> {
|
|
7
|
+
private readonly operations;
|
|
8
|
+
set(value: JsonValue): this;
|
|
9
|
+
set(property: string, value: JsonValue): this;
|
|
10
|
+
add(property: string, value: JsonValue): this;
|
|
11
|
+
combine(property: string, value: JsonValue): this;
|
|
12
|
+
merge(value: JsonStructure): this;
|
|
13
|
+
merge(property: string, value: JsonStructure): this;
|
|
14
|
+
increment(property: string, amount?: number): this;
|
|
15
|
+
decrement(property: string, amount?: number): this;
|
|
16
|
+
clear(property: string): this;
|
|
17
|
+
unset(property: string): this;
|
|
18
|
+
remove(property: string, value: JsonValue): this;
|
|
19
|
+
private pushOperation;
|
|
20
|
+
protected reset(): this;
|
|
21
|
+
abstract save(): Promise<T>;
|
|
22
|
+
protected isDirty(): boolean;
|
|
23
|
+
protected buildPatch(): Patch;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export { ActiveRecord };
|
package/activeRecord.js
CHANGED
package/apiKey.d.cts
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
type ParsedPrivateKey = {
|
|
2
|
+
algorithm: string;
|
|
3
|
+
encodedKey: string;
|
|
4
|
+
};
|
|
5
|
+
declare class ApiKey {
|
|
6
|
+
private static readonly IDENTIFIER_PATTERN;
|
|
7
|
+
private static readonly PRIVATE_KEY_PATTERN;
|
|
8
|
+
private static readonly ALGORITHMS;
|
|
9
|
+
private readonly identifier;
|
|
10
|
+
private readonly privateKey?;
|
|
11
|
+
private importedKey;
|
|
12
|
+
private constructor();
|
|
13
|
+
static from(apiKey: string | ApiKey): ApiKey;
|
|
14
|
+
static parse(apiKey: string): ApiKey;
|
|
15
|
+
static of(identifier: string, privateKey?: string): ApiKey;
|
|
16
|
+
getIdentifier(): string;
|
|
17
|
+
getIdentifierHash(): Promise<string>;
|
|
18
|
+
hasPrivateKey(): boolean;
|
|
19
|
+
getPrivateKey(): string;
|
|
20
|
+
sign(data: string): Promise<string>;
|
|
21
|
+
getSigningAlgorithm(): string;
|
|
22
|
+
private importKey;
|
|
23
|
+
private getParsedPrivateKey;
|
|
24
|
+
export(): string;
|
|
25
|
+
toString(): string;
|
|
26
|
+
/**
|
|
27
|
+
* Create an array buffer from a string.
|
|
28
|
+
*
|
|
29
|
+
* @see https://developers.google.com/web/updates/2012/06/How-to-convert-ArrayBuffer-to-and-from-String
|
|
30
|
+
*
|
|
31
|
+
* @param data The string to convert.
|
|
32
|
+
* @returns The array buffer.
|
|
33
|
+
*/
|
|
34
|
+
private static createByteArrayFromString;
|
|
35
|
+
private static createByteArrayFromHexString;
|
|
36
|
+
/**
|
|
37
|
+
* Convert an array buffer to a string.
|
|
38
|
+
*
|
|
39
|
+
* @see https://developers.google.com/web/updates/2012/06/How-to-convert-ArrayBuffer-to-and-from-String
|
|
40
|
+
*
|
|
41
|
+
* @param buffer The buffer to convert.
|
|
42
|
+
* @returns The string.
|
|
43
|
+
*/
|
|
44
|
+
private static convertBufferToString;
|
|
45
|
+
private static convertBufferToHexString;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export { ApiKey, type ParsedPrivateKey };
|
package/base64Url.d.cts
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
interface Cache {
|
|
2
|
+
get(): string | null;
|
|
3
|
+
put(value: string): void;
|
|
4
|
+
clear(): void;
|
|
5
|
+
}
|
|
6
|
+
interface CacheListener {
|
|
7
|
+
(value: string | null): void;
|
|
8
|
+
}
|
|
9
|
+
interface ObservableCache extends Cache {
|
|
10
|
+
addListener(listener: CacheListener): void;
|
|
11
|
+
removeListener(listener: CacheListener): void;
|
|
12
|
+
}
|
|
13
|
+
declare namespace ObservableCache {
|
|
14
|
+
function isObservable(cache: Cache): cache is ObservableCache;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export { type Cache, type CacheListener, ObservableCache };
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { Cache } from './cache.cjs';
|
|
2
|
+
|
|
3
|
+
type CookieCacheConfiguration = {
|
|
4
|
+
name: string;
|
|
5
|
+
secure?: boolean;
|
|
6
|
+
maxAge?: number;
|
|
7
|
+
domain?: string;
|
|
8
|
+
path?: string;
|
|
9
|
+
sameSite?: 'strict' | 'lax' | 'none';
|
|
10
|
+
};
|
|
11
|
+
declare class CookieCache implements Cache {
|
|
12
|
+
private readonly config;
|
|
13
|
+
constructor(config: CookieCacheConfiguration, defaultSecure?: boolean);
|
|
14
|
+
get(): string | null;
|
|
15
|
+
put(value: string): void;
|
|
16
|
+
clear(): void;
|
|
17
|
+
private static serializeCookie;
|
|
18
|
+
private static encode;
|
|
19
|
+
private static decode;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export { CookieCache, type CookieCacheConfiguration };
|
package/cache/index.cjs
CHANGED
|
@@ -23,14 +23,14 @@ __export(cache_exports, {
|
|
|
23
23
|
LocalStorageCache: () => import_localStorageCache.LocalStorageCache
|
|
24
24
|
});
|
|
25
25
|
module.exports = __toCommonJS(cache_exports);
|
|
26
|
-
__reExport(cache_exports, require(
|
|
27
|
-
var import_fallbackCache = require(
|
|
28
|
-
var import_inMemoryCache = require(
|
|
29
|
-
var import_localStorageCache = require(
|
|
26
|
+
__reExport(cache_exports, require('./cache.cjs'), module.exports);
|
|
27
|
+
var import_fallbackCache = require('./fallbackCache.cjs');
|
|
28
|
+
var import_inMemoryCache = require('./inMemoryCache.cjs');
|
|
29
|
+
var import_localStorageCache = require('./localStorageCache.cjs');
|
|
30
30
|
// Annotate the CommonJS export names for ESM import in node:
|
|
31
31
|
0 && (module.exports = {
|
|
32
32
|
FallbackCache,
|
|
33
33
|
InMemoryCache,
|
|
34
34
|
LocalStorageCache,
|
|
35
|
-
...require(
|
|
35
|
+
...require('./cache.cjs')
|
|
36
36
|
});
|
package/cache/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
export * from "./cache";
|
|
2
|
-
import { FallbackCache } from "./fallbackCache";
|
|
3
|
-
import { InMemoryCache } from "./inMemoryCache";
|
|
4
|
-
import { LocalStorageCache } from "./localStorageCache";
|
|
1
|
+
export * from "./cache.js";
|
|
2
|
+
import { FallbackCache } from "./fallbackCache.js";
|
|
3
|
+
import { InMemoryCache } from "./inMemoryCache.js";
|
|
4
|
+
import { LocalStorageCache } from "./localStorageCache.js";
|
|
5
5
|
export {
|
|
6
6
|
FallbackCache,
|
|
7
7
|
InMemoryCache,
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { ObservableCache, CacheListener } from './cache.cjs';
|
|
2
|
+
|
|
3
|
+
declare class LocalStorageCache implements ObservableCache {
|
|
4
|
+
private readonly storage;
|
|
5
|
+
private readonly key;
|
|
6
|
+
private value;
|
|
7
|
+
private readonly listeners;
|
|
8
|
+
constructor(storage: Storage, key: string);
|
|
9
|
+
static autoSync(cache: LocalStorageCache): (() => void);
|
|
10
|
+
get(): string | null;
|
|
11
|
+
put(value: string): void;
|
|
12
|
+
clear(): void;
|
|
13
|
+
addListener(listener: CacheListener): void;
|
|
14
|
+
removeListener(listener: CacheListener): void;
|
|
15
|
+
private notifyChange;
|
|
16
|
+
private sync;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export { LocalStorageCache };
|
package/channel/channel.cjs
CHANGED
|
@@ -20,7 +20,7 @@ __export(channel_exports, {
|
|
|
20
20
|
MessageDeliveryError: () => MessageDeliveryError
|
|
21
21
|
});
|
|
22
22
|
module.exports = __toCommonJS(channel_exports);
|
|
23
|
-
var import_error = require(
|
|
23
|
+
var import_error = require('../error.cjs');
|
|
24
24
|
class MessageDeliveryError extends Error {
|
|
25
25
|
constructor(message, retryable) {
|
|
26
26
|
super(message);
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
declare class MessageDeliveryError extends Error {
|
|
2
|
+
readonly retryable: boolean;
|
|
3
|
+
constructor(message: string, retryable: boolean);
|
|
4
|
+
static retryable(cause: unknown): MessageDeliveryError;
|
|
5
|
+
static nonRetryable(cause: unknown): MessageDeliveryError;
|
|
6
|
+
private static fromCause;
|
|
7
|
+
}
|
|
8
|
+
interface Closeable {
|
|
9
|
+
close(): Promise<void>;
|
|
10
|
+
}
|
|
11
|
+
interface OutputChannel<O> extends Closeable {
|
|
12
|
+
publish(message: O): Promise<void>;
|
|
13
|
+
}
|
|
14
|
+
type ChannelListener<T> = {
|
|
15
|
+
(message: T): void;
|
|
16
|
+
};
|
|
17
|
+
interface InputChannel<I> extends Closeable {
|
|
18
|
+
subscribe(listener: ChannelListener<I>): void;
|
|
19
|
+
unsubscribe(listener: ChannelListener<I>): void;
|
|
20
|
+
}
|
|
21
|
+
interface DuplexChannel<I, O> extends InputChannel<I>, OutputChannel<O> {
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export { type ChannelListener, type Closeable, type DuplexChannel, type InputChannel, MessageDeliveryError, type OutputChannel };
|
package/channel/channel.js
CHANGED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { OutputChannel } from './channel.cjs';
|
|
2
|
+
import { Transformer } from '../transformer.cjs';
|
|
3
|
+
|
|
4
|
+
declare class EncodedChannel<D, E> implements OutputChannel<D> {
|
|
5
|
+
private readonly encode;
|
|
6
|
+
private readonly channel;
|
|
7
|
+
constructor(channel: OutputChannel<E>, encoder: Transformer<D, E>);
|
|
8
|
+
publish(message: D): Promise<void>;
|
|
9
|
+
close(): Promise<void>;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export { EncodedChannel };
|
|
@@ -21,8 +21,8 @@ __export(guaranteedChannel_exports, {
|
|
|
21
21
|
TimeStamper: () => TimeStamper
|
|
22
22
|
});
|
|
23
23
|
module.exports = __toCommonJS(guaranteedChannel_exports);
|
|
24
|
-
var import_logging = require(
|
|
25
|
-
var import_channel = require(
|
|
24
|
+
var import_logging = require('../logging/index.cjs');
|
|
25
|
+
var import_channel = require('./channel.cjs');
|
|
26
26
|
class TimeStamper {
|
|
27
27
|
generate() {
|
|
28
28
|
return String(Date.now());
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { Logger } from '../logging/logger.cjs';
|
|
2
|
+
import { OutputChannel, DuplexChannel } from './channel.cjs';
|
|
3
|
+
|
|
4
|
+
type MessageStamper<M, S> = {
|
|
5
|
+
generate(message: M): S;
|
|
6
|
+
};
|
|
7
|
+
declare class TimeStamper implements MessageStamper<any, string> {
|
|
8
|
+
generate(): string;
|
|
9
|
+
}
|
|
10
|
+
type Envelope<M, S> = {
|
|
11
|
+
id: S;
|
|
12
|
+
message: M;
|
|
13
|
+
};
|
|
14
|
+
type Options = {
|
|
15
|
+
ackTimeout: number;
|
|
16
|
+
};
|
|
17
|
+
type Configuration<M, S> = Partial<Options> & {
|
|
18
|
+
channel: DuplexChannel<S, Envelope<M, S>>;
|
|
19
|
+
stamper: MessageStamper<M, S>;
|
|
20
|
+
logger?: Logger;
|
|
21
|
+
};
|
|
22
|
+
declare class GuaranteedChannel<M, S> implements OutputChannel<M> {
|
|
23
|
+
private readonly channel;
|
|
24
|
+
private readonly stamper;
|
|
25
|
+
private readonly logger;
|
|
26
|
+
private readonly options;
|
|
27
|
+
private closed;
|
|
28
|
+
constructor({ channel, logger, stamper, ...options }: Configuration<M, S>);
|
|
29
|
+
publish(message: M): Promise<void>;
|
|
30
|
+
close(): Promise<void>;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export { type Envelope, GuaranteedChannel, type MessageStamper, TimeStamper };
|
|
@@ -20,11 +20,11 @@ __export(httpBeaconChannel_exports, {
|
|
|
20
20
|
HttpBeaconChannel: () => HttpBeaconChannel
|
|
21
21
|
});
|
|
22
22
|
module.exports = __toCommonJS(httpBeaconChannel_exports);
|
|
23
|
-
var import_channel = require(
|
|
24
|
-
var import_logging = require(
|
|
25
|
-
var import_error = require(
|
|
26
|
-
var import_constants = require(
|
|
27
|
-
var import_help = require(
|
|
23
|
+
var import_channel = require('./channel.cjs');
|
|
24
|
+
var import_logging = require('../logging/index.cjs');
|
|
25
|
+
var import_error = require('../error.cjs');
|
|
26
|
+
var import_constants = require('../constants.cjs');
|
|
27
|
+
var import_help = require('../help.cjs');
|
|
28
28
|
class HttpBeaconChannel {
|
|
29
29
|
constructor({ logger = new import_logging.NullLogger(), ...configuration }) {
|
|
30
30
|
this.listeners = [];
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { DuplexChannel, ChannelListener } from './channel.cjs';
|
|
2
|
+
import { Envelope } from './guaranteedChannel.cjs';
|
|
3
|
+
import { Logger } from '../logging/logger.cjs';
|
|
4
|
+
import { CidAssigner } from '../cid/assigner.cjs';
|
|
5
|
+
|
|
6
|
+
type Configuration = {
|
|
7
|
+
appId: string;
|
|
8
|
+
endpointUrl: string;
|
|
9
|
+
cidAssigner: CidAssigner;
|
|
10
|
+
logger?: Logger;
|
|
11
|
+
};
|
|
12
|
+
declare class HttpBeaconChannel implements DuplexChannel<string, Envelope<string, string>> {
|
|
13
|
+
private readonly configuration;
|
|
14
|
+
private readonly logger;
|
|
15
|
+
private readonly listeners;
|
|
16
|
+
private closed;
|
|
17
|
+
constructor({ logger, ...configuration }: Configuration);
|
|
18
|
+
publish({ id: receiptId, message }: Envelope<string, string>): Promise<void>;
|
|
19
|
+
subscribe(listener: ChannelListener<string>): void;
|
|
20
|
+
unsubscribe(listener: ChannelListener<string>): void;
|
|
21
|
+
private notify;
|
|
22
|
+
close(): Promise<void>;
|
|
23
|
+
private static isRetryable;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export { type Configuration, HttpBeaconChannel };
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { MessageDeliveryError } from "./channel";
|
|
2
|
-
import { NullLogger } from "../logging";
|
|
3
|
-
import { formatMessage } from "../error";
|
|
4
|
-
import { CLIENT_LIBRARY } from "../constants";
|
|
5
|
-
import { Help } from "../help";
|
|
1
|
+
import { MessageDeliveryError } from "./channel.js";
|
|
2
|
+
import { NullLogger } from "../logging/index.js";
|
|
3
|
+
import { formatMessage } from "../error.js";
|
|
4
|
+
import { CLIENT_LIBRARY } from "../constants.js";
|
|
5
|
+
import { Help } from "../help.js";
|
|
6
6
|
class HttpBeaconChannel {
|
|
7
7
|
constructor({ logger = new NullLogger(), ...configuration }) {
|
|
8
8
|
this.listeners = [];
|
package/channel/index.cjs
CHANGED
|
@@ -26,13 +26,13 @@ __export(channel_exports, {
|
|
|
26
26
|
SandboxChannel: () => import_sandboxChannel.SandboxChannel
|
|
27
27
|
});
|
|
28
28
|
module.exports = __toCommonJS(channel_exports);
|
|
29
|
-
__reExport(channel_exports, require(
|
|
30
|
-
var import_encodedChannel = require(
|
|
31
|
-
var import_guaranteedChannel = require(
|
|
32
|
-
var import_queuedChannel = require(
|
|
33
|
-
var import_retryChannel = require(
|
|
34
|
-
var import_sandboxChannel = require(
|
|
35
|
-
var import_httpBeaconChannel = require(
|
|
29
|
+
__reExport(channel_exports, require('./channel.cjs'), module.exports);
|
|
30
|
+
var import_encodedChannel = require('./encodedChannel.cjs');
|
|
31
|
+
var import_guaranteedChannel = require('./guaranteedChannel.cjs');
|
|
32
|
+
var import_queuedChannel = require('./queuedChannel.cjs');
|
|
33
|
+
var import_retryChannel = require('./retryChannel.cjs');
|
|
34
|
+
var import_sandboxChannel = require('./sandboxChannel.cjs');
|
|
35
|
+
var import_httpBeaconChannel = require('./httpBeaconChannel.cjs');
|
|
36
36
|
// Annotate the CommonJS export names for ESM import in node:
|
|
37
37
|
0 && (module.exports = {
|
|
38
38
|
EncodedChannel,
|
|
@@ -41,5 +41,5 @@ var import_httpBeaconChannel = require("./httpBeaconChannel");
|
|
|
41
41
|
QueuedChannel,
|
|
42
42
|
RetryChannel,
|
|
43
43
|
SandboxChannel,
|
|
44
|
-
...require(
|
|
44
|
+
...require('./channel.cjs')
|
|
45
45
|
});
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export { ChannelListener, Closeable, DuplexChannel, InputChannel, MessageDeliveryError, OutputChannel } from './channel.cjs';
|
|
2
|
+
export { EncodedChannel } from './encodedChannel.cjs';
|
|
3
|
+
export { GuaranteedChannel } from './guaranteedChannel.cjs';
|
|
4
|
+
export { QueuedChannel } from './queuedChannel.cjs';
|
|
5
|
+
export { RetryChannel } from './retryChannel.cjs';
|
|
6
|
+
export { SandboxChannel } from './sandboxChannel.cjs';
|
|
7
|
+
export { HttpBeaconChannel } from './httpBeaconChannel.cjs';
|
|
8
|
+
import '../transformer.cjs';
|
|
9
|
+
import '../logging/logger.cjs';
|
|
10
|
+
import '../queue/queue.cjs';
|
|
11
|
+
import '../retry/policy.cjs';
|
|
12
|
+
import '../cid/assigner.cjs';
|
package/channel/index.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
export * from "./channel";
|
|
2
|
-
import { EncodedChannel } from "./encodedChannel";
|
|
3
|
-
import { GuaranteedChannel } from "./guaranteedChannel";
|
|
4
|
-
import { QueuedChannel } from "./queuedChannel";
|
|
5
|
-
import { RetryChannel } from "./retryChannel";
|
|
6
|
-
import { SandboxChannel } from "./sandboxChannel";
|
|
7
|
-
import { HttpBeaconChannel } from "./httpBeaconChannel";
|
|
1
|
+
export * from "./channel.js";
|
|
2
|
+
import { EncodedChannel } from "./encodedChannel.js";
|
|
3
|
+
import { GuaranteedChannel } from "./guaranteedChannel.js";
|
|
4
|
+
import { QueuedChannel } from "./queuedChannel.js";
|
|
5
|
+
import { RetryChannel } from "./retryChannel.js";
|
|
6
|
+
import { SandboxChannel } from "./sandboxChannel.js";
|
|
7
|
+
import { HttpBeaconChannel } from "./httpBeaconChannel.js";
|
|
8
8
|
export {
|
|
9
9
|
EncodedChannel,
|
|
10
10
|
GuaranteedChannel,
|
|
@@ -20,8 +20,8 @@ __export(queuedChannel_exports, {
|
|
|
20
20
|
QueuedChannel: () => QueuedChannel
|
|
21
21
|
});
|
|
22
22
|
module.exports = __toCommonJS(queuedChannel_exports);
|
|
23
|
-
var import_channel = require(
|
|
24
|
-
var import_logging = require(
|
|
23
|
+
var import_channel = require('./channel.cjs');
|
|
24
|
+
var import_logging = require('../logging/index.cjs');
|
|
25
25
|
class QueuedChannel {
|
|
26
26
|
constructor(channel, queue, logger) {
|
|
27
27
|
this.closed = false;
|
|
@@ -57,7 +57,11 @@ class QueuedChannel {
|
|
|
57
57
|
dequeue() {
|
|
58
58
|
this.logger.debug("Dequeuing message...");
|
|
59
59
|
this.logger.debug(`Queue length: ${Math.max(0, this.queue.length() - 1)}`);
|
|
60
|
-
this.queue.
|
|
60
|
+
if (this.queue.length() === 0) {
|
|
61
|
+
this.logger.debug("Queue unexpectedly empty, possibly due to concurrent modification.");
|
|
62
|
+
} else {
|
|
63
|
+
this.queue.shift();
|
|
64
|
+
}
|
|
61
65
|
}
|
|
62
66
|
requeue() {
|
|
63
67
|
if (this.closed) {
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { OutputChannel } from './channel.cjs';
|
|
2
|
+
import { Queue } from '../queue/queue.cjs';
|
|
3
|
+
import { Logger } from '../logging/logger.cjs';
|
|
4
|
+
|
|
5
|
+
declare class QueuedChannel<T> implements OutputChannel<T> {
|
|
6
|
+
private readonly channel;
|
|
7
|
+
private readonly queue;
|
|
8
|
+
private readonly logger;
|
|
9
|
+
private pending?;
|
|
10
|
+
private closed;
|
|
11
|
+
constructor(channel: OutputChannel<T>, queue: Queue<T>, logger?: Logger);
|
|
12
|
+
flush(): Promise<void>;
|
|
13
|
+
publish(message: T): Promise<void>;
|
|
14
|
+
private enqueue;
|
|
15
|
+
private dequeue;
|
|
16
|
+
private requeue;
|
|
17
|
+
private chainNext;
|
|
18
|
+
close(): Promise<void>;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export { QueuedChannel };
|
package/channel/queuedChannel.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { MessageDeliveryError } from "./channel";
|
|
2
|
-
import { NullLogger } from "../logging";
|
|
1
|
+
import { MessageDeliveryError } from "./channel.js";
|
|
2
|
+
import { NullLogger } from "../logging/index.js";
|
|
3
3
|
class QueuedChannel {
|
|
4
4
|
constructor(channel, queue, logger) {
|
|
5
5
|
this.closed = false;
|
|
@@ -35,7 +35,11 @@ class QueuedChannel {
|
|
|
35
35
|
dequeue() {
|
|
36
36
|
this.logger.debug("Dequeuing message...");
|
|
37
37
|
this.logger.debug(`Queue length: ${Math.max(0, this.queue.length() - 1)}`);
|
|
38
|
-
this.queue.
|
|
38
|
+
if (this.queue.length() === 0) {
|
|
39
|
+
this.logger.debug("Queue unexpectedly empty, possibly due to concurrent modification.");
|
|
40
|
+
} else {
|
|
41
|
+
this.queue.shift();
|
|
42
|
+
}
|
|
39
43
|
}
|
|
40
44
|
requeue() {
|
|
41
45
|
if (this.closed) {
|
package/channel/retryChannel.cjs
CHANGED
|
@@ -20,8 +20,8 @@ __export(retryChannel_exports, {
|
|
|
20
20
|
RetryChannel: () => RetryChannel
|
|
21
21
|
});
|
|
22
22
|
module.exports = __toCommonJS(retryChannel_exports);
|
|
23
|
-
var import_channel = require(
|
|
24
|
-
var import_logging = require(
|
|
23
|
+
var import_channel = require('./channel.cjs');
|
|
24
|
+
var import_logging = require('../logging/index.cjs');
|
|
25
25
|
class RetryChannel {
|
|
26
26
|
constructor({ channel, retryPolicy, logger }) {
|
|
27
27
|
this.closed = false;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { OutputChannel } from './channel.cjs';
|
|
2
|
+
import { Logger } from '../logging/logger.cjs';
|
|
3
|
+
import { RetryPolicy } from '../retry/policy.cjs';
|
|
4
|
+
|
|
5
|
+
type Configuration<T> = {
|
|
6
|
+
channel: OutputChannel<T>;
|
|
7
|
+
retryPolicy: RetryPolicy<T>;
|
|
8
|
+
logger?: Logger;
|
|
9
|
+
};
|
|
10
|
+
declare class RetryChannel<T> implements OutputChannel<T> {
|
|
11
|
+
private readonly channel;
|
|
12
|
+
private readonly retryPolicy;
|
|
13
|
+
private readonly logger;
|
|
14
|
+
private closed;
|
|
15
|
+
constructor({ channel, retryPolicy, logger }: Configuration<T>);
|
|
16
|
+
publish(message: T): Promise<void>;
|
|
17
|
+
retry(message: T, error: unknown): Promise<void>;
|
|
18
|
+
close(): Promise<void>;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export { RetryChannel };
|
package/channel/retryChannel.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { MessageDeliveryError } from "./channel";
|
|
2
|
-
import { NullLogger } from "../logging";
|
|
1
|
+
import { MessageDeliveryError } from "./channel.js";
|
|
2
|
+
import { NullLogger } from "../logging/index.js";
|
|
3
3
|
class RetryChannel {
|
|
4
4
|
constructor({ channel, retryPolicy, logger }) {
|
|
5
5
|
this.closed = false;
|
|
@@ -20,7 +20,7 @@ __export(sandboxChannel_exports, {
|
|
|
20
20
|
SandboxChannel: () => SandboxChannel
|
|
21
21
|
});
|
|
22
22
|
module.exports = __toCommonJS(sandboxChannel_exports);
|
|
23
|
-
var import_channel = require(
|
|
23
|
+
var import_channel = require('./channel.cjs');
|
|
24
24
|
class SandboxChannel {
|
|
25
25
|
constructor() {
|
|
26
26
|
this.listeners = [];
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { DuplexChannel, ChannelListener } from './channel.cjs';
|
|
2
|
+
|
|
3
|
+
declare class SandboxChannel<I, O> implements DuplexChannel<I, O> {
|
|
4
|
+
private readonly listeners;
|
|
5
|
+
readonly messages: O[];
|
|
6
|
+
private closed;
|
|
7
|
+
publish(message: O): Promise<void>;
|
|
8
|
+
notify(message: I): void;
|
|
9
|
+
subscribe(listener: ChannelListener<I>): void;
|
|
10
|
+
unsubscribe(listener: ChannelListener<I>): void;
|
|
11
|
+
close(): Promise<void>;
|
|
12
|
+
isClosed(): boolean;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export { SandboxChannel };
|