Skip to content

AnyGridTech/frappe-agt-types

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

123 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🚀 Frappe AGT Typescript

@anygridtech/frappe-agt-types

Status License npm version


This package provides TypeScript definitions for AnyGrid Tech's custom Frappe application.
It extends @anygridtech/frappe-types to add strong typing for custom DocTypes, client scripts, and server-side methods, enabling a modern, type-safe development workflow.


📝 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_field vs frm.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 agt namespaces.
  • ✅ 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):

    • BrazilianInvoiceTaxes
    • ChecklistBattery
    • ChecklistEVCharger
    • ChecklistInverter
    • ChecklistSmartEnergyManager
    • ChecklistSmartMeter
    • ChecklistTable
    • ChecklistTracker
    • ChecklistTransformer
    • Company
    • ComplianceStatement
    • CorrectionsChildList
    • CorrectionsTracker
    • ExternalIssueCode
    • Index
    • InitialAnalysis
    • InvoiceTaxes
    • IssueInverters
    • Item
    • PurchaseOrder
    • SalesOrder
    • SerialNo
    • SerialNoWorkflow
    • StockEntry
    • Ticket
    • Workflow
  • Client-side agt namespace:

    • agt.setup – General setup utility
    • agt.checklist – Checklist management
      • agt.checklist.table
    • agt.corrections_tracker – Corrections tracking
      • agt.corrections_tracker.run
      • agt.corrections_tracker.table
    • agt.growatt – Growatt integrations
    • agt.metadata – Metadata constants
      • agt.metadata.doctype.checklist
      • agt.metadata.doctype.compliance_statement
      • agt.metadata.doctype.initial_analysis
      • agt.metadata.doctype.ticket
    • agt.ui – UI utilities
      • agt.ui.ultra_dialog
    • agt.utils – Utility functions
      • agt.utils.brazil
      • agt.utils.core
      • agt.utils.db
      • agt.utils.dialog
      • agt.utils.doc
      • agt.utils.form
      • agt.utils.table
      • agt.utils.text
    • agt.workflow – Workflow utilities
      • agt.workflow.before_workflow_action
  • Server-side agt.server namespace:

    • agt.server.growatt_oss_api
    • agt.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.sh or install-app.sh.


📥 Installation

  • Create a ts folder at your_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-types

Notice: @anygridtech/frappe-types is a dependency of this project. You do not need to install it separately to have access to frappe type definitions. Installing this package is sufficient to have type definitions for both frappe and agt globals.

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 (or Cmd+Shift+P on Mac) in VSCode and select TypeScript: 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

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors