@xrmforge/typegen 0.8.4 → 0.8.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (44) hide show
  1. package/LICENSE +21 -21
  2. package/MIGRATION.md +194 -194
  3. package/dist/index.d.ts +7 -0
  4. package/dist/index.js +46 -4
  5. package/dist/index.js.map +1 -1
  6. package/docs/architecture/00-README.md +26 -26
  7. package/docs/architecture/01-executive-summary.md +11 -11
  8. package/docs/architecture/02-packages.md +110 -110
  9. package/docs/architecture/03-generated-types.md +172 -172
  10. package/docs/architecture/04-cli.md +58 -58
  11. package/docs/architecture/05-build.md +50 -50
  12. package/docs/architecture/06-incremental.md +42 -42
  13. package/docs/architecture/07-http-client.md +59 -59
  14. package/docs/architecture/08-authentication.md +18 -18
  15. package/docs/architecture/09-testing.md +55 -55
  16. package/docs/architecture/10-eslint-plugin.md +82 -82
  17. package/docs/architecture/11-agent-md.md +38 -38
  18. package/docs/architecture/12-xrm-pitfalls.md +14 -14
  19. package/docs/architecture/13-helpers.md +50 -50
  20. package/docs/architecture/14-showcases.md +21 -21
  21. package/docs/architecture/15-ci-cd.md +49 -49
  22. package/docs/architecture/16-technical-debt.md +17 -17
  23. package/docs/architecture/17-roadmap.md +25 -25
  24. package/docs/architecture/18-design-principles.md +22 -22
  25. package/docs/architektur/00-README.md +26 -26
  26. package/docs/architektur/01-zusammenfassung.md +11 -11
  27. package/docs/architektur/02-packages.md +110 -110
  28. package/docs/architektur/03-generierte-typen.md +172 -172
  29. package/docs/architektur/04-cli.md +58 -58
  30. package/docs/architektur/05-build.md +50 -50
  31. package/docs/architektur/06-inkrementell.md +42 -42
  32. package/docs/architektur/07-http-client.md +59 -59
  33. package/docs/architektur/08-authentifizierung.md +18 -18
  34. package/docs/architektur/09-testing.md +55 -55
  35. package/docs/architektur/10-eslint-plugin.md +82 -82
  36. package/docs/architektur/11-agent-md.md +38 -38
  37. package/docs/architektur/12-xrm-fallstricke.md +14 -14
  38. package/docs/architektur/13-helpers.md +50 -50
  39. package/docs/architektur/14-showcases.md +21 -21
  40. package/docs/architektur/15-ci-cd.md +49 -49
  41. package/docs/architektur/16-technische-schulden.md +17 -17
  42. package/docs/architektur/17-roadmap.md +25 -25
  43. package/docs/architektur/18-designprinzipien.md +22 -22
  44. package/package.json +1 -1
package/LICENSE CHANGED
@@ -1,21 +1,21 @@
1
- MIT License
2
-
3
- Copyright (c) 2026 XrmForge Contributors
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
1
+ MIT License
2
+
3
+ Copyright (c) 2026 XrmForge Contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/MIGRATION.md CHANGED
@@ -1,194 +1,194 @@
1
- # XrmForge Migration Guide
2
-
3
- How to convert legacy Dynamics 365 JavaScript to type-safe TypeScript with XrmForge.
4
-
5
- ## Breaking Changes in v0.8.0 (ES Module Output)
6
-
7
- ### What changed
8
- - Generated files are now `.ts` modules with `export` statements instead of `.d.ts` files with `declare namespace`
9
- - Default output directory changed from `./typings` to `./generated`
10
- - Entity Fields enums are now generated in a separate `fields/` directory
11
- - Action declarations and runtime code are now in a single `.ts` file per group
12
- - The barrel index uses `export * from` instead of `/// <reference path />`
13
-
14
- ### Migration steps
15
- 1. Update your `xrmforge generate` command: replace `--output ./typings` with `--output ./generated` (or omit for the new default)
16
- 2. Replace namespace access with imports:
17
- ```typescript
18
- // Before (v0.7.x):
19
- type AccountForm = XrmForge.Forms.Account.AccountMainForm;
20
-
21
- // After (v0.8.0):
22
- import type { AccountMainForm } from './generated/forms/account.js';
23
- ```
24
- 3. Update your tsconfig.json: replace `"typings/**/*.d.ts"` in `include` with `"generated/**/*.ts"`
25
- 4. Entity Fields enums are now available:
26
- ```typescript
27
- import { AccountFields } from './generated/fields/account.js';
28
- const result = await Xrm.WebApi.retrieveRecord('account', id, `?$select=${AccountFields.Name},${AccountFields.Telephone1}`);
29
- ```
30
-
31
- ## Breaking Changes in v0.7.0
32
-
33
- - The `@xrmforge/typegen/helpers` subpath export has been removed.
34
- - All browser-safe runtime code (`select`, `parseLookup`, `parseFormattedValue`,
35
- `withProgress`, Xrm constants, Action/Function executors, `typedForm`) is now
36
- in the new package `@xrmforge/helpers`.
37
- - Update imports: `import { select } from '@xrmforge/typegen/helpers'` becomes
38
- `import { select } from '@xrmforge/helpers'`.
39
- - `@xrmforge/formhelpers` has been removed. `typedForm()` is now in
40
- `@xrmforge/helpers`.
41
-
42
- ## Step 1: Initialize Project
43
-
44
- ```bash
45
- npx @xrmforge/cli init my-project --prefix contoso
46
- cd my-project
47
- npm install
48
- ```
49
-
50
- ## Step 2: Generate Types from Dataverse
51
-
52
- ```bash
53
- npx xrmforge generate \
54
- --url https://YOUR-ORG.crm4.dynamics.com \
55
- --auth interactive \
56
- --tenant-id YOUR-TENANT-ID \
57
- --client-id YOUR-CLIENT-ID \
58
- --entities account,contact,opportunity \
59
- --output ./generated
60
- ```
61
-
62
- This generates:
63
- - `generated/entities/*.ts` - Entity interfaces with typed attributes
64
- - `generated/forms/*.ts` - Form interfaces with Fields enum, Tabs enum, Subgrid enum
65
- - `generated/optionsets/*.ts` - OptionSet const enums with labels
66
- - `generated/fields/*.ts` - Entity Fields enums for type-safe $select queries
67
- - `generated/entity-names.ts` - EntityNames const enum
68
-
69
- ## Step 3: Convert Form Scripts
70
-
71
- ### Before (legacy JavaScript):
72
-
73
- ```javascript
74
- // account.js - global functions, raw strings, no type safety
75
- var LM = LM || {};
76
- LM.Account = {
77
- onLoad: function(executionContext) {
78
- var formContext = executionContext.getFormContext();
79
- var name = formContext.getAttribute("name"); // generic Attribute
80
- var status = formContext.getAttribute("statuscode");
81
- if (status.getValue() === 1) { // magic number!
82
- formContext.getControl("revenue").setVisible(true);
83
- }
84
- }
85
- };
86
- ```
87
-
88
- ### After (XrmForge TypeScript):
89
-
90
- ```typescript
91
- // account-form.ts - typed, safe, autocomplete everywhere
92
- import { AccountMainFormFieldsEnum as Fields } from '../../generated/forms/account.js';
93
- import type { AccountMainForm } from '../../generated/forms/account.js';
94
- import { StatusCode } from '../../generated/optionsets/account.js';
95
-
96
- export function onLoad(executionContext: Xrm.Events.EventContext): void {
97
- const form = executionContext.getFormContext() as AccountMainForm;
98
-
99
- // Fields enum: compile error on typos, autocomplete in IDE
100
- const name = form.getAttribute(Fields.AccountName); // StringAttribute, not generic
101
- const status = form.getAttribute(Fields.StatusCode); // OptionSetAttribute
102
-
103
- // OptionSet enum: no magic numbers
104
- if (status.getValue() === StatusCode.Active) {
105
- form.getControl(Fields.Revenue).setVisible(true);
106
- }
107
- }
108
- ```
109
-
110
- ### Key Differences:
111
-
112
- | Legacy | XrmForge |
113
- |--------|----------|
114
- | `getAttribute("name")` | `getAttribute(Fields.AccountName)` |
115
- | `getValue() === 1` | `getValue() === OptionSets.StatusCode.Active` |
116
- | `formContext` (untyped) | `form as AccountMainForm` (typed) |
117
- | `getControl("revenue")` | `getControl(Fields.Revenue)` |
118
- | No compile-time checks | Typos are compile errors |
119
-
120
- ## Step 4: Replace Common Patterns
121
-
122
- ### Lookup Values
123
-
124
- ```typescript
125
- // Before:
126
- var value = formContext.getAttribute("primarycontactid").getValue();
127
- var id = value[0].id.replace("{","").replace("}","");
128
-
129
- // After: use parseLookup from @xrmforge/helpers
130
- import { parseLookup } from '@xrmforge/helpers';
131
- const contact = parseLookup(form.getAttribute(Fields.PrimaryContactId));
132
- if (contact) {
133
- console.log(contact.id); // already clean GUID
134
- }
135
- ```
136
-
137
- ### Web API Queries
138
-
139
- ```typescript
140
- // Before:
141
- Xrm.WebApi.retrieveMultipleRecords("account",
142
- "?$select=name,revenue&$filter=statecode eq 0");
143
-
144
- // After: use Fields enum for $select
145
- import { select } from '@xrmforge/helpers';
146
- import { AccountFields } from '../../generated/fields/account.js';
147
- Xrm.WebApi.retrieveMultipleRecords("account",
148
- `?$select=${select(AccountFields.Name, AccountFields.Revenue)}&$filter=statecode eq 0`);
149
- ```
150
-
151
- ### Form Testing
152
-
153
- ```typescript
154
- // Before: no tests, or complex manual mocks
155
-
156
- // After: @xrmforge/testing
157
- import { createFormMock, fireOnChange } from '@xrmforge/testing';
158
- import type { AccountMainForm, AccountMainFormMockValues } from '../../generated/forms/account.js';
159
-
160
- const mock = createFormMock<AccountMainForm, AccountMainFormMockValues>({
161
- name: 'Contoso Ltd',
162
- revenue: 1000000,
163
- statuscode: 1,
164
- });
165
-
166
- onLoad(mock.executionContext);
167
- expect(mock.formContext.getControl('revenue').getVisible()).toBe(true);
168
- ```
169
-
170
- ## Step 5: Build
171
-
172
- ```bash
173
- npx xrmforge build # IIFE bundles for D365
174
- npx xrmforge build --watch # Watch mode
175
- ```
176
-
177
- ## Step 6: Replace Magic Numbers
178
-
179
- Search your code for patterns like:
180
- - `getValue() === 123` or `getValue() !== 456`
181
- - `setValue("statuscode", 1)`
182
- - Raw OptionSet values in if/switch statements
183
-
184
- Replace with generated const enums from `generated/optionsets/`.
185
-
186
- ## Checklist
187
-
188
- - [ ] All `getAttribute("string")` calls use Fields enum
189
- - [ ] All OptionSet comparisons use const enums (no magic numbers)
190
- - [ ] All `Xrm.Page` calls replaced with `formContext`
191
- - [ ] Form scripts export functions (not global namespace objects)
192
- - [ ] Each form script has tests using `@xrmforge/testing`
193
- - [ ] `xrmforge build` produces IIFE bundles
194
- - [ ] `tsc --noEmit` passes with zero errors
1
+ # XrmForge Migration Guide
2
+
3
+ How to convert legacy Dynamics 365 JavaScript to type-safe TypeScript with XrmForge.
4
+
5
+ ## Breaking Changes in v0.8.0 (ES Module Output)
6
+
7
+ ### What changed
8
+ - Generated files are now `.ts` modules with `export` statements instead of `.d.ts` files with `declare namespace`
9
+ - Default output directory changed from `./typings` to `./generated`
10
+ - Entity Fields enums are now generated in a separate `fields/` directory
11
+ - Action declarations and runtime code are now in a single `.ts` file per group
12
+ - The barrel index uses `export * from` instead of `/// <reference path />`
13
+
14
+ ### Migration steps
15
+ 1. Update your `xrmforge generate` command: replace `--output ./typings` with `--output ./generated` (or omit for the new default)
16
+ 2. Replace namespace access with imports:
17
+ ```typescript
18
+ // Before (v0.7.x):
19
+ type AccountForm = XrmForge.Forms.Account.AccountMainForm;
20
+
21
+ // After (v0.8.0):
22
+ import type { AccountMainForm } from './generated/forms/account.js';
23
+ ```
24
+ 3. Update your tsconfig.json: replace `"typings/**/*.d.ts"` in `include` with `"generated/**/*.ts"`
25
+ 4. Entity Fields enums are now available:
26
+ ```typescript
27
+ import { AccountFields } from './generated/fields/account.js';
28
+ const result = await Xrm.WebApi.retrieveRecord('account', id, `?$select=${AccountFields.Name},${AccountFields.Telephone1}`);
29
+ ```
30
+
31
+ ## Breaking Changes in v0.7.0
32
+
33
+ - The `@xrmforge/typegen/helpers` subpath export has been removed.
34
+ - All browser-safe runtime code (`select`, `parseLookup`, `parseFormattedValue`,
35
+ `withProgress`, Xrm constants, Action/Function executors, `typedForm`) is now
36
+ in the new package `@xrmforge/helpers`.
37
+ - Update imports: `import { select } from '@xrmforge/typegen/helpers'` becomes
38
+ `import { select } from '@xrmforge/helpers'`.
39
+ - `@xrmforge/formhelpers` has been removed. `typedForm()` is now in
40
+ `@xrmforge/helpers`.
41
+
42
+ ## Step 1: Initialize Project
43
+
44
+ ```bash
45
+ npx @xrmforge/cli init my-project --prefix contoso
46
+ cd my-project
47
+ npm install
48
+ ```
49
+
50
+ ## Step 2: Generate Types from Dataverse
51
+
52
+ ```bash
53
+ npx xrmforge generate \
54
+ --url https://YOUR-ORG.crm4.dynamics.com \
55
+ --auth interactive \
56
+ --tenant-id YOUR-TENANT-ID \
57
+ --client-id YOUR-CLIENT-ID \
58
+ --entities account,contact,opportunity \
59
+ --output ./generated
60
+ ```
61
+
62
+ This generates:
63
+ - `generated/entities/*.ts` - Entity interfaces with typed attributes
64
+ - `generated/forms/*.ts` - Form interfaces with Fields enum, Tabs enum, Subgrid enum
65
+ - `generated/optionsets/*.ts` - OptionSet const enums with labels
66
+ - `generated/fields/*.ts` - Entity Fields enums for type-safe $select queries
67
+ - `generated/entity-names.ts` - EntityNames const enum
68
+
69
+ ## Step 3: Convert Form Scripts
70
+
71
+ ### Before (legacy JavaScript):
72
+
73
+ ```javascript
74
+ // account.js - global functions, raw strings, no type safety
75
+ var LM = LM || {};
76
+ LM.Account = {
77
+ onLoad: function(executionContext) {
78
+ var formContext = executionContext.getFormContext();
79
+ var name = formContext.getAttribute("name"); // generic Attribute
80
+ var status = formContext.getAttribute("statuscode");
81
+ if (status.getValue() === 1) { // magic number!
82
+ formContext.getControl("revenue").setVisible(true);
83
+ }
84
+ }
85
+ };
86
+ ```
87
+
88
+ ### After (XrmForge TypeScript):
89
+
90
+ ```typescript
91
+ // account-form.ts - typed, safe, autocomplete everywhere
92
+ import { AccountMainFormFieldsEnum as Fields } from '../../generated/forms/account.js';
93
+ import type { AccountMainForm } from '../../generated/forms/account.js';
94
+ import { StatusCode } from '../../generated/optionsets/account.js';
95
+
96
+ export function onLoad(executionContext: Xrm.Events.EventContext): void {
97
+ const form = executionContext.getFormContext() as AccountMainForm;
98
+
99
+ // Fields enum: compile error on typos, autocomplete in IDE
100
+ const name = form.getAttribute(Fields.AccountName); // StringAttribute, not generic
101
+ const status = form.getAttribute(Fields.StatusCode); // OptionSetAttribute
102
+
103
+ // OptionSet enum: no magic numbers
104
+ if (status.getValue() === StatusCode.Active) {
105
+ form.getControl(Fields.Revenue).setVisible(true);
106
+ }
107
+ }
108
+ ```
109
+
110
+ ### Key Differences:
111
+
112
+ | Legacy | XrmForge |
113
+ |--------|----------|
114
+ | `getAttribute("name")` | `getAttribute(Fields.AccountName)` |
115
+ | `getValue() === 1` | `getValue() === OptionSets.StatusCode.Active` |
116
+ | `formContext` (untyped) | `form as AccountMainForm` (typed) |
117
+ | `getControl("revenue")` | `getControl(Fields.Revenue)` |
118
+ | No compile-time checks | Typos are compile errors |
119
+
120
+ ## Step 4: Replace Common Patterns
121
+
122
+ ### Lookup Values
123
+
124
+ ```typescript
125
+ // Before:
126
+ var value = formContext.getAttribute("primarycontactid").getValue();
127
+ var id = value[0].id.replace("{","").replace("}","");
128
+
129
+ // After: use parseLookup from @xrmforge/helpers
130
+ import { parseLookup } from '@xrmforge/helpers';
131
+ const contact = parseLookup(form.getAttribute(Fields.PrimaryContactId));
132
+ if (contact) {
133
+ console.log(contact.id); // already clean GUID
134
+ }
135
+ ```
136
+
137
+ ### Web API Queries
138
+
139
+ ```typescript
140
+ // Before:
141
+ Xrm.WebApi.retrieveMultipleRecords("account",
142
+ "?$select=name,revenue&$filter=statecode eq 0");
143
+
144
+ // After: use Fields enum for $select
145
+ import { select } from '@xrmforge/helpers';
146
+ import { AccountFields } from '../../generated/fields/account.js';
147
+ Xrm.WebApi.retrieveMultipleRecords("account",
148
+ `?$select=${select(AccountFields.Name, AccountFields.Revenue)}&$filter=statecode eq 0`);
149
+ ```
150
+
151
+ ### Form Testing
152
+
153
+ ```typescript
154
+ // Before: no tests, or complex manual mocks
155
+
156
+ // After: @xrmforge/testing
157
+ import { createFormMock, fireOnChange } from '@xrmforge/testing';
158
+ import type { AccountMainForm, AccountMainFormMockValues } from '../../generated/forms/account.js';
159
+
160
+ const mock = createFormMock<AccountMainForm, AccountMainFormMockValues>({
161
+ name: 'Contoso Ltd',
162
+ revenue: 1000000,
163
+ statuscode: 1,
164
+ });
165
+
166
+ onLoad(mock.executionContext);
167
+ expect(mock.formContext.getControl('revenue').getVisible()).toBe(true);
168
+ ```
169
+
170
+ ## Step 5: Build
171
+
172
+ ```bash
173
+ npx xrmforge build # IIFE bundles for D365
174
+ npx xrmforge build --watch # Watch mode
175
+ ```
176
+
177
+ ## Step 6: Replace Magic Numbers
178
+
179
+ Search your code for patterns like:
180
+ - `getValue() === 123` or `getValue() !== 456`
181
+ - `setValue("statuscode", 1)`
182
+ - Raw OptionSet values in if/switch statements
183
+
184
+ Replace with generated const enums from `generated/optionsets/`.
185
+
186
+ ## Checklist
187
+
188
+ - [ ] All `getAttribute("string")` calls use Fields enum
189
+ - [ ] All OptionSet comparisons use const enums (no magic numbers)
190
+ - [ ] All `Xrm.Page` calls replaced with `formContext`
191
+ - [ ] Form scripts export functions (not global namespace objects)
192
+ - [ ] Each form script has tests using `@xrmforge/testing`
193
+ - [ ] `xrmforge build` produces IIFE bundles
194
+ - [ ] `tsc --noEmit` passes with zero errors
package/dist/index.d.ts CHANGED
@@ -1654,6 +1654,13 @@ declare class TypeGenerationOrchestrator {
1654
1654
  * Maps the raw EntityTypeInfo data to the format expected by the OptionSet generator.
1655
1655
  */
1656
1656
  private getPicklistAttributes;
1657
+ /**
1658
+ * Generate a form-mapping.json that maps entity names to their generated
1659
+ * form interface names, fields enums, and tabs enums.
1660
+ *
1661
+ * This helps AI agents find the correct interface names without guessing.
1662
+ */
1663
+ private generateFormMapping;
1657
1664
  }
1658
1665
 
1659
1666
  export { type ActionGeneratorOptions, ApiRequestError, type AttributeMetadata, type AuthConfig, type AuthMethod, AuthenticationError, type CacheStats, type ChangeDetectionResult, ChangeDetector, type ClientCredentialsAuth, ConfigError, ConsoleLogSink, type CustomApiTypeInfo, DEFAULT_LABEL_CONFIG, DataverseHttpClient, type DateTimeAttributeMetadata, type DecimalAttributeMetadata, type DeviceCodeAuth, type EntityFieldsGeneratorOptions, type EntityGenerationResult, type EntityGeneratorOptions, type EntityMetadata, type EntityNamesGeneratorOptions, type EntityTypeInfo, ErrorCode, FastXmlParser, type FormControl, type FormGeneratorOptions, type FormSection, type FormTab, type GenerateConfig, type GeneratedFile, GenerationError, type GenerationResult, type GroupedCustomApis, type HttpClientOptions, type IntegerAttributeMetadata, type InteractiveAuth, JsonLogSink, type Label, type LabelConfig, type LocalizedLabel, type LogEntry, LogLevel, type LogSink, Logger, type LookupAttributeMetadata, type ManyToManyRelationshipMetadata, MetadataCache, MetadataClient, MetadataError, type MoneyAttributeMetadata, type OneToManyRelationshipMetadata, type OptionMetadata, type OptionSetGeneratorOptions, type OptionSetMetadata, type ParsedForm, type PicklistAttributeMetadata, SilentLogSink, type SolutionComponent, type StateAttributeMetadata, type StatusAttributeMetadata, type StringAttributeMetadata, type SystemFormMetadata, TypeGenerationOrchestrator, type XmlElement, type XmlParser, XrmForgeError, configureLogging, createCredential, createLogger, defaultXmlParser, disambiguateEnumMembers, extractControlFields, getJSDocLabel as formatDualLabel, generateActionDeclarations, generateActionModule, generateActivityPartyInterface, generateEntityFieldsEnum, generateEntityForms, generateEntityInterface, generateEntityNamesEnum, generateEntityNavigationProperties, generateEntityOptionSets, generateEnumMembers, generateFormInterface, generateOptionSetEnum, getEntityPropertyType, getFormAttributeType, getFormControlType, getFormMockValueType, getJSDocLabel, getLabelLanguagesParam, getPrimaryLabel, getSecondaryLabel, groupCustomApis, isLookupType, isPartyListType, isRateLimitError, isXrmForgeError, labelToIdentifier, parseForm, shouldIncludeInEntityInterface, toLookupValueProperty, toPascalCase, toSafeIdentifier };
package/dist/index.js CHANGED
@@ -2391,7 +2391,7 @@ function deriveActionName(uniquename) {
2391
2391
  function generateParamsInterface(name, params) {
2392
2392
  if (params.length === 0) return "";
2393
2393
  const lines = [];
2394
- lines.push(`export interface ${name}Params {`);
2394
+ lines.push(`export type ${name}Params = {`);
2395
2395
  for (const param of params) {
2396
2396
  const mapped = mapCustomApiParameterType(param.type, param.logicalentityname);
2397
2397
  const optional = param.isoptional ? "?" : "";
@@ -2400,13 +2400,13 @@ function generateParamsInterface(name, params) {
2400
2400
  }
2401
2401
  lines.push(` ${param.uniquename}${optional}: ${mapped.tsType};`);
2402
2402
  }
2403
- lines.push("}");
2403
+ lines.push("};");
2404
2404
  return lines.join("\n");
2405
2405
  }
2406
2406
  function generateResultInterface(name, props) {
2407
2407
  if (props.length === 0) return "";
2408
2408
  const lines = [];
2409
- lines.push(`export interface ${name}Result {`);
2409
+ lines.push(`export type ${name}Result = {`);
2410
2410
  for (const prop of props) {
2411
2411
  const mapped = mapCustomApiParameterType(prop.type, prop.logicalentityname);
2412
2412
  if (prop.description) {
@@ -2414,7 +2414,7 @@ function generateResultInterface(name, props) {
2414
2414
  }
2415
2415
  lines.push(` ${prop.uniquename}: ${mapped.tsType};`);
2416
2416
  }
2417
- lines.push("}");
2417
+ lines.push("};");
2418
2418
  return lines.join("\n");
2419
2419
  }
2420
2420
  function generateActionDeclarations(apis, _isFunction, _entityName, _options = {}) {
@@ -2806,6 +2806,15 @@ var TypeGenerationOrchestrator = class {
2806
2806
  type: "entity"
2807
2807
  });
2808
2808
  }
2809
+ const formFiles = allFiles.filter((f) => f.type === "form");
2810
+ if (formFiles.length > 0) {
2811
+ const formMapping = this.generateFormMapping(formFiles);
2812
+ allFiles.push({
2813
+ relativePath: "form-mapping.json",
2814
+ content: JSON.stringify(formMapping, null, 2) + "\n",
2815
+ type: "entity"
2816
+ });
2817
+ }
2809
2818
  if (allFiles.length > 0) {
2810
2819
  const indexContent = generateBarrelIndex(allFiles);
2811
2820
  const indexFile = {
@@ -3094,6 +3103,39 @@ ${navPropsContent}` : fieldsEnumContent;
3094
3103
  }
3095
3104
  return result;
3096
3105
  }
3106
+ /**
3107
+ * Generate a form-mapping.json that maps entity names to their generated
3108
+ * form interface names, fields enums, and tabs enums.
3109
+ *
3110
+ * This helps AI agents find the correct interface names without guessing.
3111
+ */
3112
+ generateFormMapping(formFiles) {
3113
+ const mapping = {};
3114
+ for (const file of formFiles) {
3115
+ const match = file.relativePath.match(/^forms\/(.+)\.ts$/);
3116
+ if (!match) continue;
3117
+ const entityName = match[1];
3118
+ const interfaces = [...file.content.matchAll(/export\s+interface\s+(\w+Form)\s+extends/g)].map((m) => m[1]);
3119
+ const fieldsEnums = [...file.content.matchAll(/export\s+const\s+enum\s+(\w+FormFieldsEnum)\s*\{/g)].map((m) => m[1]);
3120
+ const tabsEnums = [...file.content.matchAll(/export\s+const\s+enum\s+(\w+FormTabs)\s*\{/g)].map((m) => m[1]);
3121
+ const forms = [];
3122
+ for (let i = 0; i < interfaces.length; i++) {
3123
+ const interfaceName = interfaces[i];
3124
+ const jsdocMatch = file.content.match(new RegExp(`/\\*\\*\\s*(.+?)\\s*\\*/\\s*export\\s+interface\\s+${interfaceName}`));
3125
+ const formName = jsdocMatch?.[1] ?? interfaceName.replace(/Form$/, "");
3126
+ forms.push({
3127
+ formName,
3128
+ interface: interfaceName,
3129
+ fieldsEnum: fieldsEnums[i] ?? "",
3130
+ tabsEnum: tabsEnums[i] ?? ""
3131
+ });
3132
+ }
3133
+ if (forms.length > 0) {
3134
+ mapping[entityName] = forms;
3135
+ }
3136
+ }
3137
+ return mapping;
3138
+ }
3097
3139
  };
3098
3140
  export {
3099
3141
  ApiRequestError,