Fix types

This commit is contained in:
Gregory Schier
2025-01-27 06:06:02 -08:00
parent 22db739413
commit 1d37a15cfe
5 changed files with 6 additions and 19 deletions

View File

@@ -1,6 +1,6 @@
{
"name": "@yaakapp/api",
"version": "0.3.4",
"version": "0.4.0",
"main": "lib/index.js",
"typings": "./lib/index.d.ts",
"files": [

View File

@@ -27,9 +27,8 @@ import { readFileSync, statSync, watch } from 'node:fs';
import path from 'node:path';
import * as util from 'node:util';
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 { migrateHttpRequestActionKey, migrateTemplateFunctionSelectOptions } from './migrations';
import { migrateTemplateFunctionSelectOptions } from './migrations';
if (nullableParentPort == null) {
throw new Error('Worker does not have access to parentPort');
@@ -353,7 +352,7 @@ function initialize(workerData: PluginWorkerData) {
Array.isArray(plug?.httpRequestActions)
) {
const reply: HttpRequestAction[] = plug.httpRequestActions.map((a) => ({
...migrateHttpRequestActionKey(a),
...a,
// Add everything except onSelect
onSelect: undefined,
}));
@@ -449,7 +448,7 @@ function initialize(workerData: PluginWorkerData) {
payload.type === 'call_http_authentication_action_request' &&
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') {
await action.onSelect(ctx, payload.args);
sendEmpty(windowContext, replyId);
@@ -461,9 +460,7 @@ function initialize(workerData: PluginWorkerData) {
payload.type === 'call_http_request_action_request' &&
Array.isArray(plug?.httpRequestActions)
) {
const action = plug.httpRequestActions.find(
(a) => migrateHttpRequestActionKey(a).name === payload.name,
);
const action = plug.httpRequestActions[payload.index];
if (typeof action?.onSelect === 'function') {
await action.onSelect(ctx, payload.args);
sendEmpty(windowContext, replyId);

View File

@@ -1,4 +1,4 @@
import {HttpRequestAction, TemplateFunction} from '@yaakapp/api';
import { TemplateFunction } from '@yaakapp/api';
export function migrateTemplateFunctionSelectOptions(f: TemplateFunction): TemplateFunction {
const migratedArgs = f.args.map((a) => {
@@ -16,10 +16,3 @@ export function migrateTemplateFunctionSelectOptions(f: TemplateFunction): Templ
args: migratedArgs,
};
}
export function migrateHttpRequestActionKey(a: HttpRequestAction): HttpRequestAction {
return {
...a,
name: a.name || (a as any).key,
}
}

View File

@@ -428,7 +428,6 @@ var plugin = {
actions: [
{
label: "Copy Current Token",
name: "copyCurrentToken",
icon: "copy",
async onSelect(ctx, { contextId }) {
const token = await getToken(ctx, contextId);
@@ -442,7 +441,6 @@ var plugin = {
},
{
label: "Delete Token",
name: "clearToken",
icon: "trash",
async onSelect(ctx, { contextId }) {
if (await deleteToken(ctx, contextId)) {

View File

@@ -27,7 +27,6 @@ module.exports = __toCommonJS(src_exports);
var NEWLINE = "\\\n ";
var plugin = {
httpRequestActions: [{
name: "export-curl",
label: "Copy as Curl",
icon: "copy",
async onSelect(ctx, args) {