Official 1Password Template Function (#305)

This commit is contained in:
Gregory Schier
2025-11-22 06:08:13 -08:00
committed by GitHub
parent 43a7132014
commit 2bac610efe
20 changed files with 1440 additions and 142 deletions

View File

@@ -1,4 +1,5 @@
import type { AnyModel, HttpUrlParameter } from '@yaakapp-internal/models';
import type { GenericCompletionOption } from '@yaakapp-internal/plugins';
import type { CallTemplateFunctionArgs, Context, PluginDefinition } from '@yaakapp/api';
export const plugin: PluginDefinition = {
@@ -36,6 +37,21 @@ export const plugin: PluginDefinition = {
name: 'header',
label: 'Header Name',
type: 'text',
async dynamic(ctx, args) {
if (typeof args.values.requestId !== 'string') return null;
const request = await ctx.httpRequest.getById({ id: args.values.requestId });
if (request == null) return null;
const validHeaders = request.headers.filter(h => h.enabled !== false && h.name);
return {
placeholder: validHeaders[0]?.name,
completionOptions: validHeaders.map<GenericCompletionOption>((h) => ({
label: h.name,
type: 'constant',
})),
};
},
},
],
async onRender(ctx: Context, args: CallTemplateFunctionArgs): Promise<string | null> {