Zapier Platform
repository·main·Indexed 19 days ago
https://github.com/zapier/zapier-platformA monorepo providing tools, runtimes, and schemas for developers to build, deploy, and manage integrations (apps) on the Zapier platform. It includes the zapier-platform-cli for scaffolding projects via templates, managing triggers and actions, and deploying code using commands like register, link, and push. The repository also provides a Platform Boilerplate for Visual Builder compatibility and various example apps demonstrating authentication methods (Basic, Custom, Digest) and TypeScript integration.
What's inside zapier-platform
- The Zapier Platform monorepo contains the public code used to build and power Zapier apps. It is organized into several key packages that handle CLI operations, runtime functionality, and schema definitions.
What is the Zapier Platform Boilerplate?
mainThe Zapier Platform Boilerplate is a minimal, empty integration project template. It is primarily used to generate a.zipfile containing all the necessary dependencies required for integrations developed using the Zapier Visual Builder. It serves as a foundational structure for ensuring compatibility with the Zapier platform environment.Use the Zapier Platform CLI to build integrations
mainThe
zapier-platformCLI is the primary tool for building Zapier integrations. As of version 19, the CLI exposes only thezapier-platformcommand. Note that the legacyzapierbinary has been removed and should no longer be used.For detailed command usage and schema definitions, refer to the official documentation links provided in the CLI package.
zapier-platformUse the Zapier CLI for integration development
mainThe
zapier-platform-cli(invoked via thezapier-platformcommand) is the primary tool for developers to build and manage integrations on the Zapier platform. It is available on npm aszapier-platform-cli.Key operational details:
- The CLI is used to perform all operations required for integration development.
- The
core,schema, andclipackages are released in synchronized version numbers to ensure compatibility.
# Install via npm npm install -g zapier-platform-cliWhat is zapier-platform-legacy-scripting-runner?
mainThe
zapier-platform-legacy-scripting-runneris a compatibility shim designed to bridge the gap between the legacy v2 platform and the current v3 (CLI) platform. It is primarily used when auto-converting legacy applications to the modern platform to ensure they continue to function correctly.It implements the full suite of features found in the legacy scripting environment, including global functions and specific libraries that were standard in the v2 environment.
Understand the role of `zapier-platform-core`
mainThe
zapier-platform-corepackage acts as the runtime bridge between the Zapier monolith and your developer code. While you may import it for TypeScript types and testing, it is not directlyrequired in your application code. Instead, it runs your app's exposed functions at runtime.Its primary responsibilities include:
- Organizing data passed from the Zapier monolith into your code.
- Maintaining the
zobject, which provides essential utility functions. - Managing command execution (like
executeandvalidate) for compiled apps.
Note: The
core,schema, andclipackages are always released together under matching version numbers.Zapier CLI Command Structure
mainThe Zapier CLI is powered by
oclif. Commands follow a standard pattern where top-level commands and sub-commands are organized into specific files.Examples of command patterns:
- Top-level commands:
zapier-platform push,zapier-platform test. - Sub-commands:
zapier-platform env:get(using colon notation for namespaces).
All commands inherit from
ZapierBaseCommand, which provides built-in methods for:- Parsing flags
- Printing structured data
- Verifying authentication
- Top-level commands:
Use hook-to-poll triggers in Schema
mainAs of version 11.2.0, the schema supports hook-to-poll triggers.Understand zapier-platform-schema as the source of truth
mainThe
zapier-platform-schemapackage serves as the single source of truth for validating the structure of Zapier apps.- Key Output: It produces an
exported-schema.jsonfile. - Usage: This JSON schema is consumed by other packages (like
coreandcli) to ensure that app definitions, triggers, and actions conform to the platform's requirements. - Independence: It is a standalone package that does not depend on other platform packages.
- Key Output: It produces an
Use response.data for parsed JSON and form-encoded bodies in v10+
mainStarting with version 10, Zapier automatically parses JSON and form-encoded response bodies.
- Use
response.datato access the parsed object. response.jsonis still available for JSON bodies but is less preferred.- Breaking Change for
afterResponse: If you have anafterResponsehook that modifiesresponse.contentexpecting shorthand requests to pick up the change, you must switch to assigning the parsed/transformed object toresponse.datainstead (e.g.,response.data = parsedOrTransformed).
- Use
Core functions of the legacy scripting runner
mainThe runner provides several critical mechanisms to maintain backward compatibility:
- Global Function Availability: It uses
compileLegacyScriptingSourceto make the global functions that were standard in the legacy environment available to scripts. - Lifecycle Hook Management: It handles
pre_Xandpost_Xlifecycle hooks via therunEventCombofunction. - Input/Output Compatibility: It ensures that inputs and outputs remain compatible with legacy requirements, even if the modern CLI platform has stricter requirements (e.g., requiring triggers to return arrays).
- Legacy Libraries: It provides individual implementations for legacy-specific utilities, such as
btoaand$(forjQuery).
- Global Function Availability: It uses
Implement dynamic dropdowns using the Trigger-based (Legacy) pattern
mainThe legacy pattern for dynamic dropdowns (also known as dynamic choices) uses a separate trigger to fetch the available choices. You reference the trigger using the
dynamicproperty in your field definition.Format:
"triggerKey.idField.labelField"In this format, Zapier uses the
idFieldas the underlying value and thelabelFieldas the display text for the user.{ key: 'species_id', type: 'integer', label: 'Species', dynamic: 'species.id.name', // Format: "triggerKey.idField.labelField" }