Skip to content

AI Agents & MCPs & AI Workflow Automation • (~400 MCP servers for AI agents) • AI Automation / AI Agent with MCPs • AI Workflows & AI Agents • MCPs for AI Agents

1.6 KB
Raw Blame
import { createAction, Property } from '@activepieces/pieces-framework';
import { HttpMethod } from '@activepieces/pieces-common';
import { ziplinAuth } from '../common/auth';
import { makeRequest } from '../common/client';
import { project_idProp } from '../common/props';

export const findScreen = createAction({
  auth: ziplinAuth,
  name: 'findScreen',
  displayName: 'Find Screen',
  description: 'Find a screen by name or retrieve all screens in a project',
  audience: 'both',
  aiMetadata: { description: 'List screens within a given Zeplin project (by project ID). With a screen name it filters to partial (case-insensitive) title matches; with the name left empty it returns all screens in the project. Use to resolve a screen ID before creating notes or updating a screen. Read-only and idempotent. Note: if the name filter matches nothing, it falls back to returning all screens.', idempotent: true },
  props: {
    projectId: project_idProp,
    screenName: Property.ShortText({
      displayName: 'Screen Name',
      description: 'Optional screen name to search for (partial match)',
      required: false,
    }),
  },
  async run(context) {
    const { projectId, screenName } = context.propsValue;

    const screens = (await makeRequest<any[]>(
      context.auth.secret_text,
      HttpMethod.GET,
      `/projects/${projectId}/screens`
    )) || [];

    if (screenName) {
      const filtered = screens.filter((screen) =>
        screen.title.toLowerCase().includes(screenName.toLowerCase())
      );
      return filtered.length > 0 ? filtered : screens;
    }

    return screens;
  },
});