Skip to content

Commit b6e330b

Browse files
committed
Add directives to enable piping of cmdlets.
1 parent 1843756 commit b6e330b

File tree

4 files changed

+49
-13
lines changed

4 files changed

+49
-13
lines changed

src/Authentication/Authentication/Microsoft.Graph.Authentication.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@
2222
</ItemGroup>
2323
<ItemGroup>
2424
<PackageReference Include="Microsoft.Graph.Auth" Version="1.0.0-preview.3" />
25-
<PackageReference Include="Microsoft.Graph.Core" Version="1.19.0" />
26-
<PackageReference Include="Microsoft.Identity.Client" Version="4.8.0" />
25+
<PackageReference Include="Microsoft.Graph.Core" Version="1.20.0" />
26+
<PackageReference Include="Microsoft.Identity.Client" Version="4.8.2" />
2727
<PackageReference Include="PowerShellStandard.Library" Version="5.1.0" />
2828
<PackageReference Include="System.IdentityModel.Tokens.Jwt" Version="5.6.0" />
2929
<PackageReference Include="System.Security.Cryptography.ProtectedData" Version="4.7.0" />

src/Authentication/Authentication/Microsoft.Graph.Authentication.nuspec

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
<file src="bin/Microsoft.Graph.Auth.dll" target="bin" />
2626
<file src="bin/Microsoft.Graph.Core.dll" target="bin" />
2727
<file src="bin/Microsoft.Identity.Client.dll" target="bin" />
28+
<file src="bin/System.IdentityModel.Tokens.Jwt.dll" target="bin" />
2829
<file src="bin/PreloadAssemblies/System.Security.Cryptography.ProtectedData.dll" target="bin/PreloadAssemblies" />
2930
</files>
3031
</package>

src/readme.graph.md

Lines changed: 41 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ prefix: Mg
2727
module-name: Microsoft.Graph.$(service-name)
2828
subject-prefix: $(service-name)
2929
namespace: Microsoft.Graph.PowerShell
30+
sanitize-names: false
3031
```
3132
3233
> Folders
@@ -51,7 +52,9 @@ directive:
5152
- microsoft.graph.post
5253
- microsoft.graph.sectionGroup
5354
- microsoft.graph.team
54-
# Formart cmdlet response.
55+
- microsoft.graph.recipient
56+
57+
# Format cmdlet response.
5558
- where:
5659
model-name: MicrosoftGraphUser
5760
set:
@@ -289,13 +292,41 @@ directive:
289292
set:
290293
verb: Get
291294
subject: $2$1
292-
293-
# Alias entityIds as Ids
294-
- where:
295-
verb: Get|Remove
296-
subject: (.*)
297-
parameter-name: Id$
298-
set:
299-
alias:
300-
- Id
295+
# Add AfterToJson
296+
- from: source-file-csharp
297+
where: $
298+
transform: >
299+
if (!$documentPath.match(/generated%5Capi%5CModels%5CMicrosoftGraph\w*.cs/gm))
300+
{
301+
return $;
302+
} else {
303+
let regexPattern = /^\s*public\s*partial\s*class\s*MicrosoftGraph(?<EntityName>.*):$/gm;
304+
let regexArray;
305+
while ((regexArray = regexPattern.exec($)) !== null) {
306+
if (regexArray['groups'] != null)
307+
{
308+
let EntityName = regexArray['groups'].EntityName.trim();
309+
let newEntityId = EntityName + 'Id';
310+
let newEntityIdPropRegex = new RegExp("^\\s*public\\s*string\\s*"+newEntityId+"\\.*","gm");
311+
let existingIdPropRegex = /(^\s*)(public\s*string\s*Id\s.*)/gm;
312+
if ((!$.match(newEntityIdPropRegex)) && $.match(existingIdPropRegex) && (newEntityId != "DirectoryObjectId") && (newEntityId != "EntityId") && (newEntityId != "BaseItemId")) {
313+
$ = $.replace(existingIdPropRegex, '$1$2\n$1partial void AfterToJson(ref Microsoft.Graph.PowerShell.Runtime.Json.JsonObject container, Microsoft.Graph.PowerShell.Runtime.SerializationMode serializationMode) { if (serializationMode == Microsoft.Graph.PowerShell.Runtime.SerializationMode.IncludeAll) { AddIf(null != this.Id ? (Microsoft.Graph.PowerShell.Runtime.Json.JsonNode)new Microsoft.Graph.PowerShell.Runtime.Json.JsonString(this.Id) : null, "'+ EntityName.toLowerCase() +'-id", container.Add); }\n}\n');
314+
}
315+
}
316+
}
317+
return $;
318+
}
319+
- from: source-file-csharp
320+
where: $
321+
transform: >
322+
if (!$documentPath.match(/generated%5Capi%5CModels%5CMicrosoftGraph\w*.json.cs/gm))
323+
{
324+
return $;
325+
} else {
326+
let afterJsonDeclarationRegex = /(^\s*)(partial\s*void\s*AfterFromJson\s*\(Microsoft.Graph.PowerShell.Runtime.Json.JsonObject\s*json\s*\);$)/gm
327+
$ = $.replace(afterJsonDeclarationRegex, '$1$2\n$1partial void AfterToJson(ref Microsoft.Graph.PowerShell.Runtime.Json.JsonObject container, Microsoft.Graph.PowerShell.Runtime.SerializationMode serializationMode);\n');
328+
let afterJsonRegex = /(^\s*)(AfterToJson\(ref\s*container\s*\);$)/gm
329+
$ = $.replace(afterJsonRegex, '$1$2\n$1AfterToJson(ref container, serializationMode);\n');
330+
return $;
331+
}
301332
```

tools/GenerateModules.ps1

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ Install-Module powershell-yaml -Force
3030

3131
$GraphVersion = "v1.0"
3232
if ($BetaGraphVersion) {
33-
$GraphVersion = "Beta"
33+
$GraphVersion = "beta"
3434
}
3535
$ModulePrefix = "Microsoft.Graph"
3636
$ModulesOutputDir = Join-Path $PSScriptRoot "..\src\$GraphVersion\"
@@ -129,6 +129,10 @@ $ModuleMapping.Keys | ForEach-Object {
129129
else {
130130
& $BuildModulePS1 -Module $ModuleName -ModulePrefix $ModulePrefix -GraphVersion $GraphVersion -ModuleVersion $ModuleVersion -ModulePreviewNumber $ModulePreviewNumber -RequiredModules $AuthenticationModule -ReleaseNotes $ModuleReleaseNotes
131131
}
132+
133+
if ($LASTEXITCODE) {
134+
Write-Error "Failed to build '$ModuleName' module."
135+
}
132136
}
133137

134138
if ($Pack) {

0 commit comments

Comments
 (0)