@cranq/runtime
Advanced tools
Comparing version 1.0.3 to 1.0.4
@@ -0,0 +0,0 @@ export declare const TracerFlowMessageTypes: readonly ["input", "output"]; |
@@ -204,2 +204,3 @@ module.exports = | ||
__exportStar(__webpack_require__(/*! ./tracers/types/TracerParams */ "./src/tracers/types/TracerParams.ts"), exports); | ||
__exportStar(__webpack_require__(/*! ./tracers/types/TracerProjectMetadata */ "./src/tracers/types/TracerProjectMetadata.ts"), exports); | ||
__exportStar(__webpack_require__(/*! ./tracers/types/TracerId */ "./src/tracers/types/TracerId.ts"), exports); | ||
@@ -236,11 +237,17 @@ __exportStar(__webpack_require__(/*! ./tracers/types/Tracers */ "./src/tracers/types/Tracers.ts"), exports); | ||
exports.consoleTracerFactory = void 0; | ||
exports.consoleTracerFactory = (_tracerParams) => { | ||
const formatNodePath = (nodePath) => [...nodePath].reverse().map((id) => id.substr(0, 8)).join("."); | ||
const formatPortId = (portId) => portId.substr(0, 8); | ||
exports.consoleTracerFactory = (_tracerParams, tracerProjectMetadata) => { | ||
const formatNodePath = (nodePath) => { | ||
return [...nodePath].reverse().map((id) => { var _a; return (_a = tracerProjectMetadata === null || tracerProjectMetadata === void 0 ? void 0 : tracerProjectMetadata.nodeIdNameMapping[id]) !== null && _a !== void 0 ? _a : id.substr(0, 8); }) | ||
.join("."); | ||
}; | ||
const formatPortName = (portId) => { | ||
var _a; | ||
return (_a = tracerProjectMetadata === null || tracerProjectMetadata === void 0 ? void 0 : tracerProjectMetadata.portIdNameMapping[portId]) !== null && _a !== void 0 ? _a : portId.substr(0, 8); | ||
}; | ||
return ({ | ||
traceInput: (nodePath, portId, data, tag) => { | ||
console.log(`I ${formatNodePath(nodePath)}:${formatPortId(portId)} @${tag}`); | ||
console.log(`I ${formatNodePath(nodePath)}:${formatPortName(portId)} @${tag}`); | ||
}, | ||
traceOutput: (nodePath, portId, data, tag) => { | ||
console.log(`O ${formatNodePath(nodePath)}:${formatPortId(portId)} @${tag}`); | ||
console.log(`O ${formatNodePath(nodePath)}:${formatPortName(portId)} @${tag}`); | ||
}, | ||
@@ -253,3 +260,3 @@ traceNodeError: (nodePath, error) => { | ||
var _a, _b; | ||
console.error(`Error ${formatNodePath(nodePath)}:${formatPortId(portId)} ${(_b = (_a = error) === null || _a === void 0 ? void 0 : _a.message) !== null && _b !== void 0 ? _b : `${error}`}`); | ||
console.error(`Error ${formatNodePath(nodePath)}:${formatPortName(portId)} ${(_b = (_a = error) === null || _a === void 0 ? void 0 : _a.message) !== null && _b !== void 0 ? _b : `${error}`}`); | ||
} | ||
@@ -275,3 +282,3 @@ }); | ||
const ensureMinimalErrorTracer_1 = __webpack_require__(/*! ./utils/ensureMinimalErrorTracer */ "./src/tracers/utils/ensureMinimalErrorTracer.ts"); | ||
function createTracers(tracerDescriptor) { | ||
function createTracers(tracerDescriptor, projectMetadata) { | ||
const actualTracerDescriptor = ensureMinimalErrorTracer_1.ensureMinimalErrorTracer(tracerDescriptor); | ||
@@ -285,3 +292,3 @@ return Object.fromEntries(Object.entries(actualTracerDescriptor) | ||
} | ||
return [tracerId, tracerFactory(tracerParams)]; | ||
return [tracerId, tracerFactory(tracerParams, projectMetadata)]; | ||
}) | ||
@@ -611,2 +618,16 @@ .filter((tracerEntry) => tracerEntry[1] !== undefined)); | ||
/***/ "./src/tracers/types/TracerProjectMetadata.ts": | ||
/*!****************************************************!*\ | ||
!*** ./src/tracers/types/TracerProjectMetadata.ts ***! | ||
\****************************************************/ | ||
/*! no static exports found */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
/***/ }), | ||
/***/ "./src/tracers/types/Tracers.ts": | ||
@@ -613,0 +634,0 @@ /*!**************************************!*\ |
import { Node } from "./types/Node"; | ||
export declare function connectPorts(outputPort: Node["outputs"][string], inputPort: Node["inputs"][string]): void; |
@@ -0,0 +0,0 @@ export declare enum ExitCode { |
@@ -0,0 +0,0 @@ import { CleanupHandler } from "./types/CleanupHandler"; |
@@ -12,2 +12,3 @@ export * from "./connectPorts"; | ||
export * from "./tracers/types/TracerParams"; | ||
export * from "./tracers/types/TracerProjectMetadata"; | ||
export * from "./tracers/types/TracerId"; | ||
@@ -14,0 +15,0 @@ export * from "./tracers/types/Tracers"; |
import { TracerFactory } from "../types/TracerFactory"; | ||
export declare const consoleTracerFactory: TracerFactory; |
import { TracerDescriptor } from "./types/TracerDescriptor"; | ||
import { TracerProjectMetadata } from "./types/TracerProjectMetadata"; | ||
import { Tracers } from "./types/Tracers"; | ||
export declare function createTracers(tracerDescriptor: TracerDescriptor): Tracers; | ||
export declare function createTracers(tracerDescriptor: TracerDescriptor, projectMetadata?: TracerProjectMetadata): Tracers; |
import { TracerFactoryStore } from "./types/TracerFactoryStore"; | ||
export declare const tracerFactoryStore: TracerFactoryStore; |
import { TracerFactory } from "../types/TracerFactory"; | ||
export declare const localIPCTracerFactory: TracerFactory; |
import { TracerId } from "./types/TracerId"; | ||
import { Tracers } from "./types/Tracers"; | ||
export declare function traceInputFactory(tracers: Tracers, enabledTracerIds: TracerId[]): (path: string[], portId: string, data: any, tag: string) => void; |
import { TracerId } from "./types/TracerId"; | ||
import { Tracers } from "./types/Tracers"; | ||
export declare function traceNodeErrorFactory(tracers: Tracers, enabledTracerIds: TracerId[]): (path: string[], error: Error) => void; |
import { TracerId } from "./types/TracerId"; | ||
import { Tracers } from "./types/Tracers"; | ||
export declare function traceOutputFactory(tracers: Tracers, enabledTracerIds: TracerId[]): (path: string[], portId: string, data: any, tag: string) => void; |
import { TracerId } from "./types/TracerId"; | ||
import { Tracers } from "./types/Tracers"; | ||
export declare function tracePortErrorFactory(tracers: Tracers, enabledTracerIds: TracerId[]): (path: string[], portId: string, error: Error) => void; |
@@ -0,0 +0,0 @@ export declare type Tracer = { |
@@ -0,0 +0,0 @@ import { TracerId } from "./TracerId"; |
import { Tracer } from "./Tracer"; | ||
import { TracerParams } from "./TracerParams"; | ||
export declare type TracerFactory = (tracerParams: TracerParams) => Tracer; | ||
import { TracerProjectMetadata } from "./TracerProjectMetadata"; | ||
export declare type TracerFactory = (tracerParams: TracerParams, projectMetadata?: TracerProjectMetadata) => Tracer; |
@@ -0,0 +0,0 @@ import { TracerFactory } from "./TracerFactory"; |
@@ -0,0 +0,0 @@ export declare enum TracerId { |
@@ -0,0 +0,0 @@ import { TraceVariables } from "./TraceVariables"; |
@@ -0,0 +0,0 @@ import { Tracer } from "./Tracer"; |
export declare type TraceVariables = { | ||
observedUiNodePaths?: string[][]; | ||
}; |
import { TracerDescriptor } from "../types/TracerDescriptor"; | ||
export declare const ensureMinimalErrorTracer: (tracerDescriptor: TracerDescriptor) => TracerDescriptor; |
export declare const isNodePathContained: (nodePathsToMatch: string[][], additionalLevelsDownward: number) => (nodePath: string[]) => boolean; |
import { OutputHandlers } from "./OutputHandlers"; | ||
export declare type CleanupHandler = (outputs: OutputHandlers) => void; |
export declare type InputHandler = (data: unknown, tag: string) => void; |
@@ -0,0 +0,0 @@ import { InputHandler } from "./InputHandler"; |
@@ -0,0 +0,0 @@ import { CleanupHandler } from "./CleanupHandler"; |
export declare type NodePath = string[]; |
export declare type OutputHandler = (data: unknown, tag: string) => void; |
@@ -0,0 +0,0 @@ import { OutputHandler } from "./OutputHandler"; |
{ | ||
"name": "@cranq/runtime", | ||
"version": "1.0.3", | ||
"version": "1.0.4", | ||
"description": "Runtime for CRANQ projects to run on NodeJs or in the browser", | ||
@@ -5,0 +5,0 @@ "scripts": { |
@@ -0,0 +0,0 @@ /* Establishes a connection between the specified ports. */ |
@@ -0,0 +0,0 @@ export enum ExitCode { |
@@ -0,0 +0,0 @@ import {Tracer} from "./tracers/types/Tracer"; |
@@ -12,2 +12,3 @@ export * from "./connectPorts"; | ||
export * from "./tracers/types/TracerParams"; | ||
export * from "./tracers/types/TracerProjectMetadata"; | ||
export * from "./tracers/types/TracerId"; | ||
@@ -14,0 +15,0 @@ export * from "./tracers/types/Tracers"; |
import {TracerFactory} from "../types/TracerFactory"; | ||
export const consoleTracerFactory: TracerFactory = ( | ||
_tracerParams//not used at the moment | ||
) => { | ||
const formatNodePath = (nodePath: string[]) => [...nodePath].reverse().map((id) => id.substr(0, 8)).join("."); | ||
const formatPortId = (portId: string) => portId.substr(0, 8); | ||
_tracerParams,//not used at the moment | ||
tracerProjectMetadata | ||
) => { | ||
const formatNodePath = (nodePath: string[]) => { | ||
return [...nodePath].reverse().map((id) => | ||
tracerProjectMetadata?.nodeIdNameMapping[id] ?? id.substr(0, 8)) | ||
.join("."); | ||
}; | ||
const formatPortName = (portId: string) => { | ||
return tracerProjectMetadata?.portIdNameMapping[portId] ?? | ||
portId.substr(0, 8); | ||
}; | ||
return ({ | ||
traceInput: (nodePath, portId, data, tag) => { | ||
console.log(`I ${formatNodePath(nodePath)}:${formatPortId(portId)} @${tag}`); | ||
}, | ||
traceOutput: (nodePath, portId, data, tag) => { | ||
console.log(`O ${formatNodePath(nodePath)}:${formatPortId(portId)} @${tag}`); | ||
}, | ||
traceNodeError: (nodePath, error) => { | ||
console.error(`Error ${formatNodePath(nodePath)} ${(error as Error)?.message ?? `${error}`}`); | ||
}, | ||
tracePortError: (nodePath, portId, error) => { | ||
console.error(`Error ${formatNodePath(nodePath)}:${formatPortId(portId)} ${(error as Error)?.message ?? `${error}`}`); | ||
} | ||
}); | ||
}; | ||
return ({ | ||
traceInput: (nodePath, portId, data, tag) => { | ||
console.log(`I ${formatNodePath(nodePath)}:${formatPortName(portId)} @${tag}`); | ||
}, | ||
traceOutput: (nodePath, portId, data, tag) => { | ||
console.log(`O ${formatNodePath(nodePath)}:${formatPortName(portId)} @${tag}`); | ||
}, | ||
traceNodeError: (nodePath, error) => { | ||
console.error(`Error ${formatNodePath(nodePath)} ${(error as Error)?.message ?? `${error}`}`); | ||
}, | ||
tracePortError: (nodePath, portId, error) => { | ||
console.error(`Error ${formatNodePath(nodePath)}:${formatPortName(portId)} ${(error as Error)?.message ?? `${error}`}`); | ||
} | ||
}); | ||
} | ||
; |
@@ -6,2 +6,3 @@ import {tracerFactoryStore} from "./index"; | ||
import {TracerParams} from "./types/TracerParams"; | ||
import {TracerProjectMetadata} from "./types/TracerProjectMetadata"; | ||
import {Tracers} from "./types/Tracers"; | ||
@@ -11,3 +12,4 @@ import {ensureMinimalErrorTracer} from "./utils/ensureMinimalErrorTracer"; | ||
export function createTracers( | ||
tracerDescriptor: TracerDescriptor | ||
tracerDescriptor: TracerDescriptor, | ||
projectMetadata?: TracerProjectMetadata | ||
): Tracers { | ||
@@ -24,3 +26,3 @@ const actualTracerDescriptor: TracerDescriptor = ensureMinimalErrorTracer(tracerDescriptor); | ||
} | ||
return [tracerId, tracerFactory(tracerParams)]; | ||
return [tracerId, tracerFactory(tracerParams, projectMetadata)]; | ||
}) | ||
@@ -27,0 +29,0 @@ .filter((tracerEntry): tracerEntry is [TracerId, Tracer] => tracerEntry[1] !== undefined) |
@@ -0,0 +0,0 @@ import {consoleTracerFactory} from "./console/consoleTracerFactory"; |
@@ -0,0 +0,0 @@ import {TracerErrorPacket, TracerFlowPacket} from "@dtos/tracer/ipc/TracerPacket"; |
@@ -0,0 +0,0 @@ import {TracerId} from "./types/TracerId"; |
@@ -0,0 +0,0 @@ import {ExitCode} from "../constants/exitCode"; |
@@ -0,0 +0,0 @@ import {TracerId} from "./types/TracerId"; |
@@ -0,0 +0,0 @@ import {ExitCode} from "../constants/exitCode"; |
@@ -0,0 +0,0 @@ export type Tracer = { |
@@ -0,0 +0,0 @@ import {TracerId} from "./TracerId"; |
import {Tracer} from "./Tracer"; | ||
import {TracerParams} from "./TracerParams"; | ||
import {TracerProjectMetadata} from "./TracerProjectMetadata"; | ||
export type TracerFactory = (tracerParams: TracerParams) => Tracer; | ||
export type TracerFactory = ( | ||
tracerParams: TracerParams, | ||
projectMetadata?: TracerProjectMetadata) => Tracer; |
@@ -0,0 +0,0 @@ import {TracerFactory} from "./TracerFactory"; |
@@ -0,0 +0,0 @@ export enum TracerId { |
@@ -0,0 +0,0 @@ import {TraceVariables} from "./TraceVariables"; |
@@ -0,0 +0,0 @@ import {Tracer} from "./Tracer"; |
export type TraceVariables = { | ||
observedUiNodePaths?: string[][] | ||
}; |
@@ -0,0 +0,0 @@ import {tracerFactoryStore} from "../index"; |
@@ -0,0 +0,0 @@ import {isNodePathContained} from "./isNodePathContained"; |
@@ -0,0 +0,0 @@ /** |
import {OutputHandlers} from "./OutputHandlers"; | ||
export type CleanupHandler = (outputs: OutputHandlers) => void; |
import {InputHandler} from "./InputHandler"; | ||
export type InputHandlers = { [key: string]: InputHandler }; |
@@ -0,0 +0,0 @@ import {CleanupHandler} from "./CleanupHandler"; |
import {OutputHandler} from "./OutputHandler"; | ||
export type OutputHandlers = { [key: string]: OutputHandler }; |
@@ -0,0 +0,0 @@ { |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
89088
66
1276
1