@@ -7,59 +7,49 @@ open IntermediateRepresentation
77open InterpretOptionSetMetadata
88open Microsoft.Xrm .Sdk .Metadata
99
10-
11- let toSome convertFunc ( nullable : System.Nullable < 'a >) =
12- match nullable.HasValue with
13- | true -> nullable.GetValueOrDefault() |> convertFunc
14- | false -> TsType.Any
1510
1611let typeConv = function
17- | AttributeTypeCode.Boolean -> TsType.Boolean
18- | AttributeTypeCode.DateTime -> TsType.Date
12+ | XrmAttributeType.ManagedProperty
13+ | XrmAttributeType.Boolean -> TsType.Boolean
14+ | XrmAttributeType.DateTime -> TsType.Date
1915
20- | AttributeTypeCode .Memo
21- | AttributeTypeCode .EntityName
22- | AttributeTypeCode .String -> TsType.String
23-
24- | AttributeTypeCode .Integer
25- | AttributeTypeCode .Double
26- | AttributeTypeCode .BigInt
27- | AttributeTypeCode .Money
28- | AttributeTypeCode .Picklist
29- | AttributeTypeCode .State
30- | AttributeTypeCode .Status -> TsType.Number
16+ | XrmAttributeType .Memo
17+ | XrmAttributeType .EntityName
18+ | XrmAttributeType .String -> TsType.String
19+
20+ | XrmAttributeType .Integer
21+ | XrmAttributeType .Double
22+ | XrmAttributeType .BigInt
23+ | XrmAttributeType .Money
24+ | XrmAttributeType .Picklist
25+ | XrmAttributeType .State
26+ | XrmAttributeType .Status -> TsType.Number
3127 | _ -> TsType.Any
3228
33- let interpretVirtualAttribute ( a : AttributeMetadata ) ( options : OptionSet option ) =
34- match a with
35- | :? MultiSelectPicklistAttributeMetadata -> Some ( TsType.Custom $" {ENUM_NS}.{options.Value.name}" , SpecialType.MultiSelectOptionSet)
36- | _ -> None
37-
38-
39- let interpretNormalAttribute aType ( a : AttributeMetadata ) ( options : OptionSet option ) =
29+ let interpretNormalAttribute aType ( options : OptionSet option ) =
4030 match aType with
41- | AttributeTypeCode .Money -> TsType.Number, SpecialType.Money
31+ | XrmAttributeType .Money -> TsType.Number, SpecialType.Money
4232
43- | AttributeTypeCode.Picklist
44- | AttributeTypeCode.State
45- | AttributeTypeCode.Status -> TsType.Custom $" {ENUM_NS}.{options.Value.name}" , SpecialType.OptionSet
46-
47- | AttributeTypeCode.Lookup
48- | AttributeTypeCode.PartyList
49- | AttributeTypeCode.Customer
50- | AttributeTypeCode.Owner -> TsType.String, SpecialType.EntityReference
33+ | XrmAttributeType.MultiSelectPicklist -> TsType.Custom $" {ENUM_NS}.{options.Value.name}" , SpecialType.MultiSelectOptionSet
34+ | XrmAttributeType.Picklist
35+ | XrmAttributeType.State
36+ | XrmAttributeType.Status -> TsType.Custom $" {ENUM_NS}.{options.Value.name}" , SpecialType.OptionSet
37+
38+ | XrmAttributeType.Lookup
39+ | XrmAttributeType.PartyList
40+ | XrmAttributeType.Customer
41+ | XrmAttributeType.Owner -> TsType.String, SpecialType.EntityReference
5142
52- | AttributeTypeCode.Uniqueidentifier
53- -> TsType.String, SpecialType.Guid
43+ | XrmAttributeType.Uniqueidentifier -> TsType.String, SpecialType.Guid
5444
55- | AttributeTypeCode .Decimal -> toSome typeConv a.AttributeType , SpecialType.Decimal
56- | _ -> toSome typeConv a.AttributeType , SpecialType.Default
45+ | XrmAttributeType .Decimal -> typeConv aType , SpecialType.Decimal
46+ | _ -> typeConv aType , SpecialType.Default
5747
5848
5949let interpretAttribute ( nameMap : Map < string , EntityInfo >) labelMapping ( a : AttributeMetadata ) =
60- let aType = a.AttributeType.GetValueOrDefault ()
50+ let aType = XrmAttributeType.fromDisplayName a.AttributeTypeName
6151 if a.AttributeOf <> null ||
62- ( aType = AttributeTypeCode .Virtual && a.AttributeTypeName <> AttributeTypeDisplayName.MultiSelectPicklistType ) ||
52+ aType = XrmAttributeType .Virtual ||
6353 a.LogicalName.StartsWith( " yomi" ) then None, None
6454 else
6555
@@ -81,26 +71,20 @@ let interpretAttribute (nameMap: Map<string, EntityInfo>) labelMapping (a: Attri
8171 |> Some
8272 | _ -> None
8373
84- let vTypeOption =
85- match aType with
86- | AttributeTypeCode.Virtual -> interpretVirtualAttribute a options
87- | _ -> Some ( interpretNormalAttribute aType a options)
74+ let vType , sType = interpretNormalAttribute aType options
8875
89- match vTypeOption with
90- | None -> None, None
91- | Some ( vType, sType) ->
92- options, Some {
93- XrmAttribute.schemaName = a.SchemaName
94- logicalName = a.LogicalName
95- varType = vType
96- specialType = sType
97- colType = XrmAttributeType.fromDisplayName a.AttributeTypeName
98- targetEntitySets = targetEntitySets
99- readable = a.IsValidForRead.GetValueOrDefault( false )
100- createable = a.IsValidForCreate.GetValueOrDefault( false )
101- updateable = a.IsValidForUpdate.GetValueOrDefault( false )
102- displayName = getLabel a.DisplayName
103- }
76+ options, Some {
77+ XrmAttribute.schemaName = a.SchemaName
78+ logicalName = a.LogicalName
79+ varType = vType
80+ specialType = sType
81+ colType = aType
82+ targetEntitySets = targetEntitySets
83+ readable = a.IsValidForRead.GetValueOrDefault( false )
84+ createable = a.IsValidForCreate.GetValueOrDefault( false )
85+ updateable = a.IsValidForUpdate.GetValueOrDefault( false )
86+ displayName = getLabel a.DisplayName
87+ }
10488
10589let sanitizeNavigationProptertyName string =
10690 if string = null then " navigationPropertyNameNotDefined"
0 commit comments