@xrmforge/typegen 0.2.0 → 0.3.0
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 +33 -1
- package/dist/index.js +37 -1
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1362,6 +1362,36 @@ declare function generateEntityFieldsEnum(info: EntityTypeInfo, options?: Entity
|
|
|
1362
1362
|
*/
|
|
1363
1363
|
declare function generateEntityNavigationProperties(info: EntityTypeInfo, options?: EntityFieldsGeneratorOptions): string;
|
|
1364
1364
|
|
|
1365
|
+
/**
|
|
1366
|
+
* @xrmforge/typegen - Entity Names Enum Generator
|
|
1367
|
+
*
|
|
1368
|
+
* Generates a single const enum with all entity logical names.
|
|
1369
|
+
* Eliminates raw strings in Xrm.WebApi calls.
|
|
1370
|
+
*
|
|
1371
|
+
* Output pattern:
|
|
1372
|
+
* ```typescript
|
|
1373
|
+
* declare namespace XrmForge {
|
|
1374
|
+
* const enum EntityNames {
|
|
1375
|
+
* Account = 'account',
|
|
1376
|
+
* Contact = 'contact',
|
|
1377
|
+
* Lead = 'lead',
|
|
1378
|
+
* }
|
|
1379
|
+
* }
|
|
1380
|
+
* ```
|
|
1381
|
+
*/
|
|
1382
|
+
interface EntityNamesGeneratorOptions {
|
|
1383
|
+
/** Namespace (default: "XrmForge") */
|
|
1384
|
+
namespace?: string;
|
|
1385
|
+
}
|
|
1386
|
+
/**
|
|
1387
|
+
* Generate a const enum mapping entity PascalCase names to logical names.
|
|
1388
|
+
*
|
|
1389
|
+
* @param entityNames - Array of entity logical names
|
|
1390
|
+
* @param options - Generator options
|
|
1391
|
+
* @returns TypeScript declaration string
|
|
1392
|
+
*/
|
|
1393
|
+
declare function generateEntityNamesEnum(entityNames: string[], options?: EntityNamesGeneratorOptions): string;
|
|
1394
|
+
|
|
1365
1395
|
/**
|
|
1366
1396
|
* @xrmforge/typegen - Web API Helper Functions
|
|
1367
1397
|
*
|
|
@@ -1781,6 +1811,8 @@ interface GenerateConfig {
|
|
|
1781
1811
|
generateOptionSets?: boolean;
|
|
1782
1812
|
/** Whether to generate Custom API Action/Function executors (default: false) */
|
|
1783
1813
|
generateActions?: boolean;
|
|
1814
|
+
/** Filter Custom APIs by uniquename prefix (e.g. "markant_"). Only APIs matching the prefix are generated. */
|
|
1815
|
+
actionsFilter?: string;
|
|
1784
1816
|
/**
|
|
1785
1817
|
* Whether to use metadata cache for faster re-generation.
|
|
1786
1818
|
* @alpha Not yet implemented. Setting this to true will throw a ConfigError.
|
|
@@ -1880,4 +1912,4 @@ declare class TypeGenerationOrchestrator {
|
|
|
1880
1912
|
private getPicklistAttributes;
|
|
1881
1913
|
}
|
|
1882
1914
|
|
|
1883
|
-
export { type ActionGeneratorOptions, ApiRequestError, type AttributeMetadata, type AuthConfig, type AuthMethod, AuthenticationError, BindingType, type BoundActionExecutor, type BoundActionWithParamsExecutor, type BoundFunctionExecutor, 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 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, 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 };
|
|
1915
|
+
export { type ActionGeneratorOptions, ApiRequestError, type AttributeMetadata, type AuthConfig, type AuthMethod, AuthenticationError, BindingType, type BoundActionExecutor, type BoundActionWithParamsExecutor, type BoundFunctionExecutor, 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 };
|
package/dist/index.js
CHANGED
|
@@ -2169,6 +2169,24 @@ function generateEntityNavigationProperties(info, options = {}) {
|
|
|
2169
2169
|
return lines.join("\n");
|
|
2170
2170
|
}
|
|
2171
2171
|
|
|
2172
|
+
// src/generators/entity-names-generator.ts
|
|
2173
|
+
function generateEntityNamesEnum(entityNames, options = {}) {
|
|
2174
|
+
const namespace = options.namespace ?? "XrmForge";
|
|
2175
|
+
const sorted = [...entityNames].sort();
|
|
2176
|
+
const lines = [];
|
|
2177
|
+
lines.push(`declare namespace ${namespace} {`);
|
|
2178
|
+
lines.push(" /** Entity logical names for Xrm.WebApi calls (compile-time only, zero runtime) */");
|
|
2179
|
+
lines.push(" const enum EntityNames {");
|
|
2180
|
+
for (const name of sorted) {
|
|
2181
|
+
const pascal = toPascalCase(name);
|
|
2182
|
+
lines.push(` ${pascal} = '${name}',`);
|
|
2183
|
+
}
|
|
2184
|
+
lines.push(" }");
|
|
2185
|
+
lines.push("}");
|
|
2186
|
+
lines.push("");
|
|
2187
|
+
return lines.join("\n");
|
|
2188
|
+
}
|
|
2189
|
+
|
|
2172
2190
|
// src/generators/webapi-helpers.ts
|
|
2173
2191
|
function select(...fields) {
|
|
2174
2192
|
if (fields.length === 0) return "";
|
|
@@ -2739,6 +2757,7 @@ var TypeGenerationOrchestrator = class {
|
|
|
2739
2757
|
generateForms: config.generateForms ?? true,
|
|
2740
2758
|
generateOptionSets: config.generateOptionSets ?? true,
|
|
2741
2759
|
generateActions: config.generateActions ?? false,
|
|
2760
|
+
actionsFilter: config.actionsFilter ?? "",
|
|
2742
2761
|
useCache: config.useCache ?? false,
|
|
2743
2762
|
cacheDir: config.cacheDir ?? ".xrmforge/cache",
|
|
2744
2763
|
namespacePrefix: config.namespacePrefix ?? "XrmForge"
|
|
@@ -2815,7 +2834,13 @@ var TypeGenerationOrchestrator = class {
|
|
|
2815
2834
|
}
|
|
2816
2835
|
if (this.config.generateActions && !signal?.aborted) {
|
|
2817
2836
|
this.logger.info("Fetching Custom APIs...");
|
|
2818
|
-
|
|
2837
|
+
let customApis = await metadataClient.getCustomApis();
|
|
2838
|
+
if (this.config.actionsFilter) {
|
|
2839
|
+
const prefix = this.config.actionsFilter.toLowerCase();
|
|
2840
|
+
const before = customApis.length;
|
|
2841
|
+
customApis = customApis.filter((api) => api.api.uniquename.toLowerCase().startsWith(prefix));
|
|
2842
|
+
this.logger.info(`Filtered Custom APIs by prefix "${this.config.actionsFilter}": ${before} -> ${customApis.length}`);
|
|
2843
|
+
}
|
|
2819
2844
|
if (customApis.length > 0) {
|
|
2820
2845
|
const importPath = "@xrmforge/typegen";
|
|
2821
2846
|
const grouped = groupCustomApis(customApis);
|
|
@@ -2854,6 +2879,16 @@ var TypeGenerationOrchestrator = class {
|
|
|
2854
2879
|
this.logger.info("No Custom APIs found");
|
|
2855
2880
|
}
|
|
2856
2881
|
}
|
|
2882
|
+
if (this.config.entities.length > 0) {
|
|
2883
|
+
const entityNamesContent = generateEntityNamesEnum(this.config.entities, {
|
|
2884
|
+
namespace: this.config.namespacePrefix
|
|
2885
|
+
});
|
|
2886
|
+
allFiles.push({
|
|
2887
|
+
relativePath: "entity-names.d.ts",
|
|
2888
|
+
content: addGeneratedHeader(entityNamesContent),
|
|
2889
|
+
type: "entity"
|
|
2890
|
+
});
|
|
2891
|
+
}
|
|
2857
2892
|
if (allFiles.length > 0) {
|
|
2858
2893
|
const indexContent = generateBarrelIndex(allFiles);
|
|
2859
2894
|
const indexFile = {
|
|
@@ -3025,6 +3060,7 @@ export {
|
|
|
3025
3060
|
generateEntityFieldsEnum,
|
|
3026
3061
|
generateEntityForms,
|
|
3027
3062
|
generateEntityInterface,
|
|
3063
|
+
generateEntityNamesEnum,
|
|
3028
3064
|
generateEntityNavigationProperties,
|
|
3029
3065
|
generateEntityOptionSets,
|
|
3030
3066
|
generateEnumMembers,
|