@anygridtech/frappe-agt-types
v4.0.1
Published
<h1 align="center"> π Frappe AGT Typescript </h1>
Downloads
147
Maintainers
Readme
π Table of Contents
π§ About
While @anygridtech/frappe-types provides core types for the Frappe framework, custom applications introduce their own set of DocTypes and APIs. This package bridges that gap for AnyGrid Tech's specific modules.
Developing without it leads to common issues:
- β Typing mistakes in custom DocType fields (e.g.,
frm.doc.custom_fieldvsfrm.doc.custom_feild) - β No clarity on the shape of custom API responses
- β Fragile code during refactors of custom scripts
- β Poor autocomplete for proprietary functions
With @anygridtech/frappe-agt-types, you get:
- β
Accurate autocompletion for custom DocTypes and
agtnamespaces. - β Compile-time error checking for your client and server scripts.
- β Inline documentation for custom modules.
- β Improved code maintainability and developer experience.
π¦ Whatβs Included?
Type definitions for AnyGrid Tech's custom modules, including:
Custom DocTypes (26 total):
BrazilianInvoiceTaxesChecklistBatteryChecklistEVChargerChecklistInverterChecklistSmartEnergyManagerChecklistSmartMeterChecklistTableChecklistTrackerChecklistTransformerCompanyComplianceStatementCorrectionsChildListCorrectionsTrackerExternalIssueCodeIndexInitialAnalysisInvoiceTaxesIssueInvertersItemPurchaseOrderSalesOrderSerialNoSerialNoWorkflowStockEntryTicketWorkflow
Client-side
agtnamespace:agt.setupβ General setup utilityagt.checklistβ Checklist managementagt.checklist.table
agt.corrections_trackerβ Corrections trackingagt.corrections_tracker.runagt.corrections_tracker.table
agt.growattβ Growatt integrationsagt.metadataβ Metadata constantsagt.metadata.doctype.checklistagt.metadata.doctype.compliance_statementagt.metadata.doctype.initial_analysisagt.metadata.doctype.ticket
agt.uiβ UI utilitiesagt.ui.ultra_dialog
agt.utilsβ Utility functionsagt.utils.brazilagt.utils.coreagt.utils.dbagt.utils.dialogagt.utils.docagt.utils.formagt.utils.tableagt.utils.text
agt.workflowβ Workflow utilitiesagt.workflow.before_workflow_action
Server-side
agt.servernamespace:agt.server.growatt_oss_apiagt.server.growatt_public_api
π§© The list is continuously expanding as the custom application evolves.
π Getting Started
These instructions will help you integrate the custom types into your Frappe TypeScript project.
Prerequisites
- Firstly, you need a working Frappe development environment.
In case you're not familiar, we recommend using our Frappe Custom Apps Development Environment for easier setup.
- After having your working Frappe development environment, you must create a new custom app or use an existing one.
Our Frappe Custom Apps Development Environment includes helper functions for quickly scaffolding apps using
create-app.shorinstall-app.sh.
π₯ Installation
Create a
tsfolder atyour_custom_app/your_custom_app/public/to hold your TypeScript files.Install Typescript and our package via your package manager of choice:
# npm
npm install typescript @anygridtech/frappe-agt-types
# yarn
yarn add typescript @anygridtech/frappe-agt-types
# pnpm
pnpm add typescript @anygridtech/frappe-agt-typesNotice:
@anygridtech/frappe-typesis a dependency of this project. You do not need to install it separately to have access tofrappetype definitions. Installing this package is sufficient to have type definitions for bothfrappeandagtglobals.
This package is designed to work with @anygridtech/frappe-ts-tools. You must set up frappe-ts-tools first:
π Follow @anygridtech/frappe-ts-tools Setup Instructions
The frappe-ts-tools package handles all TypeScript compilation and build configuration automatically.
Reload the TypeScript server to ensure the editor picks up the new types: Hit
Ctrl+Shift+P(orCmd+Shift+Pon Mac) in VSCode and selectTypeScript: Restart TS Server. For other editors, consult your editor's documentation on reloading the language server.Finally, your app folder structure should look similiar to this:
your_custom_app/
βββ your_custom_app/
β βββ public/
| | βββ css/
β β βββ js/
β β βββ ts/
β β βββ node_modules/
β β βββ package-lock.json
β β βββ package.json
β β βββ tsconfig.json
β βββ ...
βββ ...π Usage
After setup, you can use the custom DocType and namespace types with full TypeScript support in your client scripts:
// Example: strong-typed form script while using metadata constants
import { CorrectionsTracker } from "@anygridtech/frappe-agt-types/agt/doctype/CorrectionsTracker";
const status_options = agt.metadata.doctype.corrections_tracker.status;
frappe.ui.form.on<CorrectionsTracker>('Corrections Tracker', {
refresh(frm) {
if (frm.doc.status === status_options.PENDING) {
// ...
}
}
});π€ Contributing
This project is maintained internally by AnyGrid Tech. If you are a developer at AnyGrid, please follow the internal contribution guidelines. For external users, feel free to open an issue if you believe there is a bug.
βοΈ Authors
- @anygridtech β Maintainers
