@cheep/transport
Advanced tools
Comparing version 1.3.4 to 1.3.5
{ | ||
"name": "@cheep/transport", | ||
"version": "1.3.4", | ||
"version": "1.3.5", | ||
"contributors": [ | ||
@@ -5,0 +5,0 @@ "Ezeki", |
@@ -1,18 +0,15 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const tslib_1 = require("tslib"); | ||
tslib_1.__exportStar(require("./lib/domain/normalizeError"), exports); | ||
tslib_1.__exportStar(require("./lib/memory.transport"), exports); | ||
tslib_1.__exportStar(require("./lib/metadataReducers/callStack.reducer"), exports); | ||
tslib_1.__exportStar(require("./lib/metadataReducers/createdAt.reducer"), exports); | ||
tslib_1.__exportStar(require("./lib/metadataReducers/transaction.reducer"), exports); | ||
tslib_1.__exportStar(require("./lib/metadataValidators/callStack.validator"), exports); | ||
tslib_1.__exportStar(require("./lib/metadataValidators/transactionDuration.validator"), exports); | ||
tslib_1.__exportStar(require("./lib/errors/remote.error"), exports); | ||
tslib_1.__exportStar(require("./lib/errors/rpcTimeout.error"), exports); | ||
tslib_1.__exportStar(require("./lib/transport"), exports); | ||
tslib_1.__exportStar(require("./lib/transport.base"), exports); | ||
tslib_1.__exportStar(require("./lib/constants"), exports); | ||
tslib_1.__exportStar(require("./lib/api/createTransportApi"), exports); | ||
tslib_1.__exportStar(require("./lib/api/createTransportHandler"), exports); | ||
export * from './lib/domain/normalizeError'; | ||
export * from './lib/memory.transport'; | ||
export * from './lib/metadataReducers/callStack.reducer'; | ||
export * from './lib/metadataReducers/createdAt.reducer'; | ||
export * from './lib/metadataReducers/transaction.reducer'; | ||
export * from './lib/metadataValidators/callStack.validator'; | ||
export * from './lib/metadataValidators/transactionDuration.validator'; | ||
export * from './lib/errors/remote.error'; | ||
export * from './lib/errors/rpcTimeout.error'; | ||
export * from './lib/transport'; | ||
export * from './lib/transport.base'; | ||
export * from './lib/constants'; | ||
export * from './lib/api/createTransportApi'; | ||
export * from './lib/api/createTransportHandler'; | ||
//# sourceMappingURL=index.js.map |
@@ -1,6 +0,3 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.createRouteBuilderProxy = void 0; | ||
const types_1 = require("./types"); | ||
function createRouteBuilderProxy(joinSymbol, path = []) { | ||
import { RouteVariableOperator } from './types'; | ||
export function createRouteBuilderProxy(joinSymbol, path = []) { | ||
return new Proxy(() => undefined, { | ||
@@ -15,3 +12,3 @@ get: (_, prop) => { | ||
const lastPathItem = path[path.length - 1]; | ||
if (lastPathItem === types_1.RouteVariableOperator) { | ||
if (lastPathItem === RouteVariableOperator) { | ||
return createRouteBuilderProxy(joinSymbol, [ | ||
@@ -29,3 +26,2 @@ ...path.slice(0, -1), | ||
} | ||
exports.createRouteBuilderProxy = createRouteBuilderProxy; | ||
//# sourceMappingURL=createRouteBuilderProxy.js.map |
@@ -1,6 +0,3 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.createTransportApi = void 0; | ||
const recursiveApiCaller_1 = require("./recursiveApiCaller"); | ||
function createTransportApi(transport, options, referrer) { | ||
import { recursiveApiCaller } from './recursiveApiCaller'; | ||
export function createTransportApi(transport, options, referrer) { | ||
const { joinSymbol = '.', metadata } = options !== null && options !== void 0 ? options : {}; | ||
@@ -22,7 +19,6 @@ return { | ||
} | ||
exports.createTransportApi = createTransportApi; | ||
function transportApi(transport, options) { | ||
const { joinSymbol = '.' } = options !== null && options !== void 0 ? options : {}; | ||
return recursiveApiCaller_1.recursiveApiCaller(transport, Object.assign(Object.assign({}, options), { joinSymbol })); | ||
return recursiveApiCaller(transport, Object.assign(Object.assign({}, options), { joinSymbol })); | ||
} | ||
//# sourceMappingURL=createTransportApi.js.map |
@@ -1,15 +0,12 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.createTransportHandler = void 0; | ||
const tslib_1 = require("tslib"); | ||
const createRouteBuilderProxy_1 = require("./createRouteBuilderProxy"); | ||
const createTransportApi_1 = require("./createTransportApi"); | ||
function createTransportHandler(transport, options) { | ||
import { __awaiter } from "tslib"; | ||
import { createRouteBuilderProxy } from './createRouteBuilderProxy'; | ||
import { createTransportApi } from './createTransportApi'; | ||
export function createTransportHandler(transport, options) { | ||
const { joinSymbol = '.' } = options !== null && options !== void 0 ? options : {}; | ||
function onHandler(routePick, handler) { | ||
var _a; | ||
const proxy = routePick(createRouteBuilderProxy_1.createRouteBuilderProxy(joinSymbol)); | ||
const proxy = routePick(createRouteBuilderProxy(joinSymbol)); | ||
const route = proxy(); | ||
const intermediateHandler = (msg) => tslib_1.__awaiter(this, void 0, void 0, function* () { | ||
const api = createTransportApi_1.createTransportApi(transport, options, { | ||
const intermediateHandler = (msg) => __awaiter(this, void 0, void 0, function* () { | ||
const api = createTransportApi(transport, options, { | ||
route: msg.route, | ||
@@ -31,3 +28,2 @@ metadata: msg.metadata, | ||
} | ||
exports.createTransportHandler = createTransportHandler; | ||
//# sourceMappingURL=createTransportHandler.js.map |
@@ -1,6 +0,3 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.recursiveApiCaller = void 0; | ||
const types_1 = require("./types"); | ||
function recursiveApiCaller(transport, options, | ||
import { MetadataOperator, RouteVariableOperator, } from './types'; | ||
export function recursiveApiCaller(transport, options, | ||
/** only needed internally, **DO NOT SET** */ | ||
@@ -17,3 +14,3 @@ path = [], routeMetadata = {}) { | ||
// merge metadata operator | ||
case types_1.MetadataOperator: { | ||
case MetadataOperator: { | ||
const mergedMetadata = args.reduce((meta, arg) => (Object.assign(Object.assign({}, meta), (typeof arg === 'object' && !Array.isArray(arg) | ||
@@ -27,3 +24,3 @@ ? arg | ||
// path variable operator | ||
case types_1.RouteVariableOperator: { | ||
case RouteVariableOperator: { | ||
const route = args.reduce((route, arg) => typeof arg === 'string' ? route.concat([arg]) : route, path.slice(0, -1)); | ||
@@ -63,3 +60,2 @@ return recursiveApiCaller(transport, options, route, routeMetadata); | ||
} | ||
exports.recursiveApiCaller = recursiveApiCaller; | ||
//# sourceMappingURL=recursiveApiCaller.js.map |
@@ -1,7 +0,4 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.ReferenceApi = exports.RouteVariableOperator = exports.MetadataOperator = void 0; | ||
exports.MetadataOperator = '$'; | ||
exports.RouteVariableOperator = '_'; | ||
exports.ReferenceApi = '_ReferenceApi'; | ||
export const MetadataOperator = '$'; | ||
export const RouteVariableOperator = '_'; | ||
export const ReferenceApi = '_ReferenceApi'; | ||
//# sourceMappingURL=types.js.map |
@@ -1,6 +0,3 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.WILL_NOT_HANDLE = void 0; | ||
/** return this value from an onEvery **RawHandler** to indicate that the message will not be handled, and should silently fail */ | ||
exports.WILL_NOT_HANDLE = Symbol('Cheep Handler: Will not handle this, silently fail'); | ||
export const WILL_NOT_HANDLE = Symbol('Cheep Handler: Will not handle this, silently fail'); | ||
//# sourceMappingURL=constants.js.map |
@@ -1,5 +0,2 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.normalizeError = void 0; | ||
function normalizeError(err) { | ||
export function normalizeError(err) { | ||
return { | ||
@@ -11,3 +8,2 @@ errorMessage: err.message, | ||
} | ||
exports.normalizeError = normalizeError; | ||
//# sourceMappingURL=normalizeError.js.map |
@@ -1,5 +0,2 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.RecursionCallError = void 0; | ||
class RecursionCallError extends Error { | ||
export class RecursionCallError extends Error { | ||
constructor( | ||
@@ -17,3 +14,2 @@ // eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
} | ||
exports.RecursionCallError = RecursionCallError; | ||
//# sourceMappingURL=recursion.error.js.map |
@@ -1,5 +0,2 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.RemoteError = void 0; | ||
class RemoteError extends Error { | ||
export class RemoteError extends Error { | ||
constructor(message, callStack, className) { | ||
@@ -13,3 +10,2 @@ super(message); | ||
} | ||
exports.RemoteError = RemoteError; | ||
//# sourceMappingURL=remote.error.js.map |
@@ -1,5 +0,2 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.RpcTimeoutError = void 0; | ||
class RpcTimeoutError extends Error { | ||
export class RpcTimeoutError extends Error { | ||
constructor( | ||
@@ -13,3 +10,2 @@ // eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
} | ||
exports.RpcTimeoutError = RpcTimeoutError; | ||
//# sourceMappingURL=rpcTimeout.error.js.map |
@@ -1,5 +0,2 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.TransactionDurationError = void 0; | ||
class TransactionDurationError extends Error { | ||
export class TransactionDurationError extends Error { | ||
constructor( | ||
@@ -18,3 +15,2 @@ // eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
} | ||
exports.TransactionDurationError = TransactionDurationError; | ||
//# sourceMappingURL=transactionDuration.error.js.map |
@@ -1,8 +0,5 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.MemoryTransport = void 0; | ||
const tslib_1 = require("tslib"); | ||
const normalizeError_1 = require("./domain/normalizeError"); | ||
const transport_base_1 = require("./transport.base"); | ||
class MemoryTransport extends transport_base_1.TransportBase { | ||
import { __awaiter } from "tslib"; | ||
import { normalizeError } from './domain/normalizeError'; | ||
import { TransportBase, } from './transport.base'; | ||
export class MemoryTransport extends TransportBase { | ||
constructor(options = {}, utils = { | ||
@@ -23,3 +20,3 @@ newId: () => Date.now().toString() + (++this.uniqueIndex).toString(), | ||
init() { | ||
return tslib_1.__awaiter(this, void 0, void 0, function* () { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
/**/ | ||
@@ -29,3 +26,3 @@ }); | ||
subscribeFailedMessages(action) { | ||
return tslib_1.__awaiter(this, void 0, void 0, function* () { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
this.failedMessagesAction = action; | ||
@@ -35,6 +32,6 @@ }); | ||
sendMessage(props) { | ||
return tslib_1.__awaiter(this, void 0, void 0, function* () { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const { messageDelayTime = 0 } = this.options; | ||
const { route, message, correlationId, isRpc } = props; | ||
const processAction = () => tslib_1.__awaiter(this, void 0, void 0, function* () { | ||
const processAction = () => __awaiter(this, void 0, void 0, function* () { | ||
const replyTo = isRpc ? 'REPLY' : undefined; | ||
@@ -65,3 +62,3 @@ try { | ||
payload: parsedMessage.payload, | ||
handlingErrorData: normalizeError_1.normalizeError(err), | ||
handlingErrorData: normalizeError(err), | ||
}, | ||
@@ -89,6 +86,6 @@ }); | ||
sendReplyMessage(props) { | ||
return tslib_1.__awaiter(this, void 0, void 0, function* () { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const { messageDelayTime = 0 } = this.options; | ||
const { replyTo, message, correlationId } = props; | ||
const processAction = () => tslib_1.__awaiter(this, void 0, void 0, function* () { | ||
const processAction = () => __awaiter(this, void 0, void 0, function* () { | ||
try { | ||
@@ -114,3 +111,2 @@ this.processResponseMessage({ | ||
} | ||
exports.MemoryTransport = MemoryTransport; | ||
//# sourceMappingURL=memory.transport.js.map |
@@ -1,8 +0,5 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.callStackReducer = void 0; | ||
/** | ||
* Adds new `callStack` metadata | ||
*/ | ||
function callStackReducer() { | ||
export function callStackReducer() { | ||
const rule = x => { | ||
@@ -18,3 +15,2 @@ var _a, _b, _c; | ||
} | ||
exports.callStackReducer = callStackReducer; | ||
//# sourceMappingURL=callStack.reducer.js.map |
@@ -1,4 +0,1 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.createdAtReducer = void 0; | ||
/** | ||
@@ -8,3 +5,3 @@ * Adds new `createdAt` metadata | ||
*/ | ||
function createdAtReducer(dateNow) { | ||
export function createdAtReducer(dateNow) { | ||
const rule = _ => ({ | ||
@@ -15,3 +12,2 @@ createdAt: dateNow(), | ||
} | ||
exports.createdAtReducer = createdAtReducer; | ||
//# sourceMappingURL=createdAt.reducer.js.map |
@@ -1,4 +0,1 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.transactionReducer = void 0; | ||
/** | ||
@@ -8,3 +5,3 @@ * Adds new `transactionId` metadata | ||
*/ | ||
function transactionReducer(newId, dateNow) { | ||
export function transactionReducer(newId, dateNow) { | ||
const rule = (x) => { | ||
@@ -19,3 +16,2 @@ var _a, _b, _c, _d, _e, _f; | ||
} | ||
exports.transactionReducer = transactionReducer; | ||
//# sourceMappingURL=transaction.reducer.js.map |
@@ -1,6 +0,3 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.callStackValidator = void 0; | ||
const recursion_error_1 = require("../errors/recursion.error"); | ||
function callStackValidator(prefixesToCheck) { | ||
import { RecursionCallError } from '../errors/recursion.error'; | ||
export function callStackValidator(prefixesToCheck) { | ||
return (msg) => { | ||
@@ -14,7 +11,6 @@ var _a; | ||
const transactionId = msg.metadata.transactionId; | ||
throw new recursion_error_1.RecursionCallError(transactionId, msg.route, callStack); | ||
throw new RecursionCallError(transactionId, msg.route, callStack); | ||
} | ||
}; | ||
} | ||
exports.callStackValidator = callStackValidator; | ||
//# sourceMappingURL=callStack.validator.js.map |
@@ -1,6 +0,3 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.transactionDurationValidator = void 0; | ||
const transactionDuration_error_1 = require("../errors/transactionDuration.error"); | ||
function transactionDurationValidator(maxDuration, parseDate, dateNow) { | ||
import { TransactionDurationError } from '../errors/transactionDuration.error'; | ||
export function transactionDurationValidator(maxDuration, parseDate, dateNow) { | ||
return (msg) => { | ||
@@ -17,7 +14,6 @@ var _a; | ||
const transactionId = msg.metadata.transactionId; | ||
throw new transactionDuration_error_1.TransactionDurationError(transactionId, duration, msg.route, (_a = msg.metadata['callStack']) !== null && _a !== void 0 ? _a : []); | ||
throw new TransactionDurationError(transactionId, duration, msg.route, (_a = msg.metadata['callStack']) !== null && _a !== void 0 ? _a : []); | ||
} | ||
}; | ||
} | ||
exports.transactionDurationValidator = transactionDurationValidator; | ||
//# sourceMappingURL=transactionDuration.validator.js.map |
@@ -1,12 +0,9 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.TransportBase = void 0; | ||
const tslib_1 = require("tslib"); | ||
const constants_1 = require("./constants"); | ||
const normalizeError_1 = require("./domain/normalizeError"); | ||
const remote_error_1 = require("./errors/remote.error"); | ||
const rpcTimeout_error_1 = require("./errors/rpcTimeout.error"); | ||
const transport_1 = require("./transport"); | ||
import { __awaiter } from "tslib"; | ||
import { WILL_NOT_HANDLE } from './constants'; | ||
import { normalizeError, } from './domain/normalizeError'; | ||
import { RemoteError } from './errors/remote.error'; | ||
import { RpcTimeoutError } from './errors/rpcTimeout.error'; | ||
import { TransportState, } from './transport'; | ||
// const HANDLER_META = Symbol('ROUTE_HANDLER') | ||
class TransportBase { | ||
export class TransportBase { | ||
constructor(options, utils) { | ||
@@ -28,4 +25,4 @@ this.options = options; | ||
start() { | ||
return tslib_1.__awaiter(this, void 0, void 0, function* () { | ||
this._state = transport_1.TransportState.STARTED; | ||
return __awaiter(this, void 0, void 0, function* () { | ||
this._state = TransportState.STARTED; | ||
}); | ||
@@ -37,4 +34,4 @@ } | ||
stop() { | ||
return tslib_1.__awaiter(this, void 0, void 0, function* () { | ||
this._state = transport_1.TransportState.STOPPED; | ||
return __awaiter(this, void 0, void 0, function* () { | ||
this._state = TransportState.STOPPED; | ||
}); | ||
@@ -95,3 +92,3 @@ } | ||
publish(props) { | ||
return tslib_1.__awaiter(this, void 0, void 0, function* () { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const { route, payload: message, metadata = {}, referrer } = props; | ||
@@ -119,3 +116,3 @@ const finalMetadata = this.mergeMetadata({ | ||
execute(props) { | ||
return tslib_1.__awaiter(this, void 0, void 0, function* () { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const { defaultRpcTimeout = 1000 } = this.options; | ||
@@ -132,3 +129,3 @@ const { route, payload: message, metadata = {}, referrer, rpcTimeout, } = props; | ||
if (errorData) { | ||
reject(new remote_error_1.RemoteError(errorData.errorMessage, errorData.errorCallStack, errorData.errorClassName)); | ||
reject(new RemoteError(errorData.errorMessage, errorData.errorCallStack, errorData.errorClassName)); | ||
return; | ||
@@ -142,3 +139,3 @@ } | ||
clearTimeout(timer); | ||
reject(new rpcTimeout_error_1.RpcTimeoutError(props)); | ||
reject(new RpcTimeoutError(props)); | ||
}, rpcCallTimeout); | ||
@@ -194,3 +191,3 @@ this.newRpcCallRegistered(this.listenCallbacks.size); | ||
dispose() { | ||
return tslib_1.__awaiter(this, void 0, void 0, function* () { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
yield this.stop(); | ||
@@ -205,3 +202,3 @@ this.routeHandlers.clear(); | ||
var _a; | ||
return tslib_1.__awaiter(this, void 0, void 0, function* () { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const { metadataValidator } = this.options; | ||
@@ -228,3 +225,3 @@ // start processing message | ||
metadata: message.metadata, | ||
errorData: normalizeError_1.normalizeError(err), | ||
errorData: normalizeError(err), | ||
}), | ||
@@ -297,3 +294,3 @@ }); | ||
metadata: message.metadata, | ||
errorData: normalizeError_1.normalizeError(err), | ||
errorData: normalizeError(err), | ||
}), | ||
@@ -324,3 +321,3 @@ }); | ||
}, msg)).catch(err => { | ||
if (err === constants_1.WILL_NOT_HANDLE) { | ||
if (err === WILL_NOT_HANDLE) { | ||
return; | ||
@@ -373,3 +370,2 @@ } | ||
} | ||
exports.TransportBase = TransportBase; | ||
//# sourceMappingURL=transport.base.js.map |
@@ -1,9 +0,6 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.TransportState = void 0; | ||
var TransportState; | ||
export var TransportState; | ||
(function (TransportState) { | ||
TransportState["STARTED"] = "STARTED"; | ||
TransportState["STOPPED"] = "STOPPED"; | ||
})(TransportState = exports.TransportState || (exports.TransportState = {})); | ||
})(TransportState || (TransportState = {})); | ||
//# sourceMappingURL=transport.js.map |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
74584
1140