How delegateas/xrmdefinitelytyped works
Main Components
• CLI / CommandLine Module:
• Located in src/XrmDefinitelyTyped/CommandLine.
• Contains Program.fs and related helper modules. This is the entry point when the tool is executed from the command-line.
• Creation / Generation Modules:
• Modules inside src/XrmDefinitelyTyped/CreateTypeScript handle creation of declaration files for different parts (Forms, Option Sets, Rest entities, etc.).
• The Generation folder (with files such as FileGeneration.fs, GenerationMain.fs) takes an Intermediate Representation and drives file generation.
• Interpretation / Parsing Modules:
• In src/XrmDefinitelyTyped/Interpretation, various modules (e.g., InterpretEntityMetadata.fs, InterpretFormXml.fs) parse and interpret the CRM input (metadata, XML) into an intermediate form.
• CRM Interaction Modules:
• Found in src/XrmDefinitelyTyped/Crm, these modules (e.g., CrmAuth.fs, CrmDataHelper.fs) manage connections and interactions with the CRM system.
• Intermediate Representation / Domain:
• Files like IntermediateRepresentation.fs and Domain.fs capture the core business objects and are used to standardize data between the interpretation and generation phases.
• Configuration / Resources:
• App.config, EnvInfo.config, and resource directories provide necessary configuration and static data (like TS resource templates and SDK definitions).
• Testing & Documentation:
• The test directory holds unit/integration tests (many of which target the various modules), while the docs directory provides guides, usage scenarios, and even template files.
• Build & Automation:
• FAKE scripts (build.fsx, build.cmd) and configuration files (paket.dependencies, paket.lock) orchestrate builds, testing, and releases. This should be represented as a supporting system that automates and integrates the development and deployment process.
Establish Relationships and Data Flow
• The entry point in the CLI/CommandLine module receives user arguments and configuration (from files like App.config). It then calls the relevant modules based on the intended work (for example, generating declaration files for forms, option sets, or entities).
• The Interpretation modules retrieve metadata or CRM export data (e.g., XML form definitions) and process them into an Intermediate Representation.
• This Intermediate Representation is then fed into the Generation modules where it is used to generate TypeScript declaration files (via modules in the CreateTypeScript folder).
• Some modules in the CRM folder might be used earlier in the process for authentication and data retrieval to support the interpretation stage.
• Testing components are designed to simulate or verify these data flows—from command parsing to file generation—ensuring that each module works as expected.
Important Architectural Patterns & Design Principles
• Modular Separation of Concerns:
• The project clearly separates command-line interaction, interpretation/parsing, data transformation (into IR), and file generation.
• Layered Architecture:
• There is a natural pipeline (input → parsing/interpretation → transformation/IR → generation → output) that can be clearly depicted.
• Extensibility:
• The specialized modules (such as those for creating TypeScript definitions for various CRM components) highlight a design that can be extended as new types or metadata formats arise.
• Build and Test Automation:
• FAKE and related scripts are central to the build process and continuous integration, streamlining development.
Relevant Technologies and Tools
• F# as the main programming language.
• .NET Framework and Visual Studio for development.
• Node.js and npm for testing (especially the test project with npm scripts).
• FAKE for build automation.
• Paket as the dependency manager.
• TypeScript for the output files being generated.