VirtualMetric.Custom.Format.ps1xml

<?xml version="1.0" encoding="utf-8"?>
<!--
  Views for the types the hand-written runtime emits. The catalog types' views are in
  VirtualMetric.Format.ps1xml, which the generator writes from sdk/cli/catalog.yaml; when both files define a
  table view for one type, that file's (loaded first) is used, and the list views here still apply.
  Objects keep the API's field names; epoch seconds, durations and positions are derived here, for display
  only. Script blocks run outside the module: they cannot call its private functions.

  Server text is neutralised on its way to the terminal, as the runtime's ConvertTo-VMetricSafeText does for
  messages and the generated views do for every column: a line break becomes a space, and C0 and C1 controls
  other than the tab, and format characters (bidirectional controls among them), are dropped. So a name with
  an escape sequence can write no clipboard (OSC 52), retitle no window and hide no row. The objects keep
  their data as it came; only what is shown changes. A column that joins several values cleans each first.
-->
<Configuration>
  <ViewDefinitions>
    <!--
      A context is shown as a list by default: the console's and the API's addresses are both long, and they
      may be apart. Format-Table picks the compact table below.
    -->
    <View>
      <Name>VirtualMetric.Context</Name>
      <ViewSelectedBy>
        <TypeName>VirtualMetric.Context</TypeName>
      </ViewSelectedBy>
      <ListControl>
        <ListEntries>
          <ListEntry>
            <ListItems>
              <ListItem>
                <Label>Current</Label>
                <ScriptBlock>[bool]$_.IsCurrent</ScriptBlock>
              </ListItem>
              <ListItem>
                <Label>Console</Label>
                <ScriptBlock>[string]$_.ConsoleUrl -replace '[\r\n\p{Zl}\p{Zp}]+', ' ' -replace '[\p{Cc}\p{Cf}-[\t]]'</ScriptBlock>
              </ListItem>
              <ListItem>
                <Label>Api</Label>
                <ScriptBlock>[string]$_.ApiUrl -replace '[\r\n\p{Zl}\p{Zp}]+', ' ' -replace '[\p{Cc}\p{Cf}-[\t]]'</ScriptBlock>
              </ListItem>
              <ListItem>
                <Label>Account</Label>
                <ScriptBlock>[string]$_.Account -replace '[\r\n\p{Zl}\p{Zp}]+', ' ' -replace '[\p{Cc}\p{Cf}-[\t]]'</ScriptBlock>
              </ListItem>
              <ListItem>
                <Label>Tenant</Label>
                <ScriptBlock>[string]$_.TenantName -replace '[\r\n\p{Zl}\p{Zp}]+', ' ' -replace '[\p{Cc}\p{Cf}-[\t]]'</ScriptBlock>
              </ListItem>
              <ListItem>
                <Label>TenantId</Label>
                <ScriptBlock>[string]$_.TenantId -replace '[\r\n\p{Zl}\p{Zp}]+', ' ' -replace '[\p{Cc}\p{Cf}-[\t]]'</ScriptBlock>
              </ListItem>
              <ListItem>
                <PropertyName>AuthMethod</PropertyName>
              </ListItem>
              <ListItem>
                <PropertyName>ExpiresOn</PropertyName>
              </ListItem>
              <ListItem>
                <PropertyName>SkipCertificateCheck</PropertyName>
              </ListItem>
            </ListItems>
          </ListEntry>
        </ListEntries>
      </ListControl>
    </View>

    <View>
      <Name>VirtualMetric.Context.Table</Name>
      <ViewSelectedBy>
        <TypeName>VirtualMetric.Context</TypeName>
      </ViewSelectedBy>
      <TableControl>
        <TableHeaders>
          <TableColumnHeader>
            <Label> </Label>
            <Width>1</Width>
          </TableColumnHeader>
          <TableColumnHeader>
            <Label>Console</Label>
          </TableColumnHeader>
          <TableColumnHeader>
            <Label>Account</Label>
          </TableColumnHeader>
          <TableColumnHeader>
            <Label>Tenant</Label>
          </TableColumnHeader>
          <TableColumnHeader>
            <Label>AuthMethod</Label>
          </TableColumnHeader>
          <TableColumnHeader>
            <Label>ExpiresOn</Label>
          </TableColumnHeader>
        </TableHeaders>
        <TableRowEntries>
          <TableRowEntry>
            <TableColumnItems>
              <TableColumnItem>
                <ScriptBlock>if ($_.IsCurrent) { '*' }</ScriptBlock>
              </TableColumnItem>
              <TableColumnItem>
                <ScriptBlock>[string]$_.ConsoleUrl -replace '[\r\n\p{Zl}\p{Zp}]+', ' ' -replace '[\p{Cc}\p{Cf}-[\t]]'</ScriptBlock>
              </TableColumnItem>
              <TableColumnItem>
                <ScriptBlock>[string]$_.Account -replace '[\r\n\p{Zl}\p{Zp}]+', ' ' -replace '[\p{Cc}\p{Cf}-[\t]]'</ScriptBlock>
              </TableColumnItem>
              <TableColumnItem>
                <ScriptBlock>[string]$_.TenantName -replace '[\r\n\p{Zl}\p{Zp}]+', ' ' -replace '[\p{Cc}\p{Cf}-[\t]]'</ScriptBlock>
              </TableColumnItem>
              <TableColumnItem>
                <PropertyName>AuthMethod</PropertyName>
              </TableColumnItem>
              <TableColumnItem>
                <PropertyName>ExpiresOn</PropertyName>
              </TableColumnItem>
            </TableColumnItems>
          </TableRowEntry>
        </TableRowEntries>
      </TableControl>
    </View>

    <View>
      <Name>VirtualMetric.Tenant</Name>
      <ViewSelectedBy>
        <TypeName>VirtualMetric.Tenant</TypeName>
      </ViewSelectedBy>
      <TableControl>
        <TableHeaders>
          <TableColumnHeader>
            <Label> </Label>
            <Width>1</Width>
          </TableColumnHeader>
          <TableColumnHeader>
            <Label>Name</Label>
          </TableColumnHeader>
          <TableColumnHeader>
            <Label>Id</Label>
          </TableColumnHeader>
          <TableColumnHeader>
            <Label>Main</Label>
          </TableColumnHeader>
          <TableColumnHeader>
            <Label>Delegated</Label>
          </TableColumnHeader>
        </TableHeaders>
        <TableRowEntries>
          <TableRowEntry>
            <TableColumnItems>
              <TableColumnItem>
                <ScriptBlock>if ($_.isCurrent) { '*' }</ScriptBlock>
              </TableColumnItem>
              <TableColumnItem>
                <ScriptBlock>[string]$_.name -replace '[\r\n\p{Zl}\p{Zp}]+', ' ' -replace '[\p{Cc}\p{Cf}-[\t]]'</ScriptBlock>
              </TableColumnItem>
              <TableColumnItem>
                <ScriptBlock>[string]$_.id -replace '[\r\n\p{Zl}\p{Zp}]+', ' ' -replace '[\p{Cc}\p{Cf}-[\t]]'</ScriptBlock>
              </TableColumnItem>
              <TableColumnItem>
                <PropertyName>isMain</PropertyName>
              </TableColumnItem>
              <TableColumnItem>
                <PropertyName>delegated</PropertyName>
              </TableColumnItem>
            </TableColumnItems>
          </TableRowEntry>
        </TableRowEntries>
      </TableControl>
    </View>

    <View>
      <Name>VirtualMetric.Deployment</Name>
      <ViewSelectedBy>
        <TypeName>VirtualMetric.Deployment</TypeName>
      </ViewSelectedBy>
      <TableControl>
        <TableHeaders>
          <TableColumnHeader>
            <Label>Name</Label>
          </TableColumnHeader>
          <TableColumnHeader>
            <Label>Status</Label>
          </TableColumnHeader>
          <TableColumnHeader>
            <Label>Source</Label>
          </TableColumnHeader>
          <TableColumnHeader>
            <Label>CreatedBy</Label>
          </TableColumnHeader>
          <TableColumnHeader>
            <Label>StartedAt</Label>
          </TableColumnHeader>
          <TableColumnHeader>
            <Label>Duration</Label>
          </TableColumnHeader>
          <TableColumnHeader>
            <Label>Resources</Label>
            <Alignment>Right</Alignment>
          </TableColumnHeader>
        </TableHeaders>
        <TableRowEntries>
          <TableRowEntry>
            <TableColumnItems>
              <TableColumnItem>
                <ScriptBlock>[string]$_.name -replace '[\r\n\p{Zl}\p{Zp}]+', ' ' -replace '[\p{Cc}\p{Cf}-[\t]]'</ScriptBlock>
              </TableColumnItem>
              <TableColumnItem>
                <ScriptBlock>[string]$_.status -replace '[\r\n\p{Zl}\p{Zp}]+', ' ' -replace '[\p{Cc}\p{Cf}-[\t]]'</ScriptBlock>
              </TableColumnItem>
              <TableColumnItem>
                <ScriptBlock>[string]$_.source -replace '[\r\n\p{Zl}\p{Zp}]+', ' ' -replace '[\p{Cc}\p{Cf}-[\t]]'</ScriptBlock>
              </TableColumnItem>
              <TableColumnItem>
                <ScriptBlock>[string]$_.createdBy -replace '[\r\n\p{Zl}\p{Zp}]+', ' ' -replace '[\p{Cc}\p{Cf}-[\t]]'</ScriptBlock>
              </TableColumnItem>
              <TableColumnItem>
                <ScriptBlock>if ([long]$_.startedAt -gt 0) { [DateTimeOffset]::FromUnixTimeSeconds([long]$_.startedAt).LocalDateTime }</ScriptBlock>
              </TableColumnItem>
              <TableColumnItem>
                <ScriptBlock>
                  $start = [long]$_.startedAt
                  $end = [long]$_.completedAt
                  if ($end -le 0 -and $_.status -eq 'running') { $end = [DateTimeOffset]::UtcNow.ToUnixTimeSeconds() }
                  if ($start -gt 0 -and $end -ge $start) { '{0:hh\:mm\:ss}' -f [TimeSpan]::FromSeconds($end - $start) }
                </ScriptBlock>
              </TableColumnItem>
              <TableColumnItem>
                <PropertyName>resourceCount</PropertyName>
              </TableColumnItem>
            </TableColumnItems>
          </TableRowEntry>
        </TableRowEntries>
      </TableControl>
    </View>

    <View>
      <Name>VirtualMetric.Deployment.List</Name>
      <ViewSelectedBy>
        <TypeName>VirtualMetric.Deployment</TypeName>
      </ViewSelectedBy>
      <ListControl>
        <ListEntries>
          <ListEntry>
            <ListItems>
              <ListItem>
                <Label>id</Label>
                <ScriptBlock>[string]$_.id -replace '[\r\n\p{Zl}\p{Zp}]+', ' ' -replace '[\p{Cc}\p{Cf}-[\t]]'</ScriptBlock>
              </ListItem>
              <ListItem>
                <Label>name</Label>
                <ScriptBlock>[string]$_.name -replace '[\r\n\p{Zl}\p{Zp}]+', ' ' -replace '[\p{Cc}\p{Cf}-[\t]]'</ScriptBlock>
              </ListItem>
              <ListItem>
                <Label>status</Label>
                <ScriptBlock>[string]$_.status -replace '[\r\n\p{Zl}\p{Zp}]+', ' ' -replace '[\p{Cc}\p{Cf}-[\t]]'</ScriptBlock>
              </ListItem>
              <ListItem>
                <Label>source</Label>
                <ScriptBlock>[string]$_.source -replace '[\r\n\p{Zl}\p{Zp}]+', ' ' -replace '[\p{Cc}\p{Cf}-[\t]]'</ScriptBlock>
              </ListItem>
              <ListItem>
                <Label>createdBy</Label>
                <ScriptBlock>[string]$_.createdBy -replace '[\r\n\p{Zl}\p{Zp}]+', ' ' -replace '[\p{Cc}\p{Cf}-[\t]]'</ScriptBlock>
              </ListItem>
              <ListItem>
                <Label>startedAt</Label>
                <ScriptBlock>if ([long]$_.startedAt -gt 0) { [DateTimeOffset]::FromUnixTimeSeconds([long]$_.startedAt).LocalDateTime }</ScriptBlock>
              </ListItem>
              <ListItem>
                <Label>completedAt</Label>
                <ScriptBlock>if ([long]$_.completedAt -gt 0) { [DateTimeOffset]::FromUnixTimeSeconds([long]$_.completedAt).LocalDateTime }</ScriptBlock>
              </ListItem>
              <ListItem>
                <PropertyName>resourceCount</PropertyName>
              </ListItem>
              <ListItem>
                <Label>error</Label>
                <ScriptBlock>if ($_.error) { ('{0}: {1}' -f $_.error.code, $_.error.message) -replace '[\r\n\p{Zl}\p{Zp}]+', ' ' -replace '[\p{Cc}\p{Cf}-[\t]]' }</ScriptBlock>
              </ListItem>
              <ListItem>
                <PropertyName>restricted</PropertyName>
              </ListItem>
              <ListItem>
                <Label>missingPermissions</Label>
                <ScriptBlock>($_.missingPermissions -join ', ') -replace '[\r\n\p{Zl}\p{Zp}]+', ' ' -replace '[\p{Cc}\p{Cf}-[\t]]'</ScriptBlock>
              </ListItem>
              <ListItem>
                <Label>operations</Label>
                <ScriptBlock>
                  ($_.operations | ForEach-Object {
                    $line = '{0}. {1} {2} ''{3}'': {4}' -f $_.seq, $_.operation, $_.type, $_.name, $_.status
                    if ($_.error) { $line += ' (' + $_.error.code + ': ' + $_.error.message + ')' }
                    $line -replace '[\r\n\p{Zl}\p{Zp}]+', ' ' -replace '[\p{Cc}\p{Cf}-[\t]]'
                  }) -join [Environment]::NewLine
                </ScriptBlock>
              </ListItem>
              <ListItem>
                <Label>outputs</Label>
                <ScriptBlock>if ($null -ne $_.outputs) { ($_.outputs.psobject.Properties | ForEach-Object { ('{0} = {1}' -f $_.Name, $_.Value) -replace '[\r\n\p{Zl}\p{Zp}]+', ' ' -replace '[\p{Cc}\p{Cf}-[\t]]' }) -join [Environment]::NewLine }</ScriptBlock>
              </ListItem>
            </ListItems>
          </ListEntry>
        </ListEntries>
      </ListControl>
    </View>

    <View>
      <Name>VirtualMetric.DeploymentOperation</Name>
      <ViewSelectedBy>
        <TypeName>VirtualMetric.DeploymentOperation</TypeName>
      </ViewSelectedBy>
      <TableControl>
        <TableHeaders>
          <TableColumnHeader>
            <Label>Seq</Label>
            <Alignment>Right</Alignment>
          </TableColumnHeader>
          <TableColumnHeader>
            <Label>Operation</Label>
          </TableColumnHeader>
          <TableColumnHeader>
            <Label>Status</Label>
          </TableColumnHeader>
          <TableColumnHeader>
            <Label>Type</Label>
          </TableColumnHeader>
          <TableColumnHeader>
            <Label>Name</Label>
          </TableColumnHeader>
          <TableColumnHeader>
            <Label>Error</Label>
          </TableColumnHeader>
        </TableHeaders>
        <TableRowEntries>
          <TableRowEntry>
            <TableColumnItems>
              <TableColumnItem>
                <PropertyName>seq</PropertyName>
              </TableColumnItem>
              <TableColumnItem>
                <ScriptBlock>[string]$_.operation -replace '[\r\n\p{Zl}\p{Zp}]+', ' ' -replace '[\p{Cc}\p{Cf}-[\t]]'</ScriptBlock>
              </TableColumnItem>
              <TableColumnItem>
                <ScriptBlock>[string]$_.status -replace '[\r\n\p{Zl}\p{Zp}]+', ' ' -replace '[\p{Cc}\p{Cf}-[\t]]'</ScriptBlock>
              </TableColumnItem>
              <TableColumnItem>
                <ScriptBlock>[string]$_.type -replace '[\r\n\p{Zl}\p{Zp}]+', ' ' -replace '[\p{Cc}\p{Cf}-[\t]]'</ScriptBlock>
              </TableColumnItem>
              <TableColumnItem>
                <ScriptBlock>[string]$_.name -replace '[\r\n\p{Zl}\p{Zp}]+', ' ' -replace '[\p{Cc}\p{Cf}-[\t]]'</ScriptBlock>
              </TableColumnItem>
              <TableColumnItem>
                <ScriptBlock>if ($_.error) { ('{0}: {1}' -f $_.error.code, $_.error.message) -replace '[\r\n\p{Zl}\p{Zp}]+', ' ' -replace '[\p{Cc}\p{Cf}-[\t]]' }</ScriptBlock>
              </TableColumnItem>
            </TableColumnItems>
          </TableRowEntry>
        </TableRowEntries>
      </TableControl>
    </View>

    <View>
      <Name>VirtualMetric.WhatIfChange</Name>
      <ViewSelectedBy>
        <TypeName>VirtualMetric.WhatIfChange</TypeName>
      </ViewSelectedBy>
      <TableControl>
        <TableHeaders>
          <TableColumnHeader>
            <Label>ChangeType</Label>
          </TableColumnHeader>
          <TableColumnHeader>
            <Label>Type</Label>
          </TableColumnHeader>
          <TableColumnHeader>
            <Label>Name</Label>
          </TableColumnHeader>
          <TableColumnHeader>
            <Label>Changes</Label>
          </TableColumnHeader>
          <TableColumnHeader>
            <Label>Error</Label>
          </TableColumnHeader>
        </TableHeaders>
        <TableRowEntries>
          <TableRowEntry>
            <TableColumnItems>
              <TableColumnItem>
                <ScriptBlock>[string]$_.changeType -replace '[\r\n\p{Zl}\p{Zp}]+', ' ' -replace '[\p{Cc}\p{Cf}-[\t]]'</ScriptBlock>
              </TableColumnItem>
              <TableColumnItem>
                <ScriptBlock>[string]$_.type -replace '[\r\n\p{Zl}\p{Zp}]+', ' ' -replace '[\p{Cc}\p{Cf}-[\t]]'</ScriptBlock>
              </TableColumnItem>
              <TableColumnItem>
                <ScriptBlock>[string]$_.name -replace '[\r\n\p{Zl}\p{Zp}]+', ' ' -replace '[\p{Cc}\p{Cf}-[\t]]'</ScriptBlock>
              </TableColumnItem>
              <TableColumnItem>
                <ScriptBlock>(($_.delta | ForEach-Object { $_.path }) -join ', ') -replace '[\r\n\p{Zl}\p{Zp}]+', ' ' -replace '[\p{Cc}\p{Cf}-[\t]]'</ScriptBlock>
              </TableColumnItem>
              <TableColumnItem>
                <ScriptBlock>[string]$_.error -replace '[\r\n\p{Zl}\p{Zp}]+', ' ' -replace '[\p{Cc}\p{Cf}-[\t]]'</ScriptBlock>
              </TableColumnItem>
            </TableColumnItems>
          </TableRowEntry>
        </TableRowEntries>
      </TableControl>
    </View>

    <View>
      <Name>VirtualMetric.WhatIfPropertyChange</Name>
      <ViewSelectedBy>
        <TypeName>VirtualMetric.WhatIfPropertyChange</TypeName>
      </ViewSelectedBy>
      <TableControl>
        <TableHeaders>
          <TableColumnHeader>
            <Label>Path</Label>
          </TableColumnHeader>
          <TableColumnHeader>
            <Label>Before</Label>
          </TableColumnHeader>
          <TableColumnHeader>
            <Label>After</Label>
          </TableColumnHeader>
        </TableHeaders>
        <TableRowEntries>
          <TableRowEntry>
            <TableColumnItems>
              <TableColumnItem>
                <ScriptBlock>[string]$_.path -replace '[\r\n\p{Zl}\p{Zp}]+', ' ' -replace '[\p{Cc}\p{Cf}-[\t]]'</ScriptBlock>
              </TableColumnItem>
              <TableColumnItem>
                <ScriptBlock>(ConvertTo-Json -InputObject $_.before -Depth 10 -Compress) -replace '[\r\n\p{Zl}\p{Zp}]+', ' ' -replace '[\p{Cc}\p{Cf}-[\t]]'</ScriptBlock>
              </TableColumnItem>
              <TableColumnItem>
                <ScriptBlock>(ConvertTo-Json -InputObject $_.after -Depth 10 -Compress) -replace '[\r\n\p{Zl}\p{Zp}]+', ' ' -replace '[\p{Cc}\p{Cf}-[\t]]'</ScriptBlock>
              </TableColumnItem>
            </TableColumnItems>
          </TableRowEntry>
        </TableRowEntries>
      </TableControl>
    </View>

    <View>
      <Name>VirtualMetric.DeploymentValidation</Name>
      <ViewSelectedBy>
        <TypeName>VirtualMetric.DeploymentValidation</TypeName>
      </ViewSelectedBy>
      <ListControl>
        <ListEntries>
          <ListEntry>
            <ListItems>
              <ListItem>
                <PropertyName>valid</PropertyName>
              </ListItem>
              <ListItem>
                <Label>diagnostics</Label>
                <ScriptBlock>($_.diagnostics | ForEach-Object { ('{0} {1} (line {2}, column {3}): {4}' -f $_.severity, $_.code, $_.range.startLine, $_.range.startColumn, $_.message) -replace '[\r\n\p{Zl}\p{Zp}]+', ' ' -replace '[\p{Cc}\p{Cf}-[\t]]' }) -join [Environment]::NewLine</ScriptBlock>
              </ListItem>
              <ListItem>
                <Label>parameters</Label>
                <ScriptBlock>(($_.parameters | ForEach-Object { $_.name }) -join ', ') -replace '[\r\n\p{Zl}\p{Zp}]+', ' ' -replace '[\p{Cc}\p{Cf}-[\t]]'</ScriptBlock>
              </ListItem>
              <ListItem>
                <Label>resources</Label>
                <ScriptBlock>($_.resources | ForEach-Object { ('{0} ({1})' -f $_.symbolicName, $_.type) -replace '[\r\n\p{Zl}\p{Zp}]+', ' ' -replace '[\p{Cc}\p{Cf}-[\t]]' }) -join [Environment]::NewLine</ScriptBlock>
              </ListItem>
              <ListItem>
                <Label>outputs</Label>
                <ScriptBlock>(($_.outputs | ForEach-Object { $_.name }) -join ', ') -replace '[\r\n\p{Zl}\p{Zp}]+', ' ' -replace '[\p{Cc}\p{Cf}-[\t]]'</ScriptBlock>
              </ListItem>
            </ListItems>
          </ListEntry>
        </ListEntries>
      </ListControl>
    </View>

    <View>
      <Name>VirtualMetric.Diagnostic</Name>
      <ViewSelectedBy>
        <TypeName>VirtualMetric.Diagnostic</TypeName>
      </ViewSelectedBy>
      <TableControl>
        <TableHeaders>
          <TableColumnHeader>
            <Label>Severity</Label>
          </TableColumnHeader>
          <TableColumnHeader>
            <Label>Code</Label>
          </TableColumnHeader>
          <TableColumnHeader>
            <Label>Line</Label>
            <Alignment>Right</Alignment>
          </TableColumnHeader>
          <TableColumnHeader>
            <Label>Column</Label>
            <Alignment>Right</Alignment>
          </TableColumnHeader>
          <TableColumnHeader>
            <Label>Message</Label>
          </TableColumnHeader>
        </TableHeaders>
        <TableRowEntries>
          <TableRowEntry>
            <TableColumnItems>
              <TableColumnItem>
                <ScriptBlock>[string]$_.severity -replace '[\r\n\p{Zl}\p{Zp}]+', ' ' -replace '[\p{Cc}\p{Cf}-[\t]]'</ScriptBlock>
              </TableColumnItem>
              <TableColumnItem>
                <ScriptBlock>[string]$_.code -replace '[\r\n\p{Zl}\p{Zp}]+', ' ' -replace '[\p{Cc}\p{Cf}-[\t]]'</ScriptBlock>
              </TableColumnItem>
              <TableColumnItem>
                <ScriptBlock>$_.range.startLine</ScriptBlock>
              </TableColumnItem>
              <TableColumnItem>
                <ScriptBlock>$_.range.startColumn</ScriptBlock>
              </TableColumnItem>
              <TableColumnItem>
                <ScriptBlock>[string]$_.message -replace '[\r\n\p{Zl}\p{Zp}]+', ' ' -replace '[\p{Cc}\p{Cf}-[\t]]'</ScriptBlock>
              </TableColumnItem>
            </TableColumnItems>
          </TableRowEntry>
        </TableRowEntries>
      </TableControl>
    </View>
  </ViewDefinitions>
</Configuration>