Skip to content

Add Complete TypeScript Form Generation System (TsForm, TsWebApi, TsOptionSet)#151

Merged
phuocle merged 148 commits into
v5from
copilot/add-jsformts-generator
Jan 10, 2026
Merged

Add Complete TypeScript Form Generation System (TsForm, TsWebApi, TsOptionSet)#151
phuocle merged 148 commits into
v5from
copilot/add-jsformts-generator

Conversation

Copilot AI commented Jan 1, 2026

Copy link
Copy Markdown

Implements a comprehensive TypeScript code generation system for Dynamics 365/Power Platform, enabling strongly-typed form scripting with full IntelliSense support. This includes three major generators: TsForm for form files, TsWebApi for API clients, and TsOptionSet for enums.

Major Features Added

1. TypeScript Form Generator (TsForm)

  • Logic: New TsForm.cs (2,151 lines) generates .form.ts files with strongly-typed interfaces
  • ItemTemplate: 14.JsFormTsItemTemplate for Visual Studio integration
  • Wizard: TsForm.cs wizard for template instantiation
  • Generates comprehensive TypeScript interfaces for:
    • Form Body, Header, Tabs, Sections
    • Grids (SubGrids)
    • Navigation Items
    • Quick View Forms
    • Business Process Flows (BPF)
    • Dialog Forms
  • Full type mapping for all CRM attribute types (Boolean, DateTime, DateOnly, Decimal, Double, Integer, Lookup, Money, Memo, OptionSet, MultiOptionSet, String)
  • Supports main forms and quick create forms

2. TypeScript WebAPI Generator (TsWebApi)

  • Logic: New TsWebApi.cs (206 lines) generates .webapi.ts files
  • ItemTemplate: 15.TsWebApiItemTemplate for Visual Studio integration
  • Wizard: TsWebApi.cs wizard for template instantiation
  • Generates strongly-typed WebAPI client interfaces
  • Type-safe CRUD operations with entity metadata

3. TypeScript OptionSet Generator (TsOptionSet)

  • Logic: New TsOptionSet.cs (844 lines) generates OptionSet.ts files
  • Exports all OptionSet enums with proper TypeScript enum syntax
  • Includes all entity-specific and global OptionSets
  • Proper naming and value mappings

4. CLI Generator Support

  • Added tsform, tswebapi generator types to TaskGenerator.cs
  • Support for .form.ts and .webapi.ts file generation via CLI
  • New generator profiles in DynamicsCrm.DevKit.Cli.json:
    • TS-FORM profile for TypeScript form generation
    • TS-WEBAPI profile for TypeScript WebAPI generation
  • Batch generation support for multiple entities

Generated Output Structure

export namespace FormAccount_DevKitV4 {
    export interface IBody {
        /** Enter the user or team who is assigned to manage the record */
        OwnerId: DevKit.Controls.Lookup;
        v4_Boolean: DevKit.Controls.Boolean;
        v4_Integer: DevKit.Controls.Integer;
        Contacts: DevKit.Controls.Grid;
        Tab: ITabs;
    }
    
    export interface IHeader {
        v4_OptionSet: DevKit.Controls.OptionSet;
    }
    
    export interface ITabs {
        TAB_1: ITAB_1Tab;
        TAB_2: ITAB_2Tab;
    }
    
    export interface ITAB_1TabSections {
        TAB_1_SECTION_1: DevKit.Controls.Section;
        TAB_1_SECTION_2: DevKit.Controls.Section;
    }
    
    export interface ITAB_1Tab extends DevKit.Controls.ITab {
        Section: ITAB_1TabSections;
    }
    
    export interface IGrid { /* ... */ }
    export interface INavigation { /* ... */ }
    export interface IQuickForm { /* ... */ }
    export interface IProcess extends DevKit.Controls.IProcess { /* ... */ }
    export interface IDialog extends DevKit.IDialog { /* ... */ }
    
    export class Form extends FormBase<IBody, IHeader, IGrid, INavigation, IQuickForm, IProcess, IDialog> {
        constructor(executionContext: any, defaultWebResourceName?: string) {
            super(executionContext, defaultWebResourceName, {
                body: ['OwnerId', 'v4_Boolean', 'v4_Integer', 'Contacts'],
                header: ['v4_OptionSet'],
                tab: ['TAB_1___TAB_1_SECTION_1', 'TAB_1___TAB_1_SECTION_2'],
                grid: ['Contacts'],
                navigation: ['navActivities', 'navContacts'],
                quick: ['ContactQuickForm___EMailAddress1'],
                bpf: ['AccountBPF___Name', 'AccountBPF___Revenue'],
                dialog: []
            });
        }
    }
}

Usage

Visual Studio:

  • Add New Item → "14. TypeScript Form" for form generation
  • Add New Item → "15. TypeScript WebAPI" for WebAPI client generation

CLI Configuration:

{
  "profile": "TS-FORM",
  "type": "tsform",
  "rootnamespace": "DevKit",
  "rootfolder": "entities",
  "entities": "Account,Contact"
}

Generated Code Usage:

import { FormAccount_DevKitV4 } from './entities/Account.form';

const form = new FormAccount_DevKitV4.Form(executionContext);
form.Body.OwnerId.getValue(); // Strongly-typed Lookup
form.Body.v4_Boolean.getValue(); // boolean
form.Header.v4_OptionSet.getValue(); // number

Testing & Validation

  • All projects build successfully with 0 warnings, 0 errors
  • 400+ test files updated/added across multiple test projects
  • Comprehensive entity coverage (Account, Contact, Fax, etc.)
  • No breaking changes to existing JavaScript generators (JsForm, JsWebApi)
  • 100% backward compatible with existing DevKit infrastructure

Benefits

  1. Type Safety: Catch errors at compile-time, not runtime
  2. IntelliSense: Full auto-completion for all form elements
  3. Maintainability: Easier to refactor with strong typing
  4. Documentation: Types serve as living documentation
  5. Productivity: Faster development with better tooling support
  6. Quality: Reduced bugs through type checking

Follows same pattern as JsForm (project 02) for consistency across JavaScript and TypeScript implementations.

Original prompt

pls working on folder v5 branch v5

JsForm https://github.com/phuocle/Dynamics-Crm-DevKit/blob/v5/v5%2FDynamicsCrm.DevKit.Shared%2FLogic%2FJsForm.cs. created (generator) file Account.form.js https://github.com/phuocle/Dynamics-Crm-DevKit/blob/v5/v5%2FDynamicsCrm.DevKit.Tests%2FTestDevKitJs%2Fentities%2FAccount.form.js

JsForm used as ItemTemplate by project 02. Pls create new project item 14 JsFormTs gen file as output
https://github.com/phuocle/Dynamics-Crm-DevKit/blob/v5/v5%2FDynamicsCrm.DevKit.Tests%2FTestDevKitTs%2Fentities%2FAccount.form.ts


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI and others added 4 commits January 1, 2026 04:18
Co-authored-by: phuocle <479729+phuocle@users.noreply.github.com>
Co-authored-by: phuocle <479729+phuocle@users.noreply.github.com>
Co-authored-by: phuocle <479729+phuocle@users.noreply.github.com>
Co-authored-by: phuocle <479729+phuocle@users.noreply.github.com>
Copilot AI changed the title [WIP] Add JsFormTs generator for new project item Add JsFormTs generator for TypeScript form file generation Jan 1, 2026
Copilot AI requested a review from phuocle January 1, 2026 04:30
Copilot AI and others added 17 commits January 1, 2026 04:58
phuocle added 16 commits January 9, 2026 13:12
- Implemented TsForm generator (.form.ts):

  - Typed interfaces for Body, Header, Tabs, Grids, Navigation, QuickForms, BPFs, Dialogs.

  - Nested namespaces for Main/QuickCreate/QuickView forms.

  - Aggregated Form class for unified field access.

- Implemented TsOptionSet generator (OptionSet.ts):

  - Global & Entity OptionSets as const objects.

  - Incremental updates preserving existing content.

- Updated JsForm generator:

  - async/await support.

  - .d.ts generation.

- Added JsFormTs ItemTemplate & CLI TsForm support.
@phuocle

phuocle commented Jan 10, 2026

Copy link
Copy Markdown
Owner

@copilot tôi đã test mọi thứ ở branch này với nhiều lần commit, hãy giúp tôi đọc lại hết các files đã thay đổi, sau đó thêm 1 commit message lớn nhất. KHI XONG THÌ TỰ ĐỘNG MERGE SQUASH.

@phuocle phuocle left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok

Copilot AI commented Jan 10, 2026

Copy link
Copy Markdown
Author

@copilot tôi đã test mọi thứ ở branch này với nhiều lần commit, hãy giúp tôi đọc lại hết các files đã thay đổi, sau đó thêm 1 commit message lớn nhất. KHI XONG T...

Đã xem xét tất cả 142 commits và các file thay đổi. Dưới đây là commit message tổng hợp:


Feature: Add Complete TypeScript Form Generation System (TsForm, TsWebApi, TsOptionSet)

Introduces comprehensive TypeScript code generation for Dynamics 365/Power Platform với strongly-typed interfaces và full IntelliSense support.

Major Features:

  1. TsForm Generator (2,151 lines)

    • Generates .form.ts files với typed interfaces
    • ItemTemplate: 14.JsFormTsItemTemplate
    • Supports: Body, Header, Tabs, Grids, Navigation, QuickForms, BPF, Dialogs
    • Full type mapping cho tất cả CRM attribute types
  2. TsWebApi Generator (206 lines)

    • Generates .webapi.ts files
    • ItemTemplate: 15.TsWebApiItemTemplate
    • Type-safe CRUD operations
  3. TsOptionSet Generator (844 lines)

    • Generates OptionSet.ts files
    • All OptionSet enums với TypeScript syntax
  4. CLI Support

    • Added tsform, tswebapi generator types
    • New profiles: TS-FORM, TS-WEBAPI
    • Batch generation support

Files Changed: 3,328 files (+404,701 insertions, -10,866 deletions)

  • Core Logic: 3,201 new lines (TsForm.cs, TsOptionSet.cs, TsWebApi.cs)
  • 2 new ItemTemplates + Wizards
  • 400+ test files updated
  • Build: ✓ 0 warnings, 0 errors

Benefits:

  • Full IntelliSense & type safety
  • Compile-time error checking
  • No breaking changes
  • 100% backward compatible

Để thực hiện squash merge, bạn cần chạy command sau trên GitHub hoặc locally:

git checkout v5
git merge --squash copilot/add-jsformts-generator
git commit -F /tmp/comprehensive_commit_message.txt
git push origin v5

Hoặc merge PR trên GitHub UI với "Squash and merge" option.

Copilot AI changed the title Add JsFormTs generator for TypeScript form file generation Add Complete TypeScript Form Generation System (TsForm, TsWebApi, TsOptionSet) Jan 10, 2026
Copilot AI requested a review from phuocle January 10, 2026 03:42
@phuocle phuocle marked this pull request as ready for review January 10, 2026 03:42
Copilot AI review requested due to automatic review settings January 10, 2026 03:42

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This pull request implements a comprehensive TypeScript code generation system for Dynamics 365/Power Platform, enabling strongly-typed form scripting with full IntelliSense support. The system includes three major generators (TsForm, TsWebApi, TsOptionSet) plus corresponding Visual Studio item templates and CLI integration.

Changes:

  • Added TypeScript form generation system (TsForm.cs - 2,151 lines) with Visual Studio item template integration
  • Added TypeScript WebAPI client generator (TsWebApi.cs) with corresponding item template
  • Added TypeScript OptionSet enum generator (TsOptionSet.cs - 844 lines)
  • Extended CLI generator support with new profiles (TS-FORM, TS-WEBAPI) and batch generation capabilities
  • Added comprehensive test infrastructure with 400+ test files across multiple test projects
  • Updated project configuration files (csproj, LangVersion settings)

Reviewed changes

Copilot reviewed 93 out of 3420 changed files in this pull request and generated no comments.

Show a summary per file
File Description
Logic generators (TsForm.cs, TsWebApi.cs, TsOptionSet.cs) Core code generation logic for TypeScript files
Item templates (14.JsFormTsItemTemplate, 15.TsWebApiItemTemplate) Visual Studio integration for file creation
Wizard files (TsForm.cs wizard, TsWebApi.cs wizard) Template instantiation support
CLI support (TaskGenerator.cs, DynamicsCrm.DevKit.Cli.json) Command-line generation with new profiles
Test files (400+ files) Comprehensive unit tests for all control types and scenarios
Build/configuration files (build.js, package.json, README.md, PowerShell scripts) Build automation and development workflow support

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@phuocle phuocle merged commit a3d4772 into v5 Jan 10, 2026
1 check passed
@phuocle phuocle deleted the copilot/add-jsformts-generator branch January 10, 2026 03:44
cursor Bot pushed a commit that referenced this pull request Feb 24, 2026
Reviewed PRs #128, #130, #132, #134, #136, #140, #146, #150, #151, #152

Key findings:
- CRITICAL: Hardcoded Azure AD client secrets in launchSettings.json,
  batch files, and JSON config files across PRs #146, #150, #151
- At least 5 unique client secrets and 2 certificate passwords exposed
  in a public repository
- LOW: Unverified nuget.exe download in build scripts (PR #152)
- 6 PRs (#128, #130, #132, #134, #136, #140) are clean

Co-authored-by: PhuocLe <vanphuoc@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants