UNPKG

@interopio/gateway

Version:

[![npm version](https://img.shields.io/npm/v/@interopio/gateway.svg)](https://www.npmjs.com/package/@interopio/gateway)

8 lines (7 loc) 28.8 kB
{ "version": 3, "sources": ["../../src/logger.ts", "../../../../node_modules/serialize-error/error-constructors.js", "../../../../node_modules/serialize-error/index.js", "../../src/worker/worker.ts", "../../src/metrics/worker.ts"], "sourcesContent": ["import {IOGateway} from '../gateway';\n\nenum LogLevel {\n trace,\n debug,\n info,\n warn,\n error,\n}\n\nconst loggers: {[key: string]: Logger} = Object.create(null);\nconst logLevels: Record<string, LogLevel> = {};\nconst ROOT = 'gateway';\nlogLevels[ROOT] = LogLevel.trace;\nlet appender : (e: IOGateway.Logging.LogEvent) => void = (e) => {\n console[e.level](`${e.time.toISOString()} ${e.level.toUpperCase()} [${e.name}] - ${e.message}`, ...e.data);\n};\n\ntype LogLevelKey = keyof typeof LogLevel;\n\nexport interface Logger extends IOGateway.Logging.Logger {\n (level: LogLevelKey, message?: string, ...args: unknown[])\n child(name: string): Logger\n}\nexport function logEvent(event: IOGateway.Logging.LogEvent) {\n const {name, level} = event;\n checkNameAndConfigureLevel(name);\n if (isLevelEnabledFor(level, name)) {\n appender(event);\n }\n}\n\nfunction log(this: Logger, name: string, level: LogLevelKey, message: string, ...data: unknown[]) {\n if (this.enabledFor(level)) {\n const time = new Date();\n const event: IOGateway.Logging.LogEvent = {time, level, name, message, data};\n appender(event);\n }\n}\n\nfunction isLevelEnabledFor(level: LogLevelKey, name: string) {\n const logLevelValue = LogLevel[level];\n const configuredLevel = logLevels[name];\n return configuredLevel <= logLevelValue;\n}\n\nfunction newLogger(name: string): Logger {\n checkNameAndConfigureLevel(name);\n const logger: Logger = function(level: LogLevelKey, message: string, ...args:unknown[]) {\n log.call(logger, name, level, message, ...args);\n } as Logger;\n function methods(key: string): key is LogLevelKey {\n return isNaN(Number(key));\n }\n for (const method of Object.keys(LogLevel).filter(methods)) {\n logger[method] = function(message: string, ...args: unknown[]) {\n log.call(logger, name, method, message, ...args);\n };\n }\n logger.enabledFor = function(level: LogLevelKey) {\n return isLevelEnabledFor(level, name);\n }\n logger.child = function (suffix: string) {\n return getLogger(`${name}.${suffix}`);\n }\n return logger;\n}\n\nfunction checkNameAndConfigureLevel(name: string) {\n if (!name.startsWith(ROOT)) throw new Error(`Logger name must start with ${ROOT}`);\n if (!logLevels[name]) {\n const orderedEntries = Object.entries(logLevels).sort(([n1,], [n2,])=> n2.localeCompare(n1));\n const [, level] = orderedEntries.find(([prefix,]) => name.startsWith(prefix))!;\n logLevels[name] = level;\n }\n}\n\nexport function getLogger(name: string): Logger {\n let logger: Logger | undefined = loggers[name];\n if (logger === undefined) {\n logger = newLogger(name);\n loggers[name] = logger;\n }\n return logger;\n}\n\nexport function configure(config: IOGateway.Logging.LogConfig) {\n function updateLevels(prefix: string, level: LogLevelKey) {\n for (const name of Object.keys(logLevels).filter(k => k.startsWith(prefix))) {\n logLevels[name] = LogLevel[level];\n }\n }\n\n const logLevel = config.level;\n\n if (typeof logLevel === 'string') {\n logLevels[ROOT] = LogLevel[logLevel];\n updateLevels(ROOT, logLevel);\n } else if (typeof logLevel === 'object') {\n const orderedEntries = Object.entries(logLevel).sort(([n1], [n2]) => n1.localeCompare(n2));\n for (const [prefix, level] of orderedEntries) {\n updateLevels(prefix, level);\n }\n }\n\n appender = config.appender ?? appender;\n}\n", "const list = [\n\t// Native ES errors https://262.ecma-international.org/12.0/#sec-well-known-intrinsic-objects\n\tError,\n\tEvalError,\n\tRangeError,\n\tReferenceError,\n\tSyntaxError,\n\tTypeError,\n\tURIError,\n\tAggregateError,\n\n\t// Built-in errors\n\tglobalThis.DOMException,\n\n\t// Node-specific errors\n\t// https://nodejs.org/api/errors.html\n\tglobalThis.AssertionError,\n\tglobalThis.SystemError,\n]\n\t// Non-native Errors are used with `globalThis` because they might be missing. This filter drops them when undefined.\n\t.filter(Boolean)\n\t.map(\n\t\tconstructor => [constructor.name, constructor],\n\t);\n\nexport const errorConstructors = new Map(list);\n\nexport function addKnownErrorConstructor(constructor) {\n\tconst {name} = constructor;\n\tif (errorConstructors.has(name)) {\n\t\tthrow new Error(`The error constructor \"${name}\" is already known.`);\n\t}\n\n\ttry {\n\t\t// eslint-disable-next-line no-new -- It just needs to be verified\n\t\tnew constructor();\n\t} catch (error) {\n\t\tthrow new Error(`The error constructor \"${name}\" is not compatible`, {cause: error});\n\t}\n\n\terrorConstructors.set(name, constructor);\n}\n", "import {errorConstructors} from './error-constructors.js';\n\nexport class NonError extends Error {\n\tname = 'NonError';\n\n\tconstructor(message) {\n\t\tsuper(NonError._prepareSuperMessage(message));\n\t}\n\n\tstatic _prepareSuperMessage(message) {\n\t\ttry {\n\t\t\treturn JSON.stringify(message);\n\t\t} catch {\n\t\t\treturn String(message);\n\t\t}\n\t}\n}\n\nconst errorProperties = [\n\t{\n\t\tproperty: 'name',\n\t\tenumerable: false,\n\t},\n\t{\n\t\tproperty: 'message',\n\t\tenumerable: false,\n\t},\n\t{\n\t\tproperty: 'stack',\n\t\tenumerable: false,\n\t},\n\t{\n\t\tproperty: 'code',\n\t\tenumerable: true,\n\t},\n\t{\n\t\tproperty: 'cause',\n\t\tenumerable: false,\n\t},\n\t{\n\t\tproperty: 'errors',\n\t\tenumerable: false,\n\t},\n];\n\nconst toJsonWasCalled = new WeakSet();\n\nconst toJSON = from => {\n\ttoJsonWasCalled.add(from);\n\tconst json = from.toJSON();\n\ttoJsonWasCalled.delete(from);\n\treturn json;\n};\n\nconst newError = name => {\n\tconst ErrorConstructor = errorConstructors.get(name) ?? Error;\n\treturn ErrorConstructor === AggregateError\n\t\t? new ErrorConstructor([])\n\t\t: new ErrorConstructor();\n};\n\n// eslint-disable-next-line complexity\nconst destroyCircular = ({\n\tfrom,\n\tseen,\n\tto,\n\tforceEnumerable,\n\tmaxDepth,\n\tdepth,\n\tuseToJSON,\n\tserialize,\n}) => {\n\tif (!to) {\n\t\tif (Array.isArray(from)) {\n\t\t\tto = [];\n\t\t} else if (!serialize && isErrorLike(from)) {\n\t\t\tto = newError(from.name);\n\t\t} else {\n\t\t\tto = {};\n\t\t}\n\t}\n\n\tseen.push(from);\n\n\tif (depth >= maxDepth) {\n\t\treturn to;\n\t}\n\n\tif (useToJSON && typeof from.toJSON === 'function' && !toJsonWasCalled.has(from)) {\n\t\treturn toJSON(from);\n\t}\n\n\tconst continueDestroyCircular = value => destroyCircular({\n\t\tfrom: value,\n\t\tseen: [...seen],\n\t\tforceEnumerable,\n\t\tmaxDepth,\n\t\tdepth,\n\t\tuseToJSON,\n\t\tserialize,\n\t});\n\n\tfor (const [key, value] of Object.entries(from)) {\n\t\tif (value && value instanceof Uint8Array && value.constructor.name === 'Buffer') {\n\t\t\tto[key] = '[object Buffer]';\n\t\t\tcontinue;\n\t\t}\n\n\t\t// TODO: Use `stream.isReadable()` when targeting Node.js 18.\n\t\tif (value !== null && typeof value === 'object' && typeof value.pipe === 'function') {\n\t\t\tto[key] = '[object Stream]';\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (typeof value === 'function') {\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (!value || typeof value !== 'object') {\n\t\t\t// Gracefully handle non-configurable errors like `DOMException`.\n\t\t\ttry {\n\t\t\t\tto[key] = value;\n\t\t\t} catch {}\n\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (!seen.includes(from[key])) {\n\t\t\tdepth++;\n\t\t\tto[key] = continueDestroyCircular(from[key]);\n\n\t\t\tcontinue;\n\t\t}\n\n\t\tto[key] = '[Circular]';\n\t}\n\n\tif (serialize || to instanceof Error) {\n\t\tfor (const {property, enumerable} of errorProperties) {\n\t\t\tif (from[property] !== undefined && from[property] !== null) {\n\t\t\t\tObject.defineProperty(to, property, {\n\t\t\t\t\tvalue: isErrorLike(from[property]) || Array.isArray(from[property])\n\t\t\t\t\t\t? continueDestroyCircular(from[property])\n\t\t\t\t\t\t: from[property],\n\t\t\t\t\tenumerable: forceEnumerable ? true : enumerable,\n\t\t\t\t\tconfigurable: true,\n\t\t\t\t\twritable: true,\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\t}\n\n\treturn to;\n};\n\nexport function serializeError(value, options = {}) {\n\tconst {\n\t\tmaxDepth = Number.POSITIVE_INFINITY,\n\t\tuseToJSON = true,\n\t} = options;\n\n\tif (typeof value === 'object' && value !== null) {\n\t\treturn destroyCircular({\n\t\t\tfrom: value,\n\t\t\tseen: [],\n\t\t\tforceEnumerable: true,\n\t\t\tmaxDepth,\n\t\t\tdepth: 0,\n\t\t\tuseToJSON,\n\t\t\tserialize: true,\n\t\t});\n\t}\n\n\t// People sometimes throw things besides Error objects\u2026\n\tif (typeof value === 'function') {\n\t\t// `JSON.stringify()` discards functions. We do too, unless a function is thrown directly.\n\t\t// We intentionally use `||` because `.name` is an empty string for anonymous functions.\n\t\treturn `[Function: ${value.name || 'anonymous'}]`;\n\t}\n\n\treturn value;\n}\n\nexport function deserializeError(value, options = {}) {\n\tconst {maxDepth = Number.POSITIVE_INFINITY} = options;\n\n\tif (value instanceof Error) {\n\t\treturn value;\n\t}\n\n\tif (isMinimumViableSerializedError(value)) {\n\t\treturn destroyCircular({\n\t\t\tfrom: value,\n\t\t\tseen: [],\n\t\t\tto: newError(value.name),\n\t\t\tmaxDepth,\n\t\t\tdepth: 0,\n\t\t\tserialize: false,\n\t\t});\n\t}\n\n\treturn new NonError(value);\n}\n\nexport function isErrorLike(value) {\n\treturn Boolean(value)\n\t&& typeof value === 'object'\n\t&& typeof value.name === 'string'\n\t&& typeof value.message === 'string'\n\t&& typeof value.stack === 'string';\n}\n\n// Used as a weak check for immediately-passed objects, whereas `isErrorLike` is used for nested values to avoid bad detection\nfunction isMinimumViableSerializedError(value) {\n\treturn Boolean(value)\n\t&& typeof value === 'object'\n\t&& typeof value.message === 'string'\n\t&& !Array.isArray(value);\n}\n\nexport {addKnownErrorConstructor} from './error-constructors.js';\n", "import {IOGateway} from '../../gateway';\n\nexport interface GatewayWorker {\n send<T>(payload: T): void\n\n on(type: string, callback: (message: any) => void): void\n\n onmessage: ((this: GatewayWorker, message: MessageEvent) => Promise<void> | void) | null\n onerror: ((this: GatewayWorker, error: ErrorEvent) => void) | null\n\n exit(code?: number): void\n\n findParameter(name: string): string | null | undefined\n\n streamLogs(level: IOGateway.Logging.LogConfig['level']): Promise<void>\n\n importModule<T>(moduleName: string): Promise<T>\n}\n\nconst worker: GatewayWorker = {\n send: (): void => {\n },\n on: (): void => {\n },\n onmessage: null,\n onerror: null,\n\n exit: (): void => {\n },\n\n findParameter(name: string): string | null | undefined {\n let value = new URLSearchParams(globalThis.location?.search).get(name);\n if (!value) {\n const arg = globalThis.process?.argv\n .filter(a => a.startsWith('--'))\n .map((arg) => {\n const strings = arg.slice('--'.length).split('=');\n return [strings[0], strings[1]];\n })\n .find(([k, _v]) => k === name);\n if (arg) {\n [, value] = arg;\n }\n }\n return value;\n },\n async streamLogs(level: IOGateway.Logging.LogConfig['level'] = 'trace'): Promise<void> {\n const appender = (e: IOGateway.Logging.LogEvent) => {\n worker.send({\n log: {\n time: e.time.getTime(),\n level: e.level,\n name: e.name,\n message: e.message,\n data: e.data\n }\n });\n }\n (await import('../logger.js')).configure({level, appender});\n },\n\n async importModule<T>(moduleName: string): Promise<T> {\n return await import(moduleName);\n }\n}\n\nif (typeof self !== 'undefined' && typeof postMessage === 'function' && typeof addEventListener === 'function') {\n worker.on = (event, callback) => {\n addEventListener(event, (message) => {\n callback(message);\n })\n }\n worker.send = <T>(payload: T) => {\n postMessage(payload)\n };\n if (typeof close === 'function') {\n worker.exit = close;\n }\n} else if (typeof process !== 'undefined') {\n (globalThis as { self?: unknown }).self = worker;\n worker.on = process.on.bind(process);\n\n const send = process.send?.bind(process);\n if (send) { // probably just loading the file from non worker context\n worker.send = <T>(payload: T) => {\n send(JSON.stringify({type: 'message', data: payload}));\n };\n }\n\n worker.on('disconnect', () => {\n process.exit(1);\n });\n process.on('uncaughtException', (error) => {\n if (send) {\n send(JSON.stringify({type: 'error', message: `Uncaught Error: ${error.message}`}));\n }\n });\n worker.exit = process.exit.bind(process);\n}\n\nworker.on('message', (message: MessageEvent) => {\n if (worker.onmessage) {\n worker.onmessage(message);\n }\n});\n\nworker.on('error', (error: ErrorEvent) => {\n if (worker.onerror) {\n worker.onerror(error);\n }\n});\n\nexport default worker;\n", "import {getLogger, Logger} from '../logger.js';\nimport {GatewayWorker} from '../worker/worker.ts';\nimport {PublishCommand} from './publisher/types.js';\nimport {WorkerCommandType, WorkerRequest} from './publisher.js';\nimport {IOGateway} from '../../gateway';\n\n// all imports except for worker should be dynamic. This way we can do preload before those imports\n// (very helpful in web tests that involve workers)\n\nasync function importPreload(log: Logger, module: string) {\n try {\n const preload = await import(module);\n if (typeof preload === 'function') {\n return await preload();\n }\n if (typeof preload.default === 'function') {\n return await preload.default();\n }\n } catch (e) {\n log.error(`failed to load preload`, e);\n }\n}\n\nasync function importHandler(log: Logger, publishFn: string, cfg: unknown) {\n log.debug(`loading publisher from ${publishFn}`);\n let factory: {\n name?: string,\n create: (cfg: unknown, logger: Logger) => Promise<(command: PublishCommand) => Promise<unknown>>;\n } = await import(publishFn);\n if (typeof factory['default'] === 'object') {\n factory = factory['default'] as typeof factory;\n }\n return await factory.create(cfg, getLogger(`gateway.metrics.publisher.${factory.name ?? publishFn}`));\n}\n\nasync function configureLogging(worker: GatewayWorker) {\n let logLevel = worker.findParameter('logLevel');\n\n if (logLevel?.startsWith('\"')) {\n try {\n logLevel = JSON.parse(logLevel);\n } catch (e) {\n logLevel = null;\n }\n }\n await worker.streamLogs(logLevel as IOGateway.Logging.LogConfig['level'] ?? 'info');\n}\n\nasync function startHandler(log: Logger, arg: WorkerCommandType['start']): Promise<[(command: PublishCommand) => Promise<unknown>, unknown]> {\n const {publishFn, cfg} = arg;\n if (cfg?.preload) {\n const result = await importPreload(log, cfg.preload);\n if (typeof result === 'object') {\n for (const key in result) {\n cfg[key] = result[key];\n }\n }\n }\n let handler: (command: PublishCommand) => Promise<unknown>;\n if (typeof publishFn === 'function') {\n handler = publishFn;\n } else {\n handler = await importHandler(log, publishFn, cfg);\n }\n const cleanupArg = await handler('start');\n return [handler, cleanupArg];\n}\n\nasync function stopHandler(_log: Logger, handler: (command: PublishCommand) => Promise<unknown>, cleanupArg: unknown) {\n const cleanup = await handler('stop');\n if (typeof cleanup === 'function') {\n await cleanup(cleanupArg);\n }\n}\n\nfunction attach(worker: GatewayWorker) {\n let handler: (command: PublishCommand) => Promise<unknown>;\n let cleanupArg: unknown;\n worker.onmessage = async (event: { data: WorkerRequest<keyof WorkerCommandType> }) => {\n const log = getLogger('gateway.metrics.worker');\n const {id, cmd, arg} = event.data;\n try {\n switch (cmd) {\n case 'start': {\n [handler, cleanupArg] = await startHandler(log, arg as WorkerCommandType['start']);\n break;\n }\n case 'stop': {\n await stopHandler(log, handler, cleanupArg);\n break;\n }\n case 'update': {\n await handler(arg as IOGateway.Metrics.Update);\n break;\n }\n }\n worker.send({id, result: 'ok'});\n } catch (ex) {\n const {serializeError} = await import('serialize-error');\n const error = serializeError(ex);\n worker.send({id, error});\n }\n };\n}\n\nimport('../worker/worker.js')\n .then((module) => module.default)\n .then(async (worker) => {\n await configureLogging(worker)\n attach(worker);\n worker.send({ready: true});\n }\n ).catch(e => console.error(e));\n"], "mappings": "qjBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,eAAAE,EAAA,cAAAC,EAAA,aAAAC,IAwBO,SAASA,EAASC,EAAmC,CACxD,GAAM,CAAC,KAAAC,EAAM,MAAAC,CAAK,EAAIF,EACtBG,EAA2BF,CAAI,EAC3BG,EAAkBF,EAAOD,CAAI,GAC7BI,EAASL,CAAK,CAEtB,CAEA,SAASM,EAAkBL,EAAcC,EAAoBK,KAAoBC,EAAiB,CAC1F,KAAK,WAAWN,CAAK,GAGrBG,EAD0C,CAAC,KAD9B,IAAI,KACgC,MAAAH,EAAO,KAAAD,EAAM,QAAAM,EAAS,KAAAC,CAAI,CAC7D,CAEtB,CAEA,SAASJ,EAAkBF,EAAoBD,EAAc,CACzD,IAAMQ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K,OAAQ,CACT,MAAMK,GAAYnB,EAAKiB,EAASC,CAAU,EAC1C,KACJ,CACA,IAAK,SAAU,CACX,MAAMD,EAAQH,CAA+B,EAC7C,KACJ,CACJ,CACAH,EAAO,KAAK,CAAC,GAAAa,EAAI,OAAQ,IAAI,CAAC,CAClC,OAASE,EAAI,CACT,GAAM,CAAC,eAAAC,CAAc,EAAI,KAAM,qCACzBC,EAAQD,EAAeD,CAAE,EAC/Bf,EAAO,KAAK,CAAC,GAAAa,EAAI,MAAAI,CAAK,CAAC,CAC3B,CACJ,CACJ,CAEA,oCACK,KAAM3B,GAAWA,EAAO,OAAO,EAC/B,KAAK,MAAOU,GAAW,CAChB,MAAMD,GAAiBC,CAAM,EAC7BW,GAAOX,CAAM,EACbA,EAAO,KAAK,CAAC,MAAO,EAAI,CAAC,CAC7B,CACJ,EAAE,MAAM,GAAK,QAAQ,MAAM,CAAC,CAAC", "names": ["logger_exports", "__export", "configure", "getLogger", "logEvent", "event", "name", "level", "checkNameAndConfigureLevel", "isLevelEnabledFor", "appender", "log", "message", "data", "logLevelValue", "LogLevel", "logLevels", "newLogger", "logger", "args", "methods", "key", "method", "suffix", "ROOT", "orderedEntries", "n1", "n2", "prefix", "loggers", "config", "updateLevels", "k", "logLevel", "init_logger", "__esmMin", "addKnownErrorConstructor", "constructor", "name", "errorConstructors", "error", "list", "init_error_constructors", "__esmMin", "serialize_error_exports", "__export", "NonError", "addKnownErrorConstructor", "deserializeError", "isErrorLike", "serializeError", "value", "options", "maxDepth", "useToJSON", "destroyCircular", "isMinimumViableSerializedError", "newError", "errorProperties", "toJsonWasCalled", "toJSON", "init_serialize_error", "__esmMin", "init_error_constructors", "_NonError", "message", "from", "json", "name", "ErrorConstructor", "errorConstructors", "seen", "to", "forceEnumerable", "depth", "serialize", "continueDestroyCircular", "key", "property", "enumerable", "worker_exports", "__export", "worker_default", "worker", "init_worker", "__esmMin", "name", "value", "arg", "a", "strings", "k", "_v", "level", "appender", "e", "moduleName", "__toESM", "event", "callback", "message", "payload", "send", "error", "init_logger", "importPreload", "log", "module", "preload", "__toESM", "e", "importHandler", "publishFn", "cfg", "factory", "getLogger", "configureLogging", "worker", "logLevel", "startHandler", "arg", "result", "key", "handler", "cleanupArg", "stopHandler", "_log", "cleanup", "attach", "event", "id", "cmd", "ex", "serializeError", "error"] }