Skip to content

Commit

Permalink
test(contracts): fix types in contracts
Browse files Browse the repository at this point in the history
  • Loading branch information
parfeon committed Oct 31, 2024
1 parent 96e10ff commit 0f0648f
Show file tree
Hide file tree
Showing 16 changed files with 755 additions and 9,746 deletions.
5 changes: 2 additions & 3 deletions lib/core/components/base64_codec.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
* @internal
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.encode = exports.decode = void 0;
exports.decode = decode;
exports.encode = encode;
const BASE64_CHARMAP = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';
/**
* Decode a Base64 encoded string.
Expand Down Expand Up @@ -54,7 +55,6 @@ function decode(paddedInput) {
}
return data;
}
exports.decode = decode;
/**
* Encode `ArrayBuffer` as a Base64 encoded string.
*
Expand Down Expand Up @@ -102,4 +102,3 @@ function encode(input) {
}
return base64;
}
exports.encode = encode;
3 changes: 1 addition & 2 deletions lib/core/components/stringify_buffer_keys.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* @internal
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.stringifyBufferKeys = void 0;
exports.stringifyBufferKeys = stringifyBufferKeys;
/**
* Re-map CBOR object keys from potentially C buffer strings to actual strings.
*
Expand Down Expand Up @@ -39,4 +39,3 @@ function stringifyBufferKeys(obj) {
});
return normalizedObject;
}
exports.stringifyBufferKeys = stringifyBufferKeys;
2 changes: 2 additions & 0 deletions lib/core/components/token_manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,8 @@ class TokenManager {
* @param permissions - Bit-encoded resource permissions.
*
* @returns Human-readable resource permissions.
*
* @internal
*/
extractPermissions(permissions) {
const permissionsResult = {
Expand Down
4 changes: 2 additions & 2 deletions lib/errors/pubnub-error.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.createValidationError = exports.PubNubError = void 0;
exports.PubNubError = void 0;
exports.createValidationError = createValidationError;
const categories_1 = __importDefault(require("../core/constants/categories"));
/**
* PubNub operation error.
Expand Down Expand Up @@ -60,4 +61,3 @@ function createError(errorPayload) {
function createValidationError(message, statusCode) {
return createError(Object.assign({ message }, (statusCode !== undefined ? { statusCode } : {})));
}
exports.createValidationError = createValidationError;
7 changes: 3 additions & 4 deletions lib/event-engine/core/types.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@
* @internal
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.createManagedEffect = exports.createEffect = exports.createEvent = void 0;
exports.createEvent = createEvent;
exports.createEffect = createEffect;
exports.createManagedEffect = createManagedEffect;
/**
* Create and configure event engine event.
*
Expand All @@ -21,7 +23,6 @@ function createEvent(type, fn) {
creator.type = type;
return creator;
}
exports.createEvent = createEvent;
/**
* Create and configure short-term effect invocation.
*
Expand All @@ -34,7 +35,6 @@ function createEffect(type, fn) {
creator.type = type;
return creator;
}
exports.createEffect = createEffect;
/**
* Create and configure long-running effect invocation.
*
Expand All @@ -48,4 +48,3 @@ function createManagedEffect(type, fn) {
creator.cancel = { type: 'CANCEL', payload: type, managed: false };
return creator;
}
exports.createManagedEffect = createManagedEffect;
10 changes: 5 additions & 5 deletions lib/event-engine/dispatcher.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ class EventEngineDispatcher extends core_1.Dispatcher {
}
}
})));
this.on(effects.receiveMessages.type, (0, core_1.asyncHandler)((payload_2, abortSignal_2, _b) => __awaiter(this, [payload_2, abortSignal_2, _b], void 0, function* (payload, abortSignal, { receiveMessages, config }) {
this.on(effects.receiveMessages.type, (0, core_1.asyncHandler)((payload_1, abortSignal_1, _a) => __awaiter(this, [payload_1, abortSignal_1, _a], void 0, function* (payload, abortSignal, { receiveMessages, config }) {
abortSignal.throwIfAborted();
try {
const result = yield receiveMessages({
Expand All @@ -92,15 +92,15 @@ class EventEngineDispatcher extends core_1.Dispatcher {
}
}
})));
this.on(effects.emitMessages.type, (0, core_1.asyncHandler)((payload_3, _1, _c) => __awaiter(this, [payload_3, _1, _c], void 0, function* (payload, _, { emitMessages }) {
this.on(effects.emitMessages.type, (0, core_1.asyncHandler)((payload_1, _1, _a) => __awaiter(this, [payload_1, _1, _a], void 0, function* (payload, _, { emitMessages }) {
if (payload.length > 0) {
emitMessages(payload);
}
})));
this.on(effects.emitStatus.type, (0, core_1.asyncHandler)((payload_4, _2, _d) => __awaiter(this, [payload_4, _2, _d], void 0, function* (payload, _, { emitStatus }) {
this.on(effects.emitStatus.type, (0, core_1.asyncHandler)((payload_1, _1, _a) => __awaiter(this, [payload_1, _1, _a], void 0, function* (payload, _, { emitStatus }) {
emitStatus(payload);
})));
this.on(effects.receiveReconnect.type, (0, core_1.asyncHandler)((payload_5, abortSignal_3, _e) => __awaiter(this, [payload_5, abortSignal_3, _e], void 0, function* (payload, abortSignal, { receiveMessages, delay, config }) {
this.on(effects.receiveReconnect.type, (0, core_1.asyncHandler)((payload_1, abortSignal_1, _a) => __awaiter(this, [payload_1, abortSignal_1, _a], void 0, function* (payload, abortSignal, { receiveMessages, delay, config }) {
if (config.retryConfiguration && config.retryConfiguration.shouldRetry(payload.reason, payload.attempts)) {
abortSignal.throwIfAborted();
yield delay(config.retryConfiguration.getDelay(payload.attempts, payload.reason));
Expand Down Expand Up @@ -130,7 +130,7 @@ class EventEngineDispatcher extends core_1.Dispatcher {
: 'Unable to complete subscribe messages receive.')));
}
})));
this.on(effects.handshakeReconnect.type, (0, core_1.asyncHandler)((payload_6, abortSignal_4, _f) => __awaiter(this, [payload_6, abortSignal_4, _f], void 0, function* (payload, abortSignal, { handshake, delay, presenceState, config }) {
this.on(effects.handshakeReconnect.type, (0, core_1.asyncHandler)((payload_1, abortSignal_1, _a) => __awaiter(this, [payload_1, abortSignal_1, _a], void 0, function* (payload, abortSignal, { handshake, delay, presenceState, config }) {
if (config.retryConfiguration && config.retryConfiguration.shouldRetry(payload.reason, payload.attempts)) {
abortSignal.throwIfAborted();
yield delay(config.retryConfiguration.getDelay(payload.attempts, payload.reason));
Expand Down
12 changes: 6 additions & 6 deletions lib/event-engine/presence/dispatcher.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ class PresenceEventEngineDispatcher extends core_1.Dispatcher {
}
}
})));
this.on(effects.leave.type, (0, core_1.asyncHandler)((payload_2, _2, _b) => __awaiter(this, [payload_2, _2, _b], void 0, function* (payload, _, { leave, config }) {
this.on(effects.leave.type, (0, core_1.asyncHandler)((payload_1, _1, _a) => __awaiter(this, [payload_1, _1, _a], void 0, function* (payload, _, { leave, config }) {
if (!config.suppressLeaveEvents) {
try {
leave({
Expand All @@ -81,13 +81,13 @@ class PresenceEventEngineDispatcher extends core_1.Dispatcher {
catch (e) { }
}
})));
this.on(effects.wait.type, (0, core_1.asyncHandler)((_3, abortSignal_1, _c) => __awaiter(this, [_3, abortSignal_1, _c], void 0, function* (_, abortSignal, { heartbeatDelay }) {
this.on(effects.wait.type, (0, core_1.asyncHandler)((_1, abortSignal_1, _a) => __awaiter(this, [_1, abortSignal_1, _a], void 0, function* (_, abortSignal, { heartbeatDelay }) {
abortSignal.throwIfAborted();
yield heartbeatDelay();
abortSignal.throwIfAborted();
return engine.transition(events.timesUp());
})));
this.on(effects.delayedHeartbeat.type, (0, core_1.asyncHandler)((payload_3, abortSignal_2, _d) => __awaiter(this, [payload_3, abortSignal_2, _d], void 0, function* (payload, abortSignal, { heartbeat, retryDelay, presenceState, config }) {
this.on(effects.delayedHeartbeat.type, (0, core_1.asyncHandler)((payload_1, abortSignal_1, _a) => __awaiter(this, [payload_1, abortSignal_1, _a], void 0, function* (payload, abortSignal, { heartbeat, retryDelay, presenceState, config }) {
if (config.retryConfiguration && config.retryConfiguration.shouldRetry(payload.reason, payload.attempts)) {
abortSignal.throwIfAborted();
yield retryDelay(config.retryConfiguration.getDelay(payload.attempts, payload.reason));
Expand All @@ -108,9 +108,9 @@ class PresenceEventEngineDispatcher extends core_1.Dispatcher {
return engine.transition(events.heartbeatGiveup());
}
})));
this.on(effects.emitStatus.type, (0, core_1.asyncHandler)((payload_4, _4, _e) => __awaiter(this, [payload_4, _4, _e], void 0, function* (payload, _, { emitStatus, config }) {
var _f;
if (config.announceFailedHeartbeats && ((_f = payload === null || payload === void 0 ? void 0 : payload.status) === null || _f === void 0 ? void 0 : _f.error) === true) {
this.on(effects.emitStatus.type, (0, core_1.asyncHandler)((payload_1, _1, _a) => __awaiter(this, [payload_1, _1, _a], void 0, function* (payload, _, { emitStatus, config }) {
var _b;
if (config.announceFailedHeartbeats && ((_b = payload === null || payload === void 0 ? void 0 : payload.status) === null || _b === void 0 ? void 0 : _b.error) === true) {
emitStatus(payload.status);
}
else if (config.announceSuccessfulHeartbeats && payload.statusCode === 200) {
Expand Down
Loading

0 comments on commit 0f0648f

Please sign in to comment.