forgify
v1.2.0
Published
Javascript source code parser with the goal of parsing vuex
Downloads
72
Readme
Forgify
Forgify is a powerful tool that streamlines the creation of extensibility SDKs, automating the integration between platform applications and plugins using iframe-based messaging. By generating SDK files for both client and server from popular state management solutions like Redux, Vuex, and Pinia, Forgify simplifies adding plugins to your platform.
Overview
Forgify inspects your state management setup (e.g., Redux, Vuex, or Pinia), generating an SDK that includes a client-side JavaScript file and a server-side component to facilitate communication. The SDK allows plugins to interact with your application's state (getters, actions, mutations) through well-defined extension points, eliminating the need for manual SDK setup.
This SDK generation simplifies adding custom plugins or modules to your platform by providing a standardized interface for communication and state management.
Key Features
- Automated SDK Generation: Scans client stores and produces client SDKs and server components.
- Bidirectional Messaging: Allows plugins to send and receive messages using
postMessage()
protocol. - Extensibility API: Supports plugin registration at predefined extension points (e.g., sidebars, toolbars).
- State Access: Provides direct access to store actions, getters, and mutations from plugins.
- Role-Based Permissioning: Manage different SDK variants based on user roles.
- TypeScript Support: Full TypeScript support for SDK generation and client-server interactions.
- Comment-Based Documentation: Automatically extracts and documents param types from store comments.
Installation
Install Forgify in your project:
yarn add forgify
Usage
In this example, we’ll demonstrate using Forgify with a platform named Vulcan, a plugin publisher.
Generate SDK
Run the SDK generation tool and provide inputs like namespace
and extension points
. This will generate the SDK files in the directory matching the given namespace.
yarn forgify
Example:
Input: namespace: vulcan, register points: left-sidebar, right-sidebar
Output:
vulcan.client.js
: The client SDK file, will be shared publicly to developers.SdkServer.vue
: Server component to manage iframe communication, will be kept private in your client side code.vulcan.json
: Configuration file containing SDK settings.
Use a pre-configured JSON file:
You can also use a JSON configuration file to specify SDK parameters.
yarn forgify --json config.json
TODO: Sample config
Comment-Based Parameter Documentation
For better documentation, include structured comments within your store code to describe SDK methods:
/**
* Sets the loading state.
* @param {boolean} loading - Whether the app is loading.
*/
Forgify will incorporate this documentation in the generated SDK output, providing clear, consistent parameter documentation.
Role-Based Permission Management
Generate SDKs with role-specific configurations, such as internal, partner, and public, each containing allowed actions and extension points for that role.
yarn forgify --map config_folder/
TODO: Sample config
Build & Publish
Build: Compile TypeScript files.
npx tsc
Publish: Publish your SDK package to NPM.
npm publish
License
MIT