@xrmforge/helpers 0.4.0 → 0.4.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 +22 -5
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -435,7 +435,7 @@ interface FormTypeInfoProtocol {
|
|
|
435
435
|
fields: string;
|
|
436
436
|
attributes: Record<string, Xrm.Attributes.Attribute>;
|
|
437
437
|
controls: Record<string, Xrm.Controls.Control>;
|
|
438
|
-
form:
|
|
438
|
+
form: object;
|
|
439
439
|
}
|
|
440
440
|
/**
|
|
441
441
|
* Extract Fields from a Form interface.
|
|
@@ -445,20 +445,37 @@ interface FormTypeInfoProtocol {
|
|
|
445
445
|
* to Conditional Type inference on getAttribute (works in same compilation
|
|
446
446
|
* unit but may fail across package boundaries in TS 5.9+).
|
|
447
447
|
*/
|
|
448
|
-
|
|
448
|
+
/**
|
|
449
|
+
* Type extraction uses duck typing: if TForm has a `fields` property,
|
|
450
|
+
* it's a TypeInfo interface (from typegen >= 0.10.0). Otherwise, fall
|
|
451
|
+
* back to Conditional Type inference on getAttribute overloads.
|
|
452
|
+
*
|
|
453
|
+
* Duck typing (`TForm extends { fields: infer F }`) is more robust than
|
|
454
|
+
* matching against FormTypeInfoProtocol because it doesn't require
|
|
455
|
+
* structural compatibility of attributes/controls/form across packages.
|
|
456
|
+
*/
|
|
457
|
+
type ExtractFields<TForm> = TForm extends {
|
|
458
|
+
fields: infer F extends string;
|
|
459
|
+
} ? F : TForm extends {
|
|
449
460
|
getAttribute<K extends infer F>(name: K): unknown;
|
|
450
461
|
} ? F extends string ? F : never : never;
|
|
451
|
-
type ExtractAttributeMap<TForm, TFields extends string> = TForm extends
|
|
462
|
+
type ExtractAttributeMap<TForm, TFields extends string> = TForm extends {
|
|
463
|
+
attributes: infer A extends Record<string, Xrm.Attributes.Attribute>;
|
|
464
|
+
} ? A : {
|
|
452
465
|
[K in TFields]: TForm extends {
|
|
453
466
|
getAttribute(name: K): infer R;
|
|
454
467
|
} ? R extends Xrm.Attributes.Attribute ? R : Xrm.Attributes.Attribute : Xrm.Attributes.Attribute;
|
|
455
468
|
};
|
|
456
|
-
type ExtractControlMap<TForm, TFields extends string> = TForm extends
|
|
469
|
+
type ExtractControlMap<TForm, TFields extends string> = TForm extends {
|
|
470
|
+
controls: infer C extends Record<string, Xrm.Controls.Control>;
|
|
471
|
+
} ? C : {
|
|
457
472
|
[K in TFields]: TForm extends {
|
|
458
473
|
getControl(name: K): infer R;
|
|
459
474
|
} ? R extends Xrm.Controls.Control ? R : Xrm.Controls.Control : Xrm.Controls.Control;
|
|
460
475
|
};
|
|
461
|
-
type ExtractFormContext<TForm> = TForm extends
|
|
476
|
+
type ExtractFormContext<TForm> = TForm extends {
|
|
477
|
+
form: infer FC;
|
|
478
|
+
} ? FC : TForm extends Xrm.FormContext ? TForm : Xrm.FormContext;
|
|
462
479
|
/**
|
|
463
480
|
* TypedForm: proxy type that maps field names to their attribute types.
|
|
464
481
|
*
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/webapi-helpers.ts","../src/xrm-constants.ts","../src/action-runtime.ts","../src/typed-form.ts"],"sourcesContent":["/**\r\n * @xrmforge/helpers - Web API Helper Functions\r\n *\r\n * Lightweight utility functions for building OData query strings\r\n * with type-safe field names from generated Fields enums.\r\n *\r\n * Zero runtime overhead when used with const enums (values are inlined).\r\n *\r\n * @example\r\n * ```typescript\r\n * import { select } from '@xrmforge/helpers';\r\n *\r\n * Xrm.WebApi.retrieveRecord(ref.entityType, ref.id, select(\r\n * AccountFields.Name,\r\n * AccountFields.WebsiteUrl,\r\n * AccountFields.Address1Line1,\r\n * ));\r\n * ```\r\n */\r\n\r\n/**\r\n * Build an OData $select query string from field names.\r\n *\r\n * Accepts either variadic arguments or a single array:\r\n * - `select(Fields.Name, Fields.Email)` (variadic)\r\n * - `select([Fields.Name, Fields.Email])` (array)\r\n *\r\n * @param fields - Field names (use generated Fields enum for type safety)\r\n * @returns OData query string (e.g. \"?$select=name,websiteurl,address1_line1\")\r\n */\r\nexport function select(fields: string[]): string;\r\nexport function select(...fields: string[]): string;\r\nexport function select(...args: string[] | [string[]]): string {\r\n const fields = args.length === 1 && Array.isArray(args[0]) ? args[0] : args as string[];\r\n if (fields.length === 0) return '';\r\n return `?$select=${fields.join(',')}`;\r\n}\r\n\r\n/**\r\n * Parse a lookup field from a Dataverse Web API response into a LookupValue.\r\n *\r\n * Dataverse returns lookups as `_fieldname_value` with OData annotations:\r\n * - `_fieldname_value` (GUID)\r\n * - `_fieldname_value@OData.Community.Display.V1.FormattedValue` (display name)\r\n * - `_fieldname_value@Microsoft.Dynamics.CRM.lookuplogicalname` (entity type)\r\n *\r\n * This function extracts all three into an `Xrm.LookupValue` object.\r\n *\r\n * @param response - The raw Web API response object\r\n * @param navigationProperty - Navigation property name (use NavigationProperties enum for type safety)\r\n * @returns Xrm.LookupValue or null if the lookup is empty\r\n *\r\n * @example\r\n * ```typescript\r\n * // With NavigationProperties enum (recommended):\r\n * parseLookup(result, AccountNav.Country);\r\n *\r\n * // Or with navigation property name directly:\r\n * parseLookup(result, 'markant_address1_countryid');\r\n * ```\r\n */\r\nexport function parseLookup(\r\n response: Record<string, unknown>,\r\n navigationProperty: string,\r\n): { id: string; name: string; entityType: string } | null {\r\n const key = `_${navigationProperty}_value`;\r\n const id = response[key] as string | undefined;\r\n if (!id) return null;\r\n\r\n return {\r\n id,\r\n name: (response[`${key}@OData.Community.Display.V1.FormattedValue`] as string) ?? '',\r\n entityType: (response[`${key}@Microsoft.Dynamics.CRM.lookuplogicalname`] as string) ?? '',\r\n };\r\n}\r\n\r\n/**\r\n * Parse multiple lookup fields from a Dataverse Web API response at once.\r\n *\r\n * @param response - The raw Web API response object\r\n * @param navigationProperties - Navigation property names to parse\r\n * @returns Map of navigation property name to LookupValue (null entries omitted)\r\n *\r\n * @example\r\n * ```typescript\r\n * const lookups = parseLookups(result, ['markant_address1_countryid', 'parentaccountid']);\r\n * formContext.getAttribute(Fields.Country).setValue(\r\n * lookups.markant_address1_countryid ? [lookups.markant_address1_countryid] : null\r\n * );\r\n * ```\r\n */\r\nexport function parseLookups(\r\n response: Record<string, unknown>,\r\n navigationProperties: string[],\r\n): Record<string, { id: string; name: string; entityType: string } | null> {\r\n const result: Record<string, { id: string; name: string; entityType: string } | null> = {};\r\n for (const prop of navigationProperties) {\r\n result[prop] = parseLookup(response, prop);\r\n }\r\n return result;\r\n}\r\n\r\n/**\r\n * Get the formatted (display) value of any field from a Web API response.\r\n *\r\n * Works for OptionSets, Lookups, DateTimes, Money, and other formatted fields.\r\n *\r\n * @param response - The raw Web API response object\r\n * @param fieldName - The field logical name (e.g. \"statecode\", \"createdon\")\r\n * @returns The formatted string value, or null if not available\r\n *\r\n * @example\r\n * ```typescript\r\n * const status = parseFormattedValue(result, 'statecode');\r\n * // \"Active\" (instead of 0)\r\n * ```\r\n */\r\nexport function parseFormattedValue(\r\n response: Record<string, unknown>,\r\n fieldName: string,\r\n): string | null {\r\n return (response[`${fieldName}@OData.Community.Display.V1.FormattedValue`] as string) ?? null;\r\n}\r\n\r\n/**\r\n * Build an OData $select and $expand query string.\r\n *\r\n * @param fields - Field names to select\r\n * @param expand - Navigation property to expand (optional)\r\n * @returns OData query string\r\n *\r\n * @example\r\n * ```typescript\r\n * Xrm.WebApi.retrieveRecord(\"account\", id, selectExpand(\r\n * [AccountFields.Name, AccountFields.WebsiteUrl],\r\n * \"primarycontactid($select=fullname,emailaddress1)\"\r\n * ));\r\n * ```\r\n */\r\nexport function selectExpand(fields: string[], expand: string): string {\r\n const parts: string[] = [];\r\n if (fields.length > 0) parts.push(`$select=${fields.join(',')}`);\r\n if (expand) parts.push(`$expand=${expand}`);\r\n return parts.length > 0 ? `?${parts.join('&')}` : '';\r\n}\r\n\r\n// ─── Form Lookup Helpers ────────────────────────────────────────────────────\r\n\r\n/**\r\n * Extract the first lookup value from a FormContext lookup attribute.\r\n *\r\n * Centralizes the common pattern of reading a lookup from a form field,\r\n * handling null/empty arrays, and normalizing the GUID (removing braces).\r\n *\r\n * @param attr - A lookup attribute from formContext.getAttribute()\r\n * @returns Xrm.LookupValue with normalized id (no braces), or null if empty\r\n *\r\n * @example\r\n * ```typescript\r\n * import { formLookup } from '@xrmforge/helpers';\r\n * const customer = formLookup(form.getAttribute(Fields.CustomerId));\r\n * if (customer) {\r\n * console.log(customer.id, customer.name, customer.entityType);\r\n * }\r\n * ```\r\n */\r\nexport function formLookup(\r\n attr: { getValue(): { id: string; name?: string; entityType: string }[] | null },\r\n): { id: string; name: string; entityType: string } | null {\r\n const values = attr.getValue();\r\n if (!values || values.length === 0) return null;\r\n const first = values[0]!;\r\n return {\r\n id: first.id.replace(/[{}]/g, ''),\r\n name: first.name ?? '',\r\n entityType: first.entityType,\r\n };\r\n}\r\n\r\n/**\r\n * Extract just the normalized GUID from a FormContext lookup attribute.\r\n *\r\n * Shorthand for the most common lookup use case: getting the record ID\r\n * for a Web API call or comparison.\r\n *\r\n * @param attr - A lookup attribute from formContext.getAttribute()\r\n * @returns Normalized GUID string (no braces), or null if empty\r\n *\r\n * @example\r\n * ```typescript\r\n * import { formLookupId } from '@xrmforge/helpers';\r\n * const accountId = formLookupId(form.getAttribute(Fields.AccountId));\r\n * if (accountId) {\r\n * await Xrm.WebApi.retrieveRecord(EntityNames.Account, accountId, select(...));\r\n * }\r\n * ```\r\n */\r\nexport function formLookupId(\r\n attr: { getValue(): { id: string }[] | null },\r\n): string | null {\r\n const values = attr.getValue();\r\n if (!values || values.length === 0) return null;\r\n return values[0]!.id.replace(/[{}]/g, '');\r\n}\r\n","/**\r\n * @xrmforge/helpers - Xrm API Constants\r\n *\r\n * Const enums for all common Xrm string/number constants.\r\n * Eliminates raw strings in D365 form scripts.\r\n *\r\n * @types/xrm defines these as string literal types for compile-time checking,\r\n * but does NOT provide runtime constants (XrmEnum is not available at runtime).\r\n * These const enums are erased at compile time (zero runtime overhead).\r\n *\r\n * @example\r\n * ```typescript\r\n * import { DisplayState } from '@xrmforge/helpers';\r\n *\r\n * if (tab.getDisplayState() === DisplayState.Expanded) { ... }\r\n * ```\r\n */\r\n\r\n/** Tab/Section display state */\r\nexport const enum DisplayState {\r\n Expanded = 'expanded',\r\n Collapsed = 'collapsed',\r\n}\r\n\r\n// FormType: use XrmEnum.FormType from @types/xrm (already defined as const enum there)\r\n\r\n/** Form notification level (formContext.ui.setFormNotification) */\r\nexport const enum FormNotificationLevel {\r\n Error = 'ERROR',\r\n Warning = 'WARNING',\r\n Info = 'INFO',\r\n}\r\n\r\n/** Attribute required level (attribute.setRequiredLevel) */\r\nexport const enum RequiredLevel {\r\n None = 'none',\r\n Required = 'required',\r\n Recommended = 'recommended',\r\n}\r\n\r\n/** Attribute submit mode (attribute.setSubmitMode) */\r\nexport const enum SubmitMode {\r\n Always = 'always',\r\n Never = 'never',\r\n Dirty = 'dirty',\r\n}\r\n\r\n/** Save mode (eventArgs.getSaveMode()) */\r\nexport const enum SaveMode {\r\n Save = 1,\r\n SaveAndClose = 2,\r\n Deactivate = 5,\r\n Reactivate = 6,\r\n Send = 7,\r\n Disqualify = 15,\r\n Qualify = 16,\r\n Assign = 47,\r\n SaveAsCompleted = 58,\r\n SaveAndNew = 59,\r\n AutoSave = 70,\r\n}\r\n\r\n/** Client type (Xrm.Utility.getGlobalContext().client.getClient()) */\r\nexport const enum ClientType {\r\n Web = 'Web',\r\n Outlook = 'Outlook',\r\n Mobile = 'Mobile',\r\n}\r\n\r\n/** Client state (Xrm.Utility.getGlobalContext().client.getClientState()) */\r\nexport const enum ClientState {\r\n Online = 'Online',\r\n Offline = 'Offline',\r\n}\r\n\r\n// WebApi Execute Constants\r\n\r\n/** Operation type for Xrm.WebApi.execute getMetadata().operationType */\r\nexport const enum OperationType {\r\n /** Custom Action or OOB Action (POST) */\r\n Action = 0,\r\n /** Custom Function or OOB Function (GET) */\r\n Function = 1,\r\n /** CRUD operation (Create, Retrieve, Update, Delete) */\r\n CRUD = 2,\r\n}\r\n\r\n/** Structural property for getMetadata().parameterTypes[].structuralProperty */\r\nexport const enum StructuralProperty {\r\n Unknown = 0,\r\n PrimitiveType = 1,\r\n ComplexType = 2,\r\n EnumerationType = 3,\r\n Collection = 4,\r\n EntityType = 5,\r\n}\r\n\r\n/** Binding type for Custom API definitions */\r\nexport const enum BindingType {\r\n /** Not bound to an entity (globally callable) */\r\n Global = 0,\r\n /** Bound to a single entity record */\r\n Entity = 1,\r\n /** Bound to an entity collection */\r\n EntityCollection = 2,\r\n}\r\n","/**\r\n * @xrmforge/helpers - Action/Function Runtime Helpers\r\n *\r\n * Factory functions for type-safe Custom API execution.\r\n * These are imported by generated action/function modules.\r\n *\r\n * Design:\r\n * - `createBoundAction` / `createUnboundAction`: Produce executor objects\r\n * with `.execute()` (calls Xrm.WebApi) and `.request()` (for executeMultiple)\r\n * - `executeRequest`: Central execute wrapper (single place for the `as any` cast)\r\n * - `withProgress`: Convenience wrapper with progress indicator + error dialog\r\n *\r\n * @example\r\n * ```typescript\r\n * // Generated code (in generated/actions/quote.ts):\r\n * import { createBoundAction } from '@xrmforge/helpers';\r\n * export const WinQuote = createBoundAction('markant_winquote', 'quote');\r\n *\r\n * // Developer code (in quote-form.ts):\r\n * import { WinQuote } from '../generated/actions/quote';\r\n * const response = await WinQuote.execute(recordId);\r\n * ```\r\n */\r\n\r\nimport { OperationType, StructuralProperty } from './xrm-constants.js';\r\n\r\n// Types\r\n\r\n/** Parameter metadata for getMetadata().parameterTypes */\r\nexport interface ParameterMeta {\r\n typeName: string;\r\n structuralProperty: number;\r\n}\r\n\r\n/** Map of parameter names to their OData metadata */\r\nexport type ParameterMetaMap = Record<string, ParameterMeta>;\r\n\r\n/** Executor for a bound action without additional parameters */\r\nexport interface BoundActionExecutor<TResult = void> {\r\n execute(recordId: string): Promise<TResult extends void ? Response : TResult>;\r\n request(recordId: string): Record<string, unknown>;\r\n}\r\n\r\n/** Executor for a bound action with typed parameters */\r\nexport interface BoundActionWithParamsExecutor<TParams, TResult = void> {\r\n execute(recordId: string, params: TParams): Promise<TResult extends void ? Response : TResult>;\r\n request(recordId: string, params: TParams): Record<string, unknown>;\r\n}\r\n\r\n/** Executor for an unbound action without parameters */\r\nexport interface UnboundActionExecutor<TResult = void> {\r\n execute(): Promise<TResult extends void ? Response : TResult>;\r\n request(): Record<string, unknown>;\r\n}\r\n\r\n/** Executor for an unbound action with typed parameters and optional typed response */\r\nexport interface UnboundActionWithParamsExecutor<TParams, TResult = void> {\r\n execute(params: TParams): Promise<TResult extends void ? Response : TResult>;\r\n request(params: TParams): Record<string, unknown>;\r\n}\r\n\r\n/** Executor for an unbound function with typed response */\r\nexport interface UnboundFunctionExecutor<TResult> {\r\n execute(): Promise<TResult>;\r\n request(): Record<string, unknown>;\r\n}\r\n\r\n/** Executor for a bound function with typed response */\r\nexport interface BoundFunctionExecutor<TResult> {\r\n execute(recordId: string): Promise<TResult>;\r\n request(recordId: string): Record<string, unknown>;\r\n}\r\n\r\n// Central Execute\r\n\r\n/**\r\n * Execute a single request via Xrm.WebApi.online.execute().\r\n *\r\n * This is the ONLY place in the entire framework where the `as any` cast happens.\r\n * All generated executors call this function internally.\r\n */\r\nexport function executeRequest(request: Record<string, unknown>): Promise<Response> {\r\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\r\n return (Xrm.WebApi as any).online.execute(request) as Promise<Response>;\r\n}\r\n\r\n/**\r\n * Execute multiple requests via Xrm.WebApi.online.executeMultiple().\r\n *\r\n * @param requests - Array of request objects (from `.request()` factories).\r\n * Wrap a subset in an inner array for transactional changeset execution.\r\n */\r\nexport function executeMultiple(\r\n requests: Array<Record<string, unknown> | Array<Record<string, unknown>>>,\r\n): Promise<Response[]> {\r\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\r\n return (Xrm.WebApi as any).online.executeMultiple(requests) as Promise<Response[]>;\r\n}\r\n\r\n// Request Builder (internal)\r\n\r\nfunction cleanRecordId(id: string): string {\r\n return id.replace(/[{}]/g, '');\r\n}\r\n\r\nfunction buildBoundRequest(\r\n operationName: string,\r\n entityLogicalName: string,\r\n operationType: OperationType,\r\n recordId: string,\r\n paramMeta?: ParameterMetaMap,\r\n params?: Record<string, unknown>,\r\n): Record<string, unknown> {\r\n const parameterTypes: Record<string, ParameterMeta> = {\r\n entity: {\r\n typeName: `mscrm.${entityLogicalName}`,\r\n structuralProperty: StructuralProperty.EntityType,\r\n },\r\n };\r\n\r\n if (paramMeta) {\r\n for (const [key, meta] of Object.entries(paramMeta)) {\r\n parameterTypes[key] = meta;\r\n }\r\n }\r\n\r\n const request: Record<string, unknown> = {\r\n getMetadata: () => ({\r\n boundParameter: 'entity',\r\n parameterTypes,\r\n operationName,\r\n operationType,\r\n }),\r\n entity: {\r\n id: cleanRecordId(recordId),\r\n entityType: entityLogicalName,\r\n },\r\n };\r\n\r\n if (params) {\r\n for (const [key, value] of Object.entries(params)) {\r\n request[key] = value;\r\n }\r\n }\r\n\r\n return request;\r\n}\r\n\r\nfunction buildUnboundRequest(\r\n operationName: string,\r\n operationType: OperationType,\r\n paramMeta?: ParameterMetaMap,\r\n params?: Record<string, unknown>,\r\n): Record<string, unknown> {\r\n const parameterTypes: Record<string, ParameterMeta> = {};\r\n\r\n if (paramMeta) {\r\n for (const [key, meta] of Object.entries(paramMeta)) {\r\n parameterTypes[key] = meta;\r\n }\r\n }\r\n\r\n const request: Record<string, unknown> = {\r\n getMetadata: () => ({\r\n boundParameter: null,\r\n parameterTypes,\r\n operationName,\r\n operationType,\r\n }),\r\n };\r\n\r\n if (params) {\r\n for (const [key, value] of Object.entries(params)) {\r\n request[key] = value;\r\n }\r\n }\r\n\r\n return request;\r\n}\r\n\r\n// Action Factories\r\n\r\n/**\r\n * Create an executor for a bound action (entity-bound) without parameters or typed response.\r\n *\r\n * @param operationName - Custom API unique name (e.g. \"markant_winquote\")\r\n * @param entityLogicalName - Entity logical name (e.g. \"quote\")\r\n */\r\nexport function createBoundAction(\r\n operationName: string,\r\n entityLogicalName: string,\r\n): BoundActionExecutor;\r\n\r\n/**\r\n * Create an executor for a bound action without parameters but with typed response.\r\n *\r\n * @param operationName - Custom API unique name\r\n * @param entityLogicalName - Entity logical name\r\n */\r\nexport function createBoundAction<TResult>(\r\n operationName: string,\r\n entityLogicalName: string,\r\n): BoundActionExecutor<TResult>;\r\n\r\n/**\r\n * Create an executor for a bound action with typed parameters and optional typed response.\r\n *\r\n * @param operationName - Custom API unique name\r\n * @param entityLogicalName - Entity logical name\r\n * @param paramMeta - Parameter metadata map (parameter name to OData type info)\r\n */\r\nexport function createBoundAction<\r\n TParams extends Record<string, unknown>,\r\n TResult = void,\r\n>(\r\n operationName: string,\r\n entityLogicalName: string,\r\n paramMeta: ParameterMetaMap,\r\n): BoundActionWithParamsExecutor<TParams, TResult>;\r\n\r\nexport function createBoundAction<\r\n TParams extends Record<string, unknown>,\r\n TResult = void,\r\n>(\r\n operationName: string,\r\n entityLogicalName: string,\r\n paramMeta?: ParameterMetaMap,\r\n): BoundActionExecutor<TResult> | BoundActionWithParamsExecutor<TParams, TResult> {\r\n return {\r\n async execute(recordId: string, params?: TParams): Promise<TResult extends void ? Response : TResult> {\r\n const req = buildBoundRequest(\r\n operationName, entityLogicalName, OperationType.Action,\r\n recordId, paramMeta, params,\r\n );\r\n const response = await executeRequest(req);\r\n if (!response.ok) {\r\n const errorText = await response.text();\r\n throw new Error(errorText);\r\n }\r\n // Parse JSON when response properties are defined (TResult is not void)\r\n if (response.status !== 204) {\r\n return response.json() as Promise<TResult extends void ? Response : TResult>;\r\n }\r\n return response as TResult extends void ? Response : TResult;\r\n },\r\n request(recordId: string, params?: TParams): Record<string, unknown> {\r\n return buildBoundRequest(\r\n operationName, entityLogicalName, OperationType.Action,\r\n recordId, paramMeta, params,\r\n );\r\n },\r\n };\r\n}\r\n\r\n/**\r\n * Create an executor for an unbound (global) action without parameters or typed response.\r\n *\r\n * @param operationName - Custom API unique name\r\n */\r\nexport function createUnboundAction(\r\n operationName: string,\r\n): UnboundActionExecutor;\r\n\r\n/**\r\n * Create an executor for an unbound action without parameters but with typed response.\r\n *\r\n * @param operationName - Custom API unique name\r\n */\r\nexport function createUnboundAction<TResult>(\r\n operationName: string,\r\n): UnboundActionExecutor<TResult>;\r\n\r\n/**\r\n * Create an executor for an unbound action with typed parameters and optional typed response.\r\n *\r\n * @param operationName - Custom API unique name\r\n * @param paramMeta - Parameter metadata map\r\n */\r\nexport function createUnboundAction<\r\n TParams extends Record<string, unknown>,\r\n TResult = void,\r\n>(\r\n operationName: string,\r\n paramMeta: ParameterMetaMap,\r\n): UnboundActionWithParamsExecutor<TParams, TResult>;\r\n\r\nexport function createUnboundAction<\r\n TParams extends Record<string, unknown>,\r\n TResult = void,\r\n>(\r\n operationName: string,\r\n paramMeta?: ParameterMetaMap,\r\n): UnboundActionExecutor | UnboundActionWithParamsExecutor<TParams, TResult> {\r\n return {\r\n async execute(params?: TParams): Promise<TResult extends void ? Response : TResult> {\r\n const req = buildUnboundRequest(\r\n operationName, OperationType.Action, paramMeta, params,\r\n );\r\n const response = await executeRequest(req);\r\n if (!response.ok) {\r\n const errorText = await response.text();\r\n throw new Error(errorText);\r\n }\r\n if (response.status !== 204) {\r\n return response.json() as Promise<TResult extends void ? Response : TResult>;\r\n }\r\n return response as TResult extends void ? Response : TResult;\r\n },\r\n request(params?: TParams): Record<string, unknown> {\r\n return buildUnboundRequest(\r\n operationName, OperationType.Action, paramMeta, params,\r\n );\r\n },\r\n };\r\n}\r\n\r\n// Function Factories\r\n\r\n/**\r\n * Create an executor for an unbound (global) function with typed response.\r\n *\r\n * @param operationName - Function name (e.g. \"WhoAmI\")\r\n */\r\nexport function createUnboundFunction<TResult>(\r\n operationName: string,\r\n): UnboundFunctionExecutor<TResult> {\r\n return {\r\n async execute(): Promise<TResult> {\r\n const req = buildUnboundRequest(operationName, OperationType.Function);\r\n const response = await executeRequest(req);\r\n if (!response.ok) {\r\n const errorText = await response.text();\r\n throw new Error(errorText);\r\n }\r\n return response.json() as Promise<TResult>;\r\n },\r\n request(): Record<string, unknown> {\r\n return buildUnboundRequest(operationName, OperationType.Function);\r\n },\r\n };\r\n}\r\n\r\n/**\r\n * Create an executor for a bound function with typed response.\r\n *\r\n * @param operationName - Function name\r\n * @param entityLogicalName - Entity logical name\r\n */\r\nexport function createBoundFunction<TResult>(\r\n operationName: string,\r\n entityLogicalName: string,\r\n): BoundFunctionExecutor<TResult> {\r\n return {\r\n async execute(recordId: string): Promise<TResult> {\r\n const req = buildBoundRequest(\r\n operationName, entityLogicalName, OperationType.Function, recordId,\r\n );\r\n const response = await executeRequest(req);\r\n if (!response.ok) {\r\n const errorText = await response.text();\r\n throw new Error(errorText);\r\n }\r\n return response.json() as Promise<TResult>;\r\n },\r\n request(recordId: string): Record<string, unknown> {\r\n return buildBoundRequest(\r\n operationName, entityLogicalName, OperationType.Function, recordId,\r\n );\r\n },\r\n };\r\n}\r\n\r\n// Convenience\r\n\r\n/**\r\n * Execute an async operation with Xrm progress indicator.\r\n *\r\n * Shows a progress spinner before the operation, closes it after,\r\n * and shows an error dialog on failure.\r\n *\r\n * @param message - Progress indicator message (e.g. \"Processing quote...\")\r\n * @param operation - Async function to execute\r\n * @returns The result of the operation\r\n *\r\n * @example\r\n * ```typescript\r\n * await withProgress('Processing quote...', () => WinQuote.execute(recordId));\r\n * ```\r\n */\r\nexport async function withProgress<T>(\r\n message: string,\r\n operation: () => Promise<T>,\r\n): Promise<T> {\r\n Xrm.Utility.showProgressIndicator(message);\r\n try {\r\n return await operation();\r\n } catch (error: unknown) {\r\n const msg = error instanceof Error ? error.message : String(error);\r\n Xrm.Navigation.openErrorDialog({ message: msg });\r\n throw error;\r\n } finally {\r\n Xrm.Utility.closeProgressIndicator();\r\n }\r\n}\r\n","/**\n * @xrmforge/helpers - TypedForm Proxy\n *\n * Creates a proxy around Xrm.FormContext that allows direct property access\n * to form fields. Instead of `form.getAttribute(\"name\").setValue(\"X\")`,\n * write `form.name.setValue(\"X\")`.\n *\n * Works with generated form types from @xrmforge/typegen. Since v0.9.2,\n * typegen generates a `FormTypeInfo` interface per form that bundles\n * Fields, AttributeMap, and ControlMap for reliable type extraction.\n *\n * @example\n * ```typescript\n * import { typedForm } from '@xrmforge/helpers';\n * import type { AccountLMFirmaForm } from '../../generated/forms/account.js';\n *\n * const form = typedForm<AccountLMFirmaForm>(ctx.getFormContext());\n * form.name.getValue(); // string | null (typed)\n * form.revenue.setValue(150000); // NumberAttribute (typed)\n * form.$context.ui.tabs.get(...); // Full FormContext access\n * form.$control('name'); // Control access\n * form.$unsafe('off_form_field'); // Access fields not on the form\n * ```\n */\n\n// ─── FormTypeInfo Protocol ───────────────────────────────────────────────────\n\n/**\n * Protocol interface generated by typegen for each form.\n * Bundles Fields, AttributeMap, and ControlMap so typedForm can extract\n * them reliably without fragile Conditional Type inference on overloads.\n *\n * Generated as: `export interface MyFormTypeInfo { fields: ...; attributes: ...; controls: ...; form: ...; }`\n */\nexport interface FormTypeInfoProtocol {\n fields: string;\n attributes: Record<string, Xrm.Attributes.Attribute>;\n controls: Record<string, Xrm.Controls.Control>;\n form: Xrm.FormContext;\n}\n\n// ─── Type Extraction ─────────────────────────────────────────────────────────\n\n/**\n * Extract Fields from a Form interface.\n *\n * Strategy: Check if TForm has a companion TypeInfo interface (generated by\n * typegen >= 0.9.2). If so, extract fields directly. Otherwise, fall back\n * to Conditional Type inference on getAttribute (works in same compilation\n * unit but may fail across package boundaries in TS 5.9+).\n */\ntype ExtractFields<TForm> =\n TForm extends FormTypeInfoProtocol ? TForm['fields'] :\n TForm extends { getAttribute<K extends infer F>(name: K): unknown }\n ? F extends string ? F : never\n : never;\n\ntype ExtractAttributeMap<TForm, TFields extends string> =\n TForm extends FormTypeInfoProtocol ? TForm['attributes'] :\n { [K in TFields]: TForm extends { getAttribute(name: K): infer R }\n ? R extends Xrm.Attributes.Attribute ? R : Xrm.Attributes.Attribute\n : Xrm.Attributes.Attribute;\n };\n\ntype ExtractControlMap<TForm, TFields extends string> =\n TForm extends FormTypeInfoProtocol ? TForm['controls'] :\n { [K in TFields]: TForm extends { getControl(name: K): infer R }\n ? R extends Xrm.Controls.Control ? R : Xrm.Controls.Control\n : Xrm.Controls.Control;\n };\n\ntype ExtractFormContext<TForm> =\n TForm extends FormTypeInfoProtocol ? TForm['form'] :\n TForm extends Xrm.FormContext ? TForm :\n Xrm.FormContext;\n\n// ─── TypedForm Type ──────────────────────────────────────────────────────────\n\n/**\n * TypedForm: proxy type that maps field names to their attribute types.\n *\n * Provides direct property access to form fields (e.g. `form.name` returns\n * the StringAttribute), plus:\n * - `$context` for full FormContext access (ui, data, tabs, getAttribute with addOnChange)\n * - `$control(name)` for typed control access\n * - `$unsafe(name)` for off-form field access (fields loaded by D365 but not on the form)\n */\nexport type TypedForm<\n TForm,\n TFields extends string = ExtractFields<TForm>,\n TAttrMap extends Record<string, Xrm.Attributes.Attribute> = ExtractAttributeMap<TForm, TFields>,\n TCtrlMap extends Record<string, Xrm.Controls.Control> = ExtractControlMap<TForm, TFields>,\n> = {\n /** Direct field access: form.fieldName returns the typed Attribute */\n readonly [K in TFields]: K extends keyof TAttrMap\n ? TAttrMap[K]\n : Xrm.Attributes.Attribute;\n} & {\n /** Access the underlying FormContext for ui, data, tabs, addOnChange, etc. */\n readonly $context: ExtractFormContext<TForm>;\n /** Access a typed control by field name */\n $control<K extends TFields>(name: K): K extends keyof TCtrlMap ? TCtrlMap[K] : Xrm.Controls.Control;\n /**\n * Access an off-form field (loaded by D365 but not on the current form layout).\n * Returns null if the attribute does not exist.\n * Use this for fields like 'lm_genehmigt' that are not in the form definition\n * but are accessible at runtime via formContext.getAttribute().\n */\n $unsafe(name: string): Xrm.Attributes.Attribute | null;\n};\n\n/**\n * Create a typed form proxy around a FormContext.\n *\n * Accepts either a Form interface or a FormTypeInfo interface as type parameter.\n * When using FormTypeInfo (generated by typegen >= 0.9.2), type extraction is\n * guaranteed to work across all TypeScript versions.\n *\n * @example\n * ```typescript\n * // Recommended: use Form interface directly (requires typegen >= 0.9.2 for TypeInfo)\n * const form = typedForm<AccountLMFirmaForm>(ctx.getFormContext());\n *\n * // Alternative: use TypeInfo for explicit type extraction\n * const form = typedForm<AccountLMFirmaFormTypeInfo>(ctx.getFormContext());\n * ```\n *\n * @param formContext - The Xrm.FormContext from executionContext.getFormContext()\n * @returns A proxy with direct typed property access to form fields\n */\nexport function typedForm<TForm>(\n formContext: Xrm.FormContext,\n): TypedForm<TForm> {\n return new Proxy(formContext as unknown as TypedForm<TForm>, {\n get(_target, prop) {\n if (typeof prop !== 'string') {\n return (formContext as unknown as Record<symbol, unknown>)[prop];\n }\n if (prop === '$context') return formContext;\n if (prop === '$control') {\n return (name: string) => formContext.getControl(name);\n }\n if (prop === '$unsafe') {\n return (name: string) => formContext.getAttribute(name);\n }\n const attr = formContext.getAttribute(prop);\n if (attr) return attr;\n return (formContext as unknown as Record<string, unknown>)[prop];\n },\n\n set(_target, prop, _value) {\n throw new TypeError(\n `Cannot assign to '${String(prop)}'. Use form.${String(prop)}.setValue() instead.`,\n );\n },\n\n has(_target, prop) {\n if (typeof prop !== 'string') return false;\n if (prop === '$context' || prop === '$control' || prop === '$unsafe') return true;\n return formContext.getAttribute(prop) !== null;\n },\n });\n}\n\n// ─── normalizeGuid ───────────────────────────────────────────────────────────\n\n/**\n * Normalize a GUID: strip curly braces and lowercase.\n *\n * Use this for GUIDs from sources other than formLookupId():\n * - `formContext.data.entity.getId()` returns GUIDs with braces\n * - WebApi `_value` fields may have braces depending on annotations\n * - Custom API responses may return GUIDs in varying formats\n *\n * formLookupId() already normalizes internally, so this is NOT needed for\n * lookup field access. Only use for getId(), WebApi responses, and comparisons.\n *\n * @param guid - A GUID string, possibly with braces and mixed case\n * @returns Normalized GUID (lowercase, no braces), or empty string if null/empty\n *\n * @example\n * ```typescript\n * const recordId = normalizeGuid(form.$context.data.entity.getId());\n * // \"{A1B2C3D4-...}\" -> \"a1b2c3d4-...\"\n *\n * const currencyId = normalizeGuid(result._transactioncurrencyid_value as string);\n * ```\n */\nexport function normalizeGuid(guid: string | null | undefined): string {\n if (!guid) return '';\n return guid.replace(/[{}]/g, '').toLowerCase();\n}\n\n// ─── Legacy Exports ──────────────────────────────────────────────────────────\n\n/** @deprecated Use ExtractFields<TForm> instead */\nexport type FormFields<TForm> = ExtractFields<TForm>;\n"],"mappings":";AAgCO,SAAS,UAAU,MAAqC;AAC7D,QAAM,SAAS,KAAK,WAAW,KAAK,MAAM,QAAQ,KAAK,CAAC,CAAC,IAAI,KAAK,CAAC,IAAI;AACvE,MAAI,OAAO,WAAW,EAAG,QAAO;AAChC,SAAO,YAAY,OAAO,KAAK,GAAG,CAAC;AACrC;AAyBO,SAAS,YACd,UACA,oBACyD;AACzD,QAAM,MAAM,IAAI,kBAAkB;AAClC,QAAM,KAAK,SAAS,GAAG;AACvB,MAAI,CAAC,GAAI,QAAO;AAEhB,SAAO;AAAA,IACL;AAAA,IACA,MAAO,SAAS,GAAG,GAAG,4CAA4C,KAAgB;AAAA,IAClF,YAAa,SAAS,GAAG,GAAG,2CAA2C,KAAgB;AAAA,EACzF;AACF;AAiBO,SAAS,aACd,UACA,sBACyE;AACzE,QAAM,SAAkF,CAAC;AACzF,aAAW,QAAQ,sBAAsB;AACvC,WAAO,IAAI,IAAI,YAAY,UAAU,IAAI;AAAA,EAC3C;AACA,SAAO;AACT;AAiBO,SAAS,oBACd,UACA,WACe;AACf,SAAQ,SAAS,GAAG,SAAS,4CAA4C,KAAgB;AAC3F;AAiBO,SAAS,aAAa,QAAkB,QAAwB;AACrE,QAAM,QAAkB,CAAC;AACzB,MAAI,OAAO,SAAS,EAAG,OAAM,KAAK,WAAW,OAAO,KAAK,GAAG,CAAC,EAAE;AAC/D,MAAI,OAAQ,OAAM,KAAK,WAAW,MAAM,EAAE;AAC1C,SAAO,MAAM,SAAS,IAAI,IAAI,MAAM,KAAK,GAAG,CAAC,KAAK;AACpD;AAsBO,SAAS,WACd,MACyD;AACzD,QAAM,S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AC;AAAA,MAC9D;AAAA,IACF;AAAA,IAEA,IAAI,SAAS,MAAM;AACjB,UAAI,OAAO,SAAS,SAAU,QAAO;AACrC,UAAI,SAAS,cAAc,SAAS,cAAc,SAAS,UAAW,QAAO;AAC7E,aAAO,YAAY,aAAa,IAAI,MAAM;AAAA,IAC5C;AAAA,EACF,CAAC;AACH;AA0BO,SAAS,cAAc,MAAyC;AACrE,MAAI,CAAC,KAAM,QAAO;AAClB,SAAO,KAAK,QAAQ,SAAS,EAAE,EAAE,YAAY;AAC/C;","names":["DisplayState","FormNotificationLevel","RequiredLevel","SubmitMode","SaveMode","ClientType","ClientState","OperationType","StructuralProperty","BindingType"]}
|
|
1
|
+
{"version":3,"sources":["../src/webapi-helpers.ts","../src/xrm-constants.ts","../src/action-runtime.ts","../src/typed-form.ts"],"sourcesContent":["/**\r\n * @xrmforge/helpers - Web API Helper Functions\r\n *\r\n * Lightweight utility functions for building OData query strings\r\n * with type-safe field names from generated Fields enums.\r\n *\r\n * Zero runtime overhead when used with const enums (values are inlined).\r\n *\r\n * @example\r\n * ```typescript\r\n * import { select } from '@xrmforge/helpers';\r\n *\r\n * Xrm.WebApi.retrieveRecord(ref.entityType, ref.id, select(\r\n * AccountFields.Name,\r\n * AccountFields.WebsiteUrl,\r\n * AccountFields.Address1Line1,\r\n * ));\r\n * ```\r\n */\r\n\r\n/**\r\n * Build an OData $select query string from field names.\r\n *\r\n * Accepts either variadic arguments or a single array:\r\n * - `select(Fields.Name, Fields.Email)` (variadic)\r\n * - `select([Fields.Name, Fields.Email])` (array)\r\n *\r\n * @param fields - Field names (use generated Fields enum for type safety)\r\n * @returns OData query string (e.g. \"?$select=name,websiteurl,address1_line1\")\r\n */\r\nexport function select(fields: string[]): string;\r\nexport function select(...fields: string[]): string;\r\nexport function select(...args: string[] | [string[]]): string {\r\n const fields = args.length === 1 && Array.isArray(args[0]) ? args[0] : args as string[];\r\n if (fields.length === 0) return '';\r\n return `?$select=${fields.join(',')}`;\r\n}\r\n\r\n/**\r\n * Parse a lookup field from a Dataverse Web API response into a LookupValue.\r\n *\r\n * Dataverse returns lookups as `_fieldname_value` with OData annotations:\r\n * - `_fieldname_value` (GUID)\r\n * - `_fieldname_value@OData.Community.Display.V1.FormattedValue` (display name)\r\n * - `_fieldname_value@Microsoft.Dynamics.CRM.lookuplogicalname` (entity type)\r\n *\r\n * This function extracts all three into an `Xrm.LookupValue` object.\r\n *\r\n * @param response - The raw Web API response object\r\n * @param navigationProperty - Navigation property name (use NavigationProperties enum for type safety)\r\n * @returns Xrm.LookupValue or null if the lookup is empty\r\n *\r\n * @example\r\n * ```typescript\r\n * // With NavigationProperties enum (recommended):\r\n * parseLookup(result, AccountNav.Country);\r\n *\r\n * // Or with navigation property name directly:\r\n * parseLookup(result, 'markant_address1_countryid');\r\n * ```\r\n */\r\nexport function parseLookup(\r\n response: Record<string, unknown>,\r\n navigationProperty: string,\r\n): { id: string; name: string; entityType: string } | null {\r\n const key = `_${navigationProperty}_value`;\r\n const id = response[key] as string | undefined;\r\n if (!id) return null;\r\n\r\n return {\r\n id,\r\n name: (response[`${key}@OData.Community.Display.V1.FormattedValue`] as string) ?? '',\r\n entityType: (response[`${key}@Microsoft.Dynamics.CRM.lookuplogicalname`] as string) ?? '',\r\n };\r\n}\r\n\r\n/**\r\n * Parse multiple lookup fields from a Dataverse Web API response at once.\r\n *\r\n * @param response - The raw Web API response object\r\n * @param navigationProperties - Navigation property names to parse\r\n * @returns Map of navigation property name to LookupValue (null entries omitted)\r\n *\r\n * @example\r\n * ```typescript\r\n * const lookups = parseLookups(result, ['markant_address1_countryid', 'parentaccountid']);\r\n * formContext.getAttribute(Fields.Country).setValue(\r\n * lookups.markant_address1_countryid ? [lookups.markant_address1_countryid] : null\r\n * );\r\n * ```\r\n */\r\nexport function parseLookups(\r\n response: Record<string, unknown>,\r\n navigationProperties: string[],\r\n): Record<string, { id: string; name: string; entityType: string } | null> {\r\n const result: Record<string, { id: string; name: string; entityType: string } | null> = {};\r\n for (const prop of navigationProperties) {\r\n result[prop] = parseLookup(response, prop);\r\n }\r\n return result;\r\n}\r\n\r\n/**\r\n * Get the formatted (display) value of any field from a Web API response.\r\n *\r\n * Works for OptionSets, Lookups, DateTimes, Money, and other formatted fields.\r\n *\r\n * @param response - The raw Web API response object\r\n * @param fieldName - The field logical name (e.g. \"statecode\", \"createdon\")\r\n * @returns The formatted string value, or null if not available\r\n *\r\n * @example\r\n * ```typescript\r\n * const status = parseFormattedValue(result, 'statecode');\r\n * // \"Active\" (instead of 0)\r\n * ```\r\n */\r\nexport function parseFormattedValue(\r\n response: Record<string, unknown>,\r\n fieldName: string,\r\n): string | null {\r\n return (response[`${fieldName}@OData.Community.Display.V1.FormattedValue`] as string) ?? null;\r\n}\r\n\r\n/**\r\n * Build an OData $select and $expand query string.\r\n *\r\n * @param fields - Field names to select\r\n * @param expand - Navigation property to expand (optional)\r\n * @returns OData query string\r\n *\r\n * @example\r\n * ```typescript\r\n * Xrm.WebApi.retrieveRecord(\"account\", id, selectExpand(\r\n * [AccountFields.Name, AccountFields.WebsiteUrl],\r\n * \"primarycontactid($select=fullname,emailaddress1)\"\r\n * ));\r\n * ```\r\n */\r\nexport function selectExpand(fields: string[], expand: string): string {\r\n const parts: string[] = [];\r\n if (fields.length > 0) parts.push(`$select=${fields.join(',')}`);\r\n if (expand) parts.push(`$expand=${expand}`);\r\n return parts.length > 0 ? `?${parts.join('&')}` : '';\r\n}\r\n\r\n// ─── Form Lookup Helpers ────────────────────────────────────────────────────\r\n\r\n/**\r\n * Extract the first lookup value from a FormContext lookup attribute.\r\n *\r\n * Centralizes the common pattern of reading a lookup from a form field,\r\n * handling null/empty arrays, and normalizing the GUID (removing braces).\r\n *\r\n * @param attr - A lookup attribute from formContext.getAttribute()\r\n * @returns Xrm.LookupValue with normalized id (no braces), or null if empty\r\n *\r\n * @example\r\n * ```typescript\r\n * import { formLookup } from '@xrmforge/helpers';\r\n * const customer = formLookup(form.getAttribute(Fields.CustomerId));\r\n * if (customer) {\r\n * console.log(customer.id, customer.name, customer.entityType);\r\n * }\r\n * ```\r\n */\r\nexport function formLookup(\r\n attr: { getValue(): { id: string; name?: string; entityType: string }[] | null },\r\n): { id: string; name: string; entityType: string } | null {\r\n const values = attr.getValue();\r\n if (!values || values.length === 0) return null;\r\n const first = values[0]!;\r\n return {\r\n id: first.id.replace(/[{}]/g, ''),\r\n name: first.name ?? '',\r\n entityType: first.entityType,\r\n };\r\n}\r\n\r\n/**\r\n * Extract just the normalized GUID from a FormContext lookup attribute.\r\n *\r\n * Shorthand for the most common lookup use case: getting the record ID\r\n * for a Web API call or comparison.\r\n *\r\n * @param attr - A lookup attribute from formContext.getAttribute()\r\n * @returns Normalized GUID string (no braces), or null if empty\r\n *\r\n * @example\r\n * ```typescript\r\n * import { formLookupId } from '@xrmforge/helpers';\r\n * const accountId = formLookupId(form.getAttribute(Fields.AccountId));\r\n * if (accountId) {\r\n * await Xrm.WebApi.retrieveRecord(EntityNames.Account, accountId, select(...));\r\n * }\r\n * ```\r\n */\r\nexport function formLookupId(\r\n attr: { getValue(): { id: string }[] | null },\r\n): string | null {\r\n const values = attr.getValue();\r\n if (!values || values.length === 0) return null;\r\n return values[0]!.id.replace(/[{}]/g, '');\r\n}\r\n","/**\r\n * @xrmforge/helpers - Xrm API Constants\r\n *\r\n * Const enums for all common Xrm string/number constants.\r\n * Eliminates raw strings in D365 form scripts.\r\n *\r\n * @types/xrm defines these as string literal types for compile-time checking,\r\n * but does NOT provide runtime constants (XrmEnum is not available at runtime).\r\n * These const enums are erased at compile time (zero runtime overhead).\r\n *\r\n * @example\r\n * ```typescript\r\n * import { DisplayState } from '@xrmforge/helpers';\r\n *\r\n * if (tab.getDisplayState() === DisplayState.Expanded) { ... }\r\n * ```\r\n */\r\n\r\n/** Tab/Section display state */\r\nexport const enum DisplayState {\r\n Expanded = 'expanded',\r\n Collapsed = 'collapsed',\r\n}\r\n\r\n// FormType: use XrmEnum.FormType from @types/xrm (already defined as const enum there)\r\n\r\n/** Form notification level (formContext.ui.setFormNotification) */\r\nexport const enum FormNotificationLevel {\r\n Error = 'ERROR',\r\n Warning = 'WARNING',\r\n Info = 'INFO',\r\n}\r\n\r\n/** Attribute required level (attribute.setRequiredLevel) */\r\nexport const enum RequiredLevel {\r\n None = 'none',\r\n Required = 'required',\r\n Recommended = 'recommended',\r\n}\r\n\r\n/** Attribute submit mode (attribute.setSubmitMode) */\r\nexport const enum SubmitMode {\r\n Always = 'always',\r\n Never = 'never',\r\n Dirty = 'dirty',\r\n}\r\n\r\n/** Save mode (eventArgs.getSaveMode()) */\r\nexport const enum SaveMode {\r\n Save = 1,\r\n SaveAndClose = 2,\r\n Deactivate = 5,\r\n Reactivate = 6,\r\n Send = 7,\r\n Disqualify = 15,\r\n Qualify = 16,\r\n Assign = 47,\r\n SaveAsCompleted = 58,\r\n SaveAndNew = 59,\r\n AutoSave = 70,\r\n}\r\n\r\n/** Client type (Xrm.Utility.getGlobalContext().client.getClient()) */\r\nexport const enum ClientType {\r\n Web = 'Web',\r\n Outlook = 'Outlook',\r\n Mobile = 'Mobile',\r\n}\r\n\r\n/** Client state (Xrm.Utility.getGlobalContext().client.getClientState()) */\r\nexport const enum ClientState {\r\n Online = 'Online',\r\n Offline = 'Offline',\r\n}\r\n\r\n// WebApi Execute Constants\r\n\r\n/** Operation type for Xrm.WebApi.execute getMetadata().operationType */\r\nexport const enum OperationType {\r\n /** Custom Action or OOB Action (POST) */\r\n Action = 0,\r\n /** Custom Function or OOB Function (GET) */\r\n Function = 1,\r\n /** CRUD operation (Create, Retrieve, Update, Delete) */\r\n CRUD = 2,\r\n}\r\n\r\n/** Structural property for getMetadata().parameterTypes[].structuralProperty */\r\nexport const enum StructuralProperty {\r\n Unknown = 0,\r\n PrimitiveType = 1,\r\n ComplexType = 2,\r\n EnumerationType = 3,\r\n Collection = 4,\r\n EntityType = 5,\r\n}\r\n\r\n/** Binding type for Custom API definitions */\r\nexport const enum BindingType {\r\n /** Not bound to an entity (globally callable) */\r\n Global = 0,\r\n /** Bound to a single entity record */\r\n Entity = 1,\r\n /** Bound to an entity collection */\r\n EntityCollection = 2,\r\n}\r\n","/**\r\n * @xrmforge/helpers - Action/Function Runtime Helpers\r\n *\r\n * Factory functions for type-safe Custom API execution.\r\n * These are imported by generated action/function modules.\r\n *\r\n * Design:\r\n * - `createBoundAction` / `createUnboundAction`: Produce executor objects\r\n * with `.execute()` (calls Xrm.WebApi) and `.request()` (for executeMultiple)\r\n * - `executeRequest`: Central execute wrapper (single place for the `as any` cast)\r\n * - `withProgress`: Convenience wrapper with progress indicator + error dialog\r\n *\r\n * @example\r\n * ```typescript\r\n * // Generated code (in generated/actions/quote.ts):\r\n * import { createBoundAction } from '@xrmforge/helpers';\r\n * export const WinQuote = createBoundAction('markant_winquote', 'quote');\r\n *\r\n * // Developer code (in quote-form.ts):\r\n * import { WinQuote } from '../generated/actions/quote';\r\n * const response = await WinQuote.execute(recordId);\r\n * ```\r\n */\r\n\r\nimport { OperationType, StructuralProperty } from './xrm-constants.js';\r\n\r\n// Types\r\n\r\n/** Parameter metadata for getMetadata().parameterTypes */\r\nexport interface ParameterMeta {\r\n typeName: string;\r\n structuralProperty: number;\r\n}\r\n\r\n/** Map of parameter names to their OData metadata */\r\nexport type ParameterMetaMap = Record<string, ParameterMeta>;\r\n\r\n/** Executor for a bound action without additional parameters */\r\nexport interface BoundActionExecutor<TResult = void> {\r\n execute(recordId: string): Promise<TResult extends void ? Response : TResult>;\r\n request(recordId: string): Record<string, unknown>;\r\n}\r\n\r\n/** Executor for a bound action with typed parameters */\r\nexport interface BoundActionWithParamsExecutor<TParams, TResult = void> {\r\n execute(recordId: string, params: TParams): Promise<TResult extends void ? Response : TResult>;\r\n request(recordId: string, params: TParams): Record<string, unknown>;\r\n}\r\n\r\n/** Executor for an unbound action without parameters */\r\nexport interface UnboundActionExecutor<TResult = void> {\r\n execute(): Promise<TResult extends void ? Response : TResult>;\r\n request(): Record<string, unknown>;\r\n}\r\n\r\n/** Executor for an unbound action with typed parameters and optional typed response */\r\nexport interface UnboundActionWithParamsExecutor<TParams, TResult = void> {\r\n execute(params: TParams): Promise<TResult extends void ? Response : TResult>;\r\n request(params: TParams): Record<string, unknown>;\r\n}\r\n\r\n/** Executor for an unbound function with typed response */\r\nexport interface UnboundFunctionExecutor<TResult> {\r\n execute(): Promise<TResult>;\r\n request(): Record<string, unknown>;\r\n}\r\n\r\n/** Executor for a bound function with typed response */\r\nexport interface BoundFunctionExecutor<TResult> {\r\n execute(recordId: string): Promise<TResult>;\r\n request(recordId: string): Record<string, unknown>;\r\n}\r\n\r\n// Central Execute\r\n\r\n/**\r\n * Execute a single request via Xrm.WebApi.online.execute().\r\n *\r\n * This is the ONLY place in the entire framework where the `as any` cast happens.\r\n * All generated executors call this function internally.\r\n */\r\nexport function executeRequest(request: Record<string, unknown>): Promise<Response> {\r\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\r\n return (Xrm.WebApi as any).online.execute(request) as Promise<Response>;\r\n}\r\n\r\n/**\r\n * Execute multiple requests via Xrm.WebApi.online.executeMultiple().\r\n *\r\n * @param requests - Array of request objects (from `.request()` factories).\r\n * Wrap a subset in an inner array for transactional changeset execution.\r\n */\r\nexport function executeMultiple(\r\n requests: Array<Record<string, unknown> | Array<Record<string, unknown>>>,\r\n): Promise<Response[]> {\r\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\r\n return (Xrm.WebApi as any).online.executeMultiple(requests) as Promise<Response[]>;\r\n}\r\n\r\n// Request Builder (internal)\r\n\r\nfunction cleanRecordId(id: string): string {\r\n return id.replace(/[{}]/g, '');\r\n}\r\n\r\nfunction buildBoundRequest(\r\n operationName: string,\r\n entityLogicalName: string,\r\n operationType: OperationType,\r\n recordId: string,\r\n paramMeta?: ParameterMetaMap,\r\n params?: Record<string, unknown>,\r\n): Record<string, unknown> {\r\n const parameterTypes: Record<string, ParameterMeta> = {\r\n entity: {\r\n typeName: `mscrm.${entityLogicalName}`,\r\n structuralProperty: StructuralProperty.EntityType,\r\n },\r\n };\r\n\r\n if (paramMeta) {\r\n for (const [key, meta] of Object.entries(paramMeta)) {\r\n parameterTypes[key] = meta;\r\n }\r\n }\r\n\r\n const request: Record<string, unknown> = {\r\n getMetadata: () => ({\r\n boundParameter: 'entity',\r\n parameterTypes,\r\n operationName,\r\n operationType,\r\n }),\r\n entity: {\r\n id: cleanRecordId(recordId),\r\n entityType: entityLogicalName,\r\n },\r\n };\r\n\r\n if (params) {\r\n for (const [key, value] of Object.entries(params)) {\r\n request[key] = value;\r\n }\r\n }\r\n\r\n return request;\r\n}\r\n\r\nfunction buildUnboundRequest(\r\n operationName: string,\r\n operationType: OperationType,\r\n paramMeta?: ParameterMetaMap,\r\n params?: Record<string, unknown>,\r\n): Record<string, unknown> {\r\n const parameterTypes: Record<string, ParameterMeta> = {};\r\n\r\n if (paramMeta) {\r\n for (const [key, meta] of Object.entries(paramMeta)) {\r\n parameterTypes[key] = meta;\r\n }\r\n }\r\n\r\n const request: Record<string, unknown> = {\r\n getMetadata: () => ({\r\n boundParameter: null,\r\n parameterTypes,\r\n operationName,\r\n operationType,\r\n }),\r\n };\r\n\r\n if (params) {\r\n for (const [key, value] of Object.entries(params)) {\r\n request[key] = value;\r\n }\r\n }\r\n\r\n return request;\r\n}\r\n\r\n// Action Factories\r\n\r\n/**\r\n * Create an executor for a bound action (entity-bound) without parameters or typed response.\r\n *\r\n * @param operationName - Custom API unique name (e.g. \"markant_winquote\")\r\n * @param entityLogicalName - Entity logical name (e.g. \"quote\")\r\n */\r\nexport function createBoundAction(\r\n operationName: string,\r\n entityLogicalName: string,\r\n): BoundActionExecutor;\r\n\r\n/**\r\n * Create an executor for a bound action without parameters but with typed response.\r\n *\r\n * @param operationName - Custom API unique name\r\n * @param entityLogicalName - Entity logical name\r\n */\r\nexport function createBoundAction<TResult>(\r\n operationName: string,\r\n entityLogicalName: string,\r\n): BoundActionExecutor<TResult>;\r\n\r\n/**\r\n * Create an executor for a bound action with typed parameters and optional typed response.\r\n *\r\n * @param operationName - Custom API unique name\r\n * @param entityLogicalName - Entity logical name\r\n * @param paramMeta - Parameter metadata map (parameter name to OData type info)\r\n */\r\nexport function createBoundAction<\r\n TParams extends Record<string, unknown>,\r\n TResult = void,\r\n>(\r\n operationName: string,\r\n entityLogicalName: string,\r\n paramMeta: ParameterMetaMap,\r\n): BoundActionWithParamsExecutor<TParams, TResult>;\r\n\r\nexport function createBoundAction<\r\n TParams extends Record<string, unknown>,\r\n TResult = void,\r\n>(\r\n operationName: string,\r\n entityLogicalName: string,\r\n paramMeta?: ParameterMetaMap,\r\n): BoundActionExecutor<TResult> | BoundActionWithParamsExecutor<TParams, TResult> {\r\n return {\r\n async execute(recordId: string, params?: TParams): Promise<TResult extends void ? Response : TResult> {\r\n const req = buildBoundRequest(\r\n operationName, entityLogicalName, OperationType.Action,\r\n recordId, paramMeta, params,\r\n );\r\n const response = await executeRequest(req);\r\n if (!response.ok) {\r\n const errorText = await response.text();\r\n throw new Error(errorText);\r\n }\r\n // Parse JSON when response properties are defined (TResult is not void)\r\n if (response.status !== 204) {\r\n return response.json() as Promise<TResult extends void ? Response : TResult>;\r\n }\r\n return response as TResult extends void ? Response : TResult;\r\n },\r\n request(recordId: string, params?: TParams): Record<string, unknown> {\r\n return buildBoundRequest(\r\n operationName, entityLogicalName, OperationType.Action,\r\n recordId, paramMeta, params,\r\n );\r\n },\r\n };\r\n}\r\n\r\n/**\r\n * Create an executor for an unbound (global) action without parameters or typed response.\r\n *\r\n * @param operationName - Custom API unique name\r\n */\r\nexport function createUnboundAction(\r\n operationName: string,\r\n): UnboundActionExecutor;\r\n\r\n/**\r\n * Create an executor for an unbound action without parameters but with typed response.\r\n *\r\n * @param operationName - Custom API unique name\r\n */\r\nexport function createUnboundAction<TResult>(\r\n operationName: string,\r\n): UnboundActionExecutor<TResult>;\r\n\r\n/**\r\n * Create an executor for an unbound action with typed parameters and optional typed response.\r\n *\r\n * @param operationName - Custom API unique name\r\n * @param paramMeta - Parameter metadata map\r\n */\r\nexport function createUnboundAction<\r\n TParams extends Record<string, unknown>,\r\n TResult = void,\r\n>(\r\n operationName: string,\r\n paramMeta: ParameterMetaMap,\r\n): UnboundActionWithParamsExecutor<TParams, TResult>;\r\n\r\nexport function createUnboundAction<\r\n TParams extends Record<string, unknown>,\r\n TResult = void,\r\n>(\r\n operationName: string,\r\n paramMeta?: ParameterMetaMap,\r\n): UnboundActionExecutor | UnboundActionWithParamsExecutor<TParams, TResult> {\r\n return {\r\n async execute(params?: TParams): Promise<TResult extends void ? Response : TResult> {\r\n const req = buildUnboundRequest(\r\n operationName, OperationType.Action, paramMeta, params,\r\n );\r\n const response = await executeRequest(req);\r\n if (!response.ok) {\r\n const errorText = await response.text();\r\n throw new Error(errorText);\r\n }\r\n if (response.status !== 204) {\r\n return response.json() as Promise<TResult extends void ? Response : TResult>;\r\n }\r\n return response as TResult extends void ? Response : TResult;\r\n },\r\n request(params?: TParams): Record<string, unknown> {\r\n return buildUnboundRequest(\r\n operationName, OperationType.Action, paramMeta, params,\r\n );\r\n },\r\n };\r\n}\r\n\r\n// Function Factories\r\n\r\n/**\r\n * Create an executor for an unbound (global) function with typed response.\r\n *\r\n * @param operationName - Function name (e.g. \"WhoAmI\")\r\n */\r\nexport function createUnboundFunction<TResult>(\r\n operationName: string,\r\n): UnboundFunctionExecutor<TResult> {\r\n return {\r\n async execute(): Promise<TResult> {\r\n const req = buildUnboundRequest(operationName, OperationType.Function);\r\n const response = await executeRequest(req);\r\n if (!response.ok) {\r\n const errorText = await response.text();\r\n throw new Error(errorText);\r\n }\r\n return response.json() as Promise<TResult>;\r\n },\r\n request(): Record<string, unknown> {\r\n return buildUnboundRequest(operationName, OperationType.Function);\r\n },\r\n };\r\n}\r\n\r\n/**\r\n * Create an executor for a bound function with typed response.\r\n *\r\n * @param operationName - Function name\r\n * @param entityLogicalName - Entity logical name\r\n */\r\nexport function createBoundFunction<TResult>(\r\n operationName: string,\r\n entityLogicalName: string,\r\n): BoundFunctionExecutor<TResult> {\r\n return {\r\n async execute(recordId: string): Promise<TResult> {\r\n const req = buildBoundRequest(\r\n operationName, entityLogicalName, OperationType.Function, recordId,\r\n );\r\n const response = await executeRequest(req);\r\n if (!response.ok) {\r\n const errorText = await response.text();\r\n throw new Error(errorText);\r\n }\r\n return response.json() as Promise<TResult>;\r\n },\r\n request(recordId: string): Record<string, unknown> {\r\n return buildBoundRequest(\r\n operationName, entityLogicalName, OperationType.Function, recordId,\r\n );\r\n },\r\n };\r\n}\r\n\r\n// Convenience\r\n\r\n/**\r\n * Execute an async operation with Xrm progress indicator.\r\n *\r\n * Shows a progress spinner before the operation, closes it after,\r\n * and shows an error dialog on failure.\r\n *\r\n * @param message - Progress indicator message (e.g. \"Processing quote...\")\r\n * @param operation - Async function to execute\r\n * @returns The result of the operation\r\n *\r\n * @example\r\n * ```typescript\r\n * await withProgress('Processing quote...', () => WinQuote.execute(recordId));\r\n * ```\r\n */\r\nexport async function withProgress<T>(\r\n message: string,\r\n operation: () => Promise<T>,\r\n): Promise<T> {\r\n Xrm.Utility.showProgressIndicator(message);\r\n try {\r\n return await operation();\r\n } catch (error: unknown) {\r\n const msg = error instanceof Error ? error.message : String(error);\r\n Xrm.Navigation.openErrorDialog({ message: msg });\r\n throw error;\r\n } finally {\r\n Xrm.Utility.closeProgressIndicator();\r\n }\r\n}\r\n","/**\n * @xrmforge/helpers - TypedForm Proxy\n *\n * Creates a proxy around Xrm.FormContext that allows direct property access\n * to form fields. Instead of `form.getAttribute(\"name\").setValue(\"X\")`,\n * write `form.name.setValue(\"X\")`.\n *\n * Works with generated form types from @xrmforge/typegen. Since v0.9.2,\n * typegen generates a `FormTypeInfo` interface per form that bundles\n * Fields, AttributeMap, and ControlMap for reliable type extraction.\n *\n * @example\n * ```typescript\n * import { typedForm } from '@xrmforge/helpers';\n * import type { AccountLMFirmaForm } from '../../generated/forms/account.js';\n *\n * const form = typedForm<AccountLMFirmaForm>(ctx.getFormContext());\n * form.name.getValue(); // string | null (typed)\n * form.revenue.setValue(150000); // NumberAttribute (typed)\n * form.$context.ui.tabs.get(...); // Full FormContext access\n * form.$control('name'); // Control access\n * form.$unsafe('off_form_field'); // Access fields not on the form\n * ```\n */\n\n// ─── FormTypeInfo Protocol ───────────────────────────────────────────────────\n\n/**\n * Protocol interface generated by typegen for each form.\n * Bundles Fields, AttributeMap, and ControlMap so typedForm can extract\n * them reliably without fragile Conditional Type inference on overloads.\n *\n * Generated as: `export interface MyFormTypeInfo { fields: ...; attributes: ...; controls: ...; form: ...; }`\n */\nexport interface FormTypeInfoProtocol {\n fields: string;\n attributes: Record<string, Xrm.Attributes.Attribute>;\n controls: Record<string, Xrm.Controls.Control>;\n form: object;\n}\n\n// ─── Type Extraction ─────────────────────────────────────────────────────────\n\n/**\n * Extract Fields from a Form interface.\n *\n * Strategy: Check if TForm has a companion TypeInfo interface (generated by\n * typegen >= 0.9.2). If so, extract fields directly. Otherwise, fall back\n * to Conditional Type inference on getAttribute (works in same compilation\n * unit but may fail across package boundaries in TS 5.9+).\n */\n/**\n * Type extraction uses duck typing: if TForm has a `fields` property,\n * it's a TypeInfo interface (from typegen >= 0.10.0). Otherwise, fall\n * back to Conditional Type inference on getAttribute overloads.\n *\n * Duck typing (`TForm extends { fields: infer F }`) is more robust than\n * matching against FormTypeInfoProtocol because it doesn't require\n * structural compatibility of attributes/controls/form across packages.\n */\ntype ExtractFields<TForm> =\n TForm extends { fields: infer F extends string } ? F :\n TForm extends { getAttribute<K extends infer F>(name: K): unknown }\n ? F extends string ? F : never\n : never;\n\ntype ExtractAttributeMap<TForm, TFields extends string> =\n TForm extends { attributes: infer A extends Record<string, Xrm.Attributes.Attribute> } ? A :\n { [K in TFields]: TForm extends { getAttribute(name: K): infer R }\n ? R extends Xrm.Attributes.Attribute ? R : Xrm.Attributes.Attribute\n : Xrm.Attributes.Attribute;\n };\n\ntype ExtractControlMap<TForm, TFields extends string> =\n TForm extends { controls: infer C extends Record<string, Xrm.Controls.Control> } ? C :\n { [K in TFields]: TForm extends { getControl(name: K): infer R }\n ? R extends Xrm.Controls.Control ? R : Xrm.Controls.Control\n : Xrm.Controls.Control;\n };\n\ntype ExtractFormContext<TForm> =\n TForm extends { form: infer FC } ? FC :\n TForm extends Xrm.FormContext ? TForm :\n Xrm.FormContext;\n\n// ─── TypedForm Type ──────────────────────────────────────────────────────────\n\n/**\n * TypedForm: proxy type that maps field names to their attribute types.\n *\n * Provides direct property access to form fields (e.g. `form.name` returns\n * the StringAttribute), plus:\n * - `$context` for full FormContext access (ui, data, tabs, getAttribute with addOnChange)\n * - `$control(name)` for typed control access\n * - `$unsafe(name)` for off-form field access (fields loaded by D365 but not on the form)\n */\nexport type TypedForm<\n TForm,\n TFields extends string = ExtractFields<TForm>,\n TAttrMap extends Record<string, Xrm.Attributes.Attribute> = ExtractAttributeMap<TForm, TFields>,\n TCtrlMap extends Record<string, Xrm.Controls.Control> = ExtractControlMap<TForm, TFields>,\n> = {\n /** Direct field access: form.fieldName returns the typed Attribute */\n readonly [K in TFields]: K extends keyof TAttrMap\n ? TAttrMap[K]\n : Xrm.Attributes.Attribute;\n} & {\n /** Access the underlying FormContext for ui, data, tabs, addOnChange, etc. */\n readonly $context: ExtractFormContext<TForm>;\n /** Access a typed control by field name */\n $control<K extends TFields>(name: K): K extends keyof TCtrlMap ? TCtrlMap[K] : Xrm.Controls.Control;\n /**\n * Access an off-form field (loaded by D365 but not on the current form layout).\n * Returns null if the attribute does not exist.\n * Use this for fields like 'lm_genehmigt' that are not in the form definition\n * but are accessible at runtime via formContext.getAttribute().\n */\n $unsafe(name: string): Xrm.Attributes.Attribute | null;\n};\n\n/**\n * Create a typed form proxy around a FormContext.\n *\n * Accepts either a Form interface or a FormTypeInfo interface as type parameter.\n * When using FormTypeInfo (generated by typegen >= 0.9.2), type extraction is\n * guaranteed to work across all TypeScript versions.\n *\n * @example\n * ```typescript\n * // Recommended: use Form interface directly (requires typegen >= 0.9.2 for TypeInfo)\n * const form = typedForm<AccountLMFirmaForm>(ctx.getFormContext());\n *\n * // Alternative: use TypeInfo for explicit type extraction\n * const form = typedForm<AccountLMFirmaFormTypeInfo>(ctx.getFormContext());\n * ```\n *\n * @param formContext - The Xrm.FormContext from executionContext.getFormContext()\n * @returns A proxy with direct typed property access to form fields\n */\nexport function typedForm<TForm>(\n formContext: Xrm.FormContext,\n): TypedForm<TForm> {\n return new Proxy(formContext as unknown as TypedForm<TForm>, {\n get(_target, prop) {\n if (typeof prop !== 'string') {\n return (formContext as unknown as Record<symbol, unknown>)[prop];\n }\n if (prop === '$context') return formContext;\n if (prop === '$control') {\n return (name: string) => formContext.getControl(name);\n }\n if (prop === '$unsafe') {\n return (name: string) => formContext.getAttribute(name);\n }\n const attr = formContext.getAttribute(prop);\n if (attr) return attr;\n return (formContext as unknown as Record<string, unknown>)[prop];\n },\n\n set(_target, prop, _value) {\n throw new TypeError(\n `Cannot assign to '${String(prop)}'. Use form.${String(prop)}.setValue() instead.`,\n );\n },\n\n has(_target, prop) {\n if (typeof prop !== 'string') return false;\n if (prop === '$context' || prop === '$control' || prop === '$unsafe') return true;\n return formContext.getAttribute(prop) !== null;\n },\n });\n}\n\n// ─── normalizeGuid ───────────────────────────────────────────────────────────\n\n/**\n * Normalize a GUID: strip curly braces and lowercase.\n *\n * Use this for GUIDs from sources other than formLookupId():\n * - `formContext.data.entity.getId()` returns GUIDs with braces\n * - WebApi `_value` fields may have braces depending on annotations\n * - Custom API responses may return GUIDs in varying formats\n *\n * formLookupId() already normalizes internally, so this is NOT needed for\n * lookup field access. Only use for getId(), WebApi responses, and comparisons.\n *\n * @param guid - A GUID string, possibly with braces and mixed case\n * @returns Normalized GUID (lowercase, no braces), or empty string if null/empty\n *\n * @example\n * ```typescript\n * const recordId = normalizeGuid(form.$context.data.entity.getId());\n * // \"{A1B2C3D4-...}\" -> \"a1b2c3d4-...\"\n *\n * const currencyId = normalizeGuid(result._transactioncurrencyid_value as string);\n * ```\n */\nexport function normalizeGuid(guid: string | null | undefined): string {\n if (!guid) return '';\n return guid.replace(/[{}]/g, '').toLowerCase();\n}\n\n// ─── Legacy Exports ──────────────────────────────────────────────────────────\n\n/** @deprecated Use ExtractFields<TForm> instead */\nexport type FormFields<TForm> = ExtractFields<TForm>;\n"],"mappings":";AAgCO,SAAS,UAAU,MAAqC;AAC7D,QAAM,SAAS,KAAK,WAAW,KAAK,MAAM,QAAQ,KAAK,CAAC,CAAC,IAAI,KAAK,CAAC,IAAI;AACvE,MAAI,OAAO,WAAW,EAAG,QAAO;AAChC,SAAO,YAAY,OAAO,KAAK,GAAG,CAAC;AACrC;AAyBO,SAAS,YACd,UACA,oBACyD;AACzD,QAAM,MAAM,IAAI,kBAAkB;AAClC,QAAM,KAAK,SAAS,GAAG;AACvB,MAAI,CAAC,GAAI,QAAO;AAEhB,SAAO;AAAA,IACL;AAAA,IACA,MAAO,SAAS,GAAG,GAAG,4CAA4C,KAAgB;AAAA,IAClF,YAAa,SAAS,GAAG,GAAG,2CAA2C,KAAgB;AAAA,EACzF;AACF;AAiBO,SAAS,aACd,UACA,sBACyE;AACzE,QAAM,SAAkF,CAAC;AACzF,aAAW,QAAQ,sBAAsB;AACvC,WAAO,IAAI,IAAI,YAAY,UAAU,IAAI;AAAA,EAC3C;AACA,SAAO;AACT;AAiBO,SAAS,oBACd,UACA,WACe;AACf,SAAQ,SAAS,GAAG,SAAS,4CAA4C,KAAgB;AAC3F;AAiBO,SAAS,aAAa,QAAkB,QAAwB;AACrE,QAAM,QAAkB,CAAC;AACzB,MAAI,OAAO,SAAS,EAAG,OAAM,KAAK,WAAW,OAAO,KAAK,GAAG,CAAC,EAAE;AAC/D,MAAI,OAAQ,OAAM,KAAK,WAAW,MAAM,EAAE;AAC1C,SAAO,MAAM,SAAS,IAAI,IAAI,MAAM,KAAK,GAAG,CAAC,KAAK;AACpD;AAsBO,SAAS,WACd,MACyD;AACzD,QAAM,SAAS,KAAK,SAAS;AAC7B,MAAI,CAAC,UAAU,OAAO,WAAW,EAAG,QAAO;AAC3C,QAAM,Q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,SAAU,QAAO;AACrC,UAAI,SAAS,cAAc,SAAS,cAAc,SAAS,UAAW,QAAO;AAC7E,aAAO,YAAY,aAAa,IAAI,MAAM;AAAA,IAC5C;AAAA,EACF,CAAC;AACH;AA0BO,SAAS,cAAc,MAAyC;AACrE,MAAI,CAAC,KAAM,QAAO;AAClB,SAAO,KAAK,QAAQ,SAAS,EAAE,EAAE,YAAY;AAC/C;","names":["DisplayState","FormNotificationLevel","RequiredLevel","SubmitMode","SaveMode","ClientType","ClientState","OperationType","StructuralProperty","BindingType"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xrmforge/helpers",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.2",
|
|
4
4
|
"description": "Browser-safe runtime helpers for Dynamics 365 form scripts: select(), parseLookup(), typedForm(), Xrm constants, Action/Function executors",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"dynamics-365",
|