mirror of
https://github.com/mountain-loop/yaak.git
synced 2026-04-21 00:11:21 +02:00
Websockets for plugin runtime communication (#156)
This commit is contained in:
@@ -113483,30 +113483,30 @@ var require_json_schema_faker = __commonJS({
|
||||
});
|
||||
};
|
||||
exports5.filter = function(plugins, method, file) {
|
||||
return plugins.filter(function(plugin) {
|
||||
return !!getResult(plugin, method, file);
|
||||
return plugins.filter(function(plugin2) {
|
||||
return !!getResult(plugin2, method, file);
|
||||
});
|
||||
};
|
||||
exports5.sort = function(plugins) {
|
||||
plugins.forEach(function(plugin) {
|
||||
plugin.order = plugin.order || Number.MAX_SAFE_INTEGER;
|
||||
plugins.forEach(function(plugin2) {
|
||||
plugin2.order = plugin2.order || Number.MAX_SAFE_INTEGER;
|
||||
});
|
||||
return plugins.sort(function(a, b) {
|
||||
return a.order - b.order;
|
||||
});
|
||||
};
|
||||
exports5.run = function(plugins, method, file) {
|
||||
var plugin, lastError, index = 0;
|
||||
var plugin2, lastError, index = 0;
|
||||
return new Promise(function(resolve2, reject) {
|
||||
runNextPlugin();
|
||||
function runNextPlugin() {
|
||||
plugin = plugins[index++];
|
||||
if (!plugin) {
|
||||
plugin2 = plugins[index++];
|
||||
if (!plugin2) {
|
||||
return reject(lastError);
|
||||
}
|
||||
try {
|
||||
debug(" %s", plugin.name);
|
||||
var result = getResult(plugin, method, file, callback);
|
||||
debug(" %s", plugin2.name);
|
||||
var result = getResult(plugin2, method, file, callback);
|
||||
if (result && typeof result.then === "function") {
|
||||
result.then(onSuccess, onError);
|
||||
} else if (result !== void 0) {
|
||||
@@ -113526,7 +113526,7 @@ var require_json_schema_faker = __commonJS({
|
||||
function onSuccess(result) {
|
||||
debug(" success");
|
||||
resolve2({
|
||||
plugin,
|
||||
plugin: plugin2,
|
||||
result
|
||||
});
|
||||
}
|
||||
@@ -145850,7 +145850,8 @@ var require_openapi_to_postmanv2 = __commonJS({
|
||||
// src/index.ts
|
||||
var src_exports = {};
|
||||
__export(src_exports, {
|
||||
pluginHookImport: () => pluginHookImport2
|
||||
convertOpenApi: () => convertOpenApi,
|
||||
plugin: () => plugin
|
||||
});
|
||||
module.exports = __toCommonJS(src_exports);
|
||||
var import_openapi_to_postmanv2 = __toESM(require_openapi_to_postmanv2());
|
||||
@@ -145859,7 +145860,7 @@ var import_openapi_to_postmanv2 = __toESM(require_openapi_to_postmanv2());
|
||||
var POSTMAN_2_1_0_SCHEMA = "https://schema.getpostman.com/json/collection/v2.1.0/collection.json";
|
||||
var POSTMAN_2_0_0_SCHEMA = "https://schema.getpostman.com/json/collection/v2.0.0/collection.json";
|
||||
var VALID_SCHEMAS = [POSTMAN_2_0_0_SCHEMA, POSTMAN_2_1_0_SCHEMA];
|
||||
function pluginHookImport(_ctx, contents) {
|
||||
function convertPostman(contents) {
|
||||
const root = parseJSONToRecord(contents);
|
||||
if (root == null) return;
|
||||
const info = toRecord(root.info);
|
||||
@@ -146150,7 +146151,16 @@ function generateId(model) {
|
||||
}
|
||||
|
||||
// src/index.ts
|
||||
async function pluginHookImport2(ctx, contents) {
|
||||
var plugin = {
|
||||
importer: {
|
||||
name: "OpenAPI",
|
||||
description: "Import OpenAPI collections",
|
||||
onImport(_ctx, args) {
|
||||
return convertOpenApi(args.text);
|
||||
}
|
||||
}
|
||||
};
|
||||
async function convertOpenApi(contents) {
|
||||
let postmanCollection;
|
||||
try {
|
||||
postmanCollection = await new Promise((resolve, reject) => {
|
||||
@@ -146164,11 +146174,12 @@ async function pluginHookImport2(ctx, contents) {
|
||||
} catch (err) {
|
||||
return void 0;
|
||||
}
|
||||
return pluginHookImport(ctx, JSON.stringify(postmanCollection));
|
||||
return convertPostman(JSON.stringify(postmanCollection));
|
||||
}
|
||||
// Annotate the CommonJS export names for ESM import in node:
|
||||
0 && (module.exports = {
|
||||
pluginHookImport
|
||||
convertOpenApi,
|
||||
plugin
|
||||
});
|
||||
/*! Bundled license information:
|
||||
|
||||
|
||||
Reference in New Issue
Block a user