@xrmforge/typegen 0.8.0 → 0.8.2

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.
package/dist/index.d.ts CHANGED
@@ -1440,345 +1440,12 @@ interface EntityNamesGeneratorOptions {
1440
1440
  */
1441
1441
  declare function generateEntityNamesEnum(entityNames: string[], _options?: EntityNamesGeneratorOptions): string;
1442
1442
 
1443
- /**
1444
- * @xrmforge/typegen - Web API Helper Functions
1445
- *
1446
- * Lightweight utility functions for building OData query strings
1447
- * with type-safe field names from generated Fields enums.
1448
- *
1449
- * Zero runtime overhead when used with const enums (values are inlined).
1450
- *
1451
- * @example
1452
- * ```typescript
1453
- * import { select } from '@xrmforge/typegen';
1454
- *
1455
- * Xrm.WebApi.retrieveRecord(ref.entityType, ref.id, select(
1456
- * AccountFields.Name,
1457
- * AccountFields.WebsiteUrl,
1458
- * AccountFields.Address1Line1,
1459
- * ));
1460
- * ```
1461
- */
1462
- /**
1463
- * Build an OData $select query string from field names.
1464
- *
1465
- * @param fields - Field names (use generated Fields enum for type safety)
1466
- * @returns OData query string (e.g. "?$select=name,websiteurl,address1_line1")
1467
- */
1468
- declare function select(...fields: string[]): string;
1469
- /**
1470
- * Parse a lookup field from a Dataverse Web API response into a LookupValue.
1471
- *
1472
- * Dataverse returns lookups as `_fieldname_value` with OData annotations:
1473
- * - `_fieldname_value` (GUID)
1474
- * - `_fieldname_value@OData.Community.Display.V1.FormattedValue` (display name)
1475
- * - `_fieldname_value@Microsoft.Dynamics.CRM.lookuplogicalname` (entity type)
1476
- *
1477
- * This function extracts all three into an `Xrm.LookupValue` object.
1478
- *
1479
- * @param response - The raw Web API response object
1480
- * @param navigationProperty - Navigation property name (use NavigationProperties enum for type safety)
1481
- * @returns Xrm.LookupValue or null if the lookup is empty
1482
- *
1483
- * @example
1484
- * ```typescript
1485
- * // Mit NavigationProperties-Enum (empfohlen, keine Raw-Strings):
1486
- * parseLookup(result, AccountNav.Country);
1487
- *
1488
- * // Oder mit Navigation Property Name direkt:
1489
- * parseLookup(result, 'markant_address1_countryid');
1490
- * ```
1491
- */
1492
- declare function parseLookup(response: Record<string, unknown>, navigationProperty: string): {
1493
- id: string;
1494
- name: string;
1495
- entityType: string;
1496
- } | null;
1497
- /**
1498
- * Parse multiple lookup fields from a Dataverse Web API response at once.
1499
- *
1500
- * @param response - The raw Web API response object
1501
- * @param navigationProperties - Navigation property names to parse
1502
- * @returns Map of navigation property name to LookupValue (null entries omitted)
1503
- *
1504
- * @example
1505
- * ```typescript
1506
- * const lookups = parseLookups(result, ['markant_address1_countryid', 'parentaccountid']);
1507
- * formContext.getAttribute(Fields.Country).setValue(
1508
- * lookups.markant_address1_countryid ? [lookups.markant_address1_countryid] : null
1509
- * );
1510
- * ```
1511
- */
1512
- declare function parseLookups(response: Record<string, unknown>, navigationProperties: string[]): Record<string, {
1513
- id: string;
1514
- name: string;
1515
- entityType: string;
1516
- } | null>;
1517
- /**
1518
- * Get the formatted (display) value of any field from a Web API response.
1519
- *
1520
- * Works for OptionSets, Lookups, DateTimes, Money, and other formatted fields.
1521
- *
1522
- * @param response - The raw Web API response object
1523
- * @param fieldName - The field logical name (e.g. "statecode", "createdon")
1524
- * @returns The formatted string value, or null if not available
1525
- *
1526
- * @example
1527
- * ```typescript
1528
- * const status = parseFormattedValue(result, 'statecode');
1529
- * // "Active" (statt 0)
1530
- * ```
1531
- */
1532
- declare function parseFormattedValue(response: Record<string, unknown>, fieldName: string): string | null;
1533
- /**
1534
- * Build an OData $select and $expand query string.
1535
- *
1536
- * @param fields - Field names to select
1537
- * @param expand - Navigation property to expand (optional)
1538
- * @returns OData query string
1539
- *
1540
- * @example
1541
- * ```typescript
1542
- * Xrm.WebApi.retrieveRecord("account", id, selectExpand(
1543
- * [AccountFields.Name, AccountFields.WebsiteUrl],
1544
- * "primarycontactid($select=fullname,emailaddress1)"
1545
- * ));
1546
- * ```
1547
- */
1548
- declare function selectExpand(fields: string[], expand: string): string;
1549
-
1550
- /**
1551
- * @xrmforge/typegen - Xrm API Constants
1552
- *
1553
- * Const enums for all common Xrm string/number constants.
1554
- * Eliminates raw strings in D365 form scripts.
1555
- *
1556
- * @types/xrm defines these as string literal types for compile-time checking,
1557
- * but does NOT provide runtime constants (XrmEnum is not available at runtime).
1558
- * These const enums are erased at compile time (zero runtime overhead).
1559
- *
1560
- * @example
1561
- * ```typescript
1562
- * // Statt Raw-String:
1563
- * if (tab.getDisplayState() === 'expanded') { ... }
1564
- *
1565
- * // Mit XrmForge-Konstante:
1566
- * if (tab.getDisplayState() === XrmConstants.DisplayState.Expanded) { ... }
1567
- * ```
1568
- */
1569
- /** Tab/Section display state */
1570
- declare const enum DisplayState {
1571
- Expanded = "expanded",
1572
- Collapsed = "collapsed"
1573
- }
1574
- /** Form notification level (formContext.ui.setFormNotification) */
1575
- declare const enum FormNotificationLevel {
1576
- Error = "ERROR",
1577
- Warning = "WARNING",
1578
- Info = "INFO"
1579
- }
1580
- /** Attribute required level (attribute.setRequiredLevel) */
1581
- declare const enum RequiredLevel {
1582
- None = "none",
1583
- Required = "required",
1584
- Recommended = "recommended"
1585
- }
1586
- /** Attribute submit mode (attribute.setSubmitMode) */
1587
- declare const enum SubmitMode {
1588
- Always = "always",
1589
- Never = "never",
1590
- Dirty = "dirty"
1591
- }
1592
- /** Save mode (eventArgs.getSaveMode()) */
1593
- declare const enum SaveMode {
1594
- Save = 1,
1595
- SaveAndClose = 2,
1596
- Deactivate = 5,
1597
- Reactivate = 6,
1598
- Send = 7,
1599
- Disqualify = 15,
1600
- Qualify = 16,
1601
- Assign = 47,
1602
- SaveAsCompleted = 58,
1603
- SaveAndNew = 59,
1604
- AutoSave = 70
1605
- }
1606
- /** Client type (Xrm.Utility.getGlobalContext().client.getClient()) */
1607
- declare const enum ClientType {
1608
- Web = "Web",
1609
- Outlook = "Outlook",
1610
- Mobile = "Mobile"
1611
- }
1612
- /** Client state (Xrm.Utility.getGlobalContext().client.getClientState()) */
1613
- declare const enum ClientState {
1614
- Online = "Online",
1615
- Offline = "Offline"
1616
- }
1617
- /** Operation type for Xrm.WebApi.execute getMetadata().operationType */
1618
- declare const enum OperationType {
1619
- /** Custom Action or OOB Action (POST) */
1620
- Action = 0,
1621
- /** Custom Function or OOB Function (GET) */
1622
- Function = 1,
1623
- /** CRUD operation (Create, Retrieve, Update, Delete) */
1624
- CRUD = 2
1625
- }
1626
- /** Structural property for getMetadata().parameterTypes[].structuralProperty */
1627
- declare const enum StructuralProperty {
1628
- Unknown = 0,
1629
- PrimitiveType = 1,
1630
- ComplexType = 2,
1631
- EnumerationType = 3,
1632
- Collection = 4,
1633
- EntityType = 5
1634
- }
1635
- /** Binding type for Custom API definitions */
1636
- declare const enum BindingType {
1637
- /** Nicht an eine Entity gebunden (global aufrufbar) */
1638
- Global = 0,
1639
- /** An einen einzelnen Entity-Datensatz gebunden */
1640
- Entity = 1,
1641
- /** An eine Entity-Collection gebunden */
1642
- EntityCollection = 2
1643
- }
1644
-
1645
- /**
1646
- * @xrmforge/typegen - Action/Function Runtime Helpers
1647
- *
1648
- * Factory functions for type-safe Custom API execution.
1649
- * These are imported by generated action/function modules.
1650
- *
1651
- * Design:
1652
- * - `createBoundAction` / `createUnboundAction`: Produce executor objects
1653
- * with `.execute()` (calls Xrm.WebApi) and `.request()` (for executeMultiple)
1654
- * - `executeRequest`: Central execute wrapper (single place for the `as any` cast)
1655
- * - `withProgress`: Convenience wrapper with progress indicator + error dialog
1656
- *
1657
- * @example
1658
- * ```typescript
1659
- * // Generated code (in generated/actions/quote.ts):
1660
- * export const WinQuote = createBoundAction('markant_winquote', 'quote');
1661
- *
1662
- * // Developer code (in quote-form.ts):
1663
- * import { WinQuote } from '../generated/actions/quote';
1664
- * const response = await WinQuote.execute(recordId);
1665
- * ```
1666
- */
1667
- /** Parameter metadata for getMetadata().parameterTypes */
1668
- interface ParameterMeta {
1669
- typeName: string;
1670
- structuralProperty: number;
1671
- }
1672
- /** Map of parameter names to their OData metadata */
1673
- type ParameterMetaMap = Record<string, ParameterMeta>;
1674
- /** Executor for a bound action without additional parameters */
1675
- interface BoundActionExecutor {
1676
- execute(recordId: string): Promise<Response>;
1677
- request(recordId: string): Record<string, unknown>;
1678
- }
1679
- /** Executor for a bound action with typed parameters */
1680
- interface BoundActionWithParamsExecutor<TParams> {
1681
- execute(recordId: string, params: TParams): Promise<Response>;
1682
- request(recordId: string, params: TParams): Record<string, unknown>;
1683
- }
1684
- /** Executor for an unbound action without parameters */
1685
- interface UnboundActionExecutor {
1686
- execute(): Promise<Response>;
1687
- request(): Record<string, unknown>;
1688
- }
1689
- /** Executor for an unbound action with typed parameters and optional typed response */
1690
- interface UnboundActionWithParamsExecutor<TParams, TResult = void> {
1691
- execute(params: TParams): Promise<TResult extends void ? Response : TResult>;
1692
- request(params: TParams): Record<string, unknown>;
1693
- }
1694
- /** Executor for an unbound function with typed response */
1695
- interface UnboundFunctionExecutor<TResult> {
1696
- execute(): Promise<TResult>;
1697
- request(): Record<string, unknown>;
1698
- }
1699
- /** Executor for a bound function with typed response */
1700
- interface BoundFunctionExecutor<TResult> {
1701
- execute(recordId: string): Promise<TResult>;
1702
- request(recordId: string): Record<string, unknown>;
1703
- }
1704
- /**
1705
- * Execute a single request via Xrm.WebApi.online.execute().
1706
- *
1707
- * This is the ONLY place in the entire framework where the `as any` cast happens.
1708
- * All generated executors call this function internally.
1709
- */
1710
- declare function executeRequest(request: Record<string, unknown>): Promise<Response>;
1711
- /**
1712
- * Execute multiple requests via Xrm.WebApi.online.executeMultiple().
1713
- *
1714
- * @param requests - Array of request objects (from `.request()` factories).
1715
- * Wrap a subset in an inner array for transactional changeset execution.
1716
- */
1717
- declare function executeMultiple(requests: Array<Record<string, unknown> | Array<Record<string, unknown>>>): Promise<Response[]>;
1718
- /**
1719
- * Create an executor for a bound action (entity-bound).
1720
- *
1721
- * @param operationName - Custom API unique name (e.g. "markant_winquote")
1722
- * @param entityLogicalName - Entity logical name (e.g. "quote")
1723
- */
1724
- declare function createBoundAction(operationName: string, entityLogicalName: string): BoundActionExecutor;
1725
- /**
1726
- * Create an executor for a bound action with typed parameters.
1727
- *
1728
- * @param operationName - Custom API unique name
1729
- * @param entityLogicalName - Entity logical name
1730
- * @param paramMeta - Parameter metadata map (parameter name to OData type info)
1731
- */
1732
- declare function createBoundAction<TParams extends Record<string, unknown>>(operationName: string, entityLogicalName: string, paramMeta: ParameterMetaMap): BoundActionWithParamsExecutor<TParams>;
1733
- /**
1734
- * Create an executor for an unbound (global) action without parameters.
1735
- *
1736
- * @param operationName - Custom API unique name
1737
- */
1738
- declare function createUnboundAction(operationName: string): UnboundActionExecutor;
1739
- /**
1740
- * Create an executor for an unbound action with typed parameters and response.
1741
- *
1742
- * @param operationName - Custom API unique name
1743
- * @param paramMeta - Parameter metadata map
1744
- */
1745
- declare function createUnboundAction<TParams extends Record<string, unknown>, TResult = void>(operationName: string, paramMeta: ParameterMetaMap): UnboundActionWithParamsExecutor<TParams, TResult>;
1746
- /**
1747
- * Create an executor for an unbound (global) function with typed response.
1748
- *
1749
- * @param operationName - Function name (e.g. "WhoAmI")
1750
- */
1751
- declare function createUnboundFunction<TResult>(operationName: string): UnboundFunctionExecutor<TResult>;
1752
- /**
1753
- * Create an executor for a bound function with typed response.
1754
- *
1755
- * @param operationName - Function name
1756
- * @param entityLogicalName - Entity logical name
1757
- */
1758
- declare function createBoundFunction<TResult>(operationName: string, entityLogicalName: string): BoundFunctionExecutor<TResult>;
1759
- /**
1760
- * Execute an async operation with Xrm progress indicator.
1761
- *
1762
- * Shows a progress spinner before the operation, closes it after,
1763
- * and shows an error dialog on failure.
1764
- *
1765
- * @param message - Progress indicator message (e.g. "Angebot wird gewonnen...")
1766
- * @param operation - Async function to execute
1767
- * @returns The result of the operation
1768
- *
1769
- * @example
1770
- * ```typescript
1771
- * await withProgress('Angebot wird gewonnen...', () => WinQuote.execute(recordId));
1772
- * ```
1773
- */
1774
- declare function withProgress<T>(message: string, operation: () => Promise<T>): Promise<T>;
1775
-
1776
1443
  /**
1777
1444
  * @xrmforge/typegen - Action/Function Generator
1778
1445
  *
1779
1446
  * Generates TypeScript files for type-safe Custom API execution:
1780
1447
  * - .d.ts: Parameter/Response interfaces and executor types
1781
- * - .ts: Runtime modules that import factory functions from @xrmforge/typegen
1448
+ * - .ts: Runtime modules that import factory functions from @xrmforge/helpers
1782
1449
  *
1783
1450
  * Input: CustomApiTypeInfo[] (from fixture JSON or live Dataverse query)
1784
1451
  * Output: Grouped by entity (bound) or "global" (unbound)
@@ -1792,7 +1459,7 @@ declare function withProgress<T>(message: string, operation: () => Promise<T>):
1792
1459
  * }
1793
1460
  *
1794
1461
  * // global.ts
1795
- * import { createUnboundAction } from '@xrmforge/typegen';
1462
+ * import { createUnboundAction } from '@xrmforge/helpers';
1796
1463
  * export const NormalizePhone = createUnboundAction<...>('markant_NormalizePhone', { ... });
1797
1464
  * ```
1798
1465
  */
@@ -1989,4 +1656,4 @@ declare class TypeGenerationOrchestrator {
1989
1656
  private getPicklistAttributes;
1990
1657
  }
1991
1658
 
1992
- export { type ActionGeneratorOptions, ApiRequestError, type AttributeMetadata, type AuthConfig, type AuthMethod, AuthenticationError, BindingType, type BoundActionExecutor, type BoundActionWithParamsExecutor, type BoundFunctionExecutor, type CacheStats, type ChangeDetectionResult, ChangeDetector, type ClientCredentialsAuth, ClientState, ClientType, ConfigError, ConsoleLogSink, type CustomApiTypeInfo, DEFAULT_LABEL_CONFIG, DataverseHttpClient, type DateTimeAttributeMetadata, type DecimalAttributeMetadata, type DeviceCodeAuth, DisplayState, type EntityFieldsGeneratorOptions, type EntityGenerationResult, type EntityGeneratorOptions, type EntityMetadata, type EntityNamesGeneratorOptions, type EntityTypeInfo, ErrorCode, FastXmlParser, type FormControl, type FormGeneratorOptions, FormNotificationLevel, 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, OperationType, type OptionMetadata, type OptionSetGeneratorOptions, type OptionSetMetadata, type ParameterMeta, type ParameterMetaMap, type ParsedForm, type PicklistAttributeMetadata, RequiredLevel, SaveMode, SilentLogSink, type SolutionComponent, type StateAttributeMetadata, type StatusAttributeMetadata, type StringAttributeMetadata, StructuralProperty, SubmitMode, type SystemFormMetadata, TypeGenerationOrchestrator, type UnboundActionExecutor, type UnboundActionWithParamsExecutor, type UnboundFunctionExecutor, type XmlElement, type XmlParser, XrmForgeError, configureLogging, createBoundAction, createBoundFunction, createCredential, createLogger, createUnboundAction, createUnboundFunction, defaultXmlParser, disambiguateEnumMembers, executeMultiple, executeRequest, 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, parseFormattedValue, parseLookup, parseLookups, select, selectExpand, shouldIncludeInEntityInterface, toLookupValueProperty, toPascalCase, toSafeIdentifier, withProgress };
1659
+ 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 };