mirror of
https://github.com/mountain-loop/yaak.git
synced 2026-05-30 03:10:43 +02:00
Fix types
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@yaakapp/api",
|
"name": "@yaakapp/api",
|
||||||
"version": "0.3.4",
|
"version": "0.4.0",
|
||||||
"main": "lib/index.js",
|
"main": "lib/index.js",
|
||||||
"typings": "./lib/index.d.ts",
|
"typings": "./lib/index.d.ts",
|
||||||
"files": [
|
"files": [
|
||||||
|
|||||||
@@ -27,9 +27,8 @@ import { readFileSync, statSync, watch } from 'node:fs';
|
|||||||
import path from 'node:path';
|
import path from 'node:path';
|
||||||
import * as util from 'node:util';
|
import * as util from 'node:util';
|
||||||
import { parentPort as nullableParentPort, workerData } from 'node:worker_threads';
|
import { parentPort as nullableParentPort, workerData } from 'node:worker_threads';
|
||||||
import Promise from '../../../../../Library/Caches/deno/npm/registry.npmjs.org/any-promise/1.3.0';
|
|
||||||
import { interceptStdout } from './interceptStdout';
|
import { interceptStdout } from './interceptStdout';
|
||||||
import { migrateHttpRequestActionKey, migrateTemplateFunctionSelectOptions } from './migrations';
|
import { migrateTemplateFunctionSelectOptions } from './migrations';
|
||||||
|
|
||||||
if (nullableParentPort == null) {
|
if (nullableParentPort == null) {
|
||||||
throw new Error('Worker does not have access to parentPort');
|
throw new Error('Worker does not have access to parentPort');
|
||||||
@@ -353,7 +352,7 @@ function initialize(workerData: PluginWorkerData) {
|
|||||||
Array.isArray(plug?.httpRequestActions)
|
Array.isArray(plug?.httpRequestActions)
|
||||||
) {
|
) {
|
||||||
const reply: HttpRequestAction[] = plug.httpRequestActions.map((a) => ({
|
const reply: HttpRequestAction[] = plug.httpRequestActions.map((a) => ({
|
||||||
...migrateHttpRequestActionKey(a),
|
...a,
|
||||||
// Add everything except onSelect
|
// Add everything except onSelect
|
||||||
onSelect: undefined,
|
onSelect: undefined,
|
||||||
}));
|
}));
|
||||||
@@ -449,7 +448,7 @@ function initialize(workerData: PluginWorkerData) {
|
|||||||
payload.type === 'call_http_authentication_action_request' &&
|
payload.type === 'call_http_authentication_action_request' &&
|
||||||
plug?.authentication != null
|
plug?.authentication != null
|
||||||
) {
|
) {
|
||||||
const action = plug.authentication.actions?.find((a) => a.name === payload.name);
|
const action = plug.authentication.actions?.[payload.index];
|
||||||
if (typeof action?.onSelect === 'function') {
|
if (typeof action?.onSelect === 'function') {
|
||||||
await action.onSelect(ctx, payload.args);
|
await action.onSelect(ctx, payload.args);
|
||||||
sendEmpty(windowContext, replyId);
|
sendEmpty(windowContext, replyId);
|
||||||
@@ -461,9 +460,7 @@ function initialize(workerData: PluginWorkerData) {
|
|||||||
payload.type === 'call_http_request_action_request' &&
|
payload.type === 'call_http_request_action_request' &&
|
||||||
Array.isArray(plug?.httpRequestActions)
|
Array.isArray(plug?.httpRequestActions)
|
||||||
) {
|
) {
|
||||||
const action = plug.httpRequestActions.find(
|
const action = plug.httpRequestActions[payload.index];
|
||||||
(a) => migrateHttpRequestActionKey(a).name === payload.name,
|
|
||||||
);
|
|
||||||
if (typeof action?.onSelect === 'function') {
|
if (typeof action?.onSelect === 'function') {
|
||||||
await action.onSelect(ctx, payload.args);
|
await action.onSelect(ctx, payload.args);
|
||||||
sendEmpty(windowContext, replyId);
|
sendEmpty(windowContext, replyId);
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import {HttpRequestAction, TemplateFunction} from '@yaakapp/api';
|
import { TemplateFunction } from '@yaakapp/api';
|
||||||
|
|
||||||
export function migrateTemplateFunctionSelectOptions(f: TemplateFunction): TemplateFunction {
|
export function migrateTemplateFunctionSelectOptions(f: TemplateFunction): TemplateFunction {
|
||||||
const migratedArgs = f.args.map((a) => {
|
const migratedArgs = f.args.map((a) => {
|
||||||
@@ -16,10 +16,3 @@ export function migrateTemplateFunctionSelectOptions(f: TemplateFunction): Templ
|
|||||||
args: migratedArgs,
|
args: migratedArgs,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
export function migrateHttpRequestActionKey(a: HttpRequestAction): HttpRequestAction {
|
|
||||||
return {
|
|
||||||
...a,
|
|
||||||
name: a.name || (a as any).key,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -428,7 +428,6 @@ var plugin = {
|
|||||||
actions: [
|
actions: [
|
||||||
{
|
{
|
||||||
label: "Copy Current Token",
|
label: "Copy Current Token",
|
||||||
name: "copyCurrentToken",
|
|
||||||
icon: "copy",
|
icon: "copy",
|
||||||
async onSelect(ctx, { contextId }) {
|
async onSelect(ctx, { contextId }) {
|
||||||
const token = await getToken(ctx, contextId);
|
const token = await getToken(ctx, contextId);
|
||||||
@@ -442,7 +441,6 @@ var plugin = {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: "Delete Token",
|
label: "Delete Token",
|
||||||
name: "clearToken",
|
|
||||||
icon: "trash",
|
icon: "trash",
|
||||||
async onSelect(ctx, { contextId }) {
|
async onSelect(ctx, { contextId }) {
|
||||||
if (await deleteToken(ctx, contextId)) {
|
if (await deleteToken(ctx, contextId)) {
|
||||||
|
|||||||
@@ -27,7 +27,6 @@ module.exports = __toCommonJS(src_exports);
|
|||||||
var NEWLINE = "\\\n ";
|
var NEWLINE = "\\\n ";
|
||||||
var plugin = {
|
var plugin = {
|
||||||
httpRequestActions: [{
|
httpRequestActions: [{
|
||||||
name: "export-curl",
|
|
||||||
label: "Copy as Curl",
|
label: "Copy as Curl",
|
||||||
icon: "copy",
|
icon: "copy",
|
||||||
async onSelect(ctx, args) {
|
async onSelect(ctx, args) {
|
||||||
|
|||||||
Reference in New Issue
Block a user