Skip to content

Commit

Permalink
Made #44 optional
Browse files Browse the repository at this point in the history
  • Loading branch information
magesoe committed Mar 2, 2018
1 parent 6c22f99 commit 25f58ab
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 12 deletions.
5 changes: 5 additions & 0 deletions src/XrmDefinitelyTyped/CommandLine/Arguments.fs
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,11 @@ type Args private () =
description="Comma-separated list of named semicolon-separated lists of form GUIDs that should be intersected. "
+ "Example: 'MyAccountIntersect: 284FF02B-BDD1-4BB0-9BCF-6CFDBDA130D4;16068A3B-D428-4430-AEF6-397CE2AEFE07, MyContactIntersect: F4B3397C-C1A5-40BE-89DD-CEA5F7064D1D;824CFA3C-3EB4-4746-BA3C-7F1DFCA114C0'"
required=false }

{ command="generateMappings"
altCommands=["gm"]
description="Set to true if attribute and control mappings should be generated"
required=false }
]

static member connectionArgs = [
Expand Down
1 change: 1 addition & 0 deletions src/XrmDefinitelyTyped/CommandLine/Program.fs
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ let getGenerationSettings parsedArgs =
webNs = getArg parsedArgs "web" nsSanitizer
viewNs = getArg parsedArgs "views" nsSanitizer
formIntersects = formIntersects
generateMappings = getArg parsedArgs "generateMappings" parseBoolish ?| false
}


Expand Down
20 changes: 12 additions & 8 deletions src/XrmDefinitelyTyped/CreateTypeScript/CreateFormDts.fs
Original file line number Diff line number Diff line change
Expand Up @@ -183,14 +183,18 @@ let getControlFuncs (controls: XrmFormControl list) (crmVersion: Version)=


/// Generate internal namespace for keeping track all the collections.
let getFormNamespace (form: XrmForm) crmVersion =
let getFormNamespace (form: XrmForm) crmVersion generateMappings =
let baseInterfaces =
[ getAttributeCollection form.attributes
getControlCollection form.controls crmVersion
getTabCollection form.tabs ]
Namespace.Create(form.name,
interfaces =
[ getAttributeCollection form.attributes
getAttributeCollectionMap form.attributes
getControlCollection form.controls crmVersion
getControlCollectionMap form.controls crmVersion
getTabCollection form.tabs ],
(if generateMappings then
baseInterfaces @
[getAttributeCollectionMap form.attributes
getControlCollectionMap form.controls crmVersion]
else baseInterfaces),
namespaces =
[ Namespace.Create("Tabs", interfaces = getSectionCollections form.tabs) ])

Expand All @@ -209,7 +213,7 @@ let getFormInterface (form: XrmForm) crmVersion =

/// Generate the namespace containing all the form interface and internal
/// namespaces for collections.
let getFormDts (form: XrmForm) crmVersion =
let getFormDts (form: XrmForm) crmVersion generateMappings =
let nsName =
sprintf "Form.%s%s"
(form.entityName |> Utility.sanitizeString)
Expand All @@ -220,7 +224,7 @@ let getFormDts (form: XrmForm) crmVersion =
Namespace.Create(
nsName,
declare = true,
namespaces = [ getFormNamespace form crmVersion],
namespaces = [ getFormNamespace form crmVersion generateMappings],
interfaces = [ getFormInterface form crmVersion])
|> nsToString

1 change: 1 addition & 0 deletions src/XrmDefinitelyTyped/Domain.fs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ type XdtGenerationSettings = {
webNs: OptionalNamespace
viewNs: OptionalNamespace
formIntersects: FormIntersect [] option
generateMappings: bool
}

type EntityName = string
Expand Down
4 changes: 2 additions & 2 deletions src/XrmDefinitelyTyped/Generation/FileGeneration.fs
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ let generateWebEntityDefs ns state =
defs

/// Generate the Form definitions
let generateFormDefs state crmVersion =
let generateFormDefs state crmVersion generateMappings =
printf "Generation Form definitions..."
let getFormType xrmForm = xrmForm.formType ?|> sprintf "/%s" ?| ""

Expand All @@ -263,7 +263,7 @@ let generateFormDefs state crmVersion =
|> Array.concat
|> Array.Parallel.map (fun xrmForm ->
let path = sprintf "%s/Form/%s%s" state.outputDir xrmForm.entityName (getFormType xrmForm)
let lines = getFormDts xrmForm crmVersion
let lines = getFormDts xrmForm crmVersion generateMappings
sprintf "%s/%s.d.ts" path xrmForm.name, lines)

printfn "Done!"
Expand Down
2 changes: 1 addition & 1 deletion src/XrmDefinitelyTyped/Generation/GenerationMain.fs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ let generateFromRaw gSettings rawState =
let defs =
seq {
yield! generateEnumDefs data
if not gSettings.skipForms then yield! generateFormDefs data crmVersion
if not gSettings.skipForms then yield! generateFormDefs data crmVersion gSettings.generateMappings

match crmVersion .>= (8,2,0,0) with
| true ->
Expand Down
3 changes: 2 additions & 1 deletion src/XrmDefinitelyTyped/XrmDefinitelyTyped.fs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ open GenerationMain

type XrmDefinitelyTyped private () =

static member GenerateFromCrm(url, username, password, ?domain, ?ap, ?outDir, ?jsLib, ?tsLib, ?entities, ?solutions, ?crmVersion, ?useDeprecated, ?skipForms, ?oneFile, ?restNs, ?webNs, ?viewNs, ?formIntersects) =
static member GenerateFromCrm(url, username, password, ?domain, ?ap, ?outDir, ?jsLib, ?tsLib, ?entities, ?solutions, ?crmVersion, ?useDeprecated, ?skipForms, ?oneFile, ?restNs, ?webNs, ?viewNs, ?formIntersects, ?generateMappings) =
let xrmAuth =
{ XrmAuthentication.url = Uri(url)
username = username
Expand All @@ -34,6 +34,7 @@ type XrmDefinitelyTyped private () =
webNs = webNs
viewNs = viewNs
formIntersects = formIntersects
generateMappings = generateMappings ?| false
}

XrmDefinitelyTyped.GenerateFromCrm(xrmAuth, rSettings, gSettings)
Expand Down

0 comments on commit 25f58ab

Please sign in to comment.