@microsoft.azure/autorest-core
Advanced tools
Comparing version 2.0.4152 to 2.0.4154
@@ -213,20 +213,2 @@ "use strict"; | ||
async function RunPipeline(configView, fileSystem) { | ||
// __status scope | ||
const startTime = Date.now(); | ||
configView.Raw.__status = new Proxy({}, { | ||
async get(_, key) { | ||
const expr = new Buffer(key.toString(), "base64").toString("ascii"); | ||
try { | ||
return yaml_1.FastStringify(safe_eval_1.safeEval(expr, { | ||
pipeline: pipeline.pipeline, | ||
tasks: tasks, | ||
startTime: startTime, | ||
blame: (uri, position /*TODO: cleanup, nail type*/) => configView.DataStore.Blame(uri, position) | ||
})); | ||
} | ||
catch (e) { | ||
return "" + e; | ||
} | ||
} | ||
}); | ||
// built-in plugins | ||
@@ -249,2 +231,3 @@ const plugins = { | ||
// dynamically loaded, auto-discovered plugins | ||
const __extensionExtension = {}; | ||
for (const useExtension of configView.UseExtensions) { | ||
@@ -254,4 +237,24 @@ const extension = await configuration_1.GetExtension(useExtension.fullyQualified); | ||
plugins[plugin] = CreatePluginExternal(extension, plugin); | ||
__extensionExtension[plugin] = extension; | ||
} | ||
} | ||
// __status scope | ||
const startTime = Date.now(); | ||
configView.Raw.__status = new Proxy({}, { | ||
async get(_, key) { | ||
const expr = new Buffer(key.toString(), "base64").toString("ascii"); | ||
try { | ||
return yaml_1.FastStringify(safe_eval_1.safeEval(expr, { | ||
pipeline: pipeline.pipeline, | ||
external: __extensionExtension, | ||
tasks: tasks, | ||
startTime: startTime, | ||
blame: (uri, position /*TODO: cleanup, nail type*/) => configView.DataStore.Blame(uri, position) | ||
})); | ||
} | ||
catch (e) { | ||
return "" + e; | ||
} | ||
} | ||
}); | ||
// TODO: think about adding "number of files in scope" kind of validation in between pipeline steps | ||
@@ -258,0 +261,0 @@ const fsInput = configView.DataStore.GetReadThroughScope(fileSystem); |
@@ -5,6 +5,7 @@ /// <reference types="node" /> | ||
import { CancellationToken } from "../ref/cancellation"; | ||
import { MessageConnection } from "../ref/jsonrpc"; | ||
import { DataHandle, DataSink, DataSource } from '../data-store/data-store'; | ||
import { Message } from "../message"; | ||
import { Readable, Writable } from "stream"; | ||
export declare class AutoRestExtension extends EventEmitter { | ||
private extensionName; | ||
private static lastSessionId; | ||
@@ -14,3 +15,4 @@ private static CreateSessionId(); | ||
static FromChildProcess(extensionName: string, childProc: ChildProcess): Promise<AutoRestExtension>; | ||
constructor(extensionName: string, channel: MessageConnection); | ||
private __inspectTraffic; | ||
constructor(extensionName: string, reader: Readable, writer: Writable); | ||
private apiTarget; | ||
@@ -17,0 +19,0 @@ private apiInitiator; |
@@ -14,6 +14,29 @@ "use strict"; | ||
const exception_1 = require("../exception"); | ||
const stream_1 = require("stream"); | ||
class AutoRestExtension extends events_1.EventEmitter { | ||
constructor(extensionName, channel) { | ||
constructor(extensionName, reader, writer) { | ||
super(); | ||
this.extensionName = extensionName; | ||
// Exposed through __status and consumed by tools like autorest-interactive. | ||
this.__inspectTraffic = []; | ||
this.apiInitiatorEndpoints = {}; | ||
// hook in inspectors | ||
reader.on("data", chunk => { | ||
try { | ||
this.__inspectTraffic.push([Date.now(), false, chunk.toString()]); | ||
} | ||
catch (e) { } | ||
}); | ||
const writerProxy = new stream_1.Writable({ | ||
write: (chunk, encoding, callback) => { | ||
try { | ||
this.__inspectTraffic.push([Date.now(), true, chunk.toString()]); | ||
} | ||
catch (e) { } | ||
return writer.write(chunk, encoding, callback); | ||
} | ||
}); | ||
// create channel | ||
const channel = jsonrpc_1.createMessageConnection(reader, writerProxy, console); | ||
channel.listen(); | ||
// initiator | ||
@@ -64,7 +87,4 @@ const dispatcher = (fnName) => async (sessionId, ...rest) => { | ||
static async FromChildProcess(extensionName, childProc) { | ||
// childProc.on("error", err => { throw err; }); | ||
const channel = jsonrpc_1.createMessageConnection(childProc.stdout, childProc.stdin, console); | ||
const plugin = new AutoRestExtension(extensionName, childProc.stdout, childProc.stdin); | ||
childProc.stderr.pipe(process.stderr); | ||
const plugin = new AutoRestExtension(extensionName, channel); | ||
channel.listen(); | ||
// poke the extension to detect trivial issues like process startup failure or protocol violations, ... | ||
@@ -71,0 +91,0 @@ if (!Array.isArray(await plugin.GetPluginNames(cancellation_1.CancellationToken.None))) { |
@@ -347,3 +347,3 @@ "use strict"; | ||
for (const method of methods) { | ||
if (typeof method.obj === "object" && !method.obj[pc]) { | ||
if (typeof method.obj === "object" && !Array.isArray(method.obj) && !method.obj[pc]) { | ||
populate.push(() => method.obj[pc] = yaml_2.Clone(clientPC)); | ||
@@ -350,0 +350,0 @@ mapping.push(...source_map_1.CreateAssignmentMapping(clientPC, inputSwagger.key, [pc], method.path.concat([pc]), `inlining ${pc}`)); |
{ | ||
"name": "@microsoft.azure/autorest-core", | ||
"version": "2.0.4152", | ||
"version": "2.0.4154", | ||
"description": "AutoRest core module", | ||
@@ -5,0 +5,0 @@ "engines": { |
Sorry, the diff of this file is not supported yet
31224728
5568